Fix for switching off batteries with no active cabin and raising pantographs when deactivating cabin

This commit is contained in:
Królik Uszasty
2022-07-24 23:47:46 +02:00
committed by Milek7
parent 7b40fe9a72
commit a6ba375e7a
3 changed files with 47 additions and 15 deletions

View File

@@ -3963,20 +3963,7 @@ bool TDynamicObject::Update(double dt, double dt1)
if (MoverParameters->InactiveCabPantsCheck)
{
auto p = FindPantographCarrier();
bool isAnyPantUp = false;
if (p)
{
for (auto &item : p->MoverParameters->Pantographs)
{
isAnyPantUp |= item.is_active;
}
if (isAnyPantUp)
{
MoverParameters->OperatePantographValve(end::front, operation_t::enable);
MoverParameters->OperatePantographValve(end::rear, operation_t::enable);
}
}
pants_up();
MoverParameters->InactiveCabPantsCheck = false;
}
@@ -4009,6 +3996,42 @@ bool TDynamicObject::Update(double dt, double dt1)
return true; // Ra: chyba tak?
}
void TDynamicObject::pants_up()
{
TDynamicObject *d = this;
bool isAnyPantUp = false;
while (d) {
for (auto &item : d->MoverParameters->Pantographs)
{
isAnyPantUp |= item.is_active;
}
d = d->Next(4); // pozostałe też
}
d = Prev(4);
while (d) {
for (auto &item : d->MoverParameters->Pantographs)
{
isAnyPantUp |= item.is_active;
}
d = d->Prev(4); // w drugą stronę też
}
if (isAnyPantUp)
{
d = this;
while (d) {
d->MoverParameters->OperatePantographValve(end::front, operation_t::enable, range_t::local);
d->MoverParameters->OperatePantographValve(end::rear, operation_t::enable, range_t::local);
d = d->Next(4); // pozostałe też
}
d = Prev(4);
while (d) {
d->MoverParameters->OperatePantographValve(end::front, operation_t::enable, range_t::local);
d->MoverParameters->OperatePantographValve(end::rear, operation_t::enable, range_t::local);
d = d->Prev(4); // w drugą stronę też
}
}
}
glm::dvec3 TDynamicObject::get_future_movement() const
{
return m_future_movement;

View File

@@ -728,6 +728,7 @@ private:
bool remove_coupler_adapter( int const Side );
void RadioStop();
void Damage(char flag);
void pants_up();
void SetLights();
void RaLightsSet(int head, int rear);
int LightList( end const Side ) const { return iInventory[ Side ]; }

View File

@@ -3109,14 +3109,22 @@ bool TMoverParameters::BatterySwitch( bool State, range_t const Notify )
Battery = State;
}
//switching batteries does not require activation
if( Notify != range_t::local ) {
SendCtrlToNext(
"BatterySwitch",
( State ? 1 : 0 ),
CabActive,
1,
( Notify == range_t::unit ?
coupling::control | coupling::permanent :
coupling::control ) );
SendCtrlToNext(
"BatterySwitch",
(State ? 1 : 0),
-1,
(Notify == range_t::unit ?
coupling::control | coupling::permanent :
coupling::control));
}
return ( Battery != initialstate );