X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodmanager_static.cpp;h=76f16fa92fd140e2594a0ab9062c70b46c99f2b2;hb=992674362c5f64bdb8e1942eeaa7612524529cd6;hp=7d6c89258852a6493fabda7965e64efc4024872b;hpb=8a64bd3a0ac72855b681b00f3a9a08cebee755ce;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modmanager_static.cpp b/src/modmanager_static.cpp index 7d6c89258..76f16fa92 100644 --- a/src/modmanager_static.cpp +++ b/src/modmanager_static.cpp @@ -58,7 +58,6 @@ class AllModule : public Module { Command* c = (*i)(this); cmds.push_back(c); - ServerInstance->Modules->AddService(*c); } } catch (...) @@ -88,6 +87,11 @@ bool ModuleManager::Load(const std::string& name, bool defer) if (it == modlist->end()) return false; Module* mod = NULL; + + ServiceList newservices; + if (!defer) + this->NewServices = &newservices; + try { mod = (*it->second->init)(); @@ -95,6 +99,7 @@ bool ModuleManager::Load(const std::string& name, bool defer) mod->ModuleDLLManager = NULL; mod->dying = false; Modules[name] = mod; + this->NewServices = NULL; if (defer) { ServerInstance->Logs->Log("MODULE", LOG_DEFAULT, "New module introduced: %s", name.c_str()); @@ -105,12 +110,15 @@ bool ModuleManager::Load(const std::string& name, bool defer) ConfigStatus confstatus; AttachAll(mod); + AddServices(newservices); mod->init(); mod->ReadConfig(confstatus); } } catch (CoreException& modexcept) { + this->NewServices = NULL; + if (mod) DoSafeUnload(mod); ServerInstance->Logs->Log("MODULE", LOG_DEFAULT, "Unable to load " + name + ": " + modexcept.GetReason()); @@ -123,12 +131,18 @@ bool ModuleManager::Load(const std::string& name, bool defer) return true; } -void ModuleManager::LoadCoreModules() +void ModuleManager::LoadCoreModules(std::map& servicemap) { - Load("cmd_all.so", true); - Load("cmd_whowas.so", true); - Load("cmd_lusers.so", true); - Load("cmd_privmsg.so", true); + for (modmap::const_iterator i = modlist->begin(); i != modlist->end(); ++i) + { + const std::string modname = i->first; + if (modname[0] == 'c') + { + this->NewServices = &servicemap[modname]; + Load(modname, true); + } + } + this->NewServices = NULL; } #endif