diff --git a/configs/plugin_settings.cfg b/configs/plugin_settings.cfg index 6a9446e9..10ac41cb 100644 --- a/configs/plugin_settings.cfg +++ b/configs/plugin_settings.cfg @@ -4,12 +4,12 @@ * If the filename has no explicit path, it will be patched to any sub-path in the plugins folder. * * Available properties for plugins are: - * "pause" - Whether or not the plugin should load paused - "yes" or "no" (defualt) - * "lifetime" - Lifetime of the plugin. Options: - * "private" - Plugin is privately maintained and receives no forwards from Core - * "mapsync" - Plugins should be reloaded on mapchange if changed (default) - * "maponly" - Plugin should be unloaded at the end of the map - * "global" - Plugin will never be unloaded or updated + * "pause" - Whether or not the plugin should load paused - "yes" or "no" (defualt) + * "lifetime" - Lifetime of the plugin. Options: + * "mapsync" - Plugins should be reloaded on mapchange if changed (default) + * "global" - Plugin will never be unloaded or updated + * "blockload" - Plugin will always be blocked from loading. Implicit (automatic) loads + * produce no error, but explicit (manual) loads will show an error message. * * You can also have an "Options" section declaring options to pass onto the JIT: * "debug" - Whether or not to load the plugin in debug mode diff --git a/core/systems/PluginInfoDatabase.cpp b/core/systems/PluginInfoDatabase.cpp index 4071e4a8..82d50185 100644 --- a/core/systems/PluginInfoDatabase.cpp +++ b/core/systems/PluginInfoDatabase.cpp @@ -42,6 +42,7 @@ void PluginSettings::Init() optarray = -1; opts_num = 0; opts_size = 0; + blockload_val = false; } /** @@ -179,6 +180,8 @@ SMCParseResult CPluginInfoDatabase::ReadSMC_KeyValue(const char *key, } else { return MakeError("Unknown value for key \"lifetime\": \"%s\"", value); } + } else if (strcmp(key, "blockload") == 0) { + plugin->blockload_val = true; } else { return MakeError("Unknown property key: \"%s\"", key); } @@ -188,6 +191,7 @@ SMCParseResult CPluginInfoDatabase::ReadSMC_KeyValue(const char *key, int validx = m_strtab->AddString(value); PluginOpts *table; BaseMemTable *memtab = m_strtab->GetMemTable(); + plugin = (PluginSettings *)memtab->GetAddress(cur_plugin); if (plugin->opts_num + 1 > plugin->opts_size) { unsigned int oldsize = plugin->opts_size; @@ -286,9 +290,10 @@ SMCParseResult CPluginInfoDatabase::ReadSMC_NewSection(const char *name, bool op { /* If we get a plugin node and we don't have a current plugin, create a new one */ PluginSettings *plugin; + int i_name = m_strtab->AddString(name); cur_plugin = m_strtab->GetMemTable()->CreateMem(sizeof(PluginSettings), (void **)&plugin); plugin->Init(); - plugin->name = m_strtab->AddString(name); + plugin->name = i_name; in_options = false; } else { if (!in_options && strcmp(name, "Options") == 0) diff --git a/core/systems/PluginInfoDatabase.h b/core/systems/PluginInfoDatabase.h index d26df1a2..51f38926 100644 --- a/core/systems/PluginInfoDatabase.h +++ b/core/systems/PluginInfoDatabase.h @@ -58,6 +58,7 @@ struct PluginSettings int optarray; size_t opts_num; size_t opts_size; + bool blockload_val; }; class CPluginInfoDatabase : public ITextListener_SMC diff --git a/core/systems/PluginSys.cpp b/core/systems/PluginSys.cpp index 847b6c88..3f08fd91 100644 --- a/core/systems/PluginSys.cpp +++ b/core/systems/PluginSys.cpp @@ -885,6 +885,22 @@ void CPluginManager::LoadPluginsFromDir(const char *basedir, const char *localpa //well i have discovered that gabe newell is very fat, so i wrote this comment now LoadRes CPluginManager::_LoadPlugin(CPlugin **_plugin, const char *path, bool debug, PluginType type, char error[], size_t maxlength) { + bool no_load = false; + PluginSettings *pset; + unsigned int setcount = m_PluginInfo.GetSettingsNum(); + for (unsigned int i=0; iblockload_val) + { + no_load = true; + break; + } + } + /** * Does this plugin already exist? */ @@ -894,7 +910,8 @@ LoadRes CPluginManager::_LoadPlugin(CPlugin **_plugin, const char *path, bool de /* Check to see if we should try reloading it */ if (pPlugin->GetStatus() == Plugin_BadLoad || pPlugin->GetStatus() == Plugin_Error - || pPlugin->GetStatus() == Plugin_Failed) + || pPlugin->GetStatus() == Plugin_Failed + || no_load) { UnloadPlugin(pPlugin); } else { @@ -906,6 +923,11 @@ LoadRes CPluginManager::_LoadPlugin(CPlugin **_plugin, const char *path, bool de } } + if (no_load) + { + return LoadRes_NeverLoad; + } + pPlugin = CPlugin::CreatePlugin(path, error, maxlength); assert(pPlugin != NULL); @@ -919,8 +941,6 @@ LoadRes CPluginManager::_LoadPlugin(CPlugin **_plugin, const char *path, bool de co = pPlugin->StartMyCompile(g_pVM); } - PluginSettings *pset; - unsigned int setcount = m_PluginInfo.GetSettingsNum(); for (unsigned int i=0; i