From fcf121feb0181154be3667294a7930a057ba4f6d Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 10 Feb 2007 05:42:25 +0000 Subject: [PATCH] add PlayCommandNoRecurse to fix PlayCommand hack --- stepmania/src/Actor.cpp | 9 ++++++++- stepmania/src/Actor.h | 3 ++- stepmania/src/ActorFrame.cpp | 5 ----- stepmania/src/Screen.cpp | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/stepmania/src/Actor.cpp b/stepmania/src/Actor.cpp index 5be429f55d..1fb376d5f1 100644 --- a/stepmania/src/Actor.cpp +++ b/stepmania/src/Actor.cpp @@ -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 ) diff --git a/stepmania/src/Actor.h b/stepmania/src/Actor.h index 1b4d75ac6a..8490e02256 100644 --- a/stepmania/src/Actor.h +++ b/stepmania/src/Actor.h @@ -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. diff --git a/stepmania/src/ActorFrame.cpp b/stepmania/src/ActorFrame.cpp index 5fd8484225..4943ae83d6 100644 --- a/stepmania/src/ActorFrame.cpp +++ b/stepmania/src/ActorFrame.cpp @@ -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; iPlayCommand( "Init" ); + PlayCommandNoRecurse( Message("Init") ); vector asList; split( PREPARE_SCREENS, ",", asList );