diff --git a/src/cargomonitor.h b/src/cargomonitor.h index cc3d687f35..6157d04ccb 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/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 6a0714b8ad..e2471fc174 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 0393cd864c..3775f5bace 100644 --- a/src/script/api/script_goal.cpp +++ b/src/script/api/script_goal.cpp @@ -35,7 +35,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(static_cast(destination))) || (type == GT_COMPANY && ScriptCompany::ResolveCompanyID(ScriptCompany::ToScriptCompanyID(static_cast<::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 aaf7b691b1..7d880f036c 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(static_cast(reference)))); ::CompanyID c = ScriptCompany::FromScriptCompanyID(company); diff --git a/src/script/api/script_subsidy.cpp b/src/script/api/script_subsidy.cpp index 7c640a4534..13b6734d05 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(static_cast(from_id)))); - EnforcePrecondition(false, (to_type == SPT_INDUSTRY && ScriptIndustry::IsValidIndustry(to_id)) || (to_type == SPT_TOWN && ScriptTown::IsValidTown(static_cast(to_id)))); + EnforcePrecondition(false, (from_type == SPT_INDUSTRY && ScriptIndustry::IsValidIndustry(static_cast(from_id))) || (from_type == SPT_TOWN && ScriptTown::IsValidTown(static_cast(from_id)))); + EnforcePrecondition(false, (to_type == SPT_INDUSTRY && ScriptIndustry::IsValidIndustry(static_cast(to_id))) || (to_type == SPT_TOWN && ScriptTown::IsValidTown(static_cast(to_id)))); Source from{static_cast(from_id), static_cast(from_type)}; Source to{static_cast(to_id), static_cast(to_type)};