unsafe int LoadStaticPatches(TileMatrixData tileMatrix, string dataPath, string indexPath, string lookupPath) { _staticPatchPtrs = new Dictionary <uint, StaticPatchData>(); _staticPatchStream = FileManager.GetFile(dataPath); if (_staticPatchStream == null) { return(0); } using (var fsIndex = FileManager.GetFile(indexPath)) { using (var fsLookup = FileManager.GetFile(lookupPath)) { var indexReader = new BinaryReader(fsIndex); var lookupReader = new BinaryReader(fsLookup); var count = (int)(indexReader.BaseStream.Length / 4); for (uint i = 0; i < count; ++i) { var blockID = indexReader.ReadUInt32(); var blockX = blockID / tileMatrix.ChunkHeight; var blockY = blockID % tileMatrix.ChunkHeight; var key = MakeChunkKey(blockX, blockY); var offset = lookupReader.ReadUInt32(); var length = lookupReader.ReadInt32(); lookupReader.ReadInt32(); if (_staticPatchPtrs.ContainsKey(key)) { var current = _staticPatchPtrs[key]; while (current.Next != null) { current = current.Next; } current.Next = new StaticPatchData(i, offset, length); } else { _staticPatchPtrs.Add(key, new StaticPatchData(i, offset, length)); } } indexReader.Close(); lookupReader.Close(); return(count); } } }
unsafe int LoadLandPatches(TileMatrixData tileMatrix, string landPath, string indexPath) { _landPatchPtrs = new Dictionary <uint, LandPatchData>(); if (ClientVersion.InstallationIsUopFormat) { return(0); } _landPatchStream = FileManager.GetFile(landPath); if (_landPatchStream == null) { return(0); } using (var fsIndex = FileManager.GetFile(indexPath)) { var indexReader = new BinaryReader(fsIndex); var count = (int)(indexReader.BaseStream.Length / 4); uint ptr = 0; for (uint i = 0; i < count; ++i) { var blockID = indexReader.ReadUInt32(); var x = blockID / tileMatrix.ChunkHeight; var y = blockID % tileMatrix.ChunkHeight; var key = MakeChunkKey(x, y); ptr += 4; if (_landPatchPtrs.ContainsKey(key)) { var current = _landPatchPtrs[key]; while (current.Next != null) { current = current.Next; } current.Next = new LandPatchData(i, ptr); } else { _landPatchPtrs.Add(key, new LandPatchData(i, ptr)); } ptr += 192; } indexReader.Close(); return(count); } }
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)); }