From b5a89578f0ba757d213e34d7d89e4b2d86121c4d Mon Sep 17 00:00:00 2001 From: Juliano Leal Goncalves Date: Mon, 15 Mar 2021 23:17:30 -0300 Subject: [PATCH] :recycle: Pass ItemStruct on inv InvGetItem function --- Source/inv.cpp | 10 +++++----- Source/inv.h | 2 +- Source/msg.cpp | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Source/inv.cpp b/Source/inv.cpp index c2437168c..bf21e54a7 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -2123,28 +2123,28 @@ void CleanupItems(ItemStruct *item, int ii) } } -void InvGetItem(int pnum, int ii) +void InvGetItem(int pnum, ItemStruct *item, int ii) { if (dropGoldFlag) { dropGoldFlag = FALSE; dropGoldValue = 0; } - if (dItem[items[ii]._ix][items[ii]._iy] == 0) + if (dItem[item->_ix][item->_iy] == 0) return; if (myplr == pnum && pcurs >= CURSOR_FIRSTITEM) NetSendCmdPItem(TRUE, CMD_SYNCPUTITEM, plr[myplr]._px, plr[myplr]._py); - items[ii]._iCreateInfo &= ~CF_PREGEN; - plr[pnum].HoldItem = items[ii]; + item->_iCreateInfo &= ~CF_PREGEN; + plr[pnum].HoldItem = *item; CheckQuestItem(pnum); CheckBookLevel(pnum); CheckItemStats(pnum); bool cursor_updated = false; if (gbIsHellfire && plr[pnum].HoldItem._itype == ITYPE_GOLD && GoldAutoPlace(pnum)) cursor_updated = true; - CleanupItems(&items[ii], ii); + CleanupItems(item, ii); pcursitem = -1; if (!cursor_updated) SetCursor_(plr[pnum].HoldItem._iCurs + CURSOR_FIRSTITEM); diff --git a/Source/inv.h b/Source/inv.h index 712fc28e5..b6c2a372b 100644 --- a/Source/inv.h +++ b/Source/inv.h @@ -52,7 +52,7 @@ void RemoveSpdBarItem(int pnum, int iv); void CheckInvItem(bool isShiftHeld = false); void CheckInvScrn(bool isShiftHeld); void CheckItemStats(int pnum); -void InvGetItem(int pnum, int ii); +void InvGetItem(int pnum, ItemStruct *item, int ii); void AutoGetItem(int pnum, int ii); int FindGetItem(int idx, WORD ci, int iseed); void SyncGetItem(int x, int y, int idx, WORD ci, int iseed); diff --git a/Source/msg.cpp b/Source/msg.cpp index d7b42a2e8..90b419883 100644 --- a/Source/msg.cpp +++ b/Source/msg.cpp @@ -1399,7 +1399,7 @@ static DWORD On_REQUESTGITEM(TCmd *pCmd, int pnum) if (p->bPnum != myplr) SyncGetItem(p->x, p->y, p->wIndx, p->wCI, p->dwSeed); else - InvGetItem(myplr, ii); + InvGetItem(myplr, &items[ii], ii); SetItemRecord(p->dwSeed, p->wCI, p->wIndx); } else if (!NetSendCmdReq2(CMD_REQUESTGITEM, myplr, p->bPnum, p)) NetSendCmdExtra(p); @@ -1423,9 +1423,9 @@ static DWORD On_GETITEM(TCmd *pCmd, int pnum) if (currlevel != p->bLevel) { ii = SyncPutItem(myplr, plr[myplr]._px, plr[myplr]._py, p->wIndx, p->wCI, p->dwSeed, p->bId, p->bDur, p->bMDur, p->bCh, p->bMCh, p->wValue, p->dwBuff, p->wToHit, p->wMaxDam, p->bMinStr, p->bMinMag, p->bMinDex, p->bAC); if (ii != -1) - InvGetItem(myplr, ii); + InvGetItem(myplr, &items[ii], ii); } else - InvGetItem(myplr, ii); + InvGetItem(myplr, &items[ii], ii); } else SyncGetItem(p->x, p->y, p->wIndx, p->wCI, p->dwSeed); }