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;