Page MenuHomeWildfire Games

Remove lastFormationTemplate from UnitAI
ClosedPublic

Authored by temple on Jan 25 2018, 1:50 AM.

Details

Summary

In rP9385 this.lastFormationTemplate was added to UnitAI so that if units all had the same previous formation template then their new formation could also use that template. However, if instead the units are removed from their old formation after this check, then there's no need to store that information.

Test Plan

See that everything works (or not works) as before.
There's more fixes to do, but let's save them for later patches.

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

temple created this revision.Jan 25 2018, 1:50 AM
bb added a comment.Feb 7 2018, 9:41 PM

The catch with removing stuff is seeing is if there is any regression on the current state, and if so, whether that is important. We nuke the storage of the last formation template, but instead always return the current one (seeing a single unit as a formation in "null" formation), so actually with this we do not store "old" data anymore but always return the current state, which seems the way to go.

binaries/data/mods/public/simulation/helpers/Commands.js
1451 ↗(On Diff #5482)

ideally "special/formations/null" would be hidden under some global

1497–1503 ↗(On Diff #5482)

do notice this is using different variables for the ents list (they might or might not be the same, no idea), It would absolutely be save to pass formedEnts, instead of cluster below in RemoveFromFormation

1513 ↗(On Diff #5482)

unneeded braces

temple added inline comments.Feb 8 2018, 10:55 PM
binaries/data/mods/public/simulation/helpers/Commands.js
1497–1503 ↗(On Diff #5482)

I don't understand what you're saying.

bb added inline comments.Feb 8 2018, 11:53 PM
binaries/data/mods/public/simulation/helpers/Commands.js
1497–1503 ↗(On Diff #5482)

The lines above are with this patch merged in the RemoveFromFormation call below, however the code flow is slightly different: currently we remove the entities directly here, in the proposed code the entities are first splitted into some cluster which are then removed from the formation. This could leave the same result (I didn't dig deep into that code), so I was mostly saying that one needs to be careful with rewriting this (most probable the changes are right though).

bb accepted this revision.Feb 16 2018, 10:47 PM
This revision is now accepted and ready to land.Feb 16 2018, 10:47 PM
This revision was automatically updated to reflect the committed changes.