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.

809 lines
35 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Interfaces between the client.dll and engine
  4. //
  5. //===========================================================================//
  6. #ifndef CDLL_INT_H
  7. #define CDLL_INT_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "basetypes.h"
  12. #include "interface.h"
  13. #include "mathlib/mathlib.h"
  14. #include "const.h"
  15. #include "checksum_crc.h"
  16. #include "datamap.h"
  17. #include "tier1/bitbuf.h"
  18. #include "inputsystem/ButtonCode.h"
  19. #include "modes.h"
  20. #if !defined( _X360 )
  21. #include "xbox/xboxstubs.h"
  22. #endif
  23. //-----------------------------------------------------------------------------
  24. // forward declarations
  25. //-----------------------------------------------------------------------------
  26. class ClientClass;
  27. struct model_t;
  28. class CSentence;
  29. struct vrect_t;
  30. struct cmodel_t;
  31. class IMaterial;
  32. class CAudioSource;
  33. class CMeasureSection;
  34. class SurfInfo;
  35. class ISpatialQuery;
  36. struct cache_user_t;
  37. class IMaterialSystem;
  38. class VMatrix;
  39. struct ScreenFade_t;
  40. struct ScreenShake_t;
  41. class CViewSetup;
  42. class CEngineSprite;
  43. class CGlobalVarsBase;
  44. class CPhysCollide;
  45. class CSaveRestoreData;
  46. class INetChannelInfo;
  47. struct datamap_t;
  48. struct typedescription_t;
  49. class CStandardRecvProxies;
  50. struct client_textmessage_t;
  51. class IAchievementMgr;
  52. class CGamestatsData;
  53. class KeyValues;
  54. class IFileList;
  55. class CRenamedRecvTableInfo;
  56. class CMouthInfo;
  57. class IConVar;
  58. //-----------------------------------------------------------------------------
  59. // Purpose: This data structure is filled in by the engine when the client .dll requests information about
  60. // other players that the engine knows about
  61. //-----------------------------------------------------------------------------
  62. // Engine player info, no game related infos here
  63. // If you change this, change the two byteswap defintions:
  64. // cdll_client_int.cpp and cdll_engine_int.cpp
  65. typedef struct player_info_s
  66. {
  67. DECLARE_BYTESWAP_DATADESC();
  68. // scoreboard information
  69. char name[MAX_PLAYER_NAME_LENGTH];
  70. // local server user ID, unique while server is running
  71. int userID;
  72. // global unique player identifer
  73. char guid[SIGNED_GUID_LEN + 1];
  74. // friends identification number
  75. uint32 friendsID;
  76. // friends name
  77. char friendsName[MAX_PLAYER_NAME_LENGTH];
  78. // true, if player is a bot controlled by game.dll
  79. bool fakeplayer;
  80. // true if player is the HLTV proxy
  81. bool ishltv;
  82. #if defined( REPLAY_ENABLED )
  83. // true if player is the Replay proxy
  84. bool isreplay;
  85. #endif
  86. // custom files CRC for this player
  87. CRC32_t customFiles[MAX_CUSTOM_FILES];
  88. // this counter increases each time the server downloaded a new file
  89. unsigned char filesDownloaded;
  90. } player_info_t;
  91. //-----------------------------------------------------------------------------
  92. // Hearing info
  93. //-----------------------------------------------------------------------------
  94. struct AudioState_t
  95. {
  96. Vector m_Origin;
  97. QAngle m_Angles;
  98. bool m_bIsUnderwater;
  99. };
  100. //-----------------------------------------------------------------------------
  101. // Skybox visibility
  102. //-----------------------------------------------------------------------------
  103. enum SkyboxVisibility_t
  104. {
  105. SKYBOX_NOT_VISIBLE = 0,
  106. SKYBOX_3DSKYBOX_VISIBLE,
  107. SKYBOX_2DSKYBOX_VISIBLE,
  108. };
  109. //-----------------------------------------------------------------------------
  110. // Skybox materials
  111. //-----------------------------------------------------------------------------
  112. struct SkyBoxMaterials_t
  113. {
  114. // order: "rt", "bk", "lf", "ft", "up", "dn"
  115. IMaterial *material[6];
  116. };
  117. //-----------------------------------------------------------------------------
  118. // Purpose: The engine reports to the client DLL what stage it's entering so the DLL can latch events
  119. // and make sure that certain operations only happen during the right stages.
  120. // The value for each stage goes up as you move through the frame so you can check ranges of values
  121. // and if new stages get added in-between, the range is still valid.
  122. //-----------------------------------------------------------------------------
  123. enum ClientFrameStage_t
  124. {
  125. FRAME_UNDEFINED=-1, // (haven't run any frames yet)
  126. FRAME_START,
  127. // A network packet is being recieved
  128. FRAME_NET_UPDATE_START,
  129. // Data has been received and we're going to start calling PostDataUpdate
  130. FRAME_NET_UPDATE_POSTDATAUPDATE_START,
  131. // Data has been received and we've called PostDataUpdate on all data recipients
  132. FRAME_NET_UPDATE_POSTDATAUPDATE_END,
  133. // We've received all packets, we can now do interpolation, prediction, etc..
  134. FRAME_NET_UPDATE_END,
  135. // We're about to start rendering the scene
  136. FRAME_RENDER_START,
  137. // We've finished rendering the scene.
  138. FRAME_RENDER_END
  139. };
  140. // Used by RenderView
  141. enum RenderViewInfo_t
  142. {
  143. RENDERVIEW_UNSPECIFIED = 0,
  144. RENDERVIEW_DRAWVIEWMODEL = (1<<0),
  145. RENDERVIEW_DRAWHUD = (1<<1),
  146. RENDERVIEW_SUPPRESSMONITORRENDERING = (1<<2),
  147. };
  148. //-----------------------------------------------------------------------------
  149. // Lightcache entry handle
  150. //-----------------------------------------------------------------------------
  151. DECLARE_POINTER_HANDLE( LightCacheHandle_t );
  152. //-----------------------------------------------------------------------------
  153. // Occlusion parameters
  154. //-----------------------------------------------------------------------------
  155. struct OcclusionParams_t
  156. {
  157. float m_flMaxOccludeeArea;
  158. float m_flMinOccluderArea;
  159. };
  160. //-----------------------------------------------------------------------------
  161. // Just an interface version name for the random number interface
  162. // See vstdlib/random.h for the interface definition
  163. // NOTE: If you change this, also change VENGINE_SERVER_RANDOM_INTERFACE_VERSION in eiface.h
  164. //-----------------------------------------------------------------------------
  165. #define VENGINE_CLIENT_RANDOM_INTERFACE_VERSION "VEngineRandom001"
  166. // change this when the new version is incompatable with the old
  167. #define VENGINE_CLIENT_INTERFACE_VERSION "VEngineClient014"
  168. #define VENGINE_CLIENT_INTERFACE_VERSION_13 "VEngineClient013"
  169. //-----------------------------------------------------------------------------
  170. // Purpose: Interface exposed from the engine to the client .dll
  171. //-----------------------------------------------------------------------------
  172. abstract_class IVEngineClient013
  173. {
  174. public:
  175. // Find the model's surfaces that intersect the given sphere.
  176. // Returns the number of surfaces filled in.
  177. virtual int GetIntersectingSurfaces(
  178. const model_t *model,
  179. const Vector &vCenter,
  180. const float radius,
  181. const bool bOnlyVisibleSurfaces, // Only return surfaces visible to vCenter.
  182. SurfInfo *pInfos,
  183. const int nMaxInfos) = 0;
  184. // Get the lighting intensivty for a specified point
  185. // If bClamp is specified, the resulting Vector is restricted to the 0.0 to 1.0 for each element
  186. virtual Vector GetLightForPoint(const Vector &pos, bool bClamp) = 0;
  187. // Traces the line and reports the material impacted as well as the lighting information for the impact point
  188. virtual IMaterial *TraceLineMaterialAndLighting( const Vector &start, const Vector &end,
  189. Vector &diffuseLightColor, Vector& baseColor ) = 0;
  190. // Given an input text buffer data pointer, parses a single token into the variable token and returns the new
  191. // reading position
  192. virtual const char *ParseFile( const char *data, char *token, int maxlen ) = 0;
  193. virtual bool CopyLocalFile( const char *source, const char *destination ) = 0;
  194. // Gets the dimensions of the game window
  195. virtual void GetScreenSize( int& width, int& height ) = 0;
  196. // Forwards szCmdString to the server, sent reliably if bReliable is set
  197. virtual void ServerCmd( const char *szCmdString, bool bReliable = true ) = 0;
  198. // Inserts szCmdString into the command buffer as if it was typed by the client to his/her console.
  199. // Note: Calls to this are checked against FCVAR_CLIENTCMD_CAN_EXECUTE (if that bit is not set, then this function can't change it).
  200. // Call ClientCmd_Unrestricted to have access to FCVAR_CLIENTCMD_CAN_EXECUTE vars.
  201. virtual void ClientCmd( const char *szCmdString ) = 0;
  202. // Fill in the player info structure for the specified player index (name, model, etc.)
  203. virtual bool GetPlayerInfo( int ent_num, player_info_t *pinfo ) = 0;
  204. // Retrieve the player entity number for a specified userID
  205. virtual int GetPlayerForUserID( int userID ) = 0;
  206. // Retrieves text message system information for the specified message by name
  207. virtual client_textmessage_t *TextMessageGet( const char *pName ) = 0;
  208. // Returns true if the console is visible
  209. virtual bool Con_IsVisible( void ) = 0;
  210. // Get the entity index of the local player
  211. virtual int GetLocalPlayer( void ) = 0;
  212. // Client DLL is hooking a model, loads the model into memory and returns pointer to the model_t
  213. virtual const model_t *LoadModel( const char *pName, bool bProp = false ) = 0;
  214. // Get accurate, sub-frame clock ( profiling use )
  215. virtual float Time( void ) = 0;
  216. // Get the exact server timesstamp ( server time ) from the last message received from the server
  217. virtual float GetLastTimeStamp( void ) = 0;
  218. // Given a CAudioSource (opaque pointer), retrieve the underlying CSentence object ( stores the words, phonemes, and close
  219. // captioning data )
  220. virtual CSentence *GetSentence( CAudioSource *pAudioSource ) = 0;
  221. // Given a CAudioSource, determines the length of the underlying audio file (.wav, .mp3, etc.)
  222. virtual float GetSentenceLength( CAudioSource *pAudioSource ) = 0;
  223. // Returns true if the sound is streaming off of the hard disk (instead of being memory resident)
  224. virtual bool IsStreaming( CAudioSource *pAudioSource ) const = 0;
  225. // Copy current view orientation into va
  226. virtual void GetViewAngles( QAngle& va ) = 0;
  227. // Set current view orientation from va
  228. virtual void SetViewAngles( QAngle& va ) = 0;
  229. // Retrieve the current game's maxclients setting
  230. virtual int GetMaxClients( void ) = 0;
  231. // Given the string pBinding which may be bound to a key,
  232. // returns the string name of the key to which this string is bound. Returns NULL if no such binding exists
  233. virtual const char *Key_LookupBinding( const char *pBinding ) = 0;
  234. // Given the name of the key "mouse1", "e", "tab", etc., return the string it is bound to "+jump", "impulse 50", etc.
  235. virtual const char *Key_BindingForKey( ButtonCode_t code ) = 0;
  236. // key trapping (for binding keys)
  237. virtual void StartKeyTrapMode( void ) = 0;
  238. virtual bool CheckDoneKeyTrapping( ButtonCode_t &code ) = 0;
  239. // Returns true if the player is fully connected and active in game (i.e, not still loading)
  240. virtual bool IsInGame( void ) = 0;
  241. // Returns true if the player is connected, but not necessarily active in game (could still be loading)
  242. virtual bool IsConnected( void ) = 0;
  243. // Returns true if the loading plaque should be drawn
  244. virtual bool IsDrawingLoadingImage( void ) = 0;
  245. // Prints the formatted string to the notification area of the screen ( down the right hand edge
  246. // numbered lines starting at position 0
  247. virtual void Con_NPrintf( int pos, PRINTF_FORMAT_STRING const char *fmt, ... ) = 0;
  248. // Similar to Con_NPrintf, but allows specifying custom text color and duration information
  249. virtual void Con_NXPrintf( const struct con_nprint_s *info, PRINTF_FORMAT_STRING const char *fmt, ... ) = 0;
  250. // Is the specified world-space bounding box inside the view frustum?
  251. virtual int IsBoxVisible( const Vector& mins, const Vector& maxs ) = 0;
  252. // Is the specified world-space boudning box in the same PVS cluster as the view origin?
  253. virtual int IsBoxInViewCluster( const Vector& mins, const Vector& maxs ) = 0;
  254. // Returns true if the specified box is outside of the view frustum and should be culled
  255. virtual bool CullBox( const Vector& mins, const Vector& maxs ) = 0;
  256. // Allow the sound system to paint additional data (during lengthy rendering operations) to prevent stuttering sound.
  257. virtual void Sound_ExtraUpdate( void ) = 0;
  258. // Get the current game directory ( e.g., hl2, tf2, cstrike, hl1 )
  259. virtual const char *GetGameDirectory( void ) = 0;
  260. // Get access to the world to screen transformation matrix
  261. virtual const VMatrix& WorldToScreenMatrix() = 0;
  262. // Get the matrix to move a point from world space into view space
  263. // (translate and rotate so the camera is at the origin looking down X).
  264. virtual const VMatrix& WorldToViewMatrix() = 0;
  265. // The .bsp file can have mod-specified data lumps. These APIs are for working with such game lumps.
  266. // Get mod-specified lump version id for the specified game data lump
  267. virtual int GameLumpVersion( int lumpId ) const = 0;
  268. // Get the raw size of the specified game data lump.
  269. virtual int GameLumpSize( int lumpId ) const = 0;
  270. // Loads a game lump off disk, writing the data into the buffer pointed to bye pBuffer
  271. // Returns false if the data can't be read or the destination buffer is too small
  272. virtual bool LoadGameLump( int lumpId, void* pBuffer, int size ) = 0;
  273. // Returns the number of leaves in the level
  274. virtual int LevelLeafCount() const = 0;
  275. // Gets a way to perform spatial queries on the BSP tree
  276. virtual ISpatialQuery* GetBSPTreeQuery() = 0;
  277. // Convert texlight to gamma...
  278. virtual void LinearToGamma( float* linear, float* gamma ) = 0;
  279. // Get the lightstyle value
  280. virtual float LightStyleValue( int style ) = 0;
  281. // Computes light due to dynamic lighting at a point
  282. // If the normal isn't specified, then it'll return the maximum lighting
  283. virtual void ComputeDynamicLighting( const Vector& pt, const Vector* pNormal, Vector& color ) = 0;
  284. // Returns the color of the ambient light
  285. virtual void GetAmbientLightColor( Vector& color ) = 0;
  286. // Returns the dx support level
  287. virtual int GetDXSupportLevel() = 0;
  288. // GR - returns the HDR support status
  289. virtual bool SupportsHDR() = 0;
  290. // Replace the engine's material system pointer.
  291. virtual void Mat_Stub( IMaterialSystem *pMatSys ) = 0;
  292. // Get the name of the current map
  293. virtual void GetChapterName( char *pchBuff, int iMaxLength ) = 0;
  294. virtual char const *GetLevelName( void ) = 0;
  295. virtual int GetLevelVersion( void ) = 0;
  296. #if !defined( NO_VOICE )
  297. // Obtain access to the voice tweaking API
  298. virtual struct IVoiceTweak_s *GetVoiceTweakAPI( void ) = 0;
  299. #endif
  300. // Tell engine stats gathering system that the rendering frame is beginning/ending
  301. virtual void EngineStats_BeginFrame( void ) = 0;
  302. virtual void EngineStats_EndFrame( void ) = 0;
  303. // This tells the engine to fire any events (temp entity messages) that it has queued up this frame.
  304. // It should only be called once per frame.
  305. virtual void FireEvents() = 0;
  306. // Returns an area index if all the leaves are in the same area. If they span multple areas, then it returns -1.
  307. virtual int GetLeavesArea( int *pLeaves, int nLeaves ) = 0;
  308. // Returns true if the box touches the specified area's frustum.
  309. virtual bool DoesBoxTouchAreaFrustum( const Vector &mins, const Vector &maxs, int iArea ) = 0;
  310. // Sets the hearing origin (i.e., the origin and orientation of the listener so that the sound system can spatialize
  311. // sound appropriately ).
  312. virtual void SetAudioState( const AudioState_t& state ) = 0;
  313. // Sentences / sentence groups
  314. virtual int SentenceGroupPick( int groupIndex, char *name, int nameBufLen ) = 0;
  315. virtual int SentenceGroupPickSequential( int groupIndex, char *name, int nameBufLen, int sentenceIndex, int reset ) = 0;
  316. virtual int SentenceIndexFromName( const char *pSentenceName ) = 0;
  317. virtual const char *SentenceNameFromIndex( int sentenceIndex ) = 0;
  318. virtual int SentenceGroupIndexFromName( const char *pGroupName ) = 0;
  319. virtual const char *SentenceGroupNameFromIndex( int groupIndex ) = 0;
  320. virtual float SentenceLength( int sentenceIndex ) = 0;
  321. // Computes light due to dynamic lighting at a point
  322. // If the normal isn't specified, then it'll return the maximum lighting
  323. // If pBoxColors is specified (it's an array of 6), then it'll copy the light contribution at each box side.
  324. virtual void ComputeLighting( const Vector& pt, const Vector* pNormal, bool bClamp, Vector& color, Vector *pBoxColors=NULL ) = 0;
  325. // Activates/deactivates an occluder...
  326. virtual void ActivateOccluder( int nOccluderIndex, bool bActive ) = 0;
  327. virtual bool IsOccluded( const Vector &vecAbsMins, const Vector &vecAbsMaxs ) = 0;
  328. // The save restore system allocates memory from a shared memory pool, use this allocator to allocate/free saverestore
  329. // memory.
  330. virtual void *SaveAllocMemory( size_t num, size_t size ) = 0;
  331. virtual void SaveFreeMemory( void *pSaveMem ) = 0;
  332. // returns info interface for client netchannel
  333. virtual INetChannelInfo *GetNetChannelInfo( void ) = 0;
  334. // Debugging functionality:
  335. // Very slow routine to draw a physics model
  336. virtual void DebugDrawPhysCollide( const CPhysCollide *pCollide, IMaterial *pMaterial, matrix3x4_t& transform, const color32 &color ) = 0;
  337. // This can be used to notify test scripts that we're at a particular spot in the code.
  338. virtual void CheckPoint( const char *pName ) = 0;
  339. // Draw portals if r_DrawPortals is set (Debugging only)
  340. virtual void DrawPortals() = 0;
  341. // Determine whether the client is playing back or recording a demo
  342. virtual bool IsPlayingDemo( void ) = 0;
  343. virtual bool IsRecordingDemo( void ) = 0;
  344. virtual bool IsPlayingTimeDemo( void ) = 0;
  345. virtual int GetDemoRecordingTick( void ) = 0;
  346. virtual int GetDemoPlaybackTick( void ) = 0;
  347. virtual int GetDemoPlaybackStartTick( void ) = 0;
  348. virtual float GetDemoPlaybackTimeScale( void ) = 0;
  349. virtual int GetDemoPlaybackTotalTicks( void ) = 0;
  350. // Is the game paused?
  351. virtual bool IsPaused( void ) = 0;
  352. // Is the game currently taking a screenshot?
  353. virtual bool IsTakingScreenshot( void ) = 0;
  354. // Is this a HLTV broadcast ?
  355. virtual bool IsHLTV( void ) = 0;
  356. // is this level loaded as just the background to the main menu? (active, but unplayable)
  357. virtual bool IsLevelMainMenuBackground( void ) = 0;
  358. // returns the name of the background level
  359. virtual void GetMainMenuBackgroundName( char *dest, int destlen ) = 0;
  360. // Get video modes
  361. virtual void GetVideoModes( int &nCount, vmode_s *&pModes ) = 0;
  362. // Occlusion system control
  363. virtual void SetOcclusionParameters( const OcclusionParams_t &params ) = 0;
  364. // What language is the user expecting to hear .wavs in, "english" or another...
  365. virtual void GetUILanguage( char *dest, int destlen ) = 0;
  366. // Can skybox be seen from a particular point?
  367. virtual SkyboxVisibility_t IsSkyboxVisibleFromPoint( const Vector &vecPoint ) = 0;
  368. // Get the pristine map entity lump string. (e.g., used by CS to reload the map entities when restarting a round.)
  369. virtual const char* GetMapEntitiesString() = 0;
  370. // Is the engine in map edit mode ?
  371. virtual bool IsInEditMode( void ) = 0;
  372. // current screen aspect ratio (eg. 4.0f/3.0f, 16.0f/9.0f)
  373. virtual float GetScreenAspectRatio() = 0;
  374. // allow the game UI to login a user
  375. virtual bool REMOVED_SteamRefreshLogin( const char *password, bool isSecure ) = 0;
  376. virtual bool REMOVED_SteamProcessCall( bool & finished ) = 0;
  377. // allow other modules to know about engine versioning (one use is a proxy for network compatability)
  378. virtual unsigned int GetEngineBuildNumber() = 0; // engines build
  379. virtual const char * GetProductVersionString() = 0; // mods version number (steam.inf)
  380. // Communicates to the color correction editor that it's time to grab the pre-color corrected frame
  381. // Passes in the actual size of the viewport
  382. virtual void GrabPreColorCorrectedFrame( int x, int y, int width, int height ) = 0;
  383. virtual bool IsHammerRunning( ) const = 0;
  384. // Inserts szCmdString into the command buffer as if it was typed by the client to his/her console.
  385. // And then executes the command string immediately (vs ClientCmd() which executes in the next frame)
  386. //
  387. // Note: this is NOT checked against the FCVAR_CLIENTCMD_CAN_EXECUTE vars.
  388. virtual void ExecuteClientCmd( const char *szCmdString ) = 0;
  389. // returns if the loaded map was processed with HDR info. This will be set regardless
  390. // of what HDR mode the player is in.
  391. virtual bool MapHasHDRLighting(void) = 0;
  392. virtual int GetAppID() = 0;
  393. // Just get the leaf ambient light - no caching, no samples
  394. virtual Vector GetLightForPointFast(const Vector &pos, bool bClamp) = 0;
  395. // This version does NOT check against FCVAR_CLIENTCMD_CAN_EXECUTE.
  396. virtual void ClientCmd_Unrestricted( const char *szCmdString ) = 0;
  397. // This used to be accessible through the cl_restrict_server_commands cvar.
  398. // By default, Valve games restrict the server to only being able to execute commands marked with FCVAR_SERVER_CAN_EXECUTE.
  399. // By default, mods are allowed to execute any server commands, and they can restrict the server's ability to execute client
  400. // commands with this function.
  401. virtual void SetRestrictServerCommands( bool bRestrict ) = 0;
  402. // If set to true (defaults to true for Valve games and false for others), then IVEngineClient::ClientCmd
  403. // can only execute things marked with FCVAR_CLIENTCMD_CAN_EXECUTE.
  404. virtual void SetRestrictClientCommands( bool bRestrict ) = 0;
  405. // Sets the client renderable for an overlay's material proxy to bind to
  406. virtual void SetOverlayBindProxy( int iOverlayID, void *pBindProxy ) = 0;
  407. virtual bool CopyFrameBufferToMaterial( const char *pMaterialName ) = 0;
  408. // Matchmaking
  409. virtual void ChangeTeam( const char *pTeamName ) = 0;
  410. // Causes the engine to read in the user's configuration on disk
  411. virtual void ReadConfiguration( const bool readDefault = false ) = 0;
  412. virtual void SetAchievementMgr( IAchievementMgr *pAchievementMgr ) = 0;
  413. virtual IAchievementMgr *GetAchievementMgr() = 0;
  414. virtual bool MapLoadFailed( void ) = 0;
  415. virtual void SetMapLoadFailed( bool bState ) = 0;
  416. virtual bool IsLowViolence() = 0;
  417. virtual const char *GetMostRecentSaveGame( void ) = 0;
  418. virtual void SetMostRecentSaveGame( const char *lpszFilename ) = 0;
  419. virtual void StartXboxExitingProcess() = 0;
  420. virtual bool IsSaveInProgress() = 0;
  421. virtual uint OnStorageDeviceAttached( void ) = 0;
  422. virtual void OnStorageDeviceDetached( void ) = 0;
  423. virtual void ResetDemoInterpolation( void ) = 0;
  424. // Methods to set/get a gamestats data container so client & server running in same process can send combined data
  425. virtual void SetGamestatsData( CGamestatsData *pGamestatsData ) = 0;
  426. virtual CGamestatsData *GetGamestatsData() = 0;
  427. #if defined( USE_SDL )
  428. // we need to pull delta's from the cocoa mgr, the engine vectors this for us
  429. virtual void GetMouseDelta( int &x, int &y, bool bIgnoreNextMouseDelta = false ) = 0;
  430. #endif
  431. // Sends a key values server command, not allowed from scripts execution
  432. // Params:
  433. // pKeyValues - key values to be serialized and sent to server
  434. // the pointer is deleted inside the function: pKeyValues->deleteThis()
  435. virtual void ServerCmdKeyValues( KeyValues *pKeyValues ) = 0;
  436. virtual bool IsSkippingPlayback( void ) = 0;
  437. virtual bool IsLoadingDemo( void ) = 0;
  438. // Returns true if the engine is playing back a "locally recorded" demo, which includes
  439. // both SourceTV and replay demos, since they're recorded locally (on servers), as opposed
  440. // to a client recording a demo while connected to a remote server.
  441. virtual bool IsPlayingDemoALocallyRecordedDemo() = 0;
  442. // Given the string pBinding which may be bound to a key,
  443. // returns the string name of the key to which this string is bound. Returns NULL if no such binding exists
  444. // Unlike Key_LookupBinding, leading '+' characters are not stripped from bindings.
  445. virtual const char *Key_LookupBindingExact( const char *pBinding ) = 0;
  446. virtual void AddPhonemeFile( const char *pszPhonemeFile ) = 0;
  447. virtual float GetPausedExpireTime( void ) = 0;
  448. virtual bool StartDemoRecording( const char *pszFilename, const char *pszFolder = NULL ) = 0;
  449. virtual void StopDemoRecording( void ) = 0;
  450. virtual void TakeScreenshot( const char *pszFilename, const char *pszFolder = NULL ) = 0;
  451. };
  452. abstract_class IVEngineClient : public IVEngineClient013
  453. {
  454. public:
  455. virtual uint GetProtocolVersion() = 0;
  456. virtual bool IsWindowedMode() = 0;
  457. // Flash the window (os specific)
  458. virtual void FlashWindow() = 0;
  459. // Client version from the steam.inf, this will be compared to the GC version
  460. virtual int GetClientVersion() const = 0; // engines build
  461. // Is App Active
  462. virtual bool IsActiveApp() = 0;
  463. virtual void DisconnectInternal() = 0;
  464. virtual int GetInstancesRunningCount( ) = 0;
  465. };
  466. //-----------------------------------------------------------------------------
  467. // Purpose: Interface exposed from the client .dll back to the engine
  468. //-----------------------------------------------------------------------------
  469. abstract_class IBaseClientDLL
  470. {
  471. public:
  472. // Called once when the client DLL is loaded
  473. virtual int Init( CreateInterfaceFn appSystemFactory,
  474. CreateInterfaceFn physicsFactory,
  475. CGlobalVarsBase *pGlobals ) = 0;
  476. virtual void PostInit() = 0;
  477. // Called once when the client DLL is being unloaded
  478. virtual void Shutdown( void ) = 0;
  479. // Called once the client is initialized to setup client-side replay interface pointers
  480. virtual bool ReplayInit( CreateInterfaceFn replayFactory ) = 0;
  481. virtual bool ReplayPostInit() = 0;
  482. // Called at the start of each level change
  483. virtual void LevelInitPreEntity( char const* pMapName ) = 0;
  484. // Called at the start of a new level, after the entities have been received and created
  485. virtual void LevelInitPostEntity( ) = 0;
  486. // Called at the end of a level
  487. virtual void LevelShutdown( void ) = 0;
  488. // Request a pointer to the list of client datatable classes
  489. virtual ClientClass *GetAllClasses( void ) = 0;
  490. // Called once per level to re-initialize any hud element drawing stuff
  491. virtual int HudVidInit( void ) = 0;
  492. // Called by the engine when gathering user input
  493. virtual void HudProcessInput( bool bActive ) = 0;
  494. // Called oncer per frame to allow the hud elements to think
  495. virtual void HudUpdate( bool bActive ) = 0;
  496. // Reset the hud elements to their initial states
  497. virtual void HudReset( void ) = 0;
  498. // Display a hud text message
  499. virtual void HudText( const char * message ) = 0;
  500. // Mouse Input Interfaces
  501. // Activate the mouse (hides the cursor and locks it to the center of the screen)
  502. virtual void IN_ActivateMouse( void ) = 0;
  503. // Deactivates the mouse (shows the cursor and unlocks it)
  504. virtual void IN_DeactivateMouse( void ) = 0;
  505. // This is only called during extra sound updates and just accumulates mouse x, y offets and recenters the mouse.
  506. // This call is used to try to prevent the mouse from appearing out of the side of a windowed version of the engine if
  507. // rendering or other processing is taking too long
  508. virtual void IN_Accumulate (void) = 0;
  509. // Reset all key and mouse states to their initial, unpressed state
  510. virtual void IN_ClearStates (void) = 0;
  511. // If key is found by name, returns whether it's being held down in isdown, otherwise function returns false
  512. virtual bool IN_IsKeyDown( const char *name, bool& isdown ) = 0;
  513. // Notify the client that the mouse was wheeled while in game - called prior to executing any bound commands.
  514. virtual void IN_OnMouseWheeled( int nDelta ) = 0;
  515. // Raw keyboard signal, if the client .dll returns 1, the engine processes the key as usual, otherwise,
  516. // if the client .dll returns 0, the key is swallowed.
  517. virtual int IN_KeyEvent( int eventcode, ButtonCode_t keynum, const char *pszCurrentBinding ) = 0;
  518. // This function is called once per tick to create the player CUserCmd (used for prediction/physics simulation of the player)
  519. // Because the mouse can be sampled at greater than the tick interval, there is a separate input_sample_frametime, which
  520. // specifies how much additional mouse / keyboard simulation to perform.
  521. virtual void CreateMove (
  522. int sequence_number, // sequence_number of this cmd
  523. float input_sample_frametime, // Frametime for mouse input sampling
  524. bool active ) = 0; // True if the player is active (not paused)
  525. // If the game is running faster than the tick_interval framerate, then we do extra mouse sampling to avoid jittery input
  526. // This code path is much like the normal move creation code, except no move is created
  527. virtual void ExtraMouseSample( float frametime, bool active ) = 0;
  528. // Encode the delta (changes) between the CUserCmd in slot from vs the one in slot to. The game code will have
  529. // matching logic to read the delta.
  530. virtual bool WriteUsercmdDeltaToBuffer( bf_write *buf, int from, int to, bool isnewcommand ) = 0;
  531. // Demos need to be able to encode/decode CUserCmds to memory buffers, so these functions wrap that
  532. virtual void EncodeUserCmdToBuffer( bf_write& buf, int slot ) = 0;
  533. virtual void DecodeUserCmdFromBuffer( bf_read& buf, int slot ) = 0;
  534. // Set up and render one or more views (e.g., rear view window, etc.). This called into RenderView below
  535. virtual void View_Render( vrect_t *rect ) = 0;
  536. // Allow engine to expressly render a view (e.g., during timerefresh)
  537. // See IVRenderView.h, PushViewFlags_t for nFlags values
  538. virtual void RenderView( const CViewSetup &view, int nClearFlags, int whatToDraw ) = 0;
  539. // Apply screen fade directly from engine
  540. virtual void View_Fade( ScreenFade_t *pSF ) = 0;
  541. // The engine has parsed a crosshair angle message, this function is called to dispatch the new crosshair angle
  542. virtual void SetCrosshairAngle( const QAngle& angle ) = 0;
  543. // Sprite (.spr) model handling code
  544. // Load a .spr file by name
  545. virtual void InitSprite( CEngineSprite *pSprite, const char *loadname ) = 0;
  546. // Shutdown a .spr file
  547. virtual void ShutdownSprite( CEngineSprite *pSprite ) = 0;
  548. // Returns sizeof( CEngineSprite ) so the engine can allocate appropriate memory
  549. virtual int GetSpriteSize( void ) const = 0;
  550. // Called when a player starts or stops talking.
  551. // entindex is -1 to represent the local client talking (before the data comes back from the server).
  552. // entindex is -2 to represent the local client's voice being acked by the server.
  553. // entindex is GetPlayer() when the server acknowledges that the local client is talking.
  554. virtual void VoiceStatus( int entindex, qboolean bTalking ) = 0;
  555. // Networked string table definitions have arrived, allow client .dll to
  556. // hook string changes with a callback function ( see INetworkStringTableClient.h )
  557. virtual void InstallStringTableCallback( char const *tableName ) = 0;
  558. // Notification that we're moving into another stage during the frame.
  559. virtual void FrameStageNotify( ClientFrameStage_t curStage ) = 0;
  560. // The engine has received the specified user message, this code is used to dispatch the message handler
  561. virtual bool DispatchUserMessage( int msg_type, bf_read &msg_data ) = 0;
  562. // Save/restore system hooks
  563. virtual CSaveRestoreData *SaveInit( int size ) = 0;
  564. virtual void SaveWriteFields( CSaveRestoreData *, const char *, void *, datamap_t *, typedescription_t *, int ) = 0;
  565. virtual void SaveReadFields( CSaveRestoreData *, const char *, void *, datamap_t *, typedescription_t *, int ) = 0;
  566. virtual void PreSave( CSaveRestoreData * ) = 0;
  567. virtual void Save( CSaveRestoreData * ) = 0;
  568. virtual void WriteSaveHeaders( CSaveRestoreData * ) = 0;
  569. virtual void ReadRestoreHeaders( CSaveRestoreData * ) = 0;
  570. virtual void Restore( CSaveRestoreData *, bool ) = 0;
  571. virtual void DispatchOnRestore() = 0;
  572. // Hand over the StandardRecvProxies in the client DLL's module.
  573. virtual CStandardRecvProxies* GetStandardRecvProxies() = 0;
  574. // save game screenshot writing
  575. virtual void WriteSaveGameScreenshot( const char *pFilename ) = 0;
  576. // Given a list of "S(wavname) S(wavname2)" tokens, look up the localized text and emit
  577. // the appropriate close caption if running with closecaption = 1
  578. virtual void EmitSentenceCloseCaption( char const *tokenstream ) = 0;
  579. // Emits a regular close caption by token name
  580. virtual void EmitCloseCaption( char const *captionname, float duration ) = 0;
  581. // Returns true if the client can start recording a demo now. If the client returns false,
  582. // an error message of up to length bytes should be returned in errorMsg.
  583. virtual bool CanRecordDemo( char *errorMsg, int length ) const = 0;
  584. // Give the Client a chance to do setup/cleanup.
  585. virtual void OnDemoRecordStart( char const* pDemoBaseName ) = 0;
  586. virtual void OnDemoRecordStop() = 0;
  587. virtual void OnDemoPlaybackStart( char const* pDemoBaseName ) = 0;
  588. virtual void OnDemoPlaybackStop() = 0;
  589. // Draw the console overlay?
  590. virtual bool ShouldDrawDropdownConsole() = 0;
  591. // Get client screen dimensions
  592. virtual int GetScreenWidth() = 0;
  593. virtual int GetScreenHeight() = 0;
  594. // Added interface
  595. // save game screenshot writing
  596. virtual void WriteSaveGameScreenshotOfSize( const char *pFilename, int width, int height, bool bCreatePowerOf2Padded = false, bool bWriteVTF = false ) = 0;
  597. // Gets the current view
  598. virtual bool GetPlayerView( CViewSetup &playerView ) = 0;
  599. // Matchmaking
  600. virtual void SetupGameProperties( CUtlVector< XUSER_CONTEXT > &contexts, CUtlVector< XUSER_PROPERTY > &properties ) = 0;
  601. virtual uint GetPresenceID( const char *pIDName ) = 0;
  602. virtual const char *GetPropertyIdString( const uint id ) = 0;
  603. virtual void GetPropertyDisplayString( uint id, uint value, char *pOutput, int nBytes ) = 0;
  604. #ifdef WIN32
  605. virtual void StartStatsReporting( HANDLE handle, bool bArbitrated ) = 0;
  606. #endif
  607. virtual void InvalidateMdlCache() = 0;
  608. virtual void IN_SetSampleTime( float frametime ) = 0;
  609. // For sv_pure mode. The filesystem figures out which files the client needs to reload to be "pure" ala the server's preferences.
  610. virtual void ReloadFilesInList( IFileList *pFilesToReload ) = 0;
  611. #ifdef POSIX
  612. // AR: Same as above win32 defn but down here at the end of the vtable for back compat
  613. virtual void StartStatsReporting( HANDLE handle, bool bArbitrated ) = 0;
  614. #endif
  615. // Let the client handle UI toggle - if this function returns false, the UI will toggle, otherwise it will not.
  616. virtual bool HandleUiToggle() = 0;
  617. // Allow the console to be shown?
  618. virtual bool ShouldAllowConsole() = 0;
  619. // Get renamed recv tables
  620. virtual CRenamedRecvTableInfo *GetRenamedRecvTableInfos() = 0;
  621. // Get the mouthinfo for the sound being played inside UI panels
  622. virtual CMouthInfo *GetClientUIMouthInfo() = 0;
  623. // Notify the client that a file has been received from the game server
  624. virtual void FileReceived( const char * fileName, unsigned int transferID ) = 0;
  625. virtual const char* TranslateEffectForVisionFilter( const char *pchEffectType, const char *pchEffectName ) = 0;
  626. // Give the client a chance to modify sound settings however they want before the sound plays. This is used for
  627. // things like adjusting pitch of voice lines in Pyroland in TF2.
  628. virtual void ClientAdjustStartSoundParams( struct StartSoundParams_t& params ) = 0;
  629. // Returns true if the disconnect command has been handled by the client
  630. virtual bool DisconnectAttempt( void ) = 0;
  631. virtual bool IsConnectedUserInfoChangeAllowed( IConVar *pCvar ) = 0;
  632. };
  633. #define CLIENT_DLL_INTERFACE_VERSION "VClient017"
  634. //-----------------------------------------------------------------------------
  635. // Purpose: Interface exposed from the client .dll back to the engine for specifying shared .dll IAppSystems (e.g., ISoundEmitterSystem)
  636. //-----------------------------------------------------------------------------
  637. abstract_class IClientDLLSharedAppSystems
  638. {
  639. public:
  640. virtual int Count() = 0;
  641. virtual char const *GetDllName( int idx ) = 0;
  642. virtual char const *GetInterfaceName( int idx ) = 0;
  643. };
  644. #define CLIENT_DLL_SHARED_APPSYSTEMS "VClientDllSharedAppSystems001"
  645. #endif // CDLL_INT_H