MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / InsertOrderAt

Method InsertOrderAt

src/order_cmd.cpp:417–432  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

415 * @param index is the position where the order is supposed to be inserted.
416 */
417void 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/**

Callers 1

InsertOrderFunction · 0.80

Calls 10

IsTypeMethod · 0.80
GetTimetabledWaitMethod · 0.80
GetTimetabledTravelMethod · 0.80
GetWaitTimeMethod · 0.80
GetTravelTimeMethod · 0.80
GetDestinationMethod · 0.80
beginFunction · 0.50
endFunction · 0.50
ToStationIDMethod · 0.45

Tested by

no test coverage detected