From fbb2582a66be0b98166e1f6ac21eb218aefd82e1 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 11 Feb 2023 17:53:05 +0100 Subject: src/scenery, save: store dt as 16-bit fixed point Bump save proto version. --- serialize/world-impl.hpp | 2 +- serialize/world-reader.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'serialize') diff --git a/serialize/world-impl.hpp b/serialize/world-impl.hpp index e74ebda2..59c57e78 100644 --- a/serialize/world-impl.hpp +++ b/serialize/world-impl.hpp @@ -33,7 +33,7 @@ template constexpr inline T int_max = std::numeric_limits::max(); constexpr inline std::size_t atlas_name_max = 128; constexpr inline auto null_atlas = (atlasid)-1LL; -constexpr inline proto_t proto_version = 3; +constexpr inline proto_t proto_version = 4; 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; diff --git a/serialize/world-reader.cpp b/serialize/world-reader.cpp index f5459203..4d27c27f 100644 --- a/serialize/world-reader.cpp +++ b/serialize/world-reader.cpp @@ -173,7 +173,12 @@ void reader_state::read_chunks(reader_t& s) else sc.frame.frame << s; if (sc.frame.active) - sc.frame.delta << s; + { + if (PROTO >= 4) [[likely]] + sc.frame.delta << s; + else + sc.frame.delta = (std::uint16_t)Math::clamp(int(s.read() * 65535), 0, 65535); + } } t.scenery() = sc; } -- cgit v1.2.3