예제 #1
0
 public HostBanPlayerEventArgs(Func<Task> continuation, int step, HMessage packet)
     : base(continuation, step, packet)
 {
     Id = packet.ReadInteger();
     RoomId = packet.ReadInteger();
     Ban = SKore.ToBan(packet.ReadString());
 }
예제 #2
0
 public HostMoveFurnitureEventArgs(Func<Task> continuation, int step, HMessage packet)
     : base(continuation, step, packet)
 {
     Id = packet.ReadInteger();
     Tile = new HPoint(packet.ReadInteger(), packet.ReadInteger());
     Direction = (HDirection)packet.ReadInteger();
 }
예제 #3
0
 public HostMutePlayerEventArgs(Func<Task> continuation, int step, HMessage packet)
     : base(continuation, step, packet)
 {
     Id = packet.ReadInteger();
     RoomId = packet.ReadInteger();
     Minutes = packet.ReadInteger();
 }
예제 #4
0
 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();
 }
예제 #5
0
        public HostShoutEventArgs(Func<Task> continuation, int step, HMessage packet)
            : base(continuation, step, packet)
        {
            Message = packet.ReadString();

            // TODO: Find the chunks before OwnerId and read them.
            Theme = (HTheme)packet.ReadInteger(packet.Length - 6);
        }
예제 #6
0
        private void RealignBtn_Click(object sender, EventArgs e)
        {
            if (InputBox == null)
            {
                return;
            }

            int packetHeaderEnd = 0;

            if (!InputBox.Text.StartsWith("{l}{u:"))
            {
                ushort packetHeader = 0;
                byte[] packetData   = HMessage.ToBytes(InputBox.Text);
                if (packetData.Length >= 6)
                {
                    int packetLength = BigEndian.ToInt32(packetData, 0);
                    packetHeader = BigEndian.ToUInt16(packetData, 4);

                    byte[] headerData = new byte[6];
                    Buffer.BlockCopy(packetData, 0, headerData, 0, 6);

                    if (packetLength == (packetData.Length - 4))
                    {
                        string formattedHeader = HMessage.ToString(headerData);
                        InputBox.Text = InputBox.Text.Remove(0, formattedHeader.Length);
                    }
                }
                InputBox.Text   = InputBox.Text.Insert(0, $"{{l}}{{u:{packetHeader}}}");
                packetHeaderEnd = packetHeader.ToString().Length;
            }
            else
            {
                string formattedHeader = InputBox.Text
                                         .GetChild("{l}{u:").GetParent("}");

                packetHeaderEnd = formattedHeader.Length;
            }
            InputBox.Select(6, packetHeaderEnd);
        }
예제 #7
0
        private void ProcessIncoming(HMessage previous, ref HMessage current)
        {
            int length = current.Length;

            switch (length)
            {
            case 2:
            {
                break;
            }

            case 4:
            {
                break;
            }

            case 6:
            {
                int intValue = current.ReadInt(0);
                switch (intValue)
                {
                case 4008:
                {
                    _lockedIn[current.Header] = RaiseOnPlayerKickHost;
                    OnPlayerKickHost(new PlayerKickHostEventArgs(current));
                    current = null;
                    break;
                }
                }
                break;
            }

            default:
            {
                break;
            }
            }
        }
예제 #8
0
        public bool IsInjectionAuthorized(HMessage packet)
        {
            if (!IsInjectionAuthorized())
            {
                return(false);
            }
            if (!packet.IsCorrupted)
            {
                return(true);
            }
            else
            {
                byte[] data     = packet.ToBytes();
                string alertMsg = PACKET_LENGTH_INVALID;

                if (data.Length < 6)
                {
                    alertMsg +=
                        $"\r\n\r\nYou're missing {6 - data.Length:#,##0} byte(s).";
                }
                else
                {
                    int length = (data.Length > 0 ?
                                  BigEndian.ToInt32(data, 0) : 0);

                    int  realLength = (data.Length - 4);
                    bool tooShort   = (length > realLength);
                    int  difference = Math.Abs(realLength - length);

                    alertMsg +=
                        $"\r\n\r\nYou're {difference:#,##0} byte(s) too {(tooShort ? "short" : "big")}.";
                }
                MessageBox.Show(alertMsg, "Tanji ~ Alert!",
                                MessageBoxButtons.OK, MessageBoxIcon.Asterisk);

                return(false);
            }
        }
예제 #9
0
 private void DoWork()
 {
     while (IsRunning)
     {
         HMessage imsg = null;
         if (wait)
         {
             imsg = msg_queue.DequeueMessage("timeout", "infinite");
         }
         else
         {
             try
             {
                 // unless we post a message in the queue, we get a timeout
                 // error
                 imsg = msg_queue.DequeueMessage("timeout", 0);
             }
             catch (HalconException)
             {
             }
         }
         if (imsg != null)
         {
             HTuple finish = imsg.GetMessageParam("key_exists", "finish_processing");
             if ((int)finish == 1)
             {
                 lock (locker)
                     running = false;
                 return;
             }
         }
         HMessage msg = ActorTask(imsg);
         if (Next != null)
         {
             Next.AddMessage(msg);
         }
     }
 }
예제 #10
0
        private void HandleIncoming(HMessage packet, int count)
        {
            var args = new InterceptedEventArgs(ReadIncomingAsync, count, packet);

            OnDataIncoming(args);

            if (!args.IsBlocked)
            {
                SendToClientAsync(args.Replacement.ToBytes()).Wait();
                var executeTaskList = new List <Task <int> >(args.Executions.Count);
                for (int i = 0; i < args.Executions.Count; i++)
                {
                    executeTaskList.Add(
                        SendToClientAsync(args.Executions[i].ToBytes()));
                }
                Task.WhenAll(executeTaskList).Wait();
            }

            if (!args.WasContinued)
            {
                Task readInTask = ReadIncomingAsync();
            }
        }
예제 #11
0
        public FurnitureDropEventArgs(Func <Task> continuation, int step, HMessage packet)
            : base(continuation, step, packet)
        {
            Id     = Packet.ReadInteger();
            TypeId = Packet.ReadInteger();

            int x = Packet.ReadInteger();
            int y = Packet.ReadInteger();

            Direction = (HDirection)Packet.ReadInteger();
            Tile      = new HPoint(x, y, double.Parse(Packet.ReadString()));

            Packet.ReadString();
            Packet.ReadInteger();
            Packet.ReadInteger();
            Packet.ReadString();

            IsRental = (Packet.ReadInteger() != 1);
            Packet.ReadInteger();

            OwnerId   = Packet.ReadInteger();
            OwnerName = Packet.ReadString();
        }
예제 #12
0
        public static HMessage PacketBuilder(IList <HEntity> Users, ushort header)
        {
            var ret = new HMessage(header);

            ret.WriteInteger(Users.Count());

            foreach (var obj in Users)
            {
                ret.WriteInteger(obj.Id);
                ret.WriteInteger(obj.Index);
                ret.WriteInteger(obj.Tile.X);
                ret.WriteInteger(obj.Tile.Y);
                ret.WriteInteger(0);
                ret.WriteString(obj.Name);
                ret.WriteString(obj.Motto);
                ret.WriteInteger((int)obj.Gender);
                ret.WriteInteger(obj.EntityType);
                ret.WriteString(obj.FigureId);
                ret.WriteString(obj.FavoriteGroup);
                return(ret);
            }
            return(null);
        }
예제 #13
0
        public HCatalogOffer(HMessage packet)
        {
            Id          = packet.ReadInteger();
            DisplayName = packet.ReadString();
            IsRentable  = packet.ReadBoolean();

            CreditCost        = packet.ReadInteger();
            OtherCurrencyCost = packet.ReadInteger();
            OtherCurrencyType = packet.ReadInteger();
            CanGift           = packet.ReadBoolean();

            Products = new HCatalogProduct[packet.ReadInteger()];
            for (int i = 0; i < Products.Length; i++)
            {
                Products[i] = new HCatalogProduct(packet);
            }

            ClubLevel   = packet.ReadInteger();
            IsPet       = packet.ReadBoolean();
            AllowBundle = packet.ReadBoolean();

            PreviewImage = packet.ReadString();
        }
