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.

97 lines
2.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #include "cbase.h"
  7. #include "tfc_gamerules.h"
  8. #include "tfc_player_shared.h"
  9. #include "takedamageinfo.h"
  10. #include "weapon_tfcbase.h"
  11. #ifdef CLIENT_DLL
  12. #include "c_tfc_player.h"
  13. BEGIN_RECV_TABLE_NOBASE( CTFCPlayerShared, DT_TFCPlayerShared )
  14. RecvPropInt( RECVINFO( m_iPlayerClass ) ),
  15. RecvPropInt( RECVINFO( m_iPlayerState ) ),
  16. RecvPropInt( RECVINFO( m_StateFlags ) ),
  17. RecvPropInt( RECVINFO( m_ItemFlags ) )
  18. END_RECV_TABLE()
  19. BEGIN_PREDICTION_DATA_NO_BASE( CTFCPlayerShared )
  20. DEFINE_PRED_FIELD( m_iPlayerState, FIELD_INTEGER, FTYPEDESC_INSENDTABLE )
  21. END_PREDICTION_DATA()
  22. #else
  23. #include "tfc_player.h"
  24. BEGIN_SEND_TABLE_NOBASE( CTFCPlayerShared, DT_TFCPlayerShared )
  25. SendPropInt( SENDINFO(m_iPlayerClass), NumBitsForCount( PC_LASTCLASS+1 ), SPROP_UNSIGNED ),
  26. SendPropInt( SENDINFO(m_iPlayerState), NumBitsForCount( TFC_NUM_PLAYER_STATES ), SPROP_UNSIGNED ),
  27. SendPropInt( SENDINFO(m_StateFlags) , NumBitsForCount( TFSTATE_HIGHEST_VALUE+1 ), SPROP_UNSIGNED ),
  28. SendPropInt( SENDINFO(m_StateFlags) , NumBitsForCount( IT_LAST_ITEM+1 ), SPROP_UNSIGNED )
  29. END_SEND_TABLE()
  30. #endif
  31. // --------------------------------------------------------------------------------------------------- //
  32. // Shared CTFCPlayer implementation.
  33. // --------------------------------------------------------------------------------------------------- //
  34. // --------------------------------------------------------------------------------------------------- //
  35. // CTFCPlayerShared implementation.
  36. // --------------------------------------------------------------------------------------------------- //
  37. CTFCPlayerShared::CTFCPlayerShared()
  38. {
  39. m_iPlayerClass = PC_UNDEFINED;
  40. m_iPlayerState = STATE_WELCOME;
  41. }
  42. void CTFCPlayerShared::Init( CTFCPlayer *pPlayer )
  43. {
  44. m_pOuter = pPlayer;
  45. }
  46. void CTFCPlayerShared::SetPlayerClass( int playerclass )
  47. {
  48. m_iPlayerClass = playerclass;
  49. }
  50. int CTFCPlayerShared::GetPlayerClass() const
  51. {
  52. return m_iPlayerClass;
  53. }
  54. TFCPlayerState CTFCPlayerShared::State_Get() const
  55. {
  56. return m_iPlayerState;
  57. }
  58. CWeaponTFCBase* CTFCPlayerShared::GetActiveTFCWeapon() const
  59. {
  60. CBaseCombatWeapon *pRet = m_pOuter->GetActiveWeapon();
  61. if ( pRet )
  62. {
  63. Assert( dynamic_cast< CWeaponTFCBase* >( pRet ) != NULL );
  64. return static_cast< CWeaponTFCBase * >( pRet );
  65. }
  66. else
  67. {
  68. return NULL;
  69. }
  70. }