From 4abe4b87b5902bff229505b83b9bddb9a8f759cd Mon Sep 17 00:00:00 2001 From: DS Date: Tue, 23 Feb 2021 19:39:15 +0100 Subject: Allow overwriting media files of dependencies (#10752) --- src/server/mods.cpp | 3 ++- src/server/mods.h | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src/server') diff --git a/src/server/mods.cpp b/src/server/mods.cpp index cf1467648..83fa12da9 100644 --- a/src/server/mods.cpp +++ b/src/server/mods.cpp @@ -98,7 +98,8 @@ void ServerModManager::getModNames(std::vector &modlist) const void ServerModManager::getModsMediaPaths(std::vector &paths) const { - for (const ModSpec &spec : m_sorted_mods) { + for (auto it = m_sorted_mods.crbegin(); it != m_sorted_mods.crend(); it++) { + const ModSpec &spec = *it; fs::GetRecursiveDirs(paths, spec.path + DIR_DELIM + "textures"); fs::GetRecursiveDirs(paths, spec.path + DIR_DELIM + "sounds"); fs::GetRecursiveDirs(paths, spec.path + DIR_DELIM + "media"); diff --git a/src/server/mods.h b/src/server/mods.h index 54774bd86..8954bbf72 100644 --- a/src/server/mods.h +++ b/src/server/mods.h @@ -42,5 +42,13 @@ public: void loadMods(ServerScripting *script); const ModSpec *getModSpec(const std::string &modname) const; void getModNames(std::vector &modlist) const; + /** + * Recursively gets all paths of mod folders that can contain media files. + * + * Result is ordered in descending priority, ie. files from an earlier path + * should not be replaced by files from a latter one. + * + * @param paths result vector + */ void getModsMediaPaths(std::vector &paths) const; }; -- cgit v1.2.3