This commit is contained in:
Rachael Alexanderson 2017-04-05 00:53:00 -04:00
commit c06bd028d9
3 changed files with 26 additions and 4 deletions

View file

@ -2422,16 +2422,29 @@ static bool isDehFile(int lumpnum)
&& (0 == stricmp(extension, ".deh") || 0 == stricmp(extension, ".bex"));
}
int D_LoadDehLumps()
int D_LoadDehLumps(DehLumpSource source)
{
int lastlump = 0, lumpnum, count = 0;
while ((lumpnum = Wads.FindLump("DEHACKED", &lastlump)) >= 0)
{
const int filenum = Wads.GetLumpFile(lumpnum);
if (FromIWAD == source && filenum > FWadCollection::IWAD_FILENUM)
{
// No more DEHACKED lumps in IWAD
break;
}
else if (FromPWADs == source && filenum <= FWadCollection::IWAD_FILENUM)
{
// Skip DEHACKED lumps from IWAD
continue;
}
count += D_LoadDehLump(lumpnum);
}
if (0 == PatchSize && dehload > 0)
if (FromPWADs == source && 0 == PatchSize && dehload > 0)
{
// No DEH/BEX patch is loaded yet, try to find lump(s) with specific extensions

View file

@ -34,7 +34,13 @@
#ifndef __D_DEHACK_H__
#define __D_DEHACK_H__
int D_LoadDehLumps();
enum DehLumpSource
{
FromIWAD,
FromPWADs
};
int D_LoadDehLumps(DehLumpSource source);
bool D_LoadDehLump(int lumpnum);
bool D_LoadDehFile(const char *filename);
void FinishDehPatch ();

View file

@ -2507,6 +2507,9 @@ void D_DoomMain (void)
if (!batchrun) Printf ("DecalLibrary: Load decals.\n");
DecalLibrary.ReadAllDecals ();
// Load embedded Dehacked patches
D_LoadDehLumps(FromIWAD);
// [RH] Add any .deh and .bex files on the command line.
// If there are none, try adding any in the config file.
// Note that the command line overrides defaults from the config.
@ -2528,7 +2531,7 @@ void D_DoomMain (void)
}
// Load embedded Dehacked patches
D_LoadDehLumps();
D_LoadDehLumps(FromPWADs);
// Create replacements for dehacked pickups
FinishDehPatch();