Browse Source

engine: client: increase limit of client sprites, lower part of it can be used only for HUD sprites

higher part used for client sprites
map overview sprites are loaded as normal models

thus we have equal internal engine and hud sprite indices and it fixes compatibility issues
for mods like Half-Rats Parasomnia
pull/2/head
Alibek Omarov 2 years ago
parent
commit
6e031b518a
  1. 2
      common/com_model.h
  2. 31
      engine/client/cl_game.c
  3. 2
      engine/client/client.h

2
common/com_model.h

@ -530,7 +530,7 @@ typedef struct @@ -530,7 +530,7 @@ typedef struct
#define MAX_DEMOS 32
#define MAX_MOVIES 8
#define MAX_CDTRACKS 32
#define MAX_CLIENT_SPRITES 256 // SpriteTextures
#define MAX_CLIENT_SPRITES 512 // SpriteTextures (0-256 hud, 256-512 client)
#define MAX_EFRAGS 8192 // Arcane Dimensions required
#define MAX_REQUESTS 64

31
engine/client/cl_game.c

@ -1235,6 +1235,10 @@ static model_t *CL_LoadSpriteModel( const char *filename, uint type, uint texFla @@ -1235,6 +1235,10 @@ static model_t *CL_LoadSpriteModel( const char *filename, uint type, uint texFla
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;
if( !COM_CheckString( filename ))
{
Con_Reportf( S_ERROR "CL_LoadSpriteModel: bad name!\n" );
@ -1244,8 +1248,7 @@ static model_t *CL_LoadSpriteModel( const char *filename, uint type, uint texFla @@ -1244,8 +1248,7 @@ static model_t *CL_LoadSpriteModel( const char *filename, uint type, uint texFla
Q_strncpy( name, filename, sizeof( name ));
COM_FixSlashes( name );
// slot 0 isn't used
for( i = 1, mod = clgame.sprites; i < MAX_CLIENT_SPRITES; i++, mod++ )
for( i = 0, mod = clgame.sprites + start; i < MAX_CLIENT_SPRITES / 2; i++, mod++ )
{
if( !Q_stricmp( mod->name, name ))
{
@ -1262,12 +1265,12 @@ static model_t *CL_LoadSpriteModel( const char *filename, uint type, uint texFla @@ -1262,12 +1265,12 @@ static model_t *CL_LoadSpriteModel( const char *filename, uint type, uint texFla
}
// find a free model slot spot
for( i = 1, mod = clgame.sprites; i < MAX_CLIENT_SPRITES; i++, mod++ )
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 )
if( i == MAX_CLIENT_SPRITES / 2 )
{
Con_Printf( S_ERROR "MAX_CLIENT_SPRITES limit exceeded (%d)\n", MAX_CLIENT_SPRITES );
Con_Printf( S_ERROR "MAX_CLIENT_SPRITES limit exceeded (%d)\n", MAX_CLIENT_SPRITES / 2 );
return NULL;
}
@ -1308,7 +1311,7 @@ HSPRITE pfnSPR_LoadExt( const char *szPicName, uint texFlags ) @@ -1308,7 +1311,7 @@ HSPRITE pfnSPR_LoadExt( const char *szPicName, uint texFlags )
if(( spr = CL_LoadSpriteModel( szPicName, SPR_CLIENT, texFlags )) == NULL )
return 0;
return (spr - clgame.sprites); // return index
return (spr - clgame.sprites) + 1; // return index
}
/*
@ -1324,7 +1327,7 @@ HSPRITE EXPORT pfnSPR_Load( const char *szPicName ) @@ -1324,7 +1327,7 @@ HSPRITE EXPORT pfnSPR_Load( const char *szPicName )
if(( spr = CL_LoadSpriteModel( szPicName, SPR_HUDSPRITE, 0 )) == NULL )
return 0;
return (spr - clgame.sprites); // return index
return (spr - clgame.sprites) + 1; // return index
}
/*
@ -1336,10 +1339,11 @@ CL_GetSpritePointer @@ -1336,10 +1339,11 @@ CL_GetSpritePointer
const model_t *CL_GetSpritePointer( HSPRITE hSprite )
{
model_t *mod;
int index = hSprite - 1;
if( hSprite <= 0 || hSprite >= MAX_CLIENT_SPRITES )
if( index < 0 || index >= MAX_CLIENT_SPRITES )
return NULL; // bad image
mod = &clgame.sprites[hSprite];
mod = &clgame.sprites[index];
if( mod->needload == NL_NEEDS_LOADED )
{
@ -2666,7 +2670,14 @@ pfnLoadMapSprite @@ -2666,7 +2670,14 @@ pfnLoadMapSprite
*/
model_t *pfnLoadMapSprite( const char *filename )
{
return CL_LoadSpriteModel( filename, SPR_MAPSPRITE, 0 );
model_t *mod;
mod = Mod_FindName( filename, false );
if( CL_LoadHudSprite( filename, mod, SPR_MAPSPRITE, 0 ))
return mod;
return NULL;
}
/*

2
engine/client/client.h

@ -465,7 +465,7 @@ typedef struct @@ -465,7 +465,7 @@ typedef struct
string cdtracks[MAX_CDTRACKS]; // 32 cd-tracks read from cdaudio.txt
model_t sprites[MAX_CLIENT_SPRITES]; // client spritetextures
model_t sprites[MAX_CLIENT_SPRITES*2]; // hud&client spritetexturesz
int viewport[4]; // viewport sizes
client_draw_t ds; // draw2d stuff (hud, weaponmenu etc)

Loading…
Cancel
Save