Fix build warnings

This commit is contained in:
Lactozilla 2024-01-16 14:34:38 -03:00
parent 70d8c66637
commit e73f33a677
4 changed files with 43 additions and 22 deletions

View file

@ -958,7 +958,6 @@ static int PNG_ChunkReader(png_structp png_ptr, png_unknown_chunkp chonk)
static void PNG_error(png_structp PNG, png_const_charp pngtext)
{
CONS_Debug(DBG_RENDER, "libpng error at %p: %s", PNG, pngtext);
//I_Error("libpng error at %p: %s", PNG, pngtext);
}
static void PNG_warn(png_structp PNG, png_const_charp pngtext)
@ -1025,7 +1024,7 @@ static png_bytep *PNG_Read(
png_set_read_fn(png_ptr, &png_io, PNG_IOReader);
memset(&chunk, 0x00, sizeof(png_chunk_t));
chunkname = grAb_chunk; // I want to read a grAb chunk
chunkname = grAb_chunk;
user_chunk_ptr = png_get_user_chunk_ptr(png_ptr);
png_set_read_user_chunk_fn(png_ptr, user_chunk_ptr, PNG_ChunkReader);
@ -1410,13 +1409,17 @@ boolean Picture_PNGDimensions(UINT8 *png, INT32 *width, INT32 *height, INT16 *to
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, PNG_error, PNG_warn);
if (!png_ptr)
I_Error("Picture_PNGDimensions: Couldn't initialize libpng!");
{
CONS_Alert(CONS_ERROR, "Picture_PNGDimensions: Couldn't initialize libpng!\n");
return false;
}
png_info_ptr = png_create_info_struct(png_ptr);
if (!png_info_ptr)
{
png_destroy_read_struct(&png_ptr, NULL, NULL);
I_Error("Picture_PNGDimensions: libpng couldn't allocate memory!");
CONS_Alert(CONS_ERROR, "Picture_PNGDimensions: libpng couldn't allocate memory!\n");
return false;
}
#ifdef USE_FAR_KEYWORD
@ -1426,7 +1429,8 @@ boolean Picture_PNGDimensions(UINT8 *png, INT32 *width, INT32 *height, INT16 *to
#endif
{
png_destroy_read_struct(&png_ptr, &png_info_ptr, NULL);
I_Error("Picture_PNGDimensions: libpng load error!");
CONS_Alert(CONS_ERROR, "Picture_PNGDimensions: libpng load error!\n");
return false;
}
#ifdef USE_FAR_KEYWORD
png_memcpy(png_jmpbuf(png_ptr), jmpbuf, sizeof jmp_buf);
@ -1438,7 +1442,7 @@ boolean Picture_PNGDimensions(UINT8 *png, INT32 *width, INT32 *height, INT16 *to
png_set_read_fn(png_ptr, &png_io, PNG_IOReader);
memset(&chunk, 0x00, sizeof(png_chunk_t));
chunkname = grAb_chunk; // I want to read a grAb chunk
chunkname = grAb_chunk;
user_chunk_ptr = png_get_user_chunk_ptr(png_ptr);
png_set_read_user_chunk_fn(png_ptr, user_chunk_ptr, PNG_ChunkReader);

View file

@ -176,13 +176,12 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
R_CheckTextureCache(texnum);
if (textures[texnum]->flip & 2) // vertically flipped?
{
colfunc_2s = R_DrawFlippedMaskedColumn;
lengthcol = textures[texnum]->height;
}
else
colfunc_2s = R_DrawMaskedColumn; // render the usual 2sided single-patch packed texture
lengthcol = textures[texnum]->height;
// Setup lighting based on the presence/lack-of 3D floors.
dc_numlights = 0;
if (frontsector->numlights)
@ -740,13 +739,12 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
R_CheckTextureCache(texnum);
if (textures[texnum]->flip & 2) // vertically flipped?
{
colfunc_2s = R_DrawRepeatFlippedMaskedColumn;
lengthcol = textures[texnum]->height;
}
else
colfunc_2s = R_DrawRepeatMaskedColumn; // render the usual 2sided single-patch packed texture
lengthcol = textures[texnum]->height;
// Set heights according to plane, or slope, whichever
{
fixed_t right_top, right_bottom;

View file

@ -816,9 +816,16 @@ Rloadflats (INT32 i, INT32 w)
{
INT32 texw, texh;
UINT8 *flatlump = W_CacheLumpNumPwad(wadnum, lumpnum, PU_CACHE);
Picture_PNGDimensions((UINT8 *)flatlump, &texw, &texh, NULL, NULL, lumplength);
width = (INT16)width;
height = (INT16)height;
if (Picture_PNGDimensions((UINT8 *)flatlump, &texw, &texh, NULL, NULL, lumplength))
{
width = (INT16)width;
height = (INT16)height;
}
else
{
width = 1;
height = 1;
}
Z_Free(flatlump);
}
#endif
@ -891,16 +898,23 @@ Rloadtextures (INT32 i, INT32 w)
lumplength = W_LumpLengthPwad(wadnum, lumpnum);
#endif
INT16 width, height;
INT16 width = 0, height = 0;
#ifndef NO_PNG_LUMPS
if (Picture_IsLumpPNG((UINT8 *)&patchlump, lumplength))
{
INT32 texw, texh;
UINT8 *png = W_CacheLumpNumPwad(wadnum, lumpnum, PU_CACHE);
Picture_PNGDimensions(png, &texw, &texh, NULL, NULL, lumplength);
width = (INT16)width;
height = (INT16)height;
if (Picture_PNGDimensions(png, &texw, &texh, NULL, NULL, lumplength))
{
width = (INT16)width;
height = (INT16)height;
}
else
{
width = 1;
height = 1;
}
Z_Free(png);
}
else

View file

@ -308,12 +308,17 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16
#ifndef NO_PNG_LUMPS
{
softwarepatch_t *png = W_CacheLumpNumPwad(wadnum, l, PU_STATIC);
UINT8 *png = W_CacheLumpNumPwad(wadnum, l, PU_STATIC);
size_t len = W_LumpLengthPwad(wadnum, l);
if (Picture_IsLumpPNG((UINT8 *)png, len))
if (Picture_IsLumpPNG(png, len))
{
Picture_PNGDimensions((UINT8 *)png, &width, &height, &topoffset, &leftoffset, len);
if (!Picture_PNGDimensions(png, &width, &height, &topoffset, &leftoffset, len))
{
Z_Free(png);
continue;
}
isPNG = true;
}