* 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. */
| 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. |
no test coverage detected