diff options
32 files changed, 122 insertions, 158 deletions
diff --git a/include/anope.h b/include/anope.h index 1a8612241..07cd97da5 100644 --- a/include/anope.h +++ b/include/anope.h @@ -20,6 +20,9 @@ class Message; namespace Anope { + template<typename T> class map : public std::map<string, T> { }; + template<typename T> class insensitive_map : public std::map<string, T, std::less<ci::string> > { }; + /** * A wrapper string class around all the other string classes, this class will * allow us to only require one type of string everywhere that can be converted diff --git a/include/bots.h b/include/bots.h index 4253802ff..bcbbc83d7 100644 --- a/include/bots.h +++ b/include/bots.h @@ -12,8 +12,8 @@ class BotInfo; -extern CoreExport patricia_tree<BotInfo *, ci::ci_char_traits> BotListByNick; -extern CoreExport patricia_tree<BotInfo *> BotListByUID; +extern CoreExport Anope::insensitive_map<BotInfo *> BotListByNick; +extern CoreExport Anope::map<BotInfo *> BotListByUID; /** Flags settable on a bot */ diff --git a/include/hashcomp.h b/include/hashcomp.h index 6e237f7a2..9c1f0d2dc 100644 --- a/include/hashcomp.h +++ b/include/hashcomp.h @@ -162,12 +162,6 @@ namespace irc * @return Pointer to the first occurance of c in s1 */ static const char *find(const char *s1, int n, char c); - - /** Convert a char to lowercase - * @param c1 The character to convert - * @return The lowercase version of the char - */ - static const char chartolower(char c1); }; /** This typedef declares irc::string based upon irc_char_traits. @@ -239,12 +233,6 @@ namespace ci * @return Pointer to the first occurance of c in s1 */ static const char *find(const char *s1, int n, char c); - - /** Convert a char to lowercase - * @param c1 The character to convert - * @return The lowercase version of the char - */ - static const char chartolower(char c1); }; /** This typedef declares ci::string based upon ci_char_traits. @@ -271,17 +259,6 @@ namespace ci namespace std { - /** The std_char_traits class is used for normal comparison of strings. - */ - struct CoreExport std_char_traits : char_traits<char> - { - /** Convert a char to lowercase - * @param c1 The character to convert - * @return The lowercase version of the char - */ - static const char chartolower(char c1); - }; - /** An overload for std::equal_to<ci::string> that uses Anope::string, passed for the fourth temmplate * argument for unordered_map */ diff --git a/include/services.h b/include/services.h index 75e21a5cf..15896ca83 100644 --- a/include/services.h +++ b/include/services.h @@ -202,7 +202,6 @@ extern "C" void __pfnBkCheck() {} #include <set> #include "anope.h" -#include "patricia.h" /** This class can be used on its own to represent an exception, or derived to represent a module-specific exception. * When a module whishes to abort, e.g. within a constructor, it should throw an exception using ModuleException or @@ -897,7 +896,7 @@ struct Exception /*************************************************************************/ -extern CoreExport patricia_tree<Session *> SessionList; +extern CoreExport Anope::map<Session *> SessionList; struct Session { diff --git a/include/users.h b/include/users.h index 9f6e250e5..dcfe219bf 100644 --- a/include/users.h +++ b/include/users.h @@ -8,8 +8,8 @@ #ifndef USERS_H #define USERS_H -extern CoreExport patricia_tree<User *, ci::ci_char_traits> UserListByNick; -extern CoreExport patricia_tree<User *> UserListByUID; +extern CoreExport Anope::insensitive_map<User *> UserListByNick; +extern CoreExport Anope::map<User *> UserListByUID; class CoreExport ChannelStatus : public Flags<ChannelModeName, CMODE_END * 2> { diff --git a/modules/core/bs_botlist.cpp b/modules/core/bs_botlist.cpp index bd2413b36..1310a6358 100644 --- a/modules/core/bs_botlist.cpp +++ b/modules/core/bs_botlist.cpp @@ -26,9 +26,9 @@ class CommandBSBotList : public Command User *u = source.u; unsigned count = 0; - for (patricia_tree<BotInfo *, ci::ci_char_traits>::iterator it(BotListByNick); it.next();) + for (Anope::insensitive_map<BotInfo *>::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it) { - BotInfo *bi = *it; + BotInfo *bi = it->second; if (!bi->HasFlag(BI_PRIVATE)) { @@ -43,9 +43,9 @@ class CommandBSBotList : public Command { source.Reply(_("Bots reserved to IRC operators:")); - for (patricia_tree<BotInfo *, ci::ci_char_traits>::iterator it(BotListByNick); it.next();) + for (Anope::insensitive_map<BotInfo *>::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it) { - BotInfo *bi = *it; + BotInfo *bi = it->second; if (bi->HasFlag(BI_PRIVATE)) { diff --git a/modules/core/cs_akick.cpp b/modules/core/cs_akick.cpp index bad0e6d22..e9e116cf5 100644 --- a/modules/core/cs_akick.cpp +++ b/modules/core/cs_akick.cpp @@ -213,9 +213,9 @@ class CommandCSAKick : public Command { /* Match against all currently online users with equal or * higher access. - Viper */ - for (patricia_tree<User *, ci::ci_char_traits>::iterator it(UserListByNick); it.next();) + for (Anope::insensitive_map<User *>::iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end; ++it) { - User *u2 = *it; + User *u2 = it->second; ChanAccess *u2_access = ci->GetAccess(nc), *u_access = ci->GetAccess(u); int16 u2_level = u2_access ? u2_access->level : 0, u_level = u_access ? u_access->level : 0; diff --git a/modules/core/db_plain.cpp b/modules/core/db_plain.cpp index 550f229a1..2bad313ca 100644 --- a/modules/core/db_plain.cpp +++ b/modules/core/db_plain.cpp @@ -782,9 +782,9 @@ class DBPlain : public Module FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteMetadata, na)); } - for (patricia_tree<BotInfo *, ci::ci_char_traits>::iterator it(BotListByNick); it.next();) + for (Anope::insensitive_map<BotInfo *>::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it) { - BotInfo *bi = *it; + BotInfo *bi = it->second; db_buffer << "BI " << bi->nick << " " << bi->GetIdent() << " " << bi->host << " " << bi->created << " " << bi->chancount << " :" << bi->realname << endl; if (bi->FlagCount()) diff --git a/modules/core/os_akill.cpp b/modules/core/os_akill.cpp index a6f40c9ed..6ccb33e92 100644 --- a/modules/core/os_akill.cpp +++ b/modules/core/os_akill.cpp @@ -176,8 +176,8 @@ class CommandOSAKill : public Command if (user) mask = "*@" + user->host; unsigned int affected = 0; - for (patricia_tree<User *, ci::ci_char_traits>::iterator it(UserListByNick); it.next();) - if (Anope::Match((*it)->GetIdent() + "@" + (*it)->host, mask)) + for (Anope::insensitive_map<User *>::iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) + if (Anope::Match(it->second->GetIdent() + "@" + it->second->host, mask)) ++affected; float percent = static_cast<float>(affected) / static_cast<float>(UserListByNick.size()) * 100.0; diff --git a/modules/core/os_noop.cpp b/modules/core/os_noop.cpp index 70aecdac2..a3269d121 100644 --- a/modules/core/os_noop.cpp +++ b/modules/core/os_noop.cpp @@ -39,11 +39,10 @@ class CommandOSNOOP : public Command source.Reply(_("All O:lines of \002%s\002 have been removed."), server.c_str()); /* Kill all the IRCops of the server */ - patricia_tree<User *, ci::ci_char_traits>::iterator it(UserListByNick); - for (bool next = it.next(); next;) + for (Anope::insensitive_map<User *>::iterator it = UserListByNick.begin(); it != UserListByNick.end();) { - User *u2 = *it; - next = it.next(); + User *u2 = it->second; + ++it; if (u2 && u2->HasMode(UMODE_OPER) && Anope::Match(u2->server->GetName(), server, true)) kill_user(Config->s_OperServ, u2, reason); diff --git a/modules/core/os_session.cpp b/modules/core/os_session.cpp index 2ea7e8242..8090efe10 100644 --- a/modules/core/os_session.cpp +++ b/modules/core/os_session.cpp @@ -139,9 +139,9 @@ class CommandOSSession : public Command source.Reply(_("Hosts with at least \002%d\002 sessions:"), mincount); source.Reply(_("Sessions Host")); - for (patricia_tree<Session *>::iterator it(SessionList); it.next();) + for (Anope::map<Session *>::iterator it = SessionList.begin(), it_end = SessionList.end(); it != it_end; ++it) { - Session *session = *it; + Session *session = it->second; if (session->count >= mincount) source.Reply(_("%6d %s"), session->count, session->host.c_str()); diff --git a/modules/core/os_snline.cpp b/modules/core/os_snline.cpp index 335599616..3cb9c39fd 100644 --- a/modules/core/os_snline.cpp +++ b/modules/core/os_snline.cpp @@ -190,8 +190,8 @@ class CommandOSSNLine : public Command if (mask[masklen - 1] == ' ') mask.erase(masklen - 1); unsigned int affected = 0; - for (patricia_tree<User *, ci::ci_char_traits>::iterator it(UserListByNick); it.next();) - if (Anope::Match((*it)->realname, mask)) + for (Anope::insensitive_map<User *>::iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) + if (Anope::Match(it->second->realname, mask)) ++affected; float percent = static_cast<float>(affected) / static_cast<float>(UserListByNick.size()) * 100.0; diff --git a/modules/core/os_sqline.cpp b/modules/core/os_sqline.cpp index c3d1da9e8..cf618107e 100644 --- a/modules/core/os_sqline.cpp +++ b/modules/core/os_sqline.cpp @@ -171,8 +171,8 @@ class CommandOSSQLine : public Command if (!mask.empty() && !reason.empty()) { unsigned int affected = 0; - for (patricia_tree<User *, ci::ci_char_traits>::iterator it(UserListByNick); it.next();) - if (Anope::Match((*it)->nick, mask)) + for (Anope::insensitive_map<User *>::iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) + if (Anope::Match(it->second->nick, mask)) ++affected; float percent = static_cast<float>(affected) / static_cast<float>(UserListByNick.size()) * 100.0; diff --git a/modules/core/os_szline.cpp b/modules/core/os_szline.cpp index 1998948e7..f57902fea 100644 --- a/modules/core/os_szline.cpp +++ b/modules/core/os_szline.cpp @@ -174,8 +174,8 @@ class CommandOSSZLine : public Command if (user && user->ip()) mask = user->ip.addr(); unsigned int affected = 0; - for (patricia_tree<User *, ci::ci_char_traits>::iterator it(UserListByNick); it.next();) - if ((*it)->ip() && Anope::Match((*it)->ip.addr(), mask)) + for (Anope::insensitive_map<User *>::iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) + if (it->second->ip() && Anope::Match(it->second->ip.addr(), mask)) ++affected; float percent = static_cast<float>(affected) / static_cast<float>(UserListByNick.size()) * 100.0; diff --git a/modules/core/os_userlist.cpp b/modules/core/os_userlist.cpp index 0525ecbbf..a511fbf25 100644 --- a/modules/core/os_userlist.cpp +++ b/modules/core/os_userlist.cpp @@ -53,9 +53,9 @@ class CommandOSUserList : public Command source.Reply(_("Users list:\n" "Nick Mask")); - for (patricia_tree<User *, ci::ci_char_traits>::iterator it(UserListByNick); it.next();) + for (Anope::insensitive_map<User *>::iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) { - User *u2 = *it; + User *u2 = it->second; if (!pattern.empty()) { diff --git a/modules/extra/db_mysql.cpp b/modules/extra/db_mysql.cpp index d8a6d934c..a6f83899e 100644 --- a/modules/extra/db_mysql.cpp +++ b/modules/extra/db_mysql.cpp @@ -640,9 +640,9 @@ class DBMySQL : public Module FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteChannelMetadata, CurChannel)); } - for (patricia_tree<BotInfo *, ci::ci_char_traits>::iterator it(BotListByNick); it.next();) + for (Anope::insensitive_map<BotInfo *>::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it) { - CurBot = *it; + CurBot = it->second; FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteBotMetadata, CurBot)); /* This is for the core bots, bots added by users are already handled by an event */ @@ -1222,8 +1222,8 @@ static void SaveDatabases() me->RunQuery("TRUNCATE TABLE `anope_bs_core`"); - for (patricia_tree<BotInfo *, ci::ci_char_traits>::iterator it(BotListByNick); it.next();) - me->OnBotCreate(*it); + for (Anope::insensitive_map<BotInfo *>::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it) + me->OnBotCreate(it->second); me->RunQuery("TRUNCATE TABLE `anope_cs_info`"); me->RunQuery("TRUNCATE TABLE `anope_bs_badwords`"); diff --git a/modules/protocol/inspircd12.cpp b/modules/protocol/inspircd12.cpp index ecac4a4f9..82d43434c 100644 --- a/modules/protocol/inspircd12.cpp +++ b/modules/protocol/inspircd12.cpp @@ -768,9 +768,9 @@ class ProtoInspIRCd : public Module void OnServerSync(Server *s) { - for (patricia_tree<User *, ci::ci_char_traits>::iterator it(UserListByNick); it.next();) + for (Anope::insensitive_map<User *>::iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) { - User *u = *it; + User *u = it->second; if (u->server == s && !u->IsIdentified()) validate_user(u); } diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp index 87fe74c69..575958bd8 100644 --- a/modules/protocol/inspircd20.cpp +++ b/modules/protocol/inspircd20.cpp @@ -759,9 +759,9 @@ class ProtoInspIRCd : public Module void OnServerSync(Server *s) { - for (patricia_tree<User *, ci::ci_char_traits>::iterator it(UserListByNick); it.next();) + for (Anope::insensitive_map<User *>::iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) { - User *u = *it; + User *u = it->second; if (u->server == s && !u->IsIdentified()) validate_user(u); } diff --git a/modules/protocol/ngircd.cpp b/modules/protocol/ngircd.cpp index 94b253a58..6e1f21feb 100644 --- a/modules/protocol/ngircd.cpp +++ b/modules/protocol/ngircd.cpp @@ -46,9 +46,13 @@ class ngIRCdProto : public IRCDProto void SendAkill(User *u, const XLine *x) { if (SGLine && u == NULL) - for (patricia_tree<User *, ci::ci_char_traits>::iterator it(UserListByNick); it.next();) - if (SGLine->Check(*it) != NULL) + for (Anope::insensitive_map<User *>::iterator it = UserListByNick.begin(); it != UserListByNick.end();) + { + u = it->second; + ++it; + if (SGLine->Check(u) != NULL) break; + } } void SendAkillDel(const XLine*) { } diff --git a/modules/protocol/plexus.cpp b/modules/protocol/plexus.cpp index edfdfeec4..3b299e962 100644 --- a/modules/protocol/plexus.cpp +++ b/modules/protocol/plexus.cpp @@ -644,9 +644,9 @@ class ProtoPlexus : public Module void OnServerSync(Server *s) { - for (patricia_tree<User *, ci::ci_char_traits>::iterator it(UserListByNick); it.next();) + for (Anope::insensitive_map<User *>::iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) { - User *u = *it; + User *u = it->second; if (u->server == s && !u->IsIdentified()) validate_user(u); } diff --git a/modules/protocol/ratbox.cpp b/modules/protocol/ratbox.cpp index a5f58057e..62a8d5a72 100644 --- a/modules/protocol/ratbox.cpp +++ b/modules/protocol/ratbox.cpp @@ -579,9 +579,9 @@ class ProtoRatbox : public Module void OnServerSync(Server *s) { - for (patricia_tree<User *, ci::ci_char_traits>::iterator it(UserListByNick); it.next();) + for (Anope::insensitive_map<User *>::iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) { - User *u = *it; + User *u = it->second; if (u->server == s && !u->IsIdentified()) validate_user(u); } diff --git a/src/bots.cpp b/src/bots.cpp index 85fcf8055..95a5c2aa5 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -9,8 +9,8 @@ #include "modules.h" #include "commands.h" -patricia_tree<BotInfo *, ci::ci_char_traits> BotListByNick; -patricia_tree<BotInfo *> BotListByUID; +Anope::insensitive_map<BotInfo *> BotListByNick; +Anope::map<BotInfo *> BotListByUID; BotInfo *BotServ = NULL; BotInfo *ChanServ = NULL; @@ -46,9 +46,9 @@ BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const A else this->UnsetFlag(BI_CORE); - BotListByNick.insert(this->nick, this); + BotListByNick[this->nick] = this; if (!this->uid.empty()) - BotListByUID.insert(this->uid, this); + BotListByUID[this->uid] = this; // If we're synchronised with the uplink already, send the bot. if (Me && Me->IsSynced()) @@ -118,8 +118,8 @@ void BotInfo::SetNewNick(const Anope::string &newnick) this->nick = newnick; - UserListByNick.insert(this->nick, this); - BotListByNick.insert(this->nick, this); + UserListByNick[this->nick] = this; + BotListByNick[this->nick] = this; } void BotInfo::RejoinAll() diff --git a/src/botserv.cpp b/src/botserv.cpp index a7076bcf5..4d0255cd5 100644 --- a/src/botserv.cpp +++ b/src/botserv.cpp @@ -34,9 +34,9 @@ void get_botserv_stats(long *nrec, long *memuse) { long count = 0, mem = 0; - for (patricia_tree<BotInfo *, ci::ci_char_traits>::iterator it(BotListByNick); it.next();) + for (Anope::insensitive_map<BotInfo *>::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it) { - BotInfo *bi = *it; + BotInfo *bi = it->second; ++count; mem += sizeof(*bi); @@ -361,11 +361,19 @@ void botchanmsgs(User *u, ChannelInfo *ci, const Anope::string &buf) BotInfo *findbot(const Anope::string &nick) { - BotInfo *bi; + BotInfo *bi = NULL; if (isdigit(nick[0]) && ircd->ts6) - bi = BotListByUID.find(nick); + { + Anope::map<BotInfo *>::iterator it = BotListByUID.find(nick); + if (it != BotListByUID.end()) + bi = it->second; + } else - bi = BotListByNick.find(nick); + { + Anope::insensitive_map<BotInfo *>::iterator it = BotListByNick.find(nick); + if (it != BotListByNick.end()) + bi = it->second; + } FOREACH_MOD(I_OnFindBot, OnFindBot(nick)); diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp index eb1c9f5a3..7881f2c7a 100644 --- a/src/hashcomp.cpp +++ b/src/hashcomp.cpp @@ -87,11 +87,6 @@ const char *irc::irc_char_traits::find(const char *s1, int n, char c) return n >= 0 ? s1 : NULL; } -const char irc::irc_char_traits::chartolower(char c1) -{ - return rfc_case_insensitive_map[static_cast<unsigned char>(c1)]; -} - /* VS 2008 specific function */ bool irc::hash::operator()(const Anope::string &s1, const Anope::string &s2) const { @@ -158,11 +153,6 @@ const char *ci::ci_char_traits::find(const char *s1, int n, char c) return n >= 0 ? s1 : NULL; } -const char ci::ci_char_traits::chartolower(char c1) -{ - return ascii_case_insensitive_map[static_cast<unsigned char>(c1)]; -} - /* VS 2008 specific function */ bool ci::hash::operator()(const Anope::string &s1, const Anope::string &s2) const { @@ -188,11 +178,6 @@ size_t ci::hash::operator()(const Anope::string &s) const return operator()(s.ci_str()); } -const char std::std_char_traits::chartolower(char c1) -{ - return c1; -} - /** Compare two Anope::strings as ci::strings * @param s1 The first string * @param s2 The second string diff --git a/src/init.cpp b/src/init.cpp index 05b15aecb..31d525c7b 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -57,9 +57,9 @@ void introduce_user(const Anope::string &user) } /* We make the bots go online */ - for (patricia_tree<User *, ci::ci_char_traits>::iterator it(UserListByNick); it.next();) + for (Anope::insensitive_map<User *>::iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end; ++it) { - User *u = *it; + User *u = it->second; ircdproto->SendClientIntroduction(u, ircd->pseudoclient_mode); diff --git a/src/logger.cpp b/src/logger.cpp index b40fdc11d..1265dc3e2 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -32,9 +32,9 @@ void InitLogChannels(ServerConfig *config) c->SetFlag(CH_LOGCHAN); c->SetFlag(CH_PERSIST); - for (patricia_tree<BotInfo *, ci::ci_char_traits>::iterator it(BotListByNick); it.next();) + for (Anope::insensitive_map<BotInfo *>::iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it) { - BotInfo *bi = *it; + BotInfo *bi = it->second; if (bi->HasFlag(BI_CORE) && !c->FindUser(bi)) bi->Join(c, &config->BotModeList); diff --git a/src/main.cpp b/src/main.cpp index c350f4323..3ca033507 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -170,11 +170,9 @@ void do_restart_services() if (quitmsg.empty()) quitmsg = "Restarting"; /* Send a quit for all of our bots */ - patricia_tree<BotInfo *, ci::ci_char_traits>::iterator it(BotListByNick); - for (bool next = it.next(); next;) + for (Anope::insensitive_map<BotInfo *>::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it) { - BotInfo *bi = *it; - next = it.next(); + BotInfo *bi = it->second; /* Don't use quitmsg here, it may contain information you don't want people to see */ ircdproto->SendQuit(bi, "Restarting"); @@ -214,11 +212,9 @@ static void services_shutdown() if (started && UplinkSock) { /* Send a quit for all of our bots */ - patricia_tree<BotInfo *, ci::ci_char_traits>::iterator it(BotListByNick); - for (bool next = it.next(); next;) + for (Anope::insensitive_map<BotInfo *>::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it) { - BotInfo *bi = *it; - next = it.next(); + BotInfo *bi = it->second; /* Don't use quitmsg here, it may contain information you don't want people to see */ ircdproto->SendQuit(bi, "Shutting down"); @@ -230,11 +226,10 @@ static void services_shutdown() ircdproto->SendSquit(Config->ServerName, quitmsg); - patricia_tree<User *, ci::ci_char_traits>::iterator uit(UserListByNick); - for (bool next = uit.next(); next;) + for (Anope::insensitive_map<User *>::const_iterator it = UserListByNick.begin(); it != UserListByNick.end();) { - User *u = *uit; - next = uit.next(); + User *u = it->second; + ++it; delete u; } } @@ -505,11 +500,10 @@ int main(int ac, char **av, char **envp) FOREACH_MOD(I_OnServerDisconnect, OnServerDisconnect()); /* Clear all of our users, but not our bots */ - patricia_tree<User *, ci::ci_char_traits>::iterator it(UserListByNick); - for (bool next = it.next(); next;) + for (Anope::insensitive_map<User *>::const_iterator it = UserListByNick.begin(); it != UserListByNick.end();) { - User *u = *it; - next = it.next(); + User *u = it->second; + ++it; if (u->server != Me) delete u; @@ -551,4 +545,4 @@ int main(int ac, char **av, char **envp) } return 0; -}
\ No newline at end of file +} diff --git a/src/misc.cpp b/src/misc.cpp index 1e1110fd9..edabe8f56 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -501,23 +501,9 @@ bool nickIsServices(const Anope::string &tempnick, bool bot) nick = nick.substr(0, at); } - if (!Config->s_NickServ.empty() && nick.equals_ci(Config->s_NickServ)) - return true; - else if (!Config->s_ChanServ.empty() && nick.equals_ci(Config->s_ChanServ)) - return true; - else if (!Config->s_HostServ.empty() && nick.equals_ci(Config->s_HostServ)) - return true; - else if (!Config->s_MemoServ.empty() && nick.equals_ci(Config->s_MemoServ)) - return true; - else if (!Config->s_BotServ.empty() && nick.equals_ci(Config->s_BotServ)) - return true; - else if (!Config->s_OperServ.empty() && nick.equals_ci(Config->s_OperServ)) - return true; - else if (!Config->s_GlobalNoticer.empty() && nick.equals_ci(Config->s_GlobalNoticer)) - return true; - else if (!Config->s_BotServ.empty() && bot && BotListByNick.find(nick)) - return true; - + BotInfo *bi = findbot(nick); + if (bi) + return bot ? true : bi->HasFlag(BI_CORE); return false; } diff --git a/src/operserv.cpp b/src/operserv.cpp index a00e086fd..86afda8bc 100644 --- a/src/operserv.cpp +++ b/src/operserv.cpp @@ -593,11 +593,10 @@ XLine *SNLineManager::Add(BotInfo *bi, User *u, const Anope::string &mask, time_ { Anope::string rreason = "G-Lined: " + reason; - patricia_tree<User *, ci::ci_char_traits>::iterator uit(UserListByNick); - for (bool next = uit.next(); next;) + for (Anope::insensitive_map<User *>::const_iterator it = UserListByNick.begin(); it != UserListByNick.end();) { - User *user = *uit; - next = uit.next(); + User *user = it->second; + ++it; if (!user->HasMode(UMODE_OPER) && user->server != Me && Anope::Match(user->realname, x->Mask)) kill_user(Config->ServerName, user, rreason); @@ -727,11 +726,10 @@ XLine *SQLineManager::Add(BotInfo *bi, User *u, const Anope::string &mask, time_ } else { - patricia_tree<User *, ci::ci_char_traits>::iterator uit(UserListByNick); - for (bool next = uit.next(); next;) + for (Anope::insensitive_map<User *>::const_iterator it = UserListByNick.begin(); it != UserListByNick.end();) { - User *user = *uit; - next = uit.next(); + User *user = it->second; + ++it; if (!user->HasMode(UMODE_OPER) && user->server != Me && Anope::Match(user->nick, x->Mask)) kill_user(Config->ServerName, user, rreason); diff --git a/src/servers.cpp b/src/servers.cpp index 4b287b8f9..7bde57a35 100644 --- a/src/servers.cpp +++ b/src/servers.cpp @@ -65,11 +65,10 @@ Server::~Server() if (Capab.HasFlag(CAPAB_NOQUIT) || Capab.HasFlag(CAPAB_QS)) { - patricia_tree<User *, ci::ci_char_traits>::iterator uit(UserListByNick); - for (bool next = uit.next(); next;) + for (Anope::insensitive_map<User *>::const_iterator it = UserListByNick.begin(); it != UserListByNick.end();) { - User *u = *uit; - next = uit.next(); + User *u = it->second; + ++it; if (u->server == this) { diff --git a/src/sessions.cpp b/src/sessions.cpp index dcbbff3e6..2be83410c 100644 --- a/src/sessions.cpp +++ b/src/sessions.cpp @@ -40,7 +40,7 @@ /*************************************************************************/ -patricia_tree<Session *> SessionList; +Anope::map<Session *> SessionList; std::vector<Exception *> exceptions; @@ -53,10 +53,9 @@ void get_session_stats(long &count, long &mem) count = SessionList.size(); mem = sizeof(Session) * SessionList.size(); - for (patricia_tree<Session *>::iterator it(SessionList); it.next();) + for (Anope::map<Session *>::iterator it = SessionList.begin(), it_end = SessionList.end(); it != it_end; ++it) { - Session *session = *it; - + Session *session = it->second; mem += session->host.length() + 1; } } @@ -84,7 +83,10 @@ void get_exception_stats(long &count, long &mem) Session *findsession(const Anope::string &host) { - return SessionList.find(host); + Anope::map<Session *>::iterator it = SessionList.find(host); + if (it != SessionList.end()) + return it->second; + return NULL; } /* Attempt to add a host to the session list. If the addition of the new host @@ -149,7 +151,7 @@ void add_session(User *u) session->count = 1; session->hits = 0; - SessionList.insert(session->host, session); + SessionList[session->host] = session; } } diff --git a/src/users.cpp b/src/users.cpp index 5e97fee5d..42e7984ec 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -12,8 +12,8 @@ #include "services.h" #include "modules.h" -patricia_tree<User *, ci::ci_char_traits> UserListByNick; -patricia_tree<User *> UserListByUID; +Anope::insensitive_map<User *> UserListByNick; +Anope::map<User *> UserListByUID; int32 opcnt = 0; uint32 usercnt = 0, maxusercnt = 0; @@ -42,9 +42,9 @@ User::User(const Anope::string &snick, const Anope::string &sident, const Anope: this->uid = suid; this->isSuperAdmin = 0; - UserListByNick.insert(snick, this); + UserListByNick[snick] = this; if (!suid.empty()) - UserListByUID.insert(suid, this); + UserListByUID[suid] = this; this->nc = NULL; @@ -68,7 +68,7 @@ void User::SetNewNick(const Anope::string &newnick) this->nick = newnick; - UserListByNick.insert(this->nick, this); + UserListByNick[this->nick] = this; OnAccess = false; NickAlias *na = findnick(this->nick); @@ -761,9 +761,9 @@ void get_user_stats(long &count, long &mem) { count = mem = 0; - for (patricia_tree<User *, ci::ci_char_traits>::iterator it(UserListByNick); it.next();) + for (Anope::insensitive_map<User *>::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) { - User *user = *it; + User *user = it->second; ++count; mem += sizeof(*user); @@ -784,9 +784,19 @@ void get_user_stats(long &count, long &mem) User *finduser(const Anope::string &nick) { if (isdigit(nick[0]) && ircd->ts6) - return UserListByUID.find(nick); + { + Anope::map<User *>::iterator it = UserListByUID.find(nick); + if (it != UserListByUID.end()) + return it->second; + } + else + { + Anope::insensitive_map<User *>::iterator it = UserListByNick.find(nick); + if (it != UserListByNick.end()) + return it->second; + } - return UserListByNick.find(nick); + return NULL; } /*************************************************************************/ |