mirror of
https://github.com/glest/glest-source.git
synced 2025-08-24 00:42:50 +02:00
- some bug fixes based on coverity scan
This commit is contained in:
Submodule data/glest_game updated: ad32e03df8...bf04854ade
@@ -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,6 +1371,7 @@ void AiRuleProduce::produceSpecific(const ProduceTask *pt){
|
||||
}
|
||||
// a good producer is found, lets choose a warrior production
|
||||
vector<int> productionCommandIndexes;
|
||||
if(bestIndex >= 0) {
|
||||
const UnitType *ut=aiInterface->getMyUnit(bestIndex)->getType();
|
||||
for(int j=0; j<ut->getCommandTypeCount(); ++j){
|
||||
const CommandType *ct= ut->getCommandType(j);
|
||||
@@ -1384,6 +1385,7 @@ void AiRuleProduce::produceSpecific(const ProduceTask *pt){
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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__);
|
||||
|
||||
@@ -1396,6 +1398,7 @@ void AiRuleProduce::produceSpecific(const ProduceTask *pt){
|
||||
|
||||
aiInterface->giveCommand(bestIndex, ut->getCommandType(commandIndex));
|
||||
}
|
||||
}
|
||||
else
|
||||
{// do it like normal CPU
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
@@ -48,43 +48,51 @@ const char * getDialogCommand() {
|
||||
|
||||
file = popen("which zenity","r");
|
||||
//printf("File #1 [%p]\n",file);
|
||||
if (file != NULL) {
|
||||
if (fgets(file_string, 100, file) != NULL ) {
|
||||
pclose(file);
|
||||
return "zenity";
|
||||
}
|
||||
else if (file != NULL) {
|
||||
else {
|
||||
pclose(file);
|
||||
}
|
||||
}
|
||||
|
||||
file = popen("which kdialog","r");
|
||||
//printf("File #2 [%p]\n",file);
|
||||
if (file != NULL) {
|
||||
if (fgets(file_string, 100, file) != NULL ) {
|
||||
pclose(file);
|
||||
return "kdialog";
|
||||
}
|
||||
else if (file != NULL) {
|
||||
else {
|
||||
pclose(file);
|
||||
}
|
||||
}
|
||||
|
||||
file = popen("which yad","r");
|
||||
//printf("File #3 [%p]\n",file);
|
||||
if (file != NULL) {
|
||||
if (fgets(file_string, 100, file) != NULL ) {
|
||||
pclose(file);
|
||||
return "yad";
|
||||
}
|
||||
else if (file != NULL) {
|
||||
else {
|
||||
pclose(file);
|
||||
}
|
||||
}
|
||||
|
||||
file = popen("which gdialog","r");
|
||||
//printf("File #4 [%p]\n",file);
|
||||
if (file != NULL) {
|
||||
if (fgets(file_string, 100, file) != NULL ) {
|
||||
pclose(file);
|
||||
return "gdialog";
|
||||
}
|
||||
else if (file != NULL) {
|
||||
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) {
|
||||
|
Reference in New Issue
Block a user