From a819819ff4d87e85ca41ad31cb699f3240d9166d Mon Sep 17 00:00:00 2001 From: Ted John Date: Sat, 23 Apr 2016 02:37:23 +0100 Subject: [PATCH] add global macro: gGuestInitialHunger --- src/interface/console.c | 4 ++-- src/peep/peep.c | 2 +- src/peep/peep.h | 1 + src/rct1/S4Importer.cpp | 2 +- src/windows/editor_scenario_options.c | 10 +++++----- src/world/park.c | 2 +- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/interface/console.c b/src/interface/console.c index 31fdda8a02..199410b06e 100644 --- a/src/interface/console.c +++ b/src/interface/console.c @@ -495,7 +495,7 @@ static int cc_get(const utf8 **argv, int argc) } } else if (strcmp(argv[0], "guest_initial_hunger") == 0) { - console_printf("guest_initial_hunger %d%% (%d)", ((255 - RCT2_GLOBAL(RCT2_ADDRESS_GUEST_INITIAL_HUNGER, uint8)) * 100) / 255, RCT2_GLOBAL(RCT2_ADDRESS_GUEST_INITIAL_HUNGER, uint8)); + console_printf("guest_initial_hunger %d%% (%d)", ((255 - gGuestInitialHunger) * 100) / 255, gGuestInitialHunger); } else if (strcmp(argv[0], "guest_initial_thirst") == 0) { console_printf("guest_initial_thirst %d%% (%d)", ((255 - RCT2_GLOBAL(RCT2_ADDRESS_GUEST_INITIAL_THIRST, uint8)) * 100) / 255, RCT2_GLOBAL(RCT2_ADDRESS_GUEST_INITIAL_THIRST, uint8)); @@ -622,7 +622,7 @@ static int cc_set(const utf8 **argv, int argc) console_execute_silent("get guest_initial_happiness"); } else if (strcmp(argv[0], "guest_initial_hunger") == 0 && invalidArguments(&invalidArgs, int_valid[0])) { - RCT2_GLOBAL(RCT2_ADDRESS_GUEST_INITIAL_HUNGER, uint8) = (clamp(int_val[0], 1, 84) * 255 / 100 - 255) * -1; + gGuestInitialHunger = (clamp(int_val[0], 1, 84) * 255 / 100 - 255) * -1; console_execute_silent("get guest_initial_hunger"); } else if (strcmp(argv[0], "guest_initial_thirst") == 0 && invalidArguments(&invalidArgs, int_valid[0])) { diff --git a/src/peep/peep.c b/src/peep/peep.c index 60c0bcae27..7878ac78ff 100644 --- a/src/peep/peep.c +++ b/src/peep/peep.c @@ -6126,7 +6126,7 @@ rct_peep *peep_generate(int x, int y, int z) peep->nausea = 0; peep->nausea_growth_rate = 0; - sint8 hunger = (scenario_rand() & 0x1F) - 15 + RCT2_GLOBAL(RCT2_ADDRESS_GUEST_INITIAL_HUNGER, uint8); + sint8 hunger = (scenario_rand() & 0x1F) - 15 + gGuestInitialHunger; peep->hunger = hunger; diff --git a/src/peep/peep.h b/src/peep/peep.h index d5e27b2438..0f0e2fb20f 100644 --- a/src/peep/peep.h +++ b/src/peep/peep.h @@ -601,6 +601,7 @@ enum { #define gGuestInitialCash RCT2_GLOBAL(RCT2_ADDRESS_GUEST_INITIAL_CASH, money16) #define gGuestInitialHappiness RCT2_GLOBAL(RCT2_ADDRESS_GUEST_INITIAL_HAPPINESS, uint8) +#define gGuestInitialHunger RCT2_GLOBAL(RCT2_ADDRESS_GUEST_INITIAL_HUNGER, uint8) int peep_get_staff_count(); int peep_can_be_picked_up(rct_peep* peep); diff --git a/src/rct1/S4Importer.cpp b/src/rct1/S4Importer.cpp index db29354373..1151f8570a 100644 --- a/src/rct1/S4Importer.cpp +++ b/src/rct1/S4Importer.cpp @@ -959,7 +959,7 @@ void S4Importer::ImportParkFlags() // Initial guest status gGuestInitialCash = _s4.guest_initial_cash; - RCT2_GLOBAL(RCT2_ADDRESS_GUEST_INITIAL_HUNGER, uint8) = _s4.guest_initial_hunger; + gGuestInitialHunger = _s4.guest_initial_hunger; RCT2_GLOBAL(RCT2_ADDRESS_GUEST_INITIAL_THIRST, uint8) = _s4.guest_initial_thirst; // Staff colours diff --git a/src/windows/editor_scenario_options.c b/src/windows/editor_scenario_options.c index 02c47b7215..6eb24ed1bd 100644 --- a/src/windows/editor_scenario_options.c +++ b/src/windows/editor_scenario_options.c @@ -769,16 +769,16 @@ static void window_editor_scenario_options_guests_mousedown(int widgetIndex, rct window_invalidate(w); break; case WIDX_GUEST_INITIAL_HUNGER_INCREASE: - if (RCT2_GLOBAL(RCT2_ADDRESS_GUEST_INITIAL_HUNGER, uint8) > 40) { - RCT2_GLOBAL(RCT2_ADDRESS_GUEST_INITIAL_HUNGER, uint8) -= 4; + if (gGuestInitialHunger > 40) { + gGuestInitialHunger -= 4; } else { window_error_open(3264, STR_NONE); } window_invalidate(w); break; case WIDX_GUEST_INITIAL_HUNGER_DECREASE: - if (RCT2_GLOBAL(RCT2_ADDRESS_GUEST_INITIAL_HUNGER, uint8) < 250) { - RCT2_GLOBAL(RCT2_ADDRESS_GUEST_INITIAL_HUNGER, uint8) += 4; + if (gGuestInitialHunger < 250) { + gGuestInitialHunger += 4; } else { window_error_open(3265, STR_NONE); } @@ -904,7 +904,7 @@ static void window_editor_scenario_options_guests_paint(rct_window *w, rct_drawp // Guest initial hunger value x = w->x + w->widgets[WIDX_GUEST_INITIAL_HUNGER].left + 1; y = w->y + w->widgets[WIDX_GUEST_INITIAL_HUNGER].top; - arg = ((255 - RCT2_GLOBAL(RCT2_ADDRESS_GUEST_INITIAL_HUNGER, uint8)) * 100) / 255; + arg = ((255 - gGuestInitialHunger) * 100) / 255; gfx_draw_string_left(dpi, 3247, &arg, 0, x, y); // Guest initial thirst label diff --git a/src/world/park.c b/src/world/park.c index 03e1d2d748..74a9d0bdfa 100644 --- a/src/world/park.c +++ b/src/world/park.c @@ -109,7 +109,7 @@ void park_init() gGuestInitialCash = MONEY(50,00); // Cash per guest (average) gGuestInitialHappiness = calculate_guest_initial_happiness(50); // 50% - RCT2_GLOBAL(RCT2_ADDRESS_GUEST_INITIAL_HUNGER, uint8) = 200; + gGuestInitialHunger = 200; RCT2_GLOBAL(RCT2_ADDRESS_GUEST_INITIAL_THIRST, uint8) = 200; gScenarioObjectiveType = OBJECTIVE_GUESTS_BY; gScenarioObjectiveYear = 4;