|
@@ -760,22 +760,42 @@ static void UpdateStationAcceptance(Stat
|
|
|
}
|
|
|
|
|
|
// redraw the station view since acceptance changed
|
|
|
InvalidateWindowWidget(WC_STATION_VIEW, st->index, 4);
|
|
|
}
|
|
|
|
|
|
|
|
|
static void UpdateStationSignCoord(Station *st)
|
|
|
{
|
|
|
ottd_Rectangle r = {MapSizeX(), MapSizeY(), 0, 0};
|
|
|
TileIndex tile;
|
|
|
|
|
|
// get station bounding rect
|
|
|
for (tile = 0; tile < MapSize(); tile++) {
|
|
|
if (IsTileType(tile, MP_STATION) && GetStationIndex(tile) == st->index) MergePoint(&r, tile);
|
|
|
}
|
|
|
|
|
|
if (r.max_x < r.min_x) return; // no tiles belong to this station
|
|
|
|
|
|
// clamp sign coord to be inside the rect
|
|
|
st->xy = TileXY(clampu(TileX(st->xy), r.min_x, r.max_x), clampu(TileY(st->xy), r.min_y, r.max_y));
|
|
|
UpdateStationVirtCoordDirty(st);
|
|
|
}
|
|
|
|
|
|
// This is called right after a station was deleted.
|
|
|
// It checks if the whole station is free of substations, and if so, the station will be
|
|
|
// deleted after a little while.
|
|
|
static void DeleteStationIfEmpty(Station* st)
|
|
|
{
|
|
|
if (st->facilities == 0) {
|
|
|
st->delete_ctr = 0;
|
|
|
RebuildStationLists();
|
|
|
InvalidateWindow(WC_STATION_LIST, st->owner);
|
|
|
}
|
|
|
/* station remains but it probably lost some parts - station sign should stay in the station boundaries */
|
|
|
UpdateStationSignCoord(st);
|
|
|
}
|
|
|
|
|
|
static int32 ClearTile_Station(TileIndex tile, byte flags);
|
|
|
|
|
|
// Tries to clear the given area. Returns the cost in case of success.
|
|
|
// Or an error code if it failed.
|
|
@@ -1215,12 +1235,13 @@ int32 CmdRemoveFromRailroadStation(TileI
|
|
|
DeallocateSpecFromStation(st, specindex);
|
|
|
|
|
|
// 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.
|
|
|
MakeRailwayStationAreaSmaller(st);
|
|
|
MarkStationTilesDirty(st);
|
|
|
UpdateStationSignCoord(st);
|
|
|
|
|
|
// if we deleted the whole station, delete the train facility.
|
|
|
if (st->train_tile == 0) {
|
|
|
st->facilities &= ~FACIL_TRAIN;
|
|
|
UpdateStationVirtCoordDirty(st);
|
|
|
DeleteStationIfEmpty(st);
|