mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-18 03:09:18 +02:00
build 210424. soundproofing enhancement, battery sound, heating command propagation, memory cell command retrieval logic enhancement, coupling mode logic enhancement, motor overload relay threshold cab control animation fix, cab control fallback sound activation fixes,
This commit is contained in:
39
sound.cpp
39
sound.cpp
@@ -171,10 +171,23 @@ sound_source::deserialize_mapping( cParser &Input ) {
|
||||
else if( key == "soundend:" ) {
|
||||
sound( sound_id::end ).buffer = audio::renderer.fetch_buffer( deserialize_random_set( Input, "\n\r\t ,;" ) );
|
||||
}
|
||||
else if( key.compare( 0, std::min<std::size_t>( key.size(), 5 ), "sound" ) == 0 ) {
|
||||
else if( key == "soundproofing:" ) {
|
||||
// custom soundproofing in format [ p1, p2, p3, p4, p5, p6 ]
|
||||
Input.getTokens( 6, false, "\n\r\t ,;[]" );
|
||||
std::array<float, 6> soundproofing;
|
||||
Input
|
||||
>> soundproofing[ 0 ]
|
||||
>> soundproofing[ 1 ]
|
||||
>> soundproofing[ 2 ]
|
||||
>> soundproofing[ 3 ]
|
||||
>> soundproofing[ 4 ]
|
||||
>> soundproofing[ 5 ];
|
||||
m_soundproofing = soundproofing;
|
||||
}
|
||||
else if( starts_with( key, "sound" ) ) {
|
||||
// sound chunks, defined with key soundX where X = activation threshold
|
||||
auto const indexstart { key.find_first_of( "1234567890" ) };
|
||||
auto const indexend { key.find_first_not_of( "1234567890", indexstart ) };
|
||||
auto const indexstart { key.find_first_of( "-1234567890" ) };
|
||||
auto const indexend { key.find_first_not_of( "-1234567890", indexstart ) };
|
||||
if( indexstart != std::string::npos ) {
|
||||
// NOTE: we'll sort the chunks at the end of deserialization
|
||||
m_soundchunks.emplace_back(
|
||||
@@ -202,10 +215,10 @@ sound_source::deserialize_mapping( cParser &Input ) {
|
||||
Input.getToken<float>( false, "\n\r\t ,;" ),
|
||||
0.0f, 1.0f );
|
||||
}
|
||||
else if( key.compare( 0, std::min<std::size_t>( key.size(), 5 ), "pitch" ) == 0 ) {
|
||||
else if( starts_with( key, "pitch" ) ) {
|
||||
// sound chunk pitch, defined with key pitchX where X = activation threshold
|
||||
auto const indexstart { key.find_first_of( "1234567890" ) };
|
||||
auto const indexend { key.find_first_not_of( "1234567890", indexstart ) };
|
||||
auto const indexstart { key.find_first_of( "-1234567890" ) };
|
||||
auto const indexend { key.find_first_not_of( "-1234567890", indexstart ) };
|
||||
if( indexstart != std::string::npos ) {
|
||||
auto const index { std::stoi( key.substr( indexstart, indexend - indexstart ) ) };
|
||||
auto const pitch { Input.getToken<float>( false, "\n\r\t ,;" ) };
|
||||
@@ -962,12 +975,14 @@ sound_source::update_soundproofing() {
|
||||
auto const isambient { ( ( m_placement == sound_placement::external ) && ( m_owner == nullptr ) && ( m_range < -1 ) ? 1 : 0 ) };
|
||||
auto const placement { ( isambient ? sound_placement::external_ambient : m_placement ) };
|
||||
if( m_owner != nullptr ) {
|
||||
m_properties.soundproofing =
|
||||
m_owner->soundproofing(
|
||||
static_cast<int>( placement ),
|
||||
( m_owner != listenervehicle ?
|
||||
4 : // part of two-stage calculation owner->outside->listener, or single stage owner->outside one
|
||||
occupiedcab ) );
|
||||
auto const listenerlocation { (
|
||||
m_owner != listenervehicle ?
|
||||
4 : // part of two-stage calculation owner->outside->listener, or single stage owner->outside one
|
||||
occupiedcab ) };
|
||||
m_properties.soundproofing = (
|
||||
m_soundproofing ? // custom soundproofing has higher priority than that of the owner
|
||||
m_soundproofing.value()[ listenerlocation + 1 ] : // cab indices start from -1 so we have to account for this
|
||||
m_owner->soundproofing( static_cast<int>( placement ), listenerlocation ) );
|
||||
}
|
||||
if( ( listenervehicle ) && ( listenervehicle != m_owner ) ) {
|
||||
// if the listener is located in another vehicle, calculate additional proofing of the sound coming from outside
|
||||
|
||||
Reference in New Issue
Block a user