add PlayCommandNoRecurse to fix PlayCommand hack

This commit is contained in:
Glenn Maynard
2007-02-10 05:42:25 +00:00
parent 5e549c0437
commit fcf121feb0
4 changed files with 11 additions and 8 deletions
+8 -1
View File
@@ -233,7 +233,9 @@ void Actor::LoadFromNode( const XNode* pNode )
LUA->Release( L );
PlayCommand( "Init" );
// Don't recurse Init. It gets called once for every Actor when the
// Actor is loaded, and we don't want to call it again.
PlayCommandNoRecurse( Message("Init") );
}
void Actor::Draw()
@@ -1153,6 +1155,11 @@ const apActorCommands *Actor::GetCommand( const RString &sCommandName ) const
}
void Actor::HandleMessage( const Message &msg )
{
PlayCommandNoRecurse( msg );
}
void Actor::PlayCommandNoRecurse( const Message &msg )
{
const apActorCommands *pCmd = GetCommand( msg.GetName() );
if( pCmd != NULL )
+2 -1
View File
@@ -356,7 +356,8 @@ public:
void AddCommand( const RString &sCmdName, apActorCommands apac );
bool HasCommand( const RString &sCmdName );
const apActorCommands *GetCommand( const RString &sCommandName ) const;
void PlayCommand( const RString &sCommandName ) { HandleMessage( Message(sCommandName) ); }
void PlayCommand( const RString &sCommandName ) { HandleMessage( Message(sCommandName) ); } // convenience
void PlayCommandNoRecurse( const Message &sCommandName );
virtual void RunCommands( const LuaReference& cmds, const LuaReference *pParamTable = NULL );
void RunCommands( const apActorCommands& cmds, const LuaReference *pParamTable = NULL ) { this->RunCommands( *cmds, pParamTable ); } // convenience
// If we're a leaf, then execute this command.
-5
View File
@@ -356,11 +356,6 @@ void ActorFrame::HandleMessage( const Message &msg )
{
Actor::HandleMessage( msg );
// HACK: Don't propogate Init. It gets called once for every Actor when the
// Actor is loaded, and we don't want to call it again.
if( msg.GetName() == "Init" )
return;
for( unsigned i=0; i<m_SubActors.size(); i++ )
{
Actor* pActor = m_SubActors[i];
+1 -1
View File
@@ -40,7 +40,7 @@ void Screen::Init()
ActorUtil::LoadAllCommandsFromName( *this, m_sName, "Screen" );
this->PlayCommand( "Init" );
PlayCommandNoRecurse( Message("Init") );
vector<RString> asList;
split( PREPARE_SCREENS, ",", asList );