diff --git a/src/d_dehacked.cpp b/src/d_dehacked.cpp index 85a8e8c581..69b7c814a4 100644 --- a/src/d_dehacked.cpp +++ b/src/d_dehacked.cpp @@ -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 diff --git a/src/d_dehacked.h b/src/d_dehacked.h index f7fce98688..bb87993e9a 100644 --- a/src/d_dehacked.h +++ b/src/d_dehacked.h @@ -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 (); diff --git a/src/d_main.cpp b/src/d_main.cpp index 21433acdb1..d6edd72302 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -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();