mirror of
https://github.com/anope/anope.git
synced 2026-07-02 09:06:38 +02:00
Use the same object for chanusercontainer and userchancontainer
This commit is contained in:
+8
-9
@@ -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
|
||||
|
||||
+3
-14
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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())
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"))
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
+28
-32
@@ -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)
|
||||
{
|
||||
|
||||
+6
-7
@@ -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]);
|
||||
|
||||
+2
-2
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user