3 ms·
> Though in Factorio's case it's implemented with a lot of `if(saveVersion >= 0.17.123) xyz = stream.readInt32()` and compatibility gets dropped every few versi
by UncleEntity 3y ago
> Though in Factorio's case it's implemented with a lot of `if(saveVersion >= 0.17.123) xyz = stream.readInt32()` and compatibility gets dropped every few versions.
Blender does pretty much this other than dropping compatibility.
If a new feature adds another struct member you also need the ability to read an old file into the new struct. Usually (IIRC) you would just add a line or two to the function which deals with this stuff and set your new field to a sane default -- assuming everything is compatible because all changes aren't, trying to load something like the Big Buck Bunny models into a new version isn't going to work as planned.
The easiest way I found to add something new was to take over some padding bytes (there's a bunch) so the struct has the exact same memory size and the older versions just ignore those.