From ab17f5a4f449963f60b96f8d25137a9941186586 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kr=C3=B3lik=20Uszasty?= Date: Wed, 18 Apr 2018 17:22:04 +0200 Subject: [PATCH 1/2] Fixed minimal position for MHZ_EN57 --- McZapkie/hamulce.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/McZapkie/hamulce.cpp b/McZapkie/hamulce.cpp index 10f2e949..7381c787 100644 --- a/McZapkie/hamulce.cpp +++ b/McZapkie/hamulce.cpp @@ -22,7 +22,7 @@ Copyright (C) 2007-2014 Maciej Cierniak static double const DPL = 0.25; double const TFV4aM::pos_table[11] = {-2, 6, -1, 0, -2, 1, 4, 6, 0, 0, 0}; -double const TMHZ_EN57::pos_table[11] = {-2, 10, -1, 0, 0, 2, 9, 10, 0, 0, 0}; +double const TMHZ_EN57::pos_table[11] = {-1, 10, -1, 0, 0, 2, 9, 10, 0, 0, 0}; double const TM394::pos_table[11] = {-1, 5, -1, 0, 1, 2, 4, 5, 0, 0, 0}; double const TH14K1::BPT_K[6][2] = {{10, 0}, {4, 1}, {0, 1}, {4, 0}, {4, -1}, {15, -1}}; double const TH14K1::pos_table[11] = {-1, 4, -1, 0, 1, 2, 3, 4, 0, 0, 0}; From 6349a134250d040b2fdb674201cf0179ac05cc5d Mon Sep 17 00:00:00 2001 From: tmj-fstate Date: Thu, 19 Apr 2018 23:17:56 +0200 Subject: [PATCH 2/2] build 180419. radiator fan sounds, radiator shutters submodels, minor enhancements and bug fixes --- Driver.cpp | 17 +++--- DynObj.cpp | 134 ++++++++++++++++++++++++++------------------- DynObj.h | 4 ++ McZapkie/Mover.cpp | 3 +- Train.cpp | 5 +- mouseinput.cpp | 3 + translation.h | 1 + version.h | 2 +- 8 files changed, 102 insertions(+), 67 deletions(-) diff --git a/Driver.cpp b/Driver.cpp index c7c5793f..38d5c3a7 100644 --- a/Driver.cpp +++ b/Driver.cpp @@ -2341,16 +2341,19 @@ bool TController::PrepareEngine() else OK = false; - OK = OK && ( mvOccupied->ActiveDir != 0 ) && ( mvControlling->ScndPipePress > 4.5 ) && ( workingtemperature ); - if (OK) - { - if (eStopReason == stopSleep) // jeśli dotychczas spał - eStopReason = stopNone; // teraz nie ma powodu do stania + if( ( true == OK ) + && ( mvOccupied->ActiveDir != 0 ) + && ( true == workingtemperature ) + && ( ( mvControlling->ScndPipePress > 4.5 ) || ( mvControlling->VeselVolume == 0.0 ) ) ) { + + if( eStopReason == stopSleep ) { + // jeśli dotychczas spał teraz nie ma powodu do stania + eStopReason = stopNone; + } iEngineActive = 1; return true; } - else - { + else { iEngineActive = 0; return false; } diff --git a/DynObj.cpp b/DynObj.cpp index 143d4cf0..df23e13b 100644 --- a/DynObj.cpp +++ b/DynObj.cpp @@ -584,18 +584,15 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) if (vFloor.z > 0.0) mdLoad->GetSMRoot()->SetTranslate(modelShake + vFloor); - if (ObjSqrDist < 160000) // gdy bliżej niż 400m + if (ObjSqrDist < ( 400 * 400 ) ) // gdy bliżej niż 400m { for (int i = 0; i < iAnimations; ++i) // wykonanie kolejnych animacji - if (ObjSqrDist < pAnimations[i].fMaxDist) - if (pAnimations[i].yUpdate) // jeśli zdefiniowana funkcja - pAnimations[ i ].yUpdate( &pAnimations[i] ); // aktualizacja animacji (położenia submodeli -/* - pAnimations[i].yUpdate(pAnimations + - i); // aktualizacja animacji (położenia submodeli -*/ + if (ObjSqrDist < pAnimations[ i ].fMaxDist) + if (pAnimations[ i ].yUpdate) // jeśli zdefiniowana funkcja + pAnimations[ i ].yUpdate( &pAnimations[ i ] ); // aktualizacja animacji (położenia submodeli + if( ( mdModel != nullptr ) - && ( ObjSqrDist < 2500 ) ) { + && ( ObjSqrDist < ( 50 * 50 ) ) ) { // gdy bliżej niż 50m // ABu290105: rzucanie pudlem // te animacje wymagają bananów w modelach! @@ -658,11 +655,6 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) } btnOn = true; } - // else - //{ - // btCPneumatic1.TurnOff(); - // btCPneumatic1r.TurnOff(); - //} if (TestFlag(MoverParameters->Couplers[1].CouplingFlag, ctrain_pneumatic)) { @@ -683,11 +675,6 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) } btnOn = true; } - // else - //{ - // btCPneumatic2.TurnOff(); - // btCPneumatic2r.TurnOff(); - //} // przewody zasilajace, j.w. (yB) if (TestFlag(MoverParameters->Couplers[0].CouplingFlag, ctrain_scndpneumatic)) @@ -709,11 +696,6 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) } btnOn = true; } - // else - //{ - // btPneumatic1.TurnOff(); - // btPneumatic1r.TurnOff(); - //} if (TestFlag(MoverParameters->Couplers[1].CouplingFlag, ctrain_scndpneumatic)) { @@ -734,11 +716,6 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) } btnOn = true; } - // else - //{ - // btPneumatic2.TurnOff(); - // btPneumatic2r.TurnOff(); - //} } //*********************************************************************************/ else // po staremu ABu'oewmu @@ -753,11 +730,6 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) btCPneumatic1r.TurnOn(); btnOn = true; } - // else - //{ - // btCPneumatic1.TurnOff(); - // btCPneumatic1r.TurnOff(); - //} if (TestFlag(MoverParameters->Couplers[1].CouplingFlag, ctrain_pneumatic)) { @@ -767,11 +739,6 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) btCPneumatic2r.TurnOn(); btnOn = true; } - // else - //{ - // btCPneumatic2.TurnOff(); - // btCPneumatic2r.TurnOff(); - //} // przewody powietrzne j.w., ABu: decyzja czy rysowac tylko na podstawie // 'render' @@ -784,11 +751,6 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) btPneumatic1r.TurnOn(); btnOn = true; } - // else - //{ - // btPneumatic1.TurnOff(); - // btPneumatic1r.TurnOff(); - //} if (TestFlag(MoverParameters->Couplers[1].CouplingFlag, ctrain_scndpneumatic)) { @@ -798,11 +760,6 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) btPneumatic2r.TurnOn(); btnOn = true; } - // else - //{ - // btPneumatic2.TurnOff(); - // btPneumatic2r.TurnOff(); - //} } //*************************************************************/// koniec // wezykow @@ -817,7 +774,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) if (dist < 0) smBuforPrawy[i]->SetTranslate( Math3D::vector3(dist, 0, 0)); } - } + } // vehicle within 50m // Winger 160204 - podnoszenie pantografow @@ -917,6 +874,19 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) if (smWahacze[i]) smWahacze[i]->SetRotate(float3(1, 0, 0), fWahaczeAmp * cos(MoverParameters->eAngle)); + + // cooling shutters + // NOTE: shutters display _on state when they're closed, _off otherwise + if( ( true == MoverParameters->dizel_heat.water.config.shutters ) + && ( false == MoverParameters->dizel_heat.zaluzje1 ) ) { + btShutters1.Turn( true ); + btnOn = true; + } + if( ( true == MoverParameters->dizel_heat.water_aux.config.shutters ) + && ( false == MoverParameters->dizel_heat.zaluzje2 ) ) { + btShutters2.Turn( true ); + btnOn = true; + } if( ( Mechanik != nullptr ) && ( Mechanik->GetAction() != actSleep ) ) { @@ -927,7 +897,9 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) btnOn = true; } } - } + + } // vehicle within 400m + if( MoverParameters->Battery || MoverParameters->ConverterFlag ) { // sygnały czoła pociagu //Ra: wyświetlamy bez // ograniczeń odległości, by były widoczne z @@ -992,6 +964,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) sectionchunk = sectionchunk->NextGet(); } } + } // ABu 29.01.05 koniec przeklejenia ************************************* @@ -2102,6 +2075,12 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" iInventory[ side::rear ] |= btHeadSignals23.Active() ? light::headlight_right : 0; btMechanik1.Init( "mechanik1", mdLowPolyInt, false); btMechanik2.Init( "mechanik2", mdLowPolyInt, false); + if( MoverParameters->dizel_heat.water.config.shutters ) { + btShutters1.Init( "shutters1", mdModel, false ); + } + if( MoverParameters->dizel_heat.water_aux.config.shutters ) { + btShutters1.Init( "shutters2", mdModel, false ); + } TurnOff(); // resetowanie zmiennych submodeli if( mdLowPolyInt != nullptr ) { @@ -3740,6 +3719,8 @@ void TDynamicObject::TurnOff() btHeadSignals23.Turn( false ); btMechanik1.Turn( false ); btMechanik2.Turn( false ); + btShutters1.Turn( false ); + btShutters2.Turn( false ); }; // przeliczanie dźwięków, bo będzie słychać bez wyświetlania sektora z pojazdem @@ -3768,7 +3749,7 @@ void TDynamicObject::RenderSounds() { sConverter.stop(); } - if( MoverParameters->VeselVolume > 0 ) { + if( MoverParameters->CompressorSpeed > 0.0 ) { // McZapkie! - dzwiek compressor.wav tylko gdy dziala sprezarka if( MoverParameters->CompressorFlag ) { sCompressor.play( sound_flags::exclusive | sound_flags::looping ); @@ -4963,6 +4944,18 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName, m_powertrainsounds.rsWentylator.m_frequencyfactor /= MoverParameters->RVentnmax; } + else if( token == "radiatorfan1:" ) { + // primary circuit radiator fan + m_powertrainsounds.radiator_fan.deserialize( parser, sound_type::single ); + m_powertrainsounds.radiator_fan.owner( this ); + } + + else if( token == "radiatorfan2" ) { + // auxiliary circuit radiator fan + m_powertrainsounds.radiator_fan.deserialize( parser, sound_type::single ); + m_powertrainsounds.radiator_fan.owner( this ); + } + else if( token == "transmission:" ) { // plik z dzwiekiem, mnozniki i ofsety amp. i czest. // NOTE, fixed default parameters, legacy system leftover @@ -5958,8 +5951,9 @@ TDynamicObject::powertrain_sounds::position( glm::vec3 const Location ) { auto const nullvector { glm::vec3() }; std::vector enginesounds = { - &motor_relay, &dsbWejscie_na_bezoporow, &motor_parallel, &rsWentylator, - &engine, &engine_ignition, &engine_revving, &engine_turbo, + &inverter, + &motor_relay, &dsbWejscie_na_bezoporow, &motor_parallel, &motor_shuntfield, &rsWentylator, + &engine, &engine_ignition, &engine_revving, &engine_turbo, &oil_pump, &radiator_fan, &radiator_fan_aux, &transmission, &rsEngageSlippery }; for( auto sound : enginesounds ) { @@ -6185,7 +6179,6 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub // motor sounds volume = 0.0; if( ( true == Vehicle.Mains ) - && ( false == Vehicle.dizel_ignition ) && ( false == motors.empty() ) ) { if( std::fabs( Vehicle.enrot ) > 0.01 ) { @@ -6279,7 +6272,7 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub if( Vehicle.EngineType == ElectricInductionMotor ) { if( Vehicle.InverterFrequency > 0.1 ) { - volume = inverter.m_amplitudeoffset + inverter.m_amplitudefactor * std::sqrt( std::fabs( Vehicle.dizel_fill ) ); + volume = inverter.m_amplitudeoffset + inverter.m_amplitudefactor * std::sqrt( std::abs( Vehicle.dizel_fill ) ); inverter .pitch( inverter.m_frequencyoffset + inverter.m_frequencyfactor * Vehicle.InverterFrequency ) @@ -6302,6 +6295,35 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub // ...otherwise shut down the sound rsWentylator.stop(); } + // radiator fan sounds + if( ( Vehicle.EngineType == DieselEngine ) + || ( Vehicle.EngineType == DieselElectric ) ) { + + if( Vehicle.dizel_heat.rpmw > 0.1 ) { + // NOTE: fan speed tends to max out at ~100 rpm; by default we try to get pitch range of 0.5-1.5 and volume range of 0.5-1.0 + radiator_fan + .pitch( 0.5 + radiator_fan.m_frequencyoffset + radiator_fan.m_frequencyfactor * Vehicle.dizel_heat.rpmw * 0.01 ) + .gain( 0.5 + radiator_fan.m_amplitudeoffset + 0.5 * radiator_fan.m_amplitudefactor * Vehicle.dizel_heat.rpmw * 0.01 ) + .play( sound_flags::exclusive | sound_flags::looping ); + } + else { + // ...otherwise shut down the sound + radiator_fan.stop(); + } + + if( Vehicle.dizel_heat.rpmw2 > 0.1 ) { + // NOTE: fan speed tends to max out at ~100 rpm; by default we try to get pitch range of 0.5-1.5 and volume range of 0.5-1.0 + radiator_fan_aux + .pitch( 0.5 + radiator_fan_aux.m_frequencyoffset + radiator_fan_aux.m_frequencyfactor * Vehicle.dizel_heat.rpmw2 * 0.01 ) + .gain( 0.5 + radiator_fan_aux.m_amplitudeoffset + 0.5 * radiator_fan_aux.m_amplitudefactor * Vehicle.dizel_heat.rpmw2 * 0.01 ) + .play( sound_flags::exclusive | sound_flags::looping ); + } + else { + // ...otherwise shut down the sound + radiator_fan_aux.stop(); + } + } + // relay sounds auto const soundflags { Vehicle.SoundFlag }; if( TestFlag( soundflags, sound::relay ) ) { diff --git a/DynObj.h b/DynObj.h index 0eb826e2..3ab1373b 100644 --- a/DynObj.h +++ b/DynObj.h @@ -322,6 +322,8 @@ private: sound_source engine_turbo { sound_placement::engine }; double engine_turbo_pitch { 1.0 }; sound_source oil_pump { sound_placement::engine }; + sound_source radiator_fan { sound_placement::engine }; + sound_source radiator_fan_aux { sound_placement::engine }; sound_source transmission { sound_placement::engine }; sound_source rsEngageSlippery { sound_placement::engine }; // moved from cab @@ -371,6 +373,8 @@ private: TButton btHeadSignals23; TButton btMechanik1; TButton btMechanik2; + TButton btShutters1; // cooling shutters for primary water circuit + TButton btShutters2; // cooling shutters for auxiliary water circuit double dRailLength { 0.0 }; std::vector m_axlesounds; diff --git a/McZapkie/Mover.cpp b/McZapkie/Mover.cpp index d16bac76..4caeffdc 100644 --- a/McZapkie/Mover.cpp +++ b/McZapkie/Mover.cpp @@ -7800,8 +7800,9 @@ void TMoverParameters::LoadFIZ_Brake( std::string const &line ) { DeltaPipePress = HighPipePress - LowPipePress; extract_value( VeselVolume, "Vv", line, "" ); +/* if( VeselVolume == 0.0 ) { VeselVolume = 0.01; } - +*/ extract_value( MinCompressor, "MinCP", line, "" ); extract_value( MaxCompressor, "MaxCP", line, "" ); extract_value( CompressorSpeed, "CompressorSpeed", line, "" ); diff --git a/Train.cpp b/Train.cpp index ad0f59b3..527c9889 100644 --- a/Train.cpp +++ b/Train.cpp @@ -759,7 +759,7 @@ void TTrain::OnCommand_secondcontrollerincrease( TTrain *Train, command_data con // on press or hold if( Train->mvControlled->ShuntMode ) { Train->mvControlled->AnPos = clamp( - Train->mvControlled->AnPos + ( Command.time_delta * 2.0 ), + Train->mvControlled->AnPos + 0.025, 0.0, 1.0 ); } else { @@ -820,7 +820,7 @@ void TTrain::OnCommand_secondcontrollerdecrease( TTrain *Train, command_data con // on press or hold if( Train->mvControlled->ShuntMode ) { Train->mvControlled->AnPos = clamp( - Train->mvControlled->AnPos - ( Command.time_delta * 2.0 ), + Train->mvControlled->AnPos - 0.025, 0.0, 1.0 ); } Train->mvControlled->DecScndCtrl( 1 ); @@ -7045,6 +7045,7 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka gauge.Load(Parser, DynamicObject, DynamicObject->mdKabina); gauge.AssignDouble(&mvControlled->AnPos); + m_controlmapper.insert( gauge, "shuntmodepower:" ); } else { diff --git a/mouseinput.cpp b/mouseinput.cpp index 5e4ea8ee..6d8bbda2 100644 --- a/mouseinput.cpp +++ b/mouseinput.cpp @@ -215,6 +215,9 @@ mouse_input::default_bindings() { { "scndctrl:", { user_command::secondcontrollerincrease, user_command::secondcontrollerdecrease } }, + { "shuntmodepower:", { + user_command::secondcontrollerincrease, + user_command::secondcontrollerdecrease } }, { "dirkey:", { user_command::reverserincrease, user_command::reverserdecrease } }, diff --git a/translation.h b/translation.h index d60c3fef..d48cd8ce 100644 --- a/translation.h +++ b/translation.h @@ -20,6 +20,7 @@ std::string static std::unordered_map m_cabcontrols = { { "mainctrl:", "master controller" }, { "scndctrl:", "second controller" }, + { "shuntmodepower:", "shunt mode power" }, { "dirkey:" , "reverser" }, { "brakectrl:", "train brake" }, { "localbrake:", "independent brake" }, diff --git a/version.h b/version.h index 85730745..4af1a0c5 100644 --- a/version.h +++ b/version.h @@ -1,5 +1,5 @@ #pragma once #define VERSION_MAJOR 18 -#define VERSION_MINOR 418 +#define VERSION_MINOR 419 #define VERSION_REVISION 0