Changeset - r12641:561071636083
[Not reviewed]
master
0 2 0
smatz - 15 years ago 2009-08-07 21:11:58
smatz@openttd.org
(svn r17106) -Codechange: move computation of station's catchment rectagle to separate function
2 files changed with 23 insertions and 9 deletions:
0 comments (0 inline, 0 general)
src/station.cpp
Show inline comments
 
@@ -239,6 +239,27 @@ uint Station::GetCatchmentRadius() const
 
	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 */
 
struct RectAndIndustryVector {
 
	Rect rect;
 
@@ -290,16 +311,8 @@ void Station::RecomputeIndustriesNear()
 
	this->industries_near.Clear();
 
	if (this->rect.IsEmpty()) return;
 

	
 
	/* Compute acceptance rectangle */
 
	int catchment_radius = this->GetCatchmentRadius();
 

	
 
	RectAndIndustryVector riv = {
 
		{
 
			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->GetCatchmentRect(),
 
		&this->industries_near
 
	};
 

	
src/station_base.h
Show inline comments
 
@@ -101,6 +101,7 @@ public:
 
	static void RecomputeIndustriesNearForAll();
 

	
 
	uint GetCatchmentRadius() const;
 
	Rect GetCatchmentRect() const;
 

	
 
	/* virtual */ FORCEINLINE bool TileBelongsToRailStation(TileIndex tile) const
 
	{
0 comments (0 inline, 0 general)