summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2009-10-06 19:56:43 +0000
committerfrosch <frosch@openttd.org>2009-10-06 19:56:43 +0000
commit1cab0dbc1d87da383efbc328087cce0c19b313bb (patch)
tree2bed4706eed1cc785b01928a528090101c118a80
parent9a9d0ee7c0234ed2ecec490f72746622926e8fe7 (diff)
downloadopenttd-1cab0dbc1d87da383efbc328087cce0c19b313bb.tar.xz
(svn r17729) -Cleanup: Deduplicate some code.
-rw-r--r--src/build_vehicle_gui.cpp50
1 files changed, 22 insertions, 28 deletions
diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp
index 2f6a5771c..a6920a925 100644
--- a/src/build_vehicle_gui.cpp
+++ b/src/build_vehicle_gui.cpp
@@ -629,53 +629,47 @@ int DrawVehiclePurchaseInfo(int left, int right, int y, EngineID engine_number)
YearMonthDay ymd;
ConvertDateToYMD(e->intro_date, &ymd);
bool refittable = IsArticulatedVehicleRefittable(engine_number);
+ bool articulated_cargo = false;
switch (e->type) {
default: NOT_REACHED();
- case VEH_TRAIN: {
+ case VEH_TRAIN:
if (e->u.rail.railveh_type == RAILVEH_WAGON) {
y = DrawRailWagonPurchaseInfo(left, right, y, engine_number, &e->u.rail);
} else {
y = DrawRailEnginePurchaseInfo(left, right, y, engine_number, &e->u.rail);
}
-
- /* Cargo type + capacity, or N/A */
- int new_y = DrawCargoCapacityInfo(left, right, y, engine_number, refittable);
-
- if (new_y == y) {
- SetDParam(0, CT_INVALID);
- SetDParam(2, STR_EMPTY);
- DrawString(left, right, y, STR_PURCHASE_INFO_CAPACITY);
- y += FONT_HEIGHT_NORMAL;
- } else {
- y = new_y;
- }
+ articulated_cargo = true;
break;
- }
- case VEH_ROAD: {
- y = DrawRoadVehPurchaseInfo(left, right, y, engine_number);
-
- /* Cargo type + capacity, or N/A */
- int new_y = DrawCargoCapacityInfo(left, right, y, engine_number, refittable);
- if (new_y == y) {
- SetDParam(0, CT_INVALID);
- SetDParam(2, STR_EMPTY);
- DrawString(left, right, y, STR_PURCHASE_INFO_CAPACITY);
- y += FONT_HEIGHT_NORMAL;
- } else {
- y = new_y;
- }
+ case VEH_ROAD:
+ y = DrawRoadVehPurchaseInfo(left, right, y, engine_number);
+ articulated_cargo = true;
break;
- }
+
case VEH_SHIP:
y = DrawShipPurchaseInfo(left, right, y, engine_number, &e->u.ship, refittable);
break;
+
case VEH_AIRCRAFT:
y = DrawAircraftPurchaseInfo(left, right, y, engine_number, &e->u.air, refittable);
break;
}
+ if (articulated_cargo) {
+ /* Cargo type + capacity, or N/A */
+ int new_y = DrawCargoCapacityInfo(left, right, y, engine_number, refittable);
+
+ if (new_y == y) {
+ SetDParam(0, CT_INVALID);
+ SetDParam(2, STR_EMPTY);
+ DrawString(left, right, y, STR_PURCHASE_INFO_CAPACITY);
+ y += FONT_HEIGHT_NORMAL;
+ } else {
+ y = new_y;
+ }
+ }
+
/* Draw details, that applies to all types except rail wagons */
if (e->type != VEH_TRAIN || e->u.rail.railveh_type != RAILVEH_WAGON) {
/* Design date - Life length */