From c7330d4543606fc9ea74d8922c0c126f857d9d18 Mon Sep 17 00:00:00 2001 From: TheRealQuantam <54358053+TheRealQuantam@users.noreply.github.com> Date: Tue, 30 Jan 2024 01:41:13 -0800 Subject: [PATCH] Revert bad fix for not terminating script on initial error --- src/lua-engine.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/lua-engine.cpp b/src/lua-engine.cpp index ff783cc7..2fb843b5 100644 --- a/src/lua-engine.cpp +++ b/src/lua-engine.cpp @@ -357,9 +357,6 @@ static void FCEU_LuaOnStop() #ifdef __WIN_DRIVER__ TaseditorDisableManualFunctionIfNeeded(); #endif - - if (info_onstop) - info_onstop(info_uid); } @@ -1491,12 +1488,18 @@ static int rom_getfilename(lua_State *L) { static int rom_gethash(lua_State *L) { const char *type = luaL_checkstring(L, 1); - MD5DATA md5hash = GameInfo->MD5; + if (GameInfo != nullptr) + { + MD5DATA md5hash = GameInfo->MD5; + + if (!type) lua_pushstring(L, ""); + else if (!stricmp(type, "md5")) lua_pushstring(L, md5_asciistr(md5hash)); + else if (!stricmp(type, "base64")) lua_pushstring(L, BytesToString(md5hash.data, MD5DATA::size).c_str()); + else lua_pushstring(L, ""); + } + else + lua_pushnil(L); - if (!type) lua_pushstring(L, ""); - else if (!stricmp(type, "md5")) lua_pushstring(L, md5_asciistr(md5hash)); - else if (!stricmp(type, "base64")) lua_pushstring(L, BytesToString(md5hash.data, MD5DATA::size).c_str()); - else lua_pushstring(L, ""); return 1; } @@ -6628,6 +6631,9 @@ void FCEU_LuaStop() { CoInitialize(0); #endif + if (info_onstop) + info_onstop(info_uid); + //lua_gc(L,LUA_GCCOLLECT,0);