From 96097b34a57feb7547c789b352e9b650fb2a9fea Mon Sep 17 00:00:00 2001 From: Charles Pigott Date: Mon, 22 Apr 2019 08:11:28 +0100 Subject: [PATCH] Codechange: Remove Direction*Byte types --- src/aircraft.h | 2 +- src/airport.h | 8 ++++---- src/direction_type.h | 6 ++---- src/ship.h | 10 +++++----- src/station_base.h | 2 +- src/table/airport_movement.h | 2 +- src/vehicle_base.h | 2 +- 7 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/aircraft.h b/src/aircraft.h index f4fce09be1..3abb86b4f0 100644 --- a/src/aircraft.h +++ b/src/aircraft.h @@ -79,7 +79,7 @@ struct Aircraft FINAL : public SpecializedVehicle { byte previous_pos; ///< Previous desired position of the aircraft. StationID targetairport; ///< Airport to go to next. byte state; ///< State of the airport. @see AirportMovementStates - DirectionByte last_direction; + Direction 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 AirVehicleFlags diff --git a/src/airport.h b/src/airport.h index 31c68ef002..9e9eee8703 100644 --- a/src/airport.h +++ b/src/airport.h @@ -130,10 +130,10 @@ static const uint64 /** A single location on an airport where aircraft can move to. */ struct AirportMovingData { - int16 x; ///< x-coordinate of the destination. - int16 y; ///< y-coordinate of the destination. - uint16 flag; ///< special flags when moving towards the destination. - DirectionByte direction; ///< Direction to turn the aircraft after reaching the destination. + int16 x; ///< x-coordinate of the destination. + int16 y; ///< y-coordinate of the destination. + uint16 flag; ///< special flags when moving towards the destination. + Direction direction; ///< Direction to turn the aircraft after reaching the destination. }; AirportMovingData RotateAirportMovingData(const AirportMovingData *orig, Direction rotation, uint num_tiles_x, uint num_tiles_y); diff --git a/src/direction_type.h b/src/direction_type.h index e6e08a182f..cf6b9f5cf1 100644 --- a/src/direction_type.h +++ b/src/direction_type.h @@ -23,7 +23,7 @@ * your viewport and not rotated by 45 degrees left or right to get * a "north" used in you games. */ -enum Direction { +enum Direction : byte { DIR_BEGIN = 0, ///< Used to iterate DIR_N = 0, ///< North DIR_NE = 1, ///< Northeast @@ -42,7 +42,6 @@ DECLARE_POSTFIX_INCREMENT(Direction) /** Define basic enum properties */ template <> struct EnumPropsT : MakeEnumPropsT {}; -typedef TinyEnumT DirectionByte; ///< typedefing-enumification of Direction /** @@ -77,7 +76,7 @@ enum DirDiff { * * This enumeration is used for the 4 direction of the tile-edges. */ -enum DiagDirection { +enum DiagDirection : byte { DIAGDIR_BEGIN = 0, ///< Used for iterations DIAGDIR_NE = 0, ///< Northeast, upper right on your monitor DIAGDIR_SE = 1, ///< Southeast @@ -92,7 +91,6 @@ DECLARE_POSTFIX_INCREMENT(DiagDirection) /** Define basic enum properties */ template <> struct EnumPropsT : MakeEnumPropsT {}; -typedef TinyEnumT DiagDirectionByte; ///< typedefing-enumification of DiagDirection /** diff --git a/src/ship.h b/src/ship.h index 807e69c5e6..fff0aee5cb 100644 --- a/src/ship.h +++ b/src/ship.h @@ -26,11 +26,11 @@ typedef std::deque ShipPathCache; * All ships have this type. */ struct Ship FINAL : public SpecializedVehicle { - TrackBits state; ///< The "track" the ship is following. - ShipPathCache path; ///< Cached path. - DirectionByte rotation; ///< Visible direction. - int16 rotation_x_pos; ///< NOSAVE: X Position before rotation. - int16 rotation_y_pos; ///< NOSAVE: Y Position before rotation. + TrackBits state; ///< The "track" the ship is following. + ShipPathCache path; ///< Cached path. + Direction rotation; ///< Visible direction. + int16 rotation_x_pos; ///< NOSAVE: X Position before rotation. + int16 rotation_y_pos; ///< NOSAVE: Y Position before rotation. /** We don't want GCC to zero our struct! It already is zeroed and has an index! */ Ship() : SpecializedVehicleBase() {} diff --git a/src/station_base.h b/src/station_base.h index b211e2bd48..a0cb2c015f 100644 --- a/src/station_base.h +++ b/src/station_base.h @@ -310,7 +310,7 @@ struct Airport : public TileArea { uint64 flags; ///< stores which blocks on the airport are taken. was 16 bit earlier on, then 32 byte type; ///< Type of this airport, @see AirportTypes byte layout; ///< Airport layout number. - DirectionByte rotation; ///< How this airport is rotated. + Direction rotation; ///< How this airport is rotated. PersistentStorage *psa; ///< Persistent storage for NewGRF airports. diff --git a/src/table/airport_movement.h b/src/table/airport_movement.h index d9030f652c..df368de892 100644 --- a/src/table/airport_movement.h +++ b/src/table/airport_movement.h @@ -34,7 +34,7 @@ struct AirportFTAbuildup { * @param flags Movement flags. * @param dir Direction. */ -#define AMD(x, y, flags, dir) { x, y, flags, {dir} } +#define AMD(x, y, flags, dir) { x, y, flags, dir } /** Dummy airport. */ static const AirportMovingData _airport_moving_data_dummy[] = { diff --git a/src/vehicle_base.h b/src/vehicle_base.h index 523f1c2638..9ccb671138 100644 --- a/src/vehicle_base.h +++ b/src/vehicle_base.h @@ -268,7 +268,7 @@ public: int32 x_pos; ///< x coordinate. int32 y_pos; ///< y coordinate. int32 z_pos; ///< z coordinate. - DirectionByte direction; ///< facing + Direction direction; ///< facing OwnerByte owner; ///< Which company owns the vehicle? /**