]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/main.cpp
Masterserver show privs and js autoload
[dragonfireclient.git] / src / main.cpp
index ca3c3bc5d7025a373eb4bc5af621bcc25d2de3ee..455138d5b690ac136f2f28900722ebb701f329d5 100644 (file)
@@ -58,6 +58,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "guiMessageMenu.h"
 #include "filesys.h"
 #include "config.h"
+#include "version.h"
 #include "guiMainMenu.h"
 #include "game.h"
 #include "keycode.h"
@@ -77,9 +78,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "quicktune.h"
 #include "serverlist.h"
 #include "guiEngine.h"
+#include "mapsector.h"
 
-#ifdef USE_LEVELDB
 #include "database-sqlite3.h"
+#ifdef USE_LEVELDB
 #include "database-leveldb.h"
 #endif
 
@@ -770,6 +772,8 @@ int main(int argc, char *argv[])
        std::map<std::string, ValueSpec> allowed_options;
        allowed_options.insert(std::make_pair("help", ValueSpec(VALUETYPE_FLAG,
                        _("Show allowed options"))));
+       allowed_options.insert(std::make_pair("version", ValueSpec(VALUETYPE_FLAG,
+                       _("Show version information"))));
        allowed_options.insert(std::make_pair("config", ValueSpec(VALUETYPE_STRING,
                        _("Load configuration from specified file"))));
        allowed_options.insert(std::make_pair("port", ValueSpec(VALUETYPE_STRING,
@@ -794,10 +798,8 @@ int main(int argc, char *argv[])
                        _("Set logfile path ('' = no logging)"))));
        allowed_options.insert(std::make_pair("gameid", ValueSpec(VALUETYPE_STRING,
                        _("Set gameid (\"--gameid list\" prints available ones)"))));
-       #if USE_LEVELDB
        allowed_options.insert(std::make_pair("migrate", ValueSpec(VALUETYPE_STRING,
                        _("Migrate from current map backend to another (Only works when using minetestserver or with --server)"))));
-       #endif
 #ifndef SERVER
        allowed_options.insert(std::make_pair("videomodes", ValueSpec(VALUETYPE_FLAG,
                        _("Show available video modes"))));
@@ -843,6 +845,18 @@ int main(int argc, char *argv[])
 
                return cmd_args.getFlag("help") ? 0 : 1;
        }
+
+       if(cmd_args.getFlag("version"))
+       {
+#ifdef SERVER
+               dstream<<"minetestserver "<<minetest_version_hash<<std::endl;
+#else
+               dstream<<"Minetest "<<minetest_version_hash<<std::endl;
+               dstream<<"Using Irrlicht "<<IRRLICHT_SDK_VERSION<<std::endl;
+#endif
+               dstream<<"Build info: "<<minetest_build_info<<std::endl;
+               return 0;
+       }
        
        /*
                Low-level initialization
@@ -904,7 +918,7 @@ int main(int argc, char *argv[])
        // Print startup message
        infostream<<PROJECT_NAME<<
                        " "<<_("with")<<" SER_FMT_VER_HIGHEST_READ="<<(int)SER_FMT_VER_HIGHEST_READ
-                       <<", "<<BUILD_INFO
+                       <<", "<<minetest_build_info
                        <<std::endl;
        
        /*
@@ -1218,7 +1232,6 @@ int main(int argc, char *argv[])
                // Create server
                Server server(world_path, gamespec, false);
 
-               #if USE_LEVELDB
                // Database migration
                if (cmd_args.exists("migrate")) {
                        std::string migrate_to = cmd_args.get("migrate");
@@ -1241,8 +1254,10 @@ int main(int argc, char *argv[])
                        }
                        if (migrate_to == "sqlite3")
                                new_db = new Database_SQLite3(&(ServerMap&)server.getMap(), world_path);
+                       #if USE_LEVELDB
                        else if (migrate_to == "leveldb")
                                new_db = new Database_LevelDB(&(ServerMap&)server.getMap(), world_path);
+                       #endif
                        else {
                                errorstream << "Migration to " << migrate_to << " is not supported" << std::endl;
                                return 1;
@@ -1266,11 +1281,14 @@ int main(int argc, char *argv[])
                        new_db->endSave();
 
                        actionstream << "Successfully migrated " << count << " blocks" << std::endl;
-                       actionstream << "Don't forget to update your world.mt backend setting!" << std::endl;
+                       world_mt.set("backend", migrate_to);
+                       if(!world_mt.updateConfigFile((world_path + DIR_DELIM + "world.mt").c_str()))
+                               errorstream<<"Failed to update world.mt!"<<std::endl;
+                       else
+                               actionstream<<"world.mt updated"<<std::endl;
 
                        return 0;
                }
-               #endif
 
                server.start(port);
                
@@ -1470,8 +1488,8 @@ int main(int argc, char *argv[])
        gui::IGUISkin* skin = guienv->getSkin();
        std::string font_path = g_settings->get("font_path");
        gui::IGUIFont *font;
-       bool use_freetype = g_settings->getBool("freetype");
        #if USE_FREETYPE
+       bool use_freetype = g_settings->getBool("freetype");
        if (use_freetype) {
                std::string fallback;
                if (is_yes(gettext("needs_fallback_font")))
@@ -1683,7 +1701,7 @@ int main(int argc, char *argv[])
                                g_settings->set("port", itos(port));
 
                                if((menudata.selected_world >= 0) &&
-                                               (menudata.selected_world < worldspecs.size()))
+                                               (menudata.selected_world < (int)worldspecs.size()))
                                        g_settings->set("selected_world_path",
                                                        worldspecs[menudata.selected_world].path);
 
@@ -1715,7 +1733,7 @@ int main(int argc, char *argv[])
                                
                                // Set world path to selected one
                                if ((menudata.selected_world >= 0) &&
-                                       (menudata.selected_world < worldspecs.size())) {
+                                       (menudata.selected_world < (int)worldspecs.size())) {
                                        worldspec = worldspecs[menudata.selected_world];
                                        infostream<<"Selected world: "<<worldspec.name
                                                        <<" ["<<worldspec.path<<"]"<<std::endl;