diff --git a/src/include/DataModelV2/SoundService.h b/src/include/DataModelV2/SoundService.h index 62b1ae5..9063438 100644 --- a/src/include/DataModelV2/SoundService.h +++ b/src/include/DataModelV2/SoundService.h @@ -10,7 +10,7 @@ public: ~SoundService(void); float getMusicVolume(); - void playSound(SoundInstance* sound); + void playSound(Instance* sound); private: float musicVolume; }; diff --git a/src/source/DataModelV2/PartInstance.cpp b/src/source/DataModelV2/PartInstance.cpp index a38bbec..8fb5837 100644 --- a/src/source/DataModelV2/PartInstance.cpp +++ b/src/source/DataModelV2/PartInstance.cpp @@ -525,10 +525,10 @@ void PartInstance::onTouch() case Enum::Sound::NoSound: break; case Enum::Sound::Victory: - sndService->playSound(dynamic_cast(sndService->findFirstChild("Victory"))); + sndService->playSound(sndService->findFirstChild("Victory")); break; case Enum::Sound::Boing: - sndService->playSound(dynamic_cast(sndService->findFirstChild("Boing"))); + sndService->playSound(sndService->findFirstChild("Boing")); break; } } diff --git a/src/source/DataModelV2/SoundService.cpp b/src/source/DataModelV2/SoundService.cpp index 17c9ffd..46662d4 100644 --- a/src/source/DataModelV2/SoundService.cpp +++ b/src/source/DataModelV2/SoundService.cpp @@ -71,10 +71,15 @@ SoundService::~SoundService(void) { } -void SoundService::playSound(SoundInstance* sound) +void SoundService::playSound(Instance* sound) { - std::string soundId = sound->getSoundId(); - AudioPlayer::playSound(GetFileInPath(soundId)); + // Try to dynamic_cast it to SoundInstance + SoundInstance* sndInst = dynamic_cast(sound); + if(sndInst != NULL) + { + std::string soundId = sndInst->getSoundId(); + AudioPlayer::playSound(GetFileInPath(soundId)); + } } float SoundService::getMusicVolume()