mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r19351) -Codechange: use TileArea for AfterRemoveRect
This commit is contained in:
parent
6a3dbaf99a
commit
bf6167710f
|
@ -43,7 +43,7 @@ struct StationRect : public Rect {
|
||||||
CommandCost BeforeAddTile(TileIndex tile, StationRectMode mode);
|
CommandCost BeforeAddTile(TileIndex tile, StationRectMode mode);
|
||||||
CommandCost BeforeAddRect(TileIndex tile, int w, int h, StationRectMode mode);
|
CommandCost BeforeAddRect(TileIndex tile, int w, int h, StationRectMode mode);
|
||||||
bool AfterRemoveTile(BaseStation *st, TileIndex tile);
|
bool AfterRemoveTile(BaseStation *st, TileIndex tile);
|
||||||
bool AfterRemoveRect(BaseStation *st, TileIndex tile, int w, int h);
|
bool AfterRemoveRect(BaseStation *st, TileArea ta);
|
||||||
|
|
||||||
static bool ScanForStationTiles(StationID st_id, int left_a, int top_a, int right_a, int bottom_a);
|
static bool ScanForStationTiles(StationID st_id, int left_a, int top_a, int right_a, int bottom_a);
|
||||||
|
|
||||||
|
|
|
@ -483,13 +483,13 @@ bool StationRect::AfterRemoveTile(BaseStation *st, TileIndex tile)
|
||||||
return false; // non-empty remaining rect
|
return false; // non-empty remaining rect
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StationRect::AfterRemoveRect(BaseStation *st, TileIndex tile, int w, int h)
|
bool StationRect::AfterRemoveRect(BaseStation *st, TileArea ta)
|
||||||
{
|
{
|
||||||
assert(this->PtInExtendedRect(TileX(tile), TileY(tile)));
|
assert(this->PtInExtendedRect(TileX(ta.tile), TileY(ta.tile)));
|
||||||
assert(this->PtInExtendedRect(TileX(tile) + w - 1, TileY(tile) + h - 1));
|
assert(this->PtInExtendedRect(TileX(ta.tile) + ta.w - 1, TileY(ta.tile) + ta.h - 1));
|
||||||
|
|
||||||
bool empty = this->AfterRemoveTile(st, tile);
|
bool empty = this->AfterRemoveTile(st, ta.tile);
|
||||||
if (w != 1 || h != 1) empty = empty || this->AfterRemoveTile(st, TILE_ADDXY(tile, w - 1, h - 1));
|
if (ta.w != 1 || ta.h != 1) empty = empty || this->AfterRemoveTile(st, TILE_ADDXY(ta.tile, ta.w - 1, ta.h - 1));
|
||||||
return empty;
|
return empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1408,7 +1408,6 @@ CommandCost RemoveFromRailBaseStation(TileArea ta, SmallVector<T *, 4> &affected
|
||||||
DoClearSquare(tile);
|
DoClearSquare(tile);
|
||||||
if (keep_rail) MakeRailNormal(tile, owner, TrackToTrackBits(track), rt);
|
if (keep_rail) MakeRailNormal(tile, owner, TrackToTrackBits(track), rt);
|
||||||
|
|
||||||
st->rect.AfterRemoveTile(st, tile);
|
|
||||||
AddTrackToSignalBuffer(tile, track, owner);
|
AddTrackToSignalBuffer(tile, track, owner);
|
||||||
YapfNotifyTrackLayoutChange(tile, track);
|
YapfNotifyTrackLayoutChange(tile, track);
|
||||||
|
|
||||||
|
@ -1435,6 +1434,7 @@ CommandCost RemoveFromRailBaseStation(TileArea ta, SmallVector<T *, 4> &affected
|
||||||
for (T **stp = affected_stations.Begin(); stp != affected_stations.End(); stp++) {
|
for (T **stp = affected_stations.Begin(); stp != affected_stations.End(); stp++) {
|
||||||
T *st = *stp;
|
T *st = *stp;
|
||||||
|
|
||||||
|
st->rect.AfterRemoveRect(st, ta);
|
||||||
/* now we need to make the "spanned" area of the railway station smaller
|
/* now we need to make the "spanned" area of the railway station smaller
|
||||||
* if we deleted something at the edges.
|
* if we deleted something at the edges.
|
||||||
* we also need to adjust train_tile. */
|
* we also need to adjust train_tile. */
|
||||||
|
@ -1556,7 +1556,7 @@ CommandCost RemoveRailStation(T *st, DoCommandFlag flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
st->rect.AfterRemoveRect(st, st->train_station.tile, st->train_station.w, st->train_station.h);
|
st->rect.AfterRemoveRect(st, st->train_station);
|
||||||
|
|
||||||
st->train_station.Clear();
|
st->train_station.Clear();
|
||||||
|
|
||||||
|
@ -2272,7 +2272,7 @@ static CommandCost RemoveAirport(TileIndex tile, DoCommandFlag flags)
|
||||||
Town *nearest = AirportGetNearestTown(as, tile);
|
Town *nearest = AirportGetNearestTown(as, tile);
|
||||||
nearest->noise_reached -= GetAirportNoiseLevelForTown(as, nearest->xy, tile);
|
nearest->noise_reached -= GetAirportNoiseLevelForTown(as, nearest->xy, tile);
|
||||||
|
|
||||||
st->rect.AfterRemoveRect(st, tile, st->airport.w, st->airport.h);
|
st->rect.AfterRemoveRect(st, st->airport);
|
||||||
|
|
||||||
st->airport.Clear();
|
st->airport.Clear();
|
||||||
st->facilities &= ~FACIL_AIRPORT;
|
st->facilities &= ~FACIL_AIRPORT;
|
||||||
|
|
Loading…
Reference in New Issue