* Insert a new order into the order chain. * @param new_order is the order to insert into the chain. * @param index is the position where the order is supposed to be inserted. */
| 415 | * @param index is the position where the order is supposed to be inserted. |
| 416 | */ |
| 417 | void OrderList::InsertOrderAt(Order &&order, VehicleOrderID index) |
| 418 | { |
| 419 | auto it = std::ranges::next(std::begin(this->orders), index, std::end(this->orders)); |
| 420 | auto new_order = this->orders.emplace(it, std::move(order)); |
| 421 | |
| 422 | if (!new_order->IsType(OT_IMPLICIT)) ++this->num_manual_orders; |
| 423 | this->timetable_duration += new_order->GetTimetabledWait() + new_order->GetTimetabledTravel(); |
| 424 | this->total_duration += new_order->GetWaitTime() + new_order->GetTravelTime(); |
| 425 | |
| 426 | /* We can visit oil rigs and buoys that are not our own. They will be shown in |
| 427 | * the list of stations. So, we need to invalidate that window if needed. */ |
| 428 | if (new_order->IsType(OT_GOTO_STATION) || new_order->IsType(OT_GOTO_WAYPOINT)) { |
| 429 | BaseStation *bs = BaseStation::Get(new_order->GetDestination().ToStationID()); |
| 430 | if (bs->owner == OWNER_NONE) InvalidateWindowClassesData(WC_STATION_LIST, 0); |
| 431 | } |
| 432 | } |
| 433 | |
| 434 | |
| 435 | /** |
no test coverage detected