Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2006:
[Freeciv-Dev] Re: (PR#15609) S2_1 can't load savegames saved with HEAD
Home

[Freeciv-Dev] Re: (PR#15609) S2_1 can't load savegames saved with HEAD

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: himasaram@xxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#15609) S2_1 can't load savegames saved with HEAD
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Sun, 19 Feb 2006 04:47:14 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=15609 >

On Sat, 18 Feb 2006, Daniel Markstedt wrote:
> Try loading this save (created by HEAD) with S2_1:
>
> 0: sectionfile civgame-3000.sav.gz doesn't contain a 'game.unhappysize'
> entry

Patch attached. Replaces many required lookups to fallback to default
lookups. It is a bit useless to have the savegame code set game variables
to default values, though, since they will already have been set to
default values in common/game.c anyway by the time we get here. However
this is the way it has been done so far and there is no section file
lookup function that changes a variable only if a lookup is successful.

The savegame code really needs a redesign.

  - Per

Index: server/savegame.c
===================================================================
--- server/savegame.c   (revision 11621)
+++ server/savegame.c   (working copy)
@@ -3506,37 +3506,42 @@
     game.info.warminglevel  = secfile_lookup_int(file, "game.warminglevel");
     game.info.cooling = secfile_lookup_int_default(file, 0, "game.cooling");
     game.info.nuclearwinter = secfile_lookup_int_default(file, 0, 
"game.nuclearwinter");
-    game.info.coolinglevel  = secfile_lookup_int_default(file, 8, 
"game.coolinglevel");
-    game.info.notradesize   = secfile_lookup_int_default(file, 0, 
"game.notradesize");
-    game.info.fulltradesize = secfile_lookup_int_default(file, 1, 
"game.fulltradesize");
-    game.info.unhappysize   = secfile_lookup_int(file, "game.unhappysize");
-    game.info.angrycitizen  = secfile_lookup_bool_default(file, FALSE, 
"game.angrycitizen");
+    game.info.coolinglevel = secfile_lookup_int_default(file, 8, 
"game.coolinglevel");
+    game.info.notradesize = 
+      secfile_lookup_int_default(file, GAME_DEFAULT_NOTRADESIZE, 
"game.notradesize");
+    game.info.fulltradesize = 
+      secfile_lookup_int_default(file, GAME_DEFAULT_FULLTRADESIZE, 
"game.fulltradesize");
+    game.info.unhappysize = 
+      secfile_lookup_int_default(file, GAME_DEFAULT_UNHAPPYSIZE, 
"game.unhappysize");
+    game.info.angrycitizen = 
+      secfile_lookup_bool_default(file, GAME_DEFAULT_ANGRYCITIZEN, 
"game.angrycitizen");
+    game.info.cityfactor  = 
+      secfile_lookup_int_default(file, GAME_DEFAULT_CITYFACTOR, 
"game.cityfactor");
+    game.info.diplcost    = 
+      secfile_lookup_int_default(file, GAME_DEFAULT_DIPLCOST, "game.diplcost");
+    game.info.freecost    = 
+      secfile_lookup_int_default(file, GAME_DEFAULT_FREECOST, "game.freecost");
+    game.info.conquercost = 
+      secfile_lookup_int_default(file, GAME_DEFAULT_CONQUERCOST, 
"game.conquercost");
+    game.info.foodbox  = secfile_lookup_int_default(file, 0, "game.box_food");
+    if (game.info.foodbox == 0) {
+      /* foodbox was used for 2.0 and earlier servers. */
+      game.info.foodbox = 10 * secfile_lookup_int_default(file, 100, 
"game.foodbox");
+    }
+    game.info.techpenalty = 
+      secfile_lookup_int_default(file, GAME_DEFAULT_TECHPENALTY, 
"game.techpenalty");
+    game.info.razechance  = 
+      secfile_lookup_int_default(file, GAME_DEFAULT_RAZECHANCE, 
"game.razechance");
+    game.info.save_nturns = 
+      secfile_lookup_int_default(file, GAME_DEFAULT_SAVETURNS, 
"game.save_nturns");
 
-    if (game.version >= 10100) {
-      game.info.cityfactor  = secfile_lookup_int(file, "game.cityfactor");
-      game.info.diplcost    = secfile_lookup_int(file, "game.diplcost");
-      game.info.freecost    = secfile_lookup_int(file, "game.freecost");
-      game.info.conquercost = secfile_lookup_int(file, "game.conquercost");
-      game.info.foodbox
-       = secfile_lookup_int_default(file, 0, "game.box_food");
-      if (game.info.foodbox == 0) {
-       /* foodbox was used for 2.0 and earlier servers. */
-       game.info.foodbox = 10 * secfile_lookup_int(file, "game.foodbox");
-      }
-      game.info.techpenalty = secfile_lookup_int(file, "game.techpenalty");
-      game.info.razechance  = secfile_lookup_int(file, "game.razechance");
+    /* suppress warnings about unused entries in old savegames: */
+    (void) section_file_lookup(file, "game.rail_food");
+    (void) section_file_lookup(file, "game.rail_prod");
+    (void) section_file_lookup(file, "game.rail_trade");
+    (void) section_file_lookup(file, "game.farmfood");
+    civstyle = secfile_lookup_int_default(file, 2, "game.civstyle");
 
-      /* suppress warnings about unused entries in old savegames: */
-      (void) section_file_lookup(file, "game.rail_food");
-      (void) section_file_lookup(file, "game.rail_prod");
-      (void) section_file_lookup(file, "game.rail_trade");
-      (void) section_file_lookup(file, "game.farmfood");
-    }
-    if (game.version >= 10300) {
-      civstyle = secfile_lookup_int_default(file, 2, "game.civstyle");
-      game.info.save_nturns = secfile_lookup_int(file, "game.save_nturns");
-    }
-
     game.info.citymindist  = secfile_lookup_int_default(file,
       GAME_DEFAULT_CITYMINDIST, "game.citymindist");
 

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] Re: (PR#15609) S2_1 can't load savegames saved with HEAD, Per I. Mathisen <=