build 170725. cab control sound support tweaks, excluded track nodes from casting shadows

This commit is contained in:
tmj-fstate
2017-07-25 18:34:24 +02:00
parent 2f1358422d
commit 000603877c
3 changed files with 18 additions and 12 deletions

View File

@@ -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();