diff --git a/src/lang/english.txt b/src/lang/english.txt index 6a843ab153..796230e9e8 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -6264,6 +6264,7 @@ STR_ZONING_IND_UNSER :Unserved indust STR_ZONING_TRACERESTRICT :Restricted signals STR_ZONING_2x2_GRID :2x2 town road grid STR_ZONING_3x3_GRID :3x3 town road grid +STR_ZONING_ONE_WAY_ROAD :One way roads STR_TMPL_RPL_TITLE :{WHITE}Template Replacement STR_TMPL_TEMPLATE_REPLACEMENT :Template Replacement diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index 3e779bbdd3..492b452e46 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -449,6 +449,16 @@ static bool IsOneWayRoadTile(TileIndex tile) return false; } +uint8 GetOneWayRoadTileType(TileIndex tile) +{ + if (IsNormalRoadTile(tile)) { + if (GetDisallowedRoadDirections(tile) != DRD_NONE) return 1; + if (IsOneWaySideJunctionRoad(tile)) return 2; + } + if (IsDriveThroughStopTile(tile) && GetDriveThroughStopDisallowedRoadDirections(tile) != DRD_NONE) return 3; + return 0; +} + /** * Turn a roadvehicle around. * @param tile unused diff --git a/src/zoning.h b/src/zoning.h index 9a5a11875e..2cad5f3a87 100644 --- a/src/zoning.h +++ b/src/zoning.h @@ -27,6 +27,7 @@ enum ZoningEvaluationMode { ZEM_TRACERESTRICT, ///< Check for restricted signals ZEM_2x2_GRID, ///< Show 2x2 town road grid ZEM_3x3_GRID, ///< Show 3x3 town road grid + ZEM_ONE_WAY_ROAD, ///< Show one way roads ZEM_END, ///< End marker }; diff --git a/src/zoning_cmd.cpp b/src/zoning_cmd.cpp index 3c0005c8a3..10fce275db 100644 --- a/src/zoning_cmd.cpp +++ b/src/zoning_cmd.cpp @@ -273,6 +273,30 @@ inline SpriteID TileZoneCheckRoadGridEvaluation(TileIndex tile, uint grid_size) } } +/** + * Detect whether a tile is a one way road + * + * @param TileIndex tile + * @param Owner owner + * @return red if a restricted signal, nothing otherwise + */ +inline SpriteID TileZoneCheckOneWayRoadEvaluation(TileIndex tile) +{ + extern uint8 GetOneWayRoadTileType(TileIndex tile); + + uint8 type = GetOneWayRoadTileType(tile); + switch (type) { + default: + return ZONING_INVALID_SPRITE_ID; + case 1: + return SPR_ZONING_INNER_HIGHLIGHT_LIGHT_BLUE; + case 2: + return SPR_ZONING_INNER_HIGHLIGHT_ORANGE; + case 3: + return SPR_ZONING_INNER_HIGHLIGHT_GREEN; + } +} + /** * General evaluation function; calls all the other functions depending on * evaluation mode. @@ -297,6 +321,7 @@ SpriteID TileZoningSpriteEvaluation(TileIndex tile, Owner owner, ZoningEvaluatio case ZEM_TRACERESTRICT: return TileZoneCheckTraceRestrictEvaluation(tile, owner); case ZEM_2x2_GRID: return TileZoneCheckRoadGridEvaluation(tile, 3); case ZEM_3x3_GRID: return TileZoneCheckRoadGridEvaluation(tile, 4); + case ZEM_ONE_WAY_ROAD: return TileZoneCheckOneWayRoadEvaluation(tile); default: return ZONING_INVALID_SPRITE_ID; } } diff --git a/src/zoning_gui.cpp b/src/zoning_gui.cpp index 8e3f4a5f9f..6250290564 100644 --- a/src/zoning_gui.cpp +++ b/src/zoning_gui.cpp @@ -42,6 +42,7 @@ static const StringID _zone_type_strings[] = { STR_ZONING_TRACERESTRICT, STR_ZONING_2x2_GRID, STR_ZONING_3x3_GRID, + STR_ZONING_ONE_WAY_ROAD, INVALID_STRING_ID }; @@ -56,6 +57,7 @@ static const ZoningEvaluationMode _zone_type_modes[] = { ZEM_TRACERESTRICT, ZEM_2x2_GRID, ZEM_3x3_GRID, + ZEM_ONE_WAY_ROAD, }; static ZoningEvaluationMode DropDownIndexToZoningEvaluationMode(int index)