int find_random_exit (ROOM_INDEX_DATA *troom)
if(troom->exit[i])
if( (door = find_random_exit(ch->in_room)) == -1)
(gdb) p ch->in_room
$2 = (ROOM_INDEX_DATA *) 0x2b5b111a09a8
(gdb) p troom
$1 = (ROOM_INDEX_DATA *) 0x111a09a8
int find_random_exit(ROOM_INDEX_DATA *room){
int doors[6],count = -1;
for(int i = 0;i < 6;i++)
if(room->exit[i])
doors[(++count) - 1] = i;
return count == -1 ? count : doors[number_range(0,count)];
}
int find_random_exit(ROOM_INDEX_DATA *room){
int doors[6],count = -1;
for(int i = 0;i < 6;i++)
if(room->exit[i])
doors[(++count) - 1] = i;
return count == -1 ? count : doors[number_range(0,count)];
}
#define NUM_DOORS 6
int find_random_exit(ROOM_INDEX_DATA *room)
{
int doors[NUM_DOORS];
int i = 0;
int count = 0;
if( !room || !room->exit )
return -1;
for( i = 0; i < NUM_DOORS; i++)
{
doors[ i ] = -1;
if( room->exit[ i ] )
doors[ count++ ] = i;
}
return count ? doors[ number_range( 0, count - 1) ] : -1;
}
doors[ i ] = -1;
doors[ i ] = -1;
crashes here
because troom apparently doesn't exist
this is the call for the function
this is the data at that point in code
and this is the data where it crashes in find_random_exit
in the call, in_room works, I can read the vnum, room name etc, but by the time it reaches find_random_exit it's…… gone?
Any idea what I am doing to violate my pointers?