diff --git a/Source/control.cpp b/Source/control.cpp index fba68445b..6fd3f457c 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -3,10 +3,10 @@ #include "../types.h" char sgbNextTalkSave; // weak -char sgbTalkSavePos; // weak +char sgbTalkSavePos; // weak void *pDurIcons; void *pChrButtons; -BOOL drawhpflag; // idb +BOOL drawhpflag; // idb int dropGoldFlag; // weak int panbtn[8]; int chrbtn[4]; @@ -17,7 +17,7 @@ int lvlbtndown; // weak char sgszTalkSave[8][80]; int dropGoldValue; // idb BOOL drawmanaflag; // idb -int chrbtnactive; // weak +int chrbtnactive; // weak char sgszTalkMsg[80]; void *pPanelText; int frame_4B8800; // idb @@ -30,16 +30,16 @@ int pinfoflag; // weak int talkbtndown[3]; int pSpell; // weak char *pManaBuff; -int infoclr; // weak +int infoclr; // weak int sgbPlrTalkTbl; // weak // should be char [4] void *pGBoxBuff; void *pSBkBtnCel; char tempstr[260]; -int sbooktab; // weak -int pSplType; // weak -int frame; // idb +int sbooktab; // weak +int pSplType; // weak +int frame; // idb int initialDropGoldIndex; // idb -int talkflag; // weak +int talkflag; // weak void *pSBkIconCels; int sbookflag; // weak int chrflag; @@ -53,547 +53,500 @@ int panelflag; // weak unsigned char splTrans[256]; int initialDropGoldValue; // idb void *pSpellCels; -int panbtndown; // weak +int panbtndown; // weak void *pTalkPanel; // idb -int spselflag; // weak - -const unsigned char fontframe[127] = -{ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 54, 44, 57, 58, 56, 55, 47, - 40, 41, 59, 39, 50, 37, 51, 52, 36, 27, - 28, 29, 30, 31, 32, 33, 34, 35, 48, 49, - 60, 38, 61, 53, 62, 1, 2, 3, 4, 5, - 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, - 26, 42, 63, 43, 64, 65, 0, 1, 2, 3, - 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 40, 66, 41, 67 +int spselflag; // weak + +const unsigned char fontframe[127] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 54, 44, 57, 58, 56, 55, 47, + 40, 41, 59, 39, 50, 37, 51, 52, 36, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 48, 49, + 60, 38, 61, 53, 62, 1, 2, 3, 4, 5, + 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, + 26, 42, 63, 43, 64, 65, 0, 1, 2, 3, + 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 40, 66, 41, 67 }; -const unsigned char fontkern[68] = -{ - 8, 10, 7, 9, 8, 7, 6, 8, 8, 3, - 3, 8, 6, 11, 9, 10, 6, 9, 9, 6, - 9, 11, 10, 13, 10, 11, 7, 5, 7, 7, - 8, 7, 7, 7, 7, 7, 10, 4, 5, 6, - 3, 3, 4, 3, 6, 6, 3, 3, 3, 3, - 3, 2, 7, 6, 3, 10, 10, 6, 6, 7, - 4, 4, 9, 6, 6, 12, 3, 7 +const unsigned char fontkern[68] = { + 8, 10, 7, 9, 8, 7, 6, 8, 8, 3, + 3, 8, 6, 11, 9, 10, 6, 9, 9, 6, + 9, 11, 10, 13, 10, 11, 7, 5, 7, 7, + 8, 7, 7, 7, 7, 7, 10, 4, 5, 6, + 3, 3, 4, 3, 6, 6, 3, 3, 3, 3, + 3, 2, 7, 6, 3, 10, 10, 6, 6, 7, + 4, 4, 9, 6, 6, 12, 3, 7 }; -const int lineoffset[25] = -{ - 768 * 594 + 241, - 768 * 32, - 768 * 32, - 768 * 32, - 768 * 32 + 180, - 768 * 582 + 241, - 768 * 606 + 241, - 768 * 32, - 768 * 32, - 768 * 32, - 768 * 576 + 241, - 768 * 594 + 241, - 768 * 612 + 241, - 768 * 32, - 768 * 32, - 768 * 572 + 241, - 768 * 587 + 241, - 768 * 601 + 241, - 768 * 616 + 241, - 768 * 32, - 768 * 570 + 241, - 768 * 582 + 241, - 768 * 594 + 241, - 768 * 606 + 241, - 768 * 617 + 241 +const int lineoffset[25] = { + 768 * 594 + 241, + 768 * 32, + 768 * 32, + 768 * 32, + 768 * 32 + 180, + 768 * 582 + 241, + 768 * 606 + 241, + 768 * 32, + 768 * 32, + 768 * 32, + 768 * 576 + 241, + 768 * 594 + 241, + 768 * 612 + 241, + 768 * 32, + 768 * 32, + 768 * 572 + 241, + 768 * 587 + 241, + 768 * 601 + 241, + 768 * 616 + 241, + 768 * 32, + 768 * 570 + 241, + 768 * 582 + 241, + 768 * 594 + 241, + 768 * 606 + 241, + 768 * 617 + 241 }; -const unsigned char fontidx[256] = -{ - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, - 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, - 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, - 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, - 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, - 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, - 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, - 120, 121, 122, 123, 124, 125, 126, 1, 67, 117, - 101, 97, 97, 97, 97, 99, 101, 101, 101, 105, - 105, 105, 65, 65, 69, 97, 65, 111, 111, 111, - 117, 117, 121, 79, 85, 99, 76, 89, 80, 102, - 97, 105, 111, 117, 110, 78, 97, 111, 63, 1, - 1, 1, 1, 33, 60, 62, 111, 43, 50, 51, - 39, 117, 80, 46, 44, 49, 48, 62, 1, 1, - 1, 63, 65, 65, 65, 65, 65, 65, 65, 67, - 69, 69, 69, 69, 73, 73, 73, 73, 68, 78, - 79, 79, 79, 79, 79, 88, 48, 85, 85, 85, - 85, 89, 98, 66, 97, 97, 97, 97, 97, 97, - 97, 99, 101, 101, 101, 101, 105, 105, 105, 105, - 111, 110, 111, 111, 111, 111, 111, 47, 48, 117, - 117, 117, 117, 121, 98, 121 +const unsigned char fontidx[256] = { + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, + 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, + 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, + 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, + 120, 121, 122, 123, 124, 125, 126, 1, 67, 117, + 101, 97, 97, 97, 97, 99, 101, 101, 101, 105, + 105, 105, 65, 65, 69, 97, 65, 111, 111, 111, + 117, 117, 121, 79, 85, 99, 76, 89, 80, 102, + 97, 105, 111, 117, 110, 78, 97, 111, 63, 1, + 1, 1, 1, 33, 60, 62, 111, 43, 50, 51, + 39, 117, 80, 46, 44, 49, 48, 62, 1, 1, + 1, 63, 65, 65, 65, 65, 65, 65, 65, 67, + 69, 69, 69, 69, 73, 73, 73, 73, 68, 78, + 79, 79, 79, 79, 79, 88, 48, 85, 85, 85, + 85, 89, 98, 66, 97, 97, 97, 97, 97, 97, + 97, 99, 101, 101, 101, 101, 105, 105, 105, 105, + 111, 110, 111, 111, 111, 111, 111, 47, 48, 117, + 117, 117, 117, 121, 98, 121 }; /* data */ -unsigned char SpellITbl[MAX_SPELLS] = -{ - 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, - 28, 13, 12, 18, 16, 14, 18, 19, 11, 20, - 15, 21, 23, 24, 25, 22, 26, 29, 37, 38, - 39, 42, 41, 40, 10, 36, 30 +unsigned char SpellITbl[MAX_SPELLS] = { + 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 28, 13, 12, 18, 16, 14, 18, 19, 11, 20, + 15, 21, 23, 24, 25, 22, 26, 29, 37, 38, + 39, 42, 41, 40, 10, 36, 30 }; -int PanBtnPos[8][5] = -{ - { 9, 361, 71, 19, 1 }, - { 9, 387, 71, 19, 0 }, - { 9, 427, 71, 19, 1 }, - { 9, 453, 71, 19, 0 }, - { 560, 361, 71, 19, 1 }, - { 560, 387, 71, 19, 0 }, - { 87, 443, 33, 32, 1 }, - { 527, 443, 33, 32, 1 } +int PanBtnPos[8][5] = { + { 9, 361, 71, 19, 1 }, + { 9, 387, 71, 19, 0 }, + { 9, 427, 71, 19, 1 }, + { 9, 453, 71, 19, 0 }, + { 560, 361, 71, 19, 1 }, + { 560, 387, 71, 19, 0 }, + { 87, 443, 33, 32, 1 }, + { 527, 443, 33, 32, 1 } }; char *PanBtnHotKey[8] = { "'c'", "'q'", "Tab", "Esc", "'i'", "'b'", "Enter", NULL }; -char *PanBtnStr[8] = -{ - "Character Information", - "Quests log", - "Automap", - "Main Menu", - "Inventory", - "Spell book", - "Send Message", - "Player Attack" +char *PanBtnStr[8] = { + "Character Information", + "Quests log", + "Automap", + "Main Menu", + "Inventory", + "Spell book", + "Send Message", + "Player Attack" }; -int attribute_inc_rects[4][4] = -{ - { 137, 138, 41, 22 }, - { 137, 166, 41, 22 }, - { 137, 195, 41, 22 }, - { 137, 223, 41, 22 } +int attribute_inc_rects[4][4] = { + { 137, 138, 41, 22 }, + { 137, 166, 41, 22 }, + { 137, 195, 41, 22 }, + { 137, 223, 41, 22 } }; -int SpellPages[6][7] = -{ - { SPL_NULL, SPL_FIREBOLT, SPL_CBOLT, SPL_HBOLT, SPL_HEAL, SPL_HEALOTHER, SPL_FLAME }, - { SPL_RESURRECT, SPL_FIREWALL, SPL_TELEKINESIS, SPL_LIGHTNING, SPL_TOWN, SPL_FLASH, SPL_STONE }, - { SPL_RNDTELEPORT, SPL_MANASHIELD, SPL_ELEMENT, SPL_FIREBALL, SPL_WAVE, SPL_CHAIN, SPL_GUARDIAN }, - { SPL_NOVA, SPL_GOLEM, SPL_TELEPORT, SPL_APOCA, SPL_BONESPIRIT, SPL_FLARE, SPL_ETHEREALIZE }, - { -1, -1, -1, -1, -1, -1, -1 }, - { -1, -1, -1, -1, -1, -1, -1 } +int SpellPages[6][7] = { + { SPL_NULL, SPL_FIREBOLT, SPL_CBOLT, SPL_HBOLT, SPL_HEAL, SPL_HEALOTHER, SPL_FLAME }, + { SPL_RESURRECT, SPL_FIREWALL, SPL_TELEKINESIS, SPL_LIGHTNING, SPL_TOWN, SPL_FLASH, SPL_STONE }, + { SPL_RNDTELEPORT, SPL_MANASHIELD, SPL_ELEMENT, SPL_FIREBALL, SPL_WAVE, SPL_CHAIN, SPL_GUARDIAN }, + { SPL_NOVA, SPL_GOLEM, SPL_TELEPORT, SPL_APOCA, SPL_BONESPIRIT, SPL_FLARE, SPL_ETHEREALIZE }, + { -1, -1, -1, -1, -1, -1, -1 }, + { -1, -1, -1, -1, -1, -1, -1 } }; void __fastcall DrawSpellCel(int xp, int yp, char *Trans, int nCel, int w) { - char *v5; // ebx - char *v6; // esi - char *v7; // edi - int v9; // edx - unsigned int v10; // eax - unsigned int v11; // ecx - char v14; // cf - unsigned int v15; // ecx - int v18; // [esp+Ch] [ebp-Ch] - int _EAX; - unsigned char *_EBX; - - v5 = &Trans[4 * nCel]; - v6 = &Trans[*(_DWORD *)v5]; - v7 = (char *)gpBuffer + screen_y_times_768[yp] + xp; - v18 = (int)&v6[*((_DWORD *)v5 + 1) - *(_DWORD *)v5]; - _EBX = splTrans; - do - { - v9 = w; - do - { - while ( 1 ) - { - v10 = (unsigned char)*v6++; - if ( (v10 & 0x80u) == 0 ) - break; - _LOBYTE(v10) = -(char)v10; - v7 += v10; - v9 -= v10; - if ( !v9 ) - goto LABEL_12; - } - v9 -= v10; - v11 = v10 >> 1; - if ( v10 & 1 ) - { - _EAX = *v6++; - ASM_XLAT(_EAX,_EBX); - *v7++ = _EAX; - if ( !v11 ) - continue; - } - v14 = v11 & 1; - v15 = v11 >> 1; - if ( !v14 ) - goto LABEL_15; - _EAX = *(_WORD *)v6; - v6 += 2; - ASM_XLAT(_EAX,_EBX); - _EAX = __ROR2__(_EAX, 8); - ASM_XLAT(_EAX,_EBX); - *(_WORD *)v7 = __ROR2__(_EAX, 8); - v7 += 2; - if ( v15 ) - { -LABEL_15: - do - { - _EAX = *(_DWORD *)v6; - v6 += 4; - ASM_XLAT(_EAX,_EBX); - _EAX = __ROR4__(_EAX, 8); - ASM_XLAT(_EAX,_EBX); - _EAX = __ROR4__(_EAX, 8); - ASM_XLAT(_EAX,_EBX); - _EAX = __ROR4__(_EAX, 8); - ASM_XLAT(_EAX,_EBX); - *(_DWORD *)v7 = __ROR4__(_EAX, 8); - v7 += 4; - --v15; - } - while ( v15 ); - } - } - while ( v9 ); -LABEL_12: - v7 = &v7[-w - 768]; - } - while ( v6 != (char *)v18 ); + char *v5; // ebx + char *v6; // esi + char *v7; // edi + int v9; // edx + unsigned int v10; // eax + unsigned int v11; // ecx + char v14; // cf + unsigned int v15; // ecx + int v18; // [esp+Ch] [ebp-Ch] + int _EAX; + unsigned char *_EBX; + + v5 = &Trans[4 * nCel]; + v6 = &Trans[*(_DWORD *)v5]; + v7 = (char *)gpBuffer + screen_y_times_768[yp] + xp; + v18 = (int)&v6[*((_DWORD *)v5 + 1) - *(_DWORD *)v5]; + _EBX = splTrans; + do { + v9 = w; + do { + while (1) { + v10 = (unsigned char)*v6++; + if ((v10 & 0x80u) == 0) + break; + _LOBYTE(v10) = -(char)v10; + v7 += v10; + v9 -= v10; + if (!v9) + goto LABEL_12; + } + v9 -= v10; + v11 = v10 >> 1; + if (v10 & 1) { + _EAX = *v6++; + ASM_XLAT(_EAX, _EBX); + *v7++ = _EAX; + if (!v11) + continue; + } + v14 = v11 & 1; + v15 = v11 >> 1; + if (!v14) + goto LABEL_15; + _EAX = *(_WORD *)v6; + v6 += 2; + ASM_XLAT(_EAX, _EBX); + _EAX = __ROR2__(_EAX, 8); + ASM_XLAT(_EAX, _EBX); + *(_WORD *)v7 = __ROR2__(_EAX, 8); + v7 += 2; + if (v15) { + LABEL_15: + do { + _EAX = *(_DWORD *)v6; + v6 += 4; + ASM_XLAT(_EAX, _EBX); + _EAX = __ROR4__(_EAX, 8); + ASM_XLAT(_EAX, _EBX); + _EAX = __ROR4__(_EAX, 8); + ASM_XLAT(_EAX, _EBX); + _EAX = __ROR4__(_EAX, 8); + ASM_XLAT(_EAX, _EBX); + *(_DWORD *)v7 = __ROR4__(_EAX, 8); + v7 += 4; + --v15; + } while (v15); + } + } while (v9); + LABEL_12: + v7 = &v7[-w - 768]; + } while (v6 != (char *)v18); } void __fastcall SetSpellTrans(char t) { - int i; - - if (t == RSPLTYPE_SKILL) { - for (i = 0; i < 128; i++) - splTrans[i] = i; - } - for (i = 128; i < 256; i++) - splTrans[i] = i; - splTrans[255] = 0; - - switch (t) { - case RSPLTYPE_SPELL: - splTrans[PAL8_YELLOW] = PAL16_BLUE+1; - splTrans[PAL8_YELLOW+1] = PAL16_BLUE+3; - splTrans[PAL8_YELLOW+2] = PAL16_BLUE+5; - for (i = PAL16_BLUE; i < PAL16_BLUE+16; i++) { - splTrans[PAL16_BEIGE -PAL16_BLUE+i] = i; - splTrans[PAL16_YELLOW-PAL16_BLUE+i] = i; - splTrans[PAL16_ORANGE-PAL16_BLUE+i] = i; - } - return; - case RSPLTYPE_SCROLL: - splTrans[PAL8_YELLOW] = PAL16_BEIGE+1; - splTrans[PAL8_YELLOW+1] = PAL16_BEIGE+3; - splTrans[PAL8_YELLOW+2] = PAL16_BEIGE+5; - for (i = PAL16_BEIGE; i < PAL16_BEIGE+16; i++) { - splTrans[PAL16_YELLOW-PAL16_BEIGE+i] = i; - splTrans[PAL16_ORANGE-PAL16_BEIGE+i] = i; - } - return; - case RSPLTYPE_CHARGES: - splTrans[PAL8_YELLOW] = PAL16_ORANGE+1; - splTrans[PAL8_YELLOW+1] = PAL16_ORANGE+3; - splTrans[PAL8_YELLOW+2] = PAL16_ORANGE+5; - for (i = PAL16_ORANGE; i < PAL16_ORANGE+16; i++) { - splTrans[PAL16_BEIGE -PAL16_ORANGE+i] = i; - splTrans[PAL16_YELLOW-PAL16_ORANGE+i] = i; - } - return; - case RSPLTYPE_INVALID: - splTrans[PAL8_YELLOW] = PAL16_GRAY+1; - splTrans[PAL8_YELLOW+1] = PAL16_GRAY+3; - splTrans[PAL8_YELLOW+2] = PAL16_GRAY+5; - for (i = PAL16_GRAY; i < PAL16_GRAY+15; i++) { - splTrans[PAL16_BEIGE -PAL16_GRAY+i] = i; - splTrans[PAL16_YELLOW-PAL16_GRAY+i] = i; - splTrans[PAL16_ORANGE-PAL16_GRAY+i] = i; - } - splTrans[PAL16_BEIGE+15] = 0; - splTrans[PAL16_YELLOW+15] = 0; - splTrans[PAL16_ORANGE+15] = 0; - } + int i; + + if (t == RSPLTYPE_SKILL) { + for (i = 0; i < 128; i++) + splTrans[i] = i; + } + for (i = 128; i < 256; i++) + splTrans[i] = i; + splTrans[255] = 0; + + switch (t) { + case RSPLTYPE_SPELL: + splTrans[PAL8_YELLOW] = PAL16_BLUE + 1; + splTrans[PAL8_YELLOW + 1] = PAL16_BLUE + 3; + splTrans[PAL8_YELLOW + 2] = PAL16_BLUE + 5; + for (i = PAL16_BLUE; i < PAL16_BLUE + 16; i++) { + splTrans[PAL16_BEIGE - PAL16_BLUE + i] = i; + splTrans[PAL16_YELLOW - PAL16_BLUE + i] = i; + splTrans[PAL16_ORANGE - PAL16_BLUE + i] = i; + } + return; + case RSPLTYPE_SCROLL: + splTrans[PAL8_YELLOW] = PAL16_BEIGE + 1; + splTrans[PAL8_YELLOW + 1] = PAL16_BEIGE + 3; + splTrans[PAL8_YELLOW + 2] = PAL16_BEIGE + 5; + for (i = PAL16_BEIGE; i < PAL16_BEIGE + 16; i++) { + splTrans[PAL16_YELLOW - PAL16_BEIGE + i] = i; + splTrans[PAL16_ORANGE - PAL16_BEIGE + i] = i; + } + return; + case RSPLTYPE_CHARGES: + splTrans[PAL8_YELLOW] = PAL16_ORANGE + 1; + splTrans[PAL8_YELLOW + 1] = PAL16_ORANGE + 3; + splTrans[PAL8_YELLOW + 2] = PAL16_ORANGE + 5; + for (i = PAL16_ORANGE; i < PAL16_ORANGE + 16; i++) { + splTrans[PAL16_BEIGE - PAL16_ORANGE + i] = i; + splTrans[PAL16_YELLOW - PAL16_ORANGE + i] = i; + } + return; + case RSPLTYPE_INVALID: + splTrans[PAL8_YELLOW] = PAL16_GRAY + 1; + splTrans[PAL8_YELLOW + 1] = PAL16_GRAY + 3; + splTrans[PAL8_YELLOW + 2] = PAL16_GRAY + 5; + for (i = PAL16_GRAY; i < PAL16_GRAY + 15; i++) { + splTrans[PAL16_BEIGE - PAL16_GRAY + i] = i; + splTrans[PAL16_YELLOW - PAL16_GRAY + i] = i; + splTrans[PAL16_ORANGE - PAL16_GRAY + i] = i; + } + splTrans[PAL16_BEIGE + 15] = 0; + splTrans[PAL16_YELLOW + 15] = 0; + splTrans[PAL16_ORANGE + 15] = 0; + } } void __cdecl DrawSpell() { - int v0; // ebp - char v1; // cl - char v2; // bl - int v3; // edi - int v4; // esi - char v6; // [esp+Fh] [ebp-5h] - - v0 = myplr; - v1 = plr[myplr]._pRSpell; - v2 = plr[myplr]._pRSplType; - v3 = v1; - v6 = plr[myplr]._pRSpell; - v4 = plr[myplr]._pISplLvlAdd + plr[myplr]._pSplLvl[v1]; - if ( v2 == RSPLTYPE_SPELL && v1 != -1 ) - { - if ( !CheckSpell(myplr, v1, RSPLTYPE_SPELL, TRUE) ) - v2 = RSPLTYPE_INVALID; - v0 = myplr; - if ( v4 <= 0 ) - v2 = RSPLTYPE_INVALID; - } - if ( !currlevel && v2 != RSPLTYPE_INVALID && !spelldata[v3].sTownSpell ) - v2 = RSPLTYPE_INVALID; - if ( plr[v0]._pRSpell < 0 ) - v2 = RSPLTYPE_INVALID; - SetSpellTrans(v2); - if ( v6 == -1 ) - DrawSpellCel(629, 631, (char *)pSpellCels, 27, 56); - else - DrawSpellCel(629, 631, (char *)pSpellCels, (char)SpellITbl[v3], 56); + int v0; // ebp + char v1; // cl + char v2; // bl + int v3; // edi + int v4; // esi + char v6; // [esp+Fh] [ebp-5h] + + v0 = myplr; + v1 = plr[myplr]._pRSpell; + v2 = plr[myplr]._pRSplType; + v3 = v1; + v6 = plr[myplr]._pRSpell; + v4 = plr[myplr]._pISplLvlAdd + plr[myplr]._pSplLvl[v1]; + if (v2 == RSPLTYPE_SPELL && v1 != -1) { + if (!CheckSpell(myplr, v1, RSPLTYPE_SPELL, TRUE)) + v2 = RSPLTYPE_INVALID; + v0 = myplr; + if (v4 <= 0) + v2 = RSPLTYPE_INVALID; + } + if (!currlevel && v2 != RSPLTYPE_INVALID && !spelldata[v3].sTownSpell) + v2 = RSPLTYPE_INVALID; + if (plr[v0]._pRSpell < 0) + v2 = RSPLTYPE_INVALID; + SetSpellTrans(v2); + if (v6 == -1) + DrawSpellCel(629, 631, (char *)pSpellCels, 27, 56); + else + DrawSpellCel(629, 631, (char *)pSpellCels, (char)SpellITbl[v3], 56); } void __cdecl DrawSpellList() { - int v0; // esi - signed int v1; // edi - signed int v4; // ebp - int v5; // eax - int v6; // esi - int v7; // eax - bool v8; // sf - int v9; // esi - int v10; // eax - int v11; // ebp - int v12; // edx - int *v13; // ecx - int *v14; // eax - signed int v15; // edx - signed int v16; // edi - int v17; // [esp+Ch] [ebp-34h] - __int32 xp; // [esp+10h] [ebp-30h] - __int32 yp; // [esp+14h] [ebp-2Ch] - BOOL *v20; // [esp+18h] [ebp-28h] - __int32 nCel; // [esp+1Ch] [ebp-24h] - int v22; // [esp+20h] [ebp-20h] - __int32 v23; // [esp+24h] [ebp-1Ch] - signed int v24; // [esp+28h] [ebp-18h] - unsigned __int64 v25; // [esp+2Ch] [ebp-14h] - signed __int64 v26; // [esp+34h] [ebp-Ch] - - pSpell = -1; - infostr[0] = 0; - v17 = 636; - xp = 495; - ClearPanel(); - v0 = myplr; - v1 = RSPLTYPE_SKILL; - v24 = 0; - do - { - switch ( v1 ) - { - case RSPLTYPE_SKILL: - SetSpellTrans(RSPLTYPE_SKILL); - yp = 46; - v25 = plr[v0]._pAblSpells; - break; - case RSPLTYPE_SPELL: - yp = 47; - v25 = plr[v0]._pMemSpells; - break; - case RSPLTYPE_SCROLL: - SetSpellTrans(RSPLTYPE_SCROLL); - yp = 44; - v25 = plr[v0]._pScrlSpells; - break; - case RSPLTYPE_CHARGES: - SetSpellTrans(RSPLTYPE_CHARGES); - yp = 45; - v25 = plr[v0]._pISpells; - break; - } - v20 = &spelldata[1].sTownSpell; - v4 = 1; - v26 = (__int64)1; - v23 = 1; - v22 = xp - 216; - do - { - if ( !(v25 & v26) ) - goto LABEL_68; - if ( v1 == RSPLTYPE_SPELL ) - { - v5 = v0; - v6 = plr[v0]._pSplLvl[v4]; - v7 = plr[v5]._pISplLvlAdd; - v8 = v7 + v6 < 0; - v9 = v7 + v6; - nCel = v9; - if ( v8 ) - { - nCel = 0; - v9 = 0; - } - SetSpellTrans(v9 <= 0 ? RSPLTYPE_INVALID : RSPLTYPE_SPELL); - } - else - { - v9 = nCel; - } - if ( !currlevel && !*v20 ) - SetSpellTrans(RSPLTYPE_INVALID); - DrawSpellCel(v17, xp, (char *)pSpellCels, (char)SpellITbl[v4], 56); - if ( MouseX >= v17 - 64 && MouseX < v17 - 64 + 56 && MouseY >= v22 && MouseY < v22 + 56 ) - { - pSpell = v4; - pSplType = v1; - DrawSpellCel(v17, xp, (char *)pSpellCels, yp, 56); - if ( v1 ) - { - switch ( v1 ) - { - case RSPLTYPE_SPELL: - sprintf(infostr, "%s Spell", spelldata[pSpell].sNameText); - if ( pSpell == 31 ) - { - sprintf(tempstr, "Damages undead only"); - AddPanelString(tempstr, 1); - } - if ( v9 ) - sprintf(tempstr, "Spell Level %i", v9); - else - sprintf(tempstr, "Spell Level 0 - Unusable"); -LABEL_32: - AddPanelString(tempstr, 1); - break; - case RSPLTYPE_SCROLL: - sprintf(infostr, "Scroll of %s", spelldata[pSpell].sNameText); - v10 = myplr; - v11 = 0; - v12 = plr[myplr]._pNumInv; - if ( v12 > 0 ) - { - v13 = &plr[v10].InvList[0]._iMiscId; - do - { - if ( *(v13 - 53) != -1 - && (*v13 == IMISC_SCROLL || *v13 == IMISC_SCROLLT) - && v13[1] == pSpell ) - { - ++v11; - } - v13 += 92; - --v12; - } - while ( v12 ); - } - v14 = &plr[v10].SpdList[0]._iMiscId; - v15 = MAXBELTITEMS; - do - { - if ( *(v14 - 53) != -1 - && (*v14 == IMISC_SCROLL || *v14 == IMISC_SCROLLT) - && v14[1] == pSpell ) - { - ++v11; - } - v14 += 92; - --v15; - } - while ( v15 ); - if ( v11 == 1 ) - strcpy(tempstr, "1 Scroll"); - else - sprintf(tempstr, "%i Scrolls", v11); - AddPanelString(tempstr, 1); - v4 = v23; - break; - case RSPLTYPE_CHARGES: - sprintf(infostr, "Staff of %s", spelldata[pSpell].sNameText); - if ( plr[myplr].InvBody[INVLOC_HAND_LEFT]._iCharges == 1 ) - strcpy(tempstr, "1 Charge"); - else - sprintf(tempstr, "%i Charges", plr[myplr].InvBody[INVLOC_HAND_LEFT]._iCharges); - goto LABEL_32; - } - } - else - { - sprintf(infostr, "%s Skill", spelldata[pSpell].sSkillText); - } - v0 = myplr; - v16 = 0; - do - { - if ( plr[v0]._pSplHotKey[v16] == pSpell && plr[v0]._pSplTHotKey[v16] == pSplType ) - { - DrawSpellCel(v17, xp, (char *)pSpellCels, v16 + 48, 56); - sprintf(tempstr, "Spell Hot Key #F%i", v16 + 5); - AddPanelString(tempstr, 1); - v0 = myplr; - } - ++v16; - } - while ( v16 < 4 ); - v1 = v24; - goto LABEL_66; - } - v0 = myplr; -LABEL_66: - v17 -= 56; - if ( v17 == 20 ) - { - xp -= 56; - v22 -= 56; - v17 = 636; - } -LABEL_68: - v20 += 14; - ++v4; - v26 *= (__int64)2; - v23 = v4; - } - while ( (signed int)v20 < (signed int)&spelldata[MAX_SPELLS].sTownSpell ); - if ( v25 && v17 != 636 ) - v17 -= 56; - if ( v17 == 20 ) - { - xp -= 56; - v17 = 636; - } - v24 = ++v1; - } - while ( v1 < 4 ); + int v0; // esi + signed int v1; // edi + signed int v4; // ebp + int v5; // eax + int v6; // esi + int v7; // eax + bool v8; // sf + int v9; // esi + int v10; // eax + int v11; // ebp + int v12; // edx + int *v13; // ecx + int *v14; // eax + signed int v15; // edx + signed int v16; // edi + int v17; // [esp+Ch] [ebp-34h] + __int32 xp; // [esp+10h] [ebp-30h] + __int32 yp; // [esp+14h] [ebp-2Ch] + BOOL *v20; // [esp+18h] [ebp-28h] + __int32 nCel; // [esp+1Ch] [ebp-24h] + int v22; // [esp+20h] [ebp-20h] + __int32 v23; // [esp+24h] [ebp-1Ch] + signed int v24; // [esp+28h] [ebp-18h] + unsigned __int64 v25; // [esp+2Ch] [ebp-14h] + signed __int64 v26; // [esp+34h] [ebp-Ch] + + pSpell = -1; + infostr[0] = 0; + v17 = 636; + xp = 495; + ClearPanel(); + v0 = myplr; + v1 = RSPLTYPE_SKILL; + v24 = 0; + do { + switch (v1) { + case RSPLTYPE_SKILL: + SetSpellTrans(RSPLTYPE_SKILL); + yp = 46; + v25 = plr[v0]._pAblSpells; + break; + case RSPLTYPE_SPELL: + yp = 47; + v25 = plr[v0]._pMemSpells; + break; + case RSPLTYPE_SCROLL: + SetSpellTrans(RSPLTYPE_SCROLL); + yp = 44; + v25 = plr[v0]._pScrlSpells; + break; + case RSPLTYPE_CHARGES: + SetSpellTrans(RSPLTYPE_CHARGES); + yp = 45; + v25 = plr[v0]._pISpells; + break; + } + v20 = &spelldata[1].sTownSpell; + v4 = 1; + v26 = (__int64)1; + v23 = 1; + v22 = xp - 216; + do { + if (!(v25 & v26)) + goto LABEL_68; + if (v1 == RSPLTYPE_SPELL) { + v5 = v0; + v6 = plr[v0]._pSplLvl[v4]; + v7 = plr[v5]._pISplLvlAdd; + v8 = v7 + v6 < 0; + v9 = v7 + v6; + nCel = v9; + if (v8) { + nCel = 0; + v9 = 0; + } + SetSpellTrans(v9 <= 0 ? RSPLTYPE_INVALID : RSPLTYPE_SPELL); + } else { + v9 = nCel; + } + if (!currlevel && !*v20) + SetSpellTrans(RSPLTYPE_INVALID); + DrawSpellCel(v17, xp, (char *)pSpellCels, (char)SpellITbl[v4], 56); + if (MouseX >= v17 - 64 && MouseX < v17 - 64 + 56 && MouseY >= v22 && MouseY < v22 + 56) { + pSpell = v4; + pSplType = v1; + DrawSpellCel(v17, xp, (char *)pSpellCels, yp, 56); + if (v1) { + switch (v1) { + case RSPLTYPE_SPELL: + sprintf(infostr, "%s Spell", spelldata[pSpell].sNameText); + if (pSpell == 31) { + sprintf(tempstr, "Damages undead only"); + AddPanelString(tempstr, 1); + } + if (v9) + sprintf(tempstr, "Spell Level %i", v9); + else + sprintf(tempstr, "Spell Level 0 - Unusable"); + LABEL_32: + AddPanelString(tempstr, 1); + break; + case RSPLTYPE_SCROLL: + sprintf(infostr, "Scroll of %s", spelldata[pSpell].sNameText); + v10 = myplr; + v11 = 0; + v12 = plr[myplr]._pNumInv; + if (v12 > 0) { + v13 = &plr[v10].InvList[0]._iMiscId; + do { + if (*(v13 - 53) != -1 + && (*v13 == IMISC_SCROLL || *v13 == IMISC_SCROLLT) + && v13[1] == pSpell) { + ++v11; + } + v13 += 92; + --v12; + } while (v12); + } + v14 = &plr[v10].SpdList[0]._iMiscId; + v15 = MAXBELTITEMS; + do { + if (*(v14 - 53) != -1 + && (*v14 == IMISC_SCROLL || *v14 == IMISC_SCROLLT) + && v14[1] == pSpell) { + ++v11; + } + v14 += 92; + --v15; + } while (v15); + if (v11 == 1) + strcpy(tempstr, "1 Scroll"); + else + sprintf(tempstr, "%i Scrolls", v11); + AddPanelString(tempstr, 1); + v4 = v23; + break; + case RSPLTYPE_CHARGES: + sprintf(infostr, "Staff of %s", spelldata[pSpell].sNameText); + if (plr[myplr].InvBody[INVLOC_HAND_LEFT]._iCharges == 1) + strcpy(tempstr, "1 Charge"); + else + sprintf(tempstr, "%i Charges", plr[myplr].InvBody[INVLOC_HAND_LEFT]._iCharges); + goto LABEL_32; + } + } else { + sprintf(infostr, "%s Skill", spelldata[pSpell].sSkillText); + } + v0 = myplr; + v16 = 0; + do { + if (plr[v0]._pSplHotKey[v16] == pSpell && plr[v0]._pSplTHotKey[v16] == pSplType) { + DrawSpellCel(v17, xp, (char *)pSpellCels, v16 + 48, 56); + sprintf(tempstr, "Spell Hot Key #F%i", v16 + 5); + AddPanelString(tempstr, 1); + v0 = myplr; + } + ++v16; + } while (v16 < 4); + v1 = v24; + goto LABEL_66; + } + v0 = myplr; + LABEL_66: + v17 -= 56; + if (v17 == 20) { + xp -= 56; + v22 -= 56; + v17 = 636; + } + LABEL_68: + v20 += 14; + ++v4; + v26 *= (__int64)2; + v23 = v4; + } while ((signed int)v20 < (signed int)&spelldata[MAX_SPELLS].sTownSpell); + if (v25 && v17 != 636) + v17 -= 56; + if (v17 == 20) { + xp -= 56; + v17 = 636; + } + v24 = ++v1; + } while (v1 < 4); } // 4B8834: using guessed type int pSpell; // 4B8954: using guessed type int pSplType; void __cdecl SetSpell() { - int v0; // eax + int v0; // eax - spselflag = 0; - if ( pSpell != -1 ) - { - ClearPanel(); - v0 = myplr; - drawpanflag = 255; - plr[v0]._pRSpell = pSpell; - _LOBYTE(plr[v0]._pRSplType) = pSplType; - } + spselflag = 0; + if (pSpell != -1) { + ClearPanel(); + v0 = myplr; + drawpanflag = 255; + plr[v0]._pRSpell = pSpell; + _LOBYTE(plr[v0]._pRSplType) = pSplType; + } } // 4B8834: using guessed type int pSpell; // 4B8954: using guessed type int pSplType; @@ -602,539 +555,485 @@ void __cdecl SetSpell() void __fastcall SetSpeedSpell(int slot) { - int v1; // esi - signed int v3; // ebp - int v5; // ebx - int *v6; // edi - - v1 = pSpell; - if ( pSpell != -1 ) - { - v3 = 0; - v5 = pSplType; - v6 = plr[myplr]._pSplHotKey; - do - { - if ( *v6 == v1 && plr[myplr]._pSplTHotKey[v3] == v5 ) - *v6 = -1; - ++v3; - ++v6; - } - while ( v3 < 4 ); - plr[myplr]._pSplHotKey[slot] = v1; - plr[myplr]._pSplTHotKey[slot] = v5; - } + int v1; // esi + signed int v3; // ebp + int v5; // ebx + int *v6; // edi + + v1 = pSpell; + if (pSpell != -1) { + v3 = 0; + v5 = pSplType; + v6 = plr[myplr]._pSplHotKey; + do { + if (*v6 == v1 && plr[myplr]._pSplTHotKey[v3] == v5) + *v6 = -1; + ++v3; + ++v6; + } while (v3 < 4); + plr[myplr]._pSplHotKey[slot] = v1; + plr[myplr]._pSplTHotKey[slot] = v5; + } } // 4B8834: using guessed type int pSpell; // 4B8954: using guessed type int pSplType; void __fastcall ToggleSpell(int slot) { - if ( plr[myplr]._pSplHotKey[slot] == -1 ) { - return; - } - - unsigned __int64 spells; - switch ( plr[myplr]._pSplTHotKey[slot] ) { - case RSPLTYPE_SKILL: - spells = plr[myplr]._pAblSpells; - break; - case RSPLTYPE_SPELL: - spells = plr[myplr]._pMemSpells; - break; - case RSPLTYPE_SCROLL: - spells = plr[myplr]._pScrlSpells; - break; - case RSPLTYPE_CHARGES: - spells = plr[myplr]._pISpells; - break; - } - - if ( spells & (__int64)1 << (plr[myplr]._pSplHotKey[slot] - 1) ) { - plr[myplr]._pRSpell = plr[myplr]._pSplHotKey[slot]; - plr[myplr]._pRSplType = plr[myplr]._pSplTHotKey[slot]; - drawpanflag = 255; - } + if (plr[myplr]._pSplHotKey[slot] == -1) { + return; + } + + unsigned __int64 spells; + switch (plr[myplr]._pSplTHotKey[slot]) { + case RSPLTYPE_SKILL: + spells = plr[myplr]._pAblSpells; + break; + case RSPLTYPE_SPELL: + spells = plr[myplr]._pMemSpells; + break; + case RSPLTYPE_SCROLL: + spells = plr[myplr]._pScrlSpells; + break; + case RSPLTYPE_CHARGES: + spells = plr[myplr]._pISpells; + break; + } + + if (spells & (__int64)1 << (plr[myplr]._pSplHotKey[slot] - 1)) { + plr[myplr]._pRSpell = plr[myplr]._pSplHotKey[slot]; + plr[myplr]._pRSplType = plr[myplr]._pSplTHotKey[slot]; + drawpanflag = 255; + } } // 52571C: using guessed type int drawpanflag; void __fastcall CPrintString(int No, unsigned int glyph, unsigned char col) { - int *v3; // ebx - char *v4; // esi - char *v5; // edi - int v6; // ebx - signed int v7; // edx - unsigned int v8; // eax - unsigned int v9; // ecx - char v10; // cf - unsigned int v11; // ecx - signed int v12; // edx - int v13; // eax - int v14; // ecx - char v15; // al - signed int v16; // edx - int v17; // eax - int v18; // ecx - char v19; // al - signed int v20; // edx - int v21; // eax - int v22; // ecx - char v23; // al - - v3 = (int *)((char *)pPanelText + 4 * glyph); - v4 = (char *)pPanelText + *v3; - v5 = (char *)gpBuffer + No; - v6 = (int)&v4[v3[1] - *v3]; - if ( (_BYTE)col ) - { - if ( (unsigned char)col == 1 ) - { - do - { - v12 = 13; - do - { - while ( 1 ) - { - v13 = (unsigned char)*v4++; - if ( (v13 & 0x80u) == 0 ) - break; - _LOBYTE(v13) = -(char)v13; - v5 += v13; - v12 -= v13; - if ( !v12 ) - goto LABEL_28; - } - v12 -= v13; - v14 = v13; - do - { - v15 = *v4++; - if ( (unsigned char)v15 > 0xFDu ) - { - v15 = -65; - } - else if ( (unsigned char)v15 >= 0xF0u ) - { - v15 -= 62; - } - *v5++ = v15; - --v14; - } - while ( v14 ); - } - while ( v12 ); -LABEL_28: - v5 -= 781; - } - while ( (char *)v6 != v4 ); - } - else if ( (unsigned char)col == 2 ) - { - do - { - v16 = 13; - do - { - while ( 1 ) - { - v17 = (unsigned char)*v4++; - if ( (v17 & 0x80u) == 0 ) - break; - _LOBYTE(v17) = -(char)v17; - v5 += v17; - v16 -= v17; - if ( !v16 ) - goto LABEL_39; - } - v16 -= v17; - v18 = v17; - do - { - v19 = *v4++; - if ( (unsigned char)v19 >= 0xF0u ) - v19 -= 16; - *v5++ = v19; - --v18; - } - while ( v18 ); - } - while ( v16 ); -LABEL_39: - v5 -= 781; - } - while ( (char *)v6 != v4 ); - } - else - { - do - { - v20 = 13; - do - { - while ( 1 ) - { - v21 = (unsigned char)*v4++; - if ( (v21 & 0x80u) == 0 ) - break; - _LOBYTE(v21) = -(char)v21; - v5 += v21; - v20 -= v21; - if ( !v20 ) - goto LABEL_52; - } - v20 -= v21; - v22 = v21; - do - { - v23 = *v4++; - if ( (unsigned char)v23 >= 0xF0u ) - { - if ( (unsigned char)v23 >= 0xFEu ) - v23 = -49; - else - v23 -= 46; - } - *v5++ = v23; - --v22; - } - while ( v22 ); - } - while ( v20 ); -LABEL_52: - v5 -= 781; - } - while ( (char *)v6 != v4 ); - } - } - else - { - do - { - v7 = 13; - do - { - while ( 1 ) - { - v8 = (unsigned char)*v4++; - if ( (v8 & 0x80u) == 0 ) - break; - _LOBYTE(v8) = -(char)v8; - v5 += v8; - v7 -= v8; - if ( !v7 ) - goto LABEL_15; - } - v7 -= v8; - v9 = v8 >> 1; - if ( v8 & 1 ) - { - *v5++ = *v4++; - if ( !v9 ) - continue; - } - v10 = v9 & 1; - v11 = v8 >> 2; - if ( v10 ) - { - *(_WORD *)v5 = *(_WORD *)v4; - v4 += 2; - v5 += 2; - if ( !v11 ) - continue; - } - qmemcpy(v5, v4, 4 * v11); - v4 += 4 * v11; - v5 += 4 * v11; - } - while ( v7 ); -LABEL_15: - v5 -= 781; - } - while ( (char *)v6 != v4 ); - } + int *v3; // ebx + char *v4; // esi + char *v5; // edi + int v6; // ebx + signed int v7; // edx + unsigned int v8; // eax + unsigned int v9; // ecx + char v10; // cf + unsigned int v11; // ecx + signed int v12; // edx + int v13; // eax + int v14; // ecx + char v15; // al + signed int v16; // edx + int v17; // eax + int v18; // ecx + char v19; // al + signed int v20; // edx + int v21; // eax + int v22; // ecx + char v23; // al + + v3 = (int *)((char *)pPanelText + 4 * glyph); + v4 = (char *)pPanelText + *v3; + v5 = (char *)gpBuffer + No; + v6 = (int)&v4[v3[1] - *v3]; + if ((_BYTE)col) { + if ((unsigned char)col == 1) { + do { + v12 = 13; + do { + while (1) { + v13 = (unsigned char)*v4++; + if ((v13 & 0x80u) == 0) + break; + _LOBYTE(v13) = -(char)v13; + v5 += v13; + v12 -= v13; + if (!v12) + goto LABEL_28; + } + v12 -= v13; + v14 = v13; + do { + v15 = *v4++; + if ((unsigned char)v15 > 0xFDu) { + v15 = -65; + } else if ((unsigned char)v15 >= 0xF0u) { + v15 -= 62; + } + *v5++ = v15; + --v14; + } while (v14); + } while (v12); + LABEL_28: + v5 -= 781; + } while ((char *)v6 != v4); + } else if ((unsigned char)col == 2) { + do { + v16 = 13; + do { + while (1) { + v17 = (unsigned char)*v4++; + if ((v17 & 0x80u) == 0) + break; + _LOBYTE(v17) = -(char)v17; + v5 += v17; + v16 -= v17; + if (!v16) + goto LABEL_39; + } + v16 -= v17; + v18 = v17; + do { + v19 = *v4++; + if ((unsigned char)v19 >= 0xF0u) + v19 -= 16; + *v5++ = v19; + --v18; + } while (v18); + } while (v16); + LABEL_39: + v5 -= 781; + } while ((char *)v6 != v4); + } else { + do { + v20 = 13; + do { + while (1) { + v21 = (unsigned char)*v4++; + if ((v21 & 0x80u) == 0) + break; + _LOBYTE(v21) = -(char)v21; + v5 += v21; + v20 -= v21; + if (!v20) + goto LABEL_52; + } + v20 -= v21; + v22 = v21; + do { + v23 = *v4++; + if ((unsigned char)v23 >= 0xF0u) { + if ((unsigned char)v23 >= 0xFEu) + v23 = -49; + else + v23 -= 46; + } + *v5++ = v23; + --v22; + } while (v22); + } while (v20); + LABEL_52: + v5 -= 781; + } while ((char *)v6 != v4); + } + } else { + do { + v7 = 13; + do { + while (1) { + v8 = (unsigned char)*v4++; + if ((v8 & 0x80u) == 0) + break; + _LOBYTE(v8) = -(char)v8; + v5 += v8; + v7 -= v8; + if (!v7) + goto LABEL_15; + } + v7 -= v8; + v9 = v8 >> 1; + if (v8 & 1) { + *v5++ = *v4++; + if (!v9) + continue; + } + v10 = v9 & 1; + v11 = v8 >> 2; + if (v10) { + *(_WORD *)v5 = *(_WORD *)v4; + v4 += 2; + v5 += 2; + if (!v11) + continue; + } + qmemcpy(v5, v4, 4 * v11); + v4 += 4 * v11; + v5 += 4 * v11; + } while (v7); + LABEL_15: + v5 -= 781; + } while ((char *)v6 != v4); + } } void __fastcall AddPanelString(char *str, int just) { - strcpy(&panelstr[64 * pnumlines], str); - pstrjust[pnumlines] = just; + strcpy(&panelstr[64 * pnumlines], str); + pstrjust[pnumlines] = just; - if ( pnumlines < 4 ) - pnumlines++; + if (pnumlines < 4) + pnumlines++; } void __cdecl ClearPanel() { - pnumlines = 0; - pinfoflag = 0; + pnumlines = 0; + pinfoflag = 0; } // 4B8824: using guessed type int pinfoflag; void __fastcall DrawPanelBox(int x, int y, int w, int h, int sx, int sy) { - char *v6; // esi - char *v7; // edi - int v8; // edx - unsigned int v9; // ecx - char v10; // cf - unsigned int v11; // ecx - - v6 = (char *)pBtmBuff + 640 * y + x; - v7 = &gpBuffer->row_unused_1[sy].col_unused_1[sx]; - v8 = h; - do - { - v9 = w >> 1; - if ( !(w & 1) || (*v7 = *v6, ++v6, ++v7, v9) ) - { - v10 = v9 & 1; - v11 = w >> 2; - if ( !v10 || (*(_WORD *)v7 = *(_WORD *)v6, v6 += 2, v7 += 2, v11) ) - { - qmemcpy(v7, v6, 4 * v11); - v6 += 4 * v11; - v7 += 4 * v11; - } - } - v6 = &v6[-w + 640]; - v7 = &v7[-w + 768]; - --v8; - } - while ( v8 ); + char *v6; // esi + char *v7; // edi + int v8; // edx + unsigned int v9; // ecx + char v10; // cf + unsigned int v11; // ecx + + v6 = (char *)pBtmBuff + 640 * y + x; + v7 = &gpBuffer->row_unused_1[sy].col_unused_1[sx]; + v8 = h; + do { + v9 = w >> 1; + if (!(w & 1) || (*v7 = *v6, ++v6, ++v7, v9)) { + v10 = v9 & 1; + v11 = w >> 2; + if (!v10 || (*(_WORD *)v7 = *(_WORD *)v6, v6 += 2, v7 += 2, v11)) { + qmemcpy(v7, v6, 4 * v11); + v6 += 4 * v11; + v7 += 4 * v11; + } + } + v6 = &v6[-w + 640]; + v7 = &v7[-w + 768]; + --v8; + } while (v8); } void __fastcall SetFlaskHeight(char *buf, int min, int max, int c, int r) { - char *v5; // esi - char *v6; // edi - int v7; // edx + char *v5; // esi + char *v6; // edi + int v7; // edx - v5 = &buf[88 * min]; - v6 = &gpBuffer->row_unused_1[r].col_unused_1[c]; - v7 = max - min; - do - { - qmemcpy(v6, v5, 0x58u); - v5 += 88; - v6 += 768; - --v7; - } - while ( v7 ); + v5 = &buf[88 * min]; + v6 = &gpBuffer->row_unused_1[r].col_unused_1[c]; + v7 = max - min; + do { + qmemcpy(v6, v5, 0x58u); + v5 += 88; + v6 += 768; + --v7; + } while (v7); } void __fastcall DrawFlask(void *a1, int a2, int a3, void *a4, int a5, int a6) { - char *v6; // esi - _BYTE *v7; // edi - int v8; // edx - signed int v9; // ecx - char v10; // al - int v11; // [esp+Ch] [ebp-4h] - - v11 = a2; - v6 = (char *)a1 + a3; - v7 = (unsigned char *)a4 + a5; - v8 = a6; - do - { - v9 = 59; - do - { - v10 = *v6++; - if ( v10 ) - *v7 = v10; - ++v7; - --v9; - } - while ( v9 ); - v6 = &v6[v11 - 59]; - v7 += 709; - --v8; - } - while ( v8 ); + char *v6; // esi + _BYTE *v7; // edi + int v8; // edx + signed int v9; // ecx + char v10; // al + int v11; // [esp+Ch] [ebp-4h] + + v11 = a2; + v6 = (char *)a1 + a3; + v7 = (unsigned char *)a4 + a5; + v8 = a6; + do { + v9 = 59; + do { + v10 = *v6++; + if (v10) + *v7 = v10; + ++v7; + --v9; + } while (v9); + v6 = &v6[v11 - 59]; + v7 += 709; + --v8; + } while (v8); } void __cdecl DrawLifeFlask() { - int filled = (double)plr[myplr]._pHitPoints / (double)plr[myplr]._pMaxHP * 80.0; - plr[myplr]._pHPPer = filled; + int filled = (double)plr[myplr]._pHitPoints / (double)plr[myplr]._pMaxHP * 80.0; + plr[myplr]._pHPPer = filled; - if ( filled > 80 ) - filled = 80; - filled = 80 - filled; - if ( filled > 11 ) - filled = 11; - filled += 2; + if (filled > 80) + filled = 80; + filled = 80 - filled; + if (filled > 11) + filled = 11; + filled += 2; - DrawFlask(pLifeBuff, 88, 277, gpBuffer, 768 * 499 + 173, filled); - if ( filled != 13 ) - DrawFlask(pBtmBuff, 640, 640 * filled + 2029, gpBuffer, 768 * filled + 768 * 499 + 173, 13 - filled); + DrawFlask(pLifeBuff, 88, 277, gpBuffer, 768 * 499 + 173, filled); + if (filled != 13) + DrawFlask(pBtmBuff, 640, 640 * filled + 2029, gpBuffer, 768 * filled + 768 * 499 + 173, 13 - filled); } void __cdecl UpdateLifeFlask() { - int filled = (double)plr[myplr]._pHitPoints / (double)plr[myplr]._pMaxHP * 80.0; - plr[myplr]._pHPPer = filled; + int filled = (double)plr[myplr]._pHitPoints / (double)plr[myplr]._pMaxHP * 80.0; + plr[myplr]._pHPPer = filled; - if ( filled > 69 ) - filled = 69; - else if ( filled < 0 ) - filled = 0; - if ( filled != 69 ) - SetFlaskHeight(pLifeBuff, 16, 85 - filled, 160, 512); - if ( filled ) - DrawPanelBox(96, 85 - filled, 88, filled, 160, 581 - filled); + if (filled > 69) + filled = 69; + else if (filled < 0) + filled = 0; + if (filled != 69) + SetFlaskHeight(pLifeBuff, 16, 85 - filled, 160, 512); + if (filled) + DrawPanelBox(96, 85 - filled, 88, filled, 160, 581 - filled); } void __cdecl DrawManaFlask() { - int filled = plr[myplr]._pManaPer; - if ( filled > 80 ) - filled = 80; - filled = 80 - filled; - if ( filled > 11 ) - filled = 11; - filled += 2; + int filled = plr[myplr]._pManaPer; + if (filled > 80) + filled = 80; + filled = 80 - filled; + if (filled > 11) + filled = 11; + filled += 2; - DrawFlask(pManaBuff, 88, 277, gpBuffer, 768 * 499 + 173 + 366, filled); - if ( filled != 13 ) - DrawFlask(pBtmBuff, 640, 640 * filled + 2029 + 366, gpBuffer, 768 * filled + 768 * 499 + 173 + 366, 13 - filled); + DrawFlask(pManaBuff, 88, 277, gpBuffer, 768 * 499 + 173 + 366, filled); + if (filled != 13) + DrawFlask(pBtmBuff, 640, 640 * filled + 2029 + 366, gpBuffer, 768 * filled + 768 * 499 + 173 + 366, 13 - filled); } void __cdecl control_update_life_mana() { - int manaPer; - int maxMana = plr[myplr]._pMaxMana; - int mana = plr[myplr]._pMana; - if ( maxMana < 0 ) - maxMana = 0; - if ( mana < 0 ) - mana = 0; - if ( maxMana == 0 ) - manaPer = 0; - else - manaPer = (double)mana / (double)maxMana * 80.0; - plr[myplr]._pManaPer = manaPer; - plr[myplr]._pHPPer = (double)plr[myplr]._pHitPoints / (double)plr[myplr]._pMaxHP * 80.0; + int manaPer; + int maxMana = plr[myplr]._pMaxMana; + int mana = plr[myplr]._pMana; + if (maxMana < 0) + maxMana = 0; + if (mana < 0) + mana = 0; + if (maxMana == 0) + manaPer = 0; + else + manaPer = (double)mana / (double)maxMana * 80.0; + plr[myplr]._pManaPer = manaPer; + plr[myplr]._pHPPer = (double)plr[myplr]._pHitPoints / (double)plr[myplr]._pMaxHP * 80.0; } void __cdecl UpdateManaFlask() { - int filled; - int maxMana = plr[myplr]._pMaxMana; - int mana = plr[myplr]._pMana; - if ( maxMana < 0 ) - maxMana = 0; - if ( mana < 0 ) - mana = 0; + int filled; + int maxMana = plr[myplr]._pMaxMana; + int mana = plr[myplr]._pMana; + if (maxMana < 0) + maxMana = 0; + if (mana < 0) + mana = 0; - if ( maxMana == 0 ) - filled = 0; - else - filled = (double)mana / (double)maxMana * 80.0; + if (maxMana == 0) + filled = 0; + else + filled = (double)mana / (double)maxMana * 80.0; - plr[myplr]._pManaPer = filled; + plr[myplr]._pManaPer = filled; - if ( filled > 69 ) - filled = 69; - if ( filled != 69 ) - SetFlaskHeight(pManaBuff, 16, 85 - filled, 160 + 368, 512); - if ( filled ) - DrawPanelBox(96 + 368, 85 - filled, 88, filled, 160 + 368, 581 - filled); + if (filled > 69) + filled = 69; + if (filled != 69) + SetFlaskHeight(pManaBuff, 16, 85 - filled, 160 + 368, 512); + if (filled) + DrawPanelBox(96 + 368, 85 - filled, 88, filled, 160 + 368, 581 - filled); - DrawSpell(); + DrawSpell(); } void __cdecl InitControlPan() { - size_t v0; // esi - void *v1; // ecx - void *v2; // ecx - void *v3; // ecx - unsigned char *v5; // eax - - v0 = 144 * 640; - if ( gbMaxPlayers != 1 ) - v0 = 288 * 640; - pBtmBuff = DiabloAllocPtr(v0); - memset(pBtmBuff, 0, v0); - pManaBuff = (char *)DiabloAllocPtr(0x1E40); - memset(pManaBuff, 0, 0x1E40); - pLifeBuff = (char *)DiabloAllocPtr(0x1E40); - memset(pLifeBuff, 0, 0x1E40); - pPanelText = LoadFileInMem("CtrlPan\\SmalText.CEL", 0); - pChrPanel = LoadFileInMem("Data\\Char.CEL", 0); - pSpellCels = LoadFileInMem("CtrlPan\\SpelIcon.CEL", 0); - SetSpellTrans(RSPLTYPE_SKILL); - pStatusPanel = LoadFileInMem("CtrlPan\\Panel8.CEL", 0); - CelDecodeRect((char *)pBtmBuff, 0, 143, 640, (char *)pStatusPanel, 1, 640); - v1 = pStatusPanel; - pStatusPanel = 0; - mem_free_dbg(v1); - pStatusPanel = LoadFileInMem("CtrlPan\\P8Bulbs.CEL", 0); - CelDecodeRect(pLifeBuff, 0, 87, 88, (char *)pStatusPanel, 1, 88); - CelDecodeRect(pManaBuff, 0, 87, 88, (char *)pStatusPanel, 2, 88); - v2 = pStatusPanel; - pStatusPanel = 0; - mem_free_dbg(v2); - talkflag = 0; - if ( gbMaxPlayers != 1 ) - { - pTalkPanel = LoadFileInMem("CtrlPan\\TalkPanl.CEL", 0); - CelDecodeRect((char *)pBtmBuff, 0, 287, 640, (char *)pTalkPanel, 1, 640); - v3 = pTalkPanel; - pTalkPanel = 0; - mem_free_dbg(v3); - pMultiBtns = LoadFileInMem("CtrlPan\\P8But2.CEL", 0); - pTalkBtns = LoadFileInMem("CtrlPan\\TalkButt.CEL", 0); - sgbPlrTalkTbl = 0; - *(_DWORD *)&tempstr[256] = 0x1010101; - talkbtndown[0] = 0; - talkbtndown[1] = 0; - sgszTalkMsg[0] = 0; - talkbtndown[2] = 0; - } - panelflag = 0; - lvlbtndown = 0; - pPanelButtons = LoadFileInMem("CtrlPan\\Panel8bu.CEL", 0); - memset(panbtn, 0, sizeof(panbtn)); - panbtndown = 0; - numpanbtns = 2 * (gbMaxPlayers != 1) + 6; - pChrButtons = LoadFileInMem("Data\\CharBut.CEL", 0); - chrbtn[0] = 0; - chrbtn[1] = 0; - chrbtn[2] = 0; - chrbtnactive = 0; - chrbtn[3] = 0; - pDurIcons = LoadFileInMem("Items\\DurIcons.CEL", 0); - strcpy(infostr, &empty_string); - ClearPanel(); - drawhpflag = TRUE; - drawmanaflag = TRUE; - chrflag = 0; - spselflag = 0; - pSpellBkCel = LoadFileInMem("Data\\SpellBk.CEL", 0); - pSBkBtnCel = LoadFileInMem("Data\\SpellBkB.CEL", 0); - pSBkIconCels = LoadFileInMem("Data\\SpellI2.CEL", 0); - sbooktab = 0; - sbookflag = 0; - if ( plr[myplr]._pClass == PC_WARRIOR ) { - SpellPages[0][0] = SPL_REPAIR; - } else if ( plr[myplr]._pClass == PC_ROGUE ) { - SpellPages[0][0] = SPL_DISARM; - } else if ( plr[myplr]._pClass == PC_SORCERER ) { - SpellPages[0][0] = SPL_RECHARGE; - } - pQLogCel = LoadFileInMem("Data\\Quest.CEL", 0); - v5 = LoadFileInMem("CtrlPan\\Golddrop.cel", 0); - frame_4B8800 = 1; - dropGoldFlag = 0; - dropGoldValue = 0; - initialDropGoldValue = 0; - initialDropGoldIndex = 0; - pGBoxBuff = v5; + size_t v0; // esi + void *v1; // ecx + void *v2; // ecx + void *v3; // ecx + unsigned char *v5; // eax + + v0 = 144 * 640; + if (gbMaxPlayers != 1) + v0 = 288 * 640; + pBtmBuff = DiabloAllocPtr(v0); + memset(pBtmBuff, 0, v0); + pManaBuff = (char *)DiabloAllocPtr(0x1E40); + memset(pManaBuff, 0, 0x1E40); + pLifeBuff = (char *)DiabloAllocPtr(0x1E40); + memset(pLifeBuff, 0, 0x1E40); + pPanelText = LoadFileInMem("CtrlPan\\SmalText.CEL", 0); + pChrPanel = LoadFileInMem("Data\\Char.CEL", 0); + pSpellCels = LoadFileInMem("CtrlPan\\SpelIcon.CEL", 0); + SetSpellTrans(RSPLTYPE_SKILL); + pStatusPanel = LoadFileInMem("CtrlPan\\Panel8.CEL", 0); + CelDecodeRect((char *)pBtmBuff, 0, 143, 640, (char *)pStatusPanel, 1, 640); + v1 = pStatusPanel; + pStatusPanel = 0; + mem_free_dbg(v1); + pStatusPanel = LoadFileInMem("CtrlPan\\P8Bulbs.CEL", 0); + CelDecodeRect(pLifeBuff, 0, 87, 88, (char *)pStatusPanel, 1, 88); + CelDecodeRect(pManaBuff, 0, 87, 88, (char *)pStatusPanel, 2, 88); + v2 = pStatusPanel; + pStatusPanel = 0; + mem_free_dbg(v2); + talkflag = 0; + if (gbMaxPlayers != 1) { + pTalkPanel = LoadFileInMem("CtrlPan\\TalkPanl.CEL", 0); + CelDecodeRect((char *)pBtmBuff, 0, 287, 640, (char *)pTalkPanel, 1, 640); + v3 = pTalkPanel; + pTalkPanel = 0; + mem_free_dbg(v3); + pMultiBtns = LoadFileInMem("CtrlPan\\P8But2.CEL", 0); + pTalkBtns = LoadFileInMem("CtrlPan\\TalkButt.CEL", 0); + sgbPlrTalkTbl = 0; + *(_DWORD *)&tempstr[256] = 0x1010101; + talkbtndown[0] = 0; + talkbtndown[1] = 0; + sgszTalkMsg[0] = 0; + talkbtndown[2] = 0; + } + panelflag = 0; + lvlbtndown = 0; + pPanelButtons = LoadFileInMem("CtrlPan\\Panel8bu.CEL", 0); + memset(panbtn, 0, sizeof(panbtn)); + panbtndown = 0; + numpanbtns = 2 * (gbMaxPlayers != 1) + 6; + pChrButtons = LoadFileInMem("Data\\CharBut.CEL", 0); + chrbtn[0] = 0; + chrbtn[1] = 0; + chrbtn[2] = 0; + chrbtnactive = 0; + chrbtn[3] = 0; + pDurIcons = LoadFileInMem("Items\\DurIcons.CEL", 0); + strcpy(infostr, &empty_string); + ClearPanel(); + drawhpflag = TRUE; + drawmanaflag = TRUE; + chrflag = 0; + spselflag = 0; + pSpellBkCel = LoadFileInMem("Data\\SpellBk.CEL", 0); + pSBkBtnCel = LoadFileInMem("Data\\SpellBkB.CEL", 0); + pSBkIconCels = LoadFileInMem("Data\\SpellI2.CEL", 0); + sbooktab = 0; + sbookflag = 0; + if (plr[myplr]._pClass == PC_WARRIOR) { + SpellPages[0][0] = SPL_REPAIR; + } else if (plr[myplr]._pClass == PC_ROGUE) { + SpellPages[0][0] = SPL_DISARM; + } else if (plr[myplr]._pClass == PC_SORCERER) { + SpellPages[0][0] = SPL_RECHARGE; + } + pQLogCel = LoadFileInMem("Data\\Quest.CEL", 0); + v5 = LoadFileInMem("CtrlPan\\Golddrop.cel", 0); + frame_4B8800 = 1; + dropGoldFlag = 0; + dropGoldValue = 0; + initialDropGoldValue = 0; + initialDropGoldIndex = 0; + pGBoxBuff = v5; } // 4B84DC: using guessed type int dropGoldFlag; // 4B851C: using guessed type int lvlbtndown; @@ -1151,135 +1050,126 @@ void __cdecl InitControlPan() void __cdecl ClearCtrlPan() { - DrawPanelBox(0, sgbPlrTalkTbl + 16, 640, 128, 64, 512); - DrawInfoBox(); + DrawPanelBox(0, sgbPlrTalkTbl + 16, 640, 128, 64, 512); + DrawInfoBox(); } // 4B8840: using guessed type int sgbPlrTalkTbl; void __cdecl DrawCtrlPan() { - signed int v0; // edi - int *v1; // esi - int v2; // ecx - int v3; // eax - - v0 = 0; - v1 = (int *)PanBtnPos; - do - { - v2 = *v1; - if ( panbtn[v0] ) - CelDecodeOnly(v2 + 64, v1[1] + 178, pPanelButtons, v0 + 1, 71); - else - DrawPanelBox(v2, v1[1] - 336, 71, 20, v2 + 64, v1[1] + 160); - ++v0; - v1 += 5; - } - while ( v0 < 6 ); - if ( numpanbtns == 8 ) - { - CelDecodeOnly(151, 634, pMultiBtns, panbtn[6] + 1, 33); - if ( FriendlyMode ) - v3 = panbtn[7] + 3; - else - v3 = panbtn[7] + 5; - CelDecodeOnly(591, 634, pMultiBtns, v3, 33); - } + signed int v0; // edi + int *v1; // esi + int v2; // ecx + int v3; // eax + + v0 = 0; + v1 = (int *)PanBtnPos; + do { + v2 = *v1; + if (panbtn[v0]) + CelDecodeOnly(v2 + 64, v1[1] + 178, pPanelButtons, v0 + 1, 71); + else + DrawPanelBox(v2, v1[1] - 336, 71, 20, v2 + 64, v1[1] + 160); + ++v0; + v1 += 5; + } while (v0 < 6); + if (numpanbtns == 8) { + CelDecodeOnly(151, 634, pMultiBtns, panbtn[6] + 1, 33); + if (FriendlyMode) + v3 = panbtn[7] + 3; + else + v3 = panbtn[7] + 5; + CelDecodeOnly(591, 634, pMultiBtns, v3, 33); + } } // 484368: using guessed type int FriendlyMode; // 4B8A7C: using guessed type int numpanbtns; void __cdecl DoSpeedBook() { - unsigned __int64 spells, spell; - - spselflag = 1; - int xo = 636; - int yo = 495; - int X = 600; - int Y = 307; - if ( plr[myplr]._pRSpell != -1 ) { - for ( int i = 0; i < 4; i++ ) { - switch ( i ) { - case RSPLTYPE_SKILL: - spells = plr[myplr]._pAblSpells; - break; - case RSPLTYPE_SPELL: - spells = plr[myplr]._pMemSpells; - break; - case RSPLTYPE_SCROLL: - spells = plr[myplr]._pScrlSpells; - break; - case RSPLTYPE_CHARGES: - spells = plr[myplr]._pISpells; - break; - } - spell = (__int64)1; - for ( int j = 1; j < MAX_SPELLS; j++ ) { - if ( spell & spells ) { - if ( j == plr[myplr]._pRSpell && i == plr[myplr]._pRSplType ) { - X = xo - 36; - Y = yo - 188; - } - xo -= 56; - if ( xo == 20 ) { - xo = 636; - yo -= 56; - } - } - spell <<= (__int64)1; - } - if ( spells && xo != 636 ) - xo -= 56; - if ( xo == 20 ) { - xo = 636; - yo -= 56; - } - } - } - - SetCursorPos(X, Y); + unsigned __int64 spells, spell; + + spselflag = 1; + int xo = 636; + int yo = 495; + int X = 600; + int Y = 307; + if (plr[myplr]._pRSpell != -1) { + for (int i = 0; i < 4; i++) { + switch (i) { + case RSPLTYPE_SKILL: + spells = plr[myplr]._pAblSpells; + break; + case RSPLTYPE_SPELL: + spells = plr[myplr]._pMemSpells; + break; + case RSPLTYPE_SCROLL: + spells = plr[myplr]._pScrlSpells; + break; + case RSPLTYPE_CHARGES: + spells = plr[myplr]._pISpells; + break; + } + spell = (__int64)1; + for (int j = 1; j < MAX_SPELLS; j++) { + if (spell & spells) { + if (j == plr[myplr]._pRSpell && i == plr[myplr]._pRSplType) { + X = xo - 36; + Y = yo - 188; + } + xo -= 56; + if (xo == 20) { + xo = 636; + yo -= 56; + } + } + spell <<= (__int64)1; + } + if (spells && xo != 636) + xo -= 56; + if (xo == 20) { + xo = 636; + yo -= 56; + } + } + } + + SetCursorPos(X, Y); } // 4B8C98: using guessed type int spselflag; void __cdecl DoPanBtn() { - int v0; // edx - int v1; // ebx - int v2; // edi - int v3; // esi - int (*v4)[5]; // eax - int v5; // ecx - - v0 = MouseX; - v1 = MouseY; - v2 = numpanbtns; - v3 = 0; - if ( numpanbtns > 0 ) - { - v4 = PanBtnPos; - do - { - if ( v0 >= (*v4)[0] && v0 <= (*v4)[0] + (*v4)[2] ) - { - v5 = (*v4)[1]; - if ( v1 >= v5 && v1 <= v5 + (*v4)[3] ) - { - panbtn[v3] = 1; - drawbtnflag = 1; - panbtndown = 1; - } - } - ++v3; - ++v4; - } - while ( v3 < v2 ); - } - if ( !spselflag && v0 >= 565 && v0 < 621 && v1 >= 416 && v1 < 472 ) - { - DoSpeedBook(); - gamemenu_off(); - } + int v0; // edx + int v1; // ebx + int v2; // edi + int v3; // esi + int(*v4)[5]; // eax + int v5; // ecx + + v0 = MouseX; + v1 = MouseY; + v2 = numpanbtns; + v3 = 0; + if (numpanbtns > 0) { + v4 = PanBtnPos; + do { + if (v0 >= (*v4)[0] && v0 <= (*v4)[0] + (*v4)[2]) { + v5 = (*v4)[1]; + if (v1 >= v5 && v1 <= v5 + (*v4)[3]) { + panbtn[v3] = 1; + drawbtnflag = 1; + panbtndown = 1; + } + } + ++v3; + ++v4; + } while (v3 < v2); + } + if (!spselflag && v0 >= 565 && v0 < 621 && v1 >= 416 && v1 < 472) { + DoSpeedBook(); + gamemenu_off(); + } } // 4B8A7C: using guessed type int numpanbtns; // 4B8C90: using guessed type int panbtndown; @@ -1287,182 +1177,160 @@ void __cdecl DoPanBtn() void __fastcall control_set_button_down(int btn_id) { - panbtn[btn_id] = 1; - drawbtnflag = 1; - panbtndown = 1; + panbtn[btn_id] = 1; + drawbtnflag = 1; + panbtndown = 1; } // 4B8C90: using guessed type int panbtndown; void __cdecl control_check_btn_press() { - int v0; // edx - int v1; // esi - - v0 = MouseX; - v1 = MouseY; - if ( MouseX >= PanBtnPos[3][0] - && MouseX <= PanBtnPos[3][0] + PanBtnPos[3][2] - && MouseY >= PanBtnPos[3][1] - && MouseY <= PanBtnPos[3][1] + PanBtnPos[3][3] ) - { - control_set_button_down(3); - } - if ( v0 >= PanBtnPos[6][0] - && v0 <= PanBtnPos[6][0] + PanBtnPos[6][2] - && v1 >= PanBtnPos[6][1] - && v1 <= PanBtnPos[6][1] + PanBtnPos[6][3] ) - { - control_set_button_down(6); - } + int v0; // edx + int v1; // esi + + v0 = MouseX; + v1 = MouseY; + if (MouseX >= PanBtnPos[3][0] + && MouseX <= PanBtnPos[3][0] + PanBtnPos[3][2] + && MouseY >= PanBtnPos[3][1] + && MouseY <= PanBtnPos[3][1] + PanBtnPos[3][3]) { + control_set_button_down(3); + } + if (v0 >= PanBtnPos[6][0] + && v0 <= PanBtnPos[6][0] + PanBtnPos[6][2] + && v1 >= PanBtnPos[6][1] + && v1 <= PanBtnPos[6][1] + PanBtnPos[6][3]) { + control_set_button_down(6); + } } void __cdecl DoAutoMap() { - if ( currlevel || gbMaxPlayers != 1 ) - { - if ( automapflag ) - automapflag = 0; - else - StartAutomap(); - } - else - { - InitDiabloMsg(EMSG_NO_AUTOMAP_IN_TOWN); - } + if (currlevel || gbMaxPlayers != 1) { + if (automapflag) + automapflag = 0; + else + StartAutomap(); + } else { + InitDiabloMsg(EMSG_NO_AUTOMAP_IN_TOWN); + } } // 679660: using guessed type char gbMaxPlayers; void __cdecl CheckPanelInfo() { - int v0; // edi - int v1; // eax - int v2; // ecx - int v3; // ecx - int v4; // edi - int v5; // eax - int *v6; // edx - int v7; // ebx - int v8; // ebx - int *v9; // eax - signed int v10; // edx - int v11; // ecx - int v12; // [esp+10h] [ebp-4h] - - v0 = 0; - panelflag = 0; - ClearPanel(); - if ( numpanbtns > 0 ) - { - do - { - v1 = v0; - v2 = PanBtnPos[v0][0]; - if ( MouseX >= v2 && MouseX <= v2 + PanBtnPos[v1][2] ) - { - v3 = PanBtnPos[v1][1]; - if ( MouseY >= v3 && MouseY <= v3 + PanBtnPos[v1][3] ) - { - if ( v0 == 7 ) - { - if ( FriendlyMode ) - strcpy(infostr, "Player friendly"); - else - strcpy(infostr, "Player attack"); - } - else - { - strcpy(infostr, PanBtnStr[v0]); - } - if ( PanBtnHotKey[v0] ) - { - sprintf(tempstr, "Hotkey : %s", PanBtnHotKey[v0]); - AddPanelString(tempstr, 1); - } - infoclr = COL_WHITE; - panelflag = 1; - pinfoflag = 1; - } - } - ++v0; - } - while ( v0 < numpanbtns ); - } - if ( !spselflag && MouseX >= 565 && MouseX < 621 && MouseY >= 416 && MouseY < 472 ) - { - strcpy(infostr, "Select current spell button"); - infoclr = COL_WHITE; - panelflag = 1; - pinfoflag = 1; - strcpy(tempstr, "Hotkey : 's'"); - AddPanelString(tempstr, 1); - v4 = plr[myplr]._pRSpell; - if ( v4 != -1 ) - { - switch ( _LOBYTE(plr[myplr]._pRSplType) ) - { - case RSPLTYPE_SKILL: - sprintf(tempstr, "%s Skill", spelldata[v4].sSkillText); -LABEL_54: - AddPanelString(tempstr, 1); - break; - case RSPLTYPE_SPELL: - sprintf(tempstr, "%s Spell", spelldata[v4].sNameText); - AddPanelString(tempstr, 1); - v11 = plr[myplr]._pISplLvlAdd + plr[myplr]._pSplLvl[v4]; - if ( v11 < 0 ) - v11 = 0; - if ( v11 ) - sprintf(tempstr, "Spell Level %i", v11); - else - sprintf(tempstr, "Spell Level 0 - Unusable"); - goto LABEL_54; - case RSPLTYPE_SCROLL: - sprintf(tempstr, "Scroll of %s", spelldata[v4].sNameText); - AddPanelString(tempstr, 1); - v12 = 0; - v5 = myplr; - if ( plr[myplr]._pNumInv > 0 ) - { - v6 = &plr[v5].InvList[0]._iMiscId; - v7 = plr[myplr]._pNumInv; - do - { - if ( *(v6 - 53) != -1 && (*v6 == IMISC_SCROLL || *v6 == IMISC_SCROLLT) && v6[1] == v4 ) - ++v12; - v6 += 92; - --v7; - } - while ( v7 ); - } - v8 = v12; - v9 = &plr[v5].SpdList[0]._iMiscId; - v10 = MAXBELTITEMS; - do - { - if ( *(v9 - 53) != -1 && (*v9 == IMISC_SCROLL || *v9 == IMISC_SCROLLT) && v9[1] == v4 ) - ++v8; - v9 += 92; - --v10; - } - while ( v10 ); - if ( v8 == 1 ) - strcpy(tempstr, "1 Scroll"); - else - sprintf(tempstr, "%i Scrolls", v8); - goto LABEL_54; - case RSPLTYPE_CHARGES: - sprintf(tempstr, "Staff of %s", spelldata[v4].sNameText); - AddPanelString(tempstr, 1); - if ( plr[myplr].InvBody[INVLOC_HAND_LEFT]._iCharges == 1 ) - strcpy(tempstr, "1 Charge"); - else - sprintf(tempstr, "%i Charges", plr[myplr].InvBody[INVLOC_HAND_LEFT]._iCharges); - goto LABEL_54; - } - } - } - if ( MouseX > 190 && MouseX < 437 && MouseY > 356 && MouseY < 385 ) - pcursinvitem = CheckInvHLight(); + int v0; // edi + int v1; // eax + int v2; // ecx + int v3; // ecx + int v4; // edi + int v5; // eax + int *v6; // edx + int v7; // ebx + int v8; // ebx + int *v9; // eax + signed int v10; // edx + int v11; // ecx + int v12; // [esp+10h] [ebp-4h] + + v0 = 0; + panelflag = 0; + ClearPanel(); + if (numpanbtns > 0) { + do { + v1 = v0; + v2 = PanBtnPos[v0][0]; + if (MouseX >= v2 && MouseX <= v2 + PanBtnPos[v1][2]) { + v3 = PanBtnPos[v1][1]; + if (MouseY >= v3 && MouseY <= v3 + PanBtnPos[v1][3]) { + if (v0 == 7) { + if (FriendlyMode) + strcpy(infostr, "Player friendly"); + else + strcpy(infostr, "Player attack"); + } else { + strcpy(infostr, PanBtnStr[v0]); + } + if (PanBtnHotKey[v0]) { + sprintf(tempstr, "Hotkey : %s", PanBtnHotKey[v0]); + AddPanelString(tempstr, 1); + } + infoclr = COL_WHITE; + panelflag = 1; + pinfoflag = 1; + } + } + ++v0; + } while (v0 < numpanbtns); + } + if (!spselflag && MouseX >= 565 && MouseX < 621 && MouseY >= 416 && MouseY < 472) { + strcpy(infostr, "Select current spell button"); + infoclr = COL_WHITE; + panelflag = 1; + pinfoflag = 1; + strcpy(tempstr, "Hotkey : 's'"); + AddPanelString(tempstr, 1); + v4 = plr[myplr]._pRSpell; + if (v4 != -1) { + switch (_LOBYTE(plr[myplr]._pRSplType)) { + case RSPLTYPE_SKILL: + sprintf(tempstr, "%s Skill", spelldata[v4].sSkillText); + LABEL_54: + AddPanelString(tempstr, 1); + break; + case RSPLTYPE_SPELL: + sprintf(tempstr, "%s Spell", spelldata[v4].sNameText); + AddPanelString(tempstr, 1); + v11 = plr[myplr]._pISplLvlAdd + plr[myplr]._pSplLvl[v4]; + if (v11 < 0) + v11 = 0; + if (v11) + sprintf(tempstr, "Spell Level %i", v11); + else + sprintf(tempstr, "Spell Level 0 - Unusable"); + goto LABEL_54; + case RSPLTYPE_SCROLL: + sprintf(tempstr, "Scroll of %s", spelldata[v4].sNameText); + AddPanelString(tempstr, 1); + v12 = 0; + v5 = myplr; + if (plr[myplr]._pNumInv > 0) { + v6 = &plr[v5].InvList[0]._iMiscId; + v7 = plr[myplr]._pNumInv; + do { + if (*(v6 - 53) != -1 && (*v6 == IMISC_SCROLL || *v6 == IMISC_SCROLLT) && v6[1] == v4) + ++v12; + v6 += 92; + --v7; + } while (v7); + } + v8 = v12; + v9 = &plr[v5].SpdList[0]._iMiscId; + v10 = MAXBELTITEMS; + do { + if (*(v9 - 53) != -1 && (*v9 == IMISC_SCROLL || *v9 == IMISC_SCROLLT) && v9[1] == v4) + ++v8; + v9 += 92; + --v10; + } while (v10); + if (v8 == 1) + strcpy(tempstr, "1 Scroll"); + else + sprintf(tempstr, "%i Scrolls", v8); + goto LABEL_54; + case RSPLTYPE_CHARGES: + sprintf(tempstr, "Staff of %s", spelldata[v4].sNameText); + AddPanelString(tempstr, 1); + if (plr[myplr].InvBody[INVLOC_HAND_LEFT]._iCharges == 1) + strcpy(tempstr, "1 Charge"); + else + sprintf(tempstr, "%i Charges", plr[myplr].InvBody[INVLOC_HAND_LEFT]._iCharges); + goto LABEL_54; + } + } + } + if (MouseX > 190 && MouseX < 437 && MouseY > 356 && MouseY < 385) + pcursinvitem = CheckInvHLight(); } // 484368: using guessed type int FriendlyMode; // 4B8824: using guessed type int pinfoflag; @@ -1474,91 +1342,83 @@ LABEL_54: void __cdecl CheckBtnUp() { - signed int v0; // esi - int *v1; // eax - int v2; // edx - signed int v3; // eax - int v4; // ecx - int v5; // ecx - char v6; // [esp+Fh] [ebp-1h] - - v6 = 1; - drawbtnflag = 1; - panbtndown = 0; - v0 = 0; - do - { - v1 = &panbtn[v0]; - if ( *v1 ) - { - v2 = MouseX; - *v1 = 0; - v3 = v0; - v4 = PanBtnPos[v0][0]; - if ( v2 >= v4 && v2 <= v4 + PanBtnPos[v3][2] ) - { - v5 = PanBtnPos[v3][1]; - if ( MouseY >= v5 && MouseY <= v5 + PanBtnPos[v3][3] ) - { - switch ( v0 ) - { - case PANBTN_CHARINFO: - questlog = 0; - chrflag = chrflag == 0; - break; - case PANBTN_QLOG: - chrflag = 0; - if ( questlog ) - questlog = 0; - else - StartQuestlog(); - break; - case PANBTN_AUTOMAP: - DoAutoMap(); - break; - case PANBTN_MAINMENU: - qtextflag = FALSE; - gamemenu_handle_previous(); - v6 = 0; - break; - case PANBTN_INVENTORY: - sbookflag = 0; - invflag = invflag == 0; - if ( dropGoldFlag ) - { - dropGoldFlag = 0; - dropGoldValue = 0; - } - break; - case PANBTN_SPELLBOOK: - invflag = 0; - if ( dropGoldFlag ) - { - dropGoldFlag = 0; - dropGoldValue = 0; - } - sbookflag = sbookflag == 0; - break; - case PANBTN_SENDMSG: - if ( talkflag ) - control_reset_talk(); - else - control_type_message(); - break; - case PANBTN_FRIENDLY: - FriendlyMode = FriendlyMode == 0; - break; - default: - break; - } - } - } - } - ++v0; - } - while ( v0 < 8 ); - if ( v6 ) - gamemenu_off(); + signed int v0; // esi + int *v1; // eax + int v2; // edx + signed int v3; // eax + int v4; // ecx + int v5; // ecx + char v6; // [esp+Fh] [ebp-1h] + + v6 = 1; + drawbtnflag = 1; + panbtndown = 0; + v0 = 0; + do { + v1 = &panbtn[v0]; + if (*v1) { + v2 = MouseX; + *v1 = 0; + v3 = v0; + v4 = PanBtnPos[v0][0]; + if (v2 >= v4 && v2 <= v4 + PanBtnPos[v3][2]) { + v5 = PanBtnPos[v3][1]; + if (MouseY >= v5 && MouseY <= v5 + PanBtnPos[v3][3]) { + switch (v0) { + case PANBTN_CHARINFO: + questlog = 0; + chrflag = chrflag == 0; + break; + case PANBTN_QLOG: + chrflag = 0; + if (questlog) + questlog = 0; + else + StartQuestlog(); + break; + case PANBTN_AUTOMAP: + DoAutoMap(); + break; + case PANBTN_MAINMENU: + qtextflag = FALSE; + gamemenu_handle_previous(); + v6 = 0; + break; + case PANBTN_INVENTORY: + sbookflag = 0; + invflag = invflag == 0; + if (dropGoldFlag) { + dropGoldFlag = 0; + dropGoldValue = 0; + } + break; + case PANBTN_SPELLBOOK: + invflag = 0; + if (dropGoldFlag) { + dropGoldFlag = 0; + dropGoldValue = 0; + } + sbookflag = sbookflag == 0; + break; + case PANBTN_SENDMSG: + if (talkflag) + control_reset_talk(); + else + control_type_message(); + break; + case PANBTN_FRIENDLY: + FriendlyMode = FriendlyMode == 0; + break; + default: + break; + } + } + } + } + ++v0; + } while (v0 < 8); + if (v6) + gamemenu_off(); } // 484368: using guessed type int FriendlyMode; // 4B84DC: using guessed type int dropGoldFlag; @@ -1570,212 +1430,187 @@ void __cdecl CheckBtnUp() void __cdecl FreeControlPan() { - void *v0; // ecx - void *v1; // ecx - void *v2; // ecx - void *v3; // ecx - void *v4; // ecx - void *v5; // ecx - void *v6; // ecx - void *v7; // ecx - void *v8; // ecx - void *v9; // ecx - void *v10; // ecx - void *v11; // ecx - void *v12; // ecx - void *v13; // ecx - void *v14; // ecx - void *v15; // ecx - - v0 = pBtmBuff; - pBtmBuff = 0; - mem_free_dbg(v0); - v1 = pManaBuff; - pManaBuff = 0; - mem_free_dbg(v1); - v2 = pLifeBuff; - pLifeBuff = 0; - mem_free_dbg(v2); - v3 = pPanelText; - pPanelText = 0; - mem_free_dbg(v3); - v4 = pChrPanel; - pChrPanel = 0; - mem_free_dbg(v4); - v5 = pSpellCels; - pSpellCels = 0; - mem_free_dbg(v5); - v6 = pPanelButtons; - pPanelButtons = 0; - mem_free_dbg(v6); - v7 = pMultiBtns; - pMultiBtns = 0; - mem_free_dbg(v7); - v8 = pTalkBtns; - pTalkBtns = 0; - mem_free_dbg(v8); - v9 = pChrButtons; - pChrButtons = 0; - mem_free_dbg(v9); - v10 = pDurIcons; - pDurIcons = 0; - mem_free_dbg(v10); - v11 = pQLogCel; - pQLogCel = 0; - mem_free_dbg(v11); - v12 = pSpellBkCel; - pSpellBkCel = 0; - mem_free_dbg(v12); - v13 = pSBkBtnCel; - pSBkBtnCel = 0; - mem_free_dbg(v13); - v14 = pSBkIconCels; - pSBkIconCels = 0; - mem_free_dbg(v14); - v15 = pGBoxBuff; - pGBoxBuff = 0; - mem_free_dbg(v15); + void *v0; // ecx + void *v1; // ecx + void *v2; // ecx + void *v3; // ecx + void *v4; // ecx + void *v5; // ecx + void *v6; // ecx + void *v7; // ecx + void *v8; // ecx + void *v9; // ecx + void *v10; // ecx + void *v11; // ecx + void *v12; // ecx + void *v13; // ecx + void *v14; // ecx + void *v15; // ecx + + v0 = pBtmBuff; + pBtmBuff = 0; + mem_free_dbg(v0); + v1 = pManaBuff; + pManaBuff = 0; + mem_free_dbg(v1); + v2 = pLifeBuff; + pLifeBuff = 0; + mem_free_dbg(v2); + v3 = pPanelText; + pPanelText = 0; + mem_free_dbg(v3); + v4 = pChrPanel; + pChrPanel = 0; + mem_free_dbg(v4); + v5 = pSpellCels; + pSpellCels = 0; + mem_free_dbg(v5); + v6 = pPanelButtons; + pPanelButtons = 0; + mem_free_dbg(v6); + v7 = pMultiBtns; + pMultiBtns = 0; + mem_free_dbg(v7); + v8 = pTalkBtns; + pTalkBtns = 0; + mem_free_dbg(v8); + v9 = pChrButtons; + pChrButtons = 0; + mem_free_dbg(v9); + v10 = pDurIcons; + pDurIcons = 0; + mem_free_dbg(v10); + v11 = pQLogCel; + pQLogCel = 0; + mem_free_dbg(v11); + v12 = pSpellBkCel; + pSpellBkCel = 0; + mem_free_dbg(v12); + v13 = pSBkBtnCel; + pSBkBtnCel = 0; + mem_free_dbg(v13); + v14 = pSBkIconCels; + pSBkIconCels = 0; + mem_free_dbg(v14); + v15 = pGBoxBuff; + pGBoxBuff = 0; + mem_free_dbg(v15); } int __fastcall control_WriteStringToBuffer(char *str) { - signed int v1; // edx - unsigned char v2; // al + signed int v1; // edx + unsigned char v2; // al - v1 = 0; - do - { - v2 = *str; - if ( !*str ) - return 1; - ++str; - v1 += fontkern[fontframe[fontidx[v2]]]; - } - while ( v1 < 125 ); - return 0; + v1 = 0; + do { + v2 = *str; + if (!*str) + return 1; + ++str; + v1 += fontkern[fontframe[fontidx[v2]]]; + } while (v1 < 125); + return 0; } void __cdecl DrawInfoBox() { - int v0; // ecx - int v1; // eax - int v2; // eax - int v3; // esi - char *v4; // eax - const char *v5; // eax - signed int v7; // edi - signed int v8; // ebp - int v9; // esi - char *v10; // ebx - - DrawPanelBox(177, 62, 288, 60, 241, 558); - v0 = trigflag[3]; - v1 = spselflag; - if ( !panelflag && !trigflag[3] && pcursinvitem == -1 ) - { - if ( spselflag ) - { -LABEL_32: - infoclr = COL_WHITE; - goto LABEL_33; - } - infostr[0] = 0; - infoclr = COL_WHITE; - ClearPanel(); - } - if ( v1 || v0 ) - goto LABEL_32; - if ( pcurs < CURSOR_FIRSTITEM ) - { - if ( pcursitem != -1 ) - GetItemStr(pcursitem); - if ( pcursobj != -1 ) - GetObjectStr(pcursobj); - if ( pcursmonst != -1 ) - { - if ( leveltype != DTYPE_TOWN) - { - infoclr = COL_WHITE; - strcpy(infostr, monster[pcursmonst].mName); - ClearPanel(); - if ( monster[pcursmonst]._uniqtype ) - { - infoclr = COL_GOLD; - PrintUniqueHistory(); - } - else - { - PrintMonstHistory(monster[pcursmonst].MType->mtype); - } - } - else - { - strcpy(infostr, towner[pcursmonst]._tName); - } - } - if ( pcursplr != -1 ) - { - infoclr = COL_GOLD; - strcpy(infostr, plr[pcursplr]._pName); - ClearPanel(); - sprintf(tempstr, "Level : %i", plr[pcursplr]._pLevel); - AddPanelString(tempstr, 1); - sprintf(tempstr, "Hit Points %i of %i", plr[pcursplr]._pHitPoints >> 6, plr[pcursplr]._pMaxHP >> 6); - AddPanelString(tempstr, 1); - } - } - else - { - v2 = myplr; - if ( plr[myplr].HoldItem._itype == ITYPE_GOLD ) - { - v3 = plr[v2].HoldItem._ivalue; - v4 = get_pieces_str(plr[v2].HoldItem._ivalue); - sprintf(infostr, "%i gold %s", v3, v4); - } - else if ( plr[v2].HoldItem._iStatFlag ) - { - if ( plr[v2].HoldItem._iIdentified ) - v5 = plr[v2].HoldItem._iIName; - else - v5 = plr[v2].HoldItem._iName; - strcpy(infostr, v5); - if ( plr[myplr].HoldItem._iMagical == ITEM_QUALITY_MAGIC ) - infoclr = COL_BLUE; - if ( plr[myplr].HoldItem._iMagical == ITEM_QUALITY_UNIQUE ) - infoclr = COL_GOLD; - } - else - { - ClearPanel(); - AddPanelString("Requirements not met", 1); - pinfoflag = 1; - } - } + int v0; // ecx + int v1; // eax + int v2; // eax + int v3; // esi + char *v4; // eax + const char *v5; // eax + signed int v7; // edi + signed int v8; // ebp + int v9; // esi + char *v10; // ebx + + DrawPanelBox(177, 62, 288, 60, 241, 558); + v0 = trigflag[3]; + v1 = spselflag; + if (!panelflag && !trigflag[3] && pcursinvitem == -1) { + if (spselflag) { + LABEL_32: + infoclr = COL_WHITE; + goto LABEL_33; + } + infostr[0] = 0; + infoclr = COL_WHITE; + ClearPanel(); + } + if (v1 || v0) + goto LABEL_32; + if (pcurs < CURSOR_FIRSTITEM) { + if (pcursitem != -1) + GetItemStr(pcursitem); + if (pcursobj != -1) + GetObjectStr(pcursobj); + if (pcursmonst != -1) { + if (leveltype != DTYPE_TOWN) { + infoclr = COL_WHITE; + strcpy(infostr, monster[pcursmonst].mName); + ClearPanel(); + if (monster[pcursmonst]._uniqtype) { + infoclr = COL_GOLD; + PrintUniqueHistory(); + } else { + PrintMonstHistory(monster[pcursmonst].MType->mtype); + } + } else { + strcpy(infostr, towner[pcursmonst]._tName); + } + } + if (pcursplr != -1) { + infoclr = COL_GOLD; + strcpy(infostr, plr[pcursplr]._pName); + ClearPanel(); + sprintf(tempstr, "Level : %i", plr[pcursplr]._pLevel); + AddPanelString(tempstr, 1); + sprintf(tempstr, "Hit Points %i of %i", plr[pcursplr]._pHitPoints >> 6, plr[pcursplr]._pMaxHP >> 6); + AddPanelString(tempstr, 1); + } + } else { + v2 = myplr; + if (plr[myplr].HoldItem._itype == ITYPE_GOLD) { + v3 = plr[v2].HoldItem._ivalue; + v4 = get_pieces_str(plr[v2].HoldItem._ivalue); + sprintf(infostr, "%i gold %s", v3, v4); + } else if (plr[v2].HoldItem._iStatFlag) { + if (plr[v2].HoldItem._iIdentified) + v5 = plr[v2].HoldItem._iIName; + else + v5 = plr[v2].HoldItem._iName; + strcpy(infostr, v5); + if (plr[myplr].HoldItem._iMagical == ITEM_QUALITY_MAGIC) + infoclr = COL_BLUE; + if (plr[myplr].HoldItem._iMagical == ITEM_QUALITY_UNIQUE) + infoclr = COL_GOLD; + } else { + ClearPanel(); + AddPanelString("Requirements not met", 1); + pinfoflag = 1; + } + } LABEL_33: - if ( (infostr[0] || pnumlines) && !talkflag ) - { - v7 = 0; - v8 = 1; - if ( infostr[0] ) - { - control_print_info_str(0, infostr, 1, pnumlines); - v7 = 1; - v8 = 0; - } - v9 = 0; - if ( pnumlines > 0 ) - { - v10 = panelstr; - do - { - control_print_info_str(v9 + v7, v10, pstrjust[v9], pnumlines - v8); - ++v9; - v10 += 64; - } - while ( v9 < pnumlines ); - } - } + if ((infostr[0] || pnumlines) && !talkflag) { + v7 = 0; + v8 = 1; + if (infostr[0]) { + control_print_info_str(0, infostr, 1, pnumlines); + v7 = 1; + v8 = 0; + } + v9 = 0; + if (pnumlines > 0) { + v10 = panelstr; + do { + control_print_info_str(v9 + v7, v10, pstrjust[v9], pnumlines - v8); + ++v9; + v10 += 64; + } while (v9 < pnumlines); + } + } } // 4B8824: using guessed type int pinfoflag; // 4B883C: using guessed type int infoclr; @@ -1789,1299 +1624,1174 @@ LABEL_33: void __fastcall control_print_info_str(int y, char *str, bool center, int lines) { - int v4; // edi - char *v5; // ebx - unsigned char v6; // cl - signed int v7; // eax - char *v8; // esi - int v9; // eax - unsigned char v10; // esi - unsigned char v11; // al - int width; // [esp+18h] [ebp+Ch] - - v4 = 0; - v5 = str; - width = lineoffset[y + 4 * lines + lines]; - if ( center == 1 ) - { - v6 = *str; - v7 = 0; - v8 = str; - if ( !*str ) - goto LABEL_14; - do - { - ++v8; - v7 += fontkern[fontframe[fontidx[v6]]] + 2; - v6 = *v8; - } - while ( *v8 ); - if ( v7 < 288 ) -LABEL_14: - v4 = (288 - v7) >> 1; - width += v4; - } - while ( 1 ) - { - v11 = *v5; - if ( !*v5 ) - break; - ++v5; - v9 = fontidx[v11]; - _LOBYTE(v9) = fontframe[v9]; - v10 = (unsigned char)v9; - v4 += fontkern[(unsigned char)v9] + 2; - if ( (_BYTE)v9 ) - { - if ( v4 < 288 ) - { - CPrintString(width, v10, infoclr); - } - } - width += fontkern[v10] + 2; - } + int v4; // edi + char *v5; // ebx + unsigned char v6; // cl + signed int v7; // eax + char *v8; // esi + int v9; // eax + unsigned char v10; // esi + unsigned char v11; // al + int width; // [esp+18h] [ebp+Ch] + + v4 = 0; + v5 = str; + width = lineoffset[y + 4 * lines + lines]; + if (center == 1) { + v6 = *str; + v7 = 0; + v8 = str; + if (!*str) + goto LABEL_14; + do { + ++v8; + v7 += fontkern[fontframe[fontidx[v6]]] + 2; + v6 = *v8; + } while (*v8); + if (v7 < 288) + LABEL_14: + v4 = (288 - v7) >> 1; + width += v4; + } + while (1) { + v11 = *v5; + if (!*v5) + break; + ++v5; + v9 = fontidx[v11]; + _LOBYTE(v9) = fontframe[v9]; + v10 = (unsigned char)v9; + v4 += fontkern[(unsigned char)v9] + 2; + if ((_BYTE)v9) { + if (v4 < 288) { + CPrintString(width, v10, infoclr); + } + } + width += fontkern[v10] + 2; + } } // 4B883C: using guessed type int infoclr; void __fastcall PrintGameStr(int x, int y, char *str, int color) { - char *v4; // edi - int v5; // esi - unsigned char i; // al - unsigned char v7; // bl + char *v4; // edi + int v5; // esi + unsigned char i; // al + unsigned char v7; // bl - v4 = str; - v5 = screen_y_times_768[y + 160] + x + 64; - for ( i = *str; *v4; i = *v4 ) - { - ++v4; - v7 = fontframe[fontidx[i]]; - if ( v7 ) - CPrintString(v5, v7, color); - v5 += fontkern[v7] + 1; - } + v4 = str; + v5 = screen_y_times_768[y + 160] + x + 64; + for (i = *str; *v4; i = *v4) { + ++v4; + v7 = fontframe[fontidx[i]]; + if (v7) + CPrintString(v5, v7, color); + v5 += fontkern[v7] + 1; + } } void __cdecl DrawChr() { - int v1; // ecx - int v2; // ecx - int v3; // eax - int v4; // eax - bool v5; // zf - int v6; // eax - int v7; // edi - int v8; // edi - char v9; // al - char v10; // al - char v11; // al - int v12; // ecx - int v13; // eax - int v14; // ecx - int v15; // eax - int v16; // ecx - int v17; // eax - int v18; // ecx - int v19; // eax - int *v20; // edi - int v21; // edi - int v22; // edi - int v23; // ecx - int v24; // eax - int v25; // ecx - int v26; // ecx - char a4[64]; // [esp+Ch] [ebp-50h] - int v28; // [esp+4Ch] [ebp-10h] - int v29; // [esp+50h] [ebp-Ch] - int v30; // [esp+54h] [ebp-8h] - char a5[4]; // [esp+58h] [ebp-4h] - - CelDecodeOnly(64, 511, pChrPanel, 1, 320); - ADD_PlrStringXY(20, 32, 151, plr[myplr]._pName, 0); - if ( plr[myplr]._pClass == PC_WARRIOR ) { - ADD_PlrStringXY(168, 32, 299, "Warrior", 0); - } else if ( plr[myplr]._pClass == PC_ROGUE ) { - ADD_PlrStringXY(168, 32, 299, "Rogue", 0); /* should use ClassStrTbl ? */ - } else if ( plr[myplr]._pClass == PC_SORCERER ) { - ADD_PlrStringXY(168, 32, 299, "Sorceror", 0); - } - sprintf(a4, "%i", plr[myplr]._pLevel); - ADD_PlrStringXY(66, 69, 109, a4, 0); - sprintf(a4, "%li", plr[myplr]._pExperience); - ADD_PlrStringXY(216, 69, 300, a4, 0); - if ( plr[myplr]._pLevel == 50 ) - { - strcpy(a4, "None"); - a5[0] = 3; - } - else - { - sprintf(a4, "%li", plr[myplr]._pNextExper); - a5[0] = 0; - } - ADD_PlrStringXY(216, 97, 300, a4, a5[0]); - sprintf(a4, "%i", plr[myplr]._pGold); - ADD_PlrStringXY(216, 146, 300, a4, 0); - a5[0] = 0; - v29 = plr[myplr]._pIBonusAC; - if ( v29 > 0 ) - a5[0] = 1; - if ( v29 < 0 ) - a5[0] = 2; - sprintf(a4, "%i", v29 + plr[myplr]._pIAC + plr[myplr]._pDexterity / 5); - ADD_PlrStringXY(258, 183, 301, a4, a5[0]); - a5[0] = 0; - v1 = plr[myplr]._pIBonusToHit; - if ( v1 > 0 ) - a5[0] = 1; - if ( v1 < 0 ) - a5[0] = 2; - sprintf(a4, "%i%%", (plr[myplr]._pDexterity >> 1) + v1 + 50); - ADD_PlrStringXY(258, 211, 301, a4, a5[0]); - a5[0] = 0; - v2 = myplr; - v3 = plr[myplr]._pIBonusDam; - if ( v3 > 0 ) - a5[0] = 1; - if ( v3 < 0 ) - a5[0] = 2; - v30 = plr[v2]._pIMinDam; - v30 += plr[v2]._pIBonusDamMod + v30 * v3 / 100; - v4 = plr[v2]._pDamageMod; - v5 = plr[v2].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_BOW; - v29 = plr[v2]._pDamageMod; - if ( v5 && plr[v2]._pClass != PC_ROGUE ) - v4 >>= 1; - v30 += v4; - v6 = plr[v2]._pIBonusDam; - v28 = plr[v2]._pIMaxDam; - v7 = plr[v2]._pIBonusDamMod + v28 * v6 / 100 + v28; - if ( plr[v2].InvBody[INVLOC_HAND_LEFT]._itype != ITYPE_BOW || plr[v2]._pClass == PC_ROGUE ) - v8 = v29 + v7; - else - v8 = (v29 >> 1) + v7; - sprintf(a4, "%i-%i", v30, v8); - if ( v30 >= 100 || v8 >= 100 ) - MY_PlrStringXY(254, 239, 305, a4, a5[0], -1); - else - MY_PlrStringXY(258, 239, 301, a4, a5[0], 0); - v9 = plr[myplr]._pMagResist; - a5[0] = v9 != 0; - if ( v9 < 75 ) - { - sprintf(a4, "%i%%", v9); - } - else - { - a5[0] = 3; - sprintf(a4, "MAX"); - } - ADD_PlrStringXY(257, 276, 300, a4, a5[0]); - v10 = plr[myplr]._pFireResist; - a5[0] = v10 != 0; - if ( v10 < 75 ) - { - sprintf(a4, "%i%%", v10); - } - else - { - a5[0] = 3; - sprintf(a4, "MAX"); - } - ADD_PlrStringXY(257, 304, 300, a4, a5[0]); - v11 = plr[myplr]._pLghtResist; - a5[0] = v11 != 0; - if ( v11 < 75 ) - { - sprintf(a4, "%i%%", v11); - } - else - { - a5[0] = 3; - sprintf(a4, "MAX"); - } - ADD_PlrStringXY(257, 332, 300, a4, a5[0]); - a5[0] = 0; - sprintf(a4, "%i", plr[myplr]._pBaseStr); - if ( MaxStats[plr[myplr]._pClass][ATTRIB_STR] == plr[myplr]._pBaseStr ) - a5[0] = 3; - ADD_PlrStringXY(95, 155, 126, a4, a5[0]); - a5[0] = 0; - sprintf(a4, "%i", plr[myplr]._pBaseMag); - if ( MaxStats[plr[myplr]._pClass][ATTRIB_MAG] == plr[myplr]._pBaseMag ) - a5[0] = 3; - ADD_PlrStringXY(95, 183, 126, a4, a5[0]); - a5[0] = 0; - sprintf(a4, "%i", plr[myplr]._pBaseDex); - if ( MaxStats[plr[myplr]._pClass][ATTRIB_DEX] == plr[myplr]._pBaseDex ) - a5[0] = 3; - ADD_PlrStringXY(95, 211, 126, a4, a5[0]); - a5[0] = 0; - sprintf(a4, "%i", plr[myplr]._pBaseVit); - if ( MaxStats[plr[myplr]._pClass][ATTRIB_VIT] == plr[myplr]._pBaseVit ) - a5[0] = 3; - ADD_PlrStringXY(95, 239, 126, a4, a5[0]); - a5[0] = 0; - v12 = plr[myplr]._pStrength; - v13 = plr[myplr]._pBaseStr; - if ( v12 > v13 ) - a5[0] = 1; - if ( v12 < v13 ) - a5[0] = 2; - sprintf(a4, "%i", v12); - ADD_PlrStringXY(143, 155, 173, a4, a5[0]); - a5[0] = 0; - v14 = plr[myplr]._pMagic; - v15 = plr[myplr]._pBaseMag; - if ( v14 > v15 ) - a5[0] = 1; - if ( v14 < v15 ) - a5[0] = 2; - sprintf(a4, "%i", v14); - ADD_PlrStringXY(143, 183, 173, a4, a5[0]); - a5[0] = 0; - v16 = plr[myplr]._pDexterity; - v17 = plr[myplr]._pBaseDex; - if ( v16 > v17 ) - a5[0] = 1; - if ( v16 < v17 ) - a5[0] = 2; - sprintf(a4, "%i", v16); - ADD_PlrStringXY(143, 211, 173, a4, a5[0]); - a5[0] = 0; - v18 = plr[myplr]._pVitality; - v19 = plr[myplr]._pBaseVit; - if ( v18 > v19 ) - a5[0] = 1; - if ( v18 < v19 ) - a5[0] = 2; - sprintf(a4, "%i", v18); - ADD_PlrStringXY(143, 239, 173, a4, a5[0]); - v20 = &plr[myplr]._pStatPts; - if ( *v20 > 0 ) - { - v20 = &plr[myplr]._pStatPts; - if ( CalcStatDiff(myplr) < *v20 ) - { - v20 = &plr[myplr]._pStatPts; - *v20 = CalcStatDiff(myplr); - } - } - v21 = *v20; - if ( v21 > 0 ) - { - sprintf(a4, "%i", v21); - ADD_PlrStringXY(95, 266, 126, a4, 2); - v22 = plr[myplr]._pClass; - if ( plr[myplr]._pBaseStr < MaxStats[v22][ATTRIB_STR] ) - CelDecodeOnly(201, 319, pChrButtons, chrbtn[0] + 2, 41); - if ( plr[myplr]._pBaseMag < MaxStats[v22][ATTRIB_MAG] ) - CelDecodeOnly(201, 347, pChrButtons, chrbtn[1] + 4, 41); - if ( plr[myplr]._pBaseDex < MaxStats[v22][ATTRIB_DEX] ) - CelDecodeOnly(201, 376, pChrButtons, chrbtn[2] + 6, 41); - if ( plr[myplr]._pBaseVit < MaxStats[v22][ATTRIB_VIT] ) - CelDecodeOnly(201, 404, pChrButtons, chrbtn[3] + 8, 41); - } - v23 = plr[myplr]._pMaxHP; - a5[0] = v23 > plr[myplr]._pMaxHPBase; - sprintf(a4, "%i", v23 >> 6); - ADD_PlrStringXY(95, 304, 126, a4, a5[0]); - v24 = plr[myplr]._pHitPoints; - if ( v24 != plr[myplr]._pMaxHP ) - a5[0] = 2; - sprintf(a4, "%i", v24 >> 6); - ADD_PlrStringXY(143, 304, 174, a4, a5[0]); - v25 = plr[myplr]._pMaxMana; - a5[0] = v25 > plr[myplr]._pMaxManaBase; - sprintf(a4, "%i", v25 >> 6); - ADD_PlrStringXY(95, 332, 126, a4, a5[0]); - v26 = plr[myplr]._pMana; - if ( v26 != plr[myplr]._pMaxMana ) - a5[0] = 2; - sprintf(a4, "%i", v26 >> 6); - ADD_PlrStringXY(143, 332, 174, a4, a5[0]); + int v1; // ecx + int v2; // ecx + int v3; // eax + int v4; // eax + bool v5; // zf + int v6; // eax + int v7; // edi + int v8; // edi + char v9; // al + char v10; // al + char v11; // al + int v12; // ecx + int v13; // eax + int v14; // ecx + int v15; // eax + int v16; // ecx + int v17; // eax + int v18; // ecx + int v19; // eax + int *v20; // edi + int v21; // edi + int v22; // edi + int v23; // ecx + int v24; // eax + int v25; // ecx + int v26; // ecx + char a4[64]; // [esp+Ch] [ebp-50h] + int v28; // [esp+4Ch] [ebp-10h] + int v29; // [esp+50h] [ebp-Ch] + int v30; // [esp+54h] [ebp-8h] + char a5[4]; // [esp+58h] [ebp-4h] + + CelDecodeOnly(64, 511, pChrPanel, 1, 320); + ADD_PlrStringXY(20, 32, 151, plr[myplr]._pName, 0); + if (plr[myplr]._pClass == PC_WARRIOR) { + ADD_PlrStringXY(168, 32, 299, "Warrior", 0); + } else if (plr[myplr]._pClass == PC_ROGUE) { + ADD_PlrStringXY(168, 32, 299, "Rogue", 0); /* should use ClassStrTbl ? */ + } else if (plr[myplr]._pClass == PC_SORCERER) { + ADD_PlrStringXY(168, 32, 299, "Sorceror", 0); + } + sprintf(a4, "%i", plr[myplr]._pLevel); + ADD_PlrStringXY(66, 69, 109, a4, 0); + sprintf(a4, "%li", plr[myplr]._pExperience); + ADD_PlrStringXY(216, 69, 300, a4, 0); + if (plr[myplr]._pLevel == 50) { + strcpy(a4, "None"); + a5[0] = 3; + } else { + sprintf(a4, "%li", plr[myplr]._pNextExper); + a5[0] = 0; + } + ADD_PlrStringXY(216, 97, 300, a4, a5[0]); + sprintf(a4, "%i", plr[myplr]._pGold); + ADD_PlrStringXY(216, 146, 300, a4, 0); + a5[0] = 0; + v29 = plr[myplr]._pIBonusAC; + if (v29 > 0) + a5[0] = 1; + if (v29 < 0) + a5[0] = 2; + sprintf(a4, "%i", v29 + plr[myplr]._pIAC + plr[myplr]._pDexterity / 5); + ADD_PlrStringXY(258, 183, 301, a4, a5[0]); + a5[0] = 0; + v1 = plr[myplr]._pIBonusToHit; + if (v1 > 0) + a5[0] = 1; + if (v1 < 0) + a5[0] = 2; + sprintf(a4, "%i%%", (plr[myplr]._pDexterity >> 1) + v1 + 50); + ADD_PlrStringXY(258, 211, 301, a4, a5[0]); + a5[0] = 0; + v2 = myplr; + v3 = plr[myplr]._pIBonusDam; + if (v3 > 0) + a5[0] = 1; + if (v3 < 0) + a5[0] = 2; + v30 = plr[v2]._pIMinDam; + v30 += plr[v2]._pIBonusDamMod + v30 * v3 / 100; + v4 = plr[v2]._pDamageMod; + v5 = plr[v2].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_BOW; + v29 = plr[v2]._pDamageMod; + if (v5 && plr[v2]._pClass != PC_ROGUE) + v4 >>= 1; + v30 += v4; + v6 = plr[v2]._pIBonusDam; + v28 = plr[v2]._pIMaxDam; + v7 = plr[v2]._pIBonusDamMod + v28 * v6 / 100 + v28; + if (plr[v2].InvBody[INVLOC_HAND_LEFT]._itype != ITYPE_BOW || plr[v2]._pClass == PC_ROGUE) + v8 = v29 + v7; + else + v8 = (v29 >> 1) + v7; + sprintf(a4, "%i-%i", v30, v8); + if (v30 >= 100 || v8 >= 100) + MY_PlrStringXY(254, 239, 305, a4, a5[0], -1); + else + MY_PlrStringXY(258, 239, 301, a4, a5[0], 0); + v9 = plr[myplr]._pMagResist; + a5[0] = v9 != 0; + if (v9 < 75) { + sprintf(a4, "%i%%", v9); + } else { + a5[0] = 3; + sprintf(a4, "MAX"); + } + ADD_PlrStringXY(257, 276, 300, a4, a5[0]); + v10 = plr[myplr]._pFireResist; + a5[0] = v10 != 0; + if (v10 < 75) { + sprintf(a4, "%i%%", v10); + } else { + a5[0] = 3; + sprintf(a4, "MAX"); + } + ADD_PlrStringXY(257, 304, 300, a4, a5[0]); + v11 = plr[myplr]._pLghtResist; + a5[0] = v11 != 0; + if (v11 < 75) { + sprintf(a4, "%i%%", v11); + } else { + a5[0] = 3; + sprintf(a4, "MAX"); + } + ADD_PlrStringXY(257, 332, 300, a4, a5[0]); + a5[0] = 0; + sprintf(a4, "%i", plr[myplr]._pBaseStr); + if (MaxStats[plr[myplr]._pClass][ATTRIB_STR] == plr[myplr]._pBaseStr) + a5[0] = 3; + ADD_PlrStringXY(95, 155, 126, a4, a5[0]); + a5[0] = 0; + sprintf(a4, "%i", plr[myplr]._pBaseMag); + if (MaxStats[plr[myplr]._pClass][ATTRIB_MAG] == plr[myplr]._pBaseMag) + a5[0] = 3; + ADD_PlrStringXY(95, 183, 126, a4, a5[0]); + a5[0] = 0; + sprintf(a4, "%i", plr[myplr]._pBaseDex); + if (MaxStats[plr[myplr]._pClass][ATTRIB_DEX] == plr[myplr]._pBaseDex) + a5[0] = 3; + ADD_PlrStringXY(95, 211, 126, a4, a5[0]); + a5[0] = 0; + sprintf(a4, "%i", plr[myplr]._pBaseVit); + if (MaxStats[plr[myplr]._pClass][ATTRIB_VIT] == plr[myplr]._pBaseVit) + a5[0] = 3; + ADD_PlrStringXY(95, 239, 126, a4, a5[0]); + a5[0] = 0; + v12 = plr[myplr]._pStrength; + v13 = plr[myplr]._pBaseStr; + if (v12 > v13) + a5[0] = 1; + if (v12 < v13) + a5[0] = 2; + sprintf(a4, "%i", v12); + ADD_PlrStringXY(143, 155, 173, a4, a5[0]); + a5[0] = 0; + v14 = plr[myplr]._pMagic; + v15 = plr[myplr]._pBaseMag; + if (v14 > v15) + a5[0] = 1; + if (v14 < v15) + a5[0] = 2; + sprintf(a4, "%i", v14); + ADD_PlrStringXY(143, 183, 173, a4, a5[0]); + a5[0] = 0; + v16 = plr[myplr]._pDexterity; + v17 = plr[myplr]._pBaseDex; + if (v16 > v17) + a5[0] = 1; + if (v16 < v17) + a5[0] = 2; + sprintf(a4, "%i", v16); + ADD_PlrStringXY(143, 211, 173, a4, a5[0]); + a5[0] = 0; + v18 = plr[myplr]._pVitality; + v19 = plr[myplr]._pBaseVit; + if (v18 > v19) + a5[0] = 1; + if (v18 < v19) + a5[0] = 2; + sprintf(a4, "%i", v18); + ADD_PlrStringXY(143, 239, 173, a4, a5[0]); + v20 = &plr[myplr]._pStatPts; + if (*v20 > 0) { + v20 = &plr[myplr]._pStatPts; + if (CalcStatDiff(myplr) < *v20) { + v20 = &plr[myplr]._pStatPts; + *v20 = CalcStatDiff(myplr); + } + } + v21 = *v20; + if (v21 > 0) { + sprintf(a4, "%i", v21); + ADD_PlrStringXY(95, 266, 126, a4, 2); + v22 = plr[myplr]._pClass; + if (plr[myplr]._pBaseStr < MaxStats[v22][ATTRIB_STR]) + CelDecodeOnly(201, 319, pChrButtons, chrbtn[0] + 2, 41); + if (plr[myplr]._pBaseMag < MaxStats[v22][ATTRIB_MAG]) + CelDecodeOnly(201, 347, pChrButtons, chrbtn[1] + 4, 41); + if (plr[myplr]._pBaseDex < MaxStats[v22][ATTRIB_DEX]) + CelDecodeOnly(201, 376, pChrButtons, chrbtn[2] + 6, 41); + if (plr[myplr]._pBaseVit < MaxStats[v22][ATTRIB_VIT]) + CelDecodeOnly(201, 404, pChrButtons, chrbtn[3] + 8, 41); + } + v23 = plr[myplr]._pMaxHP; + a5[0] = v23 > plr[myplr]._pMaxHPBase; + sprintf(a4, "%i", v23 >> 6); + ADD_PlrStringXY(95, 304, 126, a4, a5[0]); + v24 = plr[myplr]._pHitPoints; + if (v24 != plr[myplr]._pMaxHP) + a5[0] = 2; + sprintf(a4, "%i", v24 >> 6); + ADD_PlrStringXY(143, 304, 174, a4, a5[0]); + v25 = plr[myplr]._pMaxMana; + a5[0] = v25 > plr[myplr]._pMaxManaBase; + sprintf(a4, "%i", v25 >> 6); + ADD_PlrStringXY(95, 332, 126, a4, a5[0]); + v26 = plr[myplr]._pMana; + if (v26 != plr[myplr]._pMaxMana) + a5[0] = 2; + sprintf(a4, "%i", v26 >> 6); + ADD_PlrStringXY(143, 332, 174, a4, a5[0]); } void __fastcall ADD_PlrStringXY(int x, int y, int width, char *pszStr, char col) { - int v5; // eax - char *v6; // edx - unsigned char v7; // al - int v8; // esi - int v9; // edi - int v10; // ecx - unsigned char v11; // bl - unsigned char v12; // al - int v13; // ebx - int widtha; // [esp+Ch] [ebp-4h] - int widthb; // [esp+Ch] [ebp-4h] - - v5 = screen_y_times_768[y + 160]; - v6 = pszStr; - widtha = v5 + x + 64; - v7 = *pszStr; - v8 = width - x + 1; - v9 = 0; - v10 = 0; - if ( *pszStr ) - { - v11 = *pszStr; - do - { - ++v6; - v10 += fontkern[fontframe[fontidx[v11]]] + 1; - v11 = *v6; - } - while ( *v6 ); - } - if ( v10 < v8 ) - v9 = (v8 - v10) >> 1; - widthb = v9 + widtha; - while ( v7 ) - { - ++pszStr; - v12 = fontframe[fontidx[v7]]; - v13 = v12; - v9 += fontkern[v12] + 1; - if ( v12 ) - { - if ( v9 < v8 ) - CPrintString(widthb, v12, col); - } - widthb += fontkern[v13] + 1; - v7 = *pszStr; - } + int v5; // eax + char *v6; // edx + unsigned char v7; // al + int v8; // esi + int v9; // edi + int v10; // ecx + unsigned char v11; // bl + unsigned char v12; // al + int v13; // ebx + int widtha; // [esp+Ch] [ebp-4h] + int widthb; // [esp+Ch] [ebp-4h] + + v5 = screen_y_times_768[y + 160]; + v6 = pszStr; + widtha = v5 + x + 64; + v7 = *pszStr; + v8 = width - x + 1; + v9 = 0; + v10 = 0; + if (*pszStr) { + v11 = *pszStr; + do { + ++v6; + v10 += fontkern[fontframe[fontidx[v11]]] + 1; + v11 = *v6; + } while (*v6); + } + if (v10 < v8) + v9 = (v8 - v10) >> 1; + widthb = v9 + widtha; + while (v7) { + ++pszStr; + v12 = fontframe[fontidx[v7]]; + v13 = v12; + v9 += fontkern[v12] + 1; + if (v12) { + if (v9 < v8) + CPrintString(widthb, v12, col); + } + widthb += fontkern[v13] + 1; + v7 = *pszStr; + } } void __fastcall MY_PlrStringXY(int x, int y, int width, char *pszStr, char col, int base) { - char *v6; // ebx - unsigned char v7; // al - int v8; // edx - int v9; // esi - char *v10; // edi - unsigned char v11; // cl - unsigned char v12; // al - int v13; // edi - int widtha; // [esp+Ch] [ebp-4h] - int widthb; // [esp+Ch] [ebp-4h] - int v16; // [esp+18h] [ebp+8h] - - v6 = pszStr; - widtha = screen_y_times_768[y + 160] + x + 64; - v7 = *pszStr; - v8 = 0; - v9 = width - x + 1; - v16 = 0; - v10 = pszStr; - if ( *pszStr ) - { - v11 = *pszStr; - do - { - ++v10; - v8 += base + fontkern[fontframe[fontidx[v11]]]; - v11 = *v10; - } - while ( *v10 ); - } - if ( v8 < v9 ) - v16 = (v9 - v8) >> 1; - widthb = v16 + widtha; - while ( v7 ) - { - ++v6; - v12 = fontframe[fontidx[v7]]; - v13 = v12; - v16 += base + fontkern[v12]; - if ( v12 ) - { - if ( v16 < v9 ) - CPrintString(widthb, v12, col); - } - widthb += base + fontkern[v13]; - v7 = *v6; - } + char *v6; // ebx + unsigned char v7; // al + int v8; // edx + int v9; // esi + char *v10; // edi + unsigned char v11; // cl + unsigned char v12; // al + int v13; // edi + int widtha; // [esp+Ch] [ebp-4h] + int widthb; // [esp+Ch] [ebp-4h] + int v16; // [esp+18h] [ebp+8h] + + v6 = pszStr; + widtha = screen_y_times_768[y + 160] + x + 64; + v7 = *pszStr; + v8 = 0; + v9 = width - x + 1; + v16 = 0; + v10 = pszStr; + if (*pszStr) { + v11 = *pszStr; + do { + ++v10; + v8 += base + fontkern[fontframe[fontidx[v11]]]; + v11 = *v10; + } while (*v10); + } + if (v8 < v9) + v16 = (v9 - v8) >> 1; + widthb = v16 + widtha; + while (v7) { + ++v6; + v12 = fontframe[fontidx[v7]]; + v13 = v12; + v16 += base + fontkern[v12]; + if (v12) { + if (v16 < v9) + CPrintString(widthb, v12, col); + } + widthb += base + fontkern[v13]; + v7 = *v6; + } } void __cdecl CheckLvlBtn() { - if ( !lvlbtndown && MouseX >= 40 && MouseX <= 81 && MouseY >= 313 && MouseY <= 335 ) - lvlbtndown = 1; + if (!lvlbtndown && MouseX >= 40 && MouseX <= 81 && MouseY >= 313 && MouseY <= 335) + lvlbtndown = 1; } // 4B851C: using guessed type int lvlbtndown; void __cdecl ReleaseLvlBtn() { - if ( MouseX >= 40 && MouseX <= 81 && MouseY >= 313 && MouseY <= 335 ) - chrflag = 1; - lvlbtndown = 0; + if (MouseX >= 40 && MouseX <= 81 && MouseY >= 313 && MouseY <= 335) + chrflag = 1; + lvlbtndown = 0; } // 4B851C: using guessed type int lvlbtndown; void __cdecl DrawLevelUpIcon() { - int v0; // esi + int v0; // esi - if ( !stextflag ) - { - v0 = (lvlbtndown != 0) + 2; - ADD_PlrStringXY(0, 303, 120, "Level Up", 0); - CelDecodeOnly(104, 495, pChrButtons, v0, 41); - } + if (!stextflag) { + v0 = (lvlbtndown != 0) + 2; + ADD_PlrStringXY(0, 303, 120, "Level Up", 0); + CelDecodeOnly(104, 495, pChrButtons, v0, 41); + } } // 4B851C: using guessed type int lvlbtndown; // 6AA705: using guessed type char stextflag; void __cdecl CheckChrBtns() { - int v0; // esi - int v1; // ecx - int v2; // ebx - int v3; // edi - int v4; // edx - bool v5; // sf - unsigned char v6; // of - int v7; // edx - int v8; // edx - int v9; // edx - int v10; // eax - int v11; // edx - int v12; // edx - - 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; - } - v7 = plr[v1]._pBaseDex; - v6 = __OFSUB__(v7, MaxStats[v3][ATTRIB_DEX]); - v5 = v7 - MaxStats[v3][ATTRIB_DEX] < 0; - goto LABEL_12; - } - } + int v0; // esi + int v1; // ecx + int v2; // ebx + int v3; // edi + int v4; // edx + bool v5; // sf + unsigned char v6; // of + int v7; // edx + int v8; // edx + int v9; // edx + int v10; // eax + int v11; // edx + int v12; // edx + + 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; + } + 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() { - signed int v0; // esi - int *v1; // eax - signed int v2; // eax - int v3; // ecx - int v4; // ecx - unsigned char v5; // dl - - chrbtnactive = 0; - 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); - --plr[myplr]._pStatPts; - } - } - } -LABEL_16: - ++v0; - } - while ( v0 < 4 ); + signed int v0; // esi + int *v1; // eax + signed int v2; // eax + int v3; // ecx + int v4; // ecx + unsigned char v5; // dl + + chrbtnactive = 0; + 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); + --plr[myplr]._pStatPts; + } + } + } + LABEL_16: + ++v0; + } while (v0 < 4); } // 4B87A8: using guessed type int chrbtnactive; void __cdecl DrawDurIcon() { - int v0; // edx - PlayerStruct *v1; // esi - int v2; // eax - int v3; // eax - int v4; // eax - - if ( !chrflag && !questlog || !invflag && !sbookflag ) - { - v0 = 656; - if ( invflag || sbookflag ) - v0 = 336; - v1 = &plr[myplr]; - v2 = DrawDurIcon4Item(v1->InvBody, v0, 4); - v3 = DrawDurIcon4Item(&v1->InvBody[INVLOC_CHEST], v2, 3); - v4 = DrawDurIcon4Item(&v1->InvBody[INVLOC_HAND_LEFT], v3, 0); - DrawDurIcon4Item(&v1->InvBody[INVLOC_HAND_RIGHT], v4, 0); - } + int v0; // edx + PlayerStruct *v1; // esi + int v2; // eax + int v3; // eax + int v4; // eax + + if (!chrflag && !questlog || !invflag && !sbookflag) { + v0 = 656; + if (invflag || sbookflag) + v0 = 336; + v1 = &plr[myplr]; + v2 = DrawDurIcon4Item(v1->InvBody, v0, 4); + v3 = DrawDurIcon4Item(&v1->InvBody[INVLOC_CHEST], v2, 3); + v4 = DrawDurIcon4Item(&v1->InvBody[INVLOC_HAND_LEFT], v3, 0); + DrawDurIcon4Item(&v1->InvBody[INVLOC_HAND_RIGHT], v4, 0); + } } // 4B8968: using guessed type int sbookflag; // 69BD04: using guessed type int questlog; int __fastcall DrawDurIcon4Item(ItemStruct *pItem, int x, int c) { - int v3; // eax - int v4; // edi - int v5; // esi - signed int v7; // edx - int v8; // eax - int v9; // eax - int v10; // eax - int v11; // eax - signed int v12; // [esp-4h] [ebp-Ch] - - v3 = pItem->_itype; - v4 = x; - if ( v3 == -1 ) - return x; - v5 = pItem->_iDurability; - if ( v5 > 5 ) - return x; - v7 = c; - if ( !c ) - { - if ( pItem->_iClass != 1 ) - { - v7 = 1; - goto LABEL_18; - } - v8 = v3 - 1; - if ( !v8 ) - { - v12 = 2; - goto LABEL_15; - } - v9 = v8 - 1; - if ( !v9 ) - { - v12 = 6; - goto LABEL_15; - } - v10 = v9 - 1; - if ( !v10 ) - { - v12 = 7; - goto LABEL_15; - } - v11 = v10 - 1; - if ( !v11 ) - { - v12 = 5; - goto LABEL_15; - } - if ( v11 == 6 ) - { - v12 = 8; -LABEL_15: - v7 = v12; - goto LABEL_18; - } - } + int v3; // eax + int v4; // edi + int v5; // esi + signed int v7; // edx + int v8; // eax + int v9; // eax + int v10; // eax + int v11; // eax + signed int v12; // [esp-4h] [ebp-Ch] + + v3 = pItem->_itype; + v4 = x; + if (v3 == -1) + return x; + v5 = pItem->_iDurability; + if (v5 > 5) + return x; + v7 = c; + if (!c) { + if (pItem->_iClass != 1) { + v7 = 1; + goto LABEL_18; + } + v8 = v3 - 1; + if (!v8) { + v12 = 2; + goto LABEL_15; + } + v9 = v8 - 1; + if (!v9) { + v12 = 6; + goto LABEL_15; + } + v10 = v9 - 1; + if (!v10) { + v12 = 7; + goto LABEL_15; + } + v11 = v10 - 1; + if (!v11) { + v12 = 5; + goto LABEL_15; + } + if (v11 == 6) { + v12 = 8; + LABEL_15: + v7 = v12; + goto LABEL_18; + } + } LABEL_18: - if ( v5 > 2 ) - v7 += 8; - CelDecodeOnly(v4, 495, pDurIcons, v7, 32); - return v4 - 40; + if (v5 > 2) + v7 += 8; + CelDecodeOnly(v4, 495, pDurIcons, v7, 32); + return v4 - 40; } void __cdecl RedBack() { - int v0; // eax - char *v1; // edi - signed int v3; // edx - signed int v4; // ecx - char *v7; // edi - signed int v9; // edx - signed int v10; // ecx - int v12; // [esp+8h] [ebp-4h] - int _EAX; - char *_EBX; - - v0 = -(light4flag != 0); - _LOWORD(v0) = v0 & 0xF400; - v12 = v0 + 768 * 6; - if ( leveltype == DTYPE_HELL ) - { - v7 = gpBuffer->row[0].pixels; - _EBX = &pLightTbl[v12]; - v9 = 352; - do - { - v10 = 640; - do - { - _EAX = *v7; - if ( (unsigned char)*v7 >= 32 ) - ASM_XLAT(_EAX,_EBX); - *v7++ = _EAX; - --v10; - } - while ( v10 ); - v7 += 128; - --v9; - } - while ( v9 ); - } - else - { - v1 = gpBuffer->row[0].pixels; - _EBX = &pLightTbl[v12]; - v3 = 352; - do - { - v4 = 640; - do - { - _EAX = *v1; - ASM_XLAT(_EAX,_EBX); - *v1++ = _EAX; - --v4; - } - while ( v4 ); - v1 += 128; - --v3; - } - while ( v3 ); - } + int v0; // eax + char *v1; // edi + signed int v3; // edx + signed int v4; // ecx + char *v7; // edi + signed int v9; // edx + signed int v10; // ecx + int v12; // [esp+8h] [ebp-4h] + int _EAX; + char *_EBX; + + v0 = -(light4flag != 0); + _LOWORD(v0) = v0 & 0xF400; + v12 = v0 + 768 * 6; + if (leveltype == DTYPE_HELL) { + v7 = gpBuffer->row[0].pixels; + _EBX = &pLightTbl[v12]; + v9 = 352; + do { + v10 = 640; + do { + _EAX = *v7; + if ((unsigned char)*v7 >= 32) + ASM_XLAT(_EAX, _EBX); + *v7++ = _EAX; + --v10; + } while (v10); + v7 += 128; + --v9; + } while (v9); + } else { + v1 = gpBuffer->row[0].pixels; + _EBX = &pLightTbl[v12]; + v3 = 352; + do { + v4 = 640; + do { + _EAX = *v1; + ASM_XLAT(_EAX, _EBX); + *v1++ = _EAX; + --v4; + } while (v4); + v1 += 128; + --v3; + } while (v3); + } } // 525728: using guessed type int light4flag; char __fastcall GetSBookTrans(int ii, BOOL townok) { - char result = RSPLTYPE_SPELL; - if ( (__int64)1 << (ii - 1) & plr[myplr]._pISpells ) - result = RSPLTYPE_CHARGES; - if ( 1 << (ii - 1) & plr[myplr]._pAblSpells ) - result = RSPLTYPE_SKILL; + char result = RSPLTYPE_SPELL; + if ((__int64)1 << (ii - 1) & plr[myplr]._pISpells) + result = RSPLTYPE_CHARGES; + if (1 << (ii - 1) & plr[myplr]._pAblSpells) + result = RSPLTYPE_SKILL; - if ( result == RSPLTYPE_SPELL ) { - if ( !CheckSpell(myplr, ii, RSPLTYPE_SPELL, TRUE) ) - result = RSPLTYPE_INVALID; - if ( (char)(plr[myplr]._pISplLvlAdd + plr[myplr]._pSplLvl[ii]) <= 0 ) - result = RSPLTYPE_INVALID; - } + if (result == RSPLTYPE_SPELL) { + if (!CheckSpell(myplr, ii, RSPLTYPE_SPELL, TRUE)) + result = RSPLTYPE_INVALID; + if ((char)(plr[myplr]._pISplLvlAdd + plr[myplr]._pSplLvl[ii]) <= 0) + result = RSPLTYPE_INVALID; + } - if ( townok && currlevel == 0 && result != RSPLTYPE_INVALID && !spelldata[ii].sTownSpell ) - result = RSPLTYPE_INVALID; + if (townok && currlevel == 0 && result != RSPLTYPE_INVALID && !spelldata[ii].sTownSpell) + result = RSPLTYPE_INVALID; - return result; + return result; } void __cdecl DrawSpellBook() { - __int64 v0; // edi - __int64 v1; // ebp - int v2; // esi - char v3; // al - int v4; // eax - int v5; // ebx - int v6; // ecx - char v7; // [esp+Bh] [ebp-1Dh] - int v8; // [esp+Ch] [ebp-1Ch] - signed int v9; // [esp+10h] [ebp-18h] - int sel; // [esp+14h] [ebp-14h] - int v11; // [esp+18h] [ebp-10h] - int v12; // [esp+1Ch] [ebp-Ch] - - CelDecodeOnly(384, 511, pSpellBkCel, 1, 320); - CelDecodeOnly(76 * sbooktab + 391, 508, pSBkBtnCel, sbooktab + 1, 76); - v9 = 1; - v8 = 214; - v0 = plr[myplr]._pISpells | plr[myplr]._pMemSpells | plr[myplr]._pAblSpells; - do - { - v2 = SpellPages[0][v9 + 7 * sbooktab - 1]; // *(&attribute_inc_rects[3].h + v9 + 7 * sbooktab); /* check */ - v1 = (__int64)1 << (v2 - 1); - if ( v2 != -1 && (v1 & v0) ) - { - v7 = GetSBookTrans(v2, TRUE); - SetSpellTrans(v7); - DrawSpellCel(395, v8 + 1, (char *)pSBkIconCels, (char)SpellITbl[v2], MAX_SPELLS); - if ( v2 == plr[myplr]._pRSpell && v7 == _LOBYTE(plr[myplr]._pRSplType) ) - { - SetSpellTrans(RSPLTYPE_SKILL); - DrawSpellCel(395, v8 + 1, (char *)pSBkIconCels, 43, MAX_SPELLS); - } - PrintSBookStr(10, v8 - 22, 0, spelldata[v2].sNameText, 0); - v3 = GetSBookTrans(v2, FALSE); - if ( v3 != RSPLTYPE_SKILL ) - { - if ( v3 == RSPLTYPE_CHARGES ) - { - sprintf(tempstr, "Staff (%i charges)", plr[myplr].InvBody[INVLOC_HAND_LEFT]._iCharges); - } - else - { - v4 = GetManaAmount(myplr, v2); - v5 = v4 >> 6; - v12 = v4 >> 6; - GetDamageAmt(v2, &sel, &v11); - if ( sel == -1 ) - sprintf(tempstr, "Mana: %i Dam: n/a", v5); - else - sprintf(tempstr, "Mana: %i Dam: %i - %i", v5, sel, v11); - if ( v2 == SPL_BONESPIRIT ) - sprintf(tempstr, "Mana: %i Dam: 1/3 tgt hp", v12); - PrintSBookStr(10, v8, 0, tempstr, 0); - v6 = plr[myplr]._pISplLvlAdd + plr[myplr]._pSplLvl[v2]; - if ( v6 < 0 ) - v6 = 0; - if ( v6 ) - sprintf(tempstr, "Spell Level %i", v6); - else - sprintf(tempstr, "Spell Level 0 - Unusable"); - } - } - else - { - strcpy(tempstr, "Skill"); - } - PrintSBookStr(10, v8 - 11, 0, tempstr, 0); - } - v8 += 43; - ++v9; - } - while ( v9 < 8 ); + __int64 v0; // edi + __int64 v1; // ebp + int v2; // esi + char v3; // al + int v4; // eax + int v5; // ebx + int v6; // ecx + char v7; // [esp+Bh] [ebp-1Dh] + int v8; // [esp+Ch] [ebp-1Ch] + signed int v9; // [esp+10h] [ebp-18h] + int sel; // [esp+14h] [ebp-14h] + int v11; // [esp+18h] [ebp-10h] + int v12; // [esp+1Ch] [ebp-Ch] + + CelDecodeOnly(384, 511, pSpellBkCel, 1, 320); + CelDecodeOnly(76 * sbooktab + 391, 508, pSBkBtnCel, sbooktab + 1, 76); + v9 = 1; + v8 = 214; + v0 = plr[myplr]._pISpells | plr[myplr]._pMemSpells | plr[myplr]._pAblSpells; + do { + v2 = SpellPages[0][v9 + 7 * sbooktab - 1]; // *(&attribute_inc_rects[3].h + v9 + 7 * sbooktab); /* check */ + v1 = (__int64)1 << (v2 - 1); + if (v2 != -1 && (v1 & v0)) { + v7 = GetSBookTrans(v2, TRUE); + SetSpellTrans(v7); + DrawSpellCel(395, v8 + 1, (char *)pSBkIconCels, (char)SpellITbl[v2], MAX_SPELLS); + if (v2 == plr[myplr]._pRSpell && v7 == _LOBYTE(plr[myplr]._pRSplType)) { + SetSpellTrans(RSPLTYPE_SKILL); + DrawSpellCel(395, v8 + 1, (char *)pSBkIconCels, 43, MAX_SPELLS); + } + PrintSBookStr(10, v8 - 22, 0, spelldata[v2].sNameText, 0); + v3 = GetSBookTrans(v2, FALSE); + if (v3 != RSPLTYPE_SKILL) { + if (v3 == RSPLTYPE_CHARGES) { + sprintf(tempstr, "Staff (%i charges)", plr[myplr].InvBody[INVLOC_HAND_LEFT]._iCharges); + } else { + v4 = GetManaAmount(myplr, v2); + v5 = v4 >> 6; + v12 = v4 >> 6; + GetDamageAmt(v2, &sel, &v11); + if (sel == -1) + sprintf(tempstr, "Mana: %i Dam: n/a", v5); + else + sprintf(tempstr, "Mana: %i Dam: %i - %i", v5, sel, v11); + if (v2 == SPL_BONESPIRIT) + sprintf(tempstr, "Mana: %i Dam: 1/3 tgt hp", v12); + PrintSBookStr(10, v8, 0, tempstr, 0); + v6 = plr[myplr]._pISplLvlAdd + plr[myplr]._pSplLvl[v2]; + if (v6 < 0) + v6 = 0; + if (v6) + sprintf(tempstr, "Spell Level %i", v6); + else + sprintf(tempstr, "Spell Level 0 - Unusable"); + } + } else { + strcpy(tempstr, "Skill"); + } + PrintSBookStr(10, v8 - 11, 0, tempstr, 0); + } + v8 += 43; + ++v9; + } while (v9 < 8); } // 4B8950: using guessed type int sbooktab; void __fastcall PrintSBookStr(int x, int y, bool cjustflag, char *pszStr, int bright) { - char *v5; // ebx - signed int v6; // eax - int v7; // edi - unsigned char v8; // cl - char *v9; // esi - unsigned char v10; // al - int v11; // esi - unsigned char v12; // al - int width; // [esp+Ch] [ebp-4h] - - v5 = pszStr; - width = screen_y_times_768[y] + x + 440; - v6 = 0; - v7 = 0; - if ( cjustflag ) - { - v8 = *pszStr; - v9 = pszStr; - if ( !*pszStr ) - goto LABEL_14; - do - { - ++v9; - v6 += fontkern[fontframe[fontidx[v8]]] + 1; - v8 = *v9; - } - while ( *v9 ); - if ( v6 < 222 ) -LABEL_14: - v7 = (222 - v6) >> 1; - width += v7; - } - while ( 1 ) - { - v12 = *v5; - if ( !*v5 ) - break; - ++v5; - v10 = fontframe[fontidx[v12]]; - v11 = v10; - v7 += fontkern[v10] + 1; - if ( v10 ) - { - if ( v7 <= 222 ) - CPrintString(width, v10, bright); - } - width += fontkern[v11] + 1; - } + char *v5; // ebx + signed int v6; // eax + int v7; // edi + unsigned char v8; // cl + char *v9; // esi + unsigned char v10; // al + int v11; // esi + unsigned char v12; // al + int width; // [esp+Ch] [ebp-4h] + + v5 = pszStr; + width = screen_y_times_768[y] + x + 440; + v6 = 0; + v7 = 0; + if (cjustflag) { + v8 = *pszStr; + v9 = pszStr; + if (!*pszStr) + goto LABEL_14; + do { + ++v9; + v6 += fontkern[fontframe[fontidx[v8]]] + 1; + v8 = *v9; + } while (*v9); + if (v6 < 222) + LABEL_14: + v7 = (222 - v6) >> 1; + width += v7; + } + while (1) { + v12 = *v5; + if (!*v5) + break; + ++v5; + v10 = fontframe[fontidx[v12]]; + v11 = v10; + v7 += fontkern[v10] + 1; + if (v10) { + if (v7 <= 222) + CPrintString(width, v10, bright); + } + width += fontkern[v11] + 1; + } } void __cdecl CheckSBook() { - if ( MouseX >= 331 && MouseX < 368 && MouseY >= 18 && MouseY < 314 ) { - int spell = SpellPages[sbooktab][(MouseY - 18) / 43]; - if ( spell != -1 ) { - if ( (__int64)1 << (spell - 1) & (plr[myplr]._pAblSpells | plr[myplr]._pMemSpells | plr[myplr]._pISpells)) { - char splType = RSPLTYPE_SPELL; - if ( (__int64)1 << (spell - 1) & plr[myplr]._pISpells ) - splType = RSPLTYPE_CHARGES; - if ( (__int64)1 << (spell - 1) & plr[myplr]._pAblSpells ) - splType = RSPLTYPE_SKILL; - plr[myplr]._pRSpell = spell; - plr[myplr]._pRSplType = splType; - drawpanflag = 255; - } - } - } - if ( MouseX >= 327 && MouseX < 633 && MouseY >= 320 && MouseY < 349 ) /// BUGFIX: change `< 633` to `< 631` - sbooktab = (MouseX - 327) / 76; + if (MouseX >= 331 && MouseX < 368 && MouseY >= 18 && MouseY < 314) { + int spell = SpellPages[sbooktab][(MouseY - 18) / 43]; + if (spell != -1) { + if ((__int64)1 << (spell - 1) & (plr[myplr]._pAblSpells | plr[myplr]._pMemSpells | plr[myplr]._pISpells)) { + char splType = RSPLTYPE_SPELL; + if ((__int64)1 << (spell - 1) & plr[myplr]._pISpells) + splType = RSPLTYPE_CHARGES; + if ((__int64)1 << (spell - 1) & plr[myplr]._pAblSpells) + splType = RSPLTYPE_SKILL; + plr[myplr]._pRSpell = spell; + plr[myplr]._pRSplType = splType; + drawpanflag = 255; + } + } + } + if (MouseX >= 327 && MouseX < 633 && MouseY >= 320 && MouseY < 349) /// BUGFIX: change `< 633` to `< 631` + sbooktab = (MouseX - 327) / 76; } // 4B8950: using guessed type int sbooktab; // 52571C: using guessed type int drawpanflag; char *__fastcall get_pieces_str(int nGold) { - char *result; // eax + char *result; // eax - result = "piece"; - if ( nGold != 1 ) - result = "pieces"; - return result; + result = "piece"; + if (nGold != 1) + result = "pieces"; + return result; } void __fastcall DrawGoldSplit(int amount) { - int v1; // ebp - char *v2; // eax - char v3; // cl - signed int i; // eax - int screen_x; // [esp+10h] [ebp-4h] - int screen_xa; // [esp+10h] [ebp-4h] - - screen_x = 0; - v1 = amount; - CelDecodeOnly(415, 338, pGBoxBuff, 1, 261); - sprintf(tempstr, "You have %u gold", initialDropGoldValue); - ADD_PlrStringXY(366, 87, 600, tempstr, 3); - v2 = get_pieces_str(initialDropGoldValue); - sprintf(tempstr, "%s. How many do", v2); - ADD_PlrStringXY(366, 103, 600, tempstr, 3); - ADD_PlrStringXY(366, 121, 600, "you want to remove?", 3); - if ( v1 <= 0 ) - { - screen_xa = 450; - } - else - { - sprintf(tempstr, "%u", v1); - PrintGameStr(388, 140, tempstr, 0); - v3 = tempstr[0]; - for ( i = 0; i < v3; v3 = tempstr[i] ) - { - ++i; - screen_x += fontkern[fontframe[fontidx[(unsigned char)v3]]] + 1; - } - screen_xa = screen_x + 452; - } - CelDecodeOnly(screen_xa, 300, pCelBuff, frame_4B8800, 12); - frame_4B8800 = (frame_4B8800 & 7) + 1; + int v1; // ebp + char *v2; // eax + char v3; // cl + signed int i; // eax + int screen_x; // [esp+10h] [ebp-4h] + int screen_xa; // [esp+10h] [ebp-4h] + + screen_x = 0; + v1 = amount; + CelDecodeOnly(415, 338, pGBoxBuff, 1, 261); + sprintf(tempstr, "You have %u gold", initialDropGoldValue); + ADD_PlrStringXY(366, 87, 600, tempstr, 3); + v2 = get_pieces_str(initialDropGoldValue); + sprintf(tempstr, "%s. How many do", v2); + ADD_PlrStringXY(366, 103, 600, tempstr, 3); + ADD_PlrStringXY(366, 121, 600, "you want to remove?", 3); + if (v1 <= 0) { + screen_xa = 450; + } else { + sprintf(tempstr, "%u", v1); + PrintGameStr(388, 140, tempstr, 0); + v3 = tempstr[0]; + for (i = 0; i < v3; v3 = tempstr[i]) { + ++i; + screen_x += fontkern[fontframe[fontidx[(unsigned char)v3]]] + 1; + } + screen_xa = screen_x + 452; + } + CelDecodeOnly(screen_xa, 300, pCelBuff, frame_4B8800, 12); + frame_4B8800 = (frame_4B8800 & 7) + 1; } void __fastcall control_drop_gold(int vkey) { - char v1; // bl - int v2; // eax - int v3; // eax - size_t v4; // esi - char v6[6]; // [esp+8h] [ebp-8h] - - v1 = vkey; - if ( plr[myplr]._pHitPoints >> 6 <= 0 ) - { - dropGoldFlag = 0; - dropGoldValue = 0; - return; - } - memset(v6, 0, sizeof(v6)); - _itoa(dropGoldValue, v6, 10); - if ( v1 != VK_RETURN ) - { - if ( v1 == VK_ESCAPE ) - { - dropGoldFlag = 0; - dropGoldValue = 0; - return; - } - if ( v1 == VK_BACK ) - { - v6[strlen(v6) - 1] = '\0'; - v2 = atoi(v6); - } - else - { - v3 = v1 - '0'; - if ( v3 < 0 || v3 > 9 ) - return; - if ( dropGoldValue || atoi(v6) <= initialDropGoldValue ) - { - v6[strlen(v6)] = v1; - if ( atoi(v6) > initialDropGoldValue ) - return; - v4 = strlen(v6); - if ( v4 > strlen(v6) ) - return; - } - else - { - v6[0] = v1; - } - v2 = atoi(v6); - } - dropGoldValue = v2; - return; - } - if ( dropGoldValue > 0 ) - control_remove_gold(myplr, initialDropGoldIndex); - dropGoldFlag = 0; + char v1; // bl + int v2; // eax + int v3; // eax + size_t v4; // esi + char v6[6]; // [esp+8h] [ebp-8h] + + v1 = vkey; + if (plr[myplr]._pHitPoints >> 6 <= 0) { + dropGoldFlag = 0; + dropGoldValue = 0; + return; + } + memset(v6, 0, sizeof(v6)); + _itoa(dropGoldValue, v6, 10); + if (v1 != VK_RETURN) { + if (v1 == VK_ESCAPE) { + dropGoldFlag = 0; + dropGoldValue = 0; + return; + } + if (v1 == VK_BACK) { + v6[strlen(v6) - 1] = '\0'; + v2 = atoi(v6); + } else { + v3 = v1 - '0'; + if (v3 < 0 || v3 > 9) + return; + if (dropGoldValue || atoi(v6) <= initialDropGoldValue) { + v6[strlen(v6)] = v1; + if (atoi(v6) > initialDropGoldValue) + return; + v4 = strlen(v6); + if (v4 > strlen(v6)) + return; + } else { + v6[0] = v1; + } + v2 = atoi(v6); + } + dropGoldValue = v2; + return; + } + if (dropGoldValue > 0) + control_remove_gold(myplr, initialDropGoldIndex); + dropGoldFlag = 0; } // 4B84DC: using guessed type int dropGoldFlag; // 406C40: using guessed type char var_8[8]; void __fastcall control_remove_gold(int pnum, int gold_index) { - int v2; // edi - int v3; // esi - int v4; // edx - _DWORD *v5; // eax - int v6; // edx - _DWORD *v7; // eax - int v8; // eax - - v2 = pnum; - v3 = pnum; - if ( gold_index > 46 ) - { - v6 = gold_index - 47; - v7 = (unsigned int *)((char *)&plr[v3].SpdList[v6]._ivalue); - *v7 -= dropGoldValue; - if ( *v7 <= 0 ) - RemoveSpdBarItem(pnum, v6); - else - SetSpdbarGoldCurs(pnum, v6); - } - else - { - v4 = gold_index - 7; - v5 = (unsigned int *)((char *)&plr[v3].InvList[v4]._ivalue); - *v5 -= dropGoldValue; - if ( *v5 <= 0 ) - RemoveInvItem(pnum, v4); - else - SetGoldCurs(pnum, v4); - } - SetPlrHandItem(&plr[v3].HoldItem, IDI_GOLD); - GetGoldSeed(v2, &plr[v3].HoldItem); - plr[v3].HoldItem._ivalue = dropGoldValue; - plr[v3].HoldItem._iStatFlag = 1; - control_set_gold_curs(v2); - v8 = CalculateGold(v2); - dropGoldValue = 0; - plr[v3]._pGold = v8; + int v2; // edi + int v3; // esi + int v4; // edx + _DWORD *v5; // eax + int v6; // edx + _DWORD *v7; // eax + int v8; // eax + + v2 = pnum; + v3 = pnum; + if (gold_index > 46) { + v6 = gold_index - 47; + v7 = (unsigned int *)((char *)&plr[v3].SpdList[v6]._ivalue); + *v7 -= dropGoldValue; + if (*v7 <= 0) + RemoveSpdBarItem(pnum, v6); + else + SetSpdbarGoldCurs(pnum, v6); + } else { + v4 = gold_index - 7; + v5 = (unsigned int *)((char *)&plr[v3].InvList[v4]._ivalue); + *v5 -= dropGoldValue; + if (*v5 <= 0) + RemoveInvItem(pnum, v4); + else + SetGoldCurs(pnum, v4); + } + SetPlrHandItem(&plr[v3].HoldItem, IDI_GOLD); + GetGoldSeed(v2, &plr[v3].HoldItem); + plr[v3].HoldItem._ivalue = dropGoldValue; + plr[v3].HoldItem._iStatFlag = 1; + control_set_gold_curs(v2); + v8 = CalculateGold(v2); + dropGoldValue = 0; + plr[v3]._pGold = v8; } void __fastcall control_set_gold_curs(int pnum) { - int v1; // ecx - int v2; // eax - int *v3; // eax - bool v4; // zf - bool 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; - } - else - { - v3 = &plr[v1].HoldItem._iCurs; - plr[v1].HoldItem._iCurs = ICURS_GOLD_LARGE; - } - SetCursor(*v3 + 12); + int v1; // ecx + int v2; // eax + int *v3; // eax + bool v4; // zf + bool 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; + } else { + v3 = &plr[v1].HoldItem._iCurs; + plr[v1].HoldItem._iCurs = ICURS_GOLD_LARGE; + } + SetCursor(*v3 + 12); } void __cdecl DrawTalkPan() { - int v0; // esi - signed int v1; // edi - signed int v2; // esi - char *v3; // eax - int v4; // esi - int v5; // esi - int v6; // ebx - int v7; // eax - int a4; // [esp+4h] [ebp-Ch] - char *a1; // [esp+8h] [ebp-8h] - int v10; // [esp+Ch] [ebp-4h] - - v0 = 0; - if ( talkflag ) - { - DrawPanelBox(175, sgbPlrTalkTbl + 20, 294, 5, 239, 516); - v1 = 293; - do - { - DrawPanelBox((v0 >> 1) + 175, sgbPlrTalkTbl + v0 + 25, v1, 1, (v0 >> 1) + 239, v0 + 521); - ++v0; - --v1; - } - while ( v1 > 283 ); - DrawPanelBox(185, sgbPlrTalkTbl + 35, 274, 30, 249, 531); - DrawPanelBox(180, sgbPlrTalkTbl + 65, 284, 5, 244, 561); - v2 = 0; - do - { - DrawPanelBox(180, sgbPlrTalkTbl + v2 + 70, v2 + 284, 1, 244, v2 + 566); - ++v2; - } - while ( v2 < 10 ); - DrawPanelBox(170, sgbPlrTalkTbl + 80, 310, 55, 234, 576); - v3 = sgszTalkMsg; - v4 = 0; - do - { - v3 = control_print_talk_msg(v3, 0, v4, &a4, 0); - if ( !v3 ) - goto LABEL_10; - v4 += 13; - } - while ( v4 < 39 ); - *v3 = 0; -LABEL_10: - CelDecDatOnly((char *)gpBuffer + a4, (char *)pCelBuff, frame, 12); - v5 = 0; - a1 = plr[0]._pName; - v10 = 0; - frame = (frame & 7) + 1; - while ( v10 == myplr ) - { -LABEL_21: - a1 += 21720; - ++v10; - if ( (signed int)a1 >= (signed int)&plr[4]._pName ) - return; - } - if ( tempstr[v10 + 256] ) - { - v6 = 3; - if ( !talkbtndown[v5] ) - { -LABEL_18: - if ( *(a1 - 291) ) - control_print_talk_msg(a1, 46, 18 * v5 + 60, &a4, v6); - ++v5; - goto LABEL_21; - } - v7 = (v5 != 0) + 3; - } - else - { - v7 = (v5 != 0) + 1; - v6 = 2; - if ( talkbtndown[v5] ) - v7 = (v5 != 0) + 5; - } - CelDecodeOnly(236, 18 * v5 + 596, pTalkBtns, v7, 61); - goto LABEL_18; - } + int v0; // esi + signed int v1; // edi + signed int v2; // esi + char *v3; // eax + int v4; // esi + int v5; // esi + int v6; // ebx + int v7; // eax + int a4; // [esp+4h] [ebp-Ch] + char *a1; // [esp+8h] [ebp-8h] + int v10; // [esp+Ch] [ebp-4h] + + v0 = 0; + if (talkflag) { + DrawPanelBox(175, sgbPlrTalkTbl + 20, 294, 5, 239, 516); + v1 = 293; + do { + DrawPanelBox((v0 >> 1) + 175, sgbPlrTalkTbl + v0 + 25, v1, 1, (v0 >> 1) + 239, v0 + 521); + ++v0; + --v1; + } while (v1 > 283); + DrawPanelBox(185, sgbPlrTalkTbl + 35, 274, 30, 249, 531); + DrawPanelBox(180, sgbPlrTalkTbl + 65, 284, 5, 244, 561); + v2 = 0; + do { + DrawPanelBox(180, sgbPlrTalkTbl + v2 + 70, v2 + 284, 1, 244, v2 + 566); + ++v2; + } while (v2 < 10); + DrawPanelBox(170, sgbPlrTalkTbl + 80, 310, 55, 234, 576); + v3 = sgszTalkMsg; + v4 = 0; + do { + v3 = control_print_talk_msg(v3, 0, v4, &a4, 0); + if (!v3) + goto LABEL_10; + v4 += 13; + } while (v4 < 39); + *v3 = 0; + LABEL_10: + CelDecDatOnly((char *)gpBuffer + a4, (char *)pCelBuff, frame, 12); + v5 = 0; + a1 = plr[0]._pName; + v10 = 0; + frame = (frame & 7) + 1; + while (v10 == myplr) { + LABEL_21: + a1 += 21720; + ++v10; + if ((signed int)a1 >= (signed int)&plr[4]._pName) + return; + } + if (tempstr[v10 + 256]) { + v6 = 3; + if (!talkbtndown[v5]) { + LABEL_18: + if (*(a1 - 291)) + control_print_talk_msg(a1, 46, 18 * v5 + 60, &a4, v6); + ++v5; + goto LABEL_21; + } + v7 = (v5 != 0) + 3; + } else { + v7 = (v5 != 0) + 1; + v6 = 2; + if (talkbtndown[v5]) + v7 = (v5 != 0) + 5; + } + CelDecodeOnly(236, 18 * v5 + 596, pTalkBtns, v7, 61); + goto LABEL_18; + } } // 4B8840: using guessed type int sgbPlrTalkTbl; // 4B8960: using guessed type int talkflag; char *__fastcall control_print_talk_msg(char *msg, int x, int y, int *a4, int just) { - int v5; // edx - char *v6; // ebx - unsigned char v7; // al - int v8; // ecx - unsigned char v10; // dl - int v11; // edi - int a3; // [esp+14h] [ebp+8h] - - v5 = x + 264; - v6 = msg; - *a4 = v5 + screen_y_times_768[y + 534]; - v7 = *msg; - v8 = v5; - if ( !v7 ) - return 0; - while ( 1 ) - { - v10 = fontframe[fontidx[v7]]; - v11 = v10; - a3 = v8 + fontkern[v10] + 1; - if ( a3 > 514 ) - break; - ++v6; - if ( v10 ) - CPrintString(*a4, v10, just); - *a4 += fontkern[v11] + 1; - v7 = *v6; - if ( !*v6 ) - return 0; - v8 = a3; - } - return v6; + int v5; // edx + char *v6; // ebx + unsigned char v7; // al + int v8; // ecx + unsigned char v10; // dl + int v11; // edi + int a3; // [esp+14h] [ebp+8h] + + v5 = x + 264; + v6 = msg; + *a4 = v5 + screen_y_times_768[y + 534]; + v7 = *msg; + v8 = v5; + if (!v7) + return 0; + while (1) { + v10 = fontframe[fontidx[v7]]; + v11 = v10; + a3 = v8 + fontkern[v10] + 1; + if (a3 > 514) + break; + ++v6; + if (v10) + CPrintString(*a4, v10, just); + *a4 += fontkern[v11] + 1; + v7 = *v6; + if (!*v6) + return 0; + v8 = a3; + } + return v6; } int __cdecl control_check_talk_btn() { - int v0; // ecx - int result; // eax - - if ( !talkflag ) - return 0; - if ( MouseX < 172 ) - return 0; - v0 = MouseY; - if ( MouseY < 421 || MouseX > 233 ) - return 0; - result = 0; - if ( MouseY <= 475 ) - { - talkbtndown[0] = 0; - talkbtndown[1] = 0; - talkbtndown[2] = 0; - talkbtndown[(v0 - 421) / 18] = 1; - result = 1; - } - return result; + int v0; // ecx + int result; // eax + + if (!talkflag) + return 0; + if (MouseX < 172) + return 0; + v0 = MouseY; + if (MouseY < 421 || MouseX > 233) + return 0; + result = 0; + if (MouseY <= 475) { + talkbtndown[0] = 0; + talkbtndown[1] = 0; + talkbtndown[2] = 0; + talkbtndown[(v0 - 421) / 18] = 1; + result = 1; + } + return result; } // 4B8960: using guessed type int talkflag; void __cdecl control_release_talk_btn() { - signed int v0; // ecx - int v1; // eax - signed int v2; // ecx - - if ( talkflag ) - { - v0 = MouseX; - talkbtndown[0] = 0; - talkbtndown[1] = 0; - talkbtndown[2] = 0; - if ( v0 >= 172 && MouseY >= 421 && v0 <= 233 && MouseY <= 475 ) - { - v1 = (MouseY - 421) / 18; - v2 = 0; - do - { - if ( v1 == -1 ) - break; - if ( v2 != myplr ) - --v1; - ++v2; - } - while ( v2 < 4 ); - if ( v2 <= 4 ) - tempstr[v2 + 255] = tempstr[v2 + 255] == 0; - } - } + signed int v0; // ecx + int v1; // eax + signed int v2; // ecx + + if (talkflag) { + v0 = MouseX; + talkbtndown[0] = 0; + talkbtndown[1] = 0; + talkbtndown[2] = 0; + if (v0 >= 172 && MouseY >= 421 && v0 <= 233 && MouseY <= 475) { + v1 = (MouseY - 421) / 18; + v2 = 0; + do { + if (v1 == -1) + break; + if (v2 != myplr) + --v1; + ++v2; + } while (v2 < 4); + if (v2 <= 4) + tempstr[v2 + 255] = tempstr[v2 + 255] == 0; + } + } } // 4B8960: using guessed type int talkflag; void __cdecl control_reset_talk_msg() { - signed int v1; // ecx + signed int v1; // ecx - BOOL v0 = FALSE; - v1 = 0; - do - { - if ( tempstr[v1 + 256] ) - v0 |= 1 << v1; - ++v1; - } - while ( v1 < 4 ); - if ( !msgcmd_add_server_cmd_W(sgszTalkMsg) ) - NetSendCmdString(v0, sgszTalkMsg); + BOOL v0 = FALSE; + v1 = 0; + do { + if (tempstr[v1 + 256]) + v0 |= 1 << v1; + ++v1; + } while (v1 < 4); + if (!msgcmd_add_server_cmd_W(sgszTalkMsg)) + NetSendCmdString(v0, sgszTalkMsg); } void __cdecl control_type_message() { - if ( gbMaxPlayers != 1 ) - { - sgszTalkMsg[0] = 0; - talkflag = 1; - frame = 1; - talkbtndown[0] = 0; - talkbtndown[1] = 0; - talkbtndown[2] = 0; - sgbPlrTalkTbl = 144; - drawpanflag = 255; - sgbTalkSavePos = sgbNextTalkSave; - } + if (gbMaxPlayers != 1) { + sgszTalkMsg[0] = 0; + talkflag = 1; + frame = 1; + talkbtndown[0] = 0; + talkbtndown[1] = 0; + talkbtndown[2] = 0; + sgbPlrTalkTbl = 144; + drawpanflag = 255; + sgbTalkSavePos = sgbNextTalkSave; + } } // 4B84CC: using guessed type char sgbNextTalkSave; // 4B84CD: using guessed type char sgbTalkSavePos; @@ -3092,9 +2802,9 @@ void __cdecl control_type_message() void __cdecl control_reset_talk() { - talkflag = 0; - sgbPlrTalkTbl = 0; - drawpanflag = 255; + talkflag = 0; + sgbPlrTalkTbl = 0; + drawpanflag = 255; } // 4B8840: using guessed type int sgbPlrTalkTbl; // 4B8960: using guessed type int talkflag; @@ -3102,56 +2812,53 @@ void __cdecl control_reset_talk() int __fastcall control_talk_last_key(int a1) { - char v1; // bl - signed int v3; // eax + char v1; // bl + signed int v3; // eax - v1 = a1; - if ( gbMaxPlayers == 1 || !talkflag || (unsigned int)a1 < VK_SPACE ) - return 0; - v3 = strlen(sgszTalkMsg); - if ( v3 < 78 ) - { - sgszTalkMsg[v3 + 1] = 0; - sgszTalkMsg[v3] = v1; - } - return 1; + v1 = a1; + if (gbMaxPlayers == 1 || !talkflag || (unsigned int)a1 < VK_SPACE) + return 0; + v3 = strlen(sgszTalkMsg); + if (v3 < 78) { + sgszTalkMsg[v3 + 1] = 0; + sgszTalkMsg[v3] = v1; + } + return 1; } // 4B8960: using guessed type int talkflag; // 679660: using guessed type char gbMaxPlayers; int __fastcall control_presskeys(int a1) { - signed int v1; // eax - char v2; // cl - - if ( gbMaxPlayers != 1 && talkflag ) - { - switch ( a1 ) - { - case VK_SPACE: - return 1; - case VK_ESCAPE: - control_reset_talk(); - return 1; - case VK_RETURN: - control_press_enter(); - return 1; - case VK_BACK: - v1 = strlen(sgszTalkMsg); - if ( v1 > 0 ) - sgszTalkMsg[v1 - 1] = '\0'; - return 1; - case VK_DOWN: - v2 = 1; -LABEL_15: - control_up_down(v2); - return 1; - case VK_UP: - v2 = -1; - goto LABEL_15; - } - } - return 0; + signed int v1; // eax + char v2; // cl + + if (gbMaxPlayers != 1 && talkflag) { + switch (a1) { + case VK_SPACE: + return 1; + case VK_ESCAPE: + control_reset_talk(); + return 1; + case VK_RETURN: + control_press_enter(); + return 1; + case VK_BACK: + v1 = strlen(sgszTalkMsg); + if (v1 > 0) + sgszTalkMsg[v1 - 1] = '\0'; + return 1; + case VK_DOWN: + v2 = 1; + LABEL_15: + control_up_down(v2); + return 1; + case VK_UP: + v2 = -1; + goto LABEL_15; + } + } + return 0; } // 4B87A8: using guessed type int chrbtnactive; // 4B8960: using guessed type int talkflag; @@ -3159,67 +2866,59 @@ LABEL_15: void __cdecl control_press_enter() { - signed int v0; // esi - char (*v1)[80]; // ebp - char v2; // al - int v3; // ecx - char *v4; // ebp - - if ( sgszTalkMsg[0] ) - { - control_reset_talk_msg(); - v0 = 0; - v1 = sgszTalkSave; - do - { - if ( !strcmp((const char *)v1, sgszTalkMsg) ) - break; - ++v1; - ++v0; - } - while ( (signed int)v1 < (signed int)&sgszTalkSave[8] ); - if ( v0 < 8 ) - { - v2 = sgbNextTalkSave; - v3 = (sgbNextTalkSave - 1) & 7; - if ( v0 != v3 ) - { - v4 = sgszTalkSave[v3]; - strcpy(sgszTalkSave[v0], sgszTalkSave[v3]); - strcpy(v4, sgszTalkMsg); - v2 = sgbNextTalkSave; - } - } - else - { - strcpy(sgszTalkSave[(unsigned char)sgbNextTalkSave], sgszTalkMsg); - v2 = (sgbNextTalkSave + 1) & 7; - sgbNextTalkSave = (sgbNextTalkSave + 1) & 7; - } - sgszTalkMsg[0] = 0; - sgbTalkSavePos = v2; - } - control_reset_talk(); + signed int v0; // esi + char(*v1)[80]; // ebp + char v2; // al + int v3; // ecx + char *v4; // ebp + + if (sgszTalkMsg[0]) { + control_reset_talk_msg(); + v0 = 0; + v1 = sgszTalkSave; + do { + if (!strcmp((const char *)v1, sgszTalkMsg)) + break; + ++v1; + ++v0; + } while ((signed int)v1 < (signed int)&sgszTalkSave[8]); + if (v0 < 8) { + v2 = sgbNextTalkSave; + v3 = (sgbNextTalkSave - 1) & 7; + if (v0 != v3) { + v4 = sgszTalkSave[v3]; + strcpy(sgszTalkSave[v0], sgszTalkSave[v3]); + strcpy(v4, sgszTalkMsg); + v2 = sgbNextTalkSave; + } + } else { + strcpy(sgszTalkSave[(unsigned char)sgbNextTalkSave], sgszTalkMsg); + v2 = (sgbNextTalkSave + 1) & 7; + sgbNextTalkSave = (sgbNextTalkSave + 1) & 7; + } + sgszTalkMsg[0] = 0; + sgbTalkSavePos = v2; + } + control_reset_talk(); } // 4B84CC: using guessed type char sgbNextTalkSave; // 4B84CD: using guessed type char sgbTalkSavePos; void __fastcall control_up_down(char a1) { - unsigned char v1; // al - int v2; // esi - - v1 = sgbTalkSavePos; - v2 = 0; - while ( 1 ) - { - v1 = (a1 + v1) & 7; - sgbTalkSavePos = v1; - if ( sgszTalkSave[v1][0] ) - break; - if ( ++v2 >= 8 ) - return; - } - strcpy(sgszTalkMsg, sgszTalkSave[v1]); + unsigned char v1; // al + int v2; // esi + + v1 = sgbTalkSavePos; + v2 = 0; + while (1) { + v1 = (a1 + v1) & 7; + sgbTalkSavePos = v1; + if (sgszTalkSave[v1][0]) + break; + if (++v2 >= 8) + return; + } + strcpy(sgszTalkMsg, sgszTalkSave[v1]); } // 4B84CD: using guessed type char sgbTalkSavePos; diff --git a/Source/control.h b/Source/control.h index 7c1342994..8718fa600 100644 --- a/Source/control.h +++ b/Source/control.h @@ -3,10 +3,10 @@ #define __CONTROL_H__ extern char sgbNextTalkSave; // weak -extern char sgbTalkSavePos; // weak +extern char sgbTalkSavePos; // weak extern void *pDurIcons; extern void *pChrButtons; -extern BOOL drawhpflag; // idb +extern BOOL drawhpflag; // idb extern int dropGoldFlag; // weak extern int panbtn[8]; extern int chrbtn[4]; @@ -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 int chrbtnactive; // weak extern char sgszTalkMsg[80]; extern void *pPanelText; extern int frame_4B8800; // idb @@ -30,16 +30,16 @@ extern int pinfoflag; // weak extern int talkbtndown[3]; extern int pSpell; // weak extern char *pManaBuff; -extern int infoclr; // weak +extern int infoclr; // weak extern int sgbPlrTalkTbl; // weak // should be char [4] extern void *pGBoxBuff; extern void *pSBkBtnCel; extern char tempstr[260]; -extern int sbooktab; // weak -extern int pSplType; // weak -extern int frame; // idb +extern int sbooktab; // weak +extern int pSplType; // weak +extern int frame; // idb extern int initialDropGoldIndex; // idb -extern int talkflag; // weak +extern int talkflag; // weak extern void *pSBkIconCels; extern int sbookflag; // weak extern int chrflag; @@ -53,9 +53,9 @@ extern int panelflag; // weak extern unsigned char spell_trans[256]; extern int initialDropGoldValue; // idb extern void *pSpellCels; -extern int panbtndown; // weak +extern int panbtndown; // weak extern void *pTalkPanel; // idb -extern int spselflag; // weak +extern int spselflag; // weak void __fastcall DrawSpellCel(int xp, int yp, char *Trans, int nCel, int w); void __fastcall SetSpellTrans(char t); diff --git a/Source/cursor.cpp b/Source/cursor.cpp index f565f15fe..46e6f9187 100644 --- a/Source/cursor.cpp +++ b/Source/cursor.cpp @@ -2,450 +2,448 @@ #include "../types.h" -int cursH; // weak -int icursH28; // idb -int cursW; // idb +int cursH; // weak +int icursH28; // idb +int cursW; // idb int pcursmonst; // idb -int icursW28; // idb +int icursW28; // idb void *pCursCels; int icursH; // weak // inv_item value char pcursinvitem; // weak -int icursW; // weak -char pcursitem; // weak -char pcursobj; // weak -char pcursplr; // weak +int icursW; // weak +char pcursitem; // weak +char pcursobj; // weak +char pcursplr; // weak int cursmx; int cursmy; int dword_4B8CCC; // weak -int pcurs; // idb - +int pcurs; // idb /* rdata */ -const int InvItemWidth[180] = -{ - 0, - 33, - 32, - 32, - 32, - 32, - 32, - 32, - 32, - 32, - 32, - 23, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56 +const int InvItemWidth[180] = { + 0, + 33, + 32, + 32, + 32, + 32, + 32, + 32, + 32, + 32, + 32, + 23, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56 }; -const int InvItemHeight[180] = -{ - 0, - 29, - 32, - 32, - 32, - 32, - 32, - 32, - 32, - 32, - 32, - 35, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 56, - 56, - 56, - 56, - 56, - 56, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84 +const int InvItemHeight[180] = { + 0, + 29, + 32, + 32, + 32, + 32, + 32, + 32, + 32, + 32, + 32, + 35, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 56, + 56, + 56, + 56, + 56, + 56, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84 }; void __cdecl InitCursor() { - pCursCels = LoadFileInMem("Data\\Inv\\Objcurs.CEL", 0); - ClearCursor(); + pCursCels = LoadFileInMem("Data\\Inv\\Objcurs.CEL", 0); + ClearCursor(); } void __cdecl FreeCursor() { - void *v0; // ecx + void *v0; // ecx - v0 = pCursCels; - pCursCels = 0; - mem_free_dbg(v0); - ClearCursor(); + v0 = pCursCels; + pCursCels = 0; + mem_free_dbg(v0); + ClearCursor(); } void __fastcall SetICursor(int i) { - int v1; // ecx + int v1; // ecx - v1 = i; - icursW = InvItemWidth[v1]; - icursH = InvItemHeight[v1]; - icursW28 = icursW / 28; - icursH28 = icursH / 28; + v1 = i; + icursW = InvItemWidth[v1]; + icursH = InvItemHeight[v1]; + icursW28 = icursW / 28; + icursH28 = icursH / 28; } // 4B8CB4: using guessed type int icursH; // 4B8CBC: using guessed type int icursW; void __fastcall SetCursor(int i) { - int v1; // eax + int v1; // eax - v1 = InvItemWidth[i]; - pcurs = i; - cursW = v1; - cursH = InvItemHeight[i]; - SetICursor(i); + v1 = InvItemWidth[i]; + pcurs = i; + cursW = v1; + cursH = InvItemHeight[i]; + SetICursor(i); } // 4B8C9C: using guessed type int cursH; -void __fastcall NewCursor(int i) { - SetCursor(i); +void __fastcall NewCursor(int i) +{ + SetCursor(i); } void __cdecl InitLevelCursor() { - SetCursor(CURSOR_HAND); - cursmx = ViewX; - cursmy = ViewY; - dword_4B8CCC = -1; - pcursmonst = -1; - pcursobj = -1; - pcursitem = -1; - pcursplr = -1; - ClearCursor(); + SetCursor(CURSOR_HAND); + cursmx = ViewX; + cursmy = ViewY; + dword_4B8CCC = -1; + pcursmonst = -1; + pcursobj = -1; + pcursitem = -1; + pcursplr = -1; + ClearCursor(); } // 4B8CC0: using guessed type char pcursitem; // 4B8CC1: using guessed type char pcursobj; @@ -454,836 +452,726 @@ void __cdecl InitLevelCursor() void __cdecl CheckTown() { - int v0; // ecx - int v1; // eax - int v2; // esi - int v3; // edx - int v4; // ebx - int v5; // [esp+0h] [ebp-4h] + int v0; // ecx + int v1; // eax + int v2; // esi + int v3; // edx + int v4; // ebx + int v5; // [esp+0h] [ebp-4h] - v5 = 0; - if ( nummissiles > 0 ) - { - v0 = cursmx; - v1 = cursmy; - do - { - v2 = missileactive[v5]; - if ( missile[v2]._mitype == MIS_TOWN ) - { - if ( (v3 = missile[v2]._mix, v4 = v3 - 1, v0 == v3 - 1) && v1 == missile[v2]._miy - || v0 == v3 && v1 == missile[v2]._miy - 1 - || v0 == v4 && v1 == missile[v2]._miy - 1 - || v0 == v3 - 2 && (v1 == missile[v2]._miy - 1 || v0 == v3 - 2 && v1 == missile[v2]._miy - 2) - || v0 == v4 && v1 == missile[v2]._miy - 2 - || v0 == v3 && v1 == missile[v2]._miy ) - { - trigflag[3] = 1; - ClearPanel(); - strcpy(infostr, "Town Portal"); - sprintf(tempstr, "from %s", plr[missile[v2]._misource]._pName); - AddPanelString(tempstr, 1); - v0 = missile[v2]._mix; - v1 = missile[v2]._miy; - cursmx = missile[v2]._mix; - cursmy = v1; - } - } - ++v5; - } - while ( v5 < nummissiles ); - } + v5 = 0; + if (nummissiles > 0) { + v0 = cursmx; + v1 = cursmy; + do { + v2 = missileactive[v5]; + if (missile[v2]._mitype == MIS_TOWN) { + if ((v3 = missile[v2]._mix, v4 = v3 - 1, v0 == v3 - 1) && v1 == missile[v2]._miy + || v0 == v3 && v1 == missile[v2]._miy - 1 + || v0 == v4 && v1 == missile[v2]._miy - 1 + || v0 == v3 - 2 && (v1 == missile[v2]._miy - 1 || v0 == v3 - 2 && v1 == missile[v2]._miy - 2) + || v0 == v4 && v1 == missile[v2]._miy - 2 + || v0 == v3 && v1 == missile[v2]._miy) { + trigflag[3] = 1; + ClearPanel(); + strcpy(infostr, "Town Portal"); + sprintf(tempstr, "from %s", plr[missile[v2]._misource]._pName); + AddPanelString(tempstr, 1); + v0 = missile[v2]._mix; + v1 = missile[v2]._miy; + cursmx = missile[v2]._mix; + cursmy = v1; + } + } + ++v5; + } while (v5 < nummissiles); + } } void __cdecl CheckRportal() { - int v0; // ecx - int v1; // eax - int v2; // esi - int v3; // edx - int v4; // ebx - int v5; // [esp+0h] [ebp-4h] + int v0; // ecx + int v1; // eax + int v2; // esi + int v3; // edx + int v4; // ebx + int v5; // [esp+0h] [ebp-4h] - v5 = 0; - if ( nummissiles > 0 ) - { - v0 = cursmx; - v1 = cursmy; - do - { - v2 = missileactive[v5]; - if ( missile[v2]._mitype == MIS_RPORTAL ) - { - if ( (v3 = missile[v2]._mix, v4 = v3 - 1, v0 == v3 - 1) && v1 == missile[v2]._miy - || v0 == v3 && v1 == missile[v2]._miy - 1 - || v0 == v4 && v1 == missile[v2]._miy - 1 - || v0 == v3 - 2 && (v1 == missile[v2]._miy - 1 || v0 == v3 - 2 && v1 == missile[v2]._miy - 2) - || v0 == v4 && v1 == missile[v2]._miy - 2 - || v0 == v3 && v1 == missile[v2]._miy ) - { - trigflag[3] = 1; - ClearPanel(); - strcpy(infostr, "Portal to"); - if ( setlevel ) - strcpy(tempstr, "level 15"); - else - strcpy(tempstr, "The Unholy Altar"); - AddPanelString(tempstr, 1); - v0 = missile[v2]._mix; - v1 = missile[v2]._miy; - cursmx = missile[v2]._mix; - cursmy = v1; - } - } - ++v5; - } - while ( v5 < nummissiles ); - } + v5 = 0; + if (nummissiles > 0) { + v0 = cursmx; + v1 = cursmy; + do { + v2 = missileactive[v5]; + if (missile[v2]._mitype == MIS_RPORTAL) { + if ((v3 = missile[v2]._mix, v4 = v3 - 1, v0 == v3 - 1) && v1 == missile[v2]._miy + || v0 == v3 && v1 == missile[v2]._miy - 1 + || v0 == v4 && v1 == missile[v2]._miy - 1 + || v0 == v3 - 2 && (v1 == missile[v2]._miy - 1 || v0 == v3 - 2 && v1 == missile[v2]._miy - 2) + || v0 == v4 && v1 == missile[v2]._miy - 2 + || v0 == v3 && v1 == missile[v2]._miy) { + trigflag[3] = 1; + ClearPanel(); + strcpy(infostr, "Portal to"); + if (setlevel) + strcpy(tempstr, "level 15"); + else + strcpy(tempstr, "The Unholy Altar"); + AddPanelString(tempstr, 1); + v0 = missile[v2]._mix; + v1 = missile[v2]._miy; + cursmx = missile[v2]._mix; + cursmy = v1; + } + } + ++v5; + } while (v5 < nummissiles); + } } // 5CF31D: using guessed type char setlevel; void __cdecl CheckCursMove() { - int v0; // esi - signed int v1; // edi - int v2; // esi - int v3; // edi - int v4; // edx - int v5; // ebx - int v6; // edi - int v7; // eax - int v8; // esi - BOOL v9; // eax - int v10; // ecx - int v11; // edx - int v12; // ecx - int v13; // ebx - int v14; // ebx - int v15; // eax - bool v16; // zf - int v17; // ecx - int v18; // eax - int v19; // ecx - int v20; // eax - int v21; // ecx - int v22; // eax - int v23; // eax - int v24; // ecx - int v25; // eax - int v26; // ecx - int v27; // ebx - int v28; // edx - int v29; // eax - int v30; // ecx - int v31; // eax - int v32; // eax - int v33; // eax - int v34; // ecx - int v35; // eax - int v36; // ecx - int v37; // eax - int v38; // eax - int v39; // ecx - int v40; // eax - int v41; // ecx - signed int v42; // eax - int v43; // ecx - int v44; // eax - int v45; // eax - int v46; // eax - int v47; // eax - char v48; // al - char v49; // cl - char v50; // al - char v51; // al - char v52; // cl - int v53; // ecx - int *v54; // eax - int v55; // edx - int *v56; // ecx - char v57; // al - char v58; // cl - signed int v59; // edx - char v60; // al - char v61; // cl - char v62; // al - char v63; // al - char v64; // cl - char v65; // al - char v66; // al - char v67; // cl - char v68; // al - char v69; // al - char v70; // al - char v71; // al - char v72; // al - char v73; // cl - char v74; // al - char v75; // al - int v76; // [esp+Ch] [ebp-18h] - char *v77; // [esp+Ch] [ebp-18h] - int v78; // [esp+10h] [ebp-14h] - signed int v79; // [esp+14h] [ebp-10h] - signed int v80; // [esp+18h] [ebp-Ch] - int v81; // [esp+1Ch] [ebp-8h] - int v82; // [esp+1Ch] [ebp-8h] - signed int v83; // [esp+20h] [ebp-4h] + int v0; // esi + signed int v1; // edi + int v2; // esi + int v3; // edi + int v4; // edx + int v5; // ebx + int v6; // edi + int v7; // eax + int v8; // esi + BOOL v9; // eax + int v10; // ecx + int v11; // edx + int v12; // ecx + int v13; // ebx + int v14; // ebx + int v15; // eax + bool v16; // zf + int v17; // ecx + int v18; // eax + int v19; // ecx + int v20; // eax + int v21; // ecx + int v22; // eax + int v23; // eax + int v24; // ecx + int v25; // eax + int v26; // ecx + int v27; // ebx + int v28; // edx + int v29; // eax + int v30; // ecx + int v31; // eax + int v32; // eax + int v33; // eax + int v34; // ecx + int v35; // eax + int v36; // ecx + int v37; // eax + int v38; // eax + int v39; // ecx + int v40; // eax + int v41; // ecx + signed int v42; // eax + int v43; // ecx + int v44; // eax + int v45; // eax + int v46; // eax + int v47; // eax + char v48; // al + char v49; // cl + char v50; // al + char v51; // al + char v52; // cl + int v53; // ecx + int *v54; // eax + int v55; // edx + int *v56; // ecx + char v57; // al + char v58; // cl + signed int v59; // edx + char v60; // al + char v61; // cl + char v62; // al + char v63; // al + char v64; // cl + char v65; // al + char v66; // al + char v67; // cl + char v68; // al + char v69; // al + char v70; // al + char v71; // al + char v72; // al + char v73; // cl + char v74; // al + char v75; // al + int v76; // [esp+Ch] [ebp-18h] + char *v77; // [esp+Ch] [ebp-18h] + int v78; // [esp+10h] [ebp-14h] + signed int v79; // [esp+14h] [ebp-10h] + signed int v80; // [esp+18h] [ebp-Ch] + int v81; // [esp+1Ch] [ebp-8h] + int v82; // [esp+1Ch] [ebp-8h] + signed int v83; // [esp+20h] [ebp-4h] - v0 = MouseX; - v1 = MouseY; - if ( chrflag || questlog ) - { - if ( MouseX >= 160 ) - { - v0 = MouseX - 160; - goto LABEL_10; - } - goto LABEL_9; - } - if ( invflag || sbookflag ) - { - if ( MouseX <= 320 ) - { - v0 = MouseX + 160; - goto LABEL_10; - } -LABEL_9: - v0 = 0; - } + v0 = MouseX; + v1 = MouseY; + if (chrflag || questlog) { + if (MouseX >= 160) { + v0 = MouseX - 160; + goto LABEL_10; + } + goto LABEL_9; + } + if (invflag || sbookflag) { + if (MouseX <= 320) { + v0 = MouseX + 160; + goto LABEL_10; + } + LABEL_9: + v0 = 0; + } LABEL_10: - if ( MouseY > 351 && track_isscrolling() ) - v1 = 351; - if ( !zoomflag ) - { - v0 >>= 1; - v1 >>= 1; - } - v2 = v0 - ScrollInfo._sxoff; - v3 = v1 - ScrollInfo._syoff; - if ( ScrollInfo._sdir ) - { - v2 += ((plr[myplr]._pVar6 + plr[myplr]._pxvel) >> 8) - (plr[myplr]._pVar6 >> 8); - v3 += ((plr[myplr]._pVar7 + plr[myplr]._pyvel) >> 8) - (plr[myplr]._pVar7 >> 8); - } - if ( v2 < 0 ) - v2 = 0; - if ( v2 >= 640 ) - v2 = 640; - if ( v3 < 0 ) - v3 = 0; - if ( v3 >= 480 ) - v3 = 480; - v4 = v3 >> 5; - v5 = v3 & 0x1F; - v76 = v2 & 0x3F; - v6 = (v2 >> 6) + (v3 >> 5) + ViewX - (zoomflag != 0 ? 10 : 5); - v7 = v76 >> 1; - v8 = v4 + ViewY - (v2 >> 6); - if ( v5 < v76 >> 1 ) - --v8; - v9 = v5 >= 32 - v7; - if ( v9 ) - ++v6; - if ( v6 < 0 ) - v6 = 0; - if ( v6 >= 112 ) - v6 = 111; - if ( v8 < 0 ) - v8 = 0; - if ( v8 >= 112 ) - v8 = 111; - if ( v5 >= v76 >> 1 ) - { - if ( !v9 ) - goto LABEL_49; - goto LABEL_48; - } - if ( !v9 ) - { -LABEL_48: - if ( v76 < 32 ) - goto LABEL_39; -LABEL_49: - v83 = 0; - goto LABEL_40; - } + if (MouseY > 351 && track_isscrolling()) + v1 = 351; + if (!zoomflag) { + v0 >>= 1; + v1 >>= 1; + } + v2 = v0 - ScrollInfo._sxoff; + v3 = v1 - ScrollInfo._syoff; + if (ScrollInfo._sdir) { + v2 += ((plr[myplr]._pVar6 + plr[myplr]._pxvel) >> 8) - (plr[myplr]._pVar6 >> 8); + v3 += ((plr[myplr]._pVar7 + plr[myplr]._pyvel) >> 8) - (plr[myplr]._pVar7 >> 8); + } + if (v2 < 0) + v2 = 0; + if (v2 >= 640) + v2 = 640; + if (v3 < 0) + v3 = 0; + if (v3 >= 480) + v3 = 480; + v4 = v3 >> 5; + v5 = v3 & 0x1F; + v76 = v2 & 0x3F; + v6 = (v2 >> 6) + (v3 >> 5) + ViewX - (zoomflag != 0 ? 10 : 5); + v7 = v76 >> 1; + v8 = v4 + ViewY - (v2 >> 6); + if (v5> 1) + --v8; + v9 = v5 >= 32 - v7; + if (v9) + ++v6; + if (v6 < 0) + v6 = 0; + if (v6 >= 112) + v6 = 111; + if (v8 < 0) + v8 = 0; + if (v8 >= 112) + v8 = 111; + if (v5 >= v76 >> 1) { + if (!v9) + goto LABEL_49; + goto LABEL_48; + } + if (!v9) { + LABEL_48: + if (v76 < 32) + goto LABEL_39; + LABEL_49: + v83 = 0; + goto LABEL_40; + } LABEL_39: - v83 = 1; + v83 = 1; LABEL_40: - v10 = pcursmonst; - pcursobj = -1; - pcursitem = -1; - v11 = -1; - dword_4B8CCC = pcursmonst; - pcursmonst = -1; - if ( pcursinvitem != -1 ) - drawsbarflag = 1; - pcursinvitem = -1; - pcursplr = -1; - v16 = plr[myplr]._pInvincible == 0; - uitemflag = 0; - panelflag = 0; - trigflag[3] = 0; - if ( !v16 ) - return; - if ( pcurs >= CURSOR_FIRSTITEM || spselflag ) - { - cursmx = v6; - cursmy = v8; - return; - } - if ( MouseY > 352 ) - { - CheckPanelInfo(); - return; - } - if ( doomflag ) - return; - if ( invflag && MouseX > 320 ) - { - pcursinvitem = CheckInvHLight(); - return; - } - if ( sbookflag && MouseX > 320 || (chrflag || questlog) && MouseX < 320 ) - return; - if ( leveltype == DTYPE_TOWN ) - { - if ( v83 ) - { - v27 = 112 * v6; - v78 = 112 * v6; - v43 = 112 * v6 + v8; - v45 = dMonster[0][v43 + 1]; - if ( v45 <= 0 ) - goto LABEL_200; - v11 = v45 - 1; - cursmx = v6; - cursmy = v8 + 1; - } - else - { - v27 = 112 * v6; - v78 = 112 * v6; - v43 = 112 * v6 + v8; - v44 = dMonster[1][v43]; - if ( v44 <= 0 ) - goto LABEL_200; - v11 = v44 - 1; - cursmx = v6 + 1; - cursmy = v8; - } - pcursmonst = v11; -LABEL_200: - v46 = dMonster[0][v43]; - if ( v46 > 0 ) - { - v11 = v46 - 1; - cursmx = v6; - pcursmonst = v46 - 1; - cursmy = v8; - } - v47 = dMonster[1][v43 + 1]; - if ( v47 > 0 ) - { - v11 = v47 - 1; - cursmx = v6 + 1; - pcursmonst = v47 - 1; - cursmy = v8 + 1; - } - if ( !towner[v11]._tSelFlag ) -LABEL_205: - pcursmonst = -1; -LABEL_206: - if ( pcursmonst != -1 ) - { -LABEL_305: - v59 = pcursmonst; - goto LABEL_306; - } -LABEL_207: - if ( v83 ) - { - v50 = dPlayer[0][v27 + 1 + v8]; - if ( v50 ) - { - v49 = v50 <= 0 ? -1 - v50 : v50 - 1; - if ( v49 != myplr && plr[v49]._pHitPoints ) - { - cursmx = v6; - cursmy = v8 + 1; - goto LABEL_222; - } - } - } - else - { - v48 = dPlayer[1][v27 + v8]; - if ( v48 ) - { - v49 = v48 <= 0 ? -1 - v48 : v48 - 1; - if ( v49 != myplr && plr[v49]._pHitPoints ) - { - cursmy = v8; - cursmx = v6 + 1; -LABEL_222: - pcursplr = v49; - goto LABEL_223; - } - } - } -LABEL_223: - v51 = dPlayer[0][v27 + v8]; - if ( v51 ) - { - v52 = v51 <= 0 ? -1 - v51 : v51 - 1; - if ( v52 != myplr ) - { - cursmx = v6; - cursmy = v8; - pcursplr = v52; - } - } - if ( dFlags[0][v27 + v8] & DFLAG_DEAD_PLAYER ) - { - v53 = 0; - v54 = &plr[0].WorldY; - do - { - if ( *(v54 - 1) == v6 && *v54 == v8 && v53 != myplr ) - { - cursmx = v6; - cursmy = v8; - pcursplr = v53; - } - v54 += 5430; - ++v53; - } - while ( (signed int)v54 < (signed int)&plr[4].WorldY ); - } - if ( pcurs == CURSOR_RESURRECT ) - { - v79 = -1; - v77 = &dFlags[-1][v27 + v8]; /* v77 = &nBlockTable[v27 + 1944 + v8]; check */ - do - { - v80 = -1; - v55 = v8 - 1; - do - { - if ( v77[v80] & DFLAG_DEAD_PLAYER ) - { - v82 = 0; - v56 = &plr[0].WorldY; - do - { - if ( *(v56 - 1) == v6 + v79 && *v56 == v55 && v82 != myplr ) - { - cursmx = v6 + v79; - cursmy = v55; - pcursplr = v82; - } - ++v82; - v56 += 5430; - } - while ( (signed int)v56 < (signed int)&plr[4].WorldY ); - } - ++v80; - ++v55; - } - while ( v80 < 2 ); - ++v79; - v77 += 112; - } - while ( v79 < 2 ); - v27 = v78; - } - v57 = dPlayer[1][v27 + 1 + v8]; - if ( v57 ) - { - v58 = v57 <= 0 ? -1 - v57 : v57 - 1; - if ( v58 != myplr && plr[v58]._pHitPoints ) - { - pcursplr = v58; - cursmx = v6 + 1; - cursmy = v8 + 1; - } - } - v59 = pcursmonst; - if ( pcursmonst != -1 ) - { -LABEL_285: - if ( pcursplr == -1 ) - goto LABEL_286; -LABEL_306: - if ( pcurs == CURSOR_IDENTIFY ) - { - pcursobj = -1; - v59 = -1; - pcursitem = -1; - pcursmonst = -1; - cursmx = v6; - cursmy = v8; - } - if ( v59 != -1 ) - { - if ( monster[v59]._mFlags & 0x20 ) - pcursmonst = -1; - } - return; - } - if ( pcursplr != pcursmonst ) /* check in future */ - goto LABEL_306; - if ( v83 ) - { - v62 = dObject[0][v27 + 1 + v8]; - if ( !v62 ) - goto LABEL_272; - v61 = v62 <= 0 ? -1 - v62 : v62 - 1; - if ( object[v61]._oSelFlag < 2 ) - goto LABEL_272; - cursmx = v6; - cursmy = v8 + 1; - } - else - { - v60 = dObject[1][v27 + v8]; - if ( !v60 ) - goto LABEL_272; - v61 = v60 <= 0 ? -1 - v60 : v60 - 1; - if ( object[v61]._oSelFlag < 2 ) - goto LABEL_272; - cursmy = v8; - cursmx = v6 + 1; - } - pcursobj = v61; -LABEL_272: - v63 = dObject[0][v27 + v8]; - if ( v63 ) - { - v64 = v63 <= 0 ? -1 - v63 : v63 - 1; - v65 = object[v64]._oSelFlag; - if ( v65 == 1 || v65 == 3 ) - { - cursmx = v6; - cursmy = v8; - pcursobj = v64; - } - } - v66 = dObject[1][v27 + 1 + v8]; - if ( !v66 || (v66 <= 0 ? (v67 = -1 - v66) : (v67 = v66 - 1), object[v67]._oSelFlag < 2) ) - { -LABEL_286: - if ( pcursobj != -1 || pcursmonst != -1 ) - goto LABEL_306; - if ( v83 ) - { - v70 = dItem[0][v27 + 1 + v8]; - if ( v70 <= 0 ) - goto LABEL_296; - v69 = v70 - 1; - if ( item[v69]._iSelFlag < 2 ) - goto LABEL_296; - cursmx = v6; - cursmy = v8 + 1; - } - else - { - v68 = dItem[1][v27 + v8]; - if ( v68 <= 0 ) - goto LABEL_296; - v69 = v68 - 1; - if ( item[v69]._iSelFlag < 2 ) - goto LABEL_296; - cursmy = v8; - cursmx = v6 + 1; - } - pcursitem = v69; -LABEL_296: - v71 = dItem[0][v27 + v8]; - if ( v71 > 0 ) - { - v72 = v71 - 1; - v73 = item[v72]._iSelFlag; - if ( v73 == 1 || v73 == 3 ) - { - cursmx = v6; - cursmy = v8; - pcursitem = v72; - } - } - v74 = dItem[1][v27 + 1 + v8]; - if ( v74 > 0 ) - { - v75 = v74 - 1; - if ( item[v75]._iSelFlag >= 2 ) - { - pcursitem = v75; - cursmx = v6 + 1; - cursmy = v8 + 1; - } - } - if ( pcursitem != -1 ) - goto LABEL_306; - cursmx = v6; - cursmy = v8; - CheckTrigForce(); - CheckTown(); - CheckRportal(); - goto LABEL_305; - } - pcursobj = v67; - cursmx = v6 + 1; - cursmy = v8 + 1; - goto LABEL_285; - } - if ( v10 == -1 ) - goto LABEL_128; - v12 = 112 * v6 + v8; - v81 = 112 * v6 + v8; - v13 = 112 * v6 + v8; - if ( v83 ) - { - v14 = v13; - v15 = dMonster[1][v14 + 2]; - if ( !v15 ) - goto LABEL_74; - v16 = (dFlags[1][v12 + 2] & DFLAG_LIT) == 0; - } - else - { - v14 = v13; - v15 = dMonster[2][v14 + 1]; - if ( !v15 ) - goto LABEL_74; - v16 = (dFlags[2][v12 + 1] & DFLAG_LIT) == 0; - } - if ( !v16 ) - { - v17 = v15 <= 0 ? -1 - v15 : v15 - 1; - if ( v17 == dword_4B8CCC - && monster[v17]._mhitpoints >> 6 > 0 - && monster[v17].MData->mSelFlag & 4 ) - { - v11 = v17; - cursmx = v6 + 1; - cursmy = v8 + 2; - pcursmonst = v17; - } - } + v10 = pcursmonst; + pcursobj = -1; + pcursitem = -1; + v11 = -1; + dword_4B8CCC = pcursmonst; + pcursmonst = -1; + if (pcursinvitem != -1) + drawsbarflag = 1; + pcursinvitem = -1; + pcursplr = -1; + v16 = plr[myplr]._pInvincible == 0; + uitemflag = 0; + panelflag = 0; + trigflag[3] = 0; + if (!v16) + return; + if (pcurs >= CURSOR_FIRSTITEM || spselflag) { + cursmx = v6; + cursmy = v8; + return; + } + if (MouseY > 352) { + CheckPanelInfo(); + return; + } + if (doomflag) + return; + if (invflag && MouseX > 320) { + pcursinvitem = CheckInvHLight(); + return; + } + if (sbookflag && MouseX > 320 || (chrflag || questlog) && MouseX < 320) + return; + if (leveltype == DTYPE_TOWN) { + if (v83) { + v27 = 112 * v6; + v78 = 112 * v6; + v43 = 112 * v6 + v8; + v45 = dMonster[0][v43 + 1]; + if (v45 <= 0) + goto LABEL_200; + v11 = v45 - 1; + cursmx = v6; + cursmy = v8 + 1; + } else { + v27 = 112 * v6; + v78 = 112 * v6; + v43 = 112 * v6 + v8; + v44 = dMonster[1][v43]; + if (v44 <= 0) + goto LABEL_200; + v11 = v44 - 1; + cursmx = v6 + 1; + cursmy = v8; + } + pcursmonst = v11; + LABEL_200: + v46 = dMonster[0][v43]; + if (v46 > 0) { + v11 = v46 - 1; + cursmx = v6; + pcursmonst = v46 - 1; + cursmy = v8; + } + v47 = dMonster[1][v43 + 1]; + if (v47 > 0) { + v11 = v47 - 1; + cursmx = v6 + 1; + pcursmonst = v47 - 1; + cursmy = v8 + 1; + } + if (!towner[v11]._tSelFlag) + LABEL_205: + pcursmonst = -1; + LABEL_206: + if (pcursmonst != -1) { + LABEL_305: + v59 = pcursmonst; + goto LABEL_306; + } + LABEL_207: + if (v83) { + v50 = dPlayer[0][v27 + 1 + v8]; + if (v50) { + v49 = v50 <= 0 ? -1 - v50 : v50 - 1; + if (v49 != myplr && plr[v49]._pHitPoints) { + cursmx = v6; + cursmy = v8 + 1; + goto LABEL_222; + } + } + } else { + v48 = dPlayer[1][v27 + v8]; + if (v48) { + v49 = v48 <= 0 ? -1 - v48 : v48 - 1; + if (v49 != myplr && plr[v49]._pHitPoints) { + cursmy = v8; + cursmx = v6 + 1; + LABEL_222: + pcursplr = v49; + goto LABEL_223; + } + } + } + LABEL_223: + v51 = dPlayer[0][v27 + v8]; + if (v51) { + v52 = v51 <= 0 ? -1 - v51 : v51 - 1; + if (v52 != myplr) { + cursmx = v6; + cursmy = v8; + pcursplr = v52; + } + } + if (dFlags[0][v27 + v8] & DFLAG_DEAD_PLAYER) { + v53 = 0; + v54 = &plr[0].WorldY; + do { + if (*(v54 - 1) == v6 && *v54 == v8 && v53 != myplr) { + cursmx = v6; + cursmy = v8; + pcursplr = v53; + } + v54 += 5430; + ++v53; + } while ((signed int)v54 < (signed int)&plr[4].WorldY); + } + if (pcurs == CURSOR_RESURRECT) { + v79 = -1; + v77 = &dFlags[-1][v27 + v8]; /* v77 = &nBlockTable[v27 + 1944 + v8]; check */ + do { + v80 = -1; + v55 = v8 - 1; + do { + if (v77[v80] & DFLAG_DEAD_PLAYER) { + v82 = 0; + v56 = &plr[0].WorldY; + do { + if (*(v56 - 1) == v6 + v79 && *v56 == v55 && v82 != myplr) { + cursmx = v6 + v79; + cursmy = v55; + pcursplr = v82; + } + ++v82; + v56 += 5430; + } while ((signed int)v56 < (signed int)&plr[4].WorldY); + } + ++v80; + ++v55; + } while (v80 < 2); + ++v79; + v77 += 112; + } while (v79 < 2); + v27 = v78; + } + v57 = dPlayer[1][v27 + 1 + v8]; + if (v57) { + v58 = v57 <= 0 ? -1 - v57 : v57 - 1; + if (v58 != myplr && plr[v58]._pHitPoints) { + pcursplr = v58; + cursmx = v6 + 1; + cursmy = v8 + 1; + } + } + v59 = pcursmonst; + if (pcursmonst != -1) { + LABEL_285: + if (pcursplr == -1) + goto LABEL_286; + LABEL_306: + if (pcurs == CURSOR_IDENTIFY) { + pcursobj = -1; + v59 = -1; + pcursitem = -1; + pcursmonst = -1; + cursmx = v6; + cursmy = v8; + } + if (v59 != -1) { + if (monster[v59]._mFlags & 0x20) + pcursmonst = -1; + } + return; + } + if (pcursplr != pcursmonst) /* check in future */ + goto LABEL_306; + if (v83) { + v62 = dObject[0][v27 + 1 + v8]; + if (!v62) + goto LABEL_272; + v61 = v62 <= 0 ? -1 - v62 : v62 - 1; + if (object[v61]._oSelFlag < 2) + goto LABEL_272; + cursmx = v6; + cursmy = v8 + 1; + } else { + v60 = dObject[1][v27 + v8]; + if (!v60) + goto LABEL_272; + v61 = v60 <= 0 ? -1 - v60 : v60 - 1; + if (object[v61]._oSelFlag < 2) + goto LABEL_272; + cursmy = v8; + cursmx = v6 + 1; + } + pcursobj = v61; + LABEL_272: + v63 = dObject[0][v27 + v8]; + if (v63) { + v64 = v63 <= 0 ? -1 - v63 : v63 - 1; + v65 = object[v64]._oSelFlag; + if (v65 == 1 || v65 == 3) { + cursmx = v6; + cursmy = v8; + pcursobj = v64; + } + } + v66 = dObject[1][v27 + 1 + v8]; + if (!v66 || (v66 <= 0 ? (v67 = -1 - v66) : (v67 = v66 - 1), object[v67]._oSelFlag < 2)) { + LABEL_286: + if (pcursobj != -1 || pcursmonst != -1) + goto LABEL_306; + if (v83) { + v70 = dItem[0][v27 + 1 + v8]; + if (v70 <= 0) + goto LABEL_296; + v69 = v70 - 1; + if (item[v69]._iSelFlag < 2) + goto LABEL_296; + cursmx = v6; + cursmy = v8 + 1; + } else { + v68 = dItem[1][v27 + v8]; + if (v68 <= 0) + goto LABEL_296; + v69 = v68 - 1; + if (item[v69]._iSelFlag < 2) + goto LABEL_296; + cursmy = v8; + cursmx = v6 + 1; + } + pcursitem = v69; + LABEL_296: + v71 = dItem[0][v27 + v8]; + if (v71 > 0) { + v72 = v71 - 1; + v73 = item[v72]._iSelFlag; + if (v73 == 1 || v73 == 3) { + cursmx = v6; + cursmy = v8; + pcursitem = v72; + } + } + v74 = dItem[1][v27 + 1 + v8]; + if (v74 > 0) { + v75 = v74 - 1; + if (item[v75]._iSelFlag >= 2) { + pcursitem = v75; + cursmx = v6 + 1; + cursmy = v8 + 1; + } + } + if (pcursitem != -1) + goto LABEL_306; + cursmx = v6; + cursmy = v8; + CheckTrigForce(); + CheckTown(); + CheckRportal(); + goto LABEL_305; + } + pcursobj = v67; + cursmx = v6 + 1; + cursmy = v8 + 1; + goto LABEL_285; + } + if (v10 == -1) + goto LABEL_128; + v12 = 112 * v6 + v8; + v81 = 112 * v6 + v8; + v13 = 112 * v6 + v8; + if (v83) { + v14 = v13; + v15 = dMonster[1][v14 + 2]; + if (!v15) + goto LABEL_74; + v16 = (dFlags[1][v12 + 2] & DFLAG_LIT) == 0; + } else { + v14 = v13; + v15 = dMonster[2][v14 + 1]; + if (!v15) + goto LABEL_74; + v16 = (dFlags[2][v12 + 1] & DFLAG_LIT) == 0; + } + if (!v16) { + v17 = v15 <= 0 ? -1 - v15 : v15 - 1; + if (v17 == dword_4B8CCC + && monster[v17]._mhitpoints >> 6 > 0 + && monster[v17].MData->mSelFlag & 4) { + v11 = v17; + cursmx = v6 + 1; + cursmy = v8 + 2; + pcursmonst = v17; + } + } LABEL_74: - v18 = dMonster[2][v14 + 2]; - if ( v18 && dFlags[2][v81 + 2] & DFLAG_LIT ) - { - v19 = v18 <= 0 ? -1 - v18 : v18 - 1; - if ( v19 == dword_4B8CCC - && monster[v19]._mhitpoints >> 6 > 0 - && monster[v19].MData->mSelFlag & 4 ) - { - v11 = v19; - cursmx = v6 + 2; - cursmy = v8 + 2; - pcursmonst = v19; - } - } - if ( v83 ) - { - v22 = dMonster[0][v14 + 1]; - if ( v22 && dFlags[0][v81 + 1] & DFLAG_LIT ) - { - v21 = v22 <= 0 ? -1 - v22 : v22 - 1; - if ( v21 == dword_4B8CCC - && monster[v21]._mhitpoints >> 6 > 0 - && monster[v21].MData->mSelFlag & 2 ) - { - cursmx = v6; - cursmy = v8 + 1; - goto LABEL_102; - } - } - } - else - { - v20 = dMonster[1][v14]; - if ( v20 && dFlags[1][v81] & DFLAG_LIT ) - { - v21 = v20 <= 0 ? -1 - v20 : v20 - 1; - if ( v21 == dword_4B8CCC - && monster[v21]._mhitpoints >> 6 > 0 - && monster[v21].MData->mSelFlag & 2 ) - { - cursmy = v8; - cursmx = v6 + 1; -LABEL_102: - v11 = v21; - pcursmonst = v21; - goto LABEL_103; - } - } - } + v18 = dMonster[2][v14 + 2]; + if (v18 && dFlags[2][v81 + 2] & DFLAG_LIT) { + v19 = v18 <= 0 ? -1 - v18 : v18 - 1; + if (v19 == dword_4B8CCC + && monster[v19]._mhitpoints >> 6 > 0 + && monster[v19].MData->mSelFlag & 4) { + v11 = v19; + cursmx = v6 + 2; + cursmy = v8 + 2; + pcursmonst = v19; + } + } + if (v83) { + v22 = dMonster[0][v14 + 1]; + if (v22 && dFlags[0][v81 + 1] & DFLAG_LIT) { + v21 = v22 <= 0 ? -1 - v22 : v22 - 1; + if (v21 == dword_4B8CCC + && monster[v21]._mhitpoints >> 6 > 0 + && monster[v21].MData->mSelFlag & 2) { + cursmx = v6; + cursmy = v8 + 1; + goto LABEL_102; + } + } + } else { + v20 = dMonster[1][v14]; + if (v20 && dFlags[1][v81] & DFLAG_LIT) { + v21 = v20 <= 0 ? -1 - v20 : v20 - 1; + if (v21 == dword_4B8CCC + && monster[v21]._mhitpoints >> 6 > 0 + && monster[v21].MData->mSelFlag & 2) { + cursmy = v8; + cursmx = v6 + 1; + LABEL_102: + v11 = v21; + pcursmonst = v21; + goto LABEL_103; + } + } + } LABEL_103: - v23 = dMonster[0][v14]; - if ( v23 && dFlags[0][v81] & DFLAG_LIT ) - { - v24 = v23 <= 0 ? -1 - v23 : v23 - 1; - if ( v24 == dword_4B8CCC - && monster[v24]._mhitpoints >> 6 > 0 - && monster[v24].MData->mSelFlag & 1 ) - { - v11 = v24; - cursmx = v6; - cursmy = v8; - pcursmonst = v24; - } - } - v25 = dMonster[1][v14 + 1]; - if ( v25 && dFlags[1][v81 + 1] & DFLAG_LIT ) - { - v26 = v25 <= 0 ? -1 - v25 : v25 - 1; - if ( v26 == dword_4B8CCC - && monster[v26]._mhitpoints >> 6 > 0 - && monster[v26].MData->mSelFlag & 2 ) - { - v11 = v26; - cursmx = v6 + 1; - cursmy = v8 + 1; - pcursmonst = v26; - } - } - if ( v11 == -1 ) - goto LABEL_128; - if ( monster[v11]._mFlags & 1 ) - { - v11 = -1; - cursmx = v6; - pcursmonst = -1; - cursmy = v8; - } - if ( v11 == -1 ) - goto LABEL_128; - if ( monster[v11]._mFlags & 0x20 ) - { - v11 = -1; - pcursmonst = -1; - } - if ( v11 == -1 ) - { -LABEL_128: - v27 = 112 * v6; - v78 = 112 * v6; - if ( v83 ) - { - v28 = v27 + v8; - v32 = dMonster[1][v28 + 2]; - if ( v32 && dFlags[1][v27 + 2 + v8] & DFLAG_LIT ) - { - v30 = v32 <= 0 ? -1 - v32 : v32 - 1; - if ( monster[v30]._mhitpoints >> 6 > 0 && monster[v30].MData->mSelFlag & 4 ) - { - cursmx = v6 + 1; - v31 = v8 + 2; - goto LABEL_145; - } - } - } - else - { - v28 = v27 + v8; - v29 = dMonster[2][v28 + 1]; - if ( v29 && dFlags[2][v27 + 1 + v8] & DFLAG_LIT ) - { - v30 = v29 <= 0 ? -1 - v29 : v29 - 1; - if ( monster[v30]._mhitpoints >> 6 > 0 && monster[v30].MData->mSelFlag & 4 ) - { - cursmx = v6 + 2; - v31 = v8 + 1; -LABEL_145: - cursmy = v31; - pcursmonst = v30; - goto LABEL_146; - } - } - } -LABEL_146: - v33 = dMonster[2][v28 + 2]; - if ( v33 && dFlags[2][v27 + 2 + v8] & DFLAG_LIT ) - { - v34 = v33 <= 0 ? -1 - v33 : v33 - 1; - if ( monster[v34]._mhitpoints >> 6 > 0 && monster[v34].MData->mSelFlag & 4 ) - { - pcursmonst = v34; - cursmx = v6 + 2; - cursmy = v8 + 2; - } - } - if ( v83 ) - { - v37 = dMonster[0][v28 + 1]; - if ( v37 && dFlags[0][v27 + 1 + v8] & DFLAG_LIT ) - { - v36 = v37 <= 0 ? -1 - v37 : v37 - 1; - if ( monster[v36]._mhitpoints >> 6 > 0 && monster[v36].MData->mSelFlag & 2 ) - { - cursmx = v6; - cursmy = v8 + 1; - goto LABEL_171; - } - } - } - else - { - v35 = dMonster[1][v28]; - if ( v35 && dFlags[1][v27 + v8] & DFLAG_LIT ) - { - v36 = v35 <= 0 ? -1 - v35 : v35 - 1; - if ( monster[v36]._mhitpoints >> 6 > 0 && monster[v36].MData->mSelFlag & 2 ) - { - cursmy = v8; - cursmx = v6 + 1; -LABEL_171: - pcursmonst = v36; - goto LABEL_172; - } - } - } -LABEL_172: - v38 = dMonster[0][v28]; - if ( v38 && dFlags[0][v27 + v8] & DFLAG_LIT ) - { - v39 = v38 <= 0 ? -1 - v38 : v38 - 1; - if ( monster[v39]._mhitpoints >> 6 > 0 && monster[v39].MData->mSelFlag & 1 ) - { - cursmx = v6; - cursmy = v8; - pcursmonst = v39; - } - } - v40 = dMonster[1][v28 + 1]; - if ( v40 && dFlags[1][v27 + 1 + v8] & DFLAG_LIT ) - { - v41 = v40 <= 0 ? -1 - v40 : v40 - 1; - if ( monster[v41]._mhitpoints >> 6 > 0 && monster[v41].MData->mSelFlag & 2 ) - { - pcursmonst = v41; - cursmx = v6 + 1; - cursmy = v8 + 1; - } - } - v42 = pcursmonst; - if ( pcursmonst == -1 ) - goto LABEL_207; - if ( monster[pcursmonst]._mFlags & 1 ) - { - v42 = -1; - cursmx = v6; - pcursmonst = -1; - cursmy = v8; - } - if ( v42 == -1 ) - goto LABEL_207; - if ( monster[v42]._mFlags & 0x20 ) - goto LABEL_205; - goto LABEL_206; - } + v23 = dMonster[0][v14]; + if (v23 && dFlags[0][v81] & DFLAG_LIT) { + v24 = v23 <= 0 ? -1 - v23 : v23 - 1; + if (v24 == dword_4B8CCC + && monster[v24]._mhitpoints >> 6 > 0 + && monster[v24].MData->mSelFlag & 1) { + v11 = v24; + cursmx = v6; + cursmy = v8; + pcursmonst = v24; + } + } + v25 = dMonster[1][v14 + 1]; + if (v25 && dFlags[1][v81 + 1] & DFLAG_LIT) { + v26 = v25 <= 0 ? -1 - v25 : v25 - 1; + if (v26 == dword_4B8CCC + && monster[v26]._mhitpoints >> 6 > 0 + && monster[v26].MData->mSelFlag & 2) { + v11 = v26; + cursmx = v6 + 1; + cursmy = v8 + 1; + pcursmonst = v26; + } + } + if (v11 == -1) + goto LABEL_128; + if (monster[v11]._mFlags & 1) { + v11 = -1; + cursmx = v6; + pcursmonst = -1; + cursmy = v8; + } + if (v11 == -1) + goto LABEL_128; + if (monster[v11]._mFlags & 0x20) { + v11 = -1; + pcursmonst = -1; + } + if (v11 == -1) { + LABEL_128: + v27 = 112 * v6; + v78 = 112 * v6; + if (v83) { + v28 = v27 + v8; + v32 = dMonster[1][v28 + 2]; + if (v32 && dFlags[1][v27 + 2 + v8] & DFLAG_LIT) { + v30 = v32 <= 0 ? -1 - v32 : v32 - 1; + if (monster[v30]._mhitpoints >> 6 > 0 && monster[v30].MData->mSelFlag & 4) { + cursmx = v6 + 1; + v31 = v8 + 2; + goto LABEL_145; + } + } + } else { + v28 = v27 + v8; + v29 = dMonster[2][v28 + 1]; + if (v29 && dFlags[2][v27 + 1 + v8] & DFLAG_LIT) { + v30 = v29 <= 0 ? -1 - v29 : v29 - 1; + if (monster[v30]._mhitpoints >> 6 > 0 && monster[v30].MData->mSelFlag & 4) { + cursmx = v6 + 2; + v31 = v8 + 1; + LABEL_145: + cursmy = v31; + pcursmonst = v30; + goto LABEL_146; + } + } + } + LABEL_146: + v33 = dMonster[2][v28 + 2]; + if (v33 && dFlags[2][v27 + 2 + v8] & DFLAG_LIT) { + v34 = v33 <= 0 ? -1 - v33 : v33 - 1; + if (monster[v34]._mhitpoints >> 6 > 0 && monster[v34].MData->mSelFlag & 4) { + pcursmonst = v34; + cursmx = v6 + 2; + cursmy = v8 + 2; + } + } + if (v83) { + v37 = dMonster[0][v28 + 1]; + if (v37 && dFlags[0][v27 + 1 + v8] & DFLAG_LIT) { + v36 = v37 <= 0 ? -1 - v37 : v37 - 1; + if (monster[v36]._mhitpoints >> 6 > 0 && monster[v36].MData->mSelFlag & 2) { + cursmx = v6; + cursmy = v8 + 1; + goto LABEL_171; + } + } + } else { + v35 = dMonster[1][v28]; + if (v35 && dFlags[1][v27 + v8] & DFLAG_LIT) { + v36 = v35 <= 0 ? -1 - v35 : v35 - 1; + if (monster[v36]._mhitpoints >> 6 > 0 && monster[v36].MData->mSelFlag & 2) { + cursmy = v8; + cursmx = v6 + 1; + LABEL_171: + pcursmonst = v36; + goto LABEL_172; + } + } + } + LABEL_172: + v38 = dMonster[0][v28]; + if (v38 && dFlags[0][v27 + v8] & DFLAG_LIT) { + v39 = v38 <= 0 ? -1 - v38 : v38 - 1; + if (monster[v39]._mhitpoints >> 6 > 0 && monster[v39].MData->mSelFlag & 1) { + cursmx = v6; + cursmy = v8; + pcursmonst = v39; + } + } + v40 = dMonster[1][v28 + 1]; + if (v40 && dFlags[1][v27 + 1 + v8] & DFLAG_LIT) { + v41 = v40 <= 0 ? -1 - v40 : v40 - 1; + if (monster[v41]._mhitpoints >> 6 > 0 && monster[v41].MData->mSelFlag & 2) { + pcursmonst = v41; + cursmx = v6 + 1; + cursmy = v8 + 1; + } + } + v42 = pcursmonst; + if (pcursmonst == -1) + goto LABEL_207; + if (monster[pcursmonst]._mFlags & 1) { + v42 = -1; + cursmx = v6; + pcursmonst = -1; + cursmy = v8; + } + if (v42 == -1) + goto LABEL_207; + if (monster[v42]._mFlags & 0x20) + goto LABEL_205; + goto LABEL_206; + } } // 4B8968: using guessed type int sbookflag; // 4B8B84: using guessed type int panelflag; diff --git a/Source/cursor.h b/Source/cursor.h index 17ba85249..0c0dfa012 100644 --- a/Source/cursor.h +++ b/Source/cursor.h @@ -2,22 +2,22 @@ #ifndef __CURSOR_H__ #define __CURSOR_H__ -extern int cursH; // weak -extern int icursH28; // idb -extern int cursW; // idb +extern int cursH; // weak +extern int icursH28; // idb +extern int cursW; // idb extern int pcursmonst; // idb -extern int icursW28; // idb +extern int icursW28; // idb extern void *pCursCels; -extern int icursH; // weak +extern int icursH; // weak extern char pcursinvitem; // weak -extern int icursW; // weak -extern char pcursitem; // weak -extern char pcursobj; // weak -extern char pcursplr; // weak +extern int icursW; // weak +extern char pcursitem; // weak +extern char pcursobj; // weak +extern char pcursplr; // weak extern int cursmx; extern int cursmy; extern int dword_4B8CCC; // weak -extern int pcurs; // idb +extern int pcurs; // idb void __cdecl InitCursor(); void __cdecl FreeCursor();