mirror of
https://github.com/minetest/minetest.git
synced 2024-11-30 03:23:45 +01:00
Dont load mods that have no entry in world.mt
This commit is contained in:
parent
b2577b1f27
commit
dcd0b63f64
11
src/mods.cpp
11
src/mods.cpp
@ -220,7 +220,7 @@ ModConfiguration::ModConfiguration(std::string worldpath)
|
|||||||
Settings worldmt_settings;
|
Settings worldmt_settings;
|
||||||
worldmt_settings.readConfigFile(worldmt.c_str());
|
worldmt_settings.readConfigFile(worldmt.c_str());
|
||||||
std::vector<std::string> names = worldmt_settings.getNames();
|
std::vector<std::string> names = worldmt_settings.getNames();
|
||||||
std::set<std::string> exclude_mod_names;
|
std::set<std::string> include_mod_names;
|
||||||
for(std::vector<std::string>::iterator it = names.begin();
|
for(std::vector<std::string>::iterator it = names.begin();
|
||||||
it != names.end(); ++it)
|
it != names.end(); ++it)
|
||||||
{
|
{
|
||||||
@ -229,14 +229,13 @@ ModConfiguration::ModConfiguration(std::string worldpath)
|
|||||||
// explicitely excluded. if mod is not mentioned at all, it is
|
// explicitely excluded. if mod is not mentioned at all, it is
|
||||||
// enabled. So by default, all installed mods are enabled.
|
// enabled. So by default, all installed mods are enabled.
|
||||||
if (name.compare(0,9,"load_mod_") == 0 &&
|
if (name.compare(0,9,"load_mod_") == 0 &&
|
||||||
!worldmt_settings.getBool(name))
|
worldmt_settings.getBool(name))
|
||||||
{
|
{
|
||||||
exclude_mod_names.insert(name.substr(9));
|
include_mod_names.insert(name.substr(9));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collect all mods in gamespec.addon_mods_paths,
|
// Collect all mods that are also in include_mod_names
|
||||||
// excluding those in the set exclude_mod_names
|
|
||||||
std::vector<ModSpec> addon_mods;
|
std::vector<ModSpec> addon_mods;
|
||||||
for(std::set<std::string>::const_iterator it_path = gamespec.addon_mods_paths.begin();
|
for(std::set<std::string>::const_iterator it_path = gamespec.addon_mods_paths.begin();
|
||||||
it_path != gamespec.addon_mods_paths.end(); ++it_path)
|
it_path != gamespec.addon_mods_paths.end(); ++it_path)
|
||||||
@ -246,7 +245,7 @@ ModConfiguration::ModConfiguration(std::string worldpath)
|
|||||||
it != addon_mods_in_path.end(); ++it)
|
it != addon_mods_in_path.end(); ++it)
|
||||||
{
|
{
|
||||||
ModSpec& mod = *it;
|
ModSpec& mod = *it;
|
||||||
if(exclude_mod_names.count(mod.name) == 0)
|
if(include_mod_names.count(mod.name) != 0)
|
||||||
addon_mods.push_back(mod);
|
addon_mods.push_back(mod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -727,19 +727,13 @@ Server::Server(
|
|||||||
std::string worldmt = m_path_world + DIR_DELIM + "world.mt";
|
std::string worldmt = m_path_world + DIR_DELIM + "world.mt";
|
||||||
worldmt_settings.readConfigFile(worldmt.c_str());
|
worldmt_settings.readConfigFile(worldmt.c_str());
|
||||||
std::vector<std::string> names = worldmt_settings.getNames();
|
std::vector<std::string> names = worldmt_settings.getNames();
|
||||||
std::set<std::string> exclude_mod_names;
|
|
||||||
std::set<std::string> load_mod_names;
|
std::set<std::string> load_mod_names;
|
||||||
for(std::vector<std::string>::iterator it = names.begin();
|
for(std::vector<std::string>::iterator it = names.begin();
|
||||||
it != names.end(); ++it)
|
it != names.end(); ++it)
|
||||||
{
|
{
|
||||||
std::string name = *it;
|
std::string name = *it;
|
||||||
if (name.compare(0,9,"load_mod_")==0)
|
if(name.compare(0,9,"load_mod_")==0 && worldmt_settings.getBool(name))
|
||||||
{
|
load_mod_names.insert(name.substr(9));
|
||||||
if(worldmt_settings.getBool(name))
|
|
||||||
load_mod_names.insert(name.substr(9));
|
|
||||||
else
|
|
||||||
exclude_mod_names.insert(name.substr(9));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// complain about mods declared to be loaded, but not found
|
// complain about mods declared to be loaded, but not found
|
||||||
for(std::vector<ModSpec>::iterator it = m_mods.begin();
|
for(std::vector<ModSpec>::iterator it = m_mods.begin();
|
||||||
|
Loading…
Reference in New Issue
Block a user