summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Howard2014-09-13 02:39:50 -0400
committerSimon Howard2014-09-13 02:39:50 -0400
commit9531cdfcfadc0d4c2b767f27238bc9ac742787e0 (patch)
tree8db21ec8a0968c2dbaa61c25e71e1734434e4ff1 /src
parent4d4f74f576cbde74def4bef7e1fda8c3a69eb64f (diff)
downloadchocolate-doom-9531cdfcfadc0d4c2b767f27238bc9ac742787e0.tar.gz
chocolate-doom-9531cdfcfadc0d4c2b767f27238bc9ac742787e0.tar.bz2
chocolate-doom-9531cdfcfadc0d4c2b767f27238bc9ac742787e0.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/deh_main.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/src/deh_main.c b/src/deh_main.c
index e201ce38..a7846975 100644
--- a/src/deh_main.c
+++ b/src/deh_main.c
@@ -358,6 +358,13 @@ int DEH_LoadFile(char *filename)
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 @@ int DEH_LoadFile(char *filename)
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_LoadFile(char *filename)
int DEH_LoadLump(int lumpnum, boolean allow_long)
{
deh_context_t *context;
- boolean long_strings, long_cheats;
if (!deh_initialized)
{
@@ -389,13 +395,10 @@ int DEH_LoadLump(int lumpnum, boolean allow_long)
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);
@@ -409,13 +412,6 @@ int DEH_LoadLump(int lumpnum, boolean allow_long)
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;
}