From d17ed6b4ba01a73d33e3ff3ca8f0f6fb25259223 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 8 Apr 2023 10:06:12 +0200 Subject: a --- serialize/tile.cpp | 4 ++++ serialize/tile.hpp | 7 +++++++ 2 files changed, 11 insertions(+) (limited to 'serialize') diff --git a/serialize/tile.cpp b/serialize/tile.cpp index 1b6158e7..61431e61 100644 --- a/serialize/tile.cpp +++ b/serialize/tile.cpp @@ -17,6 +17,7 @@ struct local_coords_ final { NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(local_coords_, x, y) NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(chunk_coords, x, y) +NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(chunk_coords_, x, y, z) struct global_coords_ final { chunk_coords chunk; @@ -40,6 +41,9 @@ void adl_serializer::from_json(const json& j, local_coords& val) { void adl_serializer::to_json(json& j, const chunk_coords& val) { using nlohmann::to_json; to_json(j, val); } void adl_serializer::from_json(const json& j, chunk_coords& val) { using nlohmann::from_json; from_json(j, val); } +void adl_serializer::to_json(json& j, const chunk_coords_& val) { using nlohmann::to_json; to_json(j, val); } +void adl_serializer::from_json(const json& j, chunk_coords_& val) { using nlohmann::from_json; from_json(j, val); } + void adl_serializer::to_json(json& j, const global_coords& val) { using nlohmann::to_json; to_json(j, global_coords_{val.chunk(), val.local()}); } void adl_serializer::from_json(const json& j, global_coords& val) { using nlohmann::from_json; global_coords_ x; from_json(j, x); val = {x.chunk, x.local}; } diff --git a/serialize/tile.hpp b/serialize/tile.hpp index 66982682..8313e937 100644 --- a/serialize/tile.hpp +++ b/serialize/tile.hpp @@ -6,6 +6,7 @@ namespace floormat { struct tile_image_ref; struct local_coords; struct chunk_coords; +struct chunk_coords_; struct global_coords; } // namespace floormat @@ -30,6 +31,12 @@ struct adl_serializer { static void from_json(const json& j, floormat::chunk_coords& val); }; +template<> +struct adl_serializer { + static void to_json(json& j, const floormat::chunk_coords_& val); + static void from_json(const json& j, floormat::chunk_coords_& val); +}; + template<> struct adl_serializer { static void to_json(json& j, const floormat::global_coords& val); -- cgit v1.2.3