From ddaffef632a504e06b51628de256d2bd152c0c2a Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Tue, 13 Oct 2020 23:06:33 +0100 Subject: [PATCH] Add viewport map mode: routes --- src/viewport.cpp | 61 +++++++++++++++++++++++++++++++++++++++++++++ src/viewport_type.h | 1 + 2 files changed, 62 insertions(+) diff --git a/src/viewport.cpp b/src/viewport.cpp index 37d05f0fd5..eb1ed70b69 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -2728,6 +2728,66 @@ static inline uint32 ViewportMapGetColourOwner(const TileIndex tile, TileType t, return colour; } +template +static inline uint32 ViewportMapGetColourRoutes(const TileIndex tile, TileType t, const uint colour_index) +{ + uint32 colour; + + switch (t) { + case MP_WATER: + if (is_32bpp) { + uint slope_index = 0; + if (IsTileType(tile, MP_WATER) && GetWaterTileType(tile) != WATER_TILE_COAST) GET_SLOPE_INDEX(slope_index); + return _vp_map_water_colour[slope_index]; + } else { + return PC_WATER; + } + + case MP_INDUSTRY: + return IS32(PC_DARK_GREY); + + case MP_HOUSE: + case MP_OBJECT: + return IS32(colour_index & 1 ? PC_DARK_RED : GREY_SCALE(3)); + + case MP_STATION: + switch (GetStationType(tile)) { + case STATION_RAIL: return IS32(PC_VERY_DARK_BROWN); + case STATION_AIRPORT: return IS32(PC_RED); + case STATION_TRUCK: return IS32(PC_ORANGE); + case STATION_BUS: return IS32(PC_YELLOW); + case STATION_DOCK: return IS32(PC_LIGHT_BLUE); + default: return IS32(0xFF); + } + + case MP_RAILWAY: { + colour = GetRailTypeInfo(GetRailType(tile))->map_colour; + break; + } + + case MP_ROAD: { + const RoadTypeInfo *rti = nullptr; + if (GetRoadTypeRoad(tile) != INVALID_ROADTYPE) { + rti = GetRoadTypeInfo(GetRoadTypeRoad(tile)); + } else { + rti = GetRoadTypeInfo(GetRoadTypeTram(tile)); + } + if (rti != nullptr) { + colour = rti->map_colour; + break; + } + FALLTHROUGH; + } + + default: + colour = COLOUR_FROM_INDEX(_heightmap_schemes[_settings_client.gui.smallmap_land_colour].height_colours[TileHeight(tile)]); + break; + } + + if (show_slope) ASSIGN_SLOPIFIED_COLOUR(tile, nullptr, colour, _lighten_colour[colour], _darken_colour[colour], colour); + return IS32(colour); +} + static inline void ViewportMapStoreBridgeAboveTile(const Viewport * const vp, const TileIndex tile) { /* No need to bother for hidden things */ @@ -2832,6 +2892,7 @@ uint32 ViewportMapGetColour(const Viewport * const vp, uint x, uint y, const uin default: return ViewportMapGetColourOwner(tile, tile_type, colour_index); case VPMT_INDUSTRY: return ViewportMapGetColourIndustries(tile, tile_type, colour_index); case VPMT_VEGETATION: return ViewportMapGetColourVegetation(tile, tile_type, colour_index); + case VPMT_ROUTES: return ViewportMapGetColourRoutes(tile, tile_type, colour_index); } } diff --git a/src/viewport_type.h b/src/viewport_type.h index 4383758d2f..94f7b5839b 100644 --- a/src/viewport_type.h +++ b/src/viewport_type.h @@ -22,6 +22,7 @@ enum ViewportMapType { VPMT_BEGIN = 0, VPMT_VEGETATION = 0, VPMT_OWNER, + VPMT_ROUTES, VPMT_INDUSTRY, VPMT_END,