Textures: Load base pack only as last fallback (#8974)

This commit is contained in:
SmallJoker 2019-09-29 19:57:29 +02:00 committed by GitHub
parent c2458d3d3a
commit 61e9c1b0dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 5 deletions

View File

@ -122,9 +122,14 @@ std::string getImagePath(std::string path)
Utilizes a thread-safe cache. Utilizes a thread-safe cache.
*/ */
std::string getTexturePath(const std::string &filename) std::string getTexturePath(const std::string &filename, bool *is_base_pack)
{ {
std::string fullpath; std::string fullpath;
// This can set a wrong value on cached textures, but is irrelevant because
// is_base_pack is only passed when initializing the textures the first time
if (is_base_pack)
*is_base_pack = false;
/* /*
Check from cache Check from cache
*/ */
@ -154,6 +159,8 @@ std::string getTexturePath(const std::string &filename)
std::string testpath = base_path + DIR_DELIM + filename; std::string testpath = base_path + DIR_DELIM + filename;
// Check all filename extensions. Returns "" if not found. // Check all filename extensions. Returns "" if not found.
fullpath = getImagePath(testpath); fullpath = getImagePath(testpath);
if (is_base_pack && !fullpath.empty())
*is_base_pack = true;
} }
// Add to cache (also an empty result is cached) // Add to cache (also an empty result is cached)
@ -215,9 +222,11 @@ public:
bool need_to_grab = true; bool need_to_grab = true;
// Try to use local texture instead if asked to // Try to use local texture instead if asked to
if (prefer_local){ if (prefer_local) {
std::string path = getTexturePath(name); bool is_base_pack;
if (!path.empty()) { std::string path = getTexturePath(name, &is_base_pack);
// Ignore base pack
if (!path.empty() && !is_base_pack) {
video::IImage *img2 = RenderingEngine::get_video_driver()-> video::IImage *img2 = RenderingEngine::get_video_driver()->
createImageFromFile(path.c_str()); createImageFromFile(path.c_str());
if (img2){ if (img2){

View File

@ -64,7 +64,7 @@ std::string getImagePath(std::string path);
Utilizes a thread-safe cache. Utilizes a thread-safe cache.
*/ */
std::string getTexturePath(const std::string &filename); std::string getTexturePath(const std::string &filename, bool *is_base_pack = nullptr);
void clearTextureNameCache(); void clearTextureNameCache();