diff --git a/data/glest_game b/data/glest_game index ad32e03df..bf04854ad 160000 --- a/data/glest_game +++ b/data/glest_game @@ -1 +1 @@ -Subproject commit ad32e03df80206332f3438b4008026faa3aac97e +Subproject commit bf04854ade7cd0fc51483c857e590acfef4fbc26 diff --git a/source/glest_game/ai/ai.cpp b/source/glest_game/ai/ai.cpp index 1ba96b7a0..8682c4d28 100644 --- a/source/glest_game/ai/ai.cpp +++ b/source/glest_game/ai/ai.cpp @@ -977,7 +977,7 @@ void Ai::massiveAttack(const Vec2i &pos, Field field, bool ultraAttack){ void Ai::returnBase(int unitIndex) { Vec2i pos; //std::pair r(crFailUndefined,""); - aiInterface->getFactionIndex(); + //aiInterface->getFactionIndex(); pos= Vec2i( random.randRange(-villageRadius, villageRadius), random.randRange(-villageRadius, villageRadius)) + diff --git a/source/glest_game/ai/ai_rule.cpp b/source/glest_game/ai/ai_rule.cpp index e56a9106a..3ac7e192f 100644 --- a/source/glest_game/ai/ai_rule.cpp +++ b/source/glest_game/ai/ai_rule.cpp @@ -1371,30 +1371,33 @@ void AiRuleProduce::produceSpecific(const ProduceTask *pt){ } // a good producer is found, lets choose a warrior production vector productionCommandIndexes; - const UnitType *ut=aiInterface->getMyUnit(bestIndex)->getType(); - for(int j=0; jgetCommandTypeCount(); ++j){ - const CommandType *ct= ut->getCommandType(j); + if(bestIndex >= 0) { + const UnitType *ut=aiInterface->getMyUnit(bestIndex)->getType(); + for(int j=0; jgetCommandTypeCount(); ++j){ + const CommandType *ct= ut->getCommandType(j); - //if the command is produce - if(ct->getClass()==ccProduce) { - const UnitType *unitType= static_cast(ct->getProduced()); - if(unitType->hasSkillClass(scAttack) && !unitType->hasCommandClass(ccHarvest) && aiInterface->reqsOk(ct)) - {//this can produce a warrior - productionCommandIndexes.push_back(j); + //if the command is produce + if(ct->getClass()==ccProduce) { + const UnitType *unitType= static_cast(ct->getProduced()); + if(unitType->hasSkillClass(scAttack) && !unitType->hasCommandClass(ccHarvest) && aiInterface->reqsOk(ct)) + {//this can produce a warrior + productionCommandIndexes.push_back(j); + } } } - } - int commandIndex=productionCommandIndexes[ai->getRandom()->randRange(0, (int)productionCommandIndexes.size()-1)]; - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - if(ai->outputAIBehaviourToConsole()) printf("mega #1 produceSpecific giveCommand to unit [%s] commandType [%s]\n",aiInterface->getMyUnit(bestIndex)->getType()->getName().c_str(),ut->getCommandType(commandIndex)->getName().c_str()); - if(aiInterface->isLogLevelEnabled(4) == true) { - char szBuf[8096]=""; - snprintf(szBuf,8096,"mega #1 produceSpecific giveCommand to unit [%s] commandType [%s]",aiInterface->getMyUnit(bestIndex)->getType()->getName().c_str(),ut->getCommandType(commandIndex)->getName().c_str()); - aiInterface->printLog(4, szBuf); - } + int commandIndex=productionCommandIndexes[ai->getRandom()->randRange(0, (int)productionCommandIndexes.size()-1)]; + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - aiInterface->giveCommand(bestIndex, ut->getCommandType(commandIndex)); + if(ai->outputAIBehaviourToConsole()) printf("mega #1 produceSpecific giveCommand to unit [%s] commandType [%s]\n",aiInterface->getMyUnit(bestIndex)->getType()->getName().c_str(),ut->getCommandType(commandIndex)->getName().c_str()); + if(aiInterface->isLogLevelEnabled(4) == true) { + char szBuf[8096]=""; + snprintf(szBuf,8096,"mega #1 produceSpecific giveCommand to unit [%s] commandType [%s]",aiInterface->getMyUnit(bestIndex)->getType()->getName().c_str(),ut->getCommandType(commandIndex)->getName().c_str()); + aiInterface->printLog(4, szBuf); + } + + aiInterface->giveCommand(bestIndex, ut->getCommandType(commandIndex)); + } } else {// do it like normal CPU diff --git a/source/shared_lib/sources/platform/sdl/platform_util.cpp b/source/shared_lib/sources/platform/sdl/platform_util.cpp index 753d6707c..3f34e1a18 100644 --- a/source/shared_lib/sources/platform/sdl/platform_util.cpp +++ b/source/shared_lib/sources/platform/sdl/platform_util.cpp @@ -48,42 +48,50 @@ const char * getDialogCommand() { file = popen("which zenity","r"); //printf("File #1 [%p]\n",file); - if (fgets(file_string, 100, file) != NULL ) { - pclose(file); - return "zenity"; - } - else if (file != NULL) { - pclose(file); + if (file != NULL) { + if (fgets(file_string, 100, file) != NULL ) { + pclose(file); + return "zenity"; + } + else { + pclose(file); + } } file = popen("which kdialog","r"); //printf("File #2 [%p]\n",file); - if (fgets(file_string, 100, file) != NULL ) { - pclose(file); - return "kdialog"; - } - else if (file != NULL) { - pclose(file); + if (file != NULL) { + if (fgets(file_string, 100, file) != NULL ) { + pclose(file); + return "kdialog"; + } + else { + pclose(file); + } } file = popen("which yad","r"); //printf("File #3 [%p]\n",file); - if (fgets(file_string, 100, file) != NULL ) { - pclose(file); - return "yad"; - } - else if (file != NULL) { - pclose(file); + if (file != NULL) { + if (fgets(file_string, 100, file) != NULL ) { + pclose(file); + return "yad"; + } + else { + pclose(file); + } } file = popen("which gdialog","r"); //printf("File #4 [%p]\n",file); - if (fgets(file_string, 100, file) != NULL ) { - pclose(file); - return "gdialog"; - } - else if (file != NULL) { - pclose(file); + if (file != NULL) { + if (fgets(file_string, 100, file) != NULL ) { + pclose(file); + return "gdialog"; + } + else { + pclose(file); + } } return NULL; diff --git a/source/shared_lib/sources/platform/sdl/thread.cpp b/source/shared_lib/sources/platform/sdl/thread.cpp index 97786c564..06f0b7e2b 100644 --- a/source/shared_lib/sources/platform/sdl/thread.cpp +++ b/source/shared_lib/sources/platform/sdl/thread.cpp @@ -247,8 +247,8 @@ void Thread::start() { BaseThread *base_thread = dynamic_cast(this); if(base_thread) base_thread->setStarted(true); - - thread = SDL_CreateThread(beginExecution, base_thread->getUniqueID().c_str(), this); + string uniqueId = base_thread->getUniqueID(); + thread = SDL_CreateThread(beginExecution, uniqueId.c_str(), this); if(thread == NULL) { if(base_thread) base_thread->setStarted(false); diff --git a/source/shared_lib/sources/platform/sdl/window.cpp b/source/shared_lib/sources/platform/sdl/window.cpp index 4412060cb..de57f7963 100644 --- a/source/shared_lib/sources/platform/sdl/window.cpp +++ b/source/shared_lib/sources/platform/sdl/window.cpp @@ -656,10 +656,6 @@ void Window::handleMouseWheel(SDL_Event event) { // // movement is 120. eventMouseWheel(x, y, event.wheel.y * 120); return; - - if (SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) - SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); - } void Window::handleMouseDown(SDL_Event event) {