* Calculates and draws the accepted or supplied cargo around the selected tile(s) * @param r Rect where the string is to be drawn. * @param sct which type of cargo is to be displayed (passengers/non-passengers) * @param rad radius around selected tile(s) to be searched * @param supplies if supplied cargoes should be drawn, else accepted cargoes * @return Returns the y value below the string t
| 75 | * @return Returns the y value below the string that was drawn |
| 76 | */ |
| 77 | int DrawStationCoverageAreaText(const Rect &r, StationCoverageType sct, int rad, bool supplies) |
| 78 | { |
| 79 | TileIndex tile = TileVirtXY(_thd.pos.x, _thd.pos.y); |
| 80 | CargoTypes cargo_mask = 0; |
| 81 | if (_thd.drawstyle == HT_RECT && tile < Map::Size()) { |
| 82 | CargoArray cargoes; |
| 83 | if (supplies) { |
| 84 | cargoes = GetProductionAroundTiles(tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE, rad); |
| 85 | } else { |
| 86 | cargoes = GetAcceptanceAroundTiles(tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE, rad); |
| 87 | } |
| 88 | |
| 89 | /* Convert cargo counts to a set of cargo bits, and draw the result. */ |
| 90 | for (CargoType cargo = 0; cargo < NUM_CARGO; ++cargo) { |
| 91 | switch (sct) { |
| 92 | case SCT_PASSENGERS_ONLY: if (!IsCargoInClass(cargo, CargoClass::Passengers)) continue; break; |
| 93 | case SCT_NON_PASSENGERS_ONLY: if (IsCargoInClass(cargo, CargoClass::Passengers)) continue; break; |
| 94 | case SCT_ALL: break; |
| 95 | default: NOT_REACHED(); |
| 96 | } |
| 97 | if (cargoes[cargo] >= (supplies ? 1U : 8U)) SetBit(cargo_mask, cargo); |
| 98 | } |
| 99 | } |
| 100 | return DrawStringMultiLine(r, GetString(supplies ? STR_STATION_BUILD_SUPPLIES_CARGO : STR_STATION_BUILD_ACCEPTS_CARGO, cargo_mask)); |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * Find stations adjacent to the current tile highlight area, so that existing coverage |
no test coverage detected