summaryrefslogtreecommitdiffhomepage
path: root/serialize
diff options
context:
space:
mode:
Diffstat (limited to 'serialize')
-rw-r--r--serialize/tile.cpp4
-rw-r--r--serialize/tile.hpp7
2 files changed, 11 insertions, 0 deletions
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<local_coords>::from_json(const json& j, local_coords& val) {
void adl_serializer<chunk_coords>::to_json(json& j, const chunk_coords& val) { using nlohmann::to_json; to_json(j, val); }
void adl_serializer<chunk_coords>::from_json(const json& j, chunk_coords& val) { using nlohmann::from_json; from_json(j, val); }
+void adl_serializer<chunk_coords_>::to_json(json& j, const chunk_coords_& val) { using nlohmann::to_json; to_json(j, val); }
+void adl_serializer<chunk_coords_>::from_json(const json& j, chunk_coords_& val) { using nlohmann::from_json; from_json(j, val); }
+
void adl_serializer<global_coords>::to_json(json& j, const global_coords& val) { using nlohmann::to_json; to_json(j, global_coords_{val.chunk(), val.local()}); }
void adl_serializer<global_coords>::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
@@ -31,6 +32,12 @@ struct adl_serializer<floormat::chunk_coords> {
};
template<>
+struct adl_serializer<floormat::chunk_coords_> {
+ 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<floormat::global_coords> {
static void to_json(json& j, const floormat::global_coords& val);
static void from_json(const json& j, floormat::global_coords& val);