Offending bits of code[Specific lines in bold and underlined:
/*
* create a 'virtual' room -Thoric
*/
ROOM_INDEX_DATA *generate_exit( ROOM_INDEX_DATA *in_room, EXIT_DATA **pexit )
{
EXIT_DATA *xit, *bxit;
EXIT_DATA *orig_exit = (EXIT_DATA *) * pexit;
ROOM_INDEX_DATA *room, *backroom;
int brvnum;
int serial;
int roomnum;
int distance = -1;
int vdir = orig_exit->vdir;
sh_int hash;
bool found = FALSE;
if ( in_room->vnum > MAX_VNUMS ) /* room is virtual */
{
serial = in_room->vnum;
roomnum = in_room->tele_vnum;
if ( (serial & MAX_VNUMS) == orig_exit->vnum )
{
brvnum = serial >> 16;
--roomnum;
distance = roomnum;
}
else
{
brvnum = serial & MAX_VNUMS;
++roomnum;
distance = orig_exit->distance - 1;
}
backroom = get_room_index( brvnum );
}
else
{
int r1 = in_room->vnum;
int r2 = orig_exit->vnum;
brvnum = r1;
backroom = in_room;
serial = (UMAX( r1, r2 ) << 16) | UMIN( r1, r2 );
distance = orig_exit->distance - 1;
roomnum = r1 < r2 ? 1 : distance;
}
hash = serial % 64;
for ( room = vroom_hash[hash]; room; room = room->next )
if ( room->vnum == serial && room->tele_vnum == roomnum )
{
found = TRUE;
break;
}
if ( !found )
{
CREATE( room, ROOM_INDEX_DATA, 1 );
room->area = in_room->area;
room->vnum = serial;
room->tele_vnum = roomnum;
room->sector_type = in_room->sector_type;
room->room_flags = in_room->room_flags;
decorate_room( room );
room->next = vroom_hash[hash];
vroom_hash[hash] = room;
++top_vroom;
}
if ( !found || (xit = get_exit(room, vdir)) == NULL )
{
xit = make_exit(room, orig_exit->to_room, vdir);
xit->keyword = STRALLOC( "" );
xit->description = STRALLOC( "" );
xit->key = -1;
xit->distance = distance;
}
if ( !found )
{
bxit = make_exit(room, backroom, rev_dir[vdir]);
bxit->keyword = STRALLOC( "" );
bxit->description = STRALLOC( "" );
bxit->key = -1;
if ( (serial & MAX_VNUMS) != orig_exit->vnum )
bxit->distance = roomnum;
else
{
EXIT_DATA *tmp = get_exit( backroom, vdir );
int fulldist = tmp->distance;
bxit->distance = fulldist - distance;
}
}
(EXIT_DATA *) pexit = xit;
return room;
}
/*
* "Climb" in a certain direction. -Thoric
*/
void do_climb( CHAR_DATA *ch, char *argument )
{
EXIT_DATA *pexit;
bool found;
found = FALSE;
if ( argument[0] == '\0' )
{
for ( pexit = ch->in_room->first_exit; pexit; pexit = pexit->next )
if ( IS_SET( pexit->exit_info, EX_xCLIMB ) )
{
move_char( ch, pexit, 0 );
return ;
}
send_to_char( "You cannot climb here.\n\r", ch );
return ;
}
if ( (pexit = find_door( ch, argument, TRUE )) != NULL
&& IS_SET( pexit->exit_info, EX_xCLIMB ))
{
move_char( ch, pexit, 0 );
return ;
}
send_to_char( "You cannot climb there.\n\r", ch );
return ;
}
/*
* "enter" something (moves through an exit) -Thoric
*/
void do_enter( CHAR_DATA *ch, char *argument )
{
EXIT_DATA *pexit;
bool found;
found = FALSE;
if ( argument[0] == '\0' )
{
for ( pexit = ch->in_room->first_exit; pexit; pexit = pexit->next )
if ( IS_SET( pexit->exit_info, EX_xENTER ) )
{
move_char( ch, pexit, 0 );
return ;
}
if ( ch->in_room->sector_type != SECT_INSIDE && IS_OUTSIDE(ch) )
for ( pexit = ch->in_room->first_exit; pexit; pexit = pexit->next )
if ( pexit->to_room && (pexit->to_room->sector_type == SECT_INSIDE
|| xIS_SET(pexit->to_room->room_flags, ROOM_INDOORS)) )
{
move_char( ch, pexit, 0 );
return ;
}
send_to_char( "You cannot find an entrance here.\n\r", ch );
return ;
}
if ( (pexit = find_door( ch, argument, TRUE )) != NULL
&& IS_SET( pexit->exit_info, EX_xENTER ))
{
move_char( ch, pexit, 0 );
return ;
}
send_to_char( "You cannot enter that.\n\r", ch );
return ;
}
/*
* Leave through an exit. -Thoric
*/
void do_leave( CHAR_DATA *ch, char *argument )
{
EXIT_DATA *pexit;
bool found;
found = FALSE;
if ( argument[0] == '\0' )
{
for ( pexit = ch->in_room->first_exit; pexit; pexit = pexit->next )
if ( IS_SET( pexit->exit_info, EX_xLEAVE ) )
{
move_char( ch, pexit, 0 );
return ;
}
if ( ch->in_room->sector_type == SECT_INSIDE || !IS_OUTSIDE(ch) )
for ( pexit = ch->in_room->first_exit; pexit; pexit = pexit->next )
if ( pexit->to_room && pexit->to_room->sector_type != SECT_INSIDE
&& !xIS_SET(pexit->to_room->room_flags, ROOM_INDOORS) )
{
move_char( ch, pexit, 0 );
return ;
}
send_to_char( "You cannot find an exit here.\n\r", ch );
return ;
}
if ( (pexit = find_door( ch, argument, TRUE )) != NULL
&& IS_SET( pexit->exit_info, EX_xLEAVE ))
{
move_char( ch, pexit, 0 );
return ;
}
send_to_char( "You cannot leave that way.\n\r", ch );
return ;
}
|