summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/deh_main.c41
-rw-r--r--src/deh_main.h2
-rw-r--r--src/doom/d_main.c77
-rw-r--r--src/heretic/d_main.c12
-rw-r--r--src/strife/d_main.c13
5 files changed, 81 insertions, 64 deletions
diff --git a/src/deh_main.c b/src/deh_main.c
index b3dc609a..b0f803f1 100644
--- a/src/deh_main.c
+++ b/src/deh_main.c
@@ -83,6 +83,25 @@ static void InitializeSections(void)
}
}
+static void DEH_Init(void)
+{
+ //!
+ // @category mod
+ //
+ // Ignore cheats in dehacked files.
+ //
+
+ if (M_CheckParm("-nocheats") > 0)
+ {
+ deh_apply_cheats = false;
+ }
+
+ // Call init functions for all the section definitions.
+ InitializeSections();
+
+ deh_initialized = true;
+}
+
// Given a section name, get the section structure which corresponds
static deh_section_t *GetSectionByName(char *name)
@@ -355,8 +374,7 @@ int DEH_LoadFile(char *filename)
if (!deh_initialized)
{
- InitializeSections();
- deh_initialized = true;
+ DEH_Init();
}
// Before parsing a new file, reset special override flags to false.
@@ -397,8 +415,7 @@ int DEH_LoadLump(int lumpnum, boolean allow_long, boolean allow_error)
if (!deh_initialized)
{
- InitializeSections();
- deh_initialized = true;
+ DEH_Init();
}
// Reset all special flags to defaults.
@@ -443,25 +460,13 @@ int DEH_LoadLumpByName(char *name, boolean allow_long, boolean allow_error)
return DEH_LoadLump(lumpnum, allow_long, allow_error);
}
-// Checks the command line for -deh argument
-
-void DEH_Init(void)
+// Check the command line for -deh argument, and others.
+void DEH_ParseCommandLine(void)
{
char *filename;
int p;
//!
- // @category mod
- //
- // Ignore cheats in dehacked files.
- //
-
- if (M_CheckParm("-nocheats") > 0)
- {
- deh_apply_cheats = false;
- }
-
- //!
// @arg <files>
// @category mod
//
diff --git a/src/deh_main.h b/src/deh_main.h
index c9d41bf2..10ac2360 100644
--- a/src/deh_main.h
+++ b/src/deh_main.h
@@ -30,7 +30,7 @@
#define DEH_VANILLA_NUMSTATES 966
#define DEH_VANILLA_NUMSFX 107
-void DEH_Init(void);
+void DEH_ParseCommandLine(void);
int DEH_LoadFile(char *filename);
int DEH_LoadLump(int lumpnum, boolean allow_long, boolean allow_error);
int DEH_LoadLumpByName(char *name, boolean allow_long, boolean allow_error);
diff --git a/src/doom/d_main.c b/src/doom/d_main.c
index ef8e8aea..76acaf48 100644
--- a/src/doom/d_main.c
+++ b/src/doom/d_main.c
@@ -1082,9 +1082,10 @@ static void LoadIwadDeh(void)
//
void D_DoomMain (void)
{
- int p;
- char file[256];
- char demolumpname[9];
+ int p;
+ char file[256];
+ char demolumpname[9];
+ int numiwadlumps;
I_AtExit(D_Endoom, false);
@@ -1153,11 +1154,6 @@ void D_DoomMain (void)
}
#endif
-
-#ifdef FEATURE_DEHACKED
- printf("DEH_Init: Init Dehacked support.\n");
- DEH_Init();
-#endif
//!
// @vanilla
@@ -1299,6 +1295,7 @@ void D_DoomMain (void)
DEH_printf("W_Init: Init WADfiles.\n");
D_AddFile(iwadfile);
+ numiwadlumps = numlumps;
W_CheckCorrectIWAD(doom);
@@ -1344,6 +1341,17 @@ void D_DoomMain (void)
DEH_AddStringReplacement(PHUSTR_1, "level 33: betray");
}
+#ifdef FEATURE_DEHACKED
+ // Load Dehacked patches specified on the command line with -deh.
+ // Note that there's a very careful and deliberate ordering to how
+ // Dehacked patches are loaded. The order we use is:
+ // 1. IWAD dehacked patches.
+ // 2. Command line dehacked patches specified with -deh.
+ // 3. PWAD dehacked patches in DEHACKED lumps.
+ DEH_ParseCommandLine();
+#endif
+
+ // Load PWAD files.
modifiedgame = W_ParseCommandLine();
// Debug:
@@ -1406,9 +1414,35 @@ void D_DoomMain (void)
I_AtExit((atexit_func_t) G_CheckDemoStatus, true);
// Generate the WAD hash table. Speed things up a bit.
-
W_GenerateHashTable();
+ // 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 = numiwadlumps; i < numlumps; ++i)
+ {
+ if (!strncmp(lumpinfo[i].name, "DEHACKED", 8))
+ {
+ DEH_LoadLump(i, false, false);
+ loaded++;
+ }
+ }
+
+ printf(" loaded %i DEHACKED lumps from PWAD files.\n", loaded);
+ }
+
+ // Set the gamedescription string. This is only possible now that
+ // we've finished loading Dehacked patches.
D_SetGameDescription();
savegamedir = M_GetSaveGameDir(D_SaveGameIWADName(gamemission));
@@ -1461,31 +1495,6 @@ void D_DoomMain (void)
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, false);
- loaded++;
- }
- }
-
- printf("Loaded %i DEHACKED lumps from WAD files.\n", loaded);
- }
-
DEH_printf("I_Init: Setting up machine state.\n");
I_CheckIsScreensaver();
I_InitTimer();
diff --git a/src/heretic/d_main.c b/src/heretic/d_main.c
index 4177bd09..8389a23d 100644
--- a/src/heretic/d_main.c
+++ b/src/heretic/d_main.c
@@ -955,11 +955,6 @@ void D_DoomMain(void)
DEH_printf("Z_Init: Init zone memory allocation daemon.\n");
Z_Init();
-#ifdef FEATURE_DEHACKED
- printf("DEH_Init: Init Dehacked support.\n");
- DEH_Init();
-#endif
-
DEH_printf("W_Init: Init WADfiles.\n");
iwadfile = D_FindIWAD(IWAD_MASK_HERETIC, &gamemission);
@@ -972,6 +967,13 @@ void D_DoomMain(void)
D_AddFile(iwadfile);
W_CheckCorrectIWAD(heretic);
+
+#ifdef FEATURE_DEHACKED
+ // Load dehacked patches specified on the command line.
+ DEH_ParseCommandLine();
+#endif
+
+ // Load PWAD files.
W_ParseCommandLine();
//!
diff --git a/src/strife/d_main.c b/src/strife/d_main.c
index b2eadd96..1ce9c132 100644
--- a/src/strife/d_main.c
+++ b/src/strife/d_main.c
@@ -1390,12 +1390,6 @@ void D_DoomMain (void)
}
#endif
-
-#ifdef FEATURE_DEHACKED
- if(devparm)
- printf("DEH_Init: Init Dehacked support.\n");
- DEH_Init();
-#endif
//!
// @vanilla
@@ -1558,6 +1552,13 @@ void D_DoomMain (void)
DEH_printf("W_Init: Init WADfiles.\n");
D_AddFile(iwadfile);
W_CheckCorrectIWAD(strife);
+
+#ifdef FEATURE_DEHACKED
+ // Load dehacked patches specified on the command line.
+ DEH_ParseCommandLine();
+#endif
+
+ // Load PWAD files.
modifiedgame = W_ParseCommandLine();
// [STRIFE] serial number output