| 4708 | } |
| 4709 | |
| 4710 | void BuildOilRig(TileIndex tile) |
| 4711 | { |
| 4712 | if (!Station::CanAllocateItem()) { |
| 4713 | Debug(misc, 0, "Can't allocate station for oilrig at 0x{:X}, reverting to oilrig only", tile); |
| 4714 | return; |
| 4715 | } |
| 4716 | |
| 4717 | Station *st = new Station(tile); |
| 4718 | _station_kdtree.Insert(st->index); |
| 4719 | st->town = ClosestTownFromTile(tile, UINT_MAX); |
| 4720 | |
| 4721 | st->string_id = GenerateStationName(st, tile, STATIONNAMING_OILRIG); |
| 4722 | |
| 4723 | assert(IsTileType(tile, MP_INDUSTRY)); |
| 4724 | /* Mark industry as associated both ways */ |
| 4725 | st->industry = Industry::GetByTile(tile); |
| 4726 | st->industry->neutral_station = st; |
| 4727 | DeleteAnimatedTile(tile); |
| 4728 | MakeOilrig(tile, st->index, GetWaterClass(tile)); |
| 4729 | |
| 4730 | st->owner = OWNER_NONE; |
| 4731 | st->airport.type = AT_OILRIG; |
| 4732 | st->airport.rotation = DIR_N; |
| 4733 | st->airport.Add(tile); |
| 4734 | st->ship_station.Add(tile); |
| 4735 | st->facilities = {StationFacility::Airport, StationFacility::Dock}; |
| 4736 | st->build_date = TimerGameCalendar::date; |
| 4737 | UpdateStationDockingTiles(st); |
| 4738 | |
| 4739 | st->rect.BeforeAddTile(tile, StationRect::ADD_FORCE); |
| 4740 | |
| 4741 | st->UpdateVirtCoord(); |
| 4742 | |
| 4743 | /* An industry tile has now been replaced with a station tile, this may change the overlap between station catchments and industry tiles. |
| 4744 | * Recalculate the station catchment for all stations currently in the industry's nearby list. |
| 4745 | * Clear the industry's station nearby list first because Station::RecomputeCatchment cannot remove nearby industries in this case. */ |
| 4746 | if (_settings_game.station.serve_neutral_industries) { |
| 4747 | StationList nearby = std::move(st->industry->stations_near); |
| 4748 | st->industry->stations_near.clear(); |
| 4749 | for (Station *near : nearby) { |
| 4750 | near->RecomputeCatchment(true); |
| 4751 | UpdateStationAcceptance(near, true); |
| 4752 | } |
| 4753 | } |
| 4754 | |
| 4755 | st->RecomputeCatchment(); |
| 4756 | UpdateStationAcceptance(st, false); |
| 4757 | } |
| 4758 | |
| 4759 | void DeleteOilRig(TileIndex tile) |
| 4760 | { |
no test coverage detected