summaryrefslogtreecommitdiff
path: root/src/vehicle.h
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2007-01-22 16:16:52 +0000
committerbjarni <bjarni@openttd.org>2007-01-22 16:16:52 +0000
commit8de419641027504876d0703066ca35d41c874fb2 (patch)
tree52da6a14aed8a706e4a6b9bc3ff9ef4d252fcd38 /src/vehicle.h
parent053dd86a3cb33cb56fe0ad50b1e9ebb36ad7de2b (diff)
downloadopenttd-8de419641027504876d0703066ca35d41c874fb2.tar.xz
(svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
Diffstat (limited to 'src/vehicle.h')
-rw-r--r--src/vehicle.h45
1 files changed, 44 insertions, 1 deletions
diff --git a/src/vehicle.h b/src/vehicle.h
index 9a14c66f7..dc994b832 100644
--- a/src/vehicle.h
+++ b/src/vehicle.h
@@ -511,7 +511,50 @@ SpriteID GetVehiclePalette(const Vehicle *v);
* Best is to have a virtual value for it when it needs to change again */
#define STATUS_BAR 5
+extern const uint32 _veh_build_proc_table[];
+extern const uint32 _veh_sell_proc_table[];
+extern const uint32 _veh_refit_proc_table[];
extern const uint32 _send_to_depot_proc_table[];
-#define CMD_SEND_TO_DEPOT(x) _send_to_depot_proc_table[ x - VEH_Train]
+
+/* Functions to find the right command for certain vehicle type */
+static inline uint32 GetCmdBuildVeh(byte type)
+{
+ return _veh_build_proc_table[VehTypeToIndex(type)];
+}
+
+static inline uint32 GetCmdBuildVeh(const Vehicle *v)
+{
+ return GetCmdBuildVeh(v->type);
+}
+
+static inline uint32 GetCmdSellVeh(byte type)
+{
+ return _veh_sell_proc_table[VehTypeToIndex(type)];
+}
+
+static inline uint32 GetCmdSellVeh(const Vehicle *v)
+{
+ return GetCmdSellVeh(v->type);
+}
+
+static inline uint32 GetCmdRefitVeh(byte type)
+{
+ return _veh_refit_proc_table[VehTypeToIndex(type)];
+}
+
+static inline uint32 GetCmdRefitVeh(const Vehicle *v)
+{
+ return GetCmdRefitVeh(v->type);
+}
+
+static inline uint32 GetCmdSendToDepot(byte type)
+{
+ return _send_to_depot_proc_table[VehTypeToIndex(type)];
+}
+
+static inline uint32 GetCmdSendToDepot(const Vehicle *v)
+{
+ return GetCmdSendToDepot(v->type);
+}
#endif /* VEHICLE_H */