summaryrefslogtreecommitdiff
path: root/player_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 /player_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 'player_gui.c')
-rw-r--r--player_gui.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/player_gui.c b/player_gui.c
index 85cfdf19a..300abd686 100644
--- a/player_gui.c
+++ b/player_gui.c
@@ -422,24 +422,21 @@ static void DrawPlayerVehiclesAmount(PlayerID player)
const int x = 110;
int y = 72;
const Vehicle* v;
- uint train,road,air,ship;
+ uint train = 0;
+ uint road = 0;
+ uint air = 0;
+ uint ship = 0;
DrawString(x, y, STR_7039_VEHICLES, 0);
- train = road = air = ship = 0;
-
FOR_ALL_VEHICLES(v) {
if (v->owner == player) {
- if (v->type == VEH_Train) {
- if (v->subtype == TS_Front_Engine)
- train++;
- } else if (v->type == VEH_Road) {
- road++;
- } else if (v->type == VEH_Aircraft) {
- if (v->subtype <= 2)
- air++;
- } else if (v->type == VEH_Ship) {
- ship++;
+ switch (v->type) {
+ case VEH_Train: if (v->subtype == TS_Front_Engine) train++; break;
+ case VEH_Road: road++; break;
+ case VEH_Aircraft: if (v->subtype <= 2) air++; break;
+ case VEH_Ship: ship++; break;
+ default: break;
}
}
}