From b4b3dc7dbe63f688b88880647111aae4ad754375 Mon Sep 17 00:00:00 2001 From: Ted John Date: Sat, 23 Apr 2016 01:50:12 +0100 Subject: [PATCH] add global macro: gParkValue --- src/management/finance.c | 2 +- src/network/network.cpp | 2 +- src/rct1/S4Importer.cpp | 2 +- src/ride/ride.c | 2 +- src/scenario.c | 16 ++++------------ src/windows/finances.c | 4 ++-- src/windows/game_bottom_toolbar.c | 2 +- src/world/park.c | 6 +++--- src/world/park.h | 3 +++ 9 files changed, 17 insertions(+), 22 deletions(-) diff --git a/src/management/finance.c b/src/management/finance.c index 572ffc0035..bfeb37e0c2 100644 --- a/src/management/finance.c +++ b/src/management/finance.c @@ -184,7 +184,7 @@ void finance_init() { RCT2_GLOBAL(0x013587D0, uint32) = 0; RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_INTEREST_RATE, uint8) = 10; - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_VALUE, money32) = 0; + gParkValue = 0; RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_COMPANY_VALUE, money32) = 0; RCT2_GLOBAL(RCT2_ADDRESS_COMPLETED_COMPANY_VALUE, money32) = MONEY32_UNDEFINED; RCT2_GLOBAL(RCT2_ADDRESS_TOTAL_ADMISSIONS, uint32) = 0; diff --git a/src/network/network.cpp b/src/network/network.cpp index 90ea8b5ccf..280d752b40 100644 --- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -1128,7 +1128,7 @@ void Network::AdvertiseHeartbeat() json_object_set_new(gameInfo, "day", json_integer(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16))); json_object_set_new(gameInfo, "month", json_integer(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, uint16))); json_object_set_new(gameInfo, "guests", json_integer(gNumGuestsInPark)); - json_object_set_new(gameInfo, "parkValue", json_integer(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_VALUE, money32))); + json_object_set_new(gameInfo, "parkValue", json_integer(gParkValue)); if (!(gParkFlags & PARK_FLAGS_NO_MONEY)) { money32 cash = DECRYPT_MONEY(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, money32)); json_object_set_new(gameInfo, "cash", json_integer(cash)); diff --git a/src/rct1/S4Importer.cpp b/src/rct1/S4Importer.cpp index 219a1dbd4a..4b28de9780 100644 --- a/src/rct1/S4Importer.cpp +++ b/src/rct1/S4Importer.cpp @@ -662,7 +662,7 @@ void S4Importer::ImportFinance() RCT2_GLOBAL(RCT2_ADDRESS_INITIAL_CASH, money32) = _s4.cash; RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_COMPANY_VALUE, money32) = _s4.company_value; - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_VALUE, money32) = _s4.park_value; + gParkValue = _s4.park_value; RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32) = _s4.profit; for (int i = 0; i < 128; i++) diff --git a/src/ride/ride.c b/src/ride/ride.c index 3f1025484d..de30eee0df 100644 --- a/src/ride/ride.c +++ b/src/ride/ride.c @@ -6332,7 +6332,7 @@ void game_command_demolish_ride(int *eax, int *ebx, int *ecx, int *edx, int *esi user_string_free(ride->name); ride->type = RIDE_TYPE_NULL; window_invalidate_by_class(WC_RIDE_LIST); - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_VALUE, money32) = calculate_park_value(); + gParkValue = calculate_park_value(); RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16) = x; RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16) = y; RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16) = z; diff --git a/src/scenario.c b/src/scenario.c index 14042326d2..eabff1514e 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -278,7 +278,7 @@ void scenario_begin() window_park_objective_open(); gParkRating = calculate_park_rating(); - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_VALUE, money32) = calculate_park_value(); + gParkValue = calculate_park_value(); RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_COMPANY_VALUE, money32) = calculate_company_value(); RCT2_GLOBAL(0x013587D0, money32) = RCT2_GLOBAL(RCT2_ADDRESS_INITIAL_CASH, money32) - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, money32); RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, sint32) = ENCRYPT_MONEY(RCT2_GLOBAL(RCT2_ADDRESS_INITIAL_CASH, sint32)); @@ -1272,7 +1272,7 @@ static void scenario_objective_check_park_value_by() uint8 objectiveYear = RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_YEAR, uint8); sint16 currentMonthYear = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16); money32 objectiveParkValue = RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_CURRENCY, money32); - money32 parkValue = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_VALUE, money32); + money32 parkValue = gParkValue; if (currentMonthYear == 8 * objectiveYear) { if (parkValue >= objectiveParkValue) @@ -1419,7 +1419,7 @@ static void scenario_objective_check_finish_5_rollercoasters() static void scenario_objective_check_replay_loan_and_park_value() { money32 objectiveParkValue = RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_CURRENCY, money32); - money32 parkValue = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_VALUE, money32); + money32 parkValue = gParkValue; money32 currentLoan = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, money32); if (currentLoan <= 0 && parkValue >= objectiveParkValue) @@ -1445,16 +1445,8 @@ static void scenario_objective_check_monthly_food_income() */ static void scenario_objective_check() { - uint8 objective_type = RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_TYPE, uint8), - objective_year = RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_YEAR, uint8); - sint16 park_rating = gParkRating, - guests_in_park = gNumGuestsInPark, - objective_guests = RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_NUM_GUESTS, uint16), - cur_month_year = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16); + uint8 objective_type = RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_TYPE, uint8); uint32 scenario_completed_company_value = RCT2_GLOBAL(RCT2_ADDRESS_COMPLETED_COMPANY_VALUE, uint32); - sint32 objective_currency = RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_CURRENCY, sint32), - park_value = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_VALUE, sint32); - if (scenario_completed_company_value != MONEY32_UNDEFINED) return; diff --git a/src/windows/finances.c b/src/windows/finances.c index 658f3fe350..538322bd3e 100644 --- a/src/windows/finances.c +++ b/src/windows/finances.c @@ -756,7 +756,7 @@ static void window_finances_summary_paint(rct_window *w, rct_drawpixelinfo *dpi) gfx_draw_string_left(dpi, STR_LAST_MONTH_PROFIT_FROM_FOOD_DRINK_MERCHANDISE_SALES_LABEL, (void*)RCT2_ADDRESS_COMMON_FORMAT_ARGS, 0, w->x + 280, w->y + 229); } else { // Park value and company value - gfx_draw_string_left(dpi, STR_PARK_VALUE_LABEL, (void*)RCT2_ADDRESS_CURRENT_PARK_VALUE, 0, w->x + 280, w->y + 229); + gfx_draw_string_left(dpi, STR_PARK_VALUE_LABEL, &gParkValue, 0, w->x + 280, w->y + 229); gfx_draw_string_left(dpi, STR_COMPANY_VALUE_LABEL, (void*)RCT2_ADDRESS_CURRENT_COMPANY_VALUE, 0, w->x + 280, w->y + 244); } } @@ -933,7 +933,7 @@ static void window_finances_park_value_graph_paint(rct_window *w, rct_drawpixeli graphBottom = w->y + pageWidget->bottom - 4; // Park value - money32 parkValue = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_VALUE, money32); + money32 parkValue = gParkValue; gfx_draw_string_left( dpi, STR_FINACNES_PARK_VALUE, diff --git a/src/windows/game_bottom_toolbar.c b/src/windows/game_bottom_toolbar.c index 226377fbf3..34c6e7d59f 100644 --- a/src/windows/game_bottom_toolbar.c +++ b/src/windows/game_bottom_toolbar.c @@ -220,7 +220,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 + 4, int) = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_VALUE, sint32); + RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 4, int) = gParkValue; break; case WIDX_PARK_RATING: RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, short) = gParkRating; diff --git a/src/world/park.c b/src/world/park.c index f9f835d49f..cab54e3684 100644 --- a/src/world/park.c +++ b/src/world/park.c @@ -328,7 +328,7 @@ money32 calculate_company_value() { return DECRYPT_MONEY(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, sint32)) + - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_VALUE, money32) - + gParkValue - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, money32); } @@ -541,7 +541,7 @@ void park_update() // Every 5 seconds approximately if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) % 512 == 0) { gParkRating = calculate_park_rating(); - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_VALUE, money32) = calculate_park_value(); + gParkValue = calculate_park_value(); RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_COMPANY_VALUE, money32) = calculate_company_value(); window_invalidate_by_class(WC_FINANCES); _guestGenerationProbability = park_calculate_guest_generation_probability(); @@ -631,7 +631,7 @@ void park_update_histories() // Update park value history for (int i = 127; i > 0; i--) gParkValueHistory[i] = gParkValueHistory[i - 1]; - gParkValueHistory[0] = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_VALUE, money32); + gParkValueHistory[0] = gParkValue; } void park_set_entrance_fee(money32 value) diff --git a/src/world/park.h b/src/world/park.h index aa6470c052..596076b8ee 100644 --- a/src/world/park.h +++ b/src/world/park.h @@ -53,6 +53,9 @@ enum { #define gParkSize RCT2_GLOBAL(RCT2_ADDRESS_PARK_SIZE, uint16) #define gParkRating RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_RATING, uint16) #define gParkEntranceFee RCT2_GLOBAL(RCT2_ADDRESS_PARK_ENTRANCE_FEE, money16) + +#define gParkValue RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_VALUE, money32) + #define gNumGuestsInPark RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16) #define gLandPrice RCT2_GLOBAL(RCT2_ADDRESS_LAND_COST, money16)