Autosaving zones (was "some ideas")

From: Artovil (artovil@arcanerealms.org)
Date: 08/03/01


At 01:05 2001-08-03 -0400, you wrote:
>Del wrote:
> >
> > If you're doing a lot of building, it would cause a lot of disk
> writing, but
> > you can make a call to zedit_save_to_disk when you save a editor.
> >
>
>Sorry I screwed that up..
>
>You would have to call the *edit_save_to_disk, for the editor you save
>internally.

I have another solution at hand as well that I tossed since I switched to
everything saving directly, but, I added a flag to the command line options
that determines wether or  not to autosave zones, and also, it keeps zones
from resetting on your builder port (why you want this is up to you). This
requires the saveall snip by Cathy Gore.

---Pseudo-patch-snip-mailer-code-don't-blame-me-if-it-breaks---

CONFIG.C

/*
  * Should the game automatically save builder data every 15 minutes?
  */
int bautosave = NO;

/*
  * if bautosave (above) is yes, how often (in minutes) should the MUD
  * auto save builder data?
  */
int bautosave_time = 5;

-------

COMM.C in /* externs */

extern int bautosave;
extern int bautosave_time;        /* see config.c */

-------

COMM.C in int main(int argc, char **argv):

   while ((pos < argc) && (*(argv[pos]) == '-')) {
     switch (*(argv[pos] + 1)) {
     ...
     case 'b':
       bautosave = 1;
       puts("Builder port zone autosave enabled.");
       break;
     ...

printf("Usage: %s [-b] [-c] [-m] [-q] [-r] [-s] [-d pathname] [port #]\n"
        ...
        "  -b             Enable builder port autosave of zones.\n"
        ...

printf("Usage: %s [-b] [-c] [-m] [-q] [-r] [-s] [-d pathname] [port #]\n",
argv[0]);

-------

COMM.C in void heartbeat(int pulse):

   if (!(pulse % PULSE_ZONE)) {
     if (!bautosave)
       zone_update();
   }

   if (bautosave && !(pulse % ((bautosave_time * 60) * PASSES_PER_SEC))) {
     log("OLC: Autosaving all zones.");
     save_all();
   }

-------

in DB.C in void zone_update(void):

   if (((++timer * PULSE_ZONE) / PASSES_PER_SEC) >= 60) {
     ...
     for (i = 0; i <= top_of_zone_table; i++) {
       if ((zone_table[i].age < zone_table[i].lifespan &&
           zone_table[i].reset_mode) && !bautosave)
         (zone_table[i].age)++;
         ...

(Notice the !bautosave in the above if condition)

   for (update_u = reset_q.head; update_u; update_u = update_u->next)
     if ((zone_table[update_u->zone_to_reset].reset_mode == 2 ||
         is_empty(update_u->zone_to_reset)) && !bautosave) {

(Notice the !bautosave in the above if condition)

-------

I think that should be it...

If you don't want this, just add *edit_save_to_disk(OLC_ZNUM(d)); into the
case 'y' of the *EDIT_CONFIRM_SAVESTRING: of your OLC files and it will
save directly.

Regards,
/Torgny

--
   +---------------------------------------------------------------+
   | 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/06/01 PST