From 3358f619e29ea5cf4c073d60ec2bdf79bfc30702 Mon Sep 17 00:00:00 2001 From: qndel Date: Sat, 13 Apr 2019 12:01:56 +0200 Subject: [PATCH 1/3] ReleaseChrBtns bin exact --- Source/control.cpp | 68 ++++++++++++++++++++-------------------------- Source/control.h | 2 +- 2 files changed, 30 insertions(+), 40 deletions(-) diff --git a/Source/control.cpp b/Source/control.cpp index cf40916b8..2af6b6e01 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -9,7 +9,7 @@ void *pChrButtons; BOOL drawhpflag; // idb BOOL dropGoldFlag; int panbtn[8]; -int chrbtn[4]; +BOOL chrbtn[4]; void *pMultiBtns; void *pPanelButtons; void *pChrPanel; @@ -2290,7 +2290,7 @@ void CheckChrBtns() && 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; + chrbtn[i] = TRUE; chrbtnactive = TRUE; } } @@ -2299,49 +2299,39 @@ void CheckChrBtns() void ReleaseChrBtns() { - signed int v0; // esi - int *v1; // eax - signed int v2; // eax - int v3; // ecx - int v4; // ecx - unsigned char v5; // dl + int i; chrbtnactive = FALSE; - v0 = 0; - do { - v1 = &chrbtn[v0]; - if (*v1) { - *v1 = 0; - v2 = v0; - v3 = attribute_inc_rects[v0][0]; - if (MouseX >= v3 && MouseX <= v3 + attribute_inc_rects[v2][2]) { - v4 = attribute_inc_rects[v2][1]; - if (MouseY >= v4 && MouseY <= v4 + attribute_inc_rects[v2][3]) { - if (v0) { - switch (v0) { - case ATTRIB_MAG: - v5 = CMD_ADDMAG; - break; - case ATTRIB_DEX: - v5 = CMD_ADDDEX; - break; - case ATTRIB_VIT: - v5 = CMD_ADDVIT; - break; - default: - goto LABEL_16; - } - } else { - v5 = CMD_ADDSTR; - } - NetSendCmdParam1(TRUE, v5, 1u); + for (i = 0; i < 4; ++i) { + if (chrbtn[i]) { + chrbtn[i] = FALSE; + 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]) { + switch (i) { + case 0: + NetSendCmdParam1(TRUE, CMD_ADDSTR, 1); --plr[myplr]._pStatPts; + break; + case 1: + NetSendCmdParam1(TRUE, CMD_ADDMAG, 1); + --plr[myplr]._pStatPts; + break; + case 2: + NetSendCmdParam1(TRUE, CMD_ADDDEX, 1); + --plr[myplr]._pStatPts; + break; + case 3: + NetSendCmdParam1(TRUE, CMD_ADDVIT, 1); + --plr[myplr]._pStatPts; + break; + default: + continue; } } } - LABEL_16: - ++v0; - } while (v0 < 4); + } } void DrawDurIcon() diff --git a/Source/control.h b/Source/control.h index e3fe07537..2cb9fe7f5 100644 --- a/Source/control.h +++ b/Source/control.h @@ -7,7 +7,7 @@ extern void *pChrButtons; extern BOOL drawhpflag; // idb extern BOOL dropGoldFlag; extern int panbtn[8]; -extern int chrbtn[4]; +extern BOOL chrbtn[4]; extern void *pMultiBtns; extern void *pPanelButtons; extern void *pChrPanel; From 92200e984c0f343f522d164acff07bb60c8f1098 Mon Sep 17 00:00:00 2001 From: qndel Date: Sat, 13 Apr 2019 14:07:15 +0200 Subject: [PATCH 2/3] ReleaseChrBtns bin exact - with suggestions applied --- Source/control.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Source/control.cpp b/Source/control.cpp index d1d55f541..83e8a806d 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -2264,22 +2264,20 @@ void ReleaseChrBtns() switch (i) { case 0: NetSendCmdParam1(TRUE, CMD_ADDSTR, 1); - --plr[myplr]._pStatPts; + plr[myplr]._pStatPts--; break; case 1: NetSendCmdParam1(TRUE, CMD_ADDMAG, 1); - --plr[myplr]._pStatPts; + plr[myplr]._pStatPts--; break; case 2: NetSendCmdParam1(TRUE, CMD_ADDDEX, 1); - --plr[myplr]._pStatPts; + plr[myplr]._pStatPts--; break; case 3: NetSendCmdParam1(TRUE, CMD_ADDVIT, 1); - --plr[myplr]._pStatPts; + plr[myplr]._pStatPts--; break; - default: - continue; } } } From 0501ff10ef1de121c22c5756b678304ca59ed154 Mon Sep 17 00:00:00 2001 From: Robin Eklind Date: Wed, 17 Apr 2019 11:36:30 +0900 Subject: [PATCH 3/3] Use RECT32 struct for attribute_inc_rects --- Source/control.cpp | 18 +++++++++--------- Source/control.h | 2 +- structs.h | 12 ++++++++++++ 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/Source/control.cpp b/Source/control.cpp index 83e8a806d..88d655efe 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -159,7 +159,7 @@ char *PanBtnStr[8] = { "Send Message", "Player Attack" }; -int attribute_inc_rects[4][4] = { +RECT32 attribute_inc_rects[4] = { { 137, 138, 41, 22 }, { 137, 166, 41, 22 }, { 137, 195, 41, 22 }, @@ -2238,10 +2238,10 @@ void CheckChrBtns() 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]) { + if (MouseX >= attribute_inc_rects[i].x + && MouseX <= attribute_inc_rects[i].x + attribute_inc_rects[i].w + && MouseY >= attribute_inc_rects[i].y + && MouseY <= attribute_inc_rects[i].y + attribute_inc_rects[i].h) { chrbtn[i] = TRUE; chrbtnactive = TRUE; } @@ -2257,10 +2257,10 @@ void ReleaseChrBtns() for (i = 0; i < 4; ++i) { if (chrbtn[i]) { chrbtn[i] = FALSE; - 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]) { + if (MouseX >= attribute_inc_rects[i].x + && MouseX <= attribute_inc_rects[i].x + attribute_inc_rects[i].w + && MouseY >= attribute_inc_rects[i].y + && MouseY <= attribute_inc_rects[i].y + attribute_inc_rects[i].h) { switch (i) { case 0: NetSendCmdParam1(TRUE, CMD_ADDSTR, 1); diff --git a/Source/control.h b/Source/control.h index 2cb9fe7f5..c4561824e 100644 --- a/Source/control.h +++ b/Source/control.h @@ -131,7 +131,7 @@ extern unsigned char SpellITbl[MAX_SPELLS]; extern int PanBtnPos[8][5]; extern char *PanBtnHotKey[8]; extern char *PanBtnStr[8]; -extern int attribute_inc_rects[4][4]; +extern RECT32 attribute_inc_rects[4]; extern int SpellPages[6][7]; #endif /* __CONTROL_H__ */ diff --git a/structs.h b/structs.h index ff044c687..54bb38251 100644 --- a/structs.h +++ b/structs.h @@ -1,3 +1,15 @@ +////////////////////////////////////////////////// +// control +////////////////////////////////////////////////// + +// size: 0x10 +typedef struct RECT32 { + int x; + int y; + int w; + int h; +} RECT32; + ////////////////////////////////////////////////// // items //////////////////////////////////////////////////