- treat configurations which load a secondary WAD on top of a primary IWAD like SVE to consider the secondary WAD an actual IWAD as well.

This fixes localization of the SVE menu.
This commit is contained in:
Christoph Oelckers 2019-07-15 20:48:00 +02:00
parent 7d87df25d8
commit 8177583e2f
10 changed files with 27 additions and 19 deletions

View file

@ -738,16 +738,20 @@ 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.
int iwadnum;
if (D_AddFile(wadfiles, optional_wad))
Wads.SetIwadNum(2);
iwadnum = 2;
else
Wads.SetIwadNum(1);
iwadnum = 1;
Wads.SetIwadNum(iwadnum);
if (picks[pick].mRequiredPath.IsNotEmpty())
{
D_AddFile (wadfiles, picks[pick].mRequiredPath);
iwadnum++;
}
D_AddFile (wadfiles, picks[pick].mFullPath);
Wads.SetMaxIwadNum(iwadnum);
auto info = mIWadInfos[picks[pick].mInfoIndex];
// Load additional resources from the same directory as the IWAD itself.

View file

@ -881,7 +881,7 @@ bool FLevelLocals::DoCompleted (FString nextlevel, wbstartstruct_t &wminfo)
if (tex != nullptr)
{
int filenum = Wads.GetLumpFile(tex->GetSourceLump());
if (filenum >= 0 && filenum <= Wads.GetIwadNum())
if (filenum >= 0 && filenum <= Wads.GetMaxIwadNum())
{
texids[i]->SetInvalid();
}

View file

@ -2451,12 +2451,12 @@ int D_LoadDehLumps(DehLumpSource source)
{
const int filenum = Wads.GetLumpFile(lumpnum);
if (FromIWAD == source && filenum > Wads.GetIwadNum())
if (FromIWAD == source && filenum > Wads.GetMaxIwadNum())
{
// No more DEHACKED lumps in IWAD
break;
}
else if (FromPWADs == source && filenum <= Wads.GetIwadNum())
else if (FromPWADs == source && filenum <= Wads.GetMaxIwadNum())
{
// Skip DEHACKED lumps from IWAD
continue;

View file

@ -233,7 +233,7 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla
for (auto entry : array)
{
FTexture *tex = TexMan.GetTexture(entry, false);
if (tex && tex->SourceLump >= 0 && Wads.GetLumpFile(tex->SourceLump) <= Wads.GetIwadNum() && tex->UseType == ETextureType::MiscPatch)
if (tex && tex->SourceLump >= 0 && Wads.GetLumpFile(tex->SourceLump) <= Wads.GetMaxIwadNum() && tex->UseType == ETextureType::MiscPatch)
{
texs[i] = tex;
}

View file

@ -443,7 +443,7 @@ bool FTextureManager::OkForLocalization(FTextureID texnum, const char *substitut
// Mode 3 must also reject substitutions for non-IWAD content.
int file = Wads.GetLumpFile(Textures[texnum.GetIndex()].Texture->SourceLump);
if (file > Wads.GetIwadNum()) return true;
if (file > Wads.GetMaxIwadNum()) return true;
return false;
}
@ -927,7 +927,7 @@ void FTextureManager::AddTexturesForWad(int wadnum, FMultipatchTextureBuilder &b
{
int firsttexture = Textures.Size();
int lumpcount = Wads.GetNumLumps();
bool iwad = wadnum == Wads.GetIwadNum();
bool iwad = wadnum >= Wads.GetIwadNum() && wadnum <= Wads.GetMaxIwadNum();
FirstTextureForFile.Push(firsttexture);
@ -1449,14 +1449,14 @@ void FTextureManager::AdjustSpriteOffsets()
for (int i = 0; i < numtex; i++)
{
if (Wads.GetLumpFile(i) > Wads.GetIwadNum()) break; // we are past the IWAD
if (Wads.GetLumpNamespace(i) == ns_sprites && Wads.GetLumpFile(i) == Wads.GetIwadNum())
if (Wads.GetLumpFile(i) > Wads.GetMaxIwadNum()) break; // we are past the IWAD
if (Wads.GetLumpNamespace(i) == ns_sprites && Wads.GetLumpFile(i) >= Wads.GetIwadNum() && Wads.GetLumpFile(i) <= Wads.GetMaxIwadNum())
{
char str[9];
Wads.GetLumpName(str, i);
str[8] = 0;
FTextureID texid = TexMan.CheckForTexture(str, ETextureType::Sprite, 0);
if (texid.isValid() && Wads.GetLumpFile(GetTexture(texid)->SourceLump) > Wads.GetIwadNum())
if (texid.isValid() && Wads.GetLumpFile(GetTexture(texid)->SourceLump) > Wads.GetMaxIwadNum())
{
// This texture has been replaced by some PWAD.
memcpy(&sprid, str, 4);
@ -1498,9 +1498,9 @@ void FTextureManager::AdjustSpriteOffsets()
if (lumpnum >= 0 && lumpnum < Wads.GetNumLumps())
{
int wadno = Wads.GetLumpFile(lumpnum);
if ((iwadonly && wadno == Wads.GetIwadNum()) || (!iwadonly && wadno == ofslumpno))
if ((iwadonly && wadno >= Wads.GetIwadNum() && wadno <= Wads.GetMaxIwadNum()) || (!iwadonly && wadno == ofslumpno))
{
if (wadno == Wads.GetIwadNum() && !forced && iwadonly)
if (wadno >= Wads.GetIwadNum() && wadno <= Wads.GetMaxIwadNum() && !forced && iwadonly)
{
memcpy(&sprid, &tex->Name[0], 4);
if (donotprocess.CheckKey(sprid)) continue; // do not alter sprites that only get partially replaced.

View file

@ -117,6 +117,9 @@ public:
int GetIwadNum() { return IwadIndex; }
void SetIwadNum(int x) { IwadIndex = x; }
int GetMaxIwadNum() { return MaxIwadIndex; }
void SetMaxIwadNum(int x) { MaxIwadIndex = x; }
void InitMultipleFiles (TArray<FString> &filenames, const TArray<FString> &deletelumps);
void AddFile (const char *filename, FileReader *wadinfo = NULL);
int CheckIfWadLoaded (const char *name);
@ -208,7 +211,8 @@ protected:
uint32_t NumLumps = 0; // Not necessarily the same as LumpInfo.Size()
uint32_t NumWads;
int IwadIndex;
int IwadIndex = -1;
int MaxIwadIndex = -1;
void InitHashChains (); // [RH] Set up the lumpinfo hashing

View file

@ -323,7 +323,7 @@ bool FIntermissionActionTextscreen::ParseKey(FScanner &sc)
else
{
// only print an error if coming from a PWAD
if (Wads.GetLumpFile(sc.LumpNum) > Wads.GetIwadNum())
if (Wads.GetLumpFile(sc.LumpNum) > Wads.GetMaxIwadNum())
sc.ScriptMessage("Unknown text lump '%s'", sc.String);
mText.Format("Unknown text lump '%s'", sc.String);
}

View file

@ -836,7 +836,7 @@ static int SetupCrouchSprite(AActor *self, int crouchsprite)
int wadnorm = Wads.GetLumpFile(spritenorm);
int wadcrouch = Wads.GetLumpFile(spritenorm);
if (wadnorm > Wads.GetIwadNum() && wadcrouch <= Wads.GetIwadNum())
if (wadnorm > Wads.GetMaxIwadNum() && wadcrouch <= Wads.GetMaxIwadNum())
{
// Question: Add an option / disable crouching or do what?
return false;

View file

@ -1152,7 +1152,7 @@ class GLDefsParser
if (lumpnum != -1)
{
if (iwad && Wads.GetLumpFile(lumpnum) <= Wads.GetIwadNum()) useme = true;
if (iwad && Wads.GetLumpFile(lumpnum) <= Wads.GetMaxIwadNum()) useme = true;
if (thiswad && Wads.GetLumpFile(lumpnum) == workingLump) useme = true;
}
if (!useme) return;
@ -1336,7 +1336,7 @@ class GLDefsParser
if (lumpnum != -1)
{
if (iwad && Wads.GetLumpFile(lumpnum) <= Wads.GetIwadNum()) useme = true;
if (iwad && Wads.GetLumpFile(lumpnum) <= Wads.GetMaxIwadNum()) useme = true;
if (thiswad && Wads.GetLumpFile(lumpnum) == workingLump) useme = true;
}
if (!useme) return;

View file

@ -1106,7 +1106,7 @@ void ST_Endoom()
exit(0);
}
if (Wads.GetLumpFile(endoom_lump) == Wads.GetIwadNum() && showendoom == 2)
if (Wads.GetLumpFile(endoom_lump) == Wads.GetMaxIwadNum() && showendoom == 2)
{
// showendoom==2 means to show only lumps from PWADs.
exit(0);