void ClientMgr::Disconnect(int clientId) { if (Exists(clientId)) { try { auto client = GetClient(clientId); client->SetQuitting(); clients.erase(clientId); nameToClient.erase(client->clientName); std::error_code ec; client->Close(ec); } catch (std::exception& e) { std::cerr << "Couldn't find client during disconnect.\n"; } } else { std::cerr << "Couldn't find client during disconnect." << std::endl; } }
//----------------------------------------------------------------------------- // Purpose: // Output : int //----------------------------------------------------------------------------- void CEngine::Frame( void ) { // yield the CPU for a little while when paused, minimized, or not the focus // FIXME: Move this to main windows message pump? if ( IsPC() && !game->IsActiveApp() && !sv.IsDedicated() ) { g_pInputSystem->SleepUntilInput( NOT_FOCUS_SLEEP ); } // Get current time m_flCurrentTime = Sys_FloatTime(); // Determine dt since we last checked float dt = m_flCurrentTime - m_flPreviousTime; // Remember old time m_flPreviousTime = m_flCurrentTime; // Accumulate current time delta into the true "frametime" m_flFrameTime += dt; // If the time is < 0, that means we've restarted. // Set the new time high enough so the engine will run a frame if ( m_flFrameTime < 0.0f ) return; // If the frametime is still too short, don't pass through if ( !FilterTime( m_flFrameTime ) ) { m_flFilteredTime += dt; return; } if ( ShouldSerializeAsync() ) { static ConVar *pSyncReportConVar = g_pCVar->FindVar( "fs_report_sync_opens" ); bool bReportingSyncOpens = ( pSyncReportConVar && pSyncReportConVar->GetInt() ); int reportLevel = 0; if ( bReportingSyncOpens ) { reportLevel = pSyncReportConVar->GetInt(); pSyncReportConVar->SetValue( 0 ); } g_pFileSystem->AsyncFinishAll(); if ( bReportingSyncOpens ) { pSyncReportConVar->SetValue( reportLevel ); } } #ifdef VPROF_ENABLED PreUpdateProfile( m_flFilteredTime ); #endif // Reset swallowed time... m_flFilteredTime = 0.0f; #ifndef SWDS if ( !sv.IsDedicated() ) { ClientDLL_FrameStageNotify( FRAME_START ); } #endif #ifdef VPROF_ENABLED PostUpdateProfile(); #endif { // profile scope VPROF_BUDGET( "CEngine::Frame", VPROF_BUDGETGROUP_OTHER_UNACCOUNTED ); switch( m_nDLLState ) { case DLL_PAUSED: // paused, in hammer case DLL_INACTIVE: // no dll break; case DLL_ACTIVE: // engine is focused case DLL_CLOSE: // closing down dll case DLL_RESTART: // engine is shutting down but will restart right away // Run the engine frame HostState_Frame( m_flFrameTime ); break; } // Has the state changed? if ( m_nNextDLLState != m_nDLLState ) { m_nDLLState = m_nNextDLLState; // Do special things if we change to particular states switch( m_nDLLState ) { case DLL_CLOSE: SetQuitting( QUIT_TODESKTOP ); break; case DLL_RESTART: SetQuitting( QUIT_RESTART ); break; } } } // profile scope // Reset for next frame m_flFrameTime = 0.0f; #if defined( VPROF_ENABLED ) && defined( _X360 ) UpdateVXConsoleProfile(); #endif }
void ApplicationContext::QuitApplication() { if (!quitting) { SetQuitting(true); _pImpl.QuitApplication(); } }