UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FObjectReplicator Class Reference

#include <DataReplication.h>

Classes

struct  FRPCCallInfo
 
struct  FRPCPendingLocalCall
 

Public Types

enum class  ESkipRpcBehavior { NeverSkip , SkipIfNotReady , AlwaysSkip }
 

Public Member Functions

ENGINE_API FObjectReplicator ()
 
ENGINE_API ~FObjectReplicator ()
 
ENGINE_API void InitWithObject (UObject *InObject, UNetConnection *InConnection, bool bUseDefaultState=true)
 
ENGINE_API void CleanUp ()
 
ENGINE_API void StartReplicating (class UActorChannel *InActorChannel)
 
ENGINE_API void StopReplicating (class UActorChannel *InActorChannel)
 
ENGINE_API void InitRecentProperties (uint8 *Source)
 
ENGINE_API bool ValidateAgainstState (const UObject *ObjectState)
 
ENGINE_API bool SendCustomDeltaProperty (UObject *InObject, uint16 CustomDeltaProperty, FNetBitWriter &OutBunch, TSharedPtr< INetDeltaBaseState > &NewFullState, TSharedPtr< INetDeltaBaseState > &OldState)
 
ENGINE_API void ReceivedNak (int32 NakPacketId)
 
ENGINE_API void CountBytes (FArchive &Ar) const
 
ENGINE_API void ReplicateCustomDeltaProperties (FNetBitWriter &Bunch, FReplicationFlags RepFlags, bool &bSkippedPropertyCondition)
 
ENGINE_API bool ReplicateProperties (FOutBunch &Bunch, FReplicationFlags RepFlags)
 
ENGINE_API bool ReplicateProperties (FOutBunch &Bunch, FReplicationFlags RepFlags, FNetBitWriter &Writer)
 
ENGINE_API bool ReplicateProperties_r (FOutBunch &Bunch, FReplicationFlags RepFlags, FNetBitWriter &Writer)
 
ENGINE_API void PostSendBunch (FPacketIdRange &PacketRange, uint8 bReliable)
 
ENGINE_API bool ReceivedBunch (FNetBitReader &Bunch, const FReplicationFlags &RepFlags, const bool bHasRepLayout, bool &bOutHasUnmapped)
 
ENGINE_API bool ReceivedRPC (FNetBitReader &Reader, TSet< FNetworkGUID > &OutUnmappedGuids, bool &bOutSkippedRpcExec, const FReplicationFlags &RepFlags, const FFieldNetCache *FieldCache, ESkipRpcBehavior SkipRpcBehavior)
 
bool ReceivedRPC (FNetBitReader &Reader, const FReplicationFlags &RepFlags, const FFieldNetCache *FieldCache, const bool bCanDelayRPC, bool &bOutDelayRPC, TSet< FNetworkGUID > &OutUnmappedGuids)
 
ENGINE_API void UpdateGuidToReplicatorMap ()
 
ENGINE_API bool MoveMappedObjectToUnmapped (const FNetworkGUID &GUID)
 
ENGINE_API void PostReceivedBunch ()
 
ENGINE_API void ForceRefreshUnreliableProperties ()
 
ENGINE_API void QueueRemoteFunctionBunch (UFunction *Func, FOutBunch &Bunch)
 
ENGINE_API bool ReadyForDormancy (bool bDebug=false)
 
ENGINE_API void StartBecomingDormant ()
 
ENGINE_API void CallRepNotifies (bool bSkipIfChannelHasQueuedBunches) const
 
ENGINE_API void UpdateUnmappedObjects (bool &bOutHasMoreUnmapped)
 
ENGINE_API void ExecutePendingTransactionalRPCs ()
 
TWeakObjectPtr< UObjectGetWeakObjectPtr () const
 
UObjectGetObject () const
 
void SetObject (UObject *NewObj)
 
void ReleaseStrongReference ()
 
void PreNetReceive ()
 
void PostNetReceive ()
 
