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);
|
if (statspec->tileflags.size() < 8) statspec->tileflags.resize(8);
|
||||||
for (int j = 0; j < 8; ++j) {
|
for (int j = 0; j < 8; ++j) {
|
||||||
if (HasBit(pylons, j)) {
|
if (HasBit(pylons, j)) {
|
||||||
statspec->tileflags[j] |= StationSpec::TileFlags::Pylons;
|
statspec->tileflags[j].Set(StationSpec::TileFlag::Pylons);
|
||||||
} else {
|
} else {
|
||||||
statspec->tileflags[j] &= ~StationSpec::TileFlags::Pylons;
|
statspec->tileflags[j].Reset(StationSpec::TileFlag::Pylons);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -2115,9 +2115,9 @@ static ChangeInfoResult StationChangeInfo(uint first, uint last, int prop, ByteR
|
||||||
if (statspec->tileflags.size() < 8) statspec->tileflags.resize(8);
|
if (statspec->tileflags.size() < 8) statspec->tileflags.resize(8);
|
||||||
for (int j = 0; j < 8; ++j) {
|
for (int j = 0; j < 8; ++j) {
|
||||||
if (HasBit(wires, j)) {
|
if (HasBit(wires, j)) {
|
||||||
statspec->tileflags[j] |= StationSpec::TileFlags::NoWires;
|
statspec->tileflags[j].Set(StationSpec::TileFlag::NoWires);
|
||||||
} else {
|
} else {
|
||||||
statspec->tileflags[j] &= ~StationSpec::TileFlags::NoWires;
|
statspec->tileflags[j].Reset(StationSpec::TileFlag::NoWires);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -2128,9 +2128,9 @@ static ChangeInfoResult StationChangeInfo(uint first, uint last, int prop, ByteR
|
||||||
if (statspec->tileflags.size() < 8) statspec->tileflags.resize(8);
|
if (statspec->tileflags.size() < 8) statspec->tileflags.resize(8);
|
||||||
for (int j = 0; j < 8; ++j) {
|
for (int j = 0; j < 8; ++j) {
|
||||||
if (HasBit(blocked, j)) {
|
if (HasBit(blocked, j)) {
|
||||||
statspec->tileflags[j] |= StationSpec::TileFlags::Blocked;
|
statspec->tileflags[j].Set(StationSpec::TileFlag::Blocked);
|
||||||
} else {
|
} else {
|
||||||
statspec->tileflags[j] &= ~StationSpec::TileFlags::Blocked;
|
statspec->tileflags[j].Reset(StationSpec::TileFlag::Blocked);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
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
|
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 {
|
enum class TileFlag : uint8_t {
|
||||||
None = 0,
|
Pylons = 0, ///< Tile should contain catenary pylons.
|
||||||
Pylons = 1U << 0, ///< Tile should contain catenary pylons.
|
NoWires = 1, ///< Tile should NOT contain catenary wires.
|
||||||
NoWires = 1U << 1, ///< Tile should NOT contain catenary wires.
|
Blocked = 2, ///< Tile is blocked to vehicles.
|
||||||
Blocked = 1U << 2, ///< Tile is blocked to vehicles.
|
|
||||||
};
|
};
|
||||||
|
using TileFlags = EnumBitSet<TileFlag, uint8_t>;
|
||||||
std::vector<TileFlags> tileflags; ///< List of tile flags.
|
std::vector<TileFlags> tileflags; ///< List of tile flags.
|
||||||
|
|
||||||
AnimationInfo animation;
|
AnimationInfo animation;
|
||||||
|
@ -173,7 +173,6 @@ struct StationSpec : NewGRFSpecBase<StationClassID> {
|
||||||
/** Custom platform layouts, keyed by platform and length combined. */
|
/** Custom platform layouts, keyed by platform and length combined. */
|
||||||
std::unordered_map<uint16_t, std::vector<uint8_t>> layouts;
|
std::unordered_map<uint16_t, std::vector<uint8_t>> layouts;
|
||||||
};
|
};
|
||||||
DECLARE_ENUM_AS_BIT_SET(StationSpec::TileFlags);
|
|
||||||
|
|
||||||
/** Class containing information relating to station classes. */
|
/** Class containing information relating to station classes. */
|
||||||
using StationClass = NewGRFClass<StationSpec, StationClassID, STAT_CLASS_MAX>;
|
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)
|
static StationSpec::TileFlags GetStationTileFlags(StationGfx gfx, const StationSpec *statspec)
|
||||||
{
|
{
|
||||||
/* Default stations do not draw pylons under roofs (gfx >= 4) */
|
/* 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];
|
return statspec->tileflags[gfx];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1322,9 +1322,9 @@ static StationSpec::TileFlags GetStationTileFlags(StationGfx gfx, const StationS
|
||||||
void SetRailStationTileFlags(TileIndex tile, const StationSpec *statspec)
|
void SetRailStationTileFlags(TileIndex tile, const StationSpec *statspec)
|
||||||
{
|
{
|
||||||
const auto flags = GetStationTileFlags(GetStationGfx(tile), statspec);
|
const auto flags = GetStationTileFlags(GetStationGfx(tile), statspec);
|
||||||
SetStationTileBlocked(tile, HasFlag(flags, StationSpec::TileFlags::Blocked));
|
SetStationTileBlocked(tile, flags.Test(StationSpec::TileFlag::Blocked));
|
||||||
SetStationTileHavePylons(tile, HasFlag(flags, StationSpec::TileFlags::Pylons));
|
SetStationTileHavePylons(tile, flags.Test(StationSpec::TileFlag::Pylons));
|
||||||
SetStationTileHaveWires(tile, !HasFlag(flags, StationSpec::TileFlags::NoWires));
|
SetStationTileHaveWires(tile, !flags.Test(StationSpec::TileFlag::NoWires));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue