ref: 4d0b888e577db400a2c8e87157ffa17257074856
parent: 530888d2e243f27bd36aa71a68570195276c4173
author: Simon Howard <fraggle@gmail.com>
date: Mon Jul 28 20:50:56 EDT 2008
Add magic dehacked comment to enable long cheat sequences (also for Chex Quest support) Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1160
--- a/src/deh_cheat.c
+++ b/src/deh_cheat.c
@@ -108,10 +108,28 @@
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';
--- a/src/deh_main.c
+++ b/src/deh_main.c
@@ -63,6 +63,10 @@
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 @@
{
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 @@
}
deh_allow_long_strings = false;
+ deh_allow_long_cheats = false;
// Read the file
--- a/src/deh_main.h
+++ b/src/deh_main.h
@@ -59,6 +59,7 @@
#endif
extern boolean deh_allow_long_strings;
+extern boolean deh_allow_long_cheats;
#endif /* #ifndef DEH_MAIN_H */
--- 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