protected override void Load(bool loadentries = true) { base.Load(loadentries); if (loadentries && _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(), 0, _idxFile.ReadInt()); } UOFileIndex5D[] patches = Verdata.Patches; for (int i = 0; i < patches.Length; i++) { UOFileIndex5D patch = patches[i]; if (patch.File == _patch && patch.Index >= 0 && patch.Index < Entries.Length) { ref UOFileIndex3D entry = ref Entries[patch.Index]; entry.Offset = patch.Offset; entry.Length = patch.Length | (1 << 31); entry.Extra = patch.Extra; } } }
internal (int, int, bool) SeekByEntryIndex(int entryidx) { if (entryidx < 0 || entryidx >= Entries.Length) { return(0, 0, false); } UOFileIndex3D e = Entries[entryidx]; if (e.Offset < 0) { return(0, 0, false); } int length = e.Length & 0x7FFFFFFF; int extra = e.Extra; if ((e.Length & (1 << 31)) != 0) { Verdata.File.Seek(e.Offset); return(length, extra, true); } if (e.Length < 0) { return(0, 0, false); } Seek(e.Offset); return(length, extra, false); }
protected override void Load(bool loadentries = true) { base.Load(loadentries); if (loadentries && _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(), 0, _idxFile.ReadInt()); } UOFileIndex5D[] patches = Verdata.Patches; for (int i = 0; i < patches.Length; i++) { UOFileIndex5D patch = patches[i]; if (patch.FileID == _patch && patch.BlockID >= 0 && patch.BlockID < Entries.Length) { ref UOFileIndex3D entry = ref Entries[patch.BlockID]; entry = new UOFileIndex3D(patch.Position, patch.Length | (1 << 31), 0, patch.GumpData); } } }
protected override void Load(bool loadentries = true) { base.Load(loadentries); Seek(0); if (ReadInt() != UOP_MAGIC_NUMBER) { throw new ArgumentException("Bad uop file"); } Skip(8); long nextblock = ReadLong(); Skip(4); Entries = new UOFileIndex3D[ReadInt()]; int idx = 0; do { Seek(nextblock); int fileCount = ReadInt(); nextblock = ReadLong(); for (int i = 0; i < fileCount; i++) { long offset = ReadLong(); int headerLength = ReadInt(); int compressedLength = ReadInt(); int decompressedLength = ReadInt(); ulong hash = ReadULong(); Skip(6); if (offset == 0) { continue; } Entries[idx++] = new UOFileIndex3D((uint)(offset + headerLength), compressedLength, decompressedLength); } } while (nextblock != 0); }
protected override void Load(bool loadentries = true) { base.Load(loadentries); Seek(0); if (ReadUInt() != UOP_MAGIC_NUMBER) { throw new ArgumentException("Bad uop file"); } int version = ReadInt(); Skip(4); 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(Path).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, decompressedLength); // extra? if (_hasExtra) { long curpos = Position; Seek(offset + headerLength); int extra1 = ReadInt(); int extra2 = ReadInt(); 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 {0:X8} was not found in hashes dictionary! EA Mythic changed UOP format!", hash)); } } Seek(nextBlock); } while (nextBlock != 0); }