/* ============== CL_AddNetgraph A new packet was just parsed ============== */ void CL_AddNetgraph (void) { int i; int in; int ping; // if using the debuggraph for something else, don't // add the net lines if (scr_debuggraph->value || scr_timegraph->value) return; for (i=0 ; i<cls.netchan.dropped ; i++) SCR_DebugGraph (30, 0x40); for (i=0 ; i<cl.surpressCount ; i++) SCR_DebugGraph (30, 0xdf); // see what the latency was on this packet in = cls.netchan.incoming_acknowledged & (CMD_BACKUP-1); ping = cls.realtime - cl.cmd_time[in]; ping /= 30; if (ping > 30) ping = 30; SCR_DebugGraph (ping, 0xd0); }
/* ================= CL_CreateCmd ================= */ usercmd_t CL_CreateCmd( void ) { usercmd_t cmd; vec3_t oldAngles; VectorCopy( cl.viewangles, oldAngles ); // keyboard angle adjustment CL_AdjustAngles(); memset( &cmd, 0, sizeof( cmd ) ); CL_CmdButtons( &cmd ); // get basic movement from keyboard CL_KeyMove( &cmd ); // get basic movement from mouse CL_MouseMove( &cmd ); // get basic movement from joystick or controller if ( cl_xbox360ControllerAvailable->integer ) { CL_Xbox360ControllerMove( &cmd ); } else { CL_JoystickMove( &cmd ); } // check to make sure the angles haven't wrapped if ( cl.viewangles[ PITCH ] - oldAngles[ PITCH ] > 90 ) { cl.viewangles[ PITCH ] = oldAngles[ PITCH ] + 90; } else if ( oldAngles[ PITCH ] - cl.viewangles[ PITCH ] > 90 ) { cl.viewangles[ PITCH ] = oldAngles[ PITCH ] - 90; } // store out the final values CL_FinishMove( &cmd ); // draw debug graphs of turning for mouse testing if ( cl_debugMove->integer ) { if ( cl_debugMove->integer == 1 ) { SCR_DebugGraph( abs( cl.viewangles[ YAW ] - oldAngles[ YAW ] ), 0 ); } if ( cl_debugMove->integer == 2 ) { SCR_DebugGraph( abs( cl.viewangles[ PITCH ] - oldAngles[ PITCH ] ), 0 ); } } return cmd; }
/* ================= CL_CreateCmd ================= */ usercmd_t CL_CreateCmd( void ) { usercmd_t cmd; vec3_t oldAngles; float recoilAdd; VectorCopy( cl.viewangles, oldAngles ); // keyboard angle adjustment CL_AdjustAngles(); memset( &cmd, 0, sizeof( cmd ) ); CL_CmdButtons( &cmd ); // get basic movement from keyboard CL_KeyMove( &cmd ); // get basic movement from mouse CL_MouseMove( &cmd ); // get basic movement from joystick CL_JoystickMove( &cmd ); // check to make sure the angles haven't wrapped if ( cl.viewangles[PITCH] - oldAngles[PITCH] > 90 ) { cl.viewangles[PITCH] = oldAngles[PITCH] + 90; } else if ( oldAngles[PITCH] - cl.viewangles[PITCH] > 90 ) { cl.viewangles[PITCH] = oldAngles[PITCH] - 90; } // RF, set the kickAngles so aiming is effected recoilAdd = cl_recoilPitch->value; if ( fabs( cl.viewangles[PITCH] + recoilAdd ) < 40 ) { cl.viewangles[PITCH] += recoilAdd; } // the recoilPitch has been used, so clear it out cl_recoilPitch->value = 0; // store out the final values CL_FinishMove( &cmd ); // draw debug graphs of turning for mouse testing if ( cl_debugMove->integer ) { if ( cl_debugMove->integer == 1 ) { SCR_DebugGraph( abs(cl.viewangles[YAW] - oldAngles[YAW]) ); } if ( cl_debugMove->integer == 2 ) { SCR_DebugGraph( abs(cl.viewangles[PITCH] - oldAngles[PITCH]) ); } } cmd.cld = cl.cgameCld; // NERVE - SMF return cmd; }
usercmd_t CL_CreateCmd( void ) { usercmd_t cmd; vec3_t oldAngles; VectorCopy( cl.viewangles, oldAngles ); // keyboard angle adjustment CL_AdjustAngles (); memset( &cmd, 0, sizeof( cmd ) ); CL_CmdButtons( &cmd ); // get basic movement from keyboard CL_KeyMove (&cmd); // get basic movement from mouse CL_MouseMove( &cmd ); // get basic movement from joystick CL_JoystickMove( &cmd ); // check to make sure the angles haven't wrapped if ( cl.viewangles[PITCH] - oldAngles[PITCH] > 90 ) { cl.viewangles[PITCH] = oldAngles[PITCH] + 90; } else if ( oldAngles[PITCH] - cl.viewangles[PITCH] > 90 ) { cl.viewangles[PITCH] = oldAngles[PITCH] - 90; } if ( cl_overrideAngles ) { VectorCopy( cl_overriddenAngles, cl.viewangles ); cl_overrideAngles = qfalse; } // store out the final values CL_FinishMove( &cmd ); // draw debug graphs of turning for mouse testing #ifndef _XBOX if ( cl_debugMove->integer ) { if ( cl_debugMove->integer == 1 ) { SCR_DebugGraph( abs(cl.viewangles[YAW] - oldAngles[YAW]), 0 ); } if ( cl_debugMove->integer == 2 ) { SCR_DebugGraph( abs(cl.viewangles[PITCH] - oldAngles[PITCH]), 0 ); } } #endif return cmd; }
usercmd_t CL_CreateCmd( void ) { usercmd_t cmd; vec3_t oldAngles; VectorCopy( cl.viewangles, oldAngles ); // keyboard angle adjustment CL_AdjustAngles (); Com_Memset( &cmd, 0, sizeof( cmd ) ); CL_CmdButtons( &cmd ); // get basic movement from keyboard CL_KeyMove( &cmd ); // get basic movement from mouse CL_MouseMove( &cmd ); // get basic movement from joystick CL_JoystickMove( &cmd ); // mert akengin cvar_t *in_haptics = Cvar_Get("in_haptic","1",CVAR_ARCHIVE); cvar_t *in_haptics_move = Cvar_Get("in_haptic_move","0",CVAR_ARCHIVE); cvar_t *haptic_cvars[AXES] = { in_haptics, in_haptics_move, cl_sensitivity }; haptic_dealwith(haptic_cvars,&cmd,cl.viewangles,in_buttons); // check to make sure the angles haven't wrapped if ( cl.viewangles[PITCH] - oldAngles[PITCH] > 90 ) { cl.viewangles[PITCH] = oldAngles[PITCH] + 90; } else if ( oldAngles[PITCH] - cl.viewangles[PITCH] > 90 ) { cl.viewangles[PITCH] = oldAngles[PITCH] - 90; } // store out the final values CL_FinishMove( &cmd ); // draw debug graphs of turning for mouse testing if ( cl_debugMove->integer ) { if ( cl_debugMove->integer == 1 ) { SCR_DebugGraph( fabs(cl.viewangles[YAW] - oldAngles[YAW]) ); } if ( cl_debugMove->integer == 2 ) { SCR_DebugGraph( fabs(cl.viewangles[PITCH] - oldAngles[PITCH]) ); } } return cmd; }
usercmd_t CL_CreateCmd( void ) { usercmd_t cmd; vector3 oldAngles; VectorCopy( &cl.viewangles, &oldAngles ); // keyboard angle adjustment CL_AdjustAngles(); memset( &cmd, 0, sizeof( cmd ) ); CL_CmdButtons( &cmd ); // get basic movement from keyboard CL_KeyMove( &cmd ); // get basic movement from mouse CL_MouseMove( &cmd ); // get basic movement from joystick CL_JoystickMove( &cmd ); // check to make sure the angles haven't wrapped if ( cl.viewangles.pitch - oldAngles.pitch > 90 ) { cl.viewangles.pitch = oldAngles.pitch + 90; } else if ( oldAngles.pitch - cl.viewangles.pitch > 90 ) { cl.viewangles.pitch = oldAngles.pitch - 90; } // store out the final values CL_FinishMove( &cmd ); // draw debug graphs of turning for mouse testing if ( cl_debugMove->integer ) { if ( cl_debugMove->integer == 1 ) { SCR_DebugGraph( fabsf(cl.viewangles.yaw - oldAngles.yaw) ); } if ( cl_debugMove->integer == 2 ) { SCR_DebugGraph( fabsf(cl.viewangles.pitch - oldAngles.pitch) ); } } return cmd; }
//============== //CL_AddNetgraph // //A new packet was just parsed //============== void CL_AddNetgraph( void ) { int i; int ping; // if using the debuggraph for something else, don't // add the net lines if( scr_timegraph->integer ) return; for( i = 0; i < cls.netchan.dropped; i++ ) SCR_DebugGraph( 30.0f, 0.655f, 0.231f, 0.169f ); for( i = 0; i < cl.suppressCount; i++ ) SCR_DebugGraph( 30.0f, 0.0f, 1.0f, 0.0f ); // see what the latency was on this packet ping = cls.realtime - cl.cmd_time[cls.ucmdAcknowledged & CMD_MASK]; ping /= 30; if( ping > 30 ) ping = 30; SCR_DebugGraph( ping, 1.0f, 0.75f, 0.06f ); }
void CL_Frame ( int msec,float fractionMsec ) { if ( !com_cl_running->integer ) { return; } // load the ref / cgame if needed CL_StartHunkUsers(); #if defined (_XBOX)// && !defined(_DEBUG) // Play the intro movies once static bool firstRun = true; if(firstRun) { // SP_DoLicense(); SP_DisplayLogos(); } #endif #if defined (_XBOX) //xbox doesn't load ui in StartHunkUsers, so check it here // load ui if needed if ( !cls.uiStarted && cls.state != CA_CINEMATIC) { cls.uiStarted = qtrue; SCR_StopCinematic(); CL_InitUI(); } #endif if ( cls.state == CA_DISCONNECTED && !( cls.keyCatchers & KEYCATCH_UI ) && !com_sv_running->integer ) { // if disconnected, bring up the menu if (!CL_CheckPendingCinematic()) // this avoid having the menu flash for one frame before pending cinematics { #ifdef _XBOX if (firstRun) { UI_SetActiveMenu("splashMenu", NULL); } else #endif UI_SetActiveMenu( "mainMenu",NULL ); } } #ifdef _XBOX firstRun = false; #endif // if recording an avi, lock to a fixed fps if ( cl_avidemo->integer ) { // save the current screen if ( cls.state == CA_ACTIVE ) { if (cl_avidemo->integer > 0) { Cbuf_ExecuteText( EXEC_NOW, "screenshot silent\n" ); } else { Cbuf_ExecuteText( EXEC_NOW, "screenshot_tga silent\n" ); } } // fixed time for next frame if (cl_avidemo->integer > 0) { msec = 1000 / cl_avidemo->integer; } else { msec = 1000 / -cl_avidemo->integer; } } // save the msec before checking pause cls.realFrametime = msec; // decide the simulation time cls.frametime = msec; if(cl_framerate->integer) { avgFrametime+=msec; char mess[256]; if(!(frameCount&0x1f)) { sprintf(mess,"Frame rate=%f\n\n",1000.0f*(1.0/(avgFrametime/32.0f))); // OutputDebugString(mess); Com_Printf(mess); avgFrametime=0.0f; } frameCount++; } cls.frametimeFraction=fractionMsec; cls.realtime += msec; cls.realtimeFraction+=fractionMsec; if (cls.realtimeFraction>=1.0f) { if (cl_newClock&&cl_newClock->integer) { cls.realtime++; } cls.realtimeFraction-=1.0f; } #ifndef _XBOX if ( cl_timegraph->integer ) { SCR_DebugGraph ( cls.realFrametime * 0.25, 0 ); } #endif #ifdef _XBOX //Check on the hot swappable button states. CL_UpdateHotSwap(); #endif // see if we need to update any userinfo CL_CheckUserinfo(); // if we haven't gotten a packet in a long time, // drop the connection CL_CheckTimeout(); // send intentions now CL_SendCmd(); // resend a connection request if necessary CL_CheckForResend(); // decide on the serverTime to render CL_SetCGameTime(); if (cl_pano->integer && cls.state == CA_ACTIVE) { //grab some panoramic shots int i = 1; int pref = cl_pano->integer; int oldnoprint = cl_noprint->integer; Con_Close(); cl_noprint->integer = 1; //hide the screen shot msgs for (; i <= cl_panoNumShots->integer; i++) { Cvar_SetValue( "pano", i ); SCR_UpdateScreen();// update the screen Cbuf_ExecuteText( EXEC_NOW, va("screenshot %dpano%02d\n", pref, i) ); //grab this screen } Cvar_SetValue( "pano", 0 ); //done cl_noprint->integer = oldnoprint; } if (cl_skippingcin->integer && !cl_endcredits->integer && !com_developer->integer ) { if (cl_skippingcin->modified){ S_StopSounds(); //kill em all but music cl_skippingcin->modified=qfalse; Com_Printf (va(S_COLOR_YELLOW"%s"), SE_GetString("CON_TEXT_SKIPPING")); SCR_UpdateScreen(); } } else { // update the screen SCR_UpdateScreen(); #if defined(_XBOX) && !defined(FINAL_BUILD) if (D3DPERF_QueryRepeatFrame()) SCR_UpdateScreen(); #endif } // update audio S_Update(); #ifdef _IMMERSION FF_Update(); #endif // _IMMERSION // advance local effects for next frame SCR_RunCinematic(); Con_RunConsole(); cls.framecount++; }
void CL_Frame ( int msec,float fractionMsec ) { if ( !com_cl_running->integer ) { return; } // load the ref / cgame if needed CL_StartHunkUsers(); if ( cls.state == CA_DISCONNECTED && !( Key_GetCatcher( ) & KEYCATCH_UI ) && !com_sv_running->integer ) { // if disconnected, bring up the menu if (!CL_CheckPendingCinematic()) // this avoid having the menu flash for one frame before pending cinematics { UI_SetActiveMenu( "mainMenu",NULL ); } } // if recording an avi, lock to a fixed fps if ( cl_avidemo->integer ) { // save the current screen if ( cls.state == CA_ACTIVE ) { if (cl_avidemo->integer > 0) { Cbuf_ExecuteText( EXEC_NOW, "screenshot silent\n" ); } else { Cbuf_ExecuteText( EXEC_NOW, "screenshot_tga silent\n" ); } } // fixed time for next frame if (cl_avidemo->integer > 0) { msec = 1000 / cl_avidemo->integer; } else { msec = 1000 / -cl_avidemo->integer; } } // save the msec before checking pause cls.realFrametime = msec; // decide the simulation time cls.frametime = msec; if(cl_framerate->integer) { avgFrametime+=msec; char mess[256]; if(!(frameCount&0x1f)) { sprintf(mess,"Frame rate=%f\n\n",1000.0f*(1.0/(avgFrametime/32.0f))); // OutputDebugString(mess); Com_Printf(mess); avgFrametime=0.0f; } frameCount++; } cls.frametimeFraction=fractionMsec; cls.realtime += msec; cls.realtimeFraction+=fractionMsec; if (cls.realtimeFraction>=1.0f) { if (cl_newClock&&cl_newClock->integer) { cls.realtime++; } cls.realtimeFraction-=1.0f; } if ( cl_timegraph->integer ) { SCR_DebugGraph ( cls.realFrametime * 0.25, 0 ); } // see if we need to update any userinfo CL_CheckUserinfo(); // if we haven't gotten a packet in a long time, // drop the connection CL_CheckTimeout(); // send intentions now CL_SendCmd(); // resend a connection request if necessary CL_CheckForResend(); // decide on the serverTime to render CL_SetCGameTime(); if (cl_pano->integer && cls.state == CA_ACTIVE) { //grab some panoramic shots int i = 1; int pref = cl_pano->integer; int oldnoprint = cl_noprint->integer; Con_Close(); cl_noprint->integer = 1; //hide the screen shot msgs for (; i <= cl_panoNumShots->integer; i++) { Cvar_SetValue( "pano", i ); SCR_UpdateScreen();// update the screen Cbuf_ExecuteText( EXEC_NOW, va("screenshot %dpano%02d\n", pref, i) ); //grab this screen } Cvar_SetValue( "pano", 0 ); //done cl_noprint->integer = oldnoprint; } if (cl_skippingcin->integer && !cl_endcredits->integer && !com_developer->integer ) { if (cl_skippingcin->modified){ S_StopSounds(); //kill em all but music cl_skippingcin->modified=qfalse; Com_Printf (S_COLOR_YELLOW "%s", SE_GetString("CON_TEXT_SKIPPING")); SCR_UpdateScreen(); } } else { // update the screen SCR_UpdateScreen(); } // update audio S_Update(); // advance local effects for next frame SCR_RunCinematic(); Con_RunConsole(); cls.framecount++; }
/* ================== SCR_UpdateScreen This is called every frame, and can also be called explicitly to flush text to the screen. ================== */ void SCR_UpdateScreen( void ) { static dynvar_t *updatescreen = NULL; int numframes; int i; float separation[2]; if( !updatescreen ) updatescreen = Dynvar_Create( "updatescreen", qfalse, DYNVAR_WRITEONLY, DYNVAR_READONLY ); // if the screen is disabled (loading plaque is up, or vid mode changing) // do nothing at all if( cls.disable_screen ) { if( Sys_Milliseconds() - cls.disable_screen > 120000 ) { cls.disable_screen = 0; Com_Printf( "Loading plaque timed out.\n" ); } return; } if( !scr_initialized || !con_initialized || !cls.mediaInitialized ) return; // not initialized yet /* ** range check cl_camera_separation so we don't inadvertently fry someone's ** brain */ if( cl_stereo_separation->value > 1.0 ) Cvar_SetValue( "cl_stereo_separation", 1.0 ); else if( cl_stereo_separation->value < 0 ) Cvar_SetValue( "cl_stereo_separation", 0.0 ); if( cl_stereo->integer ) { numframes = 2; separation[0] = -cl_stereo_separation->value / 2; separation[1] = cl_stereo_separation->value / 2; } else { separation[0] = 0; separation[1] = 0; numframes = 1; } for( i = 0; i < numframes; i++ ) { R_BeginFrame( separation[i], scr_forceclear->integer ? qtrue : qfalse ); if( scr_draw_loading == 2 ) { // loading plaque over black screen scr_draw_loading = 0; CL_UIModule_DrawConnectScreen( qtrue ); } // if a cinematic is supposed to be running, handle menus // and console specially else if( SCR_GetCinematicTime() > 0 ) { SCR_DrawCinematic(); } else if( cls.state == CA_DISCONNECTED ) { CL_UIModule_Refresh( qtrue ); SCR_DrawConsole(); } else if( cls.state == CA_CONNECTING || cls.state == CA_CONNECTED || cls.state == CA_HANDSHAKE ) { CL_UIModule_DrawConnectScreen( qtrue ); } else if( cls.state == CA_LOADING ) { SCR_RenderView( separation[i] ); CL_UIModule_DrawConnectScreen( qfalse ); } else if( cls.state == CA_ACTIVE ) { SCR_RenderView( separation[i] ); CL_UIModule_Refresh( qfalse ); if( scr_timegraph->integer ) SCR_DebugGraph( cls.frametime*300, 1, 1, 1 ); if( scr_debuggraph->integer || scr_timegraph->integer || scr_netgraph->integer ) SCR_DrawDebugGraph(); SCR_DrawConsole(); } // wsw : aiwa : call any listeners so they can draw their stuff Dynvar_CallListeners( updatescreen, NULL ); R_EndFrame(); } }
/* * SCR_UpdateScreen * * This is called every frame, and can also be called explicitly to flush * text to the screen. */ void SCR_UpdateScreen( void ) { static dynvar_t *updatescreen = NULL; int numframes; int i; float separation[2]; qboolean scr_cinematic; if( !updatescreen ) updatescreen = Dynvar_Create( "updatescreen", qfalse, DYNVAR_WRITEONLY, DYNVAR_READONLY ); // if the screen is disabled (loading plaque is up, or vid mode changing) // do nothing at all if( cls.disable_screen ) { if( Sys_Milliseconds() - cls.disable_screen > 120000 ) { cls.disable_screen = 0; Com_Printf( "Loading plaque timed out.\n" ); } return; } if( !scr_initialized || !con_initialized || !cls.mediaInitialized ) return; // not initialized yet Con_CheckResize(); SCR_CheckSystemFontsModified(); /* ** range check cl_camera_separation so we don't inadvertently fry someone's ** brain */ if( cl_stereo_separation->value > 1.0 ) Cvar_SetValue( "cl_stereo_separation", 1.0 ); else if( cl_stereo_separation->value < 0 ) Cvar_SetValue( "cl_stereo_separation", 0.0 ); if( cl_stereo->integer ) { numframes = 2; separation[0] = -cl_stereo_separation->value / 2; separation[1] = cl_stereo_separation->value / 2; } else { separation[0] = 0; separation[1] = 0; numframes = 1; } // avoid redrawing fullscreen cinematics unless damaged by console drawing scr_cinematic = cls.state == CA_CINEMATIC ? qtrue : qfalse; // if( scr_cinematic && !cl.cin.redraw && !scr_con_current && !scr_con_previous ) { // return; // } if( cls.cgameActive && cls.state < CA_LOADING ) { // this is when we've finished loading cgame media and are waiting // for the first valid snapshot to arrive. keep the loading screen untouched return; } for( i = 0; i < numframes; i++ ) { re.BeginFrame( separation[i], scr_cinematic || scr_forceclear->integer ? qtrue : qfalse ); if( scr_draw_loading == 2 ) { // loading plaque over black screen scr_draw_loading = 0; CL_UIModule_UpdateConnectScreen( qtrue ); } // if a cinematic is supposed to be running, handle menus // and console specially else if( scr_cinematic ) { SCR_DrawCinematic(); SCR_DrawConsole(); } else if( cls.state == CA_DISCONNECTED ) { CL_UIModule_Refresh( qtrue, qtrue ); SCR_DrawConsole(); } else if( cls.state == CA_GETTING_TICKET || cls.state == CA_CONNECTING || cls.state == CA_CONNECTED || cls.state == CA_HANDSHAKE ) { CL_UIModule_UpdateConnectScreen( qtrue ); } else if( cls.state == CA_LOADING ) { SCR_RenderView( separation[i] ); CL_UIModule_UpdateConnectScreen( qfalse ); } else if( cls.state == CA_ACTIVE ) { SCR_RenderView( separation[i] ); CL_UIModule_Refresh( qfalse, qtrue ); if( scr_timegraph->integer ) SCR_DebugGraph( cls.frametime*300, 1, 1, 1 ); if( scr_debuggraph->integer || scr_timegraph->integer || scr_netgraph->integer ) SCR_DrawDebugGraph(); SCR_DrawConsole(); } // wsw : aiwa : call any listeners so they can draw their stuff Dynvar_CallListeners( updatescreen, NULL ); re.EndFrame(); } }
void CL_Frame ( int msec,float fractionMsec ) { checkAutoSave(); //saves the game immediately after starting a level if ( !com_cl_running->integer ) { return; } // load the ref / cgame if needed CL_StartHunkUsers(); #if defined (_XBOX)// && !defined(_DEBUG) // Play the intro movies once extern bool Sys_QuickStart( void ); static bool firstRun = true; if(firstRun) { // SP_DoLicense(); SP_DisplayLogos(); } #endif #if defined (_XBOX) //xbox doesn't load ui in StartHunkUsers, so check it here // load ui if needed if ( !cls.uiStarted && cls.state != CA_CINEMATIC) { cls.uiStarted = qtrue; SCR_StopCinematic(); CL_InitUI(); } #endif if ( cls.state == CA_DISCONNECTED && !( cls.keyCatchers & KEYCATCH_UI ) && !com_sv_running->integer ) { // if disconnected, bring up the menu #ifdef _XBOX if (firstRun && !Sys_QuickStart()) { // Fresh boot UI_SetActiveMenu("splashMenu", NULL); } else if (firstRun) { // Came from MP: UI_SetActiveMenu("mainMenu", NULL); extern void XB_Startup( XBStartupState startupState ); XB_Startup( STARTUP_LOAD_SETTINGS ); } else { #ifdef XBOX_DEMO // Quitting the demo returns to the IIS, and restores settings: Settings.RestoreDefaults(); Settings.SetAll(); UI_SetActiveMenu("splashMenu", NULL); #else UI_SetActiveMenu("mainMenu", NULL); #endif } #else if (!CL_CheckPendingCinematic()) // this avoid having the menu flash for one frame before pending cinematics { UI_SetActiveMenu("mainMenu", NULL); } #endif S_StartBackgroundTrack("music/mp/MP_action4.mp3","",0); } #ifdef _XBOX firstRun = false; #endif // if recording an avi, lock to a fixed fps if ( cl_avidemo->integer ) { // save the current screen if ( cls.state == CA_ACTIVE ) { if (cl_avidemo->integer > 0) { Cbuf_ExecuteText( EXEC_NOW, "screenshot silent\n" ); } else { Cbuf_ExecuteText( EXEC_NOW, "screenshot_tga silent\n" ); } } // fixed time for next frame if (cl_avidemo->integer > 0) { msec = 1000 / cl_avidemo->integer; } else { msec = 1000 / -cl_avidemo->integer; } } // save the msec before checking pause cls.realFrametime = msec; // decide the simulation time cls.frametime = msec; //if(cl_framerate->integer) //{ // avgFrametime+=msec; // char mess[256]; // if(!(frameCount&0x1f)) // { // sprintf(mess,"Frame rate=%f\n\n",1000.0f*(1.0/(avgFrametime/32.0f))); //// OutputDebugString(mess); // Com_Printf(mess); // avgFrametime=0.0f; // } // frameCount++; //} // Always calculate framerate, bias the LOD if low avgFrametime+=msec; extern bool in_camera; float framerate = 1000.0f*(1.0/(avgFrametime/32.0f)); static int lodFrameCount = 0; int bias = Cvar_VariableIntegerValue("r_lodbias"); if(!(frameCount&0x1f)) { if(cl_framerate->integer) { char mess[256]; sprintf(mess,"Frame rate=%f LOD=%d\n\n",framerate,bias); Com_Printf(mess); } avgFrametime=0.0f; // If we drop below 20FPS, pull down the LOD bias if(framerate < 20.0f && bias == 0) { bias++; Cvar_SetValue("r_lodbias", bias); lodFrameCount = -1; } lodFrameCount++; if(lodFrameCount==5 && bias > 0) { bias--; Cvar_SetValue("r_lodBias", bias); lodFrameCount = 0; } } frameCount++; if(in_camera) { // No LOD stuff during cutscenes Cvar_SetValue("r_lodBias", 0); } cls.frametimeFraction=fractionMsec; cls.realtime += msec; cls.realtimeFraction+=fractionMsec; if (cls.realtimeFraction>=1.0f) { if (cl_newClock&&cl_newClock->integer) { cls.realtime++; } cls.realtimeFraction-=1.0f; } #ifndef _XBOX if ( cl_timegraph->integer ) { SCR_DebugGraph ( cls.realFrametime * 0.25, 0 ); } #endif #ifdef _XBOX //Check on the hot swappable button states. CL_UpdateHotSwap(); #endif // see if we need to update any userinfo CL_CheckUserinfo(); // if we haven't gotten a packet in a long time, // drop the connection CL_CheckTimeout(); // send intentions now CL_SendCmd(); // resend a connection request if necessary CL_CheckForResend(); // decide on the serverTime to render CL_SetCGameTime(); if (cl_pano->integer && cls.state == CA_ACTIVE) { //grab some panoramic shots int i = 1; int pref = cl_pano->integer; int oldnoprint = cl_noprint->integer; Con_Close(); cl_noprint->integer = 1; //hide the screen shot msgs for (; i <= cl_panoNumShots->integer; i++) { Cvar_SetValue( "pano", i ); SCR_UpdateScreen();// update the screen Cbuf_ExecuteText( EXEC_NOW, va("screenshot %dpano%02d\n", pref, i) ); //grab this screen } Cvar_SetValue( "pano", 0 ); //done cl_noprint->integer = oldnoprint; } if (cl_skippingcin->integer && !cl_endcredits->integer && !com_developer->integer ) { if (cl_skippingcin->modified){ S_StopSounds(); //kill em all but music cl_skippingcin->modified=qfalse; Com_Printf (va(S_COLOR_YELLOW"%s"), SE_GetString("CON_TEXT_SKIPPING")); SCR_UpdateScreen(); } } else { // update the screen SCR_UpdateScreen(); #if defined(_XBOX) && !defined(FINAL_BUILD) if (D3DPERF_QueryRepeatFrame()) SCR_UpdateScreen(); #endif } // update audio S_Update(); #ifdef _IMMERSION FF_Update(); #endif // _IMMERSION // advance local effects for next frame SCR_RunCinematic(); Con_RunConsole(); cls.framecount++; }
/* * SCR_UpdateScreen * * This is called every frame, and can also be called explicitly to flush * text to the screen. */ void SCR_UpdateScreen( void ) { static dynvar_t *updatescreen = NULL; int numframes; int i; float separation[2]; bool cinematic; bool forcevsync, forceclear; if( !updatescreen ) updatescreen = Dynvar_Create( "updatescreen", false, DYNVAR_WRITEONLY, DYNVAR_READONLY ); // if the screen is disabled (loading plaque is up, or vid mode changing) // do nothing at all if( cls.disable_screen ) { if( Sys_Milliseconds() - cls.disable_screen > 120000 ) { cls.disable_screen = 0; Com_Printf( "Loading plaque timed out.\n" ); } return; } if( !scr_initialized || !con_initialized || !cls.mediaInitialized || !re.ScreenEnabled() ) return; // not ready yet Con_CheckResize(); SCR_CheckSystemFontsModified(); /* ** range check cl_camera_separation so we don't inadvertently fry someone's ** brain */ if( cl_stereo_separation->value > 1.0 ) Cvar_SetValue( "cl_stereo_separation", 1.0 ); else if( cl_stereo_separation->value < 0 ) Cvar_SetValue( "cl_stereo_separation", 0.0 ); if( cl_stereo->integer ) { numframes = 2; separation[0] = -cl_stereo_separation->value / 2; separation[1] = cl_stereo_separation->value / 2; } else { separation[0] = 0; separation[1] = 0; numframes = 1; } cinematic = cls.state == CA_CINEMATIC ? true : false; forcevsync = cinematic; forceclear = cinematic; for( i = 0; i < numframes; i++ ) { re.BeginFrame( separation[i], forceclear, forcevsync ); if( scr_draw_loading == 2 ) { // loading plaque over APP_STARTUP_COLOR screen scr_draw_loading = 0; CL_UIModule_UpdateConnectScreen( true ); } // if a cinematic is supposed to be running, handle menus // and console specially else if( cinematic ) { SCR_DrawCinematic(); SCR_DrawConsole(); } else if( cls.state == CA_DISCONNECTED ) { CL_UIModule_Refresh( true, true ); SCR_DrawConsole(); } else if( cls.state == CA_GETTING_TICKET || cls.state == CA_CONNECTING || cls.state == CA_HANDSHAKE ) { CL_UIModule_UpdateConnectScreen( true ); } else if( cls.state == CA_CONNECTED ) { if( cls.cgameActive ) { CL_UIModule_UpdateConnectScreen( false ); SCR_RenderView( separation[i] ); } else { CL_UIModule_UpdateConnectScreen( true ); } } else if( cls.state == CA_ACTIVE ) { SCR_RenderView( separation[i] ); CL_UIModule_Refresh( false, true ); if( scr_timegraph->integer ) SCR_DebugGraph( cls.frametime*300, 1, 1, 1 ); if( scr_debuggraph->integer || scr_timegraph->integer || scr_netgraph->integer ) SCR_DrawDebugGraph(); SCR_DrawConsole(); } // wsw : aiwa : call any listeners so they can draw their stuff Dynvar_CallListeners( updatescreen, NULL ); re.EndFrame(); } }