(svn r6874) - [NewStations] Mark all tiles of a railway station dirty when adding or removing tiles.

pull/155/head
peter1138 18 years ago
parent 12b34e67f3
commit d45bd66836

@ -85,6 +85,30 @@ MemoryPool _roadstop_pool = { "RoadStop", ROADSTOP_POOL_MAX_BLOCKS, ROADSTOP_POO
extern void UpdateAirplanesOnNewStation(Station *st); extern void UpdateAirplanesOnNewStation(Station *st);
static bool TileBelongsToRailStation(const Station *st, TileIndex tile)
{
return IsTileType(tile, MP_STATION) && GetStationIndex(tile) == st->index && IsRailwayStation(tile);
}
static void MarkStationTilesDirty(const Station *st)
{
TileIndex tile = st->train_tile;
uint w, h;
// XXX No station is recorded as 0, not INVALID_TILE...
if (tile == 0) return;
for (h = 0; h < st->trainst_h; h++) {
for (w = 0; w < st->trainst_w; w++) {
if (TileBelongsToRailStation(st, tile)) {
MarkTileDirtyByTile(tile);
}
tile += TileDiffXY(1, 0);
}
tile += TileDiffXY(-w, 1);
}
}
static void MarkStationDirty(const Station* st) static void MarkStationDirty(const Station* st)
{ {
if (st->sign.width_1 != 0) { if (st->sign.width_1 != 0) {
@ -1107,6 +1131,7 @@ int32 CmdBuildRailroadStation(TileIndex tile_org, uint32 flags, uint32 p1, uint3
tile_org += tile_delta ^ TileDiffXY(1, 1); // perpendicular to tile_delta tile_org += tile_delta ^ TileDiffXY(1, 1); // perpendicular to tile_delta
} while (--numtracks); } while (--numtracks);
MarkStationTilesDirty(st);
UpdateStationVirtCoordDirty(st); UpdateStationVirtCoordDirty(st);
UpdateStationAcceptance(st, false); UpdateStationAcceptance(st, false);
RebuildStationLists(); RebuildStationLists();
@ -1116,11 +1141,6 @@ int32 CmdBuildRailroadStation(TileIndex tile_org, uint32 flags, uint32 p1, uint3
return cost; return cost;
} }
static bool TileBelongsToRailStation(const Station *st, TileIndex tile)
{
return IsTileType(tile, MP_STATION) && GetStationIndex(tile) == st->index && IsRailwayStation(tile);
}
static void MakeRailwayStationAreaSmaller(Station *st) static void MakeRailwayStationAreaSmaller(Station *st)
{ {
uint w = st->trainst_w; uint w = st->trainst_w;
@ -1208,6 +1228,7 @@ int32 CmdRemoveFromRailroadStation(TileIndex tile, uint32 flags, uint32 p1, uint
// now we need to make the "spanned" area of the railway station smaller if we deleted something at the edges. // now we need to make the "spanned" area of the railway station smaller if we deleted something at the edges.
// we also need to adjust train_tile. // we also need to adjust train_tile.
MakeRailwayStationAreaSmaller(st); MakeRailwayStationAreaSmaller(st);
MarkStationTilesDirty(st);
// if we deleted the whole station, delete the train facility. // if we deleted the whole station, delete the train facility.
if (st->train_tile == 0) { if (st->train_tile == 0) {

Loading…
Cancel
Save