If there is cargo in a stack then the iteration through unmoved units will get stuck on that stack. If the cargo is removed the iteration will proceed.
The code seems substandard, debugging/re-factoring may be a waste of time. Perhaps a rewrite from scratch is in order, this is a critical feature and just one method.
The next unmoved unit procedure could be the following:
sub a: Check if there are unmoved units left. If not, display "no unmoved units" and exit.
do sub a
Remove currently selected units from list of unmoved units.
do sub a
Select next unmoved unit(s) (*)
Center display on stack.
(*) What this means exactly, eg. whole stack or something else, is open for debate. For now, we'll settle with selecting all units in the stack with the next unmoved unit.
If there is cargo in a stack then the iteration through unmoved units will get stuck on that stack. If the cargo is removed the iteration will proceed.
The code seems substandard, debugging/re-factoring may be a waste of time. Perhaps a rewrite from scratch is in order, this is a critical feature and just one method.
The next unmoved unit procedure could be the following:
sub a: Check if there are unmoved units left. If not, display "no unmoved units" and exit.
(*) What this means exactly, eg. whole stack or something else, is open for debate. For now, we'll settle with selecting all units in the stack with the next unmoved unit.