X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fusers.cpp;h=6ec46883ff7e8054b21c77bbe23c51a3f4f86296;hb=f1f8173bb5ca5f5ce01ad92d0ccd309f232fc138;hp=eff72033d021e9c2af29920748c7ce512630734d;hpb=1cf73c8f32ef8c9cd2a3a1447f9c346e8c2fdacd;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/users.cpp b/src/users.cpp index eff72033d..6ec46883f 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -86,7 +86,6 @@ User::User(const std::string& uid, Server* srv, int type) LocalUser::LocalUser(int myfd, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* servaddr) : User(ServerInstance->UIDGen.GetUID(), ServerInstance->FakeClient->server, USERTYPE_LOCAL), eh(this), - localuseriter(ServerInstance->Users->local_users.end()), bytes_in(0), bytes_out(0), cmds_in(0), cmds_out(0), nping(0), CommandFloodPenalty(0), already_sent(0) { @@ -337,17 +336,7 @@ CullResult User::cull() CullResult LocalUser::cull() { - // The iterator is initialized to local_users.end() in the constructor. It is - // overwritten in UserManager::AddUser() with the real iterator so this check - // is only a precaution currently. - if (localuseriter != ServerInstance->Users->local_users.end()) - { - ServerInstance->Users->local_count--; - ServerInstance->Users->local_users.erase(localuseriter); - } - else - ServerInstance->Logs->Log("USERS", LOG_DEFAULT, "ERROR: LocalUserIter does not point to a valid entry for " + this->nick); - + ServerInstance->Users->local_users.erase(this); ClearInvites(); eh.cull(); return User::cull(); @@ -682,7 +671,7 @@ bool User::ChangeNick(const std::string& newnick, bool force) { for (UCListIter i = this->chans.begin(); i != this->chans.end(); i++) { - Channel *chan = *i; + Channel* chan = (*i)->chan; if (chan->GetPrefixValue(this) < VOICE_VALUE && chan->IsBanned(this)) { this->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s :Cannot send to channel (you're banned)", chan->name.c_str()); @@ -761,7 +750,7 @@ const std::string& User::GetIPString() irc::sockets::satoap(client_sa, cachedip, port); /* IP addresses starting with a : on irc are a Bad Thing (tm) */ if (cachedip[0] == ':') - cachedip.insert(0,1,'0'); + cachedip.insert(cachedip.begin(),1,'0'); } return cachedip; @@ -896,7 +885,7 @@ void User::WriteNumeric(unsigned int numeric, const std::string &text) if (MOD_RESULT == MOD_RES_DENY) return; - + const std::string message = InspIRCd::Format(":%s %03u %s %s", ServerInstance->Config->ServerName.c_str(), numeric, !this->nick.empty() ? this->nick.c_str() : "*", text.c_str()); this->Write(message); @@ -962,7 +951,7 @@ void User::WriteCommonRaw(const std::string &line, bool include_self) LocalUser::already_sent_id++; - UserChanList include_c(chans); + IncludeChanList include_c(chans.begin(), chans.end()); std::map exceptions; exceptions[this] = include_self; @@ -979,9 +968,9 @@ void User::WriteCommonRaw(const std::string &line, bool include_self) u->Write(line); } } - for (UCListIter v = include_c.begin(); v != include_c.end(); ++v) + for (IncludeChanList::const_iterator v = include_c.begin(); v != include_c.end(); ++v) { - Channel* c = *v; + Channel* c = (*v)->chan; const UserMembList* ulist = c->GetUsers(); for (UserMembList::const_iterator i = ulist->begin(); i != ulist->end(); i++) { @@ -1005,7 +994,7 @@ void User::WriteCommonQuit(const std::string &normal_text, const std::string &op const std::string normalMessage = ":" + this->GetFullHost() + " QUIT :" + normal_text; const std::string operMessage = ":" + this->GetFullHost() + " QUIT :" + oper_text; - UserChanList include_c(chans); + IncludeChanList include_c(chans.begin(), chans.end()); std::map exceptions; FOREACH_MOD(OnBuildNeighborList, (this, include_c, exceptions)); @@ -1020,9 +1009,9 @@ void User::WriteCommonQuit(const std::string &normal_text, const std::string &op u->Write(u->IsOper() ? operMessage : normalMessage); } } - for (UCListIter v = include_c.begin(); v != include_c.end(); ++v) + for (IncludeChanList::const_iterator v = include_c.begin(); v != include_c.end(); ++v) { - const UserMembList* ulist = (*v)->GetUsers(); + const UserMembList* ulist = (*v)->chan->GetUsers(); for (UserMembList::const_iterator i = ulist->begin(); i != ulist->end(); i++) { LocalUser* u = IS_LOCAL(i->first); @@ -1096,7 +1085,7 @@ bool User::SharesChannelWith(User *other) /* Eliminate the inner loop (which used to be ~equal in size to the outer loop) * by replacing it with a map::find which *should* be more efficient */ - if ((*i)->HasUser(other)) + if ((*i)->chan->HasUser(other)) return true; } return false; @@ -1277,9 +1266,10 @@ void LocalUser::SetClass(const std::string &explicit_name) void User::PurgeEmptyChannels() { // firstly decrement the count on each channel - for (UCListIter f = this->chans.begin(); f != this->chans.end(); f++) + for (UCListIter i = this->chans.begin(); i != this->chans.end(); ) { - Channel* c = *f; + Channel* c = (*i)->chan; + ++i; c->DelUser(this); }