Example #1
0
        public override Task Load()
        {
            return(Task.Run(() =>
            {
                string path = Path.Combine(FileManager.UoFolderPath, "multi.mul");
                string pathidx = Path.Combine(FileManager.UoFolderPath, "multi.idx");

                if (File.Exists(path) && File.Exists(pathidx))
                {
                    _file = new UOFileMul(path, pathidx, Constants.MAX_MULTI_DATA_INDEX_COUNT, 14);
                }
                else
                {
                    throw new FileNotFoundException();
                }

                Count = _itemOffset = FileManager.ClientVersion >= ClientVersions.CV_7090 ? UnsafeMemoryManager.SizeOf <MultiBlockNew>() : UnsafeMemoryManager.SizeOf <MultiBlock>();


                string uopPath = Path.Combine(FileManager.UoFolderPath, "MultiCollection.uop");

                if (File.Exists(uopPath))
                {
                    Count = Constants.MAX_MULTI_DATA_INDEX_COUNT;
                    _fileUop = new UOFileUopNoFormat(uopPath);
                    _reader = new DataReader();

                    for (int i = 0; i < _fileUop.Entries.Length; i++)
                    {
                        long offset = _fileUop.Entries[i].Offset;
                        int csize = _fileUop.Entries[i].Length;
                        int dsize = _fileUop.Entries[i].DecompressedLength;

                        _fileUop.Seek(offset);
                        byte[] cdata = _fileUop.ReadArray <byte>(csize);
                        byte[] ddata = new byte[dsize];

                        ZLib.Decompress(cdata, 0, ddata, dsize);
                        _reader.SetData(ddata, dsize);

                        uint id = _reader.ReadUInt();

                        if (id < Constants.MAX_MULTI_DATA_INDEX_COUNT && id < _file.Entries.Length)
                        {
                            ref UOFileIndex3D index = ref _file.Entries[id];
                            int count = _reader.ReadInt();

                            index = new UOFileIndex3D(offset, csize, dsize, (int)MathHelper.Combine(count, index.Extra));
                        }
                    }

                    _reader.ReleaseData();
                }
            }));