From 1ba9d97ab7b56a4628dfd7672d1738ddc3ad646d Mon Sep 17 00:00:00 2001 From: stiffly Date: Wed, 10 Feb 2016 17:17:41 +0100 Subject: [PATCH] Fixed crash when trying to jump, when no player is spawned. --- src/Game/Systems/SoundSystem.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Game/Systems/SoundSystem.cpp b/src/Game/Systems/SoundSystem.cpp index acb7501c..e3aa49b2 100644 --- a/src/Game/Systems/SoundSystem.cpp +++ b/src/Game/Systems/SoundSystem.cpp @@ -25,7 +25,7 @@ void SoundSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& cComp void SoundSystem::Update(double dt) { // Temp for play test. - if(m_DrumsIsPlaying) { + if (m_DrumsIsPlaying) { m_DrumsIsPlaying = !drumTimer(dt); } } @@ -69,6 +69,9 @@ bool SoundSystem::OnInputCommand(const Events::InputCommand & e) void SoundSystem::playerJumps() { + if (!m_LocalPlayer.Valid()) { + return; + } bool grounded = (bool)m_World->GetComponent(m_LocalPlayer.ID, "Physics")["IsOnGround"]; if (grounded) { Events::PlaySoundOnEntity e; @@ -124,11 +127,11 @@ bool SoundSystem::OnPlayerDamage(const Events::PlayerDamage & e) std::vector paths; paths.push_back("Audio/hurt/hurt" + std::to_string(rand) + ".wav"); -// // Breathe -// int ammountOfbreaths = (static_cast(e.Damage) / 10) + 2; // TEMP: Idk something stupid like this shit -// for (int i = 0; i < ammountOfbreaths; i++) { -// paths.push_back("Audio/exhausted/breath.wav"); -// } + // // Breathe + // int ammountOfbreaths = (static_cast(e.Damage) / 10) + 2; // TEMP: Idk something stupid like this shit + // for (int i = 0; i < ammountOfbreaths; i++) { + // paths.push_back("Audio/exhausted/breath.wav"); + // } Events::PlayQueueOnEntity ev; ev.Emitter = m_LocalPlayer; ev.FilePaths = paths; @@ -140,7 +143,7 @@ bool SoundSystem::OnPlayerDeath(const Events::PlayerDeath & e) { Events::PlaySoundOnEntity ev; ev.EmitterID = m_LocalPlayer.ID; - ev.FilePath = "Audio/die/die2.wav"; + ev.FilePath = "Audio/die/die2.wav"; m_EventBroker->Publish(ev); return false; }