From f79e68266426993af94f811afc8296e7b159462a Mon Sep 17 00:00:00 2001 From: Howaner Date: Sun, 27 Jul 2014 00:03:00 +0200 Subject: Fixed plugin count and fixed plugin loading, when settings.ini was regenerated. --- src/Bindings/PluginManager.cpp | 46 +++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 16 deletions(-) (limited to 'src/Bindings') diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index 088b92a6d..1d97d1331 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -124,44 +124,58 @@ void cPluginManager::ReloadPluginsNow(cIniFile & a_SettingsIni) // 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); + KeyNum = a_SettingsIni.FindKey("Plugins"); } - else if (NumPlugins > 0) + + // How many plugins are there? + int NumPlugins = a_SettingsIni.GetNumValues(KeyNum); + + for (int i = 0; i < NumPlugins; i++) { - for (int i = 0; i < NumPlugins; i++) + AString ValueName = a_SettingsIni.GetValueName(KeyNum, i); + if (ValueName.compare("Plugin") == 0) { - AString ValueName = a_SettingsIni.GetValueName(KeyNum, i); - if (ValueName.compare("Plugin") == 0) + AString PluginFile = a_SettingsIni.GetValue(KeyNum, i); + if (!PluginFile.empty()) { - AString PluginFile = a_SettingsIni.GetValue(KeyNum, i); - if (!PluginFile.empty()) + if (m_Plugins.find(PluginFile) != m_Plugins.end()) { - if (m_Plugins.find(PluginFile) != m_Plugins.end()) - { - LoadPlugin(PluginFile); - } + LoadPlugin(PluginFile); } } } } + + // Remove invalid plugins from the PluginMap. + for (PluginMap::iterator itr = m_Plugins.begin(); itr != m_Plugins.end();) + { + if (itr->second == NULL) + { + PluginMap::iterator thiz = itr; + ++thiz; + m_Plugins.erase(itr); + itr = thiz; + continue; + } + ++itr; + } + size_t NumLoadedPlugins = GetNumPlugins(); if (NumLoadedPlugins == 0) { LOG("-- No Plugins Loaded --"); } - else if (NumLoadedPlugins > 1) + else if (NumLoadedPlugins == 1) { - LOG("-- Loaded %i Plugins --", (int)NumLoadedPlugins); + LOG("-- Loaded 1 Plugin --"); } else { - LOG("-- Loaded 1 Plugin --"); + LOG("-- Loaded %i Plugins --", (int)NumLoadedPlugins); } CallHookPluginsLoaded(); } -- cgit v1.2.3 From 4f5d73b7704e351365a987b421c35f1384afa240 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 29 Jul 2014 20:50:30 +0100 Subject: Slight cleanup after portals --- src/Bindings/PluginManager.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/Bindings') diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index 088b92a6d..3560b8660 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -476,11 +476,9 @@ bool cPluginManager::CallHookDisconnect(cClientHandle & a_Client, const AString bool cPluginManager::CallHookEntityAddEffect(cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_ENTITY_ADD_EFFECT); - if (Plugins == m_Hooks.end()) - { - return false; - } + FIND_HOOK(HOOK_ENTITY_ADD_EFFECT); + VERIFY_HOOK; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnEntityAddEffect(a_Entity, a_EffectType, a_EffectDurationTicks, a_EffectIntensity, a_DistanceModifier)) -- cgit v1.2.3 From 1d684697186de4340c6a1cc5aea6a14ffd19c002 Mon Sep 17 00:00:00 2001 From: archshift Date: Tue, 29 Jul 2014 22:43:25 -0700 Subject: Fixed "Dependency" typos --- src/Bindings/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Bindings') diff --git a/src/Bindings/CMakeLists.txt b/src/Bindings/CMakeLists.txt index 2ea2fa8c0..48e7ce79c 100644 --- a/src/Bindings/CMakeLists.txt +++ b/src/Bindings/CMakeLists.txt @@ -125,8 +125,8 @@ if (NOT MSVC) DEPENDS ${BINDING_DEPENDENCIES} ) endif () -set_source_files_properties(Bindings/Bindings.cpp PROPERTIES GENERATED TRUE) -set_source_files_properties(Bindings/Bindings.h PROPERTIES GENERATED TRUE) +set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.cpp PROPERTIES GENERATED TRUE) +set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.h PROPERTIES GENERATED TRUE) if(NOT MSVC) add_library(Bindings ${SRCS} ${HDRS}) -- cgit v1.2.3