Skip to content

Commit

Permalink
Use upstream work to do old save game upgrade
Browse files Browse the repository at this point in the history
Freeciv-web uses Freeciv trunk. Work to enable savegame compatibility inside a development version has started in Freeciv. Make use of it.
  • Loading branch information
kvilhaugsvik committed Aug 3, 2015
1 parent af184f9 commit a34d824
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 7 deletions.
6 changes: 4 additions & 2 deletions freeciv/apply_patches.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
# city_traderoute_hotfix is for Freeciv bug #23708.
# order_validation_feed_back is Freeciv patch #6151. I hope it will assist the goto bug hunting.
# action_order is Freeciv patch #6153. I didn't upgrade the Freeciv server it self because of Freeciv bug #23729.
# action_order_savegame_compat makes pre patch #6153 savegames work.
# fix_unit_order_action_validation is Freeciv bug #23737.
# dev_save_compat is Freeciv patch #6154.
# action_order_savegame_compat is Freeciv patch #6171. It makes pre patch #6153 savegames work.

PATCHLIST="freeciv_web_all_packets_def_changes caravan_fixes1 city_fixes city_impr_fix2 city_name_bugfix city-naming-change city_fixes2 citytools_changes map-settings metachange text_fixes unithand-change2 webclient-ai-attitude current_research_cost freeciv-svn-webclient-changes network-rewrite-1 fcnet_packets misc_devversion_sync scenario_ruleset savegame savegame2 maphand_ch serverside_extra_assign libtoolize_no_symlinks spacerace city_disbandable ai_traits_crash unittools ruleset-capability worklists server_password aifill barbarian-names activity_null_check add_rulesets NoDeltaHeader city_traderoute_hotfix order_validation_feed_back action_order action_order_savegame_compat"
PATCHLIST="freeciv_web_all_packets_def_changes caravan_fixes1 city_fixes city_impr_fix2 city_name_bugfix city-naming-change city_fixes2 citytools_changes map-settings metachange text_fixes unithand-change2 webclient-ai-attitude current_research_cost freeciv-svn-webclient-changes network-rewrite-1 fcnet_packets misc_devversion_sync scenario_ruleset savegame savegame2 maphand_ch serverside_extra_assign libtoolize_no_symlinks spacerace city_disbandable ai_traits_crash unittools ruleset-capability worklists server_password aifill barbarian-names activity_null_check add_rulesets NoDeltaHeader city_traderoute_hotfix order_validation_feed_back action_order fix_unit_order_action_validation dev_save_compat action_order_savegame_compat"

