-
Notifications
You must be signed in to change notification settings - Fork 8
Add type-safe pop_sum_t for large value sums of pops and refactor pop_size_t to be type-safe #677
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,6 @@ | |
| #include "openvic-simulation/types/fixed_point/FixedPoint.hpp" | ||
| #include "openvic-simulation/types/fixed_point/FixedPointMap.hpp" | ||
| #include "openvic-simulation/types/fixed_point/Fraction.hpp" | ||
| #include "openvic-simulation/types/PopSize.hpp" | ||
| #include "openvic-simulation/utility/Getters.hpp" | ||
|
|
||
| namespace OpenVic { | ||
|
|
@@ -23,6 +22,8 @@ namespace OpenVic { | |
| struct ProductionType; | ||
| struct ProvinceInstance; | ||
| struct RandomU32; | ||
| struct pop_size_t; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you still need this? |
||
| struct pop_sum_t; | ||
|
|
||
| struct ArtisanalProducer { | ||
| private: | ||
|
|
@@ -48,7 +49,7 @@ namespace OpenVic { | |
| static fixed_point_t calculate_production_type_score( | ||
| const fixed_point_t revenue, | ||
| const fixed_point_t costs, | ||
| const pop_size_t workforce | ||
| const pop_sum_t workforce | ||
| ); | ||
|
|
||
| public: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ | |
| #include "openvic-simulation/misc/GameRulesManager.hpp" | ||
| #include "openvic-simulation/population/PopManager.hpp" | ||
| #include "openvic-simulation/population/PopType.hpp" | ||
| #include "openvic-simulation/population/PopSum.hpp" | ||
|
|
||
| using namespace OpenVic; | ||
| using namespace OpenVic::NodeTools; | ||
|
|
@@ -28,7 +29,7 @@ ProductionType::ProductionType( | |
| const std::optional<Job> new_owner, | ||
| memory::vector<Job>&& new_jobs, | ||
| const template_type_t new_template_type, | ||
| const pop_size_t new_base_workforce_size, | ||
| const pop_sum_t new_base_workforce_size, | ||
| fixed_point_map_t<GoodDefinition const*>&& new_input_goods, | ||
| GoodDefinition const& new_output_good, | ||
| const fixed_point_t new_base_output_quantity, | ||
|
|
@@ -139,7 +140,7 @@ bool ProductionTypeManager::add_production_type( | |
| std::optional<Job> owner, | ||
| memory::vector<Job>&& jobs, | ||
| const ProductionType::template_type_t template_type, | ||
| const pop_size_t base_workforce_size, | ||
| const pop_sum_t base_workforce_size, | ||
| fixed_point_map_t<GoodDefinition const*>&& input_goods, | ||
| GoodDefinition const* const output_good, | ||
| const fixed_point_t base_output_quantity, | ||
|
|
@@ -327,7 +328,7 @@ bool ProductionTypeManager::load_production_types_file( | |
| memory::vector<Job> jobs; | ||
| ProductionType::template_type_t template_type { FACTORY }; | ||
| GoodDefinition const* output_good = nullptr; | ||
| pop_size_t base_workforce_size = 0; | ||
| pop_sum_t base_workforce_size = 0; | ||
| fixed_point_map_t<GoodDefinition const*> input_goods, maintenance_requirements; | ||
| fixed_point_t base_output_quantity = 0; | ||
| memory::vector<ProductionType::bonus_t> bonuses; | ||
|
|
@@ -360,7 +361,7 @@ bool ProductionTypeManager::load_production_types_file( | |
| "employees", ZERO_OR_ONE, _expect_job_list(good_definition_manager, pop_manager, move_variable_callback(jobs)), | ||
| "type", ZERO_OR_ONE, | ||
| expect_identifier(expect_mapped_string(template_type_map, assign_variable_callback(template_type))), | ||
| "workforce", ZERO_OR_ONE, expect_uint(assign_variable_callback(base_workforce_size)), | ||
| "workforce", ZERO_OR_ONE, expect_strong_typedef<pop_size_t>(assign_variable_callback(base_workforce_size)), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you use
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given #677 (comment), shouldn't we just make all production workforce size stuff use |
||
| "input_goods", ZERO_OR_ONE, | ||
| good_definition_manager.expect_good_definition_decimal_map(move_variable_callback(input_goods)), | ||
| "output_goods", ZERO_OR_ONE, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.