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