From 9478e0a53e259b0b53259dfdb3faa6bcfbe9c334 Mon Sep 17 00:00:00 2001 From: Ted John Date: Sun, 4 Sep 2016 15:36:39 +0100 Subject: [PATCH] Integrate gHistoricalProfit --- src/management/finance.c | 5 +++-- src/management/finance.h | 7 +++++++ src/rct2/S6Exporter.cpp | 2 +- src/rct2/S6Importer.cpp | 2 +- src/scenario.c | 2 +- src/scenario.h | 2 +- 6 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/management/finance.c b/src/management/finance.c index 664c723a8b..f6f06d9717 100644 --- a/src/management/finance.c +++ b/src/management/finance.c @@ -54,6 +54,7 @@ uint8 gBankLoanInterestRate; money32 gMaxBankLoan; money32 gCurrentExpenditure; money32 gCurrentProfit; +money32 gHistoricalProfit; money32 gWeeklyProfitAverageDividend; uint16 gWeeklyProfitAverageDivisor; money32 gCashHistory[128]; @@ -194,7 +195,7 @@ void finance_init() { gBankLoan = MONEY(10000,00); gMaxBankLoan = MONEY(20000,00); - RCT2_GLOBAL(0x013587D0, uint32) = 0; + gHistoricalProfit = 0; gBankLoanInterestRate = 10; gParkValue = 0; @@ -335,7 +336,7 @@ void finance_shift_expenditure_table() for (uint32 i = EXPENDITURE_TABLE_TOTAL_COUNT - RCT_EXPENDITURE_TYPE_COUNT; i < EXPENDITURE_TABLE_TOTAL_COUNT; i++) { sum += gExpenditureTable[i]; } - RCT2_GLOBAL(0x013587D0, money32) += sum; + gHistoricalProfit += sum; } // Shift the table diff --git a/src/management/finance.h b/src/management/finance.h index 26a5e18ff9..59c87abcc5 100644 --- a/src/management/finance.h +++ b/src/management/finance.h @@ -52,6 +52,13 @@ extern uint8 gBankLoanInterestRate; extern money32 gMaxBankLoan; extern money32 gCurrentExpenditure; extern money32 gCurrentProfit; + +/** + * The total profit for the entire scenario that preceeds + * the current financial table. + */ +extern money32 gHistoricalProfit; + extern money32 gWeeklyProfitAverageDividend; extern uint16 gWeeklyProfitAverageDivisor; extern money32 gCashHistory[128]; diff --git a/src/rct2/S6Exporter.cpp b/src/rct2/S6Exporter.cpp index c42e6951ea..1bf800819d 100644 --- a/src/rct2/S6Exporter.cpp +++ b/src/rct2/S6Exporter.cpp @@ -355,7 +355,7 @@ void S6Exporter::Export() _s6.loan_hash = GetLoanHash(gInitialCash, gBankLoan, gMaxBankLoan); _s6.ride_count = RCT2_GLOBAL(RCT2_ADDRESS_RIDE_COUNT, uint16); // pad_013587CA - _s6.dword_013587D0 = RCT2_GLOBAL(0x013587D0, uint32); + _s6.historical_profit = gHistoricalProfit; // pad_013587D4 memcpy(_s6.scenario_completed_name, gScenarioCompletedBy, sizeof(_s6.scenario_completed_name)); _s6.cash = gCashEncrypted; diff --git a/src/rct2/S6Importer.cpp b/src/rct2/S6Importer.cpp index ba83357975..18139dfc81 100644 --- a/src/rct2/S6Importer.cpp +++ b/src/rct2/S6Importer.cpp @@ -273,7 +273,7 @@ void S6Importer::Import() // _s6.loan_hash; RCT2_GLOBAL(RCT2_ADDRESS_RIDE_COUNT, uint16) = _s6.ride_count; // pad_013587CA - RCT2_GLOBAL(0x013587D0, uint32) = _s6.dword_013587D0; + gHistoricalProfit = _s6.historical_profit; // pad_013587D4 memcpy(gScenarioCompletedBy, _s6.scenario_completed_name, sizeof(_s6.scenario_completed_name)); gCashEncrypted = _s6.cash; diff --git a/src/scenario.c b/src/scenario.c index 71fb15557c..98cdbd8e17 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -196,7 +196,7 @@ void scenario_begin() gParkRating = calculate_park_rating(); gParkValue = calculate_park_value(); gCompanyValue = calculate_company_value(); - RCT2_GLOBAL(0x013587D0, money32) = gInitialCash - gBankLoan; + gHistoricalProfit = gInitialCash - gBankLoan; gCashEncrypted = ENCRYPT_MONEY(gInitialCash); safe_strcpy(gScenarioDetails, gS6Info->details, 256); diff --git a/src/scenario.h b/src/scenario.h index 5411b7718e..80514e8063 100644 --- a/src/scenario.h +++ b/src/scenario.h @@ -255,7 +255,7 @@ typedef struct rct_s6_data { uint32 loan_hash; uint16 ride_count; uint8 pad_013587CA[6]; - uint32 dword_013587D0; + money32 historical_profit; uint8 pad_013587D4[4]; char scenario_completed_name[32]; money32 cash;