protected override void Load() { base.Load(); if (_idxFile != null) { int count = (int)_idxFile.Length / 12; Entries = new UOFileIndex3D[count]; for (int i = 0; i < count; i++) { Entries[i] = new UOFileIndex3D(_idxFile.ReadInt(), _idxFile.ReadInt(), _idxFile.ReadInt()); } var patches = Verdata.Patches; for (int i = 0; i < patches.Length; i++) { var patch = patches[i]; if (patch.File == _patch && patch.Index >= 0 && patch.Index < Entries.Length) { UOFileIndex3D entry = Entries[patch.Index]; entry.Offset = patch.Offset; entry.Length = patch.Length | (1 << 31); entry.Extra = patch.Extra; } } } }
protected override void Load() { base.Load(); Seek(0); if (ReadUInt() != UOP_MAGIC_NUMBER) { throw new ArgumentException("Bad uop file"); } int version = ReadInt(); Skip(4); //Skip(8); long nextBlock = ReadLong(); Skip(4); int count = ReadInt(); if (_count <= 0) { _count = count; } Entries = new UOFileIndex3D[_count]; Dictionary <ulong, int> hashes = new Dictionary <ulong, int>(); string pattern = System.IO.Path.GetFileNameWithoutExtension(FileName).ToLowerInvariant(); for (int i = 0; i < _count; i++) { string file = string.Format("build/{0}/{1:D8}{2}", pattern, i, _extension); ulong hash = CreateHash(file); if (!hashes.ContainsKey(hash)) { hashes.Add(hash, i); } } Seek(nextBlock); int total = 0; do { int filesCount = ReadInt(); nextBlock = ReadLong(); total += filesCount; for (int i = 0; i < filesCount; i++) { long offset = ReadLong(); int headerLength = ReadInt(); int compressedLength = ReadInt(); int decompressedLength = ReadInt(); ulong hash = ReadULong(); Skip(4); short flag = ReadShort(); int length = flag == 1 ? compressedLength : decompressedLength; if (offset == 0) { continue; } if (hashes.TryGetValue(hash, out int idx)) { if (idx < 0 || idx > Entries.Length) { throw new IndexOutOfRangeException("hashes dictionary and files collection have different count of entries!"); } Entries[idx] = new UOFileIndex3D(offset + headerLength, length, 0, decompressedLength); // extra? if (_hasExtra) { long curpos = Position; Seek(offset + headerLength); byte[] extra = ReadArray(8); ushort extra1 = (ushort)((extra[3] << 24) | (extra[2] << 16) | (extra[1] << 8) | extra[0]); ushort extra2 = (ushort)((extra[7] << 24) | (extra[6] << 16) | (extra[5] << 8) | extra[4]); Entries[idx].Offset += 8; Entries[idx].Extra = extra1 << 16 | extra2; Entries[idx].Length -= 8; Seek(curpos); } } else { throw new ArgumentException(string.Format("File with hash 0x{0:X8} was not found in hashes dictionary! EA Mythic changed UOP format!", hash)); } } Seek(nextBlock); } while (nextBlock != 0); }