<URL: http://bugs.freeciv.org/Ticket/Display.html?id=39959 >
Not sure how you could get the idea this was caused by the rulesets... The bug is simple; compress_level (and in the development version, compress_type) are not saved in the savegame. Attached are some quick patches to fix it. This should get a bit of review; care must be taken on load since the available compression types may not be the same as when the game was saved. The compress_type is saved as an integer meaning the enumeration order gets linked to the savegame format. Alternately this could be saved as a string I suppose. In 2.1 the compress_type is explicitly saved as zlib (1) so such games loaded in 2.2 will continue to use zlib compression rather than switching mid-game. -jason
Index: utility/ioz.h =================================================================== --- utility/ioz.h (revision 14152) +++ utility/ioz.h (working copy) @@ -27,6 +27,7 @@ typedef struct fz_FILE_s fz_FILE; /* (possibly) supported methods (depending on config.h) */ +/* Do not reorder these or compatibility will be broken. */ enum fz_method { FZ_PLAIN = 0, FZ_ZLIB = 1, FZ_BZIP2 = 2, FZ_LAST }; #define FZ_NOT_USED FZ_LAST Index: server/settings.c =================================================================== --- server/settings.c (revision 14152) +++ server/settings.c (working copy) @@ -197,25 +197,7 @@ /************************************************************************/ -#if defined(HAVE_LIBBZ2) -#define GAME_MIN_COMPRESS_TYPE FZ_PLAIN -#define GAME_MAX_COMPRESS_TYPE FZ_BZIP2 -#define GAME_DEFAULT_COMPRESS_TYPE FZ_BZIP2 -#elif defined(HAVE_LIBZ) -#define GAME_MIN_COMPRESS_TYPE FZ_PLAIN -#define GAME_MAX_COMPRESS_TYPE FZ_ZLIB -#define GAME_DEFAULT_COMPRESS_TYPE FZ_ZLIB - -#else -#define GAME_MIN_COMPRESS_TYPE FZ_PLAIN -#define GAME_MAX_COMPRESS_TYPE FZ_PLAIN -#define GAME_DEFAULT_COMPRESS_TYPE FZ_PLAIN - -#endif - -/************************************************************************/ - #define GEN_BOOL(name, value, sclass, scateg, slevel, to_client, \ short_help, extra_help, func, _default) \ {name, sclass, to_client, short_help, extra_help, SSET_BOOL, \ Index: server/savegame.c =================================================================== --- server/savegame.c (revision 14152) +++ server/savegame.c (working copy) @@ -3720,6 +3720,26 @@ game.info.diplomacy = secfile_lookup_int_default(file, GAME_DEFAULT_DIPLOMACY, "game.diplomacy"); + game.info.save_compress_level + = secfile_lookup_int_default(file, GAME_DEFAULT_COMPRESS_LEVEL, + "game.compress_level"); + game.info.save_compress_type + = secfile_lookup_int_default(file, GAME_DEFAULT_COMPRESS_TYPE, + "game.compress_type"); +#ifndef HAVE_LIBBZ2 + if (game.info.save_compress_type == FZ_BZIP2) { + game.info.save_compress_type = GAME_DEFAULT_COMPRESS_TYPE; + } +#endif +#ifndef HAVE_LIBZ + if (game.info.save_compress_type == FZ_ZLIB) { + game.info.save_compress_type = GAME_DEFAULT_COMPRESS_TYPE; + } +#endif + if (game.info.save_compress_type == FZ_PLAIN) { + game.info.save_compress_level = 0; + } + sz_strlcpy(game.save_name, secfile_lookup_str_default(file, GAME_DEFAULT_SAVE_NAME, "game.save_name")); @@ -4329,6 +4349,9 @@ /* Write civstyle for compatibility with old servers */ secfile_insert_int(file, 2, "game.civstyle"); secfile_insert_int(file, game.info.save_nturns, "game.save_nturns"); + secfile_insert_int(file, + game.info.save_compress_level, "game.compress_level"); + secfile_insert_int(file, game.info.save_compress_type, "game.compress_type"); secfile_insert_str(file, game.save_name, "game.save_name"); secfile_insert_int(file, game.info.aifill, "game.aifill"); secfile_insert_bool(file, game.scorelog, "game.scorelog"); Index: common/game.h =================================================================== --- common/game.h (revision 14152) +++ common/game.h (working copy) @@ -346,6 +346,24 @@ #define GAME_MIN_COMPRESS_LEVEL 1 #define GAME_MAX_COMPRESS_LEVEL 9 +#if defined(HAVE_LIBBZ2) +#define GAME_MIN_COMPRESS_TYPE FZ_PLAIN +#define GAME_MAX_COMPRESS_TYPE FZ_BZIP2 +#define GAME_DEFAULT_COMPRESS_TYPE FZ_BZIP2 + +#elif defined(HAVE_LIBZ) +#define GAME_MIN_COMPRESS_TYPE FZ_PLAIN +#define GAME_MAX_COMPRESS_TYPE FZ_ZLIB +#define GAME_DEFAULT_COMPRESS_TYPE FZ_ZLIB + +#else +#define GAME_MIN_COMPRESS_TYPE FZ_PLAIN +#define GAME_MAX_COMPRESS_TYPE FZ_PLAIN +#define GAME_DEFAULT_COMPRESS_TYPE FZ_PLAIN + +#endif + + #define GAME_DEFAULT_ALLOWED_CITY_NAMES 1 #define GAME_MIN_ALLOWED_CITY_NAMES 0 #define GAME_MAX_ALLOWED_CITY_NAMES 3
Index: server/savegame.c =================================================================== --- server/savegame.c (revision 14152) +++ server/savegame.c (working copy) @@ -3731,6 +3731,13 @@ game.info.diplomacy = secfile_lookup_int_default(file, GAME_DEFAULT_DIPLOMACY, "game.diplomacy"); + /* Save options. */ + game.info.save_compress_level + = secfile_lookup_int_default(file, GAME_DEFAULT_COMPRESS_LEVEL, + "game.compress_level"); +#ifndef HAVE_LIBZ + game.info.save_compress_level = GAME_NO_COMPRESS_LEVEL; +#endif sz_strlcpy(game.save_name, secfile_lookup_str_default(file, GAME_DEFAULT_SAVE_NAME, "game.save_name")); @@ -4339,6 +4346,9 @@ /* Write civstyle for compatibility with old servers */ secfile_insert_int(file, 2, "game.civstyle"); secfile_insert_int(file, game.info.save_nturns, "game.save_nturns"); + secfile_insert_int(file, + game.info.save_compress_level, "game.compress_level"); + secfile_insert_int(file, 1, "game.compress_type"); /* use zlib for 2.2 */ secfile_insert_str(file, game.save_name, "game.save_name"); secfile_insert_int(file, game.info.aifill, "game.aifill"); secfile_insert_bool(file, game.scorelog, "game.scorelog");
_______________________________________________ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev