summaryrefslogtreecommitdiff
path: root/src/deh_main.c
diff options
context:
space:
mode:
authorSimon Howard2014-09-13 03:55:00 -0400
committerSimon Howard2014-09-13 03:55:00 -0400
commitcb72358ee930b29f4840b04bbb81f8d8444ce481 (patch)
treec2b9865637b9cbd93e53e1cc7c26d4553dc4a203 /src/deh_main.c
parent9531cdfcfadc0d4c2b767f27238bc9ac742787e0 (diff)
downloadchocolate-doom-cb72358ee930b29f4840b04bbb81f8d8444ce481.tar.gz
chocolate-doom-cb72358ee930b29f4840b04bbb81f8d8444ce481.tar.bz2
chocolate-doom-cb72358ee930b29f4840b04bbb81f8d8444ce481.zip
dehacked: Load Freedoom DEHACKED lump on startup.
If using one of the Freedoom IWADs, detect it by checking for the FREEDOOM lump, and then load its DEHACKED lump to apply the cosmetic string changes that it includes. In case we're using an old version of one of the Freedoom IWADs, don't bomb out with an error while parsing the DEHACKED lump.
Diffstat (limited to 'src/deh_main.c')
-rw-r--r--src/deh_main.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/deh_main.c b/src/deh_main.c
index a7846975..ff4500aa 100644
--- a/src/deh_main.c
+++ b/src/deh_main.c
@@ -275,7 +275,7 @@ static void DEH_ParseContext(deh_context_t *context)
// Read the file
- for (;;)
+ while (!DEH_HadError(context))
{
// Read the next line. We only allow the special extended parsing
// for the BEX [STRINGS] section.
@@ -331,7 +331,7 @@ static void DEH_ParseContext(deh_context_t *context)
sscanf(line, "%19s", section_name);
current_section = GetSectionByName(section_name);
-
+
if (current_section != NULL)
{
tag = current_section->start(context, line);
@@ -379,13 +379,18 @@ int DEH_LoadFile(char *filename)
DEH_CloseFile(context);
+ if (DEH_HadError(context))
+ {
+ I_Error("Error parsing dehacked file");
+ }
+
return 1;
}
// Load dehacked file from WAD lump.
// If allow_long is set, allow long strings and cheats just for this lump.
-int DEH_LoadLump(int lumpnum, boolean allow_long)
+int DEH_LoadLump(int lumpnum, boolean allow_long, boolean allow_error)
{
deh_context_t *context;
@@ -412,10 +417,17 @@ int DEH_LoadLump(int lumpnum, boolean allow_long)
DEH_CloseFile(context);
+ // If there was an error while parsing, abort with an error, but allow
+ // errors to just be ignored if allow_error=true.
+ if (!allow_error && DEH_HadError(context))
+ {
+ I_Error("Error parsing dehacked lump");
+ }
+
return 1;
}
-int DEH_LoadLumpByName(char *name, boolean allow_long)
+int DEH_LoadLumpByName(char *name, boolean allow_long, boolean allow_error)
{
int lumpnum;
@@ -427,7 +439,7 @@ int DEH_LoadLumpByName(char *name, boolean allow_long)
return 0;
}
- return DEH_LoadLump(lumpnum, allow_long);
+ return DEH_LoadLump(lumpnum, allow_long, allow_error);
}
// Checks the command line for -deh argument