ENGINE_API void QueuePropertyRepNotify (UObject *Object, FProperty *Property, const int32 ElementIndex, TArray< uint8 > &MetaData)
 
ENGINE_API void WritePropertyHeaderAndPayload (UObject *Object, FProperty *Property, FNetFieldExportGroup *NetFieldExportGroup, FNetBitWriter &Bunch, FNetBitWriter &Payload) const
 
ENGINE_API bool CanSkipUpdate (FReplicationFlags Flags)
 
bool IsDirtyForReplay () const
 
void ResetReplayDirtyTracking ()
 

Public Attributes

FNetworkGUID ObjectNetGUID
 
int32 TrackedGuidMemoryBytes
 
uint32 bLastUpdateEmpty: 1
 
uint32 bOpenAckCalled: 1
 
uint32 bForceUpdateUnmapped: 1
 
uint32 bHasReplicatedProperties: 1
 
uint32 bSentSubObjectCreation: 1
 
TSharedPtr< class FReplicationChangelistMgrChangelistMgr
 
TSharedPtr< FRepLayoutRepLayout
 
TUniquePtr< FRepStateRepState
 
TUniquePtr< FRepStateCheckpointRepState
 
TObjectPtr< UClassObjectClass
 
UObjectObjectPtr
 
UNetConnectionConnection
 
class UActorChannelOwningChannel
 
FOutBunchRemoteFunctions
 
TArray< FRPCCallInfoRemoteFuncInfo
 
TArray< FRPCPendingLocalCallPendingLocalRPCs
 
TSet< FNetworkGUIDReferencedGuids
 

Detailed Description

Represents an object that is currently being replicated or handling RPCs.

|----------------|
| NetGUID ObjRef |
    |----------------|
 |                |     
| Properties...  |
|                |  
| RPCs...        |
 |                |
 |----------------|
| </End Tag>     |
|----------------|

Member Enumeration Documentation

◆ ESkipRpcBehavior

Enumerator
NeverSkip 
SkipIfNotReady 
AlwaysSkip 

Constructor & Destructor Documentation

◆ FObjectReplicator()

FObjectReplicator::FObjectReplicator ( )

◆ ~FObjectReplicator()

FObjectReplicator::~FObjectReplicator ( )

Member Function Documentation

◆ CallRepNotifies()

void FObjectReplicator::CallRepNotifies ( bool  bSkipIfChannelHasQueuedBunches) const

◆ CanSkipUpdate()

bool FObjectReplicator::CanSkipUpdate ( FReplicationFlags  Flags)
Returns
True if we've determined nothing needs to be updated / resent by the replicator, meaning we can safely skip updating it this frame.

◆ CleanUp()

void FObjectReplicator::CleanUp ( )

◆ CountBytes()

void FObjectReplicator::CountBytes ( FArchive Ar) const

◆ ExecutePendingTransactionalRPCs()

void FObjectReplicator::ExecutePendingTransactionalRPCs ( )

Execute any pending RPCs meant to be done within an AutoRTFM transaction.

See also
UNetDriver::PostTickDispatch

◆ ForceRefreshUnreliableProperties()

void FObjectReplicator::ForceRefreshUnreliableProperties ( )

◆ GetObject()

UObject * FObjectReplicator::GetObject ( ) const
inline

◆ GetWeakObjectPtr()

TWeakObjectPtr< UObject > FObjectReplicator::GetWeakObjectPtr ( ) const
inline

◆ InitRecentProperties()

void FObjectReplicator::InitRecentProperties ( uint8 Source)

Recent/dirty related functions

Utility function to make a copy of the net properties

Parameters
Source- Memory to copy initial state from

◆ InitWithObject()

void FObjectReplicator::InitWithObject ( UObject InObject,
UNetConnection InConnection,
bool  bUseDefaultState = true 
)

◆ IsDirtyForReplay()

bool FObjectReplicator::IsDirtyForReplay ( ) const
inline

◆ MoveMappedObjectToUnmapped()

bool FObjectReplicator::MoveMappedObjectToUnmapped ( const FNetworkGUID GUID)

