added request amb948 - blocking of plugin loads
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401442
This commit is contained in:
parent
78e0de7a5b
commit
167c1d0a31
@ -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
|
||||
|
@ -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)
|
||||
|
@ -58,6 +58,7 @@ struct PluginSettings
|
||||
int optarray;
|
||||
size_t opts_num;
|
||||
size_t opts_size;
|
||||
bool blockload_val;
|
||||
};
|
||||
|
||||
class CPluginInfoDatabase : public ITextListener_SMC
|
||||
|
@ -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; i<setcount; i++)
|
||||
{
|
||||
if ((pset = m_PluginInfo.GetSettingsIfMatch(i, path)) == NULL)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (pset->blockload_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<setcount; i++)
|
||||
{
|
||||
if ((pset=m_PluginInfo.GetSettingsIfMatch(i, path)) == NULL)
|
||||
@ -1003,6 +1023,12 @@ IPlugin *CPluginManager::LoadPlugin(const char *path, bool debug, PluginType typ
|
||||
return pl;
|
||||
}
|
||||
|
||||
if (res == LoadRes_NeverLoad)
|
||||
{
|
||||
UTIL_Format(error, maxlength, "This plugin is blocked from loading (see plugin_settings.cfg)");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
AddPlugin(pl);
|
||||
|
||||
/* Run second pass if we need to */
|
||||
@ -1021,7 +1047,7 @@ IPlugin *CPluginManager::LoadPlugin(const char *path, bool debug, PluginType typ
|
||||
|
||||
void CPluginManager::LoadAutoPlugin(const char *plugin)
|
||||
{
|
||||
CPlugin *pl;
|
||||
CPlugin *pl = NULL;
|
||||
LoadRes res;
|
||||
char error[255] = "Unknown error";
|
||||
|
||||
|
@ -123,7 +123,8 @@ enum LoadRes
|
||||
{
|
||||
LoadRes_Successful,
|
||||
LoadRes_AlreadyLoaded,
|
||||
LoadRes_Failure
|
||||
LoadRes_Failure,
|
||||
LoadRes_NeverLoad
|
||||
};
|
||||
|
||||
struct AutoConfig
|
||||
|
Loading…
Reference in New Issue
Block a user