diff --git a/Driver.cpp b/Driver.cpp index b4831bf3..11a954d3 100644 --- a/Driver.cpp +++ b/Driver.cpp @@ -976,6 +976,18 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN sSpeedTable[i].iFlags = 0; } } + // for human-driven vehicles discard the stop point if they leave it far enough behind + if( ( false == AIControllFlag ) + && ( sSpeedTable[ i ].fDist < -1 * std::max( fLength + 100, 250.0 ) ) ) { + sSpeedTable[ i ].iFlags = 0; // nie liczy się już zupełnie (nie wyśle SetVelocity) + sSpeedTable[ i ].fVelNext = -1; // można jechać za W4 + if( ( sSpeedTable[ i ].fDist <= 0.0 ) && ( eSignNext == sSpeedTable[ i ].evEvent ) ) { + // sanity check, if we're held by this stop point, let us go + VelSignalLast = -1; + } + continue; + } + IsAtPassengerStop = ( ( sSpeedTable[ i ].fDist <= passengerstopmaxdistance ) // Ra 2F1I: odległość plus długość pociągu musi być mniejsza od długości @@ -1234,8 +1246,8 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN } } if( ( SemNextStopIndex == -1 ) - || ( ( sSpeedTable[ SemNextStopIndex ].fVelNext != 0 ) - && ( sSpeedTable[ i ].fVelNext == 0 ) ) ) { + || ( ( sSpeedTable[ SemNextStopIndex ].fVelNext != 0 ) + && ( sSpeedTable[ i ].fVelNext == 0 ) ) ) { SemNextStopIndex = i; } } @@ -1296,8 +1308,19 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN } else if (sSpeedTable[i].IsProperSemaphor(OrderCurrentGet())) { // to semaphor - if (sSpeedTable[i].fDist < 0) - VelSignalLast = sSpeedTable[i].fVelNext; //minięty daje prędkość obowiązującą + if( sSpeedTable[ i ].fDist < 0 ) { + if( ( false == AIControllFlag ) + && ( sSpeedTable[ i ].fDist < -1 * std::max( fLength + 100, 250.0 ) ) ) { + // for human-driven vehicles ignore the signal if it was passed by sufficient distance + sSpeedTable[ i ].iFlags &= ~spEnabled; + VelSignal = -1.0; + continue; + } + else { + // for ai-driven vehicles always play by the rules + VelSignalLast = sSpeedTable[ i ].fVelNext; //minięty daje prędkość obowiązującą + } + } else { iDrivigFlags |= moveSemaphorFound; //jeśli z przodu to dajemy falgę, że jest diff --git a/Event.cpp b/Event.cpp index 238d6f53..0f7e5fb2 100644 --- a/Event.cpp +++ b/Event.cpp @@ -18,6 +18,7 @@ http://mozilla.org/MPL/2.0/. #include "simulation.h" #include "simulationtime.h" +#include "simulationsounds.h" #include "messaging.h" #include "Globals.h" #include "MemCell.h" diff --git a/McZapkie/Mover.cpp b/McZapkie/Mover.cpp index 2fc246db..40631815 100644 --- a/McZapkie/Mover.cpp +++ b/McZapkie/Mover.cpp @@ -9904,7 +9904,7 @@ void TMoverParameters::LoadFIZ_BuffCoupl( std::string const &line, int const Ind coupler->beta = 0.3; } else if( coupler->CouplerType == TCouplerType::Articulated ) { - +/* coupler->SpringKC = 60.0 * Mass + 1000; coupler->DmaxC = 0.05; coupler->FmaxC = 20000000.0 + 2.0 * Ftmax; @@ -9912,6 +9912,14 @@ void TMoverParameters::LoadFIZ_BuffCoupl( std::string const &line, int const Ind coupler->DmaxB = 0.05; coupler->FmaxB = 4000000.0 + 2.0 * Ftmax; coupler->beta = 0.55; +*/ + coupler->SpringKC = 4500 * 1000; + coupler->DmaxC = 0.05; + coupler->FmaxC = 850 * 1000; + coupler->SpringKB = 9200 * 1000; + coupler->DmaxB = 0.05; + coupler->FmaxB = 320 * 1000; + coupler->beta = 0.55; } if( Index == 0 ) { diff --git a/application.cpp b/application.cpp index b2876d79..657aabbc 100644 --- a/application.cpp +++ b/application.cpp @@ -15,6 +15,7 @@ http://mozilla.org/MPL/2.0/. #include "Globals.h" #include "simulation.h" +#include "simulationsounds.h" #include "Train.h" #include "dictionary.h" #include "sceneeditor.h" @@ -868,6 +869,7 @@ eu07_application::init_data() { weightpair.first.erase( weightpair.first.end() - 1 ); // trim trailing ':' from the key simulation::Weights.emplace( weightpair.first, weightpair.second ); } + deserialize_map( simulation::Sound_overrides, cParser( "data/sound_overrides.txt", cParser::buffer_FILE ) ); return 0; } diff --git a/maszyna.vcxproj b/maszyna.vcxproj index 58782cd2..e4316457 100644 --- a/maszyna.vcxproj +++ b/maszyna.vcxproj @@ -309,6 +309,7 @@ + @@ -444,6 +445,7 @@ + diff --git a/maszyna.vcxproj.filters b/maszyna.vcxproj.filters index 05f37d89..6f8a6903 100644 --- a/maszyna.vcxproj.filters +++ b/maszyna.vcxproj.filters @@ -468,6 +468,9 @@ Source Files + + Source Files + @@ -857,6 +860,9 @@ Header Files + + Header Files + diff --git a/simulation.cpp b/simulation.cpp index 5d8d79ee..b5e13531 100644 --- a/simulation.cpp +++ b/simulation.cpp @@ -36,7 +36,6 @@ memory_table Memory; path_table Paths; traction_table Traction; powergridsource_table Powergrid; -sound_table Sounds; instance_table Instances; vehicle_table Vehicles; train_table Trains; diff --git a/simulation.h b/simulation.h index e3c0521d..27e9f166 100644 --- a/simulation.h +++ b/simulation.h @@ -69,7 +69,6 @@ extern memory_table Memory; extern path_table Paths; extern traction_table Traction; extern powergridsource_table Powergrid; -extern sound_table Sounds; extern instance_table Instances; extern vehicle_table Vehicles; extern train_table Trains; diff --git a/simulationenvironment.cpp b/simulationenvironment.cpp index 9ce38353..5593138e 100644 --- a/simulationenvironment.cpp +++ b/simulationenvironment.cpp @@ -10,6 +10,7 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "simulationenvironment.h" +#include "simulationsounds.h" #include "Globals.h" #include "Timer.h" @@ -78,7 +79,14 @@ world_environment::init() { m_stars.init(); m_clouds.Init(); m_precipitation.init(); - m_precipitationsound.deserialize( "rain-sound-loop", sound_type::single ); + { + auto const rainsoundoverride { simulation::Sound_overrides.find( "weather.rainsound:" ) }; + m_rainsound.deserialize( + ( rainsoundoverride != simulation::Sound_overrides.end() ? + rainsoundoverride->second : + "rain-sound-loop" ), + sound_type::single ); + } m_wind = basic_wind{ static_cast( Random( 0, 360 ) ), static_cast( Random( -5, 5 ) ), @@ -181,10 +189,13 @@ world_environment::update() { if( ( true == ( FreeFlyModeFlag || Global.CabWindowOpen ) ) && ( Global.Weather == "rain:" ) ) { - m_precipitationsound.play( sound_flags::exclusive | sound_flags::looping ); + if( m_rainsound.is_combined() ) { + m_rainsound.pitch( Global.Overcast - 1.0 ); + } + m_rainsound.play( sound_flags::exclusive | sound_flags::looping ); } else { - m_precipitationsound.stop(); + m_rainsound.stop(); } update_wind(); diff --git a/simulationenvironment.h b/simulationenvironment.h index 3c03c01e..d916594f 100644 --- a/simulationenvironment.h +++ b/simulationenvironment.h @@ -83,7 +83,7 @@ private: float m_lightintensity { 1.f }; TSky m_clouds; basic_precipitation m_precipitation; - sound_source m_precipitationsound { sound_placement::external, -1 }; + sound_source m_rainsound { sound_placement::external, -1 }; basic_wind m_wind; }; diff --git a/simulationsounds.cpp b/simulationsounds.cpp new file mode 100644 index 00000000..16703726 --- /dev/null +++ b/simulationsounds.cpp @@ -0,0 +1,22 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#include "stdafx.h" +#include "simulationsounds.h" + +#include "utilities.h" + +namespace simulation { + +sound_overridemap Sound_overrides; +sound_table Sounds; + +} // simulation + +//--------------------------------------------------------------------------- diff --git a/simulationsounds.h b/simulationsounds.h new file mode 100644 index 00000000..f3c2717f --- /dev/null +++ b/simulationsounds.h @@ -0,0 +1,23 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include "sound.h" + +namespace simulation { + +using sound_overridemap = std::unordered_map; + +extern sound_overridemap Sound_overrides; +extern sound_table Sounds; + +} // simulation + +//--------------------------------------------------------------------------- diff --git a/simulationstateserializer.cpp b/simulationstateserializer.cpp index d94f2f65..eec2a2f7 100644 --- a/simulationstateserializer.cpp +++ b/simulationstateserializer.cpp @@ -15,6 +15,7 @@ http://mozilla.org/MPL/2.0/. #include "Globals.h" #include "simulation.h" #include "simulationtime.h" +#include "simulationsounds.h" #include "simulationenvironment.h" #include "scenenodegroups.h" #include "particles.h" diff --git a/utilities.h b/utilities.h index 3d871f93..fa8c1fea 100644 --- a/utilities.h +++ b/utilities.h @@ -353,6 +353,19 @@ deserialize_random_set( cParser &Input, char const *Break = "\n\r\t ;" ); int count_trailing_zeros( uint32_t val ); +// extracts a group of pairs from provided data stream +// NOTE: expects no more than single pair per line +template +void +deserialize_map( MapType_ &Map, cParser &Input ) { + + while( Input.ok() && !Input.eof() ) { + auto const key { Input.getToken( false ) }; + auto const value { Input.getToken( false, "\n" ) }; + Map.emplace( key, value ); + } +} + namespace threading { // simple POD pairing of a data item and a mutex diff --git a/version.h b/version.h index ded5d8e9..d7dfd424 100644 --- a/version.h +++ b/version.h @@ -1,5 +1,5 @@ #pragma once #define VERSION_MAJOR 20 -#define VERSION_MINOR 913 +#define VERSION_MINOR 914 #define VERSION_REVISION 0