diff --git a/src/qcommon/cm_patch.c b/src/qcommon/cm_patch.c index f09b7c071..bf7ac82a1 100644 --- a/src/qcommon/cm_patch.c +++ b/src/qcommon/cm_patch.c @@ -2039,7 +2039,8 @@ Called from the renderer */ typedef void (*BotPolyFunc)(int color, int numPoints, float *points); -void BotDrawDebugPolygons(BotPolyFunc drawPoly, int value); +// TODO: remove in sv_bot.c +//void BotDrawDebugPolygons(BotPolyFunc drawPoly, int value); void CM_DrawDebugSurface(void (*drawPoly)(int color, int numPoints, float *points)) { @@ -2061,7 +2062,8 @@ void CM_DrawDebugSurface(void (*drawPoly)(int color, int numPoints, float *point if (cv2->integer != 1) { - BotDrawDebugPolygons(drawPoly, cv2->integer); + // TODO: remove in sv_bot.c + //BotDrawDebugPolygons(drawPoly, cv2->integer); return; } diff --git a/src/server/sv_bot.c b/src/server/sv_bot.c index 5255ba313..58b83448a 100644 --- a/src/server/sv_bot.c +++ b/src/server/sv_bot.c @@ -115,11 +115,11 @@ int SV_BotAllocateClient(int clientNum) return i; } -/* -================== -SV_BotFreeClient -================== -*/ +/** + * @brief SV_BotFreeClient + * + * @param[in] clientNum + */ void SV_BotFreeClient(int clientNum) { client_t *cl; @@ -137,23 +137,25 @@ void SV_BotFreeClient(int clientNum) } } +/** + * @brief BotDrawDebugPolygons + * @param drawPoly - unused + * @param value - unused + * + * @todo TODO: remove in cm_patch.c + */ /* -================== -BotDrawDebugPolygons - -TODO: remove in cm_patch.c -================== -*/ void BotDrawDebugPolygons(BotPolyFunc drawPoly, int value) { - return; + return; } - -/* -================== -BotImport_Print -================== */ + +/** + * @brief BotImport_Print + * @param[in] type + * @param[in] fmt + */ static __attribute__ ((format(printf, 2, 3))) void QDECL BotImport_Print(int type, char *fmt, ...) { char str[2048]; @@ -192,63 +194,76 @@ static __attribute__ ((format(printf, 2, 3))) void QDECL BotImport_Print(int typ } } -/* -================== -BotImport_Trace -================== -*/ +/** + * @brief BotImport_Trace + * @param[in] bsptrace + * @param[in] start + * @param[in] mins + * @param[in] maxs + * @param[in] end + * @param[in] passent + * @param[in] contentmask + */ void BotImport_Trace(bsp_trace_t *bsptrace, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int passent, int contentmask) { // always use bounding box for bot stuff ? SV_Trace(bsptrace, start, mins, maxs, end, passent, contentmask, qfalse); } -/* -================== -BotImport_EntityTrace -================== -*/ +/** + * @brief BotImport_EntityTrace + * @param[in] bsptrace + * @param[in] start + * @param[in] mins + * @param[in] maxs + * @param[in] end + * @param[in] entnum + * @param[in] contentmask + */ void BotImport_EntityTrace(bsp_trace_t *bsptrace, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int entnum, int contentmask) { - // always use bounding box for bot stuff ? + // TODO: always use bounding box for bot stuff ? SV_ClipToEntity(bsptrace, start, mins, maxs, end, entnum, contentmask, qfalse); } -/* -================== -BotImport_PointContents -================== -*/ +/** + * @brief BotImport_PointContents + * @param[in] point + * @return + */ int BotImport_PointContents(vec3_t point) { return SV_PointContents(point, -1); } -/* -================== -BotImport_inPVS -================== -*/ +/** + * @brief BotImport_inPVS + * @param[in] p1 + * @param[in] p2 + * @return + */ int BotImport_inPVS(vec3_t p1, vec3_t p2) { return SV_inPVS(p1, p2); } -/* -================== -BotImport_BSPEntityData -================== -*/ +/** + * @brief BotImport_BSPEntityData + * @return + */ char *BotImport_BSPEntityData(void) { return CM_EntityString(); } -/* -================== -BotImport_BSPModelMinsMaxsOrigin -================== -*/ +/** + * @brief BotImport_BSPModelMinsMaxsOrigin + * @param[in] modelnum + * @param[in] angles + * @param[in] outmins + * @param[in] outmaxs + * @param[in] origin + */ void BotImport_BSPModelMinsMaxsOrigin(int modelnum, vec3_t angles, vec3_t outmins, vec3_t outmaxs, vec3_t origin) { clipHandle_t h = CM_InlineModel(modelnum); @@ -256,7 +271,7 @@ void BotImport_BSPModelMinsMaxsOrigin(int modelnum, vec3_t angles, vec3_t outmin CM_ModelBounds(h, mins, maxs); // if the model is rotated - if ((angles[0] || angles[1] || angles[2])) + if ((angles[0] != 0.f || angles[1] != 0.f || angles[2] != 0.f)) { // expand for rotation float max = RadiusFromBounds(mins, maxs); @@ -282,11 +297,11 @@ void BotImport_BSPModelMinsMaxsOrigin(int modelnum, vec3_t angles, vec3_t outmin } } -/* -================== -BotImport_GetMemory -================== -*/ +/** + * @brief BotImport_GetMemory + * @param size + * @return + */ void *BotImport_GetMemory(int size) { void *ptr; @@ -295,31 +310,28 @@ void *BotImport_GetMemory(int size) return ptr; } -/* -================== -BotImport_FreeMemory -================== -*/ +/** + * @brief BotImport_FreeMemory + * @param[in,out] ptr + */ void BotImport_FreeMemory(void *ptr) { Z_Free(ptr); } -/* -================== -BotImport_FreeZoneMemory -================== -*/ +/** + * @brief BotImport_FreeZoneMemory + */ void BotImport_FreeZoneMemory(void) { Z_FreeTags(TAG_BOTLIB); } -/* -================= -BotImport_HunkAlloc -================= -*/ +/** + * @brief BotImport_HunkAlloc + * @param[in] size + * @return + */ void *BotImport_HunkAlloc(int size) { if (Hunk_CheckMark()) @@ -330,11 +342,13 @@ void *BotImport_HunkAlloc(int size) return Hunk_Alloc(size, h_high); } -/* -================== -BotImport_DebugPolygonCreate -================== -*/ +/** + * @brief BotImport_DebugPolygonCreate + * @param[in] color + * @param[in] numPoints + * @param[in] points + * @return + */ int BotImport_DebugPolygonCreate(int color, int numPoints, vec3_t *points) { bot_debugpoly_t *poly; @@ -361,11 +375,10 @@ int BotImport_DebugPolygonCreate(int color, int numPoints, vec3_t *points) return i; } -/* -================== -BotImport_DebugPolygonCreate -================== -*/ +/** + * @brief BotImport_GetFreeDebugPolygon + * @return + */ bot_debugpoly_t *BotImport_GetFreeDebugPolygon(void) { int i; @@ -381,11 +394,13 @@ bot_debugpoly_t *BotImport_GetFreeDebugPolygon(void) return NULL; } -/* -================== -BotImport_DebugPolygonShow -================== -*/ +/** + * @brief BotImport_DebugPolygonShow + * @param id + * @param color + * @param numPoints + * @param points + */ void BotImport_DebugPolygonShow(int id, int color, int numPoints, vec3_t *points) { bot_debugpoly_t *poly = &debugpolygons[id]; @@ -396,52 +411,50 @@ void BotImport_DebugPolygonShow(int id, int color, int numPoints, vec3_t *points memcpy(poly->points, points, numPoints * sizeof(vec3_t)); } -/* -================== -BotImport_DebugPolygonDelete -================== -*/ +/** + * @brief BotImport_DebugPolygonDelete + * @param[in] id + */ void BotImport_DebugPolygonDelete(int id) { debugpolygons[id].inuse = qfalse; } -/* -================== -BotImport_DebugPolygonDeletePointer -================== -*/ +/** + * @brief BotImport_DebugPolygonDeletePointer + * @param[out] pPoly + */ void BotImport_DebugPolygonDeletePointer(bot_debugpoly_t *pPoly) { pPoly->inuse = qfalse; } -/* -================== -BotImport_DebugLineCreate -================== -*/ +/** + * @brief BotImport_DebugLineCreate + * @return + */ int BotImport_DebugLineCreate(void) { vec3_t points[1]; return BotImport_DebugPolygonCreate(0, 0, points); } -/* -================== -BotImport_DebugLineDelete -================== -*/ +/** + * @brief BotImport_DebugLineDelete + * @param[in] line + */ void BotImport_DebugLineDelete(int line) { BotImport_DebugPolygonDelete(line); } -/* -================== -BotImport_DebugLineShow -================== -*/ +/** + * @brief BotImport_DebugLineShow + * @param[in] line + * @param[in] start + * @param[in] end + * @param[in] color + */ void BotImport_DebugLineShow(int line, vec3_t start, vec3_t end, int color) { vec3_t points[4], dir, cross, up = { 0, 0, 1 }; @@ -457,7 +470,7 @@ void BotImport_DebugLineShow(int line, vec3_t start, vec3_t end, int color) VectorSubtract(end, start, dir); VectorNormalize(dir); dot = DotProduct(dir, up); - if (dot > 0.99 || dot < -0.99) + if (dot > 0.99f || dot < -0.99f) { VectorSet(cross, 1, 0, 0); } @@ -476,11 +489,11 @@ void BotImport_DebugLineShow(int line, vec3_t start, vec3_t end, int color) BotImport_DebugPolygonShow(line, color, 4, points); } -/* -================== -SV_BotClientCommand -================== -*/ +/** + * @brief BotClientCommand + * @param[in] client + * @param[in] command + */ void BotClientCommand(int client, char *command) { SV_ExecuteClientCommand(&svs.clients[client], command, qtrue, qfalse); @@ -489,22 +502,21 @@ void BotClientCommand(int client, char *command) #ifndef DEDICATED void BotImport_DrawPolygon(int color, int numpoints, float *points); #else -/* -================== -BotImport_DrawPolygon -================== -*/ +/** + * @brief BotImport_DrawPolygon + * @param color - unused + * @param numpoints - unused + * @param points - unused + */ void BotImport_DrawPolygon(int color, int numpoints, float *points) { Com_DPrintf("BotImport_DrawPolygon stub\n"); } #endif -/* -================== -SV_BotInitBotLib -================== -*/ +/** + * @brief SV_BotInitBotLib + */ void SV_BotInitBotLib(void) { botlib_import_t botlib_import; @@ -549,11 +561,13 @@ void SV_BotInitBotLib(void) // * * * BOT AI CODE IS BELOW THIS POINT * * * -/* -================== -SV_BotGetConsoleMessage -================== -*/ +/** + * @brief SV_BotGetConsoleMessage + * @param[in] client + * @param buf - unused + * @param size - unused + * @return + */ int SV_BotGetConsoleMessage(int client, char *buf, int size) { client_t *cl = &svs.clients[client]; diff --git a/src/server/sv_ccmds.c b/src/server/sv_ccmds.c index df2df8fe7..00b9ce790 100644 --- a/src/server/sv_ccmds.c +++ b/src/server/sv_ccmds.c @@ -45,13 +45,10 @@ static time_t uptimeSince; -/* -================== -SV_GetPlayerByName - -Returns the player with name from Cmd_Argv(1) -================== -*/ +/** + * @brief Returns the player with name from Cmd_Argv(1) + * @return + */ static client_t *SV_GetPlayerByName(void) { client_t *cl; @@ -165,11 +162,12 @@ static void SV_Map_f(void) } } -/* -================ -SV_CheckTransitionGameState -================ -*/ +/** + * @brief SV_CheckTransitionGameState + * @param[in] new_gs + * @param[in] old_gs + * @return + */ static qboolean SV_CheckTransitionGameState(gamestate_t new_gs, gamestate_t old_gs) { if (old_gs == new_gs && new_gs != GS_PLAYING) @@ -195,11 +193,13 @@ static qboolean SV_CheckTransitionGameState(gamestate_t new_gs, gamestate_t old_ return qtrue; } -/* -================ -SV_TransitionGameState -================ -*/ +/** + * @brief SV_TransitionGameState + * @param[in] new_gs + * @param[in] old_gs + * @param delay - unused + * @return + */ static qboolean SV_TransitionGameState(gamestate_t new_gs, gamestate_t old_gs, int delay) { // we always do a warmup before starting match @@ -227,20 +227,19 @@ static qboolean SV_TransitionGameState(gamestate_t new_gs, gamestate_t old_gs, i void MSG_PrioritiseEntitystateFields(void); void MSG_PrioritisePlayerStateFields(void); +/** + * @brief SV_FieldInfo_f + */ static void SV_FieldInfo_f(void) { MSG_PrioritiseEntitystateFields(); MSG_PrioritisePlayerStateFields(); } -/* -================ -SV_MapRestart_f - -Completely restarts a level, but doesn't send a new gamestate to the clients. -This allows fair starts with variable load times. -================ -*/ +/** + * @brief Completely restarts a level, but doesn't send a new gamestate to the clients. + * This allows fair starts with variable load times. + */ static void SV_MapRestart_f(void) { int i; @@ -403,11 +402,11 @@ static void SV_MapRestart_f(void) //=============================================================== -/* -================== -SV_TempBanNetAddress -================== -*/ +/** + * @brief SV_TempBanNetAddress + * @param[in] address + * @param[in] length + */ void SV_TempBanNetAddress(netadr_t address, int length) { int i; @@ -438,6 +437,11 @@ void SV_TempBanNetAddress(netadr_t address, int length) svs.tempBanAddresses[oldest].endtime = svs.time + length; } +/** + * @brief SV_TempBanIsBanned + * @param[in] address + * @return + */ qboolean SV_TempBanIsBanned(netadr_t address) { int i; @@ -456,14 +460,13 @@ qboolean SV_TempBanIsBanned(netadr_t address) return qfalse; } -/* -================ -SV_Status_f -================ -*/ +/** + * @brief SV_Status_f + */ static void SV_Status_f(void) { - int i, j, l; + int i; + unsigned int j, l; client_t *cl; playerState_t *ps; const char *s; @@ -545,11 +548,9 @@ static void SV_Status_f(void) Com_Printf("\n"); } -/* -================== -SV_ConSay_f -================== -*/ +/** + * @brief SV_ConSay_f + */ static void SV_ConSay_f(void) { char *p; @@ -581,25 +582,17 @@ static void SV_ConSay_f(void) SV_SendServerCommand(NULL, "chat \"%s\"", text); } -/* -================== -SV_Heartbeat_f - -Also called by SV_DropClient, SV_DirectConnect, and SV_SpawnServer -================== -*/ +/** + * @brief Also called by SV_DropClient, SV_DirectConnect, and SV_SpawnServer + */ void SV_Heartbeat_f(void) { svs.nextHeartbeatTime = -9999999; } -/* -=========== -SV_Serverinfo_f - -Examine the serverinfo string -=========== -*/ +/** + * @brief Examine the serverinfo string + */ static void SV_Serverinfo_f(void) { // make sure server is running @@ -613,26 +606,21 @@ static void SV_Serverinfo_f(void) Info_Print(Cvar_InfoString(CVAR_SERVERINFO | CVAR_SERVERINFO_NOUPDATE)); } -/* -=========== -SV_Systeminfo_f - +/** + * @brief Examine or change the serverinfo string -=========== -*/ + */ static void SV_Systeminfo_f(void) { Com_Printf("System info settings:\n"); Info_Print(Cvar_InfoString(CVAR_SERVERINFO | CVAR_SERVERINFO_NOUPDATE)); } -/* -=========== -SV_DumpUser_f - -Examine all a users info strings FIXME: move to game -=========== -*/ +/** + * @brief Examine all a users info strings + * + * @todo FIXME: move to game + */ static void SV_DumpUser_f(void) { client_t *cl; @@ -661,21 +649,20 @@ static void SV_DumpUser_f(void) Info_Print(cl->userinfo); } -/* -================= -SV_KillServer -================= -*/ +/** + * @brief SV_KillServer_f + */ static void SV_KillServer_f(void) { SV_Shutdown("killserver"); } -/* -================== -SV_CompleteMapName -================== -*/ + +/** + * @brief SV_CompleteMapName + * @param args - unused + * @param[in] argNum + */ static void SV_CompleteMapName(char *args, int argNum) { if (argNum == 2) @@ -684,16 +671,17 @@ static void SV_CompleteMapName(char *args, int argNum) } } -/* -================= -SV_GameCompleteStatus_f -================= -*/ +/** + * @brief SV_GameCompleteStatus_f + */ void SV_GameCompleteStatus_f(void) { SV_MasterGameCompleteStatus(); } +/** + * @brief SV_UptimeReset + */ void SV_UptimeReset(void) { uptimeSince = time(NULL); @@ -704,7 +692,7 @@ void SV_UptimeReset(void) */ void SV_Uptime_f(void) { - const unsigned long uptime = difftime(time(NULL), uptimeSince); + const unsigned long uptime = (unsigned long)(difftime(time(NULL), uptimeSince)); const unsigned int s = uptime % 60, m = (uptime % 3600) / 60, h = (uptime % 86400) / 3600, @@ -725,11 +713,9 @@ void SV_Uptime_f(void) //=========================================================== -/* -================== -SV_AddOperatorCommands -================== -*/ +/** + * @brief SV_AddOperatorCommands + */ void SV_AddOperatorCommands(void) { static qboolean initialized; @@ -776,11 +762,9 @@ void SV_AddOperatorCommands(void) SV_DemoInit(); } -/* -================== -SV_RemoveOperatorCommands -================== -*/ +/** + * @brief SV_RemoveOperatorCommands + */ void SV_RemoveOperatorCommands(void) { #if 0 diff --git a/src/server/sv_client.c b/src/server/sv_client.c index 7a2deaa1c..a984502d4 100644 --- a/src/server/sv_client.c +++ b/src/server/sv_client.c @@ -43,6 +43,9 @@ static void SV_CloseDownload(client_t *cl); /** * @brief A "getchallenge" OOB command has been received + * + * @param[in] from + * * @returns challenge number that can be used in a subsequent * connectResponse command. * @@ -130,6 +133,8 @@ void SV_GetChallenge(netadr_t from) /** * @brief A "connect" OOB command has been received + * + * @param[in] from */ void SV_DirectConnect(netadr_t from) { @@ -228,13 +233,13 @@ void SV_DirectConnect(netadr_t from) // never reject a LAN client based on ping if (!Sys_IsLANAddress(from)) { - if (sv_minPing->value && ping < sv_minPing->value) + if (sv_minPing->value != 0.f && ping < sv_minPing->value) { NET_OutOfBandPrint(NS_SERVER, from, "print\n[err_dialog]Server is for high pings only\n"); Com_DPrintf("Client %i rejected on a too low ping\n", i); return; } - if (sv_maxPing->value && ping > sv_maxPing->value) + if (sv_maxPing->value != 0.f && ping > sv_maxPing->value) { NET_OutOfBandPrint(NS_SERVER, from, "print\n[err_dialog]Server is for low pings only\n"); Com_DPrintf("Client %i rejected on a too high ping: %i\n", i, ping); @@ -367,7 +372,7 @@ void SV_DirectConnect(netadr_t from) Q_strncpyz(newcl->userinfo, userinfo, sizeof(newcl->userinfo)); // get the game a chance to reject this connection or modify the userinfo - denied = (char *)VM_Call(gvm, GAME_CLIENT_CONNECT, clientNum, qtrue, qfalse); // firstTime = qtrue + denied = (char *)(VM_Call(gvm, GAME_CLIENT_CONNECT, clientNum, qtrue, qfalse)); // firstTime = qtrue if (denied) { // we can't just use VM_ArgPtr, because that is only valid inside a VM_Call @@ -424,6 +429,10 @@ void SV_DirectConnect(netadr_t from) * @brief Called when the player is totally leaving the server, either willingly * or unwillingly. This is NOT called if the entire server is quiting * or crashing -- SV_FinalCommand() will handle that + * + * @param[in,out] drop + * @param[in] reason + * */ void SV_DropClient(client_t *drop, const char *reason) { @@ -521,6 +530,8 @@ void SV_DropClient(client_t *drop, const char *reason) * This will be sent on the initial connection and upon each new map load. * It will be resent if the client acknowledges a later message but has * the wrong gamestate. + * + * @param[in,out] client */ void SV_SendClientGameState(client_t *client) { @@ -595,6 +606,11 @@ void SV_SendClientGameState(client_t *client) SV_SendMessageToClient(&msg, client); } +/** + * @brief SV_ClientEnterWorld + * @param[in,out] client + * @param[in] cmd + */ void SV_ClientEnterWorld(client_t *client, usercmd_t *cmd) { int clientNum = client - svs.clients; @@ -642,7 +658,8 @@ CLIENT COMMAND EXECUTION */ /** - * @brief clear/free any download vars + * @brief Clear/free any download vars + * @param[in,out] cl */ static void SV_CloseDownload(client_t *cl) { @@ -669,6 +686,7 @@ static void SV_CloseDownload(client_t *cl) /** * @brief Abort a download if in progress + * @param[in] cl */ static void SV_StopDownload_f(client_t *cl) { @@ -682,6 +700,7 @@ static void SV_StopDownload_f(client_t *cl) /** * @brief Downloads are finished + * @param[in] cl */ static void SV_DoneDownload_f(client_t *cl) { @@ -699,6 +718,7 @@ static void SV_DoneDownload_f(client_t *cl) /** * @brief The argument will be the last acknowledged block from the client, it should be * the same as cl->downloadClientBlock + * @param[in,out] cl */ void SV_NextDownload_f(client_t *cl) { @@ -727,6 +747,10 @@ void SV_NextDownload_f(client_t *cl) SV_DropClient(cl, "broken download"); } +/** + * @brief SV_BeginDownload_f + * @param[in,out] cl + */ void SV_BeginDownload_f(client_t *cl) { // Kill any existing download @@ -743,6 +767,10 @@ void SV_BeginDownload_f(client_t *cl) Q_strncpyz(cl->downloadName, Cmd_Argv(1), sizeof(cl->downloadName)); } +/** + * @brief SV_WWWDownload_f + * @param[in,out] cl + */ void SV_WWWDownload_f(client_t *cl) { char *subcmd = Cmd_Argv(1); @@ -811,7 +839,11 @@ void SV_WWWDownload_f(client_t *cl) SV_DropClient(cl, va("SV_WWWDownload: unknown wwwdl subcommand '%s'", subcmd)); } -// abort an attempted download +/** + * @brief Abort an attempted download + * @param[in] cl + * @param[in] msg + */ void SV_BadDownload(client_t *cl, msg_t *msg) { MSG_WriteByte(msg, svc_download); @@ -823,6 +855,10 @@ void SV_BadDownload(client_t *cl, msg_t *msg) /** * @brief sv_wwwFallbackURL can be used to redirect clients to a web URL in case direct ftp/http didn't work (or is disabled on client's end) + * + * @param[in] cl + * @param[in] msg + * * @return return true when a redirect URL message was filled up * when the cvar is set to something, the download server will effectively never use a legacy download strategy */ @@ -844,7 +880,12 @@ static qboolean SV_CheckFallbackURL(client_t *cl, msg_t *msg) return qtrue; } -// Check if we are able to share the file +/** + * @brief Check if we are able to share the file + * @param[in] cl + * @param[in] msg + * @return + */ static qboolean SV_CheckDownloadAllowed(client_t *cl, msg_t *msg) { char errorMessage[1024]; @@ -885,7 +926,12 @@ static qboolean SV_CheckDownloadAllowed(client_t *cl, msg_t *msg) return qtrue; } -// We open the file here +/** + * @brief We open the file here + * @param[in,out] cl + * @param[in] msg + * @return + */ static qboolean SV_SetupDownloadFile(client_t *cl, msg_t *msg) { int download_flag; @@ -993,6 +1039,9 @@ static qboolean SV_SetupDownloadFile(client_t *cl, msg_t *msg) /** * @brief Check to see if the client wants a file, open it if needed and start pumping the client + * @param[in,out] cl + * @param[in] msg + * @return */ static qboolean SV_WriteDownloadToClient(client_t *cl, msg_t *msg) { @@ -1107,14 +1156,10 @@ static qboolean SV_WriteDownloadToClient(client_t *cl, msg_t *msg) return qtrue; } -/* -================== -SV_SendQueuedMessages - -Send one round of fragments, or queued messages to all clients that have data pending. -Return the shortest time interval for sending next packet to client -================== -*/ +/** + * @brief Send one round of fragments, or queued messages to all clients that have data pending. + * @return The shortest time interval for sending next packet to client + */ int SV_SendQueuedMessages(void) { int i, retval = -1, nextFragT; @@ -1143,13 +1188,10 @@ int SV_SendQueuedMessages(void) return retval; } -/* -================== -SV_SendDownloadMessages - -Send one round of download messages to all clients -================== -*/ +/** + * @brief Send one round of download messages to all clients + * @return + */ int SV_SendDownloadMessages(void) { int i, numDLs = 0; @@ -1180,26 +1222,29 @@ int SV_SendDownloadMessages(void) } /** - * @brief The client is going to disconnect, so remove the connection immediately FIXME: move to game? + * @brief The client is going to disconnect, so remove the connection immediately + * @param[in] cl + * + * @todo FIXME: move to game? */ static void SV_Disconnect_f(client_t *cl) { SV_DropClient(cl, "disconnected"); } -/* -================= -SV_VerifyPaks_f - -If we are pure, disconnect the client if they do no meet the following conditions: - -1. the first two checksums match our view of cgame and ui DLLs - Wolf specific: the checksum is the checksum of the pk3 we found the DLL in -2. there are no any additional checksums that we do not have - -This routine would be a bit simpler with a goto but i abstained -================= -*/ +/** + * @brief SV_VerifyPaks_f + * @details + * If we are pure, disconnect the client if they do no meet the following conditions: + * + * 1. the first two checksums match our view of cgame and ui DLLs + * Wolf specific: the checksum is the checksum of the pk3 we found the DLL in + * 2. there are no any additional checksums that we do not have + * + * This routine would be a bit simpler with a goto but i abstained + * + * @param[in,out] cl + */ static void SV_VerifyPaks_f(client_t *cl) { int nChkSum1, nChkSum2; @@ -1382,6 +1427,10 @@ static void SV_VerifyPaks_f(client_t *cl) } } +/** + * @brief SV_ResetPureClient_f + * @param[out] cl + */ static void SV_ResetPureClient_f(client_t *cl) { cl->pureAuthentic = 0; @@ -1390,6 +1439,7 @@ static void SV_ResetPureClient_f(client_t *cl) /** * @brief Pull specific info from a newly changed userinfo string into a more C friendly form. + * @param[in,out] cl */ void SV_UserinfoChanged(client_t *cl) { @@ -1505,6 +1555,10 @@ void SV_UserinfoChanged(client_t *cl) } } +/** + * @brief SV_UpdateUserinfo_f + * @param[in] cl + */ void SV_UpdateUserinfo_f(client_t *cl) { char *arg = Cmd_Argv(1); @@ -1554,11 +1608,15 @@ static ucmd_t ucmds[] = { "stopdl", SV_StopDownload_f, qfalse }, { "donedl", SV_DoneDownload_f, qfalse }, { "wwwdl", SV_WWWDownload_f, qfalse }, - { NULL, NULL } + { NULL, NULL, qfalse } }; /** * @brief Also called by bot code + * @param[in] cl + * @param[in] s + * @param[in] clientOK + * @param[in] premaprestart */ void SV_ExecuteClientCommand(client_t *cl, const char *s, qboolean clientOK, qboolean premaprestart) { @@ -1611,6 +1669,13 @@ void SV_ExecuteClientCommand(client_t *cl, const char *s, qboolean clientOK, qbo } } +/** + * @brief SV_ClientCommand + * @param[in,out] cl + * @param[in] msg + * @param[in] premaprestart + * @return + */ static qboolean SV_ClientCommand(client_t *cl, msg_t *msg, qboolean premaprestart) { int seq; @@ -1690,6 +1755,8 @@ static qboolean SV_ClientCommand(client_t *cl, msg_t *msg, qboolean premaprestar /** * @brief Also called by bot code + * @param[in,out] cl + * @param[in] cmd */ void SV_ClientThink(client_t *cl, usercmd_t *cmd) { @@ -1703,18 +1770,20 @@ void SV_ClientThink(client_t *cl, usercmd_t *cmd) VM_Call(gvm, GAME_CLIENT_THINK, cl - svs.clients); } -/* -================== -SV_UserMove - -The message usually contains all the movement commands -that were in the last three packets, so that the information -in dropped packets can be recovered. - -On very fast clients, there may be multiple usercmd packed into -each of the backup packets. -================== -*/ +/** + * @brief SV_UserMove + * + * @details The message usually contains all the movement commands + * that were in the last three packets, so that the information + * in dropped packets can be recovered. + * + * On very fast clients, there may be multiple usercmd packed into + * each of the backup packets. + * + * @param cl + * @param msg + * @param delta + */ static void SV_UserMove(client_t *cl, msg_t *msg, qboolean delta) { int i, key; @@ -1835,6 +1904,11 @@ static void SV_UserMove(client_t *cl, msg_t *msg, qboolean delta) } } +/** + * @brief SV_ParseBinaryMessage + * @param[in] cl + * @param[in] msg + */ static void SV_ParseBinaryMessage(client_t *cl, msg_t *msg) { int size; @@ -1857,7 +1931,9 @@ USER CMD EXECUTION */ /** - * @brief Parses a client packet + * @brief SV_ExecuteClientMessage + * @param[in,out] cl + * @param[in] msg */ void SV_ExecuteClientMessage(client_t *cl, msg_t *msg) { diff --git a/src/server/sv_demo.c b/src/server/sv_demo.c index aaeb4390b..7e0db743c 100644 --- a/src/server/sv_demo.c +++ b/src/server/sv_demo.c @@ -99,13 +99,11 @@ static qboolean keepSaved = qfalse; // var that memorizes if we keep the new max * Functions used to either trim unnecessary or privacy concerned data, or to just check if the data should be written in the demo, relayed to a more specialized function or just dropped. ***********************************************/ -/* -==================== -SV_CleanStrCmd - -Same as Q_CleanStr but also remove any ^s or special empty color created by the engine in a gamecommand. -==================== -*/ +/** + * @brief Same as Q_CleanStr but also remove any ^s or special empty color created by the engine in a gamecommand. + * @param[in] string + * @return + */ char *SV_CleanStrCmd(char *string) { char *d = string; @@ -131,13 +129,12 @@ char *SV_CleanStrCmd(char *string) return string; } -/* -==================== -SV_CheckClientCommand - -Check that the clientCommand is OK (if not we either continue with a more specialized function, or drop it altogether if there's a privacy concern) -==================== -*/ +/** + * @brief Check that the clientCommand is OK (if not we either continue with a more specialized function, or drop it altogether if there's a privacy concern) + * @param[in] client + * @param[in] cmd + * @return + */ qboolean SV_CheckClientCommand(client_t *client, const char *cmd) { // If that's a userinfo command, we directly handle that with a specialized function (and we check that it contains at least 10 characters so that when we copy the string we don't end up copying a random address in memory) @@ -160,13 +157,11 @@ qboolean SV_CheckClientCommand(client_t *client, const char *cmd) return qtrue; // else, the check is OK and we continue to process with the original function } -/* -==================== -SV_CheckServerCommand - -Check that the serverCommand is OK to save (or if we drop it because already handled somewhere else) -==================== -*/ +/** + * @brief Check that the serverCommand is OK to save (or if we drop it because already handled somewhere else) + * @param[in] cmd + * @return + */ qboolean SV_CheckServerCommand(const char *cmd) { if (!Q_strncmp(cmd, "print", 5) || !Q_strncmp(cmd, "cp", 2) || !Q_strncmp(cmd, "disconnect", 10)) @@ -178,14 +173,13 @@ qboolean SV_CheckServerCommand(const char *cmd) return qtrue; // else, the check is OK and we continue to process with the original function } -/* -==================== -SV_CheckLastCmd - -Check and store the last command and compare it with the current one, to avoid duplicates. -If onlyStore is true, it will only store the new cmd, without checking. -==================== -*/ +/** + * @brief Check and store the last command and compare it with the current one, to avoid duplicates. + * If onlyStore is true, it will only store the new cmd, without checking. + * @param[in] cmd + * @param[in] onlyStore + * @return + */ qboolean SV_CheckLastCmd(const char *cmd, qboolean onlyStore) { static char prevcmddata[MAX_STRING_CHARS]; @@ -194,7 +188,7 @@ qboolean SV_CheckLastCmd(const char *cmd, qboolean onlyStore) char *cleanedcmd = (char *)malloc(MAX_STRING_CHARS * sizeof(char)); Q_strncpyz(cleanedprevcmd, SV_CleanStrCmd(va("%s", prevcmd)), MAX_STRING_CHARS); - Q_strncpyz(cleanedcmd, SV_CleanStrCmd(va("%s", (char *)cmd)), MAX_STRING_CHARS); + Q_strncpyz(cleanedcmd, SV_CleanStrCmd(va("%s", cmd)), MAX_STRING_CHARS); // if we only want to store, we skip any checking if (!onlyStore && strlen(prevcmd) > 0 && !Q_stricmp(cleanedprevcmd, cleanedcmd)) @@ -215,13 +209,11 @@ qboolean SV_CheckLastCmd(const char *cmd, qboolean onlyStore) } } -/* -==================== -SV_CheckGameCommand - -Check that the gameCommand is OK and that we can save it (or if we drop it for privacy concerns and/or because it's handled somewhere else already) -==================== -*/ +/** + * @brief Check that the gameCommand is OK and that we can save it (or if we drop it for privacy concerns and/or because it's handled somewhere else already) + * @param[in] cmd + * @return + */ qboolean SV_CheckGameCommand(const char *cmd) { if (!SV_CheckLastCmd(cmd, qfalse)) @@ -248,13 +240,12 @@ qboolean SV_CheckGameCommand(const char *cmd) } } -/* -==================== -SV_CheckConfigString - -Check that the configstring is OK (or if we relay to ClientConfigString) -==================== -*/ +/** + * @brief Check that the configstring is OK (or if we relay to ClientConfigString) + * @param cs_index + * @param cs_string + * @return + */ qboolean SV_CheckConfigString(int cs_index, const char *cs_string) { // if this is a player, we save the configstring as a clientconfigstring @@ -275,32 +266,22 @@ qboolean SV_CheckConfigString(int cs_index, const char *cs_string) return qtrue; } -/* -==================== -SV_DemoFilterClientUserinfo - -Filters privacy keys from a client userinfo to later write in a demo file -==================== -*/ -void SV_DemoFilterClientUserinfo(const char *userinfo) +/** + * @brief Filters privacy keys from a client userinfo to later write in a demo file + * @param[in,out] userinfo + */ +void SV_DemoFilterClientUserinfo(char *userinfo) { - char *buf; - - buf = (char *)userinfo; - Info_RemoveKey(buf, "cl_guid"); - Info_RemoveKey(buf, "ip"); - Info_SetValueForKey(buf, "cl_voip", "0"); - - userinfo = (const char *)buf; + Info_RemoveKey(userinfo, "cl_guid"); + Info_RemoveKey(userinfo, "ip"); + Info_SetValueForKey(userinfo, "cl_voip", "0"); } -/* -==================== -SV_CleanFilename - -Attempts to clean invalid characters from a filename that may prevent the demo to be stored on the filesystem -==================== -*/ +/** + * @brief Attempts to clean invalid characters from a filename that may prevent the demo to be stored on the filesystem + * @param[in] string + * @return + */ char *SV_CleanFilename(char *string) { char *d = string; @@ -330,13 +311,10 @@ char *SV_CleanFilename(char *string) return string; } -/* -==================== -SV_GenerateDateTime - -Generate a full datetime (local and utc) from now -==================== -*/ +/** + * @brief Generate a full datetime (local and utc) from now + * @return + */ char *SV_GenerateDateTime(void) { // Current local time @@ -365,13 +343,10 @@ char *SV_GenerateDateTime(void) * Functions used to construct and write demo events ***********************************************/ -/* -==================== -SV_DemoWriteMessage - -Write a message/event to the demo file -==================== -*/ +/** + * @brief Write a message/event to the demo file + * @param[in,out] msg + */ static void SV_DemoWriteMessage(msg_t *msg) { int len; @@ -384,13 +359,11 @@ static void SV_DemoWriteMessage(msg_t *msg) MSG_Clear(msg); } -/* -==================== -SV_DemoWriteClientCommand - -Write a client command to the demo file -==================== -*/ +/** + * @brief Write a client command to the demo file + * @param[in] client + * @param[in] cmd + */ static void SV_DemoWriteClientCommand(client_t *client, const char *cmd) { msg_t msg; @@ -408,6 +381,12 @@ static void SV_DemoWriteClientCommand(client_t *client, const char *cmd) SV_DemoWriteMessage(&msg); } +/** + * @brief SV_DemoClientCommandCapture + * @param[in] client + * @param[in] msg + * @return + */ qboolean SV_DemoClientCommandCapture(client_t *client, const char *msg) { if (sv.demoState == DS_RECORDING) // if demo is recording, we store this command and clientid @@ -428,14 +407,15 @@ qboolean SV_DemoClientCommandCapture(client_t *client, const char *msg) return qtrue; } -/* -==================== -SV_DemoWriteServerCommand - -Write a server command to the demo file -Note: we record only server commands that are meant to be sent to everyone in the first place, that's why we don't even bother to store the clientnum. For commands that were only intended to specifically one player, we only record them if they were game commands (see below the specialized function), else we do not because it may be unsafe (such as "disconnect" command) -==================== -*/ +/** + * @brief Write a server command to the demo file + * @param[in] cmd + * + * @note We record only server commands that are meant to be sent to everyone in the first place, + * that's why we don't even bother to store the clientnum. For commands that were only intended to specifically one player, + * we only record them if they were game commands (see below the specialized function), + * else we do not because it may be unsafe (such as "disconnect" command) + */ void SV_DemoWriteServerCommand(const char *cmd) { msg_t msg; @@ -456,10 +436,19 @@ void SV_DemoWriteServerCommand(const char *cmd) ==================== SV_DemoWriteGameCommand -Write a game command to the demo file -Note: game commands are sent to server commands, but we record them separately because game commands are safe to be replayed to everyone (even if at recording time it was only intended to one player), while server commands may be unsafe if it was dedicated only to one player (such as "disconnect") + ==================== */ +/** + * @brief Write a game command to the demo file + * @param[in] clientNum + * @param[in] cmd + * + * @note Game commands are sent to server commands, + * but we record them separately because game commands are safe to be replayed to everyone + * (even if at recording time it was only intended to one player), + * while server commands may be unsafe if it was dedicated only to one player (such as "disconnect") + */ void SV_DemoWriteGameCommand(int clientNum, const char *cmd) { msg_t msg; @@ -477,15 +466,16 @@ void SV_DemoWriteGameCommand(int clientNum, const char *cmd) SV_DemoWriteMessage(&msg); } -/* -==================== -SV_DemoWriteConfigString - -Write a configstring to the demo file -cs_index = index of the configstring (see bg_public.h) -cs_string = content of the configstring to set -==================== -*/ +/** + * @brief Write a configstring to the demo file + * + * @details + * cs_index = index of the configstring (see bg_public.h) + * cs_string = content of the configstring to set + * + * @param[in] cs_index + * @param[in] cs_string + */ void SV_DemoWriteConfigString(int cs_index, const char *cs_string) { msg_t msg; @@ -505,14 +495,16 @@ void SV_DemoWriteConfigString(int cs_index, const char *cs_string) SV_DemoWriteMessage(&msg); } -/* -==================== -SV_DemoWriteClientConfigString - -Write a client configstring to the demo file -Note: this is a bit redundant with SV_DemoWriteUserinfo, because clientCommand userinfo sets the new userinfo for a democlient, and clients configstrings are always derived from userinfo string. But this function is left for security purpose (so we make sure the configstring is set right). -==================== -*/ +/** + * @brief Write a client configstring to the demo file + * + * @param[in] clientNum + * @param[in] cs_string + * + * @note This is a bit redundant with SV_DemoWriteUserinfo, because clientCommand userinfo sets the new userinfo for a democlient, + * and clients configstrings are always derived from userinfo string. + * But this function is left for security purpose (so we make sure the configstring is set right). + */ static void SV_DemoWriteClientConfigString(int clientNum, const char *cs_string) { msg_t msg; @@ -524,14 +516,13 @@ static void SV_DemoWriteClientConfigString(int clientNum, const char *cs_string) SV_DemoWriteMessage(&msg); } -/* -==================== -SV_DemoWriteClientUserinfo - -Write a client userinfo to the demo file (client_t fields can almost all be filled from the userinfo string) -Note: in practice, clients userinfo should be loaded before their configstrings (because configstrings derive from userinfo in a real game) -==================== -*/ +/** + * @brief Write a client userinfo to the demo file (client_t fields can almost all be filled from the userinfo string) + * @param[in] client + * @param[in] userinfo + * + * @note In practice, clients userinfo should be loaded before their configstrings (because configstrings derive from userinfo in a real game) + */ void SV_DemoWriteClientUserinfo(client_t *client, const char *userinfo) { msg_t msg; @@ -553,15 +544,21 @@ void SV_DemoWriteClientUserinfo(client_t *client, const char *userinfo) SV_DemoWriteMessage(&msg); // commit this demo event in the demo file } -/* -==================== -SV_DemoWriteClientUsercmd - -Write a client usercmd_t for the current packet (called from sv_client.c SV_UserMove) which contains the movements commands for the player -Note: this is unnecessary to make players move, this is handled by entities management. This is only used to add more data to the dama for data analysis AND avoid inactivity timer activation -Note2: enabling this feature will use a LOT more storage space, so enable it only if you will really use it. Generally, you're probably better off leaving it disabled. -==================== -*/ +/** + * @brief Write a client usercmd_t for the current packet (called from sv_client.c SV_UserMove) which contains the movements commands for the player + * + * @param[in] cl + * @param[in] delta + * @param[in] cmdCount + * @param[in] cmds + * @param[in] key + * + * @note Note: this is unnecessary to make players move, this is handled by entities management. + * This is only used to add more data to the dama for data analysis AND avoid inactivity timer activation + * + * @note Enabling this feature will use a LOT more storage space, so enable it only if you will really use it. + * Generally, you're probably better off leaving it disabled. + */ /* void SV_DemoWriteClientUsercmd( client_t *cl, qboolean delta, int cmdCount, usercmd_t *cmds, int key ) { @@ -593,15 +590,13 @@ SV_DemoWriteMessage(&msg); } */ -/* -==================== -SV_DemoWriteAllEntityShared - -Write all active clients playerState (playerState_t) -Note: this is called at every game's endFrame. -Note2: Contrary to the other DemoWrite functions, this one writes all entities at once in one message, instead of one entity/command per message. -==================== -*/ +/** + * @brief Write all active clients playerState (playerState_t) + * + * @note This is called at every game's endFrame. + * + * @note Contrary to the other DemoWrite functions, this one writes all entities at once in one message, instead of one entity/command per message. + */ static void SV_DemoWriteAllPlayerState(void) { msg_t msg; @@ -630,15 +625,14 @@ static void SV_DemoWriteAllPlayerState(void) SV_DemoWriteMessage(&msg); } -/* -==================== -SV_DemoWriteAllEntityState - -Write all entities state (gentity_t->entityState_t) -Note: this is called at every game's endFrame. -Note2: Contrary to the other DemoWrite functions, this one writes all entities at once in one message, instead of one entity/command per message. This could be easily changed, but I'm not sure it would be beneficial for the CPU time and demo storage. -==================== -*/ +/** + * @brief Write all entities state (gentity_t->entityState_t) + * + * @note This is called at every game's endFrame. + * + * @note Contrary to the other DemoWrite functions, this one writes all entities at once in one message, instead of one entity/command per message. + * This could be easily changed, but I'm not sure it would be beneficial for the CPU time and demo storage. + */ static void SV_DemoWriteAllEntityState(void) { msg_t msg; @@ -669,15 +663,13 @@ static void SV_DemoWriteAllEntityState(void) SV_DemoWriteMessage(&msg); } -/* -==================== -SV_DemoWriteAllEntityShared - -Write all entities (gentity_t->entityShared_t) -Note: this is called at every game's endFrame. -Note2: Contrary to the other DemoWrite functions, this one writes all entities at once in one message, instead of one entity/command per message. -==================== -*/ +/** + * @brief Write all entities (gentity_t->entityShared_t) + * + * @note This is called at every game's endFrame. + * + * @note Contrary to the other DemoWrite functions, this one writes all entities at once in one message, instead of one entity/command per message. + */ static void SV_DemoWriteAllEntityShared(void) { msg_t msg; @@ -708,16 +700,14 @@ static void SV_DemoWriteAllEntityShared(void) SV_DemoWriteMessage(&msg); } -/* -==================== -SV_DemoWriteFrame - -Record all the entities (gentities fields) and players (player_t fields) at the end of every frame (this is the only write function to be called in every frame for sure) -Will be called once per server's frame -Called in the main server's loop SV_Frame() in sv_main.c -Note that this function could be called DemoWriteEndFrame, because it writes once at the end of every frame (the other events are written whenever they happen using hooks) -==================== -*/ +/** + * @brief Record all the entities (gentities fields) and players (player_t fields) at the end of every frame (this is the only write function to be called in every frame for sure) + * + * @details Will be called once per server's frame + * Called in the main server's loop SV_Frame() in sv_main.c + * Note that this function could be called DemoWriteEndFrame, + * because it writes once at the end of every frame (the other events are written whenever they happen using hooks) + */ void SV_DemoWriteFrame(void) { msg_t msg; @@ -754,16 +744,17 @@ void SV_DemoWriteFrame(void) * Functions to start/stop the recording/playback of a demo file ***********************************************/ -/* -==================== -SV_DemoAutoDemoRecord - -Generates a meaningful demo filename and automatically starts the demo recording. -This function is used in conjunction with the variable sv_autoDemo 1 -Note: be careful, if the hostname contains bad characters, the demo may not be able to be saved at all! There's a small filtering in place but a bad filename may pass through! -Note2: this function is called at MapRestart and SpawnServer (called in Map func), but in no way it's called right at the time it's set. -==================== -*/ +/** + * @brief Generates a meaningful demo filename and automatically starts the demo recording. + * + * @details This function is used in conjunction with the variable sv_autoDemo 1 + * + * @note Be careful, if the hostname contains bad characters, the demo may not be able to be saved at all! + * There's a small filtering in place but a bad filename may pass through! + * + * @note this function is called at MapRestart and SpawnServer (called in Map func), + * but in no way it's called right at the time it's set. + */ void SV_DemoAutoDemoRecord(void) { qtime_t now; @@ -788,13 +779,9 @@ void SV_DemoAutoDemoRecord(void) free(demoname); } -/* -==================== -SV_DemoStopPlayback - -Close the demo file and restart the map (can be used both when recording or when playing or at shutdown of the game) -==================== -*/ +/** + * @brief Close the demo file and restart the map (can be used both when recording or when playing or at shutdown of the game) + */ static void SV_DemoStopPlayback(void) { int olddemostate; @@ -916,13 +903,9 @@ static void SV_DemoStopPlayback(void) } } -/* -==================== -SV_DemoRestartPlayback - -Just issue again the demo_play command along with the demo filename (used when the system will automatically restart the server for special cvars values to be set up, eg: sv_maxclients, fs_game, g_gametype, etc..) -==================== -*/ +/** + * @brief Just issue again the demo_play command along with the demo filename (used when the system will automatically restart the server for special cvars values to be set up, eg: sv_maxclients, fs_game, g_gametype, etc..) + */ void SV_DemoRestartPlayback(void) { if (strlen(savedPlaybackDemoname)) @@ -937,16 +920,17 @@ void SV_DemoRestartPlayback(void) return; } -/* -==================== -SV_DemoStartPlayback - -Start the playback of a demo -sv.demo* have already been set and the demo file opened, start reading gamestate info -This function will also check that everything is alright (such as gametype, map, sv_fps, sv_democlients, sv_maxclients, etc.), if not it will try to fix it automatically -Note for developers: this is basically a mirror of SV_DemoStartRecord() but the other way around (there it writes, here it reads) - but only for the part about the headers, for the rest (eg: userinfo, configstrings, playerstates) it's directly managed by ReadFrame. -==================== -*/ +/** + * @brief Start the playback of a demo + * + * @details sv.demo* have already been set and the demo file opened, start reading gamestate info. + * + * This function will also check that everything is alright (such as gametype, map, sv_fps, sv_democlients, sv_maxclients, etc.), + * if not it will try to fix it automatically + * + * @note For developers: this is basically a mirror of SV_DemoStartRecord() but the other way around (there it writes, here it reads) + * - but only for the part about the headers, for the rest (eg: userinfo, configstrings, playerstates) it's directly managed by ReadFrame. + */ static void SV_DemoStartPlayback(void) { msg_t msg; @@ -1265,14 +1249,10 @@ static void SV_DemoStartPlayback(void) return; } -/* -==================== -SV_DemoStartRecord - -Start the recording of a demo by saving some headers data (such as the number of clients, mapname, gametype, etc..) -sv.demo* have already been set and the demo file opened, start writing gamestate info -==================== -*/ +/** + * @brief Start the recording of a demo by saving some headers data (such as the number of clients, mapname, gametype, etc..) + * @details sv.demo* have already been set and the demo file opened, start writing gamestate info + */ static void SV_DemoStartRecord(void) { msg_t msg; @@ -1351,14 +1331,10 @@ static void SV_DemoStartRecord(void) Cvar_SetValue("sv_demoState", DS_RECORDING); } -/* -==================== -SV_DemoStopRecord - -Stop the recording of a demo -Write end of demo (demo_endDemo marker) and close the demo file -==================== -*/ +/** + * @brief Stop the recording of a demo + * @details Write end of demo (demo_endDemo marker) and close the demo file + */ static void SV_DemoStopRecord(void) { msg_t msg; @@ -1380,14 +1356,14 @@ static void SV_DemoStopRecord(void) * Functions to read demo events ***********************************************/ -/* -==================== -SV_DemoReadClientCommand - -Replay a client command -Client command management (generally automatic, such as tinfo for HUD team overlay status, team selection, etc.) - except userinfo command that is managed by another event -==================== -*/ +/** + * @brief Replay a client command + * + * @details Client command management (generally automatic, such as tinfo for HUD team overlay status, team selection, etc.) + * - except userinfo command that is managed by another event + * + * @param[in] msg + */ static void SV_DemoReadClientCommand(msg_t *msg) { char *cmd; @@ -1398,14 +1374,13 @@ static void SV_DemoReadClientCommand(msg_t *msg) SV_ExecuteClientCommand(&svs.clients[num], cmd, qtrue, qfalse); // 3rd arg = clientOK, and it's necessarily true since we saved the command in the demo (else it wouldn't be saved) } -/* -==================== -SV_DemoReadServerCommand - -Replay a server command -Server command management - except print/cp (dropped at recording because already handled by gameCommand), -==================== -*/ +/** + * @brief Replay a server command + * + * @details Server command management - except print/cp (dropped at recording because already handled by gameCommand). + * + * @param[in] msg + */ static void SV_DemoReadServerCommand(msg_t *msg) { char *cmd; @@ -1414,14 +1389,16 @@ static void SV_DemoReadServerCommand(msg_t *msg) SV_SendServerCommand(NULL, "%s", cmd); } -/* -==================== -SV_DemoReadGameCommand - -Replay a game command (only game commands sent to all clients) -Game command management - such as prints/centerprint (cp) scores command - except chat/tchat (handled by clientCommand) - basically the same as demo_serverCommand (because sv_GameSendServerCommand uses SV_SendServerCommand, but game commands are safe to be replayed to everyone, while server commands may be unsafe such as disconnect) -==================== -*/ +/** + * @brief Replay a game command (only game commands sent to all clients) + * + * @details Game command management, such as prints/centerprint (cp) scores command, except chat/tchat (handled by clientCommand) + * + * Basically the same as demo_serverCommand (because sv_GameSendServerCommand uses SV_SendServerCommand, + * but game commands are safe to be replayed to everyone, while server commands may be unsafe such as disconnect) + * + * @param[in] msg + */ static void SV_DemoReadGameCommand(msg_t *msg) { char *cmd; @@ -1436,13 +1413,10 @@ static void SV_DemoReadGameCommand(msg_t *msg) } } -/* -==================== -SV_DemoReadConfigString - -Read a configstring from a message and load it into memory -==================== -*/ +/** + * @brief Read a configstring from a message and load it into memory + * @param[in] msg + */ static void SV_DemoReadConfigString(msg_t *msg) { char *configstring; @@ -1459,14 +1433,14 @@ static void SV_DemoReadConfigString(msg_t *msg) } } -/* -==================== -SV_DemoReadClientConfigString - -Read a demo client configstring from a message, load it into memory and broadcast changes to gamecode and clients -This function also manages demo clientbegin at connections and teamchange (which are normally totally handled by the gamecode, so we can't directly access nor store these events in the demo, we must use clever ways to reproduce them at the right time) -==================== -*/ +/** + * @brief Read a demo client configstring from a message, load it into memory and broadcast changes to gamecode and clients + * @details This function also manages demo clientbegin at connections and teamchange + * (which are normally totally handled by the gamecode, so we can't directly access nor store these events in the demo, + * we must use clever ways to reproduce them at the right time) + * + * @param[in] msg + */ static void SV_DemoReadClientConfigString(msg_t *msg) { client_t *client; @@ -1558,14 +1532,13 @@ static void SV_DemoReadClientConfigString(msg_t *msg) } } -/* -==================== -SV_DemoReadClientUserinfo - -Read a demo client userinfo string from a message, load it into memory, fills client_t fields by parsing the userinfo and broacast the change to the gamecode and clients -Note: this function also manage the initial team of democlients when demo recording has started. Subsequent team changes will be directly handled by clientCommands "team" -==================== -*/ +/** + * @brief Read a demo client userinfo string from a message, load it into memory, fills client_t fields by parsing the userinfo and broacast the change to the gamecode and clients + * @param msg + * + * @note This function also manage the initial team of democlients when demo recording has started. + * Subsequent team changes will be directly handled by clientCommands "team" + */ static void SV_DemoReadClientUserinfo(msg_t *msg) { client_t *client; @@ -1622,14 +1595,16 @@ static void SV_DemoReadClientUserinfo(msg_t *msg) free(svdnewteam); } -/* -==================== -SV_DemoReadClientUsercmd - -Read the usercmd_t for a democlient and restituate the movements - this is NOT needed to make democlients move, this is handled by entities management, but it should avoid inactivity timer to activate and can be used for demo analysis -FIXME: should set ucmd->serverTime = client->ps.commandTime + 2 to avoid the dropping of the usercmds_t packets, see g_active.c -==================== -*/ +/** + * @brief Read the usercmd_t for a democlient and restituate the movements + * + * @details This is NOT needed to make democlients move, this is handled by entities management, + * but it should avoid inactivity timer to activate and can be used for demo analysis + * + * @param[in] msg + * + * @todo FIXME: should set ucmd->serverTime = client->ps.commandTime + 2 to avoid the dropping of the usercmds_t packets, see g_active.c + */ /* static void SV_DemoReadClientUsercmd( msg_t *msg ) { @@ -1649,13 +1624,10 @@ static void SV_DemoReadClientUsercmd( msg_t *msg ) } */ -/* -==================== -SV_DemoReadAllPlayerState - -Read all democlients playerstate (playerState_t) from a message and store them in a demoPlayerStates array (it will be loaded in memory later when SV_DemoReadRefresh() is called) -==================== -*/ +/** + * @brief Read all democlients playerstate (playerState_t) from a message and store them in a demoPlayerStates array (it will be loaded in memory later when SV_DemoReadRefresh() is called) + * @param[in] msg + */ static void SV_DemoReadAllPlayerState(msg_t *msg) { playerState_t *player; @@ -1673,13 +1645,10 @@ static void SV_DemoReadAllPlayerState(msg_t *msg) sv.demoPlayerStates[num] = *player; } -/* -==================== -SV_DemoReadAllEntityState - -Read all entities state (gentity_t or sharedEntity_t->entityState_t) from a message and store them in a demoEntities[num].s array (it will be loaded in memory later when SV_DemoReadRefresh() is called) -==================== -*/ +/** + * @brief Read all entities state (gentity_t or sharedEntity_t->entityState_t) from a message and store them in a demoEntities[num].s array (it will be loaded in memory later when SV_DemoReadRefresh() is called) + * @param[in] msg + */ static void SV_DemoReadAllEntityState(msg_t *msg) { sharedEntity_t *entity; @@ -1700,13 +1669,12 @@ static void SV_DemoReadAllEntityState(msg_t *msg) } } -/* -==================== -SV_DemoReadAllEntityShared - -Read all shared entities (gentity_t or sharedEntity_t->entityShared_t - NOTE: sharedEntity_t = gentity_t != entityShared_t which is a subfield of gentity_t) from a message and store them in a demoEntities[num].r array (it will be loaded in memory later when SV_DemoReadRefresh() is called) -==================== -*/ +/** + * @brief Read all shared entities (gentity_t or sharedEntity_t->entityShared_t + * @param[in] msg + * + * @note sharedEntity_t = gentity_t != entityShared_t which is a subfield of gentity_t) from a message and store them in a demoEntities[num].r array (it will be loaded in memory later when SV_DemoReadRefresh() is called) + */ static void SV_DemoReadAllEntityShared(msg_t *msg) { sharedEntity_t *entity; @@ -1747,13 +1715,9 @@ static void SV_DemoReadAllEntityShared(msg_t *msg) } } -/* -==================== -SV_DemoReadRefreshEntities - -Load into memory all stored demo players states and entities (which effectively overwrites the one that were previously written by the game since SV_ReadFrame is called at the very end of every game's frame iteration). -==================== -*/ +/** + * @brief Load into memory all stored demo players states and entities (which effectively overwrites the one that were previously written by the game since SV_ReadFrame is called at the very end of every game's frame iteration). + */ static void SV_DemoReadRefreshEntities(void) { int i; @@ -1775,14 +1739,12 @@ static void SV_DemoReadRefreshEntities(void) } } -/* -==================== -SV_DemoReadRefreshPlayersHealth - -Update all demoplayers health (will be reflected on the HUD when spectated - for team overlay see tinfo clientcommand) -Note: this function should always be called after SV_DemoReadRefreshEntities() (or you can also change SV_GameClientNum(i) to sv.demoPlayerStates[i], but make sure the entity already has updated its health state...) -==================== -*/ +/** + * @brief Update all demoplayers health (will be reflected on the HUD when spectated - for team overlay see tinfo clientcommand) + * + * @note This function should always be called after SV_DemoReadRefreshEntities() (or you can also change SV_GameClientNum(i) to sv.demoPlayerStates[i], + * but make sure the entity already has updated its health state...) + */ void SV_DemoReadRefreshPlayersHealth(void) { int i; @@ -1794,15 +1756,15 @@ void SV_DemoReadRefreshPlayersHealth(void) } } -/* -==================== -SV_DemoReadFrame - -Play a frame from the demo file -This function will read one frame per call, and will process every events contained (switch to the next event when meeting the demo_EOF marker) until it meets the end of the frame (demo_endDemo marker) -Called in the main server's loop SV_Frame() in sv_main.c (it's called after any other event processing, so that it overwrites anything the game may have loaded into memory, but before the entities are broadcasted to the clients) -==================== -*/ +/** + * @brief Play a frame from the demo file + * + * @details This function will read one frame per call, and will process every events contained (switch to the next event when meeting the demo_EOF marker) + * until it meets the end of the frame (demo_endDemo marker). + * + * Called in the main server's loop SV_Frame() in sv_main.c (it's called after any other event processing, + * so that it overwrites anything the game may have loaded into memory, but before the entities are broadcasted to the clients) + */ void SV_DemoReadFrame(void) { msg_t msg; @@ -1823,10 +1785,10 @@ void SV_DemoReadFrame(void) // Update timescale currentframe++; // update the current frame number - if (com_timescale->value < 1.0 && com_timescale->value > 0.0) + if (com_timescale->value < 1.0f && com_timescale->value > 0.0f) { // Check timescale: if slowed timescale (below 1.0), then we check that we pass one frame on 1.0/com_timescale (eg: timescale = 0.5, 1.0/0.5=2, so we pass one frame on two) - if (currentframe % (int)(1.0 / com_timescale->value) != 0) + if (currentframe % (int)(1.0f / com_timescale->value) != 0) { // if it's not yet the right time to read the frame, we just pass and wait for the next server frame to read this demo frame return; } @@ -1877,7 +1839,6 @@ void SV_DemoReadFrame(void) else { // else we just drop the demo and throw a big fat error Com_Error(ERR_FATAL, "SV_DemoReadFrame: Illegible demo message\n"); - return; } case demo_EOF: // end of a demo event (the loop will continue to real the next event) MSG_Clear(&msg); @@ -1925,7 +1886,7 @@ void SV_DemoReadFrame(void) svs.time = MSG_ReadLong(&msg); // refresh server in-game time (overwriting any change the game may have done) memsvtime = svs.time; // keep memory of the last server time, in case we want to freeze the demo - if (com_timescale->value > 1.0) + if (com_timescale->value > 1.0f) { // Check for timescale: if timescale is faster (above 1.0), we read more frames at once (eg: timescale=2, we read 2 frames for one call of this function) if (currentframe % (int)(com_timescale->value) != 0) { // Check that we've read all the frames we needed @@ -1943,6 +1904,9 @@ void SV_DemoReadFrame(void) } } +/** + * @brief SV_DemoStopAll + */ void SV_DemoStopAll(void) { // stop any demos @@ -1956,11 +1920,9 @@ void SV_DemoStopAll(void) } } -/* -================= -SV_Demo_Record_f -================= -*/ +/** + * @brief SV_Demo_Record_f + */ static void SV_Demo_Record_f(void) { // make sure server is running @@ -2016,11 +1978,9 @@ static void SV_Demo_Record_f(void) SV_DemoStartRecord(); } -/* -================= -SV_Demo_Play_f -================= -*/ +/** + * @brief SV_Demo_Play_f + */ static void SV_Demo_Play_f(void) { char *arg; @@ -2059,11 +2019,9 @@ static void SV_Demo_Play_f(void) SV_DemoStartPlayback(); } -/* -================= -SV_Demo_Stop_f -================= -*/ +/** + * @brief SV_Demo_Stop_f + */ static void SV_Demo_Stop_f(void) { if (sv.demoState == DS_NONE) @@ -2083,11 +2041,11 @@ static void SV_Demo_Stop_f(void) } } -/* -==================== -SV_CompleteDemoName -==================== -*/ +/** + * @brief SV_CompleteDemoName + * @param args - unused + * @param[in] argNum + */ static void SV_CompleteDemoName(char *args, int argNum) { if (argNum == 2) @@ -2099,6 +2057,9 @@ static void SV_CompleteDemoName(char *args, int argNum) } } +/** + * @brief SV_DemoInit + */ void SV_DemoInit(void) { Cmd_AddCommand("sv_record", SV_Demo_Record_f); diff --git a/src/server/sv_demo_ext.c b/src/server/sv_demo_ext.c index 77be44859..7ad11d62d 100644 --- a/src/server/sv_demo_ext.c +++ b/src/server/sv_demo_ext.c @@ -43,13 +43,11 @@ * Functions used to update some special aspects of the demo and which need to be separated from the main sv_demo.c file because of different includes that are necessary ***********************************************/ -/* -==================== -SV_GentityGetHealthField - -Get the value of the gentity_t->health field (only used for testing purposes) -==================== -*/ +/** + * @brief Get the value of the gentity_t->health field (only used for testing purposes) + * @param[in] gent + * @return + */ int SV_GentityGetHealthField(sharedEntity_t *gent) { gentity_t *ent = (gentity_t *)gent; @@ -58,13 +56,11 @@ int SV_GentityGetHealthField(sharedEntity_t *gent) return ent->health; } -/* -==================== -SV_GentitySetHealthField - -Set the value of the gentity_t->health field (only used for testing purposes) -==================== -*/ +/** + * @brief Set the value of the gentity_t->health field (only used for testing purposes) + * @param[out] gent + * @param[in] value + */ void SV_GentitySetHealthField(sharedEntity_t *gent, int value) { gentity_t *ent = (gentity_t *)gent; @@ -72,18 +68,32 @@ void SV_GentitySetHealthField(sharedEntity_t *gent, int value) ent->health = value; } -/* -==================== -SV_GentityUpdateHealthField - -Update the value of the gentity_t->health field with playerState_t->stats[STAT_HEALTH] for a given player -You need to supply the player's sharedEntity and playerState (because since we have special includes here, we don't have access to the functions that can return a player from their int id). -The concrete effect is that when replaying a demo, the players' health will be updated on the HUD (if it weren't for this function to update the health, the health wouldn't change and stay kinda static). - -Note: we need to do that because the demo can only records this stats[stat_health], which is concretely the same as gentity_t->health. The latter should have been removed altogether considering the comments in g_active.c (ent->client->ps.stats[STAT_HEALTH] = ent->health; // FIXME: get rid of ent->health...), but it seems to have survived because it allows non-player entities to have health, such as obelisks. And weirdly, gentity_t->health has ascendence over stat_health (meaning stat_health is updated following gentity_t->health, but never the other way around), when for example stat_armor has ascendence over anything else of the same kind, so here we have to update it by ourselves. -Note2: this works pretty simply: sharedEntity_t = gentity_t but with only the first 2 fields declared (entityShared_t and entityState_t), but all the other fields are still in memory! We only need to get a valid declaration for gentity_t (which we do by doing the right includes at the top of this file, in g_local.h), and then we can convert the limited sharedEntity_t into a gentity_t with all the fields! -==================== -*/ +/** + * @brief Update the value of the gentity_t->health field with playerState_t->stats[STAT_HEALTH] for a given player + * + * @details + * You need to supply the player's sharedEntity and playerState (because since we have special includes here, + * we don't have access to the functions that can return a player from their int id). + * + * The concrete effect is that when replaying a demo, + * the players' health will be updated on the HUD (if it weren't for this function to update the health, + * the health wouldn't change and stay kinda static). + * + * @param[out] gent + * @param[in] player + * + * @note 1. We need to do that because the demo can only records this stats[stat_health], which is concretely the same as gentity_t->health. + * The latter should have been removed altogether considering the comments in g_active.c : + * (ent->client->ps.stats[STAT_HEALTH] = ent->health; // FIXME: get rid of ent->health...), + * but it seems to have survived because it allows non-player entities to have health, such as obelisks. + * And weirdly, gentity_t->health has ascendence over stat_health (meaning stat_health is updated following gentity_t->health, but never the other way around), + * when for example stat_armor has ascendence over anything else of the same kind, so here we have to update it by ourselves. + * + * @note 2. This works pretty simply: sharedEntity_t = gentity_t but with only the first 2 fields declared (entityShared_t and entityState_t), + * but all the other fields are still in memory! + * We only need to get a valid declaration for gentity_t (which we do by doing the right includes at the top of this file, in g_local.h), + * and then we can convert the limited sharedEntity_t into a gentity_t with all the fields! + */ void SV_GentityUpdateHealthField(sharedEntity_t *gent, playerState_t *player) { gentity_t *ent = (gentity_t *)gent; // convert the sharedEntity_t to a gentity_t by using a simple cast (now that we have included g_local.h that contains the definition of gentity_t, and at the same time we have linked to g_public.h via g_local.h with the definition of sharedEntity_t) diff --git a/src/server/sv_game.c b/src/server/sv_game.c index e14a3dc0c..9a5603638 100644 --- a/src/server/sv_game.c +++ b/src/server/sv_game.c @@ -42,8 +42,16 @@ botlib_export_t *botlib_export; -// these functions must be used instead of pointer arithmetic, because -// the game allocates gentities with private information after the server shared part +/** +* @todo TODO: These functions must be used instead of pointer arithmetic, because +* the game allocates gentities with private information after the server shared part +*/ + +/** + * @brief SV_NumForGentity + * @param[in] ent + * @return + */ int SV_NumForGentity(sharedEntity_t *ent) { int num = ((byte *)ent - (byte *)sv.gentities) / sv.gentitySize; @@ -51,6 +59,11 @@ int SV_NumForGentity(sharedEntity_t *ent) return num; } +/** + * @brief SV_GentityNum + * @param[in] num + * @return + */ sharedEntity_t *SV_GentityNum(int num) { sharedEntity_t *ent = ( sharedEntity_t * )((byte *)sv.gentities + sv.gentitySize * (num)); @@ -58,6 +71,11 @@ sharedEntity_t *SV_GentityNum(int num) return ent; } +/** + * @brief SV_GameClientNum + * @param[in] num + * @return + */ playerState_t *SV_GameClientNum(int num) { playerState_t *ps = ( playerState_t * )((byte *)sv.gameClients + sv.gameClientSize * (num)); @@ -65,6 +83,11 @@ playerState_t *SV_GameClientNum(int num) return ps; } +/** + * @brief SV_SvEntityForGentity + * @param[in] gEnt + * @return + */ svEntity_t *SV_SvEntityForGentity(sharedEntity_t *gEnt) { if (!gEnt || gEnt->s.number < 0 || gEnt->s.number >= MAX_GENTITIES) @@ -74,6 +97,11 @@ svEntity_t *SV_SvEntityForGentity(sharedEntity_t *gEnt) return &sv.svEntities[gEnt->s.number]; } +/** + * @brief SV_GEntityForSvEntity + * @param[in] svEnt + * @return + */ sharedEntity_t *SV_GEntityForSvEntity(svEntity_t *svEnt) { int num = svEnt - sv.svEntities; @@ -81,13 +109,11 @@ sharedEntity_t *SV_GEntityForSvEntity(svEntity_t *svEnt) return SV_GentityNum(num); } -/* -=============== -SV_GameSendServerCommand - -Sends a command string to a client -=============== -*/ +/** + * @brief Sends a command string to a client + * @param[in] clientNum + * @param[in] text + */ void SV_GameSendServerCommand(int clientNum, const char *text) { // record the game server commands in demos @@ -115,13 +141,12 @@ void SV_GameSendServerCommand(int clientNum, const char *text) } } -/* -=============== -SV_GameDropClient - -Disconnects the client with a message -=============== -*/ +/** + * @brief Disconnects the client with a message + * @param[in] clientNum + * @param[in] reason + * @param[in] length + */ void SV_GameDropClient(int clientNum, const char *reason, int length) { if (clientNum < 0 || clientNum >= sv_maxclients->integer) @@ -135,13 +160,11 @@ void SV_GameDropClient(int clientNum, const char *reason, int length) } } -/* -================= -SV_SetBrushModel - -sets mins and maxs for inline bmodels -================= -*/ +/** + * @brief Sets mins and maxs for inline bmodels + * @param[in,out] ent + * @param[in] name + */ void SV_SetBrushModel(sharedEntity_t *ent, const char *name) { clipHandle_t h; @@ -170,13 +193,12 @@ void SV_SetBrushModel(sharedEntity_t *ent, const char *name) SV_LinkEntity(ent); // FIXME: remove } -/* -================= -SV_inPVS - -Also checks portalareas so that doors block sight -================= -*/ +/** + * @brief Also checks portalareas so that doors block sight + * @param[in] p1 + * @param[in] p2 + * @return + */ qboolean SV_inPVS(const vec3_t p1, const vec3_t p2) { int leafnum; @@ -204,13 +226,12 @@ qboolean SV_inPVS(const vec3_t p1, const vec3_t p2) return qtrue; } -/* -================= -SV_inPVSIgnorePortals - -Does NOT check portalareas -================= -*/ +/** + * @brief Does NOT check portalareas + * @param[in] p1 + * @param[in] p2 + * @return + */ qboolean SV_inPVSIgnorePortals(const vec3_t p1, const vec3_t p2) { int leafnum; @@ -232,11 +253,11 @@ qboolean SV_inPVSIgnorePortals(const vec3_t p1, const vec3_t p2) return qtrue; } -/* -======================== -SV_AdjustAreaPortalState -======================== -*/ +/** + * @brief SV_AdjustAreaPortalState + * @param[in] ent + * @param[in] open + */ void SV_AdjustAreaPortalState(sharedEntity_t *ent, qboolean open) { svEntity_t *svEnt = SV_SvEntityForGentity(ent); @@ -249,11 +270,14 @@ void SV_AdjustAreaPortalState(sharedEntity_t *ent, qboolean open) CM_AdjustAreaPortalState(svEnt->areanum, svEnt->areanum2, open); } -/* -================== -SV_EntityContact -================== -*/ +/** + * @brief SV_EntityContact + * @param[in] mins + * @param[in] maxs + * @param[in] gEnt + * @param[in] capsule + * @return + */ qboolean SV_EntityContact(const vec3_t mins, const vec3_t maxs, const sharedEntity_t *gEnt, const int capsule) { const float *origin = gEnt->r.currentOrigin; @@ -269,11 +293,11 @@ qboolean SV_EntityContact(const vec3_t mins, const vec3_t maxs, const sharedEnti return trace.startsolid; } -/* -=============== -SV_GetServerinfo -=============== -*/ +/** + * @brief SV_GetServerinfo + * @param[out] buffer + * @param[in] bufferSize + */ void SV_GetServerinfo(char *buffer, int bufferSize) { if (bufferSize < 1) @@ -283,11 +307,14 @@ void SV_GetServerinfo(char *buffer, int bufferSize) Q_strncpyz(buffer, Cvar_InfoString(CVAR_SERVERINFO | CVAR_SERVERINFO_NOUPDATE), bufferSize); } -/* -=============== -SV_LocateGameData -=============== -*/ +/** + * @brief SV_LocateGameData + * @param[in] gEnts + * @param[in] numGEntities + * @param[in] sizeofGEntity_t + * @param[in] clients + * @param[in] sizeofGameClient + */ void SV_LocateGameData(sharedEntity_t *gEnts, int numGEntities, int sizeofGEntity_t, playerState_t *clients, int sizeofGameClient) { @@ -299,11 +326,11 @@ void SV_LocateGameData(sharedEntity_t *gEnts, int numGEntities, int sizeofGEntit sv.gameClientSize = sizeofGameClient; } -/* -=============== -SV_GetUsercmd -=============== -*/ +/** + * @brief SV_GetUsercmd + * @param[in] clientNum + * @param[out] cmd + */ void SV_GetUsercmd(int clientNum, usercmd_t *cmd) { if (clientNum < 0 || clientNum >= sv_maxclients->integer) @@ -315,6 +342,9 @@ void SV_GetUsercmd(int clientNum, usercmd_t *cmd) /** * @brief SV_SendBinaryMessage + * @param[in] cno + * @param[out] buf + * @param[in] buflen * @return 1 if message is in queue - 0 not sent (since 2.76) */ static int SV_SendBinaryMessage(int cno, char *buf, int buflen) @@ -338,11 +368,11 @@ static int SV_SendBinaryMessage(int cno, char *buf, int buflen) return 1; } -/* -==================== -SV_BinaryMessageStatus -==================== -*/ +/** + * @brief SV_BinaryMessageStatus + * @param[in] cno + * @return + */ static int SV_BinaryMessageStatus(int cno) { if (cno < 0 || cno >= sv_maxclients->integer) @@ -363,11 +393,13 @@ static int SV_BinaryMessageStatus(int cno) return MESSAGE_WAITING; } -/* -==================== -SV_GameBinaryMessageReceived -==================== -*/ +/** + * @brief SV_GameBinaryMessageReceived + * @param[in] cno + * @param[in] buf + * @param[in] buflen + * @param[in] commandTime + */ void SV_GameBinaryMessageReceived(int cno, const char *buf, int buflen, int commandTime) { VM_Call(gvm, GAME_MESSAGERECEIVED, cno, buf, buflen, commandTime); @@ -375,6 +407,11 @@ void SV_GameBinaryMessageReceived(int cno, const char *buf, int buflen, int comm //============================================== +/** + * @brief FloatAsInt + * @param[in] f + * @return + */ static int FloatAsInt(float f) { floatint_t fi; @@ -383,17 +420,14 @@ static int FloatAsInt(float f) return fi.i; } -/* -==================== -SV_GameSystemCalls - -The module is making a system call -==================== -*/ - extern int S_RegisterSound(const char *name, qboolean compressed); extern int S_GetSoundLength(sfxHandle_t sfxHandle); +/** + * @brief The module is making a system call + * @param[in] args + * @return + */ intptr_t SV_GameSystemCalls(intptr_t *args) { switch (args[0]) @@ -649,13 +683,9 @@ intptr_t SV_GameSystemCalls(intptr_t *args) return -1; } -/* -=============== -SV_ShutdownGameProgs - -Called every time a map changes -=============== -*/ +/** + * @brief Called every time a map changes + */ void SV_ShutdownGameProgs(void) { if (!gvm) @@ -668,13 +698,10 @@ void SV_ShutdownGameProgs(void) gvm = NULL; } -/* -================== -SV_InitGameVM - -Called for both a full init and a restart -================== -*/ +/** + * @brief Called for both a full init and a restart + * @param[in] restart + */ static void SV_InitGameVM(qboolean restart) { int i; @@ -694,13 +721,9 @@ static void SV_InitGameVM(qboolean restart) VM_Call(gvm, GAME_INIT, svs.time, Com_Milliseconds(), restart, qtrue, ETLEGACY_VERSION_INT); } -/* -=================== -SV_RestartGameProgs - -Called on a map_restart, but not on a normal map change -=================== -*/ +/** + * @brief Called on a map_restart, but not on a normal map change + */ void SV_RestartGameProgs(void) { if (!gvm) @@ -723,13 +746,9 @@ void SV_RestartGameProgs(void) #endif } -/* -=============== -SV_InitGameProgs - -Called on a normal map change, not on a map_restart -=============== -*/ +/** + * @brief Called on a normal map change, not on a map_restart + */ void SV_InitGameProgs(void) { sv.num_tagheaders = 0; @@ -749,13 +768,10 @@ void SV_InitGameProgs(void) #endif } -/* -==================== -SV_GameCommand - -See if the current console command is claimed by the game -==================== -*/ +/** + * @brief See if the current console command is claimed by the game + * @return + */ qboolean SV_GameCommand(void) { if (sv.state != SS_GAME) @@ -767,6 +783,11 @@ qboolean SV_GameCommand(void) } /** + * @brief SV_GetTag + * @param[in] clientNum - unused + * @param[in] tagFileNumber + * @param[out] tagname + * @param[out] orientation * @return qfalse if unable to retrieve tag information for this client */ qboolean SV_GetTag(int clientNum, int tagFileNumber, char *tagname, orientation_t *orientation)