diff options
author | Mattes D <github@xoft.cz> | 2015-12-18 14:32:01 +0100 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2015-12-18 14:32:01 +0100 |
commit | 749274aa4340485dfed6222af55101444eb15603 (patch) | |
tree | 7e95f9e8102c3cc7910c7a513e4cc77bce764aed /src/Bindings/LuaState.cpp | |
parent | Merge pull request #2770 from cuberite/RemoveChunkDataCollector (diff) | |
parent | Revised the explosion-related Lua API and docs. (diff) | |
download | cuberite-749274aa4340485dfed6222af55101444eb15603.tar cuberite-749274aa4340485dfed6222af55101444eb15603.tar.gz cuberite-749274aa4340485dfed6222af55101444eb15603.tar.bz2 cuberite-749274aa4340485dfed6222af55101444eb15603.tar.lz cuberite-749274aa4340485dfed6222af55101444eb15603.tar.xz cuberite-749274aa4340485dfed6222af55101444eb15603.tar.zst cuberite-749274aa4340485dfed6222af55101444eb15603.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Bindings/LuaState.cpp | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp index f5b2cac4a..953b6f17b 100644 --- a/src/Bindings/LuaState.cpp +++ b/src/Bindings/LuaState.cpp @@ -807,25 +807,6 @@ void cLuaState::Push(UInt32 a_Value) -void cLuaState::Push(void * a_Ptr) -{ - UNUSED(a_Ptr); - ASSERT(IsValid()); - - // Investigate the cause of this - what is the callstack? - // One code path leading here is the OnHookExploding / OnHookExploded with exotic parameters. Need to decide what to do with them - LOGWARNING("Lua engine: attempting to push a plain pointer, pushing nil instead."); - LOGWARNING("This indicates an unimplemented part of MCS bindings"); - LogStackTrace(); - - lua_pushnil(m_LuaState); - m_NumCurrentFunctionArgs += 1; -} - - - - - void cLuaState::Push(std::chrono::milliseconds a_Value) { ASSERT(IsValid()); @@ -838,20 +819,6 @@ void cLuaState::Push(std::chrono::milliseconds a_Value) -/* -void cLuaState::PushUserType(void * a_Object, const char * a_Type) -{ - ASSERT(IsValid()); - - tolua_pushusertype(m_LuaState, a_Object, a_Type); - m_NumCurrentFunctionArgs += 1; -} -*/ - - - - - bool cLuaState::GetStackValue(int a_StackPos, AString & a_Value) { size_t len = 0; @@ -1197,6 +1164,39 @@ bool cLuaState::CheckParamNumber(int a_StartParam, int a_EndParam) +bool cLuaState::CheckParamBool(int a_StartParam, int a_EndParam) +{ + ASSERT(IsValid()); + + if (a_EndParam < 0) + { + a_EndParam = a_StartParam; + } + + tolua_Error tolua_err; + for (int i = a_StartParam; i <= a_EndParam; i++) + { + if (tolua_isboolean(m_LuaState, i, 0, &tolua_err)) + { + continue; + } + // Not the correct parameter + lua_Debug entry; + VERIFY(lua_getstack(m_LuaState, 0, &entry)); + VERIFY(lua_getinfo (m_LuaState, "n", &entry)); + AString ErrMsg = Printf("#ferror in function '%s'.", (entry.name != nullptr) ? entry.name : "?"); + tolua_error(m_LuaState, ErrMsg.c_str(), &tolua_err); + return false; + } // for i - Param + + // All params checked ok + return true; +} + + + + + bool cLuaState::CheckParamString(int a_StartParam, int a_EndParam) { ASSERT(IsValid()); |