Example #1
0
        public void Purge(bool RemoveHash = false, bool ReplaceHash = false)
        {
            // 쓸모없는 블럭 전체 삭제 (블럭 청소 완료)
            BlockTable.RemoveAll(item => (item.Flags & MPQ_FILE_EXISTS) == 0);
            BlockTable.ForEach(item => item.Flags = (item.Flags / 0x100) * 0x100);
            // 해시들 전부 맞춰줌 (FFFFFFFF같은건 남아있음)
            Files.ForEach(File => File.Hash.BlockIndex = (uint)BlockTable.FindIndex(Block => Block == File.Block));

            if (RemoveHash)
            {
                // 블럭 없는 해시 전부 삭제
                List <uint> ExistIndexes = new List <uint>();

                int BlockTableCount = BlockTable.Count;
                for (int i = HashTable.Count - 1; i >= 0; i--)
                {
                    MPQHash Hash = HashTable[i];
                    foreach (var item in ExistIndexes)
                    {
                        if (item == Hash.BlockIndex)
                        {
                            goto RemoveHash;
                        }
                    }

                    ExistIndexes.Add(Hash.BlockIndex);

                    if ((Hash.Name1 == 0xFFFFFFFF &&
                         Hash.Name2 == 0xFFFFFFFF) ||
                        !Hash.BlockIndex.IsSafeIndex(out uint SafeIndex))
                    {
                        goto RemoveHash;
                    }
                    else
                    {
                        Hash.BlockIndex = SafeIndex;
                        if (Hash.BlockIndex >= BlockTableCount)
                        {
                            goto RemoveHash;
                        }
                    }

                    Hash.Locale   = 0;
                    Hash.Platform = 0;
                    continue;

                    RemoveHash : HashTable.Remove(Hash);
                }
            }

            if (ReplaceHash)
            {
                // 해시 위치 재정렬
            }
        }
Example #2
0
 public void Remove(MPQHash Hash) => Files.Remove(Hash);
Example #3
0
 public MPQFile Find(MPQHash Hash) => Files.Find(Hash);