Page MenuHomeWildfire Games

Fix IDLE-related infinite loops
ClosedPublic

Authored by wraitii on Fri, Jul 5, 7:51 AM.

Details

Reviewers
None
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Commits
rP22475: Fix IDLE-related infinite loops by moving stateful calls to IDLE.timer.
Trac Tickets
#5460
Summary

This is my proposed fix for the infinite loops problem.
There have been various infinite loops reported at #5460.
The beginning of the stack trace is always the same:
Units go in IDLE. That calls FindNewTargets, which finds a new possible target and calls Order.Attack.

Then there are four possible situations:

  • the order is rejected in Order.Attack (for whatever reason). The unit is still in IDLE state. The safety check from rP22059 triggers -> no infinite loop.
  • the order is rejected in Order.Attack, but the unit is a turret and has a garrison order which puts us in the IDLE state. Following rP22023, this loops.
  • the order is OKeyed, and the unit moves to ATTACK.enter. There, the Move call fails. The unit calls Finish Order and goes back to Idle. Rinse, repeat, infinite loop.
  • the order is OKeyed, the state enter goes alright, and the unit carries on attacking. We're fine.

On the subject of rP22059:

  • This was a safety net so that the FindNewTarget calls didn't have to be moved to the timer. Given the new classes of bugs, the last of which can't be caught with rP22059, I no longer think this is reasonable.

On rP22023:

  • Reverting this diff would only fix the second case described above. I believe the diff is conceptually sound, and helps avoid other classes of mistakes, so I am against reverting it.

On "IDLE.Timer":

  • Yes, it is kind of a hack. It's a workaround the fact that IDLE is the default state. It's kind of unavoidable.
  • It puts the unit in an infinite slow loop situation if the conditions for "Timer" to put us in another state happen again.
  • It's perfectly safe

On a "correct" fix for these infinite loops:

  • The general cause of infinite loops is that we don't run some conditions early enough. D2008 for example is one case.
  • FindNewTargets in particular does not run all conditions from Order.Attack or ATTACK.enter
  • I don't think they should, though. ATTACK.enter, in particular, calls "MoveToTargetRange", which might fail for UAI-reasons (visibility) or for UnitMotion reasons - and the latter should remain unknown to UAI.

For all of the above, I believe this is the only valid fix for this class of issues, which fixes all currently known infinite loops.
It's also an example of defensive programming as changing behaviour in the attack order, or in FindNewTargets and related function will not suddenly trigger infinite loops, which a "correct" fix as described above might.

Test Plan

Run the replays and notice that it no longer crashes.

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.Fri, Jul 5, 7:51 AM
wraitii edited the summary of this revision. (Show Details)
Vulcan added a comment.Fri, Jul 5, 7:54 AM

Build failure - The Moirai have given mortals hearts that can endure.

