mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-22 20:51:31 +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
|
||||
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;
|
||||
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;
|
||||
|
|
Loading…
Reference in a new issue