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,25 +427,23 @@ 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; for (size_t i = 0; i < CPN_MAX_TRIMS; i++) {
for (size_t i=0; i<CPN_MAX_TRIMS; i++) { rhs.trimMode[i] = trims[i].mode;
rhs.trimMode[i] = trims[i].mode; rhs.trimRef[i] = trims[i].ref;
rhs.trimRef[i] = trims[i].ref; rhs.trim[i] = trims[i].value;
rhs.trim[i] = trims[i].value;
}
node["swtch"] >> rhs.swtch;
node["name"] >> rhs.name;
node["fadeIn"] >> rhs.fadeIn;
node["fadeOut"] >> rhs.fadeOut;
node["gvars"] >> rhs.gvars;
return true;
} }
}; node["swtch"] >> rhs.swtch;
node["name"] >> rhs.name;
node["fadeIn"] >> rhs.fadeIn;
node["fadeOut"] >> rhs.fadeOut;
node["gvars"] >> rhs.gvars;
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);