apply_patch() {
echo "*** Applying $1.patch ***"
Expand Down
33 changes: 28 additions & 5 deletions freeciv/patches/action_order_savegame_compat.patch
Original file line number Diff line number Diff line change
@@ -1,22 +1,45 @@
From 6d249217ec4a2d834b83d1334616122bca763c56 Mon Sep 17 00:00:00 2001
From: Sveinung Kvilhaugsvik <[email protected]>
Date: Mon, 3 Aug 2015 21:39:41 +0200
Subject: [PATCH 8/8] Development version save game compatibility for action
less unit orders

Load unit orders from 3.0 development version save games that were stored
before the action_list field was added.
---
server/savegame3.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/server/savegame3.c b/server/savegame3.c
index cc0c0b2..8b98e4e 100644
index 22f3851..e0e26aa 100644
--- a/server/savegame3.c
+++ b/server/savegame3.c
@@ -5091,7 +5091,7 @@ static bool sg_load_player_unit(struct loaddata *loading,
@@ -5091,7 +5091,10 @@ static bool sg_load_player_unit(struct loaddata *loading,
struct unit_order *order = &punit->orders.list[j];

if (orders_unitstr[j] == '\0' || dir_unitstr[j] == '\0'
- || act_unitstr[j] == '\0' || action_unitstr == '\0') {
- || act_unitstr[j] == '\0' || action_unitstr[j] == '\0') {
+#ifndef FREECIV_DEV_SAVE_COMPAT
+ || action_unitstr[j] == '\0'
+#endif /* FREECIV_DEV_SAVE_COMPAT */
+ || act_unitstr[j] == '\0') {
log_sg("Invalid unit orders.");
free_unit_orders(punit);
break;
@@ -5100,7 +5100,7 @@ static bool sg_load_player_unit(struct loaddata *loading,
@@ -5100,7 +5103,12 @@ static bool sg_load_player_unit(struct loaddata *loading,
order->dir = char2dir(dir_unitstr[j]);
order->activity = char2activity(act_unitstr[j]);

- order->action = (action_unitstr[j] == '?'
+ order->action = (action_unitstr == '\0' || action_unitstr[j] == '?'
+ order->action = (
+#ifdef FREECIV_DEV_SAVE_COMPAT
+ action_unitstr[0] == '\0'
+ ||
+#endif /* FREECIV_DEV_SAVE_COMPAT */
+ action_unitstr[j] == '?'
? ACTION_COUNT
: char2num(action_unitstr[j]));

--
2.1.4

63 changes: 63 additions & 0 deletions freeciv/patches/dev_save_compat.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
From bcaf1cd98c53ab23da4f2053c0181ad4665ef300 Mon Sep 17 00:00:00 2001
From: Sveinung Kvilhaugsvik <[email protected]>
Date: Mon, 3 Aug 2015 18:58:14 +0200
Subject: [PATCH 7/8] Development version savegame compatibility

The save game format usually changes many times during the development of a
new version of Freeciv. Permanently carrying support for loading every
development version save game format isn't sustainable. The support for
loading save games from previously released versions is enough.

At the same time it would be nice to be able to load that game started with
last week's development version. Not having your save games broken on every
upgrade would help motivate testers. It would also make Freeciv-web's life
easier.

I think a reasonable compromise is to have clearly marked development
version internal save game compatibility code. The compatibility code should
always be removed before a release to take care of the sustainability issue.
It may also be removed during a development version if the backwards
compatibility becomes a large burden.

The marking should be machine readable to make it easy to remove all
development version internal save game compatibility code sections at once.
It should also be possible to build a development version without any
compatibility code so save game loading error handling code can be tested.

Add the new configure option --enable-dev-save-compat. If enabled the new
symbol FREECIV_DEV_SAVE_COMPAT is defined. Development version save game
compatibility code sections can then be marked using regular macros.

See patch #6154
---
configure.ac | 14 ++++++++++++++
1 file changed, 14 insertions(+)

diff --git a/configure.ac b/configure.ac
index 88849a7..b0349b9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -229,6 +229,20 @@ AC_ARG_WITH([appdatadir],
[ APPDATADIR=${withval} ], [ APPDATADIR="\$(prefix)/share/appdata" ])
AC_SUBST([APPDATADIR])

+dnl try to support this development version's previous save games formats
+AC_ARG_ENABLE([dev-save-compat],
+ AS_HELP_STRING([--enable-dev-save-compat=yes/no],
+ [enable development version save game compatibility]),
+ [case "${enableval}" in
+ yes) dev_save_compat=1 ;;
+ no) dev_save_compat=0 ;;
+ *) AC_MSG_ERROR([bad value ${enableval} for --enable-dev-save-compat]) ;;
+ esac],
+ [dev_save_compat=$IS_DEVEL_VERSION])
+AS_IF([test $dev_save_compat != 0],
+ [AC_DEFINE([FREECIV_DEV_SAVE_COMPAT], [1],
+ [Development version save game compatibility])])
+
dnl set default values
mapimg_all=auto
mapimg_magickwand=no
--
2.1.4

26 changes: 26 additions & 0 deletions freeciv/patches/fix_unit_order_action_validation.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
From 67bfbf52e2c2b466726b289f6025e8734a892ec7 Mon Sep 17 00:00:00 2001
From: Sveinung Kvilhaugsvik <[email protected]>
Date: Sun, 2 Aug 2015 00:36:00 +0200
Subject: [PATCH] Fix the unit-order-has-an-action save game loading
validation

---
server/savegame3.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/server/savegame3.c b/server/savegame3.c
index cc0c0b2..906853c 100644
--- a/server/savegame3.c
+++ b/server/savegame3.c
@@ -5091,7 +5091,7 @@ static bool sg_load_player_unit(struct loaddata *loading,
struct unit_order *order = &punit->orders.list[j];

if (orders_unitstr[j] == '\0' || dir_unitstr[j] == '\0'
- || act_unitstr[j] == '\0' || action_unitstr == '\0') {
+ || act_unitstr[j] == '\0' || action_unitstr[j] == '\0') {
log_sg("Invalid unit orders.");
free_unit_orders(punit);
break;
--
2.1.4

0 comments on commit a34d824

Please sign in to comment.