Ejemplo n.º 1
0
        public static List <RpcUpdateGameData> Deserialize(HazelBinaryReader reader)
        {
            var items = new List <RpcUpdateGameData>();

            while (reader.HasBytesLeft())
            {
                var msg    = new RpcUpdateGameData();
                var length = reader.ReadInt16();
                var body   = new HazelBinaryReader(reader.ReadBytes(length));
                reader.ReadByte();

                msg.playerId = body.ReadByte();
                msg.name     = body.ReadString();

                msg.color   = body.ReadByte();
                msg.hat     = (Hat)body.ReadByte();
                msg.pet     = (Pet)body.ReadByte();
                msg.skin    = (Skin)body.ReadByte();
                msg.unknown = body.ReadByte();

                items.Add(msg);
            }

            return(items);
        }
Ejemplo n.º 2
0
        public static Redirect Deserialize(HazelBinaryReader reader)
        {
            var msg = new Redirect();

            msg.adress = reader.ReadBytes(4);
            msg.port   = reader.ReadUInt16();
            return(msg);
        }
Ejemplo n.º 3
0
        public static List <GameData> Deserialize(HazelBinaryReader reader)
        {
            var gameId    = reader.ReadInt32();
            var gamedatas = new List <GameData>();

            while (reader.HasBytesLeft())
            {
                var msg = new GameData();
                msg.gameId = gameId;
                var size = reader.ReadInt16();
                msg.type = reader.ReadByte();
                msg.body = reader.ReadBytes(size);
                gamedatas.Add(msg);
            }

            return(gamedatas);
        }
Ejemplo n.º 4
0
        public static GetGameListV2Response Deserialize(HazelBinaryReader reader)
        {
            var msg = new GetGameListV2Response();

            var size = reader.ReadInt16();
            var type = reader.ReadByte();
            var body = new HazelBinaryReader(reader.ReadBytes(size));

            msg.games = new List <GameListItem>();

            while (body.HasBytesLeft())
            {
                var itemsize   = body.ReadInt16();
                var itemtype   = body.ReadByte();
                var itemBody   = body.ReadBytes(itemsize);
                var itemreader = new HazelBinaryReader(itemBody);

                msg.games.Add(GameListItem.Deserialize(itemreader));
            }

            return(msg);
        }
Ejemplo n.º 5
0
        public static Spawn Deserialize(HazelBinaryReader reader)
        {
            var msg = new Spawn();

            msg.spawnId = reader.ReadPackedInt32();
            msg.ownerId = reader.ReadPackedInt32();
            msg.flags   = (SpawnFlags)reader.ReadByte();

            msg.children = reader.ReadList(read =>
            {
                var netId = reader.ReadPackedInt32();
                var size  = reader.ReadInt16();
                var type  = reader.ReadByte();
                var body  = reader.ReadBytes(size);

                return(new SpawnChild()
                {
                    netId = netId,
                    body = body,
                });
            });

            return(msg);
        }
Ejemplo n.º 6
0
        private static List <byte[]> GetMessages(MemoryStream stream)
        {
            var buffers = new List <byte[]>();

            HazelBinaryReader reader = new HazelBinaryReader(stream);

            var header = reader.ReadByte();

            if (header == (byte)UdpSendOption.Acknowledgement ||
                header == (byte)UdpSendOption.Ping ||
                header == (byte)UdpSendOption.Disconnect)
            {
                return(buffers);
            }

            if (header == (byte)UdpSendOption.Hello)
            {
                Console.WriteLine("Recived Hello");
                var hello = HelloHandshake.Deserialize(reader);
                DumpToConsole(hello);
                return(buffers);
            }
            if (header == (byte)SendOption.Reliable)
            {
                var ack = reader.ReadInt16();
            }

            while (reader.HasBytesLeft())
            {
                int length = reader.ReadInt16();
                var data   = reader.ReadBytes(length + 1);
                buffers.Add(data);
            }

            return(buffers);
        }