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

Method OrderClick_Unload

src/order_gui.cpp:643–662  ·  view source on GitHub ↗

* Handle the click on the unload button. * @param unload_type Unload flag to apply. If matches existing unload type, toggles to default of 'unload if possible'. * @param toggle If we toggle or not (used for hotkey behavior) */

Source from the content-addressed store, hash-verified

641 * @param toggle If we toggle or not (used for hotkey behavior)
642 */
643 void OrderClick_Unload(OrderUnloadType unload_type, bool toggle = false)
644 {
645 VehicleOrderID sel_ord = this->OrderGetSel();
646 const Order *order = this->vehicle->GetOrder(sel_ord);
647
648 if (order == nullptr) return;
649
650 if (toggle && order->GetUnloadType() == unload_type) {
651 unload_type = OrderUnloadType::UnloadIfPossible;
652 }
653 if (order->GetUnloadType() == unload_type) return; // If we still match, do nothing
654
655 Command<CMD_MODIFY_ORDER>::Post(STR_ERROR_CAN_T_MODIFY_THIS_ORDER, this->vehicle->tile, this->vehicle->index, sel_ord, MOF_UNLOAD, to_underlying(unload_type));
656
657 /* Transfer and unload orders with leave empty as default */
658 if (unload_type == OrderUnloadType::Transfer || unload_type == OrderUnloadType::Unload) {
659 Command<CMD_MODIFY_ORDER>::Post(this->vehicle->tile, this->vehicle->index, sel_ord, MOF_LOAD, to_underlying(OrderLoadType::NoLoad));
660 this->SetWidgetDirty(WID_O_FULL_LOAD);
661 }
662 }
663
664 /**
665 * Handle the click on the nonstop button.

Callers 3

OnClickMethod · 0.95
OnDropdownSelectMethod · 0.95
OnHotkeyMethod · 0.95

Calls 5

OrderGetSelMethod · 0.95
to_underlyingFunction · 0.85
GetOrderMethod · 0.80
GetUnloadTypeMethod · 0.80
SetWidgetDirtyMethod · 0.80

Tested by

no test coverage detected