vassalengine/vassal

GKC can be sent to same Game Piece twice if it moves.

Closed this issue · 0 comments

https://forum.vassalengine.org/t/possible-vassal-bug-causing-extra-gkc-execution-after-send-to-zone-location/79821/7

OK.

Very interesting, I have got to the root of the problem and it is indeed a subtle Vassal GKC bug.

Firstly, your cut-down module and repro instructions where OUTSTANDING and made it very easy for me to track down the issue.

One technique I often use in these cases is to Add menu items to all the counters for all the individual Trigger steps so I can can fire them off manually one-by-one to help isolate the problem.

With this, while running Vassal under the debugger, I was able to find the GKC to the 7th HQ is being sent just once, but it indeed being received twice by the counter.

The bug is caused by the fact that the first thing Vassal does it collect up all the pieces it needs to act on, based on after applying any Fast-matches. (No Fast Match in this case). It then runs through and applies the GKC to each piece.

However, the list of pieces to be run through is a list of STACKS of counters, not the individual counters. And when the 7th Headquarters is given the the GKC, it jumps forward one space and stacks with the Cherbourg HQ piece. The GKC processing then moves on to the next Stack in the list, which is the Cherbourg piece’s stack, but that Stack now has the 7th piece in it as well. BOOM, the GJC gets re-applied to the 7th HQ.

This explains why removing the Send to Location or changing the pieces to Do Not Stack fixes the problem, It prevents the 7th HQ from changing Stacks during the running of the GKC. It also depends on what order the Stacks happen to be stored in with Vassal.

This bug will potentially raise it’s head whenever a Stacking piece is moved during the execution of a GKC and depends on the exact layout of pieces on the board and the exact order they are stored within Vassal, so will be intermittent and unpredictable.

I am hesitant to hack into the GKC code too viciously, the simple fix is to maintain a list of all pieces that have already received the GKC skip any that appear for a second time.

Thanks for the report!