Skip to content

Commit 98ecbad

Browse files
committed
bitwise operator saga begins
1 parent ac8e092 commit 98ecbad

4 files changed

Lines changed: 10 additions & 8 deletions

File tree

src/game/client/swarm/c_asw_player.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ class C_ASW_Player : public C_BasePlayer, public IASWPlayerAnimStateHelpers
146146
CInterpolatedVar< QAngle > m_iv_angEyeAngles;
147147
CNetworkHandle( C_ASW_Inhabitable_NPC, m_hInhabiting ); // our currently controlled marine
148148
CNetworkHandle( C_ASW_Inhabitable_NPC, m_hSpectating ); // the marine we're spectating when dead
149-
CNetworkVar( int, m_iSpectatorIndexes );
149+
CNetworkVar( unsigned int, m_iSpectatorIndexes );
150150
const Vector& GetCrosshairTracePos() { return m_vecCrosshairTracePos; }
151151
void SetCrosshairTracePos( const Vector &vecPos ) { m_vecCrosshairTracePos = vecPos; }
152152
Vector m_vecCrosshairTracePos; // the world location directly beneath the player's crosshair

src/game/client/vgui_fpspanel.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -537,19 +537,18 @@ void CFPSPanel::Paint()
537537
i += 3;
538538

539539
int nSpecCount = 0;
540-
for ( int id = 1; id < 31; id += 1 )
540+
for ( int id = 1; id <= 32; id += 1 )
541541
{
542542
if ( !g_PR->IsConnected( id ) )
543543
continue;
544544

545545
if ( g_PR->IsFakePlayer( id ) )
546546
continue;
547547

548-
if ( !( pPlayer->m_iSpectatorIndexes.Get() & static_cast<int>( pow( 2, id ) ) ) )
548+
if ( !( pPlayer->m_iSpectatorIndexes.Get() & ( 1u << id ) ) )
549549
continue;
550550

551551
nSpecCount++;
552-
553552
i++;
554553

555554
char szSpecName[k_cchPersonaNameMax] = { 0 };
@@ -560,7 +559,10 @@ void CFPSPanel::Paint()
560559
}
561560

562561
if ( nSpecCount == 0 )
562+
{
563+
i -= 3;
563564
break;
565+
}
564566

565567
char szName[k_cchPersonaNameMax] = { 0 };
566568
Q_strncpy( szName, pPlayer->GetPlayerName(), sizeof( szName ) );

src/game/server/swarm/asw_player.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2218,11 +2218,11 @@ void CASW_Player::SpectateNextMarine()
22182218

22192219
void CASW_Player::SetSpectatingNPC( CASW_Inhabitable_NPC *pSpectating )
22202220
{
2221-
int nOwnIndex = pow( 2, GetClientIndex() + 1 );
2221+
unsigned int nOwnIndex = 1u << ( GetClientIndex() + 1 );
22222222
CASW_Inhabitable_NPC *pSpectatingPrevious = GetSpectatingNPC();
22232223
if ( pSpectatingPrevious && pSpectatingPrevious->GetCommander() )
22242224
{
2225-
pSpectatingPrevious->GetCommander()->m_iSpectatorIndexes -= nOwnIndex;
2225+
pSpectatingPrevious->GetCommander()->m_iSpectatorIndexes &=~ nOwnIndex;
22262226
}
22272227

22282228
m_hSpectating = pSpectating;
@@ -2234,7 +2234,7 @@ void CASW_Player::SetSpectatingNPC( CASW_Inhabitable_NPC *pSpectating )
22342234
if ( !pPlayer )
22352235
return;
22362236

2237-
pPlayer->m_iSpectatorIndexes += nOwnIndex;
2237+
pPlayer->m_iSpectatorIndexes |= nOwnIndex;
22382238
}
22392239

22402240
CASW_Inhabitable_NPC *CASW_Player::GetSpectatingNPC() const

src/game/server/swarm/asw_player.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class CASW_Player : public CBaseMultiplayerPlayer, public IASWPlayerAnimStateHel
9191
CASW_Inhabitable_NPC *GetSpectatingNPC() const;
9292
HSCRIPT ScriptGetSpectatingNPC() const;
9393
CNetworkHandle( CASW_Inhabitable_NPC, m_hSpectating );
94-
CNetworkVar( int, m_iSpectatorIndexes );
94+
CNetworkVar( unsigned int, m_iSpectatorIndexes );
9595
bool m_bLastAttackButton; // used to detect left clicks for cycling through marines
9696
bool m_bLastAttack2Button; // used to detect right clicks for cycling through marines
9797
bool m_bRequestedSpectator; // this player requested to be a spectator since the start of a match (won't be considered for leader, campaign votes, etc.)

0 commit comments

Comments
 (0)