diff --git a/README.txt b/README.txt index 20917d77..d2de68d5 100644 --- a/README.txt +++ b/README.txt @@ -9,9 +9,10 @@ and contributors (see source file comments and the version control log) In case you downloaded the source code: --------------------------------------- If you downloaded the Minetest Engine source code in which this file is -contained, you probably want to download the minetest_game project too: +contained, you probably want to download these projects too: + https://github.com/minetest/common/ https://github.com/minetest/minetest_game/ -See the README.txt in it. +See the README.txt in them. Further documentation ---------------------- @@ -87,10 +88,17 @@ $ wget https://github.com/minetest/minetest/tarball/master -O master.tar.gz $ tar xf master.tar.gz $ cd minetest-minetest-286edd4 (or similar) +Download common (needed for minetest_game and some others) +$ cd games/ +$ wget https://github.com/minetest/common/tarball/master -O common.tar.gz +$ tar xf common.tar.gz +$ mv minetest-common-* common +$ cd .. + Download minetest_game (otherwise only the "Minimal development test" game is available) $ cd games/ -$ wget https://github.com/minetest/minetest_game/tarball/master -O master.tar.gz -$ tar xf master.tar.gz +$ wget https://github.com/minetest/minetest_game/tarball/master -O minetest_game.tar.gz +$ tar xf minetest_game.tar.gz $ mv minetest-minetest_game-* minetest_game $ cd .. @@ -111,7 +119,7 @@ $ ./minetest Compiling on Windows: --------------------- - This section is outdated. In addition to what is described here: - - In addition to minetest, you need to download minetest_game. + - In addition to minetest, you need to download common and minetest_game. - If you wish to have sound support, you need libogg, libvorbis and libopenal - You need: diff --git a/doc/lua_api.txt b/doc/lua_api.txt index 7d8fa149..af8b1cc9 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -27,6 +27,39 @@ Startup Mods are loaded during server startup from the mod load paths by running the init.lua scripts in a shared environment. +Paths +----- +RUN_IN_PLACE=1: (Windows release, local build) + $path_user: Linux: + Windows: + $path_share: Linux: + Windows: + +RUN_IN_PLACE=0: (Linux release) + $path_share: Linux: /usr/share/minetest + Windows: /minetest-0.4.x + $path_user: Linux: ~/.minetest + Windows: C:/users//AppData/minetest (maybe) + +Games +----- +Games are looked up from: + $path_share/games/gameid/ + $path_user/games/gameid/ +where gameid is unique to each game. + +The game directory contains the file game.conf, which contains these fields: + name = + common_mods = +eg. + name = Minetest + common_mods = bucket, default, doors, fire, stairs + +Common mods are loaded from the pseudo-game "common". + +The game directory can contain the file minetest.conf, which will be used +to set default settings when running the particular game. + Mod load path ------------- Generic: diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index fc570c8c..acfecadc 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -243,3 +243,12 @@ void set_default_settings(Settings *settings) settings->setDefault("gravity_acceleration_client", "9.86"); } +void override_default_settings(Settings *settings, Settings *from) +{ + std::vector names = from->getNames(); + for(size_t i=0; isetDefault(name, from->get(name)); + } +} + diff --git a/src/defaultsettings.h b/src/defaultsettings.h index 37e3f717..00aacad8 100644 --- a/src/defaultsettings.h +++ b/src/defaultsettings.h @@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc., class Settings; void set_default_settings(Settings *settings); +void override_default_settings(Settings *settings, Settings *from); #endif diff --git a/src/mods.cpp b/src/mods.cpp index ac2d9b17..6a7ab79a 100644 --- a/src/mods.cpp +++ b/src/mods.cpp @@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "log.h" #include "subgame.h" #include "settings.h" +#include "strfnd.h" std::map getModsInPath(std::string path) { @@ -188,11 +189,58 @@ void ModConfiguration::addMods(std::vector new_mods) } } +// If failed, returned modspec has name=="" +static ModSpec findCommonMod(const std::string &modname) +{ + // Try to find in {$user,$share}/games/common/$modname + std::vector 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 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 + m_sorted_mods.push_back(spec); + } + } + } + if(!inexistent_common_mods.empty()){ + std::string s = "Required common mods "; + for(u32 i=0; i::const_iterator i = gamespec.addon_mods_paths.begin(); - i != gamespec.addon_mods_paths.end(); ++i) + i != gamespec.addon_mods_paths.end(); ++i) addModsInPathFiltered((*i),exclude_mod_names); } diff --git a/src/server.cpp b/src/server.cpp index d699dc9d..f77ac6ad 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -58,6 +58,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "util/mathconstants.h" #include "rollback.h" #include "util/serialize.h" +#include "defaultsettings.h" void * ServerThread::Thread() { @@ -687,6 +688,13 @@ Server::Server( infostream<<"- config: "<::iterator it = m_mods.begin(); - it != m_mods.end(); ++it) + it != m_mods.end(); ++it) load_mod_names.erase((*it).name); for(std::list::iterator it = unsatisfied_mods.begin(); - it != unsatisfied_mods.end(); ++it) + it != unsatisfied_mods.end(); ++it) load_mod_names.erase((*it).name); if(!load_mod_names.empty()) { diff --git a/src/subgame.cpp b/src/subgame.cpp index 3c8bf53c..19ad4e63 100644 --- a/src/subgame.cpp +++ b/src/subgame.cpp @@ -24,12 +24,22 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "log.h" #include "util/string.h" -std::string getGameName(const std::string &game_path) +bool getGameMinetestConfig(const std::string &game_path, Settings &conf) +{ + std::string conf_path = game_path + DIR_DELIM + "minetest.conf"; + return conf.readConfigFile(conf_path.c_str()); +} + +bool getGameConfig(const std::string &game_path, Settings &conf) { std::string conf_path = game_path + DIR_DELIM + "game.conf"; + return conf.readConfigFile(conf_path.c_str()); +} + +std::string getGameName(const std::string &game_path) +{ Settings conf; - bool succeeded = conf.readConfigFile(conf_path.c_str()); - if(!succeeded) + if(!getGameConfig(game_path, conf)) return ""; if(!conf.exists("name")) return ""; @@ -117,6 +127,11 @@ std::set getAvailableGameIds() for(u32 j=0; j #include +class Settings; + #define WORLDNAME_BLACKLISTED_CHARS "/\\" struct SubgameSpec @@ -52,6 +54,11 @@ struct SubgameSpec } }; +// minetest.conf +bool getGameMinetestConfig(const std::string &game_path, Settings &conf); +// game.conf +bool getGameConfig(const std::string &game_path, Settings &conf); + std::string getGameName(const std::string &game_path); SubgameSpec findSubgame(const std::string &id); diff --git a/util/buildbot/buildwin32.sh b/util/buildbot/buildwin32.sh index 1e0094b1..9e2b8e35 100755 --- a/util/buildbot/buildwin32.sh +++ b/util/buildbot/buildwin32.sh @@ -53,6 +53,9 @@ cd $builddir wget http://github.com/rarkenin/minetest/zipball/master \ -c -O $packagedir/minetest.zip --tries=3 || (echo "Please download http://github.com/minetest/minetest/zipball/master manually and save it as $packagedir/minetest.zip"; read -s) [ -e $packagedir/minetest.zip ] || (echo "minetest.zip not found"; exit 1) +wget http://github.com/minetest/common/zipball/master \ + -c -O $packagedir/common.zip --tries=3 || (echo "Please download http://github.com/minetest/common/zipball/master manually and save it as $packagedir/common.zip"; read -s) +[ -e $packagedir/common.zip ] || (echo "common.zip not found"; exit 1) wget http://github.com/minetest/minetest_game/zipball/master \ -c -O $packagedir/minetest_game.zip --tries=3 || (echo "Please download http://github.com/minetest/minetest_game/zipball/master manually and save it as $packagedir/minetest_game.zip"; read -s) [ -e $packagedir/minetest_game.zip ] || (echo "minetest_game.zip not found"; exit 1) @@ -66,6 +69,7 @@ wget http://github.com/minetest/minetest_game/zipball/master \ minetestdirname=`unzip -l $packagedir/minetest.zip | head -n 7 | tail -n 1 | sed -e 's/^[^m]*//' -e 's/\/.*$//'` minetestdir=$builddir/rarkenin-$minetestdirname || exit 1 git_hash=`echo $minetestdirname | sed -e 's/rarkenin-minetest-//'` +commondirname=`unzip -l $packagedir/common.zip | head -n 7 | tail -n 1 | sed -e 's/^[^m]*//' -e 's/\/.*$//'` minetest_gamedirname=`unzip -l $packagedir/minetest_game.zip | head -n 7 | tail -n 1 | sed -e 's/^[^m]*//' -e 's/\/.*$//'` # Extract stuff @@ -86,6 +90,13 @@ unzip -o $packagedir/minetest.zip || exit 1 rm -rf $builddir/minetest ln -s $minetestdir $builddir/minetest +# Extract common +cd $minetestdir/games || exit 1 +rm -rf common || exit 1 +unzip -o $packagedir/common.zip || exit 1 +commondir=$minetestdir/games/$commondirname || exit 1 +mv $commondir $minetestdir/games/common || exit 1 + # Extract minetest_game cd $minetestdir/games || exit 1 rm -rf minetest_game || exit 1 @@ -123,7 +134,7 @@ cmake $minetestdir -DCMAKE_TOOLCHAIN_FILE=$toolchain_file -DENABLE_SOUND=1 \ -DCMAKE_INSTALL_PREFIX=/tmp \ -DVERSION_EXTRA=rark-`date +%F`$2 \ || exit 1 -nice -n 15 make -j2 package || exit 1 +make -j2 package || exit 1 #pubdir=/home/celeron55/public_html/random/`date +%Y-%m` || exit 1 #mkdir -p $pubdir || exit 1