コード例 #1
0
        protected CatalogPageData(IReadOnlyPacket packet)
            : this()
        {
            Position = packet.ReadInt();
            String1  = packet.ReadString();
            String2  = packet.ReadString();
            Type     = packet.ReadInt();

            switch (Type)
            {
            case 0:
                String3 = packet.ReadString();
                break;

            case 1:
                Int3 = packet.ReadInt();
                break;

            case 2:
                String4 = packet.ReadString();
                break;

            default:
                break;
            }

            SecondsToExpiration = packet.ReadInt();
        }
コード例 #2
0
ファイル: CatalogProduct.cs プロジェクト: b7c/Xabbo.Core
        protected CatalogProduct(IReadOnlyPacket packet)
        {
            Type = packet.Protocol switch
            {
                ClientType.Flash => H.ToItemType(packet.ReadString()),
                ClientType.Unity => H.ToItemType(packet.ReadShort()),
                _ => throw new Exception($"Unknown client protocol: {packet.Protocol}.")
            };

            if (Type == ItemType.Badge)
            {
                Variant = packet.ReadString();
                Count   = 0;
            }
            else
            {
                Kind    = packet.ReadInt();
                Variant = packet.ReadString();
                Count   = packet.ReadInt();
                // int ?
                IsLimited = packet.ReadBool();
                if (IsLimited)
                {
                    LimitedTotal     = packet.ReadInt();
                    LimitedRemaining = packet.ReadInt();
                }
            }
        }
    }
コード例 #3
0
 protected virtual void Initialize(IReadOnlyPacket packet)
 {
     if (Flags.HasFlag(ItemDataFlags.IsLimitedRare))
     {
         LimitedNumber = packet.ReadInt();
         LimitedTotal  = packet.ReadInt();
     }
 }
コード例 #4
0
ファイル: ChatSettings.cs プロジェクト: b7c/Xabbo.Core
 internal ChatSettings(IReadOnlyPacket packet)
 {
     Flow                = (ChatFlow)packet.ReadInt();
     BubbleWidth         = (ChatBubbleWidth)packet.ReadInt();
     ScrollSpeed         = (ChatScrollSpeed)packet.ReadInt();
     TalkHearingDistance = packet.ReadInt();
     FloodProtection     = (ChatFloodProtection)packet.ReadInt();
 }
コード例 #5
0
        protected override void Initialize(IReadOnlyPacket packet)
        {
            Value  = packet.ReadString();
            Hits   = packet.ReadInt();
            Target = packet.ReadInt();

            base.Initialize(packet);
        }
コード例 #6
0
        protected ActivityPoints(IReadOnlyPacket packet)
        {
            short n = packet.ReadLegacyShort();

            for (int i = 0; i < n; i++)
            {
                var type = (ActivityPointType)packet.ReadInt();
                dictionary[type] = packet.ReadInt();
            }
        }
コード例 #7
0
 internal RoomUser(long id, int index, IReadOnlyPacket packet)
     : this(id, index)
 {
     Gender           = H.ToGender(packet.ReadString());
     GroupId          = packet.ReadLegacyLong();
     Int8             = packet.ReadInt();
     GroupName        = packet.ReadString();
     FigureExtra      = packet.ReadString();
     AchievementScore = packet.ReadInt();
     Bool1            = packet.ReadBool();
 }
コード例 #8
0
        protected TradeOffer(IReadOnlyPacket packet)
            : this()
        {
            UserId = packet.ReadInt();
            int n = packet.ReadInt();

            for (int i = 0; i < n; i++)
            {
                Items.Add(TradeItem.Parse(packet));
            }
            FurniCount  = packet.ReadInt();
            CreditCount = packet.ReadInt();
        }
コード例 #9
0
ファイル: TradeManager.cs プロジェクト: b7c/Xabbo.Core
        private void HandleTradeCompleted(IReadOnlyPacket packet)
        {
            if (!_roomManager.IsInRoom || !IsTrading)
            {
                return;
            }

            int userId = packet.ReadInt();
            int reason = packet.ReadInt();

            bool        wasTrader    = IsTrader;
            IRoomUser?  self         = Self;
            IRoomUser?  partner      = Partner;
            ITradeOffer?ownOffer     = OwnOffer;
            ITradeOffer?partnerOffer = PartnerOffer;

            if (self == null || partner == null ||
                ownOffer == null || partnerOffer == null)
            {
                return;
            }

            IRoomUser user;

            if (userId == self.Id)
            {
                user = self;
            }
            else if (userId == partner.Id)
            {
                user = partner;
            }
            else
            {
                DebugUtil.Log($"user id {userId} does not match self {Self} or partner {Partner} ids");
                return;
            }

            ResetTrade();

            if (reason == 0)
            {
                DebugUtil.Log($"complete {userId}, partner = {partner}");
                OnComplete(wasTrader, self, partner, ownOffer, partnerOffer);
            }
            else
            {
                DebugUtil.Log($"stopped, reason = {reason} ({userId})");
                OnStop(user, reason);
            }
        }
コード例 #10
0
        protected NavigatorSearchResultList(IReadOnlyPacket packet)
        {
            Category      = packet.ReadString();
            Text          = packet.ReadString();
            ActionAllowed = packet.ReadInt();
            BoolA         = packet.ReadBool();
            ViewMode      = packet.ReadInt();
            short n = packet.ReadLegacyShort();

            for (int i = 0; i < n; i++)
            {
                Add(RoomInfo.Parse(packet));
            }
        }
コード例 #11
0
ファイル: Pet.cs プロジェクト: b7c/Xabbo.Core
 internal Pet(long id, int index, IReadOnlyPacket packet)
     : this(id, index)
 {
     Breed       = packet.ReadInt();
     OwnerId     = packet.ReadLegacyLong();
     OwnerName   = packet.ReadString();
     RarityLevel = packet.ReadInt();
     Bool1       = packet.ReadBool();
     Bool2       = packet.ReadBool();
     Bool3       = packet.ReadBool();
     Bool4       = packet.ReadBool();
     Bool5       = packet.ReadBool();
     Bool6       = packet.ReadBool();
     Level       = packet.ReadInt();
     Stance      = packet.ReadString();
 }
コード例 #12
0
ファイル: GroupMember.cs プロジェクト: b7c/Xabbo.Core
 protected GroupMember(IReadOnlyPacket packet)
 {
     Type   = (GroupMemberType)packet.ReadInt();
     Id     = packet.ReadLegacyLong();
     Name   = packet.ReadString();
     Figure = packet.ReadString();
     Joined = DateTime.Parse(packet.ReadString());
 }
コード例 #13
0
        protected RollerUpdate(IReadOnlyPacket packet)
            : this()
        {
            LocationX = packet.ReadInt();
            LocationY = packet.ReadInt();
            TargetX   = packet.ReadInt();
            TargetY   = packet.ReadInt();

            int n = packet.ReadLegacyShort();

            for (int i = 0; i < n; i++)
            {
                ObjectUpdates.Add(RollerObjectUpdate.Parse(packet));
            }

            RollerId = packet.ReadLegacyLong();

            if (packet.Available > 0)
            {
                Type = (RollerUpdateType)packet.ReadInt();
                if (Type == RollerUpdateType.MovingEntity ||
                    Type == RollerUpdateType.StationaryEntity)
                {
                    if (packet.Protocol == ClientType.Unity)
                    {
                        packet.ReadInt();
                    }
                    // Entity index may have changed to long here
                    // but it's int everywhere else ???
                    EntityIndex     = packet.ReadInt();
                    EntityLocationZ = packet.ReadLegacyFloat();
                    EntityTargetZ   = packet.ReadLegacyFloat();
                }
            }
        }
コード例 #14
0
ファイル: UserData.cs プロジェクト: b7c/Xabbo.Core
 protected UserData(IReadOnlyPacket packet)
 {
     Id               = packet.ReadLegacyLong();
     Name             = packet.ReadString();
     Figure           = packet.ReadString();
     Gender           = H.ToGender(packet.ReadString());
     Motto            = packet.ReadString();
     String4          = packet.ReadString();
     Bool1            = packet.ReadBool();
     TotalRespects    = packet.ReadInt();
     RespectsLeft     = packet.ReadInt();
     ScratchesLeft    = packet.ReadInt();
     Bool2            = packet.ReadBool();
     LastLogin        = packet.ReadString();
     IsNameChangeable = packet.ReadBool();
     IsSafetyLocked   = packet.ReadBool();
     Bool3            = packet.ReadBool();
 }
コード例 #15
0
ファイル: UserProfile.cs プロジェクト: b7c/Xabbo.Core
        protected UserProfile(IReadOnlyPacket packet)
            : this()
        {
            if (packet.Protocol == ClientType.Flash)
            {
                Id                  = packet.ReadInt();
                Name                = packet.ReadString();
                Figure              = packet.ReadString();
                Motto               = packet.ReadString();
                Created             = packet.ReadString();
                ActivityPoints      = packet.ReadInt();
                Friends             = packet.ReadInt();
                IsFriend            = packet.ReadBool();
                IsFriendRequestSent = packet.ReadBool();
                IsOnline            = packet.ReadBool();

                int n = packet.ReadInt();
                for (int i = 0; i < n; i++)
                {
                    Groups.Add(GroupInfo.Parse(packet));
                }

                LastLogin       = TimeSpan.FromSeconds(packet.ReadInt());
                DisplayInClient = packet.ReadBool();
            }
            else
            {
                Id      = packet.ReadLong();
                Name    = packet.ReadString();
                Figure  = packet.ReadString();
                Motto   = packet.ReadString();
                Created = packet.ReadString();
                // ActivityPoints = packet.ReadInt();
                Friends  = packet.ReadInt();
                IsFriend = packet.ReadBool();
                // IsFriendRequestSent = packet.ReadBool();
                // IsOnline = packet.ReadBool();

                // long secondsSinceLastLogin
                // bool showInClient ???
                // bool ?
                // int ?
                // int ?
                // int ?
                // bool ?
                // bool ?

                short n = packet.ReadShort();
                for (int i = 0; i < n; i++)
                {
                    Groups.Add(GroupInfo.Parse(packet));
                }

                LastLogin       = TimeSpan.FromSeconds(packet.ReadInt());
                DisplayInClient = packet.ReadBool();
            }
        }
コード例 #16
0
 protected Achievement(IReadOnlyPacket packet)
 {
     Id              = packet.ReadInt();
     Level           = packet.ReadInt();
     BadgeName       = packet.ReadString();
     BaseProgress    = packet.ReadInt();
     MaxProgress     = packet.ReadInt();
     Int5            = packet.ReadInt();
     Int6            = packet.ReadInt();
     CurrentProgress = packet.ReadInt();
     IsCompleted     = packet.ReadBool();
     Category        = packet.ReadString();
     String3         = packet.ReadString();
     MaxLevel        = packet.ReadInt();
     Int9            = packet.ReadInt();
     _Short1         = packet.ReadShort();
 }
コード例 #17
0
ファイル: TradeManager.cs プロジェクト: b7c/Xabbo.Core
        private void HandleTradeOpen(IReadOnlyPacket packet)
        {
            if (_profileManager.UserData == null)
            {
                DebugUtil.Log("user data not loaded");
                return;
            }

            if (!_roomManager.IsInRoom || _roomManager.Room is null)
            {
                DebugUtil.Log("not in room");
                return;
            }

            int traderId = packet.ReadInt();
            int unknownA = packet.ReadInt(); // ?
            int tradeeId = packet.ReadInt();
            int unknownB = packet.ReadInt(); // ?

            if (!_roomManager.Room.TryGetEntityById(traderId, out IRoomUser? trader))
            {
                DebugUtil.Log($"failed to find user with id {traderId}");
                return;
            }

            if (!_roomManager.Room.TryGetEntityById(tradeeId, out IRoomUser? tradee))
            {
                DebugUtil.Log($"failed to find user with id {tradeeId}");
                return;
            }

            ResetTrade();

            IsTrader = _profileManager.UserData.Id == traderId;
            Self     = IsTrader ? trader : tradee;
            Partner  = IsTrader ? tradee : trader;

            IsTrading = true;

            OnStart(IsTrader, Partner);
        }
