[CODE] do_dig modifications for OasisOLC

From: Ron Martin (rmartin@deepthought.org)
Date: 01/08/01


Hello,

I downloaded the do_copyto and do_dig snippets from the FTP site, but
has some problems with them, so I fixed up do_dig to work using the
functions associated with OasisOLC.  I also added the ability to dig to
rooms that do not exist, creating the new rooms and setting the
appropriate OLC flags.  Here is the code:

/*
        ACMD(do_dig)
        Creates an exit from one room to another, and reciprocates the process
        in the other room.  If the given room does not exist, then a new room
        will be created, initialized, and added to the world table, unless the
        zone the room should belong to does not exist, in which case the
        operation fails and returns. - RPM 1/7/01
*/
ACMD(do_dig)
{
        int iroom = 0, rroom = 0;
        int dir = 0;
        int i, j;
        struct room_data * temp_room; /* In case the room doesn't exist */

        two_arguments(argument, buf, buf2);

        iroom = atoi(buf2);

        rroom = real_room(iroom);

        if (!buf)
        {
                send_to_char("Format: dig <dir> <room number>\r\n", ch);
                return;
        }
        else if (!buf2)
        {
                send_to_char("Format: dig <dir> <room number>\r\n", ch);
                return;
        }
        if (rroom <= 0) /* Room does not exist. */
        {
                for(i = 0; i < top_of_zone_table; i++) /* Find the zone in table */
                        if(zone_table[i].number == (iroom/100))
                                break;

                if(i == top_of_zone_table) /* Zone does not exist */
                {
                        send_to_char("The zone does not exist.\r\n", ch);
                        return;
                }

                CREATE(temp_room, struct room_data, 1);

                memset(temp_room, 0, sizeof(struct room_data)); /* Clear the room
structure */
                temp_room->name = str_dup("An unfinished room"); /* Init stuff */
                temp_room->description = str_dup("You are in an unfinished
room.\r\n");
                temp_room->number = iroom;
                temp_room->zone = iroom/100;
                rroom = add_room(temp_room); /* in oasis.c */
        }

        dir = search_block(buf, dirs, FALSE);
        if(dir == -1)
        {
                send_to_char("That is not a direction.\r\n", ch);
                return;
        }

        /* Do the magic.... */

        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;

        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 = rroom;

        sprintf(buf, "You make an exit %s to room %d.\r\n", buf2, iroom);
        send_to_char(buf, ch);
}

Please let me know if there are problems with the code.

Ron Martin

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/03/01 PST