30 #include "table/strings.h"
39 template<> StationIDStackPool
StationIDStack::_pool = StationIDStackPool();
46 if (CleaningPool())
return;
53 this->sign.MarkDirty();
63 time_since_unload(255),
80 this->goods[c].cargo.OnCleanPool();
85 while (!this->loading_vehicles.empty()) {
86 this->loading_vehicles.front()->LeaveStation();
97 if (lg == NULL)
continue;
99 for (NodeID node = 0; node < lg->
Size(); ++node) {
102 if ((*lg)[node][this->goods[c].node].LastUpdate() !=
INVALID_DATE) {
108 if (lg->
Size() == 0) {
126 delete this->airport.psa;
144 this->goods[c].cargo.Truncate();
170 for (; rs != NULL; rs = rs->
next) {
191 this->random_bits = Random();
193 this->facilities |= new_facility_bit;
195 this->build_date =
_date;
205 TileIndex tile = this->train_station.tile;
216 if (this->num_specs == 0)
return;
219 for (h = 0; h < train_station.h; h++) {
220 for (w = 0; w < train_station.w; w++) {
221 if (this->TileBelongsToRailStation(tile)) {
232 assert(this->TileBelongsToRailStation(tile));
276 if (this->bus_stops != NULL) ret = max<uint>(ret,
CA_BUS);
277 if (this->truck_stops != NULL) ret = max<uint>(ret,
CA_TRUCK);
280 if (this->airport.tile !=
INVALID_TILE) ret = max<uint>(ret, this->airport.GetSpec()->catchment);
282 if (this->bus_stops != NULL || this->truck_stops != NULL || this->train_station.tile !=
INVALID_TILE || this->dock_tile !=
INVALID_TILE || this->airport.tile !=
INVALID_TILE) {
296 assert(!this->rect.IsEmpty());
299 int catchment_radius = this->GetCatchmentRadius();
302 max<int>(this->rect.left - catchment_radius, 0),
303 max<int>(this->rect.top - catchment_radius, 0),
304 min<int>(this->rect.right + catchment_radius,
MapMaxX()),
305 min<int>(this->rect.bottom + catchment_radius,
MapMaxY())
337 int x =
TileX(ind_tile);
338 int y =
TileY(ind_tile);
339 if (x < riv->rect.left || x > riv->
rect.right || y < riv->rect.top || y > riv->
rect.bottom)
return false;
359 this->industries_near.Clear();
360 if (this->rect.IsEmpty())
return;
363 this->GetCatchmentRect(),
364 &this->industries_near
369 uint max_radius =
max(
390 StationRect::StationRect()
395 void StationRect::MakeEmpty()
397 this->left = this->top = this->right = this->bottom = 0;
411 return this->left - distance <= x && x <= this->right + distance &&
412 this->top - distance <= y && y <= this->bottom + distance;
415 bool StationRect::IsEmpty()
const
417 return this->left == 0 || this->left > this->right || this->top > this->bottom;
424 if (this->IsEmpty()) {
426 if (mode != ADD_TEST) {
427 this->left = this->right = x;
428 this->top = this->bottom = y;
430 }
else if (!this->PtInExtendedRect(x, y)) {
433 Rect new_rect = {
min(x, this->left),
min(y, this->top),
max(x, this->right),
max(y, this->bottom)};
436 int w = new_rect.right - new_rect.left + 1;
437 int h = new_rect.bottom - new_rect.top + 1;
439 assert(mode != ADD_TRY);
444 if (mode != ADD_TEST) {
484 bool StationRect::AfterRemoveTile(BaseStation *st,
TileIndex tile)
494 bool left_edge = (x == this->left);
495 bool right_edge = (x == this->right);
496 bool top_edge = (y == this->top);
497 bool bottom_edge = (y == this->bottom);
500 bool reduce_x = ((left_edge || right_edge) && !ScanForStationTiles(st->
index, x, this->top, x, this->bottom));
501 bool reduce_y = ((top_edge || bottom_edge) && !ScanForStationTiles(st->
index, this->left, y, this->right, y));
502 if (!(reduce_x || reduce_y))
break;
508 this->left = x = x + 1;
511 this->right = x = x - 1;
518 this->top = y = y + 1;
521 this->bottom = y = y - 1;
525 if (left > right || top > bottom) {
534 bool StationRect::AfterRemoveRect(BaseStation *st,
TileArea ta)
539 bool empty = this->AfterRemoveTile(st, ta.
tile);
540 if (ta.
w != 1 || ta.
h != 1) empty = empty || this->AfterRemoveTile(st,
TILE_ADDXY(ta.
tile, ta.
w - 1, ta.
h - 1));
546 this->left = src.left;
548 this->right = src.right;
549 this->bottom = src.bottom;
560 Money total_cost = 0;
563 FOR_ALL_STATIONS(st) {
569 return total_cost >> 3;