From e0bf4df646d035277bcf4ffab175d7471fd65f84 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Sat, 22 Sep 2012 20:37:42 +0000 Subject: [PATCH] - cppcheck round #2 cleanup --- source/g3d_viewer/main.cpp | 4 ++-- source/g3d_viewer/renderer.cpp | 2 +- source/glest_game/ai/path_finder.cpp | 6 +++--- source/glest_game/game/commander.cpp | 4 ++-- source/glest_game/game/game.cpp | 6 +++--- source/glest_game/graphics/renderer.cpp | 18 +++++++++--------- .../menu/menu_state_connected_game.cpp | 4 ++-- .../glest_game/menu/menu_state_custom_game.cpp | 4 ++-- source/glest_game/network/server_interface.cpp | 2 +- source/shared_lib/sources/graphics/font.cpp | 2 +- 10 files changed, 26 insertions(+), 26 deletions(-) diff --git a/source/g3d_viewer/main.cpp b/source/g3d_viewer/main.cpp index 619e952d..9b6edb95 100644 --- a/source/g3d_viewer/main.cpp +++ b/source/g3d_viewer/main.cpp @@ -1324,8 +1324,8 @@ void MainWindow::loadParticle(string path) { else { if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] unit XML NOT FOUND [%s] using default position values\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,unitXML.c_str()); - int size = 1; - int height= 1; + size = 1; + height= 1; } std::map > > loadedFileList; diff --git a/source/g3d_viewer/renderer.cpp b/source/g3d_viewer/renderer.cpp index a6403d03..e51d301b 100644 --- a/source/g3d_viewer/renderer.cpp +++ b/source/g3d_viewer/renderer.cpp @@ -220,7 +220,7 @@ void Renderer::init() { if(glActiveTexture == NULL) { char szBuf[8096]=""; - sprintf(szBuf,"Error: glActiveTexture == NULL\nglActiveTexture is only supported if the GL version is 1.3 or greater,\nor if the ARB_multitexture extension is supported!",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + sprintf(szBuf,"Error: glActiveTexture == NULL\nglActiveTexture is only supported if the GL version is 1.3 or greater,\nor if the ARB_multitexture extension is supported!"); throw megaglest_runtime_error(szBuf); } diff --git a/source/glest_game/ai/path_finder.cpp b/source/glest_game/ai/path_finder.cpp index 33f69550..af7e61d3 100644 --- a/source/glest_game/ai/path_finder.cpp +++ b/source/glest_game/ai/path_finder.cpp @@ -220,7 +220,7 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu maxNodeCount= PathFinder::pathFindNodesAbsoluteMax; } - int unitFactionIndex = unit->getFactionIndex(); + //int unitFactionIndex = unit->getFactionIndex(); bool minorDebugPathfinderPerformance = false; Chrono chrono; @@ -449,7 +449,7 @@ TravelState PathFinder::aStarFast(Unit *unit, Vec2i finalPos, bool inBailout, in } if(maxNodeCount >= 1 && unit->getPathfindFailedConsecutiveFrameCount() >= 3) { - int orgmaxNodeCount = maxNodeCount; + //int orgmaxNodeCount = maxNodeCount; maxNodeCount = 200; //printf("AStar maxpath cut for unit [%d - %s] to %d [orig: %d] [unit->getPathfindFailedConsecutiveFrameCount(): %d]\n",unit->getId(),unit->getFullName().c_str(), maxNodeCount,orgmaxNodeCount,unit->getPathfindFailedConsecutiveFrameCount()); } @@ -1300,7 +1300,7 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout } if(maxNodeCount >= 1 && unit->getPathfindFailedConsecutiveFrameCount() >= 3) { - int orgmaxNodeCount = maxNodeCount; + //int orgmaxNodeCount = maxNodeCount; maxNodeCount = 200; //printf("AStar maxpath cut for unit [%d - %s] to %d [orig: %d] [unit->getPathfindFailedConsecutiveFrameCount(): %d]\n",unit->getId(),unit->getFullName().c_str(), maxNodeCount,orgmaxNodeCount,unit->getPathfindFailedConsecutiveFrameCount()); } diff --git a/source/glest_game/game/commander.cpp b/source/glest_game/game/commander.cpp index 65aab417..ccb7ab25 100644 --- a/source/glest_game/game/commander.cpp +++ b/source/glest_game/game/commander.cpp @@ -822,10 +822,10 @@ void Commander::giveNetworkCommand(NetworkCommand* networkCommand) const { NetworkManager &networkManager= NetworkManager::getInstance(); NetworkRole role = networkManager.getNetworkRole(); - GameSettings *settings = world->getGameSettingsPtr(); + //GameSettings *settings = world->getGameSettingsPtr(); if(role == nrServer) { - int factionIndex = networkCommand->getUnitId(); + //int factionIndex = networkCommand->getUnitId(); int playerIndex = networkCommand->getCommandTypeId(); GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface(); diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index b335711a..de3e4f6e 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -1742,7 +1742,7 @@ void Game::updateNetworkMarkedCells() { if(gameNetworkInterface != NULL && gameNetworkInterface->getMarkedCellList(false).empty() == false) { - Lang &lang= Lang::getInstance(); + //Lang &lang= Lang::getInstance(); std::vector chatList = gameNetworkInterface->getMarkedCellList(true); for(int idx = 0; idx < chatList.size(); idx++) { @@ -1769,7 +1769,7 @@ void Game::updateNetworkUnMarkedCells() { if(gameNetworkInterface != NULL && gameNetworkInterface->getUnMarkedCellList(false).empty() == false) { - Lang &lang= Lang::getInstance(); + //Lang &lang= Lang::getInstance(); std::vector chatList = gameNetworkInterface->getUnMarkedCellList(true); for(int idx = 0; idx < chatList.size(); idx++) { @@ -1805,7 +1805,7 @@ void Game::updateNetworkHighligtedCells() { if(gameNetworkInterface != NULL && gameNetworkInterface->getHighlightedCellList(false).empty() == false) { - Lang &lang= Lang::getInstance(); + //Lang &lang= Lang::getInstance(); std::vector highlighList = gameNetworkInterface->getHighlightedCellList(true); for(int idx = 0; idx < highlighList.size(); idx++) { MarkedCell mc = highlighList[idx]; // I want a copy here diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index 9eac228a..d48f3223 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -389,7 +389,7 @@ void Renderer::init() { if(glActiveTexture == NULL) { char szBuf[8096]=""; - sprintf(szBuf,"Error: glActiveTexture == NULL\nglActiveTexture is only supported if the GL version is 1.3 or greater,\nor if the ARB_multitexture extension is supported!",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + sprintf(szBuf,"Error: glActiveTexture == NULL\nglActiveTexture is only supported if the GL version is 1.3 or greater,\nor if the ARB_multitexture extension is supported!"); throw megaglest_runtime_error(szBuf); } @@ -1024,7 +1024,7 @@ void Renderer::setupLightingForRotatedModel() { } const World *world= game->getWorld(); - const GameCamera *gameCamera= game->getGameCamera(); + //const GameCamera *gameCamera= game->getGameCamera(); const TimeFlow *timeFlow= world->getTimeFlow(); float time= timeFlow->getTime(); @@ -4842,7 +4842,7 @@ void Renderer::renderGhostModel(const UnitType *building, const Vec2i pos,Cardin //const UnitType *building= gui->getBuilding(); //const Vec2i &pos= gui->getPosObjWorld(); - const Gui *gui= game->getGui(); + //const Gui *gui= game->getGui(); //const Mouse3d *mouse3d= gui->getMouse3d(); const Map *map= game->getWorld()->getMap(); if(map == NULL) { @@ -5897,7 +5897,7 @@ void Renderer::renderHighlightedCellsOnMinimap() { // Draw marked cells const std::vector *highlightedCells = game->getHighlightedCells(); if(highlightedCells->empty() == false) { - const Map *map= game->getWorld()->getMap(); + //const Map *map= game->getWorld()->getMap(); const World *world= game->getWorld(); const Minimap *minimap= world->getMinimap(); int pointersize=10; @@ -5905,12 +5905,12 @@ void Renderer::renderHighlightedCellsOnMinimap() { return; } - const GameCamera *gameCamera= game->getGameCamera(); + //const GameCamera *gameCamera= game->getGameCamera(); const Pixmap2D *pixmap= minimap->getTexture()->getPixmapConst(); const Metrics &metrics= Metrics::getInstance(); - int mx= metrics.getMinimapX(); + //int mx= metrics.getMinimapX(); int my= metrics.getMinimapY(); int mw= metrics.getMinimapW(); int mh= metrics.getMinimapH(); @@ -5938,7 +5938,7 @@ void Renderer::renderMarkedCellsOnMinimap() { // Draw marked cells std::map markedCells = game->getMapMarkedCellList(); if(markedCells.empty() == false) { - const Map *map= game->getWorld()->getMap(); + //const Map *map= game->getWorld()->getMap(); const World *world= game->getWorld(); const Minimap *minimap= world->getMinimap(); @@ -5946,10 +5946,10 @@ void Renderer::renderMarkedCellsOnMinimap() { return; } - const GameCamera *gameCamera= game->getGameCamera(); + //const GameCamera *gameCamera= game->getGameCamera(); const Pixmap2D *pixmap= minimap->getTexture()->getPixmapConst(); const Metrics &metrics= Metrics::getInstance(); - const WaterEffects *attackEffects= world->getAttackEffects(); + //const WaterEffects *attackEffects= world->getAttackEffects(); int mx= metrics.getMinimapX(); int my= metrics.getMinimapY(); diff --git a/source/glest_game/menu/menu_state_connected_game.cpp b/source/glest_game/menu/menu_state_connected_game.cpp index d8af9339..7efc90ea 100644 --- a/source/glest_game/menu/menu_state_connected_game.cpp +++ b/source/glest_game/menu/menu_state_connected_game.cpp @@ -3804,7 +3804,7 @@ void MenuStateConnectedGame::setupUIFromGameSettings(GameSettings *gameSettings, //printf("currentFactionName_factionPreview [%s] random [%s] observer [%s] factionVideoUrl [%s]\n",currentFactionName_factionPreview.c_str(),GameConstants::RANDOMFACTION_SLOTNAME,GameConstants::OBSERVER_SLOTNAME,factionVideoUrl.c_str()); if(factionVideoUrl != "") { - SoundRenderer &soundRenderer= SoundRenderer::getInstance(); + //SoundRenderer &soundRenderer= SoundRenderer::getInstance(); if(CoreData::getInstance().getMenuMusic()->getVolume() != 0) { CoreData::getInstance().getMenuMusic()->setVolume(0); factionVideoSwitchedOffVolume=true; @@ -3844,7 +3844,7 @@ void MenuStateConnectedGame::setupUIFromGameSettings(GameSettings *gameSettings, } } else { - SoundRenderer &soundRenderer= SoundRenderer::getInstance(); + //SoundRenderer &soundRenderer= SoundRenderer::getInstance(); //switch on music again!! Config &config = Config::getInstance(); float configVolume = (config.getInt("SoundVolumeMusic") / 100.f); diff --git a/source/glest_game/menu/menu_state_custom_game.cpp b/source/glest_game/menu/menu_state_custom_game.cpp index f8a62772..937361ec 100644 --- a/source/glest_game/menu/menu_state_custom_game.cpp +++ b/source/glest_game/menu/menu_state_custom_game.cpp @@ -2663,7 +2663,7 @@ void MenuStateCustomGame::update() { //printf("currentFactionName_factionPreview [%s] random [%s] observer [%s] factionVideoUrl [%s]\n",currentFactionName_factionPreview.c_str(),GameConstants::RANDOMFACTION_SLOTNAME,GameConstants::OBSERVER_SLOTNAME,factionVideoUrl.c_str()); if(factionVideoUrl != "") { - SoundRenderer &soundRenderer= SoundRenderer::getInstance(); + //SoundRenderer &soundRenderer= SoundRenderer::getInstance(); if(CoreData::getInstance().getMenuMusic()->getVolume() != 0) { CoreData::getInstance().getMenuMusic()->setVolume(0); factionVideoSwitchedOffVolume=true; @@ -2703,7 +2703,7 @@ void MenuStateCustomGame::update() { } } else { - SoundRenderer &soundRenderer= SoundRenderer::getInstance(); + //SoundRenderer &soundRenderer= SoundRenderer::getInstance(); //switch on music again!! Config &config = Config::getInstance(); float configVolume = (config.getInt("SoundVolumeMusic") / 100.f); diff --git a/source/glest_game/network/server_interface.cpp b/source/glest_game/network/server_interface.cpp index 0d9b3843..1d6e2ae5 100644 --- a/source/glest_game/network/server_interface.cpp +++ b/source/glest_game/network/server_interface.cpp @@ -2181,7 +2181,7 @@ void ServerInterface::validateGameSettings(GameSettings *serverGameSettings) { if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s]\n",__FILE__,__FUNCTION__); string mapFile = serverGameSettings->getMap(); - bool useNext=false; + //bool useNext=false; printf("Trying to set map to [%s]. Current map is [%s]\n",serverGameSettings->getMap().c_str(),gameSettings.getMap().c_str()); if(find(mapFiles.begin(),mapFiles.end(),mapFile) == mapFiles.end()) { printf("map not found on this server\n"); diff --git a/source/shared_lib/sources/graphics/font.cpp b/source/shared_lib/sources/graphics/font.cpp index bbd0067a..600761c8 100644 --- a/source/shared_lib/sources/graphics/font.cpp +++ b/source/shared_lib/sources/graphics/font.cpp @@ -128,7 +128,7 @@ float FontMetrics::getTextWidth(const string &str) { else { vector lineTokens; Tokenize(str,lineTokens,"\n"); - if(lineTokens.size() > 0) { + if(lineTokens.empty() == false) { for(unsigned int i = 0; i < lineTokens.size(); ++i) { string currentStr = lineTokens[i]; if(currentStr.length() > longestLine.length()) {