Browse Source

Invalidate held item when pasting into the stash

Makes use of that Item::isEmpty check in NewCursor to set the hand cursor when empty handed.
pull/4484/head
ephphatha 4 years ago committed by Anders Jenbo
parent
commit
56138ecf25
  1. 9
      Source/qol/stash.cpp

9
Source/qol/stash.cpp

@ -88,6 +88,7 @@ void CheckStashPaste(Point cursorPosition)
if (player.HoldItem._itype == ItemType::Gold) {
Stash.gold += player.HoldItem._ivalue;
player.HoldItem._itype == ItemType::None;
PlaySFX(IS_GOLD);
Stash.dirty = true;
if (!IsHardwareCursor()) {
@ -125,14 +126,14 @@ void CheckStashPaste(Point cursorPosition)
player.HoldItem.position = firstSlot + Displacement { 0, itemSize.height - 1 };
int cn = CURSOR_HAND;
if (stashIndex == StashStruct::EmptyCell) {
Stash.stashList.push_back(player.HoldItem);
player.HoldItem._itype == ItemType::None;
// stashList will have at most 10 000 items, up to 65 535 are supported with uint16_t indexes
stashIndex = static_cast<uint16_t>(Stash.stashList.size() - 1);
} else {
// remove item from stash grid
cn = SwapItem(Stash.stashList[stashIndex], player.HoldItem);
std::swap(Stash.stashList[stashIndex], player.HoldItem);
for (auto &row : Stash.GetCurrentGrid()) {
for (auto &itemId : row) {
if (itemId - 1 == stashIndex)
@ -145,11 +146,11 @@ void CheckStashPaste(Point cursorPosition)
Stash.dirty = true;
if (cn == CURSOR_HAND && !IsHardwareCursor()) {
if (player.HoldItem.isEmpty() && !IsHardwareCursor()) {
// To make software cursors behave like hardware cursors we need to adjust the hand cursor position manually
SetCursorPos(cursorPosition + hotPixelOffset);
}
NewCursor(cn);
NewCursor(player.HoldItem);
}
void CheckStashCut(Point cursorPosition, bool automaticMove)

Loading…
Cancel
Save