From 1b3ee1503b09ed4ea3fe7d285083242536a513b7 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Sat, 15 Jun 2013 01:43:44 +0000 Subject: [PATCH] code cleanup from cppcheck --- source/g3d_viewer/main.cpp | 2 +- source/glest_game/facilities/components.cpp | 2 +- source/glest_game/main/main.cpp | 8 -------- source/glest_game/menu/menu_state_about.cpp | 6 ++++++ source/glest_game/menu/menu_state_custom_game.cpp | 2 +- source/glest_game/network/network_interface.cpp | 2 ++ source/glest_game/type_instances/faction.cpp | 8 ++++---- source/glest_game/type_instances/unit.cpp | 5 ++--- .../sources/platform/common/platform_common.cpp | 4 ++-- 9 files changed, 19 insertions(+), 20 deletions(-) diff --git a/source/g3d_viewer/main.cpp b/source/g3d_viewer/main.cpp index c65cd16c..88a16d7a 100644 --- a/source/g3d_viewer/main.cpp +++ b/source/g3d_viewer/main.cpp @@ -423,7 +423,7 @@ MainWindow::MainWindow( std::pair > unitToLoad, if(modelPath != "") { fileDialog->SetPath(ToUnicode(modelPath)); } - string userData = Config::getInstance().getString("UserData_Root",""); + string userData = config.getString("UserData_Root",""); if(userData != "") { endPathWithSlash(userData); } diff --git a/source/glest_game/facilities/components.cpp b/source/glest_game/facilities/components.cpp index 160a53bf..ceae3fb4 100644 --- a/source/glest_game/facilities/components.cpp +++ b/source/glest_game/facilities/components.cpp @@ -379,7 +379,7 @@ void GraphicListBox::init(int x, int y, int w, int h, Vec3f textColor){ } const string & GraphicListBox::getTextNativeTranslation() { - if(this->translated_items.size() == 0 || + if(this->translated_items.empty() == true || this->selectedItemIndex < 0 || this->selectedItemIndex >= this->translated_items.size() || this->items.size() != this->translated_items.size()) { diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index 3b120e55..5655c35f 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -2542,8 +2542,6 @@ void runTechTranslationExtractionForPath(string techPath, string techName, } if(factions.empty() == false) { - bool techtree_errors = false; - std::map > > loadedFileList; //vector pathList = config.getPathListForType(ptTechs,""); vector pathList; @@ -2652,12 +2650,6 @@ void runTechTranslationExtraction(int argc, char** argv) { //disableBacktrace=true; printf("====== Started Translation Extraction ======\n"); - bool purgeDuplicateFiles = false; - bool showDuplicateFiles = true; - bool purgeUnusedFiles = false; - bool svnPurgeFiles = false; - - double purgedMegaBytes=0; Config &config = Config::getInstance(); // Did the user pass a specific list of factions to validate? diff --git a/source/glest_game/menu/menu_state_about.cpp b/source/glest_game/menu/menu_state_about.cpp index 63cb19d3..16c4ad4e 100644 --- a/source/glest_game/menu/menu_state_about.cpp +++ b/source/glest_game/menu/menu_state_about.cpp @@ -40,6 +40,12 @@ MenuStateAbout::MenuStateAbout(Program *program, MainMenu *mainMenu) : adjustModelText = true; + customModTextureX = 0; + customModTextureY = 0; + customModTextureW = 0; + customModTextureH = 0; + customModTextureAlpha = 0.f; + string additionalCredits= loadAdditionalCredits(); //init diff --git a/source/glest_game/menu/menu_state_custom_game.cpp b/source/glest_game/menu/menu_state_custom_game.cpp index c6bd76eb..191439bc 100644 --- a/source/glest_game/menu/menu_state_custom_game.cpp +++ b/source/glest_game/menu/menu_state_custom_game.cpp @@ -3191,7 +3191,7 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings,bool force Lang &lang= Lang::getInstance(); gameSettings->setNetworkPlayerLanguages(slotIndex, lang.getLanguage()); } - else if(serverInterface->getSlot(i) != NULL) { + else if(serverInterface != NULL && serverInterface->getSlot(i) != NULL) { gameSettings->setNetworkPlayerLanguages(slotIndex, serverInterface->getSlot(i)->getNetworkPlayerLanguage()); } diff --git a/source/glest_game/network/network_interface.cpp b/source/glest_game/network/network_interface.cpp index db8e19ab..73edfc2f 100644 --- a/source/glest_game/network/network_interface.cpp +++ b/source/glest_game/network/network_interface.cpp @@ -56,6 +56,8 @@ void NetworkInterface::init() { networkGameDataSynchCheckOkTile=false; networkGameDataSynchCheckOkTech=false; receivedDataSynchCheck=false; + + gameSettings = GameSettings(); } NetworkInterface::~NetworkInterface() { diff --git a/source/glest_game/type_instances/faction.cpp b/source/glest_game/type_instances/faction.cpp index 6119073a..fa9879df 100644 --- a/source/glest_game/type_instances/faction.cpp +++ b/source/glest_game/type_instances/faction.cpp @@ -275,11 +275,10 @@ bool FactionThread::isSignalPathfinderCompleted(int frameIndex) { if(getRunningStatus() == false) { return true; } - bool result = false; static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__); MutexSafeWrapper safeMutex(triggerIdMutex,mutexOwnerId); //bool result = (event != NULL ? event->eventCompleted : true); - result = (this->frameIndex.first == frameIndex && this->frameIndex.second == true); + bool result = (this->frameIndex.first == frameIndex && this->frameIndex.second == true); //if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] worker thread this = %p, this->frameIndex.first = %d, this->frameIndex.second = %d\n",__FILE__,__FUNCTION__,__LINE__,this,this->frameIndex.first,this->frameIndex.second); @@ -316,11 +315,10 @@ void FactionThread::execute() { break; } - int currentTriggeredFrameIndex = 0; static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__); MutexSafeWrapper safeMutex(triggerIdMutex,mutexOwnerId); bool executeTask = (this->frameIndex.first >= 0); - currentTriggeredFrameIndex = this->frameIndex.first; + int currentTriggeredFrameIndex = this->frameIndex.first; //if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] frameIndex = %d this = %p executeTask = %d\n",__FILE__,__FUNCTION__,__LINE__,frameIndex.first, this, executeTask); @@ -482,6 +480,8 @@ void Faction::init() { control = ctClosed; overridePersonalityType = fpt_EndCount; + + upgradeManager = UpgradeManager(); } Faction::~Faction() { diff --git a/source/glest_game/type_instances/unit.cpp b/source/glest_game/type_instances/unit.cpp index 5c1509a3..4622c000 100644 --- a/source/glest_game/type_instances/unit.cpp +++ b/source/glest_game/type_instances/unit.cpp @@ -2219,7 +2219,7 @@ void Unit::updateAttackBoostProgress(const Game* game) { for(unsigned int i = 0; i < currentAttackBoostOriginatorEffect.currentAttackBoostUnits.size(); ++i) { int unitnum = currentAttackBoostOriginatorEffect.currentAttackBoostUnits[i]; - printf("affected unit #: %d - %d\n",i,unitnum); + printf("affected unit #: %u - %d\n",i,unitnum); } } } @@ -3850,10 +3850,9 @@ void Unit::logSynchDataCommon(string file,int line,string source,bool threadedMo lastFile = file; lastSource = source; - string logDataText = ""; char szBufDataText[8096]=""; snprintf(szBufDataText,8096,"----------------------------------- START [FRAME %d UNIT: %d - %s] ------------------------------------------------\n",getFrameCount(),this->id,this->getType()->getName(false).c_str()); - logDataText = szBufDataText; + string logDataText = szBufDataText; snprintf(szBufDataText,8096,"[%s::%d]\n",extractFileFromDirectoryPath(file).c_str(),line); logDataText += szBufDataText; diff --git a/source/shared_lib/sources/platform/common/platform_common.cpp b/source/shared_lib/sources/platform/common/platform_common.cpp index 68fffe47..010711df 100644 --- a/source/shared_lib/sources/platform/common/platform_common.cpp +++ b/source/shared_lib/sources/platform/common/platform_common.cpp @@ -551,7 +551,7 @@ void updatePathClimbingParts(string &path) { if(pos != string::npos && pos != 0) { string orig = path; path.erase(pos,2); - pos--; + //pos--; pos = path.find("/./"); if(pos != string::npos && pos != 0) { @@ -564,7 +564,7 @@ void updatePathClimbingParts(string &path) { if(pos != string::npos && pos != 0) { string orig = path; path.erase(pos,2); - pos--; + //pos--; pos = path.find("\\.\\"); if(pos != string::npos && pos != 0) {