diff options
author | DS <vorunbekannt75@web.de> | 2020-08-20 22:25:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-20 22:25:29 +0200 |
commit | 98faeac5a7b382e5d7ce0474bf7d52fc5975a23c (patch) | |
tree | ba08707c5b06087fe8472ed6245ace7a0683d7e2 /src/server.cpp | |
parent | 9c7340104a7ec4007e3dfe0bb4482f3c8f9878e0 (diff) | |
download | hax-minetest-server-98faeac5a7b382e5d7ce0474bf7d52fc5975a23c.tar.gz hax-minetest-server-98faeac5a7b382e5d7ce0474bf7d52fc5975a23c.zip |
Load media from subfolders (#9065)
Diffstat (limited to '')
-rw-r--r-- | src/server.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/server.cpp b/src/server.cpp index 53ee8c444..ef36aedca 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -2494,19 +2494,25 @@ void Server::fillMediaCache() // Collect all media file paths std::vector<std::string> paths; - m_modmgr->getModsMediaPaths(paths); - fs::GetRecursiveDirs(paths, m_gamespec.path + DIR_DELIM + "textures"); + // The paths are ordered in descending priority fs::GetRecursiveDirs(paths, porting::path_user + DIR_DELIM + "textures" + DIR_DELIM + "server"); + fs::GetRecursiveDirs(paths, m_gamespec.path + DIR_DELIM + "textures"); + m_modmgr->getModsMediaPaths(paths); // Collect media file information from paths into cache for (const std::string &mediapath : paths) { std::vector<fs::DirListNode> dirlist = fs::GetDirListing(mediapath); for (const fs::DirListNode &dln : dirlist) { - if (dln.dir) // Ignore dirs + if (dln.dir) // Ignore dirs (already in paths) continue; + + const std::string &filename = dln.name; + if (m_media.find(filename) != m_media.end()) // Do not override + continue; + std::string filepath = mediapath; - filepath.append(DIR_DELIM).append(dln.name); - addMediaFile(dln.name, filepath); + filepath.append(DIR_DELIM).append(filename); + addMediaFile(filename, filepath); } } |