◆ PostNetReceive()

void FObjectReplicator::PostNetReceive ( )
inline

◆ PostReceivedBunch()

void FObjectReplicator::PostReceivedBunch ( )

◆ PostSendBunch()

void FObjectReplicator::PostSendBunch ( FPacketIdRange PacketRange,
uint8  bReliable 
)

◆ PreNetReceive()

void FObjectReplicator::PreNetReceive ( )
inline

◆ QueuePropertyRepNotify()

void FObjectReplicator::QueuePropertyRepNotify ( UObject Object,
FProperty Property,
const int32  ElementIndex,
TArray< uint8 > &  MetaData 
)

◆ QueueRemoteFunctionBunch()

void FObjectReplicator::QueueRemoteFunctionBunch ( UFunction Func,
FOutBunch Bunch 
)

◆ ReadyForDormancy()

bool FObjectReplicator::ReadyForDormancy ( bool  bDebug = false)

◆ ReceivedBunch()

bool FObjectReplicator::ReceivedBunch ( FNetBitReader Bunch,
const FReplicationFlags RepFlags,
const bool  bHasRepLayout,
bool bOutHasUnmapped 
)

◆ ReceivedNak()

void FObjectReplicator::ReceivedNak ( int32  NakPacketId)

Packet was dropped

Handling NAKs / Property Retransmission.

Note, NACK handling only occurs on connections that "replicate" data, which is currently only Servers. RPC retransmission is handled elsewhere.

RepLayouts:

As we send properties through FRepLayout the is a Changelist Manager that is shared
between all connections tracks sets of properties that were recently changed (history items),
as well as one aggregate set of all properties that have ever been sent.

Each Sending Rep State, which is connection unique, also tracks the set of changed
properties. These history items will only be created when replicating the object,
so there will be fewer of them in general, but they will still contain any properties
that compared differently (not *just* the properties that were actually replicated).

Whenever a NAK is received, we will iterate over the SendingRepState changelist
and mark any of the properties sent in the NAKed packet for retransmission.

The next time Properties are replicated for the Object, we will merge in any changelists
from NAKed history items.

Custom Delta Properties:

For Custom Delta Properties (CDP), we rely primarily on FPropertyRetirements and INetDeltaBaseState
for tracking property retransmission.

INetDeltaBaseStates are used to tracked internal state specific to a given type of CDP.
For example, Fast Array Replicators will use FNetFastTArrayBaseState, or some type
derived from that.

When an FObjectReplicator is created, we will create an INetDeltaBaseState for every CDP,
as well as a dummy FPropertyRetirement. This Property Retirement is used as the head
of a linked list of Retirements, and is generally never populated with any useful information.

Every time we replicate a CDP, we will pass in the most recent Base State, and we will be
returned a new CDP. If data is actually sent, then we will create a new Property Retirement,
adding it as the tail of our linked list. The new Property Retirement will also hold a reference
to the old INetDeltaBaseState (i.e., the state of the CDP before it replicated its properties).

Just before replicating, we will go through and free any ACKed FPropertyRetirments (see
UpdateAckedRetirements).

After replicating, we will cache off the returned Base State to be used as the "old" state
the next time the property is replicated.

Whenever a NAK is received, we will run through our Property Retirements. Any retirements
that predate the NACK will be removed and treated as if they were ACKs. The first
retirement that is found to be within the NAKed range will have its INetDeltaBaseState
restored (which should be the state before the NAKed packet was sent), and then
that retirement as well as all remaining will be removed.

The onus is then on the CDP to resend any necessary properties based on its current / live
state and the restored Net Delta Base State.

Fast Array Properties:

Fast Array Properties are implemented as Custom Delta Properties (CDP). Therefore, they mostly
follow the flow laid out above.

FNetFastTArrayBaseState is the basis for all Fast Array Serializer INetDeltaBaseStates.
This struct tracks the Replication Key of the Array, the ID to Replication Key map of individual
Array Items, and a History Number.

