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.

114 lines
3.0 KiB

  1. //========= Copyright 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. };
  43. //-----------------------------------------------------------------------------
  44. // Stores information necessary to perform PVS testing.
  45. //-----------------------------------------------------------------------------
  46. struct PVSInfo_t
  47. {
  48. // headnode for the entity's bounding box
  49. short m_nHeadNode;
  50. // number of clusters or -1 if too many
  51. short m_nClusterCount;
  52. // cluster indices
  53. unsigned short *m_pClusters;
  54. // For dynamic "area portals"
  55. short m_nAreaNum;
  56. short m_nAreaNum2;
  57. // current position
  58. float m_vCenter[3];
  59. private:
  60. unsigned short m_pClustersInline[MAX_FAST_ENT_CLUSTERS];
  61. friend class CVEngineServer;
  62. };
  63. // IServerNetworkable is the interface the engine uses for all networkable data.
  64. class IServerNetworkable
  65. {
  66. // These functions are handled automatically by the server_class macros and CBaseNetworkable.
  67. public:
  68. // Gets at the entity handle associated with the collideable
  69. virtual IHandleEntity *GetEntityHandle() = 0;
  70. // Tell the engine which class this object is.
  71. virtual ServerClass* GetServerClass() = 0;
  72. virtual edict_t *GetEdict() const = 0;
  73. virtual const char* GetClassName() const = 0;
  74. virtual void Release() = 0;
  75. virtual int AreaNum() const = 0;
  76. // In place of a generic QueryInterface.
  77. virtual CBaseNetworkable* GetBaseNetworkable() = 0;
  78. virtual CBaseEntity* GetBaseEntity() = 0; // Only used by game code.
  79. virtual PVSInfo_t* GetPVSInfo() = 0; // get current visibilty data
  80. protected:
  81. // Should never call delete on this!
  82. virtual ~IServerNetworkable() {}
  83. };
  84. #endif // ISERVERNETWORKABLE_H