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
|
|
@ -176,7 +176,7 @@ namespace Server.Multis
|
|||
{
|
||||
if (ip is Item item)
|
||||
{
|
||||
ip = item.GetWorldTop();
|
||||
ip = from;
|
||||
}
|
||||
|
||||
var p = new Point3D(ip);
|
||||
|
|
|
|||
|
|
@ -194,29 +194,31 @@ namespace Server.Multis
|
|||
|
||||
protected override void OnTarget(Mobile from, object o)
|
||||
{
|
||||
if (o is IPoint3D ip)
|
||||
if (o is not IPoint3D ip)
|
||||
{
|
||||
if (ip is Item item)
|
||||
{
|
||||
ip = item.GetWorldTop();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
var p = new Point3D(ip);
|
||||
Point3D p = ip switch
|
||||
{
|
||||
Item item => item.GetWorldTop(),
|
||||
Mobile m => m.Location,
|
||||
_ => new Point3D(ip)
|
||||
};
|
||||
|
||||
var region = Region.Find(p, from.Map);
|
||||
var region = Region.Find(p, from.Map);
|
||||
|
||||
if (region.IsPartOf<DungeonRegion>())
|
||||
{
|
||||
from.SendLocalizedMessage(502488); // You can not place a ship inside a dungeon.
|
||||
}
|
||||
else if (region.IsPartOf<HouseRegion>() || region.IsPartOf<ChampionSpawnRegion>())
|
||||
{
|
||||
from.SendLocalizedMessage(1042549); // A boat may not be placed in this area.
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Model.OnPlacement(from, p);
|
||||
}
|
||||
if (region.IsPartOf<DungeonRegion>())
|
||||
{
|
||||
from.SendLocalizedMessage(502488); // You can not place a ship inside a dungeon.
|
||||
}
|
||||
else if (region.IsPartOf<HouseRegion>() || region.IsPartOf<ChampionSpawnRegion>())
|
||||
{
|
||||
from.SendLocalizedMessage(1042549); // A boat may not be placed in this area.
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Model.OnPlacement(from, p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue