From a3f38bb9e834739b92470040273163b14e54da96 Mon Sep 17 00:00:00 2001 From: Sryder13 Date: Sat, 13 Jan 2018 21:07:44 +0000 Subject: [PATCH] Fix minimaps for any maps that are larger than half of the mappable area, in either direction. --- src/k_kart.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 7bd27ae99..9b4a56b00 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -5032,14 +5032,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));