From 797cf17c1932ecad1c207a62d86716c414f60e12 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Fri, 5 Apr 2019 20:14:47 +0200 Subject: [PATCH] Clean up UseScroll --- Source/inv.cpp | 47 +++++++++++++++++++---------------------------- Source/inv.h | 2 +- 2 files changed, 20 insertions(+), 29 deletions(-) diff --git a/Source/inv.cpp b/Source/inv.cpp index 9250bdbee..0ff0e00fa 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -2115,7 +2115,7 @@ BOOL __fastcall CanPut(int x, int y) return TRUE; } -int __cdecl TryInvPut() +BOOL __cdecl TryInvPut() { int dir; @@ -2524,38 +2524,29 @@ void __fastcall RemoveScroll(int pnum) BOOL __cdecl UseScroll() { - int v0; // eax - int v1; // esi - int v2; // ecx - int *v3; // edx - signed int v4; // esi - int *v5; // ecx + int i; - if (pcurs != CURSOR_HAND || leveltype == DTYPE_TOWN && !spelldata[plr[myplr]._pRSpell].sTownSpell) + if (pcurs != CURSOR_HAND) + return FALSE; + if (leveltype == DTYPE_TOWN && !spelldata[plr[myplr]._pRSpell].sTownSpell) return FALSE; - v0 = myplr; - v1 = 0; - v2 = plr[myplr]._pNumInv; - if (v2 <= 0) { - LABEL_11: - v4 = 0; - v5 = &plr[v0].SpdList[0]._iMiscId; - while (*(v5 - 53) == -1 || *v5 != IMISC_SCROLL && *v5 != IMISC_SCROLLT || v5[1] != plr[v0]._pRSpell) { - ++v4; - v5 += 92; - if (v4 >= MAXBELTITEMS) - return FALSE; + + for (i = 0; i < plr[myplr]._pNumInv; i++) { + if (plr[myplr].InvList[i]._itype != -1 + && (plr[myplr].InvList[i]._iMiscId == IMISC_SCROLL || plr[myplr].InvList[i]._iMiscId == IMISC_SCROLLT) + && plr[myplr].InvList[i]._iSpell == plr[myplr]._pRSpell) { + return TRUE; } - } else { - v3 = &plr[v0].InvList[0]._iMiscId; - while (*(v3 - 53) == -1 || *v3 != IMISC_SCROLL && *v3 != IMISC_SCROLLT || v3[1] != plr[v0]._pRSpell) { - ++v1; - v3 += 92; - if (v1 >= v2) - goto LABEL_11; + } + for (i = 0; i < MAXBELTITEMS; i++) { + if (plr[myplr].SpdList[i]._itype != -1 + && (plr[myplr].SpdList[i]._iMiscId == IMISC_SCROLL || plr[myplr].SpdList[i]._iMiscId == IMISC_SCROLLT) + && plr[myplr].SpdList[i]._iSpell == plr[myplr]._pRSpell) { + return TRUE; } } - return TRUE; + + return FALSE; } void __fastcall UseStaffCharge(int pnum) diff --git a/Source/inv.h b/Source/inv.h index fb57f9ed6..5f840863b 100644 --- a/Source/inv.h +++ b/Source/inv.h @@ -31,7 +31,7 @@ void __fastcall AutoGetItem(int pnum, int ii); int __fastcall FindGetItem(int indx, WORD ci, int iseed); void __fastcall SyncGetItem(int x, int y, int idx, WORD ci, int iseed); BOOL __fastcall CanPut(int x, int y); -int __cdecl TryInvPut(); +BOOL __cdecl TryInvPut(); void __fastcall DrawInvMsg(char *msg); int __fastcall InvPutItem(int pnum, int x, int y); int __fastcall SyncPutItem(int pnum, int x, int y, int idx, WORD icreateinfo, int iseed, int Id, int dur, int mdur, int ch, int mch, int ivalue, unsigned int ibuff);