diff --git a/SourceX/controls/plrctrls.cpp b/SourceX/controls/plrctrls.cpp index 349c374a7..cfeb4d71a 100644 --- a/SourceX/controls/plrctrls.cpp +++ b/SourceX/controls/plrctrls.cpp @@ -930,18 +930,26 @@ void UpdateSpellTarget() cursmy = player._py + kOffsets[player._pdir][1]; } +/** + * @brief Try dropping item in all 9 possible places + */ +void TryDropItem() +{ + cursmx = plr[myplr].WorldX; + cursmy = plr[myplr].WorldY; + if (!DropItemBeforeTrig()) { + cursmx--; // Try to drop on the other side + cursmy++; + DropItemBeforeTrig(); + } +} + void PerformSpellAction() { if (invflag) { int spl = plr[myplr]._pRSpell; if (pcurs >= CURSOR_FIRSTITEM) { - cursmx = plr[myplr].WorldX; - cursmy = plr[myplr].WorldY; - if (!DropItemBeforeTrig()) { - cursmx--; // Try to drop on the other side - cursmy++; - DropItemBeforeTrig(); - } + TryDropItem(); return; } if (spl != SPL_IDENTIFY && spl != SPL_REPAIR && spl != SPL_RECHARGE) diff --git a/SourceX/controls/plrctrls.h b/SourceX/controls/plrctrls.h index 784da9202..9d106def4 100644 --- a/SourceX/controls/plrctrls.h +++ b/SourceX/controls/plrctrls.h @@ -31,6 +31,7 @@ void PerformPrimaryAction(); // Open chests, doors, pickup items. void PerformSecondaryAction(); +void TryDropItem(); void PerformSpellAction(); typedef struct coords { diff --git a/SourceX/miniwin/misc_msg.cpp b/SourceX/miniwin/misc_msg.cpp index 34c7cff5d..e6f9874b8 100644 --- a/SourceX/miniwin/misc_msg.cpp +++ b/SourceX/miniwin/misc_msg.cpp @@ -319,16 +319,33 @@ void StoreSpellCoords() } // namespace /** - * @brief Clean the inventory related cursor states. + * @brief Try to clean the inventory related cursor states. + * @return True if it is safe to close the inventory */ -void BlurInventory() +bool BlurInventory() { - if (pcurs >= CURSOR_FIRSTITEM) // drop item to allow us to pick up other items - DropItemBeforeTrig(); + if (pcurs >= CURSOR_FIRSTITEM) { + TryDropItem(); + if (pcurs >= CURSOR_FIRSTITEM) { + if (plr[myplr]._pClass == PC_WARRIOR) { + PlaySFX(PS_WARR16); // "Where would I put this?" +#ifndef SPAWN + } else if (plr[myplr]._pClass == PC_ROGUE) { + PlaySFX(PS_ROGUE16); + } else if (plr[myplr]._pClass == PC_SORCERER) { + PlaySFX(PS_MAGE16); +#endif + } + return false; + } + } + if (pcurs == CURSOR_REPAIR || pcurs == CURSOR_RECHARGE) SetCursor_(CURSOR_HAND); if (chrflag) FocusOnCharInfo(); + + return true; } WINBOOL PeekMessageA(LPMSG lpMsg) @@ -411,14 +428,15 @@ WINBOOL PeekMessageA(LPMSG lpMsg) PerformSpellAction(); break; case GameActionType::TOGGLE_QUICK_SPELL_MENU: - lpMsg->message = DVL_WM_KEYDOWN; - lpMsg->wParam = 'S'; - chrflag = false; - questlog = false; - invflag = false; - BlurInventory(); - sbookflag = false; - StoreSpellCoords(); + if (BlurInventory()) { + lpMsg->message = DVL_WM_KEYDOWN; + lpMsg->wParam = 'S'; + chrflag = false; + questlog = false; + invflag = false; + sbookflag = false; + StoreSpellCoords(); + } break; case GameActionType::TOGGLE_CHARACTER_INFO: chrflag = !chrflag; @@ -429,13 +447,13 @@ WINBOOL PeekMessageA(LPMSG lpMsg) } break; case GameActionType::TOGGLE_INVENTORY: - invflag = !invflag; if (invflag) { + invflag = !BlurInventory(); + } else { sbookflag = false; spselflag = false; + invflag = true; FocusOnInventory(); - } else { - BlurInventory(); } break; case GameActionType::SEND_KEY: