fix: release() caused loop by calling activate

Dieser Commit ist enthalten in:
Reinder Feenstra 2025-01-13 23:01:25 +01:00
Ursprung 712b317221
Commit bdcb5574f8

Datei anzeigen

@ -140,9 +140,13 @@ Train::Train(World& world, std::string_view _id) :
vehicles{this, "vehicles", nullptr, PropertyFlags::ReadOnly | PropertyFlags::Store | PropertyFlags::SubObject}, vehicles{this, "vehicles", nullptr, PropertyFlags::ReadOnly | PropertyFlags::Store | PropertyFlags::SubObject},
powered{this, "powered", false, PropertyFlags::ReadOnly | PropertyFlags::NoStore | PropertyFlags::ScriptReadOnly}, powered{this, "powered", false, PropertyFlags::ReadOnly | PropertyFlags::NoStore | PropertyFlags::ScriptReadOnly},
active{this, "active", false, PropertyFlags::ReadWrite | PropertyFlags::StoreState | PropertyFlags::ScriptReadOnly, active{this, "active", false, PropertyFlags::ReadWrite | PropertyFlags::StoreState | PropertyFlags::ScriptReadOnly,
[this](bool) [this](bool value)
{ {
updateSpeed(); updateSpeed();
if(!value && m_throttle)
{
m_throttle->release();
}
}, },
std::bind(&Train::setTrainActive, this, std::placeholders::_1)}, std::bind(&Train::setTrainActive, this, std::placeholders::_1)},
mode{this, "mode", TrainMode::ManualUnprotected, PropertyFlags::ReadWrite | PropertyFlags::StoreState | PropertyFlags::ScriptReadOnly}, mode{this, "mode", TrainMode::ManualUnprotected, PropertyFlags::ReadWrite | PropertyFlags::StoreState | PropertyFlags::ScriptReadOnly},
@ -440,11 +444,6 @@ bool Train::setTrainActive(bool val)
assert(vehicle->activeTrain.value() == self); assert(vehicle->activeTrain.value() == self);
vehicle->activeTrain.setValueInternal(nullptr); vehicle->activeTrain.setValueInternal(nullptr);
} }
if(m_throttle)
{
m_throttle->release();
}
} }
return true; return true;