From e8f77ab4c9ed02ab697a9bd618f3ed45549d7d85 Mon Sep 17 00:00:00 2001 From: Paul Harvey <2677507+prharvey@users.noreply.github.com> Date: Tue, 14 Nov 2023 13:09:37 -0700 Subject: [PATCH] Move remove_creature_from_reachability calls from the destructor to on_unload. The avatar never unloads. (#69368) --- src/creature.cpp | 7 +------ src/monster.cpp | 1 + src/npc.cpp | 1 + 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/creature.cpp b/src/creature.cpp index 81278e888a125..11b257baa79e1 100644 --- a/src/creature.cpp +++ b/src/creature.cpp @@ -168,12 +168,7 @@ Creature::Creature( Creature && ) noexcept( map_is_noexcept &&list_is_noexcept ) Creature &Creature::operator=( const Creature & ) = default; Creature &Creature::operator=( Creature && ) noexcept = default; -Creature::~Creature() -{ - if( g ) { - get_map().remove_creature_from_reachability( this ); - } -} +Creature::~Creature() = default; tripoint Creature::pos() const { diff --git a/src/monster.cpp b/src/monster.cpp index 427c71995eb4d..34c5c0ed34fc3 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -3703,6 +3703,7 @@ bool monster::will_join_horde( int size ) void monster::on_unload() { last_updated = calendar::turn; + get_map().remove_creature_from_reachability( this ); } void monster::on_load() diff --git a/src/npc.cpp b/src/npc.cpp index a467497c68164..e48cc66d2f53e 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -3196,6 +3196,7 @@ void npc::add_new_mission( class mission *miss ) void npc::on_unload() { + get_map().remove_creature_from_reachability( this ); } // A throtled version of player::update_body since npc's don't need to-the-turn updates.