Avoid quadratic behaviour in updating nearby lists in RecomputeCatchmentForAll
This commit is contained in:
@@ -428,10 +428,10 @@ bool Station::CatchmentCoversTown(TownID t) const
|
||||
* Recompute tiles covered in our catchment area.
|
||||
* This will additionally recompute nearby towns and industries.
|
||||
*/
|
||||
void Station::RecomputeCatchment()
|
||||
void Station::RecomputeCatchment(bool no_clear_nearby_lists)
|
||||
{
|
||||
this->industries_near.clear();
|
||||
this->RemoveFromAllNearbyLists();
|
||||
if (!no_clear_nearby_lists) this->RemoveFromAllNearbyLists();
|
||||
|
||||
if (this->rect.IsEmpty()) {
|
||||
this->catchment_tiles.Reset();
|
||||
@@ -498,8 +498,12 @@ void Station::RecomputeCatchment()
|
||||
*/
|
||||
/* static */ void Station::RecomputeCatchmentForAll()
|
||||
{
|
||||
Town *t;
|
||||
FOR_ALL_TOWNS(t) { t->stations_near.clear(); }
|
||||
Industry *i;
|
||||
FOR_ALL_INDUSTRIES(i) { i->stations_near.clear(); }
|
||||
Station *st;
|
||||
FOR_ALL_STATIONS(st) { st->RecomputeCatchment(); }
|
||||
FOR_ALL_STATIONS(st) { st->RecomputeCatchment(true); }
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
|
@@ -504,7 +504,7 @@ public:
|
||||
|
||||
uint GetPlatformLength(TileIndex tile, DiagDirection dir) const override;
|
||||
uint GetPlatformLength(TileIndex tile) const override;
|
||||
void RecomputeCatchment();
|
||||
void RecomputeCatchment(bool no_clear_nearby_lists = false);
|
||||
static void RecomputeCatchmentForAll();
|
||||
|
||||
uint GetCatchmentRadius() const;
|
||||
|
Reference in New Issue
Block a user