fix a few areas that vc++ 2012 pointed to as potential bugs

This commit is contained in:
Mark Vejvoda 2013-06-08 03:40:04 +00:00
parent 8d2e812dc8
commit 8066502f9b
3 changed files with 14 additions and 7 deletions

View File

@ -1090,10 +1090,10 @@ void AiRuleProduce::produceSpecific(const ProduceTask *pt){
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->getName().c_str());
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->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);
@ -1114,10 +1114,10 @@ void AiRuleProduce::produceSpecific(const ProduceTask *pt){
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->getName().c_str());
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->getName().c_str());
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);
}
@ -1134,10 +1134,10 @@ void AiRuleProduce::produceSpecific(const ProduceTask *pt){
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->getName().c_str());
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->getName().c_str());
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);
}

View File

@ -617,6 +617,9 @@ void Program::setState(ProgramState *programStateNew, bool cleanupOldState) {
this->programState= programStateNew;
assert(programStateNew != NULL);
if(programStateNew == NULL) {
throw megaglest_runtime_error("programStateNew == NULL");
}
programStateNew->load();
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);

View File

@ -1772,7 +1772,7 @@ void UnitUpdater::updateRepair(Unit *unit, int frameIndex) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] rct = %p\n",__FILE__,__FUNCTION__,__LINE__,rct);
Unit *repaired = (command != NULL ? map->getCell(command->getPos())->getUnitWithEmptyCellMap(fLand) : NULL);
if(repaired == NULL) {
if(repaired == NULL && command != NULL) {
repaired = map->getCell(command->getPos())->getUnit(fLand);
}
@ -1891,6 +1891,10 @@ void UnitUpdater::updateRepair(Unit *unit, int frameIndex) {
if(unit->getCurrSkill()->getClass() != scRepair ||
(nextToRepaired == false && peerUnitBuilder == NULL)) {
if(command == NULL) {
throw megaglest_runtime_error("command == NULL");
}
Vec2i repairPos = command->getPos();
bool startRepairing = (repaired != NULL && rct->isRepairableUnitType(repaired->getType()) && repaired->isDamaged());