0x004A9B0B
| 124 | |
| 125 | // 0x004A9B0B |
| 126 | bool Vehicle2::update() |
| 127 | { |
| 128 | if (mode == TransportMode::air || mode == TransportMode::water) |
| 129 | { |
| 130 | return true; |
| 131 | } |
| 132 | Vehicle train(head); |
| 133 | |
| 134 | motorState = MotorState::accelerating; |
| 135 | const auto speedDiff = currentSpeed - train.veh1->targetSpeed; |
| 136 | if (speedDiff > 0.0_mph) |
| 137 | { |
| 138 | motorState = MotorState::braking; |
| 139 | const auto newSpeed = currentSpeed - (currentSpeed / 64 + 0.18311_mph); |
| 140 | currentSpeed = std::max(newSpeed, std::max<Speed32>(train.veh1->targetSpeed, 5.0_mph)); |
| 141 | return sub_4A9F20(); |
| 142 | } |
| 143 | |
| 144 | if (!train.head->hasVehicleFlags(VehicleFlags::manualControl)) |
| 145 | { |
| 146 | if (speedDiff >= -1.5_mph) |
| 147 | { |
| 148 | motorState = MotorState::coasting; |
| 149 | } |
| 150 | if (currentSpeed == 0.0_mph) |
| 151 | { |
| 152 | motorState = MotorState::stopped; |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | train.cars.applyToComponents([](auto& component) { |
| 157 | // If the vehicle is wheel slipping, then its wheel slipping value is incremented. |
| 158 | if (component.wheelSlipping != 0) |
| 159 | { |
| 160 | component.wheelSlipping++; |
| 161 | if (component.wheelSlipping >= kWheelSlippingDuration) |
| 162 | { |
| 163 | component.wheelSlipping = 0; |
| 164 | } |
| 165 | } |
| 166 | }); |
| 167 | |
| 168 | bool isOnRackRail = true; // Note has been inverted |
| 169 | bool isWheelSlipping = false; |
| 170 | int32_t ebp = 0; |
| 171 | for (auto& car : train.cars) |
| 172 | { |
| 173 | auto* frontBogie = car.front; |
| 174 | if (shouldStartWheelSlipping(train, *frontBogie)) |
| 175 | { |
| 176 | car.applyToComponents([](auto& component) { |
| 177 | component.wheelSlipping = 1; |
| 178 | }); |
| 179 | } |
| 180 | |
| 181 | if (frontBogie->wheelSlipping != 0) |
| 182 | { |
| 183 | isWheelSlipping = true; |
nothing calls this directly
no test coverage detected