Skip() public method

public Skip ( int numBytes ) : void
numBytes int
return void
Example #1
0
        public static Region Parse(byte[] data)
        {
            Region region = new Region();

            using (ByteStream bs = new ByteStream(data))
            {
                bs.Skip(4);
                int Count = bs.ReadInt32();
                for (int i = 0; i < Count; i++)
                {
                    region.Add(new Data
                    {
                        Left         = bs.ReadSingle(),
                        Right        = bs.ReadSingle(),
                        Bottom       = bs.ReadSingle(),
                        Top          = bs.ReadSingle(),
                        Name         = bs.ReadString(),
                        Index        = bs.ReadInt32(),
                        Roll         = bs.ReadBytes(4),
                        AmbientSound = bs.ReadString(),
                        Color        = bs.ReadBytes(3)
                    });
                    bs.Skip(1);
                }
            }
            return(region);
        }
Example #2
0
        public static Camera Parse(byte[] data)
        {
            Camera cam = new Camera();

            using (ByteStream bs = new ByteStream(data))
            {
                bs.Skip(4);
                int Count = bs.ReadInt32();
                for (int i = 0; i < Count; i++)
                {
                    cam.Add(new Data
                    {
                        TargetX       = bs.ReadSingle(),
                        TargetY       = bs.ReadSingle(),
                        ZOffset       = bs.ReadSingle(),
                        Rotation      = bs.ReadSingle(),
                        AngleOfAttack = bs.ReadSingle(),
                        Distance      = bs.ReadSingle(),
                        Roll          = bs.ReadSingle(),
                        FieldOfView   = bs.ReadSingle(),
                        FarClipping   = bs.ReadSingle(),
                        Unknown       = bs.ReadSingle(),
                        CinematicName = bs.ReadString()
                    });
                }
            }
            return(cam);
        }
Example #3
0
 public void Parse(byte[] value)
 {
     using (ByteStream bs = new ByteStream(value))
     {
         bs.Skip(8);
         Name    = bs.ReadString();
         Flags   = bs.ReadInt32();
         Players = bs.ReadInt32();
     }
     //List<byte> buffer = new List<byte>();
     //int index = 8;
     //while (value[index] != 0x00)
     //    buffer.Add(value[index++]);
     //Name = Encoding.UTF8.GetString(buffer.ToArray());
     //Flags = BitConverter.ToInt32(value, ++index);
     //Players = BitConverter.ToInt32(value, index + 4);
 }
Example #4
0
    void ExtractMIDI(ByteStream stream)
    {
        if (stream.ReadString(4) != "MIDI") {
            throw new InvalidDataException("Not a GMD file!");
        }
        stream.Skip(4);

        string type;
        while ((type = GetChunkType(stream)) != null) {
            if (type == "MThd") {
                long size = stream.Length - stream.Position;
                _midiData = stream.Read((int)size);
                return;
            }

            if (!SkipChunk(stream)) {
                break;
            }
        }

        throw new InvalidDataException("Could not locate midi track header!");
    }
Example #5
0
        public static Sound Parse(byte[] data)
        {
            Sound snd = new Sound();

            using (ByteStream bs = new ByteStream(data))
            {
                bs.Skip(4);
                int Count = bs.ReadInt32();
                for (int i = 0; i < Count; i++)
                {
                    snd.Add(new Data
                    {
                        VariableName            = bs.ReadString(),
                        FilePath                = bs.ReadString(),
                        EAXEffect               = bs.ReadString(),
                        Flags                   = (Flag)bs.ReadInt32(),
                        FadeInRate              = bs.ReadInt32(),
                        FadeOutRate             = bs.ReadInt32(),
                        Volume                  = bs.ReadInt32(),
                        Pitch                   = bs.ReadSingle(),
                        Unknown1                = bs.ReadSingle(),
                        Unknown2                = bs.ReadInt32(),
                        Channel                 = (Channels)bs.ReadInt32(),
                        MinDistance             = bs.ReadSingle(),
                        MaxDistance             = bs.ReadSingle(),
                        DistanceCutOff          = bs.ReadSingle(),
                        ConeAnglesInside        = bs.ReadSingle(),
                        ConeAnglesOutside       = bs.ReadSingle(),
                        ConeAnglesOutsizeVolume = bs.ReadInt32(),
                        ConeOrientationX        = bs.ReadSingle(),
                        ConeOrientationY        = bs.ReadSingle(),
                        ConeOrientationZ        = bs.ReadSingle()
                    });
                }
            }
            return(snd);
        }
