engine
 
载入中...
搜索中...
未找到
Public 成员函数 | 静态 Public 成员函数 | 友元 | 所有成员列表
FRepLayout类 参考

This class holds all replicated properties for a given type (either a UClass, UStruct, or UFunction). 更多...

#include <RepLayout.h>

+ 类 FRepLayout 继承关系图:

Public 成员函数

virtual ENGINE_API void AddReferencedObjects (FReferenceCollector &Collector) override
 Pure virtual that must be overloaded by the inheriting class. 更多...
 
void ENGINE_API BuildSharedSerializationForRPC (const FConstRepObjectDataBuffer Data)
 Builds shared serialization state for a multicast rpc
 
void CallRepNotifies (FReceivingRepState *RepState, UObject *Object) const
 Fire any RepNotifies that have been queued for an object while receiving properties. 更多...
 
void ENGINE_API ClearSharedSerializationForRPC ()
 Clears shared serialization state for a multicast rpc
 
TSharedPtr< FReplicationChangelistMgr > CreateReplicationChangelistMgr (const UObject *InObject, const ECreateReplicationChangelistMgrFlags CreateFlags) const
 Creates and initializes a new FReplicationChangelistMgr. 更多...
 
TUniquePtr< FRepState > CreateRepState (const FConstRepObjectDataBuffer Source, TSharedPtr< FRepChangedPropertyTracker > &InRepChangedPropertyTracker, ECreateRepStateFlags Flags) const
 Creates and initializes a new FRepState. 更多...
 
FRepStateStaticBuffer CreateShadowBuffer (const FConstRepObjectDataBuffer Source) const
 Creates and initialize a new Shadow Buffer. 更多...
 
template<ERepDataBufferType DstType, ERepDataBufferType SrcType>
bool DiffProperties (TArray< FProperty * > *RepNotifies, TRepDataBuffer< DstType > Destination, TConstRepDataBuffer< SrcType > Source, const EDiffPropertiesFlags Flags) const
 Compare all properties between source and destination buffer, and optionally update the destination buffer to match the state of the source buffer if they don't match. 更多...
 
template<ERepDataBufferType DstType, ERepDataBufferType SrcType>
bool DiffStableProperties (TArray< FProperty * > *RepNotifies, TArray< UObject * > *ObjReferences, TRepDataBuffer< DstType > Destination, TConstRepDataBuffer< SrcType > Source) const
 
void GatherGuidReferences (FReceivingRepState *RESTRICT RepState, struct FNetDeltaSerializeInfo &Params, TSet< FNetworkGUID > &OutReferencedGuids, int32 &OutTrackedGuidMemoryBytes) const
 Finds any properties in the Shadow Buffer of the given Rep State that are currently valid (mapped or unmapped) references to other network objects, and retrieves the associated Net GUIDS. 更多...
 
virtual ENGINE_API FString GetReferencerName () const override
 Use this method to report a name for your referencer.
 
template<typename T >
T * GetShadowStateValue (FRepShadowDataBuffer Data, const FName PropertyName)
 Gets a pointer to the value of the given property in the Shadow State. 更多...
 
bool MoveMappedObjectToUnmapped (FReceivingRepState *RESTRICT RepState, struct FNetDeltaSerializeInfo &Params, const FNetworkGUID &GUID) const
 Called to indicate that the object referenced by the FNetworkGUID is no longer mapped. 更多...
 
bool ReceiveProperties (UActorChannel *OwningChannel, UClass *InObjectClass, FReceivingRepState *RESTRICT RepState, UObject *Object, FNetBitReader &InBunch, bool &bOutHasUnmapped, bool &bOutGuidsChanged, const EReceivePropertiesFlags InFlags) const
 Reads all property values from the received buffer, and applies them to the property memory. 更多...
 
bool ReceiveProperties_BackwardsCompatible (UNetConnection *Connection, FReceivingRepState *RESTRICT RepState, FRepObjectDataBuffer Data, FNetBitReader &InBunch, bool &bOutHasUnmapped, const bool bEnableRepNotifies, bool &bOutGuidsChanged) const
 Currently only used for Replays / with the UDemoNetDriver.
 
void ReceivePropertiesForRPC (UObject *Object, UFunction *Function, UActorChannel *Channel, FNetBitReader &Reader, FRepObjectDataBuffer Data, TSet< FNetworkGUID > &UnmappedGuids) const
 
bool ReplicateProperties (FSendingRepState *RESTRICT RepState, FRepChangelistState *RESTRICT RepChangelistState, const FConstRepObjectDataBuffer Data, UClass *ObjectClass, UActorChannel *OwningChannel, FNetBitWriter &Writer, const FReplicationFlags &RepFlags) const
 Writes out any changed properties for an Object into the given data buffer, and does book keeping for the RepState of the object. 更多...
 
void SendProperties_BackwardsCompatible (FSendingRepState *RESTRICT RepState, FRepChangedPropertyTracker *ChangedTracker, const FConstRepObjectDataBuffer Data, UNetConnection *Connection, FNetBitWriter &Writer, TArray< uint16 > &Changed) const
 Currently only used for Replays / with the UDemoNetDriver.
 
void ENGINE_API SendPropertiesForRPC (UFunction *Function, UActorChannel *Channel, FNetBitWriter &Writer, const FConstRepObjectDataBuffer Data) const
 
ENGINE_API void SerializeObjectReplicatedProperties (UObject *Object, FBitArchive &Ar) const
 Serializes all replicated properties of a UObject in or out of an archive (depending on what type of archive it is).
 
void UpdateUnmappedObjects (FReceivingRepState *RESTRICT RepState, UPackageMap *PackageMap, UObject *Object, struct FNetDeltaSerializeInfo &Params, bool &bCalledPreNetReceive, bool &bOutSomeObjectsWereMapped, bool &bOutHasMoreUnmapped) const
 Attempts to update any unmapped network guids referenced by the RepState. 更多...
 
- Public 成员函数 继承自 FGCObject
virtual void AddReferencedObjects (FReferenceCollector &Collector)=0
 Pure virtual that must be overloaded by the inheriting class. 更多...
 
 FGCObject (FGCObject &&)
 Move constructor
 
 FGCObject (FGCObject const &)
 Copy constructor
 
 FGCObject (void)
 Tells the global object that forwards AddReferencedObjects calls on to objects that a new object is requiring AddReferencedObjects call.
 
virtual FString GetReferencerName () const
 Use this method to report a name for your referencer.
 
virtual bool GetReferencerPropertyName (UObject *Object, FString &OutPropertyName) const
 Use this method to report how the specified object is referenced, if necessary
 
virtual ~FGCObject (void)
 Removes this instance from the global referencer's list
 
- Public 成员函数 继承自 TSharedFromThis< FRepLayout >
TSharedRef< FRepLayout, Mode > AsShared ()
 Provides access to a shared reference to this object. 更多...
 
TSharedRef< FRepLayout const, Mode > AsShared () const
 Provides access to a shared reference to this object (const.) Note that is only valid to call this after a shared reference (or shared pointer) to the object has already been created. 更多...
 
FORCEINLINE bool DoesSharedInstanceExist () const
 Checks whether our referenced instance is valid (ie, whether it's safe to call AsShared). 更多...
 
FORCEINLINE void UpdateWeakReferenceInternal (TSharedPtr< SharedPtrType, Mode > const *InSharedPtr, OtherType *InObject) const
 INTERNAL USE ONLY – Do not call this method. 更多...
 
FORCEINLINE void UpdateWeakReferenceInternal (TSharedRef< SharedRefType, Mode > const *InSharedRef, OtherType *InObject) const
 INTERNAL USE ONLY – Do not call this method. 更多...
 

静态 Public 成员函数

static ENGINE_API TSharedPtr< FRepLayout > CreateFromClass (UClass *InObjectClass, const UNetConnection *ServerConnection=nullptr, const ECreateRepLayoutFlags Flags=ECreateRepLayoutFlags::None)
 Creates a new FRepLayout for the given class.
 
static TSharedPtr< FRepLayout > CreateFromFunction (UFunction *InFunction, const UNetConnection *ServerConnection=nullptr, const ECreateRepLayoutFlags Flags=ECreateRepLayoutFlags::None)
 Creates a new FRepLayout for the given function.
 
static ENGINE_API TSharedPtr< FRepLayout > CreateFromStruct (UStruct *InStruct, const UNetConnection *ServerConnection=nullptr, const ECreateRepLayoutFlags Flags=ECreateRepLayoutFlags::None)
 Creates a new FRepLayout for the given struct.
 
- 静态 Public 成员函数 继承自 FGCObject
static void StaticInit (void)
 Initializes the global object referencer and adds it to the root set.
 

友元

struct FRepStateStaticBuffer
 

额外继承的成员函数

- 静态 Public 属性 继承自 FGCObject
static UGCObjectReferencer * GGCObjectReferencer
 The static object referencer object that is shared across all garbage collectible non-UObject objects.
 
- Protected 成员函数 继承自 TSharedFromThis< FRepLayout >
FORCEINLINE TSharedFromThis & operator= (TSharedFromThis const &)
 Hidden stub assignment operator
 
 TSharedFromThis ()
 Hidden stub constructor
 
 TSharedFromThis (TSharedFromThis const &)
 Hidden stub copy constructor
 
 ~TSharedFromThis ()
 Hidden destructor
 
- 静态 Protected 成员函数 继承自 TSharedFromThis< FRepLayout >
static FORCEINLINE TSharedRef< OtherType const, Mode > SharedThis (const OtherType *ThisPtr)
 Provides access to a shared reference to an object, given the object's 'this' pointer. 更多...
 
static FORCEINLINE TSharedRef< OtherType, Mode > SharedThis (OtherType *ThisPtr)
 Provides access to a shared reference to an object, given the object's 'this' pointer. 更多...
 

详细描述

This class holds all replicated properties for a given type (either a UClass, UStruct, or UFunction).

Helpers functions exist to read, write, and compare property state.

There is only one FRepLayout for a given type, meaning all instances of the type share the FRepState.

COMMANDS:

All Properties in a RepLayout are represented as Layout Commands. These commands dictate:

Commands are split into 2 main types: Parent Commands (

参见
FRepParentCmd) and Child Commands (
FRepLayoutCmd).

A Parent Command represents a Top Level Property of the type represented by an FRepLayout. A Child Command represents any Property (even nested properties).

E.G., Imagine an Object O, with 4 Properties, CA, DA, I, and S. CA is a fixed size C-Style array. This will generate 1 Parent Command and 1 Child Command for each element in the array. DA is a dynamic array (TArray). This will generate only 1 Parent Command and 1 Child Command, both referencing the array. Additionally, Child Commands will be added recursively for the element type of the array. S is a UStruct. All struct types generate 1 Parent Command for the Struct Property. Additionally: If the struct has a native NetSerialize method then it will generate 1 Child Command referencing the struct. If the struct has a native NetDeltaSerialize method then it will generate no Child Commands. All other structs will recursively generate Child Commands for each nested Net Property in the struct. Note, in this case there is no Child Command associated with the top level struct property. I is an integer (or other supported non-Struct type, or object reference). This will generate 1 Parent Command and 1 Child Command.

CHANGELISTS

Along with Layout Commands that describe the Properties in a type, RepLayout uses changelists to know what Properties have changed between frames.

参见
FRepChangedHistory.

Changelists are arrays of Property Handles that describe what Properties have changed, however they don't track the actual values of the Properties.

Changelists can contain "sub-changelists" for arrays. Formally, they can be described as the following grammar:

Terminator          ::= 0
Handle              ::= Integer between 1 ~ 65535
Number              ::= Integer between 0 ~ 65535
Changelist          ::= <Terminator> | <Handle><Changelist> | <Handle><Array-Changelist><Changelist>
Array-Changelist:   ::= <Number><Changelist>

An important distinction is that Handles do not have a 1:1 mapping with RepLayoutCommands. Handles are 1-based (as opposed to 0-based), and track a relative command index within a single level of a changelist. Each Array Command, regardless of the number of child Commands it has, will only be count as a single handle in its owning changelist. Each time we recurse into an Array-Changelist, our handles restart at 1 for that "depth", and they correspond to the Commands associated with the Array's element type.

In order to generate Changelists, Layout Commands are sequentially applied that compare the values of an object's cached state to a object's current state. Any properties that are found to be different will have their handle written into the changelist. This means handles within a changelists are inherently ordered (with arrays inserted whose Handles are also ordered).

When we want to replicate properties for an object, merge together any outstanding changelists and then iterate over it using Layout Commands that serialize the necessary property data.

Receiving is very similar, except the Handles are baked into the serialized data so no explicit changelist is required. As each Handle is read, a Layout Command is applied that serializes the data from the network bunch and applies it to an object.

RETRIES AND RELIABLES

@FSendingRepState maintains a circular buffer that tracks recently sent Changelists (@FRepChangedHistory). These history items track the Changelist alongside the Packet ID that the bunches were sent in.

Once we receive ACKs for all associated packets, the history will be removed from the buffer. If NAKs are received for any of the packets, we will merge the changelist into the next set of properties we replicate.

If we receive no NAKs or ACKs for an extended period, to prevent overflows in the history buffer, we will merge the entire buffer into a single monolithic changelist which will be sent alongside the next set of properties.

In both cases of NAKs or no response, the merged changelists will be tracked in the latest history item alongside with other sent properties.

When "net.PartialBunchReliableThreshold" is non-zero and property data bunches are split into partial bunches above the threshold, we will not generate a history item. Instead, we will rely on the reliable bunch framework for resends and replication of the Object will be completely paused until the property bunches are acknowledged. However, this will not affect other history items since they are still unreliable.

成员函数说明

◆ AddReferencedObjects()

virtual ENGINE_API void FRepLayout::AddReferencedObjects ( FReferenceCollector &  Collector)
overridevirtual

Pure virtual that must be overloaded by the inheriting class.

Use this method to serialize any UObjects contained that you wish to keep around.

参数
CollectorThe collector of referenced objects.

实现了 FGCObject.

◆ CallRepNotifies()

void FRepLayout::CallRepNotifies ( FReceivingRepState *  RepState,
UObject *  Object 
) const

Fire any RepNotifies that have been queued for an object while receiving properties.

参数
RepStateThe ReceivingRepState associated with the Object. This is expected to be valid.
ObjectThe Object that received properties.

◆ CreateReplicationChangelistMgr()

TSharedPtr< FReplicationChangelistMgr > FRepLayout::CreateReplicationChangelistMgr ( const UObject *  InObject,
const ECreateReplicationChangelistMgrFlags  CreateFlags 
) const

Creates and initializes a new FReplicationChangelistMgr.

参数
InObjectThe Object that is being managed.
CreateFlagsFlags modifying how the manager is created.

◆ CreateRepState()

TUniquePtr< FRepState > FRepLayout::CreateRepState ( const FConstRepObjectDataBuffer  Source,
TSharedPtr< FRepChangedPropertyTracker > &  InRepChangedPropertyTracker,
ECreateRepStateFlags  Flags 
) const

Creates and initializes a new FRepState.

This includes:

  • Initializing the ShadowData.
  • Associating and validating the appropriate ChangedPropertyTracker.
  • Building initial ConditionMap.
参数
RepStateThe RepState to initialize.
ClassThe class of the object represented by the input memory.
SrcMemory buffer storing object property data.
InRepChangedPropertyTrackerThe PropertyTracker we want to associate with the RepState.
返回
A new RepState. Note, maybe a a FRepStateBase or FRepStateSending based on parameters.

◆ CreateShadowBuffer()

FRepStateStaticBuffer FRepLayout::CreateShadowBuffer ( const FConstRepObjectDataBuffer  Source) const

Creates and initialize a new Shadow Buffer.

Shadow Data / Shadow States are used to cache property data so that the Object's state can be compared between frames to see if any properties have changed. They are also used on clients to keep track of RepNotify state.

This includes:

  • Allocating memory for all Properties in the class.
  • Constructing instances of each Property.
  • Copying the values of the Properties from given object.
参数
SourceMemory buffer storing object property data.

◆ DiffProperties()

template<ERepDataBufferType DstType, ERepDataBufferType SrcType>
bool FRepLayout::DiffProperties ( TArray< FProperty * > *  RepNotifies,
TRepDataBuffer< DstType >  Destination,
TConstRepDataBuffer< SrcType >  Source,
const EDiffPropertiesFlags  Flags 
) const

Compare all properties between source and destination buffer, and optionally update the destination buffer to match the state of the source buffer if they don't match.

参数
RepNotifiesRepNotifies that should be fired if we're changing properties.
DestinationDestination buffer that will be changed if we're changing properties.
SourceSource buffer containing desired property values.
FlagsControls how DiffProperties behaves.
返回
True if there were any properties with different values.

◆ DiffStableProperties()

template<ERepDataBufferType DstType, ERepDataBufferType SrcType>
bool FRepLayout::DiffStableProperties ( TArray< FProperty * > *  RepNotifies,
TArray< UObject * > *  ObjReferences,
TRepDataBuffer< DstType >  Destination,
TConstRepDataBuffer< SrcType >  Source 
) const
参见
DiffProperties

The main difference between this method and DiffProperties is that this method will skip any properties that are:

  • Transient
  • Point to Actors or ActorComponents
  • Point to Objects that are non-stably named for networking.
参数
RepNotifiesRepNotifies that should be fired if we're changing properties.
DestinationDestination buffer that will be changed if we're changing properties.
SourceSource buffer containing desired property values.
FlagsControls how DiffProperties behaves.
返回
True if there were any properties with different values.

◆ GatherGuidReferences()

void FRepLayout::GatherGuidReferences ( FReceivingRepState *RESTRICT  RepState,
struct FNetDeltaSerializeInfo &  Params,
TSet< FNetworkGUID > &  OutReferencedGuids,
int32 &  OutTrackedGuidMemoryBytes 
) const

Finds any properties in the Shadow Buffer of the given Rep State that are currently valid (mapped or unmapped) references to other network objects, and retrieves the associated Net GUIDS.

参数
RepStateThe RepState whose shadow buffer we'll inspect. This is expected to be valid.
OutReferencedGuidsSet of Net GUIDs being referenced by the RepState.
OutTrackedGuidMemoryBytesTotal memory usage of properties containing GUID references.

◆ GetShadowStateValue()

template<typename T >
T * FRepLayout::GetShadowStateValue ( FRepShadowDataBuffer  Data,
const FName  PropertyName 
)
inline

Gets a pointer to the value of the given property in the Shadow State.

返回
A pointer to the property value in the shadow state, or nullptr if the property wasn't found.

◆ MoveMappedObjectToUnmapped()

bool FRepLayout::MoveMappedObjectToUnmapped ( FReceivingRepState *RESTRICT  RepState,
struct FNetDeltaSerializeInfo &  Params,
const FNetworkGUID &  GUID 
) const

Called to indicate that the object referenced by the FNetworkGUID is no longer mapped.

This can happen if the Object was destroyed, if its level was streamed out, or for any other reason that may cause the Server (or client) to no longer be able to properly reference the object. Note, it's possible the object may become valid again later.

参数
RepStateThe RepState that holds a reference to the object. This is expected to be valid.
GUIDThe Network GUID of the object to unmap.
ParamsDelta Serialization Params used for Custom Delta Properties.

◆ ReceiveProperties()

bool FRepLayout::ReceiveProperties ( UActorChannel *  OwningChannel,
UClass *  InObjectClass,
FReceivingRepState *RESTRICT  RepState,
UObject *  Object,
FNetBitReader &  InBunch,
bool &  bOutHasUnmapped,
bool &  bOutGuidsChanged,
const EReceivePropertiesFlags  InFlags 
) const

Reads all property values from the received buffer, and applies them to the property memory.

参数
OwningChannelThe channel of the Actor that owns the object whose properties we're reading.
InObjectClassClass of the object.
RepStateRepState for the object. This is expected to be valid.
DataPointer to memory where read property data should be stored.
InBunchThe data that should be read.
bOutHasUnmappedWhether or not unmapped GUIDs were read.
bOutGuidsChangedWhether or not any GUIDs were changed.
FlagsControls how ReceiveProperties behaves.

◆ ReceivePropertiesForRPC()

void FRepLayout::ReceivePropertiesForRPC ( UObject *  Object,
UFunction *  Function,
UActorChannel *  Channel,
FNetBitReader &  Reader,
FRepObjectDataBuffer  Data,
TSet< FNetworkGUID > &  UnmappedGuids 
) const

◆ ReplicateProperties()

bool FRepLayout::ReplicateProperties ( FSendingRepState *RESTRICT  RepState,
FRepChangelistState *RESTRICT  RepChangelistState,
const FConstRepObjectDataBuffer  Data,
UClass *  ObjectClass,
UActorChannel *  OwningChannel,
FNetBitWriter &  Writer,
const FReplicationFlags &  RepFlags 
) const

Writes out any changed properties for an Object into the given data buffer, and does book keeping for the RepState of the object.

Note, this does not compare properties or send them on the wire, it's only used to serialize properties.

参数
RepStateRepState for the object. This is expected to be valid.
RepChangelistStateRepChangelistState for the object.
DataPointer to memory where property data is stored.
ObjectClassClass of the object.
WriterWriter used to store / write out the replicated properties.
RepFlagsFlags used for replication.

◆ SendPropertiesForRPC()

void ENGINE_API FRepLayout::SendPropertiesForRPC ( UFunction *  Function,
UActorChannel *  Channel,
FNetBitWriter &  Writer,
const FConstRepObjectDataBuffer  Data 
) const
参见
SendProperties.

◆ UpdateUnmappedObjects()

void FRepLayout::UpdateUnmappedObjects ( FReceivingRepState *RESTRICT  RepState,
UPackageMap *  PackageMap,
UObject *  Object,
struct FNetDeltaSerializeInfo &  Params,
bool &  bCalledPreNetReceive,
bool &  bOutSomeObjectsWereMapped,
bool &  bOutHasMoreUnmapped 
) const

Attempts to update any unmapped network guids referenced by the RepState.

If any guids become mapped, we will update corresponding properties on the given object to point to the referenced object.

参数
RepStateThe RepState associated with the Object. This is expected to be valid.
PackageMapThe package map that controls FNetworkGUID associations.
ObjectThe live game object whose properties should be updated if we map any objects.
bOutSomeObjectsWereMappedWhether or not we successfully mapped any references.
bOutHasMoreUnamappedWhether or not there are more unmapped references in the RepState.

该类的文档由以下文件生成: