From 5ec99947e9a372f1ad6b78ebbac5c1e5388fe63b Mon Sep 17 00:00:00 2001 From: Benau Date: Tue, 10 Aug 2021 08:46:45 +0800 Subject: [PATCH] Make some flyable sfx lower volume in splitscreen multiplayer --- src/items/bowling.cpp | 1 + src/items/flyable.cpp | 9 +++++++++ src/items/flyable.hpp | 2 ++ src/items/rubber_ball.cpp | 1 + 4 files changed, 13 insertions(+) diff --git a/src/items/bowling.cpp b/src/items/bowling.cpp index 8a2b150a9..39c28ce31 100644 --- a/src/items/bowling.cpp +++ b/src/items/bowling.cpp @@ -38,6 +38,7 @@ Bowling::Bowling(AbstractKart *kart) { m_has_hit_kart = false; m_roll_sfx = SFXManager::get()->createSoundSource("bowling_roll"); + fixSFXSplitscreen(m_roll_sfx); m_roll_sfx->play(); m_roll_sfx->setLoop(true); } // Bowling diff --git a/src/items/flyable.cpp b/src/items/flyable.cpp index 4e883db45..88e5ed3fa 100644 --- a/src/items/flyable.cpp +++ b/src/items/flyable.cpp @@ -26,6 +26,7 @@ #include #include +#include "audio/sfx_base.hpp" #include "achievements/achievements_status.hpp" #include "config/player_manager.hpp" #include "graphics/explosion.hpp" @@ -809,4 +810,12 @@ void Flyable::onDeleteFlyable() moveToInfinity(); } // onDeleteFlyable +// ---------------------------------------------------------------------------- +/* Make specifc sfx lower volume if needed in splitscreen multiplayer. */ +void Flyable::fixSFXSplitscreen(SFXBase* sfx) +{ + if (sfx && RaceManager::get()->getNumLocalPlayers() > 1) + sfx->setVolume(1.0f / (float)RaceManager::get()->getNumLocalPlayers()); +} // fixSFXSplitscreen + /* EOF */ diff --git a/src/items/flyable.hpp b/src/items/flyable.hpp index 834d05d81..e2734f60b 100644 --- a/src/items/flyable.hpp +++ b/src/items/flyable.hpp @@ -39,6 +39,7 @@ class AbstractKart; class AbstractKartAnimation; class HitEffect; class PhysicalObject; +class SFXBase; class XMLNode; /** @@ -184,6 +185,7 @@ protected: void moveToInfinity(bool set_moveable_trans = true); void removePhysics(); + void fixSFXSplitscreen(SFXBase* sfx); public: Flyable (AbstractKart* kart, diff --git a/src/items/rubber_ball.cpp b/src/items/rubber_ball.cpp index 2e2930c38..7fe9baeb0 100644 --- a/src/items/rubber_ball.cpp +++ b/src/items/rubber_ball.cpp @@ -71,6 +71,7 @@ RubberBall::RubberBall(AbstractKart *kart) m_target = NULL; m_ping_sfx = SFXManager::get()->createSoundSource("ball_bounce"); + fixSFXSplitscreen(m_ping_sfx); } // RubberBall // ----------------------------------------------------------------------------