diff --git a/src/common/Module.cpp b/src/common/Module.cpp index dca73b5d2..213a39fbf 100644 --- a/src/common/Module.cpp +++ b/src/common/Module.cpp @@ -113,15 +113,18 @@ void Module::registerInstance(Module *instance) registry.insert(make_pair(name, instance)); - ModuleType moduletype = instance->getModuleType(); + ModuleType mtype = instance->getModuleType(); - if (instances[moduletype] != nullptr) + if (mtype != M_UNKNOWN) { - printf("Warning: overwriting module instance %s with new instance %s\n", - instances[moduletype]->getName(), instance->getName()); - } + if (instances[mtype] != nullptr) + { + printf("Warning: overwriting module instance %s with new instance %s\n", + instances[mtype]->getName(), instance->getName()); + } - instances[moduletype] = instance; + instances[mtype] = instance; + } } Module *Module::getInstance(const std::string &name) diff --git a/src/common/Module.h b/src/common/Module.h index c17a680e6..fc789b20a 100644 --- a/src/common/Module.h +++ b/src/common/Module.h @@ -38,6 +38,7 @@ public: enum ModuleType { + M_UNKNOWN = -1, // Use this for modules outside of LOVE's source code. M_AUDIO, M_DATA, M_EVENT, @@ -99,7 +100,7 @@ public: template static T *getInstance(ModuleType type) { - return (T *) instances[type]; + return type != M_UNKNOWN ? (T *) instances[type] : nullptr; } private: