UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
WorldPartitionActorDescArchive.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
4#if WITH_EDITOR
5#include "CoreMinimal.h"
9
13
15{
16public:
18
21
22 //~ Begin FArchive Interface
23 virtual FArchive& operator<<(FName& Value) override { FArchiveProxy::operator<<(Value); return *this; }
24 virtual FArchive& operator<<(FText& Value) override { unimplemented(); return *this; }
25 virtual FArchive& operator<<(UObject*& Value) override { unimplemented(); return *this; }
26 virtual FArchive& operator<<(FLazyObjectPtr& Value) override { unimplemented(); return *this; }
27 virtual FArchive& operator<<(FObjectPtr& Value) override { unimplemented(); return *this; }
28 virtual FArchive& operator<<(FSoftObjectPtr& Value) override { unimplemented(); return *this; }
29 virtual FArchive& operator<<(FSoftObjectPath& Value) override;
30 virtual FArchive& operator<<(FWeakObjectPtr& Value) override { unimplemented(); return *this; }
31 //~ End FArchive Interface
32
33 using FArchive::operator<<;
35
36 template <typename DestPropertyType, typename SourcePropertyType>
37 struct TDeltaSerializer
38 {
40
42 : Value(InValue)
43 {}
44
46 : Value(InValue)
47 , Func(InFunc)
48 {}
49
51 {
53
54 check(ActorDescAr.BaseDesc || Ar.IsSaving());
55 check(ActorDescAr.ActorDesc);
56
58
60 {
61 const UPTRINT PropertyOffset = (UPTRINT)&V.Value - BasePtr;
62
63 if ((PropertyOffset + sizeof(V.Value)) <= SizeOf)
64 {
65 const DestPropertyType* RefValue = (const DestPropertyType*)(DefaultPtr + PropertyOffset);
66 return RefValue;
67 }
68
69 return nullptr;
70 };
71
72 uint8 bSerialize = 1;
73
74 if (Ar.CustomVer(FFortniteMainBranchObjectVersion::GUID) >= FFortniteMainBranchObjectVersion::WorldPartitionActorClassDescSerialize)
75 {
76 if (Ar.IsSaving())
77 {
78 if (ActorDescAr.ComponentDesc)
79 {
80 if (ActorDescAr.BaseComponentDesc)
81 {
82 if constexpr (std::is_same_v<DestPropertyType, SourcePropertyType>)
83 {
84 // When saving, we expect the class descriptor to be the exact type as what we are serializing.
85 const DestPropertyType* BaseDefaultValue = GetBaseDefaultValue(*(UPTRINT*)&ActorDescAr.ComponentDesc, *(UPTRINT*)&ActorDescAr.BaseComponentDesc, ActorDescAr.BaseComponentDescSizeof);
87
88 bSerialize = (V.Value != *BaseDefaultValue) ? 1 : 0;
89 }
90 }
91 }
92 else if (ActorDescAr.BaseDesc)
93 {
94 if constexpr (std::is_same_v<DestPropertyType, SourcePropertyType>)
95 {
96 // When saving, we expect the class descriptor to be the exact type as what we are serializing.
97 const DestPropertyType* BaseDefaultValue = GetBaseDefaultValue(*(UPTRINT*)&ActorDescAr.ActorDesc, *(UPTRINT*)&ActorDescAr.BaseDesc, ActorDescAr.BaseDescSizeof);
99
100 bSerialize = (V.Value != *BaseDefaultValue) ? 1 : 0;
101 }
102 }
103 }
104
105 Ar << bSerialize;
106 }
107
108 if (bSerialize)
109 {
110 if constexpr (std::is_same_v<DestPropertyType, SourcePropertyType>)
111 {
112 Ar << V.Value;
113 }
114 else
115 {
116 check(Ar.IsLoading());
117
118 SourcePropertyType SourceValue;
119 Ar << SourceValue;
120 V.Func(V.Value, SourceValue);
121 }
122 }
123 else if (Ar.IsLoading())
124 {
125 // When loading, we need to handle a different class descriptor in case of missing classes, etc.
126 if (ActorDescAr.ComponentDesc)
127 {
128 if (const DestPropertyType* BaseDefaultValue = GetBaseDefaultValue(*(UPTRINT*)&ActorDescAr.ComponentDesc, *(UPTRINT*)&ActorDescAr.BaseComponentDesc, ActorDescAr.BaseComponentDescSizeof))
129 {
130 V.Value = *BaseDefaultValue;
131 }
132 }
133 else if (const DestPropertyType* BaseDefaultValue = GetBaseDefaultValue(*(UPTRINT*)&ActorDescAr.ActorDesc, *(UPTRINT*)&ActorDescAr.BaseDesc, ActorDescAr.BaseDescSizeof))
134 {
135 V.Value = *BaseDefaultValue;
136 }
137 else
138 {
139 check(ActorDescAr.bIsMissingBaseDesc);
140 }
141 }
142
143 return Ar;
144 }
145
148 };
149
157};
158
160{
161public:
167 {
169 }
170
171 //~ Begin FArchive Interface
172 virtual FArchive& operator<<(FName& Value) override;
173 virtual FArchive& operator<<(FSoftObjectPath& Value) override;
174 virtual void Serialize(void* V, int64 Length) override;
175 //~ End FArchive Interface
176
177 virtual FArchive& operator<<(FTopLevelAssetPath& Value) override;
178
179private:
182 bool bIsPatching;
183};
184
185template <typename DestPropertyType, typename SourcePropertyType = DestPropertyType>
186using TDeltaSerialize = FActorDescArchive::TDeltaSerializer<DestPropertyType, SourcePropertyType>;
187#endif
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
#define check(expr)
Definition AssertionMacros.h:314
#define unimplemented()
Definition AssertionMacros.h:321
FPlatformTypes::int64 int64
A 64-bit signed integer.
Definition Platform.h:1127
FPlatformTypes::UPTRINT UPTRINT
An unsigned integer the same size as a pointer.
Definition Platform.h:1146
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
FArchive & operator<<(FArchive &Ar, FEnvQueryDebugProfileData::FStep &Data)
Definition EnvQueryTypes.cpp:489
void Init()
Definition LockFreeList.h:4
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition ArchiveProxy.h:19
Definition Archive.h:1208
friend FArchive & operator<<(FArchive &Ar, ANSICHAR &Value)
Definition Archive.h:1387
virtual CORE_API void UsingCustomVersion(const struct FGuid &Guid)
Definition Archive.cpp:590
UE_FORCEINLINE_HINT bool IsLoading() const
Definition Archive.h:236
CORE_API int32 CustomVer(const struct FGuid &Key) const
Definition Archive.cpp:602
UE_FORCEINLINE_HINT bool IsSaving() const
Definition Archive.h:248
Definition NameTypes.h:617
Definition Text.h:385
Definition WorldPartitionActorDesc.h:282
Definition WorldPartitionActorDesc.h:250
Definition AndroidPlatformMisc.h:14
Definition Object.h:95
@ false
Definition radaudio_common.h:23
CORE_API static const FGuid GUID
Definition FortniteMainBranchObjectVersion.h:21
Definition LazyObjectPtr.h:151
Definition ObjectPtr.h:55
Definition SoftObjectPath.h:56
Definition SoftObjectPtr.h:45
Definition TopLevelAssetPath.h:38
Definition WeakObjectPtr.h:49