From 6af8a34d91582ce15a0341e75d3e55d847a5a47a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Doser?= Date: Sat, 8 Dec 2012 18:10:54 +0100 Subject: Basic support for configuring which mods to load for each world settings.h: added function to return all keys used in settings, and a function to remove a setting mods.{h,cpp}: added class ModConfiguration that represents a subset of the installed mods. server.{h,cpp}: server does not load add-on mods that are disabled in the world.mt file. mods are disabled by a setting of the form "load_mod_ = false". if no load_mod_ = ... setting is found, the mod is loaded anyways for backwards compatibilty. server also complains to errorstream about mods with unstatisfied dependencies and about mods that are not installed. guiConfigureWorld.{h,cpp}: shows a treeview of installed add-on mods and modpacks with little icons in front of their name indicating their status: a checkmark for enabled mods, a cross for disabled mods, a question mark for "new" mods Mods can be enabled/disabled by a checkbox. Mods also show a list of dependencies and reverse dependencies. double-click on a mod in dependency or reverse dependency listbox selects the corresponding mod. Enabling a mod also enables all its dependencies. Disabling a mod also disables all its reverse dependencies. For modpacks, show buttons to enable/disable all mods (recursively, including their dependencies) in it. Button "Save" saves the current settings to the world.mt file and returns to the main menu. Button "Cancel" returns to main menu without saving. basic keyboard controls (if the proper widget has keyboard focus): up/down: scroll through tree of mods left/right: collaps/expand a modpack space: enable/disable the selected mod --- src/server.cpp | 80 ++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 55 insertions(+), 25 deletions(-) (limited to 'src/server.cpp') diff --git a/src/server.cpp b/src/server.cpp index 0a8288324..853d0a486 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -980,33 +980,65 @@ Server::Server( std::string rollback_path = m_path_world+DIR_DELIM+"rollback.txt"; m_rollback = createRollbackManager(rollback_path, this); - // Add world mod search path - m_modspaths.push_front(m_path_world + DIR_DELIM + "worldmods"); - // Add addon mod search path - for(std::set::const_iterator i = m_gamespec.mods_paths.begin(); - i != m_gamespec.mods_paths.end(); i++) - m_modspaths.push_front((*i)); - - // Print out mod search paths - for(core::list::Iterator i = m_modspaths.begin(); - i != m_modspaths.end(); i++){ - std::string modspath = *i; - infostream<<"- mods: "< modlist = modconf.getUnsatisfiedMods(); + for(std::list::iterator it = modlist.begin(); + it != modlist.end(); ++it) + { + errorstream << (*it).name << " "; + } + errorstream << std::endl; + } + + Settings worldmt_settings; + std::string worldmt = m_path_world + DIR_DELIM + "world.mt"; + worldmt_settings.readConfigFile(worldmt.c_str()); + std::vector names = worldmt_settings.getNames(); + std::set exclude_mod_names; + std::set load_mod_names; + for(std::vector::iterator it = names.begin(); + it != names.end(); ++it) + { + std::string name = *it; + if (name.compare(0,9,"load_mod_")==0) + { + 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 + for(std::vector::iterator it = m_mods.begin(); + it != m_mods.end(); ++it) + load_mod_names.erase((*it).name); + if(!load_mod_names.empty()) + { + errorstream << "The following mods could not be found: "; + for(std::set::iterator it = load_mod_names.begin(); + it != load_mod_names.end(); ++it) + errorstream << (*it) << " "; + errorstream << std::endl; + } + + // Path to builtin.lua + std::string builtinpath = getBuiltinLuaPath() + DIR_DELIM + "builtin.lua"; + // Lock environment JMutexAutoLock envlock(m_env_mutex); JMutexAutoLock conlock(m_con_mutex); // Initialize scripting - + infostream<<"Server: Initializing Lua"<::Iterator i = m_mods.begin(); + for(std::vector::iterator i = m_mods.begin(); i != m_mods.end(); i++){ const ModSpec &mod = *i; infostream<::Iterator i = m_mods.begin(); + for(std::vector::iterator i = m_mods.begin(); i != m_mods.end(); i++){ const ModSpec &mod = *i; std::string scriptpath = mod.path + DIR_DELIM + "init.lua"; @@ -4105,7 +4135,7 @@ void Server::fillMediaCache() // Collect all media file paths std::list paths; - for(core::list::Iterator i = m_mods.begin(); + for(std::vector::iterator i = m_mods.begin(); i != m_mods.end(); i++){ const ModSpec &mod = *i; paths.push_back(mod.path + DIR_DELIM + "textures"); @@ -4770,7 +4800,7 @@ IWritableCraftDefManager* Server::getWritableCraftDefManager() const ModSpec* Server::getModSpec(const std::string &modname) { - for(core::list::Iterator i = m_mods.begin(); + for(std::vector::iterator i = m_mods.begin(); i != m_mods.end(); i++){ const ModSpec &mod = *i; if(mod.name == modname) @@ -4780,7 +4810,7 @@ const ModSpec* Server::getModSpec(const std::string &modname) } void Server::getModNames(core::list &modlist) { - for(core::list::Iterator i = m_mods.begin(); i != m_mods.end(); i++) + for(std::vector::iterator i = m_mods.begin(); i != m_mods.end(); i++) { modlist.push_back((*i).name); } -- cgit v1.2.3