summaryrefslogtreecommitdiff
path: root/src/vehicle_gui.cpp
diff options
context:
space:
mode:
authormichi_cc <michi_cc@openttd.org>2011-11-04 00:38:59 +0000
committermichi_cc <michi_cc@openttd.org>2011-11-04 00:38:59 +0000
commit3f853e7a565fcd5e51f13f1c54079c83f625225b (patch)
tree996f3864a019e4e8f1eda2a2062736cfb0b5f28a /src/vehicle_gui.cpp
parent5ee765b2b2fc9756ab5c1bba8171e106ec6bd50f (diff)
downloadopenttd-3f853e7a565fcd5e51f13f1c54079c83f625225b.tar.xz
(svn r23089) -Add: Allow specifying refits for go-to station orders.
Diffstat (limited to 'src/vehicle_gui.cpp')
-rw-r--r--src/vehicle_gui.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index 2c3ee266e..5a2993516 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -371,6 +371,7 @@ struct RefitWindow : public Window {
int click_x; ///< Position of the first click while dragging.
VehicleID selected_vehicle; ///< First vehicle in the current selection.
uint8 num_vehicles; ///< Number of selected vehicles.
+ bool auto_refit; ///< Select cargo for auto-refitting.
/**
* Collects all (cargo, subcargo) refit options of a vehicle chain.
@@ -392,6 +393,8 @@ struct RefitWindow : public Window {
/* Skip this engine if it does not carry anything */
if (!e->CanCarryCargo()) continue;
+ /* Skip this engine if we build the list for auto-refitting and engine doesn't allow it. */
+ if (this->auto_refit && !HasBit(e->info.misc_flags, EF_AUTO_REFIT)) continue;
/* Loop through all cargos in the refit mask */
int current_index = 0;
@@ -479,9 +482,10 @@ struct RefitWindow : public Window {
return NULL;
}
- RefitWindow(const WindowDesc *desc, const Vehicle *v, VehicleOrderID order) : Window()
+ RefitWindow(const WindowDesc *desc, const Vehicle *v, VehicleOrderID order, bool auto_refit) : Window()
{
this->sel = -1;
+ this->auto_refit = auto_refit;
this->CreateNestedTree(desc);
this->vscroll = this->GetScrollbar(VRW_SCROLLBAR);
@@ -587,7 +591,7 @@ struct RefitWindow : public Window {
{
assert(_current_company == _local_company);
Vehicle *v = Vehicle::Get(this->window_number);
- CommandCost cost = DoCommand(v->tile, this->selected_vehicle, option->cargo | option->subtype << 8 |
+ CommandCost cost = DoCommand(v->tile, this->selected_vehicle, option->cargo | (int)this->auto_refit << 6 | option->subtype << 8 |
this->num_vehicles << 16, DC_QUERY_COST, GetCmdRefitVeh(v->type));
if (cost.Failed()) return INVALID_STRING_ID;
@@ -910,11 +914,12 @@ static const WindowDesc _vehicle_refit_desc(
* @param *v The vehicle to show the refit window for
* @param order of the vehicle ( ? )
* @param parent the parent window of the refit window
+ * @param auto_refit Choose cargo for auto-refitting
*/
-void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order, Window *parent)
+void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order, Window *parent, bool auto_refit)
{
DeleteWindowById(WC_VEHICLE_REFIT, v->index);
- RefitWindow *w = new RefitWindow(&_vehicle_refit_desc, v, order);
+ RefitWindow *w = new RefitWindow(&_vehicle_refit_desc, v, order, auto_refit);
w->parent = parent;
}