summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/channels.h49
-rw-r--r--include/extern.h2
-rw-r--r--include/services.h23
-rw-r--r--include/users.h14
-rw-r--r--src/actions.c11
-rw-r--r--src/bots.cpp6
-rw-r--r--src/botserv.c47
-rw-r--r--src/channels.c237
-rw-r--r--src/chanserv.c4
-rw-r--r--src/core/bs_act.c2
-rw-r--r--src/core/bs_say.c2
-rw-r--r--src/core/cs_akick.c12
-rw-r--r--src/core/cs_clear.c121
-rw-r--r--src/core/cs_forbid.c10
-rw-r--r--src/core/cs_set.c4
-rw-r--r--src/core/cs_suspend.c10
-rw-r--r--src/core/os_chankill.c13
-rw-r--r--src/core/os_chanlist.c12
-rw-r--r--src/core/os_clearmodes.c46
-rw-r--r--src/core/os_userlist.c11
-rw-r--r--src/memoserv.c10
-rw-r--r--src/modes.cpp2
-rw-r--r--src/modules/cs_enforce.c46
-rw-r--r--src/nickserv.c7
-rw-r--r--src/protocol/bahamut.c16
-rw-r--r--src/protocol/inspircd11.c16
-rw-r--r--src/protocol/inspircd12.cpp16
-rw-r--r--src/protocol/ratbox.c16
-rw-r--r--src/protocol/unreal32.c16
-rw-r--r--src/regchannel.cpp2
-rw-r--r--src/users.c20
31 files changed, 388 insertions, 415 deletions
diff --git a/include/channels.h b/include/channels.h
index 0cd1829e2..3baae9f1b 100644
--- a/include/channels.h
+++ b/include/channels.h
@@ -9,6 +9,39 @@
*
*/
+struct UserData
+{
+ UserData()
+ {
+ lastline = NULL;
+ last_use = time(NULL);
+ }
+
+ virtual ~UserData() { delete [] lastline; }
+
+ /* Data validity */
+ time_t last_use;
+
+ /* for flood kicker */
+ int16 lines;
+ time_t last_start;
+
+ /* for repeat kicker */
+ char *lastline;
+ int16 times;
+};
+
+struct UserContainer
+{
+ User *user;
+ UserData *ud;
+
+ UserContainer(User *u) : user(u) { ud = new UserData; }
+ virtual ~UserContainer() { delete ud; }
+};
+
+typedef std::list<UserContainer *> CUserList;
+
enum ChannelFlags
{
/* Channel still exists when emptied */
@@ -24,6 +57,9 @@ class CoreExport Channel : public Extensible, public Flags<ChannelFlags>
*/
std::map<ChannelModeName, std::string> Params;
+ /* Modes set on the channel */
+ std::bitset<128> modes;
+
public:
/** Default constructor
* @param name The channel name
@@ -42,14 +78,13 @@ class CoreExport Channel : public Extensible, public Flags<ChannelFlags>
char *topic;
std::string topic_setter;
time_t topic_time; /* When topic was set */
- std::bitset<128> modes;
EList *bans;
EList *excepts;
EList *invites;
- struct c_userlist *users;
- uint16 usercount;
+ /* List of users in the channel */
+ CUserList users;
BanData *bd;
@@ -74,8 +109,12 @@ class CoreExport Channel : public Extensible, public Flags<ChannelFlags>
*/
void DeleteUser(User *u);
- /**
- * See if a channel has a mode
+ /** See if the channel has any modes at all
+ * @return true or false
+ */
+ inline const bool HasModes() const { return modes.count(); }
+
+ /** See if a channel has a mode
* @param Name The mode name
* @return true or false
*/
diff --git a/include/extern.h b/include/extern.h
index a46894fa2..37fc40144 100644
--- a/include/extern.h
+++ b/include/extern.h
@@ -111,7 +111,7 @@ E Entry *elist_find_mask(EList *list, const char *mask);
E long get_memuse(EList *list);
-#define whosends(ci) ((!(ci) || !((ci)->botflags.HasFlag(BS_SYMBIOSIS)) || !(ci)->bi || !(ci)->c || (ci)->c->usercount < Config.BSMinUsers) ? findbot(Config.s_ChanServ) : (ci)->bi)
+#define whosends(ci) ((!(ci) || !((ci)->botflags.HasFlag(BS_SYMBIOSIS)) || !(ci)->bi || !(ci)->c || (ci)->c->users.size() < Config.BSMinUsers) ? findbot(Config.s_ChanServ) : (ci)->bi)
/**** chanserv.c ****/
diff --git a/include/services.h b/include/services.h
index 7483e591e..6a2c748c4 100644
--- a/include/services.h
+++ b/include/services.h
@@ -360,7 +360,6 @@ class Channel;
struct EList;
typedef struct bandata_ BanData;
-typedef struct userdata_ UserData;
typedef struct mailinfo_ MailInfo;
typedef struct akill_ Akill;
typedef struct sxline_ SXLine;
@@ -804,28 +803,6 @@ struct bandata_ {
int16 ttb[TTB_SIZE];
};
-/* This structure stocks information on every user that will be used by
- * BotServ. */
-
-struct userdata_ {
- /* Data validity */
- time_t last_use;
-
- /* for flood kicker */
- int16 lines;
- time_t last_start;
-
- /* for repeat kicker */
- char *lastline;
- int16 times;
-};
-
-struct c_userlist {
- struct c_userlist *next, *prev;
- User *user;
- UserData *ud;
-};
-
#include "channels.h"
/** Channelban type flags
diff --git a/include/users.h b/include/users.h
index 80bf33114..03dad2e55 100644
--- a/include/users.h
+++ b/include/users.h
@@ -9,12 +9,17 @@
*
*/
-struct u_chanlist {
- struct u_chanlist *next, *prev;
+struct ChannelContainer
+{
Channel *chan;
- int16 status; /* Associated flags; see CSTATUS_* below. */
+ int16 status;
+
+ ChannelContainer(Channel *c) : chan(c) { status = 0; }
+ virtual ~ChannelContainer() { }
};
+typedef std::list<ChannelContainer *> UChannelList;
+
/* Online user and channel data. */
class CoreExport User : public Extensible
{
@@ -44,7 +49,8 @@ class CoreExport User : public Extensible
int isSuperAdmin; /* is SuperAdmin on or off? */
- struct u_chanlist *chans; /* Channels user has joined */
+ /* Channels the user is in */
+ UChannelList chans;
unsigned short invalid_pw_count; /* # of invalid password attempts */
time_t invalid_pw_time; /* Time of last invalid password */
diff --git a/src/actions.c b/src/actions.c
index 142f2ae61..39c646cce 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -75,7 +75,6 @@ void sqline(const std::string &mask, const std::string &reason)
{
int i;
Channel *c, *next;
- struct c_userlist *cu, *cunext;
if (ircd->chansqline)
{
@@ -91,12 +90,14 @@ void sqline(const std::string &mask, const std::string &reason)
if (!Anope::Match(c->name, mask, false))
continue;
- for (cu = c->users; cu; cu = cunext)
+ for (CUserList::iterator it = c->users.begin(); it != c->users.end();)
{
- cunext = cu->next;
- if (is_oper(cu->user))
+ UserContainer *uc = *it;
+ ++it;
+
+ if (is_oper(uc->user))
continue;
- c->Kick(NULL, cu->user, "%s", reason.c_str());
+ c->Kick(NULL, uc->user, "%s", reason.c_str());
}
}
}
diff --git a/src/bots.cpp b/src/bots.cpp
index 58206963c..d19386abc 100644
--- a/src/bots.cpp
+++ b/src/bots.cpp
@@ -92,7 +92,7 @@ void BotInfo::RejoinAll()
for (i = 0; i < 256; ++i)
for (ci = chanlists[i]; ci; ci = ci->next)
- if (ci->bi == this && ci->c && (ci->c->usercount >= Config.BSMinUsers))
+ if (ci->bi == this && ci->c && (ci->c->users.size() >= Config.BSMinUsers))
bot_join(ci);
}
@@ -108,7 +108,7 @@ void BotInfo::Assign(User *u, ChannelInfo *ci)
ci->bi = this;
++this->chancount;
- if (ci->c && ci->c->usercount >= Config.BSMinUsers)
+ if (ci->c && ci->c->users.size() >= Config.BSMinUsers)
bot_join(ci);
}
@@ -119,7 +119,7 @@ void BotInfo::UnAssign(User *u, ChannelInfo *ci)
if (MOD_RESULT == EVENT_STOP)
return;
- if (ci->c && ci->c->usercount >= Config.BSMinUsers)
+ if (ci->c && ci->c->users.size() >= Config.BSMinUsers)
{
if (u)
ircdproto->SendPart(ci->bi, ci->c, "UNASSIGN from %s", u->nick.c_str());
diff --git a/src/botserv.c b/src/botserv.c
index 855797ef1..25bebaed3 100644
--- a/src/botserv.c
+++ b/src/botserv.c
@@ -572,38 +572,31 @@ static BanData *get_ban_data(Channel * c, User * u)
* Allocates it if necessary.
*/
-static UserData *get_user_data(Channel * c, User * u)
+static UserData *get_user_data(Channel *c, User *u)
{
- struct c_userlist *user;
-
if (!c || !u)
return NULL;
- for (user = c->users; user; user = user->next) {
- if (user->user == u) {
- if (user->ud) {
- time_t now = time(NULL);
-
- /* Checks whether data is obsolete */
- if (now - user->ud->last_use > Config.BSKeepData) {
- if (user->ud->lastline)
- delete [] user->ud->lastline;
- /* We should not free and realloc, but reset to 0
- instead. */
- memset(user->ud, 0, sizeof(UserData));
- user->ud->last_use = now;
- }
+ for (CUserList::iterator it = c->users.begin(); it != c->users.end(); ++it)
+ {
+ UserContainer *uc = *it;
- return user->ud;
- } else {
- user->ud = new UserData;
- user->ud->last_use = time(NULL);
- user->ud->lines = 0;
- user->ud->last_start = 0;
- user->ud->lastline = NULL;
- user->ud->times = 0;
- return user->ud;
+ if (uc->user == u)
+ {
+ time_t now = time(NULL);
+
+ /* Checks whether data is obsolete */
+ if (now - uc->ud->last_use > Config.BSKeepData)
+ {
+ if (uc->ud->lastline)
+ delete [] uc->ud->lastline;
+ /* We should not free and realloc, but reset to 0
+ instead. */
+ memset(uc->ud, 0, sizeof(UserData));
+ uc->ud->last_use = now;
}
+
+ return uc->ud;
}
}
@@ -646,7 +639,7 @@ void bot_join(ChannelInfo * ci)
/* Should we be invited? */
if (ci->c->HasMode(CMODE_INVITE)
- || (limit && ci->c->usercount >= limit))
+ || (limit && ci->c->users.size() >= limit))
ircdproto->SendNoticeChanops(ci->bi, ci->c,
"%s invited %s into the channel.",
ci->bi->nick.c_str(), ci->bi->nick.c_str());
diff --git a/src/channels.c b/src/channels.c
index 5f18ad4bb..f0c6e704e 100644
--- a/src/channels.c
+++ b/src/channels.c
@@ -44,8 +44,6 @@ Channel::Channel(const std::string &name, time_t ts)
this->creation_time = ts;
this->topic = NULL;
this->bans = this->excepts = this->invites = NULL;
- this->users = NULL;
- this->usercount = 0;
this->bd = NULL;
this->server_modetime = this->chanserv_modetime = 0;
this->server_modecount = this->chanserv_modecount = this->bouncy_modes = this->topic_sync = 0;
@@ -128,31 +126,14 @@ void Channel::Sync()
void Channel::JoinUser(User *user)
{
- struct u_chanlist *c;
-
if (debug)
alog("debug: %s joins %s", user->nick.c_str(), this->name.c_str());
- c = new u_chanlist;
- c->prev = NULL;
- c->next = user->chans;
- if (user->chans)
- user->chans->prev = c;
- user->chans = c;
- c->chan = this;
- c->status = 0;
-
- struct c_userlist *u;
-
- u = new c_userlist;
- u->prev = NULL;
- u->next = this->users;
- if (this->users)
- this->users->prev = u;
- this->users = u;
- u->user = user;
- u->ud = NULL;
- this->usercount++;
+ ChannelContainer *cc = new ChannelContainer(this);
+ user->chans.push_back(cc);
+
+ UserContainer *uc = new UserContainer(user);
+ this->users.push_back(uc);
if (get_ignore(user->nick.c_str()) == NULL)
{
@@ -178,12 +159,12 @@ void Channel::JoinUser(User *user)
**/
if (Config.s_BotServ && this->ci && this->ci->bi && !this->ci->HasFlag(CI_PERSIST))
{
- if (this->usercount == Config.BSMinUsers)
+ if (this->users.size() == Config.BSMinUsers)
bot_join(this->ci);
}
if (Config.s_BotServ && this->ci && this->ci->bi)
{
- if (this->usercount >= Config.BSMinUsers && (this->ci->botflags.HasFlag(BS_GREET))
+ if (this->users.size() >= Config.BSMinUsers && (this->ci->botflags.HasFlag(BS_GREET))
&& user->nc && user->nc->greet && check_access(user, this->ci, CA_GREET))
{
/* Only display the greet if the main uplink we're connected
@@ -207,26 +188,17 @@ void Channel::DeleteUser(User *user)
if (this->ci)
update_cs_lastseen(user, this->ci);
- struct c_userlist *u;
- for (u = this->users; u && u->user != user; u = u->next);
- if (!u)
- return;
-
- if (u->ud)
+ CUserList::iterator it;
+ for (it = this->users.begin(); (*it)->user != user && it != this->users.end(); ++it);
+ if (it == this->users.end())
{
- if (u->ud->lastline)
- delete [] u->ud->lastline;
- delete u->ud;
+ if (debug)
+ alog("debug: Channel::DelUser() tried to delete nonexistnat user %s from channel %s", user->nick.c_str(), this->name.c_str());
+ return;
}
- if (u->next)
- u->next->prev = u->prev;
- if (u->prev)
- u->prev->next = u->next;
- else
- this->users = u->next;
- delete u;
- this->usercount--;
+ delete *it;
+ this->users.erase(it);
/* Channel is persistant, it shouldn't be deleted and the service bot should stay */
if (this->HasFlag(CH_PERSIST) || (this->ci && this->ci->HasFlag(CI_PERSIST)))
@@ -242,10 +214,10 @@ void Channel::DeleteUser(User *user)
if (this->ci && this->ci->HasFlag(CI_INHABIT))
return;
- if (Config.s_BotServ && this->ci && this->ci->bi && this->usercount <= Config.BSMinUsers - 1)
+ if (Config.s_BotServ && this->ci && this->ci->bi && this->users.size() <= Config.BSMinUsers - 1)
ircdproto->SendPart(this->ci->bi, this, NULL);
- if (!this->users)
+ if (this->users.empty())
delete this;
}
@@ -463,13 +435,13 @@ void Channel::RemoveModeInternal(ChannelMode *cm, const std::string &param, bool
if (ci)
{
ci->UnsetFlag(CI_PERSIST);
- if (Config.s_BotServ && ci->bi && usercount == Config.BSMinUsers - 1)
+ if (Config.s_BotServ && ci->bi && users.size() == Config.BSMinUsers - 1)
ircdproto->SendPart(ci->bi, this, NULL);
}
}
/* We set -P in an empty channel, delete the channel */
- if (cm->Name == CMODE_PERM && !users)
+ if (cm->Name == CMODE_PERM && users.empty())
{
delete this;
return;
@@ -900,19 +872,16 @@ void Channel::KickInternal(const std::string &source, const std::string &nick, c
if (debug)
alog("debug: Channel::KickInternal kicking %s from %s", user->nick.c_str(), this->name.c_str());
- struct u_chanlist *c;
- for (c = user->chans; c && this != c->chan; c = c->next);
- if (c)
+ UChannelList::iterator it;
+ for (it = user->chans.begin(); (*it)->chan != this && it != user->chans.end(); ++it);
+ if (it != user->chans.end())
{
- FOREACH_MOD(I_OnUserKicked, OnUserKicked(c->chan, user, source, reason));
- c->chan->DeleteUser(user);
- if (c->next)
- c->next->prev = c->prev;
- if (c->prev)
- c->prev->next = c->next;
- else
- user->chans = c->next;
- delete c;
+ ChannelContainer *cc = *it;
+
+ FOREACH_MOD(I_OnUserKicked, OnUserKicked(cc->chan, user, source, reason));
+ cc->chan->DeleteUser(user);
+ delete cc;
+ user->chans.erase(it);
}
else if (debug)
alog("debug: Channel::KickInternal got kick for user %s who isn't on channel %s ?", user->nick.c_str(), this->name.c_str());
@@ -959,7 +928,7 @@ char *chan_get_modes(Channel * chan, int complete, int plus)
ChannelModeParam *cmp;
std::map<char, ChannelMode *>::iterator it;
- if (!chan->modes.count())
+ if (chan->HasModes())
{
for (it = ModeManager::ChannelModesByChar.begin(); it != ModeManager::ChannelModesByChar.end(); ++it)
{
@@ -1009,11 +978,9 @@ char *chan_get_modes(Channel * chan, int complete, int plus)
int chan_get_user_status(Channel * chan, User * user)
{
- struct u_chanlist *uc;
-
- for (uc = user->chans; uc; uc = uc->next)
- if (uc->chan == chan)
- return uc->status;
+ for (UChannelList::iterator it = user->chans.begin(); it != user->chans.end(); ++it)
+ if ((*it)->chan == chan)
+ return (*it)->status;
return 0;
}
@@ -1024,14 +991,15 @@ int chan_get_user_status(Channel * chan, User * user)
int chan_has_user_status(Channel * chan, User * user, int16 status)
{
- struct u_chanlist *uc;
+ for (UChannelList::iterator it = user->chans.begin(); it != user->chans.end(); ++it)
+ {
+ ChannelContainer *cc = *it;
- for (uc = user->chans; uc; uc = uc->next) {
- if (uc->chan == chan) {
- if (debug) {
- alog("debug: chan_has_user_status wanted %d the user is %d", status, uc->status);
- }
- return (uc->status & status);
+ if (cc->chan == chan)
+ {
+ if (debug)
+ alog("debug: chan_has_user_status wanted %d the user is %d", status, cc->status);
+ return (cc->status & status);
}
}
return 0;
@@ -1043,15 +1011,17 @@ int chan_has_user_status(Channel * chan, User * user, int16 status)
void chan_remove_user_status(Channel * chan, User * user, int16 status)
{
- struct u_chanlist *uc;
-
if (debug >= 2)
alog("debug: removing user status (%d) from %s for %s", status,
user->nick.c_str(), chan->name.c_str());
- for (uc = user->chans; uc; uc = uc->next) {
- if (uc->chan == chan) {
- uc->status &= ~status;
+ for (UChannelList::iterator it = user->chans.begin(); it != user->chans.end(); ++it)
+ {
+ ChannelContainer *cc = *it;
+
+ if (cc->chan == chan)
+ {
+ cc->status &= ~status;
break;
}
}
@@ -1063,7 +1033,6 @@ void chan_remove_user_status(Channel * chan, User * user, int16 status)
void chan_set_user_status(Channel * chan, User * user, int16 status)
{
- struct u_chanlist *uc;
UserMode *um;
if (debug >= 2)
@@ -1081,9 +1050,13 @@ void chan_set_user_status(Channel * chan, User * user, int16 status)
user->SetMode(NULL, um);
}
- for (uc = user->chans; uc; uc = uc->next) {
- if (uc->chan == chan) {
- uc->status |= status;
+ for (UChannelList::iterator it = user->chans.begin(); it != user->chans.end(); ++it)
+ {
+ ChannelContainer *cc = *it;
+
+ if (cc->chan == chan)
+ {
+ cc->status |= status;
break;
}
}
@@ -1164,7 +1137,6 @@ void get_channel_stats(long *nrec, long *memuse)
{
long count = 0, mem = 0;
Channel *chan;
- struct c_userlist *cu;
BanData *bd;
int i;
std::string buf;
@@ -1186,13 +1158,12 @@ void get_channel_stats(long *nrec, long *memuse)
mem += get_memuse(chan->excepts);
if (ModeManager::FindChannelModeByName(CMODE_INVITEOVERRIDE))
mem += get_memuse(chan->invites);
- for (cu = chan->users; cu; cu = cu->next) {
- mem += sizeof(*cu);
- if (cu->ud) {
- mem += sizeof(*cu->ud);
- if (cu->ud->lastline)
- mem += strlen(cu->ud->lastline) + 1;
- }
+ for (CUserList::iterator it = chan->users.begin(); it != chan->users.end(); ++it)
+ {
+ mem += sizeof(*it);
+ mem += sizeof((*it)->ud);
+ if ((*it)->ud->lastline)
+ mem += strlen((*it)->ud->lastline) + 1;
}
for (bd = chan->bd; bd; bd = bd->next) {
if (bd->mask)
@@ -1211,10 +1182,8 @@ void get_channel_stats(long *nrec, long *memuse)
int is_on_chan(Channel * c, User * u)
{
- struct u_chanlist *uc;
-
- for (uc = u->chans; uc; uc = uc->next)
- if (uc->chan == c)
+ for (UChannelList::iterator it = u->chans.begin(); it != u->chans.end(); ++it)
+ if ((*it)->chan == c)
return 1;
return 0;
@@ -1227,14 +1196,15 @@ int is_on_chan(Channel * c, User * u)
User *nc_on_chan(Channel * c, NickCore * nc)
{
- struct c_userlist *u;
-
if (!c || !nc)
return NULL;
- for (u = c->users; u; u = u->next) {
- if (u->user->nc == nc)
- return u->user;
+ for (CUserList::iterator it = c->users.begin(); it != c->users.end(); ++it)
+ {
+ UserContainer *uc = *it;
+
+ if (uc->user->nc == nc)
+ return uc->user;
}
return NULL;
}
@@ -1251,17 +1221,9 @@ void do_join(const char *source, int ac, const char **av)
{
User *user;
Channel *chan;
- struct u_chanlist *c, *nextc;
- char *channame;
time_t ctime = time(NULL);
- if (ircd->ts6) {
- user = find_byuid(source);
- if (!user)
- user = finduser(source);
- } else {
- user = finduser(source);
- }
+ user = finduser(source);
if (!user) {
if (debug) {
alog("debug: JOIN from nonexistent user %s: %s", source,
@@ -1275,18 +1237,18 @@ void do_join(const char *source, int ac, const char **av)
while (sep.GetToken(buf))
{
if (buf[0] == '0') {
- c = user->chans;
- while (c) {
- nextc = c->next;
- channame = sstrdup(c->chan->name.c_str());
- FOREACH_MOD(I_OnPrePartChannel, OnPrePartChannel(user, c->chan));
- c->chan->DeleteUser(user);
- FOREACH_MOD(I_OnPartChannel, OnPartChannel(user, findchan(channame), channame, ""));
- delete [] channame;
- delete c;
- c = nextc;
+ for (UChannelList::iterator it = user->chans.begin(); it != user->chans.end();)
+ {
+ ChannelContainer *cc = *it++;
+
+ std::string channame = cc->chan->name;
+ FOREACH_MOD(I_OnPrePartChannel, OnPrePartChannel(user, cc->chan));
+ cc->chan->DeleteUser(user);
+ FOREACH_MOD(I_OnPartChannel, OnPartChannel(user, findchan(channame.c_str()), channame, ""));
+ delete cc;
+ user->chans.erase(it);
}
- user->chans = NULL;
+ user->chans.clear();
continue;
}
@@ -1377,15 +1339,8 @@ void do_kick(const std::string &source, int ac, const char **av)
void do_part(const char *source, int ac, const char **av)
{
User *user;
- struct u_chanlist *c;
- if (ircd->ts6) {
- user = find_byuid(source);
- if (!user)
- user = finduser(source);
- } else {
- user = finduser(source);
- }
+ user = finduser(source);
if (!user) {
if (debug) {
alog("debug: PART from nonexistent user %s: %s", source,
@@ -1400,29 +1355,21 @@ void do_part(const char *source, int ac, const char **av)
{
if (debug)
alog("debug: %s leaves %s", source, buf.c_str());
- for (c = user->chans; c && buf != c->chan->name; c = c->next);
- if (c)
+ UChannelList::iterator it;
+ for (it = user->chans.begin(); buf != (*it)->chan->name && it != user->chans.end(); ++it);
+ if (it != user->chans.end())
{
- if (!c->chan)
- {
- alog("user: BUG parting %s: channel entry found but c->chan NULL", buf.c_str());
- return;
- }
+ ChannelContainer *cc = *it;
- FOREACH_MOD(I_OnPrePartChannel, OnPrePartChannel(user, c->chan));
- std::string ChannelName = c->chan->name;
+ FOREACH_MOD(I_OnPrePartChannel, OnPrePartChannel(user, cc->chan));
+ std::string ChannelName = cc->chan->name;
- c->chan->DeleteUser(user);
+ cc->chan->DeleteUser(user);
- FOREACH_MOD(I_OnPartChannel, OnPartChannel(user, findchan(ChannelName.c_str()), ChannelName, av[1] ? av[1] : ""));
+ delete *it;
+ user->chans.erase(it);
- if (c->next)
- c->next->prev = c->prev;
- if (c->prev)
- c->prev->next = c->next;
- else
- user->chans = c->next;
- delete c;
+ FOREACH_MOD(I_OnPartChannel, OnPartChannel(user, findchan(ChannelName.c_str()), ChannelName, av[1] ? av[1] : ""));
}
}
}
@@ -1636,7 +1583,7 @@ void chan_set_correct_modes(User * user, Channel * c, int give_modes)
* Unless the channel has just been created. -heinz
* Or the user matches CA_AUTODEOP... -GD
*/
- if (((ci->HasFlag(CI_SECUREOPS)) || (c->usercount == 1)
+ if (((ci->HasFlag(CI_SECUREOPS)) || (c->users.size() == 1)
|| check_access(user, ci, CA_AUTODEOP))
&& !is_ulined(user->server->name)) {
if (owner && (status & CUS_OWNER) && !IsFounder(user, ci))
diff --git a/src/chanserv.c b/src/chanserv.c
index af458e42b..56a94839c 100644
--- a/src/chanserv.c
+++ b/src/chanserv.c
@@ -142,7 +142,7 @@ class ChanServTimer : public Timer
c->ci->UnsetFlag(CI_INHABIT);
/* If the channel has users again, don't part it and halt */
- if (c->usercount)
+ if (!c->users.empty())
return;
if (c->ci->bi)
@@ -697,7 +697,7 @@ bool ChannelInfo::CheckKick(User *user)
/* If the channel doesnt have any users and if a bot isn't already in the channel, join it
* NOTE: we use usercount == 1 here as there is one user, but they are about to be destroyed
*/
- if (this->c->usercount == 1 && !this->HasFlag(CI_INHABIT))
+ if (this->c->users.size() == 1 && !this->HasFlag(CI_INHABIT))
{
/* If channel was forbidden, etc, set it +si to prevent rejoin */
if (set_modes)
diff --git a/src/core/bs_act.c b/src/core/bs_act.c
index 8c54f9479..7849f322b 100644
--- a/src/core/bs_act.c
+++ b/src/core/bs_act.c
@@ -39,7 +39,7 @@ class CommandBSAct : public Command
return MOD_CONT;
}
- if (!ci->c || ci->c->usercount < Config.BSMinUsers)
+ if (!ci->c || ci->c->users.size() < Config.BSMinUsers)
{
notice_lang(Config.s_BotServ, u, BOT_NOT_ON_CHANNEL, ci->name.c_str());
return MOD_CONT;
diff --git a/src/core/bs_say.c b/src/core/bs_say.c
index 6aa2bb552..65fd93922 100644
--- a/src/core/bs_say.c
+++ b/src/core/bs_say.c
@@ -43,7 +43,7 @@ class CommandBSSay : public Command
return MOD_CONT;
}
- if (!ci->c || ci->c->usercount < Config.BSMinUsers)
+ if (!ci->c || ci->c->users.size() < Config.BSMinUsers)
{
notice_lang(Config.s_BotServ, u, BOT_NOT_ON_CHANNEL, ci->name.c_str());
return MOD_CONT;
diff --git a/src/core/cs_akick.c b/src/core/cs_akick.c
index 983dba89f..2a45cd83c 100644
--- a/src/core/cs_akick.c
+++ b/src/core/cs_akick.c
@@ -480,7 +480,6 @@ class CommandCSAKick : public Command
void DoEnforce(User *u, ChannelInfo *ci, const std::vector<ci::string> &params)
{
Channel *c = ci->c;
- c_userlist *cu, *unext;
int count = 0;
if (!c)
@@ -489,17 +488,14 @@ class CommandCSAKick : public Command
return;
}
- cu = c->users;
-
- while (cu)
+ for (CUserList::iterator it = c->users.begin(); it != c->users.end();)
{
- unext = cu->next;
- if (ci->CheckKick(cu->user))
+ UserContainer *uc = *it++;
+
+ if (ci->CheckKick(uc->user))
{
- c->Kick(NULL, cu->user, "%s", Config.CSAutokickReason);
count++;
}
- cu = unext;
}
notice_lang(Config.s_ChanServ, u, CHAN_AKICK_ENFORCE_DONE, ci->name.c_str(), count);
diff --git a/src/core/cs_clear.c b/src/core/cs_clear.c
index 0cbb192e3..5f95e0cdc 100644
--- a/src/core/cs_clear.c
+++ b/src/core/cs_clear.c
@@ -38,127 +38,144 @@ class CommandCSClear : public Command
if (c)
ci = c->ci;
- if (!c) {
+ if (!c)
notice_lang(Config.s_ChanServ, u, CHAN_X_NOT_IN_USE, chan);
- } else if (!u || !check_access(u, ci, CA_CLEAR)) {
+ else if (!u || !check_access(u, ci, CA_CLEAR))
notice_lang(Config.s_ChanServ, u, ACCESS_DENIED);
- } else if (what == "bans") {
+ else if (what == "bans")
+ {
c->ClearBans();
notice_lang(Config.s_ChanServ, u, CHAN_CLEARED_BANS, chan);
- } else if (ModeManager::FindChannelModeByName(CMODE_EXCEPT) && what == "excepts") {
+ }
+ else if (ModeManager::FindChannelModeByName(CMODE_EXCEPT) && what == "excepts")
+ {
c->ClearExcepts();
notice_lang(Config.s_ChanServ, u, CHAN_CLEARED_EXCEPTS, chan);
- } else if (ModeManager::FindChannelModeByName(CMODE_INVITE) && what == "invites") {
+ }
+ else if (ModeManager::FindChannelModeByName(CMODE_INVITE) && what == "invites")
+ {
c->ClearInvites();
notice_lang(Config.s_ChanServ, u, CHAN_CLEARED_INVITES, chan);
- } else if (what == "modes") {
+ }
+ else if (what == "modes")
+ {
c->ClearModes();
check_modes(c);
notice_lang(Config.s_ChanServ, u, CHAN_CLEARED_MODES, chan);
- } else if (what == "ops") {
- const char *av[6]; /* The max we have to hold: chan, ts, modes(max3), nick, nick, nick */
+ }
+ else if (what == "ops")
+ {
int isop, isadmin, isown;
- struct c_userlist *cu, *bnext;
- if (ircd->svsmode_ucmode) {
- av[0] = chan;
+ if (ircd->svsmode_ucmode)
+ {
ircdproto->SendSVSModeChan(c, "-o", NULL);
- if (owner) {
+ if (owner)