diff options
| author | Adam <Adam@anope.org> | 2013-04-11 00:08:28 -0500 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2013-04-11 00:08:28 -0500 |
| commit | 4f9b7874d6b3a41939ecc2e872ec08d03af7b5f1 (patch) | |
| tree | 43162205d31b277c9ff12ee28b7e3a60d6382316 /modules | |
| parent | 207c46c871e85b55ae66acc456c6bc412c0c79f9 (diff) | |
Pass new config and the new config reader to the OnReload event, aswell as call it on module load on modules that hook to it
Diffstat (limited to 'modules')
39 files changed, 200 insertions, 355 deletions
diff --git a/modules/bs_autoassign.cpp b/modules/bs_autoassign.cpp index 13bde5ff5..134904925 100644 --- a/modules/bs_autoassign.cpp +++ b/modules/bs_autoassign.cpp @@ -19,8 +19,6 @@ class BSAutoAssign : public Module Implementation i[] = { I_OnChanRegistered, I_OnReload }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); - - this->OnReload(); } void OnChanRegistered(ChannelInfo *ci) anope_override @@ -38,10 +36,9 @@ class BSAutoAssign : public Module bi->Assign(NULL, ci); } - void OnReload() anope_override + void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override { - ConfigReader config; - this->bot = config.ReadValue("bs_autoassign", "bot", "", 0); + this->bot = reader.ReadValue("bs_autoassign", "bot", "", 0); } }; diff --git a/modules/commands/cs_access.cpp b/modules/commands/cs_access.cpp index 10a4c9885..90e17eeed 100644 --- a/modules/commands/cs_access.cpp +++ b/modules/commands/cs_access.cpp @@ -790,24 +790,21 @@ class CSAccess : public Module Implementation i[] = { I_OnReload, I_OnCreateChan, I_OnGroupCheckPriv }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); - - this->OnReload(); } - void OnReload() anope_override + void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override { defaultLevels.clear(); - ConfigReader config; - for (int i = 0; i < config.Enumerate("privilege"); ++i) + for (int i = 0; i < reader.Enumerate("privilege"); ++i) { - const Anope::string &pname = config.ReadValue("privilege", "name", "", i); + const Anope::string &pname = reader.ReadValue("privilege", "name", "", i); Privilege *p = PrivilegeManager::FindPrivilege(pname); if (p == NULL) continue; - const Anope::string &value = config.ReadValue("privilege", "level", "", i); + const Anope::string &value = reader.ReadValue("privilege", "level", "", i); if (value.empty()) continue; else if (value.equals_ci("founder")) @@ -815,7 +812,7 @@ class CSAccess : public Module else if (value.equals_ci("disabled")) defaultLevels[p->name] = ACCESS_INVALID; else - defaultLevels[p->name] = config.ReadInteger("privilege", "level", i, false); + defaultLevels[p->name] = reader.ReadInteger("privilege", "level", i, false); } } diff --git a/modules/commands/cs_entrymsg.cpp b/modules/commands/cs_entrymsg.cpp index bb82e9b24..961cf1895 100644 --- a/modules/commands/cs_entrymsg.cpp +++ b/modules/commands/cs_entrymsg.cpp @@ -278,8 +278,6 @@ class CSEntryMessage : public Module Implementation i[] = { I_OnReload, I_OnJoinChannel }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); - - this->OnReload(); } void OnJoinChannel(User *u, Channel *c) anope_override @@ -294,10 +292,9 @@ class CSEntryMessage : public Module } } - void OnReload() anope_override + void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override { - ConfigReader config; - MaxEntries = config.ReadInteger("cs_entrymsg", "maxentries", "5", 0, true); + MaxEntries = reader.ReadInteger("cs_entrymsg", "maxentries", "5", 0, true); } }; diff --git a/modules/commands/cs_fantasy_stats.cpp b/modules/commands/cs_fantasy_stats.cpp index 591da28e9..b1b878c63 100644 --- a/modules/commands/cs_fantasy_stats.cpp +++ b/modules/commands/cs_fantasy_stats.cpp @@ -75,14 +75,12 @@ class CSStats : public Module Implementation i[] = { I_OnReload }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); - this->OnReload(); } - void OnReload() anope_override + void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override { - ConfigReader config; - prefix = config.ReadValue("chanstats", "prefix", "anope_", 0); - Anope::string engine = config.ReadValue("chanstats", "engine", "", 0); + prefix = reader.ReadValue("chanstats", "prefix", "anope_", 0); + Anope::string engine = reader.ReadValue("chanstats", "engine", "", 0); this->sql = ServiceReference<SQL::Provider>("SQL::Provider", engine); } diff --git a/modules/commands/cs_fantasy_top.cpp b/modules/commands/cs_fantasy_top.cpp index 739f21f41..4bad46e51 100644 --- a/modules/commands/cs_fantasy_top.cpp +++ b/modules/commands/cs_fantasy_top.cpp @@ -102,14 +102,12 @@ class CSTop : public Module Implementation i[] = { I_OnReload }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); - this->OnReload(); } - void OnReload() anope_override + void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override { - ConfigReader config; - prefix = config.ReadValue("chanstats", "prefix", "anope_", 0); - Anope::string engine = config.ReadValue("chanstats", "engine", "", 0); + prefix = reader.ReadValue("chanstats", "prefix", "anope_", 0); + Anope::string engine = reader.ReadValue("chanstats", "engine", "", 0); this->sql = ServiceReference<SQL::Provider>("SQL::Provider", engine); } diff --git a/modules/commands/cs_flags.cpp b/modules/commands/cs_flags.cpp index bdff5a6e5..cd1a14e83 100644 --- a/modules/commands/cs_flags.cpp +++ b/modules/commands/cs_flags.cpp @@ -394,24 +394,21 @@ class CSFlags : public Module Implementation i[] = { I_OnReload }; ModuleManager::Attach(i, this, 1); - - this->OnReload(); } - void OnReload() anope_override + void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override { - ConfigReader config; defaultFlags.clear(); - for (int i = 0; i < config.Enumerate("privilege"); ++i) + for (int i = 0; i < reader.Enumerate("privilege"); ++i) { - const Anope::string &pname = config.ReadValue("privilege", "name", "", i); + const Anope::string &pname = reader.ReadValue("privilege", "name", "", i); Privilege *p = PrivilegeManager::FindPrivilege(pname); if (p == NULL) continue; - const Anope::string &value = config.ReadValue("privilege", "flag", "", i); + const Anope::string &value = reader.ReadValue("privilege", "flag", "", i); if (value.empty()) continue; diff --git a/modules/commands/cs_seen.cpp b/modules/commands/cs_seen.cpp index 7c88c89b8..2d45f9a15 100644 --- a/modules/commands/cs_seen.cpp +++ b/modules/commands/cs_seen.cpp @@ -335,15 +335,12 @@ class CSSeen : public Module I_OnPartChannel, I_OnUserKicked }; ModuleManager::Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); - - OnReload(); } - void OnReload() anope_override + void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override { - ConfigReader config; - purgetime = Anope::DoTime(config.ReadValue("cs_seen", "purgetime", "30d", 0)); - expiretimeout = Anope::DoTime(config.ReadValue("cs_seen", "expiretimeout", "1d", 0)); + purgetime = Anope::DoTime(reader.ReadValue("cs_seen", "purgetime", "30d", 0)); + expiretimeout = Anope::DoTime(reader.ReadValue("cs_seen", "expiretimeout", "1d", 0)); if (purger.GetSecs() != expiretimeout) purger.SetSecs(expiretimeout); diff --git a/modules/commands/cs_set.cpp b/modules/commands/cs_set.cpp index 03aa6c59c..7b6df8a9b 100644 --- a/modules/commands/cs_set.cpp +++ b/modules/commands/cs_set.cpp @@ -1164,14 +1164,11 @@ class CSSet : public Module Implementation i[] = { I_OnReload, I_OnChanRegistered, I_OnCheckKick, I_OnDelChan }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); - - this->OnReload(); } - void OnReload() anope_override + void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override { - ConfigReader config; - CSDefChanstats = config.ReadFlag("chanstats", "CSDefChanstats", "0", 0); + CSDefChanstats = reader.ReadFlag("chanstats", "CSDefChanstats", "0", 0); } void OnChanRegistered(ChannelInfo *ci) anope_override diff --git a/modules/commands/cs_set_misc.cpp b/modules/commands/cs_set_misc.cpp index 93897f332..e74587be1 100644 --- a/modules/commands/cs_set_misc.cpp +++ b/modules/commands/cs_set_misc.cpp @@ -138,26 +138,21 @@ class CSSetMisc : public Module CSSetMisc(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), csmiscdata_type("CSMiscData", CSMiscData::Unserialize), commandcssetmisc(this) { - Implementation i[] = { I_OnReload, I_OnChanInfo }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); - - this->OnReload(); } - void OnReload() + void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override { - ConfigReader config; - descriptions.clear(); - for (int i = 0; i < config.Enumerate("command"); ++i) + for (int i = 0; i < reader.Enumerate("command"); ++i) { - if (config.ReadValue("command", "command", "", i) != "chanserv/set/misc") + if (reader.ReadValue("command", "command", "", i) != "chanserv/set/misc") continue; - Anope::string cname = config.ReadValue("command", "name", "", i); - Anope::string desc = config.ReadValue("command", "misc_description", "", i); + Anope::string cname = reader.ReadValue("command", "name", "", i); + Anope::string desc = reader.ReadValue("command", "misc_description", "", i); if (cname.empty() || desc.empty()) continue; diff --git a/modules/commands/cs_xop.cpp b/modules/commands/cs_xop.cpp index 1cfa033e2..32253770f 100644 --- a/modules/commands/cs_xop.cpp +++ b/modules/commands/cs_xop.cpp @@ -543,36 +543,33 @@ class CSXOP : public Module accessprovider(this), commandcsxop(this) { this->SetPermanent(true); - - this->OnReload(); } - void OnReload() anope_override + void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override { order.clear(); permissions.clear(); - ConfigReader config; - for (int i = 0; i < config.Enumerate("privilege"); ++i) + for (int i = 0; i < reader.Enumerate("privilege"); ++i) { - const Anope::string &pname = config.ReadValue("privilege", "name", "", i); + const Anope::string &pname = reader.ReadValue("privilege", "name", "", i); Privilege *p = PrivilegeManager::FindPrivilege(pname); if (p == NULL) continue; - const Anope::string &xop = config.ReadValue("privilege", "xop", "", i); + const Anope::string &xop = reader.ReadValue("privilege", "xop", "", i); if (xop.empty()) continue; permissions[xop].push_back(pname); } - for (int i = 0; i < config.Enumerate("command"); ++i) + for (int i = 0; i < reader.Enumerate("command"); ++i) { - const Anope::string &cname = config.ReadValue("command", "name", "", i), - &cserv = config.ReadValue("command", "command", "", i); + const Anope::string &cname = reader.ReadValue("command", "name", "", i), + &cserv = reader.ReadValue("command", "command", "", i); if (cname.empty() || cserv != "chanserv/xop") continue; diff --git a/modules/commands/hs_request.cpp b/modules/commands/hs_request.cpp index 1867dbb77..8b551f0ed 100644 --- a/modules/commands/hs_request.cpp +++ b/modules/commands/hs_request.cpp @@ -357,8 +357,6 @@ class HSRequest : public Module Implementation i[] = { I_OnReload }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); - - this->OnReload(); } ~HSRequest() @@ -370,13 +368,10 @@ class HSRequest : public Module } } - void OnReload() anope_override + void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override { - ConfigReader config; - HSRequestMemoUser = config.ReadFlag("hs_request", "memouser", "no", 0); - HSRequestMemoOper = config.ReadFlag("hs_request", "memooper", "no", 0); - - Log(LOG_DEBUG) << "[hs_request] Set config vars: MemoUser=" << HSRequestMemoUser << " MemoOper=" << HSRequestMemoOper; + HSRequestMemoUser = reader.ReadFlag("hs_request", "memouser", "no", 0); + HSRequestMemoOper = reader.ReadFlag("hs_request", "memooper", "no", 0); } }; diff --git a/modules/commands/ns_set.cpp b/modules/commands/ns_set.cpp index f8b2b7155..793b99fd1 100644 --- a/modules/commands/ns_set.cpp +++ b/modules/commands/ns_set.cpp @@ -1404,14 +1404,11 @@ class NSSet : public Module Implementation i[] = { I_OnReload, I_OnNickRegister, I_OnPreCommand }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); - - this->OnReload(); } - void OnReload() anope_override + void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override { - ConfigReader config; - NSDefChanstats = config.ReadFlag("chanstats", "NSDefChanstats", "0", 0); + NSDefChanstats = reader.ReadFlag("chanstats", "NSDefChanstats", "0", 0); } void OnNickRegister(NickAlias *na) anope_override diff --git a/modules/commands/ns_set_misc.cpp b/modules/commands/ns_set_misc.cpp index 35210abd0..5ee77a938 100644 --- a/modules/commands/ns_set_misc.cpp +++ b/modules/commands/ns_set_misc.cpp @@ -157,26 +157,21 @@ class NSSetMisc : public Module NSSetMisc(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), nsmiscdata_type("NSMiscData", NSMiscData::Unserialize), commandnssetmisc(this), commandnssasetmisc(this) { - Implementation i[] = { I_OnReload, I_OnNickInfo }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); - - this->OnReload(); } - void OnReload() + void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override { - ConfigReader config; - descriptions.clear(); - for (int i = 0; i < config.Enumerate("command"); ++i) + for (int i = 0; i < reader.Enumerate("command"); ++i) { - if (config.ReadValue("command", "command", "", i) != "nickserv/set/misc" && config.ReadValue("command", "command", "", i) != "nickserv/saset/misc") + if (reader.ReadValue("command", "command", "", i) != "nickserv/set/misc" && reader.ReadValue("command", "command", "", i) != "nickserv/saset/misc") continue; - Anope::string cname = config.ReadValue("command", "name", "", i); - Anope::string desc = config.ReadValue("command", "misc_description", "", i); + Anope::string cname = reader.ReadValue("command", "name", "", i); + Anope::string desc = reader.ReadValue("command", "misc_description", "", i); if (cname.empty() || desc.empty()) continue; diff --git a/modules/commands/os_config.cpp b/modules/commands/os_config.cpp index 540bcc3e7..0517f28d7 100644 --- a/modules/commands/os_config.cpp +++ b/modules/commands/os_config.cpp @@ -64,7 +64,7 @@ class CommandOSConfig : public Command bool allow_wild = dt & DT_ALLOW_WILD; dt &= ~(DT_ALLOW_NEWLINE | DT_ALLOW_WILD); - /* Yay for *massive* copypaste from config.cpp */ + /* Yay for *massive* copypaste from reader.cpp */ switch (dt) { case DT_NOSPACES: diff --git a/modules/commands/os_defcon.cpp b/modules/commands/os_defcon.cpp index 53148c6a8..dd45856fb 100644 --- a/modules/commands/os_defcon.cpp +++ b/modules/commands/os_defcon.cpp @@ -334,36 +334,25 @@ class OSDefcon : public Module Implementation i[] = { I_OnReload, I_OnChannelModeSet, I_OnChannelModeUnset, I_OnPreCommand, I_OnUserConnect, I_OnChannelModeAdd, I_OnChannelCreate }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); - - - try - { - this->OnReload(); - } - catch (const ConfigException &ex) - { - throw ModuleException(ex.GetReason()); - } } - void OnReload() anope_override + void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override { - ConfigReader config; DefconConfig dconfig; - dconfig.defaultlevel = config.ReadInteger("defcon", "defaultlevel", 0, 0); - dconfig.defcons[4] = config.ReadValue("defcon", "level4", 0); - dconfig.defcons[3] = config.ReadValue("defcon", "level3", 0); - dconfig.defcons[2] = config.ReadValue("defcon", "level2", 0); - dconfig.defcons[1] = config.ReadValue("defcon", "level1", 0); - dconfig.sessionlimit = config.ReadInteger("defcon", "sessionlimit", 0, 0); - dconfig.akillreason = config.ReadValue("defcon", "akillreason", 0); - dconfig.akillexpire = Anope::DoTime(config.ReadValue("defcon", "akillexpire", 0)); - dconfig.chanmodes = config.ReadValue("defcon", "chanmodes", 0); - dconfig.timeout = Anope::DoTime(config.ReadValue("defcon", "timeout", 0)); - dconfig.globalondefcon = config.ReadFlag("defcon", "globalondefcon", 0); - dconfig.message = config.ReadValue("defcon", "message", 0); - dconfig.offmessage = config.ReadValue("defcon", "offmessage", 0); + dconfig.defaultlevel = reader.ReadInteger("defcon", "defaultlevel", 0, 0); + dconfig.defcons[4] = reader.ReadValue("defcon", "level4", 0); + dconfig.defcons[3] = reader.ReadValue("defcon", "level3", 0); + dconfig.defcons[2] = reader.ReadValue("defcon", "level2", 0); + dconfig.defcons[1] = reader.ReadValue("defcon", "level1", 0); + dconfig.sessionlimit = reader.ReadInteger("defcon", "sessionlimit", 0, 0); + dconfig.akillreason = reader.ReadValue("defcon", "akillreason", 0); + dconfig.akillexpire = Anope::DoTime(reader.ReadValue("defcon", "akillexpire", 0)); + dconfig.chanmodes = reader.ReadValue("defcon", "chanmodes", 0); + dconfig.timeout = Anope::DoTime(reader.ReadValue("defcon", "timeout", 0)); + dconfig.globalondefcon = reader.ReadFlag("defcon", "globalondefcon", 0); + dconfig.message = reader.ReadValue("defcon", "message", 0); + dconfig.offmessage = reader.ReadValue("defcon", "offmessage", 0); if (dconfig.defaultlevel < 1 || dconfig.defaultlevel > 5) throw ConfigException("The value for <defcon:defaultlevel> must be between 1 and 5"); diff --git a/modules/commands/os_dns.cpp b/modules/commands/os_dns.cpp index efcff8fc5..04971e89a 100644 --- a/modules/commands/os_dns.cpp +++ b/modules/commands/os_dns.cpp @@ -670,8 +670,6 @@ class ModuleDNS : public Module Implementation i[] = { I_OnReload, I_OnNewServer, I_OnServerQuit, I_OnUserConnect, I_OnPreUserLogoff, I_OnDnsRequest }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); - this->OnReload(); - for (unsigned j = 0; j < dns_servers->size(); ++j) { DNSServer *s = dns_servers->at(j); @@ -688,16 +686,15 @@ class ModuleDNS : public Module delete dns_servers->at(i - 1); } - void OnReload() anope_override + void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override { - ConfigReader config; - this->ttl = Anope::DoTime(config.ReadValue("os_dns", "ttl", 0)); - this->user_drop_mark = config.ReadInteger("os_dns", "user_drop_mark", 0, false); - this->user_drop_time = Anope::DoTime(config.ReadValue("os_dns", "user_drop_time", 0, false)); - this->user_drop_readd_time = Anope::DoTime(config.ReadValue("os_dns", "user_drop_readd_time", 0, false)); - this->remove_split_servers = config.ReadFlag("os_dns", "remove_split_servers", 0); - this->readd_connected_servers = config.ReadFlag("os_dns", "readd_connected_servers", 0); + this->ttl = Anope::DoTime(reader.ReadValue("os_dns", "ttl", 0)); + this->user_drop_mark = reader.ReadInteger("os_dns", "user_drop_mark", 0, false); + this->user_drop_time = Anope::DoTime(reader.ReadValue("os_dns", "user_drop_time", 0, false)); + this->user_drop_readd_time = Anope::DoTime(reader.ReadValue("os_dns", "user_drop_readd_time", 0, false)); + this->remove_split_servers = reader.ReadFlag("os_dns", "remove_split_servers", 0); + this->readd_connected_servers = reader.ReadFlag("os_dns", "readd_connected_servers", 0); } void OnNewServer(Server *s) anope_override diff --git a/modules/commands/os_logsearch.cpp b/modules/commands/os_logsearch.cpp index 5a063ad53..c033c6bb5 100644 --- a/modules/commands/os_logsearch.cpp +++ b/modules/commands/os_logsearch.cpp @@ -151,17 +151,13 @@ class OSLogSearch : public Module OSLogSearch(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), commandoslogsearch(this) { - Implementation i[] = { I_OnReload }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); - - OnReload(); } - void OnReload() anope_override + void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override { - ConfigReader config; - logfile_name = config.ReadValue("logsearch", "name", "services.log", 0); + logfile_name = reader.ReadValue("logsearch", "name", "services.log", 0); } }; diff --git a/modules/commands/os_reload.cpp b/modules/commands/os_reload.cpp index 86b3a040e..fcf3868fa 100644 --- a/modules/commands/os_reload.cpp +++ b/modules/commands/os_reload.cpp @@ -24,23 +24,18 @@ class CommandOSReload : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - ServerConfig *old_config = Config; - try { - Config = new ServerConfig(); - FOREACH_MOD(I_OnReload, OnReload()); - delete old_config; + ServerConfig *new_config = new ServerConfig(); + delete Config; + Config = new_config; source.Reply(_("Services' configuration file has been reloaded.")); } catch (const ConfigException &ex) { - Config = old_config; Log(this->owner) << "Error reloading configuration file: " << ex.GetReason(); - source.Reply(_("Error reloading configuration file: ") + ex.GetReason()); + source.Reply(_("Error reloading configuration file: %s"), ex.GetReason().c_str()); } - - return; } bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override diff --git a/modules/database/db_flatfile.cpp b/modules/database/db_flatfile.cpp index 50a513c65..dcf4a5aa4 100644 --- a/modules/database/db_flatfile.cpp +++ b/modules/database/db_flatfile.cpp @@ -169,8 +169,6 @@ class DBFlatFile : public Module, public Pipe Implementation i[] = { I_OnReload, I_OnLoadDatabase, I_OnSaveDatabase, I_OnSerializeTypeCreate }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); - - OnReload(); } void OnNotify() anope_override @@ -193,11 +191,10 @@ class DBFlatFile : public Module, public Pipe Anope::Quitting = true; } - void OnReload() anope_override + void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override { - ConfigReader config; - database_file = config.ReadValue("db_flatfile", "database", "anope.db", 0); - use_fork = config.ReadFlag("db_flatfile", "fork", "no", 0); + database_file = reader.ReadValue("db_flatfile", "database", "anope.db", 0); + use_fork = reader.ReadFlag("db_flatfile", "fork", "no", 0); } EventReturn OnLoadDatabase() anope_override diff --git a/modules/database/db_plain.cpp b/modules/database/db_plain.cpp index f2b3bffd2..11274c593 100644 --- a/modules/database/db_plain.cpp +++ b/modules/database/db_plain.cpp @@ -589,19 +589,12 @@ class DBPlain : public Module public: DBPlain(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, DATABASE | VENDOR) { - Implementation i[] = { I_OnReload, I_OnLoadDatabase, I_OnSaveDatabase }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); - OnReload(); - LastDay = 0; } - ~DBPlain() - { - } - void BackupDatabase() { /* Do not backup a database that doesn't exist */ @@ -642,11 +635,10 @@ class DBPlain : public Module } } - void OnReload() anope_override + void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override { - ConfigReader config; - DatabaseFile = Anope::DataDir + "/" + config.ReadValue("db_plain", "database", "anope.db", 0); - BackupFile = Anope::DataDir + "/backups/" + config.ReadValue("db_plain", "database", "anope.db", 0); + DatabaseFile = Anope::DataDir + "/" + reader.ReadValue("db_plain", "database", "anope.db", 0); + BackupFile = Anope::DataDir + "/backups/" + reader.ReadValue("db_plain", "database", "anope.db", 0); } EventReturn OnLoadDatabase() anope_override diff --git a/modules/database/db_sql.cpp b/modules/database/db_sql.cpp index 74da4c44c..4025fec69 100644 --- a/modules/database/db_sql.cpp +++ b/modules/database/db_sql.cpp @@ -95,8 +95,6 @@ class DBSQL : public Module, public Pipe Implementation i[] = { I_OnReload, I_OnShutdown, I_OnRestart, I_OnLoadDatabase, I_OnSerializableConstruct, I_OnSerializableDestruct, I_OnSerializableUpdate, I_OnSerializeTypeCreate }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); - this->OnReload(); - if (ModuleManager::FindModule("db_sql_live") != NULL) throw ModuleException("db_sql can not be loaded after db_sql_live"); } @@ -148,13 +146,12 @@ class DBSQL : public Module, public Pipe this->imported = true; } - void OnReload() anope_override + void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override { - ConfigReader config; - Anope::string engine = config.ReadValue("db_sql", "engine", "", 0); + Anope::string engine = read |
