Move globals from main.cpp to more sane locations
authorCraig Robbins <kde.psych@gmail.com>
Wed, 1 Apr 2015 13:01:28 +0000 (23:01 +1000)
committerCraig Robbins <kde.psych@gmail.com>
Wed, 1 Apr 2015 13:04:25 +0000 (23:04 +1000)
Move debug streams to log.cpp|h

Move GUI-related globals to clientlauncher

Move g_settings and g_settings_path to settings.cpp|h

Move g_menuclouds to clouds.cpp|h

Move g_profiler to profiler.cpp|h

72 files changed:
build/android/jni/Android.mk
src/CMakeLists.txt
src/camera.cpp
src/client.cpp
src/client/clientlauncher.cpp
src/client/tile.cpp
src/clientiface.cpp
src/clientmap.cpp
src/clientmedia.cpp
src/clouds.cpp
src/clouds.h
src/collision.cpp
src/content_abm.cpp
src/content_cao.cpp
src/content_mapblock.cpp
src/content_sao.cpp
src/convert_json.cpp
src/database-sqlite3.cpp
src/drawscene.cpp
src/dungeongen.cpp
src/emerge.cpp
src/environment.cpp
src/fontengine.cpp
src/guiChatConsole.cpp
src/guiEngine.cpp
src/guiFormSpecMenu.cpp
src/guiKeyChangeMenu.cpp
src/guiTable.cpp
src/guiVolumeChange.cpp
src/guiscalingfilter.cpp
src/httpfetch.cpp
src/hud.cpp
src/inventorymanager.cpp
src/itemdef.cpp
src/keycode.cpp
src/localplayer.cpp
src/log.cpp
src/log.h
src/main.cpp
src/main.h [deleted file]
src/mainmenumanager.h
src/map.cpp
src/mapblock_mesh.cpp
src/mapgen.cpp
src/mapgen_v5.cpp
src/mapgen_v6.cpp
src/mapgen_v7.cpp
src/mapnode.cpp
src/mg_biome.cpp
src/mods.cpp
src/network/connection.cpp
src/network/serverpackethandler.cpp
src/nodedef.cpp
src/particles.cpp
src/porting.cpp
src/profiler.cpp [new file with mode: 0644]
src/profiler.h
src/script/common/c_internal.cpp
src/script/lua_api/l_internal.h
src/script/lua_api/l_mainmenu.cpp
src/script/lua_api/l_mapgen.cpp
src/script/lua_api/l_util.cpp
src/server.cpp
src/serverlist.cpp
src/settings.cpp
src/settings.h
src/shader.cpp
src/sky.cpp
src/socket.cpp
src/subgame.cpp
src/test.cpp
src/wieldmesh.cpp

index af7980c5167dfef88a6e458e7338e79af73dd732..ab4a9cfcc44e0ff7cf97d80fa2096fb2b308e806 100644 (file)
@@ -183,6 +183,7 @@ LOCAL_SRC_FILES :=                                \
                jni/src/player.cpp                        \
                jni/src/porting_android.cpp               \
                jni/src/porting.cpp                       \
+               jni/src/profiler.cpp                      \
                jni/src/quicktune.cpp                     \
                jni/src/rollback.cpp                      \
                jni/src/rollback_interface.cpp            \
