foxygit / doom Log in
commit 8980e849e5b03ae4dd6c264c6c152bc461daa9ef
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Sun Sep 14 18:14:46 2008 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Sun Sep 14 18:14:46 2008 +0000

    Add -nocheat command line parameter to disable applying cheats from
    dehacked files.

    Subversion-branch: /trunk/chocolate-doom
    Subversion-revision: 1227
---
 src/deh_cheat.c | 10 ++++++++--
 src/deh_main.c  | 15 +++++++++++++++
 src/deh_main.h  |  1 +
 3 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/src/deh_cheat.c b/src/deh_cheat.c
index f501adbf..89e5d219 100644
--- a/src/deh_cheat.c
+++ b/src/deh_cheat.c
@@ -120,7 +120,10 @@ static void DEH_CheatParseLine(deh_context_t *context, char *line, void *tag)
             break;
         }

-        cheat->seq->sequence[i] = unsvalue[i];
+	if (deh_apply_cheats)
+	{
+	    cheat->seq->sequence[i] = unsvalue[i];
+	}
         ++i;

         // Absolute limit - don't exceed
@@ -132,7 +135,10 @@ static void DEH_CheatParseLine(deh_context_t *context, char *line, void *tag)
         }
     }

-    cheat->seq->sequence[i] = '\0';
+    if (deh_apply_cheats)
+    {
+        cheat->seq->sequence[i] = '\0';
+    }
 }

 deh_section_t deh_section_cheat =
diff --git a/src/deh_main.c b/src/deh_main.c
index b70a3384..616b30e0 100644
--- a/src/deh_main.c
+++ b/src/deh_main.c
@@ -67,6 +67,10 @@ boolean deh_allow_long_strings = false;

 boolean deh_allow_long_cheats = false;

+// If false, dehacked cheat replacements are ignored.
+
+boolean deh_apply_cheats = true;
+
 //
 // List of section types:
 //
@@ -381,6 +385,17 @@ void DEH_Init(void)

     InitialiseSections();

+    //!
+    // @category mod
+    //
+    // Ignore cheats in dehacked files.
+    //
+
+    if (M_CheckParm("-nocheats") > 0)
+    {
+	deh_apply_cheats = false;
+    }
+
     //!
     // @arg <files>
     // @category mod
diff --git a/src/deh_main.h b/src/deh_main.h
index 388c56de..6afe07f3 100644
--- a/src/deh_main.h
+++ b/src/deh_main.h
@@ -61,6 +61,7 @@ char *DEH_String(char *s);

 extern boolean deh_allow_long_strings;
 extern boolean deh_allow_long_cheats;
+extern boolean deh_apply_cheats;

 #endif /* #ifndef DEH_MAIN_H */