Page MenuHomeWildfire Games

Fix Capture oversight in GetBestAttackAgainst in rP22569
ClosedPublic

Authored by wraitii on Jul 29 2019, 5:46 PM.

Details

Summary

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.

Test Plan

Verify its correctness.

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

Freagarach created this revision.Jul 29 2019, 5:46 PM
elexis edited the summary of this revision. (Show Details)Jul 29 2019, 5:48 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/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

elexis updated the Trac tickets for this revision.Jul 29 2019, 6:10 PM
elexis retitled this revision from Fix oversight in rP22569. to Fix Capture oversight in GetBestAttackAgainst in rP22569.
wraitii commandeered this revision.Jul 29 2019, 8:40 PM
wraitii edited reviewers, added: Freagarach; removed: wraitii.

Commandeering to add a test line for this particular case, which as missing before.

Thanks for the patch :)

wraitii updated this revision to Diff 9169.Jul 29 2019, 8:41 PM

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.

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

Freagarach accepted this revision.Jul 29 2019, 8:49 PM

Tested, everything works as should.

This revision is now accepted and ready to land.Jul 29 2019, 8:49 PM
This revision was automatically updated to reflect the committed changes.

Thanks for committing this @wraitii!