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/channels.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/channels.cpp') diff --git a/src/channels.cpp b/src/channels.cpp index 31038484e..b0951c8cc 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -929,14 +929,14 @@ unsigned int Channel::GetPrefixValue(User* user) return m->second->getRank(); } -void Channel::SetPrefix(User* user, char prefix, bool adding) +bool Channel::SetPrefix(User* user, char prefix, bool adding) { ModeHandler* delta_mh = ServerInstance->Modes->FindMode(prefix, MODETYPE_CHANNEL); if (!delta_mh) - return; + return false; UserMembIter m = userlist.find(user); if (m == userlist.end()) - return; + return false; for(unsigned int i=0; i < m->second->modes.length(); i++) { char mchar = m->second->modes[i]; @@ -947,11 +947,12 @@ void Channel::SetPrefix(User* user, char prefix, bool adding) m->second->modes.substr(0,i) + (adding ? std::string(1, prefix) : "") + m->second->modes.substr(mchar == prefix ? i+1 : i); - return; + return adding != (mchar == prefix); } } if (adding) m->second->modes += std::string(1, prefix); + return adding; } void Channel::RemoveAllPrefixes(User* user) -- cgit v1.2.3