1
0
Fork 0

(svn r18715) -Codechange: make StationFinder a subclass of TileArea

release/1.0
rubidium 2010-01-04 18:12:10 +00:00
parent 8b88bb0c9b
commit 31b325baaf
5 changed files with 7 additions and 12 deletions

View File

@ -509,7 +509,7 @@ static void TransportIndustryGoods(TileIndex tile)
const IndustrySpec *indspec = GetIndustrySpec(i->type); const IndustrySpec *indspec = GetIndustrySpec(i->type);
bool moved_cargo = false; 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++) { for (uint j = 0; j < lengthof(i->produced_cargo_waiting); j++) {
uint cw = min(i->produced_cargo_waiting[j], 255); uint cw = min(i->produced_cargo_waiting[j], 255);

View File

@ -3035,7 +3035,7 @@ void FindStationsAroundTiles(TileIndex tile, int w_prod, int h_prod, StationList
const StationList *StationFinder::GetStations() const StationList *StationFinder::GetStations()
{ {
if (this->tile != INVALID_TILE) { 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; this->tile = INVALID_TILE;
} }
return &this->stations; return &this->stations;

View File

@ -99,19 +99,14 @@ typedef SmallVector<Station *, 2> StationList;
* Structure contains cached list of stations nearby. The list * Structure contains cached list of stations nearby. The list
* is created upon first call to GetStations() * is created upon first call to GetStations()
*/ */
class StationFinder { class StationFinder : TileArea {
StationList stations; ///< List of stations nearby 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: public:
/** /**
* Constructs StationFinder * Constructs StationFinder
* @param t northern tile * @param area the area to search from
* @param dx width of producer
* @param dy height of producer
*/ */
StationFinder(TileIndex t, int dx, int dy) : tile(t), x_extent(dx), y_extent(dy) {} StationFinder(const TileArea &area) : TileArea(area) {}
const StationList *GetStations(); const StationList *GetStations();
}; };

View File

@ -465,7 +465,7 @@ static void TileLoop_Town(TileIndex tile)
Town *t = Town::GetByTile(tile); Town *t = Town::GetByTile(tile);
uint32 r = Random(); uint32 r = Random();
StationFinder stations(tile, 1, 1); StationFinder stations(TileArea(tile, 1, 1));
if (HasBit(hs->callback_mask, CBM_HOUSE_PRODUCE_CARGO)) { if (HasBit(hs->callback_mask, CBM_HOUSE_PRODUCE_CARGO)) {
for (uint i = 0; i < 256; i++) { for (uint i = 0; i < 256; i++) {

View File

@ -343,7 +343,7 @@ static void TileLoop_Unmovable(TileIndex tile)
uint level = GetCompanyHQSize(tile) + 1; uint level = GetCompanyHQSize(tile) + 1;
assert(level < 6); assert(level < 6);
StationFinder stations(tile, 2, 2); StationFinder stations(TileArea(tile, 2, 2));
uint r = Random(); uint r = Random();
/* Top town buildings generate 250, so the top HQ type makes 256. */ /* Top town buildings generate 250, so the top HQ type makes 256. */