diff --git a/src/openttd.cpp b/src/openttd.cpp index 4b30fb63d7..f3f1f4ce81 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -1379,9 +1379,11 @@ void CheckCaches(bool force_check, std::function log) std::vector old_station_industries_nears; std::vector old_station_catchment_tiles; + std::vector old_station_tiles; for (Station *st : Station::Iterate()) { old_station_industries_nears.push_back(st->industries_near); old_station_catchment_tiles.push_back(st->catchment_tiles); + old_station_tiles.push_back(st->station_tiles); } std::vector old_industry_stations_nears; @@ -1424,6 +1426,9 @@ void CheckCaches(bool force_check, std::function log) if (!(old_station_catchment_tiles[i] == st->catchment_tiles)) { CCLOG("station catchment_tiles mismatch: st %i", (int)st->index); } + if (!(old_station_tiles[i] == st->station_tiles)) { + CCLOG("station station_tiles mismatch: st %i, (old: %u, new: %u)", (int)st->index, old_station_tiles[i], st->station_tiles); + } i++; } i = 0; diff --git a/src/station.cpp b/src/station.cpp index abf3ed18dd..81bb3b8751 100644 --- a/src/station.cpp +++ b/src/station.cpp @@ -447,6 +447,14 @@ void Station::RecomputeCatchment(bool no_clear_nearby_lists) this->industry->stations_near.clear(); this->industry->stations_near.insert(this); this->industries_near.insert(this->industry); + + /* Loop finding all station tiles */ + TileArea ta(TileXY(this->rect.left, this->rect.top), TileXY(this->rect.right, this->rect.bottom)); + this->station_tiles = 0; + TILE_AREA_LOOP(tile, ta) { + if (!IsTileType(tile, MP_STATION) || GetStationIndex(tile) != this->index) continue; + this->station_tiles++; + } return; } @@ -454,9 +462,12 @@ void Station::RecomputeCatchment(bool no_clear_nearby_lists) /* Loop finding all station tiles */ TileArea ta(TileXY(this->rect.left, this->rect.top), TileXY(this->rect.right, this->rect.bottom)); + this->station_tiles = 0; TILE_AREA_LOOP(tile, ta) { if (!IsTileType(tile, MP_STATION) || GetStationIndex(tile) != this->index) continue; + this->station_tiles++; + uint r = GetTileCatchmentRadius(tile, this); if (r == CA_NONE) continue; diff --git a/src/station_base.h b/src/station_base.h index 036c99dc64..89fe243ba0 100644 --- a/src/station_base.h +++ b/src/station_base.h @@ -794,6 +794,7 @@ public: IndustryType indtype; ///< Industry type to get the name from BitmapTileArea catchment_tiles; ///< NOSAVE: Set of individual tiles covered by catchment area + uint station_tiles; ///< NOSAVE: Count of station tiles owned by this station StationHadVehicleOfType had_vehicle_of_type; diff --git a/src/table/newgrf_debug_data.h b/src/table/newgrf_debug_data.h index d15e82b247..5dde25c657 100644 --- a/src/table/newgrf_debug_data.h +++ b/src/table/newgrf_debug_data.h @@ -738,6 +738,8 @@ class NIHStationStruct : public NIHelper { seprintf(buffer, lastof(buffer), " %u: %s", ind->index, ind->GetCachedName()); print(buffer); } + seprintf(buffer, lastof(buffer), " Station tiles: %u", st->station_tiles); + print(buffer); } } };