From 3c79014b5da8d6f0bf297afc3d55247f920948c9 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 30 Nov 2022 00:28:33 +0100 Subject: serialize/save: bump proto version --- serialize/world-impl.hpp | 3 ++- serialize/world-reader.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'serialize') diff --git a/serialize/world-impl.hpp b/serialize/world-impl.hpp index af79b451..c32c460f 100644 --- a/serialize/world-impl.hpp +++ b/serialize/world-impl.hpp @@ -24,7 +24,8 @@ 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 = 1; +constexpr inline proto_t proto_version = 2; +constexpr inline proto_t min_proto_version = 1; constexpr inline auto chunk_magic = (std::uint16_t)~0xc0d3; constexpr inline std::underlying_type_t pass_mask = pass_blocked | pass_shoot_through | pass_ok; diff --git a/serialize/world-reader.cpp b/serialize/world-reader.cpp index f792de1a..16a3afc1 100644 --- a/serialize/world-reader.cpp +++ b/serialize/world-reader.cpp @@ -100,11 +100,11 @@ void reader_state::deserialize_world(ArrayView buf) auto s = binary_reader{buf}; if (!!::memcmp(s.read().data(), file_magic, std::size(file_magic)-1)) fm_abort("bad magic"); - std::decay_t proto; + proto_t proto; s >> proto; - if (proto != proto_version) - fm_abort("bad proto version '%zu' (should be '%zu')", - (std::size_t)proto, (std::size_t)proto_version); + if (!(proto >= min_proto_version && proto <= proto_version)) + fm_abort("bad proto version '%zu' (should be between '%zu' and '%zu')", + (std::size_t)proto, (std::size_t)min_proto_version, (std::size_t)proto_version); read_atlases(s); read_chunks(s); s.assert_end(); -- cgit v1.2.3