Browse Source

Follow up 10f0ead08f82711135ee0d582e2ab905579380e0
* Some correction on parsing yaml block

Cydh 5 years ago
parent
commit
fe16295762
2 changed files with 10 additions and 13 deletions
  1. 5 8
      src/map/item_synthesis.cpp
  2. 5 5
      src/map/item_upgrade.cpp

+ 5 - 8
src/map/item_synthesis.cpp

@@ -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;
 		}

+ 5 - 5
src/map/item_upgrade.cpp

@@ -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;
 		}