Skip to content

Commit

Permalink
general: fix gcc warnings
Browse files Browse the repository at this point in the history
* renderer: remove unused functions

* cgame: remove unused macros & variables

* cgame: fix unambiguous usage of && and || in conditional statement

* qcommon: exclude FS_AddPackToPath from dedicated server

* qcommon: ensure packName doesn't point to null terminator

This shouldn't ever happen anyway as you can't have an empty filename, but this would blow up if it somehow happened.

* game: remove unused variable

* server: remove unused variables

* tvgame: remove unused variables

Should clean up the entire LUA code from tvgame really as it's not used there.

* qcommon: remove unused function

* qcommon: replace deprecate cURL function

CURLOPT_PROGRESSDATA has been deprecated in favor of CURLOPT_XFERINFOFUNCTION, the functionality remains the same however.

* omni-bot: fix incorrect memset on non-trivial datatype

* client: fix redefinition of CMD_BACKUP, refs #2494

Flip-flop CMD_BACKUP/MASK_VET to CMD_BACKUP/MASK and add CMD_BACKUP/MASK_ETL with the increased size in order to avoid redefinition of CMD_BACKUP in server.h
  • Loading branch information
Aciz committed May 10, 2024
1 parent 6c052a6 commit 6cb533d
Show file tree
Hide file tree
Showing 23 changed files with 32 additions and 463 deletions.
2 changes: 1 addition & 1 deletion src/Omnibot/Common/BotLoadLibrary.cpp
Expand Up @@ -418,7 +418,7 @@ void KeyVals::Reset()
{
memset(m_Key, 0, sizeof(m_Key));
memset(m_String, 0, sizeof(m_String));
memset(m_Value, 0, sizeof(m_Value));
(*m_Value) = {};
}

/**
Expand Down
84 changes: 0 additions & 84 deletions src/cgame/cg_debriefing.c
Expand Up @@ -764,90 +764,6 @@ static panel_button_t *debriefPanelButtons[] =
NULL
};

static panel_button_text_t teamDebriefTitleSmall =
{
0.24f, 0.24f,
{ 1.f, 1.f, 1.f,0.8f },
0, ITEM_ALIGN_CENTER,
&cgs.media.limboFont2,
};

static panel_button_text_t teamDebriefTitle =
{
0.28f, 0.28f,
{ 1.f, 1.f, 1.f,0.8f },
0, 0,
&cgs.media.limboFont2,
};

#define TDB_SKILL_TITLES_XP(number, title, x) \
static panel_button_t teamDebriefSkillXPText_ ## number = { \
NULL, \
title, \
{ 100 + (number * 65), 304 - (x * 12), 20, 200 }, \
{ 0, 0, 0, 0, 0, 0, 0, 0}, \
&teamDebriefTitleSmall, /* font */ \
NULL, /* keyDown */ \
NULL, /* keyUp */ \
BG_PanelButtonsRender_Text, \
NULL, \
0, \
}

TDB_SKILL_TITLES_XP(0, "Battle Sense", 0);
TDB_SKILL_TITLES_XP(1, "Engineer", 1);
TDB_SKILL_TITLES_XP(2, "Medic", 0);
TDB_SKILL_TITLES_XP(3, "Field Ops", 1);
TDB_SKILL_TITLES_XP(4, "Light Weapons", 0);
TDB_SKILL_TITLES_XP(5, "Soldier", 1);
TDB_SKILL_TITLES_XP(6, "Covert Ops", 0);
TDB_SKILL_TITLES_XP(7, "Total", 1);

#define TDB_SKILL_AXIS_XP(number) \
static panel_button_t teamDebriefSkillXPText0_ ## number = { \
NULL, \
NULL, \
{ 110 + (number * 65), 320, 470, 200 }, \
{ 0, number, 0, 0, 0, 0, 0, 0}, \
&teamDebriefTitle, /* font */ \
NULL, /* keyDown */ \
NULL, /* keyUp */ \
CG_TeamDebriefingTeamSkillXP_Draw, \
NULL, \
0, \
}

#define TDB_SKILL_ALLIES_XP(number) \
static panel_button_t teamDebriefSkillXPText1_ ## number = { \
NULL, \
NULL, \
{ 110 + (number * 65), 340, 470, 200 }, \
{ 1, number, 0, 0, 0, 0, 0, 0}, \
&teamDebriefTitle, /* font */ \
NULL, /* keyDown */ \
NULL, /* keyUp */ \
CG_TeamDebriefingTeamSkillXP_Draw, \
NULL, \
0, \
}

