From 035bf2963aabf4bd34df6d1ddaa6e54aae388700 Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Thu, 12 Dec 2024 14:06:55 +0000 Subject: [PATCH] Did you know stashing changes for one branch on another by accident and forgetting about them is not great? --- src/character.cpp | 2 +- src/do_turn.cpp | 4 +--- src/game.cpp | 1 - src/iuse_actor.cpp | 1 - src/map.cpp | 31 ++++++++++++++++++++++++------- src/map.h | 7 ++++--- 6 files changed, 30 insertions(+), 16 deletions(-) diff --git a/src/character.cpp b/src/character.cpp index 92bab118704bc..ad74d5f9a7abe 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -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() ); } } diff --git a/src/do_turn.cpp b/src/do_turn.cpp index e2cef4622e979..7d32fcf20e083 100644 --- a/src/do_turn.cpp +++ b/src/do_turn.cpp @@ -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() ) ) { @@ -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. diff --git a/src/game.cpp b/src/game.cpp index a176f74b50e5c..1d4d676064c84 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -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; } diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index 67b64fa01336c..a7c7f17fb0428 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -1202,7 +1202,6 @@ std::optional 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( 2_seconds ) ); return 1; diff --git a/src/map.cpp b/src/map.cpp index 070750d811655..d8e2ac26b17c7 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -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 ) @@ -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( 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( p ); + if( char_at_p ) { + char_at_p->gravity_check(); + } +} + void map::support_dirty( const tripoint_bub_ms &p ) { if( zlevels ) { diff --git a/src/map.h b/src/map.h index 64babe471e00a..4bd9282a633eb 100644 --- a/src/map.h +++ b/src/map.h @@ -1965,9 +1965,9 @@ 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 ); @@ -1975,8 +1975,9 @@ class map 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. */