correctly check limits in RE_Draw

This commit is contained in:
Denis Pauk 2019-06-11 22:52:56 +03:00
parent 65888e6b9b
commit 9783e7955f

View file

@ -77,13 +77,16 @@ smoothly scrolled off.
void
RE_Draw_CharScaled(int x, int y, int num, float scale)
{
pixel_t *dest, *dest_max;
pixel_t *dest;
byte *source;
int drawline;
int row, col, u, xpos, ypos, iscale;
iscale = (int) scale;
if (iscale < 1)
return;
num &= 255;
if (num == 32 || num == 32+128)
@ -109,7 +112,12 @@ RE_Draw_CharScaled(int x, int y, int num, float scale)
drawline = 8;
dest = vid_buffer + y * vid.width + x;
dest_max = vid_buffer + vid.height * vid.width;
// clipped last lines
if ((y + iscale * (drawline + 1)) > vid.height)
{
drawline = (vid.height - y) / iscale;
}
while (drawline--)
{
@ -124,12 +132,6 @@ RE_Draw_CharScaled(int x, int y, int num, float scale)
}
}
dest += vid.width;
// clipped last lines
if (dest >= dest_max)
{
return;
}
}
source += 128;
}
@ -160,7 +162,7 @@ RE_Draw_GetPicSize (int *w, int *h, char *pic)
RE_Draw_StretchPicImplementation
=============
*/
void
static void
RE_Draw_StretchPicImplementation (int x, int y, int w, int h, const image_t *pic)
{
pixel_t *dest;
@ -266,8 +268,8 @@ RE_Draw_PicScaled(int x, int y, char *name, float scale)
}
if ((x < 0) ||
(x + pic->width > vid.width) ||
(y + pic->height > vid.height))
(x + pic->width * scale > vid.width) ||
(y + pic->height * scale > vid.height))
{
R_Printf(PRINT_ALL, "Draw_Pic: bad coordinates\n");
return;