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

Method GetTileColours

src/smallmap_gui.cpp:1320–1394  ·  view source on GitHub ↗

* Decide which colours to show to the user for a group of tiles. * @param ta Tile area to investigate. * @return Colours to display. */

Source from the content-addressed store, hash-verified

1318 * @return Colours to display.
1319 */
1320 uint32_t GetTileColours(const TileArea &ta) const
1321 {
1322 int importance = 0;
1323 TileIndex tile = INVALID_TILE; // Position of the most important tile.
1324 TileType et = MP_VOID; // Effective tile type at that position.
1325
1326 for (TileIndex ti : ta) {
1327 TileType ttype = GetTileType(ti);
1328
1329 switch (ttype) {
1330 case MP_TUNNELBRIDGE: {
1331 TransportType tt = GetTunnelBridgeTransportType(ti);
1332
1333 switch (tt) {
1334 case TRANSPORT_RAIL: ttype = MP_RAILWAY; break;
1335 case TRANSPORT_ROAD: ttype = MP_ROAD; break;
1336 default: ttype = MP_WATER; break;
1337 }
1338 break;
1339 }
1340
1341 case MP_INDUSTRY:
1342 /* Special handling of industries while in "Industries" smallmap view. */
1343 if (this->map_type == SMT_INDUSTRY) {
1344 /* If industry is allowed to be seen, use its colour on the map.
1345 * This has the highest priority above any value in _tiletype_importance. */
1346 IndustryType type = Industry::GetByTile(ti)->type;
1347 if (_legend_from_industries[_industry_to_list_pos[type]].show_on_map) {
1348 if (type == _smallmap_industry_highlight) {
1349 if (_smallmap_industry_highlight_state) return MKCOLOUR_XXXX(PC_WHITE);
1350 } else {
1351 return GetIndustrySpec(type)->map_colour.p * 0x01010101;
1352 }
1353 }
1354 /* Otherwise make it disappear */
1355 ttype = IsTileOnWater(ti) ? MP_WATER : MP_CLEAR;
1356 }
1357 break;
1358
1359 default:
1360 break;
1361 }
1362
1363 if (_tiletype_importance[ttype] > importance) {
1364 importance = _tiletype_importance[ttype];
1365 tile = ti;
1366 et = ttype;
1367 }
1368 }
1369
1370 switch (this->map_type) {
1371 case SMT_CONTOUR:
1372 return GetSmallMapContoursPixels(tile, et);
1373
1374 case SMT_VEHICLES:
1375 return GetSmallMapVehiclesPixels(tile, et);
1376
1377 case SMT_INDUSTRY:

Callers 1

DrawSmallMapColumnMethod · 0.95

Calls 12

GetTileTypeFunction · 0.85
GetIndustrySpecFunction · 0.85
IsTileOnWaterFunction · 0.85
GetSmallMapRoutesPixelsFunction · 0.85
GetSmallMapOwnerPixelsFunction · 0.85
NOT_REACHEDFunction · 0.85

Tested by

no test coverage detected