avoid setting cvars by name each frame

This commit is contained in:
Ludwig Nussel 2010-01-06 13:47:41 +00:00
parent 9b1a3387cb
commit 6f9b34ef75
5 changed files with 22 additions and 13 deletions

View file

@ -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 )

View file

@ -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" );
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" );

View file

@ -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 {

View file

@ -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" );
}

View file

@ -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( );
}