Fix bounce exploit (#281)

Bumps release version
This commit is contained in:
Kamron Batman 2020-10-20 22:57:57 -07:00 • committed by GitHub
parent d366fa8e3c
commit 185bee7ae2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 36 deletions

View file

@ -18,6 +18,8 @@ namespace Server
bool InRange(Point3D p, int range); bool InRange(Point3D p, int range);
bool InRange(IPoint2D p, int range); bool InRange(IPoint2D p, int range);
void RemoveItem(Item item);
} }
public class Entity : IEntity, IComparable<Entity> public class Entity : IEntity, IComparable<Entity>
@ -62,6 +64,10 @@ namespace Server
{ {
} }
public void RemoveItem(Item item)
{
}
public bool InRange(Point2D p, int range) => public bool InRange(Point2D p, int range) =>
p.m_X >= Location.m_X - range p.m_X >= Location.m_X - range
&& p.m_X <= Location.m_X + range && p.m_X <= Location.m_X + range

View file

@ -2170,60 +2170,54 @@ namespace Server
public void Bounce(Mobile from) public void Bounce(Mobile from)
{ {
if (m_Parent is Item item) m_Parent.RemoveItem(this);
{
item.RemoveItem(this);
}
else if (m_Parent is Mobile mobile)
{
mobile.RemoveItem(this);
}
m_Parent = null; m_Parent = null;
var bounce = GetBounce(); var bounce = GetBounce();
if (bounce != null) if (bounce == null)
{ {
var parent = bounce.Parent; MoveToWorld(from.Location, from.Map);
return;
}
if (parent?.Deleted != false) var parent = bounce.Parent;
{
MoveToWorld(bounce.WorldLoc, bounce.Map);
}
else if (parent is Item p)
{
var root = p.RootParent;
if (p.IsAccessibleTo(from) && if (parent?.Deleted != false)
(!(root is Mobile mobileRoot) || mobileRoot.CheckNonlocalDrop(from, this, p))) {
{ MoveToWorld(from.Location, from.Map);
Location = bounce.Location; return;
p.AddItem(this); }
}
else if (parent is Item ip)
{ {
MoveToWorld(from.Location, from.Map); var root = ip.RootParent;
} var rpm = root as Mobile;
}
else if (parent is Mobile parentMobile) if (ip.IsAccessibleTo(from) &&
rpm?.CheckNonlocalDrop(from, this, ip) == true &&
(!ip.Movable || rpm == from || ip.Map == bounce.Map && root.Location == bounce.WorldLoc)
)
{ {
if (!parentMobile.EquipItem(this)) Location = bounce.Location;
{ ip.AddItem(this);
MoveToWorld(bounce.WorldLoc, bounce.Map);
}
} }
else else
{ {
MoveToWorld(bounce.WorldLoc, bounce.Map); MoveToWorld(from.Location, from.Map);
} }
}
ClearBounce(); else if ((parent as Mobile)?.EquipItem(this) == false)
{
MoveToWorld(bounce.WorldLoc, bounce.Map);
} }
else else
{ {
MoveToWorld(from.Location, from.Map); MoveToWorld(from.Location, from.Map);
} }
ClearBounce();
} }
/// <summary> /// <summary>