diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-30 00:28:33 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-30 00:28:33 +0100 |
commit | 3c79014b5da8d6f0bf297afc3d55247f920948c9 (patch) | |
tree | f84b0c3f99e1d348333cb94a47fe31817258be88 /serialize | |
parent | 01a8ae2ddf4b52fb9a7d5d46e433c19a5efcfa8d (diff) |
serialize/save: bump proto version
Diffstat (limited to 'serialize')
-rw-r--r-- | serialize/world-impl.hpp | 3 | ||||
-rw-r--r-- | serialize/world-reader.cpp | 8 |
2 files changed, 6 insertions, 5 deletions
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<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 = 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_mode> 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<const char> buf) auto s = binary_reader{buf}; if (!!::memcmp(s.read<std::size(file_magic)-1>().data(), file_magic, std::size(file_magic)-1)) fm_abort("bad magic"); - std::decay_t<decltype(proto_version)> 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(); |