Skip to content

Commit

Permalink
Optimize headers (part 2) (#6272)
Browse files Browse the repository at this point in the history
* Optimize headers (part 2)

* less debug.h in headers
* less remoteplayer.h for everybody

* Cleanup (part 2)

* camera.h: mesh.h
* mapgen.h: mapnode.h
* serverenvironment.h: mapblock.h
* nodedef.h: shader.h
  • Loading branch information
nerzhul committed Aug 18, 2017
1 parent c427533 commit fd3afbc
Show file tree
Hide file tree
Showing 42 changed files with 55 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/camera.cpp
Expand Up @@ -30,7 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "noise.h" // easeCurve
#include "sound.h"
#include "event.h"
#include "profiler.h"
#include "nodedef.h"
#include "util/numeric.h"
#include "constants.h"
#include "fontengine.h"
Expand Down
1 change: 0 additions & 1 deletion src/camera.h
Expand Up @@ -21,7 +21,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,

#include "irrlichttypes_extrabloated.h"
#include "inventory.h"
#include "mesh.h"
#include "client/tile.h"
#include <ICameraSceneNode.h>
#include <ISceneNode.h>
Expand Down
1 change: 1 addition & 0 deletions src/client.cpp
Expand Up @@ -39,6 +39,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "minimap.h"
#include "mods.h"
#include "profiler.h"
#include "shader.h"
#include "gettext.h"
#include "clientmap.h"
#include "clientmedia.h"
Expand Down
1 change: 1 addition & 0 deletions src/client/clientlauncher.cpp
Expand Up @@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "filesys.h"
#include "guiMainMenu.h"
#include "game.h"
#include "player.h"
#include "chat.h"
#include "gettext.h"
#include "profiler.h"
Expand Down
1 change: 1 addition & 0 deletions src/clientenvironment.cpp
Expand Up @@ -27,6 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "mapblock_mesh.h"
#include "event.h"
#include "collision.h"
#include "nodedef.h"
#include "profiler.h"
#include "raycast.h"
#include "voxelalgorithms.h"
Expand Down
2 changes: 1 addition & 1 deletion src/database-postgresql.cpp
Expand Up @@ -33,7 +33,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <netinet/in.h>
#endif

#include "log.h"
#include "debug.h"
#include "exceptions.h"
#include "settings.h"
#include "content_sao.h"
Expand Down
1 change: 0 additions & 1 deletion src/dungeongen.cpp
Expand Up @@ -25,7 +25,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "mapnode.h"
#include "map.h"
#include "nodedef.h"
#include "profiler.h"
#include "settings.h"

//#define DGEN_USE_TORCHES
Expand Down
2 changes: 2 additions & 0 deletions src/game.cpp
Expand Up @@ -66,6 +66,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,

#if USE_SOUND
#include "sound_openal.h"
#include "shader.h"

#endif

extern Settings *g_settings;
Expand Down
2 changes: 1 addition & 1 deletion src/hud.cpp
Expand Up @@ -25,6 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "log.h"
#include "client.h"
#include "inventory.h"
#include "shader.h"
#include "client/tile.h"
#include "localplayer.h"
#include "camera.h"
Expand All @@ -33,7 +34,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "guiscalingfilter.h"
#include "mesh.h"
#include "wieldmesh.h"
#include <IGUIStaticText.h>
#include "client/renderingengine.h"

#ifdef HAVE_TOUCHSCREENGUI
Expand Down
2 changes: 1 addition & 1 deletion src/inventory.h
Expand Up @@ -19,14 +19,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,

#pragma once

#include "debug.h"
#include "itemdef.h"
#include "irrlichttypes.h"
#include "itemstackmetadata.h"
#include <istream>
#include <ostream>
#include <string>
#include <vector>
#include <cassert>

struct ToolCapabilities;

Expand Down
1 change: 1 addition & 0 deletions src/inventorymanager.cpp
Expand Up @@ -18,6 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/

#include "inventorymanager.h"
#include "debug.h"
#include "log.h"
#include "serverenvironment.h"
#include "scripting_server.h"
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Expand Up @@ -18,7 +18,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/

#include "irrlicht.h" // createDevice

#include "mainmenumanager.h"
#include "irrlichttypes_extrabloated.h"
#include "chat_interface.h"
Expand All @@ -38,6 +37,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "gameparams.h"
#include "database.h"
#include "config.h"
#include "player.h"
#include "porting.h"
#if USE_CURSES
#include "terminal_chat_console.h"
Expand Down
2 changes: 1 addition & 1 deletion src/mainmenumanager.h
Expand Up @@ -22,8 +22,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
/*
All kinds of stuff that needs to be exposed from main.cpp
*/
#include "debug.h" // assert
#include "modalMenu.h"
#include <cassert>
#include <list>

class IGameCallback
Expand Down
1 change: 1 addition & 0 deletions src/map.h
Expand Up @@ -33,6 +33,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "util/container.h"
#include "nodetimer.h"
#include "map_settings_manager.h"
#include "debug.h"

class Settings;
class MapDatabase;
Expand Down
1 change: 0 additions & 1 deletion src/mapblock.h
Expand Up @@ -20,7 +20,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#pragma once

#include <set>
#include "debug.h"
#include "irr_v3d.h"
#include "mapnode.h"
#include "exceptions.h"
Expand Down
1 change: 1 addition & 0 deletions src/mapblock_mesh.cpp
Expand Up @@ -22,6 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "mapblock.h"
#include "map.h"
#include "profiler.h"
#include "shader.h"
#include "mesh.h"
#include "minimap.h"
#include "content_mapblock.h"
Expand Down
1 change: 0 additions & 1 deletion src/mapgen.h
Expand Up @@ -23,7 +23,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,

#include "noise.h"
#include "nodedef.h"
#include "mapnode.h"
#include "util/string.h"
#include "util/container.h"

Expand Down
1 change: 1 addition & 0 deletions src/minimap.cpp
Expand Up @@ -21,6 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "client.h"
#include "clientmap.h"
#include "settings.h"
#include "shader.h"
#include "mapblock.h"
#include "client/renderingengine.h"

Expand Down
5 changes: 2 additions & 3 deletions src/network/serverpackethandler.cpp
Expand Up @@ -17,15 +17,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#include <chatmessage.h>
#include "chatmessage.h"
#include "server.h"
#include "log.h"

#include "content_sao.h"
#include "emerge.h"
#include "mapblock.h"
#include "nodedef.h"
#include "player.h"
#include "remoteplayer.h"
#include "rollback_interface.h"
#include "scripting_server.h"
#include "settings.h"
Expand Down
1 change: 1 addition & 0 deletions src/nodedef.cpp
Expand Up @@ -22,6 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "itemdef.h"
#ifndef SERVER
#include "mesh.h"
#include "shader.h"
#include "client.h"
#include "client/renderingengine.h"
#include "client/tile.h"
Expand Down
1 change: 0 additions & 1 deletion src/nodedef.h
Expand Up @@ -27,7 +27,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "mapnode.h"
#ifndef SERVER
#include "client/tile.h"
#include "shader.h"
#include <IMeshManipulator.h>
class Client;
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/particles.cpp
Expand Up @@ -20,13 +20,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "particles.h"
#include "client.h"
#include "collision.h"
#include <stdlib.h>
#include "client/renderingengine.h"
#include "util/numeric.h"
#include "light.h"
#include "environment.h"
#include "clientmap.h"
#include "mapnode.h"
#include "nodedef.h"
#include "client.h"
#include "settings.h"

Expand Down
1 change: 0 additions & 1 deletion src/particles.h
Expand Up @@ -23,7 +23,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "irrlichttypes_extrabloated.h"
#include "client/tile.h"
#include "localplayer.h"
#include "environment.h"
#include "tileanimation.h"

struct ClientEvent;
Expand Down
3 changes: 2 additions & 1 deletion src/profiler.h
Expand Up @@ -20,13 +20,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#pragma once

#include "irrlichttypes.h"
#include <cassert>
#include <string>
#include <map>
#include <ostream>

#include "threading/mutex_auto_lock.h"
#include "util/timetaker.h"
#include "util/numeric.h" // paging()
#include "debug.h" // assert()

#define MAX_PROFILER_TEXT_ROWS 20

Expand Down
1 change: 0 additions & 1 deletion src/script/cpp_api/s_async.h
Expand Up @@ -25,7 +25,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,

#include "threading/semaphore.h"
#include "threading/thread.h"
#include "debug.h"
#include "lua.h"
#include "cpp_api/s_base.h"

Expand Down
2 changes: 1 addition & 1 deletion src/script/cpp_api/s_internal.h
Expand Up @@ -32,7 +32,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "threading/mutex_auto_lock.h"

#ifdef SCRIPTAPI_LOCK_DEBUG
#include "debug.h" // assert()
#include <cassert>

class LockChecker {
public:
Expand Down
2 changes: 2 additions & 0 deletions src/script/lua_api/l_env.cpp
Expand Up @@ -28,6 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <algorithm>
#include "scripting_server.h"
#include "environment.h"
#include "mapblock.h"
#include "server.h"
#include "nodedef.h"
#include "daynightratio.h"
Expand All @@ -37,6 +38,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "emerge.h"
#include "pathfinder.h"
#include "face_position_cache.h"
#include "remoteplayer.h"
#ifndef SERVER
#include "client.h"
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/script/lua_api/l_inventory.cpp
Expand Up @@ -23,7 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "common/c_converter.h"
#include "common/c_content.h"
#include "server.h"
#include "player.h"
#include "remoteplayer.h"

/*
InvRef
Expand Down
1 change: 1 addition & 0 deletions src/script/lua_api/l_nodemeta.cpp
Expand Up @@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "common/c_content.h"
#include "serverenvironment.h"
#include "map.h"
#include "mapblock.h"
#include "server.h"

/*
Expand Down
1 change: 1 addition & 0 deletions src/script/lua_api/l_object.cpp
Expand Up @@ -27,6 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "tool.h"
#include "serverobject.h"
#include "content_sao.h"
#include "remoteplayer.h"
#include "server.h"
#include "hud.h"
#include "scripting_server.h"
Expand Down
2 changes: 1 addition & 1 deletion src/script/lua_api/l_server.cpp
Expand Up @@ -24,7 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "cpp_api/s_base.h"
#include "server.h"
#include "environment.h"
#include "player.h"
#include "remoteplayer.h"
#include "log.h"
#include <algorithm>

Expand Down
1 change: 1 addition & 0 deletions src/script/lua_api/l_vmanip.cpp
Expand Up @@ -25,6 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "emerge.h"
#include "environment.h"
#include "map.h"
#include "mapblock.h"
#include "server.h"
#include "mapgen.h"
#include "voxelalgorithms.h"
Expand Down
1 change: 1 addition & 0 deletions src/script/scripting_mainmenu.cpp
Expand Up @@ -25,6 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "lua_api/l_sound.h"
#include "lua_api/l_util.h"
#include "lua_api/l_settings.h"
#include "log.h"

extern "C" {
#include "lualib.h"
Expand Down
11 changes: 11 additions & 0 deletions src/server.cpp
Expand Up @@ -62,6 +62,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "database.h"
#include "chatmessage.h"
#include "chat_interface.h"
#include "remoteplayer.h"

class ClientNotFoundException : public BaseException
{
Expand Down Expand Up @@ -3122,6 +3123,11 @@ bool Server::hudSetHotbarItemcount(RemotePlayer *player, s32 hotbar_itemcount)
return true;
}

s32 Server::hudGetHotbarItemcount(RemotePlayer *player) const
{
return player->getHotbarItemcount();
}

void Server::hudSetHotbarImage(RemotePlayer *player, std::string name)
{
if (!player)
Expand All @@ -3147,6 +3153,11 @@ void Server::hudSetHotbarSelectedImage(RemotePlayer *player, std::string name)
SendHUDSetParam(player->peer_id, HUD_PARAM_HOTBAR_SELECTED_IMAGE, name);
}

const std::string& Server::hudGetHotbarSelectedImage(RemotePlayer *player) const
{
return player->getHotbarSelectedImage();
}

bool Server::setLocalPlayerAnimations(RemotePlayer *player,
v2s32 animation_frames[4], f32 frame_speed)
{
Expand Down
10 changes: 3 additions & 7 deletions src/server.h
Expand Up @@ -34,7 +34,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "util/basic_macros.h"
#include "serverenvironment.h"
#include "clientiface.h"
#include "remoteplayer.h"
#include "chatmessage.h"
#include <string>
#include <list>
Expand All @@ -50,6 +49,7 @@ class IWritableCraftDefManager;
class BanManager;
class EventManager;
class Inventory;
class RemotePlayer;
class PlayerSAO;
class IRollbackManager;
struct RollbackAction;
Expand Down Expand Up @@ -285,15 +285,11 @@ class Server : public con::PeerHandler, public MapEventReceiver,
bool hudChange(RemotePlayer *player, u32 id, HudElementStat stat, void *value);
bool hudSetFlags(RemotePlayer *player, u32 flags, u32 mask);
bool hudSetHotbarItemcount(RemotePlayer *player, s32 hotbar_itemcount);
s32 hudGetHotbarItemcount(RemotePlayer *player) const
{ return player->getHotbarItemcount(); }
s32 hudGetHotbarItemcount(RemotePlayer *player) const;
void hudSetHotbarImage(RemotePlayer *player, std::string name);
std::string hudGetHotbarImage(RemotePlayer *player);
void hudSetHotbarSelectedImage(RemotePlayer *player, std::string name);
const std::string &hudGetHotbarSelectedImage(RemotePlayer *player) const
{
return player->getHotbarSelectedImage();
}
const std::string &hudGetHotbarSelectedImage(RemotePlayer *player) const;

inline Address getPeerAddress(u16 peer_id)
{ return m_con.GetPeerAddress(peer_id); }
Expand Down

0 comments on commit fd3afbc

Please sign in to comment.