diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/access.cpp | 35 | ||||
| -rw-r--r-- | src/actions.cpp | 2 | ||||
| -rw-r--r-- | src/bots.cpp | 55 | ||||
| -rw-r--r-- | src/botserv.cpp | 16 | ||||
| -rw-r--r-- | src/channels.cpp | 76 | ||||
| -rw-r--r-- | src/chanserv.cpp | 19 | ||||
| -rw-r--r-- | src/config.cpp | 31 | ||||
| -rw-r--r-- | src/init.cpp | 2 | ||||
| -rw-r--r-- | src/language.cpp | 2 | ||||
| -rw-r--r-- | src/logger.cpp | 39 | ||||
| -rw-r--r-- | src/mail.cpp | 2 | ||||
| -rw-r--r-- | src/main.cpp | 4 | ||||
| -rw-r--r-- | src/memoserv.cpp | 53 | ||||
| -rw-r--r-- | src/messages.cpp | 2 | ||||
| -rw-r--r-- | src/misc.cpp | 6 | ||||
| -rw-r--r-- | src/modes.cpp | 21 | ||||
| -rw-r--r-- | src/nickalias.cpp | 43 | ||||
| -rw-r--r-- | src/nickcore.cpp | 36 | ||||
| -rw-r--r-- | src/nickserv.cpp | 31 | ||||
| -rw-r--r-- | src/operserv.cpp | 108 | ||||
| -rw-r--r-- | src/protocol.cpp | 6 | ||||
| -rw-r--r-- | src/regchannel.cpp | 495 | ||||
| -rw-r--r-- | src/serialize.cpp | 95 | ||||
| -rw-r--r-- | src/servers.cpp | 6 | ||||
| -rw-r--r-- | src/users.cpp | 37 |
25 files changed, 726 insertions, 496 deletions
diff --git a/src/access.cpp b/src/access.cpp index 4ed19c7fe..1100d8e7c 100644 --- a/src/access.cpp +++ b/src/access.cpp @@ -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) diff --git a/src/actions.cpp b/src/actions.cpp index 5536596e6..657973e3c 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -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; diff --git a/src/bots.cpp b/src/bots.cpp index 242b7d4f2..e9d279c3e 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -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) { diff --git a/src/botserv.cpp b/src/botserv.cpp index 962f2b80e..4ec6465a1 100644 --- a/src/botserv.cpp +++ b/src/botserv.cpp @@ -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; } diff --git a/src/channels.cpp b/src/channels.cpp index 6035d1657..283da3440 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -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; diff --git a/src/chanserv.cpp b/src/chanserv.cpp index fd7fb88f9..67b77a432 100644 --- a/src/chanserv.cpp +++ b/src/chanserv.cpp @@ -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; diff --git a/src/config.cpp b/src/config.cpp index 790f5c82f..66d8f6a8c 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -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; diff --git a/src/init.cpp b/src/init.cpp index 55ad04bae..08d4aed08 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -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. */ diff --git a/src/language.cpp b/src/language.cpp index 1a374c0bc..8b680077b 100644 --- a/src/language.cpp +++ b/src/language.cpp @@ -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); } diff --git a/src/logger.cpp b/src/logger.cpp index fb720963c..2b27e1478 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -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); } diff --git a/src/mail.cpp b/src/mail.cpp index cc1541640..aaf564bc6 100644 --- a/src/mail.cpp +++ b/src/mail.cpp @@ -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; diff --git a/src/main.cpp b/src/main.cpp index 303b6b076..cacfec814 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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); |
