diff options
Diffstat (limited to 'src/Bindings/LuaState.cpp')
-rw-r--r-- | src/Bindings/LuaState.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp index d49cd8ef3..8dd17c448 100644 --- a/src/Bindings/LuaState.cpp +++ b/src/Bindings/LuaState.cpp @@ -1066,11 +1066,13 @@ int cLuaState::CallFunctionWithForeignParams( { // Something went wrong, fix the stack and exit lua_pop(m_LuaState, 2); + m_NumCurrentFunctionArgs = -1; + m_CurrentFunctionName.clear(); return -1; } // Call the function, with an error handler: - int s = lua_pcall(m_LuaState, a_SrcParamEnd - a_SrcParamStart + 1, LUA_MULTRET, OldTop); + int s = lua_pcall(m_LuaState, a_SrcParamEnd - a_SrcParamStart + 1, LUA_MULTRET, OldTop + 1); if (ReportErrors(s)) { LOGWARN("Error while calling function '%s' in '%s'", a_FunctionName.c_str(), m_SubsystemName.c_str()); @@ -1081,11 +1083,19 @@ int cLuaState::CallFunctionWithForeignParams( { lua_pop(m_LuaState, CurTop - OldTop); } - return -1; + + // Reset the internal checking mechanisms: + m_NumCurrentFunctionArgs = -1; + m_CurrentFunctionName.clear(); + + // Make Lua think everything is okay and return 0 values, so that plugins continue executing. + // The failure is indicated by the zero return values. + return 0; } // Reset the internal checking mechanisms: m_NumCurrentFunctionArgs = -1; + m_CurrentFunctionName.clear(); // Remove the error handler from the stack: lua_remove(m_LuaState, OldTop + 1); @@ -1152,6 +1162,7 @@ int cLuaState::CopyStackFrom(cLuaState & a_SrcLuaState, int a_SrcStart, int a_Sr // Copy the value: void * ud = tolua_touserdata(a_SrcLuaState, i, NULL); tolua_pushusertype(m_LuaState, ud, type); + break; } default: { |