mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-28 08:59:09 +00:00
(svn r18715) -Codechange: make StationFinder a subclass of TileArea
This commit is contained in:
@@ -509,7 +509,7 @@ static void TransportIndustryGoods(TileIndex tile)
|
||||
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);
|
||||
|
@@ -3035,7 +3035,7 @@ void FindStationsAroundTiles(TileIndex tile, int w_prod, int h_prod, StationList
|
||||
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;
|
||||
|
@@ -99,19 +99,14 @@ typedef SmallVector<Station *, 2> StationList;
|
||||
* 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();
|
||||
};
|
||||
|
||||
|
@@ -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++) {
|
||||
|
@@ -343,7 +343,7 @@ static void TileLoop_Unmovable(TileIndex tile)
|
||||
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. */
|
||||
|
Reference in New Issue
Block a user