From 919e3ed0e242208290f358c172338c5515004ffe Mon Sep 17 00:00:00 2001 From: wolfy852 Date: Wed, 1 Jun 2016 21:06:24 -0500 Subject: [PATCH 1/2] Make token available to Lua as a global variable Reviewed by @RedEnchilada --- src/dehacked.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/dehacked.c b/src/dehacked.c index 199ea43c..f7845af4 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -8276,6 +8276,9 @@ static inline int lib_getenum(lua_State *L) } else if (fastcmp(word,"VERSIONSTRING")) { lua_pushstring(L, VERSIONSTRING); return 1; + } else if (fastcmp(word, "token")) { + lua_pushinteger(L, token); + return 1; } return 0; From 83c4dba4cee64f1bc1432f08cc5ba75aac822c24 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 2 Jun 2016 20:16:25 +0100 Subject: [PATCH 2/2] Fix crash reported by FuriousFox at http://mb.srb2.org/showthread.php?t=41536 Basically this makes sure numwadfiles is updated before loading the SOC/Lua scripts, so if a Lua script calls COM_BufInsertText with the contents "addfile scr_mysticrealm.wad" it can't overwrite the last written wadfile slot! Not that COM_BufInsertText really should be used like that to begin with --- src/w_wad.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/w_wad.c b/src/w_wad.c index 40fea522..aeaad3ce 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -475,11 +475,11 @@ UINT16 W_LoadWadFile(const char *filename) // CONS_Printf(M_GetText("Added file %s (%u lumps)\n"), filename, numlumps); wadfiles[numwadfiles] = wadfile; - W_LoadDehackedLumps(numwadfiles); + numwadfiles++; // must come BEFORE W_LoadDehackedLumps, so any addfile called by COM_BufInsertText called by Lua doesn't overwrite what we just loaded + W_LoadDehackedLumps(numwadfiles-1); W_InvalidateLumpnumCache(); - numwadfiles++; return wadfile->numlumps; }