Function introduced in rP23465, GetRange can return undefined when required component does not exist. Fixing two oversights, when check is needed.
Details
Details
- Reviewers
- None
- Commits
- rP23471: Fix checks for range existence following rP23465
- Trac Tickets
- #5666
Test that there is no error related to undefined range.
Diff Detail
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
Comment Actions
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 | 788| 788| this.FinishOrder(); | 789| 789| return; | 790| 790| } | 791| |- else | 792| |- { | | 791|+ | 793| 792| this.SetNextState("GARRISON.APPROACHING"); | 794| 793| return; | 795| |- } | | 794|+ | 796| 795| } | 797| 796| | 798| 797| 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 |1060|1060| }, |1061|1061| }, |1062|1062| |1063| |- "GARRISON":{ | |1063|+ "GARRISON": { |1064|1064| "APPROACHING": { |1065|1065| "enter": function() { |1066|1066| 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 |2038|2038| |2039|2039| "Attacked": function(msg) { |2040|2040| // If we are capturing and are attacked by something that we would not capture, attack that entity instead |2041| |- if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force) |2042| |- && this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture") | |2041|+ if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force) && | |2042|+ this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture") |2043|2043| this.RespondToTargetedEntities([msg.data.attacker]); |2044|2044| }, |2045|2045| }, | | [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 |2776|2776| { |2777|2777| // The building was already finished/fully repaired before we arrived; |2778|2778| // let the ConstructionFinished handler handle this. |2779| |- this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget}); | |2779|+ this.OnGlobalConstructionFinished({ "entity": this.repairTarget, "newentity": this.repairTarget}); |2780|2780| return true; |2781|2781| } |2782|2782| | | [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 |2776|2776| { |2777|2777| // The building was already finished/fully repaired before we arrived; |2778|2778| // let the ConstructionFinished handler handle this. |2779| |- this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget}); | |2779|+ this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget }); |2780|2780| return true; |2781|2781| } |2782|2782| | | [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 |3074|3074| this.StopTimer(); |3075|3075| this.ResetAnimation(); |3076|3076| if (this.formationAnimationVariant) |3077| |- this.SetAnimationVariant(this.formationAnimationVariant) | |3077|+ this.SetAnimationVariant(this.formationAnimationVariant); |3078|3078| else |3079|3079| this.SetDefaultAnimationVariant(); |3080|3080| 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 |3300|3300| "COMBAT": "INDIVIDUAL.COMBAT", // reuse the same combat behaviour for animals |3301|3301| |3302|3302| "WALKING": "INDIVIDUAL.WALKING", // reuse the same walking behaviour for animals |3303| |- // only used for domestic animals | |3303|+ // only used for domestic animals |3304|3304| |3305|3305| // Reuse the same garrison behaviour for animals. |3306|3306| "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 |3362|3362| |3363|3363| UnitAI.prototype.IsAnimal = function() |3364|3364| { |3365| |- return (this.template.NaturalBehaviour ? true : false); | |3365|+ return (!!this.template.NaturalBehaviour); |3366|3366| }; |3367|3367| |3368|3368| 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 |3478|3478| { |3479|3479| let index = this.GetCurrentState().indexOf("."); |3480|3480| if (index != -1) |3481| |- this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0,index)); | |3481|+ this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0, index)); |3482|3482| this.Stop(false); |3483|3483| } |3484|3484| | | [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 |3534|3534| if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity) |3535|3535| continue; |3536|3536| if (i == 0) |3537| |- this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg}); | |3537|+ this.UnitFsm.ProcessMessage(this, { "type": "PickupCanceled", "data": msg}); |3538|3538| else |3539|3539| this.orderQueue.splice(i, 1); |3540|3540| 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 |3534|3534| if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity) |3535|3535| continue; |3536|3536| if (i == 0) |3537| |- this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg}); | |3537|+ this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg }); |3538|3538| else |3539|3539| this.orderQueue.splice(i, 1); |3540|3540| 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 |3621|3621| }; |3622|3622| |3623|3623| |3624| |-//// FSM linkage functions //// | |3624|+// // FSM linkage functions //// |3625|3625| |3626|3626| // Setting the next state to the current state will leave/re-enter the top-most substate. |3627|3627| 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 |3792|3792| continue; |3793|3793| if (this.orderQueue[i].type == type) |3794|3794| continue; |3795| |- this.orderQueue.splice(i, 0, {"type": type, "data": data}); | |3795|+ this.orderQueue.splice(i, 0, { "type": type, "data": data}); |3796|3796| Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() }); |3797|3797| return; |3798|3798| } | | [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 |3792|3792| continue; |3793|3793| if (this.orderQueue[i].type == type) |3794|3794| continue; |3795| |- this.orderQueue.splice(i, 0, {"type": type, "data": data}); | |3795|+ this.orderQueue.splice(i, 0, {"type": type, "data": data }); |3796|3796| Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() }); |3797|3797| return; |3798|3798| } | | [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 |4034|4034| if (data.timerRepeat === undefined) |4035|4035| this.timer = undefined; |4036|4036| |4037| |- this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness}); | |4037|+ this.UnitFsm.ProcessMessage(this, { "type": "Timer", "data": data, "lateness": lateness}); |4038|4038| }; |4039|4039| |4040|4040| /** | | [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 |4034|4034| if (data.timerRepeat === undefined) |4035|4035| this.timer = undefined; |4036|4036| |4037| |- this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness}); | |4037|+ this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness }); |4038|4038| }; |4039|4039| |4040|4040| /** | | [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 |4079|4079| // TODO: This is a bit inefficient since every unit listens to every |4080|4080| // construction message - ideally we could scope it to only the one we're building |4081|4081| |4082| |- this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg}); | |4082|+ this.UnitFsm.ProcessMessage(this, { "type": "ConstructionFinished", "data": msg}); |4083|4083| }; |4084|4084| |4085|4085| 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 |4079|4079| // TODO: This is a bit inefficient since every unit listens to every |4080|4080| // construction message - ideally we could scope it to only the one we're building |4081|4081| |4082| |- this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg}); | |4082|+ this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg }); |4083|4083| }; |4084|4084| |4085|4085| 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 |4110|4110| if (msg.fromStatusEffect) |4111|4111| return; |4112|4112| |4113| |- this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg}); | |4113|+ this.UnitFsm.ProcessMessage(this, { "type": "Attacked", "data": msg}); |4114|4114| }; |4115|4115| |4116|4116| 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 |4110|4110| if (msg.fromStatusEffect) |4111|4111| return; |4112|4112| |4113| |- this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg}); | |4113|+ this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg }); |4114|4114| }; |4115|4115| |4116|4116| 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 |4115|4115| |4116|4116| UnitAI.prototype.OnGuardedAttacked = function(msg) |4117|4117| { |4118| |- this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data}); | |4118|+ this.UnitFsm.ProcessMessage(this, { "type": "GuardedAttacked", "data": msg.data}); |4119|4119| }; |4120|4120| |4121|4121| 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 |4115|4115| |4116|4116| UnitAI.prototype.OnGuardedAttacked = function(msg) |4117|4117| { |4118| |- this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data}); | |4118|+ this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data }); |4119|4119| }; |4120|4120| |4121|4121| 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 |4120|4120| |4121|4121| UnitAI.prototype.OnHealthChanged = function(msg) |4122|4122| { |4123| |- this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to}); | |4123|+ this.UnitFsm.ProcessMessage(this, { "type": "HealthChanged", "from": msg.from, "to": msg.to}); |4124|4124| }; |4125|4125| |4126|4126| 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 |4120|4120| |4121|4121| UnitAI.prototype.OnHealthChanged = function(msg) |4122|4122| { |4123| |- this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to}); | |4123|+ this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to }); |4124|4124| }; |4125|4125| |4126|4126| 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 |4126|4126| UnitAI.prototype.OnRangeUpdate = function(msg) |4127|4127| { |4128|4128| if (msg.tag == this.losRangeQuery) |4129| |- this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg}); | |4129|+ this.UnitFsm.ProcessMessage(this, { "type": "LosRangeUpdate", "data": msg}); |4130|4130| else if (msg.tag == this.losHealRangeQuery) |4131|4131| this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg}); |4132|4132| }; | | [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 |4126|4126| UnitAI.prototype.OnRangeUpdate = function(msg) |4127|4127| { |4128|4128| if (msg.tag == this.losRangeQuery) |4129| |- this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg}); | |4129|+ this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg }); |4130|4130| else if (msg.tag == this.losHealRangeQuery) |4131|4131| this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg}); |4132|4132| }; | | [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 |4128|4128| if (msg.tag == this.losRangeQuery) |4129|4129| this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg}); |4130|4130| else if (msg.tag == this.losHealRangeQuery) |4131| |- this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg}); | |4131|+ this.UnitFsm.ProcessMessage(this, { "type": "LosHealRangeUpdate", "data": msg}); |4132|4132| }; |4133|4133| |4134|4134| 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 |4128|4128| if (msg.tag == this.losRangeQuery) |4129|4129| this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg}); |4130|4130| else if (msg.tag == this.losHealRangeQuery) |4131| |- this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg}); | |4131|+ this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg }); |4132|4132| }; |4133|4133| |4134|4134| 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 |4133|4133| |4134|4134| UnitAI.prototype.OnPackFinished = function(msg) |4135|4135| { |4136| |- this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed}); | |4136|+ this.UnitFsm.ProcessMessage(this, { "type": "PackFinished", "packed": msg.packed}); |4137|4137| }; |4138|4138| |4139|4139| //// 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 |4133|4133| |4134|4134| UnitAI.prototype.OnPackFinished = function(msg) |4135|4135| { |4136| |- this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed}); | |4136|+ this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed }); |4137|4137| }; |4138|4138| |4139|4139| //// 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 |4136|4136| this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed}); |4137|4137| }; |4138|4138| |4139| |-//// Helper functions to be called by the FSM //// | |4139|+// // Helper functions to be called by the FSM //// |4140|4140| |4141|4141| UnitAI.prototype.GetWalkSpeed = function() |4142|4142| { | | [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 |4802|4802| UnitAI.prototype.AttackEntityInZone = function(ents) |4803|4803| { |4804|4804| var target = ents.find(target => |4805| |- this.CanAttack(target) |4806| |- && this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true)) | |4805|+ this.CanAttack(target) && | |4806|+ this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true)) |4807|4807| && (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target)) |4808|4808| ); |4809|4809| 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 |4803|4803| { |4804|4804| var target = ents.find(target => |4805|4805| this.CanAttack(target) |4806| |- && this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true)) |4807| |- && (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target)) | |4806|+ && this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true)) && | |4807|+ (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target)) |4808|4808| ); |4809|4809| if (!target) |4810|4810| 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 |4867|4867| // If we are guarding/escorting, don't abandon as long as the guarded unit is in target range of the attacker |4868|4868| if (this.isGuardOf) |4869|4869| { |4870| |- var cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI); | |4870|+ var cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI); |4871|4871| var cmpAttack = Engine.QueryInterface(target, IID_Attack); |4872|4872| if (cmpUnitAI && cmpAttack && |4873|4873| 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 |4871|4871| var cmpAttack = Engine.QueryInterface(target, IID_Attack); |4872|4872| if (cmpUnitAI && cmpAttack && |4873|4873| cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type))) |4874| |- return false; | |4874|+ return false; |4875|4875| } |4876|4876| |4877|4877| // 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 |4909|4909| // If we are guarding/escorting, chase at least as long as the guarded unit is in target range of the attacker |4910|4910| if (this.isGuardOf) |4911|4911| { |4912| |- let cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI); | |4912|+ let cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI); |4913|4913| let cmpAttack = Engine.QueryInterface(target, IID_Attack); |4914|4914| if (cmpUnitAI && cmpAttack && |4915|4915| 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 |4922|4922| return false; |4923|4923| }; |4924|4924| |4925| |-//// External interface functions //// | |4925|+// // External interface functions //// |4926|4926| |4927|4927| UnitAI.prototype.SetFormationController = function(ent) |4928|4928| { | | [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 |5078|5078| { |5079|5079| if (this.isGuardOf == target && this.order && this.order.type == "Guard") |5080|5080| return; |5081| |- else |5082| |- this.RemoveGuard(); | |5081|+ this.RemoveGuard(); |5083|5082| } |5084|5083| |5085|5084| 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 |5420|5420| this.workOrders.length && this.workOrders[0].type == "Trade") |5421|5421| { |5422|5422| let cmpTrader = Engine.QueryInterface(this.entity, IID_Trader); |5423| |- if (cmpTrader.HasBothMarkets() && | |5423|+ if (cmpTrader.HasBothMarkets() && |5424|5424| (cmpTrader.GetFirstMarket() == target && cmpTrader.GetSecondMarket() == source || |5425|5425| cmpTrader.GetFirstMarket() == source && cmpTrader.GetSecondMarket() == target)) |5426|5426| { | | [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 |5701|5701| { |5702|5702| var cmpIdentity = Engine.QueryInterface(targ, IID_Identity); |5703|5703| var targetClasses = this.order.data.targetClasses; |5704| |- if (targetClasses.attack && cmpIdentity |5705| |- && !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack)) | |5704|+ if (targetClasses.attack && cmpIdentity && | |5705|+ !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack)) |5706|5706| continue; |5707|5707| if (targetClasses.avoid && cmpIdentity |5708|5708| && 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 |5704|5704| if (targetClasses.attack && cmpIdentity |5705|5705| && !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack)) |5706|5706| continue; |5707| |- if (targetClasses.avoid && cmpIdentity |5708| |- && MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid)) | |5707|+ if (targetClasses.avoid && cmpIdentity && | |5708|+ MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid)) |5709|5709| continue; |5710|5710| // Only used by the AIs to prevent some choices of targets |5711|5711| 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 |5727|5727| { |5728|5728| var cmpIdentity = Engine.QueryInterface(targ, IID_Identity); |5729|5729| var targetClasses = this.order.data.targetClasses; |5730| |- if (cmpIdentity && targetClasses.attack |5731| |- && !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack)) | |5730|+ if (cmpIdentity && targetClasses.attack && | |5731|+ !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack)) |5732|5732| continue; |5733|5733| if (cmpIdentity && targetClasses.avoid |5734|5734| && 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 |5730|5730| if (cmpIdentity && targetClasses.attack |5731|5731| && !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack)) |5732|5732| continue; |5733| |- if (cmpIdentity && targetClasses.avoid |5734| |- && MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid)) | |5733|+ if (cmpIdentity && targetClasses.avoid && | |5734|+ MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid)) |5735|5735| continue; |5736|5736| // Only used by the AIs to prevent some choices of targets |5737|5737| 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 |5873|5873| |5874|5874| UnitAI.prototype.SetHeldPosition = function(x, z) |5875|5875| { |5876| |- this.heldPosition = {"x": x, "z": z}; | |5876|+ this.heldPosition = { "x": x, "z": z}; |5877|5877| }; |5878|5878| |5879|5879| 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 |5873|5873| |5874|5874| UnitAI.prototype.SetHeldPosition = function(x, z) |5875|5875| { |5876| |- this.heldPosition = {"x": x, "z": z}; | |5876|+ this.heldPosition = {"x": x, "z": z }; |5877|5877| }; |5878|5878| |5879|5879| 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 |5900|5900| return false; |5901|5901| }; |5902|5902| |5903| |-//// Helper functions //// | |5903|+// // Helper functions //// |5904|5904| |5905|5905| /** |5906|5906| * 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 |5919|5919| return; |5920|5920| |5921|5921| return component.GetRange(type); |5922| |-} | |5922|+}; |5923|5923| |5924|5924| UnitAI.prototype.CanAttack = function(target) |5925|5925| { | | [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 |6117|6117| return cmpPack && cmpPack.IsPacking(); |6118|6118| }; |6119|6119| |6120| |-//// Formation specific functions //// | |6120|+// // Formation specific functions //// |6121|6121| |6122|6122| UnitAI.prototype.IsAttackingAsFormation = function() |6123|6123| { | | [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 |6122|6122| UnitAI.prototype.IsAttackingAsFormation = function() |6123|6123| { |6124|6124| var cmpAttack = Engine.QueryInterface(this.entity, IID_Attack); |6125| |- return cmpAttack && cmpAttack.CanAttackAsFormation() |6126| |- && this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING"; | |6125|+ return cmpAttack && cmpAttack.CanAttackAsFormation() && | |6126|+ this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING"; |6127|6127| }; |6128|6128| |6129|6129| //// 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 |6126|6126| && this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING"; |6127|6127| }; |6128|6128| |6129| |-//// Animal specific functions //// | |6129|+// // Animal specific functions //// |6130|6130| |6131|6131| UnitAI.prototype.MoveRandomly = function(distance) |6132|6132| { 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 |1248| » » » » return·false; | | [NORMAL] ESLintBear (consistent-return): | | Method 'Timer' expected no return value. binaries/data/mods/public/simulation/components/UnitAI.js |3939| » 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 |4789| » 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 |4804| » 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 |4850| » 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 |4873| » » ····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 |5921| » return·component.GetRange(type); | | [NORMAL] ESLintBear (consistent-return): | | Function expected no return value. binaries/data/mods/public/simulation/components/UnitAI.js |2042| » » » » » » &&·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 |3077| » » » » » this.SetAnimationVariant(this.formationAnimationVariant) | | [NORMAL] JSHintBear: | | Missing semicolon. binaries/data/mods/public/simulation/components/UnitAI.js |3886| » » var·order·=·{·"type":·type,·"data":·data·}; | | [NORMAL] JSHintBear: | | 'order' is already defined. binaries/data/mods/public/simulation/components/UnitAI.js |3970| » for·(var·i·=·0;·i·<·this.orderQueue.length;·++i) | | [NORMAL] JSHintBear: | | 'i' is already defined. binaries/data/mods/public/simulation/components/UnitAI.js |4806| » » &&·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 |4807| » » &&·(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 |5705| » » » » » » &&·!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 |5708| » » » » » » &&·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 |5721| » var·targets·=·this.GetTargetsFromUnit(); | | [NORMAL] JSHintBear: | | 'targets' is already defined. binaries/data/mods/public/simulation/components/UnitAI.js |5722| » for·(var·targ·of·targets) | | [NORMAL] JSHintBear: | | 'targ' is already defined. binaries/data/mods/public/simulation/components/UnitAI.js |5728| » » » var·cmpIdentity·=·Engine.QueryInterface(targ,·IID_Identity); | | [NORMAL] JSHintBear: | | 'cmpIdentity' is already defined. binaries/data/mods/public/simulation/components/UnitAI.js |5729| » » » var·targetClasses·=·this.order.data.targetClasses; | | [NORMAL] JSHintBear: | | 'targetClasses' is already defined. binaries/data/mods/public/simulation/components/UnitAI.js |5731| » » » » &&·!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 |5734| » » » » &&·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 |5922| } | | [NORMAL] JSHintBear: | | Missing semicolon. binaries/data/mods/public/simulation/components/UnitAI.js |6126| » » &&·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/1687/display/redirect
binaries/data/mods/public/simulation/components/UnitAI.js | ||
---|---|---|
5919 ↗ | (On Diff #11236) | return undefined; for consistency (https://eslint.org/docs/2.0.0/rules/consistent-return) |