mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Replace station TileFlags with a TileSpec struct.
This allows storing more per-layout-tile data.pull/14477/head
parent
cdadfd8e83
commit
adc221f0d4
|
@ -184,12 +184,12 @@ static ChangeInfoResult StationChangeInfo(uint first, uint last, int prop, ByteR
|
||||||
|
|
||||||
case 0x11: { // Pylon placement
|
case 0x11: { // Pylon placement
|
||||||
uint8_t pylons = buf.ReadByte();
|
uint8_t pylons = buf.ReadByte();
|
||||||
if (statspec->tileflags.size() < 8) statspec->tileflags.resize(8);
|
if (statspec->tilespecs.size() < 8) statspec->tilespecs.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].Set(StationSpec::TileFlag::Pylons);
|
statspec->tilespecs[j].flags.Set(StationSpec::TileFlag::Pylons);
|
||||||
} else {
|
} else {
|
||||||
statspec->tileflags[j].Reset(StationSpec::TileFlag::Pylons);
|
statspec->tilespecs[j].flags.Reset(StationSpec::TileFlag::Pylons);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -209,12 +209,12 @@ static ChangeInfoResult StationChangeInfo(uint first, uint last, int prop, ByteR
|
||||||
|
|
||||||
case 0x14: { // Overhead wire placement
|
case 0x14: { // Overhead wire placement
|
||||||
uint8_t wires = buf.ReadByte();
|
uint8_t wires = buf.ReadByte();
|
||||||
if (statspec->tileflags.size() < 8) statspec->tileflags.resize(8);
|
if (statspec->tilespecs.size() < 8) statspec->tilespecs.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].Set(StationSpec::TileFlag::NoWires);
|
statspec->tilespecs[j].flags.Set(StationSpec::TileFlag::NoWires);
|
||||||
} else {
|
} else {
|
||||||
statspec->tileflags[j].Reset(StationSpec::TileFlag::NoWires);
|
statspec->tilespecs[j].flags.Reset(StationSpec::TileFlag::NoWires);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -222,12 +222,12 @@ static ChangeInfoResult StationChangeInfo(uint first, uint last, int prop, ByteR
|
||||||
|
|
||||||
case 0x15: { // Blocked tiles
|
case 0x15: { // Blocked tiles
|
||||||
uint8_t blocked = buf.ReadByte();
|
uint8_t blocked = buf.ReadByte();
|
||||||
if (statspec->tileflags.size() < 8) statspec->tileflags.resize(8);
|
if (statspec->tilespecs.size() < 8) statspec->tilespecs.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].Set(StationSpec::TileFlag::Blocked);
|
statspec->tilespecs[j].flags.Set(StationSpec::TileFlag::Blocked);
|
||||||
} else {
|
} else {
|
||||||
statspec->tileflags[j].Reset(StationSpec::TileFlag::Blocked);
|
statspec->tilespecs[j].flags.Reset(StationSpec::TileFlag::Blocked);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -285,8 +285,10 @@ static ChangeInfoResult StationChangeInfo(uint first, uint last, int prop, ByteR
|
||||||
|
|
||||||
case 0x1E: { // Extended tile flags (replaces prop 11, 14 and 15)
|
case 0x1E: { // Extended tile flags (replaces prop 11, 14 and 15)
|
||||||
uint16_t tiles = buf.ReadExtendedByte();
|
uint16_t tiles = buf.ReadExtendedByte();
|
||||||
auto flags = reinterpret_cast<const StationSpec::TileFlags *>(buf.ReadBytes(tiles));
|
if (statspec->tilespecs.size() < tiles) statspec->tilespecs.resize(tiles);
|
||||||
statspec->tileflags.assign(flags, flags + tiles);
|
for (uint j = 0; j != tiles; ++j) {
|
||||||
|
statspec->tilespecs[j].flags = StationSpec::TileFlags{buf.ReadByte()};
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -168,7 +168,11 @@ struct StationSpec : NewGRFSpecBase<StationClassID> {
|
||||||
Blocked = 2, ///< Tile is blocked to vehicles.
|
Blocked = 2, ///< Tile is blocked to vehicles.
|
||||||
};
|
};
|
||||||
using TileFlags = EnumBitSet<TileFlag, uint8_t>;
|
using TileFlags = EnumBitSet<TileFlag, uint8_t>;
|
||||||
std::vector<TileFlags> tileflags; ///< List of tile flags.
|
|
||||||
|
struct TileSpec {
|
||||||
|
TileFlags flags{}; ///< Tile flags.
|
||||||
|
};
|
||||||
|
std::vector<TileSpec> tilespecs; ///< Per-layout-tile information.
|
||||||
|
|
||||||
AnimationInfo<StationAnimationTriggers> animation;
|
AnimationInfo<StationAnimationTriggers> animation;
|
||||||
|
|
||||||
|
|
|
@ -1307,8 +1307,8 @@ static CommandCost CalculateRailStationCost(TileArea tile_area, DoCommandFlags f
|
||||||
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::TileFlag::Pylons : StationSpec::TileFlags{};
|
if (statspec == nullptr || gfx >= statspec->tilespecs.size()) return gfx < 4 ? StationSpec::TileFlag::Pylons : StationSpec::TileFlags{};
|
||||||
return statspec->tileflags[gfx];
|
return statspec->tilespecs[gfx].flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue