diff --git a/src/d_main.cpp b/src/d_main.cpp index 78166e3f47..28cf6435b1 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -2239,6 +2239,13 @@ void D_DoomMain (void) I_FatalError ("Cannot find " BASEWAD); } + // Load zdoom.pk3 alone so that we can get access to the internal gameinfos before + // the IWAD is known. + wadlist_t *basewad = (wadlist_t*)M_Malloc(sizeof(wadlist_t) + strlen(wad)); + strcpy(basewad->name, wad); + basewad->next = NULL; + Wads.InitMultipleFiles(&basewad); + iwad_info = &IWADInfos[IdentifyVersion(wad)]; I_SetIWADInfo(iwad_info); GameConfig->DoGameSetup (GameNames[gameinfo.gametype]); diff --git a/src/w_wad.cpp b/src/w_wad.cpp index 34e3f83939..22939085f9 100644 --- a/src/w_wad.cpp +++ b/src/w_wad.cpp @@ -164,6 +164,11 @@ FWadCollection::FWadCollection () } FWadCollection::~FWadCollection () +{ + DeleteAll(); +} + +void FWadCollection::DeleteAll () { if (FirstLumpIndex != NULL) { @@ -193,6 +198,7 @@ FWadCollection::~FWadCollection () } } LumpInfo.Clear(); + NumLumps = 0; for (DWORD i = 0; i < Wads.Size(); ++i) { @@ -217,10 +223,8 @@ void FWadCollection::InitMultipleFiles (wadlist_t **filenames) int numfiles; // open all the files, load headers, and count lumps + DeleteAll(); numfiles = 0; - Wads.Clear(); - LumpInfo.Clear(); - NumLumps = 0; while (*filenames) { @@ -260,10 +264,10 @@ void FWadCollection::InitMultipleFiles (wadlist_t **filenames) MergeLumps ("HI_START", "HI_END", ns_hires); // [RH] Set up hash table - FirstLumpIndex = new WORD[NumLumps]; - NextLumpIndex = new WORD[NumLumps]; - FirstLumpIndex_FullName = new WORD[NumLumps]; - NextLumpIndex_FullName = new WORD[NumLumps]; + FirstLumpIndex = new DWORD[NumLumps]; + NextLumpIndex = new DWORD[NumLumps]; + FirstLumpIndex_FullName = new DWORD[NumLumps]; + NextLumpIndex_FullName = new DWORD[NumLumps]; InitHashChains (); } diff --git a/src/w_wad.h b/src/w_wad.h index 70c2302fa4..e72d58d02d 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -224,11 +224,11 @@ protected: class WadFileRecord; struct LumpRecord; - WORD *FirstLumpIndex; // [RH] Hashing stuff moved out of lumpinfo structure - WORD *NextLumpIndex; + DWORD *FirstLumpIndex; // [RH] Hashing stuff moved out of lumpinfo structure + DWORD *NextLumpIndex; - WORD *FirstLumpIndex_FullName; // The same information for fully qualified paths from .zips - WORD *NextLumpIndex_FullName; + DWORD *FirstLumpIndex_FullName; // The same information for fully qualified paths from .zips + DWORD *NextLumpIndex_FullName; TArray LumpInfo; @@ -249,6 +249,7 @@ private: void ScanForFlatHack (int startlump); void RenameSprites (int startlump); void SetLumpAddress(LumpRecord *l); + void DeleteAll(); }; extern FWadCollection Wads;