diff options
| author | 2026-03-28 21:32:23 +0000 | |
|---|---|---|
| committer | 2026-03-29 00:42:15 +0000 | |
| commit | cbc5431d62e3fe9166f18395dce3ddf2af0906d3 (patch) | |
| tree | 48a87fc27dc4826ce0caf4071e2060a9ff9e24c5 /modules/customprefix.cpp | |
| parent | Move service code from base to its own header. (diff) | |
Switch modules from reference<> to shared_ptr<> and weak_ptr<>.
Diffstat (limited to 'modules/customprefix.cpp')
| -rw-r--r-- | modules/customprefix.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
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<ConfigTag> tag; - CustomPrefixMode(Module* parent, const std::string& Name, char Letter, char Prefix, const std::shared_ptr<ConfigTag>& Tag) + CustomPrefixMode(const WeakModulePtr& parent, const std::string& Name, char Letter, char Prefix, const std::shared_ptr<ConfigTag>& 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, "<customprefix:name> must be specified at " + tag->source.str()); + throw ModuleException(weak_from_this(), "<customprefix:name> must be specified at " + tag->source.str()); if (name.find(' ') != std::string::npos) - throw ModuleException(this, "<customprefix:name> must not contain spaces at " + tag->source.str()); + throw ModuleException(weak_from_this(), "<customprefix:name> 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, "<customprefix:change> specified for a nonexistent mode at " + tag->source.str()); + throw ModuleException(weak_from_this(), "<customprefix:change> specified for a nonexistent mode at " + tag->source.str()); PrefixMode* pm = mh->IsPrefixMode(); if (!pm) - throw ModuleException(this, "<customprefix:change> specified for a non-prefix mode at " + tag->source.str()); + throw ModuleException(weak_from_this(), "<customprefix:change> specified for a non-prefix mode at " + tag->source.str()); ModeHandler::Rank rank = tag->getNum<ModeHandler::Rank>("rank", pm->GetPrefixRank(), 1); ModeHandler::Rank setrank = tag->getNum<ModeHandler::Rank>("ranktoset", pm->GetLevelRequired(true), rank); @@ -91,21 +91,21 @@ public: const std::string letter = tag->getString("letter"); if (letter.length() != 1) - throw ModuleException(this, "<customprefix:letter> must be set to a mode character at " + tag->source.str()); + throw ModuleException(weak_from_this(), "<customprefix:letter> 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, "<customprefix:prefix> must be set to a mode prefix at " + tag->source.str()); + throw ModuleException(weak_from_this(), "<customprefix:prefix> 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() + ")"); } } } |
