diff options
Diffstat (limited to 'serialize/world-impl.hpp')
-rw-r--r-- | serialize/world-impl.hpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/serialize/world-impl.hpp b/serialize/world-impl.hpp index c32c460f..dcd379a9 100644 --- a/serialize/world-impl.hpp +++ b/serialize/world-impl.hpp @@ -5,9 +5,18 @@ #pragma once #include "src/tile.hpp" #include <bit> +#include <cstddef> +#include <cstdint> #include <cstdio> #include <limits> +/* protocol changelog: + * 1) Initial version. + * 2) Tile atlas variant now always a uint8_t. Was uint16_t or uint8_t + * depending on value of the tile flag (1 << 6) which is now removed. + * 3) Serialize scenery. Tile flag (1 << 6) added. + */ + namespace floormat::Serialize { using tilemeta = std::uint8_t; @@ -24,13 +33,23 @@ template<typename T> constexpr inline T int_max = std::numeric_limits<T>::max(); constexpr inline std::size_t atlas_name_max = 128; constexpr inline auto null_atlas = (atlasid)-1LL; -constexpr inline proto_t proto_version = 2; +constexpr inline proto_t proto_version = 3; constexpr inline proto_t min_proto_version = 1; constexpr inline auto chunk_magic = (std::uint16_t)~0xc0d3; +constexpr inline auto scenery_magic = (std::uint16_t)~0xb00b; constexpr inline std::underlying_type_t<pass_mode> pass_mask = pass_blocked | pass_shoot_through | pass_ok; constexpr inline auto pass_bits = std::bit_width(pass_mask); +template<typename T> constexpr inline auto highbit = T(1) << sizeof(T)*8-1; +template<typename T, std::size_t N, std::size_t off> +constexpr inline auto highbits = (T(1) << N)-1 << sizeof(T)*8-N-off; + +constexpr inline atlasid meta_long_scenery_bit = highbit<atlasid>; +constexpr inline atlasid meta_rotation_bits = highbits<atlasid, rotation_BITS, 1>; +constexpr inline atlasid scenery_id_flag_mask = meta_long_scenery_bit | meta_rotation_bits; +constexpr inline atlasid scenery_id_max = int_max<atlasid> & ~scenery_id_flag_mask; + } // namespace enum : tilemeta { @@ -38,6 +57,7 @@ enum : tilemeta { meta_wall_n = 1 << (pass_bits + 1), meta_wall_w = 1 << (pass_bits + 2), meta_short_atlasid = 1 << (pass_bits + 3), + meta_scenery = 1 << (pass_bits + 4), }; } // namespace floormat::Serialize |