Browse Source

Add function to get current grid

pull/4456/head
ephphatha 4 years ago committed by Anders Jenbo
parent
commit
cef42d47a8
  1. 4
      Source/qol/stash.cpp
  2. 8
      Source/qol/stash.h

4
Source/qol/stash.cpp

@ -132,7 +132,7 @@ void CheckStashPaste(Point cursorPosition)
} else {
stashIndex = it - 1;
cn = SwapItem(Stash.stashList[stashIndex], player.HoldItem);
for (auto &row : Stash.stashGrids[Stash.GetPage()]) {
for (auto &row : Stash.GetCurrentGrid()) {
for (auto &itemId : row) {
if (itemId == it)
itemId = 0;
@ -502,7 +502,7 @@ bool UseStashItem(uint16_t c)
void StashStruct::RemoveStashItem(uint16_t iv)
{
// Iterate through stashGrid and remove every reference to item
for (auto &row : Stash.stashGrids[Stash.GetPage()]) {
for (auto &row : Stash.GetCurrentGrid()) {
for (uint16_t &itemId : row) {
if (itemId - 1 == iv) {
itemId = 0;

8
Source/qol/stash.h

@ -17,7 +17,8 @@ namespace devilution {
class StashStruct {
public:
void RemoveStashItem(uint16_t iv);
std::map<unsigned, std::array<std::array<uint16_t, 10>, 10>> stashGrids;
using StashGrid = std::array<std::array<uint16_t, 10>, 10>;
std::map<unsigned, StashGrid> stashGrids;
std::vector<Item> stashList;
int gold;
bool dirty = false;
@ -27,6 +28,11 @@ public:
return page;
}
StashGrid &GetCurrentGrid()
{
return stashGrids[GetPage()];
}
void SetPage(unsigned newPage);
void NextPage(unsigned offset = 1);
void PreviousPage(unsigned offset = 1);

Loading…
Cancel
Save