From c5c0e88916f2aad629f8b5bbabf33ed46450c9f6 Mon Sep 17 00:00:00 2001 From: SamuXarick <43006711+SamuXarick@users.noreply.github.com> Date: Sun, 6 Apr 2025 10:02:24 +0100 Subject: [PATCH] Codechange: Simplify logic for determining road tile colour in 'Routes' mode of small map. --- src/smallmap_gui.cpp | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index e8ef37c65f..2dd4363476 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -463,7 +463,7 @@ static inline uint32_t GetSmallMapIndustriesPixels(TileIndex tile, TileType t) * * @param tile The tile of which we would like to get the colour. * @param t Effective tile type of the tile (see #SmallMapWindow::GetTileColours). - * @return The colour of tile in the small map in mode "Routes" + * @return The colour of tile in the small map in mode "Routes" */ static inline uint32_t GetSmallMapRoutesPixels(TileIndex tile, TileType t) { @@ -489,22 +489,15 @@ static inline uint32_t GetSmallMapRoutesPixels(TileIndex tile, TileType t) } case MP_ROAD: { - const RoadTypeInfo *rti = nullptr; - if (GetRoadTypeRoad(tile) != INVALID_ROADTYPE) { - rti = GetRoadTypeInfo(GetRoadTypeRoad(tile)); - } else { - rti = GetRoadTypeInfo(GetRoadTypeTram(tile)); - } - if (rti != nullptr) { - AndOr andor = { - MKCOLOUR_0XX0(rti->map_colour), - _smallmap_contours_andor[t].mand - }; + RoadType rt_road = GetRoadTypeRoad(tile); - const SmallMapColourScheme *cs = &_heightmap_schemes[_settings_client.gui.smallmap_land_colour]; - return ApplyMask(cs->default_colour, &andor); - } - [[fallthrough]]; + AndOr andor = { + MKCOLOUR_0XX0(GetRoadTypeInfo(rt_road != INVALID_ROADTYPE ? rt_road : GetRoadTypeTram(tile))->map_colour), + _smallmap_contours_andor[t].mand + }; + + const SmallMapColourScheme *cs = &_heightmap_schemes[_settings_client.gui.smallmap_land_colour]; + return ApplyMask(cs->default_colour, &andor); } default: