Author: cazfi
Date: Mon Aug  3 17:29:35 2015
New Revision: 29309

URL: http://svn.gna.org/viewcvs/freeciv?rev=29309&view=rev
Log:
Fixed converting trait values from pre-2.6 savegames.

Reported by Jacob Nevins <jtn>

See bug #23598

Modified:
    trunk/server/savecompat.c

Modified: trunk/server/savecompat.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/savecompat.c?rev=29309&r1=29308&r2=29309&view=diff
==============================================================================
--- trunk/server/savecompat.c   (original)
+++ trunk/server/savecompat.c   Mon Aug  3 17:29:35 2015
@@ -470,6 +470,7 @@
   log_debug("Upgrading data from savegame to version 2.5.0");
 
   secfile_insert_int(loading->file, 2, "savefile.roads_size");
+  secfile_insert_int(loading->file, 0, "savefile.trait_size");
 
   secfile_insert_str_vec(loading->file, modname, 2,
                          "savefile.roads_vector");
@@ -563,6 +564,7 @@
   int nplayers;
   int plrno;
   bool team_pooled_research = GAME_DEFAULT_TEAM_POOLED_RESEARCH;
+  int tsize;
 
   /* Check status and return if not OK (sg_success != TRUE). */
   sg_check_ret();
@@ -757,6 +759,9 @@
 
   nplayers = secfile_lookup_int_default(loading->file, 0, "players.nplayers");
 
+  sg_failure_ret(secfile_lookup_int(loading->file, &tsize, 
"savefile.trait_size"),
+                 "Trait size: %s", secfile_error());
+
   for (plrno = 0; plrno < nplayers; plrno++) {
     bool got_first_city;
     int old_barb_type;
@@ -777,19 +782,19 @@
     secfile_insert_str(loading->file, barbarian_type_name(new_barb_type),
                        "player%d.ai.barb_type", plrno);
 
-    for (i = 0; i < loading->trait.size; i++) {
+    for (i = 0; i < tsize; i++) {
       int val;
 
-      val = secfile_lookup_int_default(loading->file, -1, "pĺr%d.trait.val%d",
+      val = secfile_lookup_int_default(loading->file, -1, 
"player%d.trait.val%d",
                                        plrno, i);
       if (val != -1) {
-        secfile_insert_int(loading->file, val, "plr%d.trait%d.val", plrno, i);
-      }
-
-      if (secfile_lookup_int(loading->file, &val, "plr%d.trait.mod%d", plrno, 
i)) {
-        log_sg("Trait mod: %s", secfile_error());
-      }
-      secfile_insert_int(loading->file, val, "plr%d.trait%d.mod", plrno, i);
+        secfile_insert_int(loading->file, val, "player%d.trait%d.val", plrno, 
i);
+      }
+
+      sg_failure_ret(secfile_lookup_int(loading->file, &val,
+                                        "player%d.trait.mod%d", plrno, i),
+                     "Trait mod: %s", secfile_error());
+      secfile_insert_int(loading->file, val, "player%d.trait%d.mod", plrno, i);
     }
   }
 


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

Reply via email to