public FEngineVersion(Stream stream) : base(stream)
 {
     this.Branch = new FString(stream);
 }
Пример #2
0
        private FPackageFileSummary(Stream stream)
        {
            if (stream.Length < 32)
            {
                Console.WriteLine("Failed to read Package File Summary - File too small");
                return;
            }

            using (BinaryReader br = new BinaryReader(stream, Encoding.UTF8, true))
            {
                this._tag = br.ReadUInt32();
                if (this._tag != PACKAGE_FILE_TAG)
                {
                    throw new InvalidDataException("The file contains unrecognizable data, check that it is of the expected type.");
                }

                this._legacyFileVersion = br.ReadInt32();
                if (this._legacyFileVersion < 0)
                {
                    if (this._legacyFileVersion < CURRENT_LEGACY_FILE_VERSION)
                    {
                        this._fileVersionUE4         = 0;
                        this._fileVersionLicenseeUE4 = 0;
                        return;
                    }

                    if (this._legacyFileVersion != -4)
                    {
                        this._legacyUE3Version = br.ReadInt32();
                    }

                    this._fileVersionUE4         = br.ReadInt32();
                    this._fileVersionLicenseeUE4 = br.ReadInt32();

                    if (this._legacyFileVersion <= -2)
                    {
                        this.CustomVersion = new FCustomVersionContainer(stream);
                    }

                    if (this._fileVersionUE4 == 0 && this._fileVersionLicenseeUE4 == 0)
                    {
                        this.IsUnversioned   = true;
                        this._fileVersionUE4 = 516;
                        CustomVersion        = new FCustomVersionContainer();
                    }
                }
                else
                {
                    this._fileVersionUE4         = 0;
                    this._fileVersionLicenseeUE4 = 0;
                }

                this.TotalSize    = br.ReadInt32();
                this.FolderName   = new FString(stream);
                this.PackageFlags = (EPackageFlags)br.ReadInt32();

                if (this.PackageFlags.HasFlag(EPackageFlags.PKG_FilterEditorOnly))
                {
                    this._isFilterEditorOnly = true;
                }

                this.NameCount  = br.ReadInt32();
                this.NameOffset = br.ReadInt32();

                if (this._fileVersionUE4 >= 459)
                {
                    this.GathereableTextDataCount = br.ReadInt32();
                    this.GatherableTextDataOffset = br.ReadInt32();
                }

                this.ExportCount  = br.ReadInt32();
                this.ExportOffset = br.ReadInt32();

                this.ImportCount  = br.ReadInt32();
                this.ImportOffset = br.ReadInt32();

                this.DependsOffset = br.ReadInt32();

                if (this._fileVersionUE4 < 214 || this._fileVersionUE4 > 516)
                {
                    Console.WriteLine($"Unsupported Package Version '{this._fileVersionUE4}'. Can not read further.");
                    return;
                }

                if (this._fileVersionUE4 >= 384)
                {
                    this.SoftPackageReferencesCount  = br.ReadInt32();
                    this.SoftPackageReferencesOffset = br.ReadInt32();
                }

                if (this._fileVersionUE4 >= 510)
                {
                    this.SearchableNamesOffset = br.ReadInt32();
                }

                this.ThumbnailTableOffset = br.ReadInt32();

                this.Guid = new FGuid(stream);
                int generationCount = br.ReadInt32();
                this.Generations = new FGenerationInfo[generationCount];
                for (int i = 0; i < generationCount; i++)
                {
                    this.Generations[i] = new FGenerationInfo(stream);
                }

                if (this._fileVersionUE4 >= 336)
                {
                    this.SavedByEngineVersion = new FEngineVersion(stream);
                }
                else
                {
                    this.SavedByEngineVersion = new FEngineVersion();
                }

                if (this._fileVersionUE4 >= 444)
                {
                    this.CompatibleWithEngineVersion = new FEngineVersion(stream);
                }
                else
                {
                    this.CompatibleWithEngineVersion = this.SavedByEngineVersion;
                }

                this.CompressionFlags = (ECompressionFlags)br.ReadInt32();

                if (((int)this.CompressionFlags & (int)~(CompressionFlagMasks.COMPRESSION_FLAGS_TYPE_MASK | CompressionFlagMasks.COMPRESSION_FLAGS_OPTIONS_MASK)) != 0)
                {
                    Console.WriteLine("Invalid Compression Flags");
                    return;
                }

                int compressedChunkCount = br.ReadInt32();
                if (compressedChunkCount > 0)
                {
                    // This file has package level compression, we won't load it.
                    Console.WriteLine("Failed to read package file summary, the file has package level compression (and is probably cooked). These old files cannot be loaded.");
                    this._fileVersionUE4 = 213;
                    return; // We can't safely load more than this because we just changed the version to something it is not.
                }

                this.PackageSource = br.ReadInt32();

                int       numAddPackages           = br.ReadInt32();
                FString[] AdditionalPackagesToCook = new FString[numAddPackages];
                for (int i = 0; i < numAddPackages; i++)
                {
                    AdditionalPackagesToCook[i] = new FString(stream);
                }

                if (this._legacyFileVersion > -7)
                {
                    // Read unused texture allocation info
                    br.ReadInt32();
                }

                this.AssetRegistryDataOffset = br.ReadInt32();
                this.BulkDataStartOffset     = br.ReadInt64();

                if (this._fileVersionUE4 >= 224)
                {
                    this.WorldTileInfoDataOffset = br.ReadInt32();
                }

                if (this._fileVersionUE4 >= 326)
                {
                    int numChunks = br.ReadInt32();
                    this.ChunkIds = new List <int>();
                    for (int i = 0; i < numChunks; i++)
                    {
                        this.ChunkIds.Add(br.ReadInt32());
                    }
                }
                else if (this._fileVersionUE4 >= 278)
                {
                    this.ChunkIds = new List <int>()
                    {
                        br.ReadInt32()
                    };
                }

                this.PreloadDependencyCount  = -1;
                this.PreloadDependencyOffset = 0;
            }
        }