Skip to content

Commit 7fb3707

Browse files
authored
Merge pull request #655 from OpenVicProject/fix_available_funds_bug
Fix available funds bug
2 parents b90b5ae + 2f84daa commit 7fb3707

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/openvic-simulation/country/CountryInstance.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1939,18 +1939,22 @@ void CountryInstance::country_tick_before_map(
19391939
const fixed_point_t projected_military_spending_copy = projected_military_spending.get_untracked();
19401940
const fixed_point_t projected_social_spending_copy = projected_social_spending.get_untracked();
19411941
const fixed_point_t projected_import_subsidies_copy = projected_import_subsidies.get_untracked();
1942-
if (projected_spending.get_untracked() <= available_funds) {
1942+
//excluding national stockpile
1943+
const fixed_point_t projected_total_spending = projected_spending.get_untracked();
1944+
if (projected_total_spending <= available_funds) {
19431945
actual_administration_budget = projected_administration_spending_copy;
19441946
actual_education_budget = projected_education_spending_copy;
19451947
actual_military_budget = projected_military_spending_copy;
19461948
actual_social_budget = projected_social_spending_copy;
19471949
actual_import_subsidies_budget = projected_import_subsidies_copy;
1950+
available_funds -= projected_total_spending;
19481951
} else {
19491952
//TODO try take loan (callback?)
19501953
//update available_funds with loan
19511954

19521955
if (available_funds < projected_education_spending_copy) {
19531956
actual_education_budget = available_funds;
1957+
available_funds = 0;
19541958
actual_administration_budget = 0;
19551959
actual_military_budget = 0;
19561960
actual_social_budget = 0;

0 commit comments

Comments
 (0)