Changeset - r14157:8722b3bbfc4d
[Not reviewed]
master
0 5 0
rubidium - 14 years ago 2010-01-04 18:12:10
rubidium@openttd.org
(svn r18715) -Codechange: make StationFinder a subclass of TileArea
5 files changed with 7 insertions and 12 deletions:
0 comments (0 inline, 0 general)
src/industry_cmd.cpp
Show inline comments
 
@@ -509,7 +509,7 @@ static void TransportIndustryGoods(TileI
 
	const IndustrySpec *indspec = GetIndustrySpec(i->type);
 
	bool moved_cargo = false;
 

	
 
	StationFinder stations(i->xy, i->width, i->height);
 
	StationFinder stations(TileArea(i->xy, i->width, i->height));
 

	
 
	for (uint j = 0; j < lengthof(i->produced_cargo_waiting); j++) {
 
		uint cw = min(i->produced_cargo_waiting[j], 255);
src/station_cmd.cpp
Show inline comments
 
@@ -3035,7 +3035,7 @@ void FindStationsAroundTiles(TileIndex t
 
const StationList *StationFinder::GetStations()
 
{
 
	if (this->tile != INVALID_TILE) {
 
		FindStationsAroundTiles(this->tile, this->x_extent, this->y_extent, &this->stations);
 
		FindStationsAroundTiles(this->tile, this->w, this->h, &this->stations);
 
		this->tile = INVALID_TILE;
 
	}
 
	return &this->stations;
src/station_type.h
Show inline comments
 
@@ -99,19 +99,14 @@ typedef SmallVector<Station *, 2> Statio
 
 * Structure contains cached list of stations nearby. The list
 
 * is created upon first call to GetStations()
 
 */
 
class StationFinder {
 
class StationFinder : TileArea {
 
	StationList stations; ///< List of stations nearby
 
	TileIndex tile;       ///< Northern tile of producer, INVALID_TILE when # stations is valid
 
	int x_extent;         ///< Width of producer
 
	int y_extent;         ///< Height of producer
 
public:
 
	/**
 
	 * Constructs StationFinder
 
	 * @param t northern tile
 
	 * @param dx width of producer
 
	 * @param dy height of producer
 
	 * @param area the area to search from
 
	 */
 
	StationFinder(TileIndex t, int dx, int dy) : tile(t), x_extent(dx), y_extent(dy) {}
 
	StationFinder(const TileArea &area) : TileArea(area) {}
 
	const StationList *GetStations();
 
};
 

	
src/town_cmd.cpp
Show inline comments
 
@@ -465,7 +465,7 @@ static void TileLoop_Town(TileIndex tile
 
	Town *t = Town::GetByTile(tile);
 
	uint32 r = Random();
 

	
 
	StationFinder stations(tile, 1, 1);
 
	StationFinder stations(TileArea(tile, 1, 1));
 

	
 
	if (HasBit(hs->callback_mask, CBM_HOUSE_PRODUCE_CARGO)) {
 
		for (uint i = 0; i < 256; i++) {
src/unmovable_cmd.cpp
Show inline comments
 
@@ -343,7 +343,7 @@ static void TileLoop_Unmovable(TileIndex
 
	uint level = GetCompanyHQSize(tile) + 1;
 
	assert(level < 6);
 

	
 
	StationFinder stations(tile, 2, 2);
 
	StationFinder stations(TileArea(tile, 2, 2));
 

	
 
	uint r = Random();
 
	/* Top town buildings generate 250, so the top HQ type makes 256. */
0 comments (0 inline, 0 general)