* Handle the loading of the vehicle; when not it skips through dummy * orders and does nothing in all other cases. * @param mode is the non-first call for this vehicle in this tick? */
| 2405 | * @param mode is the non-first call for this vehicle in this tick? |
| 2406 | */ |
| 2407 | void Vehicle::HandleLoading(bool mode) |
| 2408 | { |
| 2409 | switch (this->current_order.GetType()) { |
| 2410 | case OT_LOADING: { |
| 2411 | TimerGameTick::Ticks wait_time = std::max(this->current_order.GetTimetabledWait() - this->lateness_counter, 0); |
| 2412 | |
| 2413 | /* Not the first call for this tick, or still loading */ |
| 2414 | if (mode || !this->vehicle_flags.Test(VehicleFlag::LoadingFinished) || this->current_order_time < wait_time) return; |
| 2415 | |
| 2416 | this->PlayLeaveStationSound(); |
| 2417 | |
| 2418 | this->LeaveStation(); |
| 2419 | |
| 2420 | /* Only advance to next order if we just loaded at the current one */ |
| 2421 | const Order *order = this->GetOrder(this->cur_implicit_order_index); |
| 2422 | if (order == nullptr || |
| 2423 | (!order->IsType(OT_IMPLICIT) && !order->IsType(OT_GOTO_STATION)) || |
| 2424 | order->GetDestination() != this->last_station_visited) { |
| 2425 | return; |
| 2426 | } |
| 2427 | break; |
| 2428 | } |
| 2429 | |
| 2430 | case OT_DUMMY: break; |
| 2431 | |
| 2432 | default: return; |
| 2433 | } |
| 2434 | |
| 2435 | this->IncrementImplicitOrderIndex(); |
| 2436 | } |
| 2437 | |
| 2438 | /** |
| 2439 | * Check if the current vehicle has a full load order. |
no test coverage detected