Example #1
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();
                }
            }
        }
        public static RpcSetStartCounter Deserialize(HazelBinaryReader reader)
        {
            var msg = new RpcSetStartCounter();

            msg.b1          = reader.ReadByte();
            msg.secondsLeft = reader.ReadByte();

            return(msg);
        }
Example #3
0
        public static RpcSendChatNote Deserialize(HazelBinaryReader reader)
        {
            var msg = new RpcSendChatNote();

            msg.b1 = reader.ReadByte();
            msg.b2 = reader.ReadByte();

            return(msg);
        }
Example #4
0
        public static GameOptionsData Deserialize(HazelBinaryReader reader)
        {
            var result = new GameOptionsData();

            result.Version              = reader.ReadByte();
            result.MaxPlayers           = reader.ReadByte();
            result.Keywords             = (GameKeywords)reader.ReadUInt32();
            result.MapId                = (Map)reader.ReadByte();
            result.PlayerSpeedMod       = reader.ReadSingle();
            result.CrewLightMod         = reader.ReadSingle();
            result.ImpostorLightMod     = reader.ReadSingle();
            result.KillCooldown         = reader.ReadSingle();
            result.NumCommonTasks       = reader.ReadByte();
            result.NumLongTasks         = reader.ReadByte();
            result.NumShortTasks        = reader.ReadByte();
            result.NumEmergencyMeetings = reader.ReadInt32();
            result.NumImpostors         = reader.ReadByte();
            result.KillDistance         = reader.ReadByte();
            result.DiscussionTime       = reader.ReadInt32();
            result.VotingTime           = reader.ReadInt32();
            result.IsDefaults           = reader.ReadBoolean();

            if (result.Version > 1)
            {
                result.EmergencyCooldown = reader.ReadByte();
            }

            if (result.Version > 2)
            {
                result.ConfirmImpostor = reader.ReadBoolean();
                result.VisualTasks     = reader.ReadBoolean();
            }

            return(result);
        }
Example #5
0
        public static EndGame Deserialize(HazelBinaryReader reader)
        {
            var msg = new EndGame();

            var b1 = reader.ReadByte();
            var b2 = reader.ReadByte();

            msg.gameId = reader.ReadInt32();

            return(msg);
        }
Example #6
0
        public static RemovePlayerResponse Deserialize(HazelBinaryReader reader)
        {
            var msg = new RemovePlayerResponse();

            msg.gameCode = reader.ReadInt32();
            msg.playerId = reader.ReadPackedInt32();
            msg.hostId   = reader.ReadInt32();
            msg.reason   = (DisconnectReason)reader.ReadByte();
            msg.unknown  = reader.ReadByte();
            //msg.unknown2 = reader.ReadByte();
            return(msg);
        }
Example #7
0
 public void Deserialize(HazelBinaryReader reader)
 {
     PlayerName = reader.ReadString();
     ColorId    = reader.ReadByte();
     HatId      = (Hat)reader.ReadPackedUInt32();
     SkinId     = (Skin)reader.ReadPackedUInt32();
     Flags      = (PlayerInfoFlags)reader.ReadByte();
     Tasks      = reader.ReadList(read => {
         var task = new TaskInfo();
         task.Deserialize(read);
         return(task);
     });
     unknown = reader.ReadByte();
 }
Example #8
0
 public override void Deserialize(HazelBinaryReader reader, bool onSpawn)
 {
     if (onSpawn)
     {
         Console.WriteLine("PlayerControl ######");
         bool isNew = reader.ReadBoolean();
         playerId = reader.ReadByte();
         Console.WriteLine("isNew: " + isNew);
         Console.WriteLine("playerid: " + playerId);
         return;
     }
     playerId = reader.ReadByte();
     Console.WriteLine("playerid: " + playerId);
 }
            public static GameListItem Deserialize(HazelBinaryReader reader)
            {
                var msg = new GameListItem();

                msg.adress     = reader.ReadInt32();
                msg.port       = reader.ReadUInt16();
                msg.code       = reader.ReadInt32();
                msg.name       = reader.ReadString();
                msg.players    = reader.ReadByte();
                msg.age        = reader.ReadPackedInt32();
                msg.mapid      = reader.ReadByte();
                msg.imposters  = reader.ReadByte();
                msg.maxplayers = reader.ReadByte();
                return(msg);
            }
Example #10
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);
        }
