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.

80 lines
2.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "cbase.h"
  8. #include "c_baseentity.h"
  9. // memdbgon must be the last include file in a .cpp file!!!
  10. #include "tier0/memdbgon.h"
  11. class C_Test_ProxyToggle_Networkable;
  12. static C_Test_ProxyToggle_Networkable *g_pTestObj = 0;
  13. // ---------------------------------------------------------------------------------------- //
  14. // C_Test_ProxyToggle_Networkable
  15. // ---------------------------------------------------------------------------------------- //
  16. class C_Test_ProxyToggle_Networkable : public C_BaseEntity
  17. {
  18. public:
  19. DECLARE_CLASS( C_Test_ProxyToggle_Networkable, C_BaseEntity );
  20. DECLARE_CLIENTCLASS();
  21. C_Test_ProxyToggle_Networkable()
  22. {
  23. g_pTestObj = this;
  24. }
  25. ~C_Test_ProxyToggle_Networkable()
  26. {
  27. g_pTestObj = 0;
  28. }
  29. int m_WithProxy;
  30. };
  31. // ---------------------------------------------------------------------------------------- //
  32. // Datatables.
  33. // ---------------------------------------------------------------------------------------- //
  34. BEGIN_RECV_TABLE_NOBASE( C_Test_ProxyToggle_Networkable, DT_ProxyToggle_ProxiedData )
  35. RecvPropInt( RECVINFO( m_WithProxy ) )
  36. END_RECV_TABLE()
  37. IMPLEMENT_CLIENTCLASS_DT( C_Test_ProxyToggle_Networkable, DT_ProxyToggle, CTest_ProxyToggle_Networkable )
  38. RecvPropDataTable( "blah", 0, 0, &REFERENCE_RECV_TABLE( DT_ProxyToggle_ProxiedData ) )
  39. END_RECV_TABLE()
  40. // ---------------------------------------------------------------------------------------- //
  41. // Console commands.
  42. // ---------------------------------------------------------------------------------------- //
  43. // The engine uses this to get the current value.
  44. CON_COMMAND_F( Test_ProxyToggle_EnsureValue, "Test_ProxyToggle_EnsureValue", FCVAR_CHEAT )
  45. {
  46. if ( args.ArgC() < 2 )
  47. {
  48. Error( "Test_ProxyToggle_EnsureValue: requires value parameter." );
  49. }
  50. else if ( !g_pTestObj )
  51. {
  52. Error( "Test_ProxyToggle_EnsureValue: object doesn't exist on the client." );
  53. }
  54. int wantedValue = atoi( args[ 1 ] );
  55. if ( g_pTestObj->m_WithProxy != wantedValue )
  56. {
  57. Error( "Test_ProxyToggle_EnsureValue: value (%d) doesn't match wanted value (%d).", g_pTestObj->m_WithProxy, wantedValue );
  58. }
  59. }