Fix warnings
This commit is contained in:
parent
35d6da159d
commit
869f1e4e8d
|
@ -580,9 +580,10 @@ static void HWR_RenderPlane(sector_t *sector, extrasubsector_t *xsub, boolean is
|
||||||
if (nrPlaneVerts < 3) //not even a triangle ?
|
if (nrPlaneVerts < 3) //not even a triangle ?
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (nrPlaneVerts > UINT16_MAX) // FIXME: exceeds plVerts size
|
// This check is so inconsistent between functions, it hurts.
|
||||||
|
if (nrPlaneVerts > INT16_MAX) // FIXME: exceeds plVerts size
|
||||||
{
|
{
|
||||||
CONS_Debug(DBG_RENDER, "polygon size of %d exceeds max value of %d vertices\n", nrPlaneVerts, UINT16_MAX);
|
CONS_Debug(DBG_RENDER, "polygon size of %d exceeds max value of %d vertices\n", nrPlaneVerts, INT16_MAX);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ typedef struct
|
||||||
UINT8 *flatpatch;
|
UINT8 *flatpatch;
|
||||||
UINT16 width, height;
|
UINT16 width, height;
|
||||||
fixed_t topoffset, leftoffset;
|
fixed_t topoffset, leftoffset;
|
||||||
size_t texturenum;
|
INT32 texturenum;
|
||||||
|
|
||||||
#ifdef ESLOPE
|
#ifdef ESLOPE
|
||||||
UINT8 *resizedflat;
|
UINT8 *resizedflat;
|
||||||
|
|
37
src/r_data.c
37
src/r_data.c
|
@ -1656,7 +1656,7 @@ boolean R_CheckIfPatch(lumpnum_t lump)
|
||||||
width = SHORT(patch->width);
|
width = SHORT(patch->width);
|
||||||
height = SHORT(patch->height);
|
height = SHORT(patch->height);
|
||||||
|
|
||||||
result = (height > 0 && height <= 16384 && width > 0 && width <= 16384 && width < size / 4);
|
result = (height > 0 && height <= 16384 && width > 0 && width <= 16384 && width < (INT16)(size / 4));
|
||||||
|
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
|
@ -1769,10 +1769,35 @@ void R_FlatTexture(size_t tex, UINT8 *flat)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void R_CropFlat(UINT8 *origflat, UINT8 *cropflat, UINT16 origwidth, UINT16 origheight, UINT16 cropwidth, UINT16 cropheight)
|
void R_CropFlat(UINT8 *srcflat, UINT8 *destflat,
|
||||||
|
UINT16 srcwidth, UINT16 srcheight,
|
||||||
|
UINT16 resizewidth, UINT16 resizeheight,
|
||||||
|
UINT16 destwidth, UINT16 destheight)
|
||||||
{
|
{
|
||||||
UINT16 x, y;
|
UINT16 y;
|
||||||
for (y = 0; y < cropheight; y++)
|
UINT16 position = 0;
|
||||||
for (x = 0; x < cropwidth; x++)
|
for (y = 0; y < destheight; y++)
|
||||||
cropflat[(y * cropwidth) + x] = origflat[(y * origwidth) + x];
|
{
|
||||||
|
if (position > (srcwidth * srcheight))
|
||||||
|
break;
|
||||||
|
if (srcwidth != resizewidth)
|
||||||
|
{
|
||||||
|
if (resizewidth > srcwidth)
|
||||||
|
{
|
||||||
|
UINT8 *pos2 = srcflat+position;
|
||||||
|
UINT8 lastpixel = *(pos2-1);
|
||||||
|
M_Memcpy(destflat, srcflat+position, destwidth);
|
||||||
|
memset(pos2, lastpixel, resizewidth-srcwidth);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
M_Memcpy(destflat, srcflat+position, resizewidth);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
M_Memcpy(destflat, srcflat+position, destwidth);
|
||||||
|
destflat += destwidth;
|
||||||
|
position += srcwidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (y++ < min(resizeheight, srcheight))
|
||||||
|
memset(destflat + (y * destwidth), *(destflat - 1), destwidth);
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,10 @@ boolean R_CheckIfPatch(lumpnum_t lump);
|
||||||
// Lactozilla
|
// Lactozilla
|
||||||
void R_FlatPatch(patch_t *patch, UINT8 *flat);
|
void R_FlatPatch(patch_t *patch, UINT8 *flat);
|
||||||
void R_FlatTexture(size_t tex, UINT8 *flat);
|
void R_FlatTexture(size_t tex, UINT8 *flat);
|
||||||
void R_CropFlat(UINT8 *origflat, UINT8 *cropflat, UINT16 origwidth, UINT16 origheight, UINT16 cropwidth, UINT16 cropheight);
|
void R_CropFlat(UINT8 *srcflat, UINT8 *destflat,
|
||||||
|
UINT16 srcwidth, UINT16 srcheight,
|
||||||
|
UINT16 resizewidth, UINT16 resizeheight,
|
||||||
|
UINT16 destwidth, UINT16 destheight);
|
||||||
|
|
||||||
extern INT32 numtextures;
|
extern INT32 numtextures;
|
||||||
|
|
||||||
|
|
|
@ -662,6 +662,7 @@ static void R_GetPatchFlat(levelflat_t *levelflat, boolean leveltexture)
|
||||||
{
|
{
|
||||||
#ifdef ESLOPE
|
#ifdef ESLOPE
|
||||||
INT32 resizewidth, resizeheight, newresize;
|
INT32 resizewidth, resizeheight, newresize;
|
||||||
|
INT32 checkresizewidth, checkresizeheight;
|
||||||
#endif // ESLOPE
|
#endif // ESLOPE
|
||||||
|
|
||||||
if (!leveltexture)
|
if (!leveltexture)
|
||||||
|
@ -700,21 +701,48 @@ static void R_GetPatchFlat(levelflat_t *levelflat, boolean leveltexture)
|
||||||
resizewidth <<= 1;
|
resizewidth <<= 1;
|
||||||
while (resizeheight < levelflat->height)
|
while (resizeheight < levelflat->height)
|
||||||
resizeheight <<= 1;
|
resizeheight <<= 1;
|
||||||
|
|
||||||
// Scale down to fit in 2048x2048
|
// Scale down to fit in 2048x2048
|
||||||
if (resizewidth > 2048)
|
if (resizewidth > 2048)
|
||||||
resizewidth = 2048;
|
resizewidth = 2048;
|
||||||
if (resizeheight > 2048)
|
if (resizeheight > 2048)
|
||||||
resizeheight = 2048;
|
resizeheight = 2048;
|
||||||
// Then scale down to fit the actual flat dimensions
|
|
||||||
while (resizewidth > levelflat->width)
|
// A single pixel difference is negligible.
|
||||||
resizewidth >>= 1;
|
checkresizewidth = levelflat->width - 1;
|
||||||
while (resizeheight > levelflat->height)
|
if (checkresizewidth & (checkresizewidth - 1))
|
||||||
resizeheight >>= 1;
|
{
|
||||||
|
checkresizewidth += 2;
|
||||||
|
if (checkresizewidth & (checkresizewidth - 1))
|
||||||
|
{
|
||||||
|
while (resizewidth > levelflat->width)
|
||||||
|
resizewidth >>= 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
resizewidth = checkresizewidth;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
resizewidth = checkresizewidth;
|
||||||
|
|
||||||
|
checkresizeheight = levelflat->height - 1;
|
||||||
|
if (checkresizeheight & (checkresizeheight - 1))
|
||||||
|
{
|
||||||
|
checkresizeheight += 2;
|
||||||
|
if (checkresizeheight & (checkresizeheight - 1))
|
||||||
|
{
|
||||||
|
while (resizeheight > levelflat->height)
|
||||||
|
resizeheight >>= 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
resizeheight = checkresizeheight;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
resizeheight = checkresizeheight;
|
||||||
|
|
||||||
levelflat->resizedwidth = levelflat->resizedheight = (newresize = min(resizewidth, resizeheight));
|
levelflat->resizedwidth = levelflat->resizedheight = (newresize = min(resizewidth, resizeheight));
|
||||||
levelflat->resizedflat = Z_Malloc(newresize * newresize, PU_LEVEL, NULL);
|
levelflat->resizedflat = Z_Malloc(newresize * newresize, PU_LEVEL, NULL);
|
||||||
memset(levelflat->resizedflat, TRANSPARENTPIXEL, newresize * newresize);
|
memset(levelflat->resizedflat, TRANSPARENTPIXEL, newresize * newresize);
|
||||||
R_CropFlat(levelflat->flatpatch, levelflat->resizedflat, levelflat->width, levelflat->height, newresize, newresize);
|
R_CropFlat(levelflat->flatpatch, levelflat->resizedflat, levelflat->width, levelflat->height, min(resizewidth, newresize), min(resizeheight, newresize), newresize, newresize);
|
||||||
#endif // ESLOPE
|
#endif // ESLOPE
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue