diff options
author | Simon Howard | 2010-11-30 20:00:06 +0000 |
---|---|---|
committer | Simon Howard | 2010-11-30 20:00:06 +0000 |
commit | 9e54684b11cf8e8e4ae19ebd2d754ee472c70089 (patch) | |
tree | 04de62e8b2f81ba24cd26affee3f99cd2a62ba0c /src/deh_main.c | |
parent | e18391bb0f7b2690d0055fb031caa5fe7d3cdecf (diff) | |
download | chocolate-doom-9e54684b11cf8e8e4ae19ebd2d754ee472c70089.tar.gz chocolate-doom-9e54684b11cf8e8e4ae19ebd2d754ee472c70089.tar.bz2 chocolate-doom-9e54684b11cf8e8e4ae19ebd2d754ee472c70089.zip |
Add support for HACX v1.2 IWAD file.
Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 2176
Diffstat (limited to 'src/deh_main.c')
-rw-r--r-- | src/deh_main.c | 54 |
1 files changed, 50 insertions, 4 deletions
diff --git a/src/deh_main.c b/src/deh_main.c index dcdfb00d..20498375 100644 --- a/src/deh_main.c +++ b/src/deh_main.c @@ -30,6 +30,7 @@ #include "doomtype.h" #include "d_iwad.h" #include "m_argv.h" +#include "w_wad.h" #include "deh_defs.h" #include "deh_io.h" @@ -281,9 +282,6 @@ static void DEH_ParseContext(deh_context_t *context) DEH_Error(context, "This is not a valid dehacked patch file!"); } - deh_allow_long_strings = false; - deh_allow_long_cheats = false; - // Read the file for (;;) @@ -295,7 +293,9 @@ static void DEH_ParseContext(deh_context_t *context) // end of file? if (line == NULL) + { return; + } while (line[0] != '\0' && isspace(line[0])) ++line; @@ -359,6 +359,11 @@ int DEH_LoadFile(char *filename) { deh_context_t *context; + // Vanilla dehacked files don't allow long string or cheat replacements. + + deh_allow_long_strings = false; + deh_allow_long_cheats = false; + printf(" loading %s\n", filename); context = DEH_OpenFile(filename); @@ -376,6 +381,48 @@ int DEH_LoadFile(char *filename) return 1; } +// Load dehacked file from WAD lump. + +int DEH_LoadLump(int lumpnum) +{ + deh_context_t *context; + + // If it's in a lump, it's probably designed for a modern source port, + // so allow it to do long string and cheat replacements. + + deh_allow_long_strings = true; + deh_allow_long_cheats = true; + + context = DEH_OpenLump(lumpnum); + + if (context == NULL) + { + fprintf(stderr, "DEH_LoadFile: Unable to open lump %i\n", lumpnum); + return 0; + } + + DEH_ParseContext(context); + + DEH_CloseFile(context); + + return 1; +} + +int DEH_LoadLumpByName(char *name) +{ + int lumpnum; + + lumpnum = W_CheckNumForName(name); + + if (lumpnum == -1) + { + fprintf(stderr, "DEH_LoadLumpByName: '%s' lump not found\n", name); + return 0; + } + + return DEH_LoadLump(lumpnum); +} + // Checks the command line for -deh argument void DEH_Init(void) @@ -418,4 +465,3 @@ void DEH_Init(void) } } - |