From fdf82e52702664231edf58df5400f749e58ccd0e Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 14 Oct 2024 18:07:58 +0300 Subject: [PATCH] engine: client: cleanup tent and efx code, make global variables static, remove unused functions --- engine/client/cl_efx.c | 33 +++++------------------ engine/client/cl_tent.c | 58 ++++++++++++++++++++++------------------- engine/client/cl_tent.h | 1 - engine/client/client.h | 1 - 4 files changed, 38 insertions(+), 55 deletions(-) diff --git a/engine/client/cl_efx.c b/engine/client/cl_efx.c index 55272953..d72c0904 100644 --- a/engine/client/cl_efx.c +++ b/engine/client/cl_efx.c @@ -25,10 +25,10 @@ static CVAR_DEFINE_AUTO( tracerspeed, "6000", 0, "tracer speed" ); static CVAR_DEFINE_AUTO( tracerlength, "0.8", 0, "tracer length factor" ); static CVAR_DEFINE_AUTO( traceroffset, "30", 0, "tracer starting offset" ); -particle_t *cl_active_particles; -particle_t *cl_active_tracers; -particle_t *cl_free_particles; -particle_t *cl_particles = NULL; // particle pool +static particle_t *cl_active_particles; +static particle_t *cl_active_tracers; +static particle_t *cl_free_particles; +static particle_t *cl_particles = NULL; // particle pool static vec3_t cl_avelocities[NUMVERTEXNORMALS]; static float cl_lasttimewarn = 0.0f; @@ -262,9 +262,9 @@ VIEWBEAMS MANAGEMENT ============================================================== */ -BEAM *cl_active_beams; -BEAM *cl_free_beams; -BEAM *cl_viewbeams = NULL; // beams pool +static BEAM *cl_active_beams; +static BEAM *cl_free_beams; +static BEAM *cl_viewbeams = NULL; // beams pool /* @@ -1764,25 +1764,6 @@ void GAME_EXPORT R_StreakSplash( const vec3_t pos, const vec3_t dir, int color, } } -/* -=============== -R_DebugParticle - -just for debug purposes -=============== -*/ -void R_DebugParticle( const vec3_t pos, byte r, byte g, byte b ) -{ - particle_t *p; - - p = R_AllocParticle( NULL ); - if( !p ) return; - - VectorCopy( pos, p->org ); - p->color = R_LookupColor( r, g, b ); - p->die = cl.time + 0.01f; -} - /* =============== CL_Particle diff --git a/engine/client/cl_tent.c b/engine/client/cl_tent.c index 6c0f09fd..ae16a1f0 100644 --- a/engine/client/cl_tent.c +++ b/engine/client/cl_tent.c @@ -35,17 +35,17 @@ TEMPENTS MANAGEMENT #define SHARD_VOLUME 12.0f // on shard ever n^3 units #define MAX_MUZZLEFLASH 3 -TEMPENTITY *cl_active_tents; -TEMPENTITY *cl_free_tents; -TEMPENTITY *cl_tempents = NULL; // entities pool +static TEMPENTITY *cl_active_tents; +static TEMPENTITY *cl_free_tents; +static TEMPENTITY *cl_tempents = NULL; // entities pool -model_t *cl_sprite_muzzleflash[MAX_MUZZLEFLASH]; // muzzle flashes -model_t *cl_sprite_dot = NULL; -model_t *cl_sprite_ricochet = NULL; -model_t *cl_sprite_shell = NULL; -model_t *cl_sprite_glow = NULL; +static model_t *cl_sprite_muzzleflash[MAX_MUZZLEFLASH]; // muzzle flashes +static model_t *cl_sprite_ricochet = NULL; +static model_t *cl_sprite_glow = NULL; +model_t *cl_sprite_dot = NULL; +model_t *cl_sprite_shell = NULL; -const char *cl_default_sprites[] = +static const char *const cl_default_sprites[] = { // built-in sprites "sprites/muzzleflash1.spr", @@ -169,29 +169,13 @@ void CL_AddClientResources( void ) #endif } - -/* -================ -CL_InitTempents - -================ -*/ -void CL_InitTempEnts( void ) -{ - cl_tempents = Mem_Calloc( cls.mempool, sizeof( TEMPENTITY ) * GI->max_tents ); - CL_ClearTempEnts(); - - // load tempent sprites (glowshell, muzzleflashes etc) - CL_LoadClientSprites (); -} - /* ================ CL_ClearTempEnts ================ */ -void CL_ClearTempEnts( void ) +static void CL_ClearTempEnts( void ) { int i; @@ -208,6 +192,21 @@ void CL_ClearTempEnts( void ) cl_active_tents = NULL; } +/* +================ +CL_InitTempents + +================ +*/ +void CL_InitTempEnts( void ) +{ + cl_tempents = Mem_Calloc( cls.mempool, sizeof( TEMPENTITY ) * GI->max_tents ); + CL_ClearTempEnts(); + + // load tempent sprites (glowshell, muzzleflashes etc) + CL_LoadClientSprites (); +} + /* ================ CL_FreeTempEnts @@ -444,11 +443,16 @@ alloc normal\low priority tempentity */ TEMPENTITY *CL_TempEntAlloc( const vec3_t org, model_t *pmodel ) { + static float cl_lasttimewarn; TEMPENTITY *pTemp; if( !cl_free_tents ) { - Con_DPrintf( "Overflow %d temporary ents!\n", GI->max_tents ); + if( cl_lasttimewarn < host.realtime ) + { + Con_DPrintf( "Overflow %d temporary ents!\n", GI->max_tents ); + cl_lasttimewarn = host.realtime + 1.0f; + } return NULL; } diff --git a/engine/client/cl_tent.h b/engine/client/cl_tent.h index f2cc7e99..53a7e2b1 100644 --- a/engine/client/cl_tent.h +++ b/engine/client/cl_tent.h @@ -77,7 +77,6 @@ void R_MultiGunshot( const vec3_t org, const vec3_t dir, const vec3_t noise, int void R_FireField( float *org, int radius, int modelIndex, int count, int flags, float life ); void R_PlayerSprites( int client, int modelIndex, int count, int size ); void R_Sprite_WallPuff( struct tempent_s *pTemp, float scale ); -void R_DebugParticle( const vec3_t pos, byte r, byte g, byte b ); void R_RicochetSound( const vec3_t pos ); struct dlight_s *CL_AllocDlight( int key ); struct dlight_s *CL_AllocElight( int key ); diff --git a/engine/client/client.h b/engine/client/client.h index e1623d68..25f5ceef 100644 --- a/engine/client/client.h +++ b/engine/client/client.h @@ -1031,7 +1031,6 @@ void CL_InitParticles( void ); void CL_ClearParticles( void ); void CL_FreeParticles( void ); void CL_InitTempEnts( void ); -void CL_ClearTempEnts( void ); void CL_FreeTempEnts( void ); void CL_TempEntUpdate( void ); void CL_InitViewBeams( void );