Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix companions ceasing activities when PC enter Z level #72883

Merged
merged 2 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3060,6 +3060,13 @@ void Character::remove_mission_items( int mission_id )
void Character::on_move( const tripoint_abs_ms &old_pos )
{
Creature::on_move( old_pos );
// Ugly to compare a tripoint_bub_ms with a tripoint_abs_ms, but the 'z' component
// is the same regardless of the x/y reference point.
if( this->pos_bub().z() != old_pos.z() ) {
// Make sure caches are rebuilt in a timely manner to ensure companions aren't
// caught in the "dark" because the caches aren't updated on their next move.
get_map().build_map_cache( this->pos_bub().z() );
}
// In case we've moved out of range of lifting assist.
if( using_lifting_assist ) {
invalidate_weight_carried_cache();
Expand Down
6 changes: 2 additions & 4 deletions tests/char_sight_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,10 @@ TEST_CASE( "light_and_fine_detail_vision_mod", "[character][sight][light][vision

SECTION( "midnight with a new moon" ) {
// yes, surprisingly, we need to test for this
calendar::turn = calendar::turn_zero;
tripoint const z_shift = GENERATE( tripoint_above, tripoint_zero );
dummy.setpos( dummy.pos() + z_shift );
dummy.setpos( dummy.pos() + z_shift ); // This implicitly rebuilds the light map.
CAPTURE( z_shift );

calendar::turn = calendar::turn_zero;
here.build_map_cache( 0, false );
REQUIRE_FALSE( g->is_in_sunlight( dummy.pos() ) );
REQUIRE( here.ambient_light_at( dummy.pos() ) == Approx( LIGHT_AMBIENT_MINIMAL ) );

Expand Down
Loading