added request
amb948 - blocking of plugin loads
1.1 --- a/configs/plugin_settings.cfg Tue Sep 18 17:07:56 2007 +0000
1.2 +++ b/configs/plugin_settings.cfg Tue Sep 18 17:44:17 2007 +0000
1.3 @@ -4,12 +4,12 @@
1.4 * If the filename has no explicit path, it will be patched to any sub-path in the plugins folder.
1.5 *
1.6 * Available properties for plugins are:
1.7 - * "pause" - Whether or not the plugin should load paused - "yes" or "no" (defualt)
1.8 - * "lifetime" - Lifetime of the plugin. Options:
1.9 - * "private" - Plugin is privately maintained and receives no forwards from Core
1.10 - * "mapsync" - Plugins should be reloaded on mapchange if changed (default)
1.11 - * "maponly" - Plugin should be unloaded at the end of the map
1.12 - * "global" - Plugin will never be unloaded or updated
1.13 + * "pause" - Whether or not the plugin should load paused - "yes" or "no" (defualt)
1.14 + * "lifetime" - Lifetime of the plugin. Options:
1.15 + * "mapsync" - Plugins should be reloaded on mapchange if changed (default)
1.16 + * "global" - Plugin will never be unloaded or updated
1.17 + * "blockload" - Plugin will always be blocked from loading. Implicit (automatic) loads
1.18 + * produce no error, but explicit (manual) loads will show an error message.
1.19 *
1.20 * You can also have an "Options" section declaring options to pass onto the JIT:
1.21 * "debug" - Whether or not to load the plugin in debug mode
2.1 --- a/core/systems/PluginInfoDatabase.cpp Tue Sep 18 17:07:56 2007 +0000
2.2 +++ b/core/systems/PluginInfoDatabase.cpp Tue Sep 18 17:44:17 2007 +0000
2.3 @@ -42,6 +42,7 @@
2.4 optarray = -1;
2.5 opts_num = 0;
2.6 opts_size = 0;
2.7 + blockload_val = false;
2.8 }
2.9
2.10 /**
2.11 @@ -179,6 +180,8 @@
2.12 } else {
2.13 return MakeError("Unknown value for key \"lifetime\": \"%s\"", value);
2.14 }
2.15 + } else if (strcmp(key, "blockload") == 0) {
2.16 + plugin->blockload_val = true;
2.17 } else {
2.18 return MakeError("Unknown property key: \"%s\"", key);
2.19 }
2.20 @@ -188,6 +191,7 @@
2.21 int validx = m_strtab->AddString(value);
2.22 PluginOpts *table;
2.23 BaseMemTable *memtab = m_strtab->GetMemTable();
2.24 + plugin = (PluginSettings *)memtab->GetAddress(cur_plugin);
2.25 if (plugin->opts_num + 1 > plugin->opts_size)
2.26 {
2.27 unsigned int oldsize = plugin->opts_size;
2.28 @@ -286,9 +290,10 @@
2.29 {
2.30 /* If we get a plugin node and we don't have a current plugin, create a new one */
2.31 PluginSettings *plugin;
2.32 + int i_name = m_strtab->AddString(name);
2.33 cur_plugin = m_strtab->GetMemTable()->CreateMem(sizeof(PluginSettings), (void **)&plugin);
2.34 plugin->Init();
2.35 - plugin->name = m_strtab->AddString(name);
2.36 + plugin->name = i_name;
2.37 in_options = false;
2.38 } else {
2.39 if (!in_options && strcmp(name, "Options") == 0)
3.1 --- a/core/systems/PluginInfoDatabase.h Tue Sep 18 17:07:56 2007 +0000
3.2 +++ b/core/systems/PluginInfoDatabase.h Tue Sep 18 17:44:17 2007 +0000
3.3 @@ -58,6 +58,7 @@
3.4 int optarray;
3.5 size_t opts_num;
3.6 size_t opts_size;
3.7 + bool blockload_val;
3.8 };
3.9
3.10 class CPluginInfoDatabase : public ITextListener_SMC
4.1 --- a/core/systems/PluginSys.cpp Tue Sep 18 17:07:56 2007 +0000
4.2 +++ b/core/systems/PluginSys.cpp Tue Sep 18 17:44:17 2007 +0000
4.3 @@ -885,6 +885,22 @@
4.4 //well i have discovered that gabe newell is very fat, so i wrote this comment now
4.5 LoadRes CPluginManager::_LoadPlugin(CPlugin **_plugin, const char *path, bool debug, PluginType type, char error[], size_t maxlength)
4.6 {
4.7 + bool no_load = false;
4.8 + PluginSettings *pset;
4.9 + unsigned int setcount = m_PluginInfo.GetSettingsNum();
4.10 + for (unsigned int i=0; i<setcount; i++)
4.11 + {
4.12 + if ((pset = m_PluginInfo.GetSettingsIfMatch(i, path)) == NULL)
4.13 + {
4.14 + continue;
4.15 + }
4.16 + if (pset->blockload_val)
4.17 + {
4.18 + no_load = true;
4.19 + break;
4.20 + }
4.21 + }
4.22 +
4.23 /**
4.24 * Does this plugin already exist?
4.25 */
4.26 @@ -894,7 +910,8 @@
4.27 /* Check to see if we should try reloading it */
4.28 if (pPlugin->GetStatus() == Plugin_BadLoad
4.29 || pPlugin->GetStatus() == Plugin_Error
4.30 - || pPlugin->GetStatus() == Plugin_Failed)
4.31 + || pPlugin->GetStatus() == Plugin_Failed
4.32 + || no_load)
4.33 {
4.34 UnloadPlugin(pPlugin);
4.35 } else {
4.36 @@ -906,6 +923,11 @@
4.37 }
4.38 }
4.39
4.40 + if (no_load)
4.41 + {
4.42 + return LoadRes_NeverLoad;
4.43 + }
4.44 +
4.45 pPlugin = CPlugin::CreatePlugin(path, error, maxlength);
4.46
4.47 assert(pPlugin != NULL);
4.48 @@ -919,8 +941,6 @@
4.49 co = pPlugin->StartMyCompile(g_pVM);
4.50 }
4.51
4.52 - PluginSettings *pset;
4.53 - unsigned int setcount = m_PluginInfo.GetSettingsNum();
4.54 for (unsigned int i=0; i<setcount; i++)
4.55 {
4.56 if ((pset=m_PluginInfo.GetSettingsIfMatch(i, path)) == NULL)
4.57 @@ -1003,6 +1023,12 @@
4.58 return pl;
4.59 }
4.60
4.61 + if (res == LoadRes_NeverLoad)
4.62 + {
4.63 + UTIL_Format(error, maxlength, "This plugin is blocked from loading (see plugin_settings.cfg)");
4.64 + return NULL;
4.65 + }
4.66 +
4.67 AddPlugin(pl);
4.68
4.69 /* Run second pass if we need to */
4.70 @@ -1021,7 +1047,7 @@
4.71
4.72 void CPluginManager::LoadAutoPlugin(const char *plugin)
4.73 {
4.74 - CPlugin *pl;
4.75 + CPlugin *pl = NULL;
4.76 LoadRes res;
4.77 char error[255] = "Unknown error";
4.78
5.1 --- a/core/systems/PluginSys.h Tue Sep 18 17:07:56 2007 +0000
5.2 +++ b/core/systems/PluginSys.h Tue Sep 18 17:44:17 2007 +0000
5.3 @@ -123,7 +123,8 @@
5.4 {
5.5 LoadRes_Successful,
5.6 LoadRes_AlreadyLoaded,
5.7 - LoadRes_Failure
5.8 + LoadRes_Failure,
5.9 + LoadRes_NeverLoad
5.10 };
5.11
5.12 struct AutoConfig