diff options
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/tile.cpp | 14 | ||||
-rw-r--r-- | src/client/tile.h | 2 |
2 files changed, 13 insertions, 3 deletions
diff --git a/src/client/tile.cpp b/src/client/tile.cpp index d0b9d81bf..91a3c0a38 100644 --- a/src/client/tile.cpp +++ b/src/client/tile.cpp @@ -129,11 +129,12 @@ std::string getTexturePath(const std::string &filename) /* Check from texture_path */ - const std::string &texture_path = g_settings->get("texture_path"); - if (!texture_path.empty()) { - std::string testpath = texture_path + DIR_DELIM + filename; + for (const auto &path : getTextureDirs()) { + std::string testpath = path + DIR_DELIM + filename; // Check all filename extensions. Returns "" if not found. fullpath = getImagePath(testpath); + if (!fullpath.empty()) + break; } /* @@ -2388,3 +2389,10 @@ video::ITexture *TextureSource::getShaderFlagsTexture(bool normalmap_present) return getTexture(tname); } + +const std::vector<std::string> &getTextureDirs() +{ + static thread_local std::vector<std::string> dirs = + fs::GetRecursiveDirs(g_settings->get("texture_path")); + return dirs; +} diff --git a/src/client/tile.h b/src/client/tile.h index e69dbe0c7..817b1aa58 100644 --- a/src/client/tile.h +++ b/src/client/tile.h @@ -337,3 +337,5 @@ struct TileSpec //! The first is base texture, the second is overlay. TileLayer layers[MAX_TILE_LAYERS]; }; + +const std::vector<std::string> &getTextureDirs(); |