1
0
mirror of https://github.com/anope/anope.git synced 2026-07-07 07:33:13 +02:00

Rewrote mlock saving/loading code to not use this silly extensible hack

This commit is contained in:
Adam
2011-08-25 18:24:06 -04:00
parent f025d1b495
commit 62752db4c4
6 changed files with 24 additions and 62 deletions
-5
View File
@@ -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
-1
View File
@@ -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());
+12 -7
View File
@@ -512,14 +512,19 @@ class DBMySQL : public Module
continue;
}
std::vector<Anope::string> mlocks;
ci->GetExtRegular("db_mlock", 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");
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));
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`";
+12 -8
View File
@@ -606,15 +606,19 @@ class DBPlain : public Module
}
else if (key.equals_ci("MLOCK"))
{
std::vector<Anope::string> mlocks;
ci->GetExtRegular("db_mlock", 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] : "";
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));
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"))
{
-39
View File
@@ -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 &param = 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
-2
View File
@@ -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;