- use local screen size variables in automap code.

This commit is contained in:
Christoph Oelckers 2021-02-27 12:30:20 +01:00
parent 783328c5fa
commit 2094b6420f
2 changed files with 43 additions and 30 deletions

View file

@ -410,6 +410,8 @@ void drawredlines(int cposx, int cposy, int czoom, int cang)
int yvect = -bcos(cang) * czoom;
int xvect2 = MulScale(xvect, yxaspect, 16);
int yvect2 = MulScale(yvect, yxaspect, 16);
int width = screen->GetWidth();
int height = screen->GetHeight();
for (int i = 0; i < numsectors; i++)
{
@ -435,14 +437,14 @@ void drawredlines(int cposx, int cposy, int czoom, int cang)
{
int ox = wal->x - cposx;
int oy = wal->y - cposy;
int x1 = DMulScale(ox, xvect, -oy, yvect, 16) + (xdim << 11);
int y1 = DMulScale(oy, xvect2, ox, yvect2, 16) + (ydim << 11);
int x1 = DMulScale(ox, xvect, -oy, yvect, 16) + (width << 11);
int y1 = DMulScale(oy, xvect2, ox, yvect2, 16) + (height << 11);
auto wal2 = &wall[wal->point2];
ox = wal2->x - cposx;
oy = wal2->y - cposy;
int x2 = DMulScale(ox, xvect, -oy, yvect, 16) + (xdim << 11);
int y2 = DMulScale(oy, xvect2, ox, yvect2, 16) + (ydim << 11);
int x2 = DMulScale(ox, xvect, -oy, yvect, 16) + (width << 11);
int y2 = DMulScale(oy, xvect2, ox, yvect2, 16) + (height << 11);
drawlinergb(x1, y1, x2, y2, RedLineColor());
}
@ -462,6 +464,8 @@ static void drawwhitelines(int cposx, int cposy, int czoom, int cang)
int yvect = -bcos(cang) * czoom;
int xvect2 = MulScale(xvect, yxaspect, 16);
int yvect2 = MulScale(yvect, yxaspect, 16);
int width = screen->GetWidth();
int height = screen->GetHeight();
for (int i = numsectors - 1; i >= 0; i--)
{
@ -483,15 +487,15 @@ static void drawwhitelines(int cposx, int cposy, int czoom, int cang)
int ox = wal->x - cposx;
int oy = wal->y - cposy;
int x1 = DMulScale(ox, xvect, -oy, yvect, 16) + (xdim << 11);
int y1 = DMulScale(oy, xvect2, ox, yvect2, 16) + (ydim << 11);
int x1 = DMulScale(ox, xvect, -oy, yvect, 16) + (width << 11);
int y1 = DMulScale(oy, xvect2, ox, yvect2, 16) + (height << 11);
int k = wal->point2;
auto wal2 = &wall[k];
ox = wal2->x - cposx;
oy = wal2->y - cposy;
int x2 = DMulScale(ox, xvect, -oy, yvect, 16) + (xdim << 11);
int y2 = DMulScale(oy, xvect2, ox, yvect2, 16) + (ydim << 11);
int x2 = DMulScale(ox, xvect, -oy, yvect, 16) + (width << 11);
int y2 = DMulScale(oy, xvect2, ox, yvect2, 16) + (height << 11);
drawlinergb(x1, y1, x2, y2, WhiteLineColor());
}
@ -516,23 +520,26 @@ void DrawPlayerArrow(int cposx, int cposy, int cang, int pl_x, int pl_y, int zoo
int pxvect = -bsin(pl_angle);
int pyvect = -bcos(pl_angle);
int width = screen->GetWidth();
int height = screen->GetHeight();
for (int i = 0; i < 12; i += 4)
{
int px1 = DMulScale(arrow[i], pxvect, -arrow[i+1], pyvect, 16);
int py1 = DMulScale(arrow[i+1], pxvect, arrow[i], pyvect, 16) + (ydim << 11);
int py1 = DMulScale(arrow[i+1], pxvect, arrow[i], pyvect, 16) + (height << 11);
int px2 = DMulScale(arrow[i+2], pxvect, -arrow[i + 3], pyvect, 16);
int py2 = DMulScale(arrow[i + 3], pxvect, arrow[i+2], pyvect, 16) + (ydim << 11);
int py2 = DMulScale(arrow[i + 3], pxvect, arrow[i+2], pyvect, 16) + (height << 11);
int ox1 = px1 - cposx;
int oy1 = py1 - cposx;
int ox2 = px2 - cposx;
int oy2 = py2 - cposx;
int sx1 = DMulScale(ox1, xvect, -oy1, yvect, 16) + (xdim << 11);
int sy1 = DMulScale(oy1, xvect2, ox1, yvect2, 16) + (ydim << 11);
int sx2 = DMulScale(ox2, xvect, -oy2, yvect, 16) + (xdim << 11);
int sy2 = DMulScale(oy2, xvect2, ox2, yvect2, 16) + (ydim << 11);
int sx1 = DMulScale(ox1, xvect, -oy1, yvect, 16) + (width << 11);
int sy1 = DMulScale(oy1, xvect2, ox1, yvect2, 16) + (height << 11);
int sx2 = DMulScale(ox2, xvect, -oy2, yvect, 16) + (width << 11);
int sy2 = DMulScale(oy2, xvect2, ox2, yvect2, 16) + (height << 11);
drawlinergb(sx1, sy1, sx2, sy2, WhiteLineColor());
}
@ -555,14 +562,15 @@ void DrawOverheadMap(int pl_x, int pl_y, int pl_angle, double const smoothratio)
int y = follow_y;
follow_a = am_rotate ? pl_angle : 0;
AutomapControl();
int width = screen->GetWidth();
if (automapMode == am_full)
{
twod->ClearScreen();
renderDrawMapView(x, y, gZoom, follow_a);
}
int32_t tmpydim = (xdim * 5) / 8;
renderSetAspect(65536, DivScale(tmpydim * 320, xdim * 200, 16));
int32_t tmpydim = (width * 5) / 8;
renderSetAspect(65536, DivScale(tmpydim * 320, width * 200, 16));
drawredlines(x, y, gZoom, follow_a);
drawwhitelines(x, y, gZoom, follow_a);