Can I just push to this branch or should I use a new one? I did not change the semnatics but rather replace the sorting by stable_sort or partial_sort (which returns the k smallest elements but is unstable)
However, I am not sure whether an unstable sorting algorithm can cause desyncts, since the implementation may change the result. Doing a source code search it seems that Widelands uses both, std::sort and std::stable_sort. At the moment we need the SoldierPriority structure to distribute the attacking soldiers evenly over all military sites (in case of equal abilities) I think the most elegant solution would be to enforce the soldiers being sorted by ability in the militarysite itself and allow a soldier to query its position. This would allow to sort Soldiers instead of SoldierPriority and would solve all kinds of sorting problems: - find soldiers for attacking/defending/healing (default: strongest) - drop least suited soldier for upgrading (default: weakest) - kicking out any soldier (by the player or for replacement/training) And at least the above operations does not destroy the sorting. Only new arriving soldiers would need to be inserted. Possible replacements for std::vector<Soldier>: - std::deque However, this would requiere a larger modification of the source code and needs more discussing. -- https://code.launchpad.net/~widelands-dev/widelands/find_attack_soldiers/+merge/245276 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/find_attack_soldiers. _______________________________________________ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp