ChangeLog Entry: Saving MUD time

From: Peter Ajamian (peter@pajamian.dhs.org)
Date: 06/20/01


I just ran across this in the ChangeLog:

-- gg - comm.c: init_game(): Save the MUD time on shutdown.
        db.c: reset_time(): Load beginning time from lib/etc/time.
        db.h: TIME_FILE: "lib/etc/time"
        utils.c: mud_time_to_secs(): New.

...and part of the diff for comm.c is this:

@@ -359,6 +361,14 @@ void init_game(ush_int port)

   CLOSE_SOCKET(mother_desc);
   fclose(player_fl);
+
+  log("Saving current MUD time.");
+  if ((bgtime = fopen(TIME_FILE, "w")) == NULL)
+    log("SYSERR: Can't write to '%s' time file.", TIME_FILE);
+  else {
+    fprintf(bgtime, "%ld\n", mud_time_to_secs(&time_info));
+    fclose(bgtime);
+  }

   if (circle_reboot) {
     log("Rebooting.");

I got to thinking (not a good thing, I know ;) ), why not throw that part
in a function (say something like save_mud_time) and then call it from
both init_game() and heartbeat() so that the mud_time file will get
updated regularily in case of a crash?  Note that separating this into a
function will also make it easier to update for things like copyover.

Regards, Peter

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/05/01 PST