aboutsummaryrefslogtreecommitdiffstats
path: root/src/mode.cpp
diff options
context:
space:
mode:
authorGravatar Sadie Powell2026-02-27 21:13:21 +0000
committerGravatar Sadie Powell2026-03-02 19:01:01 +0000
commit0c02218d0666397c6ba2b8c0097df83f83d1f50f (patch)
treefc102c2ebbfffadb985404478605e569da9d92b4 /src/mode.cpp
parentAdd irc::less and convert irc::insensitive_swo to use it. (diff)
Massive rework of how internal service providers work.
- ServiceType is dead. All modules use RegisterService now. - Modules can implement UnregisterService which is called from DelService now. - Split the service type prefix into its own field. - Renamed Service::name to Service::service_name. This revealed a few bugs.
Diffstat (limited to 'src/mode.cpp')
-rw-r--r--src/mode.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/mode.cpp b/src/mode.cpp
index 6cd77ed2c..51e63bf86 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -32,7 +32,7 @@
#include "numerichelper.h"
ModeHandler::ModeHandler(Module* Creator, const std::string& Name, char modeletter, ParamSpec Params, ModeType type, Class mclass)
- : ServiceProvider(Creator, Name, SERVICE_MODE)
+ : ServiceProvider(Creator, FMT::format("ModeHandler/{}", type == MODETYPE_CHANNEL ? "C" : "U"), Name)
, modeid(ModeParser::MODEID_MAX)
, parameters_taken(Params)
, mode(ServerInstance->Config->ConfValue("modes")->getCharacter(Name, modeletter))
@@ -115,7 +115,16 @@ bool ModeHandler::ResolveModeConflict(const std::string& theirs, const std::stri
void ModeHandler::RegisterService()
{
ServerInstance->Modes.AddMode(this);
- ServerInstance->Modules.AddReferent((GetModeType() == MODETYPE_CHANNEL ? "mode/" : "umode/") + this->service_name, this);
+ ServerInstance->Modules.AddReferent(GetModeType() == MODETYPE_CHANNEL ? "ModeHandler/C" : "ModeHandler/U",
+ this->service_name, this);
+}
+
+void ModeHandler::UnregisterService()
+{
+ if (!ServerInstance->Modes.DelMode(this))
+ throw ModuleException(creator, "Mode {} does not exist.", this->service_name);
+
+ ServerInstance->Modules.DelReferent(this);
}
bool SimpleUserMode::OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change)