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.

122 lines
3.1 KiB

  1. //========= Copyright (c) 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef ISERVERNETWORKABLE_H
  8. #define ISERVERNETWORKABLE_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "ihandleentity.h"
  13. #include "basetypes.h"
  14. #include "bitvec.h"
  15. #include "const.h"
  16. #include "bspfile.h"
  17. // Entities can span this many clusters before we revert to a slower area checking algorithm
  18. #define MAX_FAST_ENT_CLUSTERS 4
  19. #define MAX_ENT_CLUSTERS 64
  20. #define MAX_WORLD_AREAS 8
  21. class ServerClass;
  22. class SendTable;
  23. struct edict_t;
  24. class CBaseEntity;
  25. class CSerialEntity;
  26. class CBaseNetworkable;
  27. class CCheckTransmitInfo
  28. {
  29. public:
  30. edict_t *m_pClientEnt; // pointer to receiver edict
  31. byte m_PVS[PAD_NUMBER( MAX_MAP_CLUSTERS,8 ) / 8];
  32. int m_nPVSSize; // PVS size in bytes
  33. CBitVec<MAX_EDICTS> *m_pTransmitEdict; // entity n is already marked for transmission
  34. CBitVec<MAX_EDICTS> *m_pTransmitAlways; // entity n is always sent even if not in PVS (HLTV and Replay only)
  35. int m_AreasNetworked; // number of networked areas
  36. int m_Areas[MAX_WORLD_AREAS]; // the areas
  37. // This is used to determine visibility, so if the previous state
  38. // is the same as the current state (along with pvs and areas networked),
  39. // then the parts of the map that the player can see haven't changed.
  40. byte m_AreaFloodNums[MAX_MAP_AREAS];
  41. int m_nMapAreas;
  42. void Reset()
  43. {
  44. m_nPVSSize = 0;
  45. m_pTransmitEdict = NULL;
  46. m_pTransmitAlways = NULL;
  47. m_AreasNetworked = 0;
  48. m_nMapAreas = 0;
  49. }
  50. };
  51. //-----------------------------------------------------------------------------
  52. // Stores information necessary to perform PVS testing.
  53. //-----------------------------------------------------------------------------
  54. struct PVSInfo_t
  55. {
  56. // headnode for the entity's bounding box
  57. short m_nHeadNode;
  58. // number of clusters or -1 if too many
  59. short m_nClusterCount;
  60. // cluster indices
  61. unsigned short *m_pClusters;
  62. // For dynamic "area portals"
  63. short m_nAreaNum;
  64. short m_nAreaNum2;
  65. // current position
  66. float m_vCenter[3];
  67. private:
  68. unsigned short m_pClustersInline[MAX_FAST_ENT_CLUSTERS];
  69. friend class CVEngineServer;
  70. };
  71. // IServerNetworkable is the interface the engine uses for all networkable data.
  72. class IServerNetworkable
  73. {
  74. // These functions are handled automatically by the server_class macros and CBaseNetworkable.
  75. public:
  76. // Gets at the entity handle associated with the collideable
  77. virtual IHandleEntity *GetEntityHandle() = 0;
  78. // Tell the engine which class this object is.
  79. virtual ServerClass* GetServerClass() = 0;
  80. virtual edict_t *GetEdict() const = 0;
  81. virtual const char* GetClassName() const = 0;
  82. virtual void Release() = 0;
  83. virtual int AreaNum() const = 0;
  84. // In place of a generic QueryInterface.
  85. virtual CBaseNetworkable* GetBaseNetworkable() = 0;
  86. virtual CBaseEntity* GetBaseEntity() = 0; // Only used by game code.
  87. virtual PVSInfo_t* GetPVSInfo() = 0; // get current visibilty data
  88. protected:
  89. // Should never call delete on this!
  90. virtual ~IServerNetworkable() {}
  91. };
  92. #endif // ISERVERNETWORKABLE_H