diff options
-rw-r--r-- | serialize/json-helper.hpp | 2 | ||||
-rw-r--r-- | serialize/magnum-vector.hpp | 7 | ||||
-rw-r--r-- | serialize/magnum-vector2i.hpp | 4 | ||||
-rw-r--r-- | src/wall-mesh.hpp | 5 | ||||
-rw-r--r-- | 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<typename t> [[nodiscard]] - static std::tuple<t, bool> from_json(const std::filesystem::path& pathname); + static std::tuple<t, bool> from_json(const std::filesystem::path& pathname); template<typename t> [[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<Magnum::Math::Vector<N, T>>::to_json(json& j, const vec& val std::array<T, N> 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 <std::size_t N, typename T> void adl_serializer<Magnum::Math::Vector<N, T>>::from_json(const json& j, vec& val) { - std::array<T, N> array = j; + std::array<T, N> 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<Magnum::Math::Vector2<t>> 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<Vector2, 4>; - using position_array = std::array<Vector3, 4>; - struct vertex final { - typename texcoords_array::value_type texcoords; + std::array<Vector2, 4> texcoords; }; using quad = std::array<vertex, 4>; 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; } |