From 7ab99aabe8509e84b9b5b04aafa1e1ae20b40512 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 16 Oct 2022 21:51:07 +0200 Subject: a --- src/world.hpp | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/world.hpp b/src/world.hpp index 0d28429e..b21502e0 100644 --- a/src/world.hpp +++ b/src/world.hpp @@ -9,21 +9,12 @@ struct chunk_coords final { }; struct global_coords final { + std::int16_t cx = 0, cy = 0; std::int32_t x = 0, y = 0; - constexpr chunk_coords chunk() const noexcept; - constexpr chunk_coords local() const noexcept; -}; - -constexpr chunk_coords global_coords::chunk() const noexcept { - constexpr std::uint32_t mask = 0xffff0000u; - const auto x_ = (std::int16_t)(std::uint16_t)((std::uint32_t)x & mask >> 24), - y_ = (std::int16_t)(std::uint16_t)((std::uint32_t)y & mask >> 24); - return {x_, y_}; -} -constexpr chunk_coords global_coords::local() const noexcept { - const auto x_ = (std::uint8_t)x, y_ = (std::uint8_t)y; - return {x_, y_}; -} + constexpr global_coords(chunk_coords c, local_coords xy) + : cx{c.x}, cy{c.y}, x{xy.x}, y{xy.y} + {} +}; } // namespace floormat -- cgit v1.2.3