petra: take into account possible upgrade in garrison manager

This was SVN commit r18883.
This commit is contained in:
mimo
2016-10-28 18:04:52 +00:00
parent 4898e94c81
commit 0c8c879ed1
@@ -17,6 +17,27 @@ m.GarrisonManager = function()
m.GarrisonManager.prototype.update = function(gameState, events)
{
// First check for possible upgrade of a structure
for (let evt of events.EntityRenamed)
{
for (let id of this.holders.keys())
{
if (id !== evt.entity)
continue;
let list = this.holders.get(id);
this.holders.delete(id);
this.holders.set(evt.newentity, list);
}
for (let id of this.decayingStructures.keys())
{
if (id !== evt.entity)
continue;
let gmin = this.decayingStructures.get(id);
this.decayingStructures.delete(id);
this.decayingStructures.set(evt.newentity, gmin);
}
}
for (let [id, list] of this.holders.entries())
{
let holder = gameState.getEntityById(id);