Re: "Problem with CON_DISCONNECT" and a snippet for y'all

From: Tony Robbins (tonyr@NWPACLINK.COM)
Date: 03/18/98


CON_DISCONNECT:
Yada yada yada, ok, I'm noone to judge, but I'm almost positive this
could go to private e-mail (I haven't seen anything helpful at all.)

SNIPPET:
Ok, when I built for this MUD called Allanthya (There
Melen--allanthya.org 4000), the MUD used obuild for OLC and so I was
browsing the snippet page for the same functionality of obuild's copy
for OasisOLC.

Maybe somebody can expand this to include mobiles, and it hasn't been
thoroughly tested, but it does copy rooms and objects.

More Info:  This copies a complete object, or the room name, flags,
description, and extra descriptions.  Exits aren't copied cuz that'd be
silly.  This code is a shameless hack on the copyto command from the
snippet site, but, I'm a shameless person.

/*
 * Copy a room or object to another.
 */

ACMD(do_copy)
{
  extern void olc_add_to_save_list(int zone, byte type);

  char buf[80];
  char src_num[256], targ_num[256], type[256], whoopsies[256];
  int iroom = 0, rroom = 0, base_vnum = 0, baseroom = 0;  // For Rooms
  int iobj = 0, robj = 0, baseobj = 0;  // For Objects
  int save_zone = 0, zontmp = 0;  // For Saving
  struct room_data *room;
  struct obj_data *obj;

  argument = two_arguments(argument, type, src_num);
  two_arguments(argument, targ_num, whoopsies);

  if (!*type || !*src_num || !*targ_num) {
    send_to_char("Usage:  copy { room | obj } <source> <target>\r\n",
ch);
    return;
  }

  if (is_abbrev(type, "room")) {
    CREATE(room, struct room_data, 1);
    iroom = atoi(targ_num);
    rroom = real_room(atoi(targ_num));
    *room = world[rroom];
    base_vnum = atoi(src_num);
    baseroom = real_room(base_vnum);

    if (rroom <= 0) {
      sprintf(buf, "There is no room with the number %d.\r\n", iroom);
      send_to_char(buf, ch);
      return;
    }
        /* Check zone info */
    zontmp = (world[rroom].number / 100);
    zontmp = zontmp * 100;
    if (zontmp > (world[rroom].number)) save_zone = (zontmp/100) - 1;
    else save_zone = (zontmp/100);

    if ((GET_LEVEL(ch) < LVL_IMPL) && (GET_OLC_ZONE(ch) != save_zone)) {
      send_to_char("You do not have permission to edit this zone.\r\n",
ch);
      return;
    }

    /* Ok, go ahead and copy the room */

    if ((world[rroom].number) && (world[baseroom].number)) {
      if (world[baseroom].name)
        world[rroom].name = str_dup(world[baseroom].name);
      if (world[baseroom].description)
        world[rroom].description = str_dup(world[baseroom].description);
      if (world[baseroom].sector_type)
        world[rroom].sector_type = world[baseroom].sector_type;
      if (world[baseroom].room_flags)
        world[rroom].room_flags = world[baseroom].room_flags;

      olc_add_to_save_list(save_zone, OLC_SAVE_ROOM);
      sprintf(buf, "You copy room %d to room %d.\r\n", base_vnum,
iroom);
      send_to_char(buf, ch);
      free(room);
    } else send_to_char("Rooms with no numbers--wonderful!\r\n", ch);
  } else if (is_abbrev(type, "obj")) {
    CREATE(obj, struct obj_data, 1);
    iobj = atoi(targ_num);    baseobj = real_object(base_vnum);

    if (robj <= 0) {
      sprintf(buf, "There is no object with the number %d.\r\n", iroom);
      send_to_char(buf, ch);
      return;
    }

    /* Check zone info */
    zontmp = (obj_proto[baseobj].item_number / 100);
    zontmp = zontmp * 100;
    if (zontmp > (obj_proto[baseobj].item_number)) save_zone =
(zontmp/100) - 1;
    else save_zone = (zontmp/100);

    if ((GET_LEVEL(ch) < LVL_IMPL) && (GET_OLC_ZONE(ch) != save_zone)) {
      send_to_char("You do not have permission to edit this zone.\r\n",
ch);
      return;
    }

    /* Ok, go ahead and copy the object */

    if ((obj_proto[robj].item_number) &&
(obj_proto[baseobj].item_number)) {
      if (obj_proto[baseobj].name)
        obj_proto[robj].name = str_dup(obj_proto[baseobj].name);
      if (obj_proto[baseobj].description)
        obj_proto[robj].description =
str_dup(obj_proto[baseobj].description);
      if (obj_proto[baseobj].short_description)
        obj_proto[robj].short_description =
str_dup(obj_proto[baseobj].short_description);
      if (obj_proto[baseobj].action_description)
        obj_proto[robj].action_description =
str_dup(obj_proto[baseobj].action_description);
        obj_proto[robj].obj_flags = obj_proto[baseobj].obj_flags;
      if (obj_proto[baseobj].worn_on)
        obj_proto[robj].worn_on = obj_proto[baseobj].worn_on;
      if (obj_proto[baseobj].ex_description)
        obj_proto[robj].ex_description =
obj_proto[baseobj].ex_description;

      olc_add_to_save_list(save_zone, OLC_SAVE_OBJ);
      sprintf(buf, "You copy object %d to %d.\r\n", base_vnum, iobj);
      send_to_char(buf, ch);
      free(obj);
    } else send_to_char("Objects with no number?!  That's not
good.\r\n", ch);
  } else send_to_char("That's room or obj.\r\n", ch);
}

/* End Snippet */
Perhaps you will expand this for mobiles, or port the obuild copy to
Oasis.  Either way, if you do, send a copy my way.  :)
-B.


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST