Shannon V. OKeets
From: Honolulu, Hawaii
[..] Stacking applies at the end of each step and after each retreat and advance after combat. You cannot voluntarily overstack then [..]
Why not let the player do what he wants during the step. When end of step is pressed, or at the relevant points during the combat forms, do the stacking limit check. In case of overstacked hexes, indicate them in a popup and let the user correct the situation by movement. You would need an indicator for incorrectable constellations, something like: sum( stacking(hex) for hex in adjacent ) >= sum( stacking_max(hex) for hex in adjacent )
You only have to check hexes occupied by units. Actually only hexes occupied by units that have seen action this step. So that it will roughly scale with the average activity limits or the occupied hexes in the worst case.
The workaround using an adjacent hex not at capacity has the flaw that you would have to calculate the movement cost using path the unit would have taken for the swap, the shortest path (if not using explicate movement). Else some units may not be able to make it in bad weather and/or terrain.
Also by RAW 11.11.1 a unit can only move once in each land movement step, but that could be relaxed for usability sake here.
The solution that is partially coded is much simpler. It will let a player overstack land units in a hex during land movement, but then force the player to move a unit out of the overstacked hex to fix overstacking, before he does anything else. If he has no more land moves available, then his only recourse will be to Undo his original move.
Even the smallest opening in permitting overstacking might enable the player to 'game' the system and do something illegal (i.e., not according to the rules).
Perfection is an elusive goal.