diff --git a/src/engine/math_util.c b/src/engine/math_util.c index c398243b3..19b1e79a4 100644 --- a/src/engine/math_util.c +++ b/src/engine/math_util.c @@ -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; diff --git a/src/game/shadow.c b/src/game/shadow.c index 5bbb4e9cb..c6315c633 100644 --- a/src/game/shadow.c +++ b/src/game/shadow.c @@ -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) {