39 "Irrigation",
"Mine",
"Pollution",
"Hut",
"Farmland",
90#ifdef FREECIV_DEV_SAVE_COMPAT
141#define compat_current (compat_num - 1)
164 log_error(
"Savegame version newer than this build found (%d > %d). "
165 "Trying to load the game nevertheless ...",
loading->version,
171 "Unknown savefile format version (%d).",
loading->version);
177 log_normal(
_(
"Run compatibility function for version: <%d "
184#ifdef FREECIV_DEV_SAVE_COMPAT
212 log_normal(
_(
"Run post load compatibility function for version: <%d "
219#ifdef FREECIV_DEV_SAVE_COMPAT
265 "Unknown hex value: '%c' %d",
ch,
ch);
270 "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-+";
282 "Unknown ascii value for num: '%c' %d",
ch,
ch);
333 if (presource->data.resource->id_old_save == identifier) {
354 log_debug(
"Upgrading data from savegame to version 2.4.0");
372 "player%d.ncities",
plrno);
376 "player%d.c%d.size",
plrno,
i);
426 int xsize = 0,
y,
l, j,
x;
435 for (j = 0; j < 8; j++) {
438 "map.k%02d_%04d",
l * 8 + j,
y);
445 "Inconsistent xsize in map.k%02d_%04d",
447 for (
x = 0;
x < xsize;
x++) {
462 for (
x = 0;
x < xsize;
x++) {
474 for (j = 0; j < 8; j++) {
478 for (
x = 0;
x < xsize;
x++) {
483 "map.k%02d_%04d",
l * 8 + j,
y);
499 "settings.gamestart_valid");
515 const char *
const nosave =
"GAMEOVER|QUITIDLE|INTERRUPT";
516 const char *
const save =
"TURN|GAMEOVER|QUITIDLE|INTERRUPT";
520 "settings.set%d.value",
i)) {
524 "settings.set%d.value",
new_opt);
527 "settings.set%d.value",
i);
530 "settings.set%d.value",
new_opt);
537 "settings.set%d.gamestart",
i)) {
541 "settings.set%d.gamestart",
new_opt);
544 "settings.set%d.gamestart",
i);
547 "settings.set%d.gamestart",
new_opt);
556 log_sg(
"Unexpected \"autosaves\" setting found in pre-2.4 "
557 "savefile. It may have been overridden.");
587 const char *
modname[] = {
"Road",
"Railroad" };
615 log_debug(
"Upgrading data from savegame to version 2.5.0");
621 "savefile.roads_vector");
625 "savefile.activities_vector");
635 "settings.gamestart_valid");
650 "settings.set%d.value",
i)) {
656 "settings.set%d.value",
i);
659 "settings.set%d.value",
i);
667 "settings.set%d.gamestart",
i)) {
673 "settings.set%d.gamestart",
i);
676 "settings.set%d.gamestart",
i);
721 log_debug(
"Upgrading data from savegame to version 2.6.0");
749 "settings.gamestart_valid");
765 "settings.set%d.value",
i)) {
776 "settings.set%d.gamestart",
i)) {
795 "settings.set%d.value",
i)) {
806 "settings.set%d.gamestart",
i)) {
820 "settings.set%d.value",
i)) {
825 "settings.set%d.value",
i);
833 "settings.set%d.gamestart",
i)) {
838 "settings.set%d.gamestart",
i);
849 "settings.set%d.value",
i)) {
853 "settings.set%d.value",
i);
856 "settings.set%d.value",
i);
862 "settings.set%d.gamestart",
i)) {
866 "settings.set%d.gamestart",
i);
869 "settings.set%d.gamestart",
i);
876 &team_pooled_research,
877 "settings.set%d.value",
i),
882 "settings.set%d.value",
i)) {
888 "settings.set%d.gamestart",
i)) {
897 "settings.set%d.value",
i)) {
966 "player%d.capital",
plrno)) {
968 "player%d.got_first_city",
plrno);
974 "player%d.unassigned_user",
plrno);
978 "player%d.unassigned_ranked",
plrno);
982 "player%d.ai.is_barbarian",
plrno);
985 "player%d.ai.barb_type",
plrno);
1007 "player%d.trait.mod%d",
plrno,
i),
1013 "player%d.units_built",
plrno);
1019 "player%d.units_killed",
plrno);
1025 "player%d.units_lost",
plrno);
1039 "player%d.u%d.orders_last_move_safe",
1045 "player%d.u%d.orders_length",
1053 "player%d.u%d.orders_list",
1059 "player%d.u%d.orders_list",
plrno,
i);
1069 "savefile.specialists_size");
1081 "savefile.specialists_vector");
1154 if (team_pooled_research) {
1156 "player%d.team_no",
plrno);
1162 "Research out of bounds (%d)!",
i);
1178 "player%d.research.%s",
1186 "player%d.research.%s",
1194 "player%d.research.%s",
1202 "Research related entry marked as float.");
1221 "savefile.diplstate_type_size");
1230 for (j = 0; j <
DS_LAST; j++) {
1236 "savefile.diplstate_type_vector");
1275 "player%d.name",
plrno);
1277 "player%d.name",
i);
1281 log_sg(
_(
"The save game is wrong about what the closest"
1282 " relationship %s (player %d) and %s (player %d) have had is."
1329 log_debug(
"Upgrading data from savegame to version 3.0.0");
1361 "player%d.flags",
plrno);
1369 for (
i = 0;
i < num;
i++) {
1378 "player%d.ncities",
plrno);
1380 for (
i = 0;
i < num;
i++) {
1392 "settings.set_count");
1396 "game.meta_usermessage")) {
1400 "game.meta_message");
1423 "event_cache.events%d.event",
i);
1442 "savefile.server_side_agent_size");
1451 "savefile.server_side_agent_size");
1466 "savefile.server_side_agent_list");
1490 "player%d.u%d.server_side_agent",
1505 "player%d.u%d.server_side_agent",
1509 "player%d.u%d.server_side_agent",
1528 log_debug(
"Upgrading data from savegame to version 3.1.0");
1551 "player%d.u%d.orders_length",
1555 "player%d.u%d.action_list",
1575 "player%d.u%d.action_vec",
1579 "player%d.u%d.action_vec,%d",
1591 "savefile.action_size");
1597 const char *
dur_name =
"Disband Unit Recover";
1600 "savefile.action_vector");
1613 "savefile.action_vector");
1627 "settings.gamestart_valid");
1640 "settings.set%d.gamesetdef",
i);
1664 switch (
order->activity) {
1695 log_error(
"Activity %d is not supposed to appear in unit orders",
1735 struct tile *current_tile;
1746 for (
i =
act_unit->orders.index;
i > 0 && current_tile !=
NULL;
i--) {
1759 for (
i = 0;
i <
act_unit->orders.length && current_tile !=
NULL;
i++) {
1797 current_tile =
NULL;
1804 if (current_tile ==
NULL) {
1930 log_debug(
"Upgrading data from savegame to version 3.2.0");
1934 "savefile.orig_version");
1941 "savefile.orig_version");
1946 "savefile.orig_version");
1955 "savefile.action_size");
1961 const char *
dur_name =
"Transport Deboard";
1965 "savefile.action_vector");
1981 "savefile.action_vector");
1991 "savefile.activities_size");
2000 "savefile.activities_vector");
2014 "savefile.activities_vector");
2028 "settings.gamestart_valid");
2031 const char *old_name
2055 "settings.set%d.value",
i);
2057#ifdef FREECIV_HAVE_LIBZSTD
2059 "settings.set%d.value",
i);
2060#elif FREECIV_HAVE_LIBLZMA
2062 "settings.set%d.value",
i);
2063#elif FREECIV_HAVE_LIBZ
2065 "settings.set%d.value",
i);
2068 "settings.set%d.value",
i);
2074 "settings.set%d.gamestart",
i);
2076#ifdef FREECIV_HAVE_LIBZSTD
2078 "settings.set%d.gamestart",
i);
2079#elif FREECIV_HAVE_LIBLZMA
2081 "settings.set%d.gamestart",
i);
2082#elif FREECIV_HAVE_LIBZ
2084 "settings.set%d.gamestart",
i);
2087 "settings.set%d.gamestart",
i);
2098 "settings.set%d.value",
i)) {
2120 }
else if (val &
TF_HEX) {
2128 "settings.set%d.value",
i);
2131 "wrap",
"settings.set%d.name",
set_count);
2138 "settings.set%d.gamestart",
i)) {
2157 }
else if (val &
TF_HEX) {
2165 "settings.set%d.gamestart",
i);
2183 int north_latitude, south_latitude;
2189 "settings.set%d.value",
2197 "settings.set%d.value",
2227 "settings.set%d.gamestart",
2235 "settings.set%d.gamestart",
2258 "settings.set_count");
2277 log_sg(
"Invalid AI level \"%s\". "
2278 "Changed to \"%s\".",
level,
2299 for (
i = 0;
i < count;
i++) {
2304 "research.r%d.got_tech_multi",
i);
2307 "research.r%d.got_tech",
i)
2309 "research.r%d.bulbs",
i)) {
2312 "research.r%d.free_bulbs",
i);
2321 "savefile.diplstate_type_size");
2325 "savefile.diplstate_type_vector,%d",
i);
2343 "player%d.got_first_city",
2354 "player%d.flags",
plrno);
2364 "player%d.flags",
plrno);
2370 "player%d.ncities",
plrno);
2374 "player%d.c%d.wl_length",
2381 "player%d.c%d.original",
2384 "player%d.c%d.acquire_t",
2388 "player%d.c%d.acquire_t",
2393 "player%d.c%d.wlcb",
2399 "player%d.wl_max_length",
plrno);
2407 "player%d.nunits",
plrno);
2411 "player%d.u%d.orders_length",
2418 "player%d.orders_max_length",
plrno);
2421 "player%d.routes_max_length",
plrno);
2440 log_debug(
"Upgrading data from savegame to version 3.3.0");
2454 "game.last_turn_change_time") / 100.0;
2463 "savefile.server_side_agent_size");
2468 const char *
aw_name =
"AutoWorker";
2471 "savefile.server_side_agent_list");
2484 "savefile.server_side_agent_list");
2494 "savefile.action_size");
2500 const char *
cc1_name =
"Conquer City Shrink";
2501 const char *
cc2_name =
"Conquer City Shrink 2";
2502 const char *
cc3_name =
"Conquer City Shrink 3";
2503 const char *
cc4_name =
"Conquer City Shrink 4";
2506 "savefile.action_vector");
2525 "savefile.action_vector");
2535 "savefile.activities_size");
2536 if (
loading->activities.size) {
2539 "savefile.activities_vector");
2541 "Failed to load activity order: %s",
2546 "savefile.action_size");
2549 "Failed to load action order: %s",
2557 "savefile.action_vector");
2560 sizeof(*
loading->action.order));
2562 for (j = 0; j <
loading->action.size; j++) {
2586 "player%d.nunits",
plrno);
2606 if (act ==
loading->action.order[
i]) {
2628 for (
i = 0;
i < count;
i++) {
2644 "player%d.dc_total",
plrno);
2676#ifdef FREECIV_DEV_SAVE_COMPAT
2684 log_verbose(
"Upgrading data between development revisions");
2687 "No save version found");
2689#ifdef FREECIV_DEV_SAVE_COMPAT_3_3
2696 "savefile.orig_version");
2702 "savefile.orig_version");
2719 "player%d.got_first_city",
2731 "player%d.flags",
plrno);
2741 "player%d.flags",
plrno);
2747 "player%d.ncities",
plrno);
2751 "player%d.c%d.acquire_t",
2754 "player%d.c%d.original",
2757 "player%d.c%d.acquire_t",
2761 "player%d.c%d.acquire_t",
2766 "player%d.c%d.wlcb",
2769 "player%d.c%d.wlcb",
2783 "player%d.orders_max_length",
plrno)
2790 "player%d.nunits",
plrno);
2795 "player%d.u%d.orders_length",
2802 "player%d.orders_max_length",
plrno);
2811 "savefile.action_size");
2820 "savefile.action_vector");
2834 "savefile.action_vector");
2844 "savefile.activities_size");
2853 "savefile.activities_vector");
2867 "savefile.activities_vector");
2882 "settings.gamestart_valid");
2901 "savefile.server_side_agent_size");
2906 const char *
aw_name =
"AutoWorker";
2909 "savefile.server_side_agent_list");
2922 "savefile.server_side_agent_list");
2940 "game.world_peace_start");
2942 "game.world_peace_start");
2947 "game.last_turn_change_time") / 100.0;
2955 "savefile.activities_size");
2956 if (
loading->activities.size) {
2959 "savefile.activities_vector");
2961 "Failed to load activity order: %s",
2966 "savefile.action_size");
2969 "Failed to load action order: %s",
2977 "savefile.action_vector");
2980 sizeof(*
loading->action.order));
2982 for (j = 0; j <
loading->action.size; j++) {
3006 "player%d.nunits",
plrno);
3025 if (act ==
loading->action.order[
i]) {
3046 for (
i = 0;
i < count;
i++) {
3061 "savefile.action_size");
3067 const char *
cc1_name =
"Conquer City Shrink";
3068 const char *
cc2_name =
"Conquer City Shrink 2";
3069 const char *
cc3_name =
"Conquer City Shrink 3";
3070 const char *
cc4_name =
"Conquer City Shrink 4";
3073 "savefile.action_vector");
3092 "savefile.action_vector");
3108 "player%d.dc_total",
plrno);
3143#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 @130::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)
void update_capital(struct player *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_entry_ignore(_sfile_, _fmt_,...)
#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_float(secfile, value, path,...)
#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)
static void compat_post_load_030300(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::@32::@36 server
struct civ_map::@44::@46 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)