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

Reworked some actions durin cab (de)activation

This commit is contained in:
Królik Uszasty
2022-02-20 22:41:31 +01:00
parent 3da4a42156
commit 827a3394df
4 changed files with 61 additions and 5 deletions

View File

@@ -3947,6 +3947,26 @@ bool TDynamicObject::Update(double dt, double dt1)
toggle_lights();
}
if (MoverParameters->InactiveCabPantsCheck)
{
auto p = FindPantographCarrier();
bool isAnyPantUp = false;
if (p)
{
for each (auto item in p->MoverParameters->Pantographs)
{
isAnyPantUp |= item.is_active;
}
if (isAnyPantUp)
{
MoverParameters->OperatePantographValve(end::front, operation_t::enable);
MoverParameters->OperatePantographValve(end::rear, operation_t::enable);
}
}
MoverParameters->InactiveCabPantsCheck = false;
}
if (MoverParameters->DerailReason > 0)
{
switch (MoverParameters->DerailReason)
@@ -6855,11 +6875,13 @@ void TDynamicObject::Damage(char flag)
void TDynamicObject::SetLights() {
auto const isfrontcaboccupied { MoverParameters->CabOccupied * DirectionGet() >= 0 };
int const automaticmarkers { MoverParameters->CabActive == 0 && ( MoverParameters->InactiveCabFlag & activation::redmarkers )
? light::redmarker_left + light::redmarker_right : 0 };
int const front { ( isfrontcaboccupied ? end::front : end::rear ) };
int const rear { 1 - front };
auto const lightpos { MoverParameters->LightsPos - 1 };
auto const frontlights { MoverParameters->Lights[ front ][ lightpos ] };
auto const rearlights { MoverParameters->Lights[ rear ][ lightpos ] };
auto const frontlights { automaticmarkers > 0 ? automaticmarkers : MoverParameters->Lights[ front ][ lightpos ] };
auto const rearlights { automaticmarkers > 0 ? automaticmarkers : MoverParameters->Lights[ rear ][ lightpos ] };
auto *vehicle { GetFirstDynamic( MoverParameters->CabOccupied >= 0 ? end::front : end::rear, coupling::control ) };
while( vehicle != nullptr ) {
// set lights on given side if there's no coupling with another vehicle, turn them off otherwise