I'm back and working my way through a lot of mails ...
Am Saturday 28 August 2010 13:48:37 schrieb Jacob Nevins:
> So we have a new savegame format (savegame2.c) for 2.3.x, courtesy of
> patch #1541 et al. I'd like to confirm my understanding of the
> implications for maintaining the code in future.
> As I understand it, we'll continue to load old and new savegames, but
> will only ever save new-format games; while we do still have code to
> save old-format games, that's only for the purpose of debugging the new
> format, and not accessible in regular builds, and will presumably go
> away at some point.
Yes, I did try to rewrite the old savegame.c file and ended up restructuring
the entire file and also the format of the save file. As you say, the old
file is keep to load old savegames and to debug the new format (doing a
conversion NEW => OLD => NEW and compare the results; at the moment they
should be identical but there are some differences for the ownership of
The format of the save file is determined by the setting 'saveversion'. For
debug builds, a value of '-1' creates an old format savefile. savegame2.c
includes functions to define different versions of the save file format. I
have a patch which refines the handling of these compatibility part. The main
functions in the file should only concider the current format. Updating an
old format save file to the current one or downgrading a current one to an
old format should be done by the compatibility functions.
> So, if I'm adding a new feature (such as new unit properties) which
> touches the savegame, I assume I only have to support both saving and
> loading it in savegame2.c, and can leave savegame.c alone (but must of
> course ensure that the new properties are initialised properly when an
> old savegame is loaded, for instance by defaults when creating a unit).
> Is that right?
Yes. If possible, the default values should support the test format test NEW
=> OLD => NEW.
> Also, I think this means there is code in savegame2.c that was copied
> from savegame.c which can actually be removed, as it's for backward
> compatibility with old savefiles, which will always be in the old
> format. (For instance, sg_load_player_unit(), S_OLD_FORTRESS etc.) If
> that's confirmed, I'll submit a patch.
I did remove as much old code as possible. If you find a code block which is
not needed please remove it. S_OLD_FORTRESS and S_OLD_AIRBASE are still
included as they are part of the enum tile_special_type and I did not want to
change the order of the enum.
Freeciv-dev mailing list