Skip to content

Commit 2c06c58

Browse files
authored
Fix compile for UE5.4 (#104)
* Fix compile, due to newly introduced pure virtual UpdatePackageModificationStatus not implemented in subclass * Fix compile due to 5.4 API changes * Fix C4702 dead code by adjusting #if conditions. * Fix "error C4855: implicit capture of 'this' via '[=]' is deprecated in '/std:c++20'"
1 parent 019ab8a commit 2c06c58

File tree

4 files changed

+52
-9
lines changed

4 files changed

+52
-9
lines changed

HotPatcher/Source/HotPatcherCore/Private/Cooker/PackageWriter/HotPatcherPackageWriter.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,15 @@ void FHotPatcherPackageWriter::RemoveCookedPackages()
5757
UPackage::WaitForAsyncFileWrites();
5858
}
5959

60+
#if UE_VERSION_OLDER_THAN(5,4,0)
6061
void FHotPatcherPackageWriter::MarkPackagesUpToDate(TArrayView<const FName> UpToDatePackages)
6162
{
6263
}
64+
#else
65+
void FHotPatcherPackageWriter::UpdatePackageModificationStatus(FName PackageName, bool bIterativelyUnmodified, bool& bInOutShouldIterativelySkip)
66+
{
67+
}
68+
#endif
6369

6470
bool FHotPatcherPackageWriter::GetPreviousCookedBytes(const FPackageInfo& Info, FPreviousCookedBytesData& OutData)
6571
{

HotPatcher/Source/HotPatcherCore/Private/Cooker/PackageWriter/HotPatcherPackageWriter.h

+4
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ class FHotPatcherPackageWriter:public TPackageWriterToSharedBuffer<ICookedPackag
3838
virtual FCbObject GetOplogAttachment(FName PackageName, FUtf8StringView AttachmentKey) override;
3939
virtual void RemoveCookedPackages(TArrayView<const FName> PackageNamesToRemove) override;
4040
virtual void RemoveCookedPackages() override;
41+
#if UE_VERSION_OLDER_THAN(5,4,0)
4142
virtual void MarkPackagesUpToDate(TArrayView<const FName> UpToDatePackages) override;
43+
#else
44+
virtual void UpdatePackageModificationStatus(FName PackageName, bool bIterativelyUnmodified, bool& bInOutShouldIterativelySkip) override;
45+
#endif
4246
virtual bool GetPreviousCookedBytes(const FPackageInfo& Info, FPreviousCookedBytesData& OutData) override;
4347
#if UE_VERSION_OLDER_THAN(5,3,0)
4448
virtual void CompleteExportsArchiveForDiff(const FPackageInfo& Info, FLargeMemoryWriter& ExportsArchive)override;

HotPatcher/Source/HotPatcherCore/Private/FlibHotPatcherCoreHelper.cpp

+18-9
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
4040
#include "Internationalization/PackageLocalizationManager.h"
4141
#include "Misc/ScopeExit.h"
4242
#include "Misc/EngineVersionComparison.h"
43+
#if !UE_VERSION_OLDER_THAN(5,4,0)
44+
#include "AssetCompilingManager.h"
45+
#endif
4346

4447
DEFINE_LOG_CATEGORY(LogHotPatcherCoreHelper);
4548

@@ -307,7 +310,11 @@ FString UFlibHotPatcherCoreHelper::GetProjectCookedDir()
307310
#include "CookOnTheSide/CookOnTheFlyServer.h"
308311
#include "HACK_PRIVATE_MEMBER_UTILS.hpp"
309312
DECL_HACK_PRIVATE_NOCONST_FUNCTION(UCookOnTheFlyServer, FindOrCreatePackageWriter, ICookedPackageWriter&, const ITargetPlatform* TargetPlatform)
310-
DECL_HACK_PRIVATE_DATA(UCookOnTheFlyServer, TUniquePtr<class FSandboxPlatformFile>, SandboxFile)
313+
#if UE_VERSION_OLDER_THAN(5,4,0)
314+
DECL_HACK_PRIVATE_DATA(UCookOnTheFlyServer, TUniquePtr<class FSandboxPlatformFile>, SandboxFile)
315+
#else
316+
DECL_HACK_PRIVATE_DATA(UCookOnTheFlyServer, TUniquePtr<class UE::Cook::FCookSandbox>, SandboxFile)
317+
#endif
311318
#endif
312319

313320
FSavePackageContext* UFlibHotPatcherCoreHelper::CreateSaveContext(const ITargetPlatform* TargetPlatform,
@@ -638,7 +645,11 @@ bool UFlibHotPatcherCoreHelper::CookPackage(
638645
PackageArgs.TargetPlatform = Platform.Value;
639646
PackageArgs.bSlowTask = false;
640647
PackageArgs.FinalTimeStamp = FDateTime::MinValue();
648+
#if UE_VERSION_OLDER_THAN(5,4,0)
641649
FArchiveCookContext ArchiveCookContext(Package, FArchiveCookContext::ECookType::ECookByTheBook, FArchiveCookContext::ECookingDLC::ECookingDLCNo);
650+
#else
651+
FArchiveCookContext ArchiveCookContext(Package, UE::Cook::ECookType::ByTheBook, UE::Cook::ECookingDLC::No);
652+
#endif
642653
FArchiveCookData CookData(*Platform.Value, ArchiveCookContext);
643654
PackageArgs.ArchiveCookData = &CookData;
644655

@@ -951,18 +962,17 @@ FString UFlibHotPatcherCoreHelper::GetUnrealPakBinary()
951962
#endif
952963
TEXT("UnrealPak.exe")
953964
);
954-
#endif
955-
956-
#if PLATFORM_MAC
965+
#elif PLATFORM_MAC
957966
return FPaths::Combine(
958967
FPaths::ConvertRelativePathToFull(FPaths::EngineDir()),
959968
TEXT("Binaries"),
960969
TEXT("Mac"),
961970
TEXT("UnrealPak")
962971
);
963-
#endif
972+
#else
964973

965974
return TEXT("");
975+
#endif
966976
}
967977

968978
FString UFlibHotPatcherCoreHelper::GetUECmdBinary()
@@ -988,9 +998,7 @@ FString UFlibHotPatcherCoreHelper::GetUECmdBinary()
988998
return FPaths::Combine(
989999
FPaths::ConvertRelativePathToFull(FPaths::EngineDir()),
9901000
TEXT("Binaries"),PlatformName,FString::Printf(TEXT("%s%s-Cmd.exe"),*Binary,bIsDevelopment ? TEXT("") : *FString::Printf(TEXT("-%s-%s"),*PlatformName,*ConfigutationName)));
991-
#endif
992-
993-
#if PLATFORM_MAC
1001+
#elif PLATFORM_MAC
9941002
#if ENGINE_MAJOR_VERSION < 5 && ENGINE_MINOR_VERSION <= 21
9951003
return FPaths::Combine(
9961004
FPaths::ConvertRelativePathToFull(FPaths::EngineDir()),
@@ -1004,8 +1012,9 @@ FString UFlibHotPatcherCoreHelper::GetUECmdBinary()
10041012
FString::Printf(TEXT("%s%s-Cmd"),*Binary,
10051013
bIsDevelopment ? TEXT("") : *FString::Printf(TEXT("-Mac-%s"),*ConfigutationName)));
10061014
#endif
1007-
#endif
1015+
#else
10081016
return TEXT("");
1017+
#endif
10091018
}
10101019

10111020

HotPatcher/Source/HotPatcherEditor/Private/HotPatcherEditor.cpp

+24
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,11 @@ void FHotPatcherEditorModule::PluginButtonClicked(const FSHotPatcherContext& Con
173173

174174
if (!DockTab.IsValid())
175175
{
176+
#if UE_VERSION_OLDER_THAN(5,4,0)
176177
FGlobalTabmanager::Get()->RegisterNomadTabSpawner(HotPatcherTabName, FOnSpawnTab::CreateLambda([=](const class FSpawnTabArgs& InSpawnTabArgs)
178+
#else
179+
FGlobalTabmanager::Get()->RegisterNomadTabSpawner(HotPatcherTabName, FOnSpawnTab::CreateLambda([=, this](const class FSpawnTabArgs& InSpawnTabArgs)
180+
#endif
177181
{
178182
return SpawnHotPatcherTab(Context);
179183
}))
@@ -195,7 +199,11 @@ void FHotPatcherEditorModule::AddMenuExtension(FMenuBuilder& Builder)
195199
Builder.AddSubMenu(
196200
FText::FromString(TEXT("HotPatcher")),
197201
FText::FromString(TEXT("HotPatcher")),
202+
#if UE_VERSION_OLDER_THAN(5,4,0)
198203
FNewMenuDelegate::CreateLambda([=](FMenuBuilder& Menu)
204+
#else
205+
FNewMenuDelegate::CreateLambda([=, this](FMenuBuilder& Menu)
206+
#endif
199207
{
200208
Menu.AddWidget(this->HandlePickingModeContextMenu(),FText::FromString(TEXT("")),true);
201209
}),
@@ -240,7 +248,11 @@ TSharedRef<SWidget> FHotPatcherEditorModule::HandlePickingModeContextMenu()
240248
FText::FromString(TEXT("MAIN")),
241249
FText::FromString(TEXT("MAIN")),
242250
HotPatcherIcon,
251+
#if UE_VERSION_OLDER_THAN(5,4,0)
243252
FUIAction(FExecuteAction::CreateLambda([=]()
253+
#else
254+
FUIAction(FExecuteAction::CreateLambda([=, this]()
255+
#endif
244256
{
245257
this->PluginButtonClicked(Context);
246258
})));
@@ -272,7 +284,11 @@ TSharedRef<SWidget> FHotPatcherEditorModule::HandlePickingModeContextMenu()
272284
FText::FromString(ActionName),
273285
FText::FromString(ActionName),
274286
FSlateIcon(),
287+
#if UE_VERSION_OLDER_THAN(5,4,0)
275288
FUIAction(FExecuteAction::CreateLambda([=]()
289+
#else
290+
FUIAction(FExecuteAction::CreateLambda([=, this]()
291+
#endif
276292
{
277293
this->PluginButtonClicked(Context);
278294
}))
@@ -437,7 +453,11 @@ void FHotPatcherEditorModule::MakeCookAndPakActionsSubMenu(UToolMenu* Menu)
437453
FToolMenuEntry& PlatformEntry = Section.AddSubMenu(FName(*PlatformName),
438454
FText::Format(LOCTEXT("Platform", "{0}"), UKismetTextLibrary::Conv_StringToText(THotPatcherTemplateHelper::GetEnumNameByValue(Platform))),
439455
FText(),
456+
#if UE_VERSION_OLDER_THAN(5,4,0)
440457
FNewMenuDelegate::CreateLambda([=](FMenuBuilder& SubMenuBuilder){
458+
#else
459+
FNewMenuDelegate::CreateLambda([=, this](FMenuBuilder& SubMenuBuilder){
460+
#endif
441461
SubMenuBuilder.AddMenuEntry(
442462
LOCTEXT("AnalysisDependencies", "AnalysisDependencies"), FText(),
443463
FSlateIcon(*StyleSetName,TEXT("WorldBrowser.LevelsMenuBrush")),
@@ -461,7 +481,11 @@ void FHotPatcherEditorModule::MakeHotPatcherPresetsActionsSubMenu(UToolMenu* Men
461481
Section.AddSubMenu(FName(*PakConfig.VersionId),
462482
FText::Format(LOCTEXT("PakExternal_VersionID", "{0}"), UKismetTextLibrary::Conv_StringToText(PakConfig.VersionId)),
463483
FText(),
484+
#if UE_VERSION_OLDER_THAN(5,4,0)
464485
FNewMenuDelegate::CreateLambda([=](FMenuBuilder& SubMenuBuilder)
486+
#else
487+
FNewMenuDelegate::CreateLambda([=, this](FMenuBuilder& SubMenuBuilder)
488+
#endif
465489
{
466490
for (ETargetPlatform Platform : GetAllowCookPlatforms())
467491
{

0 commit comments

Comments
 (0)