aboutsummaryrefslogtreecommitdiff
path: root/misc/minetest.appdata.xml
blob: 6ef8b7f621d4d2217b5c4399db1b6acc82eb5984 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?xml version="1.0" encoding="UTF-8"?>
<application>
	<id type="desktop">minetest.desktop</id>
	<metadata_license>CC0-1.0</metadata_license>
	<project_license>LGPL-2.1+ and CC-BY-SA-3.0 and MIT and Apache-2.0</project_license>
	<name>Minetest</name>
	<summary>Multiplayer infinite-world block sandbox game</summary>
	<description>
		<p>
			Minetest is an infinite-world block sandbox game and game engine.
		</p><p>
			Players can create and destroy various types of blocks in a
			three-dimensional open world. This allows forming structures in
			every possible creation, on multiplayer servers or in singleplayer.
		</p><p>
			Minetest is designed to be simple, stable, and portable.
			It is lightweight enough to run on fairly old hardware.
		</p><p>
			Minetest has many features, including:
		</p>
		<ul>
			<li>Ability to walk around, dig, and build in a near-infinite voxel world</li>
			<li>Crafting of items from raw materials</li>
			<li>Fast and able to run on old and slow hardware</li>
			<li>A simple modding API that supports many additions and modifications to the game</li>
			<li>Multiplayer support via servers hosted by users</li>
			<li>Beautiful lightning-fast map generator</li>
		</ul>
	</description>
	<screenshots>
		<screenshot type="default" width="1440" height="851">http://minetest.net/_media/screen2.png</screenshot>
		<screenshot width="1440" height="851">http://minetest.net/_media/screenshot_4032289578.png</screenshot>
	</screenshots>
	<url type="homepage">http://minetest.net</url>
	<updatecontact>sfan5@live.de</updatecontact>
