Author: cazfi
Date: Fri Feb 19 08:09:12 2016
New Revision: 31982

URL: http://svn.gna.org/viewcvs/freeciv?rev=31982&view=rev
Log:
Save player sex by name to savegame3 saves.

See patch #6960

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

Modified: trunk/server/savecompat.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/savecompat.c?rev=31982&r1=31981&r2=31982&view=diff
==============================================================================
--- trunk/server/savecompat.c   (original)
+++ trunk/server/savecompat.c   Fri Feb 19 08:09:12 2016
@@ -1511,6 +1511,14 @@
       secfile_insert_int(loading->file, 0, "player%d.idle_turns", plrno);
     }
 
+    if (secfile_entry_lookup(loading->file, "player%d.sex", plrno) == NULL) {
+      if (secfile_lookup_bool_default(loading->file, TRUE, "player%d.is_male", 
plrno)) {
+        secfile_insert_str(loading->file, "male", "player%d.sex", plrno);
+      } else {
+        secfile_insert_str(loading->file, "female", "player%d.sex", plrno);
+      }
+    }
+
     ncities = secfile_lookup_int_default(loading->file, 0, "player%d.ncities", 
plrno);
 
     for (i = 0; i < ncities; i++) {

Modified: trunk/server/savegame3.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/savegame3.c?rev=31982&r1=31981&r2=31982&view=diff
==============================================================================
--- trunk/server/savegame3.c    (original)
+++ trunk/server/savegame3.c    Fri Feb 19 08:09:12 2016
@@ -3499,6 +3499,7 @@
   const char *level;
   const char *barb_str;
   size_t nval;
+  const char *sex;
 
   /* Check status and return if not OK (sg_success != TRUE). */
   sg_check_ret();
@@ -3688,8 +3689,12 @@
   sg_failure_ret(secfile_lookup_int(loading->file, &plr->nturns_idle,
                                     "player%d.idle_turns", plrno),
                  "%s", secfile_error());
-  plr->is_male = secfile_lookup_bool_default(loading->file, TRUE,
-                                             "player%d.is_male", plrno);
+  sex = secfile_lookup_str(loading->file, "player%d.sex", plrno);
+  if (!strcmp("male", sex)) {
+    plr->is_male = TRUE;
+  } else {
+    plr->is_male = FALSE;
+  }
   sg_failure_ret(secfile_lookup_bool(loading->file, &plr->is_alive,
                                      "player%d.is_alive", plrno),
                  "%s", secfile_error());
@@ -4016,8 +4021,13 @@
 
   secfile_insert_int(saving->file, plr->nturns_idle,
                      "player%d.idle_turns", plrno);
-  secfile_insert_bool(saving->file, plr->is_male,
-                      "player%d.is_male", plrno);
+  if (plr->is_male) {
+    secfile_insert_str(saving->file, "male",
+                       "player%d.sex", plrno);
+  } else {
+    secfile_insert_str(saving->file, "female",
+                       "player%d.sex", plrno);
+  }
   secfile_insert_bool(saving->file, plr->is_alive,
                       "player%d.is_alive", plrno);
   secfile_insert_int(saving->file, plr->turns_alive,


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

Reply via email to