From 6901d9e0fbf7a6743f1e32493766f7022057dadb Mon Sep 17 00:00:00 2001 From: Andrew James Date: Sat, 7 Sep 2024 19:51:47 +1000 Subject: [PATCH] don't trample over holditem unnecessarily --- Source/inv.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Source/inv.cpp b/Source/inv.cpp index 21ef3f5fd..05426a0cd 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -759,13 +759,13 @@ void CheckInvCut(Player &player, Point cursorPosition, bool automaticMove, bool break; case ILOC_ONEHAND: // User is attempting to move a weapon (left hand) - if (player.InvList[iv - 1]._iClass == player.InvBody[INVLOC_HAND_LEFT]._iClass - && player.GetItemLocation(player.InvList[iv - 1]) == player.GetItemLocation(player.InvBody[INVLOC_HAND_LEFT])) { + if (holdItem._iClass == player.InvBody[INVLOC_HAND_LEFT]._iClass + && player.GetItemLocation(holdItem) == player.GetItemLocation(player.InvBody[INVLOC_HAND_LEFT])) { invloc = INVLOC_HAND_LEFT; } // User is attempting to move a shield (right hand) - if (player.InvList[iv - 1]._iClass == player.InvBody[INVLOC_HAND_RIGHT]._iClass - && player.GetItemLocation(player.InvList[iv - 1]) == player.GetItemLocation(player.InvBody[INVLOC_HAND_RIGHT])) { + if (holdItem._iClass == player.InvBody[INVLOC_HAND_RIGHT]._iClass + && player.GetItemLocation(holdItem) == player.GetItemLocation(player.InvBody[INVLOC_HAND_RIGHT])) { invloc = INVLOC_HAND_RIGHT; } // A two-hand item can always be replaced with a one-hand item @@ -808,14 +808,12 @@ void CheckInvCut(Player &player, Point cursorPosition, bool automaticMove, bool } // Empty the identified InvBody slot (invloc) and hand over to AutoEquip if (invloc != NUM_INVLOC) { - holdItem = player.InvBody[invloc]; - if (player.InvBody[invloc]._itype != ItemType::None) { - if (AutoPlaceItemInInventory(player, holdItem, true)) { + if (!player.InvBody[invloc].isEmpty()) { + if (AutoPlaceItemInInventory(player, player.InvBody[invloc], true)) { player.InvBody[invloc].clear(); } } } - holdItem = player.InvList[iv - 1]; automaticallyMoved = automaticallyEquipped = AutoEquip(player, holdItem, true, &player == MyPlayer); } }