lua locking

This commit is contained in:
Glenn Maynard
2005-06-16 22:10:24 +00:00
parent 8a2334b4bf
commit c0a65b3503
4 changed files with 31 additions and 19 deletions
+10 -6
View File
@@ -850,21 +850,25 @@ void Actor::AddRotationR( float rot )
void Actor::RunCommands( const LuaReference& cmds, Actor *pParent )
{
Lua *L = LUA->Get();
// function
cmds.PushSelf( LUA->L );
ASSERT( !lua_isnil(LUA->L, -1) );
cmds.PushSelf( L );
ASSERT( !lua_isnil(L, -1) );
// 1st parameter
this->PushSelf( LUA->L );
this->PushSelf( L );
// 2nd parameter
if( pParent )
pParent->PushSelf( LUA->L );
pParent->PushSelf( L );
else
lua_pushnil( LUA->L );
lua_pushnil( L );
// call function with 1 argument and 0 results
lua_call(LUA->L, 2, 0);
lua_call( L, 2, 0 );
LUA->Release(L);
}
float Actor::GetCommandsLengthSeconds( const LuaReference& cmds )
+9 -7
View File
@@ -204,13 +204,15 @@ void ActorScroller::UpdateInternal( float fDeltaTime )
void ActorScroller::PositionItem( Actor *pActor, float fPositionOffsetFromCenter, int iItemIndex, int iNumItems )
{
m_exprTransformFunction.PushSelf( LUA->L );
ASSERT( !lua_isnil(LUA->L, -1) );
pActor->PushSelf( LUA->L );
LuaHelpers::Push( fPositionOffsetFromCenter, LUA->L );
LuaHelpers::Push( iItemIndex, LUA->L );
LuaHelpers::Push( iNumItems, LUA->L );
lua_call( LUA->L, 4, 0 ); // 4 args, 0 results
Lua *L = LUA->Get();
m_exprTransformFunction.PushSelf( L );
ASSERT( !lua_isnil(L, -1) );
pActor->PushSelf( L );
LuaHelpers::Push( fPositionOffsetFromCenter, L );
LuaHelpers::Push( iItemIndex, L );
LuaHelpers::Push( iNumItems, L );
lua_call( L, 4, 0 ); // 4 args, 0 results
LUA->Release(L);
}
void ActorScroller::DrawPrimitives()
+6 -4
View File
@@ -723,14 +723,16 @@ void GameCommand::ApplySelf( const vector<PlayerNumber> &vpns ) const
GAMESTATE->ApplyModifiers( *pn, m_sModifiers );
if( m_LuaFunction.IsSet() )
{
Lua *L = LUA->Get();
FOREACH_CONST( PlayerNumber, vpns, pn )
{
m_LuaFunction.PushSelf( LUA->L );
ASSERT( !lua_isnil(LUA->L, -1) );
m_LuaFunction.PushSelf( L );
ASSERT( !lua_isnil(L, -1) );
lua_pushnumber( LUA->L, *pn ); // 1st parameter
lua_call( LUA->L, 1, 0 ); // call function with 1 argument and 0 results
lua_pushnumber( L, *pn ); // 1st parameter
lua_call( L, 1, 0 ); // call function with 1 argument and 0 results
}
LUA->Release(L);
}
if( m_sScreen != "" )
SCREENMAN->SetNewScreen( m_sScreen );
+6 -2
View File
@@ -247,14 +247,18 @@ bool LuaHelpers::RunScriptFile( const CString &sFile )
return false;
}
Lua *L = LUA->Get();
CString sError;
if( !LuaHelpers::RunScript( LUA->L, sScript, sFile, sError, 0 ) )
if( !LuaHelpers::RunScript( L, sScript, sFile, sError, 0 ) )
{
LUA->Release(L);
sError = ssprintf( "Lua runtime error: %s", sError.c_str() );
Dialog::OK( sError, "LUA_ERROR" );
return false;
}
LUA->Release(L);
return true;
}