Undig command
Snippet Posted Wednesday, June 21st @ 09:09:13 PM, by Brandon Brown in the OLC dept.
Josh Anderson writes, "I created this command to provide a quick and easy way to purge a one or two-way exit totally without having to enter an olc editor."
We use the 'dig' snippet on my mud, used to create an easy two-way exit from
your room to another of your choice.  However, if you by accident mess up the
number or just later want to retract your doings, you must enter redit and for
both rooms to purge each exit.  I created this command to provide a quick and
easy way to purge a one or two-way exit totally without having to enter an olc
editor.

You may notice that I have included the code for ordinal directions as well,
seeing as how someone else was nice enough to post that code very recently.  If
you don't use ordinals just delete those from the end of the if/else if set of
statements, and if you did that and wanted to make the command a little more
efficient you could copy the part of the code for choosing a direction found
in the original dig command, after which part of this code is modeled.

This command can be used by most anyone, the dig command is not required.
Standard disclaimers apply, probably more so for this than some other code I
have submitted because this is the first code that really could potentially
cause someone heartache :)  If anyone has any suggestions to improve this,
please let me know.

One last note, I'm calling this command undig here, we call it unmake
on my mud, feel free to rename it to whatever you'd like.


===in act.wizard.c or something similar===

/* Josh Anderson, 21 June 2000 */
ACMD(do_undig)
{
  char buf2[10];
  char buf[80];
  int dir = 0;
  struct room_direction_data *exit1 = NULL, *exit2 = NULL;
  room_rnum toroom;

  /* buf2 is the direction */
  one_argument(argument, buf2);

  if (!*buf2) {
    send_to_char("Format: unmake \r\n", ch);
    return;
  }

  if(!strcmp(buf2, "n"))
    dir = NORTH;
  else if(!strcmp(buf2, "e"))
    dir = EAST;
  else if(!strcmp(buf2, "s"))
    dir = SOUTH;
  else if(!strcmp(buf2, "w"))
    dir = WEST;
  else if(!strcmp(buf2, "u"))
    dir = UP;
  else if(!strcmp(buf2, "d"))
    dir = DOWN;
  /* Delete down to the next mark if you don't use ordinals */
  else if(!strcmp(buf2, "ne"))
    dir = NORTHEAST;
  else if(!strcmp(buf2, "nw"))
    dir = NORTHWEST;
  else if(!strcmp(buf2, "se"))
    dir = SOUTHEAST;
  else if(!strcmp(buf2, "sw"))
    dir = SOUTHWEST;
  /* end delete mark for no ordinals */
  else
  {
    send_to_char("What direction? (n s e w u d ne nw se sw)\r\n", ch);
    return;
  }

    exit1 = world[ch->in_room].dir_option[dir];
    if (exit1)
    {
      toroom = exit1->to_room;
      exit2 = world[toroom].dir_option[rev_dir[dir]];
    }

    if (exit1)
    {
      if (exit1->general_description)
        free(exit1->general_description);
      if (exit1->keyword)
        free(exit1->keyword);
      free(exit1);
      world[ch->in_room].dir_option[dir] = NULL;
    }
    else
    {
      send_to_char("There is no exit in that direction!", ch);
      return;
    }
    if (exit2)
    {
      if (exit2->general_description)
        free(exit2->general_description);
      if (exit2->keyword)
        free(exit2->keyword);
      free(exit2);
      world[toroom].dir_option[rev_dir[dir]] = NULL;
    }
    else
    {
      send_to_char("No returning exit from the other side, only one side deleted!\r\n", ch);
    }

  /* Only works if you have Oasis OLC */
  add_to_save_list((GET_ROOM_VNUM(toroom) / 100), SL_WLD);
  add_to_save_list((IN_ROOM_VNUM(ch) / 100), SL_WLD);

  sprintf(buf, "You purge the exit to the %s.\r\n", dirs[dir]);
  send_to_char(buf, ch);
  sprintf(buf1, "%s gestures to the %s...what once was an exit has now vanished.", GET_NAME(ch), dirs[dir]);
  act(buf1, FALSE, ch, 0, 0, TO_ROOM);
}

You may have noticed the IN_ROOM_VNUM(ch) macro I used here...if you can't figure out what to do to make that work for you, here's what it is for me :)

===in utils.h===

#define IN_ROOM_VNUM(ch) (GET_ROOM_VNUM(IN_ROOM(ch)))

Enjoy!
Josh Anderson
joshua18@home.com

<< FTP Uploads 2000//0/6/ | Reply | Flattened >>

 


Related Links
  Josh Anderson
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