From dd67783f85ca9605996f66aa75df235f6e09eda5 Mon Sep 17 00:00:00 2001 From: temple Date: Wed, 24 Jan 2018 19:17:04 +0000 Subject: [PATCH] Fix formation auras Differential Revision: https://code.wildfiregames.com/D756 Reviewed by: mimo Comments by: bb git-svn-id: https://svn.wildfiregames.com/public/ps/trunk@21006 3db68df2-c116-0410-a063-a993310a9797 --- .../mods/public/simulation/components/Formation.js | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/binaries/data/mods/public/simulation/components/Formation.js b/binaries/data/mods/public/simulation/components/Formation.js index 735b9e10b8..c6b2524936 100644 --- a/binaries/data/mods/public/simulation/components/Formation.js +++ b/binaries/data/mods/public/simulation/components/Formation.js @@ -369,28 +369,24 @@ Formation.prototype.AddMembers = function(ents) this.offsets = undefined; this.inPosition = []; - for (var ent of this.formationMembersWithAura) + for (let ent of this.formationMembersWithAura) { - var cmpAuras = Engine.QueryInterface(ent, IID_Auras); - cmpAuras.RemoveFormationBonus(ents); - - // the unit with the aura is also removed from the formation - if (ents.indexOf(ent) !== -1) - cmpAuras.RemoveFormationBonus(this.members); + let cmpAuras = Engine.QueryInterface(ent, IID_Auras); + cmpAuras.ApplyFormationBonus(ents); } this.members = this.members.concat(ents); - for (var ent of this.members) + for (let ent of ents) { - var cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI); + let cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI); cmpUnitAI.SetFormationController(this.entity); - var cmpAuras = Engine.QueryInterface(ent, IID_Auras); + let cmpAuras = Engine.QueryInterface(ent, IID_Auras); if (cmpAuras && cmpAuras.HasFormationAura()) { this.formationMembersWithAura.push(ent); - cmpAuras.ApplyFormationBonus(ents); + cmpAuras.ApplyFormationBonus(this.members); } } @@ -902,7 +898,9 @@ Formation.prototype.ShapeUpdate = function() // merge the members from the twin formation into this one // twin formations should always have exactly the same orders - this.AddMembers(cmpOtherFormation.members); + let otherMembers = cmpOtherFormation.members; + cmpOtherFormation.RemoveMembers(otherMembers); + this.AddMembers(otherMembers); Engine.DestroyEntity(this.twinFormations[i]); this.twinFormations.splice(i,1); } -- 2.11.4.GIT