Exemplo 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);
        }
Exemplo n.º 2
0
        public override void Deserialize(HazelBinaryReader reader, bool onSpawn)
        {
            if (onSpawn)
            {
                Console.WriteLine("Meetinghud spawn");
                for (int i = 0; i < 10; i++)//need to fix this here, packet only contains the amount of players in the server
                {
                    while (reader.HasBytesLeft())
                    {
                        playerStates.Add(new PlayerVoteArea()
                        {
                            value = (PlayerVoteAreaFlags)reader.ReadByte(),
                        });
                    }
                }
                return;
            }
            Console.WriteLine("Meetinghud data");
            uint updateMask = reader.ReadPackedUInt32();

            for (int j = 0; j < 10; j++)
            {
                if ((updateMask & (1u << j)) != 0u)
                {
                    playerStates[j].value = (PlayerVoteAreaFlags)reader.ReadByte();
                }
            }
        }
Exemplo n.º 3
0
 public void Deserialize(HazelBinaryReader reader, bool onSpawn)
 {
     Countdown = reader.ReadSingle();
     if (reader.HasBytesLeft())
     {
         CompletedConsoles = reader.ReadList(read => reader.ReadPackedInt32());
     }
 }
Exemplo n.º 4
0
 public override void Deserialize(HazelBinaryReader reader, bool onSpawn)
 {
     if (onSpawn)
     {
         //Guid gameGuid = new Guid(reader.ReadBytesAndSize());
         AllPlayers = reader.ReadList(read =>
         {
             var playerInfo = new PlayerInfo(reader.ReadByte());
             playerInfo.Deserialize(reader);
             return(playerInfo);
         });
         if (reader.HasBytesLeft())
         {
             Console.WriteLine($"Unhandled Gamedata deserialize() on spawn size: {reader.GetBytesLeft()}");
         }
         return;
     }
     else
     {
         byte count = reader.ReadByte();
         for (int j = 0; j < count; j++)
         {
             byte       playerId    = reader.ReadByte();
             PlayerInfo playerInfo2 = AllPlayers.FirstOrDefault(p => p.PlayerId == playerId);
             if (playerInfo2 != null)
             {
                 playerInfo2.Deserialize(reader);
             }
             else
             {
                 playerInfo2 = new PlayerInfo(playerId);
                 playerInfo2.Deserialize(reader);
                 AllPlayers.Add(playerInfo2);
             }
         }
         if (reader.HasBytesLeft())
         {
             Console.WriteLine($"Unhandled Gamedata deserialize() size: {reader.GetBytesLeft()}");
         }
     }
 }
Exemplo n.º 5
0
        public override void Deserialize(HazelBinaryReader reader, bool onSpawn)
        {
            if (onSpawn)
            {
                for (int i = 0; i < 24; i++)
                {
                    var system = (SystemTypes)i;
                    if (systems.ContainsKey(system))
                    {
                        var systemObj = systems[system];
                        systemObj.Deserialize(reader, onSpawn);
                    }
                }
                if (reader.HasBytesLeft())
                {
                    Console.WriteLine($"Bytesleft in ShipStatus DeserializeOnSpawn: size: {reader.GetBytesLeft()}");
                }
                return;
            }

            uint systemFlags = reader.ReadPackedUInt32();

            for (int i = 0; i < 24; i++)
            {
                if ((systemFlags & (1 << i)) != 0)
                {
                    var system    = (SystemTypes)i;
                    var systemObj = systems[system];
                    systemObj.Deserialize(reader, onSpawn);
                }
            }
            if (reader.HasBytesLeft())
            {
                Console.WriteLine($"Bytesleft in ShipStatus Deserialize: size: {reader.GetBytesLeft()}");
            }
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
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);
        }