FRepLayout

This class holds all replicated properties for a given type (either a [UClass](API\Runtime\CoreUObject\UObject\UClass), [UStruct](API\Runtime\CoreUObject\UObject\UStruct), or [UFunction](API\Runtime\CoreUObject\UObject\UFunction)).

Windows
MacOS
Linux

Inheritance Hierarchy

References

Module

Engine

Header

/Engine/Source/Runtime/Engine/Public/Net/RepLayout.h

Include

#include "Net/RepLayout.h"

Syntax

class FRepLayout :
    public FGCObject,
    public TSharedFromThis< FRepLayout >

Remarks

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:

  • What the underlying data type is.

  • How the data is laid out in memory.

  • How the data should be serialized.

  • How the data should be compared (between instances of Objects, Structs, etc.).

  • Whether or not the data should trigger notifications on change (RepNotifies).

  • Whether or not the data is conditional (e.g. may be skipped when sending to some or all connections).

Commands are split into 2 main types: Parent Commands ( 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, ChildCommands 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 ChildCommands. All other structs will recursively generate ChildCommands 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. 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

maintains a circular buffer that tracks recently sent Changelists (). 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.

Constructors

No constructors are accessible with public or protected access.

Destructors

Name Description

Public function Virtual

~FRepLayout()

Functions

Name Description

Public function

void

 

BuildSharedSerializationForRPC

(
    const FConstRepObjectDataBuffer Dat...
)

Builds shared serialization state for a multicast rpc

Public function Const

void

 

CallRepNotifies

(
    FReceivingRepState* RepState,
    UObject* Object
)

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

Public function

void

 

ClearSharedSerializationForRPC()

Clears shared serialization state for a multicast rpc

Public function Const

void

 

CountBytes

(
    FArchive& Ar
)

Public function Static

TSharedPtr< ...

 

CreateFromClass

(
    UClass* InObjectClass,
    const UNetConnection* ServerCo...,
    const ECreateRepLayoutFlags Flags
)

Creates a new FRepLayout for the given class.

Public function Static

TSharedPtr< ...

 

CreateFromFunction

(
    UFunction* InFunction,
    const UNetConnection* ServerCo...,
    const ECreateRepLayoutFlags Flags
)

Creates a new FRepLayout for the given function.

Public function Static

TSharedPtr< ...

 

CreateFromStruct

(
    UStruct* InStruct,
    const UNetConnection* ServerCo...,
    const ECreateRepLayoutFlags Flags
)

Creates a new FRepLayout for the given struct.

Public function Const

TSharedPtr< ...

 

CreateReplicationChangelistMgr

(
    const UObject* InObject,
    const ECreateReplicationChangelistM...
)

Creates and initializes a new FReplicationChangelistMgr.

Public function Const

TUniquePtr< ...

 

CreateRepState

(
    const FConstRepObjectDataBuffer Sou...,
    TSharedPtr< FRepChangedPropertyTrac...,
    ECreateRepStateFlags Flags
)

Creates and initializes a new FRepState.

Public function Const

FRepStateSta...

 

CreateShadowBuffer

(
    const FConstRepObjectDataBuffer Sou...
)

Creates and initialize a new Shadow Buffer.

Public function Const

bool

 

DiffProperties

(
    TArray< FProperty* >* Rep...,
    TRepDataBuffer< DstType > Destinati...,
    TConstRepDataBuffer< SrcType > Sour...,
    const EDiffPropertiesFlags Flags
)

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.

Public function Const

bool

 

DiffStableProperties

(
    TArray< FProperty* >* Rep...,
    TArray< UObject* >* ObjRe...,
    TRepDataBuffer< DstType > Destinati...,
    TConstRepDataBuffer< SrcType > Sour...
)

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

Public function Const

void

 

GatherGuidReferences

(
    FReceivingRepState*__restrict ...,
    FNetDeltaSerializeInfo& Params,
    TSet< FNetworkGUID >& OutReference...,
    int32& OutTrackedGuidMemoryBytes
)

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.

Public function Const

uint32

 

GenerateChecksum

(
    const FRepState* RepState
)

Public function Const

const ERepLa...

 

GetFlags()

Public function Const

const int32

 

GetNumParents()

Public function Const

UObject *...

 

GetOwner()

Public function

T *

 

GetShadowStateValue

(
    FRepShadowDataBuffer Data,
    const FName PropertyName
)

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

Public function Const

const T *...

 

GetShadowStateValue

(
    FConstRepShadowDataBuffer Data,
    const FName PropertyName
)

Public function Const

void

 

InitChangedTracker

(
    FRepChangedPropertyTracker* Ch...
)

Public function Const

const bool

 

IsEmpty()

Public function Const

bool

 

MoveMappedObjectToUnmapped

(
    FReceivingRepState*__restrict ...,
    FNetDeltaSerializeInfo& Params,
    const FNetworkGUID& GUID
)

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

Public function Const

bool

 

ReceiveProperties

(
    UActorChannel* OwningChannel,
    UClass* InObjectClass,
    FReceivingRepState*__restrict ...,
    UObject* Object,
    FNetBitReader& InBunch,
    bool& bOutHasUnmapped,
    bool& bOutGuidsChanged,
    const EReceivePropertiesFlags InFla...
)

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

Public function Const

bool

 

ReceiveProperties_BackwardsCompatible

(
    UNetConnection* Connection,
    FReceivingRepState*__restrict ...,
    FRepObjectDataBuffer Data,
    FNetBitReader& InBunch,
    bool& bOutHasUnmapped,
    const bool bEnableRepNotifies,
    bool& bOutGuidsChanged,
    UObject* OwningObject
)

Currently only used for Replays / with the UDemoNetDriver.

Public function Const

void

 

ReceivePropertiesForRPC

(
    UObject* Object,
    UFunction* Function,
    UActorChannel* Channel,
    FNetBitReader& Reader,
    FRepObjectDataBuffer Data,
    TSet< FNetworkGUID >& UnmappedGuid...
)

Public function Const

bool

 

ReplicateProperties

(
    FSendingRepState*restrict Re...,
    FRepChangelistState*
restrict...,
    const FConstRepObjectDataBuffer Dat...,
    UClass* ObjectClass,
    UActorChannel* OwningChannel,
    FNetBitWriter& Writer,
    const FReplicationFlags& RepFlags
)

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

Public function Const

void

 

SendProperties_BackwardsCompatible

(
    FSendingRepState*__restrict Re...,
    FRepChangedPropertyTracker* Ch...,
    const FConstRepObjectDataBuffer Dat...,
    UNetConnection* Connection,
    FNetBitWriter& Writer,
    TArray< uint16 >& Changed
)

Currently only used for Replays / with the UDemoNetDriver.

Public function Const

void

 

SendPropertiesForRPC

(
    UFunction* Function,
    UActorChannel* Channel,
    FNetBitWriter& Writer,
    const FConstRepObjectDataBuffer Dat...
)

Public function Const

void

 

SerializeObjectReplicatedProperties

(
    UObject* Object,
    FBitArchive& Ar
)

Serializes all replicated properties of a UObject in or out of an archive (depending on what type of archive it is).

Public function Const

void

 

SerializePropertiesForStruct

(
    UStruct* Struct,
    FBitArchive& Ar,
    UPackageMap* Map,
    FRepObjectDataBuffer Data,
    bool& bHasUnmapped,
    const UObject* OwningObject
)

Struct support.

Public function Const

void

 

UpdateUnmappedObjects

(
    FReceivingRepState*__restrict ...,
    UPackageMap* PackageMap,
    UObject* Object,
    FNetDeltaSerializeInfo& Params,
    bool& bCalledPreNetReceive,
    bool& bOutSomeObjectsWereMapped,
    bool& bOutHasMoreUnmapped
)

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

Public function Const

void

 

ValidateWithChecksum

(
    TConstRepDataBuffer< DataType > Dat...,
    FBitArchive& Ar
)

Overridden from FGCObject

Name Description

Public function Virtual

void

 

AddReferencedObjects

(
    FReferenceCollector& Collector
)

Pure virtual that must be overloaded by the inheriting class.

Public function Virtual Const

FString

 

GetReferencerName()

Use this method to report a name for your referencer.

See Also

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss