]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/server/mods.cpp
Fix revoke debug privs not reliably turn off stuff (#11409)
[dragonfireclient.git] / src / server / mods.cpp
index c246e6446b5b869ea64d1ae9926b3dd989405ae8..83fa12da9f5ba12b36412c0931d4b0513c48c6c6 100644 (file)
@@ -22,6 +22,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "log.h"
 #include "scripting_server.h"
 #include "content/subgames.h"
+#include "porting.h"
+#include "util/metricsbackend.h"
 
 /**
  * Manage server mods
@@ -66,15 +68,14 @@ 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 = std::chrono::steady_clock::now();
+               auto t = porting::getTimeMs();
                script->loadMod(script_path, mod.name);
                infostream << "Mod \"" << mod.name << "\" loaded after "
-                       << std::chrono::duration_cast<std::chrono::milliseconds>(
-                               std::chrono::steady_clock::now() - t).count() * 0.001f
-                       << " seconds" << std::endl;
+                       << (porting::getTimeMs() - t) << " ms" << std::endl;
        }
+
+       // Run a callback when mods are loaded
+       script->on_mods_loaded();
 }
 
 // clang-format on
@@ -97,11 +98,12 @@ 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) {
-               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");
        }
 }