From 45f10a7f6f3dfdca38051c14020c2f6bd2646054 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Fri, 13 Sep 2024 11:52:26 +0100 Subject: [PATCH] Only remove extbans on unload if provided by the right module. --- include/base.h | 1 + src/coremods/core_channel/extban.cpp | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/base.h b/include/base.h index c2c7397d8..f655eb4b6 100644 --- a/include/base.h +++ b/include/base.h @@ -116,6 +116,7 @@ public: return *this; } + inline T* ptr() const { return value; } inline operator bool() const { return (value != nullptr); } inline operator T*() const { return value; } inline T* operator->() const { return value; } diff --git a/src/coremods/core_channel/extban.cpp b/src/coremods/core_channel/extban.cpp index 13ecfcb7f..c9c2611fd 100644 --- a/src/coremods/core_channel/extban.cpp +++ b/src/coremods/core_channel/extban.cpp @@ -153,8 +153,13 @@ ModResult ExtBanManager::GetStatus(ExtBan::ActingBase* extban, User* user, Chann void ExtBanManager::DelExtBan(ExtBan::Base* extban) { - byletter.erase(extban->GetLetter()); - byname.erase(extban->GetName()); + auto lit = byletter.find(extban->GetLetter()); + if (lit != byletter.end() && lit->second->creator.ptr() == extban->creator.ptr()) + byletter.erase(lit); + + auto nit = byname.find(extban->GetName()); + if (nit != byname.end() && nit->second->creator.ptr() == extban->creator.ptr()) + byname.erase(nit); } ExtBan::Base* ExtBanManager::FindName(const std::string& xbname) const