Move globals from main.cpp to more sane locations

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
This commit is contained in:
Craig Robbins 2015-04-01 23:01:28 +10:00
parent 113bdd3ec0
commit 9527984dbc
72 changed files with 120 additions and 194 deletions

@ -183,6 +183,7 @@ LOCAL_SRC_FILES := \
jni/src/player.cpp \ jni/src/player.cpp \
jni/src/porting_android.cpp \ jni/src/porting_android.cpp \
jni/src/porting.cpp \ jni/src/porting.cpp \
jni/src/profiler.cpp \
jni/src/quicktune.cpp \ jni/src/quicktune.cpp \
jni/src/rollback.cpp \ jni/src/rollback.cpp \
jni/src/rollback_interface.cpp \ jni/src/rollback_interface.cpp \

@ -329,6 +329,7 @@ set(common_SRCS
pathfinder.cpp pathfinder.cpp
player.cpp player.cpp
porting.cpp porting.cpp
profiler.cpp
quicktune.cpp quicktune.cpp
rollback.cpp rollback.cpp
rollback_interface.cpp rollback_interface.cpp

@ -20,7 +20,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "camera.h" #include "camera.h"
#include "debug.h" #include "debug.h"
#include "client.h" #include "client.h"
#include "main.h" // for g_settings
#include "map.h" #include "map.h"
#include "clientmap.h" // MapDrawControl #include "clientmap.h" // MapDrawControl
#include "player.h" #include "player.h"

@ -28,7 +28,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "util/string.h" #include "util/string.h"
#include "client.h" #include "client.h"
#include "network/clientopcodes.h" #include "network/clientopcodes.h"
#include "main.h"
#include "filesys.h" #include "filesys.h"
#include "porting.h" #include "porting.h"
#include "mapblock_mesh.h" #include "mapblock_mesh.h"

@ -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. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#include "main.h"
#include "mainmenumanager.h" #include "mainmenumanager.h"
#include "debug.h" #include "debug.h"
#include "clouds.h" #include "clouds.h"
@ -35,9 +34,23 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "fontengine.h" #include "fontengine.h"
#include "clientlauncher.h" #include "clientlauncher.h"
// A pointer to a global instance of the time getter /* mainmenumanager.h
// TODO: why? */
TimeGetter *g_timegetter = NULL; 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() u32 getTimeMs()
{ {

@ -26,7 +26,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "util/numeric.h" #include "util/numeric.h"
#include "irrlichttypes_extrabloated.h" #include "irrlichttypes_extrabloated.h"
#include "debug.h" #include "debug.h"
#include "main.h" // for g_settings
#include "filesys.h" #include "filesys.h"
#include "settings.h" #include "settings.h"
#include "mesh.h" #include "mesh.h"

@ -30,7 +30,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "map.h" #include "map.h"
#include "emerge.h" #include "emerge.h"
#include "serverobject.h" // TODO this is used for cleanup of only #include "serverobject.h" // TODO this is used for cleanup of only
#include "main.h" // for g_settings
#include "log.h" #include "log.h"
const char *ClientInterface::statenames[] = { const char *ClientInterface::statenames[] = {

@ -24,7 +24,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <matrix4.h> #include <matrix4.h>
#include "log.h" #include "log.h"
#include "mapsector.h" #include "mapsector.h"
#include "main.h" // dout_client, g_settings
#include "nodedef.h" #include "nodedef.h"
#include "mapblock.h" #include "mapblock.h"
#include "profiler.h" #include "profiler.h"

@ -26,7 +26,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "log.h" #include "log.h"
#include "porting.h" #include "porting.h"
#include "settings.h" #include "settings.h"
#include "main.h"
#include "network/networkprotocol.h" #include "network/networkprotocol.h"
#include "util/hex.h" #include "util/hex.h"
#include "util/serialize.h" #include "util/serialize.h"

@ -21,10 +21,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "noise.h" #include "noise.h"
#include "constants.h" #include "constants.h"
#include "debug.h" #include "debug.h"
#include "main.h" // For g_profiler and g_settings
#include "profiler.h" #include "profiler.h"
#include "settings.h" #include "settings.h"
// Menu clouds are created later
class Clouds;
Clouds *g_menuclouds = NULL;
irr::scene::ISceneManager *g_menucloudsmgr = NULL;
Clouds::Clouds( Clouds::Clouds(
scene::ISceneNode* parent, scene::ISceneNode* parent,
scene::ISceneManager* mgr, scene::ISceneManager* mgr,

@ -24,6 +24,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <iostream> #include <iostream>
#include "constants.h" #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 class Clouds : public scene::ISceneNode
{ {
public: public:

@ -28,7 +28,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <vector> #include <vector>
#include <set> #include <set>
#include "util/timetaker.h" #include "util/timetaker.h"
#include "main.h" // g_profiler
#include "profiler.h" #include "profiler.h"
// float error is 10 - 9.96875 = 0.03125 // float error is 10 - 9.96875 = 0.03125

@ -25,7 +25,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "content_sao.h" #include "content_sao.h"
#include "settings.h" #include "settings.h"
#include "mapblock.h" // For getNodeBlockPos #include "mapblock.h" // For getNodeBlockPos
#include "main.h" // for g_settings
#include "map.h" #include "map.h"
#include "scripting_game.h" #include "scripting_game.h"
#include "log.h" #include "log.h"

@ -42,7 +42,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "nodedef.h" #include "nodedef.h"
#include "localplayer.h" #include "localplayer.h"
#include "map.h" #include "map.h"
#include "main.h" // g_settings
#include "camera.h" // CameraModes #include "camera.h" // CameraModes
#include "wieldmesh.h" #include "wieldmesh.h"
#include "log.h" #include "log.h"

@ -20,7 +20,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "content_mapblock.h" #include "content_mapblock.h"
#include "util/numeric.h" #include "util/numeric.h"
#include "util/directiontables.h" #include "util/directiontables.h"
#include "main.h" // For g_settings
#include "mapblock_mesh.h" // For MapBlock_LightColor() and MeshCollector #include "mapblock_mesh.h" // For MapBlock_LightColor() and MeshCollector
#include "settings.h" #include "settings.h"
#include "nodedef.h" #include "nodedef.h"

@ -23,7 +23,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "collision.h" #include "collision.h"
#include "environment.h" #include "environment.h"
#include "settings.h" #include "settings.h"
#include "main.h" // For g_profiler
#include "profiler.h" #include "profiler.h"
#include "serialization.h" // For compressZlib #include "serialization.h" // For compressZlib
#include "tool.h" // For ToolCapabilities #include "tool.h" // For ToolCapabilities

@ -25,7 +25,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "mods.h" #include "mods.h"
#include "config.h" #include "config.h"
#include "log.h" #include "log.h"
#include "main.h" // for g_settings
#include "settings.h" #include "settings.h"
#include "httpfetch.h" #include "httpfetch.h"
#include "porting.h" #include "porting.h"

@ -30,7 +30,6 @@ SQLite format specification:
#include "log.h" #include "log.h"
#include "filesys.h" #include "filesys.h"
#include "exceptions.h" #include "exceptions.h"
#include "main.h"
#include "settings.h" #include "settings.h"
#include "util/string.h" #include "util/string.h"

@ -18,7 +18,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/ */
#include "drawscene.h" #include "drawscene.h"
#include "main.h" // for g_settings
#include "settings.h" #include "settings.h"
#include "clouds.h" #include "clouds.h"
#include "clientmap.h" #include "clientmap.h"

@ -26,8 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "map.h" #include "map.h"
#include "nodedef.h" #include "nodedef.h"
#include "profiler.h" #include "profiler.h"
#include "settings.h" // For g_settings #include "settings.h"
#include "main.h" // For g_profiler
//#define DGEN_USE_TORCHES //#define DGEN_USE_TORCHES

@ -28,7 +28,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "environment.h" #include "environment.h"
#include "util/container.h" #include "util/container.h"
#include "util/thread.h" #include "util/thread.h"
#include "main.h"
#include "constants.h" #include "constants.h"
#include "voxel.h" #include "voxel.h"
#include "config.h" #include "config.h"

@ -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. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#include <fstream>
#include "environment.h" #include "environment.h"
#include "filesys.h" #include "filesys.h"
#include "porting.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 "scripting_game.h"
#include "nodedef.h" #include "nodedef.h"
#include "nodemetadata.h" #include "nodemetadata.h"
#include "main.h" // For g_settings, g_profiler
#include "gamedef.h" #include "gamedef.h"
#ifndef SERVER #ifndef SERVER
#include "clientmap.h" #include "clientmap.h"

@ -18,7 +18,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/ */
#include "fontengine.h" #include "fontengine.h"
#include "log.h" #include "log.h"
#include "main.h"
#include "config.h" #include "config.h"
#include "porting.h" #include "porting.h"
#include "constants.h" #include "constants.h"

@ -24,7 +24,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "gettime.h" #include "gettime.h"
#include "keycode.h" #include "keycode.h"
#include "settings.h" #include "settings.h"
#include "main.h" // for g_settings
#include "porting.h" #include "porting.h"
#include "client/tile.h" #include "client/tile.h"
#include "fontengine.h" #include "fontengine.h"

@ -19,6 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "guiEngine.h" #include "guiEngine.h"
#include <fstream>
#include <IGUIStaticText.h> #include <IGUIStaticText.h>
#include <ICameraSceneNode.h> #include <ICameraSceneNode.h>
#include "scripting_mainmenu.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 "version.h"
#include "porting.h" #include "porting.h"
#include "filesys.h" #include "filesys.h"
#include "main.h"
#include "settings.h" #include "settings.h"
#include "guiMainMenu.h" #include "guiMainMenu.h"
#include "sound.h" #include "sound.h"

@ -44,7 +44,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "gettext.h" #include "gettext.h"
#include "scripting_game.h" #include "scripting_game.h"
#include "porting.h" #include "porting.h"
#include "main.h"
#include "settings.h" #include "settings.h"
#include "client.h" #include "client.h"
#include "fontengine.h" #include "fontengine.h"

@ -22,7 +22,6 @@
#include "guiKeyChangeMenu.h" #include "guiKeyChangeMenu.h"
#include "debug.h" #include "debug.h"
#include "serialization.h" #include "serialization.h"
#include "main.h"
#include <string> #include <string>
#include <IGUICheckBox.h> #include <IGUICheckBox.h>
#include <IGUIEditBox.h> #include <IGUIEditBox.h>

@ -33,7 +33,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "util/string.h" #include "util/string.h"
#include "util/numeric.h" #include "util/numeric.h"
#include "util/string.h" // for parseColorString() #include "util/string.h" // for parseColorString()
#include "main.h"
#include "settings.h" // for settings #include "settings.h" // for settings
#include "porting.h" // for dpi #include "porting.h" // for dpi
#include "guiscalingfilter.h" #include "guiscalingfilter.h"

@ -26,7 +26,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <IGUIScrollBar.h> #include <IGUIScrollBar.h>
#include <IGUIStaticText.h> #include <IGUIStaticText.h>
#include <IGUIFont.h> #include <IGUIFont.h>
#include "main.h"
#include "settings.h" #include "settings.h"
#include "gettext.h" #include "gettext.h"

@ -19,7 +19,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "guiscalingfilter.h" #include "guiscalingfilter.h"
#include "imagefilters.h" #include "imagefilters.h"
#include "settings.h" #include "settings.h"
#include "main.h" // for g_settings
#include "util/numeric.h" #include "util/numeric.h"
#include <stdio.h> #include <stdio.h>

@ -33,7 +33,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "util/container.h" #include "util/container.h"
#include "util/thread.h" #include "util/thread.h"
#include "version.h" #include "version.h"
#include "main.h"
#include "settings.h" #include "settings.h"
JMutex g_httpfetch_mutex; JMutex g_httpfetch_mutex;

@ -20,7 +20,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/ */
#include "hud.h" #include "hud.h"
#include "main.h"
#include "settings.h" #include "settings.h"
#include "util/numeric.h" #include "util/numeric.h"
#include "log.h" #include "log.h"

@ -22,7 +22,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "environment.h" #include "environment.h"
#include "scripting_game.h" #include "scripting_game.h"
#include "serverobject.h" #include "serverobject.h"
#include "main.h" // for g_settings
#include "settings.h" #include "settings.h"
#include "craftdef.h" #include "craftdef.h"
#include "rollback_interface.h" #include "rollback_interface.h"

@ -31,7 +31,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "client/tile.h" #include "client/tile.h"
#endif #endif
#include "log.h" #include "log.h"
#include "main.h" // g_settings
#include "settings.h" #include "settings.h"
#include "util/serialize.h" #include "util/serialize.h"
#include "util/container.h" #include "util/container.h"

@ -18,7 +18,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/ */
#include "keycode.h" #include "keycode.h"
#include "main.h" // For g_settings
#include "exceptions.h" #include "exceptions.h"
#include "settings.h" #include "settings.h"
#include "log.h" #include "log.h"

@ -19,7 +19,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "localplayer.h" #include "localplayer.h"
#include "main.h" // For g_settings
#include "event.h" #include "event.h"
#include "collision.h" #include "collision.h"
#include "gamedef.h" #include "gamedef.h"

@ -30,6 +30,20 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "porting.h" #include "porting.h"
#include "config.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__ #ifdef __ANDROID__
unsigned int android_log_level_mapping[] = { unsigned int android_log_level_mapping[] = {
/* LMT_ERROR */ ANDROID_LOG_ERROR, /* LMT_ERROR */ ANDROID_LOG_ERROR,

@ -81,5 +81,22 @@ extern bool log_trace_level_enabled;
#define TRACESTREAM(x){ if(log_trace_level_enabled) verbosestream x; } #define TRACESTREAM(x){ if(log_trace_level_enabled) verbosestream x; }
#define TRACEDO(x){ if(log_trace_level_enabled){ 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 #endif

@ -29,7 +29,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "irrlicht.h" // createDevice #include "irrlicht.h" // createDevice
#include "main.h"
#include "mainmenumanager.h" #include "mainmenumanager.h"
#include "irrlichttypes_extrabloated.h" #include "irrlichttypes_extrabloated.h"
#include "debug.h" #include "debug.h"
@ -59,38 +58,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "touchscreengui.h" #include "touchscreengui.h"
#endif #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 DEBUGFILE "debug.txt"
#define DEFAULT_SERVER_PORT 30000 #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 gettime.h implementation
*/ */

@ -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

@ -20,7 +20,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "map.h" #include "map.h"
#include "mapsector.h" #include "mapsector.h"
#include "mapblock.h" #include "mapblock.h"
#include "main.h"
#include "filesys.h" #include "filesys.h"
#include "voxel.h" #include "voxel.h"
#include "porting.h" #include "porting.h"

@ -21,7 +21,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "light.h" #include "light.h"
#include "mapblock.h" #include "mapblock.h"
#include "map.h" #include "map.h"
#include "main.h" // for g_profiler
#include "profiler.h" #include "profiler.h"
#include "nodedef.h" #include "nodedef.h"
#include "gamedef.h" #include "gamedef.h"

@ -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 "content_mapnode.h" // For content_mapnode_get_new_name
#include "voxelalgorithms.h" #include "voxelalgorithms.h"
#include "profiler.h" #include "profiler.h"
#include "settings.h" // For g_settings #include "settings.h"
#include "main.h" // For g_profiler
#include "treegen.h" #include "treegen.h"
#include "serialization.h" #include "serialization.h"
#include "util/serialize.h" #include "util/serialize.h"

@ -29,7 +29,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "voxelalgorithms.h" #include "voxelalgorithms.h"
#include "profiler.h" #include "profiler.h"
#include "settings.h" // For g_settings #include "settings.h" // For g_settings
#include "main.h" // For g_profiler
#include "emerge.h" #include "emerge.h"
#include "dungeongen.h" #include "dungeongen.h"
#include "cavegen.h" #include "cavegen.h"

@ -30,7 +30,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "voxelalgorithms.h" #include "voxelalgorithms.h"
#include "profiler.h" #include "profiler.h"
#include "settings.h" // For g_settings #include "settings.h" // For g_settings
#include "main.h" // For g_profiler
#include "emerge.h" #include "emerge.h"
#include "dungeongen.h" #include "dungeongen.h"
#include "cavegen.h" #include "cavegen.h"

@ -29,7 +29,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "voxelalgorithms.h" #include "voxelalgorithms.h"
#include "profiler.h" #include "profiler.h"
#include "settings.h" // For g_settings #include "settings.h" // For g_settings
#include "main.h" // For g_profiler
#include "emerge.h" #include "emerge.h"
#include "dungeongen.h" #include "dungeongen.h"
#include "cavegen.h" #include "cavegen.h"

@ -20,7 +20,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "irrlichttypes_extrabloated.h" #include "irrlichttypes_extrabloated.h"
#include "mapnode.h" #include "mapnode.h"
#include "porting.h" #include "porting.h"
#include "main.h" // For g_settings
#include "nodedef.h" #include "nodedef.h"
#include "content_mapnode.h" // For mapnode_translate_*_internal #include "content_mapnode.h" // For mapnode_translate_*_internal
#include "serialization.h" // For ser_ver_supported #include "serialization.h" // For ser_ver_supported

@ -23,7 +23,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "map.h" //for MMVManip #include "map.h" //for MMVManip
#include "log.h" #include "log.h"
#include "util/numeric.h" #include "util/numeric.h"
#include "main.h"
#include "util/mathconstants.h" #include "util/mathconstants.h"
#include "porting.h" #include "porting.h"

@ -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. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#include <cctype>
#include <fstream>
#include "mods.h" #include "mods.h"
#include "main.h"
#include "filesys.h" #include "filesys.h"
#include "strfnd.h" #include "strfnd.h"
#include "log.h" #include "log.h"
#include "subgame.h" #include "subgame.h"
#include "settings.h" #include "settings.h"
#include "strfnd.h" #include "strfnd.h"
#include <cctype>
#include "convert_json.h" #include "convert_json.h"
static bool parseDependsLine(std::istream &is, static bool parseDependsLine(std::istream &is,

@ -20,7 +20,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <iomanip> #include <iomanip>
#include <errno.h> #include <errno.h>
#include "connection.h" #include "connection.h"
#include "main.h"
#include "serialization.h" #include "serialization.h"
#include "log.h" #include "log.h"
#include "porting.h" #include "porting.h"

@ -23,7 +23,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "content_abm.h" #include "content_abm.h"
#include "content_sao.h" #include "content_sao.h"
#include "emerge.h" #include "emerge.h"
#include "main.h"
#include "nodedef.h" #include "nodedef.h"
#include "player.h" #include "player.h"
#include "rollback_interface.h" #include "rollback_interface.h"

@ -19,7 +19,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "nodedef.h" #include "nodedef.h"
#include "main.h" // For g_settings
#include "itemdef.h" #include "itemdef.h"
#ifndef SERVER #ifndef SERVER
#include "client/tile.h" #include "client/tile.h"

@ -20,7 +20,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "particles.h" #include "particles.h"
#include "constants.h" #include "constants.h"
#include "debug.h" #include "debug.h"
#include "main.h" // For g_profiler and g_settings
#include "settings.h" #include "settings.h"
#include "client/tile.h" #include "client/tile.h"
#include "gamedef.h" #include "gamedef.h"

@ -51,7 +51,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "filesys.h" #include "filesys.h"
#include "log.h" #include "log.h"
#include "util/string.h" #include "util/string.h"
#include "main.h"
#include "settings.h" #include "settings.h"
#include <list> #include <list>

23
src/profiler.cpp Normal file

@ -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;

@ -32,6 +32,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define MAX_PROFILER_TEXT_ROWS 20 #define MAX_PROFILER_TEXT_ROWS 20
// Global profiler
class Profiler;
extern Profiler *g_profiler;
/* /*
Time profiler Time profiler
*/ */

@ -20,7 +20,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "common/c_internal.h" #include "common/c_internal.h"
#include "debug.h" #include "debug.h"
#include "log.h" #include "log.h"
#include "main.h"
#include "settings.h" #include "settings.h"
std::string script_get_backtrace(lua_State *L) std::string script_get_backtrace(lua_State *L)

@ -36,7 +36,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#if (defined(WIN32) || defined(_WIN32_WCE)) #if (defined(WIN32) || defined(_WIN32_WCE))
#define NO_MAP_LOCK_REQUIRED #define NO_MAP_LOCK_REQUIRED
#else #else
#include "main.h"
#include "profiler.h" #include "profiler.h"
#define NO_MAP_LOCK_REQUIRED \ #define NO_MAP_LOCK_REQUIRED \
ScopeProfiler nolocktime(g_profiler,"Scriptapi: unlockable time",SPT_ADD) ScopeProfiler nolocktime(g_profiler,"Scriptapi: unlockable time",SPT_ADD)

@ -34,7 +34,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "emerge.h" #include "emerge.h"
#include "sound.h" #include "sound.h"
#include "settings.h" #include "settings.h"
#include "main.h" // for g_settings
#include "log.h" #include "log.h"
#include "EDriverTypes.h" #include "EDriverTypes.h"

@ -33,7 +33,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "mapgen_v5.h" #include "mapgen_v5.h"
#include "mapgen_v7.h" #include "mapgen_v7.h"
#include "settings.h" #include "settings.h"
#include "main.h"
#include "log.h" #include "log.h"

@ -30,7 +30,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "tool.h" #include "tool.h"
#include "filesys.h" #include "filesys.h"
#include "settings.h" #include "settings.h"
#include "main.h" //required for g_settings, g_settings_path
// debug(...) // debug(...)
// Writes a line to dstream // Writes a line to dstream

@ -27,7 +27,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "environment.h" #include "environment.h"
#include "map.h" #include "map.h"
#include "jthread/jmutexautolock.h" #include "jthread/jmutexautolock.h"
#include "main.h"
#include "constants.h" #include "constants.h"
#include "voxel.h" #include "voxel.h"
#include "config.h" #include "config.h"

@ -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. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#include <fstream>
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <algorithm> #include <algorithm>
#include "version.h" #include "version.h"
#include "main.h" // for g_settings
#include "settings.h" #include "settings.h"
#include "serverlist.h" #include "serverlist.h"
#include "filesys.h" #include "filesys.h"

@ -33,6 +33,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <cctype> #include <cctype>
#include <algorithm> #include <algorithm>
static Settings main_settings;
Settings *g_settings = &main_settings;
std::string g_settings_path;
Settings::~Settings() Settings::~Settings()
{ {

@ -31,6 +31,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
class Settings; class Settings;
struct NoiseParams; struct NoiseParams;
// Global objects
extern Settings *g_settings;
extern std::string g_settings_path;
/** function type to register a changed callback */ /** function type to register a changed callback */
typedef void (*setting_changed_callback)(const std::string, void*); typedef void (*setting_changed_callback)(const std::string, void*);

@ -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. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#include <fstream>
#include <iterator>
#include "shader.h" #include "shader.h"
#include "irrlichttypes_extrabloated.h" #include "irrlichttypes_extrabloated.h"
#include "debug.h" #include "debug.h"
#include "main.h" // for g_settings
#include "filesys.h" #include "filesys.h"
#include "util/container.h" #include "util/container.h"
#include "util/thread.h" #include "util/thread.h"
#include "settings.h" #include "settings.h"
#include <iterator>
#include <ICameraSceneNode.h> #include <ICameraSceneNode.h>
#include <IGPUProgrammingServices.h> #include <IGPUProgrammingServices.h>
#include <IMaterialRenderer.h> #include <IMaterialRenderer.h>

@ -5,9 +5,8 @@
#include "S3DVertex.h" #include "S3DVertex.h"
#include "client/tile.h" #include "client/tile.h"
#include "noise.h" // easeCurve #include "noise.h" // easeCurve
#include "main.h" // g_profiler
#include "profiler.h" #include "profiler.h"
#include "util/numeric.h" // MYMIN #include "util/numeric.h"
#include <cmath> #include <cmath>
#include "settings.h" #include "settings.h"
#include "camera.h" // CameraModes #include "camera.h" // CameraModes

@ -32,7 +32,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "debug.h" #include "debug.h"
#include "settings.h" #include "settings.h"
#include "log.h" #include "log.h"
#include "main.h" // for g_settings
#ifdef _WIN32 #ifdef _WIN32
#ifndef WIN32_LEAN_AND_MEAN #ifndef WIN32_LEAN_AND_MEAN

@ -21,16 +21,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "porting.h" #include "porting.h"
#include "filesys.h" #include "filesys.h"
#include "settings.h" #include "settings.h"
#include "main.h"
#include "log.h" #include "log.h"
#include "strfnd.h" #include "strfnd.h"
#include "defaultsettings.h" // for override_default_settings #include "defaultsettings.h" // for override_default_settings
#include "mapgen.h" // for MapgenParams #include "mapgen.h" // for MapgenParams
#include "main.h" // for g_settings #include "util/string.h"
#ifndef SERVER #ifndef SERVER
#include "client/tile.h" // getImagePath #include "client/tile.h" // getImagePath
#endif #endif
#include "util/string.h"
bool getGameMinetestConfig(const std::string &game_path, Settings &conf) bool getGameMinetestConfig(const std::string &game_path, Settings &conf)
{ {

@ -22,7 +22,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "debug.h" #include "debug.h"
#include "map.h" #include "map.h"
#include "player.h" #include "player.h"
#include "main.h"
#include "socket.h" #include "socket.h"
#include "network/connection.h" #include "network/connection.h"
#include "serialization.h" #include "serialization.h"

@ -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. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#include "main.h"
#include "settings.h" #include "settings.h"
#include "wieldmesh.h" #include "wieldmesh.h"
#include "inventory.h" #include "inventory.h"