diff --git a/src/backend/metadata/message.cpp b/src/backend/metadata/message.cpp index 15c43dae..b18fadab 100644 --- a/src/backend/metadata/message.cpp +++ b/src/backend/metadata/message.cpp @@ -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; diff --git a/src/backend/metadata/message.h b/src/backend/metadata/message.h index a080dc6f..f0b84663 100644 --- a/src/backend/metadata/message.h +++ b/src/backend/metadata/message.h @@ -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 type; + type = node["type"].as(); - 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 content; if (node["content"].IsSequence())