From b6a42cc53f808c86342d1bcd400ea95e6e7f5762 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 29 Oct 2022 00:54:19 +0200 Subject: serializer work --- serialize/world-reader.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'serialize/world-reader.cpp') diff --git a/serialize/world-reader.cpp b/serialize/world-reader.cpp index 4b5d365c..4c67031e 100644 --- a/serialize/world-reader.cpp +++ b/serialize/world-reader.cpp @@ -35,7 +35,8 @@ void reader_state::read_atlases(reader_t& s) Vector2ub size; s >> size[0]; s >> size[1]; - atlases[i] = loader.tile_atlas(s.read_asciiz_string(), size); + auto str = s.read_asciiz_string(); + atlases[i] = loader.tile_atlas({str.buf, str.len}, size); } } @@ -67,9 +68,10 @@ void reader_state::read_chunks(reader_t& s) const auto make_atlas = [&]() -> tile_image { auto atlas = lookup_atlas(s.read()); auto id = s.read(); + fm_assert(id < atlas->num_tiles()); return { atlas, id }; }; - tile t; + tile& t = chunk[i]; if (flags & meta_ground) t.ground_image = make_atlas(); if (flags & meta_wall_n) @@ -86,7 +88,6 @@ void reader_state::read_chunks(reader_t& s) default: fm_abort("bad pass mode '%zu' for tile %zu", i, (std::size_t)x); } - chunk[i] = std::move(t); } } } -- cgit v1.2.3