mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-19 03:49:19 +02:00
fix: automatic coupler crashes, horns, compressor start delay, radio and cab lever sounds
- automatic couplers don't catch above the safe collision speed (#86): with crash damage on they couple at a closing speed of 15 km/h at most, a faster hit locks the coupling until the vehicles part and the collision runs its course. On the way: CollisionVelocity() read a head-on 10 + 10 km/h as 14.1 km/h (quaternions turn by half the angle), it's now taken from the touching ends; CollisionDetect() took the other vehicle's speed the wrong way round for vehicles facing each other. Head-on hits now derail sooner, at the intended limit, - a single horn lever can't sound both tones at once (eu07/maszyna#392), - a skid ends once the vehicle stops on locked wheels (eu07/maszyna#479), - electronic destination signs are blanked at the end of the timetable (eu07/maszyna#446), - horns need the air or the voltage to sound (eu07/maszyna#290, #76): HornType=[Pneumatic]|Electric and Horn3Type in Cntrl.; a pneumatic horn needs 0.2 MPa in the main reservoir (or the main pipe without one), an electric one the low voltage; the lever stays where it was put, - compressor start delay (#67): CompressorStartDelay [s] in Brake., counted from the compressor getting its power, after the engine starts say; none by default, - the channel and volume buttons of a radio without power do nothing (eu07/maszyna#429); the power check of the radio is TMoverParameters::RadioPowered(), - a lever moved smoothly sounds the positions it passes (#83). Sonar findings in the functions changed: nesting, nested conditionals, commented-out code, std::format, references to const. Unit tests: test::pair for two vehicles running into each other, test_couplers, test_horn, test_wheelslip, test_compressor, test_radio, test_gauge_positions.
This commit is contained in:
@@ -4825,12 +4825,13 @@ void TDynamicObject::RenderSounds() {
|
||||
|
||||
// horns
|
||||
{
|
||||
// for moving vehicle combine regular horn activation flag with emergency brake horn activation flag, if the brake is active
|
||||
auto const warningsignal { (
|
||||
MoverParameters->Vel > 0.5 && MoverParameters->AlarmChainFlag ?
|
||||
// for moving vehicle combine regular horn activation flag with emergency brake horn activation flag, if the brake is active;
|
||||
// the horns without the air or the voltage they need stay silent
|
||||
auto const warningsignal { MoverParameters->SoundingHorns(
|
||||
( MoverParameters->Vel > 0.5 && MoverParameters->AlarmChainFlag ?
|
||||
MoverParameters->EmergencyBrakeWarningSignal :
|
||||
0 )
|
||||
| MoverParameters->WarningSignal };
|
||||
| MoverParameters->WarningSignal ) };
|
||||
|
||||
if( TestFlag( warningsignal, 1 ) ) {
|
||||
sHorn1.play( sound_flags::exclusive | sound_flags::looping );
|
||||
@@ -7794,7 +7795,14 @@ int TDynamicObject::RouteWish(TTrack *tr)
|
||||
return Mechanik ? Mechanik->CrossRoute(tr) : 0; // wg AI albo prosto
|
||||
};
|
||||
|
||||
void TDynamicObject::DestinationSet(std::string to, std::string numer) {
|
||||
void TDynamicObject::DestinationClear() {
|
||||
|
||||
if( false == DestinationSign.has_light ) { return; } // physical destination signs remain up until manually changed
|
||||
// update_destinations() shows the blank sign in place of the missing destination
|
||||
DestinationSign.destination = null_handle;
|
||||
}
|
||||
|
||||
void TDynamicObject::DestinationSet(std::string const &to, std::string const &numer) {
|
||||
// ustawienie stacji docelowej oraz wymiennej tekstury 4, jeśli istnieje plik
|
||||
// w zasadzie, to każdy wagon mógłby mieć inną stację docelową
|
||||
// zwłaszcza w towarowych, pod kątem zautomatyzowania maewrów albo pracy górki
|
||||
@@ -7823,6 +7831,15 @@ void TDynamicObject::DestinationSet(std::string to, std::string numer) {
|
||||
if( DestinationSign.script.empty() ) { return; } // no script so no way to make the texture
|
||||
if( numer == "none" ) { return; } // blank or incomplete/malformed timetable, don't bother
|
||||
|
||||
auto const trainname { [this]() -> std::string {
|
||||
if( ctOwner != nullptr ) { return ctOwner->TrainName(); }
|
||||
if( Mechanik != nullptr ) { return Mechanik->TrainName(); }
|
||||
return "none"; } }; // shouldn't get here but, eh
|
||||
auto const instance { [this]() -> std::string {
|
||||
if( DestinationSign.instancing == "name" ) { return MoverParameters->Name; }
|
||||
if( DestinationSign.instancing == "type" ) { return MoverParameters->TypeName; }
|
||||
return "none"; } };
|
||||
|
||||
std::string signrequest {
|
||||
"make:"
|
||||
+ DestinationSign.script
|
||||
@@ -7834,17 +7851,10 @@ void TDynamicObject::DestinationSet(std::string to, std::string numer) {
|
||||
ctOwner->Vehicle()->MoverParameters->Name ) // owned vehicle, safer to point to owner as carriages can have identical names
|
||||
// basic instancing string
|
||||
// NOTE: underscore doesn't have any magic meaning for the time being, it's just less likely to conflict with regular dictionary keys
|
||||
+ "&_id1=" + (
|
||||
ctOwner != nullptr ? ctOwner->TrainName() :
|
||||
Mechanik != nullptr ? Mechanik->TrainName() :
|
||||
"none" ) }; // shouldn't get here but, eh
|
||||
+ "&_id1=" + trainname() };
|
||||
// TBD, TODO: replace instancing with support for variables in extra parameters string?
|
||||
if( false == DestinationSign.instancing.empty() ) {
|
||||
signrequest +=
|
||||
"&_id2=" + (
|
||||
DestinationSign.instancing == "name" ? MoverParameters->Name :
|
||||
DestinationSign.instancing == "type" ? MoverParameters->TypeName :
|
||||
"none" );
|
||||
signrequest += "&_id2=" + instance();
|
||||
}
|
||||
// optionl extra parameters
|
||||
if( false == DestinationSign.parameters.empty() ) {
|
||||
|
||||
Reference in New Issue
Block a user