@@ -128,77 +128,79 @@ SoundContainer& DynamicSongSection::SelectTransitionSoundContainer() {
128
128
if (m_TransitionSoundContainers.empty ()) {
129
129
return SelectSoundContainer ();
130
130
}
131
- if (m_TransitionSoundContainers.size () == 1 ) {
132
- return m_TransitionSoundContainers[0 ];
133
- }
134
131
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
- }
140
- }
141
- }
142
-
143
- switch (m_SoundContainerSelectionCycleMode) {
144
- case RANDOMNOREPEAT: {
145
- std::vector<unsigned int > validIndices;
132
+ // Shuffle between our options if we have multiple
133
+ if (m_TransitionSoundContainers.size () > 1 ) {
134
+ if (m_TransitionShuffleUnplayedIndices.empty ()) {
146
135
for (unsigned int i = 0 ; i < m_TransitionSoundContainers.size (); i++) {
147
136
if (i != m_LastTransitionSoundContainerIndex) {
148
- validIndices .push_back (i);
137
+ m_TransitionShuffleUnplayedIndices .push_back (i);
149
138
}
150
139
}
151
-
152
- unsigned int randomIndex = validIndices[RandomNum (0 , static_cast <int >(validIndices.size ()) - 1 )];
153
- m_LastTransitionSoundContainerIndex = randomIndex;
154
- return m_TransitionSoundContainers[randomIndex];
155
- }
156
- case SHUFFLE: {
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;
161
- return m_TransitionSoundContainers[selectedIndex];
162
140
}
163
- }
164
- }
165
-
166
- SoundContainer& DynamicSongSection::SelectSoundContainer () {
167
- RTEAssert (!m_SoundContainers.empty (), " Tried to get a SoundContainer from a DynamicSongSection with none to choose from!" );
168
141
169
- if (m_SoundContainers.size () == 1 ) {
170
- return m_SoundContainers[0 ];
171
- }
142
+ switch (m_SoundContainerSelectionCycleMode) {
143
+ case RANDOMNOREPEAT: {
144
+ std::vector<unsigned int > validIndices;
145
+ for (unsigned int i = 0 ; i < m_TransitionSoundContainers.size (); i++) {
146
+ if (i != m_LastTransitionSoundContainerIndex) {
147
+ validIndices.push_back (i);
148
+ }
149
+ }
172
150
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);
151
+ unsigned int randomIndex = validIndices[RandomNum (0 , static_cast <int >(validIndices.size ()) - 1 )];
152
+ m_LastTransitionSoundContainerIndex = randomIndex;
153
+ return m_TransitionSoundContainers[randomIndex];
154
+ }
155
+ case SHUFFLE: {
156
+ unsigned int randomSelection = RandomNum (0 , static_cast <int >(m_TransitionShuffleUnplayedIndices.size () - 1 ));
157
+ unsigned int selectedIndex = m_TransitionShuffleUnplayedIndices[randomSelection];
158
+ m_TransitionShuffleUnplayedIndices.erase (m_TransitionShuffleUnplayedIndices.begin () + randomSelection);
159
+ m_LastTransitionSoundContainerIndex = selectedIndex;
160
+ return m_TransitionSoundContainers[selectedIndex];
177
161
}
178
162
}
179
163
}
180
164
181
- switch (m_SoundContainerSelectionCycleMode) {
182
- case RANDOMNOREPEAT: {
183
- std::vector<unsigned int > validIndices;
165
+ return m_TransitionSoundContainers[0 ];
166
+ }
167
+
168
+ SoundContainer& DynamicSongSection::SelectSoundContainer () {
169
+ // Shuffle between our options if we have multiple
170
+ if (m_SoundContainers.size () != 1 ) {
171
+ if (m_ShuffleUnplayedIndices.empty ()) {
184
172
for (unsigned int i = 0 ; i < m_SoundContainers.size (); i++) {
185
173
if (i != m_LastSoundContainerIndex) {
186
- validIndices .push_back (i);
174
+ m_ShuffleUnplayedIndices .push_back (i);
187
175
}
188
176
}
189
-
190
- unsigned int randomIndex = validIndices[RandomNum (0 , static_cast <int >(validIndices.size ()) - 1 )];
191
- m_LastSoundContainerIndex = randomIndex;
192
- return m_SoundContainers[randomIndex];
193
177
}
194
- case SHUFFLE: {
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;
199
- return m_SoundContainers[selectedIndex];
178
+
179
+ switch (m_SoundContainerSelectionCycleMode) {
180
+ case RANDOMNOREPEAT: {
181
+ std::vector<unsigned int > validIndices;
182
+ for (unsigned int i = 0 ; i < m_SoundContainers.size (); i++) {
183
+ if (i != m_LastSoundContainerIndex) {
184
+ validIndices.push_back (i);
185
+ }
186
+ }
187
+
188
+ unsigned int randomIndex = validIndices[RandomNum (0 , static_cast <int >(validIndices.size ()) - 1 )];
189
+ m_LastSoundContainerIndex = randomIndex;
190
+ return m_SoundContainers[randomIndex];
191
+ }
192
+ case SHUFFLE: {
193
+ unsigned int randomSelection = RandomNum (0 , static_cast <int >(m_ShuffleUnplayedIndices.size () - 1 ));
194
+ unsigned int selectedIndex = m_ShuffleUnplayedIndices[randomSelection];
195
+ m_ShuffleUnplayedIndices.erase (m_ShuffleUnplayedIndices.begin () + randomSelection);
196
+ m_LastSoundContainerIndex = selectedIndex;
197
+ return m_SoundContainers[selectedIndex];
198
+ }
200
199
}
201
200
}
201
+
202
+ RTEAssert (!m_SoundContainers.empty (), " Tried to get a SoundContainer from a DynamicSongSection with none to choose from!" );
203
+ return m_SoundContainers[0 ];
202
204
}
203
205
204
206
DynamicSong::DynamicSong () {
0 commit comments