engine: client: fix various useless checks, unused variables & defines, double assignments and mistypings

This commit is contained in:
Alibek Omarov 2022-05-25 03:50:06 +03:00
parent 843c9abf9b
commit 52d1383f14
12 changed files with 27 additions and 54 deletions

View File

@ -106,7 +106,7 @@ void CL_RemoveFromResourceList( resource_t *pResource )
if( pResource->pPrev == NULL || pResource->pNext == NULL ) if( pResource->pPrev == NULL || pResource->pNext == NULL )
Host_Error( "mislinked resource in CL_RemoveFromResourceList\n" ); Host_Error( "mislinked resource in CL_RemoveFromResourceList\n" );
if ( pResource->pNext == pResource || pResource->pPrev == pResource ) if( pResource->pNext == pResource || pResource->pPrev == pResource )
Host_Error( "attempt to free last entry in list.\n" ); Host_Error( "attempt to free last entry in list.\n" );
pResource->pPrev->pNext = pResource->pNext; pResource->pPrev->pNext = pResource->pNext;

View File

@ -188,8 +188,6 @@ void R_StoreEfrags( efrag_t **ppefrag, int framecount )
case mod_brush: case mod_brush:
case mod_studio: case mod_studio:
case mod_sprite: case mod_sprite:
pent = pefrag->entity;
if( pent->visframe != framecount ) if( pent->visframe != framecount )
{ {
if( CL_AddVisibleEntity( pent, ET_FRAGMENTED )) if( CL_AddVisibleEntity( pent, ET_FRAGMENTED ))

View File

@ -2299,9 +2299,9 @@ static void GAME_EXPORT pfnKillEvents( int entnum, const char *eventname )
int i; int i;
event_state_t *es; event_state_t *es;
event_info_t *ei; event_info_t *ei;
int eventIndex = CL_EventIndex( eventname ); word eventIndex = CL_EventIndex( eventname );
if( eventIndex < 0 || eventIndex >= MAX_EVENTS ) if( eventIndex >= MAX_EVENTS )
return; return;
if( entnum < 0 || entnum > clgame.maxEntities ) if( entnum < 0 || entnum > clgame.maxEntities )

View File

@ -2345,11 +2345,10 @@ Replace the displayed name for some resources
*/ */
const char *CL_CleanFileName( const char *filename ) const char *CL_CleanFileName( const char *filename )
{ {
const char *pfilename = filename;
if( COM_CheckString( filename ) && filename[0] == '!' ) if( COM_CheckString( filename ) && filename[0] == '!' )
pfilename = "customization"; return "customization";
return pfilename;
return filename;
} }

View File

@ -484,6 +484,8 @@ void CL_BatchResourceRequest( qboolean initialize )
switch( p->type ) switch( p->type )
{ {
case t_sound: case t_sound:
case t_model:
case t_eventscript:
if( !CL_CheckFile( &msg, p )) if( !CL_CheckFile( &msg, p ))
break; break;
CL_MoveToOnHandList( p ); CL_MoveToOnHandList( p );
@ -491,11 +493,6 @@ void CL_BatchResourceRequest( qboolean initialize )
case t_skin: case t_skin:
CL_MoveToOnHandList( p ); CL_MoveToOnHandList( p );
break; break;
case t_model:
if( !CL_CheckFile( &msg, p ))
break;
CL_MoveToOnHandList( p );
break;
case t_decal: case t_decal:
if( !HPAK_GetDataPointer( CUSTOM_RES_PATH, p, NULL, NULL )) if( !HPAK_GetDataPointer( CUSTOM_RES_PATH, p, NULL, NULL ))
{ {
@ -520,11 +517,6 @@ void CL_BatchResourceRequest( qboolean initialize )
break; break;
CL_MoveToOnHandList( p ); CL_MoveToOnHandList( p );
break; break;
case t_eventscript:
if( !CL_CheckFile( &msg, p ))
break;
CL_MoveToOnHandList( p );
break;
case t_world: case t_world:
ASSERT( 0 ); ASSERT( 0 );
break; break;
@ -2389,14 +2381,11 @@ CL_ParseBaseline
void CL_LegacyParseBaseline( sizebuf_t *msg ) void CL_LegacyParseBaseline( sizebuf_t *msg )
{ {
int i, newnum; int i, newnum;
entity_state_t nullstate;
qboolean player; qboolean player;
cl_entity_t *ent; cl_entity_t *ent;
Delta_InitClient (); // finalize client delta's Delta_InitClient (); // finalize client delta's
memset( &nullstate, 0, sizeof( nullstate ));
newnum = MSG_ReadWord( msg ); newnum = MSG_ReadWord( msg );
player = CL_IsPlayerIndex( newnum ); player = CL_IsPlayerIndex( newnum );

View File

@ -992,7 +992,6 @@ void CL_SetupPMove( playermove_t *pmove, local_state_t *from, usercmd_t *ucmd, q
pmove->flFallVelocity = ps->flFallVelocity; pmove->flFallVelocity = ps->flFallVelocity;
pmove->flSwimTime = cd->flSwimTime; pmove->flSwimTime = cd->flSwimTime;
VectorCopy( cd->punchangle, pmove->punchangle ); VectorCopy( cd->punchangle, pmove->punchangle );
pmove->flSwimTime = cd->flSwimTime;
pmove->flNextPrimaryAttack = 0.0f; // not used by PM_ code pmove->flNextPrimaryAttack = 0.0f; // not used by PM_ code
pmove->effects = ps->effects; pmove->effects = ps->effects;
pmove->flags = cd->flags; pmove->flags = cd->flags;

View File

@ -1482,7 +1482,6 @@ void GAME_EXPORT R_FunnelSprite( const vec3_t org, int modelIndex, int reverse )
pTemp->entity.baseline.angles[2] = COM_RandomFloat( -100.0f, 100.0f ); pTemp->entity.baseline.angles[2] = COM_RandomFloat( -100.0f, 100.0f );
pTemp->entity.curstate.framerate = COM_RandomFloat( 0.1f, 0.4f ); pTemp->entity.curstate.framerate = COM_RandomFloat( 0.1f, 0.4f );
pTemp->flags = FTENT_ROTATE|FTENT_FADEOUT; pTemp->flags = FTENT_ROTATE|FTENT_FADEOUT;
pTemp->entity.curstate.framerate = 10;
vel = dest[2] / 8.0f; vel = dest[2] / 8.0f;
if( vel < 64.0f ) vel = 64.0f; if( vel < 64.0f ) vel = 64.0f;
@ -2920,7 +2919,7 @@ void CL_PlayerDecal( int playernum, int customIndex, int entityIndex, float *pos
{ {
if( FBitSet( pCust->resource.ucFlags, RES_CUSTOM ) && pCust->resource.type == t_decal && pCust->bTranslated ) if( FBitSet( pCust->resource.ucFlags, RES_CUSTOM ) && pCust->resource.type == t_decal && pCust->bTranslated )
{ {
if( !pCust->nUserData1 && pCust->pInfo != NULL ) if( !pCust->nUserData1 )
{ {
const char *decalname = va( "player%dlogo%d", playernum, customIndex ); const char *decalname = va( "player%dlogo%d", playernum, customIndex );
pCust->nUserData1 = GL_LoadTextureInternal( decalname, pCust->pInfo, TF_DECAL ); pCust->nUserData1 = GL_LoadTextureInternal( decalname, pCust->pInfo, TF_DECAL );

View File

@ -1069,7 +1069,7 @@ int Con_DrawGenericString( int x, int y, const char *string, rgba_t setColor, qb
Con_UtfProcessChar( 0 ); Con_UtfProcessChar( 0 );
// draw the colored text // draw the colored text
*(uint *)color = *(uint *)setColor; memcpy( color, setColor, sizeof( color ));
s = string; s = string;
while( *s ) while( *s )
@ -2174,6 +2174,9 @@ void Con_DrawSolidConsole( int lines )
int i, x, y; int i, x, y;
float fraction; float fraction;
int start; int start;
int stringLen, width = 0, charH;
string curbuild;
byte color[4];
if( lines <= 0 ) return; if( lines <= 0 ) return;
@ -2187,28 +2190,20 @@ void Con_DrawSolidConsole( int lines )
if( !con.curFont || !host.allow_console ) if( !con.curFont || !host.allow_console )
return; // nothing to draw return; // nothing to draw
if( host.allow_console ) // draw current version
{ memcpy( color, g_color_table[7], sizeof( color ));
// draw current version
int stringLen, width = 0, charH;
string curbuild;
byte color[4];
memcpy( color, g_color_table[7], sizeof( color )); Q_snprintf( curbuild, MAX_STRING, "%s %i/%s (%s-%s build %i)", XASH_ENGINE_NAME, PROTOCOL_VERSION, XASH_VERSION, Q_buildos(), Q_buildarch(), Q_buildnum( ));
Con_DrawStringLen( curbuild, &stringLen, &charH );
start = refState.width - stringLen;
stringLen = Con_StringLength( curbuild );
Q_snprintf( curbuild, MAX_STRING, "%s %i/%s (%s-%s build %i)", XASH_ENGINE_NAME, PROTOCOL_VERSION, XASH_VERSION, Q_buildos(), Q_buildarch(), Q_buildnum( )); fraction = lines / (float)refState.height;
color[3] = Q_min( fraction * 2.0f, 1.0f ) * 255; // fadeout version number
Con_DrawStringLen( curbuild, &stringLen, &charH ); for( i = 0; i < stringLen; i++ )
start = refState.width - stringLen; width += Con_DrawCharacter( start + width, 0, curbuild[i], color );
stringLen = Con_StringLength( curbuild );
fraction = lines / (float)refState.height;
color[3] = Q_min( fraction * 2.0f, 1.0f ) * 255; // fadeout version number
for( i = 0; i < stringLen; i++ )
width += Con_DrawCharacter( start + width, 0, curbuild[i], color );
}
// draw the text // draw the text
if( CON_LINES_COUNT > 0 ) if( CON_LINES_COUNT > 0 )

View File

@ -786,7 +786,6 @@ static touch_button_t *Touch_AddButton( touchbuttonlist_t *list,
button->flags = privileged ? 0 : TOUCH_FL_UNPRIVILEGED | TOUCH_FL_CLIENT; button->flags = privileged ? 0 : TOUCH_FL_UNPRIVILEGED | TOUCH_FL_CLIENT;
MakeRGBA( button->color, color[0], color[1], color[2], color[3] ); MakeRGBA( button->color, color[0], color[1], color[2], color[3] );
button->command[0] = 0; button->command[0] = 0;
button->flags = 0;
button->fade = 1; button->fade = 1;
Touch_SetCommand( button, command ); Touch_SetCommand( button, command );

View File

@ -1044,7 +1044,7 @@ static qboolean OSK_KeyEvent( int key, int down )
else else
osk.curlayout++; osk.curlayout++;
osk.shift = osk.curbutton.val == OSK_SHIFT; osk.shift = true;
osk.curbutton.val = osk_keylayout[osk.curlayout][osk.curbutton.y][osk.curbutton.x]; osk.curbutton.val = osk_keylayout[osk.curlayout][osk.curbutton.y][osk.curbutton.x];
break; break;
case OSK_BACKSPACE: case OSK_BACKSPACE:

View File

@ -33,7 +33,6 @@ GNU General Public License for more details.
#define MAXDLY (STEREODLY + 1) #define MAXDLY (STEREODLY + 1)
#define MAXLP 10 #define MAXLP 10
#define MAXPRESETS 29
typedef struct sx_preset_s typedef struct sx_preset_s
{ {
@ -79,7 +78,7 @@ typedef struct dly_s
int *lpdelayline; int *lpdelayline;
} dly_t; } dly_t;
const sx_preset_t rgsxpre[MAXPRESETS] = const sx_preset_t rgsxpre[] =
{ {
// -------reverb-------- -------delay-------- // -------reverb-------- -------delay--------
// lp mod size refl rvblp delay feedback dlylp left // lp mod size refl rvblp delay feedback dlylp left
@ -116,7 +115,7 @@ const sx_preset_t rgsxpre[MAXPRESETS] =
// 0x0045dca8 enginegl.exe // 0x0045dca8 enginegl.exe
// SHA256: 42383d32cd712e59ee2c1bd78b7ba48814e680e7026c4223e730111f34a60d66 // SHA256: 42383d32cd712e59ee2c1bd78b7ba48814e680e7026c4223e730111f34a60d66
const sx_preset_t rgsxpre_hlalpha052[MAXPRESETS] = const sx_preset_t rgsxpre_hlalpha052[] =
{ {
// -------reverb-------- -------delay-------- // -------reverb-------- -------delay--------
// lp mod size refl rvblp delay feedback dlylp left // lp mod size refl rvblp delay feedback dlylp left
@ -882,7 +881,7 @@ void CheckNewDspPresets( void )
else idsp_room = room_type->value; else idsp_room = room_type->value;
// don't pass invalid presets // don't pass invalid presets
idsp_room = bound( 0, idsp_room, MAXPRESETS - 1 ); idsp_room = bound( 0, idsp_room, MAX_ROOM_TYPES );
if( FBitSet( hisound->flags, FCVAR_CHANGED )) if( FBitSet( hisound->flags, FCVAR_CHANGED ))
{ {
@ -893,9 +892,6 @@ void CheckNewDspPresets( void )
if( idsp_room == room_typeprev && idsp_room == 0 ) if( idsp_room == room_typeprev && idsp_room == 0 )
return; return;
if( idsp_room > MAX_ROOM_TYPES )
return;
if( idsp_room != room_typeprev ) if( idsp_room != room_typeprev )
{ {
const sx_preset_t *cur; const sx_preset_t *cur;

View File

@ -1155,7 +1155,6 @@ void S_RawSamples( uint samples, uint rate, word width, word channels, const byt
int snd_vol = 128; int snd_vol = 128;
if( entnum < 0 ) snd_vol = 256; // bg track or movie track if( entnum < 0 ) snd_vol = 256; // bg track or movie track
if( snd_vol < 0 ) snd_vol = 0; // fixup negative values
S_RawEntSamples( entnum, samples, rate, width, channels, data, snd_vol ); S_RawEntSamples( entnum, samples, rate, width, channels, data, snd_vol );
} }