Browse Source

🐛 Use 'Spell' instead of 'RSpell' for clearing used inventory scrolls

Readied spell can be swapped to something else in between the cast and the hit frame, resulting in incorrect removal.

This is how currently belt scrolls are checked so we are now using a consistent strategy.
pull/2849/head
Juliano Leal Goncalves 5 years ago committed by Anders Jenbo
parent
commit
776a3d4e84
  1. 2
      Source/inv.cpp
  2. 2
      test/inv_test.cpp

2
Source/inv.cpp

@ -1911,7 +1911,7 @@ void RemoveScroll(Player &player)
for (int i = 0; i < player._pNumInv; i++) {
if (!player.InvList[i].isEmpty()
&& (player.InvList[i]._iMiscId == IMISC_SCROLL || player.InvList[i]._iMiscId == IMISC_SCROLLT)
&& player.InvList[i]._iSpell == player._pRSpell) {
&& player.InvList[i]._iSpell == player._pSpell) {
player.RemoveInvItem(i);
player.CalcScrolls();
return;

2
test/inv_test.cpp

@ -198,7 +198,7 @@ TEST(Inv, RemoveScroll_inventory)
// Put a firebolt scroll into the inventory
Players[MyPlayerId]._pNumInv = 1;
Players[MyPlayerId]._pRSpell = static_cast<spell_id>(SPL_FIREBOLT);
Players[MyPlayerId]._pSpell = static_cast<spell_id>(SPL_FIREBOLT);
Players[MyPlayerId].InvList[0]._itype = ITYPE_MISC;
Players[MyPlayerId].InvList[0]._iMiscId = IMISC_SCROLL;
Players[MyPlayerId].InvList[0]._iSpell = SPL_FIREBOLT;

Loading…
Cancel
Save