Author: cazfi
Date: Thu Jun 11 23:38:27 2015
New Revision: 29164

URL: http://svn.gna.org/viewcvs/freeciv?rev=29164&view=rev
Log:
Fixed loading of trait values from 2.6+ savegames. Conversion from older 
savegames
is still broken.

Reported by Jacob Nevins <jtn>

See bug #23564

Modified:
    branches/S2_6/server/savegame2.c

Modified: branches/S2_6/server/savegame2.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/savegame2.c?rev=29164&r1=29163&r2=29164&view=diff
==============================================================================
--- branches/S2_6/server/savegame2.c    (original)
+++ branches/S2_6/server/savegame2.c    Thu Jun 11 23:38:27 2015
@@ -3634,9 +3634,9 @@
       /* TRANS: Minor error message: <Leader> ... <Poles>. */
       log_sg(_("%s had invalid nation; changing to %s."),
              player_name(pplayer), nation_plural_for_player(pplayer));
-    }
-
-    ai_traits_init(pplayer);
+
+      ai_traits_init(pplayer);
+    }
   } players_iterate_end;
 
   /* Sanity check alliances, prevent allied-with-ally-of-enemy. */
@@ -3818,6 +3818,9 @@
   /* Nation */
   string = secfile_lookup_str(loading->file, "player%d.nation", plrno);
   player_set_nation(plr, nation_by_rule_name(string));
+  if (plr->nation != NULL) {
+    ai_traits_init(plr);
+  }
 
   /* Government */
   string = secfile_lookup_str(loading->file, "player%d.government_name",
@@ -3995,22 +3998,22 @@
                                "player%d.research.bulbs_last_turn", plrno);
 
   /* Traits */
-  {
+  if (plr->nation) {
     for (i = 0; i < loading->trait.size; i++) {
       enum trait tr = trait_by_name(loading->trait.order[i], fc_strcasecmp);
 
       if (trait_is_valid(tr)) {
-        int val = secfile_lookup_int_default(loading->file, -1, 
"plr%d.trait%d.val",
+        int val = secfile_lookup_int_default(loading->file, -1, 
"player%d.trait%d.val",
                                              plrno, i);
 
         if (val != -1) {
           plr->ai_common.traits[tr].val = val;
         }
 
-        if (secfile_lookup_int(loading->file, &val,
-                               "plr%d.trait%d.mod", plrno, i)) {
-          plr->ai_common.traits[tr].mod = val;
-        }
+        sg_failure_ret(secfile_lookup_int(loading->file, &val,
+                                          "player%d.trait%d.mod", plrno, i),
+                       "%s", secfile_error());
+        plr->ai_common.traits[tr].mod = val;
       }
     }
   }


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

Reply via email to