petra: reset some collections only if needed

This was SVN commit r18531.
This commit is contained in:
mimo 2016-07-19 17:26:03 +00:00
parent a498d18738
commit 01ff2fb0e0
2 changed files with 6 additions and 3 deletions

View File

@ -172,13 +172,13 @@ m.SharedScript.prototype.init = function(state, deserialization)
this._entities.set(+id, new m.Entity(this, state.entities[id]));
// entity collection updated on create/destroy event.
this.entities = new m.EntityCollection(this, this._entities);
// create the terrain analyzer
this.terrainAnalyzer = new m.TerrainAnalysis();
this.terrainAnalyzer.init(this, state);
this.accessibility = new m.Accessibility();
this.accessibility.init(state, this.terrainAnalyzer);
// Setup resources
this.resourceTypes = { "food": 0, "wood": 1, "stone": 2, "metal": 2 };
this.resourceList = [];

View File

@ -131,10 +131,13 @@ m.HQ.prototype.checkEvents = function (gameState, events, queues)
if (events.TerritoriesChanged.length || events.DiplomacyChanged.length)
this.updateTerritories(gameState);
if (events.DiplomacyChanged.length)
for (let evt of events.DiplomacyChanged)
{
if (evt.player !== PlayerID && evt.otherPlayer !== PlayerID)
continue;
gameState.resetAllyStructures();
gameState.resetEnemyStructures();
break;
}
for (let evt of events.Create)