- // Print out some debug info
- TRACESTREAM(<<"Detected mods in load order:"<<std::endl);
- for(core::list<ModSpec>::Iterator i = mods_sorted.begin();
- i != mods_sorted.end(); i++){
- ModSpec &mod = *i;
- TRACESTREAM(<<"name=\""<<mod.name<<"\" path=\""<<mod.path<<"\"");
- TRACESTREAM(<<" depends=[");
- for(std::set<std::string>::iterator i = mod.depends.begin();
- i != mod.depends.end(); i++)
- TRACESTREAM(<<" "<<(*i));
- TRACESTREAM(<<" ] unsatisfied_depends=[");
- for(std::set<std::string>::iterator i = mod.unsatisfied_depends.begin();
- i != mod.unsatisfied_depends.end(); i++)
- TRACESTREAM(<<" "<<(*i));
- TRACESTREAM(<<" ]"<<std::endl);
+
+ // Step 4: write back list of unsatisfied mods
+ m_unsatisfied_mods.assign(unsatisfied.begin(), unsatisfied.end());
+}
+
+ServerModConfiguration::ServerModConfiguration(const std::string &worldpath):
+ ModConfiguration(worldpath)
+{
+ SubgameSpec gamespec = findWorldSubgame(worldpath);
+
+ // Add all game mods and all world mods
+ addModsInPath(gamespec.gamemods_path);
+ addModsInPath(worldpath + DIR_DELIM + "worldmods");
+
+ // Load normal mods
+ std::string worldmt = worldpath + DIR_DELIM + "world.mt";
+ addModsFromConfig(worldmt, gamespec.addon_mods_paths);
+}
+
+#ifndef SERVER
+ClientModConfiguration::ClientModConfiguration(const std::string &path):
+ ModConfiguration(path)
+{
+ std::set<std::string> paths;
+ std::string path_user = porting::path_user + DIR_DELIM + "clientmods";
+ paths.insert(path);
+ paths.insert(path_user);
+
+ std::string settings_path = path_user + DIR_DELIM + "mods.conf";
+ addModsFromConfig(settings_path, paths);
+}
+#endif
+
+ModMetadata::ModMetadata(const std::string &mod_name):
+ m_mod_name(mod_name)
+{
+}
+
+void ModMetadata::clear()
+{
+ Metadata::clear();
+ m_modified = true;
+}
+
+bool ModMetadata::save(const std::string &root_path)
+{
+ Json::Value json;
+ for (StringMap::const_iterator it = m_stringvars.begin();
+ it != m_stringvars.end(); ++it) {
+ json[it->first] = it->second;
+ }
+
+ if (!fs::PathExists(root_path)) {
+ if (!fs::CreateAllDirs(root_path)) {
+ errorstream << "ModMetadata[" << m_mod_name << "]: Unable to save. '"
+ << root_path << "' tree cannot be created." << std::endl;
+ return false;
+ }
+ } else if (!fs::IsDir(root_path)) {
+ errorstream << "ModMetadata[" << m_mod_name << "]: Unable to save. '"
+ << root_path << "' is not a directory." << std::endl;
+ return false;