Author: sveinung Date: Wed Aug 12 12:30:52 2015 New Revision: 29473 URL: http://svn.gna.org/viewcvs/freeciv?rev=29473&view=rev Log: Fix join foreign city order upgrade
The code that upgrades ORDER_BUILD_CITY to ORDER_PERFORM_ACTION was written with pre version 3 save games in mind. The rule that a unit can't join a foreign city is hard coded in those save games. It was then used to provide development version internal save game compatibility for Freeciv 3.0. A Freeciv 3.0 ruleset may permit a unit to join a foreign city. No ruleset currently bundled with Freeciv or Freeciv-web allows it but a save game from a custom ruleset may be out there. Stop assuming that a ORDER_BUILD_CITY to a tile without a domestic city is intended as ORDER_PERFORM_ACTION + ACTION_FOUND_CITY when dev-save-compat is enabled. See the presence of any city at the target tile as ORDER_PERFORM_ACTION + ACTION_FOUND_CITY. Wait until all foreign cities have loaded before running the order upgrade code. Reported by Jacob Nevins <jtn> See bug #23772 Modified: trunk/server/savecompat.c trunk/server/savegame3.c Modified: trunk/server/savecompat.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/savecompat.c?rev=29473&r1=29472&r2=29473&view=diff ============================================================================== --- trunk/server/savecompat.c (original) +++ trunk/server/savecompat.c Wed Aug 12 12:30:52 2015 @@ -1054,7 +1054,12 @@ switch (order) { case ORDER_OLD_BUILD_CITY: if (tile_city(tgt_tile) +#ifdef FREECIV_DEV_SAVE_COMPAT + /* Freeciv 3.0 allows joining foreign cities. */ + ) { +#else /* FREECIV_DEV_SAVE_COMPAT */ && city_owner(tile_city(tgt_tile)) == unit_owner(act_unit)) { +#endif /* FREECIV_DEV_SAVE_COMPAT */ /* The player's cities are loaded right before his units. It wasn't * possible for rulesets to allow joining foreign cities before 3.0. * This means that a converted build city order only can be a Join Modified: trunk/server/savegame3.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/savegame3.c?rev=29473&r1=29472&r2=29473&view=diff ============================================================================== --- trunk/server/savegame3.c (original) +++ trunk/server/savegame3.c Wed Aug 12 12:30:52 2015 @@ -3296,6 +3296,34 @@ sg_load_player_units_transport(loading, pplayer); } players_iterate_end; +#ifdef FREECIV_DEV_SAVE_COMPAT + /* Upgrade unit orders */ + players_iterate(pplayer) { + unit_list_iterate(pplayer->units, punit) { + int i; + + for (i = 0; i < punit->orders.length; i++) { + struct unit_order *order = &punit->orders.list[i]; + + if (order->order != ORDER_PERFORM_ACTION + && order->action == ACTION_COUNT) { + /* This order may have been replaced by the perform action + * order */ + + /* See if a corresponding action exists. */ + order->action = sg_order_to_action(order->order, punit, + punit->goto_tile); + + if (order->action != ACTION_COUNT) { + /* The order should be upgraded. */ + order->order = ORDER_PERFORM_ACTION; + } + } + } + } unit_list_iterate_end; + } players_iterate_end; +#endif /* FREECIV_DEV_SAVE_COMPAT */ + /* Savegame may contain nation assignments that are incompatible with the * current nationset -- for instance, if it predates the introduction of * nationsets. Ensure they are compatible, one way or another. */ @@ -5144,23 +5172,6 @@ ? ACTION_COUNT : char2num(action_unitstr[j])); -#ifdef FREECIV_DEV_SAVE_COMPAT - if (order->order != ORDER_PERFORM_ACTION - && order->action == ACTION_COUNT) { - /* This order may have been replaced by the perform action - * order */ - - /* See if a corresponding action exists. */ - order->action = sg_order_to_action(order->order, punit, - punit->goto_tile); - - if (order->action != ACTION_COUNT) { - /* The order should be upgraded. */ - order->order = ORDER_PERFORM_ACTION; - } - } -#endif /* FREECIV_DEV_SAVE_COMPAT */ - if (order->order == ORDER_LAST || (order->order == ORDER_MOVE && !direction8_is_valid(order->dir)) || (order->order == ORDER_ACTIVITY _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits