summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/anim-atlas.cpp10
-rw-r--r--src/chunk-collision.cpp6
-rw-r--r--src/chunk-render.cpp20
-rw-r--r--src/chunk.cpp2
-rw-r--r--src/random.cpp4
-rw-r--r--src/tile-atlas.cpp2
6 files changed, 22 insertions, 22 deletions
diff --git a/src/anim-atlas.cpp b/src/anim-atlas.cpp
index 655bcf5e..ffade2d6 100644
--- a/src/anim-atlas.cpp
+++ b/src/anim-atlas.cpp
@@ -29,7 +29,7 @@ decltype(anim_atlas::_group_indices) anim_atlas::make_group_indices(const anim_d
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
};
const auto ngroups = a.groups.size();
- for (std::size_t i = 0; i < ngroups; i++)
+ for (auto i = 0_uz; i < ngroups; i++)
array[rotation_to_index(a.groups[i].name)] = std::uint8_t(i);
return array;
}
@@ -140,10 +140,10 @@ BitArray anim_atlas::make_bitmask(const ImageView2D& tex)
fm_assert(tex.pixelSize() == 4);
fm_assert(pixels.stride()[1] == 4);
- for (std::size_t j = 0; j < height; j++)
+ for (auto j = 0_uz; j < height; j++)
{
constexpr unsigned char amin = 32;
- std::size_t i = 0;
+ auto i = 0_uz;
for (; i < width0; i += 8)
{
const auto src_idx = (j*stride + i*4)+3, dst_idx = (height-j-1)*width + i>>3;
@@ -179,7 +179,7 @@ rotation anim_atlas::next_rotation_from(rotation r) const noexcept
for (auto i = std::size_t(r)+1; i < count; i++)
if (_group_indices[i] != 0xff)
return rotation(i);
- for (std::size_t i = 0; i < count; i++)
+ for (auto i = 0_uz; i < count; i++)
if (_group_indices[i] != 0xff)
return rotation(i);
fm_abort("where did the rotations go?!");
@@ -206,7 +206,7 @@ bool anim_atlas::check_rotation(rotation r) const noexcept
rotation anim_atlas::first_rotation() const noexcept
{
- for (std::size_t i = 0; i < rot_count; i++)
+ for (auto i = 0_uz; i < rot_count; i++)
if (_group_indices[i] == 0)
return rotation(i);
fm_abort("unreachable! can't find first rotation");
diff --git a/src/chunk-collision.cpp b/src/chunk-collision.cpp
index d41c02c8..5b85de1e 100644
--- a/src/chunk-collision.cpp
+++ b/src/chunk-collision.cpp
@@ -60,7 +60,7 @@ void chunk::ensure_passability() noexcept
_rtree.RemoveAll();
- for (std::size_t i = 0; i < TILE_COUNT; i++)
+ for (auto i = 0_uz; i < TILE_COUNT; i++)
{
auto tile = operator[](i);
if (auto s = tile.scenery())
@@ -71,7 +71,7 @@ void chunk::ensure_passability() noexcept
_rtree.Insert(start.data(), end.data(), id);
}
}
- for (std::size_t i = 0; i < TILE_COUNT; i++)
+ for (auto i = 0_uz; i < TILE_COUNT; i++)
{
if (const auto* atlas = ground_atlas_at(i))
if (atlas->pass_mode(pass_mode::pass) != pass_mode::pass)
@@ -81,7 +81,7 @@ void chunk::ensure_passability() noexcept
_rtree.Insert(start.data(), end.data(), id);
}
}
- for (std::size_t i = 0; i < TILE_COUNT; i++)
+ for (auto i = 0_uz; i < TILE_COUNT; i++)
{
auto tile = operator[](i);
if (const auto* atlas = tile.wall_north_atlas().get())
diff --git a/src/chunk-render.cpp b/src/chunk-render.cpp
index 48425f72..e54260dd 100644
--- a/src/chunk-render.cpp
+++ b/src/chunk-render.cpp
@@ -12,7 +12,7 @@ template<std::size_t N = 1>
static auto make_index_array(std::size_t max)
{
std::array<std::array<UnsignedShort, 6>, N*TILE_COUNT> array; // NOLINT(cppcoreguidelines-pro-type-member-init)
- for (std::size_t i = 0; i < max; i++)
+ for (auto i = 0_uz; i < max; i++)
array[i] = tile_atlas::indices(i);
return array;
}
@@ -30,7 +30,7 @@ auto chunk::ensure_ground_mesh() noexcept -> ground_mesh_tuple
_ground_modified = false;
std::size_t count = 0;
- for (std::size_t i = 0; i < TILE_COUNT; i++)
+ for (auto i = 0_uz; i < TILE_COUNT; i++)
if (_ground_atlases[i])
ground_indexes[count++] = std::uint8_t(i);
@@ -40,7 +40,7 @@ auto chunk::ensure_ground_mesh() noexcept -> ground_mesh_tuple
});
std::array<std::array<vertex, 4>, TILE_COUNT> vertexes;
- for (std::size_t k = 0; k < count; k++)
+ for (auto k = 0_uz; k < count; k++)
{
const std::uint8_t i = ground_indexes[k];
const auto& atlas = _ground_atlases[i];
@@ -49,7 +49,7 @@ auto chunk::ensure_ground_mesh() noexcept -> ground_mesh_tuple
const auto texcoords = atlas->texcoords_for_id(_ground_variants[i]);
const float depth = tile_shader::depth_value(pos);
auto& v = vertexes[k];
- for (std::size_t j = 0; j < 4; j++)
+ for (auto j = 0_uz; j < 4; j++)
v[j] = { quad[j], texcoords[j], depth };
}
@@ -72,7 +72,7 @@ auto chunk::ensure_wall_mesh() noexcept -> wall_mesh_tuple
_walls_modified = false;
std::size_t count = 0;
- for (std::size_t i = 0; i < TILE_COUNT*2; i++)
+ for (auto i = 0_uz; i < TILE_COUNT*2; i++)
if (_wall_atlases[i])
wall_indexes[count++] = std::uint16_t(i);
@@ -82,7 +82,7 @@ auto chunk::ensure_wall_mesh() noexcept -> wall_mesh_tuple
});
std::array<std::array<vertex, 4>, TILE_COUNT*2> vertexes;
- for (std::size_t k = 0; k < count; k++)
+ for (auto k = 0_uz; k < count; k++)
{
const std::uint16_t i = wall_indexes[k];
const auto& atlas = _wall_atlases[i];
@@ -93,7 +93,7 @@ auto chunk::ensure_wall_mesh() noexcept -> wall_mesh_tuple
const float depth = tile_shader::depth_value(pos);
const auto texcoords = atlas->texcoords_for_id(variant);
auto& v = vertexes[k];
- for (std::size_t j = 0; j < 4; j++)
+ for (auto j = 0_uz; j < 4; j++)
v[j] = { quad[j], texcoords[j], depth, };
}
@@ -116,7 +116,7 @@ auto chunk::ensure_scenery_mesh() noexcept -> scenery_mesh_tuple
_scenery_modified = false;
std::size_t count = 0;
- for (std::size_t i = 0; i < TILE_COUNT; i++)
+ for (auto i = 0_uz; i < TILE_COUNT; i++)
if (const auto& atlas = _scenery_atlases[i]; atlas && atlas->info().fps == 0)
scenery_indexes[count++] = std::uint8_t(i);
@@ -127,7 +127,7 @@ auto chunk::ensure_scenery_mesh() noexcept -> scenery_mesh_tuple
});
#endif
std::array<std::array<vertex, 4>, TILE_COUNT> vertexes;
- for (std::size_t k = 0; k < count; k++)
+ for (auto k = 0_uz; k < count; k++)
{
const std::uint8_t i = scenery_indexes[k];
const local_coords pos{i};
@@ -139,7 +139,7 @@ auto chunk::ensure_scenery_mesh() noexcept -> scenery_mesh_tuple
const auto texcoords = atlas->texcoords_for_frame(fr.r, fr.frame, !group.mirror_from.isEmpty());
const float depth = tile_shader::depth_value(pos, tile_shader::scenery_depth_offset);
auto& v = vertexes[k];
- for (std::size_t j = 0; j < 4; j++)
+ for (auto j = 0_uz; j < 4; j++)
v[j] = { quad[j], texcoords[j], depth };
}
diff --git a/src/chunk.cpp b/src/chunk.cpp
index 033e1831..774a874c 100644
--- a/src/chunk.cpp
+++ b/src/chunk.cpp
@@ -7,7 +7,7 @@ bool chunk::empty(bool force) const noexcept
{
if (!force && !_maybe_empty)
return false;
- for (std::size_t i = 0; i < TILE_COUNT; i++)
+ for (auto i = 0_uz; i < TILE_COUNT; i++)
if (_ground_atlases[i] || _wall_atlases[i*2 + 0] || _wall_atlases[i*2 + 1] || _scenery_atlases[i])
return _maybe_empty = false;
return true;
diff --git a/src/random.cpp b/src/random.cpp
index d3e45292..7888dbaa 100644
--- a/src/random.cpp
+++ b/src/random.cpp
@@ -17,13 +17,13 @@ std::size_t random_engine_impl::operator()()
{
if constexpr(sizeof(std::size_t) > sizeof(std::uint32_t))
{
- constexpr std::size_t N = (sizeof(std::size_t) + sizeof(std::uint32_t)-1) / sizeof(std::uint32_t);
+ constexpr auto N = (sizeof(std::size_t) + sizeof(std::uint32_t)-1) / sizeof(std::uint32_t);
static_assert(N >= 1);
union {
std::size_t x;
std::uint32_t a[N];
} ret;
- for (std::size_t i = 0; i < N; i++)
+ for (auto i = 0_uz; i < N; i++)
ret.a[i] = g();
return ret.x;
}
diff --git a/src/tile-atlas.cpp b/src/tile-atlas.cpp
index b13b9ea8..68feb77b 100644
--- a/src/tile-atlas.cpp
+++ b/src/tile-atlas.cpp
@@ -50,7 +50,7 @@ auto tile_atlas::make_texcoords_array(Vector2ui pixel_size, Vector2ub tile_count
{
const std::size_t N = Vector2ui{tile_count}.product();
auto ptr = std::make_unique<std::array<Vector2, 4>[]>(N);
- for (std::size_t i = 0; i < N; i++)
+ for (auto i = 0_uz; i < N; i++)
ptr[i] = make_texcoords(pixel_size, tile_count, i);
return ptr;
}