From 92a5e59165ce6c0a2414534e4ef67ae1de26ddfa Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Sat, 6 Oct 2018 13:01:01 +0100 Subject: [PATCH] Zoning: Add modes to show 2x2 and 3x3 town road grids --- src/lang/english.txt | 2 ++ src/zoning.h | 2 ++ src/zoning_cmd.cpp | 20 ++++++++++++++++++++ src/zoning_gui.cpp | 4 ++++ 4 files changed, 28 insertions(+) diff --git a/src/lang/english.txt b/src/lang/english.txt index 07bf04fc1f..d5a0b8a3e8 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -5948,6 +5948,8 @@ STR_ZONING_STA_CATCH_OPEN :Station catchme STR_ZONING_BUL_UNSER :Unserved buildings STR_ZONING_IND_UNSER :Unserved industries STR_ZONING_TRACERESTRICT :Restricted signals +STR_ZONING_2x2_GRID :2x2 town road grid +STR_ZONING_3x3_GRID :3x3 town road grid STR_TMPL_RPL_TITLE :{WHITE}Template Replacement STR_TMPL_TEMPLATE_REPLACEMENT :Template Replacement diff --git a/src/zoning.h b/src/zoning.h index 39eab5f744..cf060e1dfa 100644 --- a/src/zoning.h +++ b/src/zoning.h @@ -27,6 +27,8 @@ enum ZoningEvaluationMode { ZEM_BUL_UNSER, ///< Check for unserved buildings ZEM_IND_UNSER, ///< Check for unserved industries ZEM_TRACERESTRICT, ///< Check for restricted signals + ZEM_2x2_GRID, ///< Show 2x2 town road grid + ZEM_3x3_GRID, ///< Show 3x3 town road grid }; /** diff --git a/src/zoning_cmd.cpp b/src/zoning_cmd.cpp index 8f42159e21..108d43a281 100644 --- a/src/zoning_cmd.cpp +++ b/src/zoning_cmd.cpp @@ -317,6 +317,24 @@ SpriteID TileZoneCheckTraceRestrictEvaluation(TileIndex tile, Owner owner) return ZONING_INVALID_SPRITE_ID; } +/** + * Detect whether a tile is a restricted signal tile + * + * @param TileIndex tile + * @param Owner owner + * @return red if a restricted signal, nothing otherwise + */ +inline SpriteID TileZoneCheckRoadGridEvaluation(TileIndex tile, uint grid_size) +{ + const bool x_grid = (TileX(tile) % grid_size == 0); + const bool y_grid = (TileY(tile) % grid_size == 0); + if (x_grid || y_grid) { + return SPR_ZONING_INNER_HIGHLIGHT_LIGHT_BLUE; + } else { + return ZONING_INVALID_SPRITE_ID; + } +} + /** * General evaluation function; calls all the other functions depending on * evaluation mode. @@ -339,6 +357,8 @@ SpriteID TileZoningSpriteEvaluation(TileIndex tile, Owner owner, ZoningEvaluatio case ZEM_BUL_UNSER: return TileZoneCheckUnservedBuildingsEvaluation(tile, owner); case ZEM_IND_UNSER: return TileZoneCheckUnservedIndustriesEvaluation(tile, owner); case ZEM_TRACERESTRICT: return TileZoneCheckTraceRestrictEvaluation(tile, owner); + case ZEM_2x2_GRID: return TileZoneCheckRoadGridEvaluation(tile, 3); + case ZEM_3x3_GRID: return TileZoneCheckRoadGridEvaluation(tile, 4); default: return ZONING_INVALID_SPRITE_ID; } } diff --git a/src/zoning_gui.cpp b/src/zoning_gui.cpp index b02cdafa16..1140facc24 100644 --- a/src/zoning_gui.cpp +++ b/src/zoning_gui.cpp @@ -42,6 +42,8 @@ static const StringID _zone_type_strings[] = { STR_ZONING_BUL_UNSER, STR_ZONING_IND_UNSER, STR_ZONING_TRACERESTRICT, + STR_ZONING_2x2_GRID, + STR_ZONING_3x3_GRID, INVALID_STRING_ID }; @@ -54,6 +56,8 @@ static const ZoningEvaluationMode _zone_type_modes[] = { ZEM_BUL_UNSER, ZEM_IND_UNSER, ZEM_TRACERESTRICT, + ZEM_2x2_GRID, + ZEM_3x3_GRID, }; static ZoningEvaluationMode DropDownIndexToZoningEvaluationMode(int index)