Re: [Circle][Code] ACMD(do_saveall)

From: Daniel A. Koepke (dkoepke@circlemud.org)
Date: 09/26/01


On Wed, 26 Sep 2001, Ramsey Stone wrote:

>   ACMD(do_saveall)
>   {
>     int zone = 0;
>     zone = atoi(arg);
>     oedit_save_to_disk(zone);
>     [... snip ...]

I'm guessing (I don't really know) that your problem is that the
xxx_save_to_disk() functions expect a zone real number, rather than the
virtual number you've passed.  Looking quickly at OasisOLC 2.0, all of
these functions seem to just be calls to save_xxx() functions from
genolc.c.  Thus, I would recommend:

  ACMD(do_saveall)
  {
    char buf[MAX_STRING_LENGTH];
    char arg[MAX_INPUT_LENGTH];
    zone_rnum rzone;
    zone_vnum zone;

    argument = one_argument(argument, arg);

    /* No arguments: write all zones. */
    if (!*arg) {
      for (rzone = 0; rzone <= top_of_zone_table; rzone++) {
        save_objects(rzone);
        save_mobiles(rzone);
        save_zone(rzone);
        save_rooms(rzone);
        save_shops(rzone);
      }

      sprintf(buf, "Saved %d zones.\r\n", (int) top_of_zone_table+1);
      send_to_char(buf, ch);
      return;
    }

    /* Got at least one argument: save each zone mentioned. */
    while (*arg) {
      zone = (zone_vnum) atoi(arg);

      if ((rzone = real_zone(zone)) == NOWHERE) {
        sprintf(buf, "#%d: no such zone\r\n", (int) zone);
        send_to_char(buf, ch);
        continue;
      }

      count++;

      save_objects(rzone);
      save_mobiles(rzone);
      save_zone(rzone);
      save_rooms(rzone);
      save_shops(rzone);

      argument = one_argument(argument, arg);
    }

    sprintf(buf, "Saved %d zones.\r\n", count);
    send_to_char(buf, ch);
  }

I've taken the liberty to modify how the command works, too.  Just a few
changes.  With no arguments, it saves the entire world.  With one or more,
it saves each of the zones you pass to it.  As with always--and, actually,
more so, since I'm completely unfamiliar with OasisOLC and GenOLC--this is
Mailer Code(tm) and you shouldn't expect too much from it.


-dak

--
   +---------------------------------------------------------------+
   | 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