Example #1
0
        protected virtual bool HandleIncoming(HMessage current, HMessage previous)
        {
            if (current.Length == 6)
            {
                // Range: 6
                if (TryHandlePlayerKickHost(current, previous))
                {
                    return(true);
                }
            }
            else if (current.Length >= 35)
            {
                if (TryHandleEntityAction(current, previous))
                {
                    return(true);
                }
                if (TryHandleFurnitureMove(current, previous))
                {
                    return(true);
                }
            }

            return(InDetected.ContainsKey(current.Header) ||
                   InDetected.ContainsKey(previous.Header));
        }
Example #2
0
        public void HandleIncoming(InterceptedEventArgs e)
        {
            bool ignoreCurrent = true;

            try
            {
                e.Packet.Position = 0;
                if (_inAttaches.ContainsKey(e.Packet.Header))
                {
                    _inAttaches[e.Packet.Header](e);
                }

                if (DetectIncoming)
                {
                    e.Packet.Position = 0;
                    HMessage previous = _inPrevious.Count > 0 ?
                                        _inPrevious.Pop() : e.Packet;

                    bool currentDetected  = InDetected.ContainsKey(e.Packet.Header);
                    bool previousDetected = InDetected.ContainsKey(previous.Header);

                    if (!currentDetected && !previousDetected)
                    {
                        ignoreCurrent = HandleIncoming(e.Packet, previous);
                    }

                    if (ignoreCurrent)
                    {
                        e.Packet.Position     =
                            previous.Position = 0;

                        if (InDetected.ContainsKey(e.Packet.Header))
                        {
                            InDetected[e.Packet.Header](e);
                        }
                        else if (InDetected.ContainsKey(previous.Header))
                        {
                            var args = new InterceptedEventArgs(null, e.Step - 1, previous);
                            InDetected[previous.Header](args);
                        }
                    }
                }
            }
            finally
            {
                e.Packet.Position = 0;

                if (DetectIncoming && !ignoreCurrent)
                {
                    _inPrevious.Push(e.Packet);
                }
            }
        }