void CBackgroundSound::getSubSoundList(std::vector<std::pair<std::string, CSound*> > &subsounds) const { CAudioMixerUser *mixer = CAudioMixerUser::instance(); std::vector<TSoundInfo>::const_iterator first(_Sounds.begin()), last(_Sounds.end()); for (; first != last; ++first) { CSound *sound = mixer->getSoundId(first->SoundName); subsounds.push_back(make_pair(CStringMapper::unmap(first->SoundName), sound)); } }
float CBackgroundSound::getMaxDistance() const { CAudioMixerUser *mixer = CAudioMixerUser::instance(); float ret = 0.0f; std::vector<TSoundInfo>::const_iterator first(_Sounds.begin()), last(_Sounds.end()); for (; first != last; ++first) { CSound *sound = mixer->getSoundId(first->SoundName); if (sound != 0) { ret = max(ret, sound->getMaxDistance()); } } if (ret == 0) ret = 1; return ret; }
uint32 CBackgroundSound::getDuration() { if (_DurationValid) return _Duration; vector<sint32> durations; CAudioMixerUser *mixer = CAudioMixerUser::instance(); std::vector<TSoundInfo>::const_iterator first(_Sounds.begin()), last(_Sounds.end()); for (; first != last; ++first) { CSound *sound = mixer->getSoundId(first->SoundName); if (sound != NULL) durations.push_back(sound->getDuration()); } if (durations.empty()) return 0; _Duration = *(std::max_element(durations.begin(), durations.end())); _DurationValid = true; return _Duration; }