mirror of https://github.com/OpenRCT2/OpenRCT2.git
Provide accesor function for get entity list count
This commit is contained in:
parent
64ab101b4e
commit
57d2877e67
|
@ -310,8 +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[static_cast<uint8_t>(EntityListId::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]();
|
||||
}
|
||||
|
@ -371,8 +370,7 @@ void window_editor_bottom_toolbar_invalidate(rct_window* w)
|
|||
}
|
||||
else if (!(gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER))
|
||||
{
|
||||
if (gSpriteListCount[static_cast<uint8_t>(EntityListId::Free)] != MAX_SPRITES
|
||||
|| gParkFlags & PARK_FLAGS_SPRITES_INITIALISED)
|
||||
if (GetEntityListCount(EntityListId::Free) != MAX_SPRITES || gParkFlags & PARK_FLAGS_SPRITES_INITIALISED)
|
||||
{
|
||||
hide_previous_step_button();
|
||||
}
|
||||
|
@ -397,7 +395,7 @@ void window_editor_bottom_toolbar_paint(rct_window* w, rct_drawpixelinfo* dpi)
|
|||
{
|
||||
drawPreviousButton = true;
|
||||
}
|
||||
else if (gSpriteListCount[static_cast<uint8_t>(EntityListId::Free)] != MAX_SPRITES)
|
||||
else if (GetEntityListCount(EntityListId::Free) != MAX_SPRITES)
|
||||
{
|
||||
drawNextButton = true;
|
||||
}
|
||||
|
|
|
@ -105,7 +105,7 @@ private:
|
|||
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE);
|
||||
}
|
||||
|
||||
if (gSpriteListCount[static_cast<uint8_t>(EntityListId::Free)] < 400)
|
||||
if (GetEntityListCount(EntityListId::Free) < 400)
|
||||
{
|
||||
return MakeResult(GA_ERROR::NO_FREE_ELEMENTS, STR_TOO_MANY_PEOPLE_IN_GAME);
|
||||
}
|
||||
|
|
|
@ -1587,7 +1587,7 @@ void Peep::InsertNewThought(PeepThoughtType thoughtType, uint8_t thoughtArgument
|
|||
*/
|
||||
Peep* Peep::Generate(const CoordsXYZ& coords)
|
||||
{
|
||||
if (gSpriteListCount[static_cast<uint8_t>(EntityListId::Free)] < 400)
|
||||
if (GetEntityListCount(EntityListId::Free) < 400)
|
||||
return nullptr;
|
||||
|
||||
Peep* peep = &create_sprite(SPRITE_IDENTIFIER_PEEP)->peep;
|
||||
|
|
|
@ -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[static_cast<uint8_t>(EntityListId::Misc)];
|
||||
int32_t remainingSpriteCount = gSpriteListCount[static_cast<uint8_t>(EntityListId::Free)];
|
||||
int32_t miscSpriteCount = GetEntityListCount(EntityListId::Misc);
|
||||
int32_t remainingSpriteCount = GetEntityListCount(EntityListId::Free);
|
||||
return std::max(0, miscSpriteCount + remainingSpriteCount - 300);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
@ -380,7 +385,7 @@ static constexpr uint16_t MAX_MISC_SPRITES = 300;
|
|||
|
||||
rct_sprite* create_sprite(SPRITE_IDENTIFIER spriteIdentifier, EntityListId linkedListIndex)
|
||||
{
|
||||
if (gSpriteListCount[static_cast<uint8_t>(EntityListId::Free)] == 0)
|
||||
if (GetEntityListCount(EntityListId::Free) == 0)
|
||||
{
|
||||
// No free sprites.
|
||||
return nullptr;
|
||||
|
@ -391,8 +396,8 @@ rct_sprite* create_sprite(SPRITE_IDENTIFIER spriteIdentifier, EntityListId linke
|
|||
// 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[static_cast<uint8_t>(EntityListId::Misc)];
|
||||
if (miscSlotsRemaining >= gSpriteListCount[static_cast<uint8_t>(EntityListId::Free)])
|
||||
uint16_t miscSlotsRemaining = MAX_MISC_SPRITES - GetEntityListCount(EntityListId::Misc);
|
||||
if (miscSlotsRemaining >= GetEntityListCount(EntityListId::Free))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -800,7 +805,7 @@ void litter_create(const CoordsXYZD& litterPos, int32_t type)
|
|||
if (!litter_can_be_at(offsetLitterPos))
|
||||
return;
|
||||
|
||||
if (gSpriteListCount[static_cast<uint8_t>(EntityListId::Litter)] >= 500)
|
||||
if (GetEntityListCount(EntityListId::Litter) >= 500)
|
||||
{
|
||||
Litter* newestLitter = nullptr;
|
||||
uint32_t newestLitterCreationTick = 0;
|
||||
|
|
|
@ -202,6 +202,7 @@ template<typename T> T* GetEntity(size_t sprite_idx)
|
|||
}
|
||||
|
||||
SpriteBase* GetEntity(size_t sprite_idx);
|
||||
uint16_t GetEntityListCount(EntityListId list);
|
||||
|
||||
extern uint16_t gSpriteListHead[static_cast<uint8_t>(EntityListId::Count)];
|
||||
extern uint16_t gSpriteListCount[static_cast<uint8_t>(EntityListId::Count)];
|
||||
|
|
Loading…
Reference in New Issue