コード例 #18
0
ファイル: RoomData.cs プロジェクト: b7c/Xabbo.Core
        protected RoomData(bool isUpdating, IReadOnlyPacket packet)
            : base(packet)
        {
            IsUpdating = isUpdating;

            ForceLoad    = packet.ReadBool(); // if IsUpdating == false
            Bool3        = packet.ReadBool();
            BypassAccess = packet.ReadBool();
            IsRoomMuted  = packet.ReadBool();

            Moderation = ModerationSettings.Parse(packet);

            ShowMuteButton = packet.ReadBool();
            ChatSettings   = ChatSettings.Parse(packet);

            if (packet.Protocol == ClientType.Unity)
            {
                UnknownInt1 = packet.ReadInt();
                UnknownInt2 = packet.ReadInt();
            }
        }
コード例 #19
0
        protected CatalogPageNode(IReadOnlyPacket packet)
        {
            IsVisible = packet.ReadBool();
            Icon      = packet.ReadInt();
            Id        = packet.ReadInt();
            Name      = packet.ReadString();
            Text      = packet.ReadString();

            short n = packet.ReadLegacyShort();

            for (int i = 0; i < n; i++)
            {
                OfferIds.Add(packet.ReadInt());
            }

            n = packet.ReadLegacyShort();
            for (int i = 0; i < n; i++)
            {
                Children.Add(Parse(packet));
            }
        }
コード例 #20
0
ファイル: CatalogOffer.cs プロジェクト: b7c/Xabbo.Core
        protected CatalogOffer(IReadOnlyPacket packet)
        {
            Id                    = packet.ReadInt();
            FurniLine             = packet.ReadString();
            IsRentable            = packet.ReadBool();
            PriceInCredits        = packet.ReadInt();
            PriceInActivityPoints = packet.ReadInt();
            ActivityPointType     = (ActivityPointType)packet.ReadInt();
            CanPurchaseAsGift     = packet.ReadBool();

            short n = packet.ReadLegacyShort();

            for (int i = 0; i < n; i++)
            {
                Products.Add(CatalogProduct.Parse(packet));
            }

            ClubLevel           = packet.ReadInt();
            CanPurchaseMultiple = packet.ReadBool();
            IsPet        = packet.ReadBool();
            PreviewImage = packet.ReadString();
        }
コード例 #21
0
        protected RoomInfo(IReadOnlyPacket packet)
            : this()
        {
            Id          = packet.ReadLegacyLong();
            Name        = packet.ReadString();
            OwnerId     = packet.ReadLegacyLong();
            OwnerName   = packet.ReadString();
            Access      = (RoomAccess)packet.ReadInt();
            Users       = packet.ReadInt();
            MaxUsers    = packet.ReadInt();
            Description = packet.ReadString();
            Trading     = (TradePermissions)packet.ReadInt();
            Score       = packet.ReadInt();
            Ranking     = packet.ReadInt();
            Category    = (RoomCategory)packet.ReadInt();

            int n = packet.ReadLegacyShort();

            for (int i = 0; i < n; i++)
            {
                Tags.Add(packet.ReadString());
            }

            Flags = (RoomFlags)packet.ReadInt();

            if (Flags.HasFlag(RoomFlags.HasOfficialRoomPic))
            {
                OfficialRoomPicRef = packet.ReadString();
            }

            if (Flags.HasFlag(RoomFlags.IsGroupHomeRoom))
            {
                GroupId    = packet.ReadLegacyLong();
                GroupName  = packet.ReadString();
                GroupBadge = packet.ReadString();
            }

            if (Flags.HasFlag(RoomFlags.HasEvent))
            {
                EventName        = packet.ReadString();
                EventDescription = packet.ReadString();
                EventMinutesLeft = packet.ReadInt();
            }
        }
コード例 #22
0
        private Heightmap(IReadOnlyPacket packet)
        {
            Width = packet.ReadInt();
            short n = packet.ReadLegacyShort();

            Length = n / Width;

            Values = new short[n];
            for (int i = 0; i < n; i++)
            {
                Values[i] = packet.ReadShort();
            }
        }
コード例 #23
0
ファイル: TradeManager.cs プロジェクト: b7c/Xabbo.Core
        private void HandleTradeOpenFail(IReadOnlyPacket packet)
        {
            if (!_roomManager.IsInRoom)
            {
                DebugUtil.Log("not in room");
                return;
            }

            int    reason = packet.ReadInt();
            string name   = packet.ReadString();

            ResetTrade();
            OnStartFail(reason, name);
        }
