From 0f490a2f16a886d88863ab985d916360817b3b29 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Wed, 13 May 2026 10:48:37 +0500 Subject: [PATCH] engine: client: fix warnings, cleanup unused or maybe-uninitialized variables --- engine/client/cl_efx.c | 1 - engine/client/cl_main.c | 3 --- engine/client/cl_netgraph.c | 1 - engine/client/cl_steam.c | 4 ++-- engine/client/cl_tent.c | 3 --- engine/client/console.c | 10 +++++----- engine/client/identification.c | 2 +- engine/client/input/input.c | 1 - engine/client/mod_dbghulls.c | 2 +- engine/client/parse/cl_parse.c | 4 ++-- engine/client/sound/s_main.c | 15 ++++++--------- engine/client/sound/voice.c | 7 +------ 12 files changed, 18 insertions(+), 35 deletions(-) diff --git a/engine/client/cl_efx.c b/engine/client/cl_efx.c index 89a9c3e6..f4457815 100644 --- a/engine/client/cl_efx.c +++ b/engine/client/cl_efx.c @@ -416,7 +416,6 @@ void CL_KillDeadBeams( cl_entity_t *pDeadEntity ) while( pbeam ) { - cl_entity_t *beament; pnext = pbeam->next; // link into new list. diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index cb7aa9c2..4c3c70f6 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -1986,8 +1986,6 @@ all the keys and values must be ends with ^7 */ static void CL_FixupColorStringsForInfoString( const char *in, char *out, size_t len ) { - qboolean hasPrefix = false; - qboolean endOfKeyVal = false; int color = 7; int count = 0; @@ -2163,7 +2161,6 @@ static void CL_ParseNETInfoMessage( netadr_t from, const char *s ) int i, context, type; int errorBits = 0; const char *val; - size_t slen; context = Q_atoi( Cmd_Argv( 1 )); type = Q_atoi( Cmd_Argv( 2 )); diff --git a/engine/client/cl_netgraph.c b/engine/client/cl_netgraph.c index b71db468..6740ccd3 100644 --- a/engine/client/cl_netgraph.c +++ b/engine/client/cl_netgraph.c @@ -253,7 +253,6 @@ NetGraph_DrawTimes static void NetGraph_DrawTimes( wrect_t rect, int x, int w ) { int i, j, extrap_point = NETGRAPH_LERP_HEIGHT / 3, a, h; - rgba_t colors = { 0.9 * 255, 0.9 * 255, 0.7 * 255, 255 }; wrect_t fill; for( a = 0; a < w; a++ ) diff --git a/engine/client/cl_steam.c b/engine/client/cl_steam.c index cdf46626..713c1d55 100644 --- a/engine/client/cl_steam.c +++ b/engine/client/cl_steam.c @@ -355,7 +355,7 @@ static void SteamBroker_UpdateIdle( void ) } } -void SteamBroker_AnnounceGameStart( const char *gamedir ) +static void SteamBroker_AnnounceGameStart( const char *gamedir ) { if( Q_stricmp( cl_ticket_generator.string, "steam" ) != 0 ) return; @@ -371,7 +371,7 @@ void SteamBroker_AnnounceGameStart( const char *gamedir ) SteamBroker_SendFrame( buf, len ); } -void SteamBroker_AnnounceGameShutdown( void ) +static void SteamBroker_AnnounceGameShutdown( void ) { if( Q_stricmp( cl_ticket_generator.string, "steam" ) != 0 ) return; diff --git a/engine/client/cl_tent.c b/engine/client/cl_tent.c index f1d4c1ad..97bb7b74 100644 --- a/engine/client/cl_tent.c +++ b/engine/client/cl_tent.c @@ -1669,7 +1669,6 @@ void GAME_EXPORT R_PlayerSprites( int client, int modelIndex, int count, int siz cl_entity_t *pEnt; vec3_t position; vec3_t dir; - float vel; int i; pEnt = CL_GetEntityByIndex( client ); @@ -1677,8 +1676,6 @@ void GAME_EXPORT R_PlayerSprites( int client, int modelIndex, int count, int siz if( !pEnt || !pEnt->player ) return; - vel = 128; - for( i = 0; i < count; i++ ) { VectorCopy( pEnt->origin, position ); diff --git a/engine/client/console.c b/engine/client/console.c index 748d28f6..92d4679e 100644 --- a/engine/client/console.c +++ b/engine/client/console.c @@ -159,7 +159,7 @@ static void Con_SaveHistory( con_history_t *self ); Con_BackgroundMapActive ================ */ -qboolean Con_BackgroundMapActive( void ) +static qboolean Con_BackgroundMapActive( void ) { return sv_background.value != 0.0f || cl.background; } @@ -475,7 +475,7 @@ If the line width has changed, reformat the buffer. static void Con_CheckResize( void ) { int charWidth = 8; - int i, width; + int width; if( con.curFont && con.curFont->hFontTexture ) charWidth = con.curFont->charWidths['O'] - 1; @@ -1105,7 +1105,7 @@ static void Con_ClearField( field_t *edit ) Field_Set ================ */ -static void Field_Set( field_t *f, const char *string ) +MAYBE_UNUSED static void Field_Set( field_t *f, const char *string ) { f->scroll = 0; f->cursor = Q_strncpy( f->buffer, string, sizeof( f->buffer )); @@ -1935,10 +1935,10 @@ Draws the console with the solid background */ static void Con_DrawSolidConsole( int lines ) { - int i, x, y; + int x, y; float fraction; int start; - int stringLen, width = 0, charH; + int stringLen, charH; string curbuild; byte color[4]; diff --git a/engine/client/identification.c b/engine/client/identification.c index 23f4d619..c2a6d040 100644 --- a/engine/client/identification.c +++ b/engine/client/identification.c @@ -80,7 +80,7 @@ static uint BloomFilter_Weight( bloomfilter_t value ) return weight; } -static qboolean BloomFilter_ContainsString( bloomfilter_t filter, const char *str ) +MAYBE_UNUSED static qboolean BloomFilter_ContainsString( bloomfilter_t filter, const char *str ) { bloomfilter_t value = BloomFilter_ProcessStr( str ); diff --git a/engine/client/input/input.c b/engine/client/input/input.c index f0303e66..5eb2978f 100644 --- a/engine/client/input/input.c +++ b/engine/client/input/input.c @@ -28,7 +28,6 @@ GNU General Public License for more details. static qboolean in_mouseactive; // false when not focus app static qboolean in_mouseinitialized; -static qboolean in_mouse_suspended; static struct { int x, y; diff --git a/engine/client/mod_dbghulls.c b/engine/client/mod_dbghulls.c index 2672f4bc..49fca7c6 100644 --- a/engine/client/mod_dbghulls.c +++ b/engine/client/mod_dbghulls.c @@ -725,7 +725,7 @@ static void R_DrawHull( hull_model_t *hull ) { int i; - srand((unsigned int)poly ); + srand((unsigned int)(uintptr_t)poly ); ref.dllFuncs.Color4ub( rand() & 255, rand() & 255, rand() & 255, 255 ); ref.dllFuncs.Begin( TRI_POLYGON ); diff --git a/engine/client/parse/cl_parse.c b/engine/client/parse/cl_parse.c index 89a3d5aa..e91b93f5 100644 --- a/engine/client/parse/cl_parse.c +++ b/engine/client/parse/cl_parse.c @@ -256,7 +256,7 @@ static client entity */ static void CL_ParseStaticEntity( sizebuf_t *msg ) { - int i, newnum; + int i; const entity_state_t from = { 0 }; entity_state_t to; cl_entity_t *ent; @@ -264,7 +264,7 @@ static void CL_ParseStaticEntity( sizebuf_t *msg ) if( !clgame.static_entities ) clgame.static_entities = Mem_Calloc( clgame.mempool, sizeof( cl_entity_t ) * MAX_STATIC_ENTITIES ); - newnum = MSG_ReadUBitLong( msg, MAX_ENTITY_BITS ); + MSG_ReadUBitLong( msg, MAX_ENTITY_BITS ); MSG_ReadDeltaEntity( msg, &from, &to, 0, DELTA_STATIC, cl.mtime[0] ); i = clgame.numStatics; diff --git a/engine/client/sound/s_main.c b/engine/client/sound/s_main.c index fa9de497..45b840c1 100644 --- a/engine/client/sound/s_main.c +++ b/engine/client/sound/s_main.c @@ -627,8 +627,8 @@ void S_StartSound( const vec3_t pos, int ent, int chan, sound_t handle, float fv { wavdata_t *pSource; sfx_t *sfx = NULL; - channel_t *target_chan, *check; - int vol, ch_idx; + channel_t *target_chan; + int vol; qboolean bIgnore = false; if( !snd.initialized ) return; @@ -874,7 +874,7 @@ void S_AmbientSound( const vec3_t pos, int ent, sound_t handle, float fvol, floa channel_t *ch; wavdata_t *pSource = NULL; sfx_t *sfx = NULL; - int vol, fvox = 0; + int vol; if( !snd.initialized ) return; sfx = S_GetSfxByHandle( handle ); @@ -911,7 +911,6 @@ void S_AmbientSound( const vec3_t pos, int ent, sound_t handle, float fvol, floa Q_strncpy( ch->name, sfx->name, sizeof( ch->name )); sfx = ch->sfx; if( sfx ) pSource = sfx->cache; - fvox = 1; } else { @@ -1085,8 +1084,6 @@ S_UpdateAmbientSounds */ static void S_UpdateAmbientSounds( void ) { - int ambient_channel; - if( !snd.have_ambient_sfx ) return; @@ -1117,7 +1114,7 @@ static void S_UpdateAmbientSounds( void ) continue; } - float vol = s_ambient_level.value * leaf->ambient_sound_level[ambient_channel]; + float vol = s_ambient_level.value * leaf->ambient_sound_level[i]; if( vol < 0.0f ) vol = 0.0f; @@ -1863,8 +1860,8 @@ static void S_SoundFade_f( void ) int c = Cmd_Argc(); int fade_percent; int hold_time; - int fade_out_seconds; - int fade_in_seconds; + int fade_out_seconds = 0; + int fade_in_seconds = 0; if( c != 3 && c != 5 ) { diff --git a/engine/client/sound/voice.c b/engine/client/sound/voice.c index 0ac97807..8bb9039a 100644 --- a/engine/client/sound/voice.c +++ b/engine/client/sound/voice.c @@ -601,7 +601,6 @@ static int Voice_ProcessGSData( int ent, const uint8_t *data, uint32_t size ) uint32_t crc; size_t offset; size_t samples; - uint16_t sample_rate; uint8_t vpc_type; uint16_t data_len; OpusDecoder *decoder; @@ -637,7 +636,6 @@ static int Voice_ProcessGSData( int ent, const uint8_t *data, uint32_t size ) if( offset + sizeof( uint32_t ) > size - sizeof( uint32_t )) return 0; - sample_rate = LittleShort( *(uint16_t *)( data + offset )); offset += sizeof( uint16_t ); vpc_type = data[offset++]; @@ -987,7 +985,6 @@ void Voice_AddIncomingData( int ent, const byte *data, uint size, uint frames ) const int playernum = ent - 1; int samples = 0; int ofs = 0; - voice_status_t *status = NULL; if( !voice.initialized || !voice_enable.value ) return; @@ -1041,7 +1038,7 @@ Encode our voice data and send it to server void CL_AddVoiceToDatagram( void ) { byte buffer[VOICE_MAX_DATA_SIZE]; - uint size, frames; + uint size, frames = 0; if( cls.state != ca_active || !voice.device_opened || !Voice_IsRecording()) return; @@ -1131,8 +1128,6 @@ Run timeout for clients */ void Voice_Idle( double frametime ) { - int i; - if( FBitSet( voice_enable.flags, FCVAR_CHANGED )) { ClearBits( voice_enable.flags, FCVAR_CHANGED );