fix: Cleans up Point checks and removes statics (#966)
- [X] Removes static freezing/unfreezing. Use other tools for this. - [X] Cleans up IPoint3D allocations - [X] Removes IPoint3D constructors since the compiler may not optimize the constructor path and allow allocations. Note: Instead of `new Point3D(m)`, do something like `new Point3D(m.Location)`. Sorry for the inconvenience. In the long run this will prevent abuse of hot paths that will cause performance issues.
This commit is contained in:
parent
23532db603
commit
0925a2d435
18 changed files with 184 additions and 958 deletions
|
|
@ -12,41 +12,45 @@ namespace Server.Targets
|
|||
|
||||
protected override void OnTarget(Mobile from, object o)
|
||||
{
|
||||
if (o is IPoint3D p)
|
||||
if (o is not IPoint3D ip)
|
||||
{
|
||||
if (!BaseCommand.IsAccessible(from, m_Object))
|
||||
{
|
||||
from.SendLocalizedMessage(500447); // That is not accessible.
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (p is Item pItem)
|
||||
{
|
||||
p = pItem.GetWorldTop();
|
||||
}
|
||||
if (!BaseCommand.IsAccessible(from, m_Object))
|
||||
{
|
||||
from.SendLocalizedMessage(500447); // That is not accessible.
|
||||
return;
|
||||
}
|
||||
|
||||
CommandLogging.WriteLine(
|
||||
from,
|
||||
"{0} {1} moving {2} to {3}",
|
||||
from.AccessLevel,
|
||||
CommandLogging.Format(from),
|
||||
CommandLogging.Format(m_Object),
|
||||
new Point3D(p)
|
||||
);
|
||||
Point3D p = ip switch
|
||||
{
|
||||
Item i => i.GetWorldTop(),
|
||||
Mobile m => m.Location,
|
||||
_ => new Point3D(ip)
|
||||
};
|
||||
|
||||
if (m_Object is Item item)
|
||||
CommandLogging.WriteLine(
|
||||
from,
|
||||
"{0} {1} moving {2} to {3}",
|
||||
from.AccessLevel,
|
||||
CommandLogging.Format(from),
|
||||
CommandLogging.Format(m_Object),
|
||||
p
|
||||
);
|
||||
|
||||
if (m_Object is Item item)
|
||||
{
|
||||
if (!item.Deleted)
|
||||
{
|
||||
if (!item.Deleted)
|
||||
{
|
||||
item.MoveToWorld(new Point3D(p), from.Map);
|
||||
}
|
||||
item.MoveToWorld(p, from.Map);
|
||||
}
|
||||
else if (m_Object is Mobile m)
|
||||
}
|
||||
else if (m_Object is Mobile m)
|
||||
{
|
||||
if (!m.Deleted)
|
||||
{
|
||||
if (!m.Deleted)
|
||||
{
|
||||
m.MoveToWorld(new Point3D(p), from.Map);
|
||||
}
|
||||
m.MoveToWorld(p, from.Map);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue