From f07ac29c0b8dfee61020d8f6cd08b020ad1dbe4c Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Fri, 29 Apr 2016 20:00:50 +0000 Subject: [PATCH] fix C++11 -Wliteral-suffix warnings. fix -Wnarrowing errors/warnings. fix the detestable in_sdl.c/SDL2 int-to-enum conversion failure errors from g++. git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@1302 af15c1b1-3010-417e-b628-4374ebc0bcbd --- Quake/gl_texmgr.c | 10 +++++----- Quake/glquake.h | 2 ++ Quake/host.c | 4 ++-- Quake/in_sdl.c | 6 +++--- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Quake/gl_texmgr.c b/Quake/gl_texmgr.c index 6ace37c5..eacc7ebb 100644 --- a/Quake/gl_texmgr.c +++ b/Quake/gl_texmgr.c @@ -1439,7 +1439,7 @@ void TexMgr_ReloadNobrightImages (void) ================================================================================ */ -static GLuint currenttexture[3] = {-1, -1, -1}; // to avoid unnecessary texture sets +static GLuint currenttexture[3] = {GL_UNUSED_TEXTURE, GL_UNUSED_TEXTURE, GL_UNUSED_TEXTURE}; // to avoid unnecessary texture sets static GLenum currenttarget = GL_TEXTURE0_ARB; qboolean mtexenabled = false; @@ -1517,9 +1517,9 @@ static void GL_DeleteTexture (gltexture_t *texture) { glDeleteTextures (1, &texture->texnum); - if (texture->texnum == currenttexture[0]) currenttexture[0] = -1; - if (texture->texnum == currenttexture[1]) currenttexture[1] = -1; - if (texture->texnum == currenttexture[2]) currenttexture[2] = -1; + if (texture->texnum == currenttexture[0]) currenttexture[0] = GL_UNUSED_TEXTURE; + if (texture->texnum == currenttexture[1]) currenttexture[1] = GL_UNUSED_TEXTURE; + if (texture->texnum == currenttexture[2]) currenttexture[2] = GL_UNUSED_TEXTURE; texture->texnum = 0; } @@ -1538,6 +1538,6 @@ void GL_ClearBindings(void) int i; for (i = 0; i < 3; i++) { - currenttexture[i] = -1; + currenttexture[i] = GL_UNUSED_TEXTURE; } } diff --git a/Quake/glquake.h b/Quake/glquake.h index a9df1e4a..9cbba52a 100644 --- a/Quake/glquake.h +++ b/Quake/glquake.h @@ -30,6 +30,8 @@ void GL_Set2D (void); extern int glx, gly, glwidth, glheight; +#define GL_UNUSED_TEXTURE (~(GLuint)0) + // r_local.h -- private refresh defs #define ALIAS_BASE_SIZE_RATIO (1.0 / 11.0) diff --git a/Quake/host.c b/Quake/host.c index ab8fd73f..7d3e16e4 100644 --- a/Quake/host.c +++ b/Quake/host.c @@ -221,7 +221,7 @@ void Host_Version_f (void) { Con_Printf ("Quake Version %1.2f\n", VERSION); Con_Printf ("QuakeSpasm Version %1.2f.%d\n", QUAKESPASM_VERSION, QUAKESPASM_VER_PATCH); - Con_Printf ("Exe: "__TIME__" "__DATE__"\n"); + Con_Printf ("Exe: " __TIME__ " " __DATE__ "\n"); } /* cvar callback functions : */ @@ -845,7 +845,7 @@ void Host_Init (void) NET_Init (); SV_Init (); - Con_Printf ("Exe: "__TIME__" "__DATE__"\n"); + Con_Printf ("Exe: " __TIME__ " " __DATE__ "\n"); Con_Printf ("%4.1f megabyte heap\n", host_parms->memsize/ (1024*1024.0)); if (cls.state != ca_dedicated) diff --git a/Quake/in_sdl.c b/Quake/in_sdl.c index 2effc7f3..337bd3f9 100644 --- a/Quake/in_sdl.c +++ b/Quake/in_sdl.c @@ -598,18 +598,18 @@ void IN_Commands (void) // emit key events for controller buttons for (i = 0; i < SDL_CONTROLLER_BUTTON_MAX; i++) { - qboolean newstate = SDL_GameControllerGetButton(joy_active_controller, i); + qboolean newstate = SDL_GameControllerGetButton(joy_active_controller, (SDL_GameControllerButton)i); qboolean oldstate = joy_buttonstate.buttondown[i]; joy_buttonstate.buttondown[i] = newstate; // NOTE: This can cause a reentrant call of IN_Commands, via SCR_ModalMessage when confirming a new game. - IN_JoyKeyEvent(oldstate, newstate, IN_KeyForControllerButton(i), &joy_buttontimer[i]); + IN_JoyKeyEvent(oldstate, newstate, IN_KeyForControllerButton((SDL_GameControllerButton)i), &joy_buttontimer[i]); } for (i = 0; i < SDL_CONTROLLER_AXIS_MAX; i++) { - newaxisstate.axisvalue[i] = SDL_GameControllerGetAxis(joy_active_controller, i) / 32768.0f; + newaxisstate.axisvalue[i] = SDL_GameControllerGetAxis(joy_active_controller, (SDL_GameControllerAxis)i) / 32768.0f; } // emit emulated arrow keys so the analog sticks can be used in the menu