From 42deccc4f541b7e4aa12e80395fadd11096b5dc9 Mon Sep 17 00:00:00 2001 From: frosch Date: Thu, 17 Apr 2025 13:41:18 +0200 Subject: [PATCH] Codechange: Merge (IsOn|Toggle)(Snow|Desert) into (IsOn|Toggle)SnowOrDesert. --- src/newgrf_commons.cpp | 2 +- src/road_cmd.cpp | 14 +++++++------- src/road_map.h | 8 ++------ 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/newgrf_commons.cpp b/src/newgrf_commons.cpp index 3d28b360ad..3b03f253ff 100644 --- a/src/newgrf_commons.cpp +++ b/src/newgrf_commons.cpp @@ -357,7 +357,7 @@ uint32_t GetTerrainType(TileIndex tile, TileContext context) case MP_ROAD: /* During map generation the snowstate may not be valid yet, as the tileloop may not have run yet. */ if (_generating_world) goto genworld; // we do not care about foundations here - has_snow = IsOnSnow(tile); + has_snow = IsOnSnowOrDesert(tile); break; case MP_TREES: { diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index 6e23f63c59..c12587c90e 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -1628,7 +1628,7 @@ static void DrawRoadBits(TileInfo *ti) /* DrawFoundation() modifies ti. */ } - DrawRoadGroundSprites(ti, road, tram, road_rti, tram_rti, GetRoadside(ti->tile), IsOnSnow(ti->tile)); + DrawRoadGroundSprites(ti, road, tram, road_rti, tram_rti, GetRoadside(ti->tile), IsOnSnowOrDesert(ti->tile)); /* Draw one way */ if (road_rti != nullptr) { @@ -1720,7 +1720,7 @@ static void DrawTile_Road(TileInfo *ti) SpriteID image = SPR_ROAD_Y + axis; Roadside roadside = GetRoadside(ti->tile); - if (DrawRoadAsSnowOrDesert(IsOnSnow(ti->tile), roadside)) { + if (DrawRoadAsSnowOrDesert(IsOnSnowOrDesert(ti->tile), roadside)) { image += 19; } else { switch (roadside) { @@ -1736,7 +1736,7 @@ static void DrawTile_Road(TileInfo *ti) if (IsCrossingBarred(ti->tile)) image += 2; Roadside roadside = GetRoadside(ti->tile); - if (DrawRoadAsSnowOrDesert(IsOnSnow(ti->tile), roadside)) { + if (DrawRoadAsSnowOrDesert(IsOnSnowOrDesert(ti->tile), roadside)) { image += 8; } else { switch (roadside) { @@ -1975,16 +1975,16 @@ static void TileLoop_Road(TileIndex tile) case LandscapeType::Arctic: { /* Roads on flat foundations use the snow level of the height they are elevated to. All others use the snow level of their minimum height. */ int tile_z = (std::get(GetFoundationSlope(tile)) == SLOPE_FLAT) ? GetTileMaxZ(tile) : GetTileZ(tile); - if (IsOnSnow(tile) != (tile_z > GetSnowLine())) { - ToggleSnow(tile); + if (IsOnSnowOrDesert(tile) != (tile_z > GetSnowLine())) { + ToggleSnowOrDesert(tile); MarkTileDirtyByTile(tile); } break; } case LandscapeType::Tropic: - if (GetTropicZone(tile) == TROPICZONE_DESERT && !IsOnDesert(tile)) { - ToggleDesert(tile); + if (GetTropicZone(tile) == TROPICZONE_DESERT && !IsOnSnowOrDesert(tile)) { + ToggleSnowOrDesert(tile); MarkTileDirtyByTile(tile); } break; diff --git a/src/road_map.h b/src/road_map.h index 4d53bfdbe5..3ee5de72c1 100644 --- a/src/road_map.h +++ b/src/road_map.h @@ -433,25 +433,21 @@ inline void BarCrossing(Tile t) SetCrossingBarred(t, true); } -/** Check if a road tile has snow/desert. */ -#define IsOnDesert IsOnSnow /** * Check if a road tile has snow/desert. * @param t The tile to query. * @return True if the tile has snow/desert. */ -inline bool IsOnSnow(Tile t) +inline bool IsOnSnowOrDesert(Tile t) { return HasBit(t.m7(), 5); } -/** Toggle the snow/desert state of a road tile. */ -#define ToggleDesert ToggleSnow /** * Toggle the snow/desert state of a road tile. * @param t The tile to change. */ -inline void ToggleSnow(Tile t) +inline void ToggleSnowOrDesert(Tile t) { ToggleBit(t.m7(), 5); }