+ modmap::iterator it = modlist->find(name);
+ if (it == modlist->end())
+ return false;
+ Module* mod = NULL;
+ try
+ {
+ mod = (*it->second->init)();
+ mod->ModuleSourceFile = name;
+ mod->ModuleDLLManager = NULL;
+ mod->dying = false;
+ Modules[name] = mod;
+ if (defer)
+ {
+ ServerInstance->Logs->Log("MODULE", DEFAULT,"New module introduced: %s", name.c_str());
+ return true;
+ }
+ else
+ {
+ mod->init();
+ }
+ }
+ catch (CoreException& modexcept)
+ {
+ if (mod)
+ DoSafeUnload(mod);
+ ServerInstance->Logs->Log("MODULE", DEFAULT, "Unable to load " + name + ": " + modexcept.GetReason());
+ return false;
+ }
+ FOREACH_MOD(I_OnLoadModule,OnLoadModule(mod));
+ /* We give every module a chance to re-prioritize when we introduce a new one,
+ * not just the one thats loading, as the new module could affect the preference
+ * of others
+ */
+ for(int tries = 0; tries < 20; tries++)
+ {
+ prioritizationState = tries > 0 ? PRIO_STATE_LAST : PRIO_STATE_FIRST;
+ for (std::map<std::string, Module*>::iterator n = Modules.begin(); n != Modules.end(); ++n)
+ n->second->Prioritize();