From 05c67aac26d6042454e5d0503acdb11b2c667176 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 6 Feb 2024 12:04:50 +0100 Subject: use enum loader_policy (lessen logspam) --- serialize/old-savegame.cpp | 13 +++++++------ serialize/savegame.cpp | 10 ++++++---- 2 files changed, 13 insertions(+), 10 deletions(-) (limited to 'serialize') 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::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 buf, proto_t proto); private: @@ -139,13 +139,14 @@ private: std::vector atlases; world* _world; uint16_t PROTO = proto_version; + loader_policy asset_policy; Array draw_array; Array> draw_vertexes; Array> 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) { - 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) { - 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 buf, proto_t proto) namespace floormat { -void world::deserialize_old(class world& w, ArrayView buf, proto_t proto) +void world::deserialize_old(class world& w, ArrayView 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_ 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_::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); -- cgit v1.2.3