Counter Strike : Global Offensive Source Code
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.

78 lines
2.0 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef PREDICTABLEID_H
  8. #define PREDICTABLEID_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #if defined( USE_PREDICTABLEID )
  13. #if !defined( NO_ENTITY_PREDICTION )
  14. //-----------------------------------------------------------------------------
  15. // Purpose: Wraps 32bit predictID to allow access and creation
  16. //-----------------------------------------------------------------------------
  17. class CPredictableId
  18. {
  19. public:
  20. // Construction
  21. CPredictableId( void );
  22. static void ResetInstanceCounters( void );
  23. // Is the Id being used
  24. bool IsActive( void ) const;
  25. // Call this to set from data
  26. void Init( int player, int command, const char *classname, const char *module, int line );
  27. // Get player index
  28. int GetPlayer( void ) const;
  29. // Get hash value
  30. int GetHash( void ) const;
  31. // Get index number
  32. int GetInstanceNumber( void ) const;
  33. // Get command number
  34. int GetCommandNumber( void ) const;
  35. // Check command number
  36. // bool IsCommandNumberEqual( int testNumber ) const;
  37. // Client only
  38. void SetAcknowledged( bool ack );
  39. bool GetAcknowledged( void ) const;
  40. // For conversion to/from integer
  41. int GetRaw( void ) const;
  42. void SetRaw( int raw );
  43. char const *Describe( void ) const;
  44. // Equality test
  45. bool operator ==( const CPredictableId& other ) const;
  46. bool operator !=( const CPredictableId& other ) const;
  47. private:
  48. void SetCommandNumber( int commandNumber );
  49. void SetPlayer( int playerIndex );
  50. void SetInstanceNumber( int counter );
  51. // Encoding bits, should total 32
  52. struct bitfields
  53. {
  54. unsigned int ack : 1; // 1
  55. unsigned int player : 5; // 6
  56. unsigned int command : 10; // 16
  57. unsigned int hash : 12; // 28
  58. unsigned int instance : 4; // 32
  59. } m_PredictableID;
  60. };
  61. #endif
  62. #else
  63. typedef void *CPredictableId;
  64. #endif // USE_PREDICTABLEID
  65. #endif // PREDICTABLEID_H