예제 #14
0
        public void AddSchedule(HMessage packet, int burst, int interval, string description)
        {
            if (packet.IsCorrupted || packet.Destination == HDestination.Unknown)
            {
                throw new Exception("Provided packet is either corrupted, or has Destination set to 'Unknown'.");
            }

            var item = new ListViewItem(new[] { packet.ToString(),
                                                packet.Destination.ToString(), burst.ToString(), interval.ToString(), AutoStart ? RUNNING : STOPPED });

            var schedule = new HSchedule(packet, interval, burst);

            schedule.ScheduleTriggered += OnScheduleTriggered;

            _items.Add(schedule, item);
            _schedules.Add(item, schedule);
            _descriptions.Add(item, description);

            item.Checked     = AutoStart;
            item.ToolTipText = description;

            FocusAdd(item);
        }
예제 #15
0
        public void AddSchedule(HMessage packet, int burst, int interval, string description)
        {
            if (packet.IsCorrupted)
            {
                throw new Exception("Corrupted Packet: " + packet);
            }

            var item = new ListViewItem(new[] { packet.ToString(),
                                                packet.Destination.ToString(), burst.ToString(), interval.ToString(), AutoStart ? "Running" : "Stopped" });

            var schedule = new HSchedule(packet, interval, burst);

            schedule.ScheduleTick += OnScheduleTick;

            _items.Add(schedule, item);
            _schedules.Add(item, schedule);
            _descriptions.Add(item, description);

            item.Checked     = AutoStart;
            item.ToolTipText = description;

            FocusAdd(item);
        }
        public PlayerDropFurnitureEventArgs(HMessage packet)
        {
            _packet = packet;
            Header  = _packet.Header;

            int position = 0;

            FurnitureId     = _packet.ReadInt(ref position);
            FurnitureTypeId = _packet.ReadInt(ref position);
            int x = _packet.ReadInt(ref position);
            int y = _packet.ReadInt(ref position);

            Direction = (HDirection)_packet.ReadInt(ref position);
            Tile      = new HPoint(x, y, _packet.ReadString(ref position));
            _packet.ReadString(ref position);
            _packet.ReadInt(ref position);
            _packet.ReadInt(ref position);
            _packet.ReadString(ref position);
            IsRented = _packet.ReadInt(ref position) != 1;
            _packet.ReadInt(ref position);
            FurnitureOwnerId   = _packet.ReadInt(ref position);
            FurnitureOwnerName = _packet.ReadString(ref position);
        }
예제 #17
0
        public PlayerSignEventArgs(HMessage packet)
        {
            _packet = packet;
            Header  = _packet.Header;
            int    x, y;
            string z, actionTxt;

            int position = 0;

            PlayerCount   = _packet.ReadInt(ref position);
            PlayerIndex   = _packet.ReadInt(ref position);
            x             = _packet.ReadInt(ref position);
            y             = _packet.ReadInt(ref position);
            z             = _packet.ReadString(ref position);
            HeadDirection = (HDirection)_packet.ReadInt(ref position);
            BodyDirection = (HDirection)_packet.ReadInt(ref position);
            actionTxt     = _packet.ReadString(ref position);
            actionTxt     = actionTxt.GetChild("//sign ", '/');
            Sign          = (HSign)int.Parse(actionTxt);


            Tile = new HPoint(x, y, z);
        }
예제 #18
0
        public FurnitureDropEventArgs(Func<Task> continuation, int step, HMessage packet)
            : base(continuation, step, packet)
        {
            Id = Packet.ReadInteger();
            TypeId = Packet.ReadInteger();

            int x = Packet.ReadInteger();
            int y = Packet.ReadInteger();

            Direction = (HDirection)Packet.ReadInteger();
            Tile = new HPoint(x, y, double.Parse(Packet.ReadString()));

            Packet.ReadString();
            Packet.ReadInteger();
            Packet.ReadInteger();
            Packet.ReadString();

            IsRental = (Packet.ReadInteger() != 1);
            Packet.ReadInteger();

            OwnerId = Packet.ReadInteger();
            OwnerName = Packet.ReadString();
        }
예제 #19
0
 protected virtual void WriteValue(string type, object value, byte[] data, int amount)
 {
     lock (_values)
     {
         BeginUpdate();
         string encoded = HMessage.ToString(data);
         for (int i = 0; i < amount; i++)
         {
             _values.Add(value);
             ListViewItem item = null;
             if (i != (amount - 1))
             {
                 item = AddItem(type, value, encoded);
             }
             else
             {
                 item = AddFocusedItem(type, value, encoded);
             }
         }
         EndUpdate();
         _cachedPacket = null;
     }
 }
예제 #20
0
        private void InterceptOutgoing()
        {
            HMessage packet = Local.ReceivePacket();

            if (packet != null)
            {
                var args = new DataInterceptedEventArgs(packet, ++_outSteps, true);
                try { OnDataOutgoing(args); }
                catch { args.Restore(); }

                if (!args.IsBlocked && !args.WasRelayed)
                {
                    SendToServer(args.Packet);
                }
                if (!args.HasContinued)
                {
                    Task.Factory.StartNew(InterceptOutgoing);
                }
            }
            else
            {
                Disconnect();
            }
        }
예제 #21
0
        private void Connected(object sender, ConnectedEventArgs e)
        {
            if (InvokeRequired)
            {
                Invoke(_connected, sender, e);
                return;
            }

            HMessage remoteEndPointPkt = Connection.Local.ReceivePacketAsync().Result;

            e.HotelServer           = ConnectionPg.HotelServer = HotelEndPoint.Parse(remoteEndPointPkt.ReadString().Split('\0')[0], remoteEndPointPkt.ReadInteger());
            e.IsFakingPolicyRequest = (e.HotelServer.Hotel == HHotel.Unknown);

            ConnectionPg.IsReceiving = true;
            Text    = $"Tanji ~ Connected[{e.HotelServer}]";
            TopMost = PacketLoggerUI.TopMost;

            PacketLoggerUI.RevisionTxt.Text = ("Revision: " + Game.Revision);

            PacketLoggerUI.Show();
            PacketLoggerUI.WindowState = FormWindowState.Normal;

            BringToFront();
        }
예제 #22
0
        public void init(HMessage message)
        {
            Id          = message.ReadInteger();
            Catalogname = message.ReadString();
            message.ReadBoolean();
            CreditCost  = message.ReadInteger();
            SpecialCost = message.ReadInteger();
            SpecialType = message.ReadInteger();
            AllowGift   = message.ReadBoolean();
            int ccount = message.ReadInteger();

            for (int p = 0; p < ccount; p++)
            {
                string type = message.ReadString();
                if (type == "b")
                {
                    Badge = message.ReadString();
                }
                else
                {
                    sprite_id   = message.ReadInteger();
                    SpecialData = message.ReadString();
                    Amount      = message.ReadInteger();
                    Limited     = message.ReadBoolean();
                    if (Limited)
                    {
                        message.ReadInteger();
                        message.ReadInteger();
                    }
                }
            }
            message.ReadInteger();
            message.ReadBoolean();
            message.ReadBoolean();
            message.ReadString();
        }
예제 #23
0
        private void InterceptIncoming()
        {
            HMessage packet = Remote.ReceivePacket();

            if (packet != null)
            {
                var args = new DataInterceptedEventArgs(packet, ++_inSteps, false);
                try { OnDataIncoming(args); }
                catch { args.Restore(); }

                if (!args.IsBlocked && !args.WasRelayed)
                {
                    SendToClient(args.Packet);
                }
                if (!args.HasContinued)
                {
                    Task.Factory.StartNew(InterceptIncoming);
                }
            }
            else
            {
                Disconnect();
            }
        }
예제 #24
0
        /// <summary>
        /// Determines whether the outgoing packet should be blocked, otherwise attempts to apply the filters related to the packet.
        /// </summary>
        /// <param name="packet">The outgoing packet to process.</param>
        /// <param name="repeat">The value type to update with the number of times the packet should be repeated.</param>
        /// <returns>true if the packet should be blocked; otherwise false.</returns>
        public virtual bool OutProcessFilters(ref HMessage packet)
        {
            bool passedBlockCheck = false;

            try
            {
                if (_outBlockedHeaders.Contains(packet.Header) || (_outBlockConditions.ContainsKey(packet.Header) &&
                                                                   _outBlockConditions[packet.Header](packet)))
                {
                    return(true);
                }

                passedBlockCheck = true;

                if (_outReplacements.ContainsKey(packet.Header))
                {
                    packet = _outReplacements[packet.Header];
                }
                else if (_outReplacers.ContainsKey(packet.Header))
                {
                    packet = _outReplacers[packet.Header](packet);
                }
            }
            catch
            {
                if (!passedBlockCheck)
                {
                    OutUnblock(packet.Header);
                }
                else
                {
                    OutUnreplace(packet.Header);
                }
            }
            return(false);
        }
예제 #25
0
        public HFurniture(HMessage packet)
        {
            Id     = packet.ReadInteger();
            TypeId = packet.ReadInteger();

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

            var loc1 = packet.ReadString();
            var loc3 = packet.ReadInteger();

            Category = packet.ReadInteger();
            Stuff    = ReadData(packet, Category);

            var loc4 = packet.ReadInteger();
            var loc5 = packet.ReadInteger();

            OwnerId = packet.ReadInteger();
            if (TypeId < 0)
            {
                var loc6 = packet.ReadString();
            }
        }
예제 #26
0
        private void PTLengthHeaderBtn_Click(object sender, EventArgs e)
        {
            int endSelect = 0;

            if (!MainUI.PTPacketTxt.Text.StartsWith("{l}{u:"))
            {
                string headerString = "0";
                byte[] data         = HMessage.ToBytes(MainUI.PTPacketTxt.Text);
                if (data.Length >= 6)
                {
                    int    length = BigEndian.ToSI32(data);
                    ushort header = BigEndian.ToUI16(data, 4);

                    byte[] headerLength = new byte[6];
                    Buffer.BlockCopy(data, 0, headerLength, 0, 6);

                    if (length == (data.Length - 4))
                    {
                        headerString = header.ToString();
                        string toReplace = HMessage.ToString(headerLength);
                        MainUI.PTPacketTxt.Text = MainUI.PTPacketTxt.Text.Remove(0, toReplace.Length);
                    }
                }

                MainUI.PTPacketTxt.Text = MainUI.PTPacketTxt.Text.Insert(0, $"{{l}}{{u:{headerString}}}");
                endSelect = headerString.Length;
            }
            else
            {
                string headerLengthParamValue = MainUI.PTPacketTxt.Text
                                                .GetChild("{l}{u:").GetParent("}");

                endSelect = headerLengthParamValue.Length;
            }
            MainUI.PTPacketTxt.Select(6, endSelect);
        }
예제 #27
0
        private bool TryHandleAvatarMenuClick(HMessage current, HMessage previous)
        {
            if (!previous.CanRead <string>(22))
            {
                return(false);
            }
            switch (previous.ReadString(22))
            {
            case "sit":
            case "stand":
            {
                OutgoingHeaders.UpdateStance = current.Header;
                _outLocked[current.Header]   = RaiseOnHostUpdateStance;
                return(true);
            }

            case "dance_stop":
            case "dance_start":
            {
                OutgoingHeaders.Dance      = current.Header;
                _outLocked[current.Header] = RaiseOnHostDance;
                return(true);
            }

            case "wave":
            case "idle":
            case "laugh":
            case "blow_kiss":
            {
                OutgoingHeaders.Gesture    = current.Header;
                _outLocked[current.Header] = RaiseOnHostGesture;
                return(true);
            }
            }
            return(false);
        }
예제 #28
0
        private bool TryHandleHostRaiseSign(HMessage current, HMessage previous)
        {
            if (previous.Length != 6)
            {
                return(false);
            }
            if (previous.ReadInteger(0) > 18)
            {
                return(false);
            }

            if (!current.CanReadString(22))
            {
                return(false);
            }
            if (current.ReadString(22) != "sign")
            {
                return(false);
            }

            OutgoingDetected.RaiseSign   = previous.Header;
            OutDetected[previous.Header] = RaiseOnHostRaiseSign;
            return(true);
        }
예제 #29
0
        /// <summary>
        /// The client MUST be connected to access to this service.
        /// Allow a hubapp client to create a hMessage with a hConvState payload.
        /// </summary>
        /// <param name="actor"></param>
        /// <param name="convid"></param>
        /// <param name="status"></param>
        /// <param name="mOptions"></param>
        /// <returns></returns>
        public HMessage BuildConvState(string actor, string convid, string status, HMessageOptions mOptions)
        {
            if (actor == null || actor.Length <= 0)
            {
                throw new MissingAttrException("actor");
            }
            if (convid == null || convid.Length <= 0)
            {
                throw new MissingAttrException("convid");
            }
            if (status == null || status.Length <= 0)
            {
                throw new MissingAttrException("status");
            }

            HConvState convState = new HConvState();

            convState.SetStatus(status);

            HMessage message = BuildMessage(actor, "hConvState", convState, mOptions);

            message.SetConvid(convid);
            return(message);
        }
예제 #30
0
        /// <summary>
        /// The client MUST be connected to access to this service.
        /// Allow a hubapp client to create a hMessage with a hMeasure payload.
        /// </summary>
        /// <param name="actor"></param>
        /// <param name="value"></param>
        /// <param name="unit"></param>
        /// <param name="mOptions"></param>
        /// <returns></returns>
        public HMessage BuildMeasure(string actor, string value, string unit, HMessageOptions mOptions)
        {
            if (actor == null || actor.Length <= 0)
            {
                throw new MissingAttrException("actor");
            }
            if (value == null || value.Length <= 0)
            {
                throw new MissingAttrException("value");
            }
            if (unit == null || unit.Length <= 0)
            {
                throw new MissingAttrException("unit");
            }

            HMeasure hmeasure = new HMeasure();

            hmeasure.SetUnit(unit);
            hmeasure.SetValue(value);

            HMessage message = BuildMessage(actor, "hMeasure", hmeasure, mOptions);

            return(message);
        }
예제 #31
0
        public virtual void ProcessIncoming(byte[] data)
        {
            var packet = new HMessage(data, HDestination.Client);

            if (_inCallbacks.Count > 0 && _inCallbacks.ContainsKey(packet.Header))
            {
                _inCallbacks[packet.Header](packet);
                packet.Position = 0;
            }
            if (!CaptureEvents)
            {
                return;
            }
            try
            {
                HMessage previousIncoming = (_previousIncoming.Count > 0 ? _previousIncoming.Pop() : null);
                if (LockEvents && _lockedIn.ContainsKey(packet.Header))
                {
                    _lockedIn[packet.Header](packet);
                    packet = null;
                }
                else
                {
                    ProcessIncoming(previousIncoming, ref packet);
                }
            }
            catch { packet = null; }
            finally
            {
                if (packet != null)
                {
                    packet.Position = 0;
                    _previousIncoming.Push(packet);
                }
            }
        }
예제 #32
0
 public HostTradeEventArgs(int step, HMessage packet)
     : this(null, step, packet)
 { }
예제 #33
0
 public HostClickPlayerEventArgs(Func<Task> continuation, int step, HMessage packet)
     : base(continuation, step, packet)
 {
     Id = packet.ReadInteger();
     Tile = new HPoint(packet.ReadInteger(), packet.ReadInteger());
 }
예제 #34
0
 public HostClickPlayerEventArgs(HMessage packet)
     : this(null, -1, packet)
 { }
예제 #35
0
 private void SavePacket(DataInterceptedEventArgs obj)
 {
     place_furni            = obj.Packet; //{l}{u:1956}{i:837444}{i:9123}{s:}{i:5}{i:5}{i:0} //Saves the packet to place a BC furni
     lbl_start_hint.Visible = false;
     btn_start.Enabled      = true;
 }
예제 #36
0
 public HostGestureEventArgs(HMessage packet)
     : this(null, -1, packet)
 { }
예제 #37
0
 public PlayerGestureEventArgs(int step, HMessage packet)
     : this(null, step, packet)
 { }
예제 #38
0
파일: HTriggers.cs 프로젝트: habb0/Sulakore
        private bool TryHandleHostNavigateRoom(HMessage current, HMessage previous)
        {
            if (previous.Length >= 12 &&
                current.CanRead<string>(0) &&
                current.ReadString() == "Navigation")
            {
                current.ReadString();
                if (current.ReadString() != "go.official") return false;

                if (previous.ReadInteger(0).ToString() == current.ReadString())
                {
                    OutgoingHeaders.NavigateRoom = previous.Header;

                    _outLocked[previous.Header] = RaiseOnHostNavigateRoom;
                    return true;
                }
            }
            return false;
        }
예제 #39
0
        public static IReadOnlyList<HFurniture> Parse(HMessage packet)
        {
            int ownersCount = packet.ReadInteger();
            var owners = new Dictionary<int, string>(ownersCount);

            for (int i = 0; i < ownersCount; i++)
            {
                int ownerId = packet.ReadInteger();
                string ownerName = packet.ReadString();

                owners.Add(ownerId, ownerName);
            }

            int furnitureCount = packet.ReadInteger();
            var furnitureList = new List<HFurniture>(furnitureCount);

            for (int i = 0; i < furnitureList.Capacity; i++)
            {
                int id = packet.ReadInteger();
                int typeId = packet.ReadInteger();

                int x = packet.ReadInteger();
                int y = packet.ReadInteger();
                var direction = (HDirection)packet.ReadInteger();
                double z = double.Parse(packet.ReadString());

                packet.ReadString();
                packet.ReadInteger();

                int categoryId = (packet.ReadInteger() & 0xFF);
                #region Switch Statement: categoryId
                switch (categoryId)
                {
                    case 0:
                    {
                        packet.ReadString();
                        break;
                    }
                    case 1:
                    {
                        int count = packet.ReadInteger();
                        for (int j = 0; j < count; j++)
                        {
                            packet.ReadString();
                            packet.ReadString();
                        }
                        break;
                    }
                    case 2:
                    {
                        int count = packet.ReadInteger();
                        for (int j = 0; j < count; j++)
                        {
                            packet.ReadString();
                        }
                        break;
                    }
                    case 3:
                    {
                        packet.ReadString();
                        packet.ReadInteger();
                        break;
                    }
                    case 5:
                    {
                        int count = packet.ReadInteger();
                        for (int j = 0; j < count; j++)
                        {
                            packet.ReadInteger();
                        }
                        break;
                    }
                    case 6:
                    {
                        packet.ReadString();
                        packet.ReadInteger();
                        packet.ReadInteger();

                        int count = packet.ReadInteger();
                        for (int j = 0; j < count; j++)
                        {
                            int subCount = packet.ReadInteger();
                            for (int k = 0; k < subCount; k++)
                            {
                                packet.ReadString();
                            }
                        }
                        break;
                    }
                    case 7:
                    {
                        packet.ReadString();
                        packet.ReadInteger();
                        packet.ReadInteger();
                        break;
                    }
                }
                #endregion

                packet.ReadInteger();
                packet.ReadInteger();

                int ownerId = packet.ReadInteger();
                if (typeId < 0) packet.ReadString();

                var furniture = new HFurniture(id, typeId, ownerId,
                    owners[ownerId], new HPoint(x, y, z), direction);

                furnitureList.Add(furniture);
            }
            
            return furnitureList;
        }
예제 #40
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InterceptedEventArgs"/> class.
 /// </summary>
 /// <param name="packet">The intercepted data to read/write from.</param>
 public InterceptedEventArgs(HMessage packet)
     : this(null, -1, packet)
 { }
예제 #41
0
 public HostGestureEventArgs(Func<Task> continuation, int step, HMessage packet)
     : base(continuation, step, packet)
 {
     Gesture = (HGesture)packet.ReadInteger();
 }
예제 #42
0
 public HostWalkEventArgs(Func<Task> continuation, int step, HMessage packet)
     : base(continuation, step, packet)
 {
     Tile = new HPoint(packet.ReadInteger(0),
         packet.ReadInteger(4));
 }
예제 #43
0
 public HostUpdateMottoEventArgs(Func<Task> continuation, int step, HMessage packet)
     : base(continuation, step, packet)
 {
     Motto = packet.ReadString();
 }
예제 #44
0
 private void callback(HMessage msg)
 {
     Debug.WriteLine(">>>[Callback]<<< \n " + msg.ToString() + "\n");
     Update_TextBlock_UI(msgScreen, ">>>CallBack<<< \n" + msg.ToString());
 }
예제 #45
0
 public PlayerGestureEventArgs(HMessage packet)
     : this(null, -1, packet)
 { }
예제 #46
0
 public int SendToServer(ushort Header, params object[] Chunks)
 {
     return(SendToServer(HMessage.Construct(Header, HDestinations.Server, Protocol, Chunks)));
 }
예제 #47
0
 public PlayerGestureEventArgs(Func<Task> continuation, int step, HMessage packet)
     : base(continuation, step, packet)
 {
     Index = packet.ReadInteger();
     Gesture = (HGesture)packet.ReadInteger();
 }
예제 #48
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InterceptedEventArgs"/> class.
 /// </summary>
 /// <param name="step">The current count/step/order from which this data was intercepted.</param>
 /// <param name="packet">The intercepted data to read/write from.</param>
 public InterceptedEventArgs(int step, HMessage packet)
     : this(null, step, packet)
 { }
예제 #49
0
 public void AddSchedule(HMessage packet, int interval, int cycles, bool autoStart)
 {
     AddSchedule(packet, interval, cycles, null, autoStart);
 }
예제 #50
0
 public FurnitureDropEventArgs(HMessage packet)
     : this(null, -1, packet)
 { }
예제 #51
0
 private void Form1_Load(object sender, EventArgs e)
 {
     pickallbc = new HMessage(Out.RoomUserTalk, new object[] { ":pickallbc", 0, -1 }); //{l}{u:588}{s::pickallbc}{i:0}{i:-1}
 }
예제 #52
0
 public FurnitureDropEventArgs(int step, HMessage packet)
     : this(null, step, packet)
 { }
예제 #53
0
 public HostDanceEventArgs(Func<Task> continuation, int step, HMessage packet)
     : base(continuation, step, packet)
 {
     Dance = (HDance)packet.ReadInteger();
 }
예제 #54
0
 public HostWalkEventArgs(HMessage packet)
     : this(null, -1, packet)
 { }
예제 #55
0
 public HostClickPlayerEventArgs(int step, HMessage packet)
     : this(null, step, packet)
 { }
예제 #56
0
 public HostUpdateMottoEventArgs(HMessage packet)
     : this(null, -1, packet)
 { }
예제 #57
0
 public HostTradeEventArgs(HMessage packet)
     : this(null, -1, packet)
 { }
예제 #58
0
 public HostUpdateMottoEventArgs(int step, HMessage packet)
     : this(null, step, packet)
 { }
예제 #59
0
 public HostTradeEventArgs(Func<Task> continuation, int step, HMessage packet)
     : base(continuation, step, packet)
 {
     Index = packet.ReadInteger();
 }
예제 #60
0
        /// <summary>
        /// Initializes a new instance of the <see cref="InterceptedEventArgs"/> class.
        /// </summary>
        /// <param name="continuation">The <see cref="Func{TResult}"/> of type <see cref="Task"/> that will be invoked when <see cref="ContinueRead"/> is called.</param>
        /// <param name="step">The current count/step/order from which this data was intercepted.</param>
        /// <param name="packet">The intercepted data to read/write from.</param>
        public InterceptedEventArgs(Func<Task> continuation, int step, HMessage packet)
        {
            Continuation = continuation;
            IsAsyncCapable = (Continuation != null);

            Step = step;
            Packet = packet;
        }