From 7d6bd968ca40fdc40dbd10d52d55c6d53afc8291 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 3 Dec 2022 21:12:25 +0200 Subject: [PATCH 49/49] Drop FREECIV_DEV_SAVE_COMPAT_3_1 See osdn #46170 Signed-off-by: Marko Lindqvist --- configure.ac | 4 +- server/savegame/savecompat.c | 336 ----------------------------------- 2 files changed, 1 insertion(+), 339 deletions(-) diff --git a/configure.ac b/configure.ac index 987a57c2d8..262c345485 100644 --- a/configure.ac +++ b/configure.ac @@ -409,9 +409,7 @@ AS_IF([test $dev_save_compat != 0], [AC_DEFINE([FREECIV_DEV_SAVE_COMPAT], [1], [Development version save game compatibility]) AC_DEFINE([FREECIV_DEV_SAVE_COMPAT_3_2], [1], - [Development version save game compatibility - 3.2 development]) - AC_DEFINE([FREECIV_DEV_SAVE_COMPAT_3_1], [1], - [Development version save game compatibility - 3.1 development])]) + [Development version save game compatibility - 3.2 development])]) AC_ARG_ENABLE([patient-connect], AS_HELP_STRING([--enable-patient-connect=yes/no], diff --git a/server/savegame/savecompat.c b/server/savegame/savecompat.c index 7699626805..5308b33074 100644 --- a/server/savegame/savecompat.c +++ b/server/savegame/savecompat.c @@ -2281,290 +2281,6 @@ static void compat_load_dev(struct loaddata *loading) game_version = 2060000; } -#ifdef FREECIV_DEV_SAVE_COMPAT_3_1 - - if (game_version < 3009200) { - /* Before version number bump to 3.0.92, beginning of 2020 */ - - /* Renamed actions. */ - loading->action.size = secfile_lookup_int_default(loading->file, 0, - "savefile.action_size"); - if (loading->action.size) { - const char **modname; - int j; - - modname = secfile_lookup_str_vec(loading->file, &loading->action.size, - "savefile.action_vector"); - - for (j = 0; j < loading->action.size; j++) { - if (fc_strcasecmp(modname[j], "Targeted Steal Tech Escape") == 0) { - secfile_replace_str(loading->file, "Targeted Steal Tech Escape Expected", - "savefile.action_vector,%d", j); - } else if (fc_strcasecmp(modname[j], "Steal Tech Escape") == 0) { - secfile_replace_str(loading->file, "Steal Tech Escape Expected", - "savefile.action_vector,%d", j); - } else if (fc_strcasecmp(modname[j], "Road") == 0) { - secfile_replace_str(loading->file, "Build Road", - "savefile.action_vector,%d", j); - } - } - - free(modname); - } - - /* Old unit order tgt_vec refers to order sub targets */ - player_slots_iterate(pslot) { - int unit; - int units_num; - int plrno = player_slot_index(pslot); - - if (secfile_section_lookup(loading->file, "player%d", plrno) - == NULL) { - continue; - } - - /* Number of units the player has. */ - units_num = secfile_lookup_int_default(loading->file, 0, - "player%d.nunits", - plrno); - - for (unit = 0; unit < units_num; unit++) { - size_t old_tgt_size; - int *old_tgt_vec; - - if ((old_tgt_vec = secfile_lookup_int_vec(loading->file, &old_tgt_size, - "player%d.u%d.tgt_vec", - plrno, unit))) { - secfile_insert_int_vec(loading->file, old_tgt_vec, old_tgt_size, - "player%d.u%d.sub_tgt_vec", plrno, unit); - free(old_tgt_vec); - } - } - } player_slots_iterate_end; - - /* Unit order extra sub targets was for a while stored separate from tech - * and building sub targets. */ - player_slots_iterate(pslot) { - int unit; - int units_num; - int plrno = player_slot_index(pslot); - - if (secfile_section_lookup(loading->file, "player%d", plrno) - == NULL) { - continue; - } - - /* Number of units the player has. */ - units_num = secfile_lookup_int_default(loading->file, 0, - "player%d.nunits", - plrno); - - for (unit = 0; unit < units_num; unit++) { - size_t extra_vec_size; - int *extra_vec; - - if ((extra_vec = secfile_lookup_int_vec(loading->file, - &extra_vec_size, - "player%d.u%d.extra_vec", - plrno, unit))) { - int order_num; - - for (order_num = 0; order_num < extra_vec_size; order_num++) { - if (extra_vec[order_num] != -1) { - if (order_num) { - secfile_replace_int(loading->file, extra_vec[order_num], - "player%d.u%d.sub_tgt_vec,%d", - plrno, unit, order_num); - } else { - secfile_replace_int(loading->file, extra_vec[order_num], - "player%d.u%d.sub_tgt_vec", - plrno, unit); - } - } - } - free(extra_vec); - } - } - } player_slots_iterate_end; - - player_slots_iterate(pslot) { - int plrno = player_slot_index(pslot); - int history; - - history = secfile_lookup_int_default(loading->file, 0, - "player%d.culture", - plrno); - - if (history > 0) { - /* Savefile had player history value saved to field named 'culture'. - * Save it to 'history'. */ - secfile_insert_int(loading->file, history, "player%d.history", plrno); - } - } player_slots_iterate_end; - - { - int action_count; - - action_count = secfile_lookup_int_default(loading->file, 0, - "savefile.action_size"); - if (action_count > 0) { - const char **modname; - const char **modname_new; - const char *plant_name = "Plant"; - const char *cultivate_name = "Cultivate"; - int j; - - modname = secfile_lookup_str_vec(loading->file, &loading->action.size, - "savefile.action_vector"); - - modname_new = fc_calloc(action_count, sizeof(*modname_new)); - - for (j = 0; j < action_count; j++) { - const char *aname = modname[j]; - - if (!fc_strcasecmp("Mine TF", aname)) { - modname_new[j] = plant_name; - } else if (!fc_strcasecmp("Irrigate TF", aname)) { - modname_new[j] = cultivate_name; - } else { - modname_new[j] = aname; - } - } - - secfile_replace_str_vec(loading->file, modname_new, action_count, - "savefile.action_vector"); - - free(modname_new); - } - } - - /* Actions are now stored by number. */ - player_slots_iterate(pslot) { - int unit; - int units_num; - int plrno = player_slot_index(pslot); - - if (secfile_section_lookup(loading->file, "player%d", plrno) - == NULL) { - continue; - } - - /* Number of units the player has. */ - units_num = secfile_lookup_int_default(loading->file, 0, - "player%d.nunits", - plrno); - - for (unit = 0; unit < units_num; unit++) { - const char *action_unitstr; - int order_len; - - order_len = secfile_lookup_int_default(loading->file, 0, - "player%d.u%d.orders_length", - plrno, unit); - - if ((action_unitstr = secfile_lookup_str_default(loading->file, "", - "player%d.u%d.action_list", - plrno, unit))) { - int order_num; - - if (order_len > strlen(action_unitstr)) { - order_len = strlen(action_unitstr); - } - - for (order_num = 0; order_num < order_len; order_num++) { - int unconverted_action_id; - - if (action_unitstr[order_num] == '?') { - unconverted_action_id = -1; - } else { - unconverted_action_id = char2num(action_unitstr[order_num]); - } - - if (order_num == 0) { - /* The start of a vector has no number. */ - secfile_insert_int(loading->file, unconverted_action_id, - "player%d.u%d.action_vec", - plrno, unit); - } else { - secfile_insert_int(loading->file, unconverted_action_id, - "player%d.u%d.action_vec,%d", - plrno, unit, order_num); - } - } - } - } - } player_slots_iterate_end; - player_slots_iterate(pslot) { - int city; - int city_num; - int plrno = player_slot_index(pslot); - - if (secfile_section_lookup(loading->file, "player%d", plrno) - == NULL) { - continue; - } - - /* Number of cities the player has. */ - city_num = secfile_lookup_int_default(loading->file, 0, - "player%d.ncities", - plrno); - - for (city = 0; city < city_num; city++) { - const char *action_citystr; - int order_len; - - order_len = secfile_lookup_int_default(loading->file, 0, - "player%d.c%d.rally_point_length", - plrno, city); - - if ((action_citystr = secfile_lookup_str_default(loading->file, "", - "player%d.c%d.rally_point_actions", - plrno, city))) { - int order_num; - - if (order_len > strlen(action_citystr)) { - order_len = strlen(action_citystr); - } - - for (order_num = 0; order_num < order_len; order_num++) { - int unconverted_action_id; - - if (action_citystr[order_num] == '?') { - unconverted_action_id = -1; - } else { - unconverted_action_id = char2num(action_citystr[order_num]); - } - - if (order_num == 0) { - /* The start of a vector has no number. */ - secfile_insert_int(loading->file, unconverted_action_id, - "player%d.c%d.rally_point_action_vec", - plrno, city); - } else { - secfile_insert_int(loading->file, unconverted_action_id, - "player%d.c%d.rally_point_action_vec,%d", - plrno, city, order_num); - } - } - } - } - } player_slots_iterate_end; - } /* Version < 3.0.92 */ - - if (game_version < 3009300) { - /* Before version number bump to 3.0.93, beginning of 2021 */ - - /* Explicit server side agent was new in 3.1 */ - insert_server_side_agent(loading, SAVEGAME_3); - } /* Version < 3.0.93 */ - - if (game_version < 3009400) { - /* Before version number bump to 3.0.94 */ - - } /* Version < 3.0.94 */ - -#endif /* FREECIV_DEV_SAVE_COMPAT_3_1 */ - #ifdef FREECIV_DEV_SAVE_COMPAT_3_2 if (game_version < 3019100) { @@ -3057,58 +2773,6 @@ static void compat_post_load_dev(struct loaddata *loading) game_version = 2060000; } - if (game_version < 3009300) { - players_iterate_alive(pplayer) { - unit_list_iterate(pplayer->units, punit) { - int i; - - if (!punit->has_orders) { - continue; - } - - fc_assert_action(punit->orders.length == 0 - || punit->orders.list != NULL, continue); - - for (i = 0; i < punit->orders.length; i++) { - /* "Attack" was split in "Suicide Attack" and "Attack" in 3.1. */ - if (punit->orders.list[i].order == ORDER_PERFORM_ACTION - && punit->orders.list[i].action == ACTION_ATTACK - && !unit_can_do_action(punit, ACTION_ATTACK) - && unit_can_do_action(punit, ACTION_SUICIDE_ATTACK)) { - punit->orders.list[i].action = ACTION_SUICIDE_ATTACK; - } - } - } unit_list_iterate_end; - } players_iterate_alive_end; - - /* Explicit server side agent was new in 3.1 */ - upgrade_server_side_agent(loading); - - /* Some activities should only be ordered in action orders. */ - players_iterate_alive(pplayer) { - unit_list_iterate(pplayer->units, punit) { - unit_order_activity_to_action(punit); - } unit_list_iterate_end; - } players_iterate_alive_end; - - /* Unit order action target isn't dir anymore */ - players_iterate_alive(pplayer) { - unit_list_iterate(pplayer->units, punit) { - upgrade_unit_order_targets(punit); - } unit_list_iterate_end; - } players_iterate_alive_end; - - /* Backward compatibility: if we had any open-ended orders (pillage) - * in the savegame, assign specific targets now */ - players_iterate_alive(pplayer) { - unit_list_iterate(pplayer->units, punit) { - unit_assign_specific_activity_target(punit, - &punit->activity, - &punit->activity_target); - } unit_list_iterate_end; - } players_iterate_alive_end; - } /* Version < 3.0.93 */ - #ifdef FREECIV_DEV_SAVE_COMPAT_3_2 if (game_version < 3019100) { -- 2.35.1