* Checks for internal consistency of order list. Triggers assertion if something is wrong. */
| 498 | * Checks for internal consistency of order list. Triggers assertion if something is wrong. |
| 499 | */ |
| 500 | void OrderList::DebugCheckSanity() const |
| 501 | { |
| 502 | VehicleOrderID check_num_orders = 0; |
| 503 | VehicleOrderID check_num_manual_orders = 0; |
| 504 | uint check_num_vehicles = 0; |
| 505 | TimerGameTick::Ticks check_timetable_duration = 0; |
| 506 | TimerGameTick::Ticks check_total_duration = 0; |
| 507 | |
| 508 | Debug(misc, 6, "Checking OrderList {} for sanity...", this->index); |
| 509 | |
| 510 | for (const Order &o : this->orders) { |
| 511 | ++check_num_orders; |
| 512 | if (!o.IsType(OT_IMPLICIT)) ++check_num_manual_orders; |
| 513 | check_timetable_duration += o.GetTimetabledWait() + o.GetTimetabledTravel(); |
| 514 | check_total_duration += o.GetWaitTime() + o.GetTravelTime(); |
| 515 | } |
| 516 | assert(this->GetNumOrders() == check_num_orders); |
| 517 | assert(this->num_manual_orders == check_num_manual_orders); |
| 518 | assert(this->timetable_duration == check_timetable_duration); |
| 519 | assert(this->total_duration == check_total_duration); |
| 520 | |
| 521 | for (const Vehicle *v = this->first_shared; v != nullptr; v = v->NextShared()) { |
| 522 | ++check_num_vehicles; |
| 523 | assert(v->orders == this); |
| 524 | } |
| 525 | assert(this->num_vehicles == check_num_vehicles); |
| 526 | Debug(misc, 6, "... detected {} orders ({} manual), {} vehicles, {} timetabled, {} total", |
| 527 | (uint)this->GetNumOrders(), (uint)this->num_manual_orders, |
| 528 | this->num_vehicles, this->timetable_duration, this->total_duration); |
| 529 | } |
| 530 | #endif |
| 531 | |
| 532 | /** |
no test coverage detected