From 3c049c100d27d24d2dce34248357a0a960f4835a Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sat, 26 Feb 2005 23:50:24 +0000 Subject: [PATCH] fix next screen logic --- stepmania/src/OptionRow.cpp | 7 +++++-- stepmania/src/OptionRow.h | 4 ++-- stepmania/src/ScreenOptions.cpp | 5 +---- stepmania/src/ScreenOptionsMaster.cpp | 18 +++++------------- 4 files changed, 13 insertions(+), 21 deletions(-) diff --git a/stepmania/src/OptionRow.cpp b/stepmania/src/OptionRow.cpp index 775977c97d..a3eee42935 100644 --- a/stepmania/src/OptionRow.cpp +++ b/stepmania/src/OptionRow.cpp @@ -34,12 +34,14 @@ CString ICONS_X_NAME( size_t p ) { return ssprintf("IconsP%dX",p+1); } OptionRow::OptionRow() { + m_pHand = NULL; + + Clear(); + FOREACH_PlayerNumber( p ) this->AddChild( &m_OptionIcons[p] ); this->AddChild( &m_sprBullet ); this->AddChild( &m_textTitle ); - - m_pHand = NULL; } OptionRow::~OptionRow() @@ -68,6 +70,7 @@ void OptionRow::Clear() m_bFirstItemGoesDown = false; ZERO( m_bRowHasFocus ); + ZERO( m_iChoiceInRowWithFocus ); } void OptionRow::DetachHandler() diff --git a/stepmania/src/OptionRow.h b/stepmania/src/OptionRow.h index 10e9270023..cd0174c066 100644 --- a/stepmania/src/OptionRow.h +++ b/stepmania/src/OptionRow.h @@ -106,14 +106,14 @@ public: if( m_RowDef.bOneChoiceForAllPlayers ) pn = PLAYER_1; int iChoice = m_iChoiceInRowWithFocus[pn]; - ASSERT(iChoice<(int)m_RowDef.choices.size()); + ASSERT(iChoice >= 0 && iChoice < (int)m_RowDef.choices.size()); return iChoice; } void SetChoiceInRowWithFocus( PlayerNumber pn, int iChoice ) { if( m_RowDef.bOneChoiceForAllPlayers ) pn = PLAYER_1; - ASSERT(iChoice<(int)m_RowDef.choices.size()); + ASSERT(iChoice >= 0 && iChoice < (int)m_RowDef.choices.size()); m_iChoiceInRowWithFocus[pn] = iChoice; } bool GetSelected( PlayerNumber pn, int iChoice ) const diff --git a/stepmania/src/ScreenOptions.cpp b/stepmania/src/ScreenOptions.cpp index d05fe1636e..f567406a31 100644 --- a/stepmania/src/ScreenOptions.cpp +++ b/stepmania/src/ScreenOptions.cpp @@ -1013,6 +1013,7 @@ void ScreenOptions::MoveRow( PlayerNumber pn, int dir, bool Repeat ) const unsigned iOldSelection = row.GetChoiceInRowWithFocus(p); m_iCurrentRow[p] = r; + ASSERT( r >= 0 && r < (int)m_Rows.size() ); OptionRow &row = *m_Rows[r]; @@ -1088,10 +1089,6 @@ void ScreenOptions::MenuDown( PlayerNumber pn, const InputEventType type ) int ScreenOptions::GetCurrentRow( PlayerNumber pn ) const { const int r = m_iCurrentRow[pn]; - OptionRow &row = *m_Rows[r]; - - if( row.GetRowType() != OptionRow::ROW_NORMAL ) - return -1; return r; } diff --git a/stepmania/src/ScreenOptionsMaster.cpp b/stepmania/src/ScreenOptionsMaster.cpp index 68d4f288bd..239c33fc45 100644 --- a/stepmania/src/ScreenOptionsMaster.cpp +++ b/stepmania/src/ScreenOptionsMaster.cpp @@ -154,26 +154,18 @@ void ScreenOptionsMaster::BeginFadingOut() * honor it. */ m_sNextScreen = ""; - const unsigned uFocusRow = this->GetCurrentRow(); + int iCurRow = this->GetCurrentRow(); + ASSERT( iCurRow >= 0 && iCurRow < (int)m_Rows.size() ); + OptionRow &row = *m_Rows[iCurRow]; - for( unsigned r = 0; r < OptionRowHandlers.size(); ++r ) + if( iCurRow < (int)OptionRowHandlers.size() ) { - OptionRow &row = *m_Rows[r]; - - CHECKPOINT_M( ssprintf("%i/%i", r, int(OptionRowHandlers.size())) ); - - /* If SELECT_NONE, only apply it if it's the selected option. */ - if( row.GetRowDef().selectType == SELECT_NONE && r != uFocusRow ) - continue; - - OptionRowHandler *pHand = OptionRowHandlers[r]; - const int iChoice = row.GetChoiceInRowWithFocus(GAMESTATE->m_MasterPlayerNumber); + OptionRowHandler *pHand = OptionRowHandlers[iCurRow]; CString sScreen = pHand->GetAndEraseScreen( iChoice ); if( !sScreen.empty() ) m_sNextScreen = sScreen; } - CHECKPOINT; // NEXT_SCREEN; if( m_sNextScreen == "" )