mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-23 04:52:07 +00:00
correctly check limits in RE_Draw
This commit is contained in:
parent
65888e6b9b
commit
9783e7955f
1 changed files with 15 additions and 13 deletions
|
@ -77,13 +77,16 @@ smoothly scrolled off.
|
||||||
void
|
void
|
||||||
RE_Draw_CharScaled(int x, int y, int num, float scale)
|
RE_Draw_CharScaled(int x, int y, int num, float scale)
|
||||||
{
|
{
|
||||||
pixel_t *dest, *dest_max;
|
pixel_t *dest;
|
||||||
byte *source;
|
byte *source;
|
||||||
int drawline;
|
int drawline;
|
||||||
int row, col, u, xpos, ypos, iscale;
|
int row, col, u, xpos, ypos, iscale;
|
||||||
|
|
||||||
iscale = (int) scale;
|
iscale = (int) scale;
|
||||||
|
|
||||||
|
if (iscale < 1)
|
||||||
|
return;
|
||||||
|
|
||||||
num &= 255;
|
num &= 255;
|
||||||
|
|
||||||
if (num == 32 || num == 32+128)
|
if (num == 32 || num == 32+128)
|
||||||
|
@ -109,7 +112,12 @@ RE_Draw_CharScaled(int x, int y, int num, float scale)
|
||||||
drawline = 8;
|
drawline = 8;
|
||||||
|
|
||||||
dest = vid_buffer + y * vid.width + x;
|
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--)
|
while (drawline--)
|
||||||
{
|
{
|
||||||
|
@ -124,12 +132,6 @@ RE_Draw_CharScaled(int x, int y, int num, float scale)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dest += vid.width;
|
dest += vid.width;
|
||||||
|
|
||||||
// clipped last lines
|
|
||||||
if (dest >= dest_max)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
source += 128;
|
source += 128;
|
||||||
}
|
}
|
||||||
|
@ -160,7 +162,7 @@ RE_Draw_GetPicSize (int *w, int *h, char *pic)
|
||||||
RE_Draw_StretchPicImplementation
|
RE_Draw_StretchPicImplementation
|
||||||
=============
|
=============
|
||||||
*/
|
*/
|
||||||
void
|
static void
|
||||||
RE_Draw_StretchPicImplementation (int x, int y, int w, int h, const image_t *pic)
|
RE_Draw_StretchPicImplementation (int x, int y, int w, int h, const image_t *pic)
|
||||||
{
|
{
|
||||||
pixel_t *dest;
|
pixel_t *dest;
|
||||||
|
@ -266,8 +268,8 @@ RE_Draw_PicScaled(int x, int y, char *name, float scale)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((x < 0) ||
|
if ((x < 0) ||
|
||||||
(x + pic->width > vid.width) ||
|
(x + pic->width * scale > vid.width) ||
|
||||||
(y + pic->height > vid.height))
|
(y + pic->height * scale > vid.height))
|
||||||
{
|
{
|
||||||
R_Printf(PRINT_ALL, "Draw_Pic: bad coordinates\n");
|
R_Printf(PRINT_ALL, "Draw_Pic: bad coordinates\n");
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue