mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-01-17 18:40:02 +00:00
ref_soft: fix unaligned access
This commit is contained in:
parent
59f053b1db
commit
4c7e19adeb
23
r_sprite.c
23
r_sprite.c
@ -53,13 +53,14 @@ upload a single frame
|
|||||||
*/
|
*/
|
||||||
static dframetype_t *R_SpriteLoadFrame( model_t *mod, void *pin, mspriteframe_t **ppframe, int num )
|
static dframetype_t *R_SpriteLoadFrame( model_t *mod, void *pin, mspriteframe_t **ppframe, int num )
|
||||||
{
|
{
|
||||||
dspriteframe_t *pinframe;
|
dspriteframe_t pinframe;
|
||||||
mspriteframe_t *pspriteframe;
|
mspriteframe_t *pspriteframe;
|
||||||
int gl_texturenum = 0;
|
int gl_texturenum = 0;
|
||||||
char texname[128];
|
char texname[128];
|
||||||
int bytes = 1;
|
int bytes = 1;
|
||||||
|
|
||||||
pinframe = (dspriteframe_t *)pin;
|
memcpy( &pinframe, pin, sizeof( dspriteframe_t ) );
|
||||||
|
|
||||||
if( sprite_version == SPRITE_VERSION_32 )
|
if( sprite_version == SPRITE_VERSION_32 )
|
||||||
bytes = 4;
|
bytes = 4;
|
||||||
|
|
||||||
@ -67,26 +68,26 @@ static dframetype_t *R_SpriteLoadFrame( model_t *mod, void *pin, mspriteframe_t
|
|||||||
if( FBitSet( mod->flags, MODEL_CLIENT )) // it's a HUD sprite
|
if( FBitSet( mod->flags, MODEL_CLIENT )) // it's a HUD sprite
|
||||||
{
|
{
|
||||||
Q_snprintf( texname, sizeof( texname ), "#HUD/%s(%s:%i%i).spr", sprite_name, group_suffix, num / 10, num % 10 );
|
Q_snprintf( texname, sizeof( texname ), "#HUD/%s(%s:%i%i).spr", sprite_name, group_suffix, num / 10, num % 10 );
|
||||||
gl_texturenum = GL_LoadTexture( texname, pin, pinframe->width * pinframe->height * bytes, r_texFlags );
|
gl_texturenum = GL_LoadTexture( texname, pin, pinframe.width * pinframe.height * bytes, r_texFlags );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Q_snprintf( texname, sizeof( texname ), "#%s(%s:%i%i).spr", sprite_name, group_suffix, num / 10, num % 10 );
|
Q_snprintf( texname, sizeof( texname ), "#%s(%s:%i%i).spr", sprite_name, group_suffix, num / 10, num % 10 );
|
||||||
gl_texturenum = GL_LoadTexture( texname, pin, pinframe->width * pinframe->height * bytes, r_texFlags );
|
gl_texturenum = GL_LoadTexture( texname, pin, pinframe.width * pinframe.height * bytes, r_texFlags );
|
||||||
}
|
}
|
||||||
|
|
||||||
// setup frame description
|
// setup frame description
|
||||||
pspriteframe = Mem_Malloc( mod->mempool, sizeof( mspriteframe_t ));
|
pspriteframe = Mem_Malloc( mod->mempool, sizeof( mspriteframe_t ));
|
||||||
pspriteframe->width = pinframe->width;
|
pspriteframe->width = pinframe.width;
|
||||||
pspriteframe->height = pinframe->height;
|
pspriteframe->height = pinframe.height;
|
||||||
pspriteframe->up = pinframe->origin[1];
|
pspriteframe->up = pinframe.origin[1];
|
||||||
pspriteframe->left = pinframe->origin[0];
|
pspriteframe->left = pinframe.origin[0];
|
||||||
pspriteframe->down = pinframe->origin[1] - pinframe->height;
|
pspriteframe->down = pinframe.origin[1] - pinframe.height;
|
||||||
pspriteframe->right = pinframe->width + pinframe->origin[0];
|
pspriteframe->right = pinframe.width + pinframe.origin[0];
|
||||||
pspriteframe->gl_texturenum = gl_texturenum;
|
pspriteframe->gl_texturenum = gl_texturenum;
|
||||||
*ppframe = pspriteframe;
|
*ppframe = pspriteframe;
|
||||||
|
|
||||||
return (dframetype_t *)((byte *)(pinframe + 1) + pinframe->width * pinframe->height * bytes );
|
return ( pin + sizeof(dspriteframe_t) + pinframe.width * pinframe.height * bytes );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user