Page MenuHomeWildfire Games

Fix patrol order
ClosedPublic

Authored by wraitii on Jul 24 2019, 12:01 PM.

Details

Reviewers
None
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Commits
rP22546: Fix patrol order and make the relaxed range check into a constant.
Trac Tickets
#5531
Summary

Reported in #5531, introduced by rP22526. I failed to test patrolling, apparently.

Test Plan

Test that patrol works.

Diff Detail

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

Event Timeline

wraitii created this revision.Jul 24 2019, 12:01 PM

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

Linter detected issues:
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (no-else-return):
|    | Unnecessary 'else' after 'return'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
| 753| 753| 					this.FinishOrder();
| 754| 754| 					return;
| 755| 755| 				}
| 756|    |-				else
| 757|    |-				{
|    | 756|+				
| 758| 757| 					this.SetNextState("GARRISON.APPROACHING");
| 759| 758| 					return;
| 760|    |-				}
|    | 759|+				
| 761| 760| 			}
| 762| 761| 
| 763| 762| 			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
|1015|1015| 			},
|1016|1016| 		},
|1017|1017| 
|1018|    |-		"GARRISON":{
|    |1018|+		"GARRISON": {
|1019|1019| 			"enter": function() {
|1020|1020| 				// If the garrisonholder should pickup, warn it so it can take needed action
|1021|1021| 				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
|1969|1969| 
|1970|1970| 				"Attacked": function(msg) {
|1971|1971| 					// If we are capturing and are attacked by something that we would not capture, attack that entity instead
|1972|    |-					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force)
|1973|    |-						&& this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|    |1972|+					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force) &&
|    |1973|+						this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|1974|1974| 						this.RespondToTargetedEntities([msg.data.attacker]);
|1975|1975| 				},
|1976|1976| 			},
|    | [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
|2658|2658| 					{
|2659|2659| 						// The building was already finished/fully repaired before we arrived;
|2660|2660| 						// let the ConstructionFinished handler handle this.
|2661|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2661|+						this.OnGlobalConstructionFinished({ "entity": this.repairTarget, "newentity": this.repairTarget});
|2662|2662| 						return true;
|2663|2663| 					}
|2664|2664| 
|    | [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
|2658|2658| 					{
|2659|2659| 						// The building was already finished/fully repaired before we arrived;
|2660|2660| 						// let the ConstructionFinished handler handle this.
|2661|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2661|+						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget });
|2662|2662| 						return true;
|2663|2663| 					}
|2664|2664| 
|    | [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
|3171|3171| 		"COMBAT": "INDIVIDUAL.COMBAT", // reuse the same combat behaviour for animals
|3172|3172| 
|3173|3173| 		"WALKING": "INDIVIDUAL.WALKING",	// reuse the same walking behaviour for animals
|3174|    |-							// only used for domestic animals
|    |3174|+		// only used for domestic animals
|3175|3175| 	},
|3176|3176| };
|3177|3177| 
|    | [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
|3228|3228| 
|3229|3229| UnitAI.prototype.IsAnimal = function()
|3230|3230| {
|3231|    |-	return (this.template.NaturalBehaviour ? true : false);
|    |3231|+	return (!!this.template.NaturalBehaviour);
|3232|3232| };
|3233|3233| 
|3234|3234| 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
|3344|3344| 		{
|3345|3345| 			let index = this.GetCurrentState().indexOf(".");
|3346|3346| 			if (index != -1)
|3347|    |-				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0,index));
|    |3347|+				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0, index));
|3348|3348| 			this.Stop(false);
|3349|3349| 		}
|3350|3350| 
|    | [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
|3400|3400| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3401|3401| 			continue;
|3402|3402| 		if (i == 0)
|3403|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3403|+			this.UnitFsm.ProcessMessage(this, { "type": "PickupCanceled", "data": msg});
|3404|3404| 		else
|3405|3405| 			this.orderQueue.splice(i, 1);
|3406|3406| 		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
|3400|3400| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3401|3401| 			continue;
|3402|3402| 		if (i == 0)
|3403|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3403|+			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg });
|3404|3404| 		else
|3405|3405| 			this.orderQueue.splice(i, 1);
|3406|3406| 		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
|3484|3484| };
|3485|3485| 
|3486|3486| 
|3487|    |-//// FSM linkage functions ////
|    |3487|+// // FSM linkage functions ////
|3488|3488| 
|3489|3489| // Setting the next state to the current state will leave/re-enter the top-most substate.
|3490|3490| 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
|3654|3654| 				continue;
|3655|3655| 			if (this.orderQueue[i].type == type)
|3656|3656| 				continue;
|3657|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3657|+			this.orderQueue.splice(i, 0, { "type": type, "data": data});
|3658|3658| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3659|3659| 			return;
|3660|3660| 		}
|    | [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
|3654|3654| 				continue;
|3655|3655| 			if (this.orderQueue[i].type == type)
|3656|3656| 				continue;
|3657|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3657|+			this.orderQueue.splice(i, 0, {"type": type, "data": data });
|3658|3658| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3659|3659| 			return;
|3660|3660| 		}
|    | [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
|3825|3825| 	if (data.timerRepeat === undefined)
|3826|3826| 		this.timer = undefined;
|3827|3827| 
|3828|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |3828|+	this.UnitFsm.ProcessMessage(this, { "type": "Timer", "data": data, "lateness": lateness});
|3829|3829| };
|3830|3830| 
|3831|3831| /**
|    | [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
|3825|3825| 	if (data.timerRepeat === undefined)
|3826|3826| 		this.timer = undefined;
|3827|3827| 
|3828|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |3828|+	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness });
|3829|3829| };
|3830|3830| 
|3831|3831| /**
|    | [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
|3870|3870| 	// TODO: This is a bit inefficient since every unit listens to every
|3871|3871| 	// construction message - ideally we could scope it to only the one we're building
|3872|3872| 
|3873|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |3873|+	this.UnitFsm.ProcessMessage(this, { "type": "ConstructionFinished", "data": msg});
|3874|3874| };
|3875|3875| 
|3876|3876| 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
|3870|3870| 	// TODO: This is a bit inefficient since every unit listens to every
|3871|3871| 	// construction message - ideally we could scope it to only the one we're building
|3872|3872| 
|3873|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |3873|+	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg });
|3874|3874| };
|3875|3875| 
|3876|3876| 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
|3895|3895| 
|3896|3896| UnitAI.prototype.OnAttacked = function(msg)
|3897|3897| {
|3898|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |3898|+	this.UnitFsm.ProcessMessage(this, { "type": "Attacked", "data": msg});
|3899|3899| };
|3900|3900| 
|3901|3901| 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
|3895|3895| 
|3896|3896| UnitAI.prototype.OnAttacked = function(msg)
|3897|3897| {
|3898|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |3898|+	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg });
|3899|3899| };
|3900|3900| 
|3901|3901| 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
|3900|3900| 
|3901|3901| UnitAI.prototype.OnGuardedAttacked = function(msg)
|3902|3902| {
|3903|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |3903|+	this.UnitFsm.ProcessMessage(this, { "type": "GuardedAttacked", "data": msg.data});
|3904|3904| };
|3905|3905| 
|3906|3906| 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
|3900|3900| 
|3901|3901| UnitAI.prototype.OnGuardedAttacked = function(msg)
|3902|3902| {
|3903|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |3903|+	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data });
|3904|3904| };
|3905|3905| 
|3906|3906| 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
|3905|3905| 
|3906|3906| UnitAI.prototype.OnHealthChanged = function(msg)
|3907|3907| {
|3908|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |3908|+	this.UnitFsm.ProcessMessage(this, { "type": "HealthChanged", "from": msg.from, "to": msg.to});
|3909|3909| };
|3910|3910| 
|3911|3911| 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
|3905|3905| 
|3906|3906| UnitAI.prototype.OnHealthChanged = function(msg)
|3907|3907| {
|3908|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |3908|+	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to });
|3909|3909| };
|3910|3910| 
|3911|3911| 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
|3911|3911| UnitAI.prototype.OnRangeUpdate = function(msg)
|3912|3912| {
|3913|3913| 	if (msg.tag == this.losRangeQuery)
|3914|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|    |3914|+		this.UnitFsm.ProcessMessage(this, { "type": "LosRangeUpdate", "data": msg});
|3915|3915| 	else if (msg.tag == this.losHealRangeQuery)
|3916|3916| 		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|3917|3917| };
|    | [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
|3911|3911| UnitAI.prototype.OnRangeUpdate = function(msg)
|3912|3912| {
|3913|3913| 	if (msg.tag == this.losRangeQuery)
|3914|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|    |3914|+		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg });
|3915|3915| 	else if (msg.tag == this.losHealRangeQuery)
|3916|3916| 		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|3917|3917| };
|    | [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
|3913|3913| 	if (msg.tag == this.losRangeQuery)
|3914|3914| 		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|3915|3915| 	else if (msg.tag == this.losHealRangeQuery)
|3916|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|    |3916|+		this.UnitFsm.ProcessMessage(this, { "type": "LosHealRangeUpdate", "data": msg});
|3917|3917| };
|3918|3918| 
|3919|3919| 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
|3913|3913| 	if (msg.tag == this.losRangeQuery)
|3914|3914| 		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|3915|3915| 	else if (msg.tag == this.losHealRangeQuery)
|3916|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|    |3916|+		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg });
|3917|3917| };
|3918|3918| 
|3919|3919| 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
|3918|3918| 
|3919|3919| UnitAI.prototype.OnPackFinished = function(msg)
|3920|3920| {
|3921|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |3921|+	this.UnitFsm.ProcessMessage(this, { "type": "PackFinished", "packed": msg.packed});
|3922|3922| };
|3923|3923| 
|3924|3924| //// 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
|3918|3918| 
|3919|3919| UnitAI.prototype.OnPackFinished = function(msg)
|3920|3920| {
|3921|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |3921|+	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed });
|3922|3922| };
|3923|3923| 
|3924|3924| //// 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
|3921|3921| 	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|3922|3922| };
|3923|3923| 
|3924|    |-//// Helper functions to be called by the FSM ////
|    |3924|+// // Helper functions to be called by the FSM ////
|3925|3925| 
|3926|3926| UnitAI.prototype.GetWalkSpeed = function()
|3927|3927| {
|    | [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
|4568|4568| UnitAI.prototype.AttackEntityInZone = function(ents)
|4569|4569| {
|4570|4570| 	var target = ents.find(target =>
|4571|    |-		this.CanAttack(target)
|4572|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|    |4571|+		this.CanAttack(target) &&
|    |4572|+		this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4573|4573| 		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4574|4574| 	);
|4575|4575| 	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
|4569|4569| {
|4570|4570| 	var target = ents.find(target =>
|4571|4571| 		this.CanAttack(target)
|4572|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4573|    |-		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|    |4572|+		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true)) &&
|    |4573|+		(this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4574|4574| 	);
|4575|4575| 	if (!target)
|4576|4576| 		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
|4633|4633| 	// If we are guarding/escorting, don't abandon as long as the guarded unit is in target range of the attacker
|4634|4634| 	if (this.isGuardOf)
|4635|4635| 	{
|4636|    |-		var cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |4636|+		var cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|4637|4637| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4638|4638| 		if (cmpUnitAI && cmpAttack &&
|4639|4639| 		    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
|4637|4637| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4638|4638| 		if (cmpUnitAI && cmpAttack &&
|4639|4639| 		    cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type)))
|4640|    |-				return false;
|    |4640|+			return false;
|4641|4641| 	}
|4642|4642| 
|4643|4643| 	// 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
|4675|4675| 	// If we are guarding/escorting, chase at least as long as the guarded unit is in target range of the attacker
|4676|4676| 	if (this.isGuardOf)
|4677|4677| 	{
|4678|    |-		let cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |4678|+		let cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|4679|4679| 		let cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4680|4680| 		if (cmpUnitAI && cmpAttack &&
|4681|4681| 		    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
|4688|4688| 	return false;
|4689|4689| };
|4690|4690| 
|4691|    |-//// External interface functions ////
|    |4691|+// // External interface functions ////
|4692|4692| 
|4693|4693| UnitAI.prototype.SetFormationController = function(ent)
|4694|4694| {
|    | [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
|4844|4844| 	{
|4845|4845| 		if (this.isGuardOf == target && this.order && this.order.type == "Guard")
|4846|4846| 			return;
|4847|    |-		else
|4848|    |-			this.RemoveGuard();
|    |4847|+		this.RemoveGuard();
|4849|4848| 	}
|4850|4849| 
|4851|4850| 	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
|5176|5176| 	    this.workOrders.length && this.workOrders[0].type == "Trade")
|5177|5177| 	{
|5178|5178| 		let cmpTrader = Engine.QueryInterface(this.entity, IID_Trader);
|5179|    |-		if (cmpTrader.HasBothMarkets() && 
|    |5179|+		if (cmpTrader.HasBothMarkets() &&
|5180|5180| 		   (cmpTrader.GetFirstMarket() == target && cmpTrader.GetSecondMarket() == source ||
|5181|5181| 		    cmpTrader.GetFirstMarket() == source && cmpTrader.GetSecondMarket() == target))
|5182|5182| 		{
|    | [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
|5457|5457| 				{
|5458|5458| 					var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5459|5459| 					var targetClasses = this.order.data.targetClasses;
|5460|    |-					if (targetClasses.attack && cmpIdentity
|5461|    |-						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5460|+					if (targetClasses.attack && cmpIdentity &&
|    |5461|+						!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5462|5462| 						continue;
|5463|5463| 					if (targetClasses.avoid && cmpIdentity
|5464|5464| 						&& 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
|5460|5460| 					if (targetClasses.attack && cmpIdentity
|5461|5461| 						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5462|5462| 						continue;
|5463|    |-					if (targetClasses.avoid && cmpIdentity
|5464|    |-						&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5463|+					if (targetClasses.avoid && cmpIdentity &&
|    |5464|+						MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5465|5465| 						continue;
|5466|5466| 					// Only used by the AIs to prevent some choices of targets
|5467|5467| 					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
|5483|5483| 		{
|5484|5484| 			var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5485|5485| 			var targetClasses = this.order.data.targetClasses;
|5486|    |-			if (cmpIdentity && targetClasses.attack
|5487|    |-				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5486|+			if (cmpIdentity && targetClasses.attack &&
|    |5487|+				!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5488|5488| 				continue;
|5489|5489| 			if (cmpIdentity && targetClasses.avoid
|5490|5490| 				&& 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
|5486|5486| 			if (cmpIdentity && targetClasses.attack
|5487|5487| 				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5488|5488| 				continue;
|5489|    |-			if (cmpIdentity && targetClasses.avoid
|5490|    |-				&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5489|+			if (cmpIdentity && targetClasses.avoid &&
|    |5490|+				MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5491|5491| 				continue;
|5492|5492| 			// Only used by the AIs to prevent some choices of targets
|5493|5493| 			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
|5643|5643| 
|5644|5644| UnitAI.prototype.SetHeldPosition = function(x, z)
|5645|5645| {
|5646|    |-	this.heldPosition = {"x": x, "z": z};
|    |5646|+	this.heldPosition = { "x": x, "z": z};
|5647|5647| };
|5648|5648| 
|5649|5649| 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
|5643|5643| 
|5644|5644| UnitAI.prototype.SetHeldPosition = function(x, z)
|5645|5645| {
|5646|    |-	this.heldPosition = {"x": x, "z": z};
|    |5646|+	this.heldPosition = {"x": x, "z": z };
|5647|5647| };
|5648|5648| 
|5649|5649| 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
|5670|5670| 	return false;
|5671|5671| };
|5672|5672| 
|5673|    |-//// Helper functions ////
|    |5673|+// // Helper functions ////
|5674|5674| 
|5675|5675| UnitAI.prototype.CanAttack = function(target)
|5676|5676| {
|    | [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
|5874|5874| 	return cmpPack && cmpPack.IsPacking();
|5875|5875| };
|5876|5876| 
|5877|    |-//// Formation specific functions ////
|    |5877|+// // Formation specific functions ////
|5878|5878| 
|5879|5879| UnitAI.prototype.IsAttackingAsFormation = function()
|5880|5880| {
|    | [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
|5879|5879| UnitAI.prototype.IsAttackingAsFormation = function()
|5880|5880| {
|5881|5881| 	var cmpAttack = Engine.QueryInterface(this.entity, IID_Attack);
|5882|    |-	return cmpAttack && cmpAttack.CanAttackAsFormation()
|5883|    |-		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|    |5882|+	return cmpAttack && cmpAttack.CanAttackAsFormation() &&
|    |5883|+		this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|5884|5884| };
|5885|5885| 
|5886|5886| //// 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
|5883|5883| 		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|5884|5884| };
|5885|5885| 
|5886|    |-//// Animal specific functions ////
|    |5886|+// // Animal specific functions ////
|5887|5887| 
|5888|5888| UnitAI.prototype.MoveRandomly = function(distance)
|5889|5889| {

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
| 902| »   »   »   "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
| 927| »   »   »   "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
| 977| »   »   »   »   »   return·true;
|    | [NORMAL] ESLintBear (consistent-return):
|    | Method 'enter' expected no return value.

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

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

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

binaries/data/mods/public/simulation/components/UnitAI.js
|2012| »   »   »   »   "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
|2115| »   »   »   »   "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
|2370| »   »   »   »   "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
|2403| »   »   »   »   "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
|2509| »   »   »   »   "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
|2575| »   »   »   »   "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
|2614| »   »   »   »   "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
|2825| »   »   »   »   "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
|3006| »   »   »   »   "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
|3730| »   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
|4555| »   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
|4570| »   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
|4616| »   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
|4639| »   »   ····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
|1973| »   »   »   »   »   »   &&·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
|3692| »   »   var·order·=·{·"type":·type,·"data":·data·};
|    | [NORMAL] JSHintBear:
|    | 'order' is already defined.

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

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

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

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

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

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

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

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

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

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

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

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

binaries/data/mods/public/simulation/components/UnitAI.js
|5883| »   »   &&·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/215/display/redirect

elexis added a subscriber: elexis.Jul 24 2019, 3:28 PM

12 = TERRAIN_TILE_SIZE * MAX_FAILED_PATH_COMPUTATIONS_BEFORE_LONG_PATH?

Nah 12 is just 12 meters, which is 3 terrain tiles and I deem it appropriately close enough.

Could be moved to a constant, but it's magic anyways.

wraitii updated this revision to Diff 9101.Jul 24 2019, 5:34 PM

Make the relaxed range a constant.

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

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

TERRAIN_TILE_SIZE * magic is less magic than pure magic.
(I thought it was exposed to the simulation, like it is for the MapGenerator.cpp, but that was only GetTilesPerSide` i.e. unusable here.)

UnitAI.prototype.DefaultRelaxedMaxRange sounds nice for defining it, but a bit like indirection for accessing it, just use this.DefaultRelaxedMaxRange.

What about serialization? The default serializer only iterates through owned properties I think (?), thus avoiding the constant which is not owned by the UnitAI instance but the UnitAI prototype.

I guess pathfinder.xml is the wrong place as this isn't the pathfinder.
One could also consider using the templates, but then one has to convert from string to number all the time, possibly cache it which again means having to perform manual de/serialization.

The BinarySerializer uses JS::AutoIdArray ida (cx, JS_Enumerate(cx, obj)); so it gets all enumerable properties, i.e. apparently not only owned ones, so it seems the variable would be serialized once per entity, which seems wrong.
https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_Enumerate
But then why does it not enumerate the prototype functions (apparently, as the BinarySerializer complains about functions), meh

binaries/data/mods/public/simulation/components/UnitAI.js
1587 ↗(On Diff #9101)

8 is worse than 12?

4469 ↗(On Diff #9101)

(helps pathfinding performance, not the pathfinding?)

4471 ↗(On Diff #9101)

(Constants to the top?)

UnitAI.prototype.DefaultRelaxedMaxRange sounds nice for defining it, but a bit like indirection for accessing it, just use this.DefaultRelaxedMaxRange.

Fair.

What about serialization? The default serializer only iterates through owned properties I think (?), thus avoiding the constant which is not owned by the UnitAI instance but the UnitAI prototype.

Yes, but we reconstruct the object, so it will exist I think.

I guess pathfinder.xml is the wrong place as this isn't the pathfinder.

Another reason is that we might want to change this based on the entity or the order type someday.

The BinarySerializer uses JS::AutoIdArray ida (cx, JS_Enumerate(cx, obj)); so it gets all enumerable properties, i.e. apparently not only owned ones, so it seems the variable would be serialized once per entity, which seems wrong.
https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_Enumerate
But then why does it not enumerate the prototype functions (apparently, as the BinarySerializer complains about functions), meh

It says The term own property refers to a property that is not inherited from the object's prototype so that would explain it and the above is wrong > it wouldn't serialise it once per entity.

I've checked what UnitAI serialises by default with this patch:

{orderQueue:[], order:(void 0), formationController:0, isGarrisoned:false, isIdle:true, finishedOrder:false, heldPosition:(void 0), workOrders:[], isGuardOf:(void 0), lastAttacked:(void 0), lastHealed:(void 0), stance:"aggressive", fsmStateName:"ANIMAL.FEEDING", fsmNextState:(void 0), timer:8, losRangeQuery:6}

I guess by explicitly serialising we might actually save some space in the save games but not sure it's that important.

binaries/data/mods/public/simulation/components/UnitAI.js
1587 ↗(On Diff #9101)

I don't really have a preference, could be 8, could be 12. I think both are fairly small. 12 means it would work for groups of hundreds of units ordered to walk to a point, 8 would cover fewer units but it might be irrelevant at those scales.

4469 ↗(On Diff #9101)

As we discussed on IRC, this makes units stop earlier / switch to next orders earlier. I wouldn't say it helps pathfinding per se, but it helps performance since we compute fewer paths.

4471 ↗(On Diff #9101)

I think it's better close to UnitAI.prototype.RelaxedMaxRangeCheck

wraitii updated this revision to Diff 9106.Jul 24 2019, 6:58 PM

fetch by using this.DefaultRelaxedMaxRange

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

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

(Reading the first three instead of only the first sentence helps:

JS_Enumerate gets the ids of all own properties of the specified object, obj, that have the JSPROP_ENUMERATE attribute. (The term own property refers to a property that is not inherited from the object's prototype.)

So yes, one may store the number in the prototype.)

This revision was not accepted when it landed; it landed in state Needs Review.Jul 24 2019, 9:05 PM
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.