Skip to content

Commit

Permalink
fix: don't sink down a floor from stepladder (cataclysmbnteam#3367)
Browse files Browse the repository at this point in the history
* fix: don't sink down a floor from stepladder

* style(autofix.ci): automated formatting

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
  • Loading branch information
scarf005 and autofix-ci[bot] authored Oct 5, 2023
1 parent fc9f59f commit 30c5dcb
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/avatar_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,19 @@ bool avatar_action::move( avatar &you, map &m, const tripoint &d )
const bool auto_features = get_option<bool>( "AUTO_FEATURES" );
const bool auto_mine = auto_features && get_option<bool>( "AUTO_MINING" );

const auto can_use_ladder = [&]() -> bool {
if( is_riding || m.has_floor_or_support( dest_loc ) )
{
return false;
}
return m.has_flag( flag_LADDER, dest_loc + tripoint_below );
};

bool via_ramp = false;
if( m.has_flag( TFLAG_RAMP_UP, dest_loc ) ) {
dest_loc.z += 1;
via_ramp = true;
} else if( m.has_flag( TFLAG_RAMP_DOWN, dest_loc ) ||
( !is_riding && m.has_flag( flag_LADDER, dest_loc + tripoint_below ) ) ) {
} else if( m.has_flag( TFLAG_RAMP_DOWN, dest_loc ) || can_use_ladder() ) {
dest_loc.z -= 1;
via_ramp = true;
}
Expand Down

0 comments on commit 30c5dcb

Please sign in to comment.