mirror of https://github.com/OpenRCT2/OpenRCT2.git
Fix overflow calculating maximum free slots for misc entities
This commit is contained in:
parent
7d8f13a97f
commit
3dc2a25121
|
@ -341,11 +341,14 @@ EntityBase* CreateEntity(EntityType type)
|
||||||
|
|
||||||
if (EntityTypeIsMiscEntity(type))
|
if (EntityTypeIsMiscEntity(type))
|
||||||
{
|
{
|
||||||
// Misc sprites are commonly used for effects, if there are less than MAX_MISC_SPRITES
|
// Misc sprites are commonly used for effects, give other entity types higher priority.
|
||||||
// free it will fail to keep slots for more relevant sprites.
|
if (GetMiscEntityCount() >= MAX_MISC_SPRITES)
|
||||||
// Also there can't be more than MAX_MISC_SPRITES sprites in this list.
|
{
|
||||||
uint16_t miscSlotsRemaining = MAX_MISC_SPRITES - GetMiscEntityCount();
|
return nullptr;
|
||||||
if (miscSlotsRemaining >= _freeIdList.size())
|
}
|
||||||
|
|
||||||
|
// If there are less than MAX_MISC_SPRITES free slots, ensure other entities can be created.
|
||||||
|
if (_freeIdList.size() < MAX_MISC_SPRITES)
|
||||||
{
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue