Merge pull request #11980 from duncanspumpkin/CreateSprite8

SpriteList enum class
This commit is contained in:
Michael Steenbeek authored and GitHub committed 2020-07-06 15:21:16 +02:00
commit f7b42a0254
30 files changed
+148 -212

No files matched your search

@@ -636,7 +636,7 @@ static Peep* viewport_interaction_get_closest_peep(ScreenCoordsXY screenCoords,
Peep* closestPeep = nullptr;
auto closestDistance = std::numeric_limits<int32_t>::max();
for (auto peep : EntityList<Peep>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Peep>(EntityListId::Peep))
{
if (peep->sprite_left == LOCATION_NULL)
continue;
@@ -310,7 +310,7 @@ 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)))
|| (GetEntityListCount(EntityListId::Free) == MAX_SPRITES && !(gParkFlags & PARK_FLAGS_SPRITES_INITIALISED)))
{
previous_button_mouseup_events[gS6Info.editor_step]();
}
@@ -370,7 +370,7 @@ 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 (GetEntityListCount(EntityListId::Free) != MAX_SPRITES || gParkFlags & PARK_FLAGS_SPRITES_INITIALISED)
{
hide_previous_step_button();
}
@@ -395,7 +395,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 (GetEntityListCount(EntityListId::Free) != MAX_SPRITES)
{
drawNextButton = true;
}
+4 -4
View File
@@ -248,7 +248,7 @@ void window_guest_list_refresh_list()
}
GuestList.clear();
for (auto peep : EntityList<Guest>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Guest>(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<Guest>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Guest>(EntityListId::Peep))
{
if (!peep->OutsideOfPark)
{
@@ -957,7 +957,7 @@ static void window_guest_list_find_groups()
}
}
// For each guest / group
for (auto peep : EntityList<Guest>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Guest>(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<Guest>(SPRITE_LIST_PEEP))
for (auto peep2 : EntityList<Guest>(EntityListId::Peep))
{
if (peep2->OutsideOfPark || !(peep2->flags & SPRITE_FLAGS_PEEP_VISIBLE))
continue;
+2 -2
View File
@@ -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<Peep>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Peep>(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<Vehicle>(SPRITE_LIST_TRAIN_HEAD))
for (auto train : EntityList<Vehicle>(EntityListId::TrainHead))
{
Vehicle* vehicle = nullptr;
for (auto vehicle_index = train->sprite_index; vehicle_index != SPRITE_INDEX_NULL;
+1 -1
View File
@@ -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<Staff>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Staff>(EntityListId::Peep))
{
if (peep->StaffType == STAFF_TYPE_MECHANIC)
{
+3 -3
View File
@@ -189,7 +189,7 @@ void WindowStaffListRefresh()
}
StaffList.clear();
for (auto peep : EntityList<Staff>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Staff>(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<Staff>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Staff>(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<int32_t>::max();
for (auto peep : EntityList<Staff>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Staff>(EntityListId::Peep))
{
if (peep->StaffType != selectedPeepType)
continue;
+2 -2
View File
@@ -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<Guest>(SPRITE_LIST_PEEP))
for (auto guest : EntityList<Guest>(EntityListId::Peep))
{
if (!guest->OutsideOfPark)
{
@@ -449,7 +449,7 @@ void game_fix_save_vars()
std::vector<Peep*> peepsToRemove;
// Fix possibly invalid field values
for (auto peep : EntityList<Guest>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Guest>(EntityListId::Peep))
{
if (peep->CurrentRideStation >= MAX_STATIONS)
{
+1 -1
View File
@@ -153,7 +153,7 @@ private:
}
}
for (auto peep : EntityList<Guest>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Guest>(EntityListId::Peep))
{
uint8_t ride_id_bit = _rideIndex % 8;
uint8_t ride_id_offset = _rideIndex / 8;
+6 -6
View File
@@ -427,7 +427,7 @@ private:
void RemoveLitter() const
{
for (auto litter : EntityList<Litter>(SPRITE_LIST_LITTER))
for (auto litter : EntityList<Litter>(EntityListId::Litter))
{
sprite_remove(litter);
}
@@ -570,7 +570,7 @@ private:
void SetGuestParameter(int32_t parameter, int32_t value) const
{
for (auto peep : EntityList<Guest>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Guest>(EntityListId::Peep))
{
switch (parameter)
{
@@ -614,7 +614,7 @@ private:
void GiveObjectToGuests(int32_t object) const
{
for (auto peep : EntityList<Guest>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Guest>(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<Peep>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Peep>(EntityListId::Peep))
{
if (peep->AssignedPeepType == PEEP_TYPE_GUEST)
{
@@ -700,7 +700,7 @@ private:
void ExplodeGuests() const
{
for (auto peep : EntityList<Guest>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Guest>(EntityListId::Peep))
{
if (scenario_rand_max(6) == 0)
{
@@ -711,7 +711,7 @@ private:
void SetStaffSpeed(uint8_t value) const
{
for (auto peep : EntityList<Staff>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Staff>(EntityListId::Peep))
{
peep->Energy = value;
peep->EnergyTarget = value;
+4 -4
View File
@@ -105,7 +105,7 @@ private:
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE);
}
if (gSpriteListCount[SPRITE_LIST_FREE] < 400)
if (GetEntityListCount(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<Staff>(SPRITE_LIST_PEEP))
for (auto searchPeep : EntityList<Staff>(EntityListId::Peep))
{
if (searchPeep->StaffType != _staffType)
continue;
@@ -267,7 +267,7 @@ private:
// Count number of walking guests
{
for (auto guest : EntityList<Guest>(SPRITE_LIST_PEEP))
for (auto guest : EntityList<Guest>(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<Guest>(SPRITE_LIST_PEEP))
for (auto guest : EntityList<Guest>(EntityListId::Peep))
{
if (guest->State == PEEP_STATE_WALKING)
{
@@ -65,7 +65,7 @@ public:
}
// Update each staff member's uniform
for (auto peep : EntityList<Staff>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Staff>(EntityListId::Peep))
{
if (peep->StaffType == _staffType)
{
@@ -437,7 +437,7 @@ static int32_t cc_staff(InteractiveConsole& console, const arguments_t& argv)
{
if (argv[0] == "list")
{
for (auto peep : EntityList<Staff>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Staff>(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<uint8_t>(EntityListId::Count); ++i)
{
spriteCount += gSpriteListCount[i];
}
+9 -9
View File
@@ -84,7 +84,7 @@ static bool award_is_deserved_most_untidy(int32_t activeAwardTypes)
return false;
uint32_t negativeCount = 0;
for (auto peep : EntityList<Guest>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Guest>(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<Guest>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Guest>(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<Guest>(SPRITE_LIST_PEEP);
auto list = EntityList<Guest>(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<Guest>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Guest>(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<Peep>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Peep>(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<Guest>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Guest>(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<Guest>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Guest>(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<Guest>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Guest>(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<Guest>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Guest>(EntityListId::Peep))
{
if (peep->OutsideOfPark)
continue;
+2 -2
View File
@@ -111,7 +111,7 @@ void finance_pay_wages()
return;
}
for (auto peep : EntityList<Staff>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Staff>(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<Staff>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Staff>(EntityListId::Peep))
{
current_profit -= gStaffWageTable[peep->StaffType];
}
+2 -2
View File
@@ -3014,7 +3014,7 @@ static PeepThoughtType peep_assess_surroundings(int16_t centre_x, int16_t centre
}
}
for (auto litter : EntityList<Litter>(SPRITE_LIST_LITTER))
for (auto litter : EntityList<Litter>(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<Staff>(SPRITE_LIST_PEEP))
for (auto inner_peep : EntityList<Staff>(EntityListId::Peep))
{
if (inner_peep->StaffType != STAFF_TYPE_SECURITY)
continue;
+7 -7
View File
@@ -387,7 +387,7 @@ Peep* try_get_guest(uint16_t spriteIndex)
int32_t peep_get_staff_count()
{
auto list = EntityList<Staff>(SPRITE_LIST_PEEP);
auto list = EntityList<Staff>(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<Peep>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Peep>(EntityListId::Peep))
{
if (static_cast<uint32_t>(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<Guest>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Guest>(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<Guest>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Guest>(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<Guest>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Guest>(EntityListId::Peep))
{
if (peep->OutsideOfPark)
continue;
@@ -1445,7 +1445,7 @@ void peep_applause()
*/
void peep_update_days_in_queue()
{
for (auto peep : EntityList<Guest>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Guest>(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 (GetEntityListCount(EntityListId::Free) < 400)
return nullptr;
Peep* peep = &create_sprite(SPRITE_IDENTIFIER_PEEP)->peep;
+4 -4
View File
@@ -156,7 +156,7 @@ void staff_update_greyed_patrol_areas()
gStaffPatrolAreas[staffPatrolOffset + i] = 0;
}
for (auto peep : EntityList<Staff>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Staff>(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<Staff>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Staff>(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<Litter>(SPRITE_LIST_LITTER))
for (auto litter : EntityList<Litter>(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<Guest>(SPRITE_LIST_PEEP))
for (auto guest : EntityList<Guest>(EntityListId::Peep))
{
if (guest->x == LOCATION_NULL)
continue;
+4 -4
View File
@@ -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<Vehicle*>(create_sprite(SPRITE_IDENTIFIER_VEHICLE, llt));
spriteIndexMap[i] = vehicle->sprite_index;
@@ -1355,7 +1355,7 @@ private:
}
{
for (auto peep : EntityList<Guest>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Guest>(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<Staff>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Staff>(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<Guest>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Guest>(EntityListId::Peep))
{
if (peep->State == PEEP_STATE_QUEUING_FRONT && peep->CurrentRide == 0)
{
+2 -4
View File
@@ -151,10 +151,8 @@ void S6Exporter::Save(IStream* stream, bool isScenario)
void S6Exporter::Export()
{
int32_t spatial_cycle = check_for_spatial_index_cycles(false);
int32_t regular_cycle = check_for_sprite_list_cycles(false);
int32_t disjoint_sprites_count = fix_disjoint_sprites();
openrct2_assert(spatial_cycle == -1, "Sprite cycle exists in spatial list %d", spatial_cycle);
openrct2_assert(regular_cycle == -1, "Sprite cycle exists in regular list %d", regular_cycle);
// This one is less harmful, no need to assert for it ~janisozaur
if (disjoint_sprites_count > 0)
@@ -948,7 +946,7 @@ void S6Exporter::ExportSprites()
ExportSprite(&_s6.sprites[i], reinterpret_cast<const rct_sprite*>(GetEntity(i)));
}
for (int32_t i = 0; i < SPRITE_LIST_COUNT; i++)
for (int32_t i = 0; i < static_cast<uint8_t>(EntityListId::Count); i++)
{
_s6.sprite_lists_head[i] = gSpriteListHead[i];
_s6.sprite_lists_count[i] = gSpriteListCount[i];
@@ -989,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<uint8_t>(src->linked_list_index) * 2;
dst->sprite_height_negative = src->sprite_height_negative;
dst->sprite_index = src->sprite_index;
dst->flags = src->flags;
+3 -4
View File
@@ -465,7 +465,6 @@ public:
// We try to fix the cycles on import, hence the 'true' parameter
check_for_sprite_list_cycles(true);
check_for_spatial_index_cycles(true);
int32_t disjoint_sprites_count = fix_disjoint_sprites();
// This one is less harmful, no need to assert for it ~janisozaur
if (disjoint_sprites_count > 0)
@@ -1288,13 +1287,13 @@ public:
ImportSprite(reinterpret_cast<rct_sprite*>(dst), src);
}
for (int32_t i = 0; i < SPRITE_LIST_COUNT; i++)
for (int32_t i = 0; i < static_cast<uint8_t>(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<uint8_t>(EntityListId::Free)] += (MAX_SPRITES - RCT2_MAX_SPRITES);
}
void ImportSprite(rct_sprite* dst, const RCT2Sprite* src)
@@ -1628,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<EntityListId>(src->linked_list_type_offset >> 1);
dst->sprite_height_negative = src->sprite_height_negative;
dst->sprite_index = src->sprite_index;
dst->flags = src->flags;
+1 -1
View File
@@ -24,7 +24,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);
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;
+7 -7
View File
@@ -355,7 +355,7 @@ void ride_update_favourited_stat()
for (auto& ride : GetRideManager())
ride.guests_favourite = 0;
for (auto peep : EntityList<Guest>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Guest>(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<Peep>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Peep>(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<uint32_t>::max();
for (auto peep : EntityList<Staff>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Staff>(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 = GetEntityListCount(EntityListId::Misc);
int32_t remainingSpriteCount = GetEntityListCount(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<Guest>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Guest>(EntityListId::Peep))
{
if (peep->State != PEEP_STATE_QUEUING)
continue;
+2 -2
View File
@@ -1284,7 +1284,7 @@ void vehicle_sounds_update()
vehicle_sounds_update_window_setup();
for (auto vehicle : EntityList<Vehicle>(SPRITE_LIST_TRAIN_HEAD))
for (auto vehicle : EntityList<Vehicle>(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<Vehicle>(SPRITE_LIST_TRAIN_HEAD))
for (auto vehicle : EntityList<Vehicle>(EntityListId::TrainHead))
{
vehicle->Update();
}
+2 -2
View File
@@ -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<uint8_t>(EntityListId::Count)];
uint16_t sprite_lists_count[static_cast<uint8_t>(EntityListId::Count)];
rct_string_id park_name;
uint8_t pad_013573D6[2];
uint32_t park_name_args;
+9 -9
View File
@@ -101,29 +101,29 @@ namespace OpenRCT2::Scripting
std::vector<DukValue> 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<Staff>())
result.push_back(GetObjectAsDukValue(_context, std::make_shared<ScStaff>(sprite->sprite_index)));
else
result.push_back(GetObjectAsDukValue(_context, std::make_shared<ScGuest>(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;)
{
+1 -1
View File
@@ -363,7 +363,7 @@ void duck_press(Duck* duck)
void duck_remove_all()
{
for (auto duck : EntityList<Duck>(SPRITE_LIST_MISC))
for (auto duck : EntityList<Duck>(EntityListId::Misc))
{
duck->Remove();
}
+2 -2
View File
@@ -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<Guest>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Guest>(EntityListId::Peep))
{
if (!peep->OutsideOfPark)
{
@@ -468,7 +468,7 @@ int32_t Park::CalculateParkRating() const
// Litter
{
int32_t litterCount = 0;
for (auto litter : EntityList<Litter>(SPRITE_LIST_LITTER))
for (auto litter : EntityList<Litter>(EntityListId::Litter))
{
// Ignore recently dropped litter
if (litter->creationTick - gScenarioTicks >= 7680)
+44 -106
View File
@@ -25,8 +25,8 @@
#include <cmath>
#include <iterator>
uint16_t gSpriteListHead[SPRITE_LIST_COUNT];
uint16_t gSpriteListCount[SPRITE_LIST_COUNT];
uint16_t gSpriteListHead[static_cast<uint8_t>(EntityListId::Count)];
uint16_t gSpriteListCount[static_cast<uint8_t>(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<SpriteBase>() const
@@ -78,6 +78,11 @@ template<> bool SpriteBase::Is<ExplosionCloud>() const
return sprite_identifier == SPRITE_IDENTIFIER_MISC && type == SPRITE_MISC_EXPLOSION_CLOUD;
}
uint16_t GetEntityListCount(EntityListId list)
{
return gSpriteListCount[static_cast<uint8_t>(list)];
}
std::string rct_sprite_checksum::ToString() const
{
std::string result;
@@ -178,7 +183,7 @@ void reset_sprite_list()
gSavedAge = 0;
std::memset(static_cast<void*>(_spriteList), 0, sizeof(_spriteList));
for (int32_t i = 0; i < SPRITE_LIST_COUNT; i++)
for (int32_t i = 0; i < static_cast<uint8_t>(EntityListId::Count); i++)
{
gSpriteListHead[i] = SPRITE_INDEX_NULL;
gSpriteListCount[i] = 0;
@@ -193,7 +198,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 +208,13 @@ void reset_sprite_list()
else
{
spr->previous = SPRITE_INDEX_NULL;
gSpriteListHead[SPRITE_LIST_FREE] = i;
gSpriteListHead[static_cast<uint8_t>(EntityListId::Free)] = i;
}
_spriteFlashingList[i] = false;
previous_spr = spr;
}
gSpriteListCount[SPRITE_LIST_FREE] = MAX_SPRITES;
gSpriteListCount[static_cast<uint8_t>(EntityListId::Free)] = MAX_SPRITES;
reset_sprite_spatial_index();
}
@@ -335,7 +340,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 +363,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 +383,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 (GetEntityListCount(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 - GetEntityListCount(EntityListId::Misc);
if (miscSlotsRemaining >= GetEntityListCount(EntityListId::Free))
{
return nullptr;
}
}
auto* sprite = GetEntity(gSpriteListHead[SPRITE_LIST_FREE]);
auto* sprite = GetEntity(gSpriteListHead[static_cast<uint8_t>(EntityListId::Free)]);
move_sprite_to_list(sprite, linkedListIndex);
@@ -422,20 +427,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 +454,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 +468,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<uint8_t>(oldListIndex)] = sprite->next;
}
else
{
@@ -480,8 +485,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<uint8_t>(
newListIndex)]; // This sprite's next sprite is the old head, since we're the new head
gSpriteListHead[static_cast<uint8_t>(newListIndex)] = sprite->sprite_index; // Store this sprite's index as head of its new
// list
if (sprite->next != SPRITE_INDEX_NULL)
{
@@ -491,8 +498,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<uint8_t>(oldListIndex)]--;
gSpriteListCount[static_cast<uint8_t>(newListIndex)]++;
}
/**
@@ -628,7 +635,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<rct_sprite*>(entity));
@@ -744,7 +751,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 +805,11 @@ void litter_create(const CoordsXYZD& litterPos, int32_t type)
if (!litter_can_be_at(offsetLitterPos))
return;
if (gSpriteListCount[SPRITE_LIST_LITTER] >= 500)
if (GetEntityListCount(EntityListId::Litter) >= 500)
{
Litter* newestLitter = nullptr;
uint32_t newestLitterCreationTick = 0;
for (auto litter : EntityList<Litter>(SPRITE_LIST_LITTER))
for (auto litter : EntityList<Litter>(EntityListId::Litter))
{
if (newestLitterCreationTick <= litter->creationTick)
{
@@ -1024,43 +1031,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 +1045,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<uint8_t>(EntityListId::Count); i++)
{
auto* cycle_start = find_sprite_list_cycle(gSpriteListHead[i]);
if (cycle_start != nullptr)
@@ -1093,7 +1064,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<SPRITE_LIST>(i)))
while (!index_is_in_list(cycle_next, static_cast<EntityListId>(i)))
{
auto* spr = GetEntity(cycle_next);
@@ -1111,7 +1082,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 +1092,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<uint8_t>(EntityListId::Free)]; sprite_idx != SPRITE_INDEX_NULL;)
{
reachable[sprite_idx] = true;
// cache the tail, so we don't have to walk the list twice
@@ -1153,36 +1124,3 @@ int32_t fix_disjoint_sprites()
}
return count;
}
int32_t check_for_spatial_index_cycles(bool fix)
{
for (uint32_t i = 0; i < SPATIAL_INDEX_LOCATION_NULL; i++)
{
auto* cycle_start = find_sprite_quadrant_cycle(gSpriteSpatialIndex[i]);
if (cycle_start != nullptr)
{
if (fix)
{
// Store the leftover part of cycle to be fixed
uint16_t cycle_next = cycle_start->next_in_quadrant;
// Break the cycle
cycle_start->next_in_quadrant = SPRITE_INDEX_NULL;
// 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<SPRITE_LIST>(i)))
{
auto* spr = GetEntity(cycle_next);
cycle_start->next_in_quadrant = cycle_next;
cycle_next = spr->next_in_quadrant;
spr->next_in_quadrant = SPRITE_INDEX_NULL;
cycle_start = spr;
}
}
return i;
}
}
return -1;
}
+14 -14
View File
@@ -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
@@ -202,9 +202,10 @@ template<typename T> T* GetEntity(size_t sprite_idx)
}
SpriteBase* GetEntity(size_t sprite_idx);
uint16_t GetEntityListCount(EntityListId list);
extern uint16_t gSpriteListHead[SPRITE_LIST_COUNT];
extern uint16_t gSpriteListCount[SPRITE_LIST_COUNT];
extern uint16_t gSpriteListHead[static_cast<uint8_t>(EntityListId::Count)];
extern uint16_t gSpriteListCount[static_cast<uint8_t>(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 +213,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();
@@ -259,7 +260,6 @@ rct_sprite_checksum sprite_checksum();
void sprite_set_flashing(SpriteBase* sprite, bool flashing);
bool sprite_get_flashing(SpriteBase* sprite);
int32_t check_for_sprite_list_cycles(bool fix);
int32_t check_for_spatial_index_cycles(bool fix);
int32_t fix_disjoint_sprites();
template<typename T, uint16_t SpriteBase::*NextList> class EntityIterator
@@ -347,8 +347,8 @@ private:
using EntityListIterator = EntityIterator<T, &SpriteBase::next>;
public:
EntityList(SPRITE_LIST type)
: FirstEntity(gSpriteListHead[type])
EntityList(EntityListId type)
: FirstEntity(gSpriteListHead[static_cast<uint8_t>(type)])
{
}
+3 -2
View File
@@ -3,6 +3,7 @@
#include "../common.h"
struct CoordsXYZ;
enum class EntityListId : uint8_t;
struct SpriteBase
{
@@ -11,8 +12,8 @@ struct SpriteBase
uint16_t next_in_quadrant;
uint16_t next;
uint16_t previous;
// Valid values are SPRITE_LINKEDLIST_OFFSET_...
uint8_t linked_list_index;
// Valid values are EntityListId::...
EntityListId linked_list_index;
// Height from centre of sprite to bottom
uint8_t sprite_height_negative;
uint16_t sprite_index;