void cPluginManager::ReloadPluginsNow(cIniFile & a_SettingsIni) { LOG("-- Loading Plugins --"); m_bReloadPlugins = false; UnloadPluginsNow(); FindPlugins(); cServer::BindBuiltInConsoleCommands(); // Check if the Plugins section exists. int KeyNum = a_SettingsIni.FindKey("Plugins"); // If it does, how many plugins are there? int NumPlugins = ((KeyNum != -1) ? (a_SettingsIni.GetNumValues(KeyNum)) : 0); if (KeyNum == -1) { InsertDefaultPlugins(a_SettingsIni); } else if (NumPlugins > 0) { for (int i = 0; i < NumPlugins; i++) { AString ValueName = a_SettingsIni.GetValueName(KeyNum, i); if (ValueName.compare("Plugin") == 0) { AString PluginFile = a_SettingsIni.GetValue(KeyNum, i); if (!PluginFile.empty()) { if (m_Plugins.find(PluginFile) != m_Plugins.end()) { LoadPlugin(PluginFile); } } } } } size_t NumLoadedPlugins = GetNumPlugins(); if (NumLoadedPlugins == 0) { LOG("-- No Plugins Loaded --"); } else if (NumLoadedPlugins > 1) { LOG("-- Loaded %i Plugins --", (int)NumLoadedPlugins); } else { LOG("-- Loaded 1 Plugin --"); } CallHookPluginsLoaded(); }
void cPluginManager::ReloadPluginsNow(cIniFile & a_SettingsIni) { LOG("-- Loading Plugins --"); m_bReloadPlugins = false; UnloadPluginsNow(); FindPlugins(); cServer::BindBuiltInConsoleCommands(); unsigned int KeyNum = a_SettingsIni.FindKey("Plugins"); unsigned int NumPlugins = ((KeyNum != -1) ? (a_SettingsIni.GetNumValues(KeyNum)) : 0); if (KeyNum == -1) { InsertDefaultPlugins(a_SettingsIni); } else if (NumPlugins > 0) { for(unsigned int i = 0; i < NumPlugins; i++) { AString ValueName = a_SettingsIni.GetValueName(KeyNum, i); if (ValueName.compare("Plugin") == 0) { AString PluginFile = a_SettingsIni.GetValue(KeyNum, i); if (!PluginFile.empty()) { if (m_Plugins.find(PluginFile) != m_Plugins.end()) { LoadPlugin( PluginFile ); } } } } } if (GetNumPlugins() == 0) { LOG("-- No Plugins Loaded --"); } else if (GetNumPlugins() > 1) { LOG("-- Loaded %i Plugins --", GetNumPlugins()); } else { LOG("-- Loaded 1 Plugin --"); } }
void cRoot::LoadWorlds(cIniFile & IniFile) { // First get the default world AString DefaultWorldName = IniFile.GetValueSet("Worlds", "DefaultWorld", "world"); m_pDefaultWorld = new cWorld(DefaultWorldName.c_str()); m_WorldsByName[ DefaultWorldName ] = m_pDefaultWorld; // Then load the other worlds int KeyNum = IniFile.FindKey("Worlds"); int NumWorlds = IniFile.GetNumValues(KeyNum); if (NumWorlds <= 0) { return; } bool FoundAdditionalWorlds = false; for (int i = 0; i < NumWorlds; i++) { AString ValueName = IniFile.GetValueName(KeyNum, i); if (ValueName.compare("World") != 0) { continue; } AString WorldName = IniFile.GetValue(KeyNum, i); if (WorldName.empty()) { continue; } FoundAdditionalWorlds = true; cWorld* NewWorld = new cWorld( WorldName.c_str()); m_WorldsByName[ WorldName ] = NewWorld; } // for i - Worlds if (!FoundAdditionalWorlds) { if (IniFile.GetKeyComment("Worlds", 0) != " World=secondworld") { IniFile.DeleteKeyComment("Worlds", 0); IniFile.AddKeyComment("Worlds", " World=secondworld"); } } }