Re: Trying to access room connected to room

From: Lincoln Chan (linc@CSUA.Berkeley.EDU)
Date: 04/04/95


On Tue, 4 Apr 1995, Scott Francis wrote:

> EXIT(ch,(EXIT(ch,door))->to_room)->to_room) to get there..but it doesn't seem

In this case, I believe that you are misusing the define.
When you refer to EXIT, the define only needs to know 2 things.  ch
(as to refer to ch->in_room) and door (as to refer to dir_option[door]).
{ grep EXIT utils.h }

#define MAX_RADIUS 2

ACMD(do_scan)
{
int door_dir, was_in_room, tmp_room, radius;

was_in_room = ch->in_room;
for (door_dir = 0; door_dir <= 5; door_dir++) {
for (radius = 1; radius <= MAX_RADIUS; radius++) {
if (CAN_GO(ch, door_dir)) {
tmp_room = EXIT(ch, door_dir);
ch->in_room = tmp_room;
list_char_to_char(world[ch->in_room].people, ch);
}
/* else break; */
/* I doubt the else break would be needed here.  In the LOOONG run, it
   might speed up the subroutine a bit, especially if you have a large
   MAX_RADIUS. */
}
}
ch->in_room = was_in_room;
}



This was something I tossed up between classes so it may not work fully 
the first time around.  You may have to tweak it a bit.
The reason I used the tmp_room variable was because I didn't know how
smoothly the mud would accept a statement as "daring" as:
ch->in_room = EXIT(ch, door_dir);

What this routine basically does is scan the 6 directions starting with
north (0) and from there, lists the characters in that room, checks to
see if you can go north yet again, does the list with that room, checks
north yet again, etc.  The repetition of this can be controled by
redefining MAX_RADIUS.

Well, this program was written in haste (I've got class in 3 minutes!);
if it bombs out on you the first time around and drops a lovely megaton
coredump into your dir...it at least offers you someplace to start looking.

I used references from act.movement.c and act.informative.c to speed
up the code writing.  No point in reinventing the wheel, aye?

linc aka Aladdin of Eternity DikuMUD



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