示例#1
0
    public HWallItem(IHFormat format, ref ReadOnlySpan <byte> packetData)
    {
        Id                  = int.Parse(format.ReadUTF8(ref packetData));
        TypeId              = format.Read <int>(ref packetData);
        Location            = format.ReadUTF8(ref packetData);
        Data                = format.ReadUTF8(ref packetData);
        SecondsToExpiration = format.Read <int>(ref packetData);
        UsagePolicy         = (HUsagePolicy)format.Read <int>(ref packetData);
        OwnerId             = format.Read <int>(ref packetData);

        if (float.TryParse(Data, out _))
        {
            State = int.Parse(Data);
        }

        string[] locations = Location.Split(' ');
        if (Location.IndexOf(":") == 0 && locations.Length >= 3)
        {
            Placement = locations[2];

            if (locations[0].Length <= 3 || locations[1].Length <= 2)
            {
                return;
            }
            string firstLoc  = locations[0][3..];
示例#2
0
    public HCatalogProduct(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
    {
        Type = (HProductType)format.ReadUTF8(ref packetSpan)[0];
        switch (Type)
        {
        case HProductType.Badge:
        {
            ExtraData    = format.ReadUTF8(ref packetSpan);
            ProductCount = 1;
            break;
        }

        default:
        {
            ClassId      = format.Read <int>(ref packetSpan);
            ExtraData    = format.ReadUTF8(ref packetSpan);
            ProductCount = format.Read <int>(ref packetSpan);
            if (IsLimited = format.Read <bool>(ref packetSpan))
            {
                LimitedTotal     = format.Read <int>(ref packetSpan);
                LimitedRemaining = format.Read <int>(ref packetSpan);
            }
            break;
        }
        }
    }
示例#3
0
 public HCrackableStuffData(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
     : this()
 {
     State  = format.ReadUTF8(ref packetSpan);
     Hits   = format.Read <int>(ref packetSpan);
     Target = format.Read <int>(ref packetSpan);
 }
示例#4
0
 public HIntArrayStuffData(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
     : this()
 {
     Data = new int[format.Read <int>(ref packetSpan)];
     for (int i = 0; i < Data.Length; i++)
     {
         Data[i] = format.Read <int>(ref packetSpan);
     }
 }
示例#5
0
 public HHighScoreData(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
 {
     Score = format.Read <int>(ref packetSpan);
     Users = new string[format.Read <int>(ref packetSpan)];
     for (int i = 0; i < Users.Length; i++)
     {
         Users[i] = format.ReadUTF8(ref packetSpan);
     }
 }
示例#6
0
    public HSlideObjectBundle(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
    {
        int locationX = format.Read <int>(ref packetSpan);
        int locationY = format.Read <int>(ref packetSpan);

        int    targetX = format.Read <int>(ref packetSpan);
        int    targetY = format.Read <int>(ref packetSpan);
        HPoint location, target;

        Objects = new HSlideObject[format.Read <int>(ref packetSpan)];
        for (int i = 0; i < Objects.Length; i++)
        {
            int objectId = format.Read <int>(ref packetSpan);

            location = new HPoint(locationX, locationY, float.Parse(format.ReadUTF8(ref packetSpan), CultureInfo.InvariantCulture));
            target   = new HPoint(targetX, targetY, float.Parse(format.ReadUTF8(ref packetSpan), CultureInfo.InvariantCulture));

            Objects[i] = new HSlideObject(objectId, location, target);
        }

        Id = format.Read <int>(ref packetSpan);
        if (!packetSpan.IsEmpty)
        {
            var type = (HMoveType)format.Read <int>(ref packetSpan);

            int entityIndex = format.Read <int>(ref packetSpan);
            location = new HPoint(locationX, locationY, float.Parse(format.ReadUTF8(ref packetSpan), CultureInfo.InvariantCulture));
            target   = new HPoint(targetX, targetY, float.Parse(format.ReadUTF8(ref packetSpan), CultureInfo.InvariantCulture));

            Entity = new HSlideObject(entityIndex, location, target, type);
        }
    }
示例#7
0
    public HFloorObject(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
    {
        Id     = format.Read <int>(ref packetSpan);
        TypeId = format.Read <int>(ref packetSpan);

        int x = format.Read <int>(ref packetSpan);
        int y = format.Read <int>(ref packetSpan);

        Facing = (HDirection)format.Read <int>(ref packetSpan);
        Tile   = new HPoint(x, y, float.Parse(format.ReadUTF8(ref packetSpan), CultureInfo.InvariantCulture));

        Height = double.Parse(format.ReadUTF8(ref packetSpan), CultureInfo.InvariantCulture);
        Extra  = format.Read <int>(ref packetSpan);

        StuffData = HStuffData.Parse(format, ref packetSpan);

        SecondsToExpiration = format.Read <int>(ref packetSpan);
        UsagePolicy         = (HUsagePolicy)format.Read <int>(ref packetSpan);

        OwnerId = format.Read <int>(ref packetSpan);
        if (TypeId < 0)
        {
            StaticClass = format.ReadUTF8(ref packetSpan);
        }
    }
示例#8
0
    public static HPerk[] Parse(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
    {
        var perkAllowances = new HPerk[format.Read <int>(ref packetSpan)];

        for (int i = 0; i < perkAllowances.Length; i++)
        {
            perkAllowances[i] = new HPerk(format.ReadUTF8(ref packetSpan),
                                          format.ReadUTF8(ref packetSpan), format.Read <bool>(ref packetSpan));
        }
        return(perkAllowances);
    }
示例#9
0
    public static HItem[] Parse(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
    {
        format.Read <int>(ref packetSpan);
        format.Read <int>(ref packetSpan);
        var items = new HItem[format.Read <int>(ref packetSpan)];

        for (int i = 0; i < items.Length; i++)
        {
            items[i] = new HItem(format, ref packetSpan);
        }
        return(items);
    }
示例#10
0
    public HGroupEntry(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
    {
        Id             = format.Read <int>(ref packetSpan);
        Name           = format.ReadUTF8(ref packetSpan);
        BadgeCode      = format.ReadUTF8(ref packetSpan);
        PrimaryColor   = format.ReadUTF8(ref packetSpan);
        SecondaryColor = format.ReadUTF8(ref packetSpan);

        Favorite = format.Read <bool>(ref packetSpan);
        OwnerId  = format.Read <int>(ref packetSpan);
        HasForum = format.Read <bool>(ref packetSpan);
    }
示例#11
0
    public HHighScoreStuffData(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
        : this()
    {
        State     = format.ReadUTF8(ref packetSpan);
        ScoreType = (HScoreType)format.Read <int>(ref packetSpan);
        ClearType = (HScoreClearType)format.Read <int>(ref packetSpan);

        Entries = new HHighScoreData[format.Read <int>(ref packetSpan)];
        for (int i = 0; i < Entries.Length; i++)
        {
            Entries[i] = new HHighScoreData(format, ref packetSpan);
        }
    }
示例#12
0
    public static HFriendData[] Parse(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
    {
        int removedFriends = format.Read <int>(ref packetSpan);
        int addedFriends   = format.Read <int>(ref packetSpan);

        var friends = new HFriendData[format.Read <int>(ref packetSpan)];

        for (int i = 0; i < friends.Length; i++)
        {
            friends[i] = new HFriendData(format, ref packetSpan);
        }
        return(friends);
    }
示例#13
0
    public HPoll(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
    {
        Id = format.Read <int>(ref packetSpan);

        StartMessage = format.ReadUTF8(ref packetSpan);
        EndMessage   = format.ReadUTF8(ref packetSpan);

        Questions = new HPollQuestion[format.Read <int>(ref packetSpan)];
        for (int i = 0; i < Questions.Length; i++)
        {
            Questions[i] = new HPollQuestion(format, ref packetSpan);
        }
        format.Read <bool>(ref packetSpan);
    }
示例#14
0
    public HUserObject(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
    {
        Id   = format.Read <int>(ref packetSpan);
        Name = format.ReadUTF8(ref packetSpan);

        Figure = format.ReadUTF8(ref packetSpan);
        Gender = (HGender)format.ReadUTF8(ref packetSpan)[0];

        CustomData = format.ReadUTF8(ref packetSpan);
        RealName   = format.ReadUTF8(ref packetSpan);
        DirectMail = format.Read <bool>(ref packetSpan);

        RespectTotal  = format.Read <int>(ref packetSpan);
        RespectLeft   = format.Read <int>(ref packetSpan);
        ScratchesLeft = format.Read <int>(ref packetSpan);

        StreamPublishingAllowed = format.Read <bool>(ref packetSpan);

        if (DateTime.TryParse(format.ReadUTF8(ref packetSpan), out DateTime lastAccess))
        {
            LastAccess = lastAccess;
        }

        NameChangeAllowed   = format.Read <bool>(ref packetSpan);
        AccountSafetyLocked = format.Read <bool>(ref packetSpan);
    }
示例#15
0
    public HNavigatorSearchResult(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
    {
        SearchCode = format.ReadUTF8(ref packetSpan);
        Text       = format.ReadUTF8(ref packetSpan);

        ActionAllowed = format.Read <int>(ref packetSpan);
        ForceClosed   = format.Read <bool>(ref packetSpan);
        ViewMode      = format.Read <int>(ref packetSpan);

        Rooms = new HRoomEntry[format.Read <int>(ref packetSpan)];
        for (int i = 0; i < Rooms.Length; i++)
        {
            Rooms[i] = new HRoomEntry(format, ref packetSpan);
        }
    }
示例#16
0
    public HUserSearchResult(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
    {
        Id    = format.Read <int>(ref packetSpan);
        Name  = format.ReadUTF8(ref packetSpan);
        Motto = format.ReadUTF8(ref packetSpan);

        IsOnline  = format.Read <bool>(ref packetSpan);
        CanFollow = format.Read <bool>(ref packetSpan);

        format.ReadUTF8(ref packetSpan);

        Gender = format.Read <int>(ref packetSpan) == 1 ? HGender.Male : HGender.Female;
        Figure = format.ReadUTF8(ref packetSpan);

        RealName = format.ReadUTF8(ref packetSpan);
    }
示例#17
0
    public static (HUserSearchResult[] friends, HUserSearchResult[] others) Parse(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
    {
        var friends = new HUserSearchResult[format.Read <int>(ref packetSpan)];

        for (int i = 0; i < friends.Length; i++)
        {
            friends[i] = new HUserSearchResult(format, ref packetSpan);
        }

        var others = new HUserSearchResult[format.Read <int>(ref packetSpan)];

        for (int i = 0; i < others.Length; i++)
        {
            others[i] = new HUserSearchResult(format, ref packetSpan);
        }
        return(friends, others);
    }
示例#18
0
    public static HCatalogNode Parse(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
    {
        var    root = new HCatalogNode(format, ref packetSpan);
        bool   newAdditionsAvailable = format.Read <bool>(ref packetSpan);
        string catalogType           = format.ReadUTF8(ref packetSpan);

        return(root);
    }
示例#19
0
    /// <summary>
    /// Reads a value of type <typeparamref name="T"/> from <paramref name="source"/> and then 'advances'.
    /// </summary>
    /// <exception cref="IndexOutOfRangeException">Thrown if the <paramref name="source"/> does not have enough data to read a value of type <typeparamref name="T"/>.</exception>
    public static T Read <T>(this IHFormat format, ref ReadOnlySpan <byte> source)
        where T : struct
    {
        T value = format.Read <T>(source, out int bytesRead);

        source = source.Slice(bytesRead);
        return(value);
    }
示例#20
0
    public static HEntityUpdate[] Parse(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
    {
        var updates = new HEntityUpdate[format.Read <int>(ref packetSpan)];

        for (int i = 0; i < updates.Length; i++)
        {
            updates[i] = new HEntityUpdate(format, ref packetSpan);
        }
        return(updates);
    }
示例#21
0
    public static HFloorObject[] Parse(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
    {
        int ownersCount = format.Read <int>(ref packetSpan);
        var owners      = new Dictionary <int, string>(ownersCount);

        for (int i = 0; i < ownersCount; i++)
        {
            owners.Add(format.Read <int>(ref packetSpan), format.ReadUTF8(ref packetSpan));
        }

        var floorObjects = new HFloorObject[format.Read <int>(ref packetSpan)];

        for (int i = 0; i < floorObjects.Length; i++)
        {
            var floorObject = new HFloorObject(format, ref packetSpan);
            floorObject.OwnerName = owners[floorObject.OwnerId];

            floorObjects[i] = floorObject;
        }
        return(floorObjects);
    }
示例#22
0
    public HMapStuffData(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
        : this()
    {
        int length = format.Read <int>(ref packetSpan);

        Data = new(length);

        for (int i = 0; i < length; i++)
        {
            Data[format.ReadUTF8(ref packetSpan)] = format.ReadUTF8(ref packetSpan);
        }
    }
示例#23
0
    public HCatalogPage(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
    {
        Id          = format.Read <int>(ref packetSpan);
        CatalogType = format.ReadUTF8(ref packetSpan);
        LayoutCode  = format.ReadUTF8(ref packetSpan);

        Images = new string[format.Read <int>(ref packetSpan)];
        for (int i = 0; i < Images.Length; i++)
        {
            Images[i] = format.ReadUTF8(ref packetSpan);
        }

        Texts = new string[format.Read <int>(ref packetSpan)];
        for (int i = 0; i < Texts.Length; i++)
        {
            Texts[i] = format.ReadUTF8(ref packetSpan);
        }

        Offers = new HCatalogOffer[format.Read <int>(ref packetSpan)];
        for (int i = 0; i < Offers.Length; i++)
        {
            Offers[i] = new HCatalogOffer(format, ref packetSpan);
        }

        OfferId = format.Read <int>(ref packetSpan);
        AcceptSeasonCurrencyAsCredits = format.Read <bool>(ref packetSpan);

        IsFrontPage = !packetSpan.IsEmpty;
    }
示例#24
0
    public static HNavigatorSearchResult[] Parse(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
    {
        string searchCode = format.ReadUTF8(ref packetSpan);
        string filter     = format.ReadUTF8(ref packetSpan);

        var results = new HNavigatorSearchResult[format.Read <int>(ref packetSpan)];

        for (int i = 0; i < results.Length; i++)
        {
            results[i] = new HNavigatorSearchResult(format, ref packetSpan);
        }
        return(results);
    }
示例#25
0
    public HFriendData(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
    {
        Id       = format.Read <int>(ref packetSpan);
        Username = format.ReadUTF8(ref packetSpan);
        Gender   = format.Read <int>(ref packetSpan) == 1 ? HGender.Male : HGender.Female;

        IsOnline   = format.Read <bool>(ref packetSpan);
        CanFollow  = format.Read <bool>(ref packetSpan);
        Figure     = format.ReadUTF8(ref packetSpan);
        CategoryId = format.Read <int>(ref packetSpan);
        Motto      = format.ReadUTF8(ref packetSpan);
        RealName   = format.ReadUTF8(ref packetSpan);
        format.ReadUTF8(ref packetSpan);

        IsPersisted = format.Read <bool>(ref packetSpan);
        format.Read <bool>(ref packetSpan);
        IsPocketHabboUser  = format.Read <bool>(ref packetSpan);
        RelationshipStatus = (HRelationship)format.Read <short>(ref packetSpan);
    }
示例#26
0
    public HCatalogOffer(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
    {
        Id          = format.Read <int>(ref packetSpan);
        DisplayName = format.ReadUTF8(ref packetSpan);
        IsRentable  = format.Read <bool>(ref packetSpan);

        CreditCost        = format.Read <int>(ref packetSpan);
        OtherCurrencyCost = format.Read <int>(ref packetSpan);
        OtherCurrencyType = format.Read <int>(ref packetSpan);
        CanGift           = format.Read <bool>(ref packetSpan);

        Products = new HCatalogProduct[format.Read <int>(ref packetSpan)];
        for (int i = 0; i < Products.Length; i++)
        {
            Products[i] = new HCatalogProduct(format, ref packetSpan);
        }

        ClubLevel   = format.Read <int>(ref packetSpan);
        AllowBundle = format.Read <bool>(ref packetSpan);
        IsPet       = format.Read <bool>(ref packetSpan);

        PreviewImage = format.ReadUTF8(ref packetSpan);
    }
示例#27
0
    public static HStuffData Parse(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
    {
        int        value     = format.Read <int>(ref packetSpan);
        HStuffData stuffData = (HStuffDataFormat)(value & 0xFF) switch
        {
            HStuffDataFormat.Legacy => new HLegacyStuffData(format, ref packetSpan),
            HStuffDataFormat.Map => new HMapStuffData(format, ref packetSpan),
            HStuffDataFormat.StringArray => new HStringArrayStuffData(format, ref packetSpan),
            HStuffDataFormat.VoteResult => new HVoteResultStuffData(format, ref packetSpan),
            HStuffDataFormat.Empty => new HStuffData(),
            HStuffDataFormat.IntArray => new HIntArrayStuffData(format, ref packetSpan),
            HStuffDataFormat.HighScore => new HHighScoreStuffData(format, ref packetSpan),
            HStuffDataFormat.Crackable => new HCrackableStuffData(format, ref packetSpan),
            _ => throw new NotImplementedException((value & 0xFF).ToString()),
        };

        stuffData.Flags = (HStuffDataFlags)(value & 0xFF00);
        if (stuffData.Flags.HasFlag(HStuffDataFlags.HasUniqueSerialNumber))
        {
            stuffData.UniqueSerialNumber = format.Read <int>(ref packetSpan);
            stuffData.UniqueSeriesSize   = format.Read <int>(ref packetSpan);
        }
        return(stuffData);
    }
示例#28
0
    public HUserProfile(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
    {
        Id               = format.Read <int>(ref packetSpan);
        Username         = format.ReadUTF8(ref packetSpan);
        Motto            = format.ReadUTF8(ref packetSpan);
        Figure           = format.ReadUTF8(ref packetSpan);
        CreationDate     = DateTime.Parse(format.ReadUTF8(ref packetSpan));
        AchievementScore = format.Read <int>(ref packetSpan);
        FriendCount      = format.Read <int>(ref packetSpan);

        IsFriend            = format.Read <bool>(ref packetSpan);
        IsFriendRequestSent = format.Read <bool>(ref packetSpan);
        IsOnline            = format.Read <bool>(ref packetSpan);

        Groups = new HGroupEntry[format.Read <int>(ref packetSpan)];
        for (int i = 0; i < Groups.Length; i++)
        {
            Groups[i] = new HGroupEntry(format, ref packetSpan);
        }

        SinceLastAccessInSeconds = format.Read <int>(ref packetSpan);
        OpenProfileView          = format.Read <bool>(ref packetSpan);
    }
示例#29
0
    public static HAchievement[] Parse(IHFormat format, ReadOnlySpan <byte> packetSpan)
    {
        var achievements = new HAchievement[format.Read <int>(ref packetSpan)];

        for (int i = 0; i < achievements.Length; i++)
        {
            var achievement = new HAchievement(format, ref packetSpan);
            achievements[i] = achievement;

            for (int j = 0; j < achievement.Levels.Length; j++)
            {
                var level = new ACHLevel(format, ref packetSpan);
                level.BadgeId = $"ACH_{achievement.Name}{level.Level}";

                achievement.Levels[j] = level;
            }
        }
        return(achievements);
    }
示例#30
0
    public HPollQuestion(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
    {
        Id = format.Read <int>(ref packetSpan);
        format.Read <int>(ref packetSpan);
        Type       = (HPollType)format.Read <int>(ref packetSpan);
        Text       = format.ReadUTF8(ref packetSpan);
        Category   = format.Read <int>(ref packetSpan);
        AnswerType = format.Read <int>(ref packetSpan);

        Choices = new HPollChoice[format.Read <int>(ref packetSpan)];
        for (int i = 0; i < Choices.Length; i++)
        {
            Choices[i] = new HPollChoice(format, ref packetSpan);
        }
    }