示例#1
0
 /// <summary>
 /// Internally saves chunk blocks to file.
 /// </summary>
 /// <param name="blks">The block data.</param>
 void SaveToFileI(byte[] blks)
 {
     try
     {
         ChunkDetails det = new ChunkDetails()
         {
             Version    = 2,
             X          = WorldPosition.X,
             Y          = WorldPosition.Y,
             Z          = WorldPosition.Z,
             Flags      = Flags,
             Blocks     = blks,
             Reachables = new byte[(int)ChunkReachability.COUNT]
         };
         for (int i = 0; i < det.Reachables.Length; i++)
         {
             det.Reachables[i] = (byte)(Reachability[i] ? 1 : 0);
         }
         byte[] lod    = LODBytes(5, false, true);
         byte[] lodsix = LODBytes(6, false, true);
         byte[] slod   = lod.Length == 0 ? lod : SLODBytes(lod, true);
         lock (GetLocker())
         {
             OwningRegion.PushHeightCorrection(WorldPosition, slod);
         }
         if (blks.Length == 0 && !FromFile)
         {
             return;
         }
         lock (GetLocker())
         {
             OwningRegion.ChunkManager.WriteChunkDetails(det);
             //OwningRegion.ChunkManager.WriteLODChunkDetails(det.X, det.Y, det.Z, lod);
             OwningRegion.ChunkManager.WriteSuperLODChunkDetails(det.X, det.Y, det.Z, slod);
             OwningRegion.ChunkManager.WriteLODSixChunkDetails(det.X, det.Y, det.Z, lodsix);
         }
     }
     catch (Exception ex)
     {
         SysConsole.Output(OutputType.ERROR, "Saving chunk " + WorldPosition.ToString() + " to file: " + ex.ToString());
     }
 }