From 77e837c77528965d3c98e722a55f62b45dc67cfe Mon Sep 17 00:00:00 2001 From: mniip Date: Sat, 27 Apr 2013 02:20:06 +0400 Subject: [PATCH] Fixed graphics function crash when unable to catch errors --- src/cat/LegacyLuaAPI.cpp | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/cat/LegacyLuaAPI.cpp b/src/cat/LegacyLuaAPI.cpp index a04c3bc47..96b895872 100644 --- a/src/cat/LegacyLuaAPI.cpp +++ b/src/cat/LegacyLuaAPI.cpp @@ -775,20 +775,24 @@ int luacon_graphicsReplacement(GRAPHICS_FUNC_ARGS, int i) lua_pushinteger(luacon_ci->l, *colb); callret = lua_pcall(luacon_ci->l, 4, 10, 0); if (callret) - luacon_ci->Log(CommandInterface::LogError, luacon_geterror()); - - cache = luaL_optint(luacon_ci->l, -10, 0); - *pixel_mode = luaL_optint(luacon_ci->l, -9, *pixel_mode); - *cola = luaL_optint(luacon_ci->l, -8, *cola); - *colr = luaL_optint(luacon_ci->l, -7, *colr); - *colg = luaL_optint(luacon_ci->l, -6, *colg); - *colb = luaL_optint(luacon_ci->l, -5, *colb); - *firea = luaL_optint(luacon_ci->l, -4, *firea); - *firer = luaL_optint(luacon_ci->l, -3, *firer); - *fireg = luaL_optint(luacon_ci->l, -2, *fireg); - *fireb = luaL_optint(luacon_ci->l, -1, *fireb); - lua_pop(luacon_ci->l, 10); - + { + luacon_ci->Log(CommandInterface::LogError, luaL_optstring(luacon_ci->l, -1, "")); + lua_pop(luacon_ci->l, 1); + } + else + { + cache = luaL_optint(luacon_ci->l, -10, 0); + *pixel_mode = luaL_optint(luacon_ci->l, -9, *pixel_mode); + *cola = luaL_optint(luacon_ci->l, -8, *cola); + *colr = luaL_optint(luacon_ci->l, -7, *colr); + *colg = luaL_optint(luacon_ci->l, -6, *colg); + *colb = luaL_optint(luacon_ci->l, -5, *colb); + *firea = luaL_optint(luacon_ci->l, -4, *firea); + *firer = luaL_optint(luacon_ci->l, -3, *firer); + *fireg = luaL_optint(luacon_ci->l, -2, *fireg); + *fireb = luaL_optint(luacon_ci->l, -1, *fireb); + lua_pop(luacon_ci->l, 10); + } return cache; }