diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-09-13 20:31:33 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-09-13 20:31:33 +0000 |
commit | 1524caf2f799cff54c2de330c9670a0b761ba3d8 (patch) | |
tree | 45fffe020b28782a087925c94fb5195fb9b4796b /src | |
parent | 7892c8a0313c50d8138942ff3b112691caf05a2f (diff) |
Simplify ModeHandler constructor
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11701 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
43 files changed, 138 insertions, 118 deletions
diff --git a/src/channels.cpp b/src/channels.cpp index adb0e6ebe..9489e57ba 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -351,7 +351,7 @@ Channel* Channel::ForceChan(InspIRCd* Instance, Channel* Ptr, User* user, const if (mh) { /* Set, and make sure that the mode handler knows this mode was now set */ - Ptr->SetPrefix(user, mh->GetModeChar(), mh->GetPrefixRank(), true); + Ptr->SetPrefix(user, mh->GetModeChar(), true); mh->OnModeChange(Instance->FakeClient, Instance->FakeClient, Ptr, nick, true); } } @@ -976,7 +976,7 @@ unsigned int Channel::GetPrefixValue(User* user) return bestrank; } -void Channel::SetPrefix(User* user, char prefix, unsigned int prefix_value, bool adding) +void Channel::SetPrefix(User* user, char prefix, bool adding) { ModeHandler* delta_mh = ServerInstance->Modes->FindMode(prefix, MODETYPE_CHANNEL); if (!delta_mh) diff --git a/src/mode.cpp b/src/mode.cpp index 18384aaef..86438bf73 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -49,8 +49,11 @@ /* +s (server notice masks) */ #include "modes/umode_s.h" -ModeHandler::ModeHandler(InspIRCd* Instance, Module* Creator, char modeletter, int parameters_on, int parameters_off, bool listmode, ModeType type, bool operonly, char mprefix, char prefixrequired, TranslateType translate) - : ServerInstance(Instance), mode(modeletter), n_params_on(parameters_on), n_params_off(parameters_off), list(listmode), m_type(type), m_paramtype(translate), oper(operonly), prefix(mprefix), count(0), prefixneeded(prefixrequired), creator(Creator) +InspIRCd* ModeHandler::ServerInstance; + +ModeHandler::ModeHandler(Module* Creator, char modeletter, ParamSpec Params, ModeType type) + : mode(modeletter), parameters_taken(Params), list(false), m_type(type), m_paramtype(TR_TEXT), + oper(false), prefix(0), count(0), levelrequired(HALFOP_VALUE), creator(Creator) { } @@ -63,18 +66,6 @@ bool ModeHandler::IsListMode() return list; } -char ModeHandler::GetNeededPrefix() -{ - if (prefixneeded == '%' && !ServerInstance->Config->AllowHalfop) - return '@'; - return prefixneeded; -} - -void ModeHandler::SetNeededPrefix(char needsprefix) -{ - prefixneeded = needsprefix; -} - unsigned int ModeHandler::GetPrefixRank() { return 0; @@ -91,29 +82,18 @@ void ModeHandler::ChangeCount(int modifier) ServerInstance->Logs->Log("MODE", DEBUG,"Change count for mode %c is now %d", mode, count); } -ModeType ModeHandler::GetModeType() -{ - return m_type; -} - -TranslateType ModeHandler::GetTranslateType() -{ - return m_paramtype; -} - -bool ModeHandler::NeedsOper() -{ - return oper; -} - -char ModeHandler::GetPrefix() -{ - return prefix; -} - int ModeHandler::GetNumParams(bool adding) { - return adding ? n_params_on : n_params_off; + switch (parameters_taken) + { + case PARAM_ALWAYS: + return 1; + case PARAM_SETONLY: + return adding ? 1 : 0; + case PARAM_NONE: + break; + } + return 0; } char ModeHandler::GetModeChar() @@ -292,36 +272,21 @@ ModeAction ModeParser::TryMode(User* user, User* targetuser, Channel* chan, bool if (chan && !SkipACL && (MOD_RESULT != MOD_RES_ALLOW)) { - char needed = mh->GetNeededPrefix(); - ModeHandler* prefixmode = FindPrefix(needed); - - /* If the mode defined by the handler is not '\0', but the handler for it - * cannot be found, they probably dont have the right module loaded to implement - * the prefix they want to compare the mode against, e.g. '&' for m_chanprotect. - * Revert to checking against the minimum core prefix, '%'. + unsigned int neededrank = mh->GetLevelRequired(); + /* Compare our rank on the channel against the rank of the required prefix, + * allow if >= ours. Because mIRC and xchat throw a tizz if the modes shown + * in NAMES(X) are not in rank order, we know the most powerful mode is listed + * first, so we don't need to iterate, we just look up the first instead. */ - if (needed && !prefixmode) - { - needed = ServerInstance->Config->AllowHalfop ? '%' : '@'; - prefixmode = FindPrefix(needed); - } - - if (needed) - { - unsigned int neededrank = prefixmode->GetPrefixRank(); - /* Compare our rank on the channel against the rank of the required prefix, - * allow if >= ours. Because mIRC and xchat throw a tizz if the modes shown - * in NAMES(X) are not in rank order, we know the most powerful mode is listed - * first, so we don't need to iterate, we just look up the first instead. - */ - unsigned int ourrank = chan->GetPrefixValue(user); - if (ourrank < neededrank) - { - /* Bog off */ - user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :You must have channel privilege %c or above to %sset channel mode %c", - user->nick.c_str(), chan->name.c_str(), needed, adding ? "" : "un", modechar); - return MODEACTION_DENY; - } + unsigned int ourrank = chan->GetPrefixValue(user); + if (ourrank < neededrank) + { + /* Bog off */ + // TODO replace with a real search for the proper prefix + char needed = neededrank > HALFOP_VALUE ? '@' : '%'; + user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :You must have channel privilege %c or above to %sset channel mode %c", + user->nick.c_str(), chan->name.c_str(), needed, adding ? "" : "un", modechar); + return MODEACTION_DENY; } } @@ -378,7 +343,7 @@ ModeAction ModeParser::TryMode(User* user, User* targetuser, Channel* chan, bool { User* user_to_prefix = ServerInstance->FindNick(parameter); if (user_to_prefix) - chan->SetPrefix(user_to_prefix, modechar, mh->GetPrefixRank(), adding); + chan->SetPrefix(user_to_prefix, modechar, adding); } for (ModeWatchIter watchers = modewatchers[handler_id].begin(); watchers != modewatchers[handler_id].end(); watchers++) @@ -978,6 +943,7 @@ void ModeHandler::RemoveMode(Channel* channel, irc::modestacker* stack) ModeParser::ModeParser(InspIRCd* Instance) : ServerInstance(Instance) { + ModeHandler::ServerInstance = Instance; ModeHandler* modes[] = { new ModeChannelSecret(Instance), diff --git a/src/modes/cmode_b.cpp b/src/modes/cmode_b.cpp index 9c9c2129c..d9ecb5b07 100644 --- a/src/modes/cmode_b.cpp +++ b/src/modes/cmode_b.cpp @@ -25,8 +25,9 @@ #include "hashcomp.h" #include "modes/cmode_b.h" -ModeChannelBan::ModeChannelBan(InspIRCd* Instance) : ModeHandler(Instance, NULL, 'b', 1, 1, true, MODETYPE_CHANNEL, false) +ModeChannelBan::ModeChannelBan(InspIRCd* Instance) : ModeHandler(NULL, 'b', PARAM_ALWAYS, MODETYPE_CHANNEL) { + list = true; } ModeAction ModeChannelBan::OnModeChange(User* source, User*, Channel* channel, std::string ¶meter, bool adding) diff --git a/src/modes/cmode_h.cpp b/src/modes/cmode_h.cpp index a61df4ba0..927c7ea73 100644 --- a/src/modes/cmode_h.cpp +++ b/src/modes/cmode_h.cpp @@ -19,8 +19,12 @@ #include "modules.h" #include "modes/cmode_h.h" -ModeChannelHalfOp::ModeChannelHalfOp(InspIRCd* Instance) : ModeHandler(Instance, NULL, 'h', 1, 1, true, MODETYPE_CHANNEL, false, '%', '@', TR_NICK) +ModeChannelHalfOp::ModeChannelHalfOp(InspIRCd* Instance) : ModeHandler(NULL, 'h', PARAM_ALWAYS, MODETYPE_CHANNEL) { + list = true; + prefix = '%'; + levelrequired = OP_VALUE; + m_paramtype = TR_NICK; } unsigned int ModeChannelHalfOp::GetPrefixRank() diff --git a/src/modes/cmode_k.cpp b/src/modes/cmode_k.cpp index c785f6705..ea035e7b8 100644 --- a/src/modes/cmode_k.cpp +++ b/src/modes/cmode_k.cpp @@ -17,7 +17,7 @@ #include "users.h" #include "modes/cmode_k.h" -ModeChannelKey::ModeChannelKey(InspIRCd* Instance) : ModeHandler(Instance, NULL, 'k', 1, 1, false, MODETYPE_CHANNEL, false) +ModeChannelKey::ModeChannelKey(InspIRCd* Instance) : ModeHandler(NULL, 'k', PARAM_ALWAYS, MODETYPE_CHANNEL) { } diff --git a/src/modes/cmode_l.cpp b/src/modes/cmode_l.cpp index a2ba07f10..1aea53a61 100644 --- a/src/modes/cmode_l.cpp +++ b/src/modes/cmode_l.cpp @@ -17,7 +17,7 @@ #include "users.h" #include "modes/cmode_l.h" -ModeChannelLimit::ModeChannelLimit(InspIRCd* Instance) : ModeHandler(Instance, NULL, 'l', 1, 0, false, MODETYPE_CHANNEL, false) +ModeChannelLimit::ModeChannelLimit(InspIRCd* Instance) : ModeHandler(NULL, 'l', PARAM_SETONLY, MODETYPE_CHANNEL) { } diff --git a/src/modes/cmode_o.cpp b/src/modes/cmode_o.cpp index 19c365ad9..8af364ad4 100644 --- a/src/modes/cmode_o.cpp +++ b/src/modes/cmode_o.cpp @@ -19,8 +19,12 @@ #include "modules.h" #include "modes/cmode_o.h" -ModeChannelOp::ModeChannelOp(InspIRCd* Instance) : ModeHandler(Instance, NULL, 'o', 1, 1, true, MODETYPE_CHANNEL, false, '@', '@', TR_NICK) +ModeChannelOp::ModeChannelOp(InspIRCd* Instance) : ModeHandler(NULL, 'o', PARAM_ALWAYS, MODETYPE_CHANNEL) { + list = true; + prefix = '@'; + levelrequired = OP_VALUE; + m_paramtype = TR_NICK; } unsigned int ModeChannelOp::GetPrefixRank() diff --git a/src/modes/cmode_t.cpp b/src/modes/cmode_t.cpp index 6424e1f6c..b3f266086 100644 --- a/src/modes/cmode_t.cpp +++ b/src/modes/cmode_t.cpp @@ -17,7 +17,7 @@ #include "users.h" #include "modes/cmode_t.h" -ModeChannelTopicOps::ModeChannelTopicOps(InspIRCd* Instance) : ModeHandler(Instance, NULL, 't', 0, 0, false, MODETYPE_CHANNEL, false) +ModeChannelTopicOps::ModeChannelTopicOps(InspIRCd* Instance) : ModeHandler(NULL, 't', PARAM_NONE, MODETYPE_CHANNEL) { } diff --git a/src/modes/cmode_v.cpp b/src/modes/cmode_v.cpp index 752dd509b..76faa8aae 100644 --- a/src/modes/cmode_v.cpp +++ b/src/modes/cmode_v.cpp @@ -20,8 +20,12 @@ #include "modules.h" #include "modes/cmode_v.h" -ModeChannelVoice::ModeChannelVoice(InspIRCd* Instance) : ModeHandler(Instance, NULL, 'v', 1, 1, true, MODETYPE_CHANNEL, false, '+', '%', TR_NICK) +ModeChannelVoice::ModeChannelVoice(InspIRCd* Instance) : ModeHandler(NULL, 'v', PARAM_ALWAYS, MODETYPE_CHANNEL) { + list = true; + prefix = '+'; + levelrequired = HALFOP_VALUE; + m_paramtype = TR_NICK; } unsigned int ModeChannelVoice::GetPrefixRank() diff --git a/src/modes/umode_i.cpp b/src/modes/umode_i.cpp index caac9ff37..5c7c41b62 100644 --- a/src/modes/umode_i.cpp +++ b/src/modes/umode_i.cpp @@ -17,7 +17,7 @@ #include "users.h" #include "modes/umode_i.h" -ModeUserInvisible::ModeUserInvisible(InspIRCd* Instance) : SimpleUserModeHandler(Instance, NULL, 'i') +ModeUserInvisible::ModeUserInvisible(InspIRCd* Instance) : SimpleUserModeHandler(NULL, 'i') { } diff --git a/src/modes/umode_o.cpp b/src/modes/umode_o.cpp index 02550ffe5..ec9b4ad5b 100644 --- a/src/modes/umode_o.cpp +++ b/src/modes/umode_o.cpp @@ -17,8 +17,9 @@ #include "users.h" #include "modes/umode_o.h" -ModeUserOperator::ModeUserOperator(InspIRCd* Instance) : ModeHandler(Instance, NULL, 'o', 0, 0, false, MODETYPE_USER, true) +ModeUserOperator::ModeUserOperator(InspIRCd* Instance) : ModeHandler(NULL, 'o', PARAM_NONE, MODETYPE_USER) { + oper = true; } ModeAction ModeUserOperator::OnModeChange(User* source, User* dest, Channel*, std::string&, bool adding) diff --git a/src/modes/umode_s.cpp b/src/modes/umode_s.cpp index c45c185dc..abfc480d9 100644 --- a/src/modes/umode_s.cpp +++ b/src/modes/umode_s.cpp @@ -17,8 +17,9 @@ #include "users.h" #include "modes/umode_s.h" -ModeUserServerNoticeMask::ModeUserServerNoticeMask(InspIRCd* Instance) : ModeHandler(Instance, NULL, 's', 1, 0, false, MODETYPE_USER, true) +ModeUserServerNoticeMask::ModeUserServerNoticeMask(InspIRCd* Instance) : ModeHandler(NULL, 's', PARAM_SETONLY, MODETYPE_USER) { + oper = true; } ModeAction ModeUserServerNoticeMask::OnModeChange(User* source, User* dest, Channel*, std::string ¶meter, bool adding) diff --git a/src/modes/umode_w.cpp b/src/modes/umode_w.cpp index 5990fd2a0..8cc31094d 100644 --- a/src/modes/umode_w.cpp +++ b/src/modes/umode_w.cpp @@ -17,7 +17,7 @@ #include "users.h" #include "modes/umode_w.h" -ModeUserWallops::ModeUserWallops(InspIRCd* Instance) : SimpleUserModeHandler(Instance, NULL, 'w') +ModeUserWallops::ModeUserWallops(InspIRCd* Instance) : SimpleUserModeHandler(NULL, 'w') { } diff --git a/src/modules/m_auditorium.cpp b/src/modules/m_auditorium.cpp index 35903a921..eab78bea9 100644 --- a/src/modules/m_auditorium.cpp +++ b/src/modules/m_auditorium.cpp @@ -18,7 +18,10 @@ class AuditoriumMode : public ModeHandler { public: - AuditoriumMode(InspIRCd* Instance, Module* Creator) : ModeHandler(Instance, Creator, 'u', 0, 0, false, MODETYPE_CHANNEL, false, 0, '@') { } + AuditoriumMode(InspIRCd* Instance, Module* Creator) : ModeHandler(Creator, 'u', PARAM_NONE, MODETYPE_CHANNEL) + { + levelrequired = OP_VALUE; + } ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) { diff --git a/src/modules/m_botmode.cpp b/src/modules/m_botmode.cpp index 9ba154c15..0940a2147 100644 --- a/src/modules/m_botmode.cpp +++ b/src/modules/m_botmode.cpp @@ -20,7 +20,7 @@ class BotMode : public SimpleUserModeHandler { public: - BotMode(InspIRCd* Instance, Module* Creator) : SimpleUserModeHandler(Instance, Creator, 'B') { } + BotMode(InspIRCd* Instance, Module* Creator) : SimpleUserModeHandler(Creator, 'B') { } }; class ModuleBotMode : public Module diff --git a/src/modules/m_callerid.cpp b/src/modules/m_callerid.cpp index 2e508399b..16b883f63 100644 --- a/src/modules/m_callerid.cpp +++ b/src/modules/m_callerid.cpp @@ -127,7 +127,7 @@ struct CallerIDExtInfo : public ExtensionItem class User_g : public SimpleUserModeHandler { public: - User_g(InspIRCd* Instance, Module* Creator) : SimpleUserModeHandler(Instance, Creator, 'g') { } + User_g(InspIRCd* Instance, Module* Creator) : SimpleUserModeHandler(Creator, 'g') { } }; class CommandAccept : public Command diff --git a/src/modules/m_censor.cpp b/src/modules/m_censor.cpp index 2ffe2ab45..2c58e2ec4 100644 --- a/src/modules/m_censor.cpp +++ b/src/modules/m_censor.cpp @@ -26,7 +26,7 @@ typedef std::map<irc::string,irc::string> censor_t; class CensorUser : public SimpleUserModeHandler { public: - CensorUser(InspIRCd* Instance, Module* Creator) : SimpleUserModeHandler(Instance, Creator, 'G') { } + CensorUser(InspIRCd* Instance, Module* Creator) : SimpleUserModeHandler(Creator, 'G') { } }; /** Handles channel mode +G diff --git a/src/modules/m_chanprotect.cpp b/src/modules/m_chanprotect.cpp index 1e03da617..fd121edcf 100644 --- a/src/modules/m_chanprotect.cpp +++ b/src/modules/m_chanprotect.cpp @@ -119,8 +119,14 @@ class ChanFounder : public ModeHandler, public FounderProtectBase { public: ChanFounder(InspIRCd* Instance, Module* Creator, char my_prefix, bool &depriv_self, bool &depriv_others) - : ModeHandler(Instance, Creator, 'q', 1, 1, true, MODETYPE_CHANNEL, false, my_prefix, 0, TR_NICK), - FounderProtectBase(Instance, 'q', "founder", 386, 387, depriv_self, depriv_others) { } + : ModeHandler(Creator, 'q', PARAM_ALWAYS, MODETYPE_CHANNEL), + FounderProtectBase(Instance, 'q', "founder", 386, 387, depriv_self, depriv_others) + { + ModeHandler::list = true; + prefix = my_prefix; + levelrequired = FOUNDER_VALUE; + m_paramtype = TR_NICK; + } unsigned int GetPrefixRank() { @@ -194,8 +200,14 @@ class ChanProtect : public ModeHandler, public FounderProtectBase { public: ChanProtect(InspIRCd* Instance, Module* Creator, char my_prefix, bool &depriv_self, bool &depriv_others) - : ModeHandler(Instance, Creator, 'a', 1, 1, true, MODETYPE_CHANNEL, false, my_prefix, 0, TR_NICK), - FounderProtectBase(Instance,'a',"protected user", 388, 389, depriv_self, depriv_others) { } + : ModeHandler(Creator, 'a', PARAM_ALWAYS, MODETYPE_CHANNEL), + FounderProtectBase(Instance,'a',"protected user", 388, 389, depriv_self, depriv_others) + { + ModeHandler::list = true; + prefix = my_prefix; + levelrequired = PROTECT_VALUE; + m_paramtype = TR_NICK; + } unsigned int GetPrefixRank() { diff --git a/src/modules/m_cloaking.cpp b/src/modules/m_cloaking.cpp index 2a348ba8b..221c23d64 100644 --- a/src/modules/m_cloaking.cpp +++ b/src/modules/m_cloaking.cpp @@ -64,7 +64,7 @@ class CloakUser : public ModeHandler } CloakUser(InspIRCd* Instance, Module* source, Module* Hash) - : ModeHandler(Instance, source, 'x', 0, 0, false, MODETYPE_USER, false), HashProvider(Hash), + : ModeHandler(source, 'x', PARAM_NONE, MODETYPE_USER), HashProvider(Hash), ext("cloaked_host", source) { } diff --git a/src/modules/m_commonchans.cpp b/src/modules/m_commonchans.cpp index d9e253758..4cda89f21 100644 --- a/src/modules/m_commonchans.cpp +++ b/src/modules/m_commonchans.cpp @@ -20,7 +20,7 @@ class PrivacyMode : public ModeHandler { public: - PrivacyMode(InspIRCd* Instance, Module* Creator) : ModeHandler(Instance, Creator, 'c', 0, 0, false, MODETYPE_USER, false) { } + PrivacyMode(InspIRCd* Instance, Module* Creator) : ModeHandler(Creator, 'c', PARAM_NONE, MODETYPE_USER) { } ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) { diff --git a/src/modules/m_deaf.cpp b/src/modules/m_deaf.cpp index caad1feb1..bafa3adab 100644 --- a/src/modules/m_deaf.cpp +++ b/src/modules/m_deaf.cpp @@ -20,7 +20,7 @@ class User_d : public ModeHandler { public: - User_d(InspIRCd* Instance, Module* Creator) : ModeHandler(Instance, Creator, 'd', 0, 0, false, MODETYPE_USER, false) { } + User_d(InspIRCd* Instance, Module* Creator) : ModeHandler(Creator, 'd', PARAM_NONE, MODETYPE_USER) { } ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) { diff --git a/src/modules/m_delayjoin.cpp b/src/modules/m_delayjoin.cpp index f182e18d0..ffaf1223b 100644 --- a/src/modules/m_delayjoin.cpp +++ b/src/modules/m_delayjoin.cpp @@ -19,7 +19,10 @@ class DelayJoinMode : public ModeHandler private: CUList empty; public: - DelayJoinMode(InspIRCd* Instance, Module* Parent) : ModeHandler(Instance, Parent, 'D', 0, 0, false, MODETYPE_CHANNEL, false, 0, '@') {}; + DelayJoinMode(InspIRCd* Instance, Module* Parent) : ModeHandler(Parent, 'D', PARAM_NONE, MODETYPE_CHANNEL) + { + levelrequired = OP_VALUE; + } ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding); }; diff --git a/src/modules/m_delaymsg.cpp b/src/modules/m_delaymsg.cpp index 3e9f2641c..1673d05ba 100644 --- a/src/modules/m_delaymsg.cpp +++ b/src/modules/m_delaymsg.cpp @@ -22,7 +22,11 @@ class DelayMsgMode : public ModeHandler CUList empty; public: LocalIntExt jointime; - DelayMsgMode(InspIRCd* Instance, Module* Parent) : ModeHandler(Instance, Parent, 'd', 1, 0, false, MODETYPE_CHANNEL, false, 0, '@'), jointime("delaymsg", Parent) {}; + DelayMsgMode(InspIRCd* Instance, Module* Parent) : ModeHandler(Parent, 'd', PARAM_SETONLY, MODETYPE_CHANNEL) + , jointime("delaymsg", Parent) + { + levelrequired = OP_VALUE; + } ModePair ModeSet(User*, User*, Channel* channel, const std::string ¶meter) { diff --git a/src/modules/m_helpop.cpp b/src/modules/m_helpop.cpp index d8a544039..30dd8bcb4 100644 --- a/src/modules/m_helpop.cpp +++ b/src/modules/m_helpop.cpp @@ -22,7 +22,10 @@ static std::map<irc::string, std::string> helpop_map; class Helpop : public ModeHandler { public: - Helpop(InspIRCd* Instance, Module* Creator) : ModeHandler(Instance, Creator, 'h', 0, 0, false, MODETYPE_USER, true) { } + Helpop(InspIRCd* Instance, Module* Creator) : ModeHandler(Creator, 'h', PARAM_NONE, MODETYPE_USER) + { + oper = true; + } ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) { diff --git a/src/modules/m_hidechans.cpp b/src/modules/m_hidechans.cpp index 521920593..14f77ce17 100644 --- a/src/modules/m_hidechans.cpp +++ b/src/modules/m_hidechans.cpp @@ -20,7 +20,7 @@ class HideChans : public ModeHandler { public: - HideChans(InspIRCd* Instance, Module* Creator) : ModeHandler(Instance, Creator, 'I', 0, 0, false, MODETYPE_USER, false) { } + HideChans(InspIRCd* Instance, Module* Creator) : ModeHandler(Creator, 'I', PARAM_NONE, MODETYPE_USER) { } ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) { diff --git a/src/modules/m_hideoper.cpp b/src/modules/m_hideoper.cpp index 757f2d9af..178fc8bc5 100644 --- a/src/modules/m_hideoper.cpp +++ b/src/modules/m_hideoper.cpp @@ -20,7 +20,10 @@ class HideOper : public ModeHandler { public: - HideOper(InspIRCd* Instance, Module* Creator) : ModeHandler(Instance, Creator, 'H', 0, 0, false, MODETYPE_USER, true) { } + HideOper(InspIRCd* Instance, Module* Creator) : ModeHandler(Creator, 'H', PARAM_NONE, MODETYPE_USER) + { + oper = true; + } ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) { diff --git a/src/modules/m_invisible.cpp b/src/modules/m_invisible.cpp index cbdfcc600..ae54fa96b 100644 --- a/src/modules/m_invisible.cpp +++ b/src/modules/m_invisible.cpp @@ -1,5 +1,5 @@ /* +------------------------------------+ - * | Inspire Internet Relay Chat Daemon | + * | Inspire Internet Relay Chat Daemon * +------------------------------------+ * * InspIRCd: (C) 2002-2009 InspIRCd Development Team @@ -19,8 +19,9 @@ class InvisibleMode : public ModeHandler { public: - InvisibleMode(InspIRCd* Instance, Module* Creator) : ModeHandler(Instance, Creator, 'Q', 0, 0, false, MODETYPE_USER, true) + InvisibleMode(InspIRCd* Instance, Module* Creator) : ModeHandler(Creator, 'Q', PARAM_NONE, MODETYPE_USER) { + oper = true; } ~InvisibleMode() diff --git a/src/modules/m_joinflood.cpp b/src/modules/m_joinflood.cpp index fd2957db1..c53a6d1c4 100644 --- a/src/modules/m_joinflood.cpp +++ b/src/modules/m_joinflood.cpp @@ -87,7 +87,7 @@ class JoinFlood : public ModeHandler { public: SimpleExtItem<joinfloodsettings> ext; - JoinFlood(InspIRCd* Instance, Module* Creator) : ModeHandler(Instance, Creator, 'j', 1, 0, false, MODETYPE_CHANNEL, false), + JoinFlood(InspIRCd* Instance, Module* Creator) : ModeHandler(Creator, 'j', PARAM_SETONLY, MODETYPE_CHANNEL), ext("joinflood", Creator) { } ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string ¶meter) diff --git a/src/modules/m_kicknorejoin.cpp b/src/modules/m_kicknorejoin.cpp index c151cb4e4..05deee417 100644 --- a/src/modules/m_kicknorejoin.cpp +++ b/src/modules/m_kicknorejoin.cpp @@ -31,7 +31,7 @@ class KickRejoin : public ModeHandler { public: SimpleExtItem<delaylist> ext; - KickRejoin(InspIRCd* Instance, Module* Creator) : ModeHandler(Instance, Creator, 'J', 1, 0, false, MODETYPE_CHANNEL, false), + KickRejoin(InspIRCd* Instance, Module* Creator) : ModeHandler(Creator, 'J', PARAM_SETONLY, MODETYPE_CHANNEL), ext("norejoinusers", Creator) { } ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string ¶meter) diff --git a/src/modules/m_messageflood.cpp b/src/modules/m_messageflood.cpp index db17ee09d..bd586bcba 100644 --- a/src/modules/m_messageflood.cpp +++ b/src/modules/m_messageflood.cpp @@ -77,7 +77,7 @@ class MsgFlood : public ModeHandler { public: SimpleExtItem<floodsettings> ext; - MsgFlood(InspIRCd* Instance, Module* Creator) : ModeHandler(Instance, Creator, 'f', 1, 0, false, MODETYPE_CHANNEL, false), + MsgFlood(InspIRCd* Instance, Module* Creator) : ModeHandler(Creator, 'f', PARAM_SETONLY, MODETYPE_CHANNEL), ext("messageflood", Creator) { } ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string ¶meter) diff --git a/src/modules/m_nickflood.cpp b/src/modules/m_nickflood.cpp index e2ec1e3ed..5a59814d4 100644 --- a/src/modules/m_nickflood.cpp +++ b/src/modules/m_nickflood.cpp @@ -91,7 +91,7 @@ class NickFlood : public ModeHandler { public: SimpleExtItem<nickfloodsettings> ext; - NickFlood(InspIRCd* Instance, Module* Creator) : ModeHandler(Instance, Creator, 'F', 1, 0, false, MODETYPE_CHANNEL, false), + NickFlood(InspIRCd* Instance, Module* Creator) : ModeHandler(Creator, 'F', PARAM_SETONLY, MODETYPE_CHANNEL), ext("nickflood", Creator) { } ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string ¶meter) diff --git a/src/modules/m_noctcp.cpp b/src/modules/m_noctcp.cpp index ce79a5ff6..df3db0e12 100644 --- a/src/modules/m_noctcp.cpp +++ b/src/modules/m_noctcp.cpp @@ -18,7 +18,7 @@ class NoCTCP : public ModeHandler { public: - NoCTCP(InspIRCd* Instance, Module* Creator) : ModeHandler(Instance, Creator, 'C', 0, 0, false, MODETYPE_CHANNEL, false) { } + NoCTCP(InspIRCd* Instance, Module* Creator) : ModeHandler(Creator, 'C', PARAM_NONE, MODETYPE_CHANNEL) { } ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) { diff --git a/src/modules/m_nonicks.cpp b/src/modules/m_nonicks.cpp index 31839c13a..70ecfdae0 100644 --- a/src/modules/m_nonicks.cpp +++ b/src/modules/m_nonicks.cpp @@ -18,7 +18,7 @@ class NoNicks : public ModeHandler { public: - NoNicks(InspIRCd* Instance, Module* Creator) : ModeHandler(Instance, Creator, 'N', 0, 0, false, MODETYPE_CHANNEL, false) { } + NoNicks(InspIRCd* Instance, Module* Creator) : ModeHandler(Creator, 'N', PARAM_NONE, MODETYPE_CHANNEL) { } ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) { diff --git a/src/modules/m_ojoin.cpp b/src/modules/m_ojoin.cpp index 8c45c0d50..63be08a0f 100644 --- a/src/modules/m_ojoin.cpp +++ b/src/modules/m_ojoin.cpp @@ -105,9 +105,12 @@ class CommandOjoin : public Command class NetworkPrefix : public ModeHandler { public: - NetworkPrefix(InspIRCd* Instance, Module* parent) - : ModeHandler(Instance, parent, 'Y', 1, 1, true, MODETYPE_CHANNEL, false, NPrefix, 0, TR_NICK) + NetworkPrefix(Module* parent) : ModeHandler(parent, 'Y', PARAM_ALWAYS, MODETYPE_CHANNEL) { + list = true; + prefix = NPrefix; + levelrequired = 0xFFFFFFFF; + m_paramtype = TR_NICK; } ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string ¶meter) @@ -249,7 +252,7 @@ class ModuleOjoin : public Module OnRehash(NULL); /* Initialise module variables */ - np = new NetworkPrefix(Me, this); + np = new NetworkPrefix(this); if (!ServerInstance->Modes->AddMode(np)) { diff --git a/src/modules/m_operchans.cpp b/src/modules/m_operchans.cpp index 52d5a28be..d97142e66 100644 --- a/src/modules/m_operchans.cpp +++ b/src/modules/m_operchans.cpp @@ -19,7 +19,7 @@ class OperChans : public ModeHandler { public: /* This is an oper-only mode */ - OperChans(InspIRCd* Instance, Module* Creator) : ModeHandler(Instance, Creator, 'O', 0, 0, false, MODETYPE_CHANNEL, true) { } + OperChans(InspIRCd* Instance, Module* Creator) : ModeHandler(Creator, 'O', PARAM_NONE, MODETYPE_CHANNEL) { oper = true; } ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) { diff --git a/src/modules/m_operprefix.cpp b/src/modules/m_operprefix.cpp index f3137fc24..47f19e90d 100644 --- a/src/modules/m_operprefix.cpp +++ b/src/modules/m_operprefix.cpp @@ -24,7 +24,13 @@ class OperPrefixMode : public ModeHandler { public: - OperPrefixMode(InspIRCd* Instance, Module* Creator, char pfx) : ModeHandler(Instance, Creator, 'y', 1, 1, true, MODETYPE_CHANNEL, false, pfx, pfx, TR_NICK) { } + OperPrefixMode(InspIRCd* Instance, Module* Creator, char pfx) : ModeHandler(Creator, 'y', PARAM_ALWAYS, MODETYPE_CHANNEL) + { + list = true; + prefix = pfx; + levelrequired = OPERPREFIX_VALUE; + m_paramtype = TR_NICK; + } unsigned int GetPrefixRank() { diff --git a/src/modules/m_permchannels.cpp b/src/modules/m_permchannels.cpp index 3317b5c08..41a5daf33 100644 --- a/src/modules/m_permchannels.cpp +++ b/src/modules/m_permchannels.cpp @@ -83,7 +83,7 @@ static bool WriteDatabase(InspIRCd *ServerInstance) class PermChannel : public ModeHandler { public: - PermChannel(InspIRCd* Instance, Module* Creator) : ModeHandler(Instance, Creator, 'P', 0, 0, false, MODETYPE_CHANNEL, false) { } + PermChannel(InspIRCd* Instance, Module* Creator) : ModeHandler(Creator, 'P', PARAM_NONE, MODETYPE_CHANNEL) { } ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) { diff --git a/src/modules/m_redirect.cpp b/src/modules/m_redirect.cpp index 667ab307f..00fae3c53 100644 --- a/src/modules/m_redirect.cpp +++ b/src/modules/m_redirect.cpp @@ -20,7 +20,7 @@ class Redirect : public ModeHandler { public: - Redirect(InspIRCd* Instance, Module* Creator) : ModeHandler(Instance, Creator, 'L', 1, 0, false, MODETYPE_CHANNEL, false) { } + Redirect(InspIRCd* Instance, Module* Creator) : ModeHandler(Creator, 'L', PARAM_SETONLY, MODETYPE_CHANNEL) { } ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string ¶meter) { diff --git a/src/modules/m_services_account.cpp b/src/modules/m_services_account.cpp index cbbfac0a4..ef16d6ba1 100644 --- a/src/modules/m_services_account.cpp +++ b/src/modules/m_services_account.cpp @@ -22,7 +22,7 @@ class Channel_r : public ModeHandler { public: - Channel_r(InspIRCd* Instance, Module* Creator) : ModeHandler(Instance, Creator, 'r', 0, 0, false, MODETYPE_CHANNEL, false) { } + Channel_r(InspIRCd* Instance, Module* Creator) : ModeHandler(Creator, 'r', PARAM_NONE, MODETYPE_CHANNEL) { } ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) { @@ -52,7 +52,7 @@ class User_r : public ModeHandler { public: - User_r(InspIRCd* Instance, Module* Creator) : ModeHandler(Instance, Creator, 'r', 0, 0, false, MODETYPE_USER, false) { } + User_r(InspIRCd* Instance, Module* Creator) : ModeHandler(Creator, 'r', PARAM_NONE, MODETYPE_USER) { } ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) { @@ -86,7 +86,7 @@ class AChannel_R : public SimpleChannelModeHandler class AUser_R : public SimpleUserModeHandler { public: - AUser_R(InspIRCd* Instance, Module* Creator) : SimpleUserModeHandler(Instance, Creator, 'R') { } + AUser_R(InspIRCd* Instance, Module* Creator) : SimpleUserModeHandler(Creator, 'R') { } }; /** Channel mode +M - unidentified users cannot message channel diff --git a/src/modules/m_servprotect.cpp b/src/modules/m_servprotect.cpp index 7ef77c089..f9661c3ea 100644 --- a/src/modules/m_servprotect.cpp +++ b/src/modules/m_servprotect.cpp @@ -20,7 +20,7 @@ class ServProtectMode : public ModeHandler { public: - ServProtectMode(InspIRCd* Instance, Module* Creator) : ModeHandler(Instance, Creator, 'k', 0, 0, false, MODETYPE_USER, true) { } + ServProtectMode(InspIRCd* Instance, Module* Creator) : ModeHandler(Creator, 'k', PARAM_NONE, MODETYPE_USER) { oper = true; } ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) { @@ -34,8 +34,6 @@ class ServProtectMode : public ModeHandler */ return MODEACTION_DENY; } - - bool NeedsOper() { return true; } }; class ModuleServProtectMode : public Module diff --git a/src/modules/m_showwhois.cpp b/src/modules/m_showwhois.cpp index c6e9ed27c..8b55c3e96 100644 --- a/src/modules/m_showwhois.cpp +++ b/src/modules/m_showwhois.cpp @@ -20,7 +20,10 @@ class SeeWhois : public ModeHandler { public: - SeeWhois(InspIRCd* Instance, Module* Creator, bool IsOpersOnly) : ModeHandler(Instance, Creator, 'W', 0, 0, false, MODETYPE_USER, IsOpersOnly) { } + SeeWhois(InspIRCd* Instance, Module* Creator, bool IsOpersOnly) : ModeHandler(Creator, 'W', PARAM_NONE, MODETYPE_USER) + { + oper = IsOpersOnly; + } ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) { diff --git a/src/modules/m_sslmodes.cpp b/src/modules/m_sslmodes.cpp index 396623eb9..b190cfc39 100644 --- a/src/modules/m_sslmodes.cpp +++ b/src/modules/m_sslmodes.cpp @@ -21,7 +21,7 @@ class SSLMode : public ModeHandler { public: - SSLMode(InspIRCd* Instance, Module* Creator) : ModeHandler(Instance, Creator, 'z', 0, 0, false, MODETYPE_CHANNEL, false) { } + SSLMode(InspIRCd* Instance, Module* Creator) : ModeHandler(Creator, 'z', PARAM_NONE, MODETYPE_CHANNEL) { } ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) { diff --git a/src/modules/m_stripcolor.cpp b/src/modules/m_stripcolor.cpp index 7abe4f7d2..fa5dd17c7 100644 --- a/src/modules/m_stripcolor.cpp +++ b/src/modules/m_stripcolor.cpp @@ -28,7 +28,7 @@ class ChannelStripColor : public SimpleChannelModeHandler class UserStripColor : public SimpleUserModeHandler { public: - UserStripColor(InspIRCd* Instance, Module* Creator) : SimpleUserModeHandler(Instance, Creator, 'S') { } + UserStripColor(InspIRCd* Instance, Module* Creator) : SimpleUserModeHandler(Creator, 'S') { } }; |