shithub: choc

Download patch

ref: 9531cdfcfadc0d4c2b767f27238bc9ac742787e0
parent: 4d4f74f576cbde74def4bef7e1fda8c3a69eb64f
author: Simon Howard <[email protected]>
date: Fri Sep 12 22:39:50 EDT 2014

dehacked: Set stricter scoping for magic comments.

Magic comments allow some of the Vanilla limits to be overridden, but
they should only apply to the files in which they were defined. Reset
the flag variables that control these overrides before every new
Dehacked file is parsed, so that a flag set in one file cannot spill
over into other files that are parsed subsequently.

--- a/src/deh_main.c
+++ b/src/deh_main.c
@@ -358,6 +358,13 @@
         deh_initialized = true;
     }
 
+    // Before parsing a new file, reset special override flags to false.
+    // Magic comments should only apply to the file in which they were
+    // defined, and shouldn't carry over to subsequent files as well.
+    deh_allow_long_strings = false;
+    deh_allow_long_cheats = false;
+    deh_allow_extended_strings = false;
+
     printf(" loading %s\n", filename);
 
     context = DEH_OpenFile(filename);
@@ -367,9 +374,9 @@
         fprintf(stderr, "DEH_LoadFile: Unable to open %s\n", filename);
         return 0;
     }
-    
+
     DEH_ParseContext(context);
-    
+
     DEH_CloseFile(context);
 
     return 1;
@@ -381,7 +388,6 @@
 int DEH_LoadLump(int lumpnum, boolean allow_long)
 {
     deh_context_t *context;
-    boolean long_strings, long_cheats;
 
     if (!deh_initialized)
     {
@@ -389,13 +395,10 @@
         deh_initialized = true;
     }
 
-    if (allow_long)
-    {
-        long_strings = deh_allow_long_strings;
-        long_cheats = deh_allow_long_cheats;
-        deh_allow_long_strings = true;
-        deh_allow_long_cheats = true;
-    }
+    // Reset all special flags to defaults.
+    deh_allow_long_strings = allow_long;
+    deh_allow_long_cheats = allow_long;
+    deh_allow_extended_strings = false;
 
     context = DEH_OpenLump(lumpnum);
 
@@ -408,13 +411,6 @@
     DEH_ParseContext(context);
 
     DEH_CloseFile(context);
-
-    // Restore old value of long flags.
-    if (allow_long)
-    {
-        deh_allow_long_strings = long_strings;
-        deh_allow_long_cheats = long_cheats;
-    }
 
     return 1;
 }