From edb014053ebd3256b3bce16d8d5ac6479d905a2e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 27 Oct 2022 14:42:14 +0200 Subject: kill serializing the world for now --- serialize/world.cpp | 46 ++-------------------------------------------- 1 file changed, 2 insertions(+), 44 deletions(-) (limited to 'serialize/world.cpp') diff --git a/serialize/world.cpp b/serialize/world.cpp index 7bdf8ba6..cd6ebd6b 100644 --- a/serialize/world.cpp +++ b/serialize/world.cpp @@ -1,10 +1,6 @@ #include "world.hpp" -#include "serialize/tile.hpp" -#include "serialize/tile-atlas.hpp" #include "src/global-coords.hpp" -#include "src/chunk.hpp" -#include "src/world.hpp" -#include +#include "serialize/tile.hpp" #include #if defined _MSC_VER @@ -30,49 +26,11 @@ namespace nlohmann { using namespace floormat; -template<> -struct adl_serializer> final { - static void to_json(json& j, const std::shared_ptr& x); - static void from_json(const json& j, std::shared_ptr& x); -}; - -void adl_serializer>::to_json(json& j, const std::shared_ptr& val) -{ - using nlohmann::to_json; - if (!val) - j = nullptr; - else - j = *val; -} - -void adl_serializer>::from_json(const json& j, std::shared_ptr& val) -{ - using nlohmann::from_json; - if (j.is_null()) - val = nullptr; - else - *(val = std::make_shared()) = j; -} - 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}; } -void adl_serializer::to_json(json& j, const world& val) -{ - using nlohmann::to_json; - to_json(j, val.chunks()); -} - -void adl_serializer::from_json(const json& j, world& val) -{ - using T = std::remove_cvref_t; - T x{}; - using nlohmann::from_json; - from_json(j, x); - val = world{std::move(x)}; -} - } // namespace nlohmann + -- cgit v1.2.3