diff options
author | smatz <smatz@openttd.org> | 2008-04-24 09:55:20 +0000 |
---|---|---|
committer | smatz <smatz@openttd.org> | 2008-04-24 09:55:20 +0000 |
commit | 26206fa11682313e8cbe2f19441c5dbdce63ef74 (patch) | |
tree | 425b0f3d08a6a6ba4e8c57af527383861642e162 /src/vehicle_gui.h | |
parent | 1a26e293330e6e2622547692af7e96056e9207bc (diff) | |
download | openttd-26206fa11682313e8cbe2f19441c5dbdce63ef74.tar.xz |
(svn r12862) -Codechange: reduce code duplication for VehicleType -> WindowClass lookup
Diffstat (limited to 'src/vehicle_gui.h')
-rw-r--r-- | src/vehicle_gui.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/vehicle_gui.h b/src/vehicle_gui.h index d9e4ff173..e10ed2c18 100644 --- a/src/vehicle_gui.h +++ b/src/vehicle_gui.h @@ -99,6 +99,22 @@ static inline uint GetVehicleListHeight(VehicleType type) return (type == VEH_TRAIN || type == VEH_ROAD) ? 14 : 24; } +/** Get WindowClass for vehicle list of given vehicle type + * @param vt vehicle type to check + * @return corresponding window class + * @note works only for player buildable vehicle types + */ +static inline WindowClass GetWindowClassForVehicleType(VehicleType vt) +{ + switch (vt) { + default: NOT_REACHED(); + case VEH_TRAIN: return WC_TRAINS_LIST; + case VEH_ROAD: return WC_ROADVEH_LIST; + case VEH_SHIP: return WC_SHIPS_LIST; + case VEH_AIRCRAFT: return WC_AIRCRAFT_LIST; + } +} + /* Unified window procedure */ void ShowVehicleViewWindow(const Vehicle *v); |