@@ -837,20 +837,25 @@ void CheckInvCut(Player &player, Point cursorPosition, bool automaticMove, bool
837
837
// the left hand), invloc isn't used there.
838
838
invloc = INVLOC_HAND_RIGHT;
839
839
} else {
840
- // Both hands are holding items, we must unequip the right hand item and check that there's
841
- // space for the left before trying to auto-equip
842
- if (!AutoPlaceItemInInventory (player, player.InvBody [INVLOC_HAND_RIGHT])) {
843
- // No space to move right hand item to inventory, abort.
844
- break ;
840
+ // Both hands are holding items, we must unequip one of the items and check that there's
841
+ // space for the other before trying to auto-equip
842
+ inv_body_loc mainHand = INVLOC_HAND_LEFT;
843
+ inv_body_loc offHand = INVLOC_HAND_RIGHT;
844
+ if (!AutoPlaceItemInInventory (player, player.InvBody [offHand])) {
845
+ // No space to move right hand item to inventory, can we move the left instead?
846
+ std::swap (mainHand, offHand);
847
+ if (!AutoPlaceItemInInventory (player, player.InvBody [offHand])) {
848
+ break ;
849
+ }
845
850
}
846
- if (!CouldFitItemInInventory (player, player.InvBody [INVLOC_HAND_LEFT ], iv)) {
847
- // No space for left item. Move back right item to right hand and abort.
848
- player.InvBody [INVLOC_HAND_RIGHT ] = player.InvList [player._pNumInv - 1 ];
851
+ if (!CouldFitItemInInventory (player, player.InvBody [mainHand ], iv)) {
852
+ // No space for the main hand item. Move the other item back to the off hand and abort.
853
+ player.InvBody [offHand ] = player.InvList [player._pNumInv - 1 ];
849
854
player.RemoveInvItem (player._pNumInv - 1 , false );
850
855
break ;
851
856
}
852
- RemoveEquipment (player, INVLOC_HAND_RIGHT , false );
853
- invloc = INVLOC_HAND_LEFT ;
857
+ RemoveEquipment (player, offHand , false );
858
+ invloc = mainHand ;
854
859
}
855
860
break ;
856
861
default :
0 commit comments