From 2ebc7fb7dd7dfdecf11c19633fb15130b6e79c34 Mon Sep 17 00:00:00 2001 From: Alison Watson Date: Mon, 25 Nov 2019 16:20:03 -0500 Subject: [PATCH] fix errata --- CMakeLists.txt | 54 +++++++++++++++++++----------- source/cd_null.c | 1 + source/gl_rmisc.c | 15 ++++++--- source/gl_screen.c | 4 ++- source/gl_texmgr.c | 13 ++++--- source/gl_vidsdl.c | 2 ++ source/host.c | 1 + source/in_sdl.c | 1 + source/{ => linux}/pl_linux.c | 0 source/menu.c | 1 + source/net_dgrm.c | 5 +++ source/net_loop.c | 4 +++ source/net_main.c | 2 ++ source/{ => osx}/pl_osx.m | 0 source/r_part.c | 1 + source/{ => unix}/net_bsd.c | 0 source/{ => unix}/net_udp.c | 0 source/{ => unix}/net_udp.h | 0 source/{ => unix}/sys_sdl_unix.c | 0 source/{ => windows}/net_win.c | 0 source/{ => windows}/net_wins.c | 0 source/{ => windows}/net_wins.h | 0 source/{ => windows}/net_wipx.c | 0 source/{ => windows}/net_wipx.h | 0 source/{ => windows}/pl_win.c | 0 source/{ => windows}/sys_sdl_win.c | 0 source/{ => windows}/wsaerror.h | 0 27 files changed, 73 insertions(+), 31 deletions(-) rename source/{ => linux}/pl_linux.c (100%) rename source/{ => osx}/pl_osx.m (100%) rename source/{ => unix}/net_bsd.c (100%) rename source/{ => unix}/net_udp.c (100%) rename source/{ => unix}/net_udp.h (100%) rename source/{ => unix}/sys_sdl_unix.c (100%) rename source/{ => windows}/net_win.c (100%) rename source/{ => windows}/net_wins.c (100%) rename source/{ => windows}/net_wins.h (100%) rename source/{ => windows}/net_wipx.c (100%) rename source/{ => windows}/net_wipx.h (100%) rename source/{ => windows}/pl_win.c (100%) rename source/{ => windows}/sys_sdl_win.c (100%) rename source/{ => windows}/wsaerror.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ccb358..cedf565 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,10 +5,6 @@ cmake_policy(SET CMP0071 NEW) project(agw-quake C) -if(NOT MSVC) - set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -Wextra -Werror") -endif() - find_package(OpenGL REQUIRED) find_package(PkgConfig REQUIRED) @@ -157,23 +153,36 @@ set(srcs source/zone.c source/zone.h) -if(WIN32) - list(APPEND srcs - source/net_win.c - source/net_wins.c - source/net_wins.h - source/net_wipx.c - source/net_wipx.h - source/pl_win.c - source/sys_sdl_win.c - source/wsaerror.h) +set(srcs_linux + source/linux/pl_linux.c) + +set(srcs_osx + source/osx/pl_osx.c) + +set(srcs_unix + source/unix/net_bsd.c + source/unix/net_udp.c + source/unix/net_udp.h + source/unix/sys_sdl_unix.c) + +set(srcs_windows + source/windows/net_win.c + source/windows/net_wins.c + source/windows/net_wins.h + source/windows/net_wipx.c + source/windows/net_wipx.h + source/windows/pl_win.c + source/windows/sys_sdl_win.c + source/windows/wsaerror.h) + +if(CMAKE_SYSTEM_NAME STREQUAL "Windows") + list(APPEND srcs ${srcs_windows}) +elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") + list(APPEND srcs ${srcs_unix} ${srcs_linux}) +elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + list(APPEND srcs ${srcs_unix} ${srcs_osx}) else() - list(APPEND srcs - source/net_bsd.c - source/net_udp.c - source/net_udp.h - source/pl_linux.c - source/sys_sdl_unix.c) + message(FATAL_ERROR "platform not supported") endif() add_executable(quake WIN32 ${srcs}) @@ -190,4 +199,9 @@ agw_checked_library(USE_CODEC_VORBIS Vorbis) agw_checked_library(USE_CODEC_OPUS Opus) agw_checked_library(USE_CODEC_MikMod MikMod) +target_compile_options(quake PUBLIC + $<$: + -Wall -Wextra -Werror -Wno-missing-field-initializers> + $<$: /W4>) +target_include_directories(quake PUBLIC source) target_link_libraries(quake m OpenGL::GL PkgConfig::SDL2) diff --git a/source/cd_null.c b/source/cd_null.c index 87afc7b..51e61a7 100644 --- a/source/cd_null.c +++ b/source/cd_null.c @@ -22,6 +22,7 @@ int CDAudio_Play(byte track, qboolean looping) { + (void)track, (void)looping; return -1; } diff --git a/source/gl_rmisc.c b/source/gl_rmisc.c index 4e742a8..bc1d7bf 100644 --- a/source/gl_rmisc.c +++ b/source/gl_rmisc.c @@ -58,6 +58,7 @@ GL_Overbright_f -- johnfitz */ static void GL_Overbright_f (cvar_t *var) { + (void)var; R_RebuildAllLightmaps (); } @@ -68,6 +69,7 @@ GL_Fullbrights_f -- johnfitz */ static void GL_Fullbrights_f (cvar_t *var) { + (void)var; TexMgr_ReloadNobrightImages (); } @@ -81,6 +83,7 @@ static void R_SetClearColor_f (cvar_t *var) byte *rgb; int s; + (void)var; s = (int)r_clearcolor.value & 0xFF; rgb = (byte*)(d_8to24table + s); glClearColor (rgb[0]/255.0,rgb[1]/255.0,rgb[2]/255.0,0); @@ -94,6 +97,7 @@ R_Novis_f -- johnfitz static void R_VisChanged (cvar_t *var) { extern int vis_changed; + (void)var; vis_changed = 1; } @@ -104,6 +108,7 @@ R_Model_ExtraFlags_List_f -- johnfitz -- called when r_nolerp_list or r_noshadow */ static void R_Model_ExtraFlags_List_f (cvar_t *var) { + (void)var; int i; for (i=0; i < MAX_MODELS; i++) Mod_SetExtraFlags (cl.model_precache[i]); @@ -462,7 +467,7 @@ static qboolean GL_CheckShader (GLuint shader) memset(infolog, 0, sizeof(infolog)); GL_GetShaderInfoLogFunc (shader, sizeof(infolog), NULL, infolog); - + Con_Warning ("GLSL program failed to compile: %s", infolog); return false; @@ -549,12 +554,12 @@ GLuint GL_CreateProgram (const GLchar *vertSource, const GLchar *fragSource, int GL_DeleteShaderFunc (vertShader); GL_AttachShaderFunc (program, fragShader); GL_DeleteShaderFunc (fragShader); - + for (i = 0; i < numbindings; i++) { GL_BindAttribLocationFunc (program, bindings[i].attrib, bindings[i].name); } - + GL_LinkProgramFunc (program); if (!GL_CheckProgram (program)) @@ -610,7 +615,7 @@ void GL_BindBuffer (GLenum target, GLuint buffer) if (!gl_vbo_able) return; - + switch (target) { case GL_ARRAY_BUFFER: @@ -623,7 +628,7 @@ void GL_BindBuffer (GLenum target, GLuint buffer) Host_Error("GL_BindBuffer: unsupported target %d", (int)target); return; } - + if (*cache != buffer) { *cache = buffer; diff --git a/source/gl_screen.c b/source/gl_screen.c index c733353..64fa9a7 100644 --- a/source/gl_screen.c +++ b/source/gl_screen.c @@ -357,6 +357,7 @@ void SCR_SizeDown_f (void) static void SCR_Callback_refdef (cvar_t *var) { + (void)var; vid.recalc_refdef = 1; } @@ -367,6 +368,7 @@ SCR_Conwidth_f -- johnfitz -- called when scr_conwidth or scr_conscale changes */ void SCR_Conwidth_f (cvar_t *var) { + (void)var; vid.recalc_refdef = 1; vid.conwidth = (scr_conwidth.value > 0) ? (int)scr_conwidth.value : (scr_conscale.value > 0) ? (int)(vid.width/scr_conscale.value) : vid.width; vid.conwidth = CLAMP (320, vid.conwidth, vid.width); @@ -805,7 +807,7 @@ void SCR_ScreenShot_f (void) SCR_ScreenShot_Usage (); return; } - + // find a file name to save it to for (i=0; i<10000; i++) { diff --git a/source/gl_texmgr.c b/source/gl_texmgr.c index 188907d..a5bacc0 100644 --- a/source/gl_texmgr.c +++ b/source/gl_texmgr.c @@ -129,6 +129,8 @@ static void TexMgr_TextureMode_f (cvar_t *var) gltexture_t *glt; int i; + (void)var; + for (i = 0; i < NUM_GLMODES; i++) { if (!Q_strcmp (glmodes[i].name, gl_texturemode.string)) @@ -172,6 +174,7 @@ TexMgr_Anisotropy_f -- called when gl_texture_anisotropy changes */ static void TexMgr_Anisotropy_f (cvar_t *var) { + (void)var; if (gl_texture_anisotropy.value < 1) { Cvar_SetQuick (&gl_texture_anisotropy, "1"); @@ -359,7 +362,7 @@ void TexMgr_FreeTexture (gltexture_t *kill) if (in_reload_images) return; - + if (kill == NULL) { Con_Printf ("TexMgr_FreeTexture: NULL texture\n"); @@ -573,7 +576,7 @@ void TexMgr_RecalcWarpImageSize (void) // after vid_restart TexMgr_ReloadImage reloads textures // to tx->source_width/source_height, which might not match oldsize. // fixes: https://sourceforge.net/p/quakespasm/bugs/13/ - + // // resize the textures in opengl // @@ -1414,7 +1417,7 @@ void TexMgr_ReloadImages (void) glGenTextures(1, &glt->texnum); TexMgr_ReloadImage (glt, -1, -1); } - + in_reload_images = false; } @@ -1453,7 +1456,7 @@ void GL_SelectTexture (GLenum target) { if (target == currenttarget) return; - + GL_SelectTextureFunc(target); currenttarget = target; } @@ -1528,7 +1531,7 @@ static void GL_DeleteTexture (gltexture_t *texture) /* ================ GL_ClearBindings -- ericw - + Invalidates cached bindings, so the next GL_Bind calls for each TMU will make real glBindTexture calls. Call this after changing the binding outside of GL_Bind. diff --git a/source/gl_vidsdl.c b/source/gl_vidsdl.c index 3413f8b..e6fbbd0 100644 --- a/source/gl_vidsdl.c +++ b/source/gl_vidsdl.c @@ -237,6 +237,7 @@ VID_Gamma_f -- callback when the cvar changes */ static void VID_Gamma_f (cvar_t *var) { + (void)var; if (gl_glsl_gamma_able) return; @@ -627,6 +628,7 @@ VID_Changed_f -- kristian -- notify us that a value has changed that requires a */ static void VID_Changed_f (cvar_t *var) { + (void)var; vid_changed = true; } diff --git a/source/host.c b/source/host.c index 04da0c3..ea80c54 100644 --- a/source/host.c +++ b/source/host.c @@ -93,6 +93,7 @@ Max_Edicts_f -- johnfitz */ static void Max_Edicts_f (cvar_t *var) { + (void)var; //TODO: clamp it here? if (cls.state == ca_connected || sv.active) Con_Printf ("Changes to max_edicts will not take effect until the next time a map is loaded.\n"); diff --git a/source/in_sdl.c b/source/in_sdl.c index 05470b9..0bf30f3 100644 --- a/source/in_sdl.c +++ b/source/in_sdl.c @@ -83,6 +83,7 @@ static int SDLCALL IN_FilterMouseEvents (const SDL_Event *event) static int SDLCALL IN_SDL2_FilterMouseEvents (void *userdata, SDL_Event *event) { + (void)userdata; return IN_FilterMouseEvents (event); } diff --git a/source/pl_linux.c b/source/linux/pl_linux.c similarity index 100% rename from source/pl_linux.c rename to source/linux/pl_linux.c diff --git a/source/menu.c b/source/menu.c index b33beaf..2dbd131 100644 --- a/source/menu.c +++ b/source/menu.c @@ -2441,6 +2441,7 @@ void M_Search_Draw (void) void M_Search_Key (int key) { + (void)key; } //============================================================================= diff --git a/source/net_dgrm.c b/source/net_dgrm.c index 4a4b4f7..f3df89c 100644 --- a/source/net_dgrm.c +++ b/source/net_dgrm.c @@ -253,6 +253,7 @@ qboolean Datagram_CanSendMessage (qsocket_t *sock) qboolean Datagram_CanSendUnreliableMessage (qsocket_t *sock) { + (void)sock; return true; } @@ -533,6 +534,8 @@ static void Test_Poll (void *unused) int frags; int connectTime; + (void)unused; + net_landriverlevel = testDriver; while (1) @@ -663,6 +666,8 @@ static void Test2_Poll (void *unused) char name[256]; char value[256]; + (void)unused; + net_landriverlevel = test2Driver; name[0] = 0; diff --git a/source/net_loop.c b/source/net_loop.c index 8cb22db..7726941 100644 --- a/source/net_loop.c +++ b/source/net_loop.c @@ -45,11 +45,14 @@ void Loop_Shutdown (void) void Loop_Listen (qboolean state) { + (void)state; } void Loop_SearchForHosts (qboolean xmit) { + (void)xmit; + if (!sv.active) return; @@ -231,6 +234,7 @@ qboolean Loop_CanSendMessage (qsocket_t *sock) qboolean Loop_CanSendUnreliableMessage (qsocket_t *sock) { + (void)sock; return true; } diff --git a/source/net_main.c b/source/net_main.c index bbd599a..490f852 100644 --- a/source/net_main.c +++ b/source/net_main.c @@ -361,6 +361,7 @@ const char *NET_SlistPrintServerName (int idx) static void Slist_Send (void *unused) { + (void)unused; for (net_driverlevel = 0; net_driverlevel < net_numdrivers; net_driverlevel++) { if (!slistLocal && IS_LOOP_DRIVER(net_driverlevel)) @@ -377,6 +378,7 @@ static void Slist_Send (void *unused) static void Slist_Poll (void *unused) { + (void)unused; for (net_driverlevel = 0; net_driverlevel < net_numdrivers; net_driverlevel++) { if (!slistLocal && IS_LOOP_DRIVER(net_driverlevel)) diff --git a/source/pl_osx.m b/source/osx/pl_osx.m similarity index 100% rename from source/pl_osx.m rename to source/osx/pl_osx.m diff --git a/source/r_part.c b/source/r_part.c index a72c4d5..2f1ff4a 100644 --- a/source/r_part.c +++ b/source/r_part.c @@ -124,6 +124,7 @@ R_SetParticleTexture_f -- johnfitz */ static void R_SetParticleTexture_f (cvar_t *var) { + (void)var; switch ((int)(r_particles.value)) { case 1: diff --git a/source/net_bsd.c b/source/unix/net_bsd.c similarity index 100% rename from source/net_bsd.c rename to source/unix/net_bsd.c diff --git a/source/net_udp.c b/source/unix/net_udp.c similarity index 100% rename from source/net_udp.c rename to source/unix/net_udp.c diff --git a/source/net_udp.h b/source/unix/net_udp.h similarity index 100% rename from source/net_udp.h rename to source/unix/net_udp.h diff --git a/source/sys_sdl_unix.c b/source/unix/sys_sdl_unix.c similarity index 100% rename from source/sys_sdl_unix.c rename to source/unix/sys_sdl_unix.c diff --git a/source/net_win.c b/source/windows/net_win.c similarity index 100% rename from source/net_win.c rename to source/windows/net_win.c diff --git a/source/net_wins.c b/source/windows/net_wins.c similarity index 100% rename from source/net_wins.c rename to source/windows/net_wins.c diff --git a/source/net_wins.h b/source/windows/net_wins.h similarity index 100% rename from source/net_wins.h rename to source/windows/net_wins.h diff --git a/source/net_wipx.c b/source/windows/net_wipx.c similarity index 100% rename from source/net_wipx.c rename to source/windows/net_wipx.c diff --git a/source/net_wipx.h b/source/windows/net_wipx.h similarity index 100% rename from source/net_wipx.h rename to source/windows/net_wipx.h diff --git a/source/pl_win.c b/source/windows/pl_win.c similarity index 100% rename from source/pl_win.c rename to source/windows/pl_win.c diff --git a/source/sys_sdl_win.c b/source/windows/sys_sdl_win.c similarity index 100% rename from source/sys_sdl_win.c rename to source/windows/sys_sdl_win.c diff --git a/source/wsaerror.h b/source/windows/wsaerror.h similarity index 100% rename from source/wsaerror.h rename to source/windows/wsaerror.h