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.

110 lines
2.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef ENTS_SHARED_H
  7. #define ENTS_SHARED_H
  8. #include <protocol.h>
  9. #include <iserver.h>
  10. #include "clientframe.h"
  11. #include "packed_entity.h"
  12. #ifdef _WIN32
  13. #pragma once
  14. #endif
  15. class CEntityInfo
  16. {
  17. public:
  18. CEntityInfo() {
  19. m_nOldEntity = -1;
  20. m_nNewEntity = -1;
  21. m_nHeaderBase = -1;
  22. }
  23. virtual ~CEntityInfo() {};
  24. bool m_bAsDelta;
  25. CClientFrame *m_pFrom;
  26. CClientFrame *m_pTo;
  27. UpdateType m_UpdateType;
  28. int m_nOldEntity; // current entity index in m_pFrom
  29. int m_nNewEntity; // current entity index in m_pTo
  30. int m_nHeaderBase;
  31. int m_nHeaderCount;
  32. inline void NextOldEntity( void )
  33. {
  34. if ( m_pFrom )
  35. {
  36. m_nOldEntity = m_pFrom->transmit_entity.FindNextSetBit( m_nOldEntity+1 );
  37. if ( m_nOldEntity < 0 )
  38. {
  39. // Sentinel/end of list....
  40. m_nOldEntity = ENTITY_SENTINEL;
  41. }
  42. }
  43. else
  44. {
  45. m_nOldEntity = ENTITY_SENTINEL;
  46. }
  47. }
  48. inline void NextNewEntity( void )
  49. {
  50. m_nNewEntity = m_pTo->transmit_entity.FindNextSetBit( m_nNewEntity+1 );
  51. if ( m_nNewEntity < 0 )
  52. {
  53. // Sentinel/end of list....
  54. m_nNewEntity = ENTITY_SENTINEL;
  55. }
  56. }
  57. };
  58. // PostDataUpdate calls are stored in a list until all ents have been updated.
  59. class CPostDataUpdateCall
  60. {
  61. public:
  62. int m_iEnt;
  63. DataUpdateType_t m_UpdateType;
  64. };
  65. // Passed around the read functions.
  66. class CEntityReadInfo : public CEntityInfo
  67. {
  68. public:
  69. CEntityReadInfo()
  70. { m_nPostDataUpdateCalls = 0;
  71. m_nLocalPlayerBits = 0;
  72. m_nOtherPlayerBits = 0;
  73. m_UpdateType = PreserveEnt;
  74. }
  75. bf_read *m_pBuf;
  76. int m_UpdateFlags; // from the subheader
  77. bool m_bIsEntity;
  78. int m_nBaseline; // what baseline index do we use (0/1)
  79. bool m_bUpdateBaselines; // update baseline while parsing snaphsot
  80. int m_nLocalPlayerBits; // profiling data
  81. int m_nOtherPlayerBits; // profiling data
  82. CPostDataUpdateCall m_PostDataUpdateCalls[MAX_EDICTS];
  83. int m_nPostDataUpdateCalls;
  84. };
  85. #endif // ENTS_SHARED_H