mirror of
https://github.com/w23/xash3d-fwgs
synced 2024-12-15 05:29:51 +01:00
ref_gl: fix unaligned access in sprites
This commit is contained in:
parent
90e4fbed31
commit
55c3040db1
@ -53,13 +53,14 @@ upload a single frame
|
||||
*/
|
||||
static const dframetype_t *R_SpriteLoadFrame( model_t *mod, const void *pin, mspriteframe_t **ppframe, int num )
|
||||
{
|
||||
const dspriteframe_t *pinframe;
|
||||
const dspriteframe_t pinframe;
|
||||
mspriteframe_t *pspriteframe;
|
||||
int gl_texturenum = 0;
|
||||
char texname[128];
|
||||
int bytes = 1;
|
||||
|
||||
pinframe = (dspriteframe_t *)pin;
|
||||
memcpy( &pinframe, pin, sizeof(dspriteframe_t));
|
||||
|
||||
if( sprite_version == SPRITE_VERSION_32 )
|
||||
bytes = 4;
|
||||
|
||||
@ -67,26 +68,26 @@ static const dframetype_t *R_SpriteLoadFrame( model_t *mod, const void *pin, msp
|
||||
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 );
|
||||
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
|
||||
{
|
||||
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
|
||||
pspriteframe = Mem_Malloc( mod->mempool, sizeof( mspriteframe_t ));
|
||||
pspriteframe->width = pinframe->width;
|
||||
pspriteframe->height = pinframe->height;
|
||||
pspriteframe->up = pinframe->origin[1];
|
||||
pspriteframe->left = pinframe->origin[0];
|
||||
pspriteframe->down = pinframe->origin[1] - pinframe->height;
|
||||
pspriteframe->right = pinframe->width + pinframe->origin[0];
|
||||
pspriteframe->width = pinframe.width;
|
||||
pspriteframe->height = pinframe.height;
|
||||
pspriteframe->up = pinframe.origin[1];
|
||||
pspriteframe->left = pinframe.origin[0];
|
||||
pspriteframe->down = pinframe.origin[1] - pinframe.height;
|
||||
pspriteframe->right = pinframe.width + pinframe.origin[0];
|
||||
pspriteframe->gl_texturenum = gl_texturenum;
|
||||
*ppframe = pspriteframe;
|
||||
|
||||
return (dframetype_t *)((byte *)(pinframe + 1) + pinframe->width * pinframe->height * bytes );
|
||||
return ( pin + sizeof(dspriteframe_t) + pinframe.width * pinframe.height * bytes );
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user