diff --git a/src/d_dehacked.cpp b/src/d_dehacked.cpp index 1065836c1..87f1d589e 100644 --- a/src/d_dehacked.cpp +++ b/src/d_dehacked.cpp @@ -2431,12 +2431,12 @@ int D_LoadDehLumps(DehLumpSource source) { const int filenum = Wads.GetLumpFile(lumpnum); - if (FromIWAD == source && filenum > FWadCollection::IWAD_FILENUM) + if (FromIWAD == source && filenum > Wads.GetIwadNum()) { // No more DEHACKED lumps in IWAD break; } - else if (FromPWADs == source && filenum <= FWadCollection::IWAD_FILENUM) + else if (FromPWADs == source && filenum <= Wads.GetIwadNum()) { // Skip DEHACKED lumps from IWAD continue; diff --git a/src/d_iwad.cpp b/src/d_iwad.cpp index 202eb2b5e..512e1a905 100644 --- a/src/d_iwad.cpp +++ b/src/d_iwad.cpp @@ -688,8 +688,10 @@ int FIWadManager::IdentifyVersion (TArray &wadfiles, const char *iwad, D_AddFile (wadfiles, zdoom_wad); // [SP] Load non-free assets if available. This must be done before the IWAD. - if (optional_wad) - D_AddFile(wadfiles, optional_wad); + if (D_AddFile(wadfiles, optional_wad)) + Wads.SetIwadNum(2); + else + Wads.SetIwadNum(1); if (picks[pick].mRequiredPath.IsNotEmpty()) { diff --git a/src/d_main.cpp b/src/d_main.cpp index 6edb88fdc..923d510ec 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -1992,9 +1992,9 @@ static FString CheckGameInfo(TArray & pwads) static void SetMapxxFlag() { - int lump_name = Wads.CheckNumForName("MAP01", ns_global, FWadCollection::IWAD_FILENUM); - int lump_wad = Wads.CheckNumForFullName("maps/map01.wad", FWadCollection::IWAD_FILENUM); - int lump_map = Wads.CheckNumForFullName("maps/map01.map", FWadCollection::IWAD_FILENUM); + int lump_name = Wads.CheckNumForName("MAP01", ns_global, Wads.GetIwadNum()); + int lump_wad = Wads.CheckNumForFullName("maps/map01.wad", Wads.GetIwadNum()); + int lump_map = Wads.CheckNumForFullName("maps/map01.map", Wads.GetIwadNum()); if (lump_name >= 0 || lump_wad >= 0 || lump_map >= 0) gameinfo.flags |= GI_MAPxx; } diff --git a/src/g_game.cpp b/src/g_game.cpp index d48b40b6a..d3dd47f46 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -2195,7 +2195,7 @@ static void PutSaveWads (FSerializer &arc) const char *name; // Name of IWAD - name = Wads.GetWadName (FWadCollection::IWAD_FILENUM); + name = Wads.GetWadName (Wads.GetIwadNum()); arc.AddString("Game WAD", name); // Name of wad the map resides in diff --git a/src/gl/data/gl_data.cpp b/src/gl/data/gl_data.cpp index a055523fc..d0b1a4a28 100644 --- a/src/gl/data/gl_data.cpp +++ b/src/gl/data/gl_data.cpp @@ -88,13 +88,13 @@ void AdjustSpriteOffsets() for (int i = 0; i < numtex; i++) { if (Wads.GetLumpFile(i) > 1) break; // we are past the IWAD - if (Wads.GetLumpNamespace(i) == ns_sprites && Wads.GetLumpFile(i) == FWadCollection::IWAD_FILENUM) + if (Wads.GetLumpNamespace(i) == ns_sprites && Wads.GetLumpFile(i) == Wads.GetIwadNum()) { char str[9]; Wads.GetLumpName(str, i); str[8] = 0; FTextureID texid = TexMan.CheckForTexture(str, FTexture::TEX_Sprite, 0); - if (texid.isValid() && Wads.GetLumpFile(TexMan[texid]->SourceLump) > FWadCollection::IWAD_FILENUM) + if (texid.isValid() && Wads.GetLumpFile(TexMan[texid]->SourceLump) > Wads.GetIwadNum()) { // This texture has been replaced by some PWAD. memcpy(&sprid, str, 4); @@ -137,9 +137,9 @@ void AdjustSpriteOffsets() if (lumpnum >= 0 && lumpnum < Wads.GetNumLumps()) { int wadno = Wads.GetLumpFile(lumpnum); - if ((iwadonly && wadno==FWadCollection::IWAD_FILENUM) || (!iwadonly && wadno == ofslumpno)) + if ((iwadonly && wadno==Wads.GetIwadNum()) || (!iwadonly && wadno == ofslumpno)) { - if (wadno == FWadCollection::IWAD_FILENUM && !forced && iwadonly) + if (wadno == Wads.GetIwadNum() && !forced && iwadonly) { memcpy(&sprid, &tex->Name[0], 4); if (donotprocess.CheckKey(sprid)) continue; // do not alter sprites that only get partially replaced. diff --git a/src/gl/textures/gl_texture.cpp b/src/gl/textures/gl_texture.cpp index af1a6178f..e5a91fe14 100644 --- a/src/gl/textures/gl_texture.cpp +++ b/src/gl/textures/gl_texture.cpp @@ -614,7 +614,7 @@ void gl_ParseBrightmap(FScanner &sc, int deflump) if (lumpnum != -1) { - if (iwad && Wads.GetLumpFile(lumpnum) <= FWadCollection::IWAD_FILENUM) useme = true; + if (iwad && Wads.GetLumpFile(lumpnum) <= Wads.GetIwadNum()) useme = true; if (thiswad && Wads.GetLumpFile(lumpnum) == deflump) useme = true; } if (!useme) return; diff --git a/src/menu/loadsavemenu.cpp b/src/menu/loadsavemenu.cpp index f76654165..bec3082b1 100644 --- a/src/menu/loadsavemenu.cpp +++ b/src/menu/loadsavemenu.cpp @@ -213,7 +213,7 @@ void FSavegameManager::ReadSaveStrings() // old, incompatible savegame. List as not usable. oldVer = true; } - else if (iwad.CompareNoCase(Wads.GetWadName(FWadCollection::IWAD_FILENUM)) == 0) + else if (iwad.CompareNoCase(Wads.GetWadName(Wads.GetIwadNum())) == 0) { missing = !G_CheckSaveGameWads(arc, false); } diff --git a/src/menu/menudef.cpp b/src/menu/menudef.cpp index d97705b34..de9c8bc92 100644 --- a/src/menu/menudef.cpp +++ b/src/menu/menudef.cpp @@ -1014,7 +1014,7 @@ void M_ParseMenuDefs() atterm( DeinitMenus); DeinitMenus(); - int IWADMenu = Wads.CheckNumForName("MENUDEF", ns_global, FWadCollection::IWAD_FILENUM); + int IWADMenu = Wads.CheckNumForName("MENUDEF", ns_global, Wads.GetIwadNum()); while ((lump = Wads.FindLump ("MENUDEF", &lastlump)) != -1) { diff --git a/src/p_user.cpp b/src/p_user.cpp index 104e7d241..520861651 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -962,7 +962,7 @@ void APlayerPawn::BeginPlay () int wadnorm = Wads.GetLumpFile(spritenorm); int wadcrouch = Wads.GetLumpFile(spritenorm); - if (wadnorm > FWadCollection::IWAD_FILENUM && wadcrouch <= FWadCollection::IWAD_FILENUM) + if (wadnorm > Wads.GetIwadNum() && wadcrouch <= Wads.GetIwadNum()) { // Question: Add an option / disable crouching or do what? crouchsprite = 0; diff --git a/src/v_font.cpp b/src/v_font.cpp index 30a3f45f6..68422cd74 100644 --- a/src/v_font.cpp +++ b/src/v_font.cpp @@ -2275,7 +2275,7 @@ void V_InitCustomFonts() { *p = TexMan[texid]; } - else if (Wads.GetLumpFile(sc.LumpNum) >= Wads.IWAD_FILENUM) + else if (Wads.GetLumpFile(sc.LumpNum) >= Wads.GetIwadNum()) { // Print a message only if this isn't in zdoom.pk3 sc.ScriptMessage("%s: Unable to find texture in font definition for %s", sc.String, namebuffer.GetChars()); diff --git a/src/w_wad.cpp b/src/w_wad.cpp index f1e633970..e4a8d1af0 100644 --- a/src/w_wad.cpp +++ b/src/w_wad.cpp @@ -281,7 +281,7 @@ void FWadCollection::AddFile (const char *filename, FileReader *wadinfo) lump_p->wadnum = Files.Size(); } - if (Files.Size() == IWAD_FILENUM && gameinfo.gametype == GAME_Strife && gameinfo.flags & GI_SHAREWARE) + if (Files.Size() == GetIwadNum() && gameinfo.gametype == GAME_Strife && gameinfo.flags & GI_SHAREWARE) { resfile->FindStrifeTeaserVoices(); } @@ -859,7 +859,7 @@ void FWadCollection::RenameSprites () if (LumpInfo[i].lump->Namespace == ns_sprites) { // Only sprites in the IWAD normally get renamed - if (renameAll || LumpInfo[i].wadnum == IWAD_FILENUM) + if (renameAll || LumpInfo[i].wadnum == GetIwadNum()) { for (int j = 0; j < numrenames; ++j) { @@ -921,7 +921,7 @@ void FWadCollection::RenameNerve () static const uint8_t nerve[16] = { 0x96, 0x7d, 0x5a, 0xe2, 0x3d, 0xaf, 0x45, 0x19, 0x62, 0x12, 0xae, 0x1b, 0x60, 0x5d, 0xa3, 0xb0 }; size_t nervesize = 3819855; // NERVE.WAD's file size - int w = IWAD_FILENUM; + int w = GetIwadNum(); while (++w < GetNumWads()) { FileReader *fr = GetFileReader(w); @@ -985,7 +985,7 @@ void FWadCollection::FixMacHexen() return; } - FileReader* const reader = GetFileReader(IWAD_FILENUM); + FileReader* const reader = GetFileReader(GetIwadNum()); const long iwadSize = reader->GetLength(); static const long DEMO_SIZE = 13596228; @@ -1038,8 +1038,8 @@ void FWadCollection::FixMacHexen() // Hexen Beta is very similar to Demo but it has MAP41: Maze at the end of the WAD // So keep this map if it's present but discard all extra lumps - const int lastLump = GetLastLump(IWAD_FILENUM) - (isBeta ? 12 : 0); - assert(GetFirstLump(IWAD_FILENUM) + 299 < lastLump); + const int lastLump = GetLastLump(GetIwadNum()) - (isBeta ? 12 : 0); + assert(GetFirstLump(GetIwadNum()) + 299 < lastLump); for (int i = lastLump - EXTRA_LUMPS + 1; i <= lastLump; ++i) { diff --git a/src/w_wad.h b/src/w_wad.h index 52be4e79f..6fdc62f84 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -134,7 +134,8 @@ public: ~FWadCollection (); // The wadnum for the IWAD - enum { IWAD_FILENUM = 1 }; + int GetIwadNum() { return IwadIndex; } + void SetIwadNum(int x) { IwadIndex = x; } void InitMultipleFiles (TArray &filenames); void AddFile (const char *filename, FileReader *wadinfo = NULL); @@ -224,6 +225,8 @@ protected: uint32_t NumLumps; // Not necessarily the same as LumpInfo.Size() uint32_t NumWads; + int IwadIndex; + void SkinHack (int baselump); void InitHashChains (); // [RH] Set up the lumpinfo hashing diff --git a/src/win32/st_start.cpp b/src/win32/st_start.cpp index 0fb89d581..5ba3848c7 100644 --- a/src/win32/st_start.cpp +++ b/src/win32/st_start.cpp @@ -1108,7 +1108,7 @@ void ST_Endoom() exit(0); } - if (Wads.GetLumpFile(endoom_lump) == FWadCollection::IWAD_FILENUM && showendoom == 2) + if (Wads.GetLumpFile(endoom_lump) == Wads.GetIwadNum() && showendoom == 2) { // showendoom==2 means to show only lumps from PWADs. exit(0);