38 "Irrigation",
"Mine",
"Pollution",
"Hut",
"Farmland",
87#ifdef FREECIV_DEV_SAVE_COMPAT
138#define compat_current (compat_num - 1)
161 log_error(
"Savegame version newer than this build found (%d > %d). "
162 "Trying to load the game nevertheless ...",
loading->version,
168 "Unknown savefile format version (%d).",
loading->version);
174 log_normal(
_(
"Run compatibility function for version: <%d "
181#ifdef FREECIV_DEV_SAVE_COMPAT
209 log_normal(
_(
"Run post load compatibility function for version: <%d "
216#ifdef FREECIV_DEV_SAVE_COMPAT
262 "Unknown hex value: '%c' %d",
ch,
ch);
267 "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-+";
279 "Unknown ascii value for num: '%c' %d",
ch,
ch);
330 if (presource->data.resource->id_old_save == identifier) {
351 log_debug(
"Upgrading data from savegame to version 2.4.0");
369 "player%d.ncities",
plrno);
373 "player%d.c%d.size",
plrno,
i);
423 int xsize = 0,
y,
l, j,
x;
432 for (j = 0; j < 8; j++) {
435 "map.k%02d_%04d",
l * 8 + j,
y);
442 "Inconsistent xsize in map.k%02d_%04d",
444 for (
x = 0;
x < xsize;
x++) {
459 for (
x = 0;
x < xsize;
x++) {
471 for (j = 0; j < 8; j++) {
475 for (
x = 0;
x < xsize;
x++) {
480 "map.k%02d_%04d",
l * 8 + j,
y);
496 "settings.gamestart_valid");
512 const char *
const nosave =
"GAMEOVER|QUITIDLE|INTERRUPT";
513 const char *
const save =
"TURN|GAMEOVER|QUITIDLE|INTERRUPT";
517 "settings.set%d.value",
i)) {
521 "settings.set%d.value",
new_opt);
524 "settings.set%d.value",
i);
527 "settings.set%d.value",
new_opt);
534 "settings.set%d.gamestart",
i)) {
538 "settings.set%d.gamestart",
new_opt);
541 "settings.set%d.gamestart",
i);
544 "settings.set%d.gamestart",
new_opt);
553 log_sg(
"Unexpected \"autosaves\" setting found in pre-2.4 "
554 "savefile. It may have been overridden.");
584 const char *
modname[] = {
"Road",
"Railroad" };
612 log_debug(
"Upgrading data from savegame to version 2.5.0");
618 "savefile.roads_vector");
622 "savefile.activities_vector");
632 "settings.gamestart_valid");
647 "settings.set%d.value",
i)) {
653 "settings.set%d.value",
i);
656 "settings.set%d.value",
i);
664 "settings.set%d.gamestart",
i)) {
670 "settings.set%d.gamestart",
i);
673 "settings.set%d.gamestart",
i);
718 log_debug(
"Upgrading data from savegame to version 2.6.0");
746 "settings.gamestart_valid");
762 "settings.set%d.value",
i)) {
773 "settings.set%d.gamestart",
i)) {
792 "settings.set%d.value",
i)) {
803 "settings.set%d.gamestart",
i)) {
817 "settings.set%d.value",
i)) {
822 "settings.set%d.value",
i);
830 "settings.set%d.gamestart",
i)) {
835 "settings.set%d.gamestart",
i);
846 "settings.set%d.value",
i)) {
850 "settings.set%d.value",
i);
853 "settings.set%d.value",
i);
859 "settings.set%d.gamestart",
i)) {
863 "settings.set%d.gamestart",
i);
866 "settings.set%d.gamestart",
i);
873 &team_pooled_research,
874 "settings.set%d.value",
i),
879 "settings.set%d.value",
i)) {
885 "settings.set%d.gamestart",
i)) {
894 "settings.set%d.value",
i)) {
963 "player%d.capital",
plrno)) {
965 "player%d.got_first_city",
plrno);
971 "player%d.unassigned_user",
plrno);
975 "player%d.unassigned_ranked",
plrno);
979 "player%d.ai.is_barbarian",
plrno);
982 "player%d.ai.barb_type",
plrno);
1004 "player%d.trait.mod%d",
plrno,
i),
1010 "player%d.units_built",
plrno);
1016 "player%d.units_killed",
plrno);
1022 "player%d.units_lost",
plrno);
1036 "player%d.u%d.orders_last_move_safe",
1042 "player%d.u%d.orders_length",
1050 "player%d.u%d.orders_list",
1056 "player%d.u%d.orders_list",
plrno,
i);
1066 "savefile.specialists_size");
1078 "savefile.specialists_vector");
1151 if (team_pooled_research) {
1153 "player%d.team_no",
plrno);
1159 "Research out of bounds (%d)!",
i);
1175 "player%d.research.%s",
1183 "player%d.research.%s",
1191 "player%d.research.%s",
1199 "Research related entry marked as float.");
1218 "savefile.diplstate_type_size");
1227 for (j = 0; j <
DS_LAST; j++) {
1233 "savefile.diplstate_type_vector");
1272 "player%d.name",
plrno);
1274 "player%d.name",
i);
1278 log_sg(
_(
"The save game is wrong about what the closest"
1279 " relationship %s (player %d) and %s (player %d) have had is."
1326 log_debug(
"Upgrading data from savegame to version 3.0.0");
1358 "player%d.flags",
plrno);
1366 for (
i = 0;
i < num;
i++) {
1375 "player%d.ncities",
plrno);
1377 for (
i = 0;
i < num;
i++) {
1389 "settings.set_count");
1393 "game.meta_usermessage")) {
1397 "game.meta_message");
1420 "event_cache.events%d.event",
i);
1439 "savefile.server_side_agent_size");
1448 "savefile.server_side_agent_size");
1463 "savefile.server_side_agent_list");
1487 "player%d.u%d.server_side_agent",
1502 "player%d.u%d.server_side_agent",
1506 "player%d.u%d.server_side_agent",
1525 log_debug(
"Upgrading data from savegame to version 3.1.0");
1548 "player%d.u%d.orders_length",
1552 "player%d.u%d.action_list",
1572 "player%d.u%d.action_vec",
1576 "player%d.u%d.action_vec,%d",
1588 "savefile.action_size");
1594 const char *
dur_name =
"Disband Unit Recover";
1597 "savefile.action_vector");
1610 "savefile.action_vector");
1624 "settings.gamestart_valid");
1637 "settings.set%d.gamesetdef",
i);
1661 switch (
order->activity) {
1692 log_error(
"Activity %d is not supposed to appear in unit orders",
1732 struct tile *current_tile;
1743 for (
i =
act_unit->orders.index;
i > 0 && current_tile !=
NULL;
i--) {
1756 for (
i = 0;
i <
act_unit->orders.length && current_tile !=
NULL;
i++) {
1794 current_tile =
NULL;
1801 if (current_tile ==
NULL) {
1926 log_debug(
"Upgrading data from savegame to version 3.2.0");
1930 "savefile.orig_version");
1937 "savefile.orig_version");
1942 "savefile.orig_version");
1951 "savefile.action_size");
1957 const char *
dur_name =
"Transport Deboard";
1961 "savefile.action_vector");
1977 "savefile.action_vector");
1987 "savefile.activities_size");
1996 "savefile.activities_vector");
2010 "savefile.activities_vector");
2024 "settings.gamestart_valid");
2027 const char *old_name
2051 "settings.set%d.value",
i);
2053#ifdef FREECIV_HAVE_LIBZSTD
2055 "settings.set%d.value",
i);
2056#elif FREECIV_HAVE_LIBLZMA
2058 "settings.set%d.value",
i);
2059#elif FREECIV_HAVE_LIBZ
2061 "settings.set%d.value",
i);
2064 "settings.set%d.value",
i);
2070 "settings.set%d.gamestart",
i);
2072#ifdef FREECIV_HAVE_LIBZSTD
2074 "settings.set%d.gamestart",
i);
2075#elif FREECIV_HAVE_LIBLZMA
2077 "settings.set%d.gamestart",
i);
2078#elif FREECIV_HAVE_LIBZ
2080 "settings.set%d.gamestart",
i);
2083 "settings.set%d.gamestart",
i);
2094 "settings.set%d.value",
i)) {
2116 }
else if (val &
TF_HEX) {
2124 "settings.set%d.value",
i);
2127 "wrap",
"settings.set%d.name",
set_count);
2134 "settings.set%d.gamestart",
i)) {
2153 }
else if (val &
TF_HEX) {
2161 "settings.set%d.gamestart",
i);
2179 int north_latitude, south_latitude;
2185 "settings.set%d.value",
2193 "settings.set%d.value",
2223 "settings.set%d.gamestart",
2231 "settings.set%d.gamestart",
2254 "settings.set_count");
2273 log_sg(
"Invalid AI level \"%s\". "
2274 "Changed to \"%s\".",
level,
2295 for (
i = 0;
i < count;
i++) {
2300 "research.r%d.got_tech_multi",
i);
2303 "research.r%d.got_tech",
i)
2305 "research.r%d.bulbs",
i)) {
2308 "research.r%d.free_bulbs",
i);
2317 "savefile.diplstate_type_size");
2321 "savefile.diplstate_type_vector,%d",
i);
2339 "player%d.got_first_city",
2350 "player%d.flags",
plrno);
2360 "player%d.flags",
plrno);
2366 "player%d.ncities",
plrno);
2370 "player%d.c%d.wl_length",
2377 "player%d.c%d.original",
2380 "player%d.c%d.acquire_t",
2384 "player%d.c%d.acquire_t",
2389 "player%d.c%d.wlcb",
2395 "player%d.wl_max_length",
plrno);
2403 "player%d.nunits",
plrno);
2407 "player%d.u%d.orders_length",
2414 "player%d.orders_max_length",
plrno);
2417 "player%d.routes_max_length",
plrno);
2436 log_debug(
"Upgrading data from savegame to version 3.3.0");
2448 "savefile.server_side_agent_size");
2453 const char *
aw_name =
"AutoWorker";
2456 "savefile.server_side_agent_list");
2469 "savefile.server_side_agent_list");
2479 "savefile.activities_size");
2480 if (
loading->activities.size) {
2483 "savefile.activities_vector");
2485 "Failed to load activity order: %s",
2490 "savefile.action_size");
2493 "Failed to load action order: %s",
2501 "savefile.action_vector");
2504 sizeof(*
loading->action.order));
2506 for (j = 0; j <
loading->action.size; j++) {
2530 "player%d.nunits",
plrno);
2547 if (act ==
loading->action.order[
i]) {
2563#ifdef FREECIV_DEV_SAVE_COMPAT
2571 log_verbose(
"Upgrading data between development revisions");
2574 "No save version found");
2576#ifdef FREECIV_DEV_SAVE_COMPAT_3_2
2588 for (
i = 0;
i < count;
i++) {
2590 "research.r%d.got_tech_multi",
i) ==
NULL) {
2593 "research.r%d.got_tech_multi",
i);
2614 "settings.gamestart_valid");
2617 const char *old_name
2634 "settings.set%d.value",
i);
2637#ifdef FREECIV_HAVE_LIBZSTD
2639 "settings.set%d.value",
i);
2640#elif FREECIV_HAVE_LIBLZMA
2642 "settings.set%d.value",
i);
2643#elif FREECIV_HAVE_LIBZ
2645 "settings.set%d.value",
i);
2648 "settings.set%d.value",
i);
2654 "settings.set%d.gamestart",
i);
2656#ifdef FREECIV_HAVE_LIBZSTD
2658 "settings.set%d.gamestart",
i);
2659#elif FREECIV_HAVE_LIBLZMA
2661 "settings.set%d.gamestart",
i);
2662#elif FREECIV_HAVE_LIBZ
2664 "settings.set%d.gamestart",
i);
2667 "settings.set%d.gamestart",
i);
2680 "settings.set%d.value",
i)) {
2705 }
else if (val &
TF_HEX) {
2713 "settings.set%d.value",
i);
2719 "settings.set%d.gamestart",
i)) {
2744 }
else if (val &
TF_HEX) {
2752 "settings.set%d.gamestart",
i);
2786 log_sg(
"Invalid AI level \"%s\". "
2787 "Changed to \"%s\".",
level,
2824 "savefile.action_size");
2830 const char *
dur_name =
"Disband Unit Recover";
2833 "savefile.action_vector");
2846 "savefile.action_vector");
2855 "player%d.adv.wonder_city",
2857 if (wonder_city < 0) {
2860 "player%d.wonder_city",
2862 if (wonder_city >= 0) {
2864 "player%d.adv.wonder_city",
plrno);
2877 "savefile.diplstate_type_size");
2882 "savefile.diplstate_type_vector,%d",
i);
2901 "player%d.ncities",
plrno);
2905 "player%d.c%d.wl_length",
2912 "player%d.wl_max_length",
plrno);
2914 "player%d.routes_max_length",
plrno);
2923 for (
int i = 0;
i < count;
i++) {
2928 "research.r%d.got_tech_multi",
i);
2931 "research.r%d.got_tech",
i)
2933 "research.r%d.bulbs",
i)) {
2936 "research.r%d.free_bulbs",
i);
2946 "settings.set_count");
2973 int north_latitude, south_latitude;
2979 "settings.set%d.value",
2987 "settings.set%d.value",
3015 "settings.gamestart_valid")) {
3018 "settings.set%d.gamestart",
3026 "settings.set%d.gamestart",
3044 "settings.set_count");
3053 "savefile.action_size");
3059 const char *
dur_name =
"Transport Deboard";
3062 "savefile.action_vector");
3075 "savefile.action_vector");
3085#ifdef FREECIV_DEV_SAVE_COMPAT_3_3
3092 "savefile.orig_version");
3098 "savefile.orig_version");
3115 "player%d.got_first_city",
3127 "player%d.flags",
plrno);
3137 "player%d.flags",
plrno);
3143 "player%d.ncities",
plrno);
3147 "player%d.c%d.acquire_t",
3150 "player%d.c%d.original",
3153 "player%d.c%d.acquire_t",
3157 "player%d.c%d.acquire_t",
3162 "player%d.c%d.wlcb",
3165 "player%d.c%d.wlcb",
3179 "player%d.orders_max_length",
plrno)
3186 "player%d.nunits",
plrno);
3191 "player%d.u%d.orders_length",
3198 "player%d.orders_max_length",
plrno);
3207 "savefile.action_size");
3216 "savefile.action_vector");
3230 "savefile.action_vector");
3240 "savefile.activities_size");
3249 "savefile.activities_vector");
3263 "savefile.activities_vector");
3278 "settings.gamestart_valid");
3297 "savefile.server_side_agent_size");
3302 const char *
aw_name =
"AutoWorker";
3305 "savefile.server_side_agent_list");
3318 "savefile.server_side_agent_list");
3336 "game.world_peace_start");
3338 "game.world_peace_start");
3343 "savefile.activities_size");
3344 if (
loading->activities.size) {
3347 "savefile.activities_vector");
3349 "Failed to load activity order: %s",
3354 "savefile.action_size");
3357 "Failed to load action order: %s",
3365 "savefile.action_vector");
3368 sizeof(*
loading->action.order));
3370 for (j = 0; j <
loading->action.size; j++) {
3394 "player%d.nunits",
plrno);
3411 if (act ==
loading->action.order[
i]) {
3441#ifdef FREECIV_DEV_SAVE_COMPAT_3_3
struct action * action_by_rule_name(const char *name)
int action_number(const struct action *action)
static struct action * action_by_number(action_id act_id)
#define action_iterate_end
#define action_get_activity(_pact_)
#define action_iterate(_act_)
struct @126::my_agent entries[MAX_AGENTS]
const char * default_ai_type_name(void)
bool has_capability(const char *cap, const char *capstr)
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
#define GAME_DEFAULT_REVOLENTYPE
#define GAME_DEFAULT_SCORETURN
#define GAME_DEFAULT_SAVETURNS
#define GAME_DEFAULT_TEAM_POOLED_RESEARCH
#define GAME_HARDCODED_DEFAULT_SKILL_LEVEL
#define log_verbose(message,...)
#define fc_assert(condition)
#define fc_assert_action(condition, action)
#define log_debug(message,...)
#define log_normal(message,...)
#define log_error(message,...)
struct tile * index_to_tile(const struct civ_map *imap, int mindex)
struct tile * mapstep(const struct civ_map *nmap, const struct tile *ptile, enum direction8 dir)
#define fc_calloc(n, esz)
int player_slot_count(void)
int player_slot_index(const struct player_slot *pslot)
#define player_slots_iterate(_pslot)
#define players_iterate_alive_end
#define player_slots_iterate_end
#define players_iterate_alive(_pplayer)
const char * secfile_error(void)
bool secfile_lookup_int(const struct section_file *secfile, int *ival, const char *path,...)
bool secfile_entry_delete(struct section_file *secfile, const char *path,...)
bool entry_set_name(struct entry *pentry, const char *name)
bool secfile_lookup_enum_data(const struct section_file *secfile, int *pvalue, bool bitwise, secfile_enum_name_data_fn_t name_fn, secfile_data_t data, const char *path,...)
const struct entry_list * section_entries(const struct section *psection)
const char ** secfile_lookup_str_vec(const struct section_file *secfile, size_t *dim, const char *path,...)
const char * entry_name(const struct entry *pentry)
struct entry * secfile_entry_lookup(const struct section_file *secfile, const char *path,...)
const char * secfile_lookup_str(const struct section_file *secfile, const char *path,...)
bool secfile_lookup_bool_default(const struct section_file *secfile, bool def, const char *path,...)
int secfile_lookup_int_default(const struct section_file *secfile, int def, const char *path,...)
struct section * secfile_section_by_name(const struct section_file *secfile, const char *name)
struct section * secfile_section_lookup(const struct section_file *secfile, const char *path,...)
const char * secfile_lookup_str_default(const struct section_file *secfile, const char *def, const char *path,...)
bool secfile_lookup_bool(const struct section_file *secfile, bool *bval, const char *path,...)
#define secfile_replace_str_vec(secfile, strings, dim, path,...)
#define secfile_insert_int(secfile, value, path,...)
#define secfile_insert_enum(secfile, enumerator, specenum_type, path,...)
#define secfile_insert_str_vec(secfile, strings, dim, path,...)
#define secfile_replace_int(secfile, value, path,...)
#define entry_list_iterate_end
#define secfile_insert_str(secfile, string, path,...)
#define secfile_insert_bool(secfile, value, path,...)
#define secfile_replace_str(secfile, string, path,...)
#define entry_list_iterate(entlist, pentry)
#define secfile_replace_bool(secfile, value, path,...)
const void * secfile_data_t
static void compat_post_load_030100(struct loaddata *loading, enum sgf_version format_class)
struct extra_type * resource_by_identifier(const char identifier)
int current_compat_ver(void)
static void compat_load_030000(struct loaddata *loading, enum sgf_version format_class)
static const char num_chars[]
static const char * killcitizen_enum_str(secfile_data_t data, int bit)
enum barbarian_type barb_type_convert(int old_type)
static char * special_names[]
static struct compatibility compat[]
static void compat_load_020400(struct loaddata *loading, enum sgf_version format_class)
static void upgrade_unit_order_targets(struct unit *act_unit)
static void compat_load_030300(struct loaddata *loading, enum sgf_version format_class)
char bin2ascii_hex(int value, int halfbyte_wanted)
static const int compat_num
static void compat_load_020600(struct loaddata *loading, enum sgf_version format_class)
static enum direction8 dir_opposite(enum direction8 dir)
void(* load_version_func_t)(struct loaddata *loading, enum sgf_version format_class)
static void upgrade_server_side_agent(struct loaddata *loading)
void sg_load_compat(struct loaddata *loading, enum sgf_version format_class)
static void unit_order_activity_to_action(struct unit *act_unit)
static char * revolentype_str(enum revolen_type type)
static int increase_secfile_turn_int(struct loaddata *loading, const char *key, int old_def, bool keep_default)
enum ai_level ai_level_convert(int old_level)
int ascii_hex2bin(char ch, int halfbyte)
struct extra_type * special_extra_get(int spe)
static void compat_load_020500(struct loaddata *loading, enum sgf_version format_class)
static void compat_load_030200(struct loaddata *loading, enum sgf_version format_class)
enum tile_special_type special_by_rule_name(const char *name)
void sg_load_post_load_compat(struct loaddata *loading, enum sgf_version format_class)
const char * special_rule_name(enum tile_special_type type)
static void compat_load_030100(struct loaddata *loading, enum sgf_version format_class)
static void insert_server_side_agent(struct loaddata *loading, enum sgf_version format_class)
#define sg_check_ret(...)
#define sg_warn(condition, message,...)
#define sg_failure_ret_val(condition, _val, message,...)
#define sg_failure_ret(condition, message,...)
#define MAX_TRADE_ROUTES_OLD
const char * setcompat_S3_2_name_from_S3_1(const char *old_name)
struct setting * setting_by_name(const char *name)
const char * setting_value_name(const struct setting *pset, bool pretty, char *buf, size_t buf_len)
bool setting_bitwise_set(struct setting *pset, const char *val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
struct setting_list * level[OLEVELS_NUM]
const char * setting_bitwise_secfile_str(secfile_data_t data, int bit)
struct specialist * specialist_by_number(const Specialist_type_id id)
const char * specialist_rule_name(const struct specialist *sp)
Specialist_type_id specialist_count(void)
#define specialist_type_iterate_end
#define specialist_type_iterate(sp)
struct packet_game_info info
struct civ_game::@31::@35 server
struct civ_map::@42::@44 server
const load_version_func_t post_load
const load_version_func_t load
struct name_translation name
enum unit_activity activity
enum unit_activity activity
struct extra_type * activity_target
enum server_side_agent ssa_controller
int fc_snprintf(char *str, size_t n, const char *format,...)
size_t fc_strlcpy(char *dest, const char *src, size_t n)
int fc_strcasecmp(const char *str0, const char *str1)
#define sz_strlcpy(dest, src)
#define sz_strlcat(dest, src)
#define fc_strncmp(_s1_, _s2_, _len_)
int team_slot_count(void)
char terrain_identifier(const struct terrain *pterrain)
const char * terrain_rule_name(const struct terrain *pterrain)
#define terrain_type_iterate(_p)
#define terrain_type_iterate_end
void free_unit_orders(struct unit *punit)
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
enum gen_action activity_default_action(enum unit_activity act)
bool unit_has_orders(const struct unit *punit)
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_end
const struct unit_type * unit_type_get(const struct unit *punit)
bool utype_is_moved_to_tgt_by_action(const struct action *paction, const struct unit_type *utype)
const char * unit_rule_name(const struct unit *punit)
bool utype_is_unmoved_by_action(const struct action *paction, const struct unit_type *utype)