diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/channels.cpp | 60 | ||||
-rw-r--r-- | src/messages.cpp | 13 | ||||
-rw-r--r-- | src/servers.cpp | 4 | ||||
-rw-r--r-- | src/users.cpp | 4 |
4 files changed, 38 insertions, 43 deletions
diff --git a/src/channels.cpp b/src/channels.cpp index b3ccf0fad..4a21bdd1a 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -72,12 +72,12 @@ void Channel::Reset() { this->modes.clear(); - for (CUserList::const_iterator it = this->users.begin(), it_end = this->users.end(); it != it_end; ++it) + for (ChanUserList::const_iterator it = this->users.begin(), it_end = this->users.end(); it != it_end; ++it) { - UserContainer *uc = *it; + ChanUserContainer *uc = *it; - ChannelStatus flags = *uc->status; - uc->status->ClearFlags(); + ChannelStatus flags = uc->status; + uc->status.ClearFlags(); if (BotInfo::Find(uc->user->nick)) { @@ -93,7 +93,7 @@ void Channel::Reset() this->CheckModes(); - for (CUserList::const_iterator it = this->users.begin(), it_end = this->users.end(); it != it_end; ++it) + for (ChanUserList::const_iterator it = this->users.begin(), it_end = this->users.end(); it != it_end; ++it) this->SetCorrectModes((*it)->user, true, false); if (this->ci && Me && Me->IsSynced()) @@ -183,18 +183,13 @@ void Channel::CheckModes() } } -UserContainer* Channel::JoinUser(User *user) +ChanUserContainer* Channel::JoinUser(User *user) { Log(user, this, "join"); - ChannelStatus *status = new ChannelStatus(); - ChannelContainer *cc = new ChannelContainer(this); - cc->status = status; - user->chans.push_back(cc); - - UserContainer *uc = new UserContainer(user); - uc->status = status; - this->users.push_back(uc); + ChanUserContainer *cuc = new ChanUserContainer(user, this); + user->chans.push_back(cuc); + this->users.push_back(cuc); if (this->ci && this->ci->HasFlag(CI_PERSIST) && this->creation_time > this->ci->time_registered) { @@ -204,7 +199,7 @@ UserContainer* Channel::JoinUser(User *user) this->Reset(); } - return uc; + return cuc; } void Channel::DeleteUser(User *user) @@ -212,27 +207,28 @@ void Channel::DeleteUser(User *user) Log(user, this, "leaves"); FOREACH_MOD(I_OnLeaveChannel, OnLeaveChannel(user, this)); - CUserList::iterator cit, cit_end = this->users.end(); - for (cit = this->users.begin(); (*cit)->user != user && cit != cit_end; ++cit); + ChanUserContainer *cul; + ChanUserList::iterator cit, cit_end; + for (cit = this->users.begin(), cit_end = this->users.end(); cit != cit_end && (*cit)->user != user; ++cit); if (cit == cit_end) { Log(LOG_DEBUG) << "Channel::DeleteUser() tried to delete nonexistant user " << user->nick << " from channel " << this->name; return; } - - delete (*cit)->status; - delete *cit; + cul = *cit; this->users.erase(cit); - UChannelList::iterator uit, uit_end = user->chans.end(); - for (uit = user->chans.begin(); (*uit)->chan != this && uit != uit_end; ++uit); + ChanUserList::iterator uit, uit_end; + for (uit = user->chans.begin(), uit_end = user->chans.end(); uit != uit_end && (*uit)->chan != this; ++uit); if (uit == uit_end) Log(LOG_DEBUG) << "Channel::DeleteUser() tried to delete nonexistant channel " << this->name << " from " << user->nick << "'s channel list"; else { - delete *uit; + if (cul != *uit) + Log(LOG_DEBUG) << "Channel::DeleteUser() mismatch between user and channel usre container objects"; user->chans.erase(uit); } + delete cul; /* Channel is persistent, it shouldn't be deleted and the service bot should stay */ if (this->HasFlag(CH_PERSIST) || (this->ci && this->ci->HasFlag(CI_PERSIST))) @@ -252,9 +248,9 @@ void Channel::DeleteUser(User *user) delete this; } -UserContainer *Channel::FindUser(const User *u) const +ChanUserContainer *Channel::FindUser(const User *u) const { - for (CUserList::const_iterator it = this->users.begin(), it_end = this->users.end(); it != it_end; ++it) + for (ChanUserList::const_iterator it = this->users.begin(), it_end = this->users.end(); it != it_end; ++it) if ((*it)->user == u) return *it; return NULL; @@ -266,13 +262,13 @@ bool Channel::HasUserStatus(const User *u, ChannelModeStatus *cms) const throw CoreException("Channel::HasUserStatus got bad mode"); /* Usually its more efficient to search the users channels than the channels users */ - ChannelContainer *cc = u->FindChannel(this); + ChanUserContainer *cc = u->FindChannel(this); if (cc) { if (cms) - return cc->status->HasFlag(cms->name); + return cc->status.HasFlag(cms->name); else - return !cc->status->FlagCount(); + return !cc->status.FlagCount(); } return false; @@ -330,9 +326,9 @@ void Channel::SetModeInternal(MessageSource &setter, ChannelMode *cm, const Anop Log(LOG_DEBUG) << "Setting +" << cm->mchar << " on " << this->name << " for " << u->nick; /* Set the status on the user */ - ChannelContainer *cc = u->FindChannel(this); + ChanUserContainer *cc = u->FindChannel(this); if (cc) - cc->status->SetFlag(cm->name); + cc->status.SetFlag(cm->name); /* Enforce secureops, etc */ if (enforce_mlock) @@ -400,9 +396,9 @@ void Channel::RemoveModeInternal(MessageSource &setter, ChannelMode *cm, const A Log(LOG_DEBUG) << "Setting -" << cm->mchar << " on " << this->name << " for " << u->nick; /* Remove the status on the user */ - ChannelContainer *cc = u->FindChannel(this); + ChanUserContainer *cc = u->FindChannel(this); if (cc) - cc->status->UnsetFlag(cm->name); + cc->status.UnsetFlag(cm->name); if (enforce_mlock) { diff --git a/src/messages.cpp b/src/messages.cpp index f9dc81c85..79a32347b 100644 --- a/src/messages.cpp +++ b/src/messages.cpp @@ -62,16 +62,15 @@ void Join::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) /* Special case for /join 0 */ if (channel == "0") { - for (UChannelList::iterator it = user->chans.begin(), it_end = user->chans.end(); it != it_end; ) + for (User::ChanUserList::iterator it = user->chans.begin(), it_end = user->chans.end(); it != it_end; ) { - ChannelContainer *cc = *it++; + ChanUserContainer *cc = *it++; Anope::string channame = cc->chan->name; FOREACH_MOD(I_OnPrePartChannel, OnPrePartChannel(user, cc->chan)); cc->chan->DeleteUser(user); FOREACH_MOD(I_OnPartChannel, OnPartChannel(user, Channel::Find(channame), channame, "")); } - user->chans.clear(); continue; } @@ -119,10 +118,10 @@ void Join::SJoin(MessageSource &source, const Anope::string &chan, time_t ts, co FOREACH_RESULT(I_OnPreJoinChannel, OnPreJoinChannel(u, c)); /* Add the user to the channel */ - UserContainer *cc = c->JoinUser(u); + ChanUserContainer *cc = c->JoinUser(u); /* Update their status internally on the channel */ - *cc->status = status; + cc->status = status; /* Set whatever modes the user should have, and remove any that * they aren't allowed to have (secureops etc). @@ -190,8 +189,8 @@ void Kill::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) IRCD->SendClientIntroduction(bi); bi->introduced = true; - for (UChannelList::const_iterator cit = bi->chans.begin(), cit_end = bi->chans.end(); cit != cit_end; ++cit) - IRCD->SendJoin(bi, (*cit)->chan, (*cit)->status); + for (User::ChanUserList::const_iterator cit = bi->chans.begin(), cit_end = bi->chans.end(); cit != cit_end; ++cit) + IRCD->SendJoin(bi, (*cit)->chan, &(*cit)->status); } else u->KillInternal(source.GetSource(), params[1]); diff --git a/src/servers.cpp b/src/servers.cpp index 447633298..392e494a0 100644 --- a/src/servers.cpp +++ b/src/servers.cpp @@ -108,8 +108,8 @@ Server::Server(Server *up, const Anope::string &sname, unsigned shops, const Ano if (c->users.empty()) IRCD->SendChannel(c); else - for (CUserList::const_iterator cit = c->users.begin(), cit_end = c->users.end(); cit != cit_end; ++cit) - IRCD->SendJoin((*cit)->user, c, (*cit)->status); + for (User::ChanUserList::const_iterator cit = c->users.begin(), cit_end = c->users.end(); cit != cit_end; ++cit) + IRCD->SendJoin((*cit)->user, c, &(*cit)->status); } } } diff --git a/src/users.cpp b/src/users.cpp index 3bbc0d7fd..0e2ed34f9 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -726,9 +726,9 @@ Anope::string User::GetModes() const return ret; } -ChannelContainer *User::FindChannel(const Channel *c) const +ChanUserContainer *User::FindChannel(const Channel *c) const { - for (UChannelList::const_iterator it = this->chans.begin(), it_end = this->chans.end(); it != it_end; ++it) + for (User::ChanUserList::const_iterator it = this->chans.begin(), it_end = this->chans.end(); it != it_end; ++it) if ((*it)->chan == c) return *it; return NULL; |