]> git.lizzy.rs Git - minetest.git/blobdiff - src/main.cpp
Display Lua memory usage at the time of Out-of-Memory error
[minetest.git] / src / main.cpp
index a01ddec93f80e69079806cb60d55cc157177f827..1d73b40253003a6a37140e33daae2375cd13a61e 100644 (file)
@@ -29,11 +29,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 #include "irrlicht.h" // createDevice
 
-#include "main.h"
 #include "mainmenumanager.h"
 #include "irrlichttypes_extrabloated.h"
 #include "debug.h"
-#include "test.h"
+#include "unittest/test.h"
 #include "server.h"
 #include "filesys.h"
 #include "version.h"
@@ -41,7 +40,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "game.h"
 #include "defaultsettings.h"
 #include "gettext.h"
-#include "profiler.h"
 #include "log.h"
 #include "quicktune.h"
 #include "httpfetch.h"
@@ -59,38 +57,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "touchscreengui.h"
 #endif
 
-/*
-       Settings.
-       These are loaded from the config file.
-*/
-static Settings main_settings;
-Settings *g_settings = &main_settings;
-std::string g_settings_path;
-
-// Global profiler
-Profiler main_profiler;
-Profiler *g_profiler = &main_profiler;
-
-// Menu clouds are created later
-Clouds *g_menuclouds = 0;
-irr::scene::ISceneManager *g_menucloudsmgr = 0;
-
-/*
-       Debug streams
-*/
-
-// Connection
-std::ostream *dout_con_ptr = &dummyout;
-std::ostream *derr_con_ptr = &verbosestream;
-
-// Server
-std::ostream *dout_server_ptr = &infostream;
-std::ostream *derr_server_ptr = &errorstream;
-
-// Client
-std::ostream *dout_client_ptr = &infostream;
-std::ostream *derr_client_ptr = &errorstream;
-
 #define DEBUGFILE "debug.txt"
 #define DEFAULT_SERVER_PORT 30000
 
@@ -137,26 +103,6 @@ static bool migrate_database(const GameParams &game_params, const Settings &cmd_
 
 /**********************************************************************/
 
-#ifndef SERVER
-/*
-       Random stuff
-*/
-
-/* mainmenumanager.h */
-
-gui::IGUIEnvironment* guienv = NULL;
-gui::IGUIStaticText *guiroot = NULL;
-MainMenuManager g_menumgr;
-
-bool noMenuActive()
-{
-       return (g_menumgr.menuCount() == 0);
-}
-
-// Passed to menus to allow disconnecting and exiting
-MainGameCallback *g_gamecallback = NULL;
-#endif
-
 /*
        gettime.h implementation
 */
@@ -273,7 +219,7 @@ int main(int argc, char *argv[])
        if (!game_configure(&game_params, cmd_args))
                return 1;
 
-       assert(game_params.world_path != "");
+       sanity_check(game_params.world_path != "");
 
        infostream << "Using commanded world path ["
                   << game_params.world_path << "]" << std::endl;
@@ -400,13 +346,11 @@ static void print_allowed_options(const OptionList &allowed_options)
 
 static void print_version()
 {
-#ifdef SERVER
-       dstream << "minetestserver " << minetest_version_hash << std::endl;
-#else
-       dstream << "Minetest " << minetest_version_hash << std::endl;
+       dstream << PROJECT_NAME_C " " << g_version_hash << std::endl;
+#ifndef SERVER
        dstream << "Using Irrlicht " << IRRLICHT_SDK_VERSION << std::endl;
 #endif
-       dstream << "Build info: " << minetest_build_info << std::endl;
+       dstream << "Build info: " << g_build_info << std::endl;
 }
 
 static void list_game_ids()
@@ -543,13 +487,13 @@ static void startup_message()
        infostream << PROJECT_NAME << " " << _("with")
                   << " SER_FMT_VER_HIGHEST_READ="
                << (int)SER_FMT_VER_HIGHEST_READ << ", "
-               << minetest_build_info << std::endl;
+               << g_build_info << std::endl;
 }
 
 static bool read_config_file(const Settings &cmd_args)
 {
        // Path of configuration file in use
-       assert(g_settings_path == "");  // Sanity check
+       sanity_check(g_settings_path == "");    // Sanity check
 
        if (cmd_args.exists("config")) {
                bool r = g_settings->readConfigFile(cmd_args.get("config").c_str());
@@ -748,7 +692,7 @@ static bool auto_select_world(GameParams *game_params)
                           << world_path << "]" << std::endl;
        }
 
-       assert(world_path != "");
+       assert(world_path != "");       // Post-condition
        game_params->world_path = world_path;
        return true;
 }
@@ -804,7 +748,7 @@ static bool determine_subgame(GameParams *game_params)
 {
        SubgameSpec gamespec;
 
-       assert(game_params->world_path != "");  // pre-condition
+       assert(game_params->world_path != "");  // Pre-condition
 
        verbosestream << _("Determining gameid/gamespec") << std::endl;
        // If world doesn't exist