Browse Source

♻️ Reuse existing functions in place of 'SpecialAutoPlace'

pull/1407/head
Juliano Leal Goncalves 5 years ago committed by Anders Jenbo
parent
commit
cae4461c39
  1. 2
      Source/inv.cpp
  2. 1
      Source/inv.h
  3. 12
      Source/stores.cpp

2
Source/inv.cpp

@ -634,7 +634,7 @@ bool CanBePlacedOnBelt(const ItemStruct &item)
* @param persistItem Pass 'True' to actually place the item in the belt. The default is 'False'.
* @return 'True' in case the item can be placed on the player's belt and 'False' otherwise.
*/
bool AutoPlaceItemInBelt(int playerNumber, const ItemStruct &item, bool persistItem = false)
bool AutoPlaceItemInBelt(int playerNumber, const ItemStruct &item, bool persistItem)
{
if (!CanBePlacedOnBelt(item)) {
return false;

1
Source/inv.h

@ -43,6 +43,7 @@ void DrawInvBelt(CelOutputBuffer out);
bool AutoEquipEnabled(const PlayerStruct &player, const ItemStruct &item);
bool AutoEquip(int playerNumber, const ItemStruct &item, bool persistItem = true);
bool AutoPlaceItemInInventorySlot(int playerNumber, int slotIndex, const ItemStruct &item, bool persistItem);
bool AutoPlaceItemInBelt(int playerNumber, const ItemStruct &item, bool persistItem = false);
BOOL SpecialAutoPlace(int pnum, int ii, const ItemStruct &item);
BOOL GoldAutoPlace(int pnum);
void CheckInvSwap(int pnum, BYTE bLoc, int idx, WORD wCI, int seed, BOOL bId, uint32_t dwBuff);

12
Source/stores.cpp

@ -1705,7 +1705,11 @@ void S_WBuyEnter()
}
for (i = 0; i < NUM_INV_GRID_ELEM && !done; i++) {
done = SpecialAutoPlace(myplr, i, plr[myplr].HoldItem);
done = AutoPlaceItemInInventorySlot(myplr, i, plr[myplr].HoldItem, false);
}
if (!done) {
done = AutoPlaceItemInBelt(myplr, plr[myplr].HoldItem, false);
}
if (done)
@ -2016,7 +2020,11 @@ void S_HBuyEnter()
}
for (i = 0; i < NUM_INV_GRID_ELEM && !done; i++) {
done = SpecialAutoPlace(myplr, i, plr[myplr].HoldItem);
done = AutoPlaceItemInInventorySlot(myplr, i, plr[myplr].HoldItem, false);
}
if (!done) {
done = AutoPlaceItemInBelt(myplr, plr[myplr].HoldItem, false);
}
if (done)

Loading…
Cancel
Save