summaryrefslogtreecommitdiffstats
path: root/source/cPlugin_NewLua.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--source/cPlugin_NewLua.cpp34
1 files changed, 27 insertions, 7 deletions
diff --git a/source/cPlugin_NewLua.cpp b/source/cPlugin_NewLua.cpp
index 81e629ce4..fd5a23772 100644
--- a/source/cPlugin_NewLua.cpp
+++ b/source/cPlugin_NewLua.cpp
@@ -1,6 +1,7 @@
#define LUA_USE_POSIX
#include "cPlugin_NewLua.h"
#include "cMCLogger.h"
+#include "cWebPlugin_Lua.h"
extern "C"
{
@@ -11,10 +12,10 @@ extern "C"
#include "Bindings.h"
#include "ManualBindings.h"
-#ifdef _WIN32
-#include "wdirent.h"
-#else
-#include <dirent.h>
+#ifdef _WIN32
+#include "wdirent.h"
+#else
+#include <dirent.h>
#endif
extern bool report_errors(lua_State* lua, int status);
@@ -27,6 +28,12 @@ cPlugin_NewLua::cPlugin_NewLua( const char* a_PluginName )
cPlugin_NewLua::~cPlugin_NewLua()
{
+ for( WebPluginList::iterator itr = m_WebPlugins.begin(); itr != m_WebPlugins.end(); ++itr )
+ {
+ delete *itr;
+ }
+ m_WebPlugins.clear();
+
if( m_LuaState )
{
lua_close( m_LuaState );
@@ -49,9 +56,9 @@ bool cPlugin_NewLua::Initialize()
// Load all files for this plugin, and execute them
DIR* dp;
struct dirent *entry;
- if(dp = opendir( PluginPath.c_str() ))
- {
- while(entry = readdir(dp))
+ if(dp = opendir( PluginPath.c_str() ))
+ {
+ while(entry = readdir(dp))
{
std::string FileName = entry->d_name;
if( FileName.find(".lua") != std::string::npos )
@@ -76,6 +83,7 @@ bool cPlugin_NewLua::Initialize()
}
}
}
+ closedir( dp );
}
@@ -177,7 +185,19 @@ bool cPlugin_NewLua::OnKilled( cPawn* a_Killed, cEntity* a_Killer )
return bRetVal;
}
+cWebPlugin_Lua* cPlugin_NewLua::CreateWebPlugin(lua_State* a_LuaState)
+{
+ if( a_LuaState != m_LuaState )
+ {
+ LOGERROR("Not allowed to create a WebPlugin from another plugin but your own!");
+ return 0;
+ }
+ cWebPlugin_Lua* WebPlugin = new cWebPlugin_Lua( this );
+ m_WebPlugins.push_back( WebPlugin );
+
+ return WebPlugin;
+}
// Helper functions