Example #1
0
        private unsafe int PatchLand(TileMatrix matrix, string dataPath, string indexPath)
        {
            using (FileStream fileStream1 = new FileStream(dataPath, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                using (FileStream fileStream2 = new FileStream(indexPath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    BinaryReader binaryReader = new BinaryReader((Stream)fileStream2);
                    int          num1         = (int)(binaryReader.BaseStream.Length / 4L);
                    for (int index = 0; index < num1; ++index)
                    {
                        int num2 = binaryReader.ReadInt32();
                        int x    = num2 / matrix.BlockHeight;
                        int y    = num2 % matrix.BlockHeight;
                        fileStream1.Seek(4L, SeekOrigin.Current);
                        Tile[] tileArray = new Tile[64];

                        fixed(Tile *tilePtr = &tileArray[0])
                        TileMatrixPatch._lread(fileStream1.Handle, (void *)tilePtr, 192);

                        matrix.SetLandBlock(x, y, tileArray);
                    }
                    return(num1);
                }
            }
        }
Example #2
0
 private int PatchLand(TileMatrix matrix, string dataPath, string indexPath)
 {
     unsafe
     {
         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))
             {
                 BinaryReader binaryReader = new BinaryReader(fileStream1);
                 int          length       = (int)(binaryReader.BaseStream.Length / (long)4);
                 for (int i = 0; i < length; i++)
                 {
                     int num1         = binaryReader.ReadInt32();
                     int blockHeight  = num1 / matrix.BlockHeight;
                     int blockHeight1 = num1 % matrix.BlockHeight;
                     fileStream.Seek((long)4, SeekOrigin.Current);
                     Tile[] tileArray = new Tile[64];
                     try
                     {
                         fixed(Tile *tilePointer = &tileArray[0])
                         {
                             TileMatrixPatch._lread(fileStream.Handle, tilePointer, 192);
                         }
                     }
                     finally
                     {
                         tilePointer = null;
                     }
                     matrix.SetLandBlock(blockHeight, blockHeight1, tileArray);
                 }
                 num = length;
             }
         }
         return(num);
     }
 }
Example #3
0
        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);
        }
Example #4
0
        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);
                    }
                }
            }
        }