diff --git a/Server/Components/NPCs/npcs_impl.cpp b/Server/Components/NPCs/npcs_impl.cpp index 7364d9f28..260ff951f 100644 --- a/Server/Components/NPCs/npcs_impl.cpp +++ b/Server/Components/NPCs/npcs_impl.cpp @@ -37,6 +37,12 @@ void NPCComponent::onInit(IComponentList* components) void NPCComponent::free() { + auto shallowCopy = storage._entries(); + for (auto npc : shallowCopy) + { + release(npc->getID()); + } + core->getEventDispatcher().removeEventHandler(this); core->getPlayers().getPlayerDamageDispatcher().removeEventHandler(this); core->getPlayers().getPoolEventDispatcher().removeEventHandler(this);