diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-12-01 16:13:01 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-12-01 16:13:01 +0100 |
commit | 5d3cf6f42e991af7de220a1f2b6b530e8f06cc31 (patch) | |
tree | 080f852addd9e953c23814e643acbaf447f2e259 | |
parent | cc7d22803c50c1df9fc22e3ac91efd428bd5090d (diff) |
serialize/save: fix serializing proto 1 flags
-rw-r--r-- | serialize/world-impl.hpp | 3 | ||||
-rw-r--r-- | serialize/world-reader.cpp | 8 |
2 files changed, 9 insertions, 2 deletions
diff --git a/serialize/world-impl.hpp b/serialize/world-impl.hpp index dcd379a9..ea2a9cde 100644 --- a/serialize/world-impl.hpp +++ b/serialize/world-impl.hpp @@ -57,7 +57,8 @@ 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), + meta_short_variant_ = 1 << (pass_bits + 4), + meta_scenery = 1 << (pass_bits + 5), }; } // namespace floormat::Serialize diff --git a/serialize/world-reader.cpp b/serialize/world-reader.cpp index d61a574a..eb775e77 100644 --- a/serialize/world-reader.cpp +++ b/serialize/world-reader.cpp @@ -136,7 +136,13 @@ void reader_state::read_chunks(reader_t& s) using uchar = std::uint8_t; const auto make_atlas = [&]() -> tile_image_proto { auto id = flags & meta_short_atlasid ? atlasid{s.read<uchar>()} : s.read<atlasid>(); - auto v = s.read<variant_t>(); + variant_t v; + if (PROTO >= 2) [[likely]] + s >> v; + else + v = flags & meta_short_variant_ + ? s.read<std::uint8_t>() + : std::uint8_t(s.read<std::uint16_t>()); auto atlas = lookup_atlas(id); fm_assert(v < atlas->num_tiles()); return { atlas, v }; |