Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More misc vehicle menu fixes #61025

Merged
merged 1 commit into from
Sep 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
More misc vehicle menu fixes
  • Loading branch information
irwiss committed Sep 15, 2022
commit c83af30ed8f88900a46df4da230f97dbab8aaa2d
4 changes: 0 additions & 4 deletions src/vehicle.h
Original file line number Diff line number Diff line change
@@ -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
17 changes: 5 additions & 12 deletions src/vehicle_use.cpp
Original file line number Diff line number Diff line change
@@ -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 ) );
} );
}
}

18 changes: 9 additions & 9 deletions tests/vehicle_fake_part_test.cpp
Original file line number Diff line number Diff line change
@@ -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<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 );
@@ -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<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 );