From 1e6faf12a6990a125fe5bf751f32858e6cc9f074 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 4 Sep 2002 03:29:42 +0000 Subject: [PATCH] Instead of choosing random songs in Endless, pre-shuffle them to avoid repetition. --- stepmania/src/Course.cpp | 22 ++++++++++++++++++---- stepmania/src/Course.h | 8 +++++++- stepmania/src/MusicWheel.cpp | 2 +- stepmania/src/ScreenGameplay.cpp | 14 ++++++-------- 4 files changed, 32 insertions(+), 14 deletions(-) diff --git a/stepmania/src/Course.cpp b/stepmania/src/Course.cpp index a284a334aa..0fecadb4ac 100644 --- a/stepmania/src/Course.cpp +++ b/stepmania/src/Course.cpp @@ -122,8 +122,15 @@ void Course::CreateEndlessCourseFromGroupAndDifficultyClass( CString sGroupName, Song* pSong = apSongsInGroup[s]; AddStage( pSong, DifficultyClassToString(dc), "" ); } + Shuffle(); } +void Course::Shuffle() +{ + /* Shuffle the list. */ + for( int i = 0; i < m_iStages; ++i) + swap(SongOrdering[i], SongOrdering[rand() % m_iStages]); +} Notes* Course::GetNotesForStage( int iStage ) { @@ -154,13 +161,20 @@ Notes* Course::GetNotesForStage( int iStage ) } -void Course::GetSongAndNotesForCurrentStyle( CArray& apSongsOut, CArray& apNotesOut, CStringArray& asModifiersOut ) +/* When bShuffled is true, returns courses in the song ordering list. */ +void Course::GetSongAndNotesForCurrentStyle( + CArray& apSongsOut, + CArray& apNotesOut, + CStringArray& asModifiersOut, + bool bShuffled ) { for( int i=0; i& apSongsOut, CArray& apNotesOut, CStringArray& asModifiersOut ); + void GetSongAndNotesForCurrentStyle( CArray& apSongsOut, CArray& apNotesOut, CStringArray& asModifiersOut, bool bShuffled ); D3DXCOLOR GetColor(); + +private: + int SongOrdering[MAX_COURSE_STAGES]; + void Shuffle(); }; diff --git a/stepmania/src/MusicWheel.cpp b/stepmania/src/MusicWheel.cpp index a7b7a41570..3a5e7d8e9b 100644 --- a/stepmania/src/MusicWheel.cpp +++ b/stepmania/src/MusicWheel.cpp @@ -558,7 +558,7 @@ void MusicWheel::BuildWheelItemDatas( CArray &arr CArray apSongs; CArray apNotes; CStringArray asModifiers; - pCourse->GetSongAndNotesForCurrentStyle( apSongs, apNotes, asModifiers ); + pCourse->GetSongAndNotesForCurrentStyle( apSongs, apNotes, asModifiers, false ); if( apNotes.GetSize() > 0 ) arrayWheelItemDatas.Add( WheelItemData(TYPE_COURSE, NULL, "", pCourse, pCourse->GetColor()) ); diff --git a/stepmania/src/ScreenGameplay.cpp b/stepmania/src/ScreenGameplay.cpp index e3a5942f90..b0e8cf911c 100644 --- a/stepmania/src/ScreenGameplay.cpp +++ b/stepmania/src/ScreenGameplay.cpp @@ -131,7 +131,7 @@ ScreenGameplay::ScreenGameplay() CArray apSongs; CArray apNotes; CStringArray asModifiers; - pCourse->GetSongAndNotesForCurrentStyle( apSongs, apNotes, asModifiers ); + pCourse->GetSongAndNotesForCurrentStyle( apSongs, apNotes, asModifiers, true ); for( int i=0; i apSongs; CArray apNotes; CStringArray asModifiers; - pCourse->GetSongAndNotesForCurrentStyle( apSongs, apNotes, asModifiers ); + pCourse->GetSongAndNotesForCurrentStyle( apSongs, apNotes, asModifiers, true ); return GAMESTATE->m_iSongsIntoCourse >= apSongs.GetSize(); // there are no more songs left } @@ -480,13 +480,11 @@ void ScreenGameplay::LoadNextSong( bool bFirstLoad ) CArray apSongs; CArray apNotes; CStringArray asModifiers; - pCourse->GetSongAndNotesForCurrentStyle( apSongs, apNotes, asModifiers ); - int iPlaySongIndex = -1; - if( pCourse->m_bRandomize ) - iPlaySongIndex = rand() % apSongs.GetSize(); - else - iPlaySongIndex = GAMESTATE->m_iSongsIntoCourse; + pCourse->GetSongAndNotesForCurrentStyle( apSongs, apNotes, asModifiers, true ); + + int iPlaySongIndex = GAMESTATE->m_iSongsIntoCourse; + iPlaySongIndex %= apSongs.GetSize(); GAMESTATE->m_pCurSong = apSongs[iPlaySongIndex]; for( p=0; p