* Change the configured sound set and reset sounds. * @param index Index of sound set to switch to. */
| 165 | * @param index Index of sound set to switch to. |
| 166 | */ |
| 167 | void ChangeSoundSet(int index) |
| 168 | { |
| 169 | if (BaseSounds::GetIndexOfUsedSet() == index) return; |
| 170 | |
| 171 | auto set = BaseSounds::GetSet(index); |
| 172 | BaseSounds::ini_set = set->name; |
| 173 | BaseSounds::SetSet(set); |
| 174 | |
| 175 | MxCloseAllChannels(); |
| 176 | InitializeSound(); |
| 177 | |
| 178 | /* Replace baseset sounds in the pool with the updated original sounds. This is safe to do as |
| 179 | * any sound still playing holds its own shared_ptr to the sample data. */ |
| 180 | for (uint i = 0; i < ORIGINAL_SAMPLE_COUNT; i++) { |
| 181 | SoundEntry *sound = GetSound(i); |
| 182 | /* GRF Container 0 means the sound comes from the baseset, and isn't overridden by NewGRF. */ |
| 183 | if (sound == nullptr || sound->grf_container_ver != 0) continue; |
| 184 | |
| 185 | *sound = _original_sounds[_sound_idx[i]]; |
| 186 | sound->volume = _sound_base_vol[i]; |
| 187 | sound->priority = 0; |
| 188 | } |
| 189 | |
| 190 | InvalidateWindowData(WC_GAME_OPTIONS, WN_GAME_OPTIONS_GAME_OPTIONS, 0, true); |
| 191 | } |
| 192 | |
| 193 | /** |
| 194 | * Decide 'where' (between left and right speaker) to play the sound effect. |
no test coverage detected