Skip to content

Commit 95594dc

Browse files
committed
game/client: Partially use x86-64 indexes in base entity
1 parent c3acb0b commit 95594dc

File tree

1 file changed

+17
-32
lines changed

1 file changed

+17
-32
lines changed

game/client/c_baseentity.cpp

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ END_PREDICTION_DATA()
577577
void SpewInterpolatedVar( CInterpolatedVar< Vector > *pVar )
578578
{
579579
Msg( "--------------------------------------------------\n" );
580-
int i = pVar->GetHead();
580+
intp i = pVar->GetHead();
581581
Vector v0(0, 0, 0);
582582
CApparentVelocity<Vector> apparent(v0);
583583
float prevtime = 0.0f;
@@ -601,7 +601,7 @@ void SpewInterpolatedVar( CInterpolatedVar< Vector > *pVar, float flNow, float f
601601
float target = flNow - flInterpAmount;
602602

603603
Msg( "--------------------------------------------------\n" );
604-
int i = pVar->GetHead();
604+
intp i = pVar->GetHead();
605605
Vector v0(0, 0, 0);
606606
CApparentVelocity<Vector> apparent(v0);
607607
float newtime = 999999.0f;
@@ -631,8 +631,7 @@ void SpewInterpolatedVar( CInterpolatedVar< Vector > *pVar, float flNow, float f
631631
else
632632
{
633633
bSpew = true;
634-
int savei = i;
635-
i = pVar->GetNext( i );
634+
intp savei = std::exchange(i, pVar->GetNext( i ));
636635
float oldtertime = 0.0f;
637636
pVar->GetHistoryValue( i, oldtertime );
638637

@@ -670,7 +669,7 @@ void SpewInterpolatedVar( CInterpolatedVar< Vector > *pVar, float flNow, float f
670669
void SpewInterpolatedVar( CInterpolatedVar< float > *pVar )
671670
{
672671
Msg( "--------------------------------------------------\n" );
673-
int i = pVar->GetHead();
672+
intp i = pVar->GetHead();
674673
CApparentVelocity<float> apparent(0.0f);
675674
while ( 1 )
676675
{
@@ -692,7 +691,7 @@ void GetInterpolatedVarTimeRange( CInterpolatedVar<T> *pVar, float &flMin, float
692691
flMin = 1e23;
693692
flMax = -1e23;
694693

695-
int i = pVar->GetHead();
694+
intp i = pVar->GetHead();
696695
Vector v0(0, 0, 0);
697696
CApparentVelocity<Vector> apparent(v0);
698697
while ( 1 )
@@ -802,13 +801,11 @@ void C_BaseEntity::Interp_SetupMappings( VarMapping_t *map )
802801
if( !map )
803802
return;
804803

805-
int c = map->m_Entries.Count();
806-
for ( int i = 0; i < c; i++ )
804+
for ( auto &e : map->m_Entries )
807805
{
808-
VarMapEntry_t *e = &map->m_Entries[ i ];
809-
IInterpolatedVar *watcher = e->watcher;
810-
void *data = e->data;
811-
int type = e->type;
806+
IInterpolatedVar *watcher = e.watcher;
807+
void *data = e.data;
808+
int type = e.type;
812809

813810
watcher->Setup( data, type );
814811
watcher->SetInterpolationAmount( GetInterpolationAmount( watcher->GetType() ) );
@@ -825,11 +822,9 @@ void C_BaseEntity::Interp_RestoreToLastNetworked( VarMapping_t *map )
825822
QAngle oldAngles = GetLocalAngles();
826823
Vector oldVel = GetLocalVelocity();
827824

828-
int c = map->m_Entries.Count();
829-
for ( int i = 0; i < c; i++ )
825+
for ( auto &e : map->m_Entries )
830826
{
831-
VarMapEntry_t *e = &map->m_Entries[ i ];
832-
IInterpolatedVar *watcher = e->watcher;
827+
IInterpolatedVar *watcher = e.watcher;
833828
watcher->RestoreToLastNetworked();
834829
}
835830

@@ -841,11 +836,9 @@ void C_BaseEntity::Interp_UpdateInterpolationAmounts( VarMapping_t *map )
841836
if( !map )
842837
return;
843838

844-
int c = map->m_Entries.Count();
845-
for ( int i = 0; i < c; i++ )
839+
for ( auto &e : map->m_Entries )
846840
{
847-
VarMapEntry_t *e = &map->m_Entries[ i ];
848-
IInterpolatedVar *watcher = e->watcher;
841+
IInterpolatedVar *watcher = e.watcher;
849842
watcher->SetInterpolationAmount( GetInterpolationAmount( watcher->GetType() ) );
850843
}
851844
}
@@ -2272,11 +2265,8 @@ void C_BaseEntity::MarkAimEntsDirty()
22722265
// will cause the aim-ent's (and all its children's) dirty state to be correctly updated.
22732266
//
22742267
// Then we will iterate over the loop a second time and call CalcAbsPosition on them,
2275-
int i;
2276-
int c = g_AimEntsList.Count();
2277-
for ( i = 0; i < c; ++i )
2268+
for ( auto *pEnt : g_AimEntsList )
22782269
{
2279-
C_BaseEntity *pEnt = g_AimEntsList[ i ];
22802270
Assert( pEnt && pEnt->GetMoveParent() );
22812271
if ( pEnt->IsEffectActive(EF_BONEMERGE | EF_PARENT_ANIMATES) )
22822272
{
@@ -2289,11 +2279,8 @@ void C_BaseEntity::MarkAimEntsDirty()
22892279
void C_BaseEntity::CalcAimEntPositions()
22902280
{
22912281
VPROF("CalcAimEntPositions");
2292-
int i;
2293-
int c = g_AimEntsList.Count();
2294-
for ( i = 0; i < c; ++i )
2282+
for ( auto *pEnt : g_AimEntsList )
22952283
{
2296-
C_BaseEntity *pEnt = g_AimEntsList[ i ];
22972284
Assert( pEnt );
22982285
Assert( pEnt->GetMoveParent() );
22992286
if ( pEnt->IsEffectActive(EF_BONEMERGE) )
@@ -5860,11 +5847,9 @@ void C_BaseEntity::EstimateAbsVelocity( Vector& vel )
58605847
void C_BaseEntity::Interp_Reset( VarMapping_t *map )
58615848
{
58625849
PREDICTION_TRACKVALUECHANGESCOPE_ENTITY( this, "reset" );
5863-
int c = map->m_Entries.Count();
5864-
for ( int i = 0; i < c; i++ )
5850+
for ( auto &e : map->m_Entries )
58655851
{
5866-
VarMapEntry_t *e = &map->m_Entries[ i ];
5867-
IInterpolatedVar *watcher = e->watcher;
5852+
IInterpolatedVar *watcher = e.watcher;
58685853

58695854
watcher->Reset();
58705855
}

0 commit comments

Comments
 (0)