From 2b7e094019dc45d8bd8c25209c1c253fd041bf70 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 8 Dec 2022 11:35:21 +0100 Subject: [PATCH] - fixed: aliases for null textures must still be set. Also added 'listtexturealiases' CCMD for debugging. --- source/common/textures/texturemanager.cpp | 27 ++++++++++++++++++++++- source/common/textures/texturemanager.h | 1 + 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/source/common/textures/texturemanager.cpp b/source/common/textures/texturemanager.cpp index 52d0efd02..5bb2b299d 100644 --- a/source/common/textures/texturemanager.cpp +++ b/source/common/textures/texturemanager.cpp @@ -1604,10 +1604,31 @@ void FTextureManager::SetTranslation(FTextureID fromtexnum, FTextureID totexnum) void FTextureManager::AddAlias(const char* name, FGameTexture* tex) { FTextureID id = tex->GetID(); - if (tex != Textures[id.GetIndex()].Texture || !tex->isValid()) return; // Whatever got passed in here was not valid, so ignore the alias. + if (tex != Textures[id.GetIndex()].Texture)// || !tex->isValid()) + { + return; // Whatever got passed in here was not valid, so ignore the alias. + } aliases.Insert(name, id.GetIndex()); } +void FTextureManager::Listaliases() +{ + decltype(aliases)::Iterator it(aliases); + decltype(aliases)::Pair* pair; + + TArray list; + while (it.NextPair(pair)) + { + auto tex = GetGameTexture(pair->Value); + list.Push(FStringf("%s -> %s%s", pair->Key.GetChars(), tex ? tex->GetName().GetChars() : "(null)", ((tex && tex->GetUseType() == ETextureType::Null) ? ", null" : ""))); + } + std::sort(list.begin(), list.end(), [](const FString& l, const FString& r) { return l.CompareNoCase(r) < 0; }); + for (auto& s : list) + { + Printf("%s\n", s.GetChars()); + } +} + //========================================================================== // // FTextureID::operator+ @@ -1627,3 +1648,7 @@ CCMD(flushtextures) TexMan.FlushAll(); } +CCMD(listtexturealiases) +{ + TexMan.Listaliases(); +} diff --git a/source/common/textures/texturemanager.h b/source/common/textures/texturemanager.h index 84140c54d..035d614ec 100644 --- a/source/common/textures/texturemanager.h +++ b/source/common/textures/texturemanager.h @@ -76,6 +76,7 @@ public: bool OkForLocalization(FTextureID texnum, const char *substitute, int locnum); void FlushAll(); + void Listaliases(); FTextureID GetFrontSkyLayer(FTextureID); FTextureID GetRawTexture(FTextureID tex, bool dontlookup = false); void SetRawTexture(FTextureID texid)