ref: d73a64228a6502ce68e1c9fd1cc5197863a50c7e
parent: 9f955ea5b1f124554d58733238dff4da1d9f54c4
author: Simon Howard <[email protected]>
date: Sat Mar 15 22:23:14 EDT 2014
doom: Add -dehlump parameter to load DEHACKED lumps. Lots of otherwise Vanilla-compatible WADs contain DEHACKED lumps. Allow these to be loaded by adding a -dehlump command line parameter. Thanks to Fabian Greffrath for the suggestion (fixes #349).
--- a/src/deh_main.c
+++ b/src/deh_main.c
@@ -348,17 +348,21 @@
}
// 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)
+int DEH_LoadLump(int lumpnum, boolean allow_long)
{
deh_context_t *context;
+ boolean long_strings, long_cheats;
- // 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.
+ 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;
+ }
- deh_allow_long_strings = true;
- deh_allow_long_cheats = true;
-
context = DEH_OpenLump(lumpnum);
if (context == NULL)
@@ -371,10 +375,17 @@
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;
}
-int DEH_LoadLumpByName(char *name)
+int DEH_LoadLumpByName(char *name, boolean allow_long)
{
int lumpnum;
@@ -386,7 +397,7 @@
return 0;
}
- return DEH_LoadLump(lumpnum);
+ return DEH_LoadLump(lumpnum, allow_long);
}
// Checks the command line for -deh argument
--- a/src/deh_main.h
+++ b/src/deh_main.h
@@ -41,8 +41,8 @@
void DEH_Init(void);
int DEH_LoadFile(char *filename);
-int DEH_LoadLump(int lumpnum);
-int DEH_LoadLumpByName(char *name);
+int DEH_LoadLump(int lumpnum, boolean allow_long);
+int DEH_LoadLumpByName(char *name, boolean allow_long);
boolean DEH_ParseAssignment(char *line, char **variable_name, char **value);
--- a/src/doom/d_main.c
+++ b/src/doom/d_main.c
@@ -1050,7 +1050,7 @@
if (gameversion == exe_hacx)
{
- if (!DEH_LoadLumpByName("DEHACKED"))
+ if (!DEH_LoadLumpByName("DEHACKED", true))
{
I_Error("DEHACKED lump not found. Please check that this is the "
"Hacx v1.2 IWAD.");
@@ -1423,6 +1423,31 @@
" for more information on how to play using Freedoom:\n"
" http://www.chocolate-doom.org/wiki/index.php/Freedoom\n");
I_PrintDivider();
+ }
+
+ // Load DEHACKED lumps from WAD files - but only if we give the right
+ // command line parameter.
+
+ //!
+ // @category mod
+ //
+ // Load Dehacked patches from DEHACKED lumps contained in one of the
+ // loaded PWAD files.
+ //
+ if (M_ParmExists("-dehlump"))
+ {
+ int i, loaded = 0;
+
+ for (i = 0; i < numlumps; ++i)
+ {
+ if (!strncmp(lumpinfo[i].name, "DEHACKED", 8))
+ {
+ DEH_LoadLump(i, false);
+ loaded++;
+ }
+ }
+
+ printf("Loaded %i DEHACKED lumps from WAD files.\n", loaded);
}
DEH_printf("I_Init: Setting up machine state.\n");