1
0

Merge pull request #1552 from SphinxC0re/master

Added error handling to load <plugin> command
This commit is contained in:
Alexander Harkness 2014-10-20 14:34:19 +01:00
commit bf8de85fd6
2 changed files with 13 additions and 1 deletions

View File

@ -1827,7 +1827,8 @@ bool cPluginManager::DoWithPlugin(const AString & a_PluginName, cPluginCallback
bool cPluginManager::AddPlugin(cPlugin * a_Plugin)
{
m_Plugins[a_Plugin->GetDirectory()] = a_Plugin;
m_Plugins[a_Plugin->GetDirectory()] = a_Plugin;
if (a_Plugin->Initialize())
{
// Initialization OK

View File

@ -491,6 +491,17 @@ void cServer::ExecuteConsoleCommand(const AString & a_Cmd, cCommandOutputCallbac
{
if (split.size() > 1)
{
cPluginManager::PluginMap map = cPluginManager::Get()->GetAllPlugins();
for(auto plugin_entry : map)
{
if(plugin_entry.first == split[1])
{
a_Output.Out("Error! Plugin is already loaded!");
a_Output.Finished();
return;
}
}
a_Output.Out(cPluginManager::Get()->LoadPlugin(split[1]) ? "Plugin loaded" : "Error occurred loading plugin");
}
else