Author: cazfi
Date: Wed Sep 16 05:25:15 2015
New Revision: 29900

URL: http://svn.gna.org/viewcvs/freeciv?rev=29900&view=rev
Log:
Save History Report of the current turn to savegames.

See patch #6199

Modified:
    branches/S2_6/server/report.c
    branches/S2_6/server/report.h
    branches/S2_6/server/savegame2.c

Modified: branches/S2_6/server/report.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/report.c?rev=29900&r1=29899&r2=29900&view=diff
==============================================================================
--- branches/S2_6/server/report.c       (original)
+++ branches/S2_6/server/report.c       Wed Sep 16 05:25:15 2015
@@ -1681,3 +1681,11 @@
     len -= plen;
   }
 }
+
+/**************************************************************************
+  Return current history report
+**************************************************************************/
+struct history_report *history_report_get(void)
+{
+  return &latest_history_report;
+}

Modified: branches/S2_6/server/report.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/report.h?rev=29900&r1=29899&r2=29900&view=diff
==============================================================================
--- branches/S2_6/server/report.h       (original)
+++ branches/S2_6/server/report.h       Wed Sep 16 05:25:15 2015
@@ -44,4 +44,6 @@
 void report_achievements(struct connection *pconn);
 void report_final_scores(struct conn_list *dest);
 
+struct history_report *history_report_get(void);
+
 #endif  /* FC__REPORT_H */

Modified: branches/S2_6/server/savegame2.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/savegame2.c?rev=29900&r1=29899&r2=29900&view=diff
==============================================================================
--- branches/S2_6/server/savegame2.c    (original)
+++ branches/S2_6/server/savegame2.c    Wed Sep 16 05:25:15 2015
@@ -116,6 +116,7 @@
 #include "meta.h"
 #include "notify.h"
 #include "plrhand.h"
+#include "report.h"
 #include "ruleset.h"
 #include "sanitycheck.h"
 #include "savecompat.h"
@@ -449,6 +450,9 @@
 
 static void sg_load_treaties(struct loaddata *loading);
 
+static void sg_load_history(struct loaddata *loading);
+static void sg_save_history(struct savedata *saving);
+
 static void sg_load_mapimg(struct loaddata *loading);
 static void sg_save_mapimg(struct savedata *saving);
 
@@ -568,6 +572,8 @@
   sg_load_event_cache(loading);
   /* [treaties] */
   sg_load_treaties(loading);
+  /* [history] */
+  sg_load_history(loading);
   /* [mapimg] */
   sg_load_mapimg(loading);
 
@@ -624,6 +630,8 @@
   sg_save_event_cache(saving);
   /* [treaty<i>] */
   sg_save_treaties(saving);
+  /* [history] */
+  sg_save_history(saving);
   /* [mapimg] */
   sg_save_mapimg(saving);
 
@@ -6823,6 +6831,48 @@
 }
 
 /* =======================================================================
+ * Load / save the history report
+ * ======================================================================= */
+
+/****************************************************************************
+  Load '[history]'.
+****************************************************************************/
+static void sg_load_history(struct loaddata *loading)
+{
+  struct history_report *hist = history_report_get();
+  int turn;
+
+  turn = secfile_lookup_int_default(loading->file, -2, "history.turn");
+
+  if (turn + 1 >= game.info.turn) {
+    const char *str;
+
+    hist->turn = turn;
+    str = secfile_lookup_str(loading->file, "history.title");
+    sg_failure_ret(str != NULL, "%s", secfile_error());
+    strncpy(hist->title, str, REPORT_TITLESIZE);
+    str = secfile_lookup_str(loading->file, "history.body");
+    sg_failure_ret(str != NULL, "%s", secfile_error());
+    strncpy(hist->body, str, REPORT_BODYSIZE);
+  }
+}
+
+/****************************************************************************
+  Save '[history]'.
+****************************************************************************/
+static void sg_save_history(struct savedata *saving)
+{
+  struct history_report *hist = history_report_get();
+
+  secfile_insert_int(saving->file, hist->turn, "history.turn");
+
+  if (hist->turn + 1 >= game.info.turn) {
+    secfile_insert_str(saving->file, hist->title, "history.title");
+    secfile_insert_str(saving->file, hist->body, "history.body");
+  }
+}
+
+/* =======================================================================
  * Load / save the mapimg definitions.
  * ======================================================================= */
 


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

Reply via email to