Browse Source

engine: common: validate and load PNG images in customization

pull/2/head
Alibek Omarov 2 years ago
parent
commit
f30f23ba51
  1. 20
      engine/common/custom.c

20
engine/common/custom.c

@ -17,9 +17,21 @@ GNU General Public License for more details. @@ -17,9 +17,21 @@ GNU General Public License for more details.
#include "custom.h"
#include "ref_common.h"
qboolean CustomDecal_Validate( void *raw, int nFileSize )
static rgbdata_t *CustomDecal_LoadImage( const char *path, void *raw, int size )
{
rgbdata_t *test = FS_LoadImage( "#logo.bmp", raw, nFileSize );
const char *testname;
// this way we limit file types
if( !Q_stricmp( COM_FileExtension( path ), "png" ))
testname = "#logo.png";
else testname = "#logo.bmp";
return FS_LoadImage( testname, raw, size );
}
static qboolean CustomDecal_Validate( const char *path, void *raw, int nFileSize )
{
rgbdata_t *test = CustomDecal_LoadImage( path, raw, nFileSize );
if( test )
{
@ -97,7 +109,7 @@ qboolean COM_CreateCustomization( customization_t *pListHead, resource_t *pResou @@ -97,7 +109,7 @@ qboolean COM_CreateCustomization( customization_t *pListHead, resource_t *pResou
{
pCust->resource.playernum = playernumber;
if( CustomDecal_Validate( pCust->pBuffer, pResource->nDownloadSize ))
if( CustomDecal_Validate( pResource->szFileName, pCust->pBuffer, pResource->nDownloadSize ))
{
if( !FBitSet( flags, FCUST_IGNOREINIT ))
{
@ -108,7 +120,7 @@ qboolean COM_CreateCustomization( customization_t *pListHead, resource_t *pResou @@ -108,7 +120,7 @@ qboolean COM_CreateCustomization( customization_t *pListHead, resource_t *pResou
pCust->nUserData2 = 1;
if( !FBitSet( flags, FCUST_WIPEDATA ))
pCust->pInfo = FS_LoadImage( "#logo.bmp", pCust->pBuffer, pCust->resource.nDownloadSize );
pCust->pInfo = CustomDecal_LoadImage( pResource->szFileName, pCust->pBuffer, pCust->resource.nDownloadSize );
else pCust->pInfo = NULL;
if( nLumps ) *nLumps = 1;
}

Loading…
Cancel
Save