Page MenuHomeWildfire Games

Do not compute capture points for the invalid player on player defeat
ClosedPublic

Authored by wraitii on May 18 2020, 8:19 PM.

Details

Summary

As revealed by investigating #5745 .

When a player is defeated, the last entity it owned might also be Capturable. In that case, we are currently doing twice the work of re-calculating their capture points.

This used to bug in A23 (see #5745), it no longer does, however the optimisation seems harmless.

Test Plan

Check that things work as expected

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.May 18 2020, 8:19 PM

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/Capturable.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/Capturable.js
|  20|  20| 	this.cp = [];
|  21|  21| };
|  22|  22| 
|  23|    |-//// Interface functions ////
|    |  23|+// // Interface functions ////
|  24|  24| 
|  25|  25| /**
|  26|  26|  * Returns the current capture points array
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/Capturable.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/Capturable.js
| 147| 147| 	return sourceEnemyCp > 0;
| 148| 148| };
| 149| 149| 
| 150|    |-//// Private functions ////
|    | 150|+// // Private functions ////
| 151| 151| 
| 152| 152| /**
| 153| 153|  * This has to be called whenever the capture points are changed.
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/Capturable.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/Capturable.js
| 294| 294| 		this.CheckTimer();
| 295| 295| };
| 296| 296| 
| 297|    |-//// Message Listeners ////
|    | 297|+// // Message Listeners ////
| 298| 298| 
| 299| 299| Capturable.prototype.OnValueModification = function(msg)
| 300| 300| {
Executing section cli...

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

Freagarach accepted this revision.May 21 2020, 1:56 PM
Freagarach added a subscriber: Freagarach.

We don't really care about the CP of dead entities anyway (see L323). (Code introduced in rP21685.)
What is changed now is that there is no message sent that capture points have changed.

This revision is now accepted and ready to land.May 21 2020, 1:56 PM