mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Use EnumBitSet for TileFlags.
parent
3c2706f859
commit
05ac1dd888
|
@ -2090,9 +2090,9 @@ static ChangeInfoResult StationChangeInfo(uint first, uint last, int prop, ByteR
|
|||
if (statspec->tileflags.size() < 8) statspec->tileflags.resize(8);
|
||||
for (int j = 0; j < 8; ++j) {
|
||||
if (HasBit(pylons, j)) {
|
||||
statspec->tileflags[j] |= StationSpec::TileFlags::Pylons;
|
||||
statspec->tileflags[j].Set(StationSpec::TileFlag::Pylons);
|
||||
} else {
|
||||
statspec->tileflags[j] &= ~StationSpec::TileFlags::Pylons;
|
||||
statspec->tileflags[j].Reset(StationSpec::TileFlag::Pylons);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -2115,9 +2115,9 @@ static ChangeInfoResult StationChangeInfo(uint first, uint last, int prop, ByteR
|
|||
if (statspec->tileflags.size() < 8) statspec->tileflags.resize(8);
|
||||
for (int j = 0; j < 8; ++j) {
|
||||
if (HasBit(wires, j)) {
|
||||
statspec->tileflags[j] |= StationSpec::TileFlags::NoWires;
|
||||
statspec->tileflags[j].Set(StationSpec::TileFlag::NoWires);
|
||||
} else {
|
||||
statspec->tileflags[j] &= ~StationSpec::TileFlags::NoWires;
|
||||
statspec->tileflags[j].Reset(StationSpec::TileFlag::NoWires);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -2128,9 +2128,9 @@ static ChangeInfoResult StationChangeInfo(uint first, uint last, int prop, ByteR
|
|||
if (statspec->tileflags.size() < 8) statspec->tileflags.resize(8);
|
||||
for (int j = 0; j < 8; ++j) {
|
||||
if (HasBit(blocked, j)) {
|
||||
statspec->tileflags[j] |= StationSpec::TileFlags::Blocked;
|
||||
statspec->tileflags[j].Set(StationSpec::TileFlag::Blocked);
|
||||
} else {
|
||||
statspec->tileflags[j] &= ~StationSpec::TileFlags::Blocked;
|
||||
statspec->tileflags[j].Reset(StationSpec::TileFlag::Blocked);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -160,12 +160,12 @@ struct StationSpec : NewGRFSpecBase<StationClassID> {
|
|||
|
||||
uint8_t flags; ///< Bitmask of flags, bit 0: use different sprite set; bit 1: divide cargo about by station size
|
||||
|
||||
enum class TileFlags : uint8_t {
|
||||
None = 0,
|
||||
Pylons = 1U << 0, ///< Tile should contain catenary pylons.
|
||||
NoWires = 1U << 1, ///< Tile should NOT contain catenary wires.
|
||||
Blocked = 1U << 2, ///< Tile is blocked to vehicles.
|
||||
enum class TileFlag : uint8_t {
|
||||
Pylons = 0, ///< Tile should contain catenary pylons.
|
||||
NoWires = 1, ///< Tile should NOT contain catenary wires.
|
||||
Blocked = 2, ///< Tile is blocked to vehicles.
|
||||
};
|
||||
using TileFlags = EnumBitSet<TileFlag, uint8_t>;
|
||||
std::vector<TileFlags> tileflags; ///< List of tile flags.
|
||||
|
||||
AnimationInfo animation;
|
||||
|
@ -173,7 +173,6 @@ struct StationSpec : NewGRFSpecBase<StationClassID> {
|
|||
/** Custom platform layouts, keyed by platform and length combined. */
|
||||
std::unordered_map<uint16_t, std::vector<uint8_t>> layouts;
|
||||
};
|
||||
DECLARE_ENUM_AS_BIT_SET(StationSpec::TileFlags);
|
||||
|
||||
/** Class containing information relating to station classes. */
|
||||
using StationClass = NewGRFClass<StationSpec, StationClassID, STAT_CLASS_MAX>;
|
||||
|
|
|
@ -1310,7 +1310,7 @@ static CommandCost CalculateRailStationCost(TileArea tile_area, DoCommandFlag fl
|
|||
static StationSpec::TileFlags GetStationTileFlags(StationGfx gfx, const StationSpec *statspec)
|
||||
{
|
||||
/* Default stations do not draw pylons under roofs (gfx >= 4) */
|
||||
if (statspec == nullptr || gfx >= statspec->tileflags.size()) return gfx < 4 ? StationSpec::TileFlags::Pylons : StationSpec::TileFlags::None;
|
||||
if (statspec == nullptr || gfx >= statspec->tileflags.size()) return gfx < 4 ? StationSpec::TileFlag::Pylons : StationSpec::TileFlags{};
|
||||
return statspec->tileflags[gfx];
|
||||
}
|
||||
|
||||
|
@ -1322,9 +1322,9 @@ static StationSpec::TileFlags GetStationTileFlags(StationGfx gfx, const StationS
|
|||
void SetRailStationTileFlags(TileIndex tile, const StationSpec *statspec)
|
||||
{
|
||||
const auto flags = GetStationTileFlags(GetStationGfx(tile), statspec);
|
||||
SetStationTileBlocked(tile, HasFlag(flags, StationSpec::TileFlags::Blocked));
|
||||
SetStationTileHavePylons(tile, HasFlag(flags, StationSpec::TileFlags::Pylons));
|
||||
SetStationTileHaveWires(tile, !HasFlag(flags, StationSpec::TileFlags::NoWires));
|
||||
SetStationTileBlocked(tile, flags.Test(StationSpec::TileFlag::Blocked));
|
||||
SetStationTileHavePylons(tile, flags.Test(StationSpec::TileFlag::Pylons));
|
||||
SetStationTileHaveWires(tile, !flags.Test(StationSpec::TileFlag::NoWires));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue