From 02e6784111e3266ad0dca3e8a174a6552857bfd2 Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Sat, 21 Dec 2024 12:43:37 +0200 Subject: [PATCH 1/3] renders: make pic name const --- src/client/menu/menu.c | 14 +++++++------ src/client/refresh/gl1/gl1_draw.c | 10 ++++----- src/client/refresh/gl1/gl1_image.c | 2 +- src/client/refresh/gl1/gl1_main.c | 4 ++-- src/client/refresh/gl1/gl1_warp.c | 2 +- src/client/refresh/gl1/header/local.h | 10 ++++----- src/client/refresh/gl3/gl3_draw.c | 10 ++++----- src/client/refresh/gl3/gl3_image.c | 2 +- src/client/refresh/gl3/gl3_warp.c | 2 +- src/client/refresh/gl3/header/local.h | 14 ++++++------- src/client/refresh/soft/header/local.h | 10 ++++----- src/client/refresh/soft/sw_draw.c | 10 ++++----- src/client/refresh/soft/sw_main.c | 4 ++-- src/client/vid/header/ref.h | 28 +++++++++++++------------- src/client/vid/vid.c | 14 ++++++------- 15 files changed, 69 insertions(+), 67 deletions(-) diff --git a/src/client/menu/menu.c b/src/client/menu/menu.c index f059162db..82fa98440 100644 --- a/src/client/menu/menu.c +++ b/src/client/menu/menu.c @@ -99,7 +99,7 @@ M_IsGame(const char *gamename) } static void -M_Banner(char *name) +M_Banner(const char *name) { int w, h; float scale = SCR_GetMenuScale(); @@ -753,7 +753,7 @@ M_Main_Draw(void) ( int )(cls.realtime / 100) % NUM_CURSOR_FRAMES); } -const char * +static const char * M_Main_Key(int key) { return Default_MenuKey(&s_main, key); @@ -1545,7 +1545,7 @@ DrawControllerAltButtonBindingFunc(void *self) } else { - int x; + size_t x; const char *name; name = Key_KeynumToString(keys[0]); @@ -5277,7 +5277,7 @@ AddressBook_MenuInit(void) } } -const char * +static const char * AddressBook_MenuKey(int key) { if (key == K_ESCAPE) @@ -5684,7 +5684,8 @@ HasSkinsInDir(const char *dirname, int *num) { char **list_png, **list_pcx; char **curr = NULL, **list = NULL; - int num_png, num_pcx, dirname_size; + int num_png, num_pcx; + size_t dirname_size; *num = 0; /* dir name size plus one for skip slash */ @@ -5934,7 +5935,8 @@ PlayerConfig_ScanDirectories(void) return result; } -void ListModels_f(void) +static void +ListModels_f(void) { PlayerConfig_ScanDirectories(); diff --git a/src/client/refresh/gl1/gl1_draw.c b/src/client/refresh/gl1/gl1_draw.c index 6fe553daf..2fe016cfb 100644 --- a/src/client/refresh/gl1/gl1_draw.c +++ b/src/client/refresh/gl1/gl1_draw.c @@ -84,13 +84,13 @@ RDraw_CharScaled(int x, int y, int num, float scale) } image_t * -RDraw_FindPic(char *name) +RDraw_FindPic(const char *name) { return R_FindPic(name, (findimage_t)R_FindImage); } void -RDraw_GetPicSize(int *w, int *h, char *pic) +RDraw_GetPicSize(int *w, int *h, const char *pic) { image_t *gl; @@ -107,7 +107,7 @@ RDraw_GetPicSize(int *w, int *h, char *pic) } void -RDraw_StretchPic(int x, int y, int w, int h, char *pic) +RDraw_StretchPic(int x, int y, int w, int h, const char *pic) { image_t *gl; @@ -152,7 +152,7 @@ RDraw_StretchPic(int x, int y, int w, int h, char *pic) } void -RDraw_PicScaled(int x, int y, char *pic, float factor) +RDraw_PicScaled(int x, int y, const char *pic, float factor) { image_t *gl; @@ -210,7 +210,7 @@ RDraw_PicScaled(int x, int y, char *pic, float factor) * refresh window. */ void -RDraw_TileClear(int x, int y, int w, int h, char *pic) +RDraw_TileClear(int x, int y, int w, int h, const char *pic) { image_t *image; diff --git a/src/client/refresh/gl1/gl1_image.c b/src/client/refresh/gl1/gl1_image.c index e69ef39f6..00761e70c 100644 --- a/src/client/refresh/gl1/gl1_image.c +++ b/src/client/refresh/gl1/gl1_image.c @@ -1185,7 +1185,7 @@ R_FindImage(const char *name, imagetype_t type) } struct image_s * -RI_RegisterSkin(char *name) +RI_RegisterSkin(const char *name) { return R_FindImage(name, it_skin); } diff --git a/src/client/refresh/gl1/gl1_main.c b/src/client/refresh/gl1/gl1_main.c index c931f7e8a..82c8c333a 100644 --- a/src/client/refresh/gl1/gl1_main.c +++ b/src/client/refresh/gl1/gl1_main.c @@ -2105,9 +2105,9 @@ extern int RI_InitContext(void* win); extern void RI_BeginRegistration(char *model); extern struct model_s * RI_RegisterModel(char *name); -extern struct image_s * RI_RegisterSkin(char *name); +extern struct image_s * RI_RegisterSkin(const char *name); -extern void RI_SetSky(char *name, float rotate, vec3_t axis); +extern void RI_SetSky(const char *name, float rotate, vec3_t axis); extern void RI_EndRegistration(void); extern void RI_RenderFrame(refdef_t *fd); diff --git a/src/client/refresh/gl1/gl1_warp.c b/src/client/refresh/gl1/gl1_warp.c index b36be0c69..7975a7d6a 100644 --- a/src/client/refresh/gl1/gl1_warp.c +++ b/src/client/refresh/gl1/gl1_warp.c @@ -708,7 +708,7 @@ R_DrawSkyBox(void) } void -RI_SetSky(char *name, float rotate, vec3_t axis) +RI_SetSky(const char *name, float rotate, vec3_t axis) { char skyname[MAX_QPATH]; int i; diff --git a/src/client/refresh/gl1/header/local.h b/src/client/refresh/gl1/header/local.h index 4e3a8dace..b37166e15 100644 --- a/src/client/refresh/gl1/header/local.h +++ b/src/client/refresh/gl1/header/local.h @@ -508,12 +508,12 @@ void RI_GetDrawableSize(int* width, int* height); int RI_GetSDLVersion(); /* g11_draw */ -extern image_t * RDraw_FindPic(char *name); -extern void RDraw_GetPicSize(int *w, int *h, char *pic); -extern void RDraw_PicScaled(int x, int y, char *pic, float factor); -extern void RDraw_StretchPic(int x, int y, int w, int h, char *pic); +extern image_t * RDraw_FindPic(const char *name); +extern void RDraw_GetPicSize(int *w, int *h, const char *pic); +extern void RDraw_PicScaled(int x, int y, const char *pic, float factor); +extern void RDraw_StretchPic(int x, int y, int w, int h, const char *pic); extern void RDraw_CharScaled(int x, int y, int num, float scale); -extern void RDraw_TileClear(int x, int y, int w, int h, char *pic); +extern void RDraw_TileClear(int x, int y, int w, int h, const char *pic); extern void RDraw_Fill(int x, int y, int w, int h, int c); extern void RDraw_FadeScreen(void); extern void RDraw_StretchRaw(int x, int y, int w, int h, int cols, int rows, const byte *data, int bits); diff --git a/src/client/refresh/gl3/gl3_draw.c b/src/client/refresh/gl3/gl3_draw.c index 0897180e6..721ffd69a 100644 --- a/src/client/refresh/gl3/gl3_draw.c +++ b/src/client/refresh/gl3/gl3_draw.c @@ -161,13 +161,13 @@ GL3_Draw_CharScaled(int x, int y, int num, float scale) } gl3image_t * -GL3_Draw_FindPic(char *name) +GL3_Draw_FindPic(const char *name) { return R_FindPic(name, (findimage_t)GL3_FindImage); } void -GL3_Draw_GetPicSize(int *w, int *h, char *pic) +GL3_Draw_GetPicSize(int *w, int *h, const char *pic) { gl3image_t *gl; @@ -184,7 +184,7 @@ GL3_Draw_GetPicSize(int *w, int *h, char *pic) } void -GL3_Draw_StretchPic(int x, int y, int w, int h, char *pic) +GL3_Draw_StretchPic(int x, int y, int w, int h, const char *pic) { gl3image_t *gl = R_FindPic(pic, (findimage_t)GL3_FindImage); @@ -201,7 +201,7 @@ GL3_Draw_StretchPic(int x, int y, int w, int h, char *pic) } void -GL3_Draw_PicScaled(int x, int y, char *pic, float factor) +GL3_Draw_PicScaled(int x, int y, const char *pic, float factor) { gl3image_t *gl = R_FindPic(pic, (findimage_t)GL3_FindImage); if (!gl) @@ -222,7 +222,7 @@ GL3_Draw_PicScaled(int x, int y, char *pic, float factor) * refresh window. */ void -GL3_Draw_TileClear(int x, int y, int w, int h, char *pic) +GL3_Draw_TileClear(int x, int y, int w, int h, const char *pic) { gl3image_t *image = R_FindPic(pic, (findimage_t)GL3_FindImage); if (!image) diff --git a/src/client/refresh/gl3/gl3_image.c b/src/client/refresh/gl3/gl3_image.c index 7e4656482..dc5c95e95 100644 --- a/src/client/refresh/gl3/gl3_image.c +++ b/src/client/refresh/gl3/gl3_image.c @@ -664,7 +664,7 @@ GL3_FindImage(const char *name, imagetype_t type) } gl3image_t * -GL3_RegisterSkin(char *name) +GL3_RegisterSkin(const char *name) { return GL3_FindImage(name, it_skin); } diff --git a/src/client/refresh/gl3/gl3_warp.c b/src/client/refresh/gl3/gl3_warp.c index d0eaf2818..1343fc1c5 100644 --- a/src/client/refresh/gl3/gl3_warp.c +++ b/src/client/refresh/gl3/gl3_warp.c @@ -327,7 +327,7 @@ int vec_to_st[6][3] = { void -GL3_SetSky(char *name, float rotate, vec3_t axis) +GL3_SetSky(const char *name, float rotate, vec3_t axis) { char skyname[MAX_QPATH]; int i; diff --git a/src/client/refresh/gl3/header/local.h b/src/client/refresh/gl3/header/local.h index 456ffe715..ea9e7a88f 100644 --- a/src/client/refresh/gl3/header/local.h +++ b/src/client/refresh/gl3/header/local.h @@ -414,13 +414,13 @@ extern const byte* GL3_Mod_ClusterPVS(int cluster, const gl3model_t *model); // gl3_draw.c extern void GL3_Draw_InitLocal(void); extern void GL3_Draw_ShutdownLocal(void); -extern gl3image_t * GL3_Draw_FindPic(char *name); -extern void GL3_Draw_GetPicSize(int *w, int *h, char *pic); +extern gl3image_t * GL3_Draw_FindPic(const char *name); +extern void GL3_Draw_GetPicSize(int *w, int *h, const char *pic); -extern void GL3_Draw_PicScaled(int x, int y, char *pic, float factor); -extern void GL3_Draw_StretchPic(int x, int y, int w, int h, char *pic); +extern void GL3_Draw_PicScaled(int x, int y, const char *pic, float factor); +extern void GL3_Draw_StretchPic(int x, int y, int w, int h, const char *pic); extern void GL3_Draw_CharScaled(int x, int y, int num, float scale); -extern void GL3_Draw_TileClear(int x, int y, int w, int h, char *pic); +extern void GL3_Draw_TileClear(int x, int y, int w, int h, const char *pic); extern void GL3_DrawFrameBufferObject(int x, int y, int w, int h, GLuint fboTexture, const float v_blend[4]); extern void GL3_Draw_Fill(int x, int y, int w, int h, int c); extern void GL3_Draw_FadeScreen(void); @@ -446,7 +446,7 @@ extern gl3image_t *GL3_LoadPic(char *name, byte *pic, int width, int realwidth, int height, int realheight, size_t data_size, imagetype_t type, int bits); extern gl3image_t *GL3_FindImage(const char *name, imagetype_t type); -extern gl3image_t *GL3_RegisterSkin(char *name); +extern gl3image_t *GL3_RegisterSkin(const char *name); extern void GL3_ShutdownImages(void); extern void GL3_FreeUnusedImages(void); extern qboolean GL3_ImageHasFreeSpace(void); @@ -475,7 +475,7 @@ extern void GL3_LM_EndBuildingLightmaps(void); extern void GL3_EmitWaterPolys(msurface_t *fa); extern void GL3_SubdivideSurface(msurface_t *fa, gl3model_t* loadmodel); -extern void GL3_SetSky(char *name, float rotate, vec3_t axis); +extern void GL3_SetSky(const char *name, float rotate, vec3_t axis); extern void GL3_DrawSkyBox(void); extern void GL3_ClearSkyBox(void); extern void GL3_AddSkySurface(msurface_t *fa); diff --git a/src/client/refresh/soft/header/local.h b/src/client/refresh/soft/header/local.h index 0df50bc3a..af1b2107d 100644 --- a/src/client/refresh/soft/header/local.h +++ b/src/client/refresh/soft/header/local.h @@ -577,14 +577,14 @@ void RE_BeginRegistration (char *model); struct model_s *RE_RegisterModel (char *name); void RE_EndRegistration (void); -struct image_s *RE_Draw_FindPic (char *name); +struct image_s *RE_Draw_FindPic (const char *name); -void RE_Draw_GetPicSize (int *w, int *h, char *name); -void RE_Draw_PicScaled (int x, int y, char *name, float scale); -void RE_Draw_StretchPic (int x, int y, int w, int h, char *name); +void RE_Draw_GetPicSize (int *w, int *h, const char *name); +void RE_Draw_PicScaled (int x, int y, const char *name, float scale); +void RE_Draw_StretchPic (int x, int y, int w, int h, const char *name); void RE_Draw_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte *data, int bits); void RE_Draw_CharScaled (int x, int y, int c, float scale); -void RE_Draw_TileClear (int x, int y, int w, int h, char *name); +void RE_Draw_TileClear (int x, int y, int w, int h, const char *name); void RE_Draw_Fill (int x, int y, int w, int h, int c); void RE_Draw_FadeScreen (void); diff --git a/src/client/refresh/soft/sw_draw.c b/src/client/refresh/soft/sw_draw.c index fca363beb..8ecc74f55 100644 --- a/src/client/refresh/soft/sw_draw.c +++ b/src/client/refresh/soft/sw_draw.c @@ -33,7 +33,7 @@ RE_Draw_FindPic ================ */ image_t * -RE_Draw_FindPic (char *name) +RE_Draw_FindPic (const char *name) { return R_FindPic(name, (findimage_t)R_FindImage); } @@ -144,7 +144,7 @@ RE_Draw_GetPicSize ============= */ void -RE_Draw_GetPicSize (int *w, int *h, char *name) +RE_Draw_GetPicSize (int *w, int *h, const char *name) { image_t *image; @@ -302,7 +302,7 @@ RE_Draw_StretchPic ============= */ void -RE_Draw_StretchPic (int x, int y, int w, int h, char *name) +RE_Draw_StretchPic (int x, int y, int w, int h, const char *name) { image_t *pic; @@ -380,7 +380,7 @@ Draw_Pic ============= */ void -RE_Draw_PicScaled(int x, int y, char *name, float scale) +RE_Draw_PicScaled(int x, int y, const char *name, float scale) { image_t *pic; @@ -406,7 +406,7 @@ refresh window. ============= */ void -RE_Draw_TileClear (int x, int y, int w, int h, char *name) +RE_Draw_TileClear (int x, int y, int w, int h, const char *name) { int i, j; byte *psrc; diff --git a/src/client/refresh/soft/sw_main.c b/src/client/refresh/soft/sw_main.c index c9d51b75e..55f7d39ae 100644 --- a/src/client/refresh/soft/sw_main.c +++ b/src/client/refresh/soft/sw_main.c @@ -1726,7 +1726,7 @@ static const int r_skysideimage[6] = {5, 2, 4, 1, 0, 3}; extern mtexinfo_t r_skytexinfo[6]; static void -RE_SetSky (char *name, float rotate, vec3_t axis) +RE_SetSky (const char *name, float rotate, vec3_t axis) { char skyname[MAX_QPATH]; int i; @@ -1758,7 +1758,7 @@ RE_RegisterSkin =============== */ static struct image_s * -RE_RegisterSkin (char *name) +RE_RegisterSkin (const char *name) { return R_FindImage (name, it_skin); } diff --git a/src/client/vid/header/ref.h b/src/client/vid/header/ref.h index 4f5c75316..1973a325f 100644 --- a/src/client/vid/header/ref.h +++ b/src/client/vid/header/ref.h @@ -185,20 +185,20 @@ typedef struct // slash will not use the "pics/" prefix or the ".pcx" postfix) void (EXPORT *BeginRegistration) (char *map); struct model_s * (EXPORT *RegisterModel) (char *name); - struct image_s * (EXPORT *RegisterSkin) (char *name); + struct image_s * (EXPORT *RegisterSkin) (const char *name); - void (EXPORT *SetSky) (char *name, float rotate, vec3_t axis); + void (EXPORT *SetSky) (const char *name, float rotate, vec3_t axis); void (EXPORT *EndRegistration) (void); void (EXPORT *RenderFrame) (refdef_t *fd); - struct image_s * (EXPORT *DrawFindPic)(char *name); + struct image_s * (EXPORT *DrawFindPic)(const char *name); - void (EXPORT *DrawGetPicSize) (int *w, int *h, char *name); // will return 0 0 if not found - void (EXPORT *DrawPicScaled) (int x, int y, char *pic, float factor); - void (EXPORT *DrawStretchPic) (int x, int y, int w, int h, char *name); + void (EXPORT *DrawGetPicSize) (int *w, int *h, const char *name); // will return 0 0 if not found + void (EXPORT *DrawPicScaled) (int x, int y, const char *pic, float factor); + void (EXPORT *DrawStretchPic) (int x, int y, int w, int h, const char *name); void (EXPORT *DrawCharScaled)(int x, int y, int num, float scale); - void (EXPORT *DrawTileClear) (int x, int y, int w, int h, char *name); + void (EXPORT *DrawTileClear) (int x, int y, int w, int h, const char *name); void (EXPORT *DrawFill) (int x, int y, int w, int h, int c); void (EXPORT *DrawFadeScreen) (void); @@ -272,18 +272,18 @@ extern refimport_t ri; void R_BeginRegistration(char *map); void R_Clear(void); struct model_s *R_RegisterModel(char *name); -struct image_s *R_RegisterSkin(char *name); -void R_SetSky(char *name, float rotate, vec3_t axis); +struct image_s *R_RegisterSkin(const char *name); +void R_SetSky(const char *name, float rotate, vec3_t axis); void R_EndRegistration(void); -struct image_s *Draw_FindPic(char *name); +struct image_s *Draw_FindPic(const char *name); void R_RenderFrame(refdef_t *fd); -void Draw_GetPicSize(int *w, int *h, char *name); +void Draw_GetPicSize(int *w, int *h, const char *name); -void Draw_StretchPic(int x, int y, int w, int h, char *name); -void Draw_PicScaled(int x, int y, char *pic, float factor); +void Draw_StretchPic(int x, int y, int w, int h, const char *name); +void Draw_PicScaled(int x, int y, const char *pic, float factor); void Draw_CharScaled(int x, int y, int num, float scale); -void Draw_TileClear(int x, int y, int w, int h, char *name); +void Draw_TileClear(int x, int y, int w, int h, const char *name); void Draw_Fill(int x, int y, int w, int h, int c); void Draw_FadeScreen(void); void Draw_StretchRaw(int x, int y, int w, int h, int cols, int rows, const byte *data, int bits); diff --git a/src/client/vid/vid.c b/src/client/vid/vid.c index 186b0d3f9..f980d5ad8 100644 --- a/src/client/vid/vid.c +++ b/src/client/vid/vid.c @@ -642,7 +642,7 @@ R_RegisterModel(char *name) } struct image_s* -R_RegisterSkin(char *name) +R_RegisterSkin(const char *name) { if (ref_active) { @@ -653,7 +653,7 @@ R_RegisterSkin(char *name) } void -R_SetSky(char *name, float rotate, vec3_t axis) +R_SetSky(const char *name, float rotate, vec3_t axis) { if (ref_active) { @@ -680,7 +680,7 @@ R_RenderFrame(refdef_t *fd) } struct image_s* -Draw_FindPic(char *name) +Draw_FindPic(const char *name) { if (ref_active) { @@ -692,7 +692,7 @@ Draw_FindPic(char *name) void -Draw_GetPicSize(int *w, int *h, char *name) +Draw_GetPicSize(int *w, int *h, const char *name) { if (ref_active) { @@ -701,7 +701,7 @@ Draw_GetPicSize(int *w, int *h, char *name) } void -Draw_StretchPic(int x, int y, int w, int h, char *name) +Draw_StretchPic(int x, int y, int w, int h, const char *name) { if (ref_active) { @@ -710,7 +710,7 @@ Draw_StretchPic(int x, int y, int w, int h, char *name) } void -Draw_PicScaled(int x, int y, char *pic, float factor) +Draw_PicScaled(int x, int y, const char *pic, float factor) { if (ref_active) { @@ -728,7 +728,7 @@ Draw_CharScaled(int x, int y, int num, float scale) } void -Draw_TileClear(int x, int y, int w, int h, char *name) +Draw_TileClear(int x, int y, int w, int h, const char *name) { if (ref_active) { From f70ec69470a06929143b85aefaef94dc772bceb8 Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Sat, 21 Dec 2024 13:50:03 +0200 Subject: [PATCH 2/3] hide local functions under static Also apply recomentadion of msvc for use size_t with strlen. --- src/backends/generic/misc.c | 3 +- src/backends/windows/network.c | 4 +- src/client/cl_console.c | 4 +- src/client/cl_keyboard.c | 18 +++---- src/client/cl_main.c | 2 + src/client/cl_network.c | 6 +-- src/client/cl_parse.c | 68 ++++++++++++------------ src/client/header/client.h | 8 --- src/client/input/sdl2.c | 7 ++- src/client/menu/qmenu.c | 17 ++---- src/client/refresh/gl1/gl1_image.c | 15 +++--- src/client/refresh/gl3/gl3_image.c | 7 +-- src/client/refresh/soft/sw_image.c | 3 +- src/client/refresh/soft/sw_main.c | 2 +- src/client/refresh/soft/sw_surf.c | 2 + src/client/vid/vid.c | 14 ++--- src/common/cmdparser.c | 32 ++++++----- src/common/collision.c | 3 +- src/common/filesystem.c | 3 +- src/common/frame.c | 2 +- src/game/g_cmds.c | 36 ++++++------- src/game/g_misc.c | 3 +- src/game/g_spawn.c | 2 +- src/game/player/hud.c | 5 +- src/game/savegame/savegame.c | 4 +- src/game/savegame/tables/gamefunc_decs.h | 18 ------- src/game/savegame/tables/gamefunc_list.h | 18 ------- src/server/sv_cmd.c | 3 +- src/server/sv_init.c | 2 +- 29 files changed, 140 insertions(+), 171 deletions(-) diff --git a/src/backends/generic/misc.c b/src/backends/generic/misc.c index 68683b34b..54b8f10e7 100644 --- a/src/backends/generic/misc.c +++ b/src/backends/generic/misc.c @@ -146,7 +146,8 @@ static void SetExecutablePath(char* exePath) #endif } -qboolean Sys_GetCwd(char *buf, size_t size) +static qboolean +Sys_GetCwd(char *buf, size_t size) { #ifdef _WIN32 WCHAR wpath[PATH_MAX]; diff --git a/src/backends/windows/network.c b/src/backends/windows/network.c index a6d4fc3e1..35de711da 100644 --- a/src/backends/windows/network.c +++ b/src/backends/windows/network.c @@ -800,7 +800,7 @@ NET_SendPacket(netsrc_t sock, int length, void *data, netadr_t to) /* ============================================================================= */ -int +static int NET_IPSocket(char *net_interface, int port, netsrc_t type, int family) { char Buf[BUFSIZ], *Host, *Service; @@ -1040,7 +1040,7 @@ NET_OpenIP(void) } } -int +static int NET_IPXSocket(int port) { int newsocket; diff --git a/src/client/cl_console.c b/src/client/cl_console.c index 9c30524b3..e85764d26 100644 --- a/src/client/cl_console.c +++ b/src/client/cl_console.c @@ -472,7 +472,7 @@ Con_DrawInput(void) float scale; char *text; char ch; - int txtlen; + size_t txtlen; int linepos; int draw_icon; @@ -630,7 +630,7 @@ Con_DrawConsole(float frac) { int i, j, x, y, n; int rows; - int verLen; + size_t verLen; char *text; int row; int lines; diff --git a/src/client/cl_keyboard.c b/src/client/cl_keyboard.c index c8efa1507..9e129718d 100644 --- a/src/client/cl_keyboard.c +++ b/src/client/cl_keyboard.c @@ -269,7 +269,7 @@ keyname_t keynames[] = { /* ------------------------------------------------------------------ */ -void +static void CompleteCommand(void) { char *cmd; @@ -301,7 +301,7 @@ CompleteCommand(void) key_lines[edit_line][key_linepos] = '\0'; } -void +static void CompleteMapNameCommand(void) { char *s, *cmdArg; @@ -339,7 +339,7 @@ IsInConsole(void) (cls.state == ca_disconnected || cls.state == ca_connecting)); } -void +static void Key_Console(int key) { char txt[2]; @@ -607,7 +607,7 @@ char chat_buffer[MAXCMDLINE]; int chat_bufferlen = 0; int chat_cursorpos = 0; -void +static void Key_Message(int key) { char last; @@ -735,7 +735,7 @@ Key_Message(int key) * Single ascii characters return themselves, while * the K_* names are matched up. */ -int +static int Key_StringToKeynum(char *str) { keyname_t *kn; @@ -822,7 +822,7 @@ Key_SetBinding(int keynum, char *binding) keybindings[keynum] = new; } -void +static void Key_Unbind_f(void) { int b; @@ -844,7 +844,7 @@ Key_Unbind_f(void) Key_SetBinding(b, ""); } -void +static void Key_Unbindall_f(void) { int i; @@ -862,7 +862,7 @@ Key_Unbindall_f(void) * (=> default.cfg is done) */ extern qboolean doneWithDefaultCfg; -void +static void Key_Bind_f(void) { int i, c, b; @@ -1049,7 +1049,7 @@ Key_ReadConsoleHistory() fclose(f); } -void +static void Key_Bindlist_f(void) { int i; diff --git a/src/client/cl_main.c b/src/client/cl_main.c index de050abf9..172fc4b33 100644 --- a/src/client/cl_main.c +++ b/src/client/cl_main.c @@ -33,6 +33,7 @@ void CL_Changing_f(void); void CL_Reconnect_f(void); void CL_Connect_f(void); void CL_Rcon_f(void); +void CL_Packet_f(void); void CL_CheckForResend(void); cvar_t *rcon_client_password; @@ -597,6 +598,7 @@ CL_InitLocal(void) Cmd_AddCommand("reconnect", CL_Reconnect_f); Cmd_AddCommand("rcon", CL_Rcon_f); + Cmd_AddCommand("packet", CL_Packet_f); Cmd_AddCommand("setenv", CL_Setenv_f); diff --git a/src/client/cl_network.c b/src/client/cl_network.c index 7f068192e..2e92342f8 100644 --- a/src/client/cl_network.c +++ b/src/client/cl_network.c @@ -109,7 +109,7 @@ CL_Drop(void) * We have gotten a challenge from the server, so try and * connect. */ -void +static void CL_SendConnectPacket(void) { netadr_t adr; @@ -378,7 +378,7 @@ void CL_Packet_f(void) { char send[2048]; - int i, l; + size_t i, l; char *in, *out; netadr_t adr; @@ -567,7 +567,7 @@ CL_PingServers_f(void) /* * Responses to broadcasts, etc */ -void +static void CL_ConnectionlessPacket(void) { char *s; diff --git a/src/client/cl_parse.c b/src/client/cl_parse.c index aeff4ddcd..c3ae53e29 100644 --- a/src/client/cl_parse.c +++ b/src/client/cl_parse.c @@ -30,9 +30,9 @@ void CL_DownloadFileName(char *dest, int destlen, char *fn); void CL_ParseDownload(void); -int bitcounts[32]; /* just for protocol profiling */ +static int bitcounts[32]; /* just for protocol profiling */ -char *svc_strings[256] = { +static const char *svc_strings[256] = { "svc_bad", "svc_muzzleflash", @@ -83,7 +83,7 @@ CL_RegisterSounds(void) /* * Returns the entity number and the header bits */ -int +static int CL_ParseEntityBits(unsigned *bits) { unsigned b, total; @@ -137,8 +137,8 @@ CL_ParseEntityBits(unsigned *bits) /* * Can go from either a baseline or a previous packet_entity */ -void -CL_ParseDelta(entity_state_t *from, entity_state_t *to, int number, int bits) +static void +CL_ParseDelta(const entity_state_t *from, entity_state_t *to, int number, int bits) { /* set everything to the state we are delta'ing from */ *to = *from; @@ -275,7 +275,7 @@ CL_ParseDelta(entity_state_t *from, entity_state_t *to, int number, int bits) * Parses deltas from the given base and adds the resulting entity to * the current frame */ -void +static void CL_DeltaEntity(frame_t *frame, int newnum, entity_state_t *old, int bits) { centity_t *ent; @@ -339,13 +339,12 @@ CL_DeltaEntity(frame_t *frame, int newnum, entity_state_t *old, int bits) * parsed, deal with the rest of the * data stream. */ -void +static void CL_ParsePacketEntities(frame_t *oldframe, frame_t *newframe) { unsigned int newnum; unsigned bits; - entity_state_t - *oldstate = NULL; + entity_state_t *oldstate = NULL; int oldindex, oldnum; newframe->parse_entities = cl.parse_entities; @@ -518,13 +517,11 @@ CL_ParsePacketEntities(frame_t *oldframe, frame_t *newframe) } } -void +static void CL_ParsePlayerstate(frame_t *oldframe, frame_t *newframe) { - int flags; + int flags, i, statbits; player_state_t *state; - int i; - int statbits; state = &newframe->playerstate; @@ -656,14 +653,16 @@ CL_ParsePlayerstate(frame_t *oldframe, frame_t *newframe) } } -void +static void CL_FireEntityEvents(frame_t *frame) { - entity_state_t *s1; - int pnum, num; + int pnum; for (pnum = 0; pnum < frame->num_entities; pnum++) { + entity_state_t *s1; + int num; + num = (frame->parse_entities + pnum) & (MAX_PARSE_ENTITIES - 1); s1 = &cl_parse_entities[num]; @@ -679,7 +678,16 @@ CL_FireEntityEvents(frame_t *frame) } } -void +static void +SHOWNET(const char *s) +{ + if (cl_shownet->value >= 2) + { + Com_Printf("%3i:%s\n", net_message.readcount - 1, s); + } +} + +static void CL_ParseFrame(void) { int cmd; @@ -823,7 +831,7 @@ CL_ParseFrame(void) } } -void +static void CL_ParseServerData(void) { extern cvar_t *fs_gamedirvar; @@ -891,7 +899,7 @@ CL_ParseServerData(void) } } -void +static void CL_ParseBaseline(void) { entity_state_t *es; @@ -1061,10 +1069,11 @@ CL_ParseClientinfo(int player) CL_LoadClientinfo(ci, s); } -void +static void CL_ParseConfigString(void) { - int i, length; + size_t length; + int i; char *s; char olds[MAX_QPATH]; @@ -1072,7 +1081,7 @@ CL_ParseConfigString(void) if ((i < 0) || (i >= MAX_CONFIGSTRINGS)) { - Com_Error(ERR_DROP, "configstring > MAX_CONFIGSTRINGS"); + Com_Error(ERR_DROP, "%s: configstring > MAX_CONFIGSTRINGS", __func__); } s = MSG_ReadString(&net_message); @@ -1080,9 +1089,9 @@ CL_ParseConfigString(void) Q_strlcpy(olds, cl.configstrings[i], sizeof(olds)); length = strlen(s); - if (length > sizeof(cl.configstrings) - sizeof(cl.configstrings[0])*i - 1) + if (length > sizeof(cl.configstrings) - sizeof(cl.configstrings[0]) * i - 1) { - Com_Error(ERR_DROP, "CL_ParseConfigString: oversize configstring"); + Com_Error(ERR_DROP, "%s: oversize configstring", __func__); } strcpy(cl.configstrings[i], s); @@ -1140,7 +1149,7 @@ CL_ParseConfigString(void) } } -void +static void CL_ParseStartSoundPacket(void) { vec3_t pos_v; @@ -1227,15 +1236,6 @@ CL_ParseStartSoundPacket(void) volume, attenuation, ofs); } -void -SHOWNET(char *s) -{ - if (cl_shownet->value >= 2) - { - Com_Printf("%3i:%s\n", net_message.readcount - 1, s); - } -} - void CL_ParseServerMessage(void) { diff --git a/src/client/header/client.h b/src/client/header/client.h index 4e7def1e8..d7b387435 100644 --- a/src/client/header/client.h +++ b/src/client/header/client.h @@ -421,12 +421,7 @@ void CL_Widowbeamout (cl_sustain_t *self); void CL_Nukeblast (cl_sustain_t *self); void CL_WidowSplash (vec3_t org); -int CL_ParseEntityBits (unsigned *bits); -void CL_ParseDelta (entity_state_t *from, entity_state_t *to, int number, int bits); -void CL_ParseFrame (void); - void CL_ParseTEnt (void); -void CL_ParseConfigString (void); void CL_AddMuzzleFlash (void); void CL_AddMuzzleFlash2 (void); void SmokeAndFlash(vec3_t origin); @@ -498,11 +493,8 @@ void CL_WriteDemoMessage (void); void CL_Stop_f (void); void CL_Record_f (void); -extern char *svc_strings[256]; - void CL_ParseServerMessage (void); void CL_LoadClientinfo (clientinfo_t *ci, char *s); -void SHOWNET(char *s); void CL_ParseClientinfo (int player); void CL_Download_f (void); diff --git a/src/client/input/sdl2.c b/src/client/input/sdl2.c index 0faece385..6990b2f41 100644 --- a/src/client/input/sdl2.c +++ b/src/client/input/sdl2.c @@ -2147,6 +2147,9 @@ IN_Controller_Init(qboolean notify_user) for (int i = 0; i < SDL_NumJoysticks(); i++) { + const char* joystick_name; + size_t name_len; + joystick = SDL_JoystickOpen(i); if (!joystick) { @@ -2154,8 +2157,8 @@ IN_Controller_Init(qboolean notify_user) continue; // try next joystick } - const char* joystick_name = SDL_JoystickName(joystick); - const int name_len = strlen(joystick_name); + joystick_name = SDL_JoystickName(joystick); + name_len = strlen(joystick_name); Com_Printf ("Trying joystick %d, '%s'\n", i+1, joystick_name); diff --git a/src/client/menu/qmenu.c b/src/client/menu/qmenu.c index 92b8cd24f..2804133da 100644 --- a/src/client/menu/qmenu.c +++ b/src/client/menu/qmenu.c @@ -67,7 +67,8 @@ ClampCvar(float min, float max, float value) Bitmap_Draw ================= */ -void Bitmap_Draw(menubitmap_s * item) +static void +Bitmap_Draw(menubitmap_s * item) { float scale = SCR_GetMenuScale(); int x = 0; @@ -132,19 +133,7 @@ Action_Draw(menuaction_s *a) } } -qboolean -Field_DoEnter(menufield_s *f) -{ - if (f->generic.callback) - { - f->generic.callback(f); - return true; - } - - return false; -} - -void +static void Field_Draw(menufield_s *f) { int i, n; diff --git a/src/client/refresh/gl1/gl1_image.c b/src/client/refresh/gl1/gl1_image.c index 00761e70c..1b8064d5c 100644 --- a/src/client/refresh/gl1/gl1_image.c +++ b/src/client/refresh/gl1/gl1_image.c @@ -470,7 +470,7 @@ R_ImageList_f(void) /* * Fill background pixels so mipmapping doesn't have haloes */ -void +static void R_FloodFillSkin(byte *skin, int skinwidth, int skinheight) { byte fillcolor = *skin; /* assume this is the pixel to fill */ @@ -536,7 +536,7 @@ R_FloodFillSkin(byte *skin, int skinwidth, int skinheight) * texture to increase the * lighting range */ -void +static void R_LightScaleTexture(unsigned *in, int inwidth, int inheight, qboolean only_gamma) { @@ -577,7 +577,7 @@ R_LightScaleTexture(unsigned *in, int inwidth, /* * Operates in place, quartering the size of the texture */ -void +static void R_MipMap(byte *in, int width, int height) { int i, j; @@ -602,7 +602,7 @@ R_MipMap(byte *in, int width, int height) /* * Returns has_alpha */ -void +static void R_BuildPalettedTexture(unsigned char *paletted_texture, unsigned char *scaled, int scaled_width, int scaled_height) { @@ -624,7 +624,7 @@ R_BuildPalettedTexture(unsigned char *paletted_texture, unsigned char *scaled, } } -qboolean +static qboolean R_Upload32Native(unsigned *data, int width, int height, qboolean mipmap) { // This is for GL 2.x so no palettes, no scaling, no messing around with the data here. :) @@ -660,7 +660,7 @@ R_Upload32Native(unsigned *data, int width, int height, qboolean mipmap) } -qboolean +static qboolean R_Upload32Soft(unsigned *data, int width, int height, qboolean mipmap) { int samples; @@ -1126,7 +1126,8 @@ image_t * R_FindImage(const char *name, imagetype_t type) { image_t *image; - int i, len; + size_t len; + int i; char *ptr; char namewe[256]; const char* ext; diff --git a/src/client/refresh/gl3/gl3_image.c b/src/client/refresh/gl3/gl3_image.c index dc5c95e95..8738fcabf 100644 --- a/src/client/refresh/gl3/gl3_image.c +++ b/src/client/refresh/gl3/gl3_image.c @@ -186,7 +186,7 @@ GL3_BindLightmap(int lightmapnum) /* * Returns has_alpha */ -qboolean +static qboolean GL3_Upload32(unsigned *data, int width, int height, qboolean mipmap) { qboolean res; @@ -237,7 +237,7 @@ GL3_Upload32(unsigned *data, int width, int height, qboolean mipmap) /* * Returns has_alpha */ -qboolean +static qboolean GL3_Upload8(byte *data, int width, int height, qboolean mipmap, qboolean is_sky) { int s = width * height; @@ -605,7 +605,8 @@ gl3image_t * GL3_FindImage(const char *name, imagetype_t type) { gl3image_t *image; - int i, len; + size_t len; + int i; char *ptr; char namewe[256]; const char* ext; diff --git a/src/client/refresh/soft/sw_image.c b/src/client/refresh/soft/sw_image.c index e588830e2..4a85dd057 100644 --- a/src/client/refresh/soft/sw_image.c +++ b/src/client/refresh/soft/sw_image.c @@ -492,7 +492,8 @@ image_t * R_FindImage(const char *name, imagetype_t type) { image_t *image; - int i, len; + size_t len; + int i; char *ptr; char namewe[256]; const char* ext; diff --git a/src/client/refresh/soft/sw_main.c b/src/client/refresh/soft/sw_main.c index 55f7d39ae..d996d0da7 100644 --- a/src/client/refresh/soft/sw_main.c +++ b/src/client/refresh/soft/sw_main.c @@ -2183,7 +2183,7 @@ RE_BufferDifferenceStart(int vmin, int vmax) return (pixel_t*)back_buffer - swap_frames[0]; } -static int +static size_t RE_BufferDifferenceEnd(int vmin, int vmax) { int *front_buffer, *back_buffer, *back_min; diff --git a/src/client/refresh/soft/sw_surf.c b/src/client/refresh/soft/sw_surf.c index 32c7c10e2..2478da9a7 100644 --- a/src/client/refresh/soft/sw_surf.c +++ b/src/client/refresh/soft/sw_surf.c @@ -104,6 +104,8 @@ R_DrawSurfaceBlock_Light (pixel_t *prowdest, pixel_t *psource, size_t size, for (b=(size-1); b>=0; b--) { pixel_t pix; + int j; + pix = psource[b]; prowdest[b] = R_ApplyLight(pix, light); diff --git a/src/client/vid/vid.c b/src/client/vid/vid.c index f980d5ad8..cfb293cab 100644 --- a/src/client/vid/vid.c +++ b/src/client/vid/vid.c @@ -105,7 +105,7 @@ void VID_WriteScreenshot(int width, int height, int comp, const void* data) if (argc > 2) { const char* q = Cmd_Argv(2); - int qualityStrLen = strlen(q); + size_t qualityStrLen = strlen(q); for (i = 0; i < qualityStrLen; ++i) { @@ -247,7 +247,7 @@ vidmode_t vid_modes[] = { /* * Callback function for the 'vid_listmodes' cmd. */ -void +static void VID_ListModes_f(void) { int i; @@ -264,7 +264,7 @@ VID_ListModes_f(void) /* * Returns informations about the given mode. */ -qboolean +static qboolean VID_GetModeInfo(int *width, int *height, int mode) { if ((mode < 0) || (mode >= VID_NUM_MODES)) @@ -341,7 +341,7 @@ VID_HasRenderer(const char *renderer) /* * Called by the renderer to request a restart. */ -void +static void VID_RequestRestart(ref_restart_t rs) { restart_state = rs; @@ -350,7 +350,7 @@ VID_RequestRestart(ref_restart_t rs) /* * Restarts the renderer. */ -void +static void VID_Restart_f(void) { if (restart_state == RESTART_UNDEF) @@ -364,7 +364,7 @@ VID_Restart_f(void) /* * Shuts the renderer down and unloads it. */ -void +static void VID_ShutdownRenderer(void) { if (ref_active) @@ -384,7 +384,7 @@ VID_ShutdownRenderer(void) /* * Loads and initializes a renderer. */ -qboolean +static qboolean VID_LoadRenderer(void) { refimport_t ri; diff --git a/src/common/cmdparser.c b/src/common/cmdparser.c index dcbc0dad6..9997c48a1 100644 --- a/src/common/cmdparser.c +++ b/src/common/cmdparser.c @@ -67,7 +67,7 @@ char defer_text_buf[32768]; * until next frame. This allows commands like: bind g "impulse 5 ; * +attack ; wait ; -attack ; impulse 2" */ -void +static void Cmd_Wait_f(void) { cmd_wait = Sys_Milliseconds(); @@ -85,7 +85,7 @@ Cbuf_Init(void) void Cbuf_AddText(char *text) { - int l; + size_t l; l = strlen(text); @@ -299,7 +299,7 @@ qboolean Cbuf_AddLateCommands(void) { int i, j; - int s; + size_t s; char *text, c; int argc; qboolean has_args = false; @@ -362,7 +362,7 @@ Cbuf_AddLateCommands(void) /* * Execute a script file */ -void +static void Cmd_Exec_f(void) { char *f, *f2; @@ -400,7 +400,9 @@ Cmd_Exec_f(void) /* * Inserts the current value of a variable as command text */ -void Cmd_Vstr_f( void ) { +static void +Cmd_Vstr_f(void) +{ const char *v; if (Cmd_Argc() != 2) { @@ -415,7 +417,7 @@ void Cmd_Vstr_f( void ) { /* * Just prints the rest of the line to the console */ -void +static void Cmd_Echo_f(void) { int i; @@ -432,7 +434,7 @@ Cmd_Echo_f(void) * Creates a new command that executes * a command string (possibly ; seperated) */ -void +static void Cmd_Alias_f(void) { cmdalias_t *a; @@ -524,10 +526,11 @@ Cmd_Args(void) return cmd_args; } -char * +static char * Cmd_MacroExpandString(char *text) { - int i, j, count, len; + size_t len; + int i, count; qboolean inquote; char *scan; static char expanded[MAX_STRING_CHARS]; @@ -549,6 +552,8 @@ Cmd_MacroExpandString(char *text) for (i = 0; i < len; i++) { + size_t j; + if (scan[i] == '"') { inquote ^= 1; @@ -783,7 +788,8 @@ char * Cmd_CompleteCommand(char *partial) { cmd_function_t *cmd; - int len, i, o, p; + size_t len; + int i, o, p; cmdalias_t *a; cvar_t *cvar; char *pmatch[1024]; @@ -907,13 +913,15 @@ char * Cmd_CompleteMapCommand(char *partial) { char **mapNames; - int i, j, k, nbMatches, len, nMaps; + int i, j, k, nbMatches, nMaps; char *mapName, *lastsep; char *pmatch[1024]; qboolean partialFillContinue = true; if ((mapNames = FS_ListFiles2("maps/*.bsp", &nMaps, 0, 0)) != NULL) { + size_t len; + len = strlen(partial); nbMatches = 0; memset(retval, 0, strlen(retval)); @@ -1094,7 +1102,7 @@ Cmd_ExecuteString(char *text) #endif } -void +static void Cmd_List_f(void) { cmd_function_t *cmd; diff --git a/src/common/collision.c b/src/common/collision.c index a8aa71c16..6534d8cc1 100644 --- a/src/common/collision.c +++ b/src/common/collision.c @@ -1624,7 +1624,8 @@ CMod_LoadEntityString(const lump_t *l, const char *name) if (sv_entfile->value) { char *buffer = NULL, entname[256]; - int nameLen, bufLen = -1; + size_t nameLen; + int bufLen = -1; nameLen = strlen(name); if (strcmp(name + nameLen - 4, ".bsp") || nameLen > (MAX_QPATH - 1)) diff --git a/src/common/filesystem.c b/src/common/filesystem.c index ece3ba97f..34e227086 100644 --- a/src/common/filesystem.c +++ b/src/common/filesystem.c @@ -1431,7 +1431,8 @@ Q_sort_modcmp(const void *p1, const void *p2) char** FS_ListMods(int *nummods) { - int nmods = 0, numdirchildren, numpacksinchilddir, searchpathlength; + int nmods = 0, numdirchildren, numpacksinchilddir; + size_t searchpathlength; char findnamepattern[MAX_OSPATH], modname[MAX_QPATH], searchpath[MAX_OSPATH]; char **dirchildren, **packsinchilddir, **modnames; diff --git a/src/common/frame.c b/src/common/frame.c index ce84cd12e..901fdee5b 100644 --- a/src/common/frame.c +++ b/src/common/frame.c @@ -117,7 +117,7 @@ static void Qcommon_Buildstring(void) { int i; - int verLen; + size_t verLen; const char* versionString; diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 1f217986c..d28e7b2b8 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -211,7 +211,7 @@ ValidateSelectedItem(edict_t *ent) /* * Give items to a client */ -void +static void Cmd_Give_f(edict_t *ent) { char *name; @@ -423,7 +423,7 @@ Cmd_Give_f(edict_t *ent) /* * Sets client to godmode */ -void +static void Cmd_God_f(edict_t *ent) { char *msg; @@ -457,7 +457,7 @@ Cmd_God_f(edict_t *ent) /* * Sets client to notarget */ -void +static void Cmd_Notarget_f(edict_t *ent) { char *msg; @@ -491,7 +491,7 @@ Cmd_Notarget_f(edict_t *ent) /* * argv(0) noclip */ -void +static void Cmd_Noclip_f(edict_t *ent) { char *msg; @@ -525,7 +525,7 @@ Cmd_Noclip_f(edict_t *ent) /* * Use an inventory item */ -void +static void Cmd_Use_f(edict_t *ent) { int index; @@ -566,7 +566,7 @@ Cmd_Use_f(edict_t *ent) /* * Drop an inventory item */ -void +static void Cmd_Drop_f(edict_t *ent) { int index; @@ -661,7 +661,7 @@ Cmd_Help_f(edict_t *ent) gi.unicast(ent, true); } -void +static void Cmd_Inven_f(edict_t *ent) { gclient_t *cl; @@ -688,7 +688,7 @@ Cmd_Inven_f(edict_t *ent) gi.unicast(ent, true); } -void +static void Cmd_InvUse_f(edict_t *ent) { gitem_t *it; @@ -717,7 +717,7 @@ Cmd_InvUse_f(edict_t *ent) it->use(ent, it); } -void +static void Cmd_WeapPrev_f(edict_t *ent) { gclient_t *cl; @@ -779,7 +779,7 @@ Cmd_WeapPrev_f(edict_t *ent) } } -void +static void Cmd_WeapNext_f(edict_t *ent) { gclient_t *cl; @@ -841,7 +841,7 @@ Cmd_WeapNext_f(edict_t *ent) } } -void +static void Cmd_WeapLast_f(edict_t *ent) { gclient_t *cl; @@ -882,7 +882,7 @@ Cmd_WeapLast_f(edict_t *ent) it->use(ent, it); } -void +static void Cmd_InvDrop_f(edict_t *ent) { gitem_t *it; @@ -911,7 +911,7 @@ Cmd_InvDrop_f(edict_t *ent) it->drop(ent, it); } -void +static void Cmd_Kill_f(edict_t *ent) { if (!ent) @@ -931,7 +931,7 @@ Cmd_Kill_f(edict_t *ent) player_die(ent, ent, ent, 100000, vec3_origin); } -void +static void Cmd_PutAway_f(edict_t *ent) { if (!ent) @@ -973,7 +973,7 @@ PlayerSort(void const *a, void const *b) return 0; } -void +static void Cmd_Players_f(edict_t *ent) { int i; @@ -1023,7 +1023,7 @@ Cmd_Players_f(edict_t *ent) gi.cprintf(ent, PRINT_HIGH, "%s\n%i players\n", large, count); } -void +static void Cmd_Wave_f(edict_t *ent) { int i; @@ -1147,7 +1147,7 @@ flooded(edict_t *ent) return false; } -void +static void Cmd_Say_f(edict_t *ent, qboolean team, qboolean arg0) { int j; @@ -1242,7 +1242,7 @@ Cmd_Say_f(edict_t *ent, qboolean team, qboolean arg0) } } -void +static void Cmd_PlayerList_f(edict_t *ent) { int i; diff --git a/src/game/g_misc.c b/src/game/g_misc.c index f3e2b5460..4d3a01107 100644 --- a/src/game/g_misc.c +++ b/src/game/g_misc.c @@ -2280,7 +2280,8 @@ void target_string_use(edict_t *self, edict_t *other /* unused */, edict_t *activator /* unused */) { edict_t *e; - int n, l; + size_t l; + int n; char c; if (!self) diff --git a/src/game/g_spawn.c b/src/game/g_spawn.c index 363459b43..cfbf52bc1 100644 --- a/src/game/g_spawn.c +++ b/src/game/g_spawn.c @@ -327,7 +327,7 @@ char * ED_NewString(const char *string) { char *newb, *new_p; - int i, l; + size_t i, l; if (!string) { diff --git a/src/game/player/hud.c b/src/game/player/hud.c index 7786a2163..78860a6ad 100644 --- a/src/game/player/hud.c +++ b/src/game/player/hud.c @@ -218,7 +218,7 @@ DeathmatchScoreboardMessage(edict_t *ent, edict_t *killer) { char entry[1024]; char string[1400]; - int stringlength; + size_t stringlength; int i; int sorted[MAX_CLIENTS]; int sortedscores[MAX_CLIENTS]; @@ -279,7 +279,8 @@ DeathmatchScoreboardMessage(edict_t *ent, edict_t *killer) for (i = 0; i < total; i++) { char *tag; - int x, y, j; + int x, y; + size_t j; gclient_t *cl; edict_t *cl_ent; diff --git a/src/game/savegame/savegame.c b/src/game/savegame/savegame.c index 0f030f615..a593e980b 100644 --- a/src/game/savegame/savegame.c +++ b/src/game/savegame/savegame.c @@ -370,7 +370,7 @@ void WriteField1(FILE *f, field_t *field, byte *base) { void *p; - int len; + size_t len; int index; functionList_t *func; mmoveList_t *mmove; @@ -492,7 +492,7 @@ WriteField1(FILE *f, field_t *field, byte *base) void WriteField2(FILE *f, field_t *field, byte *base) { - int len; + size_t len; void *p; functionList_t *func; mmoveList_t *mmove; diff --git a/src/game/savegame/tables/gamefunc_decs.h b/src/game/savegame/tables/gamefunc_decs.h index 32e1e0359..674acaae6 100644 --- a/src/game/savegame/tables/gamefunc_decs.h +++ b/src/game/savegame/tables/gamefunc_decs.h @@ -1013,27 +1013,9 @@ extern void SpawnDamage ( int type , vec3_t origin , vec3_t normal ) ; extern void Killed ( edict_t * targ , edict_t * inflictor , edict_t * attacker , int damage , vec3_t point ) ; extern qboolean CanDamage ( edict_t * targ , edict_t * inflictor ) ; extern void ClientCommand ( edict_t * ent ) ; -extern void Cmd_PlayerList_f ( edict_t * ent ) ; -extern void Cmd_Say_f ( edict_t * ent , qboolean team , qboolean arg0 ) ; -extern void Cmd_Wave_f ( edict_t * ent ) ; -extern void Cmd_Players_f ( edict_t * ent ) ; extern int PlayerSort ( void const * a , void const * b ) ; -extern void Cmd_PutAway_f ( edict_t * ent ) ; -extern void Cmd_Kill_f ( edict_t * ent ) ; -extern void Cmd_InvDrop_f ( edict_t * ent ) ; -extern void Cmd_WeapLast_f ( edict_t * ent ) ; -extern void Cmd_WeapNext_f ( edict_t * ent ) ; -extern void Cmd_WeapPrev_f ( edict_t * ent ) ; -extern void Cmd_InvUse_f ( edict_t * ent ) ; -extern void Cmd_Inven_f ( edict_t * ent ) ; extern void Cmd_Help_f ( edict_t * ent ) ; extern void Cmd_Score_f ( edict_t * ent ) ; -extern void Cmd_Drop_f ( edict_t * ent ) ; -extern void Cmd_Use_f ( edict_t * ent ) ; -extern void Cmd_Noclip_f ( edict_t * ent ) ; -extern void Cmd_Notarget_f ( edict_t * ent ) ; -extern void Cmd_God_f ( edict_t * ent ) ; -extern void Cmd_Give_f ( edict_t * ent ) ; extern void ValidateSelectedItem ( edict_t * ent ) ; extern void SelectPrevItem ( edict_t * ent , int itflags ) ; extern void SelectNextItem ( edict_t * ent , int itflags ) ; diff --git a/src/game/savegame/tables/gamefunc_list.h b/src/game/savegame/tables/gamefunc_list.h index 42b20eb57..4688d2b5b 100644 --- a/src/game/savegame/tables/gamefunc_list.h +++ b/src/game/savegame/tables/gamefunc_list.h @@ -1012,27 +1012,9 @@ {"Killed", (byte *)Killed}, {"CanDamage", (byte *)CanDamage}, {"ClientCommand", (byte *)ClientCommand}, -{"Cmd_PlayerList_f", (byte *)Cmd_PlayerList_f}, -{"Cmd_Say_f", (byte *)Cmd_Say_f}, -{"Cmd_Wave_f", (byte *)Cmd_Wave_f}, -{"Cmd_Players_f", (byte *)Cmd_Players_f}, {"PlayerSort", (byte *)PlayerSort}, -{"Cmd_PutAway_f", (byte *)Cmd_PutAway_f}, -{"Cmd_Kill_f", (byte *)Cmd_Kill_f}, -{"Cmd_InvDrop_f", (byte *)Cmd_InvDrop_f}, -{"Cmd_WeapLast_f", (byte *)Cmd_WeapLast_f}, -{"Cmd_WeapNext_f", (byte *)Cmd_WeapNext_f}, -{"Cmd_WeapPrev_f", (byte *)Cmd_WeapPrev_f}, -{"Cmd_InvUse_f", (byte *)Cmd_InvUse_f}, -{"Cmd_Inven_f", (byte *)Cmd_Inven_f}, {"Cmd_Help_f", (byte *)Cmd_Help_f}, {"Cmd_Score_f", (byte *)Cmd_Score_f}, -{"Cmd_Drop_f", (byte *)Cmd_Drop_f}, -{"Cmd_Use_f", (byte *)Cmd_Use_f}, -{"Cmd_Noclip_f", (byte *)Cmd_Noclip_f}, -{"Cmd_Notarget_f", (byte *)Cmd_Notarget_f}, -{"Cmd_God_f", (byte *)Cmd_God_f}, -{"Cmd_Give_f", (byte *)Cmd_Give_f}, {"ValidateSelectedItem", (byte *)ValidateSelectedItem}, {"SelectPrevItem", (byte *)SelectPrevItem}, {"SelectNextItem", (byte *)SelectNextItem}, diff --git a/src/server/sv_cmd.c b/src/server/sv_cmd.c index e44c8c24b..01f716fee 100644 --- a/src/server/sv_cmd.c +++ b/src/server/sv_cmd.c @@ -381,7 +381,8 @@ SV_Kick_f(void) void SV_Status_f(void) { - int i, j, l; + int i, j; + size_t l; client_t *cl; char *s; int ping; diff --git a/src/server/sv_init.c b/src/server/sv_init.c index 3ba3a55c9..4c2689546 100644 --- a/src/server/sv_init.c +++ b/src/server/sv_init.c @@ -492,7 +492,7 @@ SV_Map(qboolean attractloop, char *levelstring, qboolean loadgame, qboolean isau { char level[MAX_QPATH]; char *ch; - int l; + size_t l; char spawnpoint[MAX_QPATH]; sv.loadgame = loadgame; From 49b4e97f5d62f6597fbcba7cfcd4db66031c232a Mon Sep 17 00:00:00 2001 From: SiemensSchuckert <35631785+SiemensSchuckert@users.noreply.github.com> Date: Sun, 22 Dec 2024 21:12:48 +0300 Subject: [PATCH 3/3] disable certificate validation for HTTPS (#1174) disable certificate check for HTTPS disable SSL certificate check - to allow download from servers with self-signed cert, or when some certs are missing from system certificate store that CURL uses add new cvar `cl_http_verifypeer` --- doc/040_cvarlist.md | 3 +++ src/client/cl_main.c | 3 ++- src/client/curl/download.c | 3 +++ src/client/curl/header/download.h | 1 + 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/doc/040_cvarlist.md b/doc/040_cvarlist.md index fe4a0f36f..b02a35446 100644 --- a/doc/040_cvarlist.md +++ b/doc/040_cvarlist.md @@ -106,6 +106,9 @@ it's `+set busywait 0` (setting the `busywait` cvar) and `-portable` * **cl_http_max_connections**: Maximum number of parallel downloads. Set to `4` by default. A higher number may help with slow servers. +* **cl_http_verifypeer**: SSL certificate validation. Set to `1` + by default, set to `0` to disable. + * **cl_http_proxy**: Proxy to use, empty by default. * **cl_http_show_dw_progress**: Show a HTTP download progress bar. diff --git a/src/client/cl_main.c b/src/client/cl_main.c index de050abf9..4d783d931 100644 --- a/src/client/cl_main.c +++ b/src/client/cl_main.c @@ -568,7 +568,8 @@ CL_InitLocal(void) cl_vwep = Cvar_Get("cl_vwep", "1", CVAR_ARCHIVE); #ifdef USE_CURL - cl_http_proxy = Cvar_Get("cl_http_proxy", "", 0); + cl_http_verifypeer = Cvar_Get("cl_http_verifypeer", "1", CVAR_ARCHIVE); + cl_http_proxy = Cvar_Get("cl_http_proxy", "", CVAR_ARCHIVE); cl_http_filelists = Cvar_Get("cl_http_filelists", "1", 0); cl_http_downloads = Cvar_Get("cl_http_downloads", "1", CVAR_ARCHIVE); cl_http_max_connections = Cvar_Get("cl_http_max_connections", "4", 0); diff --git a/src/client/curl/download.c b/src/client/curl/download.c index 307863657..6bd0b628d 100644 --- a/src/client/curl/download.c +++ b/src/client/curl/download.c @@ -33,6 +33,7 @@ cvar_t *cl_http_downloads; cvar_t *cl_http_filelists; +cvar_t *cl_http_verifypeer; cvar_t *cl_http_proxy; cvar_t *cl_http_max_connections; cvar_t *cl_http_show_dw_progress; @@ -293,6 +294,8 @@ static void CL_StartHTTPDownload (dlqueue_t *entry, dlhandle_t *dl) qcurl_easy_setopt(dl->curl, CURLOPT_WRITEFUNCTION, CL_HTTP_Recv); } + qcurl_easy_setopt(dl->curl, CURLOPT_SSL_VERIFYPEER, (long)cl_http_verifypeer->value); + qcurl_easy_setopt(dl->curl, CURLOPT_PROXY_SSL_VERIFYPEER, (long)cl_http_verifypeer->value); qcurl_easy_setopt(dl->curl, CURLOPT_PROXY, cl_http_proxy->string); qcurl_easy_setopt(dl->curl, CURLOPT_LOW_SPEED_TIME, (long)cl_http_bw_limit_tmout->value); qcurl_easy_setopt(dl->curl, CURLOPT_LOW_SPEED_LIMIT, (long)cl_http_bw_limit_rate->value); diff --git a/src/client/curl/header/download.h b/src/client/curl/header/download.h index c2a4e97ce..a91b14556 100644 --- a/src/client/curl/header/download.h +++ b/src/client/curl/header/download.h @@ -72,6 +72,7 @@ extern dlquirks_t dlquirks; extern cvar_t *cl_http_downloads; extern cvar_t *cl_http_filelists; +extern cvar_t *cl_http_verifypeer; extern cvar_t *cl_http_proxy; extern cvar_t *cl_http_max_connections; extern cvar_t *cl_http_show_dw_progress;