diff options
Diffstat (limited to 'src/headless')
-rw-r--r-- | src/headless/main.cpp | 59 |
1 files changed, 31 insertions, 28 deletions
diff --git a/src/headless/main.cpp b/src/headless/main.cpp index 4c6eff5..a50b4ba 100644 --- a/src/headless/main.cpp +++ b/src/headless/main.cpp @@ -1,13 +1,10 @@ -#include <cstring> -#include <vector> - -#include <openvic-simulation/economy/GoodDefinition.hpp> #include <openvic-simulation/country/CountryInstance.hpp> +#include <openvic-simulation/dataloader/Dataloader.hpp> +#include <openvic-simulation/economy/GoodDefinition.hpp> #include <openvic-simulation/economy/production/ProductionType.hpp> #include <openvic-simulation/economy/production/ResourceGatheringOperation.hpp> -#include <openvic-simulation/pop/Pop.hpp> -#include <openvic-simulation/dataloader/Dataloader.hpp> #include <openvic-simulation/GameManager.hpp> +#include <openvic-simulation/pop/Pop.hpp> #include <openvic-simulation/testing/Testing.hpp> #include <openvic-simulation/utility/Logger.hpp> @@ -26,23 +23,35 @@ static void print_help(std::ostream& stream, char const* program_name) { static void print_rgo(ProvinceInstance const& province) { ResourceGatheringOperation const& rgo = province.get_rgo(); - ProductionType const* const production_type = rgo.get_production_type(); - if (production_type == nullptr) { + ProductionType const* const production_type_nullable = rgo.get_production_type_nullable(); + if (production_type_nullable == nullptr) { Logger::error( "\n ", province.get_identifier(), " - production_type: nullptr" ); - } - else { - GoodDefinition const& output_good = production_type->get_output_good(); - Logger::info( - "\n ", province.get_identifier(), + } else { + ProductionType const& production_type = *production_type_nullable; + GoodDefinition const& output_good = production_type.get_output_good(); + std::string text = StringUtils::append_string_views( + "\n\t", province.get_identifier(), " - good: ", output_good.get_identifier(), - ", production_type: ", production_type->get_identifier(), + ", production_type: ", production_type.get_identifier(), ", size_multiplier: ", rgo.get_size_multiplier().to_string(3), ", output_quantity_yesterday: ", rgo.get_output_quantity_yesterday().to_string(3), - ", revenue_yesterday: ", rgo.get_revenue_yesterday().to_string(3) + ", revenue_yesterday: ", rgo.get_revenue_yesterday().to_string(3), + ", total owner income: ", rgo.get_total_owner_income_cache().to_string(3), + ", total employee income: ", rgo.get_total_employee_income_cache().to_string(3), + "\n\temployees:" ); + + auto const& employee_count_per_type_cache=rgo.get_employee_count_per_type_cache(); + for (PopType const& pop_type : *employee_count_per_type_cache.get_keys()) { + const Pop::pop_size_t employees_of_type = employee_count_per_type_cache[pop_type]; + if (employees_of_type > 0) { + text += StringUtils::append_string_views("\n\t\t", std::to_string(employees_of_type), " ", pop_type.get_identifier()); + } + } + Logger::info("", text); } } @@ -106,19 +115,13 @@ static bool run_headless(Dataloader::path_vector_t const& roots, bool run_tests) print_ranking_list("All countries", country_instance_manager.get_total_ranking()); Logger::info("===== RGO test... ====="); - for (int i = 0; i < 3; ++i) { - CountryInstance const* const great_power = great_powers[i]; - if(great_power == nullptr) { - Logger::warning("Great power ",std::to_string(i), " is null."); - } - else { - ProvinceInstance const* const capital_province = great_power->get_capital(); - if(capital_province == nullptr) { - Logger::warning(great_power->get_identifier(), " has no capital ProvinceInstance set."); - } - else { - print_rgo(*capital_province); - } + for (size_t i = 0; i < std::min<size_t>(3, great_powers.size()); ++i) { + CountryInstance const& great_power = *great_powers[i]; + ProvinceInstance const* const capital_province = great_power.get_capital(); + if (capital_province == nullptr) { + Logger::warning(great_power.get_identifier(), " has no capital ProvinceInstance set."); + } else { + print_rgo(*capital_province); } } } else { |