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

Method OrderClick_StopSharing

src/order_gui.cpp:720–736  ·  view source on GitHub ↗

* Handle the click on the 'stop sharing' button. * If 'End of Shared Orders' isn't selected, do nothing. If Ctrl is pressed, call OrderClick_Delete and exit. * To stop sharing this vehicle order list, we copy the orders of a vehicle that share this order list. That way we * exit the group of shared vehicles while keeping the same order list. */

Source from the content-addressed store, hash-verified

718 * exit the group of shared vehicles while keeping the same order list.
719 */
720 void OrderClick_StopSharing()
721 {
722 /* Don't try to stop sharing orders if 'End of Shared Orders' isn't selected. */
723 if (!this->vehicle->IsOrderListShared() || this->selected_order != this->vehicle->GetNumOrders()) return;
724 /* If Ctrl is pressed, delete the order list as if we clicked the 'Delete' button. */
725 if (_ctrl_pressed) {
726 this->OrderClick_Delete();
727 return;
728 }
729
730 /* Get another vehicle that share orders with this vehicle. */
731 Vehicle *other_shared = (this->vehicle->FirstShared() == this->vehicle) ? this->vehicle->NextShared() : this->vehicle->PreviousShared();
732 /* Copy the order list of the other vehicle. */
733 if (Command<CMD_CLONE_ORDER>::Post(STR_ERROR_CAN_T_STOP_SHARING_ORDER_LIST, this->vehicle->tile, CO_COPY, this->vehicle->index, other_shared->index)) {
734 this->UpdateButtonState();
735 }
736 }
737
738 /**
739 * Handle the click on the refit button.

Callers 2

OnClickMethod · 0.95
OnDragDropMethod · 0.95

Calls 7

OrderClick_DeleteMethod · 0.95
UpdateButtonStateMethod · 0.95
IsOrderListSharedMethod · 0.80
FirstSharedMethod · 0.80
NextSharedMethod · 0.80
PreviousSharedMethod · 0.80
GetNumOrdersMethod · 0.45

Tested by

no test coverage detected