public static unsafe void LoadUnpackCache() { m_OutputBuffer = new byte[0x18975]; m_CacheEntries = new UnpackCacheEntry[0x10000]; fixed(UnpackCacheEntry *entryRef = m_CacheEntries) { UnpackCacheEntry *entryPtr = entryRef; fixed(byte *numRef = m_OutputBuffer) { Stack stack = new Stack(); stack.Push(m_Tree); while (stack.Count > 0) { UnpackLeaf leaf2 = (UnpackLeaf)stack.Pop(); if (leaf2.m_Left != null) { stack.Push(leaf2.m_Left); } if (leaf2.m_Right != null) { stack.Push(leaf2.m_Right); } int[] numArray = new int[0x100]; for (int i = 0; i < 0x100; i++) { byte * numPtr = numRef + m_OutputIndex; UnpackLeaf left = leaf2; int num2 = 0; int num = 8; while (--num >= 0) { switch (((i >> num) & 1)) { case 0: left = left.m_Left; break; case 1: left = left.m_Right; break; } if ((left != null) && (left.m_Value != -1)) { switch ((left.m_Value >> 8)) { case 0: numPtr[num2++] = (byte)left.m_Value; break; case 1: num = 0; break; } left = m_Tree; } } entryPtr->m_NextIndex = left.m_Index; entryPtr->m_ByteIndex = m_OutputIndex; entryPtr->m_ByteCount = num2; numArray[i] = (int)((long)((entryPtr - entryRef) / sizeof(UnpackCacheEntry))); entryPtr++; m_OutputIndex += num2; } leaf2.m_Cache = numArray; } } } }
public static unsafe void LoadUnpackCache() { Compression.m_OutputBuffer = new byte[100725]; Compression.m_CacheEntries = new UnpackCacheEntry[65536]; fixed(UnpackCacheEntry *unpackCacheEntryPtr1 = Compression.m_CacheEntries) { UnpackCacheEntry *unpackCacheEntryPtr2 = unpackCacheEntryPtr1; fixed(byte *numPtr1 = Compression.m_OutputBuffer) { Stack <UnpackLeaf> unpackLeafStack = new Stack <UnpackLeaf>(); unpackLeafStack.Push(Compression.m_Tree); while (unpackLeafStack.Count > 0) { UnpackLeaf unpackLeaf1 = unpackLeafStack.Pop(); if (unpackLeaf1.m_Left != null) { unpackLeafStack.Push(unpackLeaf1.m_Left); } if (unpackLeaf1.m_Right != null) { unpackLeafStack.Push(unpackLeaf1.m_Right); } int[] numArray = new int[256]; label_21: for (int index = 0; index < 256; ++index) { byte * numPtr2 = numPtr1 + Compression.m_OutputIndex; UnpackLeaf unpackLeaf2 = unpackLeaf1; int num1 = 0; int num2 = 8; while (--num2 >= 0) { switch (index >> num2 & 1) { case 0: unpackLeaf2 = unpackLeaf2.m_Left; break; case 1: unpackLeaf2 = unpackLeaf2.m_Right; break; } if (unpackLeaf2 != null) { if ((int)unpackLeaf2.m_Value != -1) { switch ((int)unpackLeaf2.m_Value >> 8) { case 0: numPtr2[num1++] = (byte)unpackLeaf2.m_Value; break; case 1: num2 = 0; break; } unpackLeaf2 = Compression.m_Tree; } } else { goto label_21; } } unpackCacheEntryPtr2->m_NextIndex = (int)unpackLeaf2.m_Index; unpackCacheEntryPtr2->m_ByteIndex = Compression.m_OutputIndex; unpackCacheEntryPtr2->m_ByteCount = num1; numArray[index] = (int)(unpackCacheEntryPtr2 - unpackCacheEntryPtr1); ++unpackCacheEntryPtr2; Compression.m_OutputIndex += num1; } unpackLeaf1.m_Cache = numArray; } } } }