summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-01-04 18:12:10 +0000
committerrubidium <rubidium@openttd.org>2010-01-04 18:12:10 +0000
commit31b325baafc0abe02c380af63dd6f5fe86f573fd (patch)
treee30c57a9b62586f846c736ccfa4ee5a10eb86049 /src
parent8b88bb0c9bf1072881b4111a339eb6781fdb80bc (diff)
downloadopenttd-31b325baafc0abe02c380af63dd6f5fe86f573fd.tar.xz
(svn r18715) -Codechange: make StationFinder a subclass of TileArea
Diffstat (limited to 'src')
-rw-r--r--src/industry_cmd.cpp2
-rw-r--r--src/station_cmd.cpp2
-rw-r--r--src/station_type.h11
-rw-r--r--src/town_cmd.cpp2
-rw-r--r--src/unmovable_cmd.cpp2
5 files changed, 7 insertions, 12 deletions
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index 8e4b7ffcb..0c329bd8e 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -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);
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index f51a32def..39e6283bd 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -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;
diff --git a/src/station_type.h b/src/station_type.h
index 141e6dc61..26e766b8c 100644
--- a/src/station_type.h
+++ b/src/station_type.h
@@ -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();
};
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index c96c2d239..0003a512f 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -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++) {
diff --git a/src/unmovable_cmd.cpp b/src/unmovable_cmd.cpp
index 73d7da29a..aab147099 100644
--- a/src/unmovable_cmd.cpp
+++ b/src/unmovable_cmd.cpp
@@ -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. */