vassalengine / vassal

VASSAL, the open-source boardgame engine
https://vassalengine.org
GNU Lesser General Public License v2.1
433 stars 105 forks source link

Undoing a Detach (Deselect trait) can cause a piece to be assigned to a null map #13518

Open riverwanderer opened 3 months ago

riverwanderer commented 3 months ago

This problem occurs when the "Remove piece from stack" feature is used, as in the following example:

image

When this operation is actioned, a subsequent undo can cause a piece in the stack to disappear. Further undos may restore the missing piece but it is possible to lose the piece entirely. A inventory of pieces shows that missing piece is assigned to a null map, as in this observation made with the CCN v5 development module:

image

Previous work was done to make the Deselect trait more robust but this seems to be a residual bug. It may be associated with nature of the Deselect trait, which is primarly operating a local feature (piece selection) but detaching from a stack is a shared (ie loggable) feature.

Example case to follow.

riverwanderer commented 3 months ago

Resistant to a straightforward demo. I've produced a log that shows the problem with this CCN module.

detundofail.zip

The steps taken in this demo are:- 1) Order Leader on the combined Leader / Unit stack. The order process does Mark Moved on the Leader piece and a GKC from the Leader causes the Unit piece to detach. 2) Undo - this seems to work 3) Repeat 1 twice - effectively, order / un-order 4) Undo x 2 - the problem occurs. 5) Undo x 2 again - the other piece disappears.