From 6f9b34ef759fbe87a825ba30b3edaadc64345e25 Mon Sep 17 00:00:00 2001 From: Ludwig Nussel Date: Wed, 6 Jan 2010 13:47:41 +0000 Subject: [PATCH] avoid setting cvars by name each frame --- code/client/cl_main.c | 2 -- code/client/cl_parse.c | 6 +++++- code/client/cl_scrn.c | 6 +++--- code/sdl/sdl_input.c | 14 ++++++++++++++ code/sys/sys_main.c | 7 ------- 5 files changed, 22 insertions(+), 13 deletions(-) diff --git a/code/client/cl_main.c b/code/client/cl_main.c index a1183d79..55bf41ca 100644 --- a/code/client/cl_main.c +++ b/code/client/cl_main.c @@ -321,8 +321,6 @@ void CL_CaptureVoip(void) dontCapture = qtrue; // not connected to a server. else if (!cl_connectedToVoipServer) dontCapture = qtrue; // server doesn't support VoIP. - else if ( Cvar_VariableValue( "g_gametype" ) == GT_SINGLE_PLAYER || Cvar_VariableValue("ui_singlePlayerActive")) - dontCapture = qtrue; // single player game. else if (clc.demoplaying) dontCapture = qtrue; // playing back a demo. else if ( cl_voip->integer == 0 ) diff --git a/code/client/cl_parse.c b/code/client/cl_parse.c index 687cb5f8..83e22754 100644 --- a/code/client/cl_parse.c +++ b/code/client/cl_parse.c @@ -366,7 +366,11 @@ void CL_SystemInfoChanged( void ) { // in the future, (val) will be a protocol version string, so only // accept explicitly 1, not generally non-zero. s = Info_ValueForKey( systemInfo, "sv_voip" ); - cl_connectedToVoipServer = (atoi( s ) == 1); + if ( Cvar_VariableValue( "g_gametype" ) == GT_SINGLE_PLAYER || Cvar_VariableValue("ui_singlePlayerActive")) + cl_connectedToVoipServer = qfalse; + else + cl_connectedToVoipServer = (atoi( s ) == 1); + #endif s = Info_ValueForKey( systemInfo, "sv_cheats" ); diff --git a/code/client/cl_scrn.c b/code/client/cl_scrn.c index 568d6844..ec545bc0 100644 --- a/code/client/cl_scrn.c +++ b/code/client/cl_scrn.c @@ -364,8 +364,6 @@ void SCR_DrawVoipMeter( void ) { return; // not connected to a server. else if (!cl_connectedToVoipServer) return; // server doesn't support VoIP. - else if ( Cvar_VariableValue( "g_gametype" ) == GT_SINGLE_PLAYER || Cvar_VariableValue("ui_singlePlayerActive")) - return; // single player game. else if (clc.demoplaying) return; // playing back a demo. else if (!cl_voip->integer) @@ -577,8 +575,10 @@ void SCR_UpdateScreen( void ) { // that case. if( uivm || com_dedicated->integer ) { + // XXX + extern cvar_t* r_anaglyphMode; // if running in stereo, we need to draw the frame twice - if ( cls.glconfig.stereoEnabled || Cvar_VariableIntegerValue("r_anaglyphMode")) { + if ( cls.glconfig.stereoEnabled || r_anaglyphMode->integer) { SCR_DrawScreenField( STEREO_LEFT ); SCR_DrawScreenField( STEREO_RIGHT ); } else { diff --git a/code/sdl/sdl_input.c b/code/sdl/sdl_input.c index 4949dc18..5bf3056a 100644 --- a/code/sdl/sdl_input.c +++ b/code/sdl/sdl_input.c @@ -917,6 +917,14 @@ static void IN_ProcessEvents( void ) vidRestartTime = Sys_Milliseconds() + 1000; } break; + case SDL_ACTIVEEVENT: + if (e.active.state & SDL_APPINPUTFOCUS) { + Cvar_SetValue( "com_unfocused", !e.active.gain); + } + if (e.active.state & SDL_APPACTIVE) { + Cvar_SetValue( "com_minimized", !e.active.gain); + } + break; default: break; @@ -972,6 +980,8 @@ IN_Init */ void IN_Init( void ) { + int appState; + if( !SDL_WasInit( SDL_INIT_VIDEO ) ) { Com_Error( ERR_FATAL, "IN_Init called before SDL_Init( SDL_INIT_VIDEO )\n" ); @@ -1009,6 +1019,10 @@ void IN_Init( void ) mouseAvailable = qfalse; } + appState = SDL_GetAppState( ); + Cvar_SetValue( "com_unfocused", !( appState & SDL_APPINPUTFOCUS ) ); + Cvar_SetValue( "com_minimized", !( appState & SDL_APPACTIVE ) ); + IN_InitJoystick( ); Com_DPrintf( "------------------------------------\n" ); } diff --git a/code/sys/sys_main.c b/code/sys/sys_main.c index 1adfc93b..8f97cebd 100644 --- a/code/sys/sys_main.c +++ b/code/sys/sys_main.c @@ -561,13 +561,6 @@ int main( int argc, char **argv ) while( 1 ) { -#ifndef DEDICATED - int appState = SDL_GetAppState( ); - - Cvar_SetValue( "com_unfocused", !( appState & SDL_APPINPUTFOCUS ) ); - Cvar_SetValue( "com_minimized", !( appState & SDL_APPACTIVE ) ); -#endif - IN_Frame( ); Com_Frame( ); }