Example #1
0
 public void Flush()
 {
     _firstTimeLoadProfile = true;
     _urlToken             = string.Empty;
     _csrfToken            = string.Empty;
     _playerName           = string.Empty;
     _lastSignIn           = string.Empty;
     _createdOn            = string.Empty;
     _userHash             = string.Empty;
     _motto                = string.Empty;
     _homepageVisible      = false;
     _friendRequestAllowed = false;
     _showOnlineStatus     = false;
     _offlineMessaging     = false;
     _friendsCanFollow     = false;
     _gender               = HGender.Unknown;
     _age              = 0;
     ClientStarting    = string.Empty;
     _gameData         = HGameData.Empty;
     _flashClientBuild = string.Empty;
     _flashClientUrl   = string.Empty;
     _port             = 0;
     _host             = string.Empty;
     _addresses        = null;
     _ssoTicket        = string.Empty;
 }
Example #2
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());
            }
        }
 public ReadOnlyCollection <IHPlayerData> GroupByGender(HGender gender)
 {
     if (!_groupByGender.ContainsKey(gender))
     {
         return(null);
     }
     return(_groupByGender[gender]);
 }
Example #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HEntity"/> class with the specified information,
 /// </summary>
 /// <param name="id">The id of the <see cref="HEntity"/>.</param>
 /// <param name="index">The room index value of the <see cref="HEntity"/>.</param>
 /// <param name="name">The name of the <see cref="HEntity"/>.</param>
 /// <param name="tile">The <see cref="HPoint"/> of the <see cref="HEntity"/>.</param>
 /// <param name="motto">The motto of the <see cref="HEntity"/>.</param>
 /// <param name="gender">The <see cref="HGender"/> of the <see cref="HEntity"/>.</param>
 /// <param name="figureId">The figure id of the <see cref="HEntity"/>.</param>
 /// <param name="favoriteGroup">The favorite group badge of the <see cref="HEntity"/>.</param>
 public HEntity(int id, int index, string name, HPoint tile,
     string motto, HGender gender, string figureId, string favoriteGroup)
 {
     Id = id;
     Index = index;
     Name = name;
     Tile = tile;
     Motto = motto;
     Gender = gender;
     FigureId = figureId;
     FavoriteGroup = favoriteGroup;
 }
Example #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HEntity"/> class with the specified information,
 /// </summary>
 /// <param name="id">The id of the <see cref="HEntity"/>.</param>
 /// <param name="index">The room index value of the <see cref="HEntity"/>.</param>
 /// <param name="name">The name of the <see cref="HEntity"/>.</param>
 /// <param name="tile">The <see cref="HPoint"/> of the <see cref="HEntity"/>.</param>
 /// <param name="motto">The motto of the <see cref="HEntity"/>.</param>
 /// <param name="gender">The <see cref="HGender"/> of the <see cref="HEntity"/>.</param>
 /// <param name="figureId">The figure id of the <see cref="HEntity"/>.</param>
 /// <param name="favoriteGroup">The favorite group badge of the <see cref="HEntity"/>.</param>
 public HEntity(int id, int index, string name, HPoint tile,
                string motto, HGender gender, string figureId, string favoriteGroup)
 {
     Id            = id;
     Index         = index;
     Name          = name;
     Tile          = tile;
     Motto         = motto;
     Gender        = gender;
     FigureId      = figureId;
     FavoriteGroup = favoriteGroup;
 }
Example #6
0
 public HPlayerData(string playerName, int playerId, int playerIndex,
                    HPoint tile, string figureId, string motto, HGender gender, string groupName)
 {
     PlayerName    = playerName;
     PlayerId      = playerId;
     PlayerIndex   = playerIndex;
     Tile          = tile;
     FigureId      = figureId;
     Motto         = motto;
     Gender        = gender;
     FavoriteGroup = groupName;
 }
Example #7
0
 public void Update(string Motto, HGender Gender, string FigureID)
 {
     this.Motto = Motto;
     this.Gender = Gender;
     this.FigureId = FigureId;
 }
