From c55b9c3ffe04ec0ded133eedf4ad0df881fb462f Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Fri, 17 May 2013 05:01:23 +0000 Subject: [PATCH] code cleanup based on cppcheck results --- source/glest_game/ai/ai_interface.h | 7 +++++++ source/glest_game/ai/path_finder.h | 8 ++++++++ source/glest_game/game/game.cpp | 4 ++-- source/glest_game/global/config.cpp | 2 ++ source/glest_game/menu/menu_state_options.cpp | 2 +- source/glest_game/menu/menu_state_options_sound.cpp | 2 +- source/glest_game/menu/menu_state_root.cpp | 2 +- source/glest_game/menu/menu_state_scenario.cpp | 2 +- source/glest_game/network/network_interface.h | 7 +++++++ source/glest_map_editor/program.h | 7 +++++++ 10 files changed, 37 insertions(+), 6 deletions(-) diff --git a/source/glest_game/ai/ai_interface.h b/source/glest_game/ai/ai_interface.h index 2534d6cf..af73a5e1 100644 --- a/source/glest_game/ai/ai_interface.h +++ b/source/glest_game/ai/ai_interface.h @@ -87,6 +87,13 @@ public: AiInterface(Game &game, int factionIndex, int teamIndex, int useStartLocation=-1); ~AiInterface(); + AiInterface(const AiInterface& obj) { + throw megaglest_runtime_error("class AiInterface is NOT safe to copy!"); + } + AiInterface & operator=(const AiInterface& obj) { + throw megaglest_runtime_error("class AiInterface is NOT safe to assign!"); + } + //main void update(); diff --git a/source/glest_game/ai/path_finder.h b/source/glest_game/ai/path_finder.h index 1cc4c72f..20c51b17 100644 --- a/source/glest_game/ai/path_finder.h +++ b/source/glest_game/ai/path_finder.h @@ -158,6 +158,14 @@ public: PathFinder(); PathFinder(const Map *map); ~PathFinder(); + + PathFinder(const PathFinder& obj) { + throw megaglest_runtime_error("class PathFinder is NOT safe to copy!"); + } + PathFinder & operator=(const PathFinder& obj) { + throw megaglest_runtime_error("class PathFinder is NOT safe to assign!"); + } + void init(const Map *map); TravelState findPath(Unit *unit, const Vec2i &finalPos, bool *wasStuck=NULL,int frameIndex=-1); void clearUnitPrecache(Unit *unit); diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index 386b230a..4577f67b 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -2257,7 +2257,7 @@ void Game::update() { this->speed = 1; - Lang &lang= Lang::getInstance(); + //Lang &lang= Lang::getInstance(); bool pauseAndSaveGameForNewClient = false; for(int i = 0; i < world.getFactionCount(); ++i) { Faction *faction = world.getFaction(i); @@ -4803,7 +4803,7 @@ void Game::exitGameState(Program *program, Stats &endStats) { game->endGame(); } - if(game != NULL && game->isMasterserverMode() == true || + if((game != NULL && game->isMasterserverMode() == true) || Config::getInstance().getBool("AutoTest") == true) { printf("Game ending with stats:\n"); printf("-----------------------\n"); diff --git a/source/glest_game/global/config.cpp b/source/glest_game/global/config.cpp index 62cd7b88..f7f63f93 100644 --- a/source/glest_game/global/config.cpp +++ b/source/glest_game/global/config.cpp @@ -190,6 +190,8 @@ Config::Config(std::pair type, std::pair f } #endif + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("foundPath = [%d]\n",foundPath); + if(fileMustExist.first == true && fileExists(fileName.first) == false) { //string currentpath = extractDirectoryPathFromFile(Properties::getApplicationPath()); fileName.first = currentpath + fileName.first; diff --git a/source/glest_game/menu/menu_state_options.cpp b/source/glest_game/menu/menu_state_options.cpp index 9115e9e1..68ec317f 100644 --- a/source/glest_game/menu/menu_state_options.cpp +++ b/source/glest_game/menu/menu_state_options.cpp @@ -49,7 +49,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu, Program int leftLabelStart=50; int leftColumnStart=leftLabelStart+280; - int rightLabelStart=450; + //int rightLabelStart=450; //int rightColumnStart=rightLabelStart+280; int buttonRowPos=50; int buttonStartPos=170; diff --git a/source/glest_game/menu/menu_state_options_sound.cpp b/source/glest_game/menu/menu_state_options_sound.cpp index facc4a67..8bd68823 100644 --- a/source/glest_game/menu/menu_state_options_sound.cpp +++ b/source/glest_game/menu/menu_state_options_sound.cpp @@ -48,7 +48,7 @@ MenuStateOptionsSound::MenuStateOptionsSound(Program *program, MainMenu *mainMen int leftLabelStart=50; int leftColumnStart=leftLabelStart+280; int rightLabelStart=450; - int rightColumnStart=rightLabelStart+280; + //int rightColumnStart=rightLabelStart+280; int buttonRowPos=50; int buttonStartPos=170; //int captionOffset=75; diff --git a/source/glest_game/menu/menu_state_root.cpp b/source/glest_game/menu/menu_state_root.cpp index 76b24105..a20f6d5a 100644 --- a/source/glest_game/menu/menu_state_root.cpp +++ b/source/glest_game/menu/menu_state_root.cpp @@ -268,7 +268,7 @@ void MenuStateRoot::render() { logoMainW, logoMainH, extraLogo, GraphicComponent::getFade()); - currentX += extraLogo->getPixmap()->getW(); + //currentX += extraLogo->getPixmap()->getW(); } renderer.renderButton(&buttonNewGame); diff --git a/source/glest_game/menu/menu_state_scenario.cpp b/source/glest_game/menu/menu_state_scenario.cpp index ae050871..9cc6057d 100644 --- a/source/glest_game/menu/menu_state_scenario.cpp +++ b/source/glest_game/menu/menu_state_scenario.cpp @@ -168,7 +168,7 @@ MenuStateScenario::MenuStateScenario(Program *program, MainMenu *mainMenu, showMessageBox( "Error: " + string(ex.what()), "Error detected", false); } - if(scenarioErrors.size() > 0) { + if(scenarioErrors.empty() == false) { mainMessageBoxState=1; string errorMsg = ""; diff --git a/source/glest_game/network/network_interface.h b/source/glest_game/network/network_interface.h index fdf4d8d7..2d4a0f8a 100644 --- a/source/glest_game/network/network_interface.h +++ b/source/glest_game/network/network_interface.h @@ -195,6 +195,13 @@ public: NetworkInterface(); virtual ~NetworkInterface(); + NetworkInterface(const NetworkInterface& obj) { + throw megaglest_runtime_error("class NetworkInterface is NOT safe to copy!"); + } + NetworkInterface & operator=(const NetworkInterface& obj) { + throw megaglest_runtime_error("class NetworkInterface is NOT safe to assign!"); + } + virtual Socket* getSocket(bool mutexLock=true)= 0; virtual void close()= 0; virtual string getHumanPlayerName(int index=-1) = 0; diff --git a/source/glest_map_editor/program.h b/source/glest_map_editor/program.h index 22b69f1d..b9e173fd 100644 --- a/source/glest_map_editor/program.h +++ b/source/glest_map_editor/program.h @@ -107,6 +107,13 @@ public: Program(int w, int h); ~Program(); + Program(const Program& obj) { + throw runtime_error("class Program is NOT safe to copy!"); + } + Program & operator=(const Program& obj) { + throw runtime_error("class Program is NOT safe to assign!"); + } + //map cell change void glestChangeMapHeight(int x, int y, int Height, int radius); void pirateChangeMapHeight(int x, int y, int Height, int radius);