diff --git a/Driver.cpp b/Driver.cpp index 855ad07c..236cf6ac 100644 --- a/Driver.cpp +++ b/Driver.cpp @@ -1013,7 +1013,7 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN // TODO: remove the check once the station system is in place if( m_lastexchangestop != asNextStop ) { auto const platformside = static_cast( std::floor( std::abs( sSpeedTable[ i ].evEvent->input_value( 2 ) ) ) ) % 10; - auto const exchangetime = simulation::Station.update_load( pVehicles[ 0 ], TrainParams, platformside ); + auto const exchangetime = simulation::Station.update_load( pVehicles[ end::front ], TrainParams, platformside ); WaitingSet( exchangetime ); // announce the stop name while at it announce( announcement_t::current ); diff --git a/DynObj.cpp b/DynObj.cpp index 3bf127a7..98e8b5e9 100644 --- a/DynObj.cpp +++ b/DynObj.cpp @@ -5862,7 +5862,8 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co { "near_stop:", announcement_t::approaching }, { "stop:", announcement_t::current }, { "next_stop:", announcement_t::next }, - { "destination:", announcement_t::destination } }; + { "destination:", announcement_t::destination }, + { "chime:", announcement_t::chime } }; while( ( ( token = parser.getToken() ) != "" ) && ( token != "}" ) ) { if( token.back() == ':' ) { @@ -7050,7 +7051,7 @@ material_handle TDynamicObject::DestinationFind( std::string Destination ) { return destinationhandle; } -void TDynamicObject::announce( announcement_t const Announcement ) { +void TDynamicObject::announce( announcement_t const Announcement, bool const Chime ) { if( m_speakers.empty() ) { return; } @@ -7061,6 +7062,7 @@ void TDynamicObject::announce( announcement_t const Announcement ) { if( driver == nullptr ) { return; } auto const &timetable { driver->TrainTimetable() }; + auto playchime { Chime }; if( m_announcements[ static_cast( Announcement ) ].empty() ) { goto followup; @@ -7089,6 +7091,15 @@ void TDynamicObject::announce( announcement_t const Announcement ) { if( stopnamesound.empty() ) { goto followup; } + // potentially precede the announcement with a chime... + if( ( true == playchime ) + && ( false == m_announcements[ static_cast( announcement_t::chime ) ].empty() ) ) { + for( auto &speaker : m_speakers ) { + speaker.announcement_queue.emplace_back( m_announcements[ static_cast( announcement_t::chime ) ] ); + } + playchime = false; + } + // ...then play the announcement itself for( auto &speaker : m_speakers ) { speaker.announcement_queue.emplace_back( m_announcements[ static_cast( Announcement ) ] ); speaker.announcement_queue.emplace_back( stopnamesound ); @@ -7097,7 +7108,7 @@ void TDynamicObject::announce( announcement_t const Announcement ) { followup: // potentially follow up with another announcement if( Announcement == announcement_t::next ) { - announce( announcement_t::destination ); + announce( announcement_t::destination, playchime ); } } diff --git a/DynObj.h b/DynObj.h index 3d41260d..e50944c0 100644 --- a/DynObj.h +++ b/DynObj.h @@ -156,6 +156,7 @@ enum class announcement_t : int { current, next, destination, + chime, end }; @@ -720,7 +721,8 @@ private: void OverheadTrack(float o); glm::dvec3 get_future_movement() const; void move_set(double distance); - void announce( announcement_t const Announcement ); + // playes specified announcement, potentially preceding it with a chime + void announce( announcement_t const Announcement, bool const Chime = true ); double MED[9][8]; // lista zmiennych do debugowania hamulca ED static std::string const MED_labels[ 8 ]; diff --git a/Event.cpp b/Event.cpp index 47efa8cb..98b99963 100644 --- a/Event.cpp +++ b/Event.cpp @@ -567,6 +567,10 @@ getvalues_event::init() { m_passive = true; } } + if( m_targets.empty() ) { + m_ignored = true; + return; + } // NOTE: GetValues retrieves data only from first specified memory cell // TBD, TODO: allow retrieval from more than one cell? m_input.data_source = m_targets.front(); diff --git a/McZapkie/MOVER.h b/McZapkie/MOVER.h index fcac5162..f37b77b6 100644 --- a/McZapkie/MOVER.h +++ b/McZapkie/MOVER.h @@ -699,6 +699,7 @@ struct TCoupling { int AutomaticCouplingFlag = coupling::coupler; int AllowedFlag = ( coupling::coupler | coupling::brakehose ); //Ra: maska dostępnych int PowerFlag = ( coupling::power110v | coupling::power24v ); + int PowerCoupling = coupling::permanent; // type of coupling required for power transfer /*zmienne*/ bool AutomaticCouplingAllowed { true }; // whether automatic coupling can be currently performed int CouplingFlag = 0; /*0 - wirtualnie, 1 - sprzegi, 2 - pneumatycznie, 4 - sterowanie, 8 - kabel mocy*/ diff --git a/McZapkie/Mover.cpp b/McZapkie/Mover.cpp index e8387e95..a6519f3f 100644 --- a/McZapkie/Mover.cpp +++ b/McZapkie/Mover.cpp @@ -1649,13 +1649,13 @@ void TMoverParameters::PowerCouplersCheck( double const Deltatime, coupling cons } case coupling::power110v: { - oppositecouplingispresent = ( ( oppositecoupler.CouplingFlag & coupling::permanent ) != 0 ) && ( ( oppositecoupler.PowerFlag & coupling::power110v ) != 0 ); + oppositecouplingispresent = ( TestFlag( oppositecoupler.CouplingFlag, oppositecoupler.PowerCoupling ) ) && ( ( oppositecoupler.PowerFlag & coupling::power110v ) != 0 ); localpowerexportisenabled = ( oppositecouplingispresent ); break; } case coupling::power24v: { - oppositecouplingispresent = ( ( oppositecoupler.CouplingFlag & coupling::permanent ) != 0 ) && ( ( oppositecoupler.PowerFlag & coupling::power24v ) != 0 ); + oppositecouplingispresent = ( TestFlag( oppositecoupler.CouplingFlag, oppositecoupler.PowerCoupling ) ) && ( ( oppositecoupler.PowerFlag & coupling::power24v ) != 0 ); localpowerexportisenabled = ( oppositecouplingispresent ); break; } @@ -8530,59 +8530,32 @@ std::string TMoverParameters::EngineDescription(int what) const // ************************************************************************************************* double TMoverParameters::GetTrainsetVoltage( int const Coupling ) const {//ABu: funkcja zwracajaca napiecie dla calego skladu, przydatna dla EZT - // TBD, TODO: roll into a loop, call once per vehicle update, return cached results? - auto frontvoltage { 0.0 }; - if( Couplers[ end::front ].Connected != nullptr ) { - auto const frontcouplingflag { - Couplers[ end::front ].CouplingFlag - | ( ( Couplers[ end::front ].CouplingFlag & coupling::permanent ) != 0 ? - Couplers[ end::front ].PowerFlag : + // TBD, TODO: call once per vehicle update, return cached results? + double voltages[] = { 0.0, 0.0 }; + for( int end = end::front; end <= end::rear; ++end ) { + if( Couplers[ end ].Connected == nullptr ) { + continue; + } + auto const &coupler { Couplers[ end ] }; + auto const fullcoupling { + coupler.CouplingFlag + | ( TestFlag( coupler.CouplingFlag, coupler.PowerCoupling ) ? + coupler.PowerFlag : 0 ) }; - if( ( frontcouplingflag & Coupling ) != 0 ) { - auto *connectedpowercoupling = ( - ( Coupling & ( coupling::highvoltage | coupling::heating ) ) != 0 ? &Couplers[ end::front ].Connected->Couplers[ Couplers[ end::front ].ConnectedNr ].power_high : - ( Coupling & coupling::power110v ) != 0 ? &Couplers[ end::front ].Connected->Couplers[ Couplers[ end::front ].ConnectedNr ].power_110v : - ( Coupling & coupling::power24v ) != 0 ? &Couplers[ end::front ].Connected->Couplers[ Couplers[ end::front ].ConnectedNr ].power_24v : - nullptr ); - if( ( connectedpowercoupling != nullptr ) - && ( connectedpowercoupling->is_live ) ) { - frontvoltage = connectedpowercoupling->voltage; - } + if( ( fullcoupling & Coupling ) == 0 ) { + continue; + } + auto *connectedpowercoupling = ( + ( Coupling & ( coupling::highvoltage | coupling::heating ) ) != 0 ? &coupler.Connected->Couplers[ coupler.ConnectedNr ].power_high : + ( Coupling & coupling::power110v ) != 0 ? &coupler.Connected->Couplers[ coupler.ConnectedNr ].power_110v : + ( Coupling & coupling::power24v ) != 0 ? &coupler.Connected->Couplers[ coupler.ConnectedNr ].power_24v : + nullptr ); + if( ( connectedpowercoupling != nullptr ) + && ( connectedpowercoupling->is_live ) ) { + voltages[ end ] = connectedpowercoupling->voltage; } } - auto rearvoltage{ 0.0 }; - if( Couplers[ end::rear ].Connected != nullptr ) { - auto const rearcouplingflag { - Couplers[ end::rear ].CouplingFlag - | ( ( Couplers[ end::rear ].CouplingFlag & coupling::permanent ) != 0 ? - Couplers[ end::rear ].PowerFlag : - 0 ) }; - if( ( rearcouplingflag & Coupling ) != 0 ) { - auto *connectedpowercoupling = ( - ( Coupling & ( coupling::highvoltage | coupling::heating ) ) != 0 ? &Couplers[ end::rear ].Connected->Couplers[ Couplers[ end::rear ].ConnectedNr ].power_high : - ( Coupling & coupling::power110v ) != 0 ? &Couplers[ end::rear ].Connected->Couplers[ Couplers[ end::rear ].ConnectedNr ].power_110v : - ( Coupling & coupling::power24v ) != 0 ? &Couplers[ end::rear ].Connected->Couplers[ Couplers[ end::rear ].ConnectedNr ].power_24v : - nullptr ); - if( ( connectedpowercoupling != nullptr ) - && ( connectedpowercoupling->is_live ) ) { - rearvoltage = connectedpowercoupling->voltage; - } - } - } - return std::max( frontvoltage, rearvoltage ); -/* - return std::max( - ( ( ( Couplers[end::front].Connected ) - && ( Couplers[ end::front ].Connected->Couplers[ Couplers[ end::front ].ConnectedNr ].power_high.is_live ) - && ( ( Couplers[ end::front ].CouplingFlag & Coupling ) != 0 ) ) ? - Couplers[end::front].Connected->Couplers[ Couplers[end::front].ConnectedNr ].power_high.voltage : - 0.0 ), - ( ( ( Couplers[end::rear].Connected ) - && ( Couplers[ end::rear ].Connected->Couplers[ Couplers[ end::rear ].ConnectedNr ].power_high.is_live ) - && ( ( Couplers[ end::rear ].CouplingFlag & Coupling ) != 0 ) ) ? - Couplers[ end::rear ].Connected->Couplers[ Couplers[ end::rear ].ConnectedNr ].power_high.voltage : - 0.0 ) ); -*/ + return std::max( voltages[ end::front ], voltages[ end::rear ] ); } double TMoverParameters::GetTrainsetHighVoltage() const { @@ -9924,6 +9897,7 @@ void TMoverParameters::LoadFIZ_BuffCoupl( std::string const &line, int const Ind if( coupler->AllowedFlag < 0 ) { coupler->AllowedFlag = ( ( -coupler->AllowedFlag ) | coupling::permanent ); } + extract_value( coupler->PowerCoupling, "PowerCoupling", line, "" ); extract_value( coupler->PowerFlag, "PowerFlag", line, "" ); extract_value( coupler->control_type, "ControlType", line, "" ); diff --git a/version.h b/version.h index ebc36200..b192cd9c 100644 --- a/version.h +++ b/version.h @@ -1,5 +1,5 @@ #pragma once #define VERSION_MAJOR 20 -#define VERSION_MINOR 731 +#define VERSION_MINOR 806 #define VERSION_REVISION 0