14 KiB
List of client.dll exported functions
int Initialize( cl_enginefuncs_t *enginefuncs, int version )
Important
This function is only called once.
Called after loading DLL and exports engine API to the client.dll.
enginefuncsmust be set to a pointer to a struct filled with engine function pointers, it will be described in next chapters.versionmust be always set to7. (HLSDK 1.0 uses version6, and is binary incompatible with7). Return value:0on error, otherwise success.
void HUD_PlayerMoveInit( struct playermove_s *ppmove, int server )
Important
This function is only called once.
Called on player movement prediction initialization, before HUD. In GoldSrc, engine only runs prediction loop, the players physics are implemented in client.dll.
ppmovemust be set to a pointer to a client instance of player movement structure, which also exports it's own API and will be discussed in the next chapters.servermust be always set to0on client side. This function is called only once.
void HUD_Init( void )
Important
This function is only called once.
Called to initialize the HUD. At this moment engine should be ready to register new commands, console variables and user messages. No rendering or loading graphics done at this moment.
int HUD_GetStudioModelInterface( int version, struct r_studio_interface_s **ppinterface, struct engine_studio_api_s *pstudio )
Important
This function is only called once.
This function is called after initializing HUD and exports studio model interface to the client.dll.
versionmust be always set to1.ppinterfacewill be set byclient.dllto a pointer tor_studio_interface_sstructure.pstudiomust be set to a pointer toengine_studio_api_sstructure. The studio model interface will be discussed in the next chapters. Return value:0on error, otherwise success.
void HUD_Shutdown( void )
Important
This function is only called once.
Called at client shutdown.
int HUD_GetHullBounds( int hull, vec3_t mins, vec3_t maxs )
Important
This function is only called once.
Called by the engine after HUD_PlayerMoveInit to let client.dll override hull bounds used for in player movement prediction.
hullis the hull index (0: player standing, 1: player crouched, 2: point hull, 3: large hull).minswill contain hull mins.maxswill contain hull maxs. Return value: if 0, don't override this hull and stop reading, non-zero means hull is valid and there is more.
Note
This function is broken in most implementations. It might return non-zero value, but don't write anything to the
minsandmaxsvectors, so be prepared to have some default values.
int HUD_VidInit( void )
Called when client receives svc_serverdata message. It is called before any parsing of that message is done, thus the state is preserved from the previous connection. It lets client.dll to re-initialize graphics, if required. At this point, engine is expected to have video subsystem running, but no rendering is done here.
int HUD_Redraw( float flTime, int intermission )
Called each frame to redraw the HUD. Only 2D is drawn here.
flTimemust be set tocl.time, i.e. synchronized with server.intermissionmust be set to1during intermission (set throughsvc_intermissionmessage), otherwise it's set to0. Return value: ignored.
void HUD_Reset( void )
Called on demo recording or playback start and stop.
int HUD_UpdateClientData( client_data_t *cdata, float flTime )
Called each frame after taking input.
cdatacontains pointer toclient_data_tstructure, populated by engine.flTimemust be set tocl.time, i.e. synchronized with server. Return value: if non-zero, will override engine viewangles and FOV value.
void HUD_PlayerMove( struct playermove_s *pmove, int server )
When prediction is enabled, use this function to run player movement prediction. Note that this correlates to QW/Q2's prediction mechanism. It does not include weapon prediction.
pmoveis a pointer to playermove objectservermust be always set to0
char HUD_PlayerMoveTexture( char *name )
Not used in the engine.
int HUD_ConnectionlessPacket( const netadr_t *from, const char *args, char *response_buffer, int *response_buffer_size )
Called by the engine on unknown connectionless packets. Lets client.dll and server.dll have custom query protocol.
fromis set to network address where this packet is coming from.argsraw network buffer, minus the connectionless packet header (0xFFFFFFFF).response_bufferset byclient.dllif there is a response.response_buffer_sizeis initialized by the engine with buffer maximum size. Set byclient.dllif there is a response. Return value: non-zero if handled.
void HUD_Frame( double time )
Called each frame after sending command to the remote server. No rendering is normally done in this function.
timeis the local delta time between previous and this frame (i.e.host.frametime)
void HUD_PostRunCmd( struct local_state_s *from, struct local_state_s *to, usercmd_t *cmd, int runfuncs, double time, unsigned int random_seed )
Always called after HUD_PlayerMove, even if movement prediction is disabled. Used for weapon prediction stuff.
fromis a pointer tolocal_state_sobject of the previous predicted frametois a pointer tolocal_state_sobject of this current framecmdis current user commandrunfuncsis set to1if this frame was never predicted before, and to0if it is being predicted againrandom_seedis set toincoming_acknowledgedplus number of predicted frames starting with1. This way it's synchronized between client and server.
int HUD_Key_Event( int down, int key, const char *current_binding )
Called on keyboard event.
downis set to1if key is being pressed or set to0on being released.keyis set to the key number. The key IDs are predefined.current_bindingis set to a null-terminated string with commands bound to this key Return value:0ifclient.dllwants engine to ignore that key.
int HUD_AddEntity( int type, struct cl_entity_s *ent, const char *modelname )
Called before adding entity to the rendering list.
typeis set to an entity type, seeentity_state_t::entityTypeentis a pointer tocl_entity_tobject.modelnameis a null-terminated string with that entity model name. Return value:0ifclient.dllwants engine to not draw this entity.
void HUD_CreateEntities( void )
Called each frame after all network entities (including players) are linked to let client.dll spawn client-side entities.
void HUD_StudioEvent( const struct mstudioevent_s *event, const struct cl_entity_s *ent )
Studio models have events tied to the frame, on which engine calls this function.
eventis a pointer to a studio event objectentis a pointer to a client entity object
void HUD_TxferLocalOverrides( struct entity_state_s *state, const struct clientdata_s *client )
When client processes entity updates, for local client it might be truncated, don't have enough precision, miss some critical info, so engine calls this function as client.dll might choose to use client data came from svc_clientdata message. Note that it is called on raw, non-interpolated networked entity state.
stateis a pointer to the local client entity state coming from the networkclientis a pointer to local client data object
void HUD_ProcessPlayerState( struct entity_state_s *dst, const struct entity_state_s *src )
When client processes entity updates, it calls this function for player entities as client.dll might want to override some data or fill the missing parts, but usually it just copies from src to dst.
srcis a target pointer to the player entity data (stored in frames, for example)dstis a source pointer to the player entity data coming from network
void HUD_TxferPredictionData( struct entity_state_s *ps, const struct entity_state_s *pps, struct clientdata_s *pcd, const struct clientdata_s *ppcd, struct weapon_data_s *wd, const weapon_data_s *pwd )
When client receives svc_clientdata message, this function is called before any parsing is done, so that the client.dll fills in data from prediction.
ps,pcd,wdare pointers to current network frame data.pps,ppcd,pwdare pointers to predicted frame data.
void HUD_TempEntUpdate( double frametime, double client_time, double cl_gravity, TEMPENTITY **ppTempEntFree, TEMPENTITY **ppTempEntActive, int ( *AddVisibleEntity )( cl_entity_t *pEntity ), void ( *TempEntPlaySound)( TEMPENTITY *pTemp, float damp ))
Called each frame after network entities are processed and after HUD_CreateEntities, to let client.dll process temporary entities logic.
frametimeis the delta betweencl.timeandcl.oldtime, i.e. server time.client_timeiscl.timegravityis the synchronized gravity value from the serverppTempEntFreeis a pointer to the head of linked list of free temp entitiesppTempEntActiveis a pointer to the head of linked list of active temp entitiesAddVisibleEntityis a pointer to function that letsclient.dlladd this entity to the rendering list.TempEntPlaySoundis a pointer to function that's called byclient.dllwhen temp entity needs to play predefined hit sound. Thedampargument of this argument only makes sound to NOT play, if it's zero or negative.
void HUD_DrawNormalTriangles( void )
Called each rendering frame to let client.dll draw custom solid triangles through TriAPI or direct OpenGL calls.
void HUD_DrawTransparentTriangles( void )
Called each rendering frame to let client.dll draw custom transparent triangles through TriAPI or direct OpenGL calls.
struct cl_entity_s *HUD_GetUserEntity( int index )
Called by engine when beam start/end indices are negative, thus allowing attaching beams to a temporary or client-only entity.
indexis the fixed up entity index, as beam start/end indices encode real entity index in low 12 bits (i.e.beament_start & 0xFFF).
void Demo_ReadBuffer( int size, unsigned char *buffer )
Called by engine on demo playback, if client.dll saved some custom data on demo recording prior.
sizeis the size of buffer in bytesbufferis the pointer to custom data stored byclient.dllin demo
void CAM_Think( void )
Called each frame before rendering starts to let client.dll run custom camera logic, like advanced thirdperson follow camera for example.
int CL_IsThirdPerson( void )
Returns non-zero value if camera is in thirdperson mode, lets engine figure out whether add local client entity to the rendering list or not.
void CL_CameraOffset( vec3_t offset )
Not used in the engine.
void CL_CreateMove( float frametime, usercmd_t *cmd, int active )
Called when usercmd_t is being created to let client.dll record user commands before they are being sent over the network.
frametimeis the delta time between previous and current frames.cmdis the pointer tousercmd_tobject, where player's intentions and impulses are added.activeis set to1when client is finished signing on to the server (as movement commands are being sent even if client is not fully spawned yet).
void IN_ActivateMouse( void )
Called from similarly named NQ/QW function.
void IN_DeactivateMouse( void )
Called from similarly named NQ/QW function.
void IN_MouseEvent( int mstate )
Called from similarly named NQ/QW function.
void IN_Accumulate( void )
Called from similarly named NQ/QW function.
void IN_ClearStates( void )
Called from similarly named NQ/QW function.
void V_CalcRefdef( struct ref_params_s *params )
Called each frame before rendering starts. This is close to the similarly named function found in NQ/QW and lets client.dll to run custom view logic.
paramsis the refdef parameters object. It is also used as return value and might request from the engine to not draw anything (byonlyClientDrawsfield) or to run this multiple times (bynextviewfield)
kbutton_t *KB_Find( const char *name )
Called by engine to find extra keys and their state.
Only few are really used by the engine:
in_mlookfor mouse lookin_jlookfor joystick lookin_graphfor net_graph toggle
Return value: returns pointer to kbutton_t if found. kbutton_t structure matches the same structure that can be found in NQ and QW.
void HUD_DirectorMessage( int size, void *buf )
Important
This function is optional.
Called to notify client.dll about an svc_director message. This feature is used for HLTV, though mods use it to spawn text messages or execute commands (bypassing svc_stufftext filter in old client.dll) but svc_director message structure isn't enforced by engine, so it in theory mods might modify it for their own needs.
sizeis the size of the payloadbufrawsvc_directorpayload
void HUD_VoiceStatus( int entindex, qboolean talking )
Important
This function is optional.
Called to notify client.dll about a client status of using voice chat.
entindexan entity index (client index plus one, because zero is always world). When set to -1, notifiesclient.dllabout local client recording. When set to -2, notifiesclient.dllabout a loopback (i.e. local client's voice message was sent to server and received back)talkingif true, this client is talking
void HUD_ChatInputPosition( int *x, int *y )
Important
This function is optional.
When called, returns desired X and Y positions of chat box.