- fixed: Changed IWAD_FILENUM to a dynamic lookup.

This commit is contained in:
Rachael Alexanderson 2017-09-13 04:19:03 -04:00
parent ffa11dec54
commit 765646ee1c
13 changed files with 30 additions and 25 deletions

View File

@ -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;

View File

@ -688,8 +688,10 @@ int FIWadManager::IdentifyVersion (TArray<FString> &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())
{

View File

@ -1992,9 +1992,9 @@ static FString CheckGameInfo(TArray<FString> & 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;
}

View File

@ -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

View File

@ -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.

View File

@ -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;

View File

@ -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);
}

View File

@ -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)
{

View File

@ -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;

View File

@ -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());

View File

@ -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)
{

View File

@ -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<FString> &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

View File

@ -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);