diff options
Diffstat (limited to 'serialize')
-rw-r--r-- | serialize/old-savegame.cpp | 13 | ||||
-rw-r--r-- | serialize/savegame.cpp | 10 |
2 files changed, 13 insertions, 10 deletions
diff --git a/serialize/old-savegame.cpp b/serialize/old-savegame.cpp index 8a050022..df0cbbb5 100644 --- a/serialize/old-savegame.cpp +++ b/serialize/old-savegame.cpp @@ -118,7 +118,7 @@ constexpr inline atlasid scenery_id_flag_mask_ = meta_short_scenery_bit_ | meta_ constexpr inline atlasid scenery_id_max_ = int_traits<atlasid>::max & ~scenery_id_flag_mask_; struct reader_state final { - explicit reader_state(world& world) noexcept; + explicit reader_state(world& world, loader_policy policy) noexcept; void deserialize_world(ArrayView<const char> buf, proto_t proto); private: @@ -139,13 +139,14 @@ private: std::vector<String> atlases; world* _world; uint16_t PROTO = proto_version; + loader_policy asset_policy; Array<chunk::object_draw_order> draw_array; Array<std::array<chunk::vertex, 4>> draw_vertexes; Array<std::array<UnsignedShort, 6>> draw_indexes; }; -reader_state::reader_state(world& world) noexcept : _world{&world} {} +reader_state::reader_state(world& world, loader_policy p) noexcept : _world{&world}, asset_policy{p} {} void reader_state::read_atlases(reader_t& s) { @@ -325,13 +326,13 @@ void reader_state::read_chunks(reader_t& s) auto name = lookup_atlas(id); if constexpr(std::is_same_v<ground_atlas, T>) { - auto atlas = loader.ground_atlas(name, loader_policy::warn); + auto atlas = loader.ground_atlas(name, asset_policy); fm_soft_assert(v < atlas->num_tiles()); return { atlas, v }; } else if (std::is_same_v<wall_atlas, T>) { - auto atlas = loader.wall_atlas(name, loader_policy::warn); + auto atlas = loader.wall_atlas(name, asset_policy); return { atlas, v }; } else @@ -636,9 +637,9 @@ void reader_state::deserialize_world(ArrayView<const char> buf, proto_t proto) namespace floormat { -void world::deserialize_old(class world& w, ArrayView<const char> buf, proto_t proto) +void world::deserialize_old(class world& w, ArrayView<const char> buf, proto_t proto, loader_policy asset_policy) { - reader_state s{w}; + reader_state s{w, asset_policy}; s.deserialize_world(buf, proto); } diff --git a/serialize/savegame.cpp b/serialize/savegame.cpp index af151684..4f5d2025 100644 --- a/serialize/savegame.cpp +++ b/serialize/savegame.cpp @@ -717,7 +717,9 @@ struct reader final : visitor_<reader> uint32_t nstrings = 0, natlases = 0, nchunks = 0; class world& w; - reader(class world& w) : w{w} {} + loader_policy asset_policy; + + reader(class world& w, loader_policy asset_policy) : w{w}, asset_policy{asset_policy} {} using visitor_<reader>::visit; @@ -799,7 +801,7 @@ ok: PROTO << s; if (PROTO < proto_version_min && PROTO > 0) { - w.deserialize_old(w, buf.exceptPrefix(s.bytes_read()), PROTO); + w.deserialize_old(w, buf.exceptPrefix(s.bytes_read()), PROTO, asset_policy); return true; } else @@ -982,7 +984,7 @@ ok: } // namespace -class world world::deserialize(StringView filename) noexcept(false) +class world world::deserialize(StringView filename, loader_policy asset_policy) noexcept(false) { char errbuf[128]; buffer buf; @@ -1010,7 +1012,7 @@ class world world::deserialize(StringView filename) noexcept(false) } class world w; - struct reader r{w}; + struct reader r{w, asset_policy}; r.deserialize_world(buf); //fm_assert("todo" && false); |