mirror of https://github.com/OpenTTD/OpenTTD
(svn r17106) -Codechange: move computation of station's catchment rectagle to separate function
parent
33288c9d50
commit
39e145e586
|
@ -239,6 +239,27 @@ uint Station::GetCatchmentRadius() const
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines catchment rectangle of this station
|
||||||
|
* @return clamped catchment rectangle
|
||||||
|
*/
|
||||||
|
Rect Station::GetCatchmentRect() const
|
||||||
|
{
|
||||||
|
assert(!this->rect.IsEmpty());
|
||||||
|
|
||||||
|
/* Compute acceptance rectangle */
|
||||||
|
int catchment_radius = this->GetCatchmentRadius();
|
||||||
|
|
||||||
|
Rect ret = {
|
||||||
|
max<int>(this->rect.left - catchment_radius, 0),
|
||||||
|
max<int>(this->rect.top - catchment_radius, 0),
|
||||||
|
min<int>(this->rect.right + catchment_radius, MapMaxX()),
|
||||||
|
min<int>(this->rect.bottom + catchment_radius, MapMaxY())
|
||||||
|
};
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/** Rect and pointer to IndustryVector */
|
/** Rect and pointer to IndustryVector */
|
||||||
struct RectAndIndustryVector {
|
struct RectAndIndustryVector {
|
||||||
Rect rect;
|
Rect rect;
|
||||||
|
@ -290,16 +311,8 @@ void Station::RecomputeIndustriesNear()
|
||||||
this->industries_near.Clear();
|
this->industries_near.Clear();
|
||||||
if (this->rect.IsEmpty()) return;
|
if (this->rect.IsEmpty()) return;
|
||||||
|
|
||||||
/* Compute acceptance rectangle */
|
|
||||||
int catchment_radius = this->GetCatchmentRadius();
|
|
||||||
|
|
||||||
RectAndIndustryVector riv = {
|
RectAndIndustryVector riv = {
|
||||||
{
|
this->GetCatchmentRect(),
|
||||||
max<int>(this->rect.left - catchment_radius, 0),
|
|
||||||
max<int>(this->rect.top - catchment_radius, 0),
|
|
||||||
min<int>(this->rect.right + catchment_radius, MapMaxX()),
|
|
||||||
min<int>(this->rect.bottom + catchment_radius, MapMaxY())
|
|
||||||
},
|
|
||||||
&this->industries_near
|
&this->industries_near
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -101,6 +101,7 @@ public:
|
||||||
static void RecomputeIndustriesNearForAll();
|
static void RecomputeIndustriesNearForAll();
|
||||||
|
|
||||||
uint GetCatchmentRadius() const;
|
uint GetCatchmentRadius() const;
|
||||||
|
Rect GetCatchmentRect() const;
|
||||||
|
|
||||||
/* virtual */ FORCEINLINE bool TileBelongsToRailStation(TileIndex tile) const
|
/* virtual */ FORCEINLINE bool TileBelongsToRailStation(TileIndex tile) const
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue