shithub: choc

Download patch

ref: 6e8d5f118991efdc040f367b208f32219457bb39
parent: fa03d0eb682e3838c4cebf62e3c24e3e6a7982b8
author: Simon Howard <[email protected]>
date: Sat Jul 26 11:45:52 EDT 2008

Allow magic comments in dehacked files that disable the DOS dehacked
text replacement limit, so that we can use a dehacked patch to emulate
chex.exe.

Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 1158

--- a/src/deh_main.c
+++ b/src/deh_main.c
@@ -59,6 +59,10 @@
 // deh_weapon.c: 
 extern deh_section_t deh_section_weapon;
 
+// If true, we can do long string replacements.
+
+boolean deh_allow_long_strings = false;
+
 //
 // List of section types:
 //
@@ -226,6 +230,24 @@
     return false;
 }
 
+// Parses a comment string in a dehacked file.
+
+static void DEH_ParseComment(char *comment)
+{
+    // Allow comments containing this special value to allow string
+    // replacements longer than those permitted by DOS dehacked.
+    // This allows us to use a dehacked patch for doing string 
+    // replacements for emulating Chex Quest.
+    //
+    // If you use this, your dehacked patch may not work in Vanilla
+    // Doom.
+
+    if (strstr(comment, "*allow-long-strings*") != NULL)
+    {
+        deh_allow_long_strings = true;
+    }
+}
+
 // Parses a dehacked file by reading from the context
 
 static void DEH_ParseContext(deh_context_t *context)
@@ -241,6 +263,8 @@
     {
         DEH_Error(context, "This is not a valid dehacked patch file!");
     }
+
+    deh_allow_long_strings = false;
     
     // Read the file
     
@@ -262,6 +286,7 @@
         {
             // comment
 
+            DEH_ParseComment(line);
             continue;
         }
 
--- a/src/deh_main.h
+++ b/src/deh_main.h
@@ -58,5 +58,7 @@
 
 #endif
 
+extern boolean deh_allow_long_strings;
+
 #endif /* #ifndef DEH_MAIN_H */
 
--- a/src/deh_text.c
+++ b/src/deh_text.c
@@ -31,6 +31,7 @@
 
 #include "deh_defs.h"
 #include "deh_io.h"
+#include "deh_main.h"
 
 typedef struct 
 {
@@ -194,7 +195,7 @@
     // Only allow string replacements that are possible in Vanilla Doom.  
     // Chocolate Doom is unforgiving!
 
-    if (tolen > TXT_MaxStringLength(fromlen))
+    if (!deh_allow_long_strings && tolen > TXT_MaxStringLength(fromlen))
     {
         DEH_Error(context, "Replacement string is longer than the maximum "
                            "possible in doom.exe");