* make pie_PNGLoadMem play nice and take the buffer size as an argument rather than assuming it to be 10000000 (10 million)
* do the same with pie_ReloadTexPage which calls pie_PNGLoadMem * char* -> const char* in tex.c * fix a syntax error from r1481 git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@1482 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
dcf4cb3263
commit
7356aa1b9a
|
@ -51,7 +51,7 @@ static inline void PNGCleanup(png_infop *info_ptr, png_structp *png_ptr)
|
|||
png_destroy_read_struct(png_ptr, NULL, NULL);
|
||||
}
|
||||
|
||||
BOOL pie_PNGLoadMem(const char *pngimage, iTexture *s)
|
||||
BOOL pie_PNGLoadMem(const char *inputBuffer, size_t bufferSize, iTexture *s)
|
||||
{
|
||||
unsigned int PNG_BYTES_TO_CHECK=4;
|
||||
png_structp png_ptr = NULL;
|
||||
|
@ -59,11 +59,11 @@ BOOL pie_PNGLoadMem(const char *pngimage, iTexture *s)
|
|||
|
||||
wzpng_io_buf buf;
|
||||
|
||||
assert(pngimage != NULL);
|
||||
buf.buffer = pngimage;
|
||||
buf.length = 10000000;
|
||||
assert(inputBuffer != NULL);
|
||||
buf.buffer = inputBuffer;
|
||||
buf.length = bufferSize;
|
||||
|
||||
if (png_sig_cmp((png_byte*)pngimage, (png_size_t)0, PNG_BYTES_TO_CHECK)) {
|
||||
if (png_sig_cmp((png_byte*)inputBuffer, (png_size_t)0, PNG_BYTES_TO_CHECK)) {
|
||||
debug(LOG_3D, "pie_PNGLoadMem: Did not recognize PNG header in buffer");
|
||||
PNGCleanup(&info_ptr, &png_ptr);
|
||||
return FALSE;
|
||||
|
|
|
@ -183,11 +183,12 @@ extern void SetBSPCameraPos(SDWORD x,SDWORD y,SDWORD z);
|
|||
/*!
|
||||
* Load a PNG from buffer pngimage into sprite
|
||||
*
|
||||
* \param pngimage Buffer to load from
|
||||
* \param inputBuffer Buffer to load from
|
||||
* \param bufferSize size of buffer
|
||||
* \param sprite Sprite to read into
|
||||
* \return TRUE on success, FALSE otherwise
|
||||
*/
|
||||
BOOL pie_PNGLoadMem(const char *pngimage, iTexture *sprite);
|
||||
BOOL pie_PNGLoadMem(const char *inputBuffer, size_t bufferSize, iTexture *sprite);
|
||||
|
||||
void SetBSPObjectRot(SDWORD Yaw, SDWORD Pitch);
|
||||
|
||||
|
|
|
@ -56,8 +56,8 @@ extern iTexPage _TEX_PAGE[iV_TEX_MAX];
|
|||
|
||||
//*************************************************************************
|
||||
|
||||
int iV_GetTexture(char *filename);
|
||||
extern int pie_ReloadTexPage(char *filename, char *pBuffer);
|
||||
extern int iV_GetTexture(const char *filename);
|
||||
extern int pie_ReloadTexPage(const char *filename, const char *pBuffer, size_t bufferSize);
|
||||
extern int pie_AddBMPtoTexPages(iTexture* s, const char *filename, int type, BOOL bResource);
|
||||
void pie_ChangeTexPage(int tex_index, iTexture* s, int type, BOOL bResource);
|
||||
extern void pie_TexInit(void);
|
||||
|
|
|
@ -455,9 +455,9 @@ void screen_SetBackDropFromFile(const char* filename)
|
|||
{
|
||||
iTexture imagePNG;
|
||||
char * buffer = NULL;
|
||||
unsigned int dummy = 0;
|
||||
unsigned int bufferSize = 0;
|
||||
|
||||
if (loadFile( filename, &buffer, &dummy ) && pie_PNGLoadMem( buffer, &imagePNG ) )
|
||||
if (loadFile( filename, &buffer, &bufferSize ) && pie_PNGLoadMem( buffer, bufferSize, &imagePNG ) )
|
||||
{
|
||||
if (~backDropTexture == 0)
|
||||
glGenTextures(1, &backDropTexture);
|
||||
|
@ -678,7 +678,7 @@ void screenDumpToDisk(const char* path) {
|
|||
}
|
||||
}
|
||||
|
||||
ASSERT( screendump_num != 0, "screenDumpToDisk: integer overflow; no more filenumbers available.\n", );
|
||||
ASSERT( screendump_num != 0, "screenDumpToDisk: integer overflow; no more filenumbers available.\n" );
|
||||
|
||||
// If we have an integer overflow, we don't want to go about and overwrite files
|
||||
if (screendump_num != 0)
|
||||
|
|
|
@ -155,7 +155,7 @@ void pie_ChangeTexPage(int tex_index, iTexture* s, int type, BOOL bResource)
|
|||
textures in a separate data structure _TEX_PAGE apart from the
|
||||
normal resource system.
|
||||
**************************************************************************/
|
||||
int iV_GetTexture(char *filename)
|
||||
int iV_GetTexture(const char *filename)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
|
@ -181,7 +181,7 @@ int iV_GetTexture(char *filename)
|
|||
return -1;
|
||||
}
|
||||
|
||||
int pie_ReloadTexPage(char *filename, char *pBuffer)
|
||||
int pie_ReloadTexPage(const char *filename, const char *pBuffer, size_t bufferSize)
|
||||
{
|
||||
int i = iV_GetTexture(filename);
|
||||
|
||||
|
@ -195,7 +195,7 @@ int pie_ReloadTexPage(char *filename, char *pBuffer)
|
|||
{
|
||||
free(_TEX_PAGE[i].tex.bmp);
|
||||
}
|
||||
pie_PNGLoadMem(pBuffer, &_TEX_PAGE[i].tex);
|
||||
pie_PNGLoadMem(pBuffer, bufferSize, &_TEX_PAGE[i].tex);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
|
10
src/data.c
10
src/data.c
|
@ -746,7 +746,7 @@ BOOL dataIMGPAGELoad(char *pBuffer, UDWORD size, void **ppData)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (!pie_PNGLoadMem(pBuffer, psSprite))
|
||||
if (!pie_PNGLoadMem(pBuffer, size, psSprite))
|
||||
{
|
||||
debug( LOG_ERROR, "IMGPAGE load failed" );
|
||||
return FALSE;
|
||||
|
@ -771,7 +771,7 @@ static BOOL dataHWTERTILESLoad(char *pBuffer, UDWORD size, void **ppData)
|
|||
if (bTilesPCXLoaded)
|
||||
{
|
||||
debug( LOG_TEXTURE, "Reloading terrain tiles\n" );
|
||||
if(!pie_PNGLoadMem(pBuffer,&tilesPCX))
|
||||
if(!pie_PNGLoadMem(pBuffer, size, &tilesPCX))
|
||||
{
|
||||
debug( LOG_ERROR, "HWTERTILES reload failed" );
|
||||
return FALSE;
|
||||
|
@ -780,7 +780,7 @@ static BOOL dataHWTERTILESLoad(char *pBuffer, UDWORD size, void **ppData)
|
|||
else
|
||||
{
|
||||
debug( LOG_TEXTURE, "Loading terrain tiles\n" );
|
||||
if(!pie_PNGLoadMem(pBuffer,&tilesPCX))
|
||||
if(!pie_PNGLoadMem(pBuffer, size, &tilesPCX))
|
||||
{
|
||||
debug( LOG_ERROR, "HWTERTILES load failed" );
|
||||
return FALSE;
|
||||
|
@ -881,7 +881,7 @@ static BOOL bufferTexPageLoad(char *pBuffer, UDWORD size, void **ppData)
|
|||
{
|
||||
// replace the old texture page with the new one
|
||||
debug(LOG_TEXTURE, "bufferTexPageLoad: replacing %s with new texture %s", texpage, texfile);
|
||||
id = pie_ReloadTexPage(texpage, pBuffer);
|
||||
id = pie_ReloadTexPage(texpage, pBuffer, size);
|
||||
ASSERT( id >=0, "pie_ReloadTexPage failed" );
|
||||
*ppData = NULL;
|
||||
}
|
||||
|
@ -908,7 +908,7 @@ static BOOL bufferTexPageLoad(char *pBuffer, UDWORD size, void **ppData)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (!pie_PNGLoadMem(pBuffer, psSprite))
|
||||
if (!pie_PNGLoadMem(pBuffer, size, psSprite))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue