summaryrefslogtreecommitdiffstats
path: root/src/Bindings
diff options
context:
space:
mode:
Diffstat (limited to 'src/Bindings')
-rw-r--r--src/Bindings/LuaState.cpp19
-rw-r--r--src/Bindings/ManualBindings.cpp15
2 files changed, 27 insertions, 7 deletions
diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp
index d49cd8ef3..ac5ce47e1 100644
--- a/src/Bindings/LuaState.cpp
+++ b/src/Bindings/LuaState.cpp
@@ -1018,9 +1018,7 @@ void cLuaState::LogStackTrace(lua_State * a_LuaState)
int depth = 0;
while (lua_getstack(a_LuaState, depth, &entry))
{
- int status = lua_getinfo(a_LuaState, "Sln", &entry);
- assert(status);
-
+ lua_getinfo(a_LuaState, "Sln", &entry);
LOGWARNING(" %s(%d): %s", entry.short_src, entry.currentline, entry.name ? entry.name : "(no name)");
depth++;
}
@@ -1066,11 +1064,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 +1081,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 +1160,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:
{
diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp
index dbaf32756..d476a3156 100644
--- a/src/Bindings/ManualBindings.cpp
+++ b/src/Bindings/ManualBindings.cpp
@@ -1106,6 +1106,16 @@ static int tolua_cPluginManager_GetCurrentPlugin(lua_State * S)
+static int tolua_cPluginManager_LogStackTrace(lua_State * S)
+{
+ cLuaState::LogStackTrace(S);
+ return 0;
+}
+
+
+
+
+
static int tolua_cPluginManager_AddHook_FnRef(cPluginManager * a_PluginManager, cLuaState & S, int a_ParamIdx)
{
// Helper function for cPluginmanager:AddHook() binding
@@ -1593,9 +1603,9 @@ static int tolua_cPluginManager_CallPlugin(lua_State * tolua_S)
int m_NumReturns;
cCallback(const AString & a_FunctionName, cLuaState & a_SrcLuaState) :
+ m_NumReturns(0),
m_FunctionName(a_FunctionName),
- m_SrcLuaState(a_SrcLuaState),
- m_NumReturns(0)
+ m_SrcLuaState(a_SrcLuaState)
{
}
protected:
@@ -2386,6 +2396,7 @@ void ManualBindings::Bind(lua_State * tolua_S)
tolua_function(tolua_S, "ForEachConsoleCommand", tolua_cPluginManager_ForEachConsoleCommand);
tolua_function(tolua_S, "GetAllPlugins", tolua_cPluginManager_GetAllPlugins);
tolua_function(tolua_S, "GetCurrentPlugin", tolua_cPluginManager_GetCurrentPlugin);
+ tolua_function(tolua_S, "LogStackTrace", tolua_cPluginManager_LogStackTrace);
tolua_endmodule(tolua_S);
tolua_beginmodule(tolua_S, "cPlayer");