/** * Places a new duplicate in the DuplicatedObjects map as well as the UnserializedObjects list * * @param SourceObject the original version of the object * @param DuplicateObject the copy of the object * * @return a pointer to the copy of the object */ UObject* FDuplicateDataWriter::AddDuplicate(UObject* SourceObject,UObject* DupObject) { if ( DupObject && !DupObject->IsTemplate() ) { // Make sure the duplicated object is prepared to postload DupObject->SetFlags(RF_NeedPostLoad|RF_NeedPostLoadSubobjects); } // Check for an existing duplicate of the object; if found, use that one instead of creating a new one. FDuplicatedObject Info = DuplicatedObjectAnnotation.GetAnnotation( SourceObject ); if ( Info.IsDefault() ) { DuplicatedObjectAnnotation.AddAnnotation( SourceObject, FDuplicatedObject( DupObject ) ); } else { Info.DuplicatedObject = DupObject; } UnserializedObjects.Add(SourceObject); return DupObject; }
FArchive& FDuplicateDataReader::operator<<( UObject*& Object ) { UObject* SourceObject = Object; Serialize(&SourceObject,sizeof(UObject*)); FDuplicatedObject ObjectInfo = SourceObject ? DuplicatedObjectAnnotation.GetAnnotation(SourceObject) : FDuplicatedObject(); if( !ObjectInfo.IsDefault() ) { Object = ObjectInfo.DuplicatedObject; } else { Object = SourceObject; } return *this; }