17 changes: 17 additions & 0 deletions src/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

53 changes: 0 additions & 53 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
*/
Expand Down
61 changes: 0 additions & 61 deletions src/main.h

This file was deleted.

2 changes: 1 addition & 1 deletion src/mainmenumanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class IGameCallback
virtual void signalKeyConfigChange() = 0;
};

extern gui::IGUIEnvironment* guienv;
extern gui::IGUIEnvironment *guienv;
extern gui::IGUIStaticText *guiroot;

// Handler for the modal menus
Expand Down
1 change: 0 additions & 1 deletion src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion src/mapblock_mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 1 addition & 2 deletions src/mapgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion src/mapgen_v5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion src/mapgen_v6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion src/mapgen_v7.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion src/mapnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/mg_biome.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
4 changes: 2 additions & 2 deletions src/mods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion src/network/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion src/network/serverpackethandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion src/nodedef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion src/particles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion src/porting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
23 changes: 23 additions & 0 deletions src/profiler.cpp
Original file line number Diff line number Diff line change
@@ -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;
8 changes: 6 additions & 2 deletions src/profiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
1 change: 0 additions & 1 deletion src/script/common/c_internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/script/lua_api/l_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/script/lua_api/l_mainmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
1 change: 0 additions & 1 deletion src/script/lua_api/l_mapgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"


Expand Down
1 change: 0 additions & 1 deletion src/script/lua_api/l_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/serverlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
4 changes: 4 additions & 0 deletions src/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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*);

Expand Down
4 changes: 2 additions & 2 deletions src/shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
7 changes: 3 additions & 4 deletions src/sky.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion src/socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions src/subgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
1 change: 0 additions & 1 deletion src/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion src/wieldmesh.cpp
Original file line number Diff line number Diff line change
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 "settings.h"
#include "wieldmesh.h"
#include "inventory.h"
Expand Down