summaryrefslogtreecommitdiff
path: root/src/mode.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-02-14 18:44:52 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-02-14 18:44:52 +0000
commit89f3c09b41409059237629abe5851b8ba6c55d13 (patch)
tree815123b5acb048ecaa2e3dbae58f981c11082fbe /src/mode.cpp
parent91a8894d5d4637ad6aea33ad77af67445d548732 (diff)
All working now, with any luck
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8936 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/mode.cpp')
-rw-r--r--src/mode.cpp27
1 files changed, 11 insertions, 16 deletions
diff --git a/src/mode.cpp b/src/mode.cpp
index 3fad8627d..feaca7931 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -515,7 +515,6 @@ void ModeParser::Process(const char** parameters, int pcnt, User *user, bool ser
/* Check access to this mode character */
if ((type == MODETYPE_CHANNEL) && (modehandlers[handler_id]->GetNeededPrefix()))
{
- bool allowed = false;
char needed = modehandlers[handler_id]->GetNeededPrefix();
ModeHandler* prefixmode = FindPrefix(needed);
if (prefixmode)
@@ -523,27 +522,23 @@ void ModeParser::Process(const char** parameters, int pcnt, User *user, bool ser
unsigned int neededrank = prefixmode->GetPrefixRank();
/* Compare our rank on the channel against the rank of the required prefix,
- * allow if >= ours
+ * 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 = ModeString(user, targetchannel);
- for (std::string::iterator v = modestring.begin(); v != modestring.end(); ++v)
+ std::string modestring = targetchannel->GetAllPrefixChars(user);
+ if (!modestring.empty())
{
- ModeHandler* ourmode = FindPrefix(*v);
- if (ourmode && (ourmode->GetPrefixRank() >= neededrank))
+ ModeHandler* ourmode = FindPrefix(modestring[0]);
+ if (!ourmode || ourmode->GetPrefixRank() < neededrank)
{
- /* Yay, allowed */
- allowed = true;
- break;
+ /* Bog off */
+ user->WriteServ("482 %s %s :You require channel privilege '%c' or above to execute channel mode '%c'",
+ user->nick, targetchannel->name, needed, modechar);
+ continue;
}
}
}
-
- if (!allowed)
- {
- user->WriteServ("482 %s %s :You require channel privilege '%c' or above to execute channel mode '%c'",user->nick,
- targetchannel->name, needed, modechar);
- }
}
}