Skip to content

Commit

Permalink
Did you know stashing changes for one branch on another by accident a…
Browse files Browse the repository at this point in the history
…nd forgetting about them is not great?
  • Loading branch information
Procyonae committed Dec 13, 2024
1 parent f4e4464 commit 035bf29
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11051,7 +11051,7 @@ void Character::gravity_check()
map &here = get_map();
if( here.is_open_air( pos_bub() ) && !has_effect_with_flag( json_flag_GLIDING ) &&
here.try_fall( pos_bub(), this ) ) {
get_map().update_visibility_cache( pos_bub().z() );
here.update_visibility_cache( pos_bub().z() );
}
}

Expand Down
4 changes: 1 addition & 3 deletions src/do_turn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,9 +488,6 @@ bool do_turn()
}
}

// Make sure players cant defy gravity by standing still, Looney tunes style.
u.gravity_check();

// If you're inside a wall or something and haven't been telefragged, let's get you out.
if( ( m.impassable( u.pos_bub() ) && !m.impassable_field_at( u.pos_bub() ) ) &&
!m.has_flag( ter_furn_flag::TFLAG_CLIMBABLE, u.pos_bub() ) ) {
Expand Down Expand Up @@ -557,6 +554,7 @@ bool do_turn()
if( !u.has_effect( effect_sleep ) || g->uquit == QUIT_WATCH ) {
if( u.get_moves() > 0 || g->uquit == QUIT_WATCH ) {
while( u.get_moves() > 0 || g->uquit == QUIT_WATCH ) {
m.process_falling();
g->cleanup_dead();
g->mon_info_update();
// Process any new sounds the player caused during their turn.
Expand Down
1 change: 0 additions & 1 deletion src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11749,7 +11749,6 @@ bool game::grabbed_furn_move( const tripoint_rel_ms &dp )
std::string danger_tile = enumerate_as_string( get_dangerous_tile( fdest ) );
add_msg( _( "You let go of the %1$s as it falls down the %2$s." ), furntype.name(), danger_tile );
u.grab( object_type::NONE );
m.drop_furniture( fdest );
return true;
}

Expand Down
1 change: 0 additions & 1 deletion src/iuse_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1202,7 +1202,6 @@ std::optional<int> deploy_furn_actor::use( Character *p, item &it,
}

get_map().furn_set( suitable.value(), furn_type );
get_map().drop_furniture( suitable.value() );
it.spill_contents( suitable.value() );
p->mod_moves( -to_moves<int>( 2_seconds ) );
return 1;
Expand Down
31 changes: 24 additions & 7 deletions src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2885,14 +2885,16 @@ bool map::has_vehicle_floor( const tripoint_bub_ms &p ) const

void map::drop_everything( const tripoint_bub_ms &p )
{
if( has_floor_or_water( p ) ) {
return;
}
// Creature has their own gravity check
drop_creature( p );

drop_furniture( p );
drop_items( p );
drop_vehicle( p );
drop_fields( p );
// TODO: Should be more nuance here, only low density items/furniture should float on water etc
if( !has_floor_or_water( p ) ) {
drop_furniture( p );
drop_items( p );
drop_vehicle( p );
drop_fields( p );
}
}

void map::drop_furniture( const tripoint_bub_ms &p )
Expand Down Expand Up @@ -3184,6 +3186,21 @@ void map::drop_fields( const tripoint_bub_ms &p )
}
}

void map::drop_creature( const tripoint_bub_ms &p ) const
{
monster *mon_at_p = get_creature_tracker().creature_at<monster>( p );
if( mon_at_p ) {
mon_at_p->gravity_check();
// Handle character potentially standing on monster ("zed walking")
drop_creature( p + tripoint_rel_ms::above );
return;
}
Character *char_at_p = get_creature_tracker().creature_at<Character>( p );
if( char_at_p ) {
char_at_p->gravity_check();
}
}

void map::support_dirty( const tripoint_bub_ms &p )
{
if( zlevels ) {
Expand Down
7 changes: 4 additions & 3 deletions src/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -1965,18 +1965,19 @@ class map
// TODO: Get rid of untyped overload
bool has_vehicle_floor( const tripoint &p ) const;
bool has_vehicle_floor( const tripoint_bub_ms &p ) const;

private:
/**
* Handles map objects of given type (not creatures) falling down.
* Handles map objects of given type falling down.
*/
/*@{*/
void drop_everything( const tripoint_bub_ms &p );
void drop_furniture( const tripoint_bub_ms &p );
void drop_items( const tripoint_bub_ms &p );
void drop_vehicle( const tripoint_bub_ms &p );
void drop_fields( const tripoint_bub_ms &p );
void drop_creature( const tripoint_bub_ms &p ) const;
/*@}*/

public:
/**
* Invoked @ref drop_everything on cached dirty tiles.
*/
Expand Down

0 comments on commit 035bf29

Please sign in to comment.