diff options
Diffstat (limited to 'src/openvic-simulation/misc')
-rw-r--r-- | src/openvic-simulation/misc/Define.cpp | 60 |
1 files changed, 32 insertions, 28 deletions
diff --git a/src/openvic-simulation/misc/Define.cpp b/src/openvic-simulation/misc/Define.cpp index 509b0a5..3da1f4a 100644 --- a/src/openvic-simulation/misc/Define.cpp +++ b/src/openvic-simulation/misc/Define.cpp @@ -52,14 +52,17 @@ const Date& DefineManager::get_end_date() const { } bool DefineManager::add_date_define(std::string_view name, Date date) { - if (name != "start_date" && name != "end_date") return false; + if (name != "start_date" && name != "end_date") { + return false; + } bool ret = defines.add_item({ name, date.to_string(), Define::Type::None }); - if (name == "start_date") + if (name == "start_date") { start_date.reset(new Date(date)); - else if (name == "end_date") + } else if (name == "end_date") { end_date.reset(new Date(date)); + } return ret; } @@ -67,7 +70,8 @@ bool DefineManager::add_date_define(std::string_view name, Date date) { bool DefineManager::load_defines_file(ast::NodeCPtr root) { bool ret = expect_dictionary_keys( "defines", ONE_EXACTLY, expect_dictionary([this](std::string_view key, ast::NodeCPtr value) -> bool { - if (key == "country" || key == "economy" || key == "military" || key == "diplomacy" || key == "pops" || key == "ai" || key == "graphics") { + if (key == "country" || key == "economy" || key == "military" || key == "diplomacy" + || key == "pops" || key == "ai" || key == "graphics") { return expect_dictionary([this, &key](std::string_view inner_key, ast::NodeCPtr value) -> bool { std::string str_val; @@ -76,30 +80,30 @@ bool DefineManager::load_defines_file(ast::NodeCPtr root) { Define::Type type; switch (key[0]) { using enum Define::Type; - case 'c': // country - type = Country; - break; - case 'e': // economy - type = Economy; - break; - case 'm': // military - type = Military; - break; - case 'd': // diplomacy - type = Diplomacy; - break; - case 'p': // pops - type = Pops; - break; - case 'a': // ai - type = Ai; - break; - case 'g': // graphics - type = Graphics; - break; - default: - Logger::error("Unknown define type ", key, " found in defines!"); - return false; + case 'c': // country + type = Country; + break; + case 'e': // economy + type = Economy; + break; + case 'm': // military + type = Military; + break; + case 'd': // diplomacy + type = Diplomacy; + break; + case 'p': // pops + type = Pops; + break; + case 'a': // ai + type = Ai; + break; + case 'g': // graphics + type = Graphics; + break; + default: + Logger::error("Unknown define type ", key, " found in defines!"); + return false; } ret &= add_define(inner_key, std::move(str_val), type); |