From a15ac437225893b4e2f1025782ffce988a390b35 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 12 Apr 2021 00:20:45 +0200 Subject: [PATCH] - enable embedding of blood.rff and sounds.rff in mod archives when playing Blood Some mods provide pregenerated resources, this allows loading them without picking them apart first. --- source/common/filesystem/file_7z.cpp | 2 +- source/common/filesystem/file_directory.cpp | 2 +- source/common/filesystem/file_pak.cpp | 2 +- source/common/filesystem/file_zip.cpp | 2 +- source/common/filesystem/resourcefile.cpp | 15 +++------------ source/common/filesystem/resourcefile.h | 3 ++- source/core/initfs.cpp | 5 +++++ 7 files changed, 14 insertions(+), 17 deletions(-) diff --git a/source/common/filesystem/file_7z.cpp b/source/common/filesystem/file_7z.cpp index 8d0d64bb2..f207702d0 100644 --- a/source/common/filesystem/file_7z.cpp +++ b/source/common/filesystem/file_7z.cpp @@ -293,7 +293,7 @@ bool F7ZFile::Open(bool quiet, LumpFilterInfo *filter) lump_p->Owner = this; lump_p->Flags = LUMPF_FULLPATH|LUMPF_COMPRESSED; lump_p->Position = i; - lump_p->CheckEmbedded(); + lump_p->CheckEmbedded(filter); lump_p++; } // Resize the lump record array to its actual size diff --git a/source/common/filesystem/file_directory.cpp b/source/common/filesystem/file_directory.cpp index 7654764cb..4f2c94eba 100644 --- a/source/common/filesystem/file_directory.cpp +++ b/source/common/filesystem/file_directory.cpp @@ -209,7 +209,7 @@ void FDirectory::AddEntry(const char *fullpath, int size) lump_p->LumpSize = size; lump_p->Owner = this; lump_p->Flags = 0; - lump_p->CheckEmbedded(); + lump_p->CheckEmbedded(nullptr); } diff --git a/source/common/filesystem/file_pak.cpp b/source/common/filesystem/file_pak.cpp index 5ff9ff886..13aafa985 100644 --- a/source/common/filesystem/file_pak.cpp +++ b/source/common/filesystem/file_pak.cpp @@ -109,7 +109,7 @@ bool FPakFile::Open(bool quiet, LumpFilterInfo* filter) Lumps[i].Owner = this; Lumps[i].Position = LittleLong(fileinfo[i].filepos); Lumps[i].LumpSize = LittleLong(fileinfo[i].filelen); - Lumps[i].CheckEmbedded(); + Lumps[i].CheckEmbedded(filter); } GenerateHash(); PostProcessArchive(&Lumps[0], sizeof(Lumps[0]), filter); diff --git a/source/common/filesystem/file_zip.cpp b/source/common/filesystem/file_zip.cpp index 2adca1160..f33b60ba4 100644 --- a/source/common/filesystem/file_zip.cpp +++ b/source/common/filesystem/file_zip.cpp @@ -337,7 +337,7 @@ bool FZipFile::Open(bool quiet, LumpFilterInfo* filter) lump_p->CRC32 = zip_fh->CRC32; lump_p->CompressedSize = LittleLong(zip_fh->CompressedSize); lump_p->Position = LittleLong(zip_fh->LocalHeaderOffset); - lump_p->CheckEmbedded(); + lump_p->CheckEmbedded(filter); lump_p++; } diff --git a/source/common/filesystem/resourcefile.cpp b/source/common/filesystem/resourcefile.cpp index d718d74ec..5fc484b23 100644 --- a/source/common/filesystem/resourcefile.cpp +++ b/source/common/filesystem/resourcefile.cpp @@ -122,7 +122,7 @@ static bool IsWadInFolder(const FResourceFile* const archive, const char* const return 0 == filePath.CompareNoCase(resPath); } -void FResourceLump::CheckEmbedded() +void FResourceLump::CheckEmbedded(LumpFilterInfo* lfi) { // Checks for embedded archives const char *c = strstr(FullName, ".wad"); @@ -130,22 +130,13 @@ void FResourceLump::CheckEmbedded() { Flags |= LUMPF_EMBEDDED; } - /* later - else + else if (lfi) for (auto& fstr : lfi->embeddings) { - if (c==NULL) c = strstr(Name, ".zip"); - if (c==NULL) c = strstr(Name, ".pk3"); - if (c==NULL) c = strstr(Name, ".7z"); - if (c==NULL) c = strstr(Name, ".pak"); - if (c && strlen(c) <= 4) + if (!stricmp(FullName, fstr)) { - // Mark all embedded archives in any directory Flags |= LUMPF_EMBEDDED; - memset(Name, 0, 8); } } - */ - } diff --git a/source/common/filesystem/resourcefile.h b/source/common/filesystem/resourcefile.h index bfd20e816..5e9276c76 100644 --- a/source/common/filesystem/resourcefile.h +++ b/source/common/filesystem/resourcefile.h @@ -15,6 +15,7 @@ struct LumpFilterInfo // The following are for checking if the root directory of a zip can be removed. TArray reservedFolders; TArray requiredPrefixes; + TArray embeddings; std::function postprocessFunc; }; @@ -111,7 +112,7 @@ public: virtual int GetIndexNum() const { return -1; } virtual int GetNamespace() const { return 0; } void LumpNameSetup(FString iname); - void CheckEmbedded(); + void CheckEmbedded(LumpFilterInfo* lfi); virtual FCompressedBuffer GetRawData(); void *Lock(); // validates the cache and increases the refcount. diff --git a/source/core/initfs.cpp b/source/core/initfs.cpp index 6910d2cdf..3ad2283f4 100644 --- a/source/core/initfs.cpp +++ b/source/core/initfs.cpp @@ -388,6 +388,11 @@ void InitFileSystem(TArray& groups) LumpFilterInfo lfi; for (auto p : iwad_folders) lfi.reservedFolders.Push(p); for (auto p = iwad_reserved(); *p; p++) lfi.requiredPrefixes.Push(*p); + if (isBlood()) + { + lfi.embeddings.Push("blood.rff"); + lfi.embeddings.Push("sounds.rff"); + } lfi.dotFilter = LumpFilter;