diff --git a/src/openrct2-ui/interface/ViewportInteraction.cpp b/src/openrct2-ui/interface/ViewportInteraction.cpp index 20e82e2dc9..206d9783b6 100644 --- a/src/openrct2-ui/interface/ViewportInteraction.cpp +++ b/src/openrct2-ui/interface/ViewportInteraction.cpp @@ -636,7 +636,7 @@ static Peep* viewport_interaction_get_closest_peep(ScreenCoordsXY screenCoords, Peep* closestPeep = nullptr; auto closestDistance = std::numeric_limits::max(); - for (auto peep : EntityList(SPRITE_LIST_PEEP)) + for (auto peep : EntityList(EntityListId::Peep)) { if (peep->sprite_left == LOCATION_NULL) continue; diff --git a/src/openrct2-ui/windows/EditorBottomToolbar.cpp b/src/openrct2-ui/windows/EditorBottomToolbar.cpp index e02d1570dd..2918e80e00 100644 --- a/src/openrct2-ui/windows/EditorBottomToolbar.cpp +++ b/src/openrct2-ui/windows/EditorBottomToolbar.cpp @@ -310,7 +310,8 @@ static void window_editor_bottom_toolbar_mouseup([[maybe_unused]] rct_window* w, if (widgetIndex == WIDX_PREVIOUS_STEP_BUTTON) { if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) - || (gSpriteListCount[SPRITE_LIST_FREE] == MAX_SPRITES && !(gParkFlags & PARK_FLAGS_SPRITES_INITIALISED))) + || (gSpriteListCount[static_cast(EntityListId::Free)] == MAX_SPRITES + && !(gParkFlags & PARK_FLAGS_SPRITES_INITIALISED))) { previous_button_mouseup_events[gS6Info.editor_step](); } @@ -370,7 +371,8 @@ void window_editor_bottom_toolbar_invalidate(rct_window* w) } else if (!(gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER)) { - if (gSpriteListCount[SPRITE_LIST_FREE] != MAX_SPRITES || gParkFlags & PARK_FLAGS_SPRITES_INITIALISED) + if (gSpriteListCount[static_cast(EntityListId::Free)] != MAX_SPRITES + || gParkFlags & PARK_FLAGS_SPRITES_INITIALISED) { hide_previous_step_button(); } @@ -395,7 +397,7 @@ void window_editor_bottom_toolbar_paint(rct_window* w, rct_drawpixelinfo* dpi) { drawPreviousButton = true; } - else if (gSpriteListCount[SPRITE_LIST_FREE] != MAX_SPRITES) + else if (gSpriteListCount[static_cast(EntityListId::Free)] != MAX_SPRITES) { drawNextButton = true; } diff --git a/src/openrct2-ui/windows/GuestList.cpp b/src/openrct2-ui/windows/GuestList.cpp index 2e9570642b..09a60c22fe 100644 --- a/src/openrct2-ui/windows/GuestList.cpp +++ b/src/openrct2-ui/windows/GuestList.cpp @@ -248,7 +248,7 @@ void window_guest_list_refresh_list() } GuestList.clear(); - for (auto peep : EntityList(SPRITE_LIST_PEEP)) + for (auto peep : EntityList(EntityListId::Peep)) { sprite_set_flashing(peep, false); if (peep->OutsideOfPark) @@ -948,7 +948,7 @@ static void window_guest_list_find_groups() // Set all guests to unassigned { - for (auto peep : EntityList(SPRITE_LIST_PEEP)) + for (auto peep : EntityList(EntityListId::Peep)) { if (!peep->OutsideOfPark) { @@ -957,7 +957,7 @@ static void window_guest_list_find_groups() } } // For each guest / group - for (auto peep : EntityList(SPRITE_LIST_PEEP)) + for (auto peep : EntityList(EntityListId::Peep)) { if (peep->OutsideOfPark || !(peep->flags & SPRITE_FLAGS_PEEP_VISIBLE)) continue; @@ -980,7 +980,7 @@ static void window_guest_list_find_groups() - SPR_PEEP_SMALL_FACE_VERY_VERY_UNHAPPY; // Find more peeps that belong to same group - for (auto peep2 : EntityList(SPRITE_LIST_PEEP)) + for (auto peep2 : EntityList(EntityListId::Peep)) { if (peep2->OutsideOfPark || !(peep2->flags & SPRITE_FLAGS_PEEP_VISIBLE)) continue; diff --git a/src/openrct2-ui/windows/Map.cpp b/src/openrct2-ui/windows/Map.cpp index f21c679182..cae053e090 100644 --- a/src/openrct2-ui/windows/Map.cpp +++ b/src/openrct2-ui/windows/Map.cpp @@ -1054,7 +1054,7 @@ static MapCoordsXY window_map_transform_to_map_coords(CoordsXY c) */ static void window_map_paint_peep_overlay(rct_drawpixelinfo* dpi) { - for (auto peep : EntityList(SPRITE_LIST_PEEP)) + for (auto peep : EntityList(EntityListId::Peep)) { if (peep->x == LOCATION_NULL) continue; @@ -1101,7 +1101,7 @@ static void window_map_paint_peep_overlay(rct_drawpixelinfo* dpi) */ static void window_map_paint_train_overlay(rct_drawpixelinfo* dpi) { - for (auto train : EntityList(SPRITE_LIST_TRAIN_HEAD)) + for (auto train : EntityList(EntityListId::TrainHead)) { Vehicle* vehicle = nullptr; for (auto vehicle_index = train->sprite_index; vehicle_index != SPRITE_INDEX_NULL; diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index 0bef099967..b7ae6e13e6 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -4266,7 +4266,7 @@ static void window_ride_maintenance_paint(rct_window* w, rct_drawpixelinfo* dpi) { stringId = STR_NO_MECHANICS_ARE_HIRED_MESSAGE; - for (auto peep : EntityList(SPRITE_LIST_PEEP)) + for (auto peep : EntityList(EntityListId::Peep)) { if (peep->StaffType == STAFF_TYPE_MECHANIC) { diff --git a/src/openrct2-ui/windows/StaffList.cpp b/src/openrct2-ui/windows/StaffList.cpp index fd3c3961b7..215244f95d 100644 --- a/src/openrct2-ui/windows/StaffList.cpp +++ b/src/openrct2-ui/windows/StaffList.cpp @@ -189,7 +189,7 @@ void WindowStaffListRefresh() } StaffList.clear(); - for (auto peep : EntityList(SPRITE_LIST_PEEP)) + for (auto peep : EntityList(EntityListId::Peep)) { sprite_set_flashing(peep, false); if (peep->StaffType != _windowStaffListSelectedTab) @@ -338,7 +338,7 @@ void window_staff_list_update(rct_window* w) if (window_find_by_class(WC_MAP) != nullptr) { gWindowMapFlashingFlags |= (1 << 2); - for (auto peep : EntityList(SPRITE_LIST_PEEP)) + for (auto peep : EntityList(EntityListId::Peep)) { sprite_set_flashing(peep, false); @@ -376,7 +376,7 @@ static void window_staff_list_tooldown(rct_window* w, rct_widgetindex widgetInde Peep* closestPeep = nullptr; int32_t closestPeepDistance = std::numeric_limits::max(); - for (auto peep : EntityList(SPRITE_LIST_PEEP)) + for (auto peep : EntityList(EntityListId::Peep)) { if (peep->StaffType != selectedPeepType) continue; diff --git a/src/openrct2/Game.cpp b/src/openrct2/Game.cpp index 8b98453b9d..57b6556de8 100644 --- a/src/openrct2/Game.cpp +++ b/src/openrct2/Game.cpp @@ -434,7 +434,7 @@ void game_fix_save_vars() // Recalculates peep count after loading a save to fix corrupted files uint32_t guestCount = 0; { - for (auto guest : EntityList(SPRITE_LIST_PEEP)) + for (auto guest : EntityList(EntityListId::Peep)) { if (!guest->OutsideOfPark) { @@ -449,7 +449,7 @@ void game_fix_save_vars() std::vector peepsToRemove; // Fix possibly invalid field values - for (auto peep : EntityList(SPRITE_LIST_PEEP)) + for (auto peep : EntityList(EntityListId::Peep)) { if (peep->CurrentRideStation >= MAX_STATIONS) { diff --git a/src/openrct2/actions/RideDemolishAction.hpp b/src/openrct2/actions/RideDemolishAction.hpp index 7430994478..87506d6b1b 100644 --- a/src/openrct2/actions/RideDemolishAction.hpp +++ b/src/openrct2/actions/RideDemolishAction.hpp @@ -153,7 +153,7 @@ private: } } - for (auto peep : EntityList(SPRITE_LIST_PEEP)) + for (auto peep : EntityList(EntityListId::Peep)) { uint8_t ride_id_bit = _rideIndex % 8; uint8_t ride_id_offset = _rideIndex / 8; diff --git a/src/openrct2/actions/SetCheatAction.hpp b/src/openrct2/actions/SetCheatAction.hpp index 56ccb113c0..63c0b31df6 100644 --- a/src/openrct2/actions/SetCheatAction.hpp +++ b/src/openrct2/actions/SetCheatAction.hpp @@ -427,7 +427,7 @@ private: void RemoveLitter() const { - for (auto litter : EntityList(SPRITE_LIST_LITTER)) + for (auto litter : EntityList(EntityListId::Litter)) { sprite_remove(litter); } @@ -570,7 +570,7 @@ private: void SetGuestParameter(int32_t parameter, int32_t value) const { - for (auto peep : EntityList(SPRITE_LIST_PEEP)) + for (auto peep : EntityList(EntityListId::Peep)) { switch (parameter) { @@ -614,7 +614,7 @@ private: void GiveObjectToGuests(int32_t object) const { - for (auto peep : EntityList(SPRITE_LIST_PEEP)) + for (auto peep : EntityList(EntityListId::Peep)) { switch (object) { @@ -686,7 +686,7 @@ private: // Do not use the FOR_ALL_PEEPS macro for this as next sprite index // will be fetched on a deleted peep. - for (auto peep : EntityList(SPRITE_LIST_PEEP)) + for (auto peep : EntityList(EntityListId::Peep)) { if (peep->AssignedPeepType == PEEP_TYPE_GUEST) { @@ -700,7 +700,7 @@ private: void ExplodeGuests() const { - for (auto peep : EntityList(SPRITE_LIST_PEEP)) + for (auto peep : EntityList(EntityListId::Peep)) { if (scenario_rand_max(6) == 0) { @@ -711,7 +711,7 @@ private: void SetStaffSpeed(uint8_t value) const { - for (auto peep : EntityList(SPRITE_LIST_PEEP)) + for (auto peep : EntityList(EntityListId::Peep)) { peep->Energy = value; peep->EnergyTarget = value; diff --git a/src/openrct2/actions/StaffHireNewAction.hpp b/src/openrct2/actions/StaffHireNewAction.hpp index ccdf936b52..c89f9c131b 100644 --- a/src/openrct2/actions/StaffHireNewAction.hpp +++ b/src/openrct2/actions/StaffHireNewAction.hpp @@ -105,7 +105,7 @@ private: return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); } - if (gSpriteListCount[SPRITE_LIST_FREE] < 400) + if (gSpriteListCount[static_cast(EntityListId::Free)] < 400) { return MakeResult(GA_ERROR::NO_FREE_ELEMENTS, STR_TOO_MANY_PEOPLE_IN_GAME); } @@ -182,7 +182,7 @@ private: { bool found = false; ++newStaffId; - for (auto searchPeep : EntityList(SPRITE_LIST_PEEP)) + for (auto searchPeep : EntityList(EntityListId::Peep)) { if (searchPeep->StaffType != _staffType) continue; @@ -267,7 +267,7 @@ private: // Count number of walking guests { - for (auto guest : EntityList(SPRITE_LIST_PEEP)) + for (auto guest : EntityList(EntityListId::Peep)) { if (guest->State == PEEP_STATE_WALKING) { @@ -286,7 +286,7 @@ private: uint32_t rand = scenario_rand_max(count); Guest* chosenGuest = nullptr; - for (auto guest : EntityList(SPRITE_LIST_PEEP)) + for (auto guest : EntityList(EntityListId::Peep)) { if (guest->State == PEEP_STATE_WALKING) { diff --git a/src/openrct2/actions/StaffSetColourAction.hpp b/src/openrct2/actions/StaffSetColourAction.hpp index 3115bef2e9..064684beb4 100644 --- a/src/openrct2/actions/StaffSetColourAction.hpp +++ b/src/openrct2/actions/StaffSetColourAction.hpp @@ -65,7 +65,7 @@ public: } // Update each staff member's uniform - for (auto peep : EntityList(SPRITE_LIST_PEEP)) + for (auto peep : EntityList(EntityListId::Peep)) { if (peep->StaffType == _staffType) { diff --git a/src/openrct2/interface/InteractiveConsole.cpp b/src/openrct2/interface/InteractiveConsole.cpp index c2961ca56f..13c363889f 100644 --- a/src/openrct2/interface/InteractiveConsole.cpp +++ b/src/openrct2/interface/InteractiveConsole.cpp @@ -437,7 +437,7 @@ static int32_t cc_staff(InteractiveConsole& console, const arguments_t& argv) { if (argv[0] == "list") { - for (auto peep : EntityList(SPRITE_LIST_PEEP)) + for (auto peep : EntityList(EntityListId::Peep)) { auto name = peep->GetName(); console.WriteFormatLine( @@ -1223,7 +1223,7 @@ static int32_t cc_show_limits(InteractiveConsole& console, [[maybe_unused]] cons int32_t rideCount = ride_get_count(); int32_t spriteCount = 0; - for (int32_t i = 1; i < SPRITE_LIST_COUNT; ++i) + for (int32_t i = 1; i < static_cast(EntityListId::Count); ++i) { spriteCount += gSpriteListCount[i]; } diff --git a/src/openrct2/management/Award.cpp b/src/openrct2/management/Award.cpp index 8623f8537d..c99fb35ed6 100644 --- a/src/openrct2/management/Award.cpp +++ b/src/openrct2/management/Award.cpp @@ -84,7 +84,7 @@ static bool award_is_deserved_most_untidy(int32_t activeAwardTypes) return false; uint32_t negativeCount = 0; - for (auto peep : EntityList(SPRITE_LIST_PEEP)) + for (auto peep : EntityList(EntityListId::Peep)) { if (peep->OutsideOfPark) continue; @@ -113,7 +113,7 @@ static bool award_is_deserved_most_tidy(int32_t activeAwardTypes) uint32_t positiveCount = 0; uint32_t negativeCount = 0; - for (auto peep : EntityList(SPRITE_LIST_PEEP)) + for (auto peep : EntityList(EntityListId::Peep)) { if (peep->OutsideOfPark) continue; @@ -193,7 +193,7 @@ static bool award_is_deserved_most_beautiful(int32_t activeAwardTypes) uint32_t positiveCount = 0; uint32_t negativeCount = 0; - auto list = EntityList(SPRITE_LIST_PEEP); + auto list = EntityList(EntityListId::Peep); for (auto peep : list) { if (peep->OutsideOfPark) @@ -236,7 +236,7 @@ static bool award_is_deserved_worst_value(int32_t activeAwardTypes) static bool award_is_deserved_safest([[maybe_unused]] int32_t activeAwardTypes) { auto peepsWhoDislikeVandalism = 0; - for (auto peep : EntityList(SPRITE_LIST_PEEP)) + for (auto peep : EntityList(EntityListId::Peep)) { if (peep->OutsideOfPark) continue; @@ -268,7 +268,7 @@ static bool award_is_deserved_best_staff(int32_t activeAwardTypes) auto peepCount = 0; auto staffCount = 0; auto staffTypeFlags = 0; - for (auto peep : EntityList(SPRITE_LIST_PEEP)) + for (auto peep : EntityList(EntityListId::Peep)) { if (peep->AssignedPeepType == PEEP_TYPE_STAFF) { @@ -317,7 +317,7 @@ static bool award_is_deserved_best_food(int32_t activeAwardTypes) // Count hungry peeps auto hungryPeeps = 0; - for (auto peep : EntityList(SPRITE_LIST_PEEP)) + for (auto peep : EntityList(EntityListId::Peep)) { if (peep->OutsideOfPark) continue; @@ -361,7 +361,7 @@ static bool award_is_deserved_worst_food(int32_t activeAwardTypes) // Count hungry peeps auto hungryPeeps = 0; - for (auto peep : EntityList(SPRITE_LIST_PEEP)) + for (auto peep : EntityList(EntityListId::Peep)) { if (peep->OutsideOfPark) continue; @@ -391,7 +391,7 @@ static bool award_is_deserved_best_restrooms([[maybe_unused]] int32_t activeAwar // Count number of guests who are thinking they need the restroom auto guestsWhoNeedRestroom = 0; - for (auto peep : EntityList(SPRITE_LIST_PEEP)) + for (auto peep : EntityList(EntityListId::Peep)) { if (peep->OutsideOfPark) continue; @@ -518,7 +518,7 @@ static bool award_is_deserved_most_confusing_layout([[maybe_unused]] int32_t act { uint32_t peepsCounted = 0; uint32_t peepsLost = 0; - for (auto peep : EntityList(SPRITE_LIST_PEEP)) + for (auto peep : EntityList(EntityListId::Peep)) { if (peep->OutsideOfPark) continue; diff --git a/src/openrct2/management/Finance.cpp b/src/openrct2/management/Finance.cpp index 5f03b0bb42..fa994fe843 100644 --- a/src/openrct2/management/Finance.cpp +++ b/src/openrct2/management/Finance.cpp @@ -111,7 +111,7 @@ void finance_pay_wages() return; } - for (auto peep : EntityList(SPRITE_LIST_PEEP)) + for (auto peep : EntityList(EntityListId::Peep)) { finance_payment(gStaffWageTable[peep->StaffType] / 4, ExpenditureType::Wages); } @@ -246,7 +246,7 @@ void finance_update_daily_profit() if (!(gParkFlags & PARK_FLAGS_NO_MONEY)) { // Staff costs - for (auto peep : EntityList(SPRITE_LIST_PEEP)) + for (auto peep : EntityList(EntityListId::Peep)) { current_profit -= gStaffWageTable[peep->StaffType]; } diff --git a/src/openrct2/peep/Guest.cpp b/src/openrct2/peep/Guest.cpp index b20dbdf254..d76625bbdd 100644 --- a/src/openrct2/peep/Guest.cpp +++ b/src/openrct2/peep/Guest.cpp @@ -3014,7 +3014,7 @@ static PeepThoughtType peep_assess_surroundings(int16_t centre_x, int16_t centre } } - for (auto litter : EntityList(SPRITE_LIST_LITTER)) + for (auto litter : EntityList(EntityListId::Litter)) { int16_t dist_x = abs(litter->x - centre_x); int16_t dist_y = abs(litter->y - centre_y); @@ -6255,7 +6255,7 @@ static void peep_update_walking_break_scenery(Peep* peep) return; } - for (auto inner_peep : EntityList(SPRITE_LIST_PEEP)) + for (auto inner_peep : EntityList(EntityListId::Peep)) { if (inner_peep->StaffType != STAFF_TYPE_SECURITY) continue; diff --git a/src/openrct2/peep/Peep.cpp b/src/openrct2/peep/Peep.cpp index b4ff9f3ad6..cc220d2ddb 100644 --- a/src/openrct2/peep/Peep.cpp +++ b/src/openrct2/peep/Peep.cpp @@ -387,7 +387,7 @@ Peep* try_get_guest(uint16_t spriteIndex) int32_t peep_get_staff_count() { - auto list = EntityList(SPRITE_LIST_PEEP); + auto list = EntityList(EntityListId::Peep); auto count = std::distance(list.begin(), list.end()); return count; @@ -404,7 +404,7 @@ void peep_update_all() int32_t i = 0; // Warning this loop can delete peeps - for (auto peep : EntityList(SPRITE_LIST_PEEP)) + for (auto peep : EntityList(EntityListId::Peep)) { if (static_cast(i & 0x7F) != (gCurrentTicks & 0x7F)) { @@ -1176,7 +1176,7 @@ void peep_problem_warnings_update() disgust_counter = 0, toilet_counter = 0, vandalism_counter = 0; uint8_t* warning_throttle = gPeepWarningThrottle; - for (auto peep : EntityList(SPRITE_LIST_PEEP)) + for (auto peep : EntityList(EntityListId::Peep)) { if (peep->OutsideOfPark || peep->Thoughts[0].freshness > 5) continue; @@ -1354,7 +1354,7 @@ void peep_update_crowd_noise() // Count the number of peeps visible auto visiblePeeps = 0; - for (auto peep : EntityList(SPRITE_LIST_PEEP)) + for (auto peep : EntityList(EntityListId::Peep)) { if (peep->sprite_left == LOCATION_NULL) continue; @@ -1417,7 +1417,7 @@ void peep_update_crowd_noise() */ void peep_applause() { - for (auto peep : EntityList(SPRITE_LIST_PEEP)) + for (auto peep : EntityList(EntityListId::Peep)) { if (peep->OutsideOfPark) continue; @@ -1445,7 +1445,7 @@ void peep_applause() */ void peep_update_days_in_queue() { - for (auto peep : EntityList(SPRITE_LIST_PEEP)) + for (auto peep : EntityList(EntityListId::Peep)) { if (!peep->OutsideOfPark && peep->State == PEEP_STATE_QUEUING) { @@ -1587,7 +1587,7 @@ void Peep::InsertNewThought(PeepThoughtType thoughtType, uint8_t thoughtArgument */ Peep* Peep::Generate(const CoordsXYZ& coords) { - if (gSpriteListCount[SPRITE_LIST_FREE] < 400) + if (gSpriteListCount[static_cast(EntityListId::Free)] < 400) return nullptr; Peep* peep = &create_sprite(SPRITE_IDENTIFIER_PEEP)->peep; diff --git a/src/openrct2/peep/Staff.cpp b/src/openrct2/peep/Staff.cpp index d71181bf8a..450b5d1f6f 100644 --- a/src/openrct2/peep/Staff.cpp +++ b/src/openrct2/peep/Staff.cpp @@ -156,7 +156,7 @@ void staff_update_greyed_patrol_areas() gStaffPatrolAreas[staffPatrolOffset + i] = 0; } - for (auto peep : EntityList(SPRITE_LIST_PEEP)) + for (auto peep : EntityList(EntityListId::Peep)) { if (peep->StaffType == staff_type) { @@ -361,7 +361,7 @@ static uint8_t staff_get_valid_patrol_directions(Staff* staff, const CoordsXY& l */ void staff_reset_stats() { - for (auto peep : EntityList(SPRITE_LIST_PEEP)) + for (auto peep : EntityList(EntityListId::Peep)) { peep->TimeInPark = gDateMonthsElapsed; peep->StaffLawnsMown = 0; @@ -440,7 +440,7 @@ static uint8_t staff_handyman_direction_to_nearest_litter(Peep* peep) { uint16_t nearestLitterDist = 0xFFFF; Litter* nearestLitter = nullptr; - for (auto litter : EntityList(SPRITE_LIST_LITTER)) + for (auto litter : EntityList(EntityListId::Litter)) { uint16_t distance = abs(litter->x - peep->x) + abs(litter->y - peep->y) + abs(litter->z - peep->z) * 4; @@ -1011,7 +1011,7 @@ bool Staff::DoMiscPathFinding() */ static void staff_entertainer_update_nearby_peeps(Peep* peep) { - for (auto guest : EntityList(SPRITE_LIST_PEEP)) + for (auto guest : EntityList(EntityListId::Peep)) { if (guest->x == LOCATION_NULL) continue; diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index eb7e261063..f2ac683685 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -1124,7 +1124,7 @@ private: if (srcVehicle->x != LOCATION_NULL) { // If vehicle is the first car on a train add to train list - auto llt = srcVehicle->type == VEHICLE_TYPE_HEAD ? SPRITE_LIST_TRAIN_HEAD : SPRITE_LIST_VEHICLE; + auto llt = srcVehicle->type == VEHICLE_TYPE_HEAD ? EntityListId::TrainHead : EntityListId::Vehicle; Vehicle* vehicle = reinterpret_cast(create_sprite(SPRITE_IDENTIFIER_VEHICLE, llt)); spriteIndexMap[i] = vehicle->sprite_index; @@ -1355,7 +1355,7 @@ private: } { - for (auto peep : EntityList(SPRITE_LIST_PEEP)) + for (auto peep : EntityList(EntityListId::Peep)) { FixPeepNextInQueue(peep, spriteIndexMap); } @@ -1377,7 +1377,7 @@ private: std::copy(std::begin(_s4.staff_modes), std::end(_s4.staff_modes), gStaffModes); - for (auto peep : EntityList(SPRITE_LIST_PEEP)) + for (auto peep : EntityList(EntityListId::Peep)) { ImportStaffPatrolArea(peep); } @@ -2999,7 +2999,7 @@ private: if (_s4.scenario_slot_index == SC_URBAN_PARK && _isScenario) { // First, make the queuing peep exit - for (auto peep : EntityList(SPRITE_LIST_PEEP)) + for (auto peep : EntityList(EntityListId::Peep)) { if (peep->State == PEEP_STATE_QUEUING_FRONT && peep->CurrentRide == 0) { diff --git a/src/openrct2/rct2/S6Exporter.cpp b/src/openrct2/rct2/S6Exporter.cpp index 7f842cbc12..a561e2f591 100644 --- a/src/openrct2/rct2/S6Exporter.cpp +++ b/src/openrct2/rct2/S6Exporter.cpp @@ -946,7 +946,7 @@ void S6Exporter::ExportSprites() ExportSprite(&_s6.sprites[i], reinterpret_cast(GetEntity(i))); } - for (int32_t i = 0; i < SPRITE_LIST_COUNT; i++) + for (int32_t i = 0; i < static_cast(EntityListId::Count); i++) { _s6.sprite_lists_head[i] = gSpriteListHead[i]; _s6.sprite_lists_count[i] = gSpriteListCount[i]; @@ -987,7 +987,7 @@ void S6Exporter::ExportSpriteCommonProperties(RCT12SpriteBase* dst, const Sprite dst->next_in_quadrant = src->next_in_quadrant; dst->next = src->next; dst->previous = src->previous; - dst->linked_list_type_offset = src->linked_list_index * 2; + dst->linked_list_type_offset = static_cast(src->linked_list_index) * 2; dst->sprite_height_negative = src->sprite_height_negative; dst->sprite_index = src->sprite_index; dst->flags = src->flags; diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index 603d6d9689..8581e99f44 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -1287,13 +1287,13 @@ public: ImportSprite(reinterpret_cast(dst), src); } - for (int32_t i = 0; i < SPRITE_LIST_COUNT; i++) + for (int32_t i = 0; i < static_cast(EntityListId::Count); i++) { gSpriteListHead[i] = _s6.sprite_lists_head[i]; gSpriteListCount[i] = _s6.sprite_lists_count[i]; } // This list contains the number of free slots. Increase it according to our own sprite limit. - gSpriteListCount[SPRITE_LIST_FREE] += (MAX_SPRITES - RCT2_MAX_SPRITES); + gSpriteListCount[static_cast(EntityListId::Free)] += (MAX_SPRITES - RCT2_MAX_SPRITES); } void ImportSprite(rct_sprite* dst, const RCT2Sprite* src) @@ -1627,7 +1627,7 @@ public: dst->next_in_quadrant = src->next_in_quadrant; dst->next = src->next; dst->previous = src->previous; - dst->linked_list_index = src->linked_list_type_offset >> 1; + dst->linked_list_index = static_cast(src->linked_list_type_offset >> 1); dst->sprite_height_negative = src->sprite_height_negative; dst->sprite_index = src->sprite_index; dst->flags = src->flags; diff --git a/src/openrct2/ride/CableLift.cpp b/src/openrct2/ride/CableLift.cpp index e636a32ac9..2b2d3b852c 100644 --- a/src/openrct2/ride/CableLift.cpp +++ b/src/openrct2/ride/CableLift.cpp @@ -23,8 +23,7 @@ Vehicle* cable_lift_segment_create( Ride& ride, int32_t x, int32_t y, int32_t z, int32_t direction, uint16_t var_44, int32_t remaining_distance, bool head) { - Vehicle* current = &( - create_sprite(SPRITE_IDENTIFIER_VEHICLE, head ? SPRITE_LIST_TRAIN_HEAD : SPRITE_LIST_VEHICLE)->vehicle); + Vehicle* current = &(create_sprite(SPRITE_IDENTIFIER_VEHICLE, head ? EntityListId::TrainHead : EntityListId::Vehicle)->vehicle); current->sprite_identifier = SPRITE_IDENTIFIER_VEHICLE; current->ride = ride.id; current->ride_subtype = RIDE_ENTRY_INDEX_NULL; diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index db9295b21c..d949919eef 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -355,7 +355,7 @@ void ride_update_favourited_stat() for (auto& ride : GetRideManager()) ride.guests_favourite = 0; - for (auto peep : EntityList(SPRITE_LIST_PEEP)) + for (auto peep : EntityList(EntityListId::Peep)) { if (peep->FavouriteRide != RIDE_ID_NULL) { @@ -1099,7 +1099,7 @@ void ride_remove_peeps(Ride* ride) } // Place all the peeps at exit - for (auto peep : EntityList(SPRITE_LIST_PEEP)) + for (auto peep : EntityList(EntityListId::Peep)) { if (peep->State == PEEP_STATE_QUEUING_FRONT || peep->State == PEEP_STATE_ENTERING_RIDE || peep->State == PEEP_STATE_LEAVING_RIDE || peep->State == PEEP_STATE_ON_RIDE) @@ -2691,7 +2691,7 @@ Peep* find_closest_mechanic(int32_t x, int32_t y, int32_t forInspection) Peep* closestMechanic = nullptr; uint32_t closestDistance = std::numeric_limits::max(); - for (auto peep : EntityList(SPRITE_LIST_PEEP)) + for (auto peep : EntityList(EntityListId::Peep)) { if (peep->StaffType != STAFF_TYPE_MECHANIC) continue; @@ -4299,8 +4299,8 @@ static void ride_set_start_finish_points(ride_id_t rideIndex, CoordsXYE* startEl */ static int32_t count_free_misc_sprite_slots() { - int32_t miscSpriteCount = gSpriteListCount[SPRITE_LIST_MISC]; - int32_t remainingSpriteCount = gSpriteListCount[SPRITE_LIST_FREE]; + int32_t miscSpriteCount = gSpriteListCount[static_cast(EntityListId::Misc)]; + int32_t remainingSpriteCount = gSpriteListCount[static_cast(EntityListId::Free)]; return std::max(0, miscSpriteCount + remainingSpriteCount - 300); } @@ -4342,7 +4342,7 @@ static Vehicle* vehicle_create_car( return nullptr; auto vehicleEntry = &rideEntry->vehicles[vehicleEntryIndex]; - auto vehicle = &create_sprite(SPRITE_IDENTIFIER_VEHICLE, carIndex == 0 ? SPRITE_LIST_TRAIN_HEAD : SPRITE_LIST_VEHICLE) + auto vehicle = &create_sprite(SPRITE_IDENTIFIER_VEHICLE, carIndex == 0 ? EntityListId::TrainHead : EntityListId::Vehicle) ->vehicle; if (vehicle == nullptr) return nullptr; @@ -5489,7 +5489,7 @@ int32_t ride_get_refund_price(const Ride* ride) */ void Ride::StopGuestsQueuing() { - for (auto peep : EntityList(SPRITE_LIST_PEEP)) + for (auto peep : EntityList(EntityListId::Peep)) { if (peep->State != PEEP_STATE_QUEUING) continue; diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index 8d4f8b6d6a..a8dcd195a6 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -1284,7 +1284,7 @@ void vehicle_sounds_update() vehicle_sounds_update_window_setup(); - for (auto vehicle : EntityList(SPRITE_LIST_TRAIN_HEAD)) + for (auto vehicle : EntityList(EntityListId::TrainHead)) { vehicle->UpdateSoundParams(vehicleSoundParamsList); } @@ -1364,7 +1364,7 @@ void vehicle_update_all() if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) && gS6Info.editor_step != EDITOR_STEP_ROLLERCOASTER_DESIGNER) return; - for (auto vehicle : EntityList(SPRITE_LIST_TRAIN_HEAD)) + for (auto vehicle : EntityList(EntityListId::TrainHead)) { vehicle->Update(); } diff --git a/src/openrct2/scenario/Scenario.h b/src/openrct2/scenario/Scenario.h index d166cdb54b..ea9bc3663e 100644 --- a/src/openrct2/scenario/Scenario.h +++ b/src/openrct2/scenario/Scenario.h @@ -112,8 +112,8 @@ struct rct_s6_data // SC6[6] uint32_t next_free_tile_element_pointer_index; RCT2Sprite sprites[RCT2_MAX_SPRITES]; - uint16_t sprite_lists_head[SPRITE_LIST_COUNT]; - uint16_t sprite_lists_count[SPRITE_LIST_COUNT]; + uint16_t sprite_lists_head[static_cast(EntityListId::Count)]; + uint16_t sprite_lists_count[static_cast(EntityListId::Count)]; rct_string_id park_name; uint8_t pad_013573D6[2]; uint32_t park_name_args; diff --git a/src/openrct2/scripting/ScMap.hpp b/src/openrct2/scripting/ScMap.hpp index c6d5d28145..6c57df5e55 100644 --- a/src/openrct2/scripting/ScMap.hpp +++ b/src/openrct2/scripting/ScMap.hpp @@ -101,29 +101,29 @@ namespace OpenRCT2::Scripting std::vector getAllEntities(const std::string& type) const { - SPRITE_LIST targetList{}; + EntityListId targetList{}; uint8_t targetType{}; if (type == "balloon") { - targetList = SPRITE_LIST_MISC; + targetList = EntityListId::Misc; targetType = SPRITE_MISC_BALLOON; } if (type == "car") { - targetList = SPRITE_LIST_TRAIN_HEAD; + targetList = EntityListId::TrainHead; } else if (type == "litter") { - targetList = SPRITE_LIST_LITTER; + targetList = EntityListId::Litter; } else if (type == "duck") { - targetList = SPRITE_LIST_MISC; + targetList = EntityListId::Misc; targetType = SPRITE_MISC_DUCK; } else if (type == "peep") { - targetList = SPRITE_LIST_PEEP; + targetList = EntityListId::Peep; } else { @@ -134,16 +134,16 @@ namespace OpenRCT2::Scripting for (auto sprite : EntityList(targetList)) { // Only the misc list checks the type property - if (targetList != SPRITE_LIST_MISC || sprite->type == targetType) + if (targetList != EntityListId::Misc || sprite->type == targetType) { - if (targetList == SPRITE_LIST_PEEP) + if (targetList == EntityListId::Peep) { if (sprite->As()) result.push_back(GetObjectAsDukValue(_context, std::make_shared(sprite->sprite_index))); else result.push_back(GetObjectAsDukValue(_context, std::make_shared(sprite->sprite_index))); } - else if (targetList == SPRITE_LIST_TRAIN_HEAD) + else if (targetList == EntityListId::TrainHead) { for (auto carId = sprite->sprite_index; carId != SPRITE_INDEX_NULL;) { diff --git a/src/openrct2/world/Duck.cpp b/src/openrct2/world/Duck.cpp index 1d4abcbf36..197247f7ee 100644 --- a/src/openrct2/world/Duck.cpp +++ b/src/openrct2/world/Duck.cpp @@ -363,7 +363,7 @@ void duck_press(Duck* duck) void duck_remove_all() { - for (auto duck : EntityList(SPRITE_LIST_MISC)) + for (auto duck : EntityList(EntityListId::Misc)) { duck->Remove(); } diff --git a/src/openrct2/world/Park.cpp b/src/openrct2/world/Park.cpp index 3fb6a1ac6b..cd953f06e9 100644 --- a/src/openrct2/world/Park.cpp +++ b/src/openrct2/world/Park.cpp @@ -385,7 +385,7 @@ int32_t Park::CalculateParkRating() const // Find the number of happy peeps and the number of peeps who can't find the park exit uint32_t happyGuestCount = 0; uint32_t lostGuestCount = 0; - for (auto peep : EntityList(SPRITE_LIST_PEEP)) + for (auto peep : EntityList(EntityListId::Peep)) { if (!peep->OutsideOfPark) { @@ -468,7 +468,7 @@ int32_t Park::CalculateParkRating() const // Litter { int32_t litterCount = 0; - for (auto litter : EntityList(SPRITE_LIST_LITTER)) + for (auto litter : EntityList(EntityListId::Litter)) { // Ignore recently dropped litter if (litter->creationTick - gScenarioTicks >= 7680) diff --git a/src/openrct2/world/Sprite.cpp b/src/openrct2/world/Sprite.cpp index f68a747de4..00d0af04ad 100644 --- a/src/openrct2/world/Sprite.cpp +++ b/src/openrct2/world/Sprite.cpp @@ -25,8 +25,8 @@ #include #include -uint16_t gSpriteListHead[SPRITE_LIST_COUNT]; -uint16_t gSpriteListCount[SPRITE_LIST_COUNT]; +uint16_t gSpriteListHead[static_cast(EntityListId::Count)]; +uint16_t gSpriteListCount[static_cast(EntityListId::Count)]; static rct_sprite _spriteList[MAX_SPRITES]; static bool _spriteFlashingList[MAX_SPRITES]; @@ -50,7 +50,7 @@ static CoordsXYZ _spritelocations1[MAX_SPRITES]; static CoordsXYZ _spritelocations2[MAX_SPRITES]; static size_t GetSpatialIndexOffset(int32_t x, int32_t y); -static void move_sprite_to_list(SpriteBase* sprite, SPRITE_LIST newListIndex); +static void move_sprite_to_list(SpriteBase* sprite, EntityListId newListIndex); // Required for GetEntity to return a default template<> bool SpriteBase::Is() const @@ -178,7 +178,7 @@ void reset_sprite_list() gSavedAge = 0; std::memset(static_cast(_spriteList), 0, sizeof(_spriteList)); - for (int32_t i = 0; i < SPRITE_LIST_COUNT; i++) + for (int32_t i = 0; i < static_cast(EntityListId::Count); i++) { gSpriteListHead[i] = SPRITE_INDEX_NULL; gSpriteListCount[i] = 0; @@ -193,7 +193,7 @@ void reset_sprite_list() spr->sprite_identifier = SPRITE_IDENTIFIER_NULL; spr->sprite_index = i; spr->next = SPRITE_INDEX_NULL; - spr->linked_list_index = SPRITE_LIST_FREE; + spr->linked_list_index = EntityListId::Free; if (previous_spr != nullptr) { @@ -203,13 +203,13 @@ void reset_sprite_list() else { spr->previous = SPRITE_INDEX_NULL; - gSpriteListHead[SPRITE_LIST_FREE] = i; + gSpriteListHead[static_cast(EntityListId::Free)] = i; } _spriteFlashingList[i] = false; previous_spr = spr; } - gSpriteListCount[SPRITE_LIST_FREE] = MAX_SPRITES; + gSpriteListCount[static_cast(EntityListId::Free)] = MAX_SPRITES; reset_sprite_spatial_index(); } @@ -335,7 +335,7 @@ rct_sprite_checksum sprite_checksum() static void sprite_reset(SpriteBase* sprite) { // Need to retain how the sprite is linked in lists - uint8_t llto = sprite->linked_list_index; + auto llto = sprite->linked_list_index; uint16_t next = sprite->next; uint16_t next_in_quadrant = sprite->next_in_quadrant; uint16_t prev = sprite->previous; @@ -358,10 +358,10 @@ static void sprite_reset(SpriteBase* sprite) */ void sprite_clear_all_unused() { - for (auto sprite : EntityList(SPRITE_LIST_FREE)) + for (auto sprite : EntityList(EntityListId::Free)) { sprite_reset(sprite); - sprite->linked_list_index = SPRITE_LIST_FREE; + sprite->linked_list_index = EntityListId::Free; // sprite->next_in_quadrant will only end up as zero owing to corruption // most likely due to previous builds not preserving it when resetting sprites @@ -378,27 +378,27 @@ static void SpriteSpatialInsert(SpriteBase* sprite, const CoordsXY& newLoc); static constexpr uint16_t MAX_MISC_SPRITES = 300; -rct_sprite* create_sprite(SPRITE_IDENTIFIER spriteIdentifier, SPRITE_LIST linkedListIndex) +rct_sprite* create_sprite(SPRITE_IDENTIFIER spriteIdentifier, EntityListId linkedListIndex) { - if (gSpriteListCount[SPRITE_LIST_FREE] == 0) + if (gSpriteListCount[static_cast(EntityListId::Free)] == 0) { // No free sprites. return nullptr; } - if (linkedListIndex == SPRITE_LIST_MISC) + if (linkedListIndex == EntityListId::Misc) { // Misc sprites are commonly used for effects, if there are less than MAX_MISC_SPRITES // free it will fail to keep slots for more relevant sprites. // Also there can't be more than MAX_MISC_SPRITES sprites in this list. - uint16_t miscSlotsRemaining = MAX_MISC_SPRITES - gSpriteListCount[SPRITE_LIST_MISC]; - if (miscSlotsRemaining >= gSpriteListCount[SPRITE_LIST_FREE]) + uint16_t miscSlotsRemaining = MAX_MISC_SPRITES - gSpriteListCount[static_cast(EntityListId::Misc)]; + if (miscSlotsRemaining >= gSpriteListCount[static_cast(EntityListId::Free)]) { return nullptr; } } - auto* sprite = GetEntity(gSpriteListHead[SPRITE_LIST_FREE]); + auto* sprite = GetEntity(gSpriteListHead[static_cast(EntityListId::Free)]); move_sprite_to_list(sprite, linkedListIndex); @@ -422,20 +422,20 @@ rct_sprite* create_sprite(SPRITE_IDENTIFIER spriteIdentifier, SPRITE_LIST linked rct_sprite* create_sprite(SPRITE_IDENTIFIER spriteIdentifier) { - SPRITE_LIST linkedListIndex = SPRITE_LIST_FREE; + EntityListId linkedListIndex = EntityListId::Free; switch (spriteIdentifier) { case SPRITE_IDENTIFIER_VEHICLE: - linkedListIndex = SPRITE_LIST_VEHICLE; + linkedListIndex = EntityListId::Vehicle; break; case SPRITE_IDENTIFIER_PEEP: - linkedListIndex = SPRITE_LIST_PEEP; + linkedListIndex = EntityListId::Peep; break; case SPRITE_IDENTIFIER_MISC: - linkedListIndex = SPRITE_LIST_MISC; + linkedListIndex = EntityListId::Misc; break; case SPRITE_IDENTIFIER_LITTER: - linkedListIndex = SPRITE_LIST_LITTER; + linkedListIndex = EntityListId::Litter; break; default: Guard::Assert(false, "Invalid sprite identifier: 0x%02X", spriteIdentifier); @@ -449,9 +449,9 @@ rct_sprite* create_sprite(SPRITE_IDENTIFIER spriteIdentifier) * This function moves a sprite to the specified sprite linked list. * The game uses this list to categorise sprites by type. */ -static void move_sprite_to_list(SpriteBase* sprite, SPRITE_LIST newListIndex) +static void move_sprite_to_list(SpriteBase* sprite, EntityListId newListIndex) { - int32_t oldListIndex = sprite->linked_list_index; + auto oldListIndex = sprite->linked_list_index; // No need to move if the sprite is already in the desired list if (oldListIndex == newListIndex) @@ -463,7 +463,7 @@ static void move_sprite_to_list(SpriteBase* sprite, SPRITE_LIST newListIndex) // sprite following this one becomes the new head of the list. if (sprite->previous == SPRITE_INDEX_NULL) { - gSpriteListHead[oldListIndex] = sprite->next; + gSpriteListHead[static_cast(oldListIndex)] = sprite->next; } else { @@ -480,8 +480,10 @@ static void move_sprite_to_list(SpriteBase* sprite, SPRITE_LIST newListIndex) sprite->previous = SPRITE_INDEX_NULL; // We become the new head of the target list, so there's no previous sprite sprite->linked_list_index = newListIndex; - sprite->next = gSpriteListHead[newListIndex]; // This sprite's next sprite is the old head, since we're the new head - gSpriteListHead[newListIndex] = sprite->sprite_index; // Store this sprite's index as head of its new list + sprite->next = gSpriteListHead[static_cast( + newListIndex)]; // This sprite's next sprite is the old head, since we're the new head + gSpriteListHead[static_cast(newListIndex)] = sprite->sprite_index; // Store this sprite's index as head of its new + // list if (sprite->next != SPRITE_INDEX_NULL) { @@ -491,8 +493,8 @@ static void move_sprite_to_list(SpriteBase* sprite, SPRITE_LIST newListIndex) // These globals are probably counters for each sprite list? // Decrement old list counter, increment new list counter. - gSpriteListCount[oldListIndex]--; - gSpriteListCount[newListIndex]++; + gSpriteListCount[static_cast(oldListIndex)]--; + gSpriteListCount[static_cast(newListIndex)]++; } /** @@ -628,7 +630,7 @@ static void sprite_misc_update(rct_sprite* sprite) */ void sprite_misc_update_all() { - for (auto entity : EntityList(SPRITE_LIST_MISC)) + for (auto entity : EntityList(EntityListId::Misc)) { // TODO: Use more specific Sprite class sprite_misc_update(reinterpret_cast(entity)); @@ -744,7 +746,7 @@ void sprite_remove(SpriteBase* sprite) peep->SetName({}); } - move_sprite_to_list(sprite, SPRITE_LIST_FREE); + move_sprite_to_list(sprite, EntityListId::Free); sprite->sprite_identifier = SPRITE_IDENTIFIER_NULL; _spriteFlashingList[sprite->sprite_index] = false; @@ -798,11 +800,11 @@ void litter_create(const CoordsXYZD& litterPos, int32_t type) if (!litter_can_be_at(offsetLitterPos)) return; - if (gSpriteListCount[SPRITE_LIST_LITTER] >= 500) + if (gSpriteListCount[static_cast(EntityListId::Litter)] >= 500) { Litter* newestLitter = nullptr; uint32_t newestLitterCreationTick = 0; - for (auto litter : EntityList(SPRITE_LIST_LITTER)) + for (auto litter : EntityList(EntityListId::Litter)) { if (newestLitterCreationTick <= litter->creationTick) { @@ -1024,43 +1026,7 @@ static SpriteBase* find_sprite_list_cycle(uint16_t sprite_idx) return cycle_start; } -static SpriteBase* find_sprite_quadrant_cycle(uint16_t sprite_idx) -{ - if (sprite_idx == SPRITE_INDEX_NULL) - { - return nullptr; - } - const SpriteBase* fast = GetEntity(sprite_idx); - const SpriteBase* slow = fast; - bool increment_slow = false; - SpriteBase* cycle_start = nullptr; - while (fast->sprite_index != SPRITE_INDEX_NULL) - { - // increment fast every time, unless reached the end - if (fast->next_in_quadrant == SPRITE_INDEX_NULL) - { - break; - } - else - { - fast = GetEntity(fast->next_in_quadrant); - } - // increment slow only every second iteration - if (increment_slow) - { - slow = GetEntity(slow->next_in_quadrant); - } - increment_slow = !increment_slow; - if (fast == slow) - { - cycle_start = GetEntity(slow->sprite_index); - break; - } - } - return cycle_start; -} - -static bool index_is_in_list(uint16_t index, enum SPRITE_LIST sl) +static bool index_is_in_list(uint16_t index, EntityListId sl) { for (auto entity : EntityList(sl)) { @@ -1074,7 +1040,7 @@ static bool index_is_in_list(uint16_t index, enum SPRITE_LIST sl) int32_t check_for_sprite_list_cycles(bool fix) { - for (int32_t i = 0; i < SPRITE_LIST_COUNT; i++) + for (int32_t i = 0; i < static_cast(EntityListId::Count); i++) { auto* cycle_start = find_sprite_list_cycle(gSpriteListHead[i]); if (cycle_start != nullptr) @@ -1093,7 +1059,7 @@ int32_t check_for_sprite_list_cycles(bool fix) // Now re-add remainder of the cycle back to list, safely. // Add each sprite to the list until we encounter one that is already part of the list. - while (!index_is_in_list(cycle_next, static_cast(i))) + while (!index_is_in_list(cycle_next, static_cast(i))) { auto* spr = GetEntity(cycle_next); @@ -1111,7 +1077,7 @@ int32_t check_for_sprite_list_cycles(bool fix) } /** - * Finds and fixes null sprites that are not reachable via SPRITE_LIST_FREE list. + * Finds and fixes null sprites that are not reachable via EntityListId::Free list. * * @return count of disjoint sprites found */ @@ -1121,7 +1087,7 @@ int32_t fix_disjoint_sprites() bool reachable[MAX_SPRITES] = { false }; SpriteBase* null_list_tail = nullptr; - for (uint16_t sprite_idx = gSpriteListHead[SPRITE_LIST_FREE]; sprite_idx != SPRITE_INDEX_NULL;) + for (uint16_t sprite_idx = gSpriteListHead[static_cast(EntityListId::Free)]; sprite_idx != SPRITE_INDEX_NULL;) { reachable[sprite_idx] = true; // cache the tail, so we don't have to walk the list twice diff --git a/src/openrct2/world/Sprite.h b/src/openrct2/world/Sprite.h index 8a05dd0a17..89aed45d91 100644 --- a/src/openrct2/world/Sprite.h +++ b/src/openrct2/world/Sprite.h @@ -28,15 +28,15 @@ enum SPRITE_IDENTIFIER SPRITE_IDENTIFIER_NULL = 255 }; -enum SPRITE_LIST +enum class EntityListId : uint8_t { - SPRITE_LIST_FREE, - SPRITE_LIST_TRAIN_HEAD, - SPRITE_LIST_PEEP, - SPRITE_LIST_MISC, - SPRITE_LIST_LITTER, - SPRITE_LIST_VEHICLE, - SPRITE_LIST_COUNT, + Free, + TrainHead, + Peep, + Misc, + Litter, + Vehicle, + Count, }; struct Litter : SpriteBase @@ -203,8 +203,8 @@ template T* GetEntity(size_t sprite_idx) SpriteBase* GetEntity(size_t sprite_idx); -extern uint16_t gSpriteListHead[SPRITE_LIST_COUNT]; -extern uint16_t gSpriteListCount[SPRITE_LIST_COUNT]; +extern uint16_t gSpriteListHead[static_cast(EntityListId::Count)]; +extern uint16_t gSpriteListCount[static_cast(EntityListId::Count)]; constexpr const uint32_t SPATIAL_INDEX_SIZE = (MAXIMUM_MAP_SIZE_TECHNICAL * MAXIMUM_MAP_SIZE_TECHNICAL) + 1; constexpr const uint32_t SPATIAL_INDEX_LOCATION_NULL = SPATIAL_INDEX_SIZE - 1; extern uint16_t gSpriteSpatialIndex[SPATIAL_INDEX_SIZE]; @@ -212,7 +212,7 @@ extern uint16_t gSpriteSpatialIndex[SPATIAL_INDEX_SIZE]; extern const rct_string_id litterNames[12]; rct_sprite* create_sprite(SPRITE_IDENTIFIER spriteIdentifier); -rct_sprite* create_sprite(SPRITE_IDENTIFIER spriteIdentifier, SPRITE_LIST linkedListIndex); +rct_sprite* create_sprite(SPRITE_IDENTIFIER spriteIdentifier, EntityListId linkedListIndex); void reset_sprite_list(); void reset_sprite_spatial_index(); void sprite_clear_all_unused(); @@ -346,8 +346,8 @@ private: using EntityListIterator = EntityIterator; public: - EntityList(SPRITE_LIST type) - : FirstEntity(gSpriteListHead[type]) + EntityList(EntityListId type) + : FirstEntity(gSpriteListHead[static_cast(type)]) { } diff --git a/src/openrct2/world/SpriteBase.h b/src/openrct2/world/SpriteBase.h index be763792a4..6fd76658ff 100644 --- a/src/openrct2/world/SpriteBase.h +++ b/src/openrct2/world/SpriteBase.h @@ -3,6 +3,7 @@ #include "../common.h" struct CoordsXYZ; +enum class EntityListId : uint8_t; struct SpriteBase { @@ -12,7 +13,7 @@ struct SpriteBase uint16_t next; uint16_t previous; // Valid values are SPRITE_LINKEDLIST_OFFSET_... - uint8_t linked_list_index; + EntityListId linked_list_index; // Height from centre of sprite to bottom uint8_t sprite_height_negative; uint16_t sprite_index;