Пример #1
0
 unsafe int LoadLandPatches(TileMatrixData tileMatrix, string landPath, string indexPath)
 {
     _landPatchPtrs = new Dictionary <uint, LandPatchData>();
     if (ClientVersion.InstallationIsUopFormat)
     {
         return(0);
     }
     _landPatchStream = UltimaFileManager.GetFile(landPath);
     if (_landPatchStream == null)
     {
         return(0);
     }
     using (var fsIndex = UltimaFileManager.GetFile(indexPath))
     {
         var indexReader = new BinaryReader(fsIndex);
         var count       = (int)(indexReader.BaseStream.Length / 4);
         var ptr         = 0U;
         for (var i = 0U; 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);
     }
 }
Пример #2
0
 unsafe int LoadStaticPatches(TileMatrixData tileMatrix, string dataPath, string indexPath, string lookupPath)
 {
     _staticPatchPtrs   = new Dictionary <uint, StaticPatchData>();
     _staticPatchStream = UltimaFileManager.GetFile(dataPath);
     if (_staticPatchStream == null)
     {
         return(0);
     }
     using (var fsIndex = UltimaFileManager.GetFile(indexPath))
         using (var fsLookup = UltimaFileManager.GetFile(lookupPath))
         {
             var indexReader  = new BinaryReader(fsIndex);
             var lookupReader = new BinaryReader(fsLookup);
             var count        = (int)(indexReader.BaseStream.Length / 4);
             for (var i = 0U; 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);
         }
 }
Пример #3
0
 public TileMatrixDataPatch(TileMatrixData matrix, uint idx)
 {
     LoadLandPatches(matrix, $"mapdif{idx}.mul", $"mapdifl{idx}.mul");
     LoadStaticPatches(matrix, $"stadif{idx}.mul", $"stadifl{idx}.mul", $"stadifi{idx}.mul");
 }