mirror of
https://github.com/glest/glest-source.git
synced 2025-09-26 23:49:03 +02:00
- fixed some bugs discovered by coverity scan
This commit is contained in:
@@ -622,7 +622,7 @@ const Resource *AiInterface::getResource(const ResourceType *rt){
|
|||||||
}
|
}
|
||||||
|
|
||||||
Unit *AiInterface::getMyUnitPtr(int unitIndex) {
|
Unit *AiInterface::getMyUnitPtr(int unitIndex) {
|
||||||
if(unitIndex >= world->getFaction(factionIndex)->getUnitCount()) {
|
if(unitIndex < 0 || unitIndex >= world->getFaction(factionIndex)->getUnitCount()) {
|
||||||
char szBuf[8096]="";
|
char szBuf[8096]="";
|
||||||
snprintf(szBuf,8096,"In [%s::%s Line: %d] unitIndex >= world->getFaction(factionIndex)->getUnitCount(), unitIndex = %d, world->getFaction(factionIndex)->getUnitCount() = %d",__FILE__,__FUNCTION__,__LINE__,unitIndex,world->getFaction(factionIndex)->getUnitCount());
|
snprintf(szBuf,8096,"In [%s::%s Line: %d] unitIndex >= world->getFaction(factionIndex)->getUnitCount(), unitIndex = %d, world->getFaction(factionIndex)->getUnitCount() = %d",__FILE__,__FUNCTION__,__LINE__,unitIndex,world->getFaction(factionIndex)->getUnitCount());
|
||||||
throw megaglest_runtime_error(szBuf);
|
throw megaglest_runtime_error(szBuf);
|
||||||
|
@@ -1305,125 +1305,146 @@ void AiRuleProduce::produceSpecific(const ProduceTask *pt){
|
|||||||
//besti=i%(producers.size());
|
//besti=i%(producers.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( aiInterface->getMyUnit(bestIndex)->getCommandSize() > 2) {
|
if(bestIndex >= 0) {
|
||||||
// maybe we need another producer of this kind if possible!
|
if( aiInterface->getMyUnit(bestIndex)->getCommandSize() > 2) {
|
||||||
if(aiInterface->reqsOk(aiInterface->getMyUnit(bestIndex)->getType())) {
|
// maybe we need another producer of this kind if possible!
|
||||||
if(ai->getCountOfClass(ucBuilding) > 5) {
|
if(aiInterface->reqsOk(aiInterface->getMyUnit(bestIndex)->getType())) {
|
||||||
ai->addTask(new BuildTask(aiInterface->getMyUnit(bestIndex)->getType()));
|
if(ai->getCountOfClass(ucBuilding) > 5) {
|
||||||
}
|
ai->addTask(new BuildTask(aiInterface->getMyUnit(bestIndex)->getType()));
|
||||||
}
|
|
||||||
// need to calculate another producer, maybe its better to produce another warrior with another producer
|
|
||||||
vector<int> backupProducers;
|
|
||||||
// find another producer unit which is free and produce any kind of warrior.
|
|
||||||
//for each unit
|
|
||||||
for(int i=0; i<aiInterface->getMyUnitCount(); ++i){
|
|
||||||
const UnitType *ut= aiInterface->getMyUnit(i)->getType();
|
|
||||||
//for each command
|
|
||||||
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
|
|
||||||
backupProducers.push_back(i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
// need to calculate another producer, maybe its better to produce another warrior with another producer
|
||||||
if(!backupProducers.empty()) {
|
vector<int> backupProducers;
|
||||||
int randomstart=ai->getRandom()->randRange(0, (int)backupProducers.size()-1);
|
// find another producer unit which is free and produce any kind of warrior.
|
||||||
int lowestCommandCount=1000000;
|
//for each unit
|
||||||
int currentProducerIndex=backupProducers[randomstart];
|
for(int i=0; i<aiInterface->getMyUnitCount(); ++i){
|
||||||
int bestIndex=-1;
|
const UnitType *ut= aiInterface->getMyUnit(i)->getType();
|
||||||
for(unsigned int i=randomstart; i<backupProducers.size()+randomstart; i++) {
|
//for each command
|
||||||
int prIndex = i;
|
|
||||||
if(i >= backupProducers.size()) {
|
|
||||||
prIndex = (i - (int)backupProducers.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
currentProducerIndex=backupProducers[prIndex];
|
|
||||||
|
|
||||||
if(currentProducerIndex >= aiInterface->getMyUnitCount()) {
|
|
||||||
char szBuf[8096]="";
|
|
||||||
printf("In [%s::%s Line: %d] currentProducerIndex >= aiInterface->getMyUnitCount(), currentProducerIndex = %d, aiInterface->getMyUnitCount() = %d, i = %u,backupProducers.size() = " MG_SIZE_T_SPECIFIER "\n",__FILE__,__FUNCTION__,__LINE__,currentProducerIndex,aiInterface->getMyUnitCount(),i,backupProducers.size());
|
|
||||||
snprintf(szBuf,8096,"In [%s::%s Line: %d] currentProducerIndex >= aiInterface->getMyUnitCount(), currentProducerIndex = %d, aiInterface->getMyUnitCount() = %d, i = %u,backupProducers.size() = " MG_SIZE_T_SPECIFIER "",__FILE__,__FUNCTION__,__LINE__,currentProducerIndex,aiInterface->getMyUnitCount(),i,backupProducers.size());
|
|
||||||
throw megaglest_runtime_error(szBuf);
|
|
||||||
}
|
|
||||||
if(prIndex >= (int)backupProducers.size()) {
|
|
||||||
char szBuf[8096]="";
|
|
||||||
printf("In [%s::%s Line: %d] prIndex >= backupProducers.size(), currentProducerIndex = %d, i = %u,backupProducers.size() = " MG_SIZE_T_SPECIFIER " \n",__FILE__,__FUNCTION__,__LINE__,prIndex,i,backupProducers.size());
|
|
||||||
snprintf(szBuf,8096,"In [%s::%s Line: %d] currentProducerIndex >= backupProducers.size(), currentProducerIndex = %d, i = %u,backupProducers.size() = " MG_SIZE_T_SPECIFIER "",__FILE__,__FUNCTION__,__LINE__,currentProducerIndex,i,backupProducers.size());
|
|
||||||
throw megaglest_runtime_error(szBuf);
|
|
||||||
}
|
|
||||||
|
|
||||||
int currentCommandCount=aiInterface->getMyUnit(currentProducerIndex)->getCommandSize();
|
|
||||||
if( currentCommandCount==1 &&
|
|
||||||
aiInterface->getMyUnit(currentProducerIndex)->getCurrCommand()->getCommandType()->getClass()==ccStop)
|
|
||||||
{// special for non buildings
|
|
||||||
currentCommandCount=0;
|
|
||||||
}
|
|
||||||
if(lowestCommandCount>currentCommandCount) {
|
|
||||||
lowestCommandCount=currentCommandCount;
|
|
||||||
bestIndex=currentProducerIndex;
|
|
||||||
if(lowestCommandCount==0) break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 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){
|
for(int j=0; j<ut->getCommandTypeCount(); ++j){
|
||||||
const CommandType *ct= ut->getCommandType(j);
|
const CommandType *ct= ut->getCommandType(j);
|
||||||
|
|
||||||
//if the command is produce
|
//if the command is produce
|
||||||
if(ct->getClass()==ccProduce) {
|
if(ct->getClass() == ccProduce) {
|
||||||
const UnitType *unitType= static_cast<const UnitType*>(ct->getProduced());
|
const UnitType *unitType= static_cast<const UnitType*>(ct->getProduced());
|
||||||
if(unitType->hasSkillClass(scAttack) && !unitType->hasCommandClass(ccHarvest) && aiInterface->reqsOk(ct))
|
if(unitType->hasSkillClass(scAttack) && !unitType->hasCommandClass(ccHarvest) && aiInterface->reqsOk(ct))
|
||||||
{//this can produce a warrior
|
{//this can produce a warrior
|
||||||
productionCommandIndexes.push_back(j);
|
backupProducers.push_back(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if(!backupProducers.empty()) {
|
||||||
|
int randomstart=ai->getRandom()->randRange(0, (int)backupProducers.size()-1);
|
||||||
|
int lowestCommandCount=1000000;
|
||||||
|
int currentProducerIndex=backupProducers[randomstart];
|
||||||
|
int bestIndex=-1;
|
||||||
|
for(unsigned int i=randomstart; i<backupProducers.size()+randomstart; i++) {
|
||||||
|
int prIndex = i;
|
||||||
|
if(i >= backupProducers.size()) {
|
||||||
|
prIndex = (i - (int)backupProducers.size());
|
||||||
|
}
|
||||||
|
|
||||||
int commandIndex=productionCommandIndexes[ai->getRandom()->randRange(0, (int)productionCommandIndexes.size()-1)];
|
currentProducerIndex=backupProducers[prIndex];
|
||||||
|
|
||||||
|
if(currentProducerIndex >= aiInterface->getMyUnitCount()) {
|
||||||
|
char szBuf[8096]="";
|
||||||
|
printf("In [%s::%s Line: %d] currentProducerIndex >= aiInterface->getMyUnitCount(), currentProducerIndex = %d, aiInterface->getMyUnitCount() = %d, i = %u,backupProducers.size() = " MG_SIZE_T_SPECIFIER "\n",__FILE__,__FUNCTION__,__LINE__,currentProducerIndex,aiInterface->getMyUnitCount(),i,backupProducers.size());
|
||||||
|
snprintf(szBuf,8096,"In [%s::%s Line: %d] currentProducerIndex >= aiInterface->getMyUnitCount(), currentProducerIndex = %d, aiInterface->getMyUnitCount() = %d, i = %u,backupProducers.size() = " MG_SIZE_T_SPECIFIER "",__FILE__,__FUNCTION__,__LINE__,currentProducerIndex,aiInterface->getMyUnitCount(),i,backupProducers.size());
|
||||||
|
throw megaglest_runtime_error(szBuf);
|
||||||
|
}
|
||||||
|
if(prIndex >= (int)backupProducers.size()) {
|
||||||
|
char szBuf[8096]="";
|
||||||
|
printf("In [%s::%s Line: %d] prIndex >= backupProducers.size(), currentProducerIndex = %d, i = %u,backupProducers.size() = " MG_SIZE_T_SPECIFIER " \n",__FILE__,__FUNCTION__,__LINE__,prIndex,i,backupProducers.size());
|
||||||
|
snprintf(szBuf,8096,"In [%s::%s Line: %d] currentProducerIndex >= backupProducers.size(), currentProducerIndex = %d, i = %u,backupProducers.size() = " MG_SIZE_T_SPECIFIER "",__FILE__,__FUNCTION__,__LINE__,currentProducerIndex,i,backupProducers.size());
|
||||||
|
throw megaglest_runtime_error(szBuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
int currentCommandCount=aiInterface->getMyUnit(currentProducerIndex)->getCommandSize();
|
||||||
|
if( currentCommandCount==1 &&
|
||||||
|
aiInterface->getMyUnit(currentProducerIndex)->getCurrCommand()->getCommandType()->getClass()==ccStop)
|
||||||
|
{// special for non buildings
|
||||||
|
currentCommandCount=0;
|
||||||
|
}
|
||||||
|
if(lowestCommandCount>currentCommandCount) {
|
||||||
|
lowestCommandCount=currentCommandCount;
|
||||||
|
bestIndex=currentProducerIndex;
|
||||||
|
if(lowestCommandCount==0) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 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);
|
||||||
|
|
||||||
|
//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);
|
||||||
|
}
|
||||||
|
|
||||||
|
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__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
defCt = NULL;
|
||||||
|
if(producersDefaultCommandType.find(bestIndex) != producersDefaultCommandType.end()) {
|
||||||
|
int bestCommandTypeCount = (int)producersDefaultCommandType[bestIndex].size();
|
||||||
|
int bestCommandTypeIndex = ai->getRandom()->randRange(0, bestCommandTypeCount-1);
|
||||||
|
|
||||||
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(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] bestCommandTypeIndex = %d, bestCommandTypeCount = %d\n",__FILE__,__FUNCTION__,__LINE__,bestCommandTypeIndex,bestCommandTypeCount);
|
||||||
|
|
||||||
|
defCt = producersDefaultCommandType[bestIndex][bestCommandTypeIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ai->outputAIBehaviourToConsole()) printf("mega #2 produceSpecific giveCommand to unit [%s] commandType [%s]\n",aiInterface->getMyUnit(bestIndex)->getType()->getName().c_str(),(defCt != NULL ? defCt->getName().c_str() : "n/a"));
|
||||||
if(aiInterface->isLogLevelEnabled(4) == true) {
|
if(aiInterface->isLogLevelEnabled(4) == true) {
|
||||||
char szBuf[8096]="";
|
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());
|
snprintf(szBuf,8096,"mega #2 produceSpecific giveCommand to unit [%s] commandType [%s]",aiInterface->getMyUnit(bestIndex)->getType()->getName().c_str(),(defCt != NULL ? defCt->getName().c_str() : "n/a"));
|
||||||
|
aiInterface->printLog(4, szBuf);
|
||||||
|
}
|
||||||
|
aiInterface->giveCommand(bestIndex, defCt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(currentCommandCount == 0) {
|
||||||
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
defCt = NULL;
|
||||||
|
if(producersDefaultCommandType.find(bestIndex) != producersDefaultCommandType.end()) {
|
||||||
|
//defCt = producersDefaultCommandType[bestIndex];
|
||||||
|
int bestCommandTypeCount = (int)producersDefaultCommandType[bestIndex].size();
|
||||||
|
int bestCommandTypeIndex = ai->getRandom()->randRange(0, bestCommandTypeCount-1);
|
||||||
|
|
||||||
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] bestCommandTypeIndex = %d, bestCommandTypeCount = %d\n",__FILE__,__FUNCTION__,__LINE__,bestCommandTypeIndex,bestCommandTypeCount);
|
||||||
|
|
||||||
|
defCt = producersDefaultCommandType[bestIndex][bestCommandTypeIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ai->outputAIBehaviourToConsole()) printf("mega #3 produceSpecific giveCommand to unit [%s] commandType [%s]\n",aiInterface->getMyUnit(bestIndex)->getType()->getName().c_str(),(defCt != NULL ? defCt->getName().c_str() : "n/a"));
|
||||||
|
if(aiInterface->isLogLevelEnabled(4) == true) {
|
||||||
|
char szBuf[8096]="";
|
||||||
|
snprintf(szBuf,8096,"mega #3 produceSpecific giveCommand to unit [%s] commandType [%s]",aiInterface->getMyUnit(bestIndex)->getType()->getName().c_str(),(defCt != NULL ? defCt->getName().c_str() : "n/a"));
|
||||||
aiInterface->printLog(4, szBuf);
|
aiInterface->printLog(4, szBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
aiInterface->giveCommand(bestIndex, ut->getCommandType(commandIndex));
|
aiInterface->giveCommand(bestIndex, defCt);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
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__);
|
|
||||||
defCt = NULL;
|
|
||||||
if(producersDefaultCommandType.find(bestIndex) != producersDefaultCommandType.end()) {
|
|
||||||
int bestCommandTypeCount = (int)producersDefaultCommandType[bestIndex].size();
|
|
||||||
int bestCommandTypeIndex = ai->getRandom()->randRange(0, bestCommandTypeCount-1);
|
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] bestCommandTypeIndex = %d, bestCommandTypeCount = %d\n",__FILE__,__FUNCTION__,__LINE__,bestCommandTypeIndex,bestCommandTypeCount);
|
|
||||||
|
|
||||||
defCt = producersDefaultCommandType[bestIndex][bestCommandTypeIndex];
|
|
||||||
}
|
|
||||||
|
|
||||||
if(ai->outputAIBehaviourToConsole()) printf("mega #2 produceSpecific giveCommand to unit [%s] commandType [%s]\n",aiInterface->getMyUnit(bestIndex)->getType()->getName().c_str(),(defCt != NULL ? defCt->getName().c_str() : "n/a"));
|
|
||||||
if(aiInterface->isLogLevelEnabled(4) == true) {
|
|
||||||
char szBuf[8096]="";
|
|
||||||
snprintf(szBuf,8096,"mega #2 produceSpecific giveCommand to unit [%s] commandType [%s]",aiInterface->getMyUnit(bestIndex)->getType()->getName().c_str(),(defCt != NULL ? defCt->getName().c_str() : "n/a"));
|
|
||||||
aiInterface->printLog(4, szBuf);
|
|
||||||
}
|
|
||||||
aiInterface->giveCommand(bestIndex, defCt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(currentCommandCount==0) {
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
defCt = NULL;
|
defCt = NULL;
|
||||||
if(producersDefaultCommandType.find(bestIndex) != producersDefaultCommandType.end()) {
|
if(producersDefaultCommandType.find(bestIndex) != producersDefaultCommandType.end()) {
|
||||||
@@ -1435,35 +1456,15 @@ void AiRuleProduce::produceSpecific(const ProduceTask *pt){
|
|||||||
|
|
||||||
defCt = producersDefaultCommandType[bestIndex][bestCommandTypeIndex];
|
defCt = producersDefaultCommandType[bestIndex][bestCommandTypeIndex];
|
||||||
}
|
}
|
||||||
|
if(ai->outputAIBehaviourToConsole()) printf("mega #4 produceSpecific giveCommand to unit [%s] commandType [%s]\n",aiInterface->getMyUnit(bestIndex)->getType()->getName().c_str(),(defCt != NULL ? defCt->getName().c_str() : "n/a"));
|
||||||
if(ai->outputAIBehaviourToConsole()) printf("mega #3 produceSpecific giveCommand to unit [%s] commandType [%s]\n",aiInterface->getMyUnit(bestIndex)->getType()->getName().c_str(),(defCt != NULL ? defCt->getName().c_str() : "n/a"));
|
|
||||||
if(aiInterface->isLogLevelEnabled(4) == true) {
|
if(aiInterface->isLogLevelEnabled(4) == true) {
|
||||||
char szBuf[8096]="";
|
char szBuf[8096]="";
|
||||||
snprintf(szBuf,8096,"mega #3 produceSpecific giveCommand to unit [%s] commandType [%s]",aiInterface->getMyUnit(bestIndex)->getType()->getName().c_str(),(defCt != NULL ? defCt->getName().c_str() : "n/a"));
|
snprintf(szBuf,8096,"mega #4 produceSpecific giveCommand to unit [%s] commandType [%s]",aiInterface->getMyUnit(bestIndex)->getType()->getName().c_str(),(defCt != NULL ? defCt->getName().c_str() : "n/a"));
|
||||||
aiInterface->printLog(4, szBuf);
|
aiInterface->printLog(4, szBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
aiInterface->giveCommand(bestIndex, defCt);
|
aiInterface->giveCommand(bestIndex, defCt);
|
||||||
}
|
}
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
|
||||||
defCt = NULL;
|
|
||||||
if(producersDefaultCommandType.find(bestIndex) != producersDefaultCommandType.end()) {
|
|
||||||
//defCt = producersDefaultCommandType[bestIndex];
|
|
||||||
int bestCommandTypeCount = (int)producersDefaultCommandType[bestIndex].size();
|
|
||||||
int bestCommandTypeIndex = ai->getRandom()->randRange(0, bestCommandTypeCount-1);
|
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] bestCommandTypeIndex = %d, bestCommandTypeCount = %d\n",__FILE__,__FUNCTION__,__LINE__,bestCommandTypeIndex,bestCommandTypeCount);
|
|
||||||
|
|
||||||
defCt = producersDefaultCommandType[bestIndex][bestCommandTypeIndex];
|
|
||||||
}
|
|
||||||
if(ai->outputAIBehaviourToConsole()) printf("mega #4 produceSpecific giveCommand to unit [%s] commandType [%s]\n",aiInterface->getMyUnit(bestIndex)->getType()->getName().c_str(),(defCt != NULL ? defCt->getName().c_str() : "n/a"));
|
|
||||||
if(aiInterface->isLogLevelEnabled(4) == true) {
|
|
||||||
char szBuf[8096]="";
|
|
||||||
snprintf(szBuf,8096,"mega #4 produceSpecific giveCommand to unit [%s] commandType [%s]",aiInterface->getMyUnit(bestIndex)->getType()->getName().c_str(),(defCt != NULL ? defCt->getName().c_str() : "n/a"));
|
|
||||||
aiInterface->printLog(4, szBuf);
|
|
||||||
}
|
|
||||||
|
|
||||||
aiInterface->giveCommand(bestIndex, defCt);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@@ -2012,6 +2012,9 @@ void NetworkMessageCommandList::fromEndianDetail() {
|
|||||||
// class NetworkMessageText
|
// class NetworkMessageText
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
||||||
|
NetworkMessageText::NetworkMessageText() {
|
||||||
|
messageType = nmtText;
|
||||||
|
}
|
||||||
NetworkMessageText::NetworkMessageText(const string &text, int teamIndex, int playerIndex,
|
NetworkMessageText::NetworkMessageText(const string &text, int teamIndex, int playerIndex,
|
||||||
const string targetLanguage) {
|
const string targetLanguage) {
|
||||||
if((int)text.length() >= maxTextStringSize) {
|
if((int)text.length() >= maxTextStringSize) {
|
||||||
@@ -2759,6 +2762,10 @@ void NetworkMessageSynchNetworkGameDataStatus::fromEndianDetail() {
|
|||||||
// class NetworkMessageSynchNetworkGameDataFileCRCCheck
|
// class NetworkMessageSynchNetworkGameDataFileCRCCheck
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
||||||
|
NetworkMessageSynchNetworkGameDataFileCRCCheck::NetworkMessageSynchNetworkGameDataFileCRCCheck() {
|
||||||
|
messageType= nmtSynchNetworkGameDataFileCRCCheck;
|
||||||
|
}
|
||||||
|
|
||||||
NetworkMessageSynchNetworkGameDataFileCRCCheck::NetworkMessageSynchNetworkGameDataFileCRCCheck(
|
NetworkMessageSynchNetworkGameDataFileCRCCheck::NetworkMessageSynchNetworkGameDataFileCRCCheck(
|
||||||
uint32 totalFileCount, uint32 fileIndex, uint32 fileCRC, const string fileName)
|
uint32 totalFileCount, uint32 fileIndex, uint32 fileCRC, const string fileName)
|
||||||
{
|
{
|
||||||
@@ -2872,7 +2879,9 @@ void NetworkMessageSynchNetworkGameDataFileCRCCheck::fromEndian() {
|
|||||||
// =====================================================
|
// =====================================================
|
||||||
// class NetworkMessageSynchNetworkGameDataFileGet
|
// class NetworkMessageSynchNetworkGameDataFileGet
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
NetworkMessageSynchNetworkGameDataFileGet::NetworkMessageSynchNetworkGameDataFileGet() {
|
||||||
|
messageType= nmtSynchNetworkGameDataFileGet;
|
||||||
|
}
|
||||||
NetworkMessageSynchNetworkGameDataFileGet::NetworkMessageSynchNetworkGameDataFileGet(const string fileName) {
|
NetworkMessageSynchNetworkGameDataFileGet::NetworkMessageSynchNetworkGameDataFileGet(const string fileName) {
|
||||||
messageType= nmtSynchNetworkGameDataFileGet;
|
messageType= nmtSynchNetworkGameDataFileGet;
|
||||||
data.fileName = fileName;
|
data.fileName = fileName;
|
||||||
@@ -3307,6 +3316,9 @@ void NetworkMessageLoadingStatus::fromEndian() {
|
|||||||
// =====================================================
|
// =====================================================
|
||||||
// class NetworkMessageMarkCell
|
// class NetworkMessageMarkCell
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
NetworkMessageMarkCell::NetworkMessageMarkCell() {
|
||||||
|
messageType = nmtMarkCell;
|
||||||
|
}
|
||||||
|
|
||||||
NetworkMessageMarkCell::NetworkMessageMarkCell(Vec2i target, int factionIndex, const string &text, int playerIndex) {
|
NetworkMessageMarkCell::NetworkMessageMarkCell(Vec2i target, int factionIndex, const string &text, int playerIndex) {
|
||||||
if((int)text.length() >= maxTextStringSize) {
|
if((int)text.length() >= maxTextStringSize) {
|
||||||
|
@@ -520,7 +520,7 @@ protected:
|
|||||||
virtual unsigned char * packMessage();
|
virtual unsigned char * packMessage();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NetworkMessageText(){}
|
NetworkMessageText();
|
||||||
NetworkMessageText(const string &text, int teamIndex, int playerIndex,
|
NetworkMessageText(const string &text, int teamIndex, int playerIndex,
|
||||||
const string targetLanguage);
|
const string targetLanguage);
|
||||||
|
|
||||||
@@ -793,7 +793,7 @@ protected:
|
|||||||
virtual unsigned char * packMessage();
|
virtual unsigned char * packMessage();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NetworkMessageSynchNetworkGameDataFileCRCCheck() {};
|
NetworkMessageSynchNetworkGameDataFileCRCCheck();
|
||||||
NetworkMessageSynchNetworkGameDataFileCRCCheck(uint32 totalFileCount, uint32 fileIndex, uint32 fileCRC, const string fileName);
|
NetworkMessageSynchNetworkGameDataFileCRCCheck(uint32 totalFileCount, uint32 fileIndex, uint32 fileCRC, const string fileName);
|
||||||
|
|
||||||
virtual size_t getDataSize() const { return sizeof(Data); }
|
virtual size_t getDataSize() const { return sizeof(Data); }
|
||||||
@@ -845,7 +845,7 @@ protected:
|
|||||||
virtual unsigned char * packMessage();
|
virtual unsigned char * packMessage();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NetworkMessageSynchNetworkGameDataFileGet() {};
|
NetworkMessageSynchNetworkGameDataFileGet();
|
||||||
NetworkMessageSynchNetworkGameDataFileGet(const string fileName);
|
NetworkMessageSynchNetworkGameDataFileGet(const string fileName);
|
||||||
|
|
||||||
virtual size_t getDataSize() const { return sizeof(Data); }
|
virtual size_t getDataSize() const { return sizeof(Data); }
|
||||||
@@ -1089,7 +1089,7 @@ protected:
|
|||||||
virtual unsigned char * packMessage();
|
virtual unsigned char * packMessage();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NetworkMessageMarkCell(){}
|
NetworkMessageMarkCell();
|
||||||
NetworkMessageMarkCell(Vec2i target, int factionIndex, const string &text, int playerIndex);
|
NetworkMessageMarkCell(Vec2i target, int factionIndex, const string &text, int playerIndex);
|
||||||
|
|
||||||
virtual size_t getDataSize() const { return sizeof(Data); }
|
virtual size_t getDataSize() const { return sizeof(Data); }
|
||||||
|
@@ -85,6 +85,7 @@ private:
|
|||||||
string fileName;
|
string fileName;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
OggSoundFileLoader();
|
||||||
virtual void open(const string &path, SoundInfo *soundInfo);
|
virtual void open(const string &path, SoundInfo *soundInfo);
|
||||||
virtual uint32 read(int8 *samples, uint32 size);
|
virtual uint32 read(int8 *samples, uint32 size);
|
||||||
virtual void close();
|
virtual void close();
|
||||||
|
@@ -254,6 +254,9 @@ int zipfile_tool(int argc, const char *argv[]) {
|
|||||||
uint n = BUF_SIZE - stream.avail_out;
|
uint n = BUF_SIZE - stream.avail_out;
|
||||||
if (fwrite(s_outbuf, 1, n, pOutfile) != n) {
|
if (fwrite(s_outbuf, 1, n, pOutfile) != n) {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Failed writing to output file!\n");
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Failed writing to output file!\n");
|
||||||
|
|
||||||
|
if(pInfile) fclose(pInfile);
|
||||||
|
if(pOutfile) fclose(pOutfile);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
stream.next_out = s_outbuf;
|
stream.next_out = s_outbuf;
|
||||||
|
@@ -107,7 +107,7 @@ public:
|
|||||||
base_thread->signalQuit();
|
base_thread->signalQuit();
|
||||||
sleep(10);
|
sleep(10);
|
||||||
|
|
||||||
if(Thread::getEnableVerboseMode()) printf("!!!! cleanupPendingThread Line: %d thread = %p [%s]\n",__LINE__,thread,(base_thread != NULL ? base_thread->getUniqueID().c_str() : "n/a"));
|
if(Thread::getEnableVerboseMode()) printf("!!!! cleanupPendingThread Line: %d thread = %p [%s]\n",__LINE__,thread,base_thread->getUniqueID().c_str());
|
||||||
|
|
||||||
if(base_thread->getRunningStatus() == true || base_thread->getExecutingTask() == true) {
|
if(base_thread->getRunningStatus() == true || base_thread->getExecutingTask() == true) {
|
||||||
|
|
||||||
|
@@ -201,6 +201,11 @@ void WavSoundFileLoader::restart(){
|
|||||||
// Ogg Sound File Loader
|
// Ogg Sound File Loader
|
||||||
// =======================================
|
// =======================================
|
||||||
|
|
||||||
|
OggSoundFileLoader::OggSoundFileLoader() {
|
||||||
|
vf = NULL;
|
||||||
|
f = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void OggSoundFileLoader::open(const string &path, SoundInfo *soundInfo){
|
void OggSoundFileLoader::open(const string &path, SoundInfo *soundInfo){
|
||||||
fileName = path;
|
fileName = path;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user