1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-27 17:28:41 +00:00

General code refactoring/improvements in server, treegen and connection

This commit is contained in:
sfan5 2024-03-12 14:13:24 +01:00
parent 24f2c38093
commit bc4ab8b99e
34 changed files with 330 additions and 439 deletions

View file

@ -50,7 +50,7 @@ ServerModManager::ServerModManager(const std::string &worldpath):
}
// This function cannot be currenctly easily tested but it should be ASAP
void ServerModManager::loadMods(ServerScripting *script)
void ServerModManager::loadMods(ServerScripting &script)
{
// Print mods
infostream << "Server: Loading mods: ";
@ -65,13 +65,13 @@ void ServerModManager::loadMods(ServerScripting *script)
std::string script_path = mod.path + DIR_DELIM + "init.lua";
auto t = porting::getTimeMs();
script->loadMod(script_path, mod.name);
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();
script.on_mods_loaded();
}
const ModSpec *ServerModManager::getModSpec(const std::string &modname) const

View file

@ -22,12 +22,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "content/mod_configuration.h"
#include <memory>
class MetricsBackend;
class MetricCounter;
class ServerScripting;
/**
* Manage server mods
* Manages server mods
*
* All new calls to this class must be tested in test_servermodmanager.cpp
*/
@ -36,12 +34,20 @@ class ServerModManager
ModConfiguration configuration;
public:
/**
* Creates a ServerModManager which targets worldpath
* @param worldpath
*/
ServerModManager(const std::string &worldpath);
void loadMods(ServerScripting *script);
/**
* Creates an empty ServerModManager. For testing purposes.
* Note: definition looks like this so it isn't accidentally used.
*/
explicit ServerModManager(std::nullptr_t) {};
void loadMods(ServerScripting &script);
const ModSpec *getModSpec(const std::string &modname) const;
void getModNames(std::vector<std::string> &modlist) const;