Example #6
0
        //public List<RandomUnitTable> RandomUnitTableList = new List<RandomUnitTable>();
        //public sealed class RandomUnitTable : List<RandomUnitTable.Group>
        //{
        //    public sealed class Group
        //    {
        //        public int Number;
        //        public string Name;


        //    }
        //}

        public static W3Info Parse(byte[] data)
        {
            W3Info w3i = new W3Info();

            if (data == null)
            {
                return(w3i);
            }
            using (ByteStream bs = new ByteStream(data))
            {
                bs.Skip(4);
                w3i.SaveCount          = bs.ReadInt32();
                w3i.EditorVersion      = bs.ReadInt32();
                w3i.MapName            = bs.ReadString();
                w3i.MapAuthor          = bs.ReadString();
                w3i.MapDescription     = bs.ReadString();
                w3i.PlayersRecommended = bs.ReadString();
                for (int i = 0; i < w3i.CameraBounds.Length; i++)
                {
                    w3i.CameraBounds[i] = bs.ReadSingle();
                }
                for (int i = 0; i < w3i.CameraBoundsComplements.Length; i++)
                {
                    w3i.CameraBoundsComplements[i] = bs.ReadInt32();
                }
                w3i.MapPlayableAreaWidth  = bs.ReadInt32();
                w3i.MapPlayableAreaHeight = bs.ReadInt32();
                w3i.Flags                    = bs.ReadInt32();
                w3i.MapMainGroundType        = bs.ReadByte();
                w3i.LoadingScreenPresetIndex = bs.ReadInt32();
                w3i.LoadingScreenModelPath   = bs.ReadString();
                w3i.MapLoadingScreenText     = bs.ReadString();
                w3i.MapLoadingScreenTitle    = bs.ReadString();
                w3i.MapLoadingScreenSubtitle = bs.ReadString();
                w3i.UsedGameDataSet          = bs.ReadInt32();
                w3i.PrologueScreenPath       = bs.ReadString();
                w3i.PrologueScreenText       = bs.ReadString();
                w3i.PrologueScreenTitle      = bs.ReadString();
                w3i.PrologueScreenSubtitle   = bs.ReadString();
                w3i.UsesTerrainFog           = bs.ReadInt32();
                w3i.FogStartZHeight          = bs.ReadSingle();
                w3i.FogEndZHeight            = bs.ReadSingle();
                w3i.FogDensity               = bs.ReadSingle();
                w3i.FogRed                   = bs.ReadByte();
                w3i.FogGreen                 = bs.ReadByte();
                w3i.FogBlue                  = bs.ReadByte();
                w3i.FogAlpha                 = bs.ReadByte();
                w3i.GlobalWeatherID          = bs.ReadInt32();
                w3i.CustomSoundEnvironment   = bs.ReadString();
                w3i.TilesetID                = bs.ReadByte();
                w3i.CustomWaterTintingRed    = bs.ReadByte();
                w3i.CustomWaterTintingGreen  = bs.ReadByte();
                w3i.CustomWaterTintingBlue   = bs.ReadByte();
                w3i.CustomWaterTintingAlpha  = bs.ReadByte();
                int LoopCount = bs.ReadInt32();
                for (int i = 0; i < LoopCount; i++)
                {
                    Player p = new Player();
                    p.InternalNumber = bs.ReadInt32();
                    p.Type           = bs.ReadInt32();
                    p.Race           = bs.ReadInt32();
                    bs.Skip(4);
                    p.Name                    = bs.ReadString();
                    p.StartCoordX             = bs.ReadSingle();
                    p.StartCoordY             = bs.ReadSingle();
                    p.AllyLowPrioritiesFlags  = bs.ReadInt32();
                    p.AllyHighPrioritiesFlags = bs.ReadInt32();
                    w3i.PlayerList.Add(p);
                }
                LoopCount = bs.ReadInt32();
                for (int i = 0; i < LoopCount; i++)
                {
                    Force f = new Force
                    {
                        Flags       = bs.ReadInt32(),
                        PlayerMasks = bs.ReadInt32(),
                        Name        = bs.ReadString()
                    };
                    w3i.ForceList.Add(f);
                }
                LoopCount = bs.ReadInt32();
                for (int i = 0; i < LoopCount; i++)
                {
                    UpgradeChange uc = new UpgradeChange
                    {
                        PlayerFlags  = bs.ReadInt32(),
                        ID           = bs.ReadInt32().ReverseByte(),
                        LimitLevel   = bs.ReadInt32(),
                        Availability = bs.ReadInt32()
                    };
                    w3i.UpgradeChangeList.Add(uc);
                }
                LoopCount = bs.ReadInt32();
                for (int i = 0; i < LoopCount; i++)
                {
                    TechChange tc = new TechChange
                    {
                        PlayerFlags = bs.ReadInt32(),
                        ID          = bs.ReadInt32().ReverseByte()
                    };
                    w3i.TechChangeList.Add(tc);
                }
                w3i.RandomThingsData = data.SubArray((int)bs.Position);
            }
            return(w3i);
        }
Example #7
0
    public static BM.Frame ReadHeader1(ByteStream stream, BM.CreateArgs createArgs, out FMEHeader header)
    {
        header = new FMEHeader();
        header.Shift = new Vector2();
        header.Shift.x = (float)stream.ReadLittleInt32();
        header.Shift.y = (float)stream.ReadLittleInt32();
        header.Flipped = stream.ReadLittleInt32() != 0;

        int header2Ofs = stream.ReadLittleInt32();
        stream.Skip(16 + (header2Ofs-32));

        return ReadHeader2(stream, createArgs);
    }
Example #8
0
    public static BM.Frame ReadHeader2(ByteStream stream, BM.CreateArgs createArgs)
    {
        int headerStart = (int)stream.Position;

        BM.Header header = new BM.Header();
        header.W = stream.ReadLittleInt32();
        header.H = stream.ReadLittleInt32();
        header.Compressed = stream.ReadLittleInt32();
        header.DataSize = stream.ReadLittleInt32();
        header.Transparent = 0x8;

        stream.Skip(8);

        int[] columnOffsets = null;

        if (header.Compressed != 0) {
            header.Compressed = 2;

            columnOffsets = new int[header.W];

            for (int i = 0; i < columnOffsets.Length; ++i) {
                columnOffsets[i] = stream.ReadLittleInt32() + headerStart;
            }
        }

        return BM.ReadColumns(stream, header, columnOffsets, createArgs);
    }
Example #9
0
    private Header ReadHeader(ByteStream stream, EHeaderType headerType)
    {
        Header header = new Header();

        if (headerType == EHeaderType.FileHeader) {
            header.W = stream.ReadLittleShort16();
            header.H = stream.ReadLittleShort16();
            stream.Skip(2);
            header.IY = stream.ReadLittleShort16();
            header.Transparent = stream.ReadByte();
            stream.Skip(1);
            header.Compressed = stream.ReadLittleShort16();
            header.DataSize = stream.ReadLittleInt32();
            stream.Skip(12);
        } else {
            header.W = stream.ReadLittleShort16();
            header.H = stream.ReadLittleShort16();
            stream.Skip(20);
            header.Transparent = stream.ReadByte();
            stream.Skip(3);
        }

        return header;
    }
