- some bug fixes based on coverity scan
This commit is contained in:
parent
e7eddca1ee
commit
7e0494bb28
|
@ -1 +1 @@
|
|||
Subproject commit ad32e03df80206332f3438b4008026faa3aac97e
|
||||
Subproject commit bf04854ade7cd0fc51483c857e590acfef4fbc26
|
|
@ -977,7 +977,7 @@ void Ai::massiveAttack(const Vec2i &pos, Field field, bool ultraAttack){
|
|||
void Ai::returnBase(int unitIndex) {
|
||||
Vec2i pos;
|
||||
//std::pair<CommandResult,string> r(crFailUndefined,"");
|
||||
aiInterface->getFactionIndex();
|
||||
//aiInterface->getFactionIndex();
|
||||
pos= Vec2i(
|
||||
random.randRange(-villageRadius, villageRadius),
|
||||
random.randRange(-villageRadius, villageRadius)) +
|
||||
|
|
|
@ -1371,30 +1371,33 @@ void AiRuleProduce::produceSpecific(const ProduceTask *pt){
|
|||
}
|
||||
// a good producer is found, lets choose a warrior production
|
||||
vector<int> productionCommandIndexes;
|
||||
const UnitType *ut=aiInterface->getMyUnit(bestIndex)->getType();
|
||||
for(int j=0; j<ut->getCommandTypeCount(); ++j){
|
||||
const CommandType *ct= ut->getCommandType(j);
|
||||
if(bestIndex >= 0) {
|
||||
const UnitType *ut=aiInterface->getMyUnit(bestIndex)->getType();
|
||||
for(int j=0; j<ut->getCommandTypeCount(); ++j){
|
||||
const CommandType *ct= ut->getCommandType(j);
|
||||
|
||||
//if the command is produce
|
||||
if(ct->getClass()==ccProduce) {
|
||||
const UnitType *unitType= static_cast<const UnitType*>(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<const UnitType*>(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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -247,8 +247,8 @@ void Thread::start() {
|
|||
|
||||
BaseThread *base_thread = dynamic_cast<BaseThread *>(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);
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue