Skip to content

Commit

Permalink
Convert documentation for server & client interfaces to Doxygen format
Browse files Browse the repository at this point in the history
  • Loading branch information
SamVanheer committed Jun 16, 2023
1 parent 9d48445 commit 320198b
Show file tree
Hide file tree
Showing 9 changed files with 318 additions and 652 deletions.
149 changes: 53 additions & 96 deletions src/game/client/cdll_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,23 @@ void InitInput();
void EV_HookEvents();
void IN_Commands();

/*
================================
HUD_GetHullBounds
Engine calls this to enumerate player collision hulls, for prediction. Return 0 if the hullnumber doesn't exist.
================================
*/
/**
* @brief Engine calls this to enumerate player collision hulls, for prediction.
* @return 0 if the hullnumber doesn't exist, 1 otherwise.
*/
int DLLEXPORT HUD_GetHullBounds(int hullnumber, float* mins, float* maxs)
{
return static_cast<int>(PM_GetHullBounds(hullnumber, mins, maxs));
}

/*
================================
HUD_ConnectionlessPacket
Return 1 if the packet is valid. Set response_buffer_size if you want to send a response packet. Incoming, it holds the max
size of the response_buffer, so you must zero it out if you choose not to respond.
================================
*/
/**
* @brief Return 1 if the packet is valid.
* @param net_from Address of the sender.
* @param args Argument string.
* @param response_buffer Buffer to write a response message to.
* @param[in,out] response_buffer_size Initially holds the maximum size of @p response_buffer.
* Set to size of response message or 0 if sending no response.
*/
int DLLEXPORT HUD_ConnectionlessPacket(const netadr_t* net_from, const char* args, char* response_buffer, int* response_buffer_size)
{
// Parse stuff from args
Expand Down Expand Up @@ -119,17 +116,10 @@ int DLLEXPORT Initialize(cl_enginefunc_t* pEnginefuncs, int iVersion)
return 1;
}


/*
==========================
HUD_VidInit
Called when the game initializes
and whenever the vid_mode is changed
so the HUD can reinitialize itself.
==========================
*/

/**
* @brief Called whenever the client connects to a server. Reinitializes all the hud variables.
* @details The original documentation for this and HUD_Init() were swapped.
*/
int DLLEXPORT HUD_VidInit()
{
g_Client.VidInit();
Expand All @@ -143,16 +133,10 @@ int DLLEXPORT HUD_VidInit()
return 1;
}

/*
==========================
HUD_Init
Called whenever the client connects
to a server. Reinitializes all
the hud variables.
==========================
*/

/**
* @brief Called when the game initializes and whenever the vid_mode is changed so the HUD can reinitialize itself.
* @details The original documentation for this and HUD_VidInit() were swapped.
*/
void DLLEXPORT HUD_Init()
{
g_Client.HudInit();
Expand All @@ -161,36 +145,21 @@ void DLLEXPORT HUD_Init()
Scheme_Init();
}


/*
==========================
HUD_Redraw
called every screen frame to
redraw the HUD.
===========================
*/

/**
* @brief called every screen frame to redraw the HUD.
*/
int DLLEXPORT HUD_Redraw(float time, int intermission)
{
gHUD.Redraw(time, 0 != intermission);

return 1;
}


/*
==========================
HUD_UpdateClientData
called every time shared client
dll/engine data gets changed,
and gives the cdll a chance
to modify the data.
returns 1 if anything has been changed, 0 otherwise.
==========================
*/
/**
* @brief called every time shared client dll/engine data gets changed,
* and gives the cdll a chance to modify the data.
* @return 1 if anything has been changed, 0 otherwise.
*/

int DLLEXPORT HUD_UpdateClientData(client_data_t* pcldata, float flTime)
{
Expand All @@ -199,56 +168,36 @@ int DLLEXPORT HUD_UpdateClientData(client_data_t* pcldata, float flTime)
return static_cast<int>(gHUD.UpdateClientData(pcldata, flTime));
}

/*
==========================
HUD_Reset
Called at start and end of demos to restore to "non"HUD state.
==========================
*/

/**
* @brief Called at start and end of demos to restore to "non"HUD state.
* @details Never called in Steam Half-Life.
*/
void DLLEXPORT HUD_Reset()
{
gHUD.VidInit();
}

/*
==========================
HUD_Frame
Called by engine every frame that client .dll is loaded
==========================
*/

/**
* @brief Called by engine every frame that client .dll is loaded
*/
void DLLEXPORT HUD_Frame(double time)
{
GetClientVoiceMgr()->Frame(time);

g_Client.RunFrame();
}


/*
==========================
HUD_VoiceStatus
Called when a player starts or stops talking.
==========================
*/

/**
* @brief Called when a player starts or stops talking.
*/
void DLLEXPORT HUD_VoiceStatus(int entindex, qboolean bTalking)
{
GetClientVoiceMgr()->UpdateSpeakerStatus(entindex, 0 != bTalking);
}

/*
==========================
HUD_DirectorMessage
Called when a director event message was received
==========================
*/

/**
* @brief Called when a director event message was received
*/
void DLLEXPORT HUD_DirectorMessage(int iSize, void* pbuf)
{
BufferReader reader{{reinterpret_cast<std::byte*>(pbuf), static_cast<std::size_t>(iSize)}};
Expand All @@ -273,6 +222,11 @@ void CL_LoadParticleMan()
}
}

/**
* @brief Used by Steam Half-Life to load the client dll interface.
* If not present, the client dll will be unloaded, global destructors will run, the client dll will be loaded again
* and functions will be retrieved using <tt>GetProcAddress/dlsym</tt>.
*/
extern "C" void DLLEXPORT F(void* pv)
{
cldll_func_t* pcldll_func = (cldll_func_t*)pv;
Expand Down Expand Up @@ -327,13 +281,16 @@ extern "C" void DLLEXPORT F(void* pv)

#include "cl_dll/IGameClientExports.h"

//-----------------------------------------------------------------------------
// Purpose: Exports functions that are used by the gameUI for UI dialogs
//-----------------------------------------------------------------------------
/**
* @brief Exports functions that are used by the gameUI for UI dialogs
*/
class CClientExports : public IGameClientExports
{
public:
// returns the name of the server the user is connected to, if any
/**
* @brief returns the name of the server the user is connected to, if any
* @details Does not appear to be called in Steam Half-Life
*/
const char* GetServerHostName() override
{
/*if (gViewPortInterface)
Expand Down
109 changes: 44 additions & 65 deletions src/game/client/entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,9 @@ static TEMPENTITY gTempEnts[MAX_TEMPENTS];
static TEMPENTITY* gpTempEntFree = nullptr;
static TEMPENTITY* gpTempEntActive = nullptr;

/*
========================
HUD_AddEntity
Return 0 to filter entity from visible list for rendering
========================
*/
/**
* @brief Return 0 to filter entity from visible list for rendering
*/
int DLLEXPORT HUD_AddEntity(int type, cl_entity_t* ent, const char* modelname)
{
switch (type)
Expand Down Expand Up @@ -72,15 +69,12 @@ int DLLEXPORT HUD_AddEntity(int type, cl_entity_t* ent, const char* modelname)
return 1;
}

/*
=========================
HUD_TxferLocalOverrides
The server sends us our origin with extra precision as part of the clientdata structure, not during the normal
playerstate update in entity_state_t. In order for these overrides to eventually get to the appropriate playerstate
structure, we need to copy them into the state structure at this point.
=========================
*/
/**
* @brief The server sends us our origin with extra precision as part of the clientdata structure,
* not during the normal playerstate update in entity_state_t.
* In order for these overrides to eventually get to the appropriate playerstate structure,
* we need to copy them into the state structure at this point.
*/
void DLLEXPORT HUD_TxferLocalOverrides(entity_state_t* state, const clientdata_t* client)
{
state->origin = client->origin;
Expand All @@ -96,14 +90,10 @@ void DLLEXPORT HUD_TxferLocalOverrides(entity_state_t* state, const clientdata_t
state->iuser4 = client->iuser4;
}

/*
=========================
HUD_ProcessPlayerState
We have received entity_state_t for this player over the network. We need to copy appropriate fields to the
playerstate structure
=========================
*/
/**
* @brief We have received entity_state_t for this player over the network.
* We need to copy appropriate fields to the playerstate structure
*/
void DLLEXPORT HUD_ProcessPlayerState(entity_state_t* dst, const entity_state_t* src)
{
// Copy in network data
Expand Down Expand Up @@ -161,16 +151,13 @@ void DLLEXPORT HUD_ProcessPlayerState(entity_state_t* dst, const entity_state_t*
}
}

/*
=========================
HUD_TxferPredictionData
Because we can predict an arbitrary number of frames before the server responds with an update, we need to be able to copy client side prediction data in
from the state that the server ack'd receiving, which can be anywhere along the predicted frame path ( i.e., we could predict 20 frames into the future and the server ack's
up through 10 of those frames, so we need to copy persistent client-side only state from the 10th predicted frame to the slot the server
update is occupying.
=========================
*/
/**
* @brief Because we can predict an arbitrary number of frames before the server responds with an update,
* we need to be able to copy client side prediction data in from the state that the server ack'd receiving,
* which can be anywhere along the predicted frame path ( i.e., we could predict 20 frames into the future
* and the server ack's up through 10 of those frames ), so we need to copy persistent client-side only state
* from the 10th predicted frame to the slot the server update is occupying.
*/
void DLLEXPORT HUD_TxferPredictionData(entity_state_t* ps, const entity_state_t* pps, clientdata_t* pcd, const clientdata_t* ppcd, weapon_data_t* wd, const weapon_data_t* pwd)
{
ps->oldbuttons = pps->oldbuttons;
Expand Down Expand Up @@ -296,13 +283,9 @@ void Beams()
}
#endif

/*
=========================
HUD_CreateEntities
Gives us a chance to add additional entities to the render this frame
=========================
*/
/**
* @brief Gives us a chance to add additional entities to the render this frame
*/
void DLLEXPORT HUD_CreateEntities()
{
#if defined(BEAM_TEST)
Expand All @@ -315,15 +298,10 @@ void DLLEXPORT HUD_CreateEntities()
GetClientVoiceMgr()->CreateEntities();
}


/*
=========================
HUD_StudioEvent
The entity's studio model description indicated an event was
fired during this frame, handle the event by it's tag ( e.g., muzzleflash, sound )
=========================
*/
/**
* @brief The entity's studio model description indicated an event was fired during this frame,
* handle the event by it's tag ( e.g., muzzleflash, sound )
*/
void DLLEXPORT HUD_StudioEvent(const mstudioevent_t* event, const cl_entity_t* entity)
{
bool iMuzzleFlash = true;
Expand Down Expand Up @@ -364,14 +342,20 @@ void DLLEXPORT HUD_StudioEvent(const mstudioevent_t* event, const cl_entity_t* e

/**
* @brief Simulation and cleanup of temporary entities
* @param frametime Simulation time
* @param client_time Absolute time on client
* @param cl_gravity True gravity on client
* @param ppTempEntFree List of freed temporary ents
* @param ppTempEntActive List of active temporary ents
* @param Callback_AddVisibleEntity Callback to add an entity to the list of visible entities to draw this frame
* @param Callback_TempEntPlaySound Obsolete. Use CL_TempEntPlaySound instead.
*/
void DLLEXPORT HUD_TempEntUpdate(
double frametime, // Simulation time
double client_time, // Absolute time on client
double cl_gravity, // True gravity on client
TEMPENTITY** ppTempEntFree, // List of freed temporary ents
TEMPENTITY** ppTempEntActive, // List
double frametime,
double client_time,
double cl_gravity,
TEMPENTITY** ppTempEntFree,
TEMPENTITY** ppTempEntActive,
int (*Callback_AddVisibleEntity)(cl_entity_t* pEntity),
void (*Callback_TempEntPlaySound)(TEMPENTITY* pTemp, float damp))
{
Expand Down Expand Up @@ -737,17 +721,12 @@ void DLLEXPORT HUD_TempEntUpdate(
gEngfuncs.pEventAPI->EV_PopPMStates();
}

/*
=================
HUD_GetUserEntity
If you specify negative numbers for beam start and end point entities, then
the engine will call back into this function requesting a pointer to a cl_entity_t
object that describes the entity to attach the beam onto.
Indices must start at 1, not zero.
=================
*/
/**
* @brief If you specify negative numbers for beam start and end point entities,
* then the engine will call back into this function requesting a pointer to a cl_entity_t object
* that describes the entity to attach the beam onto.
* Indices must start at 1, not zero.
*/
cl_entity_t DLLEXPORT* HUD_GetUserEntity(int index)
{
#if defined(BEAM_TEST)
Expand Down
Loading

0 comments on commit 320198b

Please sign in to comment.