From 275f7c672364d69b783b57f4c786e3279bc0cd69 Mon Sep 17 00:00:00 2001 From: Ted John Date: Mon, 9 May 2016 21:12:01 +0100 Subject: [PATCH] add global macro for gCurrentExpenditure, gCurrentProfit --- src/management/finance.c | 14 +++++++------- src/management/finance.h | 2 ++ src/rct1/S4Importer.cpp | 4 ++-- src/rct2/S6Exporter.cpp | 4 ++-- src/rct2/S6Importer.cpp | 4 ++-- src/scenario.c | 4 ++-- src/windows/finances.c | 2 +- src/windows/game_bottom_toolbar.c | 2 +- 8 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/management/finance.c b/src/management/finance.c index c930045952..c6b5788f4f 100644 --- a/src/management/finance.c +++ b/src/management/finance.c @@ -64,7 +64,7 @@ void finance_payment(money32 amount, rct_expenditure_type type) gCashEncrypted = ENCRYPT_MONEY(new_money); RCT2_ADDRESS(RCT2_ADDRESS_EXPENDITURE_TABLE, money32)[type] -= amount; if (dword_988E60[type] & 1) - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_EXPENDITURE, money32) -= amount; // Cumulative amount of money spent this day + gCurrentExpenditure -= amount; // Cumulative amount of money spent this day gToolbarDirtyFlags |= BTM_TB_DIRTY_FLAG_MONEY; @@ -168,8 +168,8 @@ void finance_init() { RCT2_ADDRESS(RCT2_ADDRESS_EXPENDITURE_TABLE, money32)[i] = 0; } - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_EXPENDITURE, uint32) = 0; - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32) = 0; + gCurrentExpenditure = 0; + gCurrentProfit = 0; RCT2_GLOBAL(0x01358334, money32) = 0; RCT2_GLOBAL(0x01358338, uint16) = 0; @@ -200,8 +200,8 @@ void finance_init() { */ void finance_update_daily_profit() { - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32) = 7 * RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_EXPENDITURE, money32); - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_EXPENDITURE, money32) = 0; // Reset daily expenditure + gCurrentProfit = 7 * gCurrentExpenditure; + gCurrentExpenditure = 0; // Reset daily expenditure money32 current_profit = 0; @@ -237,10 +237,10 @@ void finance_update_daily_profit() // This is not equivalent to / 4 due to rounding of negative numbers current_profit = current_profit >> 2; - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32) += current_profit; + gCurrentProfit += current_profit; // These are related to weekly profit graph - RCT2_GLOBAL(0x1358334, money32) += RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32); + RCT2_GLOBAL(0x1358334, money32) += gCurrentProfit; RCT2_GLOBAL(0x1358338, uint16) += 1; window_invalidate_by_class(WC_FINANCES); diff --git a/src/management/finance.h b/src/management/finance.h index eb53d4318e..366596d947 100644 --- a/src/management/finance.h +++ b/src/management/finance.h @@ -47,6 +47,8 @@ enum { #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) extern const money32 research_cost_table[4]; diff --git a/src/rct1/S4Importer.cpp b/src/rct1/S4Importer.cpp index 823fea1d17..aec15a5dbb 100644 --- a/src/rct1/S4Importer.cpp +++ b/src/rct1/S4Importer.cpp @@ -685,7 +685,7 @@ void S4Importer::ImportFinance() gCompanyValue = _s4.company_value; gParkValue = _s4.park_value; - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32) = _s4.profit; + gCurrentProfit = _s4.profit; for (int i = 0; i < 128; i++) { @@ -698,7 +698,7 @@ void S4Importer::ImportFinance() { RCT2_ADDRESS(RCT2_ADDRESS_EXPENDITURE_TABLE, money32)[i] = _s4.expenditure[i]; } - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_EXPENDITURE, money32) = _s4.total_expenditure; + gCurrentExpenditure = _s4.total_expenditure; gTotalAdmissions = _s4.num_admissions; gTotalIncomeFromAdmissions = _s4.admission_total_income; diff --git a/src/rct2/S6Exporter.cpp b/src/rct2/S6Exporter.cpp index 08ddf008f2..6368549171 100644 --- a/src/rct2/S6Exporter.cpp +++ b/src/rct2/S6Exporter.cpp @@ -329,8 +329,8 @@ void S6Exporter::Export() memcpy(_s6.balance_history, gCashHistory, sizeof(_s6.balance_history)); - _s6.current_expenditure = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_EXPENDITURE, money32); - _s6.current_profit = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32); + _s6.current_expenditure = gCurrentExpenditure; + _s6.current_profit = gCurrentProfit; _s6.dword_01358334 = RCT2_GLOBAL(0x01358334, uint32); _s6.word_01358338 = RCT2_GLOBAL(0x01358338, uint16); // pad_0135833A diff --git a/src/rct2/S6Importer.cpp b/src/rct2/S6Importer.cpp index 54e614f3f9..2893e4db26 100644 --- a/src/rct2/S6Importer.cpp +++ b/src/rct2/S6Importer.cpp @@ -261,8 +261,8 @@ void S6Importer::Import() memcpy(gCashHistory, _s6.balance_history, sizeof(_s6.balance_history)); - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_EXPENDITURE, money32) = _s6.current_expenditure; - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32) = _s6.current_profit; + gCurrentExpenditure = _s6.current_expenditure; + gCurrentProfit = _s6.current_profit; RCT2_GLOBAL(0x01358334, uint32) = _s6.dword_01358334; RCT2_GLOBAL(0x01358338, uint16) = _s6.word_01358338; // pad_0135833A diff --git a/src/scenario.c b/src/scenario.c index 07cdf5e3dc..24eccafbf7 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -233,8 +233,8 @@ void scenario_begin() strcat((char*)RCT2_ADDRESS_SAVED_GAMES_PATH_2, ".SV6"); memset((void*)0x001357848, 0, 56); - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_EXPENDITURE, uint32) = 0; - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32) = 0; + gCurrentExpenditure = 0; + gCurrentProfit = 0; RCT2_GLOBAL(0x01358334, money32) = 0; RCT2_GLOBAL(0x01358338, uint16) = 0; gScenarioCompletedCompanyValue = MONEY32_UNDEFINED; diff --git a/src/windows/finances.c b/src/windows/finances.c index 3ded740e6e..3a410b4021 100644 --- a/src/windows/finances.c +++ b/src/windows/finances.c @@ -1035,7 +1035,7 @@ static void window_finances_profit_graph_paint(rct_window *w, rct_drawpixelinfo graphBottom = w->y + pageWidget->bottom - 4; // Weekly profit - money32 weeklyPofit = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32); + money32 weeklyPofit = gCurrentProfit; gfx_draw_string_left( dpi, weeklyPofit >= 0 ? STR_FINANCES_WEEKLY_PROFIT_POSITIVE : STR_FINANCES_WEEKLY_PROFIT_LOSS, diff --git a/src/windows/game_bottom_toolbar.c b/src/windows/game_bottom_toolbar.c index a01b91956a..8075e70577 100644 --- a/src/windows/game_bottom_toolbar.c +++ b/src/windows/game_bottom_toolbar.c @@ -217,7 +217,7 @@ static void window_game_bottom_toolbar_tooltip(rct_window* w, int widgetIndex, r switch (widgetIndex) { case WIDX_MONEY: - RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, int) = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, sint32); + RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, int) = gCurrentProfit; RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 4, int) = gParkValue; break; case WIDX_PARK_RATING: