mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
build 170725. cab control sound support tweaks, excluded track nodes from casting shadows
This commit is contained in:
19
Gauge.cpp
19
Gauge.cpp
@@ -139,8 +139,8 @@ TGauge::Load_mapping( cParser &Input ) {
|
||||
}
|
||||
else if( key.find( "sound" ) == 0 ) {
|
||||
// sounds assigned to specific gauge values, defined by key soundFoo: where Foo = value
|
||||
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 ) {
|
||||
m_soundfxvalues.emplace(
|
||||
std::stoi( key.substr( indexstart, indexend - indexstart ) ),
|
||||
@@ -180,17 +180,20 @@ void TGauge::DecValue(double fNewDesired)
|
||||
void
|
||||
TGauge::UpdateValue( double fNewDesired, PSound Fallbacksound ) {
|
||||
|
||||
if( static_cast<int>( std::round( 100.0 * ( fDesiredValue - fOffset ) / fScale ) ) == static_cast<int>( 100.0 * fNewDesired ) ) {
|
||||
auto const desiredtimes100 = static_cast<int>( 100.0 * fNewDesired );
|
||||
if( static_cast<int>( std::round( 100.0 * ( fDesiredValue - fOffset ) / fScale ) ) == desiredtimes100 ) {
|
||||
return;
|
||||
}
|
||||
fDesiredValue = fNewDesired * fScale + fOffset;
|
||||
// if there's any sound associated with new requested value, play it
|
||||
// check value-specific table first...
|
||||
auto const desiredvalue = static_cast<int>( std::round( fNewDesired ) );
|
||||
auto const lookup = m_soundfxvalues.find( desiredvalue );
|
||||
if( lookup != m_soundfxvalues.end() ) {
|
||||
play( lookup->second );
|
||||
return;
|
||||
if( desiredtimes100 % 100 == 0 ) {
|
||||
// filter out values other than full integers
|
||||
auto const lookup = m_soundfxvalues.find( desiredtimes100 / 100 );
|
||||
if( lookup != m_soundfxvalues.end() ) {
|
||||
play( lookup->second );
|
||||
return;
|
||||
}
|
||||
}
|
||||
// ...and if there isn't any, fall back on the basic set...
|
||||
auto const currentvalue = GetValue();
|
||||
|
||||
Reference in New Issue
Block a user