forked from 0ad/0ad
[PetraAI] - Fix resources (dead animals) coming in the defense army.
When a wild animal was in a defenseArmy and it was killed, its resource got into the army as well. This caused a call to GetUnitAIOrder data which was undefined for the resource. Fixed by checking for UnitAI-ness and also for attack-ability whilst at it. Reported by @seregadushka at the forums: https://wildfiregames.com/forum/topic/110098-petra-error-winter-is-coming5/. Investigated and MWE by @Norse_Harold. Fixes #6899 This was SVN commit r28025.
This commit is contained in:
parent
ca0f8d9bce
commit
62db78beec
@ -550,6 +550,8 @@ m.Template = m.Class({
|
||||
"canOccupyTurret": function() { return "Turretable" in this._template; },
|
||||
|
||||
"isTreasureCollector": function() { return this.get("TreasureCollector") !== undefined; },
|
||||
|
||||
"hasUnitAI": function() { return this.get("UnitAI") !== undefined; },
|
||||
});
|
||||
|
||||
|
||||
|
@ -527,6 +527,9 @@ PETRA.DefenseArmy.prototype.checkEvents = function(gameState, events)
|
||||
}
|
||||
else if (this.ownEntities.indexOf(evt.entity) !== -1)
|
||||
{
|
||||
const newEnt = gameState.getEntityById(evt.newentity);
|
||||
if (newEnt && (!newEnt.hasUnitAI() || !newEnt.attackTypes()))
|
||||
continue;
|
||||
let idx = this.ownEntities.indexOf(evt.entity);
|
||||
this.ownEntities[idx] = evt.newentity;
|
||||
this.assignedTo[evt.newentity] = this.assignedTo[evt.entity];
|
||||
|
Loading…
Reference in New Issue
Block a user