Replaced every use of lua_call with RunScriptOnStack. Modified RunScriptOnStack to report an error to log and system message using a passed in context string. Modified every use of RunScriptOnStack to avoid crashing so that the reported error can be seen.

This commit is contained in:
Kyzentun
2014-07-05 01:34:05 -06:00
parent e9220c56b7
commit a7a98a690e
18 changed files with 219 additions and 168 deletions
+6 -7
View File
@@ -242,9 +242,8 @@ void ActorFrame::DrawPrimitives()
return;
}
this->PushSelf( L );
RString sError;
if( !LuaHelpers::RunScriptOnStack(L, sError, 1, 0) ) // 1 arg, 0 results
LOG->Warn( "Error running DrawFunction: %s", sError.c_str() );
RString Error= "Error running DrawFunction: ";
LuaHelpers::RunScriptOnStack(L, Error, 1, 0, true); // 1 arg, 0 results
LUA->Release(L);
return;
}
@@ -302,6 +301,8 @@ static int IdenticalChildrenSingleApplier(lua_State* L)
lua_pushvalue(L, lua_upvalueindex(1)); // stack: table, obj, args, func
lua_insert(L, 2); // stack: table, func, obj, args
int args_count= lua_gettop(L) - 2;
// Not using RunScriptOnStack because we're inside a lua call already and
// we want an error to propagate up.
lua_call(L, args_count, LUA_MULTRET); // stack: table, return_values
return lua_gettop(L) - 1;
}
@@ -482,10 +483,8 @@ void ActorFrame::UpdateInternal( float fDeltaTime )
}
this->PushSelf( L );
lua_pushnumber( L, fDeltaTime );
RString sError;
if( !LuaHelpers::RunScriptOnStack(L, sError, 2, 0) ) // 1 args, 0 results
LOG->Warn( "Error running m_UpdateFunction: %s", sError.c_str() );
RString Error= "Error running UpdateFunction: ";
LuaHelpers::RunScriptOnStack(L, Error, 2, 0, true); // 1 args, 0 results
LUA->Release(L);
}
}