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); } } }
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)); }
protected virtual void Dispose(bool disposing) { if (IsDisposed) { return; } if (disposing) { _inPrevious.Clear(); _outPrevious.Clear(); InDetected.Clear(); OutDetected.Clear(); _inAttaches.Clear(); _outAttaches.Clear(); #region Unsubscribe Game Events SKore.Unsubscribe(ref HostBanPlayer); SKore.Unsubscribe(ref HostUpdateClothes); SKore.Unsubscribe(ref HostUpdateMotto); SKore.Unsubscribe(ref HostUpdateStance); SKore.Unsubscribe(ref HostClickPlayer); SKore.Unsubscribe(ref HostDance); SKore.Unsubscribe(ref HostGesture); SKore.Unsubscribe(ref HostKickPlayer); SKore.Unsubscribe(ref HostMoveFurniture); SKore.Unsubscribe(ref HostMutePlayer); SKore.Unsubscribe(ref HostRaiseSign); SKore.Unsubscribe(ref HostExitRoom); SKore.Unsubscribe(ref HostNavigateRoom); SKore.Unsubscribe(ref HostSay); SKore.Unsubscribe(ref HostShout); SKore.Unsubscribe(ref HostTradePlayer); SKore.Unsubscribe(ref HostWalk); SKore.Unsubscribe(ref FurnitureLoad); SKore.Unsubscribe(ref EntityAction); SKore.Unsubscribe(ref PlayerUpdate); SKore.Unsubscribe(ref PlayerDance); SKore.Unsubscribe(ref EntityLoad); SKore.Unsubscribe(ref FurnitureDrop); SKore.Unsubscribe(ref PlayerGesture); SKore.Unsubscribe(ref PlayerKickHost); SKore.Unsubscribe(ref FurnitureMove); #endregion } IsDisposed = true; }