summaryrefslogtreecommitdiffhomepage
path: root/serialize
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-12-11 04:07:58 +0100
committerStanislaw Halik <sthalik@misaki.pl>2023-12-11 04:07:58 +0100
commitbe5ca3208891a8d45cbb7f9c25905f46332572a0 (patch)
tree04d89404a2aecb26f0dc2299bffdfba4f5eb8df3 /serialize
parenteaa6c76bd92e292ac59dcfa0a7aa70cd1e2f50fb (diff)
w
Diffstat (limited to 'serialize')
-rw-r--r--serialize/tile-atlas.cpp17
1 files changed, 6 insertions, 11 deletions
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<pass_mode> passability;
+ pass_mode passability;
};
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(proxy, name, size)
@@ -31,11 +31,7 @@ void adl_serializer<std::shared_ptr<tile_atlas>>::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<std::shared_ptr<tile_atlas>>::from_json(const json& j, std::shared_ptr<tile_atlas>& val)
@@ -47,15 +43,14 @@ void adl_serializer<std::shared_ptr<tile_atlas>>::from_json(const json& j, std::
using nlohmann::from_json;
proxy x;
from_json(j, x);
- Optional<pass_mode> 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));
}
}
}