Fix a sprite issue with B_SHOW_TYPES (#5157)
* Fixed issue where tiles were not freed * Updated to destroy first * Cleaned up returns * Added typeIconTags Added FreeAllTypeIconResources Fixed issue where typeIcons were not being properly handled when hidden
This commit is contained in:
parent
f18859ac33
commit
38752b59b4
1 changed files with 31 additions and 7 deletions
|
@ -28,6 +28,7 @@ static bool32 ShouldFlipTypeIcon(bool32, u32, u32);
|
|||
|
||||
static void SpriteCB_TypeIcon(struct Sprite*);
|
||||
static void DestroyTypeIcon(struct Sprite*);
|
||||
static void FreeAllTypeIconResources(void);
|
||||
static bool32 ShouldHideTypeIcon(u32);
|
||||
static s32 GetTypeIconHideMovement(bool32, u32);
|
||||
static s32 GetTypeIconSlideMovement(bool32, u32, s32);
|
||||
|
@ -429,22 +430,45 @@ static void SpriteCB_TypeIcon(struct Sprite* sprite)
|
|||
sprite->y = GetTypeIconBounceMovement(sprite->tVerticalPosition,position);
|
||||
}
|
||||
|
||||
static const u32 typeIconTags[] =
|
||||
{
|
||||
TYPE_ICON_TAG,
|
||||
TYPE_ICON_TAG_2
|
||||
};
|
||||
|
||||
static void DestroyTypeIcon(struct Sprite* sprite)
|
||||
{
|
||||
u32 i;
|
||||
u32 spriteId, tag;
|
||||
|
||||
DestroySpriteAndFreeResources(sprite);
|
||||
|
||||
for (i = 0; i < MAX_SPRITES; ++i)
|
||||
for (spriteId = 0; spriteId < MAX_SPRITES; ++spriteId)
|
||||
{
|
||||
if (!gSprites[i].inUse)
|
||||
if (!gSprites[spriteId].inUse)
|
||||
continue;
|
||||
|
||||
if (gSprites[i].template->paletteTag == TYPE_ICON_TAG)
|
||||
return;
|
||||
for (tag = 0; tag < 2; tag++)
|
||||
{
|
||||
if (gSprites[spriteId].template->paletteTag == typeIconTags[tag])
|
||||
return;
|
||||
|
||||
if (gSprites[spriteId].template->tileTag == typeIconTags[tag])
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
FreeSpritePaletteByTag(TYPE_ICON_TAG);
|
||||
FreeSpritePaletteByTag(TYPE_ICON_TAG_2);
|
||||
FreeAllTypeIconResources();
|
||||
}
|
||||
|
||||
static void FreeAllTypeIconResources(void)
|
||||
{
|
||||
u32 tag;
|
||||
|
||||
for (tag = 0; tag < 2; tag++)
|
||||
{
|
||||
FreeSpriteTilesByTag(typeIconTags[tag]);
|
||||
FreeSpritePaletteByTag(typeIconTags[tag]);
|
||||
}
|
||||
}
|
||||
|
||||
static bool32 ShouldHideTypeIcon(u32 battlerId)
|
||||
|
|
Loading…
Reference in a new issue