Skip to content

Commit

Permalink
Move globals from main.cpp to more sane locations
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Zeno- committed Apr 1, 2015
1 parent 113bdd3 commit 9527984
Show file tree
Hide file tree
Showing 72 changed files with 119 additions and 193 deletions.
1 change: 1 addition & 0 deletions build/android/jni/Android.mk
Expand Up @@ -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 \
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Expand Up @@ -329,6 +329,7 @@ set(common_SRCS
pathfinder.cpp
player.cpp
porting.cpp
profiler.cpp
quicktune.cpp
rollback.cpp
rollback_interface.cpp
Expand Down
5 changes: 2 additions & 3 deletions src/camera.cpp
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion src/client.cpp
Expand Up @@ -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"
Expand Down
21 changes: 17 additions & 4 deletions src/client/clientlauncher.cpp
Expand Up @@ -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"
Expand All @@ -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()
{
Expand Down
1 change: 0 additions & 1 deletion src/client/tile.cpp
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion src/clientiface.cpp
Expand Up @@ -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[] = {
Expand Down
3 changes: 1 addition & 2 deletions src/clientmap.cpp
Expand Up @@ -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>

Expand Down
1 change: 0 additions & 1 deletion src/clientmedia.cpp
Expand Up @@ -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"
Expand Down
7 changes: 6 additions & 1 deletion src/clouds.cpp
Expand Up @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions src/clouds.h
Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion src/collision.cpp
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/content_abm.cpp
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion src/content_cao.cpp
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion src/content_mapblock.cpp
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion src/content_sao.cpp
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/convert_json.cpp
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion src/database-sqlite3.cpp
Expand Up @@ -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"

Expand Down
1 change: 0 additions & 1 deletion src/drawscene.cpp
Expand Up @@ -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"
Expand Down
3 changes: 1 addition & 2 deletions src/dungeongen.cpp
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion src/emerge.cpp
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/environment.cpp
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
1 change: 0 additions & 1 deletion src/fontengine.cpp
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion src/guiChatConsole.cpp
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/guiEngine.cpp
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
1 change: 0 additions & 1 deletion src/guiFormSpecMenu.cpp
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion src/guiKeyChangeMenu.cpp
Expand Up @@ -22,7 +22,6 @@
#include "guiKeyChangeMenu.h"
#include "debug.h"
#include "serialization.h"
#include "main.h"
#include <string>
#include <IGUICheckBox.h>
#include <IGUIEditBox.h>
Expand Down
1 change: 0 additions & 1 deletion src/guiTable.cpp
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion src/guiVolumeChange.cpp
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion src/guiscalingfilter.cpp
Expand Up @@ -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>

Expand Down
1 change: 0 additions & 1 deletion src/httpfetch.cpp
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/hud.cpp
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion src/inventorymanager.cpp
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion src/itemdef.cpp
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion src/keycode.cpp
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion src/localplayer.cpp
Expand Up @@ -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"
Expand Down
14 changes: 14 additions & 0 deletions src/log.cpp
Expand Up @@ -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,
Expand Down

0 comments on commit 9527984

Please sign in to comment.