Example #10
0
    private void ParseBitmap(ByteStream stream, CreateArgs createArgs)
    {
        if ((stream.ReadString(3) != "BM ") || (stream.ReadByte() != 0x1e)){
            throw new InvalidDataException("Not a BM file.");
        }

        Header header = ReadHeader(stream, EHeaderType.FileHeader);
        DebugCheck.Assert(stream.Position == 32);

        if ((header.W == 1) && (header.H != 1)) {
            // multiple bitmaps in this file.
            _fps = stream.ReadByte();
            stream.Skip(1);

            long baseOfs = stream.Position;

            int[] offsets = new int[header.IY];
            for (int i = 0; i < offsets.Length; ++i) {
                offsets[i] = stream.ReadLittleInt32();
            }

            for (int i = 0; i < offsets.Length; ++i) {
                stream.SeekSet(offsets[i] + baseOfs);
                Header subHeader = ReadHeader(stream, EHeaderType.SubHeader);
                Frame frame = ReadColumns(stream, subHeader, null, createArgs);
                _frames.Add(frame);
            }
        } else {
            int[] columnOffsets = null;

            if (header.Compressed != 0) {
                // read column offsets.
                stream.SeekSet(header.DataSize);
                columnOffsets = new int[header.W];

                for (int i = 0; i < columnOffsets.Length; ++i) {
                    columnOffsets[i] = stream.ReadLittleInt32() + 32;
                }
            }

            Frame frame = ReadColumns(stream, header, columnOffsets, createArgs);
            _frames.Add(frame);
        }
    }
Example #11
0
        public static UnitsDoo Parse(byte[] data)
        {
            UnitsDoo doo = new UnitsDoo();

            using (ByteStream bs = new ByteStream(data))
            {
                bs.Skip(0xC);
                int Count = bs.ReadInt32();
                for (int i = 0; i < Count; i++)
                {
                    Data d = new Data();
                    d.TypeID       = bs.ReadInt32().ReverseByte();
                    d.variation    = bs.ReadInt32();
                    d.CoordX       = bs.ReadSingle();
                    d.CoordY       = bs.ReadSingle();
                    d.CoordZ       = bs.ReadSingle();
                    d.RotateAngle  = bs.ReadSingle();
                    d.ScaleX       = bs.ReadSingle();
                    d.ScaleY       = bs.ReadSingle();
                    d.ScaleZ       = bs.ReadSingle();
                    d.flags        = bs.ReadByte();
                    d.PlayerNumber = bs.ReadInt32();
                    bs.Skip(2);
                    d.HitPoint         = bs.ReadInt32();
                    d.ManaPoint        = bs.ReadInt32();
                    d.ItemTablePointer = bs.ReadInt32();
                    int LoopCount = bs.ReadInt32();
                    for (int j = 0; j < LoopCount; j++)
                    {
                        if (d.DropItemSet == null)
                        {
                            d.DropItemSet = new List <List <Data.DropItem> >();
                        }
                        int ItemTableCount             = bs.ReadInt32();
                        List <Data.DropItem> ItemTable = null;
                        for (int k = 0; k < ItemTableCount; k++)
                        {
                            if (ItemTable == null)
                            {
                                ItemTable = new List <Data.DropItem>();
                            }
                            ItemTable.Add(new Data.DropItem
                            {
                                ID     = bs.ReadInt32().ReverseByte(),
                                Chance = bs.ReadInt32()
                            });
                        }
                        if (ItemTable != null)
                        {
                            d.DropItemSet.Add(ItemTable);
                        }
                    }
                    d.Gold    = bs.ReadInt32();
                    d.Target  = bs.ReadInt32();
                    d.Level   = bs.ReadInt32();
                    d.STR     = bs.ReadInt32();
                    d.AGI     = bs.ReadInt32();
                    d.INT     = bs.ReadInt32();
                    LoopCount = bs.ReadInt32();
                    for (int j = 0; j < LoopCount; j++)
                    {
                        if (d.InvItems == null)
                        {
                            d.InvItems = new List <Data.InvItem>();
                        }
                        d.InvItems.Add(new Data.InvItem
                        {
                            Slot = bs.ReadInt32(),
                            ID   = bs.ReadInt32().ReverseByte()
                        });
                    }
                    LoopCount = bs.ReadInt32();
                    for (int j = 0; j < LoopCount; j++)
                    {
                        if (d.ModAbils == null)
                        {
                            d.ModAbils = new List <Data.ModAbil>();
                        }
                        d.ModAbils.Add(new Data.ModAbil
                        {
                            ID         = bs.ReadInt32().ReverseByte(),
                            IsAutoCast = bs.ReadInt32(),
                            Level      = bs.ReadInt32()
                        });
                    }
                    d.RandomFlag = bs.ReadInt32();
                    switch (d.RandomFlag)
                    {
                    case 0:
                        d.LevRandom = bs.ReadBytes(3);
                        d.ItemClass = bs.ReadByte();
                        break;

                    case 1:
                        d.UnitGroup = bs.ReadInt32();
                        d.PosNumber = bs.ReadInt32();
                        break;

                    case 2:
                        LoopCount = bs.ReadInt32();
                        for (int j = 0; j < LoopCount; j++)
                        {
                            if (d.RandomUnits == null)
                            {
                                d.RandomUnits = new List <Data.RandomUnit>();
                            }
                            d.RandomUnits.Add(new Data.RandomUnit
                            {
                                ID     = bs.ReadInt32().ReverseByte(),
                                Chance = bs.ReadInt32()
                            });
                        }
                        break;
                    }
                    d.CustomColor    = bs.ReadInt32();
                    d.WayGate        = bs.ReadInt32();
                    d.CreationNumber = bs.ReadInt32();
                    doo.Add(d);
                }
            }
            return(doo);
        }
