summaryrefslogtreecommitdiff
path: root/src/channels.cpp
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-09-13 20:31:23 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-09-13 20:31:23 +0000
commit7892c8a0313c50d8138942ff3b112691caf05a2f (patch)
tree9c0c4a20584c0dca6adbeddec538ff871546dabe /src/channels.cpp
parentb4be0c94ab5fb7e5a7a799a195c78de072a5e315 (diff)
Replace OnAccessCheck with OnPreMode to remove a number of redundant checks
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11700 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/channels.cpp')
-rw-r--r--src/channels.cpp33
1 files changed, 17 insertions, 16 deletions
diff --git a/src/channels.cpp b/src/channels.cpp
index 37edcebfb..adb0e6ebe 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -527,10 +527,8 @@ long Channel::KickUser(User *src, User *user, const char* reason)
ModResult res;
if (ServerInstance->ULine(src->server))
res = MOD_RES_ALLOW;
- if (res == MOD_RES_PASSTHRU)
+ else
FIRST_MOD_RESULT(ServerInstance, OnUserPreKick, res, (src,memb,reason));
- if (res == MOD_RES_PASSTHRU)
- FIRST_MOD_RESULT(ServerInstance, OnAccessCheck, res, (src,user,this,AC_KICK));
if (res == MOD_RES_DENY)
return this->GetUserCounter();
@@ -980,24 +978,27 @@ unsigned int Channel::GetPrefixValue(User* user)
void Channel::SetPrefix(User* user, char prefix, unsigned int prefix_value, bool adding)
{
+ ModeHandler* delta_mh = ServerInstance->Modes->FindMode(prefix, MODETYPE_CHANNEL);
+ if (!delta_mh)
+ return;
UserMembIter m = userlist.find(user);
- if (m != userlist.end())
+ if (m == userlist.end())
+ return;
+ for(unsigned int i=0; i < m->second->modes.length(); i++)
{
- for(unsigned int i=0; i < m->second->modes.length(); i++)
+ char mchar = m->second->modes[i];
+ ModeHandler* mh = ServerInstance->Modes->FindMode(mchar, MODETYPE_CHANNEL);
+ if (mh && mh->GetPrefixRank() <= delta_mh->GetPrefixRank())
{
- char mchar = m->second->modes[i];
- ModeHandler* mh = ServerInstance->Modes->FindMode(mchar, MODETYPE_CHANNEL);
- if (mh && mh->GetPrefixRank() <= prefix_value)
- {
- m->second->modes =
- m->second->modes.substr(0,i-1) +
- (adding ? std::string(1, prefix) : "") +
- m->second->modes.substr(mchar == prefix ? i+1 : i);
- return;
- }
+ m->second->modes =
+ m->second->modes.substr(0,i) +
+ (adding ? std::string(1, prefix) : "") +
+ m->second->modes.substr(mchar == prefix ? i+1 : i);
+ return;
}
- m->second->modes += std::string(1, prefix);
}
+ if (adding)
+ m->second->modes += std::string(1, prefix);
}
void Channel::RemoveAllPrefixes(User* user)