1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-18 01:42:38 +01:00

Codechange: Refactor FindStationsAroundTiles to avoid code duplication

This commit is contained in:
dP
2020-05-12 01:36:28 +03:00
committed by Charles Pigott
parent e39c5829a2
commit cb9c4bf4a0
7 changed files with 61 additions and 75 deletions

View File

@@ -359,12 +359,11 @@ Rect Station::GetCatchmentRect() const
/**
* Add nearby industry to station's industries_near list if it accepts cargo.
* @param ind Industry
* @param st Station
*/
static void AddIndustryToDeliver(Industry *ind, Station *st)
void Station::AddIndustryToDeliver(Industry *ind)
{
/* Don't check further if this industry is already in the list */
if (st->industries_near.find(ind) != st->industries_near.end()) return;
if (this->industries_near.find(ind) != this->industries_near.end()) return;
/* Include only industries that can accept cargo */
uint cargo_index;
@@ -373,7 +372,7 @@ static void AddIndustryToDeliver(Industry *ind, Station *st)
}
if (cargo_index >= lengthof(ind->accepts_cargo)) return;
st->industries_near.insert(ind);
this->industries_near.insert(ind);
}
/**
@@ -464,7 +463,7 @@ void Station::RecomputeCatchment()
i->stations_near.insert(this);
/* Add if we can deliver to this industry as well */
AddIndustryToDeliver(i, this);
this->AddIndustryToDeliver(i);
}
}
}