mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-20 10:19:19 +02:00
maintenance: settings item refactoring, include dependencies fixes
This commit is contained in:
27
sound.cpp
27
sound.cpp
@@ -14,6 +14,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "globals.h"
|
||||
#include "world.h"
|
||||
#include "train.h"
|
||||
#include "dynobj.h"
|
||||
|
||||
// constructors
|
||||
sound_source::sound_source( sound_placement const Placement, float const Range ) :
|
||||
@@ -154,7 +155,7 @@ sound_source::deserialize_filename( cParser &Input ) {
|
||||
filenames.emplace_back( token );
|
||||
}
|
||||
if( false == filenames.empty() ) {
|
||||
std::shuffle( std::begin( filenames ), std::end( filenames ), Global::random_engine );
|
||||
std::shuffle( std::begin( filenames ), std::end( filenames ), Global.random_engine );
|
||||
return filenames.front();
|
||||
}
|
||||
else {
|
||||
@@ -279,7 +280,7 @@ sound_source::deserialize_soundset( cParser &Input ) {
|
||||
soundsets.emplace_back( token );
|
||||
}
|
||||
if( false == soundsets.empty() ) {
|
||||
std::shuffle( std::begin( soundsets ), std::end( soundsets ), Global::random_engine );
|
||||
std::shuffle( std::begin( soundsets ), std::end( soundsets ), Global.random_engine );
|
||||
return deserialize_soundset( cParser( soundsets.front() ) );
|
||||
}
|
||||
}
|
||||
@@ -300,7 +301,7 @@ sound_source::copy_sounds( sound_source const &Source ) {
|
||||
void
|
||||
sound_source::play( int const Flags ) {
|
||||
|
||||
if( ( false == Global::bSoundEnabled )
|
||||
if( ( false == Global.bSoundEnabled )
|
||||
|| ( true == empty() ) ) {
|
||||
// if the sound is disabled altogether or nothing can be emitted from this source, no point wasting time
|
||||
return;
|
||||
@@ -311,7 +312,7 @@ sound_source::play( int const Flags ) {
|
||||
|
||||
if( m_range > 0 ) {
|
||||
auto const cutoffrange { m_range * 5 };
|
||||
if( glm::length2( location() - glm::dvec3 { Global::pCameraPosition } ) > std::min( 2750.f * 2750.f, cutoffrange * cutoffrange ) ) {
|
||||
if( glm::length2( location() - glm::dvec3 { Global.pCameraPosition } ) > std::min( 2750.f * 2750.f, cutoffrange * cutoffrange ) ) {
|
||||
// while we drop sounds from beyond sensible and/or audible range
|
||||
// we act as if it was activated normally, meaning no need to include the opening bookend in subsequent calls
|
||||
m_playbeginning = false;
|
||||
@@ -825,17 +826,17 @@ sound_source::update_soundproofing() {
|
||||
// NOTE, HACK: current cab id can vary from -1 to +1, and we use another higher priority value for open cab window
|
||||
// we use this as modifier to force re-calculations when moving between compartments or changing window state
|
||||
int const activecab = (
|
||||
Global::CabWindowOpen ? 2 :
|
||||
Global.CabWindowOpen ? 2 :
|
||||
FreeFlyModeFlag ? 0 :
|
||||
( Global::pWorld->train() ?
|
||||
Global::pWorld->train()->Dynamic()->MoverParameters->ActiveCab :
|
||||
( Global.pWorld->train() ?
|
||||
Global.pWorld->train()->Dynamic()->MoverParameters->ActiveCab :
|
||||
0 ) );
|
||||
// location-based gain factor:
|
||||
std::uintptr_t soundproofingstamp = reinterpret_cast<std::uintptr_t>( (
|
||||
FreeFlyModeFlag ?
|
||||
nullptr :
|
||||
( Global::pWorld->train() ?
|
||||
Global::pWorld->train()->Dynamic() :
|
||||
( Global.pWorld->train() ?
|
||||
Global.pWorld->train()->Dynamic() :
|
||||
nullptr ) ) )
|
||||
+ activecab;
|
||||
|
||||
@@ -849,7 +850,7 @@ sound_source::update_soundproofing() {
|
||||
}
|
||||
case sound_placement::external: {
|
||||
m_properties.soundproofing = (
|
||||
( ( soundproofingstamp == 0 ) || ( true == Global::CabWindowOpen ) ) ?
|
||||
( ( soundproofingstamp == 0 ) || ( true == Global.CabWindowOpen ) ) ?
|
||||
EU07_SOUNDPROOFING_NONE : // listener outside or has a window open
|
||||
EU07_SOUNDPROOFING_STRONG ); // listener in a vehicle with windows shut
|
||||
break;
|
||||
@@ -858,7 +859,7 @@ sound_source::update_soundproofing() {
|
||||
m_properties.soundproofing = (
|
||||
soundproofingstamp == 0 ?
|
||||
EU07_SOUNDPROOFING_STRONG : // listener outside HACK: won't be true if active vehicle has open window
|
||||
( Global::pWorld->train()->Dynamic() != m_owner ?
|
||||
( Global.pWorld->train()->Dynamic() != m_owner ?
|
||||
EU07_SOUNDPROOFING_STRONG : // in another vehicle
|
||||
( activecab == 0 ?
|
||||
EU07_SOUNDPROOFING_STRONG : // listener in the engine compartment
|
||||
@@ -867,9 +868,9 @@ sound_source::update_soundproofing() {
|
||||
}
|
||||
case sound_placement::engine: {
|
||||
m_properties.soundproofing = (
|
||||
( ( soundproofingstamp == 0 ) || ( true == Global::CabWindowOpen ) ) ?
|
||||
( ( soundproofingstamp == 0 ) || ( true == Global.CabWindowOpen ) ) ?
|
||||
EU07_SOUNDPROOFING_SOME : // listener outside or has a window open
|
||||
( Global::pWorld->train()->Dynamic() != m_owner ?
|
||||
( Global.pWorld->train()->Dynamic() != m_owner ?
|
||||
EU07_SOUNDPROOFING_STRONG : // in another vehicle
|
||||
( activecab == 0 ?
|
||||
EU07_SOUNDPROOFING_NONE : // listener in the engine compartment
|
||||
|
||||
Reference in New Issue
Block a user