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.

113 lines
2.9 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef LOCALNETWORKBACKDOOR_H
  7. #define LOCALNETWORKBACKDOOR_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "quakedef.h"
  12. #include "cl_localnetworkbackdoor.h"
  13. #include "icliententitylist.h"
  14. #include "LocalNetworkBackdoor.h"
  15. #include "iclientnetworkable.h"
  16. #include "basehandle.h"
  17. #include "client_class.h"
  18. #include "dt_localtransfer.h"
  19. #include "client.h"
  20. #include "cdll_engine_int.h"
  21. #include "datacache/imdlcache.h"
  22. #include "sys_dll.h"
  23. #include "utllinkedlist.h"
  24. #include "edict.h"
  25. #include "server.h"
  26. class SendTable;
  27. class CLocalNetworkBackdoor
  28. {
  29. public:
  30. void StartEntityStateUpdate();
  31. void EndEntityStateUpdate();
  32. void EntityDormant( int iEnt, int iSerialNum );
  33. void AddToPendingDormantEntityList( unsigned short iEdict );
  34. void ProcessDormantEntities();
  35. void NotifyEdictFlagsChange( int iEdict )
  36. {
  37. // If they newly added the dontsend flag, then we need to run it through EntityDormant.
  38. if ( sv.edicts[iEdict].m_fStateFlags & FL_EDICT_DONTSEND )
  39. AddToPendingDormantEntityList( iEdict );
  40. }
  41. void EntState(
  42. int iEnt,
  43. int iSerialNum,
  44. int iClass,
  45. const SendTable *pSendTable,
  46. const void *pSourceEnt,
  47. bool bChanged,
  48. bool bShouldTransmit );
  49. void ClearState();
  50. void StartBackdoorMode();
  51. void StopBackdoorMode();
  52. // Used by Foundry when it changes an entity (and possibly its class) but preserves its serial number.
  53. void ForceFlushEntity( int iEntity );
  54. // This is called when the client DLL is loaded to precalculate data to let it copy data faster.
  55. static void InitFastCopy();
  56. private:
  57. // Temporarily built up while processing a frame.
  58. CBitVec<MAX_EDICTS> m_EntsAlive;
  59. // This should correspond to which m_CachedEntState entries have a non-null m_pNetworkable pointer.
  60. CBitVec<MAX_EDICTS> m_PrevEntsAlive;
  61. // Entities that get created during a frame are remembered here.
  62. unsigned short m_EntsCreatedIndices[MAX_EDICTS];
  63. int m_nEntsCreated;
  64. // Entities that changed but weren't created go here.
  65. unsigned short m_EntsChangedIndices[MAX_EDICTS];
  66. int m_nEntsChanged;
  67. // Tell the client DLL about entities that need to be notified about being dormant.
  68. // Anything that EntityDormant() would care about needs to get added to this list.
  69. CUtlLinkedList<unsigned short,unsigned short> m_PendingDormantEntities;
  70. // This data is cached in here so we don't have to call a lot of virtuals to get it from the client DLL.
  71. class CCachedEntState
  72. {
  73. public:
  74. CCachedEntState()
  75. {
  76. m_iSerialNumber = -1;
  77. }
  78. bool m_bDormant;
  79. int m_iSerialNumber;
  80. void *m_pDataPointer;
  81. IClientNetworkable *m_pNetworkable;
  82. };
  83. CCachedEntState m_CachedEntState[MAX_EDICTS];
  84. };
  85. // The client will set this if it decides to use the fast path.
  86. extern CLocalNetworkBackdoor *g_pLocalNetworkBackdoor;
  87. #endif // LOCALNETWORKBACKDOOR_H