MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / GetTileHighlightType

Function GetTileHighlightType

src/viewport.cpp:1022–1064  ·  view source on GitHub ↗

* Get tile highlight type of coverage area for a given tile. * @param t Tile that is being drawn * @return Tile highlight type to draw */

Source from the content-addressed store, hash-verified

1020 * @return Tile highlight type to draw
1021 */
1022static TileHighlightType GetTileHighlightType(TileIndex t)
1023{
1024 if (_viewport_highlight_station != nullptr) {
1025 if (IsTileType(t, MP_STATION) && GetStationIndex(t) == _viewport_highlight_station->index) return THT_WHITE;
1026 if (_viewport_highlight_station->TileIsInCatchment(t)) return THT_BLUE;
1027 }
1028
1029 if (_viewport_highlight_station_rect != nullptr) {
1030 if (IsTileType(t, MP_STATION) && GetStationIndex(t) == _viewport_highlight_station_rect->index) return THT_WHITE;
1031 const StationRect *r = &_viewport_highlight_station_rect->rect;
1032 if (r->PtInExtendedRect(TileX(t), TileY(t))) return THT_BLUE;
1033 }
1034
1035 if (_viewport_highlight_waypoint != nullptr) {
1036 if (IsTileType(t, MP_STATION) && GetStationIndex(t) == _viewport_highlight_waypoint->index) return THT_BLUE;
1037 }
1038
1039 if (_viewport_highlight_waypoint_rect != nullptr) {
1040 if (IsTileType(t, MP_STATION) && GetStationIndex(t) == _viewport_highlight_waypoint_rect->index) return THT_WHITE;
1041 const StationRect *r = &_viewport_highlight_waypoint_rect->rect;
1042 if (r->PtInExtendedRect(TileX(t), TileY(t))) return THT_BLUE;
1043 }
1044
1045 if (_viewport_highlight_town != nullptr) {
1046 if (IsTileType(t, MP_HOUSE)) {
1047 if (GetTownIndex(t) == _viewport_highlight_town->index) {
1048 TileHighlightType type = THT_RED;
1049 for (const Station *st : _viewport_highlight_town->stations_near) {
1050 if (st->owner != _current_company) continue;
1051 if (st->TileIsInCatchment(t)) return THT_BLUE;
1052 }
1053 return type;
1054 }
1055 } else if (IsTileType(t, MP_STATION)) {
1056 for (const Station *st : _viewport_highlight_town->stations_near) {
1057 if (st->owner != _current_company) continue;
1058 if (GetStationIndex(t) == st->index) return THT_WHITE;
1059 }
1060 }
1061 }
1062
1063 return THT_NONE;
1064}
1065
1066/**
1067 * Draw tile highlight for coverage area highlight.

Callers 1

DrawTileSelectionFunction · 0.85

Calls 7

IsTileTypeFunction · 0.85
GetStationIndexFunction · 0.85
TileXFunction · 0.85
TileYFunction · 0.85
GetTownIndexFunction · 0.85
TileIsInCatchmentMethod · 0.80
PtInExtendedRectMethod · 0.80

Tested by

no test coverage detected