Fixed reading flight mode data (gvars)

This commit is contained in:
Raphael Coeffic
2021-12-31 10:53:11 +01:00
parent b4a64189b7
commit 0190b1e19d
2 changed files with 29 additions and 18 deletions
@@ -245,6 +245,14 @@ struct YamlSwitchWarningState {
} }
}; };
template <>
void operator >> (const YAML::Node& node, FlightModeData& value)
{
if (node && !node.IsNull()) {
YAML::convert<FlightModeData>::decode(node, value);
}
}
namespace YAML namespace YAML
{ {
Node convert<TimerData>::encode(const TimerData& rhs) Node convert<TimerData>::encode(const TimerData& rhs)
@@ -419,9 +427,8 @@ Node EncodeFMData(const FlightModeData& rhs, int phaseIdx)
return node; return node;
} }
template <> bool convert<FlightModeData>::decode(const Node& node,
struct convert<FlightModeData> { FlightModeData& rhs)
static bool decode(const Node& node, FlightModeData& rhs)
{ {
YamlTrim trims[CPN_MAX_TRIMS]; YamlTrim trims[CPN_MAX_TRIMS];
node["trim"] >> trims; node["trim"] >> trims;
@@ -437,7 +444,6 @@ struct convert<FlightModeData> {
node["gvars"] >> rhs.gvars; node["gvars"] >> rhs.gvars;
return true; return true;
} }
};
template <> template <>
struct convert<SwashRingData> { struct convert<SwashRingData> {
@@ -29,6 +29,11 @@ struct convert<TimerData> {
static bool decode(const Node& node, TimerData& rhs); static bool decode(const Node& node, TimerData& rhs);
}; };
template <>
struct convert<FlightModeData> {
static bool decode(const Node& node, FlightModeData& rhs);
};
template <> template <>
struct convert<ModelData> { struct convert<ModelData> {
static Node encode(const ModelData& rhs); static Node encode(const ModelData& rhs);