From 30a044ae723448ce476712248359ebe2245368d2 Mon Sep 17 00:00:00 2001 From: Ted John Date: Wed, 11 May 2016 19:41:20 +0100 Subject: [PATCH] add globals for gWeeklyProfitAverage... --- src/addresses.h | 3 +++ src/management/finance.c | 8 ++++---- src/management/finance.h | 16 +++++++++------- src/rct2/S6Exporter.cpp | 4 ++-- src/rct2/S6Importer.cpp | 4 ++-- src/scenario.c | 4 ++-- src/scenario.h | 4 ++-- src/world/park.c | 11 ++++++----- 8 files changed, 30 insertions(+), 24 deletions(-) diff --git a/src/addresses.h b/src/addresses.h index 234d64e705..f993ff1a18 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -370,6 +370,9 @@ #define RCT2_ADDRESS_RIDE_COUNT 0x013587C8 #define RCT2_ADDRESS_RIDE_FLAGS 0x0097CF40 +#define RCT2_ADDRESS_WEEKLY_PROFIT_AVERAGE_DIVIDEND 0x01358334 +#define RCT2_ADDRESS_WEEKLY_PROFIT_AVERAGE_DIVISOR 0x01358338 + //How many ticks the scenario has existed for #define RCT2_ADDRESS_SAVED_AGE 0x01388698 #define RCT2_ADDRESS_SAVED_VIEW_X 0x0138869A diff --git a/src/management/finance.c b/src/management/finance.c index 60086a85cb..eb4615f6ed 100644 --- a/src/management/finance.c +++ b/src/management/finance.c @@ -172,8 +172,8 @@ void finance_init() { gCurrentExpenditure = 0; gCurrentProfit = 0; - RCT2_GLOBAL(0x01358334, money32) = 0; - RCT2_GLOBAL(0x01358338, uint16) = 0; + gWeeklyProfitAverageDividend = 0; + gWeeklyProfitAverageDivisor = 0; gInitialCash = MONEY(10000,00); // Cheat detection @@ -241,8 +241,8 @@ void finance_update_daily_profit() gCurrentProfit += current_profit; // These are related to weekly profit graph - RCT2_GLOBAL(0x1358334, money32) += gCurrentProfit; - RCT2_GLOBAL(0x1358338, uint16) += 1; + gWeeklyProfitAverageDividend += gCurrentProfit; + gWeeklyProfitAverageDivisor += 1; window_invalidate_by_class(WC_FINANCES); } diff --git a/src/management/finance.h b/src/management/finance.h index 7328f6452e..7232619f12 100644 --- a/src/management/finance.h +++ b/src/management/finance.h @@ -42,13 +42,15 @@ enum { #define EXPENDITURE_TABLE_MONTH_COUNT 16 #define EXPENDITURE_TABLE_TOTAL_COUNT (EXPENDITURE_TABLE_MONTH_COUNT * RCT_EXPENDITURE_TYPE_COUNT) -#define gInitialCash RCT2_GLOBAL(RCT2_ADDRESS_INITIAL_CASH, money32) -#define gCashEncrypted RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, money32) -#define gBankLoan RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, money32) -#define gBankLoanInterestRate RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_INTEREST_RATE, sint8) -#define gMaxBankLoan RCT2_GLOBAL(RCT2_ADDRESS_MAXIMUM_LOAN, money32) -#define gCurrentExpenditure RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_EXPENDITURE, money32) -#define gCurrentProfit RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32) +#define gInitialCash RCT2_GLOBAL(RCT2_ADDRESS_INITIAL_CASH, money32) +#define gCashEncrypted RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, money32) +#define gBankLoan RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, money32) +#define gBankLoanInterestRate RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_INTEREST_RATE, sint8) +#define gMaxBankLoan RCT2_GLOBAL(RCT2_ADDRESS_MAXIMUM_LOAN, money32) +#define gCurrentExpenditure RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_EXPENDITURE, money32) +#define gCurrentProfit RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32) +#define gWeeklyProfitAverageDividend RCT2_GLOBAL(RCT2_ADDRESS_WEEKLY_PROFIT_AVERAGE_DIVIDEND, money32) +#define gWeeklyProfitAverageDivisor RCT2_GLOBAL(RCT2_ADDRESS_WEEKLY_PROFIT_AVERAGE_DIVISOR, uint16) extern const money32 research_cost_table[4]; diff --git a/src/rct2/S6Exporter.cpp b/src/rct2/S6Exporter.cpp index 35bdb5121e..730d9e423d 100644 --- a/src/rct2/S6Exporter.cpp +++ b/src/rct2/S6Exporter.cpp @@ -325,8 +325,8 @@ void S6Exporter::Export() _s6.current_expenditure = gCurrentExpenditure; _s6.current_profit = gCurrentProfit; - _s6.dword_01358334 = RCT2_GLOBAL(0x01358334, uint32); - _s6.word_01358338 = RCT2_GLOBAL(0x01358338, uint16); + _s6.weekly_profit_average_dividend = gWeeklyProfitAverageDividend; + _s6.weekly_profit_average_divisor = gWeeklyProfitAverageDivisor; // pad_0135833A memcpy(_s6.weekly_profit_history, gWeeklyProfitHistory, sizeof(_s6.weekly_profit_history)); diff --git a/src/rct2/S6Importer.cpp b/src/rct2/S6Importer.cpp index 5d43fedce3..351ebe4ac4 100644 --- a/src/rct2/S6Importer.cpp +++ b/src/rct2/S6Importer.cpp @@ -257,8 +257,8 @@ void S6Importer::Import() gCurrentExpenditure = _s6.current_expenditure; gCurrentProfit = _s6.current_profit; - RCT2_GLOBAL(0x01358334, uint32) = _s6.dword_01358334; - RCT2_GLOBAL(0x01358338, uint16) = _s6.word_01358338; + gWeeklyProfitAverageDividend = _s6.weekly_profit_average_dividend; + gWeeklyProfitAverageDivisor = _s6.weekly_profit_average_divisor; // pad_0135833A memcpy(gWeeklyProfitHistory, _s6.weekly_profit_history, sizeof(_s6.weekly_profit_history)); diff --git a/src/scenario.c b/src/scenario.c index 7f567f7074..5d94e2cd4d 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -235,8 +235,8 @@ void scenario_begin() memset((void*)0x001357848, 0, 56); gCurrentExpenditure = 0; gCurrentProfit = 0; - RCT2_GLOBAL(0x01358334, money32) = 0; - RCT2_GLOBAL(0x01358338, uint16) = 0; + gWeeklyProfitAverageDividend = 0; + gWeeklyProfitAverageDivisor = 0; gScenarioCompletedCompanyValue = MONEY32_UNDEFINED; gTotalAdmissions = 0; gTotalIncomeFromAdmissions = 0; diff --git a/src/scenario.h b/src/scenario.h index 609eb2a3cf..076e50c5fb 100644 --- a/src/scenario.h +++ b/src/scenario.h @@ -217,8 +217,8 @@ typedef struct { // SC6[11] money32 current_expenditure; money32 current_profit; - uint32 dword_01358334; - uint16 word_01358338; + uint32 weekly_profit_average_dividend; + uint16 weekly_profit_average_divisor; uint8 pad_0135833A[2]; // Ignored in scenario diff --git a/src/world/park.c b/src/world/park.c index 1c532a329b..6554ff40a0 100644 --- a/src/world/park.c +++ b/src/world/park.c @@ -628,16 +628,17 @@ void park_update_histories() window_invalidate_by_class(WC_FINANCES); // Update weekly profit history - money32 currentWeeklyProfit = RCT2_GLOBAL(0x01358334, money32); - if (RCT2_GLOBAL(0x01358338, uint16) != 0) - currentWeeklyProfit /= RCT2_GLOBAL(0x01358338, uint16); + money32 currentWeeklyProfit = gWeeklyProfitAverageDividend; + if (gWeeklyProfitAverageDivisor != 0) { + currentWeeklyProfit /= gWeeklyProfitAverageDivisor; + } for (int i = 127; i > 0; i--) gWeeklyProfitHistory[i] = gWeeklyProfitHistory[i - 1]; gWeeklyProfitHistory[0] = currentWeeklyProfit; - RCT2_GLOBAL(0x01358334, money32) = 0; - RCT2_GLOBAL(0x01358338, uint16) = 0; + gWeeklyProfitAverageDividend = 0; + gWeeklyProfitAverageDivisor = 0; window_invalidate_by_class(WC_FINANCES); // Update park value history