diff options
author | andrew <xdotftw@gmail.com> | 2014-01-21 19:40:41 +0100 |
---|---|---|
committer | andrew <xdotftw@gmail.com> | 2014-01-21 19:40:41 +0100 |
commit | 9bd8f74b598866539e3e5133188326bd7d14a827 (patch) | |
tree | 15f411bd03371e555250b898f3883c0fa20c2b8b /src/Bindings/LuaState.cpp | |
parent | Scoreboard SendTo() (diff) | |
parent | Fix a crash but somewhere... (diff) | |
download | cuberite-9bd8f74b598866539e3e5133188326bd7d14a827.tar cuberite-9bd8f74b598866539e3e5133188326bd7d14a827.tar.gz cuberite-9bd8f74b598866539e3e5133188326bd7d14a827.tar.bz2 cuberite-9bd8f74b598866539e3e5133188326bd7d14a827.tar.lz cuberite-9bd8f74b598866539e3e5133188326bd7d14a827.tar.xz cuberite-9bd8f74b598866539e3e5133188326bd7d14a827.tar.zst cuberite-9bd8f74b598866539e3e5133188326bd7d14a827.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Bindings/LuaState.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp index 00e62fcf6..bfee1d037 100644 --- a/src/Bindings/LuaState.cpp +++ b/src/Bindings/LuaState.cpp @@ -914,6 +914,40 @@ bool cLuaState::CheckParamString(int a_StartParam, int a_EndParam) +bool cLuaState::CheckParamFunction(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)) + { + 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("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 + + // All params checked ok + return true; +} + + + + + bool cLuaState::CheckParamEnd(int a_Param) { tolua_Error tolua_err; |