当前位置: 首页>>代码示例>>C#>>正文


C# DeflateStream.ReadByte方法代码示例

本文整理汇总了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;
        }
开发者ID:dekema2,项目名称:c-raft,代码行数:58,代码来源:Chunk.cs

示例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();
            }
        }
开发者ID:StianLohna,项目名称:c-raft,代码行数:33,代码来源:Chunk.cs


注:本文中的Ionic.Zlib.DeflateStream.ReadByte方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。