diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cmd_who.cpp | 8 | ||||
-rw-r--r-- | src/helperfuncs.cpp | 45 | ||||
-rw-r--r-- | src/modules.cpp | 10 | ||||
-rw-r--r-- | src/users.cpp | 13 |
4 files changed, 32 insertions, 44 deletions
diff --git a/src/cmd_who.cpp b/src/cmd_who.cpp index c25fa611d..4a94dc659 100644 --- a/src/cmd_who.cpp +++ b/src/cmd_who.cpp @@ -71,12 +71,12 @@ void cmd_who::Handle (char **parameters, int pcnt, userrec *user) { if ((IS_SINGLE(parameters[0],'0')) || (IS_SINGLE(parameters[0],'*'))) { - if ((user->chans.size()) && (user->chans[0].channel)) + if ((user->chans.size()) && (((ucrec*)*(user->chans.begin()))->channel)) { int n_list = 0; for (user_hash::const_iterator i = clientlist.begin(); i != clientlist.end(); i++) { - Ptr = i->second->chans[0].channel; + Ptr = ((ucrec*)*(i->second->chans.begin()))->channel; // suggested by phidjit and FCS if ((!common_channels(user,i->second)) && (isnick(i->second->nick))) { @@ -156,7 +156,7 @@ void cmd_who::Handle (char **parameters, int pcnt, userrec *user) charlcat(tmp, 'H' ,9); } if (*u->oper) { charlcat(tmp, '*' ,9); } - WriteServ(user->fd,"352 %s %s %s %s %s %s %s :0 %s",user->nick, u->chans.size() && u->chans[0].channel ? u->chans[0].channel->name + WriteServ(user->fd,"352 %s %s %s %s %s %s %s :0 %s",user->nick, u->chans.size() && ((ucrec*)*(u->chans.begin()))->channel ? ((ucrec*)*(u->chans.begin()))->channel->name : "*", u->ident, u->dhost, u->server, u->nick, tmp, u->fullname); } WriteServ(user->fd,"315 %s %s :End of /WHO list.",user->nick, parameters[0]); @@ -177,7 +177,7 @@ void cmd_who::Handle (char **parameters, int pcnt, userrec *user) } else { charlcat(tmp, 'H' ,9); } - WriteServ(user->fd,"352 %s %s %s %s %s %s %s* :0 %s", user->nick, oper->chans.size() && oper->chans[0].channel ? oper->chans[0].channel->name + WriteServ(user->fd,"352 %s %s %s %s %s %s %s* :0 %s", user->nick, oper->chans.size() && ((ucrec*)*(oper->chans.begin()))->channel ? ((ucrec*)*(oper->chans.begin()))->channel->name : "*", oper->ident, oper->dhost, oper->server, oper->nick, tmp, oper->fullname); } WriteServ(user->fd,"315 %s %s :End of /WHO list.",user->nick, parameters[0]); diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index f728516f9..27bc22007 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -715,7 +715,6 @@ void WriteCommon(userrec *u, char* text, ...) char textbuffer[MAXBUF]; va_list argsPtr; bool sent_to_at_least_one = false; - unsigned int y; if (!u) { @@ -735,13 +734,12 @@ void WriteCommon(userrec *u, char* text, ...) // FIX: Stops a message going to the same person more than once memset(&already_sent,0,MAX_DESCRIPTORS); - y = u->chans.size(); - for (unsigned int i = 0; i < y; i++) + for (std::vector<ucrec*>::const_iterator v = u->chans.begin(); v != u->chans.end(); v++) { - if (u->chans[i].channel) + if (((ucrec*)(*v))->channel) { - CUList *ulist= u->chans[i].channel->GetUsers(); + CUList *ulist= ((ucrec*)(*v))->channel->GetUsers(); for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++) { @@ -768,7 +766,6 @@ void WriteCommon(userrec *u, char* text, ...) void WriteCommon_NoFormat(userrec *u, const char* text) { bool sent_to_at_least_one = false; - unsigned int y; if (!u) { @@ -784,13 +781,12 @@ void WriteCommon_NoFormat(userrec *u, const char* text) // FIX: Stops a message going to the same person more than once memset(&already_sent,0,MAX_DESCRIPTORS); - y = u->chans.size(); - for (unsigned int i = 0; i < y; i++) + for (std::vector<ucrec*>::const_iterator v = u->chans.begin(); v != u->chans.end(); v++) { - if (u->chans[i].channel) + if (((ucrec*)(*v))->channel) { - CUList *ulist= u->chans[i].channel->GetUsers(); + CUList *ulist= ((ucrec*)(*v))->channel->GetUsers(); for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++) { @@ -826,7 +822,6 @@ void WriteCommonExcept(userrec *u, char* text, ...) bool quit_munge = false; va_list argsPtr; int total; - unsigned int y; if (!u) { @@ -886,13 +881,12 @@ void WriteCommonExcept(userrec *u, char* text, ...) } memset(&already_sent,0,MAX_DESCRIPTORS); - y = u->chans.size(); - for (unsigned int i = 0; i < y; i++) + for (std::vector<ucrec*>::const_iterator v = u->chans.begin(); v != u->chans.end(); v++) { - if (u->chans[i].channel) + if (((ucrec*)(*v))->channel) { - CUList *ulist= u->chans[i].channel->GetUsers(); + CUList *ulist= ((ucrec*)(*v))->channel->GetUsers(); for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++) { @@ -917,8 +911,6 @@ void WriteCommonExcept(userrec *u, char* text, ...) void WriteCommonExcept_NoFormat(userrec *u, const char* text) { - unsigned int y; - if (!u) { log(DEFAULT,"*** BUG *** WriteCommon was given an invalid parameter"); @@ -932,13 +924,12 @@ void WriteCommonExcept_NoFormat(userrec *u, const char* text) } memset(&already_sent,0,MAX_DESCRIPTORS); - y = u->chans.size(); - for (unsigned int i = 0; i < y; i++) + for (std::vector<ucrec*>::const_iterator v = u->chans.begin(); v != u->chans.end(); v++) { - if (u->chans[i].channel) + if (((ucrec*)(*v))->channel) { - CUList *ulist= u->chans[i].channel->GetUsers(); + CUList *ulist= ((ucrec*)(*v))->channel->GetUsers(); for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++) { @@ -1218,24 +1209,24 @@ long GetMaxBans(char* name) void purge_empty_chans(userrec* u) { - int purge = 0; std::vector<chanrec*> to_delete; // firstly decrement the count on each channel for (std::vector<ucrec*>::iterator f = u->chans.begin(); f != u->chans.end(); f++) { - ucrec* (ucrec*)*f; - if (f->channel) + if (((ucrec*)(*f))->channel) { - if (f->channel->DelUser(u) == 0) + if (((ucrec*)(*f))->channel->DelUser(u) == 0) { /* No users left in here, mark it for deletion */ - to_delete.push_back(f->channel); - f->channel = NULL; + to_delete.push_back(((ucrec*)(*f))->channel); + ((ucrec*)(*f))->channel = NULL; } } } + log(DEBUG,"purge_empty_chans: %d channels to delete",to_delete.size()); + for (std::vector<chanrec*>::iterator n = to_delete.begin(); n != to_delete.end(); n++) { chanrec* thischan = (chanrec*)*n; diff --git a/src/modules.cpp b/src/modules.cpp index f5129c837..9a420a25e 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -740,13 +740,11 @@ bool Server::PseudoToUser(userrec* alive,userrec* zombie,std::string message) // Fix by brain - cant write the user until their fd table entry is updated fd_ref_table[zombie->fd] = zombie; Write(zombie->fd,":%s!%s@%s NICK %s",oldnick.c_str(),oldident.c_str(),oldhost.c_str(),zombie->nick); - for (unsigned int i = 0; i < zombie->chans.size(); i++) + for (std::vector<ucrec*>::const_iterator i = zombie->chans.begin(); i != zombie->chans.end(); i++) { - if (zombie->chans[i].channel != NULL) + if (((ucrec*)(*i))->channel != NULL) { - if (zombie->chans[i].channel->name) - { - chanrec* Ptr = zombie->chans[i].channel; + chanrec* Ptr = ((ucrec*)(*i))->channel; WriteFrom(zombie->fd,zombie,"JOIN %s",Ptr->name); if (Ptr->topicset) { @@ -755,8 +753,6 @@ bool Server::PseudoToUser(userrec* alive,userrec* zombie,std::string message) } userlist(zombie,Ptr); WriteServ(zombie->fd,"366 %s %s :End of /NAMES list.", zombie->nick, Ptr->name); - - } } } if ((find(local_users.begin(),local_users.end(),zombie) == local_users.end()) && (zombie->fd != FD_MAGIC_NUMBER)) diff --git a/src/users.cpp b/src/users.cpp index 4db389957..5c1d78fb0 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -113,18 +113,19 @@ userrec::userrec() sendq = ""; chans.clear(); invites.clear(); - clientlist[tempnick]->chans.resize(MAXCHANS); + chans.resize(MAXCHANS); for (unsigned int n = 0; n < MAXCHANS; n++) - { - clientlist[tempnick]->chans[n] = new ucrec(); - clientlist[tempnick]->chans[n]->channel = NULL; - clientlist[tempnick]->chans[n]->uc_modes = 0; + { + ucrec* x = new ucrec(); + chans[n] = x; + x->channel = NULL; + x->uc_modes = 0; } } userrec::~userrec() { - for (std::vector<ucrec*>::iterator n = clientlist[tempnick]->chans.begin(); n != clientlist[tempnick]->chans.end(); n++) + for (std::vector<ucrec*>::iterator n = chans.begin(); n != chans.end(); n++) { ucrec* x = (ucrec*)*n; delete x; |