|
19 | 19 | #include "../common/xbox/xboxstubs.h" |
20 | 20 | #ifdef INFESTED_DLL |
21 | 21 | #include "c_asw_player.h" |
| 22 | +#include "c_playerresource.h" |
22 | 23 | #include "c_asw_inhabitable_npc.h" |
23 | 24 | #endif |
24 | 25 |
|
|
27 | 28 |
|
28 | 29 | static ConVar cl_showfps( "cl_showfps", "0", FCVAR_RELEASE, "Draw fps meter at top of screen (1 = fps, 2 = smooth fps, 3 = server MS, 4 = Show FPS and Log to file )" ); |
29 | 30 | static ConVar cl_showpos( "cl_showpos", "0", FCVAR_RELEASE, "Draw current position at top of screen (1 = eyes, 2 = feet)" ); |
| 31 | +static ConVar cl_showspectators( "cl_showspectators", "0", FCVAR_RELEASE, "Draw a list of spectators" ); |
30 | 32 | #ifdef INFESTED_DLL |
31 | 33 | static ConVar cl_showpos_npc( "cl_showpos_npc", "-1", FCVAR_NONE, "If the player is controlling or spectating an NPC, use the NPC's position, angles, and velocity instead; -1 = 1 if asw_allow_detach is 0, 0 otherwise" ); |
32 | 34 | extern ConVar asw_allow_detach; |
@@ -184,7 +186,8 @@ bool CFPSPanel::ShouldDraw( void ) |
184 | 186 | if ( g_bDisplayParticlePerformance ) |
185 | 187 | return true; |
186 | 188 | if ( ( !cl_showfps.GetInt() || ( gpGlobals->absoluteframetime <= 0 ) ) && |
187 | | - ( !cl_showpos.GetInt() ) ) |
| 189 | + ( !cl_showpos.GetInt() ) && |
| 190 | + ( !cl_showspectators.GetInt() ) ) |
188 | 191 | { |
189 | 192 | m_bLastDraw = false; |
190 | 193 | return false; |
@@ -278,12 +281,12 @@ void CFPSPanel::Paint() |
278 | 281 |
|
279 | 282 | float flTotalTime = 0.0f; |
280 | 283 | float flPeakTime = 0.0f; |
281 | | - for ( int i = 0; i < SERVER_TIME_HISTORY; ++i ) |
| 284 | + for ( int j = 0; j < SERVER_TIME_HISTORY; ++j ) |
282 | 285 | { |
283 | | - flTotalTime += m_pServerTimes[i]; |
284 | | - if ( flPeakTime < m_pServerTimes[i] ) |
| 286 | + flTotalTime += m_pServerTimes[j]; |
| 287 | + if ( flPeakTime < m_pServerTimes[j] ) |
285 | 288 | { |
286 | | - flPeakTime = m_pServerTimes[i]; |
| 289 | + flPeakTime = m_pServerTimes[j]; |
287 | 290 | } |
288 | 291 | } |
289 | 292 | flTotalTime /= SERVER_TIME_HISTORY; |
@@ -517,6 +520,59 @@ void CFPSPanel::Paint() |
517 | 520 | } |
518 | 521 | } |
519 | 522 |
|
| 523 | + if ( cl_showspectators.GetInt() ) |
| 524 | + { |
| 525 | + FOR_EACH_VALID_SPLITSCREEN_PLAYER( hh ) |
| 526 | + { |
| 527 | + C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer( hh ); |
| 528 | + if ( !pPlayer ) |
| 529 | + continue; |
| 530 | + |
| 531 | + C_ASW_Inhabitable_NPC *pSpectating = pPlayer->m_hSpectating; |
| 532 | + if ( pSpectating && pSpectating->GetCommander() ) |
| 533 | + { |
| 534 | + pPlayer = pSpectating->GetCommander(); |
| 535 | + } |
| 536 | + |
| 537 | + i += 3; |
| 538 | + |
| 539 | + int nSpecCount = 0; |
| 540 | + for ( int id = 1; id <= 32; id += 1 ) |
| 541 | + { |
| 542 | + if ( !g_PR->IsConnected( id ) ) |
| 543 | + continue; |
| 544 | + |
| 545 | + if ( g_PR->IsFakePlayer( id ) ) |
| 546 | + continue; |
| 547 | + |
| 548 | + if ( !( pPlayer->m_iSpectatorIndexes.Get() & ( 1u << id ) ) ) |
| 549 | + continue; |
| 550 | + |
| 551 | + nSpecCount++; |
| 552 | + i++; |
| 553 | + |
| 554 | + char szSpecName[k_cchPersonaNameMax] = { 0 }; |
| 555 | + Q_strncpy( szSpecName, g_PR->GetPlayerName( id ), sizeof( szSpecName ) ); |
| 556 | + g_pMatSystemSurface->DrawColoredText( m_hFont, x, 2 + i * lineHeight, |
| 557 | + 255, 255, 255, 255, |
| 558 | + " %s", szSpecName ); |
| 559 | + } |
| 560 | + |
| 561 | + if ( nSpecCount == 0 ) |
| 562 | + { |
| 563 | + i -= 3; |
| 564 | + break; |
| 565 | + } |
| 566 | + |
| 567 | + char szName[k_cchPersonaNameMax] = { 0 }; |
| 568 | + Q_strncpy( szName, pPlayer->GetPlayerName(), sizeof( szName ) ); |
| 569 | + |
| 570 | + g_pMatSystemSurface->DrawColoredText( m_hFont, x, 2 + ( i - nSpecCount ) * lineHeight, |
| 571 | + 255, 255, 255, 255, |
| 572 | + "Spectating %s (%d):", szName, nSpecCount ); |
| 573 | + } |
| 574 | + } |
| 575 | + |
520 | 576 | if ( m_nLinesNeeded != i ) |
521 | 577 | { |
522 | 578 | m_nLinesNeeded = i; |
|
0 commit comments