Minor cleanup: game.cpp

* Sort includes
* Remove unnecessary includes
* Ensure the parameter name for GameRunData is consistent for class member functions
This commit is contained in:
Craig Robbins 2015-03-17 16:44:17 +10:00
parent 699d42efc6
commit 34c5a5b377

@ -18,64 +18,59 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/ */
#include "game.h" #include "game.h"
#include "irrlichttypes_extrabloated.h"
#include <IGUICheckBox.h> #include <iomanip>
#include <IGUIEditBox.h>
#include <IGUIButton.h>
#include <IGUIStaticText.h>
#include <IGUIFont.h>
#include <IMaterialRendererServices.h>
#include "IMeshCache.h"
#include "client.h"
#include "server.h"
#include "guiPasswordChange.h"
#include "guiVolumeChange.h"
#include "guiKeyChangeMenu.h"
#include "guiFormSpecMenu.h"
#include "tool.h"
#include "guiChatConsole.h"
#include "config.h"
#include "version.h"
#include "clouds.h"
#include "particles.h"
#include "camera.h" #include "camera.h"
#include "mapblock.h" #include "client.h"
#include "settings.h" #include "client/tile.h" // For TextureSource
#include "profiler.h" #include "clientmap.h"
#include "mainmenumanager.h" #include "clouds.h"
#include "gettext.h" #include "config.h"
#include "content_cao.h"
#include "drawscene.h"
#include "event_manager.h"
#include "fontengine.h"
#include "itemdef.h"
#include "log.h" #include "log.h"
#include "filesys.h" #include "filesys.h"
// Needed for determining pointing to nodes #include "gettext.h"
#include "nodedef.h" #include "guiChatConsole.h"
#include "nodemetadata.h" #include "guiFormSpecMenu.h"
#include "main.h" // For g_settings #include "guiKeyChangeMenu.h"
#include "itemdef.h" #include "guiPasswordChange.h"
#include "client/tile.h" // For TextureSource #include "guiVolumeChange.h"
#include "shader.h" // For ShaderSource
#include "logoutputbuffer.h"
#include "subgame.h"
#include "quicktune_shortcutter.h"
#include "clientmap.h"
#include "hud.h" #include "hud.h"
#include "logoutputbuffer.h"
#include "mainmenumanager.h"
#include "mapblock.h"
#include "nodedef.h" // Needed for determining pointing to nodes
#include "nodemetadata.h"
#include "particles.h"
#include "profiler.h"
#include "quicktune_shortcutter.h"
#include "server.h"
#include "settings.h"
#include "shader.h" // For ShaderSource
#include "sky.h" #include "sky.h"
#include "subgame.h"
#include "tool.h"
#include "util/directiontables.h"
#include "util/pointedthing.h"
#include "version.h"
#include "sound.h" #include "sound.h"
#if USE_SOUND #if USE_SOUND
#include "sound_openal.h" #include "sound_openal.h"
#endif #endif
#include "event_manager.h"
#include <iomanip>
#include <list>
#include "util/directiontables.h"
#include "util/pointedthing.h"
#include "drawscene.h"
#include "content_cao.h"
#include "fontengine.h"
#ifdef HAVE_TOUCHSCREENGUI #ifdef HAVE_TOUCHSCREENGUI
#include "touchscreengui.h" #include "touchscreengui.h"
#endif #endif
extern Settings *g_settings;
extern Profiler *g_profiler;
/* /*
Text input system Text input system
*/ */
@ -565,16 +560,6 @@ public:
s32 graphh = 50; s32 graphh = 50;
s32 textx = x_left + m_log_max_size + 15; s32 textx = x_left + m_log_max_size + 15;
s32 textx2 = textx + 200 - 15; s32 textx2 = textx + 200 - 15;
// Draw background
/*{
u32 num_graphs = m_meta.size();
core::rect<s32> rect(x_left, y_bottom - num_graphs*graphh,
textx2, y_bottom);
video::SColor bgcolor(120,0,0,0);
driver->draw2DRectangle(bgcolor, rect, NULL);
}*/
s32 meta_i = 0; s32 meta_i = 0;
for (std::map<std::string, Meta>::const_iterator i = m_meta.begin(); for (std::map<std::string, Meta>::const_iterator i = m_meta.begin();
@ -1472,17 +1457,17 @@ protected:
// Main loop // Main loop
void updateInteractTimers(GameRunData *args, f32 dtime); void updateInteractTimers(GameRunData *runData, f32 dtime);
bool checkConnection(); bool checkConnection();
bool handleCallbacks(); bool handleCallbacks();
void processQueues(); void processQueues();
void updateProfilers(const GameRunData &run_data, const RunStats &stats, void updateProfilers(const GameRunData &runData, const RunStats &stats,
const FpsControl &draw_times, f32 dtime); const FpsControl &draw_times, f32 dtime);
void addProfilerGraphs(const RunStats &stats, const FpsControl &draw_times, void addProfilerGraphs(const RunStats &stats, const FpsControl &draw_times,
f32 dtime); f32 dtime);
void updateStats(RunStats *stats, const FpsControl &draw_times, f32 dtime); void updateStats(RunStats *stats, const FpsControl &draw_times, f32 dtime);
void processUserInput(VolatileRunFlags *flags, GameRunData *interact_args, void processUserInput(VolatileRunFlags *flags, GameRunData *runData,
f32 dtime); f32 dtime);
void processKeyboardInput(VolatileRunFlags *flags, void processKeyboardInput(VolatileRunFlags *flags,
float *statustext_time, float *statustext_time,
@ -1862,10 +1847,11 @@ void Game::shutdown()
} }
/****************************************************************************/
/**************************************************************************** /****************************************************************************
Startup Startup
****************************************************************************/ ****************************************************************************/
/****************************************************************************/
bool Game::init( bool Game::init(
const std::string &map_dir, const std::string &map_dir,
@ -2326,20 +2312,21 @@ bool Game::getServerContent(bool *aborted)
} }
/****************************************************************************/
/**************************************************************************** /****************************************************************************
Run Run
****************************************************************************/ ****************************************************************************/
/****************************************************************************/
inline void Game::updateInteractTimers(GameRunData *args, f32 dtime) inline void Game::updateInteractTimers(GameRunData *runData, f32 dtime)
{ {
if (args->nodig_delay_timer >= 0) if (runData->nodig_delay_timer >= 0)
args->nodig_delay_timer -= dtime; runData->nodig_delay_timer -= dtime;
if (args->object_hit_delay_timer >= 0) if (runData->object_hit_delay_timer >= 0)
args->object_hit_delay_timer -= dtime; runData->object_hit_delay_timer -= dtime;
args->time_from_last_punch += dtime; runData->time_from_last_punch += dtime;
} }
@ -2402,7 +2389,7 @@ void Game::processQueues()
} }
void Game::updateProfilers(const GameRunData &run_data, const RunStats &stats, void Game::updateProfilers(const GameRunData &runData, const RunStats &stats,
const FpsControl &draw_times, f32 dtime) const FpsControl &draw_times, f32 dtime)
{ {
float profiler_print_interval = float profiler_print_interval =
@ -2421,7 +2408,7 @@ void Game::updateProfilers(const GameRunData &run_data, const RunStats &stats,
} }
update_profiler_gui(guitext_profiler, g_fontengine, update_profiler_gui(guitext_profiler, g_fontengine,
run_data.profiler_current_page, run_data.profiler_max_page, runData.profiler_current_page, runData.profiler_max_page,
driver->getScreenSize().Height); driver->getScreenSize().Height);
g_profiler->clear(); g_profiler->clear();
@ -2502,7 +2489,7 @@ void Game::updateStats(RunStats *stats, const FpsControl &draw_times,
****************************************************************************/ ****************************************************************************/
void Game::processUserInput(VolatileRunFlags *flags, void Game::processUserInput(VolatileRunFlags *flags,
GameRunData *interact_args, f32 dtime) GameRunData *runData, f32 dtime)
{ {
// Reset input if window not active or some menu is active // Reset input if window not active or some menu is active
if (device->isWindowActive() == false if (device->isWindowActive() == false
@ -2533,18 +2520,18 @@ void Game::processUserInput(VolatileRunFlags *flags,
#endif #endif
// Increase timer for double tap of "keymap_jump" // Increase timer for double tap of "keymap_jump"
if (m_cache_doubletap_jump && interact_args->jump_timer <= 0.2) if (m_cache_doubletap_jump && runData->jump_timer <= 0.2)
interact_args->jump_timer += dtime; runData->jump_timer += dtime;
processKeyboardInput( processKeyboardInput(
flags, flags,
&interact_args->statustext_time, &runData->statustext_time,
&interact_args->jump_timer, &runData->jump_timer,
&interact_args->reset_jump_timer, &runData->reset_jump_timer,
&interact_args->profiler_current_page, &runData->profiler_current_page,
interact_args->profiler_max_page); runData->profiler_max_page);
processItemSelection(&interact_args->new_playeritem); processItemSelection(&runData->new_playeritem);
} }
@ -4186,9 +4173,11 @@ void Game::showOverlayMessage(const wchar_t *msg, float dtime,
} }
/****************************************************************************/
/**************************************************************************** /****************************************************************************
Shutdown / cleanup Shutdown / cleanup
****************************************************************************/ ****************************************************************************/
/****************************************************************************/
void Game::extendedResourceCleanup() void Game::extendedResourceCleanup()
{ {
@ -4212,10 +4201,11 @@ void Game::extendedResourceCleanup()
} }
/****************************************************************************/
/**************************************************************************** /****************************************************************************
extern function for launching the game extern function for launching the game
****************************************************************************/ ****************************************************************************/
/****************************************************************************/
void the_game(bool *kill, void the_game(bool *kill,
bool random_input, bool random_input,