From 05d93c7fa1be9245dd5211b7dc1bdf0961b39eea Mon Sep 17 00:00:00 2001 From: number Zero Date: Wed, 13 Sep 2017 23:03:18 +0300 Subject: Load files from subfolders in texturepacks Updated and rebased version of a PR by red-001 --- src/client/tile.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/client/tile.cpp') 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 &getTextureDirs() +{ + static thread_local std::vector dirs = + fs::GetRecursiveDirs(g_settings->get("texture_path")); + return dirs; +} -- cgit v1.2.3