Linter detected issues:
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
| 352| 352| 		var cmpPosition = Engine.QueryInterface(this.entity, IID_Position);
| 353| 353| 		if (this.lastShorelinePosition && cmpPosition && (this.lastShorelinePosition.x == cmpPosition.GetPosition().x)
| 354| 354| 		    && (this.lastShorelinePosition.z == cmpPosition.GetPosition().z))
| 355|    |-		{
|    | 355|+		
| 356| 356| 			// we were already on the shoreline, and have not moved since
| 357| 357| 			if (DistanceBetweenEntities(this.entity, this.order.data.target) < 50)
| 358| 358| 				needToMove = false;
| 359|    |-		}
|    | 359|+		
| 360| 360| 
| 361| 361| 		if (needToMove)
| 362| 362| 			this.SetNextState("INDIVIDUAL.PICKUP.APPROACHING");
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
| 350| 350| 		// Check if we need to move     TODO implement a better way to know if we are on the shoreline
| 351| 351| 		var needToMove = true;
| 352| 352| 		var cmpPosition = Engine.QueryInterface(this.entity, IID_Position);
| 353|    |-		if (this.lastShorelinePosition && cmpPosition && (this.lastShorelinePosition.x == cmpPosition.GetPosition().x)
| 354|    |-		    && (this.lastShorelinePosition.z == cmpPosition.GetPosition().z))
|    | 353|+		if (this.lastShorelinePosition && cmpPosition && (this.lastShorelinePosition.x == cmpPosition.GetPosition().x) &&
|    | 354|+		    (this.lastShorelinePosition.z == cmpPosition.GetPosition().z))
| 355| 355| 		{
| 356| 356| 			// we were already on the shoreline, and have not moved since
| 357| 357| 			if (DistanceBetweenEntities(this.entity, this.order.data.target) < 50)
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'else'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
| 517| 517| 					this.PushOrderFront("Walk", this.order.data.lastPos);
| 518| 518| 				}
| 519| 519| 				else
| 520|    |-				{
|    | 520|+				
| 521| 521| 					// We couldn't move there, or the target moved away
| 522| 522| 					this.FinishOrder();
| 523|    |-				}
|    | 523|+				
| 524| 524| 				return;
| 525| 525| 			}
| 526| 526| 
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
| 736| 736| 			}
| 737| 737| 			// Check if we are already in range, otherwise walk there
| 738| 738| 			if (!this.CheckGarrisonRange(msg.data.target))
| 739|    |-			{
|    | 739|+			
| 740| 740| 				if (!this.CheckTargetVisible(msg.data.target))
| 741| 741| 				{
| 742| 742| 					this.FinishOrder();
| 747| 747| 					this.SetNextState("GARRISON.APPROACHING");
| 748| 748| 					return;
| 749| 749| 				}
| 750|    |-			}
|    | 750|+			
| 751| 751| 
| 752| 752| 			this.SetNextState("GARRISON.GARRISONING");
| 753| 753| 		},
|    | [NORMAL] ESLintBear (no-else-return):
|    | Unnecessary 'else' after 'return'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
| 742| 742| 					this.FinishOrder();
| 743| 743| 					return;
| 744| 744| 				}
| 745|    |-				else
| 746|    |-				{
|    | 745|+				
| 747| 746| 					this.SetNextState("GARRISON.APPROACHING");
| 748| 747| 					return;
| 749|    |-				}
|    | 748|+				
| 750| 749| 			}
| 751| 750| 
| 752| 751| 			this.SetNextState("GARRISON.GARRISONING");
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'else'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
| 765| 765| 						this.PushOrderFront("Walk", msg.data.lastPos);
| 766| 766| 					}
| 767| 767| 					else
| 768|    |-					{
|    | 768|+					
| 769| 769| 						// We couldn't move there, or the target moved away
| 770| 770| 						this.FinishOrder();
| 771|    |-					}
|    | 771|+					
| 772| 772| 					return;
| 773| 773| 				}
| 774| 774| 
|    | [NORMAL] ESLintBear (key-spacing):
|    | Missing space before value for key 'GARRISON'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
| 998| 998| 			},
| 999| 999| 		},
|1000|1000| 
|1001|    |-		"GARRISON":{
|    |1001|+		"GARRISON": {
|1002|1002| 			"enter": function() {
|1003|1003| 				// If the garrisonholder should pickup, warn it so it can take needed action
|1004|1004| 				var cmpGarrisonHolder = Engine.QueryInterface(this.order.data.target, IID_GarrisonHolder);
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|1211|1211| 			// If the controller handled an order but some members rejected it,
|1212|1212| 			// they will have no orders and be in the FORMATIONMEMBER.IDLE state.
|1213|1213| 			if (this.orderQueue.length)
|1214|    |-			{
|    |1214|+			
|1215|1215| 				// We're leaving the formation, so stop our FormationWalk order
|1216|1216| 				if (this.FinishOrder())
|1217|1217| 					return;
|1218|    |-			}
|    |1218|+			
|1219|1219| 
|1220|1220| 			// No orders left, we're an individual now
|1221|1221| 			if (this.IsAnimal())
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|1239|1239| 			// Move a tile outside the building
|1240|1240| 			let range = 4;
|1241|1241| 			if (this.CheckTargetRangeExplicit(msg.data.target, range, -1))
|1242|    |-			{
|    |1242|+			
|1243|1243| 				// We are already at the target, or can't move at all
|1244|1244| 				this.FinishOrder();
|1245|    |-			}
|    |1245|+			
|1246|1246| 			else
|1247|1247| 			{
|1248|1248| 				this.order.data.min = range;
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|1431|1431| 
|1432|1432| 			"LosRangeUpdate": function(msg) {
|1433|1433| 				if (this.GetStance().targetVisibleEnemies)
|1434|    |-				{
|    |1434|+				
|1435|1435| 					// Start attacking one of the newly-seen enemy (if any)
|1436|1436| 					this.AttackEntitiesByPreference(msg.data.added);
|1437|    |-				}
|    |1437|+				
|1438|1438| 			},
|1439|1439| 
|1440|1440| 			"LosHealRangeUpdate": function(msg) {
|    | [NORMAL] ESLintBear (space-before-function-paren):
|    | Unexpected space before function parentheses.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|1484|1484| 				this.SelectAnimation("move");
|1485|1485| 			},
|1486|1486| 
|1487|    |-			"leave": function () {
|    |1487|+			"leave": function() {
|1488|1488| 				this.SelectAnimation("idle");
|1489|1489| 				this.StopMoving();
|1490|1490| 			},
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|1664|1664| 						// if nothing better to do, check if the guarded needs to be healed or repaired
|1665|1665| 						var cmpHealth = Engine.QueryInterface(this.isGuardOf, IID_Health);
|1666|1666| 						if (cmpHealth && cmpHealth.IsInjured())
|1667|    |-						{
|    |1667|+						
|1668|1668| 							if (this.CanHeal(this.isGuardOf))
|1669|1669| 								this.PushOrderFront("Heal", { "target": this.isGuardOf, "force": false });
|1670|1670| 							else if (this.CanRepair(this.isGuardOf))
|1671|1671| 								this.PushOrderFront("Repair", { "target": this.isGuardOf, "autocontinue": false, "force": false });
|1672|    |-						}
|    |1672|+						
|1673|1673| 					}
|1674|1674| 				},
|1675|1675| 
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|1954|1954| 
|1955|1955| 				"Attacked": function(msg) {
|1956|1956| 					// If we are capturing and are attacked by something that we would not capture, attack that entity instead
|1957|    |-					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force)
|1958|    |-						&& this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|    |1957|+					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force) &&
|    |1958|+						this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|1959|1959| 						this.RespondToTargetedEntities([msg.data.attacker]);
|1960|1960| 				},
|1961|1961| 			},
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|2007|2007| 					this.SelectAnimation("move");
|2008|2008| 					var cmpUnitAI = Engine.QueryInterface(this.order.data.target, IID_UnitAI);
|2009|2009| 					if (cmpUnitAI && cmpUnitAI.IsFleeing())
|2010|    |-					{
|    |2010|+					
|2011|2011| 						// Run after a fleeing target
|2012|2012| 						this.SetSpeedMultiplier(this.GetRunMultiplier());
|2013|    |-					}
|    |2013|+					
|2014|2014| 					this.StartTimer(1000, 1000);
|2015|2015| 				},
|2016|2016| 
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|2361|2361| 
|2362|2362| 				"Timer": function(msg) {
|2363|2363| 					if (this.ShouldAbandonChase(this.order.data.target, this.order.data.force, IID_Heal, null))
|2364|    |-					{
|    |2364|+					
|2365|2365| 						// Return to our original position unless we have a better order.
|2366|2366| 						if (!this.FinishOrder() && this.GetStance().respondHoldGround)
|2367|2367| 							this.WalkToHeldPosition();
|2368|    |-					}
|    |2368|+					
|2369|2369| 				},
|2370|2370| 
|2371|2371| 				"MovementUpdate": function() {
|    | [NORMAL] ESLintBear (no-unneeded-ternary):
|    | Unnecessary use of boolean literals in conditional expression.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|2395|2395| 					this.StartTimer(prepare, this.healTimers.repeat);
|2396|2396| 
|2397|2397| 					// If using a non-default prepare time, re-sync the animation when the timer runs.
|2398|    |-					this.resyncAnimation = (prepare != this.healTimers.prepare) ? true : false;
|    |2398|+					this.resyncAnimation = (prepare != this.healTimers.prepare);
|2399|2399| 
|2400|2400| 					this.FaceTowardsTarget(this.order.data.target);
|2401|2401| 				},
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|2607|2607| 					{
|2608|2608| 						// The building was already finished/fully repaired before we arrived;
|2609|2609| 						// let the ConstructionFinished handler handle this.
|2610|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2610|+						this.OnGlobalConstructionFinished({ "entity": this.repairTarget, "newentity": this.repairTarget});
|2611|2611| 						return true;
|2612|2612| 					}
|2613|2613| 
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|2607|2607| 					{
|2608|2608| 						// The building was already finished/fully repaired before we arrived;
|2609|2609| 						// let the ConstructionFinished handler handle this.
|2610|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2610|+						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget });
|2611|2611| 						return true;
|2612|2612| 					}
|2613|2613| 
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|2799|2799| 
|2800|2800| 					// Check that we can garrison here
|2801|2801| 					if (this.CanGarrison(target))
|2802|    |-					{
|    |2802|+					
|2803|2803| 						// Check that we're in range of the garrison target
|2804|2804| 						if (this.CheckGarrisonRange(target))
|2805|2805| 						{
|2875|2875| 								return false;
|2876|2876| 							}
|2877|2877| 						}
|2878|    |-					}
|    |2878|+					
|2879|2879| 					// Garrisoning failed for some reason, so finish the order
|2880|2880| 					this.FinishOrder();
|2881|2881| 					return true;
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|2996|2996| 		"Attacked": function(msg) {
|2997|2997| 			if (this.template.NaturalBehaviour == "skittish" ||
|2998|2998| 			    this.template.NaturalBehaviour == "passive")
|2999|    |-			{
|    |2999|+			
|3000|3000| 				this.Flee(msg.data.attacker, false);
|3001|    |-			}
|    |3001|+			
|3002|3002| 			else if (this.IsDangerousAnimal() || this.template.NaturalBehaviour == "defensive")
|3003|3003| 			{
|3004|3004| 				if (this.CanAttack(msg.data.attacker))
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|3005|3005| 					this.Attack(msg.data.attacker, false);
|3006|3006| 			}
|3007|3007| 			else if (this.template.NaturalBehaviour == "domestic")
|3008|    |-			{
|    |3008|+			
|3009|3009| 				// Never flee, stop what we were doing
|3010|3010| 				this.SetNextState("IDLE");
|3011|    |-			}
|    |3011|+			
|3012|3012| 		},
|3013|3013| 
|3014|3014| 		"Order.LeaveFoundation": function(msg) {
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|3060|3060| 				}
|3061|3061| 				// Start attacking one of the newly-seen enemy (if any)
|3062|3062| 				else if (this.IsDangerousAnimal())
|3063|    |-				{
|    |3063|+				
|3064|3064| 					this.AttackVisibleEntity(msg.data.added);
|3065|    |-				}
|    |3065|+				
|3066|3066| 
|3067|3067| 				// TODO: if two units enter our range together, we'll attack the
|3068|3068| 				// first and then the second won't trigger another LosRangeUpdate
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|3103|3103| 				}
|3104|3104| 				// Start attacking one of the newly-seen enemy (if any)
|3105|3105| 				else if (this.template.NaturalBehaviour == "violent")
|3106|    |-				{
|    |3106|+				
|3107|3107| 					this.AttackVisibleEntity(msg.data.added);
|3108|    |-				}
|    |3108|+				
|3109|3109| 			},
|3110|3110| 
|3111|3111| 			"Timer": function(msg) {
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 2 tabs but found 7.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|3118|3118| 		"COMBAT": "INDIVIDUAL.COMBAT", // reuse the same combat behaviour for animals
|3119|3119| 
|3120|3120| 		"WALKING": "INDIVIDUAL.WALKING",	// reuse the same walking behaviour for animals
|3121|    |-							// only used for domestic animals
|    |3121|+		// only used for domestic animals
|3122|3122| 	},
|3123|3123| };
|3124|3124| 
|    | [NORMAL] ESLintBear (no-unneeded-ternary):
|    | Unnecessary use of boolean literals in conditional expression.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|3175|3175| 
|3176|3176| UnitAI.prototype.IsAnimal = function()
|3177|3177| {
|3178|    |-	return (this.template.NaturalBehaviour ? true : false);
|    |3178|+	return (!!this.template.NaturalBehaviour);
|3179|3179| };
|3180|3180| 
|3181|3181| UnitAI.prototype.IsDangerousAnimal = function()
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|3213|3213| UnitAI.prototype.GetGarrisonHolder = function()
|3214|3214| {
|3215|3215| 	if (this.IsGarrisoned())
|3216|    |-	{
|    |3216|+	
|3217|3217| 		for (let order of this.orderQueue)
|3218|3218| 			if (order.type == "Garrison")
|3219|3219| 				return order.data.target;
|3220|    |-	}
|    |3220|+	
|3221|3221| 	return INVALID_ENTITY;
|3222|3222| };
|3223|3223| 
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|3291|3291| 		{
|3292|3292| 			let index = this.GetCurrentState().indexOf(".");
|3293|3293| 			if (index != -1)
|3294|    |-				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0,index));
|    |3294|+				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0, index));
|3295|3295| 			this.Stop(false);
|3296|3296| 		}
|3297|3297| 
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|3347|3347| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3348|3348| 			continue;
|3349|3349| 		if (i == 0)
|3350|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3350|+			this.UnitFsm.ProcessMessage(this, { "type": "PickupCanceled", "data": msg});
|3351|3351| 		else
|3352|3352| 			this.orderQueue.splice(i, 1);
|3353|3353| 		Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|3347|3347| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3348|3348| 			continue;
|3349|3349| 		if (i == 0)
|3350|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3350|+			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg });
|3351|3351| 		else
|3352|3352| 			this.orderQueue.splice(i, 1);
|3353|3353| 		Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|3431|3431| };
|3432|3432| 
|3433|3433| 
|3434|    |-//// FSM linkage functions ////
|    |3434|+// // FSM linkage functions ////
|3435|3435| 
|3436|3436| // Setting the next state to the current state will leave/re-enter the top-most substate.
|3437|3437| UnitAI.prototype.SetNextState = function(state)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|3601|3601| 				continue;
|3602|3602| 			if (this.orderQueue[i].type == type)
|3603|3603| 				continue;
|3604|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3604|+			this.orderQueue.splice(i, 0, { "type": type, "data": data});
|3605|3605| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3606|3606| 			return;
|3607|3607| 		}
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|3601|3601| 				continue;
|3602|3602| 			if (this.orderQueue[i].type == type)
|3603|3603| 				continue;
|3604|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3604|+			this.orderQueue.splice(i, 0, {"type": type, "data": data });
|3605|3605| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3606|3606| 			return;
|3607|3607| 		}
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|3615|3615| {
|3616|3616| 	// Remember the previous work orders to be able to go back to them later if required
|3617|3617| 	if (data && data.force)
|3618|    |-	{
|    |3618|+	
|3619|3619| 		if (this.IsFormationController())
|3620|3620| 			this.CallMemberFunction("UpdateWorkOrders", [type]);
|3621|3621| 		else
|3622|3622| 			this.UpdateWorkOrders(type);
|3623|    |-	}
|    |3623|+	
|3624|3624| 
|3625|3625| 	let garrisonHolder = this.IsGarrisoned() && type != "Ungarrison" ? this.GetGarrisonHolder() : null;
|3626|3626| 
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|3692|3692| 	{
|3693|3693| 		var cmpUnitAI = Engine.QueryInterface(this.formationController, IID_UnitAI);
|3694|3694| 		if (cmpUnitAI)
|3695|    |-		{
|    |3695|+		
|3696|3696| 			for (var i = 0; i < cmpUnitAI.orderQueue.length; ++i)
|3697|3697| 			{
|3698|3698| 				if (isWorkType(cmpUnitAI.orderQueue[i].type))
|3701|3701| 					return;
|3702|3702| 				}
|3703|3703| 			}
|3704|    |-		}
|    |3704|+		
|3705|3705| 	}
|3706|3706| 
|3707|3707| 	// If nothing found, take the unit orders
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'for' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|3694|3694| 		if (cmpUnitAI)
|3695|3695| 		{
|3696|3696| 			for (var i = 0; i < cmpUnitAI.orderQueue.length; ++i)
|3697|    |-			{
|    |3697|+			
|3698|3698| 				if (isWorkType(cmpUnitAI.orderQueue[i].type))
|3699|3699| 				{
|3700|3700| 					this.workOrders = cmpUnitAI.orderQueue.slice(i);
|3701|3701| 					return;
|3702|3702| 				}
|3703|    |-			}
|    |3703|+			
|3704|3704| 		}
|3705|3705| 	}
|3706|3706| 
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'for' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|3706|3706| 
|3707|3707| 	// If nothing found, take the unit orders
|3708|3708| 	for (var i = 0; i < this.orderQueue.length; ++i)
|3709|    |-	{
|    |3709|+	
|3710|3710| 		if (isWorkType(this.orderQueue[i].type))
|3711|3711| 		{
|3712|3712| 			this.workOrders = this.orderQueue.slice(i);
|3713|3713| 			return;
|3714|3714| 		}
|3715|    |-	}
|    |3715|+	
|3716|3716| };
|3717|3717| 
|3718|3718| UnitAI.prototype.BackToWork = function()
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|3772|3772| 	if (data.timerRepeat === undefined)
|3773|3773| 		this.timer = undefined;
|3774|3774| 
|3775|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |3775|+	this.UnitFsm.ProcessMessage(this, { "type": "Timer", "data": data, "lateness": lateness});
|3776|3776| };
|3777|3777| 
|3778|3778| /**
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|3772|3772| 	if (data.timerRepeat === undefined)
|3773|3773| 		this.timer = undefined;
|3774|3774| 
|3775|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |3775|+	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness });
|3776|3776| };
|3777|3777| 
|3778|3778| /**
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|3807|3807| 	this.timer = undefined;
|3808|3808| };
|3809|3809| 
|3810|    |-//// Message handlers /////
|    |3810|+// // Message handlers /////
|3811|3811| 
|3812|3812| UnitAI.prototype.OnMotionChanged = function(msg)
|3813|3813| {
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|3819|3819| 	// TODO: This is a bit inefficient since every unit listens to every
|3820|3820| 	// construction message - ideally we could scope it to only the one we're building
|3821|3821| 
|3822|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |3822|+	this.UnitFsm.ProcessMessage(this, { "type": "ConstructionFinished", "data": msg});
|3823|3823| };
|3824|3824| 
|3825|3825| UnitAI.prototype.OnGlobalEntityRenamed = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|3819|3819| 	// TODO: This is a bit inefficient since every unit listens to every
|3820|3820| 	// construction message - ideally we could scope it to only the one we're building
|3821|3821| 
|3822|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |3822|+	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg });
|3823|3823| };
|3824|3824| 
|3825|3825| UnitAI.prototype.OnGlobalEntityRenamed = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|3844|3844| 
|3845|3845| UnitAI.prototype.OnAttacked = function(msg)
|3846|3846| {
|3847|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |3847|+	this.UnitFsm.ProcessMessage(this, { "type": "Attacked", "data": msg});
|3848|3848| };
|3849|3849| 
|3850|3850| UnitAI.prototype.OnGuardedAttacked = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|3844|3844| 
|3845|3845| UnitAI.prototype.OnAttacked = function(msg)
|3846|3846| {
|3847|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |3847|+	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg });
|3848|3848| };
|3849|3849| 
|3850|3850| UnitAI.prototype.OnGuardedAttacked = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|3849|3849| 
|3850|3850| UnitAI.prototype.OnGuardedAttacked = function(msg)
|3851|3851| {
|3852|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |3852|+	this.UnitFsm.ProcessMessage(this, { "type": "GuardedAttacked", "data": msg.data});
|3853|3853| };
|3854|3854| 
|3855|3855| UnitAI.prototype.OnHealthChanged = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|3849|3849| 
|3850|3850| UnitAI.prototype.OnGuardedAttacked = function(msg)
|3851|3851| {
|3852|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |3852|+	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data });
|3853|3853| };
|3854|3854| 
|3855|3855| UnitAI.prototype.OnHealthChanged = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|3854|3854| 
|3855|3855| UnitAI.prototype.OnHealthChanged = function(msg)
|3856|3856| {
|3857|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |3857|+	this.UnitFsm.ProcessMessage(this, { "type": "HealthChanged", "from": msg.from, "to": msg.to});
|3858|3858| };
|3859|3859| 
|3860|3860| UnitAI.prototype.OnRangeUpdate = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|3854|3854| 
|3855|3855| UnitAI.prototype.OnHealthChanged = function(msg)
|3856|3856| {
|3857|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |3857|+	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to });
|3858|3858| };
|3859|3859| 
|3860|3860| UnitAI.prototype.OnRangeUpdate = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|3860|3860| UnitAI.prototype.OnRangeUpdate = function(msg)
|3861|3861| {
|3862|3862| 	if (msg.tag == this.losRangeQuery)
|3863|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|    |3863|+		this.UnitFsm.ProcessMessage(this, { "type": "LosRangeUpdate", "data": msg});
|3864|3864| 	else if (msg.tag == this.losHealRangeQuery)
|3865|3865| 		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|3866|3866| };
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|3860|3860| UnitAI.prototype.OnRangeUpdate = function(msg)
|3861|3861| {
|3862|3862| 	if (msg.tag == this.losRangeQuery)
|3863|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|    |3863|+		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg });
|3864|3864| 	else if (msg.tag == this.losHealRangeQuery)
|3865|3865| 		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|3866|3866| };
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|3862|3862| 	if (msg.tag == this.losRangeQuery)
|3863|3863| 		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|3864|3864| 	else if (msg.tag == this.losHealRangeQuery)
|3865|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|    |3865|+		this.UnitFsm.ProcessMessage(this, { "type": "LosHealRangeUpdate", "data": msg});
|3866|3866| };
|3867|3867| 
|3868|3868| UnitAI.prototype.OnPackFinished = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|3862|3862| 	if (msg.tag == this.losRangeQuery)
|3863|3863| 		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|3864|3864| 	else if (msg.tag == this.losHealRangeQuery)
|3865|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|    |3865|+		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg });
|3866|3866| };
|3867|3867| 
|3868|3868| UnitAI.prototype.OnPackFinished = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|3867|3867| 
|3868|3868| UnitAI.prototype.OnPackFinished = function(msg)
|3869|3869| {
|3870|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |3870|+	this.UnitFsm.ProcessMessage(this, { "type": "PackFinished", "packed": msg.packed});
|3871|3871| };
|3872|3872| 
|3873|3873| //// Helper functions to be called by the FSM ////
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|3867|3867| 
|3868|3868| UnitAI.prototype.OnPackFinished = function(msg)
|3869|3869| {
|3870|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |3870|+	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed });
|3871|3871| };
|3872|3872| 
|3873|3873| //// Helper functions to be called by the FSM ////
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|3870|3870| 	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|3871|3871| };
|3872|3872| 
|3873|    |-//// Helper functions to be called by the FSM ////
|    |3873|+// // Helper functions to be called by the FSM ////
|3874|3874| 
|3875|3875| UnitAI.prototype.GetWalkSpeed = function()
|3876|3876| {
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'else'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|4057|4057| 			PlaySound(name, member);
|4058|4058| 	}
|4059|4059| 	else
|4060|    |-	{
|    |4060|+	
|4061|4061| 		// Otherwise use our own sounds
|4062|4062| 		PlaySound(name, this.entity);
|4063|    |-	}
|    |4063|+	
|4064|4064| };
|4065|4065| 
|4066|4066| /*
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|4503|4503| UnitAI.prototype.AttackEntityInZone = function(ents)
|4504|4504| {
|4505|4505| 	var target = ents.find(target =>
|4506|    |-		this.CanAttack(target)
|4507|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|    |4506|+		this.CanAttack(target) &&
|    |4507|+		this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4508|4508| 		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4509|4509| 	);
|4510|4510| 	if (!target)
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|4504|4504| {
|4505|4505| 	var target = ents.find(target =>
|4506|4506| 		this.CanAttack(target)
|4507|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4508|    |-		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|    |4507|+		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true)) &&
|    |4508|+		(this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4509|4509| 	);
|4510|4510| 	if (!target)
|4511|4511| 		return false;
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before 'Engine'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|4568|4568| 	// If we are guarding/escorting, don't abandon as long as the guarded unit is in target range of the attacker
|4569|4569| 	if (this.isGuardOf)
|4570|4570| 	{
|4571|    |-		var cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |4571|+		var cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|4572|4572| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4573|4573| 		if (cmpUnitAI && cmpAttack &&
|4574|4574| 		    cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type)))
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 3 tabs but found 4.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|4572|4572| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4573|4573| 		if (cmpUnitAI && cmpAttack &&
|4574|4574| 		    cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type)))
|4575|    |-				return false;
|    |4575|+			return false;
|4576|4576| 	}
|4577|4577| 
|4578|4578| 	// Stop if we're in hold-ground mode and it's too far from the holding point
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|4577|4577| 
|4578|4578| 	// Stop if we're in hold-ground mode and it's too far from the holding point
|4579|4579| 	if (this.GetStance().respondHoldGround)
|4580|    |-	{
|    |4580|+	
|4581|4581| 		if (!this.CheckTargetDistanceFromHeldPosition(target, iid, type))
|4582|4582| 			return true;
|4583|    |-	}
|    |4583|+	
|4584|4584| 
|4585|4585| 	// Stop if it's left our vision range, unless we're especially persistent
|4586|4586| 	if (!this.GetStance().respondChaseBeyondVision)
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|4584|4584| 
|4585|4585| 	// Stop if it's left our vision range, unless we're especially persistent
|4586|4586| 	if (!this.GetStance().respondChaseBeyondVision)
|4587|    |-	{
|    |4587|+	
|4588|4588| 		if (!this.CheckTargetIsInVisionRange(target))
|4589|4589| 			return true;
|4590|    |-	}
|    |4590|+	
|4591|4591| 
|4592|4592| 	// (Note that CCmpUnitMotion will detect if the target is lost in FoW,
|4593|4593| 	// and will continue moving to its last seen position and then stop)
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before 'Engine'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|4610|4610| 	// If we are guarding/escorting, chase at least as long as the guarded unit is in target range of the attacker
|4611|4611| 	if (this.isGuardOf)
|4612|4612| 	{
|4613|    |-		let cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |4613|+		let cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|4614|4614| 		let cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4615|4615| 		if (cmpUnitAI && cmpAttack &&
|4616|4616| 		    cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type)))
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|4623|4623| 	return false;
|4624|4624| };
|4625|4625| 
|4626|    |-//// External interface functions ////
|    |4626|+// // External interface functions ////
|4627|4627| 
|4628|4628| UnitAI.prototype.SetFormationController = function(ent)
|4629|4629| {
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|4633|4633| 	// of our own formation (or ourself if not in formation)
|4634|4634| 	var cmpObstruction = Engine.QueryInterface(this.entity, IID_Obstruction);
|4635|4635| 	if (cmpObstruction)
|4636|    |-	{
|    |4636|+	
|4637|4637| 		if (ent == INVALID_ENTITY)
|4638|4638| 			cmpObstruction.SetControlGroup(this.entity);
|4639|4639| 		else
|4640|4640| 			cmpObstruction.SetControlGroup(ent);
|4641|    |-	}
|    |4641|+	
|4642|4642| 
|4643|4643| 	// If we were removed from a formation, let the FSM switch back to INDIVIDUAL
|4644|4644| 	if (ent == INVALID_ENTITY)
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|4776|4776| 	// if we already had an old guard order, do nothing if the target is the same
|4777|4777| 	// and the order is running, otherwise remove the previous order
|4778|4778| 	if (this.isGuardOf)
|4779|    |-	{
|    |4779|+	
|4780|4780| 		if (this.isGuardOf == target && this.order && this.order.type == "Guard")
|4781|4781| 			return;
|4782|4782| 		else
|4783|4783| 			this.RemoveGuard();
|4784|    |-	}
|    |4784|+	
|4785|4785| 
|4786|4786| 	this.AddOrder("Guard", { "target": target, "force": false }, queued);
|4787|4787| };
|    | [NORMAL] ESLintBear (no-else-return):
|    | Unnecessary 'else' after 'return'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|4779|4779| 	{
|4780|4780| 		if (this.isGuardOf == target && this.order && this.order.type == "Guard")
|4781|4781| 			return;
|4782|    |-		else
|4783|    |-			this.RemoveGuard();
|    |4782|+		this.RemoveGuard();
|4784|4783| 	}
|4785|4784| 
|4786|4785| 	this.AddOrder("Guard", { "target": target, "force": false }, queued);
|    | [NORMAL] ESLintBear (no-trailing-spaces):
|    | Trailing spaces not allowed.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|5111|5111| 	    this.workOrders.length && this.workOrders[0].type == "Trade")
|5112|5112| 	{
|5113|5113| 		let cmpTrader = Engine.QueryInterface(this.entity, IID_Trader);
|5114|    |-		if (cmpTrader.HasBothMarkets() && 
|    |5114|+		if (cmpTrader.HasBothMarkets() &&
|5115|5115| 		   (cmpTrader.GetFirstMarket() == target && cmpTrader.GetSecondMarket() == source ||
|5116|5116| 		    cmpTrader.GetFirstMarket() == source && cmpTrader.GetSecondMarket() == target))
|5117|5117| 		{
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|5392|5392| 				{
|5393|5393| 					var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5394|5394| 					var targetClasses = this.order.data.targetClasses;
|5395|    |-					if (targetClasses.attack && cmpIdentity
|5396|    |-						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5395|+					if (targetClasses.attack && cmpIdentity &&
|    |5396|+						!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5397|5397| 						continue;
|5398|5398| 					if (targetClasses.avoid && cmpIdentity
|5399|5399| 						&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|5395|5395| 					if (targetClasses.attack && cmpIdentity
|5396|5396| 						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5397|5397| 						continue;
|5398|    |-					if (targetClasses.avoid && cmpIdentity
|5399|    |-						&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5398|+					if (targetClasses.avoid && cmpIdentity &&
|    |5399|+						MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5400|5400| 						continue;
|5401|5401| 					// Only used by the AIs to prevent some choices of targets
|5402|5402| 					if (targetClasses.vetoEntities && targetClasses.vetoEntities[targ])
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|5418|5418| 		{
|5419|5419| 			var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5420|5420| 			var targetClasses = this.order.data.targetClasses;
|5421|    |-			if (cmpIdentity && targetClasses.attack
|5422|    |-				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5421|+			if (cmpIdentity && targetClasses.attack &&
|    |5422|+				!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5423|5423| 				continue;
|5424|5424| 			if (cmpIdentity && targetClasses.avoid
|5425|5425| 				&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|5421|5421| 			if (cmpIdentity && targetClasses.attack
|5422|5422| 				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5423|5423| 				continue;
|5424|    |-			if (cmpIdentity && targetClasses.avoid
|5425|    |-				&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5424|+			if (cmpIdentity && targetClasses.avoid &&
|    |5425|+				MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5426|5426| 				continue;
|5427|5427| 			// Only used by the AIs to prevent some choices of targets
|5428|5428| 			if (targetClasses.vetoEntities && targetClasses.vetoEntities[targ])
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|5578|5578| 
|5579|5579| UnitAI.prototype.SetHeldPosition = function(x, z)
|5580|5580| {
|5581|    |-	this.heldPosition = {"x": x, "z": z};
|    |5581|+	this.heldPosition = { "x": x, "z": z};
|5582|5582| };
|5583|5583| 
|5584|5584| UnitAI.prototype.SetHeldPositionOnEntity = function(entity)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|5578|5578| 
|5579|5579| UnitAI.prototype.SetHeldPosition = function(x, z)
|5580|5580| {
|5581|    |-	this.heldPosition = {"x": x, "z": z};
|    |5581|+	this.heldPosition = {"x": x, "z": z };
|5582|5582| };
|5583|5583| 
|5584|5584| UnitAI.prototype.SetHeldPositionOnEntity = function(entity)
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|5605|5605| 	return false;
|5606|5606| };
|5607|5607| 
|5608|    |-//// Helper functions ////
|    |5608|+// // Helper functions ////
|5609|5609| 
|5610|5610| UnitAI.prototype.CanAttack = function(target)
|5611|5611| {
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|5809|5809| 	return cmpPack && cmpPack.IsPacking();
|5810|5810| };
|5811|5811| 
|5812|    |-//// Formation specific functions ////
|    |5812|+// // Formation specific functions ////
|5813|5813| 
|5814|5814| UnitAI.prototype.IsAttackingAsFormation = function()
|5815|5815| {
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|5814|5814| UnitAI.prototype.IsAttackingAsFormation = function()
|5815|5815| {
|5816|5816| 	var cmpAttack = Engine.QueryInterface(this.entity, IID_Attack);
|5817|    |-	return cmpAttack && cmpAttack.CanAttackAsFormation()
|5818|    |-		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|    |5817|+	return cmpAttack && cmpAttack.CanAttackAsFormation() &&
|    |5818|+		this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|5819|5819| };
|5820|5820| 
|5821|5821| //// Animal specific functions ////
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/UnitAI.js
|5818|5818| 		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|5819|5819| };
|5820|5820| 
|5821|    |-//// Animal specific functions ////
|    |5821|+// // Animal specific functions ////
|5822|5822| 
|5823|5823| UnitAI.prototype.MoveRandomly = function(distance)
|5824|5824| {

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

binaries/data/mods/public/simulation/components/UnitAI.js
| 891| »   »   »   "enter":·function()·{
|    | [NORMAL] ESLintBear (consistent-return):
|    | Expected to return a value at the end of method 'enter'.

binaries/data/mods/public/simulation/components/UnitAI.js
| 913| »   »   »   "enter":·function(msg)·{
|    | [NORMAL] ESLintBear (consistent-return):
|    | Expected to return a value at the end of method 'enter'.

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

binaries/data/mods/public/simulation/components/UnitAI.js
|1023| »   »   »   »   "enter":·function()·{
|    | [NORMAL] ESLintBear (consistent-return):
|    | Expected to return a value at the end of method 'enter'.

binaries/data/mods/public/simulation/components/UnitAI.js
|1058| »   »   »   "enter":·function()·{
|    | [NORMAL] ESLintBear (consistent-return):
|    | Expected to return a value at the end of method 'enter'.

binaries/data/mods/public/simulation/components/UnitAI.js
|1090| »   »   »   »   "enter":·function()·{
|    | [NORMAL] ESLintBear (consistent-return):
|    | Expected to return a value at the end of method 'enter'.

binaries/data/mods/public/simulation/components/UnitAI.js
|1304| »   »   »   "enter":·function()·{
|    | [NORMAL] ESLintBear (consistent-return):
|    | Expected to return a value at the end of method 'enter'.

binaries/data/mods/public/simulation/components/UnitAI.js
|1478| »   »   »   "enter":·function()·{
|    | [NORMAL] ESLintBear (consistent-return):
|    | Expected to return a value at the end of method 'enter'.

binaries/data/mods/public/simulation/components/UnitAI.js
|1499| »   »   »   "enter":·function()·{
|    | [NORMAL] ESLintBear (consistent-return):
|    | Expected to return a value at the end of method 'enter'.

binaries/data/mods/public/simulation/components/UnitAI.js
|1529| »   »   »   "enter":·function()·{
|    | [NORMAL] ESLintBear (consistent-return):
|    | Expected to return a value at the end of method 'enter'.

binaries/data/mods/public/simulation/components/UnitAI.js
|1684| »   »   »   "enter":·function()·{
|    | [NORMAL] ESLintBear (consistent-return):
|    | Expected to return a value at the end of method 'enter'.

binaries/data/mods/public/simulation/components/UnitAI.js
|1735| »   »   »   »   "enter":·function()·{
|    | [NORMAL] ESLintBear (consistent-return):
|    | Expected to return a value at the end of method 'enter'.

binaries/data/mods/public/simulation/components/UnitAI.js
|1811| »   »   »   »   "enter":·function()·{
|    | [NORMAL] ESLintBear (consistent-return):
|    | Expected to return a value at the end of method 'enter'.

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

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

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

binaries/data/mods/public/simulation/components/UnitAI.js
|1997| »   »   »   »   "enter":·function()·{
|    | [NORMAL] ESLintBear (consistent-return):
|    | Expected to return a value at the end of method 'enter'.

binaries/data/mods/public/simulation/components/UnitAI.js
|2088| »   »   »   »   "enter":·function()·{
|    | [NORMAL] ESLintBear (consistent-return):
|    | Expected to return a value at the end of method 'enter'.

binaries/data/mods/public/simulation/components/UnitAI.js
|2340| »   »   »   »   "enter":·function()·{
|    | [NORMAL] ESLintBear (consistent-return):
|    | Expected to return a value at the end of method 'enter'.

binaries/data/mods/public/simulation/components/UnitAI.js
|2458| »   »   »   »   "enter":·function()·{
|    | [NORMAL] ESLintBear (consistent-return):
|    | Expected to return a value at the end of method 'enter'.

binaries/data/mods/public/simulation/components/UnitAI.js
|2523| »   »   »   »   "enter":·function()·{
|    | [NORMAL] ESLintBear (consistent-return):
|    | Expected to return a value at the end of method 'enter'.

binaries/data/mods/public/simulation/components/UnitAI.js
|2563| »   »   »   »   "enter":·function()·{
|    | [NORMAL] ESLintBear (consistent-return):
|    | Expected to return a value at the end of method 'enter'.

binaries/data/mods/public/simulation/components/UnitAI.js
|2769| »   »   »   »   "enter":·function()·{
|    | [NORMAL] ESLintBear (consistent-return):
|    | Expected to return a value at the end of method 'enter'.

binaries/data/mods/public/simulation/components/UnitAI.js
|2952| »   »   »   »   "enter":·function()·{
|    | [NORMAL] ESLintBear (consistent-return):
|    | Expected to return a value at the end of method 'enter'.

binaries/data/mods/public/simulation/components/UnitAI.js
|3677| »   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
|4490| »   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
|4505| »   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
|4551| »   var·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
|4574| »   »   ····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
| 354| »   »   ····&&·(this.lastShorelinePosition.z·==·cmpPosition.GetPosition().z))
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|1958| »   »   »   »   »   »   &&·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
|2500| »   »   »   »   »   var·cmpResourceGatherer·=·Engine.QueryInterface(this.entity,·IID_ResourceGatherer);
|    | [NORMAL] JSHintBear:
|    | 'cmpResourceGatherer' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|2801| »   »   »   »   »   if·(this.CanGarrison(target))
|    | [NORMAL] JSHintBear:
|    | 'target' used out of scope.

binaries/data/mods/public/simulation/components/UnitAI.js
|2804| »   »   »   »   »   »   if·(this.CheckGarrisonRange(target))
|    | [NORMAL] JSHintBear:
|    | 'target' used out of scope.

binaries/data/mods/public/simulation/components/UnitAI.js
|2806| »   »   »   »   »   »   »   var·cmpGarrisonHolder·=·Engine.QueryInterface(target,·IID_GarrisonHolder);
|    | [NORMAL] JSHintBear:
|    | 'target' used out of scope.

binaries/data/mods/public/simulation/components/UnitAI.js
|2828| »   »   »   »   »   »   »   »   var·cmpResourceDropsite·=·Engine.QueryInterface(target,·IID_ResourceDropsite);
|    | [NORMAL] JSHintBear:
|    | 'target' used out of scope.

binaries/data/mods/public/simulation/components/UnitAI.js
|2829| »   »   »   »   »   »   »   »   if·(cmpResourceDropsite·&&·this.CanReturnResource(target,·true))
|    | [NORMAL] JSHintBear:
|    | 'target' used out of scope.

binaries/data/mods/public/simulation/components/UnitAI.js
|2844| »   »   »   »   »   »   »   »   »   var·cmpHolderPosition·=·Engine.QueryInterface(target,·IID_Position);
|    | [NORMAL] JSHintBear:
|    | 'target' used out of scope.

binaries/data/mods/public/simulation/components/UnitAI.js
|2845| »   »   »   »   »   »   »   »   »   var·cmpHolderUnitAI·=·Engine.QueryInterface(target,·IID_UnitAI);
|    | [NORMAL] JSHintBear:
|    | 'target' used out of scope.

binaries/data/mods/public/simulation/components/UnitAI.js
|2872| »   »   »   »   »   »   »   if·(!this.CheckTargetRangeExplicit(target,·0,·0)·&&·this.MoveToTarget(target))
|    | [NORMAL] JSHintBear:
|    | 'target' used out of scope.

binaries/data/mods/public/simulation/components/UnitAI.js
|2872| »   »   »   »   »   »   »   if·(!this.CheckTargetRangeExplicit(target,·0,·0)·&&·this.MoveToTarget(target))
|    | [NORMAL] JSHintBear:
|    | 'target' used out of scope.

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

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

binaries/data/mods/public/simulation/components/UnitAI.js
|4507| »   »   &&·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
|4508| »   »   &&·(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
|5396| »   »   »   »   »   »   &&·!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
|5399| »   »   »   »   »   »   &&·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
|5412| »   var·targets·=·this.GetTargetsFromUnit();
|    | [NORMAL] JSHintBear:
|    | 'targets' is already defined.

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

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

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

binaries/data/mods/public/simulation/components/UnitAI.js
|5422| »   »   »   »   &&·!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
|5425| »   »   »   »   &&·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
|5500| »   »   var·cmpVision·=·Engine.QueryInterface(this.entity,·IID_Vision);
|    | [NORMAL] JSHintBear:
|    | 'cmpVision' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|5503| »   »   var·range·=·cmpVision.GetRange();
|    | [NORMAL] JSHintBear:
|    | 'range' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|5508| »   »   var·cmpRanged·=·Engine.QueryInterface(this.entity,·iid);
|    | [NORMAL] JSHintBear:
|    | 'cmpRanged' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|5511| »   »   var·range·=·iid·!==·IID_Attack·?·cmpRanged.GetRange()·:·cmpRanged.GetFullAttackRange();
|    | [NORMAL] JSHintBear:
|    | 'range' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|5512| »   »   var·cmpVision·=·Engine.QueryInterface(this.entity,·IID_Vision);
|    | [NORMAL] JSHintBear:
|    | 'cmpVision' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|5522| »   »   var·cmpVision·=·Engine.QueryInterface(this.entity,·IID_Vision);
|    | [NORMAL] JSHintBear:
|    | 'cmpVision' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|5525| »   »   var·range·=·cmpVision.GetRange();
|    | [NORMAL] JSHintBear:
|    | 'range' is already defined.

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

Link to build: https://jenkins.wildfiregames.com/job/differential/1900/display/redirect

wraitii edited the summary of this revision. (Show Details)Fri, Jul 5, 7:56 AM
bb added a subscriber: bb.Fri, Jul 5, 2:31 PM

I have never liked the idle timer, it always have seem a hack to me, I rather get rid of it than moving stuff towards it.

On rP22023:
For me that is the root cause of your second case: entering a state we are already in, this clearly shouldn't happen in this case.

On rP22059:
Sounds like only fixing the issue for IDLE state, who says something similar can't happen with patrol or attack-move (sure there we already have the findNewTargets in the timer and one can't have a garrison+patrol), but also there I rather would get rid of that timer

the order is OKeyed, and the unit moves to ATTACK.enter. There, the Move call fails. The unit calls Finish Order and goes back to Idle. Rinse, repeat, infinite loop.

If we can't move we shouldn't enter the attack state IMO

It's only called once, so it won't lead us to a "slow infinite loop" situation.

Once per enter indeed, but as the timer triggers another enter, we do have a "slow infinite loop".

the order is OKeyed, and the unit moves to ATTACK.enter. There, the Move call fails. The unit calls Finish Order and goes back to Idle. Rinse, repeat, infinite loop.

If we can't move we shouldn't enter the attack state IMO

It's safer to Move in the ATTACK.APPROACHING.enter state because:

  • it moves the code together (stopMoving is in ATTACK.APPROACHING.leave)
  • it makes sure that the unit cannot forget to move in case we enter this state without going through Order.Attack

Either you reject entirely and believe 'enter' state should only do infallible stuff - but then you lose the benefit of the above - or you take the opposite position that 'Order' are mostly useless and states should do more things.

Regardless, it doesn't fix the issue of infinite looping.

It's only called once, so it won't lead us to a "slow infinite loop" situation.

Once per enter indeed, but as the timer triggers another enter, we do have a "slow infinite loop".

True


Feel free to provide a better solution.

Using a boolean variable to avoid re-entering IDLE won't fix the issue for infinite loops between IDLE and some state 'enter', so I don't think it's workable, and it'd be kinda ugly since we would need to clear this every turn.

Still can't think of a better way to do this than the above.

wraitii edited the summary of this revision. (Show Details)Sat, Jul 13, 6:35 PM
This revision was not accepted when it landed; it landed in state Needs Review.Sun, Jul 14, 1:40 PM
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.