mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-27 04:04:17 +01:00
Fix/document possible division by zero in ConvertScaleParam
This commit is contained in:
parent
b88922daea
commit
67a656a4df
@ -1319,8 +1319,18 @@ void ApplyAffineAnimFrameRelativeAndUpdateMatrix(u8 matrixNum, struct AffineAnim
|
|||||||
|
|
||||||
s16 ConvertScaleParam(s16 scale)
|
s16 ConvertScaleParam(s16 scale)
|
||||||
{
|
{
|
||||||
|
s16 ret;
|
||||||
s32 val = 0x10000;
|
s32 val = 0x10000;
|
||||||
return val / scale;
|
// UB: possible division by zero
|
||||||
|
#ifdef UBFIX
|
||||||
|
if (scale != 0)
|
||||||
|
ret = val / scale;
|
||||||
|
else
|
||||||
|
ret = 0;
|
||||||
|
#else
|
||||||
|
ret = val / scale;
|
||||||
|
#endif //UBFIX
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetAffineAnimFrame(u8 matrixNum, struct Sprite *sprite, struct AffineAnimFrameCmd *frameCmd)
|
void GetAffineAnimFrame(u8 matrixNum, struct Sprite *sprite, struct AffineAnimFrameCmd *frameCmd)
|
||||||
|
@ -3042,7 +3042,7 @@ static void SpriteCB_PokedexListMonSprite(struct Sprite *sprite)
|
|||||||
if (gSineTable[sprite->data[5] + 64] != 0)
|
if (gSineTable[sprite->data[5] + 64] != 0)
|
||||||
var = 0x10000 / gSineTable[sprite->data[5] + 64];
|
var = 0x10000 / gSineTable[sprite->data[5] + 64];
|
||||||
else
|
else
|
||||||
var = 0xFFFF;
|
var = 0;
|
||||||
#else
|
#else
|
||||||
var = 0x10000 / gSineTable[sprite->data[5] + 64];
|
var = 0x10000 / gSineTable[sprite->data[5] + 64];
|
||||||
#endif //UBFIX
|
#endif //UBFIX
|
||||||
|
Loading…
Reference in New Issue
Block a user