diff --git a/stepmania/src/Actor.cpp b/stepmania/src/Actor.cpp index 4516db7f10..cacb91c023 100644 --- a/stepmania/src/Actor.cpp +++ b/stepmania/src/Actor.cpp @@ -486,9 +486,6 @@ void Actor::Update( float fDeltaTime ) // LOG->Trace( "Actor::Update( %f )", fDeltaTime ); ASSERT_M( fDeltaTime >= 0, ssprintf("%f",fDeltaTime) ); - if( m_bFirstUpdate ) - m_bFirstUpdate = false; - if( m_fHibernateSecondsLeft > 0 ) { m_fHibernateSecondsLeft -= fDeltaTime; @@ -500,6 +497,14 @@ void Actor::Update( float fDeltaTime ) m_fHibernateSecondsLeft = 0; } + this->UpdateInternal( fDeltaTime ); +} + +void Actor::UpdateInternal( float fDeltaTime ) +{ + if( m_bFirstUpdate ) + m_bFirstUpdate = false; + switch( m_EffectClock ) { case CLOCK_TIMER: @@ -1052,6 +1057,13 @@ bool Actor::HasCommand( const CString &sCmdName ) return it != m_mapNameToCommands.end(); } +const apActorCommands& Actor::GetCommand( const CString &sCommandName ) const +{ + map::const_iterator it = m_mapNameToCommands.find( sCommandName ); + ASSERT( it != m_mapNameToCommands.end() ); + return it->second; +} + void Actor::PlayCommand( const CString &sCommandName ) { PlayCommand2( sCommandName, NULL ); diff --git a/stepmania/src/Actor.h b/stepmania/src/Actor.h index 68d8e4fe49..93835b8082 100644 --- a/stepmania/src/Actor.h +++ b/stepmania/src/Actor.h @@ -87,8 +87,11 @@ public: virtual void DrawPrimitives() {}; // Derivitives should override virtual void EndDraw(); // pops transform from world matrix stack + // TODO: make Update non virtual and change all classes to override UpdateInternal + // instead. bool IsFirstUpdate() const; - virtual void Update( float fDeltaTime ); + virtual void Update( float fDeltaTime ); // this can short circuit UpdateInternal + virtual void UpdateInternal( float fDeltaTime ); // override this void UpdateTweening( float fDeltaTime ); void CopyTweening( const Actor &from ); @@ -333,6 +336,7 @@ public: virtual void PushSelf( lua_State *L ); void AddCommand( const CString &sCmdName, apActorCommands apac ); bool HasCommand( const CString &sCmdName ); + const apActorCommands& GetCommand( const CString &sCommandName ) const; virtual void PlayCommand( const CString &sCommandName ); virtual void PlayCommand2( const CString &sCommandName, Actor *pParent ); virtual void RunCommands( const LuaReference& cmds ); diff --git a/stepmania/src/ActorFrame.cpp b/stepmania/src/ActorFrame.cpp index 819160bfa0..29b0b0b57f 100644 --- a/stepmania/src/ActorFrame.cpp +++ b/stepmania/src/ActorFrame.cpp @@ -216,16 +216,13 @@ void ActorFrame::RunCommandsOnLeaves( const LuaReference& cmds ) m_SubActors[i]->RunCommandsOnLeaves( cmds ); } -void ActorFrame::Update( float fDeltaTime ) +void ActorFrame::UpdateInternal( float fDeltaTime ) { // LOG->Trace( "ActorFrame::Update( %f )", fDeltaTime ); fDeltaTime *= m_fUpdateRate; - Actor::Update( fDeltaTime ); - - if( m_fHibernateSecondsLeft > 0 ) - return; + Actor::UpdateInternal( fDeltaTime ); // update all sub-Actors for( vector::iterator it=m_SubActors.begin(); it!=m_SubActors.end(); it++ ) diff --git a/stepmania/src/ActorFrame.h b/stepmania/src/ActorFrame.h index 87e9ce2e0d..25c4f849d2 100644 --- a/stepmania/src/ActorFrame.h +++ b/stepmania/src/ActorFrame.h @@ -71,7 +71,7 @@ public: virtual void RunCommandsOnChildren( const apActorCommands& cmds ) { RunCommandsOnChildren( *cmds ); } // convenience virtual void RunCommandsOnLeaves( const LuaReference& cmds ); /* but not on self */ - virtual void Update( float fDeltaTime ); + virtual void UpdateInternal( float fDeltaTime ); virtual void DrawPrimitives(); // propagated commands diff --git a/stepmania/src/ActorScroller.cpp b/stepmania/src/ActorScroller.cpp index f12523394e..5ac3fd23c4 100644 --- a/stepmania/src/ActorScroller.cpp +++ b/stepmania/src/ActorScroller.cpp @@ -153,12 +153,9 @@ void ActorScroller::LoadFromNode( const CString &sDir, const XNode *pNode ) pNode->GetAttrValue( "QuantizePixels", m_fQuantizePixels ); } -void ActorScroller::Update( float fDeltaTime ) +void ActorScroller::UpdateInternal( float fDeltaTime ) { - ActorFrame::Update( fDeltaTime ); - - if( m_fHibernateSecondsLeft > 0 ) - return; // early abort + ActorFrame::UpdateInternal( fDeltaTime ); /* If we have no children, the code below will busy loop. */ if( !m_SubActors.size() ) diff --git a/stepmania/src/ActorScroller.h b/stepmania/src/ActorScroller.h index d2e4418bcd..e6248341ff 100644 --- a/stepmania/src/ActorScroller.h +++ b/stepmania/src/ActorScroller.h @@ -42,7 +42,7 @@ public: const CString &sTransformFunction, bool bUseMask ); - virtual void Update( float fDelta ); + virtual void UpdateInternal( float fDelta ); virtual void DrawPrimitives(); // DOES draw void LoadFromNode( const CString &sDir, const XNode *pNode ); diff --git a/stepmania/src/BGAnimationLayer.cpp b/stepmania/src/BGAnimationLayer.cpp index 663ed4a702..1fd9165eb7 100644 --- a/stepmania/src/BGAnimationLayer.cpp +++ b/stepmania/src/BGAnimationLayer.cpp @@ -556,12 +556,9 @@ void BGAnimationLayer::LoadFromNode( const CString& sDir, const XNode* pNode ) } } -void BGAnimationLayer::Update( float fDeltaTime ) +void BGAnimationLayer::UpdateInternal( float fDeltaTime ) { - if( m_fHibernateSecondsLeft > 0 ) - return; - - ActorFrame::Update( fDeltaTime ); + ActorFrame::UpdateInternal( fDeltaTime ); fDeltaTime *= m_fUpdateRate; diff --git a/stepmania/src/BGAnimationLayer.h b/stepmania/src/BGAnimationLayer.h index fb78899e5b..d08bd56201 100644 --- a/stepmania/src/BGAnimationLayer.h +++ b/stepmania/src/BGAnimationLayer.h @@ -20,7 +20,7 @@ public: void LoadFromAniLayerFile( const CString& sPath ); void LoadFromNode( const CString& sDir, const XNode* pNode ); - void Update( float fDeltaTime ); + void UpdateInternal( float fDeltaTime ); void DrawPrimitives(); bool EarlyAbortDraw(); diff --git a/stepmania/src/ThemeManager.cpp b/stepmania/src/ThemeManager.cpp index 9707558902..9bf358f355 100644 --- a/stepmania/src/ThemeManager.cpp +++ b/stepmania/src/ThemeManager.cpp @@ -629,9 +629,7 @@ bool ThemeManager::GetMetricRaw( const CString &sClassName, const CString &sValu CString sFallback; - for( deque::const_iterator iter = g_vThemes.begin(); - iter != g_vThemes.end(); - iter++ ) + FOREACHD_CONST( Theme, g_vThemes, iter ) { if( iter->iniMetrics->GetValue(sClassName,sValueName,ret) ) return true; diff --git a/stepmania/src/Transition.cpp b/stepmania/src/Transition.cpp index ca95cfdc0a..11fffaea07 100644 --- a/stepmania/src/Transition.cpp +++ b/stepmania/src/Transition.cpp @@ -65,7 +65,7 @@ void Transition::Load( CString sBGAniDir ) } -void Transition::Update( float fDeltaTime ) +void Transition::UpdateInternal( float fDeltaTime ) { if( m_State != transitioning ) return; @@ -83,7 +83,7 @@ void Transition::Update( float fDeltaTime ) SCREENMAN->SendMessageToTopScreen( m_MessageToSendWhenDone ); } - ActorFrame::Update( fDeltaTime ); + ActorFrame::UpdateInternal( fDeltaTime ); } void Transition::Reset() diff --git a/stepmania/src/Transition.h b/stepmania/src/Transition.h index f74fa5904f..120d85f653 100644 --- a/stepmania/src/Transition.h +++ b/stepmania/src/Transition.h @@ -16,7 +16,7 @@ public: void Load( CString sBGAniDir ); - virtual void Update( float fDeltaTime ); + virtual void UpdateInternal( float fDeltaTime ); virtual void StartTransitioning( ScreenMessage send_when_done = SM_None ); virtual bool EarlyAbortDraw();