mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-14 08:30:50 +00:00
- extended lump injection to allow injecting data into a PWAD's directory, not just the IWAD.
This commit is contained in:
parent
31aa855a51
commit
587fd75190
3 changed files with 27 additions and 22 deletions
|
@ -74,7 +74,7 @@ struct FResourceLump
|
|||
int ReleaseCache();
|
||||
|
||||
protected:
|
||||
virtual int FillCache() = 0;
|
||||
virtual int FillCache() {}
|
||||
|
||||
};
|
||||
|
||||
|
@ -114,6 +114,8 @@ public:
|
|||
uint32_t LumpCount() const { return NumLumps; }
|
||||
uint32_t GetFirstLump() const { return FirstLump; }
|
||||
void SetFirstLump(uint32_t f) { FirstLump = f; }
|
||||
const FString &GetHash() const { return Hash; }
|
||||
|
||||
|
||||
virtual void FindStrifeTeaserVoices ();
|
||||
virtual bool Open(bool quiet) = 0;
|
||||
|
|
|
@ -146,9 +146,12 @@ void FWadCollection::InitMultipleFiles (TArray<FString> &filenames, const TArray
|
|||
{
|
||||
int baselump = NumLumps;
|
||||
AddFile (filenames[i]);
|
||||
|
||||
if (i == (unsigned)MaxIwadIndex) MoveLumpsInFolder("after_iwad/");
|
||||
FStringf path("filter/%s", Files.Last()->GetHash().GetChars());
|
||||
MoveLumpsInFolder(path);
|
||||
}
|
||||
MoveIWadModifiers();
|
||||
|
||||
|
||||
NumLumps = LumpInfo.Size();
|
||||
if (NumLumps == 0)
|
||||
{
|
||||
|
@ -1056,39 +1059,38 @@ void FWadCollection::FixMacHexen()
|
|||
|
||||
//==========================================================================
|
||||
//
|
||||
// MoveIWadModifiers
|
||||
// MoveLumpsInFolder
|
||||
//
|
||||
// Moves all content from the after_iwad subfolder of the internal
|
||||
// resources to the first positions in the lump directory after the IWAD.
|
||||
// Moves all content from the given subfolder of the internal
|
||||
// resources to the current end of the directory.
|
||||
// Used to allow modifying content in the base files, this is needed
|
||||
// so that Hacx and Harmony can override some content that clashes
|
||||
// with localization.
|
||||
// with localization, and to inject modifying data into mods, in case
|
||||
// this is needed for some compatibility requirement.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FWadCollection::MoveIWadModifiers()
|
||||
{
|
||||
TArray<LumpRecord> lumpsToMove;
|
||||
static FResourceLump placeholderLump;
|
||||
|
||||
void FWadCollection::MoveLumpsInFolder(const char *path)
|
||||
{
|
||||
auto len = strlen(path);
|
||||
auto wadnum = LumpInfo.Last().wadnum;
|
||||
|
||||
unsigned i;
|
||||
for (i = 0; i < LumpInfo.Size(); i++)
|
||||
{
|
||||
auto& li = LumpInfo[i];
|
||||
if (li.wadnum >= GetIwadNum()) break;
|
||||
if (li.lump->FullName.Left(11).CompareNoCase("after_iwad/") == 0)
|
||||
if (li.lump->FullName.Left(len).CompareNoCase(path) == 0)
|
||||
{
|
||||
lumpsToMove.Push(li);
|
||||
LumpInfo.Delete(i--);
|
||||
LumpInfo.Push(li);
|
||||
li.lump = &placeholderLump; // Make the old entry point to something empty. We cannot delete the lump record here because it'd require adjustment of all indices in the list.
|
||||
auto &ln = LumpInfo.Last();
|
||||
ln.wadnum = wadnum; // pretend this is from the WAD this is injected into.
|
||||
ln.lump->LumpNameSetup(ln.lump->FullName.Mid(len));
|
||||
}
|
||||
}
|
||||
if (lumpsToMove.Size() == 0) return;
|
||||
for (; i < LumpInfo.Size() && LumpInfo[i].wadnum <= Wads.GetMaxIwadNum(); i++);
|
||||
for (auto& li : lumpsToMove)
|
||||
{
|
||||
li.lump->LumpNameSetup(li.lump->FullName.Mid(11));
|
||||
li.wadnum = Wads.GetMaxIwadNum(); // pretend this comes from the IWAD itself.
|
||||
LumpInfo.Insert(i++, li);
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
@ -222,7 +222,8 @@ private:
|
|||
void RenameNerve();
|
||||
void FixMacHexen();
|
||||
void DeleteAll();
|
||||
void MoveIWadModifiers();
|
||||
void MoveLumpsInFolder(const char *);
|
||||
|
||||
FileReader * GetFileReader(int wadnum); // Gets a FileReader object to the entire WAD
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue