1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-11 17:51:04 +00:00

[CSM] Client side modding

* rename GameScripting to ServerScripting
* Make getBuiltinLuaPath static serverside
* Add on_shutdown callback
* Add on_receiving_chat_message & on_sending_chat_message callbacks
* ScriptApiBase: use IGameDef instead of Server
  This permits to share common attribute between client & server
* Enable mod security in client side modding without conditions
This commit is contained in:
Loic Blot 2017-01-21 15:02:08 +01:00 committed by Loïc Blot
parent c9492b4d37
commit 2efae3ffd7
37 changed files with 488 additions and 64 deletions

View file

@ -23,12 +23,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "lua_api/l_object.h"
#include "common/c_converter.h"
#include "serverobject.h"
#include "debug.h"
#include "filesys.h"
#include "log.h"
#include "mods.h"
#include "porting.h"
#include "util/string.h"
#include "server.h"
#ifndef SERVER
#include "client.h"
#endif
extern "C" {
@ -69,7 +71,8 @@ public:
*/
ScriptApiBase::ScriptApiBase() :
m_luastackmutex()
m_luastackmutex(),
m_gamedef(NULL)
{
#ifdef SCRIPTAPI_LOCK_DEBUG
m_lock_recursion_count = 0;
@ -113,7 +116,6 @@ ScriptApiBase::ScriptApiBase() :
// Default to false otherwise
m_secure = false;
m_server = NULL;
m_environment = NULL;
m_guiengine = NULL;
}
@ -333,3 +335,14 @@ void ScriptApiBase::objectrefGet(lua_State *L, u16 id)
lua_remove(L, -2); // object_refs
lua_remove(L, -2); // core
}
Server* ScriptApiBase::getServer()
{
return dynamic_cast<Server *>(m_gamedef);
}
#ifndef SERVER
Client* ScriptApiBase::getClient()
{
return dynamic_cast<Client *>(m_gamedef);
}
#endif