summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-02-14 19:12:44 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-02-14 19:12:44 +0000
commite088bb55fcf00d4cead3f8f9c9ff15fa5cc846a0 (patch)
treee79832a607e83b417be78fab60ca33343391a3ec /src
parenta7c5427c733d1459d8976100bda315af46dc83d6 (diff)
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, '%'. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8941 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/mode.cpp40
1 files changed, 23 insertions, 17 deletions
diff --git a/src/mode.cpp b/src/mode.cpp
index d539f57f8..063b14fc4 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -525,24 +525,30 @@ void ModeParser::Process(const char** parameters, int pcnt, User *user, bool ser
char needed = modehandlers[handler_id]->GetNeededPrefix();
ModeHandler* prefixmode = FindPrefix(needed);
ServerInstance->Log(DEBUG,"Needed prefix: %c", needed);
- if (prefixmode)
+
+ /* 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, '%'.
+ */
+ if (needed && !prefixmode)
+ prefixmode = FindPrefix('%');
+
+ 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.
+ */
+ std::string modestring = targetchannel->GetAllPrefixChars(user);
+ char ml = (modestring.empty() ? '\0' : modestring[0]);
+ ModeHandler* ourmode = FindPrefix(ml);
+ if (!ourmode || ourmode->GetPrefixRank() < neededrank)
{
- 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.
- */
- std::string modestring = targetchannel->GetAllPrefixChars(user);
- char ml = (modestring.empty() ? '\0' : modestring[0]);
- ModeHandler* ourmode = FindPrefix(ml);
- if (!ourmode || ourmode->GetPrefixRank() < neededrank)
- {
- /* Bog off */
- user->WriteServ("482 %s %s :You require channel privilege %c or above to %sset channel mode %c",
- user->nick, targetchannel->name, needed, adding ? "" : "un", modechar);
- continue;
- }
+ /* Bog off */
+ user->WriteServ("482 %s %s :You require channel privilege %c or above to %sset channel mode %c",
+ user->nick, targetchannel->name, needed, adding ? "" : "un", modechar);
+ continue;
}
}
}