summaryrefslogtreecommitdiff
path: root/order_gui.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2005-11-13 14:54:09 +0000
committertron <tron@openttd.org>2005-11-13 14:54:09 +0000
commit53f00c8f9de83c73742ed6a746e6e7aec535b26a (patch)
tree0bcf189f35802c7769cd23e20ed58a18b59d9b2e /order_gui.c
parent81e5b16d7178f0ee5584201cb2f6c8e36742354f (diff)
downloadopenttd-53f00c8f9de83c73742ed6a746e6e7aec535b26a.tar.xz
(svn r3173) Use the trinary operator and switch to improve readability
Also align short cases nicely
Diffstat (limited to 'order_gui.c')
-rw-r--r--order_gui.c52
1 files changed, 27 insertions, 25 deletions
diff --git a/order_gui.c b/order_gui.c
index 04c0688ed..e7b1ccba5 100644
--- a/order_gui.c
+++ b/order_gui.c
@@ -127,37 +127,39 @@ static void DrawOrdersWindow(Window *w)
if (i - w->vscroll.pos < w->vscroll.cap) {
SetDParam(1, 6);
- if (order->type == OT_GOTO_STATION) {
- SetDParam(1, StationOrderStrings[order->flags]);
- SetDParam(2, order->station);
- } else if (order->type == OT_GOTO_DEPOT) {
- StringID s = STR_NULL;
-
- if (v->type == VEH_Aircraft) {
- s = STR_GO_TO_AIRPORT_HANGAR;
+ switch (order->type) {
+ case OT_GOTO_STATION:
+ SetDParam(1, StationOrderStrings[order->flags]);
SetDParam(2, order->station);
- } else {
- SetDParam(2, GetDepot(order->station)->town_index);
-
- switch (v->type) {
- case VEH_Train: s = STR_GO_TO_TRAIN_DEPOT; break;
- case VEH_Road: s = STR_9038_GO_TO_ROADVEH_DEPOT; break;
- case VEH_Ship: s = STR_GO_TO_SHIP_DEPOT; break;
- default:
- break;
+ break;
+
+ case OT_GOTO_DEPOT: {
+ StringID s = STR_NULL;
+
+ if (v->type == VEH_Aircraft) {
+ s = STR_GO_TO_AIRPORT_HANGAR;
+ SetDParam(2, order->station);
+ } else {
+ SetDParam(2, GetDepot(order->station)->town_index);
+
+ switch (v->type) {
+ case VEH_Train: s = (order->flags & OF_NON_STOP) ? STR_880F_GO_NON_STOP_TO_TRAIN_DEPOT : STR_GO_TO_TRAIN_DEPOT; break;
+ case VEH_Road: s = STR_9038_GO_TO_ROADVEH_DEPOT; break;
+ case VEH_Ship: s = STR_GO_TO_SHIP_DEPOT; break;
+ default: break;
+ }
}
- if (v->type == VEH_Train && order->flags & OF_NON_STOP) s += 2;
+ if (order->flags & OF_FULL_LOAD) s++; /* service at */
+
SetDParam(1, s);
+ break;
}
- if (order->flags & OF_FULL_LOAD)
- s++; /* service at */
-
- SetDParam(1, s);
- } else if (order->type == OT_GOTO_WAYPOINT) {
- SetDParam(1, (order->flags & OF_NON_STOP) ? STR_GO_NON_STOP_TO_WAYPOINT : STR_GO_TO_WAYPOINT);
- SetDParam(2, order->station);
+ case OT_GOTO_WAYPOINT:
+ SetDParam(1, (order->flags & OF_NON_STOP) ? STR_GO_NON_STOP_TO_WAYPOINT : STR_GO_TO_WAYPOINT);
+ SetDParam(2, order->station);
+ break;
}
color = (i == WP(w,order_d).sel) ? 0xC : 0x10;