diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/deh_cheat.c | 20 | ||||
-rw-r--r-- | src/deh_main.c | 14 | ||||
-rw-r--r-- | src/deh_main.h | 1 | ||||
-rw-r--r-- | src/m_cheat.h | 2 |
4 files changed, 35 insertions, 2 deletions
diff --git a/src/deh_cheat.c b/src/deh_cheat.c index 28f32572..f501adbf 100644 --- a/src/deh_cheat.c +++ b/src/deh_cheat.c @@ -108,10 +108,28 @@ static void DEH_CheatParseLine(deh_context_t *context, char *line, void *tag) i = 0; - while (i<cheat->seq->sequence_len && unsvalue[i] != 0 && unsvalue[i] != 0xff) + while (unsvalue[i] != 0 && unsvalue[i] != 0xff) { + // If the cheat length exceeds the Vanilla limit, stop. This + // does not apply if we have the limit turned off. + + if (!deh_allow_long_cheats && i >= cheat->seq->sequence_len) + { + DEH_Warning(context, "Cheat sequence longer than supported by " + "Vanilla dehacked"); + break; + } + cheat->seq->sequence[i] = unsvalue[i]; ++i; + + // Absolute limit - don't exceed + + if (i >= MAX_CHEAT_LEN - cheat->seq->parameter_chars) + { + DEH_Error(context, "Cheat sequence too long!"); + return; + } } cheat->seq->sequence[i] = '\0'; diff --git a/src/deh_main.c b/src/deh_main.c index e4ae7251..3ace70e5 100644 --- a/src/deh_main.c +++ b/src/deh_main.c @@ -63,6 +63,10 @@ extern deh_section_t deh_section_weapon; boolean deh_allow_long_strings = false; +// If true, we can do cheat replacements longer than the originals. + +boolean deh_allow_long_cheats = false; + // // List of section types: // @@ -246,6 +250,15 @@ static void DEH_ParseComment(char *comment) { deh_allow_long_strings = true; } + + // Allow magic comments to allow longer cheat replacements than + // those permitted by DOS dehacked. This is also for Chex + // Quest. + + if (strstr(comment, "*allow-long-cheats*") != NULL) + { + deh_allow_long_cheats = true; + } } // Parses a dehacked file by reading from the context @@ -265,6 +278,7 @@ static void DEH_ParseContext(deh_context_t *context) } deh_allow_long_strings = false; + deh_allow_long_cheats = false; // Read the file diff --git a/src/deh_main.h b/src/deh_main.h index de6e8296..01f82b83 100644 --- a/src/deh_main.h +++ b/src/deh_main.h @@ -59,6 +59,7 @@ char *DEH_String(char *s); #endif extern boolean deh_allow_long_strings; +extern boolean deh_allow_long_cheats; #endif /* #ifndef DEH_MAIN_H */ diff --git a/src/m_cheat.h b/src/m_cheat.h index 893eff77..5de9f8bb 100644 --- a/src/m_cheat.h +++ b/src/m_cheat.h @@ -37,7 +37,7 @@ #define CHEAT(value, parameters) \ { value, sizeof(value) - 1, parameters, 0, 0, "" } -#define MAX_CHEAT_LEN 15 +#define MAX_CHEAT_LEN 25 #define MAX_CHEAT_PARAMS 5 typedef struct |