X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmode.cpp;h=9d17f5be8b8eda5cae8a329fd550ef2d3d6d6b08;hb=8f5952d1e56c9dbefebbacfc7e40546a9df901e8;hp=98b0f98540449f4543628c7620da7b5d54310014;hpb=b76ff64daeeb1e1081cff93c611f730e5b1b051e;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/mode.cpp b/src/mode.cpp index 98b0f9854..9d17f5be8 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -24,7 +24,6 @@ #include "inspircd.h" -#include "builtinmodes.h" ModeHandler::ModeHandler(Module* Creator, const std::string& Name, char modeletter, ParamSpec Params, ModeType type, Class mclass) : ServiceProvider(Creator, Name, SERVICE_MODE) @@ -90,6 +89,11 @@ void ModeHandler::DisplayEmptyList(User*, Channel*) void ModeHandler::OnParameterMissing(User* user, User* dest, Channel* channel) { + const std::string message = InspIRCd::Format("You must specify a parameter for the %s mode", name.c_str()); + if (channel) + user->WriteNumeric(Numerics::InvalidModeParameter(channel, this, "*", message)); + else + user->WriteNumeric(Numerics::InvalidModeParameter(dest, this, "*", message)); } bool ModeHandler::ResolveModeConflict(std::string& theirs, const std::string& ours, Channel*) @@ -450,6 +454,12 @@ unsigned int ModeParser::ProcessSingle(User* user, Channel* targetchannel, User* Modes::Change& item = *i; ModeHandler* mh = item.mh; + // If a mode change has been given for a mode that does not exist then reject + // it. This can happen when core_reloadmodule attempts to restore a mode that + // no longer exists. + if (!mh) + continue; + // If the mode is supposed to have a parameter then we first take a look at item.param // and, if we were asked to, also handle mode merges now if (mh->NeedsParam(item.adding)) @@ -894,53 +904,6 @@ void PrefixMode::RemoveMode(Channel* chan, Modes::ChangeList& changelist) } } -struct builtin_modes -{ - SimpleChannelModeHandler s; - SimpleChannelModeHandler p; - SimpleChannelModeHandler m; - SimpleChannelModeHandler t; - - SimpleChannelModeHandler n; - SimpleChannelModeHandler i; - ModeChannelKey k; - ModeChannelLimit l; - - ModeChannelBan b; - ModeChannelOp o; - ModeChannelVoice v; - - SimpleUserModeHandler ui; - ModeUserOperator uo; - ModeUserServerNoticeMask us; - - builtin_modes() - : s(NULL, "secret", 's') - , p(NULL, "private", 'p') - , m(NULL, "moderated", 'm') - , t(NULL, "topiclock", 't') - , n(NULL, "noextmsg", 'n') - , i(NULL, "inviteonly", 'i') - , ui(NULL, "invisible", 'i') - { - } - - void init() - { - ServiceProvider* modes[] = { &s, &p, &m, &t, &n, &i, &k, &l, &b, &o, &v, - &ui, &uo, &us }; - ServerInstance->Modules->AddServices(modes, sizeof(modes)/sizeof(ServiceProvider*)); - } -}; - -static builtin_modes static_modes; - -void ModeParser::InitBuiltinModes() -{ - static_modes.init(); - static_modes.b.DoRehash(); -} - bool ModeParser::IsModeChar(char chr) { return ((chr >= 'A' && chr <= 'Z') || (chr >= 'a' && chr <= 'z'));