summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--serialize/world-impl.hpp3
-rw-r--r--serialize/world-reader.cpp8
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 };