diff options
Diffstat (limited to 'src/users.c')
-rw-r--r-- | src/users.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/users.c b/src/users.c index a1f9fb05c..c67d1a762 100644 --- a/src/users.c +++ b/src/users.c @@ -272,10 +272,7 @@ User::~User() while (!this->chans.empty()) { - ChannelContainer *cc = this->chans.front(); - cc->chan->DeleteUser(this); - delete cc; - this->chans.pop_front(); + this->chans.front()->chan->DeleteUser(this); } /* Cancel pending nickname enforcers, etc */ @@ -609,13 +606,26 @@ void User::SetModes(BotInfo *bi, const char *modes, ...) else this->SetMode(bi, um); } - else if (add == 0) + else { this->RemoveMode(bi, um); } } } +/** Find the channel container for Channel c that the user is on + * This is preferred over using FindUser in Channel, as there are usually more users in a channel + * than channels a user is in + * @param c The channel + * @return The channel container, or NULL + */ +ChannelContainer *User::FindChannel(Channel *c) +{ + for (UChannelList::iterator it = this->chans.begin(); it != this->chans.end(); ++it) + if ((*it)->chan == c) + return *it; + return NULL; +} /*************************************************************************/ |