Example #11
0
        public static RpcCloseDoorsOfType Deserialize(HazelBinaryReader reader)
        {
            var msg = new RpcCloseDoorsOfType();

            msg.type = (SystemTypes)reader.ReadByte();

            return(msg);
        }
Example #12
0
        public static RpcStartMeeting Deserialize(HazelBinaryReader reader)
        {
            var msg = new RpcStartMeeting();

            msg.playerId = reader.ReadByte();

            return(msg);
        }
Example #13
0
        public static CmdReportDeadBody Deserialize(HazelBinaryReader reader)
        {
            var msg = new CmdReportDeadBody();

            msg.playerId = reader.ReadByte();

            return(msg);
        }
Example #14
0
        public static RpcPlayAnimation Deserialize(HazelBinaryReader reader)
        {
            var msg = new RpcPlayAnimation();

            msg.animType = reader.ReadByte();

            return(msg);
        }
Example #15
0
        public static CmdCheckColor Deserialize(HazelBinaryReader reader)
        {
            var msg = new CmdCheckColor();

            msg.bodyColor = reader.ReadByte();

            return(msg);
        }
Example #16
0
        public static JoinGameRequest Deserialize(HazelBinaryReader reader)
        {
            var msg = new JoinGameRequest();

            msg.gameCode = reader.ReadInt32();
            msg.unknown  = reader.ReadByte();
            return(msg);
        }
Example #17
0
        public static AlterGameRequest Deserialize(HazelBinaryReader reader)
        {
            var msg = new AlterGameRequest();

            msg.gameTag = (AlterGameTags)reader.ReadByte();
            msg.value   = reader.ReadBoolean();
            return(msg);
        }
Example #18
0
        public static RpcSetColor Deserialize(HazelBinaryReader reader)
        {
            var msg = new RpcSetColor();

            msg.color = reader.ReadByte();

            return(msg);
        }
Example #19
0
        public static CmdCastVote Deserialize(HazelBinaryReader reader)
        {
            var msg = new CmdCastVote();

            msg.playerId   = reader.ReadByte();
            msg.suspectIdx = reader.ReadSByte();

            return(msg);
        }
Example #20
0
        public static RpcSetScanner Deserialize(HazelBinaryReader reader)
        {
            var msg = new RpcSetScanner();

            msg.value = reader.ReadBoolean();
            msg.b2    = reader.ReadByte();

            return(msg);
        }
Example #21
0
        public static RpcSetTasks Deserialize(HazelBinaryReader reader)
        {
            var msg = new RpcSetTasks();

            msg.playerId    = reader.ReadByte();
            msg.taskTypeIds = reader.ReadBytesAndSize();

            return(msg);
        }
Example #22
0
        public static RpcCall Deserialize(HazelBinaryReader reader)
        {
            var msg = new RpcCall();

            msg.targetNetId = reader.ReadPackedInt32();
            msg.callId      = (RpcCalls)reader.ReadByte();

            return(msg);
        }
Example #23
0
        public static RpcEndGame Deserialize(HazelBinaryReader reader)
        {
            var msg = new RpcEndGame();

            msg.endReason = (GameOverReason)reader.ReadByte();
            msg.showAd    = reader.ReadBoolean();

            return(msg);
        }
Example #24
0
        public static RpcVotingComplete Deserialize(HazelBinaryReader reader)
        {
            var msg = new RpcVotingComplete();

            msg.states         = reader.ReadBytesAndSize();
            msg.exiledPlayerId = reader.ReadByte();
            msg.tie            = reader.ReadBoolean();

            return(msg);
        }
Example #25
0
        public static HelloHandshake Deserialize(HazelBinaryReader reader)
        {
            var msg = new HelloHandshake();

            msg.Nonce         = reader.ReadUInt16();
            msg.Version       = reader.ReadByte();
            msg.ClientVersion = reader.ReadInt32();
            msg.Name          = reader.ReadString();

            return(msg);
        }
Example #26
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()}");
         }
     }
 }
Example #27
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);
        }
Example #28
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);
        }
Example #29
0
        public static ReselectServer Deserialize(HazelBinaryReader reader)
        {
            var msg = new ReselectServer();

            var u1 = reader.ReadByte();

            msg.servers = reader.ReadMessageList((read, id) =>
            {
                var server     = new Server();
                server.name    = read.ReadString();
                server.ip      = read.ReadBytes(4);
                server.port    = read.ReadUInt16();
                server.unknown = read.ReadBytes(2);
                return(server);
            });

            return(msg);
        }
        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);
        }