summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-02-26 19:36:49 +0100
committerStanislaw Halik <sthalik@misaki.pl>2023-02-26 19:36:49 +0100
commitf63d60309ec5b34d1a4816a8cfce474e6318838c (patch)
tree97faf42dab358ec314968245a6276731aa60be75
parent90d388665cfdb048a71fcadf0e142bb679f160ef (diff)
serialize: fix bug when loading own saves
-rw-r--r--serialize/world-writer.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/serialize/world-writer.cpp b/serialize/world-writer.cpp
index 6d1a0e94..170f4aa2 100644
--- a/serialize/world-writer.cpp
+++ b/serialize/world-writer.cpp
@@ -304,6 +304,12 @@ void writer_state::serialize_chunk(const chunk& c, chunk_coords coord)
auto img_w = maybe_intern_atlas(wall_west);
auto [sc, img_s, sc_exact] = maybe_intern_scenery(x.scenery(), true);
+ constexpr struct scenery default_scenery;
+
+ sc_exact &= scenery.offset == default_scenery.offset;
+ sc_exact &= scenery.bbox_size == default_scenery.bbox_size;
+ sc_exact &= scenery.bbox_offset == default_scenery.bbox_offset;
+
tilemeta flags = {};
flags |= meta_ground * (img_g != null_atlas);
flags |= meta_wall_n * (img_n != null_atlas);
@@ -352,11 +358,7 @@ void writer_state::serialize_chunk(const chunk& c, chunk_coords coord)
id |= meta_long_scenery_bit * sc_exact;
id |= atlasid(scenery.r) << sizeof(atlasid)*8-1-rotation_BITS;
s << id;
- if (constexpr struct scenery default_scenery;
- !sc_exact ||
- scenery.offset != default_scenery.offset ||
- scenery.bbox_size != default_scenery.bbox_size ||
- scenery.bbox_offset != default_scenery.bbox_offset)
+ if (!sc_exact)
{
fm_assert(scenery.active || scenery.delta == 0);
write_scenery_flags(s, scenery);