From be5ca3208891a8d45cbb7f9c25905f46332572a0 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 11 Dec 2023 04:07:58 +0100 Subject: w --- serialize/tile-atlas.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'serialize/tile-atlas.cpp') diff --git a/serialize/tile-atlas.cpp b/serialize/tile-atlas.cpp index 8ade10d8..88385339 100644 --- a/serialize/tile-atlas.cpp +++ b/serialize/tile-atlas.cpp @@ -16,7 +16,7 @@ namespace { struct proxy { StringView name; Vector2ub size; - Optional passability; + pass_mode passability; }; NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(proxy, name, size) @@ -31,11 +31,7 @@ void adl_serializer>::to_json(json& j, const std::sh if (!x) j = nullptr; else - { - to_json(j, proxy{x->name(), x->num_tiles2(), NullOpt}); - if (auto p = x->pass_mode()) - j["pass-mode"] = *p; - } + to_json(j, proxy{x->name(), x->num_tiles2(), x->pass_mode()}); } void adl_serializer>::from_json(const json& j, std::shared_ptr& val) @@ -47,15 +43,14 @@ void adl_serializer>::from_json(const json& j, std:: using nlohmann::from_json; proxy x; from_json(j, x); - Optional p; + pass_mode p = tile_atlas::default_pass_mode; if (j.contains("pass-mode")) - p = {InPlaceInit, j["pass-mode"]}; + p = j["pass-mode"]; val = loader.tile_atlas(x.name, x.size, p); - if (auto p2 = val->pass_mode(); p && p2 != p) + if (auto p2 = val->pass_mode(); p2 != p) { - int m = p2 ? int(*p2) : -1; const auto name = val->name(); - fm_throw("atlas {} wrong pass mode {} should be {}"_cf, name, m, uint8_t(*p)); + fm_throw("atlas {} wrong pass mode {} should be {}"_cf, name, uint8_t(p2), uint8_t(p)); } } } -- cgit v1.2.3