index a1c2d013c2f0ffa9de4e4980b7eda88ce4f3bc5b..ff700257c5563f28ffd6defb9d26e25ae872de35 100644 (file)
@@ -329,6 +329,7 @@ set(common_SRCS
        pathfinder.cpp
        player.cpp
        porting.cpp
+       profiler.cpp
        quicktune.cpp
        rollback.cpp
        rollback_interface.cpp
index 0152f704112b63cbf6ca68c0589fa20428749b02..ca28555d2e15daee9ff0484266bed0a2183d3801 100644 (file)
@@ -20,14 +20,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "camera.h"
 #include "debug.h"
 #include "client.h"
-#include "main.h" // for g_settings
 #include "map.h"
-#include "clientmap.h" // MapDrawControl
+#include "clientmap.h"     // MapDrawControl
 #include "player.h"
 #include <cmath>
 #include "settings.h"
 #include "wieldmesh.h"
-#include "noise.h" // easeCurve
+#include "noise.h"         // easeCurve
 #include "gamedef.h"
 #include "sound.h"
 #include "event.h"
index ba78cb51e5608106357e6b9791149e23767af340..d2bbdc284a95d65264aa3607ab0c99d5a83e7b31 100644 (file)
@@ -28,7 +28,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "util/string.h"
 #include "client.h"
 #include "network/clientopcodes.h"
-#include "main.h"
 #include "filesys.h"
 #include "porting.h"
 #include "mapblock_mesh.h"
index 6815082a670831c3df514a7d90f220aa17bdbc1d..fe4dec40f57fa558c9f37fdf4cd149b4b60400bc 100644 (file)
@@ -17,7 +17,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
 
-#include "main.h"
 #include "mainmenumanager.h"
 #include "debug.h"
 #include "clouds.h"
@@ -35,9 +34,23 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "fontengine.h"
 #include "clientlauncher.h"
 
-// A pointer to a global instance of the time getter
-// TODO: why?
-TimeGetter *g_timegetter = NULL;
+/* 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;
+
+
+// Instance of the time getter
+static TimeGetter *g_timegetter = NULL;
 
 u32 getTimeMs()
 {
index 283b262a6343d1c284e2d7d34713cea08ea79ead..315c2fa2951336d7bee057472403a1a8ec13f903 100644 (file)
@@ -26,7 +26,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "util/numeric.h"
 #include "irrlichttypes_extrabloated.h"
 #include "debug.h"
-#include "main.h" // for g_settings
 #include "filesys.h"
 #include "settings.h"
 #include "mesh.h"
index 3171e77957a10a5bd935a7339c3e5ecc948bce75..7649be29eff7586f7ced78f1bd0e4145c9a0bfcf 100644 (file)
@@ -30,7 +30,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "map.h"
 #include "emerge.h"
 #include "serverobject.h"              // TODO this is used for cleanup of only
-#include "main.h"                      // for g_settings
 #include "log.h"
 
 const char *ClientInterface::statenames[] = {
index 907df7128a15a6629a60914b8b9804334d4595cc..1a52ac4aba8ab03b7955cda6eef8c3c8b6d9b1ab 100644 (file)
@@ -24,12 +24,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include <matrix4.h>
 #include "log.h"
 #include "mapsector.h"
-#include "main.h" // dout_client, g_settings
 #include "nodedef.h"
 #include "mapblock.h"
 #include "profiler.h"
 #include "settings.h"
-#include "camera.h" // CameraModes
+#include "camera.h"               // CameraModes
 #include "util/mathconstants.h"
 #include <algorithm>
 
index 0918e8a3797002d2d262445d7dfe3ffec32b7ce4..ea11ad239ec6210683b0aadd73863bb3aa974f37 100644 (file)
@@ -26,7 +26,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "log.h"
 #include "porting.h"
 #include "settings.h"
-#include "main.h"
 #include "network/networkprotocol.h"
 #include "util/hex.h"
 #include "util/serialize.h"
index 8fea7a6aa24b7292c7d04c15ddb6f2b04f84e972..3409aac73ab6b08a8015950534ee470cbd6558e7 100644 (file)
@@ -21,10 +21,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "noise.h"
 #include "constants.h"
 #include "debug.h"
-#include "main.h" // For g_profiler and g_settings
 #include "profiler.h"
 #include "settings.h"
 
+
+// Menu clouds are created later
+class Clouds;
+Clouds *g_menuclouds = NULL;
+irr::scene::ISceneManager *g_menucloudsmgr = NULL;
+
 Clouds::Clouds(
                scene::ISceneNode* parent,
                scene::ISceneManager* mgr,
index a9e58e0f082d2590ca30ac18e1956f29bb14f560..add8a7247b2c0e5144c3ccf7aace5104069267f4 100644 (file)
@@ -24,6 +24,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include <iostream>
 #include "constants.h"
 
+// Menu clouds
+class Clouds;
+extern Clouds *g_menuclouds;
+
+// Scene manager used for menu clouds
+namespace irr{namespace scene{class ISceneManager;}}
+extern irr::scene::ISceneManager *g_menucloudsmgr;
+
 class Clouds : public scene::ISceneNode
 {
 public:
index 12eabff090dd6dd433e4ae30748be786720bf1f8..c759f20c066bfc2f2bf8ba1ea272b37eecc25a18 100644 (file)
@@ -28,7 +28,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include <vector>
 #include <set>
 #include "util/timetaker.h"
-#include "main.h" // g_profiler
 #include "profiler.h"
 
 // float error is 10 - 9.96875 = 0.03125
index 1ee41b2ecf4cceaf73fd690603a40c06ca1d6974..8694ef9814807a81d7a1fef9694d2e25286b8ae6 100644 (file)
@@ -25,7 +25,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "content_sao.h"
 #include "settings.h"
 #include "mapblock.h" // For getNodeBlockPos
-#include "main.h" // for g_settings
 #include "map.h"
 #include "scripting_game.h"
 #include "log.h"
index 6b7083d8376553e024bc2d6903dfde3b326e13f9..a8b107b49692630eec80667ea04ae4b457f1fe83 100644 (file)
@@ -42,7 +42,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "nodedef.h"
 #include "localplayer.h"
 #include "map.h"
-#include "main.h" // g_settings
 #include "camera.h" // CameraModes
 #include "wieldmesh.h"
 #include "log.h"
index a730c50a357d58cc28b99d6f348a021b45b37c2a..8fa041312e545fe261cefef7da1e5e0ef339e811 100644 (file)
@@ -20,7 +20,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "content_mapblock.h"
 #include "util/numeric.h"
 #include "util/directiontables.h"
-#include "main.h" // For g_settings
 #include "mapblock_mesh.h" // For MapBlock_LightColor() and MeshCollector
 #include "settings.h"
 #include "nodedef.h"
index 9fc61aea70479c5c36d82af91f0b573a7ac159d7..51f074f7cf08f906920fdcd91ea76857f8b0ea17 100644 (file)
@@ -23,7 +23,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "collision.h"
 #include "environment.h"
 #include "settings.h"
-#include "main.h" // For g_profiler
 #include "profiler.h"
 #include "serialization.h" // For compressZlib
 #include "tool.h" // For ToolCapabilities
index cea0896239d7b1ed9322abeeedb8252d0f52c003..68912d482de84a496b9851fdd55593b407f1f3fb 100644 (file)
@@ -25,7 +25,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "mods.h"
 #include "config.h"
 #include "log.h"
-#include "main.h" // for g_settings
 #include "settings.h"
 #include "httpfetch.h"
 #include "porting.h"
index c937cae3128bfafac52e7fd6d8634b5bacf142cb..45de3cb605aa251997525faaeec25b2a80792226 100644 (file)
@@ -30,7 +30,6 @@ SQLite format specification:
 #include "log.h"
 #include "filesys.h"
 #include "exceptions.h"
-#include "main.h"
 #include "settings.h"
 #include "util/string.h"
 
index c3c3b2ef207d2c2e3b739104a8585d77f756b7ee..f7cfdd262e2fa75f92bd3da7fe28cd00b277a8cb 100644 (file)
@@ -18,7 +18,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 */
 
 #include "drawscene.h"
-#include "main.h" // for g_settings
 #include "settings.h"
 #include "clouds.h"
 #include "clientmap.h"
index 3b7e755b389b6e7646ef25e3d4afcf9e3ae575ea..7e292024da8c170014d9aa593ec09fe6ac6f6621 100644 (file)
@@ -26,8 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "map.h"
 #include "nodedef.h"
 #include "profiler.h"
-#include "settings.h" // For g_settings
-#include "main.h" // For g_profiler
+#include "settings.h"
 
 //#define DGEN_USE_TORCHES
 
index bf104e0356c43c0f5b81094ab5004ce1323cbe24..9c5ee452ef6f0bd6389f5f181582bfdef3b2b6ee 100644 (file)
@@ -28,7 +28,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "environment.h"
 #include "util/container.h"
 #include "util/thread.h"
-#include "main.h"
 #include "constants.h"
 #include "voxel.h"
 #include "config.h"
index d437dbd5dfe660d96250997af3a19016cf0aa572..af213e5e21cbb563612dbcd93aa175d95b03c531 100644 (file)
@@ -17,6 +17,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
 
+#include <fstream>
 #include "environment.h"
 #include "filesys.h"
 #include "porting.h"
@@ -31,7 +32,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "scripting_game.h"
 #include "nodedef.h"
 #include "nodemetadata.h"
-#include "main.h" // For g_settings, g_profiler
 #include "gamedef.h"
 #ifndef SERVER
 #include "clientmap.h"
index fa30b403813795a15ce3662d9117e835e63f046a..14b65f593ee34f74e194513c7cea695d5ef2653f 100644 (file)
@@ -18,7 +18,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 */
 #include "fontengine.h"
 #include "log.h"
-#include "main.h"
 #include "config.h"
 #include "porting.h"
 #include "constants.h"
index b52589044ab018f7f2e7bef8d706f346cd05d223..3937e405cc8dcb81c415c39d4abae47daa0e5dee 100644 (file)
@@ -24,7 +24,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "gettime.h"
 #include "keycode.h"
 #include "settings.h"
-#include "main.h"  // for g_settings
 #include "porting.h"
 #include "client/tile.h"
 #include "fontengine.h"
index 07fdbb16e01d950e2c27e781e9741acf15d6d49b..6989ffa35415fe917e3a427b94ae6b20fa0c8f2e 100644 (file)
@@ -19,6 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 #include "guiEngine.h"
 
+#include <fstream>
 #include <IGUIStaticText.h>
 #include <ICameraSceneNode.h>
 #include "scripting_mainmenu.h"
@@ -27,7 +28,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "version.h"
 #include "porting.h"
 #include "filesys.h"
-#include "main.h"
 #include "settings.h"
 #include "guiMainMenu.h"
 #include "sound.h"
index c29e74f7a2807b61b99405e7285308f0a6074335..5f67bb22afbd3b96f5325cc2522f39cfbab51b9e 100644 (file)
@@ -44,7 +44,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "gettext.h"
 #include "scripting_game.h"
 #include "porting.h"
-#include "main.h"
 #include "settings.h"
 #include "client.h"
 #include "fontengine.h"
index 3ddb3f5d9e21a99bf6ee5a1899b2c8738498b201..008ac8c5d6ab996cc147c2b0dd64f9189834e98e 100644 (file)
@@ -22,7 +22,6 @@
 #include "guiKeyChangeMenu.h"
 #include "debug.h"
 #include "serialization.h"
-#include "main.h"
 #include <string>
 #include <IGUICheckBox.h>
 #include <IGUIEditBox.h>
index 6dcd115b0eeae24bd7f41aabb2266656b230bd9a..e915770a412da09dec79233c745cfde581b1ad45 100644 (file)
@@ -33,7 +33,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "util/string.h"
 #include "util/numeric.h"
 #include "util/string.h" // for parseColorString()
-#include "main.h"
 #include "settings.h" // for settings
 #include "porting.h" // for dpi
 #include "guiscalingfilter.h"
index b31b99a983de46431155556c41a229e640a36dab..c8e257f7f1c1a104d56dfb6ba33430fc99f0ec42 100644 (file)
@@ -26,7 +26,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include <IGUIScrollBar.h>
 #include <IGUIStaticText.h>
 #include <IGUIFont.h>
-#include "main.h"
 #include "settings.h"
 
 #include "gettext.h"
index 872d222d85759a3f8872afa8942db2cbca5d461e..33e0648ad3a5e7cc9225de1a9afffa3318403099 100644 (file)
@@ -19,7 +19,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "guiscalingfilter.h"
 #include "imagefilters.h"
 #include "settings.h"
-#include "main.h"              // for g_settings
 #include "util/numeric.h"
 #include <stdio.h>
 
index e17a8b1876eb825bf153aa1ce5b4dee3aa2f4ea2..50ad9e4afe69d7263586a8977dd5003aa95480f7 100644 (file)
@@ -33,7 +33,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "util/container.h"
 #include "util/thread.h"
 #include "version.h"
-#include "main.h"
 #include "settings.h"
 
 JMutex g_httpfetch_mutex;
index 0b34a7b5bfb00d323841dac23b9f0b5ca7e7f678..02b69a12cb9c7104c5758f7af87fce843ef2fdfb 100644 (file)
@@ -20,7 +20,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 */
 
 #include "hud.h"
-#include "main.h"
 #include "settings.h"
 #include "util/numeric.h"
 #include "log.h"
index 178985dfd2b3bca8d797e74cfa200447b9357cfe..c3a9576f90ef2111998d3f9c8665c74e6d67778f 100644 (file)
@@ -22,7 +22,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "environment.h"
 #include "scripting_game.h"
 #include "serverobject.h"
-#include "main.h"  // for g_settings
 #include "settings.h"
 #include "craftdef.h"
 #include "rollback_interface.h"
index 65ba356f4e1d8b33be9cbf49f2ca74f6e69a9e67..95c1e47fc88513642668daedcb7127cd129b38b8 100644 (file)
@@ -31,7 +31,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "client/tile.h"
 #endif
 #include "log.h"
-#include "main.h" // g_settings
 #include "settings.h"
 #include "util/serialize.h"
 #include "util/container.h"
index d9fc88934cfc4da3a7c2505f206827f132eb2762..1ec325961bbcbfd3859db9c94315780fef475de9 100644 (file)
@@ -18,7 +18,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 */
 
 #include "keycode.h"
-#include "main.h" // For g_settings
 #include "exceptions.h"
 #include "settings.h"
 #include "log.h"
index 55578422e8a2fea792e26b56dd2f537dd8124f68..51d9bdd4b120a54dfc7873fc5ad5bb8fe45be829 100644 (file)
@@ -19,7 +19,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 #include "localplayer.h"
 
-#include "main.h" // For g_settings
 #include "event.h"
 #include "collision.h"
 #include "gamedef.h"
index 398c89eb0bb51b346ff605239e47232de41e17ae..e6d80db34e2a0a9747a3e34dc684f9b96a999fdf 100644 (file)
@@ -30,6 +30,20 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "porting.h"
 #include "config.h"
 
+// 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;
+
+#ifndef SERVER
+// Client
+std::ostream *dout_client_ptr = &infostream;
+std::ostream *derr_client_ptr = &errorstream;
+#endif
+
 #ifdef __ANDROID__
 unsigned int android_log_level_mapping[] = {
                /* LMT_ERROR */   ANDROID_LOG_ERROR,
index 6240e34ed009ee6df24b8b4182b6c59416173a69..bd223927a6c18158427ede259a9799424e9030c0 100644 (file)
--- a/src/log.h
+++ b/src/log.h
@@ -81,5 +81,22 @@ extern bool log_trace_level_enabled;
 #define TRACESTREAM(x){ if(log_trace_level_enabled) verbosestream x; }
 #define TRACEDO(x){ if(log_trace_level_enabled){ x ;} }
 
+extern std::ostream *dout_con_ptr;
+extern std::ostream *derr_con_ptr;
+extern std::ostream *dout_server_ptr;
+extern std::ostream *derr_server_ptr;
+#define dout_con (*dout_con_ptr)
+#define derr_con (*derr_con_ptr)
+#define dout_server (*dout_server_ptr)
+#define derr_server (*derr_server_ptr)
+
+#ifndef SERVER
+extern std::ostream *dout_client_ptr;
+extern std::ostream *derr_client_ptr;
+#define dout_client (*dout_client_ptr)
+#define derr_client (*derr_client_ptr)
+
+#endif
+
 #endif
 
index 3893b9a82ce57cdf04d1ca3c42b9785a27c9de62..dc0a01f805ea1fdbc593f0d1491fdc8ddb17343c 100644 (file)
@@ -29,7 +29,6 @@ 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"
@@ -59,38 +58,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 +104,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
 */
diff --git a/src/main.h b/src/main.h
deleted file mode 100644 (file)
index 191b418..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
-Minetest
-Copyright (C) 2013 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.
-*/
-
-#ifndef MAIN_HEADER
-#define MAIN_HEADER
-
-#include <string>
-
-// Settings
-class Settings;
-extern Settings *g_settings;
-extern std::string g_settings_path;
-
-// Global profiler
-class Profiler;
-extern Profiler *g_profiler;
-
-// Menu clouds
-class Clouds;
-extern Clouds *g_menuclouds;
-
-// Scene manager used for menu clouds
-namespace irr{namespace scene{class ISceneManager;}}
-extern irr::scene::ISceneManager *g_menucloudsmgr;
-
-// Debug streams
-
-#include <fstream>
-
-extern std::ostream *dout_con_ptr;
-extern std::ostream *derr_con_ptr;
-extern std::ostream *dout_client_ptr;
-extern std::ostream *derr_client_ptr;
-extern std::ostream *dout_server_ptr;
-extern std::ostream *derr_server_ptr;
-
-#define dout_con (*dout_con_ptr)
-#define derr_con (*derr_con_ptr)
-#define dout_client (*dout_client_ptr)
-#define derr_client (*derr_client_ptr)
-#define dout_server (*dout_server_ptr)
-#define derr_server (*derr_server_ptr)
-
-#endif
-
index b14ca56e51c84f912d33a82603a2f000c375c8ae..6f8aa91376ffcf8a350eea80f42b04f212bdc4c0 100644 (file)
@@ -39,7 +39,7 @@ public:
        virtual void signalKeyConfigChange() = 0;
 };
 
-extern gui::IGUIEnvironmentguienv;
+extern gui::IGUIEnvironment *guienv;
 extern gui::IGUIStaticText *guiroot;
 
 // Handler for the modal menus
index 899c80b272314ded8ce5e5ca4774a22b398b5ddc..9fead00c6d40436b107f0249b6acb51721046517 100644 (file)
@@ -20,7 +20,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "map.h"
 #include "mapsector.h"
 #include "mapblock.h"
-#include "main.h"
 #include "filesys.h"
 #include "voxel.h"
 #include "porting.h"
index d1637891a7b9143d2bb1f6038d4281aa2b500aac..ab4b63f864aa06beffce28946dd35b2406a0f759 100644 (file)
@@ -21,7 +21,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "light.h"
 #include "mapblock.h"
 #include "map.h"
-#include "main.h" // for g_profiler
 #include "profiler.h"
 #include "nodedef.h"
 #include "gamedef.h"
index fcde5bdb8cc75dbccaeff8e50f0e007f481ff09a..66937fb53be6ba692c591bdcaca1c0d1664660ff 100644 (file)
@@ -31,8 +31,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "content_mapnode.h" // For content_mapnode_get_new_name
 #include "voxelalgorithms.h"
 #include "profiler.h"
-#include "settings.h" // For g_settings
-#include "main.h" // For g_profiler
+#include "settings.h"
 #include "treegen.h"
 #include "serialization.h"
 #include "util/serialize.h"
index 7d74c80bddc5f25b9fe3e39ae622a0b80a80ea62..59578eb4980bbe7deb37d83a5bea664e90fae84d 100644 (file)
@@ -29,7 +29,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "voxelalgorithms.h"
 #include "profiler.h"
 #include "settings.h" // For g_settings
-#include "main.h" // For g_profiler
 #include "emerge.h"
 #include "dungeongen.h"
 #include "cavegen.h"
index 8885c71e53f45d8d8171f7d1ab69630dc73527b1..612ea82b4b7d1e0768b5ac8096ac65209b79cec1 100644 (file)
@@ -30,7 +30,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "voxelalgorithms.h"
 #include "profiler.h"
 #include "settings.h" // For g_settings
-#include "main.h" // For g_profiler
 #include "emerge.h"
 #include "dungeongen.h"
 #include "cavegen.h"
index 3e7188a2c9d11847b2d9ceaa3deb1704c6dd7600..f370a0fdbf5d02a8461a05017f1b22c2c8d7af5e 100644 (file)
@@ -29,7 +29,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "voxelalgorithms.h"
 #include "profiler.h"
 #include "settings.h" // For g_settings
-#include "main.h" // For g_profiler
 #include "emerge.h"
 #include "dungeongen.h"
 #include "cavegen.h"
index 0335755e99a5345c1c97d3562d300b7d4b758334..4afa91983b19917b8f2db9d7888f7838ce45dc52 100644 (file)
@@ -20,7 +20,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "irrlichttypes_extrabloated.h"
 #include "mapnode.h"
 #include "porting.h"
-#include "main.h" // For g_settings
 #include "nodedef.h"
 #include "content_mapnode.h" // For mapnode_translate_*_internal
 #include "serialization.h" // For ser_ver_supported
index a8b150e53c94499d34b78bce2fc5c870691b442b..75334544a66341a3b4c12b0e976a28ec6e2140e0 100644 (file)
@@ -23,7 +23,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "map.h" //for MMVManip
 #include "log.h"
 #include "util/numeric.h"
-#include "main.h"
 #include "util/mathconstants.h"
 #include "porting.h"
 
index cb5a6b9fd265ff6fd8a42f6359d9747731bf07c8..a81dd46045d48fdc7d66ce6875052f9fd451723a 100644 (file)
@@ -17,15 +17,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
 
+#include <cctype>
+#include <fstream>
 #include "mods.h"
-#include "main.h"
 #include "filesys.h"
 #include "strfnd.h"
 #include "log.h"
 #include "subgame.h"
 #include "settings.h"
 #include "strfnd.h"
-#include <cctype>
 #include "convert_json.h"
 
 static bool parseDependsLine(std::istream &is,
index dd69df5bbf46d1527522a58ecf3f8937baec3508..6e8bbd6c3a4cc4e8bfcab3415d8377220ae49e9c 100644 (file)
@@ -20,7 +20,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include <iomanip>
 #include <errno.h>
 #include "connection.h"
-#include "main.h"
 #include "serialization.h"
 #include "log.h"
 #include "porting.h"
index e01aeaa55e0d36b2058f884528a6be84fb533dae..30b378ac31ba060e480164cf01b125ea06608426 100644 (file)
@@ -23,7 +23,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "content_abm.h"
 #include "content_sao.h"
 #include "emerge.h"
-#include "main.h"
 #include "nodedef.h"
 #include "player.h"
 #include "rollback_interface.h"
index ce087f6b8a99f85a2c396404c177a71203ad41f8..486a993507a68870734cfdc98058ddf531fa54d8 100644 (file)
@@ -19,7 +19,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 #include "nodedef.h"
 
-#include "main.h" // For g_settings
 #include "itemdef.h"
 #ifndef SERVER
 #include "client/tile.h"
index e9268be27c1c1847e4fbeb5b5dc81e9ef0a57bcb..b13e904b0d98b8356b5a00b6d7e22a815cf664bb 100644 (file)
@@ -20,7 +20,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "particles.h"
 #include "constants.h"
 #include "debug.h"
-#include "main.h" // For g_profiler and g_settings
 #include "settings.h"
 #include "client/tile.h"
 #include "gamedef.h"
index 797a2cf39e846a9ed5e7ab446d37f4f356523d83..86d5bf5da73bb74c6316aa457c6d336a08bfad23 100644 (file)
@@ -51,7 +51,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "filesys.h"
 #include "log.h"
 #include "util/string.h"
-#include "main.h"
 #include "settings.h"
 #include <list>
 
diff --git a/src/profiler.cpp b/src/profiler.cpp
new file mode 100644 (file)
index 0000000..197e094
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+Minetest
+Copyright (C) 2015 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 "profiler.h"
+
+static Profiler main_profiler;
+Profiler *g_profiler = &main_profiler;
index e5bb760c6dcbecc349dc605241f1a2a59766e0cc..78d3b08e06493052362b3d443d946e72d7832a23 100644 (file)
@@ -27,11 +27,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "jthread/jmutex.h"
 #include "jthread/jmutexautolock.h"
 #include "util/timetaker.h"
-#include "util/numeric.h" // paging()
-#include "debug.h" // assert()
+#include "util/numeric.h"      // paging()
+#include "debug.h"             // assert()
 
 #define MAX_PROFILER_TEXT_ROWS 20
 
+// Global profiler
+class Profiler;
+extern Profiler *g_profiler;
+
 /*
        Time profiler
 */
index 61248534cf9594f3d48481f42be84297c5f77fca..fcab98dc6c773fde1d212b96003e4b21c75e4e92 100644 (file)
@@ -20,7 +20,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "common/c_internal.h"
 #include "debug.h"
 #include "log.h"
-#include "main.h"
 #include "settings.h"
 
 std::string script_get_backtrace(lua_State *L)
index 5936ac046dbb86da222c7a38585047495cf209c7..e8a029b868ab63c68ab5bb39d6e8d70b55646349 100644 (file)
@@ -36,7 +36,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #if (defined(WIN32) || defined(_WIN32_WCE))
 #define NO_MAP_LOCK_REQUIRED
 #else
-#include "main.h"
 #include "profiler.h"
 #define NO_MAP_LOCK_REQUIRED \
        ScopeProfiler nolocktime(g_profiler,"Scriptapi: unlockable time",SPT_ADD)
index 2ad6ba360defba59cb8d5ab955dd12b3c523c6b4..b068040db67cdd9452c797002ef73d2ef0369c8c 100644 (file)
@@ -34,7 +34,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "emerge.h"
 #include "sound.h"
 #include "settings.h"
-#include "main.h" // for g_settings
 #include "log.h"
 #include "EDriverTypes.h"
 
index ed0eaaaac14e8c6fa5f9f42e90aaf9ae0ecd2ed0..cbe3610c807851696b7a69cb0df3d8907eec3f12 100644 (file)
@@ -33,7 +33,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "mapgen_v5.h"
 #include "mapgen_v7.h"
 #include "settings.h"
-#include "main.h"
 #include "log.h"
 
 
index eb6c1835d80acd18e3ffa545c55eecf78c6ad4eb..79a5b252a4552106d6cba9bdf7bd2c6dec3ca2e6 100644 (file)
@@ -30,7 +30,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "tool.h"
 #include "filesys.h"
 #include "settings.h"
-#include "main.h"  //required for g_settings, g_settings_path
 
 // debug(...)
 // Writes a line to dstream
index 144d933b17c57f8156e46366ad624e1e19c0f4dd..a57d1f1aac99ddad8aca1117d30e5b1c2facef6b 100644 (file)
@@ -27,7 +27,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "environment.h"
 #include "map.h"
 #include "jthread/jmutexautolock.h"
-#include "main.h"
 #include "constants.h"
 #include "voxel.h"
 #include "config.h"
index 978175a2a4665e3efb4ee2474da914481076e017..a33d1d6bfeeef60661849345b3e56d34b553834b 100644 (file)
@@ -17,12 +17,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
 
+#include <fstream>
 #include <iostream>
 #include <sstream>
 #include <algorithm>
 
 #include "version.h"
-#include "main.h" // for g_settings
 #include "settings.h"
 #include "serverlist.h"
 #include "filesys.h"
index c1d70714fb75fb6e8011b0f75d54fb90c2e575bd..9adcd158785daf51f73c415c42b54f780f3db8b0 100644 (file)
@@ -33,6 +33,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include <cctype>
 #include <algorithm>
 
+static Settings main_settings;
+Settings *g_settings = &main_settings;
+std::string g_settings_path;
 
 Settings::~Settings()
 {
index 48708f6cc4602e95a2ccbc2eb061690ed21798a5..d43ad6a205e28c75a23f7e11449b679db32385d5 100644 (file)
@@ -31,6 +31,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 class Settings;
 struct NoiseParams;
 
+// Global objects
+extern Settings *g_settings;
+extern std::string g_settings_path;
+
 /** function type to register a changed callback */
 typedef void (*setting_changed_callback)(const std::string, void*);
 
index 8a5fd417b658c7f683d48f1c5bf00c50faf3856e..ea2de3f1e85e4bfe4010bd5af646341d668bdf36 100644 (file)
@@ -18,15 +18,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
 
+#include <fstream>
+#include <iterator>
 #include "shader.h"
 #include "irrlichttypes_extrabloated.h"
 #include "debug.h"
-#include "main.h" // for g_settings
 #include "filesys.h"
 #include "util/container.h"
 #include "util/thread.h"
 #include "settings.h"
-#include <iterator>
 #include <ICameraSceneNode.h>
 #include <IGPUProgrammingServices.h>
 #include <IMaterialRenderer.h>
index e4060291415c1ebbde88a21c04809f87aad08240..01fb8ef860ed140e5d434d59139727c8ddbd71d8 100644 (file)
@@ -4,13 +4,12 @@
 #include "ICameraSceneNode.h"
 #include "S3DVertex.h"
 #include "client/tile.h"
-#include "noise.h" // easeCurve
-#include "main.h" // g_profiler
+#include "noise.h"            // easeCurve
 #include "profiler.h"
-#include "util/numeric.h" // MYMIN
+#include "util/numeric.h"
 #include <cmath>
 #include "settings.h"
-#include "camera.h" // CameraModes
+#include "camera.h"           // CameraModes
 
 //! constructor
 Sky::Sky(scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id,
index df9c57c5f9223a06d511e83e2b2e1551ebd706dd..c3b5fc564534b43165fd45e9c68437a5a8d2915e 100644 (file)
@@ -32,7 +32,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "debug.h"
 #include "settings.h"
 #include "log.h"
-#include "main.h" // for g_settings
 
 #ifdef _WIN32
        #ifndef WIN32_LEAN_AND_MEAN
index 864732876049c9206ebb4de7229e57cd8a075a1d..f736a78c63058bbd59659206d2d67da70bd7a698 100644 (file)
@@ -21,16 +21,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "porting.h"
 #include "filesys.h"
 #include "settings.h"
-#include "main.h"
 #include "log.h"
 #include "strfnd.h"
 #include "defaultsettings.h"  // for override_default_settings
 #include "mapgen.h"  // for MapgenParams
-#include "main.h" // for g_settings
+#include "util/string.h"
+
 #ifndef SERVER
-#include "client/tile.h" // getImagePath
+       #include "client/tile.h" // getImagePath
 #endif
-#include "util/string.h"
 
 bool getGameMinetestConfig(const std::string &game_path, Settings &conf)
 {
index 25809327802b8d0061b978562d3a43c0895a8ed2..402bae95cb33277813d3d1e5e75134f281db0a75 100644 (file)
@@ -22,7 +22,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "debug.h"
 #include "map.h"
 #include "player.h"
-#include "main.h"
 #include "socket.h"
 #include "network/connection.h"
 #include "serialization.h"
index 23310ef270b1395636fa73916f51ffafaa1b7c49..b1d82b706edc4dcb4061052447175a2953b49269 100644 (file)
@@ -17,7 +17,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
 
-#include "main.h"
 #include "settings.h"
 #include "wieldmesh.h"
 #include "inventory.h"