From 3ea6a02d9512a9f2d50e87fe47ff8ecaf8e5cfed Mon Sep 17 00:00:00 2001 From: Titus Tscharntke Date: Tue, 5 Feb 2013 22:00:50 +0000 Subject: [PATCH] no return in void methods --- source/glest_game/ai/ai.cpp | 50 +++++++++++++++-------- source/glest_game/game/script_manager.cpp | 4 +- 2 files changed, 35 insertions(+), 19 deletions(-) diff --git a/source/glest_game/ai/ai.cpp b/source/glest_game/ai/ai.cpp index c2d7b4ba..4c5e439c 100644 --- a/source/glest_game/ai/ai.cpp +++ b/source/glest_game/ai/ai.cpp @@ -736,23 +736,23 @@ void Ai::sendScoutPatrol(){ bool megaResourceAttack=(aiInterface->getControlType() == ctCpuMega || aiInterface->getControlType() == ctNetworkCpuMega) && random.randRange(0, 1) == 1; - std::vector warningEnemyList = aiInterface->getEnemyWarningPositionList(); - if(warningEnemyList.empty() == false) { - // Randomly check the enemy warning location list - if(random.randRange(0, 1) == 1) { - //for(int i = warningEnemyList.size() - 1; i <= 0; --i) { - - // randomly pick a location from the location list - int i = random.randRange(0, warningEnemyList.size() - 1); - - Vec2i &checkPos = warningEnemyList[i]; - pos = checkPos; - possibleTargetFound = true; - aiInterface->removeEnemyWarningPositionFromList(checkPos); - // break; - //} - } - } +// std::vector warningEnemyList = aiInterface->getEnemyWarningPositionList(); +// if(warningEnemyList.empty() == false) { +// // Randomly check the enemy warning location list +// if(random.randRange(0, 1) == 1) { +// //for(int i = warningEnemyList.size() - 1; i <= 0; --i) { +// +// // randomly pick a location from the location list +// int i = random.randRange(0, warningEnemyList.size() - 1); +// +// Vec2i &checkPos = warningEnemyList[i]; +// pos = checkPos; +// possibleTargetFound = true; +// aiInterface->removeEnemyWarningPositionFromList(checkPos); +// // break; +// //} +// } +// } if(possibleTargetFound == false && (megaResourceAttack || ultraResourceAttack)) { Map *map= aiInterface->getMap(); @@ -794,6 +794,22 @@ void Ai::sendScoutPatrol(){ //else printf("is outside map\n"); } } + + std::vector warningEnemyList = aiInterface->getEnemyWarningPositionList(); + if( (possibleTargetFound == false) && (warningEnemyList.empty() == false)) { + for(int i = warningEnemyList.size() - 1; i <= 0; --i) { + Vec2i &checkPos = warningEnemyList[i]; + if (random.randRange(0, 1) == 1 ) { + pos = checkPos; + possibleTargetFound = true; + warningEnemyList.clear(); + } else { + aiInterface->removeEnemyWarningPositionFromList(checkPos); + } + break; + } + } + if(possibleTargetFound == false){ startLoc= (startLoc + 1) % aiInterface->getMapMaxPlayers(); pos= aiInterface->getStartLocation(startLoc); diff --git a/source/glest_game/game/script_manager.cpp b/source/glest_game/game/script_manager.cpp index 79de8173..be81d98a 100644 --- a/source/glest_game/game/script_manager.cpp +++ b/source/glest_game/game/script_manager.cpp @@ -1496,7 +1496,7 @@ void ScriptManager::setUnitPosition(int unitId, Vec2i pos) { void ScriptManager::addCellMarker(Vec2i pos, int factionIndex, const string ¬e, const string &textureFile) { if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); ScriptManager_STREFLOP_Wrapper streflopWrapper; - return world->addCellMarker(pos,factionIndex, note, textureFile); + world->addCellMarker(pos,factionIndex, note, textureFile); } void ScriptManager::removeCellMarker(Vec2i pos, int factionIndex) { @@ -1508,7 +1508,7 @@ void ScriptManager::removeCellMarker(Vec2i pos, int factionIndex) { void ScriptManager::showMarker(Vec2i pos, int factionIndex, const string ¬e, const string &textureFile, int flashCount) { if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); ScriptManager_STREFLOP_Wrapper streflopWrapper; - return world->showMarker(pos,factionIndex, note, textureFile, flashCount); + world->showMarker(pos,factionIndex, note, textureFile, flashCount); } int ScriptManager::getIsUnitAlive(int unitId) {