diff --git a/stepmania/src/GameState.cpp b/stepmania/src/GameState.cpp index c6ebd8a461..41c88ca534 100644 --- a/stepmania/src/GameState.cpp +++ b/stepmania/src/GameState.cpp @@ -65,7 +65,7 @@ void GameState::Reset() // m_iCoins = 0; // don't reset coin count! m_MasterPlayerNumber = PLAYER_INVALID; m_sPreferredGroup = GROUP_ALL_MUSIC; - m_bChangedFailMode = false; + m_bChangedFailType = false; for( p=0; p +void setmin( T &a, const T &b ) +{ + a = min(a, b); +} + +template +void setmax( T &a, const T &b ) +{ + a = max(a, b); +} + +/* Adjust the fail mode based on the chosen difficulty. This must be called + * after the difficulty has been finalized (usually in ScreenSelectMusic or + * ScreenPlayerOptions), and before the fail mode is displayed or used (usually + * in ScreenSongOptions). */ +void GameState::AdjustFailType() +{ + /* If the player changed the fail mode explicitly, leave it alone. */ + if( GAMESTATE->m_bChangedFailType ) + return; + + /* Find the easiest difficulty notes selected by either player. */ + Difficulty dc = DIFFICULTY_INVALID; + for( int p=0; pIsHumanPlayer(p) ) + continue; // skip + + dc = min(dc, GAMESTATE->m_pCurNotes[p]->GetDifficulty()); + } + + /* Reset the fail type to the default. */ + SongOptions so; + so.FromString( PREFSMAN->m_sDefaultModifiers ); + GAMESTATE->m_SongOptions.m_FailType = so.m_FailType; + + /* Easy and beginner are never harder than FAIL_END_OF_SONG. */ + if(dc <= DIFFICULTY_EASY) + setmax(GAMESTATE->m_SongOptions.m_FailType, SongOptions::FAIL_END_OF_SONG); + + /* If beginner's steps were chosen, and this is the first stage, + * turn off failure completely--always give a second try. */ + if(dc == DIFFICULTY_BEGINNER && + !PREFSMAN->m_bEventMode && /* stage index is meaningless in event mode */ + GAMESTATE->m_iCurrentStageIndex == 0) + setmax(GAMESTATE->m_SongOptions.m_FailType, SongOptions::FAIL_OFF); +} diff --git a/stepmania/src/GameState.h b/stepmania/src/GameState.h index 7e527c6a26..7d6d13dc06 100644 --- a/stepmania/src/GameState.h +++ b/stepmania/src/GameState.h @@ -104,7 +104,7 @@ public: CString m_sLoadingMessage; // used in loading screen CString m_sPreferredGroup; // GROUP_ALL_MUSIC denotes no preferred group - bool m_bChangedFailMode; // true if the fail mode was changed in the song options screen + bool m_bChangedFailType; // true if FailType was changed in the song options screen Difficulty m_PreferredDifficulty[NUM_PLAYERS]; SongSortOrder m_SongSortOrder; // used by MusicWheel bool m_bEditing; // NoteField does special stuff when this is true @@ -203,6 +203,7 @@ public: void StoreSelectedOptions(); void RestoreSelectedOptions(); + void AdjustFailType(); // character stuff vector m_pCharacters; diff --git a/stepmania/src/ScreenPlayerOptions.cpp b/stepmania/src/ScreenPlayerOptions.cpp index 7c17c5f0ce..af0b16c50e 100644 --- a/stepmania/src/ScreenPlayerOptions.cpp +++ b/stepmania/src/ScreenPlayerOptions.cpp @@ -362,6 +362,8 @@ void ScreenPlayerOptions::GoToPrevState() void ScreenPlayerOptions::GoToNextState() { + GAMESTATE->AdjustFailType(); + if( GAMESTATE->m_bEditing ) SCREENMAN->PopTopScreen(); else if( m_bGoToOptions ) diff --git a/stepmania/src/ScreenSelectMusic.cpp b/stepmania/src/ScreenSelectMusic.cpp index 5edec0b3e3..a0ab41c699 100644 --- a/stepmania/src/ScreenSelectMusic.cpp +++ b/stepmania/src/ScreenSelectMusic.cpp @@ -669,51 +669,6 @@ void ScreenSelectMusic::HarderDifficulty( PlayerNumber pn ) AfterNotesChange( pn ); } -template -void setmin( T &a, const T &b ) -{ - a = min(a, b); -} - -template -void setmax( T &a, const T &b ) -{ - a = max(a, b); -} - -/* Adjust game options. These settings may be overridden again later by the - * SongOptions menu. */ -void ScreenSelectMusic::AdjustOptions() -{ - /* Find the easiest difficulty notes selected by either player. */ - Difficulty dc = DIFFICULTY_INVALID; - for( int p=0; pIsHumanPlayer(p) ) - continue; // skip - - dc = min(dc, GAMESTATE->m_pCurNotes[p]->GetDifficulty()); - } - - if( !GAMESTATE->m_bChangedFailMode ) - { - /* Reset the fail type to the default. */ - SongOptions so; - so.FromString( PREFSMAN->m_sDefaultModifiers ); - GAMESTATE->m_SongOptions.m_FailType = so.m_FailType; - - /* Easy and beginner are never harder than FAIL_END_OF_SONG. */ - if(dc <= DIFFICULTY_EASY) - setmax(GAMESTATE->m_SongOptions.m_FailType, SongOptions::FAIL_END_OF_SONG); - - /* If beginner's steps were chosen, and this is the first stage, - * turn off failure completely--always give a second try. */ - if(dc == DIFFICULTY_BEGINNER && - !PREFSMAN->m_bEventMode && /* stage index is meaningless in event mode */ - GAMESTATE->m_iCurrentStageIndex == 0) - setmax(GAMESTATE->m_SongOptions.m_FailType, SongOptions::FAIL_OFF); - } -} void ScreenSelectMusic::HandleScreenMessage( const ScreenMessage SM ) { @@ -754,6 +709,7 @@ void ScreenSelectMusic::HandleScreenMessage( const ScreenMessage SM ) } else { + GAMESTATE->AdjustFailType(); SOUNDMAN->StopMusic(); SCREENMAN->SetNewScreen( NEXT_SCREEN(GAMESTATE->m_PlayMode) ); } @@ -822,7 +778,6 @@ void ScreenSelectMusic::MenuStart( PlayerNumber pn ) if( GAMESTATE->IsCourseMode() ) GAMESTATE->m_PlayMode = PLAY_MODE_ARCADE; - AdjustOptions(); break; } case TYPE_COURSE: diff --git a/stepmania/src/ScreenSelectMusic.h b/stepmania/src/ScreenSelectMusic.h index 21a8a6cfec..7c9639330b 100644 --- a/stepmania/src/ScreenSelectMusic.h +++ b/stepmania/src/ScreenSelectMusic.h @@ -65,7 +65,6 @@ protected: void SortOrderChanged(); void UpdateOptionsDisplays(); - void AdjustOptions(); vector m_arrayNotes; int m_iSelection[NUM_PLAYERS]; diff --git a/stepmania/src/ScreenSongOptions.cpp b/stepmania/src/ScreenSongOptions.cpp index 0840b30808..2eb967dbcd 100644 --- a/stepmania/src/ScreenSongOptions.cpp +++ b/stepmania/src/ScreenSongOptions.cpp @@ -104,7 +104,7 @@ void ScreenSongOptions::ExportOptions() if( so.m_FailType != (SongOptions::FailType)m_iSelectedOption[0][SO_FAIL] ) { /* The user is changing the fail mode explicitly; stop messing with it. */ - GAMESTATE->m_bChangedFailMode = true; + GAMESTATE->m_bChangedFailType = true; so.m_FailType = (SongOptions::FailType)m_iSelectedOption[0][SO_FAIL]; } so.m_bAssistTick = !!m_iSelectedOption[0][SO_ASSIST];