summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2007-02-17 17:12:19 +0000
committerbjarni <bjarni@openttd.org>2007-02-17 17:12:19 +0000
commit4bcf385f3147760e89467a8a45cf67a2fb4773b6 (patch)
treea0bc46b7d3619a4d41b511464dffb81ac3592113
parent06296d98b71a0d7bdba64d9d51119b23220ed518 (diff)
downloadopenttd-4bcf385f3147760e89467a8a45cf67a2fb4773b6.tar.xz
(svn r8786) -Cleanup: replaced a switch-case to get the right refit command for a certain vehicle type. We have a function to do that
-rw-r--r--src/vehicle_gui.cpp12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index 25c7a54ab..76fa24b50 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -346,15 +346,11 @@ static void VehicleRefitWndProc(Window *w, WindowEvent *e)
WP(w,refit_d).cargo = DrawVehicleRefitWindow(WP(w, refit_d).list, WP(w, refit_d).sel, w->vscroll.pos, w->vscroll.cap, w->resize.step_height);
if (WP(w,refit_d).cargo != NULL) {
- int32 cost = 0;
- switch (GetVehicle(w->window_number)->type) {
- case VEH_Train: cost = CMD_REFIT_RAIL_VEHICLE; break;
- case VEH_Road: cost = CMD_REFIT_ROAD_VEH; break;
- case VEH_Ship: cost = CMD_REFIT_SHIP; break;
- case VEH_Aircraft: cost = CMD_REFIT_AIRCRAFT; break;
- }
+ int32 cost;
+
+ cost = DoCommand(v->tile, v->index, WP(w,refit_d).cargo->cargo | WP(w,refit_d).cargo->subtype << 8,
+ DC_QUERY_COST, GetCmdRefitVeh(GetVehicle(w->window_number)->type));
- cost = DoCommand(v->tile, v->index, WP(w,refit_d).cargo->cargo | WP(w,refit_d).cargo->subtype << 8, DC_QUERY_COST, cost);
if (!CmdFailed(cost)) {
SetDParam(0, WP(w,refit_d).cargo->cargo);
SetDParam(1, _returned_refit_capacity);