diff --git a/src/openrct2-ui/WindowManager.cpp b/src/openrct2-ui/WindowManager.cpp index 69d646297f..edd6f12b19 100644 --- a/src/openrct2-ui/WindowManager.cpp +++ b/src/openrct2-ui/WindowManager.cpp @@ -207,9 +207,9 @@ public: switch (intent->GetWindowClass()) { case WC_PEEP: - return window_guest_open((rct_peep*)intent->GetPointerExtra(INTENT_EXTRA_PEEP)); + return window_guest_open((Peep*)intent->GetPointerExtra(INTENT_EXTRA_PEEP)); case WC_FIRE_PROMPT: - return window_staff_fire_prompt_open((rct_peep*)intent->GetPointerExtra(INTENT_EXTRA_PEEP)); + return window_staff_fire_prompt_open((Peep*)intent->GetPointerExtra(INTENT_EXTRA_PEEP)); case WC_INSTALL_TRACK: return window_install_track_open(intent->GetStringExtra(INTENT_EXTRA_PATH).c_str()); case WC_GUEST_LIST: diff --git a/src/openrct2-ui/interface/ViewportInteraction.cpp b/src/openrct2-ui/interface/ViewportInteraction.cpp index 8a6550ccaf..b0bf8c4fb3 100644 --- a/src/openrct2-ui/interface/ViewportInteraction.cpp +++ b/src/openrct2-ui/interface/ViewportInteraction.cpp @@ -41,7 +41,7 @@ static void viewport_interaction_remove_footpath_item(TileElement* tileElement, static void viewport_interaction_remove_park_wall(TileElement* tileElement, int32_t x, int32_t y); static void viewport_interaction_remove_large_scenery(TileElement* tileElement, int32_t x, int32_t y); static void viewport_interaction_remove_park_entrance(TileElement* tileElement, int32_t x, int32_t y); -static rct_peep* viewport_interaction_get_closest_peep(int32_t x, int32_t y, int32_t maxDistance); +static Peep* viewport_interaction_get_closest_peep(int32_t x, int32_t y, int32_t maxDistance); /** * @@ -581,13 +581,13 @@ static void viewport_interaction_remove_large_scenery(TileElement* tileElement, } } -static rct_peep* viewport_interaction_get_closest_peep(int32_t x, int32_t y, int32_t maxDistance) +static Peep* viewport_interaction_get_closest_peep(int32_t x, int32_t y, int32_t maxDistance) { int32_t distance, closestDistance; uint16_t spriteIndex; rct_window* w; rct_viewport* viewport; - rct_peep *peep, *closestPeep; + Peep *peep, *closestPeep; w = window_find_from_point(x, y); if (w == nullptr) diff --git a/src/openrct2-ui/windows/GameBottomToolbar.cpp b/src/openrct2-ui/windows/GameBottomToolbar.cpp index 9a7966e6d7..c50653b43c 100644 --- a/src/openrct2-ui/windows/GameBottomToolbar.cpp +++ b/src/openrct2-ui/windows/GameBottomToolbar.cpp @@ -607,7 +607,7 @@ static void window_game_bottom_toolbar_draw_news_item(rct_drawpixelinfo* dpi, rc break; } - rct_peep* peep = GET_PEEP(newsItem->Assoc); + Peep* peep = GET_PEEP(newsItem->Assoc); int32_t clip_x = 10, clip_y = 19; if (peep->type == PEEP_TYPE_STAFF && peep->staff_type == STAFF_TYPE_ENTERTAINER) diff --git a/src/openrct2-ui/windows/Guest.cpp b/src/openrct2-ui/windows/Guest.cpp index 4936441f45..a188c6417b 100644 --- a/src/openrct2-ui/windows/Guest.cpp +++ b/src/openrct2-ui/windows/Guest.cpp @@ -474,7 +474,7 @@ static constexpr const uint32_t window_guest_page_enabled_widgets[] = { * rct2: 0x006989E9 * */ -rct_window* window_guest_open(rct_peep* peep) +rct_window* window_guest_open(Peep* peep) { if (peep->type == PEEP_TYPE_STAFF) { @@ -530,7 +530,7 @@ rct_window* window_guest_open(rct_peep* peep) */ void window_guest_disable_widgets(rct_window* w) { - rct_peep* peep = &get_sprite(w->number)->peep; + Peep* peep = &get_sprite(w->number)->peep; uint64_t disabled_widgets = 0; if (peep_can_be_picked_up(peep)) @@ -604,7 +604,7 @@ void window_guest_overview_resize(rct_window* w) */ void window_guest_overview_mouse_up(rct_window* w, rct_widgetindex widgetIndex) { - rct_peep* peep = GET_PEEP(w->number); + Peep* peep = GET_PEEP(w->number); switch (widgetIndex) { @@ -709,7 +709,7 @@ void window_guest_viewport_init(rct_window* w) focus.sprite.sprite_id = w->number; - rct_peep* peep = GET_PEEP(w->number); + Peep* peep = GET_PEEP(w->number); if (peep->state == PEEP_STATE_PICKED) { @@ -839,7 +839,7 @@ static void window_guest_overview_tab_paint(rct_window* w, rct_drawpixelinfo* dp x = 14; y = 20; - rct_peep* peep = GET_PEEP(w->number); + Peep* peep = GET_PEEP(w->number); if (peep->type == PEEP_TYPE_STAFF && peep->staff_type == STAFF_TYPE_ENTERTAINER) y++; @@ -896,7 +896,7 @@ static void window_guest_stats_tab_paint(rct_window* w, rct_drawpixelinfo* dpi) int32_t x = widget->left + w->x; int32_t y = widget->top + w->y; - rct_peep* peep = GET_PEEP(w->number); + Peep* peep = GET_PEEP(w->number); int32_t image_id = get_peep_face_sprite_large(peep); if (w->page == WINDOW_GUEST_STATS) { @@ -1032,7 +1032,7 @@ void window_guest_overview_paint(rct_window* w, rct_drawpixelinfo* dpi) // Draw the centred label uint32_t argument1, argument2; - rct_peep* peep = GET_PEEP(w->number); + Peep* peep = GET_PEEP(w->number); get_arguments_from_action(peep, &argument1, &argument2); set_format_arg(0, uint32_t, argument1); set_format_arg(4, uint32_t, argument2); @@ -1095,7 +1095,7 @@ void window_guest_overview_invalidate(rct_window* w) | (1ULL << WIDX_TAB_6)); w->pressed_widgets |= 1ULL << (w->page + WIDX_TAB_1); - rct_peep* peep = GET_PEEP(w->number); + Peep* peep = GET_PEEP(w->number); set_format_arg(0, rct_string_id, peep->name_string_idx); set_format_arg(2, uint32_t, peep->id); @@ -1170,7 +1170,7 @@ void window_guest_overview_update(rct_window* w) int32_t random = util_rand() & 0xFFFF; if (random <= 0x2AAA) { - rct_peep* peep = GET_PEEP(w->number); + Peep* peep = GET_PEEP(w->number); peep_insert_new_thought(peep, PEEP_THOUGHT_TYPE_WATCHED, PEEP_THOUGHT_ITEM_NONE); } } @@ -1232,7 +1232,7 @@ void window_guest_overview_tool_update(rct_window* w, rct_widgetindex widgetInde w->picked_peep_frame = 0; } - rct_peep* peep; + Peep* peep; peep = GET_PEEP(w->number); uint32_t imageId = g_peep_animation_entries[peep->sprite_type].sprite_animation[PEEP_ACTION_SPRITE_TYPE_UI].base_image; @@ -1321,7 +1321,7 @@ void window_guest_unknown_05(rct_window* w) void window_guest_stats_update(rct_window* w) { w->frame_no++; - rct_peep* peep = GET_PEEP(w->number); + Peep* peep = GET_PEEP(w->number); peep->window_invalidate_flags &= ~PEEP_INVALIDATE_PEEP_STATS; window_invalidate(w); @@ -1341,7 +1341,7 @@ void window_guest_stats_invalidate(rct_window* w) w->pressed_widgets |= 1ULL << (w->page + WIDX_TAB_1); - rct_peep* peep = GET_PEEP(w->number); + Peep* peep = GET_PEEP(w->number); set_format_arg(0, rct_string_id, peep->name_string_idx); set_format_arg(2, uint32_t, peep->id); @@ -1405,7 +1405,7 @@ void window_guest_stats_paint(rct_window* w, rct_drawpixelinfo* dpi) window_guest_inventory_tab_paint(w, dpi); // ebx - rct_peep* peep = GET_PEEP(w->number); + Peep* peep = GET_PEEP(w->number); // Not sure why this is not stats widgets // cx @@ -1589,7 +1589,7 @@ void window_guest_rides_update(rct_window* w) widget_invalidate(w, WIDX_TAB_2); widget_invalidate(w, WIDX_TAB_3); - rct_peep* peep = GET_PEEP(w->number); + Peep* peep = GET_PEEP(w->number); // Every 2048 ticks do a full window_invalidate int32_t number_of_ticks = gScenarioTicks - peep->time_in_park; @@ -1697,7 +1697,7 @@ void window_guest_rides_invalidate(rct_window* w) w->pressed_widgets |= 1ULL << (w->page + WIDX_TAB_1); - rct_peep* peep = GET_PEEP(w->number); + Peep* peep = GET_PEEP(w->number); set_format_arg(0, uint16_t, peep->name_string_idx); set_format_arg(2, uint32_t, peep->id); @@ -1732,7 +1732,7 @@ void window_guest_rides_paint(rct_window* w, rct_drawpixelinfo* dpi) window_guest_thoughts_tab_paint(w, dpi); window_guest_inventory_tab_paint(w, dpi); - rct_peep* peep = GET_PEEP(w->number); + Peep* peep = GET_PEEP(w->number); // cx int32_t x = w->x + window_guest_rides_widgets[WIDX_PAGE_BACKGROUND].left + 2; @@ -1829,7 +1829,7 @@ void window_guest_finance_invalidate(rct_window* w) w->pressed_widgets |= 1ULL << (w->page + WIDX_TAB_1); - rct_peep* peep = GET_PEEP(w->number); + Peep* peep = GET_PEEP(w->number); set_format_arg(0, rct_string_id, peep->name_string_idx); set_format_arg(2, uint32_t, peep->id); @@ -1862,7 +1862,7 @@ void window_guest_finance_paint(rct_window* w, rct_drawpixelinfo* dpi) window_guest_thoughts_tab_paint(w, dpi); window_guest_inventory_tab_paint(w, dpi); - rct_peep* peep = GET_PEEP(w->number); + Peep* peep = GET_PEEP(w->number); // cx int32_t x = w->x + window_guest_finance_widgets[WIDX_PAGE_BACKGROUND].left + 4; @@ -1944,7 +1944,7 @@ void window_guest_finance_paint(rct_window* w, rct_drawpixelinfo* dpi) */ void window_guest_thoughts_resize(rct_window* w) { - rct_peep* peep = GET_PEEP(w->number); + Peep* peep = GET_PEEP(w->number); if (peep->window_invalidate_flags & PEEP_INVALIDATE_PEEP_THOUGHTS) { peep->window_invalidate_flags &= ~PEEP_INVALIDATE_PEEP_THOUGHTS; @@ -1980,7 +1980,7 @@ void window_guest_thoughts_invalidate(rct_window* w) w->pressed_widgets |= 1ULL << (w->page + WIDX_TAB_1); - rct_peep* peep = GET_PEEP(w->number); + Peep* peep = GET_PEEP(w->number); set_format_arg(0, rct_string_id, peep->name_string_idx); set_format_arg(2, uint32_t, peep->id); @@ -2013,7 +2013,7 @@ void window_guest_thoughts_paint(rct_window* w, rct_drawpixelinfo* dpi) window_guest_thoughts_tab_paint(w, dpi); window_guest_inventory_tab_paint(w, dpi); - rct_peep* peep = GET_PEEP(w->number); + Peep* peep = GET_PEEP(w->number); // cx int32_t x = w->x + window_guest_thoughts_widgets[WIDX_PAGE_BACKGROUND].left + 4; @@ -2048,7 +2048,7 @@ void window_guest_thoughts_paint(rct_window* w, rct_drawpixelinfo* dpi) */ void window_guest_inventory_resize(rct_window* w) { - rct_peep* peep = GET_PEEP(w->number); + Peep* peep = GET_PEEP(w->number); if (peep->window_invalidate_flags & PEEP_INVALIDATE_PEEP_INVENTORY) { peep->window_invalidate_flags &= ~PEEP_INVALIDATE_PEEP_INVENTORY; @@ -2084,7 +2084,7 @@ void window_guest_inventory_invalidate(rct_window* w) w->pressed_widgets |= 1ULL << (w->page + WIDX_TAB_1); - rct_peep* peep = GET_PEEP(w->number); + Peep* peep = GET_PEEP(w->number); set_format_arg(0, rct_string_id, peep->name_string_idx); set_format_arg(2, uint32_t, peep->id); @@ -2103,7 +2103,7 @@ void window_guest_inventory_invalidate(rct_window* w) window_align_tabs(w, WIDX_TAB_1, WIDX_TAB_6); } -static rct_string_id window_guest_inventory_format_item(rct_peep* peep, int32_t item) +static rct_string_id window_guest_inventory_format_item(Peep* peep, int32_t item) { Ride* ride; @@ -2192,33 +2192,35 @@ void window_guest_inventory_paint(rct_window* w, rct_drawpixelinfo* dpi) window_guest_thoughts_tab_paint(w, dpi); window_guest_inventory_tab_paint(w, dpi); - rct_peep* peep = GET_PEEP(w->number); - - rct_widget* pageBackgroundWidget = &window_guest_inventory_widgets[WIDX_PAGE_BACKGROUND]; - int32_t x = w->x + pageBackgroundWidget->left + 4; - int32_t y = w->y + pageBackgroundWidget->top + 2; - int32_t itemNameWidth = pageBackgroundWidget->right - pageBackgroundWidget->left - 8; - - int32_t maxY = w->y + w->height - 22; - int32_t numItems = 0; - - gfx_draw_string_left(dpi, STR_CARRYING, nullptr, COLOUR_BLACK, x, y); - y += 10; - - for (int32_t item = 0; item < SHOP_ITEM_COUNT; item++) + const auto guest = (GET_PEEP(w->number))->AsGuest(); + if (guest != nullptr) { - if (y >= maxY) - break; - if (!peep->HasItem(item)) - continue; + rct_widget* pageBackgroundWidget = &window_guest_inventory_widgets[WIDX_PAGE_BACKGROUND]; + int32_t x = w->x + pageBackgroundWidget->left + 4; + int32_t y = w->y + pageBackgroundWidget->top + 2; + int32_t itemNameWidth = pageBackgroundWidget->right - pageBackgroundWidget->left - 8; - rct_string_id stringId = window_guest_inventory_format_item(peep, item); - y += gfx_draw_string_left_wrapped(dpi, gCommonFormatArgs, x, y, itemNameWidth, stringId, COLOUR_BLACK); - numItems++; - } + int32_t maxY = w->y + w->height - 22; + int32_t numItems = 0; - if (numItems == 0) - { - gfx_draw_string_left(dpi, STR_NOTHING, nullptr, COLOUR_BLACK, x, y); + gfx_draw_string_left(dpi, STR_CARRYING, nullptr, COLOUR_BLACK, x, y); + y += 10; + + for (int32_t item = 0; item < SHOP_ITEM_COUNT; item++) + { + if (y >= maxY) + break; + if (!guest->HasItem(item)) + continue; + + rct_string_id stringId = window_guest_inventory_format_item(guest, item); + y += gfx_draw_string_left_wrapped(dpi, gCommonFormatArgs, x, y, itemNameWidth, stringId, COLOUR_BLACK); + numItems++; + } + + if (numItems == 0) + { + gfx_draw_string_left(dpi, STR_NOTHING, nullptr, COLOUR_BLACK, x, y); + } } } diff --git a/src/openrct2-ui/windows/GuestList.cpp b/src/openrct2-ui/windows/GuestList.cpp index db2b637816..997091c225 100644 --- a/src/openrct2-ui/windows/GuestList.cpp +++ b/src/openrct2-ui/windows/GuestList.cpp @@ -158,12 +158,12 @@ static uint8_t _window_guest_list_group_index[240]; static char _window_guest_list_filter_name[32]; -static int32_t window_guest_list_is_peep_in_filter(rct_peep* peep); +static int32_t window_guest_list_is_peep_in_filter(Peep* peep); static void window_guest_list_find_groups(); -static void get_arguments_from_peep(rct_peep* peep, uint32_t* argument_1, uint32_t* argument_2); +static void get_arguments_from_peep(Peep* peep, uint32_t* argument_1, uint32_t* argument_2); -static bool guest_should_be_visible(rct_peep* peep); +static bool guest_should_be_visible(Peep* peep); void window_guest_list_init_vars() { @@ -471,7 +471,7 @@ static void window_guest_list_update(rct_window* w) static void window_guest_list_scrollgetsize(rct_window* w, int32_t scrollIndex, int32_t* width, int32_t* height) { int32_t i, y, numGuests, spriteIndex; - rct_peep* peep; + Peep* peep; switch (_window_guest_list_selected_tab) { @@ -538,7 +538,7 @@ static void window_guest_list_scrollgetsize(rct_window* w, int32_t scrollIndex, static void window_guest_list_scrollmousedown(rct_window* w, int32_t scrollIndex, int32_t x, int32_t y) { int32_t i, spriteIndex; - rct_peep* peep; + Peep* peep; switch (_window_guest_list_selected_tab) { @@ -717,7 +717,7 @@ static void window_guest_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, { int32_t spriteIndex, numGuests, i, j, y; rct_string_id format; - rct_peep* peep; + Peep* peep; rct_peep_thought* thought; uint32_t argument_1, argument_2; @@ -863,7 +863,7 @@ static void window_guest_list_textinput(rct_window* w, rct_widgetindex widgetInd * returns 0 for in filter and 1 for not in filter * rct2: 0x0069B865 */ -static int32_t window_guest_list_is_peep_in_filter(rct_peep* peep) +static int32_t window_guest_list_is_peep_in_filter(Peep* peep) { char temp; @@ -893,7 +893,7 @@ static int32_t window_guest_list_is_peep_in_filter(rct_peep* peep) * argument_1 (0x013CE952) gCommonFormatArgs * argument_2 (0x013CE954) gCommonFormatArgs + 2 */ -static void get_arguments_from_peep(rct_peep* peep, uint32_t* argument_1, uint32_t* argument_2) +static void get_arguments_from_peep(Peep* peep, uint32_t* argument_1, uint32_t* argument_2) { switch (_window_guest_list_selected_view) { @@ -933,7 +933,7 @@ static void get_arguments_from_peep(rct_peep* peep, uint32_t* argument_1, uint32 static void window_guest_list_find_groups() { int32_t spriteIndex, spriteIndex2, groupIndex, faceIndex; - rct_peep *peep, *peep2; + Peep *peep, *peep2; uint32_t tick256 = floor2(gScenarioTicks, 256); if (_window_guest_list_selected_view == _window_guest_list_last_find_groups_selected_view) @@ -1061,7 +1061,7 @@ static void window_guest_list_find_groups() } } -static bool guest_should_be_visible(rct_peep* peep) +static bool guest_should_be_visible(Peep* peep) { if (_window_guest_list_tracking_only && !(peep->peep_flags & PEEP_FLAGS_TRACKING)) return false; diff --git a/src/openrct2-ui/windows/Map.cpp b/src/openrct2-ui/windows/Map.cpp index 196135951e..0b4b29c4e5 100644 --- a/src/openrct2-ui/windows/Map.cpp +++ b/src/openrct2-ui/windows/Map.cpp @@ -1042,7 +1042,7 @@ static MapCoordsXY window_map_transform_to_map_coords(CoordsXY c) */ static void window_map_paint_peep_overlay(rct_drawpixelinfo* dpi) { - rct_peep* peep; + Peep* peep; uint16_t spriteIndex; FOR_ALL_PEEPS (spriteIndex, peep) diff --git a/src/openrct2-ui/windows/News.cpp b/src/openrct2-ui/windows/News.cpp index 2d3b7bf509..e642ec077e 100644 --- a/src/openrct2-ui/windows/News.cpp +++ b/src/openrct2-ui/windows/News.cpp @@ -318,7 +318,7 @@ static void window_news_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32 break; } - rct_peep* peep = GET_PEEP(newsItem->Assoc); + Peep* peep = GET_PEEP(newsItem->Assoc); int32_t clip_x = 10, clip_y = 19; // If normal peep set sprite to normal (no food) diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index 9c0dfb1069..01d596c6b6 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -1714,7 +1714,7 @@ rct_window* window_ride_open_vehicle(rct_vehicle* vehicle) rct_window* w2 = window_find_by_number(WC_PEEP, peepSpriteIndex); if (w2 == nullptr) { - rct_peep* peep = &(get_sprite(peepSpriteIndex)->peep); + Peep* peep = &(get_sprite(peepSpriteIndex)->peep); auto intent = Intent(WC_PEEP); intent.putExtra(INTENT_EXTRA_PEEP, peep); context_open_intent(&intent); @@ -3758,7 +3758,7 @@ static void window_ride_operating_paint(rct_window* w, rct_drawpixelinfo* dpi) static void window_ride_locate_mechanic(rct_window* w) { Ride* ride; - rct_peep* mechanic; + Peep* mechanic; ride = get_ride(w->number); @@ -4176,14 +4176,14 @@ static void window_ride_maintenance_paint(rct_window* w, rct_drawpixelinfo* dpi) // Mechanic status if (ride->lifecycle_flags & RIDE_LIFECYCLE_BROKEN_DOWN) { - rct_peep* peep; - uint16_t spriteIndex; - switch (ride->mechanic_status) { case RIDE_MECHANIC_STATUS_CALLING: + { stringId = STR_NO_MECHANICS_ARE_HIRED_MESSAGE; + uint16_t spriteIndex; + Peep* peep; FOR_ALL_STAFF (spriteIndex, peep) { if (peep->staff_type == STAFF_TYPE_MECHANIC) @@ -4193,6 +4193,7 @@ static void window_ride_maintenance_paint(rct_window* w, rct_drawpixelinfo* dpi) } } break; + } case RIDE_MECHANIC_STATUS_HEADING: stringId = STR_MEHCANIC_IS_HEADING_FOR_THE_RIDE; break; @@ -4213,11 +4214,11 @@ static void window_ride_maintenance_paint(rct_window* w, rct_drawpixelinfo* dpi) } else { - rct_peep* mechanicSprite = &(get_sprite(ride->mechanic)->peep); - if (mechanicSprite->IsMechanic()) + auto peep = (&(get_sprite(ride->mechanic)->peep))->AsStaff(); + if (peep != nullptr && peep->IsMechanic()) { - set_format_arg(0, rct_string_id, mechanicSprite->name_string_idx); - set_format_arg(2, uint32_t, mechanicSprite->id); + set_format_arg(0, rct_string_id, peep->name_string_idx); + set_format_arg(2, uint32_t, peep->id); gfx_draw_string_left_wrapped(dpi, gCommonFormatArgs, x + 4, y, 280, stringId, COLOUR_BLACK); } } diff --git a/src/openrct2-ui/windows/Staff.cpp b/src/openrct2-ui/windows/Staff.cpp index d7434b58b3..c31fc30c34 100644 --- a/src/openrct2-ui/windows/Staff.cpp +++ b/src/openrct2-ui/windows/Staff.cpp @@ -308,7 +308,7 @@ static PatrolAreaValue _staffPatrolAreaPaintValue = PatrolAreaValue::NONE; * * rct2: 0x006BEE98 */ -rct_window* window_staff_open(rct_peep* peep) +rct_window* window_staff_open(Peep* peep) { rct_window* w = window_bring_to_front_by_number(WC_PEEP, peep->sprite_index); if (w == nullptr) @@ -351,7 +351,7 @@ rct_window* window_staff_open(rct_peep* peep) */ void window_staff_disable_widgets(rct_window* w) { - rct_peep* peep = &get_sprite(w->number)->peep; + Peep* peep = &get_sprite(w->number)->peep; uint64_t disabled_widgets = (1 << WIDX_TAB_4); if (peep->staff_type == STAFF_TYPE_SECURITY) @@ -444,7 +444,7 @@ void window_staff_set_page(rct_window* w, int32_t page) */ void window_staff_overview_mouseup(rct_window* w, rct_widgetindex widgetIndex) { - rct_peep* peep = GET_PEEP(w->number); + Peep* peep = GET_PEEP(w->number); switch (widgetIndex) { @@ -563,7 +563,7 @@ void window_staff_overview_mousedown(rct_window* w, rct_widgetindex widgetIndex, window_dropdown_show_text(x, y, extray, w->colours[1], 0, 2); gDropdownDefaultIndex = 0; - rct_peep* peep = GET_PEEP(w->number); + Peep* peep = GET_PEEP(w->number); // Disable clear patrol area if no area is set. if (!(gStaffModes[peep->staff_id] & 2)) @@ -586,7 +586,7 @@ void window_staff_overview_dropdown(rct_window* w, rct_widgetindex widgetIndex, // Clear patrol if (dropdownIndex == 1) { - rct_peep* peep = GET_PEEP(w->number); + Peep* peep = GET_PEEP(w->number); for (int32_t i = 0; i < STAFF_PATROL_AREA_SIZE; i++) { gStaffPatrolAreas[peep->staff_id * STAFF_PATROL_AREA_SIZE + i] = 0; @@ -629,7 +629,7 @@ void window_staff_overview_update(rct_window* w) */ static void window_staff_set_order(rct_window* w, int32_t order_id) { - rct_peep* peep = GET_PEEP(w->number); + Peep* peep = GET_PEEP(w->number); uint8_t newOrders = peep->staff_orders ^ (1 << order_id); auto staffSetOrdersAction = StaffSetOrdersAction(w->number, newOrders); @@ -735,7 +735,7 @@ void window_staff_stats_update(rct_window* w) w->frame_no++; widget_invalidate(w, WIDX_TAB_3); - rct_peep* peep = GET_PEEP(w->number); + Peep* peep = GET_PEEP(w->number); if (peep->window_invalidate_flags & PEEP_INVALIDATE_STAFF_STATS) { peep->window_invalidate_flags &= ~PEEP_INVALIDATE_STAFF_STATS; @@ -768,7 +768,7 @@ void window_staff_stats_invalidate(rct_window* w) w->pressed_widgets |= 1ULL << (w->page + WIDX_TAB_1); - rct_peep* peep = GET_PEEP(w->number); + Peep* peep = GET_PEEP(w->number); set_format_arg(0, rct_string_id, peep->name_string_idx); set_format_arg(2, uint32_t, peep->id); @@ -803,7 +803,7 @@ void window_staff_options_invalidate(rct_window* w) w->pressed_widgets |= 1ULL << (w->page + WIDX_TAB_1); - rct_peep* peep = GET_PEEP(w->number); + Peep* peep = GET_PEEP(w->number); set_format_arg(0, rct_string_id, peep->name_string_idx); set_format_arg(2, uint32_t, peep->id); @@ -881,7 +881,7 @@ void window_staff_overview_invalidate(rct_window* w) w->pressed_widgets |= 1ULL << (w->page + WIDX_TAB_1); - rct_peep* peep = GET_PEEP(w->number); + Peep* peep = GET_PEEP(w->number); set_format_arg(0, rct_string_id, peep->name_string_idx); set_format_arg(2, uint32_t, peep->id); @@ -946,7 +946,7 @@ void window_staff_overview_paint(rct_window* w, rct_drawpixelinfo* dpi) // Draw the centred label uint32_t argument1, argument2; - rct_peep* peep = GET_PEEP(w->number); + Peep* peep = GET_PEEP(w->number); get_arguments_from_action(peep, &argument1, &argument2); set_format_arg(0, uint32_t, argument1); set_format_arg(4, uint32_t, argument2); @@ -1028,7 +1028,7 @@ void window_staff_overview_tab_paint(rct_window* w, rct_drawpixelinfo* dpi) x = 14; y = 20; - rct_peep* peep = GET_PEEP(w->number); + Peep* peep = GET_PEEP(w->number); if (peep->type == PEEP_TYPE_STAFF && peep->staff_type == STAFF_TYPE_ENTERTAINER) y++; @@ -1095,7 +1095,7 @@ void window_staff_stats_paint(rct_window* w, rct_drawpixelinfo* dpi) window_staff_options_tab_paint(w, dpi); window_staff_stats_tab_paint(w, dpi); - rct_peep* peep = GET_PEEP(w->number); + Peep* peep = GET_PEEP(w->number); int32_t x = w->x + window_staff_stats_widgets[WIDX_RESIZE].left + 4; int32_t y = w->y + window_staff_stats_widgets[WIDX_RESIZE].top + 4; @@ -1172,7 +1172,7 @@ void window_staff_overview_tool_update(rct_window* w, rct_widgetindex widgetInde w->picked_peep_frame = 0; } - rct_peep* peep; + Peep* peep; peep = GET_PEEP(w->number); uint32_t imageId = g_peep_animation_entries[peep->sprite_type].sprite_animation[PEEP_ACTION_SPRITE_TYPE_UI].base_image; @@ -1213,7 +1213,7 @@ void window_staff_overview_tool_down(rct_window* w, rct_widgetindex widgetIndex, if (sprite == nullptr || sprite->IsPeep() == false) return; - rct_peep& peep = sprite->peep; + Peep& peep = sprite->peep; if (peep.type != PEEP_TYPE_STAFF) return; @@ -1253,7 +1253,7 @@ void window_staff_overview_tool_drag(rct_window* w, rct_widgetindex widgetIndex, if (sprite == nullptr || sprite->IsPeep() == false) return; - rct_peep& peep = sprite->peep; + Peep& peep = sprite->peep; if (peep.type != PEEP_TYPE_STAFF) return; @@ -1325,7 +1325,7 @@ void window_staff_viewport_init(rct_window* w) focus.sprite_id = w->number; - rct_peep* peep = GET_PEEP(w->number); + Peep* peep = GET_PEEP(w->number); if (peep->state == PEEP_STATE_PICKED) { @@ -1396,7 +1396,7 @@ void window_staff_options_mousedown(rct_window* w, rct_widgetindex widgetIndex, return; } - rct_peep* peep = GET_PEEP(w->number); + Peep* peep = GET_PEEP(w->number); int32_t checkedIndex = -1; // This will be moved below where Items Checked is when all // of dropdown related functions are finished. This prevents diff --git a/src/openrct2-ui/windows/StaffFirePrompt.cpp b/src/openrct2-ui/windows/StaffFirePrompt.cpp index 99feb9caf9..31acc4e44d 100644 --- a/src/openrct2-ui/windows/StaffFirePrompt.cpp +++ b/src/openrct2-ui/windows/StaffFirePrompt.cpp @@ -75,7 +75,7 @@ static rct_window_event_list window_staff_fire_events = { /** Based off of rct2: 0x6C0A77 */ -rct_window* window_staff_fire_prompt_open(rct_peep* peep) +rct_window* window_staff_fire_prompt_open(Peep* peep) { rct_window * w; @@ -103,7 +103,7 @@ rct_window* window_staff_fire_prompt_open(rct_peep* peep) */ static void window_staff_fire_mouseup(rct_window *w, rct_widgetindex widgetIndex) { - rct_peep* peep = &get_sprite(w->number)->peep; + Peep* peep = &get_sprite(w->number)->peep; switch (widgetIndex){ case WIDX_YES: @@ -123,7 +123,7 @@ static void window_staff_fire_paint(rct_window *w, rct_drawpixelinfo *dpi) { window_draw_widgets(w, dpi); - rct_peep* peep = &get_sprite(w->number)->peep; + Peep* peep = &get_sprite(w->number)->peep; set_format_arg(0, rct_string_id, peep->name_string_idx); set_format_arg(2, uint32_t, peep->id); diff --git a/src/openrct2-ui/windows/StaffList.cpp b/src/openrct2-ui/windows/StaffList.cpp index 6209db8fcf..d969fcb494 100644 --- a/src/openrct2-ui/windows/StaffList.cpp +++ b/src/openrct2-ui/windows/StaffList.cpp @@ -314,7 +314,7 @@ void window_staff_list_update(rct_window* w) if (window_find_by_class(WC_MAP) != nullptr) { int32_t spriteIndex; - rct_peep* peep; + Peep* peep; gWindowMapFlashingFlags |= (1 << 2); FOR_ALL_STAFF (spriteIndex, peep) { @@ -348,7 +348,7 @@ static void window_staff_list_tooldown(rct_window* w, rct_widgetindex widgetInde bool isPatrolAreaSet = staff_is_patrol_area_set(200 + selectedPeepType, x, y); uint16_t spriteIndex; - rct_peep *peep, *closestPeep = nullptr; + Peep *peep, *closestPeep = nullptr; int32_t closestPeepDistance = std::numeric_limits::max(); FOR_ALL_STAFF (spriteIndex, peep) { @@ -416,7 +416,7 @@ void window_staff_list_toolabort(rct_window* w, rct_widgetindex widgetIndex) void window_staff_list_scrollgetsize(rct_window* w, int32_t scrollIndex, int32_t* width, int32_t* height) { int32_t i, spriteIndex; - rct_peep* peep; + Peep* peep; uint16_t staffCount = 0; FOR_ALL_STAFF (spriteIndex, peep) @@ -454,7 +454,7 @@ void window_staff_list_scrollgetsize(rct_window* w, int32_t scrollIndex, int32_t void window_staff_list_scrollmousedown(rct_window* w, int32_t scrollIndex, int32_t x, int32_t y) { int32_t i, spriteIndex; - rct_peep* peep; + Peep* peep; i = y / SCROLLABLE_ROW_HEIGHT; FOR_ALL_STAFF (spriteIndex, peep) @@ -658,7 +658,7 @@ void window_staff_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32_ int32_t spriteIndex, y, i, staffOrderIcon_x, staffOrders, staffOrderSprite; uint32_t argument_1, argument_2; uint8_t selectedTab; - rct_peep* peep; + Peep* peep; gfx_fill_rect(dpi, dpi->x, dpi->y, dpi->x + dpi->width - 1, dpi->y + dpi->height - 1, ColourMapA[w->colours[1]].mid_light); diff --git a/src/openrct2-ui/windows/TitleCommandEditor.cpp b/src/openrct2-ui/windows/TitleCommandEditor.cpp index 64d008b274..b78bb9f9e7 100644 --- a/src/openrct2-ui/windows/TitleCommandEditor.cpp +++ b/src/openrct2-ui/windows/TitleCommandEditor.cpp @@ -622,7 +622,7 @@ static void window_title_command_editor_tool_down(rct_window* w, rct_widgetindex if (spriteIdentifier == SPRITE_IDENTIFIER_PEEP) { validSprite = true; - rct_peep* peep = GET_PEEP(spriteIndex); + Peep* peep = GET_PEEP(spriteIndex); format_string(command.SpriteName, USER_STRING_MAX_LENGTH, peep->name_string_idx, &peep->id); } else if (spriteIdentifier == SPRITE_IDENTIFIER_VEHICLE) diff --git a/src/openrct2-ui/windows/Window.h b/src/openrct2-ui/windows/Window.h index eda85c8358..85bfb918a5 100644 --- a/src/openrct2-ui/windows/Window.h +++ b/src/openrct2-ui/windows/Window.h @@ -16,7 +16,7 @@ using loadsave_callback = void (*)(int32_t result, const utf8* path); using scenarioselect_callback = void (*)(const utf8* path); -struct rct_peep; +struct Peep; struct TileElement; struct rct_vehicle; @@ -31,7 +31,7 @@ rct_window* window_editor_main_open(); rct_window* window_editor_objective_options_open(); rct_window* window_editor_scenario_options_open(); rct_window* window_footpath_open(); -rct_window* window_guest_open(rct_peep* peep); +rct_window* window_guest_open(Peep* peep); rct_window* window_land_open(); rct_window* window_land_rights_open(); rct_window* window_main_open(); @@ -48,7 +48,7 @@ rct_window* window_server_start_open(); rct_window* window_shortcut_change_open(int32_t selected_key); rct_window* window_shortcut_keys_open(); rct_window* window_staff_list_open(); -rct_window* window_staff_open(rct_peep* peep); +rct_window* window_staff_open(Peep* peep); rct_window* window_themes_open(); rct_window* window_title_exit_open(); rct_window* window_title_logo_open(); @@ -82,7 +82,7 @@ void window_guest_list_init_vars(); void window_guest_list_refresh_list(); rct_window* window_guest_list_open(); rct_window* window_guest_list_open_with_filter(int32_t type, int32_t index); -rct_window* window_staff_fire_prompt_open(rct_peep* peep); +rct_window* window_staff_fire_prompt_open(Peep* peep); void window_title_editor_open(int32_t tab); void window_title_command_editor_open(struct TitleSequence* sequence, int32_t command, bool insert); rct_window* window_scenarioselect_open(scenarioselect_callback callback, bool titleEditor); diff --git a/src/openrct2/Cheats.cpp b/src/openrct2/Cheats.cpp index 80e51d7860..a46c25fca9 100644 --- a/src/openrct2/Cheats.cpp +++ b/src/openrct2/Cheats.cpp @@ -280,10 +280,11 @@ static void cheat_generate_guests(int32_t count) static void cheat_set_guest_parameter(int32_t parameter, int32_t value) { int32_t spriteIndex; - rct_peep* peep; - - FOR_ALL_GUESTS (spriteIndex, peep) + Peep* p; + FOR_ALL_GUESTS (spriteIndex, p) { + auto peep = p->AsGuest(); + assert(peep != nullptr); switch (parameter) { case GUEST_PARAMETER_HAPPINESS: @@ -327,10 +328,11 @@ static void cheat_set_guest_parameter(int32_t parameter, int32_t value) static void cheat_give_all_guests(int32_t object) { int32_t spriteIndex; - rct_peep* peep; - - FOR_ALL_GUESTS (spriteIndex, peep) + Peep* p; + FOR_ALL_GUESTS (spriteIndex, p) { + auto peep = p->AsGuest(); + assert(peep != nullptr); switch (object) { case OBJECT_MONEY: @@ -356,7 +358,7 @@ static void cheat_give_all_guests(int32_t object) static void cheat_remove_all_guests() { - rct_peep* peep; + Peep* peep; rct_vehicle* vehicle; uint16_t spriteIndex, nextSpriteIndex; ride_id_t rideIndex; @@ -418,7 +420,7 @@ static void cheat_remove_all_guests() static void cheat_explode_guests() { int32_t sprite_index; - rct_peep* peep; + Peep* peep; FOR_ALL_GUESTS (sprite_index, peep) { @@ -432,7 +434,7 @@ static void cheat_explode_guests() static void cheat_set_staff_speed(uint8_t value) { uint16_t spriteIndex; - rct_peep* peep; + Peep* peep; FOR_ALL_STAFF (spriteIndex, peep) { diff --git a/src/openrct2/Game.cpp b/src/openrct2/Game.cpp index 3fd0fdd4ad..8d7e6dad6c 100644 --- a/src/openrct2/Game.cpp +++ b/src/openrct2/Game.cpp @@ -849,7 +849,7 @@ void game_convert_strings_to_rct2(rct_s6_data* s6) void game_fix_save_vars() { // Recalculates peep count after loading a save to fix corrupted files - rct_peep* peep; + Peep* peep; uint16_t spriteIndex; uint16_t peepCount = 0; FOR_ALL_GUESTS (spriteIndex, peep) @@ -863,7 +863,7 @@ void game_fix_save_vars() peep_sort(); // Peeps to remove have to be cached here, as removing them from within the loop breaks iteration - std::vector peepsToRemove; + std::vector peepsToRemove; // Fix possibly invalid field values FOR_ALL_GUESTS (spriteIndex, peep) diff --git a/src/openrct2/actions/GuestSetNameAction.hpp b/src/openrct2/actions/GuestSetNameAction.hpp index e2fceae83b..09dcbbbdec 100644 --- a/src/openrct2/actions/GuestSetNameAction.hpp +++ b/src/openrct2/actions/GuestSetNameAction.hpp @@ -62,7 +62,7 @@ public: GA_ERROR::INVALID_PARAMETERS, STR_CANT_NAME_GUEST, STR_ERR_INVALID_NAME_FOR_GUEST); } - rct_peep* peep = GET_PEEP(_spriteIndex); + Peep* peep = GET_PEEP(_spriteIndex); if (peep->type != PEEP_TYPE_GUEST) { log_warning("Invalid game command for sprite %u", _spriteIndex); @@ -91,7 +91,7 @@ public: return std::make_unique(GA_ERROR::UNKNOWN, STR_CANT_NAME_GUEST, gGameCommandErrorText); } - rct_peep* peep = GET_PEEP(_spriteIndex); + Peep* peep = GET_PEEP(_spriteIndex); if (peep->type != PEEP_TYPE_GUEST) { log_warning("Invalid game command for sprite %u", _spriteIndex); diff --git a/src/openrct2/actions/RideDemolishAction.hpp b/src/openrct2/actions/RideDemolishAction.hpp index 810b4f6c78..3d1a461b18 100644 --- a/src/openrct2/actions/RideDemolishAction.hpp +++ b/src/openrct2/actions/RideDemolishAction.hpp @@ -140,7 +140,7 @@ private: } uint16_t spriteIndex; - rct_peep* peep; + Peep* peep; FOR_ALL_GUESTS (spriteIndex, peep) { uint8_t ride_id_bit = _rideIndex % 8; diff --git a/src/openrct2/actions/StaffSetColourAction.hpp b/src/openrct2/actions/StaffSetColourAction.hpp index f56813f90d..1e30cb18fb 100644 --- a/src/openrct2/actions/StaffSetColourAction.hpp +++ b/src/openrct2/actions/StaffSetColourAction.hpp @@ -66,7 +66,7 @@ public: // Update each staff member's uniform int32_t spriteIndex; - rct_peep* peep; + Peep* peep; FOR_ALL_PEEPS (spriteIndex, peep) { if (peep->type == PEEP_TYPE_STAFF && peep->staff_type == _staffType) diff --git a/src/openrct2/actions/StaffSetCostumeAction.hpp b/src/openrct2/actions/StaffSetCostumeAction.hpp index 6fdc8b6432..17355bb762 100644 --- a/src/openrct2/actions/StaffSetCostumeAction.hpp +++ b/src/openrct2/actions/StaffSetCostumeAction.hpp @@ -73,7 +73,7 @@ public: return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_NONE); } - rct_peep* peep = GET_PEEP(_spriteIndex); + Peep* peep = GET_PEEP(_spriteIndex); if (peep->type != PEEP_TYPE_STAFF || peep->staff_type != STAFF_TYPE_ENTERTAINER) { log_warning("Invalid game command for sprite %u", _spriteIndex); @@ -91,7 +91,7 @@ public: GameActionResult::Ptr Execute() const override { - rct_peep* peep = GET_PEEP(_spriteIndex); + Peep* peep = GET_PEEP(_spriteIndex); auto spriteType = static_cast(_costume + 4); peep->sprite_type = spriteType; diff --git a/src/openrct2/actions/StaffSetNameAction.hpp b/src/openrct2/actions/StaffSetNameAction.hpp index e959da648b..d06538e992 100644 --- a/src/openrct2/actions/StaffSetNameAction.hpp +++ b/src/openrct2/actions/StaffSetNameAction.hpp @@ -63,7 +63,7 @@ public: return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_STAFF_ERROR_CANT_NAME_STAFF_MEMBER); } - rct_peep* peep = GET_PEEP(_spriteIndex); + Peep* peep = GET_PEEP(_spriteIndex); if (peep->type != PEEP_TYPE_STAFF) { log_warning("Invalid game command for sprite %u", _spriteIndex); @@ -95,7 +95,7 @@ public: GA_ERROR::UNKNOWN, STR_STAFF_ERROR_CANT_NAME_STAFF_MEMBER, gGameCommandErrorText); } - rct_peep* peep = GET_PEEP(_spriteIndex); + Peep* peep = GET_PEEP(_spriteIndex); if (peep->type != PEEP_TYPE_STAFF) { log_warning("Invalid game command for sprite %u", _spriteIndex); diff --git a/src/openrct2/actions/StaffSetOrdersAction.hpp b/src/openrct2/actions/StaffSetOrdersAction.hpp index cf3be4e085..06eab21379 100644 --- a/src/openrct2/actions/StaffSetOrdersAction.hpp +++ b/src/openrct2/actions/StaffSetOrdersAction.hpp @@ -53,7 +53,7 @@ public: return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_NONE); } - rct_peep* peep = GET_PEEP(_spriteIndex); + Peep* peep = GET_PEEP(_spriteIndex); if (peep->type != PEEP_TYPE_STAFF || (peep->staff_type != STAFF_TYPE_HANDYMAN && peep->staff_type != STAFF_TYPE_MECHANIC)) { @@ -66,7 +66,7 @@ public: GameActionResult::Ptr Execute() const override { - rct_peep* peep = GET_PEEP(_spriteIndex); + Peep* peep = GET_PEEP(_spriteIndex); peep->staff_orders = _ordersId; diff --git a/src/openrct2/interface/InteractiveConsole.cpp b/src/openrct2/interface/InteractiveConsole.cpp index 3c50c7b5fc..0c12365fc9 100644 --- a/src/openrct2/interface/InteractiveConsole.cpp +++ b/src/openrct2/interface/InteractiveConsole.cpp @@ -373,7 +373,7 @@ static int32_t cc_staff(InteractiveConsole& console, const arguments_t& argv) { if (argv[0] == "list") { - rct_peep* peep; + Peep* peep; int32_t i; FOR_ALL_STAFF (i, peep) { @@ -409,7 +409,7 @@ static int32_t cc_staff(InteractiveConsole& console, const arguments_t& argv) if (int_valid[0] && int_valid[1] && ((GET_PEEP(int_val[0])) != nullptr)) { - rct_peep* peep = GET_PEEP(int_val[0]); + Peep* peep = GET_PEEP(int_val[0]); peep->energy = int_val[1]; peep->energy_target = int_val[1]; @@ -421,7 +421,7 @@ static int32_t cc_staff(InteractiveConsole& console, const arguments_t& argv) bool int_valid[2] = { false }; int_val[0] = console_parse_int(argv[2], &int_valid[0]); int_val[1] = console_parse_int(argv[3], &int_valid[1]); - rct_peep* peep = nullptr; + Peep* peep = nullptr; if (!int_valid[0]) { console.WriteLineError("Invalid staff ID"); diff --git a/src/openrct2/interface/Viewport.cpp b/src/openrct2/interface/Viewport.cpp index d1a19a395d..ba56de8399 100644 --- a/src/openrct2/interface/Viewport.cpp +++ b/src/openrct2/interface/Viewport.cpp @@ -661,7 +661,7 @@ void viewport_update_smart_sprite_follow(rct_window* window) } else if (sprite->generic.sprite_identifier == SPRITE_IDENTIFIER_PEEP) { - rct_peep* peep = GET_PEEP(window->viewport_smart_follow_sprite); + Peep* peep = GET_PEEP(window->viewport_smart_follow_sprite); if (peep->type == PEEP_TYPE_GUEST) viewport_update_smart_guest_follow(window, peep); @@ -686,7 +686,7 @@ void viewport_update_smart_sprite_follow(rct_window* window) } } -void viewport_update_smart_guest_follow(rct_window* window, rct_peep* peep) +void viewport_update_smart_guest_follow(rct_window* window, Peep* peep) { union { @@ -748,7 +748,7 @@ void viewport_update_smart_guest_follow(rct_window* window, rct_peep* peep) window->viewport_target_sprite = window->viewport_focus_sprite.sprite_id; } -void viewport_update_smart_staff_follow(rct_window* window, rct_peep* peep) +void viewport_update_smart_staff_follow(rct_window* window, Peep* peep) { sprite_focus focus = {}; diff --git a/src/openrct2/interface/Viewport.h b/src/openrct2/interface/Viewport.h index 20fd725939..58c4054c59 100644 --- a/src/openrct2/interface/Viewport.h +++ b/src/openrct2/interface/Viewport.h @@ -18,7 +18,7 @@ struct paint_session; struct paint_struct; struct rct_drawpixelinfo; -struct rct_peep; +struct Peep; struct TileElement; struct rct_vehicle; struct rct_window; @@ -91,7 +91,7 @@ struct viewport_interaction_info { TileElement* tileElement; rct_sprite* sprite; - rct_peep* peep; + Peep* peep; rct_vehicle* vehicle; }; }; @@ -126,8 +126,8 @@ void viewport_create( void viewport_update_position(rct_window* window); void viewport_update_sprite_follow(rct_window* window); void viewport_update_smart_sprite_follow(rct_window* window); -void viewport_update_smart_guest_follow(rct_window* window, rct_peep* peep); -void viewport_update_smart_staff_follow(rct_window* window, rct_peep* peep); +void viewport_update_smart_guest_follow(rct_window* window, Peep* peep); +void viewport_update_smart_staff_follow(rct_window* window, Peep* peep); void viewport_update_smart_vehicle_follow(rct_window* window); void viewport_render( rct_drawpixelinfo* dpi, rct_viewport* viewport, int32_t left, int32_t top, int32_t right, int32_t bottom, diff --git a/src/openrct2/management/Award.cpp b/src/openrct2/management/Award.cpp index 0761e7753f..550ca8cea7 100644 --- a/src/openrct2/management/Award.cpp +++ b/src/openrct2/management/Award.cpp @@ -74,7 +74,7 @@ bool award_is_positive(int32_t type) static bool award_is_deserved_most_untidy(int32_t activeAwardTypes) { uint16_t spriteIndex; - rct_peep* peep; + Peep* peep; int32_t negativeCount; if (activeAwardTypes & (1 << PARK_AWARD_MOST_BEAUTIFUL)) @@ -108,7 +108,7 @@ static bool award_is_deserved_most_untidy(int32_t activeAwardTypes) static bool award_is_deserved_most_tidy(int32_t activeAwardTypes) { uint16_t spriteIndex; - rct_peep* peep; + Peep* peep; int32_t positiveCount; int32_t negativeCount; @@ -198,7 +198,7 @@ static bool award_is_deserved_best_value(int32_t activeAwardTypes) static bool award_is_deserved_most_beautiful(int32_t activeAwardTypes) { uint16_t spriteIndex; - rct_peep* peep; + Peep* peep; int32_t positiveCount; int32_t negativeCount; @@ -252,7 +252,7 @@ static bool award_is_deserved_safest([[maybe_unused]] int32_t activeAwardTypes) { int32_t i, peepsWhoDislikeVandalism; uint16_t spriteIndex; - rct_peep* peep; + Peep* peep; Ride* ride; peepsWhoDislikeVandalism = 0; @@ -281,7 +281,7 @@ static bool award_is_deserved_safest([[maybe_unused]] int32_t activeAwardTypes) static bool award_is_deserved_best_staff(int32_t activeAwardTypes) { uint16_t spriteIndex; - rct_peep* peep; + Peep* peep; int32_t peepCount, staffCount; int32_t staffTypeFlags; @@ -315,7 +315,7 @@ static bool award_is_deserved_best_food(int32_t activeAwardTypes) Ride* ride; rct_ride_entry* rideEntry; uint16_t spriteIndex; - rct_peep* peep; + Peep* peep; if (activeAwardTypes & (1 << PARK_AWARD_WORST_FOOD)) return false; @@ -368,7 +368,7 @@ static bool award_is_deserved_worst_food(int32_t activeAwardTypes) Ride* ride; rct_ride_entry* rideEntry; uint16_t spriteIndex; - rct_peep* peep; + Peep* peep; if (activeAwardTypes & (1 << PARK_AWARD_BEST_FOOD)) return false; @@ -419,7 +419,7 @@ static bool award_is_deserved_best_restrooms([[maybe_unused]] int32_t activeAwar uint32_t i, numRestrooms, guestsWhoNeedRestroom; Ride* ride; uint16_t spriteIndex; - rct_peep* peep; + Peep* peep; // Count open restrooms numRestrooms = 0; @@ -582,7 +582,7 @@ static bool award_is_deserved_most_confusing_layout([[maybe_unused]] int32_t act { uint32_t peepsCounted, peepsLost; uint16_t spriteIndex; - rct_peep* peep; + Peep* peep; peepsCounted = 0; peepsLost = 0; diff --git a/src/openrct2/management/Finance.cpp b/src/openrct2/management/Finance.cpp index 130bd1ab1c..b801c63bf7 100644 --- a/src/openrct2/management/Finance.cpp +++ b/src/openrct2/management/Finance.cpp @@ -126,7 +126,7 @@ void finance_payment(money32 amount, rct_expenditure_type type) */ void finance_pay_wages() { - rct_peep* peep; + Peep* peep; uint16_t spriteIndex; if (gParkFlags & PARK_FLAGS_NO_MONEY) @@ -273,7 +273,7 @@ void finance_update_daily_profit() { // Staff costs uint16_t sprite_index; - rct_peep* peep; + Peep* peep; FOR_ALL_STAFF (sprite_index, peep) { diff --git a/src/openrct2/management/Marketing.cpp b/src/openrct2/management/Marketing.cpp index c4d44b97b3..733b924834 100644 --- a/src/openrct2/management/Marketing.cpp +++ b/src/openrct2/management/Marketing.cpp @@ -123,7 +123,7 @@ void marketing_update() window_invalidate_by_class(WC_FINANCES); } -void marketing_set_guest_campaign(rct_peep* peep, int32_t campaignType) +void marketing_set_guest_campaign(Peep* peep, int32_t campaignType) { auto campaign = marketing_get_campaign(campaignType); if (campaign == nullptr) diff --git a/src/openrct2/management/Marketing.h b/src/openrct2/management/Marketing.h index 84fe9a7225..dd082abfb7 100644 --- a/src/openrct2/management/Marketing.h +++ b/src/openrct2/management/Marketing.h @@ -61,7 +61,7 @@ extern std::vector gMarketingCampaigns; uint16_t marketing_get_campaign_guest_generation_probability(int32_t campaign); void marketing_update(); -void marketing_set_guest_campaign(rct_peep* peep, int32_t campaign); +void marketing_set_guest_campaign(Peep* peep, int32_t campaign); bool marketing_is_campaign_type_applicable(int32_t campaignType); MarketingCampaign* marketing_get_campaign(int32_t campaignType); void marketing_new_campaign(const MarketingCampaign& campaign); diff --git a/src/openrct2/management/NewsItem.cpp b/src/openrct2/management/NewsItem.cpp index f0a7233612..82c4acaed6 100644 --- a/src/openrct2/management/NewsItem.cpp +++ b/src/openrct2/management/NewsItem.cpp @@ -209,7 +209,7 @@ static int32_t news_item_get_new_history_slot() void news_item_get_subject_location(int32_t type, int32_t subject, int32_t* x, int32_t* y, int32_t* z) { Ride* ride; - rct_peep* peep; + Peep* peep; rct_vehicle* vehicle; switch (type) @@ -329,7 +329,7 @@ NewsItem* news_item_add_to_queue_raw(uint8_t type, const utf8* text, uint32_t as */ void news_item_open_subject(int32_t type, int32_t subject) { - rct_peep* peep; + Peep* peep; rct_window* window; switch (type) diff --git a/src/openrct2/network/Network.cpp b/src/openrct2/network/Network.cpp index a5260212cf..791044623d 100644 --- a/src/openrct2/network/Network.cpp +++ b/src/openrct2/network/Network.cpp @@ -34,7 +34,7 @@ #define NETWORK_STREAM_VERSION "49" #define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION -static rct_peep* _pickup_peep = nullptr; +static Peep* _pickup_peep = nullptr; static int32_t _pickup_peep_old_x = LOCATION_NULL; #ifndef DISABLE_NETWORK @@ -2032,7 +2032,7 @@ void Network::RemoveClient(std::unique_ptr& connection) } chat_history_add(text); - rct_peep* pickup_peep = network_get_pickup_peep(connection_player->Id); + Peep* pickup_peep = network_get_pickup_peep(connection_player->Id); if (pickup_peep) { game_command_playerid = connection_player->Id; @@ -3664,7 +3664,7 @@ int32_t network_can_perform_command(uint32_t groupindex, int32_t index) return gNetwork.group_list[groupindex]->CanPerformCommand(index); } -void network_set_pickup_peep(uint8_t playerid, rct_peep* peep) +void network_set_pickup_peep(uint8_t playerid, Peep* peep) { if (gNetwork.GetMode() == NETWORK_MODE_NONE) { @@ -3680,7 +3680,7 @@ void network_set_pickup_peep(uint8_t playerid, rct_peep* peep) } } -rct_peep* network_get_pickup_peep(uint8_t playerid) +Peep* network_get_pickup_peep(uint8_t playerid) { if (gNetwork.GetMode() == NETWORK_MODE_NONE) { @@ -4049,11 +4049,11 @@ int32_t network_can_perform_command(uint32_t groupindex, int32_t index) { return 0; } -void network_set_pickup_peep(uint8_t playerid, rct_peep* peep) +void network_set_pickup_peep(uint8_t playerid, Peep* peep) { _pickup_peep = peep; } -rct_peep* network_get_pickup_peep(uint8_t playerid) +Peep* network_get_pickup_peep(uint8_t playerid) { return _pickup_peep; } diff --git a/src/openrct2/network/NetworkPlayer.h b/src/openrct2/network/NetworkPlayer.h index 67646905f5..355198fdea 100644 --- a/src/openrct2/network/NetworkPlayer.h +++ b/src/openrct2/network/NetworkPlayer.h @@ -31,7 +31,7 @@ public: int32_t LastAction = -999; uint32_t LastActionTime = 0; LocationXYZ16 LastActionCoord = {}; - rct_peep* PickupPeep = nullptr; + Peep* PickupPeep = nullptr; int32_t PickupPeepOldX = LOCATION_NULL; std::string KeyHash; uint32_t LastDemolishRideTime = 0; diff --git a/src/openrct2/network/Twitch.cpp b/src/openrct2/network/Twitch.cpp index 5aa1ff810c..b3c5644737 100644 --- a/src/openrct2/network/Twitch.cpp +++ b/src/openrct2/network/Twitch.cpp @@ -418,7 +418,7 @@ namespace Twitch { // Check what followers are already in the park uint16_t spriteIndex; - rct_peep* peep; + Peep* peep; FOR_ALL_GUESTS (spriteIndex, peep) { if (is_user_string_id(peep->name_string_idx)) diff --git a/src/openrct2/network/network.h b/src/openrct2/network/network.h index e488790105..b1f6a75a3e 100644 --- a/src/openrct2/network/network.h +++ b/src/openrct2/network/network.h @@ -20,7 +20,7 @@ #include struct GameAction; -struct rct_peep; +struct Peep; struct LocationXYZ16; namespace OpenRCT2 @@ -75,8 +75,8 @@ int32_t network_get_num_actions(); rct_string_id network_get_action_name_string_id(uint32_t index); int32_t network_can_perform_action(uint32_t groupindex, uint32_t index); int32_t network_can_perform_command(uint32_t groupindex, int32_t index); -void network_set_pickup_peep(uint8_t playerid, rct_peep* peep); -rct_peep* network_get_pickup_peep(uint8_t playerid); +void network_set_pickup_peep(uint8_t playerid, Peep* peep); +Peep* network_get_pickup_peep(uint8_t playerid); void network_set_pickup_peep_old_x(uint8_t playerid, int32_t x); int32_t network_get_pickup_peep_old_x(uint8_t playerid); diff --git a/src/openrct2/paint/sprite/Paint.Peep.cpp b/src/openrct2/paint/sprite/Paint.Peep.cpp index cb9b0a70f6..78399c376f 100644 --- a/src/openrct2/paint/sprite/Paint.Peep.cpp +++ b/src/openrct2/paint/sprite/Paint.Peep.cpp @@ -19,7 +19,7 @@ * * rct2: 0x0068F0FB */ -void peep_paint(paint_session* session, const rct_peep* peep, int32_t imageDirection) +void peep_paint(paint_session* session, const Peep* peep, int32_t imageDirection) { #ifdef __ENABLE_LIGHTFX__ if (lightfx_is_available()) diff --git a/src/openrct2/paint/sprite/Paint.Sprite.cpp b/src/openrct2/paint/sprite/Paint.Sprite.cpp index b311e68228..234b6c054e 100644 --- a/src/openrct2/paint/sprite/Paint.Sprite.cpp +++ b/src/openrct2/paint/sprite/Paint.Sprite.cpp @@ -57,7 +57,7 @@ void sprite_paint_setup(paint_session* session, const uint16_t x, const uint16_t { if (spr->generic.sprite_identifier == SPRITE_IDENTIFIER_PEEP) { - rct_peep* peep = (rct_peep*)spr; + Peep* peep = (Peep*)spr; if (!(peep->type == PEEP_TYPE_STAFF && peep->staff_type == STAFF_TYPE_HANDYMAN)) { continue; @@ -113,7 +113,7 @@ void sprite_paint_setup(paint_session* session, const uint16_t x, const uint16_t vehicle_paint(session, (rct_vehicle*)spr, image_direction); break; case SPRITE_IDENTIFIER_PEEP: - peep_paint(session, (rct_peep*)spr, image_direction); + peep_paint(session, (Peep*)spr, image_direction); break; case SPRITE_IDENTIFIER_MISC: misc_paint(session, spr, image_direction); diff --git a/src/openrct2/paint/sprite/Paint.Sprite.h b/src/openrct2/paint/sprite/Paint.Sprite.h index 9c62008fc8..9d28015414 100644 --- a/src/openrct2/paint/sprite/Paint.Sprite.h +++ b/src/openrct2/paint/sprite/Paint.Sprite.h @@ -19,7 +19,7 @@ void sprite_paint_setup(paint_session* session, const uint16_t x, const uint16_t void misc_paint(paint_session* session, const rct_sprite* misc, int32_t imageDirection); void litter_paint(paint_session* session, const rct_litter* litter, int32_t imageDirection); -void peep_paint(paint_session* session, const rct_peep* peep, int32_t imageDirection); +void peep_paint(paint_session* session, const Peep* peep, int32_t imageDirection); extern const uint32_t vehicle_particle_base_sprites[5]; diff --git a/src/openrct2/paint/tile_element/Paint.Path.cpp b/src/openrct2/paint/tile_element/Paint.Path.cpp index 49e4ee227a..d1702af8b8 100644 --- a/src/openrct2/paint/tile_element/Paint.Path.cpp +++ b/src/openrct2/paint/tile_element/Paint.Path.cpp @@ -892,7 +892,7 @@ void path_paint(paint_session* session, uint16_t height, const TileElement* tile if (!is_staff_list) { - rct_peep* staff = GET_PEEP(staffIndex); + Peep* staff = GET_PEEP(staffIndex); if (!staff_is_patrol_area_set(staff->staff_id, x, y)) { patrolColour = COLOUR_GREY; diff --git a/src/openrct2/paint/tile_element/Paint.Surface.cpp b/src/openrct2/paint/tile_element/Paint.Surface.cpp index 41f456f0a2..243afdcd9b 100644 --- a/src/openrct2/paint/tile_element/Paint.Surface.cpp +++ b/src/openrct2/paint/tile_element/Paint.Surface.cpp @@ -1040,7 +1040,7 @@ void surface_paint(paint_session* session, uint8_t direction, uint16_t height, c if (!is_staff_list) { - rct_peep* staff = GET_PEEP(staffIndex); + Peep* staff = GET_PEEP(staffIndex); if (!staff_is_patrol_area_set(staff->staff_id, x, y)) { patrolColour = COLOUR_GREY; diff --git a/src/openrct2/peep/Guest.cpp b/src/openrct2/peep/Guest.cpp index a1abb84da8..540c360155 100644 --- a/src/openrct2/peep/Guest.cpp +++ b/src/openrct2/peep/Guest.cpp @@ -349,27 +349,27 @@ static constexpr const ride_rating NauseaMinimumThresholds[] = { }; // clang-format on -static bool peep_has_voucher_for_free_ride(rct_peep* peep, Ride* ride); -static void peep_ride_is_too_intense(rct_peep* peep, Ride* ride, bool peepAtRide); -static void peep_reset_ride_heading(rct_peep* peep); -static void peep_tried_to_enter_full_queue(rct_peep* peep, Ride* ride); -static int16_t peep_calculate_ride_satisfaction(rct_peep* peep, Ride* ride); -static void peep_update_favourite_ride(rct_peep* peep, Ride* ride); -static int16_t peep_calculate_ride_value_satisfaction(rct_peep* peep, Ride* ride); -static int16_t peep_calculate_ride_intensity_nausea_satisfaction(rct_peep* peep, Ride* ride); -static void peep_update_ride_nausea_growth(rct_peep* peep, Ride* ride); -static bool peep_should_go_on_ride_again(rct_peep* peep, Ride* ride); -static bool peep_should_preferred_intensity_increase(rct_peep* peep); -static bool peep_really_liked_ride(rct_peep* peep, Ride* ride); +static bool peep_has_voucher_for_free_ride(Peep* peep, Ride* ride); +static void peep_ride_is_too_intense(Guest* peep, Ride* ride, bool peepAtRide); +static void peep_reset_ride_heading(Peep* peep); +static void peep_tried_to_enter_full_queue(Peep* peep, Ride* ride); +static int16_t peep_calculate_ride_satisfaction(Guest* peep, Ride* ride); +static void peep_update_favourite_ride(Peep* peep, Ride* ride); +static int16_t peep_calculate_ride_value_satisfaction(Peep* peep, Ride* ride); +static int16_t peep_calculate_ride_intensity_nausea_satisfaction(Peep* peep, Ride* ride); +static void peep_update_ride_nausea_growth(Peep* peep, Ride* ride); +static bool peep_should_go_on_ride_again(Peep* peep, Ride* ride); +static bool peep_should_preferred_intensity_increase(Peep* peep); +static bool peep_really_liked_ride(Peep* peep, Ride* ride); static PeepThoughtType peep_assess_surroundings(int16_t centre_x, int16_t centre_y, int16_t centre_z); -static void peep_update_hunger(rct_peep* peep); -static void peep_decide_whether_to_leave_park(rct_peep* peep); -static void peep_leave_park(rct_peep* peep); -static void peep_head_for_nearest_ride_type(rct_peep* peep, int32_t rideType); -static void peep_head_for_nearest_ride_with_flags(rct_peep* peep, int32_t rideTypeFlags); -bool loc_690FD0(rct_peep* peep, uint8_t* rideToView, uint8_t* rideSeatToView, TileElement* tileElement); +static void peep_update_hunger(Peep* peep); +static void peep_decide_whether_to_leave_park(Peep* peep); +static void peep_leave_park(Peep* peep); +static void peep_head_for_nearest_ride_type(Guest* peep, int32_t rideType); +static void peep_head_for_nearest_ride_with_flags(Guest* peep, int32_t rideTypeFlags); +bool loc_690FD0(Peep* peep, uint8_t* rideToView, uint8_t* rideSeatToView, TileElement* tileElement); -void rct_peep::Tick128UpdateGuest(int32_t index) +void Guest::Tick128UpdateGuest(int32_t index) { if ((uint32_t)(index & 0x1FF) == (gCurrentTicks & 0x1FF)) { @@ -867,7 +867,7 @@ void rct_peep::Tick128UpdateGuest(int32_t index) * * rct2: 0x00691677 */ -void rct_peep::TryGetUpFromSitting() +void Guest::TryGetUpFromSitting() { // Eats all food first if (HasFood()) @@ -890,7 +890,7 @@ void rct_peep::TryGetUpFromSitting() * * rct2: 0x0069152B */ -void rct_peep::UpdateSitting() +void Guest::UpdateSitting() { if (sub_state == PEEP_SITTING_TRYING_TO_SIT) { @@ -999,42 +999,7 @@ void rct_peep::UpdateSitting() } } -/** - * - * rct2: 0x006966A9 - */ -void rct_peep::RemoveFromQueue() -{ - Ride* ride = get_ride(current_ride); - - auto& station = ride->stations[current_ride_station]; - // Make sure we don't underflow, building while paused might reset it to 0 where peeps have - // not yet left the queue. - if (station.QueueLength > 0) - { - station.QueueLength--; - } - - if (sprite_index == station.LastPeepInQueue) - { - station.LastPeepInQueue = next_in_queue; - return; - } - - auto spriteId = station.LastPeepInQueue; - while (spriteId != SPRITE_INDEX_NULL) - { - rct_peep* other_peep = GET_PEEP(spriteId); - if (sprite_index == other_peep->next_in_queue) - { - other_peep->next_in_queue = next_in_queue; - return; - } - spriteId = other_peep->next_in_queue; - } -} - -bool rct_peep::HasItem(int32_t peepItem) const +bool Guest::HasItem(int32_t peepItem) const { if (peepItem < 32) { @@ -1046,7 +1011,7 @@ bool rct_peep::HasItem(int32_t peepItem) const } } -int32_t rct_peep::HasFoodStandardFlag() const +int32_t Guest::HasFoodStandardFlag() const { return item_standard_flags & (PEEP_ITEM_DRINK | PEEP_ITEM_BURGER | PEEP_ITEM_CHIPS | PEEP_ITEM_ICE_CREAM | PEEP_ITEM_CANDYFLOSS | PEEP_ITEM_PIZZA @@ -1054,7 +1019,7 @@ int32_t rct_peep::HasFoodStandardFlag() const | PEEP_ITEM_COFFEE | PEEP_ITEM_CHICKEN | PEEP_ITEM_LEMONADE); } -int32_t rct_peep::HasFoodExtraFlag() const +int32_t Guest::HasFoodExtraFlag() const { return item_extra_flags & (PEEP_ITEM_PRETZEL | PEEP_ITEM_CHOCOLATE | PEEP_ITEM_ICED_TEA | PEEP_ITEM_FUNNEL_CAKE | PEEP_ITEM_BEEF_NOODLES @@ -1063,12 +1028,12 @@ int32_t rct_peep::HasFoodExtraFlag() const | PEEP_ITEM_ROAST_SAUSAGE); } -bool rct_peep::HasDrinkStandardFlag() const +bool Guest::HasDrinkStandardFlag() const { return item_standard_flags & (PEEP_ITEM_DRINK | PEEP_ITEM_COFFEE | PEEP_ITEM_LEMONADE); } -bool rct_peep::HasDrinkExtraFlag() const +bool Guest::HasDrinkExtraFlag() const { return item_extra_flags & (PEEP_ITEM_CHOCOLATE | PEEP_ITEM_ICED_TEA | PEEP_ITEM_FRUIT_JUICE | PEEP_ITEM_SOYBEAN_MILK | PEEP_ITEM_SU_JONGKWA); @@ -1078,25 +1043,25 @@ bool rct_peep::HasDrinkExtraFlag() const * To simplify check of NOT(0x12BA3C0 and 0x118F48) * returns 0 on no food. */ -bool rct_peep::HasDrink() const +bool Guest::HasDrink() const { return HasDrinkStandardFlag() || HasDrinkExtraFlag(); } -int32_t rct_peep::HasEmptyContainerStandardFlag() const +int32_t Guest::HasEmptyContainerStandardFlag() const { return item_standard_flags & (PEEP_ITEM_EMPTY_CAN | PEEP_ITEM_EMPTY_BURGER_BOX | PEEP_ITEM_EMPTY_CUP | PEEP_ITEM_RUBBISH | PEEP_ITEM_EMPTY_BOX | PEEP_ITEM_EMPTY_BOTTLE); } -int32_t rct_peep::HasEmptyContainerExtraFlag() const +int32_t Guest::HasEmptyContainerExtraFlag() const { return item_extra_flags & (PEEP_ITEM_EMPTY_BOWL_RED | PEEP_ITEM_EMPTY_DRINK_CARTON | PEEP_ITEM_EMPTY_JUICE_CUP | PEEP_ITEM_EMPTY_BOWL_BLUE); } -bool rct_peep::HasEmptyContainer() const +bool Guest::HasEmptyContainer() const { return HasEmptyContainerStandardFlag() || HasEmptyContainerExtraFlag(); } @@ -1106,7 +1071,7 @@ bool rct_peep::HasEmptyContainer() const * rct2: 0x69C308 * Check if lost. */ -void rct_peep::CheckIfLost() +void Guest::CheckIfLost() { if (!(peep_flags & PEEP_FLAGS_LOST)) { @@ -1132,7 +1097,7 @@ void rct_peep::CheckIfLost() * rct2: 0x69C26B * Check if cant find ride. */ -void rct_peep::CheckCantFindRide() +void Guest::CheckCantFindRide() { if (guest_heading_to_ride_id == RIDE_ID_NULL) return; @@ -1164,7 +1129,7 @@ void rct_peep::CheckCantFindRide() * rct2: 0x69C2D0 * Check if cant find exit. */ -void rct_peep::CheckCantFindExit() +void Guest::CheckCantFindExit() { if (!(peep_flags & PEEP_FLAGS_LEAVING_PARK)) return; @@ -1193,7 +1158,7 @@ void rct_peep::CheckCantFindExit() * * rct2: 0x0069AF1E */ -bool rct_peep::DecideAndBuyItem(Ride* ride, int32_t shopItem, money32 price) +bool Guest::DecideAndBuyItem(Ride* ride, int32_t shopItem, money32 price) { money32 itemValue; @@ -1465,7 +1430,7 @@ loc_69B221: * ride's satisfaction value. * rct2: 0x0069545B */ -void rct_peep::OnEnterRide(ride_id_t rideIndex) +void Guest::OnEnterRide(ride_id_t rideIndex) { Ride* ride = get_ride(rideIndex); @@ -1497,7 +1462,7 @@ void rct_peep::OnEnterRide(ride_id_t rideIndex) * * rct2: 0x0069576E */ -void rct_peep::OnExitRide(ride_id_t rideIndex) +void Guest::OnExitRide(ride_id_t rideIndex) { Ride* ride = get_ride(rideIndex); @@ -1552,24 +1517,11 @@ void rct_peep::OnExitRide(ride_id_t rideIndex) ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_CUSTOMER; } -/** - * - * rct2: 0x0069A512 - */ -void rct_peep::RemoveFromRide() -{ - if (state == PEEP_STATE_QUEUING) - { - RemoveFromQueue(); - } - StateReset(); -} - /** * To simplify check of 0x36BA3E0 and 0x11FF78 * returns false on no food. */ -bool rct_peep::HasFood() const +bool Guest::HasFood() const { return HasFoodStandardFlag() || HasFoodExtraFlag(); } @@ -1578,7 +1530,7 @@ bool rct_peep::HasFood() const * * rct2: 0x00695DD2 */ -void rct_peep::PickRideToGoOn() +void Guest::PickRideToGoOn() { if (state != PEEP_STATE_WALKING) return; @@ -1615,7 +1567,7 @@ void rct_peep::PickRideToGoOn() } } -Ride* rct_peep::FindBestRideToGoOn() +Ride* Guest::FindBestRideToGoOn() { // Pick the most exciting ride auto rideConsideration = FindRidesToGoOn(); @@ -1640,7 +1592,7 @@ Ride* rct_peep::FindBestRideToGoOn() return mostExcitingRide; } -std::bitset rct_peep::FindRidesToGoOn() +std::bitset Guest::FindRidesToGoOn() { std::bitset rideConsideration; @@ -1709,7 +1661,7 @@ std::bitset rct_peep::FindRidesToGoOn() * ride/shop, or they may just be thinking about it. * rct2: 0x006960AB */ -bool rct_peep::ShouldGoOnRide(Ride* ride, int32_t entranceNum, bool atQueue, bool thinking) +bool Guest::ShouldGoOnRide(Ride* ride, int32_t entranceNum, bool atQueue, bool thinking) { // Indicates whether a peep is physically at the ride, or is just thinking about going on the ride. bool peepAtRide = !thinking; @@ -1758,7 +1710,7 @@ bool rct_peep::ShouldGoOnRide(Ride* ride, int32_t entranceNum, bool atQueue, boo // Check if there's room in the queue for the peep to enter. if (ride->stations[entranceNum].LastPeepInQueue != SPRITE_INDEX_NULL) { - rct_peep* lastPeepInQueue = GET_PEEP(ride->stations[entranceNum].LastPeepInQueue); + Peep* lastPeepInQueue = GET_PEEP(ride->stations[entranceNum].LastPeepInQueue); if (abs(lastPeepInQueue->z - z) <= 6) { int32_t dx = abs(lastPeepInQueue->x - x); @@ -1997,7 +1949,7 @@ bool rct_peep::ShouldGoOnRide(Ride* ride, int32_t entranceNum, bool atQueue, boo return false; } -bool rct_peep::ShouldGoToShop(Ride* ride, bool peepAtShop) +bool Guest::ShouldGoToShop(Ride* ride, bool peepAtShop) { // Peeps won't go to the same shop twice in a row. if (ride->id == previous_ride) @@ -2071,7 +2023,7 @@ bool rct_peep::ShouldGoToShop(Ride* ride, bool peepAtShop) } // Used when no logging to an expend type required -void rct_peep::SpendMoney(money32 amount) +void Guest::SpendMoney(money32 amount) { money16 unused; SpendMoney(unused, amount); @@ -2082,7 +2034,7 @@ void rct_peep::SpendMoney(money32 amount) * rct2: 0x0069926C * Expend type was previously an offset saved in 0x00F1AEC0 */ -void rct_peep::SpendMoney(money16& peep_expend_type, money32 amount) +void Guest::SpendMoney(money16& peep_expend_type, money32 amount) { assert(!(gParkFlags & PARK_FLAGS_NO_MONEY)); @@ -2109,28 +2061,28 @@ void rct_peep::SpendMoney(money16& peep_expend_type, money32 amount) audio_play_sound_at_location(SOUND_PURCHASE, x, y, z); } -void rct_peep::SetHasRidden(Ride* ride) +void Guest::SetHasRidden(Ride* ride) { rides_been_on[ride->id / 8] |= 1 << (ride->id % 8); SetHasRiddenRideType(ride->type); } -bool rct_peep::HasRidden(Ride* ride) const +bool Guest::HasRidden(Ride* ride) const { return rides_been_on[ride->id / 8] & (1 << (ride->id % 8)); } -void rct_peep::SetHasRiddenRideType(int32_t rideType) +void Guest::SetHasRiddenRideType(int32_t rideType) { ride_types_been_on[rideType / 8] |= 1 << (rideType % 8); } -bool rct_peep::HasRiddenRideType(int32_t rideType) const +bool Guest::HasRiddenRideType(int32_t rideType) const { return ride_types_been_on[rideType / 8] & (1 << (rideType % 8)); } -void rct_peep::ChoseNotToGoOnRide(Ride* ride, bool peepAtRide, bool updateLastRide) +void Guest::ChoseNotToGoOnRide(Ride* ride, bool peepAtRide, bool updateLastRide) { if (peepAtRide && updateLastRide) { @@ -2144,7 +2096,7 @@ void rct_peep::ChoseNotToGoOnRide(Ride* ride, bool peepAtRide, bool updateLastRi } } -void rct_peep::ReadMap() +void Guest::ReadMap() { if (action == PEEP_ACTION_NONE_1 || action == PEEP_ACTION_NONE_2) { @@ -2156,7 +2108,7 @@ void rct_peep::ReadMap() } } -static bool peep_has_voucher_for_free_ride(rct_peep* peep, Ride* ride) +static bool peep_has_voucher_for_free_ride(Peep* peep, Ride* ride) { return peep->item_standard_flags & PEEP_ITEM_VOUCHER && peep->voucher_type == VOUCHER_TYPE_RIDE_FREE && peep->voucher_arguments == ride->id; @@ -2167,7 +2119,7 @@ static bool peep_has_voucher_for_free_ride(rct_peep* peep, Ride* ride) * Does not effect peeps that walk up to the queue entrance. * This flag is reset the next time a peep successfully joins the queue. */ -static void peep_tried_to_enter_full_queue(rct_peep* peep, Ride* ride) +static void peep_tried_to_enter_full_queue(Peep* peep, Ride* ride) { ride->lifecycle_flags |= RIDE_LIFECYCLE_QUEUE_FULL; peep->previous_ride = ride->id; @@ -2179,7 +2131,7 @@ static void peep_tried_to_enter_full_queue(rct_peep* peep, Ride* ride) } } -static void peep_reset_ride_heading(rct_peep* peep) +static void peep_reset_ride_heading(Peep* peep) { rct_window* w; @@ -2192,7 +2144,7 @@ static void peep_reset_ride_heading(rct_peep* peep) } } -static void peep_ride_is_too_intense(rct_peep* peep, Ride* ride, bool peepAtRide) +static void peep_ride_is_too_intense(Guest* peep, Ride* ride, bool peepAtRide) { if (peepAtRide) { @@ -2210,7 +2162,7 @@ static void peep_ride_is_too_intense(rct_peep* peep, Ride* ride, bool peepAtRide * * rct2: 0x00691C6E */ -static rct_vehicle* peep_choose_car_from_ride(rct_peep* peep, Ride* ride, std::vector& car_array) +static rct_vehicle* peep_choose_car_from_ride(Peep* peep, Ride* ride, std::vector& car_array) { uint8_t chosen_car = scenario_rand(); if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_HAS_G_FORCES) && ((chosen_car & 0xC) != 0xC)) @@ -2238,7 +2190,7 @@ static rct_vehicle* peep_choose_car_from_ride(rct_peep* peep, Ride* ride, std::v * * rct2: 0x00691CD1 */ -static void peep_choose_seat_from_car(rct_peep* peep, Ride* ride, rct_vehicle* vehicle) +static void peep_choose_seat_from_car(Peep* peep, Ride* ride, rct_vehicle* vehicle) { uint8_t chosen_seat = vehicle->next_free_seat; @@ -2261,7 +2213,7 @@ static void peep_choose_seat_from_car(rct_peep* peep, Ride* ride, rct_vehicle* v * * rct2: 0x00691D27 */ -static void peep_go_to_ride_entrance(rct_peep* peep, Ride* ride) +static void peep_go_to_ride_entrance(Guest* peep, Ride* ride) { TileCoordsXYZD location = ride_get_entrance_location(ride, peep->current_ride_station); Guard::Assert(!location.isNull()); @@ -2309,7 +2261,7 @@ static void peep_go_to_ride_entrance(rct_peep* peep, Ride* ride) peep->RemoveFromQueue(); } -static bool peep_find_vehicle_to_enter(rct_peep* peep, Ride* ride, std::vector& car_array) +static bool peep_find_vehicle_to_enter(Guest* peep, Ride* ride, std::vector& car_array) { uint8_t chosen_train = RideStation::NO_TRAIN; @@ -2378,7 +2330,7 @@ static bool peep_find_vehicle_to_enter(rct_peep* peep, Ride* ride, std::vectoritem_standard_flags & PEEP_ITEM_VOUCHER) && peep->voucher_type == VOUCHER_TYPE_RIDE_FREE && peep->voucher_arguments == peep->current_ride) @@ -2430,7 +2382,7 @@ static bool peep_check_ride_price_at_entrance(rct_peep* peep, Ride* ride, money3 * - How long the peep was waiting in the queue * - If the peep has been on the ride before, or on another ride of the same type */ -static int16_t peep_calculate_ride_satisfaction(rct_peep* peep, Ride* ride) +static int16_t peep_calculate_ride_satisfaction(Guest* peep, Ride* ride) { int16_t satisfaction = peep_calculate_ride_value_satisfaction(peep, ride); satisfaction += peep_calculate_ride_intensity_nausea_satisfaction(peep, ride); @@ -2466,7 +2418,7 @@ static int16_t peep_calculate_ride_satisfaction(rct_peep* peep, Ride* ride) * the ride becomes the peep's favourite. (This doesn't happen right away, but will be updated once the peep * exits the ride.) */ -static void peep_update_favourite_ride(rct_peep* peep, Ride* ride) +static void peep_update_favourite_ride(Peep* peep, Ride* ride) { peep->peep_flags &= ~PEEP_FLAGS_RIDE_SHOULD_BE_MARKED_AS_FAVOURITE; uint8_t peepRideRating = std::clamp((ride->excitement / 4) + peep->happiness, 0, PEEP_MAX_HAPPINESS); @@ -2481,7 +2433,7 @@ static void peep_update_favourite_ride(rct_peep* peep, Ride* ride) } /* rct2: 0x00695555 */ -static int16_t peep_calculate_ride_value_satisfaction(rct_peep* peep, Ride* ride) +static int16_t peep_calculate_ride_value_satisfaction(Peep* peep, Ride* ride) { if (gParkFlags & PARK_FLAGS_NO_MONEY) { @@ -2513,7 +2465,7 @@ static int16_t peep_calculate_ride_value_satisfaction(rct_peep* peep, Ride* ride * of the ride fall exactly within the peep's preferences, but lower scores can still be achieved * if the peep's happiness is enough to offset it. */ -static int16_t peep_calculate_ride_intensity_nausea_satisfaction(rct_peep* peep, Ride* ride) +static int16_t peep_calculate_ride_intensity_nausea_satisfaction(Peep* peep, Ride* ride) { if (!ride_has_ratings(ride)) { @@ -2613,7 +2565,7 @@ static int16_t peep_calculate_ride_intensity_nausea_satisfaction(rct_peep* peep, * - How hungry the peep is (+0% nausea at 50% hunger up to +100% nausea at 100% hunger) * - The peep's nausea tolerance (Final modifier: none: 100%, low: 50%, average: 25%, high: 12.5%) */ -static void peep_update_ride_nausea_growth(rct_peep* peep, Ride* ride) +static void peep_update_ride_nausea_growth(Peep* peep, Ride* ride) { uint32_t nauseaMultiplier = std::clamp(256 - peep->happiness_target, 64, 200); uint32_t nauseaGrowthRateChange = (ride->nausea * nauseaMultiplier) / 512; @@ -2622,7 +2574,7 @@ static void peep_update_ride_nausea_growth(rct_peep* peep, Ride* ride) peep->nausea_target = (uint8_t)std::min(peep->nausea_target + nauseaGrowthRateChange, 255u); } -static bool peep_should_go_on_ride_again(rct_peep* peep, Ride* ride) +static bool peep_should_go_on_ride_again(Peep* peep, Ride* ride) { if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_PEEP_WILL_RIDE_AGAIN)) return false; @@ -2655,7 +2607,7 @@ static bool peep_should_go_on_ride_again(rct_peep* peep, Ride* ride) return true; } -static bool peep_should_preferred_intensity_increase(rct_peep* peep) +static bool peep_should_preferred_intensity_increase(Peep* peep) { if (gParkFlags & PARK_FLAGS_PREF_LESS_INTENSE_RIDES) return false; @@ -2665,7 +2617,7 @@ static bool peep_should_preferred_intensity_increase(rct_peep* peep) return (scenario_rand() & 0xFF) >= peep->intensity; } -static bool peep_really_liked_ride(rct_peep* peep, Ride* ride) +static bool peep_really_liked_ride(Peep* peep, Ride* ride) { if (peep->happiness < 215) return false; @@ -2799,7 +2751,7 @@ static PeepThoughtType peep_assess_surroundings(int16_t centre_x, int16_t centre * * rct2: 0x0068F9A9 */ -static void peep_update_hunger(rct_peep* peep) +static void peep_update_hunger(Peep* peep) { if (peep->hunger >= 3) { @@ -2816,7 +2768,7 @@ static void peep_update_hunger(rct_peep* peep) * * rct2: 0x0068F8CD */ -static void peep_decide_whether_to_leave_park(rct_peep* peep) +static void peep_decide_whether_to_leave_park(Peep* peep) { if (peep->energy_target >= 33) { @@ -2868,7 +2820,7 @@ static void peep_decide_whether_to_leave_park(rct_peep* peep) * * rct2: 0x0068F93E */ -static void peep_leave_park(rct_peep* peep) +static void peep_leave_park(Peep* peep) { peep->guest_heading_to_ride_id = RIDE_ID_NULL; if (peep->peep_flags & PEEP_FLAGS_LEAVING_PARK) @@ -2897,7 +2849,7 @@ static void peep_leave_park(rct_peep* peep) * * rct2: 0x00695B70 */ -static void peep_head_for_nearest_ride_type(rct_peep* peep, int32_t rideType) +static void peep_head_for_nearest_ride_type(Guest* peep, int32_t rideType) { Ride* ride; @@ -3020,7 +2972,7 @@ static void peep_head_for_nearest_ride_type(rct_peep* peep, int32_t rideType) * * rct2: 0x006958D0 */ -static void peep_head_for_nearest_ride_with_flags(rct_peep* peep, int32_t rideTypeFlags) +static void peep_head_for_nearest_ride_with_flags(Guest* peep, int32_t rideTypeFlags) { Ride* ride; @@ -3152,7 +3104,7 @@ static void peep_head_for_nearest_ride_with_flags(rct_peep* peep, int32_t rideTy * such as "I'm hungry" after visiting a food shop. * Works for Thirst/Hungry/Low Money/Bathroom */ -void rct_peep::StopPurchaseThought(uint8_t ride_type) +void Guest::StopPurchaseThought(uint8_t ride_type) { uint8_t thoughtType = PEEP_THOUGHT_TYPE_HUNGRY; @@ -3200,7 +3152,7 @@ void rct_peep::StopPurchaseThought(uint8_t ride_type) * * rct2: 0x0069AEB7 */ -static bool peep_should_use_cash_machine(rct_peep* peep, ride_id_t rideIndex) +static bool peep_should_use_cash_machine(Peep* peep, ride_id_t rideIndex) { if (gParkFlags & PARK_FLAGS_NO_MONEY) return false; @@ -3225,7 +3177,7 @@ static bool peep_should_use_cash_machine(rct_peep* peep, ride_id_t rideIndex) * * rct2: 0x006912A3 */ -void rct_peep::UpdateBuying() +void Guest::UpdateBuying() { if (!CheckForPath()) return; @@ -3337,7 +3289,7 @@ void rct_peep::UpdateBuying() * * rct2: 0x00691A3B */ -void rct_peep::UpdateRideAtEntrance() +void Guest::UpdateRideAtEntrance() { Ride* ride = get_ride(current_ride); @@ -3416,7 +3368,7 @@ static constexpr const LocationXY16 _MazeEntranceStart[] = { { 24, 8 }, }; -static void peep_update_ride_leave_entrance_maze(rct_peep* peep, Ride* ride, TileCoordsXYZD& entrance_loc) +static void peep_update_ride_leave_entrance_maze(Guest* peep, Ride* ride, TileCoordsXYZD& entrance_loc) { peep->maze_last_edge = entrance_loc.direction + 1; entrance_loc.x *= 32; @@ -3449,7 +3401,7 @@ static void peep_update_ride_leave_entrance_maze(rct_peep* peep, Ride* ride, Til peep->sub_state = PEEP_RIDE_MAZE_PATHFINDING; } -static void peep_update_ride_leave_entrance_spiral_slide(rct_peep* peep, Ride* ride, TileCoordsXYZD& entrance_loc) +static void peep_update_ride_leave_entrance_spiral_slide(Guest* peep, Ride* ride, TileCoordsXYZD& entrance_loc) { entrance_loc.x = ride->stations[peep->current_ride_station].Start.x * 32; entrance_loc.y = ride->stations[peep->current_ride_station].Start.y * 32; @@ -3475,7 +3427,7 @@ static void peep_update_ride_leave_entrance_spiral_slide(rct_peep* peep, Ride* r } static uint8_t peep_get_waypointed_seat_location( - rct_peep* peep, Ride* ride, rct_ride_entry_vehicle* vehicle_type, uint8_t track_direction) + Peep* peep, Ride* ride, rct_ride_entry_vehicle* vehicle_type, uint8_t track_direction) { // The seatlocation can be split into segments around the ride base // to decide the segment first split off the segmentable seat location @@ -3500,7 +3452,7 @@ static uint8_t peep_get_waypointed_seat_location( return seatLocationSegment + seatLocationFixed; } -static void peep_update_ride_leave_entrance_waypoints(rct_peep* peep, Ride* ride) +static void peep_update_ride_leave_entrance_waypoints(Peep* peep, Ride* ride) { TileCoordsXYZD entranceLocation = ride_get_entrance_location(ride, peep->current_ride_station); Guard::Assert(!entranceLocation.isNull()); @@ -3539,7 +3491,7 @@ static void peep_update_ride_leave_entrance_waypoints(rct_peep* peep, Ride* ride * * rct2: 0x006921D3 */ -void rct_peep::UpdateRideAdvanceThroughEntrance() +void Guest::UpdateRideAdvanceThroughEntrance() { int16_t actionX, actionY, actionZ, xy_distance; @@ -3681,7 +3633,7 @@ void rct_peep::UpdateRideAdvanceThroughEntrance() * * rct2: 0x0069321D */ -static void peep_go_to_ride_exit(rct_peep* peep, Ride* ride, int16_t x, int16_t y, int16_t z, uint8_t exit_direction) +static void peep_go_to_ride_exit(Peep* peep, Ride* ride, int16_t x, int16_t y, int16_t z, uint8_t exit_direction) { z += RideData5[ride->type].z; @@ -3732,7 +3684,7 @@ static void peep_go_to_ride_exit(rct_peep* peep, Ride* ride, int16_t x, int16_t * * rct2: 0x006920B4 */ -void rct_peep::UpdateRideFreeVehicleEnterRide(Ride* ride) +void Guest::UpdateRideFreeVehicleEnterRide(Ride* ride) { money16 ridePrice = ride_get_price(ride); if (ridePrice != 0) @@ -3795,7 +3747,7 @@ void rct_peep::UpdateRideFreeVehicleEnterRide(Ride* ride) * * rct2: 0x00691FD4 */ -static void peep_update_ride_no_free_vehicle_rejoin_queue(rct_peep* peep, Ride* ride) +static void peep_update_ride_no_free_vehicle_rejoin_queue(Peep* peep, Ride* ride) { TileCoordsXYZD entranceLocation = ride_get_entrance_location(ride, peep->current_ride_station); @@ -3823,7 +3775,7 @@ static void peep_update_ride_no_free_vehicle_rejoin_queue(rct_peep* peep, Ride* * branch it out to 1 and 3. Now uses * separate functions. */ -void rct_peep::UpdateRideFreeVehicleCheck() +void Guest::UpdateRideFreeVehicleCheck() { Ride* ride = get_ride(current_ride); @@ -3916,7 +3868,7 @@ void rct_peep::UpdateRideFreeVehicleCheck() peep_update_ride_no_free_vehicle_rejoin_queue(this, ride); } -void rct_peep::UpdateRideApproachVehicle() +void Guest::UpdateRideApproachVehicle() { int16_t actionX, actionY, xy_distance; if (!UpdateAction(&actionX, &actionY, &xy_distance)) @@ -3930,7 +3882,7 @@ void rct_peep::UpdateRideApproachVehicle() Invalidate(); } -void rct_peep::UpdateRideEnterVehicle() +void Guest::UpdateRideEnterVehicle() { Ride* ride = get_ride(current_ride); @@ -3948,8 +3900,8 @@ void rct_peep::UpdateRideEnterVehicle() if (vehicle_is_used_in_pairs(vehicle)) { - rct_peep* seated_peep = GET_PEEP(vehicle->peep[current_seat ^ 1]); - if (seated_peep->sub_state != PEEP_RIDE_ENTER_VEHICLE) + auto seated_peep = (GET_PEEP(vehicle->peep[current_seat ^ 1]))->AsGuest(); + if (seated_peep == nullptr || seated_peep->sub_state != PEEP_RIDE_ENTER_VEHICLE) return; vehicle->num_peeps++; @@ -3985,7 +3937,7 @@ void rct_peep::UpdateRideEnterVehicle() * * rct2: 0x00693028 */ -void rct_peep::UpdateRideLeaveVehicle() +void Guest::UpdateRideLeaveVehicle() { Ride* ride = get_ride(current_ride); @@ -4179,7 +4131,7 @@ void rct_peep::UpdateRideLeaveVehicle() * * rct2: 0x0069376A */ -static void peep_update_ride_prepare_for_exit(rct_peep* peep) +static void peep_update_ride_prepare_for_exit(Peep* peep) { Ride* ride = get_ride(peep->current_ride); @@ -4225,7 +4177,7 @@ static void peep_update_ride_prepare_for_exit(rct_peep* peep) * * rct2: 0x0069374F */ -void rct_peep::UpdateRideApproachExit() +void Guest::UpdateRideApproachExit() { int16_t actionX, actionY, xy_distance; if (UpdateAction(&actionX, &actionY, &xy_distance)) @@ -4243,7 +4195,7 @@ void rct_peep::UpdateRideApproachExit() * * rct2: 0x0069382E */ -void rct_peep::UpdateRideInExit() +void Guest::UpdateRideInExit() { int16_t actionX, actionY, xy_distance; Ride* ride = get_ride(current_ride); @@ -4282,7 +4234,7 @@ void rct_peep::UpdateRideInExit() * * rct2: 0x006926AD */ -void rct_peep::UpdateRideApproachVehicleWaypoints() +void Guest::UpdateRideApproachVehicleWaypoints() { int16_t actionX, actionY, xy_distance; Ride* ride = get_ride(current_ride); @@ -4358,7 +4310,7 @@ void rct_peep::UpdateRideApproachVehicleWaypoints() * * rct2: 0x0069357D */ -void rct_peep::UpdateRideApproachExitWaypoints() +void Guest::UpdateRideApproachExitWaypoints() { int16_t actionX, actionY, xy_distance; Ride* ride = get_ride(current_ride); @@ -4458,7 +4410,7 @@ void rct_peep::UpdateRideApproachExitWaypoints() * * rct2: 0x006927B3 */ -void rct_peep::UpdateRideApproachSpiralSlide() +void Guest::UpdateRideApproachSpiralSlide() { int16_t actionX, actionY, xy_distance; Ride* ride = get_ride(current_ride); @@ -4552,7 +4504,7 @@ static constexpr const CoordsXY _SpiralSlideEndWaypoint[] = { * * rct2: 0x00692D83 */ -void rct_peep::UpdateRideOnSpiralSlide() +void Guest::UpdateRideOnSpiralSlide() { Ride* ride = get_ride(current_ride); @@ -4637,7 +4589,7 @@ void rct_peep::UpdateRideOnSpiralSlide() * * rct2: 0x00692C6B */ -void rct_peep::UpdateRideLeaveSpiralSlide() +void Guest::UpdateRideLeaveSpiralSlide() { // Iterates through the spiral slide waypoints until it reaches // waypoint 0. Then it readies to leave the ride by the entrance. @@ -4724,7 +4676,7 @@ static constexpr const uint8_t _MazeCurrentDirectionToOpenHedge[][4] = { * * rct2: 0x00692A83 */ -void rct_peep::UpdateRideMazePathfinding() +void Guest::UpdateRideMazePathfinding() { int16_t actionX, actionY, xy_distance; if (UpdateAction(&actionX, &actionY, &xy_distance)) @@ -4886,7 +4838,7 @@ void rct_peep::UpdateRideMazePathfinding() * * rct2: 0x006938D2 */ -void rct_peep::UpdateRideLeaveExit() +void Guest::UpdateRideLeaveExit() { int16_t actionX, actionY, xy_distance; Ride* ride = get_ride(current_ride); @@ -4945,7 +4897,7 @@ void rct_peep::UpdateRideLeaveExit() * * rct2: 0x0069299C */ -void rct_peep::UpdateRideShopApproach() +void Guest::UpdateRideShopApproach() { int16_t actionX, actionY, xy_distance; @@ -4964,7 +4916,7 @@ void rct_peep::UpdateRideShopApproach() * * rct2: 0x006929BB */ -void rct_peep::UpdateRideShopInteract() +void Guest::UpdateRideShopInteract() { const int16_t tileCenterX = next_x + 16; const int16_t tileCenterY = next_y + 16; @@ -5017,7 +4969,7 @@ void rct_peep::UpdateRideShopInteract() * * rct2: 0x00692935 */ -void rct_peep::UpdateRideShopLeave() +void Guest::UpdateRideShopLeave() { int16_t actionX, actionY, xy_distance; @@ -5044,11 +4996,55 @@ void rct_peep::UpdateRideShopLeave() ride_update_satisfaction(ride, happiness / 64); } +void Guest::UpdateGuest() +{ + switch (state) + { + case PEEP_STATE_QUEUING_FRONT: + UpdateRide(); + break; + case PEEP_STATE_LEAVING_RIDE: + UpdateRide(); + break; + case PEEP_STATE_WALKING: + UpdateWalking(); + break; + case PEEP_STATE_QUEUING: + UpdateQueuing(); + break; + case PEEP_STATE_ENTERING_RIDE: + UpdateRide(); + break; + case PEEP_STATE_SITTING: + UpdateSitting(); + break; + case PEEP_STATE_ENTERING_PARK: + UpdateEnteringPark(); + break; + case PEEP_STATE_LEAVING_PARK: + UpdateLeavingPark(); + break; + case PEEP_STATE_BUYING: + UpdateBuying(); + break; + case PEEP_STATE_WATCHING: + UpdateWatching(); + break; + case PEEP_STATE_USING_BIN: + UpdateUsingBin(); + break; + default: + // TODO reset to default state + assert(false); + break; + } +} + /** * * rct2: 0x691A30 * Used by entering_ride and queueing_front */ -void rct_peep::UpdateRide() +void Guest::UpdateRide() { next_flags &= ~PEEP_NEXT_FLAG_IS_SLOPED; @@ -5121,14 +5117,14 @@ void rct_peep::UpdateRide() } } -static void peep_update_walking_break_scenery(rct_peep* peep); -static bool peep_find_ride_to_look_at(rct_peep* peep, uint8_t edge, uint8_t* rideToView, uint8_t* rideSeatToView); +static void peep_update_walking_break_scenery(Peep* peep); +static bool peep_find_ride_to_look_at(Peep* peep, uint8_t edge, uint8_t* rideToView, uint8_t* rideSeatToView); /** * * rct2: 0x0069030A */ -void rct_peep::UpdateWalking() +void Guest::UpdateWalking() { if (!CheckForPath()) return; @@ -5417,7 +5413,7 @@ void rct_peep::UpdateWalking() * * rct2: 0x69185D */ -void rct_peep::UpdateQueuing() +void Guest::UpdateQueuing() { if (!CheckForPath()) { @@ -5442,7 +5438,7 @@ void rct_peep::UpdateQueuing() // first check if the next in queue is actually nearby // if they are not then it's safe to assume that this is // the front of the queue. - rct_peep* next_peep = GET_PEEP(next_in_queue); + Peep* next_peep = GET_PEEP(next_in_queue); if (abs(next_peep->x - x) < 32 && abs(next_peep->y - y) < 32) { is_front = false; @@ -5543,7 +5539,7 @@ void rct_peep::UpdateQueuing() /** * rct2: 0x691451 */ -void rct_peep::UpdateEnteringPark() +void Guest::UpdateEnteringPark() { if (var_37 != 1) { @@ -5580,7 +5576,7 @@ void rct_peep::UpdateEnteringPark() * * rct2: 0x6914CD */ -void rct_peep::UpdateLeavingPark() +void Guest::UpdateLeavingPark() { if (var_37 != 0) { @@ -5622,7 +5618,7 @@ void rct_peep::UpdateLeavingPark() * * rct2: 0x6916D6 */ -void rct_peep::UpdateWatching() +void Guest::UpdateWatching() { if (sub_state == 0) { @@ -5724,7 +5720,7 @@ void rct_peep::UpdateWatching() * * rct2: 0x00691089 */ -void rct_peep::UpdateUsingBin() +void Guest::UpdateUsingBin() { switch (sub_state) { @@ -5882,7 +5878,7 @@ void rct_peep::UpdateUsingBin() } /* Simplifies 0x690582. Returns true if should find bench*/ -bool rct_peep::ShouldFindBench() +bool Guest::ShouldFindBench() { if (peep_flags & PEEP_FLAGS_LEAVING_PARK) { @@ -5918,7 +5914,7 @@ bool rct_peep::ShouldFindBench() * rct2: 0x00690582 * Returns true when the guest wants to sit down and has found a bench to sit on */ -bool rct_peep::UpdateWalkingFindBench() +bool Guest::UpdateWalkingFindBench() { if (!ShouldFindBench()) return false; @@ -6009,7 +6005,7 @@ bool rct_peep::UpdateWalkingFindBench() return true; } -bool rct_peep::UpdateWalkingFindBin() +bool Guest::UpdateWalkingFindBin() { auto peep = this; if (!peep->HasEmptyContainer()) @@ -6095,7 +6091,7 @@ bool rct_peep::UpdateWalkingFindBin() * * rct2: 0x00690848 */ -static void peep_update_walking_break_scenery(rct_peep* peep) +static void peep_update_walking_break_scenery(Peep* peep) { if (gCheatsDisableVandalism) return; @@ -6167,7 +6163,7 @@ static void peep_update_walking_break_scenery(rct_peep* peep) return; } - rct_peep* inner_peep; + Peep* inner_peep; uint16_t sprite_index; FOR_ALL_STAFF (sprite_index, inner_peep) @@ -6252,7 +6248,7 @@ static bool peep_should_watch_ride(TileElement* tileElement) return true; } -bool loc_690FD0(rct_peep* peep, uint8_t* rideToView, uint8_t* rideSeatToView, TileElement* tileElement) +bool loc_690FD0(Peep* peep, uint8_t* rideToView, uint8_t* rideSeatToView, TileElement* tileElement) { Ride* ride = get_ride(tileElement->AsTrack()->GetRideIndex()); @@ -6297,7 +6293,7 @@ bool loc_690FD0(rct_peep* peep, uint8_t* rideToView, uint8_t* rideSeatToView, Ti * @param[out] rideSeatToView (ch) * @return !CF */ -static bool peep_find_ride_to_look_at(rct_peep* peep, uint8_t edge, uint8_t* rideToView, uint8_t* rideSeatToView) +static bool peep_find_ride_to_look_at(Peep* peep, uint8_t edge, uint8_t* rideToView, uint8_t* rideSeatToView) { TileElement *tileElement, *surfaceElement; @@ -6638,7 +6634,7 @@ static bool peep_find_ride_to_look_at(rct_peep* peep, uint8_t edge, uint8_t* rid } /* Part of 0x0069B8CC rct2: 0x0069BC31 */ -void rct_peep::SetSpriteType(PeepSpriteType new_sprite_type) +void Guest::SetSpriteType(PeepSpriteType new_sprite_type) { if (sprite_type == new_sprite_type) return; @@ -6722,7 +6718,7 @@ static item_pref_t item_order_preference[] = { * * rct2: 0x0069B8CC */ -void rct_peep::UpdateSpriteType() +void Guest::UpdateSpriteType() { if (sprite_type == PEEP_SPRITE_TYPE_BALLOON && (scenario_rand() & 0xFFFF) <= 327) { @@ -6818,3 +6814,8 @@ void rct_peep::UpdateSpriteType() SetSpriteType(PEEP_SPRITE_TYPE_NORMAL); } + +bool Guest::HeadingForRideOrParkExit() const +{ + return (peep_flags & PEEP_FLAGS_LEAVING_PARK) || (guest_heading_to_ride_id != 0xFF); +} diff --git a/src/openrct2/peep/GuestPathfinding.cpp b/src/openrct2/peep/GuestPathfinding.cpp index 499cb8cc93..f667799221 100644 --- a/src/openrct2/peep/GuestPathfinding.cpp +++ b/src/openrct2/peep/GuestPathfinding.cpp @@ -23,7 +23,7 @@ static int8_t _peepPathFindMaxJunctions; static int32_t _peepPathFindTilesChecked; static uint8_t _peepPathFindFewestNumSteps; -static int32_t guest_surface_path_finding(rct_peep* peep); +static int32_t guest_surface_path_finding(Peep* peep); /* A junction history for the peep pathfinding heuristic search * The magic number 16 is the largest value returned by @@ -104,7 +104,7 @@ static int32_t path_get_permitted_edges(TileElement* tileElement) * * rct2: 0x0069524E */ -static int32_t peep_move_one_tile(uint8_t direction, rct_peep* peep) +static int32_t peep_move_one_tile(uint8_t direction, Peep* peep) { assert(direction <= 3); int16_t x = peep->next_x; @@ -133,7 +133,7 @@ static int32_t peep_move_one_tile(uint8_t direction, rct_peep* peep) * * rct2: 0x00694C41 */ -static int32_t guest_surface_path_finding(rct_peep* peep) +static int32_t guest_surface_path_finding(Peep* peep) { int16_t x = peep->next_x; int16_t y = peep->next_y; @@ -411,7 +411,7 @@ static uint8_t footpath_element_destination_in_direction( * * rct2: 0x00695225 */ -static int32_t guest_path_find_aimless(rct_peep* peep, uint8_t edges) +static int32_t guest_path_find_aimless(Peep* peep, uint8_t edges) { if (scenario_rand() & 1) { @@ -437,7 +437,7 @@ static int32_t guest_path_find_aimless(rct_peep* peep, uint8_t edges) * * rct2: 0x0069A60A */ -static uint8_t peep_pathfind_get_max_number_junctions(rct_peep* peep) +static uint8_t peep_pathfind_get_max_number_junctions(Peep* peep) { if (peep->type == PEEP_TYPE_STAFF) return 8; @@ -582,7 +582,7 @@ static bool path_is_thin_junction(TileElement* path, TileCoordsXYZ loc) * rct2: 0x0069A997 */ static void peep_pathfind_heuristic_search( - TileCoordsXYZ loc, rct_peep* peep, TileElement* currentTileElement, bool inPatrolArea, uint8_t counter, uint16_t* endScore, + TileCoordsXYZ loc, Peep* peep, TileElement* currentTileElement, bool inPatrolArea, uint8_t counter, uint16_t* endScore, int32_t test_edge, uint8_t* endJunctions, TileCoordsXYZ junctionList[16], uint8_t directionList[16], TileCoordsXYZ* endXYZ, uint8_t* endSteps) { @@ -1157,7 +1157,7 @@ static void peep_pathfind_heuristic_search( * * rct2: 0x0069A5F0 */ -int32_t peep_pathfind_choose_direction(TileCoordsXYZ loc, rct_peep* peep) +int32_t peep_pathfind_choose_direction(TileCoordsXYZ loc, Peep* peep) { // The max number of thin junctions searched - a per-search-path limit. _peepPathFindMaxJunctions = peep_pathfind_get_max_number_junctions(peep); @@ -1556,7 +1556,7 @@ static uint8_t get_nearest_park_entrance_index(uint16_t x, uint16_t y) * * rct2: 0x006952C0 */ -static int32_t guest_path_find_entering_park(rct_peep* peep, [[maybe_unused]] TileElement* tile_element, uint8_t edges) +static int32_t guest_path_find_entering_park(Peep* peep, [[maybe_unused]] TileElement* tile_element, uint8_t edges) { // Send peeps to the nearest park entrance. uint8_t chosenEntrance = get_nearest_park_entrance_index(peep->next_x, peep->next_y); @@ -1609,7 +1609,7 @@ static uint8_t get_nearest_peep_spawn_index(uint16_t x, uint16_t y) * * rct2: 0x0069536C */ -static int32_t guest_path_find_leaving_park(rct_peep* peep, [[maybe_unused]] TileElement* tile_element, uint8_t edges) +static int32_t guest_path_find_leaving_park(Peep* peep, [[maybe_unused]] TileElement* tile_element, uint8_t edges) { // Send peeps to the nearest spawn point. uint8_t chosenSpawn = get_nearest_peep_spawn_index(peep->next_x, peep->next_y); @@ -1644,7 +1644,7 @@ static int32_t guest_path_find_leaving_park(rct_peep* peep, [[maybe_unused]] Til * * rct2: 0x00695161 */ -static int32_t guest_path_find_park_entrance(rct_peep* peep, [[maybe_unused]] TileElement* tile_element, uint8_t edges) +static int32_t guest_path_find_park_entrance(Peep* peep, [[maybe_unused]] TileElement* tile_element, uint8_t edges) { // If entrance no longer exists, choose a new one if ((peep->peep_flags & PEEP_FLAGS_PARK_ENTRANCE_CHOSEN) && peep->current_ride >= gParkEntrances.size()) @@ -1846,7 +1846,7 @@ static void get_ride_queue_end(TileCoordsXYZ& loc) * * rct2: 0x00694C35 */ -int32_t guest_path_finding(rct_peep* peep) +int32_t guest_path_finding(Guest* peep) { // int16_t x, y, z; diff --git a/src/openrct2/peep/Peep.cpp b/src/openrct2/peep/Peep.cpp index 72e386ac16..4c92b2a201 100644 --- a/src/openrct2/peep/Peep.cpp +++ b/src/openrct2/peep/Peep.cpp @@ -78,10 +78,10 @@ static TileElement* _peepRideEntranceExitElement; static void* _crowdSoundChannel = nullptr; -static void peep_128_tick_update(rct_peep* peep, int32_t index); -static void peep_easter_egg_peep_interactions(rct_peep* peep); -static void peep_give_real_name(rct_peep* peep); -static void peep_release_balloon(rct_peep* peep, int16_t spawn_height); +static void peep_128_tick_update(Peep* peep, int32_t index); +static void peep_easter_egg_peep_interactions(Guest* peep); +static void peep_give_real_name(Peep* peep); +static void peep_release_balloon(Guest* peep, int16_t spawn_height); // clang-format off static constexpr const char *gPeepEasterEggNames[] = { @@ -349,49 +349,59 @@ bool rct_sprite::IsPeep() return peep.sprite_identifier == SPRITE_IDENTIFIER_PEEP; } -rct_peep* rct_sprite::AsPeep() +Peep* rct_sprite::AsPeep() { - rct_peep* result = nullptr; + Peep* result = nullptr; if (IsPeep()) { - return (rct_peep*)this; + return (Peep*)this; } return result; } -void rct_peep::Invalidate() +Guest* Peep::AsGuest() +{ + return type == PEEP_TYPE_GUEST ? static_cast(this) : nullptr; +} + +Staff* Peep::AsStaff() +{ + return type == PEEP_TYPE_STAFF ? static_cast(this) : nullptr; +} + +void Peep::Invalidate() { invalidate_sprite_2((rct_sprite*)this); } -void rct_peep::MoveTo(int16_t destX, int16_t destY, int16_t destZ) +void Peep::MoveTo(int16_t destX, int16_t destY, int16_t destZ) { sprite_move(destX, destY, destZ, (rct_sprite*)this); } -uint8_t rct_peep::GetNextDirection() const +uint8_t Peep::GetNextDirection() const { return next_flags & PEEP_NEXT_FLAG_DIRECTION_MASK; } -bool rct_peep::GetNextIsSloped() const +bool Peep::GetNextIsSloped() const { return next_flags & PEEP_NEXT_FLAG_IS_SLOPED; } -bool rct_peep::GetNextIsSurface() const +bool Peep::GetNextIsSurface() const { return next_flags & PEEP_NEXT_FLAG_IS_SURFACE; } -void rct_peep::SetNextFlags(uint8_t next_direction, bool is_sloped, bool is_surface) +void Peep::SetNextFlags(uint8_t next_direction, bool is_sloped, bool is_surface) { next_flags = next_direction & PEEP_NEXT_FLAG_DIRECTION_MASK; next_flags |= is_sloped ? PEEP_NEXT_FLAG_IS_SLOPED : 0; next_flags |= is_surface ? PEEP_NEXT_FLAG_IS_SURFACE : 0; } -rct_peep* try_get_guest(uint16_t spriteIndex) +Peep* try_get_guest(uint16_t spriteIndex) { rct_sprite* sprite = try_get_sprite(spriteIndex); if (sprite == nullptr) @@ -406,7 +416,7 @@ rct_peep* try_get_guest(uint16_t spriteIndex) int32_t peep_get_staff_count() { uint16_t spriteIndex; - rct_peep* peep; + Peep* peep; int32_t count = 0; FOR_ALL_STAFF (spriteIndex, peep) @@ -423,7 +433,7 @@ void peep_update_all() { int32_t i; uint16_t spriteIndex; - rct_peep* peep; + Peep* peep; if (gScreenFlags & (SCREEN_FLAGS_SCENARIO_EDITOR | SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER)) return; @@ -457,15 +467,20 @@ void peep_update_all() * rct2: 0x0068F41A * Called every 128 ticks */ -static void peep_128_tick_update(rct_peep* peep, int32_t index) +static void peep_128_tick_update(Peep* peep, int32_t index) { - if (peep->type == PEEP_TYPE_STAFF) + auto guest = peep->AsGuest(); + if (guest != nullptr) { - peep->Tick128UpdateStaff(); + guest->Tick128UpdateGuest(index); } else { - peep->Tick128UpdateGuest(index); + auto staff = peep->AsStaff(); + if (staff != nullptr) + { + staff->Tick128UpdateStaff(); + } } } @@ -473,7 +488,7 @@ static void peep_128_tick_update(rct_peep* peep, int32_t index) * rct2: 0x68F3AE * Set peep state to falling if path below has gone missing, return true if current path is valid, false if peep starts falling. */ -bool rct_peep::CheckForPath() +bool Peep::CheckForPath() { path_check_optimisation++; if ((path_check_optimisation & 0xF) != (sprite_index & 0xF)) @@ -511,7 +526,7 @@ bool rct_peep::CheckForPath() return false; } -PeepActionSpriteType rct_peep::GetActionSpriteType() +PeepActionSpriteType Peep::GetActionSpriteType() { if (action >= PEEP_ACTION_NONE_1) { // PEEP_ACTION_NONE_1 or PEEP_ACTION_NONE_2 @@ -532,7 +547,7 @@ PeepActionSpriteType rct_peep::GetActionSpriteType() /* * rct2: 0x00693B58 */ -void rct_peep::UpdateCurrentActionSpriteType() +void Peep::UpdateCurrentActionSpriteType() { if (sprite_type >= std::size(g_peep_animation_entries)) { @@ -556,7 +571,7 @@ void rct_peep::UpdateCurrentActionSpriteType() } /* rct2: 0x00693BE5 */ -void rct_peep::SwitchToSpecialSprite(uint8_t special_sprite_id) +void Peep::SwitchToSpecialSprite(uint8_t special_sprite_id) { if (special_sprite_id == special_sprite) return; @@ -571,7 +586,7 @@ void rct_peep::SwitchToSpecialSprite(uint8_t special_sprite_id) UpdateCurrentActionSpriteType(); } -void rct_peep::StateReset() +void Peep::StateReset() { SetState(PEEP_STATE_1); SwitchToSpecialSprite(0); @@ -580,7 +595,7 @@ void rct_peep::StateReset() /** rct2: 0x00981D7C, 0x00981D7E */ static constexpr const LocationXY16 word_981D7C[4] = { { -2, 0 }, { 0, 2 }, { 2, 0 }, { 0, -2 } }; -bool rct_peep::UpdateAction() +bool Peep::UpdateAction() { int16_t actionX, actionY, xy_distance; return UpdateAction(&actionX, &actionY, &xy_distance); @@ -594,7 +609,7 @@ bool rct_peep::UpdateAction() * has not yet been reached. xy_distance is how close the * peep is to the target. */ -bool rct_peep::UpdateAction(int16_t* actionX, int16_t* actionY, int16_t* xy_distance) +bool Peep::UpdateAction(int16_t* actionX, int16_t* actionY, int16_t* xy_distance) { _unk_F1AEF0 = action_sprite_image_offset; if (action == PEEP_ACTION_NONE_1) @@ -699,7 +714,7 @@ bool rct_peep::UpdateAction(int16_t* actionX, int16_t* actionY, int16_t* xy_dist * rct2: 0x0069A409 * Decreases rider count if on/entering a ride. */ -void peep_decrement_num_riders(rct_peep* peep) +void peep_decrement_num_riders(Peep* peep) { if (peep->state == PEEP_STATE_ON_RIDE || peep->state == PEEP_STATE_ENTERING_RIDE) { @@ -714,7 +729,7 @@ void peep_decrement_num_riders(rct_peep* peep) * Note also increase ride count if on/entering a ride. * rct2: 0x0069A42F */ -void peep_window_state_update(rct_peep* peep) +void peep_window_state_update(Peep* peep) { rct_window* w = window_find_by_number(WC_PEEP, peep->sprite_index); if (w != nullptr) @@ -739,9 +754,13 @@ void peep_window_state_update(rct_peep* peep) } } -void rct_peep::Pickup() +void Peep::Pickup() { - RemoveFromRide(); + auto guest = AsGuest(); + if (guest != nullptr) + { + guest->RemoveFromRide(); + } Invalidate(); sprite_move(LOCATION_NULL, y, z, (rct_sprite*)this); @@ -749,7 +768,7 @@ void rct_peep::Pickup() sub_state = 0; } -void rct_peep::PickupAbort(int32_t old_x) +void Peep::PickupAbort(int32_t old_x) { if (state != PEEP_STATE_PICKED) return; @@ -771,7 +790,7 @@ void rct_peep::PickupAbort(int32_t old_x) } // Returns true when a peep can be dropped at the given location. When apply is set to true the peep gets dropped. -bool rct_peep::Place(TileCoordsXYZ location, bool apply) +bool Peep::Place(TileCoordsXYZ location, bool apply) { TileElement* tileElement = map_get_path_element_at(location.x, location.y, location.z); @@ -842,7 +861,7 @@ bool peep_pickup_command(uint32_t peepnum, int32_t x, int32_t y, int32_t z, int3 return false; } - rct_peep* const peep = GET_PEEP(peepnum); + Peep* const peep = GET_PEEP(peepnum); if (!peep || peep->sprite_identifier != SPRITE_IDENTIFIER_PEEP) { return false; @@ -856,7 +875,7 @@ bool peep_pickup_command(uint32_t peepnum, int32_t x, int32_t y, int32_t z, int3 { return false; } - rct_peep* existing = network_get_pickup_peep(game_command_playerid); + Peep* existing = network_get_pickup_peep(game_command_playerid); if (existing) { // already picking up a peep @@ -885,7 +904,7 @@ bool peep_pickup_command(uint32_t peepnum, int32_t x, int32_t y, int32_t z, int3 if (apply) { // TODO: Verify if this is really needed or that we can use `peep` instead - rct_peep* const pickedUpPeep = network_get_pickup_peep(game_command_playerid); + Peep* const pickedUpPeep = network_get_pickup_peep(game_command_playerid); if (pickedUpPeep) { pickedUpPeep->PickupAbort(x); @@ -931,9 +950,13 @@ void game_command_pickup_guest( * * rct2: 0x0069A535 */ -void peep_sprite_remove(rct_peep* peep) +void peep_sprite_remove(Peep* peep) { - peep->RemoveFromRide(); + auto guest = peep->AsGuest(); + if (guest != nullptr) + { + guest->RemoveFromRide(); + } peep->Invalidate(); window_close_by_number(WC_PEEP, peep->sprite_index); @@ -963,7 +986,7 @@ void peep_sprite_remove(rct_peep* peep) /** * New function removes peep from park existence. Works with staff. */ -void rct_peep::Remove() +void Peep::Remove() { if (type == PEEP_TYPE_GUEST) { @@ -985,7 +1008,7 @@ void rct_peep::Remove() * Falling and its subset drowning * rct2: 0x690028 */ -void rct_peep::UpdateFalling() +void Peep::UpdateFalling() { if (action == PEEP_ACTION_DROWNING) { @@ -1043,8 +1066,13 @@ void rct_peep::UpdateFalling() // Looks like we are drowning! Invalidate(); MoveTo(x, y, height); - // Drop balloon if held - peep_release_balloon(this, height); + + auto guest = AsGuest(); + if (guest != nullptr) + { + // Drop balloon if held + peep_release_balloon(guest, height); + } peep_insert_new_thought(this, PEEP_THOUGHT_TYPE_DROWNING, PEEP_THOUGHT_ITEM_NONE); @@ -1107,7 +1135,7 @@ void rct_peep::UpdateFalling() * * rct2: 0x6902A2 */ -void rct_peep::Update1() +void Peep::Update1() { if (!CheckForPath()) return; @@ -1127,7 +1155,7 @@ void rct_peep::Update1() direction = sprite_direction >> 3; } -void rct_peep::SetState(PeepState new_state) +void Peep::SetState(PeepState new_state) { peep_decrement_num_riders(this); state = new_state; @@ -1138,7 +1166,7 @@ void rct_peep::SetState(PeepState new_state) * * rct2: 0x690009 */ -void rct_peep::UpdatePicked() +void Peep::UpdatePicked() { if (gCurrentTicks & 0x1F) return; @@ -1150,7 +1178,7 @@ void rct_peep::UpdatePicked() } /* From peep_update */ -static void peep_update_thoughts(rct_peep* peep) +static void peep_update_thoughts(Peep* peep) { // Thoughts must always have a gap of at least // 220 ticks in age between them. In order to @@ -1214,7 +1242,7 @@ static void peep_update_thoughts(rct_peep* peep) * * rct2: 0x0068FC1E */ -void rct_peep::Update() +void Peep::Update() { if (type == PEEP_TYPE_GUEST) { @@ -1242,7 +1270,11 @@ void rct_peep::Update() step_progress = carryCheck; if (carryCheck <= 255) { - peep_easter_egg_peep_interactions(this); + auto guest = AsGuest(); + if (guest != nullptr) + { + peep_easter_egg_peep_interactions(guest); + } } else { @@ -1255,76 +1287,33 @@ void rct_peep::Update() case PEEP_STATE_1: Update1(); break; - case PEEP_STATE_QUEUING_FRONT: - UpdateRide(); - break; case PEEP_STATE_ON_RIDE: // No action break; - case PEEP_STATE_LEAVING_RIDE: - UpdateRide(); - break; - case PEEP_STATE_WALKING: - UpdateWalking(); - break; - case PEEP_STATE_QUEUING: - UpdateQueuing(); - break; - case PEEP_STATE_ENTERING_RIDE: - UpdateRide(); - break; - case PEEP_STATE_SITTING: - UpdateSitting(); - break; case PEEP_STATE_PICKED: UpdatePicked(); break; - case PEEP_STATE_PATROLLING: - UpdatePatrolling(); - break; - case PEEP_STATE_MOWING: - UpdateMowing(); - break; - case PEEP_STATE_SWEEPING: - UpdateSweeping(); - break; - case PEEP_STATE_ENTERING_PARK: - UpdateEnteringPark(); - break; - case PEEP_STATE_LEAVING_PARK: - UpdateLeavingPark(); - break; - case PEEP_STATE_ANSWERING: - UpdateAnswering(); - break; - case PEEP_STATE_FIXING: - UpdateFixing(stepsToTake); - break; - case PEEP_STATE_BUYING: - UpdateBuying(); - break; - case PEEP_STATE_WATCHING: - UpdateWatching(); - break; - case PEEP_STATE_EMPTYING_BIN: - UpdateEmptyingBin(); - break; - case PEEP_STATE_USING_BIN: - UpdateUsingBin(); - break; - case PEEP_STATE_WATERING: - UpdateWatering(); - break; - case PEEP_STATE_HEADING_TO_INSPECTION: - UpdateHeadingToInspect(); - break; - case PEEP_STATE_INSPECTING: - UpdateFixing(stepsToTake); - break; - // There shouldn't be any more default: - assert(0); + { + auto guest = AsGuest(); + if (guest != nullptr) + { + guest->UpdateGuest(); + } + else + { + auto staff = AsStaff(); + if (staff != nullptr) + { + staff->UpdateStaff(stepsToTake); + } + else + { + assert(false); + } + } break; + } } } } @@ -1335,7 +1324,7 @@ void rct_peep::Update() */ void peep_problem_warnings_update() { - rct_peep* peep; + Peep* peep; Ride* ride; uint16_t spriteIndex; uint16_t guests_in_park = gNumGuestsInPark; @@ -1509,7 +1498,7 @@ void peep_update_crowd_noise() { rct_viewport* viewport; uint16_t spriteIndex; - rct_peep* peep; + Peep* peep; int32_t visiblePeeps; if (gGameSoundsOff) @@ -1592,10 +1581,11 @@ void peep_update_crowd_noise() void peep_applause() { uint16_t spriteIndex; - rct_peep* peep; - - FOR_ALL_GUESTS (spriteIndex, peep) + Peep* p; + FOR_ALL_GUESTS (spriteIndex, p) { + auto peep = p->AsGuest(); + assert(peep != nullptr); if (peep->outside_of_park != 0) continue; @@ -1624,7 +1614,7 @@ void peep_applause() void peep_update_days_in_queue() { uint16_t sprite_index; - rct_peep* peep; + Peep* peep; FOR_ALL_GUESTS (sprite_index, peep) { @@ -1718,12 +1708,12 @@ static constexpr const uint8_t tshirt_colours[] = { * * rct2: 0x0069A05D */ -rct_peep* peep_generate(int32_t x, int32_t y, int32_t z) +Peep* peep_generate(int32_t x, int32_t y, int32_t z) { if (gSpriteListCount[SPRITE_LIST_NULL] < 400) return nullptr; - rct_peep* peep = (rct_peep*)create_sprite(1); + Peep* peep = (Peep*)create_sprite(1); move_sprite_to_list((rct_sprite*)peep, SPRITE_LIST_PEEP * 2); @@ -1912,7 +1902,7 @@ rct_peep* peep_generate(int32_t x, int32_t y, int32_t z) * argument_1 (ecx & ebx) * argument_2 (edx) */ -void get_arguments_from_action(rct_peep* peep, uint32_t* argument_1, uint32_t* argument_2) +void get_arguments_from_action(Peep* peep, uint32_t* argument_1, uint32_t* argument_2) { Ride* ride; @@ -2105,7 +2095,7 @@ static constexpr const bool peep_allow_pick_up[] = { * rct2: 0x00698827 * returns 1 on pickup (CF not set) */ -bool peep_can_be_picked_up(rct_peep* peep) +bool peep_can_be_picked_up(Peep* peep) { return peep_allow_pick_up[peep->state]; } @@ -2159,7 +2149,7 @@ static constexpr const int32_t face_sprite_large[] = { SPR_PEEP_LARGE_FACE_VERY_VERY_HAPPY, }; -static int32_t get_face_sprite_offset(rct_peep* peep) +static int32_t get_face_sprite_offset(Peep* peep) { // ANGRY if (peep->angriness > 0) @@ -2199,7 +2189,7 @@ static int32_t get_face_sprite_offset(rct_peep* peep) * Function split into large and small sprite * rct2: 0x00698721 */ -int32_t get_peep_face_sprite_small(rct_peep* peep) +int32_t get_peep_face_sprite_small(Peep* peep) { return face_sprite_small[get_face_sprite_offset(peep)]; } @@ -2208,7 +2198,7 @@ int32_t get_peep_face_sprite_small(rct_peep* peep) * Function split into large and small sprite * rct2: 0x00698721 */ -int32_t get_peep_face_sprite_large(rct_peep* peep) +int32_t get_peep_face_sprite_large(Peep* peep) { return face_sprite_large[get_face_sprite_offset(peep)]; } @@ -2218,7 +2208,7 @@ int32_t get_peep_face_sprite_large(rct_peep* peep) * rct2: 0x0069A5A0 * tests if a peep's name matches a cheat code, normally returns using a register flag */ -int32_t peep_check_easteregg_name(int32_t index, rct_peep* peep) +int32_t peep_check_easteregg_name(int32_t index, Peep* peep) { char buffer[256]; @@ -2226,7 +2216,7 @@ int32_t peep_check_easteregg_name(int32_t index, rct_peep* peep) return _stricmp(buffer, gPeepEasterEggNames[index]) == 0; } -int32_t peep_get_easteregg_name_id(rct_peep* peep) +int32_t peep_get_easteregg_name_id(Peep* peep) { char buffer[256]; @@ -2246,7 +2236,7 @@ int32_t peep_get_easteregg_name_id(rct_peep* peep) * ah:thought_arguments * esi: peep */ -void peep_insert_new_thought(rct_peep* peep, PeepThoughtType thought_type, uint8_t thought_arguments) +void peep_insert_new_thought(Peep* peep, PeepThoughtType thought_type, uint8_t thought_arguments) { PeepActionType action = PeepThoughtToActionMap[thought_type].action; if (action != PEEP_ACTION_NONE_2 && peep->action >= PEEP_ACTION_NONE_1) @@ -2288,7 +2278,7 @@ void peep_insert_new_thought(rct_peep* peep, PeepThoughtType thought_type, uint8 peep->window_invalidate_flags |= PEEP_INVALIDATE_PEEP_THOUGHTS; } -void peep_set_map_tooltip(rct_peep* peep) +void peep_set_map_tooltip(Peep* peep) { if (peep->type == PEEP_TYPE_GUEST) { @@ -2319,7 +2309,7 @@ void peep_set_map_tooltip(rct_peep* peep) /** * rct2: 0x00693BAB */ -void rct_peep::SwitchNextActionSpriteType() +void Peep::SwitchNextActionSpriteType() { // TBD: Add nextActionSpriteType as function parameter and make peep->next_action_sprite_type obsolete? if (next_action_sprite_type != action_sprite_type) @@ -2338,13 +2328,13 @@ void rct_peep::SwitchNextActionSpriteType() * * rct2: 0x00693CBB */ -static bool peep_update_queue_position(rct_peep* peep, uint8_t previous_action) +static bool peep_update_queue_position(Peep* peep, uint8_t previous_action) { peep->time_in_queue++; if (peep->next_in_queue == SPRITE_INDEX_NULL) return false; - rct_peep* peep_next = GET_PEEP(peep->next_in_queue); + Peep* peep_next = GET_PEEP(peep->next_in_queue); int16_t x_diff = abs(peep_next->x - peep->x); int16_t y_diff = abs(peep_next->y - peep->y); @@ -2411,7 +2401,7 @@ static bool peep_update_queue_position(rct_peep* peep, uint8_t previous_action) * * rct2: 0x00693EF2 */ -static void peep_return_to_centre_of_tile(rct_peep* peep) +static void peep_return_to_centre_of_tile(Peep* peep) { peep->direction = direction_reverse(peep->direction); peep->destination_x = (peep->x & 0xFFE0) + 16; @@ -2423,8 +2413,7 @@ static void peep_return_to_centre_of_tile(rct_peep* peep) * * rct2: 0x00693f2C */ -static void peep_interact_with_entrance( - rct_peep* peep, int16_t x, int16_t y, TileElement* tile_element, uint8_t& pathing_result) +static void peep_interact_with_entrance(Peep* peep, int16_t x, int16_t y, TileElement* tile_element, uint8_t& pathing_result) { uint8_t entranceType = tile_element->AsEntrance()->GetEntranceType(); ride_id_t rideIndex = tile_element->AsEntrance()->GetRideIndex(); @@ -2455,7 +2444,8 @@ static void peep_interact_with_entrance( if (entranceType == ENTRANCE_TYPE_RIDE_ENTRANCE) { - if (peep->type == PEEP_TYPE_STAFF) + auto guest = peep->AsGuest(); + if (guest == nullptr) { // Default staff behaviour attempting to enter a // ride entrance is to turn around. @@ -2488,7 +2478,7 @@ static void peep_interact_with_entrance( // Guest walks up to the ride for the first time since entering // the path tile or since considering another ride attached to // the path tile. - if (!peep->ShouldGoOnRide(ride, stationNum, false, false)) + if (!guest->ShouldGoOnRide(ride, stationNum, false, false)) { // Peep remembers that this is the last ride they // considered while on this path tile. @@ -2527,7 +2517,8 @@ static void peep_interact_with_entrance( else { // PARK_ENTRANCE - if (peep->type == PEEP_TYPE_STAFF) + auto guest = peep->AsGuest(); + if (guest == nullptr) { // Staff cannot leave the park, so go back. peep_return_to_centre_of_tile(peep); @@ -2702,7 +2693,7 @@ static void peep_interact_with_entrance( gTotalIncomeFromAdmissions += entranceFee; gCommandExpenditureType = RCT_EXPENDITURE_TYPE_PARK_ENTRANCE_TICKETS; - peep->SpendMoney(peep->paid_to_enter, entranceFee); + guest->SpendMoney(peep->paid_to_enter, entranceFee); peep->peep_flags |= PEEP_FLAGS_HAS_PAID_FOR_PARK_ENTRY; } @@ -2724,7 +2715,7 @@ static void peep_interact_with_entrance( * * rct2: 0x006946D8 */ -static void peep_footpath_move_forward(rct_peep* peep, int16_t x, int16_t y, TileElement* tile_element, bool vandalism) +static void peep_footpath_move_forward(Peep* peep, int16_t x, int16_t y, TileElement* tile_element, bool vandalism) { peep->next_x = (x & 0xFFE0); peep->next_y = (y & 0xFFE0); @@ -2776,7 +2767,7 @@ static void peep_footpath_move_forward(rct_peep* peep, int16_t x, int16_t y, Til sprite = get_sprite(sprite_id); if (sprite->generic.sprite_identifier == SPRITE_IDENTIFIER_PEEP) { - rct_peep* other_peep = (rct_peep*)sprite; + Peep* other_peep = (Peep*)sprite; if (other_peep->state != PEEP_STATE_WALKING) continue; @@ -2870,7 +2861,7 @@ static void peep_footpath_move_forward(rct_peep* peep, int16_t x, int16_t y, Til * * rct2: 0x0069455E */ -static void peep_interact_with_path(rct_peep* peep, int16_t x, int16_t y, TileElement* tile_element) +static void peep_interact_with_path(Peep* peep, int16_t x, int16_t y, TileElement* tile_element) { // 0x00F1AEE2 bool vandalism_present = false; @@ -2898,7 +2889,8 @@ static void peep_interact_with_path(rct_peep* peep, int16_t x, int16_t y, TileEl } } - if (peep->type == PEEP_TYPE_GUEST && tile_element->AsPath()->IsQueue()) + auto guest = peep->AsGuest(); + if (guest != nullptr && tile_element->AsPath()->IsQueue()) { auto rideIndex = tile_element->AsPath()->GetRideIndex(); if (peep->state == PEEP_STATE_QUEUING) @@ -2914,7 +2906,7 @@ static void peep_interact_with_path(rct_peep* peep, int16_t x, int16_t y, TileEl { // Queue got disconnected from the original ride. peep->interaction_ride_index = 0xFF; - peep->RemoveFromQueue(); + guest->RemoveFromQueue(); peep->SetState(PEEP_STATE_1); peep_footpath_move_forward(peep, x, y, tile_element, vandalism_present); } @@ -2933,7 +2925,7 @@ static void peep_interact_with_path(rct_peep* peep, int16_t x, int16_t y, TileEl /* Peep is approaching the entrance of a ride queue. * Decide whether to go on the ride. */ auto ride = get_ride(rideIndex); - if (ride != nullptr && peep->ShouldGoOnRide(ride, stationNum, true, false)) + if (ride != nullptr && guest->ShouldGoOnRide(ride, stationNum, true, false)) { // Peep has decided to go on the ride at the queue. peep->interaction_ride_index = rideIndex; @@ -2999,7 +2991,7 @@ static void peep_interact_with_path(rct_peep* peep, int16_t x, int16_t y, TileEl * * rct2: 0x00693F70 */ -static bool peep_interact_with_shop(rct_peep* peep, int16_t x, int16_t y, TileElement* tile_element) +static bool peep_interact_with_shop(Peep* peep, int16_t x, int16_t y, TileElement* tile_element) { ride_id_t rideIndex = tile_element->AsTrack()->GetRideIndex(); Ride* ride = get_ride(rideIndex); @@ -3007,7 +2999,8 @@ static bool peep_interact_with_shop(rct_peep* peep, int16_t x, int16_t y, TileEl if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_IS_SHOP)) return false; - if (peep->type == PEEP_TYPE_STAFF) + auto guest = peep->AsGuest(); + if (guest == nullptr) { peep_return_to_centre_of_tile(peep); return true; @@ -3036,7 +3029,7 @@ static bool peep_interact_with_shop(rct_peep* peep, int16_t x, int16_t y, TileEl if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_PEEP_SHOULD_GO_INSIDE_FACILITY)) { peep->time_lost = 0; - if (!peep->ShouldGoOnRide(ride, 0, false, false)) + if (!guest->ShouldGoOnRide(ride, 0, false, false)) { peep_return_to_centre_of_tile(peep); return true; @@ -3051,7 +3044,7 @@ static bool peep_interact_with_shop(rct_peep* peep, int16_t x, int16_t y, TileEl // TODO: Refactor? SpendMoney previously accepted nullptr to not track money, passing a temporary variable as a // workaround money16 money = 0; - peep->SpendMoney(money, cost); + guest->SpendMoney(money, cost); } peep->destination_x = (x & 0xFFE0) + 16; peep->destination_y = (y & 0xFFE0) + 16; @@ -3117,7 +3110,7 @@ bool is_valid_path_z_and_direction(TileElement* tileElement, int32_t currentZ, i return true; } -void rct_peep::PerformNextAction(uint8_t& pathing_result) +void Peep::PerformNextAction(uint8_t& pathing_result) { TileElement* tmpTile; PerformNextAction(pathing_result, tmpTile); @@ -3127,7 +3120,7 @@ void rct_peep::PerformNextAction(uint8_t& pathing_result) * * rct2: 0x00693C9E */ -void rct_peep::PerformNextAction(uint8_t& pathing_result, TileElement*& tile_result) +void Peep::PerformNextAction(uint8_t& pathing_result, TileElement*& tile_result) { pathing_result = 0; PeepActionType previousAction = action; @@ -3146,13 +3139,16 @@ void rct_peep::PerformNextAction(uint8_t& pathing_result, TileElement*& tile_res { pathing_result |= PATHING_DESTINATION_REACHED; uint8_t result = 0; - if (type == PEEP_TYPE_GUEST) + + auto guest = AsGuest(); + if (guest != nullptr) { - result = guest_path_finding(this); + result = guest_path_finding(guest); } else { - result = staff_path_finding(this); + auto staff = AsStaff(); + result = staff_path_finding(staff); } if (result != 0) @@ -3280,7 +3276,7 @@ void rct_peep::PerformNextAction(uint8_t& pathing_result, TileElement*& tile_res * * rct2: 0x0069A98C */ -void peep_reset_pathfind_goal(rct_peep* peep) +void peep_reset_pathfind_goal(Peep* peep) { #if defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 if (gPathFindDebug) @@ -3295,7 +3291,7 @@ void peep_reset_pathfind_goal(rct_peep* peep) peep->pathfind_goal.direction = 0xFF; } -static bool peep_has_valid_xy(rct_peep* peep) +static bool peep_has_valid_xy(Peep* peep) { if (peep->x != LOCATION_NULL) { @@ -3308,9 +3304,9 @@ static bool peep_has_valid_xy(rct_peep* peep) return false; } -using easter_egg_function = void (*)(rct_peep* peep, rct_peep* otherPeep); +using easter_egg_function = void (*)(Guest* peep, Guest* otherPeep); -static void peep_apply_easter_egg_to_nearby_guests(rct_peep* peep, easter_egg_function easter_egg) +static void peep_apply_easter_egg_to_nearby_guests(Guest* peep, easter_egg_function easter_egg) { if (!peep_has_valid_xy(peep)) return; @@ -3319,33 +3315,30 @@ static void peep_apply_easter_egg_to_nearby_guests(rct_peep* peep, easter_egg_fu if (spriteIndex == SPRITE_INDEX_NULL) return; - rct_peep* otherPeep = GET_PEEP(spriteIndex); + auto otherPeep = GET_PEEP(spriteIndex); for (; spriteIndex != SPRITE_INDEX_NULL; spriteIndex = otherPeep->next_in_quadrant) { otherPeep = GET_PEEP(spriteIndex); - - if (otherPeep->sprite_identifier != SPRITE_IDENTIFIER_PEEP) - continue; - - if (otherPeep->type != PEEP_TYPE_GUEST) - continue; - - int32_t zDiff = abs(otherPeep->z - peep->z); - if (zDiff > 32) - continue; - - easter_egg(peep, otherPeep); + auto otheerGuest = otherPeep->AsGuest(); + if (otheerGuest != nullptr) + { + auto zDiff = std::abs(otherPeep->z - peep->z); + if (zDiff <= 32) + { + easter_egg(peep, otheerGuest); + } + } } } -static void peep_give_passing_peeps_purple_clothes([[maybe_unused]] rct_peep* peep, rct_peep* otherPeep) +static void peep_give_passing_peeps_purple_clothes([[maybe_unused]] Guest* peep, Guest* otherPeep) { otherPeep->tshirt_colour = COLOUR_BRIGHT_PURPLE; otherPeep->trousers_colour = COLOUR_BRIGHT_PURPLE; invalidate_sprite_2((rct_sprite*)otherPeep); } -static void peep_give_passing_peeps_pizza(rct_peep* peep, rct_peep* otherPeep) +static void peep_give_passing_peeps_pizza(Guest* peep, Guest* otherPeep) { if ((otherPeep->item_standard_flags & PEEP_ITEM_PIZZA)) return; @@ -3369,7 +3362,7 @@ static void peep_give_passing_peeps_pizza(rct_peep* peep, rct_peep* otherPeep) invalidate_sprite_2((rct_sprite*)otherPeep); } -static void peep_make_passing_peeps_sick(rct_peep* peep, rct_peep* otherPeep) +static void peep_make_passing_peeps_sick(Guest* peep, Guest* otherPeep) { if (peep == otherPeep) return; @@ -3386,7 +3379,7 @@ static void peep_make_passing_peeps_sick(rct_peep* peep, rct_peep* otherPeep) } } -static void peep_give_passing_peeps_ice_cream(rct_peep* peep, rct_peep* otherPeep) +static void peep_give_passing_peeps_ice_cream(Guest* peep, Guest* otherPeep) { if (peep == otherPeep) return; @@ -3401,7 +3394,7 @@ static void peep_give_passing_peeps_ice_cream(rct_peep* peep, rct_peep* otherPee * * rct2: 0x0068FD3A */ -static void peep_easter_egg_peep_interactions(rct_peep* peep) +static void peep_easter_egg_peep_interactions(Guest* peep) { if (peep->peep_flags & PEEP_FLAGS_PURPLE) { @@ -3444,7 +3437,7 @@ static void peep_easter_egg_peep_interactions(rct_peep* peep) * is. * rct2: 0x00694921 */ -int32_t rct_peep::GetZOnSlope(int32_t tile_x, int32_t tile_y) +int32_t Peep::GetZOnSlope(int32_t tile_x, int32_t tile_y) { if (tile_x == LOCATION_NULL) return 0; @@ -3463,7 +3456,7 @@ int32_t rct_peep::GetZOnSlope(int32_t tile_x, int32_t tile_y) * * rct2: 0x0069C483 */ -static void peep_give_real_name(rct_peep* peep) +static void peep_give_real_name(Peep* peep) { // Generate a name_string_idx from the peep id using bit twiddling uint16_t ax = (uint16_t)(peep->id + 0xF0B); @@ -3488,8 +3481,8 @@ static void peep_give_real_name(rct_peep* peep) static int32_t peep_compare(const void* sprite_index_a, const void* sprite_index_b) { - rct_peep const* peep_a = GET_PEEP(*(uint16_t*)sprite_index_a); - rct_peep const* peep_b = GET_PEEP(*(uint16_t*)sprite_index_b); + Peep const* peep_a = GET_PEEP(*(uint16_t*)sprite_index_a); + Peep const* peep_b = GET_PEEP(*(uint16_t*)sprite_index_b); // Compare types if (peep_a->type != peep_b->type) @@ -3543,14 +3536,14 @@ static int32_t peep_compare(const void* sprite_index_a, const void* sprite_index * * rct2: 0x00699115 */ -void peep_update_name_sort(rct_peep* peep) +void peep_update_name_sort(Peep* peep) { // Remove peep from sprite list uint16_t nextSpriteIndex = peep->next; uint16_t prevSpriteIndex = peep->previous; if (prevSpriteIndex != SPRITE_INDEX_NULL) { - rct_peep* prevPeep = GET_PEEP(prevSpriteIndex); + Peep* prevPeep = GET_PEEP(prevSpriteIndex); prevPeep->next = nextSpriteIndex; } else @@ -3560,11 +3553,11 @@ void peep_update_name_sort(rct_peep* peep) if (nextSpriteIndex != SPRITE_INDEX_NULL) { - rct_peep* nextPeep = GET_PEEP(nextSpriteIndex); + Peep* nextPeep = GET_PEEP(nextSpriteIndex); nextPeep->previous = prevSpriteIndex; } - rct_peep* otherPeep; + Peep* otherPeep; uint16_t spriteIndex; FOR_ALL_PEEPS (spriteIndex, otherPeep) { @@ -3579,7 +3572,7 @@ void peep_update_name_sort(rct_peep* peep) otherPeep->previous = peep->sprite_index; if (peep->previous != SPRITE_INDEX_NULL) { - rct_peep* prevPeep = GET_PEEP(peep->previous); + Peep* prevPeep = GET_PEEP(peep->previous); peep->next = prevPeep->next; prevPeep->next = peep->sprite_index; } @@ -3616,7 +3609,7 @@ void peep_sort() { // Count number of peeps uint16_t sprite_index, num_peeps = 0; - rct_peep* peep; + Peep* peep; FOR_ALL_PEEPS (sprite_index, peep) { num_peeps++; @@ -3664,7 +3657,7 @@ void peep_update_names(bool realNames) if (realNames) { gParkFlags |= PARK_FLAGS_SHOW_REAL_GUEST_NAMES; - rct_peep* peep; + Peep* peep; uint16_t spriteIndex; FOR_ALL_GUESTS (spriteIndex, peep) { @@ -3677,7 +3670,7 @@ void peep_update_names(bool realNames) else { gParkFlags &= ~PARK_FLAGS_SHOW_REAL_GUEST_NAMES; - rct_peep* peep; + Peep* peep; uint16_t spriteIndex; FOR_ALL_GUESTS (spriteIndex, peep) { @@ -3692,12 +3685,7 @@ void peep_update_names(bool realNames) gfx_invalidate_screen(); } -bool rct_peep::HeadingForRideOrParkExit() const -{ - return (peep_flags & PEEP_FLAGS_LEAVING_PARK) || (guest_heading_to_ride_id != 0xFF); -} - -void peep_handle_easteregg_name(rct_peep* peep) +void peep_handle_easteregg_name(Peep* peep) { peep->peep_flags &= ~PEEP_FLAGS_WAVING; if (peep_check_easteregg_name(EASTEREGG_PEEP_NAME_KATIE_BRAYSHAW, peep)) @@ -3825,7 +3813,7 @@ void peep_handle_easteregg_name(rct_peep* peep) } #if defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 -void pathfind_logging_enable([[maybe_unused]] rct_peep* peep) +void pathfind_logging_enable([[maybe_unused]] Peep* peep) { # if defined(PATHFIND_DEBUG) && PATHFIND_DEBUG /* Determine if the pathfinding debugging is wanted for this peep. */ @@ -3904,7 +3892,7 @@ void decrement_guests_heading_for_park() } } -static void peep_release_balloon(rct_peep* peep, int16_t spawn_height) +static void peep_release_balloon(Guest* peep, int16_t spawn_height) { if (peep->item_standard_flags & PEEP_ITEM_BALLOON) { @@ -3918,3 +3906,51 @@ static void peep_release_balloon(rct_peep* peep, int16_t spawn_height) } } } + +/** + * + * rct2: 0x006966A9 + */ +void Peep::RemoveFromQueue() +{ + Ride* ride = get_ride(current_ride); + + auto& station = ride->stations[current_ride_station]; + // Make sure we don't underflow, building while paused might reset it to 0 where peeps have + // not yet left the queue. + if (station.QueueLength > 0) + { + station.QueueLength--; + } + + if (sprite_index == station.LastPeepInQueue) + { + station.LastPeepInQueue = next_in_queue; + return; + } + + auto spriteId = station.LastPeepInQueue; + while (spriteId != SPRITE_INDEX_NULL) + { + Peep* other_peep = GET_PEEP(spriteId); + if (sprite_index == other_peep->next_in_queue) + { + other_peep->next_in_queue = next_in_queue; + return; + } + spriteId = other_peep->next_in_queue; + } +} + +/** + * + * rct2: 0x0069A512 + */ +void Peep::RemoveFromRide() +{ + if (state == PEEP_STATE_QUEUING) + { + RemoveFromQueue(); + } + StateReset(); +} diff --git a/src/openrct2/peep/Peep.h b/src/openrct2/peep/Peep.h index 10a1bb140e..1fb258cc98 100644 --- a/src/openrct2/peep/Peep.h +++ b/src/openrct2/peep/Peep.h @@ -528,7 +528,10 @@ struct rct_peep_thought uint8_t fresh_timeout; // 3 updates every tick }; -struct rct_peep : rct_sprite_common +struct Guest; +struct Staff; + +struct Peep : rct_sprite_common { rct_string_id name_string_idx; // 0x22 uint16_t next_x; // 0x24 @@ -686,6 +689,9 @@ struct rct_peep : rct_sprite_common uint32_t item_standard_flags; // 0xFC public: // Peep + Guest* AsGuest(); + Staff* AsStaff(); + void Update(); bool UpdateAction(int16_t* actionX, int16_t* actionY, int16_t* xy_distance); bool UpdateAction(); @@ -703,30 +709,66 @@ public: // Peep void Pickup(); void PickupAbort(int32_t old_x); bool Place(TileCoordsXYZ location, bool apply); - -public: // Guest - void Tick128UpdateGuest(int32_t index); void RemoveFromQueue(); + void RemoveFromRide(); + + // TODO: Make these private again when done refactoring +public: // Peep + bool CheckForPath(); + void PerformNextAction(uint8_t& pathing_result); + void PerformNextAction(uint8_t& pathing_result, TileElement*& tile_result); + int32_t GetZOnSlope(int32_t tile_x, int32_t tile_y); + void SwitchNextActionSpriteType(); + PeepActionSpriteType GetActionSpriteType(); + +private: + void UpdateFalling(); + void Update1(); + void UpdatePicked(); +}; + +struct Guest : Peep +{ +public: + void UpdateGuest(); + void Tick128UpdateGuest(int32_t index); bool HasItem(int32_t peepItem) const; bool HasFood() const; bool HasDrink() const; bool HasEmptyContainer() const; void OnEnterRide(ride_id_t rideIndex); void OnExitRide(ride_id_t rideIndex); - void RemoveFromRide(); void UpdateSpriteType(); bool HeadingForRideOrParkExit() const; + void StopPurchaseThought(uint8_t ride_type); + void TryGetUpFromSitting(); + void ChoseNotToGoOnRide(Ride* ride, bool peepAtRide, bool updateLastRide); + void PickRideToGoOn(); + void ReadMap(); + bool ShouldGoOnRide(Ride* ride, int32_t entranceNum, bool atQueue, bool thinking); + bool ShouldGoToShop(Ride* ride, bool peepAtShop); + bool ShouldFindBench(); + bool UpdateWalkingFindBench(); + bool UpdateWalkingFindBin(); + void SpendMoney(money16& peep_expend_type, money32 amount); + void SpendMoney(money32 amount); + void SetHasRidden(Ride* ride); + bool HasRidden(Ride* ride) const; + void SetHasRiddenRideType(int32_t rideType); + bool HasRiddenRideType(int32_t rideType) const; + int32_t HasFoodStandardFlag() const; + int32_t HasFoodExtraFlag() const; + bool HasDrinkStandardFlag() const; + bool HasDrinkExtraFlag() const; + int32_t HasEmptyContainerStandardFlag() const; + int32_t HasEmptyContainerExtraFlag() const; + void CheckIfLost(); + void CheckCantFindRide(); + void CheckCantFindExit(); + bool DecideAndBuyItem(Ride* ride, int32_t shopItem, money32 price); + void SetSpriteType(PeepSpriteType new_sprite_type); -public: // Staff - void Tick128UpdateStaff(); - bool IsMechanic() const; - -private: // Peep update - void UpdateFalling(); - void Update1(); - void UpdatePicked(); - -private: // Guest update +private: void UpdateRide(); void UpdateOnRide(){}; // TODO void UpdateWalking(); @@ -757,7 +799,18 @@ private: // Guest update void UpdateRideShopInteract(); void UpdateRideShopLeave(); -private: // Staff update + Ride* FindBestRideToGoOn(); + std::bitset FindRidesToGoOn(); +}; + +struct Staff : Peep +{ +public: + void UpdateStaff(uint32_t stepsToTake); + void Tick128UpdateStaff(); + bool IsMechanic() const; + +private: void UpdatePatrolling(); void UpdateMowing(); void UpdateSweeping(); @@ -779,48 +832,6 @@ private: // Staff update bool UpdateFixingLeaveByEntranceExit(bool firstRun, Ride* ride); void UpdateRideInspected(ride_id_t rideIndex); void UpdateHeadingToInspect(); - - // TODO: Make these private again when done refactoring -public: // Peep - bool CheckForPath(); - void PerformNextAction(uint8_t& pathing_result); - void PerformNextAction(uint8_t& pathing_result, TileElement*& tile_result); - int32_t GetZOnSlope(int32_t tile_x, int32_t tile_y); - void SwitchNextActionSpriteType(); - PeepActionSpriteType GetActionSpriteType(); - -public: // Guest - void StopPurchaseThought(uint8_t ride_type); - void TryGetUpFromSitting(); - void ChoseNotToGoOnRide(Ride* ride, bool peepAtRide, bool updateLastRide); - void PickRideToGoOn(); - void ReadMap(); - bool ShouldGoOnRide(Ride* ride, int32_t entranceNum, bool atQueue, bool thinking); - bool ShouldGoToShop(Ride* ride, bool peepAtShop); - bool ShouldFindBench(); - bool UpdateWalkingFindBench(); - bool UpdateWalkingFindBin(); - void SpendMoney(money16& peep_expend_type, money32 amount); - void SpendMoney(money32 amount); - void SetHasRidden(Ride* ride); - bool HasRidden(Ride* ride) const; - void SetHasRiddenRideType(int32_t rideType); - bool HasRiddenRideType(int32_t rideType) const; - int32_t HasFoodStandardFlag() const; - int32_t HasFoodExtraFlag() const; - bool HasDrinkStandardFlag() const; - bool HasDrinkExtraFlag() const; - int32_t HasEmptyContainerStandardFlag() const; - int32_t HasEmptyContainerExtraFlag() const; - void CheckIfLost(); - void CheckCantFindRide(); - void CheckCantFindExit(); - bool DecideAndBuyItem(Ride* ride, int32_t shopItem, money32 price); - void SetSpriteType(PeepSpriteType new_sprite_type); - -private: - Ride* FindBestRideToGoOn(); - std::bitset FindRidesToGoOn(); }; struct rct_sprite_bounds @@ -920,54 +931,54 @@ extern TileCoordsXYZ gPeepPathFindGoalPosition; extern bool gPeepPathFindIgnoreForeignQueues; extern ride_id_t gPeepPathFindQueueRideIndex; -rct_peep* try_get_guest(uint16_t spriteIndex); +Peep* try_get_guest(uint16_t spriteIndex); int32_t peep_get_staff_count(); -bool peep_can_be_picked_up(rct_peep* peep); +bool peep_can_be_picked_up(Peep* peep); void peep_update_all(); void peep_problem_warnings_update(); void peep_stop_crowd_noise(); void peep_update_crowd_noise(); void peep_update_days_in_queue(); void peep_applause(); -rct_peep* peep_generate(int32_t x, int32_t y, int32_t z); -void get_arguments_from_action(rct_peep* peep, uint32_t* argument_1, uint32_t* argument_2); +Peep* peep_generate(int32_t x, int32_t y, int32_t z); +void get_arguments_from_action(Peep* peep, uint32_t* argument_1, uint32_t* argument_2); void peep_thought_set_format_args(rct_peep_thought* thought); -int32_t get_peep_face_sprite_small(rct_peep* peep); -int32_t get_peep_face_sprite_large(rct_peep* peep); -int32_t peep_check_easteregg_name(int32_t index, rct_peep* peep); -int32_t peep_get_easteregg_name_id(rct_peep* peep); +int32_t get_peep_face_sprite_small(Peep* peep); +int32_t get_peep_face_sprite_large(Peep* peep); +int32_t peep_check_easteregg_name(int32_t index, Peep* peep); +int32_t peep_get_easteregg_name_id(Peep* peep); bool peep_pickup_command(uint32_t peepnum, int32_t x, int32_t y, int32_t z, int32_t action, bool apply); void game_command_pickup_guest( int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp); -void peep_sprite_remove(rct_peep* peep); +void peep_sprite_remove(Peep* peep); -void peep_window_state_update(rct_peep* peep); -void peep_decrement_num_riders(rct_peep* peep); +void peep_window_state_update(Peep* peep); +void peep_decrement_num_riders(Peep* peep); /** * rct2: 0x699F5A * al:thought_type * ah:thought_arguments * esi: peep */ -void peep_insert_new_thought(rct_peep* peep, PeepThoughtType thought_type, uint8_t thought_arguments); +void peep_insert_new_thought(Peep* peep, PeepThoughtType thought_type, uint8_t thought_arguments); -void peep_set_map_tooltip(rct_peep* peep); +void peep_set_map_tooltip(Peep* peep); -void SwitchToSpecialSprite(rct_peep* peep, uint8_t special_sprite_id); -void peep_update_name_sort(rct_peep* peep); +void SwitchToSpecialSprite(Peep* peep, uint8_t special_sprite_id); +void peep_update_name_sort(Peep* peep); void peep_sort(); void peep_update_names(bool realNames); void guest_set_name(uint16_t spriteIndex, const char* name); -void peep_handle_easteregg_name(rct_peep* peep); +void peep_handle_easteregg_name(Peep* peep); void game_command_set_guest_name( int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp); -int32_t peep_pathfind_choose_direction(TileCoordsXYZ loc, rct_peep* peep); -void peep_reset_pathfind_goal(rct_peep* peep); +int32_t peep_pathfind_choose_direction(TileCoordsXYZ loc, Peep* peep); +void peep_reset_pathfind_goal(Peep* peep); bool is_valid_path_z_and_direction(TileElement* tileElement, int32_t currentZ, int32_t currentDirection); -int32_t guest_path_finding(rct_peep* peep); +int32_t guest_path_finding(Guest* peep); #if defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 # define PATHFIND_DEBUG \ @@ -979,7 +990,7 @@ extern utf8 gPathFindDebugPeepName[256]; // Use to put the peep name in the log // The following calls set the above two variables for a peep. // ... when PATHFIND_DEBUG is 1 (nonzero) -void pathfind_logging_enable(rct_peep* peep); +void pathfind_logging_enable(Peep* peep); void pathfind_logging_disable(); #endif // defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 diff --git a/src/openrct2/peep/Staff.cpp b/src/openrct2/peep/Staff.cpp index 7afc3eb611..89e9e0351b 100644 --- a/src/openrct2/peep/Staff.cpp +++ b/src/openrct2/peep/Staff.cpp @@ -81,7 +81,7 @@ void staff_reset_modes() staff_update_greyed_patrol_areas(); } -static inline void staff_autoposition_new_staff_member(rct_peep* newPeep) +static inline void staff_autoposition_new_staff_member(Peep* newPeep) { // Find a location to place new staff member @@ -90,7 +90,7 @@ static inline void staff_autoposition_new_staff_member(rct_peep* newPeep) int16_t x, y, z; uint32_t count = 0; uint16_t sprite_index; - rct_peep* guest = nullptr; + Peep* guest = nullptr; TileElement* guest_tile = nullptr; // Count number of walking guests @@ -209,7 +209,7 @@ static money32 staff_hire_new_staff_member( { int32_t newStaffId = i; const rct_sprite_bounds* spriteBounds; - rct_peep* newPeep = &(create_sprite(flags)->peep); + Peep* newPeep = &(create_sprite(flags)->peep); if (newPeep == nullptr) { @@ -249,7 +249,7 @@ static money32 staff_hire_new_staff_member( newPeep->staff_orders = 0; uint16_t idSearchSpriteIndex; - rct_peep* idSearchPeep; + Peep* idSearchPeep; // We search for the first available id for a given staff type uint32_t newStaffIndex = 0; @@ -387,7 +387,7 @@ void game_command_set_staff_patrol( log_warning("Invalid type of sprite %u for game command", sprite_id); return; } - rct_peep* peep = &sprite->peep; + Peep* peep = &sprite->peep; int32_t patrolOffset = peep->staff_id * STAFF_PATROL_AREA_SIZE; staff_toggle_patrol_area(peep->staff_id, x, y); @@ -435,7 +435,7 @@ void game_command_fire_staff_member( *ebx = MONEY32_UNDEFINED; return; } - rct_peep* peep = &get_sprite(sprite_id)->peep; + Peep* peep = &get_sprite(sprite_id)->peep; if (peep->sprite_identifier != SPRITE_IDENTIFIER_PEEP || peep->type != PEEP_TYPE_STAFF) { log_warning( @@ -477,7 +477,7 @@ uint16_t hire_new_staff_member(uint8_t staffType) if ((staffType == STAFF_TYPE_HANDYMAN) && gConfigGeneral.handymen_mow_default) { - rct_peep* newPeep = GET_PEEP(new_sprite_index); + Peep* newPeep = GET_PEEP(new_sprite_index); uint8_t newOrders = newPeep->staff_orders | STAFF_ORDERS_MOWING; auto staffSetOrdersAction = StaffSetOrdersAction(new_sprite_index, newOrders); @@ -493,7 +493,7 @@ uint16_t hire_new_staff_member(uint8_t staffType) */ void staff_update_greyed_patrol_areas() { - rct_peep* peep; + Peep* peep; for (int32_t staff_type = 0; staff_type < STAFF_TYPE_COUNT; ++staff_type) { @@ -520,7 +520,7 @@ void staff_update_greyed_patrol_areas() } } -static bool staff_is_location_in_patrol_area(rct_peep* peep, int32_t x, int32_t y) +static bool staff_is_location_in_patrol_area(Peep* peep, int32_t x, int32_t y) { // Patrol quads are stored in a bit map (8 patrol quads per byte) // Each patrol quad is 4x4 @@ -532,7 +532,7 @@ static bool staff_is_location_in_patrol_area(rct_peep* peep, int32_t x, int32_t * * rct2: 0x006C0905 */ -bool staff_is_location_in_patrol(rct_peep* staff, int32_t x, int32_t y) +bool staff_is_location_in_patrol(Peep* staff, int32_t x, int32_t y) { // Check if location is in the park if (!map_is_location_owned_or_has_rights(x, y)) @@ -545,7 +545,7 @@ bool staff_is_location_in_patrol(rct_peep* staff, int32_t x, int32_t y) return staff_is_location_in_patrol_area(staff, x, y); } -bool staff_is_location_on_patrol_edge(rct_peep* mechanic, int32_t x, int32_t y) +bool staff_is_location_on_patrol_edge(Peep* mechanic, int32_t x, int32_t y) { // Check whether the location x,y is inside and on the edge of the // patrol zone for mechanic. @@ -561,7 +561,7 @@ bool staff_is_location_on_patrol_edge(rct_peep* mechanic, int32_t x, int32_t y) return onZoneEdge; } -bool staff_can_ignore_wide_flag(rct_peep* staff, int32_t x, int32_t y, uint8_t z, TileElement* path) +bool staff_can_ignore_wide_flag(Peep* staff, int32_t x, int32_t y, uint8_t z, TileElement* path) { /* Wide flags can potentially wall off parts of a staff patrol zone * for the heuristic search. @@ -682,7 +682,7 @@ bool staff_can_ignore_wide_flag(rct_peep* staff, int32_t x, int32_t y, uint8_t z * rct2: 0x006C095B * returns 0xF if not in a valid patrol area */ -static uint8_t staff_get_valid_patrol_directions(rct_peep* peep, int16_t x, int16_t y) +static uint8_t staff_get_valid_patrol_directions(Peep* peep, int16_t x, int16_t y) { uint8_t directions = 0; @@ -721,7 +721,7 @@ static uint8_t staff_get_valid_patrol_directions(rct_peep* peep, int16_t x, int1 void staff_reset_stats() { uint16_t spriteIndex; - rct_peep* peep; + Peep* peep; FOR_ALL_STAFF (spriteIndex, peep) { @@ -782,7 +782,7 @@ void staff_toggle_patrol_area(int32_t staffIndex, int32_t x, int32_t y) * * Returns 0xFF when no nearby litter or unpathable litter */ -static uint8_t staff_handyman_direction_to_nearest_litter(rct_peep* peep) +static uint8_t staff_handyman_direction_to_nearest_litter(Peep* peep) { uint16_t nearestLitterDist = (uint16_t)-1; rct_litter* nearestLitter = nullptr; @@ -870,7 +870,7 @@ static uint8_t staff_handyman_direction_to_nearest_litter(rct_peep* peep) * * rct2: 0x006BF931 */ -static uint8_t staff_handyman_direction_to_uncut_grass(rct_peep* peep, uint8_t valid_directions) +static uint8_t staff_handyman_direction_to_uncut_grass(Peep* peep, uint8_t valid_directions) { if (!(peep->GetNextIsSurface())) { @@ -923,7 +923,7 @@ static uint8_t staff_handyman_direction_to_uncut_grass(rct_peep* peep, uint8_t v * * rct2: 0x006BFD9C */ -static int32_t staff_handyman_direction_rand_surface(rct_peep* peep, uint8_t validDirections) +static int32_t staff_handyman_direction_rand_surface(Peep* peep, uint8_t validDirections) { uint8_t direction = scenario_rand() & 3; for (int32_t i = 0; i < 4; ++i, ++direction) @@ -951,7 +951,7 @@ static int32_t staff_handyman_direction_rand_surface(rct_peep* peep, uint8_t val * * rct2: 0x006BFBA8 */ -static bool staff_path_finding_handyman(rct_peep* peep) +static bool staff_path_finding_handyman(Peep* peep) { peep->staff_mowing_timeout++; @@ -1042,7 +1042,7 @@ static bool staff_path_finding_handyman(rct_peep* peep) return false; } -static uint8_t staff_direction_surface(rct_peep* peep, uint8_t initialDirection) +static uint8_t staff_direction_surface(Peep* peep, uint8_t initialDirection) { uint8_t direction = initialDirection; for (int32_t i = 0; i < 3; ++i) @@ -1085,7 +1085,7 @@ static uint8_t staff_direction_surface(rct_peep* peep, uint8_t initialDirection) * * rct2: 0x006BFF45 */ -static uint8_t staff_mechanic_direction_surface(rct_peep* peep) +static uint8_t staff_mechanic_direction_surface(Peep* peep) { uint8_t direction = scenario_rand() & 3; @@ -1121,7 +1121,7 @@ static uint8_t staff_mechanic_direction_surface(rct_peep* peep) * * rct2: 0x006C02D1 */ -static uint8_t staff_mechanic_direction_path_rand(rct_peep* peep, uint8_t pathDirections) +static uint8_t staff_mechanic_direction_path_rand(Peep* peep, uint8_t pathDirections) { if (scenario_rand() & 1) { @@ -1145,7 +1145,7 @@ static uint8_t staff_mechanic_direction_path_rand(rct_peep* peep, uint8_t pathDi * * rct2: 0x006C0121 */ -static uint8_t staff_mechanic_direction_path(rct_peep* peep, uint8_t validDirections, TileElement* pathElement) +static uint8_t staff_mechanic_direction_path(Peep* peep, uint8_t validDirections, TileElement* pathElement) { uint8_t direction = 0xFF; uint8_t pathDirections = pathElement->AsPath()->GetEdges(); @@ -1238,7 +1238,7 @@ static uint8_t staff_mechanic_direction_path(rct_peep* peep, uint8_t validDirect * * rct2: 0x006BFF2C */ -static bool staff_path_finding_mechanic(rct_peep* peep) +static bool staff_path_finding_mechanic(Peep* peep) { uint8_t validDirections = staff_get_valid_patrol_directions(peep, peep->next_x, peep->next_y); uint8_t direction = 0xFF; @@ -1280,7 +1280,7 @@ static bool staff_path_finding_mechanic(rct_peep* peep) * * rct2: 0x006C050B */ -static uint8_t staff_direction_path(rct_peep* peep, uint8_t validDirections, TileElement* pathElement) +static uint8_t staff_direction_path(Peep* peep, uint8_t validDirections, TileElement* pathElement) { uint8_t direction = 0xFF; uint8_t pathDirections = pathElement->AsPath()->GetEdges(); @@ -1325,7 +1325,7 @@ static uint8_t staff_direction_path(rct_peep* peep, uint8_t validDirections, Til * * rct2: 0x006C0351 */ -static bool staff_path_finding_misc(rct_peep* peep) +static bool staff_path_finding_misc(Peep* peep) { uint8_t validDirections = staff_get_valid_patrol_directions(peep, peep->next_x, peep->next_y); @@ -1365,10 +1365,10 @@ static bool staff_path_finding_misc(rct_peep* peep) * * rct2: 0x006C086D */ -static void staff_entertainer_update_nearby_peeps(rct_peep* peep) +static void staff_entertainer_update_nearby_peeps(Peep* peep) { uint16_t spriteIndex; - rct_peep* guest; + Peep* guest; FOR_ALL_GUESTS (spriteIndex, guest) { @@ -1411,7 +1411,7 @@ static void staff_entertainer_update_nearby_peeps(rct_peep* peep) * * rct2: 0x006C05AE */ -static int32_t staff_path_finding_entertainer(rct_peep* peep) +static int32_t staff_path_finding_entertainer(Peep* peep) { if (((scenario_rand() & 0xFFFF) <= 0x4000) && (peep->action == PEEP_ACTION_NONE_1 || peep->action == PEEP_ACTION_NONE_2)) { @@ -1433,7 +1433,7 @@ static int32_t staff_path_finding_entertainer(rct_peep* peep) * * rct2: 0x006BF926 */ -int32_t staff_path_finding(rct_peep* peep) +int32_t staff_path_finding(Staff* peep) { switch (peep->staff_type) { @@ -1552,7 +1552,7 @@ static constexpr const LocationXY16 _MowingWaypoints[] = { * * rct2: 0x006BF567 */ -void rct_peep::UpdateMowing() +void Staff::UpdateMowing() { if (!CheckForPath()) return; @@ -1605,7 +1605,7 @@ void rct_peep::UpdateMowing() * * rct2: 0x006BF7E6 */ -void rct_peep::UpdateWatering() +void Staff::UpdateWatering() { staff_mowing_timeout = 0; if (sub_state == 0) @@ -1668,7 +1668,7 @@ void rct_peep::UpdateWatering() * * rct2: 0x006BF6C9 */ -void rct_peep::UpdateEmptyingBin() +void Staff::UpdateEmptyingBin() { staff_mowing_timeout = 0; @@ -1750,7 +1750,7 @@ void rct_peep::UpdateEmptyingBin() * * rct2: 0x6BF641 */ -void rct_peep::UpdateSweeping() +void Staff::UpdateSweeping() { staff_mowing_timeout = 0; if (!CheckForPath()) @@ -1793,7 +1793,7 @@ void rct_peep::UpdateSweeping() * * rct2: 0x006C16D7 */ -void rct_peep::UpdateHeadingToInspect() +void Staff::UpdateHeadingToInspect() { Ride* ride = get_ride(current_ride); @@ -1906,7 +1906,7 @@ void rct_peep::UpdateHeadingToInspect() * * rct2: 0x006C0CB8 */ -void rct_peep::UpdateAnswering() +void Staff::UpdateAnswering() { Ride* ride = get_ride(current_ride); @@ -2029,7 +2029,7 @@ static constexpr const LocationXY16 _WateringUseOffsets[] = { * * rct2: 0x006BF483 */ -static int32_t peep_update_patrolling_find_watering(rct_peep* peep) +static int32_t peep_update_patrolling_find_watering(Peep* peep) { if (!(peep->staff_orders & STAFF_ORDERS_WATER_FLOWERS)) return 0; @@ -2102,7 +2102,7 @@ static int32_t peep_update_patrolling_find_watering(rct_peep* peep) * * rct2: 0x006BF3A1 */ -static int32_t peep_update_patrolling_find_bin(rct_peep* peep) +static int32_t peep_update_patrolling_find_bin(Peep* peep) { if (!(peep->staff_orders & STAFF_ORDERS_EMPTY_BINS)) return 0; @@ -2165,7 +2165,7 @@ static int32_t peep_update_patrolling_find_bin(rct_peep* peep) * * rct2: 0x006BF322 */ -static int32_t peep_update_patrolling_find_grass(rct_peep* peep) +static int32_t peep_update_patrolling_find_grass(Peep* peep) { if (!(peep->staff_orders & STAFF_ORDERS_MOWING)) return 0; @@ -2197,7 +2197,7 @@ static int32_t peep_update_patrolling_find_grass(rct_peep* peep) * * rct2: 0x006BF295 */ -static int32_t peep_update_patrolling_find_sweeping(rct_peep* peep) +static int32_t peep_update_patrolling_find_sweeping(Peep* peep) { if (!(peep->staff_orders & STAFF_ORDERS_SWEEPING)) return 0; @@ -2227,7 +2227,7 @@ static int32_t peep_update_patrolling_find_sweeping(rct_peep* peep) return 0; } -void rct_peep::Tick128UpdateStaff() +void Staff::Tick128UpdateStaff() { if (staff_type != STAFF_TYPE_SECURITY) return; @@ -2255,16 +2255,54 @@ void rct_peep::Tick128UpdateStaff() UpdateCurrentActionSpriteType(); } -bool rct_peep::IsMechanic() const +bool Staff::IsMechanic() const { return (sprite_identifier == SPRITE_IDENTIFIER_PEEP && type == PEEP_TYPE_STAFF && staff_type == STAFF_TYPE_MECHANIC); } +void Staff::UpdateStaff(uint32_t stepsToTake) +{ + switch (state) + { + case PEEP_STATE_PATROLLING: + UpdatePatrolling(); + break; + case PEEP_STATE_MOWING: + UpdateMowing(); + break; + case PEEP_STATE_SWEEPING: + UpdateSweeping(); + break; + case PEEP_STATE_ANSWERING: + UpdateAnswering(); + break; + case PEEP_STATE_FIXING: + UpdateFixing(stepsToTake); + break; + case PEEP_STATE_INSPECTING: + UpdateFixing(stepsToTake); + break; + case PEEP_STATE_EMPTYING_BIN: + UpdateEmptyingBin(); + break; + case PEEP_STATE_WATERING: + UpdateWatering(); + break; + case PEEP_STATE_HEADING_TO_INSPECTION: + UpdateHeadingToInspect(); + break; + default: + // TODO reset to default state + assert(false); + break; + } +} + /** * * rct2: 0x006BF1FD */ -void rct_peep::UpdatePatrolling() +void Staff::UpdatePatrolling() { if (!CheckForPath()) return; @@ -2414,7 +2452,7 @@ static constexpr const uint32_t FixingSubstatesForBreakdown[9] = { * rct2: 0x006C0E8B * Also used by inspecting. */ -void rct_peep::UpdateFixing(int32_t steps) +void Staff::UpdateFixing(int32_t steps) { Ride* ride = get_ride(current_ride); @@ -2524,7 +2562,7 @@ void rct_peep::UpdateFixing(int32_t steps) * rct2: 0x006C0EEC * fixing sub_state: enter_station - applies to fixing all break down reasons and ride inspections. */ -bool rct_peep::UpdateFixingEnterStation(Ride* ride) +bool Staff::UpdateFixingEnterStation(Ride* ride) { ride->mechanic_status = RIDE_MECHANIC_STATUS_FIXING; ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_MAINTENANCE; @@ -2537,7 +2575,7 @@ bool rct_peep::UpdateFixingEnterStation(Ride* ride) * fixing sub_state: move_to_broken_down_vehicle - applies to fixing all vehicle specific breakdown reasons * - see FixingSubstatesForBreakdown[] */ -bool rct_peep::UpdateFixingMoveToBrokenDownVehicle(bool firstRun, Ride* ride) +bool Staff::UpdateFixingMoveToBrokenDownVehicle(bool firstRun, Ride* ride) { if (!firstRun) { @@ -2600,7 +2638,7 @@ bool rct_peep::UpdateFixingMoveToBrokenDownVehicle(bool firstRun, Ride* ride) * 4. doors stuck open. * - see FixingSubstatesForBreakdown[] */ -bool rct_peep::UpdateFixingFixVehicle(bool firstRun, Ride* ride) +bool Staff::UpdateFixingFixVehicle(bool firstRun, Ride* ride) { if (!firstRun) { @@ -2642,7 +2680,7 @@ bool rct_peep::UpdateFixingFixVehicle(bool firstRun, Ride* ride) * fixing sub_state: fix_vehicle_malfunction - applies fixing to vehicle malfunction. * - see FixingSubstatesForBreakdown[] */ -bool rct_peep::UpdateFixingFixVehicleMalfunction(bool firstRun, Ride* ride) +bool Staff::UpdateFixingFixVehicleMalfunction(bool firstRun, Ride* ride) { if (!firstRun) { @@ -2691,7 +2729,7 @@ static constexpr const CoordsXY _StationFixingOffsets[] = { * inspection. * - see FixingSubstatesForBreakdown[] */ -bool rct_peep::UpdateFixingMoveToStationEnd(bool firstRun, Ride* ride) +bool Staff::UpdateFixingMoveToStationEnd(bool firstRun, Ride* ride) { if (!firstRun) { @@ -2756,7 +2794,7 @@ bool rct_peep::UpdateFixingMoveToStationEnd(bool firstRun, Ride* ride) * inspection. * - see FixingSubstatesForBreakdown[] */ -bool rct_peep::UpdateFixingFixStationEnd(bool firstRun) +bool Staff::UpdateFixingFixStationEnd(bool firstRun) { if (!firstRun) { @@ -2787,7 +2825,7 @@ bool rct_peep::UpdateFixingFixStationEnd(bool firstRun) * 3. applies to inspection. * - see FixingSubstatesForBreakdown[] */ -bool rct_peep::UpdateFixingMoveToStationStart(bool firstRun, Ride* ride) +bool Staff::UpdateFixingMoveToStationStart(bool firstRun, Ride* ride) { if (!firstRun) { @@ -2873,7 +2911,7 @@ bool rct_peep::UpdateFixingMoveToStationStart(bool firstRun, Ride* ride) * 2. applies to inspection. * - see FixingSubstatesForBreakdown[] */ -bool rct_peep::UpdateFixingFixStationStart(bool firstRun, Ride* ride) +bool Staff::UpdateFixingFixStationStart(bool firstRun, Ride* ride) { if (!firstRun) { @@ -2907,7 +2945,7 @@ bool rct_peep::UpdateFixingFixStationStart(bool firstRun, Ride* ride) * fixing sub_state: fix_station_brakes - applies to fixing brake failure * - see FixingSubstatesForBreakdown[] */ -bool rct_peep::UpdateFixingFixStationBrakes(bool firstRun, Ride* ride) +bool Staff::UpdateFixingFixStationBrakes(bool firstRun, Ride* ride) { if (!firstRun) { @@ -2946,7 +2984,7 @@ bool rct_peep::UpdateFixingFixStationBrakes(bool firstRun, Ride* ride) * fixing sub_state: move_to_station_exit - applies to fixing all failures & inspections * - see FixingSubstatesForBreakdown[] */ -bool rct_peep::UpdateFixingMoveToStationExit(bool firstRun, Ride* ride) +bool Staff::UpdateFixingMoveToStationExit(bool firstRun, Ride* ride) { if (!firstRun) { @@ -2996,7 +3034,7 @@ bool rct_peep::UpdateFixingMoveToStationExit(bool firstRun, Ride* ride) * fixing sub_state: finish_fix_or_inspect - applies to fixing all failures & inspections * - see FixingSubstatesForBreakdown[] */ -bool rct_peep::UpdateFixingFinishFixOrInspect(bool firstRun, int32_t steps, Ride* ride) +bool Staff::UpdateFixingFinishFixOrInspect(bool firstRun, int32_t steps, Ride* ride) { if (!firstRun) { @@ -3040,7 +3078,7 @@ bool rct_peep::UpdateFixingFinishFixOrInspect(bool firstRun, int32_t steps, Ride * fixing sub_state: leave_by_entrance_exit - applies to fixing all failures & inspections * - see FixingSubstatesForBreakdown[] */ -bool rct_peep::UpdateFixingLeaveByEntranceExit(bool firstRun, Ride* ride) +bool Staff::UpdateFixingLeaveByEntranceExit(bool firstRun, Ride* ride) { if (!firstRun) { @@ -3095,7 +3133,7 @@ bool rct_peep::UpdateFixingLeaveByEntranceExit(bool firstRun, Ride* ride) /** * rct2: 0x6B7588 */ -void rct_peep::UpdateRideInspected(ride_id_t rideIndex) +void Staff::UpdateRideInspected(ride_id_t rideIndex) { Ride* ride = get_ride(rideIndex); ride->lifecycle_flags &= ~RIDE_LIFECYCLE_DUE_INSPECTION; diff --git a/src/openrct2/peep/Staff.h b/src/openrct2/peep/Staff.h index cc402fe369..61c15896a3 100644 --- a/src/openrct2/peep/Staff.h +++ b/src/openrct2/peep/Staff.h @@ -88,10 +88,10 @@ void staff_reset_modes(); void staff_set_name(uint16_t spriteIndex, const char* name); uint16_t hire_new_staff_member(uint8_t staffType); void staff_update_greyed_patrol_areas(); -bool staff_is_location_in_patrol(rct_peep* mechanic, int32_t x, int32_t y); -bool staff_is_location_on_patrol_edge(rct_peep* mechanic, int32_t x, int32_t y); -bool staff_can_ignore_wide_flag(rct_peep* mechanic, int32_t x, int32_t y, uint8_t z, TileElement* path); -int32_t staff_path_finding(rct_peep* peep); +bool staff_is_location_in_patrol(Peep* mechanic, int32_t x, int32_t y); +bool staff_is_location_on_patrol_edge(Peep* mechanic, int32_t x, int32_t y); +bool staff_can_ignore_wide_flag(Peep* mechanic, int32_t x, int32_t y, uint8_t z, TileElement* path); +int32_t staff_path_finding(Staff* peep); void staff_reset_stats(); bool staff_is_patrol_area_set(int32_t staffIndex, int32_t x, int32_t y); void staff_set_patrol_area(int32_t staffIndex, int32_t x, int32_t y, bool value); diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 0e26ceff9a..27317c6021 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -1343,7 +1343,7 @@ private: if (_s4.sprites[i].unknown.sprite_identifier == SPRITE_IDENTIFIER_PEEP) { rct1_peep* srcPeep = &_s4.sprites[i].peep; - rct_peep* peep = (rct_peep*)create_sprite(SPRITE_IDENTIFIER_PEEP); + Peep* peep = (Peep*)create_sprite(SPRITE_IDENTIFIER_PEEP); move_sprite_to_list((rct_sprite*)peep, SPRITE_LIST_PEEP * 2); spriteIndexMap[i] = peep->sprite_index; @@ -1362,7 +1362,7 @@ private: int i; Ride* ride; - rct_peep* peep; + Peep* peep; FOR_ALL_RIDES (i, ride) { @@ -1399,7 +1399,7 @@ private: staff_update_greyed_patrol_areas(); } - void ImportPeep(rct_peep* dst, rct1_peep* src) + void ImportPeep(Peep* dst, rct1_peep* src) { dst->sprite_identifier = SPRITE_IDENTIFIER_PEEP; // Peep vs. staff (including which kind) @@ -1605,12 +1605,12 @@ private: } } - void FixPeepNextInQueue(rct_peep* peep, const uint16_t* spriteIndexMap) + void FixPeepNextInQueue(Peep* peep, const uint16_t* spriteIndexMap) { peep->next_in_queue = MapSpriteIndex(peep->next_in_queue, spriteIndexMap); } - void ImportStaffPatrolArea(rct_peep* staffmember) + void ImportStaffPatrolArea(Peep* staffmember) { // The patrol areas in RCT1 are encoded as follows, for coordinates x and y, separately for every staff member: // - Chop off the 7 lowest bits of the x and y coordinates, which leaves 5 bits per coordinate. diff --git a/src/openrct2/rct2/S6Exporter.cpp b/src/openrct2/rct2/S6Exporter.cpp index cb59affa99..4c1bd51531 100644 --- a/src/openrct2/rct2/S6Exporter.cpp +++ b/src/openrct2/rct2/S6Exporter.cpp @@ -888,7 +888,7 @@ void S6Exporter::ExportSpriteVehicle(RCT2SpriteVehicle* dst, const rct_vehicle* dst->target_seat_rotation = src->target_seat_rotation; } -void S6Exporter::ExportSpritePeep(RCT2SpritePeep* dst, const rct_peep* src) +void S6Exporter::ExportSpritePeep(RCT2SpritePeep* dst, const Peep* src) { ExportSpriteCommonProperties(dst, (const rct_sprite_common*)src); dst->name_string_idx = src->name_string_idx; diff --git a/src/openrct2/rct2/S6Exporter.h b/src/openrct2/rct2/S6Exporter.h index 873d374de9..5c167a2b3a 100644 --- a/src/openrct2/rct2/S6Exporter.h +++ b/src/openrct2/rct2/S6Exporter.h @@ -42,7 +42,7 @@ public: void ExportSprite(RCT2Sprite* dst, const rct_sprite* src); void ExportSpriteCommonProperties(RCT12SpriteBase* dst, const rct_sprite_common* src); void ExportSpriteVehicle(RCT2SpriteVehicle* dst, const rct_vehicle* src); - void ExportSpritePeep(RCT2SpritePeep* dst, const rct_peep* src); + void ExportSpritePeep(RCT2SpritePeep* dst, const Peep* src); void ExportSpriteMisc(RCT12SpriteBase* dst, const rct_sprite_common* src); void ExportSpriteLitter(RCT12SpriteLitter* dst, const rct_litter* src); diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index 44d5826a3d..1479dbd471 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -1152,7 +1152,7 @@ public: dst->target_seat_rotation = src->target_seat_rotation; } - void ImportSpritePeep(rct_peep* dst, const RCT2SpritePeep* src) + void ImportSpritePeep(Peep* dst, const RCT2SpritePeep* src) { ImportSpriteCommonProperties((rct_sprite_common*)dst, src); dst->name_string_idx = src->name_string_idx; diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index fce1cd6bc0..708d7f64ae 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -200,11 +200,11 @@ uint8_t gRideEntranceExitPlaceDirection; uint8_t gLastEntranceStyle; // Static function declarations -rct_peep* find_closest_mechanic(int32_t x, int32_t y, int32_t forInspection); +Peep* find_closest_mechanic(int32_t x, int32_t y, int32_t forInspection); static void ride_breakdown_status_update(Ride* ride); static void ride_breakdown_update(Ride* ride); static void ride_call_closest_mechanic(Ride* ride); -static void ride_call_mechanic(Ride* ride, rct_peep* mechanic, int32_t forInspection); +static void ride_call_mechanic(Ride* ride, Peep* mechanic, int32_t forInspection); static void ride_chairlift_update(Ride* ride); static void ride_entrance_exit_connected(Ride* ride); static void ride_set_name_to_vehicle_default(Ride* ride, rct_ride_entry* rideEntry); @@ -362,10 +362,10 @@ int32_t ride_get_max_queue_time(Ride* ride) return (int32_t)queueTime; } -rct_peep* ride_get_queue_head_guest(Ride* ride, int32_t stationIndex) +Peep* ride_get_queue_head_guest(Ride* ride, int32_t stationIndex) { - rct_peep* peep; - rct_peep* result = nullptr; + Peep* peep; + Peep* result = nullptr; uint16_t spriteIndex = ride->stations[stationIndex].LastPeepInQueue; while ((peep = try_get_guest(spriteIndex)) != nullptr) { @@ -378,7 +378,7 @@ rct_peep* ride_get_queue_head_guest(Ride* ride, int32_t stationIndex) static void ride_update_queue_length(Ride* ride, int32_t stationIndex) { uint16_t count = 0; - rct_peep* peep; + Peep* peep; uint16_t spriteIndex = ride->stations[stationIndex].LastPeepInQueue; while ((peep = try_get_guest(spriteIndex)) != nullptr) { @@ -388,14 +388,14 @@ static void ride_update_queue_length(Ride* ride, int32_t stationIndex) ride->stations[stationIndex].QueueLength = count; } -void ride_queue_insert_guest_at_front(Ride* ride, int32_t stationIndex, rct_peep* peep) +void ride_queue_insert_guest_at_front(Ride* ride, int32_t stationIndex, Peep* peep) { assert(ride != nullptr); assert(stationIndex < MAX_STATIONS); assert(peep != nullptr); peep->next_in_queue = SPRITE_INDEX_NULL; - rct_peep* queueHeadGuest = ride_get_queue_head_guest(ride, peep->current_ride_station); + Peep* queueHeadGuest = ride_get_queue_head_guest(ride, peep->current_ride_station); if (queueHeadGuest == nullptr) { ride->stations[peep->current_ride_station].LastPeepInQueue = peep->sprite_index; @@ -416,7 +416,7 @@ void ride_update_favourited_stat() int32_t i; Ride* ride; uint16_t spriteIndex; - rct_peep* peep; + Peep* peep; FOR_ALL_RIDES (i, ride) ride->guests_favourite = 0; @@ -909,7 +909,7 @@ void ride_get_status(const Ride* ride, rct_string_id* formatSecondary, int32_t* if (ride->mode == RIDE_MODE_RACE && !(ride->lifecycle_flags & RIDE_LIFECYCLE_PASS_STATION_NO_STOPPING) && ride->race_winner != SPRITE_INDEX_NULL && (GET_PEEP(ride->race_winner))->sprite_identifier == SPRITE_IDENTIFIER_PEEP) { - rct_peep* peep = GET_PEEP(ride->race_winner); + Peep* peep = GET_PEEP(ride->race_winner); if (peep->name_string_idx == STR_GUEST_X) { *argument = peep->id; @@ -1184,7 +1184,7 @@ void ride_remove_peeps(Ride* ride) // Place all the peeps at exit uint16_t spriteIndex; - rct_peep* peep; + Peep* peep; FOR_ALL_PEEPS (spriteIndex, peep) { if (peep->state == PEEP_STATE_QUEUING_FRONT || peep->state == PEEP_STATE_ENTERING_RIDE @@ -2330,7 +2330,7 @@ static void ride_spiral_slide_update(Ride* ride) { ride->slide_in_use--; - rct_peep* peep = GET_PEEP(ride->slide_peep); + Peep* peep = GET_PEEP(ride->slide_peep); peep->destination_x++; } @@ -2736,8 +2736,6 @@ static void ride_breakdown_status_update(Ride* ride) */ static void ride_mechanic_status_update(Ride* ride, int32_t mechanicStatus) { - rct_peep* mechanic; - // Turn a pending breakdown into a breakdown. if ((mechanicStatus == RIDE_MECHANIC_STATUS_UNDEFINED || mechanicStatus == RIDE_MECHANIC_STATUS_CALLING || mechanicStatus == RIDE_MECHANIC_STATUS_HEADING) @@ -2773,12 +2771,9 @@ static void ride_mechanic_status_update(Ride* ride, int32_t mechanicStatus) ride_call_closest_mechanic(ride); break; case RIDE_MECHANIC_STATUS_HEADING: - mechanic = nullptr; - if (ride->mechanic != SPRITE_INDEX_NULL) - { - mechanic = &(get_sprite(ride->mechanic)->peep); - } - if (mechanic == nullptr || !mechanic->IsMechanic() + { + auto mechanic = ride_get_mechanic(ride); + if (mechanic == nullptr || (mechanic->state != PEEP_STATE_HEADING_TO_INSPECTION && mechanic->state != PEEP_STATE_ANSWERING) || mechanic->current_ride != ride->id) { @@ -2787,13 +2782,11 @@ static void ride_mechanic_status_update(Ride* ride, int32_t mechanicStatus) ride_mechanic_status_update(ride, RIDE_MECHANIC_STATUS_CALLING); } break; + } case RIDE_MECHANIC_STATUS_FIXING: - mechanic = nullptr; - if (ride->mechanic != SPRITE_INDEX_NULL) - { - mechanic = &(get_sprite(ride->mechanic)->peep); - } - if (mechanic == nullptr || !mechanic->IsMechanic() + { + auto mechanic = ride_get_mechanic(ride); + if (mechanic == nullptr || (mechanic->state != PEEP_STATE_HEADING_TO_INSPECTION && mechanic->state != PEEP_STATE_FIXING && mechanic->state != PEEP_STATE_INSPECTING && mechanic->state != PEEP_STATE_ANSWERING)) { @@ -2802,6 +2795,7 @@ static void ride_mechanic_status_update(Ride* ride, int32_t mechanicStatus) ride_mechanic_status_update(ride, RIDE_MECHANIC_STATUS_CALLING); } break; + } } } @@ -2809,7 +2803,7 @@ static void ride_mechanic_status_update(Ride* ride, int32_t mechanicStatus) * * rct2: 0x006B796C */ -static void ride_call_mechanic(Ride* ride, rct_peep* mechanic, int32_t forInspection) +static void ride_call_mechanic(Ride* ride, Peep* mechanic, int32_t forInspection) { mechanic->SetState(forInspection ? PEEP_STATE_HEADING_TO_INSPECTION : PEEP_STATE_ANSWERING); mechanic->sub_state = 0; @@ -2832,7 +2826,7 @@ static void ride_call_closest_mechanic(Ride* ride) ride_call_mechanic(ride, mechanic, forInspection); } -rct_peep* ride_find_closest_mechanic(Ride* ride, int32_t forInspection) +Peep* ride_find_closest_mechanic(Ride* ride, int32_t forInspection) { int32_t x, y, z, stationIndex; TileCoordsXYZD location; @@ -2871,11 +2865,11 @@ rct_peep* ride_find_closest_mechanic(Ride* ride, int32_t forInspection) * rct2: 0x006B774B (forInspection = 0) * rct2: 0x006B78C3 (forInspection = 1) */ -rct_peep* find_closest_mechanic(int32_t x, int32_t y, int32_t forInspection) +Peep* find_closest_mechanic(int32_t x, int32_t y, int32_t forInspection) { uint32_t closestDistance, distance; uint16_t spriteIndex; - rct_peep *peep, *closestMechanic = nullptr; + Peep *peep, *closestMechanic = nullptr; closestDistance = UINT_MAX; FOR_ALL_STAFF (spriteIndex, peep) @@ -2921,16 +2915,27 @@ rct_peep* find_closest_mechanic(int32_t x, int32_t y, int32_t forInspection) return closestMechanic; } -rct_peep* ride_get_assigned_mechanic(Ride* ride) +Staff* ride_get_mechanic(Ride* ride) +{ + if (ride->mechanic != SPRITE_INDEX_NULL) + { + auto peep = (&(get_sprite(ride->mechanic)->peep))->AsStaff(); + if (peep != nullptr && peep->IsMechanic()) + { + return peep; + } + } + return nullptr; +} + +Staff* ride_get_assigned_mechanic(Ride* ride) { if (ride->lifecycle_flags & RIDE_LIFECYCLE_BROKEN_DOWN) { if (ride->mechanic_status == RIDE_MECHANIC_STATUS_HEADING || ride->mechanic_status == RIDE_MECHANIC_STATUS_FIXING || ride->mechanic_status == RIDE_MECHANIC_STATUS_HAS_FIXED_STATION_BRAKES) { - rct_peep* peep = &(get_sprite(ride->mechanic)->peep); - if (peep->IsMechanic()) - return peep; + return ride_get_mechanic(ride); } } @@ -5793,7 +5798,7 @@ int32_t ride_get_refund_price(const Ride* ride) void ride_stop_peeps_queuing(Ride* ride) { uint16_t spriteIndex; - rct_peep* peep; + Peep* peep; FOR_ALL_PEEPS (spriteIndex, peep) { diff --git a/src/openrct2/ride/Ride.h b/src/openrct2/ride/Ride.h index a5729f007a..52c6c72100 100644 --- a/src/openrct2/ride/Ride.h +++ b/src/openrct2/ride/Ride.h @@ -20,7 +20,8 @@ interface IObjectManager; class StationObject; -struct rct_peep; +struct Peep; +struct Staff; #define MAX_RIDE_TYPES_PER_RIDE_ENTRY 3 // The max number of different types of vehicle. @@ -998,8 +999,8 @@ int32_t ride_get_default_mode(Ride* ride); int32_t ride_get_count(); int32_t ride_get_total_queue_length(Ride* ride); int32_t ride_get_max_queue_time(Ride* ride); -rct_peep* ride_get_queue_head_guest(Ride* ride, int32_t stationIndex); -void ride_queue_insert_guest_at_front(Ride* ride, int32_t stationIndex, rct_peep* peep); +Peep* ride_get_queue_head_guest(Ride* ride, int32_t stationIndex); +void ride_queue_insert_guest_at_front(Ride* ride, int32_t stationIndex, Peep* peep); void ride_init_all(); void reset_all_ride_build_dates(); void ride_update_favourited_stat(); @@ -1015,7 +1016,8 @@ int32_t ride_modify(CoordsXYE* input); void ride_remove_peeps(Ride* ride); void ride_clear_blocked_tiles(Ride* ride); void ride_get_status(const Ride* ride, rct_string_id* formatSecondary, int32_t* argument); -rct_peep* ride_get_assigned_mechanic(Ride* ride); +Staff* ride_get_mechanic(Ride* ride); +Staff* ride_get_assigned_mechanic(Ride* ride); int32_t ride_get_total_length(Ride* ride); int32_t ride_get_total_time(Ride* ride); int32_t ride_can_have_multiple_circuits(Ride* ride); @@ -1030,7 +1032,7 @@ void ride_measurement_clear(Ride* ride); void ride_measurements_update(); rct_ride_measurement* ride_get_measurement(Ride* ride, rct_string_id* message); void ride_breakdown_add_news_item(Ride* ride); -rct_peep* ride_find_closest_mechanic(Ride* ride, int32_t forInspection); +Peep* ride_find_closest_mechanic(Ride* ride, int32_t forInspection); int32_t ride_is_valid_for_open(Ride* ride, int32_t goingToBeOpen, int32_t isApplying); int32_t ride_is_valid_for_test(Ride* ride, int32_t goingToBeOpen, int32_t isApplying); int32_t ride_initialise_construction_window(Ride* ride); diff --git a/src/openrct2/ride/Station.cpp b/src/openrct2/ride/Station.cpp index c76b106b15..0953e28283 100644 --- a/src/openrct2/ride/Station.cpp +++ b/src/openrct2/ride/Station.cpp @@ -207,7 +207,7 @@ static void ride_update_station_race(Ride* ride, int32_t stationIndex) // Found a winner if (vehicle->num_peeps != 0) { - rct_peep* peep = GET_PEEP(vehicle->peep[0]); + Peep* peep = GET_PEEP(vehicle->peep[0]); ride->race_winner = peep->sprite_index; ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_MAIN | RIDE_INVALIDATE_RIDE_LIST; } @@ -282,7 +282,7 @@ static void ride_race_init_vehicle_speeds(Ride* ride) if (vehicle->num_peeps != 0) { - rct_peep* peep = &get_sprite(vehicle->peep[0])->peep; + Peep* peep = &get_sprite(vehicle->peep[0])->peep; switch (peep_get_easteregg_name_id(peep)) { diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index f195d657de..60ca4ad27f 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -3032,7 +3032,7 @@ void vehicle_peep_easteregg_here_we_are(const rct_vehicle* vehicle) vehicle = GET_VEHICLE(spriteId); for (int32_t i = 0; i < vehicle->num_peeps; ++i) { - rct_peep* peep = GET_PEEP(vehicle->peep[i]); + Peep* peep = GET_PEEP(vehicle->peep[i]); if (peep->peep_flags & PEEP_FLAGS_HERE_WE_ARE) { peep_insert_new_thought(peep, PEEP_THOUGHT_TYPE_HERE_WE_ARE, peep->current_ride); @@ -4075,7 +4075,7 @@ static void vehicle_update_unloading_passengers(rct_vehicle* vehicle) { vehicle->next_free_seat -= 2; - rct_peep* peep = GET_PEEP(vehicle->peep[seat * 2]); + Peep* peep = GET_PEEP(vehicle->peep[seat * 2]); vehicle->peep[seat * 2] = SPRITE_INDEX_NULL; peep->SetState(PEEP_STATE_LEAVING_RIDE); @@ -4119,7 +4119,7 @@ static void vehicle_update_unloading_passengers(rct_vehicle* vehicle) train->next_free_seat = 0; for (uint8_t peepIndex = 0; peepIndex < train->num_peeps; peepIndex++) { - rct_peep* peep = GET_PEEP(train->peep[peepIndex]); + Peep* peep = GET_PEEP(train->peep[peepIndex]); peep->SetState(PEEP_STATE_LEAVING_RIDE); peep->sub_state = PEEP_RIDE_LEAVE_VEHICLE; } @@ -5239,7 +5239,7 @@ static void vehicle_kill_all_passengers(rct_vehicle* vehicle) for (uint8_t i = 0; i < curVehicle->num_peeps; i++) { - rct_peep* peep = GET_PEEP(curVehicle->peep[i]); + Peep* peep = GET_PEEP(curVehicle->peep[i]); if (peep->outside_of_park == 0) { decrement_guests_in_park(); @@ -8956,7 +8956,7 @@ loc_6DC743: { if (z == 2) { - rct_peep* peep = GET_PEEP(vehicle->peep[0]); + Peep* peep = GET_PEEP(vehicle->peep[0]); if (peep->id & 7) { z = 7; @@ -8964,7 +8964,7 @@ loc_6DC743: } if (z == 6) { - rct_peep* peep = GET_PEEP(vehicle->peep[0]); + Peep* peep = GET_PEEP(vehicle->peep[0]); if (peep->id & 7) { z = 8; diff --git a/src/openrct2/ride/gentle/FerrisWheel.cpp b/src/openrct2/ride/gentle/FerrisWheel.cpp index 95e69c0617..1bd1c6537b 100644 --- a/src/openrct2/ride/gentle/FerrisWheel.cpp +++ b/src/openrct2/ride/gentle/FerrisWheel.cpp @@ -112,7 +112,7 @@ static void paint_ferris_wheel_structure( continue; } - rct_peep* peep = GET_PEEP(vehicle->peep[i]); + Peep* peep = GET_PEEP(vehicle->peep[i]); if (peep->state != PEEP_STATE_ON_RIDE) { continue; diff --git a/src/openrct2/ride/gentle/SpaceRings.cpp b/src/openrct2/ride/gentle/SpaceRings.cpp index 5bc37fc6af..0aeb20390f 100644 --- a/src/openrct2/ride/gentle/SpaceRings.cpp +++ b/src/openrct2/ride/gentle/SpaceRings.cpp @@ -71,7 +71,7 @@ static void paint_space_rings_structure(paint_session* session, Ride* ride, uint if (vehicle != nullptr && vehicle->num_peeps > 0) { - rct_peep* rider = GET_PEEP(vehicle->peep[0]); + Peep* rider = GET_PEEP(vehicle->peep[0]); imageColourFlags = SPRITE_ID_PALETTE_COLOUR_2(rider->tshirt_colour, rider->trousers_colour); imageId = ((baseImageId & 0x7FFFF) + 352 + frameNum) | imageColourFlags; sub_98199C(session, imageId, 0, 0, 20, 20, 23, height, -10, -10, height); diff --git a/src/openrct2/windows/_legacy.cpp b/src/openrct2/windows/_legacy.cpp index b3bced6709..dea46e7649 100644 --- a/src/openrct2/windows/_legacy.cpp +++ b/src/openrct2/windows/_legacy.cpp @@ -67,7 +67,7 @@ void game_command_callback_hire_new_staff_member( } else { - rct_peep* peep = &get_sprite(sprite_index)->peep; + Peep* peep = &get_sprite(sprite_index)->peep; auto intent = Intent(WC_PEEP); intent.putExtra(INTENT_EXTRA_PEEP, peep); context_open_intent(&intent); diff --git a/src/openrct2/world/Footpath.cpp b/src/openrct2/world/Footpath.cpp index d6e57919f0..6b4c100d4c 100644 --- a/src/openrct2/world/Footpath.cpp +++ b/src/openrct2/world/Footpath.cpp @@ -1026,7 +1026,7 @@ void footpath_interrupt_peeps(int32_t x, int32_t y, int32_t z) uint16_t spriteIndex = sprite_get_first_in_quadrant(x, y); while (spriteIndex != SPRITE_INDEX_NULL) { - rct_peep* peep = &get_sprite(spriteIndex)->peep; + Peep* peep = &get_sprite(spriteIndex)->peep; uint16_t nextSpriteIndex = peep->next_in_quadrant; if (peep->linked_list_type_offset == SPRITE_LIST_PEEP * 2) { diff --git a/src/openrct2/world/MapAnimation.cpp b/src/openrct2/world/MapAnimation.cpp index 137ab74bd0..84ee86c4a2 100644 --- a/src/openrct2/world/MapAnimation.cpp +++ b/src/openrct2/world/MapAnimation.cpp @@ -173,7 +173,7 @@ static bool map_animation_invalidate_small_scenery(int32_t x, int32_t y, int32_t TileElement* tileElement; rct_scenery_entry* sceneryEntry; rct_sprite* sprite; - rct_peep* peep; + Peep* peep; tileElement = map_get_first_element_at(x >> 5, y >> 5); do diff --git a/src/openrct2/world/Park.cpp b/src/openrct2/world/Park.cpp index e1112e3e86..ea5c163742 100644 --- a/src/openrct2/world/Park.cpp +++ b/src/openrct2/world/Park.cpp @@ -660,7 +660,7 @@ int32_t Park::CalculateParkRating() const int32_t happyGuestCount = 0; int32_t lostGuestCount = 0; uint16_t spriteIndex; - rct_peep* peep; + Peep* peep; FOR_ALL_GUESTS (spriteIndex, peep) { if (peep->outside_of_park == 0) @@ -976,7 +976,7 @@ void Park::GenerateGuests() } } -rct_peep* Park::GenerateGuestFromCampaign(int32_t campaign) +Peep* Park::GenerateGuestFromCampaign(int32_t campaign) { auto peep = GenerateGuest(); if (peep != nullptr) @@ -986,9 +986,9 @@ rct_peep* Park::GenerateGuestFromCampaign(int32_t campaign) return peep; } -rct_peep* Park::GenerateGuest() +Peep* Park::GenerateGuest() { - rct_peep* peep = nullptr; + Peep* peep = nullptr; const auto spawn = get_random_peep_spawn(); if (spawn != nullptr) { diff --git a/src/openrct2/world/Park.h b/src/openrct2/world/Park.h index f6c778b852..cd54738bc9 100644 --- a/src/openrct2/world/Park.h +++ b/src/openrct2/world/Park.h @@ -18,7 +18,7 @@ #define MAX_ENTRANCE_FEE MONEY(200, 00) -struct rct_peep; +struct Peep; enum : uint32_t { @@ -43,7 +43,7 @@ enum : uint32_t PARK_FLAGS_UNLOCK_ALL_PRICES = (1u << 31), // OpenRCT2 only! }; -struct rct_peep; +struct Peep; struct rct_ride; namespace OpenRCT2 @@ -71,7 +71,7 @@ namespace OpenRCT2 money32 CalculateCompanyValue() const; static uint8_t CalculateGuestInitialHappiness(uint8_t percentage); - rct_peep* GenerateGuest(); + Peep* GenerateGuest(); void ResetHistories(); void UpdateHistories(); @@ -83,7 +83,7 @@ namespace OpenRCT2 uint32_t CalculateGuestGenerationProbability() const; void GenerateGuests(); - rct_peep* GenerateGuestFromCampaign(int32_t campaign); + Peep* GenerateGuestFromCampaign(int32_t campaign); }; } // namespace OpenRCT2 diff --git a/src/openrct2/world/Sprite.h b/src/openrct2/world/Sprite.h index ffc33977b0..6becdade86 100644 --- a/src/openrct2/world/Sprite.h +++ b/src/openrct2/world/Sprite.h @@ -126,7 +126,7 @@ union rct_sprite { uint8_t pad_00[0x100]; rct_sprite_generic generic; - rct_peep peep; + Peep peep; rct_litter litter; rct_vehicle vehicle; rct_balloon balloon; @@ -142,7 +142,7 @@ union rct_sprite bool IsPeep(); rct_balloon* AsBalloon(); rct_duck* AsDuck(); - rct_peep* AsPeep(); + Peep* AsPeep(); }; assert_struct_size(rct_sprite, 0x100); diff --git a/test/tests/Pathfinding.cpp b/test/tests/Pathfinding.cpp index 2bcca46322..86140c7647 100644 --- a/test/tests/Pathfinding.cpp +++ b/test/tests/Pathfinding.cpp @@ -69,7 +69,7 @@ protected: // Our start position is in tile coordinates, but we need to give the peep spawn // position in actual world coords (32 units per tile X/Y, 8 per Z level). // Add 16 so the peep spawns in the center of the tile. - rct_peep* peep = peep_generate(pos->x * 32 + 16, pos->y * 32 + 16, pos->z * 8); + Peep* peep = peep_generate(pos->x * 32 + 16, pos->y * 32 + 16, pos->z * 8); // Peeps that are outside of the park use specialized pathfinding which we don't want to // use here