diff options
author | Mattes D <github@xoft.cz> | 2015-05-08 00:18:41 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2015-05-08 00:18:41 +0200 |
commit | 237d8fa501501a8fab881d045fa4f1eee0e728b4 (patch) | |
tree | ae916b7f21ea456da862abeee338742d4c7bc6ac /src/Bindings/LuaState.cpp | |
parent | Merge pull request #1949 from SafwatHalaby/burn (diff) | |
parent | Fixed inter-plugin calls. (diff) | |
download | cuberite-237d8fa501501a8fab881d045fa4f1eee0e728b4.tar cuberite-237d8fa501501a8fab881d045fa4f1eee0e728b4.tar.gz cuberite-237d8fa501501a8fab881d045fa4f1eee0e728b4.tar.bz2 cuberite-237d8fa501501a8fab881d045fa4f1eee0e728b4.tar.lz cuberite-237d8fa501501a8fab881d045fa4f1eee0e728b4.tar.xz cuberite-237d8fa501501a8fab881d045fa4f1eee0e728b4.tar.zst cuberite-237d8fa501501a8fab881d045fa4f1eee0e728b4.zip |
Diffstat (limited to 'src/Bindings/LuaState.cpp')
-rw-r--r-- | src/Bindings/LuaState.cpp | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp index f574dbe26..9c1e2865c 100644 --- a/src/Bindings/LuaState.cpp +++ b/src/Bindings/LuaState.cpp @@ -1535,7 +1535,7 @@ int cLuaState::CallFunctionWithForeignParams( if (!PushFunction(a_FunctionName.c_str())) { LOGWARNING("Function '%s' not found", a_FunctionName.c_str()); - lua_pop(m_LuaState, 2); + lua_settop(m_LuaState, OldTop); return -1; } @@ -1543,7 +1543,7 @@ int cLuaState::CallFunctionWithForeignParams( if (CopyStackFrom(a_SrcLuaState, a_SrcParamStart, a_SrcParamEnd) < 0) { // Something went wrong, fix the stack and exit - lua_pop(m_LuaState, 2); + lua_settop(m_LuaState, OldTop); m_NumCurrentFunctionArgs = -1; m_CurrentFunctionName.clear(); return -1; @@ -1554,13 +1554,8 @@ int cLuaState::CallFunctionWithForeignParams( if (ReportErrors(s)) { LOGWARN("Error while calling function '%s' in '%s'", a_FunctionName.c_str(), m_SubsystemName.c_str()); - // Fix the stack. - // We don't know how many values have been pushed, so just get rid of any that weren't there initially - int CurTop = lua_gettop(m_LuaState); - if (CurTop > OldTop) - { - lua_pop(m_LuaState, CurTop - OldTop); - } + // Reset the stack: + lua_settop(m_LuaState, OldTop); // Reset the internal checking mechanisms: m_NumCurrentFunctionArgs = -1; |