diff options
-rw-r--r-- | include/users.h | 3 | ||||
-rw-r--r-- | src/users.cpp | 18 |
2 files changed, 11 insertions, 10 deletions
diff --git a/include/users.h b/include/users.h index 64cdc9e0d..4652b2cb9 100644 --- a/include/users.h +++ b/include/users.h @@ -439,6 +439,8 @@ class userrec : public connection */ static void QuitUser(userrec *user, const std::string &r); + void AddToWhoWas(); + /** Default destructor */ virtual ~userrec(); @@ -466,7 +468,6 @@ typedef std::map<irc::string,whowas_set*> whowas_users; void AddOper(userrec* user); void DeleteOper(userrec* user); //void kill_link(userrec *user,const char* r); -void AddWhoWas(userrec* u); void MaintainWhoWas(time_t TIME); void AddClient(int socket, int port, bool iscached, insp_inaddr ip4); void FullConnectUser(userrec* user, CullList* Goners); diff --git a/src/users.cpp b/src/users.cpp index 8a48a641c..aab7815e8 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -698,7 +698,7 @@ void userrec::QuitUser(userrec *user,const std::string &quitreason) { if (IS_LOCAL(user)) WriteOpers("*** Client exiting: %s!%s@%s [%s]",user->nick,user->ident,user->host,reason.c_str()); - AddWhoWas(user); + user->AddToWhoWas(); } if (iter != clientlist.end()) @@ -737,29 +737,29 @@ WhoWasGroup::~WhoWasGroup() } /* adds or updates an entry in the whowas list */ -void AddWhoWas(userrec* u) +void userrec::AddToWhoWas() { - whowas_users::iterator iter = whowas.find(u->nick); - + whowas_users::iterator iter = whowas.find(this->nick); + if (iter == whowas.end()) { whowas_set* n = new whowas_set; - WhoWasGroup *a = new WhoWasGroup(u); + WhoWasGroup *a = new WhoWasGroup(this); n->push_back(a); - whowas[u->nick] = n; + whowas[this->nick] = n; } else { whowas_set* group = (whowas_set*)iter->second; - + if (group->size() > 10) { WhoWasGroup *a = (WhoWasGroup*)*(group->begin()); DELETE(a); group->pop_front(); } - - WhoWasGroup *a = new WhoWasGroup(u); + + WhoWasGroup *a = new WhoWasGroup(this); group->push_back(a); } } |