aboutsummaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
authornumber Zero <silverunicorn2011@yandex.ru>2017-09-13 23:03:18 +0300
committerparamat <mat.gregory@virginmedia.com>2017-11-17 19:23:08 +0000
commit05d93c7fa1be9245dd5211b7dc1bdf0961b39eea (patch)
treecbf354caa6c100f2e1e5c524d2f959913f52ac0e /src/client
parentae9b1aa1774aedca8f452514d9462c281e36773a (diff)
downloadminetest-05d93c7fa1be9245dd5211b7dc1bdf0961b39eea.tar.gz
minetest-05d93c7fa1be9245dd5211b7dc1bdf0961b39eea.tar.bz2
minetest-05d93c7fa1be9245dd5211b7dc1bdf0961b39eea.zip
Load files from subfolders in texturepacks
Updated and rebased version of a PR by red-001
Diffstat (limited to 'src/client')
-rw-r--r--src/client/tile.cpp14
-rw-r--r--src/client/tile.h2
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();