* 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! */
| 291 | * @note do not use on "current_order" vehicle orders! |
| 292 | */ |
| 293 | void 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 |
no test coverage detected