public static void InvokeFastWalk(FastWalkEventArgs e) { if (FastWalk != null) { FastWalk(e); } }
public static void OnFastWalk( FastWalkEventArgs e ) { if (!m_Blocks.ContainsKey(e.NetState.Mobile)) { m_Blocks.Add(e.NetState.Mobile, new List<DateTime>()); } m_Blocks[e.NetState.Mobile].Add(DateTime.Now); if (ProtectionEnabled) { e.Blocked = true;//disallow this fastwalk //Console.WriteLine("Client: {0}: Fast movement detected (name={1})", e.NetState, e.NetState.Mobile.Name); } try { List<DateTime> blocks = m_Blocks[e.NetState.Mobile]; if (e.FastWalkCount > WarningThreshold && blocks.Count >= 2 && // sanity check, shouldn't be possible to reach this point w/o Count >= 2 (blocks[blocks.Count - 1] - blocks[blocks.Count - 2]) > WarningCooldown) { Console.WriteLine("FW Warning"); } } catch (Exception ex) // we can only exception if Mobile.FwdMaxSteps < 2 - make sure SecurityManagementConsole doesn't set it too low { LogHelper.LogException(ex); Console.WriteLine(ex); } }
public static void InvokeFastWalk(FastWalkEventArgs e) { if (EventSink.FastWalk != null) { EventSink.FastWalk.Invoke(e); } }
public static void OnFastWalk( FastWalkEventArgs e ) { e.Blocked = true;//disallow this fastwalk PlayerMobile pm = e.NetState.Mobile as PlayerMobile; if (pm != null && pm.CheckFastWalk()) CommandHandlers.BroadcastMessage(AccessLevel.Seer, 0x482, String.Format("Possible tile skip ({0}) detected by: {1}.", pm.FastWalkCount, CommandLogging.Format(pm)) ); }
public static void OnFastWalk( FastWalkEventArgs e ) { Mobile m = e.NetState.Mobile; e.Blocked = true;//disallow this fastwalk if ( TestCenter.Enabled ) e.NetState.Mobile.SendMessage( "Please slow down!! ({0}) ({1} seconds)", m.MoveRecords.Count - Mobile.FwdMaxSteps, (m.EndQueue - DateTime.Now).TotalSeconds ); PublicOverheadMessage( e.NetState.Mobile, MessageType.Regular, 33, String.Format( "[Fastwalk]: Speed Detected!!! ({0}) ({1} seconds)", m.MoveRecords.Count - Mobile.FwdMaxSteps, (m.EndQueue - DateTime.Now).TotalSeconds ) ); if ( m.MoveRecords.Count - Mobile.FwdMaxSteps >= 20 ) { e.NetState.Mobile.SendMessage( "You have been kicked for excessive movement or network latency issues. Please check your network connection, or third party software before logging in." ); m.NetState.Dispose(); } }
public static void OnFastWalk( FastWalkEventArgs e ) { e.Blocked = true;//disallow this fastwalk Console.WriteLine( "Client: {0}: Fast movement detected (name={1})", e.NetState, e.NetState.Mobile.Name ); }
public static void InvokeFastWalk(FastWalkEventArgs e) { FastWalk?.Invoke(e); }
public static void InvokeFastWalk( FastWalkEventArgs e ) { if ( FastWalk != null ) FastWalk( e ); }
public virtual bool Move( Direction d ) { if ( m_Deleted ) return false; BankBox box = FindBankNoCreate(); if ( box != null && box.Opened ) box.Close(); Point3D newLocation = Location; Point3D oldLocation = newLocation; if ( (m_Direction & Direction.Mask) == (d & Direction.Mask) ) { // We are actually moving (not just a direction change) if ( m_Spell != null && !m_Spell.OnCasterMoving( d ) ) return false; if ( m_Paralyzed || m_Frozen ) { SendLocalizedMessage( 500111 ); // You are frozen and can not move. return false; } int newZ; if ( CheckMovement( d, out newZ ) ) { int x = m_Location.m_X, y = m_Location.m_Y; int oldX = x, oldY = y; int oldZ = m_Location.m_Z; switch ( d & Direction.Mask ) { case Direction.North: --y; break; case Direction.Right: ++x; --y; break; case Direction.East: ++x; break; case Direction.Down: ++x; ++y; break; case Direction.South: ++y; break; case Direction.Left: --x; ++y; break; case Direction.West: --x; break; case Direction.Up: --x; --y; break; } m_Pushing = false; Map map = m_Map; if ( map != null ) { Sector oldSector = map.GetSector( oldX, oldY ); Sector newSector = map.GetSector( x, y ); ArrayList list; if ( oldSector != newSector ) { list = oldSector.Mobiles; for ( int i = 0; i < list.Count; ++i ) { Mobile m = (Mobile)list[i]; if ( m != this && m.X == oldX && m.Y == oldY && (m.Z + 15) > oldZ && (oldZ + 15) > m.Z && !m.OnMoveOff( this ) ) return false; } list = oldSector.Items; for ( int i = 0; i < list.Count; ++i ) { Item item = (Item)list[i]; if ( item.AtWorldPoint( oldX, oldY ) && (item.Z == oldZ || ((item.Z + item.ItemData.Height) > oldZ && (oldZ + 15) > item.Z)) && !item.OnMoveOff( this ) ) return false; } list = newSector.Mobiles; for ( int i = 0; i < list.Count; ++i ) { Mobile m = (Mobile)list[i]; if ( m.X == x && m.Y == y && (m.Z + 15) > newZ && (newZ + 15) > m.Z && !m.OnMoveOver( this ) ) return false; } list = newSector.Items; for ( int i = 0; i < list.Count; ++i ) { Item item = (Item)list[i]; if ( item.AtWorldPoint( x, y ) && (item.Z == newZ || ((item.Z + item.ItemData.Height) > newZ && (newZ + 15) > item.Z)) && !item.OnMoveOver( this ) ) return false; } } else { list = oldSector.Mobiles; for ( int i = 0; i < list.Count; ++i ) { Mobile m = (Mobile)list[i]; if ( m != this && m.X == oldX && m.Y == oldY && (m.Z + 15) > oldZ && (oldZ + 15) > m.Z && !m.OnMoveOff( this ) ) return false; else if ( m.X == x && m.Y == y && (m.Z + 15) > newZ && (newZ + 15) > m.Z && !m.OnMoveOver( this ) ) return false; } list = oldSector.Items; for ( int i = 0; i < list.Count; ++i ) { Item item = (Item)list[i]; if ( item.AtWorldPoint( oldX, oldY ) && (item.Z == oldZ || ((item.Z + item.ItemData.Height) > oldZ && (oldZ + 15) > item.Z)) && !item.OnMoveOff( this ) ) return false; else if ( item.AtWorldPoint( x, y ) && (item.Z == newZ || ((item.Z + item.ItemData.Height) > newZ && (newZ + 15) > item.Z)) && !item.OnMoveOver( this ) ) return false; } } Region region = Region.Find( new Point3D( x, y, newZ ), m_Map ); if ( region != null && !region.OnMoveInto( this, d, new Point3D( x, y, newZ ), oldLocation ) ) return false; } else { return false; } if ( !InternalOnMove( d ) ) return false; if ( m_FwdEnabled && m_NetState != null && m_AccessLevel < m_FwdAccessOverride && (!m_FwdUOTDOverride || (m_NetState.Version != null && m_NetState.Version.Type != ClientType.UOTD)) ) { if ( m_MoveRecords == null ) m_MoveRecords = new Queue( 6 ); while ( m_MoveRecords.Count > 0 ) { MovementRecord r = (MovementRecord)m_MoveRecords.Peek(); if ( r.Expired() ) m_MoveRecords.Dequeue(); else break; } if ( m_MoveRecords.Count >= m_FwdMaxSteps ) { FastWalkEventArgs fw = new FastWalkEventArgs( m_NetState ); EventSink.InvokeFastWalk( fw ); if ( fw.Blocked ) return false; } TimeSpan delay; if ( Mounted ) delay = (d & Direction.Running) != 0 ? m_RunMount : m_WalkMount; else delay = (d & Direction.Running) != 0 ? m_RunFoot : m_WalkFoot; DateTime end; if ( m_MoveRecords.Count > 0 ) end = m_EndQueue + delay; else end = Core.Now + delay; m_MoveRecords.Enqueue( MovementRecord.NewInstance( end ) ); m_EndQueue = end; } m_LastMoveTime = Core.Now; newLocation = new Point3D( x, y, newZ ); } else { return false; } DisruptiveAction(); } if ( m_NetState != null ) m_NetState.Send( MovementAck.Instantiate( m_NetState.Sequence, this ) );//new MovementAck( m_NetState.Sequence, this ) ); SetLocation( newLocation, false ); SetDirection( d ); if ( m_Map != null ) { IRecyclablePacket[] cache = m_MovingPacketCache; for ( int i = 0; i < cache.Length; ++i ) cache[i] = null; IPooledEnumerable eable = m_Map.GetObjectsInRange( m_Location, Core.GlobalMaxUpdateRange ); foreach ( object o in eable ) { if ( o == this ) continue; if ( o is Mobile ) { m_MoveList.Add( o ); } else if ( o is Item ) { Item item = (Item)o; if ( item.HandlesOnMovement ) m_MoveList.Add( item ); } } eable.Free(); for ( int i = 0; i < m_MoveList.Count; ++i ) { object o = m_MoveList[i]; if ( o is Mobile ) { Mobile m = (Mobile)m_MoveList[i]; NetState ns = m.NetState; if ( ns != null && Utility.InUpdateRange( m_Location, m.m_Location ) && m.CanSee( this ) ) { int noto = Notoriety.Compute( m, this ); IRecyclablePacket p = cache[noto]; if ( p == null ) p = cache[noto] = MobileMoving.GetInstance(this, noto); ns.Send( p ); } m.OnMovement( this, oldLocation ); } else if ( o is Item ) { ((Item)o).OnMovement( this, oldLocation ); } } if ( m_MoveList.Count > 0 ) m_MoveList.Clear(); for (int i = 0; i < cache.Length; ++i) { if (cache[i] != null) { cache[i].Dispose(); cache[i] = null; } } } return true; }
public static void OnFastWalk( FastWalkEventArgs e ) { e.Blocked = true;//disallow this fastwalk log.Warn(String.Format("Client: {0}: Fast movement detected (name={1})", e.NetState, e.NetState.Mobile.Name)); }
public static void InvokeFastWalk(FastWalkEventArgs args) { FastWalk?.Invoke(args); }
public static void InvokeFastWalk(FastWalkEventArgs e) { if (FastWalk != null) { foreach (FastWalkEventHandler currentDelegate in FastWalk.GetInvocationList()) { try { currentDelegate.Invoke(e); } catch (Exception ex) { // Log an exception EventSink.InvokeLogException(new LogExceptionEventArgs(ex)); } } } }
//private int m_FastWalkCount = 0; public virtual bool Move(Direction d) { if (m_Deleted) return false; BankBox box = FindBankNoCreate(); if (box != null && box.Opened) box.Close(); Point3D newLocation = m_Location; Point3D oldLocation = newLocation; if ((m_Direction & Direction.Mask) == (d & Direction.Mask)) { // We are actually moving (not just a direction change) if (m_Spell != null && !m_Spell.OnCasterMoving(d)) return false; if (m_Paralyzed || m_Frozen) { SendLocalizedMessage(500111); // You are frozen and can not move. return false; } int newZ; if (CheckMovement(d, out newZ)) { int x = oldLocation.m_X, y = oldLocation.m_Y; int oldX = x, oldY = y; int oldZ = oldLocation.m_Z; switch (d & Direction.Mask) { case Direction.North: --y; break; case Direction.Right: ++x; --y; break; case Direction.East: ++x; break; case Direction.Down: ++x; ++y; break; case Direction.South: ++y; break; case Direction.Left: --x; ++y; break; case Direction.West: --x; break; case Direction.Up: --x; --y; break; } newLocation.m_X = x; newLocation.m_Y = y; newLocation.m_Z = newZ; m_Pushing = false; Map map = m_Map; if (map != null) { Sector oldSector = map.GetSector(oldX, oldY); Sector newSector = map.GetSector(x, y); ArrayList OnMoveOff = new ArrayList(); ArrayList OnMoveOver = new ArrayList(); if (oldSector != newSector) { foreach (Mobile m in oldSector.Mobiles.Values) { if (m == null) continue; if (m != this && m.X == oldX && m.Y == oldY && (m.Z + 15) > oldZ && (oldZ + 15) > m.Z) OnMoveOff.Add(m); } foreach (Mobile m in OnMoveOff) if (!m.OnMoveOff(this)) return false; OnMoveOff.Clear(); foreach (Item item in oldSector.Items.Values) { if (item == null) continue; if (item.AtWorldPoint(oldX, oldY) && (item.Z == oldZ || ((item.Z + item.ItemData.Height) > oldZ && (oldZ + 15) > item.Z))) OnMoveOff.Add(item); } foreach (Item item in OnMoveOff) if (!item.OnMoveOff(this)) return false; OnMoveOff.Clear(); foreach (Mobile m in newSector.Mobiles.Values) { if (m == null) continue; if (m.X == x && m.Y == y && (m.Z + 15) > newZ && (newZ + 15) > m.Z) OnMoveOver.Add(m); } foreach (Mobile m in OnMoveOver) if (!m.OnMoveOver(this)) return false; OnMoveOver.Clear(); foreach (Item item in newSector.Items.Values) { if (item == null) continue; if (item.AtWorldPoint(x, y) && (item.Z == newZ || ((item.Z + item.ItemData.Height) > newZ && (newZ + 15) > item.Z))) OnMoveOver.Add(item); } foreach (Item item in OnMoveOver) if (!item.OnMoveOver(this)) return false; OnMoveOver.Clear(); } else { foreach (Mobile m in oldSector.Mobiles.Values) { if (m == null) continue; if (m != this && m.X == oldX && m.Y == oldY && (m.Z + 15) > oldZ && (oldZ + 15) > m.Z) OnMoveOff.Add(m); else if (m.X == x && m.Y == y && (m.Z + 15) > newZ && (newZ + 15) > m.Z) OnMoveOver.Add(m); } for (int ix = 0, jx = 0; true; ix++, jx++) { if (ix < OnMoveOff.Count) if (!(OnMoveOff[ix] as Mobile).OnMoveOff(this)) return false; if (jx < OnMoveOver.Count) if (!(OnMoveOver[jx] as Mobile).OnMoveOver(this)) return false; if (ix >= OnMoveOff.Count && jx >= OnMoveOver.Count) break; } OnMoveOver.Clear(); OnMoveOff.Clear(); foreach (Item item in oldSector.Items.Values) { if (item == null) continue; if (item.AtWorldPoint(oldX, oldY) && (item.Z == oldZ || ((item.Z + item.ItemData.Height) > oldZ && (oldZ + 15) > item.Z))) OnMoveOff.Add(item); else if (item.AtWorldPoint(x, y) && (item.Z == newZ || ((item.Z + item.ItemData.Height) > newZ && (newZ + 15) > item.Z))) OnMoveOver.Add(item); } for (int ix = 0, jx = 0; true; ix++, jx++) { if (ix < OnMoveOff.Count) if (!(OnMoveOff[ix] as Item).OnMoveOff(this)) return false; if (jx < OnMoveOver.Count) if (!(OnMoveOver[jx] as Item).OnMoveOver(this)) return false; if (ix >= OnMoveOff.Count && jx >= OnMoveOver.Count) break; } OnMoveOver.Clear(); OnMoveOff.Clear(); } //if( !Region.CanMove( this, d, newLocation, oldLocation, m_Map ) ) // return false; } else { return false; } if (!InternalOnMove(d)) return false; if (m_FwdEnabled && m_NetState != null && m_AccessLevel < m_FwdAccessOverride && (!m_FwdUOTDOverride || !m_NetState.IsUOTDClient)) { if (m_MoveRecords == null) m_MoveRecords = new Queue<MovementRecord>(6); while (m_MoveRecords.Count > 0) { MovementRecord r = m_MoveRecords.Peek(); if (r.Expired()) m_MoveRecords.Dequeue(); else break; } if (m_MoveRecords.Count >= m_FwdMaxSteps) { FastWalkEventArgs fw = new FastWalkEventArgs(m_NetState); EventSink.InvokeFastWalk(fw); if (fw.Blocked) return false; } TimeSpan delay = ComputeMovementSpeed(d); /*if ( Mounted ) delay = (d & Direction.Running) != 0 ? m_RunMount : m_WalkMount; else delay = ( d & Direction.Running ) != 0 ? m_RunFoot : m_WalkFoot;*/ DateTime end; if (m_MoveRecords.Count > 0) end = m_EndQueue + delay; else end = DateTime.Now + delay; m_MoveRecords.Enqueue(MovementRecord.NewInstance(end)); m_EndQueue = end; } m_LastMoveTime = DateTime.Now; } else { return false; } DisruptiveAction(); } if (m_NetState != null) m_NetState.Send(MovementAck.Instantiate(m_NetState.Sequence, this));//new MovementAck( m_NetState.Sequence, this ) ); SetLocation(newLocation, false); SetDirection(d); if (m_Map != null) { IPooledEnumerable eable = m_Map.GetObjectsInRange(m_Location, Core.GlobalMaxUpdateRange); foreach (object o in eable) { if (o == this) continue; if (o is Mobile) { m_MoveList.Add(o); } else if (o is Item) { Item item = (Item)o; if (item.HandlesOnMovement) m_MoveList.Add(item); } } eable.Free(); Packet[] cache = m_MovingPacketCache; for (int i = 0; i < cache.Length; ++i) Packet.Release(ref cache[i]); for (int i = 0; i < m_MoveList.Count; ++i) { object o = m_MoveList[i]; if (o is Mobile) { Mobile m = (Mobile)m_MoveList[i]; NetState ns = m.NetState; if (ns != null && Utility.InUpdateRange(m_Location, m.m_Location) && m.CanSee(this)) { int noto = Notoriety.Compute(m, this); Packet p = cache[noto]; if (p == null) cache[noto] = p = Packet.Acquire(new MobileMoving(this, noto)); ns.Send(p); } m.OnMovement(this, oldLocation); } else if (o is Item) { ((Item)o).OnMovement(this, oldLocation); } } for (int i = 0; i < cache.Length; ++i) Packet.Release(ref cache[i]); if (m_MoveList.Count > 0) m_MoveList.Clear(); } OnAfterMove(oldLocation); return true; }