Compare commits

...

3 Commits

Author SHA1 Message Date
an a24e23f6d7 fix misc errata 2019-11-25 16:33:54 -05:00
an 2ebc7fb7dd fix errata 2019-11-25 16:20:03 -05:00
an d03dd0c701 replace COMPILE_TIME_ASSERT with _Static_assert 2019-11-25 15:09:21 -05:00
37 changed files with 144 additions and 108 deletions

View File

@ -5,10 +5,6 @@ cmake_policy(SET CMP0071 NEW)
project(agw-quake C) 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(OpenGL REQUIRED)
find_package(PkgConfig REQUIRED) find_package(PkgConfig REQUIRED)
@ -154,26 +150,39 @@ set(srcs
source/wad.h source/wad.h
source/world.c source/world.c
source/world.h source/world.h
source/wsaerror.h
source/zone.c source/zone.c
source/zone.h) source/zone.h)
if(WIN32) set(srcs_linux
list(APPEND srcs source/linux/pl_linux.c)
source/net_win.c
source/net_wins.c set(srcs_osx
source/net_wins.h source/osx/pl_osx.c)
source/net_wipx.c
source/net_wipx.h set(srcs_unix
source/pl_win.c source/unix/net_bsd.c
source/sys_sdl_win.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() else()
list(APPEND srcs message(FATAL_ERROR "platform not supported")
source/net_bsd.c
source/net_udp.c
source/net_udp.h
source/pl_linux.c
source/sys_sdl_unix.c)
endif() endif()
add_executable(quake WIN32 ${srcs}) 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_OPUS Opus)
agw_checked_library(USE_CODEC_MikMod MikMod) agw_checked_library(USE_CODEC_MikMod MikMod)
target_compile_options(quake PUBLIC
$<$<C_COMPILER_ID:AppleClang,Clang,GNU>:
-Wall -Wextra -Werror -Wno-missing-field-initializers>
$<$<C_COMPILER_ID:MSVC>: /W4>)
target_include_directories(quake PUBLIC source)
target_link_libraries(quake m OpenGL::GL PkgConfig::SDL2) target_link_libraries(quake m OpenGL::GL PkgConfig::SDL2)

View File

@ -22,6 +22,7 @@
int CDAudio_Play(byte track, qboolean looping) int CDAudio_Play(byte track, qboolean looping)
{ {
(void)track, (void)looping;
return -1; return -1;
} }

View File

@ -189,8 +189,8 @@ typedef struct mnode_s
mplane_t *plane; mplane_t *plane;
struct mnode_s *children[2]; struct mnode_s *children[2];
unsigned int firstsurface; int firstsurface;
unsigned int numsurfaces; int numsurfaces;
} mnode_t; } mnode_t;

View File

@ -58,6 +58,7 @@ GL_Overbright_f -- johnfitz
*/ */
static void GL_Overbright_f (cvar_t *var) static void GL_Overbright_f (cvar_t *var)
{ {
(void)var;
R_RebuildAllLightmaps (); R_RebuildAllLightmaps ();
} }
@ -68,6 +69,7 @@ GL_Fullbrights_f -- johnfitz
*/ */
static void GL_Fullbrights_f (cvar_t *var) static void GL_Fullbrights_f (cvar_t *var)
{ {
(void)var;
TexMgr_ReloadNobrightImages (); TexMgr_ReloadNobrightImages ();
} }
@ -81,6 +83,7 @@ static void R_SetClearColor_f (cvar_t *var)
byte *rgb; byte *rgb;
int s; int s;
(void)var;
s = (int)r_clearcolor.value & 0xFF; s = (int)r_clearcolor.value & 0xFF;
rgb = (byte*)(d_8to24table + s); rgb = (byte*)(d_8to24table + s);
glClearColor (rgb[0]/255.0,rgb[1]/255.0,rgb[2]/255.0,0); 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) static void R_VisChanged (cvar_t *var)
{ {
extern int vis_changed; extern int vis_changed;
(void)var;
vis_changed = 1; 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) static void R_Model_ExtraFlags_List_f (cvar_t *var)
{ {
(void)var;
int i; int i;
for (i=0; i < MAX_MODELS; i++) for (i=0; i < MAX_MODELS; i++)
Mod_SetExtraFlags (cl.model_precache[i]); Mod_SetExtraFlags (cl.model_precache[i]);
@ -462,7 +467,7 @@ static qboolean GL_CheckShader (GLuint shader)
memset(infolog, 0, sizeof(infolog)); memset(infolog, 0, sizeof(infolog));
GL_GetShaderInfoLogFunc (shader, sizeof(infolog), NULL, infolog); GL_GetShaderInfoLogFunc (shader, sizeof(infolog), NULL, infolog);
Con_Warning ("GLSL program failed to compile: %s", infolog); Con_Warning ("GLSL program failed to compile: %s", infolog);
return false; return false;
@ -549,12 +554,12 @@ GLuint GL_CreateProgram (const GLchar *vertSource, const GLchar *fragSource, int
GL_DeleteShaderFunc (vertShader); GL_DeleteShaderFunc (vertShader);
GL_AttachShaderFunc (program, fragShader); GL_AttachShaderFunc (program, fragShader);
GL_DeleteShaderFunc (fragShader); GL_DeleteShaderFunc (fragShader);
for (i = 0; i < numbindings; i++) for (i = 0; i < numbindings; i++)
{ {
GL_BindAttribLocationFunc (program, bindings[i].attrib, bindings[i].name); GL_BindAttribLocationFunc (program, bindings[i].attrib, bindings[i].name);
} }
GL_LinkProgramFunc (program); GL_LinkProgramFunc (program);
if (!GL_CheckProgram (program)) if (!GL_CheckProgram (program))
@ -610,7 +615,7 @@ void GL_BindBuffer (GLenum target, GLuint buffer)
if (!gl_vbo_able) if (!gl_vbo_able)
return; return;
switch (target) switch (target)
{ {
case GL_ARRAY_BUFFER: case GL_ARRAY_BUFFER:
@ -623,7 +628,7 @@ void GL_BindBuffer (GLenum target, GLuint buffer)
Host_Error("GL_BindBuffer: unsupported target %d", (int)target); Host_Error("GL_BindBuffer: unsupported target %d", (int)target);
return; return;
} }
if (*cache != buffer) if (*cache != buffer)
{ {
*cache = buffer; *cache = buffer;

View File

@ -357,6 +357,7 @@ void SCR_SizeDown_f (void)
static void SCR_Callback_refdef (cvar_t *var) static void SCR_Callback_refdef (cvar_t *var)
{ {
(void)var;
vid.recalc_refdef = 1; 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 SCR_Conwidth_f (cvar_t *var)
{ {
(void)var;
vid.recalc_refdef = 1; 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 = (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); vid.conwidth = CLAMP (320, vid.conwidth, vid.width);
@ -805,7 +807,7 @@ void SCR_ScreenShot_f (void)
SCR_ScreenShot_Usage (); SCR_ScreenShot_Usage ();
return; return;
} }
// find a file name to save it to // find a file name to save it to
for (i=0; i<10000; i++) for (i=0; i<10000; i++)
{ {

View File

@ -129,6 +129,8 @@ static void TexMgr_TextureMode_f (cvar_t *var)
gltexture_t *glt; gltexture_t *glt;
int i; int i;
(void)var;
for (i = 0; i < NUM_GLMODES; i++) for (i = 0; i < NUM_GLMODES; i++)
{ {
if (!Q_strcmp (glmodes[i].name, gl_texturemode.string)) 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) static void TexMgr_Anisotropy_f (cvar_t *var)
{ {
(void)var;
if (gl_texture_anisotropy.value < 1) if (gl_texture_anisotropy.value < 1)
{ {
Cvar_SetQuick (&gl_texture_anisotropy, "1"); Cvar_SetQuick (&gl_texture_anisotropy, "1");
@ -359,7 +362,7 @@ void TexMgr_FreeTexture (gltexture_t *kill)
if (in_reload_images) if (in_reload_images)
return; return;
if (kill == NULL) if (kill == NULL)
{ {
Con_Printf ("TexMgr_FreeTexture: NULL texture\n"); Con_Printf ("TexMgr_FreeTexture: NULL texture\n");
@ -573,7 +576,7 @@ void TexMgr_RecalcWarpImageSize (void)
// after vid_restart TexMgr_ReloadImage reloads textures // after vid_restart TexMgr_ReloadImage reloads textures
// to tx->source_width/source_height, which might not match oldsize. // to tx->source_width/source_height, which might not match oldsize.
// fixes: https://sourceforge.net/p/quakespasm/bugs/13/ // fixes: https://sourceforge.net/p/quakespasm/bugs/13/
// //
// resize the textures in opengl // resize the textures in opengl
// //
@ -1414,7 +1417,7 @@ void TexMgr_ReloadImages (void)
glGenTextures(1, &glt->texnum); glGenTextures(1, &glt->texnum);
TexMgr_ReloadImage (glt, -1, -1); TexMgr_ReloadImage (glt, -1, -1);
} }
in_reload_images = false; in_reload_images = false;
} }
@ -1453,7 +1456,7 @@ void GL_SelectTexture (GLenum target)
{ {
if (target == currenttarget) if (target == currenttarget)
return; return;
GL_SelectTextureFunc(target); GL_SelectTextureFunc(target);
currenttarget = target; currenttarget = target;
} }
@ -1528,7 +1531,7 @@ static void GL_DeleteTexture (gltexture_t *texture)
/* /*
================ ================
GL_ClearBindings -- ericw GL_ClearBindings -- ericw
Invalidates cached bindings, so the next GL_Bind calls for each TMU will Invalidates cached bindings, so the next GL_Bind calls for each TMU will
make real glBindTexture calls. make real glBindTexture calls.
Call this after changing the binding outside of GL_Bind. Call this after changing the binding outside of GL_Bind.

View File

@ -237,6 +237,7 @@ VID_Gamma_f -- callback when the cvar changes
*/ */
static void VID_Gamma_f (cvar_t *var) static void VID_Gamma_f (cvar_t *var)
{ {
(void)var;
if (gl_glsl_gamma_able) if (gl_glsl_gamma_able)
return; 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) static void VID_Changed_f (cvar_t *var)
{ {
(void)var;
vid_changed = true; vid_changed = true;
} }

View File

@ -93,6 +93,7 @@ Max_Edicts_f -- johnfitz
*/ */
static void Max_Edicts_f (cvar_t *var) static void Max_Edicts_f (cvar_t *var)
{ {
(void)var;
//TODO: clamp it here? //TODO: clamp it here?
if (cls.state == ca_connected || sv.active) 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"); Con_Printf ("Changes to max_edicts will not take effect until the next time a map is loaded.\n");

View File

@ -83,6 +83,7 @@ static int SDLCALL IN_FilterMouseEvents (const SDL_Event *event)
static int SDLCALL IN_SDL2_FilterMouseEvents (void *userdata, SDL_Event *event) static int SDLCALL IN_SDL2_FilterMouseEvents (void *userdata, SDL_Event *event)
{ {
(void)userdata;
return IN_FilterMouseEvents (event); return IN_FilterMouseEvents (event);
} }

View File

@ -76,5 +76,6 @@ char *PL_GetClipboardData (void)
void PL_ErrorDialog (const char *errorMsg) void PL_ErrorDialog (const char *errorMsg)
{ {
(void)errorMsg;
} }

View File

@ -2441,6 +2441,7 @@ void M_Search_Draw (void)
void M_Search_Key (int key) void M_Search_Key (int key)
{ {
(void)key;
} }
//============================================================================= //=============================================================================

View File

@ -253,6 +253,7 @@ qboolean Datagram_CanSendMessage (qsocket_t *sock)
qboolean Datagram_CanSendUnreliableMessage (qsocket_t *sock) qboolean Datagram_CanSendUnreliableMessage (qsocket_t *sock)
{ {
(void)sock;
return true; return true;
} }
@ -533,6 +534,8 @@ static void Test_Poll (void *unused)
int frags; int frags;
int connectTime; int connectTime;
(void)unused;
net_landriverlevel = testDriver; net_landriverlevel = testDriver;
while (1) while (1)
@ -663,6 +666,8 @@ static void Test2_Poll (void *unused)
char name[256]; char name[256];
char value[256]; char value[256];
(void)unused;
net_landriverlevel = test2Driver; net_landriverlevel = test2Driver;
name[0] = 0; name[0] = 0;

View File

@ -45,11 +45,14 @@ void Loop_Shutdown (void)
void Loop_Listen (qboolean state) void Loop_Listen (qboolean state)
{ {
(void)state;
} }
void Loop_SearchForHosts (qboolean xmit) void Loop_SearchForHosts (qboolean xmit)
{ {
(void)xmit;
if (!sv.active) if (!sv.active)
return; return;
@ -231,6 +234,7 @@ qboolean Loop_CanSendMessage (qsocket_t *sock)
qboolean Loop_CanSendUnreliableMessage (qsocket_t *sock) qboolean Loop_CanSendUnreliableMessage (qsocket_t *sock)
{ {
(void)sock;
return true; return true;
} }

View File

@ -361,6 +361,7 @@ const char *NET_SlistPrintServerName (int idx)
static void Slist_Send (void *unused) static void Slist_Send (void *unused)
{ {
(void)unused;
for (net_driverlevel = 0; net_driverlevel < net_numdrivers; net_driverlevel++) for (net_driverlevel = 0; net_driverlevel < net_numdrivers; net_driverlevel++)
{ {
if (!slistLocal && IS_LOOP_DRIVER(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) static void Slist_Poll (void *unused)
{ {
(void)unused;
for (net_driverlevel = 0; net_driverlevel < net_numdrivers; net_driverlevel++) for (net_driverlevel = 0; net_driverlevel < net_numdrivers; net_driverlevel++)
{ {
if (!slistLocal && IS_LOOP_DRIVER(net_driverlevel)) if (!slistLocal && IS_LOOP_DRIVER(net_driverlevel))

View File

@ -81,8 +81,8 @@ typedef int socklen_t; /* defining as signed int to match the old api */
#define socketerror(x) strerror((x)) #define socketerror(x) strerror((x))
/* Verify that we defined HAVE_SA_LEN correctly: */ _Static_assert(offsetof(struct sockaddr, sa_family) == SA_FAM_OFFSET,
COMPILE_TIME_ASSERT(sockaddr, offsetof(struct sockaddr, sa_family) == SA_FAM_OFFSET); "HAVE_SA_LEN not defined correctly");
#endif /* end of unix stuff */ #endif /* end of unix stuff */
@ -133,8 +133,8 @@ typedef unsigned int in_addr_t; /* u_int32_t */
/* there is h_errno but no hstrerror() */ /* there is h_errno but no hstrerror() */
#define hstrerror(x) strerror((x)) #define hstrerror(x) strerror((x))
/* Verify that we defined HAVE_SA_LEN correctly: */ _Static_assert(offsetof(struct sockaddr, sa_family) == SA_FAM_OFFSET,
COMPILE_TIME_ASSERT(sockaddr, offsetof(struct sockaddr, sa_family) == SA_FAM_OFFSET); "HAVE_SA_LEN not defined correctly");
#endif /* end of amiga bsdsocket.library stuff */ #endif /* end of amiga bsdsocket.library stuff */
@ -170,8 +170,8 @@ typedef SOCKET sys_socket_t;
/* must #include "wsaerror.h" for this : */ /* must #include "wsaerror.h" for this : */
#define socketerror(x) __WSAE_StrError((x)) #define socketerror(x) __WSAE_StrError((x))
/* Verify that we defined HAVE_SA_LEN correctly: */ _Static_assert(offsetof(struct sockaddr, sa_family) == SA_FAM_OFFSET,
COMPILE_TIME_ASSERT(sockaddr, offsetof(struct sockaddr, sa_family) == SA_FAM_OFFSET); "HAVE_SA_LEN not defined correctly");
#endif /* end of windows stuff */ #endif /* end of windows stuff */

View File

@ -67,14 +67,6 @@
/*==========================================================================*/ /*==========================================================================*/
#ifndef NULL
#if defined(__cplusplus)
#define NULL 0
#else
#define NULL ((void *)0)
#endif
#endif
#define Q_MAXCHAR ((char)0x7f) #define Q_MAXCHAR ((char)0x7f)
#define Q_MAXSHORT ((short)0x7fff) #define Q_MAXSHORT ((short)0x7fff)
#define Q_MAXINT ((int)0x7fffffff) #define Q_MAXINT ((int)0x7fffffff)
@ -90,20 +82,17 @@
/* Make sure the types really have the right /* Make sure the types really have the right
* sizes: These macros are from SDL headers. * sizes: These macros are from SDL headers.
*/ */
#define COMPILE_TIME_ASSERT(name, x) \ _Static_assert(sizeof(char) == 1, "char not correct size");
typedef int dummy_ ## name[(x) * 2 - 1] _Static_assert(sizeof(float) == 4, "float not correct size");
_Static_assert(sizeof(long) >= 4, "long not correct size");
COMPILE_TIME_ASSERT(char, sizeof(char) == 1); _Static_assert(sizeof(int) == 4, "int not correct size");
COMPILE_TIME_ASSERT(float, sizeof(float) == 4); _Static_assert(sizeof(short) == 2, "short not correct size");
COMPILE_TIME_ASSERT(long, sizeof(long) >= 4);
COMPILE_TIME_ASSERT(int, sizeof(int) == 4);
COMPILE_TIME_ASSERT(short, sizeof(short) == 2);
/* make sure enums are the size of ints for structure packing */ /* make sure enums are the size of ints for structure packing */
typedef enum { typedef enum {
THE_DUMMY_VALUE THE_DUMMY_VALUE
} THE_DUMMY_ENUM; } THE_DUMMY_ENUM;
COMPILE_TIME_ASSERT(enum, sizeof(THE_DUMMY_ENUM) == sizeof(int)); _Static_assert(sizeof(THE_DUMMY_ENUM) == sizeof(int), "enum not sizeof(int)");
/* Provide a substitute for offsetof() if we don't have one. /* Provide a substitute for offsetof() if we don't have one.
@ -118,24 +107,10 @@ COMPILE_TIME_ASSERT(enum, sizeof(THE_DUMMY_ENUM) == sizeof(int));
typedef unsigned char byte; typedef unsigned char byte;
#undef true
#undef false
#if defined(__cplusplus)
/* some structures have qboolean members and the x86 asm code expect
* those members to be 4 bytes long. therefore, qboolean must be 32
* bits and it can NOT be binary compatible with the 8 bit C++ bool. */
typedef int qboolean;
COMPILE_TIME_ASSERT(falsehood, (0 == false));
COMPILE_TIME_ASSERT(truth, (1 == true));
#else
typedef enum { typedef enum {
false = 0, false = 0,
true = 1 true = 1
} qboolean; } qboolean;
COMPILE_TIME_ASSERT(falsehood, ((1 != 1) == false));
COMPILE_TIME_ASSERT(truth, ((1 == 1) == true));
#endif
COMPILE_TIME_ASSERT(qboolean, sizeof(qboolean) == 4);
/*==========================================================================*/ /*==========================================================================*/

View File

@ -124,6 +124,7 @@ R_SetParticleTexture_f -- johnfitz
*/ */
static void R_SetParticleTexture_f (cvar_t *var) static void R_SetParticleTexture_f (cvar_t *var)
{ {
(void)var;
switch ((int)(r_particles.value)) switch ((int)(r_particles.value))
{ {
case 1: case 1:

View File

@ -40,7 +40,7 @@ int vis_changed; //if true, force pvs to be refreshed
/* /*
================ ================
R_ClearTextureChains -- ericw R_ClearTextureChains -- ericw
clears texture chains for all textures used by the given model, and also clears texture chains for all textures used by the given model, and also
clears the lightmap chains clears the lightmap chains
@ -54,7 +54,7 @@ void R_ClearTextureChains (qmodel_t *mod, texchain_t chain)
for (i=0 ; i<mod->numtextures ; i++) for (i=0 ; i<mod->numtextures ; i++)
if (mod->textures[i]) if (mod->textures[i])
mod->textures[i]->texturechains[chain] = NULL; mod->textures[i]->texturechains[chain] = NULL;
// clear lightmap chains // clear lightmap chains
memset (lightmap_polys, 0, sizeof(lightmap_polys)); memset (lightmap_polys, 0, sizeof(lightmap_polys));
} }
@ -237,7 +237,7 @@ void R_CullSurfaces (void)
================ ================
R_BuildLightmapChains -- johnfitz -- used for r_lightmap 1 R_BuildLightmapChains -- johnfitz -- used for r_lightmap 1
ericw -- now always used at the start of R_DrawTextureChains for the ericw -- now always used at the start of R_DrawTextureChains for the
mh dynamic lighting speedup mh dynamic lighting speedup
================ ================
*/ */
@ -496,10 +496,10 @@ static void R_BatchSurface (msurface_t *s)
int num_surf_indices; int num_surf_indices;
num_surf_indices = R_NumTriangleIndicesForSurf (s); num_surf_indices = R_NumTriangleIndicesForSurf (s);
if (num_vbo_indices + num_surf_indices > MAX_BATCH_SIZE) if (num_vbo_indices + num_surf_indices > MAX_BATCH_SIZE)
R_FlushBatch(); R_FlushBatch();
R_TriangleIndicesForSurf (s, &vbo_indices[num_vbo_indices]); R_TriangleIndicesForSurf (s, &vbo_indices[num_vbo_indices]);
num_vbo_indices += num_surf_indices; num_vbo_indices += num_surf_indices;
} }
@ -531,10 +531,10 @@ void R_DrawTextureChains_Multitexture (qmodel_t *model, entity_t *ent, texchain_
if (!bound) //only bind once we are sure we need this texture if (!bound) //only bind once we are sure we need this texture
{ {
GL_Bind ((R_TextureAnimation(t, ent != NULL ? ent->frame : 0))->gltexture); GL_Bind ((R_TextureAnimation(t, ent != NULL ? ent->frame : 0))->gltexture);
if (t->texturechains[chain]->flags & SURF_DRAWFENCE) if (t->texturechains[chain]->flags & SURF_DRAWFENCE)
glEnable (GL_ALPHA_TEST); // Flip alpha test back on glEnable (GL_ALPHA_TEST); // Flip alpha test back on
GL_EnableMultitexture(); // selects TEXTURE1 GL_EnableMultitexture(); // selects TEXTURE1
bound = true; bound = true;
} }
@ -621,16 +621,16 @@ void R_DrawTextureChains_TextureOnly (qmodel_t *model, entity_t *ent, texchain_t
if (!bound) //only bind once we are sure we need this texture if (!bound) //only bind once we are sure we need this texture
{ {
GL_Bind ((R_TextureAnimation(t, ent != NULL ? ent->frame : 0))->gltexture); GL_Bind ((R_TextureAnimation(t, ent != NULL ? ent->frame : 0))->gltexture);
if (t->texturechains[chain]->flags & SURF_DRAWFENCE) if (t->texturechains[chain]->flags & SURF_DRAWFENCE)
glEnable (GL_ALPHA_TEST); // Flip alpha test back on glEnable (GL_ALPHA_TEST); // Flip alpha test back on
bound = true; bound = true;
} }
DrawGLPoly (s->polys); DrawGLPoly (s->polys);
rs_brushpasses++; rs_brushpasses++;
} }
if (bound && t->texturechains[chain]->flags & SURF_DRAWFENCE) if (bound && t->texturechains[chain]->flags & SURF_DRAWFENCE)
glDisable (GL_ALPHA_TEST); // Flip alpha test back off glDisable (GL_ALPHA_TEST); // Flip alpha test back off
} }
@ -639,7 +639,7 @@ void R_DrawTextureChains_TextureOnly (qmodel_t *model, entity_t *ent, texchain_t
/* /*
================ ================
GL_WaterAlphaForEntitySurface -- ericw GL_WaterAlphaForEntitySurface -- ericw
Returns the water alpha to use for the entity and surface combination. Returns the water alpha to use for the entity and surface combination.
================ ================
*/ */
@ -824,7 +824,7 @@ void GLWorld_CreateShaders (void)
{ "TexCoords", texCoordsAttrIndex }, { "TexCoords", texCoordsAttrIndex },
{ "LMCoords", LMCoordsAttrIndex } { "LMCoords", LMCoordsAttrIndex }
}; };
const GLchar *vertSource = \ const GLchar *vertSource = \
"#version 110\n" "#version 110\n"
"\n" "\n"
@ -841,7 +841,7 @@ void GLWorld_CreateShaders (void)
" gl_Position = gl_ModelViewProjectionMatrix * vec4(Vert, 1.0);\n" " gl_Position = gl_ModelViewProjectionMatrix * vec4(Vert, 1.0);\n"
" FogFragCoord = gl_Position.w;\n" " FogFragCoord = gl_Position.w;\n"
"}\n"; "}\n";
const GLchar *fragSource = \ const GLchar *fragSource = \
"#version 110\n" "#version 110\n"
"\n" "\n"
@ -872,12 +872,12 @@ void GLWorld_CreateShaders (void)
" result.a = Alpha;\n" // FIXME: This will make almost transparent things cut holes though heavy fog " result.a = Alpha;\n" // FIXME: This will make almost transparent things cut holes though heavy fog
" gl_FragColor = result;\n" " gl_FragColor = result;\n"
"}\n"; "}\n";
if (!gl_glsl_alias_able) if (!gl_glsl_alias_able)
return; return;
r_world_program = GL_CreateProgram (vertSource, fragSource, sizeof(bindings)/sizeof(bindings[0]), bindings); r_world_program = GL_CreateProgram (vertSource, fragSource, sizeof(bindings)/sizeof(bindings[0]), bindings);
if (r_world_program != 0) if (r_world_program != 0)
{ {
// get uniform locations // get uniform locations
@ -910,7 +910,7 @@ void R_DrawTextureChains_GLSL (qmodel_t *model, entity_t *ent, texchain_t chain)
int lastlightmap; int lastlightmap;
gltexture_t *fullbright = NULL; gltexture_t *fullbright = NULL;
float entalpha; float entalpha;
entalpha = (ent != NULL) ? ENTALPHA_DECODE(ent->alpha) : 1.0f; entalpha = (ent != NULL) ? ENTALPHA_DECODE(ent->alpha) : 1.0f;
// enable blending / disable depth writes // enable blending / disable depth writes
@ -919,9 +919,9 @@ void R_DrawTextureChains_GLSL (qmodel_t *model, entity_t *ent, texchain_t chain)
glDepthMask (GL_FALSE); glDepthMask (GL_FALSE);
glEnable (GL_BLEND); glEnable (GL_BLEND);
} }
GL_UseProgramFunc (r_world_program); GL_UseProgramFunc (r_world_program);
// Bind the buffers // Bind the buffers
GL_BindBuffer (GL_ARRAY_BUFFER, gl_bmodel_vbo); GL_BindBuffer (GL_ARRAY_BUFFER, gl_bmodel_vbo);
GL_BindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0); // indices come from client memory! GL_BindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0); // indices come from client memory!
@ -929,11 +929,11 @@ void R_DrawTextureChains_GLSL (qmodel_t *model, entity_t *ent, texchain_t chain)
GL_EnableVertexAttribArrayFunc (vertAttrIndex); GL_EnableVertexAttribArrayFunc (vertAttrIndex);
GL_EnableVertexAttribArrayFunc (texCoordsAttrIndex); GL_EnableVertexAttribArrayFunc (texCoordsAttrIndex);
GL_EnableVertexAttribArrayFunc (LMCoordsAttrIndex); GL_EnableVertexAttribArrayFunc (LMCoordsAttrIndex);
GL_VertexAttribPointerFunc (vertAttrIndex, 3, GL_FLOAT, GL_FALSE, VERTEXSIZE * sizeof(float), ((float *)0)); GL_VertexAttribPointerFunc (vertAttrIndex, 3, GL_FLOAT, GL_FALSE, VERTEXSIZE * sizeof(float), &((float *)NULL)[0]);
GL_VertexAttribPointerFunc (texCoordsAttrIndex, 2, GL_FLOAT, GL_FALSE, VERTEXSIZE * sizeof(float), ((float *)0) + 3); GL_VertexAttribPointerFunc (texCoordsAttrIndex, 2, GL_FLOAT, GL_FALSE, VERTEXSIZE * sizeof(float), &((float *)NULL)[3]);
GL_VertexAttribPointerFunc (LMCoordsAttrIndex, 2, GL_FLOAT, GL_FALSE, VERTEXSIZE * sizeof(float), ((float *)0) + 5); GL_VertexAttribPointerFunc (LMCoordsAttrIndex, 2, GL_FLOAT, GL_FALSE, VERTEXSIZE * sizeof(float), &((float *)NULL)[3 + 2]);
// set uniforms // set uniforms
GL_Uniform1iFunc (texLoc, 0); GL_Uniform1iFunc (texLoc, 0);
GL_Uniform1iFunc (LMTexLoc, 1); GL_Uniform1iFunc (LMTexLoc, 1);
@ -942,7 +942,7 @@ void R_DrawTextureChains_GLSL (qmodel_t *model, entity_t *ent, texchain_t chain)
GL_Uniform1iFunc (useOverbrightLoc, (int)gl_overbright.value); GL_Uniform1iFunc (useOverbrightLoc, (int)gl_overbright.value);
GL_Uniform1iFunc (useAlphaTestLoc, 0); GL_Uniform1iFunc (useAlphaTestLoc, 0);
GL_Uniform1fFunc (alphaLoc, entalpha); GL_Uniform1fFunc (alphaLoc, entalpha);
for (i=0 ; i<model->numtextures ; i++) for (i=0 ; i<model->numtextures ; i++)
{ {
t = model->textures[i]; t = model->textures[i];
@ -972,14 +972,14 @@ void R_DrawTextureChains_GLSL (qmodel_t *model, entity_t *ent, texchain_t chain)
{ {
GL_SelectTexture (GL_TEXTURE0); GL_SelectTexture (GL_TEXTURE0);
GL_Bind ((R_TextureAnimation(t, ent != NULL ? ent->frame : 0))->gltexture); GL_Bind ((R_TextureAnimation(t, ent != NULL ? ent->frame : 0))->gltexture);
if (t->texturechains[chain]->flags & SURF_DRAWFENCE) if (t->texturechains[chain]->flags & SURF_DRAWFENCE)
GL_Uniform1iFunc (useAlphaTestLoc, 1); // Flip alpha test back on GL_Uniform1iFunc (useAlphaTestLoc, 1); // Flip alpha test back on
bound = true; bound = true;
lastlightmap = s->lightmaptexturenum; lastlightmap = s->lightmaptexturenum;
} }
if (s->lightmaptexturenum != lastlightmap) if (s->lightmaptexturenum != lastlightmap)
R_FlushBatch (); R_FlushBatch ();
@ -996,15 +996,15 @@ void R_DrawTextureChains_GLSL (qmodel_t *model, entity_t *ent, texchain_t chain)
if (bound && t->texturechains[chain]->flags & SURF_DRAWFENCE) if (bound && t->texturechains[chain]->flags & SURF_DRAWFENCE)
GL_Uniform1iFunc (useAlphaTestLoc, 0); // Flip alpha test back off GL_Uniform1iFunc (useAlphaTestLoc, 0); // Flip alpha test back off
} }
// clean up // clean up
GL_DisableVertexAttribArrayFunc (vertAttrIndex); GL_DisableVertexAttribArrayFunc (vertAttrIndex);
GL_DisableVertexAttribArrayFunc (texCoordsAttrIndex); GL_DisableVertexAttribArrayFunc (texCoordsAttrIndex);
GL_DisableVertexAttribArrayFunc (LMCoordsAttrIndex); GL_DisableVertexAttribArrayFunc (LMCoordsAttrIndex);
GL_UseProgramFunc (0); GL_UseProgramFunc (0);
GL_SelectTexture (GL_TEXTURE0); GL_SelectTexture (GL_TEXTURE0);
if (entalpha < 1) if (entalpha < 1)
{ {
glDepthMask (GL_TRUE); glDepthMask (GL_TRUE);
@ -1020,7 +1020,7 @@ R_DrawWorld -- johnfitz -- rewritten
void R_DrawTextureChains (qmodel_t *model, entity_t *ent, texchain_t chain) void R_DrawTextureChains (qmodel_t *model, entity_t *ent, texchain_t chain)
{ {
float entalpha; float entalpha;
if (ent != NULL) if (ent != NULL)
entalpha = ENTALPHA_DECODE(ent->alpha); entalpha = ENTALPHA_DECODE(ent->alpha);
else else
@ -1075,7 +1075,7 @@ void R_DrawTextureChains (qmodel_t *model, entity_t *ent, texchain_t chain)
if (r_world_program != 0) if (r_world_program != 0)
{ {
R_EndTransparentDrawing (entalpha); R_EndTransparentDrawing (entalpha);
R_DrawTextureChains_GLSL (model, ent, chain); R_DrawTextureChains_GLSL (model, ent, chain);
return; return;
} }

View File

@ -116,11 +116,13 @@ static void S_SoundInfo_f (void)
static void SND_Callback_sfxvolume (cvar_t *var) static void SND_Callback_sfxvolume (cvar_t *var)
{ {
(void)var;
SND_InitScaletable (); SND_InitScaletable ();
} }
static void SND_Callback_snd_filterquality (cvar_t *var) static void SND_Callback_snd_filterquality (cvar_t *var)
{ {
(void)var;
if (snd_filterquality.value < 1 || snd_filterquality.value > 5) if (snd_filterquality.value < 1 || snd_filterquality.value > 5)
{ {
Con_Printf ("snd_filterquality must be between 1 and 5\n"); Con_Printf ("snd_filterquality must be between 1 and 5\n");
@ -182,7 +184,7 @@ void S_Init (void)
Cvar_RegisterVariable(&sndspeed); Cvar_RegisterVariable(&sndspeed);
Cvar_RegisterVariable(&snd_mixspeed); Cvar_RegisterVariable(&snd_mixspeed);
Cvar_RegisterVariable(&snd_filterquality); Cvar_RegisterVariable(&snd_filterquality);
if (safemode || COM_CheckParm("-nosound")) if (safemode || COM_CheckParm("-nosound"))
return; return;
@ -199,7 +201,7 @@ void S_Init (void)
{ {
Cvar_SetQuick (&sndspeed, com_argv[i+1]); Cvar_SetQuick (&sndspeed, com_argv[i+1]);
} }
i = COM_CheckParm("-mixspeed"); i = COM_CheckParm("-mixspeed");
if (i && i < com_argc-1) if (i && i < com_argc-1)
{ {

View File

@ -80,6 +80,7 @@ static void
flac_error_func (const FLAC__StreamDecoder *decoder, flac_error_func (const FLAC__StreamDecoder *decoder,
FLAC__StreamDecoderErrorStatus status, void *client_data) FLAC__StreamDecoderErrorStatus status, void *client_data)
{ {
(void)decoder;
flacfile_t *ff = (flacfile_t *) client_data; flacfile_t *ff = (flacfile_t *) client_data;
ff->error = -1; ff->error = -1;
Con_Printf ("FLAC: decoder error %i\n", status); Con_Printf ("FLAC: decoder error %i\n", status);
@ -90,6 +91,7 @@ flac_read_func (const FLAC__StreamDecoder *decoder, FLAC__byte buffer[],
FLAC_SIZE_T *bytes, void *client_data) FLAC_SIZE_T *bytes, void *client_data)
{ {
flacfile_t *ff = (flacfile_t *) client_data; flacfile_t *ff = (flacfile_t *) client_data;
(void)decoder;
if (*bytes > 0) if (*bytes > 0)
{ {
*bytes = FS_fread(buffer, 1, *bytes, ff->file); *bytes = FS_fread(buffer, 1, *bytes, ff->file);
@ -107,6 +109,7 @@ flac_seek_func (const FLAC__StreamDecoder *decoder,
FLAC__uint64 absolute_byte_offset, void *client_data) FLAC__uint64 absolute_byte_offset, void *client_data)
{ {
flacfile_t *ff = (flacfile_t *) client_data; flacfile_t *ff = (flacfile_t *) client_data;
(void)decoder;
if (FS_fseek(ff->file, (long)absolute_byte_offset, SEEK_SET) < 0) if (FS_fseek(ff->file, (long)absolute_byte_offset, SEEK_SET) < 0)
return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR; return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR;
return FLAC__STREAM_DECODER_SEEK_STATUS_OK; return FLAC__STREAM_DECODER_SEEK_STATUS_OK;
@ -118,6 +121,7 @@ flac_tell_func (const FLAC__StreamDecoder *decoder,
{ {
flacfile_t *ff = (flacfile_t *) client_data; flacfile_t *ff = (flacfile_t *) client_data;
long pos = FS_ftell (ff->file); long pos = FS_ftell (ff->file);
(void)decoder;
if (pos < 0) return FLAC__STREAM_DECODER_TELL_STATUS_ERROR; if (pos < 0) return FLAC__STREAM_DECODER_TELL_STATUS_ERROR;
*absolute_byte_offset = (FLAC__uint64) pos; *absolute_byte_offset = (FLAC__uint64) pos;
return FLAC__STREAM_DECODER_TELL_STATUS_OK; return FLAC__STREAM_DECODER_TELL_STATUS_OK;
@ -128,6 +132,7 @@ flac_length_func (const FLAC__StreamDecoder *decoder,
FLAC__uint64 *stream_length, void *client_data) FLAC__uint64 *stream_length, void *client_data)
{ {
flacfile_t *ff = (flacfile_t *) client_data; flacfile_t *ff = (flacfile_t *) client_data;
(void)decoder;
*stream_length = (FLAC__uint64) FS_filelength (ff->file); *stream_length = (FLAC__uint64) FS_filelength (ff->file);
return FLAC__STREAM_DECODER_LENGTH_STATUS_OK; return FLAC__STREAM_DECODER_LENGTH_STATUS_OK;
} }
@ -136,6 +141,7 @@ static FLAC__bool
flac_eof_func (const FLAC__StreamDecoder *decoder, void *client_data) flac_eof_func (const FLAC__StreamDecoder *decoder, void *client_data)
{ {
flacfile_t *ff = (flacfile_t *) client_data; flacfile_t *ff = (flacfile_t *) client_data;
(void)decoder;
if (FS_feof (ff->file)) return true; if (FS_feof (ff->file)) return true;
return false; return false;
} }
@ -146,6 +152,7 @@ flac_write_func (const FLAC__StreamDecoder *decoder,
void *client_data) void *client_data)
{ {
flacfile_t *ff = (flacfile_t *) client_data; flacfile_t *ff = (flacfile_t *) client_data;
(void)decoder;
if (!ff->buffer) { if (!ff->buffer) {
ff->buffer = (byte *) malloc (ff->info->blocksize * ff->info->channels * ff->info->width); ff->buffer = (byte *) malloc (ff->info->blocksize * ff->info->channels * ff->info->width);
@ -212,6 +219,7 @@ flac_meta_func (const FLAC__StreamDecoder *decoder,
const FLAC__StreamMetadata *metadata, void *client_data) const FLAC__StreamMetadata *metadata, void *client_data)
{ {
flacfile_t *ff = (flacfile_t *) client_data; flacfile_t *ff = (flacfile_t *) client_data;
(void)decoder;
if (metadata->type == FLAC__METADATA_TYPE_STREAMINFO) if (metadata->type == FLAC__METADATA_TYPE_STREAMINFO)
{ {
ff->info->rate = metadata->data.stream_info.sample_rate; ff->info->rate = metadata->data.stream_info.sample_rate;

View File

@ -36,6 +36,7 @@
static int opc_fclose (void *f) static int opc_fclose (void *f)
{ {
(void)f;
return 0; /* we fclose() elsewhere. */ return 0; /* we fclose() elsewhere. */
} }

View File

@ -34,6 +34,8 @@ static void SDLCALL paint_audio (void *unused, Uint8 *stream, int len)
int pos, tobufend; int pos, tobufend;
int len1, len2; int len1, len2;
(void)unused;
if (!shm) if (!shm)
{ /* shouldn't happen, but just in case */ { /* shouldn't happen, but just in case */
memset(stream, 0, len); memset(stream, 0, len);

View File

@ -64,8 +64,8 @@ struct upkg_hdr {
#define UPKG_HDR_SIZE 64 /* 64 bytes up until here */ #define UPKG_HDR_SIZE 64 /* 64 bytes up until here */
/*struct _genhist *gen;*/ /*struct _genhist *gen;*/
}; };
/*COMPILE_TIME_ASSERT(upkg_hdr, offsetof(struct upkg_hdr, gen) == UPKG_HDR_SIZE);*/ _Static_assert(sizeof(struct upkg_hdr) == UPKG_HDR_SIZE,
COMPILE_TIME_ASSERT(upkg_hdr, sizeof(struct upkg_hdr) == UPKG_HDR_SIZE); "upkg_hdr not correct size");
#define UMUSIC_IT 0 #define UMUSIC_IT 0
#define UMUSIC_S3M 1 #define UMUSIC_S3M 1
@ -375,6 +375,7 @@ static qboolean S_UMX_CodecOpenStream (snd_stream_t *stream)
static int S_UMX_CodecReadStream (snd_stream_t *stream, int bytes, void *buffer) static int S_UMX_CodecReadStream (snd_stream_t *stream, int bytes, void *buffer)
{ {
(void)stream, (void)bytes, (void)buffer;
return -1; return -1;
} }
@ -385,6 +386,7 @@ static void S_UMX_CodecCloseStream (snd_stream_t *stream)
static int S_UMX_CodecRewindStream (snd_stream_t *stream) static int S_UMX_CodecRewindStream (snd_stream_t *stream)
{ {
(void)stream;
return -1; return -1;
} }

View File

@ -47,6 +47,7 @@
static int ovc_fclose (void *f) static int ovc_fclose (void *f)
{ {
(void)f;
return 0; /* we fclose() elsewhere. */ return 0; /* we fclose() elsewhere. */
} }

View File

@ -237,6 +237,7 @@ static int PartialIPAddress (const char *in, struct qsockaddr *hostaddr)
int UDP_Connect (sys_socket_t socketid, struct qsockaddr *addr) int UDP_Connect (sys_socket_t socketid, struct qsockaddr *addr)
{ {
(void)socketid, (void)addr;
return 0; return 0;
} }

View File

@ -246,7 +246,6 @@ static char const *Sys_GetUserDir(void)
static char user_dir[MAX_OSPATH]; static char user_dir[MAX_OSPATH];
static char app_name[] = "AGWQuake"; static char app_name[] = "AGWQuake";
size_t n;
char const *home_dir; char const *home_dir;
#ifdef PLATFORM_OSX #ifdef PLATFORM_OSX
@ -315,6 +314,8 @@ static void Sys_GetBasedir (char *argv0, char *dst, size_t dstsize)
{ {
char *tmp; char *tmp;
(void)argv0;
if (getcwd(dst, dstsize - 1) == NULL) if (getcwd(dst, dstsize - 1) == NULL)
Sys_Error ("Couldn't determine current directory"); Sys_Error ("Couldn't determine current directory");