From dd2ace5916a8bb24801e74aa8b209d396e012d9b Mon Sep 17 00:00:00 2001 From: danieldg Date: Sat, 9 Jan 2010 17:29:28 +0000 Subject: Disallow adding prefix-mode when it is already set (fixes bug #935) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12245 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/mode.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/mode.cpp') diff --git a/src/mode.cpp b/src/mode.cpp index 7d99277df..28390d327 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -353,6 +353,15 @@ ModeAction ModeParser::TryMode(User* user, User* targetuser, Channel* chan, bool return MODEACTION_DENY; } + if (mh->GetPrefixRank() && chan) + { + User* user_to_prefix = ServerInstance->FindNick(parameter); + if (!user_to_prefix) + return MODEACTION_DENY; + if (!chan->SetPrefix(user_to_prefix, modechar, adding)) + return MODEACTION_DENY; + } + /* Call the handler for the mode */ ModeAction ma = mh->OnModeChange(user, targetuser, chan, parameter, adding); @@ -362,15 +371,9 @@ ModeAction ModeParser::TryMode(User* user, User* targetuser, Channel* chan, bool if (ma != MODEACTION_ALLOW) return ma; + // TODO this count may not be reliable mh->ChangeCount(adding ? 1 : -1); - if (mh->GetPrefixRank() && chan) - { - User* user_to_prefix = ServerInstance->FindNick(parameter); - if (user_to_prefix) - chan->SetPrefix(user_to_prefix, modechar, adding); - } - for (ModeWatchIter watchers = modewatchers[handler_id].begin(); watchers != modewatchers[handler_id].end(); watchers++) (*watchers)->AfterMode(user, targetuser, chan, parameter, adding, type); -- cgit v1.2.3