From 5dcfa1cb0ccbd805c154f3edb8e6d634510cabc5 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 26 Dec 2019 10:47:10 +0100 Subject: [PATCH] - do not use the internal SWCUSTOM.TXT from the Twin Dragon add-on. There's a second variant without this definition, so this needs to be defined internally, and since it needs to be done internally it may receive proper localization labels. --- source/common/filesystem/filesystem.cpp | 31 +++- source/common/filesystem/filesystem.h | 4 +- source/common/gamecontrol.h | 1 + source/common/initfs.cpp | 6 +- source/common/searchpaths.cpp | 8 + wadsrc/static/demolition/demolition.grpinfo | 31 ++++ wadsrc/static/demolition/language.csv | 54 ++---- .../shadowwarrior.twindragon/SWCUSTOM.TXT | 154 ++++++++++++++++++ 8 files changed, 250 insertions(+), 39 deletions(-) create mode 100644 wadsrc/static/filter/shadowwarrior.twindragon/SWCUSTOM.TXT diff --git a/source/common/filesystem/filesystem.cpp b/source/common/filesystem/filesystem.cpp index 759cb4af0..2e5bcc75f 100644 --- a/source/common/filesystem/filesystem.cpp +++ b/source/common/filesystem/filesystem.cpp @@ -100,7 +100,7 @@ void FileSystem::DeleteAll () // //========================================================================== -int FileSystem::InitMultipleFiles (TArray &filenames, const TArray &deletelumps) +int FileSystem::InitMultipleFiles (TArray &filenames, const TArray &deletelumps, int maingamefiles) { int numfiles; @@ -126,6 +126,7 @@ int FileSystem::InitMultipleFiles (TArray &filenames, const TArray &filenames, const TArray& deletelumps, int numgamefiles) +{ + // This must account for the game directory being inserted at index 2. + // Deletion may only occur in the main game file, the directory and the add-on, there are no secondary dependencies, i.e. more than two game files. + numgamefiles++; + if (deletelumps.Size()) + for (uint32_t i = 0; i < FileInfo.Size(); i++) + { + if (FileInfo[i].rfnum >= 1 && FileInfo[i].rfnum <= numgamefiles) + { + auto cmp = FileInfo[i].lump->LumpName[FResourceLump::FullNameType].GetChars(); + for (auto &str : deletelumps) + { + if (!str.CompareNoCase(cmp)) + { + for (auto& n : FileInfo[i].lump->LumpName) n = NAME_None; + } + } + } + } +} + //========================================================================== // // AddFile diff --git a/source/common/filesystem/filesystem.h b/source/common/filesystem/filesystem.h index ae4a02db9..e89f31430 100644 --- a/source/common/filesystem/filesystem.h +++ b/source/common/filesystem/filesystem.h @@ -81,7 +81,9 @@ public: FileSystem () = default; ~FileSystem (); - int InitMultipleFiles (TArray &filenames, const TArray &todelete); + int InitMultipleFiles (TArray &filenames, const TArray &todelete, int maingamefiles); + void DeleteStuff(const TArray& deletelumps, int numgamefiles); + void AddFile (const char *filename, FileReader *wadinfo = NULL, bool nosubdirflag = false); void AddAdditionalFile(const char* filename, FileReader* wadinfo = NULL) {} int CheckIfResourceFileLoaded (const char *name) noexcept; diff --git a/source/common/gamecontrol.h b/source/common/gamecontrol.h index ca1ff4cac..5d3eb9c79 100644 --- a/source/common/gamecontrol.h +++ b/source/common/gamecontrol.h @@ -124,6 +124,7 @@ struct GrpInfo int flags = 0; bool loaddirectory = false; TArray mustcontain; + TArray tobedeleted; TArray loadfiles; TArray loadart; }; diff --git a/source/common/initfs.cpp b/source/common/initfs.cpp index 0bb9a9ee9..fedad69b8 100644 --- a/source/common/initfs.cpp +++ b/source/common/initfs.cpp @@ -378,7 +378,11 @@ void InitFileSystem(TArray& groups) } TArray todelete; - fileSystem.InitMultipleFiles(Files, todelete); + for (auto& g : groups) + { + todelete.Append(g.FileInfo.tobedeleted); + } + fileSystem.InitMultipleFiles(Files, todelete, groups.Size()); FILE* f = fopen("filesystem.dir", "wb"); for (int i = 0; i < fileSystem.GetNumEntries(); i++) diff --git a/source/common/searchpaths.cpp b/source/common/searchpaths.cpp index 0c464bd3b..aa5aa4c08 100644 --- a/source/common/searchpaths.cpp +++ b/source/common/searchpaths.cpp @@ -797,6 +797,14 @@ static TArray ParseGrpInfo(const char *fn, FileReader &fr, TMap