From 13d9a91632b562902230ae0ba61902265031036d Mon Sep 17 00:00:00 2001 From: jakubg1 <24206305+jakubg1@users.noreply.github.com> Date: Wed, 13 Mar 2024 03:25:19 +0100 Subject: [PATCH] Improve pantograph selector - A new parameter has been added to .fiz file format, in the Switches: section: - PantographPresetDefault [0] - The 0-based index of a pantograph preset that should be chosen upon the vehicle creation. 0 by default mimicks the current behavior. - Fixed the selected pantograph configuration not being respected until the configuration has been changed. --- McZapkie/MOVER.h | 1 + McZapkie/Mover.cpp | 1 + Train.cpp | 6 ++++++ Train.h | 4 +++- 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/McZapkie/MOVER.h b/McZapkie/MOVER.h index 2702aee1..f93b2e59 100644 --- a/McZapkie/MOVER.h +++ b/McZapkie/MOVER.h @@ -1205,6 +1205,7 @@ public: bool UniCtrlIntegratedLocalBrakeCtrl = false; /*zintegrowany nastawnik JH obsluguje hamowanie hamulcem pomocniczym*/ int UniCtrlNoPowerPos{ 0 }; // cached highesr position not generating traction force std::pair> PantsPreset { "0132", { 0, 0 } }; // pantograph preset switches; .first holds possible setups as chars, .second holds currently selected preset in each cab + int PantsPresetDefault = 0; // default pantograph preset, this is not updated during simulation /*-sekcja parametrow dla lokomotywy elektrycznej*/ TSchemeTable RList; /*lista rezystorow rozruchowych i polaczen silnikow, dla dizla: napelnienia*/ diff --git a/McZapkie/Mover.cpp b/McZapkie/Mover.cpp index ae3180f5..a395051d 100644 --- a/McZapkie/Mover.cpp +++ b/McZapkie/Mover.cpp @@ -11100,6 +11100,7 @@ void TMoverParameters::LoadFIZ_Switches( std::string const &Input ) { std::remove( std::begin( presets ), std::end( presets ), '|' ), std::end( presets ) ); } + extract_value( PantsPresetDefault, "PantographPresetDefault", Input, "" ); } void TMoverParameters::LoadFIZ_MotorParamTable( std::string const &Input ) { diff --git a/Train.cpp b/Train.cpp index 5e1b28f8..187b2545 100644 --- a/Train.cpp +++ b/Train.cpp @@ -637,6 +637,12 @@ bool TTrain::Init(TDynamicObject *NewDynamicObject, bool e3d) DynamicObject->Mechanik->sync_consist_reversers(); } + // Set the default pantograph preset and update pantographs' valves accordingly. + change_pantograph_selection(mvOccupied->PantsPresetDefault); + // Avoid double update if the default is other than 0. + if (mvOccupied->PantsPresetDefault == 0) + update_pantograph_valves(); + return true; } diff --git a/Train.h b/Train.h index 15bd2a03..4e2afda1 100644 --- a/Train.h +++ b/Train.h @@ -211,12 +211,14 @@ class TTrain { void update_sounds( double const Deltatime ); void update_sounds_runningnoise( sound_source &Sound ); void update_sounds_radio(); + // Translates the given cab to an end ID: cab `1` and engine compartment (`0`) translate to `end::front`, cab `2` translates to `end::rear` inline end cab_to_end( int const End ) const { return ( End == 2 ? end::rear : end::front ); } + // Translates the currently occupied cab to an end ID: cab `1` and engine compartment (`0`) translate to `end::front`, cab `2` translates to `end::rear` inline end cab_to_end() const { return cab_to_end( iCabn ); } @@ -815,7 +817,7 @@ public: // reszta może by?publiczna */ // McZapkie: opis kabiny - obszar poruszania sie mechanika oraz zajetosc std::array Cabine; // przedzial maszynowy, kabina 1 (A), kabina 2 (B) - int iCabn { 0 }; // 0: mid, 1: front, 2: rear + int iCabn { 0 }; // the cab number the player is currently inside of; 0: mid, 1: front, 2: rear bool is_cab_initialized { false }; // McZapkie: do poruszania sie po kabinie Math3D::vector3 pMechSittingPosition; // ABu 180404