diff --git a/src/clear_cmd.cpp b/src/clear_cmd.cpp index 980dc10e40..d471e2e0b3 100644 --- a/src/clear_cmd.cpp +++ b/src/clear_cmd.cpp @@ -53,12 +53,21 @@ static CommandCost ClearTile_Clear(TileIndex tile, DoCommandFlags flags) return price; } -void DrawClearLandTile(const TileInfo *ti, uint8_t set) +/** + * Draw a ClearGround::Grass tile. + * @param ti The tile to draw. + * @param density The density of the dirt -> grass transition to draw. + */ +void DrawClearLandTile(const TileInfo *ti, uint8_t density) { - DrawGroundSprite(SPR_FLAT_BARE_LAND + SlopeToSpriteOffset(ti->tileh) + set * 19, PAL_NONE); + DrawGroundSprite(_clear_land_sprites_grass[density] + SlopeToSpriteOffset(ti->tileh), PAL_NONE); } -void DrawHillyLandTile(const TileInfo *ti) +/** + * Draw a ClearGround::Rough tile. + * @param ti The tile to draw. + */ +void DrawRoughLandTile(const TileInfo *ti) { if (ti->tileh != SLOPE_FLAT) { DrawGroundSprite(SPR_FLAT_ROUGH_LAND + SlopeToSpriteOffset(ti->tileh), PAL_NONE); @@ -67,6 +76,10 @@ void DrawHillyLandTile(const TileInfo *ti) } } +/** + * Draw the fences atop a ClearGround::Fields tile. + * @param ti The tile to draw. + */ static void DrawClearLandFence(const TileInfo *ti) { /* combine fences into one sprite object */ @@ -138,7 +151,7 @@ static void DrawTile_Clear(TileInfo *ti) break; case ClearGround::Rough: - DrawHillyLandTile(ti); + DrawRoughLandTile(ti); break; case ClearGround::Rocks: diff --git a/src/clear_func.h b/src/clear_func.h index 222ff769e9..4c466f11d1 100644 --- a/src/clear_func.h +++ b/src/clear_func.h @@ -12,7 +12,7 @@ #include "tile_cmd.h" -void DrawHillyLandTile(const TileInfo *ti); +void DrawRoughLandTile(const TileInfo *ti); void DrawClearLandTile(const TileInfo *ti, uint8_t set); #endif /* CLEAR_FUNC_H */ diff --git a/src/table/clear_land.h b/src/table/clear_land.h index 6d12ea3e52..a6b2582e49 100644 --- a/src/table/clear_land.h +++ b/src/table/clear_land.h @@ -9,6 +9,7 @@ #include "sprites.h" +/** Sprites of the random variants of rough grass sprites, for flat tiles only. */ static const SpriteID _landscape_clear_sprites_rough[8] = { SPR_FLAT_ROUGH_LAND, SPR_FLAT_ROUGH_LAND_1, @@ -20,6 +21,7 @@ static const SpriteID _landscape_clear_sprites_rough[8] = { SPR_FLAT_ROUGH_LAND_2, }; +/** Sprite offset for sloped fences on the southwest edge of the tile. */ static const uint8_t _fence_mod_by_tileh_sw[32] = { 0, 2, 4, 0, 0, 2, 4, 0, 0, 2, 4, 0, 0, 2, 4, 0, @@ -27,6 +29,7 @@ static const uint8_t _fence_mod_by_tileh_sw[32] = { 0, 2, 4, 2, 0, 2, 4, 0, }; +/** Sprite offset for sloped fences on the southeast edge of the tile. */ static const uint8_t _fence_mod_by_tileh_se[32] = { 1, 1, 5, 5, 3, 3, 1, 1, 1, 1, 5, 5, 3, 3, 1, 1, @@ -34,6 +37,7 @@ static const uint8_t _fence_mod_by_tileh_se[32] = { 1, 1, 5, 5, 3, 3, 3, 1, }; +/** Sprite offset for sloped fences on the northeast edge of the tile. */ static const uint8_t _fence_mod_by_tileh_ne[32] = { 0, 0, 0, 0, 4, 4, 4, 4, 2, 2, 2, 2, 0, 0, 0, 0, @@ -41,6 +45,7 @@ static const uint8_t _fence_mod_by_tileh_ne[32] = { 2, 2, 2, 2, 0, 2, 4, 0, }; +/** Sprite offset for sloped fences on the northwest edge of the tile. */ static const uint8_t _fence_mod_by_tileh_nw[32] = { 1, 5, 1, 5, 1, 5, 1, 5, 3, 1, 3, 1, 3, 1, 3, 1, @@ -48,7 +53,7 @@ static const uint8_t _fence_mod_by_tileh_nw[32] = { 3, 1, 3, 5, 3, 3, 3, 1, }; - +/** Sprites of the flat tile base for each type of farm field fence. */ static const SpriteID _clear_land_fence_sprites[7] = { SPR_HEDGE_BUSHES, SPR_HEDGE_BUSHES_WITH_GATE, @@ -58,6 +63,7 @@ static const SpriteID _clear_land_fence_sprites[7] = { SPR_HEDGE_STONE, }; +/** Sprites of the flat tile base for each state of farm fields. */ static const SpriteID _clear_land_sprites_farmland[16] = { SPR_FARMLAND_BARE, SPR_FARMLAND_STATE_1, @@ -70,7 +76,16 @@ static const SpriteID _clear_land_sprites_farmland[16] = { SPR_FARMLAND_HAYPACKS, }; -static const SpriteID _clear_land_sprites_snow_desert[8] = { +/** Sprites of the flat tile base for each density of clear -> grass transition. */ +static const SpriteID _clear_land_sprites_grass[4] = { + SPR_FLAT_BARE_LAND, + SPR_FLAT_1_THIRD_GRASS_TILE, + SPR_FLAT_2_THIRD_GRASS_TILE, + SPR_FLAT_GRASS_TILE, +}; + +/** Sprites of the flat tile base for each density of grass -> snow/desert transition. */ +static const SpriteID _clear_land_sprites_snow_desert[4] = { SPR_FLAT_1_QUART_SNOW_DESERT_TILE, SPR_FLAT_2_QUART_SNOW_DESERT_TILE, SPR_FLAT_3_QUART_SNOW_DESERT_TILE, diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp index bd6e19105a..c191daa7ff 100644 --- a/src/tree_cmd.cpp +++ b/src/tree_cmd.cpp @@ -645,7 +645,7 @@ static void DrawTile_Trees(TileInfo *ti) switch (GetTreeGround(ti->tile)) { case TreeGround::Shore: DrawShoreTile(ti->tileh); break; case TreeGround::Grass: DrawClearLandTile(ti, GetTreeDensity(ti->tile)); break; - case TreeGround::Rough: DrawHillyLandTile(ti); break; + case TreeGround::Rough: DrawRoughLandTile(ti); break; default: DrawGroundSprite(_clear_land_sprites_snow_desert[GetTreeDensity(ti->tile)] + SlopeToSpriteOffset(ti->tileh), PAL_NONE); break; }