diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2024-02-09 23:46:45 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-02-10 01:08:23 +0100 |
commit | c7caf58e53975ad0f1d2da88708697c7b1bb5c32 (patch) | |
tree | 75ade1b77ccc52d48dc19da3853211a5675f4134 /serialize | |
parent | e9082d38bf47c4083ef3469eb5779a79735f77cf (diff) |
loader, serialize: clean up a bit
Diffstat (limited to 'serialize')
-rw-r--r-- | serialize/anim.cpp | 1 | ||||
-rw-r--r-- | serialize/ground-atlas.cpp | 1 | ||||
-rw-r--r-- | serialize/magnum-vector.cpp | 7 |
3 files changed, 6 insertions, 3 deletions
diff --git a/serialize/anim.cpp b/serialize/anim.cpp index 4b5dee77..cd1f5e5c 100644 --- a/serialize/anim.cpp +++ b/serialize/anim.cpp @@ -152,6 +152,7 @@ void adl_serializer<anim_scale>::from_json(const json& j, anim_scale& val) { fm_soft_assert(j.is_array()); fm_soft_assert(j.size() == 2); + val = {}; StringView type = j[0]; if (type == "factor"_s) { diff --git a/serialize/ground-atlas.cpp b/serialize/ground-atlas.cpp index 11ef40ef..6844019c 100644 --- a/serialize/ground-atlas.cpp +++ b/serialize/ground-atlas.cpp @@ -26,6 +26,7 @@ void adl_serializer<ground_def>::to_json(json& j, const ground_def& x) void adl_serializer<ground_def>::from_json(const json& j, ground_def& val) { using nlohmann::from_json; + val = {}; val.name = j["name"]; val.size = j["size"]; if (j.contains("pass-mode")) diff --git a/serialize/magnum-vector.cpp b/serialize/magnum-vector.cpp index 2a31877e..8e9bfaeb 100644 --- a/serialize/magnum-vector.cpp +++ b/serialize/magnum-vector.cpp @@ -1,6 +1,7 @@ #include "magnum-vector.hpp" #include "compat/format.hpp" #include "compat/exception.hpp" +#include "corrade-string.hpp" #include <Magnum/Math/Vector.h> #include <cstdio> #include <string> @@ -10,12 +11,12 @@ namespace floormat::Serialize { namespace { -[[noreturn]] void throw_failed_to_parse_vector2(const std::string& str) +[[noreturn]] void throw_failed_to_parse_vector2(StringView str) { fm_throw("failed to parse Vector2 '{}'"_cf, str); } -[[noreturn]] void throw_vector2_overflow(const std::string& str) +[[noreturn]] void throw_vector2_overflow(StringView str) { fm_throw("numeric overflow in Vector2 '{}'"_cf, str); } @@ -63,7 +64,7 @@ struct vec2_serializer static void from_json(const json& j, Vector<2, T>& val) { using namespace floormat; - std::string str = j; + StringView str = j; using type = std::conditional_t<std::is_signed_v<T>, intmax_t, uintmax_t>; constexpr auto format_string = std::is_signed_v<T> ? "%jd x %jd%n" : "%ju x %ju%n"; type x = 0, y = 0; |