コード例 #24
0
ファイル: TradeManager.cs プロジェクト: b7c/Xabbo.Core
        private void HandleTradeAccept(IReadOnlyPacket packet)
        {
            if (!_roomManager.IsInRoom)
            {
                DebugUtil.Log("not in room");
                return;
            }

            if (!IsTrading)
            {
                DebugUtil.Log("not trading");
                return;
            }

            IRoomUser user;
            int       userId   = packet.ReadInt();
            bool      accepted = packet.ReadInt() == 1;

            if (userId == Self?.Id)
            {
                user        = Self;
                HasAccepted = accepted;
            }
            else if (userId == Partner?.Id)
            {
                user = Partner;
                HasPartnerAccepted = accepted;
            }
            else
            {
                DebugUtil.Log($"user id {userId} does not match self {Self} or partner {Partner} ids");
                return;
            }

            DebugUtil.Log($"user {user} {(accepted ? "" : "un")}accepted");
            OnAccept(user, accepted);
        }
コード例 #25
0
ファイル: CatalogPage.cs プロジェクト: b7c/Xabbo.Core
        protected CatalogPage(IReadOnlyPacket packet)
        {
            Id         = packet.ReadInt();
            Mode       = packet.ReadString();
            LayoutCode = packet.ReadString();

            short n = packet.ReadLegacyShort();

            for (int i = 0; i < n; i++)
            {
                Images.Add(packet.ReadString());
            }

            n = packet.ReadLegacyShort();
            for (int i = 0; i < n; i++)
            {
                Texts.Add(packet.ReadString());
            }

            n = packet.ReadLegacyShort();
            for (int i = 0; i < n; i++)
            {
                Offers.Add(CatalogOffer.Parse(packet));
            }

            UnknownIntA = packet.ReadInt();
            AcceptSeasonCurrencyAsCredits = packet.ReadBool();
            if (packet.Available > 0)
            {
                n = packet.ReadLegacyShort();
                for (int i = 0; i < n; i++)
                {
                    Data.Add(CatalogPageData.Parse(packet));
                }
            }
        }
コード例 #26
0
        protected GroupData(IReadOnlyPacket packet, ClientType clientType)
        {
            Id                  = packet.ReadLong();
            CanLeave            = packet.ReadBool();
            Type                = (GroupType)packet.ReadInt();
            Name                = packet.ReadString();
            Description         = packet.ReadString();
            Badge               = packet.ReadString();
            HomeRoomId          = packet.ReadLong();
            HomeRoomName        = packet.ReadString();
            MemberStatus        = (GroupMemberStatus)packet.ReadInt();
            MemberCount         = packet.ReadInt();
            IsFavourite         = packet.ReadBool();
            Created             = packet.ReadString();
            IsOwner             = packet.ReadBool();
            IsAdmin             = packet.ReadBool();
            OwnerName           = packet.ReadString();
            DisplayInClient     = packet.ReadBool();
            CanDecorateHomeRoom = packet.ReadBool();
            PendingRequests     = packet.ReadInt();
            CanViewForum        = packet.ReadBool();

            // TODO extra 8 bytes
        }
コード例 #27
0
        public static StuffData Parse(IReadOnlyPacket packet)
        {
            int value = packet.ReadInt();
            var type  = (StuffDataType)(value & 0xFF);

            StuffData data = type switch
            {
                StuffDataType.Legacy => new LegacyData(),
                StuffDataType.Map => new MapData(),
                StuffDataType.StringArray => new StringArrayData(),
                StuffDataType.VoteResult => new VoteResultData(),
                StuffDataType.ItemData4 => new ItemData4(),
                StuffDataType.IntArray => new IntArrayData(),
                StuffDataType.HighScore => new HighScoreData(),
                StuffDataType.CrackableFurni => new CrackableFurniData(),
                _ => throw new Exception($"Unknown ItemData type: {type}"),
            };

            data.Flags = (ItemDataFlags)(value >> 8);
            data.Initialize(packet);

            return(data);
        }
コード例 #28
0
 protected Badge(IReadOnlyPacket packet)
 {
     Id   = packet.ReadInt();
     Code = packet.ReadString();
 }
