Author: cazfi
Date: Sun Jan  8 08:21:02 2017
New Revision: 34798

URL: http://svn.gna.org/viewcvs/freeciv?rev=34798&view=rev
Log:
Use activities order from the savegame when loading it.

See patch #8066

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

Modified: trunk/server/savecompat.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/savecompat.h?rev=34798&r1=34797&r2=34798&view=diff
==============================================================================
--- trunk/server/savecompat.h   (original)
+++ trunk/server/savecompat.h   Sun Jan  8 08:21:02 2017
@@ -59,6 +59,11 @@
     const char **order;
     size_t size;
   } technology;
+  /* loaded in sg_load_savefile(); needed in sg_load_player() */
+  struct {
+    const char **order;
+    size_t size;
+  } activities;
   /* loaded in sg_load_savefile(); needed in sg_load_player() */
   struct {
     const char **order;

Modified: trunk/server/savegame2.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/savegame2.c?rev=34798&r1=34797&r2=34798&view=diff
==============================================================================
--- trunk/server/savegame2.c    (original)
+++ trunk/server/savegame2.c    Sun Jan  8 08:21:02 2017
@@ -455,6 +455,8 @@
   loading->improvement.size = -1;
   loading->technology.order = NULL;
   loading->technology.size = -1;
+  loading->activities.order = NULL;
+  loading->activities.size = -1;
   loading->trait.order = NULL;
   loading->trait.size = -1;
   loading->extra.order = NULL;
@@ -490,6 +492,10 @@
 
   if (loading->technology.order != NULL) {
     free(loading->technology.order);
+  }
+
+  if (loading->activities.order != NULL) {
+    free(loading->activities.order);
   }
 
   if (loading->trait.order != NULL) {
@@ -1145,6 +1151,19 @@
                                "savefile.technology_vector");
     sg_failure_ret(loading->improvement.size != 0,
                    "Failed to load technology order: %s",
+                   secfile_error());
+  }
+
+  /* Load Activities. */
+  loading->activities.size
+    = secfile_lookup_int_default(loading->file, 0,
+                                 "savefile.activities_size");
+  if (loading->activities.size) {
+    loading->activities.order
+      = secfile_lookup_str_vec(loading->file, &loading->activities.size,
+                               "savefile.activities_vector");
+    sg_failure_ret(loading->activities.size != 0,
+                   "Failed to load activity order: %s",
                    secfile_error());
   }
 
@@ -3758,7 +3777,8 @@
   sg_warn_ret_val(secfile_lookup_int(loading->file, &ei,
                                      "%s.activity", unitstr), FALSE,
                   "%s", secfile_error());
-  activity = ei;
+  activity = unit_activity_by_name(loading->activities.order[ei],
+                                   fc_strcasecmp);
 
   punit->server.birth_turn
     = secfile_lookup_int_default(loading->file, game.info.turn,

Modified: trunk/server/savegame3.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/savegame3.c?rev=34798&r1=34797&r2=34798&view=diff
==============================================================================
--- trunk/server/savegame3.c    (original)
+++ trunk/server/savegame3.c    Sun Jan  8 08:21:02 2017
@@ -571,6 +571,8 @@
   loading->improvement.size = -1;
   loading->technology.order = NULL;
   loading->technology.size = -1;
+  loading->activities.order = NULL;
+  loading->activities.size = -1;
   loading->trait.order = NULL;
   loading->trait.size = -1;
   loading->extra.order = NULL;
@@ -600,6 +602,10 @@
 
   if (loading->technology.order != NULL) {
     free(loading->technology.order);
+  }
+
+  if (loading->activities.order != NULL) {
+    free(loading->activities.order);
   }
 
   if (loading->trait.order != NULL) {
@@ -1338,6 +1344,19 @@
                                "savefile.technology_vector");
     sg_failure_ret(loading->improvement.size != 0,
                    "Failed to load technology order: %s",
+                   secfile_error());
+  }
+
+  /* Load Activities. */
+  loading->activities.size
+    = secfile_lookup_int_default(loading->file, 0,
+                                 "savefile.activities_size");
+  if (loading->activities.size) {
+    loading->activities.order
+      = secfile_lookup_str_vec(loading->file, &loading->activities.size,
+                               "savefile.activities_vector");
+    sg_failure_ret(loading->activities.size != 0,
+                   "Failed to load activity order: %s",
                    secfile_error());
   }
 
@@ -5118,7 +5137,8 @@
   sg_warn_ret_val(secfile_lookup_int(loading->file, &ei,
                                      "%s.activity", unitstr), FALSE,
                   "%s", secfile_error());
-  activity = ei;
+  activity = unit_activity_by_name(loading->activities.order[ei],
+                                   fc_strcasecmp);
 
   punit->server.birth_turn
     = secfile_lookup_int_default(loading->file, game.info.turn,


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

Reply via email to