diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-08-08 13:22:30 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-08-08 13:22:30 +0000 |
commit | 903ba4e2ebf608737e1890cfa43c3e92a9ec2cf4 (patch) | |
tree | e8fd0a74b50da79e46b93dfa7d0d6fc80498cbbb /src | |
parent | 6f1b8f50dd8a9f73c9e02e64253e7e45642a88d0 (diff) |
add_channel -> chanrec::JoinUser()
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4787 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/channels.cpp | 37 | ||||
-rw-r--r-- | src/cmd_join.cpp | 4 | ||||
-rw-r--r-- | src/modules.cpp | 5 | ||||
-rw-r--r-- | src/modules/m_operjoin.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_redirect.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_sajoin.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree.cpp | 4 |
7 files changed, 18 insertions, 40 deletions
diff --git a/src/channels.cpp b/src/channels.cpp index 6d8cb756f..caae1a714 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -46,9 +46,6 @@ extern std::vector<ircd_module*> factory; extern time_t TIME; extern chan_hash chanlist; - -chanrec* ForceChan(chanrec* Ptr,ucrec *a,userrec* user, int created); - chanrec::chanrec() { *name = *topic = *setby = *key = 0; @@ -219,22 +216,15 @@ CUList* chanrec::GetVoicedUsers() * add a channel to a user, creating the record for it if needed and linking * it to the user record */ - -chanrec* add_channel(userrec *user, const char* cn, const char* key, bool override) +chanrec* chanrec::JoinUser(userrec *user, const char* cn, bool override, const char* key) { - if ((!user) || (!cn)) - { - log(DEFAULT,"*** BUG *** add_channel was given an invalid parameter"); - return 0; - } + if (!user || !cn) + return NULL; int created = 0; char cname[MAXBUF]; int MOD_RESULT = 0; strlcpy(cname,cn,CHANMAX); - log(DEBUG,"cname='%s' cn='%s'",cname,cn); - - log(DEBUG,"add_channel: %s %s",user->nick,cname); chanrec* Ptr = FindChan(cname); @@ -258,7 +248,7 @@ chanrec* add_channel(userrec *user, const char* cn, const char* key, bool overri strlcpy(chanlist[cname]->setby, user->nick,NICKMAX-1); chanlist[cname]->topicset = 0; Ptr = chanlist[cname]; - log(DEBUG,"add_channel: created: %s",cname); + log(DEBUG,"chanrec::JoinUser(): created: %s",cname); /* * set created to 2 to indicate user * is the first in the channel @@ -294,7 +284,7 @@ chanrec* add_channel(userrec *user, const char* cn, const char* key, bool overri { if (!key) { - log(DEBUG,"add_channel: no key given in JOIN"); + log(DEBUG,"chanrec::JoinUser(): no key given in JOIN"); WriteServ(user->fd,"475 %s %s :Cannot join channel (Requires key)",user->nick, Ptr->name); return NULL; } @@ -302,7 +292,7 @@ chanrec* add_channel(userrec *user, const char* cn, const char* key, bool overri { if (strcmp(key,Ptr->key)) { - log(DEBUG,"add_channel: bad key given in JOIN"); + log(DEBUG,"chanrec::JoinUser(): bad key given in JOIN"); WriteServ(user->fd,"475 %s %s :Cannot join channel (Incorrect key)",user->nick, Ptr->name); return NULL; } @@ -316,7 +306,6 @@ chanrec* add_channel(userrec *user, const char* cn, const char* key, bool overri FOREACH_RESULT(I_OnCheckInvite,OnCheckInvite(user, Ptr)); if (!MOD_RESULT) { - log(DEBUG,"add_channel: channel is +i"); if (user->IsInvited(xname)) { /* user was invited to channel */ @@ -345,7 +334,6 @@ chanrec* add_channel(userrec *user, const char* cn, const char* key, bool overri } if (Ptr->bans.size()) { - log(DEBUG,"add_channel: about to walk banlist"); MOD_RESULT = 0; FOREACH_RESULT(I_OnCheckBan,OnCheckBan(user, Ptr)); char mask[MAXBUF]; @@ -370,18 +358,16 @@ chanrec* add_channel(userrec *user, const char* cn, const char* key, bool overri } else { - log(DEBUG,"Overridden checks"); + log(DEBUG,"chanrec::JoinUser(): Overridden checks"); } created = 1; } - log(DEBUG,"Passed channel checks"); - for (UserChanList::const_iterator index = user->chans.begin(); index != user->chans.end(); index++) { if ((*index)->channel == NULL) { - return ForceChan(Ptr, *index, user, created); + return chanrec::ForceChan(Ptr, *index, user, created); } } @@ -393,7 +379,7 @@ chanrec* add_channel(userrec *user, const char* cn, const char* key, bool overri if (!IS_LOCAL(user)) /* was a check on fd < 0 */ { ucrec* a = new ucrec(); - chanrec* c = ForceChan(Ptr,a,user,created); + chanrec* c = chanrec::ForceChan(Ptr,a,user,created); user->chans.push_back(a); return c; } @@ -403,13 +389,12 @@ chanrec* add_channel(userrec *user, const char* cn, const char* key, bool overri if (user->chans.size() < OPERMAXCHANS) { ucrec* a = new ucrec(); - chanrec* c = ForceChan(Ptr,a,user,created); + chanrec* c = chanrec::ForceChan(Ptr,a,user,created); user->chans.push_back(a); return c; } } - log(DEBUG,"add_channel: user channel max exceeded: %s %s",user->nick,cname); WriteServ(user->fd,"405 %s %s :You are on too many channels",user->nick, cname); if (created == 2) @@ -446,7 +431,7 @@ chanrec* add_channel(userrec *user, const char* cn, const char* key, bool overri return NULL; } -chanrec* ForceChan(chanrec* Ptr,ucrec *a,userrec* user, int created) +chanrec* chanrec::ForceChan(chanrec* Ptr,ucrec *a,userrec* user, int created) { if (created == 2) { diff --git a/src/cmd_join.cpp b/src/cmd_join.cpp index 728038c2e..4af887585 100644 --- a/src/cmd_join.cpp +++ b/src/cmd_join.cpp @@ -31,7 +31,7 @@ void cmd_join::Handle (const char** parameters, int pcnt, userrec *user) if (IsValidChannelName(parameters[0])) { - add_channel(user, parameters[0], parameters[1], false); + chanrec::JoinUser(user, parameters[0], false, parameters[1]); return; } } @@ -42,7 +42,7 @@ void cmd_join::Handle (const char** parameters, int pcnt, userrec *user) if (IsValidChannelName(parameters[0])) { - add_channel(user, parameters[0], "", false); + chanrec::JoinUser(user, parameters[0], false); return; } } diff --git a/src/modules.cpp b/src/modules.cpp index a171e427f..d012d2c71 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -400,11 +400,6 @@ void Server::SendToModeMask(const std::string &modes, int flags, const std::stri WriteMode(modes.c_str(),flags,"%s",text.c_str()); } -chanrec* Server::JoinUserToChannel(userrec* user, const std::string &cname, const std::string &key) -{ - return add_channel(user,cname.c_str(),key.c_str(),false); -} - chanuserlist Server::GetUsers(chanrec* chan) { chanuserlist userl; diff --git a/src/modules/m_operjoin.cpp b/src/modules/m_operjoin.cpp index a0a81f7ed..bf3088053 100644 --- a/src/modules/m_operjoin.cpp +++ b/src/modules/m_operjoin.cpp @@ -72,9 +72,7 @@ class ModuleOperjoin : public Module std::vector<std::string> operChans; tokenize(operChan,operChans); for(std::vector<std::string>::iterator it = operChans.begin(); it != operChans.end(); it++) - { - Srv->JoinUserToChannel(user,(*it),""); - } + chanrec::JoinUser(user, it->c_str(), false); } } diff --git a/src/modules/m_redirect.cpp b/src/modules/m_redirect.cpp index a30073355..bbddb0f18 100644 --- a/src/modules/m_redirect.cpp +++ b/src/modules/m_redirect.cpp @@ -138,7 +138,7 @@ class ModuleRedirect : public Module { std::string channel = chan->GetModeParameter('L'); WriteServ(user->fd,"470 %s :%s has become full, so you are automatically being transferred to the linked channel %s",user->nick,cname,channel.c_str()); - Srv->JoinUserToChannel(user,channel.c_str(),""); + chanrec::JoinUser(user, channel.c_str(), false); return 1; } } diff --git a/src/modules/m_sajoin.cpp b/src/modules/m_sajoin.cpp index a94e03958..0c7387213 100644 --- a/src/modules/m_sajoin.cpp +++ b/src/modules/m_sajoin.cpp @@ -54,7 +54,7 @@ class cmd_sajoin : public command_t } Srv->SendOpers(std::string(user->nick)+" used SAJOIN to make "+std::string(dest->nick)+" join "+parameters[1]); - Srv->JoinUserToChannel(dest,std::string(parameters[1]),std::string(dest->nick)); + chanrec::JoinUser(dest, parameters[1], true); } } }; diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp index d3f8e9a21..d8292a669 100644 --- a/src/modules/m_spanningtree.cpp +++ b/src/modules/m_spanningtree.cpp @@ -1430,7 +1430,7 @@ class TreeSocket : public InspSocket who = Srv->FindNick(usr); if (who) { - Srv->JoinUserToChannel(who,channel,key); + chanrec::JoinUser(who, channel.c_str(), true, key); if (modectr >= (MAXMODES-1)) { /* theres a mode for this user. push them onto the mode queue, and flush it @@ -2030,7 +2030,7 @@ class TreeSocket : public InspSocket if (u) { - Srv->JoinUserToChannel(u,params[1],""); + chanrec::JoinUser(u, params[1].c_str(), false); DoOneToAllButSender(prefix,"SVSJOIN",params,prefix); } return true; |