summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2012-12-28 10:37:54 -0500
committerAdam <Adam@anope.org>2012-12-28 10:43:30 -0500
commitb591e8cdc8b1bc40a6a59b54dcb6266d9656b616 (patch)
tree2a31259930d9915d9248a29dc5b97006620675a2
parent379b2ccf92b6124f2026a5ec683cfc98f08e223a (diff)
Use the same object for chanusercontainer and userchancontainer
-rw-r--r--include/channels.h17
-rw-r--r--include/users.h17
-rw-r--r--modules/commands/bs_kick.cpp6
-rw-r--r--modules/commands/cs_access.cpp4
-rw-r--r--modules/commands/cs_akick.cpp4
-rw-r--r--modules/commands/cs_ban.cpp4
-rw-r--r--modules/commands/cs_enforce.cpp12
-rw-r--r--modules/commands/cs_kick.cpp4
-rw-r--r--modules/commands/cs_mode.cpp4
-rw-r--r--modules/commands/cs_modes.cpp2
-rw-r--r--modules/commands/cs_suspend.cpp4
-rw-r--r--modules/commands/cs_sync.cpp2
-rw-r--r--modules/commands/cs_updown.cpp4
-rw-r--r--modules/commands/ns_recover.cpp4
-rw-r--r--modules/commands/os_chankill.cpp4
-rw-r--r--modules/commands/os_list.cpp8
-rw-r--r--modules/commands/os_sxline.cpp4
-rw-r--r--modules/extra/cs_statusupdate.cpp4
-rw-r--r--modules/extra/m_xmlrpc_main.cpp12
-rw-r--r--modules/protocol/bahamut.cpp4
-rw-r--r--modules/protocol/hybrid.cpp4
-rw-r--r--modules/protocol/inspircd11.cpp4
-rw-r--r--modules/protocol/inspircd12.cpp4
-rw-r--r--modules/protocol/inspircd20.cpp4
-rw-r--r--modules/protocol/ngircd.cpp4
-rw-r--r--modules/protocol/plexus.cpp4
-rw-r--r--modules/protocol/unreal.cpp8
-rw-r--r--modules/pseudoclients/memoserv.cpp4
-rw-r--r--modules/pseudoclients/nickserv.cpp8
-rw-r--r--src/channels.cpp60
-rw-r--r--src/messages.cpp13
-rw-r--r--src/servers.cpp4
-rw-r--r--src/users.cpp4
33 files changed, 116 insertions, 133 deletions
diff --git a/include/channels.h b/include/channels.h
index 5cbea5ecc..b8801ff07 100644
--- a/include/channels.h
+++ b/include/channels.h
@@ -20,18 +20,16 @@ typedef Anope::hash_map<Channel *> channel_map;
extern CoreExport channel_map ChannelList;
/* A user container, there is one of these per user per channel. */
-struct UserContainer : public Extensible
+struct ChanUserContainer : public Extensible
{
User *user;
+ Channel *chan;
/* Status the user has in the channel */
- ChannelStatus *status;
+ ChannelStatus status;
- UserContainer(User *u) : user(u) { }
- virtual ~UserContainer() { }
+ ChanUserContainer(User *u, Channel *c) : user(u), chan(c) { }
};
-typedef std::list<UserContainer *> CUserList;
-
enum ChannelFlag
{
/* ChanServ is currently holding the channel */
@@ -60,7 +58,8 @@ class CoreExport Channel : public Base, public Extensible, public Flags<ChannelF
time_t creation_time;
/* Users in the channel */
- CUserList users;
+ typedef std::list<ChanUserContainer *> ChanUserList;
+ ChanUserList users;
/* Current topic of the channel */
Anope::string topic;
@@ -107,7 +106,7 @@ class CoreExport Channel : public Base, public Extensible, public Flags<ChannelF
* @param u The user
* @return The UserContainer for the user
*/
- UserContainer* JoinUser(User *u);
+ ChanUserContainer* JoinUser(User *u);
/** Remove a user internally from the channel
* @param u The user
@@ -118,7 +117,7 @@ class CoreExport Channel : public Base, public Extensible, public Flags<ChannelF
* @param u The user
* @return A user container if found, else NULL
*/
- UserContainer *FindUser(const User *u) const;
+ ChanUserContainer *FindUser(const User *u) const;
/** Check if a user has a status on a channel
* @param u The user
diff --git a/include/users.h b/include/users.h
index ab7edeee3..87a18ed3f 100644
--- a/include/users.h
+++ b/include/users.h
@@ -29,18 +29,6 @@ extern CoreExport int OperCount;
extern CoreExport unsigned MaxUserCount;
extern CoreExport time_t MaxUserTime;
-/* One per channel per user. Channel and status */
-struct ChannelContainer
-{
- Channel *chan;
- ChannelStatus *status;
-
- ChannelContainer(Channel *c) : chan(c) { }
- virtual ~ChannelContainer() { }
-};
-
-typedef std::list<ChannelContainer *> UChannelList;
-
/* Online user and channel data. */
class CoreExport User : public virtual Base, public Extensible, public CommandReply
{
@@ -89,7 +77,8 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe
bool super_admin;
/* Channels the user is in */
- UChannelList chans;
+ typedef std::list<ChanUserContainer *> ChanUserList;
+ ChanUserList chans;
/* Last time this user sent a memo command used */
time_t lastmemosend;
@@ -319,7 +308,7 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe
* @param c The channel
* @return The channel container, or NULL
*/
- ChannelContainer *FindChannel(const Channel *c) const;
+ ChanUserContainer *FindChannel(const Channel *c) const;
/** Check if the user is protected from kicks and negative mode changes
* @return true or false
diff --git a/modules/commands/bs_kick.cpp b/modules/commands/bs_kick.cpp
index 3e569696e..bb6cf9179 100644
--- a/modules/commands/bs_kick.cpp
+++ b/modules/commands/bs_kick.cpp
@@ -708,7 +708,7 @@ class BSKick : public Module
UserData *GetUserData(User *u, Channel *c)
{
- UserContainer *uc = c->FindUser(u);
+ ChanUserContainer *uc = c->FindUser(u);
if (uc == NULL)
return NULL;
@@ -776,7 +776,7 @@ class BSKick : public Module
for (channel_map::const_iterator cit = ChannelList.begin(), cit_end = ChannelList.end(); cit != cit_end; ++cit)
{
Channel *c = cit->second;
- for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it)
+ for (Channel::ChanUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it)
(*it)->Shrink("bs_main_userdata");
c->Shrink("bs_main_bandata");
}
@@ -1004,7 +1004,7 @@ class BSKick : public Module
if (ud->lastline.equals_ci(realbuf) && !ud->lasttarget.empty() && !ud->lasttarget.equals_ci(ci->name))
{
- for (UChannelList::iterator it = u->chans.begin(); it != u->chans.end();)
+ for (User::ChanUserList::iterator it = u->chans.begin(); it != u->chans.end();)
{
Channel *chan = (*it)->chan;
++it;
diff --git a/modules/commands/cs_access.cpp b/modules/commands/cs_access.cpp
index ed6f4f7fa..adf49a037 100644
--- a/modules/commands/cs_access.cpp
+++ b/modules/commands/cs_access.cpp
@@ -325,7 +325,7 @@ class CommandCSAccess : public Command
Anope::string timebuf;
if (ci->c)
- for (CUserList::const_iterator cit = ci->c->users.begin(), cit_end = ci->c->users.end(); cit != cit_end; ++cit)
+ for (Channel::ChanUserList::const_iterator cit = ci->c->users.begin(), cit_end = ci->c->users.end(); cit != cit_end; ++cit)
if (access->Matches((*cit)->user, (*cit)->user->Account()))
timebuf = "Now";
if (timebuf.empty())
@@ -359,7 +359,7 @@ class CommandCSAccess : public Command
Anope::string timebuf;
if (ci->c)
- for (CUserList::const_iterator cit = ci->c->users.begin(), cit_end = ci->c->users.end(); cit != cit_end; ++cit)
+ for (Channel::ChanUserList::const_iterator cit = ci->c->users.begin(), cit_end = ci->c->users.end(); cit != cit_end; ++cit)
if (access->Matches((*cit)->user, (*cit)->user->Account()))
timebuf = "Now";
if (timebuf.empty())
diff --git a/modules/commands/cs_akick.cpp b/modules/commands/cs_akick.cpp
index 9447b1aed..52d0ecd76 100644
--- a/modules/commands/cs_akick.cpp
+++ b/modules/commands/cs_akick.cpp
@@ -378,9 +378,9 @@ class CommandCSAKick : public Command
return;
}
- for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; )
+ for (User::ChanUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; )
{
- UserContainer *uc = *it++;
+ ChanUserContainer *uc = *it++;
if (ci->CheckKick(uc->user))
++count;
diff --git a/modules/commands/cs_ban.cpp b/modules/commands/cs_ban.cpp
index 0b8959a15..3b4ae9be0 100644
--- a/modules/commands/cs_ban.cpp
+++ b/modules/commands/cs_ban.cpp
@@ -148,9 +148,9 @@ class CommandCSBan : public Command
}
int matched = 0, kicked = 0;
- for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end;)
+ for (Channel::ChanUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end;)
{
- UserContainer *uc = *it++;
+ ChanUserContainer *uc = *it++;
if (Anope::Match(uc->user->nick, target) || Anope::Match(uc->user->GetDisplayedMask(), target))
{
diff --git a/modules/commands/cs_enforce.cpp b/modules/commands/cs_enforce.cpp
index 4622af04b..fce056994 100644
--- a/modules/commands/cs_enforce.cpp
+++ b/modules/commands/cs_enforce.cpp
@@ -62,9 +62,9 @@ class CommandCSEnforce : public Command
hadsecureops = true;
}
- for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it)
+ for (Channel::ChanUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it)
{
- UserContainer *uc = *it;
+ ChanUserContainer *uc = *it;
c->SetCorrectModes(uc->user, false, false);
}
@@ -82,9 +82,9 @@ class CommandCSEnforce : public Command
Log(LOG_COMMAND, source, this) << "to enforce restricted";
std::vector<User *> users;
- for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it)
+ for (Channel::ChanUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it)
{
- UserContainer *uc = *it;
+ ChanUserContainer *uc = *it;
User *user = uc->user;
if (ci->AccessFor(user).empty())
@@ -112,9 +112,9 @@ class CommandCSEnforce : public Command
Log(LOG_COMMAND, source, this) << "to enforce registered only";
std::vector<User *> users;
- for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it)
+ for (Channel::ChanUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it)
{
- UserContainer *uc = *it;
+ ChanUserContainer *uc = *it;
User *user = uc->user;
if (!user->IsIdentified())
diff --git a/modules/commands/cs_kick.cpp b/modules/commands/cs_kick.cpp
index e02ab5185..d832951c1 100644
--- a/modules/commands/cs_kick.cpp
+++ b/modules/commands/cs_kick.cpp
@@ -77,9 +77,9 @@ class CommandCSKick : public Command
Log(LOG_COMMAND, source, this, ci) << "for " << target;
int matched = 0, kicked = 0;
- for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end;)
+ for (Channel::ChanUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end;)
{
- UserContainer *uc = *it++;
+ ChanUserContainer *uc = *it++;
if (Anope::Match(uc->user->nick, target) || Anope::Match(uc->user->GetDisplayedMask(), target))
{
diff --git a/modules/commands/cs_mode.cpp b/modules/commands/cs_mode.cpp
index c33b317a2..6bfbd0da4 100644
--- a/modules/commands/cs_mode.cpp
+++ b/modules/commands/cs_mode.cpp
@@ -265,9 +265,9 @@ class CommandCSMode : public Command
if (param.find_first_of("*?") != Anope::string::npos)
{
- for (CUserList::const_iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
+ for (Channel::ChanUserList::const_iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
{
- UserContainer *uc = *it;
+ ChanUserContainer *uc = *it;
AccessGroup targ_access = ci->AccessFor(uc->user);
diff --git a/modules/commands/cs_modes.cpp b/modules/commands/cs_modes.cpp
index 696c38dde..26783c531 100644
--- a/modules/commands/cs_modes.cpp
+++ b/modules/commands/cs_modes.cpp
@@ -79,7 +79,7 @@ class CommandModeBase : public Command
User *u = source.GetUser();
if (chan.empty() && u)
- for (UChannelList::iterator it = u->chans.begin(); it != u->chans.end(); ++it)
+ for (User::ChanUserList::iterator it = u->chans.begin(); it != u->chans.end(); ++it)
do_mode(source, com, cm, (*it)->chan->name, u->nick, set, level, levelself);
else if (!chan.empty())
do_mode(source, com, cm, chan, !nick.empty() ? nick : u->nick, set, level, levelself);
diff --git a/modules/commands/cs_suspend.cpp b/modules/commands/cs_suspend.cpp
index 097de1823..4f840f576 100644
--- a/modules/commands/cs_suspend.cpp
+++ b/modules/commands/cs_suspend.cpp
@@ -104,9 +104,9 @@ class CommandCSSuspend : public Command
{
std::vector<User *> users;
- for (CUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
+ for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
{
- UserContainer *uc = *it;
+ ChanUserContainer *uc = *it;
User *user = uc->user;
if (!user->HasMode(UMODE_OPER) && user->server != Me)
users.push_back(user);
diff --git a/modules/commands/cs_sync.cpp b/modules/commands/cs_sync.cpp
index 23d6928a1..03cf03672 100644
--- a/modules/commands/cs_sync.cpp
+++ b/modules/commands/cs_sync.cpp
@@ -34,7 +34,7 @@ class CommandCSSync : public Command
{
Log(LOG_COMMAND, source, this, ci);
- for (CUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
+ for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
ci->c->SetCorrectModes((*it)->user, true, false);
source.Reply(_("All user modes on \002%s\002 have been synced."), ci->name.c_str());
diff --git a/modules/commands/cs_updown.cpp b/modules/commands/cs_updown.cpp
index 7504c3601..28a495e50 100644
--- a/modules/commands/cs_updown.cpp
+++ b/modules/commands/cs_updown.cpp
@@ -28,7 +28,7 @@ class CommandCSUp : public Command
User *u = source.GetUser();
if (params.empty())
- for (UChannelList::iterator it = u->chans.begin(); it != u->chans.end(); ++it)
+ for (User::ChanUserList::iterator it = u->chans.begin(); it != u->chans.end(); ++it)
{
Channel *c = (*it)->chan;
c->SetCorrectModes(u, true, false);
@@ -84,7 +84,7 @@ class CommandCSDown : public Command
User *u = source.GetUser();
if (params.empty())
- for (UChannelList::iterator it = u->chans.begin(); it != u->chans.end(); ++it)
+ for (User::ChanUserList::iterator it = u->chans.begin(); it != u->chans.end(); ++it)
{
Channel *c = (*it)->chan;
RemoveAll(u, c);
diff --git a/modules/commands/ns_recover.cpp b/modules/commands/ns_recover.cpp
index ed258c4e4..edd8ec48f 100644
--- a/modules/commands/ns_recover.cpp
+++ b/modules/commands/ns_recover.cpp
@@ -61,8 +61,8 @@ class NSRecoverRequest : public IdentifyRequest
if (!u->chans.empty())
{
NSRecoverExtensibleInfo *ei = new NSRecoverExtensibleInfo;
- for (UChannelList::iterator it = u->chans.begin(), it_end = u->chans.end(); it != it_end; ++it)
- (*ei)[(*it)->chan->name] = *(*it)->status;
+ for (User::ChanUserList::iterator it = u->chans.begin(), it_end = u->chans.end(); it != it_end; ++it)
+ (*ei)[(*it)->chan->name] = (*it)->status;
source.GetUser()->Extend("ns_recover_info", ei);
}
diff --git a/modules/commands/os_chankill.cpp b/modules/commands/os_chankill.cpp
index c1d71831b..fc3dd6181 100644
--- a/modules/commands/os_chankill.cpp
+++ b/modules/commands/os_chankill.cpp
@@ -72,9 +72,9 @@ class CommandOSChanKill : public Command
if ((c = Channel::Find(channel)))
{
- for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; )
+ for (Channel::ChanUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; )
{
- UserContainer *uc = *it++;
+ ChanUserContainer *uc = *it++;
if (uc->user->server == Me || uc->user->HasMode(UMODE_OPER))
continue;
diff --git a/modules/commands/os_list.cpp b/modules/commands/os_list.cpp
index dfb0c00c8..82523d24a 100644
--- a/modules/commands/os_list.cpp
+++ b/modules/commands/os_list.cpp
@@ -42,9 +42,9 @@ class CommandOSChanList : public Command
{
source.Reply(_("\002%s\002 channel list:"), u2->nick.c_str());
- for (UChannelList::iterator uit = u2->chans.begin(), uit_end = u2->chans.end(); uit != uit_end; ++uit)
+ for (User::ChanUserList::iterator uit = u2->chans.begin(), uit_end = u2->chans.end(); uit != uit_end; ++uit)
{
- ChannelContainer *cc = *uit;
+ ChanUserContainer *cc = *uit;
if (!Modes.empty())
for (std::list<ChannelModeName>::iterator it = Modes.begin(), it_end = Modes.end(); it != it_end; ++it)
@@ -136,9 +136,9 @@ class CommandOSUserList : public Command
{
source.Reply(_("\002%s\002 users list:"), pattern.c_str());
- for (CUserList::iterator cuit = c->users.begin(), cuit_end = c->users.end(); cuit != cuit_end; ++cuit)
+ for (Channel::ChanUserList::iterator cuit = c->users.begin(), cuit_end = c->users.end(); cuit != cuit_end; ++cuit)
{
- UserContainer *uc = *cuit;
+ ChanUserContainer *uc = *cuit;
if (!Modes.empty())
for (std::list<UserModeName>::iterator it = Modes.begin(), it_end = Modes.end(); it != it_end; ++it)
diff --git a/modules/commands/os_sxline.cpp b/modules/commands/os_sxline.cpp
index 7f48a2645..0fff4b3f0 100644
--- a/modules/commands/os_sxline.cpp
+++ b/modules/commands/os_sxline.cpp
@@ -596,9 +596,9 @@ class CommandOSSQLine : public CommandOSSXLineBase
continue;
std::vector<User *> users;
- for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it)
+ for (Channel::ChanUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it)
{
- UserContainer *uc = *it;
+ ChanUserContainer *uc = *it;
User *user = uc->user;
if (!user->HasMode(UMODE_OPER) && user->server != Me)
diff --git a/modules/extra/cs_statusupdate.cpp b/modules/extra/cs_statusupdate.cpp
index 41ea8833e..4f789156e 100644
--- a/modules/extra/cs_statusupdate.cpp
+++ b/modules/extra/cs_statusupdate.cpp
@@ -34,7 +34,7 @@ class StatusUpdate : public Module
void OnAccessAdd(ChannelInfo *ci, CommandSource &, ChanAccess *access) anope_override
{
if (ci->c)
- for (CUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
+ for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
{
User *user = (*it)->user;
@@ -51,7 +51,7 @@ class StatusUpdate : public Module
void OnAccessDel(ChannelInfo *ci, CommandSource &, ChanAccess *access) anope_override
{
if (ci->c)
- for (CUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
+ for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
{
User *user = (*it)->user;
diff --git a/modules/extra/m_xmlrpc_main.cpp b/modules/extra/m_xmlrpc_main.cpp
index 672ef5524..807aa626b 100644
--- a/modules/extra/m_xmlrpc_main.cpp
+++ b/modules/extra/m_xmlrpc_main.cpp
@@ -172,10 +172,10 @@ class MyXMLRPCEvent : public XMLRPCEvent
request.reply("invite" + stringify(++count), iface->Sanitize(its.first->second));
Anope::string users;
- for (CUserList::const_iterator it = c->users.begin(); it != c->users.end(); ++it)
+ for (Channel::ChanUserList::const_iterator it = c->users.begin(); it != c->users.end(); ++it)
{
- UserContainer *uc = *it;
- users += uc->status->BuildModePrefixList() + uc->user->nick + " ";
+ ChanUserContainer *uc = *it;
+ users += uc->status.BuildModePrefixList() + uc->user->nick + " ";
}
if (!users.empty())
{
@@ -224,10 +224,10 @@ class MyXMLRPCEvent : public XMLRPCEvent
}
Anope::string channels;
- for (UChannelList::const_iterator it = u->chans.begin(); it != u->chans.end(); ++it)
+ for (User::ChanUserList::const_iterator it = u->chans.begin(); it != u->chans.end(); ++it)
{
- ChannelContainer *cc = *it;
- channels += cc->status->BuildModePrefixList() + cc->chan->name + " ";
+ ChanUserContainer *cc = *it;
+ channels += cc->status.BuildModePrefixList() + cc->chan->name + " ";
}
if (!channels.empty())
{
diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp
index 166ada3bb..22a59ebce 100644
--- a/modules/protocol/bahamut.cpp
+++ b/modules/protocol/bahamut.cpp
@@ -180,9 +180,9 @@ class BahamutIRCdProto : public IRCDProto
/* If the user is internally on the channel with flags, kill them so that
* the stacker will allow this.
*/
- UserContainer *uc = c->FindUser(user);
+ ChanUserContainer *uc = c->FindUser(user);
if (uc != NULL)
- uc->status->ClearFlags();
+ uc->status.ClearFlags();
BotInfo *setter = BotInfo::Find(user->nick);
for (unsigned i = 0; i < ModeManager::ChannelModes.size(); ++i)
diff --git a/modules/protocol/hybrid.cpp b/modules/protocol/hybrid.cpp
index 331db994f..55c126a90 100644
--- a/modules/protocol/hybrid.cpp
+++ b/modules/protocol/hybrid.cpp
@@ -100,10 +100,10 @@ class HybridProto : public IRCDProto
/* And update our internal status for this user since this is not going through our mode handling system */
if (status != NULL)
{
- UserContainer *uc = c->FindUser(user);
+ ChanUserContainer *uc = c->FindUser(user);
if (uc != NULL)
- *uc->status = *status;
+ uc->status = *status;
}
}
diff --git a/modules/protocol/inspircd11.cpp b/modules/protocol/inspircd11.cpp
index 23bd5bca8..c95645de9 100644
--- a/modules/protocol/inspircd11.cpp
+++ b/modules/protocol/inspircd11.cpp
@@ -213,9 +213,9 @@ class InspIRCdProto : public IRCDProto
/* If the user is internally on the channel with flags, kill them so that
* the stacker will allow this.
*/
- UserContainer *uc = c->FindUser(user);
+ ChanUserContainer *uc = c->FindUser(user);
if (uc != NULL)
- uc->status->ClearFlags();
+ uc->status.ClearFlags();
BotInfo *setter = BotInfo::Find(user->nick);
for (unsigned i = 0; i < ModeManager::ChannelModes.size(); ++i)
diff --git a/modules/protocol/inspircd12.cpp b/modules/protocol/inspircd12.cpp
index 38d5c06fb..53ca4ec62 100644
--- a/modules/protocol/inspircd12.cpp
+++ b/modules/protocol/inspircd12.cpp
@@ -229,9 +229,9 @@ class InspIRCd12Proto : public IRCDProto
/* If the user is internally on the channel with flags, kill them so that
* the stacker will allow this.
*/
- UserContainer *uc = c->FindUser(user);
+ ChanUserContainer *uc = c->FindUser(user);
if (uc != NULL)
- uc->status->ClearFlags();
+ uc->status.ClearFlags();
BotInfo *setter = BotInfo::Find(user->nick);
for (unsigned i = 0; i < ModeManager::ChannelModes.size(); ++i)
diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp
index 62b77e6f7..8029a54fb 100644
--- a/modules/protocol/inspircd20.cpp
+++ b/modules/protocol/inspircd20.cpp
@@ -107,9 +107,9 @@ class InspIRCdExtBan : public ChannelModeList
Channel *c = Channel::Find(channel);
if (c != NULL)
{
- UserContainer *uc = c->FindUser(u);
+ ChanUserContainer *uc = c->FindUser(u);
if (uc != NULL)
- if (cm == NULL || uc->status->HasFlag(cm->name))
+ if (cm == NULL || uc->status.HasFlag(cm->name))
return true;
}
}
diff --git a/modules/protocol/ngircd.cpp b/modules/protocol/ngircd.cpp
index 714dcb095..794bb302d 100644
--- a/modules/protocol/ngircd.cpp
+++ b/modules/protocol/ngircd.cpp
@@ -93,9 +93,9 @@ class ngIRCdProto : public IRCDProto
/* If the user is internally on the channel with flags, kill them so that
* the stacker will allow this.
*/
- UserContainer *uc = c->FindUser(user);
+ ChanUserContainer *uc = c->FindUser(user);
if (uc != NULL)
- uc->status->ClearFlags();
+ uc->status.ClearFlags();
BotInfo *setter = BotInfo::Find(user->nick);
for (unsigned i = 0; i < ModeManager::ChannelModes.size(); ++i)
diff --git a/modules/protocol/plexus.cpp b/modules/protocol/plexus.cpp
index c66d34f50..24ee42746 100644
--- a/modules/protocol/plexus.cpp
+++ b/modules/protocol/plexus.cpp
@@ -56,9 +56,9 @@ class PlexusProto : public IRCDProto
/* If the user is internally on the channel with flags, kill them so that
* the stacker will allow this.
*/
- UserContainer *uc = c->FindUser(user);
+ ChanUserContainer *uc = c->FindUser(user);
if (uc != NULL)
- uc->status->ClearFlags();
+ uc->status.ClearFlags();
BotInfo *setter = BotInfo::Find(user->nick);
for (unsigned i = 0; i < ModeManager::ChannelModes.size(); ++i)
diff --git a/modules/protocol/unreal.cpp b/modules/protocol/unreal.cpp
index a14091c96..467724c49 100644
--- a/modules/protocol/unreal.cpp
+++ b/modules/protocol/unreal.cpp
@@ -164,9 +164,9 @@ class UnrealIRCdProto : public IRCDProto
/* If the user is internally on the channel with flags, kill them so that
* the stacker will allow this.
*/
- UserContainer *uc = c->FindUser(user);
+ ChanUserContainer *uc = c->FindUser(user);
if (uc != NULL)
- uc->status->ClearFlags();
+ uc->status.ClearFlags();
BotInfo *setter = BotInfo::Find(user->nick);
for (unsigned i = 0; i < ModeManager::ChannelModes.size(); ++i)
@@ -400,9 +400,9 @@ class UnrealExtBan : public ChannelModeList
Channel *c = Channel::Find(channel);
if (c != NULL)
{
- UserContainer *uc = c->FindUser(u);
+ ChanUserContainer *uc = c->FindUser(u);
if (uc != NULL)
- if (cm == NULL || uc->status->HasFlag(cm->name))
+ if (cm == NULL || uc->status.HasFlag(cm->name))
return true;
}
}
diff --git a/modules/pseudoclients/memoserv.cpp b/modules/pseudoclients/memoserv.cpp
index 350280caa..ba7db4654 100644
--- a/modules/pseudoclients/memoserv.cpp
+++ b/modules/pseudoclients/memoserv.cpp
@@ -99,9 +99,9 @@ class MyMemoServService : public MemoServService
if (ci->c)
{
- for (CUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
+ for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
{
- UserContainer *cu = *it;
+ ChanUserContainer *cu = *it;
if (ci->AccessFor(cu->user).HasPriv("MEMO"))
{
diff --git a/modules/pseudoclients/nickserv.cpp b/modules/pseudoclients/nickserv.cpp
index 744339f7d..dd7efcabc 100644
--- a/modules/pseudoclients/nickserv.cpp
+++ b/modules/pseudoclients/nickserv.cpp
@@ -247,9 +247,9 @@ class NickServCore : public Module
}
if (Config->NSModeOnID)
- for (UChannelList::iterator it = u->chans.begin(), it_end = u->chans.end(); it != it_end; ++it)
+ for (User::ChanUserList::iterator it = u->chans.begin(), it_end = u->chans.end(); it != it_end; ++it)
{
- ChannelContainer *cc = *it;
+ ChanUserContainer *cc = *it;
Channel *c = cc->chan;
if (c)
c->SetCorrectModes(u, true, true);
@@ -286,9 +286,9 @@ class NickServCore : public Module
void OnNickUpdate(User *u) anope_override
{
- for (UChannelList::iterator it = u->chans.begin(), it_end = u->chans.end(); it != it_end; ++it)
+ for (User::ChanUserList::iterator it = u->chans.begin(), it_end = u->chans.end(); it != it_end; ++it)
{
- ChannelContainer *cc = *it;
+ ChanUserContainer *cc = *it;
Channel *c = cc->chan;
if (c)
c->SetCorrectModes(u, true, true);
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> &params)
/* 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> &params)
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;