From 3ed15b56aded3a6f58ef98d0cbe17012e28e9430 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 20 Nov 2022 21:09:03 +0100 Subject: scenery: don't bother with bitfields The `scenery_proto` struct is rounded up to a multiple of 8 bytes. --- editor/update.cpp | 2 +- src/scenery.hpp | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/editor/update.cpp b/editor/update.cpp index e9207cf6..cc765268 100644 --- a/editor/update.cpp +++ b/editor/update.cpp @@ -29,7 +29,7 @@ void app::maybe_initialize_chunk_(const chunk_coords& pos, chunk& c) c[{K, K }].wall_west() = { _wall2, 0 }; c[{K, K+1}].wall_north() = { _wall1, 0 }; c[{K+1, K }].wall_west() = { _wall2, 0 }; - c[{K+1, K+1}].scenery() = { _door, scenery{rotation::N, 0} }; + c[{K+1, K+1}].scenery() = { _door, scenery{0, rotation::N} }; c.mark_modified(); } diff --git a/src/scenery.hpp b/src/scenery.hpp index 3e7c4e4f..cc8cc159 100644 --- a/src/scenery.hpp +++ b/src/scenery.hpp @@ -6,23 +6,21 @@ namespace floormat { struct anim_atlas; -enum class rotation : std::uint16_t { +enum class rotation : std::uint8_t { N, NE, E, SE, S, SW, W, NW, COUNT, }; struct scenery final { - static constexpr auto NO_FRAME = (1 << 12) - 1; + static constexpr auto NO_FRAME = (std::uint16_t)-1; using frame_t = std::uint16_t; - rotation r : 4 = rotation::N; - frame_t frame : 12 = NO_FRAME; + frame_t frame = NO_FRAME; + rotation r = rotation::N; }; -static_assert(sizeof(scenery) == sizeof(std::uint16_t)); - struct scenery_proto final { std::shared_ptr atlas; scenery frame; -- cgit v1.2.3