コード例 #1
0
ファイル: UpdateReader.cs プロジェクト: Reve/eveDestiny
        private static Ball ReadBallFromStream(Stream str)
        {
            var ret = new Ball {Header = str.ReadStruct<BallHeader>()};

            if (ret.Header.Mode != BallMode.Rigid)
                ret.ExtraHeader = str.ReadStruct<ExtraBallHeader>();

            if (ret.Header.Flags.HasFlag(BallFlag.IsFree))
                ret.Data = str.ReadStruct<BallData>();

            var reader = new BinaryReader(str);
            ret.FormationId = reader.ReadByte();

            switch (ret.Header.Mode)
            {
                case BallMode.Follow:
                case BallMode.Orbit:
                        ret.FollowState = str.ReadStruct<FollowState>();
                        break;

                case BallMode.Formation:
                        ret.FormationState = str.ReadStruct<FormationState>();
                        break;

                case BallMode.Troll:
                        ret.TrollState = str.ReadStruct<TrollState>();
                        break;

                case BallMode.Missile:
                        ret.MissileState = str.ReadStruct<MissileState>();
                        break;

                case BallMode.Goto:
                        ret.GotoState = str.ReadStruct<GotoState>();
                        break;

                case BallMode.Warp:
                        ret.WarpState = str.ReadStruct<WarpState>();
                        break;

                case BallMode.Mushroom:
                        ret.MushroomState = str.ReadStruct<MushroomState>();
                        break;

                case BallMode.Stop:
                case BallMode.Field:
                case BallMode.Rigid:
                        // no extra data for these
                        break;
            }

            if (ret.Header.Flags.HasFlag(BallFlag.HasMiniBalls))
                ret.MiniBalls = ReadMiniBalls(reader);
            ret.Name = ReadString(reader);

            return ret;
        }
コード例 #2
0
ファイル: Pmf.cs プロジェクト: soywiz/cspspemu
 public Chunk ReadChunk(Stream Stream)
 {
     var ChunkSize = (uint)Stream.ReadStruct<uint_be>();
     //var ChunkType = (ushort)Stream.ReadStruct<ushort_be>();
     var ChunkStream = Stream.ReadStream(ChunkSize);
     return new Chunk()
     {
         Size = ChunkSize,
         //Type = ChunkType,
         Stream = ChunkStream,
     };
 }
コード例 #3
0
ファイル: Pmf.cs プロジェクト: soywiz/cspspemu
        public Pmf Load(Stream Stream)
        {
            this.Stream = Stream;
            Header = Stream.ReadStruct<HeaderStruct>();

            var Chunk = ReadChunk(Stream.SliceWithLength(0x50));
            InfoHeader = Chunk.Stream.ReadStruct<InfoHeaderStruct>();
            /*
            Console.WriteLine("0x{0:X}", (ulong)InfoHeader.FirstTimestamp);
            Console.WriteLine("0x{0:X}", (ulong)InfoHeader.LastTimestamp);
            Console.WriteLine("{0}", (ulong)InfoHeader.Width);
            Console.WriteLine("{0}", (ulong)InfoHeader.Height);
            */

            return this;
        }
コード例 #4
0
ファイル: UpdateReader.cs プロジェクト: Reve/eveDestiny
 private void ReadHeader(Stream str)
 {
     Header = str.ReadStruct<Header>();
     if (Header.PacketType != 0 && Header.PacketType != 1)
         throw new InvalidDataException("Unknown packet type; expected 0 or 1, got " + Header.PacketType);
 }
コード例 #5
0
ファイル: UpdateReader.cs プロジェクト: Reve/EVESharp
        private static Ball ReadBallFromStream(Stream str)
        {
            var ret = new Ball {Header = str.ReadStruct<BallHeader>()};

            if (ret.Header.Mode != BallMode.Rigid)
                ret.ExtraHeader = str.ReadStruct<ExtraBallHeader>();

            if (ret.Header.Flags.HasFlag(BallFlag.IsFree))
                ret.Data = str.ReadStruct<BallData>();

            var reader = new BinaryReader(str);
            ret.FormationId = reader.ReadByte();

            switch (ret.Header.Mode)
            {
                case BallMode.Follow:
                case BallMode.Orbit:
                        ret.FollowState = str.ReadStruct<FollowState>();
                        break;

                case BallMode.Formation:
                        ret.FormationState = str.ReadStruct<FormationState>();
                        break;

                case BallMode.Troll:
                        ret.TrollState = str.ReadStruct<TrollState>();
                        break;

                case BallMode.Missile:
                        ret.MissileState = str.ReadStruct<MissileState>();
                        break;

                case BallMode.Goto:
                        ret.GotoState = str.ReadStruct<GotoState>();
                        break;

                case BallMode.Warp:
                        ret.WarpState = str.ReadStruct<WarpState>();
                        break;

                case BallMode.Mushroom:
                        ret.MushroomState = str.ReadStruct<MushroomState>();
                        break;

                case BallMode.Stop:
                case BallMode.Field:
                case BallMode.Rigid:
                        // no extra data for these
                        break;
            }

            if (ret.Header.Flags.HasFlag(BallFlag.HasMiniBalls))
                ret.MiniBalls = ReadMiniBalls(reader);

            // Crucible:
            // no more names in destiny data
            // most of them were invalid anyway, and slimitems have the name, so sensible change for CCP
            //ret.Name = ReadString(reader);

            return ret;
        }