TDB_SKILL_AXIS_XP(0);
TDB_SKILL_AXIS_XP(1);
TDB_SKILL_AXIS_XP(2);
TDB_SKILL_AXIS_XP(3);
TDB_SKILL_AXIS_XP(4);
TDB_SKILL_AXIS_XP(5);
TDB_SKILL_AXIS_XP(6);
TDB_SKILL_AXIS_XP(7);

TDB_SKILL_ALLIES_XP(0);
TDB_SKILL_ALLIES_XP(1);
TDB_SKILL_ALLIES_XP(2);
TDB_SKILL_ALLIES_XP(3);
TDB_SKILL_ALLIES_XP(4);
TDB_SKILL_ALLIES_XP(5);
TDB_SKILL_ALLIES_XP(6);
TDB_SKILL_ALLIES_XP(7);

static panel_button_t *teamDebriefPanelButtons[] =
{
Expand Down
4 changes: 2 additions & 2 deletions src/cgame/cg_draw_hud.c
Expand Up @@ -2518,8 +2518,8 @@ void CG_DrawNewCompass(hudComponent_t *comp)
else
{
if (cg.time - cgs.autoMapExpandTime <= 150.f * expandedMapFrac
|| cg.time - cgs.autoMapExpandTime <= 250.f * expandedMapFrac
&& cgs.clientinfo[cg.clientNum].team == TEAM_SPECTATOR)
|| (cg.time - cgs.autoMapExpandTime <= 250.f * expandedMapFrac
&& cgs.clientinfo[cg.clientNum].team == TEAM_SPECTATOR))
{
CG_DrawExpandedAutoMap();

Expand Down
6 changes: 2 additions & 4 deletions src/cgame/cg_hud_editor.c
Expand Up @@ -780,8 +780,6 @@ qboolean CG_HudSave(int HUDToDuplicate, int HUDToDelete)
{
while ((hud = CG_GetHudByNumber(HUDToDelete)))
{
int i;

// ensure to update parent as well
CG_UpdateParentHUD(hud->name, hud->parent, hud->hudnumber);

Expand Down Expand Up @@ -2693,8 +2691,8 @@ void CG_DrawHudEditor(void)
{
break;
}
if ((comp->visible || showLayout == HUD_SHOW_LAYOUT_ALL) && BG_CursorInRect(&button->rect))

if ((comp->visible || showLayout == HUD_SHOW_LAYOUT_ALL) && BG_CursorInRect(&button->rect))
{
CG_DrawHudEditor_ToolTip(button);
break;
Expand Down
2 changes: 1 addition & 1 deletion src/cgame/cg_local.h
Expand Up @@ -1119,7 +1119,7 @@ void CG_ParseMapEntityInfo(int axis_number, int allied_number);
#define MAX_WEAPS_IN_BANK_MP 18
#define MAX_WEAP_BANK_SWITCH_ORDER 4

#define MAX_BACKUP_STATES (CMD_BACKUP + 2)
#define MAX_BACKUP_STATES (CMD_BACKUP_ETL + 2)

/**
* @struct cg_t
Expand Down
2 changes: 1 addition & 1 deletion src/cgame/cg_predict.c
Expand Up @@ -931,7 +931,7 @@ int CG_PredictionOk(playerState_t *ps1, playerState_t *ps2)
* appear to be set for prediction runs where they previously weren't
* is a Bad Thing. This is my bugfix for #166.
*/
pmoveExt_t oldpmext[CMD_BACKUP];
pmoveExt_t oldpmext[CMD_BACKUP_ETL];

const char *predictionStrings[] =
{
Expand Down
8 changes: 4 additions & 4 deletions src/cgame/cg_public.h
Expand Up @@ -38,11 +38,11 @@
/// Allow a lot of command backups for very fast systems
/// multiple commands may be combined into a single packet, so this
/// needs to be larger than PACKET_BACKUP
#define CMD_BACKUP 128
#define CMD_MASK (CMD_BACKUP - 1)
#define CMD_BACKUP_ETL 128
#define CMD_MASK_ETL (CMD_BACKUP_ETL - 1)

#define CMD_BACKUP_VET 64
#define CMD_MASK_VET (CMD_BACKUP_VET - 1)
#define CMD_BACKUP 64
#define CMD_MASK (CMD_BACKUP - 1)

#define MAX_ENTITIES_IN_SNAPSHOT 512

Expand Down
8 changes: 4 additions & 4 deletions src/cgame/cg_syscalls.c
Expand Up @@ -1962,13 +1962,13 @@ void trap_CmdBackup_Ext(void)
{
if (dll_trap_CmdBackup_Ext)
{
cg.cmdBackup = CMD_BACKUP;
cg.cmdMask = CMD_MASK;
cg.cmdBackup = CMD_BACKUP_ETL;
cg.cmdMask = CMD_MASK_ETL;
SystemCall(dll_trap_CmdBackup_Ext);
}
else
{
cg.cmdBackup = CMD_BACKUP_VET;
cg.cmdMask = CMD_MASK_VET;
cg.cmdBackup = CMD_BACKUP;
cg.cmdMask = CMD_MASK;
}
}
14 changes: 7 additions & 7 deletions src/client/cl_cgame.c
Expand Up @@ -1070,8 +1070,8 @@ intptr_t CL_CgameSystemCalls(intptr_t *args)
return 0;

case CG_CMDBACKUP_EXT:
cl.cmdBackup = CMD_BACKUP;
cl.cmdMask = CMD_MASK;
cl.cmdBackup = CMD_BACKUP_ETL;
cl.cmdMask = CMD_MASK_ETL;
return 0;

default:
Expand Down Expand Up @@ -1692,10 +1692,10 @@ void CL_SetCGameTime(void)
*/
qboolean CL_GetTag(int clientNum, char *tagname, orientation_t *orientation)
{
if (!cgvm)
{
return qfalse;
}
if (!cgvm)
{
return qfalse;
}

return VM_Call(cgvm, CG_GET_TAG, clientNum, tagname, orientation);
return VM_Call(cgvm, CG_GET_TAG, clientNum, tagname, orientation);
}
4 changes: 2 additions & 2 deletions src/client/cl_main.c
Expand Up @@ -609,8 +609,8 @@ void CL_ClearState(void)
{
Com_Memset(&cl, 0, sizeof(cl));

cl.cmdBackup = CMD_BACKUP_VET;
cl.cmdMask = CMD_MASK_VET;
cl.cmdBackup = CMD_BACKUP;
cl.cmdMask = CMD_MASK;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/client/client.h
Expand Up @@ -154,7 +154,7 @@ typedef struct

/// cmds[cmdNumber] is the predicted command, [cmdNumber-1] is the last
/// properly generated command
usercmd_t cmds[CMD_BACKUP]; ///< each mesage will send several old cmds
usercmd_t cmds[CMD_BACKUP_ETL]; ///< each mesage will send several old cmds
int cmdNumber; ///< incremented each frame, because multiple
///< frames may need to be packed into a single packet
int cmdBackup; ///< CMD_BACKUP
Expand Down
1 change: 0 additions & 1 deletion src/game/g_cmds.c
Expand Up @@ -2851,7 +2851,6 @@ void G_Say_f(gentity_t *ent, int mode /*, qboolean arg0*/)
*/
void G_VoiceTo(gentity_t *ent, gentity_t *other, int mode, const char *id, qboolean voiceonly, float randomNum, int vsayNum, const char *customChat)
{
int color;
char *cmd;

if (!other)
Expand Down
4 changes: 2 additions & 2 deletions src/qcommon/dl_main_curl.c
Expand Up @@ -569,7 +569,7 @@ unsigned int DL_BeginDownload(const char *localName, const char *remoteName, voi
ETL_curl_easy_setopt(status, request->rawHandle, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
ETL_curl_easy_setopt(status, request->rawHandle, CURLOPT_WRITEFUNCTION, DL_cb_FWriteFile);
ETL_curl_easy_setopt(status, request->rawHandle, CURLOPT_WRITEDATA, (void *)request);
ETL_curl_easy_setopt(status, request->rawHandle, CURLOPT_PROGRESSFUNCTION, DL_cb_Progress);
ETL_curl_easy_setopt(status, request->rawHandle, CURLOPT_XFERINFOFUNCTION, DL_cb_Progress);
ETL_curl_easy_setopt(status, request->rawHandle, CURLOPT_PROGRESSDATA, (void *)request);
ETL_curl_easy_setopt(status, request->rawHandle, CURLOPT_NOPROGRESS, 0);
ETL_curl_easy_setopt(status, request->rawHandle, CURLOPT_FAILONERROR, 1);
Expand Down Expand Up @@ -649,7 +649,7 @@ unsigned int Web_CreateRequest(const char *url, const char *authToken, webUpload
ETL_curl_easy_setopt(status, request->rawHandle, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
ETL_curl_easy_setopt(status, request->rawHandle, CURLOPT_WRITEFUNCTION, DL_write_function);
ETL_curl_easy_setopt(status, request->rawHandle, CURLOPT_WRITEDATA, (void *)request);
ETL_curl_easy_setopt(status, request->rawHandle, CURLOPT_PROGRESSFUNCTION, DL_cb_Progress);
ETL_curl_easy_setopt(status, request->rawHandle, CURLOPT_XFERINFOFUNCTION, DL_cb_Progress);
ETL_curl_easy_setopt(status, request->rawHandle, CURLOPT_PROGRESSDATA, (void *)request);
ETL_curl_easy_setopt(status, request->rawHandle, CURLOPT_FORBID_REUSE, 1L);

Expand Down
26 changes: 0 additions & 26 deletions src/qcommon/download.c
Expand Up @@ -526,31 +526,6 @@ qboolean Com_WWWBadChecksum(const char *pakname)
return qfalse;
}

/**
* @brief Com_SetupDownloadRaw
* @param[in] remote
* @param[in] filename
*/
static void Com_SetupDownloadRaw(const char *remote, const char *path, const char *filename, const char *tempName, qboolean systemDownload, qboolean noReconnect)
{
dld.bWWWDl = qtrue;
dld.bWWWDlDisconnected = qtrue;
dld.systemDownload = systemDownload;
dld.noReconnect = noReconnect;

// download format: @remotename@localname
Q_strncpyz(dld.downloadList, va("@%s@%s", filename, filename), MAX_INFO_STRING);
Q_strncpyz(dld.originalDownloadName, path[0] ? va("%s/%s", path, filename) : filename, sizeof(dld.originalDownloadName));
Q_strncpyz(dld.downloadName, va("%s/%s", remote, filename), sizeof(dld.downloadName));
Q_strncpyz(dld.downloadTempName, tempName, sizeof(dld.downloadTempName));

if (!Com_BeginWebDownload(dld.downloadTempName, dld.downloadName))
{
dld.bWWWDlAborting = qtrue;
Com_Error(ERR_DROP, "Could not download file: \"%s\"", dld.downloadName);
}
}

/**
* @brief Com_SetupDownload
* @param[in] remote
Expand Down Expand Up @@ -644,7 +619,6 @@ void Com_CheckCaCertStatus(void)

if (downloadFile)
{
// Com_SetupDownloadRaw(MIRROR_SERVER_URL "/certificates", "", CA_CERT_FILE, CA_CERT_FILE TMP_FILE_EXTENSION, qtrue, qtrue);
Com_DownloadFileSimple(ospath, MIRROR_SERVER_URL "/certificates/" CA_CERT_FILE);
}
#else
Expand Down
4 changes: 3 additions & 1 deletion src/qcommon/files.c
Expand Up @@ -3740,6 +3740,7 @@ void FS_Which_f(void)

//===========================================================================

#if !defined(DEDICATED)
/**
* @brief FS_AddPackToPath add a single package to the search path
* @param osPath full os path to the pk3 file
Expand All @@ -3765,6 +3766,7 @@ static void FS_AddPackToPath(const char *osPath, const char *gameName)
search->next = fs_searchpaths;
fs_searchpaths = search;
}
#endif

/**
* @brief paksort
Expand Down Expand Up @@ -4390,7 +4392,7 @@ static void FS_AddContainerDirectory(const char *subPath)
}

char *packName = strchr(fs_serverReferencedPakNames[i], '/');
if (packName && (packName + 1))
if (packName && *(packName + 1))
{
char tmpPath[MAX_OSPATH] = { '\0' };
char const *path = FS_BuildOSPath(fs_homepath->string, subPath, va("%s%c%s.pk3", FS_CONTAINER, PATH_SEP, packName + 1));
Expand Down

0 comments on commit 6cb533d

Please sign in to comment.