Skip to content

Commit

Permalink
Deduplicate a couple of bash checks in lieu of making it optional
Browse files Browse the repository at this point in the history
  • Loading branch information
Procyonae committed Jun 9, 2024
1 parent 09dad60 commit af2417c
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3269,12 +3269,7 @@ bool map::is_bashable( const tripoint &p, const bool allow_floor ) const
return true;
}

if( has_furn( p ) && furn( p ).obj().bash.str_max != -1 ) {
return true;
}

const map_ter_bash_info &ter_bash = ter( p ).obj().bash;
return ter_bash.str_max != -1 && ( !ter_bash.bash_below || allow_floor );
return is_bashable_ter_furn( p, allow_floor );
}

bool map::is_bashable_ter( const tripoint &p, const bool allow_floor ) const
Expand Down Expand Up @@ -3305,27 +3300,25 @@ bool map::is_bashable_ter_furn( const tripoint &p, const bool allow_floor ) cons

int map::bash_strength( const tripoint &p, const bool allow_floor ) const
{
if( has_furn( p ) && furn( p ).obj().bash.str_max != -1 ) {
if( is_bashable_furn( p ) ) {
return furn( p ).obj().bash.str_max;
}

const map_ter_bash_info &ter_bash = ter( p ).obj().bash;
if( ter_bash.str_max != -1 && ( !ter_bash.bash_below || allow_floor ) ) {
return ter_bash.str_max;
if( is_bashable_ter( p, allow_floor ) ) {
return ter( p ).obj().bash.str_max;
}

return -1;
}

int map::bash_resistance( const tripoint &p, const bool allow_floor ) const
{
if( has_furn( p ) && furn( p ).obj().bash.str_min != -1 ) {
if( is_bashable_furn( p ) ) {
return furn( p ).obj().bash.str_min;
}

const map_ter_bash_info &ter_bash = ter( p ).obj().bash;
if( ter_bash.str_min != -1 && ( !ter_bash.bash_below || allow_floor ) ) {
return ter_bash.str_min;
if( is_bashable_ter( p, allow_floor ) ) {
return ter( p ).obj().bash.str_min;
}

return -1;
Expand Down

0 comments on commit af2417c

Please sign in to comment.