summaryrefslogtreecommitdiff
path: root/src/channels.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-08 12:52:24 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-08 12:52:24 +0000
commit6f1b8f50dd8a9f73c9e02e64253e7e45642a88d0 (patch)
tree4cb07b9523faaaa9cfd9c43f4f904203231328f3 /src/channels.cpp
parent7a3907f0518238402a4ea592fe5fb18849a833c5 (diff)
Change to chanrec::PartUser. As with KickUser and ServerKickUser, returns the number of users left, if it returns 0, delete the chanrec
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4786 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/channels.cpp')
-rw-r--r--src/channels.cpp50
1 files changed, 16 insertions, 34 deletions
diff --git a/src/channels.cpp b/src/channels.cpp
index 3f1d2ecb6..6d8cb756f 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -479,68 +479,50 @@ chanrec* ForceChan(chanrec* Ptr,ucrec *a,userrec* user, int created)
return Ptr;
}
-/*
- *remove a channel from a users record, and remove the record from memory
+/* chanrec::PartUser
+ * remove a channel from a users record, and remove the record from the hash
* if the channel has become empty
*/
-
-chanrec* del_channel(userrec *user, const char* cname, const char* reason, bool local)
+long chanrec::PartUser(userrec *user, const char* reason)
{
- if ((!user) || (!cname))
- {
- log(DEFAULT,"*** BUG *** del_channel was given an invalid parameter");
- return NULL;
- }
-
- chanrec* Ptr = FindChan(cname);
-
- if (!Ptr)
- return NULL;
-
- log(DEBUG,"del_channel: removing: %s %s",user->nick,Ptr->name);
+ if (!user)
+ return this->GetUserCounter();
for (unsigned int i =0; i < user->chans.size(); i++)
{
/* zap it from the channel list of the user */
- if (user->chans[i]->channel == Ptr)
+ if (user->chans[i]->channel == this)
{
if (reason)
{
- FOREACH_MOD(I_OnUserPart,OnUserPart(user,Ptr,reason));
- WriteChannel(Ptr,user,"PART %s :%s",Ptr->name, reason);
+ FOREACH_MOD(I_OnUserPart,OnUserPart(user, this, reason));
+ WriteChannel(this, user, "PART %s :%s", this->name, reason);
}
else
{
- FOREACH_MOD(I_OnUserPart,OnUserPart(user,Ptr,""));
- WriteChannel(Ptr,user,"PART :%s",Ptr->name);
+ FOREACH_MOD(I_OnUserPart,OnUserPart(user, this, ""));
+ WriteChannel(this, user, "PART :%s", this->name);
}
user->chans[i]->uc_modes = 0;
user->chans[i]->channel = NULL;
- log(DEBUG,"del_channel: unlinked: %s %s",user->nick,Ptr->name);
break;
}
}
- Ptr->DelUser(user);
-
- /* if there are no users left on the channel */
- if (!usercount(Ptr))
+ 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);
+ log(DEBUG,"del_channel: destroyed: %s", this->name);
+ FOREACH_MOD(I_OnChannelDelete,OnChannelDelete(this));
chanlist.erase(iter);
}
+ return 0;
}
- return NULL;
+ return this->GetUserCounter();
}
long chanrec::ServerKickUser(userrec* user, const char* reason, bool triggerevents)