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 +++++++++++--- src/client/tile.h | 2 ++ 2 files changed, 13 insertions(+), 3 deletions(-) (limited to 'src/client') 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; +} 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 &getTextureDirs(); -- cgit v1.2.3