diff options
Diffstat (limited to 'src/headless/main.cpp')
-rw-r--r-- | src/headless/main.cpp | 65 |
1 files changed, 63 insertions, 2 deletions
diff --git a/src/headless/main.cpp b/src/headless/main.cpp index 21e9f7c..85c0ce2 100644 --- a/src/headless/main.cpp +++ b/src/headless/main.cpp @@ -1,5 +1,12 @@ #include <cstring> - +#include <string> +#include <vector> + +#include "economy/GoodDefinition.hpp" +#include <openvic-simulation/country/CountryInstance.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/testing/Testing.hpp> @@ -18,6 +25,42 @@ static void print_help(std::ostream& stream, char const* program_name) { << "(Paths with spaces need to be enclosed in \"quotes\").\n"; } +static void print_rgo(ProvinceInstance const& province) { + ResourceGatheringOperation const* const rgo = province.get_rgo(); + if(rgo == nullptr) { + Logger::info("\n ", province.get_identifier(), " - rgo: nullptr"); + } + else { + ProductionType const* const production_type = rgo->get_production_type(); + if (production_type == nullptr) { + Logger::error( + "\n ", province.get_identifier(), + " - production_type: nullptr" + ); + } + else { + GoodDefinition const* const output_good = production_type->get_output_good(); + if(output_good == nullptr) { + Logger::error( + "\n ", province.get_identifier(), + " - good: nullptr", + ", production_type: ", production_type->get_identifier() + ); + } + else { + Logger::info( + "\n ", province.get_identifier(), + " - good: ", output_good->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) + ); + } + } + } +} + static bool run_headless(Dataloader::path_vector_t const& roots, bool run_tests) { bool ret = true; @@ -72,9 +115,27 @@ static bool run_headless(Dataloader::path_vector_t const& roots, bool run_tests) CountryInstanceManager const& country_instance_manager = game_manager.get_instance_manager()->get_country_instance_manager(); - print_ranking_list("Great Powers", country_instance_manager.get_great_powers()); + std::vector<CountryInstance*> const& great_powers = country_instance_manager.get_great_powers(); + print_ranking_list("Great Powers", great_powers); print_ranking_list("Secondary Powers", country_instance_manager.get_secondary_powers()); 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); + } + } + } } else { Logger::error("Instance manager not available!"); ret = false; |