Skip to content

Commit

Permalink
Fix #7235: Ensure catchment area of neutral station covers entire ind…
Browse files Browse the repository at this point in the history
…ustry. (#7518)
  • Loading branch information
PeterN committed Apr 16, 2019
1 parent 8ae15d9 commit 671a310
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/bitmap_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class BitmapTileArea : public TileArea {
* Initialize the BitmapTileArea with the specified Rect.
* @param rect Rect to use.
*/
void Initialize(Rect r)
void Initialize(const Rect &r)
{
this->tile = TileXY(r.left, r.top);
this->w = r.right - r.left + 1;
Expand All @@ -66,6 +66,15 @@ class BitmapTileArea : public TileArea {
this->data.resize(Index(w, h));
}

void Initialize(const TileArea &ta)
{
this->tile = ta.tile;
this->w = ta.w;
this->h = ta.h;
this->data.clear();
this->data.resize(Index(w, h));
}

/**
* Add a tile as part of the tile area.
* @param tile Tile to add.
Expand Down
4 changes: 3 additions & 1 deletion src/station.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,10 +421,10 @@ void Station::RecomputeCatchment()
this->catchment_tiles.Reset();
return;
}
this->catchment_tiles.Initialize(GetCatchmentRect());

if (!_settings_game.station.serve_neutral_industries && this->industry != nullptr) {
/* Station is associated with an industry, so we only need to deliver to that industry. */
this->catchment_tiles.Initialize(this->industry->location);
TILE_AREA_LOOP(tile, this->industry->location) {
if (IsTileType(tile, MP_INDUSTRY) && GetIndustryIndex(tile) == this->industry->index) {
this->catchment_tiles.SetTile(tile);
Expand All @@ -440,6 +440,8 @@ void Station::RecomputeCatchment()
return;
}

this->catchment_tiles.Initialize(GetCatchmentRect());

/* Loop finding all station tiles */
TileArea ta(TileXY(this->rect.left, this->rect.top), TileXY(this->rect.right, this->rect.bottom));
TILE_AREA_LOOP(tile, ta) {
Expand Down

0 comments on commit 671a310

Please sign in to comment.