diff options
author | Charles Pigott <charlespigott@googlemail.com> | 2019-04-21 22:25:54 +0100 |
---|---|---|
committer | PeterN <peter@fuzzle.org> | 2019-04-29 17:40:22 +0100 |
commit | 69a6c494bfb81e332e63376f4577a104a5a8e679 (patch) | |
tree | cd34f49260fc2ac6cd825082f8d34f37e2e21f76 /src | |
parent | 96a47877104d99e117b9fd97e43908f9e9567ec5 (diff) | |
download | openttd-69a6c494bfb81e332e63376f4577a104a5a8e679.tar.xz |
Codechange: Set VehicleType's base type to byte instead of using VehicleTypeByte
Diffstat (limited to 'src')
-rw-r--r-- | src/engine_base.h | 2 | ||||
-rw-r--r-- | src/group.h | 16 | ||||
-rw-r--r-- | src/newgrf.cpp | 2 | ||||
-rw-r--r-- | src/smallmap_gui.cpp | 2 | ||||
-rw-r--r-- | src/vehicle_type.h | 8 |
5 files changed, 14 insertions, 16 deletions
diff --git a/src/engine_base.h b/src/engine_base.h index ad41f52f2..32c5c9bf6 100644 --- a/src/engine_base.h +++ b/src/engine_base.h @@ -148,7 +148,7 @@ struct Engine : EnginePool::PoolItem<&_engine_pool> { struct EngineIDMapping { uint32 grfid; ///< The GRF ID of the file the entity belongs to uint16 internal_id; ///< The internal ID within the GRF file - VehicleTypeByte type; ///< The engine type + VehicleType type; ///< The engine type uint8 substitute_id; ///< The (original) entity ID to use if this GRF is not available (currently not used) }; diff --git a/src/group.h b/src/group.h index 4c51e6ebd..6672cff67 100644 --- a/src/group.h +++ b/src/group.h @@ -65,17 +65,17 @@ struct GroupStatistics { /** Group data. */ struct Group : GroupPool::PoolItem<&_group_pool> { - char *name; ///< Group Name - OwnerByte owner; ///< Group Owner - VehicleTypeByte vehicle_type; ///< Vehicle type of the group + char *name; ///< Group Name + OwnerByte owner; ///< Group Owner + VehicleType vehicle_type; ///< Vehicle type of the group - bool replace_protection; ///< If set to true, the global autoreplace have no effect on the group - Livery livery; ///< Custom colour scheme for vehicles in this group - GroupStatistics statistics; ///< NOSAVE: Statistics and caches on the vehicles in the group. + bool replace_protection; ///< If set to true, the global autoreplace have no effect on the group + Livery livery; ///< Custom colour scheme for vehicles in this group + GroupStatistics statistics; ///< NOSAVE: Statistics and caches on the vehicles in the group. - bool folded; ///< NOSAVE: Is this group folded in the group view? + bool folded; ///< NOSAVE: Is this group folded in the group view? - GroupID parent; ///< Parent group + GroupID parent; ///< Parent group Group(CompanyID owner = INVALID_COMPANY); ~Group(); diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 20408394e..759c556a7 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -657,7 +657,7 @@ static Engine *GetNewEngine(const GRFFile *file, VehicleType type, uint16 intern _engine_mngr.push_back({ scope_grfid, // Note: this is INVALID_GRFID if dynamic_engines is disabled, so no reservation internal_id, - {static_cast<byte>(type)}, + type, static_cast<uint8>(min(internal_id, _engine_counts[type])) // substitute_id == _engine_counts[subtype] means "no substitute" }); diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index 58e89c57f..aa1e04815 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -566,7 +566,7 @@ static inline uint32 GetSmallMapOwnerPixels(TileIndex tile, TileType t) return MKCOLOUR_XXXX(_legend_land_owners[_company_to_list_pos[o]].colour); } -/** Vehicle colours in #SMT_VEHICLES mode. Indexed by #VehicleTypeByte. */ +/** Vehicle colours in #SMT_VEHICLES mode. Indexed by #VehicleType. */ static const byte _vehicle_type_colours[6] = { PC_RED, PC_YELLOW, PC_LIGHT_BLUE, PC_WHITE, PC_BLACK, PC_RED }; diff --git a/src/vehicle_type.h b/src/vehicle_type.h index 1bc5bcef4..74bd5660d 100644 --- a/src/vehicle_type.h +++ b/src/vehicle_type.h @@ -19,8 +19,8 @@ typedef uint32 VehicleID; static const int GROUND_ACCELERATION = 9800; ///< Acceleration due to gravity, 9.8 m/s^2 -/** Available vehicle types. */ -enum VehicleType { +/** Available vehicle types. It needs to be 8bits, because we save and load it as such */ +enum VehicleType : byte { VEH_BEGIN, VEH_TRAIN = VEH_BEGIN, ///< %Train vehicle type. @@ -39,8 +39,6 @@ enum VehicleType { DECLARE_POSTFIX_INCREMENT(VehicleType) /** Helper information for extract tool. */ template <> struct EnumPropsT<VehicleType> : MakeEnumPropsT<VehicleType, byte, VEH_TRAIN, VEH_END, VEH_INVALID, 3> {}; -/** It needs to be 8bits, because we save and load it as such */ -typedef SimpleTinyEnumT<VehicleType, byte> VehicleTypeByte; struct Vehicle; struct Train; @@ -53,7 +51,7 @@ struct DisasterVehicle; /** Base vehicle class. */ struct BaseVehicle { - VehicleTypeByte type; ///< Type of vehicle + VehicleType type; ///< Type of vehicle }; static const VehicleID INVALID_VEHICLE = 0xFFFFF; ///< Constant representing a non-existing vehicle. |