From 7740c71ecedd90f9b465dc35994e64915dbda826 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 7 Oct 2022 10:10:01 +0200 Subject: a --- serialize/json-helper.hpp | 2 +- serialize/magnum-vector.hpp | 7 +++++-- serialize/magnum-vector2i.hpp | 4 ++-- src/wall-mesh.hpp | 5 +---- test/json.cpp | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/serialize/json-helper.hpp b/serialize/json-helper.hpp index 6be7f74c..b8e290b7 100644 --- a/serialize/json-helper.hpp +++ b/serialize/json-helper.hpp @@ -9,7 +9,7 @@ struct json_helper final { template [[nodiscard]] - static std::tuple from_json(const std::filesystem::path& pathname); + static std::tuple from_json(const std::filesystem::path& pathname); template [[nodiscard]] diff --git a/serialize/magnum-vector.hpp b/serialize/magnum-vector.hpp index 8ea5e13a..61e127b1 100644 --- a/serialize/magnum-vector.hpp +++ b/serialize/magnum-vector.hpp @@ -22,13 +22,16 @@ void adl_serializer>::to_json(json& j, const vec& val std::array array{}; for (std::size_t i = 0; i < N; i++) array[i] = val[i]; - j = array; + using nlohmann::to_json; + to_json(j, array); } template void adl_serializer>::from_json(const json& j, vec& val) { - std::array array = j; + std::array array{}; + using nlohmann::from_json; + from_json(j, array); for (std::size_t i = 0; i < N; i++) val[i] = array[i]; } diff --git a/serialize/magnum-vector2i.hpp b/serialize/magnum-vector2i.hpp index eb445e21..c8c52e7e 100644 --- a/serialize/magnum-vector2i.hpp +++ b/serialize/magnum-vector2i.hpp @@ -27,12 +27,12 @@ struct adl_serializer> final { type x = 0, y = 0; int n = 0; int ret = std::sscanf(str.c_str(), format_string, &x, &y, &n); - if (ret != 2 || (std::size_t)n != str.size() || x != (type)x || y != (type)y) + if (ret != 2 || (std::size_t)n != str.size() || x != (t)x || y != (t)y) { std::string msg; msg.reserve(128); msg += "failed to parse string '"; msg += str; - msg += "' as Magnum::Vector2i"; + msg += "' as Magnum::Vector2"; throw std::invalid_argument(msg); } val = { (t)x, (t)y }; diff --git a/src/wall-mesh.hpp b/src/wall-mesh.hpp index 8daec2c1..e9678e3e 100644 --- a/src/wall-mesh.hpp +++ b/src/wall-mesh.hpp @@ -21,11 +21,8 @@ struct wall_mesh final private: static constexpr auto COUNT1 = TILE_MAX_DIM*2, COUNT = COUNT1 * COUNT1; - using texcoords_array = std::array; - using position_array = std::array; - struct vertex final { - typename texcoords_array::value_type texcoords; + std::array texcoords; }; using quad = std::array; diff --git a/test/json.cpp b/test/json.cpp index b98c9ae2..cec6724e 100644 --- a/test/json.cpp +++ b/test/json.cpp @@ -33,7 +33,7 @@ static chunk make_test_chunk() bool app::test_json() // NOLINT(readability-convert-member-functions-to-static) { bool ret = true; - const std::filesystem::path output_dir = "../test/"; + const std::filesystem::path output_dir = "../test/."; { auto atlas = loader.tile_atlas("share/game/images/metal1.tga", {2, 2}); ret &= json_helper::to_json(atlas, output_dir/"atlas.json"); @@ -50,7 +50,7 @@ bool app::test_json() // NOLINT(readability-convert-member-functions-to-static) } { const auto chunk = make_test_chunk(); - ret &= json_helper::to_json(chunk, output_dir/"chunk-1.json"); + ret &= json_helper::to_json(chunk, output_dir/"zzz_chunk-1.json"); } return ret; } -- cgit v1.2.3