diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-03-19 16:48:20 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-03-19 16:48:27 +0100 |
commit | 01bad2db72d987890590607fb0a6042ea7c21c3a (patch) | |
tree | 502e7c3e6bdec28e805c06bc50f16ba226b42e66 /serialize | |
parent | 86bd6a4411badecfc76fe3a9d29b4aa30c8fdba7 (diff) |
fix scenery's json offset and rotation
Diffstat (limited to 'serialize')
-rw-r--r-- | serialize/anim.cpp | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/serialize/anim.cpp b/serialize/anim.cpp index 7be6323b..4d19acbe 100644 --- a/serialize/anim.cpp +++ b/serialize/anim.cpp @@ -38,7 +38,10 @@ static void to_json(nlohmann::json& j, const anim_group& val) const anim_group def{}; j["name"] = val.name; - j["frames"] = val.frames; + if (val.mirror_from) + j["mirror-from"] = val.mirror_from; + else + j["frames"] = val.frames; if (val.ground != def.ground) j["ground"] = val.ground; if (val.offset != def.offset) @@ -50,7 +53,10 @@ static void from_json(const nlohmann::json& j, anim_group& val) val = {}; val.name = j["name"]; fm_soft_assert(!val.name.isEmpty()); - val.frames = j["frames"]; + if (j.contains("mirror-from")) + val.mirror_from = j["mirror-from"]; + else + val.frames = j["frames"]; if (j.contains("ground")) val.ground = j["ground"]; if (j.contains("offset")) @@ -159,22 +165,7 @@ void adl_serializer<anim_group>::to_json(json& j, const anim_group& val) to_json(j, val); } -void adl_serializer<anim_group>::from_json(const json& j, anim_group& val) -{ - using nlohmann::from_json; - if (j.contains("mirror-from")) - { - const anim_group def{}; - - val.name = j["name"]; - val.mirror_from = j["mirror-from"]; - if (val.offset != def.offset) - val.offset = j["offset"]; - } - else - from_json(j, val); -} - +void adl_serializer<anim_group>::from_json(const json& j, anim_group& val) { using nlohmann::from_json; from_json(j, val); } void adl_serializer<anim_def>::to_json(json& j, const anim_def& val) { using nlohmann::to_json; to_json(j, val); } void adl_serializer<anim_def>::from_json(const json& j, anim_def& val) { using nlohmann::from_json; from_json(j, val); } |