mirror of
https://github.com/fabiangreffrath/woof.git
synced 2025-09-22 11:22:18 -04:00
bring implementation of V_DrawPatchTranslated into line with V_DrawPatchGeneral (#519)
* bring implementation of V_DrawPatchTranslated into line with V_DrawPatchGeneral * add missed overflow checks
This commit is contained in:
parent
a53db1906c
commit
ad6684b7c0
@ -553,7 +553,7 @@ void V_DrawPatchTranslated(int x, int y, int scrn, patch_t *patch,
|
||||
|
||||
x += WIDESCREENDELTA; // [crispy] horizontal widescreen offset
|
||||
|
||||
#ifdef RANGECHECK
|
||||
#ifdef RANGECHECK_NOTHANKS
|
||||
if (x<0
|
||||
||x+SHORT(patch->width) >SCREENWIDTH
|
||||
|| y<0
|
||||
@ -577,6 +577,16 @@ void V_DrawPatchTranslated(int x, int y, int scrn, patch_t *patch,
|
||||
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)
|
||||
{
|
||||
@ -586,6 +596,17 @@ void V_DrawPatchTranslated(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)
|
||||
count--, source++, dest += SCREENWIDTH*4, topy++;
|
||||
// [FG] too low, too tall
|
||||
while (topy + count > SCREENHEIGHT && count)
|
||||
count--;
|
||||
}
|
||||
|
||||
if ((count-=4)>=0)
|
||||
do
|
||||
{
|
||||
@ -627,7 +648,9 @@ void V_DrawPatchTranslated(int x, int y, int scrn, patch_t *patch,
|
||||
dest += SCREENWIDTH*4;
|
||||
}
|
||||
while (--count);
|
||||
column = (column_t *)(source+1);
|
||||
// column = (column_t *)(source+1);
|
||||
// [FG] back to Vanilla code, we may not run through the entire column
|
||||
column = (column_t *)((byte *)column + column->length + 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -640,6 +663,16 @@ void V_DrawPatchTranslated(int x, int y, int scrn, patch_t *patch,
|
||||
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)
|
||||
{
|
||||
@ -649,6 +682,17 @@ void V_DrawPatchTranslated(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)
|
||||
count--, source++, dest += SCREENWIDTH, topy++;
|
||||
// [FG] too low, too tall
|
||||
while (topy + count > SCREENHEIGHT && count)
|
||||
count--;
|
||||
}
|
||||
|
||||
if ((count-=4)>=0)
|
||||
do
|
||||
{
|
||||
@ -681,7 +725,9 @@ void V_DrawPatchTranslated(int x, int y, int scrn, patch_t *patch,
|
||||
dest += SCREENWIDTH;
|
||||
}
|
||||
while (--count);
|
||||
column = (column_t *)(source+1);
|
||||
// column = (column_t *)(source+1);
|
||||
// [FG] back to Vanilla code, we may not run through the entire column
|
||||
column = (column_t *)((byte *)column + column->length + 4);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user