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.

614 lines
27 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Defines entity interface between engine and DLLs.
  4. // This header file included by engine files and DLL files.
  5. //
  6. // Before including this header, DLLs must:
  7. // include edict.h
  8. // This is conveniently done for them in extdll.h
  9. //
  10. // $NoKeywords: $
  11. //
  12. //=============================================================================
  13. #ifndef EIFACEV21_H
  14. #define EIFACEV21_H
  15. #ifdef _WIN32
  16. #pragma once
  17. #endif
  18. #include "convar.h"
  19. #include "icvar.h"
  20. #include "edict.h"
  21. #include "iserverentity.h"
  22. #include "engine/ivmodelinfo.h"
  23. #include "soundflags.h"
  24. #include "bitvec.h"
  25. //-----------------------------------------------------------------------------
  26. // forward declarations
  27. //-----------------------------------------------------------------------------
  28. class SendTable;
  29. class ServerClass;
  30. class IMoveHelper;
  31. struct Ray_t;
  32. class CGameTrace;
  33. typedef CGameTrace trace_t;
  34. struct typedescription_t;
  35. class CSaveRestoreData;
  36. struct datamap_t;
  37. class SendTable;
  38. class ServerClass;
  39. class IMoveHelper;
  40. struct Ray_t;
  41. struct studiohdr_t;
  42. class CBaseEntity;
  43. class CRestore;
  44. class CSave;
  45. class variant_t;
  46. struct vcollide_t;
  47. class bf_read;
  48. class bf_write;
  49. class IRecipientFilter;
  50. class CBaseEntity;
  51. class ITraceFilter;
  52. struct client_textmessage_t;
  53. class INetChannelInfo;
  54. class ISpatialPartition;
  55. class IScratchPad3D;
  56. class CStandardSendProxiesV1;
  57. // Terrain Modification Types
  58. enum TerrainModType
  59. {
  60. TMod_Sphere = 0, // sphere that pushes all vertices out along their normal.
  61. TMod_Suck,
  62. TMod_AABB
  63. };
  64. class CTerrainModParams
  65. {
  66. public:
  67. // Flags for m_Flags.
  68. enum
  69. {
  70. TMOD_SUCKTONORMAL = ( 1 << 0 ), // For TMod_Suck, suck into m_Normal rather than on +Z.
  71. TMOD_STAYABOVEORIGINAL = ( 1 << 1 ) // For TMod_Suck, don't go below the original vert on Z.
  72. };
  73. CTerrainModParams() { m_Flags = 0; } // people always forget to init this
  74. Vector m_vCenter;
  75. Vector m_vNormal; // If TMod_Suck and TMOD_SUCKTONORMAL is set.
  76. int m_Flags; // Combination of TMOD_ flags.
  77. float m_flRadius;
  78. Vector m_vecMin; // Bounding box.
  79. Vector m_vecMax;
  80. float m_flStrength; // for TMod_Suck
  81. float m_flMorphTime; // time over which the morph takes place
  82. };
  83. class CSpeculativeTerrainModVert
  84. {
  85. public:
  86. Vector m_vOriginal; // vertex position before any mods
  87. Vector m_vCurrent; // current vertex position
  88. Vector m_vNew; // vertex position if the mod were applied
  89. };
  90. //-----------------------------------------------------------------------------
  91. // Terrain modification interface
  92. //-----------------------------------------------------------------------------
  93. class ITerrainMod
  94. {
  95. public:
  96. //---------------------------------------------------------------------
  97. // Initialize the terrain modifier.
  98. //---------------------------------------------------------------------
  99. virtual void Init( const CTerrainModParams &params ) = 0;
  100. //---------------------------------------------------------------------
  101. // Apply the terrain modifier to the surface. The vertex should be
  102. // moved from its original position to the target position.
  103. // Return true if the position is modified.
  104. //---------------------------------------------------------------------
  105. virtual bool ApplyMod( Vector &vecTargetPos, Vector const &vecOriginalPos ) = 0;
  106. //---------------------------------------------------------------------
  107. // Apply the terrain modifier to the surface. The vertex should from
  108. // its original position toward the target position bassed on the
  109. // morph time.
  110. // Return true if the posistion is modified.
  111. //---------------------------------------------------------------------
  112. virtual bool ApplyModAtMorphTime( Vector &vecTargetPos, const Vector&vecOriginalPos,
  113. float flCurrentTime, float flMorphTime ) = 0;
  114. //---------------------------------------------------------------------
  115. // Get the bounding box for things that this mod can affect (note that
  116. // it CAN move things outside of this bounding box).
  117. //---------------------------------------------------------------------
  118. virtual void GetBBox( Vector &vecBBMin, Vector &vecBBMax ) = 0;
  119. };
  120. //-----------------------------------------------------------------------------
  121. // Purpose: Interface the engine exposes to the game DLL
  122. //-----------------------------------------------------------------------------
  123. #define VENGINESERVER_INTERFACEVERSION_21 "VEngineServer021"
  124. namespace VEngineServerV21
  125. {
  126. abstract_class IVEngineServer
  127. {
  128. public:
  129. // Tell engine to change level ( "changelevel s1\n" or "changelevel2 s1 s2\n" )
  130. virtual void ChangeLevel( const char *s1, const char *s2 ) = 0;
  131. // Ask engine whether the specified map is a valid map file (exists and has valid version number).
  132. virtual int IsMapValid( const char *filename ) = 0;
  133. // Is this a dedicated server?
  134. virtual bool IsDedicatedServer( void ) = 0;
  135. // Is in Hammer editing mode?
  136. virtual int IsInEditMode( void ) = 0;
  137. // Add to the server/client lookup/precache table, the specified string is given a unique index
  138. // NOTE: The indices for PrecacheModel are 1 based
  139. // a 0 returned from those methods indicates the model or sound was not correctly precached
  140. // However, generic and decal are 0 based
  141. // If preload is specified, the file is loaded into the server/client's cache memory before level startup, otherwise
  142. // it'll only load when actually used (which can cause a disk i/o hitch if it occurs during play of a level).
  143. virtual int PrecacheModel( const char *s, bool preload = false ) = 0;
  144. virtual int PrecacheSentenceFile( const char *s, bool preload = false ) = 0;
  145. virtual int PrecacheDecal( const char *name, bool preload = false ) = 0;
  146. virtual int PrecacheGeneric( const char *s, bool preload = false ) = 0;
  147. // Check's if the name is precached, but doesn't actually precache the name if not...
  148. virtual bool IsModelPrecached( char const *s ) const = 0;
  149. virtual bool IsDecalPrecached( char const *s ) const = 0;
  150. virtual bool IsGenericPrecached( char const *s ) const = 0;
  151. // Note that sounds are precached using the IEngineSound interface
  152. // Special purpose PVS checking
  153. // Get the cluster # for the specified position
  154. virtual int GetClusterForOrigin( const Vector &org ) = 0;
  155. // Get the PVS bits for a specified cluster and copy the bits into outputpvs. Returns the number of bytes needed to pack the PVS
  156. virtual int GetPVSForCluster( int cluster, int outputpvslength, unsigned char *outputpvs ) = 0;
  157. // Check whether the specified origin is inside the specified PVS
  158. virtual bool CheckOriginInPVS( const Vector &org, const unsigned char *checkpvs, int checkpvssize ) = 0;
  159. // Check whether the specified worldspace bounding box is inside the specified PVS
  160. virtual bool CheckBoxInPVS( const Vector &mins, const Vector &maxs, const unsigned char *checkpvs, int checkpvssize ) = 0;
  161. // Returns the server assigned userid for this player. Useful for logging frags, etc.
  162. // returns -1 if the edict couldn't be found in the list of players.
  163. virtual int GetPlayerUserId( const edict_t *e ) = 0;
  164. virtual const char *GetPlayerNetworkIDString( const edict_t *e ) = 0;
  165. // Return the current number of used edict slots
  166. virtual int GetEntityCount( void ) = 0;
  167. // Given an edict, returns the entity index
  168. virtual int IndexOfEdict( const edict_t *pEdict ) = 0;
  169. // Given and entity index, returns the corresponding edict pointer
  170. virtual edict_t *PEntityOfEntIndex( int iEntIndex ) = 0;
  171. // Get stats info interface for a client netchannel
  172. virtual INetChannelInfo* GetPlayerNetInfo( int playerIndex ) = 0;
  173. // Allocate space for string and return index/offset of string in global string list
  174. // If iForceEdictIndex is not -1, then it will return the edict with that index. If that edict index
  175. // is already used, it'll return null.
  176. virtual edict_t *CreateEdict( int iForceEdictIndex = -1 ) = 0;
  177. // Remove the specified edict and place back into the free edict list
  178. virtual void RemoveEdict( edict_t *e ) = 0;
  179. // Memory allocation for entity class data
  180. virtual void *PvAllocEntPrivateData( long cb ) = 0;
  181. virtual void FreeEntPrivateData( void *pEntity ) = 0;
  182. // Save/restore uses a special memory allocator (which zeroes newly allocated memory, etc.)
  183. virtual void *SaveAllocMemory( size_t num, size_t size ) = 0;
  184. virtual void SaveFreeMemory( void *pSaveMem ) = 0;
  185. // Emit an ambient sound associated with the specified entity
  186. virtual void EmitAmbientSound( int entindex, const Vector &pos, const char *samp, float vol, soundlevel_t soundlevel, int fFlags, int pitch, float delay = 0.0f ) = 0;
  187. // Fade out the client's volume level toward silence (or fadePercent)
  188. virtual void FadeClientVolume( const edict_t *pEdict, float fadePercent, float fadeOutSeconds, float holdTime, float fadeInSeconds ) = 0;
  189. // Sentences / sentence groups
  190. virtual int SentenceGroupPick( int groupIndex, char *name, int nameBufLen ) = 0;
  191. virtual int SentenceGroupPickSequential( int groupIndex, char *name, int nameBufLen, int sentenceIndex, int reset ) = 0;
  192. virtual int SentenceIndexFromName( const char *pSentenceName ) = 0;
  193. virtual const char *SentenceNameFromIndex( int sentenceIndex ) = 0;
  194. virtual int SentenceGroupIndexFromName( const char *pGroupName ) = 0;
  195. virtual const char *SentenceGroupNameFromIndex( int groupIndex ) = 0;
  196. virtual float SentenceLength( int sentenceIndex ) = 0;
  197. // Issue a command to the command parser as if it was typed at the server console.
  198. virtual void ServerCommand( const char *str ) = 0;
  199. // Execute any commands currently in the command parser immediately (instead of once per frame)
  200. virtual void ServerExecute( void ) = 0;
  201. // Issue the specified command to the specified client (mimics that client typing the command at the console).
  202. virtual void ClientCommand( edict_t *pEdict, PRINTF_FORMAT_STRING const char *szFmt, ... ) = 0;
  203. // Set the lightstyle to the specified value and network the change to any connected clients. Note that val must not
  204. // change place in memory (use MAKE_STRING) for anything that's not compiled into your mod.
  205. virtual void LightStyle( int style, const char *val ) = 0;
  206. // Project a static decal onto the specified entity / model (for level placed decals in the .bsp)
  207. virtual void StaticDecal( const Vector &originInEntitySpace, int decalIndex, int entityIndex, int modelIndex, bool lowpriority ) = 0;
  208. // Given the current PVS(or PAS) and origin, determine which players should hear/receive the message
  209. virtual void Message_DetermineMulticastRecipients( bool usepas, const Vector& origin, CBitVec< ABSOLUTE_PLAYER_LIMIT >& playerbits ) = 0;
  210. // Begin a message from a server side entity to its client side counterpart (func_breakable glass, e.g.)
  211. virtual bf_write *EntityMessageBegin( int ent_index, ServerClass * ent_class, bool reliable ) = 0;
  212. // Begin a usermessage from the server to the client .dll
  213. virtual bf_write *UserMessageBegin( IRecipientFilter *filter, int msg_type ) = 0;
  214. // Finish the Entity or UserMessage and dispatch to network layer
  215. virtual void MessageEnd( void ) = 0;
  216. // Print szMsg to the client console.
  217. virtual void ClientPrintf( edict_t *pEdict, const char *szMsg ) = 0;
  218. // SINGLE PLAYER/LISTEN SERVER ONLY (just matching the client .dll api for this)
  219. // Prints the formatted string to the notification area of the screen ( down the right hand edge
  220. // numbered lines starting at position 0
  221. virtual void Con_NPrintf( int pos, PRINTF_FORMAT_STRING const char *fmt, ... ) = 0;
  222. // SINGLE PLAYER/LISTEN SERVER ONLY(just matching the client .dll api for this)
  223. // Similar to Con_NPrintf, but allows specifying custom text color and duration information
  224. virtual void Con_NXPrintf( const struct con_nprint_s *info, PRINTF_FORMAT_STRING const char *fmt, ... ) = 0;
  225. // For ConCommand parsing or parsing client commands issued by players typing at their console
  226. // Retrieves the raw command string (untokenized)
  227. virtual const char *Cmd_Args( void ) = 0;
  228. // Returns the number of tokens in the command string
  229. virtual int Cmd_Argc( void ) = 0;
  230. // Retrieves a specified token
  231. virtual char *Cmd_Argv( int argc ) = 0;
  232. // Change a specified player's "view entity" (i.e., use the view entity position/orientation for rendering the client view)
  233. virtual void SetView( const edict_t *pClient, const edict_t *pViewent ) = 0;
  234. // Get a high precision timer for doing profiling work
  235. virtual float Time( void ) = 0;
  236. // Set the player's crosshair angle
  237. virtual void CrosshairAngle( const edict_t *pClient, float pitch, float yaw ) = 0;
  238. // Get the current game directory (hl2, tf2, hl1, cstrike, etc.)
  239. virtual void GetGameDir( char *szGetGameDir, int maxlength ) = 0;
  240. // Used by AI node graph code to determine if .bsp and .ain files are out of date
  241. virtual int CompareFileTime( const char *filename1, const char *filename2, int *iCompare ) = 0;
  242. // Locks/unlocks the network string tables (.e.g, when adding bots to server, this needs to happen).
  243. // Be sure to reset the lock after executing your code!!!
  244. virtual bool LockNetworkStringTables( bool lock ) = 0;
  245. // Create a bot with the given name. Returns NULL if fake client can't be created
  246. virtual edict_t *CreateFakeClient( const char *netname ) = 0;
  247. // Get a convar keyvalue for s specified client
  248. virtual const char *GetClientConVarValue( int clientIndex, const char *name ) = 0;
  249. // Parse a token from a file
  250. virtual const char *ParseFile( const char *data, char *token, int maxlen ) = 0;
  251. // Copies a file
  252. virtual bool CopyFile( const char *source, const char *destination ) = 0;
  253. // Reset the pvs, pvssize is the size in bytes of the buffer pointed to by pvs.
  254. // This should be called right before any calls to AddOriginToPVS
  255. virtual void ResetPVS( byte *pvs, int pvssize ) = 0;
  256. // Merge the pvs bits into the current accumulated pvs based on the specified origin ( not that each pvs origin has an 8 world unit fudge factor )
  257. virtual void AddOriginToPVS( const Vector &origin ) = 0;
  258. // Mark a specified area portal as open/closes
  259. virtual void SetAreaPortalState( int portalNumber, int isOpen ) = 0;
  260. // Queue a temp entity for transmission
  261. virtual void PlaybackTempEntity( IRecipientFilter& filter, float delay, const void *pSender, const SendTable *pST, int classID ) = 0;
  262. // Given a node number and the specified PVS, return with the node is in the PVS
  263. virtual int CheckHeadnodeVisible( int nodenum, const byte *pvs, int vissize ) = 0;
  264. // Using area bits, cheeck whether area1 flows into area2 and vice versa (depends on area portal state)
  265. virtual int CheckAreasConnected( int area1, int area2 ) = 0;
  266. // Given an origin, determine which area index the origin is within
  267. virtual int GetArea( const Vector &origin ) = 0;
  268. // Get area portal bit set
  269. virtual void GetAreaBits( int area, unsigned char *bits, int buflen ) = 0;
  270. // Given a view origin (which tells us the area to start looking in) and a portal key,
  271. // fill in the plane that leads out of this area (it points into whatever area it leads to).
  272. virtual bool GetAreaPortalPlane( Vector const &vViewOrigin, int portalKey, VPlane *pPlane ) = 0;
  273. // Apply a modification to the terrain.
  274. virtual void ApplyTerrainMod( TerrainModType type, CTerrainModParams const &params ) = 0;
  275. // Save/restore wrapper - FIXME: At some point we should move this to it's own interface
  276. virtual bool LoadGameState( char const *pMapName, bool createPlayers ) = 0;
  277. virtual void LoadAdjacentEnts( const char *pOldLevel, const char *pLandmarkName ) = 0;
  278. virtual void ClearSaveDir() = 0;
  279. // Get the pristine map entity lump string. (e.g., used by CS to reload the map entities when restarting a round.)
  280. virtual const char* GetMapEntitiesString() = 0;
  281. // Text message system -- lookup the text message of the specified name
  282. virtual client_textmessage_t *TextMessageGet( const char *pName ) = 0;
  283. // Print a message to the server log file
  284. virtual void LogPrint( const char *msg ) = 0;
  285. // Builds PVS information for an entity
  286. virtual void BuildEntityClusterList( edict_t *pEdict, PVSInfo_t *pPVSInfo ) = 0;
  287. // A solid entity moved, update spatial partition
  288. virtual void SolidMoved( edict_t *pSolidEnt, ICollideable *pSolidCollide, const Vector* pPrevAbsOrigin ) = 0;
  289. // A trigger entity moved, update spatial partition
  290. virtual void TriggerMoved( edict_t *pTriggerEnt ) = 0;
  291. // Create/destroy a custom spatial partition
  292. virtual ISpatialPartition *CreateSpatialPartition( const Vector& worldmin, const Vector& worldmax ) = 0;
  293. virtual void DestroySpatialPartition( ISpatialPartition * ) = 0;
  294. // Draw the brush geometry in the map into the scratch pad.
  295. // Flags is currently unused.
  296. virtual void DrawMapToScratchPad( IScratchPad3D *pPad, unsigned long iFlags ) = 0;
  297. // This returns which entities, to the best of the server's knowledge, the client currently knows about.
  298. // This is really which entities were in the snapshot that this client last acked.
  299. // This returns a bit vector with one bit for each entity.
  300. //
  301. // USE WITH CARE. Whatever tick the client is really currently on is subject to timing and
  302. // ordering differences, so you should account for about a quarter-second discrepancy in here.
  303. // Also, this will return NULL if the client doesn't exist or if this client hasn't acked any frames yet.
  304. //
  305. // iClientIndex is the CLIENT index, so if you use pPlayer->entindex(), subtract 1.
  306. virtual const CBitVec<MAX_EDICTS>* GetEntityTransmitBitsForClient( int iClientIndex ) = 0;
  307. // Is the game paused?
  308. virtual bool IsPaused() = 0;
  309. // Marks the filename for consistency checking. This should be called after precaching the file.
  310. virtual void ForceExactFile( const char *s ) = 0;
  311. virtual void ForceModelBounds( const char *s, const Vector &mins, const Vector &maxs ) = 0;
  312. virtual void ClearSaveDirAfterClientLoad() = 0;
  313. // Sets a USERINFO client ConVar for a fakeclient
  314. virtual void SetFakeClientConVarValue( edict_t *pEntity, const char *cvar, const char *value ) = 0;
  315. virtual void InsertServerCommand( const char *str ) = 0;
  316. // Marks the material (vmt file) for consistency checking. If the client and server have different
  317. // contents for the file, the client's vmt can only use the VertexLitGeneric shader, and can only
  318. // contain $baseTexture and $bumpmap vars.
  319. virtual void ForceSimpleMaterial( const char *s ) = 0;
  320. // Is the engine in Commentary mode?
  321. virtual int IsInCommentaryMode( void ) = 0;
  322. };
  323. } // end namespace
  324. //-----------------------------------------------------------------------------
  325. // Purpose: These are the interfaces that the game .dll exposes to the engine
  326. //-----------------------------------------------------------------------------
  327. #define SERVERGAMEDLL_INTERFACEVERSION_3 "ServerGameDLL003"
  328. namespace ServerGameDLLV3
  329. {
  330. abstract_class IServerGameDLL
  331. {
  332. public:
  333. // Initialize the game (one-time call when the DLL is first loaded )
  334. // Return false if there is an error during startup.
  335. virtual bool DLLInit( CreateInterfaceFn engineFactory,
  336. CreateInterfaceFn physicsFactory,
  337. CreateInterfaceFn fileSystemFactory,
  338. CGlobalVars *pGlobals) = 0;
  339. // This is called when a new game is started. (restart, map)
  340. virtual bool GameInit( void ) = 0;
  341. // Called any time a new level is started (after GameInit() also on level transitions within a game)
  342. virtual bool LevelInit( char const *pMapName,
  343. char const *pMapEntities, char const *pOldLevel,
  344. char const *pLandmarkName, bool loadGame, bool background ) = 0;
  345. // The server is about to activate
  346. virtual void ServerActivate( edict_t *pEdictList, int edictCount, int clientMax ) = 0;
  347. // The server should run physics/think on all edicts
  348. virtual void GameFrame( bool simulating ) = 0;
  349. // Called once per simulation frame on the final tick
  350. virtual void PreClientUpdate( bool simulating ) = 0;
  351. // Called when a level is shutdown (including changing levels)
  352. virtual void LevelShutdown( void ) = 0;
  353. // This is called when a game ends (server disconnect, death, restart, load)
  354. // NOT on level transitions within a game
  355. virtual void GameShutdown( void ) = 0;
  356. // Called once during DLL shutdown
  357. virtual void DLLShutdown( void ) = 0;
  358. // Get the simulation interval (must be compiled with identical values into both client and game .dll for MOD!!!)
  359. // Right now this is only requested at server startup time so it can't be changed on the fly, etc.
  360. virtual float GetTickInterval( void ) const = 0;
  361. // Give the list of datatable classes to the engine. The engine matches class names from here with
  362. // edict_t::classname to figure out how to encode a class's data for networking
  363. virtual ServerClass* GetAllServerClasses( void ) = 0;
  364. // Returns string describing current .dll. e.g., TeamFortress 2, Half-Life 2.
  365. // Hey, it's more descriptive than just the name of the game directory
  366. virtual const char *GetGameDescription( void ) = 0;
  367. // Let the game .dll allocate it's own network/shared string tables
  368. virtual void CreateNetworkStringTables( void ) = 0;
  369. // Save/restore system hooks
  370. virtual CSaveRestoreData *SaveInit( int size ) = 0;
  371. virtual void SaveWriteFields( CSaveRestoreData *, const char *, void *, datamap_t *, typedescription_t *, int ) = 0;
  372. virtual void SaveReadFields( CSaveRestoreData *, const char *, void *, datamap_t *, typedescription_t *, int ) = 0;
  373. virtual void SaveGlobalState( CSaveRestoreData * ) = 0;
  374. virtual void RestoreGlobalState( CSaveRestoreData * ) = 0;
  375. virtual void PreSave( CSaveRestoreData * ) = 0;
  376. virtual void Save( CSaveRestoreData * ) = 0;
  377. virtual void GetSaveComment( char *comment, int maxlength ) = 0;
  378. virtual void WriteSaveHeaders( CSaveRestoreData * ) = 0;
  379. virtual void ReadRestoreHeaders( CSaveRestoreData * ) = 0;
  380. virtual void Restore( CSaveRestoreData *, bool ) = 0;
  381. virtual bool IsRestoring() = 0;
  382. // Returns the number of entities moved across the transition
  383. virtual int CreateEntityTransitionList( CSaveRestoreData *, int ) = 0;
  384. // Build the list of maps adjacent to the current map
  385. virtual void BuildAdjacentMapList( void ) = 0;
  386. // Retrieve info needed for parsing the specified user message
  387. virtual bool GetUserMessageInfo( int msg_type, char *name, int maxnamelength, int& size ) = 0;
  388. // Hand over the StandardSendProxies in the game DLL's module.
  389. virtual CStandardSendProxiesV1* GetStandardSendProxies() = 0;
  390. };
  391. } // end namespace
  392. //-----------------------------------------------------------------------------
  393. // Just an interface version name for the random number interface
  394. // See vstdlib/random.h for the interface definition
  395. // NOTE: If you change this, also change VENGINE_CLIENT_RANDOM_INTERFACE_VERSION in cdll_int.h
  396. //-----------------------------------------------------------------------------
  397. #define VENGINE_SERVER_RANDOM_INTERFACE_VERSION_1 "VEngineRandom001"
  398. //-----------------------------------------------------------------------------
  399. // Purpose: Interface to get at server entities
  400. //-----------------------------------------------------------------------------
  401. #define SERVERGAMEENTS_INTERFACEVERSION_1 "ServerGameEnts001"
  402. namespace ServerGameEntsV1
  403. {
  404. abstract_class IServerGameEnts
  405. {
  406. public:
  407. virtual ~IServerGameEnts() {}
  408. // Only for debugging. Set the edict base so you can get an edict's index in the debugger while debugging the game .dll
  409. virtual void SetDebugEdictBase(edict_t *base) = 0;
  410. // The engine wants to mark two entities as touching
  411. virtual void MarkEntitiesAsTouching( edict_t *e1, edict_t *e2 ) = 0;
  412. // Frees the entity attached to this edict
  413. virtual void FreeContainingEntity( edict_t * ) = 0;
  414. // This allows the engine to get at edicts in a CGameTrace.
  415. virtual edict_t* BaseEntityToEdict( CBaseEntity *pEnt ) = 0;
  416. virtual CBaseEntity* EdictToBaseEntity( edict_t *pEdict ) = 0;
  417. // This sets a bit in pInfo for each edict in the list that wants to be transmitted to the
  418. // client specified in pInfo.
  419. //
  420. // This is also where an entity can force other entities to be transmitted if it refers to them
  421. // with ehandles.
  422. virtual void CheckTransmit( CCheckTransmitInfo *pInfo, const unsigned short *pEdictIndices, int nEdicts ) = 0;
  423. };
  424. } // end namespace ServerGameEntsV1
  425. //-----------------------------------------------------------------------------
  426. // Purpose: Player / Client related functions
  427. //-----------------------------------------------------------------------------
  428. #define SERVERGAMECLIENTS_INTERFACEVERSION_3 "ServerGameClients003"
  429. namespace ServerGameClientsV3
  430. {
  431. abstract_class IServerGameClients
  432. {
  433. public:
  434. // Get server maxplayers and lower bound for same
  435. virtual void GetPlayerLimits( int& minplayers, int& maxplayers, int &defaultMaxPlayers ) const = 0;
  436. // Client is connecting to server ( return false to reject the connection )
  437. // You can specify a rejection message by writing it into reject
  438. virtual bool ClientConnect( edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen ) = 0;
  439. // Client is going active
  440. // If bLoadGame is true, don't spawn the player because its state is already setup.
  441. virtual void ClientActive( edict_t *pEntity, bool bLoadGame ) = 0;
  442. // Client is disconnecting from server
  443. virtual void ClientDisconnect( edict_t *pEntity ) = 0;
  444. // Client is connected and should be put in the game
  445. virtual void ClientPutInServer( edict_t *pEntity, char const *playername ) = 0;
  446. // The client has typed a command at the console
  447. virtual void ClientCommand( edict_t *pEntity ) = 0;
  448. // Sets the client index for the client who typed the command into his/her console
  449. virtual void SetCommandClient( int index ) = 0;
  450. // A player changed one/several replicated cvars (name etc)
  451. virtual void ClientSettingsChanged( edict_t *pEdict ) = 0;
  452. // Determine PVS origin and set PVS for the player/viewentity
  453. virtual void ClientSetupVisibility( edict_t *pViewEntity, edict_t *pClient, unsigned char *pvs, int pvssize ) = 0;
  454. // A block of CUserCmds has arrived from the user, decode them and buffer for execution during player simulation
  455. virtual float ProcessUsercmds( edict_t *player, bf_read *buf, int numcmds, int totalcmds,
  456. int dropped_packets, bool ignore, bool paused ) = 0;
  457. // Let the game .dll do stuff after messages have been sent to all of the clients once the server frame is complete
  458. virtual void PostClientMessagesSent_DEPRECIATED( void ) = 0;
  459. // For players, looks up the CPlayerState structure corresponding to the player
  460. virtual CPlayerState *GetPlayerState( edict_t *player ) = 0;
  461. // Get the ear position for a specified client
  462. virtual void ClientEarPosition( edict_t *pEntity, Vector *pEarOrigin ) = 0;
  463. // returns number of delay ticks if player is in Replay mode (0 = no delay)
  464. virtual int GetReplayDelay( edict_t *player ) = 0;
  465. // Anything this game .dll wants to add to the bug reporter text (e.g., the entity/model under the picker crosshair)
  466. // can be added here
  467. virtual void GetBugReportInfo( char *buf, int buflen ) = 0;
  468. };
  469. } // end namespace ServerGameClientsV3
  470. #define UPLOADGAMESTATS_INTERFACEVERSION_1 "ServerUploadGameStats001"
  471. namespace UploadGameStatsV1
  472. {
  473. abstract_class IUploadGameStats
  474. {
  475. public:
  476. // Note that this call will block the server until the upload is completed, so use only at levelshutdown if at all.
  477. virtual bool UploadGameStats(
  478. char const *mapname, // Game map name
  479. unsigned int blobversion, // Version of the binary blob data
  480. unsigned int blobsize, // Size in bytes of blob data
  481. const void *pvBlobData ) = 0; // Pointer to the blob data.
  482. };
  483. } // end namespace UploadGameStatsV1
  484. #endif // EIFACEV21_H