Skip to content

Commit 4abe4b8

Browse files
authoredFeb 23, 2021
Allow overwriting media files of dependencies (#10752)
1 parent 2968108 commit 4abe4b8

File tree

8 files changed

+21
-4
lines changed

8 files changed

+21
-4
lines changed
 

Diff for: ‎doc/lua_api.txt

+3
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,9 @@ Subfolders with names starting with `_` or `.` are ignored.
256256
If a subfolder contains a media file with the same name as a media file
257257
in one of its parents, the parent's file is used.
258258

259+
Although it is discouraged, a mod can overwrite a media file of any mod that it
260+
depends on by supplying a file with an equal name.
261+
259262
Naming conventions
260263
------------------
261264

6.36 KB
Loading

Diff for: ‎games/devtest/mods/basenodes/textures/dirt_with_grass/info.txt

-3
This file was deleted.

Diff for: ‎games/devtest/mods/basenodes/textures/info.txt

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
The dirt_with_grass folder is for testing loading textures from subfolders.
3+
If it works correctly, the default_grass_side.png file in the folder is used but
4+
default_grass.png is not overwritten by the file in the folder.
5+
6+
default_dirt.png should be overwritten by the default_dirt.png in the unittests
7+
mod which depends on basenodes.

Diff for: ‎games/devtest/mods/unittests/mod.conf

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
name = unittests
22
description = Adds automated unit tests for the engine
3+
depends = basenodes
790 Bytes
Loading

Diff for: ‎src/server/mods.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ void ServerModManager::getModNames(std::vector<std::string> &modlist) const
9898

9999
void ServerModManager::getModsMediaPaths(std::vector<std::string> &paths) const
100100
{
101-
for (const ModSpec &spec : m_sorted_mods) {
101+
for (auto it = m_sorted_mods.crbegin(); it != m_sorted_mods.crend(); it++) {
102+
const ModSpec &spec = *it;
102103
fs::GetRecursiveDirs(paths, spec.path + DIR_DELIM + "textures");
103104
fs::GetRecursiveDirs(paths, spec.path + DIR_DELIM + "sounds");
104105
fs::GetRecursiveDirs(paths, spec.path + DIR_DELIM + "media");

Diff for: ‎src/server/mods.h

+8
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,13 @@ class ServerModManager : public ModConfiguration
4242
void loadMods(ServerScripting *script);
4343
const ModSpec *getModSpec(const std::string &modname) const;
4444
void getModNames(std::vector<std::string> &modlist) const;
45+
/**
46+
* Recursively gets all paths of mod folders that can contain media files.
47+
*
48+
* Result is ordered in descending priority, ie. files from an earlier path
49+
* should not be replaced by files from a latter one.
50+
*
51+
* @param paths result vector
52+
*/
4553
void getModsMediaPaths(std::vector<std::string> &paths) const;
4654
};

0 commit comments

Comments
 (0)
Please sign in to comment.