MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / playRelativeSound

Method playRelativeSound

source/sound/SoundEffectsManager.cpp:222–249  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

220}
221
222void 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
251GameSound* SoundEffectsManager::getGameSound(const std::string& filename, bool spatialSound)
252{

Callers 2

processMessageMethod · 0.80
playButtonClickSoundMethod · 0.80

Calls 3

UintFunction · 0.85
getGameValueMethod · 0.80
playMethod · 0.45

Tested by

no test coverage detected