As we replicate Fast Array Properties, we use the Array Replication key to see if anything
is possibly dirty in the Array and the ID to Replication map to see which Array Element
items actually are dirty. A mismatch between the Net Base State Key and the Key stored on
the live Fast Array (either the Array Replication Key, or any Item Key) is how we determine
if the Array or Items is dirty.

Whenever a NAK is received, our Old Base State will be reset to the last known ACKed value,
as described in the CDP section above. This means that our Array Replication Key and ID To
Item Replication Key should be reset to those states, forcing a mismatch the next time we
replicate if anything has changed.

When net.SupportFastArrayDelta is enabled, we perform an additional step in which we actually
compare the properties of dirty items. This is very similar to normal Property replication
using RepLayouts, and leverages most of the same code.

This includes tracking history items just like Rep Layout. Instead of tracking histories per
Sending Rep State / Per Connection, we just manage a single set of Histories on the Rep
Changelist Mgr. Changelists are stored per Fast Array Item, and are referenced via ID.

Whenever we go to replicate a Fast Array Item, we will merge together all changelists since
we last sent that item, and send those accumulated changes.

This means that property retransmission for Fast Array Items is an amalgamation of Rep Layout
retransmission and CDP retransmission.

Whenever a NAK is received, our History Number should be reset to the last known  ACKed value,
and that should be enough to force us to accumulate any of the NAKed item changelists.

◆ ReceivedRPC() [1/2]

bool FObjectReplicator::ReceivedRPC ( FNetBitReader Reader,
const FReplicationFlags RepFlags,
const FFieldNetCache FieldCache,
const bool  bCanDelayRPC,
bool bOutDelayRPC,
TSet< FNetworkGUID > &  OutUnmappedGuids 
)
inline

◆ ReceivedRPC() [2/2]

bool FObjectReplicator::ReceivedRPC ( FNetBitReader Reader,
TSet< FNetworkGUID > &  OutUnmappedGuids,
bool bOutSkippedRpcExec,
const FReplicationFlags RepFlags,
const FFieldNetCache FieldCache,
ESkipRpcBehavior  SkipRpcBehavior 
)
Parameters
Readerthe buffer that contains the RPC (this function reads RPC parameters from the current position)
OutUnmappedGuidsany GUIDs that are not yet resolvable because we do not have the data (yet)
bOutSkippedRpcExecdid we skip execution of this RPC? If so, the caller must handle execution (e.g. delay).
RepFlagsthe replication flags (state) of the replicated object
FieldCachethe RPC FieldCache used to speed-up property lookups. This cannot be null.
SkipRpcBehaviorunder what circumstances should we skip the execution of the RPC?
Returns
True if the Reader is still valid. False if the Reader should be abandoned.
See also
ReceivedBunch(), UpdateUnmappedObjects()

◆ ReleaseStrongReference()

void FObjectReplicator::ReleaseStrongReference ( )
inline

◆ ReplicateCustomDeltaProperties()

void FObjectReplicator::ReplicateCustomDeltaProperties ( FNetBitWriter Bunch,
FReplicationFlags  RepFlags,
bool bSkippedPropertyCondition 
)

◆ ReplicateProperties() [1/2]

bool FObjectReplicator::ReplicateProperties ( FOutBunch Bunch,
FReplicationFlags  RepFlags 
)

◆ ReplicateProperties() [2/2]

bool FObjectReplicator::ReplicateProperties ( FOutBunch Bunch,
FReplicationFlags  RepFlags,
FNetBitWriter Writer 
)

◆ ReplicateProperties_r()

bool FObjectReplicator::ReplicateProperties_r ( FOutBunch Bunch,
FReplicationFlags  RepFlags,
FNetBitWriter Writer 
)

Replicates properties to the Bunch. Returns true if it wrote anything

◆ ResetReplayDirtyTracking()

void FObjectReplicator::ResetReplayDirtyTracking ( )
inline

◆ SendCustomDeltaProperty()

