]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Allow overwriting media files of dependencies (#10752)
authorDS <vorunbekannt75@web.de>
Tue, 23 Feb 2021 18:39:15 +0000 (19:39 +0100)
committerGitHub <noreply@github.com>
Tue, 23 Feb 2021 18:39:15 +0000 (19:39 +0100)
doc/lua_api.txt
games/devtest/mods/basenodes/textures/default_dirt.png
games/devtest/mods/basenodes/textures/dirt_with_grass/info.txt [deleted file]
games/devtest/mods/basenodes/textures/info.txt [new file with mode: 0644]
games/devtest/mods/unittests/mod.conf
games/devtest/mods/unittests/textures/default_dirt.png [new file with mode: 0644]
src/server/mods.cpp
src/server/mods.h

index a9c3bcdd91417fb91340ac64dfc7c979fffd4530..d3165b9fd6008eea8c3731893a25c19ddca6702c 100644 (file)
@@ -256,6 +256,9 @@ Subfolders with names starting with `_` or `.` are ignored.
 If a subfolder contains a media file with the same name as a media file
 in one of its parents, the parent's file is used.
 
+Although it is discouraged, a mod can overwrite a media file of any mod that it
+depends on by supplying a file with an equal name.
+
 Naming conventions
 ------------------
 
index 58670305d007716c3fee12b45e8acf301cbd4c5a..aa75bffb6459d1415a2f146f0da636fbcc94c253 100644 (file)
Binary files a/games/devtest/mods/basenodes/textures/default_dirt.png and b/games/devtest/mods/basenodes/textures/default_dirt.png differ
diff --git a/games/devtest/mods/basenodes/textures/dirt_with_grass/info.txt b/games/devtest/mods/basenodes/textures/dirt_with_grass/info.txt
deleted file mode 100644 (file)
index 8db21ed..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-This is for testing loading textures from subfolders.
-If it works correctly, the default_grass_side.png file in this folder is used but
-default_grass.png is not overwritten by the file in this folder.
diff --git a/games/devtest/mods/basenodes/textures/info.txt b/games/devtest/mods/basenodes/textures/info.txt
new file mode 100644 (file)
index 0000000..2d4ef7e
--- /dev/null
@@ -0,0 +1,7 @@
+
+The dirt_with_grass folder is for testing loading textures from subfolders.
+If it works correctly, the default_grass_side.png file in the folder is used but
+default_grass.png is not overwritten by the file in the folder.
+
+default_dirt.png should be overwritten by the default_dirt.png in the unittests
+mod which depends on basenodes.
index 0d5e3c959b5d684bc4d685dc28dd60a30dfd3d75..fa94e01a682b297802e52826db9dd397324aaffe 100644 (file)
@@ -1,2 +1,3 @@
 name = unittests
 description = Adds automated unit tests for the engine
+depends = basenodes
diff --git a/games/devtest/mods/unittests/textures/default_dirt.png b/games/devtest/mods/unittests/textures/default_dirt.png
new file mode 100644 (file)
index 0000000..5867030
Binary files /dev/null and b/games/devtest/mods/unittests/textures/default_dirt.png differ
index cf14676480472ee49654b1823c11594104b94179..83fa12da9f5ba12b36412c0931d4b0513c48c6c6 100644 (file)
@@ -98,7 +98,8 @@ void ServerModManager::getModNames(std::vector<std::string> &modlist) const
 
 void ServerModManager::getModsMediaPaths(std::vector<std::string> &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");
index 54774bd8637124097065e748ce382e214d513bc2..8954bbf7293ea5056bcaf29c73c83ab094a55e36 100644 (file)
@@ -42,5 +42,13 @@ class ServerModManager : public ModConfiguration
        void loadMods(ServerScripting *script);
        const ModSpec *getModSpec(const std::string &modname) const;
        void getModNames(std::vector<std::string> &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<std::string> &paths) const;
 };