Fixed crash in init_shadow()

This commit is contained in:
MysterD 2022-02-14 18:28:01 -08:00
parent c0e1579fce
commit f73c841bfe
2 changed files with 4 additions and 1 deletions

View file

@ -736,7 +736,7 @@ static u16 atan2_lookup(f32 y, f32 x) {
ret = gArctanTable[0];
} else {
s32 index = (s32)(y / x * 1024 + 0.5f);
if (index >= 0x401) { index = 0; }
if (index >= 0x401 || index < 0) { index = 0; }
ret = gArctanTable[index];
}
return ret;

View file

@ -234,6 +234,9 @@ s8 init_shadow(struct Shadow *s, f32 xPos, f32 yPos, f32 zPos, s16 shadowScale,
s->floorNormalY = floorGeometry->normalY;
s->floorNormalZ = floorGeometry->normalZ;
s->floorOriginOffset = floorGeometry->originOffset;
} else {
// You can't draw a shadow with no floor under you.
return 1;
}
if (overwriteSolidity) {