mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-01-29 16:24:16 +00:00
engine: common: validate and load PNG images in customization
This commit is contained in:
parent
1ba117a8e9
commit
f30f23ba51
@ -17,9 +17,21 @@ GNU General Public License for more details.
|
|||||||
#include "custom.h"
|
#include "custom.h"
|
||||||
#include "ref_common.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 )
|
if( test )
|
||||||
{
|
{
|
||||||
@ -97,7 +109,7 @@ qboolean COM_CreateCustomization( customization_t *pListHead, resource_t *pResou
|
|||||||
{
|
{
|
||||||
pCust->resource.playernum = playernumber;
|
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 ))
|
if( !FBitSet( flags, FCUST_IGNOREINIT ))
|
||||||
{
|
{
|
||||||
@ -108,7 +120,7 @@ qboolean COM_CreateCustomization( customization_t *pListHead, resource_t *pResou
|
|||||||
pCust->nUserData2 = 1;
|
pCust->nUserData2 = 1;
|
||||||
|
|
||||||
if( !FBitSet( flags, FCUST_WIPEDATA ))
|
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;
|
else pCust->pInfo = NULL;
|
||||||
if( nLumps ) *nLumps = 1;
|
if( nLumps ) *nLumps = 1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user