1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Restructure devtest's unittests and run them in CI (#11859)

This commit is contained in:
sfan5 2021-12-18 20:36:43 +01:00 committed by GitHub
parent 1c5ece8334
commit 8472141b79
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 292 additions and 75 deletions

View file

@ -125,6 +125,15 @@ protected:
friend class ModApiEnvMod;
friend class LuaVoxelManip;
/*
Subtle edge case with coroutines: If for whatever reason you have a
method in a subclass that's called from existing lua_CFunction
(any of the l_*.cpp files) then make it static and take the lua_State*
as an argument. This is REQUIRED because getStack() will not return the
correct state if called inside coroutines.
Also note that src/script/common/ is the better place for such helpers.
*/
lua_State* getStack()
{ return m_luastack; }

View file

@ -198,10 +198,8 @@ std::string ScriptApiServer::formatChatMessage(const std::string &name,
return ret;
}
u32 ScriptApiServer::allocateDynamicMediaCallback(int f_idx)
u32 ScriptApiServer::allocateDynamicMediaCallback(lua_State *L, int f_idx)
{
lua_State *L = getStack();
if (f_idx < 0)
f_idx = lua_gettop(L) + f_idx + 1;
@ -235,7 +233,7 @@ u32 ScriptApiServer::allocateDynamicMediaCallback(int f_idx)
void ScriptApiServer::freeDynamicMediaCallback(u32 token)
{
lua_State *L = getStack();
SCRIPTAPI_PRECHECKHEADER
verbosestream << "freeDynamicMediaCallback(" << token << ")" << std::endl;

View file

@ -51,7 +51,7 @@ public:
const std::string &password);
/* dynamic media handling */
u32 allocateDynamicMediaCallback(int f_idx);
static u32 allocateDynamicMediaCallback(lua_State *L, int f_idx);
void freeDynamicMediaCallback(u32 token);
void on_dynamic_media_added(u32 token, const char *playername);