コード例 #29
0
ファイル: InventoryItem.cs プロジェクト: b7c/Xabbo.Core
        protected InventoryItem(IReadOnlyPacket packet)
            : this()
        {
            ItemId = packet.ReadLegacyLong();

            if (packet.Protocol == ClientType.Flash)
            {
                Type = H.ToItemType(packet.ReadString());
            }
            else
            {
                Type = H.ToItemType(packet.ReadShort());
            }

            Id                   = packet.ReadLegacyLong();
            Kind                 = packet.ReadInt();
            Category             = (FurniCategory)packet.ReadInt();
            Data                 = StuffData.Parse(packet);
            _Bool1               = packet.ReadBool();
            IsTradeable          = packet.ReadBool();
            IsGroupable          = packet.ReadBool();
            IsSellable           = packet.ReadBool();
            SecondsToExpiration  = packet.ReadInt();
            HasRentPeriodStarted = packet.ReadBool();
            RoomId               = packet.ReadLegacyLong();

            if (packet.Protocol == ClientType.Unity)
            {
                // - Seems to be consistent
                _String1 = packet.ReadString(); // string ""
                _String2 = packet.ReadString(); // string "r" / "s"
                _Int3    = packet.ReadInt();    // int 1187551480
            }

            if (Type == ItemType.Floor)
            {
                if (packet.Protocol == ClientType.Flash)
                {
                    _String2 = packet.ReadString();
                    Extra    = packet.ReadInt();
                }
                else
                {
                    // 10 bytes ?
                    _String3 = packet.ReadString();
                    Extra    = packet.ReadInt();
                    _Int5    = packet.ReadInt();
                }
            }
            else
            {
                _String3 = string.Empty;
            }

            /*if (clientType == ClientType.Flash)
             * {
             *  ItemId = packet.ReadInt();
             *  Type = H.ToItemType(packet.ReadString());
             *  Id = packet.ReadInt();
             *  Kind = packet.ReadInt();
             *  Category = (FurniCategory)packet.ReadInt();
             *  Data = StuffData.Parse(packet, clientType);
             *  _Bool1 = packet.ReadBool();
             *  IsTradeable = packet.ReadBool();
             *  IsGroupable = packet.ReadBool();
             *  IsSellable = packet.ReadBool();
             *  SecondsToExpiration = packet.ReadInt();
             *  HasRentPeriodStarted = packet.ReadBool();
             *  RoomId = packet.ReadInt();
             *
             *  if (Type == ItemType.Floor)
             *  {
             *      _String2 = packet.ReadString();
             *      Extra = packet.ReadInt();
             *  }
             * }
             * else
             * {
             *  ItemId = packet.ReadLong();
             *  Type = H.ToItemType(packet.ReadShort());
             *  Id = packet.ReadLong();
             *  Kind = packet.ReadInt();
             *  Category = (FurniCategory)packet.ReadInt();
             *  Data = StuffData.Parse(packet, clientType);
             *  _Bool1 = packet.ReadBool();
             *  IsTradeable = packet.ReadBool();
             *  IsGroupable = packet.ReadBool();
             *  IsSellable = packet.ReadBool();
             *  SecondsToExpiration = packet.ReadInt();
             *  HasRentPeriodStarted = packet.ReadBool();
             *  RoomId = packet.ReadLong();
             *
             *  // - Seems to be consistent
             *  _String1 = packet.ReadString(); // string ""
             *  _String2 = packet.ReadString(); // string "r" / "s"
             *  _Int3 = packet.ReadInt(); // int 1187551480
             *
             *  if (Type == ItemType.Floor)
             *  {
             *      // 10 bytes ?
             *      _String3 = packet.ReadString();
             *      Extra = packet.ReadInt();
             *      _Int5 = packet.ReadInt();
             *  }
             *  else
             *  {
             *      _String3 = string.Empty;
             *  }
             * }*/
        }
コード例 #30
0
ファイル: ModerationSettings.cs プロジェクト: b7c/Xabbo.Core
 internal ModerationSettings(IReadOnlyPacket packet)
 {
     WhoCanMute = (ModerationPermissions)packet.ReadInt();
     WhoCanKick = (ModerationPermissions)packet.ReadInt();
     WhoCanBan  = (ModerationPermissions)packet.ReadInt();
 }