Example #8
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);
            }
        }
Example #9
0
        private void HandleResource(HPage page, ref string body)
        {
            PlayerId    = int.Parse(body.GetChild("var habboId = ", ';'));
            _playerName = body.GetChild("var habboName = \"", '\"');
            _age        = int.Parse(body.GetChild("kvage=", ';'));
            _gender     = (HGender)Char.ToUpper(body.GetChild("kvgender=", ';')[0]);
            _csrfToken  = body.GetChild("<meta name=\"csrf-token\" content=\"", '\"');

            switch (page)
            {
            case HPage.Me:
            {
                string[] infoBoxes = body.GetChilds("<div class=\"content\">", '<');
                _motto      = infoBoxes[6].Split('>')[1];
                _lastSignIn = infoBoxes[12].Split('>')[1];
                break;
            }

            case HPage.Home:
            {
                _createdOn = body.GetChild("<div class=\"birthday date\">", '<');
                _motto     = body.GetChild("<div class=\"profile-motto\">", '<');
                break;
            }

            case HPage.Profile:
            {
                _firstTimeLoadProfile = false;
                _urlToken             = body.GetChild("name=\"urlToken\" value=\"", '\"');

                _homepageVisible      = body.GetChild("name=\"visibility\" value=\"EVERYONE\"", '/').Contains("checked");
                _friendRequestAllowed = body.GetChild("name=\"friendRequestsAllowed\"", '/').Contains("checked");
                _showOnlineStatus     = body.GetChild("name=\"showOnlineStatus\" value=\"true\"", '/').Contains("checked");
                _offlineMessaging     = body.GetChild("name=\"persistentMessagingAllowed\" checked=\"checked\"", '/').Contains("true");
                _friendsCanFollow     = body.GetChild("name=\"followFriendMode\" value=\"1\"").Contains("checked");
                break;
            }

            case HPage.Client:
            {
                _host      = body.GetChild("\"connection.info.host\" : \"", '\"');
                _port      = int.Parse(body.GetChild("\"connection.info.port\" : \"", '\"').Split(',')[0]);
                _addresses = Dns.GetHostAddresses(_host).Select(ip => ip.ToString()).ToArray();
                _ssoTicket = body.GetChild("\"sso.ticket\" : \"", '\"');

                if (string.IsNullOrEmpty(ClientStarting))
                {
                    ClientStarting = body.GetChild("\"client.starting\" : \"", '\"');
                }
                else
                {
                    body = body.Replace(body.GetChild("\"client.starting\" : \"", '\"'), ClientStarting);
                }

                _userHash = body.GetChild("\"user.hash\" : \"", '\"');
                _gameData = HGameData.Parse(body);

                _flashClientUrl   = "http://" + body.GetChild("\"flash.client.url\" : \"", '\"').Substring(3) + "Habbo.swf";
                _flashClientBuild = _flashClientUrl.Split('/')[4];

                body = body.Replace("\"\\//", "\"http://");
                break;
            }
            }
        }
Example #10
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);
        }
Example #11
0
 public IList <IHPlayerData> PlayersByGender(HGender gender)
 {
     throw new NotImplementedException();
 }
Example #12
0
        public static HMessage MakeEntity(int Id, int Index, int X, int Y, int Z, string name, string motto, HGender gender, int entitytype, string figureid, string FavouriteGroup, ushort header)
        {
            var ret = new HMessage(header);

            ret.WriteInteger(1);
            ret.WriteInteger(Id);
            ret.WriteInteger(Index);
            ret.WriteInteger(X);
            ret.WriteInteger(Y);
            ret.WriteInteger(Z);
            ret.WriteString(name);
            ret.WriteString(motto);
            ret.WriteInteger((int)gender);
            ret.WriteInteger(entitytype);
            ret.WriteString(figureid);
            ret.WriteString(FavouriteGroup);
            return(ret);
        }
Example #13
0
 public void Update(string Motto, HGender Gender, string FigureID)
 {
     this.Motto    = Motto;
     this.Gender   = Gender;
     this.FigureId = FigureId;
 }