| 220 | } |
| 221 | |
| 222 | void SoundEffectsManager::playRelativeSound(const std::string& family) |
| 223 | { |
| 224 | // We search for the selected sound in the currently selected voice group. If we cannot |
| 225 | // find it, we fall down to the default group. That allows to create new voice groups that |
| 226 | // do not have to have sound for every event |
| 227 | std::string keeperVoice = ConfigManager::getSingleton().getGameValue(Config::KEEPERVOICE); |
| 228 | auto it = mRelativeSounds.find(keeperVoice + "/" + family); |
| 229 | if(it == mRelativeSounds.end()) |
| 230 | { |
| 231 | it = mRelativeSounds.find(ConfigManager::DEFAULT_KEEPER_VOICE + "/" + family); |
| 232 | if(it == mRelativeSounds.end()) |
| 233 | { |
| 234 | OD_LOG_ERR("Couldn't find sound family=" + family); |
| 235 | return; |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | std::vector<GameSound*>& sounds = it->second; |
| 240 | if(sounds.empty()) |
| 241 | return; |
| 242 | |
| 243 | unsigned int soundId = Random::Uint(0, sounds.size() - 1); |
| 244 | GameSound* sound = sounds[soundId]; |
| 245 | if(mRelativeSoundQueue.empty()) |
| 246 | sound->play(); |
| 247 | |
| 248 | mRelativeSoundQueue.push_back(sound); |
| 249 | } |
| 250 | |
| 251 | GameSound* SoundEffectsManager::getGameSound(const std::string& filename, bool spatialSound) |
| 252 | { |
no test coverage detected