From 30a394798be998174cdf75a94ec93c30a4589ffb Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Mon, 31 Dec 2018 21:12:58 +0100 Subject: [PATCH 1/2] Clean up control_set_gold_curs --- Source/control.cpp | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/Source/control.cpp b/Source/control.cpp index 92e739c94..5a1895e1a 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -2576,29 +2576,15 @@ void __fastcall control_remove_gold(int pnum, int gold_index) void __fastcall control_set_gold_curs(int pnum) { - int v1; // ecx - int v2; // eax - int *v3; // eax - BOOLEAN v4; // zf - BOOLEAN v5; // sf - unsigned char v6; // of - - v1 = pnum; - v2 = plr[v1].HoldItem._ivalue; - if (v2 < 2500) { - v6 = __OFSUB__(v2, 1000); - v4 = v2 == 1000; - v5 = v2 - 1000 < 0; - v3 = &plr[v1].HoldItem._iCurs; - if ((unsigned char)(v5 ^ v6) | v4) - *v3 = ICURS_GOLD_SMALL; - else - *v3 = ICURS_GOLD_MEDIUM; + if (plr[pnum].HoldItem._ivalue >= 2500) { + plr[pnum].HoldItem._iCurs = 6; } else { - v3 = &plr[v1].HoldItem._iCurs; - plr[v1].HoldItem._iCurs = ICURS_GOLD_LARGE; + if (plr[pnum].HoldItem._ivalue <= 1000) + plr[pnum].HoldItem._iCurs = 4; + else + plr[pnum].HoldItem._iCurs = 5; } - SetCursor_(*v3 + 12); + SetCursor_(plr[pnum].HoldItem._iCurs + CURSOR_FIRSTITEM); } void __cdecl DrawTalkPan() From 82d1f6c8e0cce01824ac052b2d568c6a317f6c7a Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Mon, 31 Dec 2018 22:29:49 +0100 Subject: [PATCH 2/2] Clean up CheckChrBtns --- Source/control.cpp | 103 ++++++++++++++++----------------------------- Source/control.h | 2 +- Source/diablo.cpp | 1 - 3 files changed, 37 insertions(+), 69 deletions(-) diff --git a/Source/control.cpp b/Source/control.cpp index 5a1895e1a..975e36f84 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -17,7 +17,7 @@ int lvlbtndown; // weak char sgszTalkSave[8][80]; int dropGoldValue; // idb BOOL drawmanaflag; // idb -int chrbtnactive; // weak +BOOL chrbtnactive; char sgszTalkMsg[80]; void *pPanelText; int frame_4B8800; // idb @@ -1006,7 +1006,7 @@ void __cdecl InitControlPan() chrbtn[0] = 0; chrbtn[1] = 0; chrbtn[2] = 0; - chrbtnactive = 0; + chrbtnactive = FALSE; chrbtn[3] = 0; pDurIcons = LoadFileInMem("Items\\DurIcons.CEL", 0); strcpy(infostr, ""); @@ -1038,7 +1038,6 @@ void __cdecl InitControlPan() } // 4B84DC: using guessed type int dropGoldFlag; // 4B851C: using guessed type int lvlbtndown; -// 4B87A8: using guessed type int chrbtnactive; // 4B8840: using guessed type int sgbPlrTalkTbl; // 4B8950: using guessed type int sbooktab; // 4B8960: using guessed type int talkflag; @@ -2037,69 +2036,41 @@ void __cdecl DrawLevelUpIcon() void __cdecl CheckChrBtns() { - int v0; // esi - int v1; // ecx - int v2; // ebx - int v3; // edi - int v4; // edx - BOOLEAN v5; // sf - unsigned char v6; // of - int v7; // edx - int v8; // edx - int v9; // edx - int v10; // eax - int v11; // edx - int v12; // edx + int pc, i; - v0 = 0; - if (!chrbtnactive) { - v1 = myplr; - if (plr[myplr]._pStatPts) { - v2 = MouseX; - v3 = plr[v1]._pClass; - while (1) { - if (!v0) { - v9 = plr[v1]._pBaseStr; - v6 = __OFSUB__(v9, MaxStats[v3][ATTRIB_STR]); - v5 = v9 - MaxStats[v3][ATTRIB_STR] < 0; - goto LABEL_12; - } - if (v0 == 1) { - v8 = plr[v1]._pBaseMag; - v6 = __OFSUB__(v8, MaxStats[v3][ATTRIB_MAG]); - v5 = v8 - MaxStats[v3][ATTRIB_MAG] < 0; - goto LABEL_12; - } - if (v0 == 2) - break; - if (v0 == 3) { - v4 = plr[v1]._pBaseVit; - v6 = __OFSUB__(v4, MaxStats[v3][ATTRIB_VIT]); - v5 = v4 - MaxStats[v3][ATTRIB_VIT] < 0; - LABEL_12: - if (v5 ^ v6) { - v10 = v0; - v11 = attribute_inc_rects[v0][0]; - if (v2 >= v11 && v2 <= v11 + attribute_inc_rects[v10][2]) { - v12 = attribute_inc_rects[v10][1]; - if (MouseY >= v12 && MouseY <= v12 + attribute_inc_rects[v10][3]) { - chrbtn[v0] = 1; - chrbtnactive = 1; - } - } - } - } - if (++v0 >= 4) - return; + if (!chrbtnactive && plr[myplr]._pStatPts) { + pc = plr[myplr]._pClass; + for (i = 0; i < 4; i++) { + switch (i) { + case ATTRIB_STR: + if (plr[myplr]._pBaseStr >= MaxStats[pc][ATTRIB_STR]) + continue; + break; + case ATTRIB_MAG: + if (plr[myplr]._pBaseMag >= MaxStats[pc][ATTRIB_MAG]) + continue; + break; + case ATTRIB_DEX: + if (plr[myplr]._pBaseDex >= MaxStats[pc][ATTRIB_DEX]) + continue; + break; + case ATTRIB_VIT: + if (plr[myplr]._pBaseVit >= MaxStats[pc][ATTRIB_VIT]) + continue; + break; + default: + continue; + } + if (MouseX >= attribute_inc_rects[i][0] + && MouseX <= attribute_inc_rects[i][0] + attribute_inc_rects[i][2] + && MouseY >= attribute_inc_rects[i][1] + && MouseY <= attribute_inc_rects[i][3] + attribute_inc_rects[i][1]) { + chrbtn[i] = 1; + chrbtnactive = TRUE; } - v7 = plr[v1]._pBaseDex; - v6 = __OFSUB__(v7, MaxStats[v3][ATTRIB_DEX]); - v5 = v7 - MaxStats[v3][ATTRIB_DEX] < 0; - goto LABEL_12; } } } -// 4B87A8: using guessed type int chrbtnactive; void __cdecl ReleaseChrBtns() { @@ -2110,7 +2081,7 @@ void __cdecl ReleaseChrBtns() int v4; // ecx unsigned char v5; // dl - chrbtnactive = 0; + chrbtnactive = FALSE; v0 = 0; do { v1 = &chrbtn[v0]; @@ -2147,7 +2118,6 @@ void __cdecl ReleaseChrBtns() ++v0; } while (v0 < 4); } -// 4B87A8: using guessed type int chrbtnactive; void __cdecl DrawDurIcon() { @@ -2577,12 +2547,12 @@ void __fastcall control_remove_gold(int pnum, int gold_index) void __fastcall control_set_gold_curs(int pnum) { if (plr[pnum].HoldItem._ivalue >= 2500) { - plr[pnum].HoldItem._iCurs = 6; + plr[pnum].HoldItem._iCurs = ICURS_GOLD_LARGE; } else { if (plr[pnum].HoldItem._ivalue <= 1000) - plr[pnum].HoldItem._iCurs = 4; + plr[pnum].HoldItem._iCurs = ICURS_GOLD_SMALL; else - plr[pnum].HoldItem._iCurs = 5; + plr[pnum].HoldItem._iCurs = ICURS_GOLD_MEDIUM; } SetCursor_(plr[pnum].HoldItem._iCurs + CURSOR_FIRSTITEM); } @@ -2846,7 +2816,6 @@ int __fastcall control_presskeys(int a1) } return 0; } -// 4B87A8: using guessed type int chrbtnactive; // 4B8960: using guessed type int talkflag; // 679660: using guessed type char gbMaxPlayers; diff --git a/Source/control.h b/Source/control.h index dab31e177..198be07e5 100644 --- a/Source/control.h +++ b/Source/control.h @@ -17,7 +17,7 @@ extern int lvlbtndown; // weak extern char sgszTalkSave[8][80]; extern int dropGoldValue; // idb extern BOOL drawmanaflag; // idb -extern int chrbtnactive; // weak +extern BOOL chrbtnactive; extern char sgszTalkMsg[80]; extern void *pPanelText; extern int frame_4B8800; // idb diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 32dd69fda..5f00b4472 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -975,7 +975,6 @@ void __cdecl LeftMouseUp() ReleaseStoreBtn(); } // 4B851C: using guessed type int lvlbtndown; -// 4B87A8: using guessed type int chrbtnactive; // 4B8C90: using guessed type int panbtndown; // 6AA705: using guessed type char stextflag;