Merge pull request #1815 from tustin2121/patch-5
Adding FindObjectEventPaletteIndexByTag bugfix
This commit is contained in:
@@ -497,7 +497,12 @@ static const struct SpritePalette sObjectEventSpritePalettes[] = {
|
|||||||
{gObjectEventPal_Lugia, OBJ_EVENT_PAL_TAG_LUGIA},
|
{gObjectEventPal_Lugia, OBJ_EVENT_PAL_TAG_LUGIA},
|
||||||
{gObjectEventPal_RubySapphireBrendan, OBJ_EVENT_PAL_TAG_RS_BRENDAN},
|
{gObjectEventPal_RubySapphireBrendan, OBJ_EVENT_PAL_TAG_RS_BRENDAN},
|
||||||
{gObjectEventPal_RubySapphireMay, OBJ_EVENT_PAL_TAG_RS_MAY},
|
{gObjectEventPal_RubySapphireMay, OBJ_EVENT_PAL_TAG_RS_MAY},
|
||||||
{},
|
#ifdef BUGFIX
|
||||||
|
{NULL, OBJ_EVENT_PAL_TAG_NONE},
|
||||||
|
#else
|
||||||
|
{}, // BUG: FindObjectEventPaletteIndexByTag looks for OBJ_EVENT_PAL_TAG_NONE and not 0x0.
|
||||||
|
// If it's looking for a tag that isn't in this table, the game locks in an infinite loop.
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
static const u16 sReflectionPaletteTags_Brendan[] = {
|
static const u16 sReflectionPaletteTags_Brendan[] = {
|
||||||
@@ -1993,7 +1998,12 @@ static void LoadObjectEventPalette(u16 paletteTag)
|
|||||||
{
|
{
|
||||||
u16 i = FindObjectEventPaletteIndexByTag(paletteTag);
|
u16 i = FindObjectEventPaletteIndexByTag(paletteTag);
|
||||||
|
|
||||||
if (i != OBJ_EVENT_PAL_TAG_NONE) // always true
|
// FindObjectEventPaletteIndexByTag returns 0xFF on failure, not OBJ_EVENT_PAL_TAG_NONE.
|
||||||
|
#ifdef BUGFIX
|
||||||
|
if (i != 0xFF)
|
||||||
|
#else
|
||||||
|
if (i != OBJ_EVENT_PAL_TAG_NONE)
|
||||||
|
#endif
|
||||||
LoadSpritePaletteIfTagExists(&sObjectEventSpritePalettes[i]);
|
LoadSpritePaletteIfTagExists(&sObjectEventSpritePalettes[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2016,6 +2026,7 @@ static u8 LoadSpritePaletteIfTagExists(const struct SpritePalette *spritePalette
|
|||||||
|
|
||||||
void PatchObjectPalette(u16 paletteTag, u8 paletteSlot)
|
void PatchObjectPalette(u16 paletteTag, u8 paletteSlot)
|
||||||
{
|
{
|
||||||
|
// paletteTag is assumed to exist in sObjectEventSpritePalettes
|
||||||
u8 paletteIndex = FindObjectEventPaletteIndexByTag(paletteTag);
|
u8 paletteIndex = FindObjectEventPaletteIndexByTag(paletteTag);
|
||||||
|
|
||||||
LoadPalette(sObjectEventSpritePalettes[paletteIndex].data, 16 * paletteSlot + 0x100, 0x20);
|
LoadPalette(sObjectEventSpritePalettes[paletteIndex].data, 16 * paletteSlot + 0x100, 0x20);
|
||||||
|
|||||||
Reference in New Issue
Block a user