diff options
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/cs_appendtopic.c | 2 | ||||
-rw-r--r-- | src/modules/cs_enforce.c | 2 | ||||
-rw-r--r-- | src/modules/cs_tban.c | 2 | ||||
-rw-r--r-- | src/modules/hs_request.c | 10 | ||||
-rw-r--r-- | src/modules/mysql/db_mysql.h | 7 | ||||
-rw-r--r-- | src/modules/mysql/db_mysql_execute.cpp | 25 | ||||
-rw-r--r-- | src/modules/mysql/db_mysql_read.cpp | 8 | ||||
-rw-r--r-- | src/modules/mysql/db_mysql_write.cpp | 174 | ||||
-rw-r--r-- | src/modules/ns_maxemail.c | 13 | ||||
-rw-r--r-- | src/modules/os_info.c | 27 |
10 files changed, 109 insertions, 161 deletions
diff --git a/src/modules/cs_appendtopic.c b/src/modules/cs_appendtopic.c index 22848b74a..311ac0717 100644 --- a/src/modules/cs_appendtopic.c +++ b/src/modules/cs_appendtopic.c @@ -141,7 +141,7 @@ class CSAppendTopic : public Module this->SetVersion(VERSION); this->SetType(SUPPORTED); - this->AddCommand(CHANSERV, new CommandCSAppendTopic()); + this->AddCommand(ChanServ, new CommandCSAppendTopic()); /* English (US) */ const char* langtable_en_us[] = { diff --git a/src/modules/cs_enforce.c b/src/modules/cs_enforce.c index 435f07d79..906e42ea6 100644 --- a/src/modules/cs_enforce.c +++ b/src/modules/cs_enforce.c @@ -229,7 +229,7 @@ class CSEnforce : public Module this->SetVersion(VERSION); this->SetType(SUPPORTED); - this->AddCommand(CHANSERV, new CommandCSEnforce()); + this->AddCommand(ChanServ, new CommandCSEnforce()); /* English (US) */ const char* langtable_en_us[] = { diff --git a/src/modules/cs_tban.c b/src/modules/cs_tban.c index 12fe8cd65..710840d52 100644 --- a/src/modules/cs_tban.c +++ b/src/modules/cs_tban.c @@ -92,7 +92,7 @@ class CSTBan : public Module { me = this; - this->AddCommand(CHANSERV, new CommandCSTBan()); + this->AddCommand(ChanServ, new CommandCSTBan()); this->SetAuthor(AUTHOR); this->SetVersion(VERSION); diff --git a/src/modules/hs_request.c b/src/modules/hs_request.c index 0113817b7..385dfc8c5 100644 --- a/src/modules/hs_request.c +++ b/src/modules/hs_request.c @@ -378,10 +378,10 @@ class HSRequest : public Module { me = this; - this->AddCommand(HOSTSERV, new CommandHSRequest()); - this->AddCommand(HOSTSERV, new CommandHSActivate()); - this->AddCommand(HOSTSERV, new CommandHSReject()); - this->AddCommand(HOSTSERV, new CommandHSWaiting()); + this->AddCommand(HostServ, new CommandHSRequest()); + this->AddCommand(HostServ, new CommandHSActivate()); + this->AddCommand(HostServ, new CommandHSReject()); + this->AddCommand(HostServ, new CommandHSWaiting()); this->SetAuthor(AUTHOR); this->SetVersion(VERSION); @@ -670,7 +670,7 @@ class HSRequest : public Module if (!key.empty() && key == "+req") { std::vector<ci::string> emptyParams; - Command *c = findCommand(HOSTSERV, "WAITING"); + Command *c = FindCommand(HostServ, "WAITING"); c->Execute(u, emptyParams); return EVENT_STOP; } diff --git a/src/modules/mysql/db_mysql.h b/src/modules/mysql/db_mysql.h index 12956262a..f2885408f 100644 --- a/src/modules/mysql/db_mysql.h +++ b/src/modules/mysql/db_mysql.h @@ -98,13 +98,6 @@ struct BotServFlagInfo BotServFlagInfo BotServFlags[] = { {"PRIVATE", BI_PRIVATE}, - {"CHANSERV", BI_CHANSERV}, - {"BOTSERV", BI_BOTSERV}, - {"HOSTSERV", BI_HOSTSERV}, - {"OPERSERV", BI_OPERSERV}, - {"MEMOSERV", BI_MEMOSERV}, - {"NICKSERV", BI_NICKSERV}, - {"GLOBAL", BI_GLOBAL}, {"", static_cast<BotFlag>(-1)} }; diff --git a/src/modules/mysql/db_mysql_execute.cpp b/src/modules/mysql/db_mysql_execute.cpp index 3933d54d1..356f7c0f2 100644 --- a/src/modules/mysql/db_mysql_execute.cpp +++ b/src/modules/mysql/db_mysql_execute.cpp @@ -8,17 +8,12 @@ class FakeNickCore : public NickCore public: FakeNickCore() : NickCore("-SQLUser") { - if (this->next) - this->next->prev = this->prev; - if (this->prev) - this->prev->next = this->next; - else - nclists[HASH(this->display)] = this->next; + NickCoreList.erase(this->display); } ~FakeNickCore() { - insert_core(this); + NickCoreList[this->display] = this; Users.clear(); } @@ -39,23 +34,15 @@ class FakeUser : public User this->vhost = NULL; this->server = Me; - if (this->prev) - this->prev->next = this->next; - else - userlist[HASH(this->nick.c_str())] = this->next; - if (this->next) - this->next->prev = this->prev; + UserListByNick.erase("-SQLUser"); --usercnt; } ~FakeUser() { - User **list = &userlist[HASH(this->nick.c_str())]; - this->next = *list; - if (*list) - (*list)->prev = this; - *list = this; + UserListByNick["-SQLUser"] = this; ++usercnt; + nc = NULL; } @@ -145,7 +132,7 @@ class SQLTimer : public Timer // XXX this whole strtok thing needs to die char *cmdbuf = sstrdup(qres[i]["command"].c_str()); char *cmd = strtok(cmdbuf, " "); - mod_run_cmd(bi->nick, u, bi->cmdTable, cmd); + mod_run_cmd(bi, u, cmd); delete [] cmdbuf; if (logout) diff --git a/src/modules/mysql/db_mysql_read.cpp b/src/modules/mysql/db_mysql_read.cpp index 728e4b882..79e59c9eb 100644 --- a/src/modules/mysql/db_mysql_read.cpp +++ b/src/modules/mysql/db_mysql_read.cpp @@ -166,7 +166,13 @@ static void LoadDatabase() { for (size_t i = 0; i < qres.num_rows(); ++i) { - BotInfo *bi = new BotInfo(SQLAssign(qres[i]["nick"]), SQLAssign(qres[i]["user"]), SQLAssign(qres[i]["host"]), SQLAssign(qres[i]["rname"])); + BotInfo *bi = findbot(SQLAssign(qres[i]["nick"])); + if (!bi) + bi = new BotInfo(SQLAssign(qres[i]["nick"])); + bi->user = SQLAssign(qres[i]["user"]); + bi->host = SQLAssign(qres[i]["host"]); + bi->real = SQLAssign(qres[i]["rname"]); + if (qres[i]["flags"].size()) { spacesepstream sep(SQLAssign(qres[i]["flags"])); diff --git a/src/modules/mysql/db_mysql_write.cpp b/src/modules/mysql/db_mysql_write.cpp index 5f3218381..2f7a42bb3 100644 --- a/src/modules/mysql/db_mysql_write.cpp +++ b/src/modules/mysql/db_mysql_write.cpp @@ -230,51 +230,47 @@ static void SaveDatabases() { mysqlpp::Query query(me->Con); - query << "TRUNCATE TABLE `anope_ns_core`"; - ExecuteQuery(query); query << "TRUNCATE TABLE `anope_ns_alias`"; ExecuteQuery(query); - for (int i = 0; i < 1024; ++i) + for (nickalias_map::const_iterator it = NickAliasList.begin(); it != NickAliasList.end(); ++it) { - for (NickAlias *na = nalists[i]; na; na = na->next) - { - me->OnNickRegister(na); - } + NickAlias *na = it->second; + + me->OnNickRegister(na); } - query << "TRUNCATE TABLE `anope_ns_access`"; + query << "TRUNCATE TABLE `anope_ns_core`"; ExecuteQuery(query); query << "TRUNCATE TABLE `anope_ms_info`"; ExecuteQuery(query); - - for (int i = 0; i < 1024; ++i) + + for (nickcore_map::const_iterator nit = NickCoreList.begin(); nit != NickCoreList.end(); ++nit) { - for (NickCore *nc = nclists[i]; nc; nc = nc->next) + NickCore *nc = nit->second; + + for (std::vector<std::string>::iterator it = nc->access.begin(); it != nc->access.end(); ++it) { - for (std::vector<std::string>::iterator it = nc->access.begin(); it != nc->access.end(); ++it) - { - query << "INSERT DELAYED INTO `anope_ns_access` (display, access) VALUES(" << mysqlpp::quote << nc->display << ", " << mysqlpp::quote << *it << ")"; - ExecuteQuery(query); - } + query << "INSERT DELAYED INTO `anope_ns_access` (display, access) VALUES(" << mysqlpp::quote << nc->display << ", " << mysqlpp::quote << *it << ")"; + ExecuteQuery(query); + } - for (unsigned j = 0; j < nc->memos.memos.size(); ++j) - { - Memo *m = nc->memos.memos[j]; + for (unsigned j = 0; j < nc->memos.memos.size(); ++j) + { + Memo *m = nc->memos.memos[j]; - me->OnMemoSend(NULL, nc, m); - } + me->OnMemoSend(NULL, nc, m); } } + query << "TRUNCATE TABLE `anope_bs_core`"; ExecuteQuery(query); - for (int i = 0; i < 256; ++i) + + for (botinfo_map::const_iterator it = BotList.begin(); it != BotList.end(); ++it) { - for (BotInfo *bi = botlists[i]; bi; bi = bi->next) - { - me->OnBotCreate(bi); - } + BotInfo *bi = it->second; + me->OnBotCreate(bi); } query << "TRUNCATE TABLE `anope_cs_info`"; @@ -288,67 +284,54 @@ static void SaveDatabases() query << "TRUNCATE TABLE `anope_cs_levels`"; ExecuteQuery(query); - for (int i = 0; i < 256; ++i) + for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(); it != RegisteredChannelList.end(); ++it) { - for (ChannelInfo *ci = chanlists[i]; ci; ci = ci->next) - { - me->OnChanRegistered(ci); + ChannelInfo *ci = it->second; + + me->OnChanRegistered(ci); - for (unsigned j = 0; j < ci->GetBadWordCount(); ++j) - { - BadWord *bw = ci->GetBadWord(j); + for (unsigned j = 0; j < ci->GetBadWordCount(); ++j) + { + BadWord *bw = ci->GetBadWord(j); - if (bw->InUse) - { - me->OnBadWordAdd(ci, bw); - } - } + me->OnBadWordAdd(ci, bw); + } - for (unsigned j = 0; j < ci->GetAccessCount(); ++j) - { - ChanAccess *access = ci->GetAccess(j); + for (unsigned j = 0; j < ci->GetAccessCount(); ++j) + { + ChanAccess *access = ci->GetAccess(j); - if (access->in_use) - { - query << "INSERT DELAYED INTO `anope_cs_access` (level, display, channel, last_seen, creator) VALUES('" << access->level << "', " << mysqlpp::quote << access->nc->display << ", " << mysqlpp::quote << ci->name << ", " << access->last_seen << ", " << mysqlpp::quote << access->creator << ") ON DUPLICATE KEY UPDATE level=VALUES(level), last_seen=VALUES(last_seen), creator=VALUES(creator)"; - ExecuteQuery(query); - } - } + query << "INSERT DELAYED INTO `anope_cs_access` (level, display, channel, last_seen, creator) VALUES('" << access->level << "', " << mysqlpp::quote << access->nc->display << ", " << mysqlpp::quote << ci->name << ", " << access->last_seen << ", " << mysqlpp::quote << access->creator << ") ON DUPLICATE KEY UPDATE level=VALUES(level), last_seen=VALUES(last_seen), creator=VALUES(creator)"; + ExecuteQuery(query); + } - for (unsigned j = 0; j < ci->GetAkickCount(); ++j) - { - AutoKick *ak = ci->GetAkick(j); + for (unsigned j = 0; j < ci->GetAkickCount(); ++j) + { + AutoKick *ak = ci->GetAkick(j); - if (ak->InUse) - { - me->OnAkickAdd(ci, ak); - } - } + me->OnAkickAdd(ci, ak); + } - for (int k = 0; k < CA_SIZE; ++k) - { - query << "INSERT DELAYED INTO `anope_cs_levels` (channel, position, level) VALUES(" << mysqlpp::quote << ci->name << ", '" << k << "', '" << ci->levels[k] << "') ON DUPLICATE KEY UPDATE position=VALUES(position), level=VALUES(level)"; - ExecuteQuery(query); - } + for (int k = 0; k < CA_SIZE; ++k) + { + query << "INSERT DELAYED INTO `anope_cs_levels` (channel, position, level) VALUES(" << mysqlpp::quote << ci->name << ", '" << k << "', '" << ci->levels[k] << "') ON DUPLICATE KEY UPDATE position=VALUES(position), level=VALUES(level)"; + ExecuteQuery(query); + } - for (unsigned j = 0; j < ci->memos.memos.size(); ++j) - { - Memo *m = ci->memos.memos[j]; + for (unsigned j = 0; j < ci->memos.memos.size(); ++j) + { + Memo *m = ci->memos.memos[j]; - me->OnMemoSend(NULL, ci, m); - } + me->OnMemoSend(NULL, ci, m); } } query << "TRUNCATE TABLE `anope_ns_request`"; ExecuteQuery(query); - for (int i = 0; i < 1024; i++) + for (nickrequest_map::const_iterator it = NickRequestList.begin(); it != NickRequestList.end(); ++it) { - for (NickRequest *nr = nrlists[i]; nr; nr = nr->next) - { - me->OnMakeNickRequest(nr); - } + me->OnMakeNickRequest(it->second); } for (int i = 0; i < akills.count; ++i) @@ -418,7 +401,7 @@ class DBMySQLWrite : public DBMySQL ModuleManager::Attach(I_OnServerConnect, this); - this->AddCommand(OPERSERV, new CommandSyncSQL("SQLSYNC")); + this->AddCommand(OperServ, new CommandSyncSQL("SQLSYNC")); if (uplink_server) OnServerConnect(); @@ -470,46 +453,35 @@ class DBMySQLWrite : public DBMySQL query << maxusercnt << ", " << maxusertime << ", " << akills.count << ", " << sqlines.count << ", " << sglines.count << ", " << szlines.count << ")"; ExecuteQuery(query); - for (int i = 0; i < 1024; ++i) + for (nickcore_map::const_iterator it = NickCoreList.begin(); it != NickCoreList.end(); ++it) { - for (NickCore *nc = nclists[i]; nc; nc = nc->next) - { - CurCore = nc; - FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteCoreMetadata, nc)); - } + CurCore = it->second; + FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteCoreMetadata, CurCore)); } - for (int i = 0; i < 1024; ++i) + for (nickalias_map::const_iterator it = NickAliasList.begin(); it != NickAliasList.end(); ++it) { - for (NickAlias *na = nalists[i]; na; na = na->next) - { - CurNick = na; - FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteNickMetadata, na)); - } + CurNick = it->second; + FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteNickMetadata, CurNick)); } - for (int i = 0; i < 256; ++i) + for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(); it != RegisteredChannelList.end(); ++it) { - for (ChannelInfo *ci = chanlists[i]; ci; ci = ci->next) - { - CurChannel = ci; - FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteChannelMetadata, ci)); - } + CurChannel = it->second; + FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteChannelMetadata, CurChannel)); } - for (int i = 0; i < 256; ++i) + for (botinfo_map::const_iterator it = BotList.begin(); it != BotList.end(); ++it) { - for (BotInfo *bi = botlists[i]; bi; bi = bi->next) - { - CurBot = bi; - FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteBotMetadata, bi)); - /* This is for the core bots, bots added by users are already handled by an event */ - query << "INSERT DELAYED INTO `anope_bs_core` (nick, user, host, rname, flags, created, chancount) VALUES("; - query << mysqlpp::quote << bi->nick << ", " << mysqlpp::quote << bi->user << ", " << mysqlpp::quote << bi->host; - query << ", " << mysqlpp::quote << bi->real << ", '" << GetBotServFlags(bi) << "', " << bi->created << ", "; - query << bi->chancount << ") ON DUPLICATE KEY UPDATE nick=VALUES(nick), user=VALUES(user), host=VALUES(host), rname=VALUES(rname), flags=VALUES(flags), created=VALUES(created), chancount=VALUES(created)"; - ExecuteQuery(query); - } + 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 */ + query << "INSERT DELAYED INTO `anope_bs_core` (nick, user, host, rname, flags, created, chancount) VALUES("; + query << mysqlpp::quote << CurBot->nick << ", " << mysqlpp::quote << CurBot->user << ", " << mysqlpp::quote << CurBot->host; + query << ", " << mysqlpp::quote << CurBot->real << ", '" << GetBotServFlags(CurBot) << "', " << CurBot->created << ", "; + query << CurBot->chancount << ") ON DUPLICATE KEY UPDATE nick=VALUES(nick), user=VALUES(user), host=VALUES(host), rname=VALUES(rname), flags=VALUES(flags), created=VALUES(created), chancount=VALUES(created)"; + ExecuteQuery(query); } FOREACH_MOD(I_OnDatabaseWrite, OnDatabaseWrite(Write)); diff --git a/src/modules/ns_maxemail.c b/src/modules/ns_maxemail.c index e98dc62d7..2399dba68 100644 --- a/src/modules/ns_maxemail.c +++ b/src/modules/ns_maxemail.c @@ -127,20 +127,17 @@ class NSMaxEmail : public Module int count_email_in_use(const char *email, User * u) { - NickCore *nc; - int i; int count = 0; if (!email) return 0; - for (i = 0; i < 1024; ++i) + for (nickcore_map::const_iterator it = NickCoreList.begin(); it != NickCoreList.end(); ++it) { - for (nc = nclists[i]; nc; nc = nc->next) - { - if (!(u->Account() && u->Account() == nc) && nc->email && !stricmp(nc->email, email)) - ++count; - } + NickCore *nc = it->second; + + if (!(u->Account() && u->Account() == nc) && nc->email && !stricmp(nc->email, email)) + ++count; } return count; diff --git a/src/modules/os_info.c b/src/modules/os_info.c index b486e32f6..a49fa8a88 100644 --- a/src/modules/os_info.c +++ b/src/modules/os_info.c @@ -193,8 +193,8 @@ class OSInfo : public Module this->SetVersion(VERSION); this->SetType(SUPPORTED); - this->AddCommand(NICKSERV, new CommandNSOInfo()); - this->AddCommand(CHANSERV, new CommandCSOInfo()); + this->AddCommand(NickServ, new CommandNSOInfo()); + this->AddCommand(ChanServ, new CommandCSOInfo()); const char* langtable_en_us[] = { /* OINFO_SYNTAX */ @@ -415,27 +415,20 @@ class OSInfo : public Module ~OSInfo() { - int i; - NickCore *nc; - ChannelInfo *ci; - OnSaveDatabase(); - for (i = 0; i < 1024; ++i) + for (nickcore_map::const_iterator it = NickCoreList.begin(); it != NickCoreList.end(); ++it) { - /* Remove the nick Cores */ - for (nc = nclists[i]; nc; nc = nc->next) - { - nc->Shrink("os_info"); - } + NickCore *nc = it->second; + + nc->Shrink("os_info"); } - for (i = 0; i < 256; ++i) + for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(); it != RegisteredChannelList.end(); ++it) { - for (ci = chanlists[i]; ci; ci = ci->next) - { - ci->Shrink("os_info"); - } + ChannelInfo *ci = it->second; + + ci->Shrink("os_info"); } } |