summaryrefslogtreecommitdiff
path: root/src/map/npc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/npc.cpp')
-rw-r--r--src/map/npc.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/map/npc.cpp b/src/map/npc.cpp
index ee2f30c..efb2ba3 100644
--- a/src/map/npc.cpp
+++ b/src/map/npc.cpp
@@ -1050,6 +1050,18 @@ void npc_free_internal(dumb_ptr<npc_data> nd_)
nd_->bl_m->npc[nd_->n] = nullptr;
}
+ // Also clean up any events we registered to the global ev_db
+ if (auto nd = nd_->is_script())
+ {
+ for (auto& pair : ev_db)
+ {
+ if (pair.second.nd == nd)
+ {
+ ev_db.erase(pair.first);
+ }
+ }
+ }
+
nd_.delete_();
}