mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-01-18 02:50:33 +00:00
imagelib: fix unaligned access
This commit is contained in:
parent
68472f90eb
commit
4021d7bf5c
@ -199,8 +199,9 @@ Image_LoadSPR
|
|||||||
*/
|
*/
|
||||||
qboolean Image_LoadSPR( const char *name, const byte *buffer, fs_offset_t filesize )
|
qboolean Image_LoadSPR( const char *name, const byte *buffer, fs_offset_t filesize )
|
||||||
{
|
{
|
||||||
dspriteframe_t *pin; // identical for q1\hl sprites
|
dspriteframe_t pin; // identical for q1\hl sprites
|
||||||
qboolean truecolor = false;
|
qboolean truecolor = false;
|
||||||
|
byte *fin;
|
||||||
|
|
||||||
if( image.hint == IL_HINT_HL )
|
if( image.hint == IL_HINT_HL )
|
||||||
{
|
{
|
||||||
@ -217,9 +218,9 @@ qboolean Image_LoadSPR( const char *name, const byte *buffer, fs_offset_t filesi
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pin = (dspriteframe_t *)buffer;
|
memcpy( &pin, buffer, sizeof(dspriteframe_t) );
|
||||||
image.width = pin->width;
|
image.width = pin.width;
|
||||||
image.height = pin->height;
|
image.height = pin.height;
|
||||||
|
|
||||||
if( filesize < image.width * image.height )
|
if( filesize < image.width * image.height )
|
||||||
return false;
|
return false;
|
||||||
@ -244,17 +245,18 @@ qboolean Image_LoadSPR( const char *name, const byte *buffer, fs_offset_t filesi
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fin = (byte *)(buffer + sizeof(dspriteframe_t));
|
||||||
|
|
||||||
if( truecolor )
|
if( truecolor )
|
||||||
{
|
{
|
||||||
// spr32 support
|
// spr32 support
|
||||||
image.size = image.width * image.height * 4;
|
image.size = image.width * image.height * 4;
|
||||||
image.rgba = Mem_Malloc( host.imagepool, image.size );
|
image.rgba = Mem_Malloc( host.imagepool, image.size );
|
||||||
memcpy( image.rgba, (byte *)(pin + 1), image.size );
|
memcpy( image.rgba, fin, image.size );
|
||||||
SetBits( image.flags, IMAGE_HAS_COLOR ); // Color. True Color!
|
SetBits( image.flags, IMAGE_HAS_COLOR ); // Color. True Color!
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
return Image_AddIndexedImageToPack( fin, image.width, image.height );
|
||||||
return Image_AddIndexedImageToPack( (byte *)(pin + 1), image.width, image.height );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user