From 7562c79e89c87c966a02eccc54283e81ea7d3cdf Mon Sep 17 00:00:00 2001 From: leper Date: Wed, 10 Apr 2013 22:48:02 +0000 Subject: [PATCH] Change target for all orders on EntityRenamed. Patch by mimo. Fixes #1903. This was SVN commit r13355. --- .../public/simulation/components/UnitAI.js | 41 ++----------------- 1 file changed, 3 insertions(+), 38 deletions(-) diff --git a/binaries/data/mods/public/simulation/components/UnitAI.js b/binaries/data/mods/public/simulation/components/UnitAI.js index 53a05a8ec5..db0ce6357c 100644 --- a/binaries/data/mods/public/simulation/components/UnitAI.js +++ b/binaries/data/mods/public/simulation/components/UnitAI.js @@ -156,10 +156,6 @@ var UnitFsmSpec = { // ignore }, - "EntityRenamed": function(msg) { - // ignore - }, - "PackFinished": function(msg) { // ignore }, @@ -997,21 +993,6 @@ var UnitFsmSpec = { this.StartTimer(1000, 1000); }, - "EntityRenamed": function(msg) { - if (this.order.data && this.order.data.target - && this.order.data.target == msg.entity) - { - this.order.data.target = msg.newentity; - - // If we're hunting, that means we have a queued gather - // order whose target also needs to be updated. - if (this.order.data.hunting && this.orderQueue[1] && - this.orderQueue[1].type == "Gather") - this.orderQueue[1].data.target = msg.newentity; - } - }, - - "Timer": function(msg) { var cmpFormation = Engine.QueryInterface(this.entity, IID_Formation); @@ -1299,19 +1280,6 @@ var UnitFsmSpec = { return { "discardOrder": true }; }, - "EntityRenamed": function(msg) { - if (this.order.data.target == msg.entity) - { - this.order.data.target = msg.newentity; - - // If we're hunting, that means we have a queued gather - // order whose target also needs to be updated. - if (this.order.data.hunting && this.orderQueue[1] && - this.orderQueue[1].type == "Gather") - this.orderQueue[1].data.target = msg.newentity; - } - }, - "Attacked": function(msg) { // If we're already in combat mode, ignore anyone else // who's attacking us @@ -1867,11 +1835,6 @@ var UnitFsmSpec = { }, "HEAL": { - "EntityRenamed": function(msg) { - if (this.order.data.target == msg.entity) - this.order.data.target = msg.newentity; - }, - "Attacked": function(msg) { // If we stand ground we will rather die than flee if (!this.GetStance().respondStandGround && !this.order.data.force) @@ -3002,7 +2965,9 @@ UnitAI.prototype.OnGlobalConstructionFinished = function(msg) UnitAI.prototype.OnGlobalEntityRenamed = function(msg) { - UnitFsm.ProcessMessage(this, {"type": "EntityRenamed", "entity": msg.entity, "newentity": msg.newentity}); + for each (var order in this.orderQueue) + if (order.data && order.data.target && order.data.target == msg.entity) + order.data.target = msg.newentity; }; UnitAI.prototype.OnAttacked = function(msg)