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.

915 lines
41 KiB

  1. //===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //===========================================================================//
  8. #ifndef EIFACE_H
  9. #define EIFACE_H
  10. #ifdef _WIN32
  11. #pragma once
  12. #endif
  13. #include "convar.h"
  14. #include "icvar.h"
  15. #include "edict.h"
  16. #include "mathlib/vplane.h"
  17. #include "iserverentity.h"
  18. #include "engine/ivmodelinfo.h"
  19. #include "soundflags.h"
  20. #include "bitvec.h"
  21. #include "engine/iserverplugin.h"
  22. #include "tier1/bitbuf.h"
  23. #include "iclient.h"
  24. #include "google/protobuf/message.h"
  25. #include "steam/isteamremotestorage.h"
  26. //-----------------------------------------------------------------------------
  27. // forward declarations
  28. //-----------------------------------------------------------------------------
  29. class SendTable;
  30. class ServerClass;
  31. class IMoveHelper;
  32. struct Ray_t;
  33. class CGameTrace;
  34. typedef CGameTrace trace_t;
  35. struct typedescription_t;
  36. class CSaveRestoreData;
  37. struct datamap_t;
  38. class SendTable;
  39. class ServerClass;
  40. class IMoveHelper;
  41. struct Ray_t;
  42. struct studiohdr_t;
  43. class CBaseEntity;
  44. class CRestore;
  45. class CSave;
  46. class variant_t;
  47. struct vcollide_t;
  48. class IRecipientFilter;
  49. class CBaseEntity;
  50. class ITraceFilter;
  51. struct client_textmessage_t;
  52. class INetChannelInfo;
  53. class ISpatialPartition;
  54. class IScratchPad3D;
  55. class CStandardSendProxies;
  56. class IAchievementMgr;
  57. class CGamestatsData;
  58. class CSteamID;
  59. class ISPSharedMemory;
  60. class CGamestatsData;
  61. class CEngineGotvSyncPacket; // forward declare protobuf message here
  62. typedef struct player_info_s player_info_t;
  63. //-----------------------------------------------------------------------------
  64. // defines
  65. //-----------------------------------------------------------------------------
  66. #ifdef _WIN32
  67. #define DLLEXPORT __stdcall
  68. #else
  69. #define DLLEXPORT /* */
  70. #endif
  71. #define INTERFACEVERSION_VENGINESERVER "VEngineServer023"
  72. struct bbox_t
  73. {
  74. Vector mins;
  75. Vector maxs;
  76. };
  77. enum EncryptedMessageKeyType_t
  78. {
  79. // Warning: do not renumber the key types as they get baked in demos
  80. kEncryptedMessageKeyType_None = 0,
  81. kEncryptedMessageKeyType_Private = 1,
  82. kEncryptedMessageKeyType_Public = 2,
  83. };
  84. struct CEngineHltvInfo_t
  85. {
  86. bool m_bBroadcastActive; // Whether TV broadcast is active
  87. bool m_bMasterProxy; // Whether this is master proxy
  88. float m_flDelay; // TV delay
  89. float m_flTime; // TV match time
  90. int m_nTvPort; // TV port
  91. int m_numSlots; // Total number of TV slots
  92. int m_numClients; // Clients (spectators+proxies) count
  93. int m_numProxies; // Number of proxies
  94. int m_numLocalSlots; // Local number of TV slots
  95. int m_numLocalClients; // Local clients (spectators+proxies) count
  96. int m_numLocalProxies; // Local number of proxies
  97. int m_numRelaySlots; // Relay number of TV slots
  98. int m_numRelayClients; // Relay clients (spectators+proxies) count
  99. int m_numRelayProxies; // Relay number of proxies
  100. int m_numExternalTotalViewers; // External total viewers
  101. int m_numExternalLinkedViewers; // External linked viewers
  102. uint32 m_relayAddress; // Relay address
  103. uint32 m_relayPort; // Relay port
  104. };
  105. struct ClientReplayEventParams_t
  106. {
  107. ClientReplayEventParams_t( int nEventType )
  108. {
  109. m_nEventType = nEventType;
  110. m_flSlowdownLength = 0;
  111. m_flSlowdownRate = 1.0f;
  112. m_nPrimaryTargetEntIndex = -1; // unknown by default
  113. m_flEventTime = -1.0; // unknown by default
  114. }
  115. int m_nEventType;
  116. float m_flSlowdownLength;
  117. float m_flSlowdownRate;
  118. int m_nPrimaryTargetEntIndex;
  119. float m_flEventTime;
  120. };
  121. //-----------------------------------------------------------------------------
  122. // Purpose: Interface the engine exposes to the game DLL
  123. //-----------------------------------------------------------------------------
  124. abstract_class IVEngineServer
  125. {
  126. public:
  127. // Tell engine to change level ( "changelevel s1\n" or "changelevel2 s1 s2\n" )
  128. virtual void ChangeLevel( const char *s1, const char *s2 ) = 0;
  129. // Ask engine whether the specified map is a valid map file (exists and has valid version number).
  130. virtual int IsMapValid( const char *filename ) = 0;
  131. // Is this a dedicated server?
  132. virtual bool IsDedicatedServer( void ) = 0;
  133. // Is in Hammer editing mode?
  134. virtual int IsInEditMode( void ) = 0;
  135. // get arbitrary launch options
  136. virtual KeyValues* GetLaunchOptions( 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. virtual bool IsUserIDInUse( int userID ) = 0; // TERROR: used for transitioning
  166. virtual int GetLoadingProgressForUserID( int userID ) = 0; // TERROR: used for transitioning
  167. // Return the current number of used edict slots
  168. virtual int GetEntityCount( void ) = 0;
  169. // Get stats info interface for a client netchannel
  170. virtual INetChannelInfo* GetPlayerNetInfo( int playerIndex ) = 0;
  171. // Allocate space for string and return index/offset of string in global string list
  172. // If iForceEdictIndex is not -1, then it will return the edict with that index. If that edict index
  173. // is already used, it'll return null.
  174. virtual edict_t *CreateEdict( int iForceEdictIndex = -1 ) = 0;
  175. // Remove the specified edict and place back into the free edict list
  176. virtual void RemoveEdict( edict_t *e ) = 0;
  177. // Memory allocation for entity class data
  178. virtual void *PvAllocEntPrivateData( long cb ) = 0;
  179. virtual void FreeEntPrivateData( void *pEntity ) = 0;
  180. // Save/restore uses a special memory allocator (which zeroes newly allocated memory, etc.)
  181. virtual void *SaveAllocMemory( size_t num, size_t size ) = 0;
  182. virtual void SaveFreeMemory( void *pSaveMem ) = 0;
  183. // Emit an ambient sound associated with the specified entity
  184. 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;
  185. // Fade out the client's volume level toward silence (or fadePercent)
  186. virtual void FadeClientVolume( const edict_t *pEdict, float fadePercent, float fadeOutSeconds, float holdTime, float fadeInSeconds ) = 0;
  187. // Sentences / sentence groups
  188. virtual int SentenceGroupPick( int groupIndex, char *name, int nameBufLen ) = 0;
  189. virtual int SentenceGroupPickSequential( int groupIndex, char *name, int nameBufLen, int sentenceIndex, int reset ) = 0;
  190. virtual int SentenceIndexFromName( const char *pSentenceName ) = 0;
  191. virtual const char *SentenceNameFromIndex( int sentenceIndex ) = 0;
  192. virtual int SentenceGroupIndexFromName( const char *pGroupName ) = 0;
  193. virtual const char *SentenceGroupNameFromIndex( int groupIndex ) = 0;
  194. virtual float SentenceLength( int sentenceIndex ) = 0;
  195. // Issue a command to the command parser as if it was typed at the server console.
  196. virtual void ServerCommand( const char *str ) = 0;
  197. // Execute any commands currently in the command parser immediately (instead of once per frame)
  198. virtual void ServerExecute( void ) = 0;
  199. // Issue the specified command to the specified client (mimics that client typing the command at the console).
  200. virtual void ClientCommand( edict_t *pEdict, PRINTF_FORMAT_STRING const char *szFmt, ... ) FMTFUNCTION( 3, 4 ) = 0;
  201. // Set the lightstyle to the specified value and network the change to any connected clients. Note that val must not
  202. // change place in memory (use MAKE_STRING) for anything that's not compiled into your mod.
  203. virtual void LightStyle( int style, PRINTF_FORMAT_STRING const char *val ) = 0;
  204. // Project a static decal onto the specified entity / model (for level placed decals in the .bsp)
  205. virtual void StaticDecal( const Vector &originInEntitySpace, int decalIndex, int entityIndex, int modelIndex, bool lowpriority ) = 0;
  206. // Given the current PVS(or PAS) and origin, determine which players should hear/receive the message
  207. virtual void Message_DetermineMulticastRecipients( bool usepas, const Vector& origin, CPlayerBitVec& playerbits ) = 0;
  208. // Begin a message from a server side entity to its client side counterpart (func_breakable glass, e.g.)
  209. virtual bf_write *EntityMessageBegin( int ent_index, ServerClass * ent_class, bool reliable ) = 0;
  210. // Finish the Entity or UserMessage and dispatch to network layer
  211. virtual void MessageEnd( void ) = 0;
  212. // Send a protobuf based user message
  213. virtual void SendUserMessage( IRecipientFilter& filter, int message, const ::google::protobuf::Message &msg ) = 0;
  214. // Print szMsg to the client console.
  215. virtual void ClientPrintf( edict_t *pEdict, const char *szMsg ) = 0;
  216. // SINGLE PLAYER/LISTEN SERVER ONLY (just matching the client .dll api for this)
  217. // Prints the formatted string to the notification area of the screen ( down the right hand edge
  218. // numbered lines starting at position 0
  219. virtual void Con_NPrintf( int pos, const char *fmt, ... ) = 0;
  220. // SINGLE PLAYER/LISTEN SERVER ONLY(just matching the client .dll api for this)
  221. // Similar to Con_NPrintf, but allows specifying custom text color and duration information
  222. virtual void Con_NXPrintf( const struct con_nprint_s *info, const char *fmt, ... ) = 0;
  223. // Change a specified player's "view entity" (i.e., use the view entity position/orientation for rendering the client view)
  224. virtual void SetView( const edict_t *pClient, const edict_t *pViewent ) = 0;
  225. // Set the player's crosshair angle
  226. virtual void CrosshairAngle( const edict_t *pClient, float pitch, float yaw ) = 0;
  227. // Get the current game directory (hl2, tf2, hl1, cstrike, etc.)
  228. virtual void GetGameDir( char *szGetGameDir, int maxlength ) = 0;
  229. // Used by AI node graph code to determine if .bsp and .ain files are out of date
  230. virtual int CompareFileTime( const char *filename1, const char *filename2, int *iCompare ) = 0;
  231. // Locks/unlocks the network string tables (.e.g, when adding bots to server, this needs to happen).
  232. // Be sure to reset the lock after executing your code!!!
  233. virtual bool LockNetworkStringTables( bool lock ) = 0;
  234. // Create a bot with the given name. Returns NULL if fake client can't be created
  235. virtual edict_t *CreateFakeClient( const char *netname ) = 0;
  236. // Get a convar keyvalue for s specified client
  237. virtual const char *GetClientConVarValue( int clientIndex, const char *name ) = 0;
  238. // Parse a token from a file
  239. virtual const char *ParseFile( const char *data, char *token, int maxlen ) = 0;
  240. // Copies a file
  241. virtual bool CopyFile( const char *source, const char *destination ) = 0;
  242. // Reset the pvs, pvssize is the size in bytes of the buffer pointed to by pvs.
  243. // This should be called right before any calls to AddOriginToPVS
  244. virtual void ResetPVS( byte *pvs, int pvssize ) = 0;
  245. // 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 )
  246. virtual void AddOriginToPVS( const Vector &origin ) = 0;
  247. // Mark a specified area portal as open/closed.
  248. // Use SetAreaPortalStates if you want to set a bunch of them at a time.
  249. virtual void SetAreaPortalState( int portalNumber, int isOpen ) = 0;
  250. // Queue a temp entity for transmission
  251. virtual void PlaybackTempEntity( IRecipientFilter& filter, float delay, const void *pSender, const SendTable *pST, int classID ) = 0;
  252. // Given a node number and the specified PVS, return with the node is in the PVS
  253. virtual int CheckHeadnodeVisible( int nodenum, const byte *pvs, int vissize ) = 0;
  254. // Using area bits, cheeck whether area1 flows into area2 and vice versa (depends on area portal state)
  255. virtual int CheckAreasConnected( int area1, int area2 ) = 0;
  256. // Given an origin, determine which area index the origin is within
  257. virtual int GetArea( const Vector &origin ) = 0;
  258. // Get area portal bit set
  259. virtual void GetAreaBits( int area, unsigned char *bits, int buflen ) = 0;
  260. // Given a view origin (which tells us the area to start looking in) and a portal key,
  261. // fill in the plane that leads out of this area (it points into whatever area it leads to).
  262. virtual bool GetAreaPortalPlane( Vector const &vViewOrigin, int portalKey, VPlane *pPlane ) = 0;
  263. // Save/restore wrapper - FIXME: At some point we should move this to it's own interface
  264. virtual bool LoadGameState( char const *pMapName, bool createPlayers ) = 0;
  265. virtual void LoadAdjacentEnts( const char *pOldLevel, const char *pLandmarkName ) = 0;
  266. virtual void ClearSaveDir() = 0;
  267. // Get the pristine map entity lump string. (e.g., used by CS to reload the map entities when restarting a round.)
  268. virtual const char* GetMapEntitiesString() = 0;
  269. // Text message system -- lookup the text message of the specified name
  270. virtual client_textmessage_t *TextMessageGet( const char *pName ) = 0;
  271. // Print a message to the server log file
  272. virtual void LogPrint( const char *msg ) = 0;
  273. virtual bool IsLogEnabled() = 0;
  274. // Builds PVS information for an entity
  275. virtual void BuildEntityClusterList( edict_t *pEdict, PVSInfo_t *pPVSInfo ) = 0;
  276. // A solid entity moved, update spatial partition
  277. virtual void SolidMoved( edict_t *pSolidEnt, ICollideable *pSolidCollide, const Vector* pPrevAbsOrigin, bool testSurroundingBoundsOnly ) = 0;
  278. // A trigger entity moved, update spatial partition
  279. virtual void TriggerMoved( edict_t *pTriggerEnt, bool testSurroundingBoundsOnly ) = 0;
  280. // Create/destroy a custom spatial partition
  281. virtual ISpatialPartition *CreateSpatialPartition( const Vector& worldmin, const Vector& worldmax ) = 0;
  282. virtual void DestroySpatialPartition( ISpatialPartition * ) = 0;
  283. // Draw the brush geometry in the map into the scratch pad.
  284. // Flags is currently unused.
  285. virtual void DrawMapToScratchPad( IScratchPad3D *pPad, unsigned long iFlags ) = 0;
  286. // This returns which entities, to the best of the server's knowledge, the client currently knows about.
  287. // This is really which entities were in the snapshot that this client last acked.
  288. // This returns a bit vector with one bit for each entity.
  289. //
  290. // USE WITH CARE. Whatever tick the client is really currently on is subject to timing and
  291. // ordering differences, so you should account for about a quarter-second discrepancy in here.
  292. // Also, this will return NULL if the client doesn't exist or if this client hasn't acked any frames yet.
  293. //
  294. // iClientIndex is the CLIENT index, so if you use pPlayer->entindex(), subtract 1.
  295. virtual const CBitVec<MAX_EDICTS>* GetEntityTransmitBitsForClient( int iClientIndex ) = 0;
  296. // Is the game paused?
  297. virtual bool IsPaused() = 0;
  298. // What is the game timescale multiplied with the host_timescale?
  299. virtual float GetTimescale( void ) const = 0;
  300. // Marks the filename for consistency checking. This should be called after precaching the file.
  301. virtual void ForceExactFile( const char *s ) = 0;
  302. virtual void ForceModelBounds( const char *s, const Vector &mins, const Vector &maxs ) = 0;
  303. virtual void ClearSaveDirAfterClientLoad() = 0;
  304. // Sets a USERINFO client ConVar for a fakeclient
  305. virtual void SetFakeClientConVarValue( edict_t *pEntity, const char *cvar, const char *value ) = 0;
  306. // Marks the material (vmt file) for consistency checking. If the client and server have different
  307. // contents for the file, the client's vmt can only use the VertexLitGeneric shader, and can only
  308. // contain $baseTexture and $bumpmap vars.
  309. virtual void ForceSimpleMaterial( const char *s ) = 0;
  310. // Is the engine in Commentary mode?
  311. virtual int IsInCommentaryMode( void ) = 0;
  312. // Is the engine running a background map?
  313. virtual bool IsLevelMainMenuBackground( void ) = 0;
  314. // Mark some area portals as open/closed. It's more efficient to use this
  315. // than a bunch of individual SetAreaPortalState calls.
  316. virtual void SetAreaPortalStates( const int *portalNumbers, const int *isOpen, int nPortals ) = 0;
  317. // Called when relevant edict state flags change.
  318. virtual void NotifyEdictFlagsChange( int iEdict ) = 0;
  319. // Only valid during CheckTransmit. Also, only the PVS, networked areas, and
  320. // m_pTransmitInfo are valid in the returned strucutre.
  321. virtual const CCheckTransmitInfo* GetPrevCheckTransmitInfo( edict_t *pPlayerEdict ) = 0;
  322. virtual CSharedEdictChangeInfo* GetSharedEdictChangeInfo() = 0;
  323. // Tells the engine we can immdiately re-use all edict indices
  324. // even though we may not have waited enough time
  325. virtual void AllowImmediateEdictReuse( ) = 0;
  326. // Returns true if the engine is an internal build. i.e. is using the internal bugreporter.
  327. virtual bool IsInternalBuild( void ) = 0;
  328. virtual IChangeInfoAccessor *GetChangeAccessor( const edict_t *pEdict ) = 0;
  329. // Name of most recently load .sav file
  330. virtual char const *GetMostRecentlyLoadedFileName() = 0;
  331. virtual char const *GetSaveFileName() = 0;
  332. // Cleans up the cluster list
  333. virtual void CleanUpEntityClusterList( PVSInfo_t *pPVSInfo ) = 0;
  334. virtual void SetAchievementMgr( IAchievementMgr *pAchievementMgr ) =0;
  335. virtual IAchievementMgr *GetAchievementMgr() = 0;
  336. virtual int GetAppID() = 0;
  337. virtual bool IsLowViolence() = 0;
  338. virtual bool IsAnyClientLowViolence() = 0;
  339. // Call this to find out the value of a cvar on the client.
  340. //
  341. // It is an asynchronous query, and it will call IServerGameDLL::OnQueryCvarValueFinished when
  342. // the value comes in from the client.
  343. //
  344. // Store the return value if you want to match this specific query to the OnQueryCvarValueFinished call.
  345. // Returns InvalidQueryCvarCookie if the entity is invalid.
  346. virtual QueryCvarCookie_t StartQueryCvarValue( edict_t *pPlayerEntity, const char *pName ) = 0;
  347. virtual void InsertServerCommand( const char *str ) = 0;
  348. // Fill in the player info structure for the specified player index (name, model, etc.)
  349. virtual bool GetPlayerInfo( int ent_num, player_info_t *pinfo ) = 0;
  350. // Returns true if this client has been fully authenticated by Steam
  351. virtual bool IsClientFullyAuthenticated( edict_t *pEdict ) = 0;
  352. // This makes the host run 1 tick per frame instead of checking the system timer to see how many ticks to run in a certain frame.
  353. // i.e. it does the same thing timedemo does.
  354. virtual void SetDedicatedServerBenchmarkMode( bool bBenchmarkMode ) = 0;
  355. virtual bool IsSplitScreenPlayer( int ent_num ) = 0;
  356. virtual edict_t *GetSplitScreenPlayerAttachToEdict( int ent_num ) = 0;
  357. virtual int GetNumSplitScreenUsersAttachedToEdict( int ent_num ) = 0;
  358. virtual edict_t *GetSplitScreenPlayerForEdict( int ent_num, int nSlot ) = 0;
  359. // Used by Foundry to hook into the loadgame process and override the entities that are getting loaded.
  360. virtual bool IsOverrideLoadGameEntsOn() = 0;
  361. // Used by Foundry when it changes an entity (and possibly its class) but preserves its serial number.
  362. virtual void ForceFlushEntity( int iEntity ) = 0;
  363. //Finds or Creates a shared memory space, the returned pointer will automatically be AddRef()ed
  364. virtual ISPSharedMemory *GetSinglePlayerSharedMemorySpace( const char *szName, int ent_num = MAX_EDICTS ) = 0;
  365. // Allocate hunk memory
  366. virtual void *AllocLevelStaticData( size_t bytes ) = 0;
  367. // Gets a list of all clusters' bounds. Returns total number of clusters.
  368. virtual int GetClusterCount() = 0;
  369. virtual int GetAllClusterBounds( bbox_t *pBBoxList, int maxBBox ) = 0;
  370. virtual bool IsCreatingReslist() = 0;
  371. virtual bool IsCreatingXboxReslist() = 0;
  372. virtual bool IsDedicatedServerForXbox() = 0;
  373. virtual bool IsDedicatedServerForPS3( void ) = 0;
  374. virtual void Pause( bool bPause, bool bForce = false ) = 0;
  375. virtual void SetTimescale( float flTimescale ) = 0;
  376. // Methods to set/get a gamestats data container so client & server running in same process can send combined data
  377. virtual void SetGamestatsData( CGamestatsData *pGamestatsData ) = 0;
  378. virtual CGamestatsData *GetGamestatsData() = 0;
  379. // Returns the SteamID of the specified player. It'll be NULL if the player hasn't authenticated yet.
  380. virtual const CSteamID *GetClientSteamID( const edict_t *pPlayerEdict, bool bRequireFullyAuthenticated = false ) = 0;
  381. // Returns the SteamID of the game server
  382. virtual const CSteamID *GetGameServerSteamID() = 0;
  383. // Validate session
  384. virtual void HostValidateSession() = 0;
  385. // Update the 360 pacifier/spinner
  386. virtual void RefreshScreenIfNecessary() = 0;
  387. // Tells the engine to allocate paint surfaces
  388. virtual bool HasPaintmap() = 0;
  389. // Returns true if the surface paint colors changed
  390. virtual bool SpherePaintSurface( const model_t *pModel, const Vector& vPosition, BYTE color, float flSphereRadius, float flPaintCoatPercent ) = 0;
  391. virtual void SphereTracePaintSurface( const model_t *pModel, const Vector& vPosition, const Vector& vContactNormal, float flSphereRadius, CUtlVector<BYTE>& surfColor ) = 0;
  392. virtual void RemoveAllPaint() = 0;
  393. virtual void PaintAllSurfaces( BYTE color ) = 0;
  394. virtual void RemovePaint( const model_t* pModel ) = 0;
  395. // Send a client command keyvalues
  396. // keyvalues are deleted inside the function
  397. virtual void ClientCommandKeyValues( edict_t *pEdict, KeyValues *pCommand ) = 0;
  398. // Returns the XUID of the specified player. It'll be NULL if the player hasn't connected yet.
  399. virtual uint64 GetClientXUID( edict_t *pPlayerEdict ) = 0;
  400. virtual bool IsActiveApp() = 0;
  401. virtual void SetNoClipEnabled( bool bEnabled ) = 0;
  402. virtual void GetPaintmapDataRLE( CUtlVector<uint32> &data ) = 0;
  403. virtual void LoadPaintmapDataRLE( const CUtlVector< uint32 > &data ) = 0;
  404. virtual void SendPaintmapDataToClient( edict_t *pPlayerEdict ) = 0;
  405. // Gets the accumulated latency for the sounds related to choreos.
  406. virtual float GetLatencyForChoreoSounds() = 0;
  407. virtual CrossPlayPlatform_t GetClientCrossPlayPlatform( int ent_num ) = 0;
  408. // Create the instance baseline for a serverclass if it doesn't exist in the engine's list already
  409. virtual void EnsureInstanceBaseline( int ent_num ) = 0;
  410. // Sets server reservation payload
  411. virtual bool ReserveServerForQueuedGame( char const *szReservationPayload ) = 0;
  412. // Get the TV information
  413. virtual bool GetEngineHltvInfo( CEngineHltvInfo_t &info ) = 0;
  414. // Add HLTV proxy whitelist to bypass password and Steam Auth checks upon connection, as CIDR a.b.c.d/numbits
  415. virtual void AddHltvRelayProxyWhitelist( uint32 a, uint32 b, uint32 c, uint32 d, uint32 numbits ) = 0;
  416. // Server version from the steam.inf, this will be compared to the GC version
  417. virtual int GetServerVersion() const = 0;
  418. // On master HLTV this call updates number of external viewers and which portion of those are linked with Steam
  419. virtual void UpdateHltvExternalViewers( uint32 numTotalViewers, uint32 numLinkedViewers ) = 0;
  420. // Check whether sv_shutdown was requested
  421. virtual bool WasShutDownRequested() const = 0;
  422. virtual bool StartClientHltvReplay( int nClientIndex, const HltvReplayParams_t &params ) = 0;
  423. virtual void StopClientHltvReplay( int nClientIndex ) = 0;
  424. virtual int GetClientHltvReplayDelay( int nClientIndex ) = 0;
  425. virtual bool HasHltvReplay() = 0;
  426. virtual bool ClientCanStartHltvReplay( int nClientIndex ) = 0;
  427. virtual void ClientResetReplayRequestTime( int nClientIndex ) = 0;
  428. virtual bool AnyClientsInHltvReplayMode() = 0;
  429. virtual int GetLocalClientIndex( void ) = 0;
  430. };
  431. #define INTERFACEVERSION_SERVERGAMEDLL "ServerGameDLL005"
  432. //-----------------------------------------------------------------------------
  433. // Purpose: These are the interfaces that the game .dll exposes to the engine
  434. //-----------------------------------------------------------------------------
  435. abstract_class IServerGameDLL
  436. {
  437. public:
  438. // Initialize the game (one-time call when the DLL is first loaded )
  439. // Return false if there is an error during startup.
  440. virtual bool DLLInit( CreateInterfaceFn engineFactory,
  441. CreateInterfaceFn physicsFactory,
  442. CreateInterfaceFn fileSystemFactory,
  443. CGlobalVars *pGlobals) = 0;
  444. // This is called when a new game is started. (restart, map)
  445. virtual bool GameInit( void ) = 0;
  446. // Called any time a new level is started (after GameInit() also on level transitions within a game)
  447. virtual bool LevelInit( char const *pMapName,
  448. char const *pMapEntities, char const *pOldLevel,
  449. char const *pLandmarkName, bool loadGame, bool background ) = 0;
  450. // The server is about to activate
  451. virtual void ServerActivate( edict_t *pEdictList, int edictCount, int clientMax ) = 0;
  452. // The server should run physics/think on all edicts
  453. virtual void GameFrame( bool simulating ) = 0;
  454. // Called once per simulation frame on the final tick
  455. virtual void PreClientUpdate( bool simulating ) = 0;
  456. // Called when a level is shutdown (including changing levels)
  457. virtual void LevelShutdown( void ) = 0;
  458. // This is called when a game ends (server disconnect, death, restart, load)
  459. // NOT on level transitions within a game
  460. virtual void GameShutdown( void ) = 0;
  461. // Called once during DLL shutdown
  462. virtual void DLLShutdown( void ) = 0;
  463. // Get the simulation interval (must be compiled with identical values into both client and game .dll for MOD!!!)
  464. // Right now this is only requested at server startup time so it can't be changed on the fly, etc.
  465. virtual float GetTickInterval( void ) const = 0;
  466. // Give the list of datatable classes to the engine. The engine matches class names from here with
  467. // edict_t::classname to figure out how to encode a class's data for networking
  468. virtual ServerClass* GetAllServerClasses( void ) = 0;
  469. // Returns string describing current .dll. e.g., TeamFortress 2, Half-Life 2.
  470. // Hey, it's more descriptive than just the name of the game directory
  471. virtual const char *GetGameDescription( void ) = 0;
  472. // Let the game .dll allocate it's own network/shared string tables
  473. virtual void CreateNetworkStringTables( void ) = 0;
  474. // Save/restore system hooks
  475. virtual CSaveRestoreData *SaveInit( int size ) = 0;
  476. virtual void SaveWriteFields( CSaveRestoreData *, const char *, void *, datamap_t *, typedescription_t *, int ) = 0;
  477. virtual void SaveReadFields( CSaveRestoreData *, const char *, void *, datamap_t *, typedescription_t *, int ) = 0;
  478. virtual void SaveGlobalState( CSaveRestoreData * ) = 0;
  479. virtual void RestoreGlobalState( CSaveRestoreData * ) = 0;
  480. virtual void PreSave( CSaveRestoreData * ) = 0;
  481. virtual void Save( CSaveRestoreData * ) = 0;
  482. virtual void GetSaveComment( char *comment, int maxlength, float flMinutes, float flSeconds, bool bNoTime = false ) = 0;
  483. virtual void WriteSaveHeaders( CSaveRestoreData * ) = 0;
  484. virtual void ReadRestoreHeaders( CSaveRestoreData * ) = 0;
  485. virtual void Restore( CSaveRestoreData *, bool ) = 0;
  486. virtual bool IsRestoring() = 0;
  487. virtual bool SupportsSaveRestore() = 0;
  488. // Returns the number of entities moved across the transition
  489. virtual int CreateEntityTransitionList( CSaveRestoreData *, int ) = 0;
  490. // Build the list of maps adjacent to the current map
  491. virtual void BuildAdjacentMapList( void ) = 0;
  492. // Hand over the StandardSendProxies in the game DLL's module.
  493. virtual CStandardSendProxies* GetStandardSendProxies() = 0;
  494. // Called once during startup, after the game .dll has been loaded and after the client .dll has also been loaded
  495. virtual void PostInit() = 0;
  496. // Called once per frame even when no level is loaded...
  497. virtual void Think( bool finalTick ) = 0;
  498. virtual void PreSaveGameLoaded( char const *pSaveName, bool bCurrentlyInGame ) = 0;
  499. // Returns true if the game DLL wants the server not to be made public.
  500. // Used by commentary system to hide multiplayer commentary servers from the master.
  501. virtual bool ShouldHideServer( void ) = 0;
  502. virtual void InvalidateMdlCache() = 0;
  503. // * This function is new with version 6 of the interface.
  504. //
  505. // This is called when a query from IServerPluginHelpers::StartQueryCvarValue is finished.
  506. // iCookie is the value returned by IServerPluginHelpers::StartQueryCvarValue.
  507. // Added with version 2 of the interface.
  508. virtual void OnQueryCvarValueFinished( QueryCvarCookie_t iCookie, edict_t *pPlayerEntity, EQueryCvarValueStatus eStatus, const char *pCvarName, const char *pCvarValue ) = 0;
  509. // Called after tools are initialized (i.e. when Foundry is initialized so we can get IServerFoundry).
  510. virtual void PostToolsInit() = 0;
  511. // When bActive = true the function is called after the steam API has been activated post-level startup
  512. // when bActive = false the function is called before the game server session will LogOff and all interfaces will shutdown
  513. virtual void GameServerSteamAPIActivated( bool bActive ) = 0;
  514. // Called to apply lobby settings to a dedicated server
  515. virtual void ApplyGameSettings( KeyValues *pKV ) = 0;
  516. //
  517. virtual void GetMatchmakingTags( char *buf, size_t bufSize ) = 0;
  518. virtual void ServerHibernationUpdate( bool bHibernating ) = 0;
  519. virtual bool ShouldPreferSteamAuth() = 0;
  520. // Added for CS:GO -
  521. // In Competetive mode we do not want to allow direct-connect to Valve servers
  522. virtual bool ShouldAllowDirectConnect() = 0;
  523. virtual bool FriendsReqdForDirectConnect() = 0;
  524. virtual bool IsLoadTestServer() = 0;
  525. // Is this an Official dedicated server for ranked matchmaking?
  526. virtual bool IsValveDS() = 0;
  527. // Builds extended server info for new connecting client
  528. virtual KeyValues* GetExtendedServerInfoForNewClient() = 0;
  529. // Updates GC information for this server
  530. virtual void UpdateGCInformation() = 0;
  531. // Marks the queue matchmaking game as starting
  532. virtual void ReportGCQueuedMatchStart( int32 iReservationStage, uint32 *puiConfirmedAccounts, int numConfirmedAccounts ) = 0;
  533. // Get the published file id for the community map this server is running. 0 if non-ugc map or no map is running.
  534. virtual PublishedFileId_t GetUGCMapFileID( const char* szMapPath ) = 0;
  535. // Matchmaking game data buffer to set into SteamGameServer()->SetGameData
  536. virtual void GetMatchmakingGameData( char *buf, size_t bufSize ) = 0;
  537. // Returns true if server is in the process of updating the given map
  538. virtual bool HasPendingMapDownloads( void ) const = 0;
  539. virtual void UpdateUGCMap( PublishedFileId_t id ) = 0;
  540. // Returns which encryption key to use for messages to be encrypted for TV
  541. virtual EncryptedMessageKeyType_t GetMessageEncryptionKey( INetMessage *pMessage ) = 0;
  542. // If server game dll needs more time before server process quits then
  543. // it should return true to hold game server reservation from this interface method.
  544. // If this method returns false then the server process will clear the reservation
  545. // and might shutdown to meet uptime or memory limit requirements.
  546. virtual bool ShouldHoldGameServerReservation( float flTimeElapsedWithoutClients ) = 0;
  547. // Pure server validation failed for the given client, client supplied
  548. // data is included in the payload
  549. virtual void OnPureServerFileValidationFailure( edict_t *edictClient, const char *path, const char *fileName, uint32 crc, int32 hashType, int32 len, int packNumber, int packFileID ) = 0;
  550. // Precaches particle systems defined in the specific file
  551. virtual void PrecacheParticleSystemFile( const char *pParticleSystemFile ) = 0;
  552. // Last chance validation on connect packet for the client, non-NULL return value
  553. // causes the client connect to be aborted with the provided error
  554. virtual char const * ClientConnectionValidatePreNetChan( bool bGameServer, char const *adr, int nAuthProtocol, uint64 ullSteamID ) = 0;
  555. // Network channel notification from engine to game server code
  556. virtual void OnEngineClientNetworkEvent( edict_t *edictClient, uint64 ullSteamID, int nEventType, void *pvParam ) = 0;
  557. // Engine notifying GC with a message
  558. virtual void EngineGotvSyncPacket( const CEngineGotvSyncPacket *pPkt ) = 0;
  559. // GOTV client attempt redirect over SDR
  560. virtual bool OnEngineClientProxiedRedirect( uint64 ullClient, const char *adrProxiedRedirect, const char *adrRegular ) = 0;
  561. // Tell server about a line we will write to the log file which may be sent to remote listeners
  562. virtual bool LogForHTTPListeners( const char* szLogLine ) = 0;
  563. };
  564. //-----------------------------------------------------------------------------
  565. // Just an interface version name for the random number interface
  566. // See vstdlib/random.h for the interface definition
  567. // NOTE: If you change this, also change VENGINE_CLIENT_RANDOM_INTERFACE_VERSION in cdll_int.h
  568. //-----------------------------------------------------------------------------
  569. #define VENGINE_SERVER_RANDOM_INTERFACE_VERSION "VEngineRandom001"
  570. #define INTERFACEVERSION_SERVERGAMEENTS "ServerGameEnts001"
  571. //-----------------------------------------------------------------------------
  572. // Purpose: Interface to get at server entities
  573. //-----------------------------------------------------------------------------
  574. abstract_class IServerGameEnts
  575. {
  576. public:
  577. virtual ~IServerGameEnts() {}
  578. // The engine wants to mark two entities as touching
  579. virtual void MarkEntitiesAsTouching( edict_t *e1, edict_t *e2 ) = 0;
  580. // Frees the entity attached to this edict
  581. virtual void FreeContainingEntity( edict_t * ) = 0;
  582. // This allows the engine to get at edicts in a CGameTrace.
  583. virtual edict_t* BaseEntityToEdict( CBaseEntity *pEnt ) = 0;
  584. virtual CBaseEntity* EdictToBaseEntity( edict_t *pEdict ) = 0;
  585. // This sets a bit in pInfo for each edict in the list that wants to be transmitted to the
  586. // client specified in pInfo.
  587. //
  588. // This is also where an entity can force other entities to be transmitted if it refers to them
  589. // with ehandles.
  590. virtual void CheckTransmit( CCheckTransmitInfo *pInfo, const unsigned short *pEdictIndices, int nEdicts ) = 0;
  591. // TERROR: Perform any PVS cleanup before a full update
  592. virtual void PrepareForFullUpdate( edict_t *pEdict ) = 0;
  593. };
  594. #define INTERFACEVERSION_SERVERGAMECLIENTS "ServerGameClients004"
  595. //-----------------------------------------------------------------------------
  596. // Purpose: Player / Client related functions
  597. //-----------------------------------------------------------------------------
  598. abstract_class IServerGameClients
  599. {
  600. public:
  601. // Get server maxplayers and lower bound for same
  602. virtual void GetPlayerLimits( int& minplayers, int& maxplayers, int &defaultMaxPlayers ) const = 0;
  603. // Client is connecting to server ( return false to reject the connection )
  604. // You can specify a rejection message by writing it into reject
  605. virtual bool ClientConnect( edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen ) = 0;
  606. // Client is going active
  607. // If bLoadGame is true, don't spawn the player because its state is already setup.
  608. virtual void ClientActive( edict_t *pEntity, bool bLoadGame ) = 0;
  609. virtual void ClientFullyConnect( edict_t *pEntity ) = 0;
  610. // Client is disconnecting from server
  611. virtual void ClientDisconnect( edict_t *pEntity ) = 0;
  612. // Client is connected and should be put in the game
  613. virtual void ClientPutInServer( edict_t *pEntity, char const *playername ) = 0;
  614. // The client has typed a command at the console
  615. virtual void ClientCommand( edict_t *pEntity, const CCommand &args ) = 0;
  616. // Sets the client index for the client who typed the command into his/her console
  617. virtual void SetCommandClient( int index ) = 0;
  618. // A player changed one/several replicated cvars (name etc)
  619. virtual void ClientSettingsChanged( edict_t *pEdict ) = 0;
  620. // Determine PVS origin and set PVS for the player/viewentity
  621. virtual void ClientSetupVisibility( edict_t *pViewEntity, edict_t *pClient, unsigned char *pvs, int pvssize ) = 0;
  622. // A block of CUserCmds has arrived from the user, decode them and buffer for execution during player simulation
  623. virtual float ProcessUsercmds( edict_t *player, bf_read *buf, int numcmds, int totalcmds,
  624. int dropped_packets, bool ignore, bool paused ) = 0;
  625. // Let the game .dll do stuff after messages have been sent to all of the clients once the server frame is complete
  626. virtual void PostClientMessagesSent( void ) = 0;
  627. // For players, looks up the CPlayerState structure corresponding to the player
  628. virtual CPlayerState *GetPlayerState( edict_t *player ) = 0;
  629. // Get the ear position for a specified client
  630. virtual void ClientEarPosition( edict_t *pEntity, Vector *pEarOrigin ) = 0;
  631. virtual bool ClientReplayEvent( edict_t *pEntity, const ClientReplayEventParams_t &params ) = 0;
  632. // returns number of delay ticks if player is in Replay mode (0 = no delay)
  633. virtual int GetReplayDelay( edict_t *player, int& entity ) = 0;
  634. // Anything this game .dll wants to add to the bug reporter text (e.g., the entity/model under the picker crosshair)
  635. // can be added here
  636. virtual void GetBugReportInfo( char *buf, int buflen ) = 0;
  637. // TERROR: A player sent a voice packet
  638. virtual void ClientVoice( edict_t *pEdict ) = 0;
  639. // A user has had their network id setup and validated
  640. virtual void NetworkIDValidated( const char *pszUserName, const char *pszNetworkID, CSteamID steamID ) = 0;
  641. // Returns max splitscreen slot count ( 1 == no splits, 2 for 2-player split screen )
  642. virtual int GetMaxSplitscreenPlayers() = 0;
  643. // Return # of human slots, -1 if can't determine or don't care (engine will assume it's == maxplayers )
  644. virtual int GetMaxHumanPlayers() = 0;
  645. // The client has submitted a keyvalues command
  646. virtual void ClientCommandKeyValues( edict_t *pEntity, KeyValues *pKeyValues ) = 0;
  647. // Server override for supplied client name
  648. virtual const char * ClientNameHandler( uint64 xuid, const char *pchName ) = 0;
  649. // Client submitted a user command
  650. virtual void ClientSvcUserMessage( edict_t *pEntity, int nType, int nPassthrough, uint32 cbSize, const void *pvBuffer ) = 0;
  651. };
  652. #define INTERFACEVERSION_UPLOADGAMESTATS "ServerUploadGameStats001"
  653. abstract_class IUploadGameStats
  654. {
  655. public:
  656. // Note that this call will block the server until the upload is completed, so use only at levelshutdown if at all.
  657. virtual bool UploadGameStats(
  658. char const *mapname, // Game map name
  659. unsigned int blobversion, // Version of the binary blob data
  660. unsigned int blobsize, // Size in bytes of blob data
  661. const void *pvBlobData ) = 0; // Pointer to the blob data.
  662. // Call when created to init the CSER connection
  663. virtual void InitConnection( void ) = 0;
  664. // Call periodically to poll steam for a CSER connection
  665. virtual void UpdateConnection( void ) = 0;
  666. // If user has disabled stats tracking, do nothing
  667. virtual bool IsGameStatsLoggingEnabled() = 0;
  668. // Gets a non-personally identifiable unique ID for this steam user, used for tracking total gameplay time across
  669. // multiple stats sessions, but isn't trackable back to their Steam account or id.
  670. // Buffer should be 16 bytes, ID will come back as a hexadecimal string version of a GUID
  671. virtual void GetPseudoUniqueId( char *buf, size_t bufsize ) = 0;
  672. // For determining general % of users running using cyber cafe accounts...
  673. virtual bool IsCyberCafeUser( void ) = 0;
  674. // Only works in single player
  675. virtual bool IsHDREnabled( void ) = 0;
  676. };
  677. #define INTERFACEVERSION_PLUGINHELPERSCHECK "PluginHelpersCheck001"
  678. //-----------------------------------------------------------------------------
  679. // Purpose: allows the game dll to control which plugin functions can be run
  680. //-----------------------------------------------------------------------------
  681. abstract_class IPluginHelpersCheck
  682. {
  683. public:
  684. virtual bool CreateMessage( const char *plugin, edict_t *pEntity, DIALOG_TYPE type, KeyValues *data ) = 0;
  685. };
  686. //-----------------------------------------------------------------------------
  687. // Purpose: Interface exposed from the client .dll back to the engine for specifying shared .dll IAppSystems (e.g., ISoundEmitterSystem)
  688. //-----------------------------------------------------------------------------
  689. abstract_class IServerDLLSharedAppSystems
  690. {
  691. public:
  692. virtual int Count() = 0;
  693. virtual char const *GetDllName( int idx ) = 0;
  694. virtual char const *GetInterfaceName( int idx ) = 0;
  695. };
  696. #define SERVER_DLL_SHARED_APPSYSTEMS "VServerDllSharedAppSystems001"
  697. #define INTERFACEVERSION_SERVERGAMETAGS "ServerGameTags001"
  698. //-----------------------------------------------------------------------------
  699. // Purpose: querying the game dll for Server cvar tags
  700. //-----------------------------------------------------------------------------
  701. abstract_class IServerGameTags
  702. {
  703. public:
  704. // Get the list of cvars that require tags to show differently in the server browser
  705. virtual void GetTaggedConVarList( KeyValues *pCvarTagList ) = 0;
  706. };
  707. #endif // EIFACE_H