Page MenuHomeWildfire Games

Make ship pickup nicer
Needs ReviewPublic

Authored by wraitii on Jun 20 2017, 9:22 PM.

Details

Reviewers
causative
Trac Tickets
#3472
Summary

It's currently sometimes difficult to garrison units in a ship, particularly if the coastline has few available landing spots (e.g. Corsica v Sardinia). You manually direct the ship to the patch of beach where units must be loaded - then you click to load the units into the ship - and immediately the ship moves away from the landing spot!

This is because the ship did not know that it was already on the shore, and it would "helpfully" move closer to the units to try to pick them up. The only way the ship could detect it was on the shore was if it had just previously been given a pickup order, and was still at the same location resulting from the pickup order. Manually moving the ship would change the location, causing the ship to think it is no longer on the shore.

In this patch I add a more reliable test for when the ship is on the shore. I use the hierarchical pathfinder to check if there are any navcells nearby the ship that are reachable by the unit to be picked up.

I also increase the pickup range to 15 from 10, because sometimes it's tricky to get the ship far enough into shore if the coastline is partially obstructed. In doing this, I refactor the GarrisonHolder tag to the base mechanical ship template, to avoid pointless duplication. As a side effect, this means fireships are now also GarrisonHolders (garrison size of 1) which should have zero effect on gameplay.

In the course of testing I noticed an additional bug: Have two ships offshore. Tell the unit to garrison in one ship, but before it finishes doing so, tell the unit to garrison in the other ship instead. The second ship will refuse to pick up the unit, because in UnitAI, the pickup order only occurs when a unit enters the GARRISON state, but the unit was already in the GARRISON state so it could not enter it. I have fixed this bug as well. This bugfix was removed from D665 and split into D2174 on the theory that it would be easier to review in 2 parts.

Test Plan

Have a ship in the open sea away from the shore. Tell a unit to garrison in the ship. The ship should move to the shore so the unit can garrison. (It previously did this; just make sure it still works).

Directly tell the ship to move to a specific point on the coast that the unit can reach. After the ship arrives, tell a unit to garrison in the ship. The ship should not move, and should just wait for the unit.

Tell the ship to move to an area of coast (a cliff, or another island) that the unit can't reach. Tell a unit to garrison in the ship. The ship should move towards the unit.

Have two ships offshore. Tell the unit to garrison in one ship, but before it finishes doing so, tell the unit to garrison in the other ship instead. The second ship should start moving to pick up the unit.

Performance test: tell many units at once to garrison in a ship, on a large map that's mostly land so that the number of reachable hierarchical pathfinding regions is large.

Diff Detail

Repository
rP 0 A.D. Public Repository
Lint
Lint Skipped
Unit
Unit Tests Skipped
Build Status
Buildable 2406
Build 4021: Vulcan BuildJenkins

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
source/simulation2/components/CCmpPathfinder.cpp
254

Couldn't we replace set by unordered_set in future?

264

Spaces around = and below too.

273

Unecessary variable, you could just return a value:

if (...)
    return true;
// after loop
return false;
This revision now requires changes to proceed.Jun 26 2017, 12:10 AM
source/simulation2/components/CCmpPathfinder.cpp
271

... != reachable.end().

causative updated this revision to Diff 2691.Jun 26 2017, 11:16 AM
causative edited edge metadata.

vladislav changes

Build has FAILED

Updating workspaces.
Build (release)...
In file included from ../../../source/simulation2/helpers/LongPathfinder.h:22:0,
                 from ../../../source/simulation2/components/CCmpPathfinder_Common.h:39,
                 from ../../../source/simulation2/components/CCmpPathfinder.cpp:25:
../../../source/simulation2/helpers/HierarchicalPathfinder.h:116:48: error: ‘std::unordered_set’ has not been declared
  void FindReachableRegions(RegionID from, std::unordered_set<RegionID>& reachable, pass_class_t passClass);
                                                ^
../../../source/simulation2/helpers/HierarchicalPathfinder.h:116:61: error: expected ‘,’ or ‘...’ before ‘<’ token
  void FindReachableRegions(RegionID from, std::unordered_set<RegionID>& reachable, pass_class_t passClass);
                                                             ^
../../../source/simulation2/components/CCmpPathfinder.cpp: In member function ‘virtual bool CCmpPathfinder::CheckNearShore(entity_id_t, entity_id_t, fixed) const’:
../../../source/simulation2/components/CCmpPathfinder.cpp:254:2: error: ‘unordered_set’ is not a member of ‘std’
  std::unordered_set<HierarchicalPathfinder::RegionID> reachable;
  ^
../../../source/simulation2/components/CCmpPathfinder.cpp:254:53: error: expected primary-expression before ‘>’ token
  std::unordered_set<HierarchicalPathfinder::RegionID> reachable;
                                                     ^
../../../source/simulation2/components/CCmpPathfinder.cpp:254:55: error: ‘reachable’ was not declared in this scope
  std::unordered_set<HierarchicalPathfinder::RegionID> reachable;
                                                       ^
make[1]: *** [obj/simulation2_Release/CCmpPathfinder.o] Error 1
make: *** [simulation2] Error 2
make: *** Waiting for unfinished jobs....

Link to build: http://jw:8080/job/phabricator/1624/
See console output for more information: http://jw:8080/job/phabricator/1624/console

causative updated this revision to Diff 2693.Jun 26 2017, 11:53 AM
causative marked 4 inline comments as done.
causative marked an inline comment as not done.
causative updated this revision to Diff 2694.Jun 26 2017, 12:38 PM

Fix an additional (pre-existing) bug discovered in UnitAI where if you give the order to garrison the same unit in two ships in a row, the second ship will not pickup.

causative edited the summary of this revision. (Show Details)Jun 26 2017, 12:40 PM
causative edited the test plan for this revision. (Show Details)

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Checking XML files...

http://jw:8080/job/phabricator/1626/ for more details.

causative updated this revision to Diff 2696.Jun 26 2017, 1:20 PM

replaced set with unordered_set (this required it to also be changed in many places in HierarchicalPathfinder)

causative marked 3 inline comments as done.Jun 26 2017, 1:21 PM

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Checking XML files...

http://jw:8080/job/phabricator/1627/ for more details.

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Checking XML files...

http://jw:8080/job/phabricator/1628/ for more details.

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Checking XML files...

http://jw:8080/job/phabricator/1629/ for more details.

this maybe something for @temple ?:)

Adding to my review queue, no promise on when I'll get around to it.

Stan added a subscriber: Stan.Apr 19 2019, 6:14 PM

@wraitii This year maybe ? ;)

At this point it'd probably be usefully rebased on top of D1834... I'll keep this in my review queue as I might commandeer at some point in the future.

The expected player experience is that the ship moves to the closest point to the shoreline where the units to be picked up are.
The current behavior is that the ship moves to the correct island, but upon every garrisoning moves to a presumed better location again (which turns out to be a waste of time in many cases).
If I understood the patch correctly, the behavior of the patch is that the ship moves to the closest shoreline, which may be on an entirely different island, at least.

So if I understand the patch correctly, it changes one defect for another.
But the patch might be adapted to match the expected user behavior.

Imarok added a subscriber: Imarok.Apr 25 2019, 2:26 PM
In D665#76122, @elexis wrote:

The expected player experience is that the ship moves to the closest point to the shoreline where the units to be picked up are.
The current behavior is that the ship moves to the correct island, but upon every garrisoning moves to a presumed better location again (which turns out to be a waste of time in many cases).
If I understood the patch correctly, the behavior of the patch is that the ship moves to the closest shoreline, which may be on an entirely different island, at least.
So if I understand the patch correctly, it changes one defect for another.
But the patch might be adapted to match the expected user behavior.

One easy fix would be that the ship won't move if the units can be garrissoned with the ship not moving.
Or just never move the ship.

causative updated this revision to Diff 10449.Dec 1 2019, 1:45 AM

Updated to trunk. Took out the std::unordered_set change, because other code in HierarchicalPathfinder.cpp now depends on the set being ordered.

causative added a comment.EditedDec 1 2019, 1:48 AM
In D665#76122, @elexis wrote:

If I understood the patch correctly, the behavior of the patch is that the ship moves to the closest shoreline, which may be on an entirely different island, at least.

No. It still goes to the shoreline reachable by the unit, but *only if* the ship was offshore, or on a shore not reachable by the unit, to begin with. If the ship was already on a shore reachable by the unit, now it won't move.

In D665#76161, @Imarok wrote:

One easy fix would be that the ship won't move if the units can be garrissoned with the ship not moving.

That's what the patch already does.

Vulcan added a comment.Dec 1 2019, 1:53 AM

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

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/662/display/redirect

Vulcan added a comment.Dec 1 2019, 2:06 AM

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

Linter detected issues:
Executing section Source...

source/simulation2/components/ICmpPathfinder.cpp
|   1| /*·Copyright·(C)·2017·Wildfire·Games.
|    | [NORMAL] LicenseYearBear:
|    | License should have "2019" year instead of "2017"

source/simulation2/components/ICmpPathfinder.h
|  34| template<typename·T>·class·Grid;
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Code 'template<...' is invalid C code. Use --std or --language to configure the language.

source/simulation2/components/CCmpPathfinder_Common.h
|  34| #include·"graphics/Overlay.h"
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Code 'template<...' is invalid C code. Use --std or --language to configure the language.

source/simulation2/helpers/HierarchicalPathfinder.h
|  34| ·*·is·defined·as·a·region.
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Code 'template<...' is invalid C code. Use --std or --language to configure the language.
Executing section JS...
|    | [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
| 344| 344| 		let cmpGarrisonHolder = Engine.QueryInterface(this.entity, IID_GarrisonHolder);
| 345| 345| 		let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer);
| 346| 346| 
| 347|    |-		if (!cmpTimer || !cmpGarrisonHolder || cmpGarrisonHolder.IsFull()
| 348|    |-			|| this.lastPickupTime && this.lastPickupTime + 100 > cmpTimer.GetTime())
|    | 347|+		if (!cmpTimer || !cmpGarrisonHolder || cmpGarrisonHolder.IsFull() ||
|    | 348|+			this.lastPickupTime && this.lastPickupTime + 100 > cmpTimer.GetTime())
| 349| 349| 		{
| 350| 350| 			this.FinishOrder();
| 351| 351| 			return;
|    | [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
| 763| 763| 					this.FinishOrder();
| 764| 764| 					return;
| 765| 765| 				}
| 766|    |-				else
| 767|    |-				{
|    | 766|+				
| 768| 767| 					this.SetNextState("GARRISON.APPROACHING");
| 769| 768| 					return;
| 770|    |-				}
|    | 769|+				
| 771| 770| 			}
| 772| 771| 
| 773| 772| 			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
|1031|1031| 			},
|1032|1032| 		},
|1033|1033| 
|1034|    |-		"GARRISON":{
|    |1034|+		"GARRISON": {
|1035|1035| 			"leave": function() {
|1036|1036| 				// If a pickup has been requested and not yet canceled, cancel it
|1037|1037| 				if (this.pickup)
|    | [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
|1964|1964| 
|1965|1965| 				"Attacked": function(msg) {
|1966|1966| 					// If we are capturing and are attacked by something that we would not capture, attack that entity instead
|1967|    |-					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force)
|1968|    |-						&& this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|    |1967|+					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force) &&
|    |1968|+						this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|1969|1969| 						this.RespondToTargetedEntities([msg.data.attacker]);
|1970|1970| 				},
|1971|1971| 			},
|    | [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
|2692|2692| 					{
|2693|2693| 						// The building was already finished/fully repaired before we arrived;
|2694|2694| 						// let the ConstructionFinished handler handle this.
|2695|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2695|+						this.OnGlobalConstructionFinished({ "entity": this.repairTarget, "newentity": this.repairTarget});
|2696|2696| 						return true;
|2697|2697| 					}
|2698|2698| 
|    | [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
|2692|2692| 					{
|2693|2693| 						// The building was already finished/fully repaired before we arrived;
|2694|2694| 						// let the ConstructionFinished handler handle this.
|2695|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2695|+						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget });
|2696|2696| 						return true;
|2697|2697| 					}
|2698|2698| 
|    | [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
|3191|3191| 		"COMBAT": "INDIVIDUAL.COMBAT", // reuse the same combat behaviour for animals
|3192|3192| 
|3193|3193| 		"WALKING": "INDIVIDUAL.WALKING",	// reuse the same walking behaviour for animals
|3194|    |-							// only used for domestic animals
|    |3194|+		// only used for domestic animals
|3195|3195| 	},
|3196|3196| };
|3197|3197| 
|    | [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
|3248|3248| 
|3249|3249| UnitAI.prototype.IsAnimal = function()
|3250|3250| {
|3251|    |-	return (this.template.NaturalBehaviour ? true : false);
|    |3251|+	return (!!this.template.NaturalBehaviour);
|3252|3252| };
|3253|3253| 
|3254|3254| 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
|3364|3364| 		{
|3365|3365| 			let index = this.GetCurrentState().indexOf(".");
|3366|3366| 			if (index != -1)
|3367|    |-				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0,index));
|    |3367|+				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0, index));
|3368|3368| 			this.Stop(false);
|3369|3369| 		}
|3370|3370| 
|    | [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
|3420|3420| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3421|3421| 			continue;
|3422|3422| 		if (i == 0)
|3423|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3423|+			this.UnitFsm.ProcessMessage(this, { "type": "PickupCanceled", "data": msg});
|3424|3424| 		else
|3425|3425| 			this.orderQueue.splice(i, 1);
|3426|3426| 		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
|3420|3420| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3421|3421| 			continue;
|3422|3422| 		if (i == 0)
|3423|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3423|+			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg });
|3424|3424| 		else
|3425|3425| 			this.orderQueue.splice(i, 1);
|3426|3426| 		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
|3504|3504| };
|3505|3505| 
|3506|3506| 
|3507|    |-//// FSM linkage functions ////
|    |3507|+// // FSM linkage functions ////
|3508|3508| 
|3509|3509| // Setting the next state to the current state will leave/re-enter the top-most substate.
|3510|3510| 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
|3674|3674| 				continue;
|3675|3675| 			if (this.orderQueue[i].type == type)
|3676|3676| 				continue;
|3677|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3677|+			this.orderQueue.splice(i, 0, { "type": type, "data": data});
|3678|3678| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3679|3679| 			return;
|3680|3680| 		}
|    | [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
|3674|3674| 				continue;
|3675|3675| 			if (this.orderQueue[i].type == type)
|3676|3676| 				continue;
|3677|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3677|+			this.orderQueue.splice(i, 0, {"type": type, "data": data });
|3678|3678| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3679|3679| 			return;
|3680|3680| 		}
|    | [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
|3845|3845| 	if (data.timerRepeat === undefined)
|3846|3846| 		this.timer = undefined;
|3847|3847| 
|3848|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |3848|+	this.UnitFsm.ProcessMessage(this, { "type": "Timer", "data": data, "lateness": lateness});
|3849|3849| };
|3850|3850| 
|3851|3851| /**
|    | [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
|3845|3845| 	if (data.timerRepeat === undefined)
|3846|3846| 		this.timer = undefined;
|3847|3847| 
|3848|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |3848|+	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness });
|3849|3849| };
|3850|3850| 
|3851|3851| /**
|    | [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
|3890|3890| 	// TODO: This is a bit inefficient since every unit listens to every
|3891|3891| 	// construction message - ideally we could scope it to only the one we're building
|3892|3892| 
|3893|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |3893|+	this.UnitFsm.ProcessMessage(this, { "type": "ConstructionFinished", "data": msg});
|3894|3894| };
|3895|3895| 
|3896|3896| 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
|3890|3890| 	// TODO: This is a bit inefficient since every unit listens to every
|3891|3891| 	// construction message - ideally we could scope it to only the one we're building
|3892|3892| 
|3893|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |3893|+	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg });
|3894|3894| };
|3895|3895| 
|3896|3896| 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
|3915|3915| 
|3916|3916| UnitAI.prototype.OnAttacked = function(msg)
|3917|3917| {
|3918|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |3918|+	this.UnitFsm.ProcessMessage(this, { "type": "Attacked", "data": msg});
|3919|3919| };
|3920|3920| 
|3921|3921| 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
|3915|3915| 
|3916|3916| UnitAI.prototype.OnAttacked = function(msg)
|3917|3917| {
|3918|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |3918|+	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg });
|3919|3919| };
|3920|3920| 
|3921|3921| 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
|3920|3920| 
|3921|3921| UnitAI.prototype.OnGuardedAttacked = function(msg)
|3922|3922| {
|3923|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |3923|+	this.UnitFsm.ProcessMessage(this, { "type": "GuardedAttacked", "data": msg.data});
|3924|3924| };
|3925|3925| 
|3926|3926| 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
|3920|3920| 
|3921|3921| UnitAI.prototype.OnGuardedAttacked = function(msg)
|3922|3922| {
|3923|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |3923|+	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data });
|3924|3924| };
|3925|3925| 
|3926|3926| 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
|3925|3925| 
|3926|3926| UnitAI.prototype.OnHealthChanged = function(msg)
|3927|3927| {
|3928|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |3928|+	this.UnitFsm.ProcessMessage(this, { "type": "HealthChanged", "from": msg.from, "to": msg.to});
|3929|3929| };
|3930|3930| 
|3931|3931| 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
|3925|3925| 
|3926|3926| UnitAI.prototype.OnHealthChanged = function(msg)
|3927|3927| {
|3928|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |3928|+	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to });
|3929|3929| };
|3930|3930| 
|3931|3931| 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
|3931|3931| UnitAI.prototype.OnRangeUpdate = function(msg)
|3932|3932| {
|3933|3933| 	if (msg.tag == this.losRangeQuery)
|3934|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|    |3934|+		this.UnitFsm.ProcessMessage(this, { "type": "LosRangeUpdate", "data": msg});
|3935|3935| 	else if (msg.tag == this.losHealRangeQuery)
|3936|3936| 		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|3937|3937| };
|    | [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
|3931|3931| UnitAI.prototype.OnRangeUpdate = function(msg)
|3932|3932| {
|3933|3933| 	if (msg.tag == this.losRangeQuery)
|3934|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|    |3934|+		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg });
|3935|3935| 	else if (msg.tag == this.losHealRangeQuery)
|3936|3936| 		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|3937|3937| };
|    | [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
|3933|3933| 	if (msg.tag == this.losRangeQuery)
|3934|3934| 		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|3935|3935| 	else if (msg.tag == this.losHealRangeQuery)
|3936|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|    |3936|+		this.UnitFsm.ProcessMessage(this, { "type": "LosHealRangeUpdate", "data": msg});
|3937|3937| };
|3938|3938| 
|3939|3939| UnitAI.prototype.OnPackFinished = 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
|3933|3933| 	if (msg.tag == this.losRangeQuery)
|3934|3934| 		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|3935|3935| 	else if (msg.tag == this.losHealRangeQuery)
|3936|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|    |3936|+		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg });
|3937|3937| };
|3938|3938| 
|3939|3939| UnitAI.prototype.OnPackFinished = 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
|3938|3938| 
|3939|3939| UnitAI.prototype.OnPackFinished = function(msg)
|3940|3940| {
|3941|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |3941|+	this.UnitFsm.ProcessMessage(this, { "type": "PackFinished", "packed": msg.packed});
|3942|3942| };
|3943|3943| 
|3944|3944| //// 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
|3938|3938| 
|3939|3939| UnitAI.prototype.OnPackFinished = function(msg)
|3940|3940| {
|3941|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |3941|+	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed });
|3942|3942| };
|3943|3943| 
|3944|3944| //// 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
|3941|3941| 	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|3942|3942| };
|3943|3943| 
|3944|    |-//// Helper functions to be called by the FSM ////
|    |3944|+// // Helper functions to be called by the FSM ////
|3945|3945| 
|3946|3946| UnitAI.prototype.GetWalkSpeed = function()
|3947|3947| {
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 1 tab but found 4 spaces.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4346|4346| 		return false;
|4347|4347| 	var range = cmpGarrisonHolder.GetLoadingRange();
|4348|4348| 
|4349|    |-    // If a pickup has been requested earlier, cancel it
|    |4349|+	// If a pickup has been requested earlier, cancel it
|4350|4350| 	if (this.pickup)
|4351|4351| 	{
|4352|4352| 		Engine.PostMessage(this.pickup, MT_PickupCanceled, { "entity": this.entity });
|    | [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
|4623|4623| UnitAI.prototype.AttackEntityInZone = function(ents)
|4624|4624| {
|4625|4625| 	var target = ents.find(target =>
|4626|    |-		this.CanAttack(target)
|4627|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|    |4626|+		this.CanAttack(target) &&
|    |4627|+		this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4628|4628| 		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4629|4629| 	);
|4630|4630| 	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
|4624|4624| {
|4625|4625| 	var target = ents.find(target =>
|4626|4626| 		this.CanAttack(target)
|4627|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4628|    |-		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|    |4627|+		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true)) &&
|    |4628|+		(this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4629|4629| 	);
|4630|4630| 	if (!target)
|4631|4631| 		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
|4688|4688| 	// If we are guarding/escorting, don't abandon as long as the guarded unit is in target range of the attacker
|4689|4689| 	if (this.isGuardOf)
|4690|4690| 	{
|4691|    |-		var cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |4691|+		var cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|4692|4692| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4693|4693| 		if (cmpUnitAI && cmpAttack &&
|4694|4694| 		    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
|4692|4692| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4693|4693| 		if (cmpUnitAI && cmpAttack &&
|4694|4694| 		    cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type)))
|4695|    |-				return false;
|    |4695|+			return false;
|4696|4696| 	}
|4697|4697| 
|4698|4698| 	// 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
|4730|4730| 	// If we are guarding/escorting, chase at least as long as the guarded unit is in target range of the attacker
|4731|4731| 	if (this.isGuardOf)
|4732|4732| 	{
|4733|    |-		let cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |4733|+		let cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|4734|4734| 		let cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4735|4735| 		if (cmpUnitAI && cmpAttack &&
|4736|4736| 		    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
|4743|4743| 	return false;
|4744|4744| };
|4745|4745| 
|4746|    |-//// External interface functions ////
|    |4746|+// // External interface functions ////
|4747|4747| 
|4748|4748| UnitAI.prototype.SetFormationController = function(ent)
|4749|4749| {
|    | [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
|4899|4899| 	{
|4900|4900| 		if (this.isGuardOf == target && this.order && this.order.type == "Guard")
|4901|4901| 			return;
|4902|    |-		else
|4903|    |-			this.RemoveGuard();
|    |4902|+		this.RemoveGuard();
|4904|4903| 	}
|4905|4904| 
|4906|4905| 	this.AddOrder("Guard", { "target": target, "force": false }, queued);
|    | [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
|5231|5231| 	    this.workOrders.length && this.workOrders[0].type == "Trade")
|5232|5232| 	{
|5233|5233| 		let cmpTrader = Engine.QueryInterface(this.entity, IID_Trader);
|5234|    |-		if (cmpTrader.HasBothMarkets() && 
|    |5234|+		if (cmpTrader.HasBothMarkets() &&
|5235|5235| 		   (cmpTrader.GetFirstMarket() == target && cmpTrader.GetSecondMarket() == source ||
|5236|5236| 		    cmpTrader.GetFirstMarket() == source && cmpTrader.GetSecondMarket() == target))
|5237|5237| 		{
|    | [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
|5512|5512| 				{
|5513|5513| 					var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5514|5514| 					var targetClasses = this.order.data.targetClasses;
|5515|    |-					if (targetClasses.attack && cmpIdentity
|5516|    |-						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5515|+					if (targetClasses.attack && cmpIdentity &&
|    |5516|+						!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5517|5517| 						continue;
|5518|5518| 					if (targetClasses.avoid && cmpIdentity
|5519|5519| 						&& 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
|5515|5515| 					if (targetClasses.attack && cmpIdentity
|5516|5516| 						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5517|5517| 						continue;
|5518|    |-					if (targetClasses.avoid && cmpIdentity
|5519|    |-						&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5518|+					if (targetClasses.avoid && cmpIdentity &&
|    |5519|+						MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5520|5520| 						continue;
|5521|5521| 					// Only used by the AIs to prevent some choices of targets
|5522|5522| 					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
|5538|5538| 		{
|5539|5539| 			var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5540|5540| 			var targetClasses = this.order.data.targetClasses;
|5541|    |-			if (cmpIdentity && targetClasses.attack
|5542|    |-				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5541|+			if (cmpIdentity && targetClasses.attack &&
|    |5542|+				!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5543|5543| 				continue;
|5544|5544| 			if (cmpIdentity && targetClasses.avoid
|5545|5545| 				&& 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
|5541|5541| 			if (cmpIdentity && targetClasses.attack
|5542|5542| 				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5543|5543| 				continue;
|5544|    |-			if (cmpIdentity && targetClasses.avoid
|5545|    |-				&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5544|+			if (cmpIdentity && targetClasses.avoid &&
|    |5545|+				MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5546|5546| 				continue;
|5547|5547| 			// Only used by the AIs to prevent some choices of targets
|5548|5548| 			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
|5698|5698| 
|5699|5699| UnitAI.prototype.SetHeldPosition = function(x, z)
|5700|5700| {
|5701|    |-	this.heldPosition = {"x": x, "z": z};
|    |5701|+	this.heldPosition = { "x": x, "z": z};
|5702|5702| };
|5703|5703| 
|5704|5704| 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
|5698|5698| 
|5699|5699| UnitAI.prototype.SetHeldPosition = function(x, z)
|5700|5700| {
|5701|    |-	this.heldPosition = {"x": x, "z": z};
|    |5701|+	this.heldPosition = {"x": x, "z": z };
|5702|5702| };
|5703|5703| 
|5704|5704| 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
|5725|5725| 	return false;
|5726|5726| };
|5727|5727| 
|5728|    |-//// Helper functions ////
|    |5728|+// // Helper functions ////
|5729|5729| 
|5730|5730| UnitAI.prototype.CanAttack = function(target)
|5731|5731| {
|    | [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
|5929|5929| 	return cmpPack && cmpPack.IsPacking();
|5930|5930| };
|5931|5931| 
|5932|    |-//// Formation specific functions ////
|    |5932|+// // Formation specific functions ////
|5933|5933| 
|5934|5934| UnitAI.prototype.IsAttackingAsFormation = function()
|5935|5935| {
|    | [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
|5934|5934| UnitAI.prototype.IsAttackingAsFormation = function()
|5935|5935| {
|5936|5936| 	var cmpAttack = Engine.QueryInterface(this.entity, IID_Attack);
|5937|    |-	return cmpAttack && cmpAttack.CanAttackAsFormation()
|5938|    |-		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|    |5937|+	return cmpAttack && cmpAttack.CanAttackAsFormation() &&
|    |5938|+		this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|5939|5939| };
|5940|5940| 
|5941|5941| //// 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
|5938|5938| 		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|5939|5939| };
|5940|5940| 
|5941|    |-//// Animal specific functions ////
|    |5941|+// // Animal specific functions ////
|5942|5942| 
|5943|5943| UnitAI.prototype.MoveRandomly = function(distance)
|5944|5944| {

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

binaries/data/mods/public/simulation/components/UnitAI.js
| 918| »   »   »   "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
| 943| »   »   »   "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
| 993| »   »   »   »   »   return·true;
|    | [NORMAL] ESLintBear (consistent-return):
|    | Method 'enter' expected no return value.

binaries/data/mods/public/simulation/components/UnitAI.js
|1046| »   »   »   »   "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
|1076| »   »   »   "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
|1108| »   »   »   »   "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
|1268| »   »   "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
|1325| »   »   »   "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
|1500| »   »   »   "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
|1522| »   »   »   "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
|1554| »   »   »   "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
|1708| »   »   »   "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
|1758| »   »   »   »   "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
|1836| »   »   »   »   "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
|2013| »   »   »   »   "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
|2129| »   »   »   »   "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
|2404| »   »   »   »   "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
|2437| »   »   »   »   "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
|2543| »   »   »   »   "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
|2609| »   »   »   »   "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
|2648| »   »   »   »   "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
|2849| »   »   »   »   "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
|3026| »   »   »   »   "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
|3750| »   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
|4610| »   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
|4625| »   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
|4671| »   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
|4694| »   »   ····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
| 348| »   »   »   ||·this.lastPickupTime·&&·this.lastPickupTime·+·100·>·cmpTimer.GetTime())
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '||'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|1968| »   »   »   »   »   »   &&·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
|3712| »   »   var·order·=·{·"type":·type,·"data":·data·};
|    | [NORMAL] JSHintBear:
|    | 'order' is already defined.

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

binaries/data/mods/public/simulation/components/UnitAI.js
|4627| »   »   &&·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
|4628| »   »   &&·(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
|5516| »   »   »   »   »   »   &&·!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
|5519| »   »   »   »   »   »   &&·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
|5532| »   var·targets·=·this.GetTargetsFromUnit();
|    | [NORMAL] JSHintBear:
|    | 'targets' is already defined.

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

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

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

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

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

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

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

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

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

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

binaries/data/mods/public/simulation/components/UnitAI.js
|5938| »   »   &&·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/docker-differential/1178/display/redirect

causative updated this revision to Diff 10452.Dec 1 2019, 12:23 PM

Remove the extra bugfix that was split into D2174.

causative edited the summary of this revision. (Show Details)Dec 1 2019, 12:25 PM

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

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/664/display/redirect

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

Linter detected issues:
Executing section Source...

source/simulation2/components/ICmpPathfinder.h
|  34| template<typename·T>·class·Grid;
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Code 'template<...' is invalid C code. Use --std or --language to configure the language.

source/simulation2/components/ICmpPathfinder.cpp
|   1| /*·Copyright·(C)·2017·Wildfire·Games.
|    | [NORMAL] LicenseYearBear:
|    | License should have "2019" year instead of "2017"

source/simulation2/components/CCmpPathfinder_Common.h
|  34| #include·"graphics/Overlay.h"
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Code 'template<...' is invalid C code. Use --std or --language to configure the language.

source/simulation2/helpers/HierarchicalPathfinder.h
|  34| ·*·is·defined·as·a·region.
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Code 'template<...' is invalid C code. Use --std or --language to configure the language.
Executing section JS...
|    | [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
| 344| 344| 		let cmpGarrisonHolder = Engine.QueryInterface(this.entity, IID_GarrisonHolder);
| 345| 345| 		let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer);
| 346| 346| 
| 347|    |-		if (!cmpTimer || !cmpGarrisonHolder || cmpGarrisonHolder.IsFull()
| 348|    |-			|| this.lastPickupTime && this.lastPickupTime + 100 > cmpTimer.GetTime())
|    | 347|+		if (!cmpTimer || !cmpGarrisonHolder || cmpGarrisonHolder.IsFull() ||
|    | 348|+			this.lastPickupTime && this.lastPickupTime + 100 > cmpTimer.GetTime())
| 349| 349| 		{
| 350| 350| 			this.FinishOrder();
| 351| 351| 			return;
|    | [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
| 763| 763| 					this.FinishOrder();
| 764| 764| 					return;
| 765| 765| 				}
| 766|    |-				else
| 767|    |-				{
|    | 766|+				
| 768| 767| 					this.SetNextState("GARRISON.APPROACHING");
| 769| 768| 					return;
| 770|    |-				}
|    | 769|+				
| 771| 770| 			}
| 772| 771| 
| 773| 772| 			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
|1031|1031| 			},
|1032|1032| 		},
|1033|1033| 
|1034|    |-		"GARRISON":{
|    |1034|+		"GARRISON": {
|1035|1035| 			"enter": function() {
|1036|1036| 				// If the garrisonholder should pickup, warn it so it can take needed action
|1037|1037| 				var cmpGarrisonHolder = Engine.QueryInterface(this.order.data.target, IID_GarrisonHolder);
|    | [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
|1980|1980| 
|1981|1981| 				"Attacked": function(msg) {
|1982|1982| 					// If we are capturing and are attacked by something that we would not capture, attack that entity instead
|1983|    |-					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force)
|1984|    |-						&& this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|    |1983|+					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force) &&
|    |1984|+						this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|1985|1985| 						this.RespondToTargetedEntities([msg.data.attacker]);
|1986|1986| 				},
|1987|1987| 			},
|    | [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
|2708|2708| 					{
|2709|2709| 						// The building was already finished/fully repaired before we arrived;
|2710|2710| 						// let the ConstructionFinished handler handle this.
|2711|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2711|+						this.OnGlobalConstructionFinished({ "entity": this.repairTarget, "newentity": this.repairTarget});
|2712|2712| 						return true;
|2713|2713| 					}
|2714|2714| 
|    | [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
|2708|2708| 					{
|2709|2709| 						// The building was already finished/fully repaired before we arrived;
|2710|2710| 						// let the ConstructionFinished handler handle this.
|2711|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2711|+						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget });
|2712|2712| 						return true;
|2713|2713| 					}
|2714|2714| 
|    | [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
|3217|3217| 		"COMBAT": "INDIVIDUAL.COMBAT", // reuse the same combat behaviour for animals
|3218|3218| 
|3219|3219| 		"WALKING": "INDIVIDUAL.WALKING",	// reuse the same walking behaviour for animals
|3220|    |-							// only used for domestic animals
|    |3220|+		// only used for domestic animals
|3221|3221| 	},
|3222|3222| };
|3223|3223| 
|    | [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
|3274|3274| 
|3275|3275| UnitAI.prototype.IsAnimal = function()
|3276|3276| {
|3277|    |-	return (this.template.NaturalBehaviour ? true : false);
|    |3277|+	return (!!this.template.NaturalBehaviour);
|3278|3278| };
|3279|3279| 
|3280|3280| 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
|3390|3390| 		{
|3391|3391| 			let index = this.GetCurrentState().indexOf(".");
|3392|3392| 			if (index != -1)
|3393|    |-				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0,index));
|    |3393|+				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0, index));
|3394|3394| 			this.Stop(false);
|3395|3395| 		}
|3396|3396| 
|    | [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
|3446|3446| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3447|3447| 			continue;
|3448|3448| 		if (i == 0)
|3449|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3449|+			this.UnitFsm.ProcessMessage(this, { "type": "PickupCanceled", "data": msg});
|3450|3450| 		else
|3451|3451| 			this.orderQueue.splice(i, 1);
|3452|3452| 		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
|3446|3446| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3447|3447| 			continue;
|3448|3448| 		if (i == 0)
|3449|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3449|+			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg });
|3450|3450| 		else
|3451|3451| 			this.orderQueue.splice(i, 1);
|3452|3452| 		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
|3530|3530| };
|3531|3531| 
|3532|3532| 
|3533|    |-//// FSM linkage functions ////
|    |3533|+// // FSM linkage functions ////
|3534|3534| 
|3535|3535| // Setting the next state to the current state will leave/re-enter the top-most substate.
|3536|3536| 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
|3700|3700| 				continue;
|3701|3701| 			if (this.orderQueue[i].type == type)
|3702|3702| 				continue;
|3703|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3703|+			this.orderQueue.splice(i, 0, { "type": type, "data": data});
|3704|3704| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3705|3705| 			return;
|3706|3706| 		}
|    | [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
|3700|3700| 				continue;
|3701|3701| 			if (this.orderQueue[i].type == type)
|3702|3702| 				continue;
|3703|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3703|+			this.orderQueue.splice(i, 0, {"type": type, "data": data });
|3704|3704| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3705|3705| 			return;
|3706|3706| 		}
|    | [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
|3871|3871| 	if (data.timerRepeat === undefined)
|3872|3872| 		this.timer = undefined;
|3873|3873| 
|3874|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |3874|+	this.UnitFsm.ProcessMessage(this, { "type": "Timer", "data": data, "lateness": lateness});
|3875|3875| };
|3876|3876| 
|3877|3877| /**
|    | [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
|3871|3871| 	if (data.timerRepeat === undefined)
|3872|3872| 		this.timer = undefined;
|3873|3873| 
|3874|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |3874|+	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness });
|3875|3875| };
|3876|3876| 
|3877|3877| /**
|    | [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
|3916|3916| 	// TODO: This is a bit inefficient since every unit listens to every
|3917|3917| 	// construction message - ideally we could scope it to only the one we're building
|3918|3918| 
|3919|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |3919|+	this.UnitFsm.ProcessMessage(this, { "type": "ConstructionFinished", "data": msg});
|3920|3920| };
|3921|3921| 
|3922|3922| 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
|3916|3916| 	// TODO: This is a bit inefficient since every unit listens to every
|3917|3917| 	// construction message - ideally we could scope it to only the one we're building
|3918|3918| 
|3919|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |3919|+	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg });
|3920|3920| };
|3921|3921| 
|3922|3922| 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
|3941|3941| 
|3942|3942| UnitAI.prototype.OnAttacked = function(msg)
|3943|3943| {
|3944|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |3944|+	this.UnitFsm.ProcessMessage(this, { "type": "Attacked", "data": msg});
|3945|3945| };
|3946|3946| 
|3947|3947| 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
|3941|3941| 
|3942|3942| UnitAI.prototype.OnAttacked = function(msg)
|3943|3943| {
|3944|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |3944|+	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg });
|3945|3945| };
|3946|3946| 
|3947|3947| 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
|3946|3946| 
|3947|3947| UnitAI.prototype.OnGuardedAttacked = function(msg)
|3948|3948| {
|3949|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |3949|+	this.UnitFsm.ProcessMessage(this, { "type": "GuardedAttacked", "data": msg.data});
|3950|3950| };
|3951|3951| 
|3952|3952| 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
|3946|3946| 
|3947|3947| UnitAI.prototype.OnGuardedAttacked = function(msg)
|3948|3948| {
|3949|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |3949|+	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data });
|3950|3950| };
|3951|3951| 
|3952|3952| 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
|3951|3951| 
|3952|3952| UnitAI.prototype.OnHealthChanged = function(msg)
|3953|3953| {
|3954|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |3954|+	this.UnitFsm.ProcessMessage(this, { "type": "HealthChanged", "from": msg.from, "to": msg.to});
|3955|3955| };
|3956|3956| 
|3957|3957| 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
|3951|3951| 
|3952|3952| UnitAI.prototype.OnHealthChanged = function(msg)
|3953|3953| {
|3954|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |3954|+	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to });
|3955|3955| };
|3956|3956| 
|3957|3957| 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
|3957|3957| UnitAI.prototype.OnRangeUpdate = function(msg)
|3958|3958| {
|3959|3959| 	if (msg.tag == this.losRangeQuery)
|3960|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|    |3960|+		this.UnitFsm.ProcessMessage(this, { "type": "LosRangeUpdate", "data": msg});
|3961|3961| 	else if (msg.tag == this.losHealRangeQuery)
|3962|3962| 		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|3963|3963| };
|    | [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
|3957|3957| UnitAI.prototype.OnRangeUpdate = function(msg)
|3958|3958| {
|3959|3959| 	if (msg.tag == this.losRangeQuery)
|3960|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|    |3960|+		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg });
|3961|3961| 	else if (msg.tag == this.losHealRangeQuery)
|3962|3962| 		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|3963|3963| };
|    | [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
|3959|3959| 	if (msg.tag == this.losRangeQuery)
|3960|3960| 		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|3961|3961| 	else if (msg.tag == this.losHealRangeQuery)
|3962|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|    |3962|+		this.UnitFsm.ProcessMessage(this, { "type": "LosHealRangeUpdate", "data": msg});
|3963|3963| };
|3964|3964| 
|3965|3965| UnitAI.prototype.OnPackFinished = 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
|3959|3959| 	if (msg.tag == this.losRangeQuery)
|3960|3960| 		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|3961|3961| 	else if (msg.tag == this.losHealRangeQuery)
|3962|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|    |3962|+		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg });
|3963|3963| };
|3964|3964| 
|3965|3965| UnitAI.prototype.OnPackFinished = 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
|3964|3964| 
|3965|3965| UnitAI.prototype.OnPackFinished = function(msg)
|3966|3966| {
|3967|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |3967|+	this.UnitFsm.ProcessMessage(this, { "type": "PackFinished", "packed": msg.packed});
|3968|3968| };
|3969|3969| 
|3970|3970| //// 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
|3964|3964| 
|3965|3965| UnitAI.prototype.OnPackFinished = function(msg)
|3966|3966| {
|3967|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |3967|+	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed });
|3968|3968| };
|3969|3969| 
|3970|3970| //// 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
|3967|3967| 	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|3968|3968| };
|3969|3969| 
|3970|    |-//// Helper functions to be called by the FSM ////
|    |3970|+// // Helper functions to be called by the FSM ////
|3971|3971| 
|3972|3972| UnitAI.prototype.GetWalkSpeed = function()
|3973|3973| {
|    | [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
|4636|4636| UnitAI.prototype.AttackEntityInZone = function(ents)
|4637|4637| {
|4638|4638| 	var target = ents.find(target =>
|4639|    |-		this.CanAttack(target)
|4640|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|    |4639|+		this.CanAttack(target) &&
|    |4640|+		this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4641|4641| 		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4642|4642| 	);
|4643|4643| 	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
|4637|4637| {
|4638|4638| 	var target = ents.find(target =>
|4639|4639| 		this.CanAttack(target)
|4640|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4641|    |-		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|    |4640|+		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true)) &&
|    |4641|+		(this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4642|4642| 	);
|4643|4643| 	if (!target)
|4644|4644| 		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
|4701|4701| 	// If we are guarding/escorting, don't abandon as long as the guarded unit is in target range of the attacker
|4702|4702| 	if (this.isGuardOf)
|4703|4703| 	{
|4704|    |-		var cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |4704|+		var cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|4705|4705| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4706|4706| 		if (cmpUnitAI && cmpAttack &&
|4707|4707| 		    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
|4705|4705| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4706|4706| 		if (cmpUnitAI && cmpAttack &&
|4707|4707| 		    cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type)))
|4708|    |-				return false;
|    |4708|+			return false;
|4709|4709| 	}
|4710|4710| 
|4711|4711| 	// 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
|4743|4743| 	// If we are guarding/escorting, chase at least as long as the guarded unit is in target range of the attacker
|4744|4744| 	if (this.isGuardOf)
|4745|4745| 	{
|4746|    |-		let cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |4746|+		let cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|4747|4747| 		let cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4748|4748| 		if (cmpUnitAI && cmpAttack &&
|4749|4749| 		    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
|4756|4756| 	return false;
|4757|4757| };
|4758|4758| 
|4759|    |-//// External interface functions ////
|    |4759|+// // External interface functions ////
|4760|4760| 
|4761|4761| UnitAI.prototype.SetFormationController = function(ent)
|4762|4762| {
|    | [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
|4912|4912| 	{
|4913|4913| 		if (this.isGuardOf == target && this.order && this.order.type == "Guard")
|4914|4914| 			return;
|4915|    |-		else
|4916|    |-			this.RemoveGuard();
|    |4915|+		this.RemoveGuard();
|4917|4916| 	}
|4918|4917| 
|4919|4918| 	this.AddOrder("Guard", { "target": target, "force": false }, queued);
|    | [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
|5244|5244| 	    this.workOrders.length && this.workOrders[0].type == "Trade")
|5245|5245| 	{
|5246|5246| 		let cmpTrader = Engine.QueryInterface(this.entity, IID_Trader);
|5247|    |-		if (cmpTrader.HasBothMarkets() && 
|    |5247|+		if (cmpTrader.HasBothMarkets() &&
|5248|5248| 		   (cmpTrader.GetFirstMarket() == target && cmpTrader.GetSecondMarket() == source ||
|5249|5249| 		    cmpTrader.GetFirstMarket() == source && cmpTrader.GetSecondMarket() == target))
|5250|5250| 		{
|    | [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
|5525|5525| 				{
|5526|5526| 					var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5527|5527| 					var targetClasses = this.order.data.targetClasses;
|5528|    |-					if (targetClasses.attack && cmpIdentity
|5529|    |-						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5528|+					if (targetClasses.attack && cmpIdentity &&
|    |5529|+						!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5530|5530| 						continue;
|5531|5531| 					if (targetClasses.avoid && cmpIdentity
|5532|5532| 						&& 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
|5528|5528| 					if (targetClasses.attack && cmpIdentity
|5529|5529| 						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5530|5530| 						continue;
|5531|    |-					if (targetClasses.avoid && cmpIdentity
|5532|    |-						&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5531|+					if (targetClasses.avoid && cmpIdentity &&
|    |5532|+						MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5533|5533| 						continue;
|5534|5534| 					// Only used by the AIs to prevent some choices of targets
|5535|5535| 					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
|5551|5551| 		{
|5552|5552| 			var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5553|5553| 			var targetClasses = this.order.data.targetClasses;
|5554|    |-			if (cmpIdentity && targetClasses.attack
|5555|    |-				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5554|+			if (cmpIdentity && targetClasses.attack &&
|    |5555|+				!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5556|5556| 				continue;
|5557|5557| 			if (cmpIdentity && targetClasses.avoid
|5558|5558| 				&& 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
|5554|5554| 			if (cmpIdentity && targetClasses.attack
|5555|5555| 				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5556|5556| 				continue;
|5557|    |-			if (cmpIdentity && targetClasses.avoid
|5558|    |-				&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5557|+			if (cmpIdentity && targetClasses.avoid &&
|    |5558|+				MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5559|5559| 				continue;
|5560|5560| 			// Only used by the AIs to prevent some choices of targets
|5561|5561| 			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
|5711|5711| 
|5712|5712| UnitAI.prototype.SetHeldPosition = function(x, z)
|5713|5713| {
|5714|    |-	this.heldPosition = {"x": x, "z": z};
|    |5714|+	this.heldPosition = { "x": x, "z": z};
|5715|5715| };
|5716|5716| 
|5717|5717| 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
|5711|5711| 
|5712|5712| UnitAI.prototype.SetHeldPosition = function(x, z)
|5713|5713| {
|5714|    |-	this.heldPosition = {"x": x, "z": z};
|    |5714|+	this.heldPosition = {"x": x, "z": z };
|5715|5715| };
|5716|5716| 
|5717|5717| 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
|5738|5738| 	return false;
|5739|5739| };
|5740|5740| 
|5741|    |-//// Helper functions ////
|    |5741|+// // Helper functions ////
|5742|5742| 
|5743|5743| UnitAI.prototype.CanAttack = function(target)
|5744|5744| {
|    | [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
|5942|5942| 	return cmpPack && cmpPack.IsPacking();
|5943|5943| };
|5944|5944| 
|5945|    |-//// Formation specific functions ////
|    |5945|+// // Formation specific functions ////
|5946|5946| 
|5947|5947| UnitAI.prototype.IsAttackingAsFormation = function()
|5948|5948| {
|    | [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
|5947|5947| UnitAI.prototype.IsAttackingAsFormation = function()
|5948|5948| {
|5949|5949| 	var cmpAttack = Engine.QueryInterface(this.entity, IID_Attack);
|5950|    |-	return cmpAttack && cmpAttack.CanAttackAsFormation()
|5951|    |-		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|    |5950|+	return cmpAttack && cmpAttack.CanAttackAsFormation() &&
|    |5951|+		this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|5952|5952| };
|5953|5953| 
|5954|5954| //// 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
|5951|5951| 		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|5952|5952| };
|5953|5953| 
|5954|    |-//// Animal specific functions ////
|    |5954|+// // Animal specific functions ////
|5955|5955| 
|5956|5956| UnitAI.prototype.MoveRandomly = function(distance)
|5957|5957| {

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

binaries/data/mods/public/simulation/components/UnitAI.js
| 918| »   »   »   "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
| 943| »   »   »   "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
| 993| »   »   »   »   »   return·true;
|    | [NORMAL] ESLintBear (consistent-return):
|    | Method 'enter' expected no return value.

binaries/data/mods/public/simulation/components/UnitAI.js
|1056| »   »   »   »   "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
|1092| »   »   »   "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
|1124| »   »   »   »   "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
|1284| »   »   "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
|1341| »   »   »   "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
|1516| »   »   »   "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
|1538| »   »   »   "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
|1570| »   »   »   "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
|1724| »   »   »   "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
|1774| »   »   »   »   "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
|1852| »   »   »   »   "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
|2029| »   »   »   »   "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
|2145| »   »   »   »   "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
|2420| »   »   »   »   "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
|2453| »   »   »   »   "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
|2559| »   »   »   »   "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
|2625| »   »   »   »   "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
|2664| »   »   »   »   "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
|2875| »   »   »   »   "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
|3052| »   »   »   »   "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
|3776| »   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
|4623| »   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
|4638| »   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
|4684| »   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
|4707| »   »   ····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
| 348| »   »   »   ||·this.lastPickupTime·&&·this.lastPickupTime·+·100·>·cmpTimer.GetTime())
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '||'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|1984| »   »   »   »   »   »   &&·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
|3738| »   »   var·order·=·{·"type":·type,·"data":·data·};
|    | [NORMAL] JSHintBear:
|    | 'order' is already defined.

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

binaries/data/mods/public/simulation/components/UnitAI.js
|4640| »   »   &&·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
|4641| »   »   &&·(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
|5529| »   »   »   »   »   »   &&·!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
|5532| »   »   »   »   »   »   &&·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
|5545| »   var·targets·=·this.GetTargetsFromUnit();
|    | [NORMAL] JSHintBear:
|    | 'targets' is already defined.

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

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

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

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

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

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

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

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

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

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

binaries/data/mods/public/simulation/components/UnitAI.js
|5951| »   »   &&·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/docker-differential/1180/display/redirect

Angen added a subscriber: Angen.Dec 1 2019, 4:35 PM

Some comments:

  • I think you can use global regions to skip the ReachableRegions logic entirely, which should be faster.
  • It seems you're only checking the borders of the square? I'm assuming it's for optimisation purposes, and because that likely is sufficient in the usual case?
  • I don't see any assumption that the unit is a ship, contrary to what the comment suggest. Your function is basically checking if there is a Navcell of possibility B in range x of unit A.
source/simulation2/helpers/HierarchicalPathfinder.h
120

Is there a reason why you moved this above?

causative updated this revision to Diff 11908.May 17 2020, 6:29 PM

Use GetGlobalRegion

Some comments:

  • I think you can use global regions to skip the ReachableRegions logic entirely, which should be faster.

You're right. I have changed the patch to do that. When I first wrote the patch, GetGlobalRegion didn't exist.

  • It seems you're only checking the borders of the square? I'm assuming it's for optimisation purposes, and because that likely is sufficient in the usual case?

Yes.

  • I don't see any assumption that the unit is a ship, contrary to what the comment suggest. Your function is basically checking if there is a Navcell of possibility B in range x of unit A.

Talking about a ship and the shore makes it clearer why this code is there, and makes for a more descriptive function name that is self-documenting when called from JS.

source/simulation2/helpers/HierarchicalPathfinder.h
120

Making it public. However, I don't need to use it if I use GetGlobalRegion.

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

Linter detected issues:
Executing section Source...

source/simulation2/components/ICmpPathfinder.cpp
|   1| /*·Copyright·(C)·2017·Wildfire·Games.
|    | [NORMAL] LicenseYearBear:
|    | License should have "2020" year instead of "2017"

source/simulation2/components/CCmpPathfinder_Common.h
|  34| #include·"graphics/Overlay.h"
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Code 'template<...' is invalid C code. Use --std or --language to configure the language.

source/simulation2/components/ICmpPathfinder.h
|   1| /*·Copyright·(C)·2019·Wildfire·Games.
|    | [NORMAL] LicenseYearBear:
|    | License should have "2020" year instead of "2019"

source/simulation2/components/ICmpPathfinder.h
|  34| template<typename·T>·class·Grid;
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Code 'template<...' is invalid C code. Use --std or --language to configure the language.
Executing section JS...
|    | [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
| 351| 351| 		let cmpGarrisonHolder = Engine.QueryInterface(this.entity, IID_GarrisonHolder);
| 352| 352| 		let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer);
| 353| 353| 
| 354|    |-		if (!cmpTimer || !cmpGarrisonHolder || cmpGarrisonHolder.IsFull()
| 355|    |-			|| this.lastPickupTime && this.lastPickupTime + 100 > cmpTimer.GetTime())
|    | 354|+		if (!cmpTimer || !cmpGarrisonHolder || cmpGarrisonHolder.IsFull() ||
|    | 355|+			this.lastPickupTime && this.lastPickupTime + 100 > cmpTimer.GetTime())
| 356| 356| 		{
| 357| 357| 			this.FinishOrder();
| 358| 358| 			return;
|    | [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
| 789| 789| 					this.FinishOrder();
| 790| 790| 					return;
| 791| 791| 				}
| 792|    |-				else
| 793|    |-				{
|    | 792|+				
| 794| 793| 					this.SetNextState("GARRISON.APPROACHING");
| 795| 794| 					return;
| 796|    |-				}
|    | 795|+				
| 797| 796| 			}
| 798| 797| 
| 799| 798| 			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
|1061|1061| 			},
|1062|1062| 		},
|1063|1063| 
|1064|    |-		"GARRISON":{
|    |1064|+		"GARRISON": {
|1065|1065| 			"APPROACHING": {
|1066|1066| 				"enter": function() {
|1067|1067| 					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
|2043|2043| 
|2044|2044| 				"Attacked": function(msg) {
|2045|2045| 					// If we are capturing and are attacked by something that we would not capture, attack that entity instead
|2046|    |-					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force)
|2047|    |-						&& this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|    |2046|+					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force) &&
|    |2047|+						this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|2048|2048| 						this.RespondToTargetedEntities([msg.data.attacker]);
|2049|2049| 				},
|2050|2050| 			},
|    | [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
|2202|2202| 					"MovementUpdate": function(msg) {
|2203|2203| 						// If it looks like the path is failing, and we are close enough (3 tiles) from wanted range
|2204|2204| 						// stop anyways. This avoids pathing for an unreachable goal and reduces lag considerably.
|2205|    |-						if (msg.likelyFailure || 
|    |2205|+						if (msg.likelyFailure ||
|2206|2206| 							msg.obstructed && this.RelaxedMaxRangeCheck(this.order.data, this.order.data.max + this.DefaultRelaxedMaxRange) ||
|2207|2207| 							!msg.obstructed && this.CheckRange(this.order.data))
|2208|2208| 							this.FinishOrder();
|    | [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
|2844|2844| 					{
|2845|2845| 						// The building was already finished/fully repaired before we arrived;
|2846|2846| 						// let the ConstructionFinished handler handle this.
|2847|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2847|+						this.OnGlobalConstructionFinished({ "entity": this.repairTarget, "newentity": this.repairTarget});
|2848|2848| 						return true;
|2849|2849| 					}
|2850|2850| 
|    | [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
|2844|2844| 					{
|2845|2845| 						// The building was already finished/fully repaired before we arrived;
|2846|2846| 						// let the ConstructionFinished handler handle this.
|2847|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2847|+						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget });
|2848|2848| 						return true;
|2849|2849| 					}
|2850|2850| 
|    | [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
|3138|3138| 				this.StopTimer();
|3139|3139| 				this.ResetAnimation();
|3140|3140| 				if (this.formationAnimationVariant)
|3141|    |-					this.SetAnimationVariant(this.formationAnimationVariant)
|    |3141|+					this.SetAnimationVariant(this.formationAnimationVariant);
|3142|3142| 				else
|3143|3143| 					this.SetDefaultAnimationVariant();
|3144|3144| 				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
|3364|3364| 		"COMBAT": "INDIVIDUAL.COMBAT", // reuse the same combat behaviour for animals
|3365|3365| 
|3366|3366| 		"WALKING": "INDIVIDUAL.WALKING",	// reuse the same walking behaviour for animals
|3367|    |-							// only used for domestic animals
|    |3367|+		// only used for domestic animals
|3368|3368| 
|3369|3369| 		// Reuse the same garrison behaviour for animals.
|3370|3370| 		"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
|3426|3426| 
|3427|3427| UnitAI.prototype.IsAnimal = function()
|3428|3428| {
|3429|    |-	return (this.template.NaturalBehaviour ? true : false);
|    |3429|+	return (!!this.template.NaturalBehaviour);
|3430|3430| };
|3431|3431| 
|3432|3432| 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
|3542|3542| 		{
|3543|3543| 			let index = this.GetCurrentState().indexOf(".");
|3544|3544| 			if (index != -1)
|3545|    |-				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0,index));
|    |3545|+				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0, index));
|3546|3546| 			this.Stop(false);
|3547|3547| 		}
|3548|3548| 
|    | [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
|3598|3598| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3599|3599| 			continue;
|3600|3600| 		if (i == 0)
|3601|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3601|+			this.UnitFsm.ProcessMessage(this, { "type": "PickupCanceled", "data": msg});
|3602|3602| 		else
|3603|3603| 			this.orderQueue.splice(i, 1);
|3604|3604| 		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
|3598|3598| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3599|3599| 			continue;
|3600|3600| 		if (i == 0)
|3601|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3601|+			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg });
|3602|3602| 		else
|3603|3603| 			this.orderQueue.splice(i, 1);
|3604|3604| 		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
|3685|3685| };
|3686|3686| 
|3687|3687| 
|3688|    |-//// FSM linkage functions ////
|    |3688|+// // FSM linkage functions ////
|3689|3689| 
|3690|3690| // Setting the next state to the current state will leave/re-enter the top-most substate.
|3691|3691| 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
|3856|3856| 				continue;
|3857|3857| 			if (this.orderQueue[i].type == type)
|3858|3858| 				continue;
|3859|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3859|+			this.orderQueue.splice(i, 0, { "type": type, "data": data});
|3860|3860| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3861|3861| 			return;
|3862|3862| 		}
|    | [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
|3856|3856| 				continue;
|3857|3857| 			if (this.orderQueue[i].type == type)
|3858|3858| 				continue;
|3859|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3859|+			this.orderQueue.splice(i, 0, {"type": type, "data": data });
|3860|3860| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3861|3861| 			return;
|3862|3862| 		}
|    | [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
|4098|4098| 	if (data.timerRepeat === undefined)
|4099|4099| 		this.timer = undefined;
|4100|4100| 
|4101|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |4101|+	this.UnitFsm.ProcessMessage(this, { "type": "Timer", "data": data, "lateness": lateness});
|4102|4102| };
|4103|4103| 
|4104|4104| /**
|    | [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
|4098|4098| 	if (data.timerRepeat === undefined)
|4099|4099| 		this.timer = undefined;
|4100|4100| 
|4101|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |4101|+	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness });
|4102|4102| };
|4103|4103| 
|4104|4104| /**
|    | [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
|4143|4143| 	// TODO: This is a bit inefficient since every unit listens to every
|4144|4144| 	// construction message - ideally we could scope it to only the one we're building
|4145|4145| 
|4146|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |4146|+	this.UnitFsm.ProcessMessage(this, { "type": "ConstructionFinished", "data": msg});
|4147|4147| };
|4148|4148| 
|4149|4149| 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
|4143|4143| 	// TODO: This is a bit inefficient since every unit listens to every
|4144|4144| 	// construction message - ideally we could scope it to only the one we're building
|4145|4145| 
|4146|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |4146|+	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg });
|4147|4147| };
|4148|4148| 
|4149|4149| 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
|4174|4174| 	if (msg.fromStatusEffect)
|4175|4175| 		return;
|4176|4176| 
|4177|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |4177|+	this.UnitFsm.ProcessMessage(this, { "type": "Attacked", "data": msg});
|4178|4178| };
|4179|4179| 
|4180|4180| 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
|4174|4174| 	if (msg.fromStatusEffect)
|4175|4175| 		return;
|4176|4176| 
|4177|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |4177|+	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg });
|4178|4178| };
|4179|4179| 
|4180|4180| 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
|4179|4179| 
|4180|4180| UnitAI.prototype.OnGuardedAttacked = function(msg)
|4181|4181| {
|4182|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |4182|+	this.UnitFsm.ProcessMessage(this, { "type": "GuardedAttacked", "data": msg.data});
|4183|4183| };
|4184|4184| 
|4185|4185| 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
|4179|4179| 
|4180|4180| UnitAI.prototype.OnGuardedAttacked = function(msg)
|4181|4181| {
|4182|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |4182|+	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data });
|4183|4183| };
|4184|4184| 
|4185|4185| 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
|4184|4184| 
|4185|4185| UnitAI.prototype.OnHealthChanged = function(msg)
|4186|4186| {
|4187|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |4187|+	this.UnitFsm.ProcessMessage(this, { "type": "HealthChanged", "from": msg.from, "to": msg.to});
|4188|4188| };
|4189|4189| 
|4190|4190| 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
|4184|4184| 
|4185|4185| UnitAI.prototype.OnHealthChanged = function(msg)
|4186|4186| {
|4187|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |4187|+	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to });
|4188|4188| };
|4189|4189| 
|4190|4190| 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
|4190|4190| UnitAI.prototype.OnRangeUpdate = function(msg)
|4191|4191| {
|4192|4192| 	if (msg.tag == this.losRangeQuery)
|4193|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|    |4193|+		this.UnitFsm.ProcessMessage(this, { "type": "LosRangeUpdate", "data": msg});
|4194|4194| 	else if (msg.tag == this.losHealRangeQuery)
|4195|4195| 		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|4196|4196| };
|    | [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
|4190|4190| UnitAI.prototype.OnRangeUpdate = function(msg)
|4191|4191| {
|4192|4192| 	if (msg.tag == this.losRangeQuery)
|4193|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|    |4193|+		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg });
|4194|4194| 	else if (msg.tag == this.losHealRangeQuery)
|4195|4195| 		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|4196|4196| };
|    | [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
|4192|4192| 	if (msg.tag == this.losRangeQuery)
|4193|4193| 		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|4194|4194| 	else if (msg.tag == this.losHealRangeQuery)
|4195|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|    |4195|+		this.UnitFsm.ProcessMessage(this, { "type": "LosHealRangeUpdate", "data": msg});
|4196|4196| };
|4197|4197| 
|4198|4198| UnitAI.prototype.OnPackFinished = 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
|4192|4192| 	if (msg.tag == this.losRangeQuery)
|4193|4193| 		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|4194|4194| 	else if (msg.tag == this.losHealRangeQuery)
|4195|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|    |4195|+		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg });
|4196|4196| };
|4197|4197| 
|4198|4198| UnitAI.prototype.OnPackFinished = 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
|4197|4197| 
|4198|4198| UnitAI.prototype.OnPackFinished = function(msg)
|4199|4199| {
|4200|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |4200|+	this.UnitFsm.ProcessMessage(this, { "type": "PackFinished", "packed": msg.packed});
|4201|4201| };
|4202|4202| 
|4203|4203| //// 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
|4197|4197| 
|4198|4198| UnitAI.prototype.OnPackFinished = function(msg)
|4199|4199| {
|4200|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |4200|+	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed });
|4201|4201| };
|4202|4202| 
|4203|4203| //// 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
|4200|4200| 	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|4201|4201| };
|4202|4202| 
|4203|    |-//// Helper functions to be called by the FSM ////
|    |4203|+// // Helper functions to be called by the FSM ////
|4204|4204| 
|4205|4205| UnitAI.prototype.GetWalkSpeed = function()
|4206|4206| {
|    | [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
|4912|4912| UnitAI.prototype.AttackEntityInZone = function(ents)
|4913|4913| {
|4914|4914| 	var target = ents.find(target =>
|4915|    |-		this.CanAttack(target)
|4916|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|    |4915|+		this.CanAttack(target) &&
|    |4916|+		this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4917|4917| 		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4918|4918| 	);
|4919|4919| 	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
|4913|4913| {
|4914|4914| 	var target = ents.find(target =>
|4915|4915| 		this.CanAttack(target)
|4916|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4917|    |-		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|    |4916|+		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true)) &&
|    |4917|+		(this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4918|4918| 	);
|4919|4919| 	if (!target)
|4920|4920| 		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
|4979|4979| 	// If we are guarding/escorting, don't abandon as long as the guarded unit is in target range of the attacker
|4980|4980| 	if (this.isGuardOf)
|4981|4981| 	{
|4982|    |-		var cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |4982|+		var cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|4983|4983| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4984|4984| 		if (cmpUnitAI && cmpAttack &&
|4985|4985| 		    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
|4983|4983| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4984|4984| 		if (cmpUnitAI && cmpAttack &&
|4985|4985| 		    cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type)))
|4986|    |-				return false;
|    |4986|+			return false;
|4987|4987| 	}
|4988|4988| 
|4989|4989| 	// 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
|5021|5021| 	// If we are guarding/escorting, chase at least as long as the guarded unit is in target range of the attacker
|5022|5022| 	if (this.isGuardOf)
|5023|5023| 	{
|5024|    |-		let cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |5024|+		let cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|5025|5025| 		let cmpAttack = Engine.QueryInterface(target, IID_Attack);
|5026|5026| 		if (cmpUnitAI && cmpAttack &&
|5027|5027| 		    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
|5034|5034| 	return false;
|5035|5035| };
|5036|5036| 
|5037|    |-//// External interface functions ////
|    |5037|+// // External interface functions ////
|5038|5038| 
|5039|5039| UnitAI.prototype.SetFormationController = function(ent)
|5040|5040| {
|    | [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
|5190|5190| 	{
|5191|5191| 		if (this.isGuardOf == target && this.order && this.order.type == "Guard")
|5192|5192| 			return;
|5193|    |-		else
|5194|    |-			this.RemoveGuard();
|    |5193|+		this.RemoveGuard();
|5195|5194| 	}
|5196|5195| 
|5197|5196| 	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
|5521|5521| 
|5522|5522| 	if (this.IsFormationController())
|5523|5523| 		this.CallMemberFunction("CancelSetupTradeRoute", [target]);
|5524|    |-}
|    |5524|+};
|5525|5525| /**
|5526|5526|  * Adds trade order to the queue. Either walk to the first market, or
|5527|5527|  * 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
|5542|5542| 	    this.workOrders.length && this.workOrders[0].type == "Trade")
|5543|5543| 	{
|5544|5544| 		let cmpTrader = Engine.QueryInterface(this.entity, IID_Trader);
|5545|    |-		if (cmpTrader.HasBothMarkets() && 
|    |5545|+		if (cmpTrader.HasBothMarkets() &&
|5546|5546| 		   (cmpTrader.GetFirstMarket() == target && cmpTrader.GetSecondMarket() == source ||
|5547|5547| 		    cmpTrader.GetFirstMarket() == source && cmpTrader.GetSecondMarket() == target))
|5548|5548| 		{
|    | [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
|5823|5823| 				{
|5824|5824| 					var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5825|5825| 					var targetClasses = this.order.data.targetClasses;
|5826|    |-					if (targetClasses.attack && cmpIdentity
|5827|    |-						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5826|+					if (targetClasses.attack && cmpIdentity &&
|    |5827|+						!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5828|5828| 						continue;
|5829|5829| 					if (targetClasses.avoid && cmpIdentity
|5830|5830| 						&& 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
|5826|5826| 					if (targetClasses.attack && cmpIdentity
|5827|5827| 						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5828|5828| 						continue;
|5829|    |-					if (targetClasses.avoid && cmpIdentity
|5830|    |-						&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5829|+					if (targetClasses.avoid && cmpIdentity &&
|    |5830|+						MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5831|5831| 						continue;
|5832|5832| 					// Only used by the AIs to prevent some choices of targets
|5833|5833| 					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
|5849|5849| 		{
|5850|5850| 			var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5851|5851| 			var targetClasses = this.order.data.targetClasses;
|5852|    |-			if (cmpIdentity && targetClasses.attack
|5853|    |-				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5852|+			if (cmpIdentity && targetClasses.attack &&
|    |5853|+				!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5854|5854| 				continue;
|5855|5855| 			if (cmpIdentity && targetClasses.avoid
|5856|5856| 				&& 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
|5852|5852| 			if (cmpIdentity && targetClasses.attack
|5853|5853| 				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5854|5854| 				continue;
|5855|    |-			if (cmpIdentity && targetClasses.avoid
|5856|    |-				&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5855|+			if (cmpIdentity && targetClasses.avoid &&
|    |5856|+				MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5857|5857| 				continue;
|5858|5858| 			// Only used by the AIs to prevent some choices of targets
|5859|5859| 			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
|5995|5995| 
|5996|5996| UnitAI.prototype.SetHeldPosition = function(x, z)
|5997|5997| {
|5998|    |-	this.heldPosition = {"x": x, "z": z};
|    |5998|+	this.heldPosition = { "x": x, "z": z};
|5999|5999| };
|6000|6000| 
|6001|6001| 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
|5995|5995| 
|5996|5996| UnitAI.prototype.SetHeldPosition = function(x, z)
|5997|5997| {
|5998|    |-	this.heldPosition = {"x": x, "z": z};
|    |5998|+	this.heldPosition = {"x": x, "z": z };
|5999|5999| };
|6000|6000| 
|6001|6001| 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
|6022|6022| 	return false;
|6023|6023| };
|6024|6024| 
|6025|    |-//// Helper functions ////
|    |6025|+// // Helper functions ////
|6026|6026| 
|6027|6027| /**
|6028|6028|  * 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
|6041|6041| 		return undefined;
|6042|6042| 
|6043|6043| 	return component.GetRange(type);
|6044|    |-}
|    |6044|+};
|6045|6045| 
|6046|6046| UnitAI.prototype.CanAttack = function(target)
|6047|6047| {
|    | [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
|6209|6209| 	return cmpPack && cmpPack.IsPacking();
|6210|6210| };
|6211|6211| 
|6212|    |-//// Formation specific functions ////
|    |6212|+// // Formation specific functions ////
|6213|6213| 
|6214|6214| UnitAI.prototype.IsAttackingAsFormation = function()
|6215|6215| {
|    | [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
|6214|6214| UnitAI.prototype.IsAttackingAsFormation = function()
|6215|6215| {
|6216|6216| 	var cmpAttack = Engine.QueryInterface(this.entity, IID_Attack);
|6217|    |-	return cmpAttack && cmpAttack.CanAttackAsFormation()
|6218|    |-		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|    |6217|+	return cmpAttack && cmpAttack.CanAttackAsFormation() &&
|    |6218|+		this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|6219|6219| };
|6220|6220| 
|6221|6221| //// 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
|6218|6218| 		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|6219|6219| };
|6220|6220| 
|6221|    |-//// Animal specific functions ////
|    |6221|+// // Animal specific functions ////
|6222|6222| 
|6223|6223| UnitAI.prototype.MoveRandomly = function(distance)
|6224|6224| {

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

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

binaries/data/mods/public/simulation/components/UnitAI.js
|4003| »   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
|4899| »   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
|4914| »   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
|4962| »   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
|4985| »   »   ····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
| 355| »   »   »   ||·this.lastPickupTime·&&·this.lastPickupTime·+·100·>·cmpTimer.GetTime())
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '||'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|2047| »   »   »   »   »   »   &&·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
|3141| »   »   »   »   »   this.SetAnimationVariant(this.formationAnimationVariant)
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

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

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

binaries/data/mods/public/simulation/components/UnitAI.js
|4916| »   »   &&·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
|4917| »   »   &&·(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
|5524| }
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

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

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

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

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

binaries/data/mods/public/simulation/components/UnitAI.js
|5853| »   »   »   »   &&·!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
|5856| »   »   »   »   &&·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
|6044| }
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

binaries/data/mods/public/simulation/components/UnitAI.js
|6218| »   »   &&·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/docker-differential/2149/display/redirect

Stan added inline comments.May 17 2020, 7:12 PM
binaries/data/mods/public/simulation/components/UnitAI.js
354

I believe we don't check for system components (here cmptimer) as we want to know immediately if something goes wrong with them

causative added inline comments.May 18 2020, 5:24 AM
binaries/data/mods/public/simulation/components/UnitAI.js
354

OK. I will hold off on that until I get more comments so that I don't have to make and test too many tiny changes.

Overall I like this and it should indeed improve the behaviour. Think you can improve unitAI a tad more.


You're right. I have changed the patch to do that. When I first wrote the patch, GetGlobalRegion didn't exist.

Indeed, thanks for updating.

  • It seems you're only checking the borders of the square? I'm assuming it's for optimisation purposes, and because that likely is sufficient in the usual case?

Yes.

Alright. Seems fair to me given the purpose of the patch.

  • I don't see any assumption that the unit is a ship, contrary to what the comment suggest. Your function is basically checking if there is a Navcell of possibility B in range x of unit A.

Talking about a ship and the shore makes it clearer why this code is there, and makes for a more descriptive function name that is self-documenting when called from JS.

Hm. I suppose it's fair enough given the approximation-for-speed discussed above. I would perhaps clarify in the comment that this isn't actually requiring a ship and a land unit though. One could also use it for a "Roc"-like unit or something.

binaries/data/mods/public/simulation/components/UnitAI.js
355

This seems only useful in case we didn't have to move, in which case we FinishOrder... But that's broken anyways, because we still want to pickup that first unit, and the second unit might be far away, so we'll start moving, and we're stuck.

Simply remove the 2 FinishOrder below, and always go in INDIVIDUAL.PICKUP.LOADING, and this timing issue goes away.

source/simulation2/components/CCmpPathfinder.cpp
243

I'd rather use cmpObstruction::GetSize for that. It would let players construct tunnels (which wouldn't have Motion) or something like that.

255

I think you should also check right under the "ship" entity, to make this function more general (again, thinking of the "Roc" use-case from AoM)

causative updated this revision to Diff 11987.May 22 2020, 11:17 PM
causative marked an inline comment as done.

rename CheckNearShore to CheckPickupAccessible, and also test the square directly under the ship.

I renamed to CheckPickupAccessible because it's actually used for siege pickups as well as ship pickups.

binaries/data/mods/public/simulation/components/UnitAI.js
355

The purpose of this is so that when you load 100 units into the ship with one command, it doesn't do an expensive CheckNearShore() call for each unit.

source/simulation2/components/CCmpPathfinder.cpp
243

It sounds like a stationary tunnel would work more like building garrison, so it wouldn't need to call this function.

causative marked an inline comment as done.May 22 2020, 11:21 PM
causative added inline comments.
binaries/data/mods/public/simulation/components/UnitAI.js
354

OK

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

Linter detected issues:
Executing section Source...

source/simulation2/components/ICmpPathfinder.h
|   1| /*·Copyright·(C)·2019·Wildfire·Games.
|    | [NORMAL] LicenseYearBear:
|    | License should have "2020" year instead of "2019"

source/simulation2/components/ICmpPathfinder.h
|  34| template<typename·T>·class·Grid;
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Code 'template<...' is invalid C code. Use --std or --language to configure the language.

source/simulation2/components/CCmpPathfinder_Common.h
|  34| #include·"graphics/Overlay.h"
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Code 'template<...' is invalid C code. Use --std or --language to configure the language.

source/simulation2/components/ICmpPathfinder.cpp
|   1| /*·Copyright·(C)·2017·Wildfire·Games.
|    | [NORMAL] LicenseYearBear:
|    | License should have "2020" year instead of "2017"
Executing section JS...
|    | [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
| 351| 351| 		let cmpGarrisonHolder = Engine.QueryInterface(this.entity, IID_GarrisonHolder);
| 352| 352| 		let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer);
| 353| 353| 
| 354|    |-		if (!cmpGarrisonHolder || cmpGarrisonHolder.IsFull()
| 355|    |-			|| this.lastPickupTime && this.lastPickupTime + 100 > cmpTimer.GetTime())
|    | 354|+		if (!cmpGarrisonHolder || cmpGarrisonHolder.IsFull() ||
|    | 355|+			this.lastPickupTime && this.lastPickupTime + 100 > cmpTimer.GetTime())
| 356| 356| 		{
| 357| 357| 			this.FinishOrder();
| 358| 358| 			return;
|    | [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
| 789| 789| 					this.FinishOrder();
| 790| 790| 					return;
| 791| 791| 				}
| 792|    |-				else
| 793|    |-				{
|    | 792|+				
| 794| 793| 					this.SetNextState("GARRISON.APPROACHING");
| 795| 794| 					return;
| 796|    |-				}
|    | 795|+				
| 797| 796| 			}
| 798| 797| 
| 799| 798| 			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
|1061|1061| 			},
|1062|1062| 		},
|1063|1063| 
|1064|    |-		"GARRISON":{
|    |1064|+		"GARRISON": {
|1065|1065| 			"APPROACHING": {
|1066|1066| 				"enter": function() {
|1067|1067| 					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
|2035|2035| 
|2036|2036| 				"Attacked": function(msg) {
|2037|2037| 					// If we are capturing and are attacked by something that we would not capture, attack that entity instead
|2038|    |-					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force)
|2039|    |-						&& this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|    |2038|+					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force) &&
|    |2039|+						this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|2040|2040| 						this.RespondToTargetedEntities([msg.data.attacker]);
|2041|2041| 				},
|2042|2042| 			},
|    | [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
|2194|2194| 					"MovementUpdate": function(msg) {
|2195|2195| 						// If it looks like the path is failing, and we are close enough (3 tiles) from wanted range
|2196|2196| 						// stop anyways. This avoids pathing for an unreachable goal and reduces lag considerably.
|2197|    |-						if (msg.likelyFailure || 
|    |2197|+						if (msg.likelyFailure ||
|2198|2198| 							msg.obstructed && this.RelaxedMaxRangeCheck(this.order.data, this.order.data.max + this.DefaultRelaxedMaxRange) ||
|2199|2199| 							!msg.obstructed && this.CheckRange(this.order.data))
|2200|2200| 							this.FinishOrder();
|    | [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
|2836|2836| 					{
|2837|2837| 						// The building was already finished/fully repaired before we arrived;
|2838|2838| 						// let the ConstructionFinished handler handle this.
|2839|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2839|+						this.OnGlobalConstructionFinished({ "entity": this.repairTarget, "newentity": this.repairTarget});
|2840|2840| 						return true;
|2841|2841| 					}
|2842|2842| 
|    | [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
|2836|2836| 					{
|2837|2837| 						// The building was already finished/fully repaired before we arrived;
|2838|2838| 						// let the ConstructionFinished handler handle this.
|2839|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2839|+						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget });
|2840|2840| 						return true;
|2841|2841| 					}
|2842|2842| 
|    | [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
|3130|3130| 				this.StopTimer();
|3131|3131| 				this.ResetAnimation();
|3132|3132| 				if (this.formationAnimationVariant)
|3133|    |-					this.SetAnimationVariant(this.formationAnimationVariant)
|    |3133|+					this.SetAnimationVariant(this.formationAnimationVariant);
|3134|3134| 				else
|3135|3135| 					this.SetDefaultAnimationVariant();
|3136|3136| 				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
|3356|3356| 		"COMBAT": "INDIVIDUAL.COMBAT", // reuse the same combat behaviour for animals
|3357|3357| 
|3358|3358| 		"WALKING": "INDIVIDUAL.WALKING",	// reuse the same walking behaviour for animals
|3359|    |-							// only used for domestic animals
|    |3359|+		// only used for domestic animals
|3360|3360| 
|3361|3361| 		// Reuse the same garrison behaviour for animals.
|3362|3362| 		"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
|3418|3418| 
|3419|3419| UnitAI.prototype.IsAnimal = function()
|3420|3420| {
|3421|    |-	return (this.template.NaturalBehaviour ? true : false);
|    |3421|+	return (!!this.template.NaturalBehaviour);
|3422|3422| };
|3423|3423| 
|3424|3424| 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
|3534|3534| 		{
|3535|3535| 			let index = this.GetCurrentState().indexOf(".");
|3536|3536| 			if (index != -1)
|3537|    |-				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0,index));
|    |3537|+				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0, index));
|3538|3538| 			this.Stop(false);
|3539|3539| 		}
|3540|3540| 
|    | [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
|3590|3590| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3591|3591| 			continue;
|3592|3592| 		if (i == 0)
|3593|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3593|+			this.UnitFsm.ProcessMessage(this, { "type": "PickupCanceled", "data": msg});
|3594|3594| 		else
|3595|3595| 			this.orderQueue.splice(i, 1);
|3596|3596| 		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
|3590|3590| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3591|3591| 			continue;
|3592|3592| 		if (i == 0)
|3593|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3593|+			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg });
|3594|3594| 		else
|3595|3595| 			this.orderQueue.splice(i, 1);
|3596|3596| 		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
|3677|3677| };
|3678|3678| 
|3679|3679| 
|3680|    |-//// FSM linkage functions ////
|    |3680|+// // FSM linkage functions ////
|3681|3681| 
|3682|3682| // Setting the next state to the current state will leave/re-enter the top-most substate.
|3683|3683| 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
|3848|3848| 				continue;
|3849|3849| 			if (this.orderQueue[i].type == type)
|3850|3850| 				continue;
|3851|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3851|+			this.orderQueue.splice(i, 0, { "type": type, "data": data});
|3852|3852| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3853|3853| 			return;
|3854|3854| 		}
|    | [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
|3848|3848| 				continue;
|3849|3849| 			if (this.orderQueue[i].type == type)
|3850|3850| 				continue;
|3851|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3851|+			this.orderQueue.splice(i, 0, {"type": type, "data": data });
|3852|3852| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3853|3853| 			return;
|3854|3854| 		}
|    | [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
|4090|4090| 	if (data.timerRepeat === undefined)
|4091|4091| 		this.timer = undefined;
|4092|4092| 
|4093|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |4093|+	this.UnitFsm.ProcessMessage(this, { "type": "Timer", "data": data, "lateness": lateness});
|4094|4094| };
|4095|4095| 
|4096|4096| /**
|    | [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
|4090|4090| 	if (data.timerRepeat === undefined)
|4091|4091| 		this.timer = undefined;
|4092|4092| 
|4093|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |4093|+	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness });
|4094|4094| };
|4095|4095| 
|4096|4096| /**
|    | [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
|4135|4135| 	// TODO: This is a bit inefficient since every unit listens to every
|4136|4136| 	// construction message - ideally we could scope it to only the one we're building
|4137|4137| 
|4138|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |4138|+	this.UnitFsm.ProcessMessage(this, { "type": "ConstructionFinished", "data": msg});
|4139|4139| };
|4140|4140| 
|4141|4141| 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
|4135|4135| 	// TODO: This is a bit inefficient since every unit listens to every
|4136|4136| 	// construction message - ideally we could scope it to only the one we're building
|4137|4137| 
|4138|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |4138|+	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg });
|4139|4139| };
|4140|4140| 
|4141|4141| 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
|4166|4166| 	if (msg.fromStatusEffect)
|4167|4167| 		return;
|4168|4168| 
|4169|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |4169|+	this.UnitFsm.ProcessMessage(this, { "type": "Attacked", "data": msg});
|4170|4170| };
|4171|4171| 
|4172|4172| 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
|4166|4166| 	if (msg.fromStatusEffect)
|4167|4167| 		return;
|4168|4168| 
|4169|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |4169|+	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg });
|4170|4170| };
|4171|4171| 
|4172|4172| 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
|4171|4171| 
|4172|4172| UnitAI.prototype.OnGuardedAttacked = function(msg)
|4173|4173| {
|4174|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |4174|+	this.UnitFsm.ProcessMessage(this, { "type": "GuardedAttacked", "data": msg.data});
|4175|4175| };
|4176|4176| 
|4177|4177| 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
|4171|4171| 
|4172|4172| UnitAI.prototype.OnGuardedAttacked = function(msg)
|4173|4173| {
|4174|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |4174|+	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data });
|4175|4175| };
|4176|4176| 
|4177|4177| 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
|4176|4176| 
|4177|4177| UnitAI.prototype.OnHealthChanged = function(msg)
|4178|4178| {
|4179|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |4179|+	this.UnitFsm.ProcessMessage(this, { "type": "HealthChanged", "from": msg.from, "to": msg.to});
|4180|4180| };
|4181|4181| 
|4182|4182| 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
|4176|4176| 
|4177|4177| UnitAI.prototype.OnHealthChanged = function(msg)
|4178|4178| {
|4179|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |4179|+	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to });
|4180|4180| };
|4181|4181| 
|4182|4182| 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
|4182|4182| UnitAI.prototype.OnRangeUpdate = function(msg)
|4183|4183| {
|4184|4184| 	if (msg.tag == this.losRangeQuery)
|4185|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|    |4185|+		this.UnitFsm.ProcessMessage(this, { "type": "LosRangeUpdate", "data": msg});
|4186|4186| 	else if (msg.tag == this.losHealRangeQuery)
|4187|4187| 		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|4188|4188| };
|    | [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
|4182|4182| UnitAI.prototype.OnRangeUpdate = function(msg)
|4183|4183| {
|4184|4184| 	if (msg.tag == this.losRangeQuery)
|4185|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|    |4185|+		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg });
|4186|4186| 	else if (msg.tag == this.losHealRangeQuery)
|4187|4187| 		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|4188|4188| };
|    | [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
|4184|4184| 	if (msg.tag == this.losRangeQuery)
|4185|4185| 		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|4186|4186| 	else if (msg.tag == this.losHealRangeQuery)
|4187|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|    |4187|+		this.UnitFsm.ProcessMessage(this, { "type": "LosHealRangeUpdate", "data": msg});
|4188|4188| };
|4189|4189| 
|4190|4190| UnitAI.prototype.OnPackFinished = 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
|4184|4184| 	if (msg.tag == this.losRangeQuery)
|4185|4185| 		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|4186|4186| 	else if (msg.tag == this.losHealRangeQuery)
|4187|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|    |4187|+		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg });
|4188|4188| };
|4189|4189| 
|4190|4190| UnitAI.prototype.OnPackFinished = 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
|4189|4189| 
|4190|4190| UnitAI.prototype.OnPackFinished = function(msg)
|4191|4191| {
|4192|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |4192|+	this.UnitFsm.ProcessMessage(this, { "type": "PackFinished", "packed": msg.packed});
|4193|4193| };
|4194|4194| 
|4195|4195| //// 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
|4189|4189| 
|4190|4190| UnitAI.prototype.OnPackFinished = function(msg)
|4191|4191| {
|4192|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |4192|+	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed });
|4193|4193| };
|4194|4194| 
|4195|4195| //// 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
|4192|4192| 	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|4193|4193| };
|4194|4194| 
|4195|    |-//// Helper functions to be called by the FSM ////
|    |4195|+// // Helper functions to be called by the FSM ////
|4196|4196| 
|4197|4197| UnitAI.prototype.GetWalkSpeed = function()
|4198|4198| {
|    | [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
|4904|4904| UnitAI.prototype.AttackEntityInZone = function(ents)
|4905|4905| {
|4906|4906| 	var target = ents.find(target =>
|4907|    |-		this.CanAttack(target)
|4908|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|    |4907|+		this.CanAttack(target) &&
|    |4908|+		this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4909|4909| 		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4910|4910| 	);
|4911|4911| 	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
|4905|4905| {
|4906|4906| 	var target = ents.find(target =>
|4907|4907| 		this.CanAttack(target)
|4908|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4909|    |-		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|    |4908|+		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true)) &&
|    |4909|+		(this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4910|4910| 	);
|4911|4911| 	if (!target)
|4912|4912| 		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
|4971|4971| 	// If we are guarding/escorting, don't abandon as long as the guarded unit is in target range of the attacker
|4972|4972| 	if (this.isGuardOf)
|4973|4973| 	{
|4974|    |-		var cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |4974|+		var cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|4975|4975| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4976|4976| 		if (cmpUnitAI && cmpAttack &&
|4977|4977| 		    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
|4975|4975| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4976|4976| 		if (cmpUnitAI && cmpAttack &&
|4977|4977| 		    cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type)))
|4978|    |-				return false;
|    |4978|+			return false;
|4979|4979| 	}
|4980|4980| 
|4981|4981| 	// 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
|5013|5013| 	// If we are guarding/escorting, chase at least as long as the guarded unit is in target range of the attacker
|5014|5014| 	if (this.isGuardOf)
|5015|5015| 	{
|5016|    |-		let cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |5016|+		let cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|5017|5017| 		let cmpAttack = Engine.QueryInterface(target, IID_Attack);
|5018|5018| 		if (cmpUnitAI && cmpAttack &&
|5019|5019| 		    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
|5026|5026| 	return false;
|5027|5027| };
|5028|5028| 
|5029|    |-//// External interface functions ////
|    |5029|+// // External interface functions ////
|5030|5030| 
|5031|5031| UnitAI.prototype.SetFormationController = function(ent)
|5032|5032| {
|    | [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
|5182|5182| 	{
|5183|5183| 		if (this.isGuardOf == target && this.order && this.order.type == "Guard")
|5184|5184| 			return;
|5185|    |-		else
|5186|    |-			this.RemoveGuard();
|    |5185|+		this.RemoveGuard();
|5187|5186| 	}
|5188|5187| 
|5189|5188| 	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
|5513|5513| 
|5514|5514| 	if (this.IsFormationController())
|5515|5515| 		this.CallMemberFunction("CancelSetupTradeRoute", [target]);
|5516|    |-}
|    |5516|+};
|5517|5517| /**
|5518|5518|  * Adds trade order to the queue. Either walk to the first market, or
|5519|5519|  * 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
|5534|5534| 	    this.workOrders.length && this.workOrders[0].type == "Trade")
|5535|5535| 	{
|5536|5536| 		let cmpTrader = Engine.QueryInterface(this.entity, IID_Trader);
|5537|    |-		if (cmpTrader.HasBothMarkets() && 
|    |5537|+		if (cmpTrader.HasBothMarkets() &&
|5538|5538| 		   (cmpTrader.GetFirstMarket() == target && cmpTrader.GetSecondMarket() == source ||
|5539|5539| 		    cmpTrader.GetFirstMarket() == source && cmpTrader.GetSecondMarket() == target))
|5540|5540| 		{
|    | [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
|5815|5815| 				{
|5816|5816| 					var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5817|5817| 					var targetClasses = this.order.data.targetClasses;
|5818|    |-					if (targetClasses.attack && cmpIdentity
|5819|    |-						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5818|+					if (targetClasses.attack && cmpIdentity &&
|    |5819|+						!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5820|5820| 						continue;
|5821|5821| 					if (targetClasses.avoid && cmpIdentity
|5822|5822| 						&& 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
|5818|5818| 					if (targetClasses.attack && cmpIdentity
|5819|5819| 						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5820|5820| 						continue;
|5821|    |-					if (targetClasses.avoid && cmpIdentity
|5822|    |-						&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5821|+					if (targetClasses.avoid && cmpIdentity &&
|    |5822|+						MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5823|5823| 						continue;
|5824|5824| 					// Only used by the AIs to prevent some choices of targets
|5825|5825| 					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
|5841|5841| 		{
|5842|5842| 			var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5843|5843| 			var targetClasses = this.order.data.targetClasses;
|5844|    |-			if (cmpIdentity && targetClasses.attack
|5845|    |-				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5844|+			if (cmpIdentity && targetClasses.attack &&
|    |5845|+				!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5846|5846| 				continue;
|5847|5847| 			if (cmpIdentity && targetClasses.avoid
|5848|5848| 				&& 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
|5844|5844| 			if (cmpIdentity && targetClasses.attack
|5845|5845| 				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5846|5846| 				continue;
|5847|    |-			if (cmpIdentity && targetClasses.avoid
|5848|    |-				&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5847|+			if (cmpIdentity && targetClasses.avoid &&
|    |5848|+				MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5849|5849| 				continue;
|5850|5850| 			// Only used by the AIs to prevent some choices of targets
|5851|5851| 			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
|6004|6004| 
|6005|6005| UnitAI.prototype.SetHeldPosition = function(x, z)
|6006|6006| {
|6007|    |-	this.heldPosition = {"x": x, "z": z};
|    |6007|+	this.heldPosition = { "x": x, "z": z};
|6008|6008| };
|6009|6009| 
|6010|6010| 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
|6004|6004| 
|6005|6005| UnitAI.prototype.SetHeldPosition = function(x, z)
|6006|6006| {
|6007|    |-	this.heldPosition = {"x": x, "z": z};
|    |6007|+	this.heldPosition = {"x": x, "z": z };
|6008|6008| };
|6009|6009| 
|6010|6010| 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
|6031|6031| 	return false;
|6032|6032| };
|6033|6033| 
|6034|    |-//// Helper functions ////
|    |6034|+// // Helper functions ////
|6035|6035| 
|6036|6036| /**
|6037|6037|  * 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
|6050|6050| 		return undefined;
|6051|6051| 
|6052|6052| 	return component.GetRange(type);
|6053|    |-}
|    |6053|+};
|6054|6054| 
|6055|6055| UnitAI.prototype.CanAttack = function(target)
|6056|6056| {
|    | [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
|6218|6218| 	return cmpPack && cmpPack.IsPacking();
|6219|6219| };
|6220|6220| 
|6221|    |-//// Formation specific functions ////
|    |6221|+// // Formation specific functions ////
|6222|6222| 
|6223|6223| UnitAI.prototype.IsAttackingAsFormation = function()
|6224|6224| {
|    | [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
|6223|6223| UnitAI.prototype.IsAttackingAsFormation = function()
|6224|6224| {
|6225|6225| 	var cmpAttack = Engine.QueryInterface(this.entity, IID_Attack);
|6226|    |-	return cmpAttack && cmpAttack.CanAttackAsFormation()
|6227|    |-		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|    |6226|+	return cmpAttack && cmpAttack.CanAttackAsFormation() &&
|    |6227|+		this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|6228|6228| };
|6229|6229| 
|6230|6230| //// 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
|6227|6227| 		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|6228|6228| };
|6229|6229| 
|6230|    |-//// Animal specific functions ////
|    |6230|+// // Animal specific functions ////
|6231|6231| 
|6232|6232| UnitAI.prototype.MoveRandomly = function(distance)
|6233|6233| {

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

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

binaries/data/mods/public/simulation/components/UnitAI.js
|3995| »   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
|4891| »   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
|4906| »   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
|4954| »   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
|4977| »   »   ····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
| 355| »   »   »   ||·this.lastPickupTime·&&·this.lastPickupTime·+·100·>·cmpTimer.GetTime())
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '||'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|2039| »   »   »   »   »   »   &&·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
|3133| »   »   »   »   »   this.SetAnimationVariant(this.formationAnimationVariant)
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

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

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

binaries/data/mods/public/simulation/components/UnitAI.js
|4908| »   »   &&·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
|4909| »   »   &&·(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
|5516| }
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

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

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

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

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

binaries/data/mods/public/simulation/components/UnitAI.js
|5845| »   »   »   »   &&·!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
|5848| »   »   »   »   &&·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
|6053| }
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

binaries/data/mods/public/simulation/components/UnitAI.js
|6227| »   »   &&·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/docker-differential/2209/display/redirect

I have had enough. Years of inaction on this obviously necessary bug fix to an extremely annoying part of the game which was created on Jun 20 2017, this now being May 29 2020. Finally a few comments. So I have hope, I spend my time making some requested changes. Then, nothing again. This community is broken. If anyone wants D665, and wants any more changes made, commandeer the patch yourself. But honestly none of these recent changes were functionally necessary anyway, which is another broken part of the community. Even the first revision of this patch, 3 years ago, without the long pathfinder stuff, was fully working and better than the status quo which is still broken. Just commit the shit and make the game work. Your functionally useless whims and preferences should not become time demands on the patch creator.

wraitii commandeered this revision.May 30 2020, 7:39 AM
wraitii added a reviewer: causative.

I have had enough. Years of inaction on this obviously necessary bug fix to an extremely annoying part of the game which was created on Jun 20 2017, this now being May 29 2020. Finally a few comments. So I have hope, I spend my time making some requested changes. Then, nothing again.

I understand your frustration on this. I really, really do. To make my point, D11, the "campaigns" patch, very much a necessary feature and wanted by basically everyone, exists since Dec 2016...

If anyone wants D665, and wants any more changes made, commandeer the patch yourself.

But, I want to stress, that's a perfectly acceptable position to take -> you don't want to spend more time on this. I get it. You just need to say so.


With that, I am commandeering this, since I do think it's worthwhile with a few more changes.

causative added a comment.EditedMay 30 2020, 6:20 PM

The changes you wanted are wrong and your attitude is wrong. Planning for a hypothetical future "roc" unit? Just let the code do what it was written and tested to do, don't delay it even more because of imaginary features that don't exist yet and may never, and probably shouldn't share the same code even if they did. And you may well cause a performance issue by taking out the timer. Just commit the fucking patch. It works. It has always worked through 3 years of delays and irrelevant changes.

wraitii added a comment.EditedJun 1 2020, 11:45 AM

Trigger-based test map, showing rather poor behaviour all around. The patch fixes the particular issue it was made to fix, but not the fact that ships move around the map too much.
I noticed that ship behaviour is bad because they don't adjust when the unit they want to pick up moves, which is because they are following a "known bad path", so they only update the path when it ends (this is WAD but the design expected units & ships to converge on a common point, which doesn't happen).

The timer check is indeed un-necessary from what I can tell -> either units are in range already and this is picked up by the range check, or the units are not and the entity waits on the first order so there's no 100s of calls. This might have been changed rece
ntly though, as rP23268 was changed from the original patch.

Rams don't actually pick units up so they're irrelevant here.


I do feel like this is a good improvement on the noticed issue, but the fact that pickup can be overwritten by the player is rather annoying, structurally. Garrisoning units actually will notice that the order has been deleted and abandon their garrison order, which seems rather broken.

wraitii updated this revision to Diff 12088.EditedJun 1 2020, 3:05 PM

RC version of my attempt at this.
It's essentially the same idea, but with a few twists:

  • Makes the UnitMotion stil recompute paths now and then when following "known imperfect paths", to avoid units and ships going the opposite way without noticing. Depending on the map configuration this is a large improvement.
  • Send failure messages in case these pile up, I noticed a "slow infinite loop" when testing the trigger map.
  • Use the reachability from UM instead of adding a new function doing something custom. This helps ensuring coherence with obstruction/UM code, while keeping the desired functionality.
  • Make garrisoning units wait a little harder for their ship by asking for pickup again if the ship is idle when the entity arrives at destination. This still isn't perfect, but it should help a little in some "fire and forget" cases (see trigger map).

Overall it's the same fix, so it would likely still be better to compute a path to meet the units halfway, but that's very non-trivial.

Edit -> forgot to remove the remaining lastPosition stuff.

Owners added a subscriber: Restricted Owners Package.Jun 1 2020, 3:05 PM
Vulcan added a comment.Jun 1 2020, 3:27 PM

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

Linter detected issues:
Executing section Source...

source/simulation2/components/ICmpUnitMotion.h
|   1| /*·Copyright·(C)·2019·Wildfire·Games.
|    | [NORMAL] LicenseYearBear:
|    | License should have "2020" year instead of "2019"

source/simulation2/components/ICmpUnitMotion.h
|  34| class·ICmpUnitMotion·:·public·IComponent
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Code 'classICmpUnitMotion:' is invalid C code. Use --std or --language to configure the language.

source/simulation2/helpers/HierarchicalPathfinder.h
|   1| /*·Copyright·(C)·2019·Wildfire·Games.
|    | [NORMAL] LicenseYearBear:
|    | License should have "2020" year instead of "2019"

source/simulation2/helpers/HierarchicalPathfinder.h
|  34| ·*·is·defined·as·a·region.
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Code 'template<...' is invalid C code. Use --std or --language to configure the language.

source/simulation2/components/ICmpUnitMotion.cpp
|   1| /*·Copyright·(C)·2019·Wildfire·Games.
|    | [NORMAL] LicenseYearBear:
|    | License should have "2020" year instead of "2019"

source/simulation2/components/CCmpPathfinder_Common.h
|  34| #include·"graphics/Overlay.h"
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Code 'template<...' is invalid C code. Use --std or --language to configure the language.

source/simulation2/components/ICmpPathfinder.h
|   1| /*·Copyright·(C)·2019·Wildfire·Games.
|    | [NORMAL] LicenseYearBear:
|    | License should have "2020" year instead of "2019"

source/simulation2/components/ICmpPathfinder.h
|  34| template<typename·T>·class·Grid;
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Code 'template<...' is invalid C code. Use --std or --language to configure the language.

source/simulation2/helpers/HierarchicalPathfinder.cpp
|   1| /*·Copyright·(C)·2019·Wildfire·Games.
|    | [NORMAL] LicenseYearBear:
|    | License should have "2020" year instead of "2019"
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
| 786| 786| 					this.FinishOrder();
| 787| 787| 					return;
| 788| 788| 				}
| 789|    |-				else
| 790|    |-				{
|    | 789|+				
| 791| 790| 					this.SetNextState("GARRISON.APPROACHING");
| 792| 791| 					return;
| 793|    |-				}
|    | 792|+				
| 794| 793| 			}
| 795| 794| 
| 796| 795| 			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
|1058|1058| 			},
|1059|1059| 		},
|1060|1060| 
|1061|    |-		"GARRISON":{
|    |1061|+		"GARRISON": {
|1062|1062| 			"APPROACHING": {
|1063|1063| 				"enter": function() {
|1064|1064| 					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
|2032|2032| 
|2033|2033| 				"Attacked": function(msg) {
|2034|2034| 					// If we are capturing and are attacked by something that we would not capture, attack that entity instead
|2035|    |-					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force)
|2036|    |-						&& this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|    |2035|+					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force) &&
|    |2036|+						this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|2037|2037| 						this.RespondToTargetedEntities([msg.data.attacker]);
|2038|2038| 				},
|2039|2039| 			},
|    | [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
|2191|2191| 					"MovementUpdate": function(msg) {
|2192|2192| 						// If it looks like the path is failing, and we are close enough (3 tiles) from wanted range
|2193|2193| 						// stop anyways. This avoids pathing for an unreachable goal and reduces lag considerably.
|2194|    |-						if (msg.likelyFailure || 
|    |2194|+						if (msg.likelyFailure ||
|2195|2195| 							msg.obstructed && this.RelaxedMaxRangeCheck(this.order.data, this.order.data.max + this.DefaultRelaxedMaxRange) ||
|2196|2196| 							!msg.obstructed && this.CheckRange(this.order.data))
|2197|2197| 							this.FinishOrder();
|    | [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
|2833|2833| 					{
|2834|2834| 						// The building was already finished/fully repaired before we arrived;
|2835|2835| 						// let the ConstructionFinished handler handle this.
|2836|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2836|+						this.OnGlobalConstructionFinished({ "entity": this.repairTarget, "newentity": this.repairTarget});
|2837|2837| 						return true;
|2838|2838| 					}
|2839|2839| 
|    | [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
|2833|2833| 					{
|2834|2834| 						// The building was already finished/fully repaired before we arrived;
|2835|2835| 						// let the ConstructionFinished handler handle this.
|2836|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2836|+						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget });
|2837|2837| 						return true;
|2838|2838| 					}
|2839|2839| 
|    | [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
|3132|3132| 				this.StopTimer();
|3133|3133| 				this.ResetAnimation();
|3134|3134| 				if (this.formationAnimationVariant)
|3135|    |-					this.SetAnimationVariant(this.formationAnimationVariant)
|    |3135|+					this.SetAnimationVariant(this.formationAnimationVariant);
|3136|3136| 				else
|3137|3137| 					this.SetDefaultAnimationVariant();
|3138|3138| 				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
|3358|3358| 		"COMBAT": "INDIVIDUAL.COMBAT", // reuse the same combat behaviour for animals
|3359|3359| 
|3360|3360| 		"WALKING": "INDIVIDUAL.WALKING",	// reuse the same walking behaviour for animals
|3361|    |-							// only used for domestic animals
|    |3361|+		// only used for domestic animals
|3362|3362| 
|3363|3363| 		// Reuse the same garrison behaviour for animals.
|3364|3364| 		"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
|3420|3420| 
|3421|3421| UnitAI.prototype.IsAnimal = function()
|3422|3422| {
|3423|    |-	return (this.template.NaturalBehaviour ? true : false);
|    |3423|+	return (!!this.template.NaturalBehaviour);
|3424|3424| };
|3425|3425| 
|3426|3426| 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
|3536|3536| 		{
|3537|3537| 			let index = this.GetCurrentState().indexOf(".");
|3538|3538| 			if (index != -1)
|3539|    |-				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0,index));
|    |3539|+				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0, index));
|3540|3540| 			this.Stop(false);
|3541|3541| 		}
|3542|3542| 
|    | [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
|3592|3592| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3593|3593| 			continue;
|3594|3594| 		if (i == 0)
|3595|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3595|+			this.UnitFsm.ProcessMessage(this, { "type": "PickupCanceled", "data": msg});
|3596|3596| 		else
|3597|3597| 			this.orderQueue.splice(i, 1);
|3598|3598| 		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
|3592|3592| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3593|3593| 			continue;
|3594|3594| 		if (i == 0)
|3595|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3595|+			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg });
|3596|3596| 		else
|3597|3597| 			this.orderQueue.splice(i, 1);
|3598|3598| 		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
|3679|3679| };
|3680|3680| 
|3681|3681| 
|3682|    |-//// FSM linkage functions ////
|    |3682|+// // FSM linkage functions ////
|3683|3683| 
|3684|3684| // Setting the next state to the current state will leave/re-enter the top-most substate.
|3685|3685| 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
|3850|3850| 				continue;
|3851|3851| 			if (this.orderQueue[i].type == type)
|3852|3852| 				continue;
|3853|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3853|+			this.orderQueue.splice(i, 0, { "type": type, "data": data});
|3854|3854| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3855|3855| 			return;
|3856|3856| 		}
|    | [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
|3850|3850| 				continue;
|3851|3851| 			if (this.orderQueue[i].type == type)
|3852|3852| 				continue;
|3853|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3853|+			this.orderQueue.splice(i, 0, {"type": type, "data": data });
|3854|3854| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3855|3855| 			return;
|3856|3856| 		}
|    | [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
|4092|4092| 	if (data.timerRepeat === undefined)
|4093|4093| 		this.timer = undefined;
|4094|4094| 
|4095|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |4095|+	this.UnitFsm.ProcessMessage(this, { "type": "Timer", "data": data, "lateness": lateness});
|4096|4096| };
|4097|4097| 
|4098|4098| /**
|    | [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
|4092|4092| 	if (data.timerRepeat === undefined)
|4093|4093| 		this.timer = undefined;
|4094|4094| 
|4095|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |4095|+	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness });
|4096|4096| };
|4097|4097| 
|4098|4098| /**
|    | [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
|4137|4137| 	// TODO: This is a bit inefficient since every unit listens to every
|4138|4138| 	// construction message - ideally we could scope it to only the one we're building
|4139|4139| 
|4140|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |4140|+	this.UnitFsm.ProcessMessage(this, { "type": "ConstructionFinished", "data": msg});
|4141|4141| };
|4142|4142| 
|4143|4143| 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
|4137|4137| 	// TODO: This is a bit inefficient since every unit listens to every
|4138|4138| 	// construction message - ideally we could scope it to only the one we're building
|4139|4139| 
|4140|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |4140|+	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg });
|4141|4141| };
|4142|4142| 
|4143|4143| 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
|4168|4168| 	if (msg.fromStatusEffect)
|4169|4169| 		return;
|4170|4170| 
|4171|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |4171|+	this.UnitFsm.ProcessMessage(this, { "type": "Attacked", "data": msg});
|4172|4172| };
|4173|4173| 
|4174|4174| 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
|4168|4168| 	if (msg.fromStatusEffect)
|4169|4169| 		return;
|4170|4170| 
|4171|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |4171|+	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg });
|4172|4172| };
|4173|4173| 
|4174|4174| 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
|4173|4173| 
|4174|4174| UnitAI.prototype.OnGuardedAttacked = function(msg)
|4175|4175| {
|4176|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |4176|+	this.UnitFsm.ProcessMessage(this, { "type": "GuardedAttacked", "data": msg.data});
|4177|4177| };
|4178|4178| 
|4179|4179| 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
|4173|4173| 
|4174|4174| UnitAI.prototype.OnGuardedAttacked = function(msg)
|4175|4175| {
|4176|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |4176|+	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data });
|4177|4177| };
|4178|4178| 
|4179|4179| 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
|4178|4178| 
|4179|4179| UnitAI.prototype.OnHealthChanged = function(msg)
|4180|4180| {
|4181|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |4181|+	this.UnitFsm.ProcessMessage(this, { "type": "HealthChanged", "from": msg.from, "to": msg.to});
|4182|4182| };
|4183|4183| 
|4184|4184| 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
|4178|4178| 
|4179|4179| UnitAI.prototype.OnHealthChanged = function(msg)
|4180|4180| {
|4181|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |4181|+	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to });
|4182|4182| };
|4183|4183| 
|4184|4184| 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
|4184|4184| UnitAI.prototype.OnRangeUpdate = function(msg)
|4185|4185| {
|4186|4186| 	if (msg.tag == this.losRangeQuery)
|4187|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|    |4187|+		this.UnitFsm.ProcessMessage(this, { "type": "LosRangeUpdate", "data": msg});
|4188|4188| 	else if (msg.tag == this.losHealRangeQuery)
|4189|4189| 		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|4190|4190| };
|    | [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
|4184|4184| UnitAI.prototype.OnRangeUpdate = function(msg)
|4185|4185| {
|4186|4186| 	if (msg.tag == this.losRangeQuery)
|4187|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|    |4187|+		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg });
|4188|4188| 	else if (msg.tag == this.losHealRangeQuery)
|4189|4189| 		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|4190|4190| };
|    | [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
|4186|4186| 	if (msg.tag == this.losRangeQuery)
|4187|4187| 		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|4188|4188| 	else if (msg.tag == this.losHealRangeQuery)
|4189|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|    |4189|+		this.UnitFsm.ProcessMessage(this, { "type": "LosHealRangeUpdate", "data": msg});
|4190|4190| };
|4191|4191| 
|4192|4192| UnitAI.prototype.OnPackFinished = 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
|4186|4186| 	if (msg.tag == this.losRangeQuery)
|4187|4187| 		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|4188|4188| 	else if (msg.tag == this.losHealRangeQuery)
|4189|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|    |4189|+		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg });
|4190|4190| };
|4191|4191| 
|4192|4192| UnitAI.prototype.OnPackFinished = 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
|4191|4191| 
|4192|4192| UnitAI.prototype.OnPackFinished = function(msg)
|4193|4193| {
|4194|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |4194|+	this.UnitFsm.ProcessMessage(this, { "type": "PackFinished", "packed": msg.packed});
|4195|4195| };
|4196|4196| 
|4197|4197| //// 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
|4191|4191| 
|4192|4192| UnitAI.prototype.OnPackFinished = function(msg)
|4193|4193| {
|4194|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |4194|+	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed });
|4195|4195| };
|4196|4196| 
|4197|4197| //// 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
|4194|4194| 	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|4195|4195| };
|4196|4196| 
|4197|    |-//// Helper functions to be called by the FSM ////
|    |4197|+// // Helper functions to be called by the FSM ////
|4198|4198| 
|4199|4199| UnitAI.prototype.GetWalkSpeed = function()
|4200|4200| {
|    | [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
|4901|4901| UnitAI.prototype.AttackEntityInZone = function(ents)
|4902|4902| {
|4903|4903| 	var target = ents.find(target =>
|4904|    |-		this.CanAttack(target)
|4905|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|    |4904|+		this.CanAttack(target) &&
|    |4905|+		this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4906|4906| 		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4907|4907| 	);
|4908|4908| 	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
|4902|4902| {
|4903|4903| 	var target = ents.find(target =>
|4904|4904| 		this.CanAttack(target)
|4905|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4906|    |-		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|    |4905|+		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true)) &&
|    |4906|+		(this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4907|4907| 	);
|4908|4908| 	if (!target)
|4909|4909| 		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
|4968|4968| 	// If we are guarding/escorting, don't abandon as long as the guarded unit is in target range of the attacker
|4969|4969| 	if (this.isGuardOf)
|4970|4970| 	{
|4971|    |-		var cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |4971|+		var cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|4972|4972| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4973|4973| 		if (cmpUnitAI && cmpAttack &&
|4974|4974| 		    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
|4972|4972| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4973|4973| 		if (cmpUnitAI && cmpAttack &&
|4974|4974| 		    cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type)))
|4975|    |-				return false;
|    |4975|+			return false;
|4976|4976| 	}
|4977|4977| 
|4978|4978| 	// 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
|5010|5010| 	// If we are guarding/escorting, chase at least as long as the guarded unit is in target range of the attacker
|5011|5011| 	if (this.isGuardOf)
|5012|5012| 	{
|5013|    |-		let cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |5013|+		let cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|5014|5014| 		let cmpAttack = Engine.QueryInterface(target, IID_Attack);
|5015|5015| 		if (cmpUnitAI && cmpAttack &&
|5016|5016| 		    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
|5023|5023| 	return false;
|5024|5024| };
|5025|5025| 
|5026|    |-//// External interface functions ////
|    |5026|+// // External interface functions ////
|5027|5027| 
|5028|5028| UnitAI.prototype.SetFormationController = function(ent)
|5029|5029| {
|    | [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
|5179|5179| 	{
|5180|5180| 		if (this.isGuardOf == target && this.order && this.order.type == "Guard")
|5181|5181| 			return;
|5182|    |-		else
|5183|    |-			this.RemoveGuard();
|    |5182|+		this.RemoveGuard();
|5184|5183| 	}
|5185|5184| 
|5186|5185| 	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
|5510|5510| 
|5511|5511| 	if (this.IsFormationController())
|5512|5512| 		this.CallMemberFunction("CancelSetupTradeRoute", [target]);
|5513|    |-}
|    |5513|+};
|5514|5514| /**
|5515|5515|  * Adds trade order to the queue. Either walk to the first market, or
|5516|5516|  * 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
|5531|5531| 	    this.workOrders.length && this.workOrders[0].type == "Trade")
|5532|5532| 	{
|5533|5533| 		let cmpTrader = Engine.QueryInterface(this.entity, IID_Trader);
|5534|    |-		if (cmpTrader.HasBothMarkets() && 
|    |5534|+		if (cmpTrader.HasBothMarkets() &&
|5535|5535| 		   (cmpTrader.GetFirstMarket() == target && cmpTrader.GetSecondMarket() == source ||
|5536|5536| 		    cmpTrader.GetFirstMarket() == source && cmpTrader.GetSecondMarket() == target))
|5537|5537| 		{
|    | [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
|5812|5812| 				{
|5813|5813| 					var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5814|5814| 					var targetClasses = this.order.data.targetClasses;
|5815|    |-					if (targetClasses.attack && cmpIdentity
|5816|    |-						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5815|+					if (targetClasses.attack && cmpIdentity &&
|    |5816|+						!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5817|5817| 						continue;
|5818|5818| 					if (targetClasses.avoid && cmpIdentity
|5819|5819| 						&& 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
|5815|5815| 					if (targetClasses.attack && cmpIdentity
|5816|5816| 						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5817|5817| 						continue;
|5818|    |-					if (targetClasses.avoid && cmpIdentity
|5819|    |-						&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5818|+					if (targetClasses.avoid && cmpIdentity &&
|    |5819|+						MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5820|5820| 						continue;
|5821|5821| 					// Only used by the AIs to prevent some choices of targets
|5822|5822| 					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
|5838|5838| 		{
|5839|5839| 			var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5840|5840| 			var targetClasses = this.order.data.targetClasses;
|5841|    |-			if (cmpIdentity && targetClasses.attack
|5842|    |-				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5841|+			if (cmpIdentity && targetClasses.attack &&
|    |5842|+				!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5843|5843| 				continue;
|5844|5844| 			if (cmpIdentity && targetClasses.avoid
|5845|5845| 				&& 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
|5841|5841| 			if (cmpIdentity && targetClasses.attack
|5842|5842| 				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5843|5843| 				continue;
|5844|    |-			if (cmpIdentity && targetClasses.avoid
|5845|    |-				&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5844|+			if (cmpIdentity && targetClasses.avoid &&
|    |5845|+				MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5846|5846| 				continue;
|5847|5847| 			// Only used by the AIs to prevent some choices of targets
|5848|5848| 			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
|6001|6001| 
|6002|6002| UnitAI.prototype.SetHeldPosition = function(x, z)
|6003|6003| {
|6004|    |-	this.heldPosition = {"x": x, "z": z};
|    |6004|+	this.heldPosition = { "x": x, "z": z};
|6005|6005| };
|6006|6006| 
|6007|6007| 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
|6001|6001| 
|6002|6002| UnitAI.prototype.SetHeldPosition = function(x, z)
|6003|6003| {
|6004|    |-	this.heldPosition = {"x": x, "z": z};
|    |6004|+	this.heldPosition = {"x": x, "z": z };
|6005|6005| };
|6006|6006| 
|6007|6007| 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
|6028|6028| 	return false;
|6029|6029| };
|6030|6030| 
|6031|    |-//// Helper functions ////
|    |6031|+// // Helper functions ////
|6032|6032| 
|6033|6033| /**
|6034|6034|  * 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
|6047|6047| 		return undefined;
|6048|6048| 
|6049|6049| 	return component.GetRange(type);
|6050|    |-}
|    |6050|+};
|6051|6051| 
|6052|6052| UnitAI.prototype.CanAttack = function(target)
|6053|6053| {
|    | [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
|6215|6215| 	return cmpPack && cmpPack.IsPacking();
|6216|6216| };
|6217|6217| 
|6218|    |-//// Formation specific functions ////
|    |6218|+// // Formation specific functions ////
|6219|6219| 
|6220|6220| UnitAI.prototype.IsAttackingAsFormation = function()
|6221|6221| {
|    | [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
|6220|6220| UnitAI.prototype.IsAttackingAsFormation = function()
|6221|6221| {
|6222|6222| 	var cmpAttack = Engine.QueryInterface(this.entity, IID_Attack);
|6223|    |-	return cmpAttack && cmpAttack.CanAttackAsFormation()
|6224|    |-		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|    |6223|+	return cmpAttack && cmpAttack.CanAttackAsFormation() &&
|    |6224|+		this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|6225|6225| };
|6226|6226| 
|6227|6227| //// 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
|6224|6224| 		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|6225|6225| };
|6226|6226| 
|6227|    |-//// Animal specific functions ////
|    |6227|+// // Animal specific functions ////
|6228|6228| 
|6229|6229| UnitAI.prototype.MoveRandomly = function(distance)
|6230|6230| {

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

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

binaries/data/mods/public/simulation/components/UnitAI.js
|3997| »   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
|4888| »   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
|4903| »   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
|4951| »   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
|4974| »   »   ····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
|2036| »   »   »   »   »   »   &&·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
|3135| »   »   »   »   »   this.SetAnimationVariant(this.formationAnimationVariant)
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

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

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

binaries/data/mods/public/simulation/components/UnitAI.js
|4905| »   »   &&·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
|4906| »   »   &&·(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
|5513| }
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

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

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

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

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

binaries/data/mods/public/simulation/components/UnitAI.js
|5842| »   »   »   »   &&·!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
|5845| »   »   »   »   &&·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
|6050| }
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

binaries/data/mods/public/simulation/components/UnitAI.js
|6224| »   »   &&·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/docker-differential/2285/display/redirect