Don't modify stored courses; it's far too easy to accidentally forget

to reset them in one of the (many) exit-gameplay paths, or reset it
incorrectly.

This fixes the course selection screen crashing when there is
no music.
This commit is contained in:
Glenn Maynard
2003-03-28 02:25:15 +00:00
parent 21c4f840c7
commit c7c02602d9
4 changed files with 28 additions and 57 deletions
+18 -35
View File
@@ -22,6 +22,8 @@
#include "SongOptions.h"
#include "RageUtil.h"
#include "TitleSubstitution.h"
#include "Notes.h"
#include "GameState.h"
Course::Course()
@@ -431,10 +433,26 @@ void Course::GetStageInfo(
if( !pSong || !pNotes )
continue; // this song entry isn't playable. Skip.
if(GAMESTATE->m_bDifficultCourses)
{
/* See if we can find a NoteData that's one notch more difficult than
* the one we found above. */
Difficulty dc = pNotes->GetDifficulty();
if(dc < DIFFICULTY_CHALLENGE)
{
dc = Difficulty(dc + 1);
Notes* pNewNotes = pSong->GetNotes( nt, dc );
if(pNewNotes)
pNotes = pNewNotes;
}
}
vSongsOut.push_back( pSong );
vNotesOut.push_back( pNotes );
vsModifiersOut.push_back( e.modifiers );
}
}
bool Course::GetFirstStageInfo(
@@ -609,41 +627,6 @@ void Course::AddScores( NotesType nt, bool bPlayerEnabled[NUM_PLAYERS], int iDan
}
}
bool Course::MakeNormal()
{
if( !m_bRepeat && m_iLives == -1 ) // nonstop only, not oni or endless
if(m_bDifficult) //only make it easy if it's already difficult
{
unsigned c;
for( c = 0; c < m_entries.size(); c++)
{
if( m_entries[c].difficulty == DIFFICULTY_BEGINNER || m_entries[c].difficulty == DIFFICULTY_INVALID ) // don't suddenly make things invalid or worse
continue;
m_entries[c].difficulty = Difficulty(m_entries[c].difficulty - 1);
}
m_bDifficult = false;
return true;
}
return false;
}
bool Course::MakeDifficult()
{
if( !m_bRepeat && m_iLives == -1 ) // nonstop only, not oni or endless
if(!m_bDifficult) //only make it difficult once
{
unsigned c;
for( c = 0; c < m_entries.size(); c++)
{
if( m_entries[c].difficulty < DIFFICULTY_CHALLENGE ) // don't suddenly make things invalid or worse
m_entries[c].difficulty = Difficulty(m_entries[c].difficulty + 1);
}
m_bDifficult = true;
return true;
}
return false;
}
//
// Sorting stuff
-2
View File
@@ -76,8 +76,6 @@ public:
void GetMeterRange( int stage, int& iMeterLowOut, int& iMeterHighOut ) const;
bool ContainsAnyMysterySongs() const;
bool GetTotalSeconds( float& fSecondsOut ) const;
bool MakeDifficult();
bool MakeNormal();
void LoadFromCRSFile( CString sPath );
-6
View File
@@ -844,9 +844,6 @@ void MusicWheel::Update( float fDeltaTime )
void MusicWheel::ChangeMusic(int dist)
{
if(GAMESTATE->m_PlayMode == PLAY_MODE_NONSTOP)
GetSelectedCourse()->MakeNormal();
m_iSelection += dist;
if( m_iSelection < 0 )
m_iSelection = m_CurWheelItemData.size()-1;
@@ -857,9 +854,6 @@ void MusicWheel::ChangeMusic(int dist)
m_fPositionOffsetFromSelection += dist;
if(GAMESTATE->m_bDifficultCourses && GAMESTATE->m_PlayMode == PLAY_MODE_NONSTOP)
GetSelectedCourse()->MakeDifficult();
SCREENMAN->PostMessageToTopScreen( SM_SongChanged, 0 );
/* If we're moving automatically, don't play this; it'll be called in Update. */
+10 -14
View File
@@ -253,24 +253,20 @@ void ScreenSelectCourse::Input( const DeviceInput& DeviceI, InputEventType type,
return;
}
if( CodeDetector::EnteredEasierDifficulty(GameI.controller) )
if( CodeDetector::EnteredEasierDifficulty(GameI.controller) &&
GAMESTATE->m_bDifficultCourses)
{
if( m_MusicWheel.GetSelectedCourse()->MakeNormal() )
{
m_soundChangeNotes.Play();
GAMESTATE->m_bDifficultCourses = false;
SCREENMAN->PostMessageToTopScreen(SM_SongChanged,0);
}
m_soundChangeNotes.Play();
GAMESTATE->m_bDifficultCourses = false;
SCREENMAN->PostMessageToTopScreen(SM_SongChanged,0);
}
if( CodeDetector::EnteredHarderDifficulty(GameI.controller) )
if( CodeDetector::EnteredHarderDifficulty(GameI.controller) &&
!GAMESTATE->m_bDifficultCourses)
{
if( m_MusicWheel.GetSelectedCourse()->MakeDifficult() )
{
m_soundChangeNotes.Play();
GAMESTATE->m_bDifficultCourses = true;
SCREENMAN->PostMessageToTopScreen(SM_SongChanged,0);
}
m_soundChangeNotes.Play();
GAMESTATE->m_bDifficultCourses = true;
SCREENMAN->PostMessageToTopScreen(SM_SongChanged,0);
}