Fix shift for logical switches in raw sources

Resolves #1439
This commit is contained in:
Raphael Coeffic
2022-01-16 11:46:55 +01:00
parent 064a71f7f2
commit cdd933d6e1
@@ -49,7 +49,7 @@ std::string YamlRawSourceEncode(const RawSource& rhs)
break;
case SOURCE_TYPE_CUSTOM_SWITCH:
src_str += "ls(";
src_str += std::to_string(rhs.index);
src_str += std::to_string(rhs.index + 1);
src_str += ")";
break;
case SOURCE_TYPE_CYC:
@@ -139,8 +139,8 @@ RawSource YamlRawSourceDecode(const std::string& src_str)
std::stringstream src(src_str.substr(3));
int ls = 0;
src >> ls;
if (ls < CPN_MAX_LOGICAL_SWITCHES)
rhs = RawSource(SOURCE_TYPE_CUSTOM_SWITCH, ls);
if (ls > 0 && ls < CPN_MAX_LOGICAL_SWITCHES)
rhs = RawSource(SOURCE_TYPE_CUSTOM_SWITCH, ls - 1);
} else if (val_len > 3 &&
val[0] == 't' &&