#include "filesys.h"
#include "log.h"
#include "scripting_server.h"
-#include "subgame.h"
+#include "content/subgames.h"
+#include "porting.h"
+#include "util/metricsbackend.h"
/**
* Manage server mods
addModsFromConfig(worldmt, gamespec.addon_mods_paths);
}
+// clang-format off
// This function cannot be currenctly easily tested but it should be ASAP
void ServerModManager::loadMods(ServerScripting *script)
{
"Only characters [a-z0-9_] are allowed.");
}
std::string script_path = mod.path + DIR_DELIM + "init.lua";
- infostream << " [" << padStringRight(mod.name, 12) << "] [\""
- << script_path << "\"]" << std::endl;
+ auto t = porting::getTimeMs();
script->loadMod(script_path, mod.name);
+ infostream << "Mod \"" << mod.name << "\" loaded after "
+ << (porting::getTimeMs() - t) << " ms" << std::endl;
}
+
+ // Run a callback when mods are loaded
+ script->on_mods_loaded();
}
+// clang-format on
const ModSpec *ServerModManager::getModSpec(const std::string &modname) const
{
std::vector<ModSpec>::const_iterator it;
void ServerModManager::getModsMediaPaths(std::vector<std::string> &paths) const
{
- for (const ModSpec &spec : m_sorted_mods) {
- paths.push_back(spec.path + DIR_DELIM + "textures");
- paths.push_back(spec.path + DIR_DELIM + "sounds");
- paths.push_back(spec.path + DIR_DELIM + "media");
- paths.push_back(spec.path + DIR_DELIM + "models");
- paths.push_back(spec.path + DIR_DELIM + "locale");
+ 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");
+ fs::GetRecursiveDirs(paths, spec.path + DIR_DELIM + "models");
+ fs::GetRecursiveDirs(paths, spec.path + DIR_DELIM + "locale");
}
}