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:
+18
-35
@@ -22,6 +22,8 @@
|
|||||||
#include "SongOptions.h"
|
#include "SongOptions.h"
|
||||||
#include "RageUtil.h"
|
#include "RageUtil.h"
|
||||||
#include "TitleSubstitution.h"
|
#include "TitleSubstitution.h"
|
||||||
|
#include "Notes.h"
|
||||||
|
#include "GameState.h"
|
||||||
|
|
||||||
|
|
||||||
Course::Course()
|
Course::Course()
|
||||||
@@ -431,10 +433,26 @@ void Course::GetStageInfo(
|
|||||||
if( !pSong || !pNotes )
|
if( !pSong || !pNotes )
|
||||||
continue; // this song entry isn't playable. Skip.
|
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 );
|
vSongsOut.push_back( pSong );
|
||||||
vNotesOut.push_back( pNotes );
|
vNotesOut.push_back( pNotes );
|
||||||
vsModifiersOut.push_back( e.modifiers );
|
vsModifiersOut.push_back( e.modifiers );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Course::GetFirstStageInfo(
|
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
|
// Sorting stuff
|
||||||
|
|||||||
@@ -76,8 +76,6 @@ public:
|
|||||||
void GetMeterRange( int stage, int& iMeterLowOut, int& iMeterHighOut ) const;
|
void GetMeterRange( int stage, int& iMeterLowOut, int& iMeterHighOut ) const;
|
||||||
bool ContainsAnyMysterySongs() const;
|
bool ContainsAnyMysterySongs() const;
|
||||||
bool GetTotalSeconds( float& fSecondsOut ) const;
|
bool GetTotalSeconds( float& fSecondsOut ) const;
|
||||||
bool MakeDifficult();
|
|
||||||
bool MakeNormal();
|
|
||||||
|
|
||||||
|
|
||||||
void LoadFromCRSFile( CString sPath );
|
void LoadFromCRSFile( CString sPath );
|
||||||
|
|||||||
@@ -844,9 +844,6 @@ void MusicWheel::Update( float fDeltaTime )
|
|||||||
|
|
||||||
void MusicWheel::ChangeMusic(int dist)
|
void MusicWheel::ChangeMusic(int dist)
|
||||||
{
|
{
|
||||||
if(GAMESTATE->m_PlayMode == PLAY_MODE_NONSTOP)
|
|
||||||
GetSelectedCourse()->MakeNormal();
|
|
||||||
|
|
||||||
m_iSelection += dist;
|
m_iSelection += dist;
|
||||||
if( m_iSelection < 0 )
|
if( m_iSelection < 0 )
|
||||||
m_iSelection = m_CurWheelItemData.size()-1;
|
m_iSelection = m_CurWheelItemData.size()-1;
|
||||||
@@ -857,9 +854,6 @@ void MusicWheel::ChangeMusic(int dist)
|
|||||||
|
|
||||||
m_fPositionOffsetFromSelection += dist;
|
m_fPositionOffsetFromSelection += dist;
|
||||||
|
|
||||||
if(GAMESTATE->m_bDifficultCourses && GAMESTATE->m_PlayMode == PLAY_MODE_NONSTOP)
|
|
||||||
GetSelectedCourse()->MakeDifficult();
|
|
||||||
|
|
||||||
SCREENMAN->PostMessageToTopScreen( SM_SongChanged, 0 );
|
SCREENMAN->PostMessageToTopScreen( SM_SongChanged, 0 );
|
||||||
|
|
||||||
/* If we're moving automatically, don't play this; it'll be called in Update. */
|
/* If we're moving automatically, don't play this; it'll be called in Update. */
|
||||||
|
|||||||
@@ -253,25 +253,21 @@ void ScreenSelectCourse::Input( const DeviceInput& DeviceI, InputEventType type,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( CodeDetector::EnteredEasierDifficulty(GameI.controller) )
|
if( CodeDetector::EnteredEasierDifficulty(GameI.controller) &&
|
||||||
{
|
GAMESTATE->m_bDifficultCourses)
|
||||||
if( m_MusicWheel.GetSelectedCourse()->MakeNormal() )
|
|
||||||
{
|
{
|
||||||
m_soundChangeNotes.Play();
|
m_soundChangeNotes.Play();
|
||||||
GAMESTATE->m_bDifficultCourses = false;
|
GAMESTATE->m_bDifficultCourses = false;
|
||||||
SCREENMAN->PostMessageToTopScreen(SM_SongChanged,0);
|
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();
|
m_soundChangeNotes.Play();
|
||||||
GAMESTATE->m_bDifficultCourses = true;
|
GAMESTATE->m_bDifficultCourses = true;
|
||||||
SCREENMAN->PostMessageToTopScreen(SM_SongChanged,0);
|
SCREENMAN->PostMessageToTopScreen(SM_SongChanged,0);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Screen::Input( DeviceI, type, GameI, MenuI, StyleI ); // default input handler
|
Screen::Input( DeviceI, type, GameI, MenuI, StyleI ); // default input handler
|
||||||
|
|||||||
Reference in New Issue
Block a user