Page MenuHomeWildfire Games

Fix gathering infinite loop when the gatherer is out of the world.
ClosedPublic

Authored by wraitii on Wed, Jul 29, 9:59 AM.

Details

Summary

Bit of a weird one, this.

#5788 is a situation where an entity ended up in GATHER.APPROACHING while out of the world (Haven't really investigated how, but that sounds possible if it's killed/renamed on that turn). That failed, since it can't move, it then switched to findnewtarget, which found resources to collect, and then looped back to gather.approaching, which failed again.

To fix this, I check in FINDINGINDNEWTARGET that the entity actually has a position right now, which seems sensible in general, and actually lets de-indent slightly.


There is a subsidiary question: how did this entity end up doing:

WARNING: Setting next state : INDIVIDUAL.COMBAT.ATTACKING
WARNING: Setting next state : COMBAT.FINDINGNEWTARGET
WARNING: Setting next state : INDIVIDUAL.GATHER.APPROACHING
WARNING: Setting next state : FINDINGNEWTARGET

while somehow out of the world.
Based on the video at #5788, the most likely case is that then entity promoted, thus got renamed, and thus the OG entity ended up being in an invalid state.


Reported by user psypherium on the forums, and actually caught on video: https://www.youtube.com/watch?v=fV5MZ7aBS5Q&feature=youtu.be&t=2302

Thanks to @Angen for pinging me.

Test Plan

You can use the replay at #5788 and confirm that the entity 7941 still goes through the hunting pattern, but this time it succeeds, meaning the fix doesn't change the simulation run but does fix the issue.

Diff Detail

Repository
rP 0 A.D. Public Repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

wraitii created this revision.Wed, Jul 29, 9:59 AM
Stan added a subscriber: Stan.Wed, Jul 29, 10:03 AM
Stan added inline comments.
binaries/data/mods/public/simulation/components/UnitAI.js
2515 ↗(On Diff #12959)

Is this a Vector2D hack?

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (no-else-return):
|    | Unnecessary 'else' after 'return'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
| 798| 798| 					this.FinishOrder();
| 799| 799| 					return;
| 800| 800| 				}
| 801|    |-				else
| 802|    |-				{
|    | 801|+				
| 803| 802| 					this.SetNextState("GARRISON.APPROACHING");
| 804| 803| 					return;
| 805|    |-				}
|    | 804|+				
| 806| 805| 			}
| 807| 806| 
| 808| 807| 			this.SetNextState("GARRISON.GARRISONING");
|    | [NORMAL] ESLintBear (key-spacing):
|    | Missing space before value for key 'GARRISON'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|1062|1062| 			},
|1063|1063| 		},
|1064|1064| 
|1065|    |-		"GARRISON":{
|    |1065|+		"GARRISON": {
|1066|1066| 			"APPROACHING": {
|1067|1067| 				"enter": function() {
|1068|1068| 					if (!this.MoveToGarrisonRange(this.order.data.target))
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|2066|2066| 
|2067|2067| 				"Attacked": function(msg) {
|2068|2068| 					// If we are capturing and are attacked by something that we would not capture, attack that entity instead
|2069|    |-					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force)
|2070|    |-						&& this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|    |2069|+					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force) &&
|    |2070|+						this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|2071|2071| 						this.RespondToTargetedEntities([msg.data.attacker]);
|2072|2072| 				},
|2073|2073| 			},
|    | [NORMAL] ESLintBear (no-trailing-spaces):
|    | Trailing spaces not allowed.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|2225|2225| 					"MovementUpdate": function(msg) {
|2226|2226| 						// If it looks like the path is failing, and we are close enough (3 tiles) from wanted range
|2227|2227| 						// stop anyways. This avoids pathing for an unreachable goal and reduces lag considerably.
|2228|    |-						if (msg.likelyFailure || 
|    |2228|+						if (msg.likelyFailure ||
|2229|2229| 							msg.obstructed && this.RelaxedMaxRangeCheck(this.order.data, this.order.data.max + this.DefaultRelaxedMaxRange) ||
|2230|2230| 							!msg.obstructed && this.CheckRange(this.order.data))
|2231|2231| 							this.FinishOrder();
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 6 tabs but found 5.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|2527|2527| 
|2528|2528| 							return type.specific == resourceType.specific &&
|2529|2529| 							    (type.specific != "meat" || resourceTemplate == template);
|2530|    |-					});
|    |2530|+						});
|2531|2531| 
|2532|2532| 					if (nearbyResource)
|2533|2533| 					{
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|2857|2857| 					{
|2858|2858| 						// The building was already finished/fully repaired before we arrived;
|2859|2859| 						// let the ConstructionFinished handler handle this.
|2860|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2860|+						this.OnGlobalConstructionFinished({ "entity": this.repairTarget, "newentity": this.repairTarget});
|2861|2861| 						return true;
|2862|2862| 					}
|2863|2863| 
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|2857|2857| 					{
|2858|2858| 						// The building was already finished/fully repaired before we arrived;
|2859|2859| 						// let the ConstructionFinished handler handle this.
|2860|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2860|+						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget });
|2861|2861| 						return true;
|2862|2862| 					}
|2863|2863| 
|    | [NORMAL] ESLintBear (semi):
|    | Missing semicolon.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3147|3147| 				this.StopTimer();
|3148|3148| 				this.ResetAnimation();
|3149|3149| 				if (this.formationAnimationVariant)
|3150|    |-					this.SetAnimationVariant(this.formationAnimationVariant)
|    |3150|+					this.SetAnimationVariant(this.formationAnimationVariant);
|3151|3151| 				else
|3152|3152| 					this.SetDefaultAnimationVariant();
|3153|3153| 				var cmpResistance = Engine.QueryInterface(this.entity, IID_Resistance);
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 2 tabs but found 7.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3361|3361| 		"COMBAT": "INDIVIDUAL.COMBAT", // reuse the same combat behaviour for animals
|3362|3362| 
|3363|3363| 		"WALKING": "INDIVIDUAL.WALKING",	// reuse the same walking behaviour for animals
|3364|    |-							// only used for domestic animals
|    |3364|+		// only used for domestic animals
|3365|3365| 
|3366|3366| 		// Reuse the same garrison behaviour for animals.
|3367|3367| 		"GARRISON": "INDIVIDUAL.GARRISON",
|    | [NORMAL] ESLintBear (no-unneeded-ternary):
|    | Unnecessary use of boolean literals in conditional expression.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3411|3411| 
|3412|3412| UnitAI.prototype.IsAnimal = function()
|3413|3413| {
|3414|    |-	return (this.template.NaturalBehaviour ? true : false);
|    |3414|+	return (!!this.template.NaturalBehaviour);
|3415|3415| };
|3416|3416| 
|3417|3417| UnitAI.prototype.IsDangerousAnimal = function()
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3551|3551| 		{
|3552|3552| 			let index = this.GetCurrentState().indexOf(".");
|3553|3553| 			if (index != -1)
|3554|    |-				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0,index));
|    |3554|+				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0, index));
|3555|3555| 			this.Stop(false);
|3556|3556| 		}
|3557|3557| 
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3608|3608| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3609|3609| 			continue;
|3610|3610| 		if (i == 0)
|3611|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3611|+			this.UnitFsm.ProcessMessage(this, { "type": "PickupCanceled", "data": msg});
|3612|3612| 		else
|3613|3613| 			this.orderQueue.splice(i, 1);
|3614|3614| 		Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3608|3608| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3609|3609| 			continue;
|3610|3610| 		if (i == 0)
|3611|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3611|+			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg });
|3612|3612| 		else
|3613|3613| 			this.orderQueue.splice(i, 1);
|3614|3614| 		Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3737|3737| };
|3738|3738| 
|3739|3739| 
|3740|    |-//// FSM linkage functions ////
|    |3740|+// // FSM linkage functions ////
|3741|3741| 
|3742|3742| // Setting the next state to the current state will leave/re-enter the top-most substate.
|3743|3743| UnitAI.prototype.SetNextState = function(state)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3910|3910| 				continue;
|3911|3911| 			if (this.orderQueue[i].type == type)
|3912|3912| 				continue;
|3913|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3913|+			this.orderQueue.splice(i, 0, { "type": type, "data": data});
|3914|3914| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3915|3915| 			return;
|3916|3916| 		}
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3910|3910| 				continue;
|3911|3911| 			if (this.orderQueue[i].type == type)
|3912|3912| 				continue;
|3913|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3913|+			this.orderQueue.splice(i, 0, {"type": type, "data": data });
|3914|3914| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3915|3915| 			return;
|3916|3916| 		}
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4151|4151| 	if (data.timerRepeat === undefined)
|4152|4152| 		this.timer = undefined;
|4153|4153| 
|4154|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |4154|+	this.UnitFsm.ProcessMessage(this, { "type": "Timer", "data": data, "lateness": lateness});
|4155|4155| };
|4156|4156| 
|4157|4157| /**
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4151|4151| 	if (data.timerRepeat === undefined)
|4152|4152| 		this.timer = undefined;
|4153|4153| 
|4154|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |4154|+	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness });
|4155|4155| };
|4156|4156| 
|4157|4157| /**
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4196|4196| 	// TODO: This is a bit inefficient since every unit listens to every
|4197|4197| 	// construction message - ideally we could scope it to only the one we're building
|4198|4198| 
|4199|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |4199|+	this.UnitFsm.ProcessMessage(this, { "type": "ConstructionFinished", "data": msg});
|4200|4200| };
|4201|4201| 
|4202|4202| UnitAI.prototype.OnGlobalEntityRenamed = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4196|4196| 	// TODO: This is a bit inefficient since every unit listens to every
|4197|4197| 	// construction message - ideally we could scope it to only the one we're building
|4198|4198| 
|4199|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |4199|+	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg });
|4200|4200| };
|4201|4201| 
|4202|4202| UnitAI.prototype.OnGlobalEntityRenamed = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4235|4235| 	if (msg.fromStatusEffect)
|4236|4236| 		return;
|4237|4237| 
|4238|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |4238|+	this.UnitFsm.ProcessMessage(this, { "type": "Attacked", "data": msg});
|4239|4239| };
|4240|4240| 
|4241|4241| UnitAI.prototype.OnGuardedAttacked = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4235|4235| 	if (msg.fromStatusEffect)
|4236|4236| 		return;
|4237|4237| 
|4238|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |4238|+	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg });
|4239|4239| };
|4240|4240| 
|4241|4241| UnitAI.prototype.OnGuardedAttacked = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4240|4240| 
|4241|4241| UnitAI.prototype.OnGuardedAttacked = function(msg)
|4242|4242| {
|4243|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |4243|+	this.UnitFsm.ProcessMessage(this, { "type": "GuardedAttacked", "data": msg.data});
|4244|4244| };
|4245|4245| 
|4246|4246| UnitAI.prototype.OnHealthChanged = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4240|4240| 
|4241|4241| UnitAI.prototype.OnGuardedAttacked = function(msg)
|4242|4242| {
|4243|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |4243|+	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data });
|4244|4244| };
|4245|4245| 
|4246|4246| UnitAI.prototype.OnHealthChanged = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4245|4245| 
|4246|4246| UnitAI.prototype.OnHealthChanged = function(msg)
|4247|4247| {
|4248|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |4248|+	this.UnitFsm.ProcessMessage(this, { "type": "HealthChanged", "from": msg.from, "to": msg.to});
|4249|4249| };
|4250|4250| 
|4251|4251| UnitAI.prototype.OnRangeUpdate = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4245|4245| 
|4246|4246| UnitAI.prototype.OnHealthChanged = function(msg)
|4247|4247| {
|4248|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |4248|+	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to });
|4249|4249| };
|4250|4250| 
|4251|4251| UnitAI.prototype.OnRangeUpdate = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4260|4260| 
|4261|4261| UnitAI.prototype.OnPackFinished = function(msg)
|4262|4262| {
|4263|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |4263|+	this.UnitFsm.ProcessMessage(this, { "type": "PackFinished", "packed": msg.packed});
|4264|4264| };
|4265|4265| 
|4266|4266| //// Helper functions to be called by the FSM ////
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4260|4260| 
|4261|4261| UnitAI.prototype.OnPackFinished = function(msg)
|4262|4262| {
|4263|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |4263|+	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed });
|4264|4264| };
|4265|4265| 
|4266|4266| //// Helper functions to be called by the FSM ////
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4263|4263| 	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|4264|4264| };
|4265|4265| 
|4266|    |-//// Helper functions to be called by the FSM ////
|    |4266|+// // Helper functions to be called by the FSM ////
|4267|4267| 
|4268|4268| UnitAI.prototype.GetWalkSpeed = function()
|4269|4269| {
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4993|4993| UnitAI.prototype.AttackEntityInZone = function(ents)
|4994|4994| {
|4995|4995| 	var target = ents.find(target =>
|4996|    |-		this.CanAttack(target)
|4997|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|    |4996|+		this.CanAttack(target) &&
|    |4997|+		this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4998|4998| 		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4999|4999| 	);
|5000|5000| 	if (!target)
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4994|4994| {
|4995|4995| 	var target = ents.find(target =>
|4996|4996| 		this.CanAttack(target)
|4997|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4998|    |-		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|    |4997|+		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true)) &&
|    |4998|+		(this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4999|4999| 	);
|5000|5000| 	if (!target)
|5001|5001| 		return false;
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before 'Engine'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5078|5078| 	// If we are guarding/escorting, don't abandon as long as the guarded unit is in target range of the attacker
|5079|5079| 	if (this.isGuardOf)
|5080|5080| 	{
|5081|    |-		var cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |5081|+		var cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|5082|5082| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|5083|5083| 		if (cmpUnitAI && cmpAttack &&
|5084|5084| 		    cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type)))
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 3 tabs but found 4.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5082|5082| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|5083|5083| 		if (cmpUnitAI && cmpAttack &&
|5084|5084| 		    cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type)))
|5085|    |-				return false;
|    |5085|+			return false;
|5086|5086| 	}
|5087|5087| 
|5088|5088| 	// Stop if we're in hold-ground mode and it's too far from the holding point
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before 'Engine'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5120|5120| 	// If we are guarding/escorting, chase at least as long as the guarded unit is in target range of the attacker
|5121|5121| 	if (this.isGuardOf)
|5122|5122| 	{
|5123|    |-		let cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |5123|+		let cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|5124|5124| 		let cmpAttack = Engine.QueryInterface(target, IID_Attack);
|5125|5125| 		if (cmpUnitAI && cmpAttack &&
|5126|5126| 		    cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type)))
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5133|5133| 	return false;
|5134|5134| };
|5135|5135| 
|5136|    |-//// External interface functions ////
|    |5136|+// // External interface functions ////
|5137|5137| 
|5138|5138| UnitAI.prototype.SetFormationController = function(ent)
|5139|5139| {
|    | [NORMAL] ESLintBear (no-else-return):
|    | Unnecessary 'else' after 'return'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5289|5289| 	{
|5290|5290| 		if (this.isGuardOf == target && this.order && this.order.type == "Guard")
|5291|5291| 			return;
|5292|    |-		else
|5293|    |-			this.RemoveGuard();
|    |5292|+		this.RemoveGuard();
|5294|5293| 	}
|5295|5294| 
|5296|5295| 	this.AddOrder("Guard", { "target": target, "force": false }, queued);
|    | [NORMAL] ESLintBear (semi):
|    | Missing semicolon.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5623|5623| 
|5624|5624| 	if (this.IsFormationController())
|5625|5625| 		this.CallMemberFunction("CancelSetupTradeRoute", [target]);
|5626|    |-}
|    |5626|+};
|5627|5627| /**
|5628|5628|  * Adds trade order to the queue. Either walk to the first market, or
|5629|5629|  * start a new route. Not forced, so it can be interrupted by attacks.
|    | [NORMAL] ESLintBear (no-trailing-spaces):
|    | Trailing spaces not allowed.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5644|5644| 	    this.workOrders.length && this.workOrders[0].type == "Trade")
|5645|5645| 	{
|5646|5646| 		let cmpTrader = Engine.QueryInterface(this.entity, IID_Trader);
|5647|    |-		if (cmpTrader.HasBothMarkets() && 
|    |5647|+		if (cmpTrader.HasBothMarkets() &&
|5648|5648| 		   (cmpTrader.GetFirstMarket() == target && cmpTrader.GetSecondMarket() == source ||
|5649|5649| 		    cmpTrader.GetFirstMarket() == source && cmpTrader.GetSecondMarket() == target))
|5650|5650| 		{
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5951|5951| 				{
|5952|5952| 					var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5953|5953| 					var targetClasses = this.order.data.targetClasses;
|5954|    |-					if (targetClasses.attack && cmpIdentity
|5955|    |-						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5954|+					if (targetClasses.attack && cmpIdentity &&
|    |5955|+						!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5956|5956| 						continue;
|5957|5957| 					if (targetClasses.avoid && cmpIdentity
|5958|5958| 						&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5954|5954| 					if (targetClasses.attack && cmpIdentity
|5955|5955| 						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5956|5956| 						continue;
|5957|    |-					if (targetClasses.avoid && cmpIdentity
|5958|    |-						&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5957|+					if (targetClasses.avoid && cmpIdentity &&
|    |5958|+						MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5959|5959| 						continue;
|5960|5960| 					// Only used by the AIs to prevent some choices of targets
|5961|5961| 					if (targetClasses.vetoEntities && targetClasses.vetoEntities[targ])
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5977|5977| 		{
|5978|5978| 			var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5979|5979| 			var targetClasses = this.order.data.targetClasses;
|5980|    |-			if (cmpIdentity && targetClasses.attack
|5981|    |-				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5980|+			if (cmpIdentity && targetClasses.attack &&
|    |5981|+				!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5982|5982| 				continue;
|5983|5983| 			if (cmpIdentity && targetClasses.avoid
|5984|5984| 				&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5980|5980| 			if (cmpIdentity && targetClasses.attack
|5981|5981| 				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5982|5982| 				continue;
|5983|    |-			if (cmpIdentity && targetClasses.avoid
|5984|    |-				&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5983|+			if (cmpIdentity && targetClasses.avoid &&
|    |5984|+				MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5985|5985| 				continue;
|5986|5986| 			// Only used by the AIs to prevent some choices of targets
|5987|5987| 			if (targetClasses.vetoEntities && targetClasses.vetoEntities[targ])
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|6133|6133| 
|6134|6134| UnitAI.prototype.SetHeldPosition = function(x, z)
|6135|6135| {
|6136|    |-	this.heldPosition = {"x": x, "z": z};
|    |6136|+	this.heldPosition = { "x": x, "z": z};
|6137|6137| };
|6138|6138| 
|6139|6139| UnitAI.prototype.SetHeldPositionOnEntity = function(entity)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|6133|6133| 
|6134|6134| UnitAI.prototype.SetHeldPosition = function(x, z)
|6135|6135| {
|6136|    |-	this.heldPosition = {"x": x, "z": z};
|    |6136|+	this.heldPosition = {"x": x, "z": z };
|6137|6137| };
|6138|6138| 
|6139|6139| UnitAI.prototype.SetHeldPositionOnEntity = function(entity)
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|6160|6160| 	return false;
|6161|6161| };
|6162|6162| 
|6163|    |-//// Helper functions ////
|    |6163|+// // Helper functions ////
|6164|6164| 
|6165|6165| /**
|6166|6166|  * General getter for ranges.
|    | [NORMAL] ESLintBear (semi):
|    | Missing semicolon.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|6179|6179| 		return undefined;
|6180|6180| 
|6181|6181| 	return component.GetRange(type);
|6182|    |-}
|    |6182|+};
|6183|6183| 
|6184|6184| UnitAI.prototype.CanAttack = function(target)
|6185|6185| {
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|6355|6355| 	return cmpPack && cmpPack.IsPacking();
|6356|6356| };
|6357|6357| 
|6358|    |-//// Formation specific functions ////
|    |6358|+// // Formation specific functions ////
|6359|6359| 
|6360|6360| UnitAI.prototype.IsAttackingAsFormation = function()
|6361|6361| {
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|6360|6360| UnitAI.prototype.IsAttackingAsFormation = function()
|6361|6361| {
|6362|6362| 	var cmpAttack = Engine.QueryInterface(this.entity, IID_Attack);
|6363|    |-	return cmpAttack && cmpAttack.CanAttackAsFormation()
|6364|    |-		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|    |6363|+	return cmpAttack && cmpAttack.CanAttackAsFormation() &&
|    |6364|+		this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|6365|6365| };
|6366|6366| 
|6367|6367| //// Animal specific functions ////
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|6364|6364| 		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|6365|6365| };
|6366|6366| 
|6367|    |-//// Animal specific functions ////
|    |6367|+// // Animal specific functions ////
|6368|6368| 
|6369|6369| UnitAI.prototype.MoveRandomly = function(distance)
|6370|6370| {
|    | [NORMAL] ESLintBear (semi):
|    | Missing semicolon.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|6415|6415| {
|6416|6416| 	let cmpUnitMotion = Engine.QueryInterface(this.entity, IID_UnitMotion);
|6417|6417| 	return cmpUnitMotion && cmpUnitMotion.GetFacePointAfterMove();
|6418|    |-}
|    |6418|+};
|6419|6419| 
|6420|6420| UnitAI.prototype.AttackEntitiesByPreference = function(ents)
|6421|6421| {

binaries/data/mods/public/simulation/components/UnitAI.js
| 349| »   »   »   return·true;
|    | [NORMAL] ESLintBear (consistent-return):
|    | Method 'Order.WalkToTarget' expected no return value.

binaries/data/mods/public/simulation/components/UnitAI.js
|4056| »   var·isWorkType·=·type·=>·type·==·"Gather"·||·type·==·"Trade"·||·type·==·"Repair"·||·type·==·"ReturnResource";
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'type' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/UnitAI.js
|4980| »   var·target·=·ents.find(target·=>·this.CanAttack(target));
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'target' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/UnitAI.js
|4995| »   var·target·=·ents.find(target·=>
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'target' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/UnitAI.js
|5061| »   let·ent·=·ents.find(ent·=>·this.CanHeal(ent));
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'ent' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/UnitAI.js
|5084| »   »   ····cmpAttack.GetAttackTypes().some(type·=>·cmpUnitAI.CheckTargetAttackRange(this.isGuardOf,·type)))
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'type' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/UnitAI.js
|2070| »   »   »   »   »   »   &&·this.order.data.target·!=·msg.data.attacker·&&·this.GetBestAttackAgainst(msg.data.attacker,·true)·!=·"Capture")
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|3150| »   »   »   »   »   this.SetAnimationVariant(this.formationAnimationVariant)
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

binaries/data/mods/public/simulation/components/UnitAI.js
|4003| »   »   var·order·=·{·"type":·type,·"data":·data·};
|    | [NORMAL] JSHintBear:
|    | 'order' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|4087| »   for·(var·i·=·0;·i·<·this.orderQueue.length;·++i)
|    | [NORMAL] JSHintBear:
|    | 'i' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|4997| »   »   &&·this.CheckTargetDistanceFromHeldPosition(target,·IID_Attack,·this.GetBestAttackAgainst(target,·true))
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|4998| »   »   &&·(this.GetStance().respondChaseBeyondVision·||·this.CheckTargetIsInVisionRange(target))
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|5626| }
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

binaries/data/mods/public/simulation/components/UnitAI.js
|5955| »   »   »   »   »   »   &&·!MatchesClassList(cmpIdentity.GetClassesList(),·targetClasses.attack))
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|5958| »   »   »   »   »   »   &&·MatchesClassList(cmpIdentity.GetClassesList(),·targetClasses.avoid))
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|5971| »   var·targets·=·this.GetTargetsFromUnit();
|    | [NORMAL] JSHintBear:
|    | 'targets' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|5972| »   for·(var·targ·of·targets)
|    | [NORMAL] JSHintBear:
|    | 'targ' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|5978| »   »   »   var·cmpIdentity·=·Engine.QueryInterface(targ,·IID_Identity);
|    | [NORMAL] JSHintBear:
|    | 'cmpIdentity' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|5979| »   »   »   var·targetClasses·=·this.order.data.targetClasses;
|    | [NORMAL] JSHintBear:
|    | 'targetClasses' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|5981| »   »   »   »   &&·!MatchesClassList(cmpIdentity.GetClassesList(),·targetClasses.attack))
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|5984| »   »   »   »   &&·MatchesClassList(cmpIdentity.GetClassesList(),·targetClasses.avoid))
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|6182| }
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

binaries/data/mods/public/simulation/components/UnitAI.js
|6364| »   »   &&·this.GetCurrentState()·==·"FORMATIONCONTROLLER.COMBAT.ATTACKING";
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|6418| }
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/2803/display/redirect

Angen accepted this revision.Sat, Aug 1, 6:41 PM
  1. Without position unit is not in game. Just cant happen so aborting state is ok.
  2. We do nothing with original unit when we promote it, so it ends out of world, but it finishes order in unitai and since FSM keeps swtiching states while they are called from enter, we got unit to infinite loop.

Notice gather ordered given are not queued nor pushed so they are processed inside current state.

// If func called SetNextState then switch into the new state,
// and continue switching if the new state's 'enter' called SetNextState again

I am accepting this as fixing the issue, but one should check another states affected by moving promoted unit out of world or one should ensure promoted unit gets deleted all orders and is moved to some trash state.

This revision is now accepted and ready to land.Sat, Aug 1, 6:41 PM

I'm not completely sure this is exactly the same issue, but this includes a small replay that seems to have the same issue. I'll see if this patch fixes this.

@Freagarach
I confirm it's the same issue.

In D2920#126735, @Angen wrote:

one should check another states affected by moving promoted unit out of world or one should ensure promoted unit gets deleted all orders and is moved to some trash state.

Agreed, I'll make a follow-up patch.

ERROR: CCmpPosition::GetPosition2D called on entity when IsInWorld is false

Same issue?

Freagarach added a comment.EditedMon, Aug 3, 8:44 AM

Nope, different issue. I am investigating for I had that too last week.

(On r23920 around the seventeen minute mark, turn 1930.)

[EDIT]: Entity 2675, a formation, made by player 2 with 10 Cavalry at turn 1883.