mirror of https://github.com/OpenTTD/OpenTTD
Codechange: make IndustryID an enum
parent
9015c3651f
commit
c25c3e8710
|
@ -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<IndustryID>(GB(num, CCB_TOWN_IND_NUMBER_START, CCB_TOWN_IND_NUMBER_LENGTH));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include "timer/timer_game_economy.h"
|
||||
|
||||
|
||||
typedef Pool<Industry, IndustryID, 64, 64000> IndustryPool;
|
||||
typedef Pool<Industry, IndustryID, 64, INDUSTRY_END> 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.
|
||||
|
|
|
@ -63,7 +63,7 @@ enum IndustryGraphics : uint8_t {
|
|||
inline IndustryID GetIndustryIndex(Tile t)
|
||||
{
|
||||
assert(IsTileType(t, MP_INDUSTRY));
|
||||
return t.m2();
|
||||
return static_cast<IndustryID>(t.m2());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
if (type == GT_STORY_PAGE && ScriptStoryPage::IsValidStoryPage(static_cast<StoryPageID>(destination))) story_page = ::StoryPage::Get(static_cast<StoryPageID>(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<IndustryID>(destination))) ||
|
||||
(type == GT_TOWN && ScriptTown::IsValidTown(static_cast<TownID>(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));
|
||||
|
|
|
@ -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<IndustryID>(reference))) ||
|
||||
(ref_type == NR_TOWN && ScriptTown::IsValidTown(static_cast<TownID>(reference))));
|
||||
|
||||
::CompanyID c = ScriptCompany::FromScriptCompanyID(company);
|
||||
|
|
|
@ -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<TownID>(from_id))));
|
||||
EnforcePrecondition(false, (to_type == SPT_INDUSTRY && ScriptIndustry::IsValidIndustry(to_id)) || (to_type == SPT_TOWN && ScriptTown::IsValidTown(static_cast<TownID>(to_id))));
|
||||
EnforcePrecondition(false, (from_type == SPT_INDUSTRY && ScriptIndustry::IsValidIndustry(static_cast<IndustryID>(from_id))) || (from_type == SPT_TOWN && ScriptTown::IsValidTown(static_cast<TownID>(from_id))));
|
||||
EnforcePrecondition(false, (to_type == SPT_INDUSTRY && ScriptIndustry::IsValidIndustry(static_cast<IndustryID>(to_id))) || (to_type == SPT_TOWN && ScriptTown::IsValidTown(static_cast<TownID>(to_id))));
|
||||
|
||||
Source from{static_cast<SourceID>(from_id), static_cast<SourceType>(from_type)};
|
||||
Source to{static_cast<SourceID>(to_id), static_cast<SourceType>(to_type)};
|
||||
|
|
Loading…
Reference in New Issue