mirror of
https://github.com/anope/anope.git
synced 2026-07-06 13:13:12 +02:00
Pretty large coding style cleanup, in source doc
cleanup, and allow protocol mods to depend on each other
This commit is contained in:
@@ -37,7 +37,7 @@ class DBFlatFile : public Module
|
||||
void BackupDatabase()
|
||||
{
|
||||
/* Do not backup a database that doesn't exist */
|
||||
if (!IsFile(DatabaseFile))
|
||||
if (!Anope::IsFile(DatabaseFile))
|
||||
return;
|
||||
|
||||
time_t now = Anope::CurTime;
|
||||
@@ -58,7 +58,7 @@ class DBFlatFile : public Module
|
||||
Log(this) << "Unable to back up database!";
|
||||
|
||||
if (!Config->NoBackupOkay)
|
||||
quitting = true;
|
||||
Anope::Quitting = true;
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -76,8 +76,8 @@ class DBFlatFile : public Module
|
||||
void OnReload() anope_override
|
||||
{
|
||||
ConfigReader config;
|
||||
DatabaseFile = db_dir + "/" + config.ReadValue("db_flatfile", "database", "anope.db", 0);
|
||||
BackupFile = db_dir + "/backups/" + config.ReadValue("db_flatfile", "database", "anope.db", 0);
|
||||
DatabaseFile = Anope::DataDir + "/" + config.ReadValue("db_flatfile", "database", "anope.db", 0);
|
||||
BackupFile = Anope::DataDir + "/backups/" + config.ReadValue("db_flatfile", "database", "anope.db", 0);
|
||||
}
|
||||
|
||||
EventReturn OnLoadDatabase() anope_override
|
||||
@@ -92,23 +92,23 @@ class DBFlatFile : public Module
|
||||
return EVENT_CONTINUE;
|
||||
}
|
||||
|
||||
const std::vector<Anope::string> type_order = SerializeType::GetTypeOrder();
|
||||
const std::vector<Anope::string> type_order = Serialize::Type::GetTypeOrder();
|
||||
|
||||
for (unsigned i = 0; i < type_order.size(); ++i)
|
||||
{
|
||||
SerializeType *stype = SerializeType::Find(type_order[i]);
|
||||
Serialize::Type *stype = Serialize::Type::Find(type_order[i]);
|
||||
if (stype && !databases.count(stype->GetOwner()))
|
||||
{
|
||||
Anope::string db_name = db_dir + "/module_" + stype->GetOwner()->name + ".db";
|
||||
Anope::string db_name = Anope::DataDir + "/module_" + stype->GetOwner()->name + ".db";
|
||||
databases[stype->GetOwner()] = new std::fstream(db_name.c_str(), std::ios_base::in);
|
||||
}
|
||||
}
|
||||
|
||||
std::multimap<SerializeType *, Serialize::Data> objects;
|
||||
std::multimap<Serialize::Type *, Serialize::Data> objects;
|
||||
for (std::map<Module *, std::fstream *>::iterator it = databases.begin(), it_end = databases.end(); it != it_end; ++it)
|
||||
{
|
||||
std::fstream *db = it->second;
|
||||
SerializeType *st = NULL;
|
||||
Serialize::Type *st = NULL;
|
||||
Serialize::Data data;
|
||||
for (Anope::string buf, token; std::getline(*db, buf.str());)
|
||||
{
|
||||
@@ -119,7 +119,7 @@ class DBFlatFile : public Module
|
||||
|
||||
if (token == "OBJECT" && sep.GetToken(token))
|
||||
{
|
||||
st = SerializeType::Find(token);
|
||||
st = Serialize::Type::Find(token);
|
||||
data.clear();
|
||||
}
|
||||
else if (token == "DATA" && st != NULL && sep.GetToken(token))
|
||||
@@ -136,9 +136,9 @@ class DBFlatFile : public Module
|
||||
|
||||
for (unsigned i = 0; i < type_order.size(); ++i)
|
||||
{
|
||||
SerializeType *stype = SerializeType::Find(type_order[i]);
|
||||
Serialize::Type *stype = Serialize::Type::Find(type_order[i]);
|
||||
|
||||
std::multimap<SerializeType *, Serialize::Data>::iterator it = objects.find(stype), it_end = objects.upper_bound(stype);
|
||||
std::multimap<Serialize::Type *, Serialize::Data>::iterator it = objects.find(stype), it_end = objects.upper_bound(stype);
|
||||
if (it == objects.end())
|
||||
continue;
|
||||
for (; it != it_end; ++it)
|
||||
@@ -178,16 +178,16 @@ class DBFlatFile : public Module
|
||||
for (std::list<Serializable *>::const_iterator it = items.begin(), it_end = items.end(); it != it_end; ++it)
|
||||
{
|
||||
Serializable *base = *it;
|
||||
SerializeType *s_type = base->GetSerializableType();
|
||||
Serialize::Type *s_type = base->GetSerializableType();
|
||||
|
||||
if (!s_type)
|
||||
continue;
|
||||
|
||||
Serialize::Data data = base->serialize();
|
||||
Serialize::Data data = base->Serialize();
|
||||
|
||||
if (!databases.count(s_type->GetOwner()))
|
||||
{
|
||||
Anope::string db_name = db_dir + "/module_" + s_type->GetOwner()->name + ".db";
|
||||
Anope::string db_name = Anope::DataDir + "/module_" + s_type->GetOwner()->name + ".db";
|
||||
databases[s_type->GetOwner()] = new std::fstream(db_name.c_str(), std::ios_base::out | std::ios_base::trunc);
|
||||
}
|
||||
std::fstream *fd = databases[s_type->GetOwner()];
|
||||
@@ -203,7 +203,7 @@ class DBFlatFile : public Module
|
||||
Log(this) << "Unable to write database";
|
||||
databases[NULL]->close();
|
||||
if (!Config->NoBackupOkay)
|
||||
quitting = true;
|
||||
Anope::Quitting = true;
|
||||
if (IsFile(tmp_db))
|
||||
rename(tmp_db.c_str(), DatabaseFile.c_str());
|
||||
}
|
||||
|
||||
+13
-13
@@ -309,7 +309,7 @@ static dbFILE *open_db_read(const char *service, const char *filename, int versi
|
||||
int myversion;
|
||||
|
||||
f = new dbFILE;
|
||||
strscpy(f->filename, (db_dir + "/" + filename).c_str(), sizeof(f->filename));
|
||||
strscpy(f->filename, (Anope::DataDir + "/" + filename).c_str(), sizeof(f->filename));
|
||||
f->mode = 'r';
|
||||
fp = fopen(f->filename, "rb");
|
||||
if (!fp)
|
||||
@@ -595,7 +595,7 @@ static void LoadNicks()
|
||||
|
||||
Anope::string core;
|
||||
READ(read_string(core, f));
|
||||
NickCore *nc = findcore(core);
|
||||
NickCore *nc = NickCore::Find(core);
|
||||
if (nc == NULL)
|
||||
{
|
||||
Log() << "Skipping coreless nick " << nick << " with core " << core;
|
||||
@@ -634,7 +634,7 @@ static void LoadVHosts()
|
||||
READ(read_string(creator, f));
|
||||
READ(read_int32(&vtime, f));
|
||||
|
||||
NickAlias *na = findnick(nick);
|
||||
NickAlias *na = NickAlias::Find(nick);
|
||||
if (na == NULL)
|
||||
{
|
||||
Log() << "Removing vhost for nonexistant nick " << nick;
|
||||
@@ -669,7 +669,7 @@ static void LoadBots()
|
||||
READ(read_int32(&created, f));
|
||||
READ(read_int16(&chancount, f));
|
||||
|
||||
BotInfo *bi = findbot(nick);
|
||||
BotInfo *bi = BotInfo::Find(nick);
|
||||
if (!bi)
|
||||
bi = new BotInfo(nick, user, host, real);
|
||||
bi->created = created;
|
||||
@@ -698,10 +698,10 @@ static void LoadChannels()
|
||||
ChannelInfo *ci = new ChannelInfo(namebuf);
|
||||
|
||||
READ(read_string(buffer, f));
|
||||
ci->SetFounder(findcore(buffer));
|
||||
ci->SetFounder(NickCore::Find(buffer));
|
||||
|
||||
READ(read_string(buffer, f));
|
||||
ci->successor = findcore(buffer);
|
||||
ci->successor = NickCore::Find(buffer);
|
||||
|
||||
char pwbuf[32];
|
||||
READ(read_buffer(pwbuf, f));
|
||||
@@ -777,7 +777,7 @@ static void LoadChannels()
|
||||
ci->SetLevel(GetLevelName(j), level);
|
||||
}
|
||||
|
||||
service_reference<AccessProvider> provider("AccessProvider", "access/access");
|
||||
ServiceReference<AccessProvider> provider("AccessProvider", "access/access");
|
||||
uint16_t tmpu16;
|
||||
READ(read_uint16(&tmpu16, f));
|
||||
for (uint16_t j = 0; j < tmpu16; ++j)
|
||||
@@ -793,7 +793,7 @@ static void LoadChannels()
|
||||
int16_t level;
|
||||
READ(read_int16(&level, f));
|
||||
if (access)
|
||||
access->Unserialize(stringify(level));
|
||||
access->AccessUnserialize(stringify(level));
|
||||
|
||||
Anope::string mask;
|
||||
READ(read_string(mask, f));
|
||||
@@ -858,7 +858,7 @@ static void LoadChannels()
|
||||
READ(read_string(buffer, f));
|
||||
|
||||
READ(read_string(buffer, f));
|
||||
ci->bi = findbot(buffer);
|
||||
ci->bi = BotInfo::Find(buffer);
|
||||
|
||||
READ(read_int32(&tmp32, f));
|
||||
if (tmp32 & OLD_BS_DONTKICKOPS)
|
||||
@@ -981,7 +981,7 @@ static void LoadOper()
|
||||
continue;
|
||||
|
||||
XLine *x = new XLine(user + "@" + host, by, expires, reason, XLineManager::GenerateUID());
|
||||
x->Created = seton;
|
||||
x->created = seton;
|
||||
akill->AddXLine(x);
|
||||
}
|
||||
|
||||
@@ -1001,7 +1001,7 @@ static void LoadOper()
|
||||
continue;
|
||||
|
||||
XLine *x = new XLine(mask, by, expires, reason, XLineManager::GenerateUID());
|
||||
x->Created = seton;
|
||||
x->created = seton;
|
||||
snline->AddXLine(x);
|
||||
}
|
||||
|
||||
@@ -1021,7 +1021,7 @@ static void LoadOper()
|
||||
continue;
|
||||
|
||||
XLine *x = new XLine(mask, by, expires, reason, XLineManager::GenerateUID());
|
||||
x->Created = seton;
|
||||
x->created = seton;
|
||||
sqline->AddXLine(x);
|
||||
}
|
||||
|
||||
@@ -1041,7 +1041,7 @@ static void LoadOper()
|
||||
continue;
|
||||
|
||||
XLine *x = new XLine(mask, by, expires, reason, XLineManager::GenerateUID());
|
||||
x->Created = seton;
|
||||
x->created = seton;
|
||||
szline->AddXLine(x);
|
||||
}
|
||||
|
||||
|
||||
@@ -139,9 +139,9 @@ EventReturn OnDatabaseReadMetadata(ChannelInfo *ci, const Anope::string &key, co
|
||||
else if (key.equals_ci("MEMOMAX"))
|
||||
ci->memos.memomax = params[0].is_pos_number_only() ? convertTo<int16_t>(params[0]) : -1;
|
||||
else if (key.equals_ci("FOUNDER"))
|
||||
ci->SetFounder(findcore(params[0]));
|
||||
ci->SetFounder(NickCore::Find(params[0]));
|
||||
else if (key.equals_ci("SUCCESSOR"))
|
||||
ci->successor = findcore(params[0]);
|
||||
ci->successor = NickCore::Find(params[0]);
|
||||
else if (key.equals_ci("LEVELS"))
|
||||
{
|
||||
for (unsigned j = 0, end = params.size(); j < end; j += 2)
|
||||
@@ -169,14 +169,14 @@ EventReturn OnDatabaseReadMetadata(ChannelInfo *ci, const Anope::string &key, co
|
||||
}
|
||||
else if (key.equals_ci("ACCESS")) // Older access system, from Anope 1.9.4.
|
||||
{
|
||||
service_reference<AccessProvider> provider("AccessProvider", "access/access");
|
||||
ServiceReference<AccessProvider> provider("AccessProvider", "access/access");
|
||||
if (!provider)
|
||||
throw DatabaseException("Old access entry for nonexistant provider");
|
||||
|
||||
ChanAccess *access = const_cast<ChanAccess *>(provider->Create());
|
||||
access->ci = ci;
|
||||
access->mask = params[0];
|
||||
access->Unserialize(params[1]);
|
||||
access->AccessUnserialize(params[1]);
|
||||
access->last_seen = params[2].is_pos_number_only() ? convertTo<time_t>(params[2]) : 0;
|
||||
access->creator = params[3];
|
||||
access->created = Anope::CurTime;
|
||||
@@ -185,14 +185,14 @@ EventReturn OnDatabaseReadMetadata(ChannelInfo *ci, const Anope::string &key, co
|
||||
}
|
||||
else if (key.equals_ci("ACCESS2"))
|
||||
{
|
||||
service_reference<AccessProvider> provider("AccessProvider", params[0]);
|
||||
ServiceReference<AccessProvider> provider("AccessProvider", params[0]);
|
||||
if (!provider)
|
||||
throw DatabaseException("Access entry for nonexistant provider " + params[0]);
|
||||
|
||||
ChanAccess *access = const_cast<ChanAccess *>(provider->Create());
|
||||
access->ci = ci;
|
||||
access->mask = params[1];
|
||||
access->Unserialize(params[2]);
|
||||
access->AccessUnserialize(params[2]);
|
||||
access->last_seen = params[3].is_pos_number_only() ? convertTo<time_t>(params[3]) : 0;
|
||||
access->creator = params[4];
|
||||
access->created = params.size() > 5 && params[5].is_pos_number_only() ? convertTo<time_t>(params[5]) : Anope::CurTime;
|
||||
@@ -206,7 +206,7 @@ EventReturn OnDatabaseReadMetadata(ChannelInfo *ci, const Anope::string &key, co
|
||||
NickCore *nc = NULL;
|
||||
if (Nick)
|
||||
{
|
||||
nc = findcore(params[2]);
|
||||
nc = NickCore::Find(params[2]);
|
||||
if (!nc)
|
||||
throw DatabaseException("Akick for nonexistant core " + params[2] + " on " + ci->name);
|
||||
}
|
||||
@@ -242,6 +242,7 @@ EventReturn OnDatabaseReadMetadata(ChannelInfo *ci, const Anope::string &key, co
|
||||
Anope::string setter = params[2];
|
||||
time_t mcreated = params[3].is_pos_number_only() ? convertTo<time_t>(params[3]) : Anope::CurTime;
|
||||
Anope::string param = params.size() > 4 ? params[4] : "";
|
||||
const Anope::string* ChannelModeNameStrings = Flags<ChannelModeName>::GetFlagStrings();
|
||||
for (size_t i = CMODE_BEGIN + 1; i < CMODE_END; ++i)
|
||||
if (ChannelModeNameStrings[i] == mode_name)
|
||||
{
|
||||
@@ -270,7 +271,7 @@ EventReturn OnDatabaseReadMetadata(ChannelInfo *ci, const Anope::string &key, co
|
||||
else if (key.equals_ci("BI"))
|
||||
{
|
||||
if (params[0].equals_ci("NAME"))
|
||||
ci->bi = findbot(params[1]);
|
||||
ci->bi = BotInfo::Find(params[1]);
|
||||
else if (params[0].equals_ci("FLAGS"))
|
||||
ci->botflags.FromVector(params);
|
||||
else if (params[0].equals_ci("TTB"))
|
||||
@@ -396,22 +397,22 @@ static void ReadDatabase(Module *m = NULL)
|
||||
{
|
||||
if (params[0].equals_ci("NC"))
|
||||
{
|
||||
nc = findcore(params[1]);
|
||||
nc = NickCore::Find(params[1]);
|
||||
Type = MD_NC;
|
||||
}
|
||||
else if (params[0].equals_ci("NA"))
|
||||
{
|
||||
na = findnick(params[2]);
|
||||
na = NickAlias::Find(params[2]);
|
||||
Type = MD_NA;
|
||||
}
|
||||
else if (params[0].equals_ci("BI"))
|
||||
{
|
||||
bi = findbot(params[1]);
|
||||
bi = BotInfo::Find(params[1]);
|
||||
Type = MD_BI;
|
||||
}
|
||||
else if (params[0].equals_ci("CH"))
|
||||
{
|
||||
ci = cs_findchan(params[1]);
|
||||
ci = ChannelInfo::Find(params[1]);
|
||||
Type = MD_CH;
|
||||
}
|
||||
else if (params[0].equals_ci("MD"))
|
||||
@@ -484,7 +485,7 @@ static void LoadNickCore(const std::vector<Anope::string> ¶ms)
|
||||
|
||||
static void LoadNickAlias(const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
NickCore *nc = findcore(params[0]);
|
||||
NickCore *nc = NickCore::Find(params[0]);
|
||||
if (!nc)
|
||||
{
|
||||
Log() << "[db_plain]: Unable to find core " << params[0];
|
||||
@@ -502,7 +503,7 @@ static void LoadNickAlias(const std::vector<Anope::string> ¶ms)
|
||||
|
||||
static void LoadBotInfo(const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
BotInfo *bi = findbot(params[0]);
|
||||
BotInfo *bi = BotInfo::Find(params[0]);
|
||||
if (!bi)
|
||||
bi = new BotInfo(params[0], params[1], params[2]);
|
||||
|
||||
@@ -533,8 +534,8 @@ static void LoadOperInfo(const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (params[0].equals_ci("STATS"))
|
||||
{
|
||||
maxusercnt = params[1].is_pos_number_only() ? convertTo<uint32_t>(params[1]) : 0;
|
||||
maxusertime = params[2].is_pos_number_only() ? convertTo<time_t>(params[2]) : 0;
|
||||
MaxUserCount = params[1].is_pos_number_only() ? convertTo<uint32_t>(params[1]) : 0;
|
||||
MaxUserTime = params[2].is_pos_number_only() ? convertTo<time_t>(params[2]) : 0;
|
||||
}
|
||||
else if (params[0].equals_ci("SXLINE"))
|
||||
{
|
||||
@@ -551,7 +552,7 @@ static void LoadOperInfo(const std::vector<Anope::string> ¶ms)
|
||||
Anope::string reason = params[7];
|
||||
|
||||
XLine *x = new XLine(mask, by, expires, reason, XLineManager::GenerateUID());
|
||||
x->Created = seton;
|
||||
x->created = seton;
|
||||
xl->AddXLine(x);
|
||||
break;
|
||||
}
|
||||
@@ -627,7 +628,7 @@ class DBPlain : public Module
|
||||
Log() << "Unable to back up database!";
|
||||
|
||||
if (!Config->NoBackupOkay)
|
||||
quitting = true;
|
||||
Anope::Quitting = true;
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -646,8 +647,8 @@ class DBPlain : public Module
|
||||
void OnReload() anope_override
|
||||
{
|
||||
ConfigReader config;
|
||||
DatabaseFile = db_dir + "/" + config.ReadValue("db_plain", "database", "anope.db", 0);
|
||||
BackupFile = db_dir + "/backups/" + config.ReadValue("db_plain", "database", "anope.db", 0);
|
||||
DatabaseFile = Anope::DataDir + "/" + config.ReadValue("db_plain", "database", "anope.db", 0);
|
||||
BackupFile = Anope::DataDir + "/backups/" + config.ReadValue("db_plain", "database", "anope.db", 0);
|
||||
}
|
||||
|
||||
EventReturn OnLoadDatabase() anope_override
|
||||
@@ -777,7 +778,7 @@ class DBPlain : public Module
|
||||
for (unsigned k = 0, end = ci->GetAccessCount(); k < end; ++k)
|
||||
{
|
||||
const ChanAccess *access = ci->GetAccess(k);
|
||||
db_buffer << "MD ACCESS2 " << access->provider->name << " " << access->mask << " " << access->Serialize() << " " << access->last_seen << " " << access->creator << " " << access->created << endl;
|
||||
db_buffer << "MD ACCESS2 " << access->provider->name << " " << access->mask << " " << access->AccessSerialize() << " " << access->last_seen << " " << access->creator << " " << access->created << endl;
|
||||
}
|
||||
for (unsigned k = 0, end = ci->GetAkickCount(); k < end; ++k)
|
||||
{
|
||||
@@ -835,7 +836,7 @@ class DBPlain : public Module
|
||||
//FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteMetadata, ci));
|
||||
}
|
||||
|
||||
db_buffer << "OS STATS " << maxusercnt << " " << maxusertime << endl;
|
||||
db_buffer << "OS STATS " << MaxUserCount << " " << MaxUserTime << endl;
|
||||
|
||||
for (std::list<XLineManager *>::iterator it = XLineManager::XLineManagers.begin(), it_end = XLineManager::XLineManagers.end(); it != it_end; ++it)
|
||||
{
|
||||
@@ -843,7 +844,7 @@ class DBPlain : public Module
|
||||
for (unsigned i = 0, end = xl->GetCount(); i < end; ++i)
|
||||
{
|
||||
const XLine *x = xl->GetEntry(i);
|
||||
db_buffer << "OS SXLINE " << xl->Type() << " " << x->GetUser() << " " << x->GetHost() << " " << x->By << " " << x->Created << " " << x->Expires << " :" << x->Reason << endl;
|
||||
db_buffer << "OS SXLINE " << xl->Type() << " " << x->GetUser() << " " << x->GetHost() << " " << x->by << " " << x->created << " " << x->expires << " :" << x->reason << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -861,7 +862,7 @@ class DBPlain : public Module
|
||||
|
||||
if (!db.is_open())
|
||||
{
|
||||
ircdproto->SendGlobops(NULL, "Unable to open %s for writing!", DatabaseFile.c_str());
|
||||
IRCD->SendGlobops(NULL, "Unable to open %s for writing!", DatabaseFile.c_str());
|
||||
return EVENT_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
+12
-12
@@ -33,7 +33,7 @@ class SQLSQLInterface : public SQLInterface
|
||||
|
||||
class ResultSQLSQLInterface : public SQLSQLInterface
|
||||
{
|
||||
dynamic_reference<Serializable> obj;
|
||||
Reference<Serializable> obj;
|
||||
|
||||
public:
|
||||
ResultSQLSQLInterface(Module *o, Serializable *ob) : SQLSQLInterface(o), obj(ob) { }
|
||||
@@ -55,10 +55,10 @@ public:
|
||||
|
||||
class DBSQL : public Module, public Pipe
|
||||
{
|
||||
service_reference<SQLProvider> sql;
|
||||
ServiceReference<SQLProvider> sql;
|
||||
SQLSQLInterface sqlinterface;
|
||||
Anope::string prefix;
|
||||
std::set<dynamic_reference<Serializable> > updated_items;
|
||||
std::set<Reference<Serializable> > updated_items;
|
||||
bool shutting_down;
|
||||
|
||||
void RunBackground(const SQLQuery &q, SQLInterface *iface = NULL)
|
||||
@@ -72,7 +72,7 @@ class DBSQL : public Module, public Pipe
|
||||
Log(this) << "db_sql: Unable to execute query, is SQL configured correctly?";
|
||||
}
|
||||
}
|
||||
else if (!quitting)
|
||||
else if (!Anope::Quitting)
|
||||
{
|
||||
if (iface == NULL)
|
||||
iface = &this->sqlinterface;
|
||||
@@ -95,9 +95,9 @@ class DBSQL : public Module, public Pipe
|
||||
|
||||
void OnNotify() anope_override
|
||||
{
|
||||
for (std::set<dynamic_reference<Serializable> >::iterator it = this->updated_items.begin(), it_end = this->updated_items.end(); it != it_end; ++it)
|
||||
for (std::set<Reference<Serializable> >::iterator it = this->updated_items.begin(), it_end = this->updated_items.end(); it != it_end; ++it)
|
||||
{
|
||||
dynamic_reference<Serializable> obj = *it;
|
||||
Reference<Serializable> obj = *it;
|
||||
|
||||
if (obj && this->sql)
|
||||
{
|
||||
@@ -105,11 +105,11 @@ class DBSQL : public Module, public Pipe
|
||||
continue;
|
||||
obj->UpdateCache();
|
||||
|
||||
SerializeType *s_type = obj->GetSerializableType();
|
||||
Serialize::Type *s_type = obj->GetSerializableType();
|
||||
if (!s_type)
|
||||
continue;
|
||||
|
||||
Serialize::Data data = obj->serialize();
|
||||
Serialize::Data data = obj->Serialize();
|
||||
|
||||
std::vector<SQLQuery> create = this->sql->CreateTable(this->prefix + s_type->GetName(), data);
|
||||
for (unsigned i = 0; i < create.size(); ++i)
|
||||
@@ -127,7 +127,7 @@ class DBSQL : public Module, public Pipe
|
||||
{
|
||||
ConfigReader config;
|
||||
Anope::string engine = config.ReadValue("db_sql", "engine", "", 0);
|
||||
this->sql = service_reference<SQLProvider>("SQLProvider", engine);
|
||||
this->sql = ServiceReference<SQLProvider>("SQLProvider", engine);
|
||||
this->prefix = config.ReadValue("db_sql", "prefix", "anope_db_", 0);
|
||||
}
|
||||
|
||||
@@ -150,10 +150,10 @@ class DBSQL : public Module, public Pipe
|
||||
return EVENT_CONTINUE;
|
||||
}
|
||||
|
||||
const std::vector<Anope::string> type_order = SerializeType::GetTypeOrder();
|
||||
const std::vector<Anope::string> type_order = Serialize::Type::GetTypeOrder();
|
||||
for (unsigned i = 0; i < type_order.size(); ++i)
|
||||
{
|
||||
SerializeType *sb = SerializeType::Find(type_order[i]);
|
||||
Serialize::Type *sb = Serialize::Type::Find(type_order[i]);
|
||||
|
||||
SQLQuery query("SELECT * FROM `" + this->prefix + sb->GetName() + "`");
|
||||
SQLResult res = this->sql->RunQuery(query);
|
||||
@@ -192,7 +192,7 @@ class DBSQL : public Module, public Pipe
|
||||
|
||||
void OnSerializableDestruct(Serializable *obj) anope_override
|
||||
{
|
||||
SerializeType *s_type = obj->GetSerializableType();
|
||||
Serialize::Type *s_type = obj->GetSerializableType();
|
||||
if (s_type)
|
||||
this->RunBackground("DELETE FROM `" + this->prefix + s_type->GetName() + "` WHERE `id` = " + stringify(obj->id));
|
||||
}
|
||||
|
||||
@@ -7,22 +7,20 @@ class DBMySQL : public Module, public Pipe
|
||||
private:
|
||||
Anope::string engine;
|
||||
Anope::string prefix;
|
||||
service_reference<SQLProvider> SQL;
|
||||
ServiceReference<SQLProvider> SQL;
|
||||
time_t lastwarn;
|
||||
bool ro;
|
||||
bool init;
|
||||
std::set<dynamic_reference<Serializable> > updated_items;
|
||||
std::set<Reference<Serializable> > updated_items;
|
||||
|
||||
bool CheckSQL()
|
||||
{
|
||||
if (SQL)
|
||||
{
|
||||
if (readonly && this->ro)
|
||||
if (Anope::ReadOnly && this->ro)
|
||||
{
|
||||
readonly = this->ro = false;
|
||||
const BotInfo *bi = findbot(Config->OperServ);
|
||||
if (bi)
|
||||
ircdproto->SendGlobops(bi, "Found SQL again, going out of readonly mode...");
|
||||
Anope::ReadOnly = this->ro = false;
|
||||
Log() << "Found SQL again, going out of readonly mode...";
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -31,10 +29,8 @@ class DBMySQL : public Module, public Pipe
|
||||
{
|
||||
if (Anope::CurTime - Config->UpdateTimeout > lastwarn)
|
||||
{
|
||||
const BotInfo *bi = findbot(Config->OperServ);
|
||||
if (bi)
|
||||
ircdproto->SendGlobops(bi, "Unable to locate SQL reference, going to readonly...");
|
||||
readonly = this->ro = true;
|
||||
Log() << "Unable to locate SQL reference, going to readonly...";
|
||||
Anope::ReadOnly = this->ro = true;
|
||||
this->lastwarn = Anope::CurTime;
|
||||
}
|
||||
|
||||
@@ -85,9 +81,9 @@ class DBMySQL : public Module, public Pipe
|
||||
if (!this->CheckInit())
|
||||
return;
|
||||
|
||||
for (std::set<dynamic_reference<Serializable> >::iterator it = this->updated_items.begin(), it_end = this->updated_items.end(); it != it_end; ++it)
|
||||
for (std::set<Reference<Serializable> >::iterator it = this->updated_items.begin(), it_end = this->updated_items.end(); it != it_end; ++it)
|
||||
{
|
||||
dynamic_reference<Serializable> obj = *it;
|
||||
Reference<Serializable> obj = *it;
|
||||
|
||||
if (obj && this->SQL)
|
||||
{
|
||||
@@ -95,11 +91,11 @@ class DBMySQL : public Module, public Pipe
|
||||
continue;
|
||||
obj->UpdateCache();
|
||||
|
||||
SerializeType *s_type = obj->GetSerializableType();
|
||||
Serialize::Type *s_type = obj->GetSerializableType();
|
||||
if (!s_type)
|
||||
continue;
|
||||
|
||||
Serialize::Data data = obj->serialize();
|
||||
Serialize::Data data = obj->Serialize();
|
||||
|
||||
std::vector<SQLQuery> create = this->SQL->CreateTable(this->prefix + s_type->GetName(), data);
|
||||
for (unsigned i = 0; i < create.size(); ++i)
|
||||
@@ -133,7 +129,7 @@ class DBMySQL : public Module, public Pipe
|
||||
{
|
||||
ConfigReader config;
|
||||
this->engine = config.ReadValue("db_sql", "engine", "", 0);
|
||||
this->SQL = service_reference<SQLProvider>("SQLProvider", this->engine);
|
||||
this->SQL = ServiceReference<SQLProvider>("SQLProvider", this->engine);
|
||||
this->prefix = config.ReadValue("db_sql", "prefix", "anope_db_", 0);
|
||||
}
|
||||
|
||||
@@ -149,14 +145,14 @@ class DBMySQL : public Module, public Pipe
|
||||
{
|
||||
if (!this->CheckInit())
|
||||
return;
|
||||
SerializeType *s_type = obj->GetSerializableType();
|
||||
Serialize::Type *s_type = obj->GetSerializableType();
|
||||
if (!s_type)
|
||||
return;
|
||||
this->RunQuery("DELETE FROM `" + this->prefix + s_type->GetName() + "` WHERE `id` = " + stringify(obj->id));
|
||||
s_type->objects.erase(obj->id);
|
||||
}
|
||||
|
||||
void OnSerializeCheck(SerializeType *obj) anope_override
|
||||
void OnSerializeCheck(Serialize::Type *obj) anope_override
|
||||
{
|
||||
if (!this->CheckInit() || obj->GetTimestamp() == Anope::CurTime)
|
||||
return;
|
||||
@@ -189,7 +185,7 @@ class DBMySQL : public Module, public Pipe
|
||||
std::map<unsigned int, Serializable *>::iterator it = obj->objects.find(id);
|
||||
if (it != obj->objects.end())
|
||||
{
|
||||
it->second->destroy();
|
||||
it->second->Destroy();
|
||||
obj->objects.erase(it);
|
||||
}
|
||||
}
|
||||
@@ -217,7 +213,7 @@ class DBMySQL : public Module, public Pipe
|
||||
}
|
||||
}
|
||||
else
|
||||
s->destroy();
|
||||
s->Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user