From: Holger Schemel Date: Sat, 2 Jan 2021 01:17:02 +0000 (+0100) Subject: improved command to automatically patch tapes X-Git-Tag: 4.2.2.1~19 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=d51197e00ec619213ee9c09714bafe855774ae8c;p=rocksndiamonds.git improved command to automatically patch tapes --- diff --git a/src/tape.c b/src/tape.c index 70791579..d6f89455 100644 --- a/src/tape.c +++ b/src/tape.c @@ -1493,14 +1493,14 @@ static boolean PatchTape(struct TapeInfo *tape, char *mode) return FALSE; } - byte property_bits = tape->property_bits; + boolean unpatch_tape = FALSE; + boolean use_property_bit = FALSE; byte property_bitmask = 0; - boolean set_property_bit = TRUE; if (strSuffix(mode, ":0") || strSuffix(mode, ":off") || strSuffix(mode, ":clear")) - set_property_bit = FALSE; + unpatch_tape = TRUE; if (strEqual(mode, "em_random_bug") || strPrefix(mode, "em_random_bug:")) { @@ -1514,6 +1514,8 @@ static boolean PatchTape(struct TapeInfo *tape, char *mode) } property_bitmask = TAPE_PROPERTY_EM_RANDOM_BUG; + + use_property_bit = TRUE; } else { @@ -1522,22 +1524,29 @@ static boolean PatchTape(struct TapeInfo *tape, char *mode) return FALSE; } - if (set_property_bit) - property_bits |= property_bitmask; - else - property_bits &= ~property_bitmask; - - if (property_bits == tape->property_bits) + // patching tapes using property bits may be used for several patch modes + if (use_property_bit) { - Print("Tape already patched for '%s'!\n", mode); + byte property_bits = tape->property_bits; + boolean set_property_bit = (unpatch_tape ? FALSE : TRUE); - return FALSE; + if (set_property_bit) + property_bits |= property_bitmask; + else + property_bits &= ~property_bitmask; + + if (property_bits == tape->property_bits) + { + Print("Tape already patched for '%s'!\n", mode); + + return FALSE; + } + + tape->property_bits = property_bits; } Print("Patching for '%s' ... ", mode); - tape->property_bits = property_bits; - return TRUE; }