Skip to content

Commit

Permalink
Merge pull request #11980 from duncanspumpkin/CreateSprite8
Browse files Browse the repository at this point in the history
SpriteList enum class
  • Loading branch information
Gymnasiast committed Jul 6, 2020
2 parents 8ce799a + 57d2877 commit f7b42a0
Show file tree
Hide file tree
Showing 30 changed files with 148 additions and 212 deletions.
2 changes: 1 addition & 1 deletion src/openrct2-ui/interface/ViewportInteraction.cpp
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/openrct2-ui/windows/EditorBottomToolbar.cpp
Expand Up @@ -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]();
}
Expand Down Expand Up @@ -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();
}
Expand All @@ -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;
}
Expand Down
8 changes: 4 additions & 4 deletions src/openrct2-ui/windows/GuestList.cpp
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
{
Expand All @@ -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;
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/openrct2-ui/windows/Map.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/openrct2-ui/windows/Ride.cpp
Expand Up @@ -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)
{
Expand Down
6 changes: 3 additions & 3 deletions src/openrct2-ui/windows/StaffList.cpp
Expand Up @@ -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)
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/openrct2/Game.cpp
Expand Up @@ -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)
{
Expand All @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion src/openrct2/actions/RideDemolishAction.hpp
Expand Up @@ -153,7 +153,7 @@ DEFINE_GAME_ACTION(RideDemolishAction, GAME_COMMAND_DEMOLISH_RIDE, GameActionRes
}
}

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;
Expand Down
12 changes: 6 additions & 6 deletions src/openrct2/actions/SetCheatAction.hpp
Expand Up @@ -427,7 +427,7 @@ DEFINE_GAME_ACTION(SetCheatAction, GAME_COMMAND_CHEAT, GameActionResult)

void RemoveLitter() const
{
for (auto litter : EntityList<Litter>(SPRITE_LIST_LITTER))
for (auto litter : EntityList<Litter>(EntityListId::Litter))
{
sprite_remove(litter);
}
Expand Down Expand Up @@ -570,7 +570,7 @@ DEFINE_GAME_ACTION(SetCheatAction, GAME_COMMAND_CHEAT, GameActionResult)

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)
{
Expand Down Expand Up @@ -614,7 +614,7 @@ DEFINE_GAME_ACTION(SetCheatAction, GAME_COMMAND_CHEAT, GameActionResult)

void GiveObjectToGuests(int32_t object) const
{
for (auto peep : EntityList<Guest>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Guest>(EntityListId::Peep))
{
switch (object)
{
Expand Down Expand Up @@ -686,7 +686,7 @@ DEFINE_GAME_ACTION(SetCheatAction, GAME_COMMAND_CHEAT, GameActionResult)

// 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)
{
Expand All @@ -700,7 +700,7 @@ DEFINE_GAME_ACTION(SetCheatAction, GAME_COMMAND_CHEAT, GameActionResult)

void ExplodeGuests() const
{
for (auto peep : EntityList<Guest>(SPRITE_LIST_PEEP))
for (auto peep : EntityList<Guest>(EntityListId::Peep))
{
if (scenario_rand_max(6) == 0)
{
Expand All @@ -711,7 +711,7 @@ DEFINE_GAME_ACTION(SetCheatAction, GAME_COMMAND_CHEAT, GameActionResult)

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;
Expand Down
8 changes: 4 additions & 4 deletions src/openrct2/actions/StaffHireNewAction.hpp
Expand Up @@ -105,7 +105,7 @@ DEFINE_GAME_ACTION(StaffHireNewAction, GAME_COMMAND_HIRE_NEW_STAFF_MEMBER, Staff
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);
}
Expand Down Expand Up @@ -182,7 +182,7 @@ DEFINE_GAME_ACTION(StaffHireNewAction, GAME_COMMAND_HIRE_NEW_STAFF_MEMBER, Staff
{
bool found = false;
++newStaffId;
for (auto searchPeep : EntityList<Staff>(SPRITE_LIST_PEEP))
for (auto searchPeep : EntityList<Staff>(EntityListId::Peep))
{
if (searchPeep->StaffType != _staffType)
continue;
Expand Down Expand Up @@ -267,7 +267,7 @@ DEFINE_GAME_ACTION(StaffHireNewAction, GAME_COMMAND_HIRE_NEW_STAFF_MEMBER, Staff

// 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)
{
Expand All @@ -286,7 +286,7 @@ DEFINE_GAME_ACTION(StaffHireNewAction, GAME_COMMAND_HIRE_NEW_STAFF_MEMBER, Staff
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)
{
Expand Down
2 changes: 1 addition & 1 deletion src/openrct2/actions/StaffSetColourAction.hpp
Expand Up @@ -65,7 +65,7 @@ DEFINE_GAME_ACTION(StaffSetColourAction, GAME_COMMAND_SET_STAFF_COLOUR, GameActi
}

// 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)
{
Expand Down
4 changes: 2 additions & 2 deletions src/openrct2/interface/InteractiveConsole.cpp
Expand Up @@ -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(
Expand Down Expand Up @@ -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];
}
Expand Down
18 changes: 9 additions & 9 deletions src/openrct2/management/Award.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/openrct2/management/Finance.cpp
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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];
}
Expand Down
4 changes: 2 additions & 2 deletions src/openrct2/peep/Guest.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit f7b42a0

Please sign in to comment.