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.

111 lines
2.8 KiB

  1. //========= Copyright 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. // This is called when the client DLL is loaded to precalculate data to let it copy data faster.
  53. static void InitFastCopy();
  54. private:
  55. // Temporarily built up while processing a frame.
  56. CBitVec<MAX_EDICTS> m_EntsAlive;
  57. // This should correspond to which m_CachedEntState entries have a non-null m_pNetworkable pointer.
  58. CBitVec<MAX_EDICTS> m_PrevEntsAlive;
  59. // Entities that get created during a frame are remembered here.
  60. unsigned short m_EntsCreatedIndices[MAX_EDICTS];
  61. int m_nEntsCreated;
  62. // Entities that changed but weren't created go here.
  63. unsigned short m_EntsChangedIndices[MAX_EDICTS];
  64. int m_nEntsChanged;
  65. // Tell the client DLL about entities that need to be notified about being dormant.
  66. // Anything that EntityDormant() would care about needs to get added to this list.
  67. CUtlLinkedList<unsigned short,unsigned short> m_PendingDormantEntities;
  68. // This data is cached in here so we don't have to call a lot of virtuals to get it from the client DLL.
  69. class CCachedEntState
  70. {
  71. public:
  72. CCachedEntState()
  73. {
  74. m_iSerialNumber = -1;
  75. }
  76. bool m_bDormant;
  77. int m_iSerialNumber;
  78. void *m_pDataPointer;
  79. IClientNetworkable *m_pNetworkable;
  80. };
  81. CCachedEntState m_CachedEntState[MAX_EDICTS];
  82. };
  83. // The client will set this if it decides to use the fast path.
  84. extern CLocalNetworkBackdoor *g_pLocalNetworkBackdoor;
  85. #endif // LOCALNETWORKBACKDOOR_H