1
0
Fork 0

Codechange: Set VehicleType's base type to byte instead of using VehicleTypeByte

pull/7551/head
Charles Pigott 2019-04-21 22:25:54 +01:00 committed by PeterN
parent 96a4787710
commit 69a6c494bf
5 changed files with 14 additions and 16 deletions

View File

@ -148,7 +148,7 @@ struct Engine : EnginePool::PoolItem<&_engine_pool> {
struct EngineIDMapping { struct EngineIDMapping {
uint32 grfid; ///< The GRF ID of the file the entity belongs to uint32 grfid; ///< The GRF ID of the file the entity belongs to
uint16 internal_id; ///< The internal ID within the GRF file 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) uint8 substitute_id; ///< The (original) entity ID to use if this GRF is not available (currently not used)
}; };

View File

@ -67,7 +67,7 @@ struct GroupStatistics {
struct Group : GroupPool::PoolItem<&_group_pool> { struct Group : GroupPool::PoolItem<&_group_pool> {
char *name; ///< Group Name char *name; ///< Group Name
OwnerByte owner; ///< Group Owner OwnerByte owner; ///< Group Owner
VehicleTypeByte vehicle_type; ///< Vehicle type of the group VehicleType vehicle_type; ///< Vehicle type of the group
bool replace_protection; ///< If set to true, the global autoreplace have no effect on 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 Livery livery; ///< Custom colour scheme for vehicles in this group

View File

@ -657,7 +657,7 @@ static Engine *GetNewEngine(const GRFFile *file, VehicleType type, uint16 intern
_engine_mngr.push_back({ _engine_mngr.push_back({
scope_grfid, // Note: this is INVALID_GRFID if dynamic_engines is disabled, so no reservation scope_grfid, // Note: this is INVALID_GRFID if dynamic_engines is disabled, so no reservation
internal_id, internal_id,
{static_cast<byte>(type)}, type,
static_cast<uint8>(min(internal_id, _engine_counts[type])) // substitute_id == _engine_counts[subtype] means "no substitute" static_cast<uint8>(min(internal_id, _engine_counts[type])) // substitute_id == _engine_counts[subtype] means "no substitute"
}); });

View File

@ -566,7 +566,7 @@ static inline uint32 GetSmallMapOwnerPixels(TileIndex tile, TileType t)
return MKCOLOUR_XXXX(_legend_land_owners[_company_to_list_pos[o]].colour); 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] = { static const byte _vehicle_type_colours[6] = {
PC_RED, PC_YELLOW, PC_LIGHT_BLUE, PC_WHITE, PC_BLACK, PC_RED PC_RED, PC_YELLOW, PC_LIGHT_BLUE, PC_WHITE, PC_BLACK, PC_RED
}; };

View File

@ -19,8 +19,8 @@ typedef uint32 VehicleID;
static const int GROUND_ACCELERATION = 9800; ///< Acceleration due to gravity, 9.8 m/s^2 static const int GROUND_ACCELERATION = 9800; ///< Acceleration due to gravity, 9.8 m/s^2
/** Available vehicle types. */ /** Available vehicle types. It needs to be 8bits, because we save and load it as such */
enum VehicleType { enum VehicleType : byte {
VEH_BEGIN, VEH_BEGIN,
VEH_TRAIN = VEH_BEGIN, ///< %Train vehicle type. VEH_TRAIN = VEH_BEGIN, ///< %Train vehicle type.
@ -39,8 +39,6 @@ enum VehicleType {
DECLARE_POSTFIX_INCREMENT(VehicleType) DECLARE_POSTFIX_INCREMENT(VehicleType)
/** Helper information for extract tool. */ /** Helper information for extract tool. */
template <> struct EnumPropsT<VehicleType> : MakeEnumPropsT<VehicleType, byte, VEH_TRAIN, VEH_END, VEH_INVALID, 3> {}; 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 Vehicle;
struct Train; struct Train;
@ -53,7 +51,7 @@ struct DisasterVehicle;
/** Base vehicle class. */ /** Base vehicle class. */
struct BaseVehicle struct BaseVehicle
{ {
VehicleTypeByte type; ///< Type of vehicle VehicleType type; ///< Type of vehicle
}; };
static const VehicleID INVALID_VEHICLE = 0xFFFFF; ///< Constant representing a non-existing vehicle. static const VehicleID INVALID_VEHICLE = 0xFFFFF; ///< Constant representing a non-existing vehicle.