diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/channels.cpp | 65 | ||||
-rw-r--r-- | src/cmd_invite.cpp | 4 | ||||
-rw-r--r-- | src/cmd_kick.cpp | 2 | ||||
-rw-r--r-- | src/cmd_list.cpp | 4 | ||||
-rw-r--r-- | src/cmd_names.cpp | 2 | ||||
-rw-r--r-- | src/cmd_notice.cpp | 2 | ||||
-rw-r--r-- | src/cmd_privmsg.cpp | 2 | ||||
-rw-r--r-- | src/cmd_topic.cpp | 2 | ||||
-rw-r--r-- | src/cmd_who.cpp | 2 | ||||
-rw-r--r-- | src/helperfuncs.cpp | 7 | ||||
-rw-r--r-- | src/message.cpp | 25 | ||||
-rw-r--r-- | src/mode.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_operwho.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_safelist.cpp | 5 | ||||
-rw-r--r-- | src/modules/m_uninvite.cpp | 2 | ||||
-rwxr-xr-x | src/svn-rev.sh | 2 |
16 files changed, 57 insertions, 77 deletions
diff --git a/src/channels.cpp b/src/channels.cpp index 8aa6e9f54..95e511156 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -128,94 +128,91 @@ long chanrec::GetUserCounter() return (this->internal_userlist.size()); } -void chanrec::AddUser(userrec* castuser) +void chanrec::AddUser(userrec* user) { - internal_userlist[castuser] = castuser; - log(DEBUG,"Added casted user to channel's internal list"); + internal_userlist[user] = user; } -void chanrec::DelUser(userrec* castuser) +void chanrec::DelUser(userrec* user) { - CUList::iterator a = internal_userlist.find(castuser); + CUList::iterator a = internal_userlist.find(user); if (a != internal_userlist.end()) { - log(DEBUG,"Removed casted user from channel's internal list"); internal_userlist.erase(a); /* And tidy any others... */ - DelOppedUser(castuser); - DelHalfoppedUser(castuser); - DelVoicedUser(castuser); + DelOppedUser(user); + DelHalfoppedUser(user); + DelVoicedUser(user); return; } } -void chanrec::AddOppedUser(userrec* castuser) +bool chanrec::HasUser(userrec* user) { - internal_op_userlist[castuser] = castuser; - log(DEBUG,"Added casted user to channel's internal list"); + return (internal_userlist.find(user) != internal_userlist.end()); } -void chanrec::DelOppedUser(userrec* castuser) +void chanrec::AddOppedUser(userrec* user) { - CUList::iterator a = internal_op_userlist.find(castuser); + internal_op_userlist[user] = user; +} + +void chanrec::DelOppedUser(userrec* user) +{ + CUList::iterator a = internal_op_userlist.find(user); if (a != internal_op_userlist.end()) { - log(DEBUG,"Removed casted user from channel's internal list"); internal_op_userlist.erase(a); return; } } -void chanrec::AddHalfoppedUser(userrec* castuser) +void chanrec::AddHalfoppedUser(userrec* user) { - internal_halfop_userlist[castuser] = castuser; - log(DEBUG,"Added casted user to channel's internal list"); + internal_halfop_userlist[user] = user; } -void chanrec::DelHalfoppedUser(userrec* castuser) +void chanrec::DelHalfoppedUser(userrec* user) { - CUList::iterator a = internal_halfop_userlist.find(castuser); + CUList::iterator a = internal_halfop_userlist.find(user); if (a != internal_halfop_userlist.end()) { - log(DEBUG,"Removed casted user from channel's internal list"); internal_halfop_userlist.erase(a); return; } } -void chanrec::AddVoicedUser(userrec* castuser) +void chanrec::AddVoicedUser(userrec* user) { - internal_voice_userlist[castuser] = castuser; - log(DEBUG,"Added casted user to channel's internal list"); + internal_voice_userlist[user] = user; } -void chanrec::DelVoicedUser(userrec* castuser) +void chanrec::DelVoicedUser(userrec* user) { - CUList::iterator a = internal_voice_userlist.find(castuser); + CUList::iterator a = internal_voice_userlist.find(user); if (a != internal_voice_userlist.end()) { - log(DEBUG,"Removed casted user from channel's internal list"); internal_voice_userlist.erase(a); return; } } -CUList *chanrec::GetUsers() +CUList* chanrec::GetUsers() { return &internal_userlist; } -CUList *chanrec::GetOppedUsers() +CUList* chanrec::GetOppedUsers() { return &internal_op_userlist; } -CUList *chanrec::GetHalfoppedUsers() +CUList* chanrec::GetHalfoppedUsers() { return &internal_halfop_userlist; } -CUList *chanrec::GetVoicedUsers() +CUList* chanrec::GetVoicedUsers() { return &internal_voice_userlist; } @@ -273,7 +270,7 @@ chanrec* add_channel(userrec *user, const char* cn, const char* key, bool overri else { /* Already on the channel */ - if (has_channel(user,Ptr)) + if (Ptr->HasUser(user)) return NULL; /* @@ -536,7 +533,7 @@ void server_kick_channel(userrec* user, chanrec* Ptr, char* reason, bool trigger if (IS_LOCAL(user)) { - if (!has_channel(user,Ptr)) + if (!Ptr->HasUser(user)) { /* Not on channel */ return; @@ -589,7 +586,7 @@ void kick_channel(userrec *src,userrec *user, chanrec *Ptr, char* reason) if (IS_LOCAL(src)) { - if (!has_channel(user,Ptr)) + if (!Ptr->HasUser(user)) { WriteServ(src->fd,"441 %s %s %s :They are not on that channel",src->nick, user->nick, Ptr->name); return; diff --git a/src/cmd_invite.cpp b/src/cmd_invite.cpp index 6f6cbaa7d..07559a082 100644 --- a/src/cmd_invite.cpp +++ b/src/cmd_invite.cpp @@ -70,12 +70,12 @@ void cmd_invite::Handle (char **parameters, int pcnt, userrec *user) return; } } - if (has_channel(u,c)) + if (c->HasUser(u)) { WriteServ(user->fd,"443 %s %s %s :Is already on channel %s",user->nick,u->nick,c->name,c->name); return; } - if ((IS_LOCAL(user)) && (!has_channel(user,c))) + if ((IS_LOCAL(user)) && (!c->HasUser(user))) { WriteServ(user->fd,"442 %s %s :You're not on that channel!",user->nick, c->name); return; diff --git a/src/cmd_kick.cpp b/src/cmd_kick.cpp index 5c272112c..8732dd7cf 100644 --- a/src/cmd_kick.cpp +++ b/src/cmd_kick.cpp @@ -51,7 +51,7 @@ void cmd_kick::Handle (char **parameters, int pcnt, userrec *user) WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, u ? parameters[0] : parameters[1]); return; } - if ((IS_LOCAL(user)) && (!has_channel(user,Ptr)) && (!is_uline(user->server))) + if ((IS_LOCAL(user)) && (!Ptr->HasUser(user)) && (!is_uline(user->server))) { WriteServ(user->fd,"442 %s %s :You're not on that channel!",user->nick, parameters[0]); return; diff --git a/src/cmd_list.cpp b/src/cmd_list.cpp index 262738fb3..7b17cfa77 100644 --- a/src/cmd_list.cpp +++ b/src/cmd_list.cpp @@ -46,9 +46,9 @@ void cmd_list::Handle (char **parameters, int pcnt, userrec *user) for (chan_hash::const_iterator i = chanlist.begin(); i != chanlist.end(); i++) { // if the channel is not private/secret, OR the user is on the channel anyway - if (((!(i->second->binarymodes & CM_PRIVATE)) && (!(i->second->binarymodes & CM_SECRET))) || (has_channel(user,i->second))) + if (((!(i->second->binarymodes & CM_PRIVATE)) && (!(i->second->binarymodes & CM_SECRET))) || (i->second->HasUser(user))) { - WriteServ(user->fd,"322 %s %s %d :[+%s] %s",user->nick,i->second->name,usercount_i(i->second),chanmodes(i->second,has_channel(user,i->second)),i->second->topic); + WriteServ(user->fd,"322 %s %s %d :[+%s] %s",user->nick,i->second->name,usercount_i(i->second),chanmodes(i->second,i->second->HasUser(user)),i->second->topic); } } WriteServ(user->fd,"323 %s :End of channel list.",user->nick); diff --git a/src/cmd_names.cpp b/src/cmd_names.cpp index bc1eb69c7..43797cbeb 100644 --- a/src/cmd_names.cpp +++ b/src/cmd_names.cpp @@ -76,7 +76,7 @@ void cmd_names::Handle (char **parameters, int pcnt, userrec *user) c = FindChan(parameters[0]); if (c) { - if (((c) && (!has_channel(user,c))) && (c->binarymodes & CM_SECRET)) + if ((c->binarymodes & CM_SECRET) && (!c->HasUser(user))) { WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, c->name); return; diff --git a/src/cmd_notice.cpp b/src/cmd_notice.cpp index 6dcab9553..58800ccc0 100644 --- a/src/cmd_notice.cpp +++ b/src/cmd_notice.cpp @@ -94,7 +94,7 @@ void cmd_notice::Handle (char **parameters, int pcnt, userrec *user) { if (IS_LOCAL(user)) { - if ((chan->binarymodes & CM_NOEXTERNAL) && (!has_channel(user,chan))) + if ((chan->binarymodes & CM_NOEXTERNAL) && (!chan->HasUser(user))) { WriteServ(user->fd,"404 %s %s :Cannot send to channel (no external messages)", user->nick, chan->name); return; diff --git a/src/cmd_privmsg.cpp b/src/cmd_privmsg.cpp index 41999a4ec..2770be330 100644 --- a/src/cmd_privmsg.cpp +++ b/src/cmd_privmsg.cpp @@ -94,7 +94,7 @@ void cmd_privmsg::Handle (char **parameters, int pcnt, userrec *user) { if (IS_LOCAL(user)) { - if ((chan->binarymodes & CM_NOEXTERNAL) && (!has_channel(user,chan))) + if ((chan->binarymodes & CM_NOEXTERNAL) && (!chan->HasUser(user))) { WriteServ(user->fd,"404 %s %s :Cannot send to channel (no external messages)", user->nick, chan->name); return; diff --git a/src/cmd_topic.cpp b/src/cmd_topic.cpp index e1e77bf58..9de8637b4 100644 --- a/src/cmd_topic.cpp +++ b/src/cmd_topic.cpp @@ -70,7 +70,7 @@ void cmd_topic::Handle (char **parameters, int pcnt, userrec *user) Ptr = FindChan(parameters[0]); if (Ptr) { - if (((Ptr) && (!has_channel(user,Ptr))) && (Ptr->binarymodes & CM_SECRET)) + if ((Ptr->binarymodes & CM_SECRET) && (!Ptr->HasUser(user))) { WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, Ptr->name); return; diff --git a/src/cmd_who.cpp b/src/cmd_who.cpp index d82b7906f..c25fa611d 100644 --- a/src/cmd_who.cpp +++ b/src/cmd_who.cpp @@ -115,7 +115,7 @@ void cmd_who::Handle (char **parameters, int pcnt, userrec *user) int n_list = 0; for (user_hash::const_iterator i = clientlist.begin(); i != clientlist.end(); i++) { - if ((has_channel(i->second,Ptr)) && (isnick(i->second->nick))) + if ((Ptr->HasUser(i->second)) && (isnick(i->second->nick))) { // Fix Bug #29 - Part 2.. *tmp = 0; diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index c313b5456..2a929f3b2 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -1348,9 +1348,14 @@ void userlist(userrec *user,chanrec *c) CUList *ulist= c->GetUsers(); + /* Improvement by Brain - this doesnt change in value, so why was it inside + * the loop? + */ + bool has_user = c->HasUser(user,c); + for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++) { - if ((!has_channel(user,c)) && (strchr(i->second->modes,'i'))) + if ((!n) && (strchr(i->second->modes,'i'))) { /* * user is +i, and source not on the channel, does not show diff --git a/src/message.cpp b/src/message.cpp index 9cfecb850..e943aa784 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -371,29 +371,6 @@ int cstatus(userrec *user, chanrec *chan) return STATUS_NORMAL; } -/* returns 1 if user u has channel c in their record, 0 if not */ - -int has_channel(userrec *u, chanrec *c) -{ - if ((!u) || (!c)) - { - log(DEFAULT,"*** BUG *** has_channel was given an invalid parameter"); - return 0; - } - for (unsigned int i =0; i < u->chans.size(); i++) - { - if (u->chans[i].channel) - { - if (u->chans[i].channel == c) - { - return 1; - } - } - } - return 0; -} - - void TidyBan(char *ban) { if (!ban) { @@ -443,7 +420,7 @@ std::string chlist(userrec *user,userrec* source) { // if the channel is NOT private/secret, OR the source user is on the channel, AND the user is not invisible. // if the user is the same as the source, shortcircuit the comparison. - if ((source == user) || ((((!(user->chans[i].channel->binarymodes & CM_PRIVATE)) && (!(user->chans[i].channel->binarymodes & CM_SECRET)) && (!userinvisible)) || (has_channel(source,user->chans[i].channel))))) + if ((source == user) || ((((!(user->chans[i].channel->binarymodes & CM_PRIVATE)) && (!(user->chans[i].channel->binarymodes & CM_SECRET)) && (!userinvisible)) || (user->chans[i].channel->HasUser(source))))) { lst = lst + std::string(cmode(user,user->chans[i].channel)) + std::string(user->chans[i].channel->name) + " "; } diff --git a/src/mode.cpp b/src/mode.cpp index 0acdd2bc0..5b5523dfe 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -1310,7 +1310,7 @@ void cmd_mode::Handle (char **parameters, int pcnt, userrec *user) if (pcnt == 1) { /* just /modes #channel */ - WriteServ(user->fd,"324 %s %s +%s",user->nick, Ptr->name, chanmodes(Ptr,has_channel(user,Ptr))); + WriteServ(user->fd,"324 %s %s +%s",user->nick, Ptr->name, chanmodes(Ptr,Ptr->HasUser(user))); WriteServ(user->fd,"329 %s %s %d", user->nick, Ptr->name, Ptr->created); return; } @@ -1342,7 +1342,7 @@ void cmd_mode::Handle (char **parameters, int pcnt, userrec *user) } } - if (((Ptr) && (!has_channel(user,Ptr))) && (!is_uline(user->server)) && (IS_LOCAL(user))) + if ((IS_LOCAL(user)) && (!is_uline(user->server)) && (!Ptr->HasUser(user))) { WriteServ(user->fd,"442 %s %s :You're not on that channel!",user->nick, Ptr->name); return; @@ -1357,7 +1357,7 @@ void cmd_mode::Handle (char **parameters, int pcnt, userrec *user) return; if (MOD_RESULT == ACR_DEFAULT) { - if ((cstatus(user,Ptr) < STATUS_HOP) && (IS_LOCAL(user))) + if ((IS_LOCAL(user)) && (cstatus(user,Ptr) < STATUS_HOP)) { WriteServ(user->fd,"482 %s %s :You must be at least a half-operator to change modes on this channel",user->nick, Ptr->name); return; diff --git a/src/modules/m_operwho.cpp b/src/modules/m_operwho.cpp index e4dbf3235..8926b2a9c 100644 --- a/src/modules/m_operwho.cpp +++ b/src/modules/m_operwho.cpp @@ -128,7 +128,7 @@ class ModuleOperWho : public Module { for (user_hash::const_iterator i = clientlist.begin(); i != clientlist.end(); i++) { - if ((has_channel(i->second,Ptr)) && (isnick(i->second->nick))) + if ((Ptr->HasUser(i->second)) && (isnick(i->second->nick))) { // Fix Bug #29 - Part 2.. *tmp = 0; diff --git a/src/modules/m_safelist.cpp b/src/modules/m_safelist.cpp index debacaaeb..6e1789097 100644 --- a/src/modules/m_safelist.cpp +++ b/src/modules/m_safelist.cpp @@ -97,10 +97,11 @@ class ListTimer : public InspTimer WriteServ(u->fd,"321 %s Channel :Users Name",u->nick); chan = Srv->GetChannelIndex(ld->list_position); /* spool details */ - if ((chan) && (((!(chan->binarymodes & CM_PRIVATE)) && (!(chan->binarymodes & CM_SECRET))) || (has_channel(u,chan)))) + bool has_user = chan->HasUser(u); + if ((chan) && (((!(chan->binarymodes & CM_PRIVATE)) && (!(chan->binarymodes & CM_SECRET))) || (has_user))) { /* Increment total plus linefeed */ - int counter = snprintf(buffer,MAXBUF,"322 %s %s %d :[+%s] %s",u->nick,chan->name,usercount_i(chan),chanmodes(chan,has_channel(u,chan)),chan->topic); + int counter = snprintf(buffer,MAXBUF,"322 %s %s %d :[+%s] %s",u->nick,chan->name,usercount_i(chan),chanmodes(chan,has_user),chan->topic); amount_sent += counter + 4 + Srv->GetServerName().length(); log(DEBUG,"m_safelist.so: Sent %ld of safe %ld / 4",amount_sent,u->sendqmax); WriteServ_NoFormat(u->fd,buffer); diff --git a/src/modules/m_uninvite.cpp b/src/modules/m_uninvite.cpp index e9c2078cb..dbd3af52f 100644 --- a/src/modules/m_uninvite.cpp +++ b/src/modules/m_uninvite.cpp @@ -70,7 +70,7 @@ class cmd_uninvite : public command_t WriteServ(user->fd,"491 %s %s %s :Is not invited to channel %s",user->nick,u->nick,c->name,c->name); return; } - if (!has_channel(user,c)) + if (!c->HasUser(user)) { WriteServ(user->fd,"492 %s %s :You're not on that channel!",user->nick, c->name); return; diff --git a/src/svn-rev.sh b/src/svn-rev.sh index 157c5c456..1a7209991 100755 --- a/src/svn-rev.sh +++ b/src/svn-rev.sh @@ -1 +1 @@ -echo 3557 +echo 3559 |