Improve handling of errors in lua functions and speed up calls. (#1427)

This commit is contained in:
Kyzentun
2017-04-04 11:36:23 -07:00
committed by Colby Klein
parent 86dbab0100
commit f10e3ae36a
21 changed files with 38 additions and 86 deletions
+5 -10
View File
@@ -904,8 +904,7 @@ public:
return false;
}
m_pLuaTable->PushSelf( L );
RString error= RowName + " \"EnabledForPlayers\": ";
LuaHelpers::RunScriptOnStack(L, error, 1, 1, true);
LuaHelpers::RunScriptOnStack(L, 1, 1);
if(!lua_istable(L, -1))
{
LuaHelpers::ReportScriptErrorFmt("LUA_ERROR: \"%s\" \"EnabledForPlayers\" did not return a table.", RowName.c_str());
@@ -988,8 +987,7 @@ public:
// Argument 1 (self):
m_pLuaTable->PushSelf( L );
RString error= "EnabledForPlayers: ";
LuaHelpers::RunScriptOnStack( L, error, 1, 1, true );
LuaHelpers::RunScriptOnStack( L, 1, 1 );
m_Def.m_vEnabledForPlayers.clear(); // and fill in with supplied PlayerNumbers below
lua_pushnil( L );
@@ -1149,8 +1147,7 @@ public:
ASSERT( lua_gettop(L) == 6 ); // vbSelectedOut, m_iLuaTable, function, self, arg, arg
RString error= "LoadSelections: ";
LuaHelpers::RunScriptOnStack( L, error, 3, 0, true );
LuaHelpers::RunScriptOnStack( L, 3, 0 );
ASSERT( lua_gettop(L) == 2 );
lua_pop( L, 1 ); // pop option table
@@ -1205,8 +1202,7 @@ public:
ASSERT( lua_gettop(L) == 6 ); // vbSelectedOut, m_iLuaTable, function, self, arg, arg
RString error= "SaveSelections: ";
LuaHelpers::RunScriptOnStack( L, error, 3, 0, true );
LuaHelpers::RunScriptOnStack( L, 3, 0 );
ASSERT( lua_gettop(L) == 2 );
lua_pop( L, 1 ); // pop option table
@@ -1237,8 +1233,7 @@ public:
LuaHelpers::Push(L, pn);
// Convert choice to a lua index so it matches up with the Choices table.
lua_pushinteger(L, choice+1);
RString error= "NotifyOfSelection: ";
LuaHelpers::RunScriptOnStack(L, error, 3, 1, true);
LuaHelpers::RunScriptOnStack(L, 3, 1);
if(lua_toboolean(L, -1))
{
lua_pop(L, 1);