void UWorldComposition::OnLevelPostLoad(ULevel* InLevel) { UPackage* LevelPackage = Cast<UPackage>(InLevel->GetOutermost()); if (LevelPackage && InLevel->OwningWorld) { FWorldTileInfo Info; UWorld* World = InLevel->OwningWorld; if (World->WorldComposition) { // Assign WorldLevelInfo previously loaded by world composition FWorldCompositionTile* Tile = World->WorldComposition->FindTileByName(LevelPackage->GetFName()); if (Tile) { Info = Tile->Info; } } else { #if WITH_EDITOR // Preserve FWorldTileInfo in case sub-level was loaded in the editor outside of world composition FString PackageFilename = FPackageName::LongPackageNameToFilename(LevelPackage->GetName(), FPackageName::GetMapPackageExtension()); FWorldTileInfo::Read(PackageFilename, Info); #endif //WITH_EDITOR } const bool bIsDefault = (Info == FWorldTileInfo()); if (!bIsDefault) { LevelPackage->WorldTileInfo = new FWorldTileInfo(Info); } } }
FWorldTileInfo UWorldComposition::GetTileInfo(const FName& InPackageName) const { FWorldCompositionTile* Tile = FindTileByName(InPackageName); if (Tile) { return Tile->Info; } return FWorldTileInfo(); }
bool FWorldTileInfo::Read(const FString& InPackageFileName, FWorldTileInfo& OutInfo) { // Fill with default information OutInfo = FWorldTileInfo(); // Create a file reader to load the file TScopedPointer<FArchive> FileReader(IFileManager::Get().CreateFileReader(*InPackageFileName)); if (FileReader == NULL) { // Couldn't open the file return false; } // Read package file summary from the file FPackageFileSummary FileSummary; (*FileReader) << FileSummary; // Make sure this is indeed a package if (FileSummary.Tag != PACKAGE_FILE_TAG) { // Unrecognized or malformed package file return false; } // Does the package contains a level info? if (FileSummary.WorldTileInfoDataOffset != 0) { if (!!(FileSummary.PackageFlags & PKG_StoreCompressed)) { check(FileSummary.CompressedChunks.Num() > 0); if (!FileReader->SetCompressionMap(&FileSummary.CompressedChunks, (ECompressionFlags)FileSummary.CompressionFlags)) { FileReader = new FArchiveAsync(*InPackageFileName); // re-assign scope pointer check(!FileReader->IsError()); verify(FileReader->SetCompressionMap(&FileSummary.CompressedChunks, (ECompressionFlags)FileSummary.CompressionFlags)); } } // Seek the the part of the file where the structure lives FileReader->Seek(FileSummary.WorldTileInfoDataOffset); //make sure the filereader gets the correct version number (it defaults to latest version) FileReader->SetUE4Ver(FileSummary.GetFileVersionUE4()); FileReader->SetEngineVer(FileSummary.EngineVersion); // Load the structure *FileReader << OutInfo; } return true; }