mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-02-02 12:24:15 +00:00
(svn r16728) -Fix (r14919): the Join station window didn't show all stations nearby in some cases
This commit is contained in:
parent
3c50a66ced
commit
e7be1c74cf
@ -1073,8 +1073,14 @@ void ShowStationViewWindow(StationID station)
|
|||||||
AllocateWindowDescFront<StationViewWindow>(&_station_view_desc, station);
|
AllocateWindowDescFront<StationViewWindow>(&_station_view_desc, station);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Struct containing TileIndex and StationID */
|
||||||
|
struct TileAndStation {
|
||||||
|
TileIndex tile; ///< TileIndex
|
||||||
|
StationID station; ///< StationID
|
||||||
|
};
|
||||||
|
|
||||||
|
static SmallVector<TileAndStation, 8> _deleted_stations_nearby;
|
||||||
static SmallVector<StationID, 8> _stations_nearby_list;
|
static SmallVector<StationID, 8> _stations_nearby_list;
|
||||||
static SmallMap<TileIndex, StationID, 8> _deleted_stations_nearby;
|
|
||||||
|
|
||||||
/** Context for FindStationsNearby */
|
/** Context for FindStationsNearby */
|
||||||
struct FindNearbyStationContext {
|
struct FindNearbyStationContext {
|
||||||
@ -1093,11 +1099,14 @@ static bool AddNearbyStation(TileIndex tile, void *user_data)
|
|||||||
{
|
{
|
||||||
FindNearbyStationContext *ctx = (FindNearbyStationContext *)user_data;
|
FindNearbyStationContext *ctx = (FindNearbyStationContext *)user_data;
|
||||||
|
|
||||||
/* First check if there was a deleted station here */
|
/* First check if there were deleted stations here */
|
||||||
SmallPair<TileIndex, StationID> *dst = _deleted_stations_nearby.Find(tile);
|
for (uint i = 0; i < _deleted_stations_nearby.Length(); i++) {
|
||||||
if (dst != _deleted_stations_nearby.End()) {
|
TileAndStation *ts = _deleted_stations_nearby.Get(i);
|
||||||
_stations_nearby_list.Include(dst->second);
|
if (ts->tile == tile) {
|
||||||
return false;
|
*_stations_nearby_list.Append() = _deleted_stations_nearby[i].station;
|
||||||
|
_deleted_stations_nearby.Erase(ts);
|
||||||
|
i--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if own station and if we stay within station spread */
|
/* Check if own station and if we stay within station spread */
|
||||||
@ -1145,7 +1154,9 @@ static const Station *FindStationsNearby(TileIndex tile, int w, int h, bool dist
|
|||||||
if (st->facilities == 0 && st->owner == _local_company) {
|
if (st->facilities == 0 && st->owner == _local_company) {
|
||||||
/* Include only within station spread (yes, it is strictly less than) */
|
/* Include only within station spread (yes, it is strictly less than) */
|
||||||
if (max(DistanceMax(tile, st->xy), DistanceMax(TILE_ADDXY(tile, w - 1, h - 1), st->xy)) < _settings_game.station.station_spread) {
|
if (max(DistanceMax(tile, st->xy), DistanceMax(TILE_ADDXY(tile, w - 1, h - 1), st->xy)) < _settings_game.station.station_spread) {
|
||||||
_deleted_stations_nearby.Insert(st->xy, st->index);
|
TileAndStation *ts = _deleted_stations_nearby.Append();
|
||||||
|
ts->tile = st->xy;
|
||||||
|
ts->station = st->index;
|
||||||
|
|
||||||
/* Add the station when it's within where we're going to build */
|
/* Add the station when it's within where we're going to build */
|
||||||
if (IsInsideBS(TileX(st->xy), TileX(ctx.tile), ctx.w) &&
|
if (IsInsideBS(TileX(st->xy), TileX(ctx.tile), ctx.w) &&
|
||||||
|
Loading…
Reference in New Issue
Block a user