diff options
author | rubidium <rubidium@openttd.org> | 2010-01-04 21:10:20 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2010-01-04 21:10:20 +0000 |
commit | 28fc7b47bd35acc860e84e3885d13ffb0fad2c83 (patch) | |
tree | c461b7b47abb73891c5caf5d490cede32158ed0d /src/station.cpp | |
parent | 1ed599f5cf6a0dec14d91d5442a08560e254d35c (diff) | |
download | openttd-28fc7b47bd35acc860e84e3885d13ffb0fad2c83.tar.xz |
(svn r18726) -Fix [FS#3463]: with non-uniform industries the 'supplies' text when building a station could be incorrect (missing a cargo)
-Change [NoAI]: AITile::GetCargoProduction now returns the number of producers and not the number of tiles of producers.
-Fix [NoAI]: AITileList_IndustryProducing would omit some tiles for at which a station would get cargo.
Diffstat (limited to 'src/station.cpp')
-rw-r--r-- | src/station.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/station.cpp b/src/station.cpp index a3c58052a..659ece367 100644 --- a/src/station.cpp +++ b/src/station.cpp @@ -539,6 +539,30 @@ void TileArea::Add(TileIndex to_add) this->h = ey - sy + 1; } +bool TileArea::Intersects(const TileArea &ta) const +{ + if (ta.w == 0 || this->w == 0) return false; + + assert(ta.w != 0 && ta.h != 0 && this->w != 0 && this->h != 0); + + uint left1 = TileX(this->tile); + uint top1 = TileY(this->tile); + uint right1 = left1 + this->w - 1; + uint bottom1 = top1 + this->h - 1; + + uint left2 = TileX(ta.tile); + uint top2 = TileY(ta.tile); + uint right2 = left2 + ta.w - 1; + uint bottom2 = top2 + ta.h - 1; + + return !( + left2 > right1 || + right2 < left1 || + top2 > bottom1 || + bottom2 < top1 + ); +} + void InitializeStations() { |