private void Read(BinaryReader br, Archive parent) { FileTableOffset = br.ReadUInt32(); FileTableSize = br.ReadUInt32(); Crc = br.ReadUInt64(); FileEntryCount = br.ReadUInt32(); FileSegmentCount = br.ReadUInt32(); ResourceDependencyCount = br.ReadUInt32(); // read tables for (int i = 0; i < FileEntryCount; i++) { var entry = new FileEntry(br, parent); if (!FileEntries.ContainsKey(entry.NameHash64)) { FileEntries.Add(entry.NameHash64, entry); } else { // TODO } } for (int i = 0; i < FileSegmentCount; i++) { FileSegments.Add(new FileSegment(br, i)); } for (int i = 0; i < ResourceDependencyCount; i++) { Dependencies.Add(new Dependency(br, i)); } }
public bool ReadHeader(BinaryReader br) { if (!br.CheckHeaderString("MP00", reversed: true)) { return(false); } EntryCount = br.ReadInt32(); for (var i = 0; i < EntryCount; ++i) { var entry = new FileEntry(br); FileEntries.Add(entry.Crc, entry); var crc = entry.Crc; var crc2 = entry.Crc2; var block = StreamingManager.GetStreamBlockByCRC(crc, out string source); if (block != null) { Console.WriteLine($"Adding entry: 0x{entry.Crc:X8} => {block.FileName,-45} through {source}"); } block = StreamingManager.GetStreamBlockByCRC(crc2, out string source2); if (block != null) { Console.WriteLine($"Adding entry: 0x{crc:X8} => 0x{crc2:X8} => {block.FileName,-45} through {source2}"); } else { Console.WriteLine($"Adding unknown entry: 0x{crc:X8} => 0x{crc2:X8}"); } } Array3D8 = new int[2 * EntryCount]; for (var i = 0; i < EntryCount; ++i) { Array3D8[2 * i] = br.ReadInt32(); Array3D8[2 * i + 1] = br.ReadInt32(); var entryCrc = Array3D8[2 * i]; var crc2 = Array3D8[2 * i + 1]; if (!FileEntries.ContainsKey(entryCrc)) { Console.WriteLine($"ERROR: 0x{entryCrc:X8} => 0x{crc2:X8} is not a valid fileentry!"); continue; } var entry = FileEntries[entryCrc]; if (entry.Crc == entryCrc && entry.Crc2 == crc2) { continue; } string source; var block = StreamingManager.GetStreamBlockByCRC(entryCrc, out source); if (block != null) { Console.WriteLine($"Map entry: 0x{entryCrc:X8} => {block.FileName,-45} through {source}"); } block = StreamingManager.GetStreamBlockByCRC(crc2, out source); if (block != null) { Console.WriteLine($"Map entry: 0x{entryCrc:X8} 0x{crc2:X8} => {block.FileName,-45} through {source}"); } else { Console.WriteLine($"Map unknown entry: 0x{entryCrc:X8} => 0x{crc2:X8}"); } } return(true); }
/// <summary> /// Parses a single index file on the specified path. Checking for accompanying dat file and populating file index. /// </summary> /// <param name="packFile">The full path of the index file to parse.</param> private void _LoadIndexFile(PackFile packFile) { // loop through index files foreach (PackFileEntry currFileEntry in packFile.Files) { //if (currFileEntry.Name.Contains("bldg_c_station_warp_next_layout.xml.cooked") || currFileEntry.Name.Contains("sku.")) //{ // int bp = 0; //} ulong pathHash = currFileEntry.PathHash; // have we added the file yet if (!FileEntries.ContainsKey(pathHash)) { FileEntries.Add(pathHash, currFileEntry); continue; } // we haven't added the file, so we need to compare file times and backup states PackFileEntry origFileEntry = FileEntries[pathHash]; // do backup checks first as they'll "override" the FileTime values (i.e. file not found causes game to go to older version) // if currFile IS a backup, and orig is NOT, then add to Siblings as game will be loading orig over "backup" anyways if (currFileEntry.IsPatchedOut && !origFileEntry.IsPatchedOut) { if (origFileEntry.Siblings == null) { origFileEntry.Siblings = new List <PackFileEntry>(); } origFileEntry.Siblings.Add(currFileEntry); continue; } // if curr is NOT a backup, but orig IS, then we want to update (i.e. don't care about FileTime; as above) // OR if orig is older than curr, we also want to update/re-arrange Siblings, etc if ((!currFileEntry.IsPatchedOut && origFileEntry.IsPatchedOut) || origFileEntry.FileTime < currFileEntry.FileTime) { // set the Siblings list to the updated FileEntry and null out other if (origFileEntry.Siblings != null) { currFileEntry.Siblings = origFileEntry.Siblings; origFileEntry.Siblings = null; } // add the "orig" (now old) to the curr FileEntry.Siblings list if (currFileEntry.Siblings == null) { currFileEntry.Siblings = new List <PackFileEntry>(); } currFileEntry.Siblings.Add(origFileEntry); FileEntries[pathHash] = currFileEntry; continue; } // if curr is older (or equal to; hellgate000 has duplicates) than the orig, then add this to the Siblings list (i.e. orig is newer) if (origFileEntry.FileTime >= currFileEntry.FileTime) { if (origFileEntry.Siblings == null) { origFileEntry.Siblings = new List <PackFileEntry>(); } origFileEntry.Siblings.Add(currFileEntry); continue; } Debug.Assert(false, "End of 'if (FileEntries.ContainsKey(hash))'", "wtf??\n\nThis shouldn't happen, please report this."); } }