Skip to content

Commit

Permalink
Helicopter bugfixes : allow descending into open air while moving, an…
Browse files Browse the repository at this point in the history
…d disallow roof teleporting (#39275)
  • Loading branch information
davidpwbrown authored Apr 6, 2020
1 parent f967c07 commit c6989fc
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/vehicle_move.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,8 @@ bool vehicle::check_heli_descend( player &p )
debugmsg( "A vehicle is somehow flying without being an aircraft" );
return true;
}
int count = 0;
int air_count = 0;
for( const tripoint &pt : get_points( true ) ) {
tripoint below( pt.xy(), pt.z - 1 );
if( g->m.has_zlevels() && ( pt.z < -OVERMAP_DEPTH ||
Expand All @@ -993,8 +995,12 @@ bool vehicle::check_heli_descend( player &p )
_( "It would be unsafe to try and land when there are obstacles below you." ) );
return false;
}
if( g->m.has_flag_ter_or_furn( TFLAG_NO_FLOOR, below ) ) {
air_count++;
}
count++;
}
if( velocity > 0 ) {
if( velocity > 0 && air_count != count ) {
p.add_msg_if_player( m_bad, _( "It would be unsafe to try and land while you are moving." ) );
return false;
}
Expand All @@ -1012,6 +1018,16 @@ bool vehicle::check_heli_ascend( player &p )
p.add_msg_if_player( m_bad, _( "It would be unsafe to try and take off while you are moving." ) );
return false;
}
for( const tripoint &pt : get_points( true ) ) {
tripoint above( pt.xy(), pt.z + 1 );
const optional_vpart_position ovp = g->m.veh_at( above );
if( g->m.impassable_ter_furn( above ) || ovp || g->critter_at( above ) || !g->m.is_outside( pt ) ||
!g->m.is_outside( above ) ) {
p.add_msg_if_player( m_bad,
_( "It would be unsafe to try and ascend when there are obstacles above you." ) );
return false;
}
}
return true;
}

Expand Down

0 comments on commit c6989fc

Please sign in to comment.