diff options
author | lapayo94@gmail.com <lapayo94@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-07-09 17:53:17 +0200 |
---|---|---|
committer | lapayo94@gmail.com <lapayo94@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-07-09 17:53:17 +0200 |
commit | d82e2449a0282232c6e6acd1a84514ee5332f4db (patch) | |
tree | 6935f3cd4a9d3050b1aed8b1b0f9514f5fcff17f /source/cPluginManager.cpp | |
parent | Sorry... (diff) | |
download | cuberite-d82e2449a0282232c6e6acd1a84514ee5332f4db.tar cuberite-d82e2449a0282232c6e6acd1a84514ee5332f4db.tar.gz cuberite-d82e2449a0282232c6e6acd1a84514ee5332f4db.tar.bz2 cuberite-d82e2449a0282232c6e6acd1a84514ee5332f4db.tar.lz cuberite-d82e2449a0282232c6e6acd1a84514ee5332f4db.tar.xz cuberite-d82e2449a0282232c6e6acd1a84514ee5332f4db.tar.zst cuberite-d82e2449a0282232c6e6acd1a84514ee5332f4db.zip |
Diffstat (limited to '')
-rw-r--r-- | source/cPluginManager.cpp | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/source/cPluginManager.cpp b/source/cPluginManager.cpp index 4cf21c850..99523183e 100644 --- a/source/cPluginManager.cpp +++ b/source/cPluginManager.cpp @@ -1,4 +1,3 @@ - #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "cPluginManager.h" @@ -10,6 +9,7 @@ #include "cItem.h" #include "cRoot.h" #include "cLuaCommandBinder.h" +#include "cSquirrelCommandBinder.h" #include "../iniFile/iniFile.h" #include "tolua++.h" @@ -38,6 +38,7 @@ cPluginManager* cPluginManager::GetPluginManager() cPluginManager::cPluginManager() : m_LuaCommandBinder( new cLuaCommandBinder() ) + , m_SquirrelCommandBinder( new cSquirrelCommandBinder() ) , m_bReloadPlugins(false) { } @@ -51,6 +52,7 @@ cPluginManager::~cPluginManager() UnloadPluginsNow(); delete m_LuaCommandBinder; + delete m_SquirrelCommandBinder; } @@ -130,7 +132,12 @@ void cPluginManager::ReloadPluginsNow() { LOGINFO("Loading Squirrel plugin: %s", PluginFile.c_str() ); - this->AddPlugin(new cPlugin_Squirrel(PluginFile.c_str())); + cPlugin_Squirrel *Plugin = new cPlugin_Squirrel(PluginFile.c_str()); + + if( !AddPlugin( Plugin ) ) + { + delete Plugin; + } } } #endif // USE_SQUIRREL @@ -189,6 +196,11 @@ bool cPluginManager::CallHook(PluginHook a_Hook, unsigned int a_NumArgs, ...) cPlayer * Player = va_arg(argptr, cPlayer * ); va_end (argptr); + if (m_SquirrelCommandBinder->HandleCommand( std::string( Message ), Player)) + { + return true; + } + if (m_LuaCommandBinder->HandleCommand( std::string( Message ), Player)) { return true; @@ -644,13 +656,12 @@ void cPluginManager::RemovePlugin( cPlugin* a_Plugin, bool a_bDelete /* = false if( a_bDelete ) { m_LuaCommandBinder->RemoveBindingsForPlugin( a_Plugin ); + m_SquirrelCommandBinder->RemoveBindingsForPlugin( a_Plugin ); m_Plugins.remove( a_Plugin ); RemoveHooks( a_Plugin ); a_Plugin->OnDisable(); - if( a_Plugin->GetLanguage() != cPlugin::E_SQUIRREL ) // Squirrel needs to clean it up himself! - { - delete a_Plugin; - } + + delete a_Plugin; } else { |