diff --git a/src/cargomonitor.cpp b/src/cargomonitor.cpp index 86e459526c..5f203af62d 100644 --- a/src/cargomonitor.cpp +++ b/src/cargomonitor.cpp @@ -122,7 +122,7 @@ void AddCargoDelivery(CargoType cargo_type, CompanyID company, uint32_t amount, /* Handle pickup update. */ switch (src.type) { case SourceType::Industry: { - CargoMonitorID num = EncodeCargoIndustryMonitor(company, cargo_type, src.id); + CargoMonitorID num = EncodeCargoIndustryMonitor(company, cargo_type, static_cast(src.id)); CargoMonitorMap::iterator iter = _cargo_pickups.find(num); if (iter != _cargo_pickups.end()) iter->second += amount; break; diff --git a/src/cargomonitor.h b/src/cargomonitor.h index 82dbccb803..a5396ce43d 100644 --- a/src/cargomonitor.h +++ b/src/cargomonitor.h @@ -125,7 +125,7 @@ inline bool MonitorMonitorsIndustry(CargoMonitorID num) inline IndustryID DecodeMonitorIndustry(CargoMonitorID num) { if (!MonitorMonitorsIndustry(num)) return INVALID_INDUSTRY; - return GB(num, CCB_TOWN_IND_NUMBER_START, CCB_TOWN_IND_NUMBER_LENGTH); + return static_cast(GB(num, CCB_TOWN_IND_NUMBER_START, CCB_TOWN_IND_NUMBER_LENGTH)); } /** diff --git a/src/economy.cpp b/src/economy.cpp index 8bbe2b9e5f..b1d672483e 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -1114,7 +1114,7 @@ static Money DeliverGoods(int num_pieces, CargoType cargo_type, StationID dest, Station *st = Station::Get(dest); /* Give the goods to the industry. */ - uint accepted_ind = DeliverGoodsToIndustry(st, cargo_type, num_pieces, src.type == SourceType::Industry ? src.id : INVALID_INDUSTRY, company->index); + uint accepted_ind = DeliverGoodsToIndustry(st, cargo_type, num_pieces, src.type == SourceType::Industry ? static_cast(src.id) : INVALID_INDUSTRY, company->index); /* If this cargo type is always accepted, accept all */ uint accepted_total = HasBit(st->always_accepted, cargo_type) ? num_pieces : accepted_ind; diff --git a/src/industry.h b/src/industry.h index 97eecf53a9..2e2182b0d6 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 2c3bf63f54..ec819da76e 100644 --- a/src/industry_map.h +++ b/src/industry_map.h @@ -63,7 +63,7 @@ enum IndustryGraphics : uint8_t { inline IndustryID GetIndustryIndex(Tile t) { assert(IsTileType(t, MP_INDUSTRY)); - return t.m2(); + return static_cast(t.m2()); } /** diff --git a/src/industry_type.h b/src/industry_type.h index b87c402a95..44f7d5fbf1 100644 --- a/src/industry_type.h +++ b/src/industry_type.h @@ -10,7 +10,12 @@ #ifndef INDUSTRY_TYPE_H #define INDUSTRY_TYPE_H -typedef uint16_t IndustryID; +enum IndustryID : uint16_t { + INDUSTRY_BEGIN = 0, + INDUSTRY_END = 64000, + INVALID_INDUSTRY = 0xFFFF +}; + typedef uint16_t IndustryGfx; typedef uint8_t IndustryType; struct Industry; @@ -18,8 +23,6 @@ struct Industry; struct IndustrySpec; struct IndustryTileSpec; -static const IndustryID INVALID_INDUSTRY = 0xFFFF; - static const IndustryType NUM_INDUSTRYTYPES_PER_GRF = 128; ///< maximum number of industry types per NewGRF; limited to 128 because bit 7 has a special meaning in some variables/callbacks (see MapNewGRFIndustryType). static const IndustryType NEW_INDUSTRYOFFSET = 37; ///< original number of industry types diff --git a/src/script/api/script_goal.cpp b/src/script/api/script_goal.cpp index f997799749..68ba7d3361 100644 --- a/src/script/api/script_goal.cpp +++ b/src/script/api/script_goal.cpp @@ -36,7 +36,7 @@ if (type == GT_STORY_PAGE && ScriptStoryPage::IsValidStoryPage(static_cast(destination))) story_page = ::StoryPage::Get(static_cast(destination)); return (type == GT_NONE && destination == 0) || (type == GT_TILE && ScriptMap::IsValidTile(::TileIndex(destination))) || - (type == GT_INDUSTRY && ScriptIndustry::IsValidIndustry(destination)) || + (type == GT_INDUSTRY && ScriptIndustry::IsValidIndustry(static_cast(destination))) || (type == GT_TOWN && ScriptTown::IsValidTown(destination)) || (type == GT_COMPANY && ScriptCompany::ResolveCompanyID((ScriptCompany::CompanyID)destination) != ScriptCompany::COMPANY_INVALID) || (type == GT_STORY_PAGE && story_page != nullptr && (c == INVALID_COMPANY ? story_page->company == INVALID_COMPANY : story_page->company == INVALID_COMPANY || story_page->company == c)); diff --git a/src/script/api/script_news.cpp b/src/script/api/script_news.cpp index 21ed106470..07f910c7a2 100644 --- a/src/script/api/script_news.cpp +++ b/src/script/api/script_news.cpp @@ -33,7 +33,7 @@ EnforcePrecondition(false, (ref_type == NR_NONE) || (ref_type == NR_TILE && ScriptMap::IsValidTile(::TileIndex(reference))) || (ref_type == NR_STATION && ScriptStation::IsValidStation(reference)) || - (ref_type == NR_INDUSTRY && ScriptIndustry::IsValidIndustry(reference)) || + (ref_type == NR_INDUSTRY && ScriptIndustry::IsValidIndustry(static_cast(reference))) || (ref_type == NR_TOWN && ScriptTown::IsValidTown(reference))); uint8_t c = company; diff --git a/src/script/api/script_subsidy.cpp b/src/script/api/script_subsidy.cpp index bd3bcc93cb..3e8db2e5e8 100644 --- a/src/script/api/script_subsidy.cpp +++ b/src/script/api/script_subsidy.cpp @@ -37,8 +37,8 @@ EnforcePrecondition(false, ScriptCargo::IsValidCargo(cargo_type)); EnforcePrecondition(false, from_type == SPT_INDUSTRY || from_type == SPT_TOWN); EnforcePrecondition(false, to_type == SPT_INDUSTRY || to_type == SPT_TOWN); - EnforcePrecondition(false, (from_type == SPT_INDUSTRY && ScriptIndustry::IsValidIndustry(from_id)) || (from_type == SPT_TOWN && ScriptTown::IsValidTown(from_id))); - EnforcePrecondition(false, (to_type == SPT_INDUSTRY && ScriptIndustry::IsValidIndustry(to_id)) || (to_type == SPT_TOWN && ScriptTown::IsValidTown(to_id))); + EnforcePrecondition(false, (from_type == SPT_INDUSTRY && ScriptIndustry::IsValidIndustry(static_cast(from_id))) || (from_type == SPT_TOWN && ScriptTown::IsValidTown(from_id))); + EnforcePrecondition(false, (to_type == SPT_INDUSTRY && ScriptIndustry::IsValidIndustry(static_cast(to_id))) || (to_type == SPT_TOWN && ScriptTown::IsValidTown(to_id))); Source from{static_cast(from_id), static_cast(from_type)}; Source to{static_cast(to_id), static_cast(to_type)};