summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-11-20 21:09:03 +0100
committerStanislaw Halik <sthalik@misaki.pl>2022-11-20 21:09:03 +0100
commit3ed15b56aded3a6f58ef98d0cbe17012e28e9430 (patch)
treee6fa61a797a81fd6bf7ee3f16c4bcb1a5f0bc8ff
parent2b710e55157b83cff93e3414e4017b34b9789bc3 (diff)
scenery: don't bother with bitfields
The `scenery_proto` struct is rounded up to a multiple of 8 bytes.
-rw-r--r--editor/update.cpp2
-rw-r--r--src/scenery.hpp10
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<anim_atlas> atlas;
scenery frame;