Change target for all orders on EntityRenamed. Patch by mimo. Fixes #1903.

This was SVN commit r13355.
This commit is contained in:
leper 2013-04-10 22:48:02 +00:00
parent 95a10e7f42
commit 7562c79e89

View file

@ -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)