From 98a74a89c777efa88bb7bd38ae7e591c49ec02cb Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Mon, 30 May 2022 15:47:06 -0700 Subject: [PATCH] fix: Fixes drag drop bounce issue (#1040) --- Projects/Server/Items/Item.cs | 7 ++- .../Items/Skill Items/Magical/Spellbook.cs | 44 ++++++++++--------- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/Projects/Server/Items/Item.cs b/Projects/Server/Items/Item.cs index 84bdf05d2..188bafc47 100644 --- a/Projects/Server/Items/Item.cs +++ b/Projects/Server/Items/Item.cs @@ -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 { diff --git a/Projects/UOContent/Items/Skill Items/Magical/Spellbook.cs b/Projects/UOContent/Items/Skill Items/Magical/Spellbook.cs index 500fc7b5c..cbb60611b 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Spellbook.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Spellbook.cs @@ -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;