Skip to content

Commit

Permalink
Fix: Invalid catchment initialization if station rect is empty.
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterN committed Feb 19, 2019
1 parent cb6a8b9 commit 786ea76
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/core/bitmap_type.hpp
Expand Up @@ -52,6 +52,14 @@ class BitmapTileArea : Bitmap, public TileArea {
this->h = 0;
}

void Reset()
{
this->tile = INVALID_TILE;
this->w = 0;
this->h = 0;
this->Bitmap::Reset();
}

void Initialize(Rect r)
{
this->tile = TileXY(r.left, r.top);
Expand Down
6 changes: 4 additions & 2 deletions src/station.cpp
Expand Up @@ -396,10 +396,12 @@ bool Station::CatchmentCoversTown(TownID t)
*/
void Station::RecomputeCatchment()
{
if (this->rect.IsEmpty()) {
this->catchment_tiles.Reset();
return;
}
this->catchment_tiles.Initialize(GetCatchmentRect());

if (this->rect.IsEmpty()) return;

/* 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 786ea76

Please sign in to comment.