mirror of
https://github.com/love2d/love-android.git
synced 2026-08-20 04:31:26 +02:00
actual update to latest mobile-common
This commit is contained in:
@@ -58,6 +58,8 @@ namespace
|
||||
namespace love
|
||||
{
|
||||
|
||||
Module *Module::instances[] = {};
|
||||
|
||||
Module::~Module()
|
||||
{
|
||||
ModuleRegistry ®istry = registryInstance();
|
||||
@@ -72,6 +74,13 @@ Module::~Module()
|
||||
}
|
||||
}
|
||||
|
||||
// Same deal with Module::getModuleType().
|
||||
for (int i = 0; i < (int) M_MAX_ENUM; i++)
|
||||
{
|
||||
if (instances[i] == this)
|
||||
instances[i] = nullptr;
|
||||
}
|
||||
|
||||
freeEmptyRegistry();
|
||||
}
|
||||
|
||||
@@ -94,6 +103,16 @@ void Module::registerInstance(Module *instance)
|
||||
}
|
||||
|
||||
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",
|
||||
instances[moduletype]->getName(), instance->getName());
|
||||
}
|
||||
|
||||
instances[moduletype] = instance;
|
||||
}
|
||||
|
||||
Module *Module::getInstance(const std::string &name)
|
||||
@@ -108,17 +127,4 @@ Module *Module::getInstance(const std::string &name)
|
||||
return it->second;
|
||||
}
|
||||
|
||||
Module *Module::findInstance(const std::string &name)
|
||||
{
|
||||
ModuleRegistry ®istry = registryInstance();
|
||||
|
||||
for (auto it = registry.begin(); it != registry.end(); ++it)
|
||||
{
|
||||
if (it->first.find(name) == 0)
|
||||
return it->second;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // love
|
||||
|
||||
Reference in New Issue
Block a user