void FObjectReplicator::StartReplicating( class UActorChannel * InActorChannel ) { check( OwningChannel == NULL ); OwningChannel = InActorChannel; // Cache off netGUID so if this object gets deleted we can close it ObjectNetGUID = OwningChannel->Connection->PackageMap->GetObjectNetGUID( GetObject() ); if ( !ObjectNetGUID.IsValid() ) { ObjectNetGUID = OwningChannel->Connection->PackageMap->AssignNewNetGUID( GetObject() ); check( !ObjectNetGUID.IsDefault() && ObjectNetGUID.IsValid() ); } TempBitWriter = new FNetBitWriter( OwningChannel->Connection->PackageMap, 0 ); // Allocate retirement list. // SetNum now constructs, so this is safe Retirement.SetNum( ObjectClass->ClassReps.Num() ); // figure out list of replicated object properties for ( UProperty* Prop = ObjectClass->PropertyLink; Prop != NULL; Prop = Prop->PropertyLinkNext ) { if ( Prop->PropertyFlags & CPF_Net ) { if ( IsCustomDeltaProperty( Prop ) ) { for ( int32 i = 0; i < Prop->ArrayDim; i++ ) { Retirement[Prop->RepIndex + i].CustomDelta = 1; } } if ( Prop->GetPropertyFlags() & CPF_Config ) { for ( int32 i = 0; i < Prop->ArrayDim; i++ ) { Retirement[Prop->RepIndex + i].Config = 1; } } } } }
void FObjectReplicator::StartReplicating( class UActorChannel * InActorChannel ) { check( OwningChannel == NULL ); if ( GetObject() == NULL ) { UE_LOG(LogRep, Error, TEXT("StartReplicating: Object == NULL")); return; } OwningChannel = InActorChannel; // Cache off netGUID so if this object gets deleted we can close it ObjectNetGUID = OwningChannel->Connection->Driver->GuidCache->GetOrAssignNetGUID( GetObject() ); check( !ObjectNetGUID.IsDefault() && ObjectNetGUID.IsValid() ); // Allocate retirement list. // SetNum now constructs, so this is safe Retirement.SetNum( ObjectClass->ClassReps.Num() ); // figure out list of replicated object properties for ( UProperty* Prop = ObjectClass->PropertyLink; Prop != NULL; Prop = Prop->PropertyLinkNext ) { if ( Prop->PropertyFlags & CPF_Net ) { if ( IsCustomDeltaProperty( Prop ) ) { for ( int32 i = 0; i < Prop->ArrayDim; i++ ) { Retirement[Prop->RepIndex + i].CustomDelta = 1; } } if ( Prop->GetPropertyFlags() & CPF_Config ) { for ( int32 i = 0; i < Prop->ArrayDim; i++ ) { Retirement[Prop->RepIndex + i].Config = 1; } } } } }
/** * Utility function to make a copy of the net properties * @param Source - Memory to copy initial state from **/ void FObjectReplicator::InitRecentProperties( uint8 * Source ) { check( GetObject() != NULL ); check( Connection != NULL ); check( RepState == NULL ); UClass * InObjectClass = GetObject()->GetClass(); RepState = new FRepState; // Initialize the RepState memory TSharedPtr<FRepChangedPropertyTracker> RepChangedPropertyTracker = Connection->Driver->FindOrCreateRepChangedPropertyTracker( GetObject() ); RepLayout->InitRepState( RepState, InObjectClass, Source, RepChangedPropertyTracker ); RepState->RepLayout = RepLayout; // Init custom delta property state for ( TFieldIterator<UProperty> It( InObjectClass ); It; ++It ) { if ( It->PropertyFlags & CPF_Net ) { if ( IsCustomDeltaProperty( *It ) ) { // We have to handle dynamic properties of the array individually for ( int32 ArrayIdx = 0; ArrayIdx < It->ArrayDim; ++ArrayIdx ) { FOutBunch DeltaState( Connection->PackageMap ); TSharedPtr<INetDeltaBaseState> & NewState = RecentCustomDeltaState.FindOrAdd(It->RepIndex + ArrayIdx); NewState.Reset(); TSharedPtr<INetDeltaBaseState> OldState; SerializeCustomDeltaProperty( Connection, Source, *It, ArrayIdx, DeltaState, NewState, OldState ); } } } } }