diff --git a/src/cargo_type.h b/src/cargo_type.h index 9f882bdd3e..66955dddf2 100644 --- a/src/cargo_type.h +++ b/src/cargo_type.h @@ -12,6 +12,7 @@ #include "core/enum_type.hpp" #include "core/strong_typedef_type.hpp" +#include "core/convertible_through_base.hpp" /** Globally unique label of a cargo type. */ using CargoLabel = StrongType::Typedef; diff --git a/src/cargomonitor.h b/src/cargomonitor.h index 6157d04ccb..9d76e8ce32 100644 --- a/src/cargomonitor.h +++ b/src/cargomonitor.h @@ -61,7 +61,7 @@ inline CargoMonitorID EncodeCargoIndustryMonitor(CompanyID company, CargoType ct assert(company < (1 << CCB_COMPANY_LENGTH)); uint32_t ret = 0; - SB(ret, CCB_TOWN_IND_NUMBER_START, CCB_TOWN_IND_NUMBER_LENGTH, ind); + SB(ret, CCB_TOWN_IND_NUMBER_START, CCB_TOWN_IND_NUMBER_LENGTH, ind.base()); SetBit(ret, CCB_IS_INDUSTRY_BIT); SB(ret, CCB_CARGO_TYPE_START, CCB_CARGO_TYPE_LENGTH, ctype); SB(ret, CCB_COMPANY_START, CCB_COMPANY_LENGTH, company.base()); diff --git a/src/clear_map.h b/src/clear_map.h index 4399d2c169..765a8d60d1 100644 --- a/src/clear_map.h +++ b/src/clear_map.h @@ -207,7 +207,7 @@ inline IndustryID GetIndustryIndexOfField(Tile t) inline void SetIndustryIndexOfField(Tile t, IndustryID i) { assert(GetClearGround(t) == CLEAR_FIELDS); - t.m2() = i; + t.m2() = i.base(); } @@ -282,7 +282,7 @@ inline void MakeField(Tile t, uint field_type, IndustryID industry) SetTileType(t, MP_CLEAR); t.m1() = 0; SetTileOwner(t, OWNER_NONE); - t.m2() = industry; + t.m2() = industry.base(); t.m3() = field_type; t.m4() = 0 << 5 | 0 << 2; SetClearGroundDensity(t, CLEAR_FIELDS, 3); diff --git a/src/disaster_vehicle.cpp b/src/disaster_vehicle.cpp index caf458e3bb..54e8b22921 100644 --- a/src/disaster_vehicle.cpp +++ b/src/disaster_vehicle.cpp @@ -479,7 +479,7 @@ static bool DisasterTick_Aircraft(DisasterVehicle *v, uint16_t image_override, b if (!IsTileType(tile, MP_INDUSTRY)) return true; IndustryID ind = GetIndustryIndex(tile); - v->dest_tile = TileIndex{ind}; + v->dest_tile = TileIndex{ind.base()}; if (GetIndustrySpec(Industry::Get(ind)->type)->behaviour.Test(behaviour)) { v->state = 1; @@ -969,7 +969,7 @@ void ReleaseDisastersTargetingIndustry(IndustryID i) /* primary disaster vehicles that have chosen target */ if (v->subtype == ST_AIRPLANE || v->subtype == ST_HELICOPTER) { /* if it has chosen target, and it is this industry (yes, dest_tile is IndustryID here), set order to "leaving map peacefully" */ - if (v->state > 0 && v->dest_tile == (uint32_t)i) v->state = 3; + if (v->state > 0 && v->dest_tile == i.base()) v->state = 3; } } } diff --git a/src/industry.h b/src/industry.h index 2e2182b0d6..4ddcd5ed31 100644 --- a/src/industry.h +++ b/src/industry.h @@ -20,7 +20,7 @@ #include "timer/timer_game_economy.h" -typedef Pool IndustryPool; +typedef Pool IndustryPool; extern IndustryPool _industry_pool; static const TimerGameEconomy::Year PROCESSING_INDUSTRY_ABANDONMENT_YEARS{5}; ///< If a processing industry doesn't produce for this many consecutive economy years, it may close. diff --git a/src/industry_map.h b/src/industry_map.h index e2471fc174..8a18184b06 100644 --- a/src/industry_map.h +++ b/src/industry_map.h @@ -279,7 +279,7 @@ inline void MakeIndustry(Tile t, IndustryID index, IndustryGfx gfx, uint8_t rand { SetTileType(t, MP_INDUSTRY); t.m1() = 0; - t.m2() = index; + t.m2() = index.base(); SetIndustryRandomBits(t, random); // m3 t.m4() = 0; SetIndustryGfx(t, gfx); // m5, part of m6 diff --git a/src/industry_type.h b/src/industry_type.h index 44f7d5fbf1..b6975c0d86 100644 --- a/src/industry_type.h +++ b/src/industry_type.h @@ -10,11 +10,8 @@ #ifndef INDUSTRY_TYPE_H #define INDUSTRY_TYPE_H -enum IndustryID : uint16_t { - INDUSTRY_BEGIN = 0, - INDUSTRY_END = 64000, - INVALID_INDUSTRY = 0xFFFF -}; +using IndustryID = PoolID; +static constexpr IndustryID INVALID_INDUSTRY = IndustryID::Invalid(); typedef uint16_t IndustryGfx; typedef uint8_t IndustryType; diff --git a/src/news_gui.cpp b/src/news_gui.cpp index cd5baf816e..5760ffee41 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -922,7 +922,7 @@ uint32_t SerialiseNewsReference(const NewsReference &reference) uint32_t operator()(const TileIndex &t) { return t.base(); } uint32_t operator()(const VehicleID v) { return v; } uint32_t operator()(const StationID s) { return s; } - uint32_t operator()(const IndustryID i) { return i; } + uint32_t operator()(const IndustryID i) { return i.base(); } uint32_t operator()(const TownID t) { return t; } uint32_t operator()(const EngineID e) { return e.base(); } };