diff options
author | michi_cc <michi_cc@openttd.org> | 2011-12-13 00:43:35 +0000 |
---|---|---|
committer | michi_cc <michi_cc@openttd.org> | 2011-12-13 00:43:35 +0000 |
commit | def8e7215bdabee99ad49adedb8730ae33b6c47f (patch) | |
tree | 77accd58c6e79e746605fdf851b84720c7600836 /src/aircraft.h | |
parent | 686f51d810f9fa8303639c979f0ba76f1993ce9b (diff) | |
download | openttd-def8e7215bdabee99ad49adedb8730ae33b6c47f.tar.xz |
(svn r23504) -Feature: Aircraft range.
Diffstat (limited to 'src/aircraft.h')
-rw-r--r-- | src/aircraft.h | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/aircraft.h b/src/aircraft.h index 42463492c..8ba313cfa 100644 --- a/src/aircraft.h +++ b/src/aircraft.h @@ -25,17 +25,28 @@ enum AircraftSubType { AIR_ROTOR = 6 ///< rotor of an helicopter }; +/** Aircraft flags. */ +enum VehicleAirFlags { + VAF_DEST_TOO_FAR = 0, ///< Next destination is too far away. +}; + void HandleAircraftEnterHangar(Aircraft *v); void GetAircraftSpriteSize(EngineID engine, uint &width, uint &height, EngineImageType image_type); void UpdateAirplanesOnNewStation(const Station *st); -void UpdateAircraftCache(Aircraft *v); +void UpdateAircraftCache(Aircraft *v, bool update_range = false); void AircraftLeaveHangar(Aircraft *v, Direction exit_dir); void AircraftNextAirportPos_and_Order(Aircraft *v); void SetAircraftPosition(Aircraft *v, int x, int y, int z); int GetAircraftFlyingAltitude(const Aircraft *v); +/** Variables that are cached to improve performance and such. */ +struct AircraftCache { + uint32 cached_max_range_sqr; ///< Cached squared maximum range. + uint16 cached_max_range; ///< Cached maximum range. +}; + /** * Aircraft, helicopters, rotors and their shadows belong to this class. */ @@ -48,6 +59,9 @@ struct Aircraft : public SpecializedVehicle<Aircraft, VEH_AIRCRAFT> { DirectionByte last_direction; byte number_consecutive_turns; ///< Protection to prevent the aircraft of making a lot of turns in order to reach a specific point. byte turn_counter; ///< Ticks between each turn to prevent > 45 degree turns. + byte flags; ///< Aircraft flags. @see VehicleAirFlags + + AircraftCache acache; /** We don't want GCC to zero our struct! It already is zeroed and has an index! */ Aircraft() : SpecializedVehicleBase() {} @@ -83,6 +97,15 @@ struct Aircraft : public SpecializedVehicle<Aircraft, VEH_AIRCRAFT> { * return (this->subtype == AIR_HELICOPTER) || (this->subtype == AIR_AIRCRAFT); */ return this->subtype <= AIR_AIRCRAFT; } + + /** + * Get the range of this aircraft. + * @return Range in tiles or 0 if unlimited range. + */ + uint16 GetRange() const + { + return this->acache.cached_max_range; + } }; /** |