@@ -25,11 +25,11 @@ DynamicSongSection::~DynamicSongSection() {
25
25
void DynamicSongSection::Clear () {
26
26
m_TransitionSoundContainers.clear ();
27
27
m_LastTransitionSoundContainerIndex = -1 ;
28
- m_TransitionShuffleIndices .clear ();
28
+ m_TransitionShuffleUnplayedIndices .clear ();
29
29
30
30
m_SoundContainers.clear ();
31
31
m_LastSoundContainerIndex = -1 ;
32
- m_ShuffleIndices .clear ();
32
+ m_ShuffleUnplayedIndices .clear ();
33
33
34
34
m_SoundContainerSelectionCycleMode = RANDOMNOREPEAT;
35
35
m_SectionType = " Default" ;
@@ -131,10 +131,12 @@ SoundContainer& DynamicSongSection::SelectTransitionSoundContainer() {
131
131
if (m_TransitionSoundContainers.size () == 1 ) {
132
132
return m_TransitionSoundContainers[0 ];
133
133
}
134
-
135
- if (m_TransitionShuffleIndices.empty ()) {
136
- for (unsigned int i = 0 ; i <= m_TransitionSoundContainers.size () - 1 ; i++ ) {
137
- m_TransitionShuffleIndices.push_back (i);
134
+
135
+ if (m_TransitionShuffleUnplayedIndices.empty ()) {
136
+ for (unsigned int i = 0 ; i < m_TransitionSoundContainers.size (); i++ ) {
137
+ if (i != m_LastTransitionSoundContainerIndex) {
138
+ m_TransitionShuffleUnplayedIndices.push_back (i);
139
+ }
138
140
}
139
141
}
140
142
@@ -152,8 +154,10 @@ SoundContainer& DynamicSongSection::SelectTransitionSoundContainer() {
152
154
return m_TransitionSoundContainers[randomIndex];
153
155
}
154
156
case SHUFFLE: {
155
- unsigned int selectedIndex = m_TransitionShuffleIndices[RandomNum (0 , static_cast <int >(m_TransitionShuffleIndices.size ()) - 1 )];
156
- m_TransitionShuffleIndices.erase (m_TransitionShuffleIndices.begin () + selectedIndex);
157
+ unsigned int randomSelection = RandomNum (0 , static_cast <int >(m_TransitionShuffleUnplayedIndices.size () - 1 ));
158
+ unsigned int selectedIndex = m_TransitionShuffleUnplayedIndices[randomSelection];
159
+ m_TransitionShuffleUnplayedIndices.erase (m_TransitionShuffleUnplayedIndices.begin () + randomSelection);
160
+ m_LastTransitionSoundContainerIndex = selectedIndex;
157
161
return m_TransitionSoundContainers[selectedIndex];
158
162
}
159
163
}
@@ -166,9 +170,11 @@ SoundContainer& DynamicSongSection::SelectSoundContainer() {
166
170
return m_SoundContainers[0 ];
167
171
}
168
172
169
- if (m_ShuffleIndices.empty ()) {
170
- for (unsigned int i = 0 ; i <= m_SoundContainers.size () - 1 ; i++ ) {
171
- m_ShuffleIndices.push_back (i);
173
+ if (m_ShuffleUnplayedIndices.empty ()) {
174
+ for (unsigned int i = 0 ; i < m_SoundContainers.size (); i++ ) {
175
+ if (i != m_LastSoundContainerIndex) {
176
+ m_ShuffleUnplayedIndices.push_back (i);
177
+ }
172
178
}
173
179
}
174
180
@@ -186,8 +192,10 @@ SoundContainer& DynamicSongSection::SelectSoundContainer() {
186
192
return m_SoundContainers[randomIndex];
187
193
}
188
194
case SHUFFLE: {
189
- unsigned int selectedIndex = m_ShuffleIndices[RandomNum (0 , static_cast <int >(m_ShuffleIndices.size ()) - 1 )];
190
- m_ShuffleIndices.erase (m_ShuffleIndices.begin () + selectedIndex);
195
+ unsigned int randomSelection = RandomNum (0 , static_cast <int >(m_ShuffleUnplayedIndices.size () - 1 ));
196
+ unsigned int selectedIndex = m_ShuffleUnplayedIndices[randomSelection];
197
+ m_ShuffleUnplayedIndices.erase (m_ShuffleUnplayedIndices.begin () + randomSelection);
198
+ m_LastSoundContainerIndex = selectedIndex;
191
199
return m_SoundContainers[selectedIndex];
192
200
}
193
201
}
0 commit comments