mirror of https://github.com/OpenTTD/OpenTTD
Codechange: strongly type IndustryID
parent
7e04651220
commit
d3408a4542
|
@ -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<uint32_t, struct CargoLabelTag, StrongType::Compare>;
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include "timer/timer_game_economy.h"
|
||||
|
||||
|
||||
typedef Pool<Industry, IndustryID, 64, INDUSTRY_END> IndustryPool;
|
||||
typedef Pool<Industry, IndustryID, 64, IndustryID::End().base()> 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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<uint16_t, struct IndustryIDTag, 64000, 0xFFFF>;
|
||||
static constexpr IndustryID INVALID_INDUSTRY = IndustryID::Invalid();
|
||||
|
||||
typedef uint16_t IndustryGfx;
|
||||
typedef uint8_t IndustryType;
|
||||
|
|
|
@ -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(); }
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue