Currently Online

Latest Posts

Topic: Soldier sorting in the Attack dialog box

SandJ
Avatar
Topic Opener
Joined: 2015-05-08, 22:46
Posts: 11
OS: Linux
Ranking
Pry about Widelands
Posted at: 2024-11-29, 22:36

When attacking a site, the dialog box where you select who is attacking and who is not, has me wondering. How are the soldiers sorted?

It is not by any of the attributes (Health, Attack, Defence, Evade) since heroes and rookies are all mixed up. It does not appear to be by distance from the target, I think. It does not take into account whether soldiers are still healing.

And what makes we really curious is the way the list of soldiers re-arranges as you move one from one section to the other. It makes the list shuffle again. So it cannot be an internal ID number for each soldier.

How are they arranged?

(And I will have follow-up comments such as "It would be nice if we could sort them by distance / skill / injured.")


Top Quote
mxb2001
Avatar
Joined: 2019-05-20, 18:49
Posts: 282
OS: Linux
Version: 1.2
Ranking
Tribe Member
Location: The land of the thirsty spider
Posted at: 2024-11-30, 01:00

I think it is by order of arrival in the forts. Not a clue how it sorts the forts if there is >1. What I've seen is that returning soldiers line up at the end of the queue. I think...


--
To Boldly Go Where No Man Has Gone Before

Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 18:07
Posts: 2051
OS: Debian Testing
Version: Latest master
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2024-12-01, 17:00

The soldiers are sorted by air distance to the attack target. Equally distant soldiers are always in arbitrary order, although they usually end up grouped by building and soldiers within a building typically in order of arrival.

Note that air distance does not account for obstacles so it may not accurately reflect actual walking distance. This is an optimization for performance.
Healing and skill are not currently taken into account. +1 for more sorting options.

This is the code where the sorting takes place:
https://codeberg.org/wl/widelands/src/commit/73c82e1e1a93c13677578b29cc9ecd4d7d12a239/src/wui/attack_window.cc#L702-L722


Top Quote
kaputtnik
Avatar
Joined: 2013-02-18, 20:48
Posts: 2542
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: 2024-12-01, 17:12

Do the slight background colors of the soldiers show this? I wonder what the coloring shows...


Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 18:07
Posts: 2051
OS: Debian Testing
Version: Latest master
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2024-12-01, 18:09

Yes, the background tints indicate soldiers who are in the same building, or on the same warship.

https://codeberg.org/wl/widelands/src/commit/73c82e1e1a93c13677578b29cc9ecd4d7d12a239/src/wui/attack_window.cc#L46-L64


Top Quote
mxb2001
Avatar
Joined: 2019-05-20, 18:49
Posts: 282
OS: Linux
Version: 1.2
Ranking
Tribe Member
Location: The land of the thirsty spider
Posted at: 2024-12-01, 18:17

I usually send fully healed best trained soldiers (I imagine that's the usual) so options to sort by training/healing would be nice. It's not a big deal though, scanning through them for the ones you want is not exactly the most tedious chore... On the other hand I recall doing it too quickly and misclicking. Although that might be my poor hand eye co-ordination (which is why I play strategy/thinking games and eschew arcade games!).


--
To Boldly Go Where No Man Has Gone Before

Top Quote