This commit is contained in:
Fabian Greffrath 2021-01-11 09:19:12 +01:00
commit 8ecb882201

View File

@ -302,7 +302,7 @@ void V_DrawPatchGeneral(int x, int y, int scrn, patch_t *patch,
y -= SHORT(patch->topoffset);
x -= SHORT(patch->leftoffset);
#ifdef RANGECHECK
#ifdef RANGECHECK_NOTHANKS
if (x<0
||x+SHORT(patch->width) >SCREENWIDTH
|| y<0
@ -318,11 +318,21 @@ void V_DrawPatchGeneral(int x, int y, int scrn, patch_t *patch,
{
byte *desttop = screens[scrn]+y*SCREENWIDTH*4+x*2;
for ( ; col != colstop ; col += colstep, desttop+=2)
for ( ; col != colstop ; col += colstep, desttop+=2, x++)
{
const column_t *column =
(const column_t *)((byte *)patch + LONG(patch->columnofs[col]));
// [FG] prevent framebuffer overflows
{
// [FG] too far left
if (x < 0)
continue;
// [FG] too far right, too wide
if (x >= SCREENWIDTH)
break;
}
// step through the posts in a column
while (column->topdelta != 0xff)
{
@ -332,6 +342,20 @@ void V_DrawPatchGeneral(int x, int y, int scrn, patch_t *patch,
register byte *dest = desttop + column->topdelta*SCREENWIDTH*4;
register int count = column->length;
// [FG] prevent framebuffer overflows
{
int topy = y + column->topdelta;
// [FG] too high
while (topy < 0)
count--, source++, dest += SCREENWIDTH*4, topy++;
// [FG] too low, too tall
while (topy + count > SCREENHEIGHT)
count--;
// [FG] nothing left to draw?
if (count < 1)
break;
}
if ((count-=4)>=0)
do
{
@ -377,11 +401,21 @@ void V_DrawPatchGeneral(int x, int y, int scrn, patch_t *patch,
{
byte *desttop = screens[scrn]+y*SCREENWIDTH+x;
for ( ; col != colstop ; col += colstep, desttop++)
for ( ; col != colstop ; col += colstep, desttop++, x++)
{
const column_t *column =
(const column_t *)((byte *)patch + LONG(patch->columnofs[col]));
// [FG] prevent framebuffer overflows
{
// [FG] too far left
if (x < 0)
continue;
// [FG] too far right, too wide
if (x >= SCREENWIDTH)
break;
}
// step through the posts in a column
while (column->topdelta != 0xff)
{
@ -391,6 +425,20 @@ void V_DrawPatchGeneral(int x, int y, int scrn, patch_t *patch,
register byte *dest = desttop + column->topdelta*SCREENWIDTH;
register int count = column->length;
// [FG] prevent framebuffer overflows
{
int topy = y + column->topdelta;
// [FG] too high
while (topy < 0)
count--, source++, dest += SCREENWIDTH, topy++;
// [FG] too low, too tall
while (topy + count > SCREENHEIGHT)
count--;
// [FG] nothing left to draw?
if (count < 1)
break;
}
if ((count-=4)>=0)
do
{