From e5cb1976d361a8263c04478d2fe32aad44f31bdb Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 5 Jul 2021 22:39:24 +0200 Subject: [PATCH] - disable texture name truncation for textures/ directory. Unlike Doom, a similar limit does not exist here and must not be enforced. Any texture from this folder needs to be usable by its full name without extension to be able to replace named tiles. --- source/common/textures/texturemanager.cpp | 60 +++++++++++++++-------- source/common/textures/texturemanager.h | 1 + source/core/gamecontrol.cpp | 1 + 3 files changed, 42 insertions(+), 20 deletions(-) diff --git a/source/common/textures/texturemanager.cpp b/source/common/textures/texturemanager.cpp index c07a52fb5..c4fcfd841 100644 --- a/source/common/textures/texturemanager.cpp +++ b/source/common/textures/texturemanager.cpp @@ -448,7 +448,13 @@ FTextureID FTextureManager::CreateTexture (int lumpnum, ETextureType usetype) if (lumpnum != -1) { FString str; - fileSystem.GetFileShortName(str, lumpnum); + if (!usefullnames) + fileSystem.GetFileShortName(str, lumpnum); + else + { + auto fn = fileSystem.GetFileFullName(lumpnum); + str = ExtractFileBase(fn); + } auto out = MakeGameTexture(CreateTextureFromLump(lumpnum, usetype == ETextureType::Flat), str, usetype); if (out != NULL) @@ -557,30 +563,44 @@ void FTextureManager::AddGroup(int wadnum, int ns, ETextureType usetype) int lasttx = fileSystem.GetLastEntry(wadnum); FString Name; - // Go from first to last so that ANIMDEFS work as expected. However, - // to avoid duplicates (and to keep earlier entries from overriding - // later ones), the texture is only inserted if it is the one returned - // by doing a check by name in the list of wads. - - for (; firsttx <= lasttx; ++firsttx) + if (!usefullnames) { - if (fileSystem.GetFileNamespace(firsttx) == ns) - { - fileSystem.GetFileShortName (Name, firsttx); + // Go from first to last so that ANIMDEFS work as expected. However, + // to avoid duplicates (and to keep earlier entries from overriding + // later ones), the texture is only inserted if it is the one returned + // by doing a check by name in the list of wads. - if (fileSystem.CheckNumForName (Name, ns) == firsttx) - { - CreateTexture (firsttx, usetype); - } - progressFunc(); - } - else if (ns == ns_flats && fileSystem.GetFileFlags(firsttx) & LUMPF_MAYBEFLAT) + for (; firsttx <= lasttx; ++firsttx) { - if (fileSystem.CheckNumForName (Name, ns) < firsttx) + if (fileSystem.GetFileNamespace(firsttx) == ns) { - CreateTexture (firsttx, usetype); + fileSystem.GetFileShortName(Name, firsttx); + + if (fileSystem.CheckNumForName(Name, ns) == firsttx) + { + CreateTexture(firsttx, usetype); + } + progressFunc(); + } + else if (ns == ns_flats && fileSystem.GetFileFlags(firsttx) & LUMPF_MAYBEFLAT) + { + if (fileSystem.CheckNumForName(Name, ns) < firsttx) + { + CreateTexture(firsttx, usetype); + } + progressFunc(); + } + } + } + else + { + // The duplicate check does not work with this (yet.) + for (; firsttx <= lasttx; ++firsttx) + { + if (fileSystem.GetFileNamespace(firsttx) == ns) + { + CreateTexture(firsttx, usetype); } - progressFunc(); } } } diff --git a/source/common/textures/texturemanager.h b/source/common/textures/texturemanager.h index ecf6b2b1e..076ee1769 100644 --- a/source/common/textures/texturemanager.h +++ b/source/common/textures/texturemanager.h @@ -206,6 +206,7 @@ public: FTextureID glPart2; FTextureID glPart; FTextureID mirrorTexture; + bool usefullnames; }; diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index fb6bb415f..f62502991 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -886,6 +886,7 @@ void GetGames() static void InitTextures() { + TexMan.usefullnames = true; TexMan.Init([]() {}, [](BuildInfo&) {}); StartScreen->Progress(); mdinit();