Hi Mark,
I have been discussing the problem with Claudio and the issue is quite complex.
In a nutshell, The information defining a piece is split into two parts, the Type and the State.
The Type information consists of all the stuff that does not change during a game. For a Text Label, this is stuff like the font details, the offset and the command name and key. For a Layer trait it is the List of Layers and the various commands.
The State information consists of the stuff that changes during a game. For a Text Label it is the text of the label. For a Layer it is the Activation status and the Activated layer number.
The Refresher works by taking a piece, finding it’s matching Piece Slot from the GamePieceId and then creating a completely new piece from that definition with the new Type and with all traits reset to their default State (i.e. Labels will default to the text in Piece Slot, Layers will reset to the Piece Slot setting).
Stage 2 of the Refresh is to then try and copy the State information from each old trait to the ‘corresponding’ trait in the new definition. This is where we run into problems. How do you tell if an old trait even has a corresponding version in the new unit, let alone which it is?
The method the refresher uses currently is for each trait in the new piece, look for a trait in the old piece that has EXACTLY the same Type information. If one is found, then copy the State information from it. If not, then the new trait will have the default State from the Piece Slot.
The upshot of this is that for any trait that has some changeable State, and you change something (anything) in the Type, then the comparison fails and the State does not get copied across, causing that unit to ‘reset’.
The long-term solution is allocate each trait within a GamePiece in a Piece Slot a ‘Trait Id’ that is unique within the GamePiece and that can be used by the Refresher to determine exactly which trait in the new piece corresponds to a trait in the old piece. This is a fairly major piece of work which will probably not happen before version 3.6 and will only be of use for save games created with that version or later.
I think the short-term solution is to modify the Refresher to have the option to use less than the full Type information to match up the traits. For example, for the text Label trait, a match on the ‘Description’ field should be sufficient. For the Layer trait, a match on the ‘Name’ field would be sufficient.
If you have changed the Name/Description field, there is nothing much we can do.
Thoughts?