rfg-modding / Nanoforge

A modding tool for Red Faction Guerilla Re-Mars-Tered
MIT License
31 stars 3 forks source link

Support adding new fields to serialized classes #133

Closed Moneyl closed 1 year ago

Moneyl commented 1 year ago

If you serialize a class, add a new field, then recompile and deserialize it'll crash. Possibly something to do with how bon handles unknown fields. Need to see if this can be changed with a bon attribute or if the library needs changes.

For now, it should just ignore new fields and leave them as their default value. This way new fields can be added and old data can be loaded without issues.

Eventually we might want more complex handling for this so we can handle fields getting added/removed or having their names changed. Will depend on how often that happens.

Moneyl commented 1 year ago

[BonKeepUnlessSet] and [BonKeepMembersUnlessSet] can be used to handle this. I don't like that you have to manually mark them for this to work. It should just be the default behavior to ignore new fields. But's good enough for now.