Follow up 10f0ead08f82711135ee0d582e2ab905579380e0

* Some correction on parsing yaml block
This commit is contained in:
Cydh 2019-09-16 13:55:17 +07:00
parent 6abd8463b9
commit fe16295762
2 changed files with 10 additions and 13 deletions

View File

@ -36,13 +36,7 @@ uint64 ItemSynthesisDatabase::parseBodyNode(const YAML::Node &node) {
bool exists = entry != nullptr;
if (!exists) {
if (!this->nodeExists(node, "SourceNeeded"))
return 0;
if (!this->nodeExists(node, "SourceItem"))
return 0;
if (!this->nodeExists(node, "Reward"))
if (!this->nodesExist(node, { "SourceNeeded", "SourceItem", "Reward" }))
return 0;
entry = std::make_shared<s_item_synthesis_db>();
@ -98,7 +92,10 @@ uint64 ItemSynthesisDatabase::parseBodyNode(const YAML::Node &node) {
std::string script_str;
script_code *code;
if (!this->asString(node, "Reward", script_str) || !(code = parse_script(script_str.c_str(), this->getCurrentFile().c_str(), id, SCRIPT_IGNORE_EXTERNAL_BRACKETS))) {
if (!this->asString(node, "Reward", script_str))
return 0;
if (!(code = parse_script(script_str.c_str(), this->getCurrentFile().c_str(), id, SCRIPT_IGNORE_EXTERNAL_BRACKETS))) {
this->invalidWarning(node["Reward"], "Invalid item script for 'Reward'.\n");
return 0;
}

View File

@ -36,10 +36,7 @@ uint64 ItemUpgradeDatabase::parseBodyNode(const YAML::Node &node) {
bool exists = entry != nullptr;
if (!exists) {
if (!this->nodeExists(node, "TargetItem"))
return 0;
if (!this->nodeExists(node, "Result"))
if (!this->nodesExist(node, { "TargetItem", "Result" }))
return 0;
entry = std::make_shared<s_item_upgrade_db>();
@ -50,7 +47,10 @@ uint64 ItemUpgradeDatabase::parseBodyNode(const YAML::Node &node) {
std::string script_str;
script_code *code;
if (!this->asString(node, "Result", script_str) || !(code = parse_script(script_str.c_str(), this->getCurrentFile().c_str(), id, SCRIPT_IGNORE_EXTERNAL_BRACKETS))) {
if (!this->asString(node, "Result", script_str))
return 0;
if (!(code = parse_script(script_str.c_str(), this->getCurrentFile().c_str(), id, SCRIPT_IGNORE_EXTERNAL_BRACKETS))) {
this->invalidWarning(node["Result"], "Invalid item script for 'Result'.\n");
return 0;
}