This fixes units always using capture attack on a building, since we forgot in rP22569 to eliminate Capture from the types list when not allowed.
Details
Details
- Reviewers
Freagarach - Commits
- rP22575: Fix Capture oversight in GetBestAttackAgainst in rP22569
- Trac Tickets
- #5544
Verify its correctness.
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/Attack.js | |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/Attack.js | 416| 416| { | 417| 417| if (allowCapture) | 418| 418| return "Capture"; | 419| |- else | 420| |- types.splice(captureIndex, 1); | | 419|+ types.splice(captureIndex, 1); | 421| 420| } | 422| 421| | 423| 422| let isPreferred = className => this.GetPreferredClasses(className).some(isTargetClass); | | [NORMAL] ESLintBear (spaced-comment): | | Expected space or tab after '//' in comment. |----| | /zpool0/trunk/binaries/data/mods/public/simulation/components/Attack.js | |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/Attack.js | 529| 529| | 530| 530| let horizSpeed = +this.template[type].Projectile.Speed; | 531| 531| let gravity = +this.template[type].Projectile.Gravity; | 532| |- //horizSpeed /= 2; gravity /= 2; // slow it down for testing | | 532|+ // horizSpeed /= 2; gravity /= 2; // slow it down for testing | 533| 533| | 534| 534| let cmpPosition = Engine.QueryInterface(this.entity, IID_Position); | 535| 535| if (!cmpPosition || !cmpPosition.IsInWorld()) | | [NORMAL] ESLintBear (no-trailing-spaces): | | Trailing spaces not allowed. |----| | /zpool0/trunk/binaries/data/mods/public/simulation/components/Attack.js | |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/Attack.js | 576| 576| // TODO: Use unit rotation to implement x/z offsets. | 577| 577| let deltaLaunchPoint = new Vector3D(0, this.template[type].Projectile.LaunchPoint["@y"], 0.0); | 578| 578| let launchPoint = Vector3D.add(selfPosition, deltaLaunchPoint); | 579| |- | | 579|+ | 580| 580| let cmpVisual = Engine.QueryInterface(this.entity, IID_Visual); | 581| 581| if (cmpVisual) | 582| 582| { binaries/data/mods/public/simulation/components/Attack.js | 519| ·» let·cmpDamage·=·Engine.QueryInterface(SYSTEM_ENTITY,·IID_Damage); | | [NORMAL] ESLintBear (no-mixed-spaces-and-tabs): | | Mixed spaces and tabs. binaries/data/mods/public/simulation/components/Attack.js | 623| » » cmpTimer.SetTimeout(SYSTEM_ENTITY,·IID_Damage,·"MissileHit",·timeToTarget·*·1000·+·+this.template[type].Delay,·data); | | [NORMAL] JSHintBear: | | Confusing plusses. Executing section cli...
Link to build: https://jenkins.wildfiregames.com/job/docker-differential/266/display/redirect
Comment Actions
Commandeering to add a test line for this particular case, which as missing before.
Thanks for the patch :)
Comment Actions
As elexis said on IRC we could pass the filter to GetAttackTypes but that has a parameter used in tests, so it's a little more involved than I want it to be right now.
Comment Actions
Successful build - Chance fights ever on the side of the prudent.
Linter detected issues: Executing section Source... Executing section JS... | | [NORMAL] ESLintBear (spaced-comment): | | Expected space or tab after '//' in comment. |----| | /zpool0/trunk/binaries/data/mods/public/simulation/components/Attack.js | |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/Attack.js | 528| 528| | 529| 529| let horizSpeed = +this.template[type].Projectile.Speed; | 530| 530| let gravity = +this.template[type].Projectile.Gravity; | 531| |- //horizSpeed /= 2; gravity /= 2; // slow it down for testing | | 531|+ // horizSpeed /= 2; gravity /= 2; // slow it down for testing | 532| 532| | 533| 533| let cmpPosition = Engine.QueryInterface(this.entity, IID_Position); | 534| 534| if (!cmpPosition || !cmpPosition.IsInWorld()) | | [NORMAL] ESLintBear (no-trailing-spaces): | | Trailing spaces not allowed. |----| | /zpool0/trunk/binaries/data/mods/public/simulation/components/Attack.js | |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/Attack.js | 575| 575| // TODO: Use unit rotation to implement x/z offsets. | 576| 576| let deltaLaunchPoint = new Vector3D(0, this.template[type].Projectile.LaunchPoint["@y"], 0.0); | 577| 577| let launchPoint = Vector3D.add(selfPosition, deltaLaunchPoint); | 578| |- | | 578|+ | 579| 579| let cmpVisual = Engine.QueryInterface(this.entity, IID_Visual); | 580| 580| if (cmpVisual) | 581| 581| { binaries/data/mods/public/simulation/components/Attack.js | 518| ·» let·cmpDamage·=·Engine.QueryInterface(SYSTEM_ENTITY,·IID_Damage); | | [NORMAL] ESLintBear (no-mixed-spaces-and-tabs): | | Mixed spaces and tabs. binaries/data/mods/public/simulation/components/Attack.js | 622| » » cmpTimer.SetTimeout(SYSTEM_ENTITY,·IID_Damage,·"MissileHit",·timeToTarget·*·1000·+·+this.template[type].Delay,·data); | | [NORMAL] JSHintBear: | | Confusing plusses. Executing section cli...
Link to build: https://jenkins.wildfiregames.com/job/docker-differential/267/display/redirect