Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.7 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: DOD's custom CPlayerResource
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "cbase.h"
  8. #include "dod_player.h"
  9. #include "player_resource.h"
  10. #include "dod_player_resource.h"
  11. #include <coordsize.h>
  12. // Datatable
  13. IMPLEMENT_SERVERCLASS_ST(CDODPlayerResource, DT_DODPlayerResource)
  14. SendPropArray3( SENDINFO_ARRAY3(m_iObjScore), SendPropInt( SENDINFO_ARRAY(m_iObjScore), 12 ) ),
  15. SendPropArray3( SENDINFO_ARRAY3(m_iPlayerClass), SendPropInt( SENDINFO_ARRAY(m_iPlayerClass), 4 ) ),
  16. END_SEND_TABLE()
  17. BEGIN_DATADESC( CDODPlayerResource )
  18. // DEFINE_ARRAY( m_iObjScore, FIELD_INTEGER, MAX_PLAYERS+1 ),
  19. // DEFINE_ARRAY( m_iPlayerClass, FIELD_INTEGER, MAX_PLAYERS+1 ),
  20. END_DATADESC()
  21. LINK_ENTITY_TO_CLASS( dod_player_manager, CDODPlayerResource );
  22. CDODPlayerResource::CDODPlayerResource( void )
  23. {
  24. }
  25. //-----------------------------------------------------------------------------
  26. // Purpose:
  27. //-----------------------------------------------------------------------------
  28. void CDODPlayerResource::UpdatePlayerData( void )
  29. {
  30. int i;
  31. for ( i = 1; i <= gpGlobals->maxClients; i++ )
  32. {
  33. CDODPlayer *pPlayer = (CDODPlayer*)UTIL_PlayerByIndex( i );
  34. if ( pPlayer && pPlayer->IsConnected() )
  35. {
  36. m_iObjScore.Set( i, pPlayer->GetScore() );
  37. m_iPlayerClass.Set( i, pPlayer->m_Shared.PlayerClass() );
  38. }
  39. }
  40. BaseClass::UpdatePlayerData();
  41. }
  42. void CDODPlayerResource::Spawn( void )
  43. {
  44. int i;
  45. for ( i=0; i < MAX_PLAYERS+1; i++ )
  46. {
  47. m_iObjScore.Set( i, 0 );
  48. m_iPlayerClass.Set( i, PLAYERCLASS_UNDEFINED );
  49. }
  50. BaseClass::Spawn();
  51. }