Zone Saving [by BlueDragon]
Snippet Posted Sunday, July 16th @ 11:42:53 PM, by Brandon Brown in the OLC dept.
Bluedragon writes, "I wanted a way to save zone information quicker, and this works better if you want to save everything..."
i wanted a way to save zone information quicker, and this works better if you want to save everything.... i'll just give the command itself, you can put it in interpreter.c yourself, it's only been tested on bpl14... normal disclaimer, if anything blows up it's not my fault... you put it in at your own risk...
just type zsave, impl's save help/actions, and room/mob/zone/shop/obj info for any zone you can edit... or type zsave  and it'll save that info for that zone if you can edit it.
i use olcplus, but it should work with any olc that has can_edit_zone, and is_name.
you'll have to change the LVL_ONEUP thing...
ACMD(do_zsave) {
void hedit_save_to_disk(void);
void aedit_save_to_disk(void);
void medit_save_to_disk(int zone_num);
void oedit_save_to_disk(int zone_num);
void redit_save_to_disk(int zone_num);
void zedit_save_to_disk(int zone_num);
void sedit_save_to_disk(int zone_num);
int can_edit_zone(struct char_data *ch, int number);
int x, j = 0, zonenum = 0;

  one_argument(argument, arg);
  if ((arg && *arg) && (!(zonenum = atoi(arg)))) {
    send_to_char("Usage: zsave [zone number]\r\n", ch);
    return;
  }
  /* this does present a slight problem... you can't zsave zone 0.
   - but i've never used it, and i don't see why anyone would,
   - so i don't bother fixing it... */

  /* LVL_ONEUP = LVL_IMPL - 1 ... they get a few things GRGOD's don't */

  if (GET_LEVEL(ch) >= LVL_ONEUP && !zonenum) {
    hedit_save_to_disk();
    aedit_save_to_disk();
    send_to_char("Saved help and actions.\r\n", ch);
  }

  /* i don't use can_edit_zone when there's no zonenum because
   - lvl_oneup's can edit all zones, but i only want lvl_impl
   - to save all zones.  i do use it when there is a zonenum
   - because i want lvl_oneup's to be able to zsave any zone
   - even if they're not in the builders list.  */

  for (x = 0;x <= top_of_zone_table;x++)
    if (((!zonenum) &&
        (GET_LEVEL(ch) >= LVL_IMPL || is_name(GET_NAME(ch), zone_table[x].builders))) ||
        (zonenum == zone_table[x].number && can_edit_zone(ch, x))) {
      if (!j) {
        sprintf(buf, "Saved mob, room, obj, zone, and shop info for zone%s",
          (zonenum == 0 ? "s:\r\n" : ": "));
        send_to_char(buf, ch);
      }
      j++;
      medit_save_to_disk(x);
      redit_save_to_disk(x);
      oedit_save_to_disk(x);
      zedit_save_to_disk(x);
      sedit_save_to_disk(x);

      if (!zone_table[x].name)  /* this should never happen, but try to catch everything */
        zone_table[x].name = str_dup("New Zone");

      sprintf(buf, "[%3d] %s&n\r\n", zone_table[x].number, zone_table[x].name);
      send_to_char(buf, ch);
    }

  if (!j) {
    if (!zonenum)
      send_to_char("You have to have some zones to save first.\r\n", ch);
    else
      send_to_char("The zone number must exist, and you must be able to edit it.\r\n", ch);
    return;
  }
  sprintf(buf, "\r\nYou saved info for %d zone%s.\r\n", j, (j == 1 ? "" : "s"));
  send_to_char(buf, ch);
  sprintf(buf, "%s saved info for %d zone%s.", GET_NAME(ch), j, (j == 1 ? "" : "s"));
  mudlog(buf, CMP, MAX(LVL_GOD, GET_INVIS_LEV(ch)), TRUE);
}


no credits needed, but it would be cool if you mailed me saying you've found it useful or if there's anything wrong, or something that i could add to it.

<< Undig command | Reply | Threaded | Two-Handed weapons [by Boxboy] >>

 


Related Links
  Bluedragon
Related Articles
More by bbrown
 
 

Quick Links
 
The CircleMUD FAQ
The CircleMUD home page
Alex's Snippets
Wintermute Snippets
CircleMUD Bug Reporting or Help
CircleMUD List Archives
CircleMUD Resources
Death Gate's Scripts
(Author of C conversion)
Sammy's code site
Erwin S. Andreasen's page
(Author of mudFTP and other goodies)
Death's Gate Scripting site
Help for CircleMUD in Windows
The OasisOLC Maintenance Effort
George's Random Stuff
Imaginary Realities
MUD Dictionary
 
 


"can_edit_zone"
by Tony Robbins (kupek@kupoppo.net) on Thursday, February 8th @ 11:59:01 AM
http://
As the author or compiler of OLC+, I thought I'd warn everybody that OLC+ is the only OLC system that has the can_edit_zone() function. If you want to use this snippet, you'll have to modify the checks involving can_edit_zone() to reflect how you are permitted to edit.

OLC+'s can_edit_zone() checks for a character's name inside a string attached to each zone structure. So, in other words, you just need to see if a character is allowed to edit a zone, most likely based on level, zone permissions (GET_OLC_ZONE(ch) == ...), or however your system works.

Of course, you probably already knew that.
[ Reply to this comment ]