summaryrefslogtreecommitdiff
path: root/vehicle_gui.c
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2006-10-03 14:52:39 +0000
committerbjarni <bjarni@openttd.org>2006-10-03 14:52:39 +0000
commitea63050d5f6e33e32917ff0df670638197a5ec05 (patch)
tree2957d8696ffee8fa709210c52f0ada2ce013e1bd /vehicle_gui.c
parent7b1053c35044e32ef959f3d8ef7a2e3ba06c9568 (diff)
downloadopenttd-ea63050d5f6e33e32917ff0df670638197a5ec05.tar.xz
(svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
Example: make a train transport iron ore from A to B, then it visits a depot and refits to steel It then transport steel back to A or near A if there is a factory and then it visits another depot to refit to iron ore again This is controlled in the orders. If a goto depot order is lightlighted, then "Unload" changes to "Refit" Control click "Refit" removes the refit part of the order (as the tooltip says) The player will still pay the normal refit costs Known issues: If a vehicle is not in a depot, then the refit window will fail to tell refitted cargo capacity Refit costs in the refit window can sometimes print 0 when it should not because the refit calculation is unaware that the vehicle will be refitted in between Warning: autoreplace got a protection against replacing something so you get a new cargo type, but it can fail here. In the iron ore/steel example, it can see that the vehicle carries iron ore and the new one can be refitted to iron ore, then it will replace. It will not check to see that it's valid for steel as well. This is something to look into in the future
Diffstat (limited to 'vehicle_gui.c')
-rw-r--r--vehicle_gui.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/vehicle_gui.c b/vehicle_gui.c
index 9fab39658..0b56eb0cb 100644
--- a/vehicle_gui.c
+++ b/vehicle_gui.c
@@ -373,15 +373,20 @@ static void VehicleRefitWndProc(Window *w, WindowEvent *e)
case 6: // refit button
if (WP(w,refit_d).cargo != NULL) {
const Vehicle *v = GetVehicle(w->window_number);
- int command = 0;
- switch (v->type) {
- case VEH_Train: command = CMD_REFIT_RAIL_VEHICLE | CMD_MSG(STR_RAIL_CAN_T_REFIT_VEHICLE); break;
- case VEH_Road: command = CMD_REFIT_ROAD_VEH | CMD_MSG(STR_REFIT_ROAD_VEHICLE_CAN_T); break;
- case VEH_Ship: command = CMD_REFIT_SHIP | CMD_MSG(STR_9841_CAN_T_REFIT_SHIP); break;
- case VEH_Aircraft: command = CMD_REFIT_AIRCRAFT | CMD_MSG(STR_A042_CAN_T_REFIT_AIRCRAFT); break;
+ if (WP(w, refit_d).order == INVALID_VEH_ORDER_ID) {
+ int command = 0;
+
+ switch (v->type) {
+ case VEH_Train: command = CMD_REFIT_RAIL_VEHICLE | CMD_MSG(STR_RAIL_CAN_T_REFIT_VEHICLE); break;
+ case VEH_Road: command = CMD_REFIT_ROAD_VEH | CMD_MSG(STR_REFIT_ROAD_VEHICLE_CAN_T); break;
+ case VEH_Ship: command = CMD_REFIT_SHIP | CMD_MSG(STR_9841_CAN_T_REFIT_SHIP); break;
+ case VEH_Aircraft: command = CMD_REFIT_AIRCRAFT | CMD_MSG(STR_A042_CAN_T_REFIT_AIRCRAFT); break;
+ }
+ if (DoCommandP(v->tile, v->index, WP(w,refit_d).cargo->cargo | WP(w,refit_d).cargo->subtype << 8, NULL, command)) DeleteWindow(w);
+ } else {
+ if (DoCommandP(v->tile, v->index, WP(w,refit_d).cargo->cargo | WP(w,refit_d).cargo->subtype << 8 | WP(w, refit_d).order << 16, NULL, CMD_ORDER_REFIT)) DeleteWindow(w);
}
- if (DoCommandP(v->tile, v->index, WP(w,refit_d).cargo->cargo | WP(w,refit_d).cargo->subtype << 8, NULL, command)) DeleteWindow(w);
}
break;
}
@@ -423,7 +428,7 @@ static const WindowDesc _vehicle_refit_desc = {
/** Show the refit window for a vehicle
* @param *v The vehicle to show the refit window for
*/
-void ShowVehicleRefitWindow(const Vehicle *v)
+void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order)
{
Window *w;
@@ -432,6 +437,7 @@ void ShowVehicleRefitWindow(const Vehicle *v)
_alloc_wnd_parent_num = v->index;
w = AllocateWindowDesc(&_vehicle_refit_desc);
+ WP(w, refit_d).order = order;
if (w != NULL) {
w->window_number = v->index;