mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-16 05:13:58 -07:00
Don't write entity-metadata when deserializing
The metadata where written every the turn of deserialization. When on the non rejoining client it was only written when that AI makes a turn and handles the events.
This commit is contained in:
parent
55f2d356ff
commit
2f86d4a2f8
3 changed files with 16 additions and 12 deletions
|
|
@ -114,7 +114,7 @@ BaseManager.prototype.assignEntity = function(gameState, ent)
|
|||
this.assignResourceToDropsite(gameState, ent, false);
|
||||
};
|
||||
|
||||
BaseManager.prototype.setAnchor = function(gameState, anchorEntity)
|
||||
BaseManager.prototype.setAnchor = function(gameState, anchorEntity, deserialize = false)
|
||||
{
|
||||
if (!anchorEntity.hasClass("CivCentre"))
|
||||
{
|
||||
|
|
@ -125,10 +125,12 @@ BaseManager.prototype.setAnchor = function(gameState, anchorEntity)
|
|||
{
|
||||
this.anchor = anchorEntity;
|
||||
this.anchorId = anchorEntity.id();
|
||||
this.anchor.setMetadata(PlayerID, "baseAnchor", true);
|
||||
if (!deserialize)
|
||||
this.anchor.setMetadata(PlayerID, "baseAnchor", true);
|
||||
this.basesManager.resetBaseCache();
|
||||
}
|
||||
anchorEntity.setMetadata(PlayerID, "base", this.ID);
|
||||
if (!deserialize)
|
||||
anchorEntity.setMetadata(PlayerID, "base", this.ID);
|
||||
this.buildings.updateEnt(anchorEntity);
|
||||
this.accessIndex = getLandAccess(gameState, anchorEntity);
|
||||
return true;
|
||||
|
|
@ -144,7 +146,7 @@ BaseManager.prototype.anchorLost = function(gameState)
|
|||
};
|
||||
|
||||
/** Set a building of an anchorless base */
|
||||
BaseManager.prototype.setAnchorlessEntity = function(gameState, ent)
|
||||
BaseManager.prototype.setAnchorlessEntity = function(gameState, ent, deserialize = false)
|
||||
{
|
||||
if (!this.buildings.hasEntities())
|
||||
{
|
||||
|
|
@ -162,7 +164,8 @@ BaseManager.prototype.setAnchorlessEntity = function(gameState, ent)
|
|||
getLandAccess(gameState, ent));
|
||||
}
|
||||
|
||||
ent.setMetadata(PlayerID, "base", this.ID);
|
||||
if (!deserialize)
|
||||
ent.setMetadata(PlayerID, "base", this.ID);
|
||||
this.buildings.updateEnt(ent);
|
||||
return true;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ export function BasesManager(Config)
|
|||
this.baseManagers = [];
|
||||
}
|
||||
|
||||
BasesManager.prototype.init = function(gameState)
|
||||
BasesManager.prototype.init = function(gameState, deserialize = false)
|
||||
{
|
||||
// Initialize base map. Each pixel is a base ID, or 0 if not or not accessible.
|
||||
this.basesMap = new InfoMap(gameState.sharedScript, "territory");
|
||||
|
|
@ -38,9 +38,9 @@ BasesManager.prototype.init = function(gameState)
|
|||
|
||||
for (const cc of gameState.getOwnStructures().filter(filters.byClass("CivCentre")).values())
|
||||
if (cc.foundationProgress() === undefined)
|
||||
this.createBase(gameState, cc, BaseManager.STATE_WITH_ANCHOR);
|
||||
this.createBase(gameState, cc, BaseManager.STATE_WITH_ANCHOR, deserialize);
|
||||
else
|
||||
this.createBase(gameState, cc, BaseManager.STATE_UNCONSTRUCTED);
|
||||
this.createBase(gameState, cc, BaseManager.STATE_UNCONSTRUCTED, deserialize);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -73,7 +73,8 @@ BasesManager.prototype.postinit = function(gameState)
|
|||
* Otherwise create a new one.
|
||||
* TODO when buildings, criteria should depend on distance
|
||||
*/
|
||||
BasesManager.prototype.createBase = function(gameState, ent, type = BaseManager.STATE_WITH_ANCHOR)
|
||||
BasesManager.prototype.createBase = function(gameState, ent, type = BaseManager.STATE_WITH_ANCHOR,
|
||||
deserialize = false)
|
||||
{
|
||||
const access = getLandAccess(gameState, ent);
|
||||
let newbase;
|
||||
|
|
@ -120,9 +121,9 @@ BasesManager.prototype.createBase = function(gameState, ent, type = BaseManager.
|
|||
newbase.reset(type);
|
||||
|
||||
if (type !== BaseManager.STATE_ANCHORLESS)
|
||||
newbase.setAnchor(gameState, ent);
|
||||
newbase.setAnchor(gameState, ent, deserialize);
|
||||
else
|
||||
newbase.setAnchorlessEntity(gameState, ent);
|
||||
newbase.setAnchorlessEntity(gameState, ent, deserialize);
|
||||
|
||||
return newbase;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2416,7 +2416,7 @@ Headquarters.prototype.Deserialize = function(gameState, data)
|
|||
|
||||
|
||||
this.basesManager = new BasesManager(this.Config);
|
||||
this.basesManager.init(gameState);
|
||||
this.basesManager.init(gameState, true);
|
||||
this.basesManager.Deserialize(gameState, data.basesManager);
|
||||
|
||||
this.navalManager = new NavalManager(this.Config);
|
||||
|
|
|
|||
Loading…
Reference in a new issue