diff --git a/Train.cpp b/Train.cpp index 1478b233..52706d63 100644 --- a/Train.cpp +++ b/Train.cpp @@ -7200,8 +7200,6 @@ bool TTrain::Update( double const Deltatime ) void TTrain::update_sounds( double const Deltatime ) { - if( Deltatime == 0.0 ) { return; } - double volume { 0.0 }; double const brakevolumescale { 0.5 }; @@ -7383,6 +7381,15 @@ TTrain::update_sounds( double const Deltatime ) { // don't play the optional ending sound if the listener switches views rsHuntingNoise.stop( true == FreeFlyModeFlag ); } + // rain sound + if( ( false == FreeFlyModeFlag ) + && ( false == Global.CabWindowOpen ) + && ( Global.Weather == "rain:" ) ) { + m_precipitationsound.play( sound_flags::exclusive | sound_flags::looping ); + } + else { + m_precipitationsound.stop(); + } if( fTachoCount >= 3.f ) { auto const frequency { ( @@ -7720,6 +7727,11 @@ bool TTrain::LoadMMediaFile(std::string const &asFileName) // rsHuntingNoise.m_amplitudefactor /= ( 1 + mvOccupied->Vmax ); rsHuntingNoise.m_frequencyfactor /= ( 1 + mvOccupied->Vmax ); } + else if( token == "rainsound:" ) { + // precipitation sound: + m_precipitationsound.deserialize( parser, sound_type::single ); + m_precipitationsound.owner( DynamicObject ); + } } while (token != ""); } @@ -8030,6 +8042,11 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName) if (DynamicObject->mdKabina) { */ + // assign default samples to sound emitters which weren't included in the config file + if( m_precipitationsound.empty() ) { + m_precipitationsound.deserialize( "rainsound_default", sound_type::single ); + m_precipitationsound.owner( DynamicObject ); + } // configure placement of sound emitters which aren't bound with any device model, and weren't placed manually // try first to bind sounds to location of possible devices if( dsbReverserKey.offset() == nullvector ) { diff --git a/Train.h b/Train.h index cdcab87d..fb2a52f3 100644 --- a/Train.h +++ b/Train.h @@ -726,6 +726,7 @@ public: // reszta może by?publiczna sound_source rsFadeSound { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE }; sound_source rsRunningNoise{ sound_placement::internal, EU07_SOUND_GLOBALRANGE }; sound_source rsHuntingNoise{ sound_placement::internal, EU07_SOUND_GLOBALRANGE }; + sound_source m_precipitationsound { sound_placement::internal, -1 }; sound_source dsbHasler { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE }; sound_source dsbBuzzer { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE }; diff --git a/simulationenvironment.cpp b/simulationenvironment.cpp index 5948021a..9ce38353 100644 --- a/simulationenvironment.cpp +++ b/simulationenvironment.cpp @@ -179,7 +179,8 @@ world_environment::update() { "day:" : "night:" ); - if( Global.Weather == "rain:" ) { + if( ( true == ( FreeFlyModeFlag || Global.CabWindowOpen ) ) + && ( Global.Weather == "rain:" ) ) { m_precipitationsound.play( sound_flags::exclusive | sound_flags::looping ); } else { diff --git a/version.h b/version.h index 3b53185c..30aad5ad 100644 --- a/version.h +++ b/version.h @@ -1,5 +1,5 @@ #pragma once #define VERSION_MAJOR 20 -#define VERSION_MINOR 709 +#define VERSION_MINOR 711 #define VERSION_REVISION 0