void UGameEngine::PreExit() { FAVIWriter* AVIWriter = FAVIWriter::GetInstance(); if (AVIWriter) { AVIWriter->Close(); } Super::PreExit(); // Stop tracking, automatically flushes. NETWORK_PROFILER(GNetworkProfiler.EnableTracking(false)); CancelAllPending(); // Clean up all worlds for (int32 WorldIndex = 0; WorldIndex < WorldList.Num(); ++WorldIndex) { UWorld* const World = WorldList[WorldIndex].World(); if ( World != NULL ) { World->bIsTearingDown = true; // Cancel any pending connection to a server CancelPending(World); // Shut down any existing game connections ShutdownWorldNetDriver(World); for (FActorIterator ActorIt(World); ActorIt; ++ActorIt) { ActorIt->RouteEndPlay(EEndPlayReason::Quit); } World->GetGameInstance()->Shutdown(); World->FlushLevelStreaming(EFlushLevelStreamingType::Visibility); World->CleanupWorld(); } } }
bool UGameEngine::HandleExitCommand( const TCHAR* Cmd, FOutputDevice& Ar ) { for (int32 WorldIndex = 0; WorldIndex < WorldList.Num(); ++WorldIndex) { UWorld* const World = WorldList[WorldIndex].World(); AGameMode* const GameMode = World->GetAuthGameMode(); if (GameMode) { GameMode->GameEnding(); } // Cancel any pending connection to a server CancelPending(WorldList[WorldIndex]); // Shut down any existing game connections ShutdownWorldNetDriver(World); } Ar.Log( TEXT("Closing by request") ); FPlatformMisc::RequestExit( 0 ); return true; }