WARNING: BACK UP YOUR CODE BEFORE ADDING ANY SNIPPET!

Did I tell you to back up your code? Ok good. Did you do it? Shame
on you! If this goes wrong and you have nothing to restore from, don't
blame me.

Jocularity aside, this snippet was coded on a QuickMUD base, and as
such SHOULD work for all ROM2.4 derivatives with OLC plugged in.
However, there is one possible exception which I will detail at the
end of the snippet (it will make more sense then).

/* olc_act.c: Do a search for the function change_exit. Rip it ALL
out, and replace it with what is below. You should end up with REDIT
(redit_north) below it and REDIT (redit_show) above it. */

bool change_exit (CHAR_DATA * ch, char *argument, int door)
{
    ROOM_INDEX_DATA *pRoom;
    ROOM_INDEX_DATA *pRoomIndex;
    AREA_DATA *pArea;
    char command[MAX_INPUT_LENGTH];
    char arg[MAX_INPUT_LENGTH];
    char digroom[MAX_STRING_LENGTH];
    int value, foundroom;
    int newvnum;

    newvnum = 0;
    foundroom = 0;
    pArea = ch->in_room->area;

    EDIT_ROOM (ch, pRoom);

    /*
     * Set the exit flags, needs full argument.
     * ----------------------------------------
     */
    if ((value = flag_value (exit_flags, argument)) != NO_FLAG)
    {
        ROOM_INDEX_DATA *pToRoom;
        sh_int rev;                /* ROM OLC */

        if (!pRoom->exit[door])
        {
            send_to_char ("Exit doesn't exist.\n\r", ch);
            return FALSE;
        }

        /*
         * This room.
         */
        TOGGLE_BIT (pRoom->exit[door]->rs_flags, value);
        /* Don't toggle exit_info because it can be changed by players. */
        pRoom->exit[door]->exit_info = pRoom->exit[door]->rs_flags;

        /*
         * Connected room.
         */
        pToRoom = pRoom->exit[door]->u1.to_room;    /* ROM OLC */
        rev = rev_dir[door];

        if (pToRoom->exit[rev] != NULL)
        {
            pToRoom->exit[rev]->rs_flags = pRoom->exit[door]->rs_flags;
            pToRoom->exit[rev]->exit_info = pRoom->exit[door]->exit_info;
        }

        send_to_char ("Exit flag toggled.\n\r", ch);
        return TRUE;
    }

    /*
     * Now parse the arguments.
     */
    argument = one_argument (argument, command);
    one_argument (argument, arg);

    if (command[0] == '\0' && argument[0] == '\0')
    {                            /* Move command. */
        move_char (ch, door, TRUE);    /* ROM OLC */
        return FALSE;
    }

    if (command[0] == '?')
    {
        do_help (ch, "EXIT");
        return FALSE;
    }

    if (!str_cmp (command, "delete"))
    {
        ROOM_INDEX_DATA *pToRoom;
        sh_int rev;                /* ROM OLC */

        if (!pRoom->exit[door])
        {
            send_to_char ("REdit:  Cannot delete a null exit.\n\r", ch);
            return FALSE;
        }

        /*
         * Remove ToRoom Exit.
         */
        rev = rev_dir[door];
        pToRoom = pRoom->exit[door]->u1.to_room;    /* ROM OLC */

        if (pToRoom->exit[rev])
        {
            free_exit (pToRoom->exit[rev]);
            pToRoom->exit[rev] = NULL;
        }

        /*
         * Remove this exit.
         */
        free_exit (pRoom->exit[door]);
        pRoom->exit[door] = NULL;

        send_to_char ("Exit unlinked.\n\r", ch);
        return TRUE;
    }

    if (!str_cmp (command, "link"))
    {
        EXIT_DATA *pExit;
        ROOM_INDEX_DATA *toRoom;

        if (arg[0] == '\0' || !is_number (arg))
        {
            send_to_char ("Syntax:  [direction] link [vnum]\n\r", ch);
            return FALSE;
        }

        value = atoi (arg);

        if (!(toRoom = get_room_index (value)))
        {
            send_to_char ("REdit:  Cannot link to non-existant room.\n\r",
                          ch);
            return FALSE;
        }

        if (!IS_BUILDER (ch, toRoom->area))
        {
            send_to_char ("REdit:  Cannot link to that area.\n\r", ch);
            return FALSE;
        }

        if (toRoom->exit[rev_dir[door]])
        {
            send_to_char ("REdit:  Remote side's exit already exists.\n\r",
                          ch);
            return FALSE;
        }

        if (!pRoom->exit[door])
            pRoom->exit[door] = new_exit ();

        pRoom->exit[door]->u1.to_room = toRoom;
        pRoom->exit[door]->orig_door = door;

        door = rev_dir[door];
        pExit = new_exit ();
        pExit->u1.to_room = pRoom;
        pExit->orig_door = door;
        toRoom->exit[door] = pExit;

        send_to_char ("Two-way link established.\n\r", ch);
        return TRUE;
    }

    if (!str_cmp (command, "dig"))
    {
        char buf[MAX_STRING_LENGTH];

    	if (arg[0] == '\0')
    	{
		newvnum = pArea->min_vnum;

		while (foundroom != 1)
               	{
			newvnum++;
			if ((pRoomIndex = get_room_index (newvnum)))
				foundroom = 0;
			else
			  foundroom = 1;
		}

		if (newvnum > pArea->max_vnum)
		{
			send_to_char ("Dig Error: No more free vnums in area.\n\r", ch);
			return FALSE;
		}

		sprintf (digroom, "%d", newvnum);
        	redit_create (ch, digroom);
        	sprintf (buf, "link %s", digroom);
        	change_exit (ch, buf, door);
		return TRUE;

    	}
   	else
    	{
        	if (!is_number (arg))
        	{
            		send_to_char ("Error: Argument must be numerical\n\r", ch);
            		return FALSE;
        	}
		else
		{
        		redit_create (ch, arg);
        		sprintf (buf, "link %s", arg);
        		change_exit (ch, buf, door);
        		return TRUE;
    		}
	}
    }

    if (!str_cmp (command, "room"))
    {
        ROOM_INDEX_DATA *toRoom;

        if (arg[0] == '\0' || !is_number (arg))
        {
            send_to_char ("Syntax:  [direction] room [vnum]\n\r", ch);
            return FALSE;
        }

        value = atoi (arg);

        if (!(toRoom = get_room_index (value)))
        {
            send_to_char ("REdit:  Cannot link to non-existant room.\n\r",
                          ch);
            return FALSE;
        }

        if (!pRoom->exit[door])
            pRoom->exit[door] = new_exit ();

        pRoom->exit[door]->u1.to_room = toRoom;    /* ROM OLC */
        pRoom->exit[door]->orig_door = door;

        send_to_char ("One-way link established.\n\r", ch);
        return TRUE;
    }

    if (!str_cmp (command, "key"))
    {
        OBJ_INDEX_DATA *key;

        if (arg[0] == '\0' || !is_number (arg))
        {
            send_to_char ("Syntax:  [direction] key [vnum]\n\r", ch);
            return FALSE;
        }

        if (!pRoom->exit[door])
        {
            send_to_char ("Exit doesn't exist.\n\r", ch);
            return FALSE;
        }

        value = atoi (arg);

        if (!(key = get_obj_index (value)))
        {
            send_to_char ("REdit:  Key doesn't exist.\n\r", ch);
            return FALSE;
        }

        if (key->item_type != ITEM_KEY)
        {
            send_to_char ("REdit:  Object is not a key.\n\r", ch);
            return FALSE;
        }

        pRoom->exit[door]->key = value;

        send_to_char ("Exit key set.\n\r", ch);
        return TRUE;
    }

    if (!str_cmp (command, "name"))
    {
        if (arg[0] == '\0')
        {
            send_to_char ("Syntax:  [direction] name [string]\n\r", ch);
            send_to_char ("         [direction] name none\n\r", ch);
            return FALSE;
        }

        if (!pRoom->exit[door])
        {
            send_to_char ("Exit doesn't exist.\n\r", ch);
            return FALSE;
        }

        free_string (pRoom->exit[door]->keyword);

        if (str_cmp (arg, "none"))
            pRoom->exit[door]->keyword = str_dup (arg);
        else
            pRoom->exit[door]->keyword = str_dup ("");

        send_to_char ("Exit name set.\n\r", ch);
        return TRUE;
    }

    if (!str_prefix (command, "description"))
    {
        if (arg[0] == '\0')
        {
            if (!pRoom->exit[door])
            {
                send_to_char ("Exit doesn't exist.\n\r", ch);
                return FALSE;
            }

            string_append (ch, &pRoom->exit[door]->description);
            return TRUE;
        }

        send_to_char ("Syntax:  [direction] desc\n\r", ch);
        return FALSE;
    }

    return FALSE;
}

/* end of olc_act.c changes */

EXCEPTION: If the function change_exit has been modified from stock,
replacing it with this one will DELETE any changes you've made. Please,
please make sure you haven't made any changes to this function before
you replace it.

That should be it! Now, whenever you edit a room and type "<direction> dig"
the code will create a room using the first empty vnum in the area and link
it to your current room in the specified direction. Those of you who have
already used the dig function will know you normally need to specify a vnum
for the new room. This allows you to speed up that initial room creation
process if you're one of those builders who likes to get their layout created
first before adding descriptions etc.

As "dig" is already a part of OLC and I only modified it slightly, I require
no credit, email, or addition to snippet helpfiles. Of course, it's always
nice to get email from people who are using my snippets just so I know theres
a point in still producing them!

Happy Coding!
Chris Jenkins
Xerihae of the Winds of Lor'an
Website: http://www.windsofloran.co.uk
Telnet: windsofloran.co.uk 7000
Email: xerihae@windsofloran.co.uk