2
0
mirror of https://github.com/FWGS/xash3d-fwgs synced 2024-11-17 15:39:05 +01:00

ref_api: fix remap info allocation (fixes #200)

This commit is contained in:
Velaron 2021-05-02 19:53:26 +03:00 committed by Alibek Omarov #SupportRMS
parent 585955eb19
commit 4f31d7504a
6 changed files with 21 additions and 21 deletions

View File

@ -98,7 +98,7 @@ CL_DuplicateTexture
Dupliacte texture with remap pixels
====================
*/
void CL_DuplicateTexture( cl_entity_t *entity, mstudiotexture_t *ptexture, int topcolor, int bottomcolor )
void CL_DuplicateTexture( cl_entity_t *entity, model_t *model, mstudiotexture_t *ptexture, int topcolor, int bottomcolor )
{
const char *name;
texture_t *tx = NULL;
@ -114,9 +114,9 @@ void CL_DuplicateTexture( cl_entity_t *entity, mstudiotexture_t *ptexture, int t
Q_snprintf( texname, sizeof( texname ), "#%i_%s", entity->curstate.number, name + 1 );
// search for pixels
for( i = 0; i < entity->model->numtextures; i++ )
for( i = 0; i < model->numtextures; i++ )
{
tx = entity->model->textures[i];
tx = model->textures[i];
if( tx->gl_texturenum == index )
break; // found
}
@ -242,7 +242,7 @@ Allocate new remap info per entity
and make copy of remap textures
====================
*/
void CL_AllocRemapInfo( cl_entity_t *entity, int topcolor, int bottomcolor )
void CL_AllocRemapInfo( cl_entity_t *entity, model_t *model, int topcolor, int bottomcolor )
{
remap_info_t *info;
studiohdr_t *phdr;
@ -253,7 +253,7 @@ void CL_AllocRemapInfo( cl_entity_t *entity, int topcolor, int bottomcolor )
if( !entity ) return;
i = ( entity == &clgame.viewent ) ? clgame.maxEntities : entity->curstate.number;
if( !entity->model || ( entity->model->type != mod_alias && entity->model->type != mod_studio ))
if( !model || ( model->type != mod_alias && model->type != mod_studio ))
{
// entity has changed model by another type, release remap info
if( clgame.remap_info[i] )
@ -265,7 +265,7 @@ void CL_AllocRemapInfo( cl_entity_t *entity, int topcolor, int bottomcolor )
}
// model doesn't contains remap textures
if( entity->model->numtextures <= 0 )
if( model->numtextures <= 0 )
{
// entity has changed model with no remap textures
if( clgame.remap_info[i] )
@ -276,16 +276,16 @@ void CL_AllocRemapInfo( cl_entity_t *entity, int topcolor, int bottomcolor )
return;
}
if( entity->model->type == mod_studio )
if( model->type == mod_studio )
{
phdr = (studiohdr_t *)Mod_StudioExtradata( entity->model );
phdr = (studiohdr_t *)Mod_StudioExtradata( model );
if( !phdr ) return; // bad model?
src = (mstudiotexture_t *)(((byte *)phdr) + phdr->textureindex);
dst = (clgame.remap_info[i] ? clgame.remap_info[i]->ptexture : NULL);
// NOTE: we must copy all the structures 'mstudiotexture_t' for easy access when model is rendering
if( !CL_CmpStudioTextures( phdr->numtextures, src, dst ) || clgame.remap_info[i]->model != entity->model )
if( !CL_CmpStudioTextures( phdr->numtextures, src, dst ) || clgame.remap_info[i]->model != model )
{
// this code catches studiomodel change with another studiomodel with remap textures
// e.g. playermodel 'barney' with playermodel 'gordon'
@ -314,16 +314,16 @@ void CL_AllocRemapInfo( cl_entity_t *entity, int topcolor, int bottomcolor )
for( i = 0; i < info->numtextures; i++ )
{
if( dst[i].flags & STUDIO_NF_COLORMAP )
CL_DuplicateTexture( entity, &dst[i], topcolor, bottomcolor );
CL_DuplicateTexture( entity, model, &dst[i], topcolor, bottomcolor );
}
}
else if( entity->model->type == mod_alias )
else if( model->type == mod_alias )
{
ahdr = (aliashdr_t *)Mod_AliasExtradata( entity->model );
ahdr = (aliashdr_t *)Mod_AliasExtradata( model );
if( !ahdr ) return; // bad model?
// NOTE: we must copy all the structures 'mstudiotexture_t' for easy access when model is rendering
if( !clgame.remap_info[i] || clgame.remap_info[i]->model != entity->model )
if( !clgame.remap_info[i] || clgame.remap_info[i]->model != model )
{
// this code catches studiomodel change with another studiomodel with remap textures
// e.g. playermodel 'barney' with playermodel 'gordon'
@ -336,7 +336,7 @@ void CL_AllocRemapInfo( cl_entity_t *entity, int topcolor, int bottomcolor )
return;
}
info->numtextures = entity->model->numtextures;
info->numtextures = model->numtextures;
// alias remapping is easy
CL_UpdateRemapInfo( entity, topcolor, bottomcolor );
@ -347,7 +347,7 @@ void CL_AllocRemapInfo( cl_entity_t *entity, int topcolor, int bottomcolor )
return;
}
info->model = entity->model;
info->model = model;
}
/*

View File

@ -953,7 +953,7 @@ void CL_EmitEntities( void );
// cl_remap.c
//
remap_info_t *CL_GetRemapInfoForEntity( cl_entity_t *e );
void CL_AllocRemapInfo( cl_entity_t *ent, int topcolor, int bottomcolor );
void CL_AllocRemapInfo( cl_entity_t *entity, model_t *model, int topcolor, int bottomcolor );
void CL_FreeRemapInfo( remap_info_t *info );
void CL_UpdateRemapInfo( cl_entity_t *ent, int topcolor, int bottomcolor );
void CL_ClearAllRemaps( void );

View File

@ -329,9 +329,9 @@ typedef struct ref_api_s
// remap
struct remap_info_s *(*CL_GetRemapInfoForEntity)( cl_entity_t *e );
void (*CL_AllocRemapInfo)( cl_entity_t *ent, int topcolor, int bottomcolor );
void (*CL_AllocRemapInfo)( cl_entity_t *entity, model_t *model, int topcolor, int bottomcolor );
void (*CL_FreeRemapInfo)( struct remap_info_s *info );
void (*CL_UpdateRemapInfo)( cl_entity_t *ent, int topcolor, int bottomcolor );
void (*CL_UpdateRemapInfo)( cl_entity_t *entity, int topcolor, int bottomcolor );
// utils
void (*CL_ExtraUpdate)( void );

View File

@ -1005,7 +1005,7 @@ R_AliasSetRemapColors
*/
void R_AliasSetRemapColors( int newTop, int newBottom )
{
gEngfuncs.CL_AllocRemapInfo( RI.currententity, newTop, newBottom );
gEngfuncs.CL_AllocRemapInfo( RI.currententity, RI.currentmodel, newTop, newBottom );
if( gEngfuncs.CL_GetRemapInfoForEntity( RI.currententity ))
{

View File

@ -2670,7 +2670,7 @@ R_StudioSetRemapColors
*/
static void R_StudioSetRemapColors( int newTop, int newBottom )
{
gEngfuncs.CL_AllocRemapInfo( RI.currententity, newTop, newBottom );
gEngfuncs.CL_AllocRemapInfo( RI.currententity, RI.currentmodel, newTop, newBottom );
if( gEngfuncs.CL_GetRemapInfoForEntity( RI.currententity ))
{

View File

@ -2434,7 +2434,7 @@ R_StudioSetRemapColors
*/
static void R_StudioSetRemapColors( int newTop, int newBottom )
{
gEngfuncs.CL_AllocRemapInfo( RI.currententity, newTop, newBottom );
gEngfuncs.CL_AllocRemapInfo( RI.currententity, RI.currentmodel, newTop, newBottom );
if( gEngfuncs.CL_GetRemapInfoForEntity( RI.currententity ))
{