Author: cazfi
Date: Wed Nov 11 19:11:05 2015
New Revision: 30548

URL: http://svn.gna.org/viewcvs/freeciv?rev=30548&view=rev
Log:
Support the new special meaning of 'default' rulesetdir in 2.6 savegames 
already.
In older savegames it means ruleset actually named 'default' (former name of 
the classic ruleset)
but in 2.6 and later it tells to use what ever is the freeciv default. Savegame 
is never
saved with that rulesetdir value, but it can occur only in manually edited 
scenarios.
This is mostly meant to be used in supplied rulesets that should work both on 
desktop freeciv
and freeciv-web version, and which are guaranteed to be exact match to the 
freeciv version in use.
Custom scenarios setting rulesetdir to 'default' risk freeciv default to change 
incompatible way
while the scenario saveformat version remains within compatibility range.

See patch #6541

Modified:
    trunk/server/savecompat.c
    trunk/server/savegame2.c
    trunk/server/savegame3.c

Modified: trunk/server/savecompat.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/savecompat.c?rev=30548&r1=30547&r2=30548&view=diff
==============================================================================
--- trunk/server/savecompat.c   (original)
+++ trunk/server/savecompat.c   Wed Nov 11 19:11:05 2015
@@ -602,11 +602,21 @@
   int plrno;
   bool team_pooled_research = GAME_DEFAULT_TEAM_POOLED_RESEARCH;
   int tsize;
+  const char *rs;
 
   /* Check status and return if not OK (sg_success != TRUE). */
   sg_check_ret();
 
   log_debug("Upgrading data from savegame to version 2.6.0");
+
+  rs = secfile_lookup_str_default(loading->file, GAME_DEFAULT_RULESETDIR,
+                                  "savefile.rulesetdir");
+
+  if (!strcmp("default", rs)) {
+    /* In pre-2.6 savegames 'default' rulesetdir means old name of the
+     * classic ruleset. */
+    secfile_replace_str(loading->file, "classic", "savefile.rulesetdir");
+  }
 
   /* Server setting migration. */
   {

Modified: trunk/server/savegame2.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/savegame2.c?rev=30548&r1=30547&r2=30548&view=diff
==============================================================================
--- trunk/server/savegame2.c    (original)
+++ trunk/server/savegame2.c    Wed Nov 11 19:11:05 2015
@@ -1109,10 +1109,11 @@
   sz_strlcpy(game.server.rulesetdir,
              secfile_lookup_str_default(loading->file, GAME_DEFAULT_RULESETDIR,
                                         "savefile.rulesetdir"));
-  /* In 'savegame2' saves 'default' means the old name of 'classic'
-   * ruleset. So load it as 'classic' ruleset, not the current default. */
   if (!strcmp("default", game.server.rulesetdir)) {
-    sz_strlcpy(game.server.rulesetdir, "classic");
+    /* Here 'default' really means current default.
+     * Saving happens with real ruleset name, so savegames containing this
+     * are special scenarios. */
+    sz_strlcpy(game.server.rulesetdir, GAME_DEFAULT_RULESETDIR);
   }
   if (!load_rulesets(NULL, FALSE, TRUE, FALSE)) {
     /* Failed to load correct ruleset */

Modified: trunk/server/savegame3.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/savegame3.c?rev=30548&r1=30547&r2=30548&view=diff
==============================================================================
--- trunk/server/savegame3.c    (original)
+++ trunk/server/savegame3.c    Wed Nov 11 19:11:05 2015
@@ -1344,10 +1344,10 @@
     sz_strlcpy(game.server.rulesetdir,
                secfile_lookup_str_default(loading->file, 
GAME_DEFAULT_RULESETDIR,
                                           "savefile.rulesetdir"));
-    /* In 'savegame3' saves 'default' really means current default.
+    if (!strcmp("default", game.server.rulesetdir)) {
+      /* Here 'default' really means current default.
      * Saving happens with real ruleset name, so savegames containing this
      * are special scenarios. */
-    if (!strcmp("default", game.server.rulesetdir)) {
       sz_strlcpy(game.server.rulesetdir, GAME_DEFAULT_RULESETDIR);
     }
     if (!load_rulesets(NULL, FALSE, TRUE, FALSE)) {


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to