From 26641226a484cb0523342316fe920a6eb68f6d1a Mon Sep 17 00:00:00 2001 From: Tim Angus Date: Mon, 1 Oct 2007 07:56:32 +0000 Subject: [PATCH] * Remove some C99isms (f0rqu3) * Provide Q_snprintf wrapper for snprintf (f0rqu3) --- code/qcommon/qcommon.h | 4 +++- code/sdl/sdl_gamma.c | 32 +++++++++++++++++--------------- code/sdl/sdl_glimp.c | 2 +- code/sys/sys_main.c | 2 +- 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/code/qcommon/qcommon.h b/code/qcommon/qcommon.h index 5fd3cd58..7d977ac4 100644 --- a/code/qcommon/qcommon.h +++ b/code/qcommon/qcommon.h @@ -689,10 +689,12 @@ MISC // vsnprintf is ISO/IEC 9899:1999 // abstracting this to make it portable -#ifdef WIN32 +#ifdef _WIN32 #define Q_vsnprintf _vsnprintf +#define Q_snprintf _snprintf #else #define Q_vsnprintf vsnprintf +#define Q_snprintf snprintf #endif // centralizing the declarations for cl_cdkey diff --git a/code/sdl/sdl_gamma.c b/code/sdl/sdl_gamma.c index 69143cb1..26737009 100644 --- a/code/sdl/sdl_gamma.c +++ b/code/sdl/sdl_gamma.c @@ -48,23 +48,25 @@ void GLimp_SetGamma( unsigned char red[256], unsigned char green[256], unsigned #include // Win2K and newer put this odd restriction on gamma ramps... - OSVERSIONINFO vinfo; - - vinfo.dwOSVersionInfoSize = sizeof( vinfo ); - GetVersionEx( &vinfo ); - if( vinfo.dwMajorVersion >= 5 && vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT ) { - Com_DPrintf( "performing gamma clamp.\n" ); - for( j = 0 ; j < 3 ; j++ ) - { - for( i = 0 ; i < 128 ; i++ ) - { - if( table[ j ] [ i] > ( ( 128 + i ) << 8 ) ) - table[ j ][ i ] = ( 128 + i ) << 8; - } + OSVERSIONINFO vinfo; - if( table[ j ] [127 ] > 254 << 8 ) - table[ j ][ 127 ] = 254 << 8; + vinfo.dwOSVersionInfoSize = sizeof( vinfo ); + GetVersionEx( &vinfo ); + if( vinfo.dwMajorVersion >= 5 && vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT ) + { + Com_DPrintf( "performing gamma clamp.\n" ); + for( j = 0 ; j < 3 ; j++ ) + { + for( i = 0 ; i < 128 ; i++ ) + { + if( table[ j ] [ i] > ( ( 128 + i ) << 8 ) ) + table[ j ][ i ] = ( 128 + i ) << 8; + } + + if( table[ j ] [127 ] > 254 << 8 ) + table[ j ][ 127 ] = 254 << 8; + } } } #endif diff --git a/code/sdl/sdl_glimp.c b/code/sdl/sdl_glimp.c index c2a187a4..5befe195 100644 --- a/code/sdl/sdl_glimp.c +++ b/code/sdl/sdl_glimp.c @@ -115,6 +115,7 @@ static int GLimp_SetMode( int mode, qboolean fullscreen ) int tcolorbits, tdepthbits, tstencilbits; int i = 0; SDL_Surface *vidscreen = NULL; + Uint32 flags = SDL_OPENGL; ri.Printf( PRINT_ALL, "Initializing OpenGL display\n"); @@ -127,7 +128,6 @@ static int GLimp_SetMode( int mode, qboolean fullscreen ) } ri.Printf( PRINT_ALL, " %d %d\n", glConfig.vidWidth, glConfig.vidHeight); - Uint32 flags = SDL_OPENGL; if (fullscreen) { flags |= SDL_FULLSCREEN; diff --git a/code/sys/sys_main.c b/code/sys/sys_main.c index eb85b7f2..f12f83bd 100644 --- a/code/sys/sys_main.c +++ b/code/sys/sys_main.c @@ -463,7 +463,7 @@ void *Sys_LoadDll( const char *name, char *fqpath , assert( name ); getcwd(curpath, sizeof(curpath)); - snprintf (fname, sizeof(fname), "%s" ARCH_STRING DLL_EXT, name); + Q_snprintf (fname, sizeof(fname), "%s" ARCH_STRING DLL_EXT, name); // TODO: use fs_searchpaths from files.c pwdpath = Sys_Cwd();