Add UBFIX for division by zero in SpriteCB_PokedexListMonSprite

This commit is contained in:
Sierraffinity 2020-12-26 18:25:21 -08:00
parent bafbf9240d
commit 127bb97c0e

View File

@ -3037,7 +3037,15 @@ static void SpriteCB_PokedexListMonSprite(struct Sprite *sprite)
u32 var;
sprite->pos2.y = gSineTable[(u8)sprite->data[5]] * 76 / 256;
// UB: possible division by zero
#ifdef UBFIX
if (gSineTable[sprite->data[5] + 64] != 0)
var = 0x10000 / gSineTable[sprite->data[5] + 64];
else
var = 0xFFFF;
#else
var = 0x10000 / gSineTable[sprite->data[5] + 64];
#endif //UBFIX
if (var > 0xFFFF)
var = 0xFFFF;
SetOamMatrix(sprite->data[1] + 1, 0x100, 0, 0, var);