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


C# BinaryReader.ReadFixedLengthString方法代码示例

本文整理汇总了C#中System.IO.BinaryReader.ReadFixedLengthString方法的典型用法代码示例。如果您正苦于以下问题:C# BinaryReader.ReadFixedLengthString方法的具体用法?C# BinaryReader.ReadFixedLengthString怎么用?C# BinaryReader.ReadFixedLengthString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.BinaryReader的用法示例。


在下文中一共展示了BinaryReader.ReadFixedLengthString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetFromStream

        protected override DataStructures.MapObjects.Map GetFromStream(Stream stream)
        {
            var map = new DataStructures.MapObjects.Map();
            var br = new BinaryReader(stream);

            // Only RMF version 2.2 is supported for the moment.
            var version = Math.Round(br.ReadSingle(), 1);
            if (Math.Abs(version - 2.2) > 0.01)
            {
                throw new ProviderException("Incorrect RMF version number. Expected 2.2, got " + version + ".");
            }
            map.Version = (decimal) version;

            // RMF header test
            var header = br.ReadFixedLengthString(Encoding.UTF8, 3);
            if (header != "RMF")
            {
                throw new ProviderException("Incorrect RMF header. Expected 'RMF', got '" + header + "'.");
            }

            // Visgroups
            var visgroups = ReadVisgroups(br);
            map.Visgroups.AddRange(visgroups);

            // Map Objects
            map.IDGenerator.Reset(); // So the world will be ID = 1
            var worldspawn = ReadWorldSpawn(br, map.Visgroups, map.IDGenerator);
            map.WorldSpawn = worldspawn;

            // DOCINFO string check
            var docinfo = br.ReadFixedLengthString(Encoding.UTF8, 8);
            if (docinfo != "DOCINFO")
            {
                throw new ProviderException("Incorrect RMF format. Expected 'DOCINFO', got '" + docinfo + "'.");
            }

            // Cameras
            br.ReadSingle(); // Appears to be a version number for camera data. Unused.
            var activeCamera = br.ReadInt32();
            var cameras = ReadCameras(br);
            map.Cameras.AddRange(cameras);
            if (activeCamera >= 0 && activeCamera < map.Cameras.Count)
            {
                map.ActiveCamera = map.Cameras[activeCamera];
            }

            return map;
        }
开发者ID:074769,项目名称:sledge,代码行数:48,代码来源:RmfProvider.cs

示例2: Parse

 private static Bitmap Parse(FileInfo file)
 {
     // Sprite file spec taken from the spritegen source in the Half-Life SDK.
     using (var br = new BinaryReader(file.OpenRead()))
     {
         var idst = br.ReadFixedLengthString(Encoding.ASCII, 4);
         if (idst != "IDSP") return null;
         var version = br.ReadInt32();
         if (version != 2) return null;
         var type = br.ReadInt32();
         var texFormat = br.ReadInt32();
         var boundingRadius = br.ReadSingle();
         var width = br.ReadInt32();
         var height = br.ReadInt32();
         var numframes = br.ReadInt32();
         var beamlength = br.ReadSingle();
         var synctype = br.ReadInt32();
         var paletteSize = br.ReadInt16();
         var palette = br.ReadBytes(paletteSize * 3);
         // Only read the first frame.
         var frametype = br.ReadInt32();
         if (frametype != 0)
         {
             var num = br.ReadInt32();
             var intervals = br.ReadSingleArray(num);
         }
         var originX = br.ReadInt32();
         var originY = br.ReadInt32();
         var framewidth = br.ReadInt32();
         var frameheight = br.ReadInt32();
         var pixels = br.ReadBytes(framewidth * frameheight);
         var bitmap = new Bitmap(framewidth, frameheight);
         for (var y = 0; y < frameheight; y++)
         {
             for (var x = 0; x < framewidth; x++)
             {
                 var idx = pixels[framewidth * y + x] * 3;
                 var a = 255;
                 var r = palette[idx + 0];
                 var g = palette[idx + 1];
                 var b = palette[idx + 2];
                 if (b == 255 && r == 0 && g == 0) a = b = 0; // blue pixels are transparent
                 var col = Color.FromArgb(a, r, g, b);
                 bitmap.SetPixel(x, y, col);
             }
         }
         return bitmap;
     }
 }
开发者ID:jpiolho,项目名称:sledge,代码行数:49,代码来源:SprProvider.cs

示例3: GetSize

        private static Size GetSize(IFile file)
        {
            using (var br = new BinaryReader(file.Open()))
            {
                var idst = br.ReadFixedLengthString(Encoding.ASCII, 4);
                if (idst != "IDSP") return Size.Empty;
                var version = br.ReadInt32();
                if (version != 2) return Size.Empty;
                var type = (SpriteOrientation) br.ReadInt32();
                var texFormat = (SpriteRenderMode) br.ReadInt32();
                var boundingRadius = br.ReadSingle();
                var width = br.ReadInt32();
                var height = br.ReadInt32();

                return new Size(width, height);
            }
        }
开发者ID:KonstantinUb,项目名称:sledge,代码行数:17,代码来源:SprProvider.cs

示例4: PakPackage

        public PakPackage(FileInfo packageFile)
        {
            PackageFile = packageFile;
            Entries = new List<PakEntry>();

            // Read the data from the pak
            using (var br = new BinaryReader(OpenFile(packageFile)))
            {
                var sig = br.ReadFixedLengthString(Encoding.ASCII, 4);
                if (sig != Signature) throw new PackageException("Unknown package signature: Expected '" + Signature + "', got '" + sig + "'.");

                TreeOffset = br.ReadInt32();
                TreeLength = br.ReadInt32();

                // Read all the entries from the pak
                ReadPackageEntries(br);
                BuildDirectories();
            }
        }
开发者ID:silky,项目名称:sledge,代码行数:19,代码来源:PakPackage.cs

示例5: WadPackage

        public WadPackage(FileInfo packageFile)
        {
            PackageFile = packageFile;
            Entries = new List<WadEntry>();

            // Read the data from the wad
            using (var br = new BinaryReader(OpenFile(packageFile)))
            {
                var sig = br.ReadFixedLengthString(Encoding.ASCII, 4);
                if (sig != Signature) throw new PackageException("Unknown package signature: Expected '" + Signature + "', got '" + sig + "'.");

                NumTextures = br.ReadUInt32();
                LumpOffset = br.ReadUInt32();

                // Read all the entries from the wad
                ReadTextureEntries(br);
                SetAdditionalEntryData(br);
                RemoveInvalidEntries();
                BuildDirectories();
            }
        }
开发者ID:silky,项目名称:sledge,代码行数:21,代码来源:WadPackage.cs

示例6: ReadPath

 private static Path ReadPath(BinaryReader br)
 {
     var path = new Path
         {
             Name = br.ReadFixedLengthString(Encoding.UTF8, 128),
             Type = br.ReadFixedLengthString(Encoding.UTF8, 128),
             Direction = (PathDirection) br.ReadInt32()
         };
     var numNodes = br.ReadInt32();
     for (var i = 0; i < numNodes; i++)
     {
         var node = ReadPathNode(br);
         node.Parent = path;
         path.Nodes.Add(node);
     }
     return path;
 }
开发者ID:074769,项目名称:sledge,代码行数:17,代码来源:RmfProvider.cs

示例7: ReadPathNode

 private static PathNode ReadPathNode(BinaryReader br)
 {
     var node = new PathNode
         {
             Position = br.ReadCoordinate(),
             ID = br.ReadInt32(),
             Name = br.ReadFixedLengthString(Encoding.UTF8, 128)
         };
     var numProps = br.ReadInt32();
     for (var i = 0; i < numProps; i++)
     {
         node.Properties.Add(ReadProperty(br));
     }
     return node;
 }
开发者ID:074769,项目名称:sledge,代码行数:15,代码来源:RmfProvider.cs

