1
0

Fixed error handling in cPluginManager:CallPlugin() API.

Fixed: When the called function malfunctioned, the entire plugin's call was aborted.
This commit is contained in:
madmaxoft 2014-02-04 10:29:10 +01:00
parent aa19f4fd04
commit 69c85e5169

View File

@ -1072,7 +1072,8 @@ int cLuaState::CallFunctionWithForeignParams(
}
// Call the function, with an error handler:
int s = lua_pcall(m_LuaState, a_SrcParamEnd - a_SrcParamStart + 1, LUA_MULTRET, OldTop);
LogStack("Before pcall");
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());
@ -1088,7 +1089,9 @@ int cLuaState::CallFunctionWithForeignParams(
m_NumCurrentFunctionArgs = -1;
m_CurrentFunctionName.clear();
return -1;
// 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: