diff options
author | Elias Fleckenstein <54945686+EliasFleckenstein03@users.noreply.github.com> | 2020-11-04 16:44:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-04 16:44:42 +0100 |
commit | 5d9ae5a91c544fc7fbd475decf47cef7e09ef8fc (patch) | |
tree | c980d614fec4a5495798be3e79e033229062c3cd /src/script/cpp_api/s_base.h | |
parent | 28f6a79706b088c37268a59d90878220dc4ef9c7 (diff) | |
parent | 3af10766fd2b58b068e970266724d7eb10e9316b (diff) | |
download | dragonfireclient-5d9ae5a91c544fc7fbd475decf47cef7e09ef8fc.tar.xz |
Merge branch 'master' into master
Diffstat (limited to 'src/script/cpp_api/s_base.h')
-rw-r--r-- | src/script/cpp_api/s_base.h | 73 |
1 files changed, 35 insertions, 38 deletions
diff --git a/src/script/cpp_api/s_base.h b/src/script/cpp_api/s_base.h index 36331ad37..d2081ad5c 100644 --- a/src/script/cpp_api/s_base.h +++ b/src/script/cpp_api/s_base.h @@ -45,20 +45,20 @@ extern "C" { // use that name to bypass security! #define BUILTIN_MOD_NAME "*builtin*" -#define PCALL_RES(RES) { \ - int result_ = (RES); \ - if (result_ != 0) { \ - scriptError(result_, __FUNCTION__); \ - } \ -} +#define PCALL_RES(RES) \ + { \ + int result_ = (RES); \ + if (result_ != 0) { \ + scriptError(result_, __FUNCTION__); \ + } \ + } -#define runCallbacks(nargs, mode) \ - runCallbacksRaw((nargs), (mode), __FUNCTION__) +#define runCallbacks(nargs, mode) runCallbacksRaw((nargs), (mode), __FUNCTION__) -#define setOriginFromTable(index) \ - setOriginFromTableRaw(index, __FUNCTION__) +#define setOriginFromTable(index) setOriginFromTableRaw(index, __FUNCTION__) -enum class ScriptingType: u8 { +enum class ScriptingType : u8 +{ Async, Client, MainMenu, @@ -76,14 +76,13 @@ class GUIEngine; class ServerActiveObject; struct PlayerHPChangeReason; -class ScriptApiBase : protected LuaHelper { +class ScriptApiBase : protected LuaHelper +{ public: ScriptApiBase(ScriptingType type); - // fake constructor to allow script API classes (e.g ScriptApiEnv) to virtually inherit from this one. - ScriptApiBase() - { - FATAL_ERROR("ScriptApiBase created without ScriptingType!"); - } + // fake constructor to allow script API classes (e.g ScriptApiEnv) to virtually + // inherit from this one. + ScriptApiBase() { FATAL_ERROR("ScriptApiBase created without ScriptingType!"); } virtual ~ScriptApiBase(); DISABLE_CLASS_COPY(ScriptApiBase); @@ -95,18 +94,17 @@ public: void loadModFromMemory(const std::string &mod_name); #endif - void runCallbacksRaw(int nargs, - RunCallbacksMode mode, const char *fxn); + void runCallbacksRaw(int nargs, RunCallbacksMode mode, const char *fxn); /* object */ void addObjectReference(ServerActiveObject *cobj); void removeObjectReference(ServerActiveObject *cobj); IGameDef *getGameDef() { return m_gamedef; } - Server* getServer(); + Server *getServer(); ScriptingType getType() { return m_type; } #ifndef SERVER - Client* getClient(); + Client *getClient(); Game *getGame() { return m_game; } #endif @@ -126,50 +124,49 @@ protected: friend class ModApiEnvMod; friend class LuaVoxelManip; - lua_State* getStack() - { return m_luastack; } + lua_State *getStack() { return m_luastack; } void realityCheck(); void scriptError(int result, const char *fxn); void stackDump(std::ostream &o); - void setGameDef(IGameDef* gamedef) { m_gamedef = gamedef; } + void setGameDef(IGameDef *gamedef) { m_gamedef = gamedef; } #ifndef SERVER void setGame(Game *game) { m_game = game; } #endif - Environment* getEnv() { return m_environment; } - void setEnv(Environment* env) { m_environment = env; } + Environment *getEnv() { return m_environment; } + void setEnv(Environment *env) { m_environment = env; } #ifndef SERVER - GUIEngine* getGuiEngine() { return m_guiengine; } - void setGuiEngine(GUIEngine* guiengine) { m_guiengine = guiengine; } + GUIEngine *getGuiEngine() { return m_guiengine; } + void setGuiEngine(GUIEngine *guiengine) { m_guiengine = guiengine; } #endif void objectrefGetOrCreate(lua_State *L, ServerActiveObject *cobj); - void pushPlayerHPChangeReason(lua_State *L, const PlayerHPChangeReason& reason); + void pushPlayerHPChangeReason(lua_State *L, const PlayerHPChangeReason &reason); std::recursive_mutex m_luastackmutex; - std::string m_last_run_mod; - bool m_secure = false; + std::string m_last_run_mod; + bool m_secure = false; #ifdef SCRIPTAPI_LOCK_DEBUG - int m_lock_recursion_count{}; + int m_lock_recursion_count{}; std::thread::id m_owning_thread; #endif private: static int luaPanic(lua_State *L); - lua_State *m_luastack = nullptr; + lua_State *m_luastack = nullptr; - IGameDef *m_gamedef = nullptr; + IGameDef *m_gamedef = nullptr; #ifndef SERVER - Game *m_game = nullptr; + Game *m_game = nullptr; #endif - Environment *m_environment = nullptr; + Environment *m_environment = nullptr; #ifndef SERVER - GUIEngine *m_guiengine = nullptr; + GUIEngine *m_guiengine = nullptr; #endif - ScriptingType m_type; + ScriptingType m_type; }; |