summaryrefslogtreecommitdiffstats
path: root/source/cPlugin_NewLua.cpp
diff options
context:
space:
mode:
authorfaketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-01-28 00:47:32 +0100
committerfaketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-01-28 00:47:32 +0100
commitde293999872346271cdfb5dbecbad7f77362b83b (patch)
treec627283aacda09be1592f85805261fec782b8a6d /source/cPlugin_NewLua.cpp
parentAdded a VC2010 configuration for Debug build with optimized Noise; made it the default in VC2008 (diff)
downloadcuberite-de293999872346271cdfb5dbecbad7f77362b83b.tar
cuberite-de293999872346271cdfb5dbecbad7f77362b83b.tar.gz
cuberite-de293999872346271cdfb5dbecbad7f77362b83b.tar.bz2
cuberite-de293999872346271cdfb5dbecbad7f77362b83b.tar.lz
cuberite-de293999872346271cdfb5dbecbad7f77362b83b.tar.xz
cuberite-de293999872346271cdfb5dbecbad7f77362b83b.tar.zst
cuberite-de293999872346271cdfb5dbecbad7f77362b83b.zip
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