本文整理汇总了C#中Ionic.Zlib.DeflateStream.ReadByte方法的典型用法代码示例。如果您正苦于以下问题:C# DeflateStream.ReadByte方法的具体用法?C# DeflateStream.ReadByte怎么用?C# DeflateStream.ReadByte使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ionic.Zlib.DeflateStream
的用法示例。
在下文中一共展示了DeflateStream.ReadByte方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Load
public static Chunk Load(UniversalCoords coords, WorldManager world)
{
string path = world.Folder + "/x" + coords.ChunkX + "_z" + coords.ChunkZ + ".gz";
if (!CanLoad(path))
return null;
Stream zip = null;
Chunk chunk = new Chunk(world, coords);
try
{
zip = new DeflateStream(File.Open(path, FileMode.Open), CompressionMode.Decompress);
int version = zip.ReadByte();
switch(version)
{
/* When there's a new mod you do:
case 1:
{
* dosomething
* goto case 0;
}*/
case 0:
{
chunk.LightToRecalculate = Convert.ToBoolean(zip.ReadByte());
chunk.HeightMap = new byte[16,16];
int height;
chunk.MaxHeight = 0;
for (int x = 0; x < 16; ++x)
{
for (int z = 0; z < 16; ++z)
{
height = chunk.HeightMap[x, z] = (byte) zip.ReadByte();
if (chunk.MaxHeight < height)
chunk.MaxHeight = height;
}
}
chunk.LoadAllBlocks(zip);
break;
}
}
}
catch (Exception ex)
{
world.Logger.Log(ex);
return null;
}
if (zip != null)
zip.Dispose();
(BlockHelper.Instance((byte) BlockData.Blocks.Sign_Post) as BlockSignBase).LoadSignsFromDisk(chunk, world.SignsFolder);
return chunk;
}
示例2: Load
public bool Load()
{
if (!CanLoad())
return false;
Stream zip = null;
Monitor.Enter(_SavingLock);
try
{
zip = new DeflateStream(File.Open(DataFile, FileMode.Open), CompressionMode.Decompress);
HeightMap = new byte[16, 16];
for (int x = 0; x < 16; ++x)
{
for (int z = 0; z < 16; ++z)
{
HeightMap[x, z] = (byte)zip.ReadByte();
}
}
LoadAllBlocks(zip);
return true;
}
catch (Exception ex)
{
World.Logger.Log(ex);
return false;
}
finally
{
Monitor.Exit(_SavingLock);
if (zip != null)
zip.Dispose();
}
}