Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/openvic-simulation/country/CountryInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ CountryInstance::CountryInstance(
building_type_unlock_levels { building_type_keys },

/* Budget */
balance_history{30, 0},
taxable_income_by_pop_type { pop_type_keys },
effective_tax_rate_by_strata {
strata_keys,
Expand Down Expand Up @@ -1835,7 +1836,7 @@ void CountryInstance::country_tick_before_map(InstanceManager& instance_manager)
// + industrial subsidies
// + loan interest

fixed_point_t available_funds = cash_stockpile;
fixed_point_t available_funds = cache_stockpile_start_of_tick = cash_stockpile;
fixed_point_t actual_import_subsidies;
const fixed_point_t projected_administration_spending_copy = projected_administration_spending.get_untracked();
const fixed_point_t projected_education_spending_copy = projected_education_spending.get_untracked();
Expand Down Expand Up @@ -1979,6 +1980,8 @@ void CountryInstance::country_tick_after_map(InstanceManager& instance_manager)
const fixed_point_t gold_income_value = country_defines.get_gold_to_cash_rate() * total_gold_production;;
gold_income.set(gold_income_value);
cash_stockpile += gold_income_value;
const fixed_point_t yesterdays_balance = cash_stockpile - cache_stockpile_start_of_tick;
balance_history.push_back(yesterdays_balance);
}

CountryInstance::good_data_t::good_data_t()
Expand Down
4 changes: 3 additions & 1 deletion src/openvic-simulation/country/CountryInstance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "openvic-simulation/types/TechnologyUnlockLevel.hpp"
#include "openvic-simulation/types/UnitBranchType.hpp"
#include "openvic-simulation/types/UnitVariant.hpp"
#include "openvic-simulation/types/ValueHistory.hpp"
#include "openvic-simulation/utility/Getters.hpp"
#include "openvic-simulation/utility/Containers.hpp"
#include "openvic-simulation/utility/reactive/DerivedState.hpp"
Expand Down Expand Up @@ -142,7 +143,8 @@ namespace OpenVic {
// TODO - total amount of each good produced

/* Budget */
// TODO - cash stockpile change over last 30 days
fixed_point_t cache_stockpile_start_of_tick;
ValueHistory<fixed_point_t> PROPERTY(balance_history);
STATE_PROPERTY(fixed_point_t, gold_income);
atomic_fixed_point_t PROPERTY(cash_stockpile);
std::mutex taxable_income_mutex;
Expand Down
Loading