bool FObjectReplicator::SendCustomDeltaProperty ( UObject InObject,
uint16  CustomDeltaProperty,
FNetBitWriter OutBunch,
TSharedPtr< INetDeltaBaseState > &  NewFullState,
TSharedPtr< INetDeltaBaseState > &  OldState 
)

◆ SetObject()

void FObjectReplicator::SetObject ( UObject NewObj)
inline

◆ StartBecomingDormant()

void FObjectReplicator::StartBecomingDormant ( )

◆ StartReplicating()

void FObjectReplicator::StartReplicating ( class UActorChannel InActorChannel)

◆ StopReplicating()

void FObjectReplicator::StopReplicating ( class UActorChannel InActorChannel)

◆ UpdateGuidToReplicatorMap()

void FObjectReplicator::UpdateGuidToReplicatorMap ( )

◆ UpdateUnmappedObjects()

void FObjectReplicator::UpdateUnmappedObjects ( bool bOutHasMoreUnmapped)

◆ ValidateAgainstState()

bool FObjectReplicator::ValidateAgainstState ( const UObject ObjectState)

Takes Data, and compares against shadow state to log differences

◆ WritePropertyHeaderAndPayload()

void FObjectReplicator::WritePropertyHeaderAndPayload ( UObject Object,
FProperty Property,
FNetFieldExportGroup NetFieldExportGroup,
FNetBitWriter Bunch,
FNetBitWriter Payload 
) const

Member Data Documentation

◆ bForceUpdateUnmapped

uint32 FObjectReplicator::bForceUpdateUnmapped

True if we need to do an unmapped check next frame.

◆ bHasReplicatedProperties

uint32 FObjectReplicator::bHasReplicatedProperties

Whether or not we've already replicated properties this frame.

◆ bLastUpdateEmpty

uint32 FObjectReplicator::bLastUpdateEmpty

True if last update (ReplicateActor) produced no replicated properties

◆ bOpenAckCalled

uint32 FObjectReplicator::bOpenAckCalled

Whether or not the Actor Channel on which we're replicating has been Opened / Acked by the receiver.

◆ bSentSubObjectCreation

uint32 FObjectReplicator::bSentSubObjectCreation

Is this a subobject replicator and have we sent the creation data yet.

◆ ChangelistMgr

TSharedPtr<class FReplicationChangelistMgr> FObjectReplicator::ChangelistMgr

◆ CheckpointRepState

TUniquePtr<FRepState> FObjectReplicator::CheckpointRepState

◆ Connection

UNetConnection* FObjectReplicator::Connection

Connection this replicator was created on.

◆ ObjectClass

TObjectPtr<UClass> FObjectReplicator::ObjectClass

◆ ObjectNetGUID

FNetworkGUID FObjectReplicator::ObjectNetGUID

Net GUID for the object we're replicating.

◆ ObjectPtr

UObject* FObjectReplicator::ObjectPtr

◆ OwningChannel

class UActorChannel* FObjectReplicator::OwningChannel

The Actor Channel that we're replicating on. This expected to be owned by Connection.

◆ PendingLocalRPCs

TArray<FRPCPendingLocalCall> FObjectReplicator::PendingLocalRPCs

Information on RPCs that have been received but not yet executed

◆ ReferencedGuids

TSet<FNetworkGUID> FObjectReplicator::ReferencedGuids

◆ RemoteFuncInfo

TArray<FRPCCallInfo> FObjectReplicator::RemoteFuncInfo

Meta information on pending net RPCs (to be sent)

◆ RemoteFunctions

FOutBunch* FObjectReplicator::RemoteFunctions

◆ RepLayout

TSharedPtr<FRepLayout> FObjectReplicator::RepLayout

◆ RepState

TUniquePtr<FRepState> FObjectReplicator::RepState

◆ TrackedGuidMemoryBytes

int32 FObjectReplicator::TrackedGuidMemoryBytes

The amount of memory (in bytes) that we're using to track Unmapped GUIDs.


The documentation for this class was generated from the following files: