Fix light flickering when different types of light sprite are present (#8043)

This commit is contained in:
FosterProgramming 2025-11-15 15:14:17 +01:00 committed by GitHub
parent d9d3e51a9c
commit e472d277d2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2627,37 +2627,29 @@ void UpdateLightSprite(struct Sprite *sprite)
return; return;
} }
// Note: Don't set window registers during hardware fade! if (sprite->sLightType == LIGHT_TYPE_BALL)
switch (sprite->sLightType)
{ {
default:
case LIGHT_TYPE_BALL:
if (gPaletteFade.active) // if palette fade is active, don't flicker since the timer won't be updated if (gPaletteFade.active) // if palette fade is active, don't flicker since the timer won't be updated
{ {
Weather_SetBlendCoeffs(7, BASE_SHADOW_INTENSITY);
sprite->invisible = FALSE; sprite->invisible = FALSE;
} }
else if (gPlayerAvatar.tileTransitionState) else if (gPlayerAvatar.tileTransitionState)
{ {
Weather_SetBlendCoeffs(7, BASE_SHADOW_INTENSITY); // As long as the second coefficient stays 12, shadows will not change
sprite->invisible = FALSE; sprite->invisible = FALSE;
if (GetSpritePaletteTagByPaletteNum(sprite->oam.paletteNum) == OBJ_EVENT_PAL_TAG_LIGHT_2) if (GetSpritePaletteTagByPaletteNum(sprite->oam.paletteNum) == OBJ_EVENT_PAL_TAG_LIGHT_2)
LoadSpritePaletteInSlot(&sObjectEventSpritePalettes[FindObjectEventPaletteIndexByTag(OBJ_EVENT_PAL_TAG_LIGHT)], sprite->oam.paletteNum); LoadSpritePaletteInSlot(&sObjectEventSpritePalettes[FindObjectEventPaletteIndexByTag(OBJ_EVENT_PAL_TAG_LIGHT)], sprite->oam.paletteNum);
} }
else if ((sprite->invisible = gTimeUpdateCounter & 1)) else if ((sprite->invisible = gTimeUpdateCounter & 1))
{ {
Weather_SetBlendCoeffs(7, BASE_SHADOW_INTENSITY);
sprite->invisible = FALSE; sprite->invisible = FALSE;
if (GetSpritePaletteTagByPaletteNum(sprite->oam.paletteNum) == OBJ_EVENT_PAL_TAG_LIGHT_2) if (GetSpritePaletteTagByPaletteNum(sprite->oam.paletteNum) == OBJ_EVENT_PAL_TAG_LIGHT_2)
LoadSpritePaletteInSlot(&sObjectEventSpritePalettes[FindObjectEventPaletteIndexByTag(OBJ_EVENT_PAL_TAG_LIGHT)], sprite->oam.paletteNum); LoadSpritePaletteInSlot(&sObjectEventSpritePalettes[FindObjectEventPaletteIndexByTag(OBJ_EVENT_PAL_TAG_LIGHT)], sprite->oam.paletteNum);
} }
break; } else {
case LIGHT_TYPE_PKMN_CENTER_SIGN:
case LIGHT_TYPE_POKE_MART_SIGN:
Weather_SetBlendCoeffs(12, BASE_SHADOW_INTENSITY);
sprite->invisible = FALSE; sprite->invisible = FALSE;
break;
} }
// Note: Don't set window registers during hardware fade!
Weather_SetBlendCoeffs(7, BASE_SHADOW_INTENSITY);
} }
// Spawn a light at a map coordinate // Spawn a light at a map coordinate