Fix custom functions decode of func

This commit is contained in:
elecpower
2021-12-31 10:53:11 +01:00
committed by Raphael Coeffic
parent 9057a6b7f1
commit 47a3d343b5
@@ -61,7 +61,7 @@ static const YamlLookupTable customFnLut = {
{ FuncBacklight, "BACKLIGHT" }, { FuncBacklight, "BACKLIGHT" },
{ FuncScreenshot, "SCREENSHOT" }, { FuncScreenshot, "SCREENSHOT" },
{ FuncRacingMode, "RACING_MODE" }, { FuncRacingMode, "RACING_MODE" },
{ FuncDisableTouch, "DISABLE_TOUCH" }, { FuncDisableTouch, "DISABLE_TOUCH" },
}; };
static const YamlLookupTable trainerLut = { static const YamlLookupTable trainerLut = {
@@ -218,7 +218,7 @@ Node convert<CustomFunctionData>::encode(const CustomFunctionData& rhs)
if (!def.empty()) { if (!def.empty()) {
node["def"] = def; node["def"] = def;
} }
return node; return node;
} }
@@ -228,13 +228,13 @@ bool convert<CustomFunctionData>::decode(const Node& node,
node["swtch"] >> rhs.swtch; node["swtch"] >> rhs.swtch;
int func = 0; int func = 0;
node["func"] >> func; node["func"] >> customFnLut >> func;
rhs.func = (AssignFunc)func; rhs.func = (AssignFunc)func;
std::string def_str; std::string def_str;
node["def"] >> def_str; node["def"] >> def_str;
std::stringstream def(def_str); std::stringstream def(def_str);
switch(rhs.func) { switch(rhs.func) {
case FuncOverrideCH1: { case FuncOverrideCH1: {
int ch=0; int ch=0;
@@ -254,7 +254,7 @@ bool convert<CustomFunctionData>::decode(const Node& node,
case FuncPlayPrompt: case FuncPlayPrompt:
case FuncPlayScript: case FuncPlayScript:
case FuncBackgroundMusic: case FuncBackgroundMusic:
strncpy(rhs.paramarm, def.str().c_str(), sizeof(rhs.paramarm)-1); strncpy(rhs.paramarm, def.str().c_str(), sizeof(rhs.paramarm)-1); // TODO fix eg def: engarm,1x
break; break;
case FuncReset: { case FuncReset: {
try { try {
@@ -327,7 +327,7 @@ bool convert<CustomFunctionData>::decode(const Node& node,
rhs.repeatParam = std::stoi(repeat); rhs.repeatParam = std::stoi(repeat);
} }
} }
return true; return true;
} }
} // namespace YAML } // namespace YAML