- updated unitid offset for each faction so that we support up to 100,000 units per faction per game (which is larger than previously supported)

This commit is contained in:
Mark Vejvoda 2010-05-31 09:45:54 +00:00
parent 8ea52485cc
commit fc63460e07
2 changed files with 9 additions and 3 deletions

View File

@ -61,12 +61,12 @@ enum NetworkCommandType {
class NetworkCommand{
private:
int16 networkCommandType;
int16 unitId;
int32 unitId;
int16 commandTypeId;
int16 positionX;
int16 positionY;
int16 unitTypeId;
int16 targetId;
int32 targetId;
int16 wantQueue;
int16 fromFactionIndex;
int16 unitFactionUnitCount;

View File

@ -814,9 +814,15 @@ void World::computeFow(){
}
}
// WARNING! This id is critical! MAke sure it fits inside the network packet
// (currently cannot be larger than 2,147,483,647)
// Make sure each faction has their own unique section of id #'s for proper
// multi-platform play
// Calculates the unit unit ID for each faction
//
int World::getNextUnitId(Faction *faction) {
if(mapFactionNextUnitId.find(faction->getIndex()) == mapFactionNextUnitId.end()) {
mapFactionNextUnitId[faction->getIndex()] = faction->getIndex() * 3000;
mapFactionNextUnitId[faction->getIndex()] = faction->getIndex() * 100000;
}
return mapFactionNextUnitId[faction->getIndex()]++;
}