示例#1
0
        unsafe int LoadStaticPatches(TileMatrixData tileMatrix, string dataPath, string indexPath, string lookupPath)
        {
            m_StaticPatchPtrs = new Dictionary <uint, StaticPatchData>();

            m_StaticPatchStream = FileManager.GetFile(dataPath);
            if (m_StaticPatchStream == null)
            {
                return(0);
            }

            using (FileStream fsIndex = FileManager.GetFile(indexPath))
            {
                using (FileStream fsLookup = FileManager.GetFile(lookupPath))
                {
                    BinaryReader indexReader  = new BinaryReader(fsIndex);
                    BinaryReader lookupReader = new BinaryReader(fsLookup);

                    int count = (int)(indexReader.BaseStream.Length / 4);

                    for (uint i = 0; i < count; ++i)
                    {
                        uint blockID = indexReader.ReadUInt32();
                        uint blockX  = blockID / tileMatrix.ChunkHeight;
                        uint blockY  = blockID % tileMatrix.ChunkHeight;
                        uint key     = MakeChunkKey(blockX, blockY);
                        uint offset  = lookupReader.ReadUInt32();
                        int  length  = lookupReader.ReadInt32();
                        lookupReader.ReadInt32();
                        if (m_StaticPatchPtrs.ContainsKey(key))
                        {
                            StaticPatchData current = m_StaticPatchPtrs[key];
                            while (current.Next != null)
                            {
                                current = current.Next;
                            }
                            current.Next = new StaticPatchData(i, offset, length);
                        }
                        else
                        {
                            m_StaticPatchPtrs.Add(key, new StaticPatchData(i, offset, length));
                        }
                    }

                    indexReader.Close();
                    lookupReader.Close();

                    return(count);
                }
            }
        }
示例#2
0
        unsafe int LoadLandPatches(TileMatrixData tileMatrix, string landPath, string indexPath)
        {
            m_LandPatchPtrs = new Dictionary <uint, LandPatchData>();

            if (ClientVersion.InstallationIsUopFormat)
            {
                return(0);
            }

            m_LandPatchStream = FileManager.GetFile(landPath);
            if (m_LandPatchStream == null)
            {
                return(0);
            }

            using (FileStream fsIndex = FileManager.GetFile(indexPath))
            {
                BinaryReader indexReader = new BinaryReader(fsIndex);
                int          count       = (int)(indexReader.BaseStream.Length / 4);
                uint         ptr         = 0;
                for (uint i = 0; i < count; ++i)
                {
                    uint blockID = indexReader.ReadUInt32();
                    uint x       = blockID / tileMatrix.ChunkHeight;
                    uint y       = blockID % tileMatrix.ChunkHeight;
                    uint key     = MakeChunkKey(x, y);
                    ptr += 4;
                    if (m_LandPatchPtrs.ContainsKey(key))
                    {
                        LandPatchData current = m_LandPatchPtrs[key];
                        while (current.Next != null)
                        {
                            current = current.Next;
                        }
                        current.Next = new LandPatchData(i, ptr);
                    }
                    else
                    {
                        m_LandPatchPtrs.Add(key, new LandPatchData(i, ptr));
                    }
                    ptr += 192;
                }

                indexReader.Close();

                return(count);
            }
        }
示例#3
0
 public TileMatrixDataPatch(TileMatrixData matrix, uint index)
 {
     LoadLandPatches(matrix, String.Format("mapdif{0}.mul", index), String.Format("mapdifl{0}.mul", index));
     LoadStaticPatches(matrix, String.Format("stadif{0}.mul", index), String.Format("stadifl{0}.mul", index), String.Format("stadifi{0}.mul", index));
 }