diff options
author | madmaxoft <github@xoft.cz> | 2014-02-11 15:03:35 +0100 |
---|---|---|
committer | madmaxoft <github@xoft.cz> | 2014-02-11 15:03:35 +0100 |
commit | 33c84aaa4d9d5d5255439948d318a1894db4cba4 (patch) | |
tree | 4b4adf24b502b27000fb62d5a2906b2c4cd53812 /src/Bindings/LuaState.cpp | |
parent | More gcc warnings fixed. (diff) | |
download | cuberite-33c84aaa4d9d5d5255439948d318a1894db4cba4.tar cuberite-33c84aaa4d9d5d5255439948d318a1894db4cba4.tar.gz cuberite-33c84aaa4d9d5d5255439948d318a1894db4cba4.tar.bz2 cuberite-33c84aaa4d9d5d5255439948d318a1894db4cba4.tar.lz cuberite-33c84aaa4d9d5d5255439948d318a1894db4cba4.tar.xz cuberite-33c84aaa4d9d5d5255439948d318a1894db4cba4.tar.zst cuberite-33c84aaa4d9d5d5255439948d318a1894db4cba4.zip |
Diffstat (limited to 'src/Bindings/LuaState.cpp')
-rw-r--r-- | src/Bindings/LuaState.cpp | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp index 24e64d9b2..c6be7be3c 100644 --- a/src/Bindings/LuaState.cpp +++ b/src/Bindings/LuaState.cpp @@ -944,10 +944,42 @@ bool cLuaState::CheckParamFunction(int a_StartParam, int a_EndParam) lua_Debug entry; VERIFY(lua_getstack(m_LuaState, 0, &entry)); VERIFY(lua_getinfo (m_LuaState, "n", &entry)); - AString ErrMsg = Printf("Error in function '%s' parameter #%d. Function expected, got %s", + luaL_error(m_LuaState, "Error in function '%s' parameter #%d. Function expected, got %s", + (entry.name != NULL) ? entry.name : "?", i, GetTypeText(i).c_str() + ); + return false; + } // for i - Param + + // All params checked ok + return true; +} + + + + + +bool cLuaState::CheckParamFunctionOrNil(int a_StartParam, int a_EndParam) +{ + ASSERT(IsValid()); + + if (a_EndParam < 0) + { + a_EndParam = a_StartParam; + } + + for (int i = a_StartParam; i <= a_EndParam; i++) + { + if (lua_isfunction(m_LuaState, i) || lua_isnil(m_LuaState, i)) + { + continue; + } + // Not the correct parameter + lua_Debug entry; + VERIFY(lua_getstack(m_LuaState, 0, &entry)); + VERIFY(lua_getinfo (m_LuaState, "n", &entry)); + luaL_error(m_LuaState, "Error in function '%s' parameter #%d. Function expected, got %s", (entry.name != NULL) ? entry.name : "?", i, GetTypeText(i).c_str() ); - LogStackTrace(); return false; } // for i - Param |