[NEWBIE][CODE] help with dig command

From: Christopher J. Bottaro (cjb9@mail.utexas.edu)
Date: 05/05/99


i want a command that works as follows:
dig east 101
it is suppose to make an east exit in the room you are standing to room 101
and also make a west exit in room 101 to the room you standing in.

here is the code i came up with so far and where it crashes:
----------------------------------------------------------------------------
----------------------------------------------------------------------------
--------------------------------------
ACMD(do_dig)    {
        static const char* dir_name[] = {"North", "East", "South", "West", "Up",
"Down"};
        static const char* rdir_name[] = {"South", "West", "North", "East",
"Down", "Up"};
        int dir, rdir;
        room_vnum rvnum;
        room_rnum rrnum;
        char buf1[10],buf2[10];

        *buf1 = '\0';
        *buf2 = '\0';
        half_chop(argument,buf1,buf2);

        if (!*buf1 || !*buf2)   {
                send_to_char("USAGE:  dig <exit direction> <room vnum>\r\n",ch);
                return;
        }

        for (dir = 0;dir < NUM_OF_DIRS;dir++)   {
                if (is_match(buf1,dir_name[dir]))
                        break;
        }

        if (dir == NUM_OF_DIRS) {
                sprintf(buf,"%s is not a direction.\r\n",buf1);
                send_to_char(buf,ch);
                return;
        }

        //find reverse direction
        for (rdir = 0;rdir < NUM_OF_DIRS;rdir++)        {
                if (is_match(buf1,rdir_name[rdir]))
                        break;
        }

        rvnum = atoi(buf2);
        rrnum = real_room(rvnum);
        if (rrnum == NOWHERE)   {
                sprintf(buf,"%d is not a valid room vnum.\r\n",rvnum);
                send_to_char(buf,ch);
                return;
        }

        if (world[rrnum].zone != world[ch->in_room].zone && GET_LEVEL(ch) !=
LVL_IMPL)       {
                send_to_char("You are not allowed to dig to that room.\r\n",ch);
                return;
        }

        //ok, all possible errors trapped...i think!

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

        world[ch->in_room].dir_option[dir]->to_room = rrnum;  //CRASHES HERE
        world[rrnum].dir_option[rdir]->to_room = ch->in_room;

        sprintf(buf,"Dug room %d's %s exit to room
%d\r\n",GET_ROOM_VNUM(ch->in_room),dir_name[dir],rvnum);
        send_to_char(buf,ch);

}
----------------------------------------------------------------------------
----------------------------------------------------------------------------
--------------------------------------
any help would be >greatly< appreciated.  thank you.


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST