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:
Kamron Batman 2022-03-20 23:15:59 -07:00 • committed by GitHub
parent 23532db603
commit 0925a2d435
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 184 additions and 958 deletions

View file

@ -37,20 +37,22 @@ namespace Server
protected override void OnTarget(Mobile from, object targeted)
{
if (targeted is not IPoint3D p)
if (targeted is not IPoint3D ip)
{
return;
}
if (p is Item item)
Point3D p = ip switch
{
p = item.GetWorldTop();
}
Item item => item.GetWorldTop(),
Mobile m => m.Location,
_ => new Point3D(ip)
};
if (m_First)
{
from.SendMessage("Target another location to complete the bounding box.");
from.Target = new PickTarget(new Point3D(p), false, from.Map, m_Callback);
from.Target = new PickTarget(p, false, from.Map, m_Callback);
}
else if (from.Map != m_Map)
{
@ -59,7 +61,7 @@ namespace Server
else if (m_Map != null && m_Map != Map.Internal && m_Callback != null)
{
var start = m_Store;
var end = new Point3D(p);
var end = p;
Utility.FixPoints(ref start, ref end);