- added a VERY IMPORTANT synch check in order to find unit id mismatch

This commit is contained in:
Mark Vejvoda 2010-05-29 08:23:52 +00:00
parent b31531db1f
commit 9159d44b7a
2 changed files with 14 additions and 0 deletions

View File

@ -395,6 +395,18 @@ Command* Commander::buildCommand(const NetworkCommand* networkCommand) const{
throw runtime_error(szBuf);
}
if(unit->getFaction()->getIndex() != networkCommand->getUnitFactionIndex()) {
char szBuf[1024]="";
sprintf(szBuf,"In [%s::%s Line: %d]\nUnit / Faction mismatch for network command = [%s]\n%s\nfor unit = %d\n[%s]\n[%s]\nactual local factionIndex = %d.\nGame out of synch.",
__FILE__,__FUNCTION__,__LINE__,networkCommand->toString().c_str(),unit->getType()->getCommandTypeListDesc().c_str(),unit->getId(), unit->getFullName().c_str(),unit->getDesc().c_str(),unit->getFaction()->getIndex());
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n",szBuf);
std::string worldLog = world->DumpWorldToLog();
std::string sError = "worldLog = " + worldLog + " " + string(szBuf);
throw runtime_error(sError);
}
const UnitType* unitType= world->findUnitTypeById(unit->getFaction()->getType(), networkCommand->getUnitTypeId());
ct= unit->getType()->findCommandTypeById(networkCommand->getCommandTypeId());

View File

@ -95,6 +95,8 @@ public:
int getTargetId() const {return targetId;}
int getWantQueue() const {return wantQueue;}
int getFromFactionIndex() const {return fromFactionIndex;}
int getUnitFactionUnitCount() const {return unitFactionUnitCount;}
int getUnitFactionIndex() const {return unitFactionIndex;}
void preprocessNetworkCommand(World *world);
string toString() const;