Exemple #1
0
        private void OnPlayerChangeData(HMessage obj)
        {
            try
            {
                #region Some Parsing
                int position = 0;
                obj.ReadInt(ref position);
                obj.ReadString(ref position);
                HGender Gender = SKore.ToGender(obj.ReadString(ref position));
                string  Motto  = obj.ReadString(ref position);
                #endregion

                var args = new PlayerChangeDataEventArgs(obj);
                foreach (PDU PData in _loadedPlayers.Values)
                {
                    if (PData.PlayerIndex == args.PlayerIndex)
                    {
                        PData.Update(Motto, Gender, args.FigureId);
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
Exemple #2
0
        public HEntity(HMessage packet)
        {
            Id       = packet.ReadInteger();
            Name     = packet.ReadString();
            Motto    = packet.ReadString();
            FigureId = packet.ReadString();
            Index    = packet.ReadInteger();

            Tile = new HPoint(packet.ReadInteger(), packet.ReadInteger(),
                              double.Parse(packet.ReadString(), CultureInfo.InvariantCulture));

            packet.ReadInteger();
            int type = packet.ReadInteger();

            switch (type)
            {
            case 1:
            {
                Gender = SKore.ToGender(packet.ReadString());
                packet.ReadInteger();
                packet.ReadInteger();
                FavoriteGroup = packet.ReadString();
                packet.ReadString();
                packet.ReadInteger();
                packet.ReadBoolean();

                break;
            }

            case 2:
            {
                packet.ReadInteger();
                packet.ReadInteger();
                packet.ReadString();
                packet.ReadInteger();
                packet.ReadBoolean();
                packet.ReadBoolean();
                packet.ReadBoolean();
                packet.ReadBoolean();
                packet.ReadBoolean();
                packet.ReadBoolean();
                packet.ReadInteger();
                packet.ReadString();
                break;
            }

            case 4:
            {
                packet.ReadString();
                packet.ReadInteger();
                packet.ReadString();
                for (int j = packet.ReadInteger(); j > 0; j--)
                {
                    packet.ReadShort();
                }
                break;
            }
            }
        }
        public HostChangeClothesEventArgs(HMessage packet)
        {
            _packet = packet;
            Header  = _packet.Header;

            Gender   = SKore.ToGender(_packet.ReadString(0));
            FigureId = _packet.ReadString(3);
        }
 public PlayerUpdateEventArgs(Func <Task> continuation, int step, HMessage packet)
     : base(continuation, step, packet)
 {
     Index    = packet.ReadInteger();
     FigureId = packet.ReadString();
     Gender   = SKore.ToGender(packet.ReadString());
     Motto    = packet.ReadString();
 }
Exemple #5
0
        public PlayerChangeDataEventArgs(HMessage packet)
        {
            _packet = packet;
            Header  = _packet.Header;

            int position = 4;

            PlayerIndex = _packet.ReadInt(0);
            FigureId    = _packet.ReadString(ref position);
            Gender      = SKore.ToGender(_packet.ReadString(position));
            Motto       = _packet.ReadString(position);
        }
Exemple #6
0
        private void IncomingUser(DataInterceptedEventArgs e)
        {
            int entityCount = e.Packet.ReadInteger();
            var entityList  = new List <HEntity>(entityCount);

            for (int i = 0; i < entityList.Capacity; i++)
            {
                int    id       = e.Packet.ReadInteger();
                string name     = e.Packet.ReadString();
                string motto    = e.Packet.ReadString();
                string figureId = e.Packet.ReadString();
                int    index    = e.Packet.ReadInteger();
                int    x        = e.Packet.ReadInteger();
                int    y        = e.Packet.ReadInteger();

                var z = double.Parse(
                    e.Packet.ReadString(), CultureInfo.InvariantCulture);

                e.Packet.ReadInteger();
                int type = e.Packet.ReadInteger();

                HGender gender        = HGender.Unisex;
                string  favoriteGroup = string.Empty;
                #region Switch: type
                switch (type)
                {
                case 1:
                {
                    gender = SKore.ToGender(e.Packet.ReadString());
                    e.Packet.ReadInteger();
                    e.Packet.ReadInteger();
                    favoriteGroup = e.Packet.ReadString();
                    e.Packet.ReadString();
                    e.Packet.ReadInteger();
                    e.Packet.ReadBoolean();

                    break;
                }

                case 2:
                {
                    e.Packet.ReadInteger();
                    e.Packet.ReadInteger();
                    e.Packet.ReadString();
                    e.Packet.ReadInteger();
                    e.Packet.ReadBoolean();
                    e.Packet.ReadBoolean();
                    e.Packet.ReadBoolean();
                    e.Packet.ReadBoolean();
                    e.Packet.ReadBoolean();
                    e.Packet.ReadBoolean();
                    e.Packet.ReadInteger();
                    e.Packet.ReadString();
                    break;
                }

                case 4:
                {
                    e.Packet.ReadString();
                    e.Packet.ReadInteger();
                    e.Packet.ReadString();

                    for (int j = e.Packet.ReadInteger(); j > 0; j--)
                    {
                        e.Packet.ReadShort();
                    }

                    break;
                }
                }
                #endregion

                var entity = new HEntity(id, index, name,
                                         new HPoint(x, y, z), motto, gender, figureId, favoriteGroup);

                entityList.Add(entity);
            }

            foreach (HEntity Player in entityList)
            {
                playerList.Items.Add(Player.Index + "`" + Player.Name + "`" + Player.FigureId + "`" + Player.Gender + "`" + Player.Motto);
            }
        }
Exemple #7
0
 public HostUpdateClothesEventArgs(Func <Task> continuation, int step, HMessage packet)
     : base(continuation, step, packet)
 {
     Gender   = SKore.ToGender(packet.ReadString());
     FigureId = packet.ReadString();
 }
Exemple #8
0
        /// <summary>
        /// Returns a <see cref="IReadOnlyList{T}"/> of type <see cref="HEntity"/> found in the <see cref="HMessage"/>.
        /// </summary>
        /// <param name="packet">The <see cref="HMessage"/> that contains the <see cref="HEntity"/> data to parse.</param>
        /// <returns></returns>
        public static IReadOnlyList <HEntity> Parse(HMessage packet)
        {
            int entityCount = packet.ReadInteger();
            var entityList  = new List <HEntity>(entityCount);

            for (int i = 0; i < entityList.Capacity; i++)
            {
                int    id       = packet.ReadInteger();
                string name     = packet.ReadString();
                string motto    = packet.ReadString();
                string figureId = packet.ReadString();
                int    index    = packet.ReadInteger();
                int    x        = packet.ReadInteger();
                int    y        = packet.ReadInteger();
                double z        = double.Parse(packet.ReadString());

                packet.ReadInteger();
                int type = packet.ReadInteger();

                HGender gender        = HGender.Unknown;
                string  favoriteGroup = string.Empty;
                #region Switch Statement: type
                switch (type)
                {
                case 1:
                {
                    gender = SKore.ToGender(packet.ReadString());
                    packet.ReadInteger();
                    packet.ReadInteger();
                    favoriteGroup = packet.ReadString();
                    packet.ReadString();
                    packet.ReadInteger();
                    packet.ReadBoolean();

                    break;
                }

                case 2:
                {
                    packet.ReadInteger();
                    packet.ReadInteger();
                    packet.ReadString();
                    packet.ReadInteger();
                    packet.ReadBoolean();
                    packet.ReadBoolean();
                    packet.ReadBoolean();
                    packet.ReadBoolean();
                    packet.ReadBoolean();
                    packet.ReadBoolean();
                    packet.ReadInteger();
                    packet.ReadString();
                    break;
                }

                case 4:
                {
                    packet.ReadString();
                    packet.ReadInteger();
                    packet.ReadString();

                    for (int j = packet.ReadInteger(); j > 0; j--)
                    {
                        packet.ReadShort();
                    }

                    break;
                }
                }
                #endregion

                var entity = new HEntity(id, index, name,
                                         new HPoint(x, y, z), motto, gender, figureId, favoriteGroup);

                entityList.Add(entity);
            }

            return(entityList);
        }
Exemple #9
0
        public static IList <IHPlayerData> Extract(HMessage packet)
        {
            int    playerId, playerIndex, playerType, x, y, position = 0;
            string playerName, figureId, motto, gender, groupName, z;
            var    playerDataList = new List <IHPlayerData>(packet.ReadInt(ref position));

            do
            {
                playerId   = playerIndex = playerType = x = y = 0;
                playerName = figureId = motto = gender = groupName = z = string.Empty;

                playerId    = packet.ReadInt(ref position);
                playerName  = packet.ReadString(ref position);
                motto       = packet.ReadString(ref position);
                figureId    = packet.ReadString(ref position);
                playerIndex = packet.ReadInt(ref position);
                x           = packet.ReadInt(ref position);
                y           = packet.ReadInt(ref position);
                z           = packet.ReadString(ref position);
                packet.ReadInt(ref position);
                playerType = packet.ReadInt(ref position);

                if (playerType != 1)
                {
                    playerDataList.Capacity--;
                }

                switch (playerType)
                {
                case 1:
                {
                    gender = packet.ReadString(ref position);
                    packet.ReadInt(ref position);
                    packet.ReadInt(ref position);
                    groupName = packet.ReadString(ref position);
                    packet.ReadString(ref position);
                    packet.ReadInt(ref position);
                    packet.ReadBool(ref position);

                    playerDataList.Add(new HPlayerData(playerName, playerId, playerIndex,
                                                       new HPoint(x, y, z), figureId, motto, SKore.ToGender(gender), groupName));
                    break;
                }

                case 2:
                {
                    packet.ReadInt(ref position);
                    packet.ReadInt(ref position);
                    packet.ReadString(ref position);
                    packet.ReadInt(ref position);
                    packet.ReadBool(ref position);
                    packet.ReadBool(ref position);
                    packet.ReadBool(ref position);
                    packet.ReadBool(ref position);
                    packet.ReadBool(ref position);
                    packet.ReadBool(ref position);
                    packet.ReadInt(ref position);
                    packet.ReadString(ref position);
                    break;
                }

                case 4:
                {
                    packet.ReadString(ref position);
                    packet.ReadInt(ref position);
                    packet.ReadString(ref position);
                    for (int i = packet.ReadInt(ref position); i > 0; i--)
                    {
                        packet.ReadShort(ref position);
                    }
                    break;
                }
                }
            }while (playerDataList.Count < playerDataList.Capacity);
            return(playerDataList);
        }