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
+11 -5
View File
@@ -42,8 +42,15 @@ void PercentageDisplay::LoadFromNode( const XNode* pNode )
const XNode *pChild = pNode->GetChild( "Percent" );
if( pChild == NULL )
RageException::Throw( "%s: PercentageDisplay: missing the node \"Percent\"", ActorUtil::GetWhere(pNode).c_str() );
m_textPercent.LoadFromNode( pChild );
{
LuaHelpers::ReportScriptError(ActorUtil::GetWhere(pNode) + ": PercentageDisplay: missing the node \"Percent\"");
// Make a BitmapText just so we don't crash.
m_textPercent.LoadFromFont(THEME->GetPathF("", "Common Normal"));
}
else
{
m_textPercent.LoadFromNode( pChild );
}
this->AddChild( &m_textPercent );
pChild = pNode->GetChild( "PercentRemainder" );
@@ -154,9 +161,8 @@ void PercentageDisplay::Refresh()
m_FormatPercentScore.PushSelf( L );
ASSERT( !lua_isnil(L, -1) );
LuaHelpers::Push( L, fPercentDancePoints );
RString sError;
if( !LuaHelpers::RunScriptOnStack(L, sError, 1, 1) ) // 1 arg, 1 result
LOG->Warn( "Error running FormatPercentScore: %s", sError.c_str() );
RString Error= "Error running FormatPercentScore: ";
LuaHelpers::RunScriptOnStack(L, Error, 1, 1, true); // 1 arg, 1 result
LuaHelpers::Pop( L, sNumToDisplay );
LUA->Release(L);