On Wed, 20 Jun 2001, Peter Ajamian wrote:
> 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.
I added this to my mud before it got added to the stock Circle code. I
call save_time_to_disk() at the very end of another_hour() since that is
the only place that time gets changed.
Here's the code:
void save_time_to_disk(void)
{
FILE *f;
f = fopen("etc/date", "w");
fwrite(&time_info, sizeof(time_info_data), 1, f);
fclose(f);
}
At the top of reset_time() in db.c, I have:
FILE *f;
long beginning_of_time = 650336715;
time_info = mud_time_passed(time(0), beginning_of_time);
if (!(f = fopen("etc/date", "r"))) {
log("SYSERR: File etc/date not found, mud date reverted to default!");
}
else {
fread(&time_info, sizeof(time_info_data), 1, f);
fclose(f);
}
--
Zeavon Calatin, Magemaster of the Realms
Spear of Insanity -- telnet://spear.kilnar.com:1066
http://spear.kilnar.com/
--
+---------------------------------------------------------------+
| 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