diff options
-rw-r--r-- | include/regchannel.h | 5 | ||||
-rw-r--r-- | modules/commands/cs_register.cpp | 1 | ||||
-rw-r--r-- | modules/database/db_mysql.cpp | 21 | ||||
-rw-r--r-- | modules/database/db_plain.cpp | 22 | ||||
-rw-r--r-- | src/regchannel.cpp | 39 | ||||
-rw-r--r-- | src/servers.cpp | 2 |
6 files changed, 26 insertions, 64 deletions
diff --git a/include/regchannel.h b/include/regchannel.h index 3add3000d..71136a73b 100644 --- a/include/regchannel.h +++ b/include/regchannel.h @@ -276,11 +276,6 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag, */ void ClearBadWords(); - /** Loads MLocked modes from extensible. This is used from database loading because Anope doesn't know what modes exist - * until after it connects to the IRCd. - */ - void LoadMLock(); - /** Check if a mode is mlocked * @param mode The mode * @param An optional param diff --git a/modules/commands/cs_register.cpp b/modules/commands/cs_register.cpp index e9344d362..1cc9b9c48 100644 --- a/modules/commands/cs_register.cpp +++ b/modules/commands/cs_register.cpp @@ -66,7 +66,6 @@ class CommandCSRegister : public Command else ci->last_topic_setter = source.owner->nick; - ci->bi = NULL; Log(LOG_COMMAND, u, this, ci); source.Reply(_("Channel \002%s\002 registered under your nickname: %s"), chan.c_str(), u->nick.c_str()); diff --git a/modules/database/db_mysql.cpp b/modules/database/db_mysql.cpp index 19d41bb6e..a90276274 100644 --- a/modules/database/db_mysql.cpp +++ b/modules/database/db_mysql.cpp @@ -512,14 +512,19 @@ class DBMySQL : public Module continue; } - std::vector<Anope::string> mlocks; - ci->GetExtRegular("db_mlock", mlocks); - - Anope::string modestring = r.Get(i, "status") + " " + r.Get(i, "mode") + " " + r.Get(i, "setter") + " " + r.Get(i, "created") + " " + r.Get(i, "param"); - - mlocks.push_back(modestring); - - ci->Extend("db_mlock", new ExtensibleItemRegular<std::vector<Anope::string> >(mlocks)); + Anope::string mode_name = r.Get(i, "mode"); + bool set = r.Get(i, "status") == "1" ? true : false; + Anope::string setter = r.Get(i, "setter"); + time_t mcreated = r.Get(i, "created").is_pos_number_only() ? convertTo<time_t>(r.Get(i, "created")) : Anope::CurTime; + Anope::string param = r.Get(i, "param"); + + for (size_t j = CMODE_BEGIN + 1; j < CMODE_END; ++j) + if (ChannelModeNameStrings[j] == mode_name) + { + ChannelModeName n = static_cast<ChannelModeName>(j); + ci->mode_locks.insert(std::make_pair(n, ModeLock(set, n, param, setter, mcreated))); + break; + } } query = "SELECT * FROM `anope_ms_info`"; diff --git a/modules/database/db_plain.cpp b/modules/database/db_plain.cpp index d2433b6fe..340775e0c 100644 --- a/modules/database/db_plain.cpp +++ b/modules/database/db_plain.cpp @@ -606,15 +606,19 @@ class DBPlain : public Module } else if (key.equals_ci("MLOCK")) { - std::vector<Anope::string> mlocks; - ci->GetExtRegular("db_mlock", mlocks); - - Anope::string mlock_string = params[0] + " " + params[1] + " " + params[2] + " " + params[3]; - if (params.size() > 4) - mlock_string += " " + params[4]; - - mlocks.push_back(mlock_string); - ci->Extend("db_mlock", new ExtensibleItemRegular<std::vector<Anope::string> >(mlocks)); + bool set = params[0] == "1" ? true : false; + Anope::string mode_name = params[1]; + Anope::string setter = params[2]; + time_t created = params[3].is_pos_number_only() ? convertTo<time_t>(params[3]) : Anope::CurTime; + Anope::string param = params.size() > 4 ? params[4] : ""; + + for (size_t i = CMODE_BEGIN + 1; i < CMODE_END; ++i) + if (ChannelModeNameStrings[i] == mode_name) + { + ChannelModeName n = static_cast<ChannelModeName>(i); + ci->mode_locks.insert(std::make_pair(n, ModeLock(set, n, param, setter, created))); + break; + } } else if (key.equals_ci("MI")) { diff --git a/src/regchannel.cpp b/src/regchannel.cpp index 160b7102b..882649d54 100644 --- a/src/regchannel.cpp +++ b/src/regchannel.cpp @@ -449,45 +449,6 @@ void ChannelInfo::ClearBadWords() EraseBadWord(0); } -/** Loads MLocked modes from extensible. This is used from database loading because Anope doesn't know what modes exist - * until after it connects to the IRCd. - */ -void ChannelInfo::LoadMLock() -{ - if (!this->GetExt("db_mlock")) - return; - - this->ClearMLock(); - - // Force +r - ChannelMode *chm = ModeManager::FindChannelModeByName(CMODE_REGISTERED); - if (chm) - this->SetMLock(chm, true); - - std::vector<Anope::string> mlock; - this->GetExtRegular("db_mlock", mlock); - for (unsigned i = 0; i < mlock.size(); ++i) - { - std::vector<Anope::string> mlockv = BuildStringVector(mlock[i]); - - bool set = mlockv[0] == "1"; - ChannelMode *cm = ModeManager::FindChannelModeByString(mlockv[1]); - const Anope::string &setter = mlockv[2]; - time_t created = Anope::CurTime; - try - { - created = convertTo<time_t>(mlockv[3]); - } - catch (const ConvertException &) { } - const Anope::string ¶m = mlockv.size() > 4 ? mlockv[4] : ""; - - if (cm != NULL) - this->SetMLock(cm, set, param, setter, created); - } - - this->Shrink("db_mlock"); -} - /** Check if a mode is mlocked * @param mode The mode * @param status True to check mlock on, false for mlock off diff --git a/src/servers.cpp b/src/servers.cpp index dccea8929..5a95bb85f 100644 --- a/src/servers.cpp +++ b/src/servers.cpp @@ -53,8 +53,6 @@ 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 (registered_channel_map::iterator it = RegisteredChannelList.begin(), it_end = RegisteredChannelList.end(); it != it_end; ++it) - it->second->LoadMLock(); for (botinfo_map::iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it) { BotInfo *bi = it->second; |