fix: Cleanup IPoint3D calls (#704)
This commit is contained in:
parent
788b04b958
commit
3293ffcf06
33 changed files with 158 additions and 264 deletions
|
|
@ -21,12 +21,6 @@ namespace Server
|
|||
private Point2D m_Start;
|
||||
private Point2D m_End;
|
||||
|
||||
public Rectangle2D(IPoint2D start, IPoint2D end)
|
||||
{
|
||||
m_Start = new Point2D(start);
|
||||
m_End = new Point2D(end);
|
||||
}
|
||||
|
||||
public Rectangle2D(Point2D start, Point2D end)
|
||||
{
|
||||
m_Start = start;
|
||||
|
|
@ -141,7 +135,8 @@ namespace Server
|
|||
public readonly bool Contains(Point2D p) =>
|
||||
m_Start.m_X <= p.m_X && m_Start.m_Y <= p.m_Y && m_End.m_X > p.m_X && m_End.m_Y > p.m_Y;
|
||||
|
||||
public readonly bool Contains(IPoint2D p) => m_Start <= p && m_End > p;
|
||||
public readonly bool Contains(int x, int y) =>
|
||||
m_Start.m_X <= x && m_Start.m_Y <= y && m_End.m_X > x && m_End.m_Y > y;
|
||||
|
||||
public override string ToString() => $"({X}, {Y})+({Width}, {Height})";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,6 +118,18 @@ namespace Server
|
|||
&& p.m_Z >= m_Start.m_Z
|
||||
&& p.m_Z < m_End.m_Z;
|
||||
|
||||
public bool Contains(Point2D p) =>
|
||||
p.m_X >= m_Start.m_X
|
||||
&& p.m_X < m_End.m_X
|
||||
&& p.m_Y >= m_Start.m_Y
|
||||
&& p.m_Y < m_End.m_Y;
|
||||
|
||||
public bool Contains(IPoint2D p) =>
|
||||
p.X >= m_Start.m_X
|
||||
&& p.X < m_End.m_X
|
||||
&& p.Y >= m_Start.m_Y
|
||||
&& p.Y < m_End.m_Y;
|
||||
|
||||
public bool Contains(IPoint3D p) =>
|
||||
p.X >= m_Start.m_X
|
||||
&& p.X < m_End.m_X
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ namespace Server
|
|||
{
|
||||
}
|
||||
|
||||
public WorldLocation(IPoint2D p, Map map) : this(p.X, p.Y, 0, map)
|
||||
public WorldLocation(Point2D p, Map map) : this(p.X, p.Y, 0, map)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ namespace Server
|
|||
{
|
||||
}
|
||||
|
||||
public WorldLocation(IPoint3D p, Map map) : this(p.X, p.Y, p.Z, map)
|
||||
public WorldLocation(Point3D p, Map map) : this(p.X, p.Y, p.Z, map)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,8 +29,6 @@ namespace Server
|
|||
|
||||
bool InRange(Point3D p, int range);
|
||||
|
||||
bool InRange(IPoint2D p, int range);
|
||||
|
||||
void RemoveItem(Item item);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1606,23 +1606,9 @@ namespace Server
|
|||
set => Location = new Point3D(m_Location.m_X, m_Location.m_Y, value);
|
||||
}
|
||||
|
||||
public virtual bool InRange(Point2D p, int range) =>
|
||||
p.m_X >= Location.m_X - range
|
||||
&& p.m_X <= Location.m_X + range
|
||||
&& p.m_Y >= Location.m_Y - range
|
||||
&& p.m_Y <= Location.m_Y + range;
|
||||
public virtual bool InRange(Point2D p, int range) => Utility.InRange(p.X, p.Y, X, Y, range);
|
||||
|
||||
public virtual bool InRange(Point3D p, int range) =>
|
||||
p.m_X >= Location.m_X - range
|
||||
&& p.m_X <= Location.m_X + range
|
||||
&& p.m_Y >= Location.m_Y - range
|
||||
&& p.m_Y <= Location.m_Y + range;
|
||||
|
||||
public virtual bool InRange(IPoint2D p, int range) =>
|
||||
p.X >= Location.m_X - range
|
||||
&& p.X <= Location.m_X + range
|
||||
&& p.Y >= Location.m_Y - range
|
||||
&& p.Y <= Location.m_Y + range;
|
||||
public virtual bool InRange(Point3D p, int range) => Utility.InRange(p.X, p.Y, X, Y, range);
|
||||
|
||||
public ExpandFlag GetExpandFlags()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ namespace Server
|
|||
|
||||
public static IEnumerable<NetState> SelectClients(Sector s, Rectangle2D bounds)
|
||||
{
|
||||
return s.Clients.Where(o => o?.Mobile?.Deleted == false && bounds.Contains(o.Mobile));
|
||||
return s.Clients.Where(o => o?.Mobile?.Deleted == false && bounds.Contains(o.Mobile.Location));
|
||||
}
|
||||
|
||||
public static IEnumerable<IEntity> SelectEntities(Sector s, Rectangle2D bounds) =>
|
||||
|
|
@ -73,18 +73,18 @@ namespace Server
|
|||
eable = eable.Union(s.Items.Where(o => o?.Deleted == false && o.Parent == null));
|
||||
}
|
||||
|
||||
return eable.Where(bounds.Contains);
|
||||
return eable.Where(o => bounds.Contains(o.Location));
|
||||
}
|
||||
|
||||
public static IEnumerable<T> SelectMobiles<T>(Sector s, Rectangle2D bounds) where T : Mobile
|
||||
{
|
||||
return s.Mobiles.OfType<T>().Where(o => !o.Deleted && bounds.Contains(o));
|
||||
return s.Mobiles.OfType<T>().Where(o => !o.Deleted && bounds.Contains(o.Location));
|
||||
}
|
||||
|
||||
public static IEnumerable<T> SelectItems<T>(Sector s, Rectangle2D bounds) where T : Item
|
||||
{
|
||||
return s.Items.OfType<T>()
|
||||
.Where(o => o.Deleted == false && o.Parent == null && bounds.Contains(o));
|
||||
.Where(o => o.Deleted == false && o.Parent == null && bounds.Contains(o.Location));
|
||||
}
|
||||
|
||||
public static IEnumerable<BaseMulti> SelectMultis(Sector s, Rectangle2D bounds)
|
||||
|
|
@ -806,7 +806,7 @@ namespace Server
|
|||
{
|
||||
if (this != Internal)
|
||||
{
|
||||
GetSector(m).OnClientChange(oldState, newState);
|
||||
GetSector(m.Location).OnClientChange(oldState, newState);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -814,7 +814,7 @@ namespace Server
|
|||
{
|
||||
if (this != Internal)
|
||||
{
|
||||
GetSector(m).OnEnter(m);
|
||||
GetSector(m.Location).OnEnter(m);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -825,7 +825,7 @@ namespace Server
|
|||
return;
|
||||
}
|
||||
|
||||
GetSector(item).OnEnter(item);
|
||||
GetSector(item.Location).OnEnter(item);
|
||||
|
||||
if (item is BaseMulti m)
|
||||
{
|
||||
|
|
@ -842,7 +842,7 @@ namespace Server
|
|||
{
|
||||
if (this != Internal)
|
||||
{
|
||||
GetSector(m).OnLeave(m);
|
||||
GetSector(m.Location).OnLeave(m);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -853,7 +853,7 @@ namespace Server
|
|||
return;
|
||||
}
|
||||
|
||||
GetSector(item).OnLeave(item);
|
||||
GetSector(item.Location).OnLeave(item);
|
||||
|
||||
if (item is BaseMulti m)
|
||||
{
|
||||
|
|
@ -1192,7 +1192,7 @@ namespace Server
|
|||
|
||||
public Sector GetSector(Point2D p) => InternalGetSector(p.m_X >> SectorShift, p.m_Y >> SectorShift);
|
||||
|
||||
public Sector GetSector(IPoint2D p) => InternalGetSector(p.X >> SectorShift, p.Y >> SectorShift);
|
||||
// public Sector GetSector(IPoint2D p) => InternalGetSector(p.X >> SectorShift, p.Y >> SectorShift);
|
||||
|
||||
public Sector GetSector(int x, int y) => InternalGetSector(x >> SectorShift, y >> SectorShift);
|
||||
|
||||
|
|
|
|||
|
|
@ -1119,8 +1119,7 @@ namespace Server
|
|||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Container Corpse { get; set; }
|
||||
|
||||
public static char[] GhostChars { get; set; } = { 'o', 'O' };
|
||||
|
||||
public static char[] GhostChars { get; set; }
|
||||
public static bool NoSpeechLOS { get; set; }
|
||||
|
||||
public static TimeSpan AutoManifestTimeout { get; set; } = TimeSpan.FromSeconds(5.0);
|
||||
|
|
@ -2108,7 +2107,6 @@ namespace Server
|
|||
if (Stam < StamMax)
|
||||
{
|
||||
m_StamTimer ??= new StamTimer(this);
|
||||
|
||||
m_StamTimer.Start();
|
||||
}
|
||||
else if (Stam > StamMax)
|
||||
|
|
@ -2167,7 +2165,6 @@ namespace Server
|
|||
if (Mana < ManaMax)
|
||||
{
|
||||
m_ManaTimer ??= new ManaTimer(this);
|
||||
|
||||
m_ManaTimer.Start();
|
||||
}
|
||||
else if (Mana > ManaMax)
|
||||
|
|
@ -2234,17 +2231,14 @@ namespace Server
|
|||
DamageEntries.Clear(); // reset damage entries on full HP
|
||||
}
|
||||
}
|
||||
else if (CanRegenHits)
|
||||
{
|
||||
m_HitsTimer ??= new HitsTimer(this);
|
||||
m_HitsTimer.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CanRegenHits)
|
||||
{
|
||||
m_HitsTimer ??= new HitsTimer(this);
|
||||
m_HitsTimer.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_HitsTimer?.Stop();
|
||||
}
|
||||
m_HitsTimer?.Stop();
|
||||
}
|
||||
|
||||
if (m_Hits != value)
|
||||
|
|
@ -2279,22 +2273,14 @@ namespace Server
|
|||
|
||||
value = Math.Clamp(value, 0, StamMax);
|
||||
|
||||
if (value == StamMax)
|
||||
if (CanRegenStam && value < StamMax)
|
||||
{
|
||||
m_StamTimer?.Stop();
|
||||
m_StamTimer ??= new StamTimer(this);
|
||||
m_StamTimer.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CanRegenStam)
|
||||
{
|
||||
m_StamTimer ??= new StamTimer(this);
|
||||
|
||||
m_StamTimer.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_StamTimer?.Stop();
|
||||
}
|
||||
m_StamTimer?.Stop();
|
||||
}
|
||||
|
||||
if (m_Stam != value)
|
||||
|
|
@ -2342,18 +2328,14 @@ namespace Server
|
|||
SendLocalizedMessage(501846); // You are at peace.
|
||||
}
|
||||
}
|
||||
else if (CanRegenMana)
|
||||
{
|
||||
m_ManaTimer ??= new ManaTimer(this);
|
||||
m_ManaTimer.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CanRegenMana)
|
||||
{
|
||||
m_ManaTimer ??= new ManaTimer(this);
|
||||
|
||||
m_ManaTimer.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ManaTimer?.Stop();
|
||||
}
|
||||
m_ManaTimer?.Stop();
|
||||
}
|
||||
|
||||
if (m_Mana != value)
|
||||
|
|
@ -3874,7 +3856,7 @@ namespace Server
|
|||
}
|
||||
}
|
||||
|
||||
public virtual bool CheckAttack(Mobile m) => Utility.InUpdateRange(this, m) && CanSee(m) && InLOS(m);
|
||||
public virtual bool CheckAttack(Mobile m) => Utility.InUpdateRange(Location, m.Location) && CanSee(m) && InLOS(m);
|
||||
|
||||
/// <summary>
|
||||
/// Overridable. Virtual event invoked after the <see cref="Combatant" /> property has changed.
|
||||
|
|
@ -5041,7 +5023,7 @@ namespace Server
|
|||
var root = item.RootParent;
|
||||
var okay = false;
|
||||
|
||||
if (!Utility.InUpdateRange(this, item.GetWorldLocation()))
|
||||
if (!Utility.InUpdateRange(Location, item.GetWorldLocation()))
|
||||
{
|
||||
item.OnDoubleClickOutOfRange(this);
|
||||
}
|
||||
|
|
@ -5111,7 +5093,7 @@ namespace Server
|
|||
return;
|
||||
}
|
||||
|
||||
if (!Utility.InUpdateRange(this, m))
|
||||
if (!Utility.InUpdateRange(Location, m.Location))
|
||||
{
|
||||
m.OnDoubleClickOutOfRange(this);
|
||||
}
|
||||
|
|
@ -5525,7 +5507,7 @@ namespace Server
|
|||
using var sb = new ValueStringBuilder(stackalloc char[Math.Min(text.Length, 256)]);
|
||||
for (var i = 0; i < text.Length; ++i)
|
||||
{
|
||||
sb.Append(text[i] != ' ' ? GhostChars.RandomElement() : ' ');
|
||||
sb.Append(text[i] != ' ' ? (GhostChars ?? DefaultGhostChars).RandomElement() : ' ');
|
||||
}
|
||||
|
||||
text = sb.ToString();
|
||||
|
|
@ -6586,7 +6568,6 @@ namespace Server
|
|||
if (CanRegenStam)
|
||||
{
|
||||
m_StamTimer ??= new StamTimer(this);
|
||||
|
||||
m_StamTimer.Start();
|
||||
}
|
||||
else
|
||||
|
|
@ -6604,7 +6585,6 @@ namespace Server
|
|||
if (CanRegenMana)
|
||||
{
|
||||
m_ManaTimer ??= new ManaTimer(this);
|
||||
|
||||
m_ManaTimer.Start();
|
||||
}
|
||||
else
|
||||
|
|
@ -7986,7 +7966,7 @@ namespace Server
|
|||
/// <param name="from"></param>
|
||||
public virtual void OnStatsQuery(Mobile from)
|
||||
{
|
||||
if (from.Map == Map && Utility.InUpdateRange(this, from) && from.CanSee(this))
|
||||
if (from.Map == Map && Utility.InUpdateRange(Location, from.Location) && from.CanSee(this))
|
||||
{
|
||||
from.m_NetState.SendMobileStatus(from, this);
|
||||
}
|
||||
|
|
@ -8156,6 +8136,8 @@ namespace Server
|
|||
|
||||
public static TimeSpan GetManaRegenRate(Mobile m) => ManaRegenRateHandler?.Invoke(m) ?? DefaultManaRate;
|
||||
|
||||
public static char[] DefaultGhostChars = { 'o', 'O' };
|
||||
|
||||
public Prompt BeginPrompt(PromptCallback callback, PromptCallback cancelCallback) =>
|
||||
Prompt = new SimplePrompt(callback, cancelCallback);
|
||||
|
||||
|
|
@ -9309,11 +9291,7 @@ namespace Server
|
|||
{
|
||||
private readonly Mobile m_Owner;
|
||||
|
||||
public ManaTimer(Mobile m)
|
||||
: base(GetManaRegenRate(m), GetManaRegenRate(m))
|
||||
{
|
||||
m_Owner = m;
|
||||
}
|
||||
public ManaTimer(Mobile m) : base(GetManaRegenRate(m), GetManaRegenRate(m)) => m_Owner = m;
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
|
|
@ -9330,11 +9308,7 @@ namespace Server
|
|||
{
|
||||
private readonly Mobile m_Owner;
|
||||
|
||||
public HitsTimer(Mobile m)
|
||||
: base(GetHitsRegenRate(m), GetHitsRegenRate(m))
|
||||
{
|
||||
m_Owner = m;
|
||||
}
|
||||
public HitsTimer(Mobile m) : base(GetHitsRegenRate(m), GetHitsRegenRate(m)) => m_Owner = m;
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
|
|
@ -9351,11 +9325,7 @@ namespace Server
|
|||
{
|
||||
private readonly Mobile m_Owner;
|
||||
|
||||
public StamTimer(Mobile m)
|
||||
: base(GetStamRegenRate(m), GetStamRegenRate(m))
|
||||
{
|
||||
m_Owner = m;
|
||||
}
|
||||
public StamTimer(Mobile m) : base(GetStamRegenRate(m), GetStamRegenRate(m)) => m_Owner = m;
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ namespace Server.Network
|
|||
{
|
||||
var m = World.FindMobile(s);
|
||||
|
||||
if (m != null && from.CanSee(m) && Utility.InUpdateRange(from, m))
|
||||
if (m != null && from.CanSee(m) && Utility.InUpdateRange(from.Location, m.Location))
|
||||
{
|
||||
if (SingleClickProps)
|
||||
{
|
||||
|
|
@ -173,7 +173,7 @@ namespace Server.Network
|
|||
{
|
||||
var m = World.FindMobile(s);
|
||||
|
||||
if (m != null && from.CanSee(m) && Utility.InUpdateRange(from, m))
|
||||
if (m != null && from.CanSee(m) && Utility.InUpdateRange(from.Location, m.Location))
|
||||
{
|
||||
m.SendPropertiesTo(from);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -347,7 +347,7 @@ namespace Server.Network
|
|||
{
|
||||
var m = World.FindMobile(s);
|
||||
|
||||
if (m != null && from.CanSee(m) && Utility.InUpdateRange(from, m))
|
||||
if (m != null && from.CanSee(m) && Utility.InUpdateRange(from.Location, m.Location))
|
||||
{
|
||||
m.SendPropertiesTo(from);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ namespace Server.Network
|
|||
{
|
||||
var m = World.FindMobile(reader.ReadUInt32());
|
||||
|
||||
if (m != null && Utility.InUpdateRange(state.Mobile, m) && state.Mobile.CanSee(m))
|
||||
if (m != null && Utility.InUpdateRange(state.Mobile.Location, m.Location) && state.Mobile.CanSee(m))
|
||||
{
|
||||
state.SendMobileName(m);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ namespace Server.Network
|
|||
|
||||
var flag = reader.ReadByte();
|
||||
|
||||
if (!vendor.Deleted && Utility.RangeCheck(vendor.Location, state.Mobile.Location, 10) && flag == 0x02)
|
||||
if (!vendor.Deleted && Utility.InRange(vendor.Location, state.Mobile.Location, 10) && flag == 0x02)
|
||||
{
|
||||
var msgSize = packetLength - 8; // Remaining bytes
|
||||
|
||||
|
|
@ -75,7 +75,7 @@ namespace Server.Network
|
|||
return;
|
||||
}
|
||||
|
||||
if (vendor.Deleted || !Utility.RangeCheck(vendor.Location, state.Mobile.Location, 10))
|
||||
if (vendor.Deleted || !Utility.InRange(vendor.Location, state.Mobile.Location, 10))
|
||||
{
|
||||
state.SendEndVendorSell(vendor.Serial);
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Server.Collections;
|
||||
using Server.Items;
|
||||
using Server.Network;
|
||||
|
||||
|
|
@ -141,11 +141,15 @@ namespace Server
|
|||
{
|
||||
if (m_Mobiles != null)
|
||||
{
|
||||
var sandbox = new List<Mobile>(m_Mobiles);
|
||||
|
||||
foreach (var mob in sandbox)
|
||||
using var queue = PooledRefQueue<Mobile>.Create(m_Mobiles.Count);
|
||||
foreach (var mob in m_Mobiles)
|
||||
{
|
||||
mob.UpdateRegion();
|
||||
queue.Enqueue(mob);
|
||||
}
|
||||
|
||||
while (queue.Count > 0)
|
||||
{
|
||||
queue.Dequeue().UpdateRegion();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -162,7 +166,7 @@ namespace Server
|
|||
|
||||
public void Activate()
|
||||
{
|
||||
if (!Active && Owner != Map.Internal)
|
||||
if (!Active)
|
||||
{
|
||||
if (m_Items != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ using System.Collections.Generic;
|
|||
#endif
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
|
|
|
|||
|
|
@ -571,10 +571,14 @@ namespace Server
|
|||
|
||||
public static bool InsensitiveStartsWith(string first, string second) => first.InsensitiveStartsWith(second);
|
||||
|
||||
public static Direction GetDirection(IPoint2D from, IPoint2D to)
|
||||
public static Direction GetDirection(Point3D from, Point3D to) => GetDirection(from.X, from.Y, to.X, to.Y);
|
||||
|
||||
public static Direction GetDirection(Point2D from, Point2D to) => GetDirection(from.X, from.Y, to.X, to.Y);
|
||||
|
||||
public static Direction GetDirection(int fromX, int fromY, int toX, int toY)
|
||||
{
|
||||
var dx = to.X - from.X;
|
||||
var dy = to.Y - from.Y;
|
||||
var dx = toX - fromX;
|
||||
var dy = toY - fromY;
|
||||
|
||||
var adx = Abs(dx);
|
||||
var ady = Abs(dy);
|
||||
|
|
@ -615,32 +619,20 @@ namespace Server
|
|||
{
|
||||
if (bottom.m_X < top.m_X)
|
||||
{
|
||||
var swap = top.m_X;
|
||||
top.m_X = bottom.m_X;
|
||||
bottom.m_X = swap;
|
||||
(top.m_X, bottom.m_X) = (bottom.m_X, top.m_X);
|
||||
}
|
||||
|
||||
if (bottom.m_Y < top.m_Y)
|
||||
{
|
||||
var swap = top.m_Y;
|
||||
top.m_Y = bottom.m_Y;
|
||||
bottom.m_Y = swap;
|
||||
(top.m_Y, bottom.m_Y) = (bottom.m_Y, top.m_Y);
|
||||
}
|
||||
|
||||
if (bottom.m_Z < top.m_Z)
|
||||
{
|
||||
var swap = top.m_Z;
|
||||
top.m_Z = bottom.m_Z;
|
||||
bottom.m_Z = swap;
|
||||
(top.m_Z, bottom.m_Z) = (bottom.m_Z, top.m_Z);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool RangeCheck(IPoint2D p1, IPoint2D p2, int range) =>
|
||||
p1.X >= p2.X - range
|
||||
&& p1.X <= p2.X + range
|
||||
&& p1.Y >= p2.Y - range
|
||||
&& p2.Y <= p2.Y + range;
|
||||
|
||||
public static void FormatBuffer(TextWriter output, Stream input, int length)
|
||||
{
|
||||
output.WriteLine(" 0 1 2 3 4 5 6 7 8 9 A B C D E F");
|
||||
|
|
@ -874,9 +866,7 @@ namespace Server
|
|||
{
|
||||
if (bound1 > bound2)
|
||||
{
|
||||
var i = bound1;
|
||||
bound1 = bound2;
|
||||
bound2 = i;
|
||||
(bound1, bound2) = (bound2, bound1);
|
||||
}
|
||||
|
||||
return num < bound2 + allowance && num > bound1 - allowance;
|
||||
|
|
@ -1063,29 +1053,26 @@ namespace Server
|
|||
|
||||
public static string GetText(XmlElement node, string defaultValue) => node?.InnerText ?? defaultValue;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool InRange(int p1X, int p1Y, int p2X, int p2Y, int range) =>
|
||||
p1X >= p2X - range
|
||||
&& p1X <= p2X + range
|
||||
&& p1Y >= p2Y - range
|
||||
&& p1Y <= p2Y + range;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool InRange(Point2D p1, Point2D p2, int range) =>
|
||||
InRange(p1.m_X, p1.m_Y, p2.m_X, p2.m_Y, range);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool InUpdateRange(Point2D p1, Point2D p2) => InRange(p1, p2, 18);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool InRange(Point3D p1, Point3D p2, int range) =>
|
||||
p1.m_X >= p2.m_X - range
|
||||
&& p1.m_X <= p2.m_X + range
|
||||
&& p1.m_Y >= p2.m_Y - range
|
||||
&& p1.m_Y <= p2.m_Y + range;
|
||||
InRange(p1.m_X, p1.m_Y, p2.m_X, p2.m_Y, range);
|
||||
|
||||
public static bool InUpdateRange(Point3D p1, Point3D p2) =>
|
||||
p1.m_X >= p2.m_X - 18
|
||||
&& p1.m_X <= p2.m_X + 18
|
||||
&& p1.m_Y >= p2.m_Y - 18
|
||||
&& p1.m_Y <= p2.m_Y + 18;
|
||||
|
||||
public static bool InUpdateRange(Point2D p1, Point2D p2) =>
|
||||
p1.m_X >= p2.m_X - 18
|
||||
&& p1.m_X <= p2.m_X + 18
|
||||
&& p1.m_Y >= p2.m_Y - 18
|
||||
&& p1.m_Y <= p2.m_Y + 18;
|
||||
|
||||
public static bool InUpdateRange(IPoint2D p1, IPoint2D p2) =>
|
||||
p1.X >= p2.X - 18
|
||||
&& p1.X <= p2.X + 18
|
||||
&& p1.Y >= p2.Y - 18
|
||||
&& p1.Y <= p2.Y + 18;
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool InUpdateRange(Point3D p1, Point3D p2) => InRange(p1, p2, 18);
|
||||
|
||||
// 4d6+8 would be: Utility.Dice( 4, 6, 8 )
|
||||
public static int Dice(uint amount, uint sides, int bonus)
|
||||
|
|
@ -1106,9 +1093,7 @@ namespace Server
|
|||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var r = RandomMinMax(i, count - 1);
|
||||
var swap = list[r];
|
||||
list[r] = list[i];
|
||||
list[i] = swap;
|
||||
(list[r], list[i]) = (list[i], list[r]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1118,9 +1103,7 @@ namespace Server
|
|||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var r = RandomMinMax(i, count - 1);
|
||||
var swap = list[r];
|
||||
list[r] = list[i];
|
||||
list[i] = swap;
|
||||
(list[r], list[i]) = (list[i], list[r]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1208,9 +1191,7 @@ namespace Server
|
|||
{
|
||||
if (min > max)
|
||||
{
|
||||
var copy = min;
|
||||
min = max;
|
||||
max = copy;
|
||||
(min, max) = (max, min);
|
||||
}
|
||||
else if (min == max)
|
||||
{
|
||||
|
|
@ -1225,9 +1206,7 @@ namespace Server
|
|||
{
|
||||
if (min > max)
|
||||
{
|
||||
var copy = min;
|
||||
min = max;
|
||||
max = copy;
|
||||
(min, max) = (max, min);
|
||||
}
|
||||
else if (min == max)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ namespace Server.Commands
|
|||
{
|
||||
var m = list[i];
|
||||
|
||||
if (!m.CanSee(pm) && Utility.InUpdateRange(m, pm))
|
||||
if (!m.CanSee(pm) && Utility.InUpdateRange(m.Location, pm.Location))
|
||||
{
|
||||
OutgoingEntityPackets.CreateRemoveEntity(removeEntity, pm.Serial);
|
||||
m.NetState?.Send(removeEntity);
|
||||
|
|
@ -110,7 +110,7 @@ namespace Server.Commands
|
|||
pm.SendMessage("{0} has been added to your visibility list.", targ.Name);
|
||||
}
|
||||
|
||||
if (Utility.InUpdateRange(targ, from))
|
||||
if (Utility.InUpdateRange(targ.Location, from.Location))
|
||||
{
|
||||
var ns = targ.NetState;
|
||||
|
||||
|
|
|
|||
|
|
@ -245,7 +245,7 @@ namespace Server.Engines.ConPVP
|
|||
{
|
||||
m_From.SendLocalizedMessage(1049616); // You are too busy to do that at the moment.
|
||||
}
|
||||
else if (m_From.Map == arena.Facet && arena.Zone.Contains(m_From))
|
||||
else if (m_From.Map == arena.Facet && arena.Zone.Contains(m_From.Location))
|
||||
{
|
||||
m_From.SendLocalizedMessage(1019003); // You are already there.
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ namespace Server.Engines.PartySystem
|
|||
var c = Members[i].Mobile;
|
||||
var ns = c.NetState;
|
||||
|
||||
if (c != m && ns != null && m.Map == c.Map && Utility.InUpdateRange(c, m) && c.CanSee(m))
|
||||
if (c != m && ns != null && m.Map == c.Map && Utility.InUpdateRange(c.Location, m.Location) && c.CanSee(m))
|
||||
{
|
||||
ns.Send(p);
|
||||
}
|
||||
|
|
@ -75,7 +75,7 @@ namespace Server.Engines.PartySystem
|
|||
var c = Members[i].Mobile;
|
||||
var ns = c.NetState;
|
||||
|
||||
if (c != m && ns != null && m.Map == c.Map && Utility.InUpdateRange(c, m) && c.CanSee(m))
|
||||
if (c != m && ns != null && m.Map == c.Map && Utility.InUpdateRange(c.Location, m.Location) && c.CanSee(m))
|
||||
{
|
||||
ns.Send(p);
|
||||
}
|
||||
|
|
@ -85,7 +85,7 @@ namespace Server.Engines.PartySystem
|
|||
public void OnStatsQuery(Mobile beholder, Mobile beheld)
|
||||
{
|
||||
if (beholder != beheld && Contains(beholder) && beholder.Map == beheld.Map &&
|
||||
Utility.InUpdateRange(beholder, beheld))
|
||||
Utility.InUpdateRange(beholder.Location, beheld.Location))
|
||||
{
|
||||
if (!beholder.CanSee(beheld))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ namespace Server.Engines.Quests.Necro
|
|||
}
|
||||
else if (qs.IsObjectiveInProgress(typeof(UseCallingScrollObjective)))
|
||||
{
|
||||
if (pm.Map == m_WellOfTearsMap && m_WellOfTearsArea.Contains(pm))
|
||||
if (pm.Map == m_WellOfTearsMap && m_WellOfTearsArea.Contains(pm.Location))
|
||||
{
|
||||
QuestObjective obj = qs.FindObjective<UseCallingScrollObjective>();
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ namespace Server.Engines.Quests.Naturalist
|
|||
}
|
||||
}
|
||||
|
||||
public static NestArea Find(IPoint2D p)
|
||||
public static NestArea Find(Point3D p)
|
||||
{
|
||||
return m_Areas.FirstOrDefault(area => area.Contains(p));
|
||||
}
|
||||
|
|
@ -73,11 +73,13 @@ namespace Server.Engines.Quests.Naturalist
|
|||
return null;
|
||||
}
|
||||
|
||||
public bool Contains(IPoint2D p)
|
||||
public bool Contains(Point3D p)
|
||||
{
|
||||
var x = p.X;
|
||||
var y = p.Y;
|
||||
foreach (var rect in m_Rects)
|
||||
{
|
||||
if (rect.Contains(p))
|
||||
if (rect.Contains(x, y))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace Server.Engines.Quests.Naturalist
|
|||
{
|
||||
var nest = m_CurrentNest;
|
||||
|
||||
if ((from.Map == Map.Trammel || from.Map == Map.Felucca) && nest.Contains(from))
|
||||
if ((from.Map == Map.Trammel || from.Map == Map.Felucca) && nest.Contains(from.Location))
|
||||
{
|
||||
if (m_StudyState != StudyState.Inactive)
|
||||
{
|
||||
|
|
@ -75,7 +75,7 @@ namespace Server.Engines.Quests.Naturalist
|
|||
}
|
||||
else if (from.Map == Map.Trammel || from.Map == Map.Felucca)
|
||||
{
|
||||
var nest = NestArea.Find(from);
|
||||
var nest = NestArea.Find(from.Location);
|
||||
|
||||
if (nest != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -119,12 +119,12 @@ namespace Server.Misc
|
|||
{
|
||||
var r = m.Region;
|
||||
|
||||
if (r.IsPartOf<HouseRegion>() || BaseBoat.FindBoatAt(m, m.Map) != null)
|
||||
if (r.IsPartOf<HouseRegion>() || BaseBoat.FindBoatAt(m.Location, m.Map) != null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// TODO: a CanReach of something check as opposed to above?
|
||||
|
||||
// TODO: a CanReach of something check as opposed to above?
|
||||
if (r.IsPartOf("Yomotsu Mines") || r.IsPartOf("Fan Dancer's Dojo"))
|
||||
{
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ namespace Server.Items
|
|||
|
||||
if (!e.Handled && from.InRange(this, 10) && e.Speech.ToLower() == Word)
|
||||
{
|
||||
var boat = BaseBoat.FindBoatAt(from, from.Map);
|
||||
var boat = BaseBoat.FindBoatAt(from.Location, from.Map);
|
||||
|
||||
if (boat == null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -88,32 +88,15 @@ namespace Server.Items
|
|||
|
||||
private static void FinishLaunch(Point3D endLoc, Map map)
|
||||
{
|
||||
var hue = Utility.Random(40);
|
||||
|
||||
if (hue < 8)
|
||||
var hue = Utility.Random(40) switch
|
||||
{
|
||||
hue = 0x66D;
|
||||
}
|
||||
else if (hue < 10)
|
||||
{
|
||||
hue = 0x482;
|
||||
}
|
||||
else if (hue < 12)
|
||||
{
|
||||
hue = 0x47E;
|
||||
}
|
||||
else if (hue < 16)
|
||||
{
|
||||
hue = 0x480;
|
||||
}
|
||||
else if (hue < 20)
|
||||
{
|
||||
hue = 0x47F;
|
||||
}
|
||||
else
|
||||
{
|
||||
hue = 0;
|
||||
}
|
||||
< 8 => 0x66D,
|
||||
< 10 => 0x482,
|
||||
< 12 => 0x47E,
|
||||
< 16 => 0x480,
|
||||
< 20 => 0x47F,
|
||||
_ => 0
|
||||
};
|
||||
|
||||
if (Utility.RandomBool())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -203,22 +203,13 @@ namespace Server.Misc
|
|||
{
|
||||
var medPoints = (from.Int + from.Skills.Meditation.Value) * 0.5;
|
||||
|
||||
if (medPoints <= 0)
|
||||
rate = medPoints switch
|
||||
{
|
||||
rate = 7.0;
|
||||
}
|
||||
else if (medPoints <= 100)
|
||||
{
|
||||
rate = 7.0 - 239 * medPoints / 2400 + 19 * medPoints * medPoints / 48000;
|
||||
}
|
||||
else if (medPoints < 120)
|
||||
{
|
||||
rate = 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
rate = 0.75;
|
||||
}
|
||||
<= 0 => 7.0,
|
||||
<= 100 => 7.0 - 239 * medPoints / 2400 + 19 * medPoints * medPoints / 48000,
|
||||
< 120 => 1.0,
|
||||
_ => 0.75
|
||||
};
|
||||
|
||||
rate += armorPenalty;
|
||||
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ namespace Server.Mobiles
|
|||
{
|
||||
activate = false;
|
||||
}
|
||||
else if (m.Map == null || m.Map == Map.Internal || !m.Map.GetSector(m).Active)
|
||||
else if (m.Map == null || m.Map == Map.Internal || !m.Map.GetSector(m.Location).Active)
|
||||
{
|
||||
activate = false;
|
||||
}
|
||||
|
|
@ -3040,7 +3040,7 @@ namespace Server.Mobiles
|
|||
|
||||
if (m_Owner.m_Mobile.PlayerRangeSensitive) // have to check this in the timer....
|
||||
{
|
||||
var sect = m_Owner.m_Mobile.Map.GetSector(m_Owner.m_Mobile);
|
||||
var sect = m_Owner.m_Mobile.Map.GetSector(m_Owner.m_Mobile.Location);
|
||||
if (!sect.Active)
|
||||
{
|
||||
m_Owner.Deactivate();
|
||||
|
|
|
|||
|
|
@ -887,15 +887,13 @@ namespace Server.Mobiles
|
|||
public virtual bool CanBreath => HasBreath && !Summoned;
|
||||
public virtual bool IsDispellable => Summoned && !IsAnimatedDead;
|
||||
|
||||
public virtual bool
|
||||
PlayerRangeSensitive // If they are following a waypoint, they'll continue to follow it even if players aren't around
|
||||
=> CurrentWayPoint == null;
|
||||
// If they are following a waypoint, they'll continue to follow it even if players aren't around
|
||||
public virtual bool PlayerRangeSensitive => CurrentWayPoint == null;
|
||||
|
||||
public virtual bool ReturnsToHome =>
|
||||
SeeksHome && Home != Point3D.Zero && !m_ReturnQueued && !Controlled && !Summoned;
|
||||
|
||||
// used for deleting untamed creatures [in houses]
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public bool RemoveIfUntamed { get; set; }
|
||||
|
||||
|
|
@ -3895,16 +3893,13 @@ namespace Server.Mobiles
|
|||
|
||||
public void GoHome_Callback()
|
||||
{
|
||||
if (m_ReturnQueued && IsSpawnerBound())
|
||||
if (m_ReturnQueued && IsSpawnerBound() && !Map.GetSector(X, Y).Active)
|
||||
{
|
||||
SetLocation(Home, true);
|
||||
|
||||
if (!Map.GetSector(X, Y).Active)
|
||||
{
|
||||
SetLocation(Home, true);
|
||||
|
||||
if (!Map.GetSector(X, Y).Active)
|
||||
{
|
||||
AIObject?.Deactivate();
|
||||
}
|
||||
AIObject?.Deactivate();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -968,7 +968,7 @@ namespace Server.Mobiles
|
|||
|
||||
public bool CanInteractWith(Mobile from, bool ownerOnly)
|
||||
{
|
||||
if (!from.CanSee(this) || !Utility.InUpdateRange(from, this) || !from.CheckAlive())
|
||||
if (!from.CanSee(this) || !Utility.InUpdateRange(from.Location, Location) || !from.CheckAlive())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1184,7 +1184,7 @@ namespace Server.Mobiles
|
|||
return false;
|
||||
}
|
||||
|
||||
if (House.IsInside(to) || to.Map != House.Map || !House.InRange(to, 5))
|
||||
if (House.IsInside(to) || to.Map != House.Map || !House.InRange(to.Location, 5))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -239,7 +239,7 @@ namespace Server.Multis
|
|||
|
||||
public override bool AllowsRelativeDrop => true;
|
||||
|
||||
public static BaseBoat FindBoatAt(IPoint2D loc, Map map)
|
||||
public static BaseBoat FindBoatAt(Point3D loc, Map map)
|
||||
{
|
||||
var sector = map.GetSector(loc);
|
||||
|
||||
|
|
@ -1512,7 +1512,7 @@ namespace Server.Multis
|
|||
var adx = dx.Abs();
|
||||
var ady = dy.Abs();
|
||||
|
||||
var dir = Utility.GetDirection(this, new Point2D(x, y));
|
||||
var dir = Utility.GetDirection(Location.X, Location.Y, x, y);
|
||||
var iDir = (int)dir;
|
||||
|
||||
// Compute the maximum distance we can travel without going too far away
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ namespace Server.Multis
|
|||
return;
|
||||
}
|
||||
|
||||
if (from.Region.IsPartOf<HouseRegion>() || BaseBoat.FindBoatAt(from, from.Map) != null)
|
||||
if (from.Region.IsPartOf<HouseRegion>() || BaseBoat.FindBoatAt(from.Location, from.Map) != null)
|
||||
{
|
||||
from.SendLocalizedMessage(
|
||||
1010568,
|
||||
|
|
|
|||
|
|
@ -707,16 +707,16 @@ namespace Server.Multis
|
|||
return fromSecures + fromVendors + fromLockdowns + fromMovingCrate;
|
||||
}
|
||||
|
||||
public override bool InRange(IPoint2D from, int range)
|
||||
public bool InRange(Point2D from, int range)
|
||||
{
|
||||
if (Region == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
foreach (var rect in Region.Area)
|
||||
{
|
||||
// TODO: Convert this to 3D - https://github.com/modernuo/ModernUO/issues/29
|
||||
if (from.X >= rect.Start.X - range && from.Y >= rect.Start.Y - range && from.X < rect.End.X + range && from.Y < rect.End.Y + range)
|
||||
{
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ namespace Server.Network
|
|||
continue;
|
||||
}
|
||||
|
||||
if (sendLocations && Utility.InUpdateRange(from, m) && from.CanSee(m))
|
||||
if (sendLocations && Utility.InUpdateRange(from.Location, m.Location) && from.CanSee(m))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
|
@ -139,7 +139,7 @@ namespace Server.Network
|
|||
continue;
|
||||
}
|
||||
|
||||
if (Utility.InUpdateRange(from, mob) && from.CanSee(mob))
|
||||
if (Utility.InUpdateRange(from.Location, mob.Location) && from.CanSee(mob))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,30 +11,10 @@ namespace Server.SkillHandlers
|
|||
SkillInfo.Table[46].Callback = OnUse;
|
||||
}
|
||||
|
||||
public static bool CheckOkayHolding(Item item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (item is Spellbook || item is Runebook)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Core.AOS && item is BaseWeapon weapon && weapon.Attributes.SpellChanneling != 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Core.AOS && item is BaseArmor armor && armor.Attributes.SpellChanneling != 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
public static bool CheckOkayHolding(Item item) =>
|
||||
item is null or Spellbook or Runebook
|
||||
|| Core.AOS && item is BaseWeapon weapon && weapon.Attributes.SpellChanneling != 0
|
||||
|| Core.AOS && item is BaseArmor armor && armor.Attributes.SpellChanneling != 0;
|
||||
|
||||
public static TimeSpan OnUse(Mobile m)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ namespace Server.Spells.Spellweaving
|
|||
{
|
||||
var master = pet.GetMaster();
|
||||
|
||||
if (master?.NetState != null && Utility.InUpdateRange(pet, master))
|
||||
if (master?.NetState != null && Utility.InUpdateRange(pet.Location, master.Location))
|
||||
{
|
||||
master.CloseGump<PetResurrectGump>();
|
||||
master.SendGump(new PetResurrectGump(master, pet, hitsScalar));
|
||||
|
|
@ -125,7 +125,7 @@ namespace Server.Spells.Spellweaving
|
|||
{
|
||||
var friend = friends[i];
|
||||
|
||||
if (friend.NetState != null && Utility.InUpdateRange(pet, friend))
|
||||
if (friend.NetState != null && Utility.InUpdateRange(pet.Location, friend.Location))
|
||||
{
|
||||
friend.CloseGump<PetResurrectGump>();
|
||||
friend.SendGump(new PetResurrectGump(friend, pet));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue