diff --git a/stepmania/src/Player.cpp b/stepmania/src/Player.cpp index 19e6b0e8e3..be6ec60617 100644 --- a/stepmania/src/Player.cpp +++ b/stepmania/src/Player.cpp @@ -142,7 +142,7 @@ float Player::GetWindowSeconds( TimingWindow tw ) return fSecs; } -Player::Player( NoteData &nd, bool bVisible ) : m_NoteData(nd) +Player::Player( NoteData &nd, bool bVisibleParts ) : m_NoteData(nd) { m_bLoaded = false; @@ -166,7 +166,7 @@ Player::Player( NoteData &nd, bool bVisible ) : m_NoteData(nd) m_bPaused = false; m_pAttackDisplay = NULL; - if( bVisible ) + if( bVisibleParts ) { m_pAttackDisplay = new AttackDisplay; this->AddChild( m_pAttackDisplay ); @@ -175,14 +175,12 @@ Player::Player( NoteData &nd, bool bVisible ) : m_NoteData(nd) PlayerAI::InitFromDisk(); m_pNoteField = NULL; - if( bVisible ) + if( bVisibleParts ) { m_pNoteField = new NoteField; m_pNoteField->SetName( "NoteField" ); } m_pJudgedRows = new JudgedRows; - - this->SetVisible( bVisible ); } Player::~Player() @@ -339,7 +337,7 @@ void Player::Init( m_soundAttackEnding.SetProperty( "Pan", fBalance ); - if( this->GetVisible() ) + if( HasVisibleParts() ) { LuaThreadVariable var( "Player", LuaReference::Create(m_pPlayerState->m_PlayerNumber) ); LuaThreadVariable var2( "MultiPlayer", LuaReference::Create(m_pPlayerState->m_mp) ); @@ -360,7 +358,7 @@ void Player::Init( for( int i = 0; i < GAMESTATE->GetCurrentStyle()->m_iColsPerPlayer; ++i ) m_vpHoldJudgment[i] = NULL; - if( this->GetVisible() ) + if( HasVisibleParts() ) { for( int i = 0; i < GAMESTATE->GetCurrentStyle()->m_iColsPerPlayer; ++i ) { @@ -571,7 +569,9 @@ void Player::Update( float fDeltaTime ) const float fSongBeat = GAMESTATE->m_fSongBeat; const int iSongRow = BeatToNoteRow( fSongBeat ); - if( this->GetVisible() ) + // Optimization: Don't spend time processing the things below that won't show + // if the Player doesn't show anything on the screen. + if( HasVisibleParts() ) { if( m_pPlayerState->m_bAttackBeganThisUpdate ) m_soundAttackLaunch.Play(); diff --git a/stepmania/src/Player.h b/stepmania/src/Player.h index 1059961b05..7561765090 100644 --- a/stepmania/src/Player.h +++ b/stepmania/src/Player.h @@ -39,7 +39,7 @@ class Player: public ActorFrame { public: // The passed in NoteData isn't touched until Load() is called. - Player( NoteData &nd, bool bVisible = true ); + Player( NoteData &nd, bool bVisibleParts = true ); ~Player(); virtual void Update( float fDeltaTime ); @@ -96,7 +96,7 @@ public: static float GetMaxStepDistanceSeconds(); static float GetWindowSeconds( TimingWindow tw ); const NoteData &GetNoteData() const { return m_NoteData; } - bool HasNoteField() const { return m_pNoteField != NULL; } + bool HasVisibleParts() const { return m_pNoteField != NULL; } void SetActorWithJudgmentPosition( Actor *pActor ) { m_pActorWithJudgmentPosition = pActor; } void SetActorWithComboPosition( Actor *pActor ) { m_pActorWithComboPosition = pActor; } diff --git a/stepmania/src/ScreenGameplay.cpp b/stepmania/src/ScreenGameplay.cpp index 82006249fc..01dd3ca544 100644 --- a/stepmania/src/ScreenGameplay.cpp +++ b/stepmania/src/ScreenGameplay.cpp @@ -318,7 +318,7 @@ GetNextVisiblePlayerInfo( vector::iterator iter, vector { for( ; iter != v.end(); ++iter ) { - if( !iter->m_pPlayer->HasNoteField() ) + if( !iter->m_pPlayer->HasVisibleParts() ) continue; return iter; } @@ -476,7 +476,7 @@ void ScreenGameplay::Init() FOREACH_EnabledPlayerInfoNotDummy( m_vPlayerInfo, pi ) { - if( pi->m_pPlayer->HasNoteField() ) + if( pi->m_pPlayer->HasVisibleParts() ) { pi->m_sprOniGameOver.Load( THEME->GetPathG(m_sName,"oni gameover") ); pi->m_sprOniGameOver->SetName( ssprintf("OniGameOver%s",pi->GetName().c_str()) );