Example #12
0
        public static Doodad Parse(byte[] data)
        {
            Doodad doo = new Doodad();

            using (ByteStream bs = new ByteStream(data))
            {
                bs.Skip(0xC);
                int Count = bs.ReadInt32();
                for (int i = 0; i < Count; i++)
                {
                    Data d = new Data();
                    d.TypeID           = bs.ReadInt32().ReverseByte();
                    d.variation        = bs.ReadInt32();
                    d.CoordX           = bs.ReadSingle();
                    d.CoordY           = bs.ReadSingle();
                    d.CoordZ           = bs.ReadSingle();
                    d.RotateAngle      = bs.ReadSingle();
                    d.ScaleX           = bs.ReadSingle();
                    d.ScaleY           = bs.ReadSingle();
                    d.ScaleZ           = bs.ReadSingle();
                    d.flags            = bs.ReadByte();
                    d.Life             = bs.ReadByte();
                    d.ItemTablePointer = bs.ReadInt32();
                    int LoopCount = bs.ReadInt32();
                    for (int j = 0; j < LoopCount; j++)
                    {
                        if (d.DropItemSet == null)
                        {
                            d.DropItemSet = new List <List <Data.DropItem> >();
                        }
                        int ItemTableCount             = bs.ReadInt32();
                        List <Data.DropItem> ItemTable = null;
                        for (int k = 0; k < ItemTableCount; k++)
                        {
                            if (ItemTable == null)
                            {
                                ItemTable = new List <Data.DropItem>();
                            }
                            ItemTable.Add(new Data.DropItem
                            {
                                ID     = bs.ReadInt32().ReverseByte(),
                                Chance = bs.ReadInt32()
                            });
                        }
                        if (ItemTable != null)
                        {
                            d.DropItemSet.Add(ItemTable);
                        }
                    }
                    d.CreationNumber = bs.ReadInt32();
                    doo.Add(d);
                }
                bs.Skip(4);
                Count = bs.ReadInt32();
                for (int i = 0; i < Count; i++)
                {
                    doo.Specials.Add(new Special
                    {
                        TypeID = bs.ReadInt32().ReverseByte(),
                        Z      = bs.ReadInt32(),
                        X      = bs.ReadInt32(),
                        Y      = bs.ReadInt32()
                    });
                }
            }
            return(doo);
        }
Example #13
0
 bool SkipChunk(ByteStream stream)
 {
     stream.Skip(4);
     int length = stream.ReadBigInt32();
     stream.Skip(length);
     return !stream.EOS;
 }