Re: [Code] Rlink

From: Christian Ejlertsen (chr.ejlertsen@has.dk)
Date: 11/15/02


Hi here is a snippet i build

> Does anyone by chance have an rlink snippet for CircleMUD 3.0 beta patch
> level 17? I don't necessarily like buildwalk, and the dig snippet won't work
> on my source for some reason.  (I'm used to typing rlink anyhow). :P
>

USAGE: rlink <roomnumber> <direction> <1 or 2 way exit>

Will connect the room you are in to the room and direction you specify.
1 and 2 way exit is an optional argument defaults to 2 way

ACMD(do_rlink)
{
        char target[MAX_INPUT_LENGTH], direction[MAX_INPUT_LENGTH];
        room_data *rm;
        struct room_direction_data *exit;
        int dir, twoway = 2;
        room_rnum to_room, was_in;

        argument = two_arguments(argument, target, direction);
        one_argument(argument, arg);

        if (*arg) {
                if (isdigit(*arg))
                        twoway = atoi(arg);

                if (twoway < 1 || twoway > 2)
                        twoway = 2;
        }

        if (!*target || !*direction) {
                send_to_char("rlink called with too few args\r\n", ch);
                return;
        }

        if (!(rm = &world[IN_ROOM(ch)])) {
                send_to_char("rlink: invalid target.\r\n", ch);
                return;
        }

        if ((dir = search_block(direction, dirs, FALSE)) == -1) {
                send_to_char("rlink: invalid direction.\r\n", ch);
                return;
        }

        sprintf(buf, "target: %s Direction: %s IN_ROOM: %ld\r\n", target, direction, IN_ROOM(ch));
        send_to_char(buf, ch);

        exit = rm->dir_option[dir];

        if (!strcmp("purge", target)) {
                if (exit) {
                        if (exit->general_description)
                                free(exit->general_description);
                                if (exit->keyword)
                                        free(exit->keyword);

                        free(exit);
                        rm->dir_option[dir] = NULL;
                }
                return;
        }

        if (!exit) {
                CREATE(exit, struct room_direction_data, 1);
                rm->dir_option[dir] = exit;
        }

        if ((to_room = real_room(atoi(target))) != NOWHERE)
                exit->to_room = to_room;
        else
                send_to_char("rlink: invalid door target\r\n", ch);

        if (twoway == 2) {

                was_in = IN_ROOM(ch);
                rm = &world[to_room];

                exit = rm->dir_option[rev_dir[dir]];

                if (!exit) {
                        CREATE(exit, struct room_direction_data, 1);
                        rm->dir_option[rev_dir[dir]] = exit;
                }

                exit->to_room = was_in;
        }
}

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/25/03 PDT