aboutsummaryrefslogtreecommitdiff
path: root/src/script/cpp_api/s_base.h
diff options
context:
space:
mode:
authorElias Fleckenstein <54945686+EliasFleckenstein03@users.noreply.github.com>2020-11-04 16:57:47 +0100
committerGitHub <noreply@github.com>2020-11-04 16:57:47 +0100
commit3e16c3a78fff61c20e63ba730d15e94e3bb877b4 (patch)
treec070350db219f2c4241d22bc31949685c7b42fe9 /src/script/cpp_api/s_base.h
parent5d9ae5a91c544fc7fbd475decf47cef7e09ef8fc (diff)
parent6ccb5835ff55d85156be91473c598eca9d6cb9a6 (diff)
downloaddragonfireclient-3e16c3a78fff61c20e63ba730d15e94e3bb877b4.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.h73
1 files changed, 38 insertions, 35 deletions
diff --git a/src/script/cpp_api/s_base.h b/src/script/cpp_api/s_base.h
index d2081ad5c..36331ad37 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,13 +76,14 @@ 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);
@@ -94,17 +95,18 @@ 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
@@ -124,49 +126,50 @@ 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;
};