From cbc5431d62e3fe9166f18395dce3ddf2af0906d3 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Sat, 28 Mar 2026 21:32:23 +0000 Subject: Switch modules from reference<> to shared_ptr<> and weak_ptr<>. --- modules/customprefix.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'modules/customprefix.cpp') diff --git a/modules/customprefix.cpp b/modules/customprefix.cpp index ea6bb2a58..6f76b4db0 100644 --- a/modules/customprefix.cpp +++ b/modules/customprefix.cpp @@ -28,7 +28,7 @@ class CustomPrefixMode final public: std::shared_ptr tag; - CustomPrefixMode(Module* parent, const std::string& Name, char Letter, char Prefix, const std::shared_ptr& Tag) + CustomPrefixMode(const WeakModulePtr& parent, const std::string& Name, char Letter, char Prefix, const std::shared_ptr& Tag) : PrefixMode(parent, Name, Letter, 0, Prefix) , tag(Tag) { @@ -62,20 +62,20 @@ public: { const std::string name = tag->getString("name"); if (name.empty()) - throw ModuleException(this, " must be specified at " + tag->source.str()); + throw ModuleException(weak_from_this(), " must be specified at " + tag->source.str()); if (name.find(' ') != std::string::npos) - throw ModuleException(this, " must not contain spaces at " + tag->source.str()); + throw ModuleException(weak_from_this(), " must not contain spaces at " + tag->source.str()); if (tag->getBool("change")) { ModeHandler* mh = ServerInstance->Modes.FindMode(name, MODETYPE_CHANNEL); if (!mh) - throw ModuleException(this, " specified for a nonexistent mode at " + tag->source.str()); + throw ModuleException(weak_from_this(), " specified for a nonexistent mode at " + tag->source.str()); PrefixMode* pm = mh->IsPrefixMode(); if (!pm) - throw ModuleException(this, " specified for a non-prefix mode at " + tag->source.str()); + throw ModuleException(weak_from_this(), " specified for a non-prefix mode at " + tag->source.str()); ModeHandler::Rank rank = tag->getNum("rank", pm->GetPrefixRank(), 1); ModeHandler::Rank setrank = tag->getNum("ranktoset", pm->GetLevelRequired(true), rank); @@ -91,21 +91,21 @@ public: const std::string letter = tag->getString("letter"); if (letter.length() != 1) - throw ModuleException(this, " must be set to a mode character at " + tag->source.str()); + throw ModuleException(weak_from_this(), " must be set to a mode character at " + tag->source.str()); const std::string prefix = tag->getString("prefix"); if (prefix.length() != 1) - throw ModuleException(this, " must be set to a mode prefix at " + tag->source.str()); + throw ModuleException(weak_from_this(), " must be set to a mode prefix at " + tag->source.str()); try { - auto* mh = new CustomPrefixMode(this, name, letter[0], prefix[0], tag); + auto* mh = new CustomPrefixMode(weak_from_this(), name, letter[0], prefix[0], tag); modes.push_back(mh); ServerInstance->Modules.AddService(*mh); } catch (const ModuleException& e) { - throw ModuleException(this, e.GetReason() + " (while creating mode from " + tag->source.str() + ")"); + throw ModuleException(weak_from_this(), e.GetReason() + " (while creating mode from " + tag->source.str() + ")"); } } } -- cgit v1.3.1-10-gc9f91