示例8: GetImage

        public static Bitmap GetImage(Stream stream, int maxWidth = 0, int maxHeight = 0)
        {
            using (var br = new BinaryReader(stream))
            {
                var header = br.ReadFixedLengthString(Encoding.ASCII, 4);
                if (header != VtfHeader) throw new ProviderException("Invalid VTF header. Expected '" + VtfHeader + "', got '" + header + "'.");

                var v1 = br.ReadUInt32();
                var v2 = br.ReadUInt32();
                var version = v1 + (v2 / 10m); // e.g. 7.3

                var headerSize = br.ReadUInt32();
                var width = br.ReadUInt16();
                var height = br.ReadUInt16();

                var flags = (VtfImageFlag) br.ReadUInt32();

                var numFrames = br.ReadUInt16();
                var firstFrame = br.ReadUInt16();

                br.ReadBytes(4); // padding

                var reflectivity = br.ReadCoordinate();

                br.ReadBytes(4); // padding

                var bumpmapScale = br.ReadSingle();

                var highResImageFormat = (VtfImageFormat) br.ReadUInt32();
                var mipmapCount = br.ReadByte();
                var lowResImageFormat = (VtfImageFormat) br.ReadUInt32();
                var lowResWidth = br.ReadByte();
                var lowResHeight = br.ReadByte();

                ushort depth = 1;
                uint numResources = 0;

                if (version >= 7.2m)
                {
                    depth = br.ReadUInt16();
                }
                if (version >= 7.3m)
                {
                    br.ReadBytes(3);
                    numResources = br.ReadUInt32();
                }

                var faces = 1;
                if (flags.HasFlag(VtfImageFlag.Envmap))
                {
                    faces = version < 7.5m && firstFrame != 0xFFFF ? 7 : 6;
                }

                var imageSize = ComputeImageSize(width, height, depth, mipmapCount, highResImageFormat) * faces * numFrames;
                var thumbnailSize = lowResImageFormat == VtfImageFormat.None
                    ? 0
                    : ComputeImageSize(lowResWidth, lowResHeight, 1, lowResImageFormat);

                var thumbnailPos = headerSize;
                var dataPos = headerSize + thumbnailSize;

                for (var i = 0; i < numResources; i++)
                {
                    var type = br.ReadUInt32();
                    var data = br.ReadUInt32();
                    switch (type)
                    {
                        case 0x01:
                            // Low res image
                            thumbnailPos = data;
                            break;
                        case 0x30:
                            // Regular image
                            dataPos = data;
                            break;
                    }
                }

                if (lowResImageFormat != VtfImageFormat.None)
                {
                    br.BaseStream.Position = thumbnailPos;
                    var thumbnail = br.ReadBytes((int) thumbnailSize);
                    //var thumbImage = LoadImage(br, lowResWidth, lowResHeight, lowResImageFormat);
                    //return thumbImage;
                }

                var mipNum = 0;
                if (maxWidth > 0 || maxHeight > 0) mipNum = GetMipToLoad(width, height, maxWidth > 0 ? maxWidth : width, maxHeight > 0 ? maxHeight : height, mipmapCount);

                for (var frame = 0; frame < numFrames; frame++)
                {
                    for (var face = 0; face < faces; face++)
                    {
                        for (var slice = 0; slice < depth; slice++)
                        {
                            for (var mip = mipNum; mip < mipmapCount; mip++)
                            {
                                var wid = MipmapResize(width, mip);
                                var hei = MipmapResize(height, mip);
                                var offset = GetImageDataLocation(frame, face, slice, mip, highResImageFormat, width, height, numFrames, faces, depth, mipmapCount);
//.........这里部分代码省略.........
开发者ID:silky,项目名称:sledge,代码行数:101,代码来源:VtfProvider.cs

示例9: ReadFace

 private static Face ReadFace(BinaryReader br, IDGenerator generator)
 {
     var face = new Face(generator.GetNextFaceID());
     var textureName = br.ReadFixedLengthString(Encoding.UTF8, 256);
     br.ReadBytes(4); // Unused
     face.Texture.Name = textureName;
     face.Texture.UAxis = br.ReadCoordinate();
     face.Texture.XShift = br.ReadSingleAsDecimal();
     face.Texture.VAxis = br.ReadCoordinate();
     face.Texture.YShift = br.ReadSingleAsDecimal();
     face.Texture.Rotation = br.ReadSingleAsDecimal();
     face.Texture.XScale = br.ReadSingleAsDecimal();
     face.Texture.YScale = br.ReadSingleAsDecimal();
     br.ReadBytes(16); // Unused
     var numVerts = br.ReadInt32();
     for (var i = 0; i < numVerts; i++)
     {
         face.Vertices.Add(new Vertex(br.ReadCoordinate(), face));
     }
     face.Plane = br.ReadPlane();
     face.UpdateBoundingBox();
     return face;
 }
开发者ID:074769,项目名称:sledge,代码行数:23,代码来源:RmfProvider.cs

示例10: Parse

        private static Bitmap Parse(IFile file)
        {
            // Sprite file spec taken from the spritegen source in the Half-Life SDK.
            using (var br = new BinaryReader(file.Open()))
            {
                var idst = br.ReadFixedLengthString(Encoding.ASCII, 4);
                if (idst != "IDSP") return null;
                var version = br.ReadInt32();
                if (version != 2) return null;
                var type = (SpriteOrientation) br.ReadInt32();
                var texFormat = (SpriteRenderMode) br.ReadInt32();
                var boundingRadius = br.ReadSingle();
                var width = br.ReadInt32();
                var height = br.ReadInt32();
                var numframes = br.ReadInt32();
                var beamlength = br.ReadSingle();
                var synctype = br.ReadInt32();
                var paletteSize = br.ReadInt16();
                var palette = br.ReadBytes(paletteSize * 3);

                if (paletteSize > 256) paletteSize = 256; // Don't accept anything higher
                var colours = new Color[256];
                for (var i = 0; i < paletteSize; i++)
                {
                    var r = palette[i * 3 + 0];
                    var g = palette[i * 3 + 1];
                    var b = palette[i * 3 + 2];
                    colours[i] = Color.FromArgb(255, r, g, b);
                }

                // Only read the first frame.
                var frametype = br.ReadInt32();
                if (frametype != 0)
                {
                    var num = br.ReadInt32();
                    var intervals = br.ReadSingleArray(num);
                }
                var originX = br.ReadInt32();
                var originY = br.ReadInt32();
                var framewidth = br.ReadInt32();
                var frameheight = br.ReadInt32();
                var pixels = br.ReadBytes(framewidth * frameheight);

                var bitmap = new Bitmap(framewidth, frameheight, PixelFormat.Format8bppIndexed);

                // Pre-process the palette
                var pal = bitmap.Palette;
                var last = colours[255];
                for (var i = 0; i < paletteSize; i++)
                {
                    var c = colours[i];
                    if (texFormat == SpriteRenderMode.Additive)
                    {
                        var a = (int) ((c.R + c.G + c.B) / 3f);
                        c = Color.FromArgb(a, c);
                    }
                    else if (texFormat == SpriteRenderMode.IndexAlpha && i < 255)
                    {
                        var a = (int) ((c.R + c.G + c.B) / 3f);
                        c = Color.FromArgb(a, last);
                    }
                    pal.Entries[i] = c;
                }
                if (texFormat == SpriteRenderMode.AlphaTest)
                {
                    pal.Entries[255] = Color.FromArgb(0, 0, 0, 0);
                }
                bitmap.Palette = pal;

                // Set the pixel data
                var data = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadWrite, bitmap.PixelFormat);
                Marshal.Copy(pixels, 0, data.Scan0, data.Width * data.Height);
                bitmap.UnlockBits(data);

                return bitmap;
            }
        }
开发者ID:KonstantinUb,项目名称:sledge,代码行数:77,代码来源:SprProvider.cs

示例11: GetSize

        public static Size GetSize(Stream stream)
        {
            using (var br = new BinaryReader(stream))
            {
                var header = br.ReadFixedLengthString(Encoding.ASCII, 4);
                if (header != VtfHeader) throw new ProviderException("Invalid VTF header. Expected '" + VtfHeader + "', got '" + header + "'.");

                var v1 = br.ReadUInt32();
                var v2 = br.ReadUInt32();
                var version = v1 + (v2 / 10); // e.g. 7.3

                var headerSize = br.ReadUInt32();
                var width = br.ReadUInt16();
                var height = br.ReadUInt16();

                return new Size(width, height);
            }
        }
开发者ID:silky,项目名称:sledge,代码行数:18,代码来源:VtfProvider.cs

示例12: LoadSourceMeshData

        private static void LoadSourceMeshData(ModelData modelData, IFile file)
        {
            modelData.Meshes = new List<VTXModel>();
            // In Source the vertices are saved to the VVD file
            // The vertex windings are saved in the VTX file
            var vvd = file.GetRelatedFile("vvd");
            var vtx = file.GetRelatedFile("vtx");
            if (vvd == null) throw new ProviderException("Unable to locate " + file.NameWithoutExtension + ".vvd");
            if (vtx == null) throw new ProviderException("Unable to locate " + file.NameWithoutExtension + ".vtx");

            var vertices = new List<VVDPoint>();

            using (var fs = vvd.Open())
            {
                using (var vbr = new BinaryReader(fs))
                {
                    var magicString = vbr.ReadFixedLengthString(Encoding.UTF8, 4);
                    if (magicString != MagicStringIDSV)
                    {
                        throw new ProviderException("Bad magic number for vertex file. Expected IDSV, got: " + magicString);
                    }

                    var version = vbr.ReadInt32();
                    if (version != VVDVersionSource)
                    {
                        throw new ProviderException("Bad version number for vertex file. Expected 4, got: " + version);
                    }

                    long checksum = vbr.ReadInt32();
                    var numLods = vbr.ReadInt32();
                    var numLodVertices = vbr.ReadIntArray(8);

                    var numFixups = vbr.ReadInt32();
                    var fixupTableStart = vbr.ReadInt32();
                    var vertexDataStart = vbr.ReadInt32();
                    var tangentDataStart = vbr.ReadInt32();

                    vbr.BaseStream.Position = vertexDataStart;

                    // Read all the vertices from LOD 0 (this should contain the vertices for all LODs)
                    for (var i = 0; i < numLodVertices[0]; i++)
                    {
                        var boneWeights = vbr.ReadSingleArray(3);
                        var bones = vbr.ReadBytes(3);
                        var numBones = vbr.ReadByte();
                        var position = vbr.ReadCoordinateF();
                        var normal = vbr.ReadCoordinateF();
                        var textureS = vbr.ReadSingle();
                        var textureT = vbr.ReadSingle();
                        vertices.Add(new VVDPoint(boneWeights, bones, numBones, position, normal, textureS, textureT));
                    }

                    // Apply the fixup table, this re-orders the indices in reverse LOD order for performance reasons
                    if (numFixups > 0)
                    {
                        vbr.BaseStream.Position = fixupTableStart;
                        var newVerts = new List<VVDPoint>();
                        for (var i = 0; i < numFixups; i++)
                        {
                            var fuLod = vbr.ReadInt32();
                            var fuvertid = vbr.ReadInt32();
                            var funumverts = vbr.ReadInt32();
                            newVerts.AddRange(vertices.GetRange(fuvertid, funumverts));
                        }
                        vertices.Clear();
                        vertices.AddRange(newVerts);
                    }

                    modelData.Vertices = vertices;
                }
            }
            using (var fs = vtx.Open())
            {
                using (var vbr = new BinaryReader(fs))
                {
                    var version = vbr.ReadInt32(); // 7
                    if (version != VTXVersionSource)
                    {
                        throw new ProviderException("Bad version number for vertex file. Expected 7, got: " + version);
                    }
                    var vertCacheSize = vbr.ReadInt32();
                    var maxBonesPerStrip = vbr.ReadUInt16();
                    var maxBonesPerTri = vbr.ReadUInt16();
                    var maxBonesPerVert = vbr.ReadInt32();
                    long checksum = vbr.ReadInt32();
                    var numLods = vbr.ReadInt32();
                    var materialReplacementListOffset = vbr.ReadInt32();
                    var numBodyParts = vbr.ReadInt32();
                    var bodyPartOffset = vbr.ReadInt32();

                    // BODY PARTS
                    long posbp = bodyPartOffset;
                    for (var bp = 0; bp < numBodyParts; bp++)
                    {
                        vbr.BaseStream.Position = posbp;

                        var numModels = vbr.ReadInt32();
                        var modelOffset = vbr.ReadInt32();

                        var posmdl = posbp + modelOffset;
//.........这里部分代码省略.........
开发者ID:silky,项目名称:sledge,代码行数:101,代码来源:MdlProvider.cs

示例13: ReadModel

        private static DataStructures.Models.Model ReadModel(BinaryReader br, IFile file, ModelLoadItems loadItems)
        {
            // int id - Not really an int. This is a magic string, either "IDST" or "IDSQ".
            var magicString = br.ReadFixedLengthString(Encoding.UTF8, 4);
            if (magicString != MagicStringIDST && magicString != MagicStringIDSQ)
            {
                throw new ProviderException("Bad magic number for model. Expected [IDST,IDSQ], got: " + magicString);
            }

            // int version - Half-life 1 models are version 10.
            var version = br.ReadInt32();
            if (version != MDLVersionGoldsource
                && version != MDLVersionSource2006
                && version != MDLVersionSourceEpisode2
                && version != MDLVersionSourcePortal
                && version != MDLVersionSource2007
                && version != MDLVersionSource2012)
            {
                throw new ProviderException("Bad version number for model. Expected [10,44,45,46,48,49], got: " + version);
            }

            var modelData = new ModelData {Version = version};

            if (version >= MDLVersionSource2006)
            {
                if (loadItems.HasFlag(ModelLoadItems.Meshes))
                {
                    // Source vertex and mesh info is stored in flat file structures, preload these separately.
                    LoadSourceMeshData(modelData, file);
                }
            }

            long checksum = 0;
            if (version >= MDLVersionSource2006)
            {
                checksum = br.ReadInt32(); // This is a long in the headers but is only written to the file in 4 bytes. Why? I don't know.
            }

            // char name[64] - The name of the model (file path)
            var path = br.ReadFixedLengthString(Encoding.UTF8, 64);

            // int length - The size of the model file in bytes
            var fileSize = br.ReadInt32();

            var eyePosition = br.ReadCoordinateF();

            var illumPosition = CoordinateF.Zero;
            if (version >= MDLVersionSource2006)
            {
                illumPosition = br.ReadCoordinateF();
            }

            var hullMin = br.ReadCoordinateF();
            var hullMax = br.ReadCoordinateF();

            var bbMin = br.ReadCoordinateF();
            var bbMax = br.ReadCoordinateF();

            // int flags - Unknown.
            var flags = br.ReadInt32();

            var numBones = br.ReadInt32();
            var boneIndex = br.ReadInt32();

            var numBoneControllers = br.ReadInt32();
            var boneControllerIndex = br.ReadInt32();

            var numHitBoxes = br.ReadInt32();
            var hitboxIndex = br.ReadInt32();

            if (version >= MDLVersionSource2006)
            {
                var numAnim = br.ReadInt32();
                var animIndex = br.ReadInt32();
                if (loadItems.HasFlag(ModelLoadItems.Animations))
                {
                    // Source animation data is stored on their own instead of inside the sequence
                    LoadSourceAnimationData(br, modelData, numAnim, animIndex);
                }
            }

            var numSeq = br.ReadInt32();
            var seqIndex = br.ReadInt32();

            int numSeqGroups = 0, seqGroupIndex = 0, activitylistversion = 0, eventsindexed = 0;
            if (version >= MDLVersionSource2006)
            {
                activitylistversion = br.ReadInt32();
                eventsindexed = br.ReadInt32();
            }
            else if (version == MDLVersionGoldsource)
            {
                numSeqGroups = br.ReadInt32();
                seqGroupIndex = br.ReadInt32();
            }

            var numTextures = br.ReadInt32();
            var textureIndex = br.ReadInt32();
            var textureDataIndex = 0;

//.........这里部分代码省略.........
开发者ID:silky,项目名称:sledge,代码行数:101,代码来源:MdlProvider.cs

示例14: ReadTextureEntries

        private void ReadTextureEntries(BinaryReader br)
        {
            var validTypes = Enum.GetValues(typeof (WadEntryType)).OfType<WadEntryType>().Select(x => (byte) x).ToArray();
            br.BaseStream.Position = LumpOffset;
            for (int i = 0; i < NumTextures; i++)
            {
                var offset = br.ReadUInt32();
                var compressedLength = br.ReadUInt32();
                var fullLength = br.ReadUInt32();
                var type =  br.ReadByte();
                var compressionType = br.ReadByte();
                br.ReadBytes(2); // struct padding
                var name = br.ReadFixedLengthString(Encoding.ASCII, 16).ToLowerInvariant();

                if (!validTypes.Contains(type)) continue; // Skip unsupported types
                if (Entries.Any(x => x.Name == name)) continue; // Don't add duplicates
                Entries.Add(new WadEntry(this, name, (WadEntryType) type, offset, compressionType, compressedLength, fullLength));
            }
        }
开发者ID:silky,项目名称:sledge,代码行数:19,代码来源:WadPackage.cs

示例15: ReadBodyPart

        private static void ReadBodyPart(BinaryReader br, int bodyPartIndex, ModelData data, DataStructures.Models.Model model)
        {
            var startIndex = data.Version == MDLVersionGoldsource ? 0 : br.BaseStream.Position;
            var name = "";
            var nameIndex = 0;
            if (data.Version >= MDLVersionSource2006)
            {
                nameIndex = br.ReadInt32();
                var idx = br.BaseStream.Position;
                br.BaseStream.Position = startIndex + nameIndex;
                name = br.ReadNullTerminatedString();
                br.BaseStream.Position = idx;
            }
            else if (data.Version == MDLVersionGoldsource)
            {
                name = br.ReadFixedLengthString(Encoding.UTF8, 64);
            }
            var numModels = br.ReadInt32();
            var baseIndex = br.ReadInt32();
            var modelIndex = br.ReadInt32();

            var endIndex = br.BaseStream.Position;

            br.BaseStream.Position = modelIndex + startIndex;
            for (var i = 0; i < numModels; i++)
            {
                ReadStudioModel(br, name, bodyPartIndex, i, data, model);
            }

            br.BaseStream.Position = endIndex;
        }
开发者ID:silky,项目名称:sledge,代码行数:31,代码来源:MdlProvider.cs


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