summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2022-05-25 12:38:49 +0200
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2022-05-25 12:43:44 +0200
commitca16e8d37629cf2d80bb9fb5a134ea17595de7ce (patch)
tree574948671e2f8343a9126301ff63302f556020aa /src
parentfc973c5ec32dc10256c81e9f199cdf6e7131b155 (diff)
downloadmanaserv-ca16e8d37629cf2d80bb9fb5a134ea17595de7ce.tar.gz
manaserv-ca16e8d37629cf2d80bb9fb5a134ea17595de7ce.tar.bz2
manaserv-ca16e8d37629cf2d80bb9fb5a134ea17595de7ce.tar.xz
manaserv-ca16e8d37629cf2d80bb9fb5a134ea17595de7ce.zip
Fixed compile against Lua 5.4
Now lua_resume takes 4 arguments, and the number of result values is set on the 4th one.
Diffstat (limited to 'src')
-rw-r--r--src/scripting/luascript.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/scripting/luascript.cpp b/src/scripting/luascript.cpp
index 42a78955..06fbd2ab 100644
--- a/src/scripting/luascript.cpp
+++ b/src/scripting/luascript.cpp
@@ -159,18 +159,23 @@ bool LuaScript::resume()
nbArgs = -1;
#if LUA_VERSION_NUM < 502
int result = lua_resume(mCurrentState, tmpNbArgs);
-#else
+ int nresults = lua_gettop(mCurrentState);
+#elif LUA_VERSION_NUM < 504
int result = lua_resume(mCurrentState, nullptr, tmpNbArgs);
+ int nresults = lua_gettop(mCurrentState);
+#else
+ int nresults = 0;
+ int result = lua_resume(mCurrentState, nullptr, tmpNbArgs, &nresults);
#endif
if (result == 0) // Thread is done
{
- if (lua_gettop(mCurrentState) > 0)
+ if (nresults > 0)
LOG_WARN("Ignoring values returned by script thread!");
}
else if (result == LUA_YIELD) // Thread has yielded
{
- if (lua_gettop(mCurrentState) > 0)
+ if (nresults > 0)
LOG_WARN("Ignoring values passed to yield!");
}
else // Thread encountered an error
@@ -195,7 +200,7 @@ bool LuaScript::resume()
delete mCurrentThread;
}
- mCurrentThread = 0;
+ mCurrentThread = nullptr;
mCurrentState = mRootState;
return done;