mniip: fix crash on non-string error in step and other functions

This commit is contained in:
jacob1 2013-05-03 20:13:56 -04:00
commit 773d500d8a

View File

@ -514,7 +514,7 @@ int luacon_keyevent(int key, int modifier, int event)
callret = lua_pcall(l, 4, 1, 0); callret = lua_pcall(l, 4, 1, 0);
if (callret) if (callret)
{ {
if (!strcmp(luaL_optstring(l, -1, ""), "Error: Script not responding")) if (!strcmp(luacon_geterror(), "Error: Script not responding"))
{ {
ui::Engine::Ref().LastTick(clock()); ui::Engine::Ref().LastTick(clock());
for(j=i;j<=c-1;j++) for(j=i;j<=c-1;j++)
@ -566,7 +566,7 @@ int luacon_mouseevent(int mx, int my, int mb, int event, int mouse_wheel)
callret = lua_pcall(l, 5, 1, 0); callret = lua_pcall(l, 5, 1, 0);
if (callret) if (callret)
{ {
if (!strcmp(luaL_optstring(l, -1, ""), "Error: Script not responding")) if (!strcmp(luacon_geterror(), "Error: Script not responding"))
{ {
ui::Engine::Ref().LastTick(clock()); ui::Engine::Ref().LastTick(clock());
for(j=i;j<=c-1;j++) for(j=i;j<=c-1;j++)
@ -579,7 +579,7 @@ int luacon_mouseevent(int mx, int my, int mb, int event, int mouse_wheel)
c--; c--;
i--; i--;
} }
luacon_ci->Log(CommandInterface::LogError, luaL_optstring(l, -1, "")); luacon_ci->Log(CommandInterface::LogError, luacon_geterror());
lua_pop(l, 1); lua_pop(l, 1);
} }
else else
@ -627,7 +627,7 @@ int luacon_step(int mx, int my, std::string selectl, std::string selectr, std::s
callret = lua_pcall(l, 0, 0, 0); callret = lua_pcall(l, 0, 0, 0);
if (callret) if (callret)
{ {
if (!strcmp(luaL_optstring(l, -1, ""), "Error: Script not responding")) if (!strcmp(luacon_geterror(), "Error: Script not responding"))
{ {
ui::Engine::Ref().LastTick(clock()); ui::Engine::Ref().LastTick(clock());
for(j=i;j<=c-1;j++) for(j=i;j<=c-1;j++)
@ -640,7 +640,7 @@ int luacon_step(int mx, int my, std::string selectl, std::string selectr, std::s
c--; c--;
i--; i--;
} }
luacon_ci->Log(CommandInterface::LogError, luaL_optstring(l, -1, "")); luacon_ci->Log(CommandInterface::LogError, luacon_geterror());
lua_pop(l, 1); lua_pop(l, 1);
} }
} }
@ -796,7 +796,7 @@ int luacon_graphicsReplacement(GRAPHICS_FUNC_ARGS, int i)
callret = lua_pcall(luacon_ci->l, 4, 10, 0); callret = lua_pcall(luacon_ci->l, 4, 10, 0);
if (callret) if (callret)
{ {
luacon_ci->Log(CommandInterface::LogError, luaL_optstring(luacon_ci->l, -1, "")); luacon_ci->Log(CommandInterface::LogError, luacon_geterror());
lua_pop(luacon_ci->l, 1); lua_pop(luacon_ci->l, 1);
} }
else else