Skip to content
Browse files

Allow overwriting media files of dependencies (#10752)

  • Loading branch information
Desour committed Feb 23, 2021
1 parent 2968108 commit 4abe4b87b5902bff229505b83b9bddb9a8f759cd
@@ -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

Binary file not shown.

This file was deleted.

@@ -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.
@@ -1,2 +1,3 @@
name = unittests
description = Adds automated unit tests for the engine
depends = basenodes
Binary file not shown.
@@ -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");
@@ -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;

0 comments on commit 4abe4b8

Please sign in to comment.