예제 #1
0
// 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;
}
예제 #2
0
/*
================
SV_Shutdown

Called when each game quits,
before Sys_Quit or Sys_Error
================
*/
void SV_Shutdown( char *finalmsg ) 
{
	if ( !com_sv_running || !com_sv_running->integer ) 
	{
		return;
	}

//	Com_Printf( "----- Server Shutdown -----\n" );

	//Replaced com_errorEntered check with a recursion check inside
	//SV_FinalMessage.  How else can the clients know to disconnect?
	if ( svs.clients/* && !com_errorEntered*/ ) {
		SV_FinalMessage( finalmsg );
	}

	SV_RemoveOperatorCommands();
#ifndef _XBOX	// No master on Xbox
	SV_MasterShutdown();
#endif
	SV_ShutdownGameProgs();
/*
Ghoul2 Insert Start
*/
 	// de allocate the snapshot entities 
	if (svs.snapshotEntities)
	{
		delete[] svs.snapshotEntities;
		svs.snapshotEntities = NULL;
	}

	// free current level
	SV_ClearServer();
	CM_ClearMap();//jfm: add a clear here since it's commented out in clearServer.  This prevents crashing cmShaderTable on exit.

	// free server static data
	if ( svs.clients ) {
		Z_Free( svs.clients );
	}
	Com_Memset( &svs, 0, sizeof( svs ) );

	Cvar_Set( "sv_running", "0" );
	Cvar_Set("ui_singlePlayerActive", "0");

//	Com_Printf( "---------------------------\n" );

#ifdef _XBOX
	// If we were advertising on Live, remove the listing. This also unregisters
	// the server's key. SysLink keys are never unregistered, so we don't do anything
	// special here for them.
	if ( logged_on )
		XBL_MM_Shutdown( true );

	// Leave the voice session
	g_Voice.LeaveSession();

	// Tear down voice now if we're on system link (Live keeps it active)
	if( !logged_on )
		g_Voice.Shutdown();

	if( logged_on )
	{
		XBL_F_OnClientLeaveSession();
		XBL_PL_OnClientLeaveSession();
	}

	// Wipe our player list - this is important
	memset( &xbOnlineInfo, 0, sizeof(xbOnlineInfo) );
#endif

	// disconnect any local clients
	CL_Disconnect( qfalse );
}