From 4d28901cb0c5f13c41555d5bfdc93bff7689ba34 Mon Sep 17 00:00:00 2001 From: Vinicius Sa Date: Tue, 6 Oct 2020 01:56:52 -0300 Subject: [PATCH 1/3] Refactor PeepSpriteType to use strong enum Issue: 12396 --- src/openrct2-ui/windows/GameBottomToolbar.cpp | 2 +- src/openrct2-ui/windows/Guest.cpp | 4 +- src/openrct2-ui/windows/GuestList.cpp | 2 +- src/openrct2-ui/windows/News.cpp | 2 +- src/openrct2-ui/windows/Park.cpp | 2 +- src/openrct2-ui/windows/Ride.cpp | 2 +- src/openrct2-ui/windows/Staff.cpp | 6 +- src/openrct2-ui/windows/StaffList.cpp | 10 +- src/openrct2/actions/StaffHireNewAction.hpp | 10 +- .../actions/StaffSetCostumeAction.hpp | 36 ++--- src/openrct2/paint/sprite/Paint.Peep.cpp | 2 +- src/openrct2/peep/Guest.cpp | 136 +++++++++--------- src/openrct2/peep/Peep.cpp | 16 +-- src/openrct2/peep/Peep.h | 105 +++++++------- src/openrct2/peep/Staff.cpp | 10 +- src/openrct2/rct1/S4Importer.cpp | 2 +- src/openrct2/rct1/Tables.cpp | 72 +++++----- src/openrct2/scripting/ScEntity.hpp | 8 +- 18 files changed, 214 insertions(+), 213 deletions(-) diff --git a/src/openrct2-ui/windows/GameBottomToolbar.cpp b/src/openrct2-ui/windows/GameBottomToolbar.cpp index 42a68b213a..1d2ae9d241 100644 --- a/src/openrct2-ui/windows/GameBottomToolbar.cpp +++ b/src/openrct2-ui/windows/GameBottomToolbar.cpp @@ -597,7 +597,7 @@ static void window_game_bottom_toolbar_draw_news_item(rct_drawpixelinfo* dpi, rc clipCoords.y += 3; } - uint32_t image_id_base = g_peep_animation_entries[peep->SpriteType].sprite_animation->base_image; + uint32_t image_id_base = g_peep_animation_entries[EnumValue(peep->SpriteType)].sprite_animation->base_image; image_id_base += w->frame_no & 0xFFFFFFFC; image_id_base++; diff --git a/src/openrct2-ui/windows/Guest.cpp b/src/openrct2-ui/windows/Guest.cpp index 897e514f8d..9a764c182a 100644 --- a/src/openrct2-ui/windows/Guest.cpp +++ b/src/openrct2-ui/windows/Guest.cpp @@ -761,7 +761,7 @@ static void window_guest_overview_tab_paint(rct_window* w, rct_drawpixelinfo* dp if (peep->AssignedPeepType == PeepType::Staff && peep->AssignedStaffType == StaffType::Entertainer) screenCoords.y++; - int32_t animationFrame = g_peep_animation_entries[peep->SpriteType].sprite_animation->base_image + 1; + int32_t animationFrame = g_peep_animation_entries[EnumValue(peep->SpriteType)].sprite_animation->base_image + 1; int32_t animationFrameOffset = 0; @@ -1163,7 +1163,7 @@ void window_guest_overview_tool_update(rct_window* w, rct_widgetindex widgetInde return; } - uint32_t imageId = g_peep_animation_entries[peep->SpriteType] + uint32_t imageId = g_peep_animation_entries[EnumValue(peep->SpriteType)] .sprite_animation[EnumValue(PeepActionSpriteType::Ui)] .base_image; imageId += w->picked_peep_frame >> 2; diff --git a/src/openrct2-ui/windows/GuestList.cpp b/src/openrct2-ui/windows/GuestList.cpp index a24f5f00ce..f38550f6d8 100644 --- a/src/openrct2-ui/windows/GuestList.cpp +++ b/src/openrct2-ui/windows/GuestList.cpp @@ -670,7 +670,7 @@ static void window_guest_list_paint(rct_window* w, rct_drawpixelinfo* dpi) window_draw_widgets(w, dpi); // Tab 1 image i = (_window_guest_list_selected_tab == 0 ? w->list_information_type & 0x0FFFFFFFC : 0); - i += g_peep_animation_entries[PEEP_SPRITE_TYPE_NORMAL].sprite_animation->base_image + 1; + i += g_peep_animation_entries[EnumValue(PeepSpriteType::Normal)].sprite_animation->base_image + 1; i |= 0xA1600000; gfx_draw_sprite( dpi, i, diff --git a/src/openrct2-ui/windows/News.cpp b/src/openrct2-ui/windows/News.cpp index f4ce332a95..ecaa5a880b 100644 --- a/src/openrct2-ui/windows/News.cpp +++ b/src/openrct2-ui/windows/News.cpp @@ -290,7 +290,7 @@ static void window_news_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32 int32_t sprite_type = 0; if (peep->AssignedPeepType == PeepType::Staff) { - sprite_type = peep->SpriteType; + sprite_type = EnumValue(peep->SpriteType); if (peep->AssignedStaffType == StaffType::Entertainer) { clipCoords.y += 3; diff --git a/src/openrct2-ui/windows/Park.cpp b/src/openrct2-ui/windows/Park.cpp index 2e01a4138e..aeb791d42a 100644 --- a/src/openrct2-ui/windows/Park.cpp +++ b/src/openrct2-ui/windows/Park.cpp @@ -1726,7 +1726,7 @@ static void window_park_draw_tab_images(rct_drawpixelinfo* dpi, rct_window* w) gfx_draw_sprite( dpi, sprite_idx, w->windowPos + ScreenCoordsXY{ w->widgets[WIDX_TAB_3].left, w->widgets[WIDX_TAB_3].top }, 0); - sprite_idx = g_peep_animation_entries[PEEP_SPRITE_TYPE_NORMAL].sprite_animation->base_image + 1; + sprite_idx = g_peep_animation_entries[EnumValue(PeepSpriteType::Normal)].sprite_animation->base_image + 1; if (w->page == WINDOW_PARK_PAGE_GUESTS) sprite_idx += w->var_492 & 0xFFFFFFFC; diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index 6e4f982f1c..39eed43f19 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -1098,7 +1098,7 @@ static void window_ride_draw_tab_customer(rct_drawpixelinfo* dpi, rct_window* w) if (w->page == WINDOW_RIDE_PAGE_CUSTOMER) spriteIndex = w->picked_peep_frame & ~3; - spriteIndex += g_peep_animation_entries[PEEP_SPRITE_TYPE_NORMAL].sprite_animation->base_image; + spriteIndex += g_peep_animation_entries[EnumValue(PeepSpriteType::Normal)].sprite_animation->base_image; spriteIndex += 1; spriteIndex |= 0xA9E00000; diff --git a/src/openrct2-ui/windows/Staff.cpp b/src/openrct2-ui/windows/Staff.cpp index 909f7214d6..b0dd4b3ede 100644 --- a/src/openrct2-ui/windows/Staff.cpp +++ b/src/openrct2-ui/windows/Staff.cpp @@ -802,7 +802,7 @@ void window_staff_options_invalidate(rct_window* w) window_staff_options_widgets[WIDX_CHECKBOX_4].type = WWT_EMPTY; window_staff_options_widgets[WIDX_COSTUME_BOX].type = WWT_DROPDOWN; window_staff_options_widgets[WIDX_COSTUME_BTN].type = WWT_BUTTON; - window_staff_options_widgets[WIDX_COSTUME_BOX].text = StaffCostumeNames[peep->SpriteType - 4]; + window_staff_options_widgets[WIDX_COSTUME_BOX].text = StaffCostumeNames[EnumValue(peep->SpriteType) - 4]; break; case StaffType::Handyman: window_staff_options_widgets[WIDX_CHECKBOX_1].type = WWT_CHECKBOX; @@ -1023,7 +1023,7 @@ void window_staff_overview_tab_paint(rct_window* w, rct_drawpixelinfo* dpi) if (peep->AssignedPeepType == PeepType::Staff && peep->AssignedStaffType == StaffType::Entertainer) screenCoords.y++; - int32_t ebx = g_peep_animation_entries[peep->SpriteType].sprite_animation->base_image + 1; + int32_t ebx = g_peep_animation_entries[EnumValue(peep->SpriteType)].sprite_animation->base_image + 1; int32_t eax = 0; @@ -1189,7 +1189,7 @@ void window_staff_overview_tool_update(rct_window* w, rct_widgetindex widgetInde return; } - uint32_t imageId = g_peep_animation_entries[peep->SpriteType] + uint32_t imageId = g_peep_animation_entries[EnumValue(peep->SpriteType)] .sprite_animation[EnumValue(PeepActionSpriteType::Ui)] .base_image; imageId += w->picked_peep_frame >> 2; diff --git a/src/openrct2-ui/windows/StaffList.cpp b/src/openrct2-ui/windows/StaffList.cpp index b9706f4969..e0eb0549b0 100644 --- a/src/openrct2-ui/windows/StaffList.cpp +++ b/src/openrct2-ui/windows/StaffList.cpp @@ -563,7 +563,7 @@ void window_staff_list_paint(rct_window* w, rct_drawpixelinfo* dpi) // Handymen tab image i = (selectedTab == 0 ? (w->list_information_type & ~3) : 0); - i += g_peep_animation_entries[PEEP_SPRITE_TYPE_HANDYMAN].sprite_animation->base_image + 1; + i += g_peep_animation_entries[EnumValue(PeepSpriteType::Handyman)].sprite_animation->base_image + 1; i |= SPRITE_ID_PALETTE_COLOUR_1(gStaffHandymanColour); gfx_draw_sprite( dpi, i, @@ -576,7 +576,7 @@ void window_staff_list_paint(rct_window* w, rct_drawpixelinfo* dpi) // Mechanic tab image i = (selectedTab == 1 ? (w->list_information_type & ~3) : 0); - i += g_peep_animation_entries[PEEP_SPRITE_TYPE_MECHANIC].sprite_animation->base_image + 1; + i += g_peep_animation_entries[EnumValue(PeepSpriteType::Mechanic)].sprite_animation->base_image + 1; i |= SPRITE_ID_PALETTE_COLOUR_1(gStaffMechanicColour); gfx_draw_sprite( dpi, i, @@ -589,7 +589,7 @@ void window_staff_list_paint(rct_window* w, rct_drawpixelinfo* dpi) // Security tab image i = (selectedTab == 2 ? (w->list_information_type & ~3) : 0); - i += g_peep_animation_entries[PEEP_SPRITE_TYPE_SECURITY].sprite_animation->base_image + 1; + i += g_peep_animation_entries[EnumValue(PeepSpriteType::Security)].sprite_animation->base_image + 1; i |= SPRITE_ID_PALETTE_COLOUR_1(gStaffSecurityColour); gfx_draw_sprite( dpi, i, @@ -613,7 +613,7 @@ void window_staff_list_paint(rct_window* w, rct_drawpixelinfo* dpi) { // Entertainers tab image i = (selectedTab == 3 ? (w->list_information_type & ~3) : 0); - i += g_peep_animation_entries[PEEP_SPRITE_TYPE_ENTERTAINER_ELEPHANT].sprite_animation->base_image + 1; + i += g_peep_animation_entries[EnumValue(PeepSpriteType::EntertainerElephant)].sprite_animation->base_image + 1; gfx_draw_sprite(&sprite_dpi, i, { 0x0F, 0x17 }, 0); } @@ -736,7 +736,7 @@ void window_staff_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32_ } else { - gfx_draw_sprite(dpi, staffCostumeSprites[peep->SpriteType - 4], { staffOrderIcon_x, y }, 0); + gfx_draw_sprite(dpi, staffCostumeSprites[EnumValue(peep->SpriteType) - 4], { staffOrderIcon_x, y }, 0); } } diff --git a/src/openrct2/actions/StaffHireNewAction.hpp b/src/openrct2/actions/StaffHireNewAction.hpp index 716f590f41..412ea50d89 100644 --- a/src/openrct2/actions/StaffHireNewAction.hpp +++ b/src/openrct2/actions/StaffHireNewAction.hpp @@ -30,10 +30,10 @@ /* rct2: 0x009929FC */ static constexpr const PeepSpriteType spriteTypes[] = { - PEEP_SPRITE_TYPE_HANDYMAN, - PEEP_SPRITE_TYPE_MECHANIC, - PEEP_SPRITE_TYPE_SECURITY, - PEEP_SPRITE_TYPE_ENTERTAINER_PANDA, + PeepSpriteType::Handyman, + PeepSpriteType::Mechanic, + PeepSpriteType::Security, + PeepSpriteType::EntertainerPanda, }; class StaffHireNewActionResult final : public GameActionResult @@ -210,7 +210,7 @@ private: newPeep->Name = nullptr; newPeep->SpriteType = spriteType; - const rct_sprite_bounds* spriteBounds = g_peep_animation_entries[spriteType].sprite_bounds; + const rct_sprite_bounds* spriteBounds = g_peep_animation_entries[EnumValue(spriteType)].sprite_bounds; newPeep->sprite_width = spriteBounds->sprite_width; newPeep->sprite_height_negative = spriteBounds->sprite_height_negative; newPeep->sprite_height_positive = spriteBounds->sprite_height_positive; diff --git a/src/openrct2/actions/StaffSetCostumeAction.hpp b/src/openrct2/actions/StaffSetCostumeAction.hpp index 3ae71e7e64..7eaacc6052 100644 --- a/src/openrct2/actions/StaffSetCostumeAction.hpp +++ b/src/openrct2/actions/StaffSetCostumeAction.hpp @@ -20,22 +20,22 @@ /** rct2: 0x00982134 */ constexpr const bool peep_slow_walking_types[] = { - false, // PEEP_SPRITE_TYPE_NORMAL - false, // PEEP_SPRITE_TYPE_HANDYMAN - false, // PEEP_SPRITE_TYPE_MECHANIC - false, // PEEP_SPRITE_TYPE_SECURITY - false, // PEEP_SPRITE_TYPE_ENTERTAINER_PANDA - false, // PEEP_SPRITE_TYPE_ENTERTAINER_TIGER - false, // PEEP_SPRITE_TYPE_ENTERTAINER_ELEPHANT - false, // PEEP_SPRITE_TYPE_ENTERTAINER_ROMAN - false, // PEEP_SPRITE_TYPE_ENTERTAINER_GORILLA - false, // PEEP_SPRITE_TYPE_ENTERTAINER_SNOWMAN - false, // PEEP_SPRITE_TYPE_ENTERTAINER_KNIGHT - true, // PEEP_SPRITE_TYPE_ENTERTAINER_ASTRONAUT - false, // PEEP_SPRITE_TYPE_ENTERTAINER_BANDIT - false, // PEEP_SPRITE_TYPE_ENTERTAINER_SHERIFF - true, // PEEP_SPRITE_TYPE_ENTERTAINER_PIRATE - true, // PEEP_SPRITE_TYPE_BALLOON + false, // PeepSpriteType::Normal + false, // PeepSpriteType::Handyman + false, // PeepSpriteType::Mechanic + false, // PeepSpriteType::Security + false, // PeepSpriteType::EntertainerPanda + false, // PeepSpriteType::EntertainerTiger + false, // PeepSpriteType::EntertainerElephant + false, // PeepSpriteType::EntertainerRoman + false, // PeepSpriteType::EntertainerGorilla + false, // PeepSpriteType::EntertainerSnowman + false, // PeepSpriteType::EntertainerKnight + true, // PeepSpriteType::EntertainerAstronaut + false, // PeepSpriteType::EntertainerBandit + false, // PeepSpriteType::EntertainerSheriff + true, // PeepSpriteType::EntertainerPirate + true, // PeepSpriteType::Balloon }; DEFINE_GAME_ACTION(StaffSetCostumeAction, GAME_COMMAND_SET_STAFF_COSTUME, GameActionResult) @@ -79,7 +79,7 @@ public: } auto spriteType = EntertainerCostumeToSprite(_costume); - if (spriteType > std::size(peep_slow_walking_types)) + if (EnumValue(spriteType) > std::size(peep_slow_walking_types)) { log_warning("Invalid game command for sprite %u", _spriteIndex); return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_NONE); @@ -99,7 +99,7 @@ public: auto spriteType = EntertainerCostumeToSprite(_costume); staff->SpriteType = spriteType; staff->PeepFlags &= ~PEEP_FLAGS_SLOW_WALK; - if (peep_slow_walking_types[spriteType]) + if (peep_slow_walking_types[EnumValue(spriteType)]) { staff->PeepFlags |= PEEP_FLAGS_SLOW_WALK; } diff --git a/src/openrct2/paint/sprite/Paint.Peep.cpp b/src/openrct2/paint/sprite/Paint.Peep.cpp index af16942f82..19df4a8518 100644 --- a/src/openrct2/paint/sprite/Paint.Peep.cpp +++ b/src/openrct2/paint/sprite/Paint.Peep.cpp @@ -68,7 +68,7 @@ void peep_paint(paint_session* session, const Peep* peep, int32_t imageDirection return; } - rct_peep_animation_entry sprite = g_peep_animation_entries[peep->SpriteType]; + rct_peep_animation_entry sprite = g_peep_animation_entries[EnumValue(peep->SpriteType)]; PeepActionSpriteType spriteType = peep->ActionSpriteType; uint8_t imageOffset = peep->ActionSpriteImageOffset; diff --git a/src/openrct2/peep/Guest.cpp b/src/openrct2/peep/Guest.cpp index 4bdd24d42f..075a1b554d 100644 --- a/src/openrct2/peep/Guest.cpp +++ b/src/openrct2/peep/Guest.cpp @@ -1277,7 +1277,7 @@ void Guest::UpdateSitting() return; } - if (SpriteType == PEEP_SPRITE_TYPE_UMBRELLA) + if (SpriteType == PeepSpriteType::Umbrella) { TryGetUpFromSitting(); return; @@ -1303,7 +1303,7 @@ void Guest::UpdateSitting() TryGetUpFromSitting(); return; } - if (SpriteType == PEEP_SPRITE_TYPE_BALLOON || SpriteType == PEEP_SPRITE_TYPE_HAT) + if (SpriteType == PeepSpriteType::Balloon || SpriteType == PeepSpriteType::Hat) { TryGetUpFromSitting(); return; @@ -5600,7 +5600,7 @@ void Guest::UpdateQueuing() PerformNextAction(pathingResult); if (Action < PeepActionType::None1) return; - if (SpriteType == PEEP_SPRITE_TYPE_NORMAL) + if (SpriteType == PeepSpriteType::Normal) { if (TimeInQueue >= 2000 && (0xFFFF & scenario_rand()) <= 119) { @@ -5622,28 +5622,28 @@ void Guest::UpdateQueuing() { switch (SpriteType) { - case PEEP_SPRITE_TYPE_ICE_CREAM: - case PEEP_SPRITE_TYPE_CHIPS: - case PEEP_SPRITE_TYPE_BURGER: - case PEEP_SPRITE_TYPE_DRINK: - case PEEP_SPRITE_TYPE_CANDYFLOSS: - case PEEP_SPRITE_TYPE_PIZZA: - case PEEP_SPRITE_TYPE_POPCORN: - case PEEP_SPRITE_TYPE_HOT_DOG: - case PEEP_SPRITE_TYPE_TENTACLE: - case PEEP_SPRITE_TYPE_TOFFEE_APPLE: - case PEEP_SPRITE_TYPE_DOUGHNUT: - case PEEP_SPRITE_TYPE_COFFEE: - case PEEP_SPRITE_TYPE_CHICKEN: - case PEEP_SPRITE_TYPE_LEMONADE: - case PEEP_SPRITE_TYPE_PRETZEL: - case PEEP_SPRITE_TYPE_SU_JONGKWA: - case PEEP_SPRITE_TYPE_JUICE: - case PEEP_SPRITE_TYPE_FUNNEL_CAKE: - case PEEP_SPRITE_TYPE_NOODLES: - case PEEP_SPRITE_TYPE_SAUSAGE: - case PEEP_SPRITE_TYPE_SOUP: - case PEEP_SPRITE_TYPE_SANDWICH: + case PeepSpriteType::IceCream: + case PeepSpriteType::Chips: + case PeepSpriteType::Burger: + case PeepSpriteType::Drink: + case PeepSpriteType::Candyfloss: + case PeepSpriteType::Pizza: + case PeepSpriteType::Popcorn: + case PeepSpriteType::HotDog: + case PeepSpriteType::Tentacle: + case PeepSpriteType::ToffeeApple: + case PeepSpriteType::Doughnut: + case PeepSpriteType::Coffee: + case PeepSpriteType::Chicken: + case PeepSpriteType::Lemonade: + case PeepSpriteType::Pretzel: + case PeepSpriteType::SuJongkwa: + case PeepSpriteType::Juice: + case PeepSpriteType::FunnelCake: + case PeepSpriteType::Noodles: + case PeepSpriteType::Sausage: + case PeepSpriteType::Soup: + case PeepSpriteType::Sandwich: // Eat food Action = PeepActionType::EatFood; ActionFrame = 0; @@ -6771,8 +6771,8 @@ void Guest::SetSpriteType(PeepSpriteType new_sprite_type) Action = PeepActionType::None2; PeepFlags &= ~PEEP_FLAGS_SLOW_WALK; - Guard::Assert(new_sprite_type < std::size(gSpriteTypeToSlowWalkMap)); - if (gSpriteTypeToSlowWalkMap[new_sprite_type]) + Guard::Assert(EnumValue(new_sprite_type) < std::size(gSpriteTypeToSlowWalkMap)); + if (gSpriteTypeToSlowWalkMap[EnumValue(new_sprite_type)]) { PeepFlags |= PEEP_FLAGS_SLOW_WALK; } @@ -6803,38 +6803,38 @@ struct item_pref_t // clang-format off static item_pref_t item_order_preference[] = { - { 0, PEEP_ITEM_ICE_CREAM, PEEP_SPRITE_TYPE_ICE_CREAM }, - { 0, PEEP_ITEM_CHIPS, PEEP_SPRITE_TYPE_CHIPS }, - { 0, PEEP_ITEM_PIZZA, PEEP_SPRITE_TYPE_PIZZA }, - { 0, PEEP_ITEM_BURGER, PEEP_SPRITE_TYPE_BURGER }, - { 0, PEEP_ITEM_DRINK, PEEP_SPRITE_TYPE_DRINK }, - { 0, PEEP_ITEM_COFFEE, PEEP_SPRITE_TYPE_COFFEE }, - { 0, PEEP_ITEM_CHICKEN, PEEP_SPRITE_TYPE_CHICKEN }, - { 0, PEEP_ITEM_LEMONADE, PEEP_SPRITE_TYPE_LEMONADE }, - { 0, PEEP_ITEM_CANDYFLOSS, PEEP_SPRITE_TYPE_CANDYFLOSS }, - { 0, PEEP_ITEM_POPCORN, PEEP_SPRITE_TYPE_POPCORN }, - { 0, PEEP_ITEM_HOT_DOG, PEEP_SPRITE_TYPE_HOT_DOG }, - { 0, PEEP_ITEM_TENTACLE, PEEP_SPRITE_TYPE_TENTACLE }, - { 0, PEEP_ITEM_TOFFEE_APPLE, PEEP_SPRITE_TYPE_TOFFEE_APPLE }, - { 0, PEEP_ITEM_DOUGHNUT, PEEP_SPRITE_TYPE_DOUGHNUT }, - { 1, PEEP_ITEM_PRETZEL, PEEP_SPRITE_TYPE_PRETZEL }, - { 1, PEEP_ITEM_COOKIE, PEEP_SPRITE_TYPE_PRETZEL }, - { 1, PEEP_ITEM_CHOCOLATE, PEEP_SPRITE_TYPE_COFFEE }, - { 1, PEEP_ITEM_ICED_TEA, PEEP_SPRITE_TYPE_COFFEE }, - { 1, PEEP_ITEM_FUNNEL_CAKE, PEEP_SPRITE_TYPE_FUNNEL_CAKE }, - { 1, PEEP_ITEM_BEEF_NOODLES, PEEP_SPRITE_TYPE_NOODLES }, - { 1, PEEP_ITEM_FRIED_RICE_NOODLES, PEEP_SPRITE_TYPE_NOODLES }, - { 1, PEEP_ITEM_WONTON_SOUP, PEEP_SPRITE_TYPE_SOUP }, - { 1, PEEP_ITEM_MEATBALL_SOUP, PEEP_SPRITE_TYPE_SOUP }, - { 1, PEEP_ITEM_FRUIT_JUICE, PEEP_SPRITE_TYPE_JUICE }, - { 1, PEEP_ITEM_SOYBEAN_MILK, PEEP_SPRITE_TYPE_SU_JONGKWA }, - { 1, PEEP_ITEM_SU_JONGKWA, PEEP_SPRITE_TYPE_SU_JONGKWA }, - { 1, PEEP_ITEM_SUB_SANDWICH, PEEP_SPRITE_TYPE_SANDWICH }, - { 1, PEEP_ITEM_ROAST_SAUSAGE, PEEP_SPRITE_TYPE_SAUSAGE }, - { 0, PEEP_ITEM_BALLOON, PEEP_SPRITE_TYPE_BALLOON }, - { 0, PEEP_ITEM_HAT, PEEP_SPRITE_TYPE_HAT }, - { 1, PEEP_ITEM_SUNGLASSES, PEEP_SPRITE_TYPE_SUNGLASSES }, - { 0xFF, 0xFFFFFFFF, PEEP_SPRITE_TYPE_INVALID } + { 0, PEEP_ITEM_ICE_CREAM, PeepSpriteType::IceCream }, + { 0, PEEP_ITEM_CHIPS, PeepSpriteType::Chips }, + { 0, PEEP_ITEM_PIZZA, PeepSpriteType::Pizza }, + { 0, PEEP_ITEM_BURGER, PeepSpriteType::Burger }, + { 0, PEEP_ITEM_DRINK, PeepSpriteType::Drink }, + { 0, PEEP_ITEM_COFFEE, PeepSpriteType::Coffee }, + { 0, PEEP_ITEM_CHICKEN, PeepSpriteType::Chicken }, + { 0, PEEP_ITEM_LEMONADE, PeepSpriteType::Lemonade }, + { 0, PEEP_ITEM_CANDYFLOSS, PeepSpriteType::Candyfloss }, + { 0, PEEP_ITEM_POPCORN, PeepSpriteType::Popcorn }, + { 0, PEEP_ITEM_HOT_DOG, PeepSpriteType::HotDog }, + { 0, PEEP_ITEM_TENTACLE, PeepSpriteType::Tentacle }, + { 0, PEEP_ITEM_TOFFEE_APPLE, PeepSpriteType::ToffeeApple }, + { 0, PEEP_ITEM_DOUGHNUT, PeepSpriteType::Doughnut }, + { 1, PEEP_ITEM_PRETZEL, PeepSpriteType::Pretzel }, + { 1, PEEP_ITEM_COOKIE, PeepSpriteType::Pretzel }, + { 1, PEEP_ITEM_CHOCOLATE, PeepSpriteType::Coffee }, + { 1, PEEP_ITEM_ICED_TEA, PeepSpriteType::Coffee }, + { 1, PEEP_ITEM_FUNNEL_CAKE, PeepSpriteType::FunnelCake }, + { 1, PEEP_ITEM_BEEF_NOODLES, PeepSpriteType::Noodles }, + { 1, PEEP_ITEM_FRIED_RICE_NOODLES, PeepSpriteType::Noodles }, + { 1, PEEP_ITEM_WONTON_SOUP, PeepSpriteType::Soup }, + { 1, PEEP_ITEM_MEATBALL_SOUP, PeepSpriteType::Soup }, + { 1, PEEP_ITEM_FRUIT_JUICE, PeepSpriteType::Juice }, + { 1, PEEP_ITEM_SOYBEAN_MILK, PeepSpriteType::SuJongkwa }, + { 1, PEEP_ITEM_SU_JONGKWA, PeepSpriteType::SuJongkwa }, + { 1, PEEP_ITEM_SUB_SANDWICH, PeepSpriteType::Sandwich }, + { 1, PEEP_ITEM_ROAST_SAUSAGE, PeepSpriteType::Sausage }, + { 0, PEEP_ITEM_BALLOON, PeepSpriteType::Balloon }, + { 0, PEEP_ITEM_HAT, PeepSpriteType::Hat }, + { 1, PEEP_ITEM_SUNGLASSES, PeepSpriteType::Sunglasses }, + { 0xFF, 0xFFFFFFFF, PeepSpriteType::Invalid } }; // clang-format on @@ -6844,7 +6844,7 @@ static item_pref_t item_order_preference[] = { */ void Guest::UpdateSpriteType() { - if (SpriteType == PEEP_SPRITE_TYPE_BALLOON && (scenario_rand() & 0xFFFF) <= 327) + if (SpriteType == PeepSpriteType::Balloon && (scenario_rand() & 0xFFFF) <= 327) { bool isBalloonPopped = false; if (x != LOCATION_NULL) @@ -6875,7 +6875,7 @@ void Guest::UpdateSpriteType() if (tileElement->IsLastForTile()) { - SetSpriteType(PEEP_SPRITE_TYPE_UMBRELLA); + SetSpriteType(PeepSpriteType::Umbrella); return; } tileElement++; @@ -6905,41 +6905,41 @@ void Guest::UpdateSpriteType() if (State == PeepState::Watching && StandingFlags & (1 << 1)) { - SetSpriteType(PEEP_SPRITE_TYPE_WATCHING); + SetSpriteType(PeepSpriteType::Watching); return; } if (Nausea > 170) { - SetSpriteType(PEEP_SPRITE_TYPE_VERY_NAUSEOUS); + SetSpriteType(PeepSpriteType::VeryNauseous); return; } if (Nausea > 140) { - SetSpriteType(PEEP_SPRITE_TYPE_NAUSEOUS); + SetSpriteType(PeepSpriteType::Nauseous); return; } if (Energy <= 64 && Happiness < 128) { - SetSpriteType(PEEP_SPRITE_TYPE_HEAD_DOWN); + SetSpriteType(PeepSpriteType::HeadDown); return; } if (Energy <= 80 && Happiness < 128) { - SetSpriteType(PEEP_SPRITE_TYPE_ARMS_CROSSED); + SetSpriteType(PeepSpriteType::ArmsCrossed); return; } if (Toilet > 220) { - SetSpriteType(PEEP_SPRITE_TYPE_REQUIRE_TOILET); + SetSpriteType(PeepSpriteType::RequireToilet); return; } - SetSpriteType(PEEP_SPRITE_TYPE_NORMAL); + SetSpriteType(PeepSpriteType::Normal); } bool Guest::HeadingForRideOrParkExit() const diff --git a/src/openrct2/peep/Peep.cpp b/src/openrct2/peep/Peep.cpp index 2ab4a99361..2a2ef81c95 100644 --- a/src/openrct2/peep/Peep.cpp +++ b/src/openrct2/peep/Peep.cpp @@ -496,7 +496,7 @@ PeepActionSpriteType Peep::GetActionSpriteType() */ void Peep::UpdateCurrentActionSpriteType() { - if (SpriteType >= std::size(g_peep_animation_entries)) + if (EnumValue(SpriteType) >= std::size(g_peep_animation_entries)) { return; } @@ -509,7 +509,7 @@ void Peep::UpdateCurrentActionSpriteType() Invalidate(); ActionSpriteType = newActionSpriteType; - const rct_sprite_bounds* spriteBounds = g_peep_animation_entries[SpriteType].sprite_bounds; + const rct_sprite_bounds* spriteBounds = g_peep_animation_entries[EnumValue(SpriteType)].sprite_bounds; sprite_width = spriteBounds[EnumValue(ActionSpriteType)].sprite_width; sprite_height_negative = spriteBounds[EnumValue(ActionSpriteType)].sprite_height_negative; sprite_height_positive = spriteBounds[EnumValue(ActionSpriteType)].sprite_height_positive; @@ -598,7 +598,7 @@ std::optional Peep::UpdateAction(int16_t& xy_distance) CoordsXY loc = { x, y }; loc += word_981D7C[nextDirection / 8]; WalkingFrameNum++; - const rct_peep_animation* peepAnimation = g_peep_animation_entries[SpriteType].sprite_animation; + const rct_peep_animation* peepAnimation = g_peep_animation_entries[EnumValue(SpriteType)].sprite_animation; const uint8_t* imageOffset = peepAnimation[EnumValue(ActionSpriteType)].frame_offsets; if (WalkingFrameNum >= peepAnimation[EnumValue(ActionSpriteType)].num_frames) { @@ -608,7 +608,7 @@ std::optional Peep::UpdateAction(int16_t& xy_distance) return loc; } - const rct_peep_animation* peepAnimation = g_peep_animation_entries[SpriteType].sprite_animation; + const rct_peep_animation* peepAnimation = g_peep_animation_entries[EnumValue(SpriteType)].sprite_animation; ActionFrame++; // If last frame of action @@ -1579,7 +1579,7 @@ Peep* Peep::Generate(const CoordsXYZ& coords) Peep* peep = &create_sprite(SPRITE_IDENTIFIER_PEEP)->peep; peep->sprite_identifier = SPRITE_IDENTIFIER_PEEP; - peep->SpriteType = PEEP_SPRITE_TYPE_NORMAL; + peep->SpriteType = PeepSpriteType::Normal; peep->OutsideOfPark = true; peep->State = PeepState::Falling; peep->Action = PeepActionType::None2; @@ -1591,7 +1591,7 @@ Peep* Peep::Generate(const CoordsXYZ& coords) peep->FavouriteRide = RIDE_ID_NULL; peep->FavouriteRideRating = 0; - const rct_sprite_bounds* spriteBounds = g_peep_animation_entries[peep->SpriteType].sprite_bounds; + const rct_sprite_bounds* spriteBounds = g_peep_animation_entries[EnumValue(peep->SpriteType)].sprite_bounds; peep->sprite_width = spriteBounds[EnumValue(peep->ActionSpriteType)].sprite_width; peep->sprite_height_negative = spriteBounds[EnumValue(peep->ActionSpriteType)].sprite_height_negative; peep->sprite_height_positive = spriteBounds[EnumValue(peep->ActionSpriteType)].sprite_height_positive; @@ -2192,7 +2192,7 @@ void Peep::SwitchNextActionSpriteType() { Invalidate(); ActionSpriteType = NextActionSpriteType; - const rct_sprite_bounds* spriteBounds = g_peep_animation_entries[SpriteType].sprite_bounds; + const rct_sprite_bounds* spriteBounds = g_peep_animation_entries[EnumValue(SpriteType)].sprite_bounds; sprite_width = spriteBounds[EnumValue(NextActionSpriteType)].sprite_width; sprite_height_negative = spriteBounds[EnumValue(NextActionSpriteType)].sprite_height_negative; sprite_height_positive = spriteBounds[EnumValue(NextActionSpriteType)].sprite_height_positive; @@ -3265,7 +3265,7 @@ static void peep_release_balloon(Guest* peep, int16_t spawn_height) { peep->ItemStandardFlags &= ~PEEP_ITEM_BALLOON; - if (peep->SpriteType == PEEP_SPRITE_TYPE_BALLOON && peep->x != LOCATION_NULL) + if (peep->SpriteType == PeepSpriteType::Balloon && peep->x != LOCATION_NULL) { create_balloon({ peep->x, peep->y, spawn_height }, peep->BalloonColour, false); peep->WindowInvalidateFlags |= PEEP_INVALIDATE_PEEP_INVENTORY; diff --git a/src/openrct2/peep/Peep.h b/src/openrct2/peep/Peep.h index 4a323c89f5..8786e3976b 100644 --- a/src/openrct2/peep/Peep.h +++ b/src/openrct2/peep/Peep.h @@ -16,6 +16,7 @@ #include "../ride/Ride.h" #include "../ride/RideTypes.h" #include "../ride/ShopItem.h" +#include "../util/Util.h" #include "../world/Location.hpp" #include "../world/SpriteBase.h" @@ -471,59 +472,59 @@ enum PeepItem PEEP_ITEM_EMPTY_BOWL_BLUE = (1 << 21), }; -enum PeepSpriteType : uint8_t +enum class PeepSpriteType : uint8_t { - PEEP_SPRITE_TYPE_NORMAL = 0, - PEEP_SPRITE_TYPE_HANDYMAN = 1, - PEEP_SPRITE_TYPE_MECHANIC = 2, - PEEP_SPRITE_TYPE_SECURITY = 3, - PEEP_SPRITE_TYPE_ENTERTAINER_PANDA = 4, - PEEP_SPRITE_TYPE_ENTERTAINER_TIGER = 5, - PEEP_SPRITE_TYPE_ENTERTAINER_ELEPHANT = 6, - PEEP_SPRITE_TYPE_ENTERTAINER_ROMAN = 7, - PEEP_SPRITE_TYPE_ENTERTAINER_GORILLA = 8, - PEEP_SPRITE_TYPE_ENTERTAINER_SNOWMAN = 9, - PEEP_SPRITE_TYPE_ENTERTAINER_KNIGHT = 10, - PEEP_SPRITE_TYPE_ENTERTAINER_ASTRONAUT = 11, - PEEP_SPRITE_TYPE_ENTERTAINER_BANDIT = 12, - PEEP_SPRITE_TYPE_ENTERTAINER_SHERIFF = 13, - PEEP_SPRITE_TYPE_ENTERTAINER_PIRATE = 14, - PEEP_SPRITE_TYPE_ICE_CREAM = 15, - PEEP_SPRITE_TYPE_CHIPS = 16, - PEEP_SPRITE_TYPE_BURGER = 17, - PEEP_SPRITE_TYPE_DRINK = 18, - PEEP_SPRITE_TYPE_BALLOON = 19, - PEEP_SPRITE_TYPE_CANDYFLOSS = 20, - PEEP_SPRITE_TYPE_UMBRELLA = 21, - PEEP_SPRITE_TYPE_PIZZA = 22, - PEEP_SPRITE_TYPE_SECURITY_ALT = 23, - PEEP_SPRITE_TYPE_POPCORN = 24, - PEEP_SPRITE_TYPE_ARMS_CROSSED = 25, - PEEP_SPRITE_TYPE_HEAD_DOWN = 26, - PEEP_SPRITE_TYPE_NAUSEOUS = 27, - PEEP_SPRITE_TYPE_VERY_NAUSEOUS = 28, - PEEP_SPRITE_TYPE_REQUIRE_TOILET = 29, - PEEP_SPRITE_TYPE_HAT = 30, - PEEP_SPRITE_TYPE_HOT_DOG = 31, - PEEP_SPRITE_TYPE_TENTACLE = 32, - PEEP_SPRITE_TYPE_TOFFEE_APPLE = 33, - PEEP_SPRITE_TYPE_DOUGHNUT = 34, - PEEP_SPRITE_TYPE_COFFEE = 35, - PEEP_SPRITE_TYPE_CHICKEN = 36, - PEEP_SPRITE_TYPE_LEMONADE = 37, - PEEP_SPRITE_TYPE_WATCHING = 38, - PEEP_SPRITE_TYPE_PRETZEL = 39, - PEEP_SPRITE_TYPE_SUNGLASSES = 40, - PEEP_SPRITE_TYPE_SU_JONGKWA = 41, - PEEP_SPRITE_TYPE_JUICE = 42, - PEEP_SPRITE_TYPE_FUNNEL_CAKE = 43, - PEEP_SPRITE_TYPE_NOODLES = 44, - PEEP_SPRITE_TYPE_SAUSAGE = 45, - PEEP_SPRITE_TYPE_SOUP = 46, - PEEP_SPRITE_TYPE_SANDWICH = 47, - PEEP_SPRITE_TYPE_COUNT, + Normal = 0, + Handyman = 1, + Mechanic = 2, + Security = 3, + EntertainerPanda = 4, + EntertainerTiger = 5, + EntertainerElephant = 6, + EntertainerRoman = 7, + EntertainerGorilla = 8, + EntertainerSnowman = 9, + EntertainerKnight = 10, + EntertainerAstronaut = 11, + EntertainerBandit = 12, + EntertainerSheriff = 13, + EntertainerPirate = 14, + IceCream = 15, + Chips = 16, + Burger = 17, + Drink = 18, + Balloon = 19, + Candyfloss = 20, + Umbrella = 21, + Pizza = 22, + SecurityAlt = 23, + Popcorn = 24, + ArmsCrossed = 25, + HeadDown = 26, + Nauseous = 27, + VeryNauseous = 28, + RequireToilet = 29, + Hat = 30, + HotDog = 31, + Tentacle = 32, + ToffeeApple = 33, + Doughnut = 34, + Coffee = 35, + Chicken = 36, + Lemonade = 37, + Watching = 38, + Pretzel = 39, + Sunglasses = 40, + SuJongkwa = 41, + Juice = 42, + FunnelCake = 43, + Noodles = 44, + Sausage = 45, + Soup = 46, + Sandwich = 47, + Count = 48, - PEEP_SPRITE_TYPE_INVALID = 255 + Invalid = 255 }; // Flags used by peep->WindowInvalidateFlags @@ -1036,7 +1037,7 @@ enum }; // rct2: 0x00982708 -extern rct_peep_animation_entry g_peep_animation_entries[PEEP_SPRITE_TYPE_COUNT]; +extern rct_peep_animation_entry g_peep_animation_entries[EnumValue(PeepSpriteType::Count)]; extern const bool gSpriteTypeToSlowWalkMap[48]; extern uint8_t gGuestChangeModifier; diff --git a/src/openrct2/peep/Staff.cpp b/src/openrct2/peep/Staff.cpp index 53e2573298..28d977abcd 100644 --- a/src/openrct2/peep/Staff.cpp +++ b/src/openrct2/peep/Staff.cpp @@ -1049,7 +1049,7 @@ bool Staff::DoPathFinding() uint8_t Staff::GetCostume() const { - return SpriteType - PEEP_SPRITE_TYPE_ENTERTAINER_PANDA; + return EnumValue(SpriteType) - EnumValue(PeepSpriteType::EntertainerPanda); } void Staff::SetCostume(uint8_t value) @@ -1061,7 +1061,7 @@ void Staff::SetCostume(uint8_t value) PeepSpriteType EntertainerCostumeToSprite(EntertainerCostume entertainerType) { uint8_t value = static_cast(entertainerType); - PeepSpriteType newSpriteType = static_cast(value + PEEP_SPRITE_TYPE_ENTERTAINER_PANDA); + PeepSpriteType newSpriteType = static_cast(value + EnumValue(PeepSpriteType::EntertainerPanda)); return newSpriteType; } @@ -1796,9 +1796,9 @@ void Staff::Tick128UpdateStaff() if (AssignedStaffType != StaffType::Security) return; - PeepSpriteType newSpriteType = PEEP_SPRITE_TYPE_SECURITY_ALT; + PeepSpriteType newSpriteType = PeepSpriteType::SecurityAlt; if (State != PeepState::Patrolling) - newSpriteType = PEEP_SPRITE_TYPE_SECURITY; + newSpriteType = PeepSpriteType::Security; if (SpriteType == newSpriteType) return; @@ -1810,7 +1810,7 @@ void Staff::Tick128UpdateStaff() Action = PeepActionType::None2; PeepFlags &= ~PEEP_FLAGS_SLOW_WALK; - if (gSpriteTypeToSlowWalkMap[newSpriteType]) + if (gSpriteTypeToSlowWalkMap[EnumValue(newSpriteType)]) { PeepFlags |= PEEP_FLAGS_SLOW_WALK; } diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 9aabc18155..a7a1b1b75f 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -1409,7 +1409,7 @@ private: dst->ActionSpriteType = static_cast(src->action_sprite_type); dst->ActionFrame = src->action_frame; - const rct_sprite_bounds* spriteBounds = g_peep_animation_entries[dst->SpriteType].sprite_bounds; + const rct_sprite_bounds* spriteBounds = g_peep_animation_entries[EnumValue(dst->SpriteType)].sprite_bounds; dst->sprite_width = spriteBounds[EnumValue(dst->ActionSpriteType)].sprite_width; dst->sprite_height_negative = spriteBounds[EnumValue(dst->ActionSpriteType)].sprite_height_negative; dst->sprite_height_positive = spriteBounds[EnumValue(dst->ActionSpriteType)].sprite_height_positive; diff --git a/src/openrct2/rct1/Tables.cpp b/src/openrct2/rct1/Tables.cpp index 21cda97456..536c41c3c1 100644 --- a/src/openrct2/rct1/Tables.cpp +++ b/src/openrct2/rct1/Tables.cpp @@ -70,46 +70,46 @@ namespace RCT1 { static constexpr const PeepSpriteType map[] = { - PEEP_SPRITE_TYPE_NORMAL, // 0x00 - PEEP_SPRITE_TYPE_HANDYMAN, // 0x01 - PEEP_SPRITE_TYPE_MECHANIC, // 0x02 - PEEP_SPRITE_TYPE_SECURITY, // 0x03 - PEEP_SPRITE_TYPE_ENTERTAINER_PANDA, // 0x04 - PEEP_SPRITE_TYPE_ENTERTAINER_TIGER, // 0x05 - PEEP_SPRITE_TYPE_ENTERTAINER_ELEPHANT, // 0x06 - PEEP_SPRITE_TYPE_ENTERTAINER_ROMAN, // 0x07 - PEEP_SPRITE_TYPE_ENTERTAINER_GORILLA, // 0x08 - PEEP_SPRITE_TYPE_ENTERTAINER_SNOWMAN, // 0x09 - PEEP_SPRITE_TYPE_ENTERTAINER_KNIGHT, // 0x0A - PEEP_SPRITE_TYPE_ENTERTAINER_ASTRONAUT, // 0x0B - PEEP_SPRITE_TYPE_ICE_CREAM, // 0x0C - PEEP_SPRITE_TYPE_CHIPS, // 0x0D - PEEP_SPRITE_TYPE_BURGER, // 0x0E - PEEP_SPRITE_TYPE_DRINK, // 0x0F - PEEP_SPRITE_TYPE_BALLOON, // 0x10 - PEEP_SPRITE_TYPE_CANDYFLOSS, // 0x11 - PEEP_SPRITE_TYPE_UMBRELLA, // 0x12 - PEEP_SPRITE_TYPE_PIZZA, // 0x13 - PEEP_SPRITE_TYPE_SECURITY_ALT, // 0x14 - PEEP_SPRITE_TYPE_POPCORN, // 0x15 - PEEP_SPRITE_TYPE_ARMS_CROSSED, // 0x16 - PEEP_SPRITE_TYPE_HEAD_DOWN, // 0x17 - PEEP_SPRITE_TYPE_NAUSEOUS, // 0x18 - PEEP_SPRITE_TYPE_VERY_NAUSEOUS, // 0x19 - PEEP_SPRITE_TYPE_REQUIRE_TOILET, // 0x1A - PEEP_SPRITE_TYPE_HAT, // 0x1B - PEEP_SPRITE_TYPE_HOT_DOG, // 0x1C - PEEP_SPRITE_TYPE_TENTACLE, // 0x1D - PEEP_SPRITE_TYPE_TOFFEE_APPLE, // 0x1E - PEEP_SPRITE_TYPE_DOUGHNUT, // 0x1F - PEEP_SPRITE_TYPE_COFFEE, // 0x20 - PEEP_SPRITE_TYPE_CHICKEN, // 0x21 - PEEP_SPRITE_TYPE_LEMONADE, // 0x22 + PeepSpriteType::Normal, // 0x00 + PeepSpriteType::Handyman, // 0x01 + PeepSpriteType::Mechanic, // 0x02 + PeepSpriteType::Security, // 0x03 + PeepSpriteType::EntertainerPanda, // 0x04 + PeepSpriteType::EntertainerTiger, // 0x05 + PeepSpriteType::EntertainerElephant, // 0x06 + PeepSpriteType::EntertainerRoman, // 0x07 + PeepSpriteType::EntertainerGorilla, // 0x08 + PeepSpriteType::EntertainerSnowman, // 0x09 + PeepSpriteType::EntertainerKnight, // 0x0A + PeepSpriteType::EntertainerAstronaut, // 0x0B + PeepSpriteType::IceCream, // 0x0C + PeepSpriteType::Chips, // 0x0D + PeepSpriteType::Burger, // 0x0E + PeepSpriteType::Drink, // 0x0F + PeepSpriteType::Balloon, // 0x10 + PeepSpriteType::Candyfloss, // 0x11 + PeepSpriteType::Umbrella, // 0x12 + PeepSpriteType::Pizza, // 0x13 + PeepSpriteType::SecurityAlt, // 0x14 + PeepSpriteType::Popcorn, // 0x15 + PeepSpriteType::ArmsCrossed, // 0x16 + PeepSpriteType::HeadDown, // 0x17 + PeepSpriteType::Nauseous, // 0x18 + PeepSpriteType::VeryNauseous, // 0x19 + PeepSpriteType::RequireToilet, // 0x1A + PeepSpriteType::Hat, // 0x1B + PeepSpriteType::HotDog, // 0x1C + PeepSpriteType::Tentacle, // 0x1D + PeepSpriteType::ToffeeApple, // 0x1E + PeepSpriteType::Doughnut, // 0x1F + PeepSpriteType::Coffee, // 0x20 + PeepSpriteType::Chicken, // 0x21 + PeepSpriteType::Lemonade, // 0x22 }; if (rct1SpriteType >= std::size(map)) { log_warning("Unsupported RCT1 peep sprite type: %d.", rct1SpriteType); - return PEEP_SPRITE_TYPE_NORMAL; + return PeepSpriteType::Normal; } return map[rct1SpriteType]; } diff --git a/src/openrct2/scripting/ScEntity.hpp b/src/openrct2/scripting/ScEntity.hpp index 87ea98fd8d..d9dbe3755a 100644 --- a/src/openrct2/scripting/ScEntity.hpp +++ b/src/openrct2/scripting/ScEntity.hpp @@ -1112,22 +1112,22 @@ namespace OpenRCT2::Scripting if (value == "handyman" && peep->AssignedStaffType != StaffType::Handyman) { peep->AssignedStaffType = StaffType::Handyman; - peep->SpriteType = PeepSpriteType::PEEP_SPRITE_TYPE_HANDYMAN; + peep->SpriteType = PeepSpriteType::Handyman; } else if (value == "mechanic" && peep->AssignedStaffType != StaffType::Mechanic) { peep->AssignedStaffType = StaffType::Mechanic; - peep->SpriteType = PeepSpriteType::PEEP_SPRITE_TYPE_MECHANIC; + peep->SpriteType = PeepSpriteType::Mechanic; } else if (value == "security" && peep->AssignedStaffType != StaffType::Security) { peep->AssignedStaffType = StaffType::Security; - peep->SpriteType = PeepSpriteType::PEEP_SPRITE_TYPE_SECURITY; + peep->SpriteType = PeepSpriteType::Security; } else if (value == "entertainer" && peep->AssignedStaffType != StaffType::Entertainer) { peep->AssignedStaffType = StaffType::Entertainer; - peep->SpriteType = PeepSpriteType::PEEP_SPRITE_TYPE_ENTERTAINER_PANDA; + peep->SpriteType = PeepSpriteType::EntertainerPanda; } } } From 80718f1774fbb5b92197b1a77ea1d2a0a419b92b Mon Sep 17 00:00:00 2001 From: Vinicius Sa Date: Wed, 7 Oct 2020 12:01:43 -0300 Subject: [PATCH 2/3] Use helper function GetPeepAnimation It's intended to retrieve a rct_peep_animation_entry from the global array g_peep_animation_entries, given PeepSpriteType and PeepActionSpriteType as parameters. --- src/openrct2-ui/windows/GameBottomToolbar.cpp | 2 +- src/openrct2-ui/windows/Guest.cpp | 6 ++---- src/openrct2-ui/windows/GuestList.cpp | 2 +- src/openrct2-ui/windows/News.cpp | 7 ++++--- src/openrct2-ui/windows/Park.cpp | 2 +- src/openrct2-ui/windows/Ride.cpp | 2 +- src/openrct2-ui/windows/Staff.cpp | 7 ++----- src/openrct2-ui/windows/StaffList.cpp | 8 ++++---- src/openrct2/paint/sprite/Paint.Peep.cpp | 10 ++++------ src/openrct2/peep/Peep.cpp | 4 ++-- src/openrct2/peep/Peep.h | 8 +++++++- src/openrct2/peep/PeepData.cpp | 2 +- 12 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/openrct2-ui/windows/GameBottomToolbar.cpp b/src/openrct2-ui/windows/GameBottomToolbar.cpp index 1d2ae9d241..53b767bc6b 100644 --- a/src/openrct2-ui/windows/GameBottomToolbar.cpp +++ b/src/openrct2-ui/windows/GameBottomToolbar.cpp @@ -597,7 +597,7 @@ static void window_game_bottom_toolbar_draw_news_item(rct_drawpixelinfo* dpi, rc clipCoords.y += 3; } - uint32_t image_id_base = g_peep_animation_entries[EnumValue(peep->SpriteType)].sprite_animation->base_image; + uint32_t image_id_base = GetPeepAnimation(peep->SpriteType).base_image; image_id_base += w->frame_no & 0xFFFFFFFC; image_id_base++; diff --git a/src/openrct2-ui/windows/Guest.cpp b/src/openrct2-ui/windows/Guest.cpp index 9a764c182a..a8ce6aee51 100644 --- a/src/openrct2-ui/windows/Guest.cpp +++ b/src/openrct2-ui/windows/Guest.cpp @@ -761,7 +761,7 @@ static void window_guest_overview_tab_paint(rct_window* w, rct_drawpixelinfo* dp if (peep->AssignedPeepType == PeepType::Staff && peep->AssignedStaffType == StaffType::Entertainer) screenCoords.y++; - int32_t animationFrame = g_peep_animation_entries[EnumValue(peep->SpriteType)].sprite_animation->base_image + 1; + int32_t animationFrame = GetPeepAnimation(peep->SpriteType).base_image + 1; int32_t animationFrameOffset = 0; @@ -1163,9 +1163,7 @@ void window_guest_overview_tool_update(rct_window* w, rct_widgetindex widgetInde return; } - uint32_t imageId = g_peep_animation_entries[EnumValue(peep->SpriteType)] - .sprite_animation[EnumValue(PeepActionSpriteType::Ui)] - .base_image; + uint32_t imageId = GetPeepAnimation(peep->SpriteType, PeepActionSpriteType::Ui).base_image; imageId += w->picked_peep_frame >> 2; imageId |= (peep->TshirtColour << 19) | (peep->TrousersColour << 24) | IMAGE_TYPE_REMAP | IMAGE_TYPE_REMAP_2_PLUS; diff --git a/src/openrct2-ui/windows/GuestList.cpp b/src/openrct2-ui/windows/GuestList.cpp index f38550f6d8..5cb03c905f 100644 --- a/src/openrct2-ui/windows/GuestList.cpp +++ b/src/openrct2-ui/windows/GuestList.cpp @@ -670,7 +670,7 @@ static void window_guest_list_paint(rct_window* w, rct_drawpixelinfo* dpi) window_draw_widgets(w, dpi); // Tab 1 image i = (_window_guest_list_selected_tab == 0 ? w->list_information_type & 0x0FFFFFFFC : 0); - i += g_peep_animation_entries[EnumValue(PeepSpriteType::Normal)].sprite_animation->base_image + 1; + i += GetPeepAnimation(PeepSpriteType::Normal).base_image + 1; i |= 0xA1600000; gfx_draw_sprite( dpi, i, diff --git a/src/openrct2-ui/windows/News.cpp b/src/openrct2-ui/windows/News.cpp index ecaa5a880b..887afa539c 100644 --- a/src/openrct2-ui/windows/News.cpp +++ b/src/openrct2-ui/windows/News.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -287,17 +288,17 @@ static void window_news_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32 // If normal peep set sprite to normal (no food) // If staff set sprite to staff sprite - int32_t sprite_type = 0; + auto spriteType = PeepSpriteType::Normal; if (peep->AssignedPeepType == PeepType::Staff) { - sprite_type = EnumValue(peep->SpriteType); + spriteType = peep->SpriteType; if (peep->AssignedStaffType == StaffType::Entertainer) { clipCoords.y += 3; } } - uint32_t image_id = g_peep_animation_entries[sprite_type].sprite_animation->base_image; + uint32_t image_id = GetPeepAnimation(spriteType).base_image; image_id += 0xA0000001; image_id |= (peep->TshirtColour << 19) | (peep->TrousersColour << 24); diff --git a/src/openrct2-ui/windows/Park.cpp b/src/openrct2-ui/windows/Park.cpp index aeb791d42a..8e8898c642 100644 --- a/src/openrct2-ui/windows/Park.cpp +++ b/src/openrct2-ui/windows/Park.cpp @@ -1726,7 +1726,7 @@ static void window_park_draw_tab_images(rct_drawpixelinfo* dpi, rct_window* w) gfx_draw_sprite( dpi, sprite_idx, w->windowPos + ScreenCoordsXY{ w->widgets[WIDX_TAB_3].left, w->widgets[WIDX_TAB_3].top }, 0); - sprite_idx = g_peep_animation_entries[EnumValue(PeepSpriteType::Normal)].sprite_animation->base_image + 1; + sprite_idx = GetPeepAnimation(PeepSpriteType::Normal).base_image + 1; if (w->page == WINDOW_PARK_PAGE_GUESTS) sprite_idx += w->var_492 & 0xFFFFFFFC; diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index 39eed43f19..0e9cdf6f57 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -1098,7 +1098,7 @@ static void window_ride_draw_tab_customer(rct_drawpixelinfo* dpi, rct_window* w) if (w->page == WINDOW_RIDE_PAGE_CUSTOMER) spriteIndex = w->picked_peep_frame & ~3; - spriteIndex += g_peep_animation_entries[EnumValue(PeepSpriteType::Normal)].sprite_animation->base_image; + spriteIndex += GetPeepAnimation(PeepSpriteType::Normal).base_image; spriteIndex += 1; spriteIndex |= 0xA9E00000; diff --git a/src/openrct2-ui/windows/Staff.cpp b/src/openrct2-ui/windows/Staff.cpp index b0dd4b3ede..dafd756498 100644 --- a/src/openrct2-ui/windows/Staff.cpp +++ b/src/openrct2-ui/windows/Staff.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -1023,7 +1022,7 @@ void window_staff_overview_tab_paint(rct_window* w, rct_drawpixelinfo* dpi) if (peep->AssignedPeepType == PeepType::Staff && peep->AssignedStaffType == StaffType::Entertainer) screenCoords.y++; - int32_t ebx = g_peep_animation_entries[EnumValue(peep->SpriteType)].sprite_animation->base_image + 1; + int32_t ebx = GetPeepAnimation(peep->SpriteType).base_image + 1; int32_t eax = 0; @@ -1189,9 +1188,7 @@ void window_staff_overview_tool_update(rct_window* w, rct_widgetindex widgetInde return; } - uint32_t imageId = g_peep_animation_entries[EnumValue(peep->SpriteType)] - .sprite_animation[EnumValue(PeepActionSpriteType::Ui)] - .base_image; + uint32_t imageId = GetPeepAnimation(peep->SpriteType, PeepActionSpriteType::Ui).base_image; imageId += w->picked_peep_frame >> 2; imageId |= (peep->TshirtColour << 19) | (peep->TrousersColour << 24) | IMAGE_TYPE_REMAP | IMAGE_TYPE_REMAP_2_PLUS; diff --git a/src/openrct2-ui/windows/StaffList.cpp b/src/openrct2-ui/windows/StaffList.cpp index e0eb0549b0..2b27f8690c 100644 --- a/src/openrct2-ui/windows/StaffList.cpp +++ b/src/openrct2-ui/windows/StaffList.cpp @@ -563,7 +563,7 @@ void window_staff_list_paint(rct_window* w, rct_drawpixelinfo* dpi) // Handymen tab image i = (selectedTab == 0 ? (w->list_information_type & ~3) : 0); - i += g_peep_animation_entries[EnumValue(PeepSpriteType::Handyman)].sprite_animation->base_image + 1; + i += GetPeepAnimation(PeepSpriteType::Handyman).base_image + 1; i |= SPRITE_ID_PALETTE_COLOUR_1(gStaffHandymanColour); gfx_draw_sprite( dpi, i, @@ -576,7 +576,7 @@ void window_staff_list_paint(rct_window* w, rct_drawpixelinfo* dpi) // Mechanic tab image i = (selectedTab == 1 ? (w->list_information_type & ~3) : 0); - i += g_peep_animation_entries[EnumValue(PeepSpriteType::Mechanic)].sprite_animation->base_image + 1; + i += GetPeepAnimation(PeepSpriteType::Mechanic).base_image + 1; i |= SPRITE_ID_PALETTE_COLOUR_1(gStaffMechanicColour); gfx_draw_sprite( dpi, i, @@ -589,7 +589,7 @@ void window_staff_list_paint(rct_window* w, rct_drawpixelinfo* dpi) // Security tab image i = (selectedTab == 2 ? (w->list_information_type & ~3) : 0); - i += g_peep_animation_entries[EnumValue(PeepSpriteType::Security)].sprite_animation->base_image + 1; + i += GetPeepAnimation(PeepSpriteType::Security).base_image + 1; i |= SPRITE_ID_PALETTE_COLOUR_1(gStaffSecurityColour); gfx_draw_sprite( dpi, i, @@ -613,7 +613,7 @@ void window_staff_list_paint(rct_window* w, rct_drawpixelinfo* dpi) { // Entertainers tab image i = (selectedTab == 3 ? (w->list_information_type & ~3) : 0); - i += g_peep_animation_entries[EnumValue(PeepSpriteType::EntertainerElephant)].sprite_animation->base_image + 1; + i += GetPeepAnimation(PeepSpriteType::EntertainerElephant).base_image + 1; gfx_draw_sprite(&sprite_dpi, i, { 0x0F, 0x17 }, 0); } diff --git a/src/openrct2/paint/sprite/Paint.Peep.cpp b/src/openrct2/paint/sprite/Paint.Peep.cpp index 19df4a8518..022bd57c90 100644 --- a/src/openrct2/paint/sprite/Paint.Peep.cpp +++ b/src/openrct2/paint/sprite/Paint.Peep.cpp @@ -11,7 +11,6 @@ #include "../../drawing/LightFX.h" #include "../../interface/Viewport.h" #include "../../peep/Peep.h" -#include "../../util/Util.h" #include "../../world/Sprite.h" #include "../Paint.h" #include "Paint.Sprite.h" @@ -68,20 +67,19 @@ void peep_paint(paint_session* session, const Peep* peep, int32_t imageDirection return; } - rct_peep_animation_entry sprite = g_peep_animation_entries[EnumValue(peep->SpriteType)]; - - PeepActionSpriteType spriteType = peep->ActionSpriteType; + PeepActionSpriteType actionSpriteType = peep->ActionSpriteType; uint8_t imageOffset = peep->ActionSpriteImageOffset; if (peep->Action == PeepActionType::None1) { - spriteType = peep->NextActionSpriteType; + actionSpriteType = peep->NextActionSpriteType; imageOffset = 0; } // In the following 4 calls to sub_98197C/sub_98199C, we add 5 (instead of 3) to the // bound_box_offset_z to make sure peeps are drawn on top of railways - uint32_t baseImageId = (imageDirection >> 3) + sprite.sprite_animation[EnumValue(spriteType)].base_image + imageOffset * 4; + uint32_t baseImageId = (imageDirection >> 3) + GetPeepAnimation(peep->SpriteType, actionSpriteType).base_image + + imageOffset * 4; uint32_t imageId = baseImageId | peep->TshirtColour << 19 | peep->TrousersColour << 24 | IMAGE_TYPE_REMAP | IMAGE_TYPE_REMAP_2_PLUS; sub_98197C(session, imageId, 0, 0, 1, 1, 11, peep->z, 0, 0, peep->z + 5); diff --git a/src/openrct2/peep/Peep.cpp b/src/openrct2/peep/Peep.cpp index 2a2ef81c95..109bb097af 100644 --- a/src/openrct2/peep/Peep.cpp +++ b/src/openrct2/peep/Peep.cpp @@ -598,7 +598,7 @@ std::optional Peep::UpdateAction(int16_t& xy_distance) CoordsXY loc = { x, y }; loc += word_981D7C[nextDirection / 8]; WalkingFrameNum++; - const rct_peep_animation* peepAnimation = g_peep_animation_entries[EnumValue(SpriteType)].sprite_animation; + const rct_peep_animation* peepAnimation = &GetPeepAnimation(SpriteType); const uint8_t* imageOffset = peepAnimation[EnumValue(ActionSpriteType)].frame_offsets; if (WalkingFrameNum >= peepAnimation[EnumValue(ActionSpriteType)].num_frames) { @@ -608,7 +608,7 @@ std::optional Peep::UpdateAction(int16_t& xy_distance) return loc; } - const rct_peep_animation* peepAnimation = g_peep_animation_entries[EnumValue(SpriteType)].sprite_animation; + const rct_peep_animation* peepAnimation = &GetPeepAnimation(SpriteType); ActionFrame++; // If last frame of action diff --git a/src/openrct2/peep/Peep.h b/src/openrct2/peep/Peep.h index 8786e3976b..18d9477155 100644 --- a/src/openrct2/peep/Peep.h +++ b/src/openrct2/peep/Peep.h @@ -1037,7 +1037,7 @@ enum }; // rct2: 0x00982708 -extern rct_peep_animation_entry g_peep_animation_entries[EnumValue(PeepSpriteType::Count)]; +extern const rct_peep_animation_entry g_peep_animation_entries[EnumValue(PeepSpriteType::Count)]; extern const bool gSpriteTypeToSlowWalkMap[48]; extern uint8_t gGuestChangeModifier; @@ -1085,4 +1085,10 @@ void decrement_guests_heading_for_park(); rct_string_id get_real_name_string_id_from_id(uint32_t id); +inline const rct_peep_animation& GetPeepAnimation( + PeepSpriteType spriteType, PeepActionSpriteType actionSpriteType = PeepActionSpriteType::None) +{ + return g_peep_animation_entries[EnumValue(spriteType)].sprite_animation[EnumValue(actionSpriteType)]; +}; + #endif diff --git a/src/openrct2/peep/PeepData.cpp b/src/openrct2/peep/PeepData.cpp index 4f6d54d8e1..eb851b3308 100644 --- a/src/openrct2/peep/PeepData.cpp +++ b/src/openrct2/peep/PeepData.cpp @@ -5399,7 +5399,7 @@ static constexpr const rct_sprite_bounds PeepSpriteBounds_Sandwich[] = { }; -rct_peep_animation_entry g_peep_animation_entries[] = +constexpr rct_peep_animation_entry g_peep_animation_entries[] = { { PeepSpriteImage_Normal, PeepSpriteBounds_Normal }, { PeepSpriteImage_Handyman, PeepSpriteBounds_Handyman }, From 01d237ad272ddd8a4f4a4c88ea4bb8aee5811a3e Mon Sep 17 00:00:00 2001 From: Vinicius Sa Date: Wed, 7 Oct 2020 17:02:38 -0300 Subject: [PATCH 3/3] Use helper function GetSpriteBounds It's intended to retrieve a rct_sprite_bounds from the global array g_peep_animation_entries, given PeepSpriteType and PeepActionSpriteType as parameters. --- src/openrct2/actions/StaffHireNewAction.hpp | 3 +-- src/openrct2/peep/Peep.cpp | 24 ++++++++++----------- src/openrct2/peep/Peep.h | 6 ++++++ src/openrct2/rct1/S4Importer.cpp | 8 +++---- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/openrct2/actions/StaffHireNewAction.hpp b/src/openrct2/actions/StaffHireNewAction.hpp index 412ea50d89..e88e172951 100644 --- a/src/openrct2/actions/StaffHireNewAction.hpp +++ b/src/openrct2/actions/StaffHireNewAction.hpp @@ -22,7 +22,6 @@ #include "../scenario/Scenario.h" #include "../ui/UiContext.h" #include "../ui/WindowManager.h" -#include "../util/Util.h" #include "../world/Entrance.h" #include "../world/Park.h" #include "../world/Sprite.h" @@ -210,7 +209,7 @@ private: newPeep->Name = nullptr; newPeep->SpriteType = spriteType; - const rct_sprite_bounds* spriteBounds = g_peep_animation_entries[EnumValue(spriteType)].sprite_bounds; + const rct_sprite_bounds* spriteBounds = &GetSpriteBounds(spriteType); newPeep->sprite_width = spriteBounds->sprite_width; newPeep->sprite_height_negative = spriteBounds->sprite_height_negative; newPeep->sprite_height_positive = spriteBounds->sprite_height_positive; diff --git a/src/openrct2/peep/Peep.cpp b/src/openrct2/peep/Peep.cpp index 109bb097af..7715b063b6 100644 --- a/src/openrct2/peep/Peep.cpp +++ b/src/openrct2/peep/Peep.cpp @@ -509,10 +509,10 @@ void Peep::UpdateCurrentActionSpriteType() Invalidate(); ActionSpriteType = newActionSpriteType; - const rct_sprite_bounds* spriteBounds = g_peep_animation_entries[EnumValue(SpriteType)].sprite_bounds; - sprite_width = spriteBounds[EnumValue(ActionSpriteType)].sprite_width; - sprite_height_negative = spriteBounds[EnumValue(ActionSpriteType)].sprite_height_negative; - sprite_height_positive = spriteBounds[EnumValue(ActionSpriteType)].sprite_height_positive; + const rct_sprite_bounds* spriteBounds = &GetSpriteBounds(SpriteType, ActionSpriteType); + sprite_width = spriteBounds->sprite_width; + sprite_height_negative = spriteBounds->sprite_height_negative; + sprite_height_positive = spriteBounds->sprite_height_positive; Invalidate(); } @@ -1591,10 +1591,10 @@ Peep* Peep::Generate(const CoordsXYZ& coords) peep->FavouriteRide = RIDE_ID_NULL; peep->FavouriteRideRating = 0; - const rct_sprite_bounds* spriteBounds = g_peep_animation_entries[EnumValue(peep->SpriteType)].sprite_bounds; - peep->sprite_width = spriteBounds[EnumValue(peep->ActionSpriteType)].sprite_width; - peep->sprite_height_negative = spriteBounds[EnumValue(peep->ActionSpriteType)].sprite_height_negative; - peep->sprite_height_positive = spriteBounds[EnumValue(peep->ActionSpriteType)].sprite_height_positive; + const rct_sprite_bounds* spriteBounds = &GetSpriteBounds(peep->SpriteType, peep->ActionSpriteType); + peep->sprite_width = spriteBounds->sprite_width; + peep->sprite_height_negative = spriteBounds->sprite_height_negative; + peep->sprite_height_positive = spriteBounds->sprite_height_positive; peep->MoveTo(coords); peep->sprite_direction = 0; @@ -2192,10 +2192,10 @@ void Peep::SwitchNextActionSpriteType() { Invalidate(); ActionSpriteType = NextActionSpriteType; - const rct_sprite_bounds* spriteBounds = g_peep_animation_entries[EnumValue(SpriteType)].sprite_bounds; - sprite_width = spriteBounds[EnumValue(NextActionSpriteType)].sprite_width; - sprite_height_negative = spriteBounds[EnumValue(NextActionSpriteType)].sprite_height_negative; - sprite_height_positive = spriteBounds[EnumValue(NextActionSpriteType)].sprite_height_positive; + const rct_sprite_bounds* spriteBounds = &GetSpriteBounds(SpriteType, NextActionSpriteType); + sprite_width = spriteBounds->sprite_width; + sprite_height_negative = spriteBounds->sprite_height_negative; + sprite_height_positive = spriteBounds->sprite_height_positive; Invalidate(); } } diff --git a/src/openrct2/peep/Peep.h b/src/openrct2/peep/Peep.h index 18d9477155..68335bbcb3 100644 --- a/src/openrct2/peep/Peep.h +++ b/src/openrct2/peep/Peep.h @@ -1091,4 +1091,10 @@ inline const rct_peep_animation& GetPeepAnimation( return g_peep_animation_entries[EnumValue(spriteType)].sprite_animation[EnumValue(actionSpriteType)]; }; +inline const rct_sprite_bounds& GetSpriteBounds( + PeepSpriteType spriteType, PeepActionSpriteType actionSpriteType = PeepActionSpriteType::None) +{ + return g_peep_animation_entries[EnumValue(spriteType)].sprite_bounds[EnumValue(actionSpriteType)]; +}; + #endif diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index a7a1b1b75f..f95c4ae040 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -1409,10 +1409,10 @@ private: dst->ActionSpriteType = static_cast(src->action_sprite_type); dst->ActionFrame = src->action_frame; - const rct_sprite_bounds* spriteBounds = g_peep_animation_entries[EnumValue(dst->SpriteType)].sprite_bounds; - dst->sprite_width = spriteBounds[EnumValue(dst->ActionSpriteType)].sprite_width; - dst->sprite_height_negative = spriteBounds[EnumValue(dst->ActionSpriteType)].sprite_height_negative; - dst->sprite_height_positive = spriteBounds[EnumValue(dst->ActionSpriteType)].sprite_height_positive; + const rct_sprite_bounds* spriteBounds = &GetSpriteBounds(dst->SpriteType, dst->ActionSpriteType); + dst->sprite_width = spriteBounds->sprite_width; + dst->sprite_height_negative = spriteBounds->sprite_height_negative; + dst->sprite_height_positive = spriteBounds->sprite_height_positive; dst->MoveTo({ src->x, src->y, src->z }); dst->Invalidate2();