mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-11 17:51:04 +00:00
[CSM] implement client side mod loading (#5123)
* client side mods are located in clientmods/ * move builtin/preview.lua to clientmods/preview/init.lua as a preview mod * refactor ModConfiguration class to work properly with client and server using child objects * move some Server constructor mod load code to ModConfiguration to reduce code duplication between client and server * remove mods.{cpp,h} unused functions * use UNORDERED_SET instead of std::set in some modspec storages
This commit is contained in:
parent
c42c53fccf
commit
92b45b2a18
9 changed files with 196 additions and 150 deletions
|
@ -218,20 +218,12 @@ Server::Server(
|
|||
std::string ban_path = m_path_world + DIR_DELIM "ipban.txt";
|
||||
m_banmanager = new BanManager(ban_path);
|
||||
|
||||
ModConfiguration modconf(m_path_world);
|
||||
ServerModConfiguration modconf(m_path_world);
|
||||
m_mods = modconf.getMods();
|
||||
std::vector<ModSpec> unsatisfied_mods = modconf.getUnsatisfiedMods();
|
||||
// complain about mods with unsatisfied dependencies
|
||||
if(!modconf.isConsistent()) {
|
||||
for(std::vector<ModSpec>::iterator it = unsatisfied_mods.begin();
|
||||
it != unsatisfied_mods.end(); ++it) {
|
||||
ModSpec mod = *it;
|
||||
errorstream << "mod \"" << mod.name << "\" has unsatisfied dependencies: ";
|
||||
for(std::set<std::string>::iterator dep_it = mod.unsatisfied_depends.begin();
|
||||
dep_it != mod.unsatisfied_depends.end(); ++dep_it)
|
||||
errorstream << " \"" << *dep_it << "\"";
|
||||
errorstream << std::endl;
|
||||
}
|
||||
if (!modconf.isConsistent()) {
|
||||
modconf.printUnsatisfiedModsError();
|
||||
}
|
||||
|
||||
Settings worldmt_settings;
|
||||
|
@ -271,20 +263,17 @@ Server::Server(
|
|||
|
||||
m_script = new ServerScripting(this);
|
||||
|
||||
std::string script_path = getBuiltinLuaPath() + DIR_DELIM "init.lua";
|
||||
|
||||
m_script->loadMod(script_path, BUILTIN_MOD_NAME);
|
||||
m_script->loadMod(getBuiltinLuaPath() + DIR_DELIM "init.lua", BUILTIN_MOD_NAME);
|
||||
|
||||
// Print mods
|
||||
infostream << "Server: Loading mods: ";
|
||||
for(std::vector<ModSpec>::iterator i = m_mods.begin();
|
||||
for (std::vector<ModSpec>::const_iterator i = m_mods.begin();
|
||||
i != m_mods.end(); ++i) {
|
||||
const ModSpec &mod = *i;
|
||||
infostream << mod.name << " ";
|
||||
infostream << (*i).name << " ";
|
||||
}
|
||||
infostream << std::endl;
|
||||
// Load and run "mod" scripts
|
||||
for (std::vector<ModSpec>::iterator it = m_mods.begin();
|
||||
for (std::vector<ModSpec>::const_iterator it = m_mods.begin();
|
||||
it != m_mods.end(); ++it) {
|
||||
const ModSpec &mod = *it;
|
||||
if (!string_allowed(mod.name, MODNAME_ALLOWED_CHARS)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue