Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2005:
[Freeciv-Dev] (PR#12544) [Patch] Save reason
Home

[Freeciv-Dev] (PR#12544) [Patch] Save reason

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#12544) [Patch] Save reason
From: "Marko Lindqvist" <marko.lindqvist@xxxxxxxxxxx>
Date: Sat, 19 Mar 2005 04:33:49 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12544 >


  When analyzing savegames as part of bug hunting, it makes a difference 
if savegame is autosave or if it's user requested save, not to mention 
civworld generated saves.
  This patch adds that information to savegames.


  - ML


diff -Nurd -X.diff_ignore freeciv/server/savegame.c freeciv/server/savegame.c
--- freeciv/server/savegame.c   2005-03-19 10:42:21.109375000 +0200
+++ freeciv/server/savegame.c   2005-03-19 13:30:23.500000000 +0200
@@ -3076,6 +3076,10 @@
     exit(EXIT_FAILURE);
   }
 
+  /* We don't need savefile.reason, but read it anyway to avoid
+   * warnings about unread secfile entries. */
+  secfile_lookup_str_default(file, "None", "savefile.reason");
+
   {
     set_meta_patches_string(secfile_lookup_str_default(file, 
                                                 default_meta_patches_string(),
@@ -3591,7 +3595,7 @@
 /***************************************************************
 ...
 ***************************************************************/
-void game_save(struct section_file *file)
+void game_save(struct section_file *file, const char *save_reason)
 {
   int i;
   int version;
@@ -3626,6 +3630,7 @@
     }
   }
   secfile_insert_str(file, options, "savefile.options");
+  secfile_insert_str(file, save_reason, "savefile.reason");
   /* Save improvement order in savegame, so we are not dependent on
    * ruleset order.
    * If the game isn't started improvements aren't loaded
diff -Nurd -X.diff_ignore freeciv/server/savegame.h freeciv/server/savegame.h
--- freeciv/server/savegame.h   2005-03-19 10:42:21.125000000 +0200
+++ freeciv/server/savegame.h   2005-03-19 13:24:51.437500000 +0200
@@ -16,6 +16,6 @@
 #include "registry.h"
 
 void game_load(struct section_file *file);
-void game_save(struct section_file *file);
+void game_save(struct section_file *file, const char *save_reason);
 
 #endif /* FC__SAVEGAME_H */
diff -Nurd -X.diff_ignore freeciv/server/srv_main.c freeciv/server/srv_main.c
--- freeciv/server/srv_main.c   2005-03-19 10:42:21.343750000 +0200
+++ freeciv/server/srv_main.c   2005-03-19 13:24:14.296875000 +0200
@@ -108,7 +108,7 @@
 
 static void end_turn(void);
 static bool is_game_over(void);
-static void save_game_auto(void);
+static void save_game_auto(const char *save_reason);
 static void generate_ai_players(void);
 static void mark_nation_as_used(Nation_Type_id nation);
 static void announce_ai_player(struct player *pplayer);
@@ -700,7 +700,7 @@
 Note that if !HAVE_LIBZ, then game.save_compress_level should never
 become non-zero, so no need to check HAVE_LIBZ explicitly here as well.
 **************************************************************************/
-void save_game(char *orig_filename)
+void save_game(char *orig_filename, const char *save_reason)
 {
   char filename[600];
   char *dot;
@@ -728,7 +728,7 @@
   timer_user = new_timer_start(TIMER_USER, TIMER_ACTIVE);
     
   section_file_init(&file);
-  game_save(&file);
+  game_save(&file, save_reason);
 
   /* Append ".sav" to filename. */
   sz_strlcat(filename, ".sav");
@@ -767,7 +767,7 @@
 /**************************************************************************
 Save game with autosave filename, and call gamelog_save().
 **************************************************************************/
-static void save_game_auto(void)
+static void save_game_auto(const char *save_reason)
 {
   char filename[512];
 
@@ -775,7 +775,7 @@
   
   my_snprintf(filename, sizeof(filename),
              "%s%+05d.sav", game.save_name, game.year);
-  save_game(filename);
+  save_game(filename, save_reason);
   gamelog(GAMELOG_STATUS);
 }
 
@@ -1585,7 +1585,7 @@
       if (game.phase == 0) {
        if (save_counter >= game.save_nturns && game.save_nturns > 0) {
          save_counter = 0;
-         save_game_auto();
+         save_game_auto("Autosave");
        }
        save_counter++;
       }
@@ -1695,7 +1695,7 @@
     gamelog(GAMELOG_JUDGE, GL_NONE);
     send_server_info_to_metaserver(META_INFO);
     if (game.save_nturns > 0) {
-      save_game_auto();
+      save_game_auto("Game over");
     }
     gamelog(GAMELOG_END);
 
diff -Nurd -X.diff_ignore freeciv/server/srv_main.h freeciv/server/srv_main.h
--- freeciv/server/srv_main.h   2005-03-19 10:42:21.359375000 +0200
+++ freeciv/server/srv_main.h   2005-03-19 13:20:09.718750000 +0200
@@ -58,7 +58,7 @@
 
 bool handle_packet_input(struct connection *pconn, void *packet, int type);
 void start_game(void);
-void save_game(char *orig_filename);
+void save_game(char *orig_filename, const char *save_reason);
 void pick_ai_player_name(Nation_Type_id nation, char *newname);
 void send_all_info(struct conn_list *dest);
 void check_for_full_turn_done(void);
diff -Nurd -X.diff_ignore freeciv/server/stdinhand.c freeciv/server/stdinhand.c
--- freeciv/server/stdinhand.c  2005-03-19 10:42:21.375000000 +0200
+++ freeciv/server/stdinhand.c  2005-03-19 13:22:58.781250000 +0200
@@ -758,7 +758,7 @@
              _("The game cannot be saved before it is started."));
     return FALSE;
   } else if (!check) {
-    save_game(arg);
+    save_game(arg, "User request");
   }
   return TRUE;
 }

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#12544) [Patch] Save reason, Marko Lindqvist <=