}
}
}
-
- // FIXME: optdepends.txt is deprecated
- // remove this code at some point in the future
- std::ifstream is2((spec.path+DIR_DELIM+"optdepends.txt").c_str());
- while(is2.good()){
- std::string dep;
- std::set<char> symbols;
- if(parseDependsLine(is2, dep, symbols))
- spec.optdepends.insert(dep);
- }
}
}
return result;
}
-ModSpec findCommonMod(const std::string &modname)
-{
- // Try to find in {$user,$share}/games/common/$modname
- std::vector<std::string> find_paths;
- find_paths.push_back(porting::path_user + DIR_DELIM + "games" +
- DIR_DELIM + "common" + DIR_DELIM + "mods" + DIR_DELIM + modname);
- find_paths.push_back(porting::path_share + DIR_DELIM + "games" +
- DIR_DELIM + "common" + DIR_DELIM + "mods" + DIR_DELIM + modname);
- for(u32 i=0; i<find_paths.size(); i++){
- const std::string &try_path = find_paths[i];
- if(fs::PathExists(try_path)){
- ModSpec spec(modname, try_path);
- parseModContents(spec);
- return spec;
- }
- }
- // Failed to find mod
- return ModSpec();
-}
-
std::map<std::string, ModSpec> flattenModTree(std::map<std::string, ModSpec> mods)
{
std::map<std::string, ModSpec> result;
ModSpec mod = (*it).second;
if(mod.is_modpack)
{
- std::map<std::string, ModSpec> content =
+ std::map<std::string, ModSpec> content =
flattenModTree(mod.modpack_content);
result.insert(content.begin(),content.end());
result.insert(std::make_pair(mod.name,mod));
- }
+ }
else //not a modpack
{
result.insert(std::make_pair(mod.name,mod));
std::vector<ModSpec> content = flattenMods(mod.modpack_content);
result.reserve(result.size() + content.size());
result.insert(result.end(),content.begin(),content.end());
-
- }
+
+ }
else //not a modpack
{
result.push_back(mod);
{
SubgameSpec gamespec = findWorldSubgame(worldpath);
- // Add common mods
- std::map<std::string, ModSpec> common_mods;
- std::vector<std::string> inexistent_common_mods;
- Settings gameconf;
- if(getGameConfig(gamespec.path, gameconf)){
- if(gameconf.exists("common_mods")){
- Strfnd f(gameconf.get("common_mods"));
- while(!f.atend()){
- std::string modname = trim(f.next(","));
- if(modname.empty())
- continue;
- ModSpec spec = findCommonMod(modname);
- if(spec.name.empty())
- inexistent_common_mods.push_back(modname);
- else
- common_mods.insert(std::make_pair(modname, spec));
- }
- }
- }
- if(!inexistent_common_mods.empty()){
- std::string s = "Required common mods ";
- for(u32 i=0; i<inexistent_common_mods.size(); i++){
- if(i != 0) s += ", ";
- s += std::string("\"") + inexistent_common_mods[i] + "\"";
- }
- s += " could not be found.";
- throw ModError(s);
- }
- addMods(flattenMods(common_mods));
-
// Add all game mods and all world mods
addModsInPath(gamespec.gamemods_path);
addModsInPath(worldpath + DIR_DELIM + "worldmods");
worldmt_settings.readConfigFile(worldmt.c_str());
std::vector<std::string> names = worldmt_settings.getNames();
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)
- {
- std::string name = *it;
+ {
+ std::string name = *it;
// for backwards compatibility: exclude only mods which are
// explicitely excluded. if mod is not mentioned at all, it is
// enabled. So by default, all installed mods are enabled.
// Add all the mods that come from modpacks
// Second iteration:
// Add all the mods that didn't come from modpacks
-
+
std::set<std::string> seen_this_iteration;
for(std::vector<ModSpec>::const_iterator it = new_mods.begin();
else{
++it;
}
- }
+ }
}
// Step 4: write back list of unsatisfied mods
#if USE_CURL
Json::Value getModstoreUrl(std::string url)
{
- struct curl_slist *chunk = NULL;
+ std::vector<std::string> extra_headers;
bool special_http_header = true;
catch(SettingNotFoundException &e) {
}
- if (special_http_header)
- chunk = curl_slist_append(chunk, "Accept: application/vnd.minetest.mmdb-v1+json");
-
- Json::Value retval = fetchJsonValue(url,chunk);
-
- if (chunk != NULL)
- curl_slist_free_all(chunk);
-
- return retval;
+ if (special_http_header) {
+ extra_headers.push_back("Accept: application/vnd.minetest.mmdb-v1+json");
+ return fetchJsonValue(url, &extra_headers);
+ }
+ else {
+ return fetchJsonValue(url, NULL);
+ }
}
#endif