fix: Fixes drag drop bounce issue (#1040)

This commit is contained in:
Kamron Batman 2022-05-30 15:47:06 -07:00 committed by GitHub
parent aeec7f78fd
commit 98a74a89c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 23 deletions

View file

@ -2074,9 +2074,12 @@ namespace Server
MoveToWorld(from.Location, from.Map);
}
}
else if ((parent as Mobile)?.EquipItem(this) == false)
else if (parent is Mobile mobile)
{
MoveToWorld(bounce.WorldLoc, bounce.Map);
if (!mobile.EquipItem(this))
{
MoveToWorld(bounce.WorldLoc, bounce.Map);
}
}
else
{

View file

@ -564,35 +564,37 @@ namespace Server.Items
public override bool OnDragDrop(Mobile from, Item dropped)
{
if (dropped is SpellScroll scroll && scroll.Amount == 1)
if (dropped is not SpellScroll { Amount: 1 } scroll)
{
var type = GetTypeForSpell(scroll.SpellID);
return false;
}
if (type != SpellbookType)
{
return false;
}
var type = GetTypeForSpell(scroll.SpellID);
if (HasSpell(scroll.SpellID))
{
from.SendLocalizedMessage(500179); // That spell is already present in that spellbook.
return false;
}
if (type != SpellbookType)
{
return false;
}
var val = scroll.SpellID - BookOffset;
if (HasSpell(scroll.SpellID))
{
from.SendLocalizedMessage(500179); // That spell is already present in that spellbook.
return false;
}
if (val >= 0 && val < BookCount)
{
m_Content |= (ulong)1 << val;
++SpellCount;
var val = scroll.SpellID - BookOffset;
InvalidateProperties();
if (val >= 0 && val < BookCount)
{
m_Content |= (ulong)1 << val;
++SpellCount;
scroll.Delete();
InvalidateProperties();
from.SendSound(0x249, GetWorldLocation());
return true;
}
scroll.Delete();
from.SendSound(0x249, GetWorldLocation());
return true;
}
return false;