diff options
author | Hop311 <hop3114@gmail.com> | 2023-09-09 16:00:23 +0200 |
---|---|---|
committer | Hop311 <hop3114@gmail.com> | 2023-09-09 22:50:29 +0200 |
commit | b4220ad73e14e3b497b2fdeb83d76a6633664764 (patch) | |
tree | 72aee7b62ca2a1714799ff8f477ca1e50407eca8 /src/openvic-simulation/pop | |
parent | 7772f8871348b7b52cb0a478bb76df68d8799a07 (diff) |
PR feedback + Logger::warning
Diffstat (limited to 'src/openvic-simulation/pop')
-rw-r--r-- | src/openvic-simulation/pop/Pop.cpp | 25 | ||||
-rw-r--r-- | src/openvic-simulation/pop/Pop.hpp | 6 |
2 files changed, 12 insertions, 19 deletions
diff --git a/src/openvic-simulation/pop/Pop.cpp b/src/openvic-simulation/pop/Pop.cpp index 7b4dd60..f8e7254 100644 --- a/src/openvic-simulation/pop/Pop.cpp +++ b/src/openvic-simulation/pop/Pop.cpp @@ -126,7 +126,7 @@ bool PopManager::add_pop_type(const std::string_view identifier, colour_t colour return pop_types.add_item({ identifier, colour, strata, sprite, max_size, merge_max_size, state_capital_only, demote_migrant, is_artisan, is_slave }); } -bool PopManager::load_pop_type_file(std::filesystem::path const& path, ast::NodeCPtr root) { +bool PopManager::load_pop_type_file(const std::string_view filestem, ast::NodeCPtr root) { // TODO - pop type loading @@ -135,29 +135,24 @@ bool PopManager::load_pop_type_file(std::filesystem::path const& path, ast::Node return true; } -bool PopManager::load_pop_into_province(Province& province, ast::NodeCPtr root) const { +bool PopManager::load_pop_into_province(Province& province, const std::string_view pop_type_identifier, ast::NodeCPtr pop_node) const { static PopType const* type = get_pop_type_by_identifier("test_pop_type"); Culture const* culture = nullptr; Religion const* religion = nullptr; Pop::pop_size_t size = 0; - bool ret = expect_assign( - [this, &culture, &religion, &size](std::string_view, ast::NodeCPtr pop_node) -> bool { - return expect_dictionary_keys( - "culture", ONE_EXACTLY, culture_manager.expect_culture(culture), - "religion", ONE_EXACTLY, religion_manager.expect_religion(religion), - "size", ONE_EXACTLY, expect_uint(assign_variable_callback_uint("pop size", size)), - "militancy", ZERO_OR_ONE, success_callback, - "rebel_type", ZERO_OR_ONE, success_callback - )(pop_node); - } - )(root); + bool ret = expect_dictionary_keys( + "culture", ONE_EXACTLY, culture_manager.expect_culture(culture), + "religion", ONE_EXACTLY, religion_manager.expect_religion(religion), + "size", ONE_EXACTLY, expect_uint(assign_variable_callback_uint("pop size", size)), + "militancy", ZERO_OR_ONE, success_callback, + "rebel_type", ZERO_OR_ONE, success_callback + )(pop_node); if (type != nullptr && culture != nullptr && religion != nullptr && size > 0) { ret &= province.add_pop({ *type, *culture, *religion, size }); } else { - Logger::error("Some pop arguments are invalid: type = ", type, ", culture = ", culture, ", religion = ", religion, ", size = ", size); - ret = false; + Logger::warning("Some pop arguments are invalid: province = ", province, ", type = ", type, ", culture = ", culture, ", religion = ", religion, ", size = ", size); } return ret; } diff --git a/src/openvic-simulation/pop/Pop.hpp b/src/openvic-simulation/pop/Pop.hpp index 3c635a4..d01eb97 100644 --- a/src/openvic-simulation/pop/Pop.hpp +++ b/src/openvic-simulation/pop/Pop.hpp @@ -1,7 +1,5 @@ #pragma once -#include <filesystem> - #include "openvic-simulation/pop/Culture.hpp" #include "openvic-simulation/pop/Religion.hpp" @@ -95,7 +93,7 @@ namespace OpenVic { bool is_artisan, bool is_slave); IDENTIFIER_REGISTRY_ACCESSORS(PopType, pop_type) - bool load_pop_type_file(std::filesystem::path const& path, ast::NodeCPtr root); - bool load_pop_into_province(Province& province, ast::NodeCPtr root) const; + bool load_pop_type_file(const std::string_view filestem, ast::NodeCPtr root); + bool load_pop_into_province(Province& province, const std::string_view pop_type_identifier, ast::NodeCPtr pop_node) const; }; } |