-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Government salaries and social income #363
base: master
Are you sure you want to change the base?
Conversation
6e6b63b
to
3ca3458
Compare
04e3b44
to
98e6a59
Compare
98e6a59
to
3f67419
Compare
@@ -13,6 +13,7 @@ | |||
#include "openvic-simulation/politics/Rebel.hpp" | |||
#include "openvic-simulation/utility/Logger.hpp" | |||
#include "openvic-simulation/utility/TslHelper.hpp" | |||
#include "dataloader/NodeTools.hpp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I expect this include was added by clangd automatically, you can disable that behaviour by adding this to your user settings JSON file:
"clangd.arguments": [
"-header-insertion=never"
]
|
||
public: | ||
void update_costs(PopType const& pop_type, PopsDefines const& pop_defines, GoodInstanceManager const& good_instance_manager); | ||
constexpr fixed_point_t get_social_income_form_base() const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be get_social_income_from_base
?
IndexedMap<PopType, SharedPopTypeValues> PROPERTY(shared_pop_type_values); | ||
|
||
public: | ||
SharedCountryValues( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Best to give this a default move constructor so shared_pop_type_values
doesn't ever get copied unnecessarily
if ((pop_type.get_##need_category##_needs_income_types() & ADMINISTRATION) == ADMINISTRATION) { \ | ||
administration_salary_base += base_##need_category##_need_costs; \ | ||
} \ | ||
if ((pop_type.get_##need_category##_needs_income_types() & EDUCATION) == EDUCATION) { \ | ||
education_salary_base += base_##need_category##_need_costs; \ | ||
} \ | ||
if ((pop_type.get_##need_category##_needs_income_types() & MILITARY) == MILITARY) { \ | ||
military_salary_base += base_##need_category##_need_costs; \ | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the if
statements here could use share_income_type
rather than manually doing the bitwise operations
|
||
fixed_point_t PROPERTY(administrative_efficiency); | ||
constexpr fixed_point_t get_corruption_cost_multiplier() const { | ||
return 2 - administrative_efficiency; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there definitely no need for a std::max(0, ...)
here or any other bounds check?
constexpr SharedCountryValues const& get_shared_country_values() const { | ||
return shared_country_values; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just put PROPERTY
around the shared_country_values
declaration above?
projected_administration_spending_unscaled_by_slider += size * calculate_administration_salary_base(pop_type, shared_country_values); | ||
projected_education_spending_unscaled_by_slider += size * calculate_education_salary_base(pop_type, shared_country_values); | ||
projected_military_spending_unscaled_by_slider += size * calculate_military_salary_base(pop_type, shared_country_values); | ||
projected_pensions_spending_unscaled_by_slider += size * calculate_pensions_base(pop_type, shared_country_values); | ||
projected_unemployment_subsidies_spending_unscaled_by_slider += pop_type_unemployed_count[pop_type] | ||
* calculate_unemployment_subsidies_base(pop_type, shared_country_values); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned in previous comments, the functions called here involve many repeated lookups/calculations which could be avoided with caching
} | ||
} | ||
|
||
for (auto const& [good_instance, data] : goods_data) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (auto const& [good_instance, data] : goods_data) { | |
for (auto& data : goods_data.get_values()) { |
You can iterate over an IndexedMap
's values directly
@@ -1691,6 +1822,68 @@ void CountryInstance::report_output(ProductionType const& production_type, const | |||
good_data.production_per_production_type[&production_type] += quantity; | |||
} | |||
|
|||
void CountryInstance::request_salaries_and_welfare(Pop& pop, SharedCountryValues const& shared_country_values) const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function could also benefit from caching rather than always looking up/calculating new values in every function call
} | ||
|
||
#undef DO_FOR_ALL_NEED_CATEGORIES |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and the PopNeedsMacro.hpp
include at the top of the file can be removed
Implements administration, education & military spending as well as pensions and unemployment subsidies.