summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-01-12 00:45:45 +0100
committerStanislaw Halik <sthalik@misaki.pl>2024-01-12 00:59:07 +0100
commit692edd513bce851a988b0f04209adc480e48fe1f (patch)
tree5dac466dd3e8da8a7f943d1bc4df0848a1bea8b5
parent1a84f009b39c070a8d4f4931e2376936190a161e (diff)
cc
-rw-r--r--draw/anim.hpp5
-rw-r--r--draw/box.hpp2
-rw-r--r--draw/ground.hpp2
-rw-r--r--draw/quad-floor.hpp2
-rw-r--r--draw/quad-wall-n.hpp2
-rw-r--r--draw/quad-wall-w.hpp2
-rw-r--r--draw/quad.hpp2
-rw-r--r--draw/wall.hpp2
-rw-r--r--editor/events.cpp3
-rw-r--r--editor/ground-editor.hpp3
-rw-r--r--serialize/world-writer.cpp2
-rw-r--r--src/chunk.hpp4
-rw-r--r--test/serializer.cpp6
13 files changed, 22 insertions, 15 deletions
diff --git a/draw/anim.hpp b/draw/anim.hpp
index 03bb10c4..18e57333 100644
--- a/draw/anim.hpp
+++ b/draw/anim.hpp
@@ -22,7 +22,7 @@ struct chunk;
struct clickable;
struct object;
-struct anim_mesh final
+struct anim_mesh
{
anim_mesh();
@@ -36,7 +36,8 @@ struct anim_mesh final
private:
static std::array<UnsignedShort, 6> make_index_array();
- struct vertex_data final {
+ struct vertex_data
+ {
Vector3 position;
Vector2 texcoords;
float depth = -1;
diff --git a/draw/box.hpp b/draw/box.hpp
index a6608e00..26e5485f 100644
--- a/draw/box.hpp
+++ b/draw/box.hpp
@@ -6,7 +6,7 @@
namespace floormat::wireframe {
-struct box final
+struct box
{
box(Vector3 center, Vector3 size, float line_width);
diff --git a/draw/ground.hpp b/draw/ground.hpp
index b960e8b1..c3569121 100644
--- a/draw/ground.hpp
+++ b/draw/ground.hpp
@@ -5,7 +5,7 @@ namespace floormat {
struct tile_shader;
struct chunk;
-struct ground_mesh final
+struct ground_mesh
{
ground_mesh();
diff --git a/draw/quad-floor.hpp b/draw/quad-floor.hpp
index 84ab17e9..b289ab84 100644
--- a/draw/quad-floor.hpp
+++ b/draw/quad-floor.hpp
@@ -8,7 +8,7 @@
namespace floormat::wireframe {
-struct quad_floor final
+struct quad_floor
{
quad_floor(Vector3 center, Vector2 size, float line_width);
diff --git a/draw/quad-wall-n.hpp b/draw/quad-wall-n.hpp
index c490d8b2..d607ffe3 100644
--- a/draw/quad-wall-n.hpp
+++ b/draw/quad-wall-n.hpp
@@ -7,7 +7,7 @@
namespace floormat::wireframe {
-struct quad_wall_n final
+struct quad_wall_n
{
quad_wall_n(Vector3 center, Vector3 size, float line_width);
diff --git a/draw/quad-wall-w.hpp b/draw/quad-wall-w.hpp
index b90d53c3..a96e8d83 100644
--- a/draw/quad-wall-w.hpp
+++ b/draw/quad-wall-w.hpp
@@ -7,7 +7,7 @@
namespace floormat::wireframe {
-struct quad_wall_w final
+struct quad_wall_w
{
quad_wall_w(Vector3 center, Vector3 size, float line_width);
diff --git a/draw/quad.hpp b/draw/quad.hpp
index c92e9544..c9345f64 100644
--- a/draw/quad.hpp
+++ b/draw/quad.hpp
@@ -6,7 +6,7 @@
namespace floormat::wireframe {
-struct quad final
+struct quad
{
quad(Vector3 start, Vector2 size, float line_width);
diff --git a/draw/wall.hpp b/draw/wall.hpp
index ace24904..89d3d3ac 100644
--- a/draw/wall.hpp
+++ b/draw/wall.hpp
@@ -5,7 +5,7 @@ namespace floormat {
struct tile_shader;
struct chunk;
-struct wall_mesh final
+struct wall_mesh
{
wall_mesh();
diff --git a/editor/events.cpp b/editor/events.cpp
index 94a8f94f..59507ccf 100644
--- a/editor/events.cpp
+++ b/editor/events.cpp
@@ -174,7 +174,8 @@ void app::clear_non_repeated_keys() { clear_keys(key_NO_REPEAT, key_COUNT); }
void app::on_key_up_down(const key_event& event, bool is_down) noexcept
{
using KeyEvent = Platform::Sdl2Application::KeyEvent;
- struct Ev final {
+ struct Ev
+ {
using Key = KeyEvent::Key;
using Modifier = KeyEvent::Modifier;
using Modifiers = KeyEvent::Modifiers;
diff --git a/editor/ground-editor.hpp b/editor/ground-editor.hpp
index 9ff9a198..5f2399ff 100644
--- a/editor/ground-editor.hpp
+++ b/editor/ground-editor.hpp
@@ -19,7 +19,8 @@ class ground_editor final
sel_none, sel_tile, sel_perm,
};
- struct tuple final {
+ struct tuple
+ {
std::shared_ptr<ground_atlas> atlas;
std::vector<decltype(tile_image_proto::variant)> variant;
};
diff --git a/serialize/world-writer.cpp b/serialize/world-writer.cpp
index e32d3cdf..6dad7f07 100644
--- a/serialize/world-writer.cpp
+++ b/serialize/world-writer.cpp
@@ -333,7 +333,7 @@ void writer_state::serialize_scenery(const chunk& c, writer_t& s)
const auto& e = *e_;
fm_assert(s.bytes_written() + object_size <= chunk_buf.size());
object_id oid = e.id;
- fm_assert((oid & lowbits<60, object_id>) == e.id);
+ fm_assert((oid & lowbits<collision_data_BITS, object_id>) == e.id);
const auto type = e.type();
const auto type_ = (object_type_i)type;
fm_assert(type_ == (type_ & lowbits<object_type_BITS, object_type_i>));
diff --git a/src/chunk.hpp b/src/chunk.hpp
index 1f144ca7..59eb0061 100644
--- a/src/chunk.hpp
+++ b/src/chunk.hpp
@@ -27,10 +27,12 @@ enum class collision_type : unsigned char {
none, object, scenery, geometry,
};
+constexpr inline size_t collision_data_BITS = 60;
+
struct collision_data final {
uint64_t tag : 2;
uint64_t pass : 2;
- uint64_t data : 60;
+ uint64_t data : collision_data_BITS;
};
struct chunk final
diff --git a/test/serializer.cpp b/test/serializer.cpp
index 518962e0..c69399d5 100644
--- a/test/serializer.cpp
+++ b/test/serializer.cpp
@@ -66,7 +66,7 @@ void assert_chunks_equal(const chunk& a, const chunk& b)
case object_type::critter: {
const auto& e1 = static_cast<const critter&>(ae);
const auto& e2 = static_cast<const critter&>(be);
- const auto p1 =critter_proto(e1), p2 =critter_proto(e2);
+ const auto p1 = critter_proto(e1), p2 = critter_proto(e2);
fm_assert(p1 == p2);
break;
}
@@ -102,11 +102,13 @@ void test_serializer(StringView input, StringView tmp)
{
coord = {1, 1, 0};
w = world();
- test_app::make_test_chunk(w, coord);
+ auto& c = test_app::make_test_chunk(w, coord);
+ fm_assert(!c.empty(true));
}
w.serialize(tmp);
auto w2 = world::deserialize(tmp);
auto& c2 = w2[coord];
+ fm_assert(!c2.empty(true));
assert_chunks_equal(w[coord], c2);
}