diff options
author | Simon Howard | 2010-12-10 22:44:01 +0000 |
---|---|---|
committer | Simon Howard | 2010-12-10 22:44:01 +0000 |
commit | 8dab0a3e635db40359c8ddeb9afaa9eca626ee98 (patch) | |
tree | cfd01bd0c96a97fcffad588782a5d106ca1b3d2f /src/deh_main.c | |
parent | 005747a6174d2d5b72e1af196a72cafb9b801a58 (diff) | |
parent | 678a8f9aeea9fa1966b3e8a94974688fda4d8fe1 (diff) | |
download | chocolate-doom-8dab0a3e635db40359c8ddeb9afaa9eca626ee98.tar.gz chocolate-doom-8dab0a3e635db40359c8ddeb9afaa9eca626ee98.tar.bz2 chocolate-doom-8dab0a3e635db40359c8ddeb9afaa9eca626ee98.zip |
Merge from trunk. This is slightly out of date as I did the merge
several days ago.
Subversion-branch: /branches/raven-branch
Subversion-revision: 2212
Diffstat (limited to 'src/deh_main.c')
-rw-r--r-- | src/deh_main.c | 49 |
1 files changed, 45 insertions, 4 deletions
diff --git a/src/deh_main.c b/src/deh_main.c index 75934087..39d59e8c 100644 --- a/src/deh_main.c +++ b/src/deh_main.c @@ -32,6 +32,7 @@ #include "doomtype.h" #include "d_iwad.h" #include "m_argv.h" +#include "w_wad.h" #include "deh_defs.h" #include "deh_io.h" @@ -246,9 +247,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 (;;) @@ -260,7 +258,9 @@ static void DEH_ParseContext(deh_context_t *context) // end of file? if (line == NULL) + { return; + } while (line[0] != '\0' && isspace(line[0])) ++line; @@ -347,6 +347,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) @@ -387,4 +429,3 @@ void DEH_Init(void) } } - |