|
@@ -60,11 +60,6 @@ namespace love
|
|
|
|
|
|
Module *Module::instances[] = {};
|
|
|
|
|
|
-Module::Module()
|
|
|
- : moduleType(M_INVALID)
|
|
|
-{
|
|
|
-}
|
|
|
-
|
|
|
Module::~Module()
|
|
|
{
|
|
|
ModuleRegistry ®istry = registryInstance();
|
|
@@ -79,15 +74,14 @@ Module::~Module()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- freeEmptyRegistry();
|
|
|
-
|
|
|
- if (instances[moduleType] == this)
|
|
|
- instances[moduleType] = nullptr;
|
|
|
-}
|
|
|
+ // Same deal with Module::getModuleType().
|
|
|
+ for (int i = 0; i < (int) M_MAX_ENUM; i++)
|
|
|
+ {
|
|
|
+ if (instances[i] == this)
|
|
|
+ instances[i] = nullptr;
|
|
|
+ }
|
|
|
|
|
|
-Module::ModuleType Module::getModuleType() const
|
|
|
-{
|
|
|
- return moduleType;
|
|
|
+ freeEmptyRegistry();
|
|
|
}
|
|
|
|
|
|
void Module::registerInstance(Module *instance)
|
|
@@ -108,12 +102,10 @@ void Module::registerInstance(Module *instance)
|
|
|
throw Exception("Module %s already registered!", instance->getName());
|
|
|
}
|
|
|
|
|
|
- ModuleType moduletype = instance->getModuleType();
|
|
|
- if (moduletype == M_INVALID)
|
|
|
- throw love::Exception("Module %s has an invalid base module type.", instance->getName());
|
|
|
-
|
|
|
registry.insert(make_pair(name, instance));
|
|
|
|
|
|
+ ModuleType moduletype = instance->getModuleType();
|
|
|
+
|
|
|
if (instances[moduletype] != nullptr)
|
|
|
{
|
|
|
printf("Warning: overwriting module instance %s with new instance %s\n",
|