forked from freeciv/freeciv-web
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use upstream work to do old save game upgrade
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
1 parent
af184f9
commit a34d824
Showing
4 changed files
with
121 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|