diff options
| author | Stanislaw Halik <sthalik@misaki.pl> | 2023-11-22 13:41:14 +0100 |
|---|---|---|
| committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-11-22 13:41:14 +0100 |
| commit | a5c6ca806b2bde216effbea7cd5d964b3f235b5f (patch) | |
| tree | bd859c8082ff1460c957d965aca9f485d97bc973 /serialize/tile.cpp | |
| parent | be44dc48469437370abab260fbd2c91a82109f9c (diff) | |
a
Diffstat (limited to 'serialize/tile.cpp')
| -rw-r--r-- | serialize/tile.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/serialize/tile.cpp b/serialize/tile.cpp index 783a9853..7a0b1bed 100644 --- a/serialize/tile.cpp +++ b/serialize/tile.cpp @@ -7,10 +7,12 @@ namespace floormat { +using nlohmann::json; + NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(tile_image_proto, atlas, variant) -inline void to_json(nlohmann::json& j, const tile_image_ref& val) { j = tile_image_proto(val); } -inline void from_json(const nlohmann::json& j, tile_image_ref& val) { val = tile_image_proto(j); } +inline void to_json(json& j, const tile_image_ref& val) { j = tile_image_proto(val); } +inline void from_json(const json& j, tile_image_ref& val) { val = tile_image_proto(j); } struct local_coords_ final { uint8_t x, y; @@ -20,8 +22,8 @@ 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) -inline void to_json(nlohmann::json& j, global_coords coord) { j = std::tuple<chunk_coords, local_coords, int8_t>{ coord.chunk(), coord.local(), coord.z() }; } -inline void from_json(const nlohmann::json& j, global_coords& coord) { std::tuple<chunk_coords, local_coords, int8_t> t = j; auto [ch, pos, z] = t; coord = { ch, pos, z }; } +inline void to_json(json& j, global_coords coord) { j = std::tuple<chunk_coords, local_coords, int8_t>{ coord.chunk(), coord.local(), coord.z() }; } +inline void from_json(const json& j, global_coords& coord) { std::tuple<chunk_coords, local_coords, int8_t> t = j; auto [ch, pos, z] = t; coord = { ch, pos, z }; } } // namespace floormat |
