Page MenuHomeWildfire Games

Make g_EntityCommands use all entities but not only the first
ClosedPublic

Authored by Imarok on Jan 6 2017, 6:32 PM.

Details

Summary

Currently the code for the Command selection panel loops through every selected item, to check if it can perform a command.
With the patch it checks it for the whole selection at once.
Therefore performCommand now gets the whole selection as parameter and not just the first element, too.

Test Plan
  • Check that everything works as before
  • As observer select a cc from a player with mutual allies and one from a player without mutual allies: the shared-dropsite button should exist independent of selection order.

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

Imarok updated this revision to Diff 148.Jan 6 2017, 6:32 PM
Imarok retitled this revision from to Make g_EntityCommands use all entities but not only the first.
Imarok updated this object.
Imarok edited the test plan for this revision. (Show Details)
Imarok updated the Trac tickets for this revision.
Owners added a subscriber: Restricted Owners Package.Jan 6 2017, 6:32 PM
Vulcan added a subscriber: Vulcan.Jan 6 2017, 8:23 PM

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running debug tests...
Running cxxtest tests (302 tests)..............................................................................................................................................................................................................................................................................................................OK!

http://jw:8080/job/phabricator/105/ for more details.

Itms requested changes to this revision.Jan 26 2017, 12:08 AM
Itms added a subscriber: elexis.

I like the patch but we should highlight the remaining uses of [0] with a comment, ideally we should have an idea of what we want to do with them eventually.

binaries/data/mods/public/gui/session/input.js
1503 ↗(On Diff #148)

Since we are more and more considering all entities all over the code, it would be nice to add comments when we still consider only the first one (explaining why it makes sense here, or adding a TODO with improvement ideas).

binaries/data/mods/public/gui/session/unit_actions.js
1074 ↗(On Diff #148)

Isn't there a better way to remove dupes? Asking the fat arrow master @elexis ^^

1187 ↗(On Diff #148)

A very nice thing to do would be cycling between the rally points in this situation but this might be out of the scope of the patch. Add a comment/TODO at least.

1299 ↗(On Diff #148)

Same comment as above, although here we might want to check that all selected entities belong to the same player, what do you think?

This revision now requires changes to proceed.Jan 26 2017, 12:08 AM
Itms awarded a token.Jan 26 2017, 12:08 AM
Imarok added inline comments.Jan 30 2017, 5:58 PM
binaries/data/mods/public/gui/session/unit_actions.js
1074 ↗(On Diff #148)

In what way could there be a better arrow function for removing dupes?
(The dupe removal used here is just entStates.filter( (item, index, self) => self.indexOf(item) == index ))

Imarok marked 3 inline comments as done.Jan 30 2017, 7:07 PM
Imarok added inline comments.
binaries/data/mods/public/gui/session/unit_actions.js
1299 ↗(On Diff #148)

You discovered a bug ?
As observer select a cc from a player with mutual allies and one from a player without mutual allies: the existence of the shared-dropsite button will depend on selection order.

Imarok updated this revision to Diff 401.Jan 30 2017, 7:08 PM
Imarok edited edge metadata.
Imarok marked an inline comment as done.

Fix/Comment the uses of [0]

Imarok changed the visibility from "All Users" to "Public (No Login Required)".Jan 30 2017, 7:50 PM

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running debug tests...
Running cxxtest tests (302 tests)..............................................................................................................................................................................................................................................................................................................OK!

http://jw:8080/job/phabricator/280/ for more details.

Imarok edited the test plan for this revision. (Show Details)Feb 25 2017, 5:26 PM
bb requested changes to this revision.Apr 3 2017, 5:36 PM
bb added a subscriber: bb.

some hunk got outdated, so didn't test if everything works.

binaries/data/mods/public/gui/session/unit_actions.js
1042 ↗(On Diff #401)

check added looks correct

1051 ↗(On Diff #401)

argument needed?

1059 ↗(On Diff #401)

good, since better performance than .every => isUndel(entstate)

1090 ↗(On Diff #401)

Better indeed than g_selection

1134 ↗(On Diff #401)

Shouldn't we use an entState.filter(entState => !entState.unitAI || !entState.turretParent) since we check sorta twice for the turretParent here (few lines down)?.

1139 ↗(On Diff #401)

does that 3rd check make sense? as the entity already has this as turrentParent.

1188 ↗(On Diff #401)

Should be entState = entStates.filter(entState => entState.rallyPoint && entState.rallyPoint.position)[0] || entStates.filter(entState => entState.position)[0] . And then also check if entState exists.

I don't think this can be merged with the focusTarget assignment, because of empty lists

1301 ↗(On Diff #401)

Players aren't allowed to have entity's selected of different players right? So I guess checking for 1 ent is enough.

This revision now requires changes to proceed.Apr 3 2017, 5:36 PM
Imarok updated this revision to Diff 1642.May 4 2017, 12:56 PM
Imarok edited edge metadata.

Rebase

Imarok marked 3 inline comments as done.May 4 2017, 1:36 PM
Imarok added inline comments.
binaries/data/mods/public/gui/session/unit_actions.js
1139 ↗(On Diff #401)

I don't know, so I don't change that ;)

1301 ↗(On Diff #401)

This may be changed in future

Imarok updated this revision to Diff 1645.May 4 2017, 1:36 PM

Apply remarks

Vulcan added a comment.May 4 2017, 9:21 PM

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!

http://jw:8080/job/phabricator/1000/ for more details.

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!

http://jw:8080/job/phabricator/1003/ for more details.

bb added inline comments.May 5 2017, 5:33 PM
binaries/data/mods/public/gui/session/unit_actions.js
1152 ↗(On Diff #1645)

Probably in another cleanup patch, this function (and his brothers) should be inlined here, using the entStates parameter...

1311 ↗(On Diff #1645)

GetSimState().players can be moved out of the function and stored under a variable.

Imarok added inline comments.May 5 2017, 6:57 PM
binaries/data/mods/public/gui/session/unit_actions.js
1152 ↗(On Diff #1645)

Yep

1311 ↗(On Diff #1645)

For which benefit?
(It's only used once)

bb added inline comments.May 5 2017, 7:09 PM
binaries/data/mods/public/gui/session/unit_actions.js
1311 ↗(On Diff #1645)

won't it help performance a bit? or is the interpreter smart enough to store it self?

Imarok added inline comments.May 5 2017, 9:01 PM
binaries/data/mods/public/gui/session/unit_actions.js
1311 ↗(On Diff #1645)

It should, and if not it won't bring us that much performance improvement...

bb accepted this revision.May 5 2017, 10:00 PM
bb added inline comments.
binaries/data/mods/public/gui/session/unit_actions.js
1311 ↗(On Diff #1645)

That assuming => accepting

This revision was automatically updated to reflect the committed changes.