diff --git a/include/modules.h b/include/modules.h index 26c47d450..491f8e277 100644 --- a/include/modules.h +++ b/include/modules.h @@ -1248,9 +1248,10 @@ public: /** Find the first module of a certain type * @param type The module type + * @param ignore If non-nullptr then a module to ignore. * @return The module */ - static Module *FindFirstOf(ModType type); + static Module *FindFirstOf(ModType type, Module *ignore = nullptr); /** Checks whether this version of Anope is at least major.minor.patch.build * Throws a ModuleException if not diff --git a/modules/database/db_flatfile.cpp b/modules/database/db_flatfile.cpp index 0f53e6afd..8953afb1f 100644 --- a/modules/database/db_flatfile.cpp +++ b/modules/database/db_flatfile.cpp @@ -80,6 +80,8 @@ public: DBFlatFile(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, DATABASE | DEPRECATED | VENDOR) { + if (!ModuleManager::FindFirstOf(DATABASE, this)) + throw ModuleException("db_flatfile is deprecated and can only import old databases."); } EventReturn OnLoadDatabase() override diff --git a/src/init.cpp b/src/init.cpp index 282ec8957..1ade6be64 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -552,8 +552,10 @@ bool Anope::Init(int ac, char **av) setuidgid(); #endif - auto *encryption = ModuleManager::FindFirstOf(ENCRYPTION); - if (!encryption) + if (!ModuleManager::FindFirstOf(DATABASE)) + throw CoreException("You must load a non-deprecated database module!"); + + if (!ModuleManager::FindFirstOf(ENCRYPTION)) throw CoreException("You must load a non-deprecated encryption module!"); if (!IRCD) diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp index 77dc2804b..ceee29874 100644 --- a/src/modulemanager.cpp +++ b/src/modulemanager.cpp @@ -262,11 +262,11 @@ Module *ModuleManager::FindModule(const Anope::string &name) return NULL; } -Module *ModuleManager::FindFirstOf(ModType type) +Module *ModuleManager::FindFirstOf(ModType type, Module *ignore) { for (auto *m : Modules) { - if (m->type & type) + if (m->type & type && m != ignore) return m; }