# HG changeset patch # User rubidium # Date 2011-12-10 19:20:30 # Node ID ed625b8206b55beccbcdb9d9776559bd288be6a7 # Parent 2989a4be1988741cd6387c9bbadf688140ca18a1 (svn r23484) -Fix [FS#4770]: in case you already have orders, ignore the vehicles when adding an extra order diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -838,12 +838,14 @@ struct DepotWindow : Window { /** * Clones a vehicle * @param v the original vehicle to clone + * @return Always true. */ - virtual void OnVehicleSelect(const Vehicle *v) + virtual bool OnVehicleSelect(const Vehicle *v) { if (DoCommandP(this->window_number, v->index, _ctrl_pressed ? 1 : 0, CMD_CLONE_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_TRAIN + v->type), CcCloneVehicle)) { ResetObjectToPlace(); } + return true; } virtual void OnPlaceObjectAbort() diff --git a/src/order_gui.cpp b/src/order_gui.cpp --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -1466,7 +1466,7 @@ public: } } - virtual void OnVehicleSelect(const Vehicle *v) + virtual bool OnVehicleSelect(const Vehicle *v) { /* v is vehicle getting orders. Only copy/clone orders if vehicle doesn't have any orders yet. * We disallow copying orders of other vehicles if we already have at least one order entry @@ -1474,13 +1474,14 @@ public: * Obviously if you press CTRL on a non-empty orders vehicle you know what you are doing * TODO: give a warning message */ bool share_order = _ctrl_pressed || this->goto_type == OPOS_SHARE; - if (this->vehicle->GetNumOrders() != 0 && !share_order) return; + if (this->vehicle->GetNumOrders() != 0 && !share_order) return false; if (DoCommandP(this->vehicle->tile, this->vehicle->index | (share_order ? CO_SHARE : CO_COPY) << 30, v->index, share_order ? CMD_CLONE_ORDER | CMD_MSG(STR_ERROR_CAN_T_SHARE_ORDER_LIST) : CMD_CLONE_ORDER | CMD_MSG(STR_ERROR_CAN_T_COPY_ORDER_LIST))) { this->selected_order = -1; ResetObjectToPlace(); } + return true; } virtual void OnPlaceObjectAbort() diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -2671,8 +2671,7 @@ bool VehicleClicked(const Vehicle *v) v = v->First(); if (!v->IsPrimaryVehicle()) return false; - _thd.GetCallbackWnd()->OnVehicleSelect(v); - return true; + return _thd.GetCallbackWnd()->OnVehicleSelect(v); } void StopGlobalFollowVehicle(const Vehicle *v) diff --git a/src/window_gui.h b/src/window_gui.h --- a/src/window_gui.h +++ b/src/window_gui.h @@ -667,8 +667,9 @@ public: /** * The user clicked on a vehicle while HT_VEHICLE has been set. * @param v clicked vehicle. It is guaranteed to be v->IsPrimaryVehicle() == true + * @return True if the click is handled, false if it is ignored. */ - virtual void OnVehicleSelect(const struct Vehicle *v) {} + virtual bool OnVehicleSelect(const struct Vehicle *v) { return false; } /** * The user cancelled a tile highlight mode that has been set.