Skip to content

Commit

Permalink
Minor cleanup: game.cpp
Browse files Browse the repository at this point in the history
* Sort includes
* Remove unnecessary includes
* Ensure the parameter name for GameRunData is consistent for class member functions
  • Loading branch information
Zeno- committed Mar 17, 2015
1 parent 699d42e commit 34c5a5b
Showing 1 changed file with 67 additions and 77 deletions.
144 changes: 67 additions & 77 deletions src/game.cpp
Expand Up @@ -18,64 +18,59 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/

#include "game.h"
#include "irrlichttypes_extrabloated.h"
#include <IGUICheckBox.h>
#include <IGUIEditBox.h>
#include <IGUIButton.h>
#include <IGUIStaticText.h>
#include <IGUIFont.h>
#include <IMaterialRendererServices.h>
#include "IMeshCache.h"

#include <iomanip>
#include "camera.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 "client/tile.h" // For TextureSource
#include "clientmap.h"
#include "clouds.h"
#include "particles.h"
#include "camera.h"
#include "mapblock.h"
#include "settings.h"
#include "profiler.h"
#include "mainmenumanager.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 "filesys.h"
// Needed for determining pointing to nodes
#include "nodedef.h"
#include "nodemetadata.h"
#include "main.h" // For g_settings
#include "itemdef.h"
#include "client/tile.h" // For TextureSource
#include "shader.h" // For ShaderSource
#include "gettext.h"
#include "guiChatConsole.h"
#include "guiFormSpecMenu.h"
#include "guiKeyChangeMenu.h"
#include "guiPasswordChange.h"
#include "guiVolumeChange.h"
#include "hud.h"
#include "logoutputbuffer.h"
#include "subgame.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 "clientmap.h"
#include "hud.h"
#include "server.h"
#include "settings.h"
#include "shader.h" // For ShaderSource
#include "sky.h"
#include "subgame.h"
#include "tool.h"
#include "util/directiontables.h"
#include "util/pointedthing.h"
#include "version.h"

#include "sound.h"

#if USE_SOUND
#include "sound_openal.h"
#include "sound_openal.h"
#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
#include "touchscreengui.h"
#include "touchscreengui.h"
#endif

extern Settings *g_settings;
extern Profiler *g_profiler;

/*
Text input system
*/
Expand Down Expand Up @@ -565,16 +560,6 @@ class ProfilerGraph
s32 graphh = 50;
s32 textx = x_left + m_log_max_size + 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;

for (std::map<std::string, Meta>::const_iterator i = m_meta.begin();
Expand Down Expand Up @@ -1472,17 +1457,17 @@ class Game

// Main loop

void updateInteractTimers(GameRunData *args, f32 dtime);
void updateInteractTimers(GameRunData *runData, f32 dtime);
bool checkConnection();
bool handleCallbacks();
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);
void addProfilerGraphs(const 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);
void processKeyboardInput(VolatileRunFlags *flags,
float *statustext_time,
Expand Down Expand Up @@ -1862,10 +1847,11 @@ void Game::shutdown()
}



/****************************************************************************/
/****************************************************************************
Startup
****************************************************************************/
/****************************************************************************/

bool Game::init(
const std::string &map_dir,
Expand Down Expand Up @@ -2326,20 +2312,21 @@ bool Game::getServerContent(bool *aborted)
}



/****************************************************************************/
/****************************************************************************
Run
****************************************************************************/
/****************************************************************************/

inline void Game::updateInteractTimers(GameRunData *args, f32 dtime)
inline void Game::updateInteractTimers(GameRunData *runData, f32 dtime)
{
if (args->nodig_delay_timer >= 0)
args->nodig_delay_timer -= dtime;
if (runData->nodig_delay_timer >= 0)
runData->nodig_delay_timer -= dtime;

if (args->object_hit_delay_timer >= 0)
args->object_hit_delay_timer -= dtime;
if (runData->object_hit_delay_timer >= 0)
runData->object_hit_delay_timer -= dtime;

args->time_from_last_punch += dtime;
runData->time_from_last_punch += dtime;
}


Expand Down Expand Up @@ -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)
{
float profiler_print_interval =
Expand All @@ -2421,7 +2408,7 @@ void Game::updateProfilers(const GameRunData &run_data, const RunStats &stats,
}

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

g_profiler->clear();
Expand Down Expand Up @@ -2502,7 +2489,7 @@ void Game::updateStats(RunStats *stats, const FpsControl &draw_times,
****************************************************************************/

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
if (device->isWindowActive() == false
Expand Down Expand Up @@ -2533,18 +2520,18 @@ void Game::processUserInput(VolatileRunFlags *flags,
#endif

// Increase timer for double tap of "keymap_jump"
if (m_cache_doubletap_jump && interact_args->jump_timer <= 0.2)
interact_args->jump_timer += dtime;
if (m_cache_doubletap_jump && runData->jump_timer <= 0.2)
runData->jump_timer += dtime;

processKeyboardInput(
flags,
&interact_args->statustext_time,
&interact_args->jump_timer,
&interact_args->reset_jump_timer,
&interact_args->profiler_current_page,
interact_args->profiler_max_page);
&runData->statustext_time,
&runData->jump_timer,
&runData->reset_jump_timer,
&runData->profiler_current_page,
runData->profiler_max_page);

processItemSelection(&interact_args->new_playeritem);
processItemSelection(&runData->new_playeritem);
}


Expand Down Expand Up @@ -4186,9 +4173,11 @@ void Game::showOverlayMessage(const wchar_t *msg, float dtime,
}


/****************************************************************************/
/****************************************************************************
Shutdown / cleanup
****************************************************************************/
/****************************************************************************/

void Game::extendedResourceCleanup()
{
Expand All @@ -4212,10 +4201,11 @@ void Game::extendedResourceCleanup()
}



/****************************************************************************/
/****************************************************************************
extern function for launching the game
****************************************************************************/
/****************************************************************************/

void the_game(bool *kill,
bool random_input,
Expand Down

0 comments on commit 34c5a5b

Please sign in to comment.