Download LyraStarterGame/Source/LyraGame/Hotfix/LyraHotfixManager.cpp from Alexhas2/unitysamples: direct link, hf CLI and curl.
- Browser
- Download file 6.42 kB
-
https://huggingface.co/datasets/Alexhas2/unitysamples/resolve/main/LyraStarterGame/Source/LyraGame/Hotfix/LyraHotfixManager.cpp
- Command line
-
hf download hf://datasets/Alexhas2/unitysamples/LyraStarterGame/Source/LyraGame/Hotfix/LyraHotfixManager.cpp
-
curl -L -o LyraHotfixManager.cpp https://huggingface.co/datasets/Alexhas2/unitysamples/resolve/main/LyraStarterGame/Source/LyraGame/Hotfix/LyraHotfixManager.cpp
6.42 kB
| // Copyright Epic Games, Inc. All Rights Reserved. | |
| int32 ULyraHotfixManager::GameHotfixCounter = 0; | |
| ULyraHotfixManager::ULyraHotfixManager() | |
| { | |
| OnScreenMessageHandle = FCoreDelegates::OnGetOnScreenMessages.AddUObject(this, &ULyraHotfixManager::GetOnScreenMessages); | |
| HotfixCompleteDelegateHandle = AddOnHotfixCompleteDelegate_Handle(FOnHotfixCompleteDelegate::CreateUObject(this, &ThisClass::OnHotfixCompleted)); | |
| } | |
| void ULyraHotfixManager::Init() | |
| { | |
| Super::Init(); | |
| } | |
| void ULyraHotfixManager::OnHotfixCompleted(EHotfixResult HotfixResult) | |
| { | |
| // Reload DDoS detection config for all live Net Drivers (mirrors RepGraph code) | |
| for (TObjectIterator<UNetDriver> It; It; ++It) | |
| { | |
| if (It->IsServer()) | |
| { | |
| UE_LOG(LogHotfixManager, Log, TEXT("Reloading DDoS detection settings for NetDriver: %s"), *It->GetName()); | |
| It->DDoS.InitConfig(); | |
| } | |
| } | |
| if (bHasPendingDeviceProfileHotfix) | |
| { | |
| UE_LOG(LogHotfixManager, Log, TEXT("Re-applying Hotfixed DeviceProfile")); | |
| bHasPendingDeviceProfileHotfix = false; | |
| UDeviceProfileManager::Get().ReapplyDeviceProfile(); | |
| ULyraSettingsLocal* GameSettings = ULyraSettingsLocal::Get(); | |
| GameSettings->OnHotfixDeviceProfileApplied(); | |
| } | |
| FSharedMemoryTracker::PrintMemoryDiff(TEXT("Hotfix Complete")); | |
| } | |
| ULyraHotfixManager::~ULyraHotfixManager() | |
| { | |
| ClearOnHotfixCompleteDelegate_Handle(HotfixCompleteDelegateHandle); | |
| FCoreDelegates::OnGetOnScreenMessages.Remove(OnScreenMessageHandle); | |
| } | |
| bool ULyraHotfixManager::WantsHotfixProcessing(const FCloudFileHeader& FileHeader) | |
| { | |
| bool bWantsProcessing = Super::WantsHotfixProcessing(FileHeader); | |
| if (!bWantsProcessing) | |
| { | |
| FString SupportedFiles[] = { | |
| TEXT("AssetMigrations.ini") | |
| }; | |
| for (FString SupportedFile : SupportedFiles) | |
| { | |
| if (!DebugPrefix.IsEmpty()) | |
| { | |
| SupportedFile = DebugPrefix + SupportedFile; | |
| } | |
| if (SupportedFile == FileHeader.FileName) | |
| { | |
| bWantsProcessing = true; | |
| break; | |
| } | |
| } | |
| } | |
| return bWantsProcessing; | |
| } | |
| bool ULyraHotfixManager::HotfixIniFile(const FString& FileName, const FString& IniData) | |
| { | |
| if (!bHasPendingDeviceProfileHotfix && FileName.EndsWith(TEXT("DEVICEPROFILES.INI"), ESearchCase::IgnoreCase)) | |
| { | |
| FConfigFile DeviceProfileHotfixConfig; | |
| DeviceProfileHotfixConfig.CombineFromBuffer(IniData, FileName); | |
| TSet<FString> Keys; | |
| for (const auto& DPSection : AsConst(DeviceProfileHotfixConfig)) | |
| { | |
| FString DeviceProfileName, DeviceProfileClass; | |
| if (DPSection.Key.Split(TEXT(" "), &DeviceProfileName, &DeviceProfileClass) && DeviceProfileClass == *UDeviceProfile::StaticClass()->GetName()) | |
| { | |
| Keys.Add(DeviceProfileName); | |
| } | |
| } | |
| // Check if any of the hotfixed device profiles are referenced by the currently active profile(s): | |
| bHasPendingDeviceProfileHotfix = UDeviceProfileManager::Get().DoActiveProfilesReference(Keys); | |
| UE_LOG(LogHotfixManager, Log, TEXT("Active device profile was referenced by hotfix = %d"), (uint32)bHasPendingDeviceProfileHotfix); | |
| } | |
| return Super::HotfixIniFile(FileName, IniData); | |
| } | |
| bool ULyraHotfixManager::ApplyHotfixProcessing(const FCloudFileHeader& FileHeader) | |
| { | |
| // This allows json files to be downloaded automatically | |
| const FString Extension = FPaths::GetExtension(FileHeader.FileName); | |
| if (Extension == TEXT("json")) | |
| { | |
| return true; | |
| } | |
| const bool bResult = Super::ApplyHotfixProcessing(FileHeader); | |
| if (bResult && FileHeader.FileName.EndsWith(TEXT("GAME.INI"), ESearchCase::IgnoreCase)) | |
| { | |
| GameHotfixCounter++; | |
| if (bHasPendingGameHotfix) | |
| { | |
| bHasPendingGameHotfix = false; | |
| OnPendingGameHotfixChanged.Broadcast(bHasPendingGameHotfix); | |
| } | |
| } | |
| return bResult; | |
| } | |
| bool ULyraHotfixManager::ShouldWarnAboutMissingWhenPatchingFromIni(const FString& AssetPath) const | |
| { | |
| return AssetPath.StartsWith(TEXT("/Engine/")) || AssetPath.StartsWith(TEXT("/Game/")); | |
| } | |
| void ULyraHotfixManager::PatchAssetsFromIniFiles() | |
| { | |
| FSharedMemoryTracker::PrintMemoryDiff(TEXT("Start - PatchAssetsFromIniFiles")); | |
| Super::PatchAssetsFromIniFiles(); | |
| FSharedMemoryTracker::PrintMemoryDiff(TEXT("End - PatchAssetsFromIniFiles")); | |
| } | |
| void ULyraHotfixManager::OnHotfixAvailablityCheck(const TArray<FCloudFileHeader>& PendingChangedFiles, const TArray<FCloudFileHeader>& PendingRemoveFiles) | |
| { | |
| bool bNewPendingGameHotfix = false; | |
| for (int32 Idx = 0; Idx < PendingChangedFiles.Num(); Idx++) | |
| { | |
| if (PendingChangedFiles[Idx].FileName.EndsWith(TEXT("GAME.INI"), ESearchCase::IgnoreCase)) | |
| { | |
| bNewPendingGameHotfix = true; | |
| break; | |
| } | |
| } | |
| if (bNewPendingGameHotfix && !bHasPendingGameHotfix) | |
| { | |
| bHasPendingGameHotfix = true; | |
| OnPendingGameHotfixChanged.Broadcast(bHasPendingGameHotfix); | |
| } | |
| } | |
| void ULyraHotfixManager::GetOnScreenMessages(TMultiMap<FCoreDelegates::EOnScreenMessageSeverity, FText>& OutMessages) | |
| { | |
| // TODO Any messages/errors. | |
| } | |
| void ULyraHotfixManager::RequestPatchAssetsFromIniFiles() | |
| { | |
| if (!RequestPatchAssetsHandle.IsValid()) | |
| { | |
| RequestPatchAssetsHandle = FTSTicker::GetCoreTicker().AddTicker(FTickerDelegate::CreateWeakLambda(this, [this](float DeltaTime) { | |
| RequestPatchAssetsHandle.Reset(); | |
| UE_LOG(LogHotfixManager, Display, TEXT("Hotfix manager re-calling PatchAssetsFromIniFiles due to new plugins")); | |
| PatchAssetsFromIniFiles(); | |
| return false; | |
| })); | |
| } | |
| } | |
| void ULyraHotfixManager::StartHotfixProcess() | |
| { | |
| if (GIsEditor) | |
| { | |
| UE_LOG(LogHotfixManager, Display, TEXT("Hotfixing skipped in development mode.")); | |
| TriggerHotfixComplete(EHotfixResult::SuccessNoChange); | |
| return; | |
| } | |
| FSharedMemoryTracker::PrintMemoryDiff(TEXT("StartHotfixProcess")); | |
| Super::StartHotfixProcess(); | |
| } | |