diff options
author | SmallJoker <SmallJoker@users.noreply.github.com> | 2019-09-29 19:57:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-29 19:57:29 +0200 |
commit | 61e9c1b0dd7da9cf45969875a89af5203910d290 (patch) | |
tree | ce722a2bb927803981216fa5022f67129fff8117 /src | |
parent | c2458d3d3a7f1ce309861e237fa52c13b7342e34 (diff) | |
download | minetest-61e9c1b0dd7da9cf45969875a89af5203910d290.tar.gz minetest-61e9c1b0dd7da9cf45969875a89af5203910d290.tar.bz2 minetest-61e9c1b0dd7da9cf45969875a89af5203910d290.zip |
Textures: Load base pack only as last fallback (#8974)
Diffstat (limited to 'src')
-rw-r--r-- | src/client/tile.cpp | 17 | ||||
-rw-r--r-- | src/client/tile.h | 2 |
2 files changed, 14 insertions, 5 deletions
diff --git a/src/client/tile.cpp b/src/client/tile.cpp index 009237c51..3d9e2470a 100644 --- a/src/client/tile.cpp +++ b/src/client/tile.cpp @@ -122,9 +122,14 @@ std::string getImagePath(std::string path) 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; + + // 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 */ @@ -154,6 +159,8 @@ std::string getTexturePath(const std::string &filename) std::string testpath = base_path + DIR_DELIM + filename; // Check all filename extensions. Returns "" if not found. fullpath = getImagePath(testpath); + if (is_base_pack && !fullpath.empty()) + *is_base_pack = true; } // Add to cache (also an empty result is cached) @@ -215,9 +222,11 @@ public: bool need_to_grab = true; // Try to use local texture instead if asked to - if (prefer_local){ - std::string path = getTexturePath(name); - if (!path.empty()) { + if (prefer_local) { + bool is_base_pack; + std::string path = getTexturePath(name, &is_base_pack); + // Ignore base pack + if (!path.empty() && !is_base_pack) { video::IImage *img2 = RenderingEngine::get_video_driver()-> createImageFromFile(path.c_str()); if (img2){ diff --git a/src/client/tile.h b/src/client/tile.h index 3a3ec58a3..533df676e 100644 --- a/src/client/tile.h +++ b/src/client/tile.h @@ -64,7 +64,7 @@ std::string getImagePath(std::string path); 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(); |