Skip to content

Commit

Permalink
More misc vehicle menu fixes (#61025)
Browse files Browse the repository at this point in the history
  • Loading branch information
irwiss authored Sep 16, 2022
1 parent a446e04 commit b1e5ac1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 25 deletions.
4 changes: 0 additions & 4 deletions src/vehicle.h
Original file line number Diff line number Diff line change
Expand Up @@ -1768,8 +1768,6 @@ class vehicle
// opens/closes doors or multipart doors
void open( int part_index );
void close( int part_index );
// returns whether the door is open or not
bool is_open( int part_index ) const;

bool can_close( int part_index, Character &who );

Expand All @@ -1779,8 +1777,6 @@ class vehicle
time_duration folding_time() const;
// @returns how long should unfolding activity take
time_duration unfolding_time() const;
// assigns folding activity to player avatar
void start_folding_activity();
// @returns item of this vehicle folded
item get_folded_item() const;
// restores vehicle parts from a folded item
Expand Down
17 changes: 5 additions & 12 deletions src/vehicle_use.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,11 +558,6 @@ void vehicle::connect( const tripoint &source_pos, const tripoint &target_pos )
target_veh->install_part( vcoords, target_part );
}

void vehicle::start_folding_activity()
{
get_avatar().assign_activity( player_activity( vehicle_folding_activity_actor( *this ) ) );
}

double vehicle::engine_cold_factor( const int e ) const
{
if( !part_info( engines[e] ).has_flag( "E_COLD_START" ) ) {
Expand Down Expand Up @@ -1204,11 +1199,6 @@ void vehicle::close( int part_index )
}
}

bool vehicle::is_open( int part_index ) const
{
return parts[part_index].open;
}

bool vehicle::can_close( int part_index, Character &who )
{
creature_tracker &creatures = get_creature_tracker();
Expand Down Expand Up @@ -1719,7 +1709,7 @@ void vehicle::build_interact_menu( veh_menu &menu, const tripoint &p, bool with_
const bool controls_here = has_part_here( "CONTROLS" );
const bool player_is_driving = get_player_character().controlling_vehicle;

if( !has_tag( flag_APPLIANCE ) && !player_is_driving ) {
if( !has_tag( flag_APPLIANCE ) ) {
menu.add( _( "Examine vehicle" ) )
.skip_theft_check()
.skip_locked_check()
Expand Down Expand Up @@ -2100,7 +2090,10 @@ void vehicle::build_interact_menu( veh_menu &menu, const tripoint &p, bool with_
if( is_foldable() && !remote ) {
menu.add( string_format( _( "Fold %s" ), name ) )
.hotkey( "FOLD_VEHICLE" )
.on_submit( [this] { start_folding_activity(); } );
.on_submit( [this] {
vehicle_folding_activity_actor folding_act( *this );
get_avatar().assign_activity( player_activity( folding_act ) );
} );
}
}

Expand Down
18 changes: 9 additions & 9 deletions tests/vehicle_fake_part_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ TEST_CASE( "ensure_fake_parts_enable_on_turn", "[vehicle] [vehicle_fake]" )
for( const vpart_reference &vp : veh->get_all_parts_with_fakes( true ) ) {
if( vp.info().has_flag( "OPENABLE" ) ) {
tested_a_fake |= vp.part().is_fake;
CHECK( veh->is_open( vp.part_index() ) );
CHECK( vp.part().open );
}
}
REQUIRE( tested_a_fake );
Expand All @@ -136,7 +136,7 @@ TEST_CASE( "ensure_fake_parts_enable_on_turn", "[vehicle] [vehicle_fake]" )
}
for( const vpart_reference &vp : veh->get_all_parts_with_fakes( true ) ) {
if( vp.info().has_flag( "OPENABLE" ) ) {
CHECK( !veh->is_open( vp.part_index() ) );
CHECK( !vp.part().open );
}
}

Expand Down Expand Up @@ -361,15 +361,15 @@ TEST_CASE( "open_and_close_fake_doors", "[vehicle][vehicle_fake]" )
for( const vpart_reference &vp : veh->get_all_parts_with_fakes() ) {
if( vp.info().has_flag( "OPENABLE" ) && vp.part().is_fake ) {
fakes_tested++;
REQUIRE( !veh->is_open( vp.part_index() ) );
REQUIRE( !vp.part().open );
CHECK( can_interact_at( ACTION_OPEN, vp.pos() ) );
int part_to_open = veh->next_part_to_open( vp.part_index() );
// This should be the same part for this use case since there are no curtains etc.
REQUIRE( part_to_open == static_cast<int>( vp.part_index() ) );
// Using open_all_at because it will usually be from outside the vehicle.
veh->open_all_at( part_to_open );
CHECK( veh->is_open( vp.part_index() ) );
CHECK( veh->is_open( vp.part().fake_part_to ) );
CHECK( vp.part().open );
CHECK( veh->part( vp.part().fake_part_to ).open );
}
}
REQUIRE( fakes_tested == 4 );
Expand All @@ -379,7 +379,7 @@ TEST_CASE( "open_and_close_fake_doors", "[vehicle][vehicle_fake]" )
for( const vpart_reference &vp : veh->get_avail_parts( "OPENABLE" ) ) {
REQUIRE( !vp.part().is_fake );
veh->open( vp.part_index() );
REQUIRE( veh->is_open( vp.part_index() ) );
REQUIRE( vp.part().open );
if( !vp.part().has_fake ) {
continue;
}
Expand All @@ -406,15 +406,15 @@ TEST_CASE( "open_and_close_fake_doors", "[vehicle][vehicle_fake]" )
for( const vpart_reference &vp : veh->get_all_parts_with_fakes() ) {
if( vp.info().has_flag( "OPENABLE" ) && vp.part().is_fake ) {
fakes_tested++;
CHECK( veh->is_open( vp.part_index() ) );
CHECK( vp.part().open );
CHECK( can_interact_at( ACTION_CLOSE, vp.pos() ) );
int part_to_close = veh->next_part_to_close( vp.part_index() );
// This should be the same part for this use case since there are no curtains etc.
REQUIRE( part_to_close == static_cast<int>( vp.part_index() ) );
// Using open_all_at because it will usually be from outside the vehicle.
veh->close( part_to_close );
CHECK( !veh->is_open( vp.part_index() ) );
CHECK( !veh->is_open( vp.part().fake_part_to ) );
CHECK( !vp.part().open );
CHECK( !veh->part( vp.part().fake_part_to ).open );
}
}
REQUIRE( fakes_tested == 4 );
Expand Down

0 comments on commit b1e5ac1

Please sign in to comment.