From 169a3b6b72dd2368c1929377764921cba6340a10 Mon Sep 17 00:00:00 2001 From: lnz Date: Wed, 7 May 2014 16:24:36 +0200 Subject: [PATCH 1/2] Implement Peep problem warnings update. --- src/addresses.h | 2 + src/peep.c | 131 ++++++++++++++++++++++++++++++++++++++++++++++++ src/peep.h | 15 +++++- src/scenario.c | 2 +- src/strings.h | 8 +++ 5 files changed, 156 insertions(+), 2 deletions(-) diff --git a/src/addresses.h b/src/addresses.h index a453f9c7bd..571613eb3f 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -178,6 +178,8 @@ #define RCT2_ADDRESS_CURRENT_TICKS 0x013628F4 #define RCT2_ADDRESS_RIDE_LIST 0x013628F8 +#define RCT2_ADDRESS_RIDE_COUNT 0x013587C8 +#define RCT2_ADDRESS_RIDE_FLAGS 0x0097CF40 #define RCT2_ADDRESS_SAVED_VIEW_X 0x0138869A #define RCT2_ADDRESS_SAVED_VIEW_Y 0x0138869C #define RCT2_ADDRESS_RIDE_MEASUREMENTS 0x0138B60C diff --git a/src/peep.c b/src/peep.c index 0a16060ca2..194c255704 100644 --- a/src/peep.c +++ b/src/peep.c @@ -19,8 +19,10 @@ *****************************************************************************/ #include "addresses.h" +#include "news_item.h" #include "peep.h" #include "rct2.h" +#include "ride.h" #include "sprite.h" int peep_get_staff_count() @@ -71,3 +73,132 @@ void peep_update_all() i++; } } + + +/** + * + * rct2: 0x0069BF41 + **/ +void peep_problem_warnings_update() +{ + rct_peep* peep; + rct_ride* ride; + uint16 sprite_idx; + uint16 guests_in_park = RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16); + int hunger_counter = 0, lost_counter = 0, noexit_counter = 0, thirst_counter = 0, + litter_counter = 0, disgust_counter = 0, bathroom_counter = 0 ,vandalism_counter = 0; + static int warning_throttle[6] = { 0, 0, 0, 0, 0, 0 }; + + RCT2_GLOBAL(RCT2_ADDRESS_RIDE_COUNT, sint16) = ride_get_count(); // refactor this to somewhere else + + + for (sprite_idx = RCT2_GLOBAL(RCT2_ADDRESS_SPRITES_START_PEEP, uint16); sprite_idx != SPRITE_INDEX_NULL; sprite_idx = peep->next) { + peep = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[sprite_idx].peep); + + if (peep->type != PEEP_TYPE_GUEST || peep->var_2A != 0 || peep->thoughts[0].pad_3 > 5) + continue; + + switch (peep->thoughts[0].type) { + case PEEP_THOUGHT_TYPE_LOST: //0x10 + lost_counter++; + break; + + case PEEP_THOUGHT_TYPE_HUNGRY: // 0x14 + if (peep->var_C5 == -1){ + hunger_counter++; + break; + } + ride = &RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[peep->var_C5]; + if (!(RCT2_GLOBAL(RCT2_ADDRESS_RIDE_FLAGS + ride->type * 8, uint32) & 0x80000)) + hunger_counter++; + break; + + case PEEP_THOUGHT_TYPE_THIRSTY: + if (peep->var_C5 == -1){ + thirst_counter++; + break; + } + ride = &RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[peep->var_C5]; + if (!(RCT2_GLOBAL(RCT2_ADDRESS_RIDE_FLAGS + ride->type * 8, uint32) & 0x1000000)) + thirst_counter++; + break; + + case PEEP_THOUGHT_TYPE_BATHROOM: + if (peep->var_C5 == -1){ + bathroom_counter++; + break; + } + ride = &RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[peep->var_C5]; + if (!(RCT2_GLOBAL(RCT2_ADDRESS_RIDE_FLAGS + ride->type * 8, uint32) & 0x2000000)) + bathroom_counter++; + break; + + case PEEP_THOUGHT_TYPE_BAD_LITTER: // 0x1a + litter_counter++; + break; + case PEEP_THOUGHT_TYPE_CANT_FIND_EXIT: // 0x1b + noexit_counter++; + break; + case PEEP_THOUGHT_TYPE_PATH_DISGUSTING: // 0x1f + disgust_counter++; + break; + case PEEP_THOUGHT_TYPE_VANDALISM: //0x21 + vandalism_counter++; + break; + default: + break; + } + } + // could maybe be packed into a loop, would lose a lot of clarity though + if (warning_throttle[0]) + --warning_throttle[0]; + else if ( hunger_counter >= PEEP_HUNGER_WARNING_THRESHOLD && hunger_counter >= guests_in_park / 16) { + warning_throttle[0] = 4; + news_item_add_to_queue(NEWS_ITEM_PEEPS, STR_PEEPS_ARE_HUNGRY, 20); + } + + if (warning_throttle[1]) + --warning_throttle[1]; + else if (thirst_counter >= PEEP_THIRST_WARNING_THRESHOLD && thirst_counter >= guests_in_park / 16) { + warning_throttle[1] = 4; + news_item_add_to_queue(NEWS_ITEM_PEEPS, STR_PEEPS_ARE_THIRSTY, 21); + } + + if (warning_throttle[2]) + --warning_throttle[2]; + else if (bathroom_counter >= PEEP_BATHROOM_WARNING_THRESHOLD && bathroom_counter >= guests_in_park / 16) { + warning_throttle[2] = 4; + news_item_add_to_queue(NEWS_ITEM_PEEPS, STR_PEEPS_CANT_FIND_BATHROOM, 22); + } + + if (warning_throttle[3]) + --warning_throttle[3]; + else if (litter_counter >= PEEP_LITTER_WARNING_THRESHOLD && litter_counter >= guests_in_park / 32) { + warning_throttle[3] = 4; + news_item_add_to_queue(NEWS_ITEM_PEEPS, STR_PEEPS_DISLIKE_LITTER, 26); + } + + if (warning_throttle[4]) + --warning_throttle[4]; + else if (disgust_counter >= PEEP_DISGUST_WARNING_THRESHOLD && disgust_counter >= guests_in_park / 32) { + warning_throttle[4] = 4; + news_item_add_to_queue(NEWS_ITEM_PEEPS, STR_PEEPS_DISGUSTED_BY_PATHS, 31); + } + + if (warning_throttle[5]) + --warning_throttle[5]; + else if (vandalism_counter >= PEEP_VANDALISM_WARNING_THRESHOLD && vandalism_counter >= guests_in_park / 32) { + warning_throttle[5] = 4; + news_item_add_to_queue(NEWS_ITEM_PEEPS, STR_PEEPS_DISLIKE_VANDALISM, 33); + } + + if (warning_throttle[6]) + --warning_throttle[6]; + else if (noexit_counter >= PEEP_NOEXIT_WARNING_THRESHOLD) { + warning_throttle[6] = 4; + news_item_add_to_queue(NEWS_ITEM_PEEPS, STR_PEEPS_GETTING_LOST_OR_STUCK, 27); + } else if (lost_counter >= PEEP_LOST_WARNING_THRESHOLD) { + warning_throttle[6] = 4; + news_item_add_to_queue(NEWS_ITEM_PEEPS, STR_PEEPS_GETTING_LOST_OR_STUCK, 16); + } +} diff --git a/src/peep.h b/src/peep.h index fb5b009194..0b54db7988 100644 --- a/src/peep.h +++ b/src/peep.h @@ -25,6 +25,17 @@ #define PEEP_MAX_THOUGHTS 5 +#define PEEP_HUNGER_WARNING_THRESHOLD 25 +#define PEEP_THIRST_WARNING_THRESHOLD 25 +#define PEEP_BATHROOM_WARNING_THRESHOLD 28 +#define PEEP_LITTER_WARNING_THRESHOLD 23 +#define PEEP_DISGUST_WARNING_THRESHOLD 22 +#define PEEP_VANDALISM_WARNING_THRESHOLD 15 +#define PEEP_NOEXIT_WARNING_THRESHOLD 8 +#define PEEP_LOST_WARNING_THRESHOLD 8 + + + enum PEEP_TYPE { PEEP_TYPE_GUEST, PEEP_TYPE_STAFF @@ -363,7 +374,8 @@ typedef struct { sint32 time_in_park; // 0xA9 uint8 pad_AD[0x3]; rct_peep_thought thoughts[PEEP_MAX_THOUGHTS]; // 0xB0 - uint16 pad_C4; + uint8 pad_C4; + uint8 var_C5; uint8 var_C6; uint8 photo1_ride_ref; // 0xC7 uint32 flags; // 0xC8 @@ -387,5 +399,6 @@ typedef struct { int peep_get_staff_count(); void peep_update_all(); +void peep_problem_warnings_update(); #endif diff --git a/src/scenario.c b/src/scenario.c index b283c9e767..db4ee7bd54 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -873,7 +873,7 @@ void scenario_update() finance_pay_research(); finance_pay_interest(); scenario_marketing_update(); - RCT2_CALLPROC_EBPSAFE(0x0069BF41); // peep needs update and warnings + peep_problem_warnings_update(); RCT2_CALLPROC_EBPSAFE(0x006B7A5E); // check ride reachability RCT2_CALLPROC_EBPSAFE(0x006AC916); // ride update favourited diff --git a/src/strings.h b/src/strings.h index 232d0b4068..83bb0feae4 100644 --- a/src/strings.h +++ b/src/strings.h @@ -415,6 +415,14 @@ enum { STR_SHOW_GUESTS_ON_MAP_TIP = 2803, STR_SHOW_MAP_TIP = 2805, + STR_PEEPS_DISGUSTED_BY_PATHS = 2806, + STR_PEEPS_DISLIKE_LITTER = 2807, + STR_PEEPS_DISLIKE_VANDALISM = 2808, + STR_PEEPS_ARE_HUNGRY = 2809, + STR_PEEPS_ARE_THIRSTY = 2810, + STR_PEEPS_CANT_FIND_BATHROOM = 2811, + STR_PEEPS_GETTING_LOST_OR_STUCK = 2812, + STR_ENTRANCE_FEE_TOO_HI = 2813, STR_AWARD_MOST_UNTIDY = 2814, From 840c76b68e3c18923ecaa15b8382dfe011a4363b Mon Sep 17 00:00:00 2001 From: lnz Date: Wed, 7 May 2014 16:28:42 +0200 Subject: [PATCH 2/2] Fix month not changing bug and wage cost bug. --- src/finance.c | 6 +++--- src/scenario.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/finance.c b/src/finance.c index 37c4a14d60..2f6130d8be 100644 --- a/src/finance.c +++ b/src/finance.c @@ -25,9 +25,9 @@ #include "peep.h" #include "window.h" - +// monthly cost const int wage_table[4] = { 500, 800, 600, 550 }; -const int research_cost_table[4] = { 0, 1000, 2000, 4000 }; // monthly cost +const int research_cost_table[4] = { 0, 1000, 2000, 4000 }; /** * @@ -67,7 +67,7 @@ void finance_pay_wages() for (sprite_idx = RCT2_GLOBAL(RCT2_ADDRESS_SPRITES_START_PEEP, uint16); sprite_idx != SPRITE_INDEX_NULL; sprite_idx = peep->next) { peep = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[sprite_idx].peep); if (peep->type == PEEP_TYPE_STAFF) - finance_payment(wage_table[peep->staff_type], RCT_EXPENDITURE_TYPE_WAGES); + finance_payment(wage_table[peep->staff_type] / 4, RCT_EXPENDITURE_TYPE_WAGES); } } diff --git a/src/scenario.c b/src/scenario.c index db4ee7bd54..40733fac15 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -898,7 +898,7 @@ void scenario_update() } RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16) = next_month_tick; - if (next_month_tick > 0x10000) { + if (next_month_tick >= 0x10000) { // month ends actions RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16)++; RCT2_GLOBAL(0x009A9804, uint32) |= 2;