mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Remove terminator from airport tile lists. (#14306)
parent
808af15975
commit
7c9393e822
|
@ -93,10 +93,8 @@ static ChangeInfoResult AirportChangeInfo(uint first, uint last, int prop, ByteR
|
||||||
tile.ti.x = buf.ReadByte();
|
tile.ti.x = buf.ReadByte();
|
||||||
tile.ti.y = buf.ReadByte();
|
tile.ti.y = buf.ReadByte();
|
||||||
if (tile.ti.x == 0 && tile.ti.y == 0x80) {
|
if (tile.ti.x == 0 && tile.ti.y == 0x80) {
|
||||||
/* Convert terminator to our own. */
|
/* Terminator, remove and finish up. */
|
||||||
tile.ti.x = -0x80;
|
layout.tiles.pop_back();
|
||||||
tile.ti.y = 0;
|
|
||||||
tile.gfx = 0;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,9 @@ struct AirportTileTable {
|
||||||
/** Iterator to iterate over all tiles belonging to an airport spec. */
|
/** Iterator to iterate over all tiles belonging to an airport spec. */
|
||||||
class AirportTileTableIterator : public TileIterator {
|
class AirportTileTableIterator : public TileIterator {
|
||||||
private:
|
private:
|
||||||
const AirportTileTable *att; ///< The offsets.
|
std::span<const AirportTileTable> att; ///< The offsets.
|
||||||
TileIndex base_tile; ///< The tile we base the offsets off.
|
TileIndex base_tile; ///< The tile we base the offsets off.
|
||||||
|
std::span<const AirportTileTable>::iterator iter;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
@ -40,17 +41,19 @@ public:
|
||||||
* @param att The TileTable we want to iterate over.
|
* @param att The TileTable we want to iterate over.
|
||||||
* @param base_tile The basetile for all offsets.
|
* @param base_tile The basetile for all offsets.
|
||||||
*/
|
*/
|
||||||
AirportTileTableIterator(const AirportTileTable *att, TileIndex base_tile) : TileIterator(base_tile + ToTileIndexDiff(att->ti)), att(att), base_tile(base_tile)
|
AirportTileTableIterator(std::span<const AirportTileTable> att, TileIndex base_tile)
|
||||||
|
: TileIterator(base_tile + ToTileIndexDiff(att.front().ti))
|
||||||
|
, att(att), base_tile(base_tile), iter(att.begin())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
inline TileIterator& operator ++() override
|
inline TileIterator& operator ++() override
|
||||||
{
|
{
|
||||||
this->att++;
|
++this->iter;
|
||||||
if (this->att->ti.x == -0x80) {
|
if (this->iter == std::end(att)) {
|
||||||
this->tile = INVALID_TILE;
|
this->tile = INVALID_TILE;
|
||||||
} else {
|
} else {
|
||||||
this->tile = this->base_tile + ToTileIndexDiff(this->att->ti);
|
this->tile = this->base_tile + ToTileIndexDiff(this->iter->ti);
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -58,7 +61,7 @@ public:
|
||||||
/** Get the StationGfx for the current tile. */
|
/** Get the StationGfx for the current tile. */
|
||||||
StationGfx GetStationGfx() const
|
StationGfx GetStationGfx() const
|
||||||
{
|
{
|
||||||
return this->att->gfx;
|
return this->iter->gfx;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<TileIterator> Clone() const override
|
std::unique_ptr<TileIterator> Clone() const override
|
||||||
|
|
|
@ -139,7 +139,7 @@
|
||||||
if (_settings_game.economy.station_noise_level) {
|
if (_settings_game.economy.station_noise_level) {
|
||||||
uint dist;
|
uint dist;
|
||||||
const auto &layout = as->layouts[0];
|
const auto &layout = as->layouts[0];
|
||||||
AirportGetNearestTown(as, layout.rotation, tile, AirportTileTableIterator(layout.tiles.data(), tile), dist);
|
AirportGetNearestTown(as, layout.rotation, tile, AirportTileTableIterator(layout.tiles, tile), dist);
|
||||||
return GetAirportNoiseLevelForDistance(as, dist);
|
return GetAirportNoiseLevelForDistance(as, dist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@
|
||||||
|
|
||||||
uint dist;
|
uint dist;
|
||||||
const auto &layout = as->layouts[0];
|
const auto &layout = as->layouts[0];
|
||||||
return AirportGetNearestTown(as, layout.rotation, tile, AirportTileTableIterator(layout.tiles.data(), tile), dist)->index;
|
return AirportGetNearestTown(as, layout.rotation, tile, AirportTileTableIterator(layout.tiles, tile), dist)->index;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ SQInteger ScriptAirport::GetMaintenanceCostFactor(AirportType type)
|
/* static */ SQInteger ScriptAirport::GetMaintenanceCostFactor(AirportType type)
|
||||||
|
|
|
@ -2541,7 +2541,7 @@ CommandCost CmdBuildAirport(DoCommandFlags flags, TileIndex tile, uint8_t airpor
|
||||||
return CommandCost(STR_ERROR_STATION_TOO_SPREAD_OUT);
|
return CommandCost(STR_ERROR_STATION_TOO_SPREAD_OUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
AirportTileTableIterator tile_iter(as->layouts[layout].tiles.data(), tile);
|
AirportTileTableIterator tile_iter(as->layouts[layout].tiles, tile);
|
||||||
CommandCost cost = CheckFlatLandAirport(tile_iter, flags);
|
CommandCost cost = CheckFlatLandAirport(tile_iter, flags);
|
||||||
if (cost.Failed()) return cost;
|
if (cost.Failed()) return cost;
|
||||||
|
|
||||||
|
@ -2590,7 +2590,7 @@ CommandCost CmdBuildAirport(DoCommandFlags flags, TileIndex tile, uint8_t airpor
|
||||||
return CommandCost(STR_ERROR_TOO_CLOSE_TO_ANOTHER_AIRPORT);
|
return CommandCost(STR_ERROR_TOO_CLOSE_TO_ANOTHER_AIRPORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (AirportTileTableIterator iter(as->layouts[layout].tiles.data(), tile); iter != INVALID_TILE; ++iter) {
|
for (AirportTileTableIterator iter(as->layouts[layout].tiles, tile); iter != INVALID_TILE; ++iter) {
|
||||||
cost.AddCost(_price[PR_BUILD_STATION_AIRPORT]);
|
cost.AddCost(_price[PR_BUILD_STATION_AIRPORT]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2606,7 +2606,7 @@ CommandCost CmdBuildAirport(DoCommandFlags flags, TileIndex tile, uint8_t airpor
|
||||||
|
|
||||||
st->rect.BeforeAddRect(tile, w, h, StationRect::ADD_TRY);
|
st->rect.BeforeAddRect(tile, w, h, StationRect::ADD_TRY);
|
||||||
|
|
||||||
for (AirportTileTableIterator iter(as->layouts[layout].tiles.data(), tile); iter != INVALID_TILE; ++iter) {
|
for (AirportTileTableIterator iter(as->layouts[layout].tiles, tile); iter != INVALID_TILE; ++iter) {
|
||||||
Tile t(iter);
|
Tile t(iter);
|
||||||
MakeAirport(t, st->owner, st->index, iter.GetStationGfx(), WATER_CLASS_INVALID);
|
MakeAirport(t, st->owner, st->index, iter.GetStationGfx(), WATER_CLASS_INVALID);
|
||||||
SetStationTileRandomBits(t, GB(Random(), 0, 4));
|
SetStationTileRandomBits(t, GB(Random(), 0, 4));
|
||||||
|
@ -2616,7 +2616,7 @@ CommandCost CmdBuildAirport(DoCommandFlags flags, TileIndex tile, uint8_t airpor
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Only call the animation trigger after all tiles have been built */
|
/* Only call the animation trigger after all tiles have been built */
|
||||||
for (AirportTileTableIterator iter(as->layouts[layout].tiles.data(), tile); iter != INVALID_TILE; ++iter) {
|
for (AirportTileTableIterator iter(as->layouts[layout].tiles, tile); iter != INVALID_TILE; ++iter) {
|
||||||
TriggerAirportTileAnimation(st, iter, AirportAnimationTrigger::Built);
|
TriggerAirportTileAnimation(st, iter, AirportAnimationTrigger::Built);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,11 +22,6 @@
|
||||||
*/
|
*/
|
||||||
#define MK(x, y, m) {{x, y}, m}
|
#define MK(x, y, m) {{x, y}, m}
|
||||||
|
|
||||||
/**
|
|
||||||
* Terminator of airport tiles layout definition
|
|
||||||
*/
|
|
||||||
#define MKEND {{-0x80, 0}, 0}
|
|
||||||
|
|
||||||
/** Tiles for Country Airfield (small) */
|
/** Tiles for Country Airfield (small) */
|
||||||
static const std::initializer_list<AirportTileTable> _tile_table_country_0 = {
|
static const std::initializer_list<AirportTileTable> _tile_table_country_0 = {
|
||||||
MK(0, 0, APT_SMALL_BUILDING_1),
|
MK(0, 0, APT_SMALL_BUILDING_1),
|
||||||
|
@ -41,7 +36,6 @@ static const std::initializer_list<AirportTileTable> _tile_table_country_0 = {
|
||||||
MK(1, 2, APT_RUNWAY_SMALL_MIDDLE),
|
MK(1, 2, APT_RUNWAY_SMALL_MIDDLE),
|
||||||
MK(2, 2, APT_RUNWAY_SMALL_MIDDLE),
|
MK(2, 2, APT_RUNWAY_SMALL_MIDDLE),
|
||||||
MK(3, 2, APT_RUNWAY_SMALL_NEAR_END),
|
MK(3, 2, APT_RUNWAY_SMALL_NEAR_END),
|
||||||
MKEND
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const std::initializer_list<AirportTileLayout> _tile_table_country = {
|
static const std::initializer_list<AirportTileLayout> _tile_table_country = {
|
||||||
|
@ -70,7 +64,6 @@ static const std::initializer_list<AirportTileTable> _tile_table_commuter_0 = {
|
||||||
MK(2, 3, APT_RUNWAY_2),
|
MK(2, 3, APT_RUNWAY_2),
|
||||||
MK(3, 3, APT_RUNWAY_2),
|
MK(3, 3, APT_RUNWAY_2),
|
||||||
MK(4, 3, APT_RUNWAY_END_FENCE_SE),
|
MK(4, 3, APT_RUNWAY_END_FENCE_SE),
|
||||||
MKEND
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const std::initializer_list<AirportTileLayout> _tile_table_commuter = {
|
static const std::initializer_list<AirportTileLayout> _tile_table_commuter = {
|
||||||
|
@ -115,7 +108,6 @@ static const std::initializer_list<AirportTileTable> _tile_table_city_0 = {
|
||||||
MK(3, 5, APT_RUNWAY_3),
|
MK(3, 5, APT_RUNWAY_3),
|
||||||
MK(4, 5, APT_RUNWAY_4),
|
MK(4, 5, APT_RUNWAY_4),
|
||||||
MK(5, 5, APT_RUNWAY_END_FENCE_SE),
|
MK(5, 5, APT_RUNWAY_END_FENCE_SE),
|
||||||
MKEND
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const std::initializer_list<AirportTileLayout> _tile_table_city = {
|
static const std::initializer_list<AirportTileLayout> _tile_table_city = {
|
||||||
|
@ -160,7 +152,6 @@ static const std::initializer_list<AirportTileTable> _tile_table_metropolitan_0
|
||||||
MK(3, 5, APT_RUNWAY_2),
|
MK(3, 5, APT_RUNWAY_2),
|
||||||
MK(4, 5, APT_RUNWAY_2),
|
MK(4, 5, APT_RUNWAY_2),
|
||||||
MK(5, 5, APT_RUNWAY_END_FENCE_SE),
|
MK(5, 5, APT_RUNWAY_END_FENCE_SE),
|
||||||
MKEND
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const std::initializer_list<AirportTileLayout> _tile_table_metropolitan = {
|
static const std::initializer_list<AirportTileLayout> _tile_table_metropolitan = {
|
||||||
|
@ -218,7 +209,6 @@ static const std::initializer_list<AirportTileTable> _tile_table_international_0
|
||||||
MK(4, 6, APT_RUNWAY_2),
|
MK(4, 6, APT_RUNWAY_2),
|
||||||
MK(5, 6, APT_RUNWAY_2),
|
MK(5, 6, APT_RUNWAY_2),
|
||||||
MK(6, 6, APT_RUNWAY_END_FENCE_SE),
|
MK(6, 6, APT_RUNWAY_END_FENCE_SE),
|
||||||
MKEND
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const std::initializer_list<AirportTileLayout> _tile_table_international = {
|
static const std::initializer_list<AirportTileLayout> _tile_table_international = {
|
||||||
|
@ -326,7 +316,6 @@ static const std::initializer_list<AirportTileTable> _tile_table_intercontinenta
|
||||||
MK(6, 10, APT_RUNWAY_2),
|
MK(6, 10, APT_RUNWAY_2),
|
||||||
MK(7, 10, APT_RUNWAY_END_FENCE_SE_SW),
|
MK(7, 10, APT_RUNWAY_END_FENCE_SE_SW),
|
||||||
MK(8, 10, APT_EMPTY),
|
MK(8, 10, APT_EMPTY),
|
||||||
MKEND
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const std::initializer_list<AirportTileLayout> _tile_table_intercontinental = {
|
static const std::initializer_list<AirportTileLayout> _tile_table_intercontinental = {
|
||||||
|
@ -336,7 +325,6 @@ static const std::initializer_list<AirportTileLayout> _tile_table_intercontinent
|
||||||
/** Tiles for Heliport */
|
/** Tiles for Heliport */
|
||||||
static const std::initializer_list<AirportTileTable> _tile_table_heliport_0 = {
|
static const std::initializer_list<AirportTileTable> _tile_table_heliport_0 = {
|
||||||
MK(0, 0, APT_HELIPORT),
|
MK(0, 0, APT_HELIPORT),
|
||||||
MKEND
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const std::initializer_list<AirportTileLayout> _tile_table_heliport = {
|
static const std::initializer_list<AirportTileLayout> _tile_table_heliport = {
|
||||||
|
@ -349,7 +337,6 @@ static const std::initializer_list<AirportTileTable> _tile_table_helidepot_0 = {
|
||||||
MK(1, 0, APT_DEPOT_SE),
|
MK(1, 0, APT_DEPOT_SE),
|
||||||
MK(0, 1, APT_HELIPAD_2_FENCE_NE_SE),
|
MK(0, 1, APT_HELIPAD_2_FENCE_NE_SE),
|
||||||
MK(1, 1, APT_APRON_FENCE_SE_SW),
|
MK(1, 1, APT_APRON_FENCE_SE_SW),
|
||||||
MKEND
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const std::initializer_list<AirportTileLayout> _tile_table_helidepot = {
|
static const std::initializer_list<AirportTileLayout> _tile_table_helidepot = {
|
||||||
|
@ -366,7 +353,6 @@ static const std::initializer_list<AirportTileTable> _tile_table_helistation_0 =
|
||||||
MK(1, 1, APT_APRON_FENCE_SE),
|
MK(1, 1, APT_APRON_FENCE_SE),
|
||||||
MK(2, 1, APT_APRON_FENCE_SE),
|
MK(2, 1, APT_APRON_FENCE_SE),
|
||||||
MK(3, 1, APT_HELIPAD_3_FENCE_SE_SW),
|
MK(3, 1, APT_HELIPAD_3_FENCE_SE_SW),
|
||||||
MKEND
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const std::initializer_list<AirportTileLayout> _tile_table_helistation = {
|
static const std::initializer_list<AirportTileLayout> _tile_table_helistation = {
|
||||||
|
@ -374,7 +360,6 @@ static const std::initializer_list<AirportTileLayout> _tile_table_helistation =
|
||||||
};
|
};
|
||||||
|
|
||||||
#undef MK
|
#undef MK
|
||||||
#undef MKEND
|
|
||||||
|
|
||||||
/** General AirportSpec definition. */
|
/** General AirportSpec definition. */
|
||||||
#define AS_GENERIC(fsm, layouts, depots, size_x, size_y, noise, catchment, min_year, max_year, maint_cost, ttdpatch_type, class_id, name, preview, enabled) \
|
#define AS_GENERIC(fsm, layouts, depots, size_x, size_y, noise, catchment, min_year, max_year, maint_cost, ttdpatch_type, class_id, name, preview, enabled) \
|
||||||
|
|
Loading…
Reference in New Issue