/* ================= CL_Vid_Restart_f Restart the video subsystem ================= */ void CL_Vid_Restart_f( void ) { S_StopAllSounds(); // don't let them loop during the restart S_BeginRegistration(); // all sound handles are now invalid CL_ShutdownRef(); CL_ShutdownUI(); CL_ShutdownCGame(); //rww - sof2mp does this here, but it seems to cause problems in this codebase. // CM_ClearMap(); CL_InitRef(); cls.rendererStarted = qfalse; cls.uiStarted = qfalse; cls.cgameStarted = qfalse; cls.soundRegistered = qfalse; #ifdef _IMMERSION CL_ShutdownFF(); cls.forceStarted = qfalse; #endif // _IMMERSION #ifdef _XBOX vidRestartReloadMap = qtrue; #endif // unpause so the cgame definately gets a snapshot and renders a frame Cvar_Set( "cl_paused", "0" ); }
void Hunk_Clear( void ) { #ifndef DEDICATED CL_ShutdownCGame(); CL_ShutdownUI(); #endif SV_ShutdownGameProgs(); #ifndef DEDICATED CIN_CloseAllVideos(); #endif hunk_tag = TAG_HUNK_MARK1; Z_TagFree(TAG_HUNK_MARK1); Z_TagFree(TAG_HUNK_MARK2); if ( re.HunkClearCrap ) { re.HunkClearCrap(); } // Com_Printf( "Hunk_Clear: reset the hunk ok\n" ); VM_Clear(); //See if any ghoul2 stuff was leaked, at this point it should be all cleaned up. #ifdef _FULL_G2_LEAK_CHECKING assert(g_Ghoul2Allocations == 0 && g_G2ClientAlloc == 0 && g_G2ServerAlloc == 0); if (g_Ghoul2Allocations) { Com_Printf("%i bytes leaked by ghoul2 routines (%i client, %i server)\n", g_Ghoul2Allocations, g_G2ClientAlloc, g_G2ServerAlloc); G2_DEBUG_ReportLeaks(); } #endif }
/* ================= CL_FlushMemory Called by CL_MapLoading, CL_Connect_f, and CL_ParseGamestate the only ways a client gets into a game Also called by Com_Error ================= */ void CL_FlushMemory( void ) { // clear sounds (moved higher up within this func to avoid the odd sound stutter) S_DisableSounds(); // unload the old VM CL_ShutdownCGame(); CL_ShutdownUI(); if ( re.Shutdown ) { re.Shutdown( qfalse ); // don't destroy window or context } //rwwFIXMEFIXME: The game server appears to continue running, so clearing common bsp data causes crashing and other bad things /* CM_ClearMap(); */ cls.soundRegistered = qfalse; cls.rendererStarted = qfalse; #ifdef _IMMERSION CL_ShutdownFF(); cls.forceStarted = qfalse; #endif // _IMMERSION }
// Connnect to a game we have the session ID for bool XBL_MM_ConnectViaSessionID( const XNKID *sessionID, bool invited ) { // Do the query... runSessionIDQuery( sessionID ); // No results? (Should only be one) if ( !queryByID.Results.Size() ) { return false; } CJoinSessionByIDResult &server(queryByID.Results[0]); if (server.PrivateOpen < 1 && server.PublicOpen < 1) { // No slots available return false; } // OK. If we're currently hosting a dedicated server, we need to clean things up: if( com_dedicated->integer ) { // Marks us as no longer joinable or playing: XBL_F_OnClientLeaveSession(); // Code copied from "Leave" in ui_main.c Cvar_SetValue( "cl_paused", 0 ); Key_SetCatcher( KEYCATCH_UI ); Cvar_SetValue( "cl_running", 1 ); SV_Shutdown( "Server quit\n" ); CL_ShutdownUI(); extern void RE_Shutdown( qboolean destroyWindow ); RE_Shutdown( qfalse ); CL_Disconnect( qtrue ); Cvar_SetValue( "dedicated", 0 ); Cvar_SetValue( "ui_dedicated", 0 ); CL_FlushMemory(); ui::Menus_CloseAll(); } else if( cls.state == CA_ACTIVE ) { // If we were already playing, we need to disconnect earlier than normal, // to clean up XBL stuff. Don't delete textures, we need to draw the connect screen: CL_Disconnect( qtrue, qfalse ); Net_XboxDisconnect(); } Net_XboxConnect(&server.SessionID, &server.KeyExchangeKey, &server.HostAddress); return true; }
/* ================= CL_Vid_Restart_f Restart the video subsystem ================= */ void CL_Vid_Restart_f( void ) { S_StopAllSounds(); // don't let them loop during the restart S_BeginRegistration(); // all sound handles are now invalid CL_ShutdownRef(); CL_ShutdownUI(); CL_ShutdownCGame(); CL_InitRef(); cls.rendererStarted = qfalse; cls.uiStarted = qfalse; cls.cgameStarted = qfalse; cls.soundRegistered = qfalse; // unpause so the cgame definately gets a snapshot and renders a frame Cvar_Set( "cl_paused", "0" ); }
/* ================= CL_FlushMemory Called by CL_MapLoading, CL_Connect_f, and CL_ParseGamestate the only ways a client gets into a game Also called by Com_Error ================= */ void CL_FlushMemory( void ) { // clear sounds (moved higher up within this func to avoid the odd sound stutter) S_DisableSounds(); // unload the old VM CL_ShutdownCGame(); CL_ShutdownUI(); if ( re.Shutdown ) { re.Shutdown( qfalse ); // don't destroy window or context } cls.soundRegistered = qfalse; cls.rendererStarted = qfalse; }
/* =============== CL_Shutdown =============== */ void CL_Shutdown( void ) { static qboolean recursive = qfalse; if ( !com_cl_running || !com_cl_running->integer ) { return; } Com_Printf( "----- CL_Shutdown -----\n" ); if ( recursive ) { printf ("recursive shutdown\n"); return; } recursive = qtrue; CL_ShutdownUI(); CL_Disconnect(); S_Shutdown(); CL_ShutdownRef(); #ifdef _IMMERSION CL_ShutdownFF(); #endif // _IMMERSION Cmd_RemoveCommand ("cmd"); Cmd_RemoveCommand ("configstrings"); Cmd_RemoveCommand ("clientinfo"); Cmd_RemoveCommand ("snd_restart"); Cmd_RemoveCommand ("vid_restart"); Cmd_RemoveCommand ("disconnect"); Cmd_RemoveCommand ("cinematic"); Cmd_RemoveCommand ("ingamecinematic"); Cmd_RemoveCommand ("pause"); Cvar_Set( "cl_running", "0" ); recursive = qfalse; memset( &cls, 0, sizeof( cls ) ); Com_Printf( "-----------------------\n" ); }
/* =============== CL_Shutdown =============== */ void CL_Shutdown( void ) { static qboolean recursive = qfalse; if ( !com_cl_running || !com_cl_running->integer ) { return; } Com_Printf( "----- CL_Shutdown -----\n" ); if ( recursive ) { Com_Printf( "WARNING: Recursive shutdown\n" ); return; } recursive = qtrue; CL_ShutdownUI(); CL_Disconnect(); S_Shutdown(); CL_ShutdownRef(qfalse); Cmd_RemoveCommand ("cmd"); Cmd_RemoveCommand ("configstrings"); Cmd_RemoveCommand ("clientinfo"); Cmd_RemoveCommand ("snd_restart"); Cmd_RemoveCommand ("vid_restart"); Cmd_RemoveCommand ("disconnect"); Cmd_RemoveCommand ("cinematic"); Cmd_RemoveCommand ("ingamecinematic"); Cmd_RemoveCommand ("uimenu"); Cmd_RemoveCommand ("datapad"); Cmd_RemoveCommand ("endscreendissolve"); Cvar_Set( "cl_running", "0" ); recursive = qfalse; memset( &cls, 0, sizeof( cls ) ); Com_Printf( "-----------------------\n" ); }
/* ================= CL_FF_Restart_f ================= */ void CL_FF_Restart_f( void ) { if ( FF_IsInitialized() ) { // Apply cvar changes w/o losing registered effects // Allows changing devices in-game without restarting the map if ( !FF_Init() ) FF_Shutdown(); // error (shouldn't happen) } else if ( cls.state >= CA_PRIMED ) // maybe > CA_DISCONNECTED { // Restart map or menu CL_Vid_Restart_f(); } else if ( cls.uiStarted ) { // Restart menu CL_ShutdownUI(); cls.forceStarted = qfalse; } }