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

Method FreeChain

src/order_cmd.cpp:293–314  ·  view source on GitHub ↗

* Free a complete order chain. * @param keep_orderlist If this is true only delete the orders, otherwise also delete the OrderList. * @note do not use on "current_order" vehicle orders! */

Source from the content-addressed store, hash-verified

291 * @note do not use on "current_order" vehicle orders!
292 */
293void OrderList::FreeChain(bool keep_orderlist)
294{
295 /* We can visit oil rigs and buoys that are not our own. They will be shown in
296 * the list of stations. So, we need to invalidate that window if needed. */
297 for (Order &order: this->orders) {
298 if (order.IsType(OT_GOTO_STATION) || order.IsType(OT_GOTO_WAYPOINT)) {
299 BaseStation *bs = BaseStation::GetIfValid(order.GetDestination().ToStationID());
300 if (bs != nullptr && bs->owner == OWNER_NONE) {
301 InvalidateWindowClassesData(WC_STATION_LIST, 0);
302 break;
303 }
304 }
305 }
306
307 if (keep_orderlist) {
308 this->orders.clear();
309 this->num_manual_orders = 0;
310 this->timetable_duration = 0;
311 } else {
312 delete this;
313 }
314}
315
316/**
317 * Get the next order which will make the given vehicle stop at a station

Callers 2

DeleteVehicleOrdersFunction · 0.80
AfterLoadGameFunction · 0.80

Calls 5

IsTypeMethod · 0.80
GetDestinationMethod · 0.80
ToStationIDMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected