From 0b836a984147bf525fab5bdc4cd381673538f5b7 Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Fri, 15 Dec 2017 16:31:27 +0100 Subject: [PATCH 1/2] Fix missing lua_pop in ArchiveExtVars --- src/lua_script.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lua_script.c b/src/lua_script.c index acb30682..fa87f80d 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -716,7 +716,10 @@ static void ArchiveExtVars(void *pointer, const char *ptype) lua_pop(gL, 1); if (i == 0 && !fastcmp(ptype,"player")) // skip anything that has an empty table and isn't a player. + { + lua_pop(gL, 1); return; + } if (fastcmp(ptype,"mobj")) // mobjs must write their mobjnum as a header WRITEUINT32(save_p, ((mobj_t *)pointer)->mobjnum); WRITEUINT16(save_p, i); From beb9b0f103f5df99d8688a72153a5c40c9ac9948 Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Fri, 15 Dec 2017 22:02:34 +0100 Subject: [PATCH 2/2] Return for both players and mobjs if they've got an empty table, instead of just mobjs --- src/lua_script.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lua_script.c b/src/lua_script.c index fa87f80d..be6b2003 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -715,11 +715,15 @@ static void ArchiveExtVars(void *pointer, const char *ptype) for (i = 0; lua_next(gL, -2); i++) lua_pop(gL, 1); - if (i == 0 && !fastcmp(ptype,"player")) // skip anything that has an empty table and isn't a player. + // skip anything that has an empty table and isn't a player. + if (i == 0) { + if (fastcmp(ptype,"player")) // always include players even if they have no extra variables + WRITEUINT16(save_p, 0); lua_pop(gL, 1); return; } + if (fastcmp(ptype,"mobj")) // mobjs must write their mobjnum as a header WRITEUINT32(save_p, ((mobj_t *)pointer)->mobjnum); WRITEUINT16(save_p, i);