Converted entire Core plugin including WebAdmin interface to new plugin method/system/thingy and sexyfied it.
Made some changes to WebAdmin to make the new plugins work Old plugins still work like they're supposed to Not all hooks have been programmed for the new plugins yet, this still needs to be done git-svn-id: http://mc-server.googlecode.com/svn/trunk@182 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user