From 452c4835d354f7c2faa907c34bc67ce6500ecae6 Mon Sep 17 00:00:00 2001 From: auria Date: Sun, 6 Mar 2011 23:39:55 +0000 Subject: [PATCH] Try better volume reduction in multiplayer git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@7837 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/karts/kart.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/karts/kart.cpp b/src/karts/kart.cpp index e84b76495..fe7fce991 100644 --- a/src/karts/kart.cpp +++ b/src/karts/kart.cpp @@ -327,7 +327,24 @@ void Kart::startEngineSFX() { // in multiplayer mode, sounds are NOT positional (because we have multiple listeners) // so the engine sounds of all AIs is constantly heard. So reduce volume of all sounds. - m_engine_sound->volume( 1.0f / race_manager->getNumberOfKarts() ); + if (race_manager->getNumLocalPlayers() > 1) + { + const int np = race_manager->getNumLocalPlayers(); + const int nai = race_manager->getNumberOfKarts() - np; + + // player karts twice as loud as AIs toghether + const float players_volume = (np * 2.0f) / (np*2.0f + np); + + if (m_controller->isPlayerController()) + { + m_engine_sound->volume( players_volume / np ); + } + else + { + m_engine_sound->volume( (1.0f - players_volume) / nai ); + } + } + m_engine_sound->speed(0.6f); m_engine_sound->setLoop(true); m_engine_sound->play();