Skip to content

Commit 8352e3c

Browse files
committed
refactor(client): misc refactors
inline getstat move dir and angles inside rename overshadowed i -> j int i inside for rename tempEntity inline effects rename observerTarget inline bVisible specify ParticleEffect and ControlPoint variables rename idx rename iBuffAttachment rename outer i
1 parent 9204cdd commit 8352e3c

10 files changed

Lines changed: 73 additions & 78 deletions

src/game/client/c_baseanimating.cpp

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,43 +1204,43 @@ void C_BaseAnimating::ParseModelEffects( KeyValues *modelKeyValues )
12041204
for ( KeyValues *pSingleEffect = pkvAllParticleEffects->GetFirstSubKey(); pSingleEffect; pSingleEffect = pSingleEffect->GetNextKey() )
12051205
{
12061206
const char *pszParticleEffect = pSingleEffect->GetString( "name", "" );
1207-
const char *pszAttachment = pSingleEffect->GetString( "attachment_point", "" );
1208-
const char *pszAttachType = pSingleEffect->GetString( "attachment_type", "" );
1209-
const char *pszAttachOffset = pSingleEffect->GetString( "attachment_offset", "" );
1207+
const char *pszPEAttachment = pSingleEffect->GetString( "attachment_point", "" );
1208+
const char *pszPEAttachType = pSingleEffect->GetString( "attachment_type", "" );
1209+
const char *pszPEAttachOffset = pSingleEffect->GetString( "attachment_offset", "" );
12101210

12111211
// Convert attach type
1212-
int iAttachType = GetAttachTypeFromString( pszAttachType );
1212+
int iAttachType = GetAttachTypeFromString( pszPEAttachType );
12131213
if ( iAttachType == -1 )
12141214
{
1215-
Warning("Invalid attach type specified for particle effect in model '%s' keyvalues section. Trying to spawn effect '%s' with attach type of '%s'\n", GetModelName(), pszParticleEffect, pszAttachType );
1215+
Warning("Invalid attach type specified for particle effect in model '%s' keyvalues section. Trying to spawn effect '%s' with attach type of '%s'\n", GetModelName(), pszParticleEffect, pszPEAttachType );
12161216
return;
12171217
}
12181218

12191219
// Convert attachment point
1220-
int iAttachment = atoi(pszAttachment);
1220+
int iAttachment = atoi(pszPEAttachment);
12211221
// See if we can find any attachment points matching the name
1222-
if ( pszAttachment[0] != '0' && iAttachment == 0 )
1222+
if ( pszPEAttachment[0] != '0' && iAttachment == 0 )
12231223
{
1224-
iAttachment = LookupAttachment( pszAttachment );
1224+
iAttachment = LookupAttachment( pszPEAttachment );
12251225
if ( iAttachment == -1 )
12261226
{
1227-
Warning("Failed to find attachment point specified for particle effect in model '%s' keyvalues section. Trying to spawn effect '%s' on attachment named '%s'\n", GetModelName(), pszParticleEffect, pszAttachment );
1227+
Warning("Failed to find attachment point specified for particle effect in model '%s' keyvalues section. Trying to spawn effect '%s' on attachment named '%s'\n", GetModelName(), pszParticleEffect, pszPEAttachment );
12281228
return;
12291229
}
12301230
}
12311231

1232-
Vector vecOffset = vec3_origin;
1232+
Vector vecOffsetPE = vec3_origin;
12331233

1234-
if ( pszAttachOffset )
1234+
if ( pszPEAttachOffset )
12351235
{
12361236
float flVec[3];
1237-
UTIL_StringToVector( flVec, pszAttachOffset );
1238-
vecOffset = Vector( flVec[0], flVec[1], flVec[2] );
1237+
UTIL_StringToVector( flVec, pszPEAttachOffset );
1238+
vecOffsetPE = Vector( flVec[0], flVec[1], flVec[2] );
12391239
}
12401240

12411241
CUtlReference<CNewParticleEffect> hModelEffect;
12421242
// Spawn the particle effectw
1243-
hModelEffect = ParticleProp()->Create( pszParticleEffect, (ParticleAttachment_t)iAttachType, iAttachment, vecOffset );
1243+
hModelEffect = ParticleProp()->Create( pszParticleEffect, (ParticleAttachment_t)iAttachType, iAttachment, vecOffsetPE );
12441244

12451245
KeyValues *pkvAllControlPoints = pSingleEffect->FindKey("ControlPoints");
12461246
if ( pkvAllControlPoints )
@@ -1249,37 +1249,37 @@ void C_BaseAnimating::ParseModelEffects( KeyValues *modelKeyValues )
12491249
for ( KeyValues *pSingleCP = pkvAllControlPoints->GetFirstSubKey(); pSingleCP; pSingleCP = pSingleCP->GetNextKey() )
12501250
{
12511251
const char *pszControlPoint = pSingleCP->GetString( "cp_number", "" );
1252-
const char *pszAttachment = pSingleCP->GetString( "attachment_point", "" );
1253-
const char *pszAttachType = pSingleCP->GetString( "attachment_type", "" );
1254-
const char *pszAttachOffset = pSingleCP->GetString( "attachment_offset", "" );
1252+
const char *pszCPAttachment = pSingleCP->GetString( "attachment_point", "" );
1253+
const char *pszCPAttachType = pSingleCP->GetString( "attachment_type", "" );
1254+
const char *pszCPAttachOffset = pSingleCP->GetString( "attachment_offset", "" );
12551255

12561256
// Convert control point
12571257
int iControlPoint = atoi(pszControlPoint);
12581258

12591259
// Convert attach type
1260-
int iAttachType = GetAttachTypeFromString( pszAttachType );
1260+
int iAttachType = GetAttachTypeFromString( pszCPAttachType );
12611261
if ( iAttachType == -1 )
12621262
{
1263-
Warning("Invalid attach type specified for particle effect in model '%s' keyvalues section. Trying to spawn effect '%s' with attach type of '%s'\n", GetModelName(), pszParticleEffect, pszAttachType );
1263+
Warning("Invalid attach type specified for particle effect in model '%s' keyvalues section. Trying to spawn effect '%s' with attach type of '%s'\n", GetModelName(), pszParticleEffect, pszCPAttachType );
12641264
return;
12651265
}
12661266

1267-
Vector vecOffset = vec3_origin;
1267+
Vector vecOffsetCP = vec3_origin;
12681268

1269-
if ( pszAttachOffset )
1269+
if ( pszCPAttachOffset )
12701270
{
12711271
float flVec[3];
1272-
UTIL_StringToVector( flVec, pszAttachOffset );
1273-
vecOffset = Vector( flVec[0], flVec[1], flVec[2] );
1272+
UTIL_StringToVector( flVec, pszCPAttachOffset );
1273+
vecOffsetCP = Vector( flVec[0], flVec[1], flVec[2] );
12741274
}
12751275

12761276
// Add the control point if we already have the effect
12771277
if ( hModelEffect )
12781278
{
12791279
if ( iAttachType == PATTACH_WORLDORIGIN )
1280-
ParticleProp()->AddControlPoint( hModelEffect, iControlPoint, NULL, (ParticleAttachment_t)iAttachType, NULL, vecOffset );
1280+
ParticleProp()->AddControlPoint( hModelEffect, iControlPoint, NULL, (ParticleAttachment_t)iAttachType, NULL, vecOffsetCP );
12811281
else
1282-
ParticleProp()->AddControlPoint( hModelEffect, iControlPoint, this, (ParticleAttachment_t)iAttachType, pszAttachment, vecOffset );
1282+
ParticleProp()->AddControlPoint( hModelEffect, iControlPoint, this, (ParticleAttachment_t)iAttachType, pszCPAttachment, vecOffsetCP );
12831283
}
12841284

12851285
}

src/game/client/c_baseflex.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,8 +478,7 @@ class CFlexSceneFileManager : CAutoGameSystem
478478
Q_FixSlashes( szFilename );
479479

480480
// See if it's already loaded
481-
int i;
482-
for ( i = 0; i < m_FileList.Count(); i++ )
481+
for ( int i = 0; i < m_FileList.Count(); i++ )
483482
{
484483
CFlexSceneFile *file = m_FileList[ i ];
485484
if ( file && !V_stricmp( file->filename, szFilename ) )

src/game/client/c_baseplayer.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -457,8 +457,7 @@ void C_BasePlayer::Spawn( void )
457457
ClearFlags();
458458
AddFlag( FL_CLIENT );
459459

460-
int effects = GetEffects() & EF_NOSHADOW;
461-
SetEffects( effects );
460+
SetEffects( GetEffects() & EF_NOSHADOW );
462461

463462
m_iFOV = 0; // init field of view.
464463

@@ -1526,17 +1525,17 @@ void C_BasePlayer::CalcChaseCamView(Vector& eyeOrigin, QAngle& eyeAngles, float&
15261525

15271526
void C_BasePlayer::CalcRoamingView(Vector& eyeOrigin, QAngle& eyeAngles, float& fov)
15281527
{
1529-
C_BaseEntity *target = GetObserverTarget();
1530-
1531-
if ( !target )
1528+
C_BaseEntity *observerTarget = GetObserverTarget();
1529+
1530+
if ( !observerTarget )
15321531
{
1533-
target = this;
1532+
observerTarget = this;
15341533
}
15351534

15361535
m_flObserverChaseDistance = 0.0;
15371536

1538-
eyeOrigin = target->EyePosition();
1539-
eyeAngles = target->EyeAngles();
1537+
eyeOrigin = observerTarget->EyePosition();
1538+
eyeAngles = observerTarget->EyeAngles();
15401539

15411540
if ( spec_track.GetInt() > 0 )
15421541
{

src/game/client/c_basetempentity.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@ void C_BaseTempEntity::Precache( void )
9292
//-----------------------------------------------------------------------------
9393
void C_BaseTempEntity::PrecacheTempEnts( void )
9494
{
95-
C_BaseTempEntity *te = GetList();
96-
while ( te )
95+
C_BaseTempEntity *tempEntity = GetList();
96+
while ( tempEntity )
9797
{
98-
te->Precache();
99-
te = te->GetNext();
98+
tempEntity->Precache();
99+
tempEntity = tempEntity->GetNext();
100100
}
101101
}
102102

@@ -106,12 +106,12 @@ void C_BaseTempEntity::PrecacheTempEnts( void )
106106
void C_BaseTempEntity::ClearDynamicTempEnts( void )
107107
{
108108
C_BaseTempEntity *next;
109-
C_BaseTempEntity *te = s_pDynamicEntities;
110-
while ( te )
109+
C_BaseTempEntity *tempEntity = s_pDynamicEntities;
110+
while ( tempEntity )
111111
{
112-
next = te->GetNextDynamic();
113-
delete te;
114-
te = next;
112+
next = tempEntity->GetNextDynamic();
113+
delete tempEntity;
114+
tempEntity = next;
115115
}
116116

117117
s_pDynamicEntities = NULL;
@@ -123,20 +123,20 @@ void C_BaseTempEntity::ClearDynamicTempEnts( void )
123123
void C_BaseTempEntity::CheckDynamicTempEnts( void )
124124
{
125125
C_BaseTempEntity *next, *newlist = NULL;
126-
C_BaseTempEntity *te = s_pDynamicEntities;
127-
while ( te )
126+
C_BaseTempEntity *tempEntity = s_pDynamicEntities;
127+
while ( tempEntity )
128128
{
129-
next = te->GetNextDynamic();
130-
if ( te->ShouldDestroy() )
129+
next = tempEntity->GetNextDynamic();
130+
if ( tempEntity->ShouldDestroy() )
131131
{
132-
delete te;
132+
delete tempEntity;
133133
}
134134
else
135135
{
136-
te->m_pNextDynamic = newlist;
137-
newlist = te;
136+
tempEntity->m_pNextDynamic = newlist;
137+
newlist = tempEntity;
138138
}
139-
te = next;
139+
tempEntity = next;
140140
}
141141

142142
s_pDynamicEntities = newlist;

src/game/client/c_env_projectedtexture.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,8 @@ void C_EnvProjectedTexture::UpdateLight( void )
312312

313313
NDebugOverlay::Box( vec3_origin, mins, maxs, 0, 255, 0, 100, 0.0f );
314314
#endif
315-
316-
bool bVisible = IsBBoxVisible( mins, maxs );
317-
if (!bVisible)
315+
316+
if ( !IsBBoxVisible( mins, maxs ) )
318317
{
319318
// Spotlight's extents aren't in view
320319
if ( m_LightHandle != CLIENTSHADOW_INVALID_HANDLE )

src/game/client/c_rope.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,10 +1618,10 @@ bool C_RopeKeyframe::CalculateEndPointAttachment( C_BaseEntity *pEnt, int iAttac
16181618
if ( !pModel )
16191619
return false;
16201620

1621-
int iAttachment = pModel->LookupAttachment( "buff_attach" );
1621+
int iBuffAttachment = pModel->LookupAttachment( "buff_attach" );
16221622
if ( pAngles )
1623-
return pModel->GetAttachment( iAttachment, vPos, *pAngles );
1624-
return pModel->GetAttachment( iAttachment, vPos );
1623+
return pModel->GetAttachment( iBuffAttachment, vPos, *pAngles );
1624+
return pModel->GetAttachment( iBuffAttachment, vPos );
16251625
}
16261626
}
16271627

src/game/client/c_sceneentity.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,9 +1106,9 @@ void C_SceneEntity::PrefetchAnimBlocks( CChoreoScene *pScene )
11061106
int nChecked = 0;
11071107

11081108
// Iterate events and precache necessary resources
1109-
for ( int i = 0; i < pScene->GetNumEvents(); i++ )
1109+
for ( int idx = 0; idx < pScene->GetNumEvents(); idx++ )
11101110
{
1111-
CChoreoEvent *pEvent = pScene->GetEvent( i );
1111+
CChoreoEvent *pEvent = pScene->GetEvent( idx );
11121112
if ( !pEvent )
11131113
continue;
11141114

@@ -1193,4 +1193,4 @@ void C_SceneEntity::PrefetchAnimBlocks( CChoreoScene *pScene )
11931193
return;
11941194

11951195
Msg( "%d of %d animations resident\n", nResident, nChecked );
1196-
}
1196+
}

src/game/client/clientshadowmgr.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,7 +1451,6 @@ CClientShadowMgr::CClientShadowMgr() :
14511451
//-----------------------------------------------------------------------------
14521452
CON_COMMAND_F( r_shadowdir, "Set shadow direction", FCVAR_CHEAT )
14531453
{
1454-
Vector dir;
14551454
if ( args.ArgC() == 1 )
14561455
{
14571456
Vector dir = s_ClientShadowMgr.GetShadowDirection();
@@ -1461,6 +1460,7 @@ CON_COMMAND_F( r_shadowdir, "Set shadow direction", FCVAR_CHEAT )
14611460

14621461
if ( args.ArgC() == 4 )
14631462
{
1463+
Vector dir;
14641464
dir.x = atof( args[1] );
14651465
dir.y = atof( args[2] );
14661466
dir.z = atof( args[3] );
@@ -1470,8 +1470,6 @@ CON_COMMAND_F( r_shadowdir, "Set shadow direction", FCVAR_CHEAT )
14701470

14711471
CON_COMMAND_F( r_shadowangles, "Set shadow angles", FCVAR_CHEAT )
14721472
{
1473-
Vector dir;
1474-
QAngle angles;
14751473
if (args.ArgC() == 1)
14761474
{
14771475
Vector dir = s_ClientShadowMgr.GetShadowDirection();
@@ -1483,6 +1481,8 @@ CON_COMMAND_F( r_shadowangles, "Set shadow angles", FCVAR_CHEAT )
14831481

14841482
if (args.ArgC() == 4)
14851483
{
1484+
Vector dir;
1485+
QAngle angles;
14861486
angles.x = atof( args[1] );
14871487
angles.y = atof( args[2] );
14881488
angles.z = atof( args[3] );
@@ -4336,9 +4336,9 @@ void CClientShadowMgr::UpdateDirtyShadows()
43364336

43374337
// Transparent shadows must remain dirty, since they were not re-projected
43384338
int nCount = m_TransparentShadows.Count();
4339-
for ( int i = 0; i < nCount; ++i )
4339+
for ( int j = 0; j < nCount; ++j )
43404340
{
4341-
m_DirtyShadows.Insert( m_TransparentShadows[i] );
4341+
m_DirtyShadows.Insert( m_TransparentShadows[j] );
43424342
}
43434343
m_TransparentShadows.RemoveAll();
43444344
}
@@ -4403,9 +4403,9 @@ void CClientShadowMgr::UpdateDirtyShadowsHalfRate()
44034403

44044404
// Transparent shadows must remain dirty, since they were not re-projected
44054405
int nCount = m_TransparentShadows.Count();
4406-
for ( int i = 0; i < nCount; ++i )
4406+
for ( int j = 0; j < nCount; ++j )
44074407
{
4408-
m_DirtyShadows.Insert( m_TransparentShadows[i] );
4408+
m_DirtyShadows.Insert( m_TransparentShadows[j] );
44094409
}
44104410
m_TransparentShadows.RemoveAll();
44114411
}

src/game/client/hud.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -875,11 +875,11 @@ bool CHud::LockRenderGroup( int iGroupIndex, CHudElement *pLocker /* = NULL */ )
875875
if ( !DoesRenderGroupExist(iGroupIndex) )
876876
return false;
877877

878-
int i = m_RenderGroups.Find( iGroupIndex );
878+
int idx = m_RenderGroups.Find( iGroupIndex );
879879

880-
Assert( m_RenderGroups.IsValidIndex(i) );
880+
Assert( m_RenderGroups.IsValidIndex(idx) );
881881

882-
CHudRenderGroup *group = m_RenderGroups.Element(i);
882+
CHudRenderGroup *group = m_RenderGroups.Element(idx);
883883

884884
Assert( group );
885885

@@ -924,11 +924,11 @@ bool CHud::UnlockRenderGroup( int iGroupIndex, CHudElement *pLocker /* = NULL */
924924
if ( !DoesRenderGroupExist(iGroupIndex) )
925925
return false;
926926

927-
int i = m_RenderGroups.Find( iGroupIndex );
927+
int idx = m_RenderGroups.Find( iGroupIndex );
928928

929-
Assert( m_RenderGroups.IsValidIndex(i) );
929+
Assert( m_RenderGroups.IsValidIndex(idx) );
930930

931-
CHudRenderGroup *group = m_RenderGroups.Element(i);
931+
CHudRenderGroup *group = m_RenderGroups.Element(idx);
932932

933933
if ( group )
934934
{

src/game/shared/achievementmgr.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,8 +1605,7 @@ void CAchievementMgr::Steam_OnUserStatsReceived( UserStatsReceived_t *pUserStats
16051605
int iValue;
16061606
char pszProgressName[1024];
16071607
Q_snprintf( pszProgressName, 1024, "%s_STAT", pAchievement->GetName() );
1608-
bool bRet = SteamUserStats()->GetStat( pszProgressName, &iValue );
1609-
if ( bRet )
1608+
if ( SteamUserStats()->GetStat( pszProgressName, &iValue ) )
16101609
{
16111610
pAchievement->SetCount( iValue );
16121611
}
@@ -1618,8 +1617,7 @@ void CAchievementMgr::Steam_OnUserStatsReceived( UserStatsReceived_t *pUserStats
16181617
if ( pAchievement->HasComponents() )
16191618
{
16201619
Q_snprintf( pszProgressName, 1024, "%s_COMP", pAchievement->GetName() );
1621-
bool bRet = SteamUserStats()->GetStat( pszProgressName, &iValue );
1622-
if ( bRet )
1620+
if ( SteamUserStats()->GetStat( pszProgressName, &iValue ) )
16231621
{
16241622
pAchievement->SetComponentBits( iValue );
16251623
}

0 commit comments

Comments
 (0)