Re: [HELP]do_dig

From: Robert Sinland (rsinland@ERSKINE.POLARISTEL.NET)
Date: 07/29/97


Demond De Inosantos wrote:
>
>         I want to add the dig command to my mud I'm running OasisOlc and
> have only made one bug fix(the zedit new one) and want to add do_dig to
> my commands to cut down the building new rooms time. If you can help
> please let me know  I'd realy like to know how to fix the do_dig on Oasis
>
> Thanx,
> Demond
  here is my (slightly modded) rdig function (same thing just that I
also have the dig and  bury stuff, so renamed it)

ACMD(do_rdig)
{
  /* Only works if you have Oasis OLC */
  extern void redit_save_internally(struct descriptor_data *d);
  extern void olc_add_to_save_list(int zone, byte type);
  extern const int rev_dir[];
  int real_zone(int number);

  char buf2[10];
  char buf3[10];
  char buf[80];
  int iroom = 0, rroom = 0;
  int dir = 0;
  int new = 0;
  /*  struct room_data *room; */

  two_arguments(argument, buf2, buf3);
  /* buf2 is the direction, buf3 is the room */

        iroom = atoi(buf3);
        rroom = real_room(iroom);

  if (!*buf2) {
    send_to_char("Format: rdig <dir> <room number>\r\n", ch);
    return;
  } else if (!*buf3) {
    send_to_char("Format: rdig <dir> <room number>\r\n", ch);
    return;
  } else if (!isdigit(*buf3)) {
    send_to_char("Format: rdig <dir> <room number>\r\n", ch);
    return;
  }

  if (real_zone(iroom) == -1) {
    send_to_char("There is no zone for that number!\r\n", ch);
    return;
  }

  CREATE(ch->desc->olc, struct olc_data, 1);

  if (rroom <= 0) {
    CREATE(OLC_ROOM(ch->desc), struct room_data, 1);
    OLC_ROOM(ch->desc)->name = strdup("An unfinished room");
    OLC_ROOM(ch->desc)->description = strdup("An unfinished room\n");
    OLC_NUM(ch->desc) = iroom;
    new = 1;
  }

  /* Main stuff */
   switch (*buf2) {
    case 'n':
    case 'N':
      dir = NORTH;
      break;
    case 'e':
    case 'E':
      dir = EAST;
      break;
    case 's':
    case 'S':
      dir = SOUTH;
      break;
    case 'w':
    case 'W':
      dir = WEST;
      break;
    case 'u':
    case 'U':
      dir = UP;
      break;
    case 'd':
    case 'D':
      dir = DOWN;
      break;
  }

  if (world[ch->in_room].dir_option[dir])
    free(world[ch->in_room].dir_option[dir]);

  CREATE(world[ch->in_room].dir_option[dir], struct
room_direction_data,1);

  world[ch->in_room].dir_option[dir]->general_description = NULL;
  world[ch->in_room].dir_option[dir]->keyword = NULL;
  world[ch->in_room].dir_option[dir]->to_room = iroom;

  if (!new) {
    OLC_ZNUM(ch->desc) = world[rroom].zone;
    if (world[rroom].dir_option[rev_dir[dir]])
      free (world[rroom].dir_option[rev_dir[dir]]);

    CREATE(world[rroom].dir_option[rev_dir[dir]], struct
room_direction_data,1);
    world[rroom].dir_option[rev_dir[dir]]->general_description = NULL;
    world[rroom].dir_option[rev_dir[dir]]->keyword = NULL;
    world[rroom].dir_option[rev_dir[dir]]->to_room = ch->in_room;

  } else {
    OLC_ZNUM(ch->desc) = real_zone(iroom);
    CREATE(OLC_ROOM(ch->desc)->dir_option[rev_dir[dir]], struct
room_direction_data, 1);
    OLC_ROOM(ch->desc)->dir_option[rev_dir[dir]]->general_description =
NULL;
    OLC_ROOM(ch->desc)->dir_option[rev_dir[dir]]->keyword = NULL;
    OLC_ROOM(ch->desc)->dir_option[rev_dir[dir]]->to_room = ch->in_room;
  }

    /* Only works if you have Oasis OLC */
    if (new)
    redit_save_internally(ch->desc);

  world[ch->in_room].dir_option[dir]->to_room = real_room(iroom);


 /* save world data for destination room */
  olc_add_to_save_list((iroom/100), OLC_SAVE_ROOM);


  /* save world data for starting room */

 olc_add_to_save_list(( world[ch->in_room].number)/100 , OLC_SAVE_ROOM);

  free(OLC_ROOM(ch->desc));
  free(ch->desc->olc);
  sprintf(buf, "You make an exit %s from room %d to room %d.\r\n", buf2,
world[ch->in_room].number, iroom);
  send_to_char(buf, ch);
}

RS


     +------------------------------------------------------------+
     | 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/08/00 PST