Replace INVALID_IMAGE_ID with ImageIndexUndefined

This commit is contained in:
Michael Steenbeek 2024-04-21 01:17:42 +02:00 committed by GitHub
parent 3d05fce68e
commit f7f7cd823f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 8 deletions

View File

@ -20,7 +20,6 @@
constexpr uint32_t BASE_IMAGE_ID = SPR_IMAGE_LIST_BEGIN; constexpr uint32_t BASE_IMAGE_ID = SPR_IMAGE_LIST_BEGIN;
constexpr uint32_t MAX_IMAGES = SPR_IMAGE_LIST_END - BASE_IMAGE_ID; constexpr uint32_t MAX_IMAGES = SPR_IMAGE_LIST_END - BASE_IMAGE_ID;
constexpr uint32_t INVALID_IMAGE_ID = UINT32_MAX;
static bool _initialised = false; static bool _initialised = false;
static std::list<ImageList> _freeLists; static std::list<ImageList> _freeLists;
@ -127,7 +126,7 @@ static uint32_t TryAllocateImageList(uint32_t count)
return imageList.BaseId; return imageList.BaseId;
} }
} }
return INVALID_IMAGE_ID; return ImageIndexUndefined;
} }
static uint32_t AllocateImageList(uint32_t count) static uint32_t AllocateImageList(uint32_t count)
@ -139,12 +138,12 @@ static uint32_t AllocateImageList(uint32_t count)
InitialiseImageList(); InitialiseImageList();
} }
uint32_t baseImageId = INVALID_IMAGE_ID; uint32_t baseImageId = ImageIndexUndefined;
uint32_t freeImagesRemaining = GetNumFreeImagesRemaining(); uint32_t freeImagesRemaining = GetNumFreeImagesRemaining();
if (freeImagesRemaining >= count) if (freeImagesRemaining >= count)
{ {
baseImageId = TryAllocateImageList(count); baseImageId = TryAllocateImageList(count);
if (baseImageId == INVALID_IMAGE_ID) if (baseImageId == ImageIndexUndefined)
{ {
// Defragment and try again // Defragment and try again
MergeFreeLists(); MergeFreeLists();
@ -190,14 +189,14 @@ uint32_t GfxObjectAllocateImages(const G1Element* images, uint32_t count)
{ {
if (count == 0 || gOpenRCT2NoGraphics) if (count == 0 || gOpenRCT2NoGraphics)
{ {
return INVALID_IMAGE_ID; return ImageIndexUndefined;
} }
uint32_t baseImageId = AllocateImageList(count); uint32_t baseImageId = AllocateImageList(count);
if (baseImageId == INVALID_IMAGE_ID) if (baseImageId == ImageIndexUndefined)
{ {
LOG_ERROR("Reached maximum image limit."); LOG_ERROR("Reached maximum image limit.");
return INVALID_IMAGE_ID; return ImageIndexUndefined;
} }
uint32_t imageId = baseImageId; uint32_t imageId = baseImageId;
@ -213,7 +212,7 @@ uint32_t GfxObjectAllocateImages(const G1Element* images, uint32_t count)
void GfxObjectFreeImages(uint32_t baseImageId, uint32_t count) void GfxObjectFreeImages(uint32_t baseImageId, uint32_t count)
{ {
if (baseImageId != 0 && baseImageId != INVALID_IMAGE_ID) if (baseImageId != 0 && baseImageId != ImageIndexUndefined)
{ {
// Zero the G1 elements so we don't have invalid pointers // Zero the G1 elements so we don't have invalid pointers
// and data lying about // and data lying about