From 93ceb0e4ed834123bf9f845a0190b7bf27e4acc7 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Thu, 14 Dec 2023 03:12:45 +0300 Subject: [PATCH] engine: client: split the sprites indices only when loading new sprite. Scan the whole array when searching. Fixes incorrect sprite loading in XDM --- engine/client/cl_game.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/engine/client/cl_game.c b/engine/client/cl_game.c index 3c29efe4..f8413b5d 100644 --- a/engine/client/cl_game.c +++ b/engine/client/cl_game.c @@ -1235,11 +1235,7 @@ static model_t *CL_LoadSpriteModel( const char *filename, uint type, uint texFla { char name[MAX_QPATH]; model_t *mod; - int i; - - // use high indices for client sprites - // for GoldSrc bug-compatibility - const int start = type != SPR_HUDSPRITE ? MAX_CLIENT_SPRITES / 2 : 0; + int i, start; if( !COM_CheckString( filename )) { @@ -1250,7 +1246,7 @@ static model_t *CL_LoadSpriteModel( const char *filename, uint type, uint texFla Q_strncpy( name, filename, sizeof( name )); COM_FixSlashes( name ); - for( i = 0, mod = clgame.sprites + start; i < MAX_CLIENT_SPRITES / 2; i++, mod++ ) + for( i = 0, mod = clgame.sprites; i < MAX_CLIENT_SPRITES; i++, mod++ ) { if( !Q_stricmp( mod->name, name )) { @@ -1267,8 +1263,15 @@ static model_t *CL_LoadSpriteModel( const char *filename, uint type, uint texFla } // find a free model slot spot - for( i = 0, mod = clgame.sprites + start; i < MAX_CLIENT_SPRITES / 2; i++, mod++ ) - if( !mod->name[0] ) break; // this is a valid spot + // use low indices only for HUD sprites + // for GoldSrc bug compatibility + start = type == SPR_HUDSPRITE ? 0 : MAX_CLIENT_SPRITES / 2; + + for( i = 0, mod = &clgame.sprites[start]; i < MAX_CLIENT_SPRITES / 2; i++, mod++ ) + { + if( !mod->name[0] ) + break; // this is a valid spot + } if( i == MAX_CLIENT_SPRITES / 2 ) {