Author: cazfi
Date: Sat Jan  2 00:16:10 2016
New Revision: 31293

URL: http://svn.gna.org/viewcvs/freeciv?rev=31293&view=rev
Log:
Add player 'turns_alive' and 'last_war' in savecompat 2.5 to 2.6 conversion 
function.

See bug #24248

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=31293&r1=31292&r2=31293&view=diff
==============================================================================
--- trunk/server/savecompat.c   (original)
+++ trunk/server/savecompat.c   Sat Jan  2 00:16:10 2016
@@ -603,6 +603,7 @@
   bool team_pooled_research = GAME_DEFAULT_TEAM_POOLED_RESEARCH;
   int tsize;
   int ti;
+  int turn;
 
   /* Check status and return if not OK (sg_success != TRUE). */
   sg_check_ret();
@@ -824,6 +825,8 @@
   sg_failure_ret(secfile_lookup_int(loading->file, &tsize, 
"savefile.trait_size"),
                  "Trait size: %s", secfile_error());
 
+  turn = secfile_lookup_int_default(loading->file, 0, "game.turn");
+
   for (plrno = 0; plrno < nplayers; plrno++) {
     bool got_first_city;
     int old_barb_type;
@@ -854,6 +857,13 @@
     new_barb_type = barb_type_convert(old_barb_type);
     secfile_insert_str(loading->file, barbarian_type_name(new_barb_type),
                        "player%d.ai.barb_type", plrno);
+
+    /* Pre-2.6 didn't record when a player was created or died, so we have
+     * to assume they lived from the start of the game until last turn */
+    secfile_insert_int(loading->file, turn, "player%d.turns_alive", plrno);
+
+    /* As if there never has been a war. */
+    secfile_insert_int(loading->file, -1, "player%d.last_war", plrno); 
 
     for (i = 0; i < tsize; i++) {
       int val;

Modified: trunk/server/savegame2.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/savegame2.c?rev=31293&r1=31292&r2=31293&view=diff
==============================================================================
--- trunk/server/savegame2.c    (original)
+++ trunk/server/savegame2.c    Sat Jan  2 00:16:10 2016
@@ -2945,13 +2945,12 @@
   sg_failure_ret(secfile_lookup_bool(loading->file, &plr->is_alive,
                                      "player%d.is_alive", plrno),
                  "%s", secfile_error());
-  /* Pre-2.6 didn't record when a player was created or died, so we have
-   * to assume they lived from the start of the game until last turn */
-  plr->turns_alive = secfile_lookup_int_default(loading->file,
-                                                game.info.turn,
-                                                "player%d.turns_alive", plrno);
-  plr->last_war_action = secfile_lookup_int_default(loading->file, -1,
-                                                    "player%d.last_war", 
plrno);
+  sg_failure_ret(secfile_lookup_int(loading->file, &plr->turns_alive,
+                                    "player%d.turns_alive", plrno),
+                 "%s", secfile_error());
+  sg_failure_ret(secfile_lookup_int(loading->file, &plr->last_war_action,
+                                    "player%d.last_war", plrno),
+                 "%s", secfile_error());
   plr->phase_done = secfile_lookup_bool_default(loading->file, FALSE,
                                                 "player%d.phase_done", plrno);
   sg_failure_ret(secfile_lookup_int(loading->file, &plr->economic.gold,

Modified: trunk/server/savegame3.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/savegame3.c?rev=31293&r1=31292&r2=31293&view=diff
==============================================================================
--- trunk/server/savegame3.c    (original)
+++ trunk/server/savegame3.c    Sat Jan  2 00:16:10 2016
@@ -3745,8 +3745,9 @@
   sg_failure_ret(secfile_lookup_int(loading->file, &plr->turns_alive,
                                     "player%d.turns_alive", plrno),
                  "%s", secfile_error());
-  plr->last_war_action = secfile_lookup_int_default(loading->file, -1,
-                                                    "player%d.last_war", 
plrno);
+  sg_failure_ret(secfile_lookup_int(loading->file, &plr->last_war_action,
+                                    "player%d.last_war", plrno),
+                 "%s", secfile_error());
   plr->phase_done = secfile_lookup_bool_default(loading->file, FALSE,
                                                 "player%d.phase_done", plrno);
   sg_failure_ret(secfile_lookup_int(loading->file, &plr->economic.gold,


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

Reply via email to