summaryrefslogtreecommitdiffstats
path: root/src/Bindings
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-02-09 01:04:42 +0100
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-02-09 01:04:42 +0100
commitf86f066615f4e4807941f863f6e749dc12ac01be (patch)
treea792dc877470a98030569204b3d32575da404d6d /src/Bindings
parentFixed a boat ASSERT (diff)
parentFixed a gcc warning in ManualBindings. (diff)
downloadcuberite-f86f066615f4e4807941f863f6e749dc12ac01be.tar
cuberite-f86f066615f4e4807941f863f6e749dc12ac01be.tar.gz
cuberite-f86f066615f4e4807941f863f6e749dc12ac01be.tar.bz2
cuberite-f86f066615f4e4807941f863f6e749dc12ac01be.tar.lz
cuberite-f86f066615f4e4807941f863f6e749dc12ac01be.tar.xz
cuberite-f86f066615f4e4807941f863f6e749dc12ac01be.tar.zst
cuberite-f86f066615f4e4807941f863f6e749dc12ac01be.zip
Diffstat (limited to 'src/Bindings')
-rw-r--r--src/Bindings/LuaState.cpp19
-rw-r--r--src/Bindings/ManualBindings.cpp4
2 files changed, 16 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..9ebdc4b22 100644
--- a/src/Bindings/ManualBindings.cpp
+++ b/src/Bindings/ManualBindings.cpp
@@ -1593,9 +1593,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: