added more guards and debug info related to AI bugs

This commit is contained in:
Mark Vejvoda 2010-06-10 14:58:06 +00:00
parent 6d519c4cdf
commit f5836bdf99
2 changed files with 7 additions and 3 deletions

View File

@ -246,7 +246,7 @@ CommandResult AiInterface::giveCommand(int unitIndex, const CommandType *command
sprintf(szBuf,"In [%s::%s Line: %d] Can not find AI unittype with unit index: %d, AI factionIndex = %d. Game out of synch.",__FILE__,__FUNCTION__,__LINE__,unitIndex,factionIndex);
throw runtime_error(szBuf);
}
const CommandType* ct= unit->getType()->findCommandTypeById(commandType->getId());
const CommandType* ct= (commandType != NULL ? unit->getType()->findCommandTypeById(commandType->getId()) : NULL);
if(ct == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d]\nCan not find AI command type for:\nunit = %d\n[%s]\n[%s]\nactual local factionIndex = %d.\nGame out of synch.",

View File

@ -73,8 +73,12 @@ std::string Command::toString() const {
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__, __LINE__);
std::string result = "";
result = "commandType id = " + intToStr(commandType->getId()) + ", desc = " + commandType->toString() + ", pos = " + pos.getString() + ", facing = " + intToStr(facing.asInt());
if(commandType != NULL) {
result = "commandType id = " + intToStr(commandType->getId()) + ", desc = " + commandType->toString() + ", pos = " + pos.getString() + ", facing = " + intToStr(facing.asInt());
}
else {
result = "commandType = NULL";
}
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__, __LINE__);
//if(unitRef.getUnit() != NULL) {