Author: cazfi
Date: Sun Dec 20 11:55:52 2015
New Revision: 31106

URL: http://svn.gna.org/viewcvs/freeciv?rev=31106&view=rev
Log:
Updated savegame2.c to handle savegame format produced by the 2.6 to 3.0 
compatibility
callback.

See bug #24183

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

Modified: trunk/server/savecompat.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/savecompat.c?rev=31106&r1=31105&r2=31106&view=diff
==============================================================================
--- trunk/server/savecompat.c   (original)
+++ trunk/server/savecompat.c   Sun Dec 20 11:55:52 2015
@@ -1123,6 +1123,9 @@
 
 /****************************************************************************
   Translate savegame secfile data from 2.6.x to 3.0.0 format.
+  Note that even after 2.6 savegame has gone through this compatibility
+  function, it's still 2.6 savegame in the sense that savegame2.c, and not
+  savegame3.c, handles it.
 ****************************************************************************/
 static void compat_load_030000(struct loaddata *loading)
 {

Modified: trunk/server/savegame2.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/savegame2.c?rev=31106&r1=31105&r2=31106&view=diff
==============================================================================
--- trunk/server/savegame2.c    (original)
+++ trunk/server/savegame2.c    Sun Dec 20 11:55:52 2015
@@ -1646,17 +1646,17 @@
   /* Check status and return if not OK (sg_success != TRUE). */
   sg_check_ret();
 
-  if (secfile_lookup_bool_default(loading->file, FALSE, "random.save")) {
+  if (secfile_lookup_bool_default(loading->file, FALSE, "random.saved")) {
     const char *string;
     int i;
 
     /* Since random state was previously saved, save it also when resaving.
      * This affects only pre-2.6 scenarios where scenario.save_random
      * is not defined.
-     * - If this is 2.6 or later scenario -> it would have saved random.save = 
TRUE
+     * - If this is 2.6 or later scenario -> it would have saved random.saved 
= TRUE
      *   only if scenario.save_random is already TRUE
      *
-     * Do NOT touch this in case of regular savegame. They always have 
random.save
+     * Do NOT touch this in case of regular savegame. They always have 
random.saved
      * set, but if one starts to make scenario based on a savegame, we want
      * default scenario settings in the beginning (default save_random = 
FALSE).
      */
@@ -1683,7 +1683,7 @@
     fc_rand_set_state(loading->rstate);
   } else {
     /* No random values - mark the setting. */
-    (void) secfile_entry_by_path(loading->file, "random.save");
+    (void) secfile_entry_by_path(loading->file, "random.saved");
 
     /* We're loading a game without a seed (which is okay, if it's a scenario).
      * We need to generate the game seed now because it will be needed later
@@ -2722,12 +2722,13 @@
 static void sg_load_player_main(struct loaddata *loading,
                                 struct player *plr)
 {
+  const char **slist;
   int i, plrno = player_number(plr);
   const char *string;
   struct government *gov;
   const char *level;
   const char *barb_str;
-  bool ai_controlled;
+  size_t nval;
 
   /* Check status and return if not OK (sg_success != TRUE). */
   sg_check_ret();
@@ -2757,6 +2758,17 @@
     player_delegation_set(plr, string);
   }
 
+  /* Player flags */
+  BV_CLR_ALL(plr->flags);
+  slist = secfile_lookup_str_vec(loading->file, &nval, "player%d.flags", 
plrno);
+  for (i = 0; i < nval; i++) {
+    const char *sval = slist[i];
+    enum plr_flag_id fid = plr_flag_id_by_name(sval, fc_strcasecmp);
+
+    BV_SET(plr->flags, fid);
+  }
+  free(slist);
+
   /* Nation */
   string = secfile_lookup_str(loading->file, "player%d.nation", plrno);
   player_set_nation(plr, nation_by_rule_name(string));
@@ -2788,15 +2800,6 @@
                                      &plr->server.got_first_city,
                                      "player%d.got_first_city", plrno),
                  "%s", secfile_error());
-
-  sg_failure_ret(secfile_lookup_bool(loading->file, &ai_controlled,
-                                     "player%d.ai.control", plrno),
-                 "%s", secfile_error());
-  if (ai_controlled) {
-    set_as_ai(player_by_number(plrno));
-  } else {
-    set_as_human(player_by_number(plrno));
-  }
 
   /* Load diplomatic data (diplstate + embassy + vision).
    * Shared vision is loaded in sg_load_players(). */


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

Reply via email to