From c83af30ed8f88900a46df4da230f97dbab8aaa2d Mon Sep 17 00:00:00 2001 From: Alexey Kim Date: Thu, 15 Sep 2022 17:34:23 +0300 Subject: [PATCH] More misc vehicle menu fixes --- src/vehicle.h | 4 ---- src/vehicle_use.cpp | 17 +++++------------ tests/vehicle_fake_part_test.cpp | 18 +++++++++--------- 3 files changed, 14 insertions(+), 25 deletions(-) diff --git a/src/vehicle.h b/src/vehicle.h index 4f0ed9b863630..b36421e98fd82 100644 --- a/src/vehicle.h +++ b/src/vehicle.h @@ -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 ); @@ -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 diff --git a/src/vehicle_use.cpp b/src/vehicle_use.cpp index 20311506c207b..c9b101022a870 100644 --- a/src/vehicle_use.cpp +++ b/src/vehicle_use.cpp @@ -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" ) ) { @@ -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(); @@ -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() @@ -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 ) ); + } ); } } diff --git a/tests/vehicle_fake_part_test.cpp b/tests/vehicle_fake_part_test.cpp index 52818c51a3c61..c82f77e30e38b 100644 --- a/tests/vehicle_fake_part_test.cpp +++ b/tests/vehicle_fake_part_test.cpp @@ -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 ); @@ -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 ); } } @@ -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( 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 ); @@ -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; } @@ -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( 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 );