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
|
|
@ -282,19 +282,21 @@ namespace Server.Gumps
|
|||
|
||||
protected override void OnTarget(Mobile from, object o)
|
||||
{
|
||||
if (o is IPoint3D p)
|
||||
if (o is not IPoint3D ip)
|
||||
{
|
||||
p = p switch
|
||||
{
|
||||
Item item => item.GetWorldTop(),
|
||||
Mobile m => m.Location,
|
||||
_ => p
|
||||
};
|
||||
|
||||
Commands.Add.Invoke(from, new Point3D(p), new Point3D(p), new[] { m_Type.Name });
|
||||
|
||||
from.Target = new InternalTarget(m_Type, m_SearchResults, m_SearchString, m_Page);
|
||||
return;
|
||||
}
|
||||
|
||||
Point3D p = ip switch
|
||||
{
|
||||
Item item => item.GetWorldTop(),
|
||||
Mobile m => m.Location,
|
||||
_ => new Point3D(ip)
|
||||
};
|
||||
|
||||
Commands.Add.Invoke(from, new Point3D(p), new Point3D(p), new[] { m_Type.Name });
|
||||
|
||||
from.Target = new InternalTarget(m_Type, m_SearchResults, m_SearchString, m_Page);
|
||||
}
|
||||
|
||||
protected override void OnTargetCancel(Mobile from, TargetCancelType cancelType)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue