summaryrefslogtreecommitdiff
path: root/src/channels.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-08 12:20:45 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-08 12:20:45 +0000
commit25f6cb0fe66057f62c4c1d58beefe0595098897d (patch)
tree7d194f5c2d9081623dacb9eace8d981cbdc56244 /src/channels.cpp
parent3c5d62d3b3d7e3e3543b304b9aef6eb7aead0de1 (diff)
kick_channel -> chanrec::KickUser(), server_kick_channel -> chanrec::ServerKickUser()
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4782 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/channels.cpp')
-rw-r--r--src/channels.cpp96
1 files changed, 43 insertions, 53 deletions
diff --git a/src/channels.cpp b/src/channels.cpp
index 3671fdb6d..3f1d2ecb6 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -543,141 +543,131 @@ chanrec* del_channel(userrec *user, const char* cname, const char* reason, bool
return NULL;
}
-void server_kick_channel(userrec* user, chanrec* Ptr, char* reason, bool triggerevents)
+long chanrec::ServerKickUser(userrec* user, const char* reason, bool triggerevents)
{
- if ((!user) || (!Ptr) || (!reason))
- {
- return;
- }
+ if (!user || !reason)
+ return this->GetUserCounter();
if (IS_LOCAL(user))
{
- if (!Ptr->HasUser(user))
+ if (!this->HasUser(user))
{
/* Not on channel */
- return;
+ return this->GetUserCounter();
}
}
-
+
if (triggerevents)
{
- FOREACH_MOD(I_OnUserKick,OnUserKick(NULL,user,Ptr,reason));
+ FOREACH_MOD(I_OnUserKick,OnUserKick(NULL,user,this,reason));
}
for (unsigned int i =0; i < user->chans.size(); i++)
{
- if ((user->chans[i]->channel) && (user->chans[i]->channel == Ptr))
+ if (user->chans[i]->channel == this)
{
- WriteChannelWithServ(Config->ServerName,Ptr,"KICK %s %s :%s",Ptr->name, user->nick, reason);
+ WriteChannelWithServ(Config->ServerName,this,"KICK %s %s :%s",this->name, user->nick, reason);
user->chans[i]->uc_modes = 0;
user->chans[i]->channel = NULL;
break;
}
}
- Ptr->DelUser(user);
-
- if (!usercount(Ptr))
+ if (!this->DelUser(user))
{
- chan_hash::iterator iter = chanlist.find(Ptr->name);
- log(DEBUG,"del_channel: destroying channel: %s",Ptr->name);
+ chan_hash::iterator iter = chanlist.find(this->name);
/* kill the record */
if (iter != chanlist.end())
{
- log(DEBUG,"del_channel: destroyed: %s",Ptr->name);
- FOREACH_MOD(I_OnChannelDelete,OnChannelDelete(Ptr));
- DELETE(Ptr);
+ FOREACH_MOD(I_OnChannelDelete,OnChannelDelete(this));
chanlist.erase(iter);
}
+ return 0;
}
+
+ return this->GetUserCounter();
}
-void kick_channel(userrec *src,userrec *user, chanrec *Ptr, char* reason)
+long chanrec::KickUser(userrec *src, userrec *user, const char* reason)
{
- if ((!src) || (!user) || (!Ptr) || (!reason))
- {
- log(DEFAULT,"*** BUG *** kick_channel was given an invalid parameter");
- return;
- }
-
- log(DEBUG,"kick_channel: removing: %s %s %s",user->nick,Ptr->name,src->nick);
+ if (!src || !user || !reason)
+ return this->GetUserCounter();
if (IS_LOCAL(src))
{
- if (!Ptr->HasUser(user))
+ if (!this->HasUser(user))
{
- WriteServ(src->fd,"441 %s %s %s :They are not on that channel",src->nick, user->nick, Ptr->name);
- return;
+ WriteServ(src->fd,"441 %s %s %s :They are not on that channel",src->nick, user->nick, this->name);
+ return this->GetUserCounter();
}
if ((is_uline(user->server)) && (!is_uline(src->server)))
{
- WriteServ(src->fd,"482 %s %s :Only a u-line may kick a u-line from a channel.",src->nick, Ptr->name);
- return;
+ WriteServ(src->fd,"482 %s %s :Only a u-line may kick a u-line from a channel.",src->nick, this->name);
+ return this->GetUserCounter();
}
int MOD_RESULT = 0;
if (!is_uline(src->server))
{
MOD_RESULT = 0;
- FOREACH_RESULT(I_OnUserPreKick,OnUserPreKick(src,user,Ptr,reason));
+ FOREACH_RESULT(I_OnUserPreKick,OnUserPreKick(src,user,this,reason));
if (MOD_RESULT == 1)
- return;
+ return this->GetUserCounter();
}
/* Set to -1 by OnUserPreKick if explicit allow was set */
if (MOD_RESULT != -1)
{
- FOREACH_RESULT(I_OnAccessCheck,OnAccessCheck(src,user,Ptr,AC_KICK));
+ FOREACH_RESULT(I_OnAccessCheck,OnAccessCheck(src,user,this,AC_KICK));
if ((MOD_RESULT == ACR_DENY) && (!is_uline(src->server)))
- return;
+ return this->GetUserCounter();
if ((MOD_RESULT == ACR_DEFAULT) || (!is_uline(src->server)))
{
- if ((cstatus(src,Ptr) < STATUS_HOP) || (cstatus(src,Ptr) < cstatus(user,Ptr)))
+ int them = cstatus(src, this);
+ int us = cstatus(user, this);
+ if ((them < STATUS_HOP) || (them < us))
{
- if (cstatus(src,Ptr) == STATUS_HOP)
+ if (them == STATUS_HOP)
{
- WriteServ(src->fd,"482 %s %s :You must be a channel operator",src->nick, Ptr->name);
+ WriteServ(src->fd,"482 %s %s :You must be a channel operator",src->nick, this->name);
}
else
{
- WriteServ(src->fd,"482 %s %s :You must be at least a half-operator",src->nick, Ptr->name);
+ WriteServ(src->fd,"482 %s %s :You must be at least a half-operator",src->nick, this->name);
}
-
- return;
+ return this->GetUserCounter();
}
}
}
}
- FOREACH_MOD(I_OnUserKick,OnUserKick(src,user,Ptr,reason));
+ FOREACH_MOD(I_OnUserKick,OnUserKick(src,user,this,reason));
for (UserChanList::const_iterator i = user->chans.begin(); i != user->chans.end(); i++)
{
/* zap it from the channel list of the user */
- if ((*i)->channel && ((*i)->channel == Ptr))
+ if ((*i)->channel == this)
{
- WriteChannel(Ptr,src,"KICK %s %s :%s",Ptr->name, user->nick, reason);
+ WriteChannel(this,src,"KICK %s %s :%s",this->name, user->nick, reason);
(*i)->uc_modes = 0;
(*i)->channel = NULL;
- log(DEBUG,"del_channel: unlinked: %s %s",user->nick,Ptr->name);
break;
}
}
- if (!Ptr->DelUser(user))
+ if (!this->DelUser(user))
/* if there are no users left on the channel */
{
- chan_hash::iterator iter = chanlist.find(Ptr->name);
-
- log(DEBUG,"del_channel: destroying channel: %s",Ptr->name);
+ chan_hash::iterator iter = chanlist.find(this->name);
/* kill the record */
if (iter != chanlist.end())
{
- log(DEBUG,"del_channel: destroyed: %s",Ptr->name);
- FOREACH_MOD(I_OnChannelDelete,OnChannelDelete(Ptr));
- DELETE(Ptr);
+ FOREACH_MOD(I_OnChannelDelete,OnChannelDelete(this));
chanlist.erase(iter);
}
+ return 0;
}
+
+ return this->GetUserCounter();
}