| 573 | } |
| 574 | |
| 575 | CommandCost StationRect::BeforeAddTile(TileIndex tile, StationRectMode mode) |
| 576 | { |
| 577 | int x = TileX(tile); |
| 578 | int y = TileY(tile); |
| 579 | if (this->IsEmpty()) { |
| 580 | /* we are adding the first station tile */ |
| 581 | if (mode != ADD_TEST) { |
| 582 | this->left = this->right = x; |
| 583 | this->top = this->bottom = y; |
| 584 | } |
| 585 | } else if (!this->PtInExtendedRect(x, y)) { |
| 586 | /* current rect is not empty and new point is outside this rect |
| 587 | * make new spread-out rectangle */ |
| 588 | Rect new_rect = {std::min(x, this->left), std::min(y, this->top), std::max(x, this->right), std::max(y, this->bottom)}; |
| 589 | |
| 590 | /* check new rect dimensions against preset max */ |
| 591 | int w = new_rect.Width(); |
| 592 | int h = new_rect.Height(); |
| 593 | if (mode != ADD_FORCE && (w > _settings_game.station.station_spread || h > _settings_game.station.station_spread)) { |
| 594 | assert(mode != ADD_TRY); |
| 595 | return CommandCost(STR_ERROR_STATION_TOO_SPREAD_OUT); |
| 596 | } |
| 597 | |
| 598 | /* spread-out ok, return true */ |
| 599 | if (mode != ADD_TEST) { |
| 600 | /* we should update the station rect */ |
| 601 | *this = new_rect; |
| 602 | } |
| 603 | } else { |
| 604 | ; // new point is inside the rect, we don't need to do anything |
| 605 | } |
| 606 | return CommandCost(); |
| 607 | } |
| 608 | |
| 609 | CommandCost StationRect::BeforeAddRect(TileIndex tile, int w, int h, StationRectMode mode) |
| 610 | { |
no test coverage detected