forked from 0ad/0ad
Fix counting of arrows in buildings: don't remove entities twice from the garrisonholder. Fixes #3846
This was SVN commit r17938.
This commit is contained in:
parent
e7deb587bb
commit
63d276b73b
@ -257,15 +257,10 @@ BuildingAI.prototype.GetGarrisonArrowClasses = function()
|
||||
*/
|
||||
BuildingAI.prototype.GetArrowCount = function()
|
||||
{
|
||||
let count = this.GetDefaultArrowCount();
|
||||
let count = this.GetDefaultArrowCount() +
|
||||
Math.round(this.archersGarrisoned * this.GetGarrisonArrowMultiplier());
|
||||
|
||||
let cmpGarrisonHolder = Engine.QueryInterface(this.entity, IID_GarrisonHolder);
|
||||
if (cmpGarrisonHolder)
|
||||
count += Math.round(this.archersGarrisoned * this.GetGarrisonArrowMultiplier());
|
||||
|
||||
if (this.GetMaxArrowCount() < count)
|
||||
return this.GetMaxArrowCount();
|
||||
return count;
|
||||
return Math.min(this.GetMaxArrowCount(), count);
|
||||
};
|
||||
|
||||
BuildingAI.prototype.SetUnitAITarget = function(ent)
|
||||
|
@ -698,6 +698,7 @@ GarrisonHolder.prototype.EjectOrKill = function(entities)
|
||||
}
|
||||
|
||||
// And destroy all remaining entities
|
||||
var killedEntities = [];
|
||||
for each (var entity in entities)
|
||||
{
|
||||
var entityIndex = this.entities.indexOf(entity);
|
||||
@ -707,9 +708,11 @@ GarrisonHolder.prototype.EjectOrKill = function(entities)
|
||||
if (cmpHealth)
|
||||
cmpHealth.Kill();
|
||||
this.entities.splice(entityIndex, 1);
|
||||
killedEntities.push(entity);
|
||||
}
|
||||
|
||||
Engine.PostMessage(this.entity, MT_GarrisonedUnitsChanged, { "added" : [], "removed" : entities });
|
||||
if (killedEntities.length > 0)
|
||||
Engine.PostMessage(this.entity, MT_GarrisonedUnitsChanged, { "added" : [], "removed" : killedEntities });
|
||||
this.UpdateGarrisonFlag();
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user