Re: Date saving

From: Mike Stilson (mike@velgarian.sytes.net)
Date: 09/27/02


On Fri, Sep 27, 2002 at 02:17:14PM -0700, Thomas Larsson wrote:
>Also it seems that the mud time resets ?when i reboot
>the mud, shouldnt it remember the game time ?

Yes... how silly of it.  The little AI microcritters that live in the
cpu should say "Oh, lookey here.... he's running his mud.  There's no
code in it to save what it thought the date was, but we should set it
anyway."

/endof smartass_answer

No. There's no code in stock to save it.
It's about a what, 30 line hack to put it in though....

//---- mailer code ----------
void save_mud_time(void)
{
    FILE *fp;

    if(!(fp = fopen(LIB_ETC"mud_date", "w"))) {
        log("SYSERR: Error opening mud_date for write (%s)", strerror(errno));
        return;
    }
    fprintf(fp, "%s %s %s", time_info.year, time_info.month, time_info.day);
    fclose(fp);
}

void read_mud_date(void)
{
    FILE *fp;
    int year, month, day, count;

    if(!(fp = fopen(LIB_ETC"mud_date", "r"))) {
        log("SYSERR: Error opening mud_date for read (%s)", strerror(errno));
        return;
    }

    if((count = fscanf(fp, "%d %d %d", &year, &month, &day)) != 3) {
        log("SYSERR: Reading mud_date returned %d values (expecting 3)", count);
        return;
    }
    fclose(fp);

    time_info.year = year;
    time_info.month = month;
    time_info.day = day;
}

then just add the hook to read it in db.c, and a call to write it to the
file wherever you want (heartbeat(), or another_hour() in weather.c).

-me

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/25/03 PDT