mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 09:11:48 +00:00
Merge branch 'fix-nopng-warnings' into 'master'
Fix warnings when NOPNG=1 See merge request STJr/SRB2Internal!432
This commit is contained in:
commit
184a754c2e
3 changed files with 30 additions and 20 deletions
|
@ -690,7 +690,9 @@ static void HWR_GenerateTexture(INT32 texnum, GLTexture_t *grtex)
|
|||
// Composite the columns together.
|
||||
for (i = 0, patch = texture->patches; i < texture->patchcount; i++, patch++)
|
||||
{
|
||||
#ifndef NO_PNG_LUMPS
|
||||
size_t lumplength = W_LumpLengthPwad(patch->wad, patch->lump);
|
||||
#endif
|
||||
realpatch = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE);
|
||||
#ifndef NO_PNG_LUMPS
|
||||
if (R_IsLumpPNG((UINT8 *)realpatch, lumplength))
|
||||
|
@ -929,9 +931,9 @@ static void HWR_LoadPatchFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum)
|
|||
{
|
||||
UINT8 *flat;
|
||||
patch_t *patch = (patch_t *)W_CacheLumpNum(flatlumpnum, PU_STATIC);
|
||||
#ifndef NO_PNG_LUMPS
|
||||
size_t lumplength = W_LumpLength(flatlumpnum);
|
||||
|
||||
#ifndef NO_PNG_LUMPS
|
||||
if (R_IsLumpPNG((UINT8 *)patch, lumplength))
|
||||
patch = R_PNGToPatch((UINT8 *)patch, lumplength, NULL, false);
|
||||
#endif
|
||||
|
|
41
src/r_data.c
41
src/r_data.c
|
@ -831,7 +831,9 @@ void R_LoadTextures(void)
|
|||
{
|
||||
UINT16 wadnum = (UINT16)w;
|
||||
lumpnum_t lumpnum = texstart + j;
|
||||
#ifndef NO_PNG_LUMPS
|
||||
size_t lumplength;
|
||||
#endif
|
||||
|
||||
if (wadfiles[w]->type == RET_PK3)
|
||||
{
|
||||
|
@ -839,8 +841,10 @@ void R_LoadTextures(void)
|
|||
continue; // If it is then SKIP IT
|
||||
}
|
||||
|
||||
lumplength = W_LumpLengthPwad(wadnum, lumpnum);
|
||||
patchlump = W_CacheLumpNumPwad(wadnum, lumpnum, PU_CACHE);
|
||||
#ifndef NO_PNG_LUMPS
|
||||
lumplength = W_LumpLengthPwad(wadnum, lumpnum);
|
||||
#endif
|
||||
|
||||
//CONS_Printf("\n\"%s\" is a single patch, dimensions %d x %d",W_CheckNameForNumPwad((UINT16)w,texstart+j),patchlump->width, patchlump->height);
|
||||
texture = textures[i] = Z_Calloc(sizeof(texture_t) + sizeof(texpatch_t), PU_STATIC, NULL);
|
||||
|
@ -2798,22 +2802,23 @@ boolean R_IsLumpPNG(const UINT8 *d, size_t s)
|
|||
|
||||
#ifdef HAVE_PNG
|
||||
|
||||
#if PNG_LIBPNG_VER_DLLNUM < 14
|
||||
/*#if PNG_LIBPNG_VER_DLLNUM < 14
|
||||
typedef PNG_CONST png_byte *png_const_bytep;
|
||||
#endif
|
||||
typedef struct {
|
||||
png_const_bytep buffer;
|
||||
png_uint_32 bufsize;
|
||||
png_uint_32 current_pos;
|
||||
#endif*/
|
||||
typedef struct
|
||||
{
|
||||
const UINT8 *buffer;
|
||||
UINT32 size;
|
||||
UINT32 position;
|
||||
} png_io_t;
|
||||
|
||||
static void PNG_IOReader(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
png_io_t *f = png_get_io_ptr(png_ptr);
|
||||
if (length > (f->bufsize - f->current_pos))
|
||||
if (length > (f->size - f->position))
|
||||
png_error(png_ptr, "PNG_IOReader: buffer overrun");
|
||||
memcpy(data, f->buffer + f->current_pos, length);
|
||||
f->current_pos += length;
|
||||
memcpy(data, f->buffer + f->position, length);
|
||||
f->position += length;
|
||||
}
|
||||
|
||||
typedef struct
|
||||
|
@ -2899,10 +2904,10 @@ static png_bytep *PNG_Read(const UINT8 *png, UINT16 *w, UINT16 *h, INT16 *topoff
|
|||
png_memcpy(png_jmpbuf(png_ptr), jmpbuf, sizeof jmp_buf);
|
||||
#endif
|
||||
|
||||
// set our own read_function
|
||||
png_io.buffer = (png_const_bytep)png;
|
||||
png_io.bufsize = size;
|
||||
png_io.current_pos = 0;
|
||||
// set our own read function
|
||||
png_io.buffer = png;
|
||||
png_io.size = size;
|
||||
png_io.position = 0;
|
||||
png_set_read_fn(png_ptr, &png_io, PNG_IOReader);
|
||||
|
||||
memset(&chunk, 0x00, sizeof(png_chunk_t));
|
||||
|
@ -3069,10 +3074,10 @@ boolean R_PNGDimensions(UINT8 *png, INT16 *width, INT16 *height, size_t size)
|
|||
png_memcpy(png_jmpbuf(png_ptr), jmpbuf, sizeof jmp_buf);
|
||||
#endif
|
||||
|
||||
// set our own read_function
|
||||
png_io.buffer = (png_bytep)png;
|
||||
png_io.bufsize = size;
|
||||
png_io.current_pos = 0;
|
||||
// set our own read function
|
||||
png_io.buffer = png;
|
||||
png_io.size = size;
|
||||
png_io.position = 0;
|
||||
png_set_read_fn(png_ptr, &png_io, PNG_IOReader);
|
||||
|
||||
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||
|
|
|
@ -1531,7 +1531,10 @@ void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag)
|
|||
if (!lumpcache[lump])
|
||||
{
|
||||
size_t len = W_LumpLengthPwad(wad, lump);
|
||||
void *ptr, *lumpdata, *srcdata = NULL;
|
||||
void *ptr, *lumpdata;
|
||||
#ifndef NO_PNG_LUMPS
|
||||
void *srcdata = NULL;
|
||||
#endif
|
||||
|
||||
ptr = Z_Malloc(len, tag, &lumpcache[lump]);
|
||||
lumpdata = Z_Malloc(len, tag, NULL);
|
||||
|
|
Loading…
Reference in a new issue