(svn r18377) -Codechange: add 'cache' of the tile area of truck and bus stops.

This commit is contained in:
rubidium
2009-12-02 16:20:44 +00:00
parent 1c65150d6d
commit 81062163a2
5 changed files with 75 additions and 8 deletions

View File

@@ -38,6 +38,8 @@ BaseStation::~BaseStation()
Station::Station(TileIndex tile) :
SpecializedStation<Station, false>(tile),
bus_station(INVALID_TILE, 0, 0),
truck_station(INVALID_TILE, 0, 0),
airport_tile(INVALID_TILE),
dock_tile(INVALID_TILE),
indtype(IT_INVALID),
@@ -511,6 +513,33 @@ TileArea::TileArea(TileIndex start, TileIndex end)
this->h = ey - sy + 1;
}
void TileArea::Add(TileIndex to_add)
{
if (this->tile == INVALID_TILE) {
this->tile = to_add;
this->w = 1;
this->h = 1;
return;
}
uint sx = TileX(this->tile);
uint sy = TileY(this->tile);
uint ex = sx + this->w - 1;
uint ey = sy + this->h - 1;
uint ax = TileX(to_add);
uint ay = TileY(to_add);
sx = min(ax, sx);
sy = min(ay, sy);
ex = max(ax, ex);
ey = max(ay, ey);
this->tile = TileXY(sx, sy);
this->w = ex - sx + 1;
this->h = ey - sy + 1;
}
void InitializeStations()
{