diff --git a/src/common/engine/serializer.cpp b/src/common/engine/serializer.cpp index ec84a5fee..8d5f9a6b8 100644 --- a/src/common/engine/serializer.cpp +++ b/src/common/engine/serializer.cpp @@ -1135,7 +1135,7 @@ FSerializer &Serialize(FSerializer &arc, const char *key, FTextureID &value, FTe const char *name; auto lump = pic->GetSourceLump(); - if (fileSystem.GetLinkedTexture(lump) == pic) + if (TexMan.GetLinkedTexture(lump) == pic) { name = fileSystem.GetFileFullName(lump); } diff --git a/src/common/filesystem/filesystem.cpp b/src/common/filesystem/filesystem.cpp index b7c370360..2b300abcf 100644 --- a/src/common/filesystem/filesystem.cpp +++ b/src/common/filesystem/filesystem.cpp @@ -55,7 +55,6 @@ struct FileSystem::LumpRecord { FResourceLump *lump; - FGameTexture* linkedTexture; LumpShortName shortName; FString longName; int rfnum; @@ -67,7 +66,6 @@ struct FileSystem::LumpRecord { lump = lmp; rfnum = filenum; - linkedTexture = nullptr; flags = 0; if (lump->Flags & LUMPF_SHORTNAME) @@ -748,35 +746,6 @@ int FileSystem::GetResource (int resid, const char *type, int filenum) const return i; } -//========================================================================== -// -// link a texture with a given lump -// -//========================================================================== - -void FileSystem::SetLinkedTexture(int lump, FGameTexture *tex) -{ - if ((size_t)lump < NumEntries) - { - FileInfo[lump].linkedTexture = tex; - } -} - -//========================================================================== -// -// retrieve linked texture -// -//========================================================================== - -FGameTexture *FileSystem::GetLinkedTexture(int lump) -{ - if ((size_t)lump < NumEntries) - { - return FileInfo[lump].linkedTexture; - } - return NULL; -} - //========================================================================== // // FileLength diff --git a/src/common/filesystem/filesystem.h b/src/common/filesystem/filesystem.h index fb72d77de..b6ce6bad8 100644 --- a/src/common/filesystem/filesystem.h +++ b/src/common/filesystem/filesystem.h @@ -16,7 +16,6 @@ class FResourceFile; struct FResourceLump; -class FGameTexture; union LumpShortName { @@ -125,10 +124,6 @@ public: inline int CheckNumForFullName (const FString &name, int wadfile) { return CheckNumForFullName(name.GetChars(), wadfile); } inline int GetNumForFullName (const FString &name) { return GetNumForFullName(name.GetChars()); } - void SetLinkedTexture(int lump, FGameTexture *tex); - FGameTexture *GetLinkedTexture(int lump); - - void ReadFile (int lump, void *dest); TArray GetFileData(int lump, int pad = 0); // reads lump into a writable buffer and optionally adds some padding at the end. (FileData isn't writable!) FileData ReadFile (int lump); diff --git a/src/common/scripting/interface/vmnatives.cpp b/src/common/scripting/interface/vmnatives.cpp index 54cc0d2a9..f04e39d45 100644 --- a/src/common/scripting/interface/vmnatives.cpp +++ b/src/common/scripting/interface/vmnatives.cpp @@ -424,7 +424,7 @@ DEFINE_ACTION_FUNCTION(_TexMan, GetName) { // Textures for full path names do not have their own name, they merely link to the source lump. auto lump = tex->GetSourceLump(); - if (fileSystem.GetLinkedTexture(lump) == tex) + if (TexMan.GetLinkedTexture(lump) == tex) retval = fileSystem.GetFileFullName(lump); } } diff --git a/src/common/textures/gametexture.cpp b/src/common/textures/gametexture.cpp index be4063213..3ddc8dd1b 100644 --- a/src/common/textures/gametexture.cpp +++ b/src/common/textures/gametexture.cpp @@ -98,8 +98,8 @@ FGameTexture::~FGameTexture() { if (Base != nullptr) { - FGameTexture* link = fileSystem.GetLinkedTexture(GetSourceLump()); - if (link == this) fileSystem.SetLinkedTexture(GetSourceLump(), nullptr); + FGameTexture* link = TexMan.GetLinkedTexture(GetSourceLump()); + if (link == this) TexMan.SetLinkedTexture(GetSourceLump(), nullptr); } if (SoftwareTexture != nullptr) { diff --git a/src/common/textures/texturemanager.cpp b/src/common/textures/texturemanager.cpp index 988498408..c149d99b2 100644 --- a/src/common/textures/texturemanager.cpp +++ b/src/common/textures/texturemanager.cpp @@ -244,11 +244,11 @@ FTextureID FTextureManager::CheckForTexture (const char *name, ETextureType uset // Any graphic being placed in the zip's root directory can not be found by this. if (strchr(name, '/') || (flags & TEXMAN_ForceLookup)) { - FGameTexture *const NO_TEXTURE = (FGameTexture*)-1; + FGameTexture *const NO_TEXTURE = (FGameTexture*)-1; // marker for lumps we already checked that do not map to a texture. int lump = fileSystem.CheckNumForFullName(name); if (lump >= 0) { - FGameTexture *tex = fileSystem.GetLinkedTexture(lump); + FGameTexture *tex = GetLinkedTexture(lump); if (tex == NO_TEXTURE) return FTextureID(-1); if (tex != NULL) return tex->GetID(); if (flags & TEXMAN_DontCreate) return FTextureID(-1); // we only want to check, there's no need to create a texture if we don't have one yet. @@ -256,13 +256,13 @@ FTextureID FTextureManager::CheckForTexture (const char *name, ETextureType uset if (tex != NULL) { tex->AddAutoMaterials(); - fileSystem.SetLinkedTexture(lump, tex); + SetLinkedTexture(lump, tex); return AddGameTexture(tex); } else { // mark this lump as having no valid texture so that we don't have to retry creating one later. - fileSystem.SetLinkedTexture(lump, NO_TEXTURE); + SetLinkedTexture(lump, NO_TEXTURE); } } } @@ -1627,6 +1627,37 @@ void FTextureManager::Listaliases() } } +//========================================================================== +// +// link a texture with a given lump +// +//========================================================================== + +void FTextureManager::SetLinkedTexture(int lump, FGameTexture* tex) +{ + if ((size_t)lump < fileSystem.GetNumEntries()) + { + linkedMap.Insert(lump, tex); + } +} + +//========================================================================== +// +// retrieve linked texture +// +//========================================================================== + +FGameTexture* FTextureManager::GetLinkedTexture(int lump) +{ + if ((size_t)lump < fileSystem.GetNumEntries()) + { + auto check = linkedMap.CheckKey(lump); + if (check) return *check; + } + return nullptr; +} + + //========================================================================== // // FTextureID::operator+ diff --git a/src/common/textures/texturemanager.h b/src/common/textures/texturemanager.h index 3f80514f3..cf799153f 100644 --- a/src/common/textures/texturemanager.h +++ b/src/common/textures/texturemanager.h @@ -88,6 +88,15 @@ public: } } + //========================================================================== + // + // link a texture with a given lump + // + //========================================================================== + + TMap linkedMap; + void SetLinkedTexture(int lump, FGameTexture* tex); + FGameTexture* GetLinkedTexture(int lump); enum {