From d4ae141eee51825fccf2350a6d8b906f24d57a95 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 18 Mar 2023 15:19:35 +0100 Subject: serialize/save: store entity counter right before chunks --- serialize/world-reader.cpp | 4 ++-- serialize/world-writer.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'serialize') diff --git a/serialize/world-reader.cpp b/serialize/world-reader.cpp index 84958109..dc698765 100644 --- a/serialize/world-reader.cpp +++ b/serialize/world-reader.cpp @@ -307,11 +307,11 @@ void reader_state::deserialize_world(ArrayView buf) (std::size_t)proto, (std::size_t)min_proto_version, (std::size_t)proto_version); PROTO = proto; std::uint64_t entity_counter = 0; - if (PROTO >= 8) [[likely]] - entity_counter << s; read_atlases(s); if (PROTO >= 3) [[likely]] read_sceneries(s); + if (PROTO >= 8) [[likely]] + entity_counter << s; read_chunks(s); s.assert_end(); if (PROTO >= 8) [[likely]] diff --git a/serialize/world-writer.cpp b/serialize/world-writer.cpp index 461f6dd6..f3af1c19 100644 --- a/serialize/world-writer.cpp +++ b/serialize/world-writer.cpp @@ -503,9 +503,9 @@ ArrayView writer_state::serialize_world() }; copy(Containers::StringView{file_magic, std::size(file_magic)-1}); copy_int((proto_t)proto_version); - copy_int((std::uint64_t)_world->entity_counter()); copy(atlas_buf); copy(scenery_buf); + copy_int((std::uint64_t)_world->entity_counter()); copy_int((chunksiz)_world->size()); for (const auto& buf : chunk_bufs) copy(buf); -- cgit v1.2.3