private unsafe int PatchStatics( TileMatrix matrix, string dataPath, string indexPath, string lookupPath ) { using ( FileStream fsData = new FileStream( dataPath, FileMode.Open, FileAccess.Read, FileShare.Read ) ) { using ( FileStream fsIndex = new FileStream( indexPath, FileMode.Open, FileAccess.Read, FileShare.Read ) ) { using ( FileStream fsLookup = new FileStream( lookupPath, FileMode.Open, FileAccess.Read, FileShare.Read ) ) { BinaryReader indexReader = new BinaryReader( fsIndex ); BinaryReader lookupReader = new BinaryReader( fsLookup ); int count = (int)(indexReader.BaseStream.Length / 4); HuedTileList[][] lists = new HuedTileList[8][]; for ( int x = 0; x < 8; ++x ) { lists[x] = new HuedTileList[8]; for ( int y = 0; y < 8; ++y ) lists[x][y] = new HuedTileList(); } for ( int i = 0; i < count; ++i ) { int blockID = indexReader.ReadInt32(); int blockX = blockID / matrix.BlockHeight; int blockY = blockID % matrix.BlockHeight; int offset = lookupReader.ReadInt32(); int length = lookupReader.ReadInt32(); lookupReader.ReadInt32(); // Extra if ( offset < 0 || length <= 0 ) { matrix.SetStaticBlock( blockX, blockY, matrix.EmptyStaticBlock ); continue; } fsData.Seek( offset, SeekOrigin.Begin ); int tileCount = length / 7; StaticTile[] staTiles = new StaticTile[tileCount]; fixed ( StaticTile *pTiles = staTiles ) { _lread(fsData.SafeFileHandle, pTiles, length); StaticTile *pCur = pTiles, pEnd = pTiles + tileCount; while ( pCur < pEnd ) { lists[pCur->m_X & 0x7][pCur->m_Y & 0x7].Add( (short)((pCur->m_ID & 0x3FFF) + 0x4000), pCur->m_Hue, pCur->m_Z ); ++pCur; } HuedTile[][][] tiles = new HuedTile[8][][]; for ( int x = 0; x < 8; ++x ) { tiles[x] = new HuedTile[8][]; for ( int y = 0; y < 8; ++y ) tiles[x][y] = lists[x][y].ToArray(); } matrix.SetStaticBlock( blockX, blockY, tiles ); } } return count; } } } }
private unsafe int PatchStatics(TileMatrix matrix, string dataPath, string indexPath, string lookupPath) { using (FileStream fsData = new FileStream(dataPath, FileMode.Open, FileAccess.Read, FileShare.Read)) { using (FileStream fsIndex = new FileStream(indexPath, FileMode.Open, FileAccess.Read, FileShare.Read)) { using (FileStream fsLookup = new FileStream(lookupPath, FileMode.Open, FileAccess.Read, FileShare.Read)) { BinaryReader indexReader = new BinaryReader(fsIndex); BinaryReader lookupReader = new BinaryReader(fsLookup); int count = (int)(indexReader.BaseStream.Length / 4); HuedTileList[][] lists = new HuedTileList[8][]; for (int x = 0; x < 8; ++x) { lists[x] = new HuedTileList[8]; for (int y = 0; y < 8; ++y) { lists[x][y] = new HuedTileList(); } } for (int i = 0; i < count; ++i) { int blockID = indexReader.ReadInt32(); int blockX = blockID / matrix.BlockHeight; int blockY = blockID % matrix.BlockHeight; int offset = lookupReader.ReadInt32(); int length = lookupReader.ReadInt32(); lookupReader.ReadInt32(); // Extra if (offset < 0 || length <= 0) { matrix.SetStaticBlock(blockX, blockY, matrix.EmptyStaticBlock); continue; } fsData.Seek(offset, SeekOrigin.Begin); int tileCount = length / 7; StaticTile[] staTiles = new StaticTile[tileCount]; fixed(StaticTile *pTiles = staTiles) { _lread(fsData.Handle, pTiles, length); StaticTile *pCur = pTiles, pEnd = pTiles + tileCount; while (pCur < pEnd) { lists[pCur->m_X & 0x7][pCur->m_Y & 0x7].Add((short)((pCur->m_ID & 0x3FFF) + 0x4000), pCur->m_Hue, pCur->m_Z); ++pCur; } HuedTile[][][] tiles = new HuedTile[8][][]; for (int x = 0; x < 8; ++x) { tiles[x] = new HuedTile[8][]; for (int y = 0; y < 8; ++y) { tiles[x][y] = lists[x][y].ToArray(); } } matrix.SetStaticBlock(blockX, blockY, tiles); } } return(count); } } } }
private unsafe int PatchStatics(TileMatrix matrix, string dataPath, string indexPath, string lookupPath) { using (FileStream fileStream1 = new FileStream(dataPath, FileMode.Open, FileAccess.Read, FileShare.Read)) { using (FileStream fileStream2 = new FileStream(indexPath, FileMode.Open, FileAccess.Read, FileShare.Read)) { using (FileStream fileStream3 = new FileStream(lookupPath, FileMode.Open, FileAccess.Read, FileShare.Read)) { BinaryReader binaryReader1 = new BinaryReader((Stream)fileStream2); BinaryReader binaryReader2 = new BinaryReader((Stream)fileStream3); int num1 = (int)(binaryReader1.BaseStream.Length / 4L); HuedTileList[][] huedTileListArray = new HuedTileList[8][]; for (int index1 = 0; index1 < 8; ++index1) { huedTileListArray[index1] = new HuedTileList[8]; for (int index2 = 0; index2 < 8; ++index2) { huedTileListArray[index1][index2] = new HuedTileList(); } } for (int index1 = 0; index1 < num1; ++index1) { int num2 = binaryReader1.ReadInt32(); int x = num2 / matrix.BlockHeight; int y = num2 % matrix.BlockHeight; int num3 = binaryReader2.ReadInt32(); int wBytes = binaryReader2.ReadInt32(); binaryReader2.ReadInt32(); if (num3 < 0 || wBytes <= 0) { matrix.SetStaticBlock(x, y, matrix.EmptyStaticBlock); } else { fileStream1.Seek((long)num3, SeekOrigin.Begin); int length = wBytes / 7; StaticTile[] staticTileArray = new StaticTile[length]; fixed(StaticTile *staticTilePtr1 = &staticTileArray[0]) { TileMatrixPatch._lread(fileStream1.Handle, (void *)staticTilePtr1, wBytes); StaticTile *staticTilePtr2 = staticTilePtr1; for (StaticTile *staticTilePtr3 = staticTilePtr1 + length; staticTilePtr2 < staticTilePtr3; ++staticTilePtr2) { huedTileListArray[(int)staticTilePtr2->m_X & 7][(int)staticTilePtr2->m_Y & 7].Add((short)(((int)staticTilePtr2->m_ID & 16383) + 16384), staticTilePtr2->m_Hue, staticTilePtr2->m_Z); } HuedTile[][][] huedTileArray = new HuedTile[8][][]; for (int index2 = 0; index2 < 8; ++index2) { huedTileArray[index2] = new HuedTile[8][]; for (int index3 = 0; index3 < 8; ++index3) { huedTileArray[index2][index3] = huedTileListArray[index2][index3].ToArray(); } } matrix.SetStaticBlock(x, y, huedTileArray); } } } return(num1); } } } }
private unsafe int PatchStatics(TileMatrix matrix, string dataPath, string indexPath, string lookupPath) { int num; using (FileStream fileStream = new FileStream(dataPath, FileMode.Open, FileAccess.Read, FileShare.Read)) { using (FileStream fileStream1 = new FileStream(indexPath, FileMode.Open, FileAccess.Read, FileShare.Read)) { using (FileStream fileStream2 = new FileStream(lookupPath, FileMode.Open, FileAccess.Read, FileShare.Read)) { BinaryReader binaryReader = new BinaryReader(fileStream1); BinaryReader binaryReader1 = new BinaryReader(fileStream2); int length = (int)(binaryReader.BaseStream.Length / (long)4); HuedTileList[][] huedTileList = new HuedTileList[8][]; for (int i = 0; i < 8; i++) { huedTileList[i] = new HuedTileList[8]; for (int j = 0; j < 8; j++) { huedTileList[i][j] = new HuedTileList(); } } for (int k = 0; k < length; k++) { int num1 = binaryReader.ReadInt32(); int blockHeight = num1 / matrix.BlockHeight; int blockHeight1 = num1 % matrix.BlockHeight; int num2 = binaryReader1.ReadInt32(); int num3 = binaryReader1.ReadInt32(); binaryReader1.ReadInt32(); if (num2 < 0 || num3 <= 0) { matrix.SetStaticBlock(blockHeight, blockHeight1, matrix.EmptyStaticBlock); } else { fileStream.Seek((long)num2, SeekOrigin.Begin); int num4 = num3 / 7; StaticTile[] staticTileArray = new StaticTile[num4]; try { fixed(StaticTile *staticTilePointer = &staticTileArray[0]) { TileMatrixPatch._lread(fileStream.Handle, staticTilePointer, num3); StaticTile *staticTilePointer1 = staticTilePointer; StaticTile *staticTilePointer2 = staticTilePointer + num4 * sizeof(StaticTile); while (staticTilePointer1 < staticTilePointer2) { huedTileList[(*staticTilePointer1).m_X & 7][(*staticTilePointer1).m_Y & 7].Add((short)(((*staticTilePointer1).m_ID & 16383) + 16384), (*staticTilePointer1).m_Hue, (*staticTilePointer1).m_Z); staticTilePointer1 = staticTilePointer1 + sizeof(StaticTile); } HuedTile[][][] array = new HuedTile[8][][]; for (int l = 0; l < 8; l++) { array[l] = new HuedTile[8][]; for (int m = 0; m < 8; m++) { array[l][m] = huedTileList[l][m].ToArray(); } } matrix.SetStaticBlock(blockHeight, blockHeight1, array); } } finally { staticTilePointer = null; } } } num = length; } } } return(num); }
private unsafe int PatchStatics(TileMatrix matrix, string dataPath, string indexPath, string lookupPath) { using (FileStream fileStream1 = new FileStream(dataPath, FileMode.Open, FileAccess.Read, FileShare.Read)) { using (FileStream fileStream2 = new FileStream(indexPath, FileMode.Open, FileAccess.Read, FileShare.Read)) { using (FileStream fileStream3 = new FileStream(lookupPath, FileMode.Open, FileAccess.Read, FileShare.Read)) { BinaryReader binaryReader1 = new BinaryReader((Stream) fileStream2); BinaryReader binaryReader2 = new BinaryReader((Stream) fileStream3); int num1 = (int) (binaryReader1.BaseStream.Length / 4L); HuedTileList[][] huedTileListArray = new HuedTileList[8][]; for (int index1 = 0; index1 < 8; ++index1) { huedTileListArray[index1] = new HuedTileList[8]; for (int index2 = 0; index2 < 8; ++index2) huedTileListArray[index1][index2] = new HuedTileList(); } for (int index1 = 0; index1 < num1; ++index1) { int num2 = binaryReader1.ReadInt32(); int x = num2 / matrix.BlockHeight; int y = num2 % matrix.BlockHeight; int num3 = binaryReader2.ReadInt32(); int wBytes = binaryReader2.ReadInt32(); binaryReader2.ReadInt32(); if (num3 < 0 || wBytes <= 0) { matrix.SetStaticBlock(x, y, matrix.EmptyStaticBlock); } else { fileStream1.Seek((long) num3, SeekOrigin.Begin); int length = wBytes / 7; StaticTile[] staticTileArray = new StaticTile[length]; fixed (StaticTile* staticTilePtr1 = &staticTileArray[0]) { TileMatrixPatch._lread(fileStream1.Handle, (void*) staticTilePtr1, wBytes); StaticTile* staticTilePtr2 = staticTilePtr1; for (StaticTile* staticTilePtr3 = staticTilePtr1 + length; staticTilePtr2 < staticTilePtr3; ++staticTilePtr2) huedTileListArray[(int) staticTilePtr2->m_X & 7][(int) staticTilePtr2->m_Y & 7].Add((short) (((int) staticTilePtr2->m_ID & 16383) + 16384), staticTilePtr2->m_Hue, staticTilePtr2->m_Z); HuedTile[][][] huedTileArray = new HuedTile[8][][]; for (int index2 = 0; index2 < 8; ++index2) { huedTileArray[index2] = new HuedTile[8][]; for (int index3 = 0; index3 < 8; ++index3) huedTileArray[index2][index3] = huedTileListArray[index2][index3].ToArray(); } matrix.SetStaticBlock(x, y, huedTileArray); } } } return num1; } } } }