summaryrefslogtreecommitdiffstats
path: root/src/Bindings/LuaState.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2015-12-16 15:04:47 +0100
committerMattes D <github@xoft.cz>2015-12-18 12:40:34 +0100
commit086c8b1834bfca6a4af912abbd13fd570f7b0b33 (patch)
tree7e95f9e8102c3cc7910c7a513e4cc77bce764aed /src/Bindings/LuaState.cpp
parentMerge pull request #2770 from cuberite/RemoveChunkDataCollector (diff)
downloadcuberite-086c8b1834bfca6a4af912abbd13fd570f7b0b33.tar
cuberite-086c8b1834bfca6a4af912abbd13fd570f7b0b33.tar.gz
cuberite-086c8b1834bfca6a4af912abbd13fd570f7b0b33.tar.bz2
cuberite-086c8b1834bfca6a4af912abbd13fd570f7b0b33.tar.lz
cuberite-086c8b1834bfca6a4af912abbd13fd570f7b0b33.tar.xz
cuberite-086c8b1834bfca6a4af912abbd13fd570f7b0b33.tar.zst
cuberite-086c8b1834bfca6a4af912abbd13fd570f7b0b33.zip
Diffstat (limited to 'src/Bindings/LuaState.cpp')
-rw-r--r--src/Bindings/LuaState.cpp66
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());