Help! Fixing save files with bad PieceIds

There is a problem using Refresh Counters with version 4.1 of the Commands & Colors Ancients module, which @g1ul10 mentioned to me. So I thought I’d take a look at it.

What happens is that some pieces (typically terrain) get replaced with other pieces when Refresh Counters is used. It doesn’t matter what settings are used for Refresh Counters. The replacement pieces are various cards; at least, in the scenarios that I tested.

I suspected from what Giulio described and my own tests that these particular cards in the buildfile are using the same PieceIds as the pieces that they replace in the save files.

My first action was to edit the build file, renumbering all the cards in question, starting from the next available PieceID slot. Sure enough, Refresh Counters now does not replace the terrain etc pieces.

However, the Refresh Counters action now replaced some of the cards with other cards that bare the same name (a variant of the game). My workaround to this was to temporarily re-name those other cards, do another Refresh Counters (that worked) and finally rename them back and Refresh Counters one last time.

I seem to have improved the situation, in that Refresh is now possible but I am left with one flaw. After renaming cards back, when the Refresh option to identify counters by name is used, the Refresh will still replace cards (unlike before, it will not replace them if this option is not clicked).I am wondering what I can do about this last hurdle. I have other modules with identically named pieces that do not get mixed up by a Refresh Counters, but what might I be missing?

Hoping that @Brent_Easton or @CloClooo might be able to shed some light.

Distilling this down to one question… does Refresh Counters adjust PieceIds in the Preset scenario file that it processes to bring them into line with the buildfile ?

No, Refresh Counters never makes changes to Piece Id’s.

For each counter in the current game, it finds the matching piece slot in the current module with the same Piece Id and refreshes the counter in the current game with the version that it finds in the module.

If you are just using the Vassal editor to update your module, then you will normally not have a problem with piece Id’s unless you delete a piece slot from the module that is being used in a save game somewhere. When you try and refresh that game, the piece Id in the save game can no longer be found in the module, so that piece cannot be refreshed unless you use the match by name option. The Vassal editor keeps track of the current highest piece Id and all new pieces are given a new unique Id…

Where you run into bigger problems is if you edit the buildfile directly and add, remove or change piece slots and are not very, very careful about maintaining piece Id uniqueness. If you edit in a new piece definition by copying another piece definition, you will create a 2 definitions with the same piece Id. When Vassal loads a module, it has to resolve duplicate piece Id’s and it does this by re-numbering the second definition it finds (Not the second one that was created).

At this point, Your old save games are now toast (wrt the refresher), they include pieces with piece Id’s that now belong to completely unrelated pieces.

1 Like