diff --git a/server/src/train/train.cpp b/server/src/train/train.cpp index a1224c4e..802e0c82 100644 --- a/server/src/train/train.cpp +++ b/server/src/train/train.cpp @@ -140,9 +140,13 @@ Train::Train(World& world, std::string_view _id) : vehicles{this, "vehicles", nullptr, PropertyFlags::ReadOnly | PropertyFlags::Store | PropertyFlags::SubObject}, powered{this, "powered", false, PropertyFlags::ReadOnly | PropertyFlags::NoStore | PropertyFlags::ScriptReadOnly}, active{this, "active", false, PropertyFlags::ReadWrite | PropertyFlags::StoreState | PropertyFlags::ScriptReadOnly, - [this](bool) + [this](bool value) { updateSpeed(); + if(!value && m_throttle) + { + m_throttle->release(); + } }, std::bind(&Train::setTrainActive, this, std::placeholders::_1)}, 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); vehicle->activeTrain.setValueInternal(nullptr); } - - if(m_throttle) - { - m_throttle->release(); - } } return true;