From ec2f95bdf22adea8338057a5febbeb78dc3489e2 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Mon, 22 Oct 2018 02:02:52 +0200 Subject: [PATCH] Format town files --- Source/stores.cpp | 6531 +++++++++++++++++++++----------------------- Source/stores.h | 24 +- Source/town.cpp | 2960 ++++++++++---------- Source/towners.cpp | 2470 ++++++++--------- Source/towners.h | 12 +- 5 files changed, 5600 insertions(+), 6397 deletions(-) diff --git a/Source/stores.cpp b/Source/stores.cpp index 01ac4c26e..d0822a429 100644 --- a/Source/stores.cpp +++ b/Source/stores.cpp @@ -2,100 +2,98 @@ #include "../types.h" -int stextup; // weak -int storenumh; // weak +int stextup; // weak +int storenumh; // weak int stextlhold; // weak ItemStruct boyitem; int stextshold; // idb ItemStruct premiumitem[6]; void *pSTextBoxCels; int premiumlevel; // idb -int talker; // weak +int talker; // weak STextStruct stext[24]; -char stextsize; // weak -int stextsmax; // weak +char stextsize; // weak +int stextsmax; // weak int InStoreFlag; // idb ItemStruct storehold[48]; int gossipstart; // weak ItemStruct witchitem[20]; -int stextscrl; // weak +int stextscrl; // weak int numpremium; // idb ItemStruct healitem[20]; ItemStruct golditem; char storehidx[48]; void *pSTextSlidCels; -int stextvhold; // weak -int stextsel; // weak +int stextvhold; // weak +int stextsel; // weak char stextscrldbtn; // weak -int gossipend; // weak +int gossipend; // weak void *pCelBuff; int stextsval; // idb -int boylevel; // weak +int boylevel; // weak ItemStruct smithitem[20]; -int stextdown; // weak +int stextdown; // weak char stextscrlubtn; // weak -char stextflag; // weak - -int SStringY[24] = -{ - 0, - 12, - 24, - 36, - 48, - 60, - 72, - 84, - 96, - 108, - 120, - 132, - 144, - 156, - 168, - 180, - 192, - 204, - 216, - 228, - 240, - 252, - 264, - 276 +char stextflag; // weak + +int SStringY[24] = { + 0, + 12, + 24, + 36, + 48, + 60, + 72, + 84, + 96, + 108, + 120, + 132, + 144, + 156, + 168, + 180, + 192, + 204, + 216, + 228, + 240, + 252, + 264, + 276 }; -char *talkname[9] = -{ - "Griswold", - "Pepin", - &empty_string, - "Ogden", - "Cain", - "Farnham", - "Adria", - "Gillian", - "Wirt" +char *talkname[9] = { + "Griswold", + "Pepin", + &empty_string, + "Ogden", + "Cain", + "Farnham", + "Adria", + "Gillian", + "Wirt" }; void __cdecl InitStores() { - int i; // eax - - pSTextBoxCels = LoadFileInMem("Data\\TextBox2.CEL", 0); - pCelBuff = LoadFileInMem("Data\\PentSpn2.CEL", 0); - pSTextSlidCels = LoadFileInMem("Data\\TextSlid.CEL", 0); - ClearSText(0, 24); - stextflag = 0; - InStoreFlag = 1; - premiumlevel = 1; - stextsize = 0; - stextscrl = 0; - numpremium = 0; - - for(i = 0; i < 6; i++) - premiumitem[i]._itype = -1; - - boyitem._itype = -1; - boylevel = 0; + int i; // eax + + pSTextBoxCels = LoadFileInMem("Data\\TextBox2.CEL", 0); + pCelBuff = LoadFileInMem("Data\\PentSpn2.CEL", 0); + pSTextSlidCels = LoadFileInMem("Data\\TextSlid.CEL", 0); + ClearSText(0, 24); + stextflag = 0; + InStoreFlag = 1; + premiumlevel = 1; + stextsize = 0; + stextscrl = 0; + numpremium = 0; + + for (i = 0; i < 6; i++) + premiumitem[i]._itype = -1; + + boyitem._itype = -1; + boylevel = 0; } // 69FB38: using guessed type int talker; // 6A09E0: using guessed type char stextsize; @@ -105,57 +103,53 @@ void __cdecl InitStores() void __cdecl SetupTownStores() { - int i; // eax - int l; // esi - - SetRndSeed(glSeedTbl[currlevel] * GetTickCount()); - if ( gbMaxPlayers == 1 ) - { - l = 0; - for(i = 0; i < 17; i++) - { - if ( plr[myplr]._pLvlVisited[i] ) - l = i; - } - } - else - { - l = plr[myplr]._pLevel >> 1; - } - l += 2; - if ( l < 6 ) - l = 6; - if ( l > 16 ) - l = 16; - SpawnStoreGold(); - SpawnSmith(l); - SpawnWitch(l); - SpawnHealer(l); - SpawnBoy(plr[myplr]._pLevel); - SpawnPremium(plr[myplr]._pLevel); + int i; // eax + int l; // esi + + SetRndSeed(glSeedTbl[currlevel] * GetTickCount()); + if (gbMaxPlayers == 1) { + l = 0; + for (i = 0; i < 17; i++) { + if (plr[myplr]._pLvlVisited[i]) + l = i; + } + } else { + l = plr[myplr]._pLevel >> 1; + } + l += 2; + if (l < 6) + l = 6; + if (l > 16) + l = 16; + SpawnStoreGold(); + SpawnSmith(l); + SpawnWitch(l); + SpawnHealer(l); + SpawnBoy(plr[myplr]._pLevel); + SpawnPremium(plr[myplr]._pLevel); } // 679660: using guessed type char gbMaxPlayers; void __cdecl FreeStoreMem() { - void *v0; // ecx - void *v1; // ecx - void *v2; // ecx - - v0 = pSTextBoxCels; - pSTextBoxCels = 0; - mem_free_dbg(v0); - v1 = pCelBuff; - pCelBuff = 0; - mem_free_dbg(v1); - v2 = pSTextSlidCels; - pSTextSlidCels = 0; - mem_free_dbg(v2); + void *v0; // ecx + void *v1; // ecx + void *v2; // ecx + + v0 = pSTextBoxCels; + pSTextBoxCels = 0; + mem_free_dbg(v0); + v1 = pCelBuff; + pCelBuff = 0; + mem_free_dbg(v1); + v2 = pSTextSlidCels; + pSTextSlidCels = 0; + mem_free_dbg(v2); } void __cdecl DrawSTextBack() { - CelDecodeOnly(408, 487, pSTextBoxCels, 1, 271); + CelDecodeOnly(408, 487, pSTextBoxCels, 1, 271); #define TRANS_RECT_X 347 #define TRANS_RECT_Y 28 @@ -166,109 +160,98 @@ void __cdecl DrawSTextBack() void __fastcall PrintSString(int x, int y, unsigned char cjustflag, char *str, int col, int val) { - int v6; // edi - int v7; // eax - int v8; // ebx - int v9; // esi - int v10; // esi - int v11; // ecx - int v12; // eax - int v13; // edx - int v14; // ecx - unsigned char v15; // al - int v16; // ebx - int v17; // ecx - int v18; // eax - int v19; // esi - size_t v20; // ebx - unsigned char v21; // edx - int v22; // ecx - char valstr[32]; // [esp+Ch] [ebp-3Ch] - int v24; // [esp+2Ch] [ebp-1Ch] - int v25; // [esp+30h] [ebp-18h] - int v26; // [esp+34h] [ebp-14h] - int v27; // [esp+38h] [ebp-10h] - int v28; // [esp+3Ch] [ebp-Ch] - int v29; // [esp+40h] [ebp-8h] - int v30; // [esp+44h] [ebp-4h] - - v6 = SStringY[y] + stext[y]._syoff; - v7 = -(stextsize != 0); - v8 = x; - v9 = screen_y_times_768[v6 + 204]; - _LOWORD(v7) = v7 & 0xFEC0; - v24 = y; - v26 = x; - v27 = v7 + 416; - v10 = x + v7 + 416 + v9; - v28 = strlen(str); - v11 = 0; - v25 = stextsize != 0 ? 577 : 257; - v30 = 0; - if ( cjustflag ) - { - v12 = 0; - if ( v28 > 0 ) - { - do - { - v13 = (unsigned char)str[v11++]; - v12 += fontkern[fontframe[fontidx[v13]]] + 1; - } - while ( v11 < v28 ); - } - if ( v12 < v25 ) - v30 = (v25 - v12) >> 1; - v10 += v30; - } - if ( stextsel == v24 ) - { - if ( cjustflag ) - v14 = v27 + v30 + v8 - 20; - else - v14 = v27 + v8 - 20; - CelDecodeOnly(v14, v6 + 205, pCelBuff, InStoreFlag, 12); - } - v29 = 0; - if ( v28 > 0 ) - { - do - { - v15 = fontframe[fontidx[(unsigned char)str[v29]]]; - v16 = v15; - v17 = v30 + fontkern[v15] + 1; - v30 += fontkern[v15] + 1; - if ( v15 && v17 <= v25 ) - CPrintString(v10, v15, col); - v18 = fontkern[v16]; - ++v29; - v10 += v18 + 1; - } - while ( v29 < v28 ); - v8 = v26; - } - if ( !cjustflag && val >= 0 ) - { - sprintf(valstr, "%i", val); - v19 = screen_y_times_768[v6 + 204] - v8 + 656; - v20 = strlen(valstr); - while ( (--v20 & 0x80000000) == 0 ) - { - v21 = fontframe[fontidx[(unsigned char)valstr[v20]]]; - v19 += -1 - fontkern[v21]; - if ( fontframe[fontidx[(unsigned char)valstr[v20]]] ) - CPrintString(v19, v21, col); - } - v8 = v26; - } - if ( stextsel == v24 ) - { - if ( cjustflag ) - v22 = v27 + v30 + v8 + 4; - else - v22 = 660 - v8; - CelDecodeOnly(v22, v6 + 205, pCelBuff, InStoreFlag, 12); - } + int v6; // edi + int v7; // eax + int v8; // ebx + int v9; // esi + int v10; // esi + int v11; // ecx + int v12; // eax + int v13; // edx + int v14; // ecx + unsigned char v15; // al + int v16; // ebx + int v17; // ecx + int v18; // eax + int v19; // esi + size_t v20; // ebx + unsigned char v21; // edx + int v22; // ecx + char valstr[32]; // [esp+Ch] [ebp-3Ch] + int v24; // [esp+2Ch] [ebp-1Ch] + int v25; // [esp+30h] [ebp-18h] + int v26; // [esp+34h] [ebp-14h] + int v27; // [esp+38h] [ebp-10h] + int v28; // [esp+3Ch] [ebp-Ch] + int v29; // [esp+40h] [ebp-8h] + int v30; // [esp+44h] [ebp-4h] + + v6 = SStringY[y] + stext[y]._syoff; + v7 = -(stextsize != 0); + v8 = x; + v9 = screen_y_times_768[v6 + 204]; + _LOWORD(v7) = v7 & 0xFEC0; + v24 = y; + v26 = x; + v27 = v7 + 416; + v10 = x + v7 + 416 + v9; + v28 = strlen(str); + v11 = 0; + v25 = stextsize != 0 ? 577 : 257; + v30 = 0; + if (cjustflag) { + v12 = 0; + if (v28 > 0) { + do { + v13 = (unsigned char)str[v11++]; + v12 += fontkern[fontframe[fontidx[v13]]] + 1; + } while (v11 < v28); + } + if (v12 < v25) + v30 = (v25 - v12) >> 1; + v10 += v30; + } + if (stextsel == v24) { + if (cjustflag) + v14 = v27 + v30 + v8 - 20; + else + v14 = v27 + v8 - 20; + CelDecodeOnly(v14, v6 + 205, pCelBuff, InStoreFlag, 12); + } + v29 = 0; + if (v28 > 0) { + do { + v15 = fontframe[fontidx[(unsigned char)str[v29]]]; + v16 = v15; + v17 = v30 + fontkern[v15] + 1; + v30 += fontkern[v15] + 1; + if (v15 && v17 <= v25) + CPrintString(v10, v15, col); + v18 = fontkern[v16]; + ++v29; + v10 += v18 + 1; + } while (v29 < v28); + v8 = v26; + } + if (!cjustflag && val >= 0) { + sprintf(valstr, "%i", val); + v19 = screen_y_times_768[v6 + 204] - v8 + 656; + v20 = strlen(valstr); + while ((--v20 & 0x80000000) == 0) { + v21 = fontframe[fontidx[(unsigned char)valstr[v20]]]; + v19 += -1 - fontkern[v21]; + if (fontframe[fontidx[(unsigned char)valstr[v20]]]) + CPrintString(v19, v21, col); + } + v8 = v26; + } + if (stextsel == v24) { + if (cjustflag) + v22 = v27 + v30 + v8 + 4; + else + v22 = 660 - v8; + CelDecodeOnly(v22, v6 + 205, pCelBuff, InStoreFlag, 12); + } } // 6A09E0: using guessed type char stextsize; // 6A8A28: using guessed type int stextsel; @@ -276,85 +259,79 @@ void __fastcall PrintSString(int x, int y, unsigned char cjustflag, char *str, i void __fastcall DrawSLine(int y) { - int v1; // eax - int v2; // eax - char *v3; // esi - char *v4; // edi - signed int v5; // edx - char *v6; // edi - char *v7; // esi - signed int v8; // [esp+0h] [ebp-10h] - signed int v9; // [esp+8h] [ebp-8h] - signed int v10; // [esp+Ch] [ebp-4h] - - v1 = screen_y_times_768[SStringY[y] + 198]; - if ( stextsize == 1 ) - { - v8 = 142170; - v2 = v1 + 90; - v10 = 146; - v9 = 182; - } - else - { - v8 = 142490; - v2 = v1 + 410; - v10 = 66; - v9 = 502; - } - v3 = (char *)gpBuffer + v8; - v4 = (char *)gpBuffer + v2; - v5 = 3; - do - { - qmemcpy(v4, v3, 4 * v10); - v7 = &v3[4 * v10]; - v6 = &v4[4 * v10]; - *(_WORD *)v6 = *(_WORD *)v7; - v3 = &v7[v9 + 2]; - v4 = &v6[v9 + 2]; - --v5; - } - while ( v5 ); + int v1; // eax + int v2; // eax + char *v3; // esi + char *v4; // edi + signed int v5; // edx + char *v6; // edi + char *v7; // esi + signed int v8; // [esp+0h] [ebp-10h] + signed int v9; // [esp+8h] [ebp-8h] + signed int v10; // [esp+Ch] [ebp-4h] + + v1 = screen_y_times_768[SStringY[y] + 198]; + if (stextsize == 1) { + v8 = 142170; + v2 = v1 + 90; + v10 = 146; + v9 = 182; + } else { + v8 = 142490; + v2 = v1 + 410; + v10 = 66; + v9 = 502; + } + v3 = (char *)gpBuffer + v8; + v4 = (char *)gpBuffer + v2; + v5 = 3; + do { + qmemcpy(v4, v3, 4 * v10); + v7 = &v3[4 * v10]; + v6 = &v4[4 * v10]; + *(_WORD *)v6 = *(_WORD *)v7; + v3 = &v7[v9 + 2]; + v4 = &v6[v9 + 2]; + --v5; + } while (v5); } // 6A09E0: using guessed type char stextsize; void __fastcall DrawSArrows(int y1, int y2) { - int *v2; // ebp - int v3; // ebx - int v4; // edi - int v5; // esi - int v6; // eax - int v7; // eax - - v2 = &SStringY[y2]; - v3 = y1; - v4 = SStringY[y1] + 204; - v5 = *v2 + 204; - if ( stextscrlubtn == -1 ) - CelDecodeOnly(665, v4, pSTextSlidCels, 10, 12); - else - CelDecodeOnly(665, v4, pSTextSlidCels, 12, 12); - if ( stextscrldbtn == -1 ) - CelDecodeOnly(665, v5, pSTextSlidCels, 9, 12); - else - CelDecodeOnly(665, v5, pSTextSlidCels, 11, 12); - while ( 1 ) - { - v4 += 12; - if ( v4 >= v5 ) - break; - CelDecodeOnly(665, v4, pSTextSlidCels, 14, 12); - } - v6 = stextsel; - if ( stextsel == 22 ) - v6 = stextlhold; - if ( storenumh <= 1 ) - v7 = 0; - else - v7 = (*v2 - SStringY[v3] - 24) * (1000 * (stextsval + ((v6 - stextup) >> 2)) / (storenumh - 1)) / 1000; - CelDecodeOnly(665, SStringY[v3 + 1] + v7 + 204, pSTextSlidCels, 13, 12); + int *v2; // ebp + int v3; // ebx + int v4; // edi + int v5; // esi + int v6; // eax + int v7; // eax + + v2 = &SStringY[y2]; + v3 = y1; + v4 = SStringY[y1] + 204; + v5 = *v2 + 204; + if (stextscrlubtn == -1) + CelDecodeOnly(665, v4, pSTextSlidCels, 10, 12); + else + CelDecodeOnly(665, v4, pSTextSlidCels, 12, 12); + if (stextscrldbtn == -1) + CelDecodeOnly(665, v5, pSTextSlidCels, 9, 12); + else + CelDecodeOnly(665, v5, pSTextSlidCels, 11, 12); + while (1) { + v4 += 12; + if (v4 >= v5) + break; + CelDecodeOnly(665, v4, pSTextSlidCels, 14, 12); + } + v6 = stextsel; + if (stextsel == 22) + v6 = stextlhold; + if (storenumh <= 1) + v7 = 0; + else + v7 = (*v2 - SStringY[v3] - 24) * (1000 * (stextsval + ((v6 - stextup) >> 2)) / (storenumh - 1)) / 1000; + CelDecodeOnly(665, SStringY[v3 + 1] + v7 + 204, pSTextSlidCels, 13, 12); } // 69F108: using guessed type int stextup; // 69F10C: using guessed type int storenumh; @@ -365,288 +342,242 @@ void __fastcall DrawSArrows(int y1, int y2) void __cdecl DrawSTextHelp() { - stextsel = -1; - stextsize = 1; + stextsel = -1; + stextsize = 1; } // 6A09E0: using guessed type char stextsize; // 6A8A28: using guessed type int stextsel; void __fastcall ClearSText(int s, int e) { - int v2; // edx - int *v3; // eax - - if ( s < e ) - { - v2 = e - s; - v3 = &stext[s]._syoff; - do - { - v3[37] = -1; - *(v3 - 1) = 0; - *v3 = 0; - *((_BYTE *)v3 + 4) = 0; - v3[33] = 0; - *((_BYTE *)v3 + 136) = 0; - v3[35] = 0; - v3[36] = 0; - v3 += 39; - --v2; - } - while ( v2 ); - } + int v2; // edx + int *v3; // eax + + if (s < e) { + v2 = e - s; + v3 = &stext[s]._syoff; + do { + v3[37] = -1; + *(v3 - 1) = 0; + *v3 = 0; + *((_BYTE *)v3 + 4) = 0; + v3[33] = 0; + *((_BYTE *)v3 + 136) = 0; + v3[35] = 0; + v3[36] = 0; + v3 += 39; + --v2; + } while (v2); + } } void __fastcall AddSLine(int y) { - int v1; // ecx + int v1; // ecx - v1 = y; - stext[v1]._sx = 0; - stext[v1]._syoff = 0; - stext[v1]._sstr[0] = 0; - stext[v1]._sline = 1; + v1 = y; + stext[v1]._sx = 0; + stext[v1]._syoff = 0; + stext[v1]._sstr[0] = 0; + stext[v1]._sline = 1; } void __fastcall AddSTextVal(int y, int val) { - stext[y]._sval = val; + stext[y]._sval = val; } void __fastcall OffsetSTextY(int y, int yo) { - stext[y]._syoff = yo; + stext[y]._syoff = yo; } void __fastcall AddSText(int x, int y, unsigned char j, char *str, int clr, int sel) { - int v6; // esi - - v6 = y; - stext[v6]._syoff = 0; - stext[v6]._sx = x; - strcpy(stext[y]._sstr, str); - stext[v6]._sline = 0; - stext[v6]._sjust = j; - _LOBYTE(stext[v6]._sclr) = clr; - stext[v6]._ssel = sel; + int v6; // esi + + v6 = y; + stext[v6]._syoff = 0; + stext[v6]._sx = x; + strcpy(stext[y]._sstr, str); + stext[v6]._sline = 0; + stext[v6]._sjust = j; + _LOBYTE(stext[v6]._sclr) = clr; + stext[v6]._ssel = sel; } void __cdecl StoreAutoPlace() { - int v0; // edi - int v1; // eax - int v2; // edx - ItemStruct *v3; // ebp - int v4; // esi - int v5; // esi - int v6; // esi - int v7; // esi - int v8; // esi - int v9; // esi - int v10; // esi - int v11; // esi - int *v12; // esi - int v13; // esi - int v14; // esi - int v15; // esi - int v16; // esi - int v17; // esi - signed int v19; // [esp+10h] [ebp-Ch] - int v20; // [esp+14h] [ebp-8h] - int v21; // [esp+18h] [ebp-4h] - - SetICursor(plr[myplr].HoldItem._iCurs + 12); - v0 = icursH28; - v1 = 0; - v21 = icursW28; - v20 = icursH28; - if ( icursW28 == 1 ) - { - if ( icursH28 == 1 ) - { - v2 = myplr; - if ( plr[myplr].HoldItem._iStatFlag && AllItemsList[plr[v2].HoldItem.IDidx].iUsable ) - { - v19 = 0; - v3 = plr[v2].SpdList; - do - { - if ( v1 ) - break; - if ( v3->_itype == -1 ) - { - qmemcpy(v3, &plr[v2].HoldItem, sizeof(ItemStruct)); - v0 = v20; - v1 = 1; - } - ++v19; - ++v3; - } - while ( v19 < 8 ); - } - v4 = 30; - do - { - if ( v1 ) - break; - v1 = AutoPlace(myplr, v4++, 1, 1, 1); - } - while ( v4 <= 39 ); - v5 = 20; - do - { - if ( v1 ) - break; - v1 = AutoPlace(myplr, v5++, 1, 1, 1); - } - while ( v5 <= 29 ); - v6 = 10; - do - { - if ( v1 ) - break; - v1 = AutoPlace(myplr, v6++, 1, 1, 1); - } - while ( v6 <= 19 ); - v7 = 0; - while ( !v1 ) - { - v1 = AutoPlace(myplr, v7++, 1, 1, 1); - if ( v7 > 9 ) - goto LABEL_22; - } - } - else - { -LABEL_22: - if ( v0 == 2 ) - { - v8 = 29; - do - { - if ( v1 ) - break; - v1 = AutoPlace(myplr, v8--, 1, 2, 1); - } - while ( v8 >= 20 ); - v9 = 9; - do - { - if ( v1 ) - break; - v1 = AutoPlace(myplr, v9--, 1, 2, 1); - } - while ( v9 >= 0 ); - v10 = 19; - while ( !v1 ) - { - v1 = AutoPlace(myplr, v10--, 1, 2, 1); - if ( v10 < 10 ) - goto LABEL_32; - } - } - else - { -LABEL_32: - if ( v0 == 3 ) - { - v11 = 0; - while ( !v1 ) - { - v1 = AutoPlace(myplr, v11++, 1, 3, 1); - if ( v11 >= 20 ) - goto LABEL_36; - } - } - } - } - } - else - { -LABEL_36: - if ( v21 == 2 ) - { - if ( v0 == 2 ) - { - v12 = AP2x2Tbl; - do - { - if ( v1 ) - break; - v1 = AutoPlace(myplr, *v12, 2, 2, 1); - ++v12; - } - while ( (signed int)v12 < (signed int)&AP2x2Tbl[10] ); - v13 = 21; - do - { - if ( v1 ) - break; - v1 = AutoPlace(myplr, v13, 2, 2, 1); - v13 += 2; - } - while ( v13 < 29 ); - v14 = 1; - do - { - if ( v1 ) - break; - v1 = AutoPlace(myplr, v14, 2, 2, 1); - v14 += 2; - } - while ( v14 < 9 ); - v15 = 10; - while ( !v1 ) - { - v1 = AutoPlace(myplr, v15++, 2, 2, 1); - if ( v15 >= 19 ) - goto LABEL_50; - } - } - else - { -LABEL_50: - if ( v0 == 3 ) - { - v16 = 0; - do - { - if ( v1 ) - break; - v1 = AutoPlace(myplr, v16++, 2, 3, 1); - } - while ( v16 < 9 ); - v17 = 10; - do - { - if ( v1 ) - break; - v1 = AutoPlace(myplr, v17++, 2, 3, 1); - } - while ( v17 < 19 ); - } - } - } - } + int v0; // edi + int v1; // eax + int v2; // edx + ItemStruct *v3; // ebp + int v4; // esi + int v5; // esi + int v6; // esi + int v7; // esi + int v8; // esi + int v9; // esi + int v10; // esi + int v11; // esi + int *v12; // esi + int v13; // esi + int v14; // esi + int v15; // esi + int v16; // esi + int v17; // esi + signed int v19; // [esp+10h] [ebp-Ch] + int v20; // [esp+14h] [ebp-8h] + int v21; // [esp+18h] [ebp-4h] + + SetICursor(plr[myplr].HoldItem._iCurs + 12); + v0 = icursH28; + v1 = 0; + v21 = icursW28; + v20 = icursH28; + if (icursW28 == 1) { + if (icursH28 == 1) { + v2 = myplr; + if (plr[myplr].HoldItem._iStatFlag && AllItemsList[plr[v2].HoldItem.IDidx].iUsable) { + v19 = 0; + v3 = plr[v2].SpdList; + do { + if (v1) + break; + if (v3->_itype == -1) { + qmemcpy(v3, &plr[v2].HoldItem, sizeof(ItemStruct)); + v0 = v20; + v1 = 1; + } + ++v19; + ++v3; + } while (v19 < 8); + } + v4 = 30; + do { + if (v1) + break; + v1 = AutoPlace(myplr, v4++, 1, 1, 1); + } while (v4 <= 39); + v5 = 20; + do { + if (v1) + break; + v1 = AutoPlace(myplr, v5++, 1, 1, 1); + } while (v5 <= 29); + v6 = 10; + do { + if (v1) + break; + v1 = AutoPlace(myplr, v6++, 1, 1, 1); + } while (v6 <= 19); + v7 = 0; + while (!v1) { + v1 = AutoPlace(myplr, v7++, 1, 1, 1); + if (v7 > 9) + goto LABEL_22; + } + } else { + LABEL_22: + if (v0 == 2) { + v8 = 29; + do { + if (v1) + break; + v1 = AutoPlace(myplr, v8--, 1, 2, 1); + } while (v8 >= 20); + v9 = 9; + do { + if (v1) + break; + v1 = AutoPlace(myplr, v9--, 1, 2, 1); + } while (v9 >= 0); + v10 = 19; + while (!v1) { + v1 = AutoPlace(myplr, v10--, 1, 2, 1); + if (v10 < 10) + goto LABEL_32; + } + } else { + LABEL_32: + if (v0 == 3) { + v11 = 0; + while (!v1) { + v1 = AutoPlace(myplr, v11++, 1, 3, 1); + if (v11 >= 20) + goto LABEL_36; + } + } + } + } + } else { + LABEL_36: + if (v21 == 2) { + if (v0 == 2) { + v12 = AP2x2Tbl; + do { + if (v1) + break; + v1 = AutoPlace(myplr, *v12, 2, 2, 1); + ++v12; + } while ((signed int)v12 < (signed int)&AP2x2Tbl[10]); + v13 = 21; + do { + if (v1) + break; + v1 = AutoPlace(myplr, v13, 2, 2, 1); + v13 += 2; + } while (v13 < 29); + v14 = 1; + do { + if (v1) + break; + v1 = AutoPlace(myplr, v14, 2, 2, 1); + v14 += 2; + } while (v14 < 9); + v15 = 10; + while (!v1) { + v1 = AutoPlace(myplr, v15++, 2, 2, 1); + if (v15 >= 19) + goto LABEL_50; + } + } else { + LABEL_50: + if (v0 == 3) { + v16 = 0; + do { + if (v1) + break; + v1 = AutoPlace(myplr, v16++, 2, 3, 1); + } while (v16 < 9); + v17 = 10; + do { + if (v1) + break; + v1 = AutoPlace(myplr, v17++, 2, 3, 1); + } while (v17 < 19); + } + } + } + } } // 48E9A8: using guessed type int AP2x2Tbl[10]; void __cdecl S_StartSmith() { - stextsize = 0; - stextscrl = 0; - AddSText(0, 1, 1u, "Welcome to the", COL_GOLD, 0); - AddSText(0, 3, 1u, "Blacksmith's shop", COL_GOLD, 0); - AddSText(0, 7, 1u, "Would you like to:", COL_GOLD, 0); - AddSText(0, 10, 1u, "Talk to Griswold", COL_BLUE, 1); - AddSText(0, 12, 1u, "Buy basic items", COL_WHITE, 1); - AddSText(0, 14, 1u, "Buy premium items", COL_WHITE, 1); - AddSText(0, 16, 1u, "Sell items", COL_WHITE, 1); - AddSText(0, 18, 1u, "Repair items", COL_WHITE, 1); - AddSText(0, 20, 1u, "Leave the shop", COL_WHITE, 1); - AddSLine(5); - storenumh = 20; + stextsize = 0; + stextscrl = 0; + AddSText(0, 1, 1u, "Welcome to the", COL_GOLD, 0); + AddSText(0, 3, 1u, "Blacksmith's shop", COL_GOLD, 0); + AddSText(0, 7, 1u, "Would you like to:", COL_GOLD, 0); + AddSText(0, 10, 1u, "Talk to Griswold", COL_BLUE, 1); + AddSText(0, 12, 1u, "Buy basic items", COL_WHITE, 1); + AddSText(0, 14, 1u, "Buy premium items", COL_WHITE, 1); + AddSText(0, 16, 1u, "Sell items", COL_WHITE, 1); + AddSText(0, 18, 1u, "Repair items", COL_WHITE, 1); + AddSText(0, 20, 1u, "Leave the shop", COL_WHITE, 1); + AddSLine(5); + storenumh = 20; } // 69F10C: using guessed type int storenumh; // 6A09E0: using guessed type char stextsize; @@ -654,40 +585,37 @@ void __cdecl S_StartSmith() void __fastcall S_ScrollSBuy(int idx) { - int v1; // esi - int v2; // edi - char *v3; // esi - char *v4; // eax - int iclr; // [esp+Ch] [ebp-4h] - - v1 = idx; - v2 = 5; - ClearSText(5, 21); - v3 = &smithitem[v1]._iMagical; - stextup = 5; - do - { - if ( *((_DWORD *)v3 - 13) != -1 ) - { - _LOBYTE(iclr) = COL_WHITE; - if ( *v3 ) - _LOBYTE(iclr) = COL_BLUE; - if ( !*((_DWORD *)v3 + 74) ) - _LOBYTE(iclr) = COL_RED; - v4 = v3 + 65; - if ( !*v3 ) - v4 = v3 + 1; - AddSText(20, v2, 0, v4, iclr, 1); - AddSTextVal(v2, *((_DWORD *)v3 + 35)); - PrintStoreItem((ItemStruct *)(v3 - 60), v2 + 1, iclr); - stextdown = v2; - v3 += 368; - } - v2 += 4; - } - while ( v2 < 20 ); - if ( !stext[stextsel]._ssel && stextsel != 22 ) - stextsel = stextdown; + int v1; // esi + int v2; // edi + char *v3; // esi + char *v4; // eax + int iclr; // [esp+Ch] [ebp-4h] + + v1 = idx; + v2 = 5; + ClearSText(5, 21); + v3 = &smithitem[v1]._iMagical; + stextup = 5; + do { + if (*((_DWORD *)v3 - 13) != -1) { + _LOBYTE(iclr) = COL_WHITE; + if (*v3) + _LOBYTE(iclr) = COL_BLUE; + if (!*((_DWORD *)v3 + 74)) + _LOBYTE(iclr) = COL_RED; + v4 = v3 + 65; + if (!*v3) + v4 = v3 + 1; + AddSText(20, v2, 0, v4, iclr, 1); + AddSTextVal(v2, *((_DWORD *)v3 + 35)); + PrintStoreItem((ItemStruct *)(v3 - 60), v2 + 1, iclr); + stextdown = v2; + v3 += 368; + } + v2 += 4; + } while (v2 < 20); + if (!stext[stextsel]._ssel && stextsel != 22) + stextsel = stextdown; } // 69F108: using guessed type int stextup; // 6A8A28: using guessed type int stextsel; @@ -695,126 +623,111 @@ void __fastcall S_ScrollSBuy(int idx) void __fastcall PrintStoreItem(ItemStruct *x, int l, char iclr) { - ItemStruct *v3; // esi - char v5; // cl - char v6; // cl - int v7; // eax - char v8; // al - unsigned char v9; // al - char v10; // al - int v11; // edi - char sstr[128]; // [esp+Ch] [ebp-84h] - int y; // [esp+8Ch] [ebp-4h] - - sstr[0] = 0; - v3 = x; - y = l; - if ( x->_iIdentified ) - { - if ( x->_iMagical != ITEM_QUALITY_UNIQUE ) - { - v5 = x->_iPrePower; - if ( v5 != -1 ) - { - PrintItemPower(v5, v3); - strcat(sstr, tempstr); - } - } - v6 = v3->_iSufPower; - if ( v6 != -1 ) - { - PrintItemPower(v6, v3); - if ( sstr[0] ) - strcat(sstr, ", "); - strcat(sstr, tempstr); - } - } - if ( v3->_iMiscId == IMISC_STAFF && v3->_iMaxCharges ) - { - sprintf(tempstr, "Charges: %i/%i", v3->_iCharges, v3->_iMaxCharges); - if ( sstr[0] ) - strcat(sstr, ", "); - strcat(sstr, tempstr); - } - if ( sstr[0] ) - AddSText(40, y++, 0, sstr, iclr, 0); - sstr[0] = 0; - if ( v3->_iClass == 1 ) - sprintf(sstr, "Damage: %i-%i ", v3->_iMinDam, v3->_iMaxDam); - if ( v3->_iClass == 2 ) - sprintf(sstr, "Armor: %i ", v3->_iAC); - v7 = v3->_iMaxDur; - if ( v7 != 255 && v7 ) - { - sprintf(tempstr, "Dur: %i/%i, ", v3->_iDurability, v3->_iMaxDur); - strcat(sstr, tempstr); - } - else - { - strcat(sstr, "Indestructible, "); - } - if ( !v3->_itype ) - sstr[0] = 0; - if ( v3->_iMinStr + (unsigned char)v3->_iMinMag + v3->_iMinDex ) - { - strcpy(tempstr, "Required:"); - v8 = v3->_iMinStr; - if ( v8 ) - sprintf(tempstr, "%s %i Str", tempstr, v8); - v9 = v3->_iMinMag; - if ( v9 ) - sprintf(tempstr, "%s %i Mag", tempstr, v9); - v10 = v3->_iMinDex; - if ( v10 ) - sprintf(tempstr, "%s %i Dex", tempstr, v10); - strcat(sstr, tempstr); - } - else - { - strcat(sstr, "No required attributes"); - } - v11 = y; - AddSText(40, y, 0, sstr, iclr, 0); - if ( v3->_iMagical == ITEM_QUALITY_UNIQUE ) - { - if ( v3->_iIdentified ) - AddSText(40, v11 + 1, 0, "Unique Item", iclr, 0); - } + ItemStruct *v3; // esi + char v5; // cl + char v6; // cl + int v7; // eax + char v8; // al + unsigned char v9; // al + char v10; // al + int v11; // edi + char sstr[128]; // [esp+Ch] [ebp-84h] + int y; // [esp+8Ch] [ebp-4h] + + sstr[0] = 0; + v3 = x; + y = l; + if (x->_iIdentified) { + if (x->_iMagical != ITEM_QUALITY_UNIQUE) { + v5 = x->_iPrePower; + if (v5 != -1) { + PrintItemPower(v5, v3); + strcat(sstr, tempstr); + } + } + v6 = v3->_iSufPower; + if (v6 != -1) { + PrintItemPower(v6, v3); + if (sstr[0]) + strcat(sstr, ", "); + strcat(sstr, tempstr); + } + } + if (v3->_iMiscId == IMISC_STAFF && v3->_iMaxCharges) { + sprintf(tempstr, "Charges: %i/%i", v3->_iCharges, v3->_iMaxCharges); + if (sstr[0]) + strcat(sstr, ", "); + strcat(sstr, tempstr); + } + if (sstr[0]) + AddSText(40, y++, 0, sstr, iclr, 0); + sstr[0] = 0; + if (v3->_iClass == 1) + sprintf(sstr, "Damage: %i-%i ", v3->_iMinDam, v3->_iMaxDam); + if (v3->_iClass == 2) + sprintf(sstr, "Armor: %i ", v3->_iAC); + v7 = v3->_iMaxDur; + if (v7 != 255 && v7) { + sprintf(tempstr, "Dur: %i/%i, ", v3->_iDurability, v3->_iMaxDur); + strcat(sstr, tempstr); + } else { + strcat(sstr, "Indestructible, "); + } + if (!v3->_itype) + sstr[0] = 0; + if (v3->_iMinStr + (unsigned char)v3->_iMinMag + v3->_iMinDex) { + strcpy(tempstr, "Required:"); + v8 = v3->_iMinStr; + if (v8) + sprintf(tempstr, "%s %i Str", tempstr, v8); + v9 = v3->_iMinMag; + if (v9) + sprintf(tempstr, "%s %i Mag", tempstr, v9); + v10 = v3->_iMinDex; + if (v10) + sprintf(tempstr, "%s %i Dex", tempstr, v10); + strcat(sstr, tempstr); + } else { + strcat(sstr, "No required attributes"); + } + v11 = y; + AddSText(40, y, 0, sstr, iclr, 0); + if (v3->_iMagical == ITEM_QUALITY_UNIQUE) { + if (v3->_iIdentified) + AddSText(40, v11 + 1, 0, "Unique Item", iclr, 0); + } } void __cdecl S_StartSBuy() { - int v0; // ST10_4 - int v1; // eax - int *v2; // ecx - - v0 = plr[myplr]._pGold; - stextsize = 1; - stextscrl = 1; - stextsval = 0; - sprintf(tempstr, "I have these items for sale : Your gold : %i", v0); - AddSText(0, 1, 1u, tempstr, COL_GOLD, 0); - AddSLine(3); - AddSLine(21); - S_ScrollSBuy(stextsval); - AddSText(0, 22, 1u, "Back", COL_WHITE, 0); - OffsetSTextY(22, 6); - v1 = 0; - storenumh = 0; - if ( smithitem[0]._itype != -1 ) - { - v2 = &smithitem[0]._itype; - do - { - v2 += 92; - ++v1; - } - while ( *v2 != -1 ); - storenumh = v1; - } - stextsmax = v1 - 4; - if ( v1 - 4 < 0 ) - stextsmax = 0; + int v0; // ST10_4 + int v1; // eax + int *v2; // ecx + + v0 = plr[myplr]._pGold; + stextsize = 1; + stextscrl = 1; + stextsval = 0; + sprintf(tempstr, "I have these items for sale : Your gold : %i", v0); + AddSText(0, 1, 1u, tempstr, COL_GOLD, 0); + AddSLine(3); + AddSLine(21); + S_ScrollSBuy(stextsval); + AddSText(0, 22, 1u, "Back", COL_WHITE, 0); + OffsetSTextY(22, 6); + v1 = 0; + storenumh = 0; + if (smithitem[0]._itype != -1) { + v2 = &smithitem[0]._itype; + do { + v2 += 92; + ++v1; + } while (*v2 != -1); + storenumh = v1; + } + stextsmax = v1 - 4; + if (v1 - 4 < 0) + stextsmax = 0; } // 69F10C: using guessed type int storenumh; // 6A09E0: using guessed type char stextsize; @@ -823,59 +736,51 @@ void __cdecl S_StartSBuy() void __fastcall S_ScrollSPBuy(int idx) { - int v1; // esi - int v2; // edi - int v3; // eax - int v4; // esi - int *v5; // ecx - char *v6; // esi - int iclr; // [esp+Ch] [ebp-4h] - - v1 = idx; - v2 = 5; - ClearSText(5, 21); - v3 = v1; - v4 = 0; - stextup = 5; - if ( v3 ) - { - v5 = &premiumitem[0]._itype; - do - { - if ( *v5 != -1 ) - --v3; - ++v4; - v5 += 92; - } - while ( v3 ); - } - v6 = &premiumitem[v4]._iMagical; - do - { - if ( (signed int)v6 >= (signed int)&premiumitem[6]._iMagical ) - break; - if ( *((_DWORD *)v6 - 13) == -1 ) - { - v2 -= 4; - } - else - { - _LOBYTE(iclr) = COL_WHITE; - if ( *v6 ) - _LOBYTE(iclr) = COL_BLUE; - if ( !*((_DWORD *)v6 + 74) ) - _LOBYTE(iclr) = COL_RED; - AddSText(20, v2, 0, v6 + 65, iclr, 1); - AddSTextVal(v2, *((_DWORD *)v6 + 35)); - PrintStoreItem((ItemStruct *)(v6 - 60), v2 + 1, iclr); - stextdown = v2; - } - v2 += 4; - v6 += 368; - } - while ( v2 < 20 ); - if ( !stext[stextsel]._ssel && stextsel != 22 ) - stextsel = stextdown; + int v1; // esi + int v2; // edi + int v3; // eax + int v4; // esi + int *v5; // ecx + char *v6; // esi + int iclr; // [esp+Ch] [ebp-4h] + + v1 = idx; + v2 = 5; + ClearSText(5, 21); + v3 = v1; + v4 = 0; + stextup = 5; + if (v3) { + v5 = &premiumitem[0]._itype; + do { + if (*v5 != -1) + --v3; + ++v4; + v5 += 92; + } while (v3); + } + v6 = &premiumitem[v4]._iMagical; + do { + if ((signed int)v6 >= (signed int)&premiumitem[6]._iMagical) + break; + if (*((_DWORD *)v6 - 13) == -1) { + v2 -= 4; + } else { + _LOBYTE(iclr) = COL_WHITE; + if (*v6) + _LOBYTE(iclr) = COL_BLUE; + if (!*((_DWORD *)v6 + 74)) + _LOBYTE(iclr) = COL_RED; + AddSText(20, v2, 0, v6 + 65, iclr, 1); + AddSTextVal(v2, *((_DWORD *)v6 + 35)); + PrintStoreItem((ItemStruct *)(v6 - 60), v2 + 1, iclr); + stextdown = v2; + } + v2 += 4; + v6 += 368; + } while (v2 < 20); + if (!stext[stextsel]._ssel && stextsel != 22) + stextsel = stextdown; } // 69F108: using guessed type int stextup; // 6A8A28: using guessed type int stextsel; @@ -883,44 +788,39 @@ void __fastcall S_ScrollSPBuy(int idx) bool __cdecl S_StartSPBuy() { - int *v0; // eax - bool result; // al - int v2; // ST10_4 - - storenumh = 0; - v0 = &premiumitem[0]._itype; - do - { - if ( *v0 != -1 ) - ++storenumh; - v0 += 92; - } - while ( (signed int)v0 < (signed int)&premiumitem[6]._itype ); - if ( storenumh ) - { - v2 = plr[myplr]._pGold; - stextsval = 0; - stextsize = 1; - stextscrl = 1; - sprintf(tempstr, "I have these premium items for sale : Your gold : %i", v2); - AddSText(0, 1, 1u, tempstr, COL_GOLD, 0); - AddSLine(3); - AddSLine(21); - AddSText(0, 22, 1u, "Back", COL_WHITE, 0); - OffsetSTextY(22, 6); - stextsmax = storenumh - 4; - if ( storenumh - 4 < 0 ) - stextsmax = 0; - S_ScrollSPBuy(stextsval); - result = 1; - } - else - { - StartStore(STORE_SMITH); - stextsel = 14; - result = 0; - } - return result; + int *v0; // eax + bool result; // al + int v2; // ST10_4 + + storenumh = 0; + v0 = &premiumitem[0]._itype; + do { + if (*v0 != -1) + ++storenumh; + v0 += 92; + } while ((signed int)v0 < (signed int)&premiumitem[6]._itype); + if (storenumh) { + v2 = plr[myplr]._pGold; + stextsval = 0; + stextsize = 1; + stextscrl = 1; + sprintf(tempstr, "I have these premium items for sale : Your gold : %i", v2); + AddSText(0, 1, 1u, tempstr, COL_GOLD, 0); + AddSLine(3); + AddSLine(21); + AddSText(0, 22, 1u, "Back", COL_WHITE, 0); + OffsetSTextY(22, 6); + stextsmax = storenumh - 4; + if (storenumh - 4 < 0) + stextsmax = 0; + S_ScrollSPBuy(stextsval); + result = 1; + } else { + StartStore(STORE_SMITH); + stextsel = 14; + result = 0; + } + return result; } // 69F10C: using guessed type int storenumh; // 69FB38: using guessed type int talker; @@ -931,64 +831,58 @@ bool __cdecl S_StartSPBuy() bool __fastcall SmithSellOk(int i) { - if ( plr[myplr].InvList[i]._itype != ITYPE_NONE - && plr[myplr].InvList[i]._itype - && plr[myplr].InvList[i]._itype != ITYPE_GOLD - && plr[myplr].InvList[i]._itype != ITYPE_0E - && plr[myplr].InvList[i]._itype != ITYPE_STAFF ) - return plr[myplr].InvList[i].IDidx != IDI_LAZSTAFF; - else - return 0; + if (plr[myplr].InvList[i]._itype != ITYPE_NONE + && plr[myplr].InvList[i]._itype + && plr[myplr].InvList[i]._itype != ITYPE_GOLD + && plr[myplr].InvList[i]._itype != ITYPE_0E + && plr[myplr].InvList[i]._itype != ITYPE_STAFF) + return plr[myplr].InvList[i].IDidx != IDI_LAZSTAFF; + else + return 0; } void __fastcall S_ScrollSSell(int idx) { - int v1; // esi - int v2; // edi - char *v3; // esi - int v4; // edx - int v5; // [esp+Ch] [ebp-8h] - int iclr; // [esp+10h] [ebp-4h] - - v1 = idx; - v5 = idx; - v2 = 5; - ClearSText(5, 21); - v3 = &storehold[v1]._iMagical; - stextup = 5; - do - { - if ( v5 >= storenumh ) - break; - if ( *((_DWORD *)v3 - 13) != -1 ) - { - _LOBYTE(iclr) = 0; - if ( *v3 ) - _LOBYTE(iclr) = 1; - if ( !*((_DWORD *)v3 + 74) ) - _LOBYTE(iclr) = 2; - if ( *v3 && *((_DWORD *)v3 - 1) ) - { - AddSText(20, v2, 0, v3 + 65, iclr, 1); - v4 = *((_DWORD *)v3 + 35); - } - else - { - AddSText(20, v2, 0, v3 + 1, iclr, 1); - v4 = *((_DWORD *)v3 + 34); - } - AddSTextVal(v2, v4); - PrintStoreItem((ItemStruct *)(v3 - 60), v2 + 1, iclr); - stextdown = v2; - } - ++v5; - v2 += 4; - v3 += 368; - } - while ( v2 < 20 ); - stextsmax = storenumh - 4; - if ( storenumh - 4 < 0 ) - stextsmax = 0; + int v1; // esi + int v2; // edi + char *v3; // esi + int v4; // edx + int v5; // [esp+Ch] [ebp-8h] + int iclr; // [esp+10h] [ebp-4h] + + v1 = idx; + v5 = idx; + v2 = 5; + ClearSText(5, 21); + v3 = &storehold[v1]._iMagical; + stextup = 5; + do { + if (v5 >= storenumh) + break; + if (*((_DWORD *)v3 - 13) != -1) { + _LOBYTE(iclr) = 0; + if (*v3) + _LOBYTE(iclr) = 1; + if (!*((_DWORD *)v3 + 74)) + _LOBYTE(iclr) = 2; + if (*v3 && *((_DWORD *)v3 - 1)) { + AddSText(20, v2, 0, v3 + 65, iclr, 1); + v4 = *((_DWORD *)v3 + 35); + } else { + AddSText(20, v2, 0, v3 + 1, iclr, 1); + v4 = *((_DWORD *)v3 + 34); + } + AddSTextVal(v2, v4); + PrintStoreItem((ItemStruct *)(v3 - 60), v2 + 1, iclr); + stextdown = v2; + } + ++v5; + v2 += 4; + v3 += 368; + } while (v2 < 20); + stextsmax = storenumh - 4; + if (storenumh - 4 < 0) + stextsmax = 0; } // 69F108: using guessed type int stextup; // 69F10C: using guessed type int storenumh; @@ -997,57 +891,52 @@ void __fastcall S_ScrollSSell(int idx) void __cdecl S_StartSSell() { - int i; // eax - bool sellok; // [esp+14h] [ebp-4h] - - stextsize = 1; - sellok = 0; - storenumh = 0; - - for(i = 0; i < 48; i++) - storehold[i]._itype = -1; - - for(i = 0; i < plr[myplr]._pNumInv; i++) - { - if ( SmithSellOk(i) ) - { - sellok = 1; - qmemcpy(&storehold[storenumh], &plr[myplr].InvList[i], sizeof(ItemStruct)); - - if ( storehold[storenumh]._iMagical != ITEM_QUALITY_NORMAL && storehold[storenumh]._iIdentified ) - storehold[storenumh]._ivalue = storehold[storenumh]._iIvalue; - - if ( !(storehold[storenumh]._ivalue >>= 2) ) - storehold[storenumh]._ivalue = 1; - - storehold[storenumh]._iIvalue = storehold[storenumh]._ivalue; - storehidx[storenumh++] = i; - } - } - - if ( sellok ) - { - stextsmax = plr[myplr]._pNumInv; - stextscrl = 1; - stextsval = 0; - sprintf(tempstr, "Which item is for sale? Your gold : %i", plr[myplr]._pGold); - AddSText(0, 1, 1, tempstr, COL_GOLD, 0); - AddSLine(3); - AddSLine(21); - S_ScrollSSell(stextsval); - AddSText(0, 22, 1, "Back", COL_WHITE, 1); - OffsetSTextY(22, 6); - } - else - { - stextscrl = 0; - sprintf(tempstr, "You have nothing I want. Your gold : %i", plr[myplr]._pGold); - AddSText(0, 1, 1, tempstr, COL_GOLD, 0); - AddSLine(3); - AddSLine(21); - AddSText(0, 22, 1, "Back", COL_WHITE, 1); - OffsetSTextY(22, 6); - } + int i; // eax + bool sellok; // [esp+14h] [ebp-4h] + + stextsize = 1; + sellok = 0; + storenumh = 0; + + for (i = 0; i < 48; i++) + storehold[i]._itype = -1; + + for (i = 0; i < plr[myplr]._pNumInv; i++) { + if (SmithSellOk(i)) { + sellok = 1; + qmemcpy(&storehold[storenumh], &plr[myplr].InvList[i], sizeof(ItemStruct)); + + if (storehold[storenumh]._iMagical != ITEM_QUALITY_NORMAL && storehold[storenumh]._iIdentified) + storehold[storenumh]._ivalue = storehold[storenumh]._iIvalue; + + if (!(storehold[storenumh]._ivalue >>= 2)) + storehold[storenumh]._ivalue = 1; + + storehold[storenumh]._iIvalue = storehold[storenumh]._ivalue; + storehidx[storenumh++] = i; + } + } + + if (sellok) { + stextsmax = plr[myplr]._pNumInv; + stextscrl = 1; + stextsval = 0; + sprintf(tempstr, "Which item is for sale? Your gold : %i", plr[myplr]._pGold); + AddSText(0, 1, 1, tempstr, COL_GOLD, 0); + AddSLine(3); + AddSLine(21); + S_ScrollSSell(stextsval); + AddSText(0, 22, 1, "Back", COL_WHITE, 1); + OffsetSTextY(22, 6); + } else { + stextscrl = 0; + sprintf(tempstr, "You have nothing I want. Your gold : %i", plr[myplr]._pGold); + AddSText(0, 1, 1, tempstr, COL_GOLD, 0); + AddSLine(3); + AddSLine(21); + AddSText(0, 22, 1, "Back", COL_WHITE, 1); + OffsetSTextY(22, 6); + } } // 69F10C: using guessed type int storenumh; // 6A09E0: using guessed type char stextsize; @@ -1056,115 +945,102 @@ void __cdecl S_StartSSell() bool __fastcall SmithRepairOk(int i) { - if ( plr[myplr].InvList[i]._itype != ITYPE_NONE - && plr[myplr].InvList[i]._itype - && plr[myplr].InvList[i]._itype != ITYPE_GOLD - && plr[myplr].InvList[i]._itype != ITYPE_0E ) - return plr[myplr].InvList[i]._iDurability != plr[myplr].InvList[i]._iMaxDur; - else - return 0; + if (plr[myplr].InvList[i]._itype != ITYPE_NONE + && plr[myplr].InvList[i]._itype + && plr[myplr].InvList[i]._itype != ITYPE_GOLD + && plr[myplr].InvList[i]._itype != ITYPE_0E) + return plr[myplr].InvList[i]._iDurability != plr[myplr].InvList[i]._iMaxDur; + else + return 0; } void __cdecl S_StartSRepair() { - int v0; // ebp - int *v1; // eax - int v2; // esi - int v3; // eax - int v4; // eax - int v5; // eax - int v6; // eax - int v7; // edi - //int v8; // eax - int v9; // esi - int v10; // eax - int v11; // [esp-4h] [ebp-1Ch] - signed int v12; // [esp+10h] [ebp-8h] - int v13; // [esp+14h] [ebp-4h] - - v0 = 0; - stextsize = 1; - v12 = 0; - storenumh = 0; - v1 = &storehold[0]._itype; - do - { - *v1 = -1; - v1 += 92; - } - while ( (signed int)v1 < (signed int)&storehold[48]._itype ); - v2 = myplr; - v3 = myplr; - if ( plr[myplr].InvBody[INVLOC_HEAD]._itype != -1 && plr[v3].InvBody[INVLOC_HEAD]._iDurability != plr[v3].InvBody[INVLOC_HEAD]._iMaxDur ) - { - v12 = 1; - AddStoreHoldRepair(plr[v3].InvBody, -1); - v2 = myplr; - } - v4 = v2; - if ( plr[v2].InvBody[INVLOC_CHEST]._itype != -1 && plr[v4].InvBody[INVLOC_CHEST]._iDurability != plr[v4].InvBody[INVLOC_CHEST]._iMaxDur ) - { - v12 = 1; - AddStoreHoldRepair(&plr[v4].InvBody[INVLOC_CHEST], -2); - v2 = myplr; - } - v5 = v2; - if ( plr[v2].InvBody[INVLOC_HAND_LEFT]._itype != -1 && plr[v5].InvBody[INVLOC_HAND_LEFT]._iDurability != plr[v5].InvBody[INVLOC_HAND_LEFT]._iMaxDur ) - { - v12 = 1; - AddStoreHoldRepair(&plr[v5].InvBody[INVLOC_HAND_LEFT], -3); - v2 = myplr; - } - v6 = v2; - if ( plr[v2].InvBody[INVLOC_HAND_RIGHT]._itype != -1 && plr[v6].InvBody[INVLOC_HAND_RIGHT]._iDurability != plr[v6].InvBody[INVLOC_HAND_RIGHT]._iMaxDur ) - { - v12 = 1; - AddStoreHoldRepair(&plr[v6].InvBody[INVLOC_HAND_RIGHT], -4); - v2 = myplr; - } - v7 = 21720 * v2; - if ( plr[v2]._pNumInv > 0 ) - { - v13 = 0; - do - { - //_LOBYTE(v8) = SmithRepairOk(v0); - if ( SmithRepairOk(v0) ) - { - v12 = 1; - AddStoreHoldRepair((ItemStruct *)((char *)&plr[0].InvList[v13] + v7), v0); - v2 = myplr; - } - ++v13; - v7 = 21720 * v2; - ++v0; - } - while ( v0 < plr[v2]._pNumInv ); - } - v9 = v2; - v11 = plr[v9]._pGold; - if ( v12 ) - { - stextsval = 0; - v10 = plr[v9]._pNumInv; - stextscrl = 1; - stextsmax = v10; - sprintf(tempstr, "Repair which item? Your gold : %i", v11); - AddSText(0, 1, 1u, tempstr, COL_GOLD, 0); - AddSLine(3); - AddSLine(21); - S_ScrollSSell(stextsval); - } - else - { - stextscrl = 0; - sprintf(tempstr, "You have nothing to repair. Your gold : %i", v11); - AddSText(0, 1, 1u, tempstr, COL_GOLD, 0); - AddSLine(3); - AddSLine(21); - } - AddSText(0, 22, 1u, "Back", COL_WHITE, 1); - OffsetSTextY(22, 6); + int v0; // ebp + int *v1; // eax + int v2; // esi + int v3; // eax + int v4; // eax + int v5; // eax + int v6; // eax + int v7; // edi + //int v8; // eax + int v9; // esi + int v10; // eax + int v11; // [esp-4h] [ebp-1Ch] + signed int v12; // [esp+10h] [ebp-8h] + int v13; // [esp+14h] [ebp-4h] + + v0 = 0; + stextsize = 1; + v12 = 0; + storenumh = 0; + v1 = &storehold[0]._itype; + do { + *v1 = -1; + v1 += 92; + } while ((signed int)v1 < (signed int)&storehold[48]._itype); + v2 = myplr; + v3 = myplr; + if (plr[myplr].InvBody[INVLOC_HEAD]._itype != -1 && plr[v3].InvBody[INVLOC_HEAD]._iDurability != plr[v3].InvBody[INVLOC_HEAD]._iMaxDur) { + v12 = 1; + AddStoreHoldRepair(plr[v3].InvBody, -1); + v2 = myplr; + } + v4 = v2; + if (plr[v2].InvBody[INVLOC_CHEST]._itype != -1 && plr[v4].InvBody[INVLOC_CHEST]._iDurability != plr[v4].InvBody[INVLOC_CHEST]._iMaxDur) { + v12 = 1; + AddStoreHoldRepair(&plr[v4].InvBody[INVLOC_CHEST], -2); + v2 = myplr; + } + v5 = v2; + if (plr[v2].InvBody[INVLOC_HAND_LEFT]._itype != -1 && plr[v5].InvBody[INVLOC_HAND_LEFT]._iDurability != plr[v5].InvBody[INVLOC_HAND_LEFT]._iMaxDur) { + v12 = 1; + AddStoreHoldRepair(&plr[v5].InvBody[INVLOC_HAND_LEFT], -3); + v2 = myplr; + } + v6 = v2; + if (plr[v2].InvBody[INVLOC_HAND_RIGHT]._itype != -1 && plr[v6].InvBody[INVLOC_HAND_RIGHT]._iDurability != plr[v6].InvBody[INVLOC_HAND_RIGHT]._iMaxDur) { + v12 = 1; + AddStoreHoldRepair(&plr[v6].InvBody[INVLOC_HAND_RIGHT], -4); + v2 = myplr; + } + v7 = 21720 * v2; + if (plr[v2]._pNumInv > 0) { + v13 = 0; + do { + //_LOBYTE(v8) = SmithRepairOk(v0); + if (SmithRepairOk(v0)) { + v12 = 1; + AddStoreHoldRepair((ItemStruct *)((char *)&plr[0].InvList[v13] + v7), v0); + v2 = myplr; + } + ++v13; + v7 = 21720 * v2; + ++v0; + } while (v0 < plr[v2]._pNumInv); + } + v9 = v2; + v11 = plr[v9]._pGold; + if (v12) { + stextsval = 0; + v10 = plr[v9]._pNumInv; + stextscrl = 1; + stextsmax = v10; + sprintf(tempstr, "Repair which item? Your gold : %i", v11); + AddSText(0, 1, 1u, tempstr, COL_GOLD, 0); + AddSLine(3); + AddSLine(21); + S_ScrollSSell(stextsval); + } else { + stextscrl = 0; + sprintf(tempstr, "You have nothing to repair. Your gold : %i", v11); + AddSText(0, 1, 1u, tempstr, COL_GOLD, 0); + AddSLine(3); + AddSLine(21); + } + AddSText(0, 22, 1u, "Back", COL_WHITE, 1); + OffsetSTextY(22, 6); } // 69F10C: using guessed type int storenumh; // 6A09E0: using guessed type char stextsize; @@ -1173,44 +1049,43 @@ void __cdecl S_StartSRepair() void __fastcall AddStoreHoldRepair(ItemStruct *itm, int i) { - int v2; // ebx - ItemStruct *v3; // ebp - int v5; // eax - - v2 = storenumh; - v3 = &storehold[storenumh]; - qmemcpy(&storehold[storenumh], itm, sizeof(ItemStruct)); - if ( v3->_iMagical != ITEM_QUALITY_NORMAL && v3->_iIdentified ) - v3->_ivalue = 30 * v3->_iIvalue / 100; - v5 = v3->_ivalue * (100 * (v3->_iMaxDur - v3->_iDurability) / v3->_iMaxDur) / 100; - if ( !v5 ) - { - if ( v3->_iMagical != ITEM_QUALITY_NORMAL && v3->_iIdentified ) - return; - v5 = 1; - } - if ( v5 > 1 ) - v5 >>= 1; - v3->_iIvalue = v5; - v3->_ivalue = v5; - storehidx[v2] = i; - storenumh = v2 + 1; + int v2; // ebx + ItemStruct *v3; // ebp + int v5; // eax + + v2 = storenumh; + v3 = &storehold[storenumh]; + qmemcpy(&storehold[storenumh], itm, sizeof(ItemStruct)); + if (v3->_iMagical != ITEM_QUALITY_NORMAL && v3->_iIdentified) + v3->_ivalue = 30 * v3->_iIvalue / 100; + v5 = v3->_ivalue * (100 * (v3->_iMaxDur - v3->_iDurability) / v3->_iMaxDur) / 100; + if (!v5) { + if (v3->_iMagical != ITEM_QUALITY_NORMAL && v3->_iIdentified) + return; + v5 = 1; + } + if (v5 > 1) + v5 >>= 1; + v3->_iIvalue = v5; + v3->_ivalue = v5; + storehidx[v2] = i; + storenumh = v2 + 1; } // 69F10C: using guessed type int storenumh; void __cdecl S_StartWitch() { - stextsize = 0; - stextscrl = 0; - AddSText(0, 2, 1u, "Witch's shack", COL_GOLD, 0); - AddSText(0, 9, 1u, "Would you like to:", COL_GOLD, 0); - AddSText(0, 12, 1u, "Talk to Adria", COL_BLUE, 1); - AddSText(0, 14, 1u, "Buy items", COL_WHITE, 1); - AddSText(0, 16, 1u, "Sell items", COL_WHITE, 1); - AddSText(0, 18, 1u, "Recharge staves", COL_WHITE, 1); - AddSText(0, 20, 1u, "Leave the shack", COL_WHITE, 1); - AddSLine(5); - storenumh = 20; + stextsize = 0; + stextscrl = 0; + AddSText(0, 2, 1u, "Witch's shack", COL_GOLD, 0); + AddSText(0, 9, 1u, "Would you like to:", COL_GOLD, 0); + AddSText(0, 12, 1u, "Talk to Adria", COL_BLUE, 1); + AddSText(0, 14, 1u, "Buy items", COL_WHITE, 1); + AddSText(0, 16, 1u, "Sell items", COL_WHITE, 1); + AddSText(0, 18, 1u, "Recharge staves", COL_WHITE, 1); + AddSText(0, 20, 1u, "Leave the shack", COL_WHITE, 1); + AddSLine(5); + storenumh = 20; } // 69F10C: using guessed type int storenumh; // 6A09E0: using guessed type char stextsize; @@ -1218,40 +1093,37 @@ void __cdecl S_StartWitch() void __fastcall S_ScrollWBuy(int idx) { - int v1; // esi - int v2; // edi - char *v3; // esi - char *v4; // eax - int iclr; // [esp+Ch] [ebp-4h] - - v1 = idx; - v2 = 5; - ClearSText(5, 21); - v3 = &witchitem[v1]._iMagical; - stextup = 5; - do - { - if ( *((_DWORD *)v3 - 13) != -1 ) - { - _LOBYTE(iclr) = 0; - if ( *v3 ) - _LOBYTE(iclr) = 1; - if ( !*((_DWORD *)v3 + 74) ) - _LOBYTE(iclr) = 2; - v4 = v3 + 65; - if ( !*v3 ) - v4 = v3 + 1; - AddSText(20, v2, 0, v4, iclr, 1); - AddSTextVal(v2, *((_DWORD *)v3 + 35)); - PrintStoreItem((ItemStruct *)(v3 - 60), v2 + 1, iclr); - stextdown = v2; - v3 += 368; - } - v2 += 4; - } - while ( v2 < 20 ); - if ( !stext[stextsel]._ssel && stextsel != 22 ) - stextsel = stextdown; + int v1; // esi + int v2; // edi + char *v3; // esi + char *v4; // eax + int iclr; // [esp+Ch] [ebp-4h] + + v1 = idx; + v2 = 5; + ClearSText(5, 21); + v3 = &witchitem[v1]._iMagical; + stextup = 5; + do { + if (*((_DWORD *)v3 - 13) != -1) { + _LOBYTE(iclr) = 0; + if (*v3) + _LOBYTE(iclr) = 1; + if (!*((_DWORD *)v3 + 74)) + _LOBYTE(iclr) = 2; + v4 = v3 + 65; + if (!*v3) + v4 = v3 + 1; + AddSText(20, v2, 0, v4, iclr, 1); + AddSTextVal(v2, *((_DWORD *)v3 + 35)); + PrintStoreItem((ItemStruct *)(v3 - 60), v2 + 1, iclr); + stextdown = v2; + v3 += 368; + } + v2 += 4; + } while (v2 < 20); + if (!stext[stextsel]._ssel && stextsel != 22) + stextsel = stextdown; } // 69F108: using guessed type int stextup; // 6A8A28: using guessed type int stextsel; @@ -1259,38 +1131,35 @@ void __fastcall S_ScrollWBuy(int idx) void __cdecl S_StartWBuy() { - int v0; // ST10_4 - int v1; // eax - int *v2; // ecx - - v0 = plr[myplr]._pGold; - stextsize = 1; - stextscrl = 1; - stextsval = 0; - stextsmax = 20; - sprintf(tempstr, "I have these items for sale : Your gold : %i", v0); - AddSText(0, 1, 1u, tempstr, COL_GOLD, 0); - AddSLine(3); - AddSLine(21); - S_ScrollWBuy(stextsval); - AddSText(0, 22, 1u, "Back", COL_WHITE, 0); - OffsetSTextY(22, 6); - v1 = 0; - storenumh = 0; - if ( witchitem[0]._itype != -1 ) - { - v2 = &witchitem[0]._itype; - do - { - v2 += 92; - ++v1; - } - while ( *v2 != -1 ); - storenumh = v1; - } - stextsmax = v1 - 4; - if ( v1 - 4 < 0 ) - stextsmax = 0; + int v0; // ST10_4 + int v1; // eax + int *v2; // ecx + + v0 = plr[myplr]._pGold; + stextsize = 1; + stextscrl = 1; + stextsval = 0; + stextsmax = 20; + sprintf(tempstr, "I have these items for sale : Your gold : %i", v0); + AddSText(0, 1, 1u, tempstr, COL_GOLD, 0); + AddSLine(3); + AddSLine(21); + S_ScrollWBuy(stextsval); + AddSText(0, 22, 1u, "Back", COL_WHITE, 0); + OffsetSTextY(22, 6); + v1 = 0; + storenumh = 0; + if (witchitem[0]._itype != -1) { + v2 = &witchitem[0]._itype; + do { + v2 += 92; + ++v1; + } while (*v2 != -1); + storenumh = v1; + } + stextsmax = v1 - 4; + if (v1 - 4 < 0) + stextsmax = 0; } // 69F10C: using guessed type int storenumh; // 6A09E0: using guessed type char stextsize; @@ -1299,97 +1168,90 @@ void __cdecl S_StartWBuy() bool __fastcall WitchSellOk(int i) { - bool rv; // al - ItemStruct *pI; // edx - - rv = 0; - - if ( i < 0 ) - pI = &plr[myplr].SpdList[~i]; // -(i+1) - else - pI = &plr[myplr].InvList[i]; - - if ( pI->_itype == ITYPE_MISC ) - rv = 1; - if ( pI->_itype == ITYPE_STAFF ) - rv = 1; - if ( pI->IDidx >= IDI_FIRSTQUEST && pI->IDidx <= IDI_LASTQUEST ) - rv = 0; - if ( pI->IDidx == IDI_LAZSTAFF ) - rv = 0; - return rv; + bool rv; // al + ItemStruct *pI; // edx + + rv = 0; + + if (i < 0) + pI = &plr[myplr].SpdList[~i]; // -(i+1) + else + pI = &plr[myplr].InvList[i]; + + if (pI->_itype == ITYPE_MISC) + rv = 1; + if (pI->_itype == ITYPE_STAFF) + rv = 1; + if (pI->IDidx >= IDI_FIRSTQUEST && pI->IDidx <= IDI_LASTQUEST) + rv = 0; + if (pI->IDidx == IDI_LAZSTAFF) + rv = 0; + return rv; } void __cdecl S_StartWSell() { - int i; // eax - bool sellok; // [esp+18h] [ebp-8h] - - stextsize = 1; - sellok = 0; - storenumh = 0; - - for(i = 0; i < 48; i++) - storehold[i]._itype = -1; - - for(i = 0; i < plr[myplr]._pNumInv; i++) - { - if ( WitchSellOk(i) ) - { - sellok = 1; - qmemcpy(&storehold[storenumh], &plr[myplr].InvList[i], sizeof(ItemStruct)); - - if ( storehold[storenumh]._iMagical != ITEM_QUALITY_NORMAL && storehold[storenumh]._iIdentified ) - storehold[storenumh]._ivalue = storehold[storenumh]._iIvalue; - - if ( !(storehold[storenumh]._ivalue >>= 2) ) - storehold[storenumh]._ivalue = 1; - - storehold[storenumh]._iIvalue = storehold[storenumh]._ivalue; - storehidx[storenumh++] = i; - } - } - - for(i = 0; i < MAXBELTITEMS; i++) - { - if ( plr[myplr].SpdList[i]._itype != -1 && WitchSellOk(~i) ) - { - sellok = 1; - qmemcpy(&storehold[storenumh], &plr[myplr].SpdList[i], sizeof(ItemStruct)); - - if ( storehold[storenumh]._iMagical != ITEM_QUALITY_NORMAL && storehold[storenumh]._iIdentified ) - storehold[storenumh]._ivalue = storehold[storenumh]._iIvalue; - - if ( !(storehold[storenumh]._ivalue >>= 2) ) - storehold[storenumh]._ivalue = 1; - - storehold[storenumh]._iIvalue = storehold[storenumh]._ivalue; - storehidx[storenumh++] = ~i; - } - } - - if ( sellok ) - { - stextscrl = 1; - stextsval = 0; - stextsmax = plr[myplr]._pNumInv; - sprintf(tempstr, "Which item is for sale? Your gold : %i", plr[myplr]._pGold); - AddSText(0, 1, 1, tempstr, COL_GOLD, 0); - AddSLine(3); - AddSLine(21); - S_ScrollSSell(stextsval); - } - else - { - stextscrl = 0; - sprintf(tempstr, "You have nothing I want. Your gold : %i", plr[myplr]._pGold); - AddSText(0, 1, 1, tempstr, COL_GOLD, 0); - AddSLine(3); - AddSLine(21); - } - - AddSText(0, 22, 1, "Back", COL_WHITE, 1); - OffsetSTextY(22, 6); + int i; // eax + bool sellok; // [esp+18h] [ebp-8h] + + stextsize = 1; + sellok = 0; + storenumh = 0; + + for (i = 0; i < 48; i++) + storehold[i]._itype = -1; + + for (i = 0; i < plr[myplr]._pNumInv; i++) { + if (WitchSellOk(i)) { + sellok = 1; + qmemcpy(&storehold[storenumh], &plr[myplr].InvList[i], sizeof(ItemStruct)); + + if (storehold[storenumh]._iMagical != ITEM_QUALITY_NORMAL && storehold[storenumh]._iIdentified) + storehold[storenumh]._ivalue = storehold[storenumh]._iIvalue; + + if (!(storehold[storenumh]._ivalue >>= 2)) + storehold[storenumh]._ivalue = 1; + + storehold[storenumh]._iIvalue = storehold[storenumh]._ivalue; + storehidx[storenumh++] = i; + } + } + + for (i = 0; i < MAXBELTITEMS; i++) { + if (plr[myplr].SpdList[i]._itype != -1 && WitchSellOk(~i)) { + sellok = 1; + qmemcpy(&storehold[storenumh], &plr[myplr].SpdList[i], sizeof(ItemStruct)); + + if (storehold[storenumh]._iMagical != ITEM_QUALITY_NORMAL && storehold[storenumh]._iIdentified) + storehold[storenumh]._ivalue = storehold[storenumh]._iIvalue; + + if (!(storehold[storenumh]._ivalue >>= 2)) + storehold[storenumh]._ivalue = 1; + + storehold[storenumh]._iIvalue = storehold[storenumh]._ivalue; + storehidx[storenumh++] = ~i; + } + } + + if (sellok) { + stextscrl = 1; + stextsval = 0; + stextsmax = plr[myplr]._pNumInv; + sprintf(tempstr, "Which item is for sale? Your gold : %i", plr[myplr]._pGold); + AddSText(0, 1, 1, tempstr, COL_GOLD, 0); + AddSLine(3); + AddSLine(21); + S_ScrollSSell(stextsval); + } else { + stextscrl = 0; + sprintf(tempstr, "You have nothing I want. Your gold : %i", plr[myplr]._pGold); + AddSText(0, 1, 1, tempstr, COL_GOLD, 0); + AddSLine(3); + AddSLine(21); + } + + AddSText(0, 22, 1, "Back", COL_WHITE, 1); + OffsetSTextY(22, 6); } // 69F10C: using guessed type int storenumh; // 6A09E0: using guessed type char stextsize; @@ -1398,115 +1260,105 @@ void __cdecl S_StartWSell() bool __fastcall WitchRechargeOk(int i) { - bool rv; // al - - rv = 0; - if ( plr[myplr].InvList[i]._itype == ITYPE_STAFF - && plr[myplr].InvList[i]._iCharges != plr[myplr].InvList[i]._iMaxCharges ) - { - rv = 1; - } - return rv; + bool rv; // al + + rv = 0; + if (plr[myplr].InvList[i]._itype == ITYPE_STAFF + && plr[myplr].InvList[i]._iCharges != plr[myplr].InvList[i]._iMaxCharges) { + rv = 1; + } + return rv; } void __fastcall AddStoreHoldRecharge(ItemStruct itm, int i) { - int v2; // ebx - int v3; // eax - char v4; // ST10_1 - int v5; // ecx - int v6; // eax - - v2 = storenumh; - v3 = spelldata[itm._iSpell].sStaffCost; - v4 = i; - qmemcpy(&storehold[storenumh], &itm, sizeof(ItemStruct)); - storehold[v2]._ivalue += v3; - v5 = storenumh; - v6 = storehold[v2]._ivalue - * (100 - * (storehold[v2]._iMaxCharges - storehold[v2]._iCharges) - / storehold[v2]._iMaxCharges) - / 100 >> 1; - ++storenumh; - storehold[v2]._ivalue = v6; - storehold[v2]._iIvalue = v6; - storehidx[v5] = v4; + int v2; // ebx + int v3; // eax + char v4; // ST10_1 + int v5; // ecx + int v6; // eax + + v2 = storenumh; + v3 = spelldata[itm._iSpell].sStaffCost; + v4 = i; + qmemcpy(&storehold[storenumh], &itm, sizeof(ItemStruct)); + storehold[v2]._ivalue += v3; + v5 = storenumh; + v6 = storehold[v2]._ivalue + * (100 + * (storehold[v2]._iMaxCharges - storehold[v2]._iCharges) + / storehold[v2]._iMaxCharges) + / 100 + >> 1; + ++storenumh; + storehold[v2]._ivalue = v6; + storehold[v2]._iIvalue = v6; + storehidx[v5] = v4; } // 69F108: using guessed type int stextup; // 69F10C: using guessed type int storenumh; void __cdecl S_StartWRecharge() { - int *v0; // eax - int v1; // ebp - int v2; // eax - //int v3; // eax - ItemStruct v4; // [esp-170h] [ebp-18Ch] - int v5; // [esp-4h] [ebp-20h] - int inv_num; // [esp+10h] [ebp-Ch] - ItemStruct *v7; // [esp+14h] [ebp-8h] - int v8; // [esp+18h] [ebp-4h] - - stextsize = 1; - v8 = 0; - storenumh = 0; - v0 = &storehold[0]._itype; - do - { - *v0 = -1; - v0 += 92; - } - while ( (signed int)v0 < (signed int)&storehold[48]._itype ); - v1 = myplr; - if ( plr[myplr].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_STAFF && plr[v1].InvBody[INVLOC_HAND_LEFT]._iCharges != plr[v1].InvBody[INVLOC_HAND_LEFT]._iMaxCharges ) - { - v8 = 1; - qmemcpy(&v4, &plr[v1].InvBody[INVLOC_HAND_LEFT], sizeof(v4)); - AddStoreHoldRecharge(v4, -1); - } - v2 = plr[v1]._pNumInv; - inv_num = 0; - if ( v2 > 0 ) - { - v7 = plr[v1].InvList; - do - { - //_LOBYTE(v3) = WitchRechargeOk(inv_num); - if ( WitchRechargeOk(inv_num) ) - { - v8 = 1; - qmemcpy(&v4, v7, sizeof(v4)); - AddStoreHoldRecharge(v4, inv_num); - } - ++inv_num; - v2 = plr[v1]._pNumInv; - ++v7; - } - while ( inv_num < v2 ); - } - v5 = plr[v1]._pGold; - if ( v8 ) - { - stextscrl = 1; - stextsval = 0; - stextsmax = v2; - sprintf(tempstr, "Recharge which item? Your gold : %i", v5); - AddSText(0, 1, 1u, tempstr, COL_GOLD, 0); - AddSLine(3); - AddSLine(21); - S_ScrollSSell(stextsval); - } - else - { - stextscrl = 0; - sprintf(tempstr, "You have nothing to recharge. Your gold : %i", v5); - AddSText(0, 1, 1u, tempstr, COL_GOLD, 0); - AddSLine(3); - AddSLine(21); - } - AddSText(0, 22, 1u, "Back", COL_WHITE, 1); - OffsetSTextY(22, 6); + int *v0; // eax + int v1; // ebp + int v2; // eax + //int v3; // eax + ItemStruct v4; // [esp-170h] [ebp-18Ch] + int v5; // [esp-4h] [ebp-20h] + int inv_num; // [esp+10h] [ebp-Ch] + ItemStruct *v7; // [esp+14h] [ebp-8h] + int v8; // [esp+18h] [ebp-4h] + + stextsize = 1; + v8 = 0; + storenumh = 0; + v0 = &storehold[0]._itype; + do { + *v0 = -1; + v0 += 92; + } while ((signed int)v0 < (signed int)&storehold[48]._itype); + v1 = myplr; + if (plr[myplr].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_STAFF && plr[v1].InvBody[INVLOC_HAND_LEFT]._iCharges != plr[v1].InvBody[INVLOC_HAND_LEFT]._iMaxCharges) { + v8 = 1; + qmemcpy(&v4, &plr[v1].InvBody[INVLOC_HAND_LEFT], sizeof(v4)); + AddStoreHoldRecharge(v4, -1); + } + v2 = plr[v1]._pNumInv; + inv_num = 0; + if (v2 > 0) { + v7 = plr[v1].InvList; + do { + //_LOBYTE(v3) = WitchRechargeOk(inv_num); + if (WitchRechargeOk(inv_num)) { + v8 = 1; + qmemcpy(&v4, v7, sizeof(v4)); + AddStoreHoldRecharge(v4, inv_num); + } + ++inv_num; + v2 = plr[v1]._pNumInv; + ++v7; + } while (inv_num < v2); + } + v5 = plr[v1]._pGold; + if (v8) { + stextscrl = 1; + stextsval = 0; + stextsmax = v2; + sprintf(tempstr, "Recharge which item? Your gold : %i", v5); + AddSText(0, 1, 1u, tempstr, COL_GOLD, 0); + AddSLine(3); + AddSLine(21); + S_ScrollSSell(stextsval); + } else { + stextscrl = 0; + sprintf(tempstr, "You have nothing to recharge. Your gold : %i", v5); + AddSText(0, 1, 1u, tempstr, COL_GOLD, 0); + AddSLine(3); + AddSLine(21); + } + AddSText(0, 22, 1u, "Back", COL_WHITE, 1); + OffsetSTextY(22, 6); } // 69F10C: using guessed type int storenumh; // 6A09E0: using guessed type char stextsize; @@ -1515,175 +1367,166 @@ void __cdecl S_StartWRecharge() void __cdecl S_StartNoMoney() { - StartStore((unsigned char)stextshold); - stextscrl = 0; - stextsize = 1; - ClearSText(5, 23); - AddSText(0, 14, 1u, "You do not have enough gold", COL_WHITE, 1); + StartStore((unsigned char)stextshold); + stextscrl = 0; + stextsize = 1; + ClearSText(5, 23); + AddSText(0, 14, 1u, "You do not have enough gold", COL_WHITE, 1); } // 6A09E0: using guessed type char stextsize; // 6A6BB8: using guessed type int stextscrl; void __cdecl S_StartNoRoom() { - StartStore((unsigned char)stextshold); - stextscrl = 0; - ClearSText(5, 23); - AddSText(0, 14, 1u, "You do not have enough room in inventory", COL_WHITE, 1); + StartStore((unsigned char)stextshold); + stextscrl = 0; + ClearSText(5, 23); + AddSText(0, 14, 1u, "You do not have enough room in inventory", COL_WHITE, 1); } // 6A6BB8: using guessed type int stextscrl; void __cdecl S_StartConfirm() { - BOOL idprint; // esi - char iclr; // [esp+Ch] [ebp-4h] - - StartStore(stextshold); - stextscrl = 0; - ClearSText(5, 23); - iclr = COL_WHITE; - - if ( plr[myplr].HoldItem._iMagical != ITEM_QUALITY_NORMAL ) - iclr = COL_BLUE; - if ( !plr[myplr].HoldItem._iStatFlag ) - iclr = COL_RED; - - idprint = plr[myplr].HoldItem._iMagical != ITEM_QUALITY_NORMAL; - - if ( stextshold == STORE_SIDENTIFY ) - idprint = FALSE; - if ( plr[myplr].HoldItem._iMagical != ITEM_QUALITY_NORMAL && !plr[myplr].HoldItem._iIdentified ) - { - if ( stextshold == STORE_SSELL ) - idprint = FALSE; - if ( stextshold == STORE_WSELL ) - idprint = FALSE; - if ( stextshold == STORE_SREPAIR ) - idprint = FALSE; - if ( stextshold == STORE_WRECHARGE ) - idprint = FALSE; - } - if ( idprint ) - AddSText(20, 8, 0, plr[myplr].HoldItem._iIName, iclr, 0); - else - AddSText(20, 8, 0, plr[myplr].HoldItem._iName, iclr, 0); - - AddSTextVal(8, plr[myplr].HoldItem._iIvalue); - PrintStoreItem(&plr[myplr].HoldItem, 9, iclr); - - if ( stextshold > STORE_WRECHARGE ) - { - if ( stextshold == STORE_BBOY ) - { - strcpy(tempstr, "Do we have a deal?"); - goto LABEL_37; - } - if ( stextshold != STORE_HBUY ) - { - if ( stextshold == STORE_SIDENTIFY ) - { - strcpy(tempstr, "Are you sure you want to identify this item?"); - goto LABEL_37; - } - if ( stextshold != STORE_SPBUY ) - goto LABEL_37; - } -LABEL_34: - strcpy(tempstr, "Are you sure you want to buy this item?"); - goto LABEL_37; - } - switch ( stextshold ) - { - case STORE_WRECHARGE: - strcpy(tempstr, "Are you sure you want to recharge this item?"); - break; - case STORE_SBUY: - goto LABEL_34; - case STORE_SSELL: -LABEL_27: - strcpy(tempstr, "Are you sure you want to sell this item?"); - break; - case STORE_SREPAIR: - strcpy(tempstr, "Are you sure you want to repair this item?"); - break; - case STORE_WBUY: - goto LABEL_34; - case STORE_WSELL: - goto LABEL_27; - } + BOOL idprint; // esi + char iclr; // [esp+Ch] [ebp-4h] + + StartStore(stextshold); + stextscrl = 0; + ClearSText(5, 23); + iclr = COL_WHITE; + + if (plr[myplr].HoldItem._iMagical != ITEM_QUALITY_NORMAL) + iclr = COL_BLUE; + if (!plr[myplr].HoldItem._iStatFlag) + iclr = COL_RED; + + idprint = plr[myplr].HoldItem._iMagical != ITEM_QUALITY_NORMAL; + + if (stextshold == STORE_SIDENTIFY) + idprint = FALSE; + if (plr[myplr].HoldItem._iMagical != ITEM_QUALITY_NORMAL && !plr[myplr].HoldItem._iIdentified) { + if (stextshold == STORE_SSELL) + idprint = FALSE; + if (stextshold == STORE_WSELL) + idprint = FALSE; + if (stextshold == STORE_SREPAIR) + idprint = FALSE; + if (stextshold == STORE_WRECHARGE) + idprint = FALSE; + } + if (idprint) + AddSText(20, 8, 0, plr[myplr].HoldItem._iIName, iclr, 0); + else + AddSText(20, 8, 0, plr[myplr].HoldItem._iName, iclr, 0); + + AddSTextVal(8, plr[myplr].HoldItem._iIvalue); + PrintStoreItem(&plr[myplr].HoldItem, 9, iclr); + + if (stextshold > STORE_WRECHARGE) { + if (stextshold == STORE_BBOY) { + strcpy(tempstr, "Do we have a deal?"); + goto LABEL_37; + } + if (stextshold != STORE_HBUY) { + if (stextshold == STORE_SIDENTIFY) { + strcpy(tempstr, "Are you sure you want to identify this item?"); + goto LABEL_37; + } + if (stextshold != STORE_SPBUY) + goto LABEL_37; + } + LABEL_34: + strcpy(tempstr, "Are you sure you want to buy this item?"); + goto LABEL_37; + } + switch (stextshold) { + case STORE_WRECHARGE: + strcpy(tempstr, "Are you sure you want to recharge this item?"); + break; + case STORE_SBUY: + goto LABEL_34; + case STORE_SSELL: + LABEL_27: + strcpy(tempstr, "Are you sure you want to sell this item?"); + break; + case STORE_SREPAIR: + strcpy(tempstr, "Are you sure you want to repair this item?"); + break; + case STORE_WBUY: + goto LABEL_34; + case STORE_WSELL: + goto LABEL_27; + } LABEL_37: - AddSText(0, 15, 1u, tempstr, COL_WHITE, 0); - AddSText(0, 18, 1u, "Yes", COL_WHITE, 1); - AddSText(0, 20, 1u, "No", COL_WHITE, 1); + AddSText(0, 15, 1u, tempstr, COL_WHITE, 0); + AddSText(0, 18, 1u, "Yes", COL_WHITE, 1); + AddSText(0, 20, 1u, "No", COL_WHITE, 1); } // 6A6BB8: using guessed type int stextscrl; void __cdecl S_StartBoy() { - stextsize = 0; - stextscrl = 0; - AddSText(0, 2, 1u, "Wirt the Peg-legged boy", COL_GOLD, 0); - AddSLine(5); - if ( boyitem._itype == -1 ) - { - AddSText(0, 12, 1u, "Talk to Wirt", COL_BLUE, 1); - AddSText(0, 18, 1u, "Say goodbye", COL_WHITE, 1); - } - else - { - AddSText(0, 8, 1u, "Talk to Wirt", COL_BLUE, 1); - AddSText(0, 12, 1u, "I have something for sale,", COL_GOLD, 0); - AddSText(0, 14, 1u, "but it will cost 50 gold", COL_GOLD, 0); - AddSText(0, 16, 1u, "just to take a look. ", COL_GOLD, 0); - AddSText(0, 18, 1u, "What have you got?", COL_WHITE, 1); - AddSText(0, 20, 1u, "Say goodbye", COL_WHITE, 1); - } + stextsize = 0; + stextscrl = 0; + AddSText(0, 2, 1u, "Wirt the Peg-legged boy", COL_GOLD, 0); + AddSLine(5); + if (boyitem._itype == -1) { + AddSText(0, 12, 1u, "Talk to Wirt", COL_BLUE, 1); + AddSText(0, 18, 1u, "Say goodbye", COL_WHITE, 1); + } else { + AddSText(0, 8, 1u, "Talk to Wirt", COL_BLUE, 1); + AddSText(0, 12, 1u, "I have something for sale,", COL_GOLD, 0); + AddSText(0, 14, 1u, "but it will cost 50 gold", COL_GOLD, 0); + AddSText(0, 16, 1u, "just to take a look. ", COL_GOLD, 0); + AddSText(0, 18, 1u, "What have you got?", COL_WHITE, 1); + AddSText(0, 20, 1u, "Say goodbye", COL_WHITE, 1); + } } // 6A09E0: using guessed type char stextsize; // 6A6BB8: using guessed type int stextscrl; void __cdecl S_StartBBoy() { - int iclr; // esi - - stextsize = 1; - stextscrl = 0; - sprintf(tempstr, "I have this item for sale : Your gold : %i", plr[myplr]._pGold); - AddSText(0, 1, 1u, tempstr, COL_GOLD, 0); - AddSLine(3); - AddSLine(21); - iclr = COL_WHITE; - - if ( boyitem._iMagical != ITEM_QUALITY_NORMAL ) - iclr = COL_BLUE; - if ( !boyitem._iStatFlag ) - iclr = COL_RED; - if ( boyitem._iMagical != ITEM_QUALITY_NORMAL ) - AddSText(20, 10, 0, boyitem._iIName, iclr, 1); - else - AddSText(20, 10, 0, boyitem._iName, iclr, 1); - - AddSTextVal(10, boyitem._iIvalue + (boyitem._iIvalue >> 1)); - PrintStoreItem(&boyitem, 11, iclr); - AddSText(0, 22, 1u, "Leave", COL_WHITE, 1); - OffsetSTextY(22, 6); + int iclr; // esi + + stextsize = 1; + stextscrl = 0; + sprintf(tempstr, "I have this item for sale : Your gold : %i", plr[myplr]._pGold); + AddSText(0, 1, 1u, tempstr, COL_GOLD, 0); + AddSLine(3); + AddSLine(21); + iclr = COL_WHITE; + + if (boyitem._iMagical != ITEM_QUALITY_NORMAL) + iclr = COL_BLUE; + if (!boyitem._iStatFlag) + iclr = COL_RED; + if (boyitem._iMagical != ITEM_QUALITY_NORMAL) + AddSText(20, 10, 0, boyitem._iIName, iclr, 1); + else + AddSText(20, 10, 0, boyitem._iName, iclr, 1); + + AddSTextVal(10, boyitem._iIvalue + (boyitem._iIvalue >> 1)); + PrintStoreItem(&boyitem, 11, iclr); + AddSText(0, 22, 1u, "Leave", COL_WHITE, 1); + OffsetSTextY(22, 6); } // 6A09E0: using guessed type char stextsize; // 6A6BB8: using guessed type int stextscrl; void __cdecl S_StartHealer() { - stextsize = 0; - stextscrl = 0; - AddSText(0, 1, 1u, "Welcome to the", COL_GOLD, 0); - AddSText(0, 3, 1u, "Healer's home", COL_GOLD, 0); - AddSText(0, 9, 1u, "Would you like to:", COL_GOLD, 0); - AddSText(0, 12, 1u, "Talk to Pepin", COL_BLUE, 1); - AddSText(0, 14, 1u, "Receive healing", COL_WHITE, 1); - AddSText(0, 16, 1u, "Buy items", COL_WHITE, 1); - AddSText(0, 18, 1u, "Leave Healer's home", COL_WHITE, 1); - AddSLine(5); - storenumh = 20; + stextsize = 0; + stextscrl = 0; + AddSText(0, 1, 1u, "Welcome to the", COL_GOLD, 0); + AddSText(0, 3, 1u, "Healer's home", COL_GOLD, 0); + AddSText(0, 9, 1u, "Would you like to:", COL_GOLD, 0); + AddSText(0, 12, 1u, "Talk to Pepin", COL_BLUE, 1); + AddSText(0, 14, 1u, "Receive healing", COL_WHITE, 1); + AddSText(0, 16, 1u, "Buy items", COL_WHITE, 1); + AddSText(0, 18, 1u, "Leave Healer's home", COL_WHITE, 1); + AddSLine(5); + storenumh = 20; } // 69F10C: using guessed type int storenumh; // 6A09E0: using guessed type char stextsize; @@ -1691,34 +1534,31 @@ void __cdecl S_StartHealer() void __fastcall S_ScrollHBuy(int idx) { - int v1; // esi - int v2; // edi - int *v3; // esi - int iclr; // [esp+8h] [ebp-4h] - - v1 = idx; - v2 = 5; - ClearSText(5, 21); - stextup = 5; - v3 = &healitem[v1]._iStatFlag; - do - { - if ( *(v3 - 87) != -1 ) - { - _LOBYTE(iclr) = COL_WHITE; - if ( !*v3 ) - _LOBYTE(iclr) = COL_RED; - AddSText(20, v2, 0, (char *)v3 - 295, iclr, 1); - AddSTextVal(v2, *(v3 - 39)); - PrintStoreItem((ItemStruct *)(v3 - 89), v2 + 1, iclr); - stextdown = v2; - v3 += 92; - } - v2 += 4; - } - while ( v2 < 20 ); - if ( !stext[stextsel]._ssel && stextsel != 22 ) - stextsel = stextdown; + int v1; // esi + int v2; // edi + int *v3; // esi + int iclr; // [esp+8h] [ebp-4h] + + v1 = idx; + v2 = 5; + ClearSText(5, 21); + stextup = 5; + v3 = &healitem[v1]._iStatFlag; + do { + if (*(v3 - 87) != -1) { + _LOBYTE(iclr) = COL_WHITE; + if (!*v3) + _LOBYTE(iclr) = COL_RED; + AddSText(20, v2, 0, (char *)v3 - 295, iclr, 1); + AddSTextVal(v2, *(v3 - 39)); + PrintStoreItem((ItemStruct *)(v3 - 89), v2 + 1, iclr); + stextdown = v2; + v3 += 92; + } + v2 += 4; + } while (v2 < 20); + if (!stext[stextsel]._ssel && stextsel != 22) + stextsel = stextdown; } // 69F108: using guessed type int stextup; // 6A8A28: using guessed type int stextsel; @@ -1726,37 +1566,34 @@ void __fastcall S_ScrollHBuy(int idx) void __cdecl S_StartHBuy() { - int v0; // ST10_4 - int v1; // eax - int *v2; // ecx - - v0 = plr[myplr]._pGold; - stextsize = 1; - stextscrl = 1; - stextsval = 0; - sprintf(tempstr, "I have these items for sale : Your gold : %i", v0); - AddSText(0, 1, 1u, tempstr, COL_GOLD, 0); - AddSLine(3); - AddSLine(21); - S_ScrollHBuy(stextsval); - AddSText(0, 22, 1u, "Back", COL_WHITE, 0); - OffsetSTextY(22, 6); - v1 = 0; - storenumh = 0; - if ( healitem[0]._itype != -1 ) - { - v2 = &healitem[0]._itype; - do - { - v2 += 92; - ++v1; - } - while ( *v2 != -1 ); - storenumh = v1; - } - stextsmax = v1 - 4; - if ( v1 - 4 < 0 ) - stextsmax = 0; + int v0; // ST10_4 + int v1; // eax + int *v2; // ecx + + v0 = plr[myplr]._pGold; + stextsize = 1; + stextscrl = 1; + stextsval = 0; + sprintf(tempstr, "I have these items for sale : Your gold : %i", v0); + AddSText(0, 1, 1u, tempstr, COL_GOLD, 0); + AddSLine(3); + AddSLine(21); + S_ScrollHBuy(stextsval); + AddSText(0, 22, 1u, "Back", COL_WHITE, 0); + OffsetSTextY(22, 6); + v1 = 0; + storenumh = 0; + if (healitem[0]._itype != -1) { + v2 = &healitem[0]._itype; + do { + v2 += 92; + ++v1; + } while (*v2 != -1); + storenumh = v1; + } + stextsmax = v1 - 4; + if (v1 - 4 < 0) + stextsmax = 0; } // 69F10C: using guessed type int storenumh; // 6A09E0: using guessed type char stextsize; @@ -1765,129 +1602,116 @@ void __cdecl S_StartHBuy() void __cdecl S_StartStory() { - stextsize = 0; - stextscrl = 0; - AddSText(0, 2, 1u, "The Town Elder", COL_GOLD, 0); - AddSText(0, 9, 1u, "Would you like to:", COL_GOLD, 0); - AddSText(0, 12, 1u, "Talk to Cain", COL_BLUE, 1); - AddSText(0, 14, 1u, "Identify an item", COL_WHITE, 1); - AddSText(0, 18, 1u, "Say goodbye", COL_WHITE, 1); - AddSLine(5); + stextsize = 0; + stextscrl = 0; + AddSText(0, 2, 1u, "The Town Elder", COL_GOLD, 0); + AddSText(0, 9, 1u, "Would you like to:", COL_GOLD, 0); + AddSText(0, 12, 1u, "Talk to Cain", COL_BLUE, 1); + AddSText(0, 14, 1u, "Identify an item", COL_WHITE, 1); + AddSText(0, 18, 1u, "Say goodbye", COL_WHITE, 1); + AddSLine(5); } // 6A09E0: using guessed type char stextsize; // 6A6BB8: using guessed type int stextscrl; bool __fastcall IdItemOk(ItemStruct *i) { - bool result; // al - - result = 0; - if ( i->_itype != -1 ) - { - if ( i->_iMagical != ITEM_QUALITY_NORMAL ) - result = !i->_iIdentified; - } - return result; + bool result; // al + + result = 0; + if (i->_itype != -1) { + if (i->_iMagical != ITEM_QUALITY_NORMAL) + result = !i->_iIdentified; + } + return result; } void __fastcall AddStoreHoldId(ItemStruct itm, int i) { - qmemcpy(&storehold[storenumh], &itm, sizeof(ItemStruct)); - storehold[storenumh]._ivalue = 100; - storehold[storenumh]._iIvalue = 100; - storehidx[storenumh++] = i; + qmemcpy(&storehold[storenumh], &itm, sizeof(ItemStruct)); + storehold[storenumh]._ivalue = 100; + storehold[storenumh]._iIvalue = 100; + storehidx[storenumh++] = i; } // 69F108: using guessed type int stextup; // 69F10C: using guessed type int storenumh; void __cdecl S_StartSIdentify() { - ItemStruct itm; // [esp-170h] [ebp-18Ch] - bool idok; // [esp+10h] [ebp-Ch] - int i; // [esp+14h] [ebp-8h] - - idok = 0; - storenumh = 0; - stextsize = 1; - - for(i = 0; i < 48; i++) - storehold[i]._itype = -1; - - if ( IdItemOk(plr[myplr].InvBody) ) - { - idok = 1; - qmemcpy(&itm, plr[myplr].InvBody, sizeof(ItemStruct)); - AddStoreHoldId(itm, -1); - } - if ( IdItemOk(&plr[myplr].InvBody[INVLOC_CHEST]) ) - { - idok = 1; - qmemcpy(&itm, &plr[myplr].InvBody[INVLOC_CHEST], sizeof(ItemStruct)); - AddStoreHoldId(itm, -2); - } - if ( IdItemOk(&plr[myplr].InvBody[INVLOC_HAND_LEFT]) ) - { - idok = 1; - qmemcpy(&itm, &plr[myplr].InvBody[INVLOC_HAND_LEFT], sizeof(ItemStruct)); - AddStoreHoldId(itm, -3); - } - if ( IdItemOk(&plr[myplr].InvBody[INVLOC_HAND_RIGHT]) ) - { - idok = 1; - qmemcpy(&itm, &plr[myplr].InvBody[INVLOC_HAND_RIGHT], sizeof(ItemStruct)); - AddStoreHoldId(itm, -4); - } - if ( IdItemOk(&plr[myplr].InvBody[INVLOC_RING_LEFT]) ) - { - idok = 1; - qmemcpy(&itm, &plr[myplr].InvBody[INVLOC_RING_LEFT], sizeof(ItemStruct)); - AddStoreHoldId(itm, -5); - } - if ( IdItemOk(&plr[myplr].InvBody[INVLOC_RING_RIGHT]) ) - { - idok = 1; - qmemcpy(&itm, &plr[myplr].InvBody[INVLOC_RING_RIGHT], sizeof(ItemStruct)); - AddStoreHoldId(itm, -6); - } - if ( IdItemOk(&plr[myplr].InvBody[INVLOC_AMULET]) ) - { - idok = 1; - qmemcpy(&itm, &plr[myplr].InvBody[INVLOC_AMULET], sizeof(ItemStruct)); - AddStoreHoldId(itm, -7); - } - - for(i = 0; i < plr[myplr]._pNumInv; i++) - { - if ( IdItemOk(&plr[myplr].InvList[i]) ) - { - idok = 1; - qmemcpy(&itm, &plr[myplr].InvList[i], sizeof(ItemStruct)); - AddStoreHoldId(itm, i); - } - } - - if ( idok ) - { - stextscrl = 1; - stextsval = 0; - stextsmax = plr[myplr]._pNumInv; - sprintf(tempstr, "Identify which item? Your gold : %i", plr[myplr]._pGold); - AddSText(0, 1, 1, tempstr, COL_GOLD, 0); - AddSLine(3); - AddSLine(21); - S_ScrollSSell(stextsval); - } - else - { - stextscrl = 0; - sprintf(tempstr, "You have nothing to identify. Your gold : %i", plr[myplr]._pGold); - AddSText(0, 1, 1, tempstr, COL_GOLD, 0); - AddSLine(3); - AddSLine(21); - } - - AddSText(0, 22, 1, "Back", COL_WHITE, 1); - OffsetSTextY(22, 6); + ItemStruct itm; // [esp-170h] [ebp-18Ch] + bool idok; // [esp+10h] [ebp-Ch] + int i; // [esp+14h] [ebp-8h] + + idok = 0; + storenumh = 0; + stextsize = 1; + + for (i = 0; i < 48; i++) + storehold[i]._itype = -1; + + if (IdItemOk(plr[myplr].InvBody)) { + idok = 1; + qmemcpy(&itm, plr[myplr].InvBody, sizeof(ItemStruct)); + AddStoreHoldId(itm, -1); + } + if (IdItemOk(&plr[myplr].InvBody[INVLOC_CHEST])) { + idok = 1; + qmemcpy(&itm, &plr[myplr].InvBody[INVLOC_CHEST], sizeof(ItemStruct)); + AddStoreHoldId(itm, -2); + } + if (IdItemOk(&plr[myplr].InvBody[INVLOC_HAND_LEFT])) { + idok = 1; + qmemcpy(&itm, &plr[myplr].InvBody[INVLOC_HAND_LEFT], sizeof(ItemStruct)); + AddStoreHoldId(itm, -3); + } + if (IdItemOk(&plr[myplr].InvBody[INVLOC_HAND_RIGHT])) { + idok = 1; + qmemcpy(&itm, &plr[myplr].InvBody[INVLOC_HAND_RIGHT], sizeof(ItemStruct)); + AddStoreHoldId(itm, -4); + } + if (IdItemOk(&plr[myplr].InvBody[INVLOC_RING_LEFT])) { + idok = 1; + qmemcpy(&itm, &plr[myplr].InvBody[INVLOC_RING_LEFT], sizeof(ItemStruct)); + AddStoreHoldId(itm, -5); + } + if (IdItemOk(&plr[myplr].InvBody[INVLOC_RING_RIGHT])) { + idok = 1; + qmemcpy(&itm, &plr[myplr].InvBody[INVLOC_RING_RIGHT], sizeof(ItemStruct)); + AddStoreHoldId(itm, -6); + } + if (IdItemOk(&plr[myplr].InvBody[INVLOC_AMULET])) { + idok = 1; + qmemcpy(&itm, &plr[myplr].InvBody[INVLOC_AMULET], sizeof(ItemStruct)); + AddStoreHoldId(itm, -7); + } + + for (i = 0; i < plr[myplr]._pNumInv; i++) { + if (IdItemOk(&plr[myplr].InvList[i])) { + idok = 1; + qmemcpy(&itm, &plr[myplr].InvList[i], sizeof(ItemStruct)); + AddStoreHoldId(itm, i); + } + } + + if (idok) { + stextscrl = 1; + stextsval = 0; + stextsmax = plr[myplr]._pNumInv; + sprintf(tempstr, "Identify which item? Your gold : %i", plr[myplr]._pGold); + AddSText(0, 1, 1, tempstr, COL_GOLD, 0); + AddSLine(3); + AddSLine(21); + S_ScrollSSell(stextsval); + } else { + stextscrl = 0; + sprintf(tempstr, "You have nothing to identify. Your gold : %i", plr[myplr]._pGold); + AddSText(0, 1, 1, tempstr, COL_GOLD, 0); + AddSLine(3); + AddSLine(21); + } + + AddSText(0, 22, 1, "Back", COL_WHITE, 1); + OffsetSTextY(22, 6); } // 69F10C: using guessed type int storenumh; // 6A09E0: using guessed type char stextsize; @@ -1896,84 +1720,76 @@ void __cdecl S_StartSIdentify() void __cdecl S_StartIdShow() { - char iclr; // [esp+4h] [ebp-4h] - - StartStore(stextshold); - stextscrl = 0; - ClearSText(5, 23); - iclr = COL_WHITE; - - if ( plr[myplr].HoldItem._iMagical != ITEM_QUALITY_NORMAL ) - iclr = COL_BLUE; - if ( !plr[myplr].HoldItem._iStatFlag ) - iclr = COL_RED; - - AddSText(0, 7, 1u, "This item is:", COL_WHITE, 0); - AddSText(20, 11, 0, plr[myplr].HoldItem._iIName, iclr, 0); - PrintStoreItem(&plr[myplr].HoldItem, 12, iclr); - AddSText(0, 18, 1u, "Done", COL_WHITE, 1); + char iclr; // [esp+4h] [ebp-4h] + + StartStore(stextshold); + stextscrl = 0; + ClearSText(5, 23); + iclr = COL_WHITE; + + if (plr[myplr].HoldItem._iMagical != ITEM_QUALITY_NORMAL) + iclr = COL_BLUE; + if (!plr[myplr].HoldItem._iStatFlag) + iclr = COL_RED; + + AddSText(0, 7, 1u, "This item is:", COL_WHITE, 0); + AddSText(20, 11, 0, plr[myplr].HoldItem._iIName, iclr, 0); + PrintStoreItem(&plr[myplr].HoldItem, 12, iclr); + AddSText(0, 18, 1u, "Done", COL_WHITE, 1); } // 6A6BB8: using guessed type int stextscrl; void __cdecl S_StartTalk() { - int *v0; // edi - signed int v1; // eax - int v2; // edx - int *v3; // ecx - char **v4; // ebp - int v5; // esi - int v6; // ebx - signed int v7; // [esp-4h] [ebp-1Ch] - signed int v8; // [esp+10h] [ebp-8h] - int y; // [esp+14h] [ebp-4h] - - stextsize = 0; - stextscrl = 0; - sprintf(tempstr, "Talk to %s", talkname[talker]); - AddSText(0, 2, 1u, tempstr, COL_GOLD, 0); - AddSLine(5); - v0 = &quests[0]._qlog; - v1 = 0; - v2 = 0; - v3 = &quests[0]._qlog; - do - { - if ( *((_BYTE *)v3 - 18) == 2 && *((_DWORD *)&Qtalklist[0]._qinfra + v2 + 16 * talker) != -1 && *v3 ) - ++v1; - v3 += 6; - ++v2; - } - while ( (signed int)v3 < (signed int)&quests[16]._qlog ); - if ( v1 <= 6 ) - { - v7 = 15; - v8 = 2; - } - else - { - v1 >>= 1; - v7 = 14; - v8 = 1; - } - v4 = &questlist[0]._qlstr; - v5 = v7 - v1; - v6 = 0; - y = v7 - v1 - 2; - do - { - if ( *((_BYTE *)v0 - 18) == 2 && *((_DWORD *)&Qtalklist[0]._qinfra + v6 + 16 * talker) != -1 && *v0 ) - { - AddSText(0, v5, 1u, *v4, COL_WHITE, 1); - v5 += v8; - } - v0 += 6; - ++v6; - v4 += 5; - } - while ( (signed int)v0 < (signed int)&quests[16]._qlog ); - AddSText(0, y, 1u, "Gossip", COL_BLUE, 1); - AddSText(0, 22, 1u, "Back", COL_WHITE, 1); + int *v0; // edi + signed int v1; // eax + int v2; // edx + int *v3; // ecx + char **v4; // ebp + int v5; // esi + int v6; // ebx + signed int v7; // [esp-4h] [ebp-1Ch] + signed int v8; // [esp+10h] [ebp-8h] + int y; // [esp+14h] [ebp-4h] + + stextsize = 0; + stextscrl = 0; + sprintf(tempstr, "Talk to %s", talkname[talker]); + AddSText(0, 2, 1u, tempstr, COL_GOLD, 0); + AddSLine(5); + v0 = &quests[0]._qlog; + v1 = 0; + v2 = 0; + v3 = &quests[0]._qlog; + do { + if (*((_BYTE *)v3 - 18) == 2 && *((_DWORD *)&Qtalklist[0]._qinfra + v2 + 16 * talker) != -1 && *v3) + ++v1; + v3 += 6; + ++v2; + } while ((signed int)v3 < (signed int)&quests[16]._qlog); + if (v1 <= 6) { + v7 = 15; + v8 = 2; + } else { + v1 >>= 1; + v7 = 14; + v8 = 1; + } + v4 = &questlist[0]._qlstr; + v5 = v7 - v1; + v6 = 0; + y = v7 - v1 - 2; + do { + if (*((_BYTE *)v0 - 18) == 2 && *((_DWORD *)&Qtalklist[0]._qinfra + v6 + 16 * talker) != -1 && *v0) { + AddSText(0, v5, 1u, *v4, COL_WHITE, 1); + v5 += v8; + } + v0 += 6; + ++v6; + v4 += 5; + } while ((signed int)v0 < (signed int)&quests[16]._qlog); + AddSText(0, y, 1u, "Gossip", COL_BLUE, 1); + AddSText(0, 22, 1u, "Back", COL_WHITE, 1); } // 69FB38: using guessed type int talker; // 6A09E0: using guessed type char stextsize; @@ -1981,15 +1797,15 @@ void __cdecl S_StartTalk() void __cdecl S_StartTavern() { - stextsize = 0; - stextscrl = 0; - AddSText(0, 1, 1u, "Welcome to the", COL_GOLD, 0); - AddSText(0, 3, 1u, "Rising Sun", COL_GOLD, 0); - AddSText(0, 9, 1u, "Would you like to:", COL_GOLD, 0); - AddSText(0, 12, 1u, "Talk to Ogden", COL_BLUE, 1); - AddSText(0, 18, 1u, "Leave the tavern", COL_WHITE, 1); - AddSLine(5); - storenumh = 20; + stextsize = 0; + stextscrl = 0; + AddSText(0, 1, 1u, "Welcome to the", COL_GOLD, 0); + AddSText(0, 3, 1u, "Rising Sun", COL_GOLD, 0); + AddSText(0, 9, 1u, "Would you like to:", COL_GOLD, 0); + AddSText(0, 12, 1u, "Talk to Ogden", COL_BLUE, 1); + AddSText(0, 18, 1u, "Leave the tavern", COL_WHITE, 1); + AddSLine(5); + storenumh = 20; } // 69F10C: using guessed type int storenumh; // 6A09E0: using guessed type char stextsize; @@ -1997,14 +1813,14 @@ void __cdecl S_StartTavern() void __cdecl S_StartBarMaid() { - stextsize = 0; - stextscrl = 0; - AddSText(0, 2, 1u, "Gillian", COL_GOLD, 0); - AddSText(0, 9, 1u, "Would you like to:", COL_GOLD, 0); - AddSText(0, 12, 1u, "Talk to Gillian", COL_BLUE, 1); - AddSText(0, 18, 1u, "Say goodbye", COL_WHITE, 1); - AddSLine(5); - storenumh = 20; + stextsize = 0; + stextscrl = 0; + AddSText(0, 2, 1u, "Gillian", COL_GOLD, 0); + AddSText(0, 9, 1u, "Would you like to:", COL_GOLD, 0); + AddSText(0, 12, 1u, "Talk to Gillian", COL_BLUE, 1); + AddSText(0, 18, 1u, "Say goodbye", COL_WHITE, 1); + AddSLine(5); + storenumh = 20; } // 69F10C: using guessed type int storenumh; // 6A09E0: using guessed type char stextsize; @@ -2012,14 +1828,14 @@ void __cdecl S_StartBarMaid() void __cdecl S_StartDrunk() { - stextsize = 0; - stextscrl = 0; - AddSText(0, 2, 1u, "Farnham the Drunk", COL_GOLD, 0); - AddSText(0, 9, 1u, "Would you like to:", COL_GOLD, 0); - AddSText(0, 12, 1u, "Talk to Farnham", COL_BLUE, 1); - AddSText(0, 18, 1u, "Say Goodbye", COL_WHITE, 1); - AddSLine(5); - storenumh = 20; + stextsize = 0; + stextscrl = 0; + AddSText(0, 2, 1u, "Farnham the Drunk", COL_GOLD, 0); + AddSText(0, 9, 1u, "Would you like to:", COL_GOLD, 0); + AddSText(0, 12, 1u, "Talk to Farnham", COL_BLUE, 1); + AddSText(0, 18, 1u, "Say Goodbye", COL_WHITE, 1); + AddSLine(5); + storenumh = 20; } // 69F10C: using guessed type int storenumh; // 6A09E0: using guessed type char stextsize; @@ -2027,108 +1843,105 @@ void __cdecl S_StartDrunk() void __fastcall StartStore(char s) { - char t; // bl - int i; // ecx - - for ( t = s; ; t = 1 ) - { - sbookflag = 0; - invflag = 0; - chrflag = 0; - questlog = 0; - dropGoldFlag = 0; - ClearSText(0, 24); - ReleaseStoreBtn(); - switch ( t ) - { - case STORE_SMITH: - S_StartSmith(); - break; - case STORE_SBUY: - if ( storenumh > 0 ) - S_StartSBuy(); - break; - case STORE_SSELL: - S_StartSSell(); - break; - case STORE_SREPAIR: - S_StartSRepair(); - break; - case STORE_WITCH: - S_StartWitch(); - break; - case STORE_WBUY: - if ( storenumh > 0 ) - S_StartWBuy(); - break; - case STORE_WSELL: - S_StartWSell(); - break; - case STORE_WRECHARGE: - S_StartWRecharge(); - break; - case STORE_NOMONEY: - S_StartNoMoney(); - break; - case STORE_NOROOM: - S_StartNoRoom(); - break; - case STORE_CONFIRM: - S_StartConfirm(); - break; - case STORE_BOY: - S_StartBoy(); - break; - case STORE_BBOY: - S_StartBBoy(); - break; - case STORE_HEALER: - S_StartHealer(); - break; - case STORE_STORY: - S_StartStory(); - break; - case STORE_HBUY: - if ( storenumh > 0 ) - S_StartHBuy(); - break; - case STORE_SIDENTIFY: - S_StartSIdentify(); - break; - case STORE_SPBUY: - if ( !S_StartSPBuy() ) - return; - break; - case STORE_GOSSIP: - S_StartTalk(); - break; - case STORE_IDSHOW: - S_StartIdShow(); - break; - case STORE_TAVERN: - S_StartTavern(); - break; - case STORE_DRUNK: - S_StartDrunk(); - break; - case STORE_BARMAID: - S_StartBarMaid(); - break; - default: - break; - } - - for(i = 0; i < 24; i++) - { - if ( stext[i]._ssel ) - break; - } - - stextsel = i == 24 ? -1 : i; - stextflag = t; - if ( t != 2 || storenumh ) - break; - } + char t; // bl + int i; // ecx + + for (t = s;; t = 1) { + sbookflag = 0; + invflag = 0; + chrflag = 0; + questlog = 0; + dropGoldFlag = 0; + ClearSText(0, 24); + ReleaseStoreBtn(); + switch (t) { + case STORE_SMITH: + S_StartSmith(); + break; + case STORE_SBUY: + if (storenumh > 0) + S_StartSBuy(); + break; + case STORE_SSELL: + S_StartSSell(); + break; + case STORE_SREPAIR: + S_StartSRepair(); + break; + case STORE_WITCH: + S_StartWitch(); + break; + case STORE_WBUY: + if (storenumh > 0) + S_StartWBuy(); + break; + case STORE_WSELL: + S_StartWSell(); + break; + case STORE_WRECHARGE: + S_StartWRecharge(); + break; + case STORE_NOMONEY: + S_StartNoMoney(); + break; + case STORE_NOROOM: + S_StartNoRoom(); + break; + case STORE_CONFIRM: + S_StartConfirm(); + break; + case STORE_BOY: + S_StartBoy(); + break; + case STORE_BBOY: + S_StartBBoy(); + break; + case STORE_HEALER: + S_StartHealer(); + break; + case STORE_STORY: + S_StartStory(); + break; + case STORE_HBUY: + if (storenumh > 0) + S_StartHBuy(); + break; + case STORE_SIDENTIFY: + S_StartSIdentify(); + break; + case STORE_SPBUY: + if (!S_StartSPBuy()) + return; + break; + case STORE_GOSSIP: + S_StartTalk(); + break; + case STORE_IDSHOW: + S_StartIdShow(); + break; + case STORE_TAVERN: + S_StartTavern(); + break; + case STORE_DRUNK: + S_StartDrunk(); + break; + case STORE_BARMAID: + S_StartBarMaid(); + break; + default: + break; + } + + for (i = 0; i < 24; i++) { + if (stext[i]._ssel) + break; + } + + stextsel = i == 24 ? -1 : i; + stextflag = t; + if (t != 2 || storenumh) + break; + } } // 4B84DC: using guessed type int dropGoldFlag; // 4B8968: using guessed type int sbookflag; @@ -2139,63 +1952,55 @@ void __fastcall StartStore(char s) void __cdecl DrawSText() { - int i; // edi - - if ( stextsize ) - DrawQTextBack(); - else - DrawSTextBack(); - if ( !stextscrl ) - goto LABEL_19; - if ( stextflag > (signed int)STORE_WRECHARGE ) - { - switch ( stextflag ) - { - case STORE_HBUY: - S_ScrollHBuy(stextsval); - break; - case STORE_SIDENTIFY: - goto LABEL_17; - case STORE_SPBUY: - S_ScrollSPBuy(stextsval); - break; - } - } - else - { - if ( stextflag >= (signed int)STORE_WSELL ) - goto LABEL_17; - if ( stextflag == STORE_SBUY ) - { - S_ScrollSBuy(stextsval); - goto LABEL_19; - } - if ( stextflag > (signed int)STORE_SBUY ) - { - if ( stextflag > (signed int)STORE_SREPAIR ) - { - if ( stextflag == STORE_WBUY ) - S_ScrollWBuy(stextsval); - goto LABEL_19; - } -LABEL_17: - S_ScrollSSell(stextsval); - goto LABEL_19; - } - } + int i; // edi + + if (stextsize) + DrawQTextBack(); + else + DrawSTextBack(); + if (!stextscrl) + goto LABEL_19; + if (stextflag > (signed int)STORE_WRECHARGE) { + switch (stextflag) { + case STORE_HBUY: + S_ScrollHBuy(stextsval); + break; + case STORE_SIDENTIFY: + goto LABEL_17; + case STORE_SPBUY: + S_ScrollSPBuy(stextsval); + break; + } + } else { + if (stextflag >= (signed int)STORE_WSELL) + goto LABEL_17; + if (stextflag == STORE_SBUY) { + S_ScrollSBuy(stextsval); + goto LABEL_19; + } + if (stextflag > (signed int)STORE_SBUY) { + if (stextflag > (signed int)STORE_SREPAIR) { + if (stextflag == STORE_WBUY) + S_ScrollWBuy(stextsval); + goto LABEL_19; + } + LABEL_17: + S_ScrollSSell(stextsval); + goto LABEL_19; + } + } LABEL_19: - for(i = 0; i < 24; i++) - { - if ( stext[i]._sline ) - DrawSLine(i); - if ( stext[i]._sstr ) - PrintSString(stext[i]._sx, i, stext[i]._sjust, stext[i]._sstr, stext[i]._sclr, stext[i]._sval); - } - - if ( stextscrl ) - DrawSArrows(4, 20); - InStoreFlag = (InStoreFlag & 7) + 1; + for (i = 0; i < 24; i++) { + if (stext[i]._sline) + DrawSLine(i); + if (stext[i]._sstr) + PrintSString(stext[i]._sx, i, stext[i]._sjust, stext[i]._sstr, stext[i]._sclr, stext[i]._sval); + } + + if (stextscrl) + DrawSArrows(4, 20); + InStoreFlag = (InStoreFlag & 7) + 1; } // 6A09E0: using guessed type char stextsize; // 6A6BB8: using guessed type int stextscrl; @@ -2203,86 +2008,82 @@ LABEL_19: void __cdecl STextESC() { - char v0; // cl - char v1; // cl - char v2; // cl - - if ( qtextflag ) - { - qtextflag = FALSE; - if ( leveltype == DTYPE_TOWN ) - sfx_stop(); - } - else - { - switch ( stextflag ) - { - case STORE_SMITH: - case STORE_WITCH: - case STORE_BOY: - case STORE_BBOY: - case STORE_HEALER: - case STORE_STORY: - case STORE_TAVERN: - case STORE_DRUNK: - case STORE_BARMAID: - stextflag = 0; - return; - case STORE_SBUY: - StartStore(STORE_SMITH); - stextsel = 12; - return; - case STORE_SSELL: - v1 = STORE_SMITH; - goto LABEL_16; - case STORE_SREPAIR: - v2 = STORE_SMITH; - goto LABEL_14; - case STORE_WBUY: - v0 = STORE_WITCH; - goto LABEL_18; - case STORE_WSELL: - v1 = STORE_WITCH; - goto LABEL_16; - case STORE_WRECHARGE: - v2 = STORE_WITCH; -LABEL_14: - StartStore(v2); - stextsel = 18; - return; - case STORE_NOMONEY: - case STORE_NOROOM: - case STORE_CONFIRM: - StartStore((unsigned char)stextshold); - stextsel = stextlhold; - stextsval = stextvhold; - return; - case STORE_HBUY: - v1 = STORE_HEALER; -LABEL_16: - StartStore(v1); - stextsel = 16; - return; - case STORE_SIDENTIFY: - v0 = STORE_STORY; - goto LABEL_18; - case STORE_SPBUY: - v0 = STORE_SMITH; -LABEL_18: - StartStore(v0); - stextsel = 14; - break; - case STORE_GOSSIP: - StartStore((unsigned char)stextshold); - stextsel = stextlhold; - break; - case STORE_IDSHOW: - StartStore(STORE_SIDENTIFY); - break; - default: - return; - } - } + char v0; // cl + char v1; // cl + char v2; // cl + + if (qtextflag) { + qtextflag = FALSE; + if (leveltype == DTYPE_TOWN) + sfx_stop(); + } else { + switch (stextflag) { + case STORE_SMITH: + case STORE_WITCH: + case STORE_BOY: + case STORE_BBOY: + case STORE_HEALER: + case STORE_STORY: + case STORE_TAVERN: + case STORE_DRUNK: + case STORE_BARMAID: + stextflag = 0; + return; + case STORE_SBUY: + StartStore(STORE_SMITH); + stextsel = 12; + return; + case STORE_SSELL: + v1 = STORE_SMITH; + goto LABEL_16; + case STORE_SREPAIR: + v2 = STORE_SMITH; + goto LABEL_14; + case STORE_WBUY: + v0 = STORE_WITCH; + goto LABEL_18; + case STORE_WSELL: + v1 = STORE_WITCH; + goto LABEL_16; + case STORE_WRECHARGE: + v2 = STORE_WITCH; + LABEL_14: + StartStore(v2); + stextsel = 18; + return; + case STORE_NOMONEY: + case STORE_NOROOM: + case STORE_CONFIRM: + StartStore((unsigned char)stextshold); + stextsel = stextlhold; + stextsval = stextvhold; + return; + case STORE_HBUY: + v1 = STORE_HEALER; + LABEL_16: + StartStore(v1); + stextsel = 16; + return; + case STORE_SIDENTIFY: + v0 = STORE_STORY; + goto LABEL_18; + case STORE_SPBUY: + v0 = STORE_SMITH; + LABEL_18: + StartStore(v0); + stextsel = 14; + break; + case STORE_GOSSIP: + StartStore((unsigned char)stextshold); + stextsel = stextlhold; + break; + case STORE_IDSHOW: + StartStore(STORE_SIDENTIFY); + break; + default: + return; + } + } } // 646D00: using guessed type char qtextflag; // 69F110: using guessed type int stextlhold; @@ -2292,53 +2093,45 @@ LABEL_18: void __cdecl STextUp() { - int v0; // eax - - PlaySFX(IS_TITLEMOV); - if ( stextsel != -1 ) - { - if ( stextscrl ) - { - if ( stextsel == stextup ) - { - if ( stextsval ) - --stextsval; - return; - } - v0 = stextsel - 1; - stextsel = v0; - if ( stext[v0]._ssel ) - return; - do - { - if ( v0 ) - --v0; - else - v0 = 23; - } - while ( !stext[v0]._ssel ); -LABEL_20: - stextsel = v0; - return; - } - if ( stextsel ) - v0 = stextsel - 1; - else - v0 = 23; - stextsel = v0; - if ( !stext[v0]._ssel ) - { - do - { - if ( v0 ) - --v0; - else - v0 = 23; - } - while ( !stext[v0]._ssel ); - goto LABEL_20; - } - } + int v0; // eax + + PlaySFX(IS_TITLEMOV); + if (stextsel != -1) { + if (stextscrl) { + if (stextsel == stextup) { + if (stextsval) + --stextsval; + return; + } + v0 = stextsel - 1; + stextsel = v0; + if (stext[v0]._ssel) + return; + do { + if (v0) + --v0; + else + v0 = 23; + } while (!stext[v0]._ssel); + LABEL_20: + stextsel = v0; + return; + } + if (stextsel) + v0 = stextsel - 1; + else + v0 = 23; + stextsel = v0; + if (!stext[v0]._ssel) { + do { + if (v0) + --v0; + else + v0 = 23; + } while (!stext[v0]._ssel); + goto LABEL_20; + } + } } // 69F108: using guessed type int stextup; // 6A6BB8: using guessed type int stextscrl; @@ -2346,53 +2139,45 @@ LABEL_20: void __cdecl STextDown() { - int v0; // eax - - PlaySFX(IS_TITLEMOV); - if ( stextsel != -1 ) - { - if ( stextscrl ) - { - if ( stextsel == stextdown ) - { - if ( stextsval < stextsmax ) - ++stextsval; - return; - } - v0 = stextsel + 1; - stextsel = v0; - if ( stext[v0]._ssel ) - return; - do - { - if ( v0 == 23 ) - v0 = 0; - else - ++v0; - } - while ( !stext[v0]._ssel ); -LABEL_20: - stextsel = v0; - return; - } - if ( stextsel == 23 ) - v0 = 0; - else - v0 = stextsel + 1; - stextsel = v0; - if ( !stext[v0]._ssel ) - { - do - { - if ( v0 == 23 ) - v0 = 0; - else - ++v0; - } - while ( !stext[v0]._ssel ); - goto LABEL_20; - } - } + int v0; // eax + + PlaySFX(IS_TITLEMOV); + if (stextsel != -1) { + if (stextscrl) { + if (stextsel == stextdown) { + if (stextsval < stextsmax) + ++stextsval; + return; + } + v0 = stextsel + 1; + stextsel = v0; + if (stext[v0]._ssel) + return; + do { + if (v0 == 23) + v0 = 0; + else + ++v0; + } while (!stext[v0]._ssel); + LABEL_20: + stextsel = v0; + return; + } + if (stextsel == 23) + v0 = 0; + else + v0 = stextsel + 1; + stextsel = v0; + if (!stext[v0]._ssel) { + do { + if (v0 == 23) + v0 = 0; + else + ++v0; + } while (!stext[v0]._ssel); + goto LABEL_20; + } + } } // 6A09E4: using guessed type int stextsmax; // 6A6BB8: using guessed type int stextscrl; @@ -2401,23 +2186,18 @@ LABEL_20: void __cdecl STextPrior() { - PlaySFX(IS_TITLEMOV); - if ( stextsel != -1 && stextscrl ) - { - if ( stextsel == stextup ) - { - if ( stextsval ) - { - stextsval -= 4; - if ( stextsval < 0 ) - stextsval = 0; - } - } - else - { - stextsel = stextup; - } - } + PlaySFX(IS_TITLEMOV); + if (stextsel != -1 && stextscrl) { + if (stextsel == stextup) { + if (stextsval) { + stextsval -= 4; + if (stextsval < 0) + stextsval = 0; + } + } else { + stextsel = stextup; + } + } } // 69F108: using guessed type int stextup; // 6A6BB8: using guessed type int stextscrl; @@ -2425,21 +2205,17 @@ void __cdecl STextPrior() void __cdecl STextNext() { - PlaySFX(IS_TITLEMOV); - if ( stextsel != -1 && stextscrl ) - { - if ( stextsel == stextdown ) - { - if ( stextsval < stextsmax ) - stextsval += 4; - if ( stextsval > stextsmax ) - stextsval = stextsmax; - } - else - { - stextsel = stextdown; - } - } + PlaySFX(IS_TITLEMOV); + if (stextsel != -1 && stextscrl) { + if (stextsel == stextdown) { + if (stextsval < stextsmax) + stextsval += 4; + if (stextsval > stextsmax) + stextsval = stextsmax; + } else { + stextsel = stextdown; + } + } } // 6A09E4: using guessed type int stextsmax; // 6A6BB8: using guessed type int stextscrl; @@ -2448,39 +2224,37 @@ void __cdecl STextNext() void __cdecl S_SmithEnter() { - int v0; // ecx - - v0 = 10; - if ( stextsel == 10 ) - { - talker = 0; - stextlhold = 10; - stextshold = 1; - gossipstart = QUEST_GRISWOLD2; - gossipend = QUEST_GRISWOLD13; - _LOBYTE(v0) = STORE_GOSSIP; - goto LABEL_13; - } - v0 = STORE_SBUY; - switch ( stextsel ) - { - case 12: -LABEL_13: - StartStore(v0); - return; - case 14: - _LOBYTE(v0) = STORE_SPBUY; - goto LABEL_13; - case 16: - _LOBYTE(v0) = STORE_SSELL; - goto LABEL_13; - case 18: - _LOBYTE(v0) = STORE_SREPAIR; - goto LABEL_13; - case 20: - stextflag = 0; - break; - } + int v0; // ecx + + v0 = 10; + if (stextsel == 10) { + talker = 0; + stextlhold = 10; + stextshold = 1; + gossipstart = QUEST_GRISWOLD2; + gossipend = QUEST_GRISWOLD13; + _LOBYTE(v0) = STORE_GOSSIP; + goto LABEL_13; + } + v0 = STORE_SBUY; + switch (stextsel) { + case 12: + LABEL_13: + StartStore(v0); + return; + case 14: + _LOBYTE(v0) = STORE_SPBUY; + goto LABEL_13; + case 16: + _LOBYTE(v0) = STORE_SSELL; + goto LABEL_13; + case 18: + _LOBYTE(v0) = STORE_SREPAIR; + goto LABEL_13; + case 20: + stextflag = 0; + break; + } } // 69F110: using guessed type int stextlhold; // 69FB38: using guessed type int talker; @@ -2491,236 +2265,192 @@ LABEL_13: void __fastcall SetGoldCurs(int pnum, int i) { - if ( plr[pnum].InvList[i]._ivalue < 2500 ) - { - if ( plr[pnum].InvList[i]._ivalue > 1000 ) - plr[pnum].InvList[i]._iCurs = ICURS_GOLD_MEDIUM; - else - plr[pnum].InvList[i]._iCurs = ICURS_GOLD_SMALL; - } - else - { - plr[pnum].InvList[i]._iCurs = ICURS_GOLD_LARGE; - } + if (plr[pnum].InvList[i]._ivalue < 2500) { + if (plr[pnum].InvList[i]._ivalue > 1000) + plr[pnum].InvList[i]._iCurs = ICURS_GOLD_MEDIUM; + else + plr[pnum].InvList[i]._iCurs = ICURS_GOLD_SMALL; + } else { + plr[pnum].InvList[i]._iCurs = ICURS_GOLD_LARGE; + } } void __fastcall SetSpdbarGoldCurs(int pnum, int i) { - if ( plr[pnum].SpdList[i]._ivalue < 2500 ) - { - if ( plr[pnum].SpdList[i]._ivalue > 1000 ) - plr[pnum].SpdList[i]._iCurs = ICURS_GOLD_MEDIUM; - else - plr[pnum].SpdList[i]._iCurs = ICURS_GOLD_SMALL; - } - else - { - plr[pnum].SpdList[i]._iCurs = ICURS_GOLD_LARGE; - } + if (plr[pnum].SpdList[i]._ivalue < 2500) { + if (plr[pnum].SpdList[i]._ivalue > 1000) + plr[pnum].SpdList[i]._iCurs = ICURS_GOLD_MEDIUM; + else + plr[pnum].SpdList[i]._iCurs = ICURS_GOLD_SMALL; + } else { + plr[pnum].SpdList[i]._iCurs = ICURS_GOLD_LARGE; + } } void __fastcall TakePlrsMoney(int cost) { - int v1; // edi - int v2; // eax - int v3; // esi - int v4; // ebx - int v5; // eax - _DWORD *v6; // ecx - int v7; // eax - int v8; // ebx - int v9; // eax - _DWORD *v10; // ecx - int v11; // eax - signed int v12; // ebx - int v13; // eax - int v14; // eax - _DWORD *v15; // ecx - int v16; // eax - signed int v17; // ebx - int v18; // eax - int v19; // eax - _DWORD *v20; // ecx - int v21; // eax - - v1 = cost; - v2 = CalculateGold(myplr); - v3 = myplr; - v4 = 0; - plr[myplr]._pGold = v2 - v1; - while ( v1 > 0 ) - { - v5 = 368 * v4 + 21720 * v3; - if ( *(int *)((char *)&plr[0].SpdList[0]._itype + v5) == ITYPE_GOLD ) - { - v6 = (unsigned int *)((char *)&plr[0].SpdList[0]._ivalue + v5); - v7 = *(int *)((char *)&plr[0].SpdList[0]._ivalue + v5); - if ( v7 != 5000 ) - { - if ( v1 >= v7 ) - { - v1 -= v7; - RemoveSpdBarItem(v3, v4); - v3 = myplr; - v4 = -1; - } - else - { - *v6 = v7 - v1; - SetSpdbarGoldCurs(v3, v4); - v1 = 0; - } - } - } - if ( ++v4 >= MAXBELTITEMS ) - { - if ( v1 > 0 ) - { - v8 = 0; - do - { - if ( v1 <= 0 ) - break; - v9 = 368 * v8 + 21720 * v3; - if ( *(int *)((char *)&plr[0].SpdList[0]._itype + v9) == ITYPE_GOLD ) - { - v10 = (unsigned int *)((char *)&plr[0].SpdList[0]._ivalue + v9); - v11 = *(int *)((char *)&plr[0].SpdList[0]._ivalue + v9); - if ( v1 >= v11 ) - { - v1 -= v11; - RemoveSpdBarItem(v3, v8); - v3 = myplr; - v8 = -1; - } - else - { - *v10 = v11 - v1; - SetSpdbarGoldCurs(v3, v8); - v1 = 0; - } - } - ++v8; - } - while ( v8 < MAXBELTITEMS ); - } - break; - } - } - v12 = 0; - drawpanflag = 255; - if ( v1 > 0 ) - { - v13 = 21720 * v3; - if ( plr[v3]._pNumInv <= 0 ) - { -LABEL_26: - v17 = 0; - if ( v1 > 0 ) - { - v18 = 21720 * v3; - if ( plr[v3]._pNumInv > 0 ) - { - do - { - if ( v1 <= 0 ) - break; - v19 = 368 * v17 + v18; - if ( *(int *)((char *)&plr[0].InvList[0]._itype + v19) == ITYPE_GOLD ) - { - v20 = (unsigned int *)((char *)&plr[0].InvList[0]._ivalue + v19); - v21 = *(int *)((char *)&plr[0].InvList[0]._ivalue + v19); - if ( v1 >= v21 ) - { - v1 -= v21; - RemoveInvItem(v3, v17); - v3 = myplr; - v17 = -1; - } - else - { - *v20 = v21 - v1; - SetGoldCurs(v3, v17); - v1 = 0; - } - } - ++v17; - v18 = 21720 * v3; - } - while ( v17 < plr[v3]._pNumInv ); - } - } - } - else - { - while ( v1 > 0 ) - { - v14 = 368 * v12 + v13; - if ( *(int *)((char *)&plr[0].InvList[0]._itype + v14) == ITYPE_GOLD ) - { - v15 = (unsigned int *)((char *)&plr[0].InvList[0]._ivalue + v14); - v16 = *(int *)((char *)&plr[0].InvList[0]._ivalue + v14); - if ( v16 != 5000 ) - { - if ( v1 >= v16 ) - { - v1 -= v16; - RemoveInvItem(v3, v12); - v3 = myplr; - v12 = -1; - } - else - { - *v15 = v16 - v1; - SetGoldCurs(v3, v12); - v1 = 0; - } - } - } - ++v12; - v13 = 21720 * v3; - if ( v12 >= plr[v3]._pNumInv ) - goto LABEL_26; - } - } - } + int v1; // edi + int v2; // eax + int v3; // esi + int v4; // ebx + int v5; // eax + _DWORD *v6; // ecx + int v7; // eax + int v8; // ebx + int v9; // eax + _DWORD *v10; // ecx + int v11; // eax + signed int v12; // ebx + int v13; // eax + int v14; // eax + _DWORD *v15; // ecx + int v16; // eax + signed int v17; // ebx + int v18; // eax + int v19; // eax + _DWORD *v20; // ecx + int v21; // eax + + v1 = cost; + v2 = CalculateGold(myplr); + v3 = myplr; + v4 = 0; + plr[myplr]._pGold = v2 - v1; + while (v1 > 0) { + v5 = 368 * v4 + 21720 * v3; + if (*(int *)((char *)&plr[0].SpdList[0]._itype + v5) == ITYPE_GOLD) { + v6 = (unsigned int *)((char *)&plr[0].SpdList[0]._ivalue + v5); + v7 = *(int *)((char *)&plr[0].SpdList[0]._ivalue + v5); + if (v7 != 5000) { + if (v1 >= v7) { + v1 -= v7; + RemoveSpdBarItem(v3, v4); + v3 = myplr; + v4 = -1; + } else { + *v6 = v7 - v1; + SetSpdbarGoldCurs(v3, v4); + v1 = 0; + } + } + } + if (++v4 >= MAXBELTITEMS) { + if (v1 > 0) { + v8 = 0; + do { + if (v1 <= 0) + break; + v9 = 368 * v8 + 21720 * v3; + if (*(int *)((char *)&plr[0].SpdList[0]._itype + v9) == ITYPE_GOLD) { + v10 = (unsigned int *)((char *)&plr[0].SpdList[0]._ivalue + v9); + v11 = *(int *)((char *)&plr[0].SpdList[0]._ivalue + v9); + if (v1 >= v11) { + v1 -= v11; + RemoveSpdBarItem(v3, v8); + v3 = myplr; + v8 = -1; + } else { + *v10 = v11 - v1; + SetSpdbarGoldCurs(v3, v8); + v1 = 0; + } + } + ++v8; + } while (v8 < MAXBELTITEMS); + } + break; + } + } + v12 = 0; + drawpanflag = 255; + if (v1 > 0) { + v13 = 21720 * v3; + if (plr[v3]._pNumInv <= 0) { + LABEL_26: + v17 = 0; + if (v1 > 0) { + v18 = 21720 * v3; + if (plr[v3]._pNumInv > 0) { + do { + if (v1 <= 0) + break; + v19 = 368 * v17 + v18; + if (*(int *)((char *)&plr[0].InvList[0]._itype + v19) == ITYPE_GOLD) { + v20 = (unsigned int *)((char *)&plr[0].InvList[0]._ivalue + v19); + v21 = *(int *)((char *)&plr[0].InvList[0]._ivalue + v19); + if (v1 >= v21) { + v1 -= v21; + RemoveInvItem(v3, v17); + v3 = myplr; + v17 = -1; + } else { + *v20 = v21 - v1; + SetGoldCurs(v3, v17); + v1 = 0; + } + } + ++v17; + v18 = 21720 * v3; + } while (v17 < plr[v3]._pNumInv); + } + } + } else { + while (v1 > 0) { + v14 = 368 * v12 + v13; + if (*(int *)((char *)&plr[0].InvList[0]._itype + v14) == ITYPE_GOLD) { + v15 = (unsigned int *)((char *)&plr[0].InvList[0]._ivalue + v14); + v16 = *(int *)((char *)&plr[0].InvList[0]._ivalue + v14); + if (v16 != 5000) { + if (v1 >= v16) { + v1 -= v16; + RemoveInvItem(v3, v12); + v3 = myplr; + v12 = -1; + } else { + *v15 = v16 - v1; + SetGoldCurs(v3, v12); + v1 = 0; + } + } + } + ++v12; + v13 = 21720 * v3; + if (v12 >= plr[v3]._pNumInv) + goto LABEL_26; + } + } + } } // 52571C: using guessed type int drawpanflag; void __cdecl SmithBuyItem() { - int idx; // eax - ItemStruct *v1; // edx - ItemStruct *v2; // edi - bool v3; // zf - - TakePlrsMoney(plr[myplr].HoldItem._iIvalue); - if ( plr[myplr].HoldItem._iMagical == ITEM_QUALITY_NORMAL ) - plr[myplr].HoldItem._iIdentified = FALSE; - StoreAutoPlace(); - idx = stextvhold + ((stextlhold - stextup) >> 2); - if ( idx == 19 ) - { - smithitem[19]._itype = -1; - } - else - { - if ( smithitem[idx + 1]._itype != -1 ) - { - v1 = &smithitem[idx]; - do - { - v2 = v1; - ++v1; - ++idx; - v3 = v1[1]._itype == -1; - qmemcpy(v2, v1, sizeof(ItemStruct)); - } - while ( !v3 ); - } - smithitem[idx]._itype = -1; - } - CalcPlrInv(myplr, 1u); + int idx; // eax + ItemStruct *v1; // edx + ItemStruct *v2; // edi + bool v3; // zf + + TakePlrsMoney(plr[myplr].HoldItem._iIvalue); + if (plr[myplr].HoldItem._iMagical == ITEM_QUALITY_NORMAL) + plr[myplr].HoldItem._iIdentified = FALSE; + StoreAutoPlace(); + idx = stextvhold + ((stextlhold - stextup) >> 2); + if (idx == 19) { + smithitem[19]._itype = -1; + } else { + if (smithitem[idx + 1]._itype != -1) { + v1 = &smithitem[idx]; + do { + v2 = v1; + ++v1; + ++idx; + v3 = v1[1]._itype == -1; + qmemcpy(v2, v1, sizeof(ItemStruct)); + } while (!v3); + } + smithitem[idx]._itype = -1; + } + CalcPlrInv(myplr, 1u); } // 69F108: using guessed type int stextup; // 69F110: using guessed type int stextlhold; @@ -2728,53 +2458,44 @@ void __cdecl SmithBuyItem() void __cdecl S_SBuyEnter() { - int v0; // eax - int idx; // ecx - int done; // eax - int i; // esi - char v4; // cl - - if ( stextsel == 22 ) - { - StartStore(STORE_SMITH); - stextsel = 12; - } - else - { - stextlhold = stextsel; - stextvhold = stextsval; - stextshold = 2; - v0 = myplr; - idx = stextsval + ((stextsel - stextup) >> 2); - if ( plr[myplr]._pGold >= smithitem[idx]._iIvalue ) - { - qmemcpy(&plr[v0].HoldItem, &smithitem[idx], sizeof(plr[v0].HoldItem)); - SetCursor(plr[v0].HoldItem._iCurs + 12); - done = 0; - i = 0; - do - { - if ( done ) - goto LABEL_9; - done = AutoPlace(myplr, i++, cursW / 28, cursH / 28, 0); - } - while ( i < 40 ); - if ( done ) - { -LABEL_9: - v4 = STORE_CONFIRM; - goto LABEL_11; - } - v4 = STORE_NOROOM; -LABEL_11: - StartStore(v4); - SetCursor(CURSOR_HAND); - } - else - { - StartStore(STORE_NOMONEY); - } - } + int v0; // eax + int idx; // ecx + int done; // eax + int i; // esi + char v4; // cl + + if (stextsel == 22) { + StartStore(STORE_SMITH); + stextsel = 12; + } else { + stextlhold = stextsel; + stextvhold = stextsval; + stextshold = 2; + v0 = myplr; + idx = stextsval + ((stextsel - stextup) >> 2); + if (plr[myplr]._pGold >= smithitem[idx]._iIvalue) { + qmemcpy(&plr[v0].HoldItem, &smithitem[idx], sizeof(plr[v0].HoldItem)); + SetCursor(plr[v0].HoldItem._iCurs + 12); + done = 0; + i = 0; + do { + if (done) + goto LABEL_9; + done = AutoPlace(myplr, i++, cursW / 28, cursH / 28, 0); + } while (i < 40); + if (done) { + LABEL_9: + v4 = STORE_CONFIRM; + goto LABEL_11; + } + v4 = STORE_NOROOM; + LABEL_11: + StartStore(v4); + SetCursor(CURSOR_HAND); + } else { + StartStore(STORE_NOMONEY); + } + } } // 4B8C9C: using guessed type int cursH; // 69F108: using guessed type int stextup; @@ -2784,38 +2505,34 @@ LABEL_11: void __cdecl SmithBuyPItem() { - int xx; // ecx - int idx; // eax - bool v2; // sf - int v3; // eax - int i; // edx - - TakePlrsMoney(plr[myplr].HoldItem._iIvalue); - if ( plr[myplr].HoldItem._iMagical == ITEM_QUALITY_NORMAL ) - plr[myplr].HoldItem._iIdentified = FALSE; - StoreAutoPlace(); - xx = 0; - idx = (stextlhold - stextup) >> 2; - v2 = stextvhold + idx < 0; - v3 = stextvhold + idx; - i = 0; - if ( !v2 ) - { - do - { - if ( premiumitem[i]._itype != -1 ) - { - --v3; - xx = i; - } - ++i; - } - while ( v3 >= 0 ); - } - - premiumitem[xx]._itype = -1; - --numpremium; - SpawnPremium(plr[myplr]._pLevel); + int xx; // ecx + int idx; // eax + bool v2; // sf + int v3; // eax + int i; // edx + + TakePlrsMoney(plr[myplr].HoldItem._iIvalue); + if (plr[myplr].HoldItem._iMagical == ITEM_QUALITY_NORMAL) + plr[myplr].HoldItem._iIdentified = FALSE; + StoreAutoPlace(); + xx = 0; + idx = (stextlhold - stextup) >> 2; + v2 = stextvhold + idx < 0; + v3 = stextvhold + idx; + i = 0; + if (!v2) { + do { + if (premiumitem[i]._itype != -1) { + --v3; + xx = i; + } + ++i; + } while (v3 >= 0); + } + + premiumitem[xx]._itype = -1; + --numpremium; + SpawnPremium(plr[myplr]._pLevel); } // 69F108: using guessed type int stextup; // 69F110: using guessed type int stextlhold; @@ -2823,79 +2540,66 @@ void __cdecl SmithBuyPItem() void __cdecl S_SPBuyEnter() { - int v0; // eax - bool v1; // sf - int v2; // eax - int v3; // ecx - int v4; // edx - int *v5; // esi - int v6; // ecx - int v7; // eax - int v8; // eax - int v9; // esi - char v10; // cl - - if ( stextsel == 22 ) - { - StartStore(STORE_SMITH); - stextsel = 14; - } - else - { - stextlhold = stextsel; - stextshold = 18; - stextvhold = stextsval; - v0 = (stextsel - stextup) >> 2; - v1 = stextsval + v0 < 0; - v2 = stextsval + v0; - v3 = 0; - v4 = 0; - if ( !v1 ) - { - v5 = &premiumitem[0]._itype; - do - { - if ( *v5 != -1 ) - { - --v2; - v3 = v4; - } - ++v4; - v5 += 92; - } - while ( v2 >= 0 ); - } - v6 = v3; - v7 = myplr; - if ( plr[myplr]._pGold >= premiumitem[v6]._iIvalue ) - { - qmemcpy(&plr[v7].HoldItem, &premiumitem[v6], sizeof(plr[v7].HoldItem)); - SetCursor(plr[v7].HoldItem._iCurs + 12); - v8 = 0; - v9 = 0; - do - { - if ( v8 ) - goto LABEL_14; - v8 = AutoPlace(myplr, v9++, cursW / 28, cursH / 28, 0); - } - while ( v9 < 40 ); - if ( v8 ) - { -LABEL_14: - v10 = STORE_CONFIRM; - goto LABEL_16; - } - v10 = STORE_NOROOM; -LABEL_16: - StartStore(v10); - SetCursor(CURSOR_HAND); - } - else - { - StartStore(STORE_NOMONEY); - } - } + int v0; // eax + bool v1; // sf + int v2; // eax + int v3; // ecx + int v4; // edx + int *v5; // esi + int v6; // ecx + int v7; // eax + int v8; // eax + int v9; // esi + char v10; // cl + + if (stextsel == 22) { + StartStore(STORE_SMITH); + stextsel = 14; + } else { + stextlhold = stextsel; + stextshold = 18; + stextvhold = stextsval; + v0 = (stextsel - stextup) >> 2; + v1 = stextsval + v0 < 0; + v2 = stextsval + v0; + v3 = 0; + v4 = 0; + if (!v1) { + v5 = &premiumitem[0]._itype; + do { + if (*v5 != -1) { + --v2; + v3 = v4; + } + ++v4; + v5 += 92; + } while (v2 >= 0); + } + v6 = v3; + v7 = myplr; + if (plr[myplr]._pGold >= premiumitem[v6]._iIvalue) { + qmemcpy(&plr[v7].HoldItem, &premiumitem[v6], sizeof(plr[v7].HoldItem)); + SetCursor(plr[v7].HoldItem._iCurs + 12); + v8 = 0; + v9 = 0; + do { + if (v8) + goto LABEL_14; + v8 = AutoPlace(myplr, v9++, cursW / 28, cursH / 28, 0); + } while (v9 < 40); + if (v8) { + LABEL_14: + v10 = STORE_CONFIRM; + goto LABEL_16; + } + v10 = STORE_NOROOM; + LABEL_16: + StartStore(v10); + SetCursor(CURSOR_HAND); + } else { + StartStore(STORE_NOMONEY); + } + } } // 4B8C9C: using guessed type int cursH; // 69F108: using guessed type int stextup; @@ -2905,158 +2609,140 @@ LABEL_16: bool __fastcall StoreGoldFit(int idx) { - int cost; // edi - int i; // ecx - int sz; // eax - int numsqrs; // [esp+Ch] [ebp-4h] - - cost = storehold[idx]._iIvalue; - sz = cost / 5000; - if ( cost % 5000 ) - sz++; - - SetCursor(storehold[idx]._iCurs + 12); - numsqrs = cursW / 28 * (cursH / 28); - SetCursor(CURSOR_HAND); - - if ( numsqrs >= sz ) - return 1; - - for(i = 0; i < 40; i++) - { - if ( !plr[myplr].InvGrid[i] ) - numsqrs++; - } - - for(i = 0; i < plr[myplr]._pNumInv; i++) - { - if ( plr[myplr].InvList[i]._itype == ITYPE_GOLD && plr[myplr].InvList[i]._ivalue != 5000 ) - { - cost += plr[myplr].InvList[i]._ivalue; - if ( cost > 5000 ) - cost -= 5000; - else - cost = 0; - } - } - - sz = cost / 5000; - if ( cost % 5000 ) - sz++; - return numsqrs >= sz; + int cost; // edi + int i; // ecx + int sz; // eax + int numsqrs; // [esp+Ch] [ebp-4h] + + cost = storehold[idx]._iIvalue; + sz = cost / 5000; + if (cost % 5000) + sz++; + + SetCursor(storehold[idx]._iCurs + 12); + numsqrs = cursW / 28 * (cursH / 28); + SetCursor(CURSOR_HAND); + + if (numsqrs >= sz) + return 1; + + for (i = 0; i < 40; i++) { + if (!plr[myplr].InvGrid[i]) + numsqrs++; + } + + for (i = 0; i < plr[myplr]._pNumInv; i++) { + if (plr[myplr].InvList[i]._itype == ITYPE_GOLD && plr[myplr].InvList[i]._ivalue != 5000) { + cost += plr[myplr].InvList[i]._ivalue; + if (cost > 5000) + cost -= 5000; + else + cost = 0; + } + } + + sz = cost / 5000; + if (cost % 5000) + sz++; + return numsqrs >= sz; } // 4B8C9C: using guessed type int cursH; void __fastcall PlaceStoreGold(int v) { - bool done; // ecx - int ii; // ebp - int xx; // esi - int yy; // ST20_4 - int i; // [esp+10h] [ebp-10h] - - done = 0; - - for(i = 0; i < 40; i++) - { - if ( done ) - break; - ii = 10 * (i / 10); - if ( !plr[myplr].InvGrid[i % 10 + ii] ) - { - xx = plr[myplr]._pNumInv; - yy = plr[myplr]._pNumInv; - GetGoldSeed(myplr, &golditem); - qmemcpy(&plr[myplr].InvList[xx], &golditem, sizeof(ItemStruct)); - ++plr[myplr]._pNumInv; - plr[myplr].InvGrid[i % 10 + ii] = plr[myplr]._pNumInv; - plr[myplr].InvList[xx]._ivalue = v; - SetGoldCurs(myplr, yy); - done = 1; - } - } + bool done; // ecx + int ii; // ebp + int xx; // esi + int yy; // ST20_4 + int i; // [esp+10h] [ebp-10h] + + done = 0; + + for (i = 0; i < 40; i++) { + if (done) + break; + ii = 10 * (i / 10); + if (!plr[myplr].InvGrid[i % 10 + ii]) { + xx = plr[myplr]._pNumInv; + yy = plr[myplr]._pNumInv; + GetGoldSeed(myplr, &golditem); + qmemcpy(&plr[myplr].InvList[xx], &golditem, sizeof(ItemStruct)); + ++plr[myplr]._pNumInv; + plr[myplr].InvGrid[i % 10 + ii] = plr[myplr]._pNumInv; + plr[myplr].InvList[xx]._ivalue = v; + SetGoldCurs(myplr, yy); + done = 1; + } + } } void __cdecl StoreSellItem() { - int idx; // ebx - char v1; // al - int v2; // eax - int cost; // ebp - bool v4; // sf - unsigned char v5; // of - unsigned int v6; // eax - int v8; // edx - int *v10; // edi - int v11; // eax - unsigned int v12; // esi - int v13; // [esp+10h] [ebp-4h] - - idx = stextvhold + ((stextlhold - stextup) >> 2); - v1 = storehidx[idx]; - if ( v1 < 0 ) - RemoveSpdBarItem(myplr, -1 - v1); - else - RemoveInvItem(myplr, v1); - v2 = storenumh - 1; - cost = storehold[idx]._iIvalue; - v5 = __OFSUB__(idx, storenumh - 1); - v4 = idx - (storenumh-- - 1) < 0; - if ( v4 ^ v5 ) - { - v6 = v2 - idx; - qmemcpy(&storehidx[idx], &storehidx[idx + 1], v6); - qmemcpy(&storehold[idx], &storehold[idx + 1], 4 * (368 * v6 >> 2)); - } - v8 = 0; - v13 = 0; - plr[myplr]._pGold += cost; - if ( plr[myplr]._pNumInv <= 0 ) - { -LABEL_15: - if ( cost > 0 ) - { - if ( cost > 5000 ) - { - v12 = (cost - 5001) / 5000 + 1; - cost += -5000 * v12; - do - { - PlaceStoreGold(5000); - --v12; - } - while ( v12 ); - } - PlaceStoreGold(cost); - } - } - else - { - v10 = &plr[myplr].InvList[0]._ivalue; - while ( cost > 0 ) - { - if ( *(v10 - 47) == ITYPE_GOLD && *v10 != 5000 ) - { - v11 = cost + *v10; - if ( v11 > 5000 ) - { - *v10 = 5000; - cost = v11 - 5000; - SetGoldCurs(myplr, v8); - } - else - { - *v10 = v11; - SetGoldCurs(myplr, v8); - cost = 0; - } - } - v10 += 92; - v8 = v13++ + 1; - if ( v13 >= plr[myplr]._pNumInv ) - goto LABEL_15; - } - } + int idx; // ebx + char v1; // al + int v2; // eax + int cost; // ebp + bool v4; // sf + unsigned char v5; // of + unsigned int v6; // eax + int v8; // edx + int *v10; // edi + int v11; // eax + unsigned int v12; // esi + int v13; // [esp+10h] [ebp-4h] + + idx = stextvhold + ((stextlhold - stextup) >> 2); + v1 = storehidx[idx]; + if (v1 < 0) + RemoveSpdBarItem(myplr, -1 - v1); + else + RemoveInvItem(myplr, v1); + v2 = storenumh - 1; + cost = storehold[idx]._iIvalue; + v5 = __OFSUB__(idx, storenumh - 1); + v4 = idx - (storenumh-- - 1) < 0; + if (v4 ^ v5) { + v6 = v2 - idx; + qmemcpy(&storehidx[idx], &storehidx[idx + 1], v6); + qmemcpy(&storehold[idx], &storehold[idx + 1], 4 * (368 * v6 >> 2)); + } + v8 = 0; + v13 = 0; + plr[myplr]._pGold += cost; + if (plr[myplr]._pNumInv <= 0) { + LABEL_15: + if (cost > 0) { + if (cost > 5000) { + v12 = (cost - 5001) / 5000 + 1; + cost += -5000 * v12; + do { + PlaceStoreGold(5000); + --v12; + } while (v12); + } + PlaceStoreGold(cost); + } + } else { + v10 = &plr[myplr].InvList[0]._ivalue; + while (cost > 0) { + if (*(v10 - 47) == ITYPE_GOLD && *v10 != 5000) { + v11 = cost + *v10; + if (v11 > 5000) { + *v10 = 5000; + cost = v11 - 5000; + SetGoldCurs(myplr, v8); + } else { + *v10 = v11; + SetGoldCurs(myplr, v8); + cost = 0; + } + } + v10 += 92; + v8 = v13++ + 1; + if (v13 >= plr[myplr]._pNumInv) + goto LABEL_15; + } + } } // 69F108: using guessed type int stextup; // 69F10C: using guessed type int storenumh; @@ -3065,27 +2751,24 @@ LABEL_15: void __cdecl S_SSellEnter() { - int idx; // eax - - if ( stextsel == 22 ) - { - StartStore(STORE_SMITH); - stextsel = 16; - } - else - { - stextlhold = stextsel; - idx = stextsval + ((stextsel - stextup) >> 2); - stextshold = 3; - stextvhold = stextsval; - - qmemcpy(&plr[myplr].HoldItem, &storehold[idx], sizeof(plr[myplr].HoldItem)); - - if ( !StoreGoldFit(idx) ) - StartStore(STORE_NOROOM); - else - StartStore(STORE_CONFIRM); - } + int idx; // eax + + if (stextsel == 22) { + StartStore(STORE_SMITH); + stextsel = 16; + } else { + stextlhold = stextsel; + idx = stextsval + ((stextsel - stextup) >> 2); + stextshold = 3; + stextvhold = stextsval; + + qmemcpy(&plr[myplr].HoldItem, &storehold[idx], sizeof(plr[myplr].HoldItem)); + + if (!StoreGoldFit(idx)) + StartStore(STORE_NOROOM); + else + StartStore(STORE_CONFIRM); + } } // 69F108: using guessed type int stextup; // 69F110: using guessed type int stextlhold; @@ -3094,30 +2777,27 @@ void __cdecl S_SSellEnter() void __cdecl SmithRepairItem() { - int i; // edx - int idx; // eax - - TakePlrsMoney(plr[myplr].HoldItem._iIvalue); - - idx = stextvhold + ((stextlhold - stextup) >> 2); - i = storehidx[idx]; - storehold[idx]._iDurability = storehold[idx]._iMaxDur; - - if ( i >= 0 ) - { - plr[myplr].InvList[i]._iDurability = plr[myplr].InvList[i]._iMaxDur; - } - else - { - if ( i == -1 ) - plr[myplr].InvBody[INVLOC_HEAD]._iDurability = plr[myplr].InvBody[INVLOC_HEAD]._iMaxDur; - if ( i == -2 ) - plr[myplr].InvBody[INVLOC_CHEST]._iDurability = plr[myplr].InvBody[INVLOC_CHEST]._iMaxDur; - if ( i == -3 ) - plr[myplr].InvBody[INVLOC_HAND_LEFT]._iDurability = plr[myplr].InvBody[INVLOC_HAND_LEFT]._iMaxDur; - if ( i == -4 ) - plr[myplr].InvBody[INVLOC_HAND_RIGHT]._iDurability = plr[myplr].InvBody[INVLOC_HAND_RIGHT]._iMaxDur; - } + int i; // edx + int idx; // eax + + TakePlrsMoney(plr[myplr].HoldItem._iIvalue); + + idx = stextvhold + ((stextlhold - stextup) >> 2); + i = storehidx[idx]; + storehold[idx]._iDurability = storehold[idx]._iMaxDur; + + if (i >= 0) { + plr[myplr].InvList[i]._iDurability = plr[myplr].InvList[i]._iMaxDur; + } else { + if (i == -1) + plr[myplr].InvBody[INVLOC_HEAD]._iDurability = plr[myplr].InvBody[INVLOC_HEAD]._iMaxDur; + if (i == -2) + plr[myplr].InvBody[INVLOC_CHEST]._iDurability = plr[myplr].InvBody[INVLOC_CHEST]._iMaxDur; + if (i == -3) + plr[myplr].InvBody[INVLOC_HAND_LEFT]._iDurability = plr[myplr].InvBody[INVLOC_HAND_LEFT]._iMaxDur; + if (i == -4) + plr[myplr].InvBody[INVLOC_HAND_RIGHT]._iDurability = plr[myplr].InvBody[INVLOC_HAND_RIGHT]._iMaxDur; + } } // 69F108: using guessed type int stextup; // 69F110: using guessed type int stextlhold; @@ -3125,34 +2805,31 @@ void __cdecl SmithRepairItem() void __cdecl S_SRepairEnter() { - int idx; // eax - int v1; // edx - int v2; // ecx - bool v3; // sf - unsigned char v4; // of - char v5; // cl - - if ( stextsel == 22 ) - { - StartStore(STORE_SMITH); - stextsel = 18; - } - else - { - stextlhold = stextsel; - stextshold = 4; - idx = stextsval + ((stextsel - stextup) >> 2); - v1 = myplr; - stextvhold = stextsval; - qmemcpy(&plr[myplr].HoldItem, &storehold[idx], sizeof(plr[myplr].HoldItem)); - v2 = plr[v1]._pGold; - v4 = __OFSUB__(v2, storehold[idx]._iIvalue); - v3 = v2 - storehold[idx]._iIvalue < 0; - v5 = STORE_NOMONEY; - if ( !(v3 ^ v4) ) - v5 = STORE_CONFIRM; - StartStore(v5); - } + int idx; // eax + int v1; // edx + int v2; // ecx + bool v3; // sf + unsigned char v4; // of + char v5; // cl + + if (stextsel == 22) { + StartStore(STORE_SMITH); + stextsel = 18; + } else { + stextlhold = stextsel; + stextshold = 4; + idx = stextsval + ((stextsel - stextup) >> 2); + v1 = myplr; + stextvhold = stextsval; + qmemcpy(&plr[myplr].HoldItem, &storehold[idx], sizeof(plr[myplr].HoldItem)); + v2 = plr[v1]._pGold; + v4 = __OFSUB__(v2, storehold[idx]._iIvalue); + v3 = v2 - storehold[idx]._iIvalue < 0; + v5 = STORE_NOMONEY; + if (!(v3 ^ v4)) + v5 = STORE_CONFIRM; + StartStore(v5); + } } // 69F108: using guessed type int stextup; // 69F110: using guessed type int stextlhold; @@ -3161,37 +2838,35 @@ void __cdecl S_SRepairEnter() void __cdecl S_WitchEnter() { - int v0; // ecx - - v0 = 12; - if ( stextsel == 12 ) - { - stextlhold = 12; - talker = 6; - stextshold = 5; - gossipstart = QUEST_ADRIA2; - gossipend = QUEST_ADRIA13; - _LOBYTE(v0) = STORE_GOSSIP; - goto LABEL_12; - } - v0 = 2; - switch ( stextsel ) - { - case 14: - _LOBYTE(v0) = STORE_WBUY; - goto LABEL_12; - case 16: - _LOBYTE(v0) = STORE_WSELL; - goto LABEL_12; - case 18: - _LOBYTE(v0) = STORE_WRECHARGE; -LABEL_12: - StartStore(v0); - return; - case 20: - stextflag = 0; - break; - } + int v0; // ecx + + v0 = 12; + if (stextsel == 12) { + stextlhold = 12; + talker = 6; + stextshold = 5; + gossipstart = QUEST_ADRIA2; + gossipend = QUEST_ADRIA13; + _LOBYTE(v0) = STORE_GOSSIP; + goto LABEL_12; + } + v0 = 2; + switch (stextsel) { + case 14: + _LOBYTE(v0) = STORE_WBUY; + goto LABEL_12; + case 16: + _LOBYTE(v0) = STORE_WSELL; + goto LABEL_12; + case 18: + _LOBYTE(v0) = STORE_WRECHARGE; + LABEL_12: + StartStore(v0); + return; + case 20: + stextflag = 0; + break; + } } // 69F110: using guessed type int stextlhold; // 69FB38: using guessed type int talker; @@ -3202,42 +2877,35 @@ LABEL_12: void __cdecl WitchBuyItem() { - int idx; // ebx - ItemStruct *v3; // eax - ItemStruct *v4; // edi - - idx = stextvhold + ((stextlhold - stextup) >> 2); - - if ( idx < 3 ) - plr[myplr].HoldItem._iSeed = GetRndSeed(); - - TakePlrsMoney(plr[myplr].HoldItem._iIvalue); - StoreAutoPlace(); - - if ( idx >= 3 ) - { - if ( idx == 19 ) - { - witchitem[19]._itype = -1; - } - else - { - if ( witchitem[idx + 1]._itype != -1 ) - { - v3 = &witchitem[idx]; - do - { - v4 = v3; - ++v3; - ++idx; - qmemcpy(v4, v3, sizeof(ItemStruct)); - } - while ( v3[1]._itype != -1 ); - } - witchitem[idx]._itype = -1; - } - } - CalcPlrInv(myplr, 1u); + int idx; // ebx + ItemStruct *v3; // eax + ItemStruct *v4; // edi + + idx = stextvhold + ((stextlhold - stextup) >> 2); + + if (idx < 3) + plr[myplr].HoldItem._iSeed = GetRndSeed(); + + TakePlrsMoney(plr[myplr].HoldItem._iIvalue); + StoreAutoPlace(); + + if (idx >= 3) { + if (idx == 19) { + witchitem[19]._itype = -1; + } else { + if (witchitem[idx + 1]._itype != -1) { + v3 = &witchitem[idx]; + do { + v4 = v3; + ++v3; + ++idx; + qmemcpy(v4, v3, sizeof(ItemStruct)); + } while (v3[1]._itype != -1); + } + witchitem[idx]._itype = -1; + } + } + CalcPlrInv(myplr, 1u); } // 69F108: using guessed type int stextup; // 69F110: using guessed type int stextlhold; @@ -3245,47 +2913,40 @@ void __cdecl WitchBuyItem() void __cdecl S_WBuyEnter() { - int idx; // ecx - int done; // eax - int i; // esi - - if ( stextsel == 22 ) - { - StartStore(STORE_WITCH); - stextsel = 14; - } - else - { - stextlhold = stextsel; - stextvhold = stextsval; - stextshold = 6; - idx = stextsval + ((stextsel - stextup) >> 2); - - if ( plr[myplr]._pGold >= witchitem[idx]._iIvalue ) - { - qmemcpy(&plr[myplr].HoldItem, &witchitem[idx], sizeof(ItemStruct)); - SetCursor(plr[myplr].HoldItem._iCurs + 12); - done = 0; - - for(i = 0; i < 40; i++) - { - if ( done ) - break; - done = SpecialAutoPlace(myplr, i, cursW / 28, cursH / 28, 0); - } - - if ( done ) - StartStore(STORE_CONFIRM); - else - StartStore(STORE_NOROOM); - - SetCursor(CURSOR_HAND); - } - else - { - StartStore(STORE_NOMONEY); - } - } + int idx; // ecx + int done; // eax + int i; // esi + + if (stextsel == 22) { + StartStore(STORE_WITCH); + stextsel = 14; + } else { + stextlhold = stextsel; + stextvhold = stextsval; + stextshold = 6; + idx = stextsval + ((stextsel - stextup) >> 2); + + if (plr[myplr]._pGold >= witchitem[idx]._iIvalue) { + qmemcpy(&plr[myplr].HoldItem, &witchitem[idx], sizeof(ItemStruct)); + SetCursor(plr[myplr].HoldItem._iCurs + 12); + done = 0; + + for (i = 0; i < 40; i++) { + if (done) + break; + done = SpecialAutoPlace(myplr, i, cursW / 28, cursH / 28, 0); + } + + if (done) + StartStore(STORE_CONFIRM); + else + StartStore(STORE_NOROOM); + + SetCursor(CURSOR_HAND); + } else { + StartStore(STORE_NOMONEY); + } + } } // 4B8C9C: using guessed type int cursH; // 69F108: using guessed type int stextup; @@ -3295,26 +2956,23 @@ void __cdecl S_WBuyEnter() void __cdecl S_WSellEnter() { - int idx; // eax - char v2; // cl - - if ( stextsel == 22 ) - { - StartStore(STORE_WITCH); - stextsel = 16; - } - else - { - stextlhold = stextsel; - idx = stextsval + ((stextsel - stextup) >> 2); - stextshold = 7; - stextvhold = stextsval; - qmemcpy(&plr[myplr].HoldItem, &storehold[idx], sizeof(plr[myplr].HoldItem)); - v2 = STORE_CONFIRM; - if ( !StoreGoldFit(idx) ) - v2 = STORE_NOROOM; - StartStore(v2); - } + int idx; // eax + char v2; // cl + + if (stextsel == 22) { + StartStore(STORE_WITCH); + stextsel = 16; + } else { + stextlhold = stextsel; + idx = stextsval + ((stextsel - stextup) >> 2); + stextshold = 7; + stextvhold = stextsval; + qmemcpy(&plr[myplr].HoldItem, &storehold[idx], sizeof(plr[myplr].HoldItem)); + v2 = STORE_CONFIRM; + if (!StoreGoldFit(idx)) + v2 = STORE_NOROOM; + StartStore(v2); + } } // 69F108: using guessed type int stextup; // 69F110: using guessed type int stextlhold; @@ -3323,21 +2981,21 @@ void __cdecl S_WSellEnter() void __cdecl WitchRechargeItem() { - int i; // ecx - int idx; // eax + int i; // ecx + int idx; // eax - TakePlrsMoney(plr[myplr].HoldItem._iIvalue); + TakePlrsMoney(plr[myplr].HoldItem._iIvalue); - idx = stextvhold + ((stextlhold - stextup) >> 2); - i = storehidx[idx]; - storehold[idx]._iCharges = storehold[idx]._iMaxCharges; + idx = stextvhold + ((stextlhold - stextup) >> 2); + i = storehidx[idx]; + storehold[idx]._iCharges = storehold[idx]._iMaxCharges; - if ( i >= 0 ) - plr[myplr].InvList[i]._iCharges = plr[myplr].InvList[i]._iMaxCharges; - else - plr[myplr].InvBody[INVLOC_HAND_LEFT]._iCharges = plr[myplr].InvBody[INVLOC_HAND_LEFT]._iMaxCharges; + if (i >= 0) + plr[myplr].InvList[i]._iCharges = plr[myplr].InvList[i]._iMaxCharges; + else + plr[myplr].InvBody[INVLOC_HAND_LEFT]._iCharges = plr[myplr].InvBody[INVLOC_HAND_LEFT]._iMaxCharges; - CalcPlrInv(myplr, 1u); + CalcPlrInv(myplr, 1u); } // 69F108: using guessed type int stextup; // 69F110: using guessed type int stextlhold; @@ -3345,34 +3003,31 @@ void __cdecl WitchRechargeItem() void __cdecl S_WRechargeEnter() { - int idx; // eax - int v1; // edx - int v2; // ecx - bool v3; // sf - unsigned char v4; // of - char v5; // cl - - if ( stextsel == 22 ) - { - StartStore(STORE_WITCH); - stextsel = 18; - } - else - { - stextlhold = stextsel; - stextshold = 8; - idx = stextsval + ((stextsel - stextup) >> 2); - v1 = myplr; - stextvhold = stextsval; - qmemcpy(&plr[myplr].HoldItem, &storehold[idx], sizeof(plr[myplr].HoldItem)); - v2 = plr[v1]._pGold; - v4 = __OFSUB__(v2, storehold[idx]._iIvalue); - v3 = v2 - storehold[idx]._iIvalue < 0; - v5 = STORE_NOMONEY; - if ( !(v3 ^ v4) ) - v5 = STORE_CONFIRM; - StartStore(v5); - } + int idx; // eax + int v1; // edx + int v2; // ecx + bool v3; // sf + unsigned char v4; // of + char v5; // cl + + if (stextsel == 22) { + StartStore(STORE_WITCH); + stextsel = 18; + } else { + stextlhold = stextsel; + stextshold = 8; + idx = stextsval + ((stextsel - stextup) >> 2); + v1 = myplr; + stextvhold = stextsval; + qmemcpy(&plr[myplr].HoldItem, &storehold[idx], sizeof(plr[myplr].HoldItem)); + v2 = plr[v1]._pGold; + v4 = __OFSUB__(v2, storehold[idx]._iIvalue); + v3 = v2 - storehold[idx]._iIvalue < 0; + v5 = STORE_NOMONEY; + if (!(v3 ^ v4)) + v5 = STORE_CONFIRM; + StartStore(v5); + } } // 69F108: using guessed type int stextup; // 69F110: using guessed type int stextlhold; @@ -3381,39 +3036,34 @@ void __cdecl S_WRechargeEnter() void __cdecl S_BoyEnter() { - signed int v0; // ecx - - v0 = boyitem._itype; - if ( boyitem._itype != -1 && stextsel == 18 ) - { - v0 = 50; - if ( plr[myplr]._pGold >= 50 ) - { - TakePlrsMoney(50); - _LOBYTE(v0) = STORE_BBOY; - } - else - { - stextshold = 12; - stextlhold = 18; - stextvhold = stextsval; - _LOBYTE(v0) = STORE_NOMONEY; - } - goto LABEL_5; - } - if ( stextsel == 8 && boyitem._itype != -1 || stextsel == 12 && boyitem._itype == -1 ) - { - talker = 8; - stextshold = 12; - stextlhold = stextsel; - gossipstart = QUEST_WIRT2; - gossipend = QUEST_WIRT12; - _LOBYTE(v0) = STORE_GOSSIP; -LABEL_5: - StartStore(v0); - return; - } - stextflag = 0; + signed int v0; // ecx + + v0 = boyitem._itype; + if (boyitem._itype != -1 && stextsel == 18) { + v0 = 50; + if (plr[myplr]._pGold >= 50) { + TakePlrsMoney(50); + _LOBYTE(v0) = STORE_BBOY; + } else { + stextshold = 12; + stextlhold = 18; + stextvhold = stextsval; + _LOBYTE(v0) = STORE_NOMONEY; + } + goto LABEL_5; + } + if (stextsel == 8 && boyitem._itype != -1 || stextsel == 12 && boyitem._itype == -1) { + talker = 8; + stextshold = 12; + stextlhold = stextsel; + gossipstart = QUEST_WIRT2; + gossipend = QUEST_WIRT12; + _LOBYTE(v0) = STORE_GOSSIP; + LABEL_5: + StartStore(v0); + return; + } + stextflag = 0; } // 69F110: using guessed type int stextlhold; // 69FB38: using guessed type int talker; @@ -3425,88 +3075,72 @@ LABEL_5: void __cdecl BoyBuyItem() { - TakePlrsMoney(plr[myplr].HoldItem._iIvalue); - StoreAutoPlace(); - boyitem._itype = -1; - stextshold = 12; - CalcPlrInv(myplr, 1u); + TakePlrsMoney(plr[myplr].HoldItem._iIvalue); + StoreAutoPlace(); + boyitem._itype = -1; + stextshold = 12; + CalcPlrInv(myplr, 1u); } void __cdecl HealerBuyItem() { - int idx; // esi - bool v1; // sf - unsigned char v2; // of - int v3; // eax - int v4; // ecx - bool v5; // sf - unsigned char v6; // of - int v7; // eax - ItemStruct *v8; // edx - ItemStruct *v9; // edi - bool v10; // zf - - idx = stextvhold + ((stextlhold - stextup) >> 2); - if ( gbMaxPlayers == 1 ) - { - v2 = __OFSUB__(idx, 2); - v1 = idx - 2 < 0; - } - else - { - v2 = __OFSUB__(idx, 3); - v1 = idx - 3 < 0; - } - if ( v1 ^ v2 ) - { - v3 = GetRndSeed(); - v4 = myplr; - plr[myplr].HoldItem._iSeed = v3; - } - else - { - v4 = myplr; - } - TakePlrsMoney(plr[v4].HoldItem._iIvalue); - if ( plr[myplr].HoldItem._iMagical == ITEM_QUALITY_NORMAL ) - plr[myplr].HoldItem._iIdentified = FALSE; - StoreAutoPlace(); - if ( gbMaxPlayers == 1 ) - { - v6 = __OFSUB__(idx, 2); - v5 = idx - 2 < 0; - } - else - { - v6 = __OFSUB__(idx, 3); - v5 = idx - 3 < 0; - } - if ( !(v5 ^ v6) ) - { - v7 = stextvhold + ((stextlhold - stextup) >> 2); - if ( v7 == 19 ) - { - healitem[19]._itype = -1; - } - else - { - if ( healitem[v7 + 1]._itype != -1 ) - { - v8 = &healitem[v7]; - do - { - v9 = v8; - ++v8; - ++v7; - v10 = v8[1]._itype == -1; - qmemcpy(v9, v8, sizeof(ItemStruct)); - } - while ( !v10 ); - } - healitem[v7]._itype = -1; - } - CalcPlrInv(myplr, 1u); - } + int idx; // esi + bool v1; // sf + unsigned char v2; // of + int v3; // eax + int v4; // ecx + bool v5; // sf + unsigned char v6; // of + int v7; // eax + ItemStruct *v8; // edx + ItemStruct *v9; // edi + bool v10; // zf + + idx = stextvhold + ((stextlhold - stextup) >> 2); + if (gbMaxPlayers == 1) { + v2 = __OFSUB__(idx, 2); + v1 = idx - 2 < 0; + } else { + v2 = __OFSUB__(idx, 3); + v1 = idx - 3 < 0; + } + if (v1 ^ v2) { + v3 = GetRndSeed(); + v4 = myplr; + plr[myplr].HoldItem._iSeed = v3; + } else { + v4 = myplr; + } + TakePlrsMoney(plr[v4].HoldItem._iIvalue); + if (plr[myplr].HoldItem._iMagical == ITEM_QUALITY_NORMAL) + plr[myplr].HoldItem._iIdentified = FALSE; + StoreAutoPlace(); + if (gbMaxPlayers == 1) { + v6 = __OFSUB__(idx, 2); + v5 = idx - 2 < 0; + } else { + v6 = __OFSUB__(idx, 3); + v5 = idx - 3 < 0; + } + if (!(v5 ^ v6)) { + v7 = stextvhold + ((stextlhold - stextup) >> 2); + if (v7 == 19) { + healitem[19]._itype = -1; + } else { + if (healitem[v7 + 1]._itype != -1) { + v8 = &healitem[v7]; + do { + v9 = v8; + ++v8; + ++v7; + v10 = v8[1]._itype == -1; + qmemcpy(v9, v8, sizeof(ItemStruct)); + } while (!v10); + } + healitem[v7]._itype = -1; + } + CalcPlrInv(myplr, 1u); + } } // 679660: using guessed type char gbMaxPlayers; // 69F108: using guessed type int stextup; @@ -3515,54 +3149,45 @@ void __cdecl HealerBuyItem() void __cdecl S_BBuyEnter() { - int v0; // ecx - int v1; // eax - int v2; // ecx - int v3; // eax - int v4; // esi - - if ( stextsel == 10 ) - { - v0 = boyitem._iIvalue; - stextvhold = stextsval; - v1 = myplr; - stextshold = 13; - stextlhold = 10; - if ( plr[myplr]._pGold >= boyitem._iIvalue + (boyitem._iIvalue >> 1) ) - { - qmemcpy(&plr[v1].HoldItem, &boyitem, sizeof(plr[v1].HoldItem)); - plr[v1].HoldItem._iIvalue += plr[v1].HoldItem._iIvalue >> 1; - SetCursor(plr[v1].HoldItem._iCurs + 12); - v3 = 0; - v4 = 0; - do - { - if ( v3 ) - goto LABEL_8; - v3 = AutoPlace(myplr, v4++, cursW / 28, cursH / 28, 0); - } - while ( v4 < 40 ); - if ( v3 ) - { -LABEL_8: - _LOBYTE(v2) = STORE_CONFIRM; - goto LABEL_10; - } - _LOBYTE(v2) = STORE_NOROOM; -LABEL_10: - StartStore(v2); - SetCursor(CURSOR_HAND); - } - else - { - _LOBYTE(v0) = STORE_NOMONEY; - StartStore(v0); - } - } - else - { - stextflag = 0; - } + int v0; // ecx + int v1; // eax + int v2; // ecx + int v3; // eax + int v4; // esi + + if (stextsel == 10) { + v0 = boyitem._iIvalue; + stextvhold = stextsval; + v1 = myplr; + stextshold = 13; + stextlhold = 10; + if (plr[myplr]._pGold >= boyitem._iIvalue + (boyitem._iIvalue >> 1)) { + qmemcpy(&plr[v1].HoldItem, &boyitem, sizeof(plr[v1].HoldItem)); + plr[v1].HoldItem._iIvalue += plr[v1].HoldItem._iIvalue >> 1; + SetCursor(plr[v1].HoldItem._iCurs + 12); + v3 = 0; + v4 = 0; + do { + if (v3) + goto LABEL_8; + v3 = AutoPlace(myplr, v4++, cursW / 28, cursH / 28, 0); + } while (v4 < 40); + if (v3) { + LABEL_8: + _LOBYTE(v2) = STORE_CONFIRM; + goto LABEL_10; + } + _LOBYTE(v2) = STORE_NOROOM; + LABEL_10: + StartStore(v2); + SetCursor(CURSOR_HAND); + } else { + _LOBYTE(v0) = STORE_NOMONEY; + StartStore(v0); + } + } else { + stextflag = 0; + } } // 4B8C9C: using guessed type int cursH; // 69F110: using guessed type int stextlhold; @@ -3572,37 +3197,34 @@ LABEL_10: void __cdecl StoryIdItem() { - int v0; // ecx - int v1; // eax - int v2; // eax - - v0 = storehidx[((stextlhold - stextup) >> 2) + stextvhold]; - v1 = myplr; - if ( v0 >= 0 ) - { - plr[myplr].InvList[v0]._iIdentified = TRUE; - } - else - { - if ( v0 == -1 ) - plr[myplr].InvBody[INVLOC_HEAD]._iIdentified = TRUE; - if ( v0 == -2 ) - plr[v1].InvBody[INVLOC_CHEST]._iIdentified = TRUE; - if ( v0 == -3 ) - plr[v1].InvBody[INVLOC_HAND_LEFT]._iIdentified = TRUE; - if ( v0 == -4 ) - plr[v1].InvBody[INVLOC_HAND_RIGHT]._iIdentified = TRUE; - if ( v0 == -5 ) - plr[v1].InvBody[INVLOC_RING_LEFT]._iIdentified = TRUE; - if ( v0 == -6 ) - plr[v1].InvBody[INVLOC_RING_RIGHT]._iIdentified = TRUE; - if ( v0 == -7 ) - plr[v1].InvBody[INVLOC_AMULET]._iIdentified = TRUE; - } - v2 = v1; - plr[v2].HoldItem._iIdentified = TRUE; - TakePlrsMoney(plr[v2].HoldItem._iIvalue); - CalcPlrInv(myplr, 1u); + int v0; // ecx + int v1; // eax + int v2; // eax + + v0 = storehidx[((stextlhold - stextup) >> 2) + stextvhold]; + v1 = myplr; + if (v0 >= 0) { + plr[myplr].InvList[v0]._iIdentified = TRUE; + } else { + if (v0 == -1) + plr[myplr].InvBody[INVLOC_HEAD]._iIdentified = TRUE; + if (v0 == -2) + plr[v1].InvBody[INVLOC_CHEST]._iIdentified = TRUE; + if (v0 == -3) + plr[v1].InvBody[INVLOC_HAND_LEFT]._iIdentified = TRUE; + if (v0 == -4) + plr[v1].InvBody[INVLOC_HAND_RIGHT]._iIdentified = TRUE; + if (v0 == -5) + plr[v1].InvBody[INVLOC_RING_LEFT]._iIdentified = TRUE; + if (v0 == -6) + plr[v1].InvBody[INVLOC_RING_RIGHT]._iIdentified = TRUE; + if (v0 == -7) + plr[v1].InvBody[INVLOC_AMULET]._iIdentified = TRUE; + } + v2 = v1; + plr[v2].HoldItem._iIdentified = TRUE; + TakePlrsMoney(plr[v2].HoldItem._iIvalue); + CalcPlrInv(myplr, 1u); } // 69F108: using guessed type int stextup; // 69F110: using guessed type int stextlhold; @@ -3610,61 +3232,55 @@ void __cdecl StoryIdItem() void __cdecl S_ConfirmEnter() { - char v0; // cl - - if ( stextsel == 18 ) - { - if ( stextshold > STORE_WRECHARGE ) - { - switch ( stextshold ) - { - case STORE_BBOY: - BoyBuyItem(); - break; - case STORE_HBUY: - HealerBuyItem(); - break; - case STORE_SIDENTIFY: - StoryIdItem(); - v0 = STORE_IDSHOW; -LABEL_20: - StartStore(v0); - return; - case STORE_SPBUY: - SmithBuyPItem(); - break; - } - } - else - { - switch ( stextshold ) - { - case STORE_WRECHARGE: - WitchRechargeItem(); - break; - case STORE_SBUY: - SmithBuyItem(); - break; - case STORE_SSELL: - goto LABEL_27; - case STORE_SREPAIR: - SmithRepairItem(); - break; - case STORE_WBUY: - WitchBuyItem(); - break; - case STORE_WSELL: -LABEL_27: - StoreSellItem(); - break; - } - } - v0 = stextshold; - goto LABEL_20; - } - StartStore((unsigned char)stextshold); - stextsel = stextlhold; - stextsval = stextvhold; + char v0; // cl + + if (stextsel == 18) { + if (stextshold > STORE_WRECHARGE) { + switch (stextshold) { + case STORE_BBOY: + BoyBuyItem(); + break; + case STORE_HBUY: + HealerBuyItem(); + break; + case STORE_SIDENTIFY: + StoryIdItem(); + v0 = STORE_IDSHOW; + LABEL_20: + StartStore(v0); + return; + case STORE_SPBUY: + SmithBuyPItem(); + break; + } + } else { + switch (stextshold) { + case STORE_WRECHARGE: + WitchRechargeItem(); + break; + case STORE_SBUY: + SmithBuyItem(); + break; + case STORE_SSELL: + goto LABEL_27; + case STORE_SREPAIR: + SmithRepairItem(); + break; + case STORE_WBUY: + WitchBuyItem(); + break; + case STORE_WSELL: + LABEL_27: + StoreSellItem(); + break; + } + } + v0 = stextshold; + goto LABEL_20; + } + StartStore((unsigned char)stextshold); + stextsel = stextlhold; + stextsval = stextvhold; } // 69F110: using guessed type int stextlhold; // 6A8A24: using guessed type int stextvhold; @@ -3672,39 +3288,36 @@ LABEL_27: void __cdecl S_HealerEnter() { - int v0; // ecx - int v1; // eax - - v0 = 12; - if ( stextsel == 12 ) - { - stextlhold = 12; - talker = 1; - stextshold = 14; - gossipstart = QUEST_PEPIN2; - gossipend = QUEST_PEPIN11; - _LOBYTE(v0) = STORE_GOSSIP; - goto LABEL_12; - } - if ( stextsel != 14 ) - { - if ( stextsel != 16 ) - { - if ( stextsel == 18 ) - stextflag = 0; - return; - } - _LOBYTE(v0) = STORE_HBUY; -LABEL_12: - StartStore(v0); - return; - } - if ( plr[myplr]._pHitPoints != plr[myplr]._pMaxHP ) - PlaySFX(IS_CAST8); - drawhpflag = TRUE; - v1 = myplr; - plr[v1]._pHitPoints = plr[myplr]._pMaxHP; - plr[v1]._pHPBase = plr[v1]._pMaxHPBase; + int v0; // ecx + int v1; // eax + + v0 = 12; + if (stextsel == 12) { + stextlhold = 12; + talker = 1; + stextshold = 14; + gossipstart = QUEST_PEPIN2; + gossipend = QUEST_PEPIN11; + _LOBYTE(v0) = STORE_GOSSIP; + goto LABEL_12; + } + if (stextsel != 14) { + if (stextsel != 16) { + if (stextsel == 18) + stextflag = 0; + return; + } + _LOBYTE(v0) = STORE_HBUY; + LABEL_12: + StartStore(v0); + return; + } + if (plr[myplr]._pHitPoints != plr[myplr]._pMaxHP) + PlaySFX(IS_CAST8); + drawhpflag = TRUE; + v1 = myplr; + plr[v1]._pHitPoints = plr[myplr]._pMaxHP; + plr[v1]._pHPBase = plr[v1]._pMaxHPBase; } // 69F110: using guessed type int stextlhold; // 69FB38: using guessed type int talker; @@ -3715,53 +3328,44 @@ LABEL_12: void __cdecl S_HBuyEnter() { - int v0; // eax - int idx; // ecx - int done; // eax - int i; // esi - char v4; // cl - - if ( stextsel == 22 ) - { - StartStore(STORE_HEALER); - stextsel = 16; - } - else - { - stextlhold = stextsel; - stextvhold = stextsval; - stextshold = 16; - v0 = myplr; - idx = stextsval + ((stextsel - stextup) >> 2); - if ( plr[myplr]._pGold >= healitem[idx]._iIvalue ) - { - qmemcpy(&plr[v0].HoldItem, &healitem[idx], sizeof(plr[v0].HoldItem)); - SetCursor(plr[v0].HoldItem._iCurs + 12); - done = 0; - i = 0; - do - { - if ( done ) - goto LABEL_9; - done = SpecialAutoPlace(myplr, i++, cursW / 28, cursH / 28, 0); - } - while ( i < 40 ); - if ( done ) - { -LABEL_9: - v4 = STORE_CONFIRM; - goto LABEL_11; - } - v4 = STORE_NOROOM; -LABEL_11: - StartStore(v4); - SetCursor(CURSOR_HAND); - } - else - { - StartStore(STORE_NOMONEY); - } - } + int v0; // eax + int idx; // ecx + int done; // eax + int i; // esi + char v4; // cl + + if (stextsel == 22) { + StartStore(STORE_HEALER); + stextsel = 16; + } else { + stextlhold = stextsel; + stextvhold = stextsval; + stextshold = 16; + v0 = myplr; + idx = stextsval + ((stextsel - stextup) >> 2); + if (plr[myplr]._pGold >= healitem[idx]._iIvalue) { + qmemcpy(&plr[v0].HoldItem, &healitem[idx], sizeof(plr[v0].HoldItem)); + SetCursor(plr[v0].HoldItem._iCurs + 12); + done = 0; + i = 0; + do { + if (done) + goto LABEL_9; + done = SpecialAutoPlace(myplr, i++, cursW / 28, cursH / 28, 0); + } while (i < 40); + if (done) { + LABEL_9: + v4 = STORE_CONFIRM; + goto LABEL_11; + } + v4 = STORE_NOROOM; + LABEL_11: + StartStore(v4); + SetCursor(CURSOR_HAND); + } else { + StartStore(STORE_NOMONEY); + } + } } // 4B8C9C: using guessed type int cursH; // 69F108: using guessed type int stextup; @@ -3771,28 +3375,27 @@ LABEL_11: void __cdecl S_StoryEnter() { - int v0; // ecx - - v0 = 12; - switch ( stextsel ) - { - case 12: - stextlhold = 12; - talker = 4; - stextshold = 15; - gossipstart = QUEST_STORY2; - gossipend = QUEST_STORY11; - _LOBYTE(v0) = STORE_GOSSIP; - goto LABEL_8; - case 14: - _LOBYTE(v0) = STORE_SIDENTIFY; -LABEL_8: - StartStore(v0); - return; - case 18: - stextflag = 0; - break; - } + int v0; // ecx + + v0 = 12; + switch (stextsel) { + case 12: + stextlhold = 12; + talker = 4; + stextshold = 15; + gossipstart = QUEST_STORY2; + gossipend = QUEST_STORY11; + _LOBYTE(v0) = STORE_GOSSIP; + goto LABEL_8; + case 14: + _LOBYTE(v0) = STORE_SIDENTIFY; + LABEL_8: + StartStore(v0); + return; + case 18: + stextflag = 0; + break; + } } // 69F110: using guessed type int stextlhold; // 69FB38: using guessed type int talker; @@ -3803,34 +3406,31 @@ LABEL_8: void __cdecl S_SIDEnter() { - int idx; // eax - int v1; // edx - int v2; // ecx - bool v3; // sf - unsigned char v4; // of - char v5; // cl - - if ( stextsel == 22 ) - { - StartStore(STORE_STORY); - stextsel = 14; - } - else - { - stextlhold = stextsel; - stextshold = 17; - idx = stextsval + ((stextsel - stextup) >> 2); - v1 = myplr; - stextvhold = stextsval; - qmemcpy(&plr[myplr].HoldItem, &storehold[idx], sizeof(plr[myplr].HoldItem)); - v2 = plr[v1]._pGold; - v4 = __OFSUB__(v2, storehold[idx]._iIvalue); - v3 = v2 - storehold[idx]._iIvalue < 0; - v5 = STORE_NOMONEY; - if ( !(v3 ^ v4) ) - v5 = STORE_CONFIRM; - StartStore(v5); - } + int idx; // eax + int v1; // edx + int v2; // ecx + bool v3; // sf + unsigned char v4; // of + char v5; // cl + + if (stextsel == 22) { + StartStore(STORE_STORY); + stextsel = 14; + } else { + stextlhold = stextsel; + stextshold = 17; + idx = stextsval + ((stextsel - stextup) >> 2); + v1 = myplr; + stextvhold = stextsval; + qmemcpy(&plr[myplr].HoldItem, &storehold[idx], sizeof(plr[myplr].HoldItem)); + v2 = plr[v1]._pGold; + v4 = __OFSUB__(v2, storehold[idx]._iIvalue); + v3 = v2 - storehold[idx]._iIvalue < 0; + v5 = STORE_NOMONEY; + if (!(v3 ^ v4)) + v5 = STORE_CONFIRM; + StartStore(v5); + } } // 69F108: using guessed type int stextup; // 69F110: using guessed type int stextlhold; @@ -3839,80 +3439,63 @@ void __cdecl S_SIDEnter() void __cdecl S_TalkEnter() { - int v0; // edx - int *v1; // edi - signed int v2; // eax - int v3; // esi - int *v4; // ecx - int v5; // esi - signed int v6; // ebp - int v8; // eax - int v9; // ebx - int v10; // ecx - - if ( stextsel == 22 ) - { - StartStore((unsigned char)stextshold); - stextsel = stextlhold; - } - else - { - v0 = talker; - v1 = &quests[0]._qlog; - v2 = 0; - v3 = 0; - v4 = &quests[0]._qlog; - do - { - if ( *((_BYTE *)v4 - 18) == 2 && *((_DWORD *)&Qtalklist[0]._qinfra + v3 + 16 * talker) != -1 && *v4 ) - ++v2; - v4 += 6; - ++v3; - } - while ( (signed int)v4 < (signed int)&quests[16]._qlog ); - if ( v2 <= 6 ) - { - v5 = 15 - v2; - v6 = 2; - } - else - { - v5 = 14 - (v2 >> 1); - v6 = 1; - } - if ( stextsel == v5 - 2 ) - { - SetRndSeed(towner[talker]._tSeed); - v8 = random(0, gossipend - gossipstart + 1); - InitQTextMsg(gossipstart + v8); - } - else - { - v9 = 0; - do - { - if ( *((_BYTE *)v1 - 18) == 2 ) - { - v10 = *((_DWORD *)&Qtalklist[0]._qinfra + v9 + 16 * v0); - if ( v10 != -1 ) - { - if ( *v1 ) - { - if ( v5 == stextsel ) - { - InitQTextMsg(v10); - v0 = talker; - } - v5 += v6; - } - } - } - v1 += 6; - ++v9; - } - while ( (signed int)v1 < (signed int)&quests[16]._qlog ); - } - } + int v0; // edx + int *v1; // edi + signed int v2; // eax + int v3; // esi + int *v4; // ecx + int v5; // esi + signed int v6; // ebp + int v8; // eax + int v9; // ebx + int v10; // ecx + + if (stextsel == 22) { + StartStore((unsigned char)stextshold); + stextsel = stextlhold; + } else { + v0 = talker; + v1 = &quests[0]._qlog; + v2 = 0; + v3 = 0; + v4 = &quests[0]._qlog; + do { + if (*((_BYTE *)v4 - 18) == 2 && *((_DWORD *)&Qtalklist[0]._qinfra + v3 + 16 * talker) != -1 && *v4) + ++v2; + v4 += 6; + ++v3; + } while ((signed int)v4 < (signed int)&quests[16]._qlog); + if (v2 <= 6) { + v5 = 15 - v2; + v6 = 2; + } else { + v5 = 14 - (v2 >> 1); + v6 = 1; + } + if (stextsel == v5 - 2) { + SetRndSeed(towner[talker]._tSeed); + v8 = random(0, gossipend - gossipstart + 1); + InitQTextMsg(gossipstart + v8); + } else { + v9 = 0; + do { + if (*((_BYTE *)v1 - 18) == 2) { + v10 = *((_DWORD *)&Qtalklist[0]._qinfra + v9 + 16 * v0); + if (v10 != -1) { + if (*v1) { + if (v5 == stextsel) { + InitQTextMsg(v10); + v0 = talker; + } + v5 += v6; + } + } + } + v1 += 6; + ++v9; + } while ((signed int)v1 < (signed int)&quests[16]._qlog); + } + } } // 69F110: using guessed type int stextlhold; // 69FB38: using guessed type int talker; @@ -3922,23 +3505,20 @@ void __cdecl S_TalkEnter() void __cdecl S_TavernEnter() { - int v0; // ecx - - v0 = 12; - if ( stextsel == 12 ) - { - stextlhold = 12; - talker = 3; - stextshold = 21; - gossipstart = QUEST_OGDEN2; - gossipend = QUEST_OGDEN10; - _LOBYTE(v0) = STORE_GOSSIP; - StartStore(v0); - } - else if ( stextsel == 18 ) - { - stextflag = 0; - } + int v0; // ecx + + v0 = 12; + if (stextsel == 12) { + stextlhold = 12; + talker = 3; + stextshold = 21; + gossipstart = QUEST_OGDEN2; + gossipend = QUEST_OGDEN10; + _LOBYTE(v0) = STORE_GOSSIP; + StartStore(v0); + } else if (stextsel == 18) { + stextflag = 0; + } } // 69F110: using guessed type int stextlhold; // 69FB38: using guessed type int talker; @@ -3949,23 +3529,20 @@ void __cdecl S_TavernEnter() void __cdecl S_BarmaidEnter() { - int v0; // ecx - - v0 = 12; - if ( stextsel == 12 ) - { - stextlhold = 12; - talker = 7; - stextshold = 23; - gossipstart = QUEST_GILLIAN2; - gossipend = QUEST_GILLIAN10; - _LOBYTE(v0) = STORE_GOSSIP; - StartStore(v0); - } - else if ( stextsel == 18 ) - { - stextflag = 0; - } + int v0; // ecx + + v0 = 12; + if (stextsel == 12) { + stextlhold = 12; + talker = 7; + stextshold = 23; + gossipstart = QUEST_GILLIAN2; + gossipend = QUEST_GILLIAN10; + _LOBYTE(v0) = STORE_GOSSIP; + StartStore(v0); + } else if (stextsel == 18) { + stextflag = 0; + } } // 69F110: using guessed type int stextlhold; // 69FB38: using guessed type int talker; @@ -3976,23 +3553,20 @@ void __cdecl S_BarmaidEnter() void __cdecl S_DrunkEnter() { - int v0; // ecx - - v0 = 12; - if ( stextsel == 12 ) - { - stextlhold = 12; - talker = 5; - stextshold = 22; - gossipstart = QUEST_FARNHAM2; - gossipend = QUEST_FARNHAM13; - _LOBYTE(v0) = STORE_GOSSIP; - StartStore(v0); - } - else if ( stextsel == 18 ) - { - stextflag = 0; - } + int v0; // ecx + + v0 = 12; + if (stextsel == 12) { + stextlhold = 12; + talker = 5; + stextshold = 22; + gossipstart = QUEST_FARNHAM2; + gossipend = QUEST_FARNHAM13; + _LOBYTE(v0) = STORE_GOSSIP; + StartStore(v0); + } else if (stextsel == 18) { + stextflag = 0; + } } // 69F110: using guessed type int stextlhold; // 69FB38: using guessed type int talker; @@ -4003,90 +3577,86 @@ void __cdecl S_DrunkEnter() void __cdecl STextEnter() { - if ( qtextflag ) - { - qtextflag = FALSE; - if ( leveltype == DTYPE_TOWN ) - sfx_stop(); - } - else - { - PlaySFX(IS_TITLSLCT); - switch ( stextflag ) - { - case STORE_SMITH: - S_SmithEnter(); - break; - case STORE_SBUY: - S_SBuyEnter(); - break; - case STORE_SSELL: - S_SSellEnter(); - break; - case STORE_SREPAIR: - S_SRepairEnter(); - break; - case STORE_WITCH: - S_WitchEnter(); - break; - case STORE_WBUY: - S_WBuyEnter(); - break; - case STORE_WSELL: - S_WSellEnter(); - break; - case STORE_WRECHARGE: - S_WRechargeEnter(); - break; - case STORE_NOMONEY: - case STORE_NOROOM: - StartStore(stextshold); - stextsel = stextlhold; - stextsval = stextvhold; - break; - case STORE_CONFIRM: - S_ConfirmEnter(); - break; - case STORE_BOY: - S_BoyEnter(); - break; - case STORE_BBOY: - S_BBuyEnter(); - break; - case STORE_HEALER: - S_HealerEnter(); - break; - case STORE_STORY: - S_StoryEnter(); - break; - case STORE_HBUY: - S_HBuyEnter(); - break; - case STORE_SIDENTIFY: - S_SIDEnter(); - break; - case STORE_SPBUY: - S_SPBuyEnter(); - break; - case STORE_GOSSIP: - S_TalkEnter(); - break; - case STORE_IDSHOW: - StartStore(STORE_SIDENTIFY); - break; - case STORE_TAVERN: - S_TavernEnter(); - break; - case STORE_DRUNK: - S_DrunkEnter(); - break; - case STORE_BARMAID: - S_BarmaidEnter(); - break; - default: - return; - } - } + if (qtextflag) { + qtextflag = FALSE; + if (leveltype == DTYPE_TOWN) + sfx_stop(); + } else { + PlaySFX(IS_TITLSLCT); + switch (stextflag) { + case STORE_SMITH: + S_SmithEnter(); + break; + case STORE_SBUY: + S_SBuyEnter(); + break; + case STORE_SSELL: + S_SSellEnter(); + break; + case STORE_SREPAIR: + S_SRepairEnter(); + break; + case STORE_WITCH: + S_WitchEnter(); + break; + case STORE_WBUY: + S_WBuyEnter(); + break; + case STORE_WSELL: + S_WSellEnter(); + break; + case STORE_WRECHARGE: + S_WRechargeEnter(); + break; + case STORE_NOMONEY: + case STORE_NOROOM: + StartStore(stextshold); + stextsel = stextlhold; + stextsval = stextvhold; + break; + case STORE_CONFIRM: + S_ConfirmEnter(); + break; + case STORE_BOY: + S_BoyEnter(); + break; + case STORE_BBOY: + S_BBuyEnter(); + break; + case STORE_HEALER: + S_HealerEnter(); + break; + case STORE_STORY: + S_StoryEnter(); + break; + case STORE_HBUY: + S_HBuyEnter(); + break; + case STORE_SIDENTIFY: + S_SIDEnter(); + break; + case STORE_SPBUY: + S_SPBuyEnter(); + break; + case STORE_GOSSIP: + S_TalkEnter(); + break; + case STORE_IDSHOW: + StartStore(STORE_SIDENTIFY); + break; + case STORE_TAVERN: + S_TavernEnter(); + break; + case STORE_DRUNK: + S_DrunkEnter(); + break; + case STORE_BARMAID: + S_BarmaidEnter(); + break; + default: + return; + } + } } // 646D00: using guessed type char qtextflag; // 69F110: using guessed type int stextlhold; @@ -4096,87 +3666,64 @@ void __cdecl STextEnter() void __cdecl CheckStoreBtn() { - bool v0; // sf - unsigned char v1; // of - int v2; // eax - int *v3; // ecx - - if ( qtextflag ) - { - qtextflag = FALSE; - if ( leveltype == DTYPE_TOWN ) - sfx_stop(); - } - else if ( stextsel != -1 && MouseY >= 32 && MouseY <= 320 ) - { - if ( stextsize ) - { - v1 = __OFSUB__(MouseX, 24); - v0 = MouseX - 24 < 0; - } - else - { - v1 = __OFSUB__(MouseX, 344); - v0 = MouseX - 344 < 0; - } - if ( !(v0 ^ v1) && MouseX <= 616 ) - { - v2 = (MouseY - 32) / 12; - if ( stextscrl && MouseX > 600 ) - { - if ( v2 == 4 ) - { - if ( stextscrlubtn <= 0 ) - { - STextUp(); - stextscrlubtn = 10; - return; - } - --stextscrlubtn; - } - if ( v2 == 20 ) - { - if ( stextscrldbtn > 0 ) - { - --stextscrldbtn; - } - else - { - STextDown(); - stextscrldbtn = 10; - } - } - } - else if ( v2 >= 5 ) - { - if ( v2 >= 23 ) - v2 = 22; - if ( stextscrl ) - { - if ( v2 < 21 ) - { - v3 = &stext[v2]._ssel; - if ( !*v3 ) - { - if ( stext[v2 - 2]._ssel ) - { - v2 -= 2; - } - else if ( *(v3 - 39) ) - { - --v2; - } - } - } - } - if ( stext[v2]._ssel || stextscrl && v2 == 22 ) - { - stextsel = v2; - STextEnter(); - } - } - } - } + bool v0; // sf + unsigned char v1; // of + int v2; // eax + int *v3; // ecx + + if (qtextflag) { + qtextflag = FALSE; + if (leveltype == DTYPE_TOWN) + sfx_stop(); + } else if (stextsel != -1 && MouseY >= 32 && MouseY <= 320) { + if (stextsize) { + v1 = __OFSUB__(MouseX, 24); + v0 = MouseX - 24 < 0; + } else { + v1 = __OFSUB__(MouseX, 344); + v0 = MouseX - 344 < 0; + } + if (!(v0 ^ v1) && MouseX <= 616) { + v2 = (MouseY - 32) / 12; + if (stextscrl && MouseX > 600) { + if (v2 == 4) { + if (stextscrlubtn <= 0) { + STextUp(); + stextscrlubtn = 10; + return; + } + --stextscrlubtn; + } + if (v2 == 20) { + if (stextscrldbtn > 0) { + --stextscrldbtn; + } else { + STextDown(); + stextscrldbtn = 10; + } + } + } else if (v2 >= 5) { + if (v2 >= 23) + v2 = 22; + if (stextscrl) { + if (v2 < 21) { + v3 = &stext[v2]._ssel; + if (!*v3) { + if (stext[v2 - 2]._ssel) { + v2 -= 2; + } else if (*(v3 - 39)) { + --v2; + } + } + } + } + if (stext[v2]._ssel || stextscrl && v2 == 22) { + stextsel = v2; + STextEnter(); + } + } + } + } } // 646D00: using guessed type char qtextflag; // 6A09E0: using guessed type char stextsize; @@ -4187,8 +3734,8 @@ void __cdecl CheckStoreBtn() void __cdecl ReleaseStoreBtn() { - stextscrlubtn = -1; - stextscrldbtn = -1; + stextscrlubtn = -1; + stextscrldbtn = -1; } // 6A8A2C: using guessed type char stextscrldbtn; // 6AA704: using guessed type char stextscrlubtn; diff --git a/Source/stores.h b/Source/stores.h index 16b0c0fd2..ebad21275 100644 --- a/Source/stores.h +++ b/Source/stores.h @@ -2,39 +2,39 @@ #ifndef __STORES_H__ #define __STORES_H__ -extern int stextup; // weak -extern int storenumh; // weak +extern int stextup; // weak +extern int storenumh; // weak extern int stextlhold; // weak extern ItemStruct boyitem; extern int stextshold; // idb extern ItemStruct premiumitem[6]; extern void *pSTextBoxCels; extern int premiumlevel; // idb -extern int talker; // weak +extern int talker; // weak extern STextStruct stext[24]; -extern char stextsize; // weak -extern int stextsmax; // weak +extern char stextsize; // weak +extern int stextsmax; // weak extern int InStoreFlag; // idb extern ItemStruct storehold[48]; extern int gossipstart; // weak extern ItemStruct witchitem[20]; -extern int stextscrl; // weak +extern int stextscrl; // weak extern int numpremium; // idb extern ItemStruct healitem[20]; extern ItemStruct golditem; extern char storehidx[48]; extern void *pSTextSlidCels; -extern int stextvhold; // weak -extern int stextsel; // weak +extern int stextvhold; // weak +extern int stextsel; // weak extern char stextscrldbtn; // weak -extern int gossipend; // weak +extern int gossipend; // weak extern void *pCelBuff; extern int stextsval; // idb -extern int boylevel; // weak +extern int boylevel; // weak extern ItemStruct smithitem[20]; -extern int stextdown; // weak +extern int stextdown; // weak extern char stextscrlubtn; // weak -extern char stextflag; // weak +extern char stextflag; // weak void __cdecl InitStores(); void __cdecl SetupTownStores(); diff --git a/Source/town.cpp b/Source/town.cpp index d5cd092dd..439a20e77 100644 --- a/Source/town.cpp +++ b/Source/town.cpp @@ -4,1116 +4,998 @@ void __fastcall town_clear_upper_buf(unsigned char *a1) { - unsigned char *v1; // edi - signed int v2; // edx - signed int v3; // ebx - unsigned char *v4; // edi - signed int v5; // edx - signed int v6; // ebx - unsigned char *v7; // edi + unsigned char *v1; // edi + signed int v2; // edx + signed int v3; // ebx + unsigned char *v4; // edi + signed int v5; // edx + signed int v6; // ebx + unsigned char *v7; // edi - v1 = a1; - v2 = 30; - v3 = 1; - while ( v1 >= gpBufEnd ) - { - v4 = &v1[v2]; - memset(v4, 0, 4 * v3); - v1 = &v4[4 * v3 - 832 + v2]; - if ( !v2 ) - { - v5 = 2; - v6 = 15; - do - { - if ( v1 < gpBufEnd ) - break; - v7 = &v1[v5]; - memset(v7, 0, 4 * v6); - v1 = &v7[4 * v6-- - 832 + v5]; - v5 += 2; - } - while ( v5 != 32 ); - return; - } - v2 -= 2; - ++v3; - } + v1 = a1; + v2 = 30; + v3 = 1; + while (v1 >= gpBufEnd) { + v4 = &v1[v2]; + memset(v4, 0, 4 * v3); + v1 = &v4[4 * v3 - 832 + v2]; + if (!v2) { + v5 = 2; + v6 = 15; + do { + if (v1 < gpBufEnd) + break; + v7 = &v1[v5]; + memset(v7, 0, 4 * v6); + v1 = &v7[4 * v6-- - 832 + v5]; + v5 += 2; + } while (v5 != 32); + return; + } + v2 -= 2; + ++v3; + } } // 69CF0C: using guessed type int gpBufEnd; void __fastcall town_clear_low_buf(unsigned char *y_related) { - unsigned char *v1; // edi - signed int v2; // edx - signed int i; // ebx - unsigned char *v4; // edi - unsigned char *v5; // edi - signed int v6; // edx - signed int v7; // ebx - unsigned char *v8; // edi - unsigned char *v9; // edi + unsigned char *v1; // edi + signed int v2; // edx + signed int i; // ebx + unsigned char *v4; // edi + unsigned char *v5; // edi + signed int v6; // edx + signed int v7; // ebx + unsigned char *v8; // edi + unsigned char *v9; // edi - v1 = y_related; - v2 = 30; - for ( i = 1; ; ++i ) - { - if ( v1 < gpBufEnd ) - { - v5 = &v1[v2]; - memset(v5, 0, 4 * i); - v4 = &v5[4 * i + v2]; - } - else - { - v4 = v1 + 64; - } - v1 = v4 - 832; - if ( !v2 ) - break; - v2 -= 2; - } - v6 = 2; - v7 = 15; - do - { - if ( v1 < gpBufEnd ) - { - v9 = &v1[v6]; - memset(v9, 0, 4 * v7); - v8 = &v9[4 * v7 + v6]; - } - else - { - v8 = v1 + 64; - } - v1 = v8 - 832; - --v7; - v6 += 2; - } - while ( v6 != 32 ); + v1 = y_related; + v2 = 30; + for (i = 1;; ++i) { + if (v1 < gpBufEnd) { + v5 = &v1[v2]; + memset(v5, 0, 4 * i); + v4 = &v5[4 * i + v2]; + } else { + v4 = v1 + 64; + } + v1 = v4 - 832; + if (!v2) + break; + v2 -= 2; + } + v6 = 2; + v7 = 15; + do { + if (v1 < gpBufEnd) { + v9 = &v1[v6]; + memset(v9, 0, 4 * v7); + v8 = &v9[4 * v7 + v6]; + } else { + v8 = v1 + 64; + } + v1 = v8 - 832; + --v7; + v6 += 2; + } while (v6 != 32); } // 69CF0C: using guessed type int gpBufEnd; void __fastcall town_draw_clipped_e_flag(void *buffer, int x, int y, int sx, int sy) { - int v5; // ebx - char *v6; // esi - signed int v7; // edi - int v8; // eax - int v9; // eax - void *unused; // [esp+Ch] [ebp-8h] - unsigned char *a1; // [esp+10h] [ebp-4h] + int v5; // ebx + char *v6; // esi + signed int v7; // edi + int v8; // eax + int v9; // eax + void *unused; // [esp+Ch] [ebp-8h] + unsigned char *a1; // [esp+10h] [ebp-4h] - v5 = x; - unused = buffer; - a1 = (unsigned char *)buffer; - v6 = (char *)dpiece_defs_map_1 + 32 * gendung_get_dpiece_num_from_coord(x, y); - v7 = 0; - do - { - v8 = *(unsigned short *)&v6[2 * v7]; - level_cel_block = *(unsigned short *)&v6[2 * v7]; - if ( v8 ) - drawLowerScreen(a1); - v9 = *(unsigned short *)&v6[2 * v7 + 2]; - level_cel_block = *(unsigned short *)&v6[2 * v7 + 2]; - if ( v9 ) - drawLowerScreen(a1 + 32); - a1 -= 768 * 32; - v7 += 2; - } - while ( v7 < 12 ); - town_draw_clipped_town(unused, v5, y, sx, sy, 0); + v5 = x; + unused = buffer; + a1 = (unsigned char *)buffer; + v6 = (char *)dpiece_defs_map_1 + 32 * gendung_get_dpiece_num_from_coord(x, y); + v7 = 0; + do { + v8 = *(unsigned short *)&v6[2 * v7]; + level_cel_block = *(unsigned short *)&v6[2 * v7]; + if (v8) + drawLowerScreen(a1); + v9 = *(unsigned short *)&v6[2 * v7 + 2]; + level_cel_block = *(unsigned short *)&v6[2 * v7 + 2]; + if (v9) + drawLowerScreen(a1 + 32); + a1 -= 768 * 32; + v7 += 2; + } while (v7 < 12); + town_draw_clipped_town(unused, v5, y, sx, sy, 0); } // 69CF14: using guessed type int level_cel_block; void __fastcall town_draw_clipped_town(void *unused, int x, int y, int sx, int sy, int some_flag) { - unsigned int v6; // edx - int v7; // edi - char v8; // al - char v9; // al - int v10; // esi - int v11; // ebx - int v12; // esi - int v13; // ebx - int v14; // eax - int v15; // eax - int v16; // esi - int v17; // ebx - char v18; // al - int v19; // esi - int v20; // ebx - int v21; // edi - char v22; // al - char v23; // al - int v24; // esi - int v25; // ebx - int v26; // edi - char *v27; // [esp+Ch] [ebp-Ch] - int xa; // [esp+10h] [ebp-8h] - int v29; // [esp+14h] [ebp-4h] + unsigned int v6; // edx + int v7; // edi + char v8; // al + char v9; // al + int v10; // esi + int v11; // ebx + int v12; // esi + int v13; // ebx + int v14; // eax + int v15; // eax + int v16; // esi + int v17; // ebx + char v18; // al + int v19; // esi + int v20; // ebx + int v21; // edi + char v22; // al + char v23; // al + int v24; // esi + int v25; // ebx + int v26; // edi + char *v27; // [esp+Ch] [ebp-Ch] + int xa; // [esp+10h] [ebp-8h] + int v29; // [esp+14h] [ebp-4h] - xa = x; - v6 = 112 * x; - v27 = (char *)gpBuffer + screen_y_times_768[sy] + sx; - v7 = v6 + y; - v29 = v6 + y; - v8 = dItem[v6 / 0x70][y]; - if ( v8 ) - { - v9 = v8 - 1; - v10 = v9; - v11 = sx - item[v10]._iAnimWidth2; - if ( v9 == pcursitem ) - CelDrawHdrClrHL( - ICOL_BLUE, - v11, - sy, - (char *)item[v10]._iAnimData, - item[v10]._iAnimFrame, - item[v10]._iAnimWidth, - 0, - 8); - Cel2DrawHdrOnly(v11, sy, (char *)item[v10]._iAnimData, item[v10]._iAnimFrame, item[v10]._iAnimWidth, 0, 8); - } - if ( dFlags[0][v7] & DFLAG_MONSTER ) - { - v12 = -1 - dMonster[x][y-1]; // -1 - *(&dword_52D204 + v7); /* check */ - v13 = sx - towner[v12]._tAnimWidth2; - if ( v12 == pcursmonst ) - CelDrawHdrClrHL( - 166, - v13, - sy, - (char *)towner[v12]._tAnimData, - towner[v12]._tAnimFrame, - towner[v12]._tAnimWidth, - 0, - 8); - Cel2DrawHdrOnly(v13, sy, (char *)towner[v12]._tAnimData, towner[v12]._tAnimFrame, towner[v12]._tAnimWidth, 0, 8); - } - v14 = dMonster[0][v7]; - if ( v14 > 0 ) - { - v15 = v14 - 1; - v16 = v15; - v17 = sx - towner[v15]._tAnimWidth2; - if ( v15 == pcursmonst ) - CelDrawHdrClrHL( - 166, - v17, - sy, - (char *)towner[v16]._tAnimData, - towner[v16]._tAnimFrame, - towner[v16]._tAnimWidth, - 0, - 8); - Cel2DrawHdrOnly(v17, sy, (char *)towner[v16]._tAnimData, towner[v16]._tAnimFrame, towner[v16]._tAnimWidth, 0, 8); - } - if ( dFlags[0][v7] & DFLAG_PLAYER ) - { - v18 = -1 - dPlayer[x][y-1]; // -1 - *((_BYTE *)&themeLoc[49].height + v7 + 3); - v19 = v18; - v20 = sy + plr[v19]._pyoff; - v21 = sx + plr[v19]._pxoff - plr[v19]._pAnimWidth2; - if ( v18 == pcursplr ) - Cl2DecodeClrHL(165, v21, v20, (char *)plr[v19]._pAnimData, plr[v19]._pAnimFrame, plr[v19]._pAnimWidth, 0, 8); - Cl2DecodeFrm4(v21, v20, (char *)plr[v19]._pAnimData, plr[v19]._pAnimFrame, plr[v19]._pAnimWidth, 0, 8); - if ( some_flag && plr[v19]._peflag ) - town_draw_clipped_e_flag(v27 - 64, xa - 1, y + 1, sx - 64, sy); - v7 = v29; - } - if ( dFlags[0][v7] & DFLAG_DEAD_PLAYER ) - DrawDeadPlayer(xa, y, sx, sy, 0, 8, 1); - v22 = dPlayer[0][v7]; - if ( v22 > 0 ) - { - v23 = v22 - 1; - v24 = v23; - v25 = sy + plr[v24]._pyoff; - v26 = sx + plr[v24]._pxoff - plr[v24]._pAnimWidth2; - if ( v23 == pcursplr ) - Cl2DecodeClrHL(165, v26, v25, (char *)plr[v24]._pAnimData, plr[v24]._pAnimFrame, plr[v24]._pAnimWidth, 0, 8); - Cl2DecodeFrm4(v26, v25, (char *)plr[v24]._pAnimData, plr[v24]._pAnimFrame, plr[v24]._pAnimWidth, 0, 8); - if ( some_flag && plr[v24]._peflag ) - town_draw_clipped_e_flag(v27 - 64, xa - 1, y + 1, sx - 64, sy); - v7 = v29; - } - if ( dFlags[0][v7] & DFLAG_MISSILE ) - DrawClippedMissile(xa, y, sx, sy, 0, 8, 0); + xa = x; + v6 = 112 * x; + v27 = (char *)gpBuffer + screen_y_times_768[sy] + sx; + v7 = v6 + y; + v29 = v6 + y; + v8 = dItem[v6 / 0x70][y]; + if (v8) { + v9 = v8 - 1; + v10 = v9; + v11 = sx - item[v10]._iAnimWidth2; + if (v9 == pcursitem) + CelDrawHdrClrHL( + ICOL_BLUE, + v11, + sy, + (char *)item[v10]._iAnimData, + item[v10]._iAnimFrame, + item[v10]._iAnimWidth, + 0, + 8); + Cel2DrawHdrOnly(v11, sy, (char *)item[v10]._iAnimData, item[v10]._iAnimFrame, item[v10]._iAnimWidth, 0, 8); + } + if (dFlags[0][v7] & DFLAG_MONSTER) { + v12 = -1 - dMonster[x][y - 1]; // -1 - *(&dword_52D204 + v7); /* check */ + v13 = sx - towner[v12]._tAnimWidth2; + if (v12 == pcursmonst) + CelDrawHdrClrHL( + 166, + v13, + sy, + (char *)towner[v12]._tAnimData, + towner[v12]._tAnimFrame, + towner[v12]._tAnimWidth, + 0, + 8); + Cel2DrawHdrOnly(v13, sy, (char *)towner[v12]._tAnimData, towner[v12]._tAnimFrame, towner[v12]._tAnimWidth, 0, 8); + } + v14 = dMonster[0][v7]; + if (v14 > 0) { + v15 = v14 - 1; + v16 = v15; + v17 = sx - towner[v15]._tAnimWidth2; + if (v15 == pcursmonst) + CelDrawHdrClrHL( + 166, + v17, + sy, + (char *)towner[v16]._tAnimData, + towner[v16]._tAnimFrame, + towner[v16]._tAnimWidth, + 0, + 8); + Cel2DrawHdrOnly(v17, sy, (char *)towner[v16]._tAnimData, towner[v16]._tAnimFrame, towner[v16]._tAnimWidth, 0, 8); + } + if (dFlags[0][v7] & DFLAG_PLAYER) { + v18 = -1 - dPlayer[x][y - 1]; // -1 - *((_BYTE *)&themeLoc[49].height + v7 + 3); + v19 = v18; + v20 = sy + plr[v19]._pyoff; + v21 = sx + plr[v19]._pxoff - plr[v19]._pAnimWidth2; + if (v18 == pcursplr) + Cl2DecodeClrHL(165, v21, v20, (char *)plr[v19]._pAnimData, plr[v19]._pAnimFrame, plr[v19]._pAnimWidth, 0, 8); + Cl2DecodeFrm4(v21, v20, (char *)plr[v19]._pAnimData, plr[v19]._pAnimFrame, plr[v19]._pAnimWidth, 0, 8); + if (some_flag && plr[v19]._peflag) + town_draw_clipped_e_flag(v27 - 64, xa - 1, y + 1, sx - 64, sy); + v7 = v29; + } + if (dFlags[0][v7] & DFLAG_DEAD_PLAYER) + DrawDeadPlayer(xa, y, sx, sy, 0, 8, 1); + v22 = dPlayer[0][v7]; + if (v22 > 0) { + v23 = v22 - 1; + v24 = v23; + v25 = sy + plr[v24]._pyoff; + v26 = sx + plr[v24]._pxoff - plr[v24]._pAnimWidth2; + if (v23 == pcursplr) + Cl2DecodeClrHL(165, v26, v25, (char *)plr[v24]._pAnimData, plr[v24]._pAnimFrame, plr[v24]._pAnimWidth, 0, 8); + Cl2DecodeFrm4(v26, v25, (char *)plr[v24]._pAnimData, plr[v24]._pAnimFrame, plr[v24]._pAnimWidth, 0, 8); + if (some_flag && plr[v24]._peflag) + town_draw_clipped_e_flag(v27 - 64, xa - 1, y + 1, sx - 64, sy); + v7 = v29; + } + if (dFlags[0][v7] & DFLAG_MISSILE) + DrawClippedMissile(xa, y, sx, sy, 0, 8, 0); } // 4B8CC0: using guessed type char pcursitem; // 4B8CC2: using guessed type char pcursplr; void __fastcall town_draw_lower(int x, int y, int sx, int sy, int a5, int some_flag) { - int v6; // ebx - int *v7; // edi - char *v8; // esi - int v9; // eax - int v10; // eax - int *v11; // ebx - int v12; // esi - unsigned char *v13; // esi - char *v14; // edi - int v15; // eax - int v16; // eax - bool v17; // zf - int *v18; // ebx - unsigned char *v19; // esi - char *v20; // edi - int v21; // eax - unsigned char *a1; // [esp+Ch] [ebp-10h] - int a1a; // [esp+Ch] [ebp-10h] - int ya; // [esp+10h] [ebp-Ch] - signed int v25; // [esp+14h] [ebp-8h] - signed int v26; // [esp+14h] [ebp-8h] - signed int v27; // [esp+14h] [ebp-8h] - signed int xa; // [esp+18h] [ebp-4h] - int a5a; // [esp+2Ch] [ebp+10h] + int v6; // ebx + int *v7; // edi + char *v8; // esi + int v9; // eax + int v10; // eax + int *v11; // ebx + int v12; // esi + unsigned char *v13; // esi + char *v14; // edi + int v15; // eax + int v16; // eax + bool v17; // zf + int *v18; // ebx + unsigned char *v19; // esi + char *v20; // edi + int v21; // eax + unsigned char *a1; // [esp+Ch] [ebp-10h] + int a1a; // [esp+Ch] [ebp-10h] + int ya; // [esp+10h] [ebp-Ch] + signed int v25; // [esp+14h] [ebp-8h] + signed int v26; // [esp+14h] [ebp-8h] + signed int v27; // [esp+14h] [ebp-8h] + signed int xa; // [esp+18h] [ebp-4h] + int a5a; // [esp+2Ch] [ebp+10h] - ya = y; - xa = x; - if ( some_flag ) - { - if ( y >= 0 && y < 112 && x >= 0 && x < 112 && (level_cel_block = dPiece[0][y + 112 * x]) != 0 ) - { - v6 = sy; - v7 = &screen_y_times_768[sy]; - a1 = (unsigned char *)&gpBuffer->row_unused_1[0].col_unused_1[*v7 + 32 + sx]; - v25 = 1; - v8 = (char *)dpiece_defs_map_1 + 32 * gendung_get_dpiece_num_from_coord(x, y); - do - { - v9 = *(unsigned short *)&v8[2 * v25]; - level_cel_block = *(unsigned short *)&v8[2 * v25]; - if ( v9 ) - drawLowerScreen(a1); - v25 += 2; - a1 -= 768 * 32; - } - while ( v25 < 17 ); - town_draw_clipped_town((char *)gpBuffer + *v7 + sx, xa, ya, sx, sy, 0); - } - else - { - town_clear_low_buf((unsigned char *)gpBuffer + screen_y_times_768[sy] + sx); - v6 = sy; - } - ++xa; - y = ya - 1; - sx += 64; - --ya; - } - else - { - v6 = sy; - } - v10 = a5 - some_flag; - if ( a5 - some_flag > 0 ) - { - v11 = &screen_y_times_768[v6]; - v12 = 112 * xa; - a5a = 112 * xa; - a1a = v10; - do - { - if ( y >= 0 && y < 112 && v12 >= 0 && v12 < MAXDUNX * MAXDUNY && (level_cel_block = dPiece[0][v12 + y]) != 0 ) - { - v13 = (unsigned char *)gpBuffer + *v11 + sx; - v14 = (char *)dpiece_defs_map_1 + 32 * gendung_get_dpiece_num_from_coord(xa, ya); - v26 = 0; - do - { - v15 = *(unsigned short *)&v14[2 * v26]; - level_cel_block = *(unsigned short *)&v14[2 * v26]; - if ( v15 ) - drawLowerScreen(v13); - v16 = *(unsigned short *)&v14[2 * v26 + 2]; - level_cel_block = *(unsigned short *)&v14[2 * v26 + 2]; - if ( v16 ) - drawLowerScreen(v13 + 32); - v26 += 2; - v13 -= 768 * 32; - } - while ( v26 < 16 ); - town_draw_clipped_town((char *)gpBuffer + *v11 + sx, xa, ya, sx, sy, 1); - v12 = a5a; - } - else - { - town_clear_low_buf((unsigned char *)gpBuffer + *v11 + sx); - } - ++xa; - sx += 64; - v12 += 112; - y = ya - 1; - v17 = a1a-- == 1; - a5a = v12; - --ya; - } - while ( !v17 ); - v6 = sy; - } - if ( some_flag ) - { - if ( y >= 0 && y < 112 && xa >= 0 && xa < 112 && (level_cel_block = dPiece[0][y + 112 * xa]) != 0 ) - { - v18 = &screen_y_times_768[v6]; - v19 = (unsigned char *)gpBuffer + *v18 + sx; - v20 = (char *)dpiece_defs_map_1 + 32 * gendung_get_dpiece_num_from_coord(xa, ya); - v27 = 0; - do - { - v21 = *(unsigned short *)&v20[2 * v27]; - level_cel_block = *(unsigned short *)&v20[2 * v27]; - if ( v21 ) - drawLowerScreen(v19); - v27 += 2; - v19 -= 768 * 32; - } - while ( v27 < 16 ); - town_draw_clipped_town((char *)gpBuffer + *v18 + sx, xa, ya, sx, sy, 0); - } - else - { - town_clear_low_buf((unsigned char *)gpBuffer + screen_y_times_768[v6] + sx); - } - } + ya = y; + xa = x; + if (some_flag) { + if (y >= 0 && y < 112 && x >= 0 && x < 112 && (level_cel_block = dPiece[0][y + 112 * x]) != 0) { + v6 = sy; + v7 = &screen_y_times_768[sy]; + a1 = (unsigned char *)&gpBuffer->row_unused_1[0].col_unused_1[*v7 + 32 + sx]; + v25 = 1; + v8 = (char *)dpiece_defs_map_1 + 32 * gendung_get_dpiece_num_from_coord(x, y); + do { + v9 = *(unsigned short *)&v8[2 * v25]; + level_cel_block = *(unsigned short *)&v8[2 * v25]; + if (v9) + drawLowerScreen(a1); + v25 += 2; + a1 -= 768 * 32; + } while (v25 < 17); + town_draw_clipped_town((char *)gpBuffer + *v7 + sx, xa, ya, sx, sy, 0); + } else { + town_clear_low_buf((unsigned char *)gpBuffer + screen_y_times_768[sy] + sx); + v6 = sy; + } + ++xa; + y = ya - 1; + sx += 64; + --ya; + } else { + v6 = sy; + } + v10 = a5 - some_flag; + if (a5 - some_flag > 0) { + v11 = &screen_y_times_768[v6]; + v12 = 112 * xa; + a5a = 112 * xa; + a1a = v10; + do { + if (y >= 0 && y < 112 && v12 >= 0 && v12 < MAXDUNX * MAXDUNY && (level_cel_block = dPiece[0][v12 + y]) != 0) { + v13 = (unsigned char *)gpBuffer + *v11 + sx; + v14 = (char *)dpiece_defs_map_1 + 32 * gendung_get_dpiece_num_from_coord(xa, ya); + v26 = 0; + do { + v15 = *(unsigned short *)&v14[2 * v26]; + level_cel_block = *(unsigned short *)&v14[2 * v26]; + if (v15) + drawLowerScreen(v13); + v16 = *(unsigned short *)&v14[2 * v26 + 2]; + level_cel_block = *(unsigned short *)&v14[2 * v26 + 2]; + if (v16) + drawLowerScreen(v13 + 32); + v26 += 2; + v13 -= 768 * 32; + } while (v26 < 16); + town_draw_clipped_town((char *)gpBuffer + *v11 + sx, xa, ya, sx, sy, 1); + v12 = a5a; + } else { + town_clear_low_buf((unsigned char *)gpBuffer + *v11 + sx); + } + ++xa; + sx += 64; + v12 += 112; + y = ya - 1; + v17 = a1a-- == 1; + a5a = v12; + --ya; + } while (!v17); + v6 = sy; + } + if (some_flag) { + if (y >= 0 && y < 112 && xa >= 0 && xa < 112 && (level_cel_block = dPiece[0][y + 112 * xa]) != 0) { + v18 = &screen_y_times_768[v6]; + v19 = (unsigned char *)gpBuffer + *v18 + sx; + v20 = (char *)dpiece_defs_map_1 + 32 * gendung_get_dpiece_num_from_coord(xa, ya); + v27 = 0; + do { + v21 = *(unsigned short *)&v20[2 * v27]; + level_cel_block = *(unsigned short *)&v20[2 * v27]; + if (v21) + drawLowerScreen(v19); + v27 += 2; + v19 -= 768 * 32; + } while (v27 < 16); + town_draw_clipped_town((char *)gpBuffer + *v18 + sx, xa, ya, sx, sy, 0); + } else { + town_clear_low_buf((unsigned char *)gpBuffer + screen_y_times_768[v6] + sx); + } + } } // 69CF14: using guessed type int level_cel_block; void __fastcall town_draw_clipped_e_flag_2(void *buffer, int x, int y, int a4, int a5, int sx, int sy) { - int v7; // ebx - unsigned char *v8; // edi - short *v9; // esi - int v10; // eax - int v11; // eax - void *v12; // [esp+8h] [ebp-8h] - int xa; // [esp+Ch] [ebp-4h] - int a4a; // [esp+1Ch] [ebp+Ch] + int v7; // ebx + unsigned char *v8; // edi + short *v9; // esi + int v10; // eax + int v11; // eax + void *v12; // [esp+8h] [ebp-8h] + int xa; // [esp+Ch] [ebp-4h] + int a4a; // [esp+1Ch] [ebp+Ch] - v7 = a4; - xa = x; - v12 = buffer; - if ( a4 ) - v8 = (unsigned char *)buffer + 768 * 32 * a4; - else - v8 = (unsigned char *)buffer; - a4a = 0; - v9 = &dpiece_defs_map_1[0][0][16 * gendung_get_dpiece_num_from_coord(x, y) + 3]; - do - { - if ( v7 <= a4a ) - { - v10 = (unsigned short)*(v9 - 1); - level_cel_block = (unsigned short)*(v9 - 1); - if ( v10 ) - drawLowerScreen(v8); - v11 = (unsigned short)*v9; - level_cel_block = (unsigned short)*v9; - if ( v11 ) - drawLowerScreen(v8 + 32); - } - v8 -= 768 * 32; - ++a4a; - v9 += 2; - } - while ( a4a < 6 ); - if ( a5 < 8 ) - town_draw_clipped_town_2((int)v12, xa, y, v7, a5, sx, sy, 0); + v7 = a4; + xa = x; + v12 = buffer; + if (a4) + v8 = (unsigned char *)buffer + 768 * 32 * a4; + else + v8 = (unsigned char *)buffer; + a4a = 0; + v9 = &dpiece_defs_map_1[0][0][16 * gendung_get_dpiece_num_from_coord(x, y) + 3]; + do { + if (v7 <= a4a) { + v10 = (unsigned short)*(v9 - 1); + level_cel_block = (unsigned short)*(v9 - 1); + if (v10) + drawLowerScreen(v8); + v11 = (unsigned short)*v9; + level_cel_block = (unsigned short)*v9; + if (v11) + drawLowerScreen(v8 + 32); + } + v8 -= 768 * 32; + ++a4a; + v9 += 2; + } while (a4a < 6); + if (a5 < 8) + town_draw_clipped_town_2((int)v12, xa, y, v7, a5, sx, sy, 0); } // 69CF14: using guessed type int level_cel_block; void __fastcall town_draw_clipped_town_2(int x, int y, int a3, int a4, int a5, int sx, int sy, int some_flag) { - unsigned int v8; // edx - int v9; // ebx - char v10; // al - char v11; // al - int v12; // esi - int v13; // edi - int v14; // esi - int v15; // edi - int v16; // eax - int v17; // eax - int v18; // esi - int v19; // edi - char v20; // al - int v21; // esi - int v22; // ebx - int v23; // edi - char v24; // al - char v25; // al - int v26; // esi - int v27; // ebx - int v28; // edi - int v29; // [esp+Ch] [ebp-Ch] - int xa; // [esp+10h] [ebp-8h] - int v31; // [esp+14h] [ebp-4h] + unsigned int v8; // edx + int v9; // ebx + char v10; // al + char v11; // al + int v12; // esi + int v13; // edi + int v14; // esi + int v15; // edi + int v16; // eax + int v17; // eax + int v18; // esi + int v19; // edi + char v20; // al + int v21; // esi + int v22; // ebx + int v23; // edi + char v24; // al + char v25; // al + int v26; // esi + int v27; // ebx + int v28; // edi + int v29; // [esp+Ch] [ebp-Ch] + int xa; // [esp+10h] [ebp-8h] + int v31; // [esp+14h] [ebp-4h] - xa = y; - v8 = 112 * y; - v9 = v8 + a3; - v29 = x; - v31 = v8 + a3; - v10 = dItem[v8 / 0x70][a3]; - if ( v10 ) - { - v11 = v10 - 1; - v12 = v11; - v13 = sx - item[v12]._iAnimWidth2; - if ( v11 == pcursitem ) - CelDrawHdrClrHL( - ICOL_BLUE, - v13, - sy, - (char *)item[v12]._iAnimData, - item[v12]._iAnimFrame, - item[v12]._iAnimWidth, - a5, - 8); - Cel2DrawHdrOnly(v13, sy, (char *)item[v12]._iAnimData, item[v12]._iAnimFrame, item[v12]._iAnimWidth, a5, 8); - } - if ( dFlags[0][v9] & DFLAG_MONSTER ) - { - v14 = -1 - dMonster[x][y-1]; // -1 - *(&dword_52D204 + v9); /* check */ - v15 = sx - towner[v14]._tAnimWidth2; - if ( v14 == pcursmonst ) - CelDrawHdrClrHL( - 166, - v15, - sy, - (char *)towner[v14]._tAnimData, - towner[v14]._tAnimFrame, - towner[v14]._tAnimWidth, - a5, - 8); - Cel2DrawHdrOnly(v15, sy, (char *)towner[v14]._tAnimData, towner[v14]._tAnimFrame, towner[v14]._tAnimWidth, a5, 8); - } - v16 = dMonster[0][v9]; - if ( v16 > 0 ) - { - v17 = v16 - 1; - v18 = v17; - v19 = sx - towner[v17]._tAnimWidth2; - if ( v17 == pcursmonst ) - CelDrawHdrClrHL( - 166, - v19, - sy, - (char *)towner[v18]._tAnimData, - towner[v18]._tAnimFrame, - towner[v18]._tAnimWidth, - a5, - 8); - Cel2DrawHdrOnly(v19, sy, (char *)towner[v18]._tAnimData, towner[v18]._tAnimFrame, towner[v18]._tAnimWidth, a5, 8); - } - if ( dFlags[0][v9] & DFLAG_PLAYER ) - { - v20 = -1 - dPlayer[x][y-1]; // -1 - *((_BYTE *)&themeLoc[49].height + v9 + 3); - v21 = v20; - v22 = sy + plr[v21]._pyoff; - v23 = sx + plr[v21]._pxoff - plr[v21]._pAnimWidth2; - if ( v20 == pcursplr ) - Cl2DecodeClrHL(165, v23, v22, (char *)plr[v21]._pAnimData, plr[v21]._pAnimFrame, plr[v21]._pAnimWidth, a5, 8); - Cl2DecodeFrm4(v23, v22, (char *)plr[v21]._pAnimData, plr[v21]._pAnimFrame, plr[v21]._pAnimWidth, a5, 8); - if ( some_flag && plr[v21]._peflag ) - town_draw_clipped_e_flag_2((void *)(v29 - 64), xa - 1, a3 + 1, a4, a5, sx - 64, sy); - v9 = v31; - } - if ( dFlags[0][v9] & DFLAG_DEAD_PLAYER ) - DrawDeadPlayer(xa, a3, sx, sy, a5, 8, 1); - v24 = dPlayer[0][v9]; - if ( v24 > 0 ) - { - v25 = v24 - 1; - v26 = v25; - v27 = sy + plr[v26]._pyoff; - v28 = sx + plr[v26]._pxoff - plr[v26]._pAnimWidth2; - if ( v25 == pcursplr ) - Cl2DecodeClrHL(165, v28, v27, (char *)plr[v26]._pAnimData, plr[v26]._pAnimFrame, plr[v26]._pAnimWidth, a5, 8); - Cl2DecodeFrm4(v28, v27, (char *)plr[v26]._pAnimData, plr[v26]._pAnimFrame, plr[v26]._pAnimWidth, a5, 8); - if ( some_flag && plr[v26]._peflag ) - town_draw_clipped_e_flag_2((void *)(v29 - 64), xa - 1, a3 + 1, a4, a5, sx - 64, sy); - v9 = v31; - } - if ( dFlags[0][v9] & DFLAG_MISSILE ) - DrawClippedMissile(xa, a3, sx, sy, a5, 8, 0); + xa = y; + v8 = 112 * y; + v9 = v8 + a3; + v29 = x; + v31 = v8 + a3; + v10 = dItem[v8 / 0x70][a3]; + if (v10) { + v11 = v10 - 1; + v12 = v11; + v13 = sx - item[v12]._iAnimWidth2; + if (v11 == pcursitem) + CelDrawHdrClrHL( + ICOL_BLUE, + v13, + sy, + (char *)item[v12]._iAnimData, + item[v12]._iAnimFrame, + item[v12]._iAnimWidth, + a5, + 8); + Cel2DrawHdrOnly(v13, sy, (char *)item[v12]._iAnimData, item[v12]._iAnimFrame, item[v12]._iAnimWidth, a5, 8); + } + if (dFlags[0][v9] & DFLAG_MONSTER) { + v14 = -1 - dMonster[x][y - 1]; // -1 - *(&dword_52D204 + v9); /* check */ + v15 = sx - towner[v14]._tAnimWidth2; + if (v14 == pcursmonst) + CelDrawHdrClrHL( + 166, + v15, + sy, + (char *)towner[v14]._tAnimData, + towner[v14]._tAnimFrame, + towner[v14]._tAnimWidth, + a5, + 8); + Cel2DrawHdrOnly(v15, sy, (char *)towner[v14]._tAnimData, towner[v14]._tAnimFrame, towner[v14]._tAnimWidth, a5, 8); + } + v16 = dMonster[0][v9]; + if (v16 > 0) { + v17 = v16 - 1; + v18 = v17; + v19 = sx - towner[v17]._tAnimWidth2; + if (v17 == pcursmonst) + CelDrawHdrClrHL( + 166, + v19, + sy, + (char *)towner[v18]._tAnimData, + towner[v18]._tAnimFrame, + towner[v18]._tAnimWidth, + a5, + 8); + Cel2DrawHdrOnly(v19, sy, (char *)towner[v18]._tAnimData, towner[v18]._tAnimFrame, towner[v18]._tAnimWidth, a5, 8); + } + if (dFlags[0][v9] & DFLAG_PLAYER) { + v20 = -1 - dPlayer[x][y - 1]; // -1 - *((_BYTE *)&themeLoc[49].height + v9 + 3); + v21 = v20; + v22 = sy + plr[v21]._pyoff; + v23 = sx + plr[v21]._pxoff - plr[v21]._pAnimWidth2; + if (v20 == pcursplr) + Cl2DecodeClrHL(165, v23, v22, (char *)plr[v21]._pAnimData, plr[v21]._pAnimFrame, plr[v21]._pAnimWidth, a5, 8); + Cl2DecodeFrm4(v23, v22, (char *)plr[v21]._pAnimData, plr[v21]._pAnimFrame, plr[v21]._pAnimWidth, a5, 8); + if (some_flag && plr[v21]._peflag) + town_draw_clipped_e_flag_2((void *)(v29 - 64), xa - 1, a3 + 1, a4, a5, sx - 64, sy); + v9 = v31; + } + if (dFlags[0][v9] & DFLAG_DEAD_PLAYER) + DrawDeadPlayer(xa, a3, sx, sy, a5, 8, 1); + v24 = dPlayer[0][v9]; + if (v24 > 0) { + v25 = v24 - 1; + v26 = v25; + v27 = sy + plr[v26]._pyoff; + v28 = sx + plr[v26]._pxoff - plr[v26]._pAnimWidth2; + if (v25 == pcursplr) + Cl2DecodeClrHL(165, v28, v27, (char *)plr[v26]._pAnimData, plr[v26]._pAnimFrame, plr[v26]._pAnimWidth, a5, 8); + Cl2DecodeFrm4(v28, v27, (char *)plr[v26]._pAnimData, plr[v26]._pAnimFrame, plr[v26]._pAnimWidth, a5, 8); + if (some_flag && plr[v26]._peflag) + town_draw_clipped_e_flag_2((void *)(v29 - 64), xa - 1, a3 + 1, a4, a5, sx - 64, sy); + v9 = v31; + } + if (dFlags[0][v9] & DFLAG_MISSILE) + DrawClippedMissile(xa, a3, sx, sy, a5, 8, 0); } // 4B8CC0: using guessed type char pcursitem; // 4B8CC2: using guessed type char pcursplr; void __fastcall town_draw_lower_2(int x, int y, int sx, int sy, int a5, int a6, int some_flag) { - int v7; // esi - int v8; // ebx - int *v9; // edi - short *v10; // eax - int v11; // esi - int v12; // eax - int *v13; // ebx - int v14; // edi - short *v15; // edi - int v16; // eax - int v17; // eax - int v18; // eax - bool v19; // zf - int *v20; // edi - short *v21; // ebx - int v22; // eax - short *v23; // [esp+Ch] [ebp-10h] - int v24; // [esp+Ch] [ebp-10h] - unsigned char *a1; // [esp+10h] [ebp-Ch] - unsigned char *a1a; // [esp+10h] [ebp-Ch] - unsigned char *a1b; // [esp+10h] [ebp-Ch] - signed int ya; // [esp+14h] [ebp-8h] - signed int xa; // [esp+18h] [ebp-4h] - signed int sxa; // [esp+24h] [ebp+8h] - signed int sxb; // [esp+24h] [ebp+8h] - signed int sxc; // [esp+24h] [ebp+8h] - int a5a; // [esp+2Ch] [ebp+10h] + int v7; // esi + int v8; // ebx + int *v9; // edi + short *v10; // eax + int v11; // esi + int v12; // eax + int *v13; // ebx + int v14; // edi + short *v15; // edi + int v16; // eax + int v17; // eax + int v18; // eax + bool v19; // zf + int *v20; // edi + short *v21; // ebx + int v22; // eax + short *v23; // [esp+Ch] [ebp-10h] + int v24; // [esp+Ch] [ebp-10h] + unsigned char *a1; // [esp+10h] [ebp-Ch] + unsigned char *a1a; // [esp+10h] [ebp-Ch] + unsigned char *a1b; // [esp+10h] [ebp-Ch] + signed int ya; // [esp+14h] [ebp-8h] + signed int xa; // [esp+18h] [ebp-4h] + signed int sxa; // [esp+24h] [ebp+8h] + signed int sxb; // [esp+24h] [ebp+8h] + signed int sxc; // [esp+24h] [ebp+8h] + int a5a; // [esp+2Ch] [ebp+10h] - ya = y; - xa = x; - if ( some_flag ) - { - if ( y < 0 || y >= 112 || x < 0 || x >= 112 ) - { - v7 = sx; - } - else - { - v7 = sx; - level_cel_block = dPiece[0][y + 112 * x]; - if ( level_cel_block ) - { - v8 = sy; - v9 = &screen_y_times_768[sy]; - a1 = (unsigned char *)gpBuffer + *v9 + sx - 24544; - sxa = 0; - v10 = &dpiece_defs_map_1[0][0][16 * gendung_get_dpiece_num_from_coord(x, y) + 3]; - v23 = v10; - do - { - if ( a6 <= sxa ) - { - level_cel_block = (unsigned short)*v10; - if ( level_cel_block ) - drawLowerScreen(a1); - } - a1 -= 768 * 32; - ++sxa; - v10 = v23 + 2; - v23 += 2; - } - while ( sxa < 7 ); - if ( 2 * a6 + 2 < 8 ) - town_draw_clipped_town_2((int)gpBuffer + *v9 + v7, xa, ya, a6, 2 * a6 + 2, v7, sy, 0); - goto LABEL_16; - } - } - town_clear_low_buf((unsigned char *)gpBuffer + screen_y_times_768[sy] + v7); - v8 = sy; -LABEL_16: - ++xa; - --ya; - v11 = v7 + 64; - goto LABEL_18; - } - v11 = sx; - v8 = sy; + ya = y; + xa = x; + if (some_flag) { + if (y < 0 || y >= 112 || x < 0 || x >= 112) { + v7 = sx; + } else { + v7 = sx; + level_cel_block = dPiece[0][y + 112 * x]; + if (level_cel_block) { + v8 = sy; + v9 = &screen_y_times_768[sy]; + a1 = (unsigned char *)gpBuffer + *v9 + sx - 24544; + sxa = 0; + v10 = &dpiece_defs_map_1[0][0][16 * gendung_get_dpiece_num_from_coord(x, y) + 3]; + v23 = v10; + do { + if (a6 <= sxa) { + level_cel_block = (unsigned short)*v10; + if (level_cel_block) + drawLowerScreen(a1); + } + a1 -= 768 * 32; + ++sxa; + v10 = v23 + 2; + v23 += 2; + } while (sxa < 7); + if (2 * a6 + 2 < 8) + town_draw_clipped_town_2((int)gpBuffer + *v9 + v7, xa, ya, a6, 2 * a6 + 2, v7, sy, 0); + goto LABEL_16; + } + } + town_clear_low_buf((unsigned char *)gpBuffer + screen_y_times_768[sy] + v7); + v8 = sy; + LABEL_16: + ++xa; + --ya; + v11 = v7 + 64; + goto LABEL_18; + } + v11 = sx; + v8 = sy; LABEL_18: - v12 = a5 - some_flag; - if ( a5 - some_flag > 0 ) - { - v13 = &screen_y_times_768[v8]; - v14 = 112 * xa; - a5a = 112 * xa; - v24 = v12; - do - { - if ( ya >= 0 && ya < 112 && v14 >= 0 && v14 < MAXDUNX * MAXDUNY && (level_cel_block = dPiece[0][v14 + ya]) != 0 ) - { - a1a = (unsigned char *)gpBuffer + *v13 + v11 - 768 * 32; - sxb = 0; - v15 = &dpiece_defs_map_1[0][0][16 * gendung_get_dpiece_num_from_coord(xa, ya) + 3]; - do - { - if ( a6 <= sxb ) - { - v16 = (unsigned short)*(v15 - 1); - level_cel_block = (unsigned short)*(v15 - 1); - if ( v16 ) - drawLowerScreen(a1a); - v17 = (unsigned short)*v15; - level_cel_block = (unsigned short)*v15; - if ( v17 ) - drawLowerScreen(a1a + 32); - } - a1a -= 768 * 32; - ++sxb; - v15 += 2; - } - while ( sxb < 7 ); - v18 = 2 * a6 + 2; - if ( v18 < 8 ) - town_draw_clipped_town_2((int)gpBuffer + *v13 - 12288 * v18 + v11, xa, ya, a6, 2 * a6 + 2, v11, sy, 1); - v14 = a5a; - } - else - { - town_clear_low_buf((unsigned char *)gpBuffer + *v13 + v11); - } - ++xa; - v14 += 112; - --ya; - v11 += 64; - v19 = v24-- == 1; - a5a = v14; - } - while ( !v19 ); - v8 = sy; - } - if ( some_flag ) - { - if ( ya >= 0 && ya < 112 && xa >= 0 && xa < 112 && (level_cel_block = dPiece[0][ya + 112 * xa]) != 0 ) - { - v20 = &screen_y_times_768[v8]; - a1b = (unsigned char *)gpBuffer + *v20 + v11 - 768 * 32; - sxc = 0; - v21 = &dpiece_defs_map_1[0][0][16 * gendung_get_dpiece_num_from_coord(xa, ya) + 2]; - do - { - if ( a6 <= sxc ) - { - v22 = (unsigned short)*v21; - level_cel_block = (unsigned short)*v21; - if ( v22 ) - drawLowerScreen(a1b); - } - a1b -= 768 * 32; - ++sxc; - v21 += 2; - } - while ( sxc < 7 ); - if ( 2 * a6 + 2 < 8 ) - town_draw_clipped_town_2((int)gpBuffer + *v20 + v11, xa, ya, a6, 2 * a6 + 2, v11, sy, 0); - } - else - { - town_clear_low_buf((unsigned char *)gpBuffer + screen_y_times_768[v8] + v11); - } - } + v12 = a5 - some_flag; + if (a5 - some_flag > 0) { + v13 = &screen_y_times_768[v8]; + v14 = 112 * xa; + a5a = 112 * xa; + v24 = v12; + do { + if (ya >= 0 && ya < 112 && v14 >= 0 && v14 < MAXDUNX * MAXDUNY && (level_cel_block = dPiece[0][v14 + ya]) != 0) { + a1a = (unsigned char *)gpBuffer + *v13 + v11 - 768 * 32; + sxb = 0; + v15 = &dpiece_defs_map_1[0][0][16 * gendung_get_dpiece_num_from_coord(xa, ya) + 3]; + do { + if (a6 <= sxb) { + v16 = (unsigned short)*(v15 - 1); + level_cel_block = (unsigned short)*(v15 - 1); + if (v16) + drawLowerScreen(a1a); + v17 = (unsigned short)*v15; + level_cel_block = (unsigned short)*v15; + if (v17) + drawLowerScreen(a1a + 32); + } + a1a -= 768 * 32; + ++sxb; + v15 += 2; + } while (sxb < 7); + v18 = 2 * a6 + 2; + if (v18 < 8) + town_draw_clipped_town_2((int)gpBuffer + *v13 - 12288 * v18 + v11, xa, ya, a6, 2 * a6 + 2, v11, sy, 1); + v14 = a5a; + } else { + town_clear_low_buf((unsigned char *)gpBuffer + *v13 + v11); + } + ++xa; + v14 += 112; + --ya; + v11 += 64; + v19 = v24-- == 1; + a5a = v14; + } while (!v19); + v8 = sy; + } + if (some_flag) { + if (ya >= 0 && ya < 112 && xa >= 0 && xa < 112 && (level_cel_block = dPiece[0][ya + 112 * xa]) != 0) { + v20 = &screen_y_times_768[v8]; + a1b = (unsigned char *)gpBuffer + *v20 + v11 - 768 * 32; + sxc = 0; + v21 = &dpiece_defs_map_1[0][0][16 * gendung_get_dpiece_num_from_coord(xa, ya) + 2]; + do { + if (a6 <= sxc) { + v22 = (unsigned short)*v21; + level_cel_block = (unsigned short)*v21; + if (v22) + drawLowerScreen(a1b); + } + a1b -= 768 * 32; + ++sxc; + v21 += 2; + } while (sxc < 7); + if (2 * a6 + 2 < 8) + town_draw_clipped_town_2((int)gpBuffer + *v20 + v11, xa, ya, a6, 2 * a6 + 2, v11, sy, 0); + } else { + town_clear_low_buf((unsigned char *)gpBuffer + screen_y_times_768[v8] + v11); + } + } } // 69CF14: using guessed type int level_cel_block; void __fastcall town_draw_e_flag(void *buffer, int x, int y, int a4, int dir, int sx, int sy) { - int v7; // ebx - char *v8; // esi - int v9; // edi - int v10; // eax - int v11; // eax - void *buffera; // [esp+Ch] [ebp-8h] - unsigned char *a1; // [esp+10h] [ebp-4h] + int v7; // ebx + char *v8; // esi + int v9; // edi + int v10; // eax + int v11; // eax + void *buffera; // [esp+Ch] [ebp-8h] + unsigned char *a1; // [esp+10h] [ebp-4h] - v7 = x; - buffera = buffer; - a1 = (unsigned char *)buffer; - v8 = (char *)dpiece_defs_map_1 + 32 * gendung_get_dpiece_num_from_coord(x, y); - v9 = 0; - do - { - if ( a4 >= v9 ) - { - v10 = *(unsigned short *)&v8[4 * v9]; - level_cel_block = *(unsigned short *)&v8[4 * v9]; - if ( v10 ) - drawUpperScreen(a1); - v11 = *(unsigned short *)&v8[4 * v9 + 2]; - level_cel_block = *(unsigned short *)&v8[4 * v9 + 2]; - if ( v11 ) - drawUpperScreen(a1 + 32); - } - a1 -= 768 * 32; - ++v9; - } - while ( v9 < 7 ); - town_draw_town_all(buffera, v7, y, a4, dir, sx, sy, 0); + v7 = x; + buffera = buffer; + a1 = (unsigned char *)buffer; + v8 = (char *)dpiece_defs_map_1 + 32 * gendung_get_dpiece_num_from_coord(x, y); + v9 = 0; + do { + if (a4 >= v9) { + v10 = *(unsigned short *)&v8[4 * v9]; + level_cel_block = *(unsigned short *)&v8[4 * v9]; + if (v10) + drawUpperScreen(a1); + v11 = *(unsigned short *)&v8[4 * v9 + 2]; + level_cel_block = *(unsigned short *)&v8[4 * v9 + 2]; + if (v11) + drawUpperScreen(a1 + 32); + } + a1 -= 768 * 32; + ++v9; + } while (v9 < 7); + town_draw_town_all(buffera, v7, y, a4, dir, sx, sy, 0); } // 69CF14: using guessed type int level_cel_block; void __fastcall town_draw_town_all(void *buffer, int x, int y, int a4, int dir, int sx, int sy, int some_flag) { - //int v9; // ebx - int id; // esi - int yy; // ebx - int xx; // edi + //int v9; // ebx + int id; // esi + int yy; // ebx + int xx; // edi - //v9 = 112 * x + y; - if ( dItem[x][y] ) - { - id = dItem[x][y] - 1; - xx = sx - item[id]._iAnimWidth2; - if ( id == pcursitem ) - CelDecodeClr(ICOL_BLUE, xx, sy, (char *)item[id]._iAnimData, item[id]._iAnimFrame, item[id]._iAnimWidth, 0, dir); - CelDrawHdrOnly(xx, sy, (char *)item[id]._iAnimData, item[id]._iAnimFrame, item[id]._iAnimWidth, 0, dir); - } - if ( dFlags[x][y] & DFLAG_MONSTER ) - { - id = -1 - dMonster[x][y-1]; // -1 - *(&dword_52D204 + v9); /* check */ - xx = sx - towner[id]._tAnimWidth2; - if ( id == pcursmonst ) - CelDecodeClr(166, xx, sy, (char *)towner[id]._tAnimData, towner[id]._tAnimFrame, towner[id]._tAnimWidth, 0, dir); - CelDrawHdrOnly(xx, sy, (char *)towner[id]._tAnimData, towner[id]._tAnimFrame, towner[id]._tAnimWidth, 0, dir); - } - if ( dMonster[x][y] > 0 ) - { - id = dMonster[x][y] - 1; - xx = sx - towner[id]._tAnimWidth2; - if ( id == pcursmonst ) - CelDecodeClr(166, xx, sy, (char *)towner[id]._tAnimData, towner[id]._tAnimFrame, towner[id]._tAnimWidth, 0, dir); - CelDrawHdrOnly(xx, sy, (char *)towner[id]._tAnimData, towner[id]._tAnimFrame, towner[id]._tAnimWidth, 0, dir); - } - if ( dFlags[x][y] & DFLAG_PLAYER ) - { - id = -1 - dPlayer[x][y-1]; // -1 - *((_BYTE *)&themeLoc[49].height + v9 + 3); - yy = sy + plr[id]._pyoff; - xx = sx + plr[id]._pxoff - plr[id]._pAnimWidth2; - if ( id == pcursplr ) - Cl2DecodeFrm2(165, xx, yy, (char *)plr[id]._pAnimData, plr[id]._pAnimFrame, plr[id]._pAnimWidth, 0, dir); - Cl2DecodeFrm1(xx, yy, (char *)plr[id]._pAnimData, plr[id]._pAnimFrame, plr[id]._pAnimWidth, 0, dir); - if ( some_flag && plr[id]._peflag ) - town_draw_e_flag((char *)buffer - 64, x - 1, y + 1, a4, dir, sx - 64, sy); - } - if ( dFlags[x][y] & DFLAG_DEAD_PLAYER ) - DrawDeadPlayer(x, y, sx, sy, 0, dir, 0); - if ( dPlayer[x][y] > 0 ) - { - id = dPlayer[x][y] - 1; - yy = sy + plr[id]._pyoff; - xx = sx + plr[id]._pxoff - plr[id]._pAnimWidth2; - if ( id == pcursplr ) - Cl2DecodeFrm2(165, xx, yy, (char *)plr[id]._pAnimData, plr[id]._pAnimFrame, plr[id]._pAnimWidth, 0, dir); - Cl2DecodeFrm1(xx, yy, (char *)plr[id]._pAnimData, plr[id]._pAnimFrame, plr[id]._pAnimWidth, 0, dir); - if ( some_flag && plr[id]._peflag ) - town_draw_e_flag((char *)buffer - 64, x - 1, y + 1, a4, dir, sx - 64, sy); - } - if ( dFlags[x][y] & DFLAG_MISSILE ) - DrawMissile(x, y, sx, sy, 0, dir, 0); + //v9 = 112 * x + y; + if (dItem[x][y]) { + id = dItem[x][y] - 1; + xx = sx - item[id]._iAnimWidth2; + if (id == pcursitem) + CelDecodeClr(ICOL_BLUE, xx, sy, (char *)item[id]._iAnimData, item[id]._iAnimFrame, item[id]._iAnimWidth, 0, dir); + CelDrawHdrOnly(xx, sy, (char *)item[id]._iAnimData, item[id]._iAnimFrame, item[id]._iAnimWidth, 0, dir); + } + if (dFlags[x][y] & DFLAG_MONSTER) { + id = -1 - dMonster[x][y - 1]; // -1 - *(&dword_52D204 + v9); /* check */ + xx = sx - towner[id]._tAnimWidth2; + if (id == pcursmonst) + CelDecodeClr(166, xx, sy, (char *)towner[id]._tAnimData, towner[id]._tAnimFrame, towner[id]._tAnimWidth, 0, dir); + CelDrawHdrOnly(xx, sy, (char *)towner[id]._tAnimData, towner[id]._tAnimFrame, towner[id]._tAnimWidth, 0, dir); + } + if (dMonster[x][y] > 0) { + id = dMonster[x][y] - 1; + xx = sx - towner[id]._tAnimWidth2; + if (id == pcursmonst) + CelDecodeClr(166, xx, sy, (char *)towner[id]._tAnimData, towner[id]._tAnimFrame, towner[id]._tAnimWidth, 0, dir); + CelDrawHdrOnly(xx, sy, (char *)towner[id]._tAnimData, towner[id]._tAnimFrame, towner[id]._tAnimWidth, 0, dir); + } + if (dFlags[x][y] & DFLAG_PLAYER) { + id = -1 - dPlayer[x][y - 1]; // -1 - *((_BYTE *)&themeLoc[49].height + v9 + 3); + yy = sy + plr[id]._pyoff; + xx = sx + plr[id]._pxoff - plr[id]._pAnimWidth2; + if (id == pcursplr) + Cl2DecodeFrm2(165, xx, yy, (char *)plr[id]._pAnimData, plr[id]._pAnimFrame, plr[id]._pAnimWidth, 0, dir); + Cl2DecodeFrm1(xx, yy, (char *)plr[id]._pAnimData, plr[id]._pAnimFrame, plr[id]._pAnimWidth, 0, dir); + if (some_flag && plr[id]._peflag) + town_draw_e_flag((char *)buffer - 64, x - 1, y + 1, a4, dir, sx - 64, sy); + } + if (dFlags[x][y] & DFLAG_DEAD_PLAYER) + DrawDeadPlayer(x, y, sx, sy, 0, dir, 0); + if (dPlayer[x][y] > 0) { + id = dPlayer[x][y] - 1; + yy = sy + plr[id]._pyoff; + xx = sx + plr[id]._pxoff - plr[id]._pAnimWidth2; + if (id == pcursplr) + Cl2DecodeFrm2(165, xx, yy, (char *)plr[id]._pAnimData, plr[id]._pAnimFrame, plr[id]._pAnimWidth, 0, dir); + Cl2DecodeFrm1(xx, yy, (char *)plr[id]._pAnimData, plr[id]._pAnimFrame, plr[id]._pAnimWidth, 0, dir); + if (some_flag && plr[id]._peflag) + town_draw_e_flag((char *)buffer - 64, x - 1, y + 1, a4, dir, sx - 64, sy); + } + if (dFlags[x][y] & DFLAG_MISSILE) + DrawMissile(x, y, sx, sy, 0, dir, 0); } // 4B8CC0: using guessed type char pcursitem; // 4B8CC2: using guessed type char pcursplr; void __fastcall town_draw_upper(int x, int y, int sx, int sy, int a5, int a6, int some_flag) { - signed int v7; // ebx - int v8; // esi - int v9; // eax - bool v10; // zf - int v11; // eax - short *v12; // ebx - int v13; // eax - int v14; // esi - int v15; // edi - int v16; // eax - Screen *v17; // eax - unsigned char *v18; // ebx - char *v19; // edi - int v20; // eax - int v21; // eax - int v22; // eax - int v23; // eax - unsigned char *v24; // edi - char *v25; // ebx - int v26; // eax - int *a1; // [esp+Ch] [ebp-10h] - int *a1a; // [esp+Ch] [ebp-10h] - int dir; // [esp+10h] [ebp-Ch] - int ya; // [esp+14h] [ebp-8h] - signed int xa; // [esp+18h] [ebp-4h] - signed int sxa; // [esp+24h] [ebp+8h] - signed int sxb; // [esp+24h] [ebp+8h] - signed int sxc; // [esp+24h] [ebp+8h] - int a5a; // [esp+2Ch] [ebp+10h] + signed int v7; // ebx + int v8; // esi + int v9; // eax + bool v10; // zf + int v11; // eax + short *v12; // ebx + int v13; // eax + int v14; // esi + int v15; // edi + int v16; // eax + Screen *v17; // eax + unsigned char *v18; // ebx + char *v19; // edi + int v20; // eax + int v21; // eax + int v22; // eax + int v23; // eax + unsigned char *v24; // edi + char *v25; // ebx + int v26; // eax + int *a1; // [esp+Ch] [ebp-10h] + int *a1a; // [esp+Ch] [ebp-10h] + int dir; // [esp+10h] [ebp-Ch] + int ya; // [esp+14h] [ebp-8h] + signed int xa; // [esp+18h] [ebp-4h] + signed int sxa; // [esp+24h] [ebp+8h] + signed int sxb; // [esp+24h] [ebp+8h] + signed int sxc; // [esp+24h] [ebp+8h] + int a5a; // [esp+2Ch] [ebp+10h] - xa = x; - v7 = y; - ya = y; - dir = 2 * a6 + 2; - if ( dir > 8 ) - dir = 8; - if ( some_flag ) - { - if ( y < 0 || y >= 112 || x < 0 || x >= 112 ) - { - v11 = sy; - v8 = sx; - } - else - { - v8 = sx; - v9 = dPiece[0][y + 112 * x]; - level_cel_block = v9; - v10 = v9 == 0; - v11 = sy; - if ( !v10 ) - { - a1 = (int *)&gpBuffer->row_unused_1[0].col_unused_1[sx + 32 + screen_y_times_768[sy]]; - sxa = 0; - v12 = &dpiece_defs_map_1[0][0][16 * gendung_get_dpiece_num_from_coord(x, y) + 1]; - do - { - if ( a6 >= sxa ) - { - v13 = (unsigned short)*v12; - level_cel_block = (unsigned short)*v12; - if ( v13 ) - drawUpperScreen((unsigned char *)a1); - } - a1 -= 6144; - ++sxa; - v12 += 2; - } - while ( sxa < 7 ); - town_draw_town_all((char *)gpBuffer + v8 + screen_y_times_768[sy], xa, ya, a6, dir, v8, sy, 0); - v7 = ya; - goto LABEL_17; - } - } - town_clear_upper_buf((unsigned char *)gpBuffer + screen_y_times_768[v11] + v8); -LABEL_17: - ++xa; - ya = --v7; - v14 = v8 + 64; - goto LABEL_19; - } - v14 = sx; + xa = x; + v7 = y; + ya = y; + dir = 2 * a6 + 2; + if (dir > 8) + dir = 8; + if (some_flag) { + if (y < 0 || y >= 112 || x < 0 || x >= 112) { + v11 = sy; + v8 = sx; + } else { + v8 = sx; + v9 = dPiece[0][y + 112 * x]; + level_cel_block = v9; + v10 = v9 == 0; + v11 = sy; + if (!v10) { + a1 = (int *)&gpBuffer->row_unused_1[0].col_unused_1[sx + 32 + screen_y_times_768[sy]]; + sxa = 0; + v12 = &dpiece_defs_map_1[0][0][16 * gendung_get_dpiece_num_from_coord(x, y) + 1]; + do { + if (a6 >= sxa) { + v13 = (unsigned short)*v12; + level_cel_block = (unsigned short)*v12; + if (v13) + drawUpperScreen((unsigned char *)a1); + } + a1 -= 6144; + ++sxa; + v12 += 2; + } while (sxa < 7); + town_draw_town_all((char *)gpBuffer + v8 + screen_y_times_768[sy], xa, ya, a6, dir, v8, sy, 0); + v7 = ya; + goto LABEL_17; + } + } + town_clear_upper_buf((unsigned char *)gpBuffer + screen_y_times_768[v11] + v8); + LABEL_17: + ++xa; + ya = --v7; + v14 = v8 + 64; + goto LABEL_19; + } + v14 = sx; LABEL_19: - if ( a5 - some_flag > 0 ) - { - a1a = (int *)(a5 - some_flag); - v15 = 112 * xa; - a5a = 112 * xa; - do - { - if ( v7 < 0 || v7 >= 112 || v15 < 0 || v15 >= MAXDUNX * MAXDUNY ) - { - v17 = gpBuffer; - } - else - { - v16 = dPiece[0][v15 + v7]; - level_cel_block = v16; - v10 = v16 == 0; - v17 = gpBuffer; - if ( !v10 ) - { - v18 = (unsigned char *)gpBuffer + v14 + screen_y_times_768[sy]; - v19 = (char *)dpiece_defs_map_1 + 32 * gendung_get_dpiece_num_from_coord(xa, ya); - sxb = 0; - do - { - if ( a6 >= sxb ) - { - v20 = *(unsigned short *)&v19[4 * sxb]; - level_cel_block = *(unsigned short *)&v19[4 * sxb]; - if ( v20 ) - drawUpperScreen(v18); - v21 = *(unsigned short *)&v19[4 * sxb + 2]; - level_cel_block = *(unsigned short *)&v19[4 * sxb + 2]; - if ( v21 ) - drawUpperScreen(v18 + 32); - } - v18 -= 768 * 32; - ++sxb; - } - while ( sxb < 7 ); - town_draw_town_all((char *)gpBuffer + v14 + screen_y_times_768[sy], xa, ya, a6, dir, v14, sy, 1); - v15 = a5a; - v7 = ya; - goto LABEL_36; - } - } - town_clear_upper_buf((unsigned char *)v17 + v14 + screen_y_times_768[sy]); -LABEL_36: - ++xa; - v15 += 112; - --v7; - v14 += 64; - v10 = a1a == (int *)1; - a1a = (int *)((char *)a1a - 1); - a5a = v15; - ya = v7; - } - while ( !v10 ); - } - if ( some_flag ) - { - if ( v7 < 0 || v7 >= 112 || xa < 0 || xa >= 112 ) - { - v23 = sy; - } - else - { - v22 = dPiece[0][v7 + 112 * xa]; - level_cel_block = v22; - v10 = v22 == 0; - v23 = sy; - if ( !v10 ) - { - v24 = (unsigned char *)gpBuffer + v14 + screen_y_times_768[sy]; - v25 = (char *)dpiece_defs_map_1 + 32 * gendung_get_dpiece_num_from_coord(xa, v7); - sxc = 0; - do - { - if ( a6 >= sxc ) - { - v26 = *(unsigned short *)&v25[4 * sxc]; - level_cel_block = *(unsigned short *)&v25[4 * sxc]; - if ( v26 ) - drawUpperScreen(v24); - } - v24 -= 768 * 32; - ++sxc; - } - while ( sxc < 7 ); - town_draw_town_all((char *)gpBuffer + v14 + screen_y_times_768[sy], xa, ya, a6, dir, v14, sy, 0); - return; - } - } - town_clear_upper_buf((unsigned char *)gpBuffer + screen_y_times_768[v23] + v14); - } + if (a5 - some_flag > 0) { + a1a = (int *)(a5 - some_flag); + v15 = 112 * xa; + a5a = 112 * xa; + do { + if (v7 < 0 || v7 >= 112 || v15 < 0 || v15 >= MAXDUNX * MAXDUNY) { + v17 = gpBuffer; + } else { + v16 = dPiece[0][v15 + v7]; + level_cel_block = v16; + v10 = v16 == 0; + v17 = gpBuffer; + if (!v10) { + v18 = (unsigned char *)gpBuffer + v14 + screen_y_times_768[sy]; + v19 = (char *)dpiece_defs_map_1 + 32 * gendung_get_dpiece_num_from_coord(xa, ya); + sxb = 0; + do { + if (a6 >= sxb) { + v20 = *(unsigned short *)&v19[4 * sxb]; + level_cel_block = *(unsigned short *)&v19[4 * sxb]; + if (v20) + drawUpperScreen(v18); + v21 = *(unsigned short *)&v19[4 * sxb + 2]; + level_cel_block = *(unsigned short *)&v19[4 * sxb + 2]; + if (v21) + drawUpperScreen(v18 + 32); + } + v18 -= 768 * 32; + ++sxb; + } while (sxb < 7); + town_draw_town_all((char *)gpBuffer + v14 + screen_y_times_768[sy], xa, ya, a6, dir, v14, sy, 1); + v15 = a5a; + v7 = ya; + goto LABEL_36; + } + } + town_clear_upper_buf((unsigned char *)v17 + v14 + screen_y_times_768[sy]); + LABEL_36: + ++xa; + v15 += 112; + --v7; + v14 += 64; + v10 = a1a == (int *)1; + a1a = (int *)((char *)a1a - 1); + a5a = v15; + ya = v7; + } while (!v10); + } + if (some_flag) { + if (v7 < 0 || v7 >= 112 || xa < 0 || xa >= 112) { + v23 = sy; + } else { + v22 = dPiece[0][v7 + 112 * xa]; + level_cel_block = v22; + v10 = v22 == 0; + v23 = sy; + if (!v10) { + v24 = (unsigned char *)gpBuffer + v14 + screen_y_times_768[sy]; + v25 = (char *)dpiece_defs_map_1 + 32 * gendung_get_dpiece_num_from_coord(xa, v7); + sxc = 0; + do { + if (a6 >= sxc) { + v26 = *(unsigned short *)&v25[4 * sxc]; + level_cel_block = *(unsigned short *)&v25[4 * sxc]; + if (v26) + drawUpperScreen(v24); + } + v24 -= 768 * 32; + ++sxc; + } while (sxc < 7); + town_draw_town_all((char *)gpBuffer + v14 + screen_y_times_768[sy], xa, ya, a6, dir, v14, sy, 0); + return; + } + } + town_clear_upper_buf((unsigned char *)gpBuffer + screen_y_times_768[v23] + v14); + } } // 69CF14: using guessed type int level_cel_block; void __fastcall T_DrawGame(int x, int y) { - int v2; // esi - int v3; // edi - int v4; // ebx - int v5; // ebx - int v6; // esi - int v7; // ebx - int v8; // esi - int v9; // ebx - int v10; // esi - signed int v11; // [esp+Ch] [ebp-10h] - signed int a6; // [esp+10h] [ebp-Ch] - signed int a6a; // [esp+10h] [ebp-Ch] - signed int a5; // [esp+14h] [ebp-8h] - int ya; // [esp+18h] [ebp-4h] + int v2; // esi + int v3; // edi + int v4; // ebx + int v5; // ebx + int v6; // esi + int v7; // ebx + int v8; // esi + int v9; // ebx + int v10; // esi + signed int v11; // [esp+Ch] [ebp-10h] + signed int a6; // [esp+10h] [ebp-Ch] + signed int a6a; // [esp+10h] [ebp-Ch] + signed int a5; // [esp+14h] [ebp-8h] + int ya; // [esp+18h] [ebp-4h] - v2 = ScrollInfo._sxoff + 64; - v3 = x - 10; - ya = y - 1; - v4 = ScrollInfo._syoff + 175; - dword_5C2FF8 = 10; - a5 = 10; - scr_pix_width = 640; - scr_pix_height = 352; - dword_5C2FFC = 11; - v11 = 5; - if ( chrflag || questlog ) - { - ya = y - 3; - v3 += 2; - v2 = ScrollInfo._sxoff + 352; - a5 = 6; - } - if ( invflag || sbookflag ) - { - ya -= 2; - v3 += 2; - v2 -= 32; - a5 = 6; - } - switch ( ScrollInfo._sdir ) - { - case DIR_SW: - v4 = ScrollInfo._syoff + 143; - --v3; - --ya; - goto LABEL_15; - case DIR_W: - v4 = ScrollInfo._syoff + 143; - --v3; - --ya; - goto LABEL_14; - case DIR_NW: - goto LABEL_12; - case DIR_N: - goto LABEL_14; - case DIR_NE: - goto LABEL_15; - case DIR_E: - v2 -= 64; - --v3; - ++ya; - goto LABEL_14; - case DIR_SE: - v2 -= 64; - --v3; - ++ya; -LABEL_12: - ++a5; - break; - case DIR_OMNI: - v2 -= 64; - v4 = ScrollInfo._syoff + 143; - v3 -= 2; -LABEL_14: - ++a5; -LABEL_15: - v11 = 6; - break; - default: - break; - } - a6 = 0; - gpBufEnd = (unsigned char *)gpBuffer + screen_y_times_768[160]; - do - { - town_draw_upper(v3, ya++, v2, v4, a5, a6, 0); - v5 = v4 + 16; - v6 = v2 - 32; - town_draw_upper(v3++, ya, v6, v5, a5, a6, 1); - v2 = v6 + 32; - v4 = v5 + 16; - ++a6; - } - while ( a6 < 7 ); - gpBufEnd = (unsigned char *)gpBuffer + screen_y_times_768[512]; - if ( v11 > 0 ) - { - do - { - town_draw_lower(v3, ya++, v2, v4, a5, 0); - v7 = v4 + 16; - v8 = v2 - 32; - town_draw_lower(v3++, ya, v8, v7, a5, 1); - v2 = v8 + 32; - v4 = v7 + 16; - --v11; - } - while ( v11 ); - } - a6a = 0; - do - { - town_draw_lower_2(v3, ya++, v2, v4, a5, a6a, 0); - v9 = v4 + 16; - v10 = v2 - 32; - town_draw_lower_2(v3++, ya, v10, v9, a5, a6a, 1); - v2 = v10 + 32; - v4 = v9 + 16; - ++a6a; - } - while ( a6a < 7 ); + v2 = ScrollInfo._sxoff + 64; + v3 = x - 10; + ya = y - 1; + v4 = ScrollInfo._syoff + 175; + dword_5C2FF8 = 10; + a5 = 10; + scr_pix_width = 640; + scr_pix_height = 352; + dword_5C2FFC = 11; + v11 = 5; + if (chrflag || questlog) { + ya = y - 3; + v3 += 2; + v2 = ScrollInfo._sxoff + 352; + a5 = 6; + } + if (invflag || sbookflag) { + ya -= 2; + v3 += 2; + v2 -= 32; + a5 = 6; + } + switch (ScrollInfo._sdir) { + case DIR_SW: + v4 = ScrollInfo._syoff + 143; + --v3; + --ya; + goto LABEL_15; + case DIR_W: + v4 = ScrollInfo._syoff + 143; + --v3; + --ya; + goto LABEL_14; + case DIR_NW: + goto LABEL_12; + case DIR_N: + goto LABEL_14; + case DIR_NE: + goto LABEL_15; + case DIR_E: + v2 -= 64; + --v3; + ++ya; + goto LABEL_14; + case DIR_SE: + v2 -= 64; + --v3; + ++ya; + LABEL_12: + ++a5; + break; + case DIR_OMNI: + v2 -= 64; + v4 = ScrollInfo._syoff + 143; + v3 -= 2; + LABEL_14: + ++a5; + LABEL_15: + v11 = 6; + break; + default: + break; + } + a6 = 0; + gpBufEnd = (unsigned char *)gpBuffer + screen_y_times_768[160]; + do { + town_draw_upper(v3, ya++, v2, v4, a5, a6, 0); + v5 = v4 + 16; + v6 = v2 - 32; + town_draw_upper(v3++, ya, v6, v5, a5, a6, 1); + v2 = v6 + 32; + v4 = v5 + 16; + ++a6; + } while (a6 < 7); + gpBufEnd = (unsigned char *)gpBuffer + screen_y_times_768[512]; + if (v11 > 0) { + do { + town_draw_lower(v3, ya++, v2, v4, a5, 0); + v7 = v4 + 16; + v8 = v2 - 32; + town_draw_lower(v3++, ya, v8, v7, a5, 1); + v2 = v8 + 32; + v4 = v7 + 16; + --v11; + } while (v11); + } + a6a = 0; + do { + town_draw_lower_2(v3, ya++, v2, v4, a5, a6a, 0); + v9 = v4 + 16; + v10 = v2 - 32; + town_draw_lower_2(v3++, ya, v10, v9, a5, a6a, 1); + v2 = v10 + 32; + v4 = v9 + 16; + ++a6a; + } while (a6a < 7); } // 4B8968: using guessed type int sbookflag; // 5C2FF8: using guessed type int dword_5C2FF8; @@ -1125,165 +1007,151 @@ LABEL_15: void __fastcall T_DrawZoom(int x, int y) { - int v2; // edi - int v3; // ebx - int v4; // esi - int v5; // esi - int v6; // edi - int v7; // esi - int v8; // edi - int v9; // esi - int v10; // edi - _WORD *v11; // edi - char *v12; // esi - char *v13; // ebx - signed int v14; // edx - signed int v15; // ecx - short v16; // ax - int v17; // eax - signed int v18; // [esp+Ch] [ebp-10h] - signed int v19; // [esp+Ch] [ebp-10h] - signed int a6; // [esp+10h] [ebp-Ch] - signed int a6a; // [esp+10h] [ebp-Ch] - int a6b; // [esp+10h] [ebp-Ch] - signed int a5; // [esp+14h] [ebp-8h] - int a5a; // [esp+14h] [ebp-8h] - int ya; // [esp+18h] [ebp-4h] + int v2; // edi + int v3; // ebx + int v4; // esi + int v5; // esi + int v6; // edi + int v7; // esi + int v8; // edi + int v9; // esi + int v10; // edi + _WORD *v11; // edi + char *v12; // esi + char *v13; // ebx + signed int v14; // edx + signed int v15; // ecx + short v16; // ax + int v17; // eax + signed int v18; // [esp+Ch] [ebp-10h] + signed int v19; // [esp+Ch] [ebp-10h] + signed int a6; // [esp+10h] [ebp-Ch] + signed int a6a; // [esp+10h] [ebp-Ch] + int a6b; // [esp+10h] [ebp-Ch] + signed int a5; // [esp+14h] [ebp-8h] + int a5a; // [esp+14h] [ebp-8h] + int ya; // [esp+18h] [ebp-4h] - v18 = 0; - v2 = ScrollInfo._sxoff + 64; - dword_5C2FF8 = 6; - dword_5C2FFC = 6; - v3 = x - 6; - a5 = 6; - v4 = ScrollInfo._syoff + 143; - ya = y - 1; - scr_pix_width = 384; - scr_pix_height = 192; - switch ( ScrollInfo._sdir ) - { - case DIR_SW: - v4 = ScrollInfo._syoff + 111; - v3 = x - 7; - ya = y - 2; - goto LABEL_9; - case DIR_W: - v4 = ScrollInfo._syoff + 111; - v3 = x - 7; - ya = y - 2; - goto LABEL_8; - case DIR_NW: - goto LABEL_6; - case DIR_N: - goto LABEL_8; - case DIR_NE: - goto LABEL_9; - case DIR_E: - v2 = ScrollInfo._sxoff; - v3 = x - 7; - ya = y; - goto LABEL_8; - case DIR_SE: - v2 = ScrollInfo._sxoff; - v3 = x - 7; - ya = y; -LABEL_6: - a5 = 7; - break; - case DIR_OMNI: - v2 = ScrollInfo._sxoff; - v4 = ScrollInfo._syoff + 111; - v3 = x - 8; -LABEL_8: - a5 = 7; -LABEL_9: - v18 = 1; - break; - default: - break; - } - a6 = 0; - gpBufEnd = (unsigned char *)gpBuffer + screen_y_times_768[143]; - do - { - town_draw_upper(v3, ya++, v2, v4, a5, a6, 0); - v5 = v4 + 16; - v6 = v2 - 32; - town_draw_upper(v3++, ya, v6, v5, a5, a6, 1); - v2 = v6 + 32; - v4 = v5 + 16; - ++a6; - } - while ( a6 < 7 ); - gpBufEnd = (unsigned char *)gpBuffer + screen_y_times_768[320]; - if ( v18 > 0 ) - { - do - { - town_draw_lower(v3, ya++, v2, v4, a5, 0); - v7 = v4 + 16; - v8 = v2 - 32; - town_draw_lower(v3++, ya, v8, v7, a5, 1); - v2 = v8 + 32; - v4 = v7 + 16; - --v18; - } - while ( v18 ); - } - a6a = 0; - do - { - town_draw_lower_2(v3, ya++, v2, v4, a5, a6a, 0); - v9 = v4 + 16; - v10 = v2 - 32; - town_draw_lower_2(v3++, ya, v10, v9, a5, a6a, 1); - v2 = v10 + 32; - v4 = v9 + 16; - ++a6a; - } - while ( a6a < 7 ); - if ( chrflag || questlog ) - { - a5a = 392064; - goto LABEL_23; - } - if ( invflag || sbookflag ) - { - a5a = 391744; -LABEL_23: - a6b = 245168; - v19 = 160; - goto LABEL_24; - } - a6b = 245088; - a5a = 391744; - v19 = 320; + v18 = 0; + v2 = ScrollInfo._sxoff + 64; + dword_5C2FF8 = 6; + dword_5C2FFC = 6; + v3 = x - 6; + a5 = 6; + v4 = ScrollInfo._syoff + 143; + ya = y - 1; + scr_pix_width = 384; + scr_pix_height = 192; + switch (ScrollInfo._sdir) { + case DIR_SW: + v4 = ScrollInfo._syoff + 111; + v3 = x - 7; + ya = y - 2; + goto LABEL_9; + case DIR_W: + v4 = ScrollInfo._syoff + 111; + v3 = x - 7; + ya = y - 2; + goto LABEL_8; + case DIR_NW: + goto LABEL_6; + case DIR_N: + goto LABEL_8; + case DIR_NE: + goto LABEL_9; + case DIR_E: + v2 = ScrollInfo._sxoff; + v3 = x - 7; + ya = y; + goto LABEL_8; + case DIR_SE: + v2 = ScrollInfo._sxoff; + v3 = x - 7; + ya = y; + LABEL_6: + a5 = 7; + break; + case DIR_OMNI: + v2 = ScrollInfo._sxoff; + v4 = ScrollInfo._syoff + 111; + v3 = x - 8; + LABEL_8: + a5 = 7; + LABEL_9: + v18 = 1; + break; + default: + break; + } + a6 = 0; + gpBufEnd = (unsigned char *)gpBuffer + screen_y_times_768[143]; + do { + town_draw_upper(v3, ya++, v2, v4, a5, a6, 0); + v5 = v4 + 16; + v6 = v2 - 32; + town_draw_upper(v3++, ya, v6, v5, a5, a6, 1); + v2 = v6 + 32; + v4 = v5 + 16; + ++a6; + } while (a6 < 7); + gpBufEnd = (unsigned char *)gpBuffer + screen_y_times_768[320]; + if (v18 > 0) { + do { + town_draw_lower(v3, ya++, v2, v4, a5, 0); + v7 = v4 + 16; + v8 = v2 - 32; + town_draw_lower(v3++, ya, v8, v7, a5, 1); + v2 = v8 + 32; + v4 = v7 + 16; + --v18; + } while (v18); + } + a6a = 0; + do { + town_draw_lower_2(v3, ya++, v2, v4, a5, a6a, 0); + v9 = v4 + 16; + v10 = v2 - 32; + town_draw_lower_2(v3++, ya, v10, v9, a5, a6a, 1); + v2 = v10 + 32; + v4 = v9 + 16; + ++a6a; + } while (a6a < 7); + if (chrflag || questlog) { + a5a = 392064; + goto LABEL_23; + } + if (invflag || sbookflag) { + a5a = 391744; + LABEL_23: + a6b = 245168; + v19 = 160; + goto LABEL_24; + } + a6b = 245088; + a5a = 391744; + v19 = 320; LABEL_24: - v11 = (_WORD *)((char *)gpBuffer + a5a); - v12 = (char *)gpBuffer + a6b; - v13 = &gpBuffer->row_unused_1[1].col_unused_1[a5a]; - v14 = 176; - do - { - v15 = v19; - do - { - _LOBYTE(v16) = *v12++; - _HIBYTE(v16) = v16; - *v11 = v16; - *(_WORD *)v13 = v16; - ++v11; - v13 += 2; - --v15; - } - while ( v15 ); - v12 += -v19 - 768; - v17 = 2 * (v19 + 768); - v13 -= v17; - v11 = (_WORD *)((char *)v11 - v17); - --v14; - } - while ( v14 ); + v11 = (_WORD *)((char *)gpBuffer + a5a); + v12 = (char *)gpBuffer + a6b; + v13 = &gpBuffer->row_unused_1[1].col_unused_1[a5a]; + v14 = 176; + do { + v15 = v19; + do { + _LOBYTE(v16) = *v12++; + _HIBYTE(v16) = v16; + *v11 = v16; + *(_WORD *)v13 = v16; + ++v11; + v13 += 2; + --v15; + } while (v15); + v12 += -v19 - 768; + v17 = 2 * (v19 + 768); + v13 -= v17; + v11 = (_WORD *)((char *)v11 - v17); + --v14; + } while (v14); } // 4B8968: using guessed type int sbookflag; // 5C2FF8: using guessed type int dword_5C2FF8; @@ -1295,57 +1163,49 @@ LABEL_24: void __fastcall T_DrawView(int StartX, int StartY) { - light_table_index = 0; - cel_transparency_active = 0; - if ( zoomflag ) - T_DrawGame(StartX, StartY); - else - T_DrawZoom(StartX, StartY); - if ( automapflag ) - DrawAutomap(); - if ( stextflag && !qtextflag ) - DrawSText(); - if ( invflag ) - { - DrawInv(); - } - else if ( sbookflag ) - { - DrawSpellBook(); - } - DrawDurIcon(); - if ( chrflag ) - { - DrawChr(); - } - else if ( questlog ) - { - DrawQuestLog(); - } - else if ( plr[myplr]._pStatPts && !spselflag ) - { - DrawLevelUpIcon(); - } - if ( uitemflag ) - DrawUniqueInfo(); - if ( qtextflag ) - DrawQText(); - if ( spselflag ) - DrawSpellList(); - if ( dropGoldFlag ) - DrawGoldSplit(dropGoldValue); - if ( helpflag ) - DrawHelp(); - if ( msgflag ) - DrawDiabloMsg(); - if ( PauseMode && !deathflag ) - gmenu_draw_pause(); - DrawPlrMsg(); - gmenu_draw(); - doom_draw(); - DrawInfoBox(); - DrawLifeFlask(); - DrawManaFlask(); + light_table_index = 0; + cel_transparency_active = 0; + if (zoomflag) + T_DrawGame(StartX, StartY); + else + T_DrawZoom(StartX, StartY); + if (automapflag) + DrawAutomap(); + if (stextflag && !qtextflag) + DrawSText(); + if (invflag) { + DrawInv(); + } else if (sbookflag) { + DrawSpellBook(); + } + DrawDurIcon(); + if (chrflag) { + DrawChr(); + } else if (questlog) { + DrawQuestLog(); + } else if (plr[myplr]._pStatPts && !spselflag) { + DrawLevelUpIcon(); + } + if (uitemflag) + DrawUniqueInfo(); + if (qtextflag) + DrawQText(); + if (spselflag) + DrawSpellList(); + if (dropGoldFlag) + DrawGoldSplit(dropGoldValue); + if (helpflag) + DrawHelp(); + if (msgflag) + DrawDiabloMsg(); + if (PauseMode && !deathflag) + gmenu_draw_pause(); + DrawPlrMsg(); + gmenu_draw(); + doom_draw(); + DrawInfoBox(); + DrawLifeFlask(); + DrawManaFlask(); } // 4B84DC: using guessed type int dropGoldFlag; // 4B8968: using guessed type int sbookflag; @@ -1361,62 +1221,50 @@ void __fastcall T_DrawView(int StartX, int StartY) void __cdecl town_init_dpiece_defs_map() { - int (*v0)[112]; // ebx - int v1; // ebp - int v2; // esi - char *v3; // edi - char *v4; // ecx - signed int v5; // eax - int (*v6)[112]; // [esp+10h] [ebp-8h] - int y; // [esp+14h] [ebp-4h] + int(*v0)[112]; // ebx + int v1; // ebp + int v2; // esi + char *v3; // edi + char *v4; // ecx + signed int v5; // eax + int(*v6)[112]; // [esp+10h] [ebp-8h] + int y; // [esp+14h] [ebp-4h] - y = 0; - v6 = dPiece; - do - { - v0 = v6; - v1 = 0; - do - { - v2 = (*v0)[0]; - v3 = (char *)dpiece_defs_map_1 + 32 * gendung_get_dpiece_num_from_coord(v1, y); - if ( v2 ) - { - v4 = (char *)pLevelPieces + 32 * v2 - 32; - v5 = 0; - do - { - *(_WORD *)&v3[2 * v5] = *(_WORD *)&v4[2 * ((v5 & 1) - (v5 & 0xE)) + 28]; - ++v5; - } - while ( v5 < 16 ); - } - else - { - memset(v3, 0, 0x20u); - } - ++v1; - ++v0; - } - while ( v1 < 112 ); - v6 = (int (*)[112])((char *)v6 + 4); - ++y; - } - while ( (signed int)v6 < (signed int)dPiece[1] ); - if ( zoomflag ) - { - scr_pix_width = 640; - scr_pix_height = 352; - dword_5C2FF8 = 10; - dword_5C2FFC = 11; - } - else - { - scr_pix_width = 384; - scr_pix_height = 224; - dword_5C2FF8 = 6; - dword_5C2FFC = 7; - } + y = 0; + v6 = dPiece; + do { + v0 = v6; + v1 = 0; + do { + v2 = (*v0)[0]; + v3 = (char *)dpiece_defs_map_1 + 32 * gendung_get_dpiece_num_from_coord(v1, y); + if (v2) { + v4 = (char *)pLevelPieces + 32 * v2 - 32; + v5 = 0; + do { + *(_WORD *)&v3[2 * v5] = *(_WORD *)&v4[2 * ((v5 & 1) - (v5 & 0xE)) + 28]; + ++v5; + } while (v5 < 16); + } else { + memset(v3, 0, 0x20u); + } + ++v1; + ++v0; + } while (v1 < 112); + v6 = (int(*)[112])((char *)v6 + 4); + ++y; + } while ((signed int)v6 < (signed int)dPiece[1]); + if (zoomflag) { + scr_pix_width = 640; + scr_pix_height = 352; + dword_5C2FF8 = 10; + dword_5C2FFC = 11; + } else { + scr_pix_width = 384; + scr_pix_height = 224; + dword_5C2FF8 = 6; + dword_5C2FFC = 7; + } } // 52569C: using guessed type int zoomflag; // 5C2FF8: using guessed type int dword_5C2FF8; @@ -1426,297 +1274,261 @@ void __cdecl town_init_dpiece_defs_map() void __fastcall T_FillSector(unsigned char *P3Tiles, unsigned char *pSector, int xi, int yi, int w, int h) /* check 7 params: int AddSec */ { - int v7; // ebx - int v8; // edx - int v9; // edi - int *v10; // ecx - int v11; // eax - unsigned char *v12; // esi - unsigned short v13; // ax - int v14; // eax - int v15; // [esp+4h] [ebp-14h] - int v16; // [esp+8h] [ebp-10h] - unsigned char *v17; // [esp+Ch] [ebp-Ch] - unsigned char *v18; // [esp+10h] [ebp-8h] - signed int v19; // [esp+14h] [ebp-4h] - int a4; // [esp+24h] [ebp+Ch] - int a6; // [esp+2Ch] [ebp+14h] + int v7; // ebx + int v8; // edx + int v9; // edi + int *v10; // ecx + int v11; // eax + unsigned char *v12; // esi + unsigned short v13; // ax + int v14; // eax + int v15; // [esp+4h] [ebp-14h] + int v16; // [esp+8h] [ebp-10h] + unsigned char *v17; // [esp+Ch] [ebp-Ch] + unsigned char *v18; // [esp+10h] [ebp-8h] + signed int v19; // [esp+14h] [ebp-4h] + int a4; // [esp+24h] [ebp+Ch] + int a6; // [esp+2Ch] [ebp+14h] - v7 = h; - v17 = pSector; - v8 = yi; - v18 = P3Tiles; - v19 = 4; - if ( h > 0 ) - { - do - { - v9 = w; - if ( w > 0 ) - { - v10 = &dPiece[1][v8 + 112 * xi]; - do - { - v11 = *(unsigned short *)&v17[v19]; - if ( (_WORD)v11 ) - { - v12 = &v18[8 * (v11 - 1)]; - v13 = *(_WORD *)v12; - v12 += 2; - v14 = v13 + 1; - a4 = v14; - _LOWORD(v14) = *(_WORD *)v12; - v12 += 2; - a6 = ++v14; - _LOWORD(v14) = *(_WORD *)v12; - v16 = ++v14; - _LOWORD(v14) = *((_WORD *)v12 + 1); - v15 = v14 + 1; - } - else - { - a4 = 0; - a6 = 0; - v16 = 0; - v15 = 0; - } - v19 += 2; - *(v10 - 112) = a4; - *v10 = a6; - *(v10 - 111) = v16; - v10[1] = v15; - v10 += 224; - --v9; - } - while ( v9 ); - } - v8 += 2; - --v7; - } - while ( v7 ); - } + v7 = h; + v17 = pSector; + v8 = yi; + v18 = P3Tiles; + v19 = 4; + if (h > 0) { + do { + v9 = w; + if (w > 0) { + v10 = &dPiece[1][v8 + 112 * xi]; + do { + v11 = *(unsigned short *)&v17[v19]; + if ((_WORD)v11) { + v12 = &v18[8 * (v11 - 1)]; + v13 = *(_WORD *)v12; + v12 += 2; + v14 = v13 + 1; + a4 = v14; + _LOWORD(v14) = *(_WORD *)v12; + v12 += 2; + a6 = ++v14; + _LOWORD(v14) = *(_WORD *)v12; + v16 = ++v14; + _LOWORD(v14) = *((_WORD *)v12 + 1); + v15 = v14 + 1; + } else { + a4 = 0; + a6 = 0; + v16 = 0; + v15 = 0; + } + v19 += 2; + *(v10 - 112) = a4; + *v10 = a6; + *(v10 - 111) = v16; + v10[1] = v15; + v10 += 224; + --v9; + } while (v9); + } + v8 += 2; + --v7; + } while (v7); + } } void __fastcall T_FillTile(unsigned char *P3Tiles, int xx, int yy, int t) { - unsigned char *v4; // esi - unsigned short v5; // ax - int v6; // eax - int v7; // ST10_4 - int v8; // ST0C_4 - int v9; // ST08_4 + unsigned char *v4; // esi + unsigned short v5; // ax + int v6; // eax + int v7; // ST10_4 + int v8; // ST0C_4 + int v9; // ST08_4 - v4 = &P3Tiles[8 * (t - 1)]; - v5 = *(_WORD *)v4; - v4 += 2; - v6 = v5 + 1; - v7 = v6; - _LOWORD(v6) = *(_WORD *)v4; - v4 += 2; - v8 = ++v6; - _LOWORD(v6) = *(_WORD *)v4; - v9 = ++v6; - _LOWORD(v6) = *((_WORD *)v4 + 1); - dPiece[xx][yy] = v7; - dPiece[xx + 1][yy] = v8; - dPiece[xx][yy + 1] = v9; - dPiece[xx + 1][yy + 1] = v6 + 1; + v4 = &P3Tiles[8 * (t - 1)]; + v5 = *(_WORD *)v4; + v4 += 2; + v6 = v5 + 1; + v7 = v6; + _LOWORD(v6) = *(_WORD *)v4; + v4 += 2; + v8 = ++v6; + _LOWORD(v6) = *(_WORD *)v4; + v9 = ++v6; + _LOWORD(v6) = *((_WORD *)v4 + 1); + dPiece[xx][yy] = v7; + dPiece[xx + 1][yy] = v8; + dPiece[xx][yy + 1] = v9; + dPiece[xx + 1][yy + 1] = v6 + 1; } void __cdecl T_Pass3() { - int *v1; // esi - int *v2; // eax - signed int v3; // ecx - unsigned char *P3Tiles; // esi - unsigned char *pSector; // edi - int xx; // edi + int *v1; // esi + int *v2; // eax + signed int v3; // ecx + unsigned char *P3Tiles; // esi + unsigned char *pSector; // edi + int xx; // edi - v1 = dPiece[1]; - do - { - v2 = v1; - v3 = 56; - do - { - *(v2 - 112) = 0; - *v2 = 0; - *(v2 - 111) = 0; - v2[1] = 0; - v2 += 224; - --v3; - } - while ( v3 ); - v1 += 2; - } - while ( (signed int)v1 < (signed int)dPiece[2] ); - P3Tiles = LoadFileInMem("Levels\\TownData\\Town.TIL", 0); - pSector = LoadFileInMem("Levels\\TownData\\Sector1s.DUN", 0); - T_FillSector(P3Tiles, pSector, 46, 46, 25, 25); - mem_free_dbg(pSector); - pSector = LoadFileInMem("Levels\\TownData\\Sector2s.DUN", 0); - T_FillSector(P3Tiles, pSector, 46, 0, 25, 23); - mem_free_dbg(pSector); - pSector = LoadFileInMem("Levels\\TownData\\Sector3s.DUN", 0); - T_FillSector(P3Tiles, pSector, 0, 46, 23, 25); - mem_free_dbg(pSector); - pSector = LoadFileInMem("Levels\\TownData\\Sector4s.DUN", 0); - T_FillSector(P3Tiles, pSector, 0, 0, 23, 23); - mem_free_dbg(pSector); - if ( gbMaxPlayers == 1 ) - { - if ( !(plr[myplr].pTownWarps & 1) ) - { - T_FillTile(P3Tiles, 48, 20, 320); - } - if ( !(plr[myplr].pTownWarps & 2) ) - { - T_FillTile(P3Tiles, 16, 68, 332); - T_FillTile(P3Tiles, 16, 70, 331); - } - if ( !(plr[myplr].pTownWarps & 4) ) - { - xx = 36; - do - { - T_FillTile(P3Tiles, xx++, 78, random(0, 4) + 1); - } - while ( xx < 46 ); - } - } - if ( quests[QTYPE_PW]._qactive != 3 && quests[QTYPE_PW]._qactive ) - T_FillTile(P3Tiles, 60, 70, 342); - else - T_FillTile(P3Tiles, 60, 70, 71); - mem_free_dbg(P3Tiles); + v1 = dPiece[1]; + do { + v2 = v1; + v3 = 56; + do { + *(v2 - 112) = 0; + *v2 = 0; + *(v2 - 111) = 0; + v2[1] = 0; + v2 += 224; + --v3; + } while (v3); + v1 += 2; + } while ((signed int)v1 < (signed int)dPiece[2]); + P3Tiles = LoadFileInMem("Levels\\TownData\\Town.TIL", 0); + pSector = LoadFileInMem("Levels\\TownData\\Sector1s.DUN", 0); + T_FillSector(P3Tiles, pSector, 46, 46, 25, 25); + mem_free_dbg(pSector); + pSector = LoadFileInMem("Levels\\TownData\\Sector2s.DUN", 0); + T_FillSector(P3Tiles, pSector, 46, 0, 25, 23); + mem_free_dbg(pSector); + pSector = LoadFileInMem("Levels\\TownData\\Sector3s.DUN", 0); + T_FillSector(P3Tiles, pSector, 0, 46, 23, 25); + mem_free_dbg(pSector); + pSector = LoadFileInMem("Levels\\TownData\\Sector4s.DUN", 0); + T_FillSector(P3Tiles, pSector, 0, 0, 23, 23); + mem_free_dbg(pSector); + if (gbMaxPlayers == 1) { + if (!(plr[myplr].pTownWarps & 1)) { + T_FillTile(P3Tiles, 48, 20, 320); + } + if (!(plr[myplr].pTownWarps & 2)) { + T_FillTile(P3Tiles, 16, 68, 332); + T_FillTile(P3Tiles, 16, 70, 331); + } + if (!(plr[myplr].pTownWarps & 4)) { + xx = 36; + do { + T_FillTile(P3Tiles, xx++, 78, random(0, 4) + 1); + } while (xx < 46); + } + } + if (quests[QTYPE_PW]._qactive != 3 && quests[QTYPE_PW]._qactive) + T_FillTile(P3Tiles, 60, 70, 342); + else + T_FillTile(P3Tiles, 60, 70, 71); + mem_free_dbg(P3Tiles); } // 45FDE6: could not find valid save-restore pair for edi // 679660: using guessed type char gbMaxPlayers; void __fastcall CreateTown(int entry) { - int v1; // edi - int (*v2)[112]; // esi - _BYTE *v3; // eax - int (*v4)[112]; // edx - signed int v5; // ebp - int v6; // ecx + int v1; // edi + int(*v2)[112]; // esi + _BYTE *v3; // eax + int(*v4)[112]; // edx + signed int v5; // ebp + int v6; // ecx - v1 = 0; - dminx = 10; - dminy = 10; - dmaxx = 84; - dmaxy = 84; - if ( entry ) - { - if ( entry == 1 ) - { - ViewX = 25; - ViewY = 31; - } - else if ( entry == 7 ) - { - if ( TWarpFrom == 5 ) - { - ViewX = 49; - ViewY = 22; - } - if ( TWarpFrom == 9 ) - { - ViewX = 18; - ViewY = 69; - } - if ( TWarpFrom == 13 ) - { - ViewX = 41; - ViewY = 81; - } - } - } - else - { - ViewX = 75; - ViewY = 68; - } - T_Pass3(); - memset(dTransVal, 0, sizeof(dTransVal)); - memset(dFlags, 0, sizeof(dFlags)); - memset(dPlayer, 0, sizeof(dPlayer)); - memset(dMonster, 0, sizeof(dMonster)); - memset(dObject, 0, sizeof(dObject)); - memset(dItem, 0, sizeof(dItem)); - memset(dArch, 0, sizeof(dArch)); - v2 = dPiece; - do - { - v3 = (unsigned char *)dArch + v1; - v4 = v2; - v5 = 112; - do - { - v6 = (*v4)[0]; - if ( (*v4)[0] == 360 ) - { - *v3 = 1; - } - else - { - switch ( v6 ) - { - case 358: - *v3 = 2; - break; - case 129: - *v3 = 6; - break; - case 130: - *v3 = 7; - break; - case 128: - *v3 = 8; - break; - case 117: - *v3 = 9; - break; - case 157: - *v3 = 10; - break; - case 158: - *v3 = 11; - break; - case 156: - *v3 = 12; - break; - case 162: - *v3 = 13; - break; - case 160: - *v3 = 14; - break; - case 214: - *v3 = 15; - break; - case 212: - *v3 = 16; - break; - case 217: - *v3 = 17; - break; - case 216: - *v3 = 18; - break; - } - } - ++v4; - v3 += 112; - --v5; - } - while ( v5 ); - v2 = (int (*)[112])((char *)v2 + 4); - ++v1; - } - while ( (signed int)v2 < (signed int)dPiece[1] ); - town_init_dpiece_defs_map(); + v1 = 0; + dminx = 10; + dminy = 10; + dmaxx = 84; + dmaxy = 84; + if (entry) { + if (entry == 1) { + ViewX = 25; + ViewY = 31; + } else if (entry == 7) { + if (TWarpFrom == 5) { + ViewX = 49; + ViewY = 22; + } + if (TWarpFrom == 9) { + ViewX = 18; + ViewY = 69; + } + if (TWarpFrom == 13) { + ViewX = 41; + ViewY = 81; + } + } + } else { + ViewX = 75; + ViewY = 68; + } + T_Pass3(); + memset(dTransVal, 0, sizeof(dTransVal)); + memset(dFlags, 0, sizeof(dFlags)); + memset(dPlayer, 0, sizeof(dPlayer)); + memset(dMonster, 0, sizeof(dMonster)); + memset(dObject, 0, sizeof(dObject)); + memset(dItem, 0, sizeof(dItem)); + memset(dArch, 0, sizeof(dArch)); + v2 = dPiece; + do { + v3 = (unsigned char *)dArch + v1; + v4 = v2; + v5 = 112; + do { + v6 = (*v4)[0]; + if ((*v4)[0] == 360) { + *v3 = 1; + } else { + switch (v6) { + case 358: + *v3 = 2; + break; + case 129: + *v3 = 6; + break; + case 130: + *v3 = 7; + break; + case 128: + *v3 = 8; + break; + case 117: + *v3 = 9; + break; + case 157: + *v3 = 10; + break; + case 158: + *v3 = 11; + break; + case 156: + *v3 = 12; + break; + case 162: + *v3 = 13; + break; + case 160: + *v3 = 14; + break; + case 214: + *v3 = 15; + break; + case 212: + *v3 = 16; + break; + case 217: + *v3 = 17; + break; + case 216: + *v3 = 18; + break; + } + } + ++v4; + v3 += 112; + --v5; + } while (v5); + v2 = (int(*)[112])((char *)v2 + 4); + ++v1; + } while ((signed int)v2 < (signed int)dPiece[1]); + town_init_dpiece_defs_map(); } // 5CF328: using guessed type int dmaxx; // 5CF32C: using guessed type int dmaxy; diff --git a/Source/towners.cpp b/Source/towners.cpp index a56b0a347..39775343d 100644 --- a/Source/towners.cpp +++ b/Source/towners.cpp @@ -2,983 +2,904 @@ #include "../types.h" -int storeflag; // weak -int sgnCowMsg; // weak -int numtowners; // idb +int storeflag; // weak +int sgnCowMsg; // weak +int numtowners; // idb int sgdwCowClicks; // weak -int bannerflag; // weak // unused 0x6AAC28 -int boyloadflag; // weak -void *pCowCels; // idb +int bannerflag; // weak // unused 0x6AAC28 +int boyloadflag; // weak +void *pCowCels; // idb TownerStruct towner[16]; - -const int snSFX[3][3] = -{ - { PS_WARR52, PS_ROGUE52, PS_MAGE52 }, - { PS_WARR49, PS_ROGUE49, PS_MAGE49 }, - { PS_WARR50, PS_ROGUE50, PS_MAGE50 } +const int snSFX[3][3] = { + { PS_WARR52, PS_ROGUE52, PS_MAGE52 }, + { PS_WARR49, PS_ROGUE49, PS_MAGE49 }, + { PS_WARR50, PS_ROGUE50, PS_MAGE50 } }; /* data */ -char AnimOrder[6][148] = -{ - { - 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, - 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, - 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, - 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, - 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, - 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 5, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, - -1 - }, - { - 1, 2, 3, 3, 2, 1, 20, 19, 19, 20, - 1, 2, 3, 3, 2, 1, 20, 19, 19, 20, - 1, 2, 3, 3, 2, 1, 20, 19, 19, 20, - 1, 2, 3, 3, 2, 1, 20, 19, 19, 20, - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 15, 14, 13, 12, - 11, 10, 9, 8, 7, 6, 5, 4, 5, 6, - 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, - 5, 4, 5, 6, 7, 8, 9, 10, 11, 12, - 13, 14, 15, 16, 17, 18, 19, 20, -1 - }, - { - 1, 1, 25, 25, 24, 23, 22, 21, 20, 19, - 18, 17, 16, 15, 16, 17, 18, 19, 20, 21, - 22, 23, 24, 25, 25, 25, 1, 1, 1, 25, - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 14, 13, 12, 11, 10, - 9, 8, 7, 6, 5, 4, 3, 2, 1, -1 - }, - { - 1, 2, 3, 3, 2, 1, 16, 15, 14, 14, - 16, 1, 2, 3, 3, 2, 1, 16, 15, 14, - 14, 15, 16, 1, 2, 3, 3, 2, 1, 16, - 15, 14, 14, 15, 16, 1, 2, 3, 3, 2, - 1, 16, 15, 14, 14, 15, 16, 1, 2, 3, - 3, 2, 1, 16, 15, 14, 14, 15, 16, 1, - 2, 3, 3, 2, 1, 16, 15, 14, 14, 15, - 16, 1, 2, 3, 3, 2, 1, 16, 15, 14, - 14, 15, 16, 1, 2, 3, 2, 1, 16, 15, - 14, 14, 15, 16, 1, 2, 3, 4, 5, 6, - 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - -1 - }, - { - 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, - 9, 10, 11, 11, 11, 11, 12, 13, 14, 15, - 16, 17, 18, 18, 1, 1, 1, 18, 17, 16, - 15, 14, 13, 12, 11, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 1, 2, 3, 4, 5, 5, - 5, 4, 3, 2, -1 - }, - { - 4, 4, 4, 5, 6, 6, 6, 5, 4, 15, - 14, 13, 13, 13, 14, 15, 4, 5, 6, 6, - 6, 5, 4, 4, 4, 5, 6, 6, 6, 5, - 4, 15, 14, 13, 13, 13, 14, 15, 4, 5, - 6, 6, 6, 5, 4, 4, 4, 5, 6, 6, - 6, 5, 4, 15, 14, 13, 13, 13, 14, 15, - 4, 5, 6, 6, 6, 5, 4, 3, 2, 1, - 19, 18, 19, 1, 2, 1, 19, 18, 19, 1, - 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, - 10, 11, 12, 13, 14, 15, 15, 15, 14, 13, - 13, 13, 13, 14, 15, 15, 15, 14, 13, 12, - 12, 12, 11, 10, 10, 10, 9, 8, 9, 10, - 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, - 1, 2, 1, 19, 18, 19, 1, 2, 1, 2, - 3, -1 - } +char AnimOrder[6][148] = { + { 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 5, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, + -1 }, + { 1, 2, 3, 3, 2, 1, 20, 19, 19, 20, + 1, 2, 3, 3, 2, 1, 20, 19, 19, 20, + 1, 2, 3, 3, 2, 1, 20, 19, 19, 20, + 1, 2, 3, 3, 2, 1, 20, 19, 19, 20, + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 15, 14, 13, 12, + 11, 10, 9, 8, 7, 6, 5, 4, 5, 6, + 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, + 5, 4, 5, 6, 7, 8, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 18, 19, 20, -1 }, + { 1, 1, 25, 25, 24, 23, 22, 21, 20, 19, + 18, 17, 16, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 25, 25, 25, 1, 1, 1, 25, + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 14, 13, 12, 11, 10, + 9, 8, 7, 6, 5, 4, 3, 2, 1, -1 }, + { 1, 2, 3, 3, 2, 1, 16, 15, 14, 14, + 16, 1, 2, 3, 3, 2, 1, 16, 15, 14, + 14, 15, 16, 1, 2, 3, 3, 2, 1, 16, + 15, 14, 14, 15, 16, 1, 2, 3, 3, 2, + 1, 16, 15, 14, 14, 15, 16, 1, 2, 3, + 3, 2, 1, 16, 15, 14, 14, 15, 16, 1, + 2, 3, 3, 2, 1, 16, 15, 14, 14, 15, + 16, 1, 2, 3, 3, 2, 1, 16, 15, 14, + 14, 15, 16, 1, 2, 3, 2, 1, 16, 15, + 14, 14, 15, 16, 1, 2, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + -1 }, + { 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 11, 11, 11, 12, 13, 14, 15, + 16, 17, 18, 18, 1, 1, 1, 18, 17, 16, + 15, 14, 13, 12, 11, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 1, 2, 3, 4, 5, 5, + 5, 4, 3, 2, -1 }, + { 4, 4, 4, 5, 6, 6, 6, 5, 4, 15, + 14, 13, 13, 13, 14, 15, 4, 5, 6, 6, + 6, 5, 4, 4, 4, 5, 6, 6, 6, 5, + 4, 15, 14, 13, 13, 13, 14, 15, 4, 5, + 6, 6, 6, 5, 4, 4, 4, 5, 6, 6, + 6, 5, 4, 15, 14, 13, 13, 13, 14, 15, + 4, 5, 6, 6, 6, 5, 4, 3, 2, 1, + 19, 18, 19, 1, 2, 1, 19, 18, 19, 1, + 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 15, 15, 14, 13, + 13, 13, 13, 14, 15, 15, 15, 14, 13, 12, + 12, 12, 11, 10, 10, 10, 9, 8, 9, 10, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 1, 2, 1, 19, 18, 19, 1, 2, 1, 2, + 3, -1 } }; int TownCowX[3] = { 58, 56, 59 }; int TownCowY[3] = { 16, 14, 20 }; int TownCowDir[3] = { 1, 3, 4 }; int cowoffx[8] = { -1, 0, -1, -1, -1, 0, -1, -1 }; int cowoffy[8] = { -1, -1, -1, 0, -1, -1, -1, 0 }; -QuestTalkData Qtalklist[11] = -{ - { - QUEST_INFRA6, - QUEST_MUSH6, - -1, - -1, - QUEST_VEIL5, - -1, - QUEST_BUTCH5, - QUEST_BANNER6, - QUEST_BLIND5, - QUEST_BLOOD5, - QUEST_ANVIL6, - QUEST_WARLRD5, - QUEST_KING7, - QUEST_POISON7, - QUEST_BONE5, - QUEST_VILE9 - }, - { - QUEST_INFRA3, - -1, - -1, - -1, - QUEST_VEIL3, - -1, - QUEST_BUTCH3, - QUEST_BANNER4, - QUEST_BLIND3, - QUEST_BLOOD3, - QUEST_ANVIL3, - QUEST_WARLRD3, - QUEST_KING5, - QUEST_POISON4, - QUEST_BONE3, - QUEST_VILE7 - }, - { - -1, - -1, - -1, - -1, - -1, - -1, - -1, - -1, - -1, - -1, - -1, - -1, - -1, - -1, - -1, - -1 - }, - { - QUEST_INFRA2, - QUEST_MUSH2, - -1, - -1, - QUEST_VEIL2, - -1, - QUEST_BUTCH2, - -1, - QUEST_BLIND2, - QUEST_BLOOD2, - QUEST_ANVIL2, - QUEST_WARLRD2, - QUEST_KING3, - QUEST_POISON2, - QUEST_BONE2, - QUEST_VILE4 - }, - { - QUEST_INFRA1, - QUEST_MUSH1, - -1, - -1, - QUEST_VEIL1, - QUEST_VILE3, - QUEST_BUTCH1, - QUEST_BANNER1, - QUEST_BLIND1, - QUEST_BLOOD1, - QUEST_ANVIL1, - QUEST_WARLRD1, - QUEST_KING1, - QUEST_POISON1, - QUEST_BONE1, - QUEST_VILE2 - }, - { - QUEST_INFRA8, - QUEST_MUSH7, - -1, - -1, - QUEST_VEIL6, - -1, - QUEST_BUTCH6, - QUEST_BANNER7, - QUEST_BLIND6, - QUEST_BLOOD6, - QUEST_ANVIL8, - QUEST_WARLRD6, - QUEST_KING8, - QUEST_POISON8, - QUEST_BONE6, - QUEST_VILE10 - }, - { - QUEST_INFRA9, - QUEST_MUSH9, - -1, - -1, - QUEST_VEIL7, - -1, - QUEST_BUTCH7, - QUEST_BANNER8, - QUEST_BLIND7, - QUEST_BLOOD7, - QUEST_ANVIL9, - QUEST_WARLRD7, - QUEST_KING9, - QUEST_POISON9, - QUEST_BONE7, - QUEST_VILE11 - }, - { - QUEST_INFRA4, - QUEST_MUSH5, - -1, - -1, - QUEST_VEIL4, - -1, - QUEST_BUTCH4, - QUEST_BANNER5, - QUEST_BLIND4, - QUEST_BLOOD4, - QUEST_ANVIL4, - QUEST_WARLRD4, - QUEST_KING6, - QUEST_POISON6, - QUEST_BONE4, - QUEST_VILE8 - }, - { - QUEST_INFRA10, - QUEST_MUSH13, - -1, - -1, - QUEST_VEIL8, - -1, - QUEST_BUTCH8, - QUEST_BANNER9, - QUEST_BLIND8, - QUEST_BLOOD8, - QUEST_ANVIL10, - QUEST_WARLRD8, - QUEST_KING10, - QUEST_POISON10, - QUEST_BONE8, - QUEST_VILE12 - }, - { - -1, - -1, - -1, - -1, - -1, - -1, - -1, - -1, - -1, - -1, - -1, - -1, - -1, - -1, - -1, - -1 - }, - { - QUEST_KING1, - QUEST_KING1, - QUEST_KING1, - QUEST_KING1, - QUEST_KING1, - QUEST_KING1, - QUEST_KING1, - QUEST_KING1, - QUEST_KING1, - QUEST_KING1, - QUEST_KING1, - QUEST_KING1, - QUEST_KING1, - QUEST_KING1, - QUEST_KING1, - QUEST_KING1 - } +QuestTalkData Qtalklist[11] = { + { QUEST_INFRA6, + QUEST_MUSH6, + -1, + -1, + QUEST_VEIL5, + -1, + QUEST_BUTCH5, + QUEST_BANNER6, + QUEST_BLIND5, + QUEST_BLOOD5, + QUEST_ANVIL6, + QUEST_WARLRD5, + QUEST_KING7, + QUEST_POISON7, + QUEST_BONE5, + QUEST_VILE9 }, + { QUEST_INFRA3, + -1, + -1, + -1, + QUEST_VEIL3, + -1, + QUEST_BUTCH3, + QUEST_BANNER4, + QUEST_BLIND3, + QUEST_BLOOD3, + QUEST_ANVIL3, + QUEST_WARLRD3, + QUEST_KING5, + QUEST_POISON4, + QUEST_BONE3, + QUEST_VILE7 }, + { -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 }, + { QUEST_INFRA2, + QUEST_MUSH2, + -1, + -1, + QUEST_VEIL2, + -1, + QUEST_BUTCH2, + -1, + QUEST_BLIND2, + QUEST_BLOOD2, + QUEST_ANVIL2, + QUEST_WARLRD2, + QUEST_KING3, + QUEST_POISON2, + QUEST_BONE2, + QUEST_VILE4 }, + { QUEST_INFRA1, + QUEST_MUSH1, + -1, + -1, + QUEST_VEIL1, + QUEST_VILE3, + QUEST_BUTCH1, + QUEST_BANNER1, + QUEST_BLIND1, + QUEST_BLOOD1, + QUEST_ANVIL1, + QUEST_WARLRD1, + QUEST_KING1, + QUEST_POISON1, + QUEST_BONE1, + QUEST_VILE2 }, + { QUEST_INFRA8, + QUEST_MUSH7, + -1, + -1, + QUEST_VEIL6, + -1, + QUEST_BUTCH6, + QUEST_BANNER7, + QUEST_BLIND6, + QUEST_BLOOD6, + QUEST_ANVIL8, + QUEST_WARLRD6, + QUEST_KING8, + QUEST_POISON8, + QUEST_BONE6, + QUEST_VILE10 }, + { QUEST_INFRA9, + QUEST_MUSH9, + -1, + -1, + QUEST_VEIL7, + -1, + QUEST_BUTCH7, + QUEST_BANNER8, + QUEST_BLIND7, + QUEST_BLOOD7, + QUEST_ANVIL9, + QUEST_WARLRD7, + QUEST_KING9, + QUEST_POISON9, + QUEST_BONE7, + QUEST_VILE11 }, + { QUEST_INFRA4, + QUEST_MUSH5, + -1, + -1, + QUEST_VEIL4, + -1, + QUEST_BUTCH4, + QUEST_BANNER5, + QUEST_BLIND4, + QUEST_BLOOD4, + QUEST_ANVIL4, + QUEST_WARLRD4, + QUEST_KING6, + QUEST_POISON6, + QUEST_BONE4, + QUEST_VILE8 }, + { QUEST_INFRA10, + QUEST_MUSH13, + -1, + -1, + QUEST_VEIL8, + -1, + QUEST_BUTCH8, + QUEST_BANNER9, + QUEST_BLIND8, + QUEST_BLOOD8, + QUEST_ANVIL10, + QUEST_WARLRD8, + QUEST_KING10, + QUEST_POISON10, + QUEST_BONE8, + QUEST_VILE12 }, + { -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 }, + { QUEST_KING1, + QUEST_KING1, + QUEST_KING1, + QUEST_KING1, + QUEST_KING1, + QUEST_KING1, + QUEST_KING1, + QUEST_KING1, + QUEST_KING1, + QUEST_KING1, + QUEST_KING1, + QUEST_KING1, + QUEST_KING1, + QUEST_KING1, + QUEST_KING1, + QUEST_KING1 } }; int CowPlaying = -1; int __fastcall GetActiveTowner(int t) { - int i; // eax - - i = 0; - if ( numtowners <= 0 ) - return -1; - - while ( towner[i]._ttype != t ) - { - ++i; - if ( i >= numtowners ) - return -1; - } - return i; + int i; // eax + + i = 0; + if (numtowners <= 0) + return -1; + + while (towner[i]._ttype != t) { + ++i; + if (i >= numtowners) + return -1; + } + return i; } void __fastcall SetTownerGPtrs(void *pData, void **pAnim) { - void **v2; // esi - signed int v3; // edx - char *v4; // eax - signed int v5; // [esp+Ch] [ebp-4h] - - v5 = 0; - v2 = pAnim; - do - { - v3 = v5; - v4 = (char *)pData + *((_DWORD *)pData + v5++); - v2[v3] = v4; - } - while ( v5 < 8 ); + void **v2; // esi + signed int v3; // edx + char *v4; // eax + signed int v5; // [esp+Ch] [ebp-4h] + + v5 = 0; + v2 = pAnim; + do { + v3 = v5; + v4 = (char *)pData + *((_DWORD *)pData + v5++); + v2[v3] = v4; + } while (v5 < 8); } void __fastcall NewTownerAnim(int tnum, unsigned char *pAnim, int numFrames, int Delay) { - int v4; // ecx - - v4 = tnum; - towner[v4]._tAnimCnt = 0; - towner[v4]._tAnimLen = numFrames; - towner[v4]._tAnimData = pAnim; - towner[v4]._tAnimFrame = 1; - towner[v4]._tAnimDelay = Delay; + int v4; // ecx + + v4 = tnum; + towner[v4]._tAnimCnt = 0; + towner[v4]._tAnimLen = numFrames; + towner[v4]._tAnimData = pAnim; + towner[v4]._tAnimFrame = 1; + towner[v4]._tAnimDelay = Delay; } void __fastcall InitTownerInfo(int i, int w, bool sel, int t, int x, int y, int ao, int tp) { - int v8; // ebx - int v9; // esi - int v10; // edi - - v8 = i; - v9 = i; - v10 = w; - memset(&towner[i], 0, 0xE8u); - towner[v9]._tSelFlag = sel; - towner[v9]._ttype = t; - towner[v9]._tx = x; - towner[v9]._tMsgSaid = 0; - towner[v9]._tAnimWidth = v10; - towner[v9]._tAnimWidth2 = (v10 - 64) >> 1; - towner[v9]._ty = y; - dMonster[0][y + 112 * x] = v8 + 1; - _LOBYTE(towner[v9]._tAnimOrder) = ao; - towner[v9]._tTenPer = tp; - towner[v9]._tSeed = GetRndSeed(); + int v8; // ebx + int v9; // esi + int v10; // edi + + v8 = i; + v9 = i; + v10 = w; + memset(&towner[i], 0, 0xE8u); + towner[v9]._tSelFlag = sel; + towner[v9]._ttype = t; + towner[v9]._tx = x; + towner[v9]._tMsgSaid = 0; + towner[v9]._tAnimWidth = v10; + towner[v9]._tAnimWidth2 = (v10 - 64) >> 1; + towner[v9]._ty = y; + dMonster[0][y + 112 * x] = v8 + 1; + _LOBYTE(towner[v9]._tAnimOrder) = ao; + towner[v9]._tTenPer = tp; + towner[v9]._tSeed = GetRndSeed(); } void __fastcall InitQstSnds(int i) { - int v1; // eax - _BYTE *v2; // ecx - unsigned char *v3; // esi - QuestTalkData *v4; // eax - bool v5; // zf - - v1 = i; - if ( boyloadflag ) - v1 = i + 1; - v2 = (unsigned char *)&towner[i].qsts[0]._qstmsgact; - v3 = &quests[0]._qtype; - v4 = &Qtalklist[v1]; - do - { - v5 = v4->_qinfra == -1; - *(v2 - 2) = *v3; - *(v2 - 1) = v4->_qinfra; - *v2 = !v5; - v3 += 24; - v4 = (QuestTalkData *)((char *)v4 + 4); - v2 += 3; - } - while ( (signed int)v3 < (signed int)&quests[16]._qtype ); + int v1; // eax + _BYTE *v2; // ecx + unsigned char *v3; // esi + QuestTalkData *v4; // eax + bool v5; // zf + + v1 = i; + if (boyloadflag) + v1 = i + 1; + v2 = (unsigned char *)&towner[i].qsts[0]._qstmsgact; + v3 = &quests[0]._qtype; + v4 = &Qtalklist[v1]; + do { + v5 = v4->_qinfra == -1; + *(v2 - 2) = *v3; + *(v2 - 1) = v4->_qinfra; + *v2 = !v5; + v3 += 24; + v4 = (QuestTalkData *)((char *)v4 + 4); + v2 += 3; + } while ((signed int)v3 < (signed int)&quests[16]._qtype); } // 69BE90: using guessed type int qline; // 6AAC2C: using guessed type int boyloadflag; void __cdecl InitSmith() { - int v0; // esi - int v1; // esi - _DWORD *v2; // eax - signed int v3; // ecx - int v4; // ecx - - InitTownerInfo(numtowners, 96, 1, 0, 62, 63, 0, 10); - v0 = numtowners; - InitQstSnds(numtowners); - v1 = v0; - towner[v1]._tNData = LoadFileInMem("Towners\\Smith\\SmithN.CEL", 0); - v2 = (unsigned int *)towner[v1]._tNAnim; - v3 = 8; - do - { - *v2 = (unsigned int)towner[v1]._tNData; - ++v2; - --v3; - } - while ( v3 ); - v4 = numtowners; - towner[v1]._tNFrames = 16; - NewTownerAnim(v4, towner[v1]._tNAnim[1], 16, 3); - strcpy(towner[v1]._tName, "Griswold the Blacksmith"); - ++numtowners; + int v0; // esi + int v1; // esi + _DWORD *v2; // eax + signed int v3; // ecx + int v4; // ecx + + InitTownerInfo(numtowners, 96, 1, 0, 62, 63, 0, 10); + v0 = numtowners; + InitQstSnds(numtowners); + v1 = v0; + towner[v1]._tNData = LoadFileInMem("Towners\\Smith\\SmithN.CEL", 0); + v2 = (unsigned int *)towner[v1]._tNAnim; + v3 = 8; + do { + *v2 = (unsigned int)towner[v1]._tNData; + ++v2; + --v3; + } while (v3); + v4 = numtowners; + towner[v1]._tNFrames = 16; + NewTownerAnim(v4, towner[v1]._tNAnim[1], 16, 3); + strcpy(towner[v1]._tName, "Griswold the Blacksmith"); + ++numtowners; } void __cdecl InitBarOwner() { - int v0; // esi - int v1; // esi - _DWORD *v2; // eax - signed int v3; // ecx - int v4; // ecx - - bannerflag = 0; // unused - InitTownerInfo(numtowners, 96, 1, 3, 55, 62, 3, 10); - v0 = numtowners; - InitQstSnds(numtowners); - v1 = v0; - towner[v1]._tNData = LoadFileInMem("Towners\\TwnF\\TwnFN.CEL", 0); - v2 = (unsigned int *)towner[v1]._tNAnim; - v3 = 8; - do - { - *v2 = (unsigned int)towner[v1]._tNData; - ++v2; - --v3; - } - while ( v3 ); - v4 = numtowners; - towner[v1]._tNFrames = 16; - NewTownerAnim(v4, towner[v1]._tNAnim[1], 16, 3); - strcpy(towner[v1]._tName, "Ogden the Tavern owner"); - ++numtowners; + int v0; // esi + int v1; // esi + _DWORD *v2; // eax + signed int v3; // ecx + int v4; // ecx + + bannerflag = 0; // unused + InitTownerInfo(numtowners, 96, 1, 3, 55, 62, 3, 10); + v0 = numtowners; + InitQstSnds(numtowners); + v1 = v0; + towner[v1]._tNData = LoadFileInMem("Towners\\TwnF\\TwnFN.CEL", 0); + v2 = (unsigned int *)towner[v1]._tNAnim; + v3 = 8; + do { + *v2 = (unsigned int)towner[v1]._tNData; + ++v2; + --v3; + } while (v3); + v4 = numtowners; + towner[v1]._tNFrames = 16; + NewTownerAnim(v4, towner[v1]._tNAnim[1], 16, 3); + strcpy(towner[v1]._tName, "Ogden the Tavern owner"); + ++numtowners; } // 6AAC28: using guessed type int bannerflag; void __cdecl InitTownDead() { - int v0; // esi - int v1; // esi - _DWORD *v2; // eax - signed int v3; // ecx - int v4; // ecx - - InitTownerInfo(numtowners, 96, 1, 2, 24, 32, -1, 10); - v0 = numtowners; - InitQstSnds(numtowners); - v1 = v0; - towner[v1]._tNData = LoadFileInMem("Towners\\Butch\\Deadguy.CEL", 0); - v2 = (unsigned int *)towner[v1]._tNAnim; - v3 = 8; - do - { - *v2 = (unsigned int)towner[v1]._tNData; - ++v2; - --v3; - } - while ( v3 ); - v4 = numtowners; - towner[v1]._tNFrames = 8; - NewTownerAnim(v4, towner[v1]._tNAnim[4], 8, 6); - strcpy(towner[v1]._tName, "Wounded Townsman"); - ++numtowners; + int v0; // esi + int v1; // esi + _DWORD *v2; // eax + signed int v3; // ecx + int v4; // ecx + + InitTownerInfo(numtowners, 96, 1, 2, 24, 32, -1, 10); + v0 = numtowners; + InitQstSnds(numtowners); + v1 = v0; + towner[v1]._tNData = LoadFileInMem("Towners\\Butch\\Deadguy.CEL", 0); + v2 = (unsigned int *)towner[v1]._tNAnim; + v3 = 8; + do { + *v2 = (unsigned int)towner[v1]._tNData; + ++v2; + --v3; + } while (v3); + v4 = numtowners; + towner[v1]._tNFrames = 8; + NewTownerAnim(v4, towner[v1]._tNAnim[4], 8, 6); + strcpy(towner[v1]._tName, "Wounded Townsman"); + ++numtowners; } void __cdecl InitWitch() { - int v0; // esi - int v1; // esi - _DWORD *v2; // ecx - signed int v3; // edx - - InitTownerInfo(numtowners, 96, 1, 6, 80, 20, 5, 10); - v0 = numtowners; - InitQstSnds(numtowners); - v1 = v0; - towner[v1]._tNData = LoadFileInMem("Towners\\TownWmn1\\Witch.CEL", 0); - v2 = (unsigned int *)towner[v1]._tNAnim; - v3 = 8; - do - { - *v2 = (unsigned int)towner[v1]._tNData; - ++v2; - --v3; - } - while ( v3 ); - towner[v1]._tNFrames = 19; - NewTownerAnim(numtowners, towner[v1]._tNAnim[0], 19, 6); - strcpy(towner[v1]._tName, "Adria the Witch"); - ++numtowners; + int v0; // esi + int v1; // esi + _DWORD *v2; // ecx + signed int v3; // edx + + InitTownerInfo(numtowners, 96, 1, 6, 80, 20, 5, 10); + v0 = numtowners; + InitQstSnds(numtowners); + v1 = v0; + towner[v1]._tNData = LoadFileInMem("Towners\\TownWmn1\\Witch.CEL", 0); + v2 = (unsigned int *)towner[v1]._tNAnim; + v3 = 8; + do { + *v2 = (unsigned int)towner[v1]._tNData; + ++v2; + --v3; + } while (v3); + towner[v1]._tNFrames = 19; + NewTownerAnim(numtowners, towner[v1]._tNAnim[0], 19, 6); + strcpy(towner[v1]._tName, "Adria the Witch"); + ++numtowners; } void __cdecl InitBarmaid() { - int v0; // esi - int v1; // esi - _DWORD *v2; // ecx - signed int v3; // edx - - InitTownerInfo(numtowners, 96, 1, 7, 43, 66, -1, 10); - v0 = numtowners; - InitQstSnds(numtowners); - v1 = v0; - towner[v1]._tNData = LoadFileInMem("Towners\\TownWmn1\\WmnN.CEL", 0); - v2 = (unsigned int *)towner[v1]._tNAnim; - v3 = 8; - do - { - *v2 = (unsigned int)towner[v1]._tNData; - ++v2; - --v3; - } - while ( v3 ); - towner[v1]._tNFrames = 18; - NewTownerAnim(numtowners, towner[v1]._tNAnim[0], 18, 6); - strcpy(towner[v1]._tName, "Gillian the Barmaid"); - ++numtowners; + int v0; // esi + int v1; // esi + _DWORD *v2; // ecx + signed int v3; // edx + + InitTownerInfo(numtowners, 96, 1, 7, 43, 66, -1, 10); + v0 = numtowners; + InitQstSnds(numtowners); + v1 = v0; + towner[v1]._tNData = LoadFileInMem("Towners\\TownWmn1\\WmnN.CEL", 0); + v2 = (unsigned int *)towner[v1]._tNAnim; + v3 = 8; + do { + *v2 = (unsigned int)towner[v1]._tNData; + ++v2; + --v3; + } while (v3); + towner[v1]._tNFrames = 18; + NewTownerAnim(numtowners, towner[v1]._tNAnim[0], 18, 6); + strcpy(towner[v1]._tName, "Gillian the Barmaid"); + ++numtowners; } void __cdecl InitBoy() { - int v0; // esi - int v1; // esi - _DWORD *v2; // ecx - signed int v3; // edx - - boyloadflag = 1; - InitTownerInfo(numtowners, 96, 1, 8, 11, 53, -1, 10); - v0 = numtowners; - InitQstSnds(numtowners); - v1 = v0; - towner[v1]._tNData = LoadFileInMem("Towners\\TownBoy\\PegKid1.CEL", 0); - v2 = (unsigned int *)towner[v1]._tNAnim; - v3 = 8; - do - { - *v2 = (unsigned int)towner[v1]._tNData; - ++v2; - --v3; - } - while ( v3 ); - towner[v1]._tNFrames = 20; - NewTownerAnim(numtowners, towner[v1]._tNAnim[0], 20, 6); - strcpy(towner[v1]._tName, "Wirt the Peg-legged boy"); - ++numtowners; + int v0; // esi + int v1; // esi + _DWORD *v2; // ecx + signed int v3; // edx + + boyloadflag = 1; + InitTownerInfo(numtowners, 96, 1, 8, 11, 53, -1, 10); + v0 = numtowners; + InitQstSnds(numtowners); + v1 = v0; + towner[v1]._tNData = LoadFileInMem("Towners\\TownBoy\\PegKid1.CEL", 0); + v2 = (unsigned int *)towner[v1]._tNAnim; + v3 = 8; + do { + *v2 = (unsigned int)towner[v1]._tNData; + ++v2; + --v3; + } while (v3); + towner[v1]._tNFrames = 20; + NewTownerAnim(numtowners, towner[v1]._tNAnim[0], 20, 6); + strcpy(towner[v1]._tName, "Wirt the Peg-legged boy"); + ++numtowners; } // 6AAC2C: using guessed type int boyloadflag; void __cdecl InitHealer() { - int v0; // esi - int v1; // esi - _DWORD *v2; // eax - signed int v3; // ecx - int v4; // ecx - - InitTownerInfo(numtowners, 96, 1, 1, 55, 79, 1, 10); - v0 = numtowners; - InitQstSnds(numtowners); - v1 = v0; - towner[v1]._tNData = LoadFileInMem("Towners\\Healer\\Healer.CEL", 0); - v2 = (unsigned int *)towner[v1]._tNAnim; - v3 = 8; - do - { - *v2 = (unsigned int)towner[v1]._tNData; - ++v2; - --v3; - } - while ( v3 ); - v4 = numtowners; - towner[v1]._tNFrames = 20; - NewTownerAnim(v4, towner[v1]._tNAnim[7], 20, 6); - strcpy(towner[v1]._tName, "Pepin the Healer"); - ++numtowners; + int v0; // esi + int v1; // esi + _DWORD *v2; // eax + signed int v3; // ecx + int v4; // ecx + + InitTownerInfo(numtowners, 96, 1, 1, 55, 79, 1, 10); + v0 = numtowners; + InitQstSnds(numtowners); + v1 = v0; + towner[v1]._tNData = LoadFileInMem("Towners\\Healer\\Healer.CEL", 0); + v2 = (unsigned int *)towner[v1]._tNAnim; + v3 = 8; + do { + *v2 = (unsigned int)towner[v1]._tNData; + ++v2; + --v3; + } while (v3); + v4 = numtowners; + towner[v1]._tNFrames = 20; + NewTownerAnim(v4, towner[v1]._tNAnim[7], 20, 6); + strcpy(towner[v1]._tName, "Pepin the Healer"); + ++numtowners; } void __cdecl InitTeller() { - int v0; // esi - int v1; // esi - _DWORD *v2; // ecx - signed int v3; // edx - - InitTownerInfo(numtowners, 96, 1, 4, 62, 71, 2, 10); - v0 = numtowners; - InitQstSnds(numtowners); - v1 = v0; - towner[v1]._tNData = LoadFileInMem("Towners\\Strytell\\Strytell.CEL", 0); - v2 = (unsigned int *)towner[v1]._tNAnim; - v3 = 8; - do - { - *v2 = (unsigned int)towner[v1]._tNData; - ++v2; - --v3; - } - while ( v3 ); - towner[v1]._tNFrames = 25; - NewTownerAnim(numtowners, towner[v1]._tNAnim[0], 25, 3); - strcpy(towner[v1]._tName, "Cain the Elder"); - ++numtowners; + int v0; // esi + int v1; // esi + _DWORD *v2; // ecx + signed int v3; // edx + + InitTownerInfo(numtowners, 96, 1, 4, 62, 71, 2, 10); + v0 = numtowners; + InitQstSnds(numtowners); + v1 = v0; + towner[v1]._tNData = LoadFileInMem("Towners\\Strytell\\Strytell.CEL", 0); + v2 = (unsigned int *)towner[v1]._tNAnim; + v3 = 8; + do { + *v2 = (unsigned int)towner[v1]._tNData; + ++v2; + --v3; + } while (v3); + towner[v1]._tNFrames = 25; + NewTownerAnim(numtowners, towner[v1]._tNAnim[0], 25, 3); + strcpy(towner[v1]._tName, "Cain the Elder"); + ++numtowners; } void __cdecl InitDrunk() { - int v0; // esi - int v1; // esi - _DWORD *v2; // ecx - signed int v3; // edx - - InitTownerInfo(numtowners, 96, 1, 5, 71, 84, 4, 10); - v0 = numtowners; - InitQstSnds(numtowners); - v1 = v0; - towner[v1]._tNData = LoadFileInMem("Towners\\Drunk\\TwnDrunk.CEL", 0); - v2 = (unsigned int *)towner[v1]._tNAnim; - v3 = 8; - do - { - *v2 = (unsigned int)towner[v1]._tNData; - ++v2; - --v3; - } - while ( v3 ); - towner[v1]._tNFrames = 18; - NewTownerAnim(numtowners, towner[v1]._tNAnim[0], 18, 3); - strcpy(towner[v1]._tName, "Farnham the Drunk"); - ++numtowners; + int v0; // esi + int v1; // esi + _DWORD *v2; // ecx + signed int v3; // edx + + InitTownerInfo(numtowners, 96, 1, 5, 71, 84, 4, 10); + v0 = numtowners; + InitQstSnds(numtowners); + v1 = v0; + towner[v1]._tNData = LoadFileInMem("Towners\\Drunk\\TwnDrunk.CEL", 0); + v2 = (unsigned int *)towner[v1]._tNAnim; + v3 = 8; + do { + *v2 = (unsigned int)towner[v1]._tNData; + ++v2; + --v3; + } while (v3); + towner[v1]._tNFrames = 18; + NewTownerAnim(numtowners, towner[v1]._tNAnim[0], 18, 3); + strcpy(towner[v1]._tName, "Farnham the Drunk"); + ++numtowners; } void __cdecl InitCows() { - unsigned char *v0; // eax - int v1; // ecx - signed int v2; // ebx - int v3; // esi - int v4; // ebp - int v5; // eax - void **v6; // ecx - int v7; // edi - int v9; // edx - int v10; // eax - int v11; // ecx - _DWORD *v12; // esi - int v13; // edx - _DWORD *v14; // esi - _DWORD *v15; // eax - int v16; // [esp+10h] [ebp-4h] - - v0 = LoadFileInMem("Towners\\Animals\\Cow.CEL", 0); - v1 = numtowners; - pCowCels = v0; - v2 = 0; - do - { - v3 = TownCowX[v2]; - v4 = TownCowDir[v2]; - v16 = TownCowY[v2]; - InitTownerInfo(v1, 128, 0, 9, TownCowX[v2], v16, -1, 10); - v5 = numtowners; - v6 = (void **)&towner[numtowners]._tNData; - *v6 = pCowCels; - SetTownerGPtrs(*v6, (void **)towner[v5]._tNAnim); - v7 = numtowners; - towner[numtowners]._tNFrames = 12; - NewTownerAnim(v7, towner[0]._tNAnim[v4 + 58 * v7], 12, 3); - v7 *= 232; - *(int *)((char *)&towner[0]._tAnimFrame + v7) = random(0, 11) + 1; - *(int *)((char *)&towner[0]._tSelFlag + v7) = 1; - strcpy(&towner[0]._tName[v7], "Cow"); - v9 = v3 + cowoffx[v4]; - v10 = v16 + cowoffy[v4]; - v11 = numtowners; - v12 = (_DWORD *)((char *)dMonster + 4 * (v10 + 112 * v3)); - if ( !*v12 ) - *v12 = -1 - numtowners; - v13 = 112 * v9; - v14 = (_DWORD *)((char *)dMonster + 4 * (v13 + v16)); - if ( !*v14 ) - *v14 = -1 - v11; - v15 = (_DWORD *)((char *)dMonster + 4 * (v10 + v13)); - if ( !*v15 ) - *v15 = -1 - v11; - ++v2; - v1 = v11 + 1; - numtowners = v1; - } - while ( v2 < 3 ); + unsigned char *v0; // eax + int v1; // ecx + signed int v2; // ebx + int v3; // esi + int v4; // ebp + int v5; // eax + void **v6; // ecx + int v7; // edi + int v9; // edx + int v10; // eax + int v11; // ecx + _DWORD *v12; // esi + int v13; // edx + _DWORD *v14; // esi + _DWORD *v15; // eax + int v16; // [esp+10h] [ebp-4h] + + v0 = LoadFileInMem("Towners\\Animals\\Cow.CEL", 0); + v1 = numtowners; + pCowCels = v0; + v2 = 0; + do { + v3 = TownCowX[v2]; + v4 = TownCowDir[v2]; + v16 = TownCowY[v2]; + InitTownerInfo(v1, 128, 0, 9, TownCowX[v2], v16, -1, 10); + v5 = numtowners; + v6 = (void **)&towner[numtowners]._tNData; + *v6 = pCowCels; + SetTownerGPtrs(*v6, (void **)towner[v5]._tNAnim); + v7 = numtowners; + towner[numtowners]._tNFrames = 12; + NewTownerAnim(v7, towner[0]._tNAnim[v4 + 58 * v7], 12, 3); + v7 *= 232; + *(int *)((char *)&towner[0]._tAnimFrame + v7) = random(0, 11) + 1; + *(int *)((char *)&towner[0]._tSelFlag + v7) = 1; + strcpy(&towner[0]._tName[v7], "Cow"); + v9 = v3 + cowoffx[v4]; + v10 = v16 + cowoffy[v4]; + v11 = numtowners; + v12 = (_DWORD *)((char *)dMonster + 4 * (v10 + 112 * v3)); + if (!*v12) + *v12 = -1 - numtowners; + v13 = 112 * v9; + v14 = (_DWORD *)((char *)dMonster + 4 * (v13 + v16)); + if (!*v14) + *v14 = -1 - v11; + v15 = (_DWORD *)((char *)dMonster + 4 * (v10 + v13)); + if (!*v15) + *v15 = -1 - v11; + ++v2; + v1 = v11 + 1; + numtowners = v1; + } while (v2 < 3); } // 6AAC2C: using guessed type int boyloadflag; void __cdecl InitTowners() { - numtowners = 0; - boyloadflag = 0; - InitSmith(); - InitHealer(); - if ( quests[QTYPE_BUTCH]._qactive && quests[QTYPE_BUTCH]._qactive != 3 ) - InitTownDead(); - InitBarOwner(); - InitTeller(); - InitDrunk(); - InitWitch(); - InitBarmaid(); - InitBoy(); - InitCows(); + numtowners = 0; + boyloadflag = 0; + InitSmith(); + InitHealer(); + if (quests[QTYPE_BUTCH]._qactive && quests[QTYPE_BUTCH]._qactive != 3) + InitTownDead(); + InitBarOwner(); + InitTeller(); + InitDrunk(); + InitWitch(); + InitBarmaid(); + InitBoy(); + InitCows(); } // 6AAC2C: using guessed type int boyloadflag; void __cdecl FreeTownerGFX() { - void **v0; // esi - void *v1; // ecx - void *v2; // ecx - - v0 = (void **)&towner[0]._tNData; - do - { - v1 = *v0; - if ( *v0 == pCowCels ) - { - *v0 = 0; - } - else if ( v1 ) - { - *v0 = 0; - mem_free_dbg(v1); - } - v0 += 58; - } - while ( (signed int)v0 < (signed int)&towner[16]._tNData ); - v2 = pCowCels; - pCowCels = 0; - mem_free_dbg(v2); + void **v0; // esi + void *v1; // ecx + void *v2; // ecx + + v0 = (void **)&towner[0]._tNData; + do { + v1 = *v0; + if (*v0 == pCowCels) { + *v0 = 0; + } else if (v1) { + *v0 = 0; + mem_free_dbg(v1); + } + v0 += 58; + } while ((signed int)v0 < (signed int)&towner[16]._tNData); + v2 = pCowCels; + pCowCels = 0; + mem_free_dbg(v2); } // 6ABB9C: using guessed type int dword_6ABB9C; void __fastcall TownCtrlMsg(int i) { - int p; // edi - int dx; // ebx - int dy; // eax - - if ( towner[i]._tbtcnt ) - { - p = towner[i]._tVar1; - dx = abs(towner[i]._tx - plr[p].WorldX); - dy = abs(towner[i]._ty - plr[p].WorldY); - if ( dx >= 2 || dy >= 2 ) - towner[i]._tbtcnt = 0; - if ( !towner[i]._tbtcnt ) - { - qtextflag = FALSE; - sfx_stop(); - } - } + int p; // edi + int dx; // ebx + int dy; // eax + + if (towner[i]._tbtcnt) { + p = towner[i]._tVar1; + dx = abs(towner[i]._tx - plr[p].WorldX); + dy = abs(towner[i]._ty - plr[p].WorldY); + if (dx >= 2 || dy >= 2) + towner[i]._tbtcnt = 0; + if (!towner[i]._tbtcnt) { + qtextflag = FALSE; + sfx_stop(); + } + } } // 646D00: using guessed type char qtextflag; void __cdecl TownBlackSmith() { - int v0; // eax + int v0; // eax - v0 = GetActiveTowner(TOWN_SMITH); - TownCtrlMsg(v0); + v0 = GetActiveTowner(TOWN_SMITH); + TownCtrlMsg(v0); } void __cdecl TownBarOwner() { - int v0; // eax + int v0; // eax - v0 = GetActiveTowner(TOWN_TAVERN); - TownCtrlMsg(v0); + v0 = GetActiveTowner(TOWN_TAVERN); + TownCtrlMsg(v0); } void __cdecl TownDead() { - int v0; // esi - int v1; // eax - - v0 = GetActiveTowner(TOWN_DEADGUY); - TownCtrlMsg(v0); - if ( qtextflag ) - goto LABEL_6; - if ( (quests[6]._qactive != 2 || quests[6]._qlog) && quests[6]._qactive != 1 ) - { - v1 = v0; - towner[v1]._tAnimDelay = 1000; - towner[v1]._tAnimFrame = 1; - strcpy(towner[v0]._tName, "Slain Townsman"); -LABEL_6: - if ( quests[QTYPE_BUTCH]._qactive != 1 ) - towner[v0]._tAnimCnt = 0; - } + int v0; // esi + int v1; // eax + + v0 = GetActiveTowner(TOWN_DEADGUY); + TownCtrlMsg(v0); + if (qtextflag) + goto LABEL_6; + if ((quests[6]._qactive != 2 || quests[6]._qlog) && quests[6]._qactive != 1) { + v1 = v0; + towner[v1]._tAnimDelay = 1000; + towner[v1]._tAnimFrame = 1; + strcpy(towner[v0]._tName, "Slain Townsman"); + LABEL_6: + if (quests[QTYPE_BUTCH]._qactive != 1) + towner[v0]._tAnimCnt = 0; + } } // 646D00: using guessed type char qtextflag; void __cdecl TownHealer() { - int v0; // eax + int v0; // eax - v0 = GetActiveTowner(TOWN_HEALER); - TownCtrlMsg(v0); + v0 = GetActiveTowner(TOWN_HEALER); + TownCtrlMsg(v0); } void __cdecl TownStory() { - int v0; // eax + int v0; // eax - v0 = GetActiveTowner(TOWN_STORY); - TownCtrlMsg(v0); + v0 = GetActiveTowner(TOWN_STORY); + TownCtrlMsg(v0); } void __cdecl TownDrunk() { - int v0; // eax + int v0; // eax - v0 = GetActiveTowner(TOWN_DRUNK); - TownCtrlMsg(v0); + v0 = GetActiveTowner(TOWN_DRUNK); + TownCtrlMsg(v0); } void __cdecl TownBoy() { - int v0; // eax + int v0; // eax - v0 = GetActiveTowner(TOWN_PEGBOY); - TownCtrlMsg(v0); + v0 = GetActiveTowner(TOWN_PEGBOY); + TownCtrlMsg(v0); } void __cdecl TownWitch() { - int v0; // eax + int v0; // eax - v0 = GetActiveTowner(TOWN_WITCH); - TownCtrlMsg(v0); + v0 = GetActiveTowner(TOWN_WITCH); + TownCtrlMsg(v0); } void __cdecl TownBarMaid() { - int v0; // eax + int v0; // eax - v0 = GetActiveTowner(TOWN_BMAID); - TownCtrlMsg(v0); + v0 = GetActiveTowner(TOWN_BMAID); + TownCtrlMsg(v0); } void __cdecl TownCow() { - int v0; // eax + int v0; // eax - v0 = GetActiveTowner(TOWN_COW); - TownCtrlMsg(v0); + v0 = GetActiveTowner(TOWN_COW); + TownCtrlMsg(v0); } void __cdecl ProcessTowners() { - int *v0; // esi - char v1; // al - int v2; // ecx - _DWORD *v3; // eax - - v0 = &towner[0]._tAnimCnt; - do - { - switch ( *(v0 - 10) ) - { - case TOWN_SMITH: - TownBlackSmith(); - break; - case TOWN_HEALER: - TownHealer(); - break; - case TOWN_DEADGUY: - TownDead(); - break; - case TOWN_TAVERN: - TownBarOwner(); - break; - case TOWN_STORY: - TownStory(); - break; - case TOWN_DRUNK: - TownDrunk(); - break; - case TOWN_WITCH: - TownWitch(); - break; - case TOWN_BMAID: - TownBarMaid(); - break; - case TOWN_PEGBOY: - TownBoy(); - break; - case TOWN_COW: - TownCow(); - break; - default: - break; - } - if ( ++*v0 >= *(v0 - 1) ) - { - v1 = *((_BYTE *)v0 + 16); - *v0 = 0; - if ( v1 < 0 ) - { - if ( ++v0[2] > v0[1] ) - v0[2] = 1; - } - else - { - v2 = 148 * v1; - v3 = (unsigned int *)v0 + 3; - ++*v3; - if ( AnimOrder[0][v0[3] + v2] == -1 ) - *v3 = 0; - v0[2] = (char)AnimOrder[0][*v3 + v2]; - } - } - v0 += 58; - } - while ( (signed int)v0 < (signed int)&towner[16]._tAnimCnt ); + int *v0; // esi + char v1; // al + int v2; // ecx + _DWORD *v3; // eax + + v0 = &towner[0]._tAnimCnt; + do { + switch (*(v0 - 10)) { + case TOWN_SMITH: + TownBlackSmith(); + break; + case TOWN_HEALER: + TownHealer(); + break; + case TOWN_DEADGUY: + TownDead(); + break; + case TOWN_TAVERN: + TownBarOwner(); + break; + case TOWN_STORY: + TownStory(); + break; + case TOWN_DRUNK: + TownDrunk(); + break; + case TOWN_WITCH: + TownWitch(); + break; + case TOWN_BMAID: + TownBarMaid(); + break; + case TOWN_PEGBOY: + TownBoy(); + break; + case TOWN_COW: + TownCow(); + break; + default: + break; + } + if (++*v0 >= *(v0 - 1)) { + v1 = *((_BYTE *)v0 + 16); + *v0 = 0; + if (v1 < 0) { + if (++v0[2] > v0[1]) + v0[2] = 1; + } else { + v2 = 148 * v1; + v3 = (unsigned int *)v0 + 3; + ++*v3; + if (AnimOrder[0][v0[3] + v2] == -1) + *v3 = 0; + v0[2] = (char)AnimOrder[0][*v3 + v2]; + } + } + v0 += 58; + } while ((signed int)v0 < (signed int)&towner[16]._tAnimCnt); } ItemStruct *__fastcall PlrHasItem(int pnum, int item, int *i) { - unsigned int v3; // eax - int v4; // ecx - - v3 = 21720 * pnum; - *i = 0; - if ( plr[pnum]._pNumInv <= 0 ) - return 0; - while ( *(int *)((char *)&plr[0].InvList[*i].IDidx + v3) != item ) - { - v4 = *i + 1; - *i = v4; - if ( v4 >= plr[v3 / 0x54D8]._pNumInv ) - return 0; - } - return (ItemStruct *)((char *)&plr[0].InvList[*i] + v3); + unsigned int v3; // eax + int v4; // ecx + + v3 = 21720 * pnum; + *i = 0; + if (plr[pnum]._pNumInv <= 0) + return 0; + while (*(int *)((char *)&plr[0].InvList[*i].IDidx + v3) != item) { + v4 = *i + 1; + *i = v4; + if (v4 >= plr[v3 / 0x54D8]._pNumInv) + return 0; + } + return (ItemStruct *)((char *)&plr[0].InvList[*i] + v3); } void __fastcall TownerTalk(int t) { - sgdwCowClicks = 0; - sgnCowMsg = 0; - storeflag = 1; - InitQTextMsg(t); + sgdwCowClicks = 0; + sgnCowMsg = 0; + storeflag = 1; + InitQTextMsg(t); } // 6AAC18: using guessed type int storeflag; // 6AAC1C: using guessed type int sgnCowMsg; @@ -986,483 +907,410 @@ void __fastcall TownerTalk(int t) void __fastcall TalkToTowner(int p, int t) { - int v2; // ebx - int v3; // edi - int v6; // ebp - int v7; // esi - int v8; // eax - int v9; // ecx - //char v10; // cl - bool v11; // zf - int v12; // edi - //int v13; // eax - //int v14; // eax - //int v15; // eax - //char v16; // cl - _speech_id v17; // ecx - ItemStruct *Item; // ebp - unsigned char v19; // dl - int inv_item_num; // [esp+10h] [ebp-8h] - int v21; // [esp+14h] [ebp-4h] - - v2 = t; - v3 = p; - v21 = t; - random(6, 3); /* figure out what these are for */ - random(6, 4); - random(6, 5); - v6 = v3; - v7 = v2; - inv_item_num = abs(plr[v3].WorldX - towner[v2]._tx); - v8 = abs(plr[v3].WorldY - towner[v2]._ty); - if ( inv_item_num >= 2 ) - return; - if ( v8 >= 2 ) - return; - if ( qtextflag ) - return; - towner[v7]._tMsgSaid = 0; - if ( pcurs >= CURSOR_FIRSTITEM && !DropItemBeforeTrig() ) - return; - if ( v2 == GetActiveTowner(TOWN_TAVERN) ) - { - if ( !plr[v6]._pLvlVisited[0] && !towner[v7]._tMsgSaid ) - { - towner[v7]._tbtcnt = 150; - towner[v7]._tVar1 = v3; - InitQTextMsg(QUEST_INTRO); - towner[v7]._tMsgSaid = 1; - } - if ( (plr[v6]._pLvlVisited[2] || plr[v6]._pLvlVisited[4]) && quests[QTYPE_KING]._qactive ) - { - if ( !quests[QTYPE_KING]._qvar2 && !towner[v7]._tMsgSaid ) - { - quests[QTYPE_KING]._qvar2 = 1; - quests[QTYPE_KING]._qlog = 1; - if ( quests[QTYPE_KING]._qactive == 1 ) - { - quests[QTYPE_KING]._qactive = 2; - quests[QTYPE_KING]._qvar1 = 1; - } - towner[v7]._tbtcnt = 150; - towner[v7]._tVar1 = v3; - InitQTextMsg(QUEST_KING2); - towner[v7]._tMsgSaid = 1; - NetSendCmdQuest(TRUE, 0xCu); - } - if ( quests[QTYPE_KING]._qactive == 3 && quests[QTYPE_KING]._qvar2 == 1 && !towner[v7]._tMsgSaid ) - { - quests[QTYPE_KING]._qvar2 = 2; - quests[QTYPE_KING]._qvar1 = 2; - towner[v7]._tbtcnt = 150; - towner[v7]._tVar1 = v3; - InitQTextMsg(QUEST_KING4); - towner[v7]._tMsgSaid = 1; - NetSendCmdQuest(TRUE, 0xCu); - } - } - if ( gbMaxPlayers == 1 && plr[v6]._pLvlVisited[3] && quests[QTYPE_BOL]._qactive ) - { - if ( (quests[QTYPE_BOL]._qactive == 1 || quests[QTYPE_BOL]._qactive == 2) && !quests[QTYPE_BOL]._qvar2 ) - { - if ( towner[v7]._tMsgSaid ) - goto LABEL_36; - quests[QTYPE_BOL]._qvar2 = 1; - if ( quests[QTYPE_BOL]._qactive == 1 ) - { - quests[QTYPE_BOL]._qvar1 = 1; - quests[QTYPE_BOL]._qactive = 2; - } - quests[QTYPE_BOL]._qlog = 1; - towner[v7]._tbtcnt = 150; - towner[v7]._tVar1 = v3; - InitQTextMsg(QUEST_BANNER2); - towner[v7]._tMsgSaid = 1; - } - if ( quests[QTYPE_BOL]._qvar2 == 1 && PlrHasItem(v3, IDI_BANNER, &inv_item_num) && !towner[v7]._tMsgSaid ) - { - quests[QTYPE_BOL]._qactive = 3; - quests[QTYPE_BOL]._qvar1 = 3; - RemoveInvItem(v3, inv_item_num); - CreateItem(UITEM_HARCREST, towner[v7]._tx, towner[v7]._ty + 1); - towner[v7]._tbtcnt = 150; - towner[v7]._tVar1 = v3; - InitQTextMsg(QUEST_BANNER3); - towner[v7]._tMsgSaid = 1; - } - } -LABEL_36: - if ( !qtextflag ) - { - TownerTalk(QUEST_OGDEN1); - if ( storeflag ) - { - _LOBYTE(v9) = STORE_TAVERN; -LABEL_39: - StartStore(v9); - return; - } - } - return; - } - if ( v2 == GetActiveTowner(TOWN_DEADGUY) ) - { - if ( quests[QTYPE_BUTCH]._qactive == 2 ) - { - if ( quests[QTYPE_BUTCH]._qvar1 == 1 ) - { - towner[v7]._tbtcnt = 150; - towner[v7]._tVar1 = v3; - quests[QTYPE_BUTCH]._qvar1 = 1; - if ( plr[v6]._pClass == PC_WARRIOR && (v12 = PS_WARR8, !effect_is_playing(PS_WARR8)) - || plr[v6]._pClass == PC_ROGUE && (v12 = PS_ROGUE8, !effect_is_playing(PS_ROGUE8)) - || plr[v6]._pClass == PC_SORCERER && (v12 = PS_MAGE8, !effect_is_playing(PS_MAGE8)) ) - { - PlaySFX(v12); - } -LABEL_53: - towner[v7]._tMsgSaid = 1; - return; - } - if ( quests[QTYPE_BUTCH]._qvar1 ) - return; - } - else - { - if ( quests[QTYPE_BUTCH]._qactive == 3 ) - { - if ( quests[QTYPE_BUTCH]._qvar1 != 1 ) - return; - quests[QTYPE_BUTCH]._qvar1 = 1; - towner[v7]._tbtcnt = 150; - towner[v7]._tVar1 = v3; - goto LABEL_53; - } - if ( quests[QTYPE_BUTCH]._qactive != 1 ) - return; - } - quests[QTYPE_BUTCH]._qactive = 2; - quests[QTYPE_BUTCH]._qlog = 1; - quests[QTYPE_BUTCH]._qmsg = QUEST_BUTCH9; - quests[QTYPE_BUTCH]._qvar1 = 1; - towner[v7]._tbtcnt = 50; - towner[v7]._tVar1 = v3; - towner[v7]._tVar2 = 3; - InitQTextMsg(QUEST_BUTCH9); - towner[v7]._tMsgSaid = 1; - NetSendCmdQuest(TRUE, 6u); - return; - } - if ( v2 != GetActiveTowner(0) ) - { - if ( v2 == GetActiveTowner(TOWN_WITCH) ) - { - if ( quests[QTYPE_BLKM]._qactive == 1 ) - { - if ( PlrHasItem(v3, IDI_FUNGALTM, &inv_item_num) ) - { - RemoveInvItem(v3, inv_item_num); - quests[QTYPE_BLKM]._qactive = 2; - quests[QTYPE_BLKM]._qlog = 1; - quests[QTYPE_BLKM]._qvar1 = QS_TOMEGIVEN; - v17 = QUEST_MUSH8; -LABEL_105: - towner[v7]._tVar1 = v3; - towner[v7]._tbtcnt = 150; - InitQTextMsg(v17); - towner[v7]._tMsgSaid = 1; - goto LABEL_106; - } - } - else if ( quests[QTYPE_BLKM]._qactive == 2 ) - { - if ( quests[QTYPE_BLKM]._qvar1 >= QS_TOMEGIVEN && quests[QTYPE_BLKM]._qvar1 <= QS_MUSHPICKED ) - { - if ( PlrHasItem(v3, IDI_MUSHROOM, &inv_item_num) ) - { - RemoveInvItem(v3, inv_item_num); - Qtalklist[TOWN_WITCH]._qblkm = -1; - quests[QTYPE_BLKM]._qvar1 = QS_MUSHGIVEN; - Qtalklist[TOWN_HEALER]._qblkm = QUEST_MUSH3; - v17 = QUEST_MUSH10; - } - else - { - v17 = QUEST_MUSH9; - if ( quests[QTYPE_BLKM]._qmsg == QUEST_MUSH9 ) - goto LABEL_106; - } - quests[QTYPE_BLKM]._qmsg = v17; - goto LABEL_105; - } - Item = PlrHasItem(v3, IDI_SPECELIX, &inv_item_num); - if ( Item ) - { - towner[v7]._tbtcnt = 150; - towner[v7]._tVar1 = v3; - InitQTextMsg(QUEST_MUSH12); - quests[QTYPE_BLKM]._qactive = 3; - towner[v7]._tMsgSaid = 1; - AllItemsList[Item->IDidx].iUsable = 1; - } - else if ( PlrHasItem(v3, IDI_BRAIN, &inv_item_num) ) - { - v17 = QUEST_MUSH11; - if ( quests[QTYPE_BLKM]._qvar2 != QUEST_MUSH11 ) - { - quests[QTYPE_BLKM]._qvar2 = QUEST_MUSH11; - goto LABEL_105; - } - } - } -LABEL_106: - if ( !qtextflag ) - { - TownerTalk(QUEST_ADRIA1); - if ( storeflag ) - { - _LOBYTE(v9) = STORE_WITCH; - goto LABEL_39; - } - } - return; - } - if ( v2 == GetActiveTowner(TOWN_BMAID) ) - { - if ( !qtextflag ) - { - TownerTalk(QUEST_GILLIAN1); - if ( storeflag ) - { - _LOBYTE(v9) = STORE_BARMAID; - goto LABEL_39; - } - } - return; - } - if ( v2 == GetActiveTowner(TOWN_DRUNK) ) - { - if ( !qtextflag ) - { - TownerTalk(QUEST_FARNHAM1); - if ( storeflag ) - { - _LOBYTE(v9) = STORE_DRUNK; - goto LABEL_39; - } - } - return; - } - if ( v21 == GetActiveTowner(1) ) - { - if ( gbMaxPlayers != 1 ) - goto LABEL_131; - if ( plr[v6]._pLvlVisited[1] && !towner[v7]._tMsgSaid ) - { - if ( quests[QTYPE_PW]._qactive == 1 ) - { - quests[QTYPE_PW]._qactive = 2; - quests[QTYPE_PW]._qlog = 1; - quests[QTYPE_PW]._qmsg = QUEST_POISON3; - quests[QTYPE_PW]._qvar1 = 1; - towner[v7]._tbtcnt = 150; - towner[v7]._tVar1 = v3; - InitQTextMsg(QUEST_POISON3); -LABEL_126: - towner[v7]._tMsgSaid = 1; - goto LABEL_127; - } - if ( quests[QTYPE_PW]._qactive == 3 && quests[QTYPE_PW]._qvar1 != 2 ) - { - quests[QTYPE_PW]._qvar1 = 2; - towner[v7]._tbtcnt = 150; - towner[v7]._tVar1 = v3; - InitQTextMsg(QUEST_POISON5); - CreateItem(UITEM_TRING, towner[v7]._tx, towner[v7]._ty + 1); - goto LABEL_126; - } - } -LABEL_127: - if ( quests[QTYPE_BLKM]._qactive == 2 && quests[QTYPE_BLKM]._qmsg == QUEST_MUSH10 && PlrHasItem(v3, IDI_BRAIN, &inv_item_num) ) - { - RemoveInvItem(v3, inv_item_num); - SpawnQuestItem(IDI_SPECELIX, towner[v7]._tx, towner[v7]._ty + 1, 0, 0); - InitQTextMsg(QUEST_MUSH4); - Qtalklist[TOWN_HEALER]._qblkm = -1; - quests[QTYPE_BLKM]._qvar1 = QS_BRAINGIVEN; - } -LABEL_131: - if ( !qtextflag ) - { - TownerTalk(QUEST_PEPIN1); - if ( storeflag ) - { - _LOBYTE(v9) = STORE_HEALER; - goto LABEL_39; - } - } - return; - } - if ( v21 == GetActiveTowner(TOWN_PEGBOY) ) - { - if ( !qtextflag ) - { - TownerTalk(QUEST_WIRT1); - if ( storeflag ) - { - _LOBYTE(v9) = STORE_BOY; - goto LABEL_39; - } - } - return; - } - if ( v21 != GetActiveTowner(TOWN_STORY) ) - { - if ( towner[v7]._ttype == 9 && !qtextflag ) - CowSFX(v3); - return; - } - if ( gbMaxPlayers == 1 ) - { - if ( quests[QTYPE_VB]._qactive == 1 ) - { - if ( !PlrHasItem(v3, IDI_LAZSTAFF, &inv_item_num) ) - goto LABEL_154; - RemoveInvItem(v3, inv_item_num); - quests[QTYPE_VB]._qvar1 = 2; - towner[v7]._tbtcnt = QUEST_STORY1; - towner[v7]._tVar1 = v3; - InitQTextMsg(QUEST_VILE1); - quests[QTYPE_VB]._qactive = 2; - quests[QTYPE_VB]._qlog = 1; - } - else - { - if ( quests[QTYPE_VB]._qactive != 3 || quests[QTYPE_VB]._qvar1 != 7 ) - goto LABEL_154; - quests[QTYPE_VB]._qvar1 = 8; - towner[v7]._tbtcnt = QUEST_STORY1; - towner[v7]._tVar1 = v3; - InitQTextMsg(QUEST_VILE3); - quests[QTYPE_VB]._qlog = 1; - } - v11 = gbMaxPlayers == 1; - towner[v7]._tMsgSaid = 1; - if ( v11 ) - goto LABEL_154; - } - if ( quests[QTYPE_VB]._qactive == 2 ) - { - if ( !quests[QTYPE_VB]._qlog ) - { - towner[v7]._tbtcnt = QUEST_STORY1; - towner[v7]._tVar1 = v3; - InitQTextMsg(QUEST_VILE1); - towner[v7]._tMsgSaid = 1; - quests[QTYPE_VB]._qlog = 1; - v19 = 15; -LABEL_153: - NetSendCmdQuest(TRUE, v19); - goto LABEL_154; - } - } - else if ( quests[QTYPE_VB]._qactive == 3 && quests[QTYPE_VB]._qvar1 == 7 ) - { - quests[QTYPE_VB]._qvar1 = 8; - towner[v7]._tbtcnt = QUEST_STORY1; - towner[v7]._tVar1 = v3; - InitQTextMsg(QUEST_VILE3); - towner[v7]._tMsgSaid = 1; - NetSendCmdQuest(TRUE, 0xFu); - quests[QTYPE_VB]._qlog = 1; - v19 = 5; - goto LABEL_153; - } -LABEL_154: - if ( !qtextflag ) - { - TownerTalk(QUEST_STORY1); - if ( storeflag ) - { - _LOBYTE(v9) = STORE_STORY; - goto LABEL_39; - } - } - return; - } - if ( gbMaxPlayers == 1 ) - { - if ( plr[v6]._pLvlVisited[4] != 0 && quests[QTYPE_INFRA]._qactive ) - { - if ( quests[QTYPE_INFRA]._qvar2 == 0 ) - { - quests[QTYPE_INFRA]._qvar2 = 1; - quests[QTYPE_INFRA]._qlog = 1; - if ( quests[QTYPE_INFRA]._qactive == 1 ) - { - quests[QTYPE_INFRA]._qactive = 2; - quests[QTYPE_INFRA]._qvar1 = 1; - } - towner[v7]._tbtcnt = 150; - towner[v7]._tVar1 = v3; - InitQTextMsg(QUEST_INFRA5); - towner[v7]._tMsgSaid = 1; - } - if ( quests[QTYPE_INFRA]._qvar2 == 1 && PlrHasItem(v3, IDI_ROCK, &inv_item_num) && !towner[v7]._tMsgSaid ) - { - quests[QTYPE_INFRA]._qactive = 3; - quests[QTYPE_INFRA]._qvar2 = 2; - quests[QTYPE_INFRA]._qvar1 = 2; - RemoveInvItem(v3, inv_item_num); - CreateItem(UITEM_INFRARING, towner[v7]._tx, towner[v7]._ty + 1); - towner[v7]._tbtcnt = 150; - towner[v7]._tVar1 = v3; - InitQTextMsg(QUEST_INFRA7); - towner[v7]._tMsgSaid = 1; - } - } - if ( plr[v6]._pLvlVisited[9] && quests[QTYPE_ANVIL]._qactive ) - { - if ( (quests[QTYPE_ANVIL]._qactive == 1 || quests[QTYPE_ANVIL]._qactive == 2) && !quests[QTYPE_ANVIL]._qvar2 ) - { - if ( towner[v7]._tMsgSaid || quests[QTYPE_INFRA]._qvar2 != 2 && (quests[QTYPE_INFRA]._qactive != 2 || quests[QTYPE_INFRA]._qvar2 != 1) ) - goto LABEL_86; - quests[QTYPE_ANVIL]._qvar2 = 1; - quests[QTYPE_ANVIL]._qlog = 1; - if ( quests[QTYPE_ANVIL]._qactive == 1 ) - { - quests[QTYPE_ANVIL]._qactive = 2; - quests[QTYPE_ANVIL]._qvar1 = 1; - } - towner[v7]._tbtcnt = 150; - towner[v7]._tVar1 = v3; - InitQTextMsg(QUEST_ANVIL5); - towner[v7]._tMsgSaid = 1; - } - if ( quests[QTYPE_ANVIL]._qvar2 == 1 && PlrHasItem(v3, IDI_ANVIL, &inv_item_num) && !towner[v7]._tMsgSaid ) - { - quests[QTYPE_ANVIL]._qactive = 3; - quests[QTYPE_ANVIL]._qvar2 = 2; - quests[QTYPE_ANVIL]._qvar1 = 2; - RemoveInvItem(v3, inv_item_num); - CreateItem(UITEM_GRISWOLD, towner[v7]._tx, towner[v7]._ty + 1); - towner[v7]._tbtcnt = 150; - towner[v7]._tVar1 = v3; - InitQTextMsg(QUEST_ANVIL7); - towner[v7]._tMsgSaid = 1; - } - } - } + int v2; // ebx + int v3; // edi + int v6; // ebp + int v7; // esi + int v8; // eax + int v9; // ecx + //char v10; // cl + bool v11; // zf + int v12; // edi + //int v13; // eax + //int v14; // eax + //int v15; // eax + //char v16; // cl + _speech_id v17; // ecx + ItemStruct *Item; // ebp + unsigned char v19; // dl + int inv_item_num; // [esp+10h] [ebp-8h] + int v21; // [esp+14h] [ebp-4h] + + v2 = t; + v3 = p; + v21 = t; + random(6, 3); /* figure out what these are for */ + random(6, 4); + random(6, 5); + v6 = v3; + v7 = v2; + inv_item_num = abs(plr[v3].WorldX - towner[v2]._tx); + v8 = abs(plr[v3].WorldY - towner[v2]._ty); + if (inv_item_num >= 2) + return; + if (v8 >= 2) + return; + if (qtextflag) + return; + towner[v7]._tMsgSaid = 0; + if (pcurs >= CURSOR_FIRSTITEM && !DropItemBeforeTrig()) + return; + if (v2 == GetActiveTowner(TOWN_TAVERN)) { + if (!plr[v6]._pLvlVisited[0] && !towner[v7]._tMsgSaid) { + towner[v7]._tbtcnt = 150; + towner[v7]._tVar1 = v3; + InitQTextMsg(QUEST_INTRO); + towner[v7]._tMsgSaid = 1; + } + if ((plr[v6]._pLvlVisited[2] || plr[v6]._pLvlVisited[4]) && quests[QTYPE_KING]._qactive) { + if (!quests[QTYPE_KING]._qvar2 && !towner[v7]._tMsgSaid) { + quests[QTYPE_KING]._qvar2 = 1; + quests[QTYPE_KING]._qlog = 1; + if (quests[QTYPE_KING]._qactive == 1) { + quests[QTYPE_KING]._qactive = 2; + quests[QTYPE_KING]._qvar1 = 1; + } + towner[v7]._tbtcnt = 150; + towner[v7]._tVar1 = v3; + InitQTextMsg(QUEST_KING2); + towner[v7]._tMsgSaid = 1; + NetSendCmdQuest(TRUE, 0xCu); + } + if (quests[QTYPE_KING]._qactive == 3 && quests[QTYPE_KING]._qvar2 == 1 && !towner[v7]._tMsgSaid) { + quests[QTYPE_KING]._qvar2 = 2; + quests[QTYPE_KING]._qvar1 = 2; + towner[v7]._tbtcnt = 150; + towner[v7]._tVar1 = v3; + InitQTextMsg(QUEST_KING4); + towner[v7]._tMsgSaid = 1; + NetSendCmdQuest(TRUE, 0xCu); + } + } + if (gbMaxPlayers == 1 && plr[v6]._pLvlVisited[3] && quests[QTYPE_BOL]._qactive) { + if ((quests[QTYPE_BOL]._qactive == 1 || quests[QTYPE_BOL]._qactive == 2) && !quests[QTYPE_BOL]._qvar2) { + if (towner[v7]._tMsgSaid) + goto LABEL_36; + quests[QTYPE_BOL]._qvar2 = 1; + if (quests[QTYPE_BOL]._qactive == 1) { + quests[QTYPE_BOL]._qvar1 = 1; + quests[QTYPE_BOL]._qactive = 2; + } + quests[QTYPE_BOL]._qlog = 1; + towner[v7]._tbtcnt = 150; + towner[v7]._tVar1 = v3; + InitQTextMsg(QUEST_BANNER2); + towner[v7]._tMsgSaid = 1; + } + if (quests[QTYPE_BOL]._qvar2 == 1 && PlrHasItem(v3, IDI_BANNER, &inv_item_num) && !towner[v7]._tMsgSaid) { + quests[QTYPE_BOL]._qactive = 3; + quests[QTYPE_BOL]._qvar1 = 3; + RemoveInvItem(v3, inv_item_num); + CreateItem(UITEM_HARCREST, towner[v7]._tx, towner[v7]._ty + 1); + towner[v7]._tbtcnt = 150; + towner[v7]._tVar1 = v3; + InitQTextMsg(QUEST_BANNER3); + towner[v7]._tMsgSaid = 1; + } + } + LABEL_36: + if (!qtextflag) { + TownerTalk(QUEST_OGDEN1); + if (storeflag) { + _LOBYTE(v9) = STORE_TAVERN; + LABEL_39: + StartStore(v9); + return; + } + } + return; + } + if (v2 == GetActiveTowner(TOWN_DEADGUY)) { + if (quests[QTYPE_BUTCH]._qactive == 2) { + if (quests[QTYPE_BUTCH]._qvar1 == 1) { + towner[v7]._tbtcnt = 150; + towner[v7]._tVar1 = v3; + quests[QTYPE_BUTCH]._qvar1 = 1; + if (plr[v6]._pClass == PC_WARRIOR && (v12 = PS_WARR8, !effect_is_playing(PS_WARR8)) + || plr[v6]._pClass == PC_ROGUE && (v12 = PS_ROGUE8, !effect_is_playing(PS_ROGUE8)) + || plr[v6]._pClass == PC_SORCERER && (v12 = PS_MAGE8, !effect_is_playing(PS_MAGE8))) { + PlaySFX(v12); + } + LABEL_53: + towner[v7]._tMsgSaid = 1; + return; + } + if (quests[QTYPE_BUTCH]._qvar1) + return; + } else { + if (quests[QTYPE_BUTCH]._qactive == 3) { + if (quests[QTYPE_BUTCH]._qvar1 != 1) + return; + quests[QTYPE_BUTCH]._qvar1 = 1; + towner[v7]._tbtcnt = 150; + towner[v7]._tVar1 = v3; + goto LABEL_53; + } + if (quests[QTYPE_BUTCH]._qactive != 1) + return; + } + quests[QTYPE_BUTCH]._qactive = 2; + quests[QTYPE_BUTCH]._qlog = 1; + quests[QTYPE_BUTCH]._qmsg = QUEST_BUTCH9; + quests[QTYPE_BUTCH]._qvar1 = 1; + towner[v7]._tbtcnt = 50; + towner[v7]._tVar1 = v3; + towner[v7]._tVar2 = 3; + InitQTextMsg(QUEST_BUTCH9); + towner[v7]._tMsgSaid = 1; + NetSendCmdQuest(TRUE, 6u); + return; + } + if (v2 != GetActiveTowner(0)) { + if (v2 == GetActiveTowner(TOWN_WITCH)) { + if (quests[QTYPE_BLKM]._qactive == 1) { + if (PlrHasItem(v3, IDI_FUNGALTM, &inv_item_num)) { + RemoveInvItem(v3, inv_item_num); + quests[QTYPE_BLKM]._qactive = 2; + quests[QTYPE_BLKM]._qlog = 1; + quests[QTYPE_BLKM]._qvar1 = QS_TOMEGIVEN; + v17 = QUEST_MUSH8; + LABEL_105: + towner[v7]._tVar1 = v3; + towner[v7]._tbtcnt = 150; + InitQTextMsg(v17); + towner[v7]._tMsgSaid = 1; + goto LABEL_106; + } + } else if (quests[QTYPE_BLKM]._qactive == 2) { + if (quests[QTYPE_BLKM]._qvar1 >= QS_TOMEGIVEN && quests[QTYPE_BLKM]._qvar1 <= QS_MUSHPICKED) { + if (PlrHasItem(v3, IDI_MUSHROOM, &inv_item_num)) { + RemoveInvItem(v3, inv_item_num); + Qtalklist[TOWN_WITCH]._qblkm = -1; + quests[QTYPE_BLKM]._qvar1 = QS_MUSHGIVEN; + Qtalklist[TOWN_HEALER]._qblkm = QUEST_MUSH3; + v17 = QUEST_MUSH10; + } else { + v17 = QUEST_MUSH9; + if (quests[QTYPE_BLKM]._qmsg == QUEST_MUSH9) + goto LABEL_106; + } + quests[QTYPE_BLKM]._qmsg = v17; + goto LABEL_105; + } + Item = PlrHasItem(v3, IDI_SPECELIX, &inv_item_num); + if (Item) { + towner[v7]._tbtcnt = 150; + towner[v7]._tVar1 = v3; + InitQTextMsg(QUEST_MUSH12); + quests[QTYPE_BLKM]._qactive = 3; + towner[v7]._tMsgSaid = 1; + AllItemsList[Item->IDidx].iUsable = 1; + } else if (PlrHasItem(v3, IDI_BRAIN, &inv_item_num)) { + v17 = QUEST_MUSH11; + if (quests[QTYPE_BLKM]._qvar2 != QUEST_MUSH11) { + quests[QTYPE_BLKM]._qvar2 = QUEST_MUSH11; + goto LABEL_105; + } + } + } + LABEL_106: + if (!qtextflag) { + TownerTalk(QUEST_ADRIA1); + if (storeflag) { + _LOBYTE(v9) = STORE_WITCH; + goto LABEL_39; + } + } + return; + } + if (v2 == GetActiveTowner(TOWN_BMAID)) { + if (!qtextflag) { + TownerTalk(QUEST_GILLIAN1); + if (storeflag) { + _LOBYTE(v9) = STORE_BARMAID; + goto LABEL_39; + } + } + return; + } + if (v2 == GetActiveTowner(TOWN_DRUNK)) { + if (!qtextflag) { + TownerTalk(QUEST_FARNHAM1); + if (storeflag) { + _LOBYTE(v9) = STORE_DRUNK; + goto LABEL_39; + } + } + return; + } + if (v21 == GetActiveTowner(1)) { + if (gbMaxPlayers != 1) + goto LABEL_131; + if (plr[v6]._pLvlVisited[1] && !towner[v7]._tMsgSaid) { + if (quests[QTYPE_PW]._qactive == 1) { + quests[QTYPE_PW]._qactive = 2; + quests[QTYPE_PW]._qlog = 1; + quests[QTYPE_PW]._qmsg = QUEST_POISON3; + quests[QTYPE_PW]._qvar1 = 1; + towner[v7]._tbtcnt = 150; + towner[v7]._tVar1 = v3; + InitQTextMsg(QUEST_POISON3); + LABEL_126: + towner[v7]._tMsgSaid = 1; + goto LABEL_127; + } + if (quests[QTYPE_PW]._qactive == 3 && quests[QTYPE_PW]._qvar1 != 2) { + quests[QTYPE_PW]._qvar1 = 2; + towner[v7]._tbtcnt = 150; + towner[v7]._tVar1 = v3; + InitQTextMsg(QUEST_POISON5); + CreateItem(UITEM_TRING, towner[v7]._tx, towner[v7]._ty + 1); + goto LABEL_126; + } + } + LABEL_127: + if (quests[QTYPE_BLKM]._qactive == 2 && quests[QTYPE_BLKM]._qmsg == QUEST_MUSH10 && PlrHasItem(v3, IDI_BRAIN, &inv_item_num)) { + RemoveInvItem(v3, inv_item_num); + SpawnQuestItem(IDI_SPECELIX, towner[v7]._tx, towner[v7]._ty + 1, 0, 0); + InitQTextMsg(QUEST_MUSH4); + Qtalklist[TOWN_HEALER]._qblkm = -1; + quests[QTYPE_BLKM]._qvar1 = QS_BRAINGIVEN; + } + LABEL_131: + if (!qtextflag) { + TownerTalk(QUEST_PEPIN1); + if (storeflag) { + _LOBYTE(v9) = STORE_HEALER; + goto LABEL_39; + } + } + return; + } + if (v21 == GetActiveTowner(TOWN_PEGBOY)) { + if (!qtextflag) { + TownerTalk(QUEST_WIRT1); + if (storeflag) { + _LOBYTE(v9) = STORE_BOY; + goto LABEL_39; + } + } + return; + } + if (v21 != GetActiveTowner(TOWN_STORY)) { + if (towner[v7]._ttype == 9 && !qtextflag) + CowSFX(v3); + return; + } + if (gbMaxPlayers == 1) { + if (quests[QTYPE_VB]._qactive == 1) { + if (!PlrHasItem(v3, IDI_LAZSTAFF, &inv_item_num)) + goto LABEL_154; + RemoveInvItem(v3, inv_item_num); + quests[QTYPE_VB]._qvar1 = 2; + towner[v7]._tbtcnt = QUEST_STORY1; + towner[v7]._tVar1 = v3; + InitQTextMsg(QUEST_VILE1); + quests[QTYPE_VB]._qactive = 2; + quests[QTYPE_VB]._qlog = 1; + } else { + if (quests[QTYPE_VB]._qactive != 3 || quests[QTYPE_VB]._qvar1 != 7) + goto LABEL_154; + quests[QTYPE_VB]._qvar1 = 8; + towner[v7]._tbtcnt = QUEST_STORY1; + towner[v7]._tVar1 = v3; + InitQTextMsg(QUEST_VILE3); + quests[QTYPE_VB]._qlog = 1; + } + v11 = gbMaxPlayers == 1; + towner[v7]._tMsgSaid = 1; + if (v11) + goto LABEL_154; + } + if (quests[QTYPE_VB]._qactive == 2) { + if (!quests[QTYPE_VB]._qlog) { + towner[v7]._tbtcnt = QUEST_STORY1; + towner[v7]._tVar1 = v3; + InitQTextMsg(QUEST_VILE1); + towner[v7]._tMsgSaid = 1; + quests[QTYPE_VB]._qlog = 1; + v19 = 15; + LABEL_153: + NetSendCmdQuest(TRUE, v19); + goto LABEL_154; + } + } else if (quests[QTYPE_VB]._qactive == 3 && quests[QTYPE_VB]._qvar1 == 7) { + quests[QTYPE_VB]._qvar1 = 8; + towner[v7]._tbtcnt = QUEST_STORY1; + towner[v7]._tVar1 = v3; + InitQTextMsg(QUEST_VILE3); + towner[v7]._tMsgSaid = 1; + NetSendCmdQuest(TRUE, 0xFu); + quests[QTYPE_VB]._qlog = 1; + v19 = 5; + goto LABEL_153; + } + LABEL_154: + if (!qtextflag) { + TownerTalk(QUEST_STORY1); + if (storeflag) { + _LOBYTE(v9) = STORE_STORY; + goto LABEL_39; + } + } + return; + } + if (gbMaxPlayers == 1) { + if (plr[v6]._pLvlVisited[4] != 0 && quests[QTYPE_INFRA]._qactive) { + if (quests[QTYPE_INFRA]._qvar2 == 0) { + quests[QTYPE_INFRA]._qvar2 = 1; + quests[QTYPE_INFRA]._qlog = 1; + if (quests[QTYPE_INFRA]._qactive == 1) { + quests[QTYPE_INFRA]._qactive = 2; + quests[QTYPE_INFRA]._qvar1 = 1; + } + towner[v7]._tbtcnt = 150; + towner[v7]._tVar1 = v3; + InitQTextMsg(QUEST_INFRA5); + towner[v7]._tMsgSaid = 1; + } + if (quests[QTYPE_INFRA]._qvar2 == 1 && PlrHasItem(v3, IDI_ROCK, &inv_item_num) && !towner[v7]._tMsgSaid) { + quests[QTYPE_INFRA]._qactive = 3; + quests[QTYPE_INFRA]._qvar2 = 2; + quests[QTYPE_INFRA]._qvar1 = 2; + RemoveInvItem(v3, inv_item_num); + CreateItem(UITEM_INFRARING, towner[v7]._tx, towner[v7]._ty + 1); + towner[v7]._tbtcnt = 150; + towner[v7]._tVar1 = v3; + InitQTextMsg(QUEST_INFRA7); + towner[v7]._tMsgSaid = 1; + } + } + if (plr[v6]._pLvlVisited[9] && quests[QTYPE_ANVIL]._qactive) { + if ((quests[QTYPE_ANVIL]._qactive == 1 || quests[QTYPE_ANVIL]._qactive == 2) && !quests[QTYPE_ANVIL]._qvar2) { + if (towner[v7]._tMsgSaid || quests[QTYPE_INFRA]._qvar2 != 2 && (quests[QTYPE_INFRA]._qactive != 2 || quests[QTYPE_INFRA]._qvar2 != 1)) + goto LABEL_86; + quests[QTYPE_ANVIL]._qvar2 = 1; + quests[QTYPE_ANVIL]._qlog = 1; + if (quests[QTYPE_ANVIL]._qactive == 1) { + quests[QTYPE_ANVIL]._qactive = 2; + quests[QTYPE_ANVIL]._qvar1 = 1; + } + towner[v7]._tbtcnt = 150; + towner[v7]._tVar1 = v3; + InitQTextMsg(QUEST_ANVIL5); + towner[v7]._tMsgSaid = 1; + } + if (quests[QTYPE_ANVIL]._qvar2 == 1 && PlrHasItem(v3, IDI_ANVIL, &inv_item_num) && !towner[v7]._tMsgSaid) { + quests[QTYPE_ANVIL]._qactive = 3; + quests[QTYPE_ANVIL]._qvar2 = 2; + quests[QTYPE_ANVIL]._qvar1 = 2; + RemoveInvItem(v3, inv_item_num); + CreateItem(UITEM_GRISWOLD, towner[v7]._tx, towner[v7]._ty + 1); + towner[v7]._tbtcnt = 150; + towner[v7]._tVar1 = v3; + InitQTextMsg(QUEST_ANVIL7); + towner[v7]._tMsgSaid = 1; + } + } + } LABEL_86: - if ( !qtextflag ) - { - TownerTalk(QUEST_GRISWOLD1); - if ( storeflag ) - { - _LOBYTE(v9) = 1; - goto LABEL_39; - } - } + if (!qtextflag) { + TownerTalk(QUEST_GRISWOLD1); + if (storeflag) { + _LOBYTE(v9) = 1; + goto LABEL_39; + } + } } // 646D00: using guessed type char qtextflag; // 679660: using guessed type char gbMaxPlayers; @@ -1470,22 +1318,18 @@ LABEL_86: void __fastcall CowSFX(int pnum) { - if ( CowPlaying == -1 || !effect_is_playing(CowPlaying) ) - { - if ( sgdwCowClicks++ < 8 ) - { - CowPlaying = (sgdwCowClicks == 4) + TSFX_COW1; - } - else - { - PlaySfxLoc(TSFX_COW1, plr[pnum].WorldX, plr[pnum].WorldY + 5); - sgdwCowClicks = 4; - CowPlaying = snSFX[sgnCowMsg][plr[pnum]._pClass]; /* snSFX is local */ - if ( sgnCowMsg++ >= 2 ) - sgnCowMsg = 0; - } - PlaySfxLoc(CowPlaying, plr[pnum].WorldX, plr[pnum].WorldY); - } + if (CowPlaying == -1 || !effect_is_playing(CowPlaying)) { + if (sgdwCowClicks++ < 8) { + CowPlaying = (sgdwCowClicks == 4) + TSFX_COW1; + } else { + PlaySfxLoc(TSFX_COW1, plr[pnum].WorldX, plr[pnum].WorldY + 5); + sgdwCowClicks = 4; + CowPlaying = snSFX[sgnCowMsg][plr[pnum]._pClass]; /* snSFX is local */ + if (sgnCowMsg++ >= 2) + sgnCowMsg = 0; + } + PlaySfxLoc(CowPlaying, plr[pnum].WorldX, plr[pnum].WorldY); + } } // 6AAC1C: using guessed type int sgnCowMsg; // 6AAC24: using guessed type int sgdwCowClicks; diff --git a/Source/towners.h b/Source/towners.h index 32dd4837d..93904b0c9 100644 --- a/Source/towners.h +++ b/Source/towners.h @@ -2,13 +2,13 @@ #ifndef __TOWNERS_H__ #define __TOWNERS_H__ -extern int storeflag; // weak -extern int sgnCowMsg; // weak -extern int numtowners; // idb +extern int storeflag; // weak +extern int sgnCowMsg; // weak +extern int numtowners; // idb extern int sgdwCowClicks; // weak -extern int bannerflag; // weak // unused 0x6AAC28 -extern int boyloadflag; // weak -extern void *pCowCels; // idb +extern int bannerflag; // weak // unused 0x6AAC28 +extern int boyloadflag; // weak +extern void *pCowCels; // idb extern TownerStruct towner[16]; int __fastcall GetActiveTowner(int t);