From 13f7b53b1caeec5abc3e07e1c4f7c3e50a1ae249 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 4 Jun 2018 17:08:09 +0200 Subject: [PATCH] Revert "Don't force DDS file usage (fixes #1392)" This reverts commit 90f3ff2da4b37a6766e0eb369150d866ec488d06. --- components/misc/resourcehelpers.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/components/misc/resourcehelpers.cpp b/components/misc/resourcehelpers.cpp index f38387ff8..5cf4378b8 100644 --- a/components/misc/resourcehelpers.cpp +++ b/components/misc/resourcehelpers.cpp @@ -63,16 +63,28 @@ std::string Misc::ResourceHelpers::correctResourcePath(const std::string &topLev std::string origExt = correctedPath; - if (vfs->exists(origExt) - || (changeExtensionToDds(correctedPath) && vfs->exists(correctedPath))) + // since we know all (GOTY edition or less) textures end + // in .dds, we change the extension + bool changedToDds = changeExtensionToDds(correctedPath); + if (vfs->exists(correctedPath)) return correctedPath; + // if it turns out that the above wasn't true in all cases (not for vanilla, but maybe mods) + // verify, and revert if false (this call succeeds quickly, but fails slowly) + if (changedToDds && vfs->exists(origExt)) + return origExt; // fall back to a resource in the top level directory if it exists - std::string fallback = topLevelDirectory + "\\" + getBasename(origExt); - if (vfs->exists(fallback) - || (changeExtensionToDds(fallback) && vfs->exists(fallback))) + std::string fallback = topLevelDirectory + "\\" + getBasename(correctedPath); + if (vfs->exists(fallback)) return fallback; + if (changedToDds) + { + fallback = topLevelDirectory + "\\" + getBasename(origExt); + if (vfs->exists(fallback)) + return fallback; + } + return correctedPath; }