Skip to content

Commit

Permalink
Merge pull request #233 from Fxrmillan/StorePopIncome
Browse files Browse the repository at this point in the history
Added stores for pop Income solves #225
  • Loading branch information
Hop311 authored Nov 18, 2024
2 parents c739c07 + deb3581 commit 30cafa3
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 6 deletions.
28 changes: 24 additions & 4 deletions src/openvic-simulation/pop/Pop.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#define KEEP_DO_FOR_ALL_TYPES_OF_INCOME
#include "Pop.hpp"

#undef KEEP_DO_FOR_ALL_TYPES_OF_INCOME
#include "openvic-simulation/country/CountryDefinition.hpp"
#include "openvic-simulation/country/CountryInstance.hpp"
#include "openvic-simulation/defines/Define.hpp"
Expand Down Expand Up @@ -44,6 +45,11 @@ Pop::Pop(PopBase const& pop_base, decltype(ideologies)::keys_t const& ideology_k
life_needs_fulfilled { 0 },
everyday_needs_fulfilled { 0 },
luxury_needs_fulfilled { 0 },
#define INITALIZE_POP_INCOME_STORES(name)\
name { 0 },

DO_FOR_ALL_TYPES_OF_POP_INCOME(INITALIZE_POP_INCOME_STORES)
#undef INITALIZE_POP_INCOME_STORES
max_supported_regiments { 0 } {}

void Pop::setup_pop_test_values(IssueManager const& issue_manager) {
Expand Down Expand Up @@ -159,9 +165,23 @@ void Pop::update_gamestate(
}
}

//TODO store income
void Pop::add_rgo_owner_income(const fixed_point_t income) {}
void Pop::add_rgo_worker_income(const fixed_point_t income) {}
#define DEFINE_ADD_INCOME_FUNCTIONS(name)\
void Pop::add_##name(const fixed_point_t pop_income){\
name += pop_income;\
income += pop_income;\
}

DO_FOR_ALL_TYPES_OF_POP_INCOME(DEFINE_ADD_INCOME_FUNCTIONS)
#undef DEFINE_ADD_INCOME_FUNCTIONS

#define SET_ALL_INCOME_TO_ZERO(name)\
name = fixed_point_t::_0();

void Pop::clear_all_income(){
DO_FOR_ALL_TYPES_OF_POP_INCOME(SET_ALL_INCOME_TO_ZERO)
#undef DO_FOR_ALL_TYPES_OF_POP_INCOME
#undef SET_ALL_INCOME_TO_ZERO
}

Strata::Strata(std::string_view new_identifier) : HasIdentifier { new_identifier } {}

Expand Down
32 changes: 30 additions & 2 deletions src/openvic-simulation/pop/Pop.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,26 @@ namespace OpenVic {
);
};

#define DO_FOR_ALL_TYPES_OF_POP_INCOME(F)\
F(rgo_owner_income)\
F(rgo_worker_income)\
F(artisanal_income)\
F(factory_worker_income)\
F(factory_owner_income)\
F(unemployment_subsidies)\
F(pensions)\
F(government_salary_administration)\
F(government_salary_education)\
F(government_salary_military)\
F(event_and_decision_income)\
F(loan_interest_payments)

#define DECLARE_POP_INCOME_STORES(income_type)\
fixed_point_t PROPERTY(income_type);

#define DECLARE_POP_INCOME_STORE_FUNCTIONS(name)\
void add_##name(const fixed_point_t pop_income);

/* REQUIREMENTS:
* POP-18, POP-19, POP-20, POP-21, POP-34, POP-35, POP-36, POP-37
*/
Expand Down Expand Up @@ -84,6 +104,9 @@ namespace OpenVic {
fixed_point_t PROPERTY(everyday_needs_fulfilled);
fixed_point_t PROPERTY(luxury_needs_fulfilled);

DO_FOR_ALL_TYPES_OF_POP_INCOME(DECLARE_POP_INCOME_STORES);
#undef DECLARE_POP_INCOME_STORES

size_t PROPERTY(max_supported_regiments);

Pop(PopBase const& pop_base, decltype(ideologies)::keys_t const& ideology_keys);
Expand All @@ -104,8 +127,10 @@ namespace OpenVic {
const fixed_point_t pop_size_per_regiment_multiplier
);

void add_rgo_owner_income(const fixed_point_t income);
void add_rgo_worker_income(const fixed_point_t income);
DO_FOR_ALL_TYPES_OF_POP_INCOME(DECLARE_POP_INCOME_STORE_FUNCTIONS)
#undef DECLARE_POP_INCOME_STORE_FUNCTIONS
void clear_all_income();

};

struct Strata : HasIdentifier {
Expand Down Expand Up @@ -346,3 +371,6 @@ namespace OpenVic {
bool parse_scripts(DefinitionManager const& definition_manager);
};
}
#ifndef KEEP_DO_FOR_ALL_TYPES_OF_INCOME
#undef DO_FOR_ALL_TYPES_OF_POP_INCOME
#endif

0 comments on commit 30cafa3

Please sign in to comment.