diff --git a/stepmania/src/MusicWheel.cpp b/stepmania/src/MusicWheel.cpp index a61c12a4b1..3d5e924c01 100644 --- a/stepmania/src/MusicWheel.cpp +++ b/stepmania/src/MusicWheel.cpp @@ -1230,23 +1230,21 @@ void MusicWheel::StartRoulette() void MusicWheel::StartRandom() { /* Shuffle the roulette wheel. */ - //unsigned total = m_WheelItemDatas[SORT_ROULETTE].size(); - //for(unsigned i = 0; i < total; ++i) - // swap(m_WheelItemDatas[SORT_ROULETTE][i], m_WheelItemDatas[SORT_ROULETTE][rand() % total]); + /*Linear shuffle means that we shuffle the deck from the beginning to end, + but never switch a song from the end with one < i. This method gives an + even distribution for any number of songs less than RAND_MAX.*/ + unsigned total = m_WheelItemDatas[SORT_ROULETTE].size(); + for(unsigned i = 0; i < total; ++i) + swap(m_WheelItemDatas[SORT_ROULETTE][i], m_WheelItemDatas[SORT_ROULETTE][(rand() % (total-i))+i]); - //SetOpenGroup("", SongSortOrder(SORT_ROULETTE)); + SetOpenGroup("", SongSortOrder(SORT_ROULETTE)); - //m_Moving = -1; - //m_TimeBeforeMovingBegins = 0; - //m_SpinSpeed = 1.0f/ROULETTE_SWITCH_SECONDS; - //m_SpinSpeed *= 20.0f; /* faster! */ - - - //Simplify Random to make it more random than previously + m_Moving = -1; + m_TimeBeforeMovingBegins = 0; + m_SpinSpeed = 1.0f/ROULETTE_SWITCH_SECONDS; + m_SpinSpeed *= 20.0f; /* faster! */ m_WheelState = STATE_RANDOM_SPINNING; - SelectSong(SONGMAN->GetRandomSong()); - this->Select(); RebuildMusicWheelItems(); }