Index: binaries/data/mods/public/simulation/components/Formation.js =================================================================== --- binaries/data/mods/public/simulation/components/Formation.js +++ binaries/data/mods/public/simulation/components/Formation.js @@ -925,26 +925,37 @@ Formation.prototype.OnGlobalEntityRenamed = function(msg) { - if (this.members.indexOf(msg.entity) != -1) + if (this.members.indexOf(msg.entity) == -1) + return; + + this.offsets = undefined; + var cmpNewUnitAI = Engine.QueryInterface(msg.newentity, IID_UnitAI); + if (cmpNewUnitAI) { - this.offsets = undefined; - var cmpNewUnitAI = Engine.QueryInterface(msg.newentity, IID_UnitAI); - if (cmpNewUnitAI) - { - this.members[this.members.indexOf(msg.entity)] = msg.newentity; - this.memberPositions[msg.newentity] = this.memberPositions[msg.entity]; - } + this.members[this.members.indexOf(msg.entity)] = msg.newentity; + this.memberPositions[msg.newentity] = this.memberPositions[msg.entity]; - var cmpOldUnitAI = Engine.QueryInterface(msg.entity, IID_UnitAI); - cmpOldUnitAI.SetFormationController(INVALID_ENTITY); + let cmpAuras = Engine.QueryInterface(msg.newentity, IID_Auras); + let auraIndex = this.formationMembersWithAura.indexOf(msg.entity); + if (auraIndex != -1 && cmpAuras && cmpAuras.hasFormationAura()) + this.formationMembersWithAura[auraIndex] = msg.newentity; + } - if (cmpNewUnitAI) - cmpNewUnitAI.SetFormationController(this.entity); + var cmpOldUnitAI = Engine.QueryInterface(msg.entity, IID_UnitAI); + cmpOldUnitAI.SetFormationController(INVALID_ENTITY); - // Because the renamed entity might have different characteristics, - // (e.g. packed vs. unpacked siege), we need to recompute motion parameters - this.ComputeMotionParameters(); + if (cmpNewUnitAI) + cmpNewUnitAI.SetFormationController(this.entity); + + for (let ent of this.formationMembersWithAura) + { + let cmpAuras = Engine.QueryInterface(ent, IID_Auras); + cmpAuras.ApplyFormationBonus([msg.newentity]); } + + // Because the renamed entity might have different characteristics, + // (e.g. packed vs. unpacked siege), we need to recompute motion parameters + this.ComputeMotionParameters(); }; Formation.prototype.RegisterTwinFormation = function(entity)