diff --git a/.clang-format b/.clang-format index e8f6fe1..f7cb345 100644 --- a/.clang-format +++ b/.clang-format @@ -7,7 +7,7 @@ AlignConsecutiveAssignments: None AlignConsecutiveBitFields: None AlignConsecutiveDeclarations: None AlignEscapedNewlines: Left -AlignOperands: Align +AlignOperands: DontAlign AlignTrailingComments: Kind: Always OverEmptyLines: 2 diff --git a/tilemap/src/biome.cpp b/tilemap/src/biome.cpp index 50908d2..e0bf84a 100644 --- a/tilemap/src/biome.cpp +++ b/tilemap/src/biome.cpp @@ -1,8 +1,6 @@ #include "biome.h" #include "chunk.h" #include -#include -#include namespace istd { diff --git a/tilemap/src/pass/biome.cpp b/tilemap/src/pass/biome.cpp index 805bbd2..0f89a49 100644 --- a/tilemap/src/pass/biome.cpp +++ b/tilemap/src/pass/biome.cpp @@ -23,24 +23,26 @@ void BiomeGenerationPass::operator()(TileMap &tilemap) { // Generate biomes for each sub-chunk for (std::uint8_t chunk_x = 0; chunk_x < map_size; ++chunk_x) { for (std::uint8_t chunk_y = 0; chunk_y < map_size; ++chunk_y) { - Chunk &chunk = tilemap.get_chunk(chunk_x, chunk_y); + auto &chunk = tilemap.get_chunk(chunk_x, chunk_y); for (std::uint8_t sub_x = 0; sub_x < Chunk::subchunk_count; ++sub_x) { for (std::uint8_t sub_y = 0; sub_y < Chunk::subchunk_count; ++sub_y) { // Calculate global position for this sub-chunk's center - auto [start_x, start_y] - = subchunk_to_tile_start(SubChunkPos(sub_x, sub_y)); - double global_x = chunk_x * Chunk::size + start_x - + Chunk::subchunk_size / 2; + auto [start_x, start_y] = subchunk_to_tile_start( + {sub_x, sub_y} + ); + double global_x = chunk_x * Chunk::size + start_x + + (Chunk::subchunk_size >> 1); double global_y = chunk_y * Chunk::size + start_y - + Chunk::subchunk_size / 2; + + (Chunk::subchunk_size >> 1); // Get climate values - auto [temperature, humidity] - = get_climate(global_x, global_y); + auto [temperature, humidity] = get_climate( + global_x, global_y + ); // Determine biome and store directly in chunk BiomeType biome = determine_biome(temperature, humidity); diff --git a/tilemap/src/pass/deepwater.cpp b/tilemap/src/pass/deepwater.cpp index bf5b5c9..fab8528 100644 --- a/tilemap/src/pass/deepwater.cpp +++ b/tilemap/src/pass/deepwater.cpp @@ -21,8 +21,9 @@ void DeepwaterGenerationPass::operator()(TileMap &tilemap) { ++sub_y) { SubChunkPos sub_pos(sub_x, sub_y); BiomeType biome = chunk.get_biome(sub_pos); - const BiomeProperties &properties - = get_biome_properties(biome); + const BiomeProperties &properties = get_biome_properties( + biome + ); // Only process ocean biomes if (!properties.is_ocean) { @@ -83,10 +84,10 @@ bool DeepwaterGenerationPass::is_surrounded_by_water( dx <= static_cast(radius); ++dx) { for (std::int32_t dy = -static_cast(radius); dy <= static_cast(radius); ++dy) { - std::int32_t check_x - = static_cast(center_global_x) + dx; - std::int32_t check_y - = static_cast(center_global_y) + dy; + std::int32_t check_x = static_cast(center_global_x) + + dx; + std::int32_t check_y = static_cast(center_global_y) + + dy; // Check bounds if (check_x < 0 || check_y < 0 @@ -117,4 +118,4 @@ void TerrainGenerator::deepwater_pass(TileMap &tilemap) { pass(tilemap); } -} // namespace istd \ No newline at end of file +} // namespace istd diff --git a/tilemap/src/pass/mountain_hole_fill.cpp b/tilemap/src/pass/mountain_hole_fill.cpp index 420c7e6..59f9fa2 100644 --- a/tilemap/src/pass/mountain_hole_fill.cpp +++ b/tilemap/src/pass/mountain_hole_fill.cpp @@ -1,4 +1,5 @@ #include "generation.h" +#include #include namespace istd { @@ -44,13 +45,13 @@ void MountainHoleFillPass::operator()(TileMap &tilemap) { ); // Check if this component touches the boundary - bool touches_boundary = false; - for (const auto component_pos : component_positions) { - if (tilemap.is_at_boundary(component_pos)) { - touches_boundary = true; - break; - } - } + auto boundary_checker = + [&tilemap](const TilePos &component_pos) { + return tilemap.is_at_boundary(component_pos); + }; + bool touches_boundary = std::ranges::any_of( + component_positions, boundary_checker + ); // Fill small holes that don't touch the boundary if (!touches_boundary diff --git a/tilemap/src/pass/smoothen_island.cpp b/tilemap/src/pass/smoothen_island.cpp index 09915b1..d5608b2 100644 --- a/tilemap/src/pass/smoothen_island.cpp +++ b/tilemap/src/pass/smoothen_island.cpp @@ -57,14 +57,14 @@ void SmoothenIslandPass::remove_small_island(TileMap &tilemap) { tilemap, pos, visited, component_positions ); - // If the component touches the boundary, skip it - bool touches_boundary = false; - for (auto component_pos : component_positions) { - if (tilemap.is_at_boundary(component_pos)) { - touches_boundary = true; - break; - } - } + // Check if this component touches the boundary + auto boundary_checker = + [&tilemap](const TilePos &component_pos) { + return tilemap.is_at_boundary(component_pos); + }; + bool touches_boundary = std::ranges::any_of( + component_positions, boundary_checker + ); // Skip if it touches the boundary if (touches_boundary) {