From ac1cf0499a0ac4c6917e2912b572afcdb3844144 Mon Sep 17 00:00:00 2001 From: aleos Date: Tue, 8 Aug 2017 21:12:20 -0400 Subject: [PATCH] Follow up to dcbb2df * Adjusted the checks to one-line. * Corrected the map-server from spitting out an error for the achievements import file. --- 3rdparty/yaml-cpp/src/parse.cpp | 2 +- db/import-tmpl/achievement_db.yml | 2 ++ src/common/yamlwrapper.cpp | 4 +--- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/3rdparty/yaml-cpp/src/parse.cpp b/3rdparty/yaml-cpp/src/parse.cpp index a215e23f99..d864907edb 100644 --- a/3rdparty/yaml-cpp/src/parse.cpp +++ b/3rdparty/yaml-cpp/src/parse.cpp @@ -31,7 +31,7 @@ Node Load(std::istream& input) { Node LoadFile(const std::string& filename) { std::ifstream fin(filename.c_str()); - if (fin.bad()) { + if (!fin || fin.bad()) { throw BadFile(); } return Load(fin); diff --git a/db/import-tmpl/achievement_db.yml b/db/import-tmpl/achievement_db.yml index 2565e1751f..eb8448ccd6 100644 --- a/db/import-tmpl/achievement_db.yml +++ b/db/import-tmpl/achievement_db.yml @@ -76,3 +76,5 @@ ########################################################################### # Score - Achievement points that are given on completion. ########################################################################### + +Achievements: diff --git a/src/common/yamlwrapper.cpp b/src/common/yamlwrapper.cpp index f14bf513e2..36008da7e8 100644 --- a/src/common/yamlwrapper.cpp +++ b/src/common/yamlwrapper.cpp @@ -45,9 +45,7 @@ yamlwrapper* yaml_load_file(const char* file_name) { try { node = YAML::LoadFile(file_name); - if (!node.IsDefined()) - return NULL; - if (node.IsNull()) + if (!node.IsDefined() || node.IsNull()) return NULL; } catch (YAML::ParserException &e) { ShowError("YAML Exception Caught: %s\n", e.what());