1
0
Fork 0

(svn r23462) -Codechange: use AirportTileTableIterator in a few more places to make the code easier to read

release/1.2
yexo 2011-12-09 19:53:42 +00:00
parent c9be5d50da
commit 16eb11e988
2 changed files with 17 additions and 16 deletions

View File

@ -56,6 +56,12 @@ public:
return *this; return *this;
} }
/** Get the StationGfx for the current tile. */
StationGfx GetStationGfx() const
{
return this->att->gfx;
}
virtual AirportTileTableIterator *Clone() const virtual AirportTileTableIterator *Clone() const
{ {
return new AirportTileTableIterator(*this); return new AirportTileTableIterator(*this);

View File

@ -2224,10 +2224,9 @@ CommandCost CmdBuildAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
} }
} }
const AirportTileTable *it = as->table[layout]; for (AirportTileTableIterator iter(as->table[layout], tile); iter != INVALID_TILE; ++iter) {
do {
cost.AddCost(_price[PR_BUILD_STATION_AIRPORT]); cost.AddCost(_price[PR_BUILD_STATION_AIRPORT]);
} while ((++it)->ti.x != -0x80); }
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
/* Always add the noise, so there will be no need to recalculate when option toggles */ /* Always add the noise, so there will be no need to recalculate when option toggles */
@ -2241,22 +2240,18 @@ CommandCost CmdBuildAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
st->rect.BeforeAddRect(tile, w, h, StationRect::ADD_TRY); st->rect.BeforeAddRect(tile, w, h, StationRect::ADD_TRY);
it = as->table[layout]; for (AirportTileTableIterator iter(as->table[layout], tile); iter != INVALID_TILE; ++iter) {
do { MakeAirport(iter, st->owner, st->index, iter.GetStationGfx(), WATER_CLASS_INVALID);
TileIndex cur_tile = tile + ToTileIndexDiff(it->ti); SetStationTileRandomBits(iter, GB(Random(), 0, 4));
MakeAirport(cur_tile, st->owner, st->index, it->gfx, WATER_CLASS_INVALID); st->airport.Add(iter);
SetStationTileRandomBits(cur_tile, GB(Random(), 0, 4));
st->airport.Add(cur_tile);
if (AirportTileSpec::Get(GetTranslatedAirportTileID(it->gfx))->animation.status != ANIM_STATUS_NO_ANIMATION) AddAnimatedTile(cur_tile); if (AirportTileSpec::Get(GetTranslatedAirportTileID(iter.GetStationGfx()))->animation.status != ANIM_STATUS_NO_ANIMATION) AddAnimatedTile(iter);
} while ((++it)->ti.x != -0x80); }
/* Only call the animation trigger after all tiles have been built */ /* Only call the animation trigger after all tiles have been built */
it = as->table[layout]; for (AirportTileTableIterator iter(as->table[layout], tile); iter != INVALID_TILE; ++iter) {
do { AirportTileAnimationTrigger(st, iter, AAT_BUILT);
TileIndex cur_tile = tile + ToTileIndexDiff(it->ti); }
AirportTileAnimationTrigger(st, cur_tile, AAT_BUILT);
} while ((++it)->ti.x != -0x80);
UpdateAirplanesOnNewStation(st); UpdateAirplanesOnNewStation(st);