</application>
n172' href='#n172'>172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
/*
Minetest-c55
Copyright (C) 2011 celeron55, Perttu Ahola <celeron55@gmail.com>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#include "mods.h"
#include "filesys.h"
#include "strfnd.h"
#include "log.h"
#include "subgame.h"
#include "settings.h"

std::map<std::string, ModSpec> getModsInPath(std::string path)
{
	std::map<std::string, ModSpec> result;
	std::vector<fs::DirListNode> dirlist = fs::GetDirListing(path);
	for(u32 j=0; j<dirlist.size(); j++){
		if(!dirlist[j].dir)
			continue;
		std::string modname = dirlist[j].name;
		// Ignore all directories beginning with a ".", especially
		// VCS directories like ".git" or ".svn"
		if(modname[0] == '.')
			continue;
		std::string modpath = path + DIR_DELIM + modname;

		// Handle modpacks (defined by containing modpack.txt)
		std::ifstream modpack_is((modpath+DIR_DELIM+"modpack.txt").c_str(),
					std::ios_base::binary);
		if(modpack_is.good()) //a modpack, recursively get the mods in it
		{
			modpack_is.close(); // We don't actually need the file
			ModSpec spec(modname,modpath);
			spec.modpack_content = getModsInPath(modpath);
			spec.is_modpack = true;
			result.insert(std::make_pair(modname,spec));
		}
		else // not a modpack, add the modspec
		{
			std::set<std::string> depends;
			std::ifstream is((modpath+DIR_DELIM+"depends.txt").c_str(),
				std::ios_base::binary);
			while(is.good())
			{
				std::string dep;
				std::getline(is, dep);
				dep = trim(dep);	
				if(dep != "")
					depends.insert(dep);
			}

			ModSpec spec(modname, modpath, depends);
			result.insert(std::make_pair(modname,spec));
		}
	}
	return result;
}

std::map<std::string, ModSpec> flattenModTree(std::map<std::string, ModSpec> mods)
{
	std::map<std::string, ModSpec> result;
	for(std::map<std::string,ModSpec>::iterator it = mods.begin();
		it != mods.end(); ++it)
	{
		ModSpec mod = (*it).second;
		if(mod.is_modpack)
		{
			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));
		}
	}
	return result;
}

std::vector<ModSpec> flattenMods(std::map<std::string, ModSpec> mods)
{
	std::vector<ModSpec> result;
	for(std::map<std::string,ModSpec>::iterator it = mods.begin();
		it != mods.end(); ++it)
	{
		ModSpec mod = (*it).second;
		if(mod.is_modpack)
		{
			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
		{
			// infostream << "inserting mod " << mod.name << std::endl;
			result.push_back(mod);
		}
	}
	return result;
}

std::vector<ModSpec> filterMods(std::vector<ModSpec> mods,
								std::set<std::string> exclude_mod_names)
{
	std::vector<ModSpec> result;
	for(std::vector<ModSpec>::iterator it = mods.begin();
		it != mods.end(); ++it)
	{
		ModSpec& mod = *it;
		if(exclude_mod_names.count(mod.name) == 0)
			result.push_back(mod);
	}	
	return result;
}

void ModConfiguration::addModsInPathFiltered(std::string path, std::set<std::string> exclude_mods)
{
	addMods(filterMods(flattenMods(getModsInPath(path)),exclude_mods));
}


void ModConfiguration::addMods(std::vector<ModSpec> new_mods)
{
	// Step 1: remove mods in sorted_mods from unmet dependencies
	// of new_mods. new mods without unmet dependencies are
	// temporarily stored in satisfied_mods
	std::vector<ModSpec> satisfied_mods;
	for(std::vector<ModSpec>::iterator it = m_sorted_mods.begin();
		it != m_sorted_mods.end(); ++it)
	{
		ModSpec mod = *it;
		for(std::vector<ModSpec>::iterator it_new = new_mods.begin();
			it_new != new_mods.end(); ++it_new)
		{
			ModSpec& mod_new = *it_new;
			//infostream << "erasing dependency " << mod.name << " from " << mod_new.name << std::endl;
			mod_new.unsatisfied_depends.erase(mod.name);
		}
	}

	// split new mods into satisfied and unsatisfied
	for(std::vector<ModSpec>::iterator it = new_mods.begin();
		it != new_mods.end(); ++it)
	{
		ModSpec mod_new = *it;
		if(mod_new.unsatisfied_depends.empty())
			satisfied_mods.push_back(mod_new);
		else
			m_unsatisfied_mods.push_back(mod_new);
	}

	// Step 2: mods without unmet dependencies can be appended to
	// the sorted list.
	while(!satisfied_mods.empty())
	{
		ModSpec mod = satisfied_mods.back();
		m_sorted_mods.push_back(mod);
		satisfied_mods.pop_back();
		for(std::list<ModSpec>::iterator it = m_unsatisfied_mods.begin();
			it != m_unsatisfied_mods.end(); )
		{
			ModSpec& mod2 = *it;
			mod2.unsatisfied_depends.erase(mod.name);
			if(mod2.unsatisfied_depends.empty())
			{
				satisfied_mods.push_back(mod2);
				it = m_unsatisfied_mods.erase(it);
			}
			else
				++it;
		}	
	}
}

ModConfiguration::ModConfiguration(std::string worldpath)
{
	// Add all world mods and all game mods
	addModsInPath(worldpath + DIR_DELIM + "worldmods");
	SubgameSpec gamespec = findWorldSubgame(worldpath);
	addModsInPath(gamespec.gamemods_path);

	// check world.mt file for mods explicitely declared to be
	// loaded or not by a load_mod_<modname> = ... line.
	std::string worldmt = worldpath+DIR_DELIM+"world.mt";
	Settings worldmt_settings;
	worldmt_settings.readConfigFile(worldmt.c_str());
	std::vector<std::string> names = worldmt_settings.getNames();
	std::set<std::string> exclude_mod_names;
	for(std::vector<std::string>::iterator it = names.begin(); 
		it != names.end(); ++it)
	{	
		std::string name = *it;  
		// for backwards compatibility: exclude only mods which are