Skip to content

Commit

Permalink
Fix furniture being "destroyed" when grab-moving (#47457)
Browse files Browse the repository at this point in the history
  • Loading branch information
Saicchi authored Feb 14, 2021
1 parent b198aa9 commit 1e40b42
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10520,7 +10520,7 @@ bool game::grabbed_furn_move( const tripoint &dp )

// Actually move the furniture.
m.furn_set( fdest, m.furn( fpos ) );
m.furn_set( fpos, f_null );
m.furn_set( fpos, f_null, true );

if( fire_intensity == 1 && !pulling_furniture ) {
m.remove_field( fpos, fd_fire );
Expand Down
3 changes: 2 additions & 1 deletion src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1331,7 +1331,7 @@ furn_id map::furn( const tripoint &p ) const
return current_submap->get_furn( l );
}

void map::furn_set( const tripoint &p, const furn_id &new_furniture )
void map::furn_set( const tripoint &p, const furn_id &new_furniture, const bool furn_reset )
{
if( !inbounds( p ) ) {
return;
Expand All @@ -1358,6 +1358,7 @@ void map::furn_set( const tripoint &p, const furn_id &new_furniture )
avatar &player_character = get_avatar();
// If player has grabbed this furniture and it's no longer grabbable, release the grab.
if( player_character.get_grab_type() == object_type::FURNITURE &&
!furn_reset &&
player_character.pos() + player_character.grab_point == p && !new_t.is_movable() ) {
add_msg( _( "The %s you were grabbing is destroyed!" ), old_t.name() );
player_character.grab( object_type::NONE );
Expand Down
6 changes: 5 additions & 1 deletion src/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,11 @@ class map
furn_id furn( const point &p ) const {
return furn( tripoint( p, abs_sub.z ) );
}
void furn_set( const tripoint &p, const furn_id &new_furniture );
/**
* furn_reset should be true if new_furniture is being set to f_null
* when the player is grab-moving furniture
*/
void furn_set( const tripoint &p, const furn_id &new_furniture, bool furn_reset = false );
void furn_set( const point &p, const furn_id &new_furniture ) {
furn_set( tripoint( p, abs_sub.z ), new_furniture );
}
Expand Down

0 comments on commit 1e40b42

Please sign in to comment.