16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-21 12:29:18 +02:00

Merge remote-tracking branch 'TMJ/master'

This commit is contained in:
Królik Uszasty
2021-05-09 18:06:15 +02:00
13 changed files with 550 additions and 584 deletions

View File

@@ -1285,25 +1285,6 @@ TController::TableUpdateStopPoint( TCommandType &Command, TSpeedPos &Point, doub
}
}
if( pVehicle->DirectionGet() != m_lastexchangedirection ) {
// generally means the ai driver moved to the opposite end of the consist
// TODO: investigate whether user playing with the reverser can mess this up
auto const left { ( m_lastexchangedirection > 0 ) ? 1 : 2 };
auto const right { 3 - left };
m_lastexchangeplatforms =
( ( m_lastexchangeplatforms & left ) != 0 ? right : 0 )
+ ( ( m_lastexchangeplatforms & right ) != 0 ? left : 0 );
m_lastexchangedirection = pVehicle->DirectionGet();
}
if( ( false == TrainParams.IsMaintenance() )
&& ( ( false == TestFlag( iDrivigFlags, moveDoorOpened ) )
|| ( true == DoesAnyDoorNeedOpening ) ) ) {
iDrivigFlags |= moveDoorOpened; // nie wykonywać drugi raz
remove_hint( locale::string::driver_hint_doorleftopen );
remove_hint( locale::string::driver_hint_doorrightopen );
Doors( true, m_lastexchangeplatforms );
}
if (OrderCurrentGet() & ( Shunt | Loose_shunt )) {
OrderNext(Obey_train); // uruchomić jazdę pociągową
CheckVehicles(); // zmienić światła
@@ -2728,10 +2709,11 @@ bool TController::PrepareEngine()
cue_action( locale::string::driver_hint_pantographcompressoroff ); // sprężarkę pantografów można już wyłączyć
}
}
// TODO: make pantograph setup a part of control_pantographs() and call it here instead
if( ( fOverhead2 == -1.0 ) && ( iOverheadDown == 0 ) ) {
cue_action( locale::string::driver_hint_pantographsvalveon );
cue_action( locale::string::driver_hint_frontpantographvalveon );
cue_action( locale::string::driver_hint_rearpantographvalveon );
cue_action( locale::string::driver_hint_frontpantographvalveon, ( iDirection >= 0 ? 5 : 0 ) );
cue_action( locale::string::driver_hint_rearpantographvalveon, ( iDirection >= 0 ? 0 : 5 ) );
}
}
@@ -2748,6 +2730,7 @@ bool TController::PrepareEngine()
if( IsAnyConverterOverloadRelayOpen ) {
// wywalił bezpiecznik nadmiarowy przetwornicy
cue_action( locale::string::driver_hint_compressoroff ); // TODO: discern whether compressor needs converter to operate
cue_action( locale::string::driver_hint_converteroff );
cue_action( locale::string::driver_hint_primaryconverteroverloadreset ); // reset nadmiarowego
}
@@ -6625,6 +6608,44 @@ TController::check_departure() {
}
}
// verify progress of load exchange
void
TController::check_load_exchange() {
ExchangeTime = 0.f;
DoesAnyDoorNeedOpening = false;
if( fStopTime > 0 ) { return; }
// czas postoju przed dalszą jazdą (np. na przystanku)
auto *vehicle { pVehicles[ end::front ] };
while( vehicle != nullptr ) {
auto const vehicleexchangetime { vehicle->LoadExchangeTime() };
DoesAnyDoorNeedOpening |= ( ( vehicleexchangetime > 0 ) && ( vehicle->LoadExchangeSpeed() == 0 ) );
ExchangeTime = std::max( ExchangeTime, vehicleexchangetime );
vehicle = vehicle->Next();
}
if( pVehicle->DirectionGet() != m_lastexchangedirection ) {
// generally means the ai driver moved to the opposite end of the consist
// TODO: investigate whether user playing with the reverser can mess this up
auto const left { ( m_lastexchangedirection > 0 ) ? 1 : 2 };
auto const right { 3 - left };
m_lastexchangeplatforms =
( ( m_lastexchangeplatforms & left ) != 0 ? right : 0 )
+ ( ( m_lastexchangeplatforms & right ) != 0 ? left : 0 );
m_lastexchangedirection = pVehicle->DirectionGet();
}
if( ( false == TrainParams.IsMaintenance() )
&& ( ( false == TestFlag( iDrivigFlags, moveDoorOpened ) )
|| ( true == DoesAnyDoorNeedOpening ) ) ) {
iDrivigFlags |= moveDoorOpened; // nie wykonywać drugi raz
remove_hint( locale::string::driver_hint_doorleftopen );
remove_hint( locale::string::driver_hint_doorrightopen );
Doors( true, m_lastexchangeplatforms );
}
}
void
TController::UpdateChangeDirection() {
// TODO: rework into driver mode independent routine
@@ -6640,6 +6661,10 @@ TController::UpdateChangeDirection() {
// shared part of the routine, implement if direction matches what was requested
if( ( mvOccupied->Vel < EU07_AI_NOMOVEMENT )
&& ( iDirection == iDirectionOrder ) ) {
// NOTE: we can't be sure there's a visible signal within scan range after direction change
// which would normally overwrite the old limit, so we reset signal value manually here
VelSignal = -1;
VelSignalNext = -1;
PrepareEngine();
JumpToNextOrder(); // następnie robimy, co jest do zrobienia (Shunt albo Obey_train)
if( OrderCurrentGet() & ( Shunt | Loose_shunt | Connect ) ) {
@@ -7249,22 +7274,12 @@ TController::adjust_desired_speed_for_limits() {
}
// recalculate potential load exchange duration
DoesAnyDoorNeedOpening = false;
ExchangeTime = 0.f;
check_load_exchange();
if( ( ExchangeTime > 0 )
|| ( mvOccupied->Vel > 2.0 ) ) { // HACK: force timer reset if the load exchange is cancelled due to departure
WaitingSet( ExchangeTime );
}
if( fStopTime < 0 ) {
// czas postoju przed dalszą jazdą (np. na przystanku)
// verify progress of load exchange
auto *vehicle { pVehicles[ end::front ] };
while( vehicle != nullptr ) {
auto const vehicleexchangetime { vehicle->LoadExchangeTime() };
DoesAnyDoorNeedOpening |= ( ( vehicleexchangetime > 0 ) && ( vehicle->LoadExchangeSpeed() == 0 ) );
ExchangeTime = std::max( ExchangeTime, vehicleexchangetime );
vehicle = vehicle->Next();
}
if( ( ExchangeTime > 0 )
|| ( mvOccupied->Vel > 2.0 ) ) { // HACK: force timer reset if the load exchange is cancelled due to departure
WaitingSet( ExchangeTime );
}
VelDesired = 0.0; // jak ma czekać, to nie ma jazdy
cue_action( locale::string::driver_hint_waitloadexchange );
return; // speed limit can't get any lower

View File

@@ -314,6 +314,7 @@ private:
void handle_engine();
void handle_orders();
void UpdateNextStop();
void check_load_exchange(); // returns: estimated remaining time of load exchange, in seconds
void check_departure();
void UpdateConnect();
void UpdateDisconnect();

View File

@@ -4210,7 +4210,7 @@ void TDynamicObject::RenderSounds() {
}
// Dzwiek odluzniacza
if( MoverParameters->Hamulec->GetStatus() & b_rls ) {
if( MoverParameters->Hamulec->Releaser() ) {
sReleaser
.gain(
clamp<float>(
@@ -4295,6 +4295,19 @@ void TDynamicObject::RenderSounds() {
rsPisk.stop();
}
// spring brake
if( m_springbrakesounds.state != MoverParameters->SpringBrake.Activate ) {
m_springbrakesounds.state = MoverParameters->SpringBrake.Activate;
if( m_springbrakesounds.state ) {
m_springbrakesounds.activate.play( sound_flags::exclusive );
m_springbrakesounds.release.stop();
}
else {
m_springbrakesounds.activate.stop();
m_springbrakesounds.release.play( sound_flags::exclusive );
}
}
// other sounds
// load exchange
if( MoverParameters->LoadStatus & 1 ) {
@@ -5703,6 +5716,15 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co
rsUnbrake.deserialize( parser, sound_type::single, sound_parameters::range );
rsUnbrake.owner( this );
}
// spring brake sounds
else if( token == "springbrake:" ) {
m_springbrakesounds.activate.deserialize( parser, sound_type::single );
m_springbrakesounds.activate.owner( this );
}
else if( token == "springbrakeoff:" ) {
m_springbrakesounds.release.deserialize( parser, sound_type::single );
m_springbrakesounds.release.owner( this );
}
else if( token == "derail:" ) {
// dzwiek przy wykolejeniu

View File

@@ -421,6 +421,12 @@ private:
sound_source announcement;
std::deque<sound_source> announcement_queue; // fifo queue
};
struct springbrake_sounds {
sound_source activate { sound_placement::external };
sound_source release { sound_placement::external };
bool state { false };
};
// methods
void ABuLittleUpdate(double ObjSqrDist);
@@ -496,6 +502,7 @@ private:
sound_source m_emergencybrake { sound_placement::engine };
double m_emergencybrakeflow{ 0.f };
sound_source sReleaser { sound_placement::external };
springbrake_sounds m_springbrakesounds;
sound_source rsSlippery { sound_placement::external, EU07_SOUND_BRAKINGCUTOFFRANGE }; // moved from cab
sound_source sSand { sound_placement::external };
// moving part and other external sounds

View File

@@ -286,25 +286,25 @@ TGauge::Load_mapping( cParser &Input, TGauge::scratch_data &Scratchpad ) {
return true; // return value marks a key: value pair was extracted, nothing about whether it's recognized
}
void
TGauge::UpdateValue( float fNewDesired ) {
return UpdateValue( fNewDesired, nullptr );
}
void
TGauge::UpdateValue( float fNewDesired, sound_source &Fallbacksound ) {
return UpdateValue( fNewDesired, &Fallbacksound );
}
// ustawienie wartości docelowej. plays provided fallback sound, if no sound was defined in the control itself
void
TGauge::UpdateValue( float fNewDesired, sound_source *Fallbacksound ) {
bool
TGauge::UpdateValue( float fNewDesired, std::optional<sound_source> &Fallbacksound ) {
if( false == UpdateValue( fNewDesired ) ) {
if( Fallbacksound ) {
Fallbacksound->play( m_soundtype );
return true;
}
}
return false;
}
bool
TGauge::UpdateValue( float fNewDesired ) {
auto const desiredtimes100 = static_cast<int>( std::round( 100.0 * fNewDesired ) );
if( desiredtimes100 == static_cast<int>( std::round( 100.0 * m_targetvalue ) ) ) {
return;
return true;
}
m_targetvalue = fNewDesired;
// if there's any sound associated with new requested value, play it
@@ -315,7 +315,7 @@ TGauge::UpdateValue( float fNewDesired, sound_source *Fallbacksound ) {
auto const lookup = m_soundfxvalues.find( desiredtimes100 / 100 );
if( lookup != m_soundfxvalues.end() ) {
lookup->second.play();
return;
return true;
}
}
else {
@@ -329,20 +329,17 @@ TGauge::UpdateValue( float fNewDesired, sound_source *Fallbacksound ) {
// shift up
if( false == m_soundfxincrease.empty() ) {
m_soundfxincrease.play( m_soundtype );
return;
return true;
}
}
else if( currentvalue > fNewDesired ) {
// shift down
if( false == m_soundfxdecrease.empty() ) {
m_soundfxdecrease.play( m_soundtype );
return;
return true;
}
}
if( Fallbacksound != nullptr ) {
// ...and if that fails too, try the provided fallback sound from legacy system
Fallbacksound->play( m_soundtype );
}
return false; // no suitable sound was found
};
void TGauge::PutValue(float fNewDesired)

View File

@@ -43,8 +43,8 @@ public:
*this = TGauge(); }
void Init(TSubModel *Submodel, TSubModel *Submodelon, TGaugeAnimation Type, float Scale = 1, float Offset = 0, float Friction = 0, float Value = 0, float const Endvalue = -1.0, float const Endscale = -1.0, bool const Interpolate = false );
void Load(cParser &Parser, TDynamicObject const *Owner, double const mul = 1.0);
void UpdateValue( float fNewDesired );
void UpdateValue( float fNewDesired, sound_source &Fallbacksound );
bool UpdateValue( float fNewDesired );
bool UpdateValue( float fNewDesired, std::optional<sound_source> &Fallbacksound );
void PutValue(float fNewDesired);
float GetValue() const;
float GetDesiredValue() const;
@@ -79,8 +79,6 @@ private:
// imports member data pair from the config file
bool
Load_mapping( cParser &Input, TGauge::scratch_data &Scratchpad );
void
UpdateValue( float fNewDesired, sound_source *Fallbacksound );
float
GetScaledValue() const;
void

View File

@@ -71,7 +71,7 @@ TCommandType TMemCell::CommandCheck()
eCommand = TCommandType::cm_OutsideStation;
bCommand = false; // tego nie powinno być w komórce
}
else if( szText.compare( 0, 19, "PassengerStopPoint:" ) == 0 ) // porównanie początków
else if( starts_with( szText, "PassengerStopPoint:" ) ) // porównanie początków
{
eCommand = TCommandType::cm_PassengerStopPoint;
bCommand = false; // tego nie powinno być w komórce

900
Train.cpp

File diff suppressed because it is too large Load Diff

52
Train.h
View File

@@ -728,35 +728,33 @@ public: // reszta może by?publiczna
TButton btHaslerBrakes; // ciśnienie w cylindrach
TButton btHaslerCurrent; // prąd na silnikach
sound_source dsbReverserKey { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE }; // hunter-121211
sound_source dsbNastawnikJazdy { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE };
sound_source dsbNastawnikBocz { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE }; // hunter-081211
sound_source dsbSwitch { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE };
sound_source dsbPneumaticSwitch { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE };
sound_source rsHiss { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE }; // upuszczanie
sound_source rsHissU { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE }; // napelnianie
sound_source rsHissE { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE }; // nagle
sound_source rsHissX { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE }; // fala
sound_source rsHissT { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE }; // czasowy
sound_source rsSBHiss { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE }; // local
sound_source rsSBHissU { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE }; // local, engage brakes
float m_lastlocalbrakepressure { -1.f }; // helper, cached level of pressure in local brake cylinder
float m_localbrakepressurechange { 0.f }; // recent change of pressure in local brake cylinder
sound_source rsBrake { sound_placement::internal, -1 };
sound_source rsFadeSound { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE };
sound_source rsRunningNoise{ sound_placement::internal, EU07_SOUND_GLOBALRANGE };
sound_source rsHuntingNoise{ sound_placement::internal, EU07_SOUND_GLOBALRANGE };
sound_source m_rainsound { sound_placement::internal, -1 };
sound_source dsbHasler { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE };
sound_source dsbBuzzer { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE };
sound_source dsbSlipAlarm { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE }; // Bombardier 011010: alarm przy poslizgu dla 181/182
std::optional<sound_source>
dsbNastawnikJazdy,
dsbNastawnikBocz,
dsbReverserKey,
dsbBuzzer,
m_radiostop,
dsbSlipAlarm,
m_distancecounterclear,
dsbHasler,
dsbSwitch,
dsbPneumaticSwitch,
rsHiss,
rsHissU,
rsHissE,
rsHissX,
rsHissT,
rsSBHiss,
rsSBHissU,
rsBrake,
rsFadeSound,
rsRunningNoise,
rsHuntingNoise,
m_rainsound;
sound_source m_radiosound { sound_placement::internal, 2 * EU07_SOUND_CABCONTROLSCUTOFFRANGE }; // cached template for radio messages
std::vector<std::pair<int, std::shared_ptr<sound_source>>> m_radiomessages; // list of currently played radio messages
sound_source m_radiostop { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE };
sound_source m_distancecounterclear { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE }; // distance meter 'good to go' alert
float m_lastlocalbrakepressure { -1.f }; // helper, cached level of pressure in local brake cylinder
float m_localbrakepressurechange { 0.f }; // recent change of pressure in local brake cylinder
/*
int iCabLightFlag; // McZapkie:120503: oswietlenie kabiny (0: wyl, 1: przyciemnione, 2: pelne)
bool bCabLight; // hunter-091012: czy swiatlo jest zapalone?

View File

@@ -723,7 +723,7 @@ TController::cue_action( locale::string const Action, float const Actionparamete
hint(
Action,
[this](float const Parameter) -> bool {
return ( mvPantographUnit->PantPress >= 4.2 ); } );
return ( mvPantographUnit->PantPress >= ( is_emu() ? ( mvPantographUnit->PantPressLockActive ? 4.6 : 2.6 ) : 4.2 ) ); } );
break;
}
case locale::string::driver_hint_waitloadexchange: {

View File

@@ -58,7 +58,7 @@ itemproperties_panel::update( scene::basic_node const *Node ) {
}
*/
textline =
"name: " + ( node->name().empty() ? "(none)" : node->name() )
"name: " + ( node->name().empty() ? "(none)" : Bezogonkow( node->name() ) )
+ "\nlocation: [" + to_string( node->location().x, 2 ) + ", " + to_string( node->location().y, 2 ) + ", " + to_string( node->location().z, 2 ) + "]"
+ " (distance: " + to_string( glm::length( glm::dvec3{ node->location().x, 0.0, node->location().z } -glm::dvec3{ camera.Pos.x, 0.0, camera.Pos.z } ), 1 ) + " m)";
text_lines.emplace_back( textline, Global.UITextColor );
@@ -112,7 +112,7 @@ itemproperties_panel::update( scene::basic_node const *Node ) {
auto const *subnode = static_cast<TTrack const *>( node );
// basic attributes
textline =
"isolated: " + ( ( subnode->pIsolated != nullptr ) ? subnode->pIsolated->asName : "(none)" )
"isolated: " + ( ( subnode->pIsolated != nullptr ) ? Bezogonkow( subnode->pIsolated->asName ) : "(none)" )
+ "\nvelocity: " + to_string( subnode->SwitchExtension ? subnode->SwitchExtension->fVelocity : subnode->fVelocity )
+ "\nwidth: " + to_string( subnode->fTrackWidth ) + " m"
+ "\nfriction: " + to_string( subnode->fFriction, 2 )
@@ -168,7 +168,7 @@ itemproperties_panel::update( scene::basic_node const *Node ) {
}
textline += (
event.second != nullptr ?
event.second->m_name :
Bezogonkow( event.second->m_name ) :
event.first + " (missing)" );
}
textline += "] ";
@@ -184,7 +184,7 @@ itemproperties_panel::update( scene::basic_node const *Node ) {
+ " [" + to_string( subnode->Value1(), 2 ) + "]"
+ " [" + to_string( subnode->Value2(), 2 ) + "]";
text_lines.emplace_back( textline, Global.UITextColor );
textline = "track: " + ( subnode->asTrackName.empty() ? "(none)" : subnode->asTrackName );
textline = "track: " + ( subnode->asTrackName.empty() ? "(none)" : Bezogonkow( subnode->asTrackName ) );
text_lines.emplace_back( textline, Global.UITextColor );
}

View File

@@ -215,7 +215,7 @@ std::ptrdiff_t len_common_prefix( std::string const &Left, std::string const &Ri
// returns true if provided string ends with another provided string
bool ends_with( std::string_view String, std::string_view Suffix );
// returns true if provided string begins with another provided string
bool starts_with( std::string_view String, std::string_view Suffix );
bool starts_with( std::string_view String, std::string_view Prefix );
template <typename Type_>
void SafeDelete( Type_ &Pointer ) {

View File

@@ -1,5 +1,5 @@
#pragma once
#define VERSION_MAJOR 21
#define VERSION_MINOR 426
#define VERSION_MINOR 508
#define VERSION_REVISION 0