diff options
author | wvpm <24685035+wvpm@users.noreply.github.com> | 2024-09-22 01:07:51 +0200 |
---|---|---|
committer | wvpm <24685035+wvpm@users.noreply.github.com> | 2024-10-30 22:04:41 +0100 |
commit | 0d861669d9e1f5d487c810ae01be50f142790f1e (patch) | |
tree | 187df50130475006b404c5ab57f0fa679173ad04 /src/headless/main.cpp | |
parent | 48e4e92682db99239e928a67e6677cdd2c53a375 (diff) |
Implement rgo for new gameprepare_for_rgo
Map province history rgo to production type for province instance
output_goods back to ZERO_OR_ONE
Link trade_goods in history to RGO instance for province.
Other producer types as structs instead of classes
Convert pops to equivalents & calculate rgo size
Also convert pops when changing rgo
Clean up
Refactored RGO into part of ProvinceInstance
ProductionType const& output_good
Remove unused imports
Clean up unused imports
Restore constructor for ResourceGatheringOperation to initialise from savegame
Move rgo size calculation to rgo
Use terrain modifiers to calculate rgo size (placeholder code)
Clean up
Basic production & sales for rgo when initialising new game
Use mutable pops
Paychecks for owners, workers and slaves
Clean up
Simplify rgo instantiation
Co-authored-by: Hop311 <Hop3114@gmail.com>
Simplify good_to_rgo_production_type assignment
Co-authored-by: Hop311 <Hop3114@gmail.com>
Fix import
Co-authored-by: Hop311 <Hop3114@gmail.com>
min(3, great_powers.size())
Co-authored-by: Hop311 <Hop3114@gmail.com>
Fix import
Co-authored-by: Hop311 <Hop3114@gmail.com>
Apply comments
Log errors and return result when applying history
Cleanup
Diffstat (limited to 'src/headless/main.cpp')
-rw-r--r-- | src/headless/main.cpp | 55 |
1 files changed, 52 insertions, 3 deletions
diff --git a/src/headless/main.cpp b/src/headless/main.cpp index 21e9f7c..a50b4ba 100644 --- a/src/headless/main.cpp +++ b/src/headless/main.cpp @@ -1,7 +1,10 @@ -#include <cstring> - +#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/GameManager.hpp> +#include <openvic-simulation/pop/Pop.hpp> #include <openvic-simulation/testing/Testing.hpp> #include <openvic-simulation/utility/Logger.hpp> @@ -18,6 +21,40 @@ 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& rgo = province.get_rgo(); + 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 { + 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(), + ", 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), + ", 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); + } +} + static bool run_headless(Dataloader::path_vector_t const& roots, bool run_tests) { bool ret = true; @@ -72,9 +109,21 @@ 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 (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 { Logger::error("Instance manager not available!"); ret = false; |