Page MenuHomeWildfire Games

Cleanup of create corpse in Health.js.
ClosedPublic

Authored by Freagarach on Mar 18 2020, 9:51 AM.

Details

Summary

As is now, there need to be two checks for an entity to leave resources, namely deathType == "remain" and cmpResourceSupply. This patch changed that so that all entities get corpses, but only entities that have a resource supply and killbeforegather == true will drop as resources.
This means that remain will actually do as it states. The entity remains with 0 health.

Test Plan

Verify that:

  • Entities with resources such as huntables will behave the same.

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.Mar 18 2020, 9:51 AM
Owners added a subscriber: Restricted Owners Package.Mar 18 2020, 9:51 AM

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

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/1349/display/redirect

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

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

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

Link to build: https://jenkins.wildfiregames.com/job/macos-differential/445/display/redirect

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

Linter detected issues:
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (semi):
|    | Missing semicolon.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/Health.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/Health.js
| 433| 433| 
| 434| 434| 	if (this.regenRate != oldRegenRate || this.idleRegenRate != oldIdleRegenRate)
| 435| 435| 		this.CheckRegenTimer();
| 436|    |-}
|    | 436|+};
| 437| 437| 
| 438| 438| Health.prototype.OnValueModification = function(msg)
| 439| 439| {
|    | [NORMAL] ESLintBear (semi):
|    | Missing semicolon.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/Health.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/Health.js
| 445| 445| {
| 446| 446| 	if (msg.to != INVALID_PLAYER)
| 447| 447| 		this.RecalculateValues();
| 448|    |-}
|    | 448|+};
| 449| 449| 
| 450| 450| Health.prototype.RegisterHealthChanged = function(from)
| 451| 451| {

binaries/data/mods/public/simulation/components/Health.js
| 436| }
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

binaries/data/mods/public/simulation/components/Health.js
| 448| }
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.
Executing section cli...

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

bb accepted this revision as: bb.Apr 25 2020, 6:16 PM
bb removed a reviewer: Restricted Owners Package.
bb added a subscriber: bb.

Front doesn't fall. Adding a unit with remain keyword appears working. Some trivialities left for commit

grep says all remain keywords are removed now. Any use case for this?

binaries/data/mods/public/simulation/components/Health.js
319 ↗(On Diff #11501)

inlinable

349 ↗(On Diff #11501)

trailing .0

353–356 ↗(On Diff #11501)

Usually when renaming an entity, the old entity will be destroyed. However, in principle, this doesn't have to be the case. Given this I think having this call here is correct, it allows for the case that we create a corps, but keep the old entity running too.

This revision is now accepted and ready to land.Apr 25 2020, 6:16 PM

Thanks for the review and commit @bb!

In D2656#114065, @bb wrote:

grep says all remain keywords are removed now. Any use case for this?

Not really, although I do remember an AoE II campaign where some hero died but remained visually to encourage his troops.
My main point was not adding functionality, but to make the functions/keywords do as they say.