Fix Lua crashes when loading without addons

This commit is contained in:
Latapostrophe 2020-03-12 16:03:12 +01:00
parent cbc7fe7b67
commit 44f45d6d28
3 changed files with 9 additions and 1 deletions

View File

@ -45,6 +45,7 @@
#include "dehacked.h" // get_number (for ghost thok)
#include "lua_script.h" // LUA_ArchiveDemo and LUA_UnArchiveDemo
#include "lua_hook.h"
#include "lua_libs.h" // gL (Lua state)
#include "b_bot.h"
#include "m_cond.h" // condition sets
#include "md5.h" // demo checksums
@ -7538,7 +7539,12 @@ void G_DoPlayDemo(char *defdemoname)
// so this is where we are to read our lua variables (if possible!)
#ifdef HAVE_BLUA
if (demoflags & DF_LUAVARS) // again, used for compability, lua shit will be saved to replays regardless of if it's even been loaded
{
if (!gL) // No Lua state! ...I guess we'll just start one...
LUA_ClearState();
LUA_UnArchiveDemo();
}
#endif
splitscreen = 0;

View File

@ -112,7 +112,7 @@ static int noglobals(lua_State *L)
// Clear and create a new Lua state, laddo!
// There's SCRIPTIN to be had!
static void LUA_ClearState(void)
void LUA_ClearState(void)
{
lua_State *L;
int i;

View File

@ -38,6 +38,8 @@
void LUA_ClearExtVars(void);
#endif
void LUA_ClearState(void);
void LUA_LoadLump(UINT16 wad, UINT16 lump);
#ifdef LUA_ALLOW_BYTECODE
void LUA_DumpFile(const char *filename);