diff --git a/src/k_kart.c b/src/k_kart.c index 45d3a5d79..8918e7c5b 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -5105,14 +5105,24 @@ static void K_drawKartMinimap(void) if (bsp->bbox[1][BOXTOP] > maxy) maxy = bsp->bbox[1][BOXTOP]; + // You might be wondering why these are being bitshift here + // it's because mapwidth and height would otherwise overflow for maps larger than half the size possible... + // map boundaries and sizes will ALWAYS be whole numbers thankfully + // later calculations take into consideration that these are actually not in terms of FRACUNIT though + minx >>= FRACBITS; + maxx >>= FRACBITS; + miny >>= FRACBITS; + maxy >>= FRACBITS; + fixed_t mapwidth = maxx - minx; fixed_t mapheight = maxy - miny; - fixed_t xoffset = minx + mapwidth/2; - fixed_t yoffset = miny + mapheight/2; + // These should always be small enough to be bitshift back right now + fixed_t xoffset = (minx + mapwidth/2)<width<height<width/2, mapwidth); + fixed_t yscale = FixedDiv(AutomapPic->height/2, mapheight); fixed_t zoom = FixedMul(min(xscale, yscale), FRACUNIT-FRACUNIT/20); amnumxpos = (FixedMul(players[i].mo->x, zoom) - FixedMul(xoffset, zoom));