summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2013-04-10 22:26:40 -0500
committerAdam <Adam@anope.org>2013-04-10 22:26:40 -0500
commit207c46c871e85b55ae66acc456c6bc412c0c79f9 (patch)
tree27b07dc9d1e0ee068872ec7841920eea9b846b65 /src
parent957cb2bf93d77a5ebb97d945b0656bd1e7bec164 (diff)
Move some of the modules in extras/ that arent really extra out of extras. Mark our modules as VENDOR and allow modules to have multple types.
Diffstat (limited to 'src')
-rw-r--r--src/module.cpp11
-rw-r--r--src/modulemanager.cpp25
2 files changed, 24 insertions, 12 deletions
diff --git a/src/module.cpp b/src/module.cpp
index a20e7520b..fd7ba63de 100644
--- a/src/module.cpp
+++ b/src/module.cpp
@@ -23,10 +23,19 @@ Module::Module(const Anope::string &modname, const Anope::string &, ModType modt
this->created = Anope::CurTime;
this->SetVersion(Anope::Version());
+ if (type & VENDOR)
+ this->SetAuthor("Anope");
+ else
+ {
+ /* Not vendor implies third */
+ type |= THIRD;
+ this->SetAuthor("Unknown");
+ }
+
if (ModuleManager::FindModule(this->name))
throw CoreException("Module already exists!");
- if (Anope::NoThird && modtype == THIRD)
+ if (Anope::NoThird && type & THIRD)
throw ModuleException("Third party modules may not be loaded");
ModuleManager::Modules.push_back(this);
diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp
index 229067979..a6fa1fffd 100644
--- a/src/modulemanager.cpp
+++ b/src/modulemanager.cpp
@@ -260,7 +260,7 @@ Module *ModuleManager::FindFirstOf(ModType type)
{
Module *m = *it;
- if (m->type == type)
+ if (m->type & type)
return m;
}
@@ -459,17 +459,20 @@ bool ModuleManager::SetPriority(Module *mod, Implementation i, Priority s, Modul
void ModuleManager::UnloadAll()
{
- std::vector<Anope::string> modules[MT_END];
- for (std::list<Module *>::iterator it = Modules.begin(), it_end = Modules.end(); it != it_end; ++it)
- if ((*it)->type != PROTOCOL && !(*it)->GetPermanent())
- modules[(*it)->type].push_back((*it)->name);
-
- for (size_t i = MT_BEGIN + 1; i != MT_END; ++i)
- for (unsigned j = 0; j < modules[i].size(); ++j)
+ std::vector<Anope::string> modules;
+ for (size_t i = 1, j = 0; i != MT_END; i <<= 1, j |= i)
+ for (std::list<Module *>::iterator it = Modules.begin(), it_end = Modules.end(); it != it_end; ++it)
{
- Module *m = FindModule(modules[i][j]);
- if (m != NULL)
- UnloadModule(m, NULL);
+ Module *m = *it;
+ if ((m->type & j) == m->type)
+ modules.push_back(m->name);
}
+
+ for (unsigned i = 0; i < modules.size(); ++i)
+ {
+ Module *m = FindModule(modules[i]);
+ if (m != NULL)
+ UnloadModule(m, NULL);
+ }
}