mirror of
https://github.com/anope/anope.git
synced 2026-07-07 00:03:13 +02:00
Reworked live SQL support yet again
This commit is contained in:
+22
-13
@@ -46,8 +46,11 @@ void PrivilegeManager::RemovePrivilege(Privilege &p)
|
||||
if (it != privs.end())
|
||||
privs.erase(it);
|
||||
|
||||
for (registered_channel_map::const_iterator cit = RegisteredChannelList.begin(), cit_end = RegisteredChannelList.end(); cit != cit_end; ++cit)
|
||||
for (registered_channel_map::const_iterator cit = RegisteredChannelList->begin(), cit_end = RegisteredChannelList->end(); cit != cit_end; ++cit)
|
||||
{
|
||||
cit->second->QueueUpdate();
|
||||
cit->second->RemoveLevel(p.name);
|
||||
}
|
||||
}
|
||||
|
||||
Privilege *PrivilegeManager::FindPrivilege(const Anope::string &name)
|
||||
@@ -84,14 +87,14 @@ ChanAccess::~ChanAccess()
|
||||
{
|
||||
}
|
||||
|
||||
Anope::string ChanAccess::serialize_name() const
|
||||
const Anope::string ChanAccess::serialize_name() const
|
||||
{
|
||||
return "ChanAccess";
|
||||
}
|
||||
|
||||
Serializable::serialized_data ChanAccess::serialize()
|
||||
Serialize::Data ChanAccess::serialize() const
|
||||
{
|
||||
serialized_data data;
|
||||
Serialize::Data data;
|
||||
|
||||
data["provider"] << this->provider->name;
|
||||
data["ci"] << this->ci->name;
|
||||
@@ -104,14 +107,18 @@ Serializable::serialized_data ChanAccess::serialize()
|
||||
return data;
|
||||
}
|
||||
|
||||
void ChanAccess::unserialize(serialized_data &data)
|
||||
Serializable* ChanAccess::unserialize(Serializable *obj, Serialize::Data &data)
|
||||
{
|
||||
service_reference<AccessProvider> aprovider("AccessProvider", data["provider"].astr());
|
||||
ChannelInfo *ci = cs_findchan(data["ci"].astr());
|
||||
if (!aprovider || !ci)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
ChanAccess *access = aprovider->Create();
|
||||
ChanAccess *access;
|
||||
if (obj)
|
||||
access = debug_cast<ChanAccess *>(obj);
|
||||
else
|
||||
access = const_cast<ChanAccess *>(aprovider->Create());
|
||||
access->provider = aprovider;
|
||||
access->ci = ci;
|
||||
data["mask"] >> access->mask;
|
||||
@@ -120,10 +127,12 @@ void ChanAccess::unserialize(serialized_data &data)
|
||||
data["created"] >> access->created;
|
||||
access->Unserialize(data["data"].astr());
|
||||
|
||||
ci->AddAccess(access);
|
||||
if (!obj)
|
||||
ci->AddAccess(access);
|
||||
return access;
|
||||
}
|
||||
|
||||
bool ChanAccess::Matches(User *u, NickCore *nc)
|
||||
bool ChanAccess::Matches(const User *u, const NickCore *nc) const
|
||||
{
|
||||
bool is_mask = this->mask.find_first_of("!@?*") != Anope::string::npos;
|
||||
if (u && is_mask && Anope::Match(u->nick, this->mask))
|
||||
@@ -131,10 +140,10 @@ bool ChanAccess::Matches(User *u, NickCore *nc)
|
||||
else if (u && Anope::Match(u->GetDisplayedMask(), this->mask))
|
||||
return true;
|
||||
else if (nc)
|
||||
for (std::list<NickAlias *>::iterator it = nc->aliases.begin(); it != nc->aliases.end(); ++it)
|
||||
for (std::list<serialize_obj<NickAlias> >::const_iterator it = nc->aliases.begin(); it != nc->aliases.end();)
|
||||
{
|
||||
NickAlias *na = *it;
|
||||
if (Anope::Match(na->nick, this->mask))
|
||||
const NickAlias *na = *it++;
|
||||
if (na && Anope::Match(na->nick, this->mask))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -245,7 +254,7 @@ bool AccessGroup::HasPriv(const Anope::string &name) const
|
||||
return false;
|
||||
}
|
||||
|
||||
ChanAccess *AccessGroup::Highest() const
|
||||
const ChanAccess *AccessGroup::Highest() const
|
||||
{
|
||||
const std::vector<Privilege> &privs = PrivilegeManager::GetPrivileges();
|
||||
for (unsigned i = privs.size(); i > 0; --i)
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ bool bad_password(User *u)
|
||||
* @param full True to match against the users real host and IP
|
||||
* @return void
|
||||
*/
|
||||
void common_unban(ChannelInfo *ci, User *u, bool full)
|
||||
void common_unban(const ChannelInfo *ci, User *u, bool full)
|
||||
{
|
||||
if (!u || !ci || !ci->c || !ci->c->HasMode(CMODE_BAN))
|
||||
return;
|
||||
|
||||
+31
-24
@@ -16,9 +16,10 @@
|
||||
#include "config.h"
|
||||
#include "language.h"
|
||||
#include "extern.h"
|
||||
#include "serialize.h"
|
||||
|
||||
Anope::insensitive_map<BotInfo *> BotListByNick;
|
||||
Anope::map<BotInfo *> BotListByUID;
|
||||
serialize_checker<botinfo_map> BotListByNick("BotInfo");
|
||||
serialize_checker<botinfouid_map> BotListByUID("BotInfo");
|
||||
|
||||
BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const Anope::string &nhost, const Anope::string &nreal, const Anope::string &bmodes) : User(nnick, nuser, nhost, ts6_uid_retrieve()), Flags<BotFlag, BI_END>(BotFlagString), botmodes(bmodes)
|
||||
{
|
||||
@@ -28,9 +29,9 @@ BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const A
|
||||
this->lastmsg = this->created = Anope::CurTime;
|
||||
this->introduced = false;
|
||||
|
||||
BotListByNick[this->nick] = this;
|
||||
(*BotListByNick)[this->nick] = this;
|
||||
if (!this->uid.empty())
|
||||
BotListByUID[this->uid] = this;
|
||||
(*BotListByUID)[this->uid] = this;
|
||||
|
||||
// If we're synchronised with the uplink already, send the bot.
|
||||
if (Me && Me->IsSynced())
|
||||
@@ -57,29 +58,32 @@ BotInfo::~BotInfo()
|
||||
ircdproto->SendSQLineDel(&x);
|
||||
}
|
||||
|
||||
for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(), it_end = RegisteredChannelList.end(); it != it_end; ++it)
|
||||
for (registered_channel_map::const_iterator it = RegisteredChannelList->begin(), it_end = RegisteredChannelList->end(); it != it_end; ++it)
|
||||
{
|
||||
ChannelInfo *ci = it->second;
|
||||
|
||||
if (ci->bi == this)
|
||||
{
|
||||
ci->QueueUpdate();
|
||||
ci->bi = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
BotListByNick.erase(this->nick);
|
||||
BotListByNick->erase(this->nick);
|
||||
if (!this->uid.empty())
|
||||
BotListByUID.erase(this->uid);
|
||||
BotListByUID->erase(this->uid);
|
||||
}
|
||||
|
||||
Anope::string BotInfo::serialize_name() const
|
||||
const Anope::string BotInfo::serialize_name() const
|
||||
{
|
||||
return "BotInfo";
|
||||
}
|
||||
|
||||
Serializable::serialized_data BotInfo::serialize()
|
||||
Serialize::Data BotInfo::serialize() const
|
||||
{
|
||||
serialized_data data;
|
||||
Serialize::Data data;
|
||||
|
||||
data["nick"] << this->nick;
|
||||
data["nick"].setMax(64) << this->nick;
|
||||
data["user"] << this->ident;
|
||||
data["host"] << this->host;
|
||||
data["realname"] << this->realname;
|
||||
@@ -89,13 +93,16 @@ Serializable::serialized_data BotInfo::serialize()
|
||||
return data;
|
||||
}
|
||||
|
||||
void BotInfo::unserialize(serialized_data &data)
|
||||
Serializable* BotInfo::unserialize(Serializable *obj, Serialize::Data &data)
|
||||
{
|
||||
BotInfo *bi = findbot(data["nick"].astr());
|
||||
if (bi == NULL)
|
||||
BotInfo *bi;
|
||||
if (obj)
|
||||
bi = debug_cast<BotInfo *>(obj);
|
||||
else if (!(bi = findbot(data["nick"].astr())))
|
||||
bi = new BotInfo(data["nick"].astr(), data["user"].astr(), data["host"].astr(), data["realname"].astr());
|
||||
data["created"] >> bi->created;
|
||||
bi->FromString(data["flags"].astr());
|
||||
return bi;
|
||||
}
|
||||
|
||||
void BotInfo::GenerateUID()
|
||||
@@ -103,26 +110,26 @@ void BotInfo::GenerateUID()
|
||||
if (!this->uid.empty())
|
||||
throw CoreException("Bot already has a uid?");
|
||||
this->uid = ts6_uid_retrieve();
|
||||
BotListByUID[this->uid] = this;
|
||||
(*BotListByUID)[this->uid] = this;
|
||||
UserListByUID[this->uid] = this;
|
||||
}
|
||||
|
||||
void BotInfo::SetNewNick(const Anope::string &newnick)
|
||||
{
|
||||
UserListByNick.erase(this->nick);
|
||||
BotListByNick.erase(this->nick);
|
||||
BotListByNick->erase(this->nick);
|
||||
|
||||
this->nick = newnick;
|
||||
|
||||
UserListByNick[this->nick] = this;
|
||||
BotListByNick[this->nick] = this;
|
||||
(*BotListByNick)[this->nick] = this;
|
||||
}
|
||||
|
||||
void BotInfo::RejoinAll()
|
||||
{
|
||||
for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(), it_end = RegisteredChannelList.end(); it != it_end; ++it)
|
||||
for (registered_channel_map::const_iterator it = RegisteredChannelList->begin(), it_end = RegisteredChannelList->end(); it != it_end; ++it)
|
||||
{
|
||||
ChannelInfo *ci = it->second;
|
||||
const ChannelInfo *ci = it->second;
|
||||
|
||||
if (ci->bi == this && ci->c && ci->c->users.size() >= Config->BSMinUsers)
|
||||
this->Join(ci->c);
|
||||
@@ -162,12 +169,12 @@ void BotInfo::UnAssign(User *u, ChannelInfo *ci)
|
||||
ci->bi = NULL;
|
||||
}
|
||||
|
||||
unsigned BotInfo::GetChannelCount()
|
||||
unsigned BotInfo::GetChannelCount() const
|
||||
{
|
||||
unsigned count = 0;
|
||||
for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(), it_end = RegisteredChannelList.end(); it != it_end; ++it)
|
||||
for (registered_channel_map::const_iterator it = RegisteredChannelList->begin(), it_end = RegisteredChannelList->end(); it != it_end; ++it)
|
||||
{
|
||||
ChannelInfo *ci = it->second;
|
||||
const ChannelInfo *ci = it->second;
|
||||
|
||||
if (ci->bi == this)
|
||||
++count;
|
||||
@@ -234,7 +241,7 @@ void BotInfo::OnMessage(User *u, const Anope::string &message)
|
||||
std::vector<Anope::string> params = BuildStringVector(message);
|
||||
bool has_help = this->commands.find("HELP") != this->commands.end();
|
||||
|
||||
BotInfo::command_map::iterator it = this->commands.end();
|
||||
BotInfo::command_map::const_iterator it = this->commands.end();
|
||||
unsigned count = 0;
|
||||
for (unsigned max = params.size(); it == this->commands.end() && max > 0; --max)
|
||||
{
|
||||
@@ -256,7 +263,7 @@ void BotInfo::OnMessage(User *u, const Anope::string &message)
|
||||
return;
|
||||
}
|
||||
|
||||
CommandInfo &info = it->second;
|
||||
const CommandInfo &info = it->second;
|
||||
service_reference<Command> c("Command", info.name);
|
||||
if (!c)
|
||||
{
|
||||
|
||||
+8
-8
@@ -21,24 +21,24 @@
|
||||
#include "access.h"
|
||||
#include "channels.h"
|
||||
|
||||
BotInfo *findbot(const Anope::string &nick)
|
||||
BotInfo* findbot(const Anope::string &nick)
|
||||
{
|
||||
BotInfo *bi = NULL;
|
||||
if (isdigit(nick[0]) && ircd->ts6)
|
||||
{
|
||||
Anope::map<BotInfo *>::iterator it = BotListByUID.find(nick);
|
||||
if (it != BotListByUID.end())
|
||||
botinfouid_map::iterator it = BotListByUID->find(nick);
|
||||
if (it != BotListByUID->end())
|
||||
bi = it->second;
|
||||
}
|
||||
else
|
||||
{
|
||||
Anope::insensitive_map<BotInfo *>::iterator it = BotListByNick.find(nick);
|
||||
if (it != BotListByNick.end())
|
||||
botinfo_map::iterator it = BotListByNick->find(nick);
|
||||
if (it != BotListByNick->end())
|
||||
bi = it->second;
|
||||
}
|
||||
|
||||
FOREACH_MOD(I_OnFindBot, OnFindBot(nick));
|
||||
|
||||
|
||||
if (bi)
|
||||
bi->QueueUpdate();
|
||||
return bi;
|
||||
}
|
||||
|
||||
|
||||
+36
-40
@@ -102,7 +102,7 @@ void Channel::Reset()
|
||||
|
||||
void Channel::Sync()
|
||||
{
|
||||
if (!this->HasMode(CMODE_PERM) && (this->users.empty() || (this->users.size() == 1 && this->ci && this->ci->bi == this->users.front()->user)))
|
||||
if (!this->HasMode(CMODE_PERM) && (this->users.empty() || (this->users.size() == 1 && this->ci && this->ci->bi && *this->ci->bi == this->users.front()->user)))
|
||||
{
|
||||
this->Hold();
|
||||
}
|
||||
@@ -141,30 +141,30 @@ void Channel::CheckModes()
|
||||
return;
|
||||
|
||||
if (this->ci)
|
||||
for (std::multimap<ChannelModeName, ModeLock>::const_iterator it = this->ci->GetMLock().begin(), it_end = this->ci->GetMLock().end(); it != it_end; ++it)
|
||||
for (ChannelInfo::ModeList::const_iterator it = this->ci->GetMLock().begin(), it_end = this->ci->GetMLock().end(); it != it_end; ++it)
|
||||
{
|
||||
const ModeLock &ml = it->second;
|
||||
ChannelMode *cm = ModeManager::FindChannelModeByName(ml.name);
|
||||
const ModeLock *ml = it->second;
|
||||
ChannelMode *cm = ModeManager::FindChannelModeByName(ml->name);
|
||||
if (!cm)
|
||||
continue;
|
||||
|
||||
if (cm->Type == MODE_REGULAR)
|
||||
{
|
||||
if (!this->HasMode(cm->Name) && ml.set)
|
||||
if (!this->HasMode(cm->Name) && ml->set)
|
||||
this->SetMode(NULL, cm);
|
||||
else if (this->HasMode(cm->Name) && !ml.set)
|
||||
else if (this->HasMode(cm->Name) && !ml->set)
|
||||
this->RemoveMode(NULL, cm);
|
||||
}
|
||||
else if (cm->Type == MODE_PARAM)
|
||||
{
|
||||
/* If the channel doesnt have the mode, or it does and it isn't set correctly */
|
||||
if (ml.set)
|
||||
if (ml->set)
|
||||
{
|
||||
Anope::string param;
|
||||
this->GetParam(cm->Name, param);
|
||||
|
||||
if (!this->HasMode(cm->Name) || (!param.empty() && !ml.param.empty() && !param.equals_cs(ml.param)))
|
||||
this->SetMode(NULL, cm, ml.param);
|
||||
if (!this->HasMode(cm->Name) || (!param.empty() && !ml->param.empty() && !param.equals_cs(ml->param)))
|
||||
this->SetMode(NULL, cm, ml->param);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -175,10 +175,10 @@ void Channel::CheckModes()
|
||||
}
|
||||
else if (cm->Type == MODE_LIST)
|
||||
{
|
||||
if (ml.set)
|
||||
this->SetMode(NULL, cm, ml.param);
|
||||
if (ml->set)
|
||||
this->SetMode(NULL, cm, ml->param);
|
||||
else
|
||||
this->RemoveMode(NULL, cm, ml.param);
|
||||
this->RemoveMode(NULL, cm, ml->param);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -260,9 +260,9 @@ void Channel::DeleteUser(User *user)
|
||||
* @param u The user
|
||||
* @return A user container if found, else NULL
|
||||
*/
|
||||
UserContainer *Channel::FindUser(User *u)
|
||||
UserContainer *Channel::FindUser(const User *u) const
|
||||
{
|
||||
for (CUserList::iterator it = this->users.begin(), it_end = this->users.end(); it != it_end; ++it)
|
||||
for (CUserList::const_iterator it = this->users.begin(), it_end = this->users.end(); it != it_end; ++it)
|
||||
if ((*it)->user == u)
|
||||
return *it;
|
||||
return NULL;
|
||||
@@ -273,7 +273,7 @@ UserContainer *Channel::FindUser(User *u)
|
||||
* @param cms The status mode, or NULL to represent no status
|
||||
* @return true or false
|
||||
*/
|
||||
bool Channel::HasUserStatus(User *u, ChannelModeStatus *cms) const
|
||||
bool Channel::HasUserStatus(const User *u, ChannelModeStatus *cms) const
|
||||
{
|
||||
if (!u || (cms && cms->Type != MODE_STATUS))
|
||||
throw CoreException("Channel::HasUserStatus got bad mode");
|
||||
@@ -297,7 +297,7 @@ bool Channel::HasUserStatus(User *u, ChannelModeStatus *cms) const
|
||||
* @param Name The Mode name, eg CMODE_OP, CMODE_VOICE
|
||||
* @return true or false
|
||||
*/
|
||||
bool Channel::HasUserStatus(User *u, ChannelModeName Name) const
|
||||
bool Channel::HasUserStatus(const User *u, ChannelModeName Name) const
|
||||
{
|
||||
return HasUserStatus(u, debug_cast<ChannelModeStatus *>(ModeManager::FindChannelModeByName(Name)));
|
||||
}
|
||||
@@ -395,8 +395,8 @@ void Channel::SetModeInternal(User *setter, ChannelMode *cm, const Anope::string
|
||||
if (cm->Name == CMODE_PERM)
|
||||
{
|
||||
this->SetFlag(CH_PERSIST);
|
||||
if (ci)
|
||||
ci->SetFlag(CI_PERSIST);
|
||||
if (this->ci)
|
||||
this->ci->SetFlag(CI_PERSIST);
|
||||
}
|
||||
|
||||
/* Check if we should enforce mlock */
|
||||
@@ -429,8 +429,8 @@ void Channel::RemoveModeInternal(User *setter, ChannelMode *cm, const Anope::str
|
||||
return;
|
||||
}
|
||||
|
||||
BotInfo *bi = findbot(param);
|
||||
User *u = bi ? bi : finduser(param);
|
||||
const BotInfo *bi = findbot(param);
|
||||
const User *u = bi ? bi : finduser(param);
|
||||
|
||||
if (!u)
|
||||
{
|
||||
@@ -482,8 +482,8 @@ void Channel::RemoveModeInternal(User *setter, ChannelMode *cm, const Anope::str
|
||||
{
|
||||
this->UnsetFlag(CH_PERSIST);
|
||||
|
||||
if (ci)
|
||||
ci->UnsetFlag(CI_PERSIST);
|
||||
if (this->ci)
|
||||
this->ci->UnsetFlag(CI_PERSIST);
|
||||
|
||||
if (this->users.empty())
|
||||
{
|
||||
@@ -506,7 +506,7 @@ void Channel::RemoveModeInternal(User *setter, ChannelMode *cm, const Anope::str
|
||||
* @param param Optional param arg for the mode
|
||||
* @param EnforceMLock true if mlocks should be enforced, false to override mlock
|
||||
*/
|
||||
void Channel::SetMode(BotInfo *bi, ChannelMode *cm, const Anope::string ¶m, bool EnforceMLock)
|
||||
void Channel::SetMode(const BotInfo *bi, ChannelMode *cm, const Anope::string ¶m, bool EnforceMLock)
|
||||
{
|
||||
if (!cm)
|
||||
return;
|
||||
@@ -547,7 +547,7 @@ void Channel::SetMode(BotInfo *bi, ChannelMode *cm, const Anope::string ¶m,
|
||||
* @param param Optional param arg for the mode
|
||||
* @param EnforceMLock true if mlocks should be enforced, false to override mlock
|
||||
*/
|
||||
void Channel::SetMode(BotInfo *bi, ChannelModeName Name, const Anope::string ¶m, bool EnforceMLock)
|
||||
void Channel::SetMode(const BotInfo *bi, ChannelModeName Name, const Anope::string ¶m, bool EnforceMLock)
|
||||
{
|
||||
SetMode(bi, ModeManager::FindChannelModeByName(Name), param, EnforceMLock);
|
||||
}
|
||||
@@ -558,7 +558,7 @@ void Channel::SetMode(BotInfo *bi, ChannelModeName Name, const Anope::string &pa
|
||||
* @param param Optional param arg for the mode
|
||||
* @param EnforceMLock true if mlocks should be enforced, false to override mlock
|
||||
*/
|
||||
void Channel::RemoveMode(BotInfo *bi, ChannelMode *cm, const Anope::string ¶m, bool EnforceMLock)
|
||||
void Channel::RemoveMode(const BotInfo *bi, ChannelMode *cm, const Anope::string ¶m, bool EnforceMLock)
|
||||
{
|
||||
if (!cm)
|
||||
return;
|
||||
@@ -599,7 +599,7 @@ void Channel::RemoveMode(BotInfo *bi, ChannelMode *cm, const Anope::string ¶
|
||||
* @param param Optional param arg for the mode
|
||||
* @param EnforceMLock true if mlocks should be enforced, false to override mlock
|
||||
*/
|
||||
void Channel::RemoveMode(BotInfo *bi, ChannelModeName Name, const Anope::string ¶m, bool EnforceMLock)
|
||||
void Channel::RemoveMode(const BotInfo *bi, ChannelModeName Name, const Anope::string ¶m, bool EnforceMLock)
|
||||
{
|
||||
RemoveMode(bi, ModeManager::FindChannelModeByName(Name), param, EnforceMLock);
|
||||
}
|
||||
@@ -631,7 +631,7 @@ bool Channel::GetParam(ChannelModeName Name, Anope::string &Target) const
|
||||
* @param EnforceMLock Should mlock be enforced on this mode change
|
||||
* @param cmodes The modes to set
|
||||
*/
|
||||
void Channel::SetModes(BotInfo *bi, bool EnforceMLock, const char *cmodes, ...)
|
||||
void Channel::SetModes(const BotInfo *bi, bool EnforceMLock, const char *cmodes, ...)
|
||||
{
|
||||
char buf[BUFSIZE] = "";
|
||||
va_list args;
|
||||
@@ -879,9 +879,7 @@ void Channel::ChangeTopicInternal(const Anope::string &user, const Anope::string
|
||||
FOREACH_MOD(I_OnTopicUpdated, OnTopicUpdated(this, u, this->topic));
|
||||
|
||||
if (this->ci)
|
||||
{
|
||||
this->ci->CheckTopic();
|
||||
}
|
||||
}
|
||||
|
||||
void Channel::ChangeTopic(const Anope::string &user, const Anope::string &newtopic, time_t ts)
|
||||
@@ -896,9 +894,7 @@ void Channel::ChangeTopic(const Anope::string &user, const Anope::string &newtop
|
||||
FOREACH_MOD(I_OnTopicUpdated, OnTopicUpdated(this, u, this->topic));
|
||||
|
||||
if (this->ci)
|
||||
{
|
||||
this->ci->CheckTopic();
|
||||
}
|
||||
}
|
||||
|
||||
/** A timer used to keep the BotServ bot/ChanServ in the channel
|
||||
@@ -1157,7 +1153,7 @@ void do_cmode(const Anope::string &source, const Anope::string &channel, const A
|
||||
* @param give_modes Set to 1 to give modes, 0 to not give modes
|
||||
* @return void
|
||||
**/
|
||||
void chan_set_correct_modes(User *user, Channel *c, int give_modes)
|
||||
void chan_set_correct_modes(const User *user, Channel *c, int give_modes)
|
||||
{
|
||||
ChannelMode *owner = ModeManager::FindChannelModeByName(CMODE_OWNER),
|
||||
*admin = ModeManager::FindChannelModeByName(CMODE_PROTECT),
|
||||
@@ -1208,20 +1204,20 @@ void chan_set_correct_modes(User *user, Channel *c, int give_modes)
|
||||
}
|
||||
|
||||
// Check mlock
|
||||
for (std::multimap<ChannelModeName, ModeLock>::const_iterator it = ci->GetMLock().begin(), it_end = ci->GetMLock().end(); it != it_end; ++it)
|
||||
for (ChannelInfo::ModeList::const_iterator it = ci->GetMLock().begin(), it_end = ci->GetMLock().end(); it != it_end; ++it)
|
||||
{
|
||||
const ModeLock &ml = it->second;
|
||||
ChannelMode *cm = ModeManager::FindChannelModeByName(ml.name);
|
||||
const ModeLock *ml = it->second;
|
||||
ChannelMode *cm = ModeManager::FindChannelModeByName(ml->name);
|
||||
if (!cm || cm->Type != MODE_STATUS)
|
||||
continue;
|
||||
|
||||
if (Anope::Match(user->nick, ml.param) || Anope::Match(user->GetDisplayedMask(), ml.param))
|
||||
if (Anope::Match(user->nick, ml->param) || Anope::Match(user->GetDisplayedMask(), ml->param))
|
||||
{
|
||||
if ((ml.set && !c->HasUserStatus(user, ml.name)) || (!ml.set && c->HasUserStatus(user, ml.name)))
|
||||
if ((ml->set && !c->HasUserStatus(user, ml->name)) || (!ml->set && c->HasUserStatus(user, ml->name)))
|
||||
{
|
||||
if (ml.set)
|
||||
if (ml->set)
|
||||
c->SetMode(NULL, cm, user->nick, false);
|
||||
else if (!ml.set)
|
||||
else if (!ml->set)
|
||||
c->RemoveMode(NULL, cm, user->nick, false);
|
||||
}
|
||||
}
|
||||
@@ -1326,7 +1322,7 @@ const Anope::string Entry::GetMask()
|
||||
* @param full True to match against a users real host and IP
|
||||
* @return true on match
|
||||
*/
|
||||
bool Entry::Matches(User *u, bool full) const
|
||||
bool Entry::Matches(const User *u, bool full) const
|
||||
{
|
||||
bool ret = true;
|
||||
|
||||
|
||||
+8
-11
@@ -18,17 +18,14 @@
|
||||
#include "channels.h"
|
||||
#include "access.h"
|
||||
|
||||
registered_channel_map RegisteredChannelList;
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
ChannelInfo *cs_findchan(const Anope::string &chan)
|
||||
ChannelInfo* cs_findchan(const Anope::string &chan)
|
||||
{
|
||||
FOREACH_MOD(I_OnFindChan, OnFindChan(chan));
|
||||
|
||||
registered_channel_map::const_iterator it = RegisteredChannelList.find(chan);
|
||||
if (it != RegisteredChannelList.end())
|
||||
registered_channel_map::const_iterator it = RegisteredChannelList->find(chan);
|
||||
if (it != RegisteredChannelList->end())
|
||||
{
|
||||
it->second->QueueUpdate();
|
||||
return it->second;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -40,7 +37,7 @@ ChannelInfo *cs_findchan(const Anope::string &chan)
|
||||
* @param ci The channel
|
||||
* @return true or false
|
||||
*/
|
||||
bool IsFounder(User *user, ChannelInfo *ci)
|
||||
bool IsFounder(const User *user, const ChannelInfo *ci)
|
||||
{
|
||||
if (!user || !ci)
|
||||
return false;
|
||||
@@ -71,7 +68,7 @@ void update_cs_lastseen(User *user, ChannelInfo *ci)
|
||||
/* Returns the best ban possible for a user depending of the bantype
|
||||
value. */
|
||||
|
||||
int get_idealban(ChannelInfo *ci, User *u, Anope::string &ret)
|
||||
int get_idealban(const ChannelInfo *ci, User *u, Anope::string &ret)
|
||||
{
|
||||
Anope::string mask;
|
||||
|
||||
|
||||
+21
-10
@@ -620,9 +620,13 @@ static bool DoneOperTypes(ServerConfig *, const Anope::string &)
|
||||
|
||||
static bool InitOpers(ServerConfig *config, const Anope::string &)
|
||||
{
|
||||
for (nickcore_map::const_iterator it = NickCoreList.begin(), it_end = NickCoreList.end(); it != it_end; ++it)
|
||||
if (it->second->o && it->second->o->config)
|
||||
it->second->o = NULL;
|
||||
for (nickcore_map::const_iterator it = NickCoreList->begin(), it_end = NickCoreList->end(); it != it_end; ++it)
|
||||
{
|
||||
NickCore *nc = it->second;
|
||||
nc->QueueUpdate();
|
||||
if (nc->o && nc->o->config)
|
||||
nc->o = NULL;
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < config->Opers.size(); ++i)
|
||||
delete config->Opers[i];
|
||||
@@ -674,7 +678,7 @@ static bool DoneOpers(ServerConfig *config, const Anope::string &)
|
||||
{
|
||||
Oper *o = config->Opers[i];
|
||||
|
||||
NickAlias *na = findnick(o->name);
|
||||
const NickAlias *na = findnick(o->name);
|
||||
if (!na)
|
||||
// Nonexistant nick
|
||||
continue;
|
||||
@@ -817,8 +821,15 @@ static bool DoneLogs(ServerConfig *config, const Anope::string &)
|
||||
|
||||
static bool InitCommands(ServerConfig *config, const Anope::string &)
|
||||
{
|
||||
for (botinfo_map::iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it)
|
||||
it->second->commands.clear();
|
||||
for (botinfo_map::const_iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it)
|
||||
{
|
||||
BotInfo *bi = it->second;
|
||||
if (bi)
|
||||
{
|
||||
bi->QueueUpdate();
|
||||
bi->commands.clear();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -929,8 +940,8 @@ static bool DoServices(ServerConfig *config, const Anope::string &, const Anope:
|
||||
throw ConfigException("One or more values in your configuration file failed to validate. Please see your log for more information.");
|
||||
|
||||
services.insert(nick);
|
||||
BotInfo *bi = findbot(nick);
|
||||
if (bi == NULL)
|
||||
BotInfo* bi = findbot(nick);
|
||||
if (!bi)
|
||||
bi = new BotInfo(nick, user, host, gecos, modes);
|
||||
bi->SetFlag(BI_CONF);
|
||||
|
||||
@@ -1000,13 +1011,13 @@ static bool DoServices(ServerConfig *config, const Anope::string &, const Anope:
|
||||
|
||||
static bool DoneServices(ServerConfig *config, const Anope::string &)
|
||||
{
|
||||
for (botinfo_map::iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end;)
|
||||
for (botinfo_map::const_iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end;)
|
||||
{
|
||||
BotInfo *bi = it->second;
|
||||
++it;
|
||||
|
||||
if (bi->HasFlag(BI_CONF) && services.count(bi->nick) == 0)
|
||||
delete bi;
|
||||
bi->destroy();
|
||||
}
|
||||
services.clear();
|
||||
return true;
|
||||
|
||||
+1
-1
@@ -453,7 +453,7 @@ void Init(int ac, char **av)
|
||||
|
||||
/* Create me */
|
||||
Me = new Server(NULL, Config->ServerName, 0, Config->ServerDesc, Config->Numeric);
|
||||
for (botinfo_map::iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it)
|
||||
for (botinfo_map::const_iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it)
|
||||
it->second->server = Me;
|
||||
|
||||
/* Announce ourselves to the logfile. */
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ const char *translate(User *u, const char *string)
|
||||
return translate(u ? u->Account() : NULL, string);
|
||||
}
|
||||
|
||||
const char *translate(NickCore *nc, const char *string)
|
||||
const char *translate(const NickCore *nc, const char *string)
|
||||
{
|
||||
return anope_gettext(nc ? nc->language.c_str() : Config->NSDefLanguage.c_str(), string);
|
||||
}
|
||||
|
||||
+20
-19
@@ -75,15 +75,15 @@ Anope::string LogFile::GetName() const
|
||||
return this->filename;
|
||||
}
|
||||
|
||||
Log::Log(LogType type, const Anope::string &category, BotInfo *b) : bi(b), u(NULL), c(NULL), chan(NULL), ci(NULL), s(NULL), Type(type), Category(category)
|
||||
Log::Log(LogType type, const Anope::string &category, const BotInfo *b) : bi(b), u(NULL), c(NULL), chan(NULL), ci(NULL), s(NULL), Type(type), Category(category)
|
||||
{
|
||||
if (!bi)
|
||||
bi = Config ? findbot(Config->Global) : NULL;
|
||||
if (!bi && Config)
|
||||
bi = findbot(Config->Global);
|
||||
if (bi)
|
||||
this->Sources.push_back(bi->nick);
|
||||
}
|
||||
|
||||
Log::Log(LogType type, User *_u, Command *_c, ChannelInfo *_ci) : u(_u), c(_c), chan(NULL), ci(_ci), s(NULL), Type(type)
|
||||
Log::Log(LogType type, const User *_u, Command *_c, const ChannelInfo *_ci) : u(_u), c(_c), chan(NULL), ci(_ci), s(NULL), Type(type)
|
||||
{
|
||||
if (!u || !c)
|
||||
throw CoreException("Invalid pointers passed to Log::Log");
|
||||
@@ -95,8 +95,8 @@ Log::Log(LogType type, User *_u, Command *_c, ChannelInfo *_ci) : u(_u), c(_c),
|
||||
this->bi = NULL;
|
||||
if (sl != Anope::string::npos)
|
||||
this->bi = findbot(c->name.substr(0, sl));
|
||||
if (this->bi == NULL)
|
||||
this->bi = Config ? findbot(Config->Global) : NULL;
|
||||
if (this->bi == NULL && Config)
|
||||
this->bi = findbot(Config->Global);
|
||||
this->Category = c->name;
|
||||
if (this->bi)
|
||||
this->Sources.push_back(this->bi->nick);
|
||||
@@ -106,12 +106,13 @@ Log::Log(LogType type, User *_u, Command *_c, ChannelInfo *_ci) : u(_u), c(_c),
|
||||
this->Sources.push_back(ci->name);
|
||||
}
|
||||
|
||||
Log::Log(User *_u, Channel *ch, const Anope::string &category) : u(_u), c(NULL), chan(ch), ci(chan ? chan->ci : NULL), s(NULL), Type(LOG_CHANNEL)
|
||||
Log::Log(const User *_u, Channel *ch, const Anope::string &category) : bi(NULL), u(_u), c(NULL), chan(ch), ci(chan ? *chan->ci : NULL), s(NULL), Type(LOG_CHANNEL)
|
||||
{
|
||||
if (!chan)
|
||||
throw CoreException("Invalid pointers passed to Log::Log");
|
||||
|
||||
this->bi = Config ? findbot(Config->ChanServ) : NULL;
|
||||
if (Config)
|
||||
this->bi = findbot(Config->ChanServ);
|
||||
this->Category = category;
|
||||
if (this->bi)
|
||||
this->Sources.push_back(this->bi->nick);
|
||||
@@ -120,36 +121,36 @@ Log::Log(User *_u, Channel *ch, const Anope::string &category) : u(_u), c(NULL),
|
||||
this->Sources.push_back(chan->name);
|
||||
}
|
||||
|
||||
Log::Log(User *_u, const Anope::string &category, BotInfo *_bi) : bi(_bi), u(_u), c(NULL), chan(NULL), ci(NULL), s(NULL), Type(LOG_USER), Category(category)
|
||||
Log::Log(const User *_u, const Anope::string &category, const BotInfo *_bi) : bi(_bi), u(_u), c(NULL), chan(NULL), ci(NULL), s(NULL), Type(LOG_USER), Category(category)
|
||||
{
|
||||
if (!u)
|
||||
throw CoreException("Invalid pointers passed to Log::Log");
|
||||
|
||||
if (!this->bi)
|
||||
this->bi = Config ? findbot(Config->Global) : NULL;
|
||||
if (!this->bi && Config)
|
||||
this->bi = findbot(Config->Global);
|
||||
if (this->bi)
|
||||
this->Sources.push_back(this->bi->nick);
|
||||
this->Sources.push_back(u->nick);
|
||||
}
|
||||
|
||||
Log::Log(Server *serv, const Anope::string &category, BotInfo *_bi) : bi(_bi), u(NULL), c(NULL), chan(NULL), ci(NULL), s(serv), Type(LOG_SERVER), Category(category)
|
||||
Log::Log(Server *serv, const Anope::string &category, const BotInfo *_bi) : bi(_bi), u(NULL), c(NULL), chan(NULL), ci(NULL), s(serv), Type(LOG_SERVER), Category(category)
|
||||
{
|
||||
if (!s)
|
||||
throw CoreException("Invalid pointer passed to Log::Log");
|
||||
|
||||
if (!this->bi)
|
||||
this->bi = Config ? findbot(Config->OperServ) : NULL;
|
||||
if (!this->bi)
|
||||
this->bi = Config ? findbot(Config->Global) : NULL;
|
||||
if (!this->bi && Config)
|
||||
this->bi = findbot(Config->OperServ);
|
||||
if (!this->bi && Config)
|
||||
this->bi = findbot(Config->Global);
|
||||
if (this->bi)
|
||||
this->Sources.push_back(this->bi->nick);
|
||||
this->Sources.push_back(s->GetName());
|
||||
}
|
||||
|
||||
Log::Log(BotInfo *b, const Anope::string &category) : bi(b), u(NULL), c(NULL), chan(NULL), ci(NULL), s(NULL), Type(LOG_NORMAL), Category(category)
|
||||
Log::Log(const BotInfo *b, const Anope::string &category) : bi(b), u(NULL), c(NULL), chan(NULL), ci(NULL), s(NULL), Type(LOG_NORMAL), Category(category)
|
||||
{
|
||||
if (!this->bi)
|
||||
this->bi = Config ? findbot(Config->Global) : NULL;
|
||||
if (!this->bi && Config)
|
||||
this->bi = findbot(Config->Global);
|
||||
if (this->bi)
|
||||
this->Sources.push_back(bi->nick);
|
||||
}
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ void MailThread::Run()
|
||||
SetExitState();
|
||||
}
|
||||
|
||||
bool Mail(User *u, NickCore *nc, BotInfo *service, const Anope::string &subject, const Anope::string &message)
|
||||
bool Mail(User *u, NickCore *nc, const BotInfo *service, const Anope::string &subject, const Anope::string &message)
|
||||
{
|
||||
if (!u || !nc || !service || subject.empty() || message.empty())
|
||||
return false;
|
||||
|
||||
+2
-2
@@ -124,7 +124,7 @@ UplinkSocket::~UplinkSocket()
|
||||
{
|
||||
/* Don't use quitmsg here, it may contain information you don't want people to see */
|
||||
ircdproto->SendQuit(u, "Shutting down");
|
||||
BotInfo *bi = findbot(u->nick);
|
||||
BotInfo* bi = findbot(u->nick);
|
||||
if (bi != NULL)
|
||||
bi->introduced = false;
|
||||
}
|
||||
@@ -224,7 +224,7 @@ UplinkSocket::Message::~Message()
|
||||
return;
|
||||
}
|
||||
|
||||
BotInfo *bi = findbot(this->user->nick);
|
||||
const BotInfo *bi = findbot(this->user->nick);
|
||||
if (bi != NULL && bi->introduced == false)
|
||||
{
|
||||
Log(LOG_DEBUG) << "Attempted to send \"" << this->buffer.str() << "\" from " << bi->nick << " when not introduced";
|
||||
|
||||
+36
-17
@@ -20,14 +20,14 @@
|
||||
|
||||
Memo::Memo() : Flags<MemoFlag>(MemoFlagStrings) { }
|
||||
|
||||
Anope::string Memo::serialize_name() const
|
||||
const Anope::string Memo::serialize_name() const
|
||||
{
|
||||
return "Memo";
|
||||
}
|
||||
|
||||
Serializable::serialized_data Memo::serialize()
|
||||
Serialize::Data Memo::serialize() const
|
||||
{
|
||||
serialized_data data;
|
||||
Serialize::Data data;
|
||||
|
||||
data["owner"] << this->owner;
|
||||
data["time"].setType(Serialize::DT_INT) << this->time;
|
||||
@@ -38,50 +38,69 @@ Serializable::serialized_data Memo::serialize()
|
||||
return data;
|
||||
}
|
||||
|
||||
void Memo::unserialize(serialized_data &data)
|
||||
Serializable* Memo::unserialize(Serializable *obj, Serialize::Data &data)
|
||||
{
|
||||
if (!memoserv)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
bool ischan;
|
||||
MemoInfo *mi = memoserv->GetMemoInfo(data["owner"].astr(), ischan);
|
||||
if (!mi)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
Memo *m = new Memo();
|
||||
Memo *m;
|
||||
if (obj)
|
||||
m = debug_cast<Memo *>(obj);
|
||||
else
|
||||
m = new Memo();
|
||||
data["owner"] >> m->owner;
|
||||
data["time"] >> m->time;
|
||||
data["sender"] >> m->sender;
|
||||
data["text"] >> m->text;
|
||||
m->FromString(data["flags"].astr());
|
||||
|
||||
mi->memos.push_back(m);
|
||||
if (obj == NULL)
|
||||
mi->memos->push_back(m);
|
||||
return m;
|
||||
}
|
||||
|
||||
MemoInfo::MemoInfo() : memos("Memo")
|
||||
{
|
||||
}
|
||||
|
||||
Memo *MemoInfo::GetMemo(unsigned index) const
|
||||
{
|
||||
if (index >= this->memos->size())
|
||||
return NULL;
|
||||
Memo *m = (*memos)[index];
|
||||
m->QueueUpdate();
|
||||
return m;
|
||||
}
|
||||
|
||||
unsigned MemoInfo::GetIndex(Memo *m) const
|
||||
{
|
||||
for (unsigned i = 0; i < this->memos.size(); ++i)
|
||||
if (this->memos[i] == m)
|
||||
for (unsigned i = 0; i < this->memos->size(); ++i)
|
||||
if (this->GetMemo(i) == m)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
void MemoInfo::Del(unsigned index)
|
||||
{
|
||||
if (index >= this->memos.size())
|
||||
if (index >= this->memos->size())
|
||||
return;
|
||||
delete this->memos[index];
|
||||
this->memos.erase(this->memos.begin() + index);
|
||||
this->GetMemo(index)->destroy();
|
||||
this->memos->erase(this->memos->begin() + index);
|
||||
}
|
||||
|
||||
void MemoInfo::Del(Memo *memo)
|
||||
{
|
||||
std::vector<Memo *>::iterator it = std::find(this->memos.begin(), this->memos.end(), memo);
|
||||
std::vector<Memo *>::iterator it = std::find(this->memos->begin(), this->memos->end(), memo);
|
||||
|
||||
if (it != this->memos.end())
|
||||
if (it != this->memos->end())
|
||||
{
|
||||
delete memo;
|
||||
this->memos.erase(it);
|
||||
memo->destroy();
|
||||
this->memos->erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ bool OnStats(const Anope::string &source, const std::vector<Anope::string> ¶
|
||||
{
|
||||
Oper *o = Config->Opers[i];
|
||||
|
||||
NickAlias *na = findnick(o->name);
|
||||
const NickAlias *na = findnick(o->name);
|
||||
if (na)
|
||||
ircdproto->SendNumeric(243, source, "O * * %s %s 0", o->name.c_str(), o->ot->GetName().c_str());
|
||||
}
|
||||
|
||||
+3
-3
@@ -305,7 +305,7 @@ time_t dotime(const Anope::string &s)
|
||||
* @param seconds time in seconds
|
||||
* @return buffer
|
||||
*/
|
||||
Anope::string duration(const time_t &t, NickCore *nc)
|
||||
Anope::string duration(const time_t &t, const NickCore *nc)
|
||||
{
|
||||
/* We first calculate everything */
|
||||
time_t days = (t / 86400);
|
||||
@@ -339,7 +339,7 @@ Anope::string duration(const time_t &t, NickCore *nc)
|
||||
}
|
||||
}
|
||||
|
||||
Anope::string do_strftime(const time_t &t, NickCore *nc, bool short_output)
|
||||
Anope::string do_strftime(const time_t &t, const NickCore *nc, bool short_output)
|
||||
{
|
||||
tm tm = *localtime(&t);
|
||||
char buf[BUFSIZE];
|
||||
@@ -514,7 +514,7 @@ bool nickIsServices(const Anope::string &tempnick, bool bot)
|
||||
nick = nick.substr(0, at);
|
||||
}
|
||||
|
||||
BotInfo *bi = findbot(nick);
|
||||
const BotInfo *bi = findbot(nick);
|
||||
if (bi)
|
||||
return bot ? true : bi->HasFlag(BI_CORE);
|
||||
return false;
|
||||
|
||||
+15
-6
@@ -24,12 +24,14 @@ std::vector<UserMode *> ModeManager::UserModes;
|
||||
/* Number of generic modes we support */
|
||||
unsigned GenericChannelModes = 0, GenericUserModes = 0;
|
||||
/* Default mlocked modes */
|
||||
std::multimap<ChannelModeName, ModeLock> def_mode_locks;
|
||||
ChannelInfo::ModeList def_mode_locks;
|
||||
|
||||
/** Parse the mode string from the config file and set the default mlocked modes
|
||||
*/
|
||||
void SetDefaultMLock(ServerConfig *config)
|
||||
{
|
||||
for (ChannelInfo::ModeList::iterator it = def_mode_locks.begin(), it_end = def_mode_locks.end(); it != it_end; ++it)
|
||||
delete it->second;
|
||||
def_mode_locks.clear();
|
||||
|
||||
Anope::string modes;
|
||||
@@ -57,8 +59,15 @@ void SetDefaultMLock(ServerConfig *config)
|
||||
}
|
||||
|
||||
if (cm->Type != MODE_LIST) // Only MODE_LIST can have duplicates
|
||||
def_mode_locks.erase(cm->Name);
|
||||
def_mode_locks.insert(std::make_pair(cm->Name, ModeLock(NULL, adding == 1, cm->Name, param)));
|
||||
{
|
||||
ChannelInfo::ModeList::iterator it = def_mode_locks.find(cm->Name);
|
||||
if (it != def_mode_locks.end())
|
||||
{
|
||||
delete it->second;
|
||||
def_mode_locks.erase(it);
|
||||
}
|
||||
}
|
||||
def_mode_locks.insert(std::make_pair(cm->Name, new ModeLock(NULL, adding == 1, cm->Name, param)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -461,7 +470,7 @@ std::list<Anope::string> ModeManager::BuildModeStrings(StackerInfo *info)
|
||||
* @param Param A param, if there is one
|
||||
* @param Type The type this is, user or channel
|
||||
*/
|
||||
void ModeManager::StackerAddInternal(BotInfo *bi, Base *Object, Mode *mode, bool Set, const Anope::string &Param, StackerType Type)
|
||||
void ModeManager::StackerAddInternal(const BotInfo *bi, Base *Object, Mode *mode, bool Set, const Anope::string &Param, StackerType Type)
|
||||
{
|
||||
StackerInfo *s = GetInfo(Object);
|
||||
s->Type = Type;
|
||||
@@ -646,7 +655,7 @@ char ModeManager::GetStatusChar(char Value)
|
||||
* @param Set true for setting, false for removing
|
||||
* @param Param The param, if there is one
|
||||
*/
|
||||
void ModeManager::StackerAdd(BotInfo *bi, Channel *c, ChannelMode *cm, bool Set, const Anope::string &Param)
|
||||
void ModeManager::StackerAdd(const BotInfo *bi, Channel *c, ChannelMode *cm, bool Set, const Anope::string &Param)
|
||||
{
|
||||
StackerAddInternal(bi, c, cm, Set, Param, ST_CHANNEL);
|
||||
}
|
||||
@@ -658,7 +667,7 @@ void ModeManager::StackerAdd(BotInfo *bi, Channel *c, ChannelMode *cm, bool Set,
|
||||
* @param Set true for setting, false for removing
|
||||
* @param param The param, if there is one
|
||||
*/
|
||||
void ModeManager::StackerAdd(BotInfo *bi, User *u, UserMode *um, bool Set, const Anope::string &Param)
|
||||
void ModeManager::StackerAdd(const BotInfo *bi, User *u, UserMode *um, bool Set, const Anope::string &Param)
|
||||
{
|
||||
StackerAddInternal(bi, u, um, Set, Param, ST_USER);
|
||||
}
|
||||
|
||||
+24
-19
@@ -19,16 +19,17 @@
|
||||
#include "servers.h"
|
||||
#include "config.h"
|
||||
|
||||
class NickServHeld;
|
||||
serialize_checker<nickalias_map> NickAliasList("NickAlias");
|
||||
|
||||
class NickServHeld;
|
||||
typedef std::map<Anope::string, NickServHeld *> nickservheld_map;
|
||||
static nickservheld_map NickServHelds;
|
||||
|
||||
/** Default constructor
|
||||
* @param nick The nick
|
||||
* @param nickcore The nickcofe for this nick
|
||||
* @param nickcore The nickcore for this nick
|
||||
*/
|
||||
NickAlias::NickAlias(const Anope::string &nickname, NickCore *nickcore) : Flags<NickNameFlag, NS_END>(NickNameFlagStrings)
|
||||
NickAlias::NickAlias(const Anope::string &nickname, NickCore* nickcore) : Flags<NickNameFlag, NS_END>(NickNameFlagStrings)
|
||||
{
|
||||
if (nickname.empty())
|
||||
throw CoreException("Empty nick passed to NickAlias constructor");
|
||||
@@ -38,16 +39,16 @@ NickAlias::NickAlias(const Anope::string &nickname, NickCore *nickcore) : Flags<
|
||||
this->time_registered = this->last_seen = Anope::CurTime;
|
||||
this->nick = nickname;
|
||||
this->nc = nickcore;
|
||||
this->nc->aliases.push_back(this);
|
||||
nickcore->aliases.push_back(this);
|
||||
|
||||
NickAliasList[this->nick] = this;
|
||||
(*NickAliasList)[this->nick] = this;
|
||||
|
||||
if (this->nc->o == NULL)
|
||||
{
|
||||
Oper *o = Oper::Find(this->nick);
|
||||
if (o == NULL)
|
||||
o = Oper::Find(this->nc->display);
|
||||
this->nc->o = o;
|
||||
nickcore->o = o;
|
||||
if (this->nc->o != NULL)
|
||||
Log() << "Tied oper " << this->nc->display << " to type " << this->nc->o->ot->GetName();
|
||||
}
|
||||
@@ -63,7 +64,7 @@ NickAlias::~NickAlias()
|
||||
if (this->nc)
|
||||
{
|
||||
/* Next: see if our core is still useful. */
|
||||
std::list<NickAlias *>::iterator it = std::find(this->nc->aliases.begin(), this->nc->aliases.end(), this);
|
||||
std::list<serialize_obj<NickAlias> >::iterator it = std::find(this->nc->aliases.begin(), this->nc->aliases.end(), this);
|
||||
if (it != this->nc->aliases.end())
|
||||
this->nc->aliases.erase(it);
|
||||
if (this->nc->aliases.empty())
|
||||
@@ -80,7 +81,7 @@ NickAlias::~NickAlias()
|
||||
}
|
||||
|
||||
/* Remove us from the aliases list */
|
||||
NickAliasList.erase(this->nick);
|
||||
NickAliasList->erase(this->nick);
|
||||
}
|
||||
|
||||
/** Release a nick from being held. This can be called from the core (ns_release)
|
||||
@@ -242,16 +243,16 @@ time_t NickAlias::GetVhostCreated() const
|
||||
return this->vhost_created;
|
||||
}
|
||||
|
||||
Anope::string NickAlias::serialize_name() const
|
||||
const Anope::string NickAlias::serialize_name() const
|
||||
{
|
||||
return "NickAlias";
|
||||
}
|
||||
|
||||
Serializable::serialized_data NickAlias::serialize()
|
||||
Serialize::Data NickAlias::serialize() const
|
||||
{
|
||||
serialized_data data;
|
||||
Serialize::Data data;
|
||||
|
||||
data["nick"].setKey().setMax(Config->NickLen) << this->nick;
|
||||
data["nick"].setMax(Config->NickLen) << this->nick;
|
||||
data["last_quit"] << this->last_quit;
|
||||
data["last_realname"] << this->last_realname;
|
||||
data["last_usermask"] << this->last_usermask;
|
||||
@@ -272,18 +273,21 @@ Serializable::serialized_data NickAlias::serialize()
|
||||
return data;
|
||||
}
|
||||
|
||||
void NickAlias::unserialize(serialized_data &data)
|
||||
Serializable* NickAlias::unserialize(Serializable *obj, Serialize::Data &data)
|
||||
{
|
||||
NickCore *core = findcore(data["nc"].astr());
|
||||
if (core == NULL)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
NickAlias *na = findnick(data["nick"].astr());
|
||||
if (na == NULL)
|
||||
NickAlias *na;
|
||||
if (obj)
|
||||
na = debug_cast<NickAlias *>(obj);
|
||||
else
|
||||
na = new NickAlias(data["nick"].astr(), core);
|
||||
else if (na->nc != core)
|
||||
|
||||
if (na->nc != core)
|
||||
{
|
||||
std::list<NickAlias *>::iterator it = std::find(na->nc->aliases.begin(), na->nc->aliases.end(), na);
|
||||
std::list<serialize_obj<NickAlias> >::iterator it = std::find(na->nc->aliases.begin(), na->nc->aliases.end(), na);
|
||||
if (it != na->nc->aliases.end())
|
||||
na->nc->aliases.erase(it);
|
||||
|
||||
@@ -293,7 +297,7 @@ void NickAlias::unserialize(serialized_data &data)
|
||||
change_core_display(na->nc);
|
||||
|
||||
na->nc = core;
|
||||
na->nc->aliases.push_back(na);
|
||||
core->aliases.push_back(na);
|
||||
}
|
||||
|
||||
data["last_quit"] >> na->last_quit;
|
||||
@@ -307,5 +311,6 @@ void NickAlias::unserialize(serialized_data &data)
|
||||
time_t vhost_time;
|
||||
data["vhost_time"] >> vhost_time;
|
||||
na->SetVhost(data["vhost_ident"].astr(), data["vhost_host"].astr(), data["vhost_creator"].astr(), vhost_time);
|
||||
return na;
|
||||
}
|
||||
|
||||
|
||||
+22
-14
@@ -14,6 +14,8 @@
|
||||
#include "account.h"
|
||||
#include "config.h"
|
||||
|
||||
serialize_checker<nickcore_map> NickCoreList("NickCore");
|
||||
|
||||
/** Default constructor
|
||||
* @param display The display nick
|
||||
*/
|
||||
@@ -35,7 +37,7 @@ NickCore::NickCore(const Anope::string &coredisplay) : Flags<NickCoreFlag, NI_EN
|
||||
if (Config->NSDefFlags.HasFlag(static_cast<NickCoreFlag>(t)))
|
||||
this->SetFlag(static_cast<NickCoreFlag>(t));
|
||||
|
||||
NickCoreList[this->display] = this;
|
||||
(*NickCoreList)[this->display] = this;
|
||||
}
|
||||
|
||||
/** Default destructor
|
||||
@@ -45,29 +47,29 @@ NickCore::~NickCore()
|
||||
FOREACH_MOD(I_OnDelCore, OnDelCore(this));
|
||||
|
||||
/* Remove the core from the list */
|
||||
NickCoreList.erase(this->display);
|
||||
NickCoreList->erase(this->display);
|
||||
|
||||
/* Clear access before deleting display name, we want to be able to use the display name in the clear access event */
|
||||
this->ClearAccess();
|
||||
|
||||
if (!this->memos.memos.empty())
|
||||
if (!this->memos.memos->empty())
|
||||
{
|
||||
for (unsigned i = 0, end = this->memos.memos.size(); i < end; ++i)
|
||||
delete this->memos.memos[i];
|
||||
this->memos.memos.clear();
|
||||
for (unsigned i = 0, end = this->memos.memos->size(); i < end; ++i)
|
||||
this->memos.GetMemo(i)->destroy();
|
||||
this->memos.memos->clear();
|
||||
}
|
||||
}
|
||||
|
||||
Anope::string NickCore::serialize_name() const
|
||||
const Anope::string NickCore::serialize_name() const
|
||||
{
|
||||
return "NickCore";
|
||||
}
|
||||
|
||||
Serializable::serialized_data NickCore::serialize()
|
||||
Serialize::Data NickCore::serialize() const
|
||||
{
|
||||
serialized_data data;
|
||||
Serialize::Data data;
|
||||
|
||||
data["display"].setKey().setMax(Config->NickLen) << this->display;
|
||||
data["display"].setMax(Config->NickLen) << this->display;
|
||||
data["pass"] << this->pass;
|
||||
data["email"] << this->email;
|
||||
data["greet"] << this->greet;
|
||||
@@ -84,11 +86,15 @@ Serializable::serialized_data NickCore::serialize()
|
||||
return data;
|
||||
}
|
||||
|
||||
void NickCore::unserialize(serialized_data &data)
|
||||
Serializable* NickCore::unserialize(Serializable *obj, Serialize::Data &data)
|
||||
{
|
||||
NickCore *nc = findcore(data["display"].astr());
|
||||
if (nc == NULL)
|
||||
NickCore *nc;
|
||||
|
||||
if (obj)
|
||||
nc = debug_cast<NickCore *>(obj);
|
||||
else
|
||||
nc = new NickCore(data["display"].astr());
|
||||
|
||||
data["pass"] >> nc->pass;
|
||||
data["email"] >> nc->email;
|
||||
data["greet"] >> nc->greet;
|
||||
@@ -119,6 +125,8 @@ void NickCore::unserialize(serialized_data &data)
|
||||
while (sep.GetToken(buf))
|
||||
nc->memos.ignores.push_back(buf);
|
||||
}
|
||||
|
||||
return nc;
|
||||
}
|
||||
|
||||
bool NickCore::IsServicesOper() const
|
||||
@@ -178,7 +186,7 @@ Anope::string NickCore::GetCert(unsigned entry) const
|
||||
return this->cert[entry];
|
||||
}
|
||||
|
||||
bool NickCore::FindCert(const Anope::string &entry)
|
||||
bool NickCore::FindCert(const Anope::string &entry) const
|
||||
{
|
||||
for (unsigned i = 0, end = this->cert.size(); i < end; ++i)
|
||||
if (this->cert[i] == entry)
|
||||
|
||||
+15
-16
@@ -15,29 +15,28 @@
|
||||
#include "users.h"
|
||||
#include "protocol.h"
|
||||
|
||||
nickalias_map NickAliasList;
|
||||
nickcore_map NickCoreList;
|
||||
|
||||
NickAlias *findnick(const Anope::string &nick)
|
||||
NickAlias* findnick(const Anope::string &nick)
|
||||
{
|
||||
FOREACH_MOD(I_OnFindNick, OnFindNick(nick));
|
||||
|
||||
nickalias_map::const_iterator it = NickAliasList.find(nick);
|
||||
if (it != NickAliasList.end())
|
||||
nickalias_map::const_iterator it = NickAliasList->find(nick);
|
||||
if (it != NickAliasList->end())
|
||||
{
|
||||
it->second->QueueUpdate();
|
||||
return it->second;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
NickCore *findcore(const Anope::string &nick)
|
||||
NickCore* findcore(const Anope::string &nick)
|
||||
{
|
||||
FOREACH_MOD(I_OnFindCore, OnFindCore(nick));
|
||||
|
||||
nickcore_map::const_iterator it = NickCoreList.find(nick);
|
||||
if (it != NickCoreList.end())
|
||||
nickcore_map::const_iterator it = NickCoreList->find(nick);
|
||||
if (it != NickCoreList->end())
|
||||
{
|
||||
it->second->QueueUpdate();
|
||||
return it->second;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -81,16 +80,16 @@ void change_core_display(NickCore *nc, const Anope::string &newdisplay)
|
||||
FOREACH_MOD(I_OnChangeCoreDisplay, OnChangeCoreDisplay(nc, newdisplay));
|
||||
|
||||
/* Remove the core from the list */
|
||||
NickCoreList.erase(nc->display);
|
||||
NickCoreList->erase(nc->display);
|
||||
|
||||
nc->display = newdisplay;
|
||||
|
||||
NickCoreList[nc->display] = nc;
|
||||
(*NickCoreList)[nc->display] = nc;
|
||||
}
|
||||
|
||||
void change_core_display(NickCore *nc)
|
||||
{
|
||||
NickAlias *na;
|
||||
const NickAlias *na;
|
||||
if (nc->aliases.empty())
|
||||
return;
|
||||
na = nc->aliases.front();
|
||||
|
||||
+68
-40
@@ -22,7 +22,7 @@
|
||||
|
||||
/* List of XLine managers we check users against in XLineManager::CheckAll */
|
||||
std::list<XLineManager *> XLineManager::XLineManagers;
|
||||
std::multimap<Anope::string, XLine *, ci::less> XLineManager::XLinesByUID;
|
||||
serialize_checker<std::multimap<Anope::string, XLine *, ci::less> > XLineManager::XLinesByUID("XLine");
|
||||
|
||||
void XLine::InitRegex()
|
||||
{
|
||||
@@ -138,14 +138,14 @@ bool XLine::IsRegex() const
|
||||
return !this->Mask.empty() && this->Mask[0] == '/' && this->Mask[this->Mask.length() - 1] == '/';
|
||||
}
|
||||
|
||||
Anope::string XLine::serialize_name() const
|
||||
const Anope::string XLine::serialize_name() const
|
||||
{
|
||||
return "XLine";
|
||||
}
|
||||
|
||||
Serializable::serialized_data XLine::serialize()
|
||||
Serialize::Data XLine::serialize() const
|
||||
{
|
||||
serialized_data data;
|
||||
Serialize::Data data;
|
||||
|
||||
data["mask"] << this->Mask;
|
||||
data["by"] << this->By;
|
||||
@@ -159,19 +159,39 @@ Serializable::serialized_data XLine::serialize()
|
||||
return data;
|
||||
}
|
||||
|
||||
void XLine::unserialize(serialized_data &data)
|
||||
Serializable* XLine::unserialize(Serializable *obj, Serialize::Data &data)
|
||||
{
|
||||
service_reference<XLineManager> xlm("XLineManager", data["manager"].astr());
|
||||
if (!xlm)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
XLine *xl;
|
||||
if (obj)
|
||||
{
|
||||
xl = debug_cast<XLine *>(obj);
|
||||
data["mask"] >> xl->Mask;
|
||||
data["by"] >> xl->By;
|
||||
data["reason"] >> xl->Reason;
|
||||
data["uid"] >> xl->UID;
|
||||
|
||||
if (xlm != xl->manager)
|
||||
{
|
||||
xl->manager->DelXLine(xl);
|
||||
xlm->AddXLine(xl);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
time_t expires;
|
||||
data["expires"] >> expires;
|
||||
xl = new XLine(data["mask"].astr(), data["by"].astr(), expires, data["reason"].astr(), data["uid"].astr());
|
||||
xlm->AddXLine(xl);
|
||||
}
|
||||
|
||||
time_t expires;
|
||||
data["expires"] >> expires;
|
||||
XLine *xl = new XLine(data["mask"].astr(), data["by"].astr(), expires, data["reason"].astr(), data["uid"].astr());
|
||||
data["created"] >> xl->Created;
|
||||
xl->manager = xlm;
|
||||
|
||||
xlm->AddXLine(xl);
|
||||
return xl;
|
||||
}
|
||||
|
||||
/** Register a XLineManager, places it in XLineManagers for use in XLineManager::CheckAll
|
||||
@@ -220,7 +240,7 @@ Anope::string XLineManager::GenerateUID()
|
||||
{
|
||||
Anope::string id;
|
||||
int count = 0;
|
||||
while (id.empty() || XLinesByUID.count(id) > 0)
|
||||
while (id.empty() || XLinesByUID->count(id) > 0)
|
||||
{
|
||||
if (++count > 10)
|
||||
{
|
||||
@@ -244,7 +264,7 @@ Anope::string XLineManager::GenerateUID()
|
||||
|
||||
/** Constructor
|
||||
*/
|
||||
XLineManager::XLineManager(Module *creator, const Anope::string &xname, char t) : Service(creator, "XLineManager", xname), type(t)
|
||||
XLineManager::XLineManager(Module *creator, const Anope::string &xname, char t) : Service(creator, "XLineManager", xname), type(t), XLines("XLine")
|
||||
{
|
||||
}
|
||||
|
||||
@@ -269,7 +289,7 @@ const char &XLineManager::Type()
|
||||
*/
|
||||
size_t XLineManager::GetCount() const
|
||||
{
|
||||
return this->XLines.size();
|
||||
return this->XLines->size();
|
||||
}
|
||||
|
||||
/** Get the XLine vector
|
||||
@@ -285,10 +305,9 @@ const std::vector<XLine *> &XLineManager::GetList() const
|
||||
*/
|
||||
void XLineManager::AddXLine(XLine *x)
|
||||
{
|
||||
x->manager = this;
|
||||
if (!x->UID.empty())
|
||||
XLinesByUID.insert(std::make_pair(x->UID, x));
|
||||
this->XLines.push_back(x);
|
||||
XLinesByUID->insert(std::make_pair(x->UID, x));
|
||||
this->XLines->push_back(x);
|
||||
}
|
||||
|
||||
/** Delete an entry from this XLineManager
|
||||
@@ -297,25 +316,25 @@ void XLineManager::AddXLine(XLine *x)
|
||||
*/
|
||||
bool XLineManager::DelXLine(XLine *x)
|
||||
{
|
||||
std::vector<XLine *>::iterator it = std::find(this->XLines.begin(), this->XLines.end(), x);
|
||||
std::vector<XLine *>::iterator it = std::find(this->XLines->begin(), this->XLines->end(), x);
|
||||
|
||||
if (!x->UID.empty())
|
||||
{
|
||||
std::multimap<Anope::string, XLine *, ci::less>::iterator it2 = XLinesByUID.find(x->UID), it3 = XLinesByUID.upper_bound(x->UID);
|
||||
for (; it2 != XLinesByUID.end() && it2 != it3; ++it2)
|
||||
std::multimap<Anope::string, XLine *, ci::less>::iterator it2 = XLinesByUID->find(x->UID), it3 = XLinesByUID->upper_bound(x->UID);
|
||||
for (; it2 != XLinesByUID->end() && it2 != it3; ++it2)
|
||||
if (it2->second == x)
|
||||
{
|
||||
XLinesByUID.erase(it2);
|
||||
XLinesByUID->erase(it2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (it != this->XLines.end())
|
||||
if (it != this->XLines->end())
|
||||
{
|
||||
this->SendDel(x);
|
||||
|
||||
delete x;
|
||||
this->XLines.erase(it);
|
||||
x->destroy();
|
||||
this->XLines->erase(it);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -327,25 +346,28 @@ bool XLineManager::DelXLine(XLine *x)
|
||||
* @param index The index
|
||||
* @return The XLine, or NULL if the index is out of bounds
|
||||
*/
|
||||
XLine *XLineManager::GetEntry(unsigned index)
|
||||
XLine* XLineManager::GetEntry(unsigned index)
|
||||
{
|
||||
if (index >= this->XLines.size())
|
||||
if (index >= this->XLines->size())
|
||||
return NULL;
|
||||
|
||||
return this->XLines[index];
|
||||
XLine *x = this->XLines->at(index);
|
||||
x->QueueUpdate();
|
||||
return x;
|
||||
}
|
||||
|
||||
/** Clear the XLine vector
|
||||
*/
|
||||
void XLineManager::Clear()
|
||||
{
|
||||
for (unsigned i = 0; i < this->XLines.size(); ++i)
|
||||
for (unsigned i = 0; i < this->XLines->size(); ++i)
|
||||
{
|
||||
if (!this->XLines[i]->UID.empty())
|
||||
XLinesByUID.erase(this->XLines[i]->UID);
|
||||
delete this->XLines[i];
|
||||
XLine *x = this->XLines->at(i);
|
||||
if (!x->UID.empty())
|
||||
XLinesByUID->erase(x->UID);
|
||||
x->destroy();
|
||||
}
|
||||
this->XLines.clear();
|
||||
this->XLines->clear();
|
||||
}
|
||||
|
||||
/** Checks if a mask can/should be added to the XLineManager
|
||||
@@ -406,19 +428,25 @@ bool XLineManager::CanAdd(CommandSource &source, const Anope::string &mask, time
|
||||
* @param mask The mask
|
||||
* @return The XLine the user matches, or NULL
|
||||
*/
|
||||
XLine *XLineManager::HasEntry(const Anope::string &mask)
|
||||
XLine* XLineManager::HasEntry(const Anope::string &mask)
|
||||
{
|
||||
std::map<Anope::string, XLine *, ci::less>::iterator it = XLinesByUID.find(mask);
|
||||
if (it != XLinesByUID.end())
|
||||
for (std::map<Anope::string, XLine *, ci::less>::iterator it2 = XLinesByUID.upper_bound(mask); it != it2; ++it)
|
||||
std::map<Anope::string, XLine *, ci::less>::iterator it = XLinesByUID->find(mask);
|
||||
if (it != XLinesByUID->end())
|
||||
for (std::map<Anope::string, XLine *, ci::less>::iterator it2 = XLinesByUID->upper_bound(mask); it != it2; ++it)
|
||||
if (it->second->manager == NULL || it->second->manager == this)
|
||||
{
|
||||
it->second->QueueUpdate();
|
||||
return it->second;
|
||||
for (unsigned i = 0, end = this->XLines.size(); i < end; ++i)
|
||||
}
|
||||
for (unsigned i = 0, end = this->XLines->size(); i < end; ++i)
|
||||
{
|
||||
XLine *x = this->XLines[i];
|
||||
XLine *x = this->XLines->at(i);
|
||||
|
||||
if (x->Mask.equals_ci(mask))
|
||||
{
|
||||
x->QueueUpdate();
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -430,9 +458,9 @@ XLine *XLineManager::HasEntry(const Anope::string &mask)
|
||||
*/
|
||||
XLine *XLineManager::CheckAllXLines(User *u)
|
||||
{
|
||||
for (unsigned i = this->XLines.size(); i > 0; --i)
|
||||
for (unsigned i = this->XLines->size(); i > 0; --i)
|
||||
{
|
||||
XLine *x = this->XLines[i - 1];
|
||||
XLine *x = this->XLines->at(i - 1);
|
||||
|
||||
if (x->Expires && x->Expires < Anope::CurTime)
|
||||
{
|
||||
@@ -454,7 +482,7 @@ XLine *XLineManager::CheckAllXLines(User *u)
|
||||
/** Called when an XLine expires
|
||||
* @param x The xline
|
||||
*/
|
||||
void XLineManager::OnExpire(XLine *x)
|
||||
void XLineManager::OnExpire(const XLine *x)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -413,7 +413,7 @@ bool IRCdMessage::OnPrivmsg(const Anope::string &source, const std::vector<Anope
|
||||
{
|
||||
Log() << message << ": user record for " << source << " not found";
|
||||
|
||||
BotInfo *bi = findbot(receiver);
|
||||
const BotInfo *bi = findbot(receiver);
|
||||
if (bi)
|
||||
ircdproto->SendMessage(bi, source, "%s", "Internal error - unable to process request.");
|
||||
|
||||
@@ -443,7 +443,7 @@ bool IRCdMessage::OnPrivmsg(const Anope::string &source, const std::vector<Anope
|
||||
}
|
||||
else if (Config->UseStrictPrivMsg)
|
||||
{
|
||||
BotInfo *bi = findbot(receiver);
|
||||
const BotInfo *bi = findbot(receiver);
|
||||
if (!bi)
|
||||
return true;
|
||||
Log(LOG_DEBUG) << "Ignored PRIVMSG without @ from " << source;
|
||||
@@ -543,7 +543,7 @@ bool IRCdMessage::OnWhois(const Anope::string &source, const std::vector<Anope::
|
||||
User *u = finduser(params[0]);
|
||||
if (u && u->server == Me)
|
||||
{
|
||||
BotInfo *bi = findbot(u->nick);
|
||||
const BotInfo *bi = findbot(u->nick);
|
||||
ircdproto->SendNumeric(311, source, "%s %s %s * :%s", u->nick.c_str(), u->GetIdent().c_str(), u->host.c_str(), u->realname.c_str());
|
||||
if (bi)
|
||||
ircdproto->SendNumeric(307, source, "%s :is a registered nick", bi->nick.c_str());
|
||||
|
||||
+295
-198
File diff suppressed because it is too large
Load Diff
+73
-28
@@ -13,16 +13,17 @@
|
||||
#include "services.h"
|
||||
#include "anope.h"
|
||||
#include "serialize.h"
|
||||
#include "modules.h"
|
||||
|
||||
std::vector<Anope::string> SerializeType::type_order;
|
||||
Anope::map<SerializeType *> SerializeType::types;
|
||||
std::list<Serializable *> *Serializable::serizliable_items;
|
||||
std::list<Serializable *> *Serializable::serializable_items;
|
||||
|
||||
stringstream::stringstream() : std::stringstream(), type(Serialize::DT_TEXT), key(false), _max(0)
|
||||
stringstream::stringstream() : std::stringstream(), type(Serialize::DT_TEXT), _max(0)
|
||||
{
|
||||
}
|
||||
|
||||
stringstream::stringstream(const stringstream &ss) : std::stringstream(ss.str()), type(Serialize::DT_TEXT), key(false), _max(0)
|
||||
stringstream::stringstream(const stringstream &ss) : std::stringstream(ss.str()), type(Serialize::DT_TEXT), _max(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -37,6 +38,16 @@ std::istream &stringstream::operator>>(Anope::string &val)
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool stringstream::operator==(const stringstream &other) const
|
||||
{
|
||||
return this->astr() == other.astr();
|
||||
}
|
||||
|
||||
bool stringstream::operator!=(const stringstream &other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
stringstream &stringstream::setType(Serialize::DataType t)
|
||||
{
|
||||
this->type = t;
|
||||
@@ -48,17 +59,6 @@ Serialize::DataType stringstream::getType() const
|
||||
return this->type;
|
||||
}
|
||||
|
||||
stringstream &stringstream::setKey()
|
||||
{
|
||||
this->key = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool stringstream::getKey() const
|
||||
{
|
||||
return this->key;
|
||||
}
|
||||
|
||||
stringstream &stringstream::setMax(unsigned m)
|
||||
{
|
||||
this->_max = m;
|
||||
@@ -70,25 +70,30 @@ unsigned stringstream::getMax() const
|
||||
return this->_max;
|
||||
}
|
||||
|
||||
Serializable::Serializable()
|
||||
Serializable::Serializable() : id(0)
|
||||
{
|
||||
if (serizliable_items == NULL)
|
||||
serizliable_items = new std::list<Serializable *>();
|
||||
serizliable_items->push_back(this);
|
||||
this->s_iter = serizliable_items->end();
|
||||
if (serializable_items == NULL)
|
||||
serializable_items = new std::list<Serializable *>();
|
||||
serializable_items->push_back(this);
|
||||
|
||||
this->s_iter = serializable_items->end();
|
||||
--this->s_iter;
|
||||
|
||||
FOREACH_MOD(I_OnSerializableConstruct, OnSerializableConstruct(this));
|
||||
}
|
||||
|
||||
Serializable::Serializable(const Serializable &)
|
||||
Serializable::Serializable(const Serializable &) : id(0)
|
||||
{
|
||||
serizliable_items->push_back(this);
|
||||
this->s_iter = serizliable_items->end();
|
||||
serializable_items->push_back(this);
|
||||
this->s_iter = serializable_items->end();
|
||||
--this->s_iter;
|
||||
|
||||
FOREACH_MOD(I_OnSerializableConstruct, OnSerializableConstruct(this));
|
||||
}
|
||||
|
||||
Serializable::~Serializable()
|
||||
{
|
||||
serizliable_items->erase(this->s_iter);
|
||||
serializable_items->erase(this->s_iter);
|
||||
}
|
||||
|
||||
Serializable &Serializable::operator=(const Serializable &)
|
||||
@@ -96,12 +101,37 @@ Serializable &Serializable::operator=(const Serializable &)
|
||||
return *this;
|
||||
}
|
||||
|
||||
const std::list<Serializable *> &Serializable::GetItems()
|
||||
void Serializable::destroy()
|
||||
{
|
||||
return *serizliable_items;
|
||||
if (!this)
|
||||
return;
|
||||
|
||||
FOREACH_MOD(I_OnSerializableDestruct, OnSerializableDestruct(this));
|
||||
|
||||
delete this;
|
||||
}
|
||||
|
||||
SerializeType::SerializeType(const Anope::string &n, unserialize_func f) : name(n), unserialize(f)
|
||||
void Serializable::QueueUpdate()
|
||||
{
|
||||
FOREACH_MOD(I_OnSerializableUpdate, OnSerializableUpdate(this));
|
||||
}
|
||||
|
||||
bool Serializable::IsCached()
|
||||
{
|
||||
return this->last_commit == this->serialize();
|
||||
}
|
||||
|
||||
void Serializable::UpdateCache()
|
||||
{
|
||||
this->last_commit = this->serialize();
|
||||
}
|
||||
|
||||
const std::list<Serializable *> &Serializable::GetItems()
|
||||
{
|
||||
return *serializable_items;
|
||||
}
|
||||
|
||||
SerializeType::SerializeType(const Anope::string &n, unserialize_func f) : name(n), unserialize(f), timestamp(0)
|
||||
{
|
||||
type_order.push_back(this->name);
|
||||
types[this->name] = this;
|
||||
@@ -120,9 +150,24 @@ const Anope::string &SerializeType::GetName()
|
||||
return this->name;
|
||||
}
|
||||
|
||||
void SerializeType::Create(Serializable::serialized_data &data)
|
||||
Serializable *SerializeType::Unserialize(Serializable *obj, Serialize::Data &data)
|
||||
{
|
||||
this->unserialize(data);
|
||||
return this->unserialize(obj, data);
|
||||
}
|
||||
|
||||
void SerializeType::Check()
|
||||
{
|
||||
FOREACH_MOD(I_OnSerializeCheck, OnSerializeCheck(this));
|
||||
}
|
||||
|
||||
time_t SerializeType::GetTimestamp() const
|
||||
{
|
||||
return this->timestamp;
|
||||
}
|
||||
|
||||
void SerializeType::UpdateTimestamp()
|
||||
{
|
||||
this->timestamp = Anope::CurTime;
|
||||
}
|
||||
|
||||
SerializeType *SerializeType::Find(const Anope::string &name)
|
||||
|
||||
+3
-3
@@ -49,7 +49,7 @@ Server::Server(Server *uplink, const Anope::string &name, unsigned hops, const A
|
||||
if (Me == this->UplinkServer && !this->HasFlag(SERVER_JUPED))
|
||||
{
|
||||
/* Now do mode related stuff as we know what modes exist .. */
|
||||
for (botinfo_map::iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it)
|
||||
for (botinfo_map::iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it)
|
||||
{
|
||||
BotInfo *bi = it->second;
|
||||
Anope::string modes = !bi->botmodes.empty() ? ("+" + bi->botmodes) : ircd->pseudoclient_mode;
|
||||
@@ -276,7 +276,7 @@ void Server::Sync(bool SyncLinks)
|
||||
|
||||
if (this->GetUplink() && this->GetUplink() == Me)
|
||||
{
|
||||
for (registered_channel_map::iterator it = RegisteredChannelList.begin(), it_end = RegisteredChannelList.end(); it != it_end; ++it)
|
||||
for (registered_channel_map::iterator it = RegisteredChannelList->begin(), it_end = RegisteredChannelList->end(); it != it_end; ++it)
|
||||
{
|
||||
ChannelInfo *ci = it->second;
|
||||
if (ci->HasFlag(CI_PERSIST))
|
||||
@@ -353,7 +353,7 @@ bool Server::IsULined() const
|
||||
* @param source The source of the message
|
||||
* @param message The message
|
||||
*/
|
||||
void Server::Notice(BotInfo *source, const Anope::string &message)
|
||||
void Server::Notice(const BotInfo *source, const Anope::string &message)
|
||||
{
|
||||
if (Config->NSDefFlags.HasFlag(NI_MSG))
|
||||
ircdproto->SendGlobalPrivmsg(source, this, message);
|
||||
|
||||
+18
-19
@@ -41,7 +41,6 @@ User::User(const Anope::string &snick, const Anope::string &sident, const Anope:
|
||||
|
||||
/* we used to do this by calloc, no more. */
|
||||
server = NULL;
|
||||
nc = NULL;
|
||||
invalid_pw_count = invalid_pw_time = lastmemosend = lastnickreg = lastmail = 0;
|
||||
OnAccess = false;
|
||||
timestamp = my_signon = Anope::CurTime;
|
||||
@@ -81,7 +80,7 @@ void User::SetNewNick(const Anope::string &newnick)
|
||||
UserListByNick[this->nick] = this;
|
||||
|
||||
OnAccess = false;
|
||||
NickAlias *na = findnick(this->nick);
|
||||
const NickAlias *na = findnick(this->nick);
|
||||
if (na)
|
||||
OnAccess = is_on_access(this, na->nc);
|
||||
}
|
||||
@@ -225,7 +224,7 @@ User::~User()
|
||||
Log(LOG_DEBUG_2) << "User::~User() done";
|
||||
}
|
||||
|
||||
void User::SendMessage(BotInfo *source, const char *fmt, ...)
|
||||
void User::SendMessage(const BotInfo *source, const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
char buf[BUFSIZE] = "";
|
||||
@@ -240,7 +239,7 @@ void User::SendMessage(BotInfo *source, const char *fmt, ...)
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void User::SendMessage(BotInfo *source, Anope::string msg)
|
||||
void User::SendMessage(const BotInfo *source, Anope::string msg)
|
||||
{
|
||||
const char *translated_message = translate(this, msg.c_str());
|
||||
|
||||
@@ -318,7 +317,7 @@ void User::SendMessage(BotInfo *source, Anope::string msg)
|
||||
*/
|
||||
void User::Collide(NickAlias *na)
|
||||
{
|
||||
BotInfo *bi = findbot(Config->NickServ);
|
||||
const BotInfo *bi = findbot(Config->NickServ);
|
||||
if (!bi)
|
||||
return;
|
||||
if (na)
|
||||
@@ -372,15 +371,15 @@ void User::Identify(NickAlias *na)
|
||||
this->Login(na->nc);
|
||||
ircdproto->SendLogin(this);
|
||||
|
||||
NickAlias *this_na = findnick(this->nick);
|
||||
if (!Config->NoNicknameOwnership && this_na && this_na->nc == na->nc && na->nc->HasFlag(NI_UNCONFIRMED) == false)
|
||||
const NickAlias *this_na = findnick(this->nick);
|
||||
if (!Config->NoNicknameOwnership && this_na && this_na->nc == *na->nc && na->nc->HasFlag(NI_UNCONFIRMED) == false)
|
||||
this->SetMode(findbot(Config->NickServ), UMODE_REGISTERED);
|
||||
|
||||
FOREACH_MOD(I_OnNickIdentify, OnNickIdentify(this));
|
||||
|
||||
if (this->IsServicesOper())
|
||||
{
|
||||
BotInfo *bi = findbot(Config->OperServ);
|
||||
const BotInfo *bi = findbot(Config->OperServ);
|
||||
if (!this->nc->o->ot->modes.empty())
|
||||
{
|
||||
this->SetModes(bi, "%s", this->nc->o->ot->modes.c_str());
|
||||
@@ -427,7 +426,7 @@ void User::Logout()
|
||||
/** Get the account the user is logged in using
|
||||
* @reurn The account or NULL
|
||||
*/
|
||||
NickCore *User::Account()
|
||||
NickCore *User::Account() const
|
||||
{
|
||||
return this->nc;
|
||||
}
|
||||
@@ -436,13 +435,13 @@ NickCore *User::Account()
|
||||
* @param CheckNick True to check if the user is identified to the nickname they are on too
|
||||
* @return true or false
|
||||
*/
|
||||
bool User::IsIdentified(bool CheckNick)
|
||||
bool User::IsIdentified(bool CheckNick) const
|
||||
{
|
||||
if (CheckNick && this->nc)
|
||||
{
|
||||
NickAlias *na = findnick(this->nc->display);
|
||||
|
||||
if (na && na->nc == this->nc)
|
||||
if (na && *na->nc == *this->nc)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@@ -455,11 +454,11 @@ bool User::IsIdentified(bool CheckNick)
|
||||
* @param CheckSecure Only returns true if the user has secure off
|
||||
* @return true or false
|
||||
*/
|
||||
bool User::IsRecognized(bool CheckSecure)
|
||||
bool User::IsRecognized(bool CheckSecure) const
|
||||
{
|
||||
if (CheckSecure && OnAccess)
|
||||
{
|
||||
NickAlias *na = findnick(this->nick);
|
||||
const NickAlias *na = findnick(this->nick);
|
||||
|
||||
if (!na || na->nc->HasFlag(NI_SECURE))
|
||||
return false;
|
||||
@@ -589,7 +588,7 @@ void User::RemoveModeInternal(UserMode *um)
|
||||
* @param um The user mode
|
||||
* @param Param Optional param for the mode
|
||||
*/
|
||||
void User::SetMode(BotInfo *bi, UserMode *um, const Anope::string &Param)
|
||||
void User::SetMode(const BotInfo *bi, UserMode *um, const Anope::string &Param)
|
||||
{
|
||||
if (!um || HasMode(um->Name))
|
||||
return;
|
||||
@@ -603,7 +602,7 @@ void User::SetMode(BotInfo *bi, UserMode *um, const Anope::string &Param)
|
||||
* @param Name The mode name
|
||||
* @param param Optional param for the mode
|
||||
*/
|
||||
void User::SetMode(BotInfo *bi, UserModeName Name, const Anope::string &Param)
|
||||
void User::SetMode(const BotInfo *bi, UserModeName Name, const Anope::string &Param)
|
||||
{
|
||||
SetMode(bi, ModeManager::FindUserModeByName(Name), Param);
|
||||
}
|
||||
@@ -612,7 +611,7 @@ void User::SetMode(BotInfo *bi, UserModeName Name, const Anope::string &Param)
|
||||
* @param bi The client setting the mode
|
||||
* @param um The user mode
|
||||
*/
|
||||
void User::RemoveMode(BotInfo *bi, UserMode *um)
|
||||
void User::RemoveMode(const BotInfo *bi, UserMode *um)
|
||||
{
|
||||
if (!um || !HasMode(um->Name))
|
||||
return;
|
||||
@@ -625,7 +624,7 @@ void User::RemoveMode(BotInfo *bi, UserMode *um)
|
||||
* @param bi The client setting the mode
|
||||
* @param Name The mode name
|
||||
*/
|
||||
void User::RemoveMode(BotInfo *bi, UserModeName Name)
|
||||
void User::RemoveMode(const BotInfo *bi, UserModeName Name)
|
||||
{
|
||||
RemoveMode(bi, ModeManager::FindUserModeByName(Name));
|
||||
}
|
||||
@@ -634,7 +633,7 @@ void User::RemoveMode(BotInfo *bi, UserModeName Name)
|
||||
* @param bi The client setting the mode
|
||||
* @param umodes The modes
|
||||
*/
|
||||
void User::SetModes(BotInfo *bi, const char *umodes, ...)
|
||||
void User::SetModes(const BotInfo *bi, const char *umodes, ...)
|
||||
{
|
||||
char buf[BUFSIZE] = "";
|
||||
va_list args;
|
||||
@@ -761,7 +760,7 @@ Anope::string User::GetModes() const
|
||||
* @param c The channel
|
||||
* @return The channel container, or NULL
|
||||
*/
|
||||
ChannelContainer *User::FindChannel(const Channel *c)
|
||||
ChannelContainer *User::FindChannel(const Channel *c) const
|
||||
{
|
||||
for (UChannelList::const_iterator it = this->chans.begin(), it_end = this->chans.end(); it != it_end; ++it)
|
||||
if ((*it)->chan == c)
|
||||
|
||||
Reference in New Issue
Block a user