summaryrefslogtreecommitdiff
path: root/src/vehicle_base.h
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-11-18 14:04:36 +0000
committerrubidium <rubidium@openttd.org>2010-11-18 14:04:36 +0000
commitf4689f43011da8500e3fbe2622e23bacac47e007 (patch)
tree5eaca0a04b188380a637a239bf675a200e789579 /src/vehicle_base.h
parent79c47ef8b06e98e551c28c768541ba62851d6888 (diff)
downloadopenttd-f4689f43011da8500e3fbe2622e23bacac47e007.tar.xz
(svn r21233) -Codechange: Introduce an enum to remove some magic numbers from the visual effect code (Hirundo)
Diffstat (limited to 'src/vehicle_base.h')
-rw-r--r--src/vehicle_base.h27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/vehicle_base.h b/src/vehicle_base.h
index 1cc503e17..55e81b2f0 100644
--- a/src/vehicle_base.h
+++ b/src/vehicle_base.h
@@ -64,17 +64,28 @@ struct NewGRFCache {
uint8 cache_valid; ///< Bitset that indicates which cache values are valid.
};
+/** Meaning of the various bits of the visual effect. */
+enum VisualEffect {
+ VE_OFFSET_START = 0, ///< First bit that contains the offset (0 = front, 8 = centre, 15 = rear)
+ VE_OFFSET_COUNT = 4, ///< Number of bits used for the offset
+ VE_OFFSET_CENTRE = 8, ///< Value of offset corresponding to a position above the centre of the vehicle
+
+ VE_TYPE_START = 4, ///< First bit used for the type of effect
+ VE_TYPE_COUNT = 2, ///< Number of bits used for the effect type
+ VE_TYPE_DEFAULT = 0, ///< Use default from engine class
+ VE_TYPE_STEAM = 1, ///< Steam plumes
+ VE_TYPE_DIESEL = 2, ///< Diesel fumes
+ VE_TYPE_ELECTRIC = 3, ///< Electric sparks
+
+ VE_DISABLE_EFFECT = 6, ///< Flag to disable visual effect
+ VE_DISABLE_WAGON_POWER = 7, ///< Flag to disable wagon power
+};
+
/** Cached often queried values common to all vehicles. */
struct VehicleCache {
uint16 cached_max_speed; ///< Maximum speed of the consist (minimum of the max speed of all vehicles in the consist).
- /**
- * Position/type of visual effect.
- * bit 0 - 3 = position of effect relative to vehicle. (0 = front, 8 = centre, 15 = rear)
- * bit 4 - 5 = type of effect. (0 = default for engine class, 1 = steam, 2 = diesel, 3 = electric)
- * bit 6 = disable visual effect.
- * bit 7 = disable powered wagons (trains only).
- */
- byte cached_vis_effect;
+
+ byte cached_vis_effect; ///< Visual effect to show (see #VisualEffect)
};
/** A vehicle pool for a little over 1 million vehicles. */