mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Fix Message YAML encode/decode.
* Don't create a condition key unless there's a condition. * Treat invalid message types as "say", not errors. Also a minor if statement tidy-up.
This commit is contained in:
@@ -108,7 +108,7 @@ namespace YAML {
|
||||
else
|
||||
out << Key << "content" << Value << rhs.Content();
|
||||
|
||||
if (!rhs.Condition().empty())
|
||||
if (rhs.IsConditional())
|
||||
out << Key << "condition" << Value << YAML::SingleQuoted << rhs.Condition();
|
||||
|
||||
out << EndMap;
|
||||
|
||||
@@ -70,7 +70,6 @@ namespace YAML {
|
||||
struct convert < loot::Message > {
|
||||
static Node encode(const loot::Message& rhs) {
|
||||
Node node;
|
||||
node["condition"] = rhs.Condition();
|
||||
node["content"] = rhs.Content();
|
||||
|
||||
if (rhs.Type() == loot::Message::say)
|
||||
@@ -80,6 +79,9 @@ namespace YAML {
|
||||
else
|
||||
node["type"] = "error";
|
||||
|
||||
if (rhs.IsConditional())
|
||||
node["condition"] = rhs.Condition();
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -87,18 +89,14 @@ namespace YAML {
|
||||
if (!node.IsMap() || !node["type"] || !node["content"])
|
||||
return false;
|
||||
|
||||
unsigned int typeNo = loot::Message::say;
|
||||
if (node["type"]) {
|
||||
std::string type;
|
||||
type = node["type"].as<std::string>();
|
||||
std::string type;
|
||||
type = node["type"].as<std::string>();
|
||||
|
||||
if (boost::iequals(type, "say"))
|
||||
typeNo = loot::Message::say;
|
||||
else if (boost::iequals(type, "warn"))
|
||||
typeNo = loot::Message::warn;
|
||||
else
|
||||
typeNo = loot::Message::error;
|
||||
}
|
||||
unsigned int typeNo = loot::Message::say;
|
||||
if (boost::iequals(type, "warn"))
|
||||
typeNo = loot::Message::warn;
|
||||
else if (boost::iequals(type, "error"))
|
||||
typeNo = loot::Message::error;
|
||||
|
||||
std::vector<loot::MessageContent> content;
|
||||
if (node["content"].IsSequence())
|
||||
|
||||
Reference in New Issue
Block a user