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.

97 lines
2.1 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef PRECACHE_H
  8. #define PRECACHE_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "networkstringtabledefs.h"
  13. #define PRECACHE_USER_DATA_NUMBITS 2 // Only network two bits from flags field...
  14. #pragma pack(1)
  15. //-----------------------------------------------------------------------------
  16. // Purpose:
  17. //-----------------------------------------------------------------------------
  18. struct CPrecacheUserData
  19. {
  20. unsigned char flags : PRECACHE_USER_DATA_NUMBITS;
  21. };
  22. #pragma pack()
  23. class CSfxTable;
  24. struct model_t;
  25. //#define DEBUG_PRECACHE 1
  26. //-----------------------------------------------------------------------------
  27. // Purpose:
  28. //-----------------------------------------------------------------------------
  29. class CPrecacheItem
  30. {
  31. public:
  32. CPrecacheItem( void );
  33. // accessorts
  34. model_t *GetModel( void );
  35. char const *GetGeneric( void );
  36. CSfxTable *GetSound( void );
  37. char const *GetName( void );
  38. char const *GetDecal( void );
  39. void SetModel( model_t const *pmodel );
  40. void SetGeneric( char const *pname );
  41. void SetSound( CSfxTable const *psound );
  42. void SetName( char const *pname );
  43. void SetDecal( char const *decalname );
  44. float GetFirstReference( void );
  45. float GetMostRecentReference( void );
  46. unsigned int GetReferenceCount( void );
  47. private:
  48. enum
  49. {
  50. TYPE_UNK = 0,
  51. TYPE_MODEL,
  52. TYPE_SOUND,
  53. TYPE_GENERIC,
  54. TYPE_DECAL
  55. };
  56. void Init( int type, void const *ptr );
  57. void ResetStats( void );
  58. void Reference( void );
  59. unsigned int m_nType : 3;
  60. unsigned int m_uiRefcount : 29;
  61. union precacheptr
  62. {
  63. model_t *model;
  64. char const *generic;
  65. CSfxTable *sound;
  66. char const *name;
  67. } u;
  68. #if DEBUG_PRECACHE
  69. float m_flFirst;
  70. float m_flMostRecent;
  71. #endif
  72. };
  73. #define MODEL_PRECACHE_TABLENAME "modelprecache"
  74. #define GENERIC_PRECACHE_TABLENAME "genericprecache"
  75. #define SOUND_PRECACHE_TABLENAME "soundprecache"
  76. #define DECAL_PRECACHE_TABLENAME "decalprecache"
  77. char const *GetFlagString( int flags );
  78. #endif // PRECACHE_H