diff --git a/source/glest_game/game/commander.cpp b/source/glest_game/game/commander.cpp index bc14add5..0f8c8ddd 100644 --- a/source/glest_game/game/commander.cpp +++ b/source/glest_game/game/commander.cpp @@ -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()); diff --git a/source/glest_game/network/network_types.h b/source/glest_game/network/network_types.h index 997b1f86..e9e27c52 100644 --- a/source/glest_game/network/network_types.h +++ b/source/glest_game/network/network_types.h @@ -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;