1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

CSM fixes: load mods after flavours & add flavour to block mod loading (#6738)

* CSM fixes: load mods after flavours & add flavour to block mod loading

* Don't permit to load mods twice

* Prepare builtin integrity global algorithm

* Add missing doc & use a nicer byteflag for LOAD_CLIENT_MODS flavour

* flag typo fix

* Invert CSM_FL_LOOKUP_NODES & CSM_FL_LOAD_CLIENT_MODS ids
This commit is contained in:
Loïc Blot 2017-12-11 17:33:44 +01:00 committed by GitHub
parent 02cc257fe0
commit 308bb69eef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 55 additions and 32 deletions

View file

@ -113,18 +113,38 @@ Client::Client(
m_script->setEnv(&m_env);
}
void Client::loadMods()
void Client::loadBuiltin()
{
// Load builtin
scanModIntoMemory(BUILTIN_MOD_NAME, getBuiltinLuaPath());
// If modding is not enabled, don't load mods, just builtin
if (!m_modding_enabled) {
m_script->loadModFromMemory(BUILTIN_MOD_NAME);
}
void Client::loadMods()
{
// Don't permit to load mods twice
if (m_mods_loaded) {
return;
}
// If modding is not enabled or flavour disable it, don't load mods, just builtin
if (!m_modding_enabled) {
warningstream << "Client side mods are disabled by configuration." << std::endl;
return;
}
if (checkCSMFlavourLimit(CSMFlavourLimit::CSM_FL_LOAD_CLIENT_MODS)) {
warningstream << "Client side mods are disabled by server." << std::endl;
// If mods loading is disabled and builtin integrity is wrong, disconnect user.
if (!checkBuiltinIntegrity()) {
// @TODO disconnect user
}
return;
}
ClientModConfiguration modconf(getClientModsLuaPath());
m_mods = modconf.getMods();
std::vector<ModSpec> unsatisfied_mods = modconf.getUnsatisfiedMods();
// complain about mods with unsatisfied dependencies
if (!modconf.isConsistent()) {
modconf.printUnsatisfiedModsError();
@ -145,6 +165,18 @@ void Client::loadMods()
}
scanModIntoMemory(mod.name, mod.path);
}
// Load and run "mod" scripts
for (const ModSpec &mod : m_mods)
m_script->loadModFromMemory(mod.name);
m_mods_loaded = true;
}
bool Client::checkBuiltinIntegrity()
{
// @TODO
return true;
}
void Client::scanModSubfolder(const std::string &mod_name, const std::string &mod_path,
@ -164,20 +196,6 @@ void Client::scanModSubfolder(const std::string &mod_name, const std::string &mo
}
}
void Client::initMods()
{
m_script->loadModFromMemory(BUILTIN_MOD_NAME);
// If modding is not enabled, don't load mods, just builtin
if (!m_modding_enabled) {
return;
}
// Load and run "mod" scripts
for (const ModSpec &mod : m_mods)
m_script->loadModFromMemory(mod.name);
}
const std::string &Client::getBuiltinLuaPath()
{
static const std::string builtin_dir = porting::path_share + DIR_DELIM + "builtin";