diff --git a/.clang-format b/.clang-format index fe04430a..6c69a182 100644 --- a/.clang-format +++ b/.clang-format @@ -5,4 +5,6 @@ AllowShortFunctionsOnASingleLine: None, PointerAlignment: Right, AlignConsecutiveAssignments: true, + TabWidth: 4, + UseTab: ForIndentation, } diff --git a/.editorconfig b/.editorconfig index 2ac87f02..c90d5fd9 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,13 +1,11 @@ root = true [*] -indent_style = space -indent_size = 4 +indent_style = tab end_of_line = crlf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [*.sh] -indent_style = tab end_of_line = lf diff --git a/Source/.clang-format b/Source/.clang-format index cf3be358..7b78b700 100644 --- a/Source/.clang-format +++ b/Source/.clang-format @@ -1,7 +1,9 @@ { - BasedOnStyle: webkit, - AlignTrailingComments: true, - AllowShortBlocksOnASingleLine: true, - AllowShortFunctionsOnASingleLine: None, - PointerAlignment: Right, + BasedOnStyle: webkit, + AlignTrailingComments: true, + AllowShortBlocksOnASingleLine: true, + AllowShortFunctionsOnASingleLine: None, + PointerAlignment: Right, + TabWidth: 4, + UseTab: ForIndentation, } diff --git a/Source/_asm.cpp b/Source/_asm.cpp index 628648e9..00ee1993 100644 --- a/Source/_asm.cpp +++ b/Source/_asm.cpp @@ -10,112 +10,112 @@ static inline unsigned int asm_trans_light_mask(unsigned char w, BYTE *tbl, BYTE static inline void asm_cel_light_edge(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src) { - unsigned char l = w >> 1; + unsigned char l = w >> 1; - if (w & 1) { - dst[0] = tbl[src[0]]; - src++; - dst++; - } - if (l & 1) { - dst[0] = tbl[src[0]]; - dst[1] = tbl[src[1]]; - src += 2; - dst += 2; - } + if (w & 1) { + dst[0] = tbl[src[0]]; + src++; + dst++; + } + if (l & 1) { + dst[0] = tbl[src[0]]; + dst[1] = tbl[src[1]]; + src += 2; + dst += 2; + } - asm_cel_light_square(l >> 1, tbl, dst, src); + asm_cel_light_square(l >> 1, tbl, dst, src); } static inline void asm_cel_light_square(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src) { - for (; w; --w) { - dst[0] = tbl[src[0]]; - dst[1] = tbl[src[1]]; - dst[2] = tbl[src[2]]; - dst[3] = tbl[src[3]]; - src += 4; - dst += 4; - } + for (; w; --w) { + dst[0] = tbl[src[0]]; + dst[1] = tbl[src[1]]; + dst[2] = tbl[src[2]]; + dst[3] = tbl[src[3]]; + src += 4; + dst += 4; + } } static inline void asm_trans_light_cel_0_2(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src) { - if (!(w & 1)) { - asm_trans_light_edge_1_3(w >> 1, tbl, dst, src); - } else { - src++; - dst++; - asm_trans_light_edge_0_2(w >> 1, tbl, dst, src); - } + if (!(w & 1)) { + asm_trans_light_edge_1_3(w >> 1, tbl, dst, src); + } else { + src++; + dst++; + asm_trans_light_edge_0_2(w >> 1, tbl, dst, src); + } } static inline void asm_trans_light_edge_0_2(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src) { - unsigned char l = w >> 1; + unsigned char l = w >> 1; - if (w & 1) { - dst[0] = tbl[src[0]]; - src += 2; - dst += 2; - } - if (l) { - asm_trans_light_square_0_2(l, tbl, dst, src); - } + if (w & 1) { + dst[0] = tbl[src[0]]; + src += 2; + dst += 2; + } + if (l) { + asm_trans_light_square_0_2(l, tbl, dst, src); + } } static inline void asm_trans_light_square_0_2(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src) { - for (; w; --w) { - dst[0] = tbl[src[0]]; - dst[2] = tbl[src[2]]; - src += 4; - dst += 4; - } + for (; w; --w) { + dst[0] = tbl[src[0]]; + dst[2] = tbl[src[2]]; + src += 4; + dst += 4; + } } static inline void asm_trans_light_cel_1_3(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src) { - if (!(w & 1)) { - asm_trans_light_edge_0_2(w >> 1, tbl, dst, src); - } else { - dst[0] = tbl[src[0]]; - src++; - dst++; - asm_trans_light_edge_1_3(w >> 1, tbl, dst, src); - } + if (!(w & 1)) { + asm_trans_light_edge_0_2(w >> 1, tbl, dst, src); + } else { + dst[0] = tbl[src[0]]; + src++; + dst++; + asm_trans_light_edge_1_3(w >> 1, tbl, dst, src); + } } static inline void asm_trans_light_edge_1_3(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src) { - unsigned char l = w >> 1; + unsigned char l = w >> 1; - if (w & 1) { - dst[1] = tbl[src[1]]; - src += 2; - dst += 2; - } - if (l) { - asm_trans_light_square_1_3(l, tbl, dst, src); - } + if (w & 1) { + dst[1] = tbl[src[1]]; + src += 2; + dst += 2; + } + if (l) { + asm_trans_light_square_1_3(l, tbl, dst, src); + } } static inline void asm_trans_light_square_1_3(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src) { - for (; w; --w) { - dst[1] = tbl[src[1]]; - dst[3] = tbl[src[3]]; - src += 4; - dst += 4; - } + for (; w; --w) { + dst[1] = tbl[src[1]]; + dst[3] = tbl[src[3]]; + src += 4; + dst += 4; + } } static inline unsigned int asm_trans_light_mask(unsigned char w, BYTE *tbl, BYTE *&dst, BYTE *&src, unsigned int mask) { - for (; w; --w, src++, dst++, mask *= 2) { - if (mask & 0x80000000) - dst[0] = tbl[src[0]]; - } + for (; w; --w, src++, dst++, mask *= 2) { + if (mask & 0x80000000) + dst[0] = tbl[src[0]]; + } return mask; } diff --git a/Source/appfat.cpp b/Source/appfat.cpp index dd554d36..25370043 100644 --- a/Source/appfat.cpp +++ b/Source/appfat.cpp @@ -12,235 +12,235 @@ char empty_string; // appfat_cpp_init initializes the C++ runtime of appfat.cpp. struct appfat_cpp_init { - appfat_cpp_init() - { - appfat_cpp_init_value = INFINITY; - } + appfat_cpp_init() + { + appfat_cpp_init_value = INFINITY; + } } appfat_cpp_init; // delete overloads the delete operator. void operator delete(void *ptr) { - if (ptr != NULL) { - SMemFree(ptr, "delete", -1, 0); - } + if (ptr != NULL) { + SMemFree(ptr, "delete", -1, 0); + } } char *__fastcall GetErrorStr(int error_code) { - int v1; // edi - unsigned int v2; // eax - signed int v4; // eax - char *i; // ecx + int v1; // edi + unsigned int v2; // eax + signed int v4; // eax + char *i; // ecx - v1 = error_code; - v2 = ((unsigned int)error_code >> 16) & 0x1FFF; - if (v2 == 0x0878) { - TraceErrorDS(error_code, sz_error_buf, 256); - } else if (v2 == 0x0876) { - TraceErrorDD(error_code, sz_error_buf, 256); - } else { - if (!SErrGetErrorStr(error_code, sz_error_buf, 256) && !FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, v1, 0x400u, sz_error_buf, 0x100u, NULL)) - wsprintf(sz_error_buf, "unknown error 0x%08x", v1); - } - v4 = strlen(sz_error_buf); - for (i = &sz_error_buf[v4 - 1]; v4 > 0; *i = 0) { - --v4; - --i; - if (*i != '\r' && *i != '\n') - break; - } - return sz_error_buf; + v1 = error_code; + v2 = ((unsigned int)error_code >> 16) & 0x1FFF; + if (v2 == 0x0878) { + TraceErrorDS(error_code, sz_error_buf, 256); + } else if (v2 == 0x0876) { + TraceErrorDD(error_code, sz_error_buf, 256); + } else { + if (!SErrGetErrorStr(error_code, sz_error_buf, 256) && !FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, v1, 0x400u, sz_error_buf, 0x100u, NULL)) + wsprintf(sz_error_buf, "unknown error 0x%08x", v1); + } + v4 = strlen(sz_error_buf); + for (i = &sz_error_buf[v4 - 1]; v4 > 0; *i = 0) { + --v4; + --i; + if (*i != '\r' && *i != '\n') + break; + } + return sz_error_buf; } #define CASE_ERROR(v, errName) \ - case errName: \ - v = #errName; \ - break; + case errName: \ + v = #errName; \ + break; void __fastcall TraceErrorDD(int error_code, char *error_buf, int error_buf_len) { - const char *v3; // eax - char v4[20]; // [esp+0h] [ebp-14h] + const char *v3; // eax + char v4[20]; // [esp+0h] [ebp-14h] - switch (error_code) { - CASE_ERROR(v3, DDERR_CANTPAGEUNLOCK); - CASE_ERROR(v3, DDERR_NOTPAGELOCKED); - CASE_ERROR(v3, DD_OK); - CASE_ERROR(v3, DDERR_CANTPAGELOCK); - CASE_ERROR(v3, DDERR_BLTFASTCANTCLIP); - CASE_ERROR(v3, DDERR_NOBLTHW); - CASE_ERROR(v3, DDERR_NODDROPSHW); - CASE_ERROR(v3, DDERR_OVERLAYNOTVISIBLE); - CASE_ERROR(v3, DDERR_NOOVERLAYDEST); - CASE_ERROR(v3, DDERR_INVALIDPOSITION); - CASE_ERROR(v3, DDERR_NOTAOVERLAYSURFACE); - CASE_ERROR(v3, DDERR_EXCLUSIVEMODEALREADYSET); - CASE_ERROR(v3, DDERR_NOTFLIPPABLE); - CASE_ERROR(v3, DDERR_CANTDUPLICATE); - CASE_ERROR(v3, DDERR_NOTLOCKED); - CASE_ERROR(v3, DDERR_CANTCREATEDC); - CASE_ERROR(v3, DDERR_NODC); - CASE_ERROR(v3, DDERR_WRONGMODE); - CASE_ERROR(v3, DDERR_IMPLICITLYCREATED); - CASE_ERROR(v3, DDERR_NOTPALETTIZED); - CASE_ERROR(v3, DDERR_NOMIPMAPHW); - CASE_ERROR(v3, DDERR_INVALIDSURFACETYPE); - CASE_ERROR(v3, DDERR_DCALREADYCREATED); - CASE_ERROR(v3, DDERR_NOPALETTEHW); - CASE_ERROR(v3, DDERR_DIRECTDRAWALREADYCREATED); - CASE_ERROR(v3, DDERR_NODIRECTDRAWHW); - CASE_ERROR(v3, DDERR_PRIMARYSURFACEALREADYEXISTS); - CASE_ERROR(v3, DDERR_NOEMULATION); - CASE_ERROR(v3, DDERR_REGIONTOOSMALL); - CASE_ERROR(v3, DDERR_CLIPPERISUSINGHWND); - CASE_ERROR(v3, DDERR_NOCLIPPERATTACHED); - CASE_ERROR(v3, DDERR_NOHWND); - CASE_ERROR(v3, DDERR_HWNDSUBCLASSED); - CASE_ERROR(v3, DDERR_HWNDALREADYSET); - CASE_ERROR(v3, DDERR_NOPALETTEATTACHED); - CASE_ERROR(v3, DDERR_INVALIDDIRECTDRAWGUID); - CASE_ERROR(v3, DDERR_UNSUPPORTEDFORMAT); - CASE_ERROR(v3, DDERR_UNSUPPORTEDMASK); - CASE_ERROR(v3, DDERR_VERTICALBLANKINPROGRESS); - CASE_ERROR(v3, DDERR_WASSTILLDRAWING); - CASE_ERROR(v3, DDERR_XALIGN); - CASE_ERROR(v3, DDERR_TOOBIGWIDTH); - CASE_ERROR(v3, DDERR_CANTLOCKSURFACE); - CASE_ERROR(v3, DDERR_SURFACEISOBSCURED); - CASE_ERROR(v3, DDERR_SURFACELOST); - CASE_ERROR(v3, DDERR_SURFACENOTATTACHED); - CASE_ERROR(v3, DDERR_TOOBIGHEIGHT); - CASE_ERROR(v3, DDERR_TOOBIGSIZE); - CASE_ERROR(v3, DDERR_SURFACEBUSY); - CASE_ERROR(v3, DDERR_OVERLAYCOLORKEYONLYONEACTIVE); - CASE_ERROR(v3, DDERR_PALETTEBUSY); - CASE_ERROR(v3, DDERR_COLORKEYNOTSET); - CASE_ERROR(v3, DDERR_SURFACEALREADYATTACHED); - CASE_ERROR(v3, DDERR_SURFACEALREADYDEPENDENT); - CASE_ERROR(v3, DDERR_OVERLAYCANTCLIP); - CASE_ERROR(v3, DDERR_NOVSYNCHW); - CASE_ERROR(v3, DDERR_NOZBUFFERHW); - CASE_ERROR(v3, DDERR_NOZOVERLAYHW); - CASE_ERROR(v3, DDERR_OUTOFCAPS); - CASE_ERROR(v3, DDERR_OUTOFVIDEOMEMORY); - CASE_ERROR(v3, DDERR_NOTEXTUREHW); - CASE_ERROR(v3, DDERR_NOROTATIONHW); - CASE_ERROR(v3, DDERR_NOSTRETCHHW); - CASE_ERROR(v3, DDERR_NOT4BITCOLOR); - CASE_ERROR(v3, DDERR_NOT4BITCOLORINDEX); - CASE_ERROR(v3, DDERR_NOT8BITCOLOR); - CASE_ERROR(v3, DDERR_NORASTEROPHW); - CASE_ERROR(v3, DDERR_NOEXCLUSIVEMODE); - CASE_ERROR(v3, DDERR_NOFLIPHW); - CASE_ERROR(v3, DDERR_NOGDI); - CASE_ERROR(v3, DDERR_NOMIRRORHW); - CASE_ERROR(v3, DDERR_NOTFOUND); - CASE_ERROR(v3, DDERR_NOOVERLAYHW); - CASE_ERROR(v3, DDERR_NOCOLORKEYHW); - CASE_ERROR(v3, DDERR_NOALPHAHW); - CASE_ERROR(v3, DDERR_NOCLIPLIST); - CASE_ERROR(v3, DDERR_NOCOLORCONVHW); - CASE_ERROR(v3, DDERR_NOCOOPERATIVELEVELSET); - CASE_ERROR(v3, DDERR_NOCOLORKEY); - CASE_ERROR(v3, DDERR_NO3D); - CASE_ERROR(v3, DDERR_INVALIDMODE); - CASE_ERROR(v3, DDERR_INVALIDOBJECT); - CASE_ERROR(v3, DDERR_INVALIDPIXELFORMAT); - CASE_ERROR(v3, DDERR_INVALIDRECT); - CASE_ERROR(v3, DDERR_LOCKEDSURFACES); - CASE_ERROR(v3, DDERR_INVALIDCLIPLIST); - CASE_ERROR(v3, DDERR_CURRENTLYNOTAVAIL); - CASE_ERROR(v3, DDERR_EXCEPTION); - CASE_ERROR(v3, DDERR_HEIGHTALIGN); - CASE_ERROR(v3, DDERR_INCOMPATIBLEPRIMARY); - CASE_ERROR(v3, DDERR_INVALIDCAPS); - CASE_ERROR(v3, DDERR_CANNOTDETACHSURFACE); - CASE_ERROR(v3, DDERR_UNSUPPORTED); - CASE_ERROR(v3, DDERR_GENERIC); - CASE_ERROR(v3, DDERR_OUTOFMEMORY); - CASE_ERROR(v3, DDERR_INVALIDPARAMS); - CASE_ERROR(v3, DDERR_ALREADYINITIALIZED); - CASE_ERROR(v3, DDERR_CANNOTATTACHSURFACE); - default: - strcpy(v4, "DDERR unknown 0x%x"); - sprintf(error_buf, v4, error_code); - return; - } - strncpy(error_buf, v3, error_buf_len); + switch (error_code) { + CASE_ERROR(v3, DDERR_CANTPAGEUNLOCK); + CASE_ERROR(v3, DDERR_NOTPAGELOCKED); + CASE_ERROR(v3, DD_OK); + CASE_ERROR(v3, DDERR_CANTPAGELOCK); + CASE_ERROR(v3, DDERR_BLTFASTCANTCLIP); + CASE_ERROR(v3, DDERR_NOBLTHW); + CASE_ERROR(v3, DDERR_NODDROPSHW); + CASE_ERROR(v3, DDERR_OVERLAYNOTVISIBLE); + CASE_ERROR(v3, DDERR_NOOVERLAYDEST); + CASE_ERROR(v3, DDERR_INVALIDPOSITION); + CASE_ERROR(v3, DDERR_NOTAOVERLAYSURFACE); + CASE_ERROR(v3, DDERR_EXCLUSIVEMODEALREADYSET); + CASE_ERROR(v3, DDERR_NOTFLIPPABLE); + CASE_ERROR(v3, DDERR_CANTDUPLICATE); + CASE_ERROR(v3, DDERR_NOTLOCKED); + CASE_ERROR(v3, DDERR_CANTCREATEDC); + CASE_ERROR(v3, DDERR_NODC); + CASE_ERROR(v3, DDERR_WRONGMODE); + CASE_ERROR(v3, DDERR_IMPLICITLYCREATED); + CASE_ERROR(v3, DDERR_NOTPALETTIZED); + CASE_ERROR(v3, DDERR_NOMIPMAPHW); + CASE_ERROR(v3, DDERR_INVALIDSURFACETYPE); + CASE_ERROR(v3, DDERR_DCALREADYCREATED); + CASE_ERROR(v3, DDERR_NOPALETTEHW); + CASE_ERROR(v3, DDERR_DIRECTDRAWALREADYCREATED); + CASE_ERROR(v3, DDERR_NODIRECTDRAWHW); + CASE_ERROR(v3, DDERR_PRIMARYSURFACEALREADYEXISTS); + CASE_ERROR(v3, DDERR_NOEMULATION); + CASE_ERROR(v3, DDERR_REGIONTOOSMALL); + CASE_ERROR(v3, DDERR_CLIPPERISUSINGHWND); + CASE_ERROR(v3, DDERR_NOCLIPPERATTACHED); + CASE_ERROR(v3, DDERR_NOHWND); + CASE_ERROR(v3, DDERR_HWNDSUBCLASSED); + CASE_ERROR(v3, DDERR_HWNDALREADYSET); + CASE_ERROR(v3, DDERR_NOPALETTEATTACHED); + CASE_ERROR(v3, DDERR_INVALIDDIRECTDRAWGUID); + CASE_ERROR(v3, DDERR_UNSUPPORTEDFORMAT); + CASE_ERROR(v3, DDERR_UNSUPPORTEDMASK); + CASE_ERROR(v3, DDERR_VERTICALBLANKINPROGRESS); + CASE_ERROR(v3, DDERR_WASSTILLDRAWING); + CASE_ERROR(v3, DDERR_XALIGN); + CASE_ERROR(v3, DDERR_TOOBIGWIDTH); + CASE_ERROR(v3, DDERR_CANTLOCKSURFACE); + CASE_ERROR(v3, DDERR_SURFACEISOBSCURED); + CASE_ERROR(v3, DDERR_SURFACELOST); + CASE_ERROR(v3, DDERR_SURFACENOTATTACHED); + CASE_ERROR(v3, DDERR_TOOBIGHEIGHT); + CASE_ERROR(v3, DDERR_TOOBIGSIZE); + CASE_ERROR(v3, DDERR_SURFACEBUSY); + CASE_ERROR(v3, DDERR_OVERLAYCOLORKEYONLYONEACTIVE); + CASE_ERROR(v3, DDERR_PALETTEBUSY); + CASE_ERROR(v3, DDERR_COLORKEYNOTSET); + CASE_ERROR(v3, DDERR_SURFACEALREADYATTACHED); + CASE_ERROR(v3, DDERR_SURFACEALREADYDEPENDENT); + CASE_ERROR(v3, DDERR_OVERLAYCANTCLIP); + CASE_ERROR(v3, DDERR_NOVSYNCHW); + CASE_ERROR(v3, DDERR_NOZBUFFERHW); + CASE_ERROR(v3, DDERR_NOZOVERLAYHW); + CASE_ERROR(v3, DDERR_OUTOFCAPS); + CASE_ERROR(v3, DDERR_OUTOFVIDEOMEMORY); + CASE_ERROR(v3, DDERR_NOTEXTUREHW); + CASE_ERROR(v3, DDERR_NOROTATIONHW); + CASE_ERROR(v3, DDERR_NOSTRETCHHW); + CASE_ERROR(v3, DDERR_NOT4BITCOLOR); + CASE_ERROR(v3, DDERR_NOT4BITCOLORINDEX); + CASE_ERROR(v3, DDERR_NOT8BITCOLOR); + CASE_ERROR(v3, DDERR_NORASTEROPHW); + CASE_ERROR(v3, DDERR_NOEXCLUSIVEMODE); + CASE_ERROR(v3, DDERR_NOFLIPHW); + CASE_ERROR(v3, DDERR_NOGDI); + CASE_ERROR(v3, DDERR_NOMIRRORHW); + CASE_ERROR(v3, DDERR_NOTFOUND); + CASE_ERROR(v3, DDERR_NOOVERLAYHW); + CASE_ERROR(v3, DDERR_NOCOLORKEYHW); + CASE_ERROR(v3, DDERR_NOALPHAHW); + CASE_ERROR(v3, DDERR_NOCLIPLIST); + CASE_ERROR(v3, DDERR_NOCOLORCONVHW); + CASE_ERROR(v3, DDERR_NOCOOPERATIVELEVELSET); + CASE_ERROR(v3, DDERR_NOCOLORKEY); + CASE_ERROR(v3, DDERR_NO3D); + CASE_ERROR(v3, DDERR_INVALIDMODE); + CASE_ERROR(v3, DDERR_INVALIDOBJECT); + CASE_ERROR(v3, DDERR_INVALIDPIXELFORMAT); + CASE_ERROR(v3, DDERR_INVALIDRECT); + CASE_ERROR(v3, DDERR_LOCKEDSURFACES); + CASE_ERROR(v3, DDERR_INVALIDCLIPLIST); + CASE_ERROR(v3, DDERR_CURRENTLYNOTAVAIL); + CASE_ERROR(v3, DDERR_EXCEPTION); + CASE_ERROR(v3, DDERR_HEIGHTALIGN); + CASE_ERROR(v3, DDERR_INCOMPATIBLEPRIMARY); + CASE_ERROR(v3, DDERR_INVALIDCAPS); + CASE_ERROR(v3, DDERR_CANNOTDETACHSURFACE); + CASE_ERROR(v3, DDERR_UNSUPPORTED); + CASE_ERROR(v3, DDERR_GENERIC); + CASE_ERROR(v3, DDERR_OUTOFMEMORY); + CASE_ERROR(v3, DDERR_INVALIDPARAMS); + CASE_ERROR(v3, DDERR_ALREADYINITIALIZED); + CASE_ERROR(v3, DDERR_CANNOTATTACHSURFACE); + default: + strcpy(v4, "DDERR unknown 0x%x"); + sprintf(error_buf, v4, error_code); + return; + } + strncpy(error_buf, v3, error_buf_len); } void __fastcall TraceErrorDS(int error_code, char *error_buf, int error_buf_len) { - const char *v3; // eax - char v4[20]; // [esp+0h] [ebp-14h] + const char *v3; // eax + char v4[20]; // [esp+0h] [ebp-14h] - switch (error_code) { - CASE_ERROR(v3, DSERR_PRIOLEVELNEEDED); - CASE_ERROR(v3, DSERR_BADFORMAT); - CASE_ERROR(v3, DSERR_NODRIVER); - CASE_ERROR(v3, DSERR_ALREADYINITIALIZED); - CASE_ERROR(v3, DSERR_BUFFERLOST); - CASE_ERROR(v3, DS_OK); - CASE_ERROR(v3, DSERR_INVALIDCALL); - CASE_ERROR(v3, E_NOINTERFACE); - CASE_ERROR(v3, DSERR_NOAGGREGATION); - CASE_ERROR(v3, DSERR_OUTOFMEMORY); - CASE_ERROR(v3, DSERR_INVALIDPARAM); - CASE_ERROR(v3, DSERR_ALLOCATED); - CASE_ERROR(v3, DSERR_CONTROLUNAVAIL); - default: - strcpy(v4, "DSERR unknown 0x%x"); - sprintf(error_buf, v4, error_code); - return; - } - strncpy(error_buf, v3, error_buf_len); + switch (error_code) { + CASE_ERROR(v3, DSERR_PRIOLEVELNEEDED); + CASE_ERROR(v3, DSERR_BADFORMAT); + CASE_ERROR(v3, DSERR_NODRIVER); + CASE_ERROR(v3, DSERR_ALREADYINITIALIZED); + CASE_ERROR(v3, DSERR_BUFFERLOST); + CASE_ERROR(v3, DS_OK); + CASE_ERROR(v3, DSERR_INVALIDCALL); + CASE_ERROR(v3, E_NOINTERFACE); + CASE_ERROR(v3, DSERR_NOAGGREGATION); + CASE_ERROR(v3, DSERR_OUTOFMEMORY); + CASE_ERROR(v3, DSERR_INVALIDPARAM); + CASE_ERROR(v3, DSERR_ALLOCATED); + CASE_ERROR(v3, DSERR_CONTROLUNAVAIL); + default: + strcpy(v4, "DSERR unknown 0x%x"); + sprintf(error_buf, v4, error_code); + return; + } + strncpy(error_buf, v3, error_buf_len); } char *__cdecl TraceLastError() { - int v0; // eax + int v0; // eax - v0 = GetLastError(); - return GetErrorStr(v0); + v0 = GetLastError(); + return GetErrorStr(v0); } void TermMsg(char *pszFmt, ...) { - va_list arglist; // [esp+8h] [ebp+8h] + va_list arglist; // [esp+8h] [ebp+8h] - va_start(arglist, pszFmt); - FreeDlg(); - if (pszFmt) - MsgBox(pszFmt, arglist); - va_end(arglist); - init_cleanup(0); - exit(1); + va_start(arglist, pszFmt); + FreeDlg(); + if (pszFmt) + MsgBox(pszFmt, arglist); + va_end(arglist); + init_cleanup(0); + exit(1); } void __fastcall MsgBox(char *pszFmt, va_list va) { - char Text[256]; // [esp+0h] [ebp-100h] + char Text[256]; // [esp+0h] [ebp-100h] - wvsprintf(Text, pszFmt, va); - if (ghMainWnd) - SetWindowPos(ghMainWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); - MessageBox(ghMainWnd, Text, "ERROR", MB_TASKMODAL | MB_ICONHAND); + wvsprintf(Text, pszFmt, va); + if (ghMainWnd) + SetWindowPos(ghMainWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); + MessageBox(ghMainWnd, Text, "ERROR", MB_TASKMODAL | MB_ICONHAND); } void __cdecl FreeDlg() { - if (terminating && cleanup_thread_id != GetCurrentThreadId()) - Sleep(20000u); - terminating = 1; - cleanup_thread_id = GetCurrentThreadId(); - dx_cleanup(); - if ((unsigned char)gbMaxPlayers > 1u) { - if (SNetLeaveGame(3)) - Sleep(2000u); - } - SNetDestroy(); - ShowCursor(1); + if (terminating && cleanup_thread_id != GetCurrentThreadId()) + Sleep(20000u); + terminating = 1; + cleanup_thread_id = GetCurrentThreadId(); + dx_cleanup(); + if ((unsigned char)gbMaxPlayers > 1u) { + if (SNetLeaveGame(3)) + Sleep(2000u); + } + SNetDestroy(); + ShowCursor(1); } // 4B7A34: using guessed type int terminating; // 4B7A38: using guessed type int cleanup_thread_id; @@ -248,178 +248,178 @@ void __cdecl FreeDlg() void DrawDlg(char *pszFmt, ...) { - char text[256]; // [esp+0h] [ebp-100h] - va_list arglist; // [esp+10Ch] [ebp+Ch] + char text[256]; // [esp+0h] [ebp-100h] + va_list arglist; // [esp+10Ch] [ebp+Ch] - va_start(arglist, pszFmt); - wvsprintf(text, pszFmt, arglist); - va_end(arglist); - SDrawMessageBox(text, "Diablo", MB_TASKMODAL | MB_ICONEXCLAMATION); + va_start(arglist, pszFmt); + wvsprintf(text, pszFmt, arglist); + va_end(arglist); + SDrawMessageBox(text, "Diablo", MB_TASKMODAL | MB_ICONEXCLAMATION); } void __fastcall DDErrMsg(int error_code, int log_line_nr, char *log_file_path) { - int v3; // esi - char *v4; // eax + int v3; // esi + char *v4; // eax - v3 = log_line_nr; - if (error_code) { - v4 = GetErrorStr(error_code); - TermMsg("Direct draw error (%s:%d)\n%s", log_file_path, v3, v4); - } + v3 = log_line_nr; + if (error_code) { + v4 = GetErrorStr(error_code); + TermMsg("Direct draw error (%s:%d)\n%s", log_file_path, v3, v4); + } } void __fastcall DSErrMsg(int error_code, int log_line_nr, char *log_file_path) { - int v3; // esi - char *v4; // eax + int v3; // esi + char *v4; // eax - v3 = log_line_nr; - if (error_code) { - v4 = GetErrorStr(error_code); - TermMsg("Direct sound error (%s:%d)\n%s", log_file_path, v3, v4); - } + v3 = log_line_nr; + if (error_code) { + v4 = GetErrorStr(error_code); + TermMsg("Direct sound error (%s:%d)\n%s", log_file_path, v3, v4); + } } void __fastcall center_window(HWND hDlg) { - LONG v1; // esi - LONG v2; // edi - int v3; // ebx - char *v4; // eax - struct tagRECT Rect; // [esp+Ch] [ebp-1Ch] - int v6; // [esp+1Ch] [ebp-Ch] - HDC hdc; // [esp+20h] [ebp-8h] - HWND hWnd; // [esp+24h] [ebp-4h] + LONG v1; // esi + LONG v2; // edi + int v3; // ebx + char *v4; // eax + struct tagRECT Rect; // [esp+Ch] [ebp-1Ch] + int v6; // [esp+1Ch] [ebp-Ch] + HDC hdc; // [esp+20h] [ebp-8h] + HWND hWnd; // [esp+24h] [ebp-4h] - hWnd = hDlg; - GetWindowRect(hDlg, &Rect); - v1 = Rect.right - Rect.left; - v2 = Rect.bottom - Rect.top; - hdc = GetDC(hWnd); - v6 = GetDeviceCaps(hdc, HORZRES); - v3 = GetDeviceCaps(hdc, VERTRES); - ReleaseDC(hWnd, hdc); - if (!SetWindowPos(hWnd, HWND_TOP, (v6 - v1) / 2, (v3 - v2) / 2, 0, 0, SWP_NOZORDER | SWP_NOSIZE)) { - v4 = TraceLastError(); - TermMsg("center_window: %s", v4); - } + hWnd = hDlg; + GetWindowRect(hDlg, &Rect); + v1 = Rect.right - Rect.left; + v2 = Rect.bottom - Rect.top; + hdc = GetDC(hWnd); + v6 = GetDeviceCaps(hdc, HORZRES); + v3 = GetDeviceCaps(hdc, VERTRES); + ReleaseDC(hWnd, hdc); + if (!SetWindowPos(hWnd, HWND_TOP, (v6 - v1) / 2, (v3 - v2) / 2, 0, 0, SWP_NOZORDER | SWP_NOSIZE)) { + v4 = TraceLastError(); + TermMsg("center_window: %s", v4); + } } void __fastcall ErrDlg(int template_id, int error_code, char *log_file_path, int log_line_nr) { - int v4; // ebx - int v5; // edi - char *v6; // esi - char *v7; // eax - char *v8; // eax - LPARAM dwInitParam[128]; // [esp+Ch] [ebp-200h] + int v4; // ebx + int v5; // edi + char *v6; // esi + char *v7; // eax + char *v8; // eax + LPARAM dwInitParam[128]; // [esp+Ch] [ebp-200h] - v4 = error_code; - v5 = template_id; - FreeDlg(); - v6 = log_file_path; - v7 = strrchr(log_file_path, '\\'); - if (v7) - v6 = v7 + 1; - v8 = GetErrorStr(v4); - wsprintf((LPSTR)dwInitParam, "%s\nat: %s line %d", v8, v6, log_line_nr); - if (DialogBoxParam(ghInst, MAKEINTRESOURCE(v5), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)dwInitParam) == -1) - TermMsg("ErrDlg: %d", v5); - TermMsg(0); + v4 = error_code; + v5 = template_id; + FreeDlg(); + v6 = log_file_path; + v7 = strrchr(log_file_path, '\\'); + if (v7) + v6 = v7 + 1; + v8 = GetErrorStr(v4); + wsprintf((LPSTR)dwInitParam, "%s\nat: %s line %d", v8, v6, log_line_nr); + if (DialogBoxParam(ghInst, MAKEINTRESOURCE(v5), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)dwInitParam) == -1) + TermMsg("ErrDlg: %d", v5); + TermMsg(0); } BOOL __stdcall FuncDlg(HWND hDlg, UINT uMsg, WPARAM wParam, char *text) { - if (uMsg == WM_INITDIALOG) { - TextDlg(hDlg, text); - } else { - if (uMsg != WM_COMMAND) - return 0; - if ((_WORD)wParam == 1) { - EndDialog(hDlg, 1); - } else if ((_WORD)wParam == 2) { - EndDialog(hDlg, 0); - } - } - return 1; + if (uMsg == WM_INITDIALOG) { + TextDlg(hDlg, text); + } else { + if (uMsg != WM_COMMAND) + return 0; + if ((_WORD)wParam == 1) { + EndDialog(hDlg, 1); + } else if ((_WORD)wParam == 2) { + EndDialog(hDlg, 0); + } + } + return 1; } void __fastcall TextDlg(HWND hDlg, char *text) { - char *v2; // esi - HWND v3; // edi + char *v2; // esi + HWND v3; // edi - v2 = text; - v3 = hDlg; - center_window(hDlg); - if (v2) - SetDlgItemText(v3, 1000, v2); + v2 = text; + v3 = hDlg; + center_window(hDlg); + if (v2) + SetDlgItemText(v3, 1000, v2); } void __fastcall ErrOkDlg(int template_id, int error_code, char *log_file_path, int log_line_nr) { - char *v4; // esi - int v5; // edi - unsigned short v6; // bx - char *v7; // eax - char *v8; // eax - LPARAM dwInitParam[128]; // [esp+Ch] [ebp-200h] + char *v4; // esi + int v5; // edi + unsigned short v6; // bx + char *v7; // eax + char *v8; // eax + LPARAM dwInitParam[128]; // [esp+Ch] [ebp-200h] - v4 = log_file_path; - v5 = error_code; - v6 = template_id; - v7 = strrchr(log_file_path, '\\'); - if (v7) - v4 = v7 + 1; - v8 = GetErrorStr(v5); - wsprintf((LPSTR)dwInitParam, "%s\nat: %s line %d", v8, v4, log_line_nr); - DialogBoxParam(ghInst, MAKEINTRESOURCE(v6), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)dwInitParam); + v4 = log_file_path; + v5 = error_code; + v6 = template_id; + v7 = strrchr(log_file_path, '\\'); + if (v7) + v4 = v7 + 1; + v8 = GetErrorStr(v5); + wsprintf((LPSTR)dwInitParam, "%s\nat: %s line %d", v8, v4, log_line_nr); + DialogBoxParam(ghInst, MAKEINTRESOURCE(v6), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)dwInitParam); } void __fastcall FileErrDlg(const char *error) { - const char *v1; // esi + const char *v1; // esi - v1 = error; - FreeDlg(); - if (!v1) - v1 = &empty_string; - if (DialogBoxParam(ghInst, MAKEINTRESOURCE(IDD_DIALOG3), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)v1) == -1) - TermMsg("FileErrDlg"); - TermMsg(0); + v1 = error; + FreeDlg(); + if (!v1) + v1 = &empty_string; + if (DialogBoxParam(ghInst, MAKEINTRESOURCE(IDD_DIALOG3), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)v1) == -1) + TermMsg("FileErrDlg"); + TermMsg(0); } void __fastcall DiskFreeDlg(char *error) { - char *v1; // esi + char *v1; // esi - v1 = error; - FreeDlg(); - if (DialogBoxParam(ghInst, MAKEINTRESOURCE(IDD_DIALOG7), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)v1) == -1) - TermMsg("DiskFreeDlg"); - TermMsg(0); + v1 = error; + FreeDlg(); + if (DialogBoxParam(ghInst, MAKEINTRESOURCE(IDD_DIALOG7), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)v1) == -1) + TermMsg("DiskFreeDlg"); + TermMsg(0); } BOOL __cdecl InsertCDDlg() { - int v0; // edi + int v0; // edi - ShowCursor(1); - v0 = DialogBoxParam(ghInst, MAKEINTRESOURCE(IDD_DIALOG9), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)&empty_string); - if (v0 == -1) - TermMsg("InsertCDDlg"); - ShowCursor(0); - return v0 == 1; + ShowCursor(1); + v0 = DialogBoxParam(ghInst, MAKEINTRESOURCE(IDD_DIALOG9), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)&empty_string); + if (v0 == -1) + TermMsg("InsertCDDlg"); + ShowCursor(0); + return v0 == 1; } void __fastcall DirErrorDlg(char *error) { - char *v1; // esi + char *v1; // esi - v1 = error; - FreeDlg(); - if (DialogBoxParam(ghInst, MAKEINTRESOURCE(IDD_DIALOG11), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)v1) == -1) - TermMsg("DirErrorDlg"); - TermMsg(0); + v1 = error; + FreeDlg(); + if (DialogBoxParam(ghInst, MAKEINTRESOURCE(IDD_DIALOG11), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)v1) == -1) + TermMsg("DirErrorDlg"); + TermMsg(0); } diff --git a/Source/automap.cpp b/Source/automap.cpp index 960dab0d..1adb9937 100644 --- a/Source/automap.cpp +++ b/Source/automap.cpp @@ -38,234 +38,234 @@ int AMPlayerY; // weak void __cdecl InitAutomapOnce() { - automapflag = FALSE; - AutoMapScale = 50; - AutoMapPosBits = 32; - AutoMapXPos = 16; - AutoMapYPos = 8; - AMPlayerX = 4; - AMPlayerY = 2; + automapflag = FALSE; + AutoMapScale = 50; + AutoMapPosBits = 32; + AutoMapXPos = 16; + AutoMapYPos = 8; + AMPlayerX = 4; + AMPlayerY = 2; } void __cdecl InitAutomap() { - signed int v0; // edi - signed int v1; // ecx - int v2; // esi - char v3; // al - int v4; // esi - char v5; // al - char *v6; // ecx - unsigned char *v7; // eax - int v8; // ecx - unsigned char *v9; // edx - unsigned int i; // esi - unsigned char v11; // bl - _BYTE *v12; // edx - signed int v13; // ecx - _BYTE *v14; // eax - signed int v15; // edx - int size; // [esp+Ch] [ebp-4h] + signed int v0; // edi + signed int v1; // ecx + int v2; // esi + char v3; // al + int v4; // esi + char v5; // al + char *v6; // ecx + unsigned char *v7; // eax + int v8; // ecx + unsigned char *v9; // edx + unsigned int i; // esi + unsigned char v11; // bl + _BYTE *v12; // edx + signed int v13; // ecx + _BYTE *v14; // eax + signed int v15; // edx + int size; // [esp+Ch] [ebp-4h] - v0 = 50; - v1 = 0; - do { - v2 = (v0 << 6) / 100; - v3 = 2 * (320 / v2); - v4 = 320 % v2; - v5 = v3 + 1; - AMbyte_4B7E4C[v1] = v5; - if (v4) - AMbyte_4B7E4C[v1] = v5 + 1; - if (v4 >= 32 * v0 / 100) - ++AMbyte_4B7E4C[v1]; - v0 += 5; - ++v1; - } while (v1 < 31); - memset(automaptype, 0, sizeof(automaptype)); - switch (leveltype) { - case DTYPE_CATHEDRAL: - v6 = "Levels\\L1Data\\L1.AMP"; - break; - case DTYPE_CATACOMBS: - v6 = "Levels\\L2Data\\L2.AMP"; - break; - case DTYPE_CAVES: - v6 = "Levels\\L3Data\\L3.AMP"; - break; - case DTYPE_HELL: - v6 = "Levels\\L4Data\\L4.AMP"; - break; - default: - return; - } - v7 = LoadFileInMem(v6, &size); - size = (unsigned int)size >> 1; - v9 = v7; - for (i = 1; i <= size; ++i) { - v11 = *v9; - v12 = v9 + 1; - _LOWORD(v0) = v11; - _LOBYTE(v8) = *v12; - v9 = v12 + 1; - _LOWORD(v8) = (unsigned char)v8; - v8 = v0 + (v8 << 8); - automaptype[i] = v8; - } - mem_free_dbg(v7); - memset(automapview, 0, sizeof(automapview)); - v13 = 0; - do { - v14 = (unsigned char *)dFlags + v13; - v15 = 112; - do { - *v14 &= ~DFLAG_EXPLORED; - v14 += 112; - --v15; - } while (v15); - ++v13; - } while (v13 < 112); + v0 = 50; + v1 = 0; + do { + v2 = (v0 << 6) / 100; + v3 = 2 * (320 / v2); + v4 = 320 % v2; + v5 = v3 + 1; + AMbyte_4B7E4C[v1] = v5; + if (v4) + AMbyte_4B7E4C[v1] = v5 + 1; + if (v4 >= 32 * v0 / 100) + ++AMbyte_4B7E4C[v1]; + v0 += 5; + ++v1; + } while (v1 < 31); + memset(automaptype, 0, sizeof(automaptype)); + switch (leveltype) { + case DTYPE_CATHEDRAL: + v6 = "Levels\\L1Data\\L1.AMP"; + break; + case DTYPE_CATACOMBS: + v6 = "Levels\\L2Data\\L2.AMP"; + break; + case DTYPE_CAVES: + v6 = "Levels\\L3Data\\L3.AMP"; + break; + case DTYPE_HELL: + v6 = "Levels\\L4Data\\L4.AMP"; + break; + default: + return; + } + v7 = LoadFileInMem(v6, &size); + size = (unsigned int)size >> 1; + v9 = v7; + for (i = 1; i <= size; ++i) { + v11 = *v9; + v12 = v9 + 1; + _LOWORD(v0) = v11; + _LOBYTE(v8) = *v12; + v9 = v12 + 1; + _LOWORD(v8) = (unsigned char)v8; + v8 = v0 + (v8 << 8); + automaptype[i] = v8; + } + mem_free_dbg(v7); + memset(automapview, 0, sizeof(automapview)); + v13 = 0; + do { + v14 = (unsigned char *)dFlags + v13; + v15 = 112; + do { + *v14 &= ~DFLAG_EXPLORED; + v14 += 112; + --v15; + } while (v15); + ++v13; + } while (v13 < 112); } void __cdecl StartAutomap() { - AutoMapXOfs = 0; - AutoMapYOfs = 0; - automapflag = TRUE; + AutoMapXOfs = 0; + AutoMapYOfs = 0; + automapflag = TRUE; } void __cdecl AutomapUp() { - --AutoMapXOfs; - --AutoMapYOfs; + --AutoMapXOfs; + --AutoMapYOfs; } void __cdecl AutomapDown() { - ++AutoMapXOfs; - ++AutoMapYOfs; + ++AutoMapXOfs; + ++AutoMapYOfs; } void __cdecl AutomapLeft() { - --AutoMapXOfs; - ++AutoMapYOfs; + --AutoMapXOfs; + ++AutoMapYOfs; } void __cdecl AutomapRight() { - ++AutoMapXOfs; - --AutoMapYOfs; + ++AutoMapXOfs; + --AutoMapYOfs; } void __cdecl AutomapZoomIn() { - if (AutoMapScale < 200) { - AutoMapScale += 5; - AutoMapPosBits = (AutoMapScale << 6) / 100; - AutoMapXPos = AutoMapPosBits >> 1; - AutoMapYPos = AutoMapXPos >> 1; - AMPlayerX = AutoMapYPos >> 1; - AMPlayerY = AMPlayerX >> 1; - } + if (AutoMapScale < 200) { + AutoMapScale += 5; + AutoMapPosBits = (AutoMapScale << 6) / 100; + AutoMapXPos = AutoMapPosBits >> 1; + AutoMapYPos = AutoMapXPos >> 1; + AMPlayerX = AutoMapYPos >> 1; + AMPlayerY = AMPlayerX >> 1; + } } void __cdecl AutomapZoomOut() { - if (AutoMapScale > 50) { - AutoMapScale -= 5; - AutoMapPosBits = (AutoMapScale << 6) / 100; - AutoMapXPos = AutoMapPosBits >> 1; - AutoMapYPos = AutoMapXPos >> 1; - AMPlayerX = AutoMapYPos >> 1; - AMPlayerY = AMPlayerX >> 1; - } + if (AutoMapScale > 50) { + AutoMapScale -= 5; + AutoMapPosBits = (AutoMapScale << 6) / 100; + AutoMapXPos = AutoMapPosBits >> 1; + AutoMapYPos = AutoMapXPos >> 1; + AMPlayerX = AutoMapYPos >> 1; + AMPlayerY = AMPlayerX >> 1; + } } void __cdecl DrawAutomap() { - int cells; - int screen_x; - int screen_y; - int i, j; - int mapx, mapy; + int cells; + int screen_x; + int screen_y; + int i, j; + int mapx, mapy; - if (leveltype == DTYPE_TOWN) { - DrawAutomapGame(); - return; - } + if (leveltype == DTYPE_TOWN) { + DrawAutomapGame(); + return; + } - gpBufEnd = (unsigned char *)&gpBuffer->row[352]; + gpBufEnd = (unsigned char *)&gpBuffer->row[352]; - MapX = (ViewX - 16) >> 1; - while (MapX + AutoMapXOfs < 0) - AutoMapXOfs++; - while (MapX + AutoMapXOfs >= DMAXX) - AutoMapXOfs--; - MapX += AutoMapXOfs; + MapX = (ViewX - 16) >> 1; + while (MapX + AutoMapXOfs < 0) + AutoMapXOfs++; + while (MapX + AutoMapXOfs >= DMAXX) + AutoMapXOfs--; + MapX += AutoMapXOfs; - MapY = (ViewY - 16) >> 1; - while (MapY + AutoMapYOfs < 0) - AutoMapYOfs++; - while (MapY + AutoMapYOfs >= DMAXY) - AutoMapYOfs--; - MapY += AutoMapYOfs; + MapY = (ViewY - 16) >> 1; + while (MapY + AutoMapYOfs < 0) + AutoMapYOfs++; + while (MapY + AutoMapYOfs >= DMAXY) + AutoMapYOfs--; + MapY += AutoMapYOfs; - cells = AMbyte_4B7E4C[(AutoMapScale - 50) / 5]; - if (ScrollInfo._sxoff + ScrollInfo._syoff) - cells++; - mapx = MapX - cells; - mapy = MapY - 1; + cells = AMbyte_4B7E4C[(AutoMapScale - 50) / 5]; + if (ScrollInfo._sxoff + ScrollInfo._syoff) + cells++; + mapx = MapX - cells; + mapy = MapY - 1; - if (cells & 1) { - screen_x = 384 - AutoMapPosBits * ((cells - 1) >> 1); - screen_y = 336 - AutoMapXPos * ((cells + 1) >> 1); - } else { - screen_x = 384 - AutoMapPosBits * (cells >> 1) + AutoMapXPos; - screen_y = 336 - AutoMapXPos * (cells >> 1) - AutoMapYPos; - } - if (ViewX & 1) { - screen_x -= AutoMapYPos; - screen_y -= AMPlayerX; - } - if (ViewY & 1) { - screen_x += AutoMapYPos; - screen_y -= AMPlayerX; - } + if (cells & 1) { + screen_x = 384 - AutoMapPosBits * ((cells - 1) >> 1); + screen_y = 336 - AutoMapXPos * ((cells + 1) >> 1); + } else { + screen_x = 384 - AutoMapPosBits * (cells >> 1) + AutoMapXPos; + screen_y = 336 - AutoMapXPos * (cells >> 1) - AutoMapYPos; + } + if (ViewX & 1) { + screen_x -= AutoMapYPos; + screen_y -= AMPlayerX; + } + if (ViewY & 1) { + screen_x += AutoMapYPos; + screen_y -= AMPlayerX; + } - screen_x += AutoMapScale * ScrollInfo._sxoff / 100 >> 1; - screen_y += AutoMapScale * ScrollInfo._syoff / 100 >> 1; - if (invflag || sbookflag) { - screen_x -= 160; - } - if (chrflag || questlog) { - screen_x += 160; - } + screen_x += AutoMapScale * ScrollInfo._sxoff / 100 >> 1; + screen_y += AutoMapScale * ScrollInfo._syoff / 100 >> 1; + if (invflag || sbookflag) { + screen_x -= 160; + } + if (chrflag || questlog) { + screen_x += 160; + } - for (i = 0; i <= cells + 1; i++) { - int x = screen_x; - int y; + for (i = 0; i <= cells + 1; i++) { + int x = screen_x; + int y; - for (j = 0; j < cells; j++) { - WORD maptype = GetAutomapType(mapx + j, mapy - j, TRUE); - if (maptype) - DrawAutomapType(x, screen_y, maptype); - x += AutoMapPosBits; - } - mapy++; - x = screen_x - AutoMapXPos; - y = screen_y + AutoMapYPos; - for (j = 0; j <= cells; j++) { - WORD maptype = GetAutomapType(mapx + j, mapy - j, TRUE); - if (maptype) - DrawAutomapType(x, y, maptype); - x += AutoMapPosBits; - } - mapx++; - screen_y += AutoMapXPos; - } - DrawAutomapPlr(); - DrawAutomapGame(); + for (j = 0; j < cells; j++) { + WORD maptype = GetAutomapType(mapx + j, mapy - j, TRUE); + if (maptype) + DrawAutomapType(x, screen_y, maptype); + x += AutoMapPosBits; + } + mapy++; + x = screen_x - AutoMapXPos; + y = screen_y + AutoMapYPos; + for (j = 0; j <= cells; j++) { + WORD maptype = GetAutomapType(mapx + j, mapy - j, TRUE); + if (maptype) + DrawAutomapType(x, y, maptype); + x += AutoMapPosBits; + } + mapx++; + screen_y += AutoMapXPos; + } + DrawAutomapPlr(); + DrawAutomapGame(); } // 4B8968: using guessed type int sbookflag; // 69BD04: using guessed type int questlog; @@ -273,380 +273,380 @@ void __cdecl DrawAutomap() void __fastcall DrawAutomapType(int screen_x, int screen_y, WORD automap_type) { - BOOL do_vert; - BOOL do_horz; - BOOL do_cave_horz; - BOOL do_cave_vert; - int x1, y1, x2, y2; + BOOL do_vert; + BOOL do_horz; + BOOL do_cave_horz; + BOOL do_cave_vert; + int x1, y1, x2, y2; - BYTE flags = automap_type >> 8; + BYTE flags = automap_type >> 8; - if (flags & MAPFLAG_SQUARE) { - ENG_set_pixel(screen_x, screen_y, COLOR_DIM); - ENG_set_pixel(screen_x - AMPlayerX, screen_y - AMPlayerY, COLOR_DIM); - ENG_set_pixel(screen_x - AMPlayerX, screen_y + AMPlayerY, COLOR_DIM); - ENG_set_pixel(screen_x + AMPlayerX, screen_y - AMPlayerY, COLOR_DIM); - ENG_set_pixel(screen_x + AMPlayerX, screen_y + AMPlayerY, COLOR_DIM); - ENG_set_pixel(screen_x - AutoMapYPos, screen_y, COLOR_DIM); - ENG_set_pixel(screen_x + AutoMapYPos, screen_y, COLOR_DIM); - ENG_set_pixel(screen_x, screen_y - AMPlayerX, COLOR_DIM); - ENG_set_pixel(screen_x, screen_y + AMPlayerX, COLOR_DIM); - ENG_set_pixel(screen_x + AMPlayerX - AutoMapXPos, screen_y + AMPlayerY, COLOR_DIM); - ENG_set_pixel(screen_x - AMPlayerX + AutoMapXPos, screen_y + AMPlayerY, COLOR_DIM); - ENG_set_pixel(screen_x - AutoMapYPos, screen_y + AMPlayerX, COLOR_DIM); - ENG_set_pixel(screen_x + AutoMapYPos, screen_y + AMPlayerX, COLOR_DIM); - ENG_set_pixel(screen_x - AMPlayerX, screen_y + AutoMapYPos - AMPlayerY, COLOR_DIM); - ENG_set_pixel(screen_x + AMPlayerX, screen_y + AutoMapYPos - AMPlayerY, COLOR_DIM); - ENG_set_pixel(screen_x, screen_y + AutoMapYPos, COLOR_DIM); - } + if (flags & MAPFLAG_SQUARE) { + ENG_set_pixel(screen_x, screen_y, COLOR_DIM); + ENG_set_pixel(screen_x - AMPlayerX, screen_y - AMPlayerY, COLOR_DIM); + ENG_set_pixel(screen_x - AMPlayerX, screen_y + AMPlayerY, COLOR_DIM); + ENG_set_pixel(screen_x + AMPlayerX, screen_y - AMPlayerY, COLOR_DIM); + ENG_set_pixel(screen_x + AMPlayerX, screen_y + AMPlayerY, COLOR_DIM); + ENG_set_pixel(screen_x - AutoMapYPos, screen_y, COLOR_DIM); + ENG_set_pixel(screen_x + AutoMapYPos, screen_y, COLOR_DIM); + ENG_set_pixel(screen_x, screen_y - AMPlayerX, COLOR_DIM); + ENG_set_pixel(screen_x, screen_y + AMPlayerX, COLOR_DIM); + ENG_set_pixel(screen_x + AMPlayerX - AutoMapXPos, screen_y + AMPlayerY, COLOR_DIM); + ENG_set_pixel(screen_x - AMPlayerX + AutoMapXPos, screen_y + AMPlayerY, COLOR_DIM); + ENG_set_pixel(screen_x - AutoMapYPos, screen_y + AMPlayerX, COLOR_DIM); + ENG_set_pixel(screen_x + AutoMapYPos, screen_y + AMPlayerX, COLOR_DIM); + ENG_set_pixel(screen_x - AMPlayerX, screen_y + AutoMapYPos - AMPlayerY, COLOR_DIM); + ENG_set_pixel(screen_x + AMPlayerX, screen_y + AutoMapYPos - AMPlayerY, COLOR_DIM); + ENG_set_pixel(screen_x, screen_y + AutoMapYPos, COLOR_DIM); + } - if (flags & MAPFLAG_STAIRS) { - DrawLine(screen_x - AMPlayerX, screen_y - AMPlayerX - AMPlayerY, screen_x + AMPlayerX + AutoMapYPos, screen_y + AMPlayerY, COLOR_BRIGHT); - DrawLine(screen_x - AutoMapYPos, screen_y - AMPlayerX, screen_x + AutoMapYPos, screen_y + AMPlayerX, COLOR_BRIGHT); - DrawLine(screen_x - AutoMapYPos - AMPlayerX, screen_y - AMPlayerY, screen_x + AMPlayerX, screen_y + AMPlayerX + AMPlayerY, COLOR_BRIGHT); - DrawLine(screen_x - AutoMapXPos, screen_y, screen_x, screen_y + AutoMapYPos, COLOR_BRIGHT); - } + if (flags & MAPFLAG_STAIRS) { + DrawLine(screen_x - AMPlayerX, screen_y - AMPlayerX - AMPlayerY, screen_x + AMPlayerX + AutoMapYPos, screen_y + AMPlayerY, COLOR_BRIGHT); + DrawLine(screen_x - AutoMapYPos, screen_y - AMPlayerX, screen_x + AutoMapYPos, screen_y + AMPlayerX, COLOR_BRIGHT); + DrawLine(screen_x - AutoMapYPos - AMPlayerX, screen_y - AMPlayerY, screen_x + AMPlayerX, screen_y + AMPlayerX + AMPlayerY, COLOR_BRIGHT); + DrawLine(screen_x - AutoMapXPos, screen_y, screen_x, screen_y + AutoMapYPos, COLOR_BRIGHT); + } - do_vert = FALSE; - do_horz = FALSE; - do_cave_horz = FALSE; - do_cave_vert = FALSE; - switch (automap_type & MAPFLAG_TYPE) { - case 1: // stand-alone column or other unpassable object - x1 = screen_x - AutoMapYPos; - y1 = screen_y - AutoMapYPos; - x2 = x1 + AutoMapXPos; - y2 = screen_y - AMPlayerX; - DrawLine(screen_x, y1, x1, y2, COLOR_DIM); - DrawLine(screen_x, y1, x2, y2, COLOR_DIM); - DrawLine(screen_x, screen_y, x1, y2, COLOR_DIM); - DrawLine(screen_x, screen_y, x2, y2, COLOR_DIM); - return; - case 2: - case 5: - do_vert = TRUE; - break; - case 4: - do_vert = TRUE; - do_horz = TRUE; - break; - case 3: - case 6: - do_horz = TRUE; - break; - case 8: - do_vert = TRUE; - do_cave_horz = TRUE; - break; - case 9: - do_horz = TRUE; - do_cave_vert = TRUE; - break; - case 10: - do_cave_horz = TRUE; - break; - case 11: - do_cave_vert = TRUE; - break; - case 12: - do_cave_horz = TRUE; - do_cave_vert = TRUE; - break; - } + do_vert = FALSE; + do_horz = FALSE; + do_cave_horz = FALSE; + do_cave_vert = FALSE; + switch (automap_type & MAPFLAG_TYPE) { + case 1: // stand-alone column or other unpassable object + x1 = screen_x - AutoMapYPos; + y1 = screen_y - AutoMapYPos; + x2 = x1 + AutoMapXPos; + y2 = screen_y - AMPlayerX; + DrawLine(screen_x, y1, x1, y2, COLOR_DIM); + DrawLine(screen_x, y1, x2, y2, COLOR_DIM); + DrawLine(screen_x, screen_y, x1, y2, COLOR_DIM); + DrawLine(screen_x, screen_y, x2, y2, COLOR_DIM); + return; + case 2: + case 5: + do_vert = TRUE; + break; + case 4: + do_vert = TRUE; + do_horz = TRUE; + break; + case 3: + case 6: + do_horz = TRUE; + break; + case 8: + do_vert = TRUE; + do_cave_horz = TRUE; + break; + case 9: + do_horz = TRUE; + do_cave_vert = TRUE; + break; + case 10: + do_cave_horz = TRUE; + break; + case 11: + do_cave_vert = TRUE; + break; + case 12: + do_cave_horz = TRUE; + do_cave_vert = TRUE; + break; + } - if (do_vert) { // right-facing obstacle - if (flags & MAPFLAG_VERTDOOR) { // two wall segments with a door in the middle - x1 = screen_x - AutoMapXPos; - x2 = screen_x - AutoMapYPos; - y1 = screen_y - AutoMapYPos; - y2 = screen_y - AMPlayerX; + if (do_vert) { // right-facing obstacle + if (flags & MAPFLAG_VERTDOOR) { // two wall segments with a door in the middle + x1 = screen_x - AutoMapXPos; + x2 = screen_x - AutoMapYPos; + y1 = screen_y - AutoMapYPos; + y2 = screen_y - AMPlayerX; - DrawLine(screen_x, y1, screen_x - AMPlayerX, y1 + AMPlayerY, COLOR_DIM); - DrawLine(x1, screen_y, x1 + AMPlayerX, screen_y - AMPlayerY, COLOR_DIM); - DrawLine(x2, y1, x1, y2, COLOR_BRIGHT); - DrawLine(x2, y1, screen_x, y2, COLOR_BRIGHT); - DrawLine(x2, screen_y, x1, y2, COLOR_BRIGHT); - DrawLine(x2, screen_y, screen_x, y2, COLOR_BRIGHT); - } - if (flags & MAPFLAG_VERTGRATE) { // right-facing half-wall - DrawLine(screen_x - AutoMapYPos, screen_y - AMPlayerX, screen_x - AutoMapXPos, screen_y, COLOR_DIM); - flags |= MAPFLAG_VERTARCH; - } - if (flags & MAPFLAG_VERTARCH) { // window or passable column - x1 = screen_x - AutoMapYPos; - y1 = screen_y - AutoMapYPos; - x2 = x1 + AutoMapXPos; - y2 = screen_y - AMPlayerX; + DrawLine(screen_x, y1, screen_x - AMPlayerX, y1 + AMPlayerY, COLOR_DIM); + DrawLine(x1, screen_y, x1 + AMPlayerX, screen_y - AMPlayerY, COLOR_DIM); + DrawLine(x2, y1, x1, y2, COLOR_BRIGHT); + DrawLine(x2, y1, screen_x, y2, COLOR_BRIGHT); + DrawLine(x2, screen_y, x1, y2, COLOR_BRIGHT); + DrawLine(x2, screen_y, screen_x, y2, COLOR_BRIGHT); + } + if (flags & MAPFLAG_VERTGRATE) { // right-facing half-wall + DrawLine(screen_x - AutoMapYPos, screen_y - AMPlayerX, screen_x - AutoMapXPos, screen_y, COLOR_DIM); + flags |= MAPFLAG_VERTARCH; + } + if (flags & MAPFLAG_VERTARCH) { // window or passable column + x1 = screen_x - AutoMapYPos; + y1 = screen_y - AutoMapYPos; + x2 = x1 + AutoMapXPos; + y2 = screen_y - AMPlayerX; - DrawLine(screen_x, y1, x1, y2, COLOR_DIM); - DrawLine(screen_x, y1, x2, y2, COLOR_DIM); - DrawLine(screen_x, screen_y, x1, y2, COLOR_DIM); - DrawLine(screen_x, screen_y, x2, y2, COLOR_DIM); - } - if (!(flags & (MAPFLAG_VERTDOOR | MAPFLAG_VERTGRATE | MAPFLAG_VERTARCH))) - DrawLine(screen_x, screen_y - AutoMapYPos, screen_x - AutoMapXPos, screen_y, COLOR_DIM); - } + DrawLine(screen_x, y1, x1, y2, COLOR_DIM); + DrawLine(screen_x, y1, x2, y2, COLOR_DIM); + DrawLine(screen_x, screen_y, x1, y2, COLOR_DIM); + DrawLine(screen_x, screen_y, x2, y2, COLOR_DIM); + } + if (!(flags & (MAPFLAG_VERTDOOR | MAPFLAG_VERTGRATE | MAPFLAG_VERTARCH))) + DrawLine(screen_x, screen_y - AutoMapYPos, screen_x - AutoMapXPos, screen_y, COLOR_DIM); + } - if (do_horz) { // left-facing obstacle - if (flags & MAPFLAG_HORZDOOR) { - x1 = screen_x + AutoMapYPos; - x2 = screen_x + AutoMapXPos; - y1 = screen_y - AutoMapYPos; - y2 = screen_y - AMPlayerX; + if (do_horz) { // left-facing obstacle + if (flags & MAPFLAG_HORZDOOR) { + x1 = screen_x + AutoMapYPos; + x2 = screen_x + AutoMapXPos; + y1 = screen_y - AutoMapYPos; + y2 = screen_y - AMPlayerX; - DrawLine(screen_x, y1, screen_x + AMPlayerX, y1 + AMPlayerY, COLOR_DIM); - DrawLine(x2, screen_y, x2 - AMPlayerX, screen_y - AMPlayerY, COLOR_DIM); - DrawLine(x1, y1, screen_x, y2, COLOR_BRIGHT); - DrawLine(x1, y1, x2, y2, COLOR_BRIGHT); - DrawLine(x1, screen_y, screen_x, y2, COLOR_BRIGHT); - DrawLine(x1, screen_y, x2, y2, COLOR_BRIGHT); - } - if (flags & MAPFLAG_HORZGRATE) { - DrawLine(screen_x + AutoMapYPos, screen_y - AMPlayerX, screen_x + AutoMapXPos, screen_y, COLOR_DIM); - flags |= MAPFLAG_HORZARCH; - } - if (flags & MAPFLAG_HORZARCH) { - x1 = screen_x - AutoMapYPos; - y1 = screen_y - AutoMapYPos; - x2 = x1 + AutoMapXPos; - y2 = screen_y - AMPlayerX; + DrawLine(screen_x, y1, screen_x + AMPlayerX, y1 + AMPlayerY, COLOR_DIM); + DrawLine(x2, screen_y, x2 - AMPlayerX, screen_y - AMPlayerY, COLOR_DIM); + DrawLine(x1, y1, screen_x, y2, COLOR_BRIGHT); + DrawLine(x1, y1, x2, y2, COLOR_BRIGHT); + DrawLine(x1, screen_y, screen_x, y2, COLOR_BRIGHT); + DrawLine(x1, screen_y, x2, y2, COLOR_BRIGHT); + } + if (flags & MAPFLAG_HORZGRATE) { + DrawLine(screen_x + AutoMapYPos, screen_y - AMPlayerX, screen_x + AutoMapXPos, screen_y, COLOR_DIM); + flags |= MAPFLAG_HORZARCH; + } + if (flags & MAPFLAG_HORZARCH) { + x1 = screen_x - AutoMapYPos; + y1 = screen_y - AutoMapYPos; + x2 = x1 + AutoMapXPos; + y2 = screen_y - AMPlayerX; - DrawLine(screen_x, y1, x1, y2, COLOR_DIM); - DrawLine(screen_x, y1, x2, y2, COLOR_DIM); - DrawLine(screen_x, screen_y, x1, y2, COLOR_DIM); - DrawLine(screen_x, screen_y, x2, y2, COLOR_DIM); - } - if (!(flags & (MAPFLAG_HORZDOOR | MAPFLAG_HORZGRATE | MAPFLAG_HORZARCH))) - DrawLine(screen_x, screen_y - AutoMapYPos, screen_x + AutoMapXPos, screen_y, COLOR_DIM); - } + DrawLine(screen_x, y1, x1, y2, COLOR_DIM); + DrawLine(screen_x, y1, x2, y2, COLOR_DIM); + DrawLine(screen_x, screen_y, x1, y2, COLOR_DIM); + DrawLine(screen_x, screen_y, x2, y2, COLOR_DIM); + } + if (!(flags & (MAPFLAG_HORZDOOR | MAPFLAG_HORZGRATE | MAPFLAG_HORZARCH))) + DrawLine(screen_x, screen_y - AutoMapYPos, screen_x + AutoMapXPos, screen_y, COLOR_DIM); + } - // for caves the horz/vert flags are switched - if (do_cave_horz) { - if (flags & MAPFLAG_VERTDOOR) { - x1 = screen_x - AutoMapXPos; - x2 = screen_x - AutoMapYPos; - y1 = screen_y + AutoMapYPos; - y2 = screen_y + AMPlayerX; + // for caves the horz/vert flags are switched + if (do_cave_horz) { + if (flags & MAPFLAG_VERTDOOR) { + x1 = screen_x - AutoMapXPos; + x2 = screen_x - AutoMapYPos; + y1 = screen_y + AutoMapYPos; + y2 = screen_y + AMPlayerX; - DrawLine(screen_x, y1, screen_x - AMPlayerX, y1 - AMPlayerY, COLOR_DIM); - DrawLine(x1, screen_y, x1 + AMPlayerX, screen_y + AMPlayerY, COLOR_DIM); - DrawLine(x2, y1, x1, y2, COLOR_BRIGHT); - DrawLine(x2, y1, screen_x, y2, COLOR_BRIGHT); - DrawLine(x2, screen_y, x1, y2, COLOR_BRIGHT); - DrawLine(x2, screen_y, screen_x, y2, COLOR_BRIGHT); - } else - DrawLine(screen_x, screen_y + AutoMapYPos, screen_x - AutoMapXPos, screen_y, COLOR_DIM); - } + DrawLine(screen_x, y1, screen_x - AMPlayerX, y1 - AMPlayerY, COLOR_DIM); + DrawLine(x1, screen_y, x1 + AMPlayerX, screen_y + AMPlayerY, COLOR_DIM); + DrawLine(x2, y1, x1, y2, COLOR_BRIGHT); + DrawLine(x2, y1, screen_x, y2, COLOR_BRIGHT); + DrawLine(x2, screen_y, x1, y2, COLOR_BRIGHT); + DrawLine(x2, screen_y, screen_x, y2, COLOR_BRIGHT); + } else + DrawLine(screen_x, screen_y + AutoMapYPos, screen_x - AutoMapXPos, screen_y, COLOR_DIM); + } - if (do_cave_vert) { - if (flags & MAPFLAG_HORZDOOR) { - x1 = screen_x + AutoMapYPos; - x2 = screen_x + AutoMapXPos; - y1 = screen_y + AutoMapYPos; - y2 = screen_y + AMPlayerX; + if (do_cave_vert) { + if (flags & MAPFLAG_HORZDOOR) { + x1 = screen_x + AutoMapYPos; + x2 = screen_x + AutoMapXPos; + y1 = screen_y + AutoMapYPos; + y2 = screen_y + AMPlayerX; - DrawLine(screen_x, y1, screen_x + AMPlayerX, y1 - AMPlayerY, COLOR_DIM); - DrawLine(x2, screen_y, x2 - AMPlayerX, screen_y + AMPlayerY, COLOR_DIM); - DrawLine(x1, y1, screen_x, y2, COLOR_BRIGHT); - DrawLine(x1, y1, x2, y2, COLOR_BRIGHT); - DrawLine(x1, screen_y, screen_x, y2, COLOR_BRIGHT); - DrawLine(x1, screen_y, x2, y2, COLOR_BRIGHT); - } else - DrawLine(screen_x, screen_y + AutoMapYPos, screen_x + AutoMapXPos, screen_y, COLOR_DIM); - } + DrawLine(screen_x, y1, screen_x + AMPlayerX, y1 - AMPlayerY, COLOR_DIM); + DrawLine(x2, screen_y, x2 - AMPlayerX, screen_y + AMPlayerY, COLOR_DIM); + DrawLine(x1, y1, screen_x, y2, COLOR_BRIGHT); + DrawLine(x1, y1, x2, y2, COLOR_BRIGHT); + DrawLine(x1, screen_y, screen_x, y2, COLOR_BRIGHT); + DrawLine(x1, screen_y, x2, y2, COLOR_BRIGHT); + } else + DrawLine(screen_x, screen_y + AutoMapYPos, screen_x + AutoMapXPos, screen_y, COLOR_DIM); + } } void __cdecl DrawAutomapPlr() { - int posx, posy; - int x, y; + int posx, posy; + int x, y; - if (plr[myplr]._pmode == PM_WALK3) { - x = plr[myplr]._px; - y = plr[myplr]._py; - if (plr[myplr]._pdir == DIR_W) - x++; - else - y++; - } else { - x = plr[myplr].WorldX; - y = plr[myplr].WorldY; - } - posx = x - 2 * AutoMapXOfs - ViewX; - posy = y - 2 * AutoMapYOfs - ViewY; + if (plr[myplr]._pmode == PM_WALK3) { + x = plr[myplr]._px; + y = plr[myplr]._py; + if (plr[myplr]._pdir == DIR_W) + x++; + else + y++; + } else { + x = plr[myplr].WorldX; + y = plr[myplr].WorldY; + } + posx = x - 2 * AutoMapXOfs - ViewX; + posy = y - 2 * AutoMapYOfs - ViewY; - x = (plr[myplr]._pxoff * AutoMapScale / 100 >> 1) + (ScrollInfo._sxoff * AutoMapScale / 100 >> 1) + (posx - posy) * AutoMapYPos + 384; - y = (plr[myplr]._pyoff * AutoMapScale / 100 >> 1) + (ScrollInfo._syoff * AutoMapScale / 100 >> 1) + (posx + posy) * AMPlayerX + 336; + x = (plr[myplr]._pxoff * AutoMapScale / 100 >> 1) + (ScrollInfo._sxoff * AutoMapScale / 100 >> 1) + (posx - posy) * AutoMapYPos + 384; + y = (plr[myplr]._pyoff * AutoMapScale / 100 >> 1) + (ScrollInfo._syoff * AutoMapScale / 100 >> 1) + (posx + posy) * AMPlayerX + 336; - if (invflag || sbookflag) - x -= 160; - if (chrflag || questlog) - x += 160; - y -= AMPlayerX; + if (invflag || sbookflag) + x -= 160; + if (chrflag || questlog) + x += 160; + y -= AMPlayerX; - switch (plr[myplr]._pdir) { - case DIR_N: - DrawLine(x, y, x, y - AutoMapYPos, COLOR_PLAYER); - DrawLine(x, y - AutoMapYPos, x - AMPlayerY, y - AMPlayerX, COLOR_PLAYER); - DrawLine(x, y - AutoMapYPos, x + AMPlayerY, y - AMPlayerX, COLOR_PLAYER); - break; - case DIR_NE: - DrawLine(x, y, x + AutoMapYPos, y - AMPlayerX, COLOR_PLAYER); - DrawLine(x + AutoMapYPos, y - AMPlayerX, x + AMPlayerX, y - AMPlayerX, COLOR_PLAYER); - DrawLine(x + AutoMapYPos, y - AMPlayerX, x + AMPlayerX + AMPlayerY, y, COLOR_PLAYER); - break; - case DIR_E: - DrawLine(x, y, x + AutoMapYPos, y, COLOR_PLAYER); - DrawLine(x + AutoMapYPos, y, x + AMPlayerX, y - AMPlayerY, COLOR_PLAYER); - DrawLine(x + AutoMapYPos, y, x + AMPlayerX, y + AMPlayerY, COLOR_PLAYER); - break; - case DIR_SE: - DrawLine(x, y, x + AutoMapYPos, y + AMPlayerX, COLOR_PLAYER); - DrawLine(x + AutoMapYPos, y + AMPlayerX, x + AMPlayerX + AMPlayerY, y, COLOR_PLAYER); - DrawLine(x + AutoMapYPos, y + AMPlayerX, x + AMPlayerX, y + AMPlayerX, COLOR_PLAYER); - break; - case DIR_S: - DrawLine(x, y, x, y + AutoMapYPos, COLOR_PLAYER); - DrawLine(x, y + AutoMapYPos, x + AMPlayerY, y + AMPlayerX, COLOR_PLAYER); - DrawLine(x, y + AutoMapYPos, x - AMPlayerY, y + AMPlayerX, COLOR_PLAYER); - break; - case DIR_SW: - DrawLine(x, y, x - AutoMapYPos, y + AMPlayerX, COLOR_PLAYER); - DrawLine(x - AutoMapYPos, y + AMPlayerX, x - AMPlayerY - AMPlayerX, y, COLOR_PLAYER); - DrawLine(x - AutoMapYPos, y + AMPlayerX, x - AMPlayerX, y + AMPlayerX, COLOR_PLAYER); - break; - case DIR_W: - DrawLine(x, y, x - AutoMapYPos, y, COLOR_PLAYER); - DrawLine(x - AutoMapYPos, y, x - AMPlayerX, y - AMPlayerY, COLOR_PLAYER); - DrawLine(x - AutoMapYPos, y, x - AMPlayerX, y + AMPlayerY, COLOR_PLAYER); - break; - case DIR_NW: - DrawLine(x, y, x - AutoMapYPos, y - AMPlayerX, COLOR_PLAYER); - DrawLine(x - AutoMapYPos, y - AMPlayerX, x - AMPlayerX, y - AMPlayerX, COLOR_PLAYER); - DrawLine(x - AutoMapYPos, y - AMPlayerX, x - AMPlayerY - AMPlayerX, y, COLOR_PLAYER); - } + switch (plr[myplr]._pdir) { + case DIR_N: + DrawLine(x, y, x, y - AutoMapYPos, COLOR_PLAYER); + DrawLine(x, y - AutoMapYPos, x - AMPlayerY, y - AMPlayerX, COLOR_PLAYER); + DrawLine(x, y - AutoMapYPos, x + AMPlayerY, y - AMPlayerX, COLOR_PLAYER); + break; + case DIR_NE: + DrawLine(x, y, x + AutoMapYPos, y - AMPlayerX, COLOR_PLAYER); + DrawLine(x + AutoMapYPos, y - AMPlayerX, x + AMPlayerX, y - AMPlayerX, COLOR_PLAYER); + DrawLine(x + AutoMapYPos, y - AMPlayerX, x + AMPlayerX + AMPlayerY, y, COLOR_PLAYER); + break; + case DIR_E: + DrawLine(x, y, x + AutoMapYPos, y, COLOR_PLAYER); + DrawLine(x + AutoMapYPos, y, x + AMPlayerX, y - AMPlayerY, COLOR_PLAYER); + DrawLine(x + AutoMapYPos, y, x + AMPlayerX, y + AMPlayerY, COLOR_PLAYER); + break; + case DIR_SE: + DrawLine(x, y, x + AutoMapYPos, y + AMPlayerX, COLOR_PLAYER); + DrawLine(x + AutoMapYPos, y + AMPlayerX, x + AMPlayerX + AMPlayerY, y, COLOR_PLAYER); + DrawLine(x + AutoMapYPos, y + AMPlayerX, x + AMPlayerX, y + AMPlayerX, COLOR_PLAYER); + break; + case DIR_S: + DrawLine(x, y, x, y + AutoMapYPos, COLOR_PLAYER); + DrawLine(x, y + AutoMapYPos, x + AMPlayerY, y + AMPlayerX, COLOR_PLAYER); + DrawLine(x, y + AutoMapYPos, x - AMPlayerY, y + AMPlayerX, COLOR_PLAYER); + break; + case DIR_SW: + DrawLine(x, y, x - AutoMapYPos, y + AMPlayerX, COLOR_PLAYER); + DrawLine(x - AutoMapYPos, y + AMPlayerX, x - AMPlayerY - AMPlayerX, y, COLOR_PLAYER); + DrawLine(x - AutoMapYPos, y + AMPlayerX, x - AMPlayerX, y + AMPlayerX, COLOR_PLAYER); + break; + case DIR_W: + DrawLine(x, y, x - AutoMapYPos, y, COLOR_PLAYER); + DrawLine(x - AutoMapYPos, y, x - AMPlayerX, y - AMPlayerY, COLOR_PLAYER); + DrawLine(x - AutoMapYPos, y, x - AMPlayerX, y + AMPlayerY, COLOR_PLAYER); + break; + case DIR_NW: + DrawLine(x, y, x - AutoMapYPos, y - AMPlayerX, COLOR_PLAYER); + DrawLine(x - AutoMapYPos, y - AMPlayerX, x - AMPlayerX, y - AMPlayerX, COLOR_PLAYER); + DrawLine(x - AutoMapYPos, y - AMPlayerX, x - AMPlayerY - AMPlayerX, y, COLOR_PLAYER); + } } WORD __fastcall GetAutomapType(int x, int y, BOOL view) { - if (view) { - if (x == -1 && y >= 0 && y < DMAXY && automapview[0][y]) - return ~GetAutomapType(0, y, FALSE) & (MAPFLAG_SQUARE << 8); - if (y == -1) { - if (x < 0) - return 0; - if (x < DMAXX && automapview[x][0]) - return ~GetAutomapType(x, 0, FALSE) & (MAPFLAG_SQUARE << 8); - } - } + if (view) { + if (x == -1 && y >= 0 && y < DMAXY && automapview[0][y]) + return ~GetAutomapType(0, y, FALSE) & (MAPFLAG_SQUARE << 8); + if (y == -1) { + if (x < 0) + return 0; + if (x < DMAXX && automapview[x][0]) + return ~GetAutomapType(x, 0, FALSE) & (MAPFLAG_SQUARE << 8); + } + } - if (x >= 0 && x < DMAXX && y >= 0 && y < DMAXY) { - if (automapview[x][y] || !view) { - WORD type = automaptype[(BYTE)dungeon[x][y]]; - if (type == 7 && GetAutomapType(x - 1, y, FALSE) & (MAPFLAG_HORZARCH << 8) - && GetAutomapType(x, y - 1, FALSE) & (MAPFLAG_VERTARCH << 8)) { - type = 1; - } - return type; - } - } - return 0; + if (x >= 0 && x < DMAXX && y >= 0 && y < DMAXY) { + if (automapview[x][y] || !view) { + WORD type = automaptype[(BYTE)dungeon[x][y]]; + if (type == 7 && GetAutomapType(x - 1, y, FALSE) & (MAPFLAG_HORZARCH << 8) + && GetAutomapType(x, y - 1, FALSE) & (MAPFLAG_VERTARCH << 8)) { + type = 1; + } + return type; + } + } + return 0; } void __cdecl DrawAutomapGame() { - char desc[256]; - int nextline = 20; + char desc[256]; + int nextline = 20; - if (gbMaxPlayers > 1) { - strcat(strcpy(desc, "game: "), szPlayerName); - PrintGameStr(8, 20, desc, COL_GOLD); - nextline = 35; - if (szPlayerDescript[0]) { - strcat(strcpy(desc, "password: "), szPlayerDescript); - PrintGameStr(8, 35, desc, COL_GOLD); - nextline = 50; - } - } - if (setlevel) - PrintGameStr(8, nextline, quest_level_names[(BYTE)setlvlnum], COL_GOLD); - else if (currlevel) { - sprintf(desc, "Level: %i", currlevel); - PrintGameStr(8, nextline, desc, COL_GOLD); - } + if (gbMaxPlayers > 1) { + strcat(strcpy(desc, "game: "), szPlayerName); + PrintGameStr(8, 20, desc, COL_GOLD); + nextline = 35; + if (szPlayerDescript[0]) { + strcat(strcpy(desc, "password: "), szPlayerDescript); + PrintGameStr(8, 35, desc, COL_GOLD); + nextline = 50; + } + } + if (setlevel) + PrintGameStr(8, nextline, quest_level_names[(BYTE)setlvlnum], COL_GOLD); + else if (currlevel) { + sprintf(desc, "Level: %i", currlevel); + PrintGameStr(8, nextline, desc, COL_GOLD); + } } void __fastcall SetAutomapView(int x, int y) { - int xx = (x - 16) >> 1; - int yy = (y - 16) >> 1; + int xx = (x - 16) >> 1; + int yy = (y - 16) >> 1; - if (xx < 0 || xx >= DMAXX || yy < 0 || yy >= DMAXY) { - return; - } + if (xx < 0 || xx >= DMAXX || yy < 0 || yy >= DMAXY) { + return; + } - automapview[xx][yy] = 1; + automapview[xx][yy] = 1; - WORD maptype = GetAutomapType(xx, yy, FALSE); - WORD solid = maptype & 0x4000; + WORD maptype = GetAutomapType(xx, yy, FALSE); + WORD solid = maptype & 0x4000; - switch (maptype & 0xF) { - case 2: - if (solid) { - if (GetAutomapType(xx, yy + 1, FALSE) == 0x4007) - automapview[xx][yy + 1] = 1; - } else if (GetAutomapType(xx - 1, yy, FALSE) & 0x4000) - automapview[xx - 1][yy] = 1; - break; - case 3: - if (solid) { - if (GetAutomapType(xx + 1, yy, FALSE) == 0x4007) - automapview[xx + 1][yy] = 1; - } else if (GetAutomapType(xx, yy - 1, FALSE) & 0x4000) - automapview[xx][yy - 1] = 1; - break; - case 4: - if (solid) { - if (GetAutomapType(xx, yy + 1, FALSE) == 0x4007) - automapview[xx][yy + 1] = 1; - if (GetAutomapType(xx + 1, yy, FALSE) == 0x4007) - automapview[xx + 1][yy] = 1; - } else { - if (GetAutomapType(xx - 1, yy, FALSE) & 0x4000) - automapview[xx - 1][yy] = 1; - if (GetAutomapType(xx, yy - 1, FALSE) & 0x4000) - automapview[xx][yy - 1] = 1; - if (GetAutomapType(xx - 1, yy - 1, FALSE) & 0x4000) - automapview[xx - 1][yy - 1] = 1; - } - break; - case 5: - if (solid) { - if (GetAutomapType(xx, yy - 1, FALSE) & 0x4000) - automapview[xx][yy - 1] = 1; - if (GetAutomapType(xx, yy + 1, FALSE) == 0x4007) - automapview[xx][yy + 1] = 1; - } else if (GetAutomapType(xx - 1, yy, FALSE) & 0x4000) - automapview[xx - 1][yy] = 1; - break; - case 6: - if (solid) { - if (GetAutomapType(xx - 1, yy, FALSE) & 0x4000) - automapview[xx - 1][yy] = 1; - if (GetAutomapType(xx + 1, yy, FALSE) == 0x4007) - automapview[xx + 1][yy] = 1; - } else if (GetAutomapType(xx, yy - 1, FALSE) & 0x4000) - automapview[xx][yy - 1] = 1; - } + switch (maptype & 0xF) { + case 2: + if (solid) { + if (GetAutomapType(xx, yy + 1, FALSE) == 0x4007) + automapview[xx][yy + 1] = 1; + } else if (GetAutomapType(xx - 1, yy, FALSE) & 0x4000) + automapview[xx - 1][yy] = 1; + break; + case 3: + if (solid) { + if (GetAutomapType(xx + 1, yy, FALSE) == 0x4007) + automapview[xx + 1][yy] = 1; + } else if (GetAutomapType(xx, yy - 1, FALSE) & 0x4000) + automapview[xx][yy - 1] = 1; + break; + case 4: + if (solid) { + if (GetAutomapType(xx, yy + 1, FALSE) == 0x4007) + automapview[xx][yy + 1] = 1; + if (GetAutomapType(xx + 1, yy, FALSE) == 0x4007) + automapview[xx + 1][yy] = 1; + } else { + if (GetAutomapType(xx - 1, yy, FALSE) & 0x4000) + automapview[xx - 1][yy] = 1; + if (GetAutomapType(xx, yy - 1, FALSE) & 0x4000) + automapview[xx][yy - 1] = 1; + if (GetAutomapType(xx - 1, yy - 1, FALSE) & 0x4000) + automapview[xx - 1][yy - 1] = 1; + } + break; + case 5: + if (solid) { + if (GetAutomapType(xx, yy - 1, FALSE) & 0x4000) + automapview[xx][yy - 1] = 1; + if (GetAutomapType(xx, yy + 1, FALSE) == 0x4007) + automapview[xx][yy + 1] = 1; + } else if (GetAutomapType(xx - 1, yy, FALSE) & 0x4000) + automapview[xx - 1][yy] = 1; + break; + case 6: + if (solid) { + if (GetAutomapType(xx - 1, yy, FALSE) & 0x4000) + automapview[xx - 1][yy] = 1; + if (GetAutomapType(xx + 1, yy, FALSE) == 0x4007) + automapview[xx + 1][yy] = 1; + } else if (GetAutomapType(xx, yy - 1, FALSE) & 0x4000) + automapview[xx][yy - 1] = 1; + } } void __cdecl AutomapZoomReset() { - AutoMapXOfs = 0; - AutoMapYOfs = 0; - AutoMapPosBits = (AutoMapScale << 6) / 100; - AutoMapXPos = AutoMapPosBits >> 1; - AutoMapYPos = AutoMapXPos >> 1; - AMPlayerX = AutoMapYPos >> 1; - AMPlayerY = AMPlayerX >> 1; + AutoMapXOfs = 0; + AutoMapYOfs = 0; + AutoMapPosBits = (AutoMapScale << 6) / 100; + AutoMapXPos = AutoMapPosBits >> 1; + AutoMapYPos = AutoMapXPos >> 1; + AMPlayerX = AutoMapYPos >> 1; + AMPlayerY = AMPlayerX >> 1; } diff --git a/Source/capture.cpp b/Source/capture.cpp index 26f4a155..4d0b722c 100644 --- a/Source/capture.cpp +++ b/Source/capture.cpp @@ -4,154 +4,154 @@ void __cdecl CaptureScreen() { - PALETTEENTRY palette[256]; - char FileName[MAX_PATH]; + PALETTEENTRY palette[256]; + char FileName[MAX_PATH]; - HANDLE hObject = CaptureFile(FileName); - if (hObject != INVALID_HANDLE_VALUE) { - DrawAndBlit(); - lpDDPalette->GetEntries(0, 0, 256, palette); - RedPalette(palette); + HANDLE hObject = CaptureFile(FileName); + if (hObject != INVALID_HANDLE_VALUE) { + DrawAndBlit(); + lpDDPalette->GetEntries(0, 0, 256, palette); + RedPalette(palette); - j_lock_buf_priv(2); - bool success = CaptureHdr(hObject, 640, 480); - if (success) { - success = CapturePix(hObject, 640, 480, 768, (BYTE *)gpBuffer->row[0].pixels); - if (success) { - success = CapturePal(hObject, palette); - } - } - j_unlock_buf_priv(2); - CloseHandle(hObject); + j_lock_buf_priv(2); + bool success = CaptureHdr(hObject, 640, 480); + if (success) { + success = CapturePix(hObject, 640, 480, 768, (BYTE *)gpBuffer->row[0].pixels); + if (success) { + success = CapturePal(hObject, palette); + } + } + j_unlock_buf_priv(2); + CloseHandle(hObject); - if (!success) - DeleteFile(FileName); + if (!success) + DeleteFile(FileName); - Sleep(300); - lpDDPalette->SetEntries(0, 0, 256, palette); - } + Sleep(300); + lpDDPalette->SetEntries(0, 0, 256, palette); + } } bool __fastcall CaptureHdr(HANDLE hFile, short width, short height) { - PCXHeader Buffer; - memset(&Buffer, 0, sizeof(Buffer)); + PCXHeader Buffer; + memset(&Buffer, 0, sizeof(Buffer)); - Buffer.xmax = width - 1; - Buffer.vertRes = height; - Buffer.manufacturer = 10; - Buffer.version = 5; - Buffer.encoding = 1; - Buffer.bitsPerPixel = 8; - Buffer.ymax = height - 1; - Buffer.horzRes = width; - Buffer.numColorPlanes = 1; - Buffer.bytesPerScanLine = width; + Buffer.xmax = width - 1; + Buffer.vertRes = height; + Buffer.manufacturer = 10; + Buffer.version = 5; + Buffer.encoding = 1; + Buffer.bitsPerPixel = 8; + Buffer.ymax = height - 1; + Buffer.horzRes = width; + Buffer.numColorPlanes = 1; + Buffer.bytesPerScanLine = width; - DWORD lpNumBytes; - return WriteFile(hFile, &Buffer, sizeof(Buffer), &lpNumBytes, NULL) && lpNumBytes == sizeof(Buffer); + DWORD lpNumBytes; + return WriteFile(hFile, &Buffer, sizeof(Buffer), &lpNumBytes, NULL) && lpNumBytes == sizeof(Buffer); } bool __fastcall CapturePal(HANDLE hFile, PALETTEENTRY *palette) { - char *v3; - char Buffer[769]; + char *v3; + char Buffer[769]; - Buffer[0] = 12; - v3 = &Buffer[1]; - for (int i = 256; i != 0; --i) { - v3[0] = palette->peRed; - v3[1] = palette->peGreen; - v3[2] = palette->peBlue; + Buffer[0] = 12; + v3 = &Buffer[1]; + for (int i = 256; i != 0; --i) { + v3[0] = palette->peRed; + v3[1] = palette->peGreen; + v3[2] = palette->peBlue; - palette++; - v3 += 3; - } + palette++; + v3 += 3; + } - DWORD lpNumBytes; - return WriteFile(hFile, Buffer, sizeof(Buffer), &lpNumBytes, NULL) && lpNumBytes == sizeof(Buffer); + DWORD lpNumBytes; + return WriteFile(hFile, Buffer, sizeof(Buffer), &lpNumBytes, NULL) && lpNumBytes == sizeof(Buffer); } bool __fastcall CapturePix(HANDLE hFile, WORD width, WORD height, WORD stride, BYTE *pixels) { - int writeSize; - DWORD lpNumBytes; + int writeSize; + DWORD lpNumBytes; - BYTE *pBuffer = (BYTE *)DiabloAllocPtr(2 * width); - do { - if (!height) { - mem_free_dbg(pBuffer); - return 1; - } - height--; - BYTE *pBufferEnd = CaptureEnc(pixels, pBuffer, width); - pixels += stride; - writeSize = pBufferEnd - pBuffer; - } while (WriteFile(hFile, pBuffer, writeSize, &lpNumBytes, 0) && lpNumBytes == writeSize); - return 0; + BYTE *pBuffer = (BYTE *)DiabloAllocPtr(2 * width); + do { + if (!height) { + mem_free_dbg(pBuffer); + return 1; + } + height--; + BYTE *pBufferEnd = CaptureEnc(pixels, pBuffer, width); + pixels += stride; + writeSize = pBufferEnd - pBuffer; + } while (WriteFile(hFile, pBuffer, writeSize, &lpNumBytes, 0) && lpNumBytes == writeSize); + return 0; } BYTE *__fastcall CaptureEnc(BYTE *src, BYTE *dst, int width) { - do { - BYTE rlePixel = *src++; - --width; + do { + BYTE rlePixel = *src++; + --width; - int rleLength = 1; - while (rlePixel == *src) { - if (rleLength >= 63) - break; - if (!width) - break; - ++rleLength; + int rleLength = 1; + while (rlePixel == *src) { + if (rleLength >= 63) + break; + if (!width) + break; + ++rleLength; - --width; - ++src; - } + --width; + ++src; + } - if (rlePixel > 0xBF || rleLength > 1) { - *dst++ = rleLength | 0xC0; - } - *dst++ = rlePixel; - } while (width); - return dst; + if (rlePixel > 0xBF || rleLength > 1) { + *dst++ = rleLength | 0xC0; + } + *dst++ = rlePixel; + } while (width); + return dst; } HANDLE __fastcall CaptureFile(char *dst_path) { - bool num_used[100] = { false }; + bool num_used[100] = { false }; - _finddata_t finder; - int hFind = _findfirst("screen??.PCX", &finder); - if (hFind != -1) { - do { - if (isdigit(finder.name[6]) && isdigit(finder.name[7])) { - num_used[10 * (finder.name[6] - '0') + (finder.name[7] - '0')] = true; - } - } while (_findnext(hFind, &finder) == 0); - } + _finddata_t finder; + int hFind = _findfirst("screen??.PCX", &finder); + if (hFind != -1) { + do { + if (isdigit(finder.name[6]) && isdigit(finder.name[7])) { + num_used[10 * (finder.name[6] - '0') + (finder.name[7] - '0')] = true; + } + } while (_findnext(hFind, &finder) == 0); + } - int free_num = 0; - while (num_used[free_num]) { - ++free_num; - if (free_num >= 100) - return INVALID_HANDLE_VALUE; - } + int free_num = 0; + while (num_used[free_num]) { + ++free_num; + if (free_num >= 100) + return INVALID_HANDLE_VALUE; + } - sprintf(dst_path, "screen%02d.PCX", free_num); - return CreateFile(dst_path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + sprintf(dst_path, "screen%02d.PCX", free_num); + return CreateFile(dst_path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); } void __fastcall RedPalette(PALETTEENTRY *pal) { - PALETTEENTRY red[256]; + PALETTEENTRY red[256]; - for (int i = 0; i < 256; i++) { - red[i].peRed = pal[i].peRed; - red[i].peGreen = 0; - red[i].peBlue = 0; - red[i].peFlags = 0; - } + for (int i = 0; i < 256; i++) { + red[i].peRed = pal[i].peRed; + red[i].peGreen = 0; + red[i].peBlue = 0; + red[i].peFlags = 0; + } - lpDDPalette->SetEntries(0, 0, 256, red); + lpDDPalette->SetEntries(0, 0, 256, red); } diff --git a/Source/codec.cpp b/Source/codec.cpp index 05e96920..2fc03abb 100644 --- a/Source/codec.cpp +++ b/Source/codec.cpp @@ -4,92 +4,92 @@ int __fastcall codec_decode(void *pbSrcDst, int size, char *pszPassword) { - unsigned int v3; // ebx - char *v4; // esi - int v5; // ebx - signed int v7; // ecx - int v8; // esi - char v9[128]; // [esp+8h] [ebp-98h] - char dst[20]; // [esp+88h] [ebp-18h] - int v11; // [esp+9Ch] [ebp-4h] - char *passworda; // [esp+A8h] [ebp+8h] + unsigned int v3; // ebx + char *v4; // esi + int v5; // ebx + signed int v7; // ecx + int v8; // esi + char v9[128]; // [esp+8h] [ebp-98h] + char dst[20]; // [esp+88h] [ebp-18h] + int v11; // [esp+9Ch] [ebp-4h] + char *passworda; // [esp+A8h] [ebp+8h] - v3 = size; - v4 = (char *)pbSrcDst; - codec_init_key(0, pszPassword); - if (v3 <= 8) - return 0; - v5 = v3 - 8; - v11 = v5; - if (v5 & 0x3F) - return 0; - passworda = (char *)v5; - if (v5) { - do { - memcpy(v9, v4, 0x40u); - SHA1Result(0, dst); - v7 = 0; - do { - v9[v7] ^= dst[v7 % 20]; - ++v7; - } while (v7 < 64); - SHA1Calculate(0, v9, NULL); - memset(dst, 0, sizeof(dst)); - memcpy(v4, v9, 0x40u); - v4 += 64; - passworda -= 64; - } while (passworda); - v5 = v11; - } - memset(v9, 0, sizeof(v9)); - if (!v4[4]) { - SHA1Result(0, dst); - if (*(_DWORD *)v4 == *(_DWORD *)dst) { - v8 = v5 + (unsigned char)v4[5] - 64; - goto LABEL_14; - } - memset(dst, 0, sizeof(dst)); - } - v8 = 0; + v3 = size; + v4 = (char *)pbSrcDst; + codec_init_key(0, pszPassword); + if (v3 <= 8) + return 0; + v5 = v3 - 8; + v11 = v5; + if (v5 & 0x3F) + return 0; + passworda = (char *)v5; + if (v5) { + do { + memcpy(v9, v4, 0x40u); + SHA1Result(0, dst); + v7 = 0; + do { + v9[v7] ^= dst[v7 % 20]; + ++v7; + } while (v7 < 64); + SHA1Calculate(0, v9, NULL); + memset(dst, 0, sizeof(dst)); + memcpy(v4, v9, 0x40u); + v4 += 64; + passworda -= 64; + } while (passworda); + v5 = v11; + } + memset(v9, 0, sizeof(v9)); + if (!v4[4]) { + SHA1Result(0, dst); + if (*(_DWORD *)v4 == *(_DWORD *)dst) { + v8 = v5 + (unsigned char)v4[5] - 64; + goto LABEL_14; + } + memset(dst, 0, sizeof(dst)); + } + v8 = 0; LABEL_14: - SHA1Clear(); - return v8; + SHA1Clear(); + return v8; } // 4034D9: using guessed type char var_98[128]; void __fastcall codec_init_key(int unused, char *pszPassword) { - int i; - char key[136]; // last 64 bytes are the SHA1 - char pw[64]; - char digest[SHA1HashSize]; + int i; + char key[136]; // last 64 bytes are the SHA1 + char pw[64]; + char digest[SHA1HashSize]; - srand(0x7058); + srand(0x7058); - char *keyInit = key; - for (i = 0; i < 136; i++) { - *keyInit = rand(); - keyInit++; - } - int ch = 0; - for (i = 0; i < 64; i++) { - if (!pszPassword[ch]) - ch = 0; - pw[i] = pszPassword[ch]; - ch++; - } - SHA1Reset(0); - SHA1Calculate(0, pw, digest); - SHA1Clear(); - for (i = 0; (DWORD)i < 136; i++) - key[i] ^= digest[i % 20]; - memset(pw, 0, sizeof(pw)); - memset(digest, 0, sizeof(digest)); - for (int n = 0; n < 3; n++) { - SHA1Reset(n); - SHA1Calculate(n, &key[72], NULL); - } - memset(key, 0, sizeof(key)); + char *keyInit = key; + for (i = 0; i < 136; i++) { + *keyInit = rand(); + keyInit++; + } + int ch = 0; + for (i = 0; i < 64; i++) { + if (!pszPassword[ch]) + ch = 0; + pw[i] = pszPassword[ch]; + ch++; + } + SHA1Reset(0); + SHA1Calculate(0, pw, digest); + SHA1Clear(); + for (i = 0; (DWORD)i < 136; i++) + key[i] ^= digest[i % 20]; + memset(pw, 0, sizeof(pw)); + memset(digest, 0, sizeof(digest)); + for (int n = 0; n < 3; n++) { + SHA1Reset(n); + SHA1Calculate(n, &key[72], NULL); + } + memset(key, 0, sizeof(key)); } // 4035DB: using guessed type char var_E0[72]; // 4035DB: using guessed type char var_58[64]; @@ -97,57 +97,57 @@ void __fastcall codec_init_key(int unused, char *pszPassword) int __fastcall codec_get_encoded_len(int dwSrcBytes) { - if (dwSrcBytes & 0x3F) - dwSrcBytes += 64 - (dwSrcBytes & 0x3F); - return dwSrcBytes + 8; + if (dwSrcBytes & 0x3F) + dwSrcBytes += 64 - (dwSrcBytes & 0x3F); + return dwSrcBytes + 8; } void __fastcall codec_encode(void *pbSrcDst, int size, int size_64, char *pszPassword) { - char *v4; // esi - char v5; // bl - size_t v6; // edi - signed int v7; // ecx - char v9[128]; // [esp+8h] [ebp-ACh] - char v10[20]; // [esp+88h] [ebp-2Ch] - char dst[20]; // [esp+9Ch] [ebp-18h] - size_t v12; // [esp+B0h] [ebp-4h] + char *v4; // esi + char v5; // bl + size_t v6; // edi + signed int v7; // ecx + char v9[128]; // [esp+8h] [ebp-ACh] + char v10[20]; // [esp+88h] [ebp-2Ch] + char dst[20]; // [esp+9Ch] [ebp-18h] + size_t v12; // [esp+B0h] [ebp-4h] - v4 = (char *)pbSrcDst; - v12 = size; - if (size_64 != codec_get_encoded_len(size)) - TermMsg("Invalid encode parameters"); - codec_init_key(1, pszPassword); - v5 = 0; - if (v12) { - do { - v6 = v12; - if (v12 >= 0x40) - v6 = 64; - memcpy(v9, v4, v6); - if (v6 < 0x40) - memset(&v9[v6], 0, 64 - v6); - SHA1Result(0, dst); - SHA1Calculate(0, v9, NULL); - v7 = 0; - do { - v9[v7] ^= dst[v7 % 20]; - ++v7; - } while (v7 < 64); - memset(dst, 0, sizeof(dst)); - memcpy(v4, v9, 0x40u); - v4 += 64; - v12 -= v6; - } while (v12); - v5 = v6; - } - memset(v9, 0, sizeof(v9)); - SHA1Result(0, v10); - v4[4] = 0; - *((_WORD *)v4 + 3) = 0; - *(_DWORD *)v4 = *(_DWORD *)v10; - v4[5] = v5; - SHA1Clear(); + v4 = (char *)pbSrcDst; + v12 = size; + if (size_64 != codec_get_encoded_len(size)) + TermMsg("Invalid encode parameters"); + codec_init_key(1, pszPassword); + v5 = 0; + if (v12) { + do { + v6 = v12; + if (v12 >= 0x40) + v6 = 64; + memcpy(v9, v4, v6); + if (v6 < 0x40) + memset(&v9[v6], 0, 64 - v6); + SHA1Result(0, dst); + SHA1Calculate(0, v9, NULL); + v7 = 0; + do { + v9[v7] ^= dst[v7 % 20]; + ++v7; + } while (v7 < 64); + memset(dst, 0, sizeof(dst)); + memcpy(v4, v9, 0x40u); + v4 += 64; + v12 -= v6; + } while (v12); + v5 = v6; + } + memset(v9, 0, sizeof(v9)); + SHA1Result(0, v10); + v4[4] = 0; + *((_WORD *)v4 + 3) = 0; + *(_DWORD *)v4 = *(_DWORD *)v10; + v4[5] = v5; + SHA1Clear(); } // 4036BE: using guessed type char var_AC[128]; // 4036BE: using guessed type char dst[20]; diff --git a/Source/control.cpp b/Source/control.cpp index 6fd3f457..c2ae9f08 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -58,495 +58,495 @@ void *pTalkPanel; // idb int spselflag; // weak const unsigned char fontframe[127] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 54, 44, 57, 58, 56, 55, 47, - 40, 41, 59, 39, 50, 37, 51, 52, 36, 27, - 28, 29, 30, 31, 32, 33, 34, 35, 48, 49, - 60, 38, 61, 53, 62, 1, 2, 3, 4, 5, - 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, - 26, 42, 63, 43, 64, 65, 0, 1, 2, 3, - 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 40, 66, 41, 67 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 54, 44, 57, 58, 56, 55, 47, + 40, 41, 59, 39, 50, 37, 51, 52, 36, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 48, 49, + 60, 38, 61, 53, 62, 1, 2, 3, 4, 5, + 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, + 26, 42, 63, 43, 64, 65, 0, 1, 2, 3, + 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 40, 66, 41, 67 }; const unsigned char fontkern[68] = { - 8, 10, 7, 9, 8, 7, 6, 8, 8, 3, - 3, 8, 6, 11, 9, 10, 6, 9, 9, 6, - 9, 11, 10, 13, 10, 11, 7, 5, 7, 7, - 8, 7, 7, 7, 7, 7, 10, 4, 5, 6, - 3, 3, 4, 3, 6, 6, 3, 3, 3, 3, - 3, 2, 7, 6, 3, 10, 10, 6, 6, 7, - 4, 4, 9, 6, 6, 12, 3, 7 + 8, 10, 7, 9, 8, 7, 6, 8, 8, 3, + 3, 8, 6, 11, 9, 10, 6, 9, 9, 6, + 9, 11, 10, 13, 10, 11, 7, 5, 7, 7, + 8, 7, 7, 7, 7, 7, 10, 4, 5, 6, + 3, 3, 4, 3, 6, 6, 3, 3, 3, 3, + 3, 2, 7, 6, 3, 10, 10, 6, 6, 7, + 4, 4, 9, 6, 6, 12, 3, 7 }; const int lineoffset[25] = { - 768 * 594 + 241, - 768 * 32, - 768 * 32, - 768 * 32, - 768 * 32 + 180, - 768 * 582 + 241, - 768 * 606 + 241, - 768 * 32, - 768 * 32, - 768 * 32, - 768 * 576 + 241, - 768 * 594 + 241, - 768 * 612 + 241, - 768 * 32, - 768 * 32, - 768 * 572 + 241, - 768 * 587 + 241, - 768 * 601 + 241, - 768 * 616 + 241, - 768 * 32, - 768 * 570 + 241, - 768 * 582 + 241, - 768 * 594 + 241, - 768 * 606 + 241, - 768 * 617 + 241 + 768 * 594 + 241, + 768 * 32, + 768 * 32, + 768 * 32, + 768 * 32 + 180, + 768 * 582 + 241, + 768 * 606 + 241, + 768 * 32, + 768 * 32, + 768 * 32, + 768 * 576 + 241, + 768 * 594 + 241, + 768 * 612 + 241, + 768 * 32, + 768 * 32, + 768 * 572 + 241, + 768 * 587 + 241, + 768 * 601 + 241, + 768 * 616 + 241, + 768 * 32, + 768 * 570 + 241, + 768 * 582 + 241, + 768 * 594 + 241, + 768 * 606 + 241, + 768 * 617 + 241 }; const unsigned char fontidx[256] = { - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, - 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, - 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, - 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, - 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, - 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, - 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, - 120, 121, 122, 123, 124, 125, 126, 1, 67, 117, - 101, 97, 97, 97, 97, 99, 101, 101, 101, 105, - 105, 105, 65, 65, 69, 97, 65, 111, 111, 111, - 117, 117, 121, 79, 85, 99, 76, 89, 80, 102, - 97, 105, 111, 117, 110, 78, 97, 111, 63, 1, - 1, 1, 1, 33, 60, 62, 111, 43, 50, 51, - 39, 117, 80, 46, 44, 49, 48, 62, 1, 1, - 1, 63, 65, 65, 65, 65, 65, 65, 65, 67, - 69, 69, 69, 69, 73, 73, 73, 73, 68, 78, - 79, 79, 79, 79, 79, 88, 48, 85, 85, 85, - 85, 89, 98, 66, 97, 97, 97, 97, 97, 97, - 97, 99, 101, 101, 101, 101, 105, 105, 105, 105, - 111, 110, 111, 111, 111, 111, 111, 47, 48, 117, - 117, 117, 117, 121, 98, 121 + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, + 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, + 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, + 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, + 120, 121, 122, 123, 124, 125, 126, 1, 67, 117, + 101, 97, 97, 97, 97, 99, 101, 101, 101, 105, + 105, 105, 65, 65, 69, 97, 65, 111, 111, 111, + 117, 117, 121, 79, 85, 99, 76, 89, 80, 102, + 97, 105, 111, 117, 110, 78, 97, 111, 63, 1, + 1, 1, 1, 33, 60, 62, 111, 43, 50, 51, + 39, 117, 80, 46, 44, 49, 48, 62, 1, 1, + 1, 63, 65, 65, 65, 65, 65, 65, 65, 67, + 69, 69, 69, 69, 73, 73, 73, 73, 68, 78, + 79, 79, 79, 79, 79, 88, 48, 85, 85, 85, + 85, 89, 98, 66, 97, 97, 97, 97, 97, 97, + 97, 99, 101, 101, 101, 101, 105, 105, 105, 105, + 111, 110, 111, 111, 111, 111, 111, 47, 48, 117, + 117, 117, 117, 121, 98, 121 }; /* data */ unsigned char SpellITbl[MAX_SPELLS] = { - 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, - 28, 13, 12, 18, 16, 14, 18, 19, 11, 20, - 15, 21, 23, 24, 25, 22, 26, 29, 37, 38, - 39, 42, 41, 40, 10, 36, 30 + 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 28, 13, 12, 18, 16, 14, 18, 19, 11, 20, + 15, 21, 23, 24, 25, 22, 26, 29, 37, 38, + 39, 42, 41, 40, 10, 36, 30 }; int PanBtnPos[8][5] = { - { 9, 361, 71, 19, 1 }, - { 9, 387, 71, 19, 0 }, - { 9, 427, 71, 19, 1 }, - { 9, 453, 71, 19, 0 }, - { 560, 361, 71, 19, 1 }, - { 560, 387, 71, 19, 0 }, - { 87, 443, 33, 32, 1 }, - { 527, 443, 33, 32, 1 } + { 9, 361, 71, 19, 1 }, + { 9, 387, 71, 19, 0 }, + { 9, 427, 71, 19, 1 }, + { 9, 453, 71, 19, 0 }, + { 560, 361, 71, 19, 1 }, + { 560, 387, 71, 19, 0 }, + { 87, 443, 33, 32, 1 }, + { 527, 443, 33, 32, 1 } }; char *PanBtnHotKey[8] = { "'c'", "'q'", "Tab", "Esc", "'i'", "'b'", "Enter", NULL }; char *PanBtnStr[8] = { - "Character Information", - "Quests log", - "Automap", - "Main Menu", - "Inventory", - "Spell book", - "Send Message", - "Player Attack" + "Character Information", + "Quests log", + "Automap", + "Main Menu", + "Inventory", + "Spell book", + "Send Message", + "Player Attack" }; int attribute_inc_rects[4][4] = { - { 137, 138, 41, 22 }, - { 137, 166, 41, 22 }, - { 137, 195, 41, 22 }, - { 137, 223, 41, 22 } + { 137, 138, 41, 22 }, + { 137, 166, 41, 22 }, + { 137, 195, 41, 22 }, + { 137, 223, 41, 22 } }; int SpellPages[6][7] = { - { SPL_NULL, SPL_FIREBOLT, SPL_CBOLT, SPL_HBOLT, SPL_HEAL, SPL_HEALOTHER, SPL_FLAME }, - { SPL_RESURRECT, SPL_FIREWALL, SPL_TELEKINESIS, SPL_LIGHTNING, SPL_TOWN, SPL_FLASH, SPL_STONE }, - { SPL_RNDTELEPORT, SPL_MANASHIELD, SPL_ELEMENT, SPL_FIREBALL, SPL_WAVE, SPL_CHAIN, SPL_GUARDIAN }, - { SPL_NOVA, SPL_GOLEM, SPL_TELEPORT, SPL_APOCA, SPL_BONESPIRIT, SPL_FLARE, SPL_ETHEREALIZE }, - { -1, -1, -1, -1, -1, -1, -1 }, - { -1, -1, -1, -1, -1, -1, -1 } + { SPL_NULL, SPL_FIREBOLT, SPL_CBOLT, SPL_HBOLT, SPL_HEAL, SPL_HEALOTHER, SPL_FLAME }, + { SPL_RESURRECT, SPL_FIREWALL, SPL_TELEKINESIS, SPL_LIGHTNING, SPL_TOWN, SPL_FLASH, SPL_STONE }, + { SPL_RNDTELEPORT, SPL_MANASHIELD, SPL_ELEMENT, SPL_FIREBALL, SPL_WAVE, SPL_CHAIN, SPL_GUARDIAN }, + { SPL_NOVA, SPL_GOLEM, SPL_TELEPORT, SPL_APOCA, SPL_BONESPIRIT, SPL_FLARE, SPL_ETHEREALIZE }, + { -1, -1, -1, -1, -1, -1, -1 }, + { -1, -1, -1, -1, -1, -1, -1 } }; void __fastcall DrawSpellCel(int xp, int yp, char *Trans, int nCel, int w) { - char *v5; // ebx - char *v6; // esi - char *v7; // edi - int v9; // edx - unsigned int v10; // eax - unsigned int v11; // ecx - char v14; // cf - unsigned int v15; // ecx - int v18; // [esp+Ch] [ebp-Ch] - int _EAX; - unsigned char *_EBX; + char *v5; // ebx + char *v6; // esi + char *v7; // edi + int v9; // edx + unsigned int v10; // eax + unsigned int v11; // ecx + char v14; // cf + unsigned int v15; // ecx + int v18; // [esp+Ch] [ebp-Ch] + int _EAX; + unsigned char *_EBX; - v5 = &Trans[4 * nCel]; - v6 = &Trans[*(_DWORD *)v5]; - v7 = (char *)gpBuffer + screen_y_times_768[yp] + xp; - v18 = (int)&v6[*((_DWORD *)v5 + 1) - *(_DWORD *)v5]; - _EBX = splTrans; - do { - v9 = w; - do { - while (1) { - v10 = (unsigned char)*v6++; - if ((v10 & 0x80u) == 0) - break; - _LOBYTE(v10) = -(char)v10; - v7 += v10; - v9 -= v10; - if (!v9) - goto LABEL_12; - } - v9 -= v10; - v11 = v10 >> 1; - if (v10 & 1) { - _EAX = *v6++; - ASM_XLAT(_EAX, _EBX); - *v7++ = _EAX; - if (!v11) - continue; - } - v14 = v11 & 1; - v15 = v11 >> 1; - if (!v14) - goto LABEL_15; - _EAX = *(_WORD *)v6; - v6 += 2; - ASM_XLAT(_EAX, _EBX); - _EAX = __ROR2__(_EAX, 8); - ASM_XLAT(_EAX, _EBX); - *(_WORD *)v7 = __ROR2__(_EAX, 8); - v7 += 2; - if (v15) { - LABEL_15: - do { - _EAX = *(_DWORD *)v6; - v6 += 4; - ASM_XLAT(_EAX, _EBX); - _EAX = __ROR4__(_EAX, 8); - ASM_XLAT(_EAX, _EBX); - _EAX = __ROR4__(_EAX, 8); - ASM_XLAT(_EAX, _EBX); - _EAX = __ROR4__(_EAX, 8); - ASM_XLAT(_EAX, _EBX); - *(_DWORD *)v7 = __ROR4__(_EAX, 8); - v7 += 4; - --v15; - } while (v15); - } - } while (v9); - LABEL_12: - v7 = &v7[-w - 768]; - } while (v6 != (char *)v18); + v5 = &Trans[4 * nCel]; + v6 = &Trans[*(_DWORD *)v5]; + v7 = (char *)gpBuffer + screen_y_times_768[yp] + xp; + v18 = (int)&v6[*((_DWORD *)v5 + 1) - *(_DWORD *)v5]; + _EBX = splTrans; + do { + v9 = w; + do { + while (1) { + v10 = (unsigned char)*v6++; + if ((v10 & 0x80u) == 0) + break; + _LOBYTE(v10) = -(char)v10; + v7 += v10; + v9 -= v10; + if (!v9) + goto LABEL_12; + } + v9 -= v10; + v11 = v10 >> 1; + if (v10 & 1) { + _EAX = *v6++; + ASM_XLAT(_EAX, _EBX); + *v7++ = _EAX; + if (!v11) + continue; + } + v14 = v11 & 1; + v15 = v11 >> 1; + if (!v14) + goto LABEL_15; + _EAX = *(_WORD *)v6; + v6 += 2; + ASM_XLAT(_EAX, _EBX); + _EAX = __ROR2__(_EAX, 8); + ASM_XLAT(_EAX, _EBX); + *(_WORD *)v7 = __ROR2__(_EAX, 8); + v7 += 2; + if (v15) { + LABEL_15: + do { + _EAX = *(_DWORD *)v6; + v6 += 4; + ASM_XLAT(_EAX, _EBX); + _EAX = __ROR4__(_EAX, 8); + ASM_XLAT(_EAX, _EBX); + _EAX = __ROR4__(_EAX, 8); + ASM_XLAT(_EAX, _EBX); + _EAX = __ROR4__(_EAX, 8); + ASM_XLAT(_EAX, _EBX); + *(_DWORD *)v7 = __ROR4__(_EAX, 8); + v7 += 4; + --v15; + } while (v15); + } + } while (v9); + LABEL_12: + v7 = &v7[-w - 768]; + } while (v6 != (char *)v18); } void __fastcall SetSpellTrans(char t) { - int i; + int i; - if (t == RSPLTYPE_SKILL) { - for (i = 0; i < 128; i++) - splTrans[i] = i; - } - for (i = 128; i < 256; i++) - splTrans[i] = i; - splTrans[255] = 0; + if (t == RSPLTYPE_SKILL) { + for (i = 0; i < 128; i++) + splTrans[i] = i; + } + for (i = 128; i < 256; i++) + splTrans[i] = i; + splTrans[255] = 0; - switch (t) { - case RSPLTYPE_SPELL: - splTrans[PAL8_YELLOW] = PAL16_BLUE + 1; - splTrans[PAL8_YELLOW + 1] = PAL16_BLUE + 3; - splTrans[PAL8_YELLOW + 2] = PAL16_BLUE + 5; - for (i = PAL16_BLUE; i < PAL16_BLUE + 16; i++) { - splTrans[PAL16_BEIGE - PAL16_BLUE + i] = i; - splTrans[PAL16_YELLOW - PAL16_BLUE + i] = i; - splTrans[PAL16_ORANGE - PAL16_BLUE + i] = i; - } - return; - case RSPLTYPE_SCROLL: - splTrans[PAL8_YELLOW] = PAL16_BEIGE + 1; - splTrans[PAL8_YELLOW + 1] = PAL16_BEIGE + 3; - splTrans[PAL8_YELLOW + 2] = PAL16_BEIGE + 5; - for (i = PAL16_BEIGE; i < PAL16_BEIGE + 16; i++) { - splTrans[PAL16_YELLOW - PAL16_BEIGE + i] = i; - splTrans[PAL16_ORANGE - PAL16_BEIGE + i] = i; - } - return; - case RSPLTYPE_CHARGES: - splTrans[PAL8_YELLOW] = PAL16_ORANGE + 1; - splTrans[PAL8_YELLOW + 1] = PAL16_ORANGE + 3; - splTrans[PAL8_YELLOW + 2] = PAL16_ORANGE + 5; - for (i = PAL16_ORANGE; i < PAL16_ORANGE + 16; i++) { - splTrans[PAL16_BEIGE - PAL16_ORANGE + i] = i; - splTrans[PAL16_YELLOW - PAL16_ORANGE + i] = i; - } - return; - case RSPLTYPE_INVALID: - splTrans[PAL8_YELLOW] = PAL16_GRAY + 1; - splTrans[PAL8_YELLOW + 1] = PAL16_GRAY + 3; - splTrans[PAL8_YELLOW + 2] = PAL16_GRAY + 5; - for (i = PAL16_GRAY; i < PAL16_GRAY + 15; i++) { - splTrans[PAL16_BEIGE - PAL16_GRAY + i] = i; - splTrans[PAL16_YELLOW - PAL16_GRAY + i] = i; - splTrans[PAL16_ORANGE - PAL16_GRAY + i] = i; - } - splTrans[PAL16_BEIGE + 15] = 0; - splTrans[PAL16_YELLOW + 15] = 0; - splTrans[PAL16_ORANGE + 15] = 0; - } + switch (t) { + case RSPLTYPE_SPELL: + splTrans[PAL8_YELLOW] = PAL16_BLUE + 1; + splTrans[PAL8_YELLOW + 1] = PAL16_BLUE + 3; + splTrans[PAL8_YELLOW + 2] = PAL16_BLUE + 5; + for (i = PAL16_BLUE; i < PAL16_BLUE + 16; i++) { + splTrans[PAL16_BEIGE - PAL16_BLUE + i] = i; + splTrans[PAL16_YELLOW - PAL16_BLUE + i] = i; + splTrans[PAL16_ORANGE - PAL16_BLUE + i] = i; + } + return; + case RSPLTYPE_SCROLL: + splTrans[PAL8_YELLOW] = PAL16_BEIGE + 1; + splTrans[PAL8_YELLOW + 1] = PAL16_BEIGE + 3; + splTrans[PAL8_YELLOW + 2] = PAL16_BEIGE + 5; + for (i = PAL16_BEIGE; i < PAL16_BEIGE + 16; i++) { + splTrans[PAL16_YELLOW - PAL16_BEIGE + i] = i; + splTrans[PAL16_ORANGE - PAL16_BEIGE + i] = i; + } + return; + case RSPLTYPE_CHARGES: + splTrans[PAL8_YELLOW] = PAL16_ORANGE + 1; + splTrans[PAL8_YELLOW + 1] = PAL16_ORANGE + 3; + splTrans[PAL8_YELLOW + 2] = PAL16_ORANGE + 5; + for (i = PAL16_ORANGE; i < PAL16_ORANGE + 16; i++) { + splTrans[PAL16_BEIGE - PAL16_ORANGE + i] = i; + splTrans[PAL16_YELLOW - PAL16_ORANGE + i] = i; + } + return; + case RSPLTYPE_INVALID: + splTrans[PAL8_YELLOW] = PAL16_GRAY + 1; + splTrans[PAL8_YELLOW + 1] = PAL16_GRAY + 3; + splTrans[PAL8_YELLOW + 2] = PAL16_GRAY + 5; + for (i = PAL16_GRAY; i < PAL16_GRAY + 15; i++) { + splTrans[PAL16_BEIGE - PAL16_GRAY + i] = i; + splTrans[PAL16_YELLOW - PAL16_GRAY + i] = i; + splTrans[PAL16_ORANGE - PAL16_GRAY + i] = i; + } + splTrans[PAL16_BEIGE + 15] = 0; + splTrans[PAL16_YELLOW + 15] = 0; + splTrans[PAL16_ORANGE + 15] = 0; + } } void __cdecl DrawSpell() { - int v0; // ebp - char v1; // cl - char v2; // bl - int v3; // edi - int v4; // esi - char v6; // [esp+Fh] [ebp-5h] + int v0; // ebp + char v1; // cl + char v2; // bl + int v3; // edi + int v4; // esi + char v6; // [esp+Fh] [ebp-5h] - v0 = myplr; - v1 = plr[myplr]._pRSpell; - v2 = plr[myplr]._pRSplType; - v3 = v1; - v6 = plr[myplr]._pRSpell; - v4 = plr[myplr]._pISplLvlAdd + plr[myplr]._pSplLvl[v1]; - if (v2 == RSPLTYPE_SPELL && v1 != -1) { - if (!CheckSpell(myplr, v1, RSPLTYPE_SPELL, TRUE)) - v2 = RSPLTYPE_INVALID; - v0 = myplr; - if (v4 <= 0) - v2 = RSPLTYPE_INVALID; - } - if (!currlevel && v2 != RSPLTYPE_INVALID && !spelldata[v3].sTownSpell) - v2 = RSPLTYPE_INVALID; - if (plr[v0]._pRSpell < 0) - v2 = RSPLTYPE_INVALID; - SetSpellTrans(v2); - if (v6 == -1) - DrawSpellCel(629, 631, (char *)pSpellCels, 27, 56); - else - DrawSpellCel(629, 631, (char *)pSpellCels, (char)SpellITbl[v3], 56); + v0 = myplr; + v1 = plr[myplr]._pRSpell; + v2 = plr[myplr]._pRSplType; + v3 = v1; + v6 = plr[myplr]._pRSpell; + v4 = plr[myplr]._pISplLvlAdd + plr[myplr]._pSplLvl[v1]; + if (v2 == RSPLTYPE_SPELL && v1 != -1) { + if (!CheckSpell(myplr, v1, RSPLTYPE_SPELL, TRUE)) + v2 = RSPLTYPE_INVALID; + v0 = myplr; + if (v4 <= 0) + v2 = RSPLTYPE_INVALID; + } + if (!currlevel && v2 != RSPLTYPE_INVALID && !spelldata[v3].sTownSpell) + v2 = RSPLTYPE_INVALID; + if (plr[v0]._pRSpell < 0) + v2 = RSPLTYPE_INVALID; + SetSpellTrans(v2); + if (v6 == -1) + DrawSpellCel(629, 631, (char *)pSpellCels, 27, 56); + else + DrawSpellCel(629, 631, (char *)pSpellCels, (char)SpellITbl[v3], 56); } void __cdecl DrawSpellList() { - int v0; // esi - signed int v1; // edi - signed int v4; // ebp - int v5; // eax - int v6; // esi - int v7; // eax - bool v8; // sf - int v9; // esi - int v10; // eax - int v11; // ebp - int v12; // edx - int *v13; // ecx - int *v14; // eax - signed int v15; // edx - signed int v16; // edi - int v17; // [esp+Ch] [ebp-34h] - __int32 xp; // [esp+10h] [ebp-30h] - __int32 yp; // [esp+14h] [ebp-2Ch] - BOOL *v20; // [esp+18h] [ebp-28h] - __int32 nCel; // [esp+1Ch] [ebp-24h] - int v22; // [esp+20h] [ebp-20h] - __int32 v23; // [esp+24h] [ebp-1Ch] - signed int v24; // [esp+28h] [ebp-18h] - unsigned __int64 v25; // [esp+2Ch] [ebp-14h] - signed __int64 v26; // [esp+34h] [ebp-Ch] + int v0; // esi + signed int v1; // edi + signed int v4; // ebp + int v5; // eax + int v6; // esi + int v7; // eax + bool v8; // sf + int v9; // esi + int v10; // eax + int v11; // ebp + int v12; // edx + int *v13; // ecx + int *v14; // eax + signed int v15; // edx + signed int v16; // edi + int v17; // [esp+Ch] [ebp-34h] + __int32 xp; // [esp+10h] [ebp-30h] + __int32 yp; // [esp+14h] [ebp-2Ch] + BOOL *v20; // [esp+18h] [ebp-28h] + __int32 nCel; // [esp+1Ch] [ebp-24h] + int v22; // [esp+20h] [ebp-20h] + __int32 v23; // [esp+24h] [ebp-1Ch] + signed int v24; // [esp+28h] [ebp-18h] + unsigned __int64 v25; // [esp+2Ch] [ebp-14h] + signed __int64 v26; // [esp+34h] [ebp-Ch] - pSpell = -1; - infostr[0] = 0; - v17 = 636; - xp = 495; - ClearPanel(); - v0 = myplr; - v1 = RSPLTYPE_SKILL; - v24 = 0; - do { - switch (v1) { - case RSPLTYPE_SKILL: - SetSpellTrans(RSPLTYPE_SKILL); - yp = 46; - v25 = plr[v0]._pAblSpells; - break; - case RSPLTYPE_SPELL: - yp = 47; - v25 = plr[v0]._pMemSpells; - break; - case RSPLTYPE_SCROLL: - SetSpellTrans(RSPLTYPE_SCROLL); - yp = 44; - v25 = plr[v0]._pScrlSpells; - break; - case RSPLTYPE_CHARGES: - SetSpellTrans(RSPLTYPE_CHARGES); - yp = 45; - v25 = plr[v0]._pISpells; - break; - } - v20 = &spelldata[1].sTownSpell; - v4 = 1; - v26 = (__int64)1; - v23 = 1; - v22 = xp - 216; - do { - if (!(v25 & v26)) - goto LABEL_68; - if (v1 == RSPLTYPE_SPELL) { - v5 = v0; - v6 = plr[v0]._pSplLvl[v4]; - v7 = plr[v5]._pISplLvlAdd; - v8 = v7 + v6 < 0; - v9 = v7 + v6; - nCel = v9; - if (v8) { - nCel = 0; - v9 = 0; - } - SetSpellTrans(v9 <= 0 ? RSPLTYPE_INVALID : RSPLTYPE_SPELL); - } else { - v9 = nCel; - } - if (!currlevel && !*v20) - SetSpellTrans(RSPLTYPE_INVALID); - DrawSpellCel(v17, xp, (char *)pSpellCels, (char)SpellITbl[v4], 56); - if (MouseX >= v17 - 64 && MouseX < v17 - 64 + 56 && MouseY >= v22 && MouseY < v22 + 56) { - pSpell = v4; - pSplType = v1; - DrawSpellCel(v17, xp, (char *)pSpellCels, yp, 56); - if (v1) { - switch (v1) { - case RSPLTYPE_SPELL: - sprintf(infostr, "%s Spell", spelldata[pSpell].sNameText); - if (pSpell == 31) { - sprintf(tempstr, "Damages undead only"); - AddPanelString(tempstr, 1); - } - if (v9) - sprintf(tempstr, "Spell Level %i", v9); - else - sprintf(tempstr, "Spell Level 0 - Unusable"); - LABEL_32: - AddPanelString(tempstr, 1); - break; - case RSPLTYPE_SCROLL: - sprintf(infostr, "Scroll of %s", spelldata[pSpell].sNameText); - v10 = myplr; - v11 = 0; - v12 = plr[myplr]._pNumInv; - if (v12 > 0) { - v13 = &plr[v10].InvList[0]._iMiscId; - do { - if (*(v13 - 53) != -1 - && (*v13 == IMISC_SCROLL || *v13 == IMISC_SCROLLT) - && v13[1] == pSpell) { - ++v11; - } - v13 += 92; - --v12; - } while (v12); - } - v14 = &plr[v10].SpdList[0]._iMiscId; - v15 = MAXBELTITEMS; - do { - if (*(v14 - 53) != -1 - && (*v14 == IMISC_SCROLL || *v14 == IMISC_SCROLLT) - && v14[1] == pSpell) { - ++v11; - } - v14 += 92; - --v15; - } while (v15); - if (v11 == 1) - strcpy(tempstr, "1 Scroll"); - else - sprintf(tempstr, "%i Scrolls", v11); - AddPanelString(tempstr, 1); - v4 = v23; - break; - case RSPLTYPE_CHARGES: - sprintf(infostr, "Staff of %s", spelldata[pSpell].sNameText); - if (plr[myplr].InvBody[INVLOC_HAND_LEFT]._iCharges == 1) - strcpy(tempstr, "1 Charge"); - else - sprintf(tempstr, "%i Charges", plr[myplr].InvBody[INVLOC_HAND_LEFT]._iCharges); - goto LABEL_32; - } - } else { - sprintf(infostr, "%s Skill", spelldata[pSpell].sSkillText); - } - v0 = myplr; - v16 = 0; - do { - if (plr[v0]._pSplHotKey[v16] == pSpell && plr[v0]._pSplTHotKey[v16] == pSplType) { - DrawSpellCel(v17, xp, (char *)pSpellCels, v16 + 48, 56); - sprintf(tempstr, "Spell Hot Key #F%i", v16 + 5); - AddPanelString(tempstr, 1); - v0 = myplr; - } - ++v16; - } while (v16 < 4); - v1 = v24; - goto LABEL_66; - } - v0 = myplr; - LABEL_66: - v17 -= 56; - if (v17 == 20) { - xp -= 56; - v22 -= 56; - v17 = 636; - } - LABEL_68: - v20 += 14; - ++v4; - v26 *= (__int64)2; - v23 = v4; - } while ((signed int)v20 < (signed int)&spelldata[MAX_SPELLS].sTownSpell); - if (v25 && v17 != 636) - v17 -= 56; - if (v17 == 20) { - xp -= 56; - v17 = 636; - } - v24 = ++v1; - } while (v1 < 4); + pSpell = -1; + infostr[0] = 0; + v17 = 636; + xp = 495; + ClearPanel(); + v0 = myplr; + v1 = RSPLTYPE_SKILL; + v24 = 0; + do { + switch (v1) { + case RSPLTYPE_SKILL: + SetSpellTrans(RSPLTYPE_SKILL); + yp = 46; + v25 = plr[v0]._pAblSpells; + break; + case RSPLTYPE_SPELL: + yp = 47; + v25 = plr[v0]._pMemSpells; + break; + case RSPLTYPE_SCROLL: + SetSpellTrans(RSPLTYPE_SCROLL); + yp = 44; + v25 = plr[v0]._pScrlSpells; + break; + case RSPLTYPE_CHARGES: + SetSpellTrans(RSPLTYPE_CHARGES); + yp = 45; + v25 = plr[v0]._pISpells; + break; + } + v20 = &spelldata[1].sTownSpell; + v4 = 1; + v26 = (__int64)1; + v23 = 1; + v22 = xp - 216; + do { + if (!(v25 & v26)) + goto LABEL_68; + if (v1 == RSPLTYPE_SPELL) { + v5 = v0; + v6 = plr[v0]._pSplLvl[v4]; + v7 = plr[v5]._pISplLvlAdd; + v8 = v7 + v6 < 0; + v9 = v7 + v6; + nCel = v9; + if (v8) { + nCel = 0; + v9 = 0; + } + SetSpellTrans(v9 <= 0 ? RSPLTYPE_INVALID : RSPLTYPE_SPELL); + } else { + v9 = nCel; + } + if (!currlevel && !*v20) + SetSpellTrans(RSPLTYPE_INVALID); + DrawSpellCel(v17, xp, (char *)pSpellCels, (char)SpellITbl[v4], 56); + if (MouseX >= v17 - 64 && MouseX < v17 - 64 + 56 && MouseY >= v22 && MouseY < v22 + 56) { + pSpell = v4; + pSplType = v1; + DrawSpellCel(v17, xp, (char *)pSpellCels, yp, 56); + if (v1) { + switch (v1) { + case RSPLTYPE_SPELL: + sprintf(infostr, "%s Spell", spelldata[pSpell].sNameText); + if (pSpell == 31) { + sprintf(tempstr, "Damages undead only"); + AddPanelString(tempstr, 1); + } + if (v9) + sprintf(tempstr, "Spell Level %i", v9); + else + sprintf(tempstr, "Spell Level 0 - Unusable"); + LABEL_32: + AddPanelString(tempstr, 1); + break; + case RSPLTYPE_SCROLL: + sprintf(infostr, "Scroll of %s", spelldata[pSpell].sNameText); + v10 = myplr; + v11 = 0; + v12 = plr[myplr]._pNumInv; + if (v12 > 0) { + v13 = &plr[v10].InvList[0]._iMiscId; + do { + if (*(v13 - 53) != -1 + && (*v13 == IMISC_SCROLL || *v13 == IMISC_SCROLLT) + && v13[1] == pSpell) { + ++v11; + } + v13 += 92; + --v12; + } while (v12); + } + v14 = &plr[v10].SpdList[0]._iMiscId; + v15 = MAXBELTITEMS; + do { + if (*(v14 - 53) != -1 + && (*v14 == IMISC_SCROLL || *v14 == IMISC_SCROLLT) + && v14[1] == pSpell) { + ++v11; + } + v14 += 92; + --v15; + } while (v15); + if (v11 == 1) + strcpy(tempstr, "1 Scroll"); + else + sprintf(tempstr, "%i Scrolls", v11); + AddPanelString(tempstr, 1); + v4 = v23; + break; + case RSPLTYPE_CHARGES: + sprintf(infostr, "Staff of %s", spelldata[pSpell].sNameText); + if (plr[myplr].InvBody[INVLOC_HAND_LEFT]._iCharges == 1) + strcpy(tempstr, "1 Charge"); + else + sprintf(tempstr, "%i Charges", plr[myplr].InvBody[INVLOC_HAND_LEFT]._iCharges); + goto LABEL_32; + } + } else { + sprintf(infostr, "%s Skill", spelldata[pSpell].sSkillText); + } + v0 = myplr; + v16 = 0; + do { + if (plr[v0]._pSplHotKey[v16] == pSpell && plr[v0]._pSplTHotKey[v16] == pSplType) { + DrawSpellCel(v17, xp, (char *)pSpellCels, v16 + 48, 56); + sprintf(tempstr, "Spell Hot Key #F%i", v16 + 5); + AddPanelString(tempstr, 1); + v0 = myplr; + } + ++v16; + } while (v16 < 4); + v1 = v24; + goto LABEL_66; + } + v0 = myplr; + LABEL_66: + v17 -= 56; + if (v17 == 20) { + xp -= 56; + v22 -= 56; + v17 = 636; + } + LABEL_68: + v20 += 14; + ++v4; + v26 *= (__int64)2; + v23 = v4; + } while ((signed int)v20 < (signed int)&spelldata[MAX_SPELLS].sTownSpell); + if (v25 && v17 != 636) + v17 -= 56; + if (v17 == 20) { + xp -= 56; + v17 = 636; + } + v24 = ++v1; + } while (v1 < 4); } // 4B8834: using guessed type int pSpell; // 4B8954: using guessed type int pSplType; void __cdecl SetSpell() { - int v0; // eax + int v0; // eax - spselflag = 0; - if (pSpell != -1) { - ClearPanel(); - v0 = myplr; - drawpanflag = 255; - plr[v0]._pRSpell = pSpell; - _LOBYTE(plr[v0]._pRSplType) = pSplType; - } + spselflag = 0; + if (pSpell != -1) { + ClearPanel(); + v0 = myplr; + drawpanflag = 255; + plr[v0]._pRSpell = pSpell; + _LOBYTE(plr[v0]._pRSplType) = pSplType; + } } // 4B8834: using guessed type int pSpell; // 4B8954: using guessed type int pSplType; @@ -555,485 +555,485 @@ void __cdecl SetSpell() void __fastcall SetSpeedSpell(int slot) { - int v1; // esi - signed int v3; // ebp - int v5; // ebx - int *v6; // edi + int v1; // esi + signed int v3; // ebp + int v5; // ebx + int *v6; // edi - v1 = pSpell; - if (pSpell != -1) { - v3 = 0; - v5 = pSplType; - v6 = plr[myplr]._pSplHotKey; - do { - if (*v6 == v1 && plr[myplr]._pSplTHotKey[v3] == v5) - *v6 = -1; - ++v3; - ++v6; - } while (v3 < 4); - plr[myplr]._pSplHotKey[slot] = v1; - plr[myplr]._pSplTHotKey[slot] = v5; - } + v1 = pSpell; + if (pSpell != -1) { + v3 = 0; + v5 = pSplType; + v6 = plr[myplr]._pSplHotKey; + do { + if (*v6 == v1 && plr[myplr]._pSplTHotKey[v3] == v5) + *v6 = -1; + ++v3; + ++v6; + } while (v3 < 4); + plr[myplr]._pSplHotKey[slot] = v1; + plr[myplr]._pSplTHotKey[slot] = v5; + } } // 4B8834: using guessed type int pSpell; // 4B8954: using guessed type int pSplType; void __fastcall ToggleSpell(int slot) { - if (plr[myplr]._pSplHotKey[slot] == -1) { - return; - } + if (plr[myplr]._pSplHotKey[slot] == -1) { + return; + } - unsigned __int64 spells; - switch (plr[myplr]._pSplTHotKey[slot]) { - case RSPLTYPE_SKILL: - spells = plr[myplr]._pAblSpells; - break; - case RSPLTYPE_SPELL: - spells = plr[myplr]._pMemSpells; - break; - case RSPLTYPE_SCROLL: - spells = plr[myplr]._pScrlSpells; - break; - case RSPLTYPE_CHARGES: - spells = plr[myplr]._pISpells; - break; - } + unsigned __int64 spells; + switch (plr[myplr]._pSplTHotKey[slot]) { + case RSPLTYPE_SKILL: + spells = plr[myplr]._pAblSpells; + break; + case RSPLTYPE_SPELL: + spells = plr[myplr]._pMemSpells; + break; + case RSPLTYPE_SCROLL: + spells = plr[myplr]._pScrlSpells; + break; + case RSPLTYPE_CHARGES: + spells = plr[myplr]._pISpells; + break; + } - if (spells & (__int64)1 << (plr[myplr]._pSplHotKey[slot] - 1)) { - plr[myplr]._pRSpell = plr[myplr]._pSplHotKey[slot]; - plr[myplr]._pRSplType = plr[myplr]._pSplTHotKey[slot]; - drawpanflag = 255; - } + if (spells & (__int64)1 << (plr[myplr]._pSplHotKey[slot] - 1)) { + plr[myplr]._pRSpell = plr[myplr]._pSplHotKey[slot]; + plr[myplr]._pRSplType = plr[myplr]._pSplTHotKey[slot]; + drawpanflag = 255; + } } // 52571C: using guessed type int drawpanflag; void __fastcall CPrintString(int No, unsigned int glyph, unsigned char col) { - int *v3; // ebx - char *v4; // esi - char *v5; // edi - int v6; // ebx - signed int v7; // edx - unsigned int v8; // eax - unsigned int v9; // ecx - char v10; // cf - unsigned int v11; // ecx - signed int v12; // edx - int v13; // eax - int v14; // ecx - char v15; // al - signed int v16; // edx - int v17; // eax - int v18; // ecx - char v19; // al - signed int v20; // edx - int v21; // eax - int v22; // ecx - char v23; // al + int *v3; // ebx + char *v4; // esi + char *v5; // edi + int v6; // ebx + signed int v7; // edx + unsigned int v8; // eax + unsigned int v9; // ecx + char v10; // cf + unsigned int v11; // ecx + signed int v12; // edx + int v13; // eax + int v14; // ecx + char v15; // al + signed int v16; // edx + int v17; // eax + int v18; // ecx + char v19; // al + signed int v20; // edx + int v21; // eax + int v22; // ecx + char v23; // al - v3 = (int *)((char *)pPanelText + 4 * glyph); - v4 = (char *)pPanelText + *v3; - v5 = (char *)gpBuffer + No; - v6 = (int)&v4[v3[1] - *v3]; - if ((_BYTE)col) { - if ((unsigned char)col == 1) { - do { - v12 = 13; - do { - while (1) { - v13 = (unsigned char)*v4++; - if ((v13 & 0x80u) == 0) - break; - _LOBYTE(v13) = -(char)v13; - v5 += v13; - v12 -= v13; - if (!v12) - goto LABEL_28; - } - v12 -= v13; - v14 = v13; - do { - v15 = *v4++; - if ((unsigned char)v15 > 0xFDu) { - v15 = -65; - } else if ((unsigned char)v15 >= 0xF0u) { - v15 -= 62; - } - *v5++ = v15; - --v14; - } while (v14); - } while (v12); - LABEL_28: - v5 -= 781; - } while ((char *)v6 != v4); - } else if ((unsigned char)col == 2) { - do { - v16 = 13; - do { - while (1) { - v17 = (unsigned char)*v4++; - if ((v17 & 0x80u) == 0) - break; - _LOBYTE(v17) = -(char)v17; - v5 += v17; - v16 -= v17; - if (!v16) - goto LABEL_39; - } - v16 -= v17; - v18 = v17; - do { - v19 = *v4++; - if ((unsigned char)v19 >= 0xF0u) - v19 -= 16; - *v5++ = v19; - --v18; - } while (v18); - } while (v16); - LABEL_39: - v5 -= 781; - } while ((char *)v6 != v4); - } else { - do { - v20 = 13; - do { - while (1) { - v21 = (unsigned char)*v4++; - if ((v21 & 0x80u) == 0) - break; - _LOBYTE(v21) = -(char)v21; - v5 += v21; - v20 -= v21; - if (!v20) - goto LABEL_52; - } - v20 -= v21; - v22 = v21; - do { - v23 = *v4++; - if ((unsigned char)v23 >= 0xF0u) { - if ((unsigned char)v23 >= 0xFEu) - v23 = -49; - else - v23 -= 46; - } - *v5++ = v23; - --v22; - } while (v22); - } while (v20); - LABEL_52: - v5 -= 781; - } while ((char *)v6 != v4); - } - } else { - do { - v7 = 13; - do { - while (1) { - v8 = (unsigned char)*v4++; - if ((v8 & 0x80u) == 0) - break; - _LOBYTE(v8) = -(char)v8; - v5 += v8; - v7 -= v8; - if (!v7) - goto LABEL_15; - } - v7 -= v8; - v9 = v8 >> 1; - if (v8 & 1) { - *v5++ = *v4++; - if (!v9) - continue; - } - v10 = v9 & 1; - v11 = v8 >> 2; - if (v10) { - *(_WORD *)v5 = *(_WORD *)v4; - v4 += 2; - v5 += 2; - if (!v11) - continue; - } - qmemcpy(v5, v4, 4 * v11); - v4 += 4 * v11; - v5 += 4 * v11; - } while (v7); - LABEL_15: - v5 -= 781; - } while ((char *)v6 != v4); - } + v3 = (int *)((char *)pPanelText + 4 * glyph); + v4 = (char *)pPanelText + *v3; + v5 = (char *)gpBuffer + No; + v6 = (int)&v4[v3[1] - *v3]; + if ((_BYTE)col) { + if ((unsigned char)col == 1) { + do { + v12 = 13; + do { + while (1) { + v13 = (unsigned char)*v4++; + if ((v13 & 0x80u) == 0) + break; + _LOBYTE(v13) = -(char)v13; + v5 += v13; + v12 -= v13; + if (!v12) + goto LABEL_28; + } + v12 -= v13; + v14 = v13; + do { + v15 = *v4++; + if ((unsigned char)v15 > 0xFDu) { + v15 = -65; + } else if ((unsigned char)v15 >= 0xF0u) { + v15 -= 62; + } + *v5++ = v15; + --v14; + } while (v14); + } while (v12); + LABEL_28: + v5 -= 781; + } while ((char *)v6 != v4); + } else if ((unsigned char)col == 2) { + do { + v16 = 13; + do { + while (1) { + v17 = (unsigned char)*v4++; + if ((v17 & 0x80u) == 0) + break; + _LOBYTE(v17) = -(char)v17; + v5 += v17; + v16 -= v17; + if (!v16) + goto LABEL_39; + } + v16 -= v17; + v18 = v17; + do { + v19 = *v4++; + if ((unsigned char)v19 >= 0xF0u) + v19 -= 16; + *v5++ = v19; + --v18; + } while (v18); + } while (v16); + LABEL_39: + v5 -= 781; + } while ((char *)v6 != v4); + } else { + do { + v20 = 13; + do { + while (1) { + v21 = (unsigned char)*v4++; + if ((v21 & 0x80u) == 0) + break; + _LOBYTE(v21) = -(char)v21; + v5 += v21; + v20 -= v21; + if (!v20) + goto LABEL_52; + } + v20 -= v21; + v22 = v21; + do { + v23 = *v4++; + if ((unsigned char)v23 >= 0xF0u) { + if ((unsigned char)v23 >= 0xFEu) + v23 = -49; + else + v23 -= 46; + } + *v5++ = v23; + --v22; + } while (v22); + } while (v20); + LABEL_52: + v5 -= 781; + } while ((char *)v6 != v4); + } + } else { + do { + v7 = 13; + do { + while (1) { + v8 = (unsigned char)*v4++; + if ((v8 & 0x80u) == 0) + break; + _LOBYTE(v8) = -(char)v8; + v5 += v8; + v7 -= v8; + if (!v7) + goto LABEL_15; + } + v7 -= v8; + v9 = v8 >> 1; + if (v8 & 1) { + *v5++ = *v4++; + if (!v9) + continue; + } + v10 = v9 & 1; + v11 = v8 >> 2; + if (v10) { + *(_WORD *)v5 = *(_WORD *)v4; + v4 += 2; + v5 += 2; + if (!v11) + continue; + } + qmemcpy(v5, v4, 4 * v11); + v4 += 4 * v11; + v5 += 4 * v11; + } while (v7); + LABEL_15: + v5 -= 781; + } while ((char *)v6 != v4); + } } void __fastcall AddPanelString(char *str, int just) { - strcpy(&panelstr[64 * pnumlines], str); - pstrjust[pnumlines] = just; + strcpy(&panelstr[64 * pnumlines], str); + pstrjust[pnumlines] = just; - if (pnumlines < 4) - pnumlines++; + if (pnumlines < 4) + pnumlines++; } void __cdecl ClearPanel() { - pnumlines = 0; - pinfoflag = 0; + pnumlines = 0; + pinfoflag = 0; } // 4B8824: using guessed type int pinfoflag; void __fastcall DrawPanelBox(int x, int y, int w, int h, int sx, int sy) { - char *v6; // esi - char *v7; // edi - int v8; // edx - unsigned int v9; // ecx - char v10; // cf - unsigned int v11; // ecx + char *v6; // esi + char *v7; // edi + int v8; // edx + unsigned int v9; // ecx + char v10; // cf + unsigned int v11; // ecx - v6 = (char *)pBtmBuff + 640 * y + x; - v7 = &gpBuffer->row_unused_1[sy].col_unused_1[sx]; - v8 = h; - do { - v9 = w >> 1; - if (!(w & 1) || (*v7 = *v6, ++v6, ++v7, v9)) { - v10 = v9 & 1; - v11 = w >> 2; - if (!v10 || (*(_WORD *)v7 = *(_WORD *)v6, v6 += 2, v7 += 2, v11)) { - qmemcpy(v7, v6, 4 * v11); - v6 += 4 * v11; - v7 += 4 * v11; - } - } - v6 = &v6[-w + 640]; - v7 = &v7[-w + 768]; - --v8; - } while (v8); + v6 = (char *)pBtmBuff + 640 * y + x; + v7 = &gpBuffer->row_unused_1[sy].col_unused_1[sx]; + v8 = h; + do { + v9 = w >> 1; + if (!(w & 1) || (*v7 = *v6, ++v6, ++v7, v9)) { + v10 = v9 & 1; + v11 = w >> 2; + if (!v10 || (*(_WORD *)v7 = *(_WORD *)v6, v6 += 2, v7 += 2, v11)) { + qmemcpy(v7, v6, 4 * v11); + v6 += 4 * v11; + v7 += 4 * v11; + } + } + v6 = &v6[-w + 640]; + v7 = &v7[-w + 768]; + --v8; + } while (v8); } void __fastcall SetFlaskHeight(char *buf, int min, int max, int c, int r) { - char *v5; // esi - char *v6; // edi - int v7; // edx + char *v5; // esi + char *v6; // edi + int v7; // edx - v5 = &buf[88 * min]; - v6 = &gpBuffer->row_unused_1[r].col_unused_1[c]; - v7 = max - min; - do { - qmemcpy(v6, v5, 0x58u); - v5 += 88; - v6 += 768; - --v7; - } while (v7); + v5 = &buf[88 * min]; + v6 = &gpBuffer->row_unused_1[r].col_unused_1[c]; + v7 = max - min; + do { + qmemcpy(v6, v5, 0x58u); + v5 += 88; + v6 += 768; + --v7; + } while (v7); } void __fastcall DrawFlask(void *a1, int a2, int a3, void *a4, int a5, int a6) { - char *v6; // esi - _BYTE *v7; // edi - int v8; // edx - signed int v9; // ecx - char v10; // al - int v11; // [esp+Ch] [ebp-4h] + char *v6; // esi + _BYTE *v7; // edi + int v8; // edx + signed int v9; // ecx + char v10; // al + int v11; // [esp+Ch] [ebp-4h] - v11 = a2; - v6 = (char *)a1 + a3; - v7 = (unsigned char *)a4 + a5; - v8 = a6; - do { - v9 = 59; - do { - v10 = *v6++; - if (v10) - *v7 = v10; - ++v7; - --v9; - } while (v9); - v6 = &v6[v11 - 59]; - v7 += 709; - --v8; - } while (v8); + v11 = a2; + v6 = (char *)a1 + a3; + v7 = (unsigned char *)a4 + a5; + v8 = a6; + do { + v9 = 59; + do { + v10 = *v6++; + if (v10) + *v7 = v10; + ++v7; + --v9; + } while (v9); + v6 = &v6[v11 - 59]; + v7 += 709; + --v8; + } while (v8); } void __cdecl DrawLifeFlask() { - int filled = (double)plr[myplr]._pHitPoints / (double)plr[myplr]._pMaxHP * 80.0; - plr[myplr]._pHPPer = filled; + int filled = (double)plr[myplr]._pHitPoints / (double)plr[myplr]._pMaxHP * 80.0; + plr[myplr]._pHPPer = filled; - if (filled > 80) - filled = 80; - filled = 80 - filled; - if (filled > 11) - filled = 11; - filled += 2; + if (filled > 80) + filled = 80; + filled = 80 - filled; + if (filled > 11) + filled = 11; + filled += 2; - DrawFlask(pLifeBuff, 88, 277, gpBuffer, 768 * 499 + 173, filled); - if (filled != 13) - DrawFlask(pBtmBuff, 640, 640 * filled + 2029, gpBuffer, 768 * filled + 768 * 499 + 173, 13 - filled); + DrawFlask(pLifeBuff, 88, 277, gpBuffer, 768 * 499 + 173, filled); + if (filled != 13) + DrawFlask(pBtmBuff, 640, 640 * filled + 2029, gpBuffer, 768 * filled + 768 * 499 + 173, 13 - filled); } void __cdecl UpdateLifeFlask() { - int filled = (double)plr[myplr]._pHitPoints / (double)plr[myplr]._pMaxHP * 80.0; - plr[myplr]._pHPPer = filled; + int filled = (double)plr[myplr]._pHitPoints / (double)plr[myplr]._pMaxHP * 80.0; + plr[myplr]._pHPPer = filled; - if (filled > 69) - filled = 69; - else if (filled < 0) - filled = 0; - if (filled != 69) - SetFlaskHeight(pLifeBuff, 16, 85 - filled, 160, 512); - if (filled) - DrawPanelBox(96, 85 - filled, 88, filled, 160, 581 - filled); + if (filled > 69) + filled = 69; + else if (filled < 0) + filled = 0; + if (filled != 69) + SetFlaskHeight(pLifeBuff, 16, 85 - filled, 160, 512); + if (filled) + DrawPanelBox(96, 85 - filled, 88, filled, 160, 581 - filled); } void __cdecl DrawManaFlask() { - int filled = plr[myplr]._pManaPer; - if (filled > 80) - filled = 80; - filled = 80 - filled; - if (filled > 11) - filled = 11; - filled += 2; + int filled = plr[myplr]._pManaPer; + if (filled > 80) + filled = 80; + filled = 80 - filled; + if (filled > 11) + filled = 11; + filled += 2; - DrawFlask(pManaBuff, 88, 277, gpBuffer, 768 * 499 + 173 + 366, filled); - if (filled != 13) - DrawFlask(pBtmBuff, 640, 640 * filled + 2029 + 366, gpBuffer, 768 * filled + 768 * 499 + 173 + 366, 13 - filled); + DrawFlask(pManaBuff, 88, 277, gpBuffer, 768 * 499 + 173 + 366, filled); + if (filled != 13) + DrawFlask(pBtmBuff, 640, 640 * filled + 2029 + 366, gpBuffer, 768 * filled + 768 * 499 + 173 + 366, 13 - filled); } void __cdecl control_update_life_mana() { - int manaPer; - int maxMana = plr[myplr]._pMaxMana; - int mana = plr[myplr]._pMana; - if (maxMana < 0) - maxMana = 0; - if (mana < 0) - mana = 0; - if (maxMana == 0) - manaPer = 0; - else - manaPer = (double)mana / (double)maxMana * 80.0; - plr[myplr]._pManaPer = manaPer; - plr[myplr]._pHPPer = (double)plr[myplr]._pHitPoints / (double)plr[myplr]._pMaxHP * 80.0; + int manaPer; + int maxMana = plr[myplr]._pMaxMana; + int mana = plr[myplr]._pMana; + if (maxMana < 0) + maxMana = 0; + if (mana < 0) + mana = 0; + if (maxMana == 0) + manaPer = 0; + else + manaPer = (double)mana / (double)maxMana * 80.0; + plr[myplr]._pManaPer = manaPer; + plr[myplr]._pHPPer = (double)plr[myplr]._pHitPoints / (double)plr[myplr]._pMaxHP * 80.0; } void __cdecl UpdateManaFlask() { - int filled; - int maxMana = plr[myplr]._pMaxMana; - int mana = plr[myplr]._pMana; - if (maxMana < 0) - maxMana = 0; - if (mana < 0) - mana = 0; + int filled; + int maxMana = plr[myplr]._pMaxMana; + int mana = plr[myplr]._pMana; + if (maxMana < 0) + maxMana = 0; + if (mana < 0) + mana = 0; - if (maxMana == 0) - filled = 0; - else - filled = (double)mana / (double)maxMana * 80.0; + if (maxMana == 0) + filled = 0; + else + filled = (double)mana / (double)maxMana * 80.0; - plr[myplr]._pManaPer = filled; + plr[myplr]._pManaPer = filled; - if (filled > 69) - filled = 69; - if (filled != 69) - SetFlaskHeight(pManaBuff, 16, 85 - filled, 160 + 368, 512); - if (filled) - DrawPanelBox(96 + 368, 85 - filled, 88, filled, 160 + 368, 581 - filled); + if (filled > 69) + filled = 69; + if (filled != 69) + SetFlaskHeight(pManaBuff, 16, 85 - filled, 160 + 368, 512); + if (filled) + DrawPanelBox(96 + 368, 85 - filled, 88, filled, 160 + 368, 581 - filled); - DrawSpell(); + DrawSpell(); } void __cdecl InitControlPan() { - size_t v0; // esi - void *v1; // ecx - void *v2; // ecx - void *v3; // ecx - unsigned char *v5; // eax + size_t v0; // esi + void *v1; // ecx + void *v2; // ecx + void *v3; // ecx + unsigned char *v5; // eax - v0 = 144 * 640; - if (gbMaxPlayers != 1) - v0 = 288 * 640; - pBtmBuff = DiabloAllocPtr(v0); - memset(pBtmBuff, 0, v0); - pManaBuff = (char *)DiabloAllocPtr(0x1E40); - memset(pManaBuff, 0, 0x1E40); - pLifeBuff = (char *)DiabloAllocPtr(0x1E40); - memset(pLifeBuff, 0, 0x1E40); - pPanelText = LoadFileInMem("CtrlPan\\SmalText.CEL", 0); - pChrPanel = LoadFileInMem("Data\\Char.CEL", 0); - pSpellCels = LoadFileInMem("CtrlPan\\SpelIcon.CEL", 0); - SetSpellTrans(RSPLTYPE_SKILL); - pStatusPanel = LoadFileInMem("CtrlPan\\Panel8.CEL", 0); - CelDecodeRect((char *)pBtmBuff, 0, 143, 640, (char *)pStatusPanel, 1, 640); - v1 = pStatusPanel; - pStatusPanel = 0; - mem_free_dbg(v1); - pStatusPanel = LoadFileInMem("CtrlPan\\P8Bulbs.CEL", 0); - CelDecodeRect(pLifeBuff, 0, 87, 88, (char *)pStatusPanel, 1, 88); - CelDecodeRect(pManaBuff, 0, 87, 88, (char *)pStatusPanel, 2, 88); - v2 = pStatusPanel; - pStatusPanel = 0; - mem_free_dbg(v2); - talkflag = 0; - if (gbMaxPlayers != 1) { - pTalkPanel = LoadFileInMem("CtrlPan\\TalkPanl.CEL", 0); - CelDecodeRect((char *)pBtmBuff, 0, 287, 640, (char *)pTalkPanel, 1, 640); - v3 = pTalkPanel; - pTalkPanel = 0; - mem_free_dbg(v3); - pMultiBtns = LoadFileInMem("CtrlPan\\P8But2.CEL", 0); - pTalkBtns = LoadFileInMem("CtrlPan\\TalkButt.CEL", 0); - sgbPlrTalkTbl = 0; - *(_DWORD *)&tempstr[256] = 0x1010101; - talkbtndown[0] = 0; - talkbtndown[1] = 0; - sgszTalkMsg[0] = 0; - talkbtndown[2] = 0; - } - panelflag = 0; - lvlbtndown = 0; - pPanelButtons = LoadFileInMem("CtrlPan\\Panel8bu.CEL", 0); - memset(panbtn, 0, sizeof(panbtn)); - panbtndown = 0; - numpanbtns = 2 * (gbMaxPlayers != 1) + 6; - pChrButtons = LoadFileInMem("Data\\CharBut.CEL", 0); - chrbtn[0] = 0; - chrbtn[1] = 0; - chrbtn[2] = 0; - chrbtnactive = 0; - chrbtn[3] = 0; - pDurIcons = LoadFileInMem("Items\\DurIcons.CEL", 0); - strcpy(infostr, &empty_string); - ClearPanel(); - drawhpflag = TRUE; - drawmanaflag = TRUE; - chrflag = 0; - spselflag = 0; - pSpellBkCel = LoadFileInMem("Data\\SpellBk.CEL", 0); - pSBkBtnCel = LoadFileInMem("Data\\SpellBkB.CEL", 0); - pSBkIconCels = LoadFileInMem("Data\\SpellI2.CEL", 0); - sbooktab = 0; - sbookflag = 0; - if (plr[myplr]._pClass == PC_WARRIOR) { - SpellPages[0][0] = SPL_REPAIR; - } else if (plr[myplr]._pClass == PC_ROGUE) { - SpellPages[0][0] = SPL_DISARM; - } else if (plr[myplr]._pClass == PC_SORCERER) { - SpellPages[0][0] = SPL_RECHARGE; - } - pQLogCel = LoadFileInMem("Data\\Quest.CEL", 0); - v5 = LoadFileInMem("CtrlPan\\Golddrop.cel", 0); - frame_4B8800 = 1; - dropGoldFlag = 0; - dropGoldValue = 0; - initialDropGoldValue = 0; - initialDropGoldIndex = 0; - pGBoxBuff = v5; + v0 = 144 * 640; + if (gbMaxPlayers != 1) + v0 = 288 * 640; + pBtmBuff = DiabloAllocPtr(v0); + memset(pBtmBuff, 0, v0); + pManaBuff = (char *)DiabloAllocPtr(0x1E40); + memset(pManaBuff, 0, 0x1E40); + pLifeBuff = (char *)DiabloAllocPtr(0x1E40); + memset(pLifeBuff, 0, 0x1E40); + pPanelText = LoadFileInMem("CtrlPan\\SmalText.CEL", 0); + pChrPanel = LoadFileInMem("Data\\Char.CEL", 0); + pSpellCels = LoadFileInMem("CtrlPan\\SpelIcon.CEL", 0); + SetSpellTrans(RSPLTYPE_SKILL); + pStatusPanel = LoadFileInMem("CtrlPan\\Panel8.CEL", 0); + CelDecodeRect((char *)pBtmBuff, 0, 143, 640, (char *)pStatusPanel, 1, 640); + v1 = pStatusPanel; + pStatusPanel = 0; + mem_free_dbg(v1); + pStatusPanel = LoadFileInMem("CtrlPan\\P8Bulbs.CEL", 0); + CelDecodeRect(pLifeBuff, 0, 87, 88, (char *)pStatusPanel, 1, 88); + CelDecodeRect(pManaBuff, 0, 87, 88, (char *)pStatusPanel, 2, 88); + v2 = pStatusPanel; + pStatusPanel = 0; + mem_free_dbg(v2); + talkflag = 0; + if (gbMaxPlayers != 1) { + pTalkPanel = LoadFileInMem("CtrlPan\\TalkPanl.CEL", 0); + CelDecodeRect((char *)pBtmBuff, 0, 287, 640, (char *)pTalkPanel, 1, 640); + v3 = pTalkPanel; + pTalkPanel = 0; + mem_free_dbg(v3); + pMultiBtns = LoadFileInMem("CtrlPan\\P8But2.CEL", 0); + pTalkBtns = LoadFileInMem("CtrlPan\\TalkButt.CEL", 0); + sgbPlrTalkTbl = 0; + *(_DWORD *)&tempstr[256] = 0x1010101; + talkbtndown[0] = 0; + talkbtndown[1] = 0; + sgszTalkMsg[0] = 0; + talkbtndown[2] = 0; + } + panelflag = 0; + lvlbtndown = 0; + pPanelButtons = LoadFileInMem("CtrlPan\\Panel8bu.CEL", 0); + memset(panbtn, 0, sizeof(panbtn)); + panbtndown = 0; + numpanbtns = 2 * (gbMaxPlayers != 1) + 6; + pChrButtons = LoadFileInMem("Data\\CharBut.CEL", 0); + chrbtn[0] = 0; + chrbtn[1] = 0; + chrbtn[2] = 0; + chrbtnactive = 0; + chrbtn[3] = 0; + pDurIcons = LoadFileInMem("Items\\DurIcons.CEL", 0); + strcpy(infostr, &empty_string); + ClearPanel(); + drawhpflag = TRUE; + drawmanaflag = TRUE; + chrflag = 0; + spselflag = 0; + pSpellBkCel = LoadFileInMem("Data\\SpellBk.CEL", 0); + pSBkBtnCel = LoadFileInMem("Data\\SpellBkB.CEL", 0); + pSBkIconCels = LoadFileInMem("Data\\SpellI2.CEL", 0); + sbooktab = 0; + sbookflag = 0; + if (plr[myplr]._pClass == PC_WARRIOR) { + SpellPages[0][0] = SPL_REPAIR; + } else if (plr[myplr]._pClass == PC_ROGUE) { + SpellPages[0][0] = SPL_DISARM; + } else if (plr[myplr]._pClass == PC_SORCERER) { + SpellPages[0][0] = SPL_RECHARGE; + } + pQLogCel = LoadFileInMem("Data\\Quest.CEL", 0); + v5 = LoadFileInMem("CtrlPan\\Golddrop.cel", 0); + frame_4B8800 = 1; + dropGoldFlag = 0; + dropGoldValue = 0; + initialDropGoldValue = 0; + initialDropGoldIndex = 0; + pGBoxBuff = v5; } // 4B84DC: using guessed type int dropGoldFlag; // 4B851C: using guessed type int lvlbtndown; @@ -1050,126 +1050,126 @@ void __cdecl InitControlPan() void __cdecl ClearCtrlPan() { - DrawPanelBox(0, sgbPlrTalkTbl + 16, 640, 128, 64, 512); - DrawInfoBox(); + DrawPanelBox(0, sgbPlrTalkTbl + 16, 640, 128, 64, 512); + DrawInfoBox(); } // 4B8840: using guessed type int sgbPlrTalkTbl; void __cdecl DrawCtrlPan() { - signed int v0; // edi - int *v1; // esi - int v2; // ecx - int v3; // eax + signed int v0; // edi + int *v1; // esi + int v2; // ecx + int v3; // eax - v0 = 0; - v1 = (int *)PanBtnPos; - do { - v2 = *v1; - if (panbtn[v0]) - CelDecodeOnly(v2 + 64, v1[1] + 178, pPanelButtons, v0 + 1, 71); - else - DrawPanelBox(v2, v1[1] - 336, 71, 20, v2 + 64, v1[1] + 160); - ++v0; - v1 += 5; - } while (v0 < 6); - if (numpanbtns == 8) { - CelDecodeOnly(151, 634, pMultiBtns, panbtn[6] + 1, 33); - if (FriendlyMode) - v3 = panbtn[7] + 3; - else - v3 = panbtn[7] + 5; - CelDecodeOnly(591, 634, pMultiBtns, v3, 33); - } + v0 = 0; + v1 = (int *)PanBtnPos; + do { + v2 = *v1; + if (panbtn[v0]) + CelDecodeOnly(v2 + 64, v1[1] + 178, pPanelButtons, v0 + 1, 71); + else + DrawPanelBox(v2, v1[1] - 336, 71, 20, v2 + 64, v1[1] + 160); + ++v0; + v1 += 5; + } while (v0 < 6); + if (numpanbtns == 8) { + CelDecodeOnly(151, 634, pMultiBtns, panbtn[6] + 1, 33); + if (FriendlyMode) + v3 = panbtn[7] + 3; + else + v3 = panbtn[7] + 5; + CelDecodeOnly(591, 634, pMultiBtns, v3, 33); + } } // 484368: using guessed type int FriendlyMode; // 4B8A7C: using guessed type int numpanbtns; void __cdecl DoSpeedBook() { - unsigned __int64 spells, spell; + unsigned __int64 spells, spell; - spselflag = 1; - int xo = 636; - int yo = 495; - int X = 600; - int Y = 307; - if (plr[myplr]._pRSpell != -1) { - for (int i = 0; i < 4; i++) { - switch (i) { - case RSPLTYPE_SKILL: - spells = plr[myplr]._pAblSpells; - break; - case RSPLTYPE_SPELL: - spells = plr[myplr]._pMemSpells; - break; - case RSPLTYPE_SCROLL: - spells = plr[myplr]._pScrlSpells; - break; - case RSPLTYPE_CHARGES: - spells = plr[myplr]._pISpells; - break; - } - spell = (__int64)1; - for (int j = 1; j < MAX_SPELLS; j++) { - if (spell & spells) { - if (j == plr[myplr]._pRSpell && i == plr[myplr]._pRSplType) { - X = xo - 36; - Y = yo - 188; - } - xo -= 56; - if (xo == 20) { - xo = 636; - yo -= 56; - } - } - spell <<= (__int64)1; - } - if (spells && xo != 636) - xo -= 56; - if (xo == 20) { - xo = 636; - yo -= 56; - } - } - } + spselflag = 1; + int xo = 636; + int yo = 495; + int X = 600; + int Y = 307; + if (plr[myplr]._pRSpell != -1) { + for (int i = 0; i < 4; i++) { + switch (i) { + case RSPLTYPE_SKILL: + spells = plr[myplr]._pAblSpells; + break; + case RSPLTYPE_SPELL: + spells = plr[myplr]._pMemSpells; + break; + case RSPLTYPE_SCROLL: + spells = plr[myplr]._pScrlSpells; + break; + case RSPLTYPE_CHARGES: + spells = plr[myplr]._pISpells; + break; + } + spell = (__int64)1; + for (int j = 1; j < MAX_SPELLS; j++) { + if (spell & spells) { + if (j == plr[myplr]._pRSpell && i == plr[myplr]._pRSplType) { + X = xo - 36; + Y = yo - 188; + } + xo -= 56; + if (xo == 20) { + xo = 636; + yo -= 56; + } + } + spell <<= (__int64)1; + } + if (spells && xo != 636) + xo -= 56; + if (xo == 20) { + xo = 636; + yo -= 56; + } + } + } - SetCursorPos(X, Y); + SetCursorPos(X, Y); } // 4B8C98: using guessed type int spselflag; void __cdecl DoPanBtn() { - int v0; // edx - int v1; // ebx - int v2; // edi - int v3; // esi - int(*v4)[5]; // eax - int v5; // ecx + int v0; // edx + int v1; // ebx + int v2; // edi + int v3; // esi + int(*v4)[5]; // eax + int v5; // ecx - v0 = MouseX; - v1 = MouseY; - v2 = numpanbtns; - v3 = 0; - if (numpanbtns > 0) { - v4 = PanBtnPos; - do { - if (v0 >= (*v4)[0] && v0 <= (*v4)[0] + (*v4)[2]) { - v5 = (*v4)[1]; - if (v1 >= v5 && v1 <= v5 + (*v4)[3]) { - panbtn[v3] = 1; - drawbtnflag = 1; - panbtndown = 1; - } - } - ++v3; - ++v4; - } while (v3 < v2); - } - if (!spselflag && v0 >= 565 && v0 < 621 && v1 >= 416 && v1 < 472) { - DoSpeedBook(); - gamemenu_off(); - } + v0 = MouseX; + v1 = MouseY; + v2 = numpanbtns; + v3 = 0; + if (numpanbtns > 0) { + v4 = PanBtnPos; + do { + if (v0 >= (*v4)[0] && v0 <= (*v4)[0] + (*v4)[2]) { + v5 = (*v4)[1]; + if (v1 >= v5 && v1 <= v5 + (*v4)[3]) { + panbtn[v3] = 1; + drawbtnflag = 1; + panbtndown = 1; + } + } + ++v3; + ++v4; + } while (v3 < v2); + } + if (!spselflag && v0 >= 565 && v0 < 621 && v1 >= 416 && v1 < 472) { + DoSpeedBook(); + gamemenu_off(); + } } // 4B8A7C: using guessed type int numpanbtns; // 4B8C90: using guessed type int panbtndown; @@ -1177,160 +1177,160 @@ void __cdecl DoPanBtn() void __fastcall control_set_button_down(int btn_id) { - panbtn[btn_id] = 1; - drawbtnflag = 1; - panbtndown = 1; + panbtn[btn_id] = 1; + drawbtnflag = 1; + panbtndown = 1; } // 4B8C90: using guessed type int panbtndown; void __cdecl control_check_btn_press() { - int v0; // edx - int v1; // esi + int v0; // edx + int v1; // esi - v0 = MouseX; - v1 = MouseY; - if (MouseX >= PanBtnPos[3][0] - && MouseX <= PanBtnPos[3][0] + PanBtnPos[3][2] - && MouseY >= PanBtnPos[3][1] - && MouseY <= PanBtnPos[3][1] + PanBtnPos[3][3]) { - control_set_button_down(3); - } - if (v0 >= PanBtnPos[6][0] - && v0 <= PanBtnPos[6][0] + PanBtnPos[6][2] - && v1 >= PanBtnPos[6][1] - && v1 <= PanBtnPos[6][1] + PanBtnPos[6][3]) { - control_set_button_down(6); - } + v0 = MouseX; + v1 = MouseY; + if (MouseX >= PanBtnPos[3][0] + && MouseX <= PanBtnPos[3][0] + PanBtnPos[3][2] + && MouseY >= PanBtnPos[3][1] + && MouseY <= PanBtnPos[3][1] + PanBtnPos[3][3]) { + control_set_button_down(3); + } + if (v0 >= PanBtnPos[6][0] + && v0 <= PanBtnPos[6][0] + PanBtnPos[6][2] + && v1 >= PanBtnPos[6][1] + && v1 <= PanBtnPos[6][1] + PanBtnPos[6][3]) { + control_set_button_down(6); + } } void __cdecl DoAutoMap() { - if (currlevel || gbMaxPlayers != 1) { - if (automapflag) - automapflag = 0; - else - StartAutomap(); - } else { - InitDiabloMsg(EMSG_NO_AUTOMAP_IN_TOWN); - } + if (currlevel || gbMaxPlayers != 1) { + if (automapflag) + automapflag = 0; + else + StartAutomap(); + } else { + InitDiabloMsg(EMSG_NO_AUTOMAP_IN_TOWN); + } } // 679660: using guessed type char gbMaxPlayers; void __cdecl CheckPanelInfo() { - int v0; // edi - int v1; // eax - int v2; // ecx - int v3; // ecx - int v4; // edi - int v5; // eax - int *v6; // edx - int v7; // ebx - int v8; // ebx - int *v9; // eax - signed int v10; // edx - int v11; // ecx - int v12; // [esp+10h] [ebp-4h] + int v0; // edi + int v1; // eax + int v2; // ecx + int v3; // ecx + int v4; // edi + int v5; // eax + int *v6; // edx + int v7; // ebx + int v8; // ebx + int *v9; // eax + signed int v10; // edx + int v11; // ecx + int v12; // [esp+10h] [ebp-4h] - v0 = 0; - panelflag = 0; - ClearPanel(); - if (numpanbtns > 0) { - do { - v1 = v0; - v2 = PanBtnPos[v0][0]; - if (MouseX >= v2 && MouseX <= v2 + PanBtnPos[v1][2]) { - v3 = PanBtnPos[v1][1]; - if (MouseY >= v3 && MouseY <= v3 + PanBtnPos[v1][3]) { - if (v0 == 7) { - if (FriendlyMode) - strcpy(infostr, "Player friendly"); - else - strcpy(infostr, "Player attack"); - } else { - strcpy(infostr, PanBtnStr[v0]); - } - if (PanBtnHotKey[v0]) { - sprintf(tempstr, "Hotkey : %s", PanBtnHotKey[v0]); - AddPanelString(tempstr, 1); - } - infoclr = COL_WHITE; - panelflag = 1; - pinfoflag = 1; - } - } - ++v0; - } while (v0 < numpanbtns); - } - if (!spselflag && MouseX >= 565 && MouseX < 621 && MouseY >= 416 && MouseY < 472) { - strcpy(infostr, "Select current spell button"); - infoclr = COL_WHITE; - panelflag = 1; - pinfoflag = 1; - strcpy(tempstr, "Hotkey : 's'"); - AddPanelString(tempstr, 1); - v4 = plr[myplr]._pRSpell; - if (v4 != -1) { - switch (_LOBYTE(plr[myplr]._pRSplType)) { - case RSPLTYPE_SKILL: - sprintf(tempstr, "%s Skill", spelldata[v4].sSkillText); - LABEL_54: - AddPanelString(tempstr, 1); - break; - case RSPLTYPE_SPELL: - sprintf(tempstr, "%s Spell", spelldata[v4].sNameText); - AddPanelString(tempstr, 1); - v11 = plr[myplr]._pISplLvlAdd + plr[myplr]._pSplLvl[v4]; - if (v11 < 0) - v11 = 0; - if (v11) - sprintf(tempstr, "Spell Level %i", v11); - else - sprintf(tempstr, "Spell Level 0 - Unusable"); - goto LABEL_54; - case RSPLTYPE_SCROLL: - sprintf(tempstr, "Scroll of %s", spelldata[v4].sNameText); - AddPanelString(tempstr, 1); - v12 = 0; - v5 = myplr; - if (plr[myplr]._pNumInv > 0) { - v6 = &plr[v5].InvList[0]._iMiscId; - v7 = plr[myplr]._pNumInv; - do { - if (*(v6 - 53) != -1 && (*v6 == IMISC_SCROLL || *v6 == IMISC_SCROLLT) && v6[1] == v4) - ++v12; - v6 += 92; - --v7; - } while (v7); - } - v8 = v12; - v9 = &plr[v5].SpdList[0]._iMiscId; - v10 = MAXBELTITEMS; - do { - if (*(v9 - 53) != -1 && (*v9 == IMISC_SCROLL || *v9 == IMISC_SCROLLT) && v9[1] == v4) - ++v8; - v9 += 92; - --v10; - } while (v10); - if (v8 == 1) - strcpy(tempstr, "1 Scroll"); - else - sprintf(tempstr, "%i Scrolls", v8); - goto LABEL_54; - case RSPLTYPE_CHARGES: - sprintf(tempstr, "Staff of %s", spelldata[v4].sNameText); - AddPanelString(tempstr, 1); - if (plr[myplr].InvBody[INVLOC_HAND_LEFT]._iCharges == 1) - strcpy(tempstr, "1 Charge"); - else - sprintf(tempstr, "%i Charges", plr[myplr].InvBody[INVLOC_HAND_LEFT]._iCharges); - goto LABEL_54; - } - } - } - if (MouseX > 190 && MouseX < 437 && MouseY > 356 && MouseY < 385) - pcursinvitem = CheckInvHLight(); + v0 = 0; + panelflag = 0; + ClearPanel(); + if (numpanbtns > 0) { + do { + v1 = v0; + v2 = PanBtnPos[v0][0]; + if (MouseX >= v2 && MouseX <= v2 + PanBtnPos[v1][2]) { + v3 = PanBtnPos[v1][1]; + if (MouseY >= v3 && MouseY <= v3 + PanBtnPos[v1][3]) { + if (v0 == 7) { + if (FriendlyMode) + strcpy(infostr, "Player friendly"); + else + strcpy(infostr, "Player attack"); + } else { + strcpy(infostr, PanBtnStr[v0]); + } + if (PanBtnHotKey[v0]) { + sprintf(tempstr, "Hotkey : %s", PanBtnHotKey[v0]); + AddPanelString(tempstr, 1); + } + infoclr = COL_WHITE; + panelflag = 1; + pinfoflag = 1; + } + } + ++v0; + } while (v0 < numpanbtns); + } + if (!spselflag && MouseX >= 565 && MouseX < 621 && MouseY >= 416 && MouseY < 472) { + strcpy(infostr, "Select current spell button"); + infoclr = COL_WHITE; + panelflag = 1; + pinfoflag = 1; + strcpy(tempstr, "Hotkey : 's'"); + AddPanelString(tempstr, 1); + v4 = plr[myplr]._pRSpell; + if (v4 != -1) { + switch (_LOBYTE(plr[myplr]._pRSplType)) { + case RSPLTYPE_SKILL: + sprintf(tempstr, "%s Skill", spelldata[v4].sSkillText); + LABEL_54: + AddPanelString(tempstr, 1); + break; + case RSPLTYPE_SPELL: + sprintf(tempstr, "%s Spell", spelldata[v4].sNameText); + AddPanelString(tempstr, 1); + v11 = plr[myplr]._pISplLvlAdd + plr[myplr]._pSplLvl[v4]; + if (v11 < 0) + v11 = 0; + if (v11) + sprintf(tempstr, "Spell Level %i", v11); + else + sprintf(tempstr, "Spell Level 0 - Unusable"); + goto LABEL_54; + case RSPLTYPE_SCROLL: + sprintf(tempstr, "Scroll of %s", spelldata[v4].sNameText); + AddPanelString(tempstr, 1); + v12 = 0; + v5 = myplr; + if (plr[myplr]._pNumInv > 0) { + v6 = &plr[v5].InvList[0]._iMiscId; + v7 = plr[myplr]._pNumInv; + do { + if (*(v6 - 53) != -1 && (*v6 == IMISC_SCROLL || *v6 == IMISC_SCROLLT) && v6[1] == v4) + ++v12; + v6 += 92; + --v7; + } while (v7); + } + v8 = v12; + v9 = &plr[v5].SpdList[0]._iMiscId; + v10 = MAXBELTITEMS; + do { + if (*(v9 - 53) != -1 && (*v9 == IMISC_SCROLL || *v9 == IMISC_SCROLLT) && v9[1] == v4) + ++v8; + v9 += 92; + --v10; + } while (v10); + if (v8 == 1) + strcpy(tempstr, "1 Scroll"); + else + sprintf(tempstr, "%i Scrolls", v8); + goto LABEL_54; + case RSPLTYPE_CHARGES: + sprintf(tempstr, "Staff of %s", spelldata[v4].sNameText); + AddPanelString(tempstr, 1); + if (plr[myplr].InvBody[INVLOC_HAND_LEFT]._iCharges == 1) + strcpy(tempstr, "1 Charge"); + else + sprintf(tempstr, "%i Charges", plr[myplr].InvBody[INVLOC_HAND_LEFT]._iCharges); + goto LABEL_54; + } + } + } + if (MouseX > 190 && MouseX < 437 && MouseY > 356 && MouseY < 385) + pcursinvitem = CheckInvHLight(); } // 484368: using guessed type int FriendlyMode; // 4B8824: using guessed type int pinfoflag; @@ -1342,83 +1342,83 @@ void __cdecl CheckPanelInfo() void __cdecl CheckBtnUp() { - signed int v0; // esi - int *v1; // eax - int v2; // edx - signed int v3; // eax - int v4; // ecx - int v5; // ecx - char v6; // [esp+Fh] [ebp-1h] + signed int v0; // esi + int *v1; // eax + int v2; // edx + signed int v3; // eax + int v4; // ecx + int v5; // ecx + char v6; // [esp+Fh] [ebp-1h] - v6 = 1; - drawbtnflag = 1; - panbtndown = 0; - v0 = 0; - do { - v1 = &panbtn[v0]; - if (*v1) { - v2 = MouseX; - *v1 = 0; - v3 = v0; - v4 = PanBtnPos[v0][0]; - if (v2 >= v4 && v2 <= v4 + PanBtnPos[v3][2]) { - v5 = PanBtnPos[v3][1]; - if (MouseY >= v5 && MouseY <= v5 + PanBtnPos[v3][3]) { - switch (v0) { - case PANBTN_CHARINFO: - questlog = 0; - chrflag = chrflag == 0; - break; - case PANBTN_QLOG: - chrflag = 0; - if (questlog) - questlog = 0; - else - StartQuestlog(); - break; - case PANBTN_AUTOMAP: - DoAutoMap(); - break; - case PANBTN_MAINMENU: - qtextflag = FALSE; - gamemenu_handle_previous(); - v6 = 0; - break; - case PANBTN_INVENTORY: - sbookflag = 0; - invflag = invflag == 0; - if (dropGoldFlag) { - dropGoldFlag = 0; - dropGoldValue = 0; - } - break; - case PANBTN_SPELLBOOK: - invflag = 0; - if (dropGoldFlag) { - dropGoldFlag = 0; - dropGoldValue = 0; - } - sbookflag = sbookflag == 0; - break; - case PANBTN_SENDMSG: - if (talkflag) - control_reset_talk(); - else - control_type_message(); - break; - case PANBTN_FRIENDLY: - FriendlyMode = FriendlyMode == 0; - break; - default: - break; - } - } - } - } - ++v0; - } while (v0 < 8); - if (v6) - gamemenu_off(); + v6 = 1; + drawbtnflag = 1; + panbtndown = 0; + v0 = 0; + do { + v1 = &panbtn[v0]; + if (*v1) { + v2 = MouseX; + *v1 = 0; + v3 = v0; + v4 = PanBtnPos[v0][0]; + if (v2 >= v4 && v2 <= v4 + PanBtnPos[v3][2]) { + v5 = PanBtnPos[v3][1]; + if (MouseY >= v5 && MouseY <= v5 + PanBtnPos[v3][3]) { + switch (v0) { + case PANBTN_CHARINFO: + questlog = 0; + chrflag = chrflag == 0; + break; + case PANBTN_QLOG: + chrflag = 0; + if (questlog) + questlog = 0; + else + StartQuestlog(); + break; + case PANBTN_AUTOMAP: + DoAutoMap(); + break; + case PANBTN_MAINMENU: + qtextflag = FALSE; + gamemenu_handle_previous(); + v6 = 0; + break; + case PANBTN_INVENTORY: + sbookflag = 0; + invflag = invflag == 0; + if (dropGoldFlag) { + dropGoldFlag = 0; + dropGoldValue = 0; + } + break; + case PANBTN_SPELLBOOK: + invflag = 0; + if (dropGoldFlag) { + dropGoldFlag = 0; + dropGoldValue = 0; + } + sbookflag = sbookflag == 0; + break; + case PANBTN_SENDMSG: + if (talkflag) + control_reset_talk(); + else + control_type_message(); + break; + case PANBTN_FRIENDLY: + FriendlyMode = FriendlyMode == 0; + break; + default: + break; + } + } + } + } + ++v0; + } while (v0 < 8); + if (v6) + gamemenu_off(); } // 484368: using guessed type int FriendlyMode; // 4B84DC: using guessed type int dropGoldFlag; @@ -1430,187 +1430,187 @@ void __cdecl CheckBtnUp() void __cdecl FreeControlPan() { - void *v0; // ecx - void *v1; // ecx - void *v2; // ecx - void *v3; // ecx - void *v4; // ecx - void *v5; // ecx - void *v6; // ecx - void *v7; // ecx - void *v8; // ecx - void *v9; // ecx - void *v10; // ecx - void *v11; // ecx - void *v12; // ecx - void *v13; // ecx - void *v14; // ecx - void *v15; // ecx + void *v0; // ecx + void *v1; // ecx + void *v2; // ecx + void *v3; // ecx + void *v4; // ecx + void *v5; // ecx + void *v6; // ecx + void *v7; // ecx + void *v8; // ecx + void *v9; // ecx + void *v10; // ecx + void *v11; // ecx + void *v12; // ecx + void *v13; // ecx + void *v14; // ecx + void *v15; // ecx - v0 = pBtmBuff; - pBtmBuff = 0; - mem_free_dbg(v0); - v1 = pManaBuff; - pManaBuff = 0; - mem_free_dbg(v1); - v2 = pLifeBuff; - pLifeBuff = 0; - mem_free_dbg(v2); - v3 = pPanelText; - pPanelText = 0; - mem_free_dbg(v3); - v4 = pChrPanel; - pChrPanel = 0; - mem_free_dbg(v4); - v5 = pSpellCels; - pSpellCels = 0; - mem_free_dbg(v5); - v6 = pPanelButtons; - pPanelButtons = 0; - mem_free_dbg(v6); - v7 = pMultiBtns; - pMultiBtns = 0; - mem_free_dbg(v7); - v8 = pTalkBtns; - pTalkBtns = 0; - mem_free_dbg(v8); - v9 = pChrButtons; - pChrButtons = 0; - mem_free_dbg(v9); - v10 = pDurIcons; - pDurIcons = 0; - mem_free_dbg(v10); - v11 = pQLogCel; - pQLogCel = 0; - mem_free_dbg(v11); - v12 = pSpellBkCel; - pSpellBkCel = 0; - mem_free_dbg(v12); - v13 = pSBkBtnCel; - pSBkBtnCel = 0; - mem_free_dbg(v13); - v14 = pSBkIconCels; - pSBkIconCels = 0; - mem_free_dbg(v14); - v15 = pGBoxBuff; - pGBoxBuff = 0; - mem_free_dbg(v15); + v0 = pBtmBuff; + pBtmBuff = 0; + mem_free_dbg(v0); + v1 = pManaBuff; + pManaBuff = 0; + mem_free_dbg(v1); + v2 = pLifeBuff; + pLifeBuff = 0; + mem_free_dbg(v2); + v3 = pPanelText; + pPanelText = 0; + mem_free_dbg(v3); + v4 = pChrPanel; + pChrPanel = 0; + mem_free_dbg(v4); + v5 = pSpellCels; + pSpellCels = 0; + mem_free_dbg(v5); + v6 = pPanelButtons; + pPanelButtons = 0; + mem_free_dbg(v6); + v7 = pMultiBtns; + pMultiBtns = 0; + mem_free_dbg(v7); + v8 = pTalkBtns; + pTalkBtns = 0; + mem_free_dbg(v8); + v9 = pChrButtons; + pChrButtons = 0; + mem_free_dbg(v9); + v10 = pDurIcons; + pDurIcons = 0; + mem_free_dbg(v10); + v11 = pQLogCel; + pQLogCel = 0; + mem_free_dbg(v11); + v12 = pSpellBkCel; + pSpellBkCel = 0; + mem_free_dbg(v12); + v13 = pSBkBtnCel; + pSBkBtnCel = 0; + mem_free_dbg(v13); + v14 = pSBkIconCels; + pSBkIconCels = 0; + mem_free_dbg(v14); + v15 = pGBoxBuff; + pGBoxBuff = 0; + mem_free_dbg(v15); } int __fastcall control_WriteStringToBuffer(char *str) { - signed int v1; // edx - unsigned char v2; // al + signed int v1; // edx + unsigned char v2; // al - v1 = 0; - do { - v2 = *str; - if (!*str) - return 1; - ++str; - v1 += fontkern[fontframe[fontidx[v2]]]; - } while (v1 < 125); - return 0; + v1 = 0; + do { + v2 = *str; + if (!*str) + return 1; + ++str; + v1 += fontkern[fontframe[fontidx[v2]]]; + } while (v1 < 125); + return 0; } void __cdecl DrawInfoBox() { - int v0; // ecx - int v1; // eax - int v2; // eax - int v3; // esi - char *v4; // eax - const char *v5; // eax - signed int v7; // edi - signed int v8; // ebp - int v9; // esi - char *v10; // ebx + int v0; // ecx + int v1; // eax + int v2; // eax + int v3; // esi + char *v4; // eax + const char *v5; // eax + signed int v7; // edi + signed int v8; // ebp + int v9; // esi + char *v10; // ebx - DrawPanelBox(177, 62, 288, 60, 241, 558); - v0 = trigflag[3]; - v1 = spselflag; - if (!panelflag && !trigflag[3] && pcursinvitem == -1) { - if (spselflag) { - LABEL_32: - infoclr = COL_WHITE; - goto LABEL_33; - } - infostr[0] = 0; - infoclr = COL_WHITE; - ClearPanel(); - } - if (v1 || v0) - goto LABEL_32; - if (pcurs < CURSOR_FIRSTITEM) { - if (pcursitem != -1) - GetItemStr(pcursitem); - if (pcursobj != -1) - GetObjectStr(pcursobj); - if (pcursmonst != -1) { - if (leveltype != DTYPE_TOWN) { - infoclr = COL_WHITE; - strcpy(infostr, monster[pcursmonst].mName); - ClearPanel(); - if (monster[pcursmonst]._uniqtype) { - infoclr = COL_GOLD; - PrintUniqueHistory(); - } else { - PrintMonstHistory(monster[pcursmonst].MType->mtype); - } - } else { - strcpy(infostr, towner[pcursmonst]._tName); - } - } - if (pcursplr != -1) { - infoclr = COL_GOLD; - strcpy(infostr, plr[pcursplr]._pName); - ClearPanel(); - sprintf(tempstr, "Level : %i", plr[pcursplr]._pLevel); - AddPanelString(tempstr, 1); - sprintf(tempstr, "Hit Points %i of %i", plr[pcursplr]._pHitPoints >> 6, plr[pcursplr]._pMaxHP >> 6); - AddPanelString(tempstr, 1); - } - } else { - v2 = myplr; - if (plr[myplr].HoldItem._itype == ITYPE_GOLD) { - v3 = plr[v2].HoldItem._ivalue; - v4 = get_pieces_str(plr[v2].HoldItem._ivalue); - sprintf(infostr, "%i gold %s", v3, v4); - } else if (plr[v2].HoldItem._iStatFlag) { - if (plr[v2].HoldItem._iIdentified) - v5 = plr[v2].HoldItem._iIName; - else - v5 = plr[v2].HoldItem._iName; - strcpy(infostr, v5); - if (plr[myplr].HoldItem._iMagical == ITEM_QUALITY_MAGIC) - infoclr = COL_BLUE; - if (plr[myplr].HoldItem._iMagical == ITEM_QUALITY_UNIQUE) - infoclr = COL_GOLD; - } else { - ClearPanel(); - AddPanelString("Requirements not met", 1); - pinfoflag = 1; - } - } + DrawPanelBox(177, 62, 288, 60, 241, 558); + v0 = trigflag[3]; + v1 = spselflag; + if (!panelflag && !trigflag[3] && pcursinvitem == -1) { + if (spselflag) { + LABEL_32: + infoclr = COL_WHITE; + goto LABEL_33; + } + infostr[0] = 0; + infoclr = COL_WHITE; + ClearPanel(); + } + if (v1 || v0) + goto LABEL_32; + if (pcurs < CURSOR_FIRSTITEM) { + if (pcursitem != -1) + GetItemStr(pcursitem); + if (pcursobj != -1) + GetObjectStr(pcursobj); + if (pcursmonst != -1) { + if (leveltype != DTYPE_TOWN) { + infoclr = COL_WHITE; + strcpy(infostr, monster[pcursmonst].mName); + ClearPanel(); + if (monster[pcursmonst]._uniqtype) { + infoclr = COL_GOLD; + PrintUniqueHistory(); + } else { + PrintMonstHistory(monster[pcursmonst].MType->mtype); + } + } else { + strcpy(infostr, towner[pcursmonst]._tName); + } + } + if (pcursplr != -1) { + infoclr = COL_GOLD; + strcpy(infostr, plr[pcursplr]._pName); + ClearPanel(); + sprintf(tempstr, "Level : %i", plr[pcursplr]._pLevel); + AddPanelString(tempstr, 1); + sprintf(tempstr, "Hit Points %i of %i", plr[pcursplr]._pHitPoints >> 6, plr[pcursplr]._pMaxHP >> 6); + AddPanelString(tempstr, 1); + } + } else { + v2 = myplr; + if (plr[myplr].HoldItem._itype == ITYPE_GOLD) { + v3 = plr[v2].HoldItem._ivalue; + v4 = get_pieces_str(plr[v2].HoldItem._ivalue); + sprintf(infostr, "%i gold %s", v3, v4); + } else if (plr[v2].HoldItem._iStatFlag) { + if (plr[v2].HoldItem._iIdentified) + v5 = plr[v2].HoldItem._iIName; + else + v5 = plr[v2].HoldItem._iName; + strcpy(infostr, v5); + if (plr[myplr].HoldItem._iMagical == ITEM_QUALITY_MAGIC) + infoclr = COL_BLUE; + if (plr[myplr].HoldItem._iMagical == ITEM_QUALITY_UNIQUE) + infoclr = COL_GOLD; + } else { + ClearPanel(); + AddPanelString("Requirements not met", 1); + pinfoflag = 1; + } + } LABEL_33: - if ((infostr[0] || pnumlines) && !talkflag) { - v7 = 0; - v8 = 1; - if (infostr[0]) { - control_print_info_str(0, infostr, 1, pnumlines); - v7 = 1; - v8 = 0; - } - v9 = 0; - if (pnumlines > 0) { - v10 = panelstr; - do { - control_print_info_str(v9 + v7, v10, pstrjust[v9], pnumlines - v8); - ++v9; - v10 += 64; - } while (v9 < pnumlines); - } - } + if ((infostr[0] || pnumlines) && !talkflag) { + v7 = 0; + v8 = 1; + if (infostr[0]) { + control_print_info_str(0, infostr, 1, pnumlines); + v7 = 1; + v8 = 0; + } + v9 = 0; + if (pnumlines > 0) { + v10 = panelstr; + do { + control_print_info_str(v9 + v7, v10, pstrjust[v9], pnumlines - v8); + ++v9; + v10 += 64; + } while (v9 < pnumlines); + } + } } // 4B8824: using guessed type int pinfoflag; // 4B883C: using guessed type int infoclr; @@ -1624,1174 +1624,1174 @@ LABEL_33: void __fastcall control_print_info_str(int y, char *str, bool center, int lines) { - int v4; // edi - char *v5; // ebx - unsigned char v6; // cl - signed int v7; // eax - char *v8; // esi - int v9; // eax - unsigned char v10; // esi - unsigned char v11; // al - int width; // [esp+18h] [ebp+Ch] + int v4; // edi + char *v5; // ebx + unsigned char v6; // cl + signed int v7; // eax + char *v8; // esi + int v9; // eax + unsigned char v10; // esi + unsigned char v11; // al + int width; // [esp+18h] [ebp+Ch] - v4 = 0; - v5 = str; - width = lineoffset[y + 4 * lines + lines]; - if (center == 1) { - v6 = *str; - v7 = 0; - v8 = str; - if (!*str) - goto LABEL_14; - do { - ++v8; - v7 += fontkern[fontframe[fontidx[v6]]] + 2; - v6 = *v8; - } while (*v8); - if (v7 < 288) - LABEL_14: - v4 = (288 - v7) >> 1; - width += v4; - } - while (1) { - v11 = *v5; - if (!*v5) - break; - ++v5; - v9 = fontidx[v11]; - _LOBYTE(v9) = fontframe[v9]; - v10 = (unsigned char)v9; - v4 += fontkern[(unsigned char)v9] + 2; - if ((_BYTE)v9) { - if (v4 < 288) { - CPrintString(width, v10, infoclr); - } - } - width += fontkern[v10] + 2; - } + v4 = 0; + v5 = str; + width = lineoffset[y + 4 * lines + lines]; + if (center == 1) { + v6 = *str; + v7 = 0; + v8 = str; + if (!*str) + goto LABEL_14; + do { + ++v8; + v7 += fontkern[fontframe[fontidx[v6]]] + 2; + v6 = *v8; + } while (*v8); + if (v7 < 288) + LABEL_14: + v4 = (288 - v7) >> 1; + width += v4; + } + while (1) { + v11 = *v5; + if (!*v5) + break; + ++v5; + v9 = fontidx[v11]; + _LOBYTE(v9) = fontframe[v9]; + v10 = (unsigned char)v9; + v4 += fontkern[(unsigned char)v9] + 2; + if ((_BYTE)v9) { + if (v4 < 288) { + CPrintString(width, v10, infoclr); + } + } + width += fontkern[v10] + 2; + } } // 4B883C: using guessed type int infoclr; void __fastcall PrintGameStr(int x, int y, char *str, int color) { - char *v4; // edi - int v5; // esi - unsigned char i; // al - unsigned char v7; // bl + char *v4; // edi + int v5; // esi + unsigned char i; // al + unsigned char v7; // bl - v4 = str; - v5 = screen_y_times_768[y + 160] + x + 64; - for (i = *str; *v4; i = *v4) { - ++v4; - v7 = fontframe[fontidx[i]]; - if (v7) - CPrintString(v5, v7, color); - v5 += fontkern[v7] + 1; - } + v4 = str; + v5 = screen_y_times_768[y + 160] + x + 64; + for (i = *str; *v4; i = *v4) { + ++v4; + v7 = fontframe[fontidx[i]]; + if (v7) + CPrintString(v5, v7, color); + v5 += fontkern[v7] + 1; + } } void __cdecl DrawChr() { - int v1; // ecx - int v2; // ecx - int v3; // eax - int v4; // eax - bool v5; // zf - int v6; // eax - int v7; // edi - int v8; // edi - char v9; // al - char v10; // al - char v11; // al - int v12; // ecx - int v13; // eax - int v14; // ecx - int v15; // eax - int v16; // ecx - int v17; // eax - int v18; // ecx - int v19; // eax - int *v20; // edi - int v21; // edi - int v22; // edi - int v23; // ecx - int v24; // eax - int v25; // ecx - int v26; // ecx - char a4[64]; // [esp+Ch] [ebp-50h] - int v28; // [esp+4Ch] [ebp-10h] - int v29; // [esp+50h] [ebp-Ch] - int v30; // [esp+54h] [ebp-8h] - char a5[4]; // [esp+58h] [ebp-4h] + int v1; // ecx + int v2; // ecx + int v3; // eax + int v4; // eax + bool v5; // zf + int v6; // eax + int v7; // edi + int v8; // edi + char v9; // al + char v10; // al + char v11; // al + int v12; // ecx + int v13; // eax + int v14; // ecx + int v15; // eax + int v16; // ecx + int v17; // eax + int v18; // ecx + int v19; // eax + int *v20; // edi + int v21; // edi + int v22; // edi + int v23; // ecx + int v24; // eax + int v25; // ecx + int v26; // ecx + char a4[64]; // [esp+Ch] [ebp-50h] + int v28; // [esp+4Ch] [ebp-10h] + int v29; // [esp+50h] [ebp-Ch] + int v30; // [esp+54h] [ebp-8h] + char a5[4]; // [esp+58h] [ebp-4h] - CelDecodeOnly(64, 511, pChrPanel, 1, 320); - ADD_PlrStringXY(20, 32, 151, plr[myplr]._pName, 0); - if (plr[myplr]._pClass == PC_WARRIOR) { - ADD_PlrStringXY(168, 32, 299, "Warrior", 0); - } else if (plr[myplr]._pClass == PC_ROGUE) { - ADD_PlrStringXY(168, 32, 299, "Rogue", 0); /* should use ClassStrTbl ? */ - } else if (plr[myplr]._pClass == PC_SORCERER) { - ADD_PlrStringXY(168, 32, 299, "Sorceror", 0); - } - sprintf(a4, "%i", plr[myplr]._pLevel); - ADD_PlrStringXY(66, 69, 109, a4, 0); - sprintf(a4, "%li", plr[myplr]._pExperience); - ADD_PlrStringXY(216, 69, 300, a4, 0); - if (plr[myplr]._pLevel == 50) { - strcpy(a4, "None"); - a5[0] = 3; - } else { - sprintf(a4, "%li", plr[myplr]._pNextExper); - a5[0] = 0; - } - ADD_PlrStringXY(216, 97, 300, a4, a5[0]); - sprintf(a4, "%i", plr[myplr]._pGold); - ADD_PlrStringXY(216, 146, 300, a4, 0); - a5[0] = 0; - v29 = plr[myplr]._pIBonusAC; - if (v29 > 0) - a5[0] = 1; - if (v29 < 0) - a5[0] = 2; - sprintf(a4, "%i", v29 + plr[myplr]._pIAC + plr[myplr]._pDexterity / 5); - ADD_PlrStringXY(258, 183, 301, a4, a5[0]); - a5[0] = 0; - v1 = plr[myplr]._pIBonusToHit; - if (v1 > 0) - a5[0] = 1; - if (v1 < 0) - a5[0] = 2; - sprintf(a4, "%i%%", (plr[myplr]._pDexterity >> 1) + v1 + 50); - ADD_PlrStringXY(258, 211, 301, a4, a5[0]); - a5[0] = 0; - v2 = myplr; - v3 = plr[myplr]._pIBonusDam; - if (v3 > 0) - a5[0] = 1; - if (v3 < 0) - a5[0] = 2; - v30 = plr[v2]._pIMinDam; - v30 += plr[v2]._pIBonusDamMod + v30 * v3 / 100; - v4 = plr[v2]._pDamageMod; - v5 = plr[v2].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_BOW; - v29 = plr[v2]._pDamageMod; - if (v5 && plr[v2]._pClass != PC_ROGUE) - v4 >>= 1; - v30 += v4; - v6 = plr[v2]._pIBonusDam; - v28 = plr[v2]._pIMaxDam; - v7 = plr[v2]._pIBonusDamMod + v28 * v6 / 100 + v28; - if (plr[v2].InvBody[INVLOC_HAND_LEFT]._itype != ITYPE_BOW || plr[v2]._pClass == PC_ROGUE) - v8 = v29 + v7; - else - v8 = (v29 >> 1) + v7; - sprintf(a4, "%i-%i", v30, v8); - if (v30 >= 100 || v8 >= 100) - MY_PlrStringXY(254, 239, 305, a4, a5[0], -1); - else - MY_PlrStringXY(258, 239, 301, a4, a5[0], 0); - v9 = plr[myplr]._pMagResist; - a5[0] = v9 != 0; - if (v9 < 75) { - sprintf(a4, "%i%%", v9); - } else { - a5[0] = 3; - sprintf(a4, "MAX"); - } - ADD_PlrStringXY(257, 276, 300, a4, a5[0]); - v10 = plr[myplr]._pFireResist; - a5[0] = v10 != 0; - if (v10 < 75) { - sprintf(a4, "%i%%", v10); - } else { - a5[0] = 3; - sprintf(a4, "MAX"); - } - ADD_PlrStringXY(257, 304, 300, a4, a5[0]); - v11 = plr[myplr]._pLghtResist; - a5[0] = v11 != 0; - if (v11 < 75) { - sprintf(a4, "%i%%", v11); - } else { - a5[0] = 3; - sprintf(a4, "MAX"); - } - ADD_PlrStringXY(257, 332, 300, a4, a5[0]); - a5[0] = 0; - sprintf(a4, "%i", plr[myplr]._pBaseStr); - if (MaxStats[plr[myplr]._pClass][ATTRIB_STR] == plr[myplr]._pBaseStr) - a5[0] = 3; - ADD_PlrStringXY(95, 155, 126, a4, a5[0]); - a5[0] = 0; - sprintf(a4, "%i", plr[myplr]._pBaseMag); - if (MaxStats[plr[myplr]._pClass][ATTRIB_MAG] == plr[myplr]._pBaseMag) - a5[0] = 3; - ADD_PlrStringXY(95, 183, 126, a4, a5[0]); - a5[0] = 0; - sprintf(a4, "%i", plr[myplr]._pBaseDex); - if (MaxStats[plr[myplr]._pClass][ATTRIB_DEX] == plr[myplr]._pBaseDex) - a5[0] = 3; - ADD_PlrStringXY(95, 211, 126, a4, a5[0]); - a5[0] = 0; - sprintf(a4, "%i", plr[myplr]._pBaseVit); - if (MaxStats[plr[myplr]._pClass][ATTRIB_VIT] == plr[myplr]._pBaseVit) - a5[0] = 3; - ADD_PlrStringXY(95, 239, 126, a4, a5[0]); - a5[0] = 0; - v12 = plr[myplr]._pStrength; - v13 = plr[myplr]._pBaseStr; - if (v12 > v13) - a5[0] = 1; - if (v12 < v13) - a5[0] = 2; - sprintf(a4, "%i", v12); - ADD_PlrStringXY(143, 155, 173, a4, a5[0]); - a5[0] = 0; - v14 = plr[myplr]._pMagic; - v15 = plr[myplr]._pBaseMag; - if (v14 > v15) - a5[0] = 1; - if (v14 < v15) - a5[0] = 2; - sprintf(a4, "%i", v14); - ADD_PlrStringXY(143, 183, 173, a4, a5[0]); - a5[0] = 0; - v16 = plr[myplr]._pDexterity; - v17 = plr[myplr]._pBaseDex; - if (v16 > v17) - a5[0] = 1; - if (v16 < v17) - a5[0] = 2; - sprintf(a4, "%i", v16); - ADD_PlrStringXY(143, 211, 173, a4, a5[0]); - a5[0] = 0; - v18 = plr[myplr]._pVitality; - v19 = plr[myplr]._pBaseVit; - if (v18 > v19) - a5[0] = 1; - if (v18 < v19) - a5[0] = 2; - sprintf(a4, "%i", v18); - ADD_PlrStringXY(143, 239, 173, a4, a5[0]); - v20 = &plr[myplr]._pStatPts; - if (*v20 > 0) { - v20 = &plr[myplr]._pStatPts; - if (CalcStatDiff(myplr) < *v20) { - v20 = &plr[myplr]._pStatPts; - *v20 = CalcStatDiff(myplr); - } - } - v21 = *v20; - if (v21 > 0) { - sprintf(a4, "%i", v21); - ADD_PlrStringXY(95, 266, 126, a4, 2); - v22 = plr[myplr]._pClass; - if (plr[myplr]._pBaseStr < MaxStats[v22][ATTRIB_STR]) - CelDecodeOnly(201, 319, pChrButtons, chrbtn[0] + 2, 41); - if (plr[myplr]._pBaseMag < MaxStats[v22][ATTRIB_MAG]) - CelDecodeOnly(201, 347, pChrButtons, chrbtn[1] + 4, 41); - if (plr[myplr]._pBaseDex < MaxStats[v22][ATTRIB_DEX]) - CelDecodeOnly(201, 376, pChrButtons, chrbtn[2] + 6, 41); - if (plr[myplr]._pBaseVit < MaxStats[v22][ATTRIB_VIT]) - CelDecodeOnly(201, 404, pChrButtons, chrbtn[3] + 8, 41); - } - v23 = plr[myplr]._pMaxHP; - a5[0] = v23 > plr[myplr]._pMaxHPBase; - sprintf(a4, "%i", v23 >> 6); - ADD_PlrStringXY(95, 304, 126, a4, a5[0]); - v24 = plr[myplr]._pHitPoints; - if (v24 != plr[myplr]._pMaxHP) - a5[0] = 2; - sprintf(a4, "%i", v24 >> 6); - ADD_PlrStringXY(143, 304, 174, a4, a5[0]); - v25 = plr[myplr]._pMaxMana; - a5[0] = v25 > plr[myplr]._pMaxManaBase; - sprintf(a4, "%i", v25 >> 6); - ADD_PlrStringXY(95, 332, 126, a4, a5[0]); - v26 = plr[myplr]._pMana; - if (v26 != plr[myplr]._pMaxMana) - a5[0] = 2; - sprintf(a4, "%i", v26 >> 6); - ADD_PlrStringXY(143, 332, 174, a4, a5[0]); + CelDecodeOnly(64, 511, pChrPanel, 1, 320); + ADD_PlrStringXY(20, 32, 151, plr[myplr]._pName, 0); + if (plr[myplr]._pClass == PC_WARRIOR) { + ADD_PlrStringXY(168, 32, 299, "Warrior", 0); + } else if (plr[myplr]._pClass == PC_ROGUE) { + ADD_PlrStringXY(168, 32, 299, "Rogue", 0); /* should use ClassStrTbl ? */ + } else if (plr[myplr]._pClass == PC_SORCERER) { + ADD_PlrStringXY(168, 32, 299, "Sorceror", 0); + } + sprintf(a4, "%i", plr[myplr]._pLevel); + ADD_PlrStringXY(66, 69, 109, a4, 0); + sprintf(a4, "%li", plr[myplr]._pExperience); + ADD_PlrStringXY(216, 69, 300, a4, 0); + if (plr[myplr]._pLevel == 50) { + strcpy(a4, "None"); + a5[0] = 3; + } else { + sprintf(a4, "%li", plr[myplr]._pNextExper); + a5[0] = 0; + } + ADD_PlrStringXY(216, 97, 300, a4, a5[0]); + sprintf(a4, "%i", plr[myplr]._pGold); + ADD_PlrStringXY(216, 146, 300, a4, 0); + a5[0] = 0; + v29 = plr[myplr]._pIBonusAC; + if (v29 > 0) + a5[0] = 1; + if (v29 < 0) + a5[0] = 2; + sprintf(a4, "%i", v29 + plr[myplr]._pIAC + plr[myplr]._pDexterity / 5); + ADD_PlrStringXY(258, 183, 301, a4, a5[0]); + a5[0] = 0; + v1 = plr[myplr]._pIBonusToHit; + if (v1 > 0) + a5[0] = 1; + if (v1 < 0) + a5[0] = 2; + sprintf(a4, "%i%%", (plr[myplr]._pDexterity >> 1) + v1 + 50); + ADD_PlrStringXY(258, 211, 301, a4, a5[0]); + a5[0] = 0; + v2 = myplr; + v3 = plr[myplr]._pIBonusDam; + if (v3 > 0) + a5[0] = 1; + if (v3 < 0) + a5[0] = 2; + v30 = plr[v2]._pIMinDam; + v30 += plr[v2]._pIBonusDamMod + v30 * v3 / 100; + v4 = plr[v2]._pDamageMod; + v5 = plr[v2].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_BOW; + v29 = plr[v2]._pDamageMod; + if (v5 && plr[v2]._pClass != PC_ROGUE) + v4 >>= 1; + v30 += v4; + v6 = plr[v2]._pIBonusDam; + v28 = plr[v2]._pIMaxDam; + v7 = plr[v2]._pIBonusDamMod + v28 * v6 / 100 + v28; + if (plr[v2].InvBody[INVLOC_HAND_LEFT]._itype != ITYPE_BOW || plr[v2]._pClass == PC_ROGUE) + v8 = v29 + v7; + else + v8 = (v29 >> 1) + v7; + sprintf(a4, "%i-%i", v30, v8); + if (v30 >= 100 || v8 >= 100) + MY_PlrStringXY(254, 239, 305, a4, a5[0], -1); + else + MY_PlrStringXY(258, 239, 301, a4, a5[0], 0); + v9 = plr[myplr]._pMagResist; + a5[0] = v9 != 0; + if (v9 < 75) { + sprintf(a4, "%i%%", v9); + } else { + a5[0] = 3; + sprintf(a4, "MAX"); + } + ADD_PlrStringXY(257, 276, 300, a4, a5[0]); + v10 = plr[myplr]._pFireResist; + a5[0] = v10 != 0; + if (v10 < 75) { + sprintf(a4, "%i%%", v10); + } else { + a5[0] = 3; + sprintf(a4, "MAX"); + } + ADD_PlrStringXY(257, 304, 300, a4, a5[0]); + v11 = plr[myplr]._pLghtResist; + a5[0] = v11 != 0; + if (v11 < 75) { + sprintf(a4, "%i%%", v11); + } else { + a5[0] = 3; + sprintf(a4, "MAX"); + } + ADD_PlrStringXY(257, 332, 300, a4, a5[0]); + a5[0] = 0; + sprintf(a4, "%i", plr[myplr]._pBaseStr); + if (MaxStats[plr[myplr]._pClass][ATTRIB_STR] == plr[myplr]._pBaseStr) + a5[0] = 3; + ADD_PlrStringXY(95, 155, 126, a4, a5[0]); + a5[0] = 0; + sprintf(a4, "%i", plr[myplr]._pBaseMag); + if (MaxStats[plr[myplr]._pClass][ATTRIB_MAG] == plr[myplr]._pBaseMag) + a5[0] = 3; + ADD_PlrStringXY(95, 183, 126, a4, a5[0]); + a5[0] = 0; + sprintf(a4, "%i", plr[myplr]._pBaseDex); + if (MaxStats[plr[myplr]._pClass][ATTRIB_DEX] == plr[myplr]._pBaseDex) + a5[0] = 3; + ADD_PlrStringXY(95, 211, 126, a4, a5[0]); + a5[0] = 0; + sprintf(a4, "%i", plr[myplr]._pBaseVit); + if (MaxStats[plr[myplr]._pClass][ATTRIB_VIT] == plr[myplr]._pBaseVit) + a5[0] = 3; + ADD_PlrStringXY(95, 239, 126, a4, a5[0]); + a5[0] = 0; + v12 = plr[myplr]._pStrength; + v13 = plr[myplr]._pBaseStr; + if (v12 > v13) + a5[0] = 1; + if (v12 < v13) + a5[0] = 2; + sprintf(a4, "%i", v12); + ADD_PlrStringXY(143, 155, 173, a4, a5[0]); + a5[0] = 0; + v14 = plr[myplr]._pMagic; + v15 = plr[myplr]._pBaseMag; + if (v14 > v15) + a5[0] = 1; + if (v14 < v15) + a5[0] = 2; + sprintf(a4, "%i", v14); + ADD_PlrStringXY(143, 183, 173, a4, a5[0]); + a5[0] = 0; + v16 = plr[myplr]._pDexterity; + v17 = plr[myplr]._pBaseDex; + if (v16 > v17) + a5[0] = 1; + if (v16 < v17) + a5[0] = 2; + sprintf(a4, "%i", v16); + ADD_PlrStringXY(143, 211, 173, a4, a5[0]); + a5[0] = 0; + v18 = plr[myplr]._pVitality; + v19 = plr[myplr]._pBaseVit; + if (v18 > v19) + a5[0] = 1; + if (v18 < v19) + a5[0] = 2; + sprintf(a4, "%i", v18); + ADD_PlrStringXY(143, 239, 173, a4, a5[0]); + v20 = &plr[myplr]._pStatPts; + if (*v20 > 0) { + v20 = &plr[myplr]._pStatPts; + if (CalcStatDiff(myplr) < *v20) { + v20 = &plr[myplr]._pStatPts; + *v20 = CalcStatDiff(myplr); + } + } + v21 = *v20; + if (v21 > 0) { + sprintf(a4, "%i", v21); + ADD_PlrStringXY(95, 266, 126, a4, 2); + v22 = plr[myplr]._pClass; + if (plr[myplr]._pBaseStr < MaxStats[v22][ATTRIB_STR]) + CelDecodeOnly(201, 319, pChrButtons, chrbtn[0] + 2, 41); + if (plr[myplr]._pBaseMag < MaxStats[v22][ATTRIB_MAG]) + CelDecodeOnly(201, 347, pChrButtons, chrbtn[1] + 4, 41); + if (plr[myplr]._pBaseDex < MaxStats[v22][ATTRIB_DEX]) + CelDecodeOnly(201, 376, pChrButtons, chrbtn[2] + 6, 41); + if (plr[myplr]._pBaseVit < MaxStats[v22][ATTRIB_VIT]) + CelDecodeOnly(201, 404, pChrButtons, chrbtn[3] + 8, 41); + } + v23 = plr[myplr]._pMaxHP; + a5[0] = v23 > plr[myplr]._pMaxHPBase; + sprintf(a4, "%i", v23 >> 6); + ADD_PlrStringXY(95, 304, 126, a4, a5[0]); + v24 = plr[myplr]._pHitPoints; + if (v24 != plr[myplr]._pMaxHP) + a5[0] = 2; + sprintf(a4, "%i", v24 >> 6); + ADD_PlrStringXY(143, 304, 174, a4, a5[0]); + v25 = plr[myplr]._pMaxMana; + a5[0] = v25 > plr[myplr]._pMaxManaBase; + sprintf(a4, "%i", v25 >> 6); + ADD_PlrStringXY(95, 332, 126, a4, a5[0]); + v26 = plr[myplr]._pMana; + if (v26 != plr[myplr]._pMaxMana) + a5[0] = 2; + sprintf(a4, "%i", v26 >> 6); + ADD_PlrStringXY(143, 332, 174, a4, a5[0]); } void __fastcall ADD_PlrStringXY(int x, int y, int width, char *pszStr, char col) { - int v5; // eax - char *v6; // edx - unsigned char v7; // al - int v8; // esi - int v9; // edi - int v10; // ecx - unsigned char v11; // bl - unsigned char v12; // al - int v13; // ebx - int widtha; // [esp+Ch] [ebp-4h] - int widthb; // [esp+Ch] [ebp-4h] + int v5; // eax + char *v6; // edx + unsigned char v7; // al + int v8; // esi + int v9; // edi + int v10; // ecx + unsigned char v11; // bl + unsigned char v12; // al + int v13; // ebx + int widtha; // [esp+Ch] [ebp-4h] + int widthb; // [esp+Ch] [ebp-4h] - v5 = screen_y_times_768[y + 160]; - v6 = pszStr; - widtha = v5 + x + 64; - v7 = *pszStr; - v8 = width - x + 1; - v9 = 0; - v10 = 0; - if (*pszStr) { - v11 = *pszStr; - do { - ++v6; - v10 += fontkern[fontframe[fontidx[v11]]] + 1; - v11 = *v6; - } while (*v6); - } - if (v10 < v8) - v9 = (v8 - v10) >> 1; - widthb = v9 + widtha; - while (v7) { - ++pszStr; - v12 = fontframe[fontidx[v7]]; - v13 = v12; - v9 += fontkern[v12] + 1; - if (v12) { - if (v9 < v8) - CPrintString(widthb, v12, col); - } - widthb += fontkern[v13] + 1; - v7 = *pszStr; - } + v5 = screen_y_times_768[y + 160]; + v6 = pszStr; + widtha = v5 + x + 64; + v7 = *pszStr; + v8 = width - x + 1; + v9 = 0; + v10 = 0; + if (*pszStr) { + v11 = *pszStr; + do { + ++v6; + v10 += fontkern[fontframe[fontidx[v11]]] + 1; + v11 = *v6; + } while (*v6); + } + if (v10 < v8) + v9 = (v8 - v10) >> 1; + widthb = v9 + widtha; + while (v7) { + ++pszStr; + v12 = fontframe[fontidx[v7]]; + v13 = v12; + v9 += fontkern[v12] + 1; + if (v12) { + if (v9 < v8) + CPrintString(widthb, v12, col); + } + widthb += fontkern[v13] + 1; + v7 = *pszStr; + } } void __fastcall MY_PlrStringXY(int x, int y, int width, char *pszStr, char col, int base) { - char *v6; // ebx - unsigned char v7; // al - int v8; // edx - int v9; // esi - char *v10; // edi - unsigned char v11; // cl - unsigned char v12; // al - int v13; // edi - int widtha; // [esp+Ch] [ebp-4h] - int widthb; // [esp+Ch] [ebp-4h] - int v16; // [esp+18h] [ebp+8h] + char *v6; // ebx + unsigned char v7; // al + int v8; // edx + int v9; // esi + char *v10; // edi + unsigned char v11; // cl + unsigned char v12; // al + int v13; // edi + int widtha; // [esp+Ch] [ebp-4h] + int widthb; // [esp+Ch] [ebp-4h] + int v16; // [esp+18h] [ebp+8h] - v6 = pszStr; - widtha = screen_y_times_768[y + 160] + x + 64; - v7 = *pszStr; - v8 = 0; - v9 = width - x + 1; - v16 = 0; - v10 = pszStr; - if (*pszStr) { - v11 = *pszStr; - do { - ++v10; - v8 += base + fontkern[fontframe[fontidx[v11]]]; - v11 = *v10; - } while (*v10); - } - if (v8 < v9) - v16 = (v9 - v8) >> 1; - widthb = v16 + widtha; - while (v7) { - ++v6; - v12 = fontframe[fontidx[v7]]; - v13 = v12; - v16 += base + fontkern[v12]; - if (v12) { - if (v16 < v9) - CPrintString(widthb, v12, col); - } - widthb += base + fontkern[v13]; - v7 = *v6; - } + v6 = pszStr; + widtha = screen_y_times_768[y + 160] + x + 64; + v7 = *pszStr; + v8 = 0; + v9 = width - x + 1; + v16 = 0; + v10 = pszStr; + if (*pszStr) { + v11 = *pszStr; + do { + ++v10; + v8 += base + fontkern[fontframe[fontidx[v11]]]; + v11 = *v10; + } while (*v10); + } + if (v8 < v9) + v16 = (v9 - v8) >> 1; + widthb = v16 + widtha; + while (v7) { + ++v6; + v12 = fontframe[fontidx[v7]]; + v13 = v12; + v16 += base + fontkern[v12]; + if (v12) { + if (v16 < v9) + CPrintString(widthb, v12, col); + } + widthb += base + fontkern[v13]; + v7 = *v6; + } } void __cdecl CheckLvlBtn() { - if (!lvlbtndown && MouseX >= 40 && MouseX <= 81 && MouseY >= 313 && MouseY <= 335) - lvlbtndown = 1; + if (!lvlbtndown && MouseX >= 40 && MouseX <= 81 && MouseY >= 313 && MouseY <= 335) + lvlbtndown = 1; } // 4B851C: using guessed type int lvlbtndown; void __cdecl ReleaseLvlBtn() { - if (MouseX >= 40 && MouseX <= 81 && MouseY >= 313 && MouseY <= 335) - chrflag = 1; - lvlbtndown = 0; + if (MouseX >= 40 && MouseX <= 81 && MouseY >= 313 && MouseY <= 335) + chrflag = 1; + lvlbtndown = 0; } // 4B851C: using guessed type int lvlbtndown; void __cdecl DrawLevelUpIcon() { - int v0; // esi + int v0; // esi - if (!stextflag) { - v0 = (lvlbtndown != 0) + 2; - ADD_PlrStringXY(0, 303, 120, "Level Up", 0); - CelDecodeOnly(104, 495, pChrButtons, v0, 41); - } + if (!stextflag) { + v0 = (lvlbtndown != 0) + 2; + ADD_PlrStringXY(0, 303, 120, "Level Up", 0); + CelDecodeOnly(104, 495, pChrButtons, v0, 41); + } } // 4B851C: using guessed type int lvlbtndown; // 6AA705: using guessed type char stextflag; void __cdecl CheckChrBtns() { - int v0; // esi - int v1; // ecx - int v2; // ebx - int v3; // edi - int v4; // edx - bool v5; // sf - unsigned char v6; // of - int v7; // edx - int v8; // edx - int v9; // edx - int v10; // eax - int v11; // edx - int v12; // edx + int v0; // esi + int v1; // ecx + int v2; // ebx + int v3; // edi + int v4; // edx + bool v5; // sf + unsigned char v6; // of + int v7; // edx + int v8; // edx + int v9; // edx + int v10; // eax + int v11; // edx + int v12; // edx - v0 = 0; - if (!chrbtnactive) { - v1 = myplr; - if (plr[myplr]._pStatPts) { - v2 = MouseX; - v3 = plr[v1]._pClass; - while (1) { - if (!v0) { - v9 = plr[v1]._pBaseStr; - v6 = __OFSUB__(v9, MaxStats[v3][ATTRIB_STR]); - v5 = v9 - MaxStats[v3][ATTRIB_STR] < 0; - goto LABEL_12; - } - if (v0 == 1) { - v8 = plr[v1]._pBaseMag; - v6 = __OFSUB__(v8, MaxStats[v3][ATTRIB_MAG]); - v5 = v8 - MaxStats[v3][ATTRIB_MAG] < 0; - goto LABEL_12; - } - if (v0 == 2) - break; - if (v0 == 3) { - v4 = plr[v1]._pBaseVit; - v6 = __OFSUB__(v4, MaxStats[v3][ATTRIB_VIT]); - v5 = v4 - MaxStats[v3][ATTRIB_VIT] < 0; - LABEL_12: - if (v5 ^ v6) { - v10 = v0; - v11 = attribute_inc_rects[v0][0]; - if (v2 >= v11 && v2 <= v11 + attribute_inc_rects[v10][2]) { - v12 = attribute_inc_rects[v10][1]; - if (MouseY >= v12 && MouseY <= v12 + attribute_inc_rects[v10][3]) { - chrbtn[v0] = 1; - chrbtnactive = 1; - } - } - } - } - if (++v0 >= 4) - return; - } - v7 = plr[v1]._pBaseDex; - v6 = __OFSUB__(v7, MaxStats[v3][ATTRIB_DEX]); - v5 = v7 - MaxStats[v3][ATTRIB_DEX] < 0; - goto LABEL_12; - } - } + v0 = 0; + if (!chrbtnactive) { + v1 = myplr; + if (plr[myplr]._pStatPts) { + v2 = MouseX; + v3 = plr[v1]._pClass; + while (1) { + if (!v0) { + v9 = plr[v1]._pBaseStr; + v6 = __OFSUB__(v9, MaxStats[v3][ATTRIB_STR]); + v5 = v9 - MaxStats[v3][ATTRIB_STR] < 0; + goto LABEL_12; + } + if (v0 == 1) { + v8 = plr[v1]._pBaseMag; + v6 = __OFSUB__(v8, MaxStats[v3][ATTRIB_MAG]); + v5 = v8 - MaxStats[v3][ATTRIB_MAG] < 0; + goto LABEL_12; + } + if (v0 == 2) + break; + if (v0 == 3) { + v4 = plr[v1]._pBaseVit; + v6 = __OFSUB__(v4, MaxStats[v3][ATTRIB_VIT]); + v5 = v4 - MaxStats[v3][ATTRIB_VIT] < 0; + LABEL_12: + if (v5 ^ v6) { + v10 = v0; + v11 = attribute_inc_rects[v0][0]; + if (v2 >= v11 && v2 <= v11 + attribute_inc_rects[v10][2]) { + v12 = attribute_inc_rects[v10][1]; + if (MouseY >= v12 && MouseY <= v12 + attribute_inc_rects[v10][3]) { + chrbtn[v0] = 1; + chrbtnactive = 1; + } + } + } + } + if (++v0 >= 4) + return; + } + v7 = plr[v1]._pBaseDex; + v6 = __OFSUB__(v7, MaxStats[v3][ATTRIB_DEX]); + v5 = v7 - MaxStats[v3][ATTRIB_DEX] < 0; + goto LABEL_12; + } + } } // 4B87A8: using guessed type int chrbtnactive; void __cdecl ReleaseChrBtns() { - signed int v0; // esi - int *v1; // eax - signed int v2; // eax - int v3; // ecx - int v4; // ecx - unsigned char v5; // dl + signed int v0; // esi + int *v1; // eax + signed int v2; // eax + int v3; // ecx + int v4; // ecx + unsigned char v5; // dl - chrbtnactive = 0; - v0 = 0; - do { - v1 = &chrbtn[v0]; - if (*v1) { - *v1 = 0; - v2 = v0; - v3 = attribute_inc_rects[v0][0]; - if (MouseX >= v3 && MouseX <= v3 + attribute_inc_rects[v2][2]) { - v4 = attribute_inc_rects[v2][1]; - if (MouseY >= v4 && MouseY <= v4 + attribute_inc_rects[v2][3]) { - if (v0) { - switch (v0) { - case ATTRIB_MAG: - v5 = CMD_ADDMAG; - break; - case ATTRIB_DEX: - v5 = CMD_ADDDEX; - break; - case ATTRIB_VIT: - v5 = CMD_ADDVIT; - break; - default: - goto LABEL_16; - } - } else { - v5 = CMD_ADDSTR; - } - NetSendCmdParam1(TRUE, v5, 1u); - --plr[myplr]._pStatPts; - } - } - } - LABEL_16: - ++v0; - } while (v0 < 4); + chrbtnactive = 0; + v0 = 0; + do { + v1 = &chrbtn[v0]; + if (*v1) { + *v1 = 0; + v2 = v0; + v3 = attribute_inc_rects[v0][0]; + if (MouseX >= v3 && MouseX <= v3 + attribute_inc_rects[v2][2]) { + v4 = attribute_inc_rects[v2][1]; + if (MouseY >= v4 && MouseY <= v4 + attribute_inc_rects[v2][3]) { + if (v0) { + switch (v0) { + case ATTRIB_MAG: + v5 = CMD_ADDMAG; + break; + case ATTRIB_DEX: + v5 = CMD_ADDDEX; + break; + case ATTRIB_VIT: + v5 = CMD_ADDVIT; + break; + default: + goto LABEL_16; + } + } else { + v5 = CMD_ADDSTR; + } + NetSendCmdParam1(TRUE, v5, 1u); + --plr[myplr]._pStatPts; + } + } + } + LABEL_16: + ++v0; + } while (v0 < 4); } // 4B87A8: using guessed type int chrbtnactive; void __cdecl DrawDurIcon() { - int v0; // edx - PlayerStruct *v1; // esi - int v2; // eax - int v3; // eax - int v4; // eax + int v0; // edx + PlayerStruct *v1; // esi + int v2; // eax + int v3; // eax + int v4; // eax - if (!chrflag && !questlog || !invflag && !sbookflag) { - v0 = 656; - if (invflag || sbookflag) - v0 = 336; - v1 = &plr[myplr]; - v2 = DrawDurIcon4Item(v1->InvBody, v0, 4); - v3 = DrawDurIcon4Item(&v1->InvBody[INVLOC_CHEST], v2, 3); - v4 = DrawDurIcon4Item(&v1->InvBody[INVLOC_HAND_LEFT], v3, 0); - DrawDurIcon4Item(&v1->InvBody[INVLOC_HAND_RIGHT], v4, 0); - } + if (!chrflag && !questlog || !invflag && !sbookflag) { + v0 = 656; + if (invflag || sbookflag) + v0 = 336; + v1 = &plr[myplr]; + v2 = DrawDurIcon4Item(v1->InvBody, v0, 4); + v3 = DrawDurIcon4Item(&v1->InvBody[INVLOC_CHEST], v2, 3); + v4 = DrawDurIcon4Item(&v1->InvBody[INVLOC_HAND_LEFT], v3, 0); + DrawDurIcon4Item(&v1->InvBody[INVLOC_HAND_RIGHT], v4, 0); + } } // 4B8968: using guessed type int sbookflag; // 69BD04: using guessed type int questlog; int __fastcall DrawDurIcon4Item(ItemStruct *pItem, int x, int c) { - int v3; // eax - int v4; // edi - int v5; // esi - signed int v7; // edx - int v8; // eax - int v9; // eax - int v10; // eax - int v11; // eax - signed int v12; // [esp-4h] [ebp-Ch] + int v3; // eax + int v4; // edi + int v5; // esi + signed int v7; // edx + int v8; // eax + int v9; // eax + int v10; // eax + int v11; // eax + signed int v12; // [esp-4h] [ebp-Ch] - v3 = pItem->_itype; - v4 = x; - if (v3 == -1) - return x; - v5 = pItem->_iDurability; - if (v5 > 5) - return x; - v7 = c; - if (!c) { - if (pItem->_iClass != 1) { - v7 = 1; - goto LABEL_18; - } - v8 = v3 - 1; - if (!v8) { - v12 = 2; - goto LABEL_15; - } - v9 = v8 - 1; - if (!v9) { - v12 = 6; - goto LABEL_15; - } - v10 = v9 - 1; - if (!v10) { - v12 = 7; - goto LABEL_15; - } - v11 = v10 - 1; - if (!v11) { - v12 = 5; - goto LABEL_15; - } - if (v11 == 6) { - v12 = 8; - LABEL_15: - v7 = v12; - goto LABEL_18; - } - } + v3 = pItem->_itype; + v4 = x; + if (v3 == -1) + return x; + v5 = pItem->_iDurability; + if (v5 > 5) + return x; + v7 = c; + if (!c) { + if (pItem->_iClass != 1) { + v7 = 1; + goto LABEL_18; + } + v8 = v3 - 1; + if (!v8) { + v12 = 2; + goto LABEL_15; + } + v9 = v8 - 1; + if (!v9) { + v12 = 6; + goto LABEL_15; + } + v10 = v9 - 1; + if (!v10) { + v12 = 7; + goto LABEL_15; + } + v11 = v10 - 1; + if (!v11) { + v12 = 5; + goto LABEL_15; + } + if (v11 == 6) { + v12 = 8; + LABEL_15: + v7 = v12; + goto LABEL_18; + } + } LABEL_18: - if (v5 > 2) - v7 += 8; - CelDecodeOnly(v4, 495, pDurIcons, v7, 32); - return v4 - 40; + if (v5 > 2) + v7 += 8; + CelDecodeOnly(v4, 495, pDurIcons, v7, 32); + return v4 - 40; } void __cdecl RedBack() { - int v0; // eax - char *v1; // edi - signed int v3; // edx - signed int v4; // ecx - char *v7; // edi - signed int v9; // edx - signed int v10; // ecx - int v12; // [esp+8h] [ebp-4h] - int _EAX; - char *_EBX; + int v0; // eax + char *v1; // edi + signed int v3; // edx + signed int v4; // ecx + char *v7; // edi + signed int v9; // edx + signed int v10; // ecx + int v12; // [esp+8h] [ebp-4h] + int _EAX; + char *_EBX; - v0 = -(light4flag != 0); - _LOWORD(v0) = v0 & 0xF400; - v12 = v0 + 768 * 6; - if (leveltype == DTYPE_HELL) { - v7 = gpBuffer->row[0].pixels; - _EBX = &pLightTbl[v12]; - v9 = 352; - do { - v10 = 640; - do { - _EAX = *v7; - if ((unsigned char)*v7 >= 32) - ASM_XLAT(_EAX, _EBX); - *v7++ = _EAX; - --v10; - } while (v10); - v7 += 128; - --v9; - } while (v9); - } else { - v1 = gpBuffer->row[0].pixels; - _EBX = &pLightTbl[v12]; - v3 = 352; - do { - v4 = 640; - do { - _EAX = *v1; - ASM_XLAT(_EAX, _EBX); - *v1++ = _EAX; - --v4; - } while (v4); - v1 += 128; - --v3; - } while (v3); - } + v0 = -(light4flag != 0); + _LOWORD(v0) = v0 & 0xF400; + v12 = v0 + 768 * 6; + if (leveltype == DTYPE_HELL) { + v7 = gpBuffer->row[0].pixels; + _EBX = &pLightTbl[v12]; + v9 = 352; + do { + v10 = 640; + do { + _EAX = *v7; + if ((unsigned char)*v7 >= 32) + ASM_XLAT(_EAX, _EBX); + *v7++ = _EAX; + --v10; + } while (v10); + v7 += 128; + --v9; + } while (v9); + } else { + v1 = gpBuffer->row[0].pixels; + _EBX = &pLightTbl[v12]; + v3 = 352; + do { + v4 = 640; + do { + _EAX = *v1; + ASM_XLAT(_EAX, _EBX); + *v1++ = _EAX; + --v4; + } while (v4); + v1 += 128; + --v3; + } while (v3); + } } // 525728: using guessed type int light4flag; char __fastcall GetSBookTrans(int ii, BOOL townok) { - char result = RSPLTYPE_SPELL; - if ((__int64)1 << (ii - 1) & plr[myplr]._pISpells) - result = RSPLTYPE_CHARGES; - if (1 << (ii - 1) & plr[myplr]._pAblSpells) - result = RSPLTYPE_SKILL; + char result = RSPLTYPE_SPELL; + if ((__int64)1 << (ii - 1) & plr[myplr]._pISpells) + result = RSPLTYPE_CHARGES; + if (1 << (ii - 1) & plr[myplr]._pAblSpells) + result = RSPLTYPE_SKILL; - if (result == RSPLTYPE_SPELL) { - if (!CheckSpell(myplr, ii, RSPLTYPE_SPELL, TRUE)) - result = RSPLTYPE_INVALID; - if ((char)(plr[myplr]._pISplLvlAdd + plr[myplr]._pSplLvl[ii]) <= 0) - result = RSPLTYPE_INVALID; - } + if (result == RSPLTYPE_SPELL) { + if (!CheckSpell(myplr, ii, RSPLTYPE_SPELL, TRUE)) + result = RSPLTYPE_INVALID; + if ((char)(plr[myplr]._pISplLvlAdd + plr[myplr]._pSplLvl[ii]) <= 0) + result = RSPLTYPE_INVALID; + } - if (townok && currlevel == 0 && result != RSPLTYPE_INVALID && !spelldata[ii].sTownSpell) - result = RSPLTYPE_INVALID; + if (townok && currlevel == 0 && result != RSPLTYPE_INVALID && !spelldata[ii].sTownSpell) + result = RSPLTYPE_INVALID; - return result; + return result; } void __cdecl DrawSpellBook() { - __int64 v0; // edi - __int64 v1; // ebp - int v2; // esi - char v3; // al - int v4; // eax - int v5; // ebx - int v6; // ecx - char v7; // [esp+Bh] [ebp-1Dh] - int v8; // [esp+Ch] [ebp-1Ch] - signed int v9; // [esp+10h] [ebp-18h] - int sel; // [esp+14h] [ebp-14h] - int v11; // [esp+18h] [ebp-10h] - int v12; // [esp+1Ch] [ebp-Ch] + __int64 v0; // edi + __int64 v1; // ebp + int v2; // esi + char v3; // al + int v4; // eax + int v5; // ebx + int v6; // ecx + char v7; // [esp+Bh] [ebp-1Dh] + int v8; // [esp+Ch] [ebp-1Ch] + signed int v9; // [esp+10h] [ebp-18h] + int sel; // [esp+14h] [ebp-14h] + int v11; // [esp+18h] [ebp-10h] + int v12; // [esp+1Ch] [ebp-Ch] - CelDecodeOnly(384, 511, pSpellBkCel, 1, 320); - CelDecodeOnly(76 * sbooktab + 391, 508, pSBkBtnCel, sbooktab + 1, 76); - v9 = 1; - v8 = 214; - v0 = plr[myplr]._pISpells | plr[myplr]._pMemSpells | plr[myplr]._pAblSpells; - do { - v2 = SpellPages[0][v9 + 7 * sbooktab - 1]; // *(&attribute_inc_rects[3].h + v9 + 7 * sbooktab); /* check */ - v1 = (__int64)1 << (v2 - 1); - if (v2 != -1 && (v1 & v0)) { - v7 = GetSBookTrans(v2, TRUE); - SetSpellTrans(v7); - DrawSpellCel(395, v8 + 1, (char *)pSBkIconCels, (char)SpellITbl[v2], MAX_SPELLS); - if (v2 == plr[myplr]._pRSpell && v7 == _LOBYTE(plr[myplr]._pRSplType)) { - SetSpellTrans(RSPLTYPE_SKILL); - DrawSpellCel(395, v8 + 1, (char *)pSBkIconCels, 43, MAX_SPELLS); - } - PrintSBookStr(10, v8 - 22, 0, spelldata[v2].sNameText, 0); - v3 = GetSBookTrans(v2, FALSE); - if (v3 != RSPLTYPE_SKILL) { - if (v3 == RSPLTYPE_CHARGES) { - sprintf(tempstr, "Staff (%i charges)", plr[myplr].InvBody[INVLOC_HAND_LEFT]._iCharges); - } else { - v4 = GetManaAmount(myplr, v2); - v5 = v4 >> 6; - v12 = v4 >> 6; - GetDamageAmt(v2, &sel, &v11); - if (sel == -1) - sprintf(tempstr, "Mana: %i Dam: n/a", v5); - else - sprintf(tempstr, "Mana: %i Dam: %i - %i", v5, sel, v11); - if (v2 == SPL_BONESPIRIT) - sprintf(tempstr, "Mana: %i Dam: 1/3 tgt hp", v12); - PrintSBookStr(10, v8, 0, tempstr, 0); - v6 = plr[myplr]._pISplLvlAdd + plr[myplr]._pSplLvl[v2]; - if (v6 < 0) - v6 = 0; - if (v6) - sprintf(tempstr, "Spell Level %i", v6); - else - sprintf(tempstr, "Spell Level 0 - Unusable"); - } - } else { - strcpy(tempstr, "Skill"); - } - PrintSBookStr(10, v8 - 11, 0, tempstr, 0); - } - v8 += 43; - ++v9; - } while (v9 < 8); + CelDecodeOnly(384, 511, pSpellBkCel, 1, 320); + CelDecodeOnly(76 * sbooktab + 391, 508, pSBkBtnCel, sbooktab + 1, 76); + v9 = 1; + v8 = 214; + v0 = plr[myplr]._pISpells | plr[myplr]._pMemSpells | plr[myplr]._pAblSpells; + do { + v2 = SpellPages[0][v9 + 7 * sbooktab - 1]; // *(&attribute_inc_rects[3].h + v9 + 7 * sbooktab); /* check */ + v1 = (__int64)1 << (v2 - 1); + if (v2 != -1 && (v1 & v0)) { + v7 = GetSBookTrans(v2, TRUE); + SetSpellTrans(v7); + DrawSpellCel(395, v8 + 1, (char *)pSBkIconCels, (char)SpellITbl[v2], MAX_SPELLS); + if (v2 == plr[myplr]._pRSpell && v7 == _LOBYTE(plr[myplr]._pRSplType)) { + SetSpellTrans(RSPLTYPE_SKILL); + DrawSpellCel(395, v8 + 1, (char *)pSBkIconCels, 43, MAX_SPELLS); + } + PrintSBookStr(10, v8 - 22, 0, spelldata[v2].sNameText, 0); + v3 = GetSBookTrans(v2, FALSE); + if (v3 != RSPLTYPE_SKILL) { + if (v3 == RSPLTYPE_CHARGES) { + sprintf(tempstr, "Staff (%i charges)", plr[myplr].InvBody[INVLOC_HAND_LEFT]._iCharges); + } else { + v4 = GetManaAmount(myplr, v2); + v5 = v4 >> 6; + v12 = v4 >> 6; + GetDamageAmt(v2, &sel, &v11); + if (sel == -1) + sprintf(tempstr, "Mana: %i Dam: n/a", v5); + else + sprintf(tempstr, "Mana: %i Dam: %i - %i", v5, sel, v11); + if (v2 == SPL_BONESPIRIT) + sprintf(tempstr, "Mana: %i Dam: 1/3 tgt hp", v12); + PrintSBookStr(10, v8, 0, tempstr, 0); + v6 = plr[myplr]._pISplLvlAdd + plr[myplr]._pSplLvl[v2]; + if (v6 < 0) + v6 = 0; + if (v6) + sprintf(tempstr, "Spell Level %i", v6); + else + sprintf(tempstr, "Spell Level 0 - Unusable"); + } + } else { + strcpy(tempstr, "Skill"); + } + PrintSBookStr(10, v8 - 11, 0, tempstr, 0); + } + v8 += 43; + ++v9; + } while (v9 < 8); } // 4B8950: using guessed type int sbooktab; void __fastcall PrintSBookStr(int x, int y, bool cjustflag, char *pszStr, int bright) { - char *v5; // ebx - signed int v6; // eax - int v7; // edi - unsigned char v8; // cl - char *v9; // esi - unsigned char v10; // al - int v11; // esi - unsigned char v12; // al - int width; // [esp+Ch] [ebp-4h] + char *v5; // ebx + signed int v6; // eax + int v7; // edi + unsigned char v8; // cl + char *v9; // esi + unsigned char v10; // al + int v11; // esi + unsigned char v12; // al + int width; // [esp+Ch] [ebp-4h] - v5 = pszStr; - width = screen_y_times_768[y] + x + 440; - v6 = 0; - v7 = 0; - if (cjustflag) { - v8 = *pszStr; - v9 = pszStr; - if (!*pszStr) - goto LABEL_14; - do { - ++v9; - v6 += fontkern[fontframe[fontidx[v8]]] + 1; - v8 = *v9; - } while (*v9); - if (v6 < 222) - LABEL_14: - v7 = (222 - v6) >> 1; - width += v7; - } - while (1) { - v12 = *v5; - if (!*v5) - break; - ++v5; - v10 = fontframe[fontidx[v12]]; - v11 = v10; - v7 += fontkern[v10] + 1; - if (v10) { - if (v7 <= 222) - CPrintString(width, v10, bright); - } - width += fontkern[v11] + 1; - } + v5 = pszStr; + width = screen_y_times_768[y] + x + 440; + v6 = 0; + v7 = 0; + if (cjustflag) { + v8 = *pszStr; + v9 = pszStr; + if (!*pszStr) + goto LABEL_14; + do { + ++v9; + v6 += fontkern[fontframe[fontidx[v8]]] + 1; + v8 = *v9; + } while (*v9); + if (v6 < 222) + LABEL_14: + v7 = (222 - v6) >> 1; + width += v7; + } + while (1) { + v12 = *v5; + if (!*v5) + break; + ++v5; + v10 = fontframe[fontidx[v12]]; + v11 = v10; + v7 += fontkern[v10] + 1; + if (v10) { + if (v7 <= 222) + CPrintString(width, v10, bright); + } + width += fontkern[v11] + 1; + } } void __cdecl CheckSBook() { - if (MouseX >= 331 && MouseX < 368 && MouseY >= 18 && MouseY < 314) { - int spell = SpellPages[sbooktab][(MouseY - 18) / 43]; - if (spell != -1) { - if ((__int64)1 << (spell - 1) & (plr[myplr]._pAblSpells | plr[myplr]._pMemSpells | plr[myplr]._pISpells)) { - char splType = RSPLTYPE_SPELL; - if ((__int64)1 << (spell - 1) & plr[myplr]._pISpells) - splType = RSPLTYPE_CHARGES; - if ((__int64)1 << (spell - 1) & plr[myplr]._pAblSpells) - splType = RSPLTYPE_SKILL; - plr[myplr]._pRSpell = spell; - plr[myplr]._pRSplType = splType; - drawpanflag = 255; - } - } - } - if (MouseX >= 327 && MouseX < 633 && MouseY >= 320 && MouseY < 349) /// BUGFIX: change `< 633` to `< 631` - sbooktab = (MouseX - 327) / 76; + if (MouseX >= 331 && MouseX < 368 && MouseY >= 18 && MouseY < 314) { + int spell = SpellPages[sbooktab][(MouseY - 18) / 43]; + if (spell != -1) { + if ((__int64)1 << (spell - 1) & (plr[myplr]._pAblSpells | plr[myplr]._pMemSpells | plr[myplr]._pISpells)) { + char splType = RSPLTYPE_SPELL; + if ((__int64)1 << (spell - 1) & plr[myplr]._pISpells) + splType = RSPLTYPE_CHARGES; + if ((__int64)1 << (spell - 1) & plr[myplr]._pAblSpells) + splType = RSPLTYPE_SKILL; + plr[myplr]._pRSpell = spell; + plr[myplr]._pRSplType = splType; + drawpanflag = 255; + } + } + } + if (MouseX >= 327 && MouseX < 633 && MouseY >= 320 && MouseY < 349) /// BUGFIX: change `< 633` to `< 631` + sbooktab = (MouseX - 327) / 76; } // 4B8950: using guessed type int sbooktab; // 52571C: using guessed type int drawpanflag; char *__fastcall get_pieces_str(int nGold) { - char *result; // eax + char *result; // eax - result = "piece"; - if (nGold != 1) - result = "pieces"; - return result; + result = "piece"; + if (nGold != 1) + result = "pieces"; + return result; } void __fastcall DrawGoldSplit(int amount) { - int v1; // ebp - char *v2; // eax - char v3; // cl - signed int i; // eax - int screen_x; // [esp+10h] [ebp-4h] - int screen_xa; // [esp+10h] [ebp-4h] + int v1; // ebp + char *v2; // eax + char v3; // cl + signed int i; // eax + int screen_x; // [esp+10h] [ebp-4h] + int screen_xa; // [esp+10h] [ebp-4h] - screen_x = 0; - v1 = amount; - CelDecodeOnly(415, 338, pGBoxBuff, 1, 261); - sprintf(tempstr, "You have %u gold", initialDropGoldValue); - ADD_PlrStringXY(366, 87, 600, tempstr, 3); - v2 = get_pieces_str(initialDropGoldValue); - sprintf(tempstr, "%s. How many do", v2); - ADD_PlrStringXY(366, 103, 600, tempstr, 3); - ADD_PlrStringXY(366, 121, 600, "you want to remove?", 3); - if (v1 <= 0) { - screen_xa = 450; - } else { - sprintf(tempstr, "%u", v1); - PrintGameStr(388, 140, tempstr, 0); - v3 = tempstr[0]; - for (i = 0; i < v3; v3 = tempstr[i]) { - ++i; - screen_x += fontkern[fontframe[fontidx[(unsigned char)v3]]] + 1; - } - screen_xa = screen_x + 452; - } - CelDecodeOnly(screen_xa, 300, pCelBuff, frame_4B8800, 12); - frame_4B8800 = (frame_4B8800 & 7) + 1; + screen_x = 0; + v1 = amount; + CelDecodeOnly(415, 338, pGBoxBuff, 1, 261); + sprintf(tempstr, "You have %u gold", initialDropGoldValue); + ADD_PlrStringXY(366, 87, 600, tempstr, 3); + v2 = get_pieces_str(initialDropGoldValue); + sprintf(tempstr, "%s. How many do", v2); + ADD_PlrStringXY(366, 103, 600, tempstr, 3); + ADD_PlrStringXY(366, 121, 600, "you want to remove?", 3); + if (v1 <= 0) { + screen_xa = 450; + } else { + sprintf(tempstr, "%u", v1); + PrintGameStr(388, 140, tempstr, 0); + v3 = tempstr[0]; + for (i = 0; i < v3; v3 = tempstr[i]) { + ++i; + screen_x += fontkern[fontframe[fontidx[(unsigned char)v3]]] + 1; + } + screen_xa = screen_x + 452; + } + CelDecodeOnly(screen_xa, 300, pCelBuff, frame_4B8800, 12); + frame_4B8800 = (frame_4B8800 & 7) + 1; } void __fastcall control_drop_gold(int vkey) { - char v1; // bl - int v2; // eax - int v3; // eax - size_t v4; // esi - char v6[6]; // [esp+8h] [ebp-8h] + char v1; // bl + int v2; // eax + int v3; // eax + size_t v4; // esi + char v6[6]; // [esp+8h] [ebp-8h] - v1 = vkey; - if (plr[myplr]._pHitPoints >> 6 <= 0) { - dropGoldFlag = 0; - dropGoldValue = 0; - return; - } - memset(v6, 0, sizeof(v6)); - _itoa(dropGoldValue, v6, 10); - if (v1 != VK_RETURN) { - if (v1 == VK_ESCAPE) { - dropGoldFlag = 0; - dropGoldValue = 0; - return; - } - if (v1 == VK_BACK) { - v6[strlen(v6) - 1] = '\0'; - v2 = atoi(v6); - } else { - v3 = v1 - '0'; - if (v3 < 0 || v3 > 9) - return; - if (dropGoldValue || atoi(v6) <= initialDropGoldValue) { - v6[strlen(v6)] = v1; - if (atoi(v6) > initialDropGoldValue) - return; - v4 = strlen(v6); - if (v4 > strlen(v6)) - return; - } else { - v6[0] = v1; - } - v2 = atoi(v6); - } - dropGoldValue = v2; - return; - } - if (dropGoldValue > 0) - control_remove_gold(myplr, initialDropGoldIndex); - dropGoldFlag = 0; + v1 = vkey; + if (plr[myplr]._pHitPoints >> 6 <= 0) { + dropGoldFlag = 0; + dropGoldValue = 0; + return; + } + memset(v6, 0, sizeof(v6)); + _itoa(dropGoldValue, v6, 10); + if (v1 != VK_RETURN) { + if (v1 == VK_ESCAPE) { + dropGoldFlag = 0; + dropGoldValue = 0; + return; + } + if (v1 == VK_BACK) { + v6[strlen(v6) - 1] = '\0'; + v2 = atoi(v6); + } else { + v3 = v1 - '0'; + if (v3 < 0 || v3 > 9) + return; + if (dropGoldValue || atoi(v6) <= initialDropGoldValue) { + v6[strlen(v6)] = v1; + if (atoi(v6) > initialDropGoldValue) + return; + v4 = strlen(v6); + if (v4 > strlen(v6)) + return; + } else { + v6[0] = v1; + } + v2 = atoi(v6); + } + dropGoldValue = v2; + return; + } + if (dropGoldValue > 0) + control_remove_gold(myplr, initialDropGoldIndex); + dropGoldFlag = 0; } // 4B84DC: using guessed type int dropGoldFlag; // 406C40: using guessed type char var_8[8]; void __fastcall control_remove_gold(int pnum, int gold_index) { - int v2; // edi - int v3; // esi - int v4; // edx - _DWORD *v5; // eax - int v6; // edx - _DWORD *v7; // eax - int v8; // eax + int v2; // edi + int v3; // esi + int v4; // edx + _DWORD *v5; // eax + int v6; // edx + _DWORD *v7; // eax + int v8; // eax - v2 = pnum; - v3 = pnum; - if (gold_index > 46) { - v6 = gold_index - 47; - v7 = (unsigned int *)((char *)&plr[v3].SpdList[v6]._ivalue); - *v7 -= dropGoldValue; - if (*v7 <= 0) - RemoveSpdBarItem(pnum, v6); - else - SetSpdbarGoldCurs(pnum, v6); - } else { - v4 = gold_index - 7; - v5 = (unsigned int *)((char *)&plr[v3].InvList[v4]._ivalue); - *v5 -= dropGoldValue; - if (*v5 <= 0) - RemoveInvItem(pnum, v4); - else - SetGoldCurs(pnum, v4); - } - SetPlrHandItem(&plr[v3].HoldItem, IDI_GOLD); - GetGoldSeed(v2, &plr[v3].HoldItem); - plr[v3].HoldItem._ivalue = dropGoldValue; - plr[v3].HoldItem._iStatFlag = 1; - control_set_gold_curs(v2); - v8 = CalculateGold(v2); - dropGoldValue = 0; - plr[v3]._pGold = v8; + v2 = pnum; + v3 = pnum; + if (gold_index > 46) { + v6 = gold_index - 47; + v7 = (unsigned int *)((char *)&plr[v3].SpdList[v6]._ivalue); + *v7 -= dropGoldValue; + if (*v7 <= 0) + RemoveSpdBarItem(pnum, v6); + else + SetSpdbarGoldCurs(pnum, v6); + } else { + v4 = gold_index - 7; + v5 = (unsigned int *)((char *)&plr[v3].InvList[v4]._ivalue); + *v5 -= dropGoldValue; + if (*v5 <= 0) + RemoveInvItem(pnum, v4); + else + SetGoldCurs(pnum, v4); + } + SetPlrHandItem(&plr[v3].HoldItem, IDI_GOLD); + GetGoldSeed(v2, &plr[v3].HoldItem); + plr[v3].HoldItem._ivalue = dropGoldValue; + plr[v3].HoldItem._iStatFlag = 1; + control_set_gold_curs(v2); + v8 = CalculateGold(v2); + dropGoldValue = 0; + plr[v3]._pGold = v8; } void __fastcall control_set_gold_curs(int pnum) { - int v1; // ecx - int v2; // eax - int *v3; // eax - bool v4; // zf - bool v5; // sf - unsigned char v6; // of + int v1; // ecx + int v2; // eax + int *v3; // eax + bool v4; // zf + bool v5; // sf + unsigned char v6; // of - v1 = pnum; - v2 = plr[v1].HoldItem._ivalue; - if (v2 < 2500) { - v6 = __OFSUB__(v2, 1000); - v4 = v2 == 1000; - v5 = v2 - 1000 < 0; - v3 = &plr[v1].HoldItem._iCurs; - if ((unsigned char)(v5 ^ v6) | v4) - *v3 = ICURS_GOLD_SMALL; - else - *v3 = ICURS_GOLD_MEDIUM; - } else { - v3 = &plr[v1].HoldItem._iCurs; - plr[v1].HoldItem._iCurs = ICURS_GOLD_LARGE; - } - SetCursor(*v3 + 12); + v1 = pnum; + v2 = plr[v1].HoldItem._ivalue; + if (v2 < 2500) { + v6 = __OFSUB__(v2, 1000); + v4 = v2 == 1000; + v5 = v2 - 1000 < 0; + v3 = &plr[v1].HoldItem._iCurs; + if ((unsigned char)(v5 ^ v6) | v4) + *v3 = ICURS_GOLD_SMALL; + else + *v3 = ICURS_GOLD_MEDIUM; + } else { + v3 = &plr[v1].HoldItem._iCurs; + plr[v1].HoldItem._iCurs = ICURS_GOLD_LARGE; + } + SetCursor(*v3 + 12); } void __cdecl DrawTalkPan() { - int v0; // esi - signed int v1; // edi - signed int v2; // esi - char *v3; // eax - int v4; // esi - int v5; // esi - int v6; // ebx - int v7; // eax - int a4; // [esp+4h] [ebp-Ch] - char *a1; // [esp+8h] [ebp-8h] - int v10; // [esp+Ch] [ebp-4h] + int v0; // esi + signed int v1; // edi + signed int v2; // esi + char *v3; // eax + int v4; // esi + int v5; // esi + int v6; // ebx + int v7; // eax + int a4; // [esp+4h] [ebp-Ch] + char *a1; // [esp+8h] [ebp-8h] + int v10; // [esp+Ch] [ebp-4h] - v0 = 0; - if (talkflag) { - DrawPanelBox(175, sgbPlrTalkTbl + 20, 294, 5, 239, 516); - v1 = 293; - do { - DrawPanelBox((v0 >> 1) + 175, sgbPlrTalkTbl + v0 + 25, v1, 1, (v0 >> 1) + 239, v0 + 521); - ++v0; - --v1; - } while (v1 > 283); - DrawPanelBox(185, sgbPlrTalkTbl + 35, 274, 30, 249, 531); - DrawPanelBox(180, sgbPlrTalkTbl + 65, 284, 5, 244, 561); - v2 = 0; - do { - DrawPanelBox(180, sgbPlrTalkTbl + v2 + 70, v2 + 284, 1, 244, v2 + 566); - ++v2; - } while (v2 < 10); - DrawPanelBox(170, sgbPlrTalkTbl + 80, 310, 55, 234, 576); - v3 = sgszTalkMsg; - v4 = 0; - do { - v3 = control_print_talk_msg(v3, 0, v4, &a4, 0); - if (!v3) - goto LABEL_10; - v4 += 13; - } while (v4 < 39); - *v3 = 0; - LABEL_10: - CelDecDatOnly((char *)gpBuffer + a4, (char *)pCelBuff, frame, 12); - v5 = 0; - a1 = plr[0]._pName; - v10 = 0; - frame = (frame & 7) + 1; - while (v10 == myplr) { - LABEL_21: - a1 += 21720; - ++v10; - if ((signed int)a1 >= (signed int)&plr[4]._pName) - return; - } - if (tempstr[v10 + 256]) { - v6 = 3; - if (!talkbtndown[v5]) { - LABEL_18: - if (*(a1 - 291)) - control_print_talk_msg(a1, 46, 18 * v5 + 60, &a4, v6); - ++v5; - goto LABEL_21; - } - v7 = (v5 != 0) + 3; - } else { - v7 = (v5 != 0) + 1; - v6 = 2; - if (talkbtndown[v5]) - v7 = (v5 != 0) + 5; - } - CelDecodeOnly(236, 18 * v5 + 596, pTalkBtns, v7, 61); - goto LABEL_18; - } + v0 = 0; + if (talkflag) { + DrawPanelBox(175, sgbPlrTalkTbl + 20, 294, 5, 239, 516); + v1 = 293; + do { + DrawPanelBox((v0 >> 1) + 175, sgbPlrTalkTbl + v0 + 25, v1, 1, (v0 >> 1) + 239, v0 + 521); + ++v0; + --v1; + } while (v1 > 283); + DrawPanelBox(185, sgbPlrTalkTbl + 35, 274, 30, 249, 531); + DrawPanelBox(180, sgbPlrTalkTbl + 65, 284, 5, 244, 561); + v2 = 0; + do { + DrawPanelBox(180, sgbPlrTalkTbl + v2 + 70, v2 + 284, 1, 244, v2 + 566); + ++v2; + } while (v2 < 10); + DrawPanelBox(170, sgbPlrTalkTbl + 80, 310, 55, 234, 576); + v3 = sgszTalkMsg; + v4 = 0; + do { + v3 = control_print_talk_msg(v3, 0, v4, &a4, 0); + if (!v3) + goto LABEL_10; + v4 += 13; + } while (v4 < 39); + *v3 = 0; + LABEL_10: + CelDecDatOnly((char *)gpBuffer + a4, (char *)pCelBuff, frame, 12); + v5 = 0; + a1 = plr[0]._pName; + v10 = 0; + frame = (frame & 7) + 1; + while (v10 == myplr) { + LABEL_21: + a1 += 21720; + ++v10; + if ((signed int)a1 >= (signed int)&plr[4]._pName) + return; + } + if (tempstr[v10 + 256]) { + v6 = 3; + if (!talkbtndown[v5]) { + LABEL_18: + if (*(a1 - 291)) + control_print_talk_msg(a1, 46, 18 * v5 + 60, &a4, v6); + ++v5; + goto LABEL_21; + } + v7 = (v5 != 0) + 3; + } else { + v7 = (v5 != 0) + 1; + v6 = 2; + if (talkbtndown[v5]) + v7 = (v5 != 0) + 5; + } + CelDecodeOnly(236, 18 * v5 + 596, pTalkBtns, v7, 61); + goto LABEL_18; + } } // 4B8840: using guessed type int sgbPlrTalkTbl; // 4B8960: using guessed type int talkflag; char *__fastcall control_print_talk_msg(char *msg, int x, int y, int *a4, int just) { - int v5; // edx - char *v6; // ebx - unsigned char v7; // al - int v8; // ecx - unsigned char v10; // dl - int v11; // edi - int a3; // [esp+14h] [ebp+8h] + int v5; // edx + char *v6; // ebx + unsigned char v7; // al + int v8; // ecx + unsigned char v10; // dl + int v11; // edi + int a3; // [esp+14h] [ebp+8h] - v5 = x + 264; - v6 = msg; - *a4 = v5 + screen_y_times_768[y + 534]; - v7 = *msg; - v8 = v5; - if (!v7) - return 0; - while (1) { - v10 = fontframe[fontidx[v7]]; - v11 = v10; - a3 = v8 + fontkern[v10] + 1; - if (a3 > 514) - break; - ++v6; - if (v10) - CPrintString(*a4, v10, just); - *a4 += fontkern[v11] + 1; - v7 = *v6; - if (!*v6) - return 0; - v8 = a3; - } - return v6; + v5 = x + 264; + v6 = msg; + *a4 = v5 + screen_y_times_768[y + 534]; + v7 = *msg; + v8 = v5; + if (!v7) + return 0; + while (1) { + v10 = fontframe[fontidx[v7]]; + v11 = v10; + a3 = v8 + fontkern[v10] + 1; + if (a3 > 514) + break; + ++v6; + if (v10) + CPrintString(*a4, v10, just); + *a4 += fontkern[v11] + 1; + v7 = *v6; + if (!*v6) + return 0; + v8 = a3; + } + return v6; } int __cdecl control_check_talk_btn() { - int v0; // ecx - int result; // eax + int v0; // ecx + int result; // eax - if (!talkflag) - return 0; - if (MouseX < 172) - return 0; - v0 = MouseY; - if (MouseY < 421 || MouseX > 233) - return 0; - result = 0; - if (MouseY <= 475) { - talkbtndown[0] = 0; - talkbtndown[1] = 0; - talkbtndown[2] = 0; - talkbtndown[(v0 - 421) / 18] = 1; - result = 1; - } - return result; + if (!talkflag) + return 0; + if (MouseX < 172) + return 0; + v0 = MouseY; + if (MouseY < 421 || MouseX > 233) + return 0; + result = 0; + if (MouseY <= 475) { + talkbtndown[0] = 0; + talkbtndown[1] = 0; + talkbtndown[2] = 0; + talkbtndown[(v0 - 421) / 18] = 1; + result = 1; + } + return result; } // 4B8960: using guessed type int talkflag; void __cdecl control_release_talk_btn() { - signed int v0; // ecx - int v1; // eax - signed int v2; // ecx + signed int v0; // ecx + int v1; // eax + signed int v2; // ecx - if (talkflag) { - v0 = MouseX; - talkbtndown[0] = 0; - talkbtndown[1] = 0; - talkbtndown[2] = 0; - if (v0 >= 172 && MouseY >= 421 && v0 <= 233 && MouseY <= 475) { - v1 = (MouseY - 421) / 18; - v2 = 0; - do { - if (v1 == -1) - break; - if (v2 != myplr) - --v1; - ++v2; - } while (v2 < 4); - if (v2 <= 4) - tempstr[v2 + 255] = tempstr[v2 + 255] == 0; - } - } + if (talkflag) { + v0 = MouseX; + talkbtndown[0] = 0; + talkbtndown[1] = 0; + talkbtndown[2] = 0; + if (v0 >= 172 && MouseY >= 421 && v0 <= 233 && MouseY <= 475) { + v1 = (MouseY - 421) / 18; + v2 = 0; + do { + if (v1 == -1) + break; + if (v2 != myplr) + --v1; + ++v2; + } while (v2 < 4); + if (v2 <= 4) + tempstr[v2 + 255] = tempstr[v2 + 255] == 0; + } + } } // 4B8960: using guessed type int talkflag; void __cdecl control_reset_talk_msg() { - signed int v1; // ecx + signed int v1; // ecx - BOOL v0 = FALSE; - v1 = 0; - do { - if (tempstr[v1 + 256]) - v0 |= 1 << v1; - ++v1; - } while (v1 < 4); - if (!msgcmd_add_server_cmd_W(sgszTalkMsg)) - NetSendCmdString(v0, sgszTalkMsg); + BOOL v0 = FALSE; + v1 = 0; + do { + if (tempstr[v1 + 256]) + v0 |= 1 << v1; + ++v1; + } while (v1 < 4); + if (!msgcmd_add_server_cmd_W(sgszTalkMsg)) + NetSendCmdString(v0, sgszTalkMsg); } void __cdecl control_type_message() { - if (gbMaxPlayers != 1) { - sgszTalkMsg[0] = 0; - talkflag = 1; - frame = 1; - talkbtndown[0] = 0; - talkbtndown[1] = 0; - talkbtndown[2] = 0; - sgbPlrTalkTbl = 144; - drawpanflag = 255; - sgbTalkSavePos = sgbNextTalkSave; - } + if (gbMaxPlayers != 1) { + sgszTalkMsg[0] = 0; + talkflag = 1; + frame = 1; + talkbtndown[0] = 0; + talkbtndown[1] = 0; + talkbtndown[2] = 0; + sgbPlrTalkTbl = 144; + drawpanflag = 255; + sgbTalkSavePos = sgbNextTalkSave; + } } // 4B84CC: using guessed type char sgbNextTalkSave; // 4B84CD: using guessed type char sgbTalkSavePos; @@ -2802,9 +2802,9 @@ void __cdecl control_type_message() void __cdecl control_reset_talk() { - talkflag = 0; - sgbPlrTalkTbl = 0; - drawpanflag = 255; + talkflag = 0; + sgbPlrTalkTbl = 0; + drawpanflag = 255; } // 4B8840: using guessed type int sgbPlrTalkTbl; // 4B8960: using guessed type int talkflag; @@ -2812,53 +2812,53 @@ void __cdecl control_reset_talk() int __fastcall control_talk_last_key(int a1) { - char v1; // bl - signed int v3; // eax + char v1; // bl + signed int v3; // eax - v1 = a1; - if (gbMaxPlayers == 1 || !talkflag || (unsigned int)a1 < VK_SPACE) - return 0; - v3 = strlen(sgszTalkMsg); - if (v3 < 78) { - sgszTalkMsg[v3 + 1] = 0; - sgszTalkMsg[v3] = v1; - } - return 1; + v1 = a1; + if (gbMaxPlayers == 1 || !talkflag || (unsigned int)a1 < VK_SPACE) + return 0; + v3 = strlen(sgszTalkMsg); + if (v3 < 78) { + sgszTalkMsg[v3 + 1] = 0; + sgszTalkMsg[v3] = v1; + } + return 1; } // 4B8960: using guessed type int talkflag; // 679660: using guessed type char gbMaxPlayers; int __fastcall control_presskeys(int a1) { - signed int v1; // eax - char v2; // cl + signed int v1; // eax + char v2; // cl - if (gbMaxPlayers != 1 && talkflag) { - switch (a1) { - case VK_SPACE: - return 1; - case VK_ESCAPE: - control_reset_talk(); - return 1; - case VK_RETURN: - control_press_enter(); - return 1; - case VK_BACK: - v1 = strlen(sgszTalkMsg); - if (v1 > 0) - sgszTalkMsg[v1 - 1] = '\0'; - return 1; - case VK_DOWN: - v2 = 1; - LABEL_15: - control_up_down(v2); - return 1; - case VK_UP: - v2 = -1; - goto LABEL_15; - } - } - return 0; + if (gbMaxPlayers != 1 && talkflag) { + switch (a1) { + case VK_SPACE: + return 1; + case VK_ESCAPE: + control_reset_talk(); + return 1; + case VK_RETURN: + control_press_enter(); + return 1; + case VK_BACK: + v1 = strlen(sgszTalkMsg); + if (v1 > 0) + sgszTalkMsg[v1 - 1] = '\0'; + return 1; + case VK_DOWN: + v2 = 1; + LABEL_15: + control_up_down(v2); + return 1; + case VK_UP: + v2 = -1; + goto LABEL_15; + } + } + return 0; } // 4B87A8: using guessed type int chrbtnactive; // 4B8960: using guessed type int talkflag; @@ -2866,59 +2866,59 @@ int __fastcall control_presskeys(int a1) void __cdecl control_press_enter() { - signed int v0; // esi - char(*v1)[80]; // ebp - char v2; // al - int v3; // ecx - char *v4; // ebp + signed int v0; // esi + char(*v1)[80]; // ebp + char v2; // al + int v3; // ecx + char *v4; // ebp - if (sgszTalkMsg[0]) { - control_reset_talk_msg(); - v0 = 0; - v1 = sgszTalkSave; - do { - if (!strcmp((const char *)v1, sgszTalkMsg)) - break; - ++v1; - ++v0; - } while ((signed int)v1 < (signed int)&sgszTalkSave[8]); - if (v0 < 8) { - v2 = sgbNextTalkSave; - v3 = (sgbNextTalkSave - 1) & 7; - if (v0 != v3) { - v4 = sgszTalkSave[v3]; - strcpy(sgszTalkSave[v0], sgszTalkSave[v3]); - strcpy(v4, sgszTalkMsg); - v2 = sgbNextTalkSave; - } - } else { - strcpy(sgszTalkSave[(unsigned char)sgbNextTalkSave], sgszTalkMsg); - v2 = (sgbNextTalkSave + 1) & 7; - sgbNextTalkSave = (sgbNextTalkSave + 1) & 7; - } - sgszTalkMsg[0] = 0; - sgbTalkSavePos = v2; - } - control_reset_talk(); + if (sgszTalkMsg[0]) { + control_reset_talk_msg(); + v0 = 0; + v1 = sgszTalkSave; + do { + if (!strcmp((const char *)v1, sgszTalkMsg)) + break; + ++v1; + ++v0; + } while ((signed int)v1 < (signed int)&sgszTalkSave[8]); + if (v0 < 8) { + v2 = sgbNextTalkSave; + v3 = (sgbNextTalkSave - 1) & 7; + if (v0 != v3) { + v4 = sgszTalkSave[v3]; + strcpy(sgszTalkSave[v0], sgszTalkSave[v3]); + strcpy(v4, sgszTalkMsg); + v2 = sgbNextTalkSave; + } + } else { + strcpy(sgszTalkSave[(unsigned char)sgbNextTalkSave], sgszTalkMsg); + v2 = (sgbNextTalkSave + 1) & 7; + sgbNextTalkSave = (sgbNextTalkSave + 1) & 7; + } + sgszTalkMsg[0] = 0; + sgbTalkSavePos = v2; + } + control_reset_talk(); } // 4B84CC: using guessed type char sgbNextTalkSave; // 4B84CD: using guessed type char sgbTalkSavePos; void __fastcall control_up_down(char a1) { - unsigned char v1; // al - int v2; // esi + unsigned char v1; // al + int v2; // esi - v1 = sgbTalkSavePos; - v2 = 0; - while (1) { - v1 = (a1 + v1) & 7; - sgbTalkSavePos = v1; - if (sgszTalkSave[v1][0]) - break; - if (++v2 >= 8) - return; - } - strcpy(sgszTalkMsg, sgszTalkSave[v1]); + v1 = sgbTalkSavePos; + v2 = 0; + while (1) { + v1 = (a1 + v1) & 7; + sgbTalkSavePos = v1; + if (sgszTalkSave[v1][0]) + break; + if (++v2 >= 8) + return; + } + strcpy(sgszTalkMsg, sgszTalkSave[v1]); } // 4B84CD: using guessed type char sgbTalkSavePos; diff --git a/Source/cursor.cpp b/Source/cursor.cpp index 46e6f918..c6342b1f 100644 --- a/Source/cursor.cpp +++ b/Source/cursor.cpp @@ -23,427 +23,427 @@ int pcurs; // idb /* rdata */ const int InvItemWidth[180] = { - 0, - 33, - 32, - 32, - 32, - 32, - 32, - 32, - 32, - 32, - 32, - 23, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56 + 0, + 33, + 32, + 32, + 32, + 32, + 32, + 32, + 32, + 32, + 32, + 23, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56 }; const int InvItemHeight[180] = { - 0, - 29, - 32, - 32, - 32, - 32, - 32, - 32, - 32, - 32, - 32, - 35, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 28, - 56, - 56, - 56, - 56, - 56, - 56, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 56, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84, - 84 + 0, + 29, + 32, + 32, + 32, + 32, + 32, + 32, + 32, + 32, + 32, + 35, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 28, + 56, + 56, + 56, + 56, + 56, + 56, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 56, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84, + 84 }; void __cdecl InitCursor() { - pCursCels = LoadFileInMem("Data\\Inv\\Objcurs.CEL", 0); - ClearCursor(); + pCursCels = LoadFileInMem("Data\\Inv\\Objcurs.CEL", 0); + ClearCursor(); } void __cdecl FreeCursor() { - void *v0; // ecx + void *v0; // ecx - v0 = pCursCels; - pCursCels = 0; - mem_free_dbg(v0); - ClearCursor(); + v0 = pCursCels; + pCursCels = 0; + mem_free_dbg(v0); + ClearCursor(); } void __fastcall SetICursor(int i) { - int v1; // ecx + int v1; // ecx - v1 = i; - icursW = InvItemWidth[v1]; - icursH = InvItemHeight[v1]; - icursW28 = icursW / 28; - icursH28 = icursH / 28; + v1 = i; + icursW = InvItemWidth[v1]; + icursH = InvItemHeight[v1]; + icursW28 = icursW / 28; + icursH28 = icursH / 28; } // 4B8CB4: using guessed type int icursH; // 4B8CBC: using guessed type int icursW; void __fastcall SetCursor(int i) { - int v1; // eax + int v1; // eax - v1 = InvItemWidth[i]; - pcurs = i; - cursW = v1; - cursH = InvItemHeight[i]; - SetICursor(i); + v1 = InvItemWidth[i]; + pcurs = i; + cursW = v1; + cursH = InvItemHeight[i]; + SetICursor(i); } // 4B8C9C: using guessed type int cursH; void __fastcall NewCursor(int i) { - SetCursor(i); + SetCursor(i); } void __cdecl InitLevelCursor() { - SetCursor(CURSOR_HAND); - cursmx = ViewX; - cursmy = ViewY; - dword_4B8CCC = -1; - pcursmonst = -1; - pcursobj = -1; - pcursitem = -1; - pcursplr = -1; - ClearCursor(); + SetCursor(CURSOR_HAND); + cursmx = ViewX; + cursmy = ViewY; + dword_4B8CCC = -1; + pcursmonst = -1; + pcursobj = -1; + pcursitem = -1; + pcursplr = -1; + ClearCursor(); } // 4B8CC0: using guessed type char pcursitem; // 4B8CC1: using guessed type char pcursobj; @@ -452,726 +452,726 @@ void __cdecl InitLevelCursor() void __cdecl CheckTown() { - int v0; // ecx - int v1; // eax - int v2; // esi - int v3; // edx - int v4; // ebx - int v5; // [esp+0h] [ebp-4h] + int v0; // ecx + int v1; // eax + int v2; // esi + int v3; // edx + int v4; // ebx + int v5; // [esp+0h] [ebp-4h] - v5 = 0; - if (nummissiles > 0) { - v0 = cursmx; - v1 = cursmy; - do { - v2 = missileactive[v5]; - if (missile[v2]._mitype == MIS_TOWN) { - if ((v3 = missile[v2]._mix, v4 = v3 - 1, v0 == v3 - 1) && v1 == missile[v2]._miy - || v0 == v3 && v1 == missile[v2]._miy - 1 - || v0 == v4 && v1 == missile[v2]._miy - 1 - || v0 == v3 - 2 && (v1 == missile[v2]._miy - 1 || v0 == v3 - 2 && v1 == missile[v2]._miy - 2) - || v0 == v4 && v1 == missile[v2]._miy - 2 - || v0 == v3 && v1 == missile[v2]._miy) { - trigflag[3] = 1; - ClearPanel(); - strcpy(infostr, "Town Portal"); - sprintf(tempstr, "from %s", plr[missile[v2]._misource]._pName); - AddPanelString(tempstr, 1); - v0 = missile[v2]._mix; - v1 = missile[v2]._miy; - cursmx = missile[v2]._mix; - cursmy = v1; - } - } - ++v5; - } while (v5 < nummissiles); - } + v5 = 0; + if (nummissiles > 0) { + v0 = cursmx; + v1 = cursmy; + do { + v2 = missileactive[v5]; + if (missile[v2]._mitype == MIS_TOWN) { + if ((v3 = missile[v2]._mix, v4 = v3 - 1, v0 == v3 - 1) && v1 == missile[v2]._miy + || v0 == v3 && v1 == missile[v2]._miy - 1 + || v0 == v4 && v1 == missile[v2]._miy - 1 + || v0 == v3 - 2 && (v1 == missile[v2]._miy - 1 || v0 == v3 - 2 && v1 == missile[v2]._miy - 2) + || v0 == v4 && v1 == missile[v2]._miy - 2 + || v0 == v3 && v1 == missile[v2]._miy) { + trigflag[3] = 1; + ClearPanel(); + strcpy(infostr, "Town Portal"); + sprintf(tempstr, "from %s", plr[missile[v2]._misource]._pName); + AddPanelString(tempstr, 1); + v0 = missile[v2]._mix; + v1 = missile[v2]._miy; + cursmx = missile[v2]._mix; + cursmy = v1; + } + } + ++v5; + } while (v5 < nummissiles); + } } void __cdecl CheckRportal() { - int v0; // ecx - int v1; // eax - int v2; // esi - int v3; // edx - int v4; // ebx - int v5; // [esp+0h] [ebp-4h] + int v0; // ecx + int v1; // eax + int v2; // esi + int v3; // edx + int v4; // ebx + int v5; // [esp+0h] [ebp-4h] - v5 = 0; - if (nummissiles > 0) { - v0 = cursmx; - v1 = cursmy; - do { - v2 = missileactive[v5]; - if (missile[v2]._mitype == MIS_RPORTAL) { - if ((v3 = missile[v2]._mix, v4 = v3 - 1, v0 == v3 - 1) && v1 == missile[v2]._miy - || v0 == v3 && v1 == missile[v2]._miy - 1 - || v0 == v4 && v1 == missile[v2]._miy - 1 - || v0 == v3 - 2 && (v1 == missile[v2]._miy - 1 || v0 == v3 - 2 && v1 == missile[v2]._miy - 2) - || v0 == v4 && v1 == missile[v2]._miy - 2 - || v0 == v3 && v1 == missile[v2]._miy) { - trigflag[3] = 1; - ClearPanel(); - strcpy(infostr, "Portal to"); - if (setlevel) - strcpy(tempstr, "level 15"); - else - strcpy(tempstr, "The Unholy Altar"); - AddPanelString(tempstr, 1); - v0 = missile[v2]._mix; - v1 = missile[v2]._miy; - cursmx = missile[v2]._mix; - cursmy = v1; - } - } - ++v5; - } while (v5 < nummissiles); - } + v5 = 0; + if (nummissiles > 0) { + v0 = cursmx; + v1 = cursmy; + do { + v2 = missileactive[v5]; + if (missile[v2]._mitype == MIS_RPORTAL) { + if ((v3 = missile[v2]._mix, v4 = v3 - 1, v0 == v3 - 1) && v1 == missile[v2]._miy + || v0 == v3 && v1 == missile[v2]._miy - 1 + || v0 == v4 && v1 == missile[v2]._miy - 1 + || v0 == v3 - 2 && (v1 == missile[v2]._miy - 1 || v0 == v3 - 2 && v1 == missile[v2]._miy - 2) + || v0 == v4 && v1 == missile[v2]._miy - 2 + || v0 == v3 && v1 == missile[v2]._miy) { + trigflag[3] = 1; + ClearPanel(); + strcpy(infostr, "Portal to"); + if (setlevel) + strcpy(tempstr, "level 15"); + else + strcpy(tempstr, "The Unholy Altar"); + AddPanelString(tempstr, 1); + v0 = missile[v2]._mix; + v1 = missile[v2]._miy; + cursmx = missile[v2]._mix; + cursmy = v1; + } + } + ++v5; + } while (v5 < nummissiles); + } } // 5CF31D: using guessed type char setlevel; void __cdecl CheckCursMove() { - int v0; // esi - signed int v1; // edi - int v2; // esi - int v3; // edi - int v4; // edx - int v5; // ebx - int v6; // edi - int v7; // eax - int v8; // esi - BOOL v9; // eax - int v10; // ecx - int v11; // edx - int v12; // ecx - int v13; // ebx - int v14; // ebx - int v15; // eax - bool v16; // zf - int v17; // ecx - int v18; // eax - int v19; // ecx - int v20; // eax - int v21; // ecx - int v22; // eax - int v23; // eax - int v24; // ecx - int v25; // eax - int v26; // ecx - int v27; // ebx - int v28; // edx - int v29; // eax - int v30; // ecx - int v31; // eax - int v32; // eax - int v33; // eax - int v34; // ecx - int v35; // eax - int v36; // ecx - int v37; // eax - int v38; // eax - int v39; // ecx - int v40; // eax - int v41; // ecx - signed int v42; // eax - int v43; // ecx - int v44; // eax - int v45; // eax - int v46; // eax - int v47; // eax - char v48; // al - char v49; // cl - char v50; // al - char v51; // al - char v52; // cl - int v53; // ecx - int *v54; // eax - int v55; // edx - int *v56; // ecx - char v57; // al - char v58; // cl - signed int v59; // edx - char v60; // al - char v61; // cl - char v62; // al - char v63; // al - char v64; // cl - char v65; // al - char v66; // al - char v67; // cl - char v68; // al - char v69; // al - char v70; // al - char v71; // al - char v72; // al - char v73; // cl - char v74; // al - char v75; // al - int v76; // [esp+Ch] [ebp-18h] - char *v77; // [esp+Ch] [ebp-18h] - int v78; // [esp+10h] [ebp-14h] - signed int v79; // [esp+14h] [ebp-10h] - signed int v80; // [esp+18h] [ebp-Ch] - int v81; // [esp+1Ch] [ebp-8h] - int v82; // [esp+1Ch] [ebp-8h] - signed int v83; // [esp+20h] [ebp-4h] + int v0; // esi + signed int v1; // edi + int v2; // esi + int v3; // edi + int v4; // edx + int v5; // ebx + int v6; // edi + int v7; // eax + int v8; // esi + BOOL v9; // eax + int v10; // ecx + int v11; // edx + int v12; // ecx + int v13; // ebx + int v14; // ebx + int v15; // eax + bool v16; // zf + int v17; // ecx + int v18; // eax + int v19; // ecx + int v20; // eax + int v21; // ecx + int v22; // eax + int v23; // eax + int v24; // ecx + int v25; // eax + int v26; // ecx + int v27; // ebx + int v28; // edx + int v29; // eax + int v30; // ecx + int v31; // eax + int v32; // eax + int v33; // eax + int v34; // ecx + int v35; // eax + int v36; // ecx + int v37; // eax + int v38; // eax + int v39; // ecx + int v40; // eax + int v41; // ecx + signed int v42; // eax + int v43; // ecx + int v44; // eax + int v45; // eax + int v46; // eax + int v47; // eax + char v48; // al + char v49; // cl + char v50; // al + char v51; // al + char v52; // cl + int v53; // ecx + int *v54; // eax + int v55; // edx + int *v56; // ecx + char v57; // al + char v58; // cl + signed int v59; // edx + char v60; // al + char v61; // cl + char v62; // al + char v63; // al + char v64; // cl + char v65; // al + char v66; // al + char v67; // cl + char v68; // al + char v69; // al + char v70; // al + char v71; // al + char v72; // al + char v73; // cl + char v74; // al + char v75; // al + int v76; // [esp+Ch] [ebp-18h] + char *v77; // [esp+Ch] [ebp-18h] + int v78; // [esp+10h] [ebp-14h] + signed int v79; // [esp+14h] [ebp-10h] + signed int v80; // [esp+18h] [ebp-Ch] + int v81; // [esp+1Ch] [ebp-8h] + int v82; // [esp+1Ch] [ebp-8h] + signed int v83; // [esp+20h] [ebp-4h] - v0 = MouseX; - v1 = MouseY; - if (chrflag || questlog) { - if (MouseX >= 160) { - v0 = MouseX - 160; - goto LABEL_10; - } - goto LABEL_9; - } - if (invflag || sbookflag) { - if (MouseX <= 320) { - v0 = MouseX + 160; - goto LABEL_10; - } - LABEL_9: - v0 = 0; - } + v0 = MouseX; + v1 = MouseY; + if (chrflag || questlog) { + if (MouseX >= 160) { + v0 = MouseX - 160; + goto LABEL_10; + } + goto LABEL_9; + } + if (invflag || sbookflag) { + if (MouseX <= 320) { + v0 = MouseX + 160; + goto LABEL_10; + } + LABEL_9: + v0 = 0; + } LABEL_10: - if (MouseY > 351 && track_isscrolling()) - v1 = 351; - if (!zoomflag) { - v0 >>= 1; - v1 >>= 1; - } - v2 = v0 - ScrollInfo._sxoff; - v3 = v1 - ScrollInfo._syoff; - if (ScrollInfo._sdir) { - v2 += ((plr[myplr]._pVar6 + plr[myplr]._pxvel) >> 8) - (plr[myplr]._pVar6 >> 8); - v3 += ((plr[myplr]._pVar7 + plr[myplr]._pyvel) >> 8) - (plr[myplr]._pVar7 >> 8); - } - if (v2 < 0) - v2 = 0; - if (v2 >= 640) - v2 = 640; - if (v3 < 0) - v3 = 0; - if (v3 >= 480) - v3 = 480; - v4 = v3 >> 5; - v5 = v3 & 0x1F; - v76 = v2 & 0x3F; - v6 = (v2 >> 6) + (v3 >> 5) + ViewX - (zoomflag != 0 ? 10 : 5); - v7 = v76 >> 1; - v8 = v4 + ViewY - (v2 >> 6); - if (v5> 1) - --v8; - v9 = v5 >= 32 - v7; - if (v9) - ++v6; - if (v6 < 0) - v6 = 0; - if (v6 >= 112) - v6 = 111; - if (v8 < 0) - v8 = 0; - if (v8 >= 112) - v8 = 111; - if (v5 >= v76 >> 1) { - if (!v9) - goto LABEL_49; - goto LABEL_48; - } - if (!v9) { - LABEL_48: - if (v76 < 32) - goto LABEL_39; - LABEL_49: - v83 = 0; - goto LABEL_40; - } + if (MouseY > 351 && track_isscrolling()) + v1 = 351; + if (!zoomflag) { + v0 >>= 1; + v1 >>= 1; + } + v2 = v0 - ScrollInfo._sxoff; + v3 = v1 - ScrollInfo._syoff; + if (ScrollInfo._sdir) { + v2 += ((plr[myplr]._pVar6 + plr[myplr]._pxvel) >> 8) - (plr[myplr]._pVar6 >> 8); + v3 += ((plr[myplr]._pVar7 + plr[myplr]._pyvel) >> 8) - (plr[myplr]._pVar7 >> 8); + } + if (v2 < 0) + v2 = 0; + if (v2 >= 640) + v2 = 640; + if (v3 < 0) + v3 = 0; + if (v3 >= 480) + v3 = 480; + v4 = v3 >> 5; + v5 = v3 & 0x1F; + v76 = v2 & 0x3F; + v6 = (v2 >> 6) + (v3 >> 5) + ViewX - (zoomflag != 0 ? 10 : 5); + v7 = v76 >> 1; + v8 = v4 + ViewY - (v2 >> 6); + if (v5> 1) + --v8; + v9 = v5 >= 32 - v7; + if (v9) + ++v6; + if (v6 < 0) + v6 = 0; + if (v6 >= 112) + v6 = 111; + if (v8 < 0) + v8 = 0; + if (v8 >= 112) + v8 = 111; + if (v5 >= v76 >> 1) { + if (!v9) + goto LABEL_49; + goto LABEL_48; + } + if (!v9) { + LABEL_48: + if (v76 < 32) + goto LABEL_39; + LABEL_49: + v83 = 0; + goto LABEL_40; + } LABEL_39: - v83 = 1; + v83 = 1; LABEL_40: - v10 = pcursmonst; - pcursobj = -1; - pcursitem = -1; - v11 = -1; - dword_4B8CCC = pcursmonst; - pcursmonst = -1; - if (pcursinvitem != -1) - drawsbarflag = 1; - pcursinvitem = -1; - pcursplr = -1; - v16 = plr[myplr]._pInvincible == 0; - uitemflag = 0; - panelflag = 0; - trigflag[3] = 0; - if (!v16) - return; - if (pcurs >= CURSOR_FIRSTITEM || spselflag) { - cursmx = v6; - cursmy = v8; - return; - } - if (MouseY > 352) { - CheckPanelInfo(); - return; - } - if (doomflag) - return; - if (invflag && MouseX > 320) { - pcursinvitem = CheckInvHLight(); - return; - } - if (sbookflag && MouseX > 320 || (chrflag || questlog) && MouseX < 320) - return; - if (leveltype == DTYPE_TOWN) { - if (v83) { - v27 = 112 * v6; - v78 = 112 * v6; - v43 = 112 * v6 + v8; - v45 = dMonster[0][v43 + 1]; - if (v45 <= 0) - goto LABEL_200; - v11 = v45 - 1; - cursmx = v6; - cursmy = v8 + 1; - } else { - v27 = 112 * v6; - v78 = 112 * v6; - v43 = 112 * v6 + v8; - v44 = dMonster[1][v43]; - if (v44 <= 0) - goto LABEL_200; - v11 = v44 - 1; - cursmx = v6 + 1; - cursmy = v8; - } - pcursmonst = v11; - LABEL_200: - v46 = dMonster[0][v43]; - if (v46 > 0) { - v11 = v46 - 1; - cursmx = v6; - pcursmonst = v46 - 1; - cursmy = v8; - } - v47 = dMonster[1][v43 + 1]; - if (v47 > 0) { - v11 = v47 - 1; - cursmx = v6 + 1; - pcursmonst = v47 - 1; - cursmy = v8 + 1; - } - if (!towner[v11]._tSelFlag) - LABEL_205: - pcursmonst = -1; - LABEL_206: - if (pcursmonst != -1) { - LABEL_305: - v59 = pcursmonst; - goto LABEL_306; - } - LABEL_207: - if (v83) { - v50 = dPlayer[0][v27 + 1 + v8]; - if (v50) { - v49 = v50 <= 0 ? -1 - v50 : v50 - 1; - if (v49 != myplr && plr[v49]._pHitPoints) { - cursmx = v6; - cursmy = v8 + 1; - goto LABEL_222; - } - } - } else { - v48 = dPlayer[1][v27 + v8]; - if (v48) { - v49 = v48 <= 0 ? -1 - v48 : v48 - 1; - if (v49 != myplr && plr[v49]._pHitPoints) { - cursmy = v8; - cursmx = v6 + 1; - LABEL_222: - pcursplr = v49; - goto LABEL_223; - } - } - } - LABEL_223: - v51 = dPlayer[0][v27 + v8]; - if (v51) { - v52 = v51 <= 0 ? -1 - v51 : v51 - 1; - if (v52 != myplr) { - cursmx = v6; - cursmy = v8; - pcursplr = v52; - } - } - if (dFlags[0][v27 + v8] & DFLAG_DEAD_PLAYER) { - v53 = 0; - v54 = &plr[0].WorldY; - do { - if (*(v54 - 1) == v6 && *v54 == v8 && v53 != myplr) { - cursmx = v6; - cursmy = v8; - pcursplr = v53; - } - v54 += 5430; - ++v53; - } while ((signed int)v54 < (signed int)&plr[4].WorldY); - } - if (pcurs == CURSOR_RESURRECT) { - v79 = -1; - v77 = &dFlags[-1][v27 + v8]; /* v77 = &nBlockTable[v27 + 1944 + v8]; check */ - do { - v80 = -1; - v55 = v8 - 1; - do { - if (v77[v80] & DFLAG_DEAD_PLAYER) { - v82 = 0; - v56 = &plr[0].WorldY; - do { - if (*(v56 - 1) == v6 + v79 && *v56 == v55 && v82 != myplr) { - cursmx = v6 + v79; - cursmy = v55; - pcursplr = v82; - } - ++v82; - v56 += 5430; - } while ((signed int)v56 < (signed int)&plr[4].WorldY); - } - ++v80; - ++v55; - } while (v80 < 2); - ++v79; - v77 += 112; - } while (v79 < 2); - v27 = v78; - } - v57 = dPlayer[1][v27 + 1 + v8]; - if (v57) { - v58 = v57 <= 0 ? -1 - v57 : v57 - 1; - if (v58 != myplr && plr[v58]._pHitPoints) { - pcursplr = v58; - cursmx = v6 + 1; - cursmy = v8 + 1; - } - } - v59 = pcursmonst; - if (pcursmonst != -1) { - LABEL_285: - if (pcursplr == -1) - goto LABEL_286; - LABEL_306: - if (pcurs == CURSOR_IDENTIFY) { - pcursobj = -1; - v59 = -1; - pcursitem = -1; - pcursmonst = -1; - cursmx = v6; - cursmy = v8; - } - if (v59 != -1) { - if (monster[v59]._mFlags & 0x20) - pcursmonst = -1; - } - return; - } - if (pcursplr != pcursmonst) /* check in future */ - goto LABEL_306; - if (v83) { - v62 = dObject[0][v27 + 1 + v8]; - if (!v62) - goto LABEL_272; - v61 = v62 <= 0 ? -1 - v62 : v62 - 1; - if (object[v61]._oSelFlag < 2) - goto LABEL_272; - cursmx = v6; - cursmy = v8 + 1; - } else { - v60 = dObject[1][v27 + v8]; - if (!v60) - goto LABEL_272; - v61 = v60 <= 0 ? -1 - v60 : v60 - 1; - if (object[v61]._oSelFlag < 2) - goto LABEL_272; - cursmy = v8; - cursmx = v6 + 1; - } - pcursobj = v61; - LABEL_272: - v63 = dObject[0][v27 + v8]; - if (v63) { - v64 = v63 <= 0 ? -1 - v63 : v63 - 1; - v65 = object[v64]._oSelFlag; - if (v65 == 1 || v65 == 3) { - cursmx = v6; - cursmy = v8; - pcursobj = v64; - } - } - v66 = dObject[1][v27 + 1 + v8]; - if (!v66 || (v66 <= 0 ? (v67 = -1 - v66) : (v67 = v66 - 1), object[v67]._oSelFlag < 2)) { - LABEL_286: - if (pcursobj != -1 || pcursmonst != -1) - goto LABEL_306; - if (v83) { - v70 = dItem[0][v27 + 1 + v8]; - if (v70 <= 0) - goto LABEL_296; - v69 = v70 - 1; - if (item[v69]._iSelFlag < 2) - goto LABEL_296; - cursmx = v6; - cursmy = v8 + 1; - } else { - v68 = dItem[1][v27 + v8]; - if (v68 <= 0) - goto LABEL_296; - v69 = v68 - 1; - if (item[v69]._iSelFlag < 2) - goto LABEL_296; - cursmy = v8; - cursmx = v6 + 1; - } - pcursitem = v69; - LABEL_296: - v71 = dItem[0][v27 + v8]; - if (v71 > 0) { - v72 = v71 - 1; - v73 = item[v72]._iSelFlag; - if (v73 == 1 || v73 == 3) { - cursmx = v6; - cursmy = v8; - pcursitem = v72; - } - } - v74 = dItem[1][v27 + 1 + v8]; - if (v74 > 0) { - v75 = v74 - 1; - if (item[v75]._iSelFlag >= 2) { - pcursitem = v75; - cursmx = v6 + 1; - cursmy = v8 + 1; - } - } - if (pcursitem != -1) - goto LABEL_306; - cursmx = v6; - cursmy = v8; - CheckTrigForce(); - CheckTown(); - CheckRportal(); - goto LABEL_305; - } - pcursobj = v67; - cursmx = v6 + 1; - cursmy = v8 + 1; - goto LABEL_285; - } - if (v10 == -1) - goto LABEL_128; - v12 = 112 * v6 + v8; - v81 = 112 * v6 + v8; - v13 = 112 * v6 + v8; - if (v83) { - v14 = v13; - v15 = dMonster[1][v14 + 2]; - if (!v15) - goto LABEL_74; - v16 = (dFlags[1][v12 + 2] & DFLAG_LIT) == 0; - } else { - v14 = v13; - v15 = dMonster[2][v14 + 1]; - if (!v15) - goto LABEL_74; - v16 = (dFlags[2][v12 + 1] & DFLAG_LIT) == 0; - } - if (!v16) { - v17 = v15 <= 0 ? -1 - v15 : v15 - 1; - if (v17 == dword_4B8CCC - && monster[v17]._mhitpoints >> 6 > 0 - && monster[v17].MData->mSelFlag & 4) { - v11 = v17; - cursmx = v6 + 1; - cursmy = v8 + 2; - pcursmonst = v17; - } - } + v10 = pcursmonst; + pcursobj = -1; + pcursitem = -1; + v11 = -1; + dword_4B8CCC = pcursmonst; + pcursmonst = -1; + if (pcursinvitem != -1) + drawsbarflag = 1; + pcursinvitem = -1; + pcursplr = -1; + v16 = plr[myplr]._pInvincible == 0; + uitemflag = 0; + panelflag = 0; + trigflag[3] = 0; + if (!v16) + return; + if (pcurs >= CURSOR_FIRSTITEM || spselflag) { + cursmx = v6; + cursmy = v8; + return; + } + if (MouseY > 352) { + CheckPanelInfo(); + return; + } + if (doomflag) + return; + if (invflag && MouseX > 320) { + pcursinvitem = CheckInvHLight(); + return; + } + if (sbookflag && MouseX > 320 || (chrflag || questlog) && MouseX < 320) + return; + if (leveltype == DTYPE_TOWN) { + if (v83) { + v27 = 112 * v6; + v78 = 112 * v6; + v43 = 112 * v6 + v8; + v45 = dMonster[0][v43 + 1]; + if (v45 <= 0) + goto LABEL_200; + v11 = v45 - 1; + cursmx = v6; + cursmy = v8 + 1; + } else { + v27 = 112 * v6; + v78 = 112 * v6; + v43 = 112 * v6 + v8; + v44 = dMonster[1][v43]; + if (v44 <= 0) + goto LABEL_200; + v11 = v44 - 1; + cursmx = v6 + 1; + cursmy = v8; + } + pcursmonst = v11; + LABEL_200: + v46 = dMonster[0][v43]; + if (v46 > 0) { + v11 = v46 - 1; + cursmx = v6; + pcursmonst = v46 - 1; + cursmy = v8; + } + v47 = dMonster[1][v43 + 1]; + if (v47 > 0) { + v11 = v47 - 1; + cursmx = v6 + 1; + pcursmonst = v47 - 1; + cursmy = v8 + 1; + } + if (!towner[v11]._tSelFlag) + LABEL_205: + pcursmonst = -1; + LABEL_206: + if (pcursmonst != -1) { + LABEL_305: + v59 = pcursmonst; + goto LABEL_306; + } + LABEL_207: + if (v83) { + v50 = dPlayer[0][v27 + 1 + v8]; + if (v50) { + v49 = v50 <= 0 ? -1 - v50 : v50 - 1; + if (v49 != myplr && plr[v49]._pHitPoints) { + cursmx = v6; + cursmy = v8 + 1; + goto LABEL_222; + } + } + } else { + v48 = dPlayer[1][v27 + v8]; + if (v48) { + v49 = v48 <= 0 ? -1 - v48 : v48 - 1; + if (v49 != myplr && plr[v49]._pHitPoints) { + cursmy = v8; + cursmx = v6 + 1; + LABEL_222: + pcursplr = v49; + goto LABEL_223; + } + } + } + LABEL_223: + v51 = dPlayer[0][v27 + v8]; + if (v51) { + v52 = v51 <= 0 ? -1 - v51 : v51 - 1; + if (v52 != myplr) { + cursmx = v6; + cursmy = v8; + pcursplr = v52; + } + } + if (dFlags[0][v27 + v8] & DFLAG_DEAD_PLAYER) { + v53 = 0; + v54 = &plr[0].WorldY; + do { + if (*(v54 - 1) == v6 && *v54 == v8 && v53 != myplr) { + cursmx = v6; + cursmy = v8; + pcursplr = v53; + } + v54 += 5430; + ++v53; + } while ((signed int)v54 < (signed int)&plr[4].WorldY); + } + if (pcurs == CURSOR_RESURRECT) { + v79 = -1; + v77 = &dFlags[-1][v27 + v8]; /* v77 = &nBlockTable[v27 + 1944 + v8]; check */ + do { + v80 = -1; + v55 = v8 - 1; + do { + if (v77[v80] & DFLAG_DEAD_PLAYER) { + v82 = 0; + v56 = &plr[0].WorldY; + do { + if (*(v56 - 1) == v6 + v79 && *v56 == v55 && v82 != myplr) { + cursmx = v6 + v79; + cursmy = v55; + pcursplr = v82; + } + ++v82; + v56 += 5430; + } while ((signed int)v56 < (signed int)&plr[4].WorldY); + } + ++v80; + ++v55; + } while (v80 < 2); + ++v79; + v77 += 112; + } while (v79 < 2); + v27 = v78; + } + v57 = dPlayer[1][v27 + 1 + v8]; + if (v57) { + v58 = v57 <= 0 ? -1 - v57 : v57 - 1; + if (v58 != myplr && plr[v58]._pHitPoints) { + pcursplr = v58; + cursmx = v6 + 1; + cursmy = v8 + 1; + } + } + v59 = pcursmonst; + if (pcursmonst != -1) { + LABEL_285: + if (pcursplr == -1) + goto LABEL_286; + LABEL_306: + if (pcurs == CURSOR_IDENTIFY) { + pcursobj = -1; + v59 = -1; + pcursitem = -1; + pcursmonst = -1; + cursmx = v6; + cursmy = v8; + } + if (v59 != -1) { + if (monster[v59]._mFlags & 0x20) + pcursmonst = -1; + } + return; + } + if (pcursplr != pcursmonst) /* check in future */ + goto LABEL_306; + if (v83) { + v62 = dObject[0][v27 + 1 + v8]; + if (!v62) + goto LABEL_272; + v61 = v62 <= 0 ? -1 - v62 : v62 - 1; + if (object[v61]._oSelFlag < 2) + goto LABEL_272; + cursmx = v6; + cursmy = v8 + 1; + } else { + v60 = dObject[1][v27 + v8]; + if (!v60) + goto LABEL_272; + v61 = v60 <= 0 ? -1 - v60 : v60 - 1; + if (object[v61]._oSelFlag < 2) + goto LABEL_272; + cursmy = v8; + cursmx = v6 + 1; + } + pcursobj = v61; + LABEL_272: + v63 = dObject[0][v27 + v8]; + if (v63) { + v64 = v63 <= 0 ? -1 - v63 : v63 - 1; + v65 = object[v64]._oSelFlag; + if (v65 == 1 || v65 == 3) { + cursmx = v6; + cursmy = v8; + pcursobj = v64; + } + } + v66 = dObject[1][v27 + 1 + v8]; + if (!v66 || (v66 <= 0 ? (v67 = -1 - v66) : (v67 = v66 - 1), object[v67]._oSelFlag < 2)) { + LABEL_286: + if (pcursobj != -1 || pcursmonst != -1) + goto LABEL_306; + if (v83) { + v70 = dItem[0][v27 + 1 + v8]; + if (v70 <= 0) + goto LABEL_296; + v69 = v70 - 1; + if (item[v69]._iSelFlag < 2) + goto LABEL_296; + cursmx = v6; + cursmy = v8 + 1; + } else { + v68 = dItem[1][v27 + v8]; + if (v68 <= 0) + goto LABEL_296; + v69 = v68 - 1; + if (item[v69]._iSelFlag < 2) + goto LABEL_296; + cursmy = v8; + cursmx = v6 + 1; + } + pcursitem = v69; + LABEL_296: + v71 = dItem[0][v27 + v8]; + if (v71 > 0) { + v72 = v71 - 1; + v73 = item[v72]._iSelFlag; + if (v73 == 1 || v73 == 3) { + cursmx = v6; + cursmy = v8; + pcursitem = v72; + } + } + v74 = dItem[1][v27 + 1 + v8]; + if (v74 > 0) { + v75 = v74 - 1; + if (item[v75]._iSelFlag >= 2) { + pcursitem = v75; + cursmx = v6 + 1; + cursmy = v8 + 1; + } + } + if (pcursitem != -1) + goto LABEL_306; + cursmx = v6; + cursmy = v8; + CheckTrigForce(); + CheckTown(); + CheckRportal(); + goto LABEL_305; + } + pcursobj = v67; + cursmx = v6 + 1; + cursmy = v8 + 1; + goto LABEL_285; + } + if (v10 == -1) + goto LABEL_128; + v12 = 112 * v6 + v8; + v81 = 112 * v6 + v8; + v13 = 112 * v6 + v8; + if (v83) { + v14 = v13; + v15 = dMonster[1][v14 + 2]; + if (!v15) + goto LABEL_74; + v16 = (dFlags[1][v12 + 2] & DFLAG_LIT) == 0; + } else { + v14 = v13; + v15 = dMonster[2][v14 + 1]; + if (!v15) + goto LABEL_74; + v16 = (dFlags[2][v12 + 1] & DFLAG_LIT) == 0; + } + if (!v16) { + v17 = v15 <= 0 ? -1 - v15 : v15 - 1; + if (v17 == dword_4B8CCC + && monster[v17]._mhitpoints >> 6 > 0 + && monster[v17].MData->mSelFlag & 4) { + v11 = v17; + cursmx = v6 + 1; + cursmy = v8 + 2; + pcursmonst = v17; + } + } LABEL_74: - v18 = dMonster[2][v14 + 2]; - if (v18 && dFlags[2][v81 + 2] & DFLAG_LIT) { - v19 = v18 <= 0 ? -1 - v18 : v18 - 1; - if (v19 == dword_4B8CCC - && monster[v19]._mhitpoints >> 6 > 0 - && monster[v19].MData->mSelFlag & 4) { - v11 = v19; - cursmx = v6 + 2; - cursmy = v8 + 2; - pcursmonst = v19; - } - } - if (v83) { - v22 = dMonster[0][v14 + 1]; - if (v22 && dFlags[0][v81 + 1] & DFLAG_LIT) { - v21 = v22 <= 0 ? -1 - v22 : v22 - 1; - if (v21 == dword_4B8CCC - && monster[v21]._mhitpoints >> 6 > 0 - && monster[v21].MData->mSelFlag & 2) { - cursmx = v6; - cursmy = v8 + 1; - goto LABEL_102; - } - } - } else { - v20 = dMonster[1][v14]; - if (v20 && dFlags[1][v81] & DFLAG_LIT) { - v21 = v20 <= 0 ? -1 - v20 : v20 - 1; - if (v21 == dword_4B8CCC - && monster[v21]._mhitpoints >> 6 > 0 - && monster[v21].MData->mSelFlag & 2) { - cursmy = v8; - cursmx = v6 + 1; - LABEL_102: - v11 = v21; - pcursmonst = v21; - goto LABEL_103; - } - } - } + v18 = dMonster[2][v14 + 2]; + if (v18 && dFlags[2][v81 + 2] & DFLAG_LIT) { + v19 = v18 <= 0 ? -1 - v18 : v18 - 1; + if (v19 == dword_4B8CCC + && monster[v19]._mhitpoints >> 6 > 0 + && monster[v19].MData->mSelFlag & 4) { + v11 = v19; + cursmx = v6 + 2; + cursmy = v8 + 2; + pcursmonst = v19; + } + } + if (v83) { + v22 = dMonster[0][v14 + 1]; + if (v22 && dFlags[0][v81 + 1] & DFLAG_LIT) { + v21 = v22 <= 0 ? -1 - v22 : v22 - 1; + if (v21 == dword_4B8CCC + && monster[v21]._mhitpoints >> 6 > 0 + && monster[v21].MData->mSelFlag & 2) { + cursmx = v6; + cursmy = v8 + 1; + goto LABEL_102; + } + } + } else { + v20 = dMonster[1][v14]; + if (v20 && dFlags[1][v81] & DFLAG_LIT) { + v21 = v20 <= 0 ? -1 - v20 : v20 - 1; + if (v21 == dword_4B8CCC + && monster[v21]._mhitpoints >> 6 > 0 + && monster[v21].MData->mSelFlag & 2) { + cursmy = v8; + cursmx = v6 + 1; + LABEL_102: + v11 = v21; + pcursmonst = v21; + goto LABEL_103; + } + } + } LABEL_103: - v23 = dMonster[0][v14]; - if (v23 && dFlags[0][v81] & DFLAG_LIT) { - v24 = v23 <= 0 ? -1 - v23 : v23 - 1; - if (v24 == dword_4B8CCC - && monster[v24]._mhitpoints >> 6 > 0 - && monster[v24].MData->mSelFlag & 1) { - v11 = v24; - cursmx = v6; - cursmy = v8; - pcursmonst = v24; - } - } - v25 = dMonster[1][v14 + 1]; - if (v25 && dFlags[1][v81 + 1] & DFLAG_LIT) { - v26 = v25 <= 0 ? -1 - v25 : v25 - 1; - if (v26 == dword_4B8CCC - && monster[v26]._mhitpoints >> 6 > 0 - && monster[v26].MData->mSelFlag & 2) { - v11 = v26; - cursmx = v6 + 1; - cursmy = v8 + 1; - pcursmonst = v26; - } - } - if (v11 == -1) - goto LABEL_128; - if (monster[v11]._mFlags & 1) { - v11 = -1; - cursmx = v6; - pcursmonst = -1; - cursmy = v8; - } - if (v11 == -1) - goto LABEL_128; - if (monster[v11]._mFlags & 0x20) { - v11 = -1; - pcursmonst = -1; - } - if (v11 == -1) { - LABEL_128: - v27 = 112 * v6; - v78 = 112 * v6; - if (v83) { - v28 = v27 + v8; - v32 = dMonster[1][v28 + 2]; - if (v32 && dFlags[1][v27 + 2 + v8] & DFLAG_LIT) { - v30 = v32 <= 0 ? -1 - v32 : v32 - 1; - if (monster[v30]._mhitpoints >> 6 > 0 && monster[v30].MData->mSelFlag & 4) { - cursmx = v6 + 1; - v31 = v8 + 2; - goto LABEL_145; - } - } - } else { - v28 = v27 + v8; - v29 = dMonster[2][v28 + 1]; - if (v29 && dFlags[2][v27 + 1 + v8] & DFLAG_LIT) { - v30 = v29 <= 0 ? -1 - v29 : v29 - 1; - if (monster[v30]._mhitpoints >> 6 > 0 && monster[v30].MData->mSelFlag & 4) { - cursmx = v6 + 2; - v31 = v8 + 1; - LABEL_145: - cursmy = v31; - pcursmonst = v30; - goto LABEL_146; - } - } - } - LABEL_146: - v33 = dMonster[2][v28 + 2]; - if (v33 && dFlags[2][v27 + 2 + v8] & DFLAG_LIT) { - v34 = v33 <= 0 ? -1 - v33 : v33 - 1; - if (monster[v34]._mhitpoints >> 6 > 0 && monster[v34].MData->mSelFlag & 4) { - pcursmonst = v34; - cursmx = v6 + 2; - cursmy = v8 + 2; - } - } - if (v83) { - v37 = dMonster[0][v28 + 1]; - if (v37 && dFlags[0][v27 + 1 + v8] & DFLAG_LIT) { - v36 = v37 <= 0 ? -1 - v37 : v37 - 1; - if (monster[v36]._mhitpoints >> 6 > 0 && monster[v36].MData->mSelFlag & 2) { - cursmx = v6; - cursmy = v8 + 1; - goto LABEL_171; - } - } - } else { - v35 = dMonster[1][v28]; - if (v35 && dFlags[1][v27 + v8] & DFLAG_LIT) { - v36 = v35 <= 0 ? -1 - v35 : v35 - 1; - if (monster[v36]._mhitpoints >> 6 > 0 && monster[v36].MData->mSelFlag & 2) { - cursmy = v8; - cursmx = v6 + 1; - LABEL_171: - pcursmonst = v36; - goto LABEL_172; - } - } - } - LABEL_172: - v38 = dMonster[0][v28]; - if (v38 && dFlags[0][v27 + v8] & DFLAG_LIT) { - v39 = v38 <= 0 ? -1 - v38 : v38 - 1; - if (monster[v39]._mhitpoints >> 6 > 0 && monster[v39].MData->mSelFlag & 1) { - cursmx = v6; - cursmy = v8; - pcursmonst = v39; - } - } - v40 = dMonster[1][v28 + 1]; - if (v40 && dFlags[1][v27 + 1 + v8] & DFLAG_LIT) { - v41 = v40 <= 0 ? -1 - v40 : v40 - 1; - if (monster[v41]._mhitpoints >> 6 > 0 && monster[v41].MData->mSelFlag & 2) { - pcursmonst = v41; - cursmx = v6 + 1; - cursmy = v8 + 1; - } - } - v42 = pcursmonst; - if (pcursmonst == -1) - goto LABEL_207; - if (monster[pcursmonst]._mFlags & 1) { - v42 = -1; - cursmx = v6; - pcursmonst = -1; - cursmy = v8; - } - if (v42 == -1) - goto LABEL_207; - if (monster[v42]._mFlags & 0x20) - goto LABEL_205; - goto LABEL_206; - } + v23 = dMonster[0][v14]; + if (v23 && dFlags[0][v81] & DFLAG_LIT) { + v24 = v23 <= 0 ? -1 - v23 : v23 - 1; + if (v24 == dword_4B8CCC + && monster[v24]._mhitpoints >> 6 > 0 + && monster[v24].MData->mSelFlag & 1) { + v11 = v24; + cursmx = v6; + cursmy = v8; + pcursmonst = v24; + } + } + v25 = dMonster[1][v14 + 1]; + if (v25 && dFlags[1][v81 + 1] & DFLAG_LIT) { + v26 = v25 <= 0 ? -1 - v25 : v25 - 1; + if (v26 == dword_4B8CCC + && monster[v26]._mhitpoints >> 6 > 0 + && monster[v26].MData->mSelFlag & 2) { + v11 = v26; + cursmx = v6 + 1; + cursmy = v8 + 1; + pcursmonst = v26; + } + } + if (v11 == -1) + goto LABEL_128; + if (monster[v11]._mFlags & 1) { + v11 = -1; + cursmx = v6; + pcursmonst = -1; + cursmy = v8; + } + if (v11 == -1) + goto LABEL_128; + if (monster[v11]._mFlags & 0x20) { + v11 = -1; + pcursmonst = -1; + } + if (v11 == -1) { + LABEL_128: + v27 = 112 * v6; + v78 = 112 * v6; + if (v83) { + v28 = v27 + v8; + v32 = dMonster[1][v28 + 2]; + if (v32 && dFlags[1][v27 + 2 + v8] & DFLAG_LIT) { + v30 = v32 <= 0 ? -1 - v32 : v32 - 1; + if (monster[v30]._mhitpoints >> 6 > 0 && monster[v30].MData->mSelFlag & 4) { + cursmx = v6 + 1; + v31 = v8 + 2; + goto LABEL_145; + } + } + } else { + v28 = v27 + v8; + v29 = dMonster[2][v28 + 1]; + if (v29 && dFlags[2][v27 + 1 + v8] & DFLAG_LIT) { + v30 = v29 <= 0 ? -1 - v29 : v29 - 1; + if (monster[v30]._mhitpoints >> 6 > 0 && monster[v30].MData->mSelFlag & 4) { + cursmx = v6 + 2; + v31 = v8 + 1; + LABEL_145: + cursmy = v31; + pcursmonst = v30; + goto LABEL_146; + } + } + } + LABEL_146: + v33 = dMonster[2][v28 + 2]; + if (v33 && dFlags[2][v27 + 2 + v8] & DFLAG_LIT) { + v34 = v33 <= 0 ? -1 - v33 : v33 - 1; + if (monster[v34]._mhitpoints >> 6 > 0 && monster[v34].MData->mSelFlag & 4) { + pcursmonst = v34; + cursmx = v6 + 2; + cursmy = v8 + 2; + } + } + if (v83) { + v37 = dMonster[0][v28 + 1]; + if (v37 && dFlags[0][v27 + 1 + v8] & DFLAG_LIT) { + v36 = v37 <= 0 ? -1 - v37 : v37 - 1; + if (monster[v36]._mhitpoints >> 6 > 0 && monster[v36].MData->mSelFlag & 2) { + cursmx = v6; + cursmy = v8 + 1; + goto LABEL_171; + } + } + } else { + v35 = dMonster[1][v28]; + if (v35 && dFlags[1][v27 + v8] & DFLAG_LIT) { + v36 = v35 <= 0 ? -1 - v35 : v35 - 1; + if (monster[v36]._mhitpoints >> 6 > 0 && monster[v36].MData->mSelFlag & 2) { + cursmy = v8; + cursmx = v6 + 1; + LABEL_171: + pcursmonst = v36; + goto LABEL_172; + } + } + } + LABEL_172: + v38 = dMonster[0][v28]; + if (v38 && dFlags[0][v27 + v8] & DFLAG_LIT) { + v39 = v38 <= 0 ? -1 - v38 : v38 - 1; + if (monster[v39]._mhitpoints >> 6 > 0 && monster[v39].MData->mSelFlag & 1) { + cursmx = v6; + cursmy = v8; + pcursmonst = v39; + } + } + v40 = dMonster[1][v28 + 1]; + if (v40 && dFlags[1][v27 + 1 + v8] & DFLAG_LIT) { + v41 = v40 <= 0 ? -1 - v40 : v40 - 1; + if (monster[v41]._mhitpoints >> 6 > 0 && monster[v41].MData->mSelFlag & 2) { + pcursmonst = v41; + cursmx = v6 + 1; + cursmy = v8 + 1; + } + } + v42 = pcursmonst; + if (pcursmonst == -1) + goto LABEL_207; + if (monster[pcursmonst]._mFlags & 1) { + v42 = -1; + cursmx = v6; + pcursmonst = -1; + cursmy = v8; + } + if (v42 == -1) + goto LABEL_207; + if (monster[v42]._mFlags & 0x20) + goto LABEL_205; + goto LABEL_206; + } } // 4B8968: using guessed type int sbookflag; // 4B8B84: using guessed type int panelflag; diff --git a/Source/dead.cpp b/Source/dead.cpp index fb6fb6b5..32fcadbc 100644 --- a/Source/dead.cpp +++ b/Source/dead.cpp @@ -10,77 +10,77 @@ int stonendx; void __cdecl InitDead() { - int i, j; - int mtypes[MAXMONSTERS]; - int idx; + int i, j; + int mtypes[MAXMONSTERS]; + int idx; - for (i = 0; i < MAXMONSTERS; i++) - mtypes[i] = 0; + for (i = 0; i < MAXMONSTERS; i++) + mtypes[i] = 0; - idx = 0; - for (i = 0; i < nummtypes; i++) { - if (!mtypes[Monsters[i].mtype]) { - for (j = 0; j < 8; j++) - dead[idx]._deadData[j] = Monsters[i].Anims[MA_DEATH].Data[j]; - dead[idx]._deadFrame = Monsters[i].Anims[MA_DEATH].Frames; - dead[idx]._deadWidth = Monsters[i].flags_1; - dead[idx]._deadWidth2 = Monsters[i].flags_2; - dead[idx]._deadtrans = 0; - Monsters[i].mdeadval = idx + 1; - mtypes[Monsters[i].mtype] = ++idx; - } - } + idx = 0; + for (i = 0; i < nummtypes; i++) { + if (!mtypes[Monsters[i].mtype]) { + for (j = 0; j < 8; j++) + dead[idx]._deadData[j] = Monsters[i].Anims[MA_DEATH].Data[j]; + dead[idx]._deadFrame = Monsters[i].Anims[MA_DEATH].Frames; + dead[idx]._deadWidth = Monsters[i].flags_1; + dead[idx]._deadWidth2 = Monsters[i].flags_2; + dead[idx]._deadtrans = 0; + Monsters[i].mdeadval = idx + 1; + mtypes[Monsters[i].mtype] = ++idx; + } + } - for (j = 0; j < 8; j++) - dead[idx]._deadData[j] = misfiledata[MFILE_BLODBUR].mAnimData[0]; - dead[idx]._deadtrans = 0; - dead[idx]._deadFrame = 8; - spurtndx = idx + 1; - dead[idx]._deadWidth = 128; - dead[idx]._deadWidth2 = 32; - idx = spurtndx; + for (j = 0; j < 8; j++) + dead[idx]._deadData[j] = misfiledata[MFILE_BLODBUR].mAnimData[0]; + dead[idx]._deadtrans = 0; + dead[idx]._deadFrame = 8; + spurtndx = idx + 1; + dead[idx]._deadWidth = 128; + dead[idx]._deadWidth2 = 32; + idx = spurtndx; - for (j = 0; j < 8; j++) - dead[idx]._deadData[j] = misfiledata[MFILE_SHATTER1].mAnimData[0]; - dead[idx]._deadtrans = 0; - dead[idx]._deadFrame = 12; - stonendx = idx + 1; - dead[idx]._deadWidth = 128; - dead[idx]._deadWidth2 = 32; - idx++; + for (j = 0; j < 8; j++) + dead[idx]._deadData[j] = misfiledata[MFILE_SHATTER1].mAnimData[0]; + dead[idx]._deadtrans = 0; + dead[idx]._deadFrame = 12; + stonendx = idx + 1; + dead[idx]._deadWidth = 128; + dead[idx]._deadWidth2 = 32; + idx++; - for (i = 0; i < nummonsters; i++) { - int ii = monstactive[i]; - if (monster[ii]._uniqtype) { - for (j = 0; j < 8; j++) - dead[idx]._deadData[j] = monster[ii].MType->Anims[MA_DEATH].Data[j]; - dead[idx]._deadFrame = monster[ii].MType->Anims[MA_DEATH].Frames; - dead[idx]._deadWidth = monster[ii].MType->flags_1; - dead[idx]._deadWidth2 = monster[ii].MType->flags_2; - dead[idx]._deadtrans = monster[ii]._uniqtrans + 4; - monster[ii]._udeadval = idx + 1; - idx++; - } - } + for (i = 0; i < nummonsters; i++) { + int ii = monstactive[i]; + if (monster[ii]._uniqtype) { + for (j = 0; j < 8; j++) + dead[idx]._deadData[j] = monster[ii].MType->Anims[MA_DEATH].Data[j]; + dead[idx]._deadFrame = monster[ii].MType->Anims[MA_DEATH].Frames; + dead[idx]._deadWidth = monster[ii].MType->flags_1; + dead[idx]._deadWidth2 = monster[ii].MType->flags_2; + dead[idx]._deadtrans = monster[ii]._uniqtrans + 4; + monster[ii]._udeadval = idx + 1; + idx++; + } + } } // 4B8CD8: using guessed type int spurtndx; void __fastcall AddDead(int dx, int dy, char dv, int ddir) { - dDead[dx][dy] = (dv & 0x1F) + (ddir << 5); + dDead[dx][dy] = (dv & 0x1F) + (ddir << 5); } void __cdecl SetDead() { - for (int i = 0; i < nummonsters; i++) { - int m = monstactive[i]; - if (monster[m]._uniqtype) { - for (int x = 0; x < MAXDUNX; x++) { - for (int y = 0; y < MAXDUNY; y++) { - if ((dDead[x][y] & 0x1F) == monster[m]._udeadval) - ChangeLightXY(monster[m].mlid, x, y); - } - } - } - } + for (int i = 0; i < nummonsters; i++) { + int m = monstactive[i]; + if (monster[m]._uniqtype) { + for (int x = 0; x < MAXDUNX; x++) { + for (int y = 0; y < MAXDUNY; y++) { + if ((dDead[x][y] & 0x1F) == monster[m]._udeadval) + ChangeLightXY(monster[m].mlid, x, y); + } + } + } + } } diff --git a/Source/debug.cpp b/Source/debug.cpp index f8f9096c..e9ec68e9 100644 --- a/Source/debug.cpp +++ b/Source/debug.cpp @@ -8,220 +8,220 @@ char dFlagDbg[NUMLEVELS][MAXDUNX][MAXDUNY]; void __cdecl LoadDebugGFX() { - if (visiondebug) - pSquareCel = LoadFileInMem("Data\\Square.CEL", 0); + if (visiondebug) + pSquareCel = LoadFileInMem("Data\\Square.CEL", 0); } // 525720: using guessed type int visiondebug; void __cdecl FreeDebugGFX() { - void *temp = pSquareCel; - pSquareCel = NULL; - mem_free_dbg(temp); + void *temp = pSquareCel; + pSquareCel = NULL; + mem_free_dbg(temp); } void __cdecl CheckDungeonClear() { - int i; - int j; + int i; + int j; - for (i = 0; i < MAXDUNX; i++) { - for (j = 0; j < MAXDUNY; j++) { - if (dMonster[i][j]) - TermMsg("Monsters not cleared"); - if (dPlayer[i][j]) - TermMsg("Players not cleared"); + for (i = 0; i < MAXDUNX; i++) { + for (j = 0; j < MAXDUNY; j++) { + if (dMonster[i][j]) + TermMsg("Monsters not cleared"); + if (dPlayer[i][j]) + TermMsg("Players not cleared"); - dMonsDbg[currlevel][i][j] = dFlags[i][j] & DFLAG_VISIBLE; - dFlagDbg[currlevel][i][j] = dFlags[i][j] & DFLAG_POPULATED; - } - } + dMonsDbg[currlevel][i][j] = dFlags[i][j] & DFLAG_VISIBLE; + dFlagDbg[currlevel][i][j] = dFlags[i][j] & DFLAG_POPULATED; + } + } } #ifdef _DEBUG void __cdecl GiveGoldCheat() { - int i; // esi - int ni; // ebp + int i; // esi + int ni; // ebp - for (i = 0; i < 40; i++) { - if (!plr[myplr].InvGrid[i]) { - ni = plr[myplr]._pNumInv++; - SetPlrHandItem(&plr[myplr].InvList[ni], IDI_GOLD); - GetPlrHandSeed(&plr[myplr].InvList[ni]); - plr[myplr].InvList[ni]._ivalue = 5000; - plr[myplr].InvList[ni]._iCurs = 6; - plr[myplr]._pGold += 5000; - plr[myplr].InvGrid[i] = plr[myplr]._pNumInv; - } - } + for (i = 0; i < 40; i++) { + if (!plr[myplr].InvGrid[i]) { + ni = plr[myplr]._pNumInv++; + SetPlrHandItem(&plr[myplr].InvList[ni], IDI_GOLD); + GetPlrHandSeed(&plr[myplr].InvList[ni]); + plr[myplr].InvList[ni]._ivalue = 5000; + plr[myplr].InvList[ni]._iCurs = 6; + plr[myplr]._pGold += 5000; + plr[myplr].InvGrid[i] = plr[myplr]._pNumInv; + } + } } void __cdecl StoresCheat() { - int i; // eax + int i; // eax - numpremium = 0; + numpremium = 0; - for (i = 0; i < 6; i++) - premiumitem[i]._itype = -1; + for (i = 0; i < 6; i++) + premiumitem[i]._itype = -1; - SpawnPremium(30); + SpawnPremium(30); - for (i = 0; i < 20; i++) - witchitem[i]._itype = -1; + for (i = 0; i < 20; i++) + witchitem[i]._itype = -1; - SpawnWitch(30); + SpawnWitch(30); } void __cdecl TakeGoldCheat() { - int i; // esi - char ig; // cl + int i; // esi + char ig; // cl - for (i = 0; i < 40; i++) { - ig = plr[myplr].InvGrid[i]; - if (ig > 0 && plr[myplr].InvList[ig - 1]._itype == ITYPE_GOLD) - RemoveInvItem(myplr, ig - 1); - } + for (i = 0; i < 40; i++) { + ig = plr[myplr].InvGrid[i]; + if (ig > 0 && plr[myplr].InvList[ig - 1]._itype == ITYPE_GOLD) + RemoveInvItem(myplr, ig - 1); + } - for (i = 0; i < MAXBELTITEMS; i++) { - if (plr[myplr].SpdList[i]._itype == ITYPE_GOLD) - plr[myplr].SpdList[i]._itype = -1; - } + for (i = 0; i < MAXBELTITEMS; i++) { + if (plr[myplr].SpdList[i]._itype == ITYPE_GOLD) + plr[myplr].SpdList[i]._itype = -1; + } - plr[myplr]._pGold = 0; + plr[myplr]._pGold = 0; } void __cdecl MaxSpellsCheat() { - for (int i = 1; i < MAX_SPELLS; i++) { - if (spelldata[i].sBookLvl != -1) { - plr[myplr]._pMemSpells |= (__int64)1 << (i - 1); - plr[myplr]._pSplLvl[i] = 10; - } - } + for (int i = 1; i < MAX_SPELLS; i++) { + if (spelldata[i].sBookLvl != -1) { + plr[myplr]._pMemSpells |= (__int64)1 << (i - 1); + plr[myplr]._pSplLvl[i] = 10; + } + } } void __fastcall SetSpellLevelCheat(char spl, int spllvl) { - plr[myplr]._pMemSpells |= (__int64)1 << (spl - 1); - plr[myplr]._pSplLvl[spl] = spllvl; + plr[myplr]._pMemSpells |= (__int64)1 << (spl - 1); + plr[myplr]._pSplLvl[spl] = spllvl; } void __cdecl SetAllSpellsCheat() { - SetSpellLevelCheat(SPL_FIREBOLT, 8); - SetSpellLevelCheat(SPL_CBOLT, 11); - SetSpellLevelCheat(SPL_HBOLT, 10); - SetSpellLevelCheat(SPL_HEAL, 7); - SetSpellLevelCheat(SPL_HEALOTHER, 5); - SetSpellLevelCheat(SPL_LIGHTNING, 9); - SetSpellLevelCheat(SPL_FIREWALL, 5); - SetSpellLevelCheat(SPL_TELEKINESIS, 3); - SetSpellLevelCheat(SPL_TOWN, 3); - SetSpellLevelCheat(SPL_FLASH, 3); - SetSpellLevelCheat(SPL_RNDTELEPORT, 2); - SetSpellLevelCheat(SPL_MANASHIELD, 2); - SetSpellLevelCheat(SPL_WAVE, 4); - SetSpellLevelCheat(SPL_FIREBALL, 3); - SetSpellLevelCheat(SPL_STONE, 1); - SetSpellLevelCheat(SPL_CHAIN, 1); - SetSpellLevelCheat(SPL_GUARDIAN, 4); - SetSpellLevelCheat(SPL_ELEMENT, 3); - SetSpellLevelCheat(SPL_NOVA, 1); - SetSpellLevelCheat(SPL_GOLEM, 2); - SetSpellLevelCheat(SPL_FLARE, 1); - SetSpellLevelCheat(SPL_BONESPIRIT, 1); + SetSpellLevelCheat(SPL_FIREBOLT, 8); + SetSpellLevelCheat(SPL_CBOLT, 11); + SetSpellLevelCheat(SPL_HBOLT, 10); + SetSpellLevelCheat(SPL_HEAL, 7); + SetSpellLevelCheat(SPL_HEALOTHER, 5); + SetSpellLevelCheat(SPL_LIGHTNING, 9); + SetSpellLevelCheat(SPL_FIREWALL, 5); + SetSpellLevelCheat(SPL_TELEKINESIS, 3); + SetSpellLevelCheat(SPL_TOWN, 3); + SetSpellLevelCheat(SPL_FLASH, 3); + SetSpellLevelCheat(SPL_RNDTELEPORT, 2); + SetSpellLevelCheat(SPL_MANASHIELD, 2); + SetSpellLevelCheat(SPL_WAVE, 4); + SetSpellLevelCheat(SPL_FIREBALL, 3); + SetSpellLevelCheat(SPL_STONE, 1); + SetSpellLevelCheat(SPL_CHAIN, 1); + SetSpellLevelCheat(SPL_GUARDIAN, 4); + SetSpellLevelCheat(SPL_ELEMENT, 3); + SetSpellLevelCheat(SPL_NOVA, 1); + SetSpellLevelCheat(SPL_GOLEM, 2); + SetSpellLevelCheat(SPL_FLARE, 1); + SetSpellLevelCheat(SPL_BONESPIRIT, 1); } void __fastcall PrintDebugPlayer(bool bNextPlayer) { - char dstr[128]; // [esp+Ch] [ebp-80h] + char dstr[128]; // [esp+Ch] [ebp-80h] - if (bNextPlayer) - dbgplr = ((_BYTE)dbgplr + 1) & 3; + if (bNextPlayer) + dbgplr = ((_BYTE)dbgplr + 1) & 3; - sprintf(dstr, "Plr %i : Active = %i", dbgplr, plr[dbgplr].plractive); - NetSendCmdString(1 << myplr, dstr); + sprintf(dstr, "Plr %i : Active = %i", dbgplr, plr[dbgplr].plractive); + NetSendCmdString(1 << myplr, dstr); - if (plr[dbgplr].plractive) { - sprintf(dstr, " Plr %i is %s", dbgplr, plr[dbgplr]._pName); - NetSendCmdString(1 << myplr, dstr); - sprintf(dstr, " Lvl = %i : Change = %i", plr[dbgplr].plrlevel, plr[dbgplr]._pLvlChanging); - NetSendCmdString(1 << myplr, dstr); - sprintf(dstr, " x = %i, y = %i : tx = %i, ty = %i", plr[dbgplr].WorldX, plr[dbgplr].WorldY, plr[dbgplr]._ptargx, plr[dbgplr]._ptargy); - NetSendCmdString(1 << myplr, dstr); - sprintf(dstr, " mode = %i : daction = %i : walk[0] = %i", plr[dbgplr]._pmode, plr[dbgplr].destAction, plr[dbgplr].walkpath[0]); - NetSendCmdString(1 << myplr, dstr); - sprintf(dstr, " inv = %i : hp = %i", plr[dbgplr]._pInvincible, plr[dbgplr]._pHitPoints); - NetSendCmdString(1 << myplr, dstr); - } + if (plr[dbgplr].plractive) { + sprintf(dstr, " Plr %i is %s", dbgplr, plr[dbgplr]._pName); + NetSendCmdString(1 << myplr, dstr); + sprintf(dstr, " Lvl = %i : Change = %i", plr[dbgplr].plrlevel, plr[dbgplr]._pLvlChanging); + NetSendCmdString(1 << myplr, dstr); + sprintf(dstr, " x = %i, y = %i : tx = %i, ty = %i", plr[dbgplr].WorldX, plr[dbgplr].WorldY, plr[dbgplr]._ptargx, plr[dbgplr]._ptargy); + NetSendCmdString(1 << myplr, dstr); + sprintf(dstr, " mode = %i : daction = %i : walk[0] = %i", plr[dbgplr]._pmode, plr[dbgplr].destAction, plr[dbgplr].walkpath[0]); + NetSendCmdString(1 << myplr, dstr); + sprintf(dstr, " inv = %i : hp = %i", plr[dbgplr]._pInvincible, plr[dbgplr]._pHitPoints); + NetSendCmdString(1 << myplr, dstr); + } } void __cdecl PrintDebugQuest() { - char dstr[128]; // [esp+0h] [ebp-80h] + char dstr[128]; // [esp+0h] [ebp-80h] - sprintf(dstr, "Quest %i : Active = %i, Var1 = %i", dbgqst, quests[dbgqst]._qactive, quests[dbgqst]._qvar1); - NetSendCmdString(1 << myplr, dstr); - if (++dbgqst == MAXQUESTS) - dbgqst = 0; + sprintf(dstr, "Quest %i : Active = %i, Var1 = %i", dbgqst, quests[dbgqst]._qactive, quests[dbgqst]._qvar1); + NetSendCmdString(1 << myplr, dstr); + if (++dbgqst == MAXQUESTS) + dbgqst = 0; } void __fastcall PrintDebugMonster(int m) { - bool bActive; // ecx - int i; // eax - char dstr[128]; // [esp+Ch] [ebp-80h] + bool bActive; // ecx + int i; // eax + char dstr[128]; // [esp+Ch] [ebp-80h] - sprintf(dstr, "Monster %i = %s", m, monster[m].mName); - NetSendCmdString(1 << myplr, dstr); - sprintf(dstr, "X = %i, Y = %i", monster[m]._mx, monster[m]._my); - NetSendCmdString(1 << myplr, dstr); - sprintf(dstr, "Enemy = %i, HP = %i", monster[m]._menemy, monster[m]._mhitpoints); - NetSendCmdString(1 << myplr, dstr); - sprintf(dstr, "Mode = %i, Var1 = %i", monster[m]._mmode, monster[m]._mVar1); - NetSendCmdString(1 << myplr, dstr); + sprintf(dstr, "Monster %i = %s", m, monster[m].mName); + NetSendCmdString(1 << myplr, dstr); + sprintf(dstr, "X = %i, Y = %i", monster[m]._mx, monster[m]._my); + NetSendCmdString(1 << myplr, dstr); + sprintf(dstr, "Enemy = %i, HP = %i", monster[m]._menemy, monster[m]._mhitpoints); + NetSendCmdString(1 << myplr, dstr); + sprintf(dstr, "Mode = %i, Var1 = %i", monster[m]._mmode, monster[m]._mVar1); + NetSendCmdString(1 << myplr, dstr); - bActive = 0; + bActive = 0; - for (i = 0; i < nummonsters; i++) { - if (monstactive[i] == m) - bActive = 1; - } + for (i = 0; i < nummonsters; i++) { + if (monstactive[i] == m) + bActive = 1; + } - sprintf(dstr, "Active List = %i, Squelch = %i", bActive, monster[m]._msquelch); - NetSendCmdString(1 << myplr, dstr); + sprintf(dstr, "Active List = %i, Squelch = %i", bActive, monster[m]._msquelch); + NetSendCmdString(1 << myplr, dstr); } void __cdecl GetDebugMonster() { - int v0; // ecx - int v1; // eax + int v0; // ecx + int v1; // eax - v0 = pcursmonst; - if (pcursmonst == -1) { - v1 = dMonster[cursmx][cursmy]; - if (v1) { - v0 = v1 - 1; - if (v1 <= 0) - v0 = -1 - v1; - } else { - v0 = dbgmon; - } - } - PrintDebugMonster(v0); + v0 = pcursmonst; + if (pcursmonst == -1) { + v1 = dMonster[cursmx][cursmy]; + if (v1) { + v0 = v1 - 1; + if (v1 <= 0) + v0 = -1 - v1; + } else { + v0 = dbgmon; + } + } + PrintDebugMonster(v0); } void __cdecl NextDebugMonster() { - char dstr[128]; // [esp+0h] [ebp-80h] + char dstr[128]; // [esp+0h] [ebp-80h] - if (dbgmon++ == MAXMONSTERS) - dbgmon = 0; + if (dbgmon++ == MAXMONSTERS) + dbgmon = 0; - sprintf(dstr, "Current debug monster = %i", dbgmon); - NetSendCmdString(1 << myplr, dstr); + sprintf(dstr, "Current debug monster = %i", dbgmon); + NetSendCmdString(1 << myplr, dstr); } #endif diff --git a/Source/diablo.cpp b/Source/diablo.cpp index c82aebf1..46377ef5 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -60,156 +60,156 @@ int framestart; #endif BOOL FriendlyMode = TRUE; char *spszMsgTbl[4] = { - "I need help! Come Here!", - "Follow me.", - "Here's something for you.", - "Now you DIE!" + "I need help! Come Here!", + "Follow me.", + "Here's something for you.", + "Now you DIE!" }; // weak char *spszMsgKeyTbl[4] = { "F9", "F10", "F11", "F12" }; // weak struct diablo_cpp_init { - diablo_cpp_init() - { - diablo_cpp_init_value = diablo_inf; - } + diablo_cpp_init() + { + diablo_cpp_init_value = diablo_inf; + } } _diablo_cpp_init; // 479BF8: using guessed type int diablo_inf; // 525514: using guessed type int diablo_cpp_init_value; void __cdecl FreeGameMem() { - void *v0; // ecx - void *v1; // ecx - void *v2; // ecx - void *v3; // ecx - void *v4; // ecx + void *v0; // ecx + void *v1; // ecx + void *v2; // ecx + void *v3; // ecx + void *v4; // ecx - music_stop(); - v0 = pDungeonCels; - pDungeonCels = 0; - mem_free_dbg(v0); - v1 = pMegaTiles; - pMegaTiles = 0; - mem_free_dbg(v1); - v2 = pLevelPieces; - pLevelPieces = 0; - mem_free_dbg(v2); - v3 = level_special_cel; - level_special_cel = 0; - mem_free_dbg(v3); - v4 = pSpeedCels; - pSpeedCels = 0; - mem_free_dbg(v4); - FreeMissiles(); - FreeMonsters(); - FreeObjectGFX(); - FreeEffects(); - FreeTownerGFX(); + music_stop(); + v0 = pDungeonCels; + pDungeonCels = 0; + mem_free_dbg(v0); + v1 = pMegaTiles; + pMegaTiles = 0; + mem_free_dbg(v1); + v2 = pLevelPieces; + pLevelPieces = 0; + mem_free_dbg(v2); + v3 = level_special_cel; + level_special_cel = 0; + mem_free_dbg(v3); + v4 = pSpeedCels; + pSpeedCels = 0; + mem_free_dbg(v4); + FreeMissiles(); + FreeMonsters(); + FreeObjectGFX(); + FreeEffects(); + FreeTownerGFX(); } int __fastcall diablo_init_menu(int a1, int bSinglePlayer) { - int v2; // esi - int v3; // edi - int v4; // ecx - int pfExitProgram; // [esp+Ch] [ebp-4h] + int v2; // esi + int v3; // edi + int v4; // ecx + int pfExitProgram; // [esp+Ch] [ebp-4h] - v2 = bSinglePlayer; - v3 = a1; - byte_678640 = 1; - while (1) { - pfExitProgram = 0; - dword_5256E8 = FALSE; - if (!NetInit(v2, &pfExitProgram)) - break; - byte_678640 = 0; - if ((v3 || !gbValidSaveFile) - && (InitLevels(), InitQuests(), InitPortals(), InitDungMsgs(myplr), !gbValidSaveFile) - || (v4 = WM_DIABLOADGAME, !dword_5256E8)) { - v4 = WM_DIABNEWGAME; - } - run_game_loop(v4); - NetClose(); - pfile_create_player_description(0, 0); - if (!gbRunGameResult) - goto LABEL_11; - } - gbRunGameResult = pfExitProgram == 0; + v2 = bSinglePlayer; + v3 = a1; + byte_678640 = 1; + while (1) { + pfExitProgram = 0; + dword_5256E8 = FALSE; + if (!NetInit(v2, &pfExitProgram)) + break; + byte_678640 = 0; + if ((v3 || !gbValidSaveFile) + && (InitLevels(), InitQuests(), InitPortals(), InitDungMsgs(myplr), !gbValidSaveFile) + || (v4 = WM_DIABLOADGAME, !dword_5256E8)) { + v4 = WM_DIABNEWGAME; + } + run_game_loop(v4); + NetClose(); + pfile_create_player_description(0, 0); + if (!gbRunGameResult) + goto LABEL_11; + } + gbRunGameResult = pfExitProgram == 0; LABEL_11: - SNetDestroy(); - return gbRunGameResult; + SNetDestroy(); + return gbRunGameResult; } // 678640: using guessed type char byte_678640; void __fastcall run_game_loop(int uMsg) { - //int v3; // eax - bool v5; // zf - //int v6; // eax - signed int v7; // [esp+8h] [ebp-24h] - WNDPROC saveProc; // [esp+Ch] [ebp-20h] - struct tagMSG msg; // [esp+10h] [ebp-1Ch] + //int v3; // eax + bool v5; // zf + //int v6; // eax + signed int v7; // [esp+8h] [ebp-24h] + WNDPROC saveProc; // [esp+Ch] [ebp-20h] + struct tagMSG msg; // [esp+10h] [ebp-1Ch] - nthread_ignore_mutex(1); - start_game(uMsg); - saveProc = SetWindowProc(GM_Game); - control_update_life_mana(); - msg_process_net_packets(); - gbRunGame = TRUE; - gbProcessPlayers = TRUE; - gbRunGameResult = TRUE; - drawpanflag = 255; - DrawAndBlit(); - PaletteFadeIn(8); - drawpanflag = 255; - gbGameLoopStartup = 1; - nthread_ignore_mutex(0); - while (gbRunGame) { - diablo_color_cyc_logic(); - if (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { - SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL); - while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { - if (msg.message == WM_QUIT) { - gbRunGameResult = FALSE; - gbRunGame = FALSE; - break; - } - TranslateMessage(&msg); - DispatchMessage(&msg); - } - if (!gbRunGame || (v7 = 1, !nthread_has_500ms_passed())) - v7 = 0; - SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL); - v5 = v7 == 0; - } else { - //_LOBYTE(v6) = nthread_has_500ms_passed(); - v5 = nthread_has_500ms_passed() == 0; - } - if (!v5) { - multi_process_network_packets(); - game_loop(gbGameLoopStartup); - msgcmd_send_chat(); - gbGameLoopStartup = 0; - DrawAndBlit(); - } + nthread_ignore_mutex(1); + start_game(uMsg); + saveProc = SetWindowProc(GM_Game); + control_update_life_mana(); + msg_process_net_packets(); + gbRunGame = TRUE; + gbProcessPlayers = TRUE; + gbRunGameResult = TRUE; + drawpanflag = 255; + DrawAndBlit(); + PaletteFadeIn(8); + drawpanflag = 255; + gbGameLoopStartup = 1; + nthread_ignore_mutex(0); + while (gbRunGame) { + diablo_color_cyc_logic(); + if (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { + SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL); + while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { + if (msg.message == WM_QUIT) { + gbRunGameResult = FALSE; + gbRunGame = FALSE; + break; + } + TranslateMessage(&msg); + DispatchMessage(&msg); + } + if (!gbRunGame || (v7 = 1, !nthread_has_500ms_passed())) + v7 = 0; + SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL); + v5 = v7 == 0; + } else { + //_LOBYTE(v6) = nthread_has_500ms_passed(); + v5 = nthread_has_500ms_passed() == 0; + } + if (!v5) { + multi_process_network_packets(); + game_loop(gbGameLoopStartup); + msgcmd_send_chat(); + gbGameLoopStartup = 0; + DrawAndBlit(); + } #ifdef SLEEP - Sleep(1); + Sleep(1); #endif - } - if ((unsigned char)gbMaxPlayers > 1u) - pfile_write_hero(); - pfile_flush_W(); - PaletteFadeOut(8); - SetCursor(0); - ClearScreenBuffer(); - drawpanflag = 255; - scrollrt_draw_game_screen(1); - SetWindowProc(saveProc); - free_game(); - if (cineflag) { - cineflag = FALSE; - DoEnding(); - } + } + if ((unsigned char)gbMaxPlayers > 1u) + pfile_write_hero(); + pfile_flush_W(); + PaletteFadeOut(8); + SetCursor(0); + ClearScreenBuffer(); + drawpanflag = 255; + scrollrt_draw_game_screen(1); + SetWindowProc(saveProc); + free_game(); + if (cineflag) { + cineflag = FALSE; + DoEnding(); + } } // 525718: using guessed type char cineflag; // 52571C: using guessed type int drawpanflag; @@ -217,18 +217,18 @@ void __fastcall run_game_loop(int uMsg) void __fastcall start_game(int uMsg) { - cineflag = FALSE; - zoomflag = 1; - InitCursor(); - InitLightTable(); - LoadDebugGFX(); - music_stop(); - ShowProgress(uMsg); - gmenu_init_menu(); - InitLevelCursor(); - sgnTimeoutCurs = 0; - sgbMouseDown = 0; - track_repeat_walk(0); + cineflag = FALSE; + zoomflag = 1; + InitCursor(); + InitLightTable(); + LoadDebugGFX(); + music_stop(); + ShowProgress(uMsg); + gmenu_init_menu(); + InitLevelCursor(); + sgnTimeoutCurs = 0; + sgbMouseDown = 0; + track_repeat_walk(0); } // 52569C: using guessed type int zoomflag; // 525718: using guessed type char cineflag; @@ -236,370 +236,370 @@ void __fastcall start_game(int uMsg) void __cdecl free_game() { - int i; // esi + int i; // esi - FreeControlPan(); - FreeInvGFX(); - FreeGMenu(); - FreeQuestText(); - FreeStoreMem(); + FreeControlPan(); + FreeInvGFX(); + FreeGMenu(); + FreeQuestText(); + FreeStoreMem(); - for (i = 0; i < MAX_PLRS; i++) - FreePlayerGFX(i); + for (i = 0; i < MAX_PLRS; i++) + FreePlayerGFX(i); - FreeItemGFX(); - FreeCursor(); - FreeLightTable(); - FreeDebugGFX(); - FreeGameMem(); + FreeItemGFX(); + FreeCursor(); + FreeLightTable(); + FreeDebugGFX(); + FreeGameMem(); } bool __cdecl diablo_get_not_running() { - SetLastError(0); - CreateEvent(NULL, FALSE, FALSE, "DiabloEvent"); - return GetLastError() != ERROR_ALREADY_EXISTS; + SetLastError(0); + CreateEvent(NULL, FALSE, FALSE, "DiabloEvent"); + return GetLastError() != ERROR_ALREADY_EXISTS; } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { - HINSTANCE v4; // esi - char Filename[260]; // [esp+8h] [ebp-10Ch] - char value_name[8]; // [esp+10Ch] [ebp-8h] + HINSTANCE v4; // esi + char Filename[260]; // [esp+8h] [ebp-10Ch] + char value_name[8]; // [esp+10Ch] [ebp-8h] - v4 = hInstance; + v4 = hInstance; #ifndef DEBUGGER - diablo_reload_process(hInstance); + diablo_reload_process(hInstance); #endif - ghInst = v4; - if (RestrictedTest()) - ErrOkDlg(IDD_DIALOG10, 0, "C:\\Src\\Diablo\\Source\\DIABLO.CPP", 877); - if (ReadOnlyTest()) { - if (!GetModuleFileName(ghInst, Filename, 0x104u)) - *Filename = '\0'; - DirErrorDlg(Filename); - } - ShowCursor(FALSE); - srand(GetTickCount()); - InitHash(); - exception_get_filter(); - if (!diablo_find_window("DIABLO") && diablo_get_not_running()) { - diablo_init_screen(); - diablo_parse_flags(lpCmdLine); - init_create_window(nCmdShow); - sound_init(); - UiInitialize(); + ghInst = v4; + if (RestrictedTest()) + ErrOkDlg(IDD_DIALOG10, 0, "C:\\Src\\Diablo\\Source\\DIABLO.CPP", 877); + if (ReadOnlyTest()) { + if (!GetModuleFileName(ghInst, Filename, 0x104u)) + *Filename = '\0'; + DirErrorDlg(Filename); + } + ShowCursor(FALSE); + srand(GetTickCount()); + InitHash(); + exception_get_filter(); + if (!diablo_find_window("DIABLO") && diablo_get_not_running()) { + diablo_init_screen(); + diablo_parse_flags(lpCmdLine); + init_create_window(nCmdShow); + sound_init(); + UiInitialize(); #ifdef _DEBUG - if (showintrodebug) - play_movie("gendata\\logo.smk", 1); + if (showintrodebug) + play_movie("gendata\\logo.smk", 1); #else - play_movie("gendata\\logo.smk", 1); + play_movie("gendata\\logo.smk", 1); #endif - strcpy(value_name, "Intro"); - if (!SRegLoadValue("Diablo", value_name, 0, (int *)&hInstance)) - hInstance = (HINSTANCE)1; - if (hInstance) - play_movie("gendata\\diablo1.smk", 1); - SRegSaveValue("Diablo", value_name, 0, 0); + strcpy(value_name, "Intro"); + if (!SRegLoadValue("Diablo", value_name, 0, (int *)&hInstance)) + hInstance = (HINSTANCE)1; + if (hInstance) + play_movie("gendata\\diablo1.smk", 1); + SRegSaveValue("Diablo", value_name, 0, 0); #ifdef _DEBUG - if (showintrodebug) { - UiTitleDialog(7); - BlackPalette(); - } + if (showintrodebug) { + UiTitleDialog(7); + BlackPalette(); + } #else - UiTitleDialog(7); - BlackPalette(); + UiTitleDialog(7); + BlackPalette(); #endif - mainmenu_loop(); - UiDestroy(); - SaveGamma(); - if (ghMainWnd) { - Sleep(300); - DestroyWindow(ghMainWnd); - } - } - return 0; + mainmenu_loop(); + UiDestroy(); + SaveGamma(); + if (ghMainWnd) { + Sleep(300); + DestroyWindow(ghMainWnd); + } + } + return 0; } void __fastcall diablo_parse_flags(char *args) { #ifdef _DEBUG - int n; // edi - int v15; // eax + int n; // edi + int v15; // eax #endif - while (*args) { - for (; isspace(*args); ++args) - ; - if (!_strcmpi("dd_emulate", args)) { - gbEmulate = 1; - args += strlen("dd_emulate"); - } else if (!_strcmpi("dd_backbuf", args)) { - gbBackBuf = 1; - args += strlen("dd_backbuf"); - } else if (!_strcmpi("ds_noduplicates", args)) { - gbDupSounds = FALSE; - args += strlen("ds_noduplicates"); - } else { + while (*args) { + for (; isspace(*args); ++args) + ; + if (!_strcmpi("dd_emulate", args)) { + gbEmulate = 1; + args += strlen("dd_emulate"); + } else if (!_strcmpi("dd_backbuf", args)) { + gbBackBuf = 1; + args += strlen("dd_backbuf"); + } else if (!_strcmpi("ds_noduplicates", args)) { + gbDupSounds = FALSE; + args += strlen("ds_noduplicates"); + } else { #ifdef _DEBUG - switch (tolower(*args++)) { - case '^': // god mod with all spells as skills - debug_mode_key_inverted_v = 1; - break; - case '$': // demi-god - debug_mode_dollar_sign = 1; - break; - /*case 'b': // enable drop log + switch (tolower(*args++)) { + case '^': // god mod with all spells as skills + debug_mode_key_inverted_v = 1; + break; + case '$': // demi-god + debug_mode_dollar_sign = 1; + break; + /*case 'b': // enable drop log debug_mode_key_b = 1; break;*/ - case 'd': // no startup video+??? - showintrodebug = 0; - debug_mode_key_d = 1; - break; - case 'f': // draw fps - EnableFrameCount(); - break; - case 'i': // disable network timeout - debug_mode_key_i = 1; - break; - /*case 'j': // : init trigger at level + case 'd': // no startup video+??? + showintrodebug = 0; + debug_mode_key_d = 1; + break; + case 'f': // draw fps + EnableFrameCount(); + break; + case 'i': // disable network timeout + debug_mode_key_i = 1; + break; + /*case 'j': // : init trigger at level for ( ; isspace(*args); ++args ) ; for ( n = 0; isdigit(*args); n = v15 + 10 * n - 48 ) v15 = *args++; debug_mode_key_J_trigger = n; break;*/ - case 'l': // : start in level as type - setlevel = 0; - for (leveldebug = 1; isspace(*args); ++args) - ; - for (n = 0; isdigit(*args); n = v15 + 10 * n - 48) - v15 = *args++; - for (leveltype = n; isspace(*args); ++args) - ; - for (n = 0; isdigit(*args); n = v15 + 10 * n - 48) - v15 = *args++; - currlevel = n; - plr[0].plrlevel = n; - break; - case 'm': // : add debug monster, up to 10 allowed - for (monstdebug = 1; isspace(*args); ++args) - ; - for (n = 0; isdigit(*args); n = v15 + 10 * n - 48) - v15 = *args++; - DebugMonsters[debugmonsttypes++] = n; - break; - case 'n': // disable startup video - showintrodebug = 0; - break; - case 'q': // : force a certain quest - for (; isspace(*args); ++args) - ; - for (n = 0; isdigit(*args); n = v15 + 10 * n - 48) - v15 = *args++; - questdebug = n; - break; - case 'r': // : set map seed to - for (; isspace(*args); ++args) - ; - for (n = 0; isdigit(*args); n = v15 + 10 * n - 48) - v15 = *args++; - setseed = n; - break; - case 's': // unused - debug_mode_key_s = 1; - break; - case 't': // : sets current quest level - leveldebug = 1; - for (setlevel = 1; isspace(*args); ++args) - ; - for (n = 0; isdigit(*args); n = v15 + 10 * n - 48) - v15 = *args++; - setlvlnum = n; - break; - case 'v': // draw yellow debug tiles - visiondebug = 1; - break; - case 'w': // rest of the cheats, some only in town - debug_mode_key_w = 1; - break; - case 'x': - fullscreen = FALSE; - break; - default: - break; - } + case 'l': // : start in level as type + setlevel = 0; + for (leveldebug = 1; isspace(*args); ++args) + ; + for (n = 0; isdigit(*args); n = v15 + 10 * n - 48) + v15 = *args++; + for (leveltype = n; isspace(*args); ++args) + ; + for (n = 0; isdigit(*args); n = v15 + 10 * n - 48) + v15 = *args++; + currlevel = n; + plr[0].plrlevel = n; + break; + case 'm': // : add debug monster, up to 10 allowed + for (monstdebug = 1; isspace(*args); ++args) + ; + for (n = 0; isdigit(*args); n = v15 + 10 * n - 48) + v15 = *args++; + DebugMonsters[debugmonsttypes++] = n; + break; + case 'n': // disable startup video + showintrodebug = 0; + break; + case 'q': // : force a certain quest + for (; isspace(*args); ++args) + ; + for (n = 0; isdigit(*args); n = v15 + 10 * n - 48) + v15 = *args++; + questdebug = n; + break; + case 'r': // : set map seed to + for (; isspace(*args); ++args) + ; + for (n = 0; isdigit(*args); n = v15 + 10 * n - 48) + v15 = *args++; + setseed = n; + break; + case 's': // unused + debug_mode_key_s = 1; + break; + case 't': // : sets current quest level + leveldebug = 1; + for (setlevel = 1; isspace(*args); ++args) + ; + for (n = 0; isdigit(*args); n = v15 + 10 * n - 48) + v15 = *args++; + setlvlnum = n; + break; + case 'v': // draw yellow debug tiles + visiondebug = 1; + break; + case 'w': // rest of the cheats, some only in town + debug_mode_key_w = 1; + break; + case 'x': + fullscreen = FALSE; + break; + default: + break; + } #else - tolower(*args++); + tolower(*args++); #endif - } - } + } + } } // 52A548: using guessed type char gbBackBuf; // 52A549: using guessed type char gbEmulate; void __cdecl diablo_init_screen() { - int v0; // ecx - int *v1; // eax + int v0; // ecx + int *v1; // eax - v0 = 0; - MouseX = 320; - MouseY = 240; - ScrollInfo._sdx = 0; - ScrollInfo._sdy = 0; - ScrollInfo._sxoff = 0; - ScrollInfo._syoff = 0; - ScrollInfo._sdir = 0; - v1 = screen_y_times_768; - do { - *v1 = v0; - ++v1; - v0 += 768; - } while ((signed int)v1 < (signed int)&screen_y_times_768[1024]); - ClrDiabloMsg(); + v0 = 0; + MouseX = 320; + MouseY = 240; + ScrollInfo._sdx = 0; + ScrollInfo._sdy = 0; + ScrollInfo._sxoff = 0; + ScrollInfo._syoff = 0; + ScrollInfo._sdir = 0; + v1 = screen_y_times_768; + do { + *v1 = v0; + ++v1; + v0 += 768; + } while ((signed int)v1 < (signed int)&screen_y_times_768[1024]); + ClrDiabloMsg(); } // 69CEFC: using guessed type int scrollrt_cpp_init_value; BOOL __fastcall diablo_find_window(LPCSTR lpClassName) { - HWND result; // eax - HWND v2; // esi - HWND v3; // eax - HWND v4; // edi + HWND result; // eax + HWND v2; // esi + HWND v3; // eax + HWND v4; // edi - result = FindWindow(lpClassName, 0); - v2 = result; - if (!result) - return 0; + result = FindWindow(lpClassName, 0); + v2 = result; + if (!result) + return 0; - v3 = GetLastActivePopup(result); - if (v3) - v2 = v3; - v4 = GetTopWindow(v2); - if (!v4) - v4 = v2; - SetForegroundWindow(v2); - SetFocus(v4); - return 1; + v3 = GetLastActivePopup(result); + if (v3) + v2 = v3; + v4 = GetTopWindow(v2); + if (!v4) + v4 = v2; + SetForegroundWindow(v2); + SetFocus(v4); + return 1; } void __fastcall diablo_reload_process(HMODULE hModule) { - char *i; // eax - DWORD dwSize; // esi - BOOL v3; // edi - _DWORD *v4; // eax - _DWORD *v5; // esi - HWND v6; // eax - char Name[276]; // [esp+Ch] [ebp-29Ch] - char Filename[260]; // [esp+120h] [ebp-188h] - STARTUPINFOA si; // [esp+224h] [ebp-84h] - SYSTEM_INFO sinf; // [esp+268h] [ebp-40h] - PROCESS_INFORMATION pi; // [esp+28Ch] [ebp-1Ch] - DWORD dwProcessId; // [esp+29Ch] [ebp-Ch] - HANDLE hMap; // [esp+2A0h] [ebp-8h] - HWND hWnd; // [esp+2A4h] [ebp-4h] + char *i; // eax + DWORD dwSize; // esi + BOOL v3; // edi + _DWORD *v4; // eax + _DWORD *v5; // esi + HWND v6; // eax + char Name[276]; // [esp+Ch] [ebp-29Ch] + char Filename[260]; // [esp+120h] [ebp-188h] + STARTUPINFOA si; // [esp+224h] [ebp-84h] + SYSTEM_INFO sinf; // [esp+268h] [ebp-40h] + PROCESS_INFORMATION pi; // [esp+28Ch] [ebp-1Ch] + DWORD dwProcessId; // [esp+29Ch] [ebp-Ch] + HANDLE hMap; // [esp+2A0h] [ebp-8h] + HWND hWnd; // [esp+2A4h] [ebp-4h] - *Filename = empty_string; - memset(Filename + 1, 0, sizeof(Filename) - 1); - // *(_WORD *)&Filename[257] = 0; - // Filename[259] = 0; - GetModuleFileName(hModule, Filename, 0x104u); - wsprintf(Name, "Reload-%s", Filename); - for (i = Name; *i; ++i) { - if (*i == '\\') - *i = '/'; - } - GetSystemInfo(&sinf); - dwSize = sinf.dwPageSize; - if (sinf.dwPageSize < 4096) - dwSize = 4096; - hMap = CreateFileMapping((HANDLE)0xFFFFFFFF, NULL, SEC_COMMIT | PAGE_READWRITE, 0, dwSize, Name); - v3 = GetLastError() != ERROR_ALREADY_EXISTS; - if (hMap) { - v4 = (unsigned int *)MapViewOfFile(hMap, FILE_MAP_ALL_ACCESS, 0, 0, dwSize); - v5 = v4; - if (v4) { - if (v3) { - *v4 = -1; - v4[1] = 0; - memset(&si, 0, sizeof(si)); - si.cb = sizeof(si); - CreateProcess(Filename, NULL, NULL, NULL, FALSE, CREATE_NEW_PROCESS_GROUP, NULL, NULL, &si, &pi); - WaitForInputIdle(pi.hProcess, 0xFFFFFFFF); - CloseHandle(pi.hThread); - CloseHandle(pi.hProcess); - while (*v5 < 0) - Sleep(1000); - UnmapViewOfFile(v5); - CloseHandle(hMap); - ExitProcess(0); - } - if (InterlockedIncrement((long *)v4)) { - v6 = GetForegroundWindow(); - do { - hWnd = v6; - v6 = GetWindow(v6, 3u); - } while (v6); - while (1) { - GetWindowThreadProcessId(hWnd, &dwProcessId); - if (dwProcessId == v5[1]) - break; - hWnd = GetWindow(hWnd, 2u); - if (!hWnd) - goto LABEL_23; - } - SetForegroundWindow(hWnd); - LABEL_23: - UnmapViewOfFile(v5); - CloseHandle(hMap); - ExitProcess(0); - } - v5[1] = GetCurrentProcessId(); - } - } + *Filename = empty_string; + memset(Filename + 1, 0, sizeof(Filename) - 1); + // *(_WORD *)&Filename[257] = 0; + // Filename[259] = 0; + GetModuleFileName(hModule, Filename, 0x104u); + wsprintf(Name, "Reload-%s", Filename); + for (i = Name; *i; ++i) { + if (*i == '\\') + *i = '/'; + } + GetSystemInfo(&sinf); + dwSize = sinf.dwPageSize; + if (sinf.dwPageSize < 4096) + dwSize = 4096; + hMap = CreateFileMapping((HANDLE)0xFFFFFFFF, NULL, SEC_COMMIT | PAGE_READWRITE, 0, dwSize, Name); + v3 = GetLastError() != ERROR_ALREADY_EXISTS; + if (hMap) { + v4 = (unsigned int *)MapViewOfFile(hMap, FILE_MAP_ALL_ACCESS, 0, 0, dwSize); + v5 = v4; + if (v4) { + if (v3) { + *v4 = -1; + v4[1] = 0; + memset(&si, 0, sizeof(si)); + si.cb = sizeof(si); + CreateProcess(Filename, NULL, NULL, NULL, FALSE, CREATE_NEW_PROCESS_GROUP, NULL, NULL, &si, &pi); + WaitForInputIdle(pi.hProcess, 0xFFFFFFFF); + CloseHandle(pi.hThread); + CloseHandle(pi.hProcess); + while (*v5 < 0) + Sleep(1000); + UnmapViewOfFile(v5); + CloseHandle(hMap); + ExitProcess(0); + } + if (InterlockedIncrement((long *)v4)) { + v6 = GetForegroundWindow(); + do { + hWnd = v6; + v6 = GetWindow(v6, 3u); + } while (v6); + while (1) { + GetWindowThreadProcessId(hWnd, &dwProcessId); + if (dwProcessId == v5[1]) + break; + hWnd = GetWindow(hWnd, 2u); + if (!hWnd) + goto LABEL_23; + } + SetForegroundWindow(hWnd); + LABEL_23: + UnmapViewOfFile(v5); + CloseHandle(hMap); + ExitProcess(0); + } + v5[1] = GetCurrentProcessId(); + } + } } int __cdecl PressEscKey() { - int result; // eax + int result; // eax - result = 0; - if (doomflag) { - doom_close(); - result = 1; - } - if (helpflag) { - helpflag = 0; - result = 1; - } - if (qtextflag) { - qtextflag = FALSE; - sfx_stop(); - } else { - if (!stextflag) - goto LABEL_10; - STextESC(); - } - result = 1; + result = 0; + if (doomflag) { + doom_close(); + result = 1; + } + if (helpflag) { + helpflag = 0; + result = 1; + } + if (qtextflag) { + qtextflag = FALSE; + sfx_stop(); + } else { + if (!stextflag) + goto LABEL_10; + STextESC(); + } + result = 1; LABEL_10: - if (msgflag) { - msgdelay = 0; - result = 1; - } - if (talkflag) { - control_reset_talk(); - result = 1; - } - if (dropGoldFlag) { - control_drop_gold(VK_ESCAPE); - result = 1; - } - if (spselflag) { - spselflag = 0; - result = 1; - } - return result; + if (msgflag) { + msgdelay = 0; + result = 1; + } + if (talkflag) { + control_reset_talk(); + result = 1; + } + if (dropGoldFlag) { + control_drop_gold(VK_ESCAPE); + result = 1; + } + if (spselflag) { + spselflag = 0; + result = 1; + } + return result; } // 4B84DC: using guessed type int dropGoldFlag; // 4B8960: using guessed type int talkflag; @@ -612,151 +612,151 @@ LABEL_10: LRESULT __stdcall DisableInputWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - bool v5; // zf + bool v5; // zf - if (uMsg <= WM_LBUTTONDOWN) { - if (uMsg != WM_LBUTTONDOWN) { - if (uMsg >= WM_KEYFIRST - && (uMsg <= WM_CHAR - || uMsg == WM_SYSKEYDOWN - || uMsg == WM_SYSCOMMAND - || uMsg == WM_MOUSEFIRST)) { - return 0; - } - return MainWndProc(hWnd, uMsg, wParam, lParam); - } - if (!sgbMouseDown) { - sgbMouseDown = 1; - LABEL_21: - SetCapture(hWnd); - return 0; - } - return 0; - } - if (uMsg == WM_LBUTTONUP) { - v5 = sgbMouseDown == 1; - goto LABEL_23; - } - if (uMsg != WM_RBUTTONDOWN) { - if (uMsg != WM_RBUTTONUP) { - if (uMsg == WM_CAPTURECHANGED) { - if (hWnd != (HWND)lParam) - sgbMouseDown = 0; - return 0; - } - return MainWndProc(hWnd, uMsg, wParam, lParam); - } - v5 = sgbMouseDown == 2; - LABEL_23: - if (v5) { - sgbMouseDown = 0; - ReleaseCapture(); - } - return 0; - } - if (!sgbMouseDown) { - sgbMouseDown = 2; - goto LABEL_21; - } - return 0; + if (uMsg <= WM_LBUTTONDOWN) { + if (uMsg != WM_LBUTTONDOWN) { + if (uMsg >= WM_KEYFIRST + && (uMsg <= WM_CHAR + || uMsg == WM_SYSKEYDOWN + || uMsg == WM_SYSCOMMAND + || uMsg == WM_MOUSEFIRST)) { + return 0; + } + return MainWndProc(hWnd, uMsg, wParam, lParam); + } + if (!sgbMouseDown) { + sgbMouseDown = 1; + LABEL_21: + SetCapture(hWnd); + return 0; + } + return 0; + } + if (uMsg == WM_LBUTTONUP) { + v5 = sgbMouseDown == 1; + goto LABEL_23; + } + if (uMsg != WM_RBUTTONDOWN) { + if (uMsg != WM_RBUTTONUP) { + if (uMsg == WM_CAPTURECHANGED) { + if (hWnd != (HWND)lParam) + sgbMouseDown = 0; + return 0; + } + return MainWndProc(hWnd, uMsg, wParam, lParam); + } + v5 = sgbMouseDown == 2; + LABEL_23: + if (v5) { + sgbMouseDown = 0; + ReleaseCapture(); + } + return 0; + } + if (!sgbMouseDown) { + sgbMouseDown = 2; + goto LABEL_21; + } + return 0; } // 525748: using guessed type char sgbMouseDown; LRESULT __stdcall GM_Game(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - if (uMsg > WM_LBUTTONDOWN) { - if (uMsg == WM_LBUTTONUP) { - MouseX = (unsigned short)lParam; - MouseY = (unsigned int)lParam >> 16; - if (sgbMouseDown != 1) - return 0; - sgbMouseDown = 0; - LeftMouseUp(); - track_repeat_walk(0); - } else { - if (uMsg == WM_RBUTTONDOWN) { - MouseX = (unsigned short)lParam; - MouseY = (unsigned int)lParam >> 16; - if (!sgbMouseDown) { - sgbMouseDown = 2; - SetCapture(hWnd); - RightMouseDown(); - } - return 0; - } - if (uMsg != WM_RBUTTONUP) { - if (uMsg == WM_CAPTURECHANGED) { - if (hWnd != (HWND)lParam) { - sgbMouseDown = 0; - track_repeat_walk(0); - } - } else if (uMsg > WM_DIAB && uMsg <= WM_DIABRETOWN) { - if ((unsigned char)gbMaxPlayers > 1u) - pfile_write_hero(); - nthread_ignore_mutex(1); - PaletteFadeOut(8); - FreeMonsterSnd(); - music_stop(); - track_repeat_walk(0); - sgbMouseDown = 0; - ReleaseCapture(); - ShowProgress(uMsg); - drawpanflag = 255; - DrawAndBlit(); - if (gbRunGame) - PaletteFadeIn(8); - nthread_ignore_mutex(0); - gbGameLoopStartup = 1; - return 0; - } - return MainWndProc(hWnd, uMsg, wParam, lParam); - } - MouseX = (unsigned short)lParam; - MouseY = (unsigned int)lParam >> 16; - if (sgbMouseDown != 2) - return 0; - sgbMouseDown = 0; - } - ReleaseCapture(); - return 0; - } - switch (uMsg) { - case WM_LBUTTONDOWN: - MouseX = (unsigned short)lParam; - MouseY = (unsigned int)lParam >> 16; - if (!sgbMouseDown) { - sgbMouseDown = 1; - SetCapture(hWnd); - track_repeat_walk(LeftMouseDown(wParam)); - } - return 0; - case WM_KEYFIRST: - PressKey(wParam); - return 0; - case WM_KEYUP: - ReleaseKey(wParam); - return 0; - case WM_CHAR: - PressChar(wParam); - return 0; - case WM_SYSKEYDOWN: - if (PressSysKey(wParam)) - return 0; - return MainWndProc(hWnd, uMsg, wParam, lParam); - case WM_SYSCOMMAND: - if (wParam == SC_CLOSE) { - gbRunGame = FALSE; - gbRunGameResult = FALSE; - return 0; - } - return MainWndProc(hWnd, uMsg, wParam, lParam); - } - if (uMsg != WM_MOUSEFIRST) - return MainWndProc(hWnd, uMsg, wParam, lParam); - MouseX = (unsigned short)lParam; - MouseY = (unsigned int)lParam >> 16; - gmenu_on_mouse_move((unsigned short)lParam); - return 0; + if (uMsg > WM_LBUTTONDOWN) { + if (uMsg == WM_LBUTTONUP) { + MouseX = (unsigned short)lParam; + MouseY = (unsigned int)lParam >> 16; + if (sgbMouseDown != 1) + return 0; + sgbMouseDown = 0; + LeftMouseUp(); + track_repeat_walk(0); + } else { + if (uMsg == WM_RBUTTONDOWN) { + MouseX = (unsigned short)lParam; + MouseY = (unsigned int)lParam >> 16; + if (!sgbMouseDown) { + sgbMouseDown = 2; + SetCapture(hWnd); + RightMouseDown(); + } + return 0; + } + if (uMsg != WM_RBUTTONUP) { + if (uMsg == WM_CAPTURECHANGED) { + if (hWnd != (HWND)lParam) { + sgbMouseDown = 0; + track_repeat_walk(0); + } + } else if (uMsg > WM_DIAB && uMsg <= WM_DIABRETOWN) { + if ((unsigned char)gbMaxPlayers > 1u) + pfile_write_hero(); + nthread_ignore_mutex(1); + PaletteFadeOut(8); + FreeMonsterSnd(); + music_stop(); + track_repeat_walk(0); + sgbMouseDown = 0; + ReleaseCapture(); + ShowProgress(uMsg); + drawpanflag = 255; + DrawAndBlit(); + if (gbRunGame) + PaletteFadeIn(8); + nthread_ignore_mutex(0); + gbGameLoopStartup = 1; + return 0; + } + return MainWndProc(hWnd, uMsg, wParam, lParam); + } + MouseX = (unsigned short)lParam; + MouseY = (unsigned int)lParam >> 16; + if (sgbMouseDown != 2) + return 0; + sgbMouseDown = 0; + } + ReleaseCapture(); + return 0; + } + switch (uMsg) { + case WM_LBUTTONDOWN: + MouseX = (unsigned short)lParam; + MouseY = (unsigned int)lParam >> 16; + if (!sgbMouseDown) { + sgbMouseDown = 1; + SetCapture(hWnd); + track_repeat_walk(LeftMouseDown(wParam)); + } + return 0; + case WM_KEYFIRST: + PressKey(wParam); + return 0; + case WM_KEYUP: + ReleaseKey(wParam); + return 0; + case WM_CHAR: + PressChar(wParam); + return 0; + case WM_SYSKEYDOWN: + if (PressSysKey(wParam)) + return 0; + return MainWndProc(hWnd, uMsg, wParam, lParam); + case WM_SYSCOMMAND: + if (wParam == SC_CLOSE) { + gbRunGame = FALSE; + gbRunGameResult = FALSE; + return 0; + } + return MainWndProc(hWnd, uMsg, wParam, lParam); + } + if (uMsg != WM_MOUSEFIRST) + return MainWndProc(hWnd, uMsg, wParam, lParam); + MouseX = (unsigned short)lParam; + MouseY = (unsigned int)lParam >> 16; + gmenu_on_mouse_move((unsigned short)lParam); + return 0; } // 52571C: using guessed type int drawpanflag; // 525748: using guessed type char sgbMouseDown; @@ -764,164 +764,164 @@ LRESULT __stdcall GM_Game(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) bool __fastcall LeftMouseDown(int a1) { - int v1; // edi - int v3; // eax - bool v6; // zf - int v7; // ecx - int v8; // eax - unsigned char v9; // dl - unsigned char v11; // dl - unsigned short v12; // ax - unsigned char v13; // dl - unsigned short v15; // [esp-8h] [ebp-10h] + int v1; // edi + int v3; // eax + bool v6; // zf + int v7; // ecx + int v8; // eax + unsigned char v9; // dl + unsigned char v11; // dl + unsigned short v12; // ax + unsigned char v13; // dl + unsigned short v15; // [esp-8h] [ebp-10h] - v1 = a1; - if (gmenu_left_mouse(1) || control_check_talk_btn() || sgnTimeoutCurs) - return 0; - if (deathflag) { - control_check_btn_press(); - return 0; - } - if (PauseMode == 2) - return 0; - if (doomflag) { - doom_close(); - return 0; - } - if (spselflag) { - SetSpell(); - return 0; - } - if (stextflag) { - CheckStoreBtn(); - return 0; - } - if (MouseY >= 352) { - if (!talkflag && !dropGoldFlag) { - if (!gmenu_exception()) - CheckInvScrn(); - } - DoPanBtn(); - if (pcurs <= 1 || pcurs >= 12) - return 0; - goto LABEL_48; - } - if (gmenu_exception() || TryIconCurs()) - return 0; - if (questlog && MouseX > 32 && MouseX < 288 && MouseY > 32 && MouseY < 308) { - QuestlogESC(); - return 0; - } - if (qtextflag) { - qtextflag = FALSE; - sfx_stop(); - return 0; - } - if (chrflag && MouseX < 320) { - CheckChrBtns(); - return 0; - } - if (invflag && MouseX > 320) { - if (!dropGoldFlag) - CheckInvItem(); - return 0; - } - if (sbookflag && MouseX > 320) { - CheckSBook(); - return 0; - } - if (pcurs >= CURSOR_FIRSTITEM) { - if (!TryInvPut()) - return 0; - NetSendCmdPItem(TRUE, CMD_PUTITEM, cursmx, cursmy); - LABEL_48: - SetCursor(CURSOR_HAND); - return 0; - } - v3 = 21720 * myplr; - if (plr[myplr]._pStatPts && !spselflag) - CheckLvlBtn(); - if (lvlbtndown) - return 0; - if (leveltype != DTYPE_TOWN) { - v7 = abs(plr[myplr].WorldX - cursmx) < 2 && abs(plr[myplr].WorldY - cursmy) < 2; - _HIWORD(v8) = _HIWORD(pcurs); - if (pcursitem != -1 && pcurs == 1 && v1 != 5) { - _LOWORD(v8) = pcursitem; - NetSendCmdLocParam1(TRUE, (invflag == 0) + CMD_GOTOGETITEM, cursmx, cursmy, v8); - LABEL_96: - if (pcursitem != -1) - return 0; - v6 = pcursobj == -1; - goto LABEL_98; - } - if (pcursobj != -1) { - if (v1 != 5 || v7 && object[pcursobj]._oBreak == 1) { - NetSendCmdLocParam1(TRUE, (pcurs == 5) + CMD_OPOBJXY, cursmx, cursmy, pcursobj); - goto LABEL_95; - } - } - if (plr[myplr]._pwtype == 1) { - if (v1 == 5) { - v9 = CMD_RATTACKXY; - LABEL_84: - NetSendCmdLoc(TRUE, v9, cursmx, cursmy); - goto LABEL_95; - } - if (pcursmonst != -1) { - v15 = pcursmonst; - if (!CanTalkToMonst(pcursmonst)) { - v11 = CMD_RATTACKID; - LABEL_89: - NetSendCmdParam1(TRUE, v11, v15); - goto LABEL_96; - } - LABEL_88: - v11 = CMD_ATTACKID; - goto LABEL_89; - } - _LOBYTE(v12) = pcursplr; - if (pcursplr == -1 || FriendlyMode) - goto LABEL_96; - v13 = CMD_RATTACKPID; - } else { - if (v1 == 5) { - if (pcursmonst == -1 || !CanTalkToMonst(pcursmonst)) { - v9 = CMD_SATTACKXY; - goto LABEL_84; - } - v12 = pcursmonst; - v13 = CMD_ATTACKID; - LABEL_94: - NetSendCmdParam1(TRUE, v13, v12); - LABEL_95: - if (v1 == 5) - return 0; - goto LABEL_96; - } - if (pcursmonst != -1) { - v15 = pcursmonst; - goto LABEL_88; - } - _LOBYTE(v12) = pcursplr; - if (pcursplr == -1 || FriendlyMode) - goto LABEL_96; - v13 = CMD_ATTACKPID; - } - v12 = (char)v12; - goto LABEL_94; - } - if (pcursitem != -1 && pcurs == 1) { - _LOWORD(v3) = pcursitem; - NetSendCmdLocParam1(TRUE, (invflag == 0) + CMD_GOTOGETITEM, cursmx, cursmy, v3); - } - if (pcursmonst != -1) - NetSendCmdLocParam1(TRUE, CMD_TALKXY, cursmx, cursmy, pcursmonst); - v6 = pcursitem == -1; + v1 = a1; + if (gmenu_left_mouse(1) || control_check_talk_btn() || sgnTimeoutCurs) + return 0; + if (deathflag) { + control_check_btn_press(); + return 0; + } + if (PauseMode == 2) + return 0; + if (doomflag) { + doom_close(); + return 0; + } + if (spselflag) { + SetSpell(); + return 0; + } + if (stextflag) { + CheckStoreBtn(); + return 0; + } + if (MouseY >= 352) { + if (!talkflag && !dropGoldFlag) { + if (!gmenu_exception()) + CheckInvScrn(); + } + DoPanBtn(); + if (pcurs <= 1 || pcurs >= 12) + return 0; + goto LABEL_48; + } + if (gmenu_exception() || TryIconCurs()) + return 0; + if (questlog && MouseX > 32 && MouseX < 288 && MouseY > 32 && MouseY < 308) { + QuestlogESC(); + return 0; + } + if (qtextflag) { + qtextflag = FALSE; + sfx_stop(); + return 0; + } + if (chrflag && MouseX < 320) { + CheckChrBtns(); + return 0; + } + if (invflag && MouseX > 320) { + if (!dropGoldFlag) + CheckInvItem(); + return 0; + } + if (sbookflag && MouseX > 320) { + CheckSBook(); + return 0; + } + if (pcurs >= CURSOR_FIRSTITEM) { + if (!TryInvPut()) + return 0; + NetSendCmdPItem(TRUE, CMD_PUTITEM, cursmx, cursmy); + LABEL_48: + SetCursor(CURSOR_HAND); + return 0; + } + v3 = 21720 * myplr; + if (plr[myplr]._pStatPts && !spselflag) + CheckLvlBtn(); + if (lvlbtndown) + return 0; + if (leveltype != DTYPE_TOWN) { + v7 = abs(plr[myplr].WorldX - cursmx) < 2 && abs(plr[myplr].WorldY - cursmy) < 2; + _HIWORD(v8) = _HIWORD(pcurs); + if (pcursitem != -1 && pcurs == 1 && v1 != 5) { + _LOWORD(v8) = pcursitem; + NetSendCmdLocParam1(TRUE, (invflag == 0) + CMD_GOTOGETITEM, cursmx, cursmy, v8); + LABEL_96: + if (pcursitem != -1) + return 0; + v6 = pcursobj == -1; + goto LABEL_98; + } + if (pcursobj != -1) { + if (v1 != 5 || v7 && object[pcursobj]._oBreak == 1) { + NetSendCmdLocParam1(TRUE, (pcurs == 5) + CMD_OPOBJXY, cursmx, cursmy, pcursobj); + goto LABEL_95; + } + } + if (plr[myplr]._pwtype == 1) { + if (v1 == 5) { + v9 = CMD_RATTACKXY; + LABEL_84: + NetSendCmdLoc(TRUE, v9, cursmx, cursmy); + goto LABEL_95; + } + if (pcursmonst != -1) { + v15 = pcursmonst; + if (!CanTalkToMonst(pcursmonst)) { + v11 = CMD_RATTACKID; + LABEL_89: + NetSendCmdParam1(TRUE, v11, v15); + goto LABEL_96; + } + LABEL_88: + v11 = CMD_ATTACKID; + goto LABEL_89; + } + _LOBYTE(v12) = pcursplr; + if (pcursplr == -1 || FriendlyMode) + goto LABEL_96; + v13 = CMD_RATTACKPID; + } else { + if (v1 == 5) { + if (pcursmonst == -1 || !CanTalkToMonst(pcursmonst)) { + v9 = CMD_SATTACKXY; + goto LABEL_84; + } + v12 = pcursmonst; + v13 = CMD_ATTACKID; + LABEL_94: + NetSendCmdParam1(TRUE, v13, v12); + LABEL_95: + if (v1 == 5) + return 0; + goto LABEL_96; + } + if (pcursmonst != -1) { + v15 = pcursmonst; + goto LABEL_88; + } + _LOBYTE(v12) = pcursplr; + if (pcursplr == -1 || FriendlyMode) + goto LABEL_96; + v13 = CMD_ATTACKPID; + } + v12 = (char)v12; + goto LABEL_94; + } + if (pcursitem != -1 && pcurs == 1) { + _LOWORD(v3) = pcursitem; + NetSendCmdLocParam1(TRUE, (invflag == 0) + CMD_GOTOGETITEM, cursmx, cursmy, v3); + } + if (pcursmonst != -1) + NetSendCmdLocParam1(TRUE, CMD_TALKXY, cursmx, cursmy, pcursmonst); + v6 = pcursitem == -1; LABEL_98: - if (v6 && pcursmonst == -1 && pcursplr == -1) - return 1; - return 0; + if (v6 && pcursmonst == -1 && pcursplr == -1) + return 1; + return 0; } // 484368: using guessed type int FriendlyMode; // 4B84DC: using guessed type int dropGoldFlag; @@ -940,66 +940,66 @@ LABEL_98: bool __cdecl TryIconCurs() { - unsigned char v0; // dl - int v1; // edx - int v2; // eax - int v3; // eax - int v4; // ST0C_4 - int v5; // eax + unsigned char v0; // dl + int v1; // edx + int v2; // eax + int v3; // eax + int v4; // ST0C_4 + int v5; // eax - switch (pcurs) { - case CURSOR_RESURRECT: - v0 = CMD_RESURRECT; - LABEL_3: - NetSendCmdParam1(TRUE, v0, pcursplr); - return 1; - case CURSOR_HEALOTHER: - v0 = CMD_HEALOTHER; - goto LABEL_3; - case CURSOR_TELEKINESIS: - DoTelekinesis(); - return 1; - case CURSOR_IDENTIFY: - if (pcursinvitem != -1) { - CheckIdentify(myplr, pcursinvitem); - return 1; - } - LABEL_26: - SetCursor(CURSOR_HAND); - return 1; - case CURSOR_REPAIR: - if (pcursinvitem != -1) { - DoRepair(myplr, pcursinvitem); - return 1; - } - goto LABEL_26; - case CURSOR_RECHARGE: - if (pcursinvitem != -1) { - DoRecharge(myplr, pcursinvitem); - return 1; - } - goto LABEL_26; - case CURSOR_TELEPORT: - v1 = plr[myplr]._pTSpell; - if (pcursmonst == -1) { - if (pcursplr == -1) { - v4 = GetSpellLevel(myplr, v1); - v5 = 21720 * myplr; - _LOWORD(v5) = plr[myplr]._pTSpell; - NetSendCmdLocParam2(TRUE, CMD_TSPELLXY, cursmx, cursmy, v5, v4); - } else { - v3 = GetSpellLevel(myplr, v1); - NetSendCmdParam3(TRUE, CMD_TSPELLPID, pcursplr, plr[myplr]._pTSpell, v3); - } - } else { - v2 = GetSpellLevel(myplr, v1); - NetSendCmdParam3(TRUE, CMD_TSPELLID, pcursmonst, plr[myplr]._pTSpell, v2); - } - goto LABEL_26; - } - if (pcurs == CURSOR_DISARM && pcursobj == -1) - goto LABEL_26; - return 0; + switch (pcurs) { + case CURSOR_RESURRECT: + v0 = CMD_RESURRECT; + LABEL_3: + NetSendCmdParam1(TRUE, v0, pcursplr); + return 1; + case CURSOR_HEALOTHER: + v0 = CMD_HEALOTHER; + goto LABEL_3; + case CURSOR_TELEKINESIS: + DoTelekinesis(); + return 1; + case CURSOR_IDENTIFY: + if (pcursinvitem != -1) { + CheckIdentify(myplr, pcursinvitem); + return 1; + } + LABEL_26: + SetCursor(CURSOR_HAND); + return 1; + case CURSOR_REPAIR: + if (pcursinvitem != -1) { + DoRepair(myplr, pcursinvitem); + return 1; + } + goto LABEL_26; + case CURSOR_RECHARGE: + if (pcursinvitem != -1) { + DoRecharge(myplr, pcursinvitem); + return 1; + } + goto LABEL_26; + case CURSOR_TELEPORT: + v1 = plr[myplr]._pTSpell; + if (pcursmonst == -1) { + if (pcursplr == -1) { + v4 = GetSpellLevel(myplr, v1); + v5 = 21720 * myplr; + _LOWORD(v5) = plr[myplr]._pTSpell; + NetSendCmdLocParam2(TRUE, CMD_TSPELLXY, cursmx, cursmy, v5, v4); + } else { + v3 = GetSpellLevel(myplr, v1); + NetSendCmdParam3(TRUE, CMD_TSPELLPID, pcursplr, plr[myplr]._pTSpell, v3); + } + } else { + v2 = GetSpellLevel(myplr, v1); + NetSendCmdParam3(TRUE, CMD_TSPELLID, pcursmonst, plr[myplr]._pTSpell, v2); + } + goto LABEL_26; + } + if (pcurs == CURSOR_DISARM && pcursobj == -1) + goto LABEL_26; + return 0; } // 4B8CB8: using guessed type char pcursinvitem; // 4B8CC1: using guessed type char pcursobj; @@ -1007,16 +1007,16 @@ bool __cdecl TryIconCurs() void __cdecl LeftMouseUp() { - gmenu_left_mouse(0); - control_release_talk_btn(); - if (panbtndown) - CheckBtnUp(); - if (chrbtnactive) - ReleaseChrBtns(); - if (lvlbtndown) - ReleaseLvlBtn(); - if (stextflag) - ReleaseStoreBtn(); + gmenu_left_mouse(0); + control_release_talk_btn(); + if (panbtndown) + CheckBtnUp(); + if (chrbtnactive) + ReleaseChrBtns(); + if (lvlbtndown) + ReleaseLvlBtn(); + if (stextflag) + ReleaseStoreBtn(); } // 4B851C: using guessed type int lvlbtndown; // 4B87A8: using guessed type int chrbtnactive; @@ -1025,25 +1025,25 @@ void __cdecl LeftMouseUp() void __cdecl RightMouseDown() { - if (!gmenu_exception() && sgnTimeoutCurs == CURSOR_NONE && PauseMode != 2 && !plr[myplr]._pInvincible) { - if (doomflag) { - doom_close(); - } else if (!stextflag) { - if (spselflag) { - SetSpell(); - } else if (MouseY >= 352 - || (!sbookflag || MouseX <= 320) - && !TryIconCurs() - && (pcursinvitem == -1 || !UseInvItem(myplr, pcursinvitem))) { - if (pcurs == 1) { - if (pcursinvitem == -1 || !UseInvItem(myplr, pcursinvitem)) - CheckPlrSpell(); - } else if (pcurs > 1 && pcurs < 12) { - SetCursor(CURSOR_HAND); - } - } - } - } + if (!gmenu_exception() && sgnTimeoutCurs == CURSOR_NONE && PauseMode != 2 && !plr[myplr]._pInvincible) { + if (doomflag) { + doom_close(); + } else if (!stextflag) { + if (spselflag) { + SetSpell(); + } else if (MouseY >= 352 + || (!sbookflag || MouseX <= 320) + && !TryIconCurs() + && (pcursinvitem == -1 || !UseInvItem(myplr, pcursinvitem))) { + if (pcurs == 1) { + if (pcursinvitem == -1 || !UseInvItem(myplr, pcursinvitem)) + CheckPlrSpell(); + } else if (pcurs > 1 && pcurs < 12) { + SetCursor(CURSOR_HAND); + } + } + } + } } // 4B8968: using guessed type int sbookflag; // 4B8C98: using guessed type int spselflag; @@ -1054,30 +1054,30 @@ void __cdecl RightMouseDown() bool __fastcall PressSysKey(int wParam) { - if (gmenu_exception() || wParam != VK_F10) - return 0; - diablo_hotkey_msg(1); - return 1; + if (gmenu_exception() || wParam != VK_F10) + return 0; + diablo_hotkey_msg(1); + return 1; } void __fastcall diablo_hotkey_msg(int dwMsg) { - int v1; // esi - char *v2; // eax - char Filename[260]; // [esp+4h] [ebp-154h] - char ReturnedString[80]; // [esp+108h] [ebp-50h] + int v1; // esi + char *v2; // eax + char Filename[260]; // [esp+4h] [ebp-154h] + char ReturnedString[80]; // [esp+108h] [ebp-50h] - v1 = dwMsg; - if (gbMaxPlayers != 1) { - if (!GetModuleFileName(ghInst, Filename, 0x104u)) - TermMsg("Can't get program name"); - v2 = strrchr(Filename, '\\'); - if (v2) - *v2 = 0; - strcat(Filename, "\\Diablo.ini"); - GetPrivateProfileString("NetMsg", spszMsgKeyTbl[v1], spszMsgTbl[v1], ReturnedString, 0x50u, Filename); - NetSendCmdString(-1, ReturnedString); - } + v1 = dwMsg; + if (gbMaxPlayers != 1) { + if (!GetModuleFileName(ghInst, Filename, 0x104u)) + TermMsg("Can't get program name"); + v2 = strrchr(Filename, '\\'); + if (v2) + *v2 = 0; + strcat(Filename, "\\Diablo.ini"); + GetPrivateProfileString("NetMsg", spszMsgKeyTbl[v1], spszMsgTbl[v1], ReturnedString, 0x50u, Filename); + NetSendCmdString(-1, ReturnedString); + } } // 48436C: using guessed type char *spszMsgTbl[4]; // 48437C: using guessed type char *spszMsgKeyTbl[4]; @@ -1085,206 +1085,206 @@ void __fastcall diablo_hotkey_msg(int dwMsg) void __fastcall ReleaseKey(int vkey) { - if (vkey == VK_SNAPSHOT) - CaptureScreen(); + if (vkey == VK_SNAPSHOT) + CaptureScreen(); } void __fastcall PressKey(int vkey) { - int v1; // esi - int v2; // ecx - int v3; // ecx - signed int v4; // eax + int v1; // esi + int v2; // ecx + int v3; // ecx + signed int v4; // eax - v1 = vkey; - if (!gmenu_presskeys(vkey) && !control_presskeys(v1)) { - if (!deathflag) - goto LABEL_113; - if (sgnTimeoutCurs == CURSOR_NONE) { - if (v1 == VK_F9) - diablo_hotkey_msg(0); - if (v1 == VK_F10) - diablo_hotkey_msg(1); - if (v1 == VK_F11) - diablo_hotkey_msg(2); - if (v1 == VK_F12) - diablo_hotkey_msg(3); - if (v1 == VK_RETURN) - control_type_message(); - if (v1 == VK_ESCAPE) { - LABEL_113: - if (v1 == VK_ESCAPE) { - if (!PressEscKey()) { - track_repeat_walk(0); - gamemenu_previous(); - } - return; - } - if (sgnTimeoutCurs == CURSOR_NONE && !dropGoldFlag) { - if (v1 == VK_PAUSE) { - diablo_pause_game(); - return; - } - if (PauseMode != 2) { - switch (v1) { - case VK_RETURN: - if (stextflag) { - STextEnter(); - } else if (questlog) { - QuestlogEnter(); - } else { - control_type_message(); - } - return; - case VK_F1: - if (helpflag) { - helpflag = 0; - return; - } - if (stextflag) { - ClearPanel(); - AddPanelString("No help available", 1); - AddPanelString("while in stores", 1); - track_repeat_walk(0); - return; - } - invflag = 0; - chrflag = 0; - sbookflag = 0; - spselflag = 0; - if (qtextflag && leveltype == DTYPE_TOWN) { - qtextflag = FALSE; - sfx_stop(); - } - questlog = 0; - automapflag = 0; - msgdelay = 0; - gamemenu_off(); - DisplayHelp(); - LABEL_110: - doom_close(); - return; + v1 = vkey; + if (!gmenu_presskeys(vkey) && !control_presskeys(v1)) { + if (!deathflag) + goto LABEL_113; + if (sgnTimeoutCurs == CURSOR_NONE) { + if (v1 == VK_F9) + diablo_hotkey_msg(0); + if (v1 == VK_F10) + diablo_hotkey_msg(1); + if (v1 == VK_F11) + diablo_hotkey_msg(2); + if (v1 == VK_F12) + diablo_hotkey_msg(3); + if (v1 == VK_RETURN) + control_type_message(); + if (v1 == VK_ESCAPE) { + LABEL_113: + if (v1 == VK_ESCAPE) { + if (!PressEscKey()) { + track_repeat_walk(0); + gamemenu_previous(); + } + return; + } + if (sgnTimeoutCurs == CURSOR_NONE && !dropGoldFlag) { + if (v1 == VK_PAUSE) { + diablo_pause_game(); + return; + } + if (PauseMode != 2) { + switch (v1) { + case VK_RETURN: + if (stextflag) { + STextEnter(); + } else if (questlog) { + QuestlogEnter(); + } else { + control_type_message(); + } + return; + case VK_F1: + if (helpflag) { + helpflag = 0; + return; + } + if (stextflag) { + ClearPanel(); + AddPanelString("No help available", 1); + AddPanelString("while in stores", 1); + track_repeat_walk(0); + return; + } + invflag = 0; + chrflag = 0; + sbookflag = 0; + spselflag = 0; + if (qtextflag && leveltype == DTYPE_TOWN) { + qtextflag = FALSE; + sfx_stop(); + } + questlog = 0; + automapflag = 0; + msgdelay = 0; + gamemenu_off(); + DisplayHelp(); + LABEL_110: + doom_close(); + return; #ifdef _DEBUG - case VK_F3: - if (pcursitem != -1) { - sprintf(tempstr, "IDX = %i : Seed = %i : CF = %i", item[pcursitem].IDidx, item[pcursitem]._iSeed, item[pcursitem]._iCreateInfo); - NetSendCmdString(1 << myplr, tempstr); - } - sprintf(tempstr, "Numitems : %i", numitems); - NetSendCmdString(1 << myplr, tempstr); - return; - case VK_F4: - PrintDebugQuest(); - return; + case VK_F3: + if (pcursitem != -1) { + sprintf(tempstr, "IDX = %i : Seed = %i : CF = %i", item[pcursitem].IDidx, item[pcursitem]._iSeed, item[pcursitem]._iCreateInfo); + NetSendCmdString(1 << myplr, tempstr); + } + sprintf(tempstr, "Numitems : %i", numitems); + NetSendCmdString(1 << myplr, tempstr); + return; + case VK_F4: + PrintDebugQuest(); + return; #endif - case VK_F5: - v2 = 0; - goto LABEL_48; - case VK_F6: - v2 = 1; - goto LABEL_48; - case VK_F7: - v2 = 2; - goto LABEL_48; - case VK_F8: - v2 = 3; - LABEL_48: - if (spselflag) - SetSpeedSpell(v2); - else - ToggleSpell(v2); - return; - case VK_F9: - v3 = 0; - LABEL_59: - diablo_hotkey_msg(v3); - return; - case VK_F10: - v3 = 1; - goto LABEL_59; - case VK_F11: - v3 = 2; - goto LABEL_59; - case VK_F12: - v3 = 3; - goto LABEL_59; - case VK_UP: - if (stextflag) { - STextUp(); - } else if (questlog) { - QuestlogUp(); - } else if (helpflag) { - HelpScrollUp(); - } else if (automapflag) { - AutomapUp(); - } - return; - case VK_DOWN: - if (stextflag) { - STextDown(); - } else if (questlog) { - QuestlogDown(); - } else if (helpflag) { - HelpScrollDown(); - } else if (automapflag) { - AutomapDown(); - } - return; - case VK_PRIOR: - if (stextflag) - STextPrior(); - return; - case VK_NEXT: - if (stextflag) - STextNext(); - return; - case VK_LEFT: - if (automapflag && !talkflag) - AutomapLeft(); - return; - case VK_RIGHT: - if (automapflag && !talkflag) - AutomapRight(); - return; - case VK_TAB: - DoAutoMap(); - return; - case VK_SPACE: - if (!chrflag) { - if (!invflag) { - LABEL_106: - helpflag = 0; - invflag = 0; - chrflag = 0; - sbookflag = 0; - spselflag = 0; - if (qtextflag && leveltype == DTYPE_TOWN) { - qtextflag = FALSE; - sfx_stop(); - } - questlog = 0; - automapflag = 0; - msgdelay = 0; - gamemenu_off(); - goto LABEL_110; - } - v4 = MouseX; - if (MouseX >= 480 || MouseY >= 352) { - LABEL_101: - if (!invflag && chrflag && v4 > 160 && MouseY < 352) - SetCursorPos(v4 - 160, MouseY); - goto LABEL_106; - } - SetCursorPos(MouseX + 160, MouseY); - } - v4 = MouseX; - goto LABEL_101; - } - } - } - } - } - } + case VK_F5: + v2 = 0; + goto LABEL_48; + case VK_F6: + v2 = 1; + goto LABEL_48; + case VK_F7: + v2 = 2; + goto LABEL_48; + case VK_F8: + v2 = 3; + LABEL_48: + if (spselflag) + SetSpeedSpell(v2); + else + ToggleSpell(v2); + return; + case VK_F9: + v3 = 0; + LABEL_59: + diablo_hotkey_msg(v3); + return; + case VK_F10: + v3 = 1; + goto LABEL_59; + case VK_F11: + v3 = 2; + goto LABEL_59; + case VK_F12: + v3 = 3; + goto LABEL_59; + case VK_UP: + if (stextflag) { + STextUp(); + } else if (questlog) { + QuestlogUp(); + } else if (helpflag) { + HelpScrollUp(); + } else if (automapflag) { + AutomapUp(); + } + return; + case VK_DOWN: + if (stextflag) { + STextDown(); + } else if (questlog) { + QuestlogDown(); + } else if (helpflag) { + HelpScrollDown(); + } else if (automapflag) { + AutomapDown(); + } + return; + case VK_PRIOR: + if (stextflag) + STextPrior(); + return; + case VK_NEXT: + if (stextflag) + STextNext(); + return; + case VK_LEFT: + if (automapflag && !talkflag) + AutomapLeft(); + return; + case VK_RIGHT: + if (automapflag && !talkflag) + AutomapRight(); + return; + case VK_TAB: + DoAutoMap(); + return; + case VK_SPACE: + if (!chrflag) { + if (!invflag) { + LABEL_106: + helpflag = 0; + invflag = 0; + chrflag = 0; + sbookflag = 0; + spselflag = 0; + if (qtextflag && leveltype == DTYPE_TOWN) { + qtextflag = FALSE; + sfx_stop(); + } + questlog = 0; + automapflag = 0; + msgdelay = 0; + gamemenu_off(); + goto LABEL_110; + } + v4 = MouseX; + if (MouseX >= 480 || MouseY >= 352) { + LABEL_101: + if (!invflag && chrflag && v4 > 160 && MouseY < 352) + SetCursorPos(v4 - 160, MouseY); + goto LABEL_106; + } + SetCursorPos(MouseX + 160, MouseY); + } + v4 = MouseX; + goto LABEL_101; + } + } + } + } + } + } } // 4B84DC: using guessed type int dropGoldFlag; // 4B8960: using guessed type int talkflag; @@ -1298,16 +1298,16 @@ void __fastcall PressKey(int vkey) void __cdecl diablo_pause_game() { - if ((unsigned char)gbMaxPlayers <= 1u) { - if (PauseMode) { - PauseMode = 0; - } else { - PauseMode = 2; - FreeMonsterSnd(); - track_repeat_walk(0); - } - drawpanflag = 255; - } + if ((unsigned char)gbMaxPlayers <= 1u) { + if (PauseMode) { + PauseMode = 0; + } else { + PauseMode = 2; + FreeMonsterSnd(); + track_repeat_walk(0); + } + drawpanflag = 255; + } } // 52571C: using guessed type int drawpanflag; // 525740: using guessed type int PauseMode; @@ -1315,300 +1315,300 @@ void __cdecl diablo_pause_game() void __fastcall PressChar(int vkey) { - int v1; // ebx - BOOL v4; // ecx - int v5; // ecx - int v6; // eax - BOOL v7; // ecx - int v9; // ecx - int v10; // eax - int v11; // eax - int v12; // eax - int v13; // eax - int v14; // eax - int v15; // eax - int v16; // eax - int v18; // [esp-4h] [ebp-8h] + int v1; // ebx + BOOL v4; // ecx + int v5; // ecx + int v6; // eax + BOOL v7; // ecx + int v9; // ecx + int v10; // eax + int v11; // eax + int v12; // eax + int v13; // eax + int v14; // eax + int v15; // eax + int v16; // eax + int v18; // [esp-4h] [ebp-8h] - v1 = vkey; - if (!gmenu_exception() && !control_talk_last_key(v1) && sgnTimeoutCurs == CURSOR_NONE && !deathflag) { - if ((_BYTE)v1 == 'p' || (_BYTE)v1 == 'P') { - diablo_pause_game(); - } else if (PauseMode != 2) { - if (doomflag) { - doom_close(); - return; - } - if (dropGoldFlag) { - control_drop_gold(v1); - return; - } - switch (v1) { - case '!': - case '1': - v9 = myplr; - v10 = plr[myplr].SpdList[0]._itype; - if (v10 != -1 && v10 != 11) { - v18 = 47; - goto LABEL_72; - } - return; - case '#': - case '3': - v9 = myplr; - v12 = plr[myplr].SpdList[2]._itype; - if (v12 != -1 && v12 != 11) { - v18 = 49; - goto LABEL_72; - } - return; - case '$': - case '4': - v9 = myplr; - v13 = plr[myplr].SpdList[3]._itype; - if (v13 != -1 && v13 != 11) { - v18 = 50; - goto LABEL_72; - } - return; - case '%': - case '5': - v9 = myplr; - v14 = plr[myplr].SpdList[4]._itype; - if (v14 != -1 && v14 != 11) { - v18 = 51; - goto LABEL_72; - } - return; - case '&': - case '7': - v9 = myplr; - v16 = plr[myplr].SpdList[6]._itype; - if (v16 != -1 && v16 != 11) { - v18 = 53; - goto LABEL_72; - } - return; - case '*': - case '8': + v1 = vkey; + if (!gmenu_exception() && !control_talk_last_key(v1) && sgnTimeoutCurs == CURSOR_NONE && !deathflag) { + if ((_BYTE)v1 == 'p' || (_BYTE)v1 == 'P') { + diablo_pause_game(); + } else if (PauseMode != 2) { + if (doomflag) { + doom_close(); + return; + } + if (dropGoldFlag) { + control_drop_gold(v1); + return; + } + switch (v1) { + case '!': + case '1': + v9 = myplr; + v10 = plr[myplr].SpdList[0]._itype; + if (v10 != -1 && v10 != 11) { + v18 = 47; + goto LABEL_72; + } + return; + case '#': + case '3': + v9 = myplr; + v12 = plr[myplr].SpdList[2]._itype; + if (v12 != -1 && v12 != 11) { + v18 = 49; + goto LABEL_72; + } + return; + case '$': + case '4': + v9 = myplr; + v13 = plr[myplr].SpdList[3]._itype; + if (v13 != -1 && v13 != 11) { + v18 = 50; + goto LABEL_72; + } + return; + case '%': + case '5': + v9 = myplr; + v14 = plr[myplr].SpdList[4]._itype; + if (v14 != -1 && v14 != 11) { + v18 = 51; + goto LABEL_72; + } + return; + case '&': + case '7': + v9 = myplr; + v16 = plr[myplr].SpdList[6]._itype; + if (v16 != -1 && v16 != 11) { + v18 = 53; + goto LABEL_72; + } + return; + case '*': + case '8': #ifdef _DEBUG - if (debug_mode_key_inverted_v || debug_mode_key_w) { - NetSendCmd(TRUE, CMD_CHEAT_EXPERIENCE); - return; - } + if (debug_mode_key_inverted_v || debug_mode_key_w) { + NetSendCmd(TRUE, CMD_CHEAT_EXPERIENCE); + return; + } #endif - v9 = myplr; - if (plr[myplr].SpdList[7]._itype != -1 - && plr[myplr].SpdList[7]._itype != 11) { - v18 = 54; - goto LABEL_72; - } - return; - case '+': - case '=': - if (automapflag) - AutomapZoomIn(); - return; - case '-': - case '_': - if (automapflag) - AutomapZoomOut(); - return; - case '2': - case '@': - v9 = myplr; - v11 = plr[myplr].SpdList[1]._itype; - if (v11 != -1 && v11 != 11) { - v18 = 48; - goto LABEL_72; - } - return; - case '6': - case '^': - v9 = myplr; - v15 = plr[myplr].SpdList[5]._itype; - if (v15 != -1 && v15 != 11) { - v18 = 52; - LABEL_72: - UseInvItem(v9, v18); - } - return; - case 'B': - case 'b': - if (!stextflag) { - invflag = 0; - sbookflag = sbookflag == 0; - } - return; - case 'C': - case 'c': - if (!stextflag) { - questlog = 0; - v7 = chrflag == 0; - chrflag = chrflag == 0; - if (!v7 || invflag) - goto LABEL_18; - goto LABEL_24; - } - return; - case 'F': - case 'f': - IncreaseGamma(); - return; - case 'G': - case 'g': - DecreaseGamma(); - return; - case 'I': - case 'i': - if (stextflag) - return; - sbookflag = 0; - v4 = invflag == 0; - invflag = invflag == 0; - if (!v4 || chrflag) { - LABEL_24: - if (MouseX < 480) { - v5 = MouseY; - if (MouseY < 352) { - v6 = MouseX + 160; - goto LABEL_27; - } - } - } else { - LABEL_18: - if (MouseX > 160) { - v5 = MouseY; - if (MouseY < 352) { - v6 = MouseX - 160; - LABEL_27: - SetCursorPos(v6, v5); - return; - } - } - } - break; - case 'Q': - case 'q': - if (!stextflag) { - chrflag = 0; - if (questlog) - questlog = 0; - else - StartQuestlog(); - } - return; - case 'S': - case 's': - if (!stextflag) { - invflag = 0; - if (spselflag) - spselflag = 0; - else - DoSpeedBook(); - track_repeat_walk(0); - } - return; - case 'V': - NetSendCmdString(1 << myplr, gszVersionNumber); - return; - case 'v': - NetSendCmdString(1 << myplr, gszProductName); - return; - case 'Z': - case 'z': - zoomflag = zoomflag == 0; - return; + v9 = myplr; + if (plr[myplr].SpdList[7]._itype != -1 + && plr[myplr].SpdList[7]._itype != 11) { + v18 = 54; + goto LABEL_72; + } + return; + case '+': + case '=': + if (automapflag) + AutomapZoomIn(); + return; + case '-': + case '_': + if (automapflag) + AutomapZoomOut(); + return; + case '2': + case '@': + v9 = myplr; + v11 = plr[myplr].SpdList[1]._itype; + if (v11 != -1 && v11 != 11) { + v18 = 48; + goto LABEL_72; + } + return; + case '6': + case '^': + v9 = myplr; + v15 = plr[myplr].SpdList[5]._itype; + if (v15 != -1 && v15 != 11) { + v18 = 52; + LABEL_72: + UseInvItem(v9, v18); + } + return; + case 'B': + case 'b': + if (!stextflag) { + invflag = 0; + sbookflag = sbookflag == 0; + } + return; + case 'C': + case 'c': + if (!stextflag) { + questlog = 0; + v7 = chrflag == 0; + chrflag = chrflag == 0; + if (!v7 || invflag) + goto LABEL_18; + goto LABEL_24; + } + return; + case 'F': + case 'f': + IncreaseGamma(); + return; + case 'G': + case 'g': + DecreaseGamma(); + return; + case 'I': + case 'i': + if (stextflag) + return; + sbookflag = 0; + v4 = invflag == 0; + invflag = invflag == 0; + if (!v4 || chrflag) { + LABEL_24: + if (MouseX < 480) { + v5 = MouseY; + if (MouseY < 352) { + v6 = MouseX + 160; + goto LABEL_27; + } + } + } else { + LABEL_18: + if (MouseX > 160) { + v5 = MouseY; + if (MouseY < 352) { + v6 = MouseX - 160; + LABEL_27: + SetCursorPos(v6, v5); + return; + } + } + } + break; + case 'Q': + case 'q': + if (!stextflag) { + chrflag = 0; + if (questlog) + questlog = 0; + else + StartQuestlog(); + } + return; + case 'S': + case 's': + if (!stextflag) { + invflag = 0; + if (spselflag) + spselflag = 0; + else + DoSpeedBook(); + track_repeat_walk(0); + } + return; + case 'V': + NetSendCmdString(1 << myplr, gszVersionNumber); + return; + case 'v': + NetSendCmdString(1 << myplr, gszProductName); + return; + case 'Z': + case 'z': + zoomflag = zoomflag == 0; + return; #ifdef _DEBUG - case ')': - case '0': - if (debug_mode_key_inverted_v) { - if (arrowdebug > 2) - arrowdebug = 0; - if (!arrowdebug) { - plr[myplr]._pIFlags &= ~ISPL_FIRE_ARROWS; - plr[myplr]._pIFlags &= ~ISPL_LIGHT_ARROWS; - } - if (arrowdebug == 1) - plr[myplr]._pIFlags |= ISPL_FIRE_ARROWS; - if (arrowdebug == 2) - plr[myplr]._pIFlags |= ISPL_LIGHT_ARROWS; - arrowdebug++; - } - return; - case ':': - if (!currlevel && debug_mode_key_w) - SetAllSpellsCheat(); - return; - case '[': - if (!currlevel && debug_mode_key_w) - TakeGoldCheat(); - return; - case ']': - if (!currlevel && debug_mode_key_w) - MaxSpellsCheat(); - return; - case 'a': - if (debug_mode_key_inverted_v) { - spelldata[SPL_TELEPORT].sTownSpell = TRUE; - plr[myplr]._pSplLvl[plr[myplr]._pSpell]++; - } - return; - case 'D': - PrintDebugPlayer(1); - return; - case 'd': - PrintDebugPlayer(0); - return; - case 'e': - if (debug_mode_key_d) { - sprintf(tempstr, "EFlag = %i", plr[myplr]._peflag); - NetSendCmdString(1 << myplr, tempstr); - } - return; - case 'L': - case 'l': - if (debug_mode_key_inverted_v) - ToggleLighting(); - return; - case 'M': - NextDebugMonster(); - return; - case 'm': - GetDebugMonster(); - return; - case 'R': - case 'r': - sprintf(tempstr, "seed = %i", glSeedTbl[currlevel]); - NetSendCmdString(1 << myplr, tempstr); - sprintf(tempstr, "Mid1 = %i : Mid2 = %i : Mid3 = %i", glMid1Seed[currlevel], glMid2Seed[currlevel], glMid3Seed[currlevel]); - NetSendCmdString(1 << myplr, tempstr); - sprintf(tempstr, "End = %i", glEndSeed[currlevel]); - NetSendCmdString(1 << myplr, tempstr); - return; - case 'T': - case 't': - if (debug_mode_key_inverted_v) { - sprintf(tempstr, "PX = %i PY = %i", plr[myplr].WorldX, plr[myplr].WorldY); - NetSendCmdString(1 << myplr, tempstr); - sprintf(tempstr, "CX = %i CY = %i DP = %i", cursmx, cursmy, dungeon[cursmx][cursmy]); - NetSendCmdString(1 << myplr, tempstr); - } - return; - case '|': - if (!currlevel && debug_mode_key_w) - GiveGoldCheat(); - return; - case '~': - if (!currlevel && debug_mode_key_w) - StoresCheat(); - return; + case ')': + case '0': + if (debug_mode_key_inverted_v) { + if (arrowdebug > 2) + arrowdebug = 0; + if (!arrowdebug) { + plr[myplr]._pIFlags &= ~ISPL_FIRE_ARROWS; + plr[myplr]._pIFlags &= ~ISPL_LIGHT_ARROWS; + } + if (arrowdebug == 1) + plr[myplr]._pIFlags |= ISPL_FIRE_ARROWS; + if (arrowdebug == 2) + plr[myplr]._pIFlags |= ISPL_LIGHT_ARROWS; + arrowdebug++; + } + return; + case ':': + if (!currlevel && debug_mode_key_w) + SetAllSpellsCheat(); + return; + case '[': + if (!currlevel && debug_mode_key_w) + TakeGoldCheat(); + return; + case ']': + if (!currlevel && debug_mode_key_w) + MaxSpellsCheat(); + return; + case 'a': + if (debug_mode_key_inverted_v) { + spelldata[SPL_TELEPORT].sTownSpell = TRUE; + plr[myplr]._pSplLvl[plr[myplr]._pSpell]++; + } + return; + case 'D': + PrintDebugPlayer(1); + return; + case 'd': + PrintDebugPlayer(0); + return; + case 'e': + if (debug_mode_key_d) { + sprintf(tempstr, "EFlag = %i", plr[myplr]._peflag); + NetSendCmdString(1 << myplr, tempstr); + } + return; + case 'L': + case 'l': + if (debug_mode_key_inverted_v) + ToggleLighting(); + return; + case 'M': + NextDebugMonster(); + return; + case 'm': + GetDebugMonster(); + return; + case 'R': + case 'r': + sprintf(tempstr, "seed = %i", glSeedTbl[currlevel]); + NetSendCmdString(1 << myplr, tempstr); + sprintf(tempstr, "Mid1 = %i : Mid2 = %i : Mid3 = %i", glMid1Seed[currlevel], glMid2Seed[currlevel], glMid3Seed[currlevel]); + NetSendCmdString(1 << myplr, tempstr); + sprintf(tempstr, "End = %i", glEndSeed[currlevel]); + NetSendCmdString(1 << myplr, tempstr); + return; + case 'T': + case 't': + if (debug_mode_key_inverted_v) { + sprintf(tempstr, "PX = %i PY = %i", plr[myplr].WorldX, plr[myplr].WorldY); + NetSendCmdString(1 << myplr, tempstr); + sprintf(tempstr, "CX = %i CY = %i DP = %i", cursmx, cursmy, dungeon[cursmx][cursmy]); + NetSendCmdString(1 << myplr, tempstr); + } + return; + case '|': + if (!currlevel && debug_mode_key_w) + GiveGoldCheat(); + return; + case '~': + if (!currlevel && debug_mode_key_w) + StoresCheat(); + return; #endif - default: - return; - } - } - } + default: + return; + } + } + } } // 4B84DC: using guessed type int dropGoldFlag; // 4B8968: using guessed type int sbookflag; @@ -1621,301 +1621,301 @@ void __fastcall PressChar(int vkey) void __cdecl LoadLvlGFX() { - switch (leveltype) { - case DTYPE_TOWN: - pDungeonCels = LoadFileInMem("Levels\\TownData\\Town.CEL", 0); - pMegaTiles = LoadFileInMem("Levels\\TownData\\Town.TIL", 0); - pLevelPieces = LoadFileInMem("Levels\\TownData\\Town.MIN", 0); - level_special_cel = LoadFileInMem("Levels\\TownData\\TownS.CEL", 0); - break; - case DTYPE_CATHEDRAL: - pDungeonCels = LoadFileInMem("Levels\\L1Data\\L1.CEL", 0); - pMegaTiles = LoadFileInMem("Levels\\L1Data\\L1.TIL", 0); - pLevelPieces = LoadFileInMem("Levels\\L1Data\\L1.MIN", 0); - level_special_cel = LoadFileInMem("Levels\\L1Data\\L1S.CEL", 0); - break; - case DTYPE_CATACOMBS: - pDungeonCels = LoadFileInMem("Levels\\L2Data\\L2.CEL", 0); - pMegaTiles = LoadFileInMem("Levels\\L2Data\\L2.TIL", 0); - pLevelPieces = LoadFileInMem("Levels\\L2Data\\L2.MIN", 0); - level_special_cel = LoadFileInMem("Levels\\L2Data\\L2S.CEL", 0); - break; - case DTYPE_CAVES: - pDungeonCels = LoadFileInMem("Levels\\L3Data\\L3.CEL", 0); - pMegaTiles = LoadFileInMem("Levels\\L3Data\\L3.TIL", 0); - pLevelPieces = LoadFileInMem("Levels\\L3Data\\L3.MIN", 0); - level_special_cel = LoadFileInMem("Levels\\L1Data\\L1S.CEL", 0); - break; - case DTYPE_HELL: - pDungeonCels = LoadFileInMem("Levels\\L4Data\\L4.CEL", 0); - pMegaTiles = LoadFileInMem("Levels\\L4Data\\L4.TIL", 0); - pLevelPieces = LoadFileInMem("Levels\\L4Data\\L4.MIN", 0); - level_special_cel = LoadFileInMem("Levels\\L2Data\\L2S.CEL", 0); - break; - default: - TermMsg("LoadLvlGFX"); - return; - } + switch (leveltype) { + case DTYPE_TOWN: + pDungeonCels = LoadFileInMem("Levels\\TownData\\Town.CEL", 0); + pMegaTiles = LoadFileInMem("Levels\\TownData\\Town.TIL", 0); + pLevelPieces = LoadFileInMem("Levels\\TownData\\Town.MIN", 0); + level_special_cel = LoadFileInMem("Levels\\TownData\\TownS.CEL", 0); + break; + case DTYPE_CATHEDRAL: + pDungeonCels = LoadFileInMem("Levels\\L1Data\\L1.CEL", 0); + pMegaTiles = LoadFileInMem("Levels\\L1Data\\L1.TIL", 0); + pLevelPieces = LoadFileInMem("Levels\\L1Data\\L1.MIN", 0); + level_special_cel = LoadFileInMem("Levels\\L1Data\\L1S.CEL", 0); + break; + case DTYPE_CATACOMBS: + pDungeonCels = LoadFileInMem("Levels\\L2Data\\L2.CEL", 0); + pMegaTiles = LoadFileInMem("Levels\\L2Data\\L2.TIL", 0); + pLevelPieces = LoadFileInMem("Levels\\L2Data\\L2.MIN", 0); + level_special_cel = LoadFileInMem("Levels\\L2Data\\L2S.CEL", 0); + break; + case DTYPE_CAVES: + pDungeonCels = LoadFileInMem("Levels\\L3Data\\L3.CEL", 0); + pMegaTiles = LoadFileInMem("Levels\\L3Data\\L3.TIL", 0); + pLevelPieces = LoadFileInMem("Levels\\L3Data\\L3.MIN", 0); + level_special_cel = LoadFileInMem("Levels\\L1Data\\L1S.CEL", 0); + break; + case DTYPE_HELL: + pDungeonCels = LoadFileInMem("Levels\\L4Data\\L4.CEL", 0); + pMegaTiles = LoadFileInMem("Levels\\L4Data\\L4.TIL", 0); + pLevelPieces = LoadFileInMem("Levels\\L4Data\\L4.MIN", 0); + level_special_cel = LoadFileInMem("Levels\\L2Data\\L2S.CEL", 0); + break; + default: + TermMsg("LoadLvlGFX"); + return; + } } void __cdecl LoadAllGFX() { - pSpeedCels = DiabloAllocPtr(0x100000); - IncProgress(); - IncProgress(); - InitObjectGFX(); - IncProgress(); - InitMissileGFX(); - IncProgress(); + pSpeedCels = DiabloAllocPtr(0x100000); + IncProgress(); + IncProgress(); + InitObjectGFX(); + IncProgress(); + InitMissileGFX(); + IncProgress(); } void __fastcall CreateLevel(int lvldir) { - int hnd; // cl + int hnd; // cl - switch (leveltype) { - case DTYPE_TOWN: - CreateTown(lvldir); - InitTownTriggers(); - hnd = 0; - break; - case DTYPE_CATHEDRAL: - CreateL5Dungeon(glSeedTbl[currlevel], lvldir); - InitL1Triggers(); - Freeupstairs(); - hnd = 1; - break; - case DTYPE_CATACOMBS: - CreateL2Dungeon(glSeedTbl[currlevel], lvldir); - InitL2Triggers(); - Freeupstairs(); - hnd = 2; - break; - case DTYPE_CAVES: - CreateL3Dungeon(glSeedTbl[currlevel], lvldir); - InitL3Triggers(); - Freeupstairs(); - hnd = 3; - break; - case DTYPE_HELL: - CreateL4Dungeon(glSeedTbl[currlevel], lvldir); - InitL4Triggers(); - Freeupstairs(); - hnd = 4; - break; - default: - TermMsg("CreateLevel"); - return; - } + switch (leveltype) { + case DTYPE_TOWN: + CreateTown(lvldir); + InitTownTriggers(); + hnd = 0; + break; + case DTYPE_CATHEDRAL: + CreateL5Dungeon(glSeedTbl[currlevel], lvldir); + InitL1Triggers(); + Freeupstairs(); + hnd = 1; + break; + case DTYPE_CATACOMBS: + CreateL2Dungeon(glSeedTbl[currlevel], lvldir); + InitL2Triggers(); + Freeupstairs(); + hnd = 2; + break; + case DTYPE_CAVES: + CreateL3Dungeon(glSeedTbl[currlevel], lvldir); + InitL3Triggers(); + Freeupstairs(); + hnd = 3; + break; + case DTYPE_HELL: + CreateL4Dungeon(glSeedTbl[currlevel], lvldir); + InitL4Triggers(); + Freeupstairs(); + hnd = 4; + break; + default: + TermMsg("CreateLevel"); + return; + } - LoadRndLvlPal(hnd); + LoadRndLvlPal(hnd); } void __fastcall LoadGameLevel(BOOL firstflag, int lvldir) { - int v2; // ebp - bool visited; // edx - int i; // ecx - int j; // eax + int v2; // ebp + bool visited; // edx + int i; // ecx + int j; // eax - v2 = 0; - if (setseed) - glSeedTbl[currlevel] = setseed; - music_stop(); - SetCursor(CURSOR_HAND); - SetRndSeed(glSeedTbl[currlevel]); - IncProgress(); - MakeLightTable(); - LoadLvlGFX(); - IncProgress(); - if (firstflag) { - InitInv(); - InitItemGFX(); - InitQuestText(); + v2 = 0; + if (setseed) + glSeedTbl[currlevel] = setseed; + music_stop(); + SetCursor(CURSOR_HAND); + SetRndSeed(glSeedTbl[currlevel]); + IncProgress(); + MakeLightTable(); + LoadLvlGFX(); + IncProgress(); + if (firstflag) { + InitInv(); + InitItemGFX(); + InitQuestText(); - if (gbMaxPlayers) { - for (i = 0; i < gbMaxPlayers; i++) - InitPlrGFXMem(i); - } + if (gbMaxPlayers) { + for (i = 0; i < gbMaxPlayers; i++) + InitPlrGFXMem(i); + } - InitStores(); - InitAutomapOnce(); - InitHelp(); - } - SetRndSeed(glSeedTbl[currlevel]); - if (leveltype == DTYPE_TOWN) - SetupTownStores(); - IncProgress(); - InitAutomap(); - if (leveltype != DTYPE_TOWN && lvldir != 4) { - InitLighting(); - InitVision(); - } - InitLevelMonsters(); - IncProgress(); - if (!setlevel) { - CreateLevel(lvldir); - IncProgress(); - FillSolidBlockTbls(); - SetRndSeed(glSeedTbl[currlevel]); - if (leveltype != DTYPE_TOWN) { - GetLevelMTypes(); - InitThemes(); - LoadAllGFX(); - } else { - InitMissileGFX(); - } - IncProgress(); - if (lvldir == 3) - GetReturnLvlPos(); - if (lvldir == 5) - GetPortalLvlPos(); - IncProgress(); + InitStores(); + InitAutomapOnce(); + InitHelp(); + } + SetRndSeed(glSeedTbl[currlevel]); + if (leveltype == DTYPE_TOWN) + SetupTownStores(); + IncProgress(); + InitAutomap(); + if (leveltype != DTYPE_TOWN && lvldir != 4) { + InitLighting(); + InitVision(); + } + InitLevelMonsters(); + IncProgress(); + if (!setlevel) { + CreateLevel(lvldir); + IncProgress(); + FillSolidBlockTbls(); + SetRndSeed(glSeedTbl[currlevel]); + if (leveltype != DTYPE_TOWN) { + GetLevelMTypes(); + InitThemes(); + LoadAllGFX(); + } else { + InitMissileGFX(); + } + IncProgress(); + if (lvldir == 3) + GetReturnLvlPos(); + if (lvldir == 5) + GetPortalLvlPos(); + IncProgress(); - for (i = 0; i < MAX_PLRS; i++) { - if (plr[i].plractive) { - if (currlevel == plr[i].plrlevel) { - InitPlayerGFX(v2); - if (lvldir != 4) - InitPlayer(v2, firstflag); - } - } - ++v2; - } + for (i = 0; i < MAX_PLRS; i++) { + if (plr[i].plractive) { + if (currlevel == plr[i].plrlevel) { + InitPlayerGFX(v2); + if (lvldir != 4) + InitPlayer(v2, firstflag); + } + } + ++v2; + } - PlayDungMsgs(); - InitMultiView(); - IncProgress(); + PlayDungMsgs(); + InitMultiView(); + IncProgress(); - visited = 0; - if (gbMaxPlayers > 0) { - for (i = 0; i < gbMaxPlayers; i++) { - if (plr[i].plractive) - visited = visited || plr[i]._pLvlVisited[currlevel]; - } - } - SetRndSeed(glSeedTbl[currlevel]); - if (leveltype != DTYPE_TOWN) { - if (firstflag || lvldir == 4 || !plr[myplr]._pLvlVisited[currlevel] || gbMaxPlayers != 1) { - HoldThemeRooms(); - glMid1Seed[currlevel] = GetRndSeed(); - InitMonsters(); - glMid2Seed[currlevel] = GetRndSeed(); - InitObjects(); - InitItems(); - CreateThemeRooms(); - glMid3Seed[currlevel] = GetRndSeed(); - InitMissiles(); - InitDead(); - glEndSeed[currlevel] = GetRndSeed(); - if (gbMaxPlayers != 1) - DeltaLoadLevel(); - IncProgress(); - SavePreLighting(); - goto LABEL_55; - } - InitMonsters(); - InitMissiles(); - InitDead(); - IncProgress(); - LoadLevel(); - LABEL_54: - IncProgress(); - LABEL_55: - if (gbMaxPlayers == 1) - ResyncQuests(); - else - ResyncMPQuests(); - goto LABEL_72; - } + visited = 0; + if (gbMaxPlayers > 0) { + for (i = 0; i < gbMaxPlayers; i++) { + if (plr[i].plractive) + visited = visited || plr[i]._pLvlVisited[currlevel]; + } + } + SetRndSeed(glSeedTbl[currlevel]); + if (leveltype != DTYPE_TOWN) { + if (firstflag || lvldir == 4 || !plr[myplr]._pLvlVisited[currlevel] || gbMaxPlayers != 1) { + HoldThemeRooms(); + glMid1Seed[currlevel] = GetRndSeed(); + InitMonsters(); + glMid2Seed[currlevel] = GetRndSeed(); + InitObjects(); + InitItems(); + CreateThemeRooms(); + glMid3Seed[currlevel] = GetRndSeed(); + InitMissiles(); + InitDead(); + glEndSeed[currlevel] = GetRndSeed(); + if (gbMaxPlayers != 1) + DeltaLoadLevel(); + IncProgress(); + SavePreLighting(); + goto LABEL_55; + } + InitMonsters(); + InitMissiles(); + InitDead(); + IncProgress(); + LoadLevel(); + LABEL_54: + IncProgress(); + LABEL_55: + if (gbMaxPlayers == 1) + ResyncQuests(); + else + ResyncMPQuests(); + goto LABEL_72; + } - for (i = 0; i < 112; i++) { - for (j = 0; j < 112; j++) - dFlags[i][j] |= DFLAG_LIT; - } + for (i = 0; i < 112; i++) { + for (j = 0; j < 112; j++) + dFlags[i][j] |= DFLAG_LIT; + } - InitTowners(); - InitItems(); - InitMissiles(); - IncProgress(); - if (!firstflag && lvldir != 4 && plr[myplr]._pLvlVisited[currlevel]) { - if (gbMaxPlayers != 1) - goto LABEL_53; - LoadLevel(); - } - if (gbMaxPlayers == 1) - goto LABEL_54; - LABEL_53: - DeltaLoadLevel(); - goto LABEL_54; - } - pSpeedCels = DiabloAllocPtr(0x100000); - LoadSetMap(); - IncProgress(); - GetLevelMTypes(); - InitMonsters(); - InitMissileGFX(); - InitDead(); - FillSolidBlockTbls(); - IncProgress(); - if (lvldir == 5) - GetPortalLvlPos(); + InitTowners(); + InitItems(); + InitMissiles(); + IncProgress(); + if (!firstflag && lvldir != 4 && plr[myplr]._pLvlVisited[currlevel]) { + if (gbMaxPlayers != 1) + goto LABEL_53; + LoadLevel(); + } + if (gbMaxPlayers == 1) + goto LABEL_54; + LABEL_53: + DeltaLoadLevel(); + goto LABEL_54; + } + pSpeedCels = DiabloAllocPtr(0x100000); + LoadSetMap(); + IncProgress(); + GetLevelMTypes(); + InitMonsters(); + InitMissileGFX(); + InitDead(); + FillSolidBlockTbls(); + IncProgress(); + if (lvldir == 5) + GetPortalLvlPos(); - for (i = 0; i < MAX_PLRS; i++) { - if (plr[i].plractive) { - if (currlevel == plr[i].plrlevel) { - InitPlayerGFX(v2); - if (lvldir != 4) - InitPlayer(v2, firstflag); - } - } - ++v2; - } + for (i = 0; i < MAX_PLRS; i++) { + if (plr[i].plractive) { + if (currlevel == plr[i].plrlevel) { + InitPlayerGFX(v2); + if (lvldir != 4) + InitPlayer(v2, firstflag); + } + } + ++v2; + } - InitMultiView(); - IncProgress(); - if (firstflag || lvldir == 4 || !plr[myplr]._pSLvlVisited[setlvlnum]) { - InitItems(); - SavePreLighting(); - } else { - LoadLevel(); - } - InitMissiles(); - IncProgress(); + InitMultiView(); + IncProgress(); + if (firstflag || lvldir == 4 || !plr[myplr]._pSLvlVisited[setlvlnum]) { + InitItems(); + SavePreLighting(); + } else { + LoadLevel(); + } + InitMissiles(); + IncProgress(); LABEL_72: - SyncPortals(); + SyncPortals(); - for (i = 0; i < MAX_PLRS; i++) { - if (plr[i].plractive && plr[i].plrlevel == currlevel && (!plr[i]._pLvlChanging || i == myplr)) { - if (plr[i]._pHitPoints <= 0) - dFlags[plr[i].WorldX][plr[i].WorldY] |= DFLAG_DEAD_PLAYER; - else if (gbMaxPlayers == 1) - dPlayer[plr[i].WorldX][plr[i].WorldY] = i + 1; - else - SyncInitPlrPos(i); - } - } + for (i = 0; i < MAX_PLRS; i++) { + if (plr[i].plractive && plr[i].plrlevel == currlevel && (!plr[i]._pLvlChanging || i == myplr)) { + if (plr[i]._pHitPoints <= 0) + dFlags[plr[i].WorldX][plr[i].WorldY] |= DFLAG_DEAD_PLAYER; + else if (gbMaxPlayers == 1) + dPlayer[plr[i].WorldX][plr[i].WorldY] = i + 1; + else + SyncInitPlrPos(i); + } + } - if (leveltype != DTYPE_TOWN) - SetDungeonMicros(); - InitLightMax(); - IncProgress(); - IncProgress(); - if (firstflag) { - InitControlPan(); - IncProgress(); - } - if (leveltype != DTYPE_TOWN) { - ProcessLightList(); - ProcessVisionList(); - } - music_start(leveltype); - //do - // _LOBYTE(v19) = IncProgress(); - while (!IncProgress()) - ; - if (setlevel && setlvlnum == SL_SKELKING && quests[QTYPE_KING]._qactive == 2) - PlaySFX(USFX_SKING1); + if (leveltype != DTYPE_TOWN) + SetDungeonMicros(); + InitLightMax(); + IncProgress(); + IncProgress(); + if (firstflag) { + InitControlPan(); + IncProgress(); + } + if (leveltype != DTYPE_TOWN) { + ProcessLightList(); + ProcessVisionList(); + } + music_start(leveltype); + //do + // _LOBYTE(v19) = IncProgress(); + while (!IncProgress()) + ; + if (setlevel && setlvlnum == SL_SKELKING && quests[QTYPE_KING]._qactive == 2) + PlaySFX(USFX_SKING1); } // 525738: using guessed type int setseed; // 5CF31D: using guessed type char setlevel; @@ -1923,73 +1923,73 @@ LABEL_72: void __fastcall game_loop(bool bStartup) { - int v1; // ecx - int v2; // esi + int v1; // ecx + int v2; // esi - v1 = bStartup != 0 ? 0x39 : 0; - v2 = v1 + 3; - if (v1 != -3) { - while (1) { - --v2; - if (!multi_handle_delta()) - break; - timeout_cursor(0); - game_logic(); - if (gbRunGame) { - if (gbMaxPlayers != 1) { - if (nthread_has_500ms_passed()) { - if (v2) - continue; - } - } - } - return; - } - timeout_cursor(1); - } + v1 = bStartup != 0 ? 0x39 : 0; + v2 = v1 + 3; + if (v1 != -3) { + while (1) { + --v2; + if (!multi_handle_delta()) + break; + timeout_cursor(0); + game_logic(); + if (gbRunGame) { + if (gbMaxPlayers != 1) { + if (nthread_has_500ms_passed()) { + if (v2) + continue; + } + } + } + return; + } + timeout_cursor(1); + } } // 679660: using guessed type char gbMaxPlayers; void __cdecl game_logic() { - if (PauseMode != 2) { - if (PauseMode == 1) - PauseMode = 2; - if (gbMaxPlayers == 1 && gmenu_exception()) { - drawpanflag |= 1u; - } else { - if (!gmenu_exception() && sgnTimeoutCurs == CURSOR_NONE) { - CheckCursMove(); - track_process(); - } - if (gbProcessPlayers) - ProcessPlayers(); - if (leveltype != DTYPE_TOWN) { - ProcessMonsters(); - ProcessObjects(); - ProcessMissiles(); - ProcessItems(); - ProcessLightList(); - ProcessVisionList(); - } else { - ProcessTowners(); - ProcessItems(); - ProcessMissiles(); - } + if (PauseMode != 2) { + if (PauseMode == 1) + PauseMode = 2; + if (gbMaxPlayers == 1 && gmenu_exception()) { + drawpanflag |= 1u; + } else { + if (!gmenu_exception() && sgnTimeoutCurs == CURSOR_NONE) { + CheckCursMove(); + track_process(); + } + if (gbProcessPlayers) + ProcessPlayers(); + if (leveltype != DTYPE_TOWN) { + ProcessMonsters(); + ProcessObjects(); + ProcessMissiles(); + ProcessItems(); + ProcessLightList(); + ProcessVisionList(); + } else { + ProcessTowners(); + ProcessItems(); + ProcessMissiles(); + } #ifdef _DEBUG - if (debug_mode_key_inverted_v) { - if (GetAsyncKeyState(VK_SHIFT) & 0x8000) - ScrollView(); - } + if (debug_mode_key_inverted_v) { + if (GetAsyncKeyState(VK_SHIFT) & 0x8000) + ScrollView(); + } #endif - sound_update(); - ClearPlrMsg(); - CheckTriggers(); - CheckQuests(); - drawpanflag |= 1u; - pfile_update(0); - } - } + sound_update(); + ClearPlrMsg(); + CheckTriggers(); + CheckQuests(); + drawpanflag |= 1u; + pfile_update(0); + } + } } // 525718: using guessed type char cineflag; // 52571C: using guessed type int drawpanflag; @@ -1998,42 +1998,42 @@ void __cdecl game_logic() void __fastcall timeout_cursor(bool bTimeout) { - if (bTimeout) { - if (sgnTimeoutCurs == CURSOR_NONE && !sgbMouseDown) { - sgnTimeoutCurs = pcurs; - multi_net_ping(); - ClearPanel(); - AddPanelString("-- Network timeout --", 1); - AddPanelString("-- Waiting for players --", 1); - SetCursor(CURSOR_HOURGLASS); - drawpanflag = 255; - } - scrollrt_draw_game_screen(1); - } else if (sgnTimeoutCurs) { - SetCursor(sgnTimeoutCurs); - sgnTimeoutCurs = 0; - ClearPanel(); - drawpanflag = 255; - } + if (bTimeout) { + if (sgnTimeoutCurs == CURSOR_NONE && !sgbMouseDown) { + sgnTimeoutCurs = pcurs; + multi_net_ping(); + ClearPanel(); + AddPanelString("-- Network timeout --", 1); + AddPanelString("-- Waiting for players --", 1); + SetCursor(CURSOR_HOURGLASS); + drawpanflag = 255; + } + scrollrt_draw_game_screen(1); + } else if (sgnTimeoutCurs) { + SetCursor(sgnTimeoutCurs); + sgnTimeoutCurs = 0; + ClearPanel(); + drawpanflag = 255; + } } // 52571C: using guessed type int drawpanflag; // 525748: using guessed type char sgbMouseDown; void __cdecl diablo_color_cyc_logic() { - DWORD v0; // eax + DWORD v0; // eax - v0 = GetTickCount(); - if (v0 - color_cycle_timer >= 0x32) { - color_cycle_timer = v0; - if (palette_get_colour_cycling()) { - if (leveltype == DTYPE_HELL) { - lighting_color_cycling(); - } else if (leveltype == DTYPE_CAVES) { - if (fullscreen) - palette_update_caves(); - } - } - } + v0 = GetTickCount(); + if (v0 - color_cycle_timer >= 0x32) { + color_cycle_timer = v0; + if (palette_get_colour_cycling()) { + if (leveltype == DTYPE_HELL) { + lighting_color_cycling(); + } else if (leveltype == DTYPE_CAVES) { + if (fullscreen) + palette_update_caves(); + } + } + } } // 52574C: using guessed type int color_cycle_timer; diff --git a/Source/doom.cpp b/Source/doom.cpp index 6360b94b..7fb51ffb 100644 --- a/Source/doom.cpp +++ b/Source/doom.cpp @@ -30,70 +30,70 @@ void __cdecl doom_play_movie() int __cdecl doom_get_frame_from_time() { - if (DoomQuestState == 36001) { - return 31; - } + if (DoomQuestState == 36001) { + return 31; + } - return DoomQuestState / 1200; + return DoomQuestState / 1200; } void __cdecl doom_alloc_cel() { - pDoomCel = DiabloAllocPtr(229376); + pDoomCel = DiabloAllocPtr(229376); } void __cdecl doom_cleanup() { - void *ptr = pDoomCel; - pDoomCel = NULL; - mem_free_dbg(ptr); + void *ptr = pDoomCel; + pDoomCel = NULL; + mem_free_dbg(ptr); } void __cdecl doom_load_graphics() { - if (doom_quest_time == 31) { - strcpy(tempstr, "Items\\Map\\MapZDoom.CEL"); - } else if (doom_quest_time < 10) { - sprintf(tempstr, "Items\\Map\\MapZ000%i.CEL", doom_quest_time); - } else { - sprintf(tempstr, "Items\\Map\\MapZ00%i.CEL", doom_quest_time); - } - LoadFileWithMem(tempstr, pDoomCel); + if (doom_quest_time == 31) { + strcpy(tempstr, "Items\\Map\\MapZDoom.CEL"); + } else if (doom_quest_time < 10) { + sprintf(tempstr, "Items\\Map\\MapZ000%i.CEL", doom_quest_time); + } else { + sprintf(tempstr, "Items\\Map\\MapZ00%i.CEL", doom_quest_time); + } + LoadFileWithMem(tempstr, pDoomCel); } void __cdecl doom_init() { - doomflag = TRUE; - doom_alloc_cel(); - doom_quest_time = doom_get_frame_from_time() == 31 ? 31 : 0; - doom_load_graphics(); + doomflag = TRUE; + doom_alloc_cel(); + doom_quest_time = doom_get_frame_from_time() == 31 ? 31 : 0; + doom_load_graphics(); } void __cdecl doom_close() { - if (doomflag) { - doomflag = FALSE; - doom_cleanup(); - } + if (doomflag) { + doomflag = FALSE; + doom_cleanup(); + } } void __cdecl doom_draw() { - if (!doomflag) { - return; - } + if (!doomflag) { + return; + } - if (doom_quest_time != 31) { - doom_stars_drawn++; - if (doom_stars_drawn >= 5) { - doom_stars_drawn = 0; - doom_quest_time++; - if (doom_quest_time > doom_get_frame_from_time()) { - doom_quest_time = 0; - } - doom_load_graphics(); - } - } + if (doom_quest_time != 31) { + doom_stars_drawn++; + if (doom_stars_drawn >= 5) { + doom_stars_drawn = 0; + doom_quest_time++; + if (doom_quest_time > doom_get_frame_from_time()) { + doom_quest_time = 0; + } + doom_load_graphics(); + } + } - CelDecodeOnly(64, 511, pDoomCel, 1, 640); + CelDecodeOnly(64, 511, pDoomCel, 1, 640); } diff --git a/Source/drlg_l1.cpp b/Source/drlg_l1.cpp index 1381f57c..6a28b396 100644 --- a/Source/drlg_l1.cpp +++ b/Source/drlg_l1.cpp @@ -14,7 +14,7 @@ int VR3; void *pSetPiece; // idb const ShadowStruct SPATS[37] = { - // clang-format off + // clang-format off // strig, s1, s2, s3, nv1, nv2, nv3 { 7, 13, 0, 13, 144, 0, 142 }, { 16, 13, 0, 13, 144, 0, 142 }, @@ -53,53 +53,53 @@ const ShadowStruct SPATS[37] = { { 12, 0, 1, 0, 0, 146, 0 }, { 12, 13, 11, 0, 140, 147, 0 }, { 3, 13, 11, 12, 150, 0, 0 } - // clang-format on + // clang-format on }; const unsigned char BSTYPES[206] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, - 10, 11, 12, 13, 14, 15, 16, 17, 0, 0, - 0, 0, 0, 0, 0, 1, 2, 10, 4, 5, - 6, 7, 8, 9, 10, 11, 12, 14, 5, 14, - 10, 4, 14, 4, 5, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, - 2, 3, 4, 1, 6, 7, 16, 17, 2, 1, - 1, 2, 2, 1, 1, 2, 2, 2, 2, 2, - 1, 1, 11, 1, 13, 13, 13, 1, 2, 1, - 2, 1, 2, 1, 2, 2, 2, 2, 12, 0, - 0, 11, 1, 11, 1, 13, 0, 0, 0, 0, - 0, 0, 0, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 1, 11, 2, 12, - 13, 13, 13, 12, 2, 1, 2, 2, 4, 14, - 4, 10, 13, 13, 4, 4, 1, 1, 4, 2, - 2, 13, 13, 13, 13, 25, 26, 28, 30, 31, - 41, 43, 40, 41, 42, 43, 25, 41, 43, 28, - 28, 1, 2, 25, 26, 22, 22, 25, 26, 0, - 0, 0, 0, 0, 0, 0 + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 0, 0, + 0, 0, 0, 0, 0, 1, 2, 10, 4, 5, + 6, 7, 8, 9, 10, 11, 12, 14, 5, 14, + 10, 4, 14, 4, 5, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 2, 3, 4, 1, 6, 7, 16, 17, 2, 1, + 1, 2, 2, 1, 1, 2, 2, 2, 2, 2, + 1, 1, 11, 1, 13, 13, 13, 1, 2, 1, + 2, 1, 2, 1, 2, 2, 2, 2, 12, 0, + 0, 11, 1, 11, 1, 13, 0, 0, 0, 0, + 0, 0, 0, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 1, 11, 2, 12, + 13, 13, 13, 12, 2, 1, 2, 2, 4, 14, + 4, 10, 13, 13, 4, 4, 1, 1, 4, 2, + 2, 13, 13, 13, 13, 25, 26, 28, 30, 31, + 41, 43, 40, 41, 42, 43, 25, 41, 43, 28, + 28, 1, 2, 25, 26, 22, 22, 25, 26, 0, + 0, 0, 0, 0, 0, 0 }; const unsigned char L5BTYPES[206] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, - 10, 11, 12, 13, 14, 15, 16, 17, 0, 0, - 0, 0, 0, 0, 0, 25, 26, 0, 28, 0, - 30, 31, 0, 0, 0, 0, 0, 0, 0, 0, - 40, 41, 42, 43, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 79, - 80, 0, 82, 0, 0, 0, 0, 0, 0, 79, - 0, 80, 0, 0, 79, 80, 0, 2, 2, 2, - 1, 1, 11, 25, 13, 13, 13, 1, 2, 1, - 2, 1, 2, 1, 2, 2, 2, 2, 12, 0, - 0, 11, 1, 11, 1, 13, 0, 0, 0, 0, - 0, 0, 0, 13, 13, 13, 13, 13, 13, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0 + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 0, 0, + 0, 0, 0, 0, 0, 25, 26, 0, 28, 0, + 30, 31, 0, 0, 0, 0, 0, 0, 0, 0, + 40, 41, 42, 43, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 79, + 80, 0, 82, 0, 0, 0, 0, 0, 0, 79, + 0, 80, 0, 0, 79, 80, 0, 2, 2, 2, + 1, 1, 11, 25, 13, 13, 13, 1, 2, 1, + 2, 1, 2, 1, 2, 2, 2, 2, 12, 0, + 0, 11, 1, 11, 1, 13, 0, 0, 0, 0, + 0, 0, 0, 13, 13, 13, 13, 13, 13, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0 }; const unsigned char STAIRSUP[] = { 4, 4, 13, 13, 13, 13, 2, 2, 2, 2, 13, 13, 13, 13, 13, 13, 13, 13, 0, 66, 6, 0, 63, 64, 65, 0, 0, 67, 68, 0, 0, 0, 0, 0 }; const unsigned char L5STAIRSUP[] = { 4, 4, 22, 22, 22, 22, 2, 2, 2, 2, 13, 13, 13, 13, 13, 13, 13, 13, 0, 66, 23, 0, 63, 64, 65, 0, 0, 67, 68, 0, 0, 0, 0, 0 }; @@ -112,40 +112,40 @@ unsigned char L5ConvTbl[16] = { 22u, 13u, 1u, 13u, 2u, 13u, 13u, 13u, 4u, 13u, 1 void __cdecl DRLG_Init_Globals() { - char c; + char c; - memset(dFlags, 0, sizeof(dFlags)); - memset(dPlayer, 0, sizeof(dPlayer)); - memset(dMonster, 0, sizeof(dMonster)); - memset(dDead, 0, sizeof(dDead)); - memset(dObject, 0, sizeof(dObject)); - memset(dItem, 0, sizeof(dItem)); - memset(dMissile, 0, sizeof(dMissile)); - memset(dArch, 0, sizeof(dArch)); - if (!lightflag) - c = (light4flag) ? 3 : 15; - else - c = 0; - memset(dTransVal, c, sizeof(dTransVal)); + memset(dFlags, 0, sizeof(dFlags)); + memset(dPlayer, 0, sizeof(dPlayer)); + memset(dMonster, 0, sizeof(dMonster)); + memset(dDead, 0, sizeof(dDead)); + memset(dObject, 0, sizeof(dObject)); + memset(dItem, 0, sizeof(dItem)); + memset(dMissile, 0, sizeof(dMissile)); + memset(dArch, 0, sizeof(dArch)); + if (!lightflag) + c = (light4flag) ? 3 : 15; + else + c = 0; + memset(dTransVal, c, sizeof(dTransVal)); } // 525728: using guessed type int light4flag; // 646A28: using guessed type int lightflag; void __fastcall LoadL1Dungeon(char *sFileName, int vx, int vy) { - char *v3; // esi + char *v3; // esi unsigned char *v4; // esi - signed int v5; // ecx - signed int v6; // eax - signed int v7; // edx - int v8; // edi - int v9; // ebx - char *v10; // eax - int v11; // ecx - char v12; // dl - int v13; // [esp+Ch] [ebp-Ch] - int v14; // [esp+10h] [ebp-8h] - int v15; // [esp+14h] [ebp-4h] + signed int v5; // ecx + signed int v6; // eax + signed int v7; // edx + int v8; // edi + int v9; // ebx + char *v10; // eax + int v11; // ecx + char v12; // dl + int v13; // [esp+Ch] [ebp-Ch] + int v14; // [esp+10h] [ebp-8h] + int v15; // [esp+14h] [ebp-4h] v13 = vx; dminx = 16; @@ -156,54 +156,41 @@ void __fastcall LoadL1Dungeon(char *sFileName, int vx, int vy) DRLG_InitTrans(); v4 = LoadFileInMem(v3, 0); v5 = 0; - do - { + do { v6 = v5; v7 = 40; - do - { + do { mydflags[0][v6] = 0; dungeon[0][v6] = 22; v6 += 40; --v7; - } - while ( v7 ); + } while (v7); ++v5; - } - while ( v5 < 40 ); + } while (v5 < 40); v15 = 0; v8 = *v4; v9 = v4[2]; v10 = (char *)(v4 + 4); - if ( v9 > 0 ) - { - do - { - if ( v8 > 0 ) - { + if (v9 > 0) { + do { + if (v8 > 0) { v11 = v15; v14 = v8; - do - { + do { v12 = *v10; - if ( *v10 ) - { + if (*v10) { mydflags[0][v11] |= 0x80u; dungeon[0][v11] = v12; - } - else - { + } else { dungeon[0][v11] = 13; } v11 += 40; v10 += 2; --v14; - } - while ( v14 ); + } while (v14); } ++v15; - } - while ( v15 < v9 ); + } while (v15 < v9); } DRLG_L1Floor(); ViewX = v13; @@ -222,41 +209,41 @@ void __fastcall LoadL1Dungeon(char *sFileName, int vx, int vy) void __cdecl DRLG_L1Floor() { - for (int j = 0; j < DMAXY; j++) { - for (int i = 0; i < DMAXX; i++) { - if (mydflags[i][j] == 0 && dungeon[i][j] == 13) { - long rv = random(0, 3); + for (int j = 0; j < DMAXY; j++) { + for (int i = 0; i < DMAXX; i++) { + if (mydflags[i][j] == 0 && dungeon[i][j] == 13) { + long rv = random(0, 3); - if (rv == 1) - dungeon[i][j] = 162; - if (rv == 2) - dungeon[i][j] = 163; - } - } - } + if (rv == 1) + dungeon[i][j] = 162; + if (rv == 2) + dungeon[i][j] = 163; + } + } + } } void __cdecl DRLG_L1Pass3() { - int v0; // eax - int *v1; // edx - int *v2; // eax - signed int v3; // ecx - signed int v4; // ebx - int *v5; // ecx - unsigned char *v6; // edx + int v0; // eax + int *v1; // edx + int *v2; // eax + signed int v3; // ecx + signed int v4; // ebx + int *v5; // ecx + unsigned char *v6; // edx unsigned short *v7; // esi - unsigned short v8; // ax - int v9; // eax - int v10; // ST24_4 - int v11; // ST20_4 - int v12; // ST1C_4 - signed int v13; // [esp+Ch] [ebp-1Ch] - int *v14; // [esp+10h] [ebp-18h] - int v15; // [esp+14h] [ebp-14h] - int v16; // [esp+18h] [ebp-10h] - int v17; // [esp+1Ch] [ebp-Ch] - int v18; // [esp+20h] [ebp-8h] + unsigned short v8; // ax + int v9; // eax + int v10; // ST24_4 + int v11; // ST20_4 + int v12; // ST1C_4 + signed int v13; // [esp+Ch] [ebp-1Ch] + int *v14; // [esp+10h] [ebp-18h] + int v15; // [esp+14h] [ebp-14h] + int v16; // [esp+18h] [ebp-10h] + int v17; // [esp+1Ch] [ebp-Ch] + int v18; // [esp+20h] [ebp-8h] v0 = *((unsigned short *)pMegaTiles + 84) + 1; v18 = *((unsigned short *)pMegaTiles + 84) + 1; @@ -267,32 +254,26 @@ void __cdecl DRLG_L1Pass3() _LOWORD(v0) = *((_WORD *)pMegaTiles + 87); v15 = v0 + 1; v1 = dPiece[1]; - do - { + do { v2 = v1; v3 = 56; - do - { + do { *(v2 - 112) = v18; *v2 = v17; *(v2 - 111) = v16; v2[1] = v15; v2 += 224; --v3; - } - while ( v3 ); + } while (v3); v1 += 2; - } - while ( (signed int)v1 < (signed int)dPiece[2] ); + } while ((signed int)v1 < (signed int)dPiece[2]); v4 = 0; v14 = &dPiece[17][16]; /* check */ - do - { + do { v5 = v14; v6 = (unsigned char *)dungeon + v4; v13 = 40; - do - { + do { v7 = (unsigned short *)((char *)pMegaTiles + 8 * (*v6 - 1)); v8 = *v7; ++v7; @@ -311,70 +292,58 @@ void __cdecl DRLG_L1Pass3() v5[1] = v9 + 1; v5 += 224; --v13; - } - while ( v13 ); + } while (v13); v14 += 2; ++v4; - } - while ( v4 < 40 ); + } while (v4 < 40); } void __cdecl DRLG_InitL1Vals() { - int v0; // esi - int (*v1)[112]; // edx - char *v2; // ecx - int v3; // eax - char v4; // al - char v5; // [esp-4h] [ebp-18h] + int v0; // esi + int(*v1)[112]; // edx + char *v2; // ecx + int v3; // eax + char v4; // al + char v5; // [esp-4h] [ebp-18h] signed int v6; // [esp+Ch] [ebp-8h] - int (*v7)[112]; // [esp+10h] [ebp-4h] + int(*v7)[112]; // [esp+10h] [ebp-4h] v0 = 0; v7 = dPiece; - do - { + do { v1 = v7; v2 = (char *)dArch + v0; v6 = 112; - do - { + do { v3 = (*v1)[0]; - if ( (*v1)[0] != 12 ) - { - if ( v3 == 11 ) + if ((*v1)[0] != 12) { + if (v3 == 11) goto LABEL_21; - if ( v3 != 71 ) - { - if ( v3 == 259 ) - { + if (v3 != 71) { + if (v3 == 259) { v5 = 5; -LABEL_9: + LABEL_9: v4 = v5; goto LABEL_22; } - if ( v3 == 249 || v3 == 325 ) + if (v3 == 249 || v3 == 325) goto LABEL_21; - if ( v3 != 321 ) - { - if ( v3 == 255 ) - { + if (v3 != 321) { + if (v3 == 255) { v5 = 4; goto LABEL_9; } - if ( v3 != 211 ) - { - if ( v3 == 344 ) + if (v3 != 211) { + if (v3 == 344) goto LABEL_21; - if ( v3 != 341 ) - { - if ( v3 == 331 ) + if (v3 != 341) { + if (v3 == 331) goto LABEL_21; - if ( v3 != 418 ) - { - if ( v3 != 421 ) + if (v3 != 418) { + if (v3 != 421) goto LABEL_23; -LABEL_21: + LABEL_21: v4 = 2; goto LABEL_22; } @@ -384,36 +353,34 @@ LABEL_21: } } v4 = 1; -LABEL_22: + LABEL_22: *v2 = v4; -LABEL_23: + LABEL_23: ++v1; v2 += 112; --v6; - } - while ( v6 ); - v7 = (int (*)[112])((char *)v7 + 4); + } while (v6); + v7 = (int(*)[112])((char *)v7 + 4); ++v0; - } - while ( (signed int)v7 < (signed int)dPiece[1] ); + } while ((signed int)v7 < (signed int)dPiece[1]); } void __fastcall LoadPreL1Dungeon(char *sFileName, int vx, int vy) { unsigned char *v3; // ebx - signed int v4; // ecx - signed int v5; // eax - signed int v6; // edx - int v7; // esi - int v8; // edi - char *v9; // eax - int v10; // ecx - char v11; // dl - signed int v12; // esi - signed int v13; // eax - signed int v14; // edi - int v15; // [esp+Ch] [ebp-8h] - int v16; // [esp+10h] [ebp-4h] + signed int v4; // ecx + signed int v5; // eax + signed int v6; // edx + int v7; // esi + int v8; // edi + char *v9; // eax + int v10; // ecx + char v11; // dl + signed int v12; // esi + signed int v13; // eax + signed int v14; // edi + int v15; // [esp+Ch] [ebp-8h] + int v16; // [esp+10h] [ebp-4h] dminx = 16; dminy = 16; @@ -421,71 +388,54 @@ void __fastcall LoadPreL1Dungeon(char *sFileName, int vx, int vy) dmaxy = 96; v3 = LoadFileInMem(sFileName, 0); v4 = 0; - do - { + do { v5 = v4; v6 = 40; - do - { + do { mydflags[0][v5] = 0; dungeon[0][v5] = 22; v5 += 40; --v6; - } - while ( v6 ); + } while (v6); ++v4; - } - while ( v4 < 40 ); + } while (v4 < 40); v16 = 0; v7 = *v3; v8 = v3[2]; v9 = (char *)(v3 + 4); - if ( v8 > 0 ) - { - do - { - if ( v7 > 0 ) - { + if (v8 > 0) { + do { + if (v7 > 0) { v10 = v16; v15 = v7; - do - { + do { v11 = *v9; - if ( *v9 ) - { + if (*v9) { mydflags[0][v10] |= 0x80u; dungeon[0][v10] = v11; - } - else - { + } else { dungeon[0][v10] = 13; } v10 += 40; v9 += 2; --v15; - } - while ( v15 ); + } while (v15); } ++v16; - } - while ( v16 < v8 ); + } while (v16 < v8); } DRLG_L1Floor(); v12 = 0; - do - { + do { v13 = v12; v14 = 40; - do - { + do { pdungeon[0][v13] = dungeon[0][v13]; v13 += 40; --v14; - } - while ( v14 ); + } while (v14); ++v12; - } - while ( v12 < 40 ); + } while (v12 < 40); mem_free_dbg(v3); } // 5CF328: using guessed type int dmaxx; @@ -495,21 +445,21 @@ void __fastcall LoadPreL1Dungeon(char *sFileName, int vx, int vy) void __fastcall CreateL5Dungeon(int rseed, int entry) { - SetRndSeed(rseed); + SetRndSeed(rseed); - dminx = 16; - dminy = 16; - dmaxx = 96; - dmaxy = 96; + dminx = 16; + dminy = 16; + dmaxx = 96; + dmaxy = 96; - DRLG_InitTrans(); - DRLG_InitSetPC(); - DRLG_LoadL1SP(); - DRLG_L5(entry); - DRLG_L1Pass3(); - DRLG_FreeL1SP(); - DRLG_InitL1Vals(); - DRLG_SetPC(); + DRLG_InitTrans(); + DRLG_InitSetPC(); + DRLG_LoadL1SP(); + DRLG_L5(entry); + DRLG_L1Pass3(); + DRLG_FreeL1SP(); + DRLG_InitL1Vals(); + DRLG_SetPC(); } // 5CF328: using guessed type int dmaxx; // 5CF32C: using guessed type int dmaxy; @@ -518,19 +468,19 @@ void __fastcall CreateL5Dungeon(int rseed, int entry) void __cdecl DRLG_LoadL1SP() { - setloadflag = 0; - if (QuestStatus(QTYPE_BUTCH)) { - pSetPiece = LoadFileInMem("Levels\\L1Data\\rnd6.DUN", 0); - setloadflag = 1; - } - if (QuestStatus(QTYPE_KING) && gbMaxPlayers == 1) { - pSetPiece = LoadFileInMem("Levels\\L1Data\\SKngDO.DUN", 0); - setloadflag = 1; - } - if (QuestStatus(QTYPE_BOL)) { - pSetPiece = LoadFileInMem("Levels\\L1Data\\Banner2.DUN", 0); - setloadflag = 1; - } + setloadflag = 0; + if (QuestStatus(QTYPE_BUTCH)) { + pSetPiece = LoadFileInMem("Levels\\L1Data\\rnd6.DUN", 0); + setloadflag = 1; + } + if (QuestStatus(QTYPE_KING) && gbMaxPlayers == 1) { + pSetPiece = LoadFileInMem("Levels\\L1Data\\SKngDO.DUN", 0); + setloadflag = 1; + } + if (QuestStatus(QTYPE_BOL)) { + pSetPiece = LoadFileInMem("Levels\\L1Data\\Banner2.DUN", 0); + setloadflag = 1; + } } // 5276A4: using guessed type int setloadflag; // 679660: using guessed type char gbMaxPlayers; @@ -546,382 +496,382 @@ void __cdecl DRLG_FreeL1SP() void __fastcall DRLG_L5(int entry) { - int i, j; - long minarea; - BOOL doneflag; + int i, j; + long minarea; + BOOL doneflag; - switch (currlevel) { - case 1: - minarea = 533; - break; - case 2: - minarea = 693; - break; - case 3: - case 4: - minarea = 761; - break; - default: - break; - } + switch (currlevel) { + case 1: + minarea = 533; + break; + case 2: + minarea = 693; + break; + case 3: + case 4: + minarea = 761; + break; + default: + break; + } - do { - DRLG_InitTrans(); + do { + DRLG_InitTrans(); - do { - InitL5Dungeon(); - L5firstRoom(); - } while (L5GetArea() < minarea); + do { + InitL5Dungeon(); + L5firstRoom(); + } while (L5GetArea() < minarea); - L5makeDungeon(); - L5makeDmt(); - L5FillChambers(); - L5tileFix(); - L5AddWall(); - L5ClearFlags(); - DRLG_L5FloodTVal(); + L5makeDungeon(); + L5makeDmt(); + L5FillChambers(); + L5tileFix(); + L5AddWall(); + L5ClearFlags(); + DRLG_L5FloodTVal(); - doneflag = TRUE; + doneflag = TRUE; - if (QuestStatus(QTYPE_PW)) { - if (entry == 0) { - if (DRLG_PlaceMiniSet(PWATERIN, 1, 1, 0, 0, 1, -1, 0) < 0) - doneflag = FALSE; - } else { - if (DRLG_PlaceMiniSet(PWATERIN, 1, 1, 0, 0, 0, -1, 0) < 0) - doneflag = FALSE; - ViewY--; - } - } - if (QuestStatus(QTYPE_BOL)) { - if (entry == 0) { - if (DRLG_PlaceMiniSet(STAIRSUP, 1, 1, 0, 0, 1, -1, 0) < 0) - doneflag = FALSE; - } else { - if (DRLG_PlaceMiniSet(STAIRSUP, 1, 1, 0, 0, 0, -1, 0) < 0) - doneflag = FALSE; - if (entry == 1) { - ViewX = 2 * setpc_x + 20; - ViewY = 2 * setpc_y + 28; - } else { - ViewY--; - } - } - } else if (entry == 0) { - if (DRLG_PlaceMiniSet(L5STAIRSUP, 1, 1, 0, 0, 1, -1, 0) < 0) - doneflag = FALSE; - else if (DRLG_PlaceMiniSet(STAIRSDOWN, 1, 1, 0, 0, 0, -1, 1) < 0) - doneflag = FALSE; - } else { - if (DRLG_PlaceMiniSet(L5STAIRSUP, 1, 1, 0, 0, 0, -1, 0) < 0) - doneflag = FALSE; - else if (DRLG_PlaceMiniSet(STAIRSDOWN, 1, 1, 0, 0, 1, -1, 1) < 0) - doneflag = FALSE; - ViewY--; - } - } while (doneflag == FALSE); + if (QuestStatus(QTYPE_PW)) { + if (entry == 0) { + if (DRLG_PlaceMiniSet(PWATERIN, 1, 1, 0, 0, 1, -1, 0) < 0) + doneflag = FALSE; + } else { + if (DRLG_PlaceMiniSet(PWATERIN, 1, 1, 0, 0, 0, -1, 0) < 0) + doneflag = FALSE; + ViewY--; + } + } + if (QuestStatus(QTYPE_BOL)) { + if (entry == 0) { + if (DRLG_PlaceMiniSet(STAIRSUP, 1, 1, 0, 0, 1, -1, 0) < 0) + doneflag = FALSE; + } else { + if (DRLG_PlaceMiniSet(STAIRSUP, 1, 1, 0, 0, 0, -1, 0) < 0) + doneflag = FALSE; + if (entry == 1) { + ViewX = 2 * setpc_x + 20; + ViewY = 2 * setpc_y + 28; + } else { + ViewY--; + } + } + } else if (entry == 0) { + if (DRLG_PlaceMiniSet(L5STAIRSUP, 1, 1, 0, 0, 1, -1, 0) < 0) + doneflag = FALSE; + else if (DRLG_PlaceMiniSet(STAIRSDOWN, 1, 1, 0, 0, 0, -1, 1) < 0) + doneflag = FALSE; + } else { + if (DRLG_PlaceMiniSet(L5STAIRSUP, 1, 1, 0, 0, 0, -1, 0) < 0) + doneflag = FALSE; + else if (DRLG_PlaceMiniSet(STAIRSDOWN, 1, 1, 0, 0, 1, -1, 1) < 0) + doneflag = FALSE; + ViewY--; + } + } while (doneflag == FALSE); - for (j = 0; j < DMAXY; j++) { - for (i = 0; i < DMAXX; i++) { - if (dungeon[i][j] == 64) { - int xx = 2 * i + 16; /* todo: fix loop */ - int yy = 2 * j + 16; - DRLG_CopyTrans(xx, yy + 1, xx, yy); - DRLG_CopyTrans(xx + 1, yy + 1, xx + 1, yy); - } - } - } + for (j = 0; j < DMAXY; j++) { + for (i = 0; i < DMAXX; i++) { + if (dungeon[i][j] == 64) { + int xx = 2 * i + 16; /* todo: fix loop */ + int yy = 2 * j + 16; + DRLG_CopyTrans(xx, yy + 1, xx, yy); + DRLG_CopyTrans(xx + 1, yy + 1, xx + 1, yy); + } + } + } - DRLG_L5TransFix(); - DRLG_L5DirtFix(); - DRLG_L5CornerFix(); + DRLG_L5TransFix(); + DRLG_L5DirtFix(); + DRLG_L5CornerFix(); - for (j = 0; j < DMAXY; j++) { - for (i = 0; i < DMAXX; i++) { - if (mydflags[i][j] & 0x7F) - DRLG_PlaceDoor(i, j); - } - } + for (j = 0; j < DMAXY; j++) { + for (i = 0; i < DMAXX; i++) { + if (mydflags[i][j] & 0x7F) + DRLG_PlaceDoor(i, j); + } + } - DRLG_L5Subs(); - DRLG_L1Shadows(); - DRLG_PlaceMiniSet(LAMPS, 5, 10, 0, 0, 0, -1, 4); - DRLG_L1Floor(); + DRLG_L5Subs(); + DRLG_L1Shadows(); + DRLG_PlaceMiniSet(LAMPS, 5, 10, 0, 0, 0, -1, 4); + DRLG_L1Floor(); - for (j = 0; j < DMAXY; j++) { - for (i = 0; i < DMAXX; i++) { - pdungeon[i][j] = dungeon[i][j]; - } - } + for (j = 0; j < DMAXY; j++) { + for (i = 0; i < DMAXX; i++) { + pdungeon[i][j] = dungeon[i][j]; + } + } - DRLG_Init_Globals(); - DRLG_CheckQuests(setpc_x, setpc_y); + DRLG_Init_Globals(); + DRLG_CheckQuests(setpc_x, setpc_y); } void __fastcall DRLG_PlaceDoor(int x, int y) { - if ((mydflags[x][y] & 0x80) == 0) { /* todo: unsigned */ - unsigned char df = mydflags[x][y] & 0x7F; - unsigned char c = dungeon[x][y]; + if ((mydflags[x][y] & 0x80) == 0) { /* todo: unsigned */ + unsigned char df = mydflags[x][y] & 0x7F; + unsigned char c = dungeon[x][y]; - if (df == 1) { - if (y != 1 && c == 2) - dungeon[x][y] = 26; - if (y != 1 && c == 7) - dungeon[x][y] = 31; - if (y != 1 && c == 14) - dungeon[x][y] = 42; - if (y != 1 && c == 4) - dungeon[x][y] = 43; - if (x != 1 && c == 1) - dungeon[x][y] = 25; - if (x != 1 && c == 10) - dungeon[x][y] = 40; - if (x != 1 && c == 6) - dungeon[x][y] = 30; - } - if (df == 2) { - if (x != 1 && c == 1) - dungeon[x][y] = 25; - if (x != 1 && c == 6) - dungeon[x][y] = 30; - if (x != 1 && c == 10) - dungeon[x][y] = 40; - if (x != 1 && c == 4) - dungeon[x][y] = 41; - if (y != 1 && c == 2) - dungeon[x][y] = 26; - if (y != 1 && c == 14) - dungeon[x][y] = 42; - if (y != 1 && c == 7) - dungeon[x][y] = 31; - } - if (df == 3) { - if (x != 1 && y != 1 && c == 4) - dungeon[x][y] = 28; - if (x != 1 && c == 10) - dungeon[x][y] = 40; - if (y != 1 && c == 14) - dungeon[x][y] = 42; - if (y != 1 && c == 2) - dungeon[x][y] = 26; - if (x != 1 && c == 1) - dungeon[x][y] = 25; - if (y != 1 && c == 7) - dungeon[x][y] = 31; - if (x != 1 && c == 6) - dungeon[x][y] = 30; - } - } + if (df == 1) { + if (y != 1 && c == 2) + dungeon[x][y] = 26; + if (y != 1 && c == 7) + dungeon[x][y] = 31; + if (y != 1 && c == 14) + dungeon[x][y] = 42; + if (y != 1 && c == 4) + dungeon[x][y] = 43; + if (x != 1 && c == 1) + dungeon[x][y] = 25; + if (x != 1 && c == 10) + dungeon[x][y] = 40; + if (x != 1 && c == 6) + dungeon[x][y] = 30; + } + if (df == 2) { + if (x != 1 && c == 1) + dungeon[x][y] = 25; + if (x != 1 && c == 6) + dungeon[x][y] = 30; + if (x != 1 && c == 10) + dungeon[x][y] = 40; + if (x != 1 && c == 4) + dungeon[x][y] = 41; + if (y != 1 && c == 2) + dungeon[x][y] = 26; + if (y != 1 && c == 14) + dungeon[x][y] = 42; + if (y != 1 && c == 7) + dungeon[x][y] = 31; + } + if (df == 3) { + if (x != 1 && y != 1 && c == 4) + dungeon[x][y] = 28; + if (x != 1 && c == 10) + dungeon[x][y] = 40; + if (y != 1 && c == 14) + dungeon[x][y] = 42; + if (y != 1 && c == 2) + dungeon[x][y] = 26; + if (x != 1 && c == 1) + dungeon[x][y] = 25; + if (y != 1 && c == 7) + dungeon[x][y] = 31; + if (x != 1 && c == 6) + dungeon[x][y] = 30; + } + } - mydflags[x][y] = 0x80; + mydflags[x][y] = 0x80; } void __cdecl DRLG_L1Shadows() { - int x, y; - unsigned char sd[2][2]; - unsigned char tnv3; + int x, y; + unsigned char sd[2][2]; + unsigned char tnv3; - for (y = 1; y < DMAXY; y++) { - for (x = 1; x < DMAXX; x++) { - sd[0][0] = BSTYPES[(unsigned char)dungeon[x][y]]; - sd[1][0] = BSTYPES[(unsigned char)dungeon[x - 1][y]]; - sd[0][1] = BSTYPES[(unsigned char)dungeon[x][y - 1]]; - sd[1][1] = BSTYPES[(unsigned char)dungeon[x - 1][y - 1]]; + for (y = 1; y < DMAXY; y++) { + for (x = 1; x < DMAXX; x++) { + sd[0][0] = BSTYPES[(unsigned char)dungeon[x][y]]; + sd[1][0] = BSTYPES[(unsigned char)dungeon[x - 1][y]]; + sd[0][1] = BSTYPES[(unsigned char)dungeon[x][y - 1]]; + sd[1][1] = BSTYPES[(unsigned char)dungeon[x - 1][y - 1]]; - for (int i = 0; i < 37; i++) { - if (SPATS[i].strig == sd[0][0]) { - BOOL patflag = TRUE; - if (SPATS[i].s1 && SPATS[i].s1 != sd[1][1]) - patflag = FALSE; - if (SPATS[i].s2 && SPATS[i].s2 != sd[0][1]) - patflag = FALSE; - if (SPATS[i].s3 && SPATS[i].s3 != sd[1][0]) - patflag = FALSE; - if (patflag == TRUE) { - if (SPATS[i].nv1 && !mydflags[x - 1][y - 1]) - dungeon[x - 1][y - 1] = SPATS[i].nv1; - if (SPATS[i].nv2 && !mydflags[x][y - 1]) - dungeon[x][y - 1] = SPATS[i].nv2; - if (SPATS[i].nv3) { - if (!mydflags[x - 1][y]) - dungeon[x - 1][y] = SPATS[i].nv3; - } - } - } - } - } - } + for (int i = 0; i < 37; i++) { + if (SPATS[i].strig == sd[0][0]) { + BOOL patflag = TRUE; + if (SPATS[i].s1 && SPATS[i].s1 != sd[1][1]) + patflag = FALSE; + if (SPATS[i].s2 && SPATS[i].s2 != sd[0][1]) + patflag = FALSE; + if (SPATS[i].s3 && SPATS[i].s3 != sd[1][0]) + patflag = FALSE; + if (patflag == TRUE) { + if (SPATS[i].nv1 && !mydflags[x - 1][y - 1]) + dungeon[x - 1][y - 1] = SPATS[i].nv1; + if (SPATS[i].nv2 && !mydflags[x][y - 1]) + dungeon[x][y - 1] = SPATS[i].nv2; + if (SPATS[i].nv3) { + if (!mydflags[x - 1][y]) + dungeon[x - 1][y] = SPATS[i].nv3; + } + } + } + } + } + } - for (y = 1; y < DMAXY; y++) { - for (x = 1; x < DMAXX; x++) { - if ((unsigned char)dungeon[x - 1][y] == 139 && !mydflags[x - 1][y]) { - tnv3 = 139; - if (dungeon[x][y] == 29) - tnv3 = 141; - if (dungeon[x][y] == 32) - tnv3 = 141; - if (dungeon[x][y] == 35) - tnv3 = 141; - if (dungeon[x][y] == 37) - tnv3 = 141; - if (dungeon[x][y] == 38) - tnv3 = 141; - if (dungeon[x][y] == 39) - tnv3 = 141; - dungeon[x - 1][y] = tnv3; - } - if ((unsigned char)dungeon[x - 1][y] == 149 && !mydflags[x - 1][y]) { - tnv3 = 149; - if (dungeon[x][y] == 29) - tnv3 = 153; - if (dungeon[x][y] == 32) - tnv3 = 153; - if (dungeon[x][y] == 35) - tnv3 = 153; - if (dungeon[x][y] == 37) - tnv3 = 153; - if (dungeon[x][y] == 38) - tnv3 = 153; - if (dungeon[x][y] == 39) - tnv3 = 153; - dungeon[x - 1][y] = tnv3; - } - if ((unsigned char)dungeon[x - 1][y] == 148 && !mydflags[x - 1][y]) { - tnv3 = 148; - if (dungeon[x][y] == 29) - tnv3 = 154; - if (dungeon[x][y] == 32) - tnv3 = 154; - if (dungeon[x][y] == 35) - tnv3 = 154; - if (dungeon[x][y] == 37) - tnv3 = 154; - if (dungeon[x][y] == 38) - tnv3 = 154; - if (dungeon[x][y] == 39) - tnv3 = 154; - dungeon[x - 1][y] = tnv3; - } - } - } + for (y = 1; y < DMAXY; y++) { + for (x = 1; x < DMAXX; x++) { + if ((unsigned char)dungeon[x - 1][y] == 139 && !mydflags[x - 1][y]) { + tnv3 = 139; + if (dungeon[x][y] == 29) + tnv3 = 141; + if (dungeon[x][y] == 32) + tnv3 = 141; + if (dungeon[x][y] == 35) + tnv3 = 141; + if (dungeon[x][y] == 37) + tnv3 = 141; + if (dungeon[x][y] == 38) + tnv3 = 141; + if (dungeon[x][y] == 39) + tnv3 = 141; + dungeon[x - 1][y] = tnv3; + } + if ((unsigned char)dungeon[x - 1][y] == 149 && !mydflags[x - 1][y]) { + tnv3 = 149; + if (dungeon[x][y] == 29) + tnv3 = 153; + if (dungeon[x][y] == 32) + tnv3 = 153; + if (dungeon[x][y] == 35) + tnv3 = 153; + if (dungeon[x][y] == 37) + tnv3 = 153; + if (dungeon[x][y] == 38) + tnv3 = 153; + if (dungeon[x][y] == 39) + tnv3 = 153; + dungeon[x - 1][y] = tnv3; + } + if ((unsigned char)dungeon[x - 1][y] == 148 && !mydflags[x - 1][y]) { + tnv3 = 148; + if (dungeon[x][y] == 29) + tnv3 = 154; + if (dungeon[x][y] == 32) + tnv3 = 154; + if (dungeon[x][y] == 35) + tnv3 = 154; + if (dungeon[x][y] == 37) + tnv3 = 154; + if (dungeon[x][y] == 38) + tnv3 = 154; + if (dungeon[x][y] == 39) + tnv3 = 154; + dungeon[x - 1][y] = tnv3; + } + } + } } int __fastcall DRLG_PlaceMiniSet(const unsigned char *miniset, int tmin, int tmax, int cx, int cy, BOOL setview, int noquad, int ldir) { - int xx, yy, sx, sy; - int ii; - int numt; + int xx, yy, sx, sy; + int ii; + int numt; - int sw = miniset[0]; - int sh = miniset[1]; + int sw = miniset[0]; + int sh = miniset[1]; - if (tmax - tmin == 0) - numt = 1; - else - numt = random(0, tmax - tmin) + tmin; + if (tmax - tmin == 0) + numt = 1; + else + numt = random(0, tmax - tmin) + tmin; - for (int i = 0; i < numt; i++) { - sx = random(0, 40 - sw); - sy = random(0, 40 - sh); - BOOL abort = FALSE; - int found = 0; + for (int i = 0; i < numt; i++) { + sx = random(0, 40 - sw); + sy = random(0, 40 - sh); + BOOL abort = FALSE; + int found = 0; - while (abort == FALSE) { - abort = TRUE; - if (cx != -1 && sx >= cx - sw && sx <= cx + 12) { - sx++; - abort = FALSE; - } - if (cy != -1 && sy >= cy - sh && sy <= cy + 12) { - sy++; - abort = FALSE; - } + while (abort == FALSE) { + abort = TRUE; + if (cx != -1 && sx >= cx - sw && sx <= cx + 12) { + sx++; + abort = FALSE; + } + if (cy != -1 && sy >= cy - sh && sy <= cy + 12) { + sy++; + abort = FALSE; + } - switch (noquad) { - case 0: - if (sx < cx && sy < cy) - abort = FALSE; - break; - case 1: - if (sx > cx && sy < cy) - abort = FALSE; - break; - case 2: - if (sx < cx && sy > cy) - abort = FALSE; - break; - case 3: - if (sx > cx && sy > cy) - abort = FALSE; - break; - default: - break; - } + switch (noquad) { + case 0: + if (sx < cx && sy < cy) + abort = FALSE; + break; + case 1: + if (sx > cx && sy < cy) + abort = FALSE; + break; + case 2: + if (sx < cx && sy > cy) + abort = FALSE; + break; + case 3: + if (sx > cx && sy > cy) + abort = FALSE; + break; + default: + break; + } - ii = 2; + ii = 2; - for (yy = 0; yy < sh && abort == TRUE; yy++) { - for (xx = 0; xx < sw && abort == TRUE; xx++) { - if (miniset[ii] && (unsigned char)dungeon[xx + sx][sy + yy] != miniset[ii]) - abort = FALSE; - if (mydflags[xx + sx][sy + yy]) - abort = FALSE; - ii++; - } - } + for (yy = 0; yy < sh && abort == TRUE; yy++) { + for (xx = 0; xx < sw && abort == TRUE; xx++) { + if (miniset[ii] && (unsigned char)dungeon[xx + sx][sy + yy] != miniset[ii]) + abort = FALSE; + if (mydflags[xx + sx][sy + yy]) + abort = FALSE; + ii++; + } + } - if (abort == FALSE) { - if (++sx == 40 - sw) { - sx = 0; - if (++sy == 40 - sh) - sy = 0; - } - if (++found > 4000) - return -1; - } - } + if (abort == FALSE) { + if (++sx == 40 - sw) { + sx = 0; + if (++sy == 40 - sh) + sy = 0; + } + if (++found > 4000) + return -1; + } + } - ii = sw * sh + 2; + ii = sw * sh + 2; - for (yy = 0; yy < sh; yy++) { - for (xx = 0; xx < sw; xx++) { - if (miniset[ii]) - dungeon[xx + sx][sy + yy] = miniset[ii]; - ii++; - } - } - } + for (yy = 0; yy < sh; yy++) { + for (xx = 0; xx < sw; xx++) { + if (miniset[ii]) + dungeon[xx + sx][sy + yy] = miniset[ii]; + ii++; + } + } + } - if (miniset == PWATERIN) { - int t = TransVal; - TransVal = 0; - DRLG_MRectTrans(sx, sy + 2, sx + 5, sy + 4); - TransVal = t; + if (miniset == PWATERIN) { + int t = TransVal; + TransVal = 0; + DRLG_MRectTrans(sx, sy + 2, sx + 5, sy + 4); + TransVal = t; - quests[QTYPE_PW]._qtx = 2 * sx + 21; - quests[QTYPE_PW]._qty = 2 * sy + 22; - } + quests[QTYPE_PW]._qtx = 2 * sx + 21; + quests[QTYPE_PW]._qty = 2 * sy + 22; + } - if (setview == TRUE) { - ViewX = 2 * sx + 19; - ViewY = 2 * sy + 20; - } + if (setview == TRUE) { + ViewX = 2 * sx + 19; + ViewY = 2 * sy + 20; + } - if (ldir == 0) { - LvlViewX = 2 * sx + 19; - LvlViewY = 2 * sy + 20; - } + if (ldir == 0) { + LvlViewX = 2 * sx + 19; + LvlViewY = 2 * sy + 20; + } - if (sx < cx && sy < cy) - return 0; - if (sx > cx && sy < cy) - return 1; - if (sx < cx && sy > cy) - return 2; - else - return 3; + if (sx < cx && sy < cy) + return 0; + if (sx > cx && sy < cy) + return 1; + if (sx < cx && sy > cy) + return 2; + else + return 3; } // 5A5590: using guessed type char TransVal; // 5CF320: using guessed type int LvlViewY; @@ -929,220 +879,218 @@ int __fastcall DRLG_PlaceMiniSet(const unsigned char *miniset, int tmin, int tma void __cdecl InitL5Dungeon() { - for (int j = 0; j < DMAXY; j++) { - for (int i = 0; i < DMAXX; i++) { - dungeon[i][j] = 0; - mydflags[i][j] = 0; - } - } + for (int j = 0; j < DMAXY; j++) { + for (int i = 0; i < DMAXX; i++) { + dungeon[i][j] = 0; + mydflags[i][j] = 0; + } + } } void __cdecl L5ClearFlags() { - for (int j = 0; j < DMAXY; j++) { - for (int i = 0; i < DMAXX; i++) { - mydflags[i][j] &= 0xBF; - } - } + for (int j = 0; j < DMAXY; j++) { + for (int i = 0; i < DMAXX; i++) { + mydflags[i][j] &= 0xBF; + } + } } void __cdecl L5firstRoom() { - if (random(0, 2) == 0) { - int ys = 1; - int ye = 39; + if (random(0, 2) == 0) { + int ys = 1; + int ye = 39; - VR1 = random(0, 2); - VR2 = random(0, 2); - VR3 = random(0, 2); + VR1 = random(0, 2); + VR2 = random(0, 2); + VR3 = random(0, 2); - if (VR1 + VR3 <= 1) - VR2 = 1; - if (VR1) - L5drawRoom(15, 1, 10, 10); - else - ys = 18; + if (VR1 + VR3 <= 1) + VR2 = 1; + if (VR1) + L5drawRoom(15, 1, 10, 10); + else + ys = 18; - if (VR2) - L5drawRoom(15, 15, 10, 10); - if (VR3) - L5drawRoom(15, 29, 10, 10); - else - ye = 22; + if (VR2) + L5drawRoom(15, 15, 10, 10); + if (VR3) + L5drawRoom(15, 29, 10, 10); + else + ye = 22; - for (int y = ys; y < ye; y++) { - dungeon[17][y] = 1; - dungeon[18][y] = 1; - dungeon[19][y] = 1; - dungeon[20][y] = 1; - dungeon[21][y] = 1; - dungeon[22][y] = 1; - } + for (int y = ys; y < ye; y++) { + dungeon[17][y] = 1; + dungeon[18][y] = 1; + dungeon[19][y] = 1; + dungeon[20][y] = 1; + dungeon[21][y] = 1; + dungeon[22][y] = 1; + } - if (VR1) - L5roomGen(15, 1, 10, 10, 0); - if (VR2) - L5roomGen(15, 15, 10, 10, 0); - if (VR3) - L5roomGen(15, 29, 10, 10, 0); + if (VR1) + L5roomGen(15, 1, 10, 10, 0); + if (VR2) + L5roomGen(15, 15, 10, 10, 0); + if (VR3) + L5roomGen(15, 29, 10, 10, 0); - HR3 = 0; - HR2 = 0; - HR1 = 0; - } else { - int xs = 1; - int xe = 39; + HR3 = 0; + HR2 = 0; + HR1 = 0; + } else { + int xs = 1; + int xe = 39; - HR1 = random(0, 2); - HR2 = random(0, 2); - HR3 = random(0, 2); + HR1 = random(0, 2); + HR2 = random(0, 2); + HR3 = random(0, 2); - if (HR1 + HR3 <= 1) - HR2 = 1; - if (HR1) - L5drawRoom(1, 15, 10, 10); - else - xs = 18; + if (HR1 + HR3 <= 1) + HR2 = 1; + if (HR1) + L5drawRoom(1, 15, 10, 10); + else + xs = 18; - if (HR2) - L5drawRoom(15, 15, 10, 10); - if (HR3) - L5drawRoom(29, 15, 10, 10); - else - xe = 22; + if (HR2) + L5drawRoom(15, 15, 10, 10); + if (HR3) + L5drawRoom(29, 15, 10, 10); + else + xe = 22; - for (int x = xs; x < xe; x++) { - dungeon[x][17] = 1; - dungeon[x][18] = 1; - dungeon[x][19] = 1; - dungeon[x][20] = 1; - dungeon[x][21] = 1; - dungeon[x][22] = 1; - } + for (int x = xs; x < xe; x++) { + dungeon[x][17] = 1; + dungeon[x][18] = 1; + dungeon[x][19] = 1; + dungeon[x][20] = 1; + dungeon[x][21] = 1; + dungeon[x][22] = 1; + } - if (HR1) - L5roomGen(1, 15, 10, 10, 1); - if (HR2) - L5roomGen(15, 15, 10, 10, 1); - if (HR3) - L5roomGen(29, 15, 10, 10, 1); + if (HR1) + L5roomGen(1, 15, 10, 10, 1); + if (HR2) + L5roomGen(15, 15, 10, 10, 1); + if (HR3) + L5roomGen(29, 15, 10, 10, 1); - VR3 = 0; - VR2 = 0; - VR1 = 0; - } + VR3 = 0; + VR2 = 0; + VR1 = 0; + } } void __fastcall L5drawRoom(int x, int y, int w, int h) { - for (int j = 0; j < h; j++) { - for (int i = 0; i < w; i++) { - dungeon[x + i][y + j] = 1; - } - } + for (int j = 0; j < h; j++) { + for (int i = 0; i < w; i++) { + dungeon[x + i][y + j] = 1; + } + } } void __fastcall L5roomGen(int x, int y, int w, int h, int dir) { - int num; - BOOL ran, ran2; - int width, height, rx, ry, ry2; - int cw, ch, cx1, cy1, cx2; + int num; + BOOL ran, ran2; + int width, height, rx, ry, ry2; + int cw, ch, cx1, cy1, cx2; - int dirProb = random(0, 4); + int dirProb = random(0, 4); - switch (dir == 1 ? dirProb != 0 : dirProb == 0) { - case FALSE: - num = 0; - do { - cw = (random(0, 5) + 2) & 0xFFFFFFFE; - ch = (random(0, 5) + 2) & 0xFFFFFFFE; - cy1 = h / 2 + y - ch / 2; - cx1 = x - cw; - ran = L5checkRoom(cx1 - 1, cy1 - 1, ch + 2, cw + 1); /// BUGFIX: swap args 3 and 4 ("ch+2" and "cw+1") - num++; - } while (ran == FALSE && num < 20); + switch (dir == 1 ? dirProb != 0 : dirProb == 0) { + case FALSE: + num = 0; + do { + cw = (random(0, 5) + 2) & 0xFFFFFFFE; + ch = (random(0, 5) + 2) & 0xFFFFFFFE; + cy1 = h / 2 + y - ch / 2; + cx1 = x - cw; + ran = L5checkRoom(cx1 - 1, cy1 - 1, ch + 2, cw + 1); /// BUGFIX: swap args 3 and 4 ("ch+2" and "cw+1") + num++; + } while (ran == FALSE && num < 20); - if (ran == TRUE) - L5drawRoom(cx1, cy1, cw, ch); - cx2 = x + w; - ran2 = L5checkRoom(cx2, cy1 - 1, cw + 1, ch + 2); - if (ran2 == TRUE) - L5drawRoom(cx2, cy1, cw, ch); - if (ran == TRUE) - L5roomGen(cx1, cy1, cw, ch, 1); - if (ran2 == TRUE) - L5roomGen(cx2, cy1, cw, ch, 1); - break; - case TRUE: - num = 0; - do { - width = (random(0, 5) + 2) & 0xFFFFFFFE; - height = (random(0, 5) + 2) & 0xFFFFFFFE; - rx = w / 2 + x - width / 2; - ry = y - height; - ran = L5checkRoom(rx - 1, ry - 1, width + 2, height + 1); - num++; - } while (ran == FALSE && num < 20); + if (ran == TRUE) + L5drawRoom(cx1, cy1, cw, ch); + cx2 = x + w; + ran2 = L5checkRoom(cx2, cy1 - 1, cw + 1, ch + 2); + if (ran2 == TRUE) + L5drawRoom(cx2, cy1, cw, ch); + if (ran == TRUE) + L5roomGen(cx1, cy1, cw, ch, 1); + if (ran2 == TRUE) + L5roomGen(cx2, cy1, cw, ch, 1); + break; + case TRUE: + num = 0; + do { + width = (random(0, 5) + 2) & 0xFFFFFFFE; + height = (random(0, 5) + 2) & 0xFFFFFFFE; + rx = w / 2 + x - width / 2; + ry = y - height; + ran = L5checkRoom(rx - 1, ry - 1, width + 2, height + 1); + num++; + } while (ran == FALSE && num < 20); - if (ran == TRUE) - L5drawRoom(rx, ry, width, height); - ry2 = y + h; - ran2 = L5checkRoom(rx - 1, ry2, width + 2, height + 1); - if (ran2 == TRUE) - L5drawRoom(rx, ry2, width, height); - if (ran == TRUE) - L5roomGen(rx, ry, width, height, 0); - if (ran2 == TRUE) - L5roomGen(rx, ry2, width, height, 0); - break; - } + if (ran == TRUE) + L5drawRoom(rx, ry, width, height); + ry2 = y + h; + ran2 = L5checkRoom(rx - 1, ry2, width + 2, height + 1); + if (ran2 == TRUE) + L5drawRoom(rx, ry2, width, height); + if (ran == TRUE) + L5roomGen(rx, ry, width, height, 0); + if (ran2 == TRUE) + L5roomGen(rx, ry2, width, height, 0); + break; + } } BOOL __fastcall L5checkRoom(int x, int y, int width, int height) { - for (int j = 0; j < height; j++) { - for (int i = 0; i < width; i++) { - if (i + x < 0 || i + x >= DMAXX || j + y < 0 || j + y >= DMAXY) - return FALSE; - if (dungeon[i + x][j + y]) - return FALSE; - } - } + for (int j = 0; j < height; j++) { + for (int i = 0; i < width; i++) { + if (i + x < 0 || i + x >= DMAXX || j + y < 0 || j + y >= DMAXY) + return FALSE; + if (dungeon[i + x][j + y]) + return FALSE; + } + } - return TRUE; + return TRUE; } int __cdecl L5GetArea() { - int rv = 0; + int rv = 0; - for (int j = 0; j < DMAXY; j++) { - for (int i = 0; i < DMAXX; i++) { - if (dungeon[i][j] == 1) - rv++; - } - } + for (int j = 0; j < DMAXY; j++) { + for (int i = 0; i < DMAXX; i++) { + if (dungeon[i][j] == 1) + rv++; + } + } - return rv; + return rv; } void __cdecl L5makeDungeon() { signed int v0; // edi signed int v1; // esi - char *v2; // edx - char v3; // cl - int v4; // eax - int v5; // eax + char *v2; // edx + char v3; // cl + int v4; // eax + int v5; // eax v0 = 0; - do - { + do { v1 = 0; v2 = (char *)dungeon + v0; - do - { + do { v3 = *v2; v2 += 40; v4 = 160 * v1++; @@ -1151,500 +1099,497 @@ void __cdecl L5makeDungeon() L5dungeon[0][v5 + 1] = v3; L5dungeon[1][v5] = v3; L5dungeon[1][v5 + 1] = v3; - } - while ( v1 < 40 ); + } while (v1 < 40); ++v0; - } - while ( v0 < 40 ); + } while (v0 < 40); } void __cdecl L5makeDmt() { - int i, j, dmtx, dmty; + int i, j, dmtx, dmty; - for (j = 0; j < DMAXY; j++) { - for (i = 0; i < DMAXX; i++) { - dungeon[i][j] = 22; - } - } + for (j = 0; j < DMAXY; j++) { + for (i = 0; i < DMAXX; i++) { + dungeon[i][j] = 22; + } + } - for (j = 0, dmty = 1; dmty <= 77; j++, dmty += 2) { - for (i = 0, dmtx = 1; dmtx <= 77; i++, dmtx += 2) { - int val = (unsigned char)L5dungeon[dmtx + 1][dmty + 1]; /* todo: unsigned */ - val = 2 * val + (unsigned char)L5dungeon[dmtx][dmty + 1]; - val = 2 * val + (unsigned char)L5dungeon[dmtx + 1][dmty]; - val = 2 * val + (unsigned char)L5dungeon[dmtx][dmty]; - dungeon[i][j] = L5ConvTbl[val]; - } - } + for (j = 0, dmty = 1; dmty <= 77; j++, dmty += 2) { + for (i = 0, dmtx = 1; dmtx <= 77; i++, dmtx += 2) { + int val = (unsigned char)L5dungeon[dmtx + 1][dmty + 1]; /* todo: unsigned */ + val = 2 * val + (unsigned char)L5dungeon[dmtx][dmty + 1]; + val = 2 * val + (unsigned char)L5dungeon[dmtx + 1][dmty]; + val = 2 * val + (unsigned char)L5dungeon[dmtx][dmty]; + dungeon[i][j] = L5ConvTbl[val]; + } + } } void __cdecl L5AddWall() { - for (int j = 0; j < DMAXY; j++) { - for (int i = 0; i < DMAXX; i++) { - if (!mydflags[i][j]) { - if (dungeon[i][j] == 3 && random(0, 100) < 100) { - int x = L5HWallOk(i, j); - if (x != -1) - L5HorizWall(i, j, 2, x); - } - if (dungeon[i][j] == 3 && random(0, 100) < 100) { - int y = L5VWallOk(i, j); - if (y != -1) - L5VertWall(i, j, 1, y); - } - if (dungeon[i][j] == 6 && random(0, 100) < 100) { - int x = L5HWallOk(i, j); - if (x != -1) - L5HorizWall(i, j, 4, x); - } - if (dungeon[i][j] == 7 && random(0, 100) < 100) { - int y = L5VWallOk(i, j); - if (y != -1) - L5VertWall(i, j, 4, y); - } - if (dungeon[i][j] == 2 && random(0, 100) < 100) { - int x = L5HWallOk(i, j); - if (x != -1) - L5HorizWall(i, j, 2, x); - } - if (dungeon[i][j] == 1 && random(0, 100) < 100) { - int y = L5VWallOk(i, j); - if (y != -1) - L5VertWall(i, j, 1, y); - } - } - } - } + for (int j = 0; j < DMAXY; j++) { + for (int i = 0; i < DMAXX; i++) { + if (!mydflags[i][j]) { + if (dungeon[i][j] == 3 && random(0, 100) < 100) { + int x = L5HWallOk(i, j); + if (x != -1) + L5HorizWall(i, j, 2, x); + } + if (dungeon[i][j] == 3 && random(0, 100) < 100) { + int y = L5VWallOk(i, j); + if (y != -1) + L5VertWall(i, j, 1, y); + } + if (dungeon[i][j] == 6 && random(0, 100) < 100) { + int x = L5HWallOk(i, j); + if (x != -1) + L5HorizWall(i, j, 4, x); + } + if (dungeon[i][j] == 7 && random(0, 100) < 100) { + int y = L5VWallOk(i, j); + if (y != -1) + L5VertWall(i, j, 4, y); + } + if (dungeon[i][j] == 2 && random(0, 100) < 100) { + int x = L5HWallOk(i, j); + if (x != -1) + L5HorizWall(i, j, 2, x); + } + if (dungeon[i][j] == 1 && random(0, 100) < 100) { + int y = L5VWallOk(i, j); + if (y != -1) + L5VertWall(i, j, 1, y); + } + } + } + } } int __fastcall L5HWallOk(int i, int j) { - int x; + int x; - for (x = 1; dungeon[i + x][j] == 13; x++) { - if (dungeon[i + x][j - 1] != 13 || dungeon[i + x][j + 1] != 13 || mydflags[i + x][j]) - break; - } + for (x = 1; dungeon[i + x][j] == 13; x++) { + if (dungeon[i + x][j - 1] != 13 || dungeon[i + x][j + 1] != 13 || mydflags[i + x][j]) + break; + } - BOOL wallok = FALSE; - if ((unsigned char)dungeon[i + x][j] >= 3 && (unsigned char)dungeon[i + x][j] <= 7) /* todo: unsigned */ - wallok = TRUE; - if ((unsigned char)dungeon[i + x][j] >= 16 && (unsigned char)dungeon[i + x][j] <= 24) - wallok = TRUE; - if (dungeon[i + x][j] == 22) - wallok = FALSE; - if (x == 1) - wallok = FALSE; + BOOL wallok = FALSE; + if ((unsigned char)dungeon[i + x][j] >= 3 && (unsigned char)dungeon[i + x][j] <= 7) /* todo: unsigned */ + wallok = TRUE; + if ((unsigned char)dungeon[i + x][j] >= 16 && (unsigned char)dungeon[i + x][j] <= 24) + wallok = TRUE; + if (dungeon[i + x][j] == 22) + wallok = FALSE; + if (x == 1) + wallok = FALSE; - if (wallok) - return x; - else - return -1; + if (wallok) + return x; + else + return -1; } int __fastcall L5VWallOk(int i, int j) { - int y; + int y; - for (y = 1; dungeon[i][j + y] == 13; y++) { - if (dungeon[i - 1][j + y] != 13 || dungeon[i + 1][j + y] != 13 || mydflags[i][j + y]) - break; - } + for (y = 1; dungeon[i][j + y] == 13; y++) { + if (dungeon[i - 1][j + y] != 13 || dungeon[i + 1][j + y] != 13 || mydflags[i][j + y]) + break; + } - BOOL wallok = FALSE; - if ((unsigned char)dungeon[i][j + y] >= 3 && (unsigned char)dungeon[i][j + y] <= 7) /* todo: unsigned */ - wallok = TRUE; - if ((unsigned char)dungeon[i][j + y] >= 16 && (unsigned char)dungeon[i][j + y] <= 24) - wallok = TRUE; - if (dungeon[i][j + y] == 22) - wallok = FALSE; - if (y == 1) - wallok = FALSE; + BOOL wallok = FALSE; + if ((unsigned char)dungeon[i][j + y] >= 3 && (unsigned char)dungeon[i][j + y] <= 7) /* todo: unsigned */ + wallok = TRUE; + if ((unsigned char)dungeon[i][j + y] >= 16 && (unsigned char)dungeon[i][j + y] <= 24) + wallok = TRUE; + if (dungeon[i][j + y] == 22) + wallok = FALSE; + if (y == 1) + wallok = FALSE; - if (wallok) - return y; - else - return -1; + if (wallok) + return y; + else + return -1; } void __fastcall L5HorizWall(int i, int j, char p, int dx) { - int xx; - char wt, dt; + int xx; + char wt, dt; - switch (random(0, 4)) { - case 0: - case 1: - dt = 2; - break; - case 2: - dt = 12; - if (p == 2) - p = 12; - if (p == 4) - p = 10; - break; - case 3: - dt = 36; - if (p == 2) - p = 36; - if (p == 4) - p = 27; - break; - default: - break; - } + switch (random(0, 4)) { + case 0: + case 1: + dt = 2; + break; + case 2: + dt = 12; + if (p == 2) + p = 12; + if (p == 4) + p = 10; + break; + case 3: + dt = 36; + if (p == 2) + p = 36; + if (p == 4) + p = 27; + break; + default: + break; + } - if (random(0, 6) == 5) - wt = 12; - else - wt = 26; - if (dt == 12) - wt = 12; + if (random(0, 6) == 5) + wt = 12; + else + wt = 26; + if (dt == 12) + wt = 12; - dungeon[i][j] = p; + dungeon[i][j] = p; - for (xx = 1; xx < dx; xx++) { - dungeon[i + xx][j] = dt; - } + for (xx = 1; xx < dx; xx++) { + dungeon[i + xx][j] = dt; + } - xx = random(0, dx - 1) + 1; + xx = random(0, dx - 1) + 1; - if (wt == 12) { - dungeon[i + xx][j] = wt; - } else { - dungeon[i + xx][j] = 2; - mydflags[i + xx][j] |= 1; - } + if (wt == 12) { + dungeon[i + xx][j] = wt; + } else { + dungeon[i + xx][j] = 2; + mydflags[i + xx][j] |= 1; + } } void __fastcall L5VertWall(int i, int j, char p, int dy) { - int yy; - char wt, dt; + int yy; + char wt, dt; - switch (random(0, 4)) { - case 0: - case 1: - dt = 1; - break; - case 2: - dt = 11; - if (p == 1) - p = 11; - if (p == 4) - p = 14; - break; - case 3: - dt = 35; - if (p == 1) - p = 35; - if (p == 4) - p = 37; - break; - default: - break; - } + switch (random(0, 4)) { + case 0: + case 1: + dt = 1; + break; + case 2: + dt = 11; + if (p == 1) + p = 11; + if (p == 4) + p = 14; + break; + case 3: + dt = 35; + if (p == 1) + p = 35; + if (p == 4) + p = 37; + break; + default: + break; + } - if (random(0, 6) == 5) - wt = 11; - else - wt = 25; - if (dt == 11) - wt = 11; + if (random(0, 6) == 5) + wt = 11; + else + wt = 25; + if (dt == 11) + wt = 11; - dungeon[i][j] = p; + dungeon[i][j] = p; - for (yy = 1; yy < dy; yy++) { - dungeon[i][j + yy] = dt; - } + for (yy = 1; yy < dy; yy++) { + dungeon[i][j + yy] = dt; + } - yy = random(0, dy - 1) + 1; + yy = random(0, dy - 1) + 1; - if (wt == 11) { - dungeon[i][j + yy] = wt; - } else { - dungeon[i][j + yy] = 1; - mydflags[i][j + yy] |= 2; - } + if (wt == 11) { + dungeon[i][j + yy] = wt; + } else { + dungeon[i][j + yy] = 1; + mydflags[i][j + yy] |= 2; + } } void __cdecl L5tileFix() { - int i, j; + int i, j; - for (j = 0; j < DMAXY; j++) { - for (i = 0; i < DMAXX; i++) { - if (dungeon[i][j] == 2 && dungeon[i + 1][j] == 22) - dungeon[i + 1][j] = 23; - if (dungeon[i][j] == 13 && dungeon[i + 1][j] == 22) - dungeon[i + 1][j] = 18; - if (dungeon[i][j] == 13 && dungeon[i + 1][j] == 2) - dungeon[i + 1][j] = 7; - if (dungeon[i][j] == 6 && dungeon[i + 1][j] == 22) - dungeon[i + 1][j] = 24; - if (dungeon[i][j] == 1 && dungeon[i][j + 1] == 22) - dungeon[i][j + 1] = 24; - if (dungeon[i][j] == 13 && dungeon[i][j + 1] == 1) - dungeon[i][j + 1] = 6; - if (dungeon[i][j] == 13 && dungeon[i][j + 1] == 22) - dungeon[i][j + 1] = 19; - } - } + for (j = 0; j < DMAXY; j++) { + for (i = 0; i < DMAXX; i++) { + if (dungeon[i][j] == 2 && dungeon[i + 1][j] == 22) + dungeon[i + 1][j] = 23; + if (dungeon[i][j] == 13 && dungeon[i + 1][j] == 22) + dungeon[i + 1][j] = 18; + if (dungeon[i][j] == 13 && dungeon[i + 1][j] == 2) + dungeon[i + 1][j] = 7; + if (dungeon[i][j] == 6 && dungeon[i + 1][j] == 22) + dungeon[i + 1][j] = 24; + if (dungeon[i][j] == 1 && dungeon[i][j + 1] == 22) + dungeon[i][j + 1] = 24; + if (dungeon[i][j] == 13 && dungeon[i][j + 1] == 1) + dungeon[i][j + 1] = 6; + if (dungeon[i][j] == 13 && dungeon[i][j + 1] == 22) + dungeon[i][j + 1] = 19; + } + } - for (j = 0; j < DMAXY; j++) { - for (i = 0; i < DMAXX; i++) { - if (dungeon[i][j] == 13 && dungeon[i + 1][j] == 19) - dungeon[i + 1][j] = 21; - if (dungeon[i][j] == 13 && dungeon[i + 1][j] == 22) - dungeon[i + 1][j] = 20; - if (dungeon[i][j] == 7 && dungeon[i + 1][j] == 22) - dungeon[i + 1][j] = 23; - if (dungeon[i][j] == 13 && dungeon[i + 1][j] == 24) - dungeon[i + 1][j] = 21; - if (dungeon[i][j] == 19 && dungeon[i + 1][j] == 22) - dungeon[i + 1][j] = 20; - if (dungeon[i][j] == 2 && dungeon[i + 1][j] == 19) - dungeon[i + 1][j] = 21; - if (dungeon[i][j] == 19 && dungeon[i + 1][j] == 1) - dungeon[i + 1][j] = 6; - if (dungeon[i][j] == 7 && dungeon[i + 1][j] == 19) - dungeon[i + 1][j] = 21; - if (dungeon[i][j] == 2 && dungeon[i + 1][j] == 1) - dungeon[i + 1][j] = 6; - if (dungeon[i][j] == 3 && dungeon[i + 1][j] == 22) - dungeon[i + 1][j] = 24; - if (dungeon[i][j] == 21 && dungeon[i + 1][j] == 1) - dungeon[i + 1][j] = 6; - if (dungeon[i][j] == 7 && dungeon[i + 1][j] == 1) - dungeon[i + 1][j] = 6; - if (dungeon[i][j] == 7 && dungeon[i + 1][j] == 24) - dungeon[i + 1][j] = 21; - if (dungeon[i][j] == 4 && dungeon[i + 1][j] == 16) - dungeon[i + 1][j] = 17; - if (dungeon[i][j] == 7 && dungeon[i + 1][j] == 13) - dungeon[i + 1][j] = 17; - if (dungeon[i][j] == 2 && dungeon[i + 1][j] == 24) - dungeon[i + 1][j] = 21; - if (dungeon[i][j] == 2 && dungeon[i + 1][j] == 13) - dungeon[i + 1][j] = 17; - if (dungeon[i][j] == 23 && dungeon[i - 1][j] == 22) - dungeon[i - 1][j] = 19; - if (dungeon[i][j] == 19 && dungeon[i - 1][j] == 23) - dungeon[i - 1][j] = 21; - if (dungeon[i][j] == 6 && dungeon[i - 1][j] == 22) - dungeon[i - 1][j] = 24; - if (dungeon[i][j] == 6 && dungeon[i - 1][j] == 23) - dungeon[i - 1][j] = 21; - if (dungeon[i][j] == 1 && dungeon[i][j + 1] == 2) - dungeon[i][j + 1] = 7; - if (dungeon[i][j] == 6 && dungeon[i][j + 1] == 18) - dungeon[i][j + 1] = 21; - if (dungeon[i][j] == 18 && dungeon[i][j + 1] == 2) - dungeon[i][j + 1] = 7; - if (dungeon[i][j] == 6 && dungeon[i][j + 1] == 2) - dungeon[i][j + 1] = 7; - if (dungeon[i][j] == 21 && dungeon[i][j + 1] == 2) - dungeon[i][j + 1] = 7; - if (dungeon[i][j] == 6 && dungeon[i][j + 1] == 22) - dungeon[i][j + 1] = 24; - if (dungeon[i][j] == 6 && dungeon[i][j + 1] == 13) - dungeon[i][j + 1] = 16; - if (dungeon[i][j] == 1 && dungeon[i][j + 1] == 13) - dungeon[i][j + 1] = 16; - if (dungeon[i][j] == 13 && dungeon[i][j + 1] == 16) - dungeon[i][j + 1] = 17; - if (dungeon[i][j] == 6 && dungeon[i][j - 1] == 22) - dungeon[i][j - 1] = 7; - if (dungeon[i][j] == 6 && dungeon[i][j - 1] == 22) - dungeon[i][j - 1] = 24; - if (dungeon[i][j] == 7 && dungeon[i][j - 1] == 24) - dungeon[i][j - 1] = 21; - if (dungeon[i][j] == 18 && dungeon[i][j - 1] == 24) - dungeon[i][j - 1] = 21; - } - } + for (j = 0; j < DMAXY; j++) { + for (i = 0; i < DMAXX; i++) { + if (dungeon[i][j] == 13 && dungeon[i + 1][j] == 19) + dungeon[i + 1][j] = 21; + if (dungeon[i][j] == 13 && dungeon[i + 1][j] == 22) + dungeon[i + 1][j] = 20; + if (dungeon[i][j] == 7 && dungeon[i + 1][j] == 22) + dungeon[i + 1][j] = 23; + if (dungeon[i][j] == 13 && dungeon[i + 1][j] == 24) + dungeon[i + 1][j] = 21; + if (dungeon[i][j] == 19 && dungeon[i + 1][j] == 22) + dungeon[i + 1][j] = 20; + if (dungeon[i][j] == 2 && dungeon[i + 1][j] == 19) + dungeon[i + 1][j] = 21; + if (dungeon[i][j] == 19 && dungeon[i + 1][j] == 1) + dungeon[i + 1][j] = 6; + if (dungeon[i][j] == 7 && dungeon[i + 1][j] == 19) + dungeon[i + 1][j] = 21; + if (dungeon[i][j] == 2 && dungeon[i + 1][j] == 1) + dungeon[i + 1][j] = 6; + if (dungeon[i][j] == 3 && dungeon[i + 1][j] == 22) + dungeon[i + 1][j] = 24; + if (dungeon[i][j] == 21 && dungeon[i + 1][j] == 1) + dungeon[i + 1][j] = 6; + if (dungeon[i][j] == 7 && dungeon[i + 1][j] == 1) + dungeon[i + 1][j] = 6; + if (dungeon[i][j] == 7 && dungeon[i + 1][j] == 24) + dungeon[i + 1][j] = 21; + if (dungeon[i][j] == 4 && dungeon[i + 1][j] == 16) + dungeon[i + 1][j] = 17; + if (dungeon[i][j] == 7 && dungeon[i + 1][j] == 13) + dungeon[i + 1][j] = 17; + if (dungeon[i][j] == 2 && dungeon[i + 1][j] == 24) + dungeon[i + 1][j] = 21; + if (dungeon[i][j] == 2 && dungeon[i + 1][j] == 13) + dungeon[i + 1][j] = 17; + if (dungeon[i][j] == 23 && dungeon[i - 1][j] == 22) + dungeon[i - 1][j] = 19; + if (dungeon[i][j] == 19 && dungeon[i - 1][j] == 23) + dungeon[i - 1][j] = 21; + if (dungeon[i][j] == 6 && dungeon[i - 1][j] == 22) + dungeon[i - 1][j] = 24; + if (dungeon[i][j] == 6 && dungeon[i - 1][j] == 23) + dungeon[i - 1][j] = 21; + if (dungeon[i][j] == 1 && dungeon[i][j + 1] == 2) + dungeon[i][j + 1] = 7; + if (dungeon[i][j] == 6 && dungeon[i][j + 1] == 18) + dungeon[i][j + 1] = 21; + if (dungeon[i][j] == 18 && dungeon[i][j + 1] == 2) + dungeon[i][j + 1] = 7; + if (dungeon[i][j] == 6 && dungeon[i][j + 1] == 2) + dungeon[i][j + 1] = 7; + if (dungeon[i][j] == 21 && dungeon[i][j + 1] == 2) + dungeon[i][j + 1] = 7; + if (dungeon[i][j] == 6 && dungeon[i][j + 1] == 22) + dungeon[i][j + 1] = 24; + if (dungeon[i][j] == 6 && dungeon[i][j + 1] == 13) + dungeon[i][j + 1] = 16; + if (dungeon[i][j] == 1 && dungeon[i][j + 1] == 13) + dungeon[i][j + 1] = 16; + if (dungeon[i][j] == 13 && dungeon[i][j + 1] == 16) + dungeon[i][j + 1] = 17; + if (dungeon[i][j] == 6 && dungeon[i][j - 1] == 22) + dungeon[i][j - 1] = 7; + if (dungeon[i][j] == 6 && dungeon[i][j - 1] == 22) + dungeon[i][j - 1] = 24; + if (dungeon[i][j] == 7 && dungeon[i][j - 1] == 24) + dungeon[i][j - 1] = 21; + if (dungeon[i][j] == 18 && dungeon[i][j - 1] == 24) + dungeon[i][j - 1] = 21; + } + } - for (j = 0; j < DMAXY; j++) { - for (i = 0; i < DMAXX; i++) { - if (dungeon[i][j] == 4 && dungeon[i][j + 1] == 2) - dungeon[i][j + 1] = 7; - if (dungeon[i][j] == 2 && dungeon[i + 1][j] == 19) - dungeon[i + 1][j] = 21; - if (dungeon[i][j] == 18 && dungeon[i][j + 1] == 22) - dungeon[i][j + 1] = 20; - } - } + for (j = 0; j < DMAXY; j++) { + for (i = 0; i < DMAXX; i++) { + if (dungeon[i][j] == 4 && dungeon[i][j + 1] == 2) + dungeon[i][j + 1] = 7; + if (dungeon[i][j] == 2 && dungeon[i + 1][j] == 19) + dungeon[i + 1][j] = 21; + if (dungeon[i][j] == 18 && dungeon[i][j + 1] == 22) + dungeon[i][j + 1] = 20; + } + } } void __cdecl DRLG_L5Subs() { - for (int y = 0; y < DMAXY; y++) { - for (int x = 0; x < DMAXX; x++) { - if (!random(0, 4)) { - unsigned char c = L5BTYPES[(unsigned char)dungeon[x][y]]; /* todo: changed to unsigned */ + for (int y = 0; y < DMAXY; y++) { + for (int x = 0; x < DMAXX; x++) { + if (!random(0, 4)) { + unsigned char c = L5BTYPES[(unsigned char)dungeon[x][y]]; /* todo: changed to unsigned */ - if (c && !mydflags[x][y]) { - int rv = random(0, 16); - int i = -1; + if (c && !mydflags[x][y]) { + int rv = random(0, 16); + int i = -1; - while (rv >= 0) { - if (++i == sizeof(L5BTYPES)) - i = 0; - if (c == L5BTYPES[i]) - rv--; - } + while (rv >= 0) { + if (++i == sizeof(L5BTYPES)) + i = 0; + if (c == L5BTYPES[i]) + rv--; + } - if (i == 89) { - if (L5BTYPES[(unsigned char)dungeon[x][y - 1]] != 79 || mydflags[x][y - 1]) - i = 79; - else - dungeon[x][y - 1] = 90; - } - if (i == 91) { - if (L5BTYPES[(unsigned char)dungeon[x + 1][y]] != 80 || mydflags[x + 1][y]) - i = 80; - else - dungeon[x + 1][y] = 92; - } - dungeon[x][y] = i; - } - } - } - } + if (i == 89) { + if (L5BTYPES[(unsigned char)dungeon[x][y - 1]] != 79 || mydflags[x][y - 1]) + i = 79; + else + dungeon[x][y - 1] = 90; + } + if (i == 91) { + if (L5BTYPES[(unsigned char)dungeon[x + 1][y]] != 80 || mydflags[x + 1][y]) + i = 80; + else + dungeon[x + 1][y] = 92; + } + dungeon[x][y] = i; + } + } + } + } } void __cdecl L5FillChambers() { - int c; + int c; - if (HR1) - DRLG_L5GChamber(0, 14, 0, 0, 0, 1); + if (HR1) + DRLG_L5GChamber(0, 14, 0, 0, 0, 1); - if (HR2) { - if (HR1 && !HR3) - DRLG_L5GChamber(14, 14, 0, 0, 1, 0); - if (!HR1 && HR3) - DRLG_L5GChamber(14, 14, 0, 0, 0, 1); - if (HR1 && HR3) - DRLG_L5GChamber(14, 14, 0, 0, 1, 1); - if (!HR1 && !HR3) - DRLG_L5GChamber(14, 14, 0, 0, 0, 0); - } + if (HR2) { + if (HR1 && !HR3) + DRLG_L5GChamber(14, 14, 0, 0, 1, 0); + if (!HR1 && HR3) + DRLG_L5GChamber(14, 14, 0, 0, 0, 1); + if (HR1 && HR3) + DRLG_L5GChamber(14, 14, 0, 0, 1, 1); + if (!HR1 && !HR3) + DRLG_L5GChamber(14, 14, 0, 0, 0, 0); + } - if (HR3) - DRLG_L5GChamber(28, 14, 0, 0, 1, 0); - if (HR1 && HR2) - DRLG_L5GHall(12, 18, 14, 18); - if (HR2 && HR3) - DRLG_L5GHall(26, 18, 28, 18); - if (HR1 && !HR2 && HR3) - DRLG_L5GHall(12, 18, 28, 18); - if (VR1) - DRLG_L5GChamber(14, 0, 0, 1, 0, 0); + if (HR3) + DRLG_L5GChamber(28, 14, 0, 0, 1, 0); + if (HR1 && HR2) + DRLG_L5GHall(12, 18, 14, 18); + if (HR2 && HR3) + DRLG_L5GHall(26, 18, 28, 18); + if (HR1 && !HR2 && HR3) + DRLG_L5GHall(12, 18, 28, 18); + if (VR1) + DRLG_L5GChamber(14, 0, 0, 1, 0, 0); - if (VR2) { - if (VR1 && !VR3) - DRLG_L5GChamber(14, 14, 1, 0, 0, 0); - if (!VR1 && VR3) - DRLG_L5GChamber(14, 14, 0, 1, 0, 0); - if (VR1 && VR3) - DRLG_L5GChamber(14, 14, 1, 1, 0, 0); - if (!VR1 && !VR3) - DRLG_L5GChamber(14, 14, 0, 0, 0, 0); - } + if (VR2) { + if (VR1 && !VR3) + DRLG_L5GChamber(14, 14, 1, 0, 0, 0); + if (!VR1 && VR3) + DRLG_L5GChamber(14, 14, 0, 1, 0, 0); + if (VR1 && VR3) + DRLG_L5GChamber(14, 14, 1, 1, 0, 0); + if (!VR1 && !VR3) + DRLG_L5GChamber(14, 14, 0, 0, 0, 0); + } - if (VR3) - DRLG_L5GChamber(14, 28, 1, 0, 0, 0); - if (VR1 && VR2) - DRLG_L5GHall(18, 12, 18, 14); - if (VR2 && VR3) - DRLG_L5GHall(18, 26, 18, 28); - if (VR1 && !VR2 && VR3) - DRLG_L5GHall(18, 12, 18, 28); + if (VR3) + DRLG_L5GChamber(14, 28, 1, 0, 0, 0); + if (VR1 && VR2) + DRLG_L5GHall(18, 12, 18, 14); + if (VR2 && VR3) + DRLG_L5GHall(18, 26, 18, 28); + if (VR1 && !VR2 && VR3) + DRLG_L5GHall(18, 12, 18, 28); - if (setloadflag) { - if (VR1 || VR2 || VR3) { - c = 1; - if (!VR1 && VR2 && VR3 && random(0, 2)) - c = 2; - if (VR1 && VR2 && !VR3 && random(0, 2)) - c = 0; + if (setloadflag) { + if (VR1 || VR2 || VR3) { + c = 1; + if (!VR1 && VR2 && VR3 && random(0, 2)) + c = 2; + if (VR1 && VR2 && !VR3 && random(0, 2)) + c = 0; - if (VR1 && !VR2 && VR3) { - if (random(0, 2)) - c = 0; - else - c = 2; - } + if (VR1 && !VR2 && VR3) { + if (random(0, 2)) + c = 0; + else + c = 2; + } - if (VR1 && VR2 && VR3) - c = random(0, 3); + if (VR1 && VR2 && VR3) + c = random(0, 3); - switch (c) { - case 0: - DRLG_L5SetRoom(16, 2); - break; - case 1: - DRLG_L5SetRoom(16, 16); - break; - case 2: - DRLG_L5SetRoom(16, 30); - break; - } - } else { - c = 1; - if (!HR1 && HR2 && HR3 && random(0, 2)) - c = 2; - if (HR1 && HR2 && !HR3 && random(0, 2)) - c = 0; + switch (c) { + case 0: + DRLG_L5SetRoom(16, 2); + break; + case 1: + DRLG_L5SetRoom(16, 16); + break; + case 2: + DRLG_L5SetRoom(16, 30); + break; + } + } else { + c = 1; + if (!HR1 && HR2 && HR3 && random(0, 2)) + c = 2; + if (HR1 && HR2 && !HR3 && random(0, 2)) + c = 0; - if (HR1 && !HR2 && HR3) { - if (random(0, 2)) - c = 0; - else - c = 2; - } + if (HR1 && !HR2 && HR3) { + if (random(0, 2)) + c = 0; + else + c = 2; + } - if (HR1 && HR2 && HR3) - c = random(0, 3); + if (HR1 && HR2 && HR3) + c = random(0, 3); - switch (c) { - case 0: - DRLG_L5SetRoom(2, 16); - break; - case 1: - DRLG_L5SetRoom(16, 16); - break; - case 2: - DRLG_L5SetRoom(30, 16); - break; - } - } - } + switch (c) { + case 0: + DRLG_L5SetRoom(2, 16); + break; + case 1: + DRLG_L5SetRoom(16, 16); + break; + case 2: + DRLG_L5SetRoom(30, 16); + break; + } + } + } } // 5276A4: using guessed type int setloadflag; void __fastcall DRLG_L5GChamber(int sx, int sy, bool topflag, bool bottomflag, bool leftflag, bool rightflag) { - int v6; // eax - int v7; // edx - int v8; // eax - char *v9; // eax - int v10; // eax - int v11; // ecx - int v12; // eax - char *v13; // eax + int v6; // eax + int v7; // edx + int v8; // eax + char *v9; // eax + int v10; // eax + int v11; // ecx + int v12; // eax + char *v13; // eax signed int v14; // edi - int v15; // eax - int v16; // edx - int v17; // ecx + int v15; // eax + int v16; // edx + int v17; // ecx signed int v18; // esi - if ( topflag == 1 ) - { + if (topflag == 1) { v6 = sy + 40 * sx; dungeon[2][v6] = 12; dungeon[3][v6] = 12; @@ -1653,8 +1598,7 @@ void __fastcall DRLG_L5GChamber(int sx, int sy, bool topflag, bool bottomflag, b dungeon[8][v6] = 12; dungeon[9][v6] = 2; } - if ( bottomflag == 1 ) - { + if (bottomflag == 1) { v7 = sy + 11; v8 = v7 + 40 * sx; dungeon[2][v8] = 10; @@ -1663,12 +1607,11 @@ void __fastcall DRLG_L5GChamber(int sx, int sy, bool topflag, bool bottomflag, b dungeon[7][v8] = 5; dungeon[8][v8] = 12; v9 = &dungeon[9][v8]; - if ( *v9 != 4 ) + if (*v9 != 4) *v9 = 21; sy = v7 - 11; } - if ( leftflag == 1 ) - { + if (leftflag == 1) { v10 = sy + 40 * sx; dungeon[0][v10 + 2] = 11; dungeon[0][v10 + 3] = 11; @@ -1677,8 +1620,7 @@ void __fastcall DRLG_L5GChamber(int sx, int sy, bool topflag, bool bottomflag, b dungeon[0][v10 + 8] = 11; dungeon[0][v10 + 9] = 1; } - if ( rightflag == 1 ) - { + if (rightflag == 1) { v11 = sx + 11; v12 = sy + 40 * v11; dungeon[0][v12 + 2] = 14; @@ -1687,29 +1629,25 @@ void __fastcall DRLG_L5GChamber(int sx, int sy, bool topflag, bool bottomflag, b dungeon[0][v12 + 7] = 5; dungeon[0][v12 + 8] = 11; v13 = &dungeon[0][v12 + 9]; - if ( *v13 != 4 ) + if (*v13 != 4) *v13 = 21; sx = v11 - 11; } v14 = 10; v15 = sy + 40 * sx; v16 = v15 + 1; - do - { + do { v17 = v16; v18 = 10; - do - { + do { mydflags[1][v17] |= 0x40u; dungeon[1][v17] = 13; v17 += 40; --v18; - } - while ( v18 ); + } while (v18); ++v16; --v14; - } - while ( v14 ); + } while (v14); dungeon[4][v15 + 4] = 15; dungeon[7][v15 + 4] = 15; dungeon[4][v15 + 7] = 15; @@ -1718,164 +1656,164 @@ void __fastcall DRLG_L5GChamber(int sx, int sy, bool topflag, bool bottomflag, b void __fastcall DRLG_L5GHall(int x1, int y1, int x2, int y2) { - int i; + int i; - if (y1 == y2) { - for (i = x1; i < x2; i++) { - dungeon[i][y1] = 12; - dungeon[i][y1 + 3] = 12; - } - } else { - for (i = y1; i < y2; i++) { - dungeon[x1][i] = 11; - dungeon[x1 + 3][i] = 11; - } - } + if (y1 == y2) { + for (i = x1; i < x2; i++) { + dungeon[i][y1] = 12; + dungeon[i][y1 + 3] = 12; + } + } else { + for (i = y1; i < y2; i++) { + dungeon[x1][i] = 11; + dungeon[x1 + 3][i] = 11; + } + } } void __fastcall DRLG_L5SetRoom(int rx1, int ry1) { - int rw = *(unsigned char *)pSetPiece; /* todo: BYTE */ - int rh = *((unsigned char *)pSetPiece + 2); + int rw = *(unsigned char *)pSetPiece; /* todo: BYTE */ + int rh = *((unsigned char *)pSetPiece + 2); - setpc_x = rx1; - setpc_y = ry1; - setpc_w = rw; - setpc_h = rh; + setpc_x = rx1; + setpc_y = ry1; + setpc_w = rw; + setpc_h = rh; - unsigned char *sp = (unsigned char *)pSetPiece + 4; + unsigned char *sp = (unsigned char *)pSetPiece + 4; - for (int j = 0; j < rh; j++) { - for (int i = 0; i < rw; i++) { - if (*sp) { - dungeon[rx1 + i][ry1 + j] = *sp; - mydflags[rx1 + i][ry1 + j] |= 0x80; - } else { - dungeon[rx1 + i][ry1 + j] = 13; - } - sp += 2; - } - } + for (int j = 0; j < rh; j++) { + for (int i = 0; i < rw; i++) { + if (*sp) { + dungeon[rx1 + i][ry1 + j] = *sp; + mydflags[rx1 + i][ry1 + j] |= 0x80; + } else { + dungeon[rx1 + i][ry1 + j] = 13; + } + sp += 2; + } + } } // 5CF330: using guessed type int setpc_h; // 5CF334: using guessed type int setpc_w; void __cdecl DRLG_L5FloodTVal() { - int yy = 16; + int yy = 16; - for (int j = 0; j < DMAXY; j++) { - int xx = 16; + for (int j = 0; j < DMAXY; j++) { + int xx = 16; - for (int i = 0; i < DMAXX; i++) { - if (dungeon[i][j] == 13 && !dung_map[xx][yy]) { - DRLG_L5FTVR(i, j, xx, yy, 0); - TransVal++; - } - xx += 2; - } - yy += 2; - } + for (int i = 0; i < DMAXX; i++) { + if (dungeon[i][j] == 13 && !dung_map[xx][yy]) { + DRLG_L5FTVR(i, j, xx, yy, 0); + TransVal++; + } + xx += 2; + } + yy += 2; + } } // 5A5590: using guessed type char TransVal; void __fastcall DRLG_L5FTVR(int i, int j, int x, int y, int d) { - if (dung_map[x][y] || dungeon[i][j] != 13) { - if (d == 1) { - dung_map[x][y] = TransVal; - dung_map[x][y + 1] = TransVal; - } - if (d == 2) { - dung_map[x + 1][y] = TransVal; - dung_map[x + 1][y + 1] = TransVal; - } - if (d == 3) { - dung_map[x][y] = TransVal; - dung_map[x + 1][y] = TransVal; - } - if (d == 4) { - dung_map[x][y + 1] = TransVal; - dung_map[x + 1][y + 1] = TransVal; - } - if (d == 5) - dung_map[x + 1][y + 1] = TransVal; - if (d == 6) - dung_map[x][y + 1] = TransVal; - if (d == 7) - dung_map[x + 1][y] = TransVal; - if (d == 8) - dung_map[x][y] = TransVal; - } else { - dung_map[x][y] = TransVal; - dung_map[x + 1][y] = TransVal; - dung_map[x][y + 1] = TransVal; - dung_map[x + 1][y + 1] = TransVal; - DRLG_L5FTVR(i + 1, j, x + 2, y, 1); - DRLG_L5FTVR(i - 1, j, x - 2, y, 2); - DRLG_L5FTVR(i, j + 1, x, y + 2, 3); - DRLG_L5FTVR(i, j - 1, x, y - 2, 4); - DRLG_L5FTVR(i - 1, j - 1, x - 2, y - 2, 5); - DRLG_L5FTVR(i + 1, j - 1, x + 2, y - 2, 6); - DRLG_L5FTVR(i - 1, j + 1, x - 2, y + 2, 7); - DRLG_L5FTVR(i + 1, j + 1, x + 2, y + 2, 8); - } + if (dung_map[x][y] || dungeon[i][j] != 13) { + if (d == 1) { + dung_map[x][y] = TransVal; + dung_map[x][y + 1] = TransVal; + } + if (d == 2) { + dung_map[x + 1][y] = TransVal; + dung_map[x + 1][y + 1] = TransVal; + } + if (d == 3) { + dung_map[x][y] = TransVal; + dung_map[x + 1][y] = TransVal; + } + if (d == 4) { + dung_map[x][y + 1] = TransVal; + dung_map[x + 1][y + 1] = TransVal; + } + if (d == 5) + dung_map[x + 1][y + 1] = TransVal; + if (d == 6) + dung_map[x][y + 1] = TransVal; + if (d == 7) + dung_map[x + 1][y] = TransVal; + if (d == 8) + dung_map[x][y] = TransVal; + } else { + dung_map[x][y] = TransVal; + dung_map[x + 1][y] = TransVal; + dung_map[x][y + 1] = TransVal; + dung_map[x + 1][y + 1] = TransVal; + DRLG_L5FTVR(i + 1, j, x + 2, y, 1); + DRLG_L5FTVR(i - 1, j, x - 2, y, 2); + DRLG_L5FTVR(i, j + 1, x, y + 2, 3); + DRLG_L5FTVR(i, j - 1, x, y - 2, 4); + DRLG_L5FTVR(i - 1, j - 1, x - 2, y - 2, 5); + DRLG_L5FTVR(i + 1, j - 1, x + 2, y - 2, 6); + DRLG_L5FTVR(i - 1, j + 1, x - 2, y + 2, 7); + DRLG_L5FTVR(i + 1, j + 1, x + 2, y + 2, 8); + } } // 5A5590: using guessed type char TransVal; void __cdecl DRLG_L5TransFix() { - int yy = 16; + int yy = 16; - for (int j = 0; j < DMAXY; j++) { - int xx = 16; + for (int j = 0; j < DMAXY; j++) { + int xx = 16; - for (int i = 0; i < DMAXX; i++) { - if (dungeon[i][j] == 23 && dungeon[i][j - 1] == 18) { - dung_map[xx + 1][yy] = dung_map[xx][yy]; - dung_map[xx + 1][yy + 1] = dung_map[xx][yy]; - } - if (dungeon[i][j] == 24 && dungeon[i + 1][j] == 19) { - dung_map[xx][yy + 1] = dung_map[xx][yy]; - dung_map[xx + 1][yy + 1] = dung_map[xx][yy]; - } - if (dungeon[i][j] == 18) { - dung_map[xx + 1][yy] = dung_map[xx][yy]; - dung_map[xx + 1][yy + 1] = dung_map[xx][yy]; - } - if (dungeon[i][j] == 19) { - dung_map[xx][yy + 1] = dung_map[xx][yy]; - dung_map[xx + 1][yy + 1] = dung_map[xx][yy]; - } - if (dungeon[i][j] == 20) { - dung_map[xx + 1][yy] = dung_map[xx][yy]; - dung_map[xx][yy + 1] = dung_map[xx][yy]; - dung_map[xx + 1][yy + 1] = dung_map[xx][yy]; - } - xx += 2; - } - yy += 2; - } + for (int i = 0; i < DMAXX; i++) { + if (dungeon[i][j] == 23 && dungeon[i][j - 1] == 18) { + dung_map[xx + 1][yy] = dung_map[xx][yy]; + dung_map[xx + 1][yy + 1] = dung_map[xx][yy]; + } + if (dungeon[i][j] == 24 && dungeon[i + 1][j] == 19) { + dung_map[xx][yy + 1] = dung_map[xx][yy]; + dung_map[xx + 1][yy + 1] = dung_map[xx][yy]; + } + if (dungeon[i][j] == 18) { + dung_map[xx + 1][yy] = dung_map[xx][yy]; + dung_map[xx + 1][yy + 1] = dung_map[xx][yy]; + } + if (dungeon[i][j] == 19) { + dung_map[xx][yy + 1] = dung_map[xx][yy]; + dung_map[xx + 1][yy + 1] = dung_map[xx][yy]; + } + if (dungeon[i][j] == 20) { + dung_map[xx + 1][yy] = dung_map[xx][yy]; + dung_map[xx][yy + 1] = dung_map[xx][yy]; + dung_map[xx + 1][yy + 1] = dung_map[xx][yy]; + } + xx += 2; + } + yy += 2; + } } void __cdecl DRLG_L5DirtFix() { - for (int j = 0; j < DMAXY; j++) { - for (int i = 0; i < DMAXX; i++) { - if (dungeon[i][j] == 21 && dungeon[i + 1][j] != 19) - dungeon[i][j] = 202; - if (dungeon[i][j] == 19 && dungeon[i + 1][j] != 19) - dungeon[i][j] = 200; - if (dungeon[i][j] == 24 && dungeon[i + 1][j] != 19) - dungeon[i][j] = 205; - if (dungeon[i][j] == 18 && dungeon[i][j + 1] != 18) - dungeon[i][j] = 199; - if (dungeon[i][j] == 21 && dungeon[i][j + 1] != 18) - dungeon[i][j] = 202; - if (dungeon[i][j] == 23 && dungeon[i][j + 1] != 18) - dungeon[i][j] = 204; - } - } + for (int j = 0; j < DMAXY; j++) { + for (int i = 0; i < DMAXX; i++) { + if (dungeon[i][j] == 21 && dungeon[i + 1][j] != 19) + dungeon[i][j] = 202; + if (dungeon[i][j] == 19 && dungeon[i + 1][j] != 19) + dungeon[i][j] = 200; + if (dungeon[i][j] == 24 && dungeon[i + 1][j] != 19) + dungeon[i][j] = 205; + if (dungeon[i][j] == 18 && dungeon[i][j + 1] != 18) + dungeon[i][j] = 199; + if (dungeon[i][j] == 21 && dungeon[i][j + 1] != 18) + dungeon[i][j] = 202; + if (dungeon[i][j] == 23 && dungeon[i][j + 1] != 18) + dungeon[i][j] = 204; + } + } } void __cdecl DRLG_L5CornerFix() @@ -1885,24 +1823,19 @@ void __cdecl DRLG_L5CornerFix() signed int v2; // edi v0 = 1; - do - { + do { v1 = v0; v2 = 38; - do - { - if ( mydflags[1][v1] >= 0 && dungeon[1][v1] == 17 && dungeon[0][v1] == 13 && dungeon[0][v1 + 39] == 1 ) - { + do { + if (mydflags[1][v1] >= 0 && dungeon[1][v1] == 17 && dungeon[0][v1] == 13 && dungeon[0][v1 + 39] == 1) { mydflags[0][v1 + 39] &= 0x80u; dungeon[1][v1] = 16; } - if ( dungeon[1][v1] == -54 && dungeon[2][v1] == 13 && dungeon[1][v1 + 1] == 1 ) + if (dungeon[1][v1] == -54 && dungeon[2][v1] == 13 && dungeon[1][v1 + 1] == 1) dungeon[1][v1] = 8; v1 += 40; --v2; - } - while ( v2 ); + } while (v2); ++v0; - } - while ( v0 < 39 ); + } while (v0 < 39); } diff --git a/Source/drlg_l2.cpp b/Source/drlg_l2.cpp index f7c23b14..022357b2 100644 --- a/Source/drlg_l2.cpp +++ b/Source/drlg_l2.cpp @@ -132,106 +132,106 @@ unsigned char CTRDOOR6[] = { 3, 3, 3, 1, 3, 0, 4, 0, 0, 13, 0, 0, 4, 0, 0, 1, 0, unsigned char CTRDOOR7[] = { 3, 3, 3, 1, 3, 0, 4, 0, 0, 16, 0, 0, 4, 0, 0, 1, 0, 0, 0, 0 }; unsigned char CTRDOOR8[] = { 3, 3, 3, 1, 3, 0, 4, 0, 0, 14, 0, 0, 4, 0, 0, 1, 0, 0, 0, 0 }; int Patterns[100][10] = { - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 3 }, - { 0, 0, 0, 0, 2, 0, 0, 0, 0, 3 }, - { 0, 7, 0, 0, 1, 0, 0, 5, 0, 2 }, - { 0, 5, 0, 0, 1, 0, 0, 7, 0, 2 }, - { 0, 0, 0, 7, 1, 5, 0, 0, 0, 1 }, - { 0, 0, 0, 5, 1, 7, 0, 0, 0, 1 }, - { 0, 1, 0, 0, 3, 0, 0, 1, 0, 4 }, - { 0, 0, 0, 1, 3, 1, 0, 0, 0, 5 }, - { 0, 6, 0, 6, 1, 0, 0, 0, 0, 6 }, - { 0, 6, 0, 0, 1, 6, 0, 0, 0, 9 }, - { 0, 0, 0, 6, 1, 0, 0, 6, 0, 7 }, - { 0, 0, 0, 0, 1, 6, 0, 6, 0, 8 }, - { 0, 6, 0, 6, 6, 0, 8, 6, 0, 7 }, - { 0, 6, 8, 6, 6, 6, 0, 0, 0, 9 }, - { 0, 6, 0, 0, 6, 6, 0, 6, 8, 8 }, - { 6, 6, 6, 6, 6, 6, 0, 6, 0, 8 }, - { 2, 6, 6, 6, 6, 6, 0, 6, 0, 8 }, - { 7, 7, 7, 6, 6, 6, 0, 6, 0, 8 }, - { 6, 6, 2, 6, 6, 6, 0, 6, 0, 8 }, - { 6, 2, 6, 6, 6, 6, 0, 6, 0, 8 }, - { 2, 6, 6, 6, 6, 6, 0, 6, 0, 8 }, - { 6, 7, 7, 6, 6, 6, 0, 6, 0, 8 }, - { 4, 4, 6, 6, 6, 6, 2, 6, 2, 8 }, - { 2, 2, 2, 2, 6, 2, 2, 6, 2, 7 }, - { 2, 2, 2, 2, 6, 2, 6, 6, 6, 7 }, - { 2, 2, 6, 2, 6, 6, 2, 2, 6, 9 }, - { 2, 6, 2, 2, 6, 2, 2, 2, 2, 6 }, - { 2, 2, 2, 2, 6, 6, 2, 2, 2, 9 }, - { 2, 2, 2, 6, 6, 2, 2, 2, 2, 6 }, - { 2, 2, 0, 2, 6, 6, 2, 2, 0, 9 }, - { 0, 0, 0, 0, 4, 0, 0, 0, 0, 12 }, - { 0, 1, 0, 0, 1, 4, 0, 1, 0, 10 }, - { 0, 0, 0, 1, 1, 1, 0, 4, 0, 11 }, - { 0, 0, 0, 6, 1, 4, 0, 1, 0, 14 }, - { 0, 6, 0, 1, 1, 0, 0, 4, 0, 16 }, - { 0, 6, 0, 0, 1, 1, 0, 4, 0, 15 }, - { 0, 0, 0, 0, 1, 1, 0, 1, 4, 13 }, - { 8, 8, 8, 8, 1, 1, 0, 1, 1, 13 }, - { 8, 8, 4, 8, 1, 1, 0, 1, 1, 10 }, - { 0, 0, 0, 1, 1, 1, 1, 1, 1, 11 }, - { 1, 1, 1, 1, 1, 1, 2, 2, 8, 2 }, - { 0, 1, 0, 1, 1, 4, 1, 1, 0, 16 }, - { 0, 0, 0, 1, 1, 1, 1, 1, 4, 11 }, - { 1, 1, 4, 1, 1, 1, 0, 2, 2, 2 }, - { 1, 1, 1, 1, 1, 1, 6, 2, 6, 2 }, - { 4, 1, 1, 1, 1, 1, 6, 2, 6, 2 }, - { 2, 2, 2, 1, 1, 1, 4, 1, 1, 11 }, - { 4, 1, 1, 1, 1, 1, 2, 2, 2, 2 }, - { 1, 1, 4, 1, 1, 1, 2, 2, 1, 2 }, - { 4, 1, 1, 1, 1, 1, 1, 2, 2, 2 }, - { 2, 2, 6, 1, 1, 1, 4, 1, 1, 11 }, - { 4, 1, 1, 1, 1, 1, 2, 2, 6, 2 }, - { 1, 2, 2, 1, 1, 1, 4, 1, 1, 11 }, - { 0, 1, 1, 0, 1, 1, 0, 1, 1, 10 }, - { 2, 1, 1, 3, 1, 1, 2, 1, 1, 14 }, - { 1, 1, 0, 1, 1, 2, 1, 1, 0, 1 }, - { 0, 4, 0, 1, 1, 1, 0, 1, 1, 14 }, - { 4, 1, 0, 1, 1, 0, 1, 1, 0, 1 }, - { 0, 1, 0, 4, 1, 1, 0, 1, 1, 15 }, - { 1, 1, 1, 1, 1, 1, 0, 2, 2, 2 }, - { 0, 1, 1, 2, 1, 1, 2, 1, 4, 10 }, - { 2, 1, 1, 1, 1, 1, 0, 4, 0, 16 }, - { 1, 1, 4, 1, 1, 2, 0, 1, 2, 1 }, - { 2, 1, 1, 2, 1, 1, 1, 1, 4, 10 }, - { 1, 1, 2, 1, 1, 2, 4, 1, 8, 1 }, - { 2, 1, 4, 1, 1, 1, 4, 4, 1, 16 }, - { 2, 1, 1, 1, 1, 1, 1, 1, 1, 16 }, - { 1, 1, 2, 1, 1, 1, 1, 1, 1, 15 }, - { 1, 1, 1, 1, 1, 1, 2, 1, 1, 14 }, - { 4, 1, 1, 1, 1, 1, 2, 1, 1, 14 }, - { 1, 1, 1, 1, 1, 1, 1, 1, 2, 8 }, - { 0, 0, 0, 0, 255, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 3 }, + { 0, 0, 0, 0, 2, 0, 0, 0, 0, 3 }, + { 0, 7, 0, 0, 1, 0, 0, 5, 0, 2 }, + { 0, 5, 0, 0, 1, 0, 0, 7, 0, 2 }, + { 0, 0, 0, 7, 1, 5, 0, 0, 0, 1 }, + { 0, 0, 0, 5, 1, 7, 0, 0, 0, 1 }, + { 0, 1, 0, 0, 3, 0, 0, 1, 0, 4 }, + { 0, 0, 0, 1, 3, 1, 0, 0, 0, 5 }, + { 0, 6, 0, 6, 1, 0, 0, 0, 0, 6 }, + { 0, 6, 0, 0, 1, 6, 0, 0, 0, 9 }, + { 0, 0, 0, 6, 1, 0, 0, 6, 0, 7 }, + { 0, 0, 0, 0, 1, 6, 0, 6, 0, 8 }, + { 0, 6, 0, 6, 6, 0, 8, 6, 0, 7 }, + { 0, 6, 8, 6, 6, 6, 0, 0, 0, 9 }, + { 0, 6, 0, 0, 6, 6, 0, 6, 8, 8 }, + { 6, 6, 6, 6, 6, 6, 0, 6, 0, 8 }, + { 2, 6, 6, 6, 6, 6, 0, 6, 0, 8 }, + { 7, 7, 7, 6, 6, 6, 0, 6, 0, 8 }, + { 6, 6, 2, 6, 6, 6, 0, 6, 0, 8 }, + { 6, 2, 6, 6, 6, 6, 0, 6, 0, 8 }, + { 2, 6, 6, 6, 6, 6, 0, 6, 0, 8 }, + { 6, 7, 7, 6, 6, 6, 0, 6, 0, 8 }, + { 4, 4, 6, 6, 6, 6, 2, 6, 2, 8 }, + { 2, 2, 2, 2, 6, 2, 2, 6, 2, 7 }, + { 2, 2, 2, 2, 6, 2, 6, 6, 6, 7 }, + { 2, 2, 6, 2, 6, 6, 2, 2, 6, 9 }, + { 2, 6, 2, 2, 6, 2, 2, 2, 2, 6 }, + { 2, 2, 2, 2, 6, 6, 2, 2, 2, 9 }, + { 2, 2, 2, 6, 6, 2, 2, 2, 2, 6 }, + { 2, 2, 0, 2, 6, 6, 2, 2, 0, 9 }, + { 0, 0, 0, 0, 4, 0, 0, 0, 0, 12 }, + { 0, 1, 0, 0, 1, 4, 0, 1, 0, 10 }, + { 0, 0, 0, 1, 1, 1, 0, 4, 0, 11 }, + { 0, 0, 0, 6, 1, 4, 0, 1, 0, 14 }, + { 0, 6, 0, 1, 1, 0, 0, 4, 0, 16 }, + { 0, 6, 0, 0, 1, 1, 0, 4, 0, 15 }, + { 0, 0, 0, 0, 1, 1, 0, 1, 4, 13 }, + { 8, 8, 8, 8, 1, 1, 0, 1, 1, 13 }, + { 8, 8, 4, 8, 1, 1, 0, 1, 1, 10 }, + { 0, 0, 0, 1, 1, 1, 1, 1, 1, 11 }, + { 1, 1, 1, 1, 1, 1, 2, 2, 8, 2 }, + { 0, 1, 0, 1, 1, 4, 1, 1, 0, 16 }, + { 0, 0, 0, 1, 1, 1, 1, 1, 4, 11 }, + { 1, 1, 4, 1, 1, 1, 0, 2, 2, 2 }, + { 1, 1, 1, 1, 1, 1, 6, 2, 6, 2 }, + { 4, 1, 1, 1, 1, 1, 6, 2, 6, 2 }, + { 2, 2, 2, 1, 1, 1, 4, 1, 1, 11 }, + { 4, 1, 1, 1, 1, 1, 2, 2, 2, 2 }, + { 1, 1, 4, 1, 1, 1, 2, 2, 1, 2 }, + { 4, 1, 1, 1, 1, 1, 1, 2, 2, 2 }, + { 2, 2, 6, 1, 1, 1, 4, 1, 1, 11 }, + { 4, 1, 1, 1, 1, 1, 2, 2, 6, 2 }, + { 1, 2, 2, 1, 1, 1, 4, 1, 1, 11 }, + { 0, 1, 1, 0, 1, 1, 0, 1, 1, 10 }, + { 2, 1, 1, 3, 1, 1, 2, 1, 1, 14 }, + { 1, 1, 0, 1, 1, 2, 1, 1, 0, 1 }, + { 0, 4, 0, 1, 1, 1, 0, 1, 1, 14 }, + { 4, 1, 0, 1, 1, 0, 1, 1, 0, 1 }, + { 0, 1, 0, 4, 1, 1, 0, 1, 1, 15 }, + { 1, 1, 1, 1, 1, 1, 0, 2, 2, 2 }, + { 0, 1, 1, 2, 1, 1, 2, 1, 4, 10 }, + { 2, 1, 1, 1, 1, 1, 0, 4, 0, 16 }, + { 1, 1, 4, 1, 1, 2, 0, 1, 2, 1 }, + { 2, 1, 1, 2, 1, 1, 1, 1, 4, 10 }, + { 1, 1, 2, 1, 1, 2, 4, 1, 8, 1 }, + { 2, 1, 4, 1, 1, 1, 4, 4, 1, 16 }, + { 2, 1, 1, 1, 1, 1, 1, 1, 1, 16 }, + { 1, 1, 2, 1, 1, 1, 1, 1, 1, 15 }, + { 1, 1, 1, 1, 1, 1, 2, 1, 1, 14 }, + { 4, 1, 1, 1, 1, 1, 2, 1, 1, 14 }, + { 1, 1, 1, 1, 1, 1, 1, 1, 2, 8 }, + { 0, 0, 0, 0, 255, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; void __cdecl InitDungeon() @@ -241,191 +241,165 @@ void __cdecl InitDungeon() signed int v2; // ecx v0 = 0; - do - { + do { v1 = v0; v2 = 40; - do - { + do { dflags[0][v1] = 0; predungeon[0][v1] = 32; v1 += 40; --v2; - } - while ( v2 ); + } while (v2); ++v0; - } - while ( v0 < 40 ); + } while (v0 < 40); } void __cdecl L2LockoutFix() { - signed int v0; // ecx - char *v1; // eax - signed int v2; // edx - signed int v3; // ecx - signed int v4; // edi - signed int v5; // eax - char *v6; // esi - signed int v7; // edx - char v8; // al + signed int v0; // ecx + char *v1; // eax + signed int v2; // edx + signed int v3; // ecx + signed int v4; // edi + signed int v5; // eax + char *v6; // esi + signed int v7; // edx + char v8; // al unsigned int v9; // ecx - signed int v10; // eax - char v11; // dl - signed int v12; // esi - char v13; // bl - char *v14; // edx + signed int v10; // eax + char v11; // dl + signed int v12; // esi + char v13; // bl + char *v14; // edx v0 = 0; - do - { + do { v1 = (char *)dungeon + v0; v2 = 40; - do - { - if ( *v1 == 4 && *(v1 - 40) != 3 ) + do { + if (*v1 == 4 && *(v1 - 40) != 3) *v1 = 1; - if ( *v1 == 5 && *(v1 - 1) != 3 ) + if (*v1 == 5 && *(v1 - 1) != 3) *v1 = 2; v1 += 40; --v2; - } - while ( v2 ); + } while (v2); ++v0; - } - while ( v0 < 40 ); + } while (v0 < 40); v3 = 1; - do - { + do { v4 = 1; - do - { + do { v5 = v4; - if ( dflags[v4][v3] >= 0 ) - { + if (dflags[v4][v3] >= 0) { v6 = &dungeon[v5][v3]; - if ( (*v6 == 2 || *v6 == 5) && *(v6 - 1) == 3 && dungeon[v5][v3 + 1] == 3 ) - { + if ((*v6 == 2 || *v6 == 5) && *(v6 - 1) == 3 && dungeon[v5][v3 + 1] == 3) { v7 = 0; - while ( 1 ) - { + while (1) { v8 = *v6; - if ( *v6 != 2 && v8 != 5 ) + if (*v6 != 2 && v8 != 5) break; - if ( *(v6 - 1) != 3 || v6[1] != 3 ) + if (*(v6 - 1) != 3 || v6[1] != 3) break; - if ( v8 == 5 ) + if (v8 == 5) v7 = 1; ++v4; v6 += 40; } - if ( !v7 && dflags[v4 - 1][v3] >= 0 ) // dflags[-1][] - dungeon[v4 - 1][v3] = 5; // dungeon[-1][] + if (!v7 && dflags[v4 - 1][v3] >= 0) // dflags[-1][] + dungeon[v4 - 1][v3] = 5; // dungeon[-1][] } } ++v4; - } - while ( v4 < 39 ); + } while (v4 < 39); ++v3; - } - while ( v3 < 39 ); + } while (v3 < 39); v9 = 1; - do - { + do { v10 = 1; - do - { - if ( dflags[v9][v10] >= 0 ) - { + do { + if (dflags[v9][v10] >= 0) { v11 = dungeon[v9][v10]; - if ( (v11 == 1 || v11 == 4) - && dungeon[v9 - 1][v10] == 3 // dungeon[-1][] - && dungeon[v9 + 1][v10] == 3 ) - { + if ((v11 == 1 || v11 == 4) + && dungeon[v9 - 1][v10] == 3 // dungeon[-1][] + && dungeon[v9 + 1][v10] == 3) { v12 = 0; - while ( 1 ) - { + while (1) { v13 = dungeon[v9][v10]; - if ( v13 != 1 && v13 != 4 ) + if (v13 != 1 && v13 != 4) break; v14 = &dungeon[v9 + 1][v10]; - if ( *(v14 - 80) != 3 || *v14 != 3 ) + if (*(v14 - 80) != 3 || *v14 != 3) break; - if ( v13 == 4 ) + if (v13 == 4) v12 = 1; ++v10; } - if ( !v12 && dflags[v9][v10 - 1] >= 0 ) // dflags[][-1] - dungeon[v9][v10 - 1] = 4; // dungeon[][-1] + if (!v12 && dflags[v9][v10 - 1] >= 0) // dflags[][-1] + dungeon[v9][v10 - 1] = 4; // dungeon[][-1] } } ++v10; - } - while ( v10 < 39 ); + } while (v10 < 39); ++v9; - } - while ( v9 < 39 ); + } while (v9 < 39); } void __cdecl L2DoorFix() { signed int v0; // ecx - char *v1; // eax + char *v1; // eax signed int v2; // edx v0 = 1; - do - { + do { v1 = &dungeon[1][v0]; v2 = 39; - do - { - if ( *v1 == 4 && *(v1 - 1) == 3 ) + do { + if (*v1 == 4 && *(v1 - 1) == 3) *v1 = 7; - if ( *v1 == 5 && *(v1 - 40) == 3 ) + if (*v1 == 5 && *(v1 - 40) == 3) *v1 = 9; v1 += 40; --v2; - } - while ( v2 ); + } while (v2); ++v0; - } - while ( v0 < 40 ); + } while (v0 < 40); } void __fastcall LoadL2Dungeon(char *sFileName, int vx, int vy) { - char *v3; // esi + char *v3; // esi unsigned char *v4; // edi - signed int v5; // edx - signed int v6; // eax - signed int v7; // ecx - int v8; // esi - int v9; // eax - int v10; // ebx - int v11; // edi - char *v12; // eax - int v13; // ecx - char v14; // dl - signed int v15; // ecx - _BYTE *v16; // eax - signed int v17; // edx - int v18; // ebx - int (*v19)[112]; // esi - char *v20; // ecx - signed int v21; // edi - int v22; // edx - char v23; // al - int v24; // ecx - int (*v25)[112]; // edi - char *v26; // eax - int (*v27)[112]; // edx - signed int v28; // ebx - int v29; // esi - int v30; // [esp+Ch] [ebp-Ch] - char *ptr; // [esp+10h] [ebp-8h] - int v32; // [esp+14h] [ebp-4h] - int (*v33)[112]; // [esp+14h] [ebp-4h] + signed int v5; // edx + signed int v6; // eax + signed int v7; // ecx + int v8; // esi + int v9; // eax + int v10; // ebx + int v11; // edi + char *v12; // eax + int v13; // ecx + char v14; // dl + signed int v15; // ecx + _BYTE *v16; // eax + signed int v17; // edx + int v18; // ebx + int(*v19)[112]; // esi + char *v20; // ecx + signed int v21; // edi + int v22; // edx + char v23; // al + int v24; // ecx + int(*v25)[112]; // edi + char *v26; // eax + int(*v27)[112]; // edx + signed int v28; // ebx + int v29; // esi + int v30; // [esp+Ch] [ebp-Ch] + char *ptr; // [esp+10h] [ebp-8h] + int v32; // [esp+14h] [ebp-4h] + int(*v33)[112]; // [esp+14h] [ebp-4h] v30 = vx; v3 = sFileName; @@ -434,138 +408,110 @@ void __fastcall LoadL2Dungeon(char *sFileName, int vx, int vy) v4 = LoadFileInMem(v3, 0); v5 = 0; ptr = (char *)v4; - do - { + do { v6 = v5; v7 = 40; - do - { + do { dflags[0][v6] = 0; dungeon[0][v6] = 12; v6 += 40; --v7; - } - while ( v7 ); + } while (v7); ++v5; - } - while ( v5 < 40 ); + } while (v5 < 40); v8 = *v4; v9 = (int)(v4 + 2); v10 = 0; v11 = v4[2]; v12 = (char *)(v9 + 2); - if ( v11 > 0 ) - { - do - { - if ( v8 > 0 ) - { + if (v11 > 0) { + do { + if (v8 > 0) { v13 = v10; v32 = v8; - do - { + do { v14 = *v12; - if ( *v12 ) - { + if (*v12) { dflags[0][v13] |= DFLAG_EXPLORED; dungeon[0][v13] = v14; - } - else - { + } else { dungeon[0][v13] = 3; } v13 += 40; v12 += 2; --v32; - } - while ( v32 ); + } while (v32); } ++v10; - } - while ( v10 < v11 ); + } while (v10 < v11); } v15 = 0; - do - { + do { v16 = (unsigned char *)dungeon + v15; v17 = 40; - do - { - if ( !*v16 ) + do { + if (!*v16) *v16 = 12; v16 += 40; --v17; - } - while ( v17 ); + } while (v17); ++v15; - } - while ( v15 < 40 ); + } while (v15 < 40); DRLG_L2Pass3(); DRLG_Init_Globals(); v18 = 0; v33 = dPiece; - do - { + do { v19 = v33; v20 = (char *)dArch + v18; v21 = 112; - do - { + do { v22 = (*v19)[0]; v23 = 0; - if ( (*v19)[0] == 541 ) + if ((*v19)[0] == 541) v23 = 5; - if ( v22 == 178 ) + if (v22 == 178) v23 = 5; - if ( v22 == 551 ) + if (v22 == 551) v23 = 5; - if ( v22 == 542 ) + if (v22 == 542) v23 = 6; - if ( v22 == 553 ) + if (v22 == 553) v23 = 6; - if ( v22 == 13 ) + if (v22 == 13) v23 = 5; - if ( v22 == 17 ) + if (v22 == 17) v23 = 6; *v20 = v23; ++v19; v20 += 112; --v21; - } - while ( v21 ); - v33 = (int (*)[112])((char *)v33 + 4); + } while (v21); + v33 = (int(*)[112])((char *)v33 + 4); ++v18; - } - while ( (signed int)v33 < (signed int)dPiece[1] ); + } while ((signed int)v33 < (signed int)dPiece[1]); v24 = 0; v25 = dPiece; - do - { + do { v26 = &dArch[0][v24 + 2]; v27 = v25; v28 = 112; - do - { + do { v29 = (*v27)[0]; - if ( (*v27)[0] == 132 ) - { + if ((*v27)[0] == 132) { *(v26 - 1) = 2; *v26 = 1; - } - else if ( v29 == 135 || v29 == 139 ) - { + } else if (v29 == 135 || v29 == 139) { v26[110] = 3; v26[222] = 4; } ++v27; v26 += 112; --v28; - } - while ( v28 ); - v25 = (int (*)[112])((char *)v25 + 4); + } while (v28); + v25 = (int(*)[112])((char *)v25 + 4); ++v24; - } - while ( (signed int)v25 < (signed int)dPiece[1] ); + } while ((signed int)v25 < (signed int)dPiece[1]); ViewX = v30; ViewY = vy; SetMapMonsters((unsigned char *)ptr, 0, 0); @@ -575,25 +521,25 @@ void __fastcall LoadL2Dungeon(char *sFileName, int vx, int vy) void __cdecl DRLG_L2Pass3() { - int v0; // eax - int *v1; // edx - int *v2; // eax - signed int v3; // ecx - signed int v4; // ebx - int *v5; // ecx - unsigned char *v6; // edx + int v0; // eax + int *v1; // edx + int *v2; // eax + signed int v3; // ecx + signed int v4; // ebx + int *v5; // ecx + unsigned char *v6; // edx unsigned short *v7; // esi - unsigned short v8; // ax - int v9; // eax - int v10; // ST24_4 - int v11; // ST20_4 - int v12; // ST1C_4 - signed int v13; // [esp+Ch] [ebp-1Ch] - int *v14; // [esp+10h] [ebp-18h] - int v15; // [esp+14h] [ebp-14h] - int v16; // [esp+18h] [ebp-10h] - int v17; // [esp+1Ch] [ebp-Ch] - int v18; // [esp+20h] [ebp-8h] + unsigned short v8; // ax + int v9; // eax + int v10; // ST24_4 + int v11; // ST20_4 + int v12; // ST1C_4 + signed int v13; // [esp+Ch] [ebp-1Ch] + int *v14; // [esp+10h] [ebp-18h] + int v15; // [esp+14h] [ebp-14h] + int v16; // [esp+18h] [ebp-10h] + int v17; // [esp+1Ch] [ebp-Ch] + int v18; // [esp+20h] [ebp-8h] v0 = *((unsigned short *)pMegaTiles + 44) + 1; v18 = *((unsigned short *)pMegaTiles + 44) + 1; @@ -604,32 +550,26 @@ void __cdecl DRLG_L2Pass3() _LOWORD(v0) = *((_WORD *)pMegaTiles + 47); v15 = v0 + 1; v1 = dPiece[1]; - do - { + do { v2 = v1; v3 = 56; - do - { + do { *(v2 - 112) = v18; *v2 = v17; *(v2 - 111) = v16; v2[1] = v15; v2 += 224; --v3; - } - while ( v3 ); + } while (v3); v1 += 2; - } - while ( (signed int)v1 < (signed int)dPiece[2] ); + } while ((signed int)v1 < (signed int)dPiece[2]); v4 = 0; v14 = &dPiece[17][16]; - do - { + do { v5 = v14; v6 = (unsigned char *)dungeon + v4; v13 = 40; - do - { + do { v7 = (unsigned short *)((char *)pMegaTiles + 8 * (*v6 - 1)); v8 = *v7; ++v7; @@ -648,35 +588,33 @@ void __cdecl DRLG_L2Pass3() v5[1] = v9 + 1; v5 += 224; --v13; - } - while ( v13 ); + } while (v13); v14 += 2; ++v4; - } - while ( v4 < 40 ); + } while (v4 < 40); } void __fastcall LoadPreL2Dungeon(char *sFileName, int vx, int vy) { - char *v3; // esi - unsigned char *v4; // ebx - signed int v5; // esi - signed int v6; // edx - signed int v7; // eax - int v8; // eax - int v9; // edi - char *v10; // edx - int v11; // esi - char v12; // bl - signed int v13; // eax - _BYTE *v14; // edx - signed int v15; // esi - signed int v16; // eax - signed int v17; // edx - signed int v18; // esi + char *v3; // esi + unsigned char *v4; // ebx + signed int v5; // esi + signed int v6; // edx + signed int v7; // eax + int v8; // eax + int v9; // edi + char *v10; // edx + int v11; // esi + char v12; // bl + signed int v13; // eax + _BYTE *v14; // edx + signed int v15; // esi + signed int v16; // eax + signed int v17; // edx + signed int v18; // esi unsigned char *ptr; // [esp+8h] [ebp-Ch] - int v20; // [esp+Ch] [ebp-8h] - int v21; // [esp+10h] [ebp-4h] + int v20; // [esp+Ch] [ebp-8h] + int v21; // [esp+10h] [ebp-4h] v3 = sFileName; InitDungeon(); @@ -684,86 +622,65 @@ void __fastcall LoadPreL2Dungeon(char *sFileName, int vx, int vy) v4 = LoadFileInMem(v3, 0); v5 = 0; ptr = v4; - do - { + do { v6 = v5; v7 = 40; - do - { + do { dflags[0][v6] = 0; dungeon[0][v6] = 12; v6 += 40; --v7; - } - while ( v7 ); + } while (v7); ++v5; - } - while ( v5 < 40 ); + } while (v5 < 40); v21 = 0; v8 = v4[2]; v9 = *v4; v10 = (char *)(v4 + 4); - if ( v8 > 0 ) - { - do - { - if ( v9 > 0 ) - { + if (v8 > 0) { + do { + if (v9 > 0) { v11 = v21; v20 = v9; - do - { + do { v12 = *v10; - if ( *v10 ) - { + if (*v10) { dflags[0][v11] |= DFLAG_EXPLORED; dungeon[0][v11] = v12; - } - else - { + } else { dungeon[0][v11] = 3; } v11 += 40; v10 += 2; --v20; - } - while ( v20 ); + } while (v20); } ++v21; - } - while ( v21 < v8 ); + } while (v21 < v8); } v13 = 0; - do - { + do { v14 = (unsigned char *)dungeon + v13; v15 = 40; - do - { - if ( !*v14 ) + do { + if (!*v14) *v14 = 12; v14 += 40; --v15; - } - while ( v15 ); + } while (v15); ++v13; - } - while ( v13 < 40 ); + } while (v13 < 40); v16 = 0; - do - { + do { v17 = v16; v18 = 40; - do - { + do { pdungeon[0][v17] = dungeon[0][v17]; v17 += 40; --v18; - } - while ( v18 ); + } while (v18); ++v16; - } - while ( v16 < 40 ); + } while (v16 < 40); mem_free_dbg(ptr); } @@ -775,25 +692,19 @@ void __fastcall CreateL2Dungeon(int rseed, int entry) v2 = entry; v3 = rseed; - if ( gbMaxPlayers == 1 ) - { - if ( currlevel == 7 ) - { - if ( quests[QTYPE_BLIND]._qactive ) + if (gbMaxPlayers == 1) { + if (currlevel == 7) { + if (quests[QTYPE_BLIND]._qactive) goto LABEL_10; currlevel = 6; CreateL2Dungeon(glSeedTbl[6], 4); currlevel = 7; } - if ( currlevel == 8 ) - { - if ( quests[QTYPE_BLIND]._qactive ) - { + if (currlevel == 8) { + if (quests[QTYPE_BLIND]._qactive) { v4 = glSeedTbl[7]; currlevel = 7; - } - else - { + } else { v4 = glSeedTbl[6]; currlevel = 6; } @@ -827,19 +738,13 @@ void __cdecl DRLG_LoadL2SP() char *v1; // ecx setloadflag_2 = 0; - if ( QuestStatus(QTYPE_BLIND) ) - { + if (QuestStatus(QTYPE_BLIND)) { v1 = "Levels\\L2Data\\Blind2.DUN"; - } - else - { - if ( QuestStatus(QTYPE_BLOOD) ) - { + } else { + if (QuestStatus(QTYPE_BLOOD)) { v1 = "Levels\\L2Data\\Blood1.DUN"; - } - else - { - if ( !QuestStatus(QTYPE_BONE) ) + } else { + if (!QuestStatus(QTYPE_BONE)) return; v1 = "Levels\\L2Data\\Bonestr2.DUN"; } @@ -860,81 +765,74 @@ void __cdecl DRLG_FreeL2SP() void __fastcall DRLG_L2(int entry) { - int v1; // esi - int v2; // eax - int v3; // eax - int v4; // eax - int v5; // eax - int v6; // eax - int v7; // eax - int v8; // eax - int v9; // eax + int v1; // esi + int v2; // eax + int v3; // eax + int v4; // eax + int v5; // eax + int v6; // eax + int v7; // eax + int v8; // eax + int v9; // eax signed int v10; // ecx signed int v11; // eax signed int v12; // esi - int v13; // [esp+10h] [ebp-4h] + int v13; // [esp+10h] [ebp-4h] v1 = 0; v13 = entry; - do - { + do { nRoomCnt = 0; InitDungeon(); DRLG_InitTrans(); v2 = CreateDungeon(); - if ( !v2 ) + if (!v2) continue; L2TileFix(); - if ( setloadflag_2 ) + if (setloadflag_2) DRLG_L2SetRoom(nSx1, nSy1); DRLG_L2FloodTVal(); DRLG_L2TransFix(); - if ( !v13 ) - { + if (!v13) { v3 = DRLG_L2PlaceMiniSet(USTAIRS, 1, 1, -1, -1, 1, 0); v1 = v3; - if ( !v3 ) + if (!v3) goto LABEL_21; v4 = DRLG_L2PlaceMiniSet(DSTAIRS, 1, 1, -1, -1, 0, 1); v1 = v4; - if ( !v4 || currlevel != 5 ) + if (!v4 || currlevel != 5) goto LABEL_21; v5 = DRLG_L2PlaceMiniSet(WARPSTAIRS, 1, 1, -1, -1, 0, 6); -LABEL_20: + LABEL_20: v1 = v5; -LABEL_21: + LABEL_21: ViewY -= 2; continue; } v6 = DRLG_L2PlaceMiniSet(USTAIRS, 1, 1, -1, -1, 0, 0); v1 = v6; - if ( v13 != 1 ) - { - if ( !v6 ) + if (v13 != 1) { + if (!v6) goto LABEL_21; v9 = DRLG_L2PlaceMiniSet(DSTAIRS, 1, 1, -1, -1, 0, 1); v1 = v9; - if ( !v9 || currlevel != 5 ) + if (!v9 || currlevel != 5) goto LABEL_21; v5 = DRLG_L2PlaceMiniSet(WARPSTAIRS, 1, 1, -1, -1, 1, 6); goto LABEL_20; } - if ( v6 ) - { + if (v6) { v7 = DRLG_L2PlaceMiniSet(DSTAIRS, 1, 1, -1, -1, 1, 1); v1 = v7; - if ( v7 ) - { - if ( currlevel == 5 ) - { + if (v7) { + if (currlevel == 5) { v8 = DRLG_L2PlaceMiniSet(WARPSTAIRS, 1, 1, -1, -1, 0, 6); v1 = v8; } } } --ViewX; - } - while ( !v1 ); + } while (!v1); L2LockoutFix(); L2DoorFix(); L2DirtFix(); @@ -1050,20 +948,16 @@ LABEL_21: DRLG_L2Subs(); DRLG_L2Shadows(); v10 = 0; - do - { + do { v11 = v10; v12 = 40; - do - { + do { pdungeon[0][v11] = dungeon[0][v11]; v11 += 40; --v12; - } - while ( v12 ); + } while (v12); ++v10; - } - while ( v10 < 40 ); + } while (v10 < 40); DRLG_Init_Globals(); DRLG_CheckQuests(nSx1, nSy1); } @@ -1071,36 +965,36 @@ LABEL_21: bool __fastcall DRLG_L2PlaceMiniSet(unsigned char *miniset, int tmin, int tmax, int cx, int cy, bool setview, int ldir) { - int v7; // ebx - int v8; // esi - int v9; // edi - int v10; // edx - int v11; // eax - int v13; // esi - int v14; // ebx - int v15; // ecx - int v16; // eax - int v18; // eax - int v20; // edi - signed int i; // eax - int v22; // ecx - unsigned char v23; // dl - int v24; // eax - int v25; // edi - char *v26; // edx - unsigned char v27; // bl - bool result; // al + int v7; // ebx + int v8; // esi + int v9; // edi + int v10; // edx + int v11; // eax + int v13; // esi + int v14; // ebx + int v15; // ecx + int v16; // eax + int v18; // eax + int v20; // edi + signed int i; // eax + int v22; // ecx + unsigned char v23; // dl + int v24; // eax + int v25; // edi + char *v26; // edx + unsigned char v27; // bl + bool result; // al unsigned char *v29; // [esp+Ch] [ebp-28h] - int v30; // [esp+10h] [ebp-24h] - int v31; // [esp+14h] [ebp-20h] - int v32; // [esp+18h] [ebp-1Ch] - signed int v33; // [esp+1Ch] [ebp-18h] - int v34; // [esp+20h] [ebp-14h] - int v35; // [esp+24h] [ebp-10h] - int v36; // [esp+28h] [ebp-Ch] - int max; // [esp+2Ch] [ebp-8h] + int v30; // [esp+10h] [ebp-24h] + int v31; // [esp+14h] [ebp-20h] + int v32; // [esp+18h] [ebp-1Ch] + signed int v33; // [esp+1Ch] [ebp-18h] + int v34; // [esp+20h] [ebp-14h] + int v35; // [esp+24h] [ebp-10h] + int v36; // [esp+28h] [ebp-Ch] + int max; // [esp+2Ch] [ebp-8h] //int v38; // [esp+30h] [ebp-4h] - int v39; // [esp+30h] [ebp-4h] + int v39; // [esp+30h] [ebp-4h] int tmaxa; // [esp+3Ch] [ebp+8h] v7 = miniset[1]; @@ -1110,43 +1004,33 @@ bool __fastcall DRLG_L2PlaceMiniSet(unsigned char *miniset, int tmin, int tmax, v10 = tmax - tmin; v34 = *miniset; v35 = miniset[1]; - if ( v10 ) - { + if (v10) { v30 = v8 + random(0, v10); - } - else - { + } else { v30 = 1; } v31 = 0; - if ( v30 <= 0 ) - { + if (v30 <= 0) { v13 = ldir; v14 = 0; /* v38; check */ - } - else - { + } else { max = 40 - v9; v36 = 40 - v7; - do - { + do { v11 = random(0, max); v13 = v11; v33 = 0; v14 = random(0, v36); v39 = v14; - do - { - if ( v33 >= 200 ) + do { + if (v33 >= 200) return 0; tmaxa = 1; - if ( v13 >= nSx1 && v13 <= nSx2 && v14 >= nSy1 && v14 <= nSy2 ) + if (v13 >= nSx1 && v13 <= nSx2 && v14 >= nSy1 && v14 <= nSy2) tmaxa = 0; - if ( cx != -1 ) - { + if (cx != -1) { v15 = cx - v34; - if ( v13 >= cx - v34 && v13 <= cx + 12 ) - { + if (v13 >= cx - v34 && v13 <= cx + 12) { v16 = random(0, max); v13 = v16; tmaxa = 0; @@ -1154,8 +1038,7 @@ bool __fastcall DRLG_L2PlaceMiniSet(unsigned char *miniset, int tmin, int tmax, v14 = v39; } } - if ( cy != -1 && v14 >= cy - v35 && v14 <= cy + 12 ) - { + if (cy != -1 && v14 >= cy - v35 && v14 <= cy + 12) { v18 = random(0, max); /* cy - v35 */ v13 = v18; tmaxa = 0; @@ -1163,82 +1046,67 @@ bool __fastcall DRLG_L2PlaceMiniSet(unsigned char *miniset, int tmin, int tmax, v14 = v39; } v20 = 0; - for ( i = 2; v20 < v35; ++v20 ) - { - if ( tmaxa != 1 ) + for (i = 2; v20 < v35; ++v20) { + if (tmaxa != 1) break; v32 = 0; - if ( v34 > 0 ) - { + if (v34 > 0) { v22 = v14 + v20 + 40 * v13; - do - { - if ( tmaxa != 1 ) + do { + if (tmaxa != 1) break; v23 = v29[i]; - if ( v23 && dungeon[0][v22] != v23 ) + if (v23 && dungeon[0][v22] != v23) tmaxa = 0; - if ( dflags[0][v22] ) + if (dflags[0][v22]) tmaxa = 0; ++i; ++v32; v22 += 40; - } - while ( v32 < v34 ); + } while (v32 < v34); } } - if ( !tmaxa && ++v13 == max ) - { + if (!tmaxa && ++v13 == max) { v13 = 0; v39 = ++v14; - if ( v14 == v36 ) - { + if (v14 == v36) { v39 = 0; v14 = 0; } } ++v33; - } - while ( !tmaxa ); - if ( v33 >= 200 ) + } while (!tmaxa); + if (v33 >= 200) return 0; v24 = 0; - for ( miniset = (unsigned char *)(v34 * v35 + 2); v24 < v35; ++v24 ) - { + for (miniset = (unsigned char *)(v34 * v35 + 2); v24 < v35; ++v24) { v25 = v34; - if ( v34 > 0 ) - { + if (v34 > 0) { v26 = &dungeon[v13][v24 + v14]; - do - { + do { v27 = v29[(_DWORD)miniset]; - if ( v27 ) + if (v27) *v26 = v27; ++miniset; v26 += 40; --v25; - } - while ( v25 ); + } while (v25); v14 = v39; } } ++v31; - } - while ( v31 < v30 ); + } while (v31 < v30); } result = 1; - if ( setview == 1 ) - { + if (setview == 1) { ViewX = 2 * v13 + 21; ViewY = 2 * v14 + 22; } - if ( !ldir ) - { + if (!ldir) { LvlViewX = 2 * v13 + 21; LvlViewY = 2 * v14 + 22; } - if ( ldir == 6 ) - { + if (ldir == 6) { LvlViewX = 2 * v13 + 21; LvlViewY = 2 * v14 + 22; } @@ -1251,38 +1119,38 @@ bool __fastcall DRLG_L2PlaceMiniSet(unsigned char *miniset, int tmin, int tmax, void __fastcall DRLG_L2PlaceRndSet(unsigned char *miniset, int rndper) { - unsigned char *v2; // ebx - signed int v3; // esi - signed int v4; // ecx - int v5; // edx - signed int v6; // edi - signed int i; // edx - signed int v8; // esi - int v9; // eax - unsigned char v10; // cl - int v11; // edi - _BYTE *v12; // ecx - int v13; // esi - int v14; // eax - int v15; // eax - signed int j; // edx - signed int v17; // esi + unsigned char *v2; // ebx + signed int v3; // esi + signed int v4; // ecx + int v5; // edx + signed int v6; // edi + signed int i; // edx + signed int v8; // esi + int v9; // eax + unsigned char v10; // cl + int v11; // edi + _BYTE *v12; // ecx + int v13; // esi + int v14; // eax + int v15; // eax + signed int j; // edx + signed int v17; // esi unsigned char *v18; // eax - unsigned char v19; // cl - int v20; // [esp+8h] [ebp-3Ch] + unsigned char v19; // cl + int v20; // [esp+8h] [ebp-3Ch] unsigned char *v21; // [esp+10h] [ebp-34h] - int v22; // [esp+14h] [ebp-30h] - int v23; // [esp+18h] [ebp-2Ch] - int v24; // [esp+1Ch] [ebp-28h] - int v25; // [esp+20h] [ebp-24h] - int v26; // [esp+24h] [ebp-20h] - int v27; // [esp+28h] [ebp-1Ch] - int v28; // [esp+2Ch] [ebp-18h] - int v29; // [esp+30h] [ebp-14h] - signed int v30; // [esp+34h] [ebp-10h] - signed int v31; // [esp+38h] [ebp-Ch] - int v32; // [esp+3Ch] [ebp-8h] - signed int v33; // [esp+40h] [ebp-4h] + int v22; // [esp+14h] [ebp-30h] + int v23; // [esp+18h] [ebp-2Ch] + int v24; // [esp+1Ch] [ebp-28h] + int v25; // [esp+20h] [ebp-24h] + int v26; // [esp+24h] [ebp-20h] + int v27; // [esp+28h] [ebp-1Ch] + int v28; // [esp+2Ch] [ebp-18h] + int v29; // [esp+30h] [ebp-14h] + signed int v30; // [esp+34h] [ebp-10h] + signed int v31; // [esp+38h] [ebp-Ch] + int v32; // [esp+3Ch] [ebp-8h] + signed int v33; // [esp+40h] [ebp-4h] v2 = miniset; v32 = 0; @@ -1293,103 +1161,81 @@ void __fastcall DRLG_L2PlaceRndSet(unsigned char *miniset, int rndper) v30 = v4; v26 = 40 - v3; v31 = v3; - if ( 40 - v3 > 0 ) - { + if (40 - v3 > 0) { v27 = 40 - v4; v23 = -v3; - while ( 1 ) - { + while (1) { v5 = 0; v25 = 0; - if ( v27 > 0 ) - { + if (v27 > 0) { v29 = -v4; v22 = v4 * v3 + 2; v28 = 0; v24 = -40 * v4; - do - { + do { v33 = 1; v6 = 2; - if ( v5 >= nSx1 && v5 <= nSx2 && v32 >= nSy1 && v32 <= nSy2 ) + if (v5 >= nSx1 && v5 <= nSx2 && v32 >= nSy1 && v32 <= nSy2) v33 = 0; - for ( i = 0; i < v31; ++i ) - { - if ( v33 != 1 ) + for (i = 0; i < v31; ++i) { + if (v33 != 1) break; v8 = 0; - if ( v30 > 0 ) - { + if (v30 > 0) { v9 = v32 + i + v28; - do - { - if ( v33 != 1 ) + do { + if (v33 != 1) break; v10 = v2[v6]; - if ( v10 && dungeon[0][v9] != v10 ) + if (v10 && dungeon[0][v9] != v10) v33 = 0; - if ( dflags[0][v9] ) + if (dflags[0][v9]) v33 = 0; ++v6; ++v8; v9 += 40; - } - while ( v8 < v30 ); + } while (v8 < v30); } } v11 = v22; - if ( v33 == 1 ) - { + if (v33 == 1) { v12 = (_BYTE *)v31; v13 = v23; - if ( v23 >= v32 + 2 * v31 ) - { -LABEL_34: - if ( random(0, 100) < v20 ) - { - for ( j = 0; j < v31; ++j ) - { + if (v23 >= v32 + 2 * v31) { + LABEL_34: + if (random(0, 100) < v20) { + for (j = 0; j < v31; ++j) { v17 = v30; - if ( v30 > 0 ) - { + if (v30 > 0) { v18 = (unsigned char *)dungeon + j + v28 + v32; - do - { + do { v19 = v2[v11]; - if ( v19 ) + if (v19) *v18 = v19; ++v11; v18 += 40; --v17; - } - while ( v17 ); + } while (v17); } } } - } - else - { - while ( v33 == 1 ) - { + } else { + while (v33 == 1) { v12 = (_BYTE *)v30; v14 = v25 + 2 * v30; - if ( v29 < v14 ) - { + if (v29 < v14) { v15 = v14 - v29; v12 = (unsigned char *)dungeon + v24 + v13; - do - { - if ( *v12 == v2[v22] ) + do { + if (*v12 == v2[v22]) v33 = 0; v12 += 40; --v15; - } - while ( v15 ); + } while (v15); v2 = v21; } - if ( ++v13 >= v32 + 2 * v31 ) - { - if ( v33 != 1 ) + if (++v13 >= v32 + 2 * v31) { + if (v33 != 1) break; goto LABEL_34; } @@ -1401,12 +1247,11 @@ LABEL_34: v5 = v25 + 1; ++v29; ++v25; - } - while ( v25 < v27 ); + } while (v25 < v27); } ++v32; ++v23; - if ( v32 >= v26 ) + if (v32 >= v26) break; v4 = v30; v3 = v31; @@ -1418,147 +1263,129 @@ LABEL_34: void __cdecl DRLG_L2Subs() { - signed int v0; // edi + signed int v0; // edi unsigned char v1; // bl - int v2; // eax - signed int v3; // edx - int v4; // esi - int i; // ebx - int j; // eax - signed int v7; // [esp+Ch] [ebp-10h] - char *v8; // [esp+10h] [ebp-Ch] - signed int v9; // [esp+14h] [ebp-8h] - int v10; // [esp+18h] [ebp-4h] + int v2; // eax + signed int v3; // edx + int v4; // esi + int i; // ebx + int j; // eax + signed int v7; // [esp+Ch] [ebp-10h] + char *v8; // [esp+10h] [ebp-Ch] + signed int v9; // [esp+14h] [ebp-8h] + int v10; // [esp+18h] [ebp-4h] v0 = 3; v9 = -2; v7 = 3; - do - { + do { v10 = 0; v8 = &dungeon[0][v9 + 2]; - do - { - if ( (v10 < nSx1 || v10 > nSx2) && (v0 - 3 < nSy1 || v0 - 3 > nSy2) && !random(0, 4) ) - { + do { + if ((v10 < nSx1 || v10 > nSx2) && (v0 - 3 < nSy1 || v0 - 3 > nSy2) && !random(0, 4)) { v1 = BTYPESL2[(unsigned char)*v8]; - if ( v1 ) - { + if (v1) { v2 = random(0, 16); v3 = -1; - while ( v2 >= 0 ) - { - if ( ++v3 == 161 ) + while (v2 >= 0) { + if (++v3 == 161) v3 = 0; - if ( v1 == BTYPESL2[v3] ) + if (v1 == BTYPESL2[v3]) --v2; } v4 = v9; - for ( i = v0 - 1; v4 < i; ++v4 ) - { - for ( j = v10 - 2; j < v10 + 2; ++j ) - { + for (i = v0 - 1; v4 < i; ++v4) { + for (j = v10 - 2; j < v10 + 2; ++j) { v0 = v7; - if ( (unsigned char)dungeon[j][v4] == v3 ) - { + if ((unsigned char)dungeon[j][v4] == v3) { v4 = v7; j = v10 + 2; } } } - if ( v4 < v0 ) + if (v4 < v0) *v8 = v3; } } ++v10; v8 += 40; - } - while ( v10 < 40 ); + } while (v10 < 40); ++v9; v7 = ++v0; - } - while ( v0 - 3 < 40 ); + } while (v0 - 3 < 40); } // 5276CC: using guessed type int nSx2; // 5276D4: using guessed type int nSy2; void __cdecl DRLG_L2Shadows() { - char *v0; // eax + char *v0; // eax unsigned char *v1; // esi - unsigned char v2; // dl - signed int v3; // edi - char v4; // cl - char v5; // cl - char v6; // cl - char v7; // cl - char v8; // cl - signed int v9; // [esp+8h] [ebp-Ch] - signed int v10; // [esp+Ch] [ebp-8h] + unsigned char v2; // dl + signed int v3; // edi + char v4; // cl + char v5; // cl + char v6; // cl + char v7; // cl + char v8; // cl + signed int v9; // [esp+8h] [ebp-Ch] + signed int v10; // [esp+Ch] [ebp-8h] unsigned char v11; // [esp+11h] [ebp-3h] unsigned char v12; // [esp+12h] [ebp-2h] unsigned char v13; // [esp+13h] [ebp-1h] v10 = 1; - do - { + do { v9 = 39; v0 = &dungeon[0][v10 + 39]; - do - { + do { v1 = &SPATSL2[0].s1; v2 = BSTYPESL2[(unsigned char)v0[1]]; v12 = BSTYPESL2[(unsigned char)*(v0 - 39)]; v11 = BSTYPESL2[(unsigned char)*v0]; v13 = BSTYPESL2[(unsigned char)*(v0 - 40)]; - do - { - if ( *(v1 - 1) == v2 ) - { + do { + if (*(v1 - 1) == v2) { v3 = 1; - if ( *v1 && *v1 != v13 ) + if (*v1 && *v1 != v13) v3 = 0; v4 = v1[1]; - if ( v4 && v4 != v11 ) + if (v4 && v4 != v11) v3 = 0; v5 = v1[2]; - if ( v5 && v5 != v12 ) + if (v5 && v5 != v12) v3 = 0; - if ( v3 == 1 ) - { + if (v3 == 1) { v6 = v1[3]; - if ( v6 ) + if (v6) *(v0 - 40) = v6; v7 = v1[4]; - if ( v7 ) + if (v7) *v0 = v7; v8 = v1[5]; - if ( v8 ) + if (v8) *(v0 - 39) = v8; } } v1 += 7; - } - while ( (signed int)v1 < (signed int)&SPATSL2[2].s1 ); + } while ((signed int)v1 < (signed int)&SPATSL2[2].s1); v0 += 40; --v9; - } - while ( v9 ); + } while (v9); ++v10; - } - while ( v10 < 40 ); + } while (v10 < 40); } // 48489A: using guessed type short word_48489A; void __fastcall DRLG_L2SetRoom(int rx1, int ry1) { - int v2; // edi - int v3; // esi - int v4; // eax - char v5; // bl - int v6; // [esp+8h] [ebp-Ch] + int v2; // edi + int v3; // esi + int v4; // eax + char v5; // bl + int v6; // [esp+8h] [ebp-Ch] char *v7; // [esp+Ch] [ebp-8h] - int v8; // [esp+10h] [ebp-4h] + int v8; // [esp+10h] [ebp-4h] v8 = 0; v2 = (unsigned char)pSetPiece_2[2]; @@ -1568,35 +1395,26 @@ void __fastcall DRLG_L2SetRoom(int rx1, int ry1) setpc_w = v3; setpc_h = v2; v7 = pSetPiece_2 + 4; - if ( v2 > 0 ) - { - do - { - if ( v3 > 0 ) - { + if (v2 > 0) { + do { + if (v3 > 0) { v6 = v3; v4 = ry1 + v8 + 40 * rx1; - do - { + do { v5 = *v7; - if ( *v7 ) - { + if (*v7) { dflags[0][v4] |= DFLAG_EXPLORED; dungeon[0][v4] = v5; - } - else - { + } else { dungeon[0][v4] = 3; } v7 += 2; v4 += 40; --v6; - } - while ( v6 ); + } while (v6); } ++v8; - } - while ( v8 < v2 ); + } while (v8 < v2); } } // 5CF330: using guessed type int setpc_h; @@ -1605,81 +1423,70 @@ void __fastcall DRLG_L2SetRoom(int rx1, int ry1) void __cdecl L2TileFix() { signed int v0; // edx - char *v1; // eax + char *v1; // eax signed int v2; // esi - char v3; // cl + char v3; // cl v0 = 0; - do - { + do { v1 = (char *)dungeon + v0; v2 = 40; - do - { + do { v3 = *v1; - if ( *v1 == 1 && v1[1] == 3 ) + if (*v1 == 1 && v1[1] == 3) v1[1] = 1; - if ( v3 == 3 ) - { - if ( v1[1] == 1 ) + if (v3 == 3) { + if (v1[1] == 1) v1[1] = 3; - if ( v1[40] == 7 ) + if (v1[40] == 7) v1[40] = 3; } - if ( v3 == 2 && v1[40] == 3 ) + if (v3 == 2 && v1[40] == 3) v1[40] = 2; - if ( v3 == 11 && v1[40] == 14 ) + if (v3 == 11 && v1[40] == 14) v1[40] = 16; v1 += 40; --v2; - } - while ( v2 ); + } while (v2); ++v0; - } - while ( v0 < 40 ); + } while (v0 < 40); } bool __cdecl CreateDungeon() { - int v0; // esi - int v1; // edx - int v2; // ecx - signed int v3; // esi - char *v4; // eax - signed int v5; // ebx - _BYTE *v6; // ecx - bool v7; // zf - bool v8; // eax - int v9; // edi - int v10; // esi + int v0; // esi + int v1; // edx + int v2; // ecx + signed int v3; // esi + char *v4; // eax + signed int v5; // ebx + _BYTE *v6; // ecx + bool v7; // zf + bool v8; // eax + int v9; // edi + int v10; // esi signed int v12; // [esp-4h] [ebp-20h] - int nX1; // [esp+8h] [ebp-14h] - int nY1; // [esp+Ch] [ebp-10h] - int nX2; // [esp+10h] [ebp-Ch] - int nY2; // [esp+14h] [ebp-8h] - int nHd; // [esp+18h] [ebp-4h] + int nX1; // [esp+8h] [ebp-14h] + int nY1; // [esp+Ch] [ebp-10h] + int nX2; // [esp+10h] [ebp-Ch] + int nY2; // [esp+14h] [ebp-8h] + int nHd; // [esp+18h] [ebp-4h] v0 = 0; v1 = 0; v2 = 0; - if ( currlevel == 5 ) - { - if ( !quests[QTYPE_BLOOD]._qactive ) + if (currlevel == 5) { + if (!quests[QTYPE_BLOOD]._qactive) goto LABEL_12; v1 = 20; v0 = 14; - } - else - { - if ( currlevel == 6 ) - { - if ( !quests[QTYPE_BONE]._qactive ) + } else { + if (currlevel == 6) { + if (!quests[QTYPE_BONE]._qactive) goto LABEL_12; v12 = 10; - } - else - { - if ( currlevel != 7 || !quests[QTYPE_BLIND]._qactive ) + } else { + if (currlevel != 7 || !quests[QTYPE_BLIND]._qactive) goto LABEL_12; v12 = 15; } @@ -1689,68 +1496,59 @@ bool __cdecl CreateDungeon() v2 = 1; LABEL_12: CreateRoom(2, 2, 39, 39, 0, 0, v2, v1, v0); - while ( pHallList ) - { + while (pHallList) { GetHall(&nX1, &nY1, &nX2, &nY2, &nHd); ConnectHall(nX1, nY1, nX2, nY2, nHd); } v3 = 0; - do - { + do { v4 = &predungeon[-1][v3]; v5 = 41; - do - { + do { v6 = (unsigned char *)v4 + 40; - if ( v4[40] == 67 ) + if (v4[40] == 67) *v6 = 35; - if ( *v6 == 66 ) + if (*v6 == 66) *v6 = 35; - if ( *v6 == 69 ) + if (*v6 == 69) *v6 = 35; - if ( *v6 == 65 ) + if (*v6 == 65) *v6 = 35; - if ( *v6 == 44 ) - { + if (*v6 == 44) { v7 = *(v4 - 1) == 32; *v6 = 46; - if ( v7 ) + if (v7) *(v4 - 1) = 35; - if ( *v4 == 32 ) + if (*v4 == 32) *v4 = 35; - if ( v4[1] == 32 ) + if (v4[1] == 32) v4[1] = 35; - if ( v4[79] == 32 ) + if (v4[79] == 32) v4[79] = 35; - if ( v4[80] == 32 ) + if (v4[80] == 32) v4[80] = 35; - if ( v4[81] == 32 ) + if (v4[81] == 32) v4[81] = 35; - if ( v4[39] == 32 ) + if (v4[39] == 32) v4[39] = 35; - if ( v4[41] == 32 ) + if (v4[41] == 32) v4[41] = 35; } --v5; v4 += 40; - } - while ( v5 ); + } while (v5); ++v3; - } - while ( v3 <= 40 ); + } while (v3 <= 40); v8 = DL2_FillVoids(); - if ( v8 ) - { + if (v8) { v9 = 0; - do - { + do { v10 = 0; do DoPatternCheck(v10++, v9); - while ( v10 < 40 ); + while (v10 < 40); ++v9; - } - while ( v9 < 40 ); + } while (v9 < 40); v8 = 1; } return v8; @@ -1758,68 +1556,63 @@ LABEL_12: void __fastcall CreateRoom(int nX1, int nY1, int nX2, int nY2, int nRDest, int nHDir, int ForceHW, int nH, int nW) { - int v9; // esi - int v10; // ebx - int v11; // edx - int v12; // eax - int v13; // edx - int v14; // edx - int v15; // edi - int v17; // esi - int v18; // ebx - int v19; // edx - int v20; // ecx - int v21; // eax - int v23; // eax - int v24; // eax - int v26; // eax - int *v27; // ecx - int v28; // eax - int v29; // eax - int *v30; // ecx - int v31; // eax - int nX1a; // [esp+Ch] [ebp-30h] - int v33; // [esp+10h] [ebp-2Ch] - int v34; // [esp+14h] [ebp-28h] - int v35; // [esp+18h] [ebp-24h] - int v36; // [esp+1Ch] [ebp-20h] - int v37; // [esp+20h] [ebp-1Ch] - int nY1a; // [esp+24h] [ebp-18h] - int v39; // [esp+28h] [ebp-14h] - int v40; // [esp+2Ch] [ebp-10h] - int v41; // [esp+30h] [ebp-Ch] - int v42; // [esp+34h] [ebp-8h] - int v43; // [esp+38h] [ebp-4h] + int v9; // esi + int v10; // ebx + int v11; // edx + int v12; // eax + int v13; // edx + int v14; // edx + int v15; // edi + int v17; // esi + int v18; // ebx + int v19; // edx + int v20; // ecx + int v21; // eax + int v23; // eax + int v24; // eax + int v26; // eax + int *v27; // ecx + int v28; // eax + int v29; // eax + int *v30; // ecx + int v31; // eax + int nX1a; // [esp+Ch] [ebp-30h] + int v33; // [esp+10h] [ebp-2Ch] + int v34; // [esp+14h] [ebp-28h] + int v35; // [esp+18h] [ebp-24h] + int v36; // [esp+1Ch] [ebp-20h] + int v37; // [esp+20h] [ebp-1Ch] + int nY1a; // [esp+24h] [ebp-18h] + int v39; // [esp+28h] [ebp-14h] + int v40; // [esp+2Ch] [ebp-10h] + int v41; // [esp+30h] [ebp-Ch] + int v42; // [esp+34h] [ebp-8h] + int v43; // [esp+38h] [ebp-4h] int *ForceHWa; // [esp+54h] [ebp+18h] int *ForceHWb; // [esp+54h] [ebp+18h] v39 = nY1; v37 = nX1; - if ( nRoomCnt < 80 ) - { + if (nRoomCnt < 80) { v40 = nX2 - 2; nY1a = nY1 + 2; - while ( 1 ) - { + while (1) { v9 = nX2 - v37; v10 = nY2 - v39; - if ( nX2 - v37 < Area_Min || v10 < Area_Min ) + if (nX2 - v37 < Area_Min || v10 < Area_Min) return; - if ( v9 > Room_Max ) + if (v9 > Room_Max) break; nX1 = Room_Min; - if ( v9 > Room_Min ) - { + if (v9 > Room_Min) { v11 = v9 - Room_Min; goto LABEL_7; } v41 = nX2 - v37; -LABEL_11: + LABEL_11: v13 = Room_Max; - if ( v10 <= Room_Max ) - { - if ( v10 <= nX1 ) - { + if (v10 <= Room_Max) { + if (v10 <= nX1) { v36 = nY2 - v39; goto LABEL_16; } @@ -1827,9 +1620,8 @@ LABEL_11: } v14 = v13 - nX1; v36 = Room_Min + random(0, v14); -LABEL_16: - if ( ForceHW == 1 ) - { + LABEL_16: + if (ForceHW == 1) { v41 = nW; v36 = nH; } @@ -1837,35 +1629,32 @@ LABEL_16: v17 = v39 + random(0, v10); v18 = v15 + v41; v43 = v17 + v36; - if ( v15 + v41 > nX2 ) - { + if (v15 + v41 > nX2) { v18 = nX2; v15 = nX2 - v41; } - if ( v17 + v36 > nY2 ) - { + if (v17 + v36 > nY2) { v43 = nY2; v17 = nY2 - v36; } - if ( v15 >= 38 ) + if (v15 >= 38) v15 = 38; - if ( v17 >= 38 ) + if (v17 >= 38) v17 = 38; - if ( v15 <= 1 ) + if (v15 <= 1) v15 = 1; - if ( v17 <= 1 ) + if (v17 <= 1) v17 = 1; - if ( v18 >= 38 ) + if (v18 >= 38) v18 = 38; - if ( v43 >= 38 ) + if (v43 >= 38) v43 = 38; - if ( v18 <= 1 ) + if (v18 <= 1) v18 = 1; - if ( v43 <= 1 ) + if (v43 <= 1) v43 = 1; DefineRoom(v15, v17, v18, v43, ForceHW); - if ( ForceHW == 1 ) - { + if (ForceHW == 1) { nSx2 = v18; nSx1 = v15 + 2; nSy1 = v17 + 2; @@ -1875,10 +1664,8 @@ LABEL_16: v20 = nRDest; v42 = nRoomCnt; RoomList[nRoomCnt].nRoomDest = nRDest; - if ( nRDest ) - { - if ( nHDir == 1 ) - { + if (nRDest) { + if (nHDir == 1) { v21 = random(0, v18 - v15 - 2); nX1a = v21 + v15 + 1; v33 = v17; @@ -1887,8 +1674,7 @@ LABEL_16: v34 = v23 + RoomList[nRDest].nRoomx1 + 1; v35 = RoomList[nRDest].nRoomy2; } - if ( nHDir == 3 ) - { + if (nHDir == 3) { v24 = random(0, v18 - v15 - 2); nX1a = v24 + v15 + 1; v33 = v43; @@ -1897,8 +1683,7 @@ LABEL_16: v34 = v26 + RoomList[nRDest].nRoomx1 + 1; v35 = RoomList[nRDest].nRoomy1; } - if ( nHDir == 2 ) - { + if (nHDir == 2) { nX1a = v18; v33 = random(0, v43 - v17 - 2) + v17 + 1; v34 = RoomList[nRDest].nRoomx1; @@ -1909,8 +1694,7 @@ LABEL_16: v20 = *ForceHWa; v35 = v29 + *ForceHWa + 1; } - if ( nHDir == 4 ) - { + if (nHDir == 4) { nX1a = v15; v33 = random(0, v43 - v17 - 2) + v17 + 1; v34 = RoomList[nRDest].nRoomx2; @@ -1922,8 +1706,7 @@ LABEL_16: AddHall(nX1a, v33, v34, v35, nHDir); v19 = v42; } - if ( v36 <= v41 ) - { + if (v36 <= v41) { CreateRoom(v37 + 2, nY1a, v18 - 2, v17 - 2, v19, 3, 0, 0, 0); CreateRoom(v15 + 2, v43 + 2, v40, nY2 - 2, v42, 1, 0, 0, 0); CreateRoom(v37 + 2, v17 + 2, v15 - 2, nY2 - 2, v42, 2, 0, 0, 0); @@ -1938,9 +1721,7 @@ LABEL_16: v39 += 2; nY1a += 2; v37 = v18 + 2; - } - else - { + } else { CreateRoom(v37 + 2, nY1a, v15 - 2, v43 - 2, v19, 2, 0, 0, 0); CreateRoom(v18 + 2, v17 + 2, v40, nY2 - 2, v42, 4, 0, 0, 0); CreateRoom(v37 + 2, v43 + 2, v18 - 2, nY2 - 2, v42, 1, 0, 0, 0); @@ -1956,11 +1737,11 @@ LABEL_16: nY2 = v17 - 2; v37 = v15 + 2; } - if ( nRoomCnt >= 80 ) + if (nRoomCnt >= 80) return; } v11 = Room_Max - Room_Min; -LABEL_7: + LABEL_7: v12 = random(0, v11); nX1 = Room_Min; v41 = Room_Min + v12; @@ -1975,18 +1756,18 @@ LABEL_7: void __fastcall DefineRoom(int nX1, int nY1, int nX2, int nY2, int ForceHW) { - int v5; // esi - int v6; // edi - int v7; // eax - int i; // eax - bool v9; // zf - int v10; // ecx - char *v11; // eax - char *v12; // ebx - int v13; // eax - int v14; // [esp+10h] [ebp-4h] - int v15; // [esp+10h] [ebp-4h] - int nY2a; // [esp+20h] [ebp+Ch] + int v5; // esi + int v6; // edi + int v7; // eax + int i; // eax + bool v9; // zf + int v10; // ecx + char *v11; // eax + char *v12; // ebx + int v13; // eax + int v14; // [esp+10h] [ebp-4h] + int v15; // [esp+10h] [ebp-4h] + int nY2a; // [esp+20h] [ebp+Ch] char *ForceHWa; // [esp+24h] [ebp+10h] v5 = nX1; @@ -2002,70 +1783,57 @@ void __fastcall DefineRoom(int nX1, int nY1, int nX2, int nY2, int ForceHW) *(int *)((char *)&RoomList[0].nRoomx2 + v7) = nX2; *(int *)((char *)&RoomList[0].nRoomy1 + v7) = nY1; *(int *)((char *)&RoomList[0].nRoomy2 + v7) = nY2; - if ( ForceHW == 1 ) - { - for ( i = nX1; i < nX2; ++i ) - { - if ( i < nY2 ) - { + if (ForceHW == 1) { + for (i = nX1; i < nX2; ++i) { + if (i < nY2) { ForceHWa = &dflags[i][nY1]; v14 = nY2 - i; i = nY2; - do - { + do { *ForceHWa |= DFLAG_EXPLORED; v9 = v14-- == 1; ForceHWa += 40; - } - while ( !v9 ); + } while (!v9); } } } v10 = nX1 + 1; - if ( v10 <= nX2 - 1 ) - { + if (v10 <= nX2 - 1) { v15 = nX2 - v10; v11 = &predungeon[v10][nY2]; - do - { + do { v11[nY1 - nY2] = 35; *v11 = 35; v11 += 40; --v15; - } - while ( v15 ); + } while (v15); } nY2a = nY2 - 1; - while ( ++nY1 <= nY2a ) - { + while (++nY1 <= nY2a) { predungeon[v5][nY1] = 35; predungeon[v6][nY1] = 35; - if ( v10 < nX2 ) - { + if (v10 < nX2) { v12 = &predungeon[v10][nY1]; v13 = nX2 - v10; - do - { + do { *v12 = 46; v12 += 40; --v13; - } - while ( v13 ); + } while (v13); } } } void __fastcall AddHall(int nX1, int nY1, int nX2, int nY2, int nHd) { - int v5; // edi - int v6; // esi + int v5; // edi + int v6; // esi HALLNODE *v7; // eax - HALLNODE *i; // ecx + HALLNODE *i; // ecx v5 = nX1; v6 = nY1; - if ( pHallList ) - { + if (pHallList) { v7 = (HALLNODE *)DiabloAllocPtr(24); v7->pNext = 0; v7->nHallx2 = nX2; @@ -2073,12 +1841,10 @@ void __fastcall AddHall(int nX1, int nY1, int nX2, int nY2, int nHd) v7->nHallx1 = v5; v7->nHally1 = v6; v7->nHalldir = nHd; - for ( i = pHallList; i->pNext; i = i->pNext ) + for (i = pHallList; i->pNext; i = i->pNext) ; i->pNext = v7; - } - else - { + } else { pHallList = (HALLNODE *)DiabloAllocPtr(24); pHallList->nHallx1 = v5; pHallList->nHally1 = v6; @@ -2108,41 +1874,41 @@ void __fastcall GetHall(int *nX1, int *nY1, int *nX2, int *nY2, int *nHd) void __fastcall ConnectHall(int nX1, int nY1, int nX2, int nY2, int nHd) { - int v5; // edi + int v5; // edi signed int v6; // esi - int v7; // eax - int v9; // edi - int v10; // ebx - int v11; // ecx - char v12; // al - int v13; // eax - int v14; // ecx - char *v15; // ebx - int v16; // ecx - int v17; // edx - int v18; // ecx - int v19; // edx - int v20; // eax + int v7; // eax + int v9; // edi + int v10; // ebx + int v11; // ecx + char v12; // al + int v13; // eax + int v14; // ecx + char *v15; // ebx + int v16; // ecx + int v17; // edx + int v18; // ecx + int v19; // edx + int v20; // eax //int v21; // ST04_4 - int v23; // ebx - int v24; // ebx - bool v25; // zf + int v23; // ebx + int v24; // ebx + bool v25; // zf signed int v26; // [esp-4h] [ebp-34h] signed int v27; // [esp-4h] [ebp-34h] signed int v28; // [esp-4h] [ebp-34h] signed int v29; // [esp-4h] [ebp-34h] - int v30; // [esp+Ch] [ebp-24h] - int v31; // [esp+10h] [ebp-20h] - int v32; // [esp+14h] [ebp-1Ch] + int v30; // [esp+Ch] [ebp-24h] + int v31; // [esp+10h] [ebp-20h] + int v32; // [esp+14h] [ebp-1Ch] signed int v33; // [esp+18h] [ebp-18h] signed int v34; // [esp+1Ch] [ebp-14h] signed int v35; // [esp+20h] [ebp-10h] - int v36; // [esp+24h] [ebp-Ch] - char *v37; // [esp+28h] [ebp-8h] - signed int nY; // [esp+2Ch] [ebp-4h] - int nX2a; // [esp+38h] [ebp+8h] - int nY2a; // [esp+3Ch] [ebp+Ch] - int nHda; // [esp+40h] [ebp+10h] + int v36; // [esp+24h] [ebp-Ch] + char *v37; // [esp+28h] [ebp-8h] + signed int nY; // [esp+2Ch] [ebp-4h] + int nX2a; // [esp+38h] [ebp+8h] + int nY2a; // [esp+3Ch] [ebp+Ch] + int nHda; // [esp+40h] [ebp+10h] v34 = 0; v5 = nY1; @@ -2165,24 +1931,23 @@ void __fastcall ConnectHall(int nX1, int nY1, int nX2, int nY2, int nHd) nX2a = v10; predungeon[v10][v11] = 44; v37 = &predungeon[v6][nY]; - do - { - if ( v6 >= 38 && v9 == 2 ) + do { + if (v6 >= 38 && v9 == 2) v9 = 4; - if ( nY >= 38 && v9 == 3 ) + if (nY >= 38 && v9 == 3) v9 = 1; - if ( v6 <= 1 && v9 == 4 ) + if (v6 <= 1 && v9 == 4) v9 = 2; - if ( nY <= 1 && v9 == 1 ) + if (nY <= 1 && v9 == 1) v9 = 3; v12 = *v37; - if ( *v37 == 67 && (v9 == 1 || v9 == 4) ) + if (*v37 == 67 && (v9 == 1 || v9 == 4)) v9 = 2; - if ( v12 == 66 && (v9 == 1 || v9 == 2) ) + if (v12 == 66 && (v9 == 1 || v9 == 2)) v9 = 3; - if ( v12 == 69 && (v9 == 4 || v9 == 3) ) + if (v12 == 69 && (v9 == 4 || v9 == 3)) v9 = 1; - if ( v12 == 65 && (v9 == 2 || v9 == 3) ) + if (v12 == 65 && (v9 == 2 || v9 == 3)) v9 = 4; v13 = Dir_Xadd[v9]; v14 = Dir_Yadd[v9]; @@ -2190,37 +1955,25 @@ void __fastcall ConnectHall(int nX1, int nY1, int nX2, int nY2, int nHd) v6 += v13; v15 = &predungeon[v6][nY]; v37 = v15; - if ( *v15 == 32 ) - { - if ( nHda ) - { + if (*v15 == 32) { + if (nHda) { CreateDoorType(v6 - v13, nY - v14); - } - else - { - if ( v33 < 50 ) - { - if ( v9 == 1 || v9 == 3 ) - { + } else { + if (v33 < 50) { + if (v9 == 1 || v9 == 3) { v17 = nY; v16 = v6 - 1; - } - else - { + } else { v16 = v6; v17 = nY - 1; } PlaceHallExt(v16, v17); } - if ( v32 < 50 ) - { - if ( v9 == 1 || v9 == 3 ) - { + if (v32 < 50) { + if (v9 == 1 || v9 == 3) { v19 = nY; v18 = v6 + 1; - } - else - { + } else { v18 = v6; v19 = nY + 1; } @@ -2229,74 +1982,62 @@ void __fastcall ConnectHall(int nX1, int nY1, int nX2, int nY2, int nHd) } nHda = 0; *v15 = 44; - } - else - { - if ( !nHda && *v15 == 35 ) + } else { + if (!nHda && *v15 == 35) CreateDoorType(v6, nY); - if ( *v15 != 44 ) + if (*v15 != 44) nHda = 1; } v36 = abs(nX2a - v6); v20 = abs(nY2a - nY); //v22 = v21; v35 = v20; - if ( v36 <= v20 ) - { + if (v36 <= v20) { v24 = 5 * v20; - if ( 5 * v20 > 80 ) + if (5 * v20 > 80) v24 = 80; - if ( random(0, 100) < v24 ) - { - if ( nY2a <= nY || nY >= 40 ) - { + if (random(0, 100) < v24) { + if (nY2a <= nY || nY >= 40) { v9 = 1; goto LABEL_67; } v26 = 3; goto LABEL_58; } - } - else - { + } else { v23 = 2 * v36; - if ( 2 * v36 > 30 ) + if (2 * v36 > 30) v23 = 30; - if ( random(0, 100) < v23 ) - { - if ( nX2a <= v6 || v6 >= 40 ) + if (random(0, 100) < v23) { + if (nX2a <= v6 || v6 >= 40) v26 = 4; else v26 = 2; -LABEL_58: + LABEL_58: v9 = v26; goto LABEL_67; } } -LABEL_67: - if ( v35 < 10 && v6 == nX2a && (v9 == 2 || v9 == 4) ) - { - if ( nY2a <= nY || nY >= 40 ) + LABEL_67: + if (v35 < 10 && v6 == nX2a && (v9 == 2 || v9 == 4)) { + if (nY2a <= nY || nY >= 40) v9 = 1; else v9 = 3; } - if ( v36 < 10 && nY == nY2a && (v9 == 1 || v9 == 3) ) - { - if ( nX2a <= v6 || v6 >= 40 ) + if (v36 < 10 && nY == nY2a && (v9 == 1 || v9 == 3)) { + if (nX2a <= v6 || v6 >= 40) v27 = 4; else v27 = 2; v9 = v27; } - if ( v35 == 1 ) - { + if (v35 == 1) { v25 = v36 == 1; - if ( v36 <= 1 ) + if (v36 <= 1) goto LABEL_94; - if ( v9 == 1 || v9 == 3 ) - { - if ( nX2a <= v6 || v6 >= 40 ) + if (v9 == 1 || v9 == 3) { + if (nX2a <= v6 || v6 >= 40) v28 = 4; else v28 = 2; @@ -2304,62 +2045,57 @@ LABEL_67: } } v25 = v36 == 1; -LABEL_94: - if ( v25 ) - { - if ( v35 <= 1 || v9 != 2 && v9 != 4 ) + LABEL_94: + if (v25) { + if (v35 <= 1 || v9 != 2 && v9 != 4) goto LABEL_109; - if ( nY2a > nY && v6 < 40 ) + if (nY2a > nY && v6 < 40) goto LABEL_100; v9 = 1; } - if ( !v36 && *v37 != 32 && (v9 == 2 || v9 == 4) ) - { - if ( nX2a <= v31 || v6 >= 40 ) - { + if (!v36 && *v37 != 32 && (v9 == 2 || v9 == 4)) { + if (nX2a <= v31 || v6 >= 40) { v9 = 1; goto LABEL_109; } -LABEL_100: + LABEL_100: v9 = 3; } -LABEL_109: - if ( !v35 && *v37 != 32 && (v9 == 1 || v9 == 3) ) - { - if ( nY2a <= v30 || nY >= 40 ) + LABEL_109: + if (!v35 && *v37 != 32 && (v9 == 1 || v9 == 3)) { + if (nY2a <= v30 || nY >= 40) v29 = 4; else v29 = 2; v9 = v29; } - if ( v6 == nX2a && nY == nY2a ) + if (v6 == nX2a && nY == nY2a) v34 = 1; - } - while ( !v34 ); + } while (!v34); } void __fastcall CreateDoorType(int nX, int nY) { - int v2; // eax + int v2; // eax signed int v3; // esi - char *v4; // ecx - char v5; // al + char *v4; // ecx + char v5; // al v2 = nX; v3 = 0; v4 = &predungeon[nX][nY]; - if ( *(v4 - 40) == 68 ) + if (*(v4 - 40) == 68) v3 = 1; - if ( predungeon[v2 + 1][nY] == 68 ) + if (predungeon[v2 + 1][nY] == 68) v3 = 1; - if ( *(v4 - 1) == 68 ) + if (*(v4 - 1) == 68) v3 = 1; - if ( predungeon[v2][nY + 1] == 68 ) + if (predungeon[v2][nY + 1] == 68) v3 = 1; v5 = *v4; - if ( *v4 == 66 || v5 == 67 || v5 == 65 || v5 == 69 ) + if (*v4 == 66 || v5 == 67 || v5 == 65 || v5 == 69) v3 = 1; - if ( !v3 ) + if (!v3) *v4 = 68; } @@ -2368,216 +2104,202 @@ void __fastcall PlaceHallExt(int nX, int nY) char *v2; // eax v2 = &predungeon[nX][nY]; - if ( *v2 == 32 ) + if (*v2 == 32) *v2 = 44; } void __fastcall DoPatternCheck(int i, int j) { - int v2; // edx + int v2; // edx signed int v3; // eax signed int v4; // ebp - int v5; // esi - int v6; // ecx - bool v7; // zf - char v8; // bl - bool v9; // zf - char v10; // bl - int *v11; // [esp+0h] [ebp-10h] - int v12; // [esp+4h] [ebp-Ch] - int v13; // [esp+8h] [ebp-8h] - int v14; // [esp+Ch] [ebp-4h] + int v5; // esi + int v6; // ecx + bool v7; // zf + char v8; // bl + bool v9; // zf + char v10; // bl + int *v11; // [esp+0h] [ebp-10h] + int v12; // [esp+4h] [ebp-Ch] + int v13; // [esp+8h] [ebp-8h] + int v14; // [esp+Ch] [ebp-4h] v13 = j; v14 = i; - if ( Patterns[0][4] != 255 ) - { + if (Patterns[0][4] != 255) { v12 = 0; v2 = i - 1; v11 = &Patterns[0][4]; - do - { + do { v3 = v2; v4 = 254; v5 = v13 - 1; v6 = 0; - while ( v4 == 254 ) - { + while (v4 == 254) { v4 = 255; - if ( v6 == 3 || v6 == 6 ) - { + if (v6 == 3 || v6 == 6) { ++v5; v3 = v2; } - if ( v3 < 0 || v3 >= 40 || v5 < 0 || v5 >= 40 ) - { -LABEL_26: + if (v3 < 0 || v3 >= 40 || v5 < 0 || v5 >= 40) { + LABEL_26: v4 = 254; - } - else - { - switch ( Patterns[0][v6 + v12] ) - { - case 0: + } else { + switch (Patterns[0][v6 + v12]) { + case 0: + goto LABEL_26; + case 1: + v7 = predungeon[v3][v5] == 35; + goto LABEL_25; + case 2: + v7 = predungeon[v3][v5] == 46; + goto LABEL_25; + case 3: + v7 = predungeon[v3][v5] == 68; + goto LABEL_25; + case 4: + v7 = predungeon[v3][v5] == 32; + goto LABEL_25; + case 5: + v8 = predungeon[v3][v5]; + v9 = v8 == 68; + goto LABEL_23; + case 6: + v10 = predungeon[v3][v5]; + if (v10 == 68) goto LABEL_26; - case 1: - v7 = predungeon[v3][v5] == 35; - goto LABEL_25; - case 2: - v7 = predungeon[v3][v5] == 46; - goto LABEL_25; - case 3: - v7 = predungeon[v3][v5] == 68; - goto LABEL_25; - case 4: - v7 = predungeon[v3][v5] == 32; - goto LABEL_25; - case 5: - v8 = predungeon[v3][v5]; - v9 = v8 == 68; - goto LABEL_23; - case 6: - v10 = predungeon[v3][v5]; - if ( v10 == 68 ) - goto LABEL_26; - v7 = v10 == 35; - goto LABEL_25; - case 7: - v8 = predungeon[v3][v5]; - v9 = v8 == 32; - goto LABEL_23; - case 8: - v8 = predungeon[v3][v5]; - if ( v8 == 68 ) - goto LABEL_26; - v9 = v8 == 35; -LABEL_23: - if ( v9 ) - goto LABEL_26; - v7 = v8 == 46; -LABEL_25: - if ( v7 ) - goto LABEL_26; - break; - default: - break; + v7 = v10 == 35; + goto LABEL_25; + case 7: + v8 = predungeon[v3][v5]; + v9 = v8 == 32; + goto LABEL_23; + case 8: + v8 = predungeon[v3][v5]; + if (v8 == 68) + goto LABEL_26; + v9 = v8 == 35; + LABEL_23: + if (v9) + goto LABEL_26; + v7 = v8 == 46; + LABEL_25: + if (v7) + goto LABEL_26; + break; + default: + break; } } ++v3; - if ( ++v6 >= 9 ) - { - if ( v4 == 254 ) + if (++v6 >= 9) { + if (v4 == 254) dungeon[v14][v13] = *((_BYTE *)v11 + 20); break; } } v11 += 10; v12 += 10; - } - while ( *v11 != 255 ); + } while (*v11 != 255); } } bool __cdecl DL2_FillVoids() { - int i; // eax - int v2; // eax - int v4; // edi - int v5; // eax - int v6; // ebx - int v7; // eax - int v8; // ecx - char v9; // dl - bool v10; // eax - int v11; // esi + int i; // eax + int v2; // eax + int v4; // edi + int v5; // eax + int v6; // ebx + int v7; // eax + int v8; // ecx + char v9; // dl + bool v10; // eax + int v11; // esi signed int v12; // ecx signed int v13; // edi signed int v14; // edx signed int v15; // eax - int v16; // ebx - char *v17; // eax + int v16; // ebx + char *v17; // eax signed int v18; // edx - int k; // eax - int v20; // ebx - int v21; // ebx - char *v22; // eax - int v23; // ebx + int k; // eax + int v20; // ebx + int v21; // ebx + char *v22; // eax + int v23; // ebx signed int v24; // edx - int v25; // eax - int v26; // esi - int v27; // edx - int v28; // esi - int v29; // edx - int v30; // edx + int v25; // eax + int v26; // esi + int v27; // edx + int v28; // esi + int v29; // edx + int v30; // edx signed int v31; // ebx - int v32; // edi - int v33; // ecx - char *v34; // eax - int v35; // edi - int v36; // edx + int v32; // edi + int v33; // ecx + char *v34; // eax + int v35; // edi + int v36; // edx signed int v37; // ecx signed int v38; // eax - int v39; // edx - int v40; // edx - int v41; // edx + int v39; // edx + int v40; // edx + int v41; // edx signed int v42; // ebx - int j; // edi - int v44; // ecx - char *v45; // eax - int v46; // edi - int v47; // [esp-4h] [ebp-30h] + int j; // edi + int v44; // ecx + char *v45; // eax + int v46; // edi + int v47; // [esp-4h] [ebp-30h] signed int v48; // [esp+Ch] [ebp-20h] signed int y1f; // [esp+10h] [ebp-1Ch] signed int y2f; // [esp+14h] [ebp-18h] signed int x2f; // [esp+18h] [ebp-14h] signed int x1f; // [esp+1Ch] [ebp-10h] - int x2; // [esp+20h] [ebp-Ch] - int x2a; // [esp+20h] [ebp-Ch] - int y1; // [esp+24h] [ebp-8h] - int y1a; // [esp+24h] [ebp-8h] - int y1b; // [esp+24h] [ebp-8h] - int y2; // [esp+28h] [ebp-4h] - int y2a; // [esp+28h] [ebp-4h] - int y2b; // [esp+28h] [ebp-4h] + int x2; // [esp+20h] [ebp-Ch] + int x2a; // [esp+20h] [ebp-Ch] + int y1; // [esp+24h] [ebp-8h] + int y1a; // [esp+24h] [ebp-8h] + int y1b; // [esp+24h] [ebp-8h] + int y2; // [esp+28h] [ebp-4h] + int y2a; // [esp+28h] [ebp-4h] + int y2b; // [esp+28h] [ebp-4h] v48 = 0; - for ( i = DL2_NumNoChar(); i > 700 && v48 < 100; i = DL2_NumNoChar() ) - { + for (i = DL2_NumNoChar(); i > 700 && v48 < 100; i = DL2_NumNoChar()) { v2 = random(0, 38); v4 = v2 + 1; v5 = random(0, 38); v6 = v5 + 1; v7 = v5 + 1 + 40 * v4; - if ( predungeon[0][v7] != 35 ) + if (predungeon[0][v7] != 35) continue; y2f = 0; y1f = 0; x2f = 0; x1f = 0; v8 = predungeon[-1][v7]; // *((unsigned char *)&VR1 + v7); - if ( (_BYTE)v8 == 32 && predungeon[1][v7] == 46 ) - { - if ( predungeon[0][v7 + 39] != 46 - || predungeon[1][v7 + 1] != 46 - || predungeon[-1][v7 - 1] != 32 // *((_BYTE *)&HR3 + v7 + 3) != 32 - || predungeon[-1][v7 + 1] != 32 ) // *((_BYTE *)&VR1 + v7 + 1) != 32 ) + if ((_BYTE)v8 == 32 && predungeon[1][v7] == 46) { + if (predungeon[0][v7 + 39] != 46 + || predungeon[1][v7 + 1] != 46 + || predungeon[-1][v7 - 1] != 32 // *((_BYTE *)&HR3 + v7 + 3) != 32 + || predungeon[-1][v7 + 1] != 32) // *((_BYTE *)&VR1 + v7 + 1) != 32 ) { goto LABEL_34; } y1f = 1; -LABEL_32: + LABEL_32: x1f = 1; -LABEL_33: + LABEL_33: y2f = 1; goto LABEL_34; } - if ( predungeon[1][v7] == 32 && (_BYTE)v8 == 46 ) - { - if ( predungeon[-1][v7 - 1] != 46 // *((_BYTE *)&HR3 + v7 + 3) != 46 - || predungeon[-1][v7 + 1] != 46 // *((_BYTE *)&VR1 + v7 + 1) != 46 - || predungeon[0][v7 + 39] != 32 - || predungeon[1][v7 + 1] != 32 ) - { + if (predungeon[1][v7] == 32 && (_BYTE)v8 == 46) { + if (predungeon[-1][v7 - 1] != 46 // *((_BYTE *)&HR3 + v7 + 3) != 46 + || predungeon[-1][v7 + 1] != 46 // *((_BYTE *)&VR1 + v7 + 1) != 46 + || predungeon[0][v7 + 39] != 32 + || predungeon[1][v7 + 1] != 32) { goto LABEL_34; } y1f = 1; @@ -2585,304 +2307,263 @@ LABEL_33: goto LABEL_33; } v9 = predungeon[0][v7 - 1]; /* *((_BYTE *)&nRoomCnt + v7 + 3); */ - if ( v9 != 32 || predungeon[0][v7 + 1] != 46 ) - { - if ( predungeon[0][v7 + 1] != 32 - || v9 != 46 - || predungeon[-1][v7 - 1] != 46 // *((_BYTE *)&HR3 + v7 + 3) != 46 - || predungeon[0][v7 + 39] != 46 - || predungeon[-1][v7 + 1] != 32 - || predungeon[1][v7 + 1] != 32 ) - { + if (v9 != 32 || predungeon[0][v7 + 1] != 46) { + if (predungeon[0][v7 + 1] != 32 + || v9 != 46 + || predungeon[-1][v7 - 1] != 46 // *((_BYTE *)&HR3 + v7 + 3) != 46 + || predungeon[0][v7 + 39] != 46 + || predungeon[-1][v7 + 1] != 32 + || predungeon[1][v7 + 1] != 32) { goto LABEL_34; } x2f = 1; goto LABEL_32; } - if ( predungeon[-1][v7 + 1] == 46 - && predungeon[1][v7 + 1] == 46 - && predungeon[-1][v7 - 1] == 32 // *((_BYTE *)&HR3 + v7 + 3) == 32 - && predungeon[0][v7 + 39] == 32 ) - { + if (predungeon[-1][v7 + 1] == 46 + && predungeon[1][v7 + 1] == 46 + && predungeon[-1][v7 - 1] == 32 // *((_BYTE *)&HR3 + v7 + 3) == 32 + && predungeon[0][v7 + 39] == 32) { x2f = 1; x1f = 1; y1f = 1; v10 = DL2_Cont(1, 1, 1, 0); goto LABEL_35; } -LABEL_34: + LABEL_34: v10 = DL2_Cont(x1f, y1f, x2f, y2f); -LABEL_35: - if ( v10 ) - { + LABEL_35: + if (v10) { v11 = v4 - 1; - if ( !x1f ) + if (!x1f) v11 = v4; v12 = x2f; - if ( x2f ) + if (x2f) ++v4; x2 = v4; v13 = y1f; - if ( y1f ) + if (y1f) y1 = v6 - 1; else y1 = v6; v14 = y2f; - if ( y2f ) + if (y2f) ++v6; v15 = x1f; y2 = v6; - if ( x1f ) - { - if ( x2f ) - { - if ( y1f ) - { - if ( y2f ) + if (x1f) { + if (x2f) { + if (y1f) { + if (y2f) goto LABEL_177; v37 = x1f; v38 = x2f; v39 = x2; - while ( v37 || v38 ) - { - if ( !v11 ) + while (v37 || v38) { + if (!v11) v37 = 0; - if ( v39 == 39 ) + if (v39 == 39) v38 = 0; - if ( v39 - v11 >= 14 ) - { + if (v39 - v11 >= 14) { v37 = 0; v38 = 0; } - if ( v37 ) + if (v37) --v11; - if ( v38 ) + if (v38) ++v39; - if ( predungeon[v11][y1] != 32 ) + if (predungeon[v11][y1] != 32) v37 = 0; - if ( predungeon[v39][y1] != 32 ) + if (predungeon[v39][y1] != 32) v38 = 0; } v28 = v11 + 2; v40 = v39 - 2; x2a = v40; v41 = v40 - v28; - if ( v41 <= 5 ) + if (v41 <= 5) goto LABEL_177; v42 = y1f; - for ( j = y1; ; --j ) - { - if ( !j ) + for (j = y1;; --j) { + if (!j) v42 = 0; - if ( y2 - j >= 12 ) + if (y2 - j >= 12) v42 = 0; - if ( v28 <= x2a ) - { + if (v28 <= x2a) { v44 = v41 + 1; v45 = &predungeon[v28][j]; - do - { - if ( *v45 != 32 ) + do { + if (*v45 != 32) v42 = 0; v45 += 40; --v44; - } - while ( v44 ); + } while (v44); } - if ( !v42 ) + if (!v42) break; } v46 = j + 2; - if ( y2 - v46 <= 5 ) + if (y2 - v46 <= 5) goto LABEL_177; DL2_DrawRoom(v28, v46, x2a, y2); v36 = v46; v47 = y2; - } - else - { + } else { v27 = x2; - while ( v15 || v12 ) - { - if ( !v11 ) + while (v15 || v12) { + if (!v11) v15 = 0; - if ( v27 == 39 ) + if (v27 == 39) v12 = 0; - if ( v27 - v11 >= 14 ) - { + if (v27 - v11 >= 14) { v15 = 0; v12 = 0; } - if ( v15 ) + if (v15) --v11; - if ( v12 ) + if (v12) ++v27; - if ( predungeon[v11][v6] != 32 ) + if (predungeon[v11][v6] != 32) v15 = 0; - if ( predungeon[v27][v6] != 32 ) + if (predungeon[v27][v6] != 32) v12 = 0; } v28 = v11 + 2; v29 = v27 - 2; x2a = v29; v30 = v29 - v28; - if ( v30 <= 5 ) + if (v30 <= 5) goto LABEL_177; v31 = y2f; v32 = y2; - if ( y2f ) - { - while ( 1 ) - { - if ( v32 == 39 ) + if (y2f) { + while (1) { + if (v32 == 39) v31 = 0; - if ( v32 - y1 >= 12 ) + if (v32 - y1 >= 12) v31 = 0; - if ( v28 <= x2a ) - { + if (v28 <= x2a) { v33 = v30 + 1; v34 = &predungeon[v28][v32]; - do - { - if ( *v34 != 32 ) + do { + if (*v34 != 32) v31 = 0; v34 += 40; --v33; - } - while ( v33 ); + } while (v33); } - if ( !v31 ) + if (!v31) break; ++v32; } } v35 = v32 - 2; - if ( v35 - y1 <= 5 ) + if (v35 - y1 <= 5) goto LABEL_177; DL2_DrawRoom(v28, y1, x2a, v35); v36 = y1; v47 = v35; } DL2_KnockWalls(v28, v36, x2a, v47); - } - else - { + } else { v21 = y1; - while ( v13 || v14 ) - { - if ( !v21 ) + while (v13 || v14) { + if (!v21) v13 = 0; - if ( y2 == 39 ) + if (y2 == 39) v14 = 0; - if ( y2 - v21 >= 14 ) - { + if (y2 - v21 >= 14) { v13 = 0; v14 = 0; } - if ( v13 ) + if (v13) --v21; - if ( v14 ) + if (v14) ++y2; v22 = predungeon[v11]; - if ( v22[v21] != 32 ) + if (v22[v21] != 32) v13 = 0; - if ( v22[y2] != 32 ) + if (v22[y2] != 32) v14 = 0; } y2b = y2 - 2; v23 = v21 + 2; y1b = v23; - if ( y2b - v23 > 5 ) - { + if (y2b - v23 > 5) { v24 = x1f; - while ( 1 ) - { - if ( !v11 ) + while (1) { + if (!v11) v24 = 0; - if ( x2 - v11 >= 12 ) + if (x2 - v11 >= 12) v24 = 0; v25 = v23; - if ( v23 <= y2b ) - { - do - { - if ( predungeon[v11][v25] != 32 ) + if (v23 <= y2b) { + do { + if (predungeon[v11][v25] != 32) v24 = 0; ++v25; - } - while ( v25 <= y2b ); + } while (v25 <= y2b); v23 = y1b; } - if ( !v24 ) + if (!v24) break; --v11; } v26 = v11 + 2; - if ( x2 - v26 > 5 ) - { + if (x2 - v26 > 5) { DL2_DrawRoom(v26, v23, x2, y2b); DL2_KnockWalls(v26, v23, x2, y2b); } } } - } - else - { + } else { v16 = x2; - while ( v13 || v14 ) - { - if ( !y1 ) + while (v13 || v14) { + if (!y1) v13 = 0; - if ( y2 == 39 ) + if (y2 == 39) v14 = 0; - if ( y2 - y1 >= 14 ) - { + if (y2 - y1 >= 14) { v13 = 0; v14 = 0; } - if ( v13 ) + if (v13) --y1; - if ( v14 ) + if (v14) ++y2; v17 = predungeon[x2]; - if ( v17[y1] != 32 ) + if (v17[y1] != 32) v13 = 0; - if ( v17[y2] != 32 ) + if (v17[y2] != 32) v14 = 0; } y2a = y2 - 2; y1a = y1 + 2; - if ( y2a - y1a > 5 ) - { + if (y2a - y1a > 5) { v18 = x2f; - if ( x2f ) - { - while ( 1 ) - { - if ( v16 == 39 ) + if (x2f) { + while (1) { + if (v16 == 39) v18 = 0; - if ( v16 - v11 >= 12 ) + if (v16 - v11 >= 12) v18 = 0; - for ( k = y1a; k <= y2a; ++k ) - { - if ( predungeon[v16][k] != 32 ) + for (k = y1a; k <= y2a; ++k) { + if (predungeon[v16][k] != 32) v18 = 0; } - if ( !v18 ) + if (!v18) break; ++v16; } } v20 = v16 - 2; - if ( v20 - v11 > 5 ) - { + if (v20 - v11 > 5) { DL2_DrawRoom(v11, y1a, v20, y2a); DL2_KnockWalls(v11, y1a, v20, y2a); } } } } -LABEL_177: + LABEL_177: ++v48; } return DL2_NumNoChar() <= 700; @@ -2892,182 +2573,159 @@ bool __fastcall DL2_Cont(bool x1f, bool y1f, bool x2f, bool y2f) { bool v4; // zf - if ( x1f && x2f ) - { - if ( !y1f ) + if (x1f && x2f) { + if (!y1f) goto LABEL_16; - if ( y2f ) + if (y2f) return 0; - if ( !y1f ) - { -LABEL_16: + if (!y1f) { + LABEL_16: v4 = y2f == 0; goto LABEL_11; } return 1; } - if ( !y1f || !y2f ) + if (!y1f || !y2f) return 0; - if ( x1f ) + if (x1f) return 1; v4 = x2f == 0; LABEL_11: - if ( !v4 ) + if (!v4) return 1; return 0; } int __cdecl DL2_NumNoChar() { - int result; // eax + int result; // eax signed int v1; // edx - _BYTE *v2; // ecx + _BYTE *v2; // ecx signed int v3; // esi result = 0; v1 = 0; - do - { + do { v2 = (unsigned char *)predungeon + v1; v3 = 40; - do - { - if ( *v2 == 32 ) + do { + if (*v2 == 32) ++result; v2 += 40; --v3; - } - while ( v3 ); + } while (v3); ++v1; - } - while ( v1 < 40 ); + } while (v1 < 40); return result; } void __fastcall DL2_DrawRoom(int x1, int y1, int x2, int y2) { - int v4; // ebx + int v4; // ebx char *v5; // edx - int v6; // esi - int i; // esi + int v6; // esi + int i; // esi char *v8; // esi - int v9; // eax - int v10; // [esp+Ch] [ebp-4h] + int v9; // eax + int v10; // [esp+Ch] [ebp-4h] v4 = y1; v10 = y1; - while ( v4 <= y2 ) - { - if ( x1 <= x2 ) - { + while (v4 <= y2) { + if (x1 <= x2) { v5 = &predungeon[x1][v4]; v6 = x2 - x1 + 1; - do - { + do { *v5 = 46; v5 += 40; --v6; - } - while ( v6 ); + } while (v6); } ++v4; } - for ( i = v10; i <= y2; ++i ) - { + for (i = v10; i <= y2; ++i) { predungeon[x1][i] = 35; predungeon[x2][i] = 35; } - if ( x1 <= x2 ) - { + if (x1 <= x2) { v8 = &predungeon[x1][y2]; v9 = x2 - x1 + 1; - do - { + do { v8[v10 - y2] = 35; *v8 = 35; v8 += 40; --v9; - } - while ( v9 ); + } while (v9); } } void __fastcall DL2_KnockWalls(int x1, int y1, int x2, int y2) { - int v4; // esi - char *v5; // ebx - char *v6; // eax - int v7; // edi - int v8; // eax - int v9; // ecx + int v4; // esi + char *v5; // ebx + char *v6; // eax + int v7; // edi + int v8; // eax + int v9; // ecx char *v10; // edx char *v11; // esi v4 = x1 + 1; - if ( x1 + 1 < x2 ) - { + if (x1 + 1 < x2) { v5 = &predungeon[v4][y2 + 1]; v6 = &predungeon[v4][y1 - 1]; // (char *)&nRoomCnt + 40 * v4 + y1 + 3; /* check */ v7 = x2 - v4; - do - { - if ( *v6 == 46 && v6[2] == 46 ) + do { + if (*v6 == 46 && v6[2] == 46) v6[1] = 46; - if ( v6[y2 - y1] == 46 && *v5 == 46 ) + if (v6[y2 - y1] == 46 && *v5 == 46) *(v5 - 1) = 46; - if ( *v6 == 68 ) + if (*v6 == 68) *v6 = 46; - if ( *v5 == 68 ) + if (*v5 == 68) *v5 = 46; v6 += 40; v5 += 40; --v7; - } - while ( v7 ); + } while (v7); } v8 = y1 + 1; - if ( y1 + 1 < y2 ) - { + if (y1 + 1 < y2) { v9 = x1; v10 = predungeon[x2 + 1]; - do - { + do { v11 = &predungeon[v9 - 1][v8]; // (char *)&VR1 + v9 * 40 + v8; - if ( *v11 == 46 && predungeon[v9 + 1][v8] == 46 ) + if (*v11 == 46 && predungeon[v9 + 1][v8] == 46) predungeon[v9][v8] = 46; - if ( v10[v8 - 80] == 46 && v10[v8] == 46 ) + if (v10[v8 - 80] == 46 && v10[v8] == 46) v10[v8 - 40] = 46; - if ( *v11 == 68 ) + if (*v11 == 68) *v11 = 46; - if ( v10[v8] == 68 ) + if (v10[v8] == 68) v10[v8] = 46; ++v8; - } - while ( v8 < y2 ); + } while (v8 < y2); } } void __cdecl DRLG_L2FloodTVal() { - int v0; // ebx - int v1; // esi - char *v2; // edi - _BYTE *v3; // [esp+Ch] [ebp-Ch] + int v0; // ebx + int v1; // esi + char *v2; // edi + _BYTE *v3; // [esp+Ch] [ebp-Ch] signed int x; // [esp+10h] [ebp-8h] signed int i; // [esp+14h] [ebp-4h] v0 = 16; v1 = 0; - do - { + do { i = 0; x = 16; v2 = &dung_map[16][v0]; v3 = (unsigned char *)dungeon + v1; - do - { - if ( *v3 == 3 && !*v2 ) - { + do { + if (*v3 == 3 && !*v2) { DRLG_L2FTVR(i, v1, x, v0, 0); ++TransVal; } @@ -3075,37 +2733,35 @@ void __cdecl DRLG_L2FloodTVal() v3 += 40; v2 += 224; ++i; - } - while ( i < 40 ); + } while (i < 40); v0 += 2; ++v1; - } - while ( v1 < 40 ); + } while (v1 < 40); } // 5A5590: using guessed type char TransVal; void __fastcall DRLG_L2FTVR(int i, int j, int x, int y, int d) { - int v5; // ebx - int v6; // esi - int v7; // edi - int v8; // edx - int v9; // ecx - int v10; // ebx - int v11; // eax - int v12; // edi + int v5; // ebx + int v6; // esi + int v7; // edi + int v8; // edx + int v9; // ecx + int v10; // ebx + int v11; // eax + int v12; // edi char v13; // al char v14; // al - int v15; // ecx - int v16; // ecx - int v17; // ecx - int v18; // ecx - int v19; // [esp+Ch] [ebp-14h] - int k; // [esp+10h] [ebp-10h] - int v21; // [esp+14h] [ebp-Ch] - int ja; // [esp+18h] [ebp-8h] - int ia; // [esp+1Ch] [ebp-4h] - int ya; // [esp+2Ch] [ebp+Ch] + int v15; // ecx + int v16; // ecx + int v17; // ecx + int v18; // ecx + int v19; // [esp+Ch] [ebp-14h] + int k; // [esp+10h] [ebp-10h] + int v21; // [esp+14h] [ebp-Ch] + int ja; // [esp+18h] [ebp-8h] + int ia; // [esp+1Ch] [ebp-4h] + int ya; // [esp+2Ch] [ebp+Ch] v5 = x; v6 = y; @@ -3114,16 +2770,14 @@ void __fastcall DRLG_L2FTVR(int i, int j, int x, int y, int d) v9 = 112 * x + y; ja = v7; v21 = v8; - if ( !dung_map[0][v9] ) - { + if (!dung_map[0][v9]) { v19 = x; ia = v8 - 1; v10 = x - 2; v11 = 40 * v8; ya = v7 - 1; v12 = v6 - 2; - for ( k = 40 * v8; dungeon[0][v11 + ja] == 3; v11 = k ) - { + for (k = 40 * v8; dungeon[0][v11 + ja] == 3; v11 = k) { v13 = TransVal; dung_map[0][v9] = TransVal; dung_map[1][v9] = v13; @@ -3148,43 +2802,39 @@ void __fastcall DRLG_L2FTVR(int i, int j, int x, int y, int d) ++v21; ++ia; v9 = v19 * 112 + v6; - if ( dung_map[v19][v6] ) + if (dung_map[v19][v6]) break; } v5 = x; } v14 = TransVal; - if ( d == 1 ) - { + if (d == 1) { v15 = v6 + 112 * v5; dung_map[0][v15] = TransVal; dung_map[0][v15 + 1] = v14; } - if ( d == 2 ) - { + if (d == 2) { v16 = v6 + 112 * v5; dung_map[1][v16] = v14; dung_map[1][v16 + 1] = v14; } - if ( d == 3 ) - { + if (d == 3) { v17 = v6 + 112 * v5; dung_map[0][v17] = v14; dung_map[1][v17] = v14; } - if ( d == 4 ) - { + if (d == 4) { v18 = v6 + 112 * v5; dung_map[0][v18 + 1] = v14; dung_map[1][v18 + 1] = v14; } - if ( d == 5 ) + if (d == 5) dung_map[v5 + 1][v6 + 1] = v14; - if ( d == 6 ) + if (d == 6) dung_map[v5][v6 + 1] = v14; - if ( d == 7 ) + if (d == 7) dung_map[v5 + 1][v6] = v14; - if ( d == 8 ) + if (d == 8) dung_map[v5][v6] = v14; } // 5A5590: using guessed type char TransVal; @@ -3192,53 +2842,46 @@ void __fastcall DRLG_L2FTVR(int i, int j, int x, int y, int d) void __cdecl DRLG_L2TransFix() { signed int v0; // esi - char *v1; // eax - char *v2; // ecx + char *v1; // eax + char *v2; // ecx signed int v3; // edi - char v4; // bl - char v5; // dl - char v6; // dl - char v7; // dl - char v8; // dl - char v9; // dl - char *v10; // [esp+Ch] [ebp-4h] + char v4; // bl + char v5; // dl + char v6; // dl + char v7; // dl + char v8; // dl + char v9; // dl + char *v10; // [esp+Ch] [ebp-4h] v0 = 0; v10 = &dung_map[16][16]; - do - { + do { v1 = v10; v2 = (char *)dungeon + v0; v3 = 40; - do - { + do { v4 = *v2; - if ( *v2 == 14 && *(v2 - 1) == 10 ) - { + if (*v2 == 14 && *(v2 - 1) == 10) { v5 = *v1; v1[112] = *v1; v1[113] = v5; } - if ( v4 == 15 && v2[40] == 11 ) - { + if (v4 == 15 && v2[40] == 11) { v6 = *v1; v1[1] = *v1; v1[113] = v6; } - if ( v4 == 10 ) - { + if (v4 == 10) { v7 = *v1; v1[112] = *v1; v1[113] = v7; } - if ( v4 == 11 ) - { + if (v4 == 11) { v8 = *v1; v1[1] = *v1; v1[113] = v8; } - if ( v4 == 16 ) - { + if (v4 == 16) { v9 = *v1; v1[112] = *v1; v1[1] = v9; @@ -3247,127 +2890,108 @@ void __cdecl DRLG_L2TransFix() v1 += 224; v2 += 40; --v3; - } - while ( v3 ); + } while (v3); v10 += 2; ++v0; - } - while ( v0 < 40 ); + } while (v0 < 40); } void __cdecl L2DirtFix() { signed int v0; // ecx - char *v1; // eax + char *v1; // eax signed int v2; // edx v0 = 0; - do - { + do { v1 = (char *)dungeon + v0; v2 = 40; - do - { - if ( *v1 == 13 && v1[40] != 11 ) + do { + if (*v1 == 13 && v1[40] != 11) *v1 = -110; - if ( *v1 == 11 && v1[40] != 11 ) + if (*v1 == 11 && v1[40] != 11) *v1 = -112; - if ( *v1 == 15 && v1[40] != 11 ) + if (*v1 == 15 && v1[40] != 11) *v1 = -108; - if ( *v1 == 10 && v1[1] != 10 ) + if (*v1 == 10 && v1[1] != 10) *v1 = -113; - if ( *v1 == 13 && v1[1] != 10 ) + if (*v1 == 13 && v1[1] != 10) *v1 = -110; - if ( *v1 == 14 && v1[1] != 15 ) + if (*v1 == 14 && v1[1] != 15) *v1 = -109; v1 += 40; --v2; - } - while ( v2 ); + } while (v2); ++v0; - } - while ( v0 < 40 ); + } while (v0 < 40); } void __cdecl DRLG_InitL2Vals() { - int v0; // edi - int (*v1)[112]; // ebx - char *v2; // ecx - int (*v3)[112]; // edx - signed int v4; // esi - int v5; // eax - int v6; // ecx - int (*v7)[112]; // esi - char *v8; // eax - int (*v9)[112]; // edx + int v0; // edi + int(*v1)[112]; // ebx + char *v2; // ecx + int(*v3)[112]; // edx + signed int v4; // esi + int v5; // eax + int v6; // ecx + int(*v7)[112]; // esi + char *v8; // eax + int(*v9)[112]; // edx signed int v10; // ebx - int v11; // edi - char v12; // [esp-4h] [ebp-14h] + int v11; // edi + char v12; // [esp-4h] [ebp-14h] v0 = 0; v1 = dPiece; - do - { + do { v2 = (char *)dArch + v0; v3 = v1; v4 = 112; - do - { + do { v5 = (*v3)[0]; - if ( (*v3)[0] != 541 && v5 != 178 && v5 != 551 ) - { - if ( v5 == 542 || v5 == 553 ) + if ((*v3)[0] != 541 && v5 != 178 && v5 != 551) { + if (v5 == 542 || v5 == 553) goto LABEL_11; - if ( v5 != 13 ) - { - if ( v5 != 17 ) + if (v5 != 13) { + if (v5 != 17) goto LABEL_13; -LABEL_11: + LABEL_11: v12 = 6; goto LABEL_12; } } v12 = 5; -LABEL_12: + LABEL_12: *v2 = v12; -LABEL_13: + LABEL_13: ++v3; v2 += 112; --v4; - } - while ( v4 ); - v1 = (int (*)[112])((char *)v1 + 4); + } while (v4); + v1 = (int(*)[112])((char *)v1 + 4); ++v0; - } - while ( (signed int)v1 < (signed int)dPiece[1] ); + } while ((signed int)v1 < (signed int)dPiece[1]); v6 = 0; v7 = dPiece; - do - { + do { v8 = &dArch[0][v6 + 2]; v9 = v7; v10 = 112; - do - { + do { v11 = (*v9)[0]; - if ( (*v9)[0] == 132 ) - { + if ((*v9)[0] == 132) { *(v8 - 1) = 2; *v8 = 1; - } - else if ( v11 == 135 || v11 == 139 ) - { + } else if (v11 == 135 || v11 == 139) { v8[110] = 3; v8[222] = 4; } ++v9; v8 += 112; --v10; - } - while ( v10 ); - v7 = (int (*)[112])((char *)v7 + 4); + } while (v10); + v7 = (int(*)[112])((char *)v7 + 4); ++v6; - } - while ( (signed int)v7 < (signed int)dPiece[1] ); + } while ((signed int)v7 < (signed int)dPiece[1]); } diff --git a/Source/drlg_l3.cpp b/Source/drlg_l3.cpp index 97d89f98..051447a8 100644 --- a/Source/drlg_l3.cpp +++ b/Source/drlg_l3.cpp @@ -44,31 +44,31 @@ const unsigned char L3XTRA3[4] = { 1u, 1u, 7u, 108u }; const unsigned char L3XTRA4[4] = { 1u, 1u, 9u, 109u }; const unsigned char L3XTRA5[4] = { 1u, 1u, 10u, 110u }; const unsigned char L3ANVIL[244] = { - 11, 11, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 29, 26, 26, 26, - 26, 26, 30, 0, 0, 0, 29, 34, 33, 33, - 37, 36, 33, 35, 30, 0, 0, 25, 33, 37, - 27, 32, 31, 36, 33, 28, 0, 0, 25, 37, - 32, 7, 7, 7, 31, 27, 32, 0, 0, 25, - 28, 7, 7, 7, 7, 2, 2, 2, 0, 0, - 25, 35, 30, 7, 7, 7, 29, 26, 30, 0, - 0, 25, 33, 35, 26, 30, 29, 34, 33, 28, - 0, 0, 31, 36, 33, 33, 35, 34, 33, 37, - 32, 0, 0, 0, 31, 27, 27, 27, 27, 27, - 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0 + 11, 11, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 29, 26, 26, 26, + 26, 26, 30, 0, 0, 0, 29, 34, 33, 33, + 37, 36, 33, 35, 30, 0, 0, 25, 33, 37, + 27, 32, 31, 36, 33, 28, 0, 0, 25, 37, + 32, 7, 7, 7, 31, 27, 32, 0, 0, 25, + 28, 7, 7, 7, 7, 2, 2, 2, 0, 0, + 25, 35, 30, 7, 7, 7, 29, 26, 30, 0, + 0, 25, 33, 35, 26, 30, 29, 34, 33, 28, + 0, 0, 31, 36, 33, 33, 35, 34, 33, 37, + 32, 0, 0, 0, 31, 27, 27, 27, 27, 27, + 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0 }; const unsigned char L3SpawnTbl1[15] = { 0u, 10u, 67u, 5u, 44u, 6u, 9u, 0u, 0u, 28u, 131u, 6u, 9u, 10u, 5u }; /* local spawntable? */ const unsigned char L3SpawnTbl2[15] = { 0u, 10u, 3u, 5u, 12u, 6u, 9u, 0u, 0u, 12u, 3u, 6u, 9u, 10u, 5u }; /* local spawntable? */ @@ -76,206 +76,182 @@ const unsigned char L3PoolSub[15] = { 0u, 35u, 26u, 36u, 25u, 29u, 34u, 7u, 33u, void __cdecl AddFenceDoors() { - signed int v0; // esi - char *v1; // eax - signed int v2; // ebx + signed int v0; // esi + char *v1; // eax + signed int v2; // ebx unsigned char v3; // cl - char v4; // cl - char v5; // cl + char v4; // cl + char v5; // cl v0 = 0; - do - { + do { v1 = &dungeon[-1][v0 + 39]; v2 = 40; - do - { - if ( v1[1] == 7 ) - { + do { + if (v1[1] == 7) { v3 = *(v1 - 39); - if ( v3 > 0x98u - || v3 < 0x82u - || (v4 = v1[41], (unsigned char)v4 > 0x98u) - || (unsigned char)v4 < 0x82u ) - { - if ( (unsigned char)*v1 <= 0x98u && (unsigned char)*v1 >= 0x82u ) - { + if (v3 > 0x98u + || v3 < 0x82u + || (v4 = v1[41], (unsigned char)v4 > 0x98u) + || (unsigned char)v4 < 0x82u) { + if ((unsigned char)*v1 <= 0x98u && (unsigned char)*v1 >= 0x82u) { v5 = v1[2]; - if ( (unsigned char)v5 <= 0x98u && (unsigned char)v5 >= 0x82u ) + if ((unsigned char)v5 <= 0x98u && (unsigned char)v5 >= 0x82u) v1[1] = -109; } - } - else - { + } else { v1[1] = -110; } } v1 += 40; --v2; - } - while ( v2 ); + } while (v2); ++v0; - } - while ( v0 < 40 ); + } while (v0 < 40); } void __cdecl FenceDoorFix() { - signed int v0; // edi - char *v1; // eax - signed int v2; // esi - char v3; // bl - char v4; // cl + signed int v0; // edi + char *v1; // eax + signed int v2; // esi + char v3; // bl + char v4; // cl unsigned char v5; // cl - char v6; // dl - char v7; // cl - char v8; // cl - char v9; // dl + char v6; // dl + char v7; // cl + char v8; // cl + char v9; // dl v0 = 0; - do - { + do { v1 = &dungeon[-1][v0 + 39]; v2 = 40; - do - { + do { v3 = v1[1]; - if ( v3 == -110 - && ((v4 = v1[41], (unsigned char)v4 > 0x98u) - || (unsigned char)v4 < 0x82u - || (v5 = *(v1 - 39), v5 > 0x98u) - || v5 < 0x82u - || (v6 = v1[41], v6 != -126) - && v5 != -126 - && v6 != -124 - && v5 != -124 - && v6 != -123 - && v5 != -123 - && v6 != -122 - && v5 != -122 - && v6 != -120 - && v5 != -120 - && v6 != -118 - && v5 != -118 - && v6 != -116 - && v5 != -116) - || v3 == -109 - && ((v7 = v1[2], (unsigned char)v7 > 0x98u) - || (unsigned char)v7 < 0x82u - || (v8 = *v1, (unsigned char)*v1 > 0x98u) - || (unsigned char)v8 < 0x82u - || (v9 = v1[2], v9 != -125) - && v8 != -125 - && v9 != -124 - && v8 != -124 - && v9 != -123 - && v8 != -123 - && v9 != -121 - && v8 != -121 - && v9 != -119 - && v8 != -119 - && v9 != -118 - && v8 != -118 - && v9 != -117 - && v8 != -117) ) - { + if (v3 == -110 + && ((v4 = v1[41], (unsigned char)v4 > 0x98u) + || (unsigned char)v4 < 0x82u + || (v5 = *(v1 - 39), v5 > 0x98u) + || v5 < 0x82u + || (v6 = v1[41], v6 != -126) + && v5 != -126 + && v6 != -124 + && v5 != -124 + && v6 != -123 + && v5 != -123 + && v6 != -122 + && v5 != -122 + && v6 != -120 + && v5 != -120 + && v6 != -118 + && v5 != -118 + && v6 != -116 + && v5 != -116) + || v3 == -109 + && ((v7 = v1[2], (unsigned char)v7 > 0x98u) + || (unsigned char)v7 < 0x82u + || (v8 = *v1, (unsigned char)*v1 > 0x98u) + || (unsigned char)v8 < 0x82u + || (v9 = v1[2], v9 != -125) + && v8 != -125 + && v9 != -124 + && v8 != -124 + && v9 != -123 + && v8 != -123 + && v9 != -121 + && v8 != -121 + && v9 != -119 + && v8 != -119 + && v9 != -118 + && v8 != -118 + && v9 != -117 + && v8 != -117)) { v1[1] = 7; } v1 += 40; --v2; - } - while ( v2 ); + } while (v2); ++v0; - } - while ( v0 < 40 ); + } while (v0 < 40); } int __cdecl DRLG_L3Anvil() { - int v0; // esi - signed int v1; // edi - signed int v2; // ebx - signed int v3; // eax - int v4; // ecx - unsigned char v5; // dl - signed int v7; // ebx - int v8; // edi - int v9; // ecx - signed int v10; // eax + int v0; // esi + signed int v1; // edi + signed int v2; // ebx + signed int v3; // eax + int v4; // ecx + unsigned char v5; // dl + signed int v7; // ebx + int v8; // edi + int v9; // ecx + signed int v10; // eax unsigned char v11; // dl - signed int v12; // [esp+Ch] [ebp-Ch] - signed int v13; // [esp+Ch] [ebp-Ch] - signed int v14; // [esp+10h] [ebp-8h] - int v15; // [esp+14h] [ebp-4h] + signed int v12; // [esp+Ch] [ebp-Ch] + signed int v13; // [esp+Ch] [ebp-Ch] + signed int v14; // [esp+10h] [ebp-8h] + int v15; // [esp+14h] [ebp-4h] v0 = random(0, 29); v1 = 0; v15 = random(0, 29); v12 = 0; - while ( 1 ) - { - if ( v12 >= 200 ) + while (1) { + if (v12 >= 200) return 1; ++v12; v14 = 1; v2 = 2; - do - { - if ( v14 != 1 ) + do { + if (v14 != 1) break; v3 = 0; v4 = v15 + v1 + 40 * v0; - do - { - if ( v14 != 1 ) + do { + if (v14 != 1) break; v5 = L3ANVIL[v2]; - if ( v5 && dungeon[0][v4] != v5 ) + if (v5 && dungeon[0][v4] != v5) v14 = 0; - if ( dflags[0][v4] ) + if (dflags[0][v4]) v14 = 0; ++v2; ++v3; v4 += 40; - } - while ( v3 < 11 ); + } while (v3 < 11); ++v1; - } - while ( v1 < 11 ); + } while (v1 < 11); v1 = 0; - if ( v14 ) + if (v14) break; - if ( ++v0 == 29 ) - { + if (++v0 == 29) { v0 = 0; - if ( ++v15 == 29 ) + if (++v15 == 29) v15 = 0; } } - if ( v12 >= 200 ) + if (v12 >= 200) return 1; v13 = 11; v7 = 123; v8 = v15 + 40 * v0; - do - { + do { v9 = v8; v10 = 11; - do - { + do { v11 = L3ANVIL[v7]; - if ( v11 ) + if (v11) dungeon[0][v9] = v11; dflags[0][v9] |= DFLAG_EXPLORED; ++v7; v9 += 40; --v10; - } - while ( v10 ); + } while (v10); ++v8; --v13; - } - while ( v13 ); + } while (v13); setpc_y = v15; setpc_w = 11; setpc_h = 11; @@ -287,22 +263,19 @@ int __cdecl DRLG_L3Anvil() void __cdecl FixL3Warp() { - int v0; // ecx + int v0; // ecx signed int v1; // esi - char *v2; // eax - char v3; // dl + char *v2; // eax + char v3; // dl signed int v4; // eax v0 = 0; - while ( 2 ) - { + while (2) { v1 = 0; v2 = &dungeon[1][v0 + 1]; - do - { + do { v3 = *(v2 - 41); - if ( v3 == 125 && *(v2 - 1) == 125 && *(v2 - 40) == 125 && *v2 == 125 ) - { + if (v3 == 125 && *(v2 - 1) == 125 && *(v2 - 40) == 125 && *v2 == 125) { v4 = v1; dungeon[v4][v0] = -100; dungeon[v4 + 1][v0] = -101; @@ -310,13 +283,12 @@ void __cdecl FixL3Warp() dungeon[v4 + 1][v0 + 1] = -102; return; } - if ( v3 == 5 && *v2 == 7 ) + if (v3 == 5 && *v2 == 7) *(v2 - 41) = 7; ++v1; v2 += 40; - } - while ( v1 < 40 ); - if ( ++v0 < 40 ) + } while (v1 < 40); + if (++v0 < 40) continue; break; } @@ -325,45 +297,36 @@ void __cdecl FixL3Warp() void __cdecl FixL3HallofHeroes() { signed int v0; // ecx - char *v1; // eax + char *v1; // eax signed int v2; // edx signed int v3; // ecx - char *v4; // eax + char *v4; // eax signed int v5; // edx v0 = 0; - do - { + do { v1 = (char *)dungeon + v0; v2 = 40; - do - { - if ( *v1 == 5 && v1[41] == 7 ) + do { + if (*v1 == 5 && v1[41] == 7) *v1 = 7; v1 += 40; --v2; - } - while ( v2 ); + } while (v2); ++v0; - } - while ( v0 < 40 ); + } while (v0 < 40); v3 = 0; - do - { + do { v4 = (char *)dungeon + v3; v5 = 40; - do - { - if ( *v4 == 5 ) - { - if ( v4[41] == 12 && v4[40] == 7 ) - { + do { + if (*v4 == 5) { + if (v4[41] == 12 && v4[40] == 7) { *v4 = 7; v4[1] = 7; v4[41] = 7; } - if ( *v4 == 5 && v4[41] == 12 && v4[1] == 7 ) - { + if (*v4 == 5 && v4[41] == 12 && v4[1] == 7) { *v4 = 7; v4[40] = 7; v4[41] = 7; @@ -371,28 +334,24 @@ void __cdecl FixL3HallofHeroes() } v4 += 40; --v5; - } - while ( v5 ); + } while (v5); ++v3; - } - while ( v3 < 40 ); + } while (v3 < 40); } void __fastcall DRLG_L3LockRec(int x, int y) { - int v2; // esi - int v3; // edi + int v2; // esi + int v3; // edi char *v4; // eax char *v5; // ebp v2 = x; v3 = y; v4 = &lockout[x][y]; - if ( *v4 ) - { + if (*v4) { v5 = &lockout[x][y]; - do - { + do { *v4 = 0; ++lockoutcnt; DRLG_L3LockRec(v2, v3 - 1); @@ -401,47 +360,39 @@ void __fastcall DRLG_L3LockRec(int x, int y) v5 += 40; ++v2; v4 = v5; - } - while ( *v5 ); + } while (*v5); } } // 528380: using guessed type int lockoutcnt; bool __cdecl DRLG_L3Lockout() { - int v0; // esi + int v0; // esi signed int v1; // edx signed int v2; // ecx signed int v3; // eax - int x; // [esp+4h] [ebp-8h] - int y; // [esp+8h] [ebp-4h] + int x; // [esp+4h] [ebp-8h] + int y; // [esp+8h] [ebp-4h] v0 = 0; v1 = 0; - do - { + do { v2 = 0; v3 = v1; - do - { - if ( dungeon[0][v3] ) - { + do { + if (dungeon[0][v3]) { lockout[0][v3] = 1; x = v2; y = v1; ++v0; - } - else - { + } else { lockout[0][v3] = 0; } ++v2; v3 += 40; - } - while ( v2 < 40 ); + } while (v2 < 40); ++v1; - } - while ( v1 < 40 ); + } while (v1 < 40); lockoutcnt = 0; DRLG_L3LockRec(x, y); return v0 == lockoutcnt; @@ -450,12 +401,12 @@ bool __cdecl DRLG_L3Lockout() void __fastcall CreateL3Dungeon(int rseed, int entry) { - int v2; // esi - int v3; // edi - int v4; // esi - signed int v5; // eax + int v2; // esi + int v3; // edi + int v4; // esi + signed int v5; // eax signed int *v6; // [esp+8h] [ebp-8h] - int (*v7)[112]; // [esp+Ch] [ebp-4h] + int(*v7)[112]; // [esp+Ch] [ebp-4h] v2 = entry; SetRndSeed(rseed); @@ -469,23 +420,19 @@ void __fastcall CreateL3Dungeon(int rseed, int entry) DRLG_L3Pass3(); v3 = 0; v7 = dPiece; - do - { + do { v4 = 0; v6 = (signed int *)v7; - do - { + do { v5 = *v6; - if ( *v6 >= 56 && v5 <= 147 || v5 >= 154 && v5 <= 161 || v5 == 150 || v5 == 152 ) + if (*v6 >= 56 && v5 <= 147 || v5 >= 154 && v5 <= 161 || v5 == 150 || v5 == 152) DoLighting(v4, v3, 7, -1); v6 += 112; ++v4; - } - while ( v4 < 112 ); - v7 = (int (*)[112])((char *)v7 + 4); + } while (v4 < 112); + v7 = (int(*)[112])((char *)v7 + 4); ++v3; - } - while ( (signed int)v7 < (signed int)dPiece[1] ); + } while ((signed int)v7 < (signed int)dPiece[1]); DRLG_SetPC(); } // 5CF328: using guessed type int dmaxx; @@ -495,23 +442,20 @@ void __fastcall CreateL3Dungeon(int rseed, int entry) void __fastcall DRLG_L3(int entry) { - int x1; // esi - int y1; // eax - int x2; // edi - int y2; // eax - int found; // eax - int genok; // eax + int x1; // esi + int y1; // eax + int x2; // edi + int y2; // eax + int found; // eax + int genok; // eax signed int i; // ecx signed int j; // esi - bool v24; // [esp-8h] [ebp-20h] + bool v24; // [esp-8h] [ebp-20h] lavapool = 0; - do - { - do - { - do - { + do { + do { + do { InitL3Dungeon(); x1 = random(0, 20) + 10; y1 = random(0, 20); @@ -521,8 +465,7 @@ void __fastcall DRLG_L3(int entry) DRLG_L3CreateBlock(x1, y1 + 12, 2, 2); DRLG_L3CreateBlock(x1, y1 + 10, 2, 3); - if ( QuestStatus(QTYPE_ANVIL) ) - { + if (QuestStatus(QTYPE_ANVIL)) { x2 = random(0, 10) + 10; y2 = random(0, 10); DRLG_L3FloorArea(x2, y2 + 10, x2 + 12, y2 + 22); @@ -532,65 +475,59 @@ void __fastcall DRLG_L3(int entry) DRLG_L3FillStraights(); DRLG_L3FillDiags(); DRLG_L3Edges(); - if ( DRLG_L3GetFloorArea() < 600 ) + if (DRLG_L3GetFloorArea() < 600) found = 0; else found = DRLG_L3Lockout(); - } - while ( !found ); + } while (!found); DRLG_L3MakeMegas(); - if ( !entry ) - { + if (!entry) { genok = DRLG_L3PlaceMiniSet(L3UP, 1, 1, -1, -1, 1, 0); - if ( genok ) + if (genok) continue; genok = DRLG_L3PlaceMiniSet(L3DOWN, 1, 1, -1, -1, 0, 1); - if ( genok ) + if (genok) continue; - if ( currlevel != 9 ) + if (currlevel != 9) goto LABEL_24; genok = DRLG_L3PlaceMiniSet(L3HOLDWARP, 1, 1, -1, -1, 0, 6); goto LABEL_23; } genok = DRLG_L3PlaceMiniSet(L3UP, 1, 1, -1, -1, 0, 0); - if ( entry == 1 ) - { - if ( genok ) + if (entry == 1) { + if (genok) continue; genok = DRLG_L3PlaceMiniSet(L3DOWN, 1, 1, -1, -1, 1, 1); ViewX += 2; ViewY -= 2; - if ( genok ) + if (genok) continue; - if ( currlevel != 9 ) + if (currlevel != 9) goto LABEL_24; v24 = 0; -LABEL_22: + LABEL_22: genok = DRLG_L3PlaceMiniSet(L3HOLDWARP, 1, 1, -1, -1, v24, 6); -LABEL_23: - if ( genok ) + LABEL_23: + if (genok) continue; goto LABEL_24; } - if ( genok ) + if (genok) continue; genok = DRLG_L3PlaceMiniSet(L3DOWN, 1, 1, -1, -1, 0, 1); - if ( genok ) + if (genok) continue; - if ( currlevel == 9 ) - { + if (currlevel == 9) { v24 = 1; goto LABEL_22; } -LABEL_24: - if ( !QuestStatus(QTYPE_ANVIL) ) + LABEL_24: + if (!QuestStatus(QTYPE_ANVIL)) break; genok = DRLG_L3Anvil(); - } - while ( genok == 1 ); + } while (genok == 1); DRLG_L3Pool(); - } - while ( !lavapool ); + } while (!lavapool); DRLG_L3PoolFix(); FixL3Warp(); DRLG_L3PlaceRndSet(L3ISLE1, 70); @@ -603,13 +540,12 @@ LABEL_24: FixL3HallofHeroes(); DRLG_L3River(); - if ( QuestStatus(QTYPE_ANVIL) ) - { + if (QuestStatus(QTYPE_ANVIL)) { dungeon[setpc_x + 7][setpc_y + 5] = 7; dungeon[setpc_x + 8][setpc_y + 5] = 7; dungeon[setpc_x + 9][setpc_y + 5] = 7; - if ( dungeon[setpc_x + 10][setpc_y + 5] == 17 - || dungeon[setpc_x + 10][setpc_y + 5] == 18 ) + if (dungeon[setpc_x + 10][setpc_y + 5] == 17 + || dungeon[setpc_x + 10][setpc_y + 5] == 18) dungeon[setpc_x + 10][setpc_y + 5] = 45; } @@ -643,9 +579,8 @@ LABEL_24: DRLG_L3PlaceRndSet(L3XTRA4, 25); DRLG_L3PlaceRndSet(L3XTRA5, 25); - for(i = 0; i < 40; i++) - { - for(j = 0; j < 40; j++) + for (i = 0; i < 40; i++) { + for (j = 0; j < 40; j++) pdungeon[i][j] = dungeon[i][j]; } @@ -660,10 +595,8 @@ void __cdecl InitL3Dungeon() memset(dungeon, 0, sizeof(dungeon)); - for(i = 0; i < 40; i++) - { - for(j = 0; j < 40; j++) - { + for (i = 0; i < 40; i++) { + for (j = 0; j < 40; j++) { dungeon[i][j] = 0; dflags[i][j] = 0; } @@ -672,56 +605,49 @@ void __cdecl InitL3Dungeon() int __fastcall DRLG_L3FillRoom(int x1, int y1, int x2, int y2) { - int v4; // esi - int v5; // eax - int v6; // edi - int v7; // edx - int v8; // ecx - char *v9; // ecx - int v10; // eax - int v11; // ebx + int v4; // esi + int v5; // eax + int v6; // edi + int v7; // edx + int v8; // ecx + char *v9; // ecx + int v10; // eax + int v11; // ebx char *v12; // edx - int v13; // eax - int i; // ebx - int v16; // ecx + int v13; // eax + int i; // ebx + int v16; // ecx char *v17; // ebx - int v18; // edi - int v21; // [esp+Ch] [ebp-4h] - int x2a; // [esp+18h] [ebp+8h] - int y2a; // [esp+1Ch] [ebp+Ch] + int v18; // edi + int v21; // [esp+Ch] [ebp-4h] + int x2a; // [esp+18h] [ebp+8h] + int y2a; // [esp+1Ch] [ebp+Ch] v4 = x1; v5 = y1; v21 = y1; - if ( x1 <= 1 ) + if (x1 <= 1) return 0; v6 = x2; - if ( x2 >= 34 || y1 <= 1 || y2 >= 38 ) + if (x2 >= 34 || y1 <= 1 || y2 >= 38) return 0; v7 = 0; v8 = v5; x2a = v5; - if ( v5 <= y2 ) - { - do - { - if ( v4 <= v6 ) - { + if (v5 <= y2) { + do { + if (v4 <= v6) { v9 = &dungeon[v4][v8]; v10 = v6 - v4 + 1; - do - { + do { v7 += (unsigned char)*v9; v9 += 40; --v10; - } - while ( v10 ); + } while (v10); } v8 = x2a++ + 1; - } - while ( x2a <= y2 ); - if ( !v7 ) - { + } while (x2a <= y2); + if (!v7) { v5 = v21; goto LABEL_12; } @@ -729,156 +655,133 @@ int __fastcall DRLG_L3FillRoom(int x1, int y1, int x2, int y2) } LABEL_12: v11 = v5 + 1; - if ( v5 + 1 < y2 ) - { + if (v5 + 1 < y2) { v8 = v4 + 1; - do - { - if ( v8 < v6 ) - { + do { + if (v8 < v6) { v12 = &dungeon[v8][v11]; v13 = v6 - v8; - do - { + do { *v12 = 1; v12 += 40; --v13; - } - while ( v13 ); + } while (v13); } ++v11; - } - while ( v11 < y2 ); + } while (v11 < y2); v5 = v21; } - for ( i = v5; i <= y2; ++i ) - { - if ( random(0, 2) ) + for (i = v5; i <= y2; ++i) { + if (random(0, 2)) dungeon[v4][i] = 1; - if ( random(0, 2) ) + if (random(0, 2)) dungeon[v6][i] = 1; } - if ( v4 <= v6 ) - { + if (v4 <= v6) { v16 = y2; v17 = &dungeon[v4][y2]; v18 = v6 - v4 + 1; y2a = v21 - y2; - do - { - if ( random(0, 2) ) + do { + if (random(0, 2)) v17[y2a] = 1; - if ( random(0, 2) ) + if (random(0, 2)) *v17 = 1; v17 += 40; --v18; - } - while ( v18 ); + } while (v18); } return 1; } void __fastcall DRLG_L3CreateBlock(int x, int y, int obs, int dir) { - int v4; // esi - int v5; // edi - int v6; // eax - int v9; // ebx + int v4; // esi + int v5; // edi + int v6; // eax + int v9; // ebx bool v10; // zf bool v11; // zf - int y2; // [esp+Ch] [ebp-14h] - int x2; // [esp+10h] [ebp-10h] - int i; // [esp+14h] [ebp-Ch] - int v16; // [esp+18h] [ebp-8h] - int max; // [esp+1Ch] [ebp-4h] + int y2; // [esp+Ch] [ebp-14h] + int x2; // [esp+10h] [ebp-10h] + int i; // [esp+14h] [ebp-Ch] + int v16; // [esp+18h] [ebp-8h] + int max; // [esp+1Ch] [ebp-4h] v4 = obs; v5 = obs; v16 = y; - for ( i = x; ; i = v4 ) - { + for (i = x;; i = v4) { v6 = random(0, 2); max = v6 + 3; v9 = random(0, 2) + 3; - if ( !dir ) - { + if (!dir) { y2 = v16 - 1; v5 = v16 - 1 - v9; - if ( max < obs ) - { + if (max < obs) { v4 = i + random(0, max); } - if ( max == obs ) + if (max == obs) v4 = i; - if ( max > obs ) - { + if (max > obs) { v4 = i - random(0, max); } x2 = v4 + max; } - if ( dir == 3 ) - { + if (dir == 3) { x2 = i - 1; v4 = i - 1 - max; v10 = v9 == obs; - if ( v9 < obs ) - { + if (v9 < obs) { v5 = v16 + random(0, v9); v10 = v9 == obs; } - if ( v10 ) + if (v10) v5 = v16; - if ( v9 > obs ) - { + if (v9 > obs) { v5 = v16 - random(0, v9); } y2 = v5 + v9; } - if ( dir == 2 ) - { + if (dir == 2) { v5 = v16 + 1; y2 = v16 + 1 + v9; - if ( max < obs ) - { + if (max < obs) { v4 = i + random(0, max); } - if ( max == obs ) + if (max == obs) v4 = i; - if ( max > obs ) - { + if (max > obs) { v4 = i - random(0, max); } x2 = v4 + max; } - if ( dir == 1 ) - { + if (dir == 1) { v4 = i + 1; v11 = v9 == obs; x2 = i + 1 + max; - if ( v9 < obs ) - { + if (v9 < obs) { v5 = v16 + random(0, v9); v11 = v9 == obs; } - if ( v11 ) + if (v11) v5 = v16; - if ( v9 > obs ) - { + if (v9 > obs) { v5 = v16 - random(0, v9); } y2 = v5 + v9; } - if ( DRLG_L3FillRoom(v4, v5, x2, y2) != 1 ) + if (DRLG_L3FillRoom(v4, v5, x2, y2) != 1) break; - if ( !random(0, 4) ) + if (!random(0, 4)) break; - if ( dir != 2 ) + if (dir != 2) DRLG_L3CreateBlock(v4, v5, v9, 0); - if ( dir != 3 ) + if (dir != 3) DRLG_L3CreateBlock(x2, v5, max, 1); - if ( dir ) + if (dir) DRLG_L3CreateBlock(v4, y2, v9, 2); - if ( dir == 1 ) + if (dir == 1) break; dir = 3; obs = max; @@ -888,23 +791,19 @@ void __fastcall DRLG_L3CreateBlock(int x, int y, int obs, int dir) void __fastcall DRLG_L3FloorArea(int x1, int y1, int x2, int y2) { - int i; // esi + int i; // esi char *v5; // edx - int v6; // eax + int v6; // eax - for ( i = y1; i <= y2; ++i ) - { - if ( x1 <= x2 ) - { + for (i = y1; i <= y2; ++i) { + if (x1 <= x2) { v5 = &dungeon[x1][i]; v6 = x2 - x1 + 1; - do - { + do { *v5 = 1; v5 += 40; --v6; - } - while ( v6 ); + } while (v6); } } } @@ -912,114 +811,101 @@ void __fastcall DRLG_L3FloorArea(int x1, int y1, int x2, int y2) void __cdecl DRLG_L3FillDiags() { signed int v0; // ebx - char *v1; // esi + char *v1; // esi signed int v2; // ebp - int v3; // ecx - int v4; // edi + int v3; // ecx + int v4; // edi v0 = 0; - do - { + do { v1 = &dungeon[1][v0 + 1]; v2 = 39; - do - { + do { v3 = (unsigned char)*v1; v4 = v3 - + 2 * ((unsigned char)*(v1 - 40) + 2 * ((unsigned char)*(v1 - 1) + 2 * (unsigned char)*(v1 - 41))); - if ( v4 == 6 ) - { - if ( !random(0, 2) ) - { + + 2 * ((unsigned char)*(v1 - 40) + 2 * ((unsigned char)*(v1 - 1) + 2 * (unsigned char)*(v1 - 41))); + if (v4 == 6) { + if (!random(0, 2)) { *(v1 - 41) = 1; goto LABEL_11; } *v1 = 1; } - if ( v4 == 9 ) - { - if ( random(0, 2) ) + if (v4 == 9) { + if (random(0, 2)) *(v1 - 40) = 1; else *(v1 - 1) = 1; } -LABEL_11: + LABEL_11: v1 += 40; --v2; - } - while ( v2 ); + } while (v2); ++v0; - } - while ( v0 < 39 ); + } while (v0 < 39); } void __cdecl DRLG_L3FillSingles() { signed int v0; // ecx - char *v1; // eax + char *v1; // eax signed int v2; // edx v0 = 1; - do - { + do { v1 = &dungeon[0][v0 + 39]; v2 = 38; - do - { - if ( !v1[1] - && (unsigned char)*v1 + (unsigned char)v1[40] + (unsigned char)*(v1 - 40) == 3 - && (unsigned char)*(v1 - 39) + (unsigned char)v1[41] == 2 - && (unsigned char)v1[2] + (unsigned char)*(v1 - 38) + (unsigned char)v1[42] == 3 ) - { + do { + if (!v1[1] + && (unsigned char)*v1 + (unsigned char)v1[40] + (unsigned char)*(v1 - 40) == 3 + && (unsigned char)*(v1 - 39) + (unsigned char)v1[41] == 2 + && (unsigned char)v1[2] + (unsigned char)*(v1 - 38) + (unsigned char)v1[42] == 3) { v1[1] = 1; } v1 += 40; --v2; - } - while ( v2 ); + } while (v2); ++v0; - } - while ( v0 < 39 ); + } while (v0 < 39); } void __cdecl DRLG_L3FillStraights() { - int v0; // esi - char *v1; // ecx - signed int v2; // eax - char *v3; // ebx - int v4; // edi - int v5; // ebx - char v6; // al - char *v7; // ecx - signed int v8; // eax - char *v9; // ebx - int v10; // edi - int v11; // ebx - char v12; // al + int v0; // esi + char *v1; // ecx + signed int v2; // eax + char *v3; // ebx + int v4; // edi + int v5; // ebx + char v6; // al + char *v7; // ecx + signed int v8; // eax + char *v9; // ebx + int v10; // edi + int v11; // ebx + char v12; // al signed int v13; // ebx signed int v14; // eax signed int v15; // esi - signed int i; // edi + signed int i; // edi signed int v17; // ebx signed int v18; // eax signed int v19; // esi - signed int j; // edi + signed int j; // edi //int v21; // [esp+Ch] [ebp-14h] - char *v22; // [esp+Ch] [ebp-14h] - char *v23; // [esp+Ch] [ebp-14h] - char *v24; // [esp+10h] [ebp-10h] + char *v22; // [esp+Ch] [ebp-14h] + char *v23; // [esp+Ch] [ebp-14h] + char *v24; // [esp+10h] [ebp-10h] signed int v25; // [esp+14h] [ebp-Ch] signed int v26; // [esp+14h] [ebp-Ch] signed int v27; // [esp+18h] [ebp-8h] signed int v28; // [esp+18h] [ebp-8h] - int v29; // [esp+1Ch] [ebp-4h] - int v30; // [esp+1Ch] [ebp-4h] + int v29; // [esp+1Ch] [ebp-4h] + int v30; // [esp+1Ch] [ebp-4h] v27 = 0; v0 = 0; /* v21 */ - do - { + do { v1 = (char *)v27; v2 = 0; v29 = 0; @@ -1027,37 +913,27 @@ void __cdecl DRLG_L3FillStraights() v4 = 40 * v0; v25 = 0; v22 = &dungeon[0][v27 + 1]; - do - { - if ( *(v3 - 1) || *v3 != 1 ) - { - if ( v2 > 3 ) - { - if ( random(0, 2) ) - { - if ( v0 < v29 ) - { + do { + if (*(v3 - 1) || *v3 != 1) { + if (v2 > 3) { + if (random(0, 2)) { + if (v0 < v29) { v5 = v29 - v0; v24 = (char *)dungeon + v4 + v27; - do - { + do { v6 = random(0, 2); v1 = v24; v24 += 40; --v5; *v1 = v6; - } - while ( v5 ); + } while (v5); v3 = v22; } } } v2 = 0; - } - else - { - if ( !v2 ) - { + } else { + if (!v2) { v0 = v29; v4 = v25; } @@ -1067,14 +943,11 @@ void __cdecl DRLG_L3FillStraights() ++v29; v3 += 40; v22 = v3; - } - while ( v25 < 1480 ); + } while (v25 < 1480); ++v27; - } - while ( v27 < 39 ); + } while (v27 < 39); v28 = 0; - do - { + do { v7 = (char *)v28; v8 = 0; v30 = 0; @@ -1082,37 +955,27 @@ void __cdecl DRLG_L3FillStraights() v26 = 0; v10 = 40 * v0; v23 = &dungeon[0][v28 + 1]; - do - { - if ( *(v9 - 1) != 1 || *v9 ) - { - if ( v8 > 3 ) - { - if ( random(0, 2) ) - { - if ( v0 < v30 ) - { + do { + if (*(v9 - 1) != 1 || *v9) { + if (v8 > 3) { + if (random(0, 2)) { + if (v0 < v30) { v11 = v30 - v0; v24 = &dungeon[0][v10 + 1 + v28]; - do - { + do { v12 = random(0, 2); v7 = v24; v24 += 40; --v11; *v7 = v12; - } - while ( v11 ); + } while (v11); v9 = v23; } } } v8 = 0; - } - else - { - if ( !v8 ) - { + } else { + if (!v8) { v0 = v30; v10 = v26; } @@ -1122,77 +985,55 @@ void __cdecl DRLG_L3FillStraights() ++v30; v9 += 40; v23 = v9; - } - while ( v26 < 1480 ); + } while (v26 < 1480); ++v28; - } - while ( v28 < 39 ); + } while (v28 < 39); v13 = 0; - do - { + do { v14 = 0; v15 = 0; - do - { - if ( dungeon[v13][v15] || dungeon[v13 + 1][v15] != 1 ) - { - if ( v14 > 3 ) - { - if ( random(0, 2) ) - { - for ( i = (signed int)v24; i < v15; ++i ) - { + do { + if (dungeon[v13][v15] || dungeon[v13 + 1][v15] != 1) { + if (v14 > 3) { + if (random(0, 2)) { + for (i = (signed int)v24; i < v15; ++i) { dungeon[v13][i] = random(0, 2); } } } v14 = 0; - } - else - { - if ( !v14 ) + } else { + if (!v14) v24 = (char *)v15; ++v14; } ++v15; - } - while ( v15 < 37 ); + } while (v15 < 37); ++v13; - } - while ( v13 < 39 ); + } while (v13 < 39); v17 = 0; - do - { + do { v18 = 0; v19 = 0; - do - { - if ( dungeon[v17][v19] != 1 || dungeon[v17 + 1][v19] ) - { - if ( v18 > 3 ) - { - if ( random(0, 2) ) - { - for ( j = (signed int)v24; j < v19; ++j ) - { + do { + if (dungeon[v17][v19] != 1 || dungeon[v17 + 1][v19]) { + if (v18 > 3) { + if (random(0, 2)) { + for (j = (signed int)v24; j < v19; ++j) { dungeon[v17 + 1][j] = random(0, 2); } } } v18 = 0; - } - else - { - if ( !v18 ) + } else { + if (!v18) v24 = (char *)v19; ++v18; } ++v19; - } - while ( v19 < 37 ); + } while (v19 < 37); ++v17; - } - while ( v17 < 39 ); + } while (v17 < 39); } void __cdecl DRLG_L3Edges() @@ -1201,25 +1042,22 @@ void __cdecl DRLG_L3Edges() memset(dungeon[39], 0, sizeof(char[40])); v0 = &dungeon[0][39]; - do - { + do { *v0 = 0; v0 += 40; - } - while ( (signed int)v0 < (signed int)&dungeon[40][39] ); + } while ((signed int)v0 < (signed int)&dungeon[40][39]); } int __cdecl DRLG_L3GetFloorArea() { int gfa; // eax - int i; // edx - int j; // esi + int i; // edx + int j; // esi gfa = 0; - for(i = 0; i < 40; i++) - { - for(j = 0; j < 40; j++) + for (i = 0; i < 40; i++) { + for (j = 0; j < 40; j++) gfa += dungeon[i][j]; } @@ -1229,169 +1067,153 @@ int __cdecl DRLG_L3GetFloorArea() void __cdecl DRLG_L3MakeMegas() { signed int v0; // edi - char *v1; // esi + char *v1; // esi signed int v2; // ebp - int v3; // ecx - int v4; // eax - char *v5; // eax + int v3; // ecx + int v4; // eax + char *v5; // eax v0 = 0; - do - { + do { v1 = &dungeon[0][v0 + 1]; v2 = 39; - do - { + do { v3 = (unsigned char)v1[40]; v4 = v3 + 2 * ((unsigned char)*v1 + 2 * ((unsigned char)v1[39] + 2 * (unsigned char)*(v1 - 1))); - if ( v4 == 6 ) - { - if ( !random(0, 2) ) - { + if (v4 == 6) { + if (!random(0, 2)) { v4 = 12; goto LABEL_9; } v4 = 5; } - if ( v4 == 9 ) - { + if (v4 == 9) { v4 = (random(0, 2) != 0) + 13; } -LABEL_9: + LABEL_9: --v2; *(v1 - 1) = L3ConvTbl[v4]; v1 += 40; - } - while ( v2 ); + } while (v2); dungeon[39][v0++] = 8; - } - while ( v0 < 39 ); + } while (v0 < 39); v5 = &dungeon[0][39]; - do - { + do { *v5 = 8; v5 += 40; - } - while ( (signed int)v5 < (signed int)&dungeon[40][39] ); + } while ((signed int)v5 < (signed int)&dungeon[40][39]); } void __cdecl DRLG_L3River() { - signed int v0; // ebx - int v1; // esi - int v2; // edi - char v3; // al - char v4; // al - signed int v5; // edx - int v6; // eax - int v7; // ebx - unsigned char v8; // al - unsigned char v9; // al - int v10; // eax - char *v11; // eax - signed int v12; // eax - int v13; // ecx - bool v14; // zf - int v15; // eax - signed int v16; // eax - int v17; // eax - signed int v18; // eax - signed int v19; // eax - signed int v20; // edi - int v21; // eax - int v22; // eax - int v23; // edx - int v24; // ecx - int v25; // ecx - int v26; // esi - int v27; // ecx - int v28; // edx - int v29; // ecx - int v30; // edx - int v31; // ecx - int v32; // edx - bool v33; // sf + signed int v0; // ebx + int v1; // esi + int v2; // edi + char v3; // al + char v4; // al + signed int v5; // edx + int v6; // eax + int v7; // ebx + unsigned char v8; // al + unsigned char v9; // al + int v10; // eax + char *v11; // eax + signed int v12; // eax + int v13; // ecx + bool v14; // zf + int v15; // eax + signed int v16; // eax + int v17; // eax + signed int v18; // eax + signed int v19; // eax + signed int v20; // edi + int v21; // eax + int v22; // eax + int v23; // edx + int v24; // ecx + int v25; // ecx + int v26; // esi + int v27; // ecx + int v28; // edx + int v29; // ecx + int v30; // edx + int v31; // ecx + int v32; // edx + bool v33; // sf unsigned char v34; // of int river[3][100]; // [esp+Ch] [ebp-4E8h] - int v36; // [esp+4BCh] [ebp-38h] - int v37; // [esp+4C0h] [ebp-34h] - int v38; // [esp+4C4h] [ebp-30h] - int v39; // [esp+4C8h] [ebp-2Ch] - int v40; // [esp+4CCh] [ebp-28h] - int v41; // [esp+4D0h] [ebp-24h] - int v42; // [esp+4D4h] [ebp-20h] - int v43; // [esp+4D8h] [ebp-1Ch] - int v44; // [esp+4DCh] [ebp-18h] - int v45; // [esp+4E0h] [ebp-14h] - int v46; // [esp+4E4h] [ebp-10h] - int v47; // [esp+4E8h] [ebp-Ch] - int v48; // [esp+4ECh] [ebp-8h] - int max; // [esp+4F0h] [ebp-4h] + int v36; // [esp+4BCh] [ebp-38h] + int v37; // [esp+4C0h] [ebp-34h] + int v38; // [esp+4C4h] [ebp-30h] + int v39; // [esp+4C8h] [ebp-2Ch] + int v40; // [esp+4CCh] [ebp-28h] + int v41; // [esp+4D0h] [ebp-24h] + int v42; // [esp+4D4h] [ebp-20h] + int v43; // [esp+4D8h] [ebp-1Ch] + int v44; // [esp+4DCh] [ebp-18h] + int v45; // [esp+4E0h] [ebp-14h] + int v46; // [esp+4E4h] [ebp-10h] + int v47; // [esp+4E8h] [ebp-Ch] + int v48; // [esp+4ECh] [ebp-8h] + int max; // [esp+4F0h] [ebp-4h] v0 = 0; v39 = 0; v41 = 0; - while ( v39 < 4 ) - { + while (v39 < 4) { v47 = 0; - do - { - if ( v41 >= 200 ) - { + do { + if (v41 >= 200) { v5 = max; break; } ++v41; v1 = 0; v2 = 0; - while ( 1 ) - { + while (1) { v3 = dungeon[v1][v2]; - if ( (unsigned char)v3 >= 0x19u && (unsigned char)v3 <= 0x1Cu ) + if ((unsigned char)v3 >= 0x19u && (unsigned char)v3 <= 0x1Cu) break; - if ( v0 >= 100 ) + if (v0 >= 100) return; v1 = random(0, 40); v2 = random(0, 40); ++v0; - while ( 1 ) - { + while (1) { v4 = dungeon[v1][v2]; - if ( (unsigned char)v4 >= 0x19u && (unsigned char)v4 <= 0x1Cu ) + if ((unsigned char)v4 >= 0x19u && (unsigned char)v4 <= 0x1Cu) break; - if ( v2 >= 40 ) + if (v2 >= 40) break; - if ( ++v1 >= 40 ) - { + if (++v1 >= 40) { v1 = 0; ++v2; } } } - if ( v0 >= 100 ) + if (v0 >= 100) return; - switch ( dungeon[v1][v2] ) - { - case 0x19: - v48 = 3; - v42 = 2; - river[2][0] = 40; - break; - case 0x1A: - v48 = 0; - v42 = 1; - river[2][0] = 38; - break; - case 0x1B: - v42 = 0; - v48 = 1; - river[2][0] = 41; - break; - case 0x1C: - v48 = 2; - v42 = 3; - river[2][0] = 39; - break; + switch (dungeon[v1][v2]) { + case 0x19: + v48 = 3; + v42 = 2; + river[2][0] = 40; + break; + case 0x1A: + v48 = 0; + v42 = 1; + river[2][0] = 38; + break; + case 0x1B: + v42 = 0; + v48 = 1; + river[2][0] = 41; + break; + case 0x1C: + v48 = 2; + v42 = 3; + river[2][0] = 39; + break; } v43 = 0; max = 1; @@ -1400,68 +1222,56 @@ void __cdecl DRLG_L3River() river[1][0] = v2; v46 = 4; v45 = 40 * v1; - while ( v5 < 100 ) - { + while (v5 < 100) { v38 = v1; v36 = v45; v37 = v2; - if ( v43 ) - { + if (v43) { v48 = ((_BYTE)v48 + 1) & 3; v7 = v48; - } - else - { + } else { v6 = random(0, 4); v5 = max; v7 = v6; v48 = v6; } - while ( 1 ) - { + while (1) { ++v43; - if ( v7 != v42 && v7 != v46 ) + if (v7 != v42 && v7 != v46) break; v7 = ((_BYTE)v7 + 1) & 3; } v48 = v7; - if ( !v7 ) - { - if ( v2 <= 0 ) + if (!v7) { + if (v2 <= 0) goto LABEL_44; --v2; } - if ( v7 == 1 ) - { - if ( v2 >= 40 ) + if (v7 == 1) { + if (v2 >= 40) goto LABEL_44; ++v2; } - if ( v7 != 2 ) + if (v7 != 2) goto LABEL_41; - if ( v1 < 40 ) - { + if (v1 < 40) { ++v1; v45 += 40; -LABEL_41: - if ( v7 == 3 && v1 > 0 ) - { + LABEL_41: + if (v7 == 3 && v1 > 0) { --v1; v45 -= 40; } } -LABEL_44: - if ( dungeon[0][v45 + v2] == 7 ) - { + LABEL_44: + if (dungeon[0][v45 + v2] == 7) { v43 = 0; - if ( v7 < 2 ) - { + if (v7 < 2) { v8 = random(0, 2); v5 = max; river[2][max] = v8 + 17; } - if ( v7 > 1 ) - { + if (v7 > 1) { v9 = random(0, 2); v5 = max; river[2][max] = v9 + 15; @@ -1470,239 +1280,211 @@ LABEL_44: river[0][v5] = v1; river[1][v5++] = v2; max = v5; - if ( v7 || v10 != 2 ) - { - if ( v7 != 3 ) + if (v7 || v10 != 2) { + if (v7 != 3) goto LABEL_58; - if ( v10 != 1 ) + if (v10 != 1) goto LABEL_70; } - if ( v5 > 2 ) + if (v5 > 2) river[1][v5 + 98] = 22; - if ( !v7 ) - { + if (!v7) { v46 = 1; -LABEL_59: - if ( v10 == 3 ) + LABEL_59: + if (v10 == 3) goto LABEL_62; goto LABEL_60; } v46 = 2; -LABEL_58: - if ( !v7 ) + LABEL_58: + if (!v7) goto LABEL_59; -LABEL_60: - if ( v7 != 2 ) + LABEL_60: + if (v7 != 2) goto LABEL_67; - if ( v10 != 1 ) + if (v10 != 1) goto LABEL_79; -LABEL_62: - if ( v5 > 2 ) + LABEL_62: + if (v5 > 2) river[1][v5 + 98] = 21; - if ( !v7 ) - { + if (!v7) { v46 = 1; goto LABEL_83; } v46 = 3; -LABEL_67: - if ( v7 != 1 || v10 != 2 ) - { - if ( v7 != 3 ) + LABEL_67: + if (v7 != 1 || v10 != 2) { + if (v7 != 3) goto LABEL_76; -LABEL_70: - if ( v10 ) + LABEL_70: + if (v10) goto LABEL_83; } - if ( v5 > 2 ) + if (v5 > 2) river[1][v5 + 98] = 20; - if ( v7 == 1 ) - { + if (v7 == 1) { v46 = 0; goto LABEL_77; } v46 = 2; -LABEL_76: - if ( v7 != 1 ) + LABEL_76: + if (v7 != 1) goto LABEL_78; -LABEL_77: - if ( v10 != 3 ) - { -LABEL_78: - if ( v7 != 2 ) + LABEL_77: + if (v10 != 3) { + LABEL_78: + if (v7 != 2) goto LABEL_83; -LABEL_79: - if ( v10 ) + LABEL_79: + if (v10) goto LABEL_83; } - if ( v5 > 2 ) + if (v5 > 2) river[1][v5 + 98] = 19; v46 = v7 != 1 ? 3 : 0; -LABEL_83: + LABEL_83: v40 = v7; - } - else - { + } else { v1 = v38; v2 = v37; v45 = v36; - if ( v43 >= 4 ) + if (v43 >= 4) break; } } - if ( v48 ) - { + if (v48) { v13 = v40; goto LABEL_94; } v11 = &dungeon[v1][v2]; - if ( *(v11 - 1) == 10 && *(v11 - 2) == 8 ) - { + if (*(v11 - 1) == 10 && *(v11 - 2) == 8) { v12 = v5; river[1][v12] = v2 - 1; v13 = v40; v14 = v40 == 2; river[0][v12] = v1; river[2][v12] = 24; - if ( v14 ) + if (v14) river[1][v12 + 99] = 22; - if ( v13 == 3 ) + if (v13 == 3) river[1][v12 + 99] = 21; v47 = 1; -LABEL_94: - if ( v48 == 1 ) - { + LABEL_94: + if (v48 == 1) { v15 = v2 + 40 * v1; - if ( dungeon[0][v15 + 1] == 2 && dungeon[0][v15 + 2] == 8 ) - { + if (dungeon[0][v15 + 1] == 2 && dungeon[0][v15 + 2] == 8) { v16 = v5; river[0][v16] = v1; river[1][v16] = v2 + 1; river[2][v16] = 42; - if ( v13 == 2 ) + if (v13 == 2) river[1][v16 + 99] = 20; - if ( v13 == 3 ) + if (v13 == 3) river[1][v16 + 99] = 19; v47 = 1; goto LABEL_102; } - } - else - { -LABEL_102: - if ( v48 == 2 ) - { + } else { + LABEL_102: + if (v48 == 2) { v17 = v2 + 40 * v1; - if ( dungeon[1][v17] != 4 || dungeon[2][v17] != 8 ) + if (dungeon[1][v17] != 4 || dungeon[2][v17] != 8) goto LABEL_118; v18 = v5; river[0][v18] = v1 + 1; river[1][v18] = v2; river[2][v18] = 43; - if ( !v13 ) + if (!v13) river[1][v18 + 99] = 19; - if ( v13 == 1 ) + if (v13 == 1) river[1][v18 + 99] = 21; v47 = 1; } - if ( v48 == 3 - && dungeon[v1-1][v2] == 9 // *((_BYTE *)&dMonster[111][10 * v1 + 102] + v2) == 9 /* check */ - && dungeon[0][8 * (5 * v1 - 10) + v2] == 8 ) - { + if (v48 == 3 + && dungeon[v1 - 1][v2] == 9 // *((_BYTE *)&dMonster[111][10 * v1 + 102] + v2) == 9 /* check */ + && dungeon[0][8 * (5 * v1 - 10) + v2] == 8) { v19 = v5; river[0][v19] = v1 - 1; river[1][v19] = v2; river[2][v19] = 23; - if ( !v13 ) + if (!v13) river[1][v19 + 99] = 20; - if ( v13 == 1 ) + if (v13 == 1) river[1][v19 + 99] = 22; v47 = 1; } } } -LABEL_118: + LABEL_118: v0 = 0; - } - while ( !v47 ); - if ( v47 == 1 && v5 >= 7 ) - { + } while (!v47); + if (v47 == 1 && v5 >= 7) { v20 = 0; v47 = 0; -LABEL_124: - while ( v47 < 30 ) - { + LABEL_124: + while (v47 < 30) { ++v47; v21 = random(0, max); v44 = v21; v22 = v21; v23 = river[2][v22]; - if ( v23 == 15 || v23 == 16 ) - { + if (v23 == 15 || v23 == 16) { v24 = river[1][v22] + 40 * river[0][v22]; - if ( dungeon[0][v24 - 1] == 7 && dungeon[0][v24 + 1] == 7 ) /* *((_BYTE *)&dMonster[111][111] + v24 + 3) check */ + if (dungeon[0][v24 - 1] == 7 && dungeon[0][v24 + 1] == 7) /* *((_BYTE *)&dMonster[111][111] + v24 + 3) check */ v20 = 1; } - if ( v23 == 17 || v23 == 18 ) - { + if (v23 == 17 || v23 == 18) { v25 = river[1][v22] + 40 * river[0][v22]; - if ( dungeon[-1][v25] == 7 && dungeon[1][v25] == 7 ) /* *((_BYTE *)&dMonster[111][102] + v25) check */ + if (dungeon[-1][v25] == 7 && dungeon[1][v25] == 7) /* *((_BYTE *)&dMonster[111][102] + v25) check */ v20 = 2; } v26 = 0; - if ( max > 0 ) - { - while ( 1 ) - { - if ( !v20 ) + if (max > 0) { + while (1) { + if (!v20) goto LABEL_124; - if ( v20 != 1 ) + if (v20 != 1) goto LABEL_142; v27 = river[1][v22]; v28 = river[1][v26]; - if ( (v27 - 1 == v28 || v27 + 1 == v28) && river[0][v22] == river[0][v26] ) + if ((v27 - 1 == v28 || v27 + 1 == v28) && river[0][v22] == river[0][v26]) break; -LABEL_147: - if ( ++v26 >= max ) + LABEL_147: + if (++v26 >= max) goto LABEL_148; } v20 = 0; -LABEL_142: - if ( v20 == 2 ) - { + LABEL_142: + if (v20 == 2) { v29 = river[0][v22]; v30 = river[0][v26]; - if ( (v29 - 1 == v30 || v29 + 1 == v30) && river[1][v22] == river[1][v26] ) + if ((v29 - 1 == v30 || v29 + 1 == v30) && river[1][v22] == river[1][v26]) v20 = 0; } goto LABEL_147; } -LABEL_148: - if ( v20 ) + LABEL_148: + if (v20) break; } v0 = 0; - if ( v20 ) - { + if (v20) { river[2][v44] = v20 == 1 ? 44 : 45; v31 = max; ++v39; v44 = 0; - if ( max >= 0 ) - { - do - { + if (max >= 0) { + do { v32 = v44++; v34 = __OFSUB__(v44, v31); v14 = v44 == v31; v33 = v44 - v31 < 0; dungeon[river[0][v32]][river[1][v32]] = river[2][v32]; - } - while ( (unsigned char)(v33 ^ v34) | v14 ); + } while ((unsigned char)(v33 ^ v34) | v14); } } } - if ( v41 >= 200 ) + if (v41 >= 200) return; } } @@ -1712,39 +1494,36 @@ LABEL_148: void __cdecl DRLG_L3Pool() { - int v0; // ebx - _BYTE *v1; // ecx - int v2; // esi - int v3; // ecx - signed int v4; // eax - signed int v5; // eax - signed int v6; // eax - int v7; // eax - int v8; // edi - int v9; // ecx - int v10; // eax - int v11; // esi - char *v12; // edx + int v0; // ebx + _BYTE *v1; // ecx + int v2; // esi + int v3; // ecx + signed int v4; // eax + signed int v5; // eax + signed int v6; // eax + int v7; // eax + int v8; // edi + int v9; // ecx + int v10; // eax + int v11; // esi + char *v12; // edx unsigned char v13; // al unsigned char v14; // al - signed int v15; // [esp+Ch] [ebp-18h] - char *v16; // [esp+10h] [ebp-14h] - signed int v17; // [esp+14h] [ebp-10h] - int v18; // [esp+18h] [ebp-Ch] - int totarea; // [esp+1Ch] [ebp-8h] - int x; // [esp+20h] [ebp-4h] + signed int v15; // [esp+Ch] [ebp-18h] + char *v16; // [esp+10h] [ebp-14h] + signed int v17; // [esp+14h] [ebp-10h] + int v18; // [esp+18h] [ebp-Ch] + int totarea; // [esp+1Ch] [ebp-8h] + int x; // [esp+20h] [ebp-4h] v0 = 0; v18 = 0; - do - { + do { x = 0; v1 = (unsigned char *)dungeon + v0; v16 = (char *)dungeon + v0; - do - { - if ( *v1 == 8 ) - { + do { + if (*v1 == 8) { *v1 = -120; v2 = x - 1; totarea = 1; @@ -1757,30 +1536,22 @@ void __cdecl DRLG_L3Pool() v8 = totarea; v15 = v7; v9 = v0 - totarea; - if ( v0 - totarea < totarea + v0 ) - { + if (v0 - totarea < totarea + v0) { totarea = x - totarea; v10 = v8 + x; - do - { + do { v11 = totarea; - if ( totarea < v10 ) - { + if (totarea < v10) { v12 = &dungeon[totarea][v9]; - do - { - if ( *v12 < 0 && v9 >= 0 && v9 < 40 && v11 >= 0 && v11 < 40 ) - { + do { + if (*v12 < 0 && v9 >= 0 && v9 < 40 && v11 >= 0 && v11 < 40) { v13 = *v12 & 0x7F; *v12 = v13; - if ( v8 > 4 ) - { - if ( v15 < 25 && !v17 ) - { + if (v8 > 4) { + if (v15 < 25 && !v17) { v14 = L3PoolSub[v13]; - if ( v14 ) - { - if ( v14 <= 0x25u ) + if (v14) { + if (v14 <= 0x25u) *v12 = v14; } lavapool = 1; @@ -1791,84 +1562,72 @@ void __cdecl DRLG_L3Pool() ++v11; v10 = v8 + x; v12 += 40; - } - while ( v11 < v8 + x ); + } while (v11 < v8 + x); } ++v9; - } - while ( v9 < v8 + v0 ); + } while (v9 < v8 + v0); } } ++x; v1 = (unsigned char *)v16 + 40; v16 += 40; - } - while ( x < 40 ); + } while (x < 40); v18 = ++v0; - } - while ( v0 < 40 ); + } while (v0 < 40); } // 528378: using guessed type char lavapool; int __fastcall DRLG_L3SpawnEdge(int x, int y, int *totarea) { - int *v3; // ebp - int v4; // edi - int v5; // esi - char *v6; // ecx - int *v7; // eax - int v8; // eax + int *v3; // ebp + int v4; // edi + int v5; // esi + char *v6; // ecx + int *v7; // eax + int v8; // eax int *totareaa; // [esp+14h] [ebp+4h] v3 = totarea; v4 = y; v5 = x; - if ( *totarea <= 40 && x >= 0 && y >= 0 && x < 40 && y < 40 ) - { + if (*totarea <= 40 && x >= 0 && y >= 0 && x < 40 && y < 40) { v6 = &dungeon[x][y]; _LOBYTE(v7) = *v6; - if ( *v6 < 0 ) + if (*v6 < 0) return 0; - if ( (unsigned char)v7 <= 0xFu ) - { + if ((unsigned char)v7 <= 0xFu) { *v6 = (unsigned char)v7 | 0x80; ++*totarea; - if ( (_BYTE)v7 == 8 ) - { - if ( DRLG_L3SpawnEdge(v5 + 1, y, totarea) == 1 - || DRLG_L3SpawnEdge(v5 - 1, v4, totarea) == 1 - || DRLG_L3SpawnEdge(v5, v4 + 1, totarea) == 1 ) - { + if ((_BYTE)v7 == 8) { + if (DRLG_L3SpawnEdge(v5 + 1, y, totarea) == 1 + || DRLG_L3SpawnEdge(v5 - 1, v4, totarea) == 1 + || DRLG_L3SpawnEdge(v5, v4 + 1, totarea) == 1) { return 1; } v8 = DRLG_L3SpawnEdge(v5, v4 - 1, totarea); -LABEL_24: - if ( v8 == 1 ) + LABEL_24: + if (v8 == 1) return 1; return 0; } v7 = (int *)(unsigned char)v7; totareaa = v7; - if ( L3SpawnTbl2[(unsigned char)v7] & 8 ) - { - if ( DRLG_L3Spawn(v5, y - 1, v3) == 1 ) + if (L3SpawnTbl2[(unsigned char)v7] & 8) { + if (DRLG_L3Spawn(v5, y - 1, v3) == 1) return 1; v7 = totareaa; } - if ( L3SpawnTbl2[(_DWORD)v7] & 4 ) - { - if ( DRLG_L3Spawn(v5, v4 + 1, v3) == 1 ) + if (L3SpawnTbl2[(_DWORD)v7] & 4) { + if (DRLG_L3Spawn(v5, v4 + 1, v3) == 1) return 1; v7 = totareaa; } - if ( !(L3SpawnTbl2[(_DWORD)v7] & 2) ) + if (!(L3SpawnTbl2[(_DWORD)v7] & 2)) goto LABEL_18; - if ( DRLG_L3Spawn(v5 + 1, v4, v3) != 1 ) - { + if (DRLG_L3Spawn(v5 + 1, v4, v3) != 1) { v7 = totareaa; -LABEL_18: - if ( L3SpawnTbl2[(_DWORD)v7] & 1 ) - { + LABEL_18: + if (L3SpawnTbl2[(_DWORD)v7] & 1) { v8 = DRLG_L3Spawn(v5 - 1, v4, v3); goto LABEL_24; } @@ -1882,31 +1641,29 @@ LABEL_18: int __fastcall DRLG_L3Spawn(int x, int y, int *totarea) { - int v3; // edi - int v4; // esi - char *v5; // eax + int v3; // edi + int v4; // esi + char *v5; // eax unsigned char v6; // cl - int v7; // ebx - int result; // eax + int v7; // ebx + int result; // eax v3 = y; v4 = x; result = 1; - if ( *totarea <= 40 && x >= 0 && y >= 0 && x < 40 && y < 40 ) - { + if (*totarea <= 40 && x >= 0 && y >= 0 && x < 40 && y < 40) { v5 = &dungeon[x][y]; v6 = *v5; - if ( *v5 < 0 - || v6 <= 0xFu - && ((v7 = v6, *v5 = v6 | 0x80, ++*totarea, !(L3SpawnTbl1[v6] & 8)) || DRLG_L3Spawn(v4, y - 1, totarea) != 1) - && (!(L3SpawnTbl1[v7] & 4) || DRLG_L3Spawn(v4, v3 + 1, totarea) != 1) - && (!(L3SpawnTbl1[v7] & 2) || DRLG_L3Spawn(v4 + 1, v3, totarea) != 1) - && (!(L3SpawnTbl1[v7] & 1) || DRLG_L3Spawn(v4 - 1, v3, totarea) != 1) - && ((L3SpawnTbl1[v7] & 0x80u) == 0 || DRLG_L3SpawnEdge(v4, v3 - 1, totarea) != 1) - && (!(L3SpawnTbl1[v7] & 0x40) || DRLG_L3SpawnEdge(v4, v3 + 1, totarea) != 1) - && (!(L3SpawnTbl1[v7] & 0x20) || DRLG_L3SpawnEdge(v4 + 1, v3, totarea) != 1) - && (!(L3SpawnTbl1[v7] & 0x10) || DRLG_L3SpawnEdge(v4 - 1, v3, totarea) != 1) ) - { + if (*v5 < 0 + || v6 <= 0xFu + && ((v7 = v6, *v5 = v6 | 0x80, ++*totarea, !(L3SpawnTbl1[v6] & 8)) || DRLG_L3Spawn(v4, y - 1, totarea) != 1) + && (!(L3SpawnTbl1[v7] & 4) || DRLG_L3Spawn(v4, v3 + 1, totarea) != 1) + && (!(L3SpawnTbl1[v7] & 2) || DRLG_L3Spawn(v4 + 1, v3, totarea) != 1) + && (!(L3SpawnTbl1[v7] & 1) || DRLG_L3Spawn(v4 - 1, v3, totarea) != 1) + && ((L3SpawnTbl1[v7] & 0x80u) == 0 || DRLG_L3SpawnEdge(v4, v3 - 1, totarea) != 1) + && (!(L3SpawnTbl1[v7] & 0x40) || DRLG_L3SpawnEdge(v4, v3 + 1, totarea) != 1) + && (!(L3SpawnTbl1[v7] & 0x20) || DRLG_L3SpawnEdge(v4 + 1, v3, totarea) != 1) + && (!(L3SpawnTbl1[v7] & 0x10) || DRLG_L3SpawnEdge(v4 - 1, v3, totarea) != 1)) { result = 0; } } @@ -1915,49 +1672,40 @@ int __fastcall DRLG_L3Spawn(int x, int y, int *totarea) void __cdecl DRLG_L3PoolFix() { - signed int v0; // esi - char *v1; // eax - char *v2; // edi + signed int v0; // esi + char *v1; // eax + char *v2; // edi unsigned char v3; // cl - char v4; // cl - char v5; // cl - char v6; // cl - char v7; // cl - char v8; // cl - char v9; // al - bool v10; // zf - signed int v11; // [esp+10h] [ebp-4h] + char v4; // cl + char v5; // cl + char v6; // cl + char v7; // cl + char v8; // cl + char v9; // al + bool v10; // zf + signed int v11; // [esp+10h] [ebp-4h] v0 = 0; - do - { + do { v1 = &dungeon[-1][v0]; v11 = 40; - do - { + do { v2 = v1 + 40; - if ( v1[40] == 8 ) - { + if (v1[40] == 8) { v3 = *(v1 - 1); - if ( v3 >= 0x19u && v3 <= 0x29u && (unsigned char)*v1 >= 0x19u && (unsigned char)*v1 <= 0x29u ) - { + if (v3 >= 0x19u && v3 <= 0x29u && (unsigned char)*v1 >= 0x19u && (unsigned char)*v1 <= 0x29u) { v4 = v1[1]; - if ( (unsigned char)v4 >= 0x19u && (unsigned char)v4 <= 0x29u ) - { + if ((unsigned char)v4 >= 0x19u && (unsigned char)v4 <= 0x29u) { v5 = v1[39]; - if ( (unsigned char)v5 >= 0x19u && (unsigned char)v5 <= 0x29u ) - { + if ((unsigned char)v5 >= 0x19u && (unsigned char)v5 <= 0x29u) { v6 = v1[41]; - if ( (unsigned char)v6 >= 0x19u && (unsigned char)v6 <= 0x29u ) - { + if ((unsigned char)v6 >= 0x19u && (unsigned char)v6 <= 0x29u) { v7 = v1[79]; - if ( (unsigned char)v7 >= 0x19u && (unsigned char)v7 <= 0x29u ) - { + if ((unsigned char)v7 >= 0x19u && (unsigned char)v7 <= 0x29u) { v8 = v1[80]; - if ( (unsigned char)v8 >= 0x19u && (unsigned char)v8 <= 0x29u ) - { + if ((unsigned char)v8 >= 0x19u && (unsigned char)v8 <= 0x29u) { v9 = v1[81]; - if ( (unsigned char)v9 >= 0x19u && (unsigned char)v9 <= 0x29u ) + if ((unsigned char)v9 >= 0x19u && (unsigned char)v9 <= 0x29u) *v2 = 33; } } @@ -1968,39 +1716,37 @@ void __cdecl DRLG_L3PoolFix() } v10 = v11-- == 1; v1 = v2; - } - while ( !v10 ); + } while (!v10); ++v0; - } - while ( v0 < 40 ); + } while (v0 < 40); } int __fastcall DRLG_L3PlaceMiniSet(const unsigned char *miniset, int tmin, int tmax, int cx, int cy, bool setview, int ldir) { - int v7; // ebx - int v8; // esi - int v9; // edi - int v10; // edx - int v11; // esi - signed int v12; // ebx - int v13; // edi - signed int i; // eax - int v15; // ecx - unsigned char v16; // dl - int v17; // eax - int v18; // ecx - int v19; // edi - char *v20; // edx - char v21; // bl + int v7; // ebx + int v8; // esi + int v9; // edi + int v10; // edx + int v11; // esi + signed int v12; // ebx + int v13; // edi + signed int i; // eax + int v15; // ecx + unsigned char v16; // dl + int v17; // eax + int v18; // ecx + int v19; // edi + char *v20; // edx + char v21; // bl const unsigned char *v23; // [esp+Ch] [ebp-24h] - int v24; // [esp+10h] [ebp-20h] - int v25; // [esp+14h] [ebp-1Ch] - int v26; // [esp+18h] [ebp-18h] - signed int v27; // [esp+1Ch] [ebp-14h] - int v28; // [esp+20h] [ebp-10h] - int v29; // [esp+24h] [ebp-Ch] - int v30; // [esp+28h] [ebp-8h] - int max; // [esp+2Ch] [ebp-4h] + int v24; // [esp+10h] [ebp-20h] + int v25; // [esp+14h] [ebp-1Ch] + int v26; // [esp+18h] [ebp-18h] + signed int v27; // [esp+1Ch] [ebp-14h] + int v28; // [esp+20h] [ebp-10h] + int v29; // [esp+24h] [ebp-Ch] + int v30; // [esp+28h] [ebp-8h] + int max; // [esp+2Ch] [ebp-4h] v7 = miniset[1]; v8 = tmin; @@ -2009,114 +1755,93 @@ int __fastcall DRLG_L3PlaceMiniSet(const unsigned char *miniset, int tmin, int t v10 = tmax - tmin; v28 = *miniset; v29 = miniset[1]; - if ( v10 ) + if (v10) v24 = v8 + random(0, v10); else v24 = 1; v25 = 0; - if ( v24 <= 0 ) - { + if (v24 <= 0) { v11 = tmax; - } - else - { + } else { max = 40 - v9; v30 = 40 - v7; - do - { + do { v11 = random(0, max); v27 = 0; tmax = random(0, v30); - while ( 1 ) - { - if ( v27 >= 200 ) + while (1) { + if (v27 >= 200) return 1; ++v27; v12 = 1; - if ( cx != -1 && v11 >= cx - v28 && v11 <= cx + 12 ) - { + if (cx != -1 && v11 >= cx - v28 && v11 <= cx + 12) { v11 = random(0, max); tmax = random(0, v30); v12 = 0; } - if ( cy != -1 && tmax >= cy - v29 && tmax <= cy + 12 ) - { + if (cy != -1 && tmax >= cy - v29 && tmax <= cy + 12) { v11 = random(0, max); tmax = random(0, v30); v12 = 0; } v13 = 0; - for ( i = 2; v13 < v29; ++v13 ) - { - if ( v12 != 1 ) + for (i = 2; v13 < v29; ++v13) { + if (v12 != 1) break; v26 = 0; - if ( v28 > 0 ) - { + if (v28 > 0) { v15 = tmax + v13 + 40 * v11; - do - { - if ( v12 != 1 ) + do { + if (v12 != 1) break; v16 = v23[i]; - if ( v16 && dungeon[0][v15] != v16 ) + if (v16 && dungeon[0][v15] != v16) v12 = 0; - if ( dflags[0][v15] ) + if (dflags[0][v15]) v12 = 0; ++i; ++v26; v15 += 40; - } - while ( v26 < v28 ); + } while (v26 < v28); } } v17 = 0; - if ( v12 ) + if (v12) break; - if ( ++v11 == max ) - { + if (++v11 == max) { v11 = 0; - if ( ++tmax == v30 ) + if (++tmax == v30) tmax = 0; } } - if ( v27 >= 200 ) + if (v27 >= 200) return 1; v18 = v28 * v29 + 2; - if ( v29 > 0 ) - { - do - { + if (v29 > 0) { + do { v19 = v28; - if ( v28 > 0 ) - { + if (v28 > 0) { v20 = &dungeon[v11][v17 + tmax]; - do - { + do { v21 = v23[v18]; - if ( v21 ) + if (v21) *v20 = v21; ++v18; v20 += 40; --v19; - } - while ( v19 ); + } while (v19); } ++v17; - } - while ( v17 < v29 ); + } while (v17 < v29); } ++v25; - } - while ( v25 < v24 ); + } while (v25 < v24); } - if ( setview == 1 ) - { + if (setview == 1) { ViewX = 2 * v11 + 17; ViewY = 2 * tmax + 19; } - if ( !ldir ) - { + if (!ldir) { LvlViewX = 2 * v11 + 17; LvlViewY = 2 * tmax + 19; } @@ -2128,33 +1853,33 @@ int __fastcall DRLG_L3PlaceMiniSet(const unsigned char *miniset, int tmin, int t void __fastcall DRLG_L3PlaceRndSet(const unsigned char *miniset, int rndper) { const unsigned char *v2; // ebx - int v3; // ecx - int v4; // eax - char *v5; // ecx - int v6; // esi - signed int i; // edx - int v8; // edi - int v9; // eax - unsigned char v10; // cl - int v11; // edi - unsigned char v12; // al - char v13; // al - int j; // edx - int v15; // esi - unsigned char *v16; // eax - unsigned char v17; // cl - bool v18; // zf - int v19; // [esp+8h] [ebp-30h] - int v20; // [esp+10h] [ebp-28h] - char *v21; // [esp+14h] [ebp-24h] - int v22; // [esp+18h] [ebp-20h] - int v23; // [esp+1Ch] [ebp-1Ch] - int v24; // [esp+20h] [ebp-18h] - int v25; // [esp+24h] [ebp-14h] - int v26; // [esp+28h] [ebp-10h] - int v27; // [esp+2Ch] [ebp-Ch] - int v28; // [esp+30h] [ebp-8h] - signed int v29; // [esp+34h] [ebp-4h] + int v3; // ecx + int v4; // eax + char *v5; // ecx + int v6; // esi + signed int i; // edx + int v8; // edi + int v9; // eax + unsigned char v10; // cl + int v11; // edi + unsigned char v12; // al + char v13; // al + int j; // edx + int v15; // esi + unsigned char *v16; // eax + unsigned char v17; // cl + bool v18; // zf + int v19; // [esp+8h] [ebp-30h] + int v20; // [esp+10h] [ebp-28h] + char *v21; // [esp+14h] [ebp-24h] + int v22; // [esp+18h] [ebp-20h] + int v23; // [esp+1Ch] [ebp-1Ch] + int v24; // [esp+20h] [ebp-18h] + int v25; // [esp+24h] [ebp-14h] + int v26; // [esp+28h] [ebp-10h] + int v27; // [esp+2Ch] [ebp-Ch] + int v28; // [esp+30h] [ebp-8h] + signed int v29; // [esp+34h] [ebp-4h] v2 = miniset; v19 = rndper; @@ -2164,94 +1889,81 @@ void __fastcall DRLG_L3PlaceRndSet(const unsigned char *miniset, int rndper) v27 = *v2; v28 = v3; v24 = 0; - if ( 40 - v3 > 0 ) - { + if (40 - v3 > 0) { v22 = 40 - *v2; v21 = dungeon[-1]; - while ( v22 <= 0 ) - { -LABEL_44: + while (v22 <= 0) { + LABEL_44: v4 = v24++ + 1; - if ( v24 >= v23 ) + if (v24 >= v23) return; } v26 = 0; v20 = v22; v5 = &v21[v4]; v25 = (int)&v21[v4]; - while ( 1 ) - { + while (1) { v6 = 0; v29 = 1; - for ( i = 2; v6 < v28; ++v6 ) - { - if ( v29 != 1 ) + for (i = 2; v6 < v28; ++v6) { + if (v29 != 1) break; v8 = 0; - if ( v27 > 0 ) - { + if (v27 > 0) { v9 = v24 + v6 + v26; - do - { - if ( v29 != 1 ) + do { + if (v29 != 1) break; v10 = v2[i]; - if ( v10 && dungeon[0][v9] != v10 ) + if (v10 && dungeon[0][v9] != v10) v29 = 0; - if ( dflags[0][v9] ) + if (dflags[0][v9]) v29 = 0; ++i; ++v8; v9 += 40; - } - while ( v8 < v27 ); + } while (v8 < v27); v5 = (char *)v25; } } v11 = v27 * v28 + 2; v12 = v2[v11]; - if ( v12 < 0x54u || v12 > 0x64u ) + if (v12 < 0x54u || v12 > 0x64u) goto LABEL_33; - if ( v29 == 1 ) + if (v29 == 1) break; -LABEL_43: + LABEL_43: v26 += 40; v5 += 40; v18 = v20-- == 1; v25 = (int)v5; - if ( v18 ) + if (v18) goto LABEL_44; } v13 = *v5; - if ( (unsigned char)*v5 >= 0x54u && (unsigned char)v13 <= 0x64u ) + if ((unsigned char)*v5 >= 0x54u && (unsigned char)v13 <= 0x64u) v29 = 0; - if ( (unsigned char)v5[80] >= 0x54u && (unsigned char)v13 <= 0x64u ) + if ((unsigned char)v5[80] >= 0x54u && (unsigned char)v13 <= 0x64u) v29 = 0; - if ( (unsigned char)v5[41] >= 0x54u && (unsigned char)v13 <= 0x64u ) + if ((unsigned char)v5[41] >= 0x54u && (unsigned char)v13 <= 0x64u) v29 = 0; - if ( (unsigned char)v5[39] >= 0x54u && (unsigned char)v13 <= 0x64u ) + if ((unsigned char)v5[39] >= 0x54u && (unsigned char)v13 <= 0x64u) v29 = 0; -LABEL_33: - if ( v29 == 1 ) - { - if ( random(0, 100) < v19 ) - { - for ( j = 0; j < v28; ++j ) - { + LABEL_33: + if (v29 == 1) { + if (random(0, 100) < v19) { + for (j = 0; j < v28; ++j) { v15 = v27; - if ( v27 > 0 ) - { + if (v27 > 0) { v16 = (unsigned char *)dungeon + j + v26 + v24; - do - { + do { v17 = v2[v11]; - if ( v17 ) + if (v17) *v16 = v17; ++v11; v16 += 40; --v15; - } - while ( v15 ); + } while (v15); } } } @@ -2263,113 +1975,99 @@ LABEL_33: void __cdecl DRLG_L3Wood() { - char *v0; // edi - int v1; // edx - _BYTE *v2; // eax - int v3; // edx - _BYTE *v4; // ebx - int v5; // esi - int v6; // esi - int v7; // ebx - int v8; // ebx + char *v0; // edi + int v1; // edx + _BYTE *v2; // eax + int v3; // edx + _BYTE *v4; // ebx + int v5; // esi + int v6; // esi + int v7; // ebx + int v8; // ebx signed int v9; // esi - _BYTE *v10; // eax - int v11; // esi - int v12; // ebx - int v13; // eax - _BYTE *v14; // ecx - int v15; // ecx - int v16; // eax - int v17; // esi - int v18; // esi + _BYTE *v10; // eax + int v11; // esi + int v12; // ebx + int v13; // eax + _BYTE *v14; // ecx + int v15; // ecx + int v16; // eax + int v17; // esi + int v18; // esi //int v19; // eax - int v20; // edi - int v21; // esi - int i; // edx - int v23; // esi - int v24; // edi + int v20; // edi + int v21; // esi + int i; // edx + int v23; // esi + int v24; // edi signed int v25; // ecx - int v26; // ebx - char *v27; // esi - int v28; // ecx - int v29; // edi - int v30; // ecx - int v31; // edi - int v32; // ebx - int v33; // ebx - char *v34; // esi + int v26; // ebx + char *v27; // esi + int v28; // ecx + int v29; // edi + int v30; // ecx + int v31; // edi + int v32; // ebx + int v33; // ebx + char *v34; // esi signed int v35; // ecx - int v36; // [esp+Ch] [ebp-14h] - int v37; // [esp+10h] [ebp-10h] - int v38; // [esp+10h] [ebp-10h] - int v39; // [esp+10h] [ebp-10h] - int v40; // [esp+10h] [ebp-10h] - int v41; // [esp+10h] [ebp-10h] - int x; // [esp+14h] [ebp-Ch] - int xa; // [esp+14h] [ebp-Ch] + int v36; // [esp+Ch] [ebp-14h] + int v37; // [esp+10h] [ebp-10h] + int v38; // [esp+10h] [ebp-10h] + int v39; // [esp+10h] [ebp-10h] + int v40; // [esp+10h] [ebp-10h] + int v41; // [esp+10h] [ebp-10h] + int x; // [esp+14h] [ebp-Ch] + int xa; // [esp+14h] [ebp-Ch] signed int v44; // [esp+18h] [ebp-8h] signed int v45; // [esp+18h] [ebp-8h] - int y; // [esp+1Ch] [ebp-4h] - signed int ya; // [esp+1Ch] [ebp-4h] + int y; // [esp+1Ch] [ebp-4h] + signed int ya; // [esp+1Ch] [ebp-4h] y = 0; - do - { + do { x = 0; v44 = 1; v0 = (char *)dungeon + y; - do - { - if ( *v0 == 10 && random(0, 2) ) - { + do { + if (*v0 == 10 && random(0, 2)) { v1 = v44 - 1; - if ( *v0 == 10 ) - { + if (*v0 == 10) { v2 = (unsigned char *)v0; - do - { + do { v2 += 40; ++v1; - } - while ( *v2 == 10 ); + } while (*v2 == 10); } v3 = v1 - 1; v37 = v3; - if ( v3 - (v44 - 1) > 0 ) - { + if (v3 - (v44 - 1) > 0) { *v0 = 127; - if ( v44 < v3 ) - { + if (v44 < v3) { v4 = (unsigned char *)v0 + 40; v5 = v3 - v44; - do - { + do { *v4 = random(0, 2) != 0 ? 126 : -127; v4 += 40; --v5; - } - while ( v5 ); + } while (v5); } dungeon[v37][y] = -128; } } - if ( *v0 == 9 && random(0, 2) ) - { + if (*v0 == 9 && random(0, 2)) { v6 = y; v7 = y; - if ( *v0 == 9 ) - { + if (*v0 == 9) { do ++v7; - while ( dungeon[x][v7] == 9 ); + while (dungeon[x][v7] == 9); } v8 = v7 - 1; - if ( v8 - y > 0 ) - { + if (v8 - y > 0) { *v0 = 123; - while ( ++v6 < v8 ) - { - if ( random(0, 2) ) + while (++v6 < v8) { + if (random(0, 2)) dungeon[x][v6] = 121; else dungeon[x][v6] = 124; @@ -2377,213 +2075,185 @@ void __cdecl DRLG_L3Wood() dungeon[x][v8] = 122; } } - if ( *v0 == 11 && v0[40] == 10 && v0[1] == 9 && random(0, 2) ) - { + if (*v0 == 11 && v0[40] == 10 && v0[1] == 9 && random(0, 2)) { v9 = v44; *v0 = 125; - if ( v0[40] == 10 ) - { + if (v0[40] == 10) { v10 = (unsigned char *)v0 + 40; - do - { + do { v10 += 40; ++v9; - } - while ( *v10 == 10 ); + } while (*v10 == 10); } v11 = v9 - 1; - if ( v44 < v11 ) - { + if (v44 < v11) { v38 = (int)(v0 + 40); v12 = v11 - v44; - do - { + do { v13 = random(0, 2); v14 = (_BYTE *)v38; v38 += 40; --v12; *v14 = v13 != 0 ? 126 : -127; - } - while ( v12 ); + } while (v12); } v15 = v11; v16 = y + 1; v17 = v16; - for ( dungeon[v15][v16 - 1] = 128; dungeon[x][v17] == 9; ++v17 ) /* check *((_BYTE *)&dMonster[111][2 * v15 + 111] + v16 + 3) */ + for (dungeon[v15][v16 - 1] = 128; dungeon[x][v17] == 9; ++v17) /* check *((_BYTE *)&dMonster[111][2 * v15 + 111] + v16 + 3) */ ; v18 = v17 - 1; v39 = y + 1; - if ( v16 < v18 ) - { - do - { - if ( random(0, 2) ) + if (v16 < v18) { + do { + if (random(0, 2)) dungeon[x][v39] = 121; else dungeon[x][v39] = 124; ++v39; - } - while ( v39 < v18 ); + } while (v39 < v18); } dungeon[x][v18] = 122; } ++v44; ++x; v0 += 40; - } - while ( v44 - 1 < 39 ); + } while (v44 - 1 < 39); ++y; - } - while ( y < 39 ); + } while (y < 39); ya = 0; - do - { + do { xa = 0; v45 = 0; - do - { - if ( dungeon[v45][ya] != 7 ) + do { + if (dungeon[v45][ya] != 7) goto LABEL_112; - if ( random(0, 1) ) + if (random(0, 1)) goto LABEL_112; //_LOBYTE(v19) = SkipThemeRoom(xa, ya); - if ( !SkipThemeRoom(xa, ya) ) + if (!SkipThemeRoom(xa, ya)) goto LABEL_112; v36 = random(0, 2); - if ( !v36 ) - { + if (!v36) { v20 = ya; v21 = ya; - for ( i = ya; WoodVertU(xa, i); i = v21 ) + for (i = ya; WoodVertU(xa, i); i = v21) --v21; v23 = v21 + 1; - while ( WoodVertD(xa, v20) ) + while (WoodVertD(xa, v20)) ++v20; v24 = v20 - 1; v25 = 1; - if ( dungeon[v45][v23] == 7 ) + if (dungeon[v45][v23] == 7) v25 = 0; - if ( dungeon[v45][v24] == 7 ) + if (dungeon[v45][v24] == 7) v25 = 0; - if ( v24 - v23 <= 1 ) + if (v24 - v23 <= 1) goto LABEL_112; - if ( !v25 ) + if (!v25) goto LABEL_112; v40 = random(0, v24 - v23 - 1) + v23 + 1; v26 = v23; - if ( v23 > v24 ) + if (v23 > v24) goto LABEL_112; - do - { - if ( v26 != v40 ) - { + do { + if (v26 != v40) { v27 = &dungeon[v45][v26]; - if ( *v27 == 7 ) + if (*v27 == 7) *v27 = random(0, 2) != 0 ? -121 : -119; - if ( *v27 == 10 ) + if (*v27 == 10) *v27 = -125; - if ( *v27 == 126 ) + if (*v27 == 126) *v27 = -123; - if ( *v27 == -127 ) + if (*v27 == -127) *v27 = -123; - if ( *v27 == 2 ) + if (*v27 == 2) *v27 = -117; - if ( *v27 == -122 ) + if (*v27 == -122) *v27 = -118; - if ( *v27 == -120 ) + if (*v27 == -120) *v27 = -118; } ++v26; - } - while ( v26 <= v24 ); + } while (v26 <= v24); } - if ( v36 == 1 ) - { + if (v36 == 1) { v28 = xa; v29 = xa; - while ( WoodHorizL(v28, ya) ) + while (WoodHorizL(v28, ya)) v28 = --v29; v30 = xa; v31 = v29 + 1; v32 = xa; - while ( WoodHorizR(v30, ya) ) + while (WoodHorizR(v30, ya)) v30 = ++v32; v33 = v32 - 1; v34 = &dungeon[v31][ya]; v35 = 1; - if ( *v34 == 7 ) + if (*v34 == 7) v35 = 0; - if ( dungeon[v33][ya] == 7 ) + if (dungeon[v33][ya] == 7) v35 = 0; - if ( v33 - v31 > 1 && v35 ) - { + if (v33 - v31 > 1 && v35) { v41 = random(0, v33 - v31 - 1) + v31 + 1; - while ( 1 ) - { - if ( v31 > v33 ) + while (1) { + if (v31 > v33) break; - if ( v31 != v41 ) - { - if ( *v34 == 7 ) - { - if ( random(0, 2) ) - { + if (v31 != v41) { + if (*v34 == 7) { + if (random(0, 2)) { *v34 = -122; goto LABEL_110; } *v34 = -120; } - if ( *v34 == 9 ) + if (*v34 == 9) *v34 = -126; - if ( *v34 == 121 ) + if (*v34 == 121) *v34 = -124; - if ( *v34 == 124 ) + if (*v34 == 124) *v34 = -124; - if ( *v34 == 4 ) + if (*v34 == 4) *v34 = -116; - if ( *v34 == -121 ) + if (*v34 == -121) *v34 = -118; - if ( *v34 == -119 ) + if (*v34 == -119) *v34 = -118; } -LABEL_110: + LABEL_110: ++v31; v34 += 40; } } } -LABEL_112: + LABEL_112: ++v45; ++xa; - } - while ( v45 < 40 ); + } while (v45 < 40); ++ya; - } - while ( ya < 40 ); + } while (ya < 40); AddFenceDoors(); FenceDoorFix(); } bool __fastcall WoodVertU(int i, int y) { - int v2; // eax - char v3; // cl - char *v4; // eax + int v2; // eax + char v3; // cl + char *v4; // eax unsigned char v5; // cl - char v6; // al - bool result; // eax + char v6; // al + bool result; // eax v2 = i; v3 = dungeon[i + 1][y]; result = 0; - if ( (unsigned char)v3 > 0x98u || (unsigned char)v3 < 0x82u ) - { + if ((unsigned char)v3 > 0x98u || (unsigned char)v3 < 0x82u) { v4 = &dungeon[v2][y]; v5 = *(v4 - 40); - if ( v5 > 0x98u || v5 < 0x82u ) - { + if (v5 > 0x98u || v5 < 0x82u) { v6 = *v4; - if ( v6 == 7 || v6 == 10 || v6 == 126 || v6 == -127 || v6 == -122 || v6 == -120 ) + if (v6 == 7 || v6 == 10 || v6 == 126 || v6 == -127 || v6 == -122 || v6 == -120) result = 1; } } @@ -2592,24 +2262,22 @@ bool __fastcall WoodVertU(int i, int y) bool __fastcall WoodVertD(int i, int y) { - int v2; // eax - char v3; // cl - char *v4; // eax + int v2; // eax + char v3; // cl + char *v4; // eax unsigned char v5; // cl - char v6; // al - bool result; // eax + char v6; // al + bool result; // eax v2 = i; v3 = dungeon[i + 1][y]; result = 0; - if ( (unsigned char)v3 > 0x98u || (unsigned char)v3 < 0x82u ) - { + if ((unsigned char)v3 > 0x98u || (unsigned char)v3 < 0x82u) { v4 = &dungeon[v2][y]; v5 = *(v4 - 40); - if ( v5 > 0x98u || v5 < 0x82u ) - { + if (v5 > 0x98u || v5 < 0x82u) { v6 = *v4; - if ( v6 == 7 || v6 == 2 || v6 == -122 || v6 == -120 ) + if (v6 == 7 || v6 == 2 || v6 == -122 || v6 == -120) result = 1; } } @@ -2618,24 +2286,22 @@ bool __fastcall WoodVertD(int i, int y) bool __fastcall WoodHorizL(int x, int j) { - int v2; // eax - char v3; // cl - char *v4; // eax + int v2; // eax + char v3; // cl + char *v4; // eax unsigned char v5; // cl - char v6; // al - bool result; // eax + char v6; // al + bool result; // eax v2 = x; v3 = dungeon[x][j + 1]; result = 0; - if ( (unsigned char)v3 > 0x98u || (unsigned char)v3 < 0x82u ) - { + if ((unsigned char)v3 > 0x98u || (unsigned char)v3 < 0x82u) { v4 = &dungeon[v2][j]; v5 = *(v4 - 1); - if ( v5 > 0x98u || v5 < 0x82u ) - { + if (v5 > 0x98u || v5 < 0x82u) { v6 = *v4; - if ( v6 == 7 || v6 == 9 || v6 == 121 || v6 == 124 || v6 == -121 || v6 == -119 ) + if (v6 == 7 || v6 == 9 || v6 == 121 || v6 == 124 || v6 == -121 || v6 == -119) result = 1; } } @@ -2644,24 +2310,22 @@ bool __fastcall WoodHorizL(int x, int j) bool __fastcall WoodHorizR(int x, int j) { - int v2; // eax - char v3; // cl - char *v4; // eax + int v2; // eax + char v3; // cl + char *v4; // eax unsigned char v5; // cl - char v6; // al - bool result; // eax + char v6; // al + bool result; // eax v2 = x; v3 = dungeon[x][j + 1]; result = 0; - if ( (unsigned char)v3 > 0x98u || (unsigned char)v3 < 0x82u ) - { + if ((unsigned char)v3 > 0x98u || (unsigned char)v3 < 0x82u) { v4 = &dungeon[v2][j]; v5 = *(v4 - 1); - if ( v5 > 0x98u || v5 < 0x82u ) - { + if (v5 > 0x98u || v5 < 0x82u) { v6 = *v4; - if ( v6 == 7 || v6 == 4 || v6 == -121 || v6 == -119 ) + if (v6 == 7 || v6 == 4 || v6 == -121 || v6 == -119) result = 1; } } @@ -2670,27 +2334,27 @@ bool __fastcall WoodHorizR(int x, int j) void __cdecl DRLG_L3Pass3() { - int v0; // eax - int *v1; // esi - int *v2; // eax - signed int v3; // ecx - signed int v4; // ebx - int *v5; // ecx - unsigned char *v6; // edi + int v0; // eax + int *v1; // esi + int *v2; // eax + signed int v3; // ecx + signed int v4; // ebx + int *v5; // ecx + unsigned char *v6; // edi unsigned short *v7; // esi - unsigned short v8; // ax - int v9; // eax - signed int v10; // [esp+Ch] [ebp-1Ch] - int *v11; // [esp+10h] [ebp-18h] - int v12; // [esp+14h] [ebp-14h] - int v13; // [esp+18h] [ebp-10h] - int v14; // [esp+18h] [ebp-10h] - int v15; // [esp+1Ch] [ebp-Ch] - int v16; // [esp+1Ch] [ebp-Ch] - int v17; // [esp+20h] [ebp-8h] - int v18; // [esp+20h] [ebp-8h] - int v19; // [esp+24h] [ebp-4h] - int v20; // [esp+24h] [ebp-4h] + unsigned short v8; // ax + int v9; // eax + signed int v10; // [esp+Ch] [ebp-1Ch] + int *v11; // [esp+10h] [ebp-18h] + int v12; // [esp+14h] [ebp-14h] + int v13; // [esp+18h] [ebp-10h] + int v14; // [esp+18h] [ebp-10h] + int v15; // [esp+1Ch] [ebp-Ch] + int v16; // [esp+1Ch] [ebp-Ch] + int v17; // [esp+20h] [ebp-8h] + int v18; // [esp+20h] [ebp-8h] + int v19; // [esp+24h] [ebp-4h] + int v20; // [esp+24h] [ebp-4h] v0 = *((unsigned short *)pMegaTiles + 28) + 1; v19 = *((unsigned short *)pMegaTiles + 28) + 1; @@ -2701,42 +2365,33 @@ void __cdecl DRLG_L3Pass3() _LOWORD(v0) = *((_WORD *)pMegaTiles + 31); v13 = v0 + 1; v1 = dPiece[1]; - do - { + do { v2 = v1; v3 = 56; - do - { + do { *(v2 - 112) = v19; *v2 = v17; *(v2 - 111) = v15; v2[1] = v13; v2 += 224; --v3; - } - while ( v3 ); + } while (v3); v1 += 2; - } - while ( (signed int)v1 < (signed int)dPiece[2] ); + } while ((signed int)v1 < (signed int)dPiece[2]); v4 = 0; v11 = &dPiece[17][16]; - do - { + do { v5 = v11; v6 = (unsigned char *)dungeon + v4; v10 = 40; - do - { + do { v12 = *v6 - 1; - if ( v12 < 0 ) - { + if (v12 < 0) { v20 = 0; v18 = 0; v16 = 0; v14 = 0; - } - else - { + } else { v7 = (unsigned short *)((char *)pMegaTiles + 8 * v12); v8 = *v7; ++v7; @@ -2757,33 +2412,31 @@ void __cdecl DRLG_L3Pass3() v5[1] = v14; v5 += 224; --v10; - } - while ( v10 ); + } while (v10); v11 += 2; ++v4; - } - while ( v4 < 40 ); + } while (v4 < 40); } void __fastcall LoadL3Dungeon(char *sFileName, int vx, int vy) { - char *v3; // esi + char *v3; // esi unsigned char *v4; // eax - char *v5; // esi - int v6; // edi - int v7; // ecx - _BYTE *v8; // eax - _BYTE *v9; // edx - int v10; // ebx - signed int v11; // ecx - _BYTE *v12; // eax - signed int v13; // edx - int v14; // edi - signed int v15; // eax - int v16; // [esp+Ch] [ebp-8h] - signed int *v17; // [esp+Ch] [ebp-8h] - int v18; // [esp+10h] [ebp-4h] - int (*v19)[112]; // [esp+10h] [ebp-4h] + char *v5; // esi + int v6; // edi + int v7; // ecx + _BYTE *v8; // eax + _BYTE *v9; // edx + int v10; // ebx + signed int v11; // ecx + _BYTE *v12; // eax + signed int v13; // edx + int v14; // edi + signed int v15; // eax + int v16; // [esp+Ch] [ebp-8h] + signed int *v17; // [esp+Ch] [ebp-8h] + int v18; // [esp+10h] [ebp-4h] + int(*v19)[112]; // [esp+10h] [ebp-4h] v3 = sFileName; InitL3Dungeon(); @@ -2799,47 +2452,37 @@ void __fastcall LoadL3Dungeon(char *sFileName, int vx, int vy) v4 += 2; v7 = *v4; v8 = v4 + 2; - if ( v7 > 0 ) - { - do - { - if ( v6 > 0 ) - { + if (v7 > 0) { + do { + if (v6 > 0) { v16 = v6; v9 = (unsigned char *)dungeon + v18; - do - { - if ( *v8 ) + do { + if (*v8) *v9 = *v8; else *v9 = 7; v9 += 40; v8 += 2; --v16; - } - while ( v16 ); + } while (v16); } ++v18; - } - while ( v18 < v7 ); + } while (v18 < v7); } v10 = 0; v11 = 0; - do - { + do { v12 = (unsigned char *)dungeon + v11; v13 = 40; - do - { - if ( !*v12 ) + do { + if (!*v12) *v12 = 8; v12 += 40; --v13; - } - while ( v13 ); + } while (v13); ++v11; - } - while ( v11 < 40 ); + } while (v11 < 40); abyssx = 112; DRLG_L3Pass3(); DRLG_Init_Globals(); @@ -2848,23 +2491,19 @@ void __fastcall LoadL3Dungeon(char *sFileName, int vx, int vy) SetMapMonsters((unsigned char *)v5, 0, 0); SetMapObjects((unsigned char *)v5, 0, 0); v19 = dPiece; - do - { + do { v14 = 0; v17 = (signed int *)v19; - do - { + do { v15 = *v17; - if ( *v17 >= 56 && v15 <= 147 || v15 >= 154 && v15 <= 161 || v15 == 150 || v15 == 152 ) + if (*v17 >= 56 && v15 <= 147 || v15 >= 154 && v15 <= 161 || v15 == 150 || v15 == 152) DoLighting(v14, v10, 7, -1); v17 += 112; ++v14; - } - while ( v14 < 112 ); - v19 = (int (*)[112])((char *)v19 + 4); + } while (v14 < 112); + v19 = (int(*)[112])((char *)v19 + 4); ++v10; - } - while ( (signed int)v19 < (signed int)dPiece[1] ); + } while ((signed int)v19 < (signed int)dPiece[1]); mem_free_dbg(v5); } // 52837C: using guessed type int abyssx; @@ -2875,18 +2514,18 @@ void __fastcall LoadL3Dungeon(char *sFileName, int vx, int vy) void __fastcall LoadPreL3Dungeon(char *sFileName, int vx, int vy) { - char *v3; // esi + char *v3; // esi unsigned char *v4; // eax unsigned char *v5; // esi - int v6; // edx - int v7; // edi - _BYTE *v8; // eax - _BYTE *v9; // ecx - signed int v10; // ecx - _BYTE *v11; // eax - signed int v12; // edx - int v13; // [esp+8h] [ebp-8h] - int v14; // [esp+Ch] [ebp-4h] + int v6; // edx + int v7; // edi + _BYTE *v8; // eax + _BYTE *v9; // ecx + signed int v10; // ecx + _BYTE *v11; // eax + signed int v12; // edx + int v13; // [esp+8h] [ebp-8h] + int v14; // [esp+Ch] [ebp-4h] v3 = sFileName; InitL3Dungeon(); @@ -2898,46 +2537,36 @@ void __fastcall LoadPreL3Dungeon(char *sFileName, int vx, int vy) v4 += 2; v7 = *v4; v8 = v4 + 2; - if ( v7 > 0 ) - { - do - { - if ( v6 > 0 ) - { + if (v7 > 0) { + do { + if (v6 > 0) { v13 = v6; v9 = (unsigned char *)dungeon + v14; - do - { - if ( *v8 ) + do { + if (*v8) *v9 = *v8; else *v9 = 7; v9 += 40; v8 += 2; --v13; - } - while ( v13 ); + } while (v13); } ++v14; - } - while ( v14 < v7 ); + } while (v14 < v7); } v10 = 0; - do - { + do { v11 = (unsigned char *)dungeon + v10; v12 = 40; - do - { - if ( !*v11 ) + do { + if (!*v11) *v11 = 8; v11 += 40; --v12; - } - while ( v12 ); + } while (v12); ++v10; - } - while ( v10 < 40 ); + } while (v10 < 40); memcpy(pdungeon, dungeon, 0x640u); mem_free_dbg(v5); } diff --git a/Source/drlg_l4.cpp b/Source/drlg_l4.cpp index 9fa25f49..f8c84098 100644 --- a/Source/drlg_l4.cpp +++ b/Source/drlg_l4.cpp @@ -23,283 +23,283 @@ char dung[20][20]; const unsigned char L4ConvTbl[16] = { 30u, 6u, 1u, 6u, 2u, 6u, 6u, 6u, 9u, 6u, 1u, 6u, 2u, 6u, 3u, 6u }; const unsigned char L4USTAIRS[42] = { - 4u, - 5u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 0u, - 0u, - 0u, - 0u, - 36u, - 38u, - 35u, - 0u, - 37u, - 34u, - 33u, - 32u, - 0u, - 0u, - 31u, - 0u, - 0u, - 0u, - 0u, - 0u + 4u, + 5u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 0u, + 0u, + 0u, + 0u, + 36u, + 38u, + 35u, + 0u, + 37u, + 34u, + 33u, + 32u, + 0u, + 0u, + 31u, + 0u, + 0u, + 0u, + 0u, + 0u }; const unsigned char L4TWARP[42] = { - 4u, - 5u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 0u, - 0u, - 0u, - 0u, - 134u, - 136u, - 133u, - 0u, - 135u, - 132u, - 131u, - 130u, - 0u, - 0u, - 129u, - 0u, - 0u, - 0u, - 0u, - 0u + 4u, + 5u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 0u, + 0u, + 0u, + 0u, + 134u, + 136u, + 133u, + 0u, + 135u, + 132u, + 131u, + 130u, + 0u, + 0u, + 129u, + 0u, + 0u, + 0u, + 0u, + 0u }; const unsigned char L4DSTAIRS[52] = { - 5u, - 5u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 0u, - 0u, - 0u, - 0u, - 0u, - 0u, - 0u, - 45u, - 41u, - 0u, - 0u, - 44u, - 43u, - 40u, - 0u, - 0u, - 46u, - 42u, - 39u, - 0u, - 0u, - 0u, - 0u, - 0u, - 0u + 5u, + 5u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 0u, + 0u, + 0u, + 0u, + 0u, + 0u, + 0u, + 45u, + 41u, + 0u, + 0u, + 44u, + 43u, + 40u, + 0u, + 0u, + 46u, + 42u, + 39u, + 0u, + 0u, + 0u, + 0u, + 0u, + 0u }; const unsigned char L4PENTA[52] = { - 5u, - 5u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 0u, - 0u, - 0u, - 0u, - 0u, - 0u, - 98u, - 100u, - 103u, - 0u, - 0u, - 99u, - 102u, - 105u, - 0u, - 0u, - 101u, - 104u, - 106u, - 0u, - 0u, - 0u, - 0u, - 0u, - 0u + 5u, + 5u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 0u, + 0u, + 0u, + 0u, + 0u, + 0u, + 98u, + 100u, + 103u, + 0u, + 0u, + 99u, + 102u, + 105u, + 0u, + 0u, + 101u, + 104u, + 106u, + 0u, + 0u, + 0u, + 0u, + 0u, + 0u }; const unsigned char L4PENTA2[52] = { - 5u, - 5u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 6u, - 0u, - 0u, - 0u, - 0u, - 0u, - 0u, - 107u, - 109u, - 112u, - 0u, - 0u, - 108u, - 111u, - 114u, - 0u, - 0u, - 110u, - 113u, - 115u, - 0u, - 0u, - 0u, - 0u, - 0u, - 0u + 5u, + 5u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 6u, + 0u, + 0u, + 0u, + 0u, + 0u, + 0u, + 107u, + 109u, + 112u, + 0u, + 0u, + 108u, + 111u, + 114u, + 0u, + 0u, + 110u, + 113u, + 115u, + 0u, + 0u, + 0u, + 0u, + 0u, + 0u }; const unsigned char L4BTYPES[140] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, - 10, 11, 12, 13, 14, 15, 16, 17, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, - 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 2, 1, 2, 1, 2, 1, 1, 2, - 2, 0, 0, 0, 0, 0, 0, 15, 16, 9, - 12, 4, 5, 7, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, + 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 2, 1, 2, 1, 2, 1, 1, 2, + 2, 0, 0, 0, 0, 0, 0, 15, 16, 9, + 12, 4, 5, 7, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; void __cdecl DRLG_LoadL4SP() { - setloadflag_2 = 0; - if (QuestStatus(QTYPE_WARLRD)) { - pSetPiece_2 = (char *)LoadFileInMem("Levels\\L4Data\\Warlord.DUN", 0); - setloadflag_2 = 1; - } - if (currlevel == 15 && gbMaxPlayers != 1) { - pSetPiece_2 = (char *)LoadFileInMem("Levels\\L4Data\\Vile1.DUN", 0); - setloadflag_2 = 1; - } + setloadflag_2 = 0; + if (QuestStatus(QTYPE_WARLRD)) { + pSetPiece_2 = (char *)LoadFileInMem("Levels\\L4Data\\Warlord.DUN", 0); + setloadflag_2 = 1; + } + if (currlevel == 15 && gbMaxPlayers != 1) { + pSetPiece_2 = (char *)LoadFileInMem("Levels\\L4Data\\Vile1.DUN", 0); + setloadflag_2 = 1; + } } // 5B50D8: using guessed type int setloadflag_2; // 679660: using guessed type char gbMaxPlayers; @@ -315,13 +315,13 @@ void __cdecl DRLG_FreeL4SP() void __fastcall DRLG_L4SetSPRoom(int rx1, int ry1) { - int v2; // edi - int v3; // esi - int v4; // eax - char v5; // bl - int v6; // [esp+8h] [ebp-Ch] + int v2; // edi + int v3; // esi + int v4; // eax + char v5; // bl + int v6; // [esp+8h] [ebp-Ch] char *v7; // [esp+Ch] [ebp-8h] - int v8; // [esp+10h] [ebp-4h] + int v8; // [esp+10h] [ebp-4h] v8 = 0; v2 = (unsigned char)pSetPiece_2[2]; @@ -331,35 +331,26 @@ void __fastcall DRLG_L4SetSPRoom(int rx1, int ry1) setpc_w = v3; setpc_h = v2; v7 = pSetPiece_2 + 4; - if ( v2 > 0 ) - { - do - { - if ( v3 > 0 ) - { + if (v2 > 0) { + do { + if (v3 > 0) { v6 = v3; v4 = ry1 + v8 + 40 * rx1; - do - { + do { v5 = *v7; - if ( *v7 ) - { + if (*v7) { dflags[0][v4] |= DFLAG_EXPLORED; dungeon[0][v4] = v5; - } - else - { + } else { dungeon[0][v4] = 6; } v7 += 2; v4 += 40; --v6; - } - while ( v6 ); + } while (v6); } ++v8; - } - while ( v8 < v2 ); + } while (v8 < v2); } } // 5CF330: using guessed type int setpc_h; @@ -367,32 +358,30 @@ void __fastcall DRLG_L4SetSPRoom(int rx1, int ry1) void __cdecl L4SaveQuads() { - char *v0; // esi - char *v1; // edx - char *v2; // edi - char *v3; // eax - char *v4; // ecx - char *v5; // ebx + char *v0; // esi + char *v1; // edx + char *v2; // edi + char *v3; // eax + char *v4; // ecx + char *v5; // ebx signed int v6; // [esp+Ch] [ebp-14h] signed int v7; // [esp+10h] [ebp-10h] - char *v8; // [esp+14h] [ebp-Ch] - char *v9; // [esp+18h] [ebp-8h] - char *v10; // [esp+1Ch] [ebp-4h] + char *v8; // [esp+14h] [ebp-Ch] + char *v9; // [esp+18h] [ebp-8h] + char *v10; // [esp+1Ch] [ebp-4h] v0 = &dflags[39][l4holdy - 40 * l4holdx]; /* check */ v1 = &dflags[39][-l4holdy + 39 + -40 * l4holdx]; v9 = &dflags[l4holdx][l4holdy]; v8 = &dflags[0][40 * l4holdx - l4holdy + 39]; v6 = 14; - do - { + do { v2 = v1; v10 = v8; v3 = v9; v4 = v0; v7 = 14; - do - { + do { v5 = v10; v10 += 40; *v3 = 1; @@ -403,74 +392,63 @@ void __cdecl L4SaveQuads() v2 -= 40; v3 += 40; --v7; - } - while ( v7 ); + } while (v7); ++v9; --v8; --v1; ++v0; --v6; - } - while ( v6 ); + } while (v6); } // 528A34: using guessed type int l4holdx; // 528A38: using guessed type int l4holdy; void __fastcall DRLG_L4SetRoom(unsigned char *pSetPiece, int rx1, int ry1) { - int v3; // ebx - int v4; // edi + int v3; // ebx + int v4; // edi unsigned char *v5; // esi - int v6; // eax - char v7; // cl - int v8; // [esp+Ch] [ebp-8h] - int v9; // [esp+10h] [ebp-4h] + int v6; // eax + char v7; // cl + int v8; // [esp+Ch] [ebp-8h] + int v9; // [esp+10h] [ebp-4h] v3 = *pSetPiece; v4 = 0; v8 = pSetPiece[2]; v5 = pSetPiece + 4; - if ( v8 > 0 ) - { - do - { - if ( v3 > 0 ) - { + if (v8 > 0) { + do { + if (v3 > 0) { v9 = v3; v6 = ry1 + v4 + 40 * rx1; - do - { + do { v7 = *v5; - if ( *v5 ) - { + if (*v5) { dflags[0][v6] |= DFLAG_EXPLORED; dungeon[0][v6] = v7; - } - else - { + } else { dungeon[0][v6] = 6; } v6 += 40; v5 += 2; --v9; - } - while ( v9 ); + } while (v9); } ++v4; - } - while ( v4 < v8 ); + } while (v4 < v8); } } void __fastcall DRLG_LoadDiabQuads(bool preflag) { - bool v1; // esi + bool v1; // esi unsigned char *v2; // edi - char *v3; // ecx + char *v3; // ecx unsigned char *v4; // edi - char *v5; // ecx + char *v5; // ecx unsigned char *v6; // edi - char *v7; // ecx + char *v7; // ecx unsigned char *v8; // esi v1 = preflag; @@ -480,7 +458,7 @@ void __fastcall DRLG_LoadDiabQuads(bool preflag) DRLG_L4SetRoom(v2, l4holdx + 4, l4holdy + 4); mem_free_dbg(v2); v3 = "Levels\\L4Data\\diab2b.DUN"; - if ( !v1 ) + if (!v1) v3 = "Levels\\L4Data\\diab2a.DUN"; v4 = LoadFileInMem(v3, 0); diabquad2y = l4holdy + 1; @@ -488,7 +466,7 @@ void __fastcall DRLG_LoadDiabQuads(bool preflag) DRLG_L4SetRoom(v4, 27 - l4holdx, l4holdy + 1); mem_free_dbg(v4); v5 = "Levels\\L4Data\\diab3b.DUN"; - if ( !v1 ) + if (!v1) v5 = "Levels\\L4Data\\diab3a.DUN"; v6 = LoadFileInMem(v5, 0); diabquad3x = l4holdx + 1; @@ -496,7 +474,7 @@ void __fastcall DRLG_LoadDiabQuads(bool preflag) DRLG_L4SetRoom(v6, l4holdx + 1, 27 - l4holdy); mem_free_dbg(v6); v7 = "Levels\\L4Data\\diab4b.DUN"; - if ( !v1 ) + if (!v1) v7 = "Levels\\L4Data\\diab4a.DUN"; v8 = LoadFileInMem(v7, 0); diabquad4y = 28 - l4holdy; @@ -513,7 +491,7 @@ bool __fastcall IsDURWall(char d) { bool result; // al - if ( d == 25 || d == 28 ) + if (d == 25 || d == 28) result = 1; else result = d == 23; @@ -524,7 +502,7 @@ bool __fastcall IsDLLWall(char dd) { bool result; // al - if ( dd == 27 || dd == 26 ) + if (dd == 27 || dd == 26) result = 1; else result = dd == 22; @@ -533,15 +511,13 @@ bool __fastcall IsDLLWall(char dd) void __cdecl L4FixRim() { - char (*v0)[20]; // eax + char(*v0)[20]; // eax v0 = dung; - do - { + do { *(_BYTE *)v0 = 0; ++v0; - } - while ( (signed int)v0 < (signed int)&dung[20][0] ); + } while ((signed int)v0 < (signed int)&dung[20][0]); *(_DWORD *)&dung[0][0] = 0; *(_DWORD *)&dung[0][4] = 0; *(_DWORD *)&dung[0][8] = 0; @@ -553,25 +529,21 @@ void __cdecl L4FixRim() void __cdecl DRLG_L4GeneralFix() { signed int v0; // ecx - char *v1; // eax + char *v1; // eax signed int v2; // esi v0 = 0; - do - { + do { v1 = (char *)dungeon + v0; v2 = 39; - do - { - if ( (*v1 == 24 || *v1 == 122) && v1[40] == 2 && v1[1] == 5 ) + do { + if ((*v1 == 24 || *v1 == 122) && v1[40] == 2 && v1[1] == 5) *v1 = 17; v1 += 40; --v2; - } - while ( v2 ); + } while (v2); ++v0; - } - while ( v0 < 39 ); + } while (v0 < 39); } void __fastcall CreateL4Dungeon(int rseed, int entry) @@ -602,56 +574,50 @@ void __fastcall DRLG_L4(int entry) { signed int v1; // ebp //int v2; // eax - int v3; // edx - char *v4; // edi - char v5; // bp + int v3; // edx + char *v4; // edi + char v5; // bp unsigned int v6; // ecx - char *v7; // edi - int v8; // ecx + char *v7; // edi + int v8; // ecx //int v9; // eax - int v10; // eax + int v10; // eax unsigned char *v11; // ecx unsigned char *v12; // ecx //int v13; // eax signed int v14; // eax signed int v15; // ecx - int v16; // ebx - int v17; // edi - char *v18; // ebp + int v16; // ebx + int v17; // edi + char *v18; // ebp signed int v19; // ecx signed int v20; // eax signed int v21; // esi - int v22; // [esp-8h] [ebp-20h] - int v23; // [esp+10h] [ebp-8h] - int v24; // [esp+14h] [ebp-4h] + int v22; // [esp-8h] [ebp-20h] + int v23; // [esp+10h] [ebp-8h] + int v24; // [esp+14h] [ebp-4h] v1 = 0; v23 = entry; - do - { + do { DRLG_InitTrans(); - do - { + do { InitL4Dungeon(); L4firstRoom(); L4FixRim(); - } - while ( GetArea() < 173 ); + } while (GetArea() < 173); uShape(); L4makeDungeon(); L4makeDmt(); L4tileFix(); - if ( currlevel == 16 ) + if (currlevel == 16) L4SaveQuads(); //_LOBYTE(v2) = QuestStatus(QTYPE_WARLRD); - if ( (QuestStatus(QTYPE_WARLRD) || currlevel == quests[QTYPE_VB]._qlevel && gbMaxPlayers != 1) && SP4x1 < SP4x2 ) - { + if ((QuestStatus(QTYPE_WARLRD) || currlevel == quests[QTYPE_VB]._qlevel && gbMaxPlayers != 1) && SP4x1 < SP4x2) { v3 = SP4x1; v24 = SP4x2 - SP4x1; - do - { - if ( SP4y1 < SP4y2 ) - { + do { + if (SP4y1 < SP4y2) { v4 = &dflags[v3][SP4y1]; v5 = SP4y2 - SP4y1; v6 = (unsigned int)(SP4y2 - SP4y1) >> 2; @@ -663,69 +629,55 @@ void __fastcall DRLG_L4(int entry) } ++v3; --v24; - } - while ( v24 ); + } while (v24); } L4AddWall(); DRLG_L4FloodTVal(); DRLG_L4TransFix(); - if ( setloadflag_2 ) + if (setloadflag_2) DRLG_L4SetSPRoom(SP4x1, SP4y1); - if ( currlevel == 16 ) + if (currlevel == 16) DRLG_LoadDiabQuads(1); //_LOBYTE(v9) = QuestStatus(QTYPE_WARLRD); - if ( !QuestStatus(QTYPE_WARLRD) ) - { - if ( currlevel == 15 ) - { - if ( !v23 ) - { + if (!QuestStatus(QTYPE_WARLRD)) { + if (currlevel == 15) { + if (!v23) { v10 = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 1, 0); - if ( v10 ) - { - if ( gbMaxPlayers != 1 || (v11 = (unsigned char *)L4PENTA, quests[QTYPE_MOD]._qactive == 2) ) + if (v10) { + if (gbMaxPlayers != 1 || (v11 = (unsigned char *)L4PENTA, quests[QTYPE_MOD]._qactive == 2)) v11 = (unsigned char *)L4PENTA2; v10 = DRLG_L4PlaceMiniSet(v11, 1, 1, -1, -1, 0, 1); } goto LABEL_35; } v10 = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 0, 0); - if ( v10 ) - { - if ( gbMaxPlayers != 1 || (v12 = (unsigned char *)L4PENTA, quests[QTYPE_MOD]._qactive == 2) ) + if (v10) { + if (gbMaxPlayers != 1 || (v12 = (unsigned char *)L4PENTA, quests[QTYPE_MOD]._qactive == 2)) v12 = (unsigned char *)L4PENTA2; v10 = DRLG_L4PlaceMiniSet(v12, 1, 1, -1, -1, 1, 1); } - } - else - { - if ( !v23 ) - { + } else { + if (!v23) { v10 = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 1, 0); - if ( v10 ) - { - if ( currlevel != 16 ) + if (v10) { + if (currlevel != 16) v10 = DRLG_L4PlaceMiniSet(L4DSTAIRS, 1, 1, -1, -1, 0, 1); goto LABEL_31; } -LABEL_35: + LABEL_35: ++ViewX; continue; } v10 = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 0, 0); - if ( v23 != 1 ) - { - if ( v10 ) - { - if ( currlevel != 16 ) + if (v23 != 1) { + if (v10) { + if (currlevel != 16) v10 = DRLG_L4PlaceMiniSet(L4DSTAIRS, 1, 1, -1, -1, 0, 1); -LABEL_46: - if ( v10 ) - { - if ( currlevel == 13 ) - { + LABEL_46: + if (v10) { + if (currlevel == 13) { v22 = 1; -LABEL_34: + LABEL_34: v10 = DRLG_L4PlaceMiniSet(L4TWARP, 1, 1, -1, -1, v22, 6); goto LABEL_35; } @@ -733,99 +685,81 @@ LABEL_34: } goto LABEL_35; } - if ( v10 ) - { - if ( currlevel != 16 ) + if (v10) { + if (currlevel != 16) v10 = DRLG_L4PlaceMiniSet(L4DSTAIRS, 1, 1, -1, -1, 1, 1); - if ( v10 && currlevel == 13 ) + if (v10 && currlevel == 13) v10 = DRLG_L4PlaceMiniSet(L4TWARP, 1, 1, -1, -1, 0, 6); } } ++ViewY; continue; } - if ( !v23 ) - { + if (!v23) { v10 = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 1, 0); -LABEL_31: - if ( !v10 || currlevel != 13 ) + LABEL_31: + if (!v10 || currlevel != 13) goto LABEL_35; v22 = 0; goto LABEL_34; } v10 = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 0, 0); - if ( v23 != 1 ) + if (v23 != 1) goto LABEL_46; - if ( v10 && currlevel == 13 ) + if (v10 && currlevel == 13) v10 = DRLG_L4PlaceMiniSet(L4TWARP, 1, 1, -1, -1, 0, 6); ViewX = 2 * setpc_x + 22; ViewY = 2 * setpc_y + 22; - } - while ( !v10 ); + } while (!v10); DRLG_L4GeneralFix(); - if ( currlevel != 16 ) + if (currlevel != 16) DRLG_PlaceThemeRooms(7, 10, 6, 8, 1); DRLG_L4Shadows(); DRLG_L4Corners(); DRLG_L4Subs(); DRLG_Init_Globals(); //_LOBYTE(v13) = QuestStatus(QTYPE_WARLRD); - if ( QuestStatus(QTYPE_WARLRD) ) - { - do - { + if (QuestStatus(QTYPE_WARLRD)) { + do { v14 = v1; v15 = 40; - do - { + do { pdungeon[0][v14] = dungeon[0][v14]; v14 += 40; --v15; - } - while ( v15 ); + } while (v15); ++v1; - } - while ( v1 < 40 ); + } while (v1 < 40); } DRLG_CheckQuests(SP4x1, SP4y1); - if ( currlevel == 15 ) - { + if (currlevel == 15) { v16 = -1; - do - { + do { v17 = -1; v18 = &dungeon[0][v16 + 1]; - do - { - if ( *v18 == 98 ) + do { + if (*v18 == 98) Make_SetPC(v17, v16, 5, 5); - if ( *v18 == 107 ) + if (*v18 == 107) Make_SetPC(v17, v16, 5, 5); v18 += 40; ++v17; - } - while ( v17 + 1 < 40 ); + } while (v17 + 1 < 40); ++v16; - } - while ( v16 < 39 ); + } while (v16 < 39); } - if ( currlevel == 16 ) - { + if (currlevel == 16) { v19 = 0; - do - { + do { v20 = v19; v21 = 40; - do - { + do { pdungeon[0][v20] = dungeon[0][v20]; v20 += 40; --v21; - } - while ( v21 ); + } while (v21); ++v19; - } - while ( v19 < 40 ); + } while (v19 < 40); DRLG_LoadDiabQuads(0); } } @@ -837,42 +771,37 @@ LABEL_31: void __cdecl DRLG_L4Shadows() { signed int v0; // esi - char *v1; // eax + char *v1; // eax signed int v2; // edi - char v3; // dl + char v3; // dl signed int v4; // ecx v0 = 1; - do - { + do { v1 = &dungeon[1][v0]; v2 = 39; - do - { + do { v3 = *v1; v4 = 0; - if ( *v1 == 3 ) + if (*v1 == 3) v4 = 1; - if ( v3 == 4 ) + if (v3 == 4) v4 = 1; - if ( v3 == 8 ) + if (v3 == 8) v4 = 1; - if ( v3 == 15 ) + if (v3 == 15) v4 = 1; - if ( v4 ) - { - if ( *(v1 - 40) == 6 ) + if (v4) { + if (*(v1 - 40) == 6) *(v1 - 40) = 47; - if ( *(v1 - 41) == 6 ) + if (*(v1 - 41) == 6) *(v1 - 41) = 48; } v1 += 40; --v2; - } - while ( v2 ); + } while (v2); ++v0; - } - while ( v0 < 40 ); + } while (v0 < 40); } void __cdecl InitL4Dungeon() @@ -884,69 +813,61 @@ void __cdecl InitL4Dungeon() memset(dung, 0, sizeof(dung)); memset(L4dungeon, 0, sizeof(L4dungeon)); v0 = 0; - do - { + do { v1 = v0; v2 = 40; - do - { + do { dflags[0][v1] = 0; dungeon[0][v1] = 30; v1 += 40; --v2; - } - while ( v2 ); + } while (v2); ++v0; - } - while ( v0 < 40 ); + } while (v0 < 40); } void __cdecl L4makeDmt() { signed int v0; // ecx - char (*v1)[40]; // ebp - char (*v2)[40]; // esi - char *v3; // eax + char(*v1)[40]; // ebp + char(*v2)[40]; // esi + char *v3; // eax signed int v4; // edi - int v5; // edx - int v6; // ebx + int v5; // edx + int v6; // ebx v0 = 1; v1 = dungeon; - do - { + do { v2 = v1; v3 = &L4dungeon[1][v0 + 1]; v4 = 39; - do - { + do { v5 = (unsigned char)v3[80]; v6 = (unsigned char)*v3; v3 += 160; *(_BYTE *)v2 = L4ConvTbl[2 * ((unsigned char)*(v3 - 81) + 2 * (v6 + 2 * v5)) - + (unsigned char)*(v3 - 161)]; + + (unsigned char)*(v3 - 161)]; ++v2; --v4; - } - while ( v4 ); - v1 = (char (*)[40])((char *)v1 + 1); + } while (v4); + v1 = (char(*)[40])((char *)v1 + 1); v0 += 2; - } - while ( v0 <= 77 ); + } while (v0 <= 77); } void __cdecl L4AddWall() { - int v0; // edi - int v1; // esi - int v2; // ebx - int v3; // eax - int v4; // eax - int v5; // eax - int v6; // eax - int v7; // eax - int v8; // eax - int v9; // eax + int v0; // edi + int v1; // esi + int v2; // ebx + int v3; // eax + int v4; // eax + int v5; // eax + int v6; // eax + int v7; // eax + int v8; // eax + int v9; // eax int v10; // eax int v11; // eax int v12; // eax @@ -957,315 +878,285 @@ void __cdecl L4AddWall() int v17; // eax v0 = 0; - do - { + do { v1 = 0; v2 = v0; - do - { - if ( !dflags[0][v2] ) - { - if ( dungeon[0][v2] == 10 && random(0, 100) < 100 ) - { + do { + if (!dflags[0][v2]) { + if (dungeon[0][v2] == 10 && random(0, 100) < 100) { v3 = L4HWallOk(v1, v0); - if ( v3 != -1 ) + if (v3 != -1) L4HorizWall(v1, v0, v3); } - if ( dungeon[0][v2] == 12 && random(0, 100) < 100 ) - { + if (dungeon[0][v2] == 12 && random(0, 100) < 100) { v4 = L4HWallOk(v1, v0); - if ( v4 != -1 ) + if (v4 != -1) L4HorizWall(v1, v0, v4); } - if ( dungeon[0][v2] == 13 && random(0, 100) < 100 ) - { + if (dungeon[0][v2] == 13 && random(0, 100) < 100) { v5 = L4HWallOk(v1, v0); - if ( v5 != -1 ) + if (v5 != -1) L4HorizWall(v1, v0, v5); } - if ( dungeon[0][v2] == 15 && random(0, 100) < 100 ) - { + if (dungeon[0][v2] == 15 && random(0, 100) < 100) { v6 = L4HWallOk(v1, v0); - if ( v6 != -1 ) + if (v6 != -1) L4HorizWall(v1, v0, v6); } - if ( dungeon[0][v2] == 16 && random(0, 100) < 100 ) - { + if (dungeon[0][v2] == 16 && random(0, 100) < 100) { v7 = L4HWallOk(v1, v0); - if ( v7 != -1 ) + if (v7 != -1) L4HorizWall(v1, v0, v7); } - if ( dungeon[0][v2] == 21 && random(0, 100) < 100 ) - { + if (dungeon[0][v2] == 21 && random(0, 100) < 100) { v8 = L4HWallOk(v1, v0); - if ( v8 != -1 ) + if (v8 != -1) L4HorizWall(v1, v0, v8); } - if ( dungeon[0][v2] == 22 && random(0, 100) < 100 ) - { + if (dungeon[0][v2] == 22 && random(0, 100) < 100) { v9 = L4HWallOk(v1, v0); - if ( v9 != -1 ) + if (v9 != -1) L4HorizWall(v1, v0, v9); } - if ( dungeon[0][v2] == 8 && random(0, 100) < 100 ) - { + if (dungeon[0][v2] == 8 && random(0, 100) < 100) { v10 = L4VWallOk(v1, v0); - if ( v10 != -1 ) + if (v10 != -1) L4VertWall(v1, v0, v10); } - if ( dungeon[0][v2] == 9 && random(0, 100) < 100 ) - { + if (dungeon[0][v2] == 9 && random(0, 100) < 100) { v11 = L4VWallOk(v1, v0); - if ( v11 != -1 ) + if (v11 != -1) L4VertWall(v1, v0, v11); } - if ( dungeon[0][v2] == 11 && random(0, 100) < 100 ) - { + if (dungeon[0][v2] == 11 && random(0, 100) < 100) { v12 = L4VWallOk(v1, v0); - if ( v12 != -1 ) + if (v12 != -1) L4VertWall(v1, v0, v12); } - if ( dungeon[0][v2] == 14 && random(0, 100) < 100 ) - { + if (dungeon[0][v2] == 14 && random(0, 100) < 100) { v13 = L4VWallOk(v1, v0); - if ( v13 != -1 ) + if (v13 != -1) L4VertWall(v1, v0, v13); } - if ( dungeon[0][v2] == 15 && random(0, 100) < 100 ) - { + if (dungeon[0][v2] == 15 && random(0, 100) < 100) { v14 = L4VWallOk(v1, v0); - if ( v14 != -1 ) + if (v14 != -1) L4VertWall(v1, v0, v14); } - if ( dungeon[0][v2] == 16 && random(0, 100) < 100 ) - { + if (dungeon[0][v2] == 16 && random(0, 100) < 100) { v15 = L4VWallOk(v1, v0); - if ( v15 != -1 ) + if (v15 != -1) L4VertWall(v1, v0, v15); } - if ( dungeon[0][v2] == 21 && random(0, 100) < 100 ) - { + if (dungeon[0][v2] == 21 && random(0, 100) < 100) { v16 = L4VWallOk(v1, v0); - if ( v16 != -1 ) + if (v16 != -1) L4VertWall(v1, v0, v16); } - if ( dungeon[0][v2] == 23 && random(0, 100) < 100 ) - { + if (dungeon[0][v2] == 23 && random(0, 100) < 100) { v17 = L4VWallOk(v1, v0); - if ( v17 != -1 ) + if (v17 != -1) L4VertWall(v1, v0, v17); } } ++v1; v2 += 40; - } - while ( v1 < 40 ); + } while (v1 < 40); ++v0; - } - while ( v0 < 40 ); + } while (v0 < 40); } int __fastcall L4HWallOk(int i, int j) { - int v2; // esi - int v3; // edi - char *v4; // ebx - int result; // eax + int v2; // esi + int v3; // edi + char *v4; // ebx + int result; // eax signed int v6; // esi - char v7; // dl - int v8; // [esp+8h] [ebp-4h] + char v7; // dl + int v8; // [esp+8h] [ebp-4h] v2 = 8 * (5 * i + 5); v8 = 1; - if ( dungeon[0][v2 + j] == 6 ) - { + if (dungeon[0][v2 + j] == 6) { v3 = 8 * (5 * i + 5); v4 = &dungeon[i + 1][j]; - do - { - if ( dflags[0][v3 + j] ) + do { + if (dflags[0][v3 + j]) break; - if ( dungeon[0][v3 + j - 1] != 6 ) // *((_BYTE *)&dMonster[111][111] + v3 + j + 3) != 6 ) /* check */ + if (dungeon[0][v3 + j - 1] != 6) // *((_BYTE *)&dMonster[111][111] + v3 + j + 3) != 6 ) /* check */ break; - if ( dungeon[0][v3 + 1 + j] != 6 ) + if (dungeon[0][v3 + 1 + j] != 6) break; ++v8; v4 += 40; v2 += 40; v3 = v2; - } - while ( *v4 == 6 ); + } while (*v4 == 6); } result = v8; v6 = 0; v7 = dungeon[v8 + i][j]; - if ( v7 == 10 ) + if (v7 == 10) v6 = 1; - if ( v7 == 12 ) + if (v7 == 12) v6 = 1; - if ( v7 == 13 ) + if (v7 == 13) v6 = 1; - if ( v7 == 15 ) + if (v7 == 15) v6 = 1; - if ( v7 == 16 ) + if (v7 == 16) v6 = 1; - if ( v7 == 21 ) + if (v7 == 21) v6 = 1; - if ( v7 == 22 ) + if (v7 == 22) v6 = 1; - if ( v8 <= 3 ) + if (v8 <= 3) v6 = 0; - if ( !v6 ) + if (!v6) result = -1; return result; } int __fastcall L4VWallOk(int i, int j) { - int v2; // ecx - int result; // eax - char *v4; // esi + int v2; // ecx + int result; // eax + char *v4; // esi signed int v5; // esi - char v6; // dl + char v6; // dl v2 = i; result = 1; - if ( dungeon[v2][j + 1] == 6 ) - { - do - { - if ( dflags[v2][j + result] ) + if (dungeon[v2][j + 1] == 6) { + do { + if (dflags[v2][j + result]) break; v4 = &dungeon[v2][j]; - if ( v4[result - 40] != 6 ) + if (v4[result - 40] != 6) break; - if ( dungeon[v2 + 1][result + j] != 6 ) + if (dungeon[v2 + 1][result + j] != 6) break; ++result; - } - while ( v4[result] == 6 ); + } while (v4[result] == 6); } v5 = 0; v6 = dungeon[0][result + v2 * 40 + j]; - if ( v6 == 8 ) + if (v6 == 8) v5 = 1; - if ( v6 == 9 ) + if (v6 == 9) v5 = 1; - if ( v6 == 11 ) + if (v6 == 11) v5 = 1; - if ( v6 == 14 ) + if (v6 == 14) v5 = 1; - if ( v6 == 15 ) + if (v6 == 15) v5 = 1; - if ( v6 == 16 ) + if (v6 == 16) v5 = 1; - if ( v6 == 21 ) + if (v6 == 21) v5 = 1; - if ( v6 == 23 ) + if (v6 == 23) v5 = 1; - if ( result <= 3 ) + if (result <= 3) v5 = 0; - if ( !v5 ) + if (!v5) result = -1; return result; } void __fastcall L4HorizWall(int i, int j, int dx) { - int v3; // esi - int v4; // edi - int v5; // eax - int v6; // ecx - char *v7; // eax - int v8; // edx - char *v9; // eax - int v10; // eax - bool v11; // zf + int v3; // esi + int v4; // edi + int v5; // eax + int v6; // ecx + char *v7; // eax + int v8; // edx + char *v9; // eax + int v10; // eax + bool v11; // zf char *v12; // eax v3 = i; v4 = j; v5 = j + 40 * i; - if ( dungeon[0][v5] == 13 ) + if (dungeon[0][v5] == 13) dungeon[0][v5] = 17; - if ( dungeon[0][v5] == 16 ) + if (dungeon[0][v5] == 16) dungeon[0][v5] = 11; - if ( dungeon[0][v5] == 12 ) + if (dungeon[0][v5] == 12) dungeon[0][v5] = 14; v6 = dx; - if ( dx > 1 ) - { + if (dx > 1) { v7 = &dungeon[1][v5]; v8 = dx - 1; - do - { + do { *v7 = 2; v7 += 40; --v8; - } - while ( v8 ); + } while (v8); } v9 = &dungeon[v3 + dx][v4]; - if ( *v9 == 15 ) + if (*v9 == 15) *v9 = 14; - if ( *v9 == 10 ) + if (*v9 == 10) *v9 = 17; - if ( *v9 == 21 ) + if (*v9 == 21) *v9 = 23; - if ( *v9 == 22 ) + if (*v9 == 22) *v9 = 29; v10 = v4 + 40 * (v3 + random(0, dx - 3) + 1); dungeon[2][v10] = 56; dungeon[1][v10] = 60; v11 = dungeon[0][v10 - 1] == 6; dungeon[0][v10] = 57; - if ( v11 ) + if (v11) dungeon[0][v10 - 1] = 58; v12 = &dungeon[0][v10 + 39]; - if ( *v12 == 6 ) + if (*v12 == 6) *v12 = 59; } void __fastcall L4VertWall(int i, int j, int dy) { - int v3; // edi - int v4; // esi - int v5; // edx - int v6; // ecx + int v3; // edi + int v4; // esi + int v5; // edx + int v6; // ecx _BYTE *v7; // eax - int v8; // edx - int v9; // eax + int v8; // edx + int v9; // eax char *v10; // ecx - bool v11; // zf - int v12; // [esp+8h] [ebp-4h] + bool v11; // zf + int v12; // [esp+8h] [ebp-4h] v3 = j; v4 = 40 * i; v12 = j; v5 = 40 * i + j; - if ( dungeon[0][v5] == 14 ) + if (dungeon[0][v5] == 14) dungeon[0][v5] = 17; - if ( dungeon[0][v5] == 8 ) + if (dungeon[0][v5] == 8) dungeon[0][v5] = 9; - if ( dungeon[0][v5] == 15 ) + if (dungeon[0][v5] == 15) dungeon[0][v5] = 10; v6 = dy; - if ( dy > 1 ) - { + if (dy > 1) { memset(&dungeon[0][v5 + 1], 1u, dy - 1); v3 = v12; v6 = dy; } v7 = (unsigned char *)dungeon + v5 + v6; - if ( *v7 == 11 ) + if (*v7 == 11) *v7 = 17; - if ( *v7 == 9 ) + if (*v7 == 9) *v7 = 10; - if ( *v7 == 16 ) + if (*v7 == 16) *v7 = 13; - if ( *v7 == 21 ) + if (*v7 == 21) *v7 = 22; - if ( *v7 == 23 ) + if (*v7 == 23) *v7 = 29; v8 = v6 - 3; v9 = random(0, v8) + 1 + v4 + v3; @@ -1274,1030 +1165,894 @@ void __fastcall L4VertWall(int i, int j, int dy) dungeon[0][v9 + 1] = 6; v11 = dungeon[-1][v9] == 6; dungeon[0][v9] = 53; - if ( v11 ) + if (v11) *(v10 - 40) = 54; - if ( *(v10 - 41) == 6 ) + if (*(v10 - 41) == 6) *(v10 - 41) = 55; } void __cdecl L4tileFix() { - signed int v0; // edx - char *v1; // eax - signed int v2; // esi - char v3; // cl - signed int v4; // edx - char *v5; // eax - signed int v6; // esi - char v7; // cl - signed int v8; // ecx - int v9; // eax - int v10; // eax - char *v11; // esi - char v12; // bl - char *v13; // edx - char *v14; // edx - char *v15; // edx - char *v16; // edx - char *v17; // edx - char *v18; // edx - char *v19; // edx - char *v20; // edx - char *v21; // edx - char *v22; // edx - char *v23; // edx - char *v24; // edx - char *v25; // edx - char *v26; // edx - char *v27; // edx - char *v28; // edx - char *v29; // edx - char *v30; // edx - char *v31; // edx - char *v32; // edx - char *v33; // edx - char *v34; // edx - char *v35; // edx - char *v36; // edx - char *v37; // edx - char *v38; // edx - char *v39; // edx - char *v40; // edx - char *v41; // edx - char *v42; // edx - char *v43; // edx - char *v44; // edx - char *v45; // edx - char *v46; // edx - char *v47; // edx - char *v48; // edx - char *v49; // edx - char *v50; // edx - char *v51; // edx - char *v52; // edx - char *v53; // edx - char *v54; // edx - char *v55; // edx - char *v56; // edx - char *v57; // edx - char *v58; // edx - char *v59; // edx - char *v60; // edx - char *v61; // edx - char *v62; // edx - char *v63; // edx - char *v64; // edx - char *v65; // edx - char *v66; // edx - char *v67; // edx - char *v68; // edx - char *v69; // edx - char *v70; // edx - char *v71; // edx - char *v72; // edx - char *v73; // edx - char *v74; // edx - char *v75; // edx - char *v76; // edx - char *v77; // edx - char *v78; // edx - char *v79; // edx - char *v80; // edx - char *v81; // edx - char *v82; // edx - char *v83; // edx - char *v84; // edx - char *v85; // edx - char *v86; // edx - char *v87; // edx - char *v88; // edx - char *v89; // edx - char *v90; // edx - char *v91; // edx - char *v92; // edx - char *v93; // edx - char *v94; // edx - char *v95; // edx - signed int v96; // ecx - signed int v97; // edi - signed int v98; // eax - char *v99; // esi - char v100; // bl - char *v101; // edx - char *v102; // edx - char *v103; // edx - char *v104; // edx - char *v105; // edx - char *v106; // edx - char *v107; // edx - char *v108; // edx - char *v109; // edx - char *v110; // edx - char *v111; // edx - char *v112; // edx - char *v113; // edx - char *v114; // edx - char *v115; // edx - char *v116; // edx - char *v117; // edx - char *v118; // edx - char *v119; // edx - char *v120; // edx - char *v121; // edx - char *v122; // edx - char *v123; // edx - char *v124; // edx - char *v125; // edx - char *v126; // edx - char *v127; // edx - char *v128; // edx - char *v129; // edx - char *v130; // edx + signed int v0; // edx + char *v1; // eax + signed int v2; // esi + char v3; // cl + signed int v4; // edx + char *v5; // eax + signed int v6; // esi + char v7; // cl + signed int v8; // ecx + int v9; // eax + int v10; // eax + char *v11; // esi + char v12; // bl + char *v13; // edx + char *v14; // edx + char *v15; // edx + char *v16; // edx + char *v17; // edx + char *v18; // edx + char *v19; // edx + char *v20; // edx + char *v21; // edx + char *v22; // edx + char *v23; // edx + char *v24; // edx + char *v25; // edx + char *v26; // edx + char *v27; // edx + char *v28; // edx + char *v29; // edx + char *v30; // edx + char *v31; // edx + char *v32; // edx + char *v33; // edx + char *v34; // edx + char *v35; // edx + char *v36; // edx + char *v37; // edx + char *v38; // edx + char *v39; // edx + char *v40; // edx + char *v41; // edx + char *v42; // edx + char *v43; // edx + char *v44; // edx + char *v45; // edx + char *v46; // edx + char *v47; // edx + char *v48; // edx + char *v49; // edx + char *v50; // edx + char *v51; // edx + char *v52; // edx + char *v53; // edx + char *v54; // edx + char *v55; // edx + char *v56; // edx + char *v57; // edx + char *v58; // edx + char *v59; // edx + char *v60; // edx + char *v61; // edx + char *v62; // edx + char *v63; // edx + char *v64; // edx + char *v65; // edx + char *v66; // edx + char *v67; // edx + char *v68; // edx + char *v69; // edx + char *v70; // edx + char *v71; // edx + char *v72; // edx + char *v73; // edx + char *v74; // edx + char *v75; // edx + char *v76; // edx + char *v77; // edx + char *v78; // edx + char *v79; // edx + char *v80; // edx + char *v81; // edx + char *v82; // edx + char *v83; // edx + char *v84; // edx + char *v85; // edx + char *v86; // edx + char *v87; // edx + char *v88; // edx + char *v89; // edx + char *v90; // edx + char *v91; // edx + char *v92; // edx + char *v93; // edx + char *v94; // edx + char *v95; // edx + signed int v96; // ecx + signed int v97; // edi + signed int v98; // eax + char *v99; // esi + char v100; // bl + char *v101; // edx + char *v102; // edx + char *v103; // edx + char *v104; // edx + char *v105; // edx + char *v106; // edx + char *v107; // edx + char *v108; // edx + char *v109; // edx + char *v110; // edx + char *v111; // edx + char *v112; // edx + char *v113; // edx + char *v114; // edx + char *v115; // edx + char *v116; // edx + char *v117; // edx + char *v118; // edx + char *v119; // edx + char *v120; // edx + char *v121; // edx + char *v122; // edx + char *v123; // edx + char *v124; // edx + char *v125; // edx + char *v126; // edx + char *v127; // edx + char *v128; // edx + char *v129; // edx + char *v130; // edx signed int v131; // edx - char *v132; // eax + char *v132; // eax signed int v133; // esi - char v134; // cl + char v134; // cl signed int v135; // edx - char *v136; // eax + char *v136; // eax signed int v137; // esi - char v138; // cl + char v138; // cl signed int v139; // [esp+8h] [ebp-4h] v0 = 0; - do - { + do { v1 = &dungeon[1][v0]; v2 = 40; - do - { + do { v3 = *(v1 - 40); - if ( v3 == 2 ) - { - if ( *v1 == 6 ) + if (v3 == 2) { + if (*v1 == 6) *v1 = 5; - if ( *v1 == 1 ) + if (*v1 == 1) *v1 = 13; } - if ( v3 == 1 && *(v1 - 39) == 2 ) + if (v3 == 1 && *(v1 - 39) == 2) *(v1 - 39) = 14; v1 += 40; --v2; - } - while ( v2 ); + } while (v2); ++v0; - } - while ( v0 < 40 ); + } while (v0 < 40); v4 = 0; - do - { + do { v5 = &dungeon[1][v4]; v6 = 40; - do - { + do { v7 = *(v5 - 40); - if ( v7 == 2 ) - { - if ( *v5 == 6 ) + if (v7 == 2) { + if (*v5 == 6) *v5 = 2; - if ( *v5 == 9 ) + if (*v5 == 9) *v5 = 11; } - if ( v7 == 9 && *v5 == 6 ) + if (v7 == 9 && *v5 == 6) *v5 = 12; - if ( v7 == 14 && *v5 == 1 ) + if (v7 == 14 && *v5 == 1) *v5 = 13; - if ( v7 == 6 ) - { - if ( *v5 == 14 ) + if (v7 == 6) { + if (*v5 == 14) *v5 = 15; - if ( *(v5 - 39) == 13 ) + if (*(v5 - 39) == 13) *(v5 - 39) = 16; } - if ( v7 == 1 && *(v5 - 39) == 9 ) + if (v7 == 1 && *(v5 - 39) == 9) *(v5 - 39) = 10; - if ( v7 == 6 && *(v5 - 41) == 1 ) + if (v7 == 6 && *(v5 - 41) == 1) *(v5 - 41) = 1; v5 += 40; --v6; - } - while ( v6 ); + } while (v6); ++v4; - } - while ( v4 < 40 ); + } while (v4 < 40); v8 = 0; - do - { + do { v9 = 0; v139 = 0; - do - { + do { v10 = v9; v11 = &dungeon[v10][v8]; v12 = *v11; - if ( *v11 == 13 ) - { + if (*v11 == 13) { v13 = &dungeon[v10][v8 + 1]; - if ( *v13 == 30 ) + if (*v13 == 30) *v13 = 27; } - if ( v12 == 27 ) - { + if (v12 == 27) { v14 = &dungeon[v10 + 1][v8]; - if ( *v14 == 30 ) + if (*v14 == 30) *v14 = 19; } - if ( v12 == 1 ) - { + if (v12 == 1) { v15 = &dungeon[v10][v8 + 1]; - if ( *v15 == 30 ) + if (*v15 == 30) *v15 = 27; } - if ( v12 == 27 ) - { + if (v12 == 27) { v16 = &dungeon[v10 + 1][v8]; - if ( *v16 == 1 ) + if (*v16 == 1) *v16 = 16; } - if ( v12 == 19 ) - { + if (v12 == 19) { v17 = &dungeon[v10 + 1][v8]; - if ( *v17 == 27 ) + if (*v17 == 27) *v17 = 26; } - if ( v12 == 27 ) - { + if (v12 == 27) { v18 = &dungeon[v10 + 1][v8]; - if ( *v18 == 30 ) + if (*v18 == 30) *v18 = 19; } - if ( v12 == 2 ) - { + if (v12 == 2) { v19 = &dungeon[v10 + 1][v8]; - if ( *v19 == 15 ) + if (*v19 == 15) *v19 = 14; } - if ( v12 == 14 ) - { + if (v12 == 14) { v20 = &dungeon[v10 + 1][v8]; - if ( *v20 == 15 ) + if (*v20 == 15) *v20 = 14; } - if ( v12 == 22 ) - { + if (v12 == 22) { v21 = &dungeon[v10 + 1][v8]; - if ( *v21 == 1 ) + if (*v21 == 1) *v21 = 16; } - if ( v12 == 27 ) - { + if (v12 == 27) { v22 = &dungeon[v10 + 1][v8]; - if ( *v22 == 1 ) + if (*v22 == 1) *v22 = 16; } - if ( v12 == 6 ) - { + if (v12 == 6) { v23 = &dungeon[v10 + 1][v8]; - if ( *v23 == 27 ) - { - if ( dungeon[v10 + 1][v8 + 1] ) + if (*v23 == 27) { + if (dungeon[v10 + 1][v8 + 1]) *v23 = 22; } } - if ( v12 == 22 ) - { + if (v12 == 22) { v24 = &dungeon[v10 + 1][v8]; - if ( *v24 == 30 ) + if (*v24 == 30) *v24 = 19; } - if ( v12 == 21 ) - { + if (v12 == 21) { v25 = &dungeon[v10 + 1][v8]; - if ( *v25 == 1 && dungeon[v10][v8 + 39] == 1 ) + if (*v25 == 1 && dungeon[v10][v8 + 39] == 1) *v25 = 13; } - if ( v12 == 14 ) - { + if (v12 == 14) { v26 = &dungeon[v10 + 1][v8]; - if ( *v26 == 30 && dungeon[v10][v8 + 1] == 6 ) + if (*v26 == 30 && dungeon[v10][v8 + 1] == 6) *v26 = 28; } - if ( v12 == 16 ) - { - if ( dungeon[v10 + 1][v8] == 6 ) - { + if (v12 == 16) { + if (dungeon[v10 + 1][v8] == 6) { v27 = &dungeon[v10][v8 + 1]; - if ( *v27 == 30 ) + if (*v27 == 30) *v27 = 27; } v28 = &dungeon[v10][v8 + 1]; - if ( *v28 == 30 && dungeon[v10 + 1][v8 + 1] == 30 ) + if (*v28 == 30 && dungeon[v10 + 1][v8 + 1] == 30) *v28 = 27; } - if ( v12 == 6 ) - { + if (v12 == 6) { v29 = &dungeon[v10 + 1][v8]; - if ( *v29 == 30 && dungeon[v10][v8 + 39] == 6 ) + if (*v29 == 30 && dungeon[v10][v8 + 39] == 6) *v29 = 21; } - if ( v12 == 2 ) - { + if (v12 == 2) { v30 = &dungeon[v10 + 1][v8]; - if ( *v30 == 27 && dungeon[v10 + 1][v8 + 1] == 9 ) + if (*v30 == 27 && dungeon[v10 + 1][v8 + 1] == 9) *v30 = 29; } - if ( v12 == 9 ) - { + if (v12 == 9) { v31 = &dungeon[v10 + 1][v8]; - if ( *v31 == 15 ) + if (*v31 == 15) *v31 = 14; } - if ( v12 == 15 ) - { + if (v12 == 15) { v32 = &dungeon[v10 + 1][v8]; - if ( *v32 == 27 && dungeon[v10 + 1][v8 + 1] == 2 ) + if (*v32 == 27 && dungeon[v10 + 1][v8 + 1] == 2) *v32 = 29; } - if ( v12 == 19 ) - { + if (v12 == 19) { v33 = &dungeon[v10 + 1][v8]; - if ( *v33 == 18 ) + if (*v33 == 18) *v33 = 24; } - if ( v12 == 9 ) - { + if (v12 == 9) { v34 = &dungeon[v10 + 1][v8]; - if ( *v34 == 15 ) + if (*v34 == 15) *v34 = 14; } - if ( v12 == 19 ) - { + if (v12 == 19) { v35 = &dungeon[v10 + 1][v8]; - if ( *v35 == 19 && dungeon[v10][v8 + 39] == 30 ) + if (*v35 == 19 && dungeon[v10][v8 + 39] == 30) *v35 = 24; } - if ( v12 == 24 && *(v11 - 1) == 30 && *(v11 - 2) == 6 ) + if (v12 == 24 && *(v11 - 1) == 30 && *(v11 - 2) == 6) *(v11 - 1) = 21; - if ( v12 == 2 ) - { + if (v12 == 2) { v36 = &dungeon[v10 + 1][v8]; - if ( *v36 == 30 ) + if (*v36 == 30) *v36 = 28; } - if ( v12 == 15 ) - { + if (v12 == 15) { v37 = &dungeon[v10 + 1][v8]; - if ( *v37 == 30 ) + if (*v37 == 30) *v37 = 28; } - if ( v12 == 28 ) - { + if (v12 == 28) { v38 = &dungeon[v10][v8 + 1]; - if ( *v38 == 30 ) + if (*v38 == 30) *v38 = 18; v39 = &dungeon[v10][v8 + 1]; - if ( *v39 == 2 ) + if (*v39 == 2) *v39 = 15; } - if ( v12 == 19 ) - { - if ( dungeon[v10 + 2][v8] == 2 && dungeon[v10][v8 + 39] == 18 && dungeon[v10 + 1][v8 + 1] == 1 ) + if (v12 == 19) { + if (dungeon[v10 + 2][v8] == 2 && dungeon[v10][v8 + 39] == 18 && dungeon[v10 + 1][v8 + 1] == 1) dungeon[v10 + 1][v8] = 17; - if ( dungeon[v10 + 2][v8] == 2 && dungeon[v10][v8 + 39] == 22 && dungeon[v10 + 1][v8 + 1] == 1 ) + if (dungeon[v10 + 2][v8] == 2 && dungeon[v10][v8 + 39] == 22 && dungeon[v10 + 1][v8 + 1] == 1) dungeon[v10 + 1][v8] = 17; - if ( dungeon[v10 + 2][v8] == 2 && dungeon[v10][v8 + 39] == 18 && dungeon[v10 + 1][v8 + 1] == 13 ) + if (dungeon[v10 + 2][v8] == 2 && dungeon[v10][v8 + 39] == 18 && dungeon[v10 + 1][v8 + 1] == 13) dungeon[v10 + 1][v8] = 17; } - if ( v12 == 21 ) - { - if ( dungeon[v10 + 2][v8] == 2 && dungeon[v10][v8 + 39] == 18 && dungeon[v10 + 1][v8 + 1] == 1 ) + if (v12 == 21) { + if (dungeon[v10 + 2][v8] == 2 && dungeon[v10][v8 + 39] == 18 && dungeon[v10 + 1][v8 + 1] == 1) dungeon[v10 + 1][v8] = 17; - if ( dungeon[v10 + 1][v8 + 1] == 1 && dungeon[v10][v8 + 39] == 22 && dungeon[v10 + 2][v8] == 3 ) + if (dungeon[v10 + 1][v8 + 1] == 1 && dungeon[v10][v8 + 39] == 22 && dungeon[v10 + 2][v8] == 3) dungeon[v10 + 1][v8] = 17; } - if ( v12 == 15 ) - { + if (v12 == 15) { v40 = &dungeon[v10 + 1][v8]; - if ( *v40 == 28 && dungeon[v10 + 2][v8] == 30 && dungeon[v10][v8 + 39] == 6 ) + if (*v40 == 28 && dungeon[v10 + 2][v8] == 30 && dungeon[v10][v8 + 39] == 6) *v40 = 23; } - if ( v12 == 14 ) - { + if (v12 == 14) { v41 = &dungeon[v10 + 1][v8]; - if ( *v41 == 28 && dungeon[v10 + 2][v8] == 1 ) + if (*v41 == 28 && dungeon[v10 + 2][v8] == 1) *v41 = 23; } - if ( v12 == 15 ) - { + if (v12 == 15) { v42 = &dungeon[v10 + 1][v8]; - if ( *v42 == 27 && dungeon[v10 + 1][v8 + 1] == 30 ) + if (*v42 == 27 && dungeon[v10 + 1][v8 + 1] == 30) *v42 = 29; } - if ( v12 == 28 ) - { + if (v12 == 28) { v43 = &dungeon[v10][v8 + 1]; - if ( *v43 == 9 ) + if (*v43 == 9) *v43 = 15; } - if ( v12 == 21 && dungeon[v10][v8 + 39] == 21 ) + if (v12 == 21 && dungeon[v10][v8 + 39] == 21) dungeon[v10 + 1][v8] = 24; - if ( v12 == 2 ) - { + if (v12 == 2) { v44 = &dungeon[v10 + 1][v8]; - if ( *v44 == 27 && dungeon[v10 + 1][v8 + 1] == 30 ) + if (*v44 == 27 && dungeon[v10 + 1][v8 + 1] == 30) *v44 = 29; v45 = &dungeon[v10 + 1][v8]; - if ( *v45 == 18 ) + if (*v45 == 18) *v45 = 25; } - if ( v12 == 21 ) - { + if (v12 == 21) { v46 = &dungeon[v10 + 1][v8]; - if ( *v46 == 9 && dungeon[v10 + 2][v8] == 2 ) + if (*v46 == 9 && dungeon[v10 + 2][v8] == 2) *v46 = 11; } - if ( v12 == 19 ) - { + if (v12 == 19) { v47 = &dungeon[v10 + 1][v8]; - if ( *v47 == 10 ) + if (*v47 == 10) *v47 = 17; } - if ( v12 == 15 ) - { + if (v12 == 15) { v48 = &dungeon[v10][v8 + 1]; - if ( *v48 == 3 ) + if (*v48 == 3) *v48 = 4; } - if ( v12 == 22 ) - { + if (v12 == 22) { v49 = &dungeon[v10][v8 + 1]; - if ( *v49 == 9 ) + if (*v49 == 9) *v49 = 15; } - if ( v12 == 18 ) - { + if (v12 == 18) { v50 = &dungeon[v10][v8 + 1]; - if ( *v50 == 30 ) + if (*v50 == 30) *v50 = 18; } - if ( v12 == 24 && *(v11 - 40) == 30 ) + if (v12 == 24 && *(v11 - 40) == 30) *(v11 - 40) = 19; - if ( v12 == 21 ) - { + if (v12 == 21) { v51 = &dungeon[v10][v8 + 1]; - if ( *v51 == 2 ) + if (*v51 == 2) *v51 = 15; v52 = &dungeon[v10][v8 + 1]; - if ( *v52 == 9 ) + if (*v52 == 9) *v52 = 10; } - if ( v12 == 22 ) - { + if (v12 == 22) { v53 = &dungeon[v10][v8 + 1]; - if ( *v53 == 30 ) + if (*v53 == 30) *v53 = 18; } - if ( v12 == 21 ) - { + if (v12 == 21) { v54 = &dungeon[v10][v8 + 1]; - if ( *v54 == 30 ) + if (*v54 == 30) *v54 = 18; } - if ( v12 == 16 ) - { + if (v12 == 16) { v55 = &dungeon[v10][v8 + 1]; - if ( *v55 == 2 ) + if (*v55 == 2) *v55 = 15; } - if ( v12 == 13 ) - { + if (v12 == 13) { v56 = &dungeon[v10][v8 + 1]; - if ( *v56 == 2 ) + if (*v56 == 2) *v56 = 15; } - if ( v12 == 22 ) - { + if (v12 == 22) { v57 = &dungeon[v10][v8 + 1]; - if ( *v57 == 2 ) + if (*v57 == 2) *v57 = 15; } - if ( v12 == 21 ) - { + if (v12 == 21) { v58 = &dungeon[v10 + 1][v8]; - if ( *v58 == 18 && dungeon[v10 + 2][v8] == 30 ) + if (*v58 == 18 && dungeon[v10 + 2][v8] == 30) *v58 = 24; v59 = &dungeon[v10 + 1][v8]; - if ( *v59 == 9 && dungeon[v10 + 1][v8 + 1] == 1 ) + if (*v59 == 9 && dungeon[v10 + 1][v8 + 1] == 1) *v59 = 16; } - if ( v12 == 2 ) - { + if (v12 == 2) { v60 = &dungeon[v10 + 1][v8]; - if ( *v60 == 27 && dungeon[v10 + 1][v8 + 1] == 2 ) + if (*v60 == 27 && dungeon[v10 + 1][v8 + 1] == 2) *v60 = 29; } - if ( v12 == 23 ) - { + if (v12 == 23) { v61 = &dungeon[v10][v8 + 1]; - if ( *v61 == 2 ) + if (*v61 == 2) *v61 = 15; v62 = &dungeon[v10][v8 + 1]; - if ( *v62 == 9 ) + if (*v62 == 9) *v62 = 15; } - if ( v12 == 25 ) - { + if (v12 == 25) { v63 = &dungeon[v10][v8 + 1]; - if ( *v63 == 2 ) + if (*v63 == 2) *v63 = 15; } - if ( v12 == 22 ) - { + if (v12 == 22) { v64 = &dungeon[v10 + 1][v8]; - if ( *v64 == 9 ) + if (*v64 == 9) *v64 = 11; } - if ( v12 == 23 ) - { + if (v12 == 23) { v65 = &dungeon[v10 + 1][v8]; - if ( *v65 == 9 ) + if (*v65 == 9) *v65 = 11; } - if ( v12 == 15 ) - { + if (v12 == 15) { v66 = &dungeon[v10 + 1][v8]; - if ( *v66 == 1 ) + if (*v66 == 1) *v66 = 16; } - if ( v12 == 11 ) - { + if (v12 == 11) { v67 = &dungeon[v10 + 1][v8]; - if ( *v67 == 15 ) + if (*v67 == 15) *v67 = 14; } - if ( v12 == 23 ) - { + if (v12 == 23) { v68 = &dungeon[v10 + 1][v8]; - if ( *v68 == 1 ) + if (*v68 == 1) *v68 = 16; } - if ( v12 == 21 ) - { + if (v12 == 21) { v69 = &dungeon[v10 + 1][v8]; - if ( *v69 == 27 ) + if (*v69 == 27) *v69 = 26; v70 = &dungeon[v10 + 1][v8]; - if ( *v70 == 18 ) + if (*v70 == 18) *v70 = 24; } - if ( v12 == 26 ) - { + if (v12 == 26) { v71 = &dungeon[v10 + 1][v8]; - if ( *v71 == 1 ) + if (*v71 == 1) *v71 = 16; } - if ( v12 == 29 ) - { + if (v12 == 29) { v72 = &dungeon[v10 + 1][v8]; - if ( *v72 == 1 ) + if (*v72 == 1) *v72 = 16; v73 = &dungeon[v10][v8 + 1]; - if ( *v73 == 2 ) + if (*v73 == 2) *v73 = 15; } - if ( v12 == 1 && *(v11 - 1) == 15 ) + if (v12 == 1 && *(v11 - 1) == 15) *(v11 - 1) = 10; - if ( v12 == 18 ) - { + if (v12 == 18) { v74 = &dungeon[v10][v8 + 1]; - if ( *v74 == 2 ) + if (*v74 == 2) *v74 = 15; } - if ( v12 == 23 ) - { + if (v12 == 23) { v75 = &dungeon[v10][v8 + 1]; - if ( *v75 == 30 ) + if (*v75 == 30) *v75 = 18; } - if ( v12 == 18 ) - { + if (v12 == 18) { v76 = &dungeon[v10][v8 + 1]; - if ( *v76 == 9 ) + if (*v76 == 9) *v76 = 10; } - if ( v12 == 14 ) - { + if (v12 == 14) { v77 = &dungeon[v10 + 1][v8]; - if ( *v77 == 30 && dungeon[v10 + 1][v8 + 1] == 30 ) + if (*v77 == 30 && dungeon[v10 + 1][v8 + 1] == 30) *v77 = 23; } - if ( v12 == 2 ) - { + if (v12 == 2) { v78 = &dungeon[v10 + 1][v8]; - if ( *v78 == 28 && dungeon[v10][v8 + 39] == 6 ) + if (*v78 == 28 && dungeon[v10][v8 + 39] == 6) *v78 = 23; } - if ( v12 == 23 ) - { + if (v12 == 23) { v79 = &dungeon[v10 + 1][v8]; - if ( *v79 == 18 && *(v11 - 1) == 6 ) + if (*v79 == 18 && *(v11 - 1) == 6) *v79 = 24; } - if ( v12 == 14 ) - { + if (v12 == 14) { v80 = &dungeon[v10 + 1][v8]; - if ( *v80 == 23 && dungeon[v10 + 2][v8] == 30 ) + if (*v80 == 23 && dungeon[v10 + 2][v8] == 30) *v80 = 28; v81 = &dungeon[v10 + 1][v8]; - if ( *v81 == 28 && dungeon[v10 + 2][v8] == 30 && dungeon[v10][v8 + 39] == 6 ) + if (*v81 == 28 && dungeon[v10 + 2][v8] == 30 && dungeon[v10][v8 + 39] == 6) *v81 = 23; } - if ( v12 == 23 ) - { + if (v12 == 23) { v82 = &dungeon[v10 + 1][v8]; - if ( *v82 == 30 ) + if (*v82 == 30) *v82 = 19; } - if ( v12 == 29 ) - { + if (v12 == 29) { v83 = &dungeon[v10 + 1][v8]; - if ( *v83 == 30 ) + if (*v83 == 30) *v83 = 19; v84 = &dungeon[v10][v8 + 1]; - if ( *v84 == 30 ) + if (*v84 == 30) *v84 = 18; } - if ( v12 == 19 ) - { + if (v12 == 19) { v85 = &dungeon[v10 + 1][v8]; - if ( *v85 == 30 ) + if (*v85 == 30) *v85 = 19; } - if ( v12 == 21 ) - { + if (v12 == 21) { v86 = &dungeon[v10 + 1][v8]; - if ( *v86 == 30 ) + if (*v86 == 30) *v86 = 19; } - if ( v12 == 26 ) - { + if (v12 == 26) { v87 = &dungeon[v10 + 1][v8]; - if ( *v87 == 30 ) + if (*v87 == 30) *v87 = 19; } - if ( v12 == 16 ) - { + if (v12 == 16) { v88 = &dungeon[v10][v8 + 1]; - if ( *v88 == 30 ) + if (*v88 == 30) *v88 = 18; } - if ( v12 == 13 ) - { + if (v12 == 13) { v89 = &dungeon[v10][v8 + 1]; - if ( *v89 == 9 ) + if (*v89 == 9) *v89 = 10; } - if ( v12 == 25 ) - { + if (v12 == 25) { v90 = &dungeon[v10][v8 + 1]; - if ( *v90 == 30 ) + if (*v90 == 30) *v90 = 18; } - if ( v12 == 18 ) - { + if (v12 == 18) { v91 = &dungeon[v10][v8 + 1]; - if ( *v91 == 2 ) + if (*v91 == 2) *v91 = 15; } - if ( v12 == 11 ) - { + if (v12 == 11) { v92 = &dungeon[v10 + 1][v8]; - if ( *v92 == 3 ) + if (*v92 == 3) *v92 = 5; } - if ( v12 == 19 ) - { + if (v12 == 19) { v93 = &dungeon[v10 + 1][v8]; - if ( *v93 == 9 ) + if (*v93 == 9) *v93 = 11; v94 = &dungeon[v10 + 1][v8]; - if ( *v94 == 1 ) + if (*v94 == 1) *v94 = 13; v95 = &dungeon[v10 + 1][v8]; - if ( *v95 == 13 && dungeon[v10][v8 + 39] == 6 ) + if (*v95 == 13 && dungeon[v10][v8 + 39] == 6) *v95 = 16; } v9 = v139++ + 1; - } - while ( v139 < 40 ); + } while (v139 < 40); ++v8; - } - while ( v8 < 40 ); + } while (v8 < 40); v96 = 0; - do - { + do { v97 = 0; - do - { + do { v98 = v97; v99 = &dungeon[v97][v96]; v100 = *v99; - if ( *v99 == 21 ) - { + if (*v99 == 21) { v101 = &dungeon[v98][v96 + 1]; - if ( *v101 == 24 && dungeon[v98][v96 + 2] == 1 ) + if (*v101 == 24 && dungeon[v98][v96 + 2] == 1) *v101 = 17; } - if ( v100 == 15 - && dungeon[v98 + 1][v96 + 1] == 9 - && dungeon[v98][v96 + 39] == 1 - && dungeon[v98 + 2][v96] == 16 ) - { + if (v100 == 15 + && dungeon[v98 + 1][v96 + 1] == 9 + && dungeon[v98][v96 + 39] == 1 + && dungeon[v98 + 2][v96] == 16) { dungeon[v98 + 1][v96] = 29; } - if ( v100 == 2 && *(v99 - 40) == 6 ) + if (v100 == 2 && *(v99 - 40) == 6) *(v99 - 40) = 8; - if ( v100 == 1 && *(v99 - 1) == 6 ) + if (v100 == 1 && *(v99 - 1) == 6) *(v99 - 1) = 7; - if ( v100 == 6 ) - { + if (v100 == 6) { v102 = &dungeon[v98 + 1][v96]; - if ( *v102 == 15 && dungeon[v98 + 1][v96 + 1] == 4 ) + if (*v102 == 15 && dungeon[v98 + 1][v96 + 1] == 4) *v102 = 10; } - if ( v100 == 1 ) - { + if (v100 == 1) { v103 = &dungeon[v98][v96 + 1]; - if ( *v103 == 3 ) + if (*v103 == 3) *v103 = 4; v104 = &dungeon[v98][v96 + 1]; - if ( *v104 == 6 ) + if (*v104 == 6) *v104 = 4; } - if ( v100 == 9 ) - { + if (v100 == 9) { v105 = &dungeon[v98][v96 + 1]; - if ( *v105 == 3 ) + if (*v105 == 3) *v105 = 4; } - if ( v100 == 10 ) - { + if (v100 == 10) { v106 = &dungeon[v98][v96 + 1]; - if ( *v106 == 3 ) + if (*v106 == 3) *v106 = 4; } - if ( v100 == 13 ) - { + if (v100 == 13) { v107 = &dungeon[v98][v96 + 1]; - if ( *v107 == 3 ) + if (*v107 == 3) *v107 = 4; } - if ( v100 == 1 ) - { + if (v100 == 1) { v108 = &dungeon[v98][v96 + 1]; - if ( *v108 == 5 ) + if (*v108 == 5) *v108 = 12; v109 = &dungeon[v98][v96 + 1]; - if ( *v109 == 16 ) + if (*v109 == 16) *v109 = 13; } - if ( v100 == 6 ) - { + if (v100 == 6) { v110 = &dungeon[v98][v96 + 1]; - if ( *v110 == 13 ) + if (*v110 == 13) *v110 = 16; } - if ( v100 == 25 ) - { + if (v100 == 25) { v111 = &dungeon[v98][v96 + 1]; - if ( *v111 == 9 ) + if (*v111 == 9) *v111 = 10; } - if ( v100 == 13 ) - { + if (v100 == 13) { v112 = &dungeon[v98][v96 + 1]; - if ( *v112 == 5 ) + if (*v112 == 5) *v112 = 12; } - if ( v100 == 28 && *(v99 - 1) == 6 ) - { + if (v100 == 28 && *(v99 - 1) == 6) { v113 = &dungeon[v98 + 1][v96]; - if ( *v113 == 1 ) + if (*v113 == 1) *v113 = 23; } - if ( v100 == 19 ) - { + if (v100 == 19) { v114 = &dungeon[v98 + 1][v96]; - if ( *v114 == 10 ) + if (*v114 == 10) *v114 = 17; } - if ( v100 == 21 ) - { + if (v100 == 21) { v115 = &dungeon[v98 + 1][v96]; - if ( *v115 == 9 ) + if (*v115 == 9) *v115 = 11; } - if ( v100 == 11 ) - { + if (v100 == 11) { v116 = &dungeon[v98 + 1][v96]; - if ( *v116 == 3 ) + if (*v116 == 3) *v116 = 5; } - if ( v100 == 10 ) - { + if (v100 == 10) { v117 = &dungeon[v98 + 1][v96]; - if ( *v117 == 4 ) + if (*v117 == 4) *v117 = 12; } - if ( v100 == 14 ) - { + if (v100 == 14) { v118 = &dungeon[v98 + 1][v96]; - if ( *v118 == 4 ) + if (*v118 == 4) *v118 = 12; } - if ( v100 == 27 ) - { + if (v100 == 27) { v119 = &dungeon[v98 + 1][v96]; - if ( *v119 == 9 ) + if (*v119 == 9) *v119 = 11; } - if ( v100 == 15 ) - { + if (v100 == 15) { v120 = &dungeon[v98 + 1][v96]; - if ( *v120 == 4 ) + if (*v120 == 4) *v120 = 12; } - if ( v100 == 21 ) - { + if (v100 == 21) { v121 = &dungeon[v98 + 1][v96]; - if ( *v121 == 1 ) + if (*v121 == 1) *v121 = 16; } - if ( v100 == 11 ) - { + if (v100 == 11) { v122 = &dungeon[v98 + 1][v96]; - if ( *v122 == 4 ) + if (*v122 == 4) *v122 = 12; } - if ( v100 == 2 ) - { + if (v100 == 2) { v123 = &dungeon[v98 + 1][v96]; - if ( *v123 == 3 ) + if (*v123 == 3) *v123 = 5; } - if ( v100 == 9 ) - { + if (v100 == 9) { v124 = &dungeon[v98 + 1][v96]; - if ( *v124 == 3 ) + if (*v124 == 3) *v124 = 5; } - if ( v100 == 14 ) - { + if (v100 == 14) { v125 = &dungeon[v98 + 1][v96]; - if ( *v125 == 3 ) + if (*v125 == 3) *v125 = 5; } - if ( v100 == 15 ) - { + if (v100 == 15) { v126 = &dungeon[v98 + 1][v96]; - if ( *v126 == 3 ) + if (*v126 == 3) *v126 = 5; } - if ( v100 == 2 ) - { + if (v100 == 2) { v127 = &dungeon[v98 + 1][v96]; - if ( *v127 == 5 && dungeon[v98][v96 + 39] == 16 ) + if (*v127 == 5 && dungeon[v98][v96 + 39] == 16) *v127 = 12; v128 = &dungeon[v98 + 1][v96]; - if ( *v128 == 4 ) + if (*v128 == 4) *v128 = 12; } - if ( v100 == 9 ) - { + if (v100 == 9) { v129 = &dungeon[v98 + 1][v96]; - if ( *v129 == 4 ) + if (*v129 == 4) *v129 = 12; } - if ( v100 == 1 && *(v99 - 1) == 8 ) + if (v100 == 1 && *(v99 - 1) == 8) *(v99 - 1) = 9; - if ( v100 == 28 ) - { + if (v100 == 28) { v130 = &dungeon[v98 + 1][v96]; - if ( *v130 == 23 && dungeon[v98 + 1][v96 + 1] == 3 ) + if (*v130 == 23 && dungeon[v98 + 1][v96 + 1] == 3) *v130 = 16; } ++v97; - } - while ( v97 < 40 ); + } while (v97 < 40); ++v96; - } - while ( v96 < 40 ); + } while (v96 < 40); v131 = 0; - do - { + do { v132 = &dungeon[0][v131 + 1]; v133 = 40; - do - { + do { v134 = *(v132 - 1); - if ( v134 == 21 && v132[39] == 10 ) + if (v134 == 21 && v132[39] == 10) v132[39] = 17; - if ( v134 == 17 && v132[39] == 4 ) + if (v134 == 17 && v132[39] == 4) v132[39] = 12; - if ( v134 == 10 && v132[39] == 4 ) + if (v134 == 10 && v132[39] == 4) v132[39] = 12; - if ( v134 == 17 && *v132 == 5 ) + if (v134 == 17 && *v132 == 5) *v132 = 12; - if ( v134 == 29 && *v132 == 9 ) + if (v134 == 29 && *v132 == 9) *v132 = 10; - if ( v134 == 13 && *v132 == 5 ) + if (v134 == 13 && *v132 == 5) *v132 = 12; - if ( v134 == 9 && *v132 == 16 ) + if (v134 == 9 && *v132 == 16) *v132 = 13; - if ( v134 == 10 && *v132 == 16 ) + if (v134 == 10 && *v132 == 16) *v132 = 13; - if ( v134 == 16 && *v132 == 3 ) + if (v134 == 16 && *v132 == 3) *v132 = 4; - if ( v134 == 11 && *v132 == 5 ) + if (v134 == 11 && *v132 == 5) *v132 = 12; - if ( v134 == 10 && v132[39] == 3 && v132[38] == 16 ) + if (v134 == 10 && v132[39] == 3 && v132[38] == 16) v132[39] = 12; - if ( v134 == 16 && *v132 == 5 ) + if (v134 == 16 && *v132 == 5) *v132 = 12; - if ( v134 == 1 && *v132 == 6 ) + if (v134 == 1 && *v132 == 6) *v132 = 4; - if ( v134 == 21 && v132[39] == 13 && *v132 == 10 ) + if (v134 == 21 && v132[39] == 13 && *v132 == 10) v132[40] = 12; - if ( v134 == 15 && v132[39] == 10 ) + if (v134 == 15 && v132[39] == 10) v132[39] = 17; - if ( v134 == 22 && *v132 == 11 ) + if (v134 == 22 && *v132 == 11) *v132 = 17; - if ( v134 == 15 && v132[39] == 28 && v132[79] == 16 ) + if (v134 == 15 && v132[39] == 28 && v132[79] == 16) v132[39] = 23; - if ( v134 == 28 && v132[39] == 23 && v132[40] == 1 && v132[79] == 6 ) + if (v134 == 28 && v132[39] == 23 && v132[40] == 1 && v132[79] == 6) v132[39] = 16; v132 += 40; --v133; - } - while ( v133 ); + } while (v133); ++v131; - } - while ( v131 < 40 ); + } while (v131 < 40); v135 = 0; - do - { + do { v136 = (char *)dungeon + v135; v137 = 40; - do - { + do { v138 = *v136; - if ( *v136 == 15 && v136[40] == 28 && v136[80] == 16 ) + if (*v136 == 15 && v136[40] == 28 && v136[80] == 16) v136[40] = 23; - if ( v138 == 21 && v136[39] == 21 && v136[41] == 13 && v136[80] == 2 ) + if (v138 == 21 && v136[39] == 21 && v136[41] == 13 && v136[80] == 2) v136[40] = 17; - if ( v138 == 19 && v136[40] == 15 && v136[41] == 12 ) + if (v138 == 19 && v136[40] == 15 && v136[41] == 12) v136[40] = 17; v136 += 40; --v137; - } - while ( v137 ); + } while (v137); ++v135; - } - while ( v135 < 40 ); + } while (v135 < 40); } void __cdecl DRLG_L4Subs() { - signed int v0; // edi - signed int v1; // esi - signed int v2; // ebp + signed int v0; // edi + signed int v1; // esi + signed int v2; // ebp unsigned char v3; // bl - int v4; // eax - signed int v5; // ecx - signed int v6; // edi - signed int v7; // esi - signed int v8; // ebx + int v4; // eax + signed int v5; // ecx + signed int v6; // edi + signed int v7; // esi + signed int v8; // ebx v0 = 0; - do - { + do { v1 = v0; v2 = 40; - do - { - if ( !random(0, 3) ) - { + do { + if (!random(0, 3)) { v3 = L4BTYPES[(unsigned char)dungeon[0][v1]]; - if ( v3 ) - { - if ( !dflags[0][v1] ) - { + if (v3) { + if (!dflags[0][v1]) { v4 = random(0, 16); v5 = -1; - while ( v4 >= 0 ) - { - if ( ++v5 == 140 ) + while (v4 >= 0) { + if (++v5 == 140) v5 = 0; - if ( v3 == L4BTYPES[v5] ) + if (v3 == L4BTYPES[v5]) --v4; } dungeon[0][v1] = v5; @@ -2306,66 +2061,58 @@ void __cdecl DRLG_L4Subs() } v1 += 40; --v2; - } - while ( v2 ); + } while (v2); ++v0; - } - while ( v0 < 40 ); + } while (v0 < 40); v6 = 0; - do - { + do { v7 = v6; v8 = 40; - do - { - if ( !random(0, 10) && L4BTYPES[(unsigned char)dungeon[0][v7]] == 6 && !dflags[0][v7] ) + do { + if (!random(0, 10) && L4BTYPES[(unsigned char)dungeon[0][v7]] == 6 && !dflags[0][v7]) dungeon[0][v7] = random(0, 3) + 95; v7 += 40; --v8; - } - while ( v8 ); + } while (v8); ++v6; - } - while ( v6 < 40 ); + } while (v6 < 40); } void __cdecl L4makeDungeon() { - signed int v0; // ebx - signed int v1; // esi - char *v2; // edx - char v3; // cl - int v4; // eax - int v5; // eax - int v6; // ebx - char *v7; // esi - signed int v8; // edx - char v9; // cl - int v10; // eax - int v11; // eax + signed int v0; // ebx + signed int v1; // esi + char *v2; // edx + char v3; // cl + int v4; // eax + int v5; // eax + int v6; // ebx + char *v7; // esi + signed int v8; // edx + char v9; // cl + int v10; // eax + int v11; // eax signed int v12; // ebx signed int v13; // esi - char *v14; // edx - char v15; // cl - int v16; // eax - int v17; // eax - int v18; // ebx - char *v19; // esi + char *v14; // edx + char v15; // cl + int v16; // eax + int v17; // eax + int v18; // ebx + char *v19; // esi signed int v20; // edx - char v21; // cl - int v22; // eax - int v23; // eax + char v21; // cl + int v22; // eax + int v23; // eax signed int v24; // [esp+Ch] [ebp-8h] - char *v25; // [esp+10h] [ebp-4h] - char *v26; // [esp+10h] [ebp-4h] + char *v25; // [esp+10h] [ebp-4h] + char *v26; // [esp+10h] [ebp-4h] v0 = 0; - do - { + do { v1 = 0; v2 = (char *)dung + v0; - do - { + do { v3 = *v2; v2 += 20; v4 = 160 * v1++; @@ -2374,20 +2121,16 @@ void __cdecl L4makeDungeon() L4dungeon[0][v5 + 1] = v3; L4dungeon[1][v5] = v3; L4dungeon[1][v5 + 1] = v3; - } - while ( v1 < 20 ); + } while (v1 < 20); ++v0; - } - while ( v0 < 20 ); + } while (v0 < 20); v6 = 0; v25 = &dung[0][19]; v24 = 20; - do - { + do { v7 = v25; v8 = 0; - do - { + do { v9 = *v7; v7 += 20; v10 = 160 * v8++; @@ -2396,20 +2139,16 @@ void __cdecl L4makeDungeon() L4dungeon[0][v11 + 41] = v9; L4dungeon[1][v11 + 40] = v9; L4dungeon[1][v11 + 41] = v9; - } - while ( v8 < 20 ); + } while (v8 < 20); ++v6; --v25; --v24; - } - while ( v24 ); + } while (v24); v12 = 0; - do - { + do { v13 = 0; v14 = &dung[19][v12]; - do - { + do { v15 = *v14; v14 -= 20; v16 = 160 * v13++; @@ -2418,19 +2157,15 @@ void __cdecl L4makeDungeon() L4dungeon[40][v17 + 1] = v15; L4dungeon[41][v17] = v15; L4dungeon[41][v17 + 1] = v15; - } - while ( v13 < 20 ); + } while (v13 < 20); ++v12; - } - while ( v12 < 20 ); + } while (v12 < 20); v18 = 0; v26 = &dung[19][19]; - do - { + do { v19 = v26; v20 = 0; - do - { + do { v21 = *v19; v19 -= 20; v22 = 160 * v20++; @@ -2439,154 +2174,118 @@ void __cdecl L4makeDungeon() L4dungeon[40][v23 + 41] = v21; L4dungeon[41][v23 + 40] = v21; L4dungeon[41][v23 + 41] = v21; - } - while ( v20 < 20 ); + } while (v20 < 20); ++v18; --v26; - } - while ( (signed int)v26 > (signed int)&dung[18][19] ); + } while ((signed int)v26 > (signed int)&dung[18][19]); } void __cdecl uShape() { - int v0; // ecx - signed int v1; // esi - signed int v2; // eax - char v3; // dl - int v4; // eax - signed int v5; // esi - int v6; // ecx - int v7; // ecx - int *v8; // esi - signed int v9; // eax - char v10; // dl - int v11; // eax + int v0; // ecx + signed int v1; // esi + signed int v2; // eax + char v3; // dl + int v4; // eax + signed int v5; // esi + int v6; // ecx + int v7; // ecx + int *v8; // esi + signed int v9; // eax + char v10; // dl + int v11; // eax signed int v12; // esi - char *v13; // edx + char *v13; // edx v0 = 19; - do - { + do { v1 = 19; - do - { + do { v2 = v1; v3 = dung[v1][v0]; - if ( v3 == 1 || (hallok[v0] = 0, v3 == 1) ) - { + if (v3 == 1 || (hallok[v0] = 0, v3 == 1)) { hallok[v0] = dung[v2][v0 + 1] == 1 && !dung[v2 + 1][v0 + 1]; v1 = 0; } --v1; - } - while ( v1 >= 0 ); + } while (v1 >= 0); --v0; - } - while ( v0 >= 0 ); + } while (v0 >= 0); v4 = random(0, 19) + 1; - do - { - if ( hallok[v4] ) - { + do { + if (hallok[v4]) { v5 = 19; - do - { + do { v6 = v4 + 20 * v5; - if ( dung[0][v6] == 1 ) - { + if (dung[0][v6] == 1) { v5 = -1; v4 = 0; - } - else - { + } else { dung[0][v6] = 1; dung[0][v6 + 1] = 1; } --v5; - } - while ( v5 >= 0 ); - } - else if ( ++v4 == 20 ) - { + } while (v5 >= 0); + } else if (++v4 == 20) { v4 = 1; } - } - while ( v4 ); + } while (v4); v7 = 380; v8 = &hallok[19]; - do - { + do { v9 = 19; - do - { + do { v10 = dung[0][v7 + v9]; - if ( v10 == 1 || (*v8 = 0, v10 == 1) ) - { + if (v10 == 1 || (*v8 = 0, v10 == 1)) { *v8 = dung[1][v7 + v9] == 1 && !dung[1][v7 + 1 + v9]; v9 = 0; } --v9; - } - while ( v9 >= 0 ); + } while (v9 >= 0); --v8; v7 -= 20; - } - while ( (signed int)v8 >= (signed int)hallok ); + } while ((signed int)v8 >= (signed int)hallok); v11 = random(0, 19) + 1; - do - { - if ( hallok[v11] ) - { + do { + if (hallok[v11]) { v12 = 19; - do - { + do { v13 = &dung[v11][v12]; - if ( *v13 == 1 ) - { + if (*v13 == 1) { v12 = -1; v11 = 0; - } - else - { + } else { *v13 = 1; dung[v11 + 1][v12] = 1; } --v12; - } - while ( v12 >= 0 ); - } - else if ( ++v11 == 20 ) - { + } while (v12 >= 0); + } else if (++v11 == 20) { v11 = 1; } - } - while ( v11 ); + } while (v11); } int __cdecl GetArea() { - int result; // eax + int result; // eax signed int v1; // edx - _BYTE *v2; // ecx + _BYTE *v2; // ecx signed int v3; // esi result = 0; v1 = 0; - do - { + do { v2 = (unsigned char *)dung + v1; v3 = 20; - do - { - if ( *v2 == 1 ) + do { + if (*v2 == 1) ++result; v2 += 20; --v3; - } - while ( v3 ); + } while (v3); ++v1; - } - while ( v1 < 20 ); + } while (v1 < 20); return result; } @@ -2599,19 +2298,15 @@ void __cdecl L4firstRoom() int v4; // eax int v5; // ebp //int v6; // eax - int v7; // eax - int v8; // eax + int v7; // eax + int v8; // eax signed int v9; // [esp-4h] [ebp-18h] - if ( currlevel == 16 ) - { + if (currlevel == 16) { v9 = 14; - } - else - { - if ( (currlevel != quests[QTYPE_WARLRD]._qlevel || !quests[QTYPE_WARLRD]._qactive) - && (currlevel != quests[QTYPE_VB]._qlevel || gbMaxPlayers == 1) ) - { + } else { + if ((currlevel != quests[QTYPE_WARLRD]._qlevel || !quests[QTYPE_WARLRD]._qactive) + && (currlevel != quests[QTYPE_VB]._qlevel || gbMaxPlayers == 1)) { v0 = random(0, 5) + 2; v1 = random(0, 5) + 2; goto LABEL_10; @@ -2623,27 +2318,23 @@ void __cdecl L4firstRoom() LABEL_10: v2 = 20 - v0; v3 = ((20 - v0) >> 1) + random(0, 20 - ((20 - v0) >> 1) - v0); - if ( v3 + v0 <= 19 ) + if (v3 + v0 <= 19) v2 = v3; v4 = ((20 - v1) >> 1) + random(0, 20 - ((20 - v1) >> 1) - v1); v5 = 20 - v1; - if ( v4 + v1 <= 19 ) + if (v4 + v1 <= 19) v5 = v4; - if ( currlevel == 16 ) - { + if (currlevel == 16) { l4holdx = v2; l4holdy = v5; } //_LOBYTE(v6) = QuestStatus(QTYPE_WARLRD); - if ( QuestStatus(QTYPE_WARLRD) || currlevel == quests[QTYPE_VB]._qlevel && gbMaxPlayers != 1 ) - { + if (QuestStatus(QTYPE_WARLRD) || currlevel == quests[QTYPE_VB]._qlevel && gbMaxPlayers != 1) { SP4x1 = v2 + 1; SP4y1 = v5 + 1; v7 = v0 + v2 + 1; SP4y2 = v1 + v5 + 1; - } - else - { + } else { v7 = 0; SP4x1 = 0; SP4y1 = 0; @@ -2662,76 +2353,69 @@ LABEL_10: void __fastcall L4drawRoom(int x, int y, int width, int height) { - int i; // esi - int v5; // edi + int i; // esi + int v5; // edi char *v6; // eax - for ( i = 0; i < height; ++i ) - { - if ( width > 0 ) - { + for (i = 0; i < height; ++i) { + if (width > 0) { v5 = width; v6 = &dung[x][i + y]; - do - { + do { *v6 = 1; v6 += 20; --v5; - } - while ( v5 ); + } while (v5); } } } void __fastcall L4roomGen(int x, int y, int w, int h, int dir) { - int v5; // eax - int v6; // ecx - int v7; // eax - int v8; // ecx - int v9; // eax - int v11; // esi - int v12; // edi - int v13; // ebx - int v14; // eax - int v15; // eax - int v17; // esi - int v18; // edi - int v19; // ebx - int v20; // eax - int ya; // [esp+Ch] [ebp-10h] - int yb; // [esp+Ch] [ebp-10h] - int v23; // [esp+10h] [ebp-Ch] - int v24; // [esp+10h] [ebp-Ch] - int xa; // [esp+14h] [ebp-8h] - int xb; // [esp+14h] [ebp-8h] - int v27; // [esp+18h] [ebp-4h] - int wa; // [esp+24h] [ebp+8h] - int ha; // [esp+28h] [ebp+Ch] - int hb; // [esp+28h] [ebp+Ch] - int hc; // [esp+28h] [ebp+Ch] + int v5; // eax + int v6; // ecx + int v7; // eax + int v8; // ecx + int v9; // eax + int v11; // esi + int v12; // edi + int v13; // ebx + int v14; // eax + int v15; // eax + int v17; // esi + int v18; // edi + int v19; // ebx + int v20; // eax + int ya; // [esp+Ch] [ebp-10h] + int yb; // [esp+Ch] [ebp-10h] + int v23; // [esp+10h] [ebp-Ch] + int v24; // [esp+10h] [ebp-Ch] + int xa; // [esp+14h] [ebp-8h] + int xb; // [esp+14h] [ebp-8h] + int v27; // [esp+18h] [ebp-4h] + int wa; // [esp+24h] [ebp+8h] + int ha; // [esp+28h] [ebp+Ch] + int hb; // [esp+28h] [ebp+Ch] + int hc; // [esp+28h] [ebp+Ch] int dira; // [esp+2Ch] [ebp+10h] int dirb; // [esp+2Ch] [ebp+10h] v27 = y; xa = x; - while ( 1 ) - { - while ( 1 ) - { + while (1) { + while (1) { v5 = random(0, 4); v6 = 0; _LOBYTE(v6) = dir == 1 ? v5 != 0 : v5 == 0; v7 = v6; v8 = 0; - if ( !v7 ) + if (!v7) break; - if ( v7 != 1 ) + if (v7 != 1) return; dira = 0; wa = w / 2; - do - { + do { v9 = random(0, 5); v11 = (v9 + 2) & 0xFFFFFFFE; v12 = (random(0, 5) + 2) & 0xFFFFFFFE; @@ -2740,17 +2424,16 @@ void __fastcall L4roomGen(int x, int y, int w, int h, int dir) v14 = L4checkRoom(v13 - 1, v27 - v12 - 1, v11 + 2, v12 + 1); ++dira; v23 = v14; - } - while ( !v14 && dira < 20 ); - if ( v14 == 1 ) + } while (!v14 && dira < 20); + if (v14 == 1) L4drawRoom(v13, ya, v11, v12); xb = v27 + h; ha = L4checkRoom(v13 - 1, v27 + h, v11 + 2, v12 + 1); - if ( ha == 1 ) + if (ha == 1) L4drawRoom(v13, xb, v11, v12); - if ( v23 == 1 ) + if (v23 == 1) L4roomGen(v13, ya, v11, v12, 0); - if ( ha != 1 ) + if (ha != 1) return; dir = 0; h = v12; @@ -2760,8 +2443,7 @@ void __fastcall L4roomGen(int x, int y, int w, int h, int dir) } dirb = 0; hb = h / 2; - do - { + do { v15 = random(0, 5); v17 = (v15 + 2) & 0xFFFFFFFE; v18 = (random(0, 5) + 2) & 0xFFFFFFFE; @@ -2770,17 +2452,16 @@ void __fastcall L4roomGen(int x, int y, int w, int h, int dir) v20 = L4checkRoom(xa - v17 - 1, v19 - 1, v18 + 2, v17 + 1); ++dirb; v24 = v20; - } - while ( !v20 && dirb < 20 ); - if ( v20 == 1 ) + } while (!v20 && dirb < 20); + if (v20 == 1) L4drawRoom(yb, v19, v17, v18); xa += w; hc = L4checkRoom(xa, v19 - 1, v17 + 1, v18 + 2); - if ( hc == 1 ) + if (hc == 1) L4drawRoom(xa, v19, v17, v18); - if ( v24 == 1 ) + if (v24 == 1) L4roomGen(yb, v19, v17, v18, 1); - if ( hc != 1 ) + if (hc != 1) break; dir = 1; h = v18; @@ -2791,33 +2472,30 @@ void __fastcall L4roomGen(int x, int y, int w, int h, int dir) bool __fastcall L4checkRoom(int x, int y, int width, int height) { - int v4; // esi - int v5; // ebx + int v4; // esi + int v5; // ebx char *v6; // edi - int v8; // [esp+Ch] [ebp-4h] + int v8; // [esp+Ch] [ebp-4h] v4 = 0; - if ( x > 0 && y > 0 ) - { - if ( height <= 0 ) + if (x > 0 && y > 0) { + if (height <= 0) return 1; - while ( 1 ) - { + while (1) { v8 = 0; - if ( width > 0 ) + if (width > 0) break; -LABEL_12: - if ( ++v4 >= height ) + LABEL_12: + if (++v4 >= height) return 1; } v5 = x; v6 = &dung[x][v4 + y]; - while ( v5 >= 0 && v5 < 20 && v4 + y >= 0 && v4 + y < 20 && !*v6 ) - { + while (v5 >= 0 && v5 < 20 && v4 + y >= 0 && v4 + y < 20 && !*v6) { ++v8; v6 += 20; ++v5; - if ( v8 >= width ) + if (v8 >= width) goto LABEL_12; } } @@ -2826,33 +2504,33 @@ LABEL_12: bool __fastcall DRLG_L4PlaceMiniSet(const unsigned char *miniset, int tmin, int tmax, int cx, int cy, int setview, int ldir) { - int v7; // ebx - int v8; // esi - int v9; // edi - int v10; // edx - int v11; // esi - int v12; // ebx - int v13; // edi - signed int i; // eax - int v15; // ecx - unsigned char v16; // dl - int v17; // eax - int j; // ecx - int v19; // edi - int v20; // edx - char v21; // bl - bool result; // al + int v7; // ebx + int v8; // esi + int v9; // edi + int v10; // edx + int v11; // esi + int v12; // ebx + int v13; // edi + signed int i; // eax + int v15; // ecx + unsigned char v16; // dl + int v17; // eax + int j; // ecx + int v19; // edi + int v20; // edx + char v21; // bl + bool result; // al const unsigned char *v23; // [esp+Ch] [ebp-28h] - int v24; // [esp+10h] [ebp-24h] - int v25; // [esp+14h] [ebp-20h] - int v26; // [esp+18h] [ebp-1Ch] - signed int v27; // [esp+1Ch] [ebp-18h] - int v28; // [esp+20h] [ebp-14h] - int v29; // [esp+24h] [ebp-10h] - int v30; // [esp+28h] [ebp-Ch] - int max; // [esp+2Ch] [ebp-8h] + int v24; // [esp+10h] [ebp-24h] + int v25; // [esp+14h] [ebp-20h] + int v26; // [esp+18h] [ebp-1Ch] + signed int v27; // [esp+1Ch] [ebp-18h] + int v28; // [esp+20h] [ebp-14h] + int v29; // [esp+24h] [ebp-10h] + int v30; // [esp+28h] [ebp-Ch] + int max; // [esp+2Ch] [ebp-8h] //int v32; // [esp+30h] [ebp-4h] - int v33; // [esp+30h] [ebp-4h] + int v33; // [esp+30h] [ebp-4h] int tmaxa; // [esp+3Ch] [ebp+8h] v7 = miniset[1]; @@ -2862,127 +2540,104 @@ bool __fastcall DRLG_L4PlaceMiniSet(const unsigned char *miniset, int tmin, int v10 = tmax - tmin; v28 = *miniset; v29 = miniset[1]; - if ( v10 ) + if (v10) v24 = v8 + random(0, v10); else v24 = 1; v25 = 0; - if ( v24 <= 0 ) - { + if (v24 <= 0) { v11 = tmax; v12 = 0; /* v32 */ - } - else - { + } else { max = 40 - v9; v30 = 40 - v7; - do - { + do { v11 = random(0, max); v27 = 0; v12 = random(0, v30); v33 = v12; - do - { - if ( v27 >= 200 ) + do { + if (v27 >= 200) return 0; tmaxa = 1; - if ( v11 >= SP4x1 && v11 <= SP4x2 && v12 >= SP4y1 && v12 <= SP4y2 ) + if (v11 >= SP4x1 && v11 <= SP4x2 && v12 >= SP4y1 && v12 <= SP4y2) tmaxa = 0; - if ( cx != -1 && v11 >= cx - v28 && v11 <= cx + 12 ) - { + if (cx != -1 && v11 >= cx - v28 && v11 <= cx + 12) { v11 = random(0, max); tmaxa = 0; v33 = random(0, v30); v12 = v33; } - if ( cy != -1 && v12 >= cy - v29 && v12 <= cy + 12 ) - { + if (cy != -1 && v12 >= cy - v29 && v12 <= cy + 12) { v11 = random(0, max); tmaxa = 0; v33 = random(0, v30); v12 = v33; } v13 = 0; - for ( i = 2; v13 < v29; ++v13 ) - { - if ( tmaxa != 1 ) + for (i = 2; v13 < v29; ++v13) { + if (tmaxa != 1) break; v26 = 0; - if ( v28 > 0 ) - { + if (v28 > 0) { v15 = v12 + v13 + 40 * v11; - do - { - if ( tmaxa != 1 ) + do { + if (tmaxa != 1) break; v16 = v23[i]; - if ( v16 && dungeon[0][v15] != v16 ) + if (v16 && dungeon[0][v15] != v16) tmaxa = 0; - if ( dflags[0][v15] ) + if (dflags[0][v15]) tmaxa = 0; ++i; ++v26; v15 += 40; - } - while ( v26 < v28 ); + } while (v26 < v28); } } - if ( !tmaxa && ++v11 == max ) - { + if (!tmaxa && ++v11 == max) { v11 = 0; v33 = ++v12; - if ( v12 == v30 ) - { + if (v12 == v30) { v33 = 0; v12 = 0; } } ++v27; - } - while ( !tmaxa ); - if ( v27 >= 200 ) + } while (!tmaxa); + if (v27 >= 200) return 0; v17 = 0; - for ( j = v28 * v29 + 2; v17 < v29; ++v17 ) - { + for (j = v28 * v29 + 2; v17 < v29; ++v17) { v19 = v28; - if ( v28 > 0 ) - { + if (v28 > 0) { v20 = v12 + v17 + 40 * v11; - do - { + do { v21 = v23[j]; - if ( v21 ) - { + if (v21) { dflags[0][v20] |= DFLAG_POPULATED; dungeon[0][v20] = v21; } ++j; v20 += 40; --v19; - } - while ( v19 ); + } while (v19); v12 = v33; } } ++v25; - } - while ( v25 < v24 ); + } while (v25 < v24); } - if ( currlevel == 15 ) - { + if (currlevel == 15) { quests[QTYPE_VB]._qtx = v11 + 1; quests[QTYPE_VB]._qty = v12 + 1; } result = 1; - if ( setview == 1 ) - { + if (setview == 1) { ViewX = 2 * v11 + 21; ViewY = 2 * v12 + 22; } - if ( !ldir ) - { + if (!ldir) { LvlViewX = 2 * v11 + 21; LvlViewY = 2 * v12 + 22; } @@ -2995,25 +2650,22 @@ bool __fastcall DRLG_L4PlaceMiniSet(const unsigned char *miniset, int tmin, int void __cdecl DRLG_L4FloodTVal() { - int v0; // ebx - int v1; // esi - char *v2; // edi - _BYTE *v3; // [esp+Ch] [ebp-Ch] + int v0; // ebx + int v1; // esi + char *v2; // edi + _BYTE *v3; // [esp+Ch] [ebp-Ch] signed int x; // [esp+10h] [ebp-8h] signed int i; // [esp+14h] [ebp-4h] v0 = 16; v1 = 0; - do - { + do { i = 0; x = 16; v2 = &dung_map[16][v0]; v3 = (unsigned char *)dungeon + v1; - do - { - if ( *v3 == 6 && !*v2 ) - { + do { + if (*v3 == 6 && !*v2) { DRLG_L4FTVR(i, v1, x, v0, 0); ++TransVal; } @@ -3021,37 +2673,35 @@ void __cdecl DRLG_L4FloodTVal() v3 += 40; v2 += 224; ++i; - } - while ( i < 40 ); + } while (i < 40); v0 += 2; ++v1; - } - while ( v1 < 40 ); + } while (v1 < 40); } // 5A5590: using guessed type char TransVal; void __fastcall DRLG_L4FTVR(int i, int j, int x, int y, int d) { - int v5; // ebx - int v6; // esi - int v7; // edi - int v8; // edx - int v9; // ecx - int v10; // ebx - int v11; // eax - int v12; // edi + int v5; // ebx + int v6; // esi + int v7; // edi + int v8; // edx + int v9; // ecx + int v10; // ebx + int v11; // eax + int v12; // edi char v13; // al char v14; // al - int v15; // ecx - int v16; // ecx - int v17; // ecx - int v18; // ecx - int v19; // [esp+Ch] [ebp-14h] - int k; // [esp+10h] [ebp-10h] - int v21; // [esp+14h] [ebp-Ch] - int ja; // [esp+18h] [ebp-8h] - int ia; // [esp+1Ch] [ebp-4h] - int ya; // [esp+2Ch] [ebp+Ch] + int v15; // ecx + int v16; // ecx + int v17; // ecx + int v18; // ecx + int v19; // [esp+Ch] [ebp-14h] + int k; // [esp+10h] [ebp-10h] + int v21; // [esp+14h] [ebp-Ch] + int ja; // [esp+18h] [ebp-8h] + int ia; // [esp+1Ch] [ebp-4h] + int ya; // [esp+2Ch] [ebp+Ch] v5 = x; v6 = y; @@ -3060,16 +2710,14 @@ void __fastcall DRLG_L4FTVR(int i, int j, int x, int y, int d) v9 = 112 * x + y; ja = v7; v21 = v8; - if ( !dung_map[0][v9] ) - { + if (!dung_map[0][v9]) { v19 = x; ia = v8 - 1; v10 = x - 2; v11 = 40 * v8; ya = v7 - 1; v12 = v6 - 2; - for ( k = 40 * v8; dungeon[0][v11 + ja] == 6; v11 = k ) - { + for (k = 40 * v8; dungeon[0][v11 + ja] == 6; v11 = k) { v13 = TransVal; dung_map[0][v9] = TransVal; dung_map[1][v9] = v13; @@ -3094,43 +2742,39 @@ void __fastcall DRLG_L4FTVR(int i, int j, int x, int y, int d) ++v21; ++ia; v9 = v19 * 112 + v6; - if ( dung_map[v19][v6] ) + if (dung_map[v19][v6]) break; } v5 = x; } v14 = TransVal; - if ( d == 1 ) - { + if (d == 1) { v15 = v6 + 112 * v5; dung_map[0][v15] = TransVal; dung_map[0][v15 + 1] = v14; } - if ( d == 2 ) - { + if (d == 2) { v16 = v6 + 112 * v5; dung_map[1][v16] = v14; dung_map[1][v16 + 1] = v14; } - if ( d == 3 ) - { + if (d == 3) { v17 = v6 + 112 * v5; dung_map[0][v17] = v14; dung_map[1][v17] = v14; } - if ( d == 4 ) - { + if (d == 4) { v18 = v6 + 112 * v5; dung_map[0][v18 + 1] = v14; dung_map[1][v18 + 1] = v14; } - if ( d == 5 ) + if (d == 5) dung_map[v5 + 1][v6 + 1] = v14; - if ( d == 6 ) + if (d == 6) dung_map[v5][v6 + 1] = v14; - if ( d == 7 ) + if (d == 7) dung_map[v5 + 1][v6] = v14; - if ( d == 8 ) + if (d == 8) dung_map[v5][v6] = v14; } // 5A5590: using guessed type char TransVal; @@ -3138,122 +2782,106 @@ void __fastcall DRLG_L4FTVR(int i, int j, int x, int y, int d) void __cdecl DRLG_L4TransFix() { signed int v0; // ebx - char *v1; // esi - char *v2; // edi - char v3; // al + char *v1; // esi + char *v2; // edi + char v3; // al signed int v4; // [esp+Ch] [ebp-8h] - char *v5; // [esp+10h] [ebp-4h] + char *v5; // [esp+10h] [ebp-4h] v0 = 0; v5 = &dung_map[16][16]; - do - { + do { v1 = v5; v2 = (char *)dungeon + v0; v4 = 40; - do - { - if ( IsDURWall(*v2) && *(v2 - 1) == 18 ) - { + do { + if (IsDURWall(*v2) && *(v2 - 1) == 18) { v1[112] = *v1; v1[113] = *v1; } - if ( IsDLLWall(*v2) && v2[40] == 19 ) - { + if (IsDLLWall(*v2) && v2[40] == 19) { v1[1] = *v1; v1[113] = *v1; } v3 = *v2; - if ( *v2 == 18 ) - { + if (*v2 == 18) { v1[112] = *v1; v1[113] = *v1; } - if ( v3 == 19 ) - { + if (v3 == 19) { v1[1] = *v1; v1[113] = *v1; } - if ( v3 == 24 ) - { + if (v3 == 24) { v1[112] = *v1; v1[1] = *v1; v1[113] = *v1; } - if ( v3 == 57 ) - { + if (v3 == 57) { *(v1 - 112) = v1[1]; *v1 = v1[1]; } - if ( v3 == 53 ) - { + if (v3 == 53) { *(v1 - 1) = v1[112]; *v1 = v1[112]; } v1 += 224; v2 += 40; --v4; - } - while ( v4 ); + } while (v4); v5 += 2; ++v0; - } - while ( v0 < 40 ); + } while (v0 < 40); } void __cdecl DRLG_L4Corners() { signed int v0; // edx - char *v1; // ecx + char *v1; // ecx signed int v2; // esi - char v3; // al + char v3; // al v0 = 1; - do - { + do { v1 = &dungeon[1][v0]; v2 = 38; - do - { + do { v3 = *v1; - if ( (unsigned char)*v1 >= 0x12u - && (unsigned char)v3 <= 0x1Eu - && ((unsigned char)v1[40] < 0x12u || (unsigned char)v1[1] < 0x12u) ) - { + if ((unsigned char)*v1 >= 0x12u + && (unsigned char)v3 <= 0x1Eu + && ((unsigned char)v1[40] < 0x12u || (unsigned char)v1[1] < 0x12u)) { *v1 = v3 + 98; } v1 += 40; --v2; - } - while ( v2 ); + } while (v2); ++v0; - } - while ( v0 < 39 ); + } while (v0 < 39); } void __cdecl DRLG_L4Pass3() { - int v0; // eax - int *v1; // esi - int *v2; // eax - signed int v3; // ecx - signed int v4; // ebx - int *v5; // ecx - unsigned char *v6; // edi + int v0; // eax + int *v1; // esi + int *v2; // eax + signed int v3; // ecx + signed int v4; // ebx + int *v5; // ecx + unsigned char *v6; // edi unsigned short *v7; // esi - unsigned short v8; // ax - int v9; // eax - signed int v10; // [esp+Ch] [ebp-1Ch] - int *v11; // [esp+10h] [ebp-18h] - int v12; // [esp+14h] [ebp-14h] - int v13; // [esp+18h] [ebp-10h] - int v14; // [esp+18h] [ebp-10h] - int v15; // [esp+1Ch] [ebp-Ch] - int v16; // [esp+1Ch] [ebp-Ch] - int v17; // [esp+20h] [ebp-8h] - int v18; // [esp+20h] [ebp-8h] - int v19; // [esp+24h] [ebp-4h] - int v20; // [esp+24h] [ebp-4h] + unsigned short v8; // ax + int v9; // eax + signed int v10; // [esp+Ch] [ebp-1Ch] + int *v11; // [esp+10h] [ebp-18h] + int v12; // [esp+14h] [ebp-14h] + int v13; // [esp+18h] [ebp-10h] + int v14; // [esp+18h] [ebp-10h] + int v15; // [esp+1Ch] [ebp-Ch] + int v16; // [esp+1Ch] [ebp-Ch] + int v17; // [esp+20h] [ebp-8h] + int v18; // [esp+20h] [ebp-8h] + int v19; // [esp+24h] [ebp-4h] + int v20; // [esp+24h] [ebp-4h] v0 = *((unsigned short *)pMegaTiles + 116) + 1; v19 = *((unsigned short *)pMegaTiles + 116) + 1; @@ -3264,42 +2892,33 @@ void __cdecl DRLG_L4Pass3() _LOWORD(v0) = *((_WORD *)pMegaTiles + 119); v13 = v0 + 1; v1 = dPiece[1]; - do - { + do { v2 = v1; v3 = 56; - do - { + do { *(v2 - 112) = v19; *v2 = v17; *(v2 - 111) = v15; v2[1] = v13; v2 += 224; --v3; - } - while ( v3 ); + } while (v3); v1 += 2; - } - while ( (signed int)v1 < (signed int)dPiece[2] ); + } while ((signed int)v1 < (signed int)dPiece[2]); v4 = 0; v11 = &dPiece[17][16]; - do - { + do { v5 = v11; v6 = (unsigned char *)dungeon + v4; v10 = 40; - do - { + do { v12 = *v6 - 1; - if ( v12 < 0 ) - { + if (v12 < 0) { v20 = 0; v18 = 0; v16 = 0; v14 = 0; - } - else - { + } else { v7 = (unsigned short *)((char *)pMegaTiles + 8 * v12); v8 = *v7; ++v7; @@ -3320,10 +2939,8 @@ void __cdecl DRLG_L4Pass3() v5[1] = v14; v5 += 224; --v10; - } - while ( v10 ); + } while (v10); v11 += 2; ++v4; - } - while ( v4 < 40 ); + } while (v4 < 40); } diff --git a/Source/dthread.cpp b/Source/dthread.cpp index bf962d6c..feca7b14 100644 --- a/Source/dthread.cpp +++ b/Source/dthread.cpp @@ -15,169 +15,169 @@ int dthread_inf = 0x7F800000; // weak static HANDLE sghThread = (HANDLE)0xFFFFFFFF; // idb struct dthread_cpp_init_1 { - dthread_cpp_init_1() - { - dthread_cpp_init_value = dthread_inf; - } + dthread_cpp_init_1() + { + dthread_cpp_init_value = dthread_inf; + } } _dthread_cpp_init_1; // 47A460: using guessed type int dthread_inf; // 52A4E0: using guessed type int dthread_cpp_init_value; struct dthread_cpp_init_2 { - dthread_cpp_init_2() - { - dthread_init_mutex(); - dthread_cleanup_mutex_atexit(); - } + dthread_cpp_init_2() + { + dthread_init_mutex(); + dthread_cleanup_mutex_atexit(); + } } _dthread_cpp_init_2; void __cdecl dthread_init_mutex() { - InitializeCriticalSection(&sgMemCrit); + InitializeCriticalSection(&sgMemCrit); } void __cdecl dthread_cleanup_mutex_atexit() { - atexit(dthread_cleanup_mutex); + atexit(dthread_cleanup_mutex); } void __cdecl dthread_cleanup_mutex() { - DeleteCriticalSection(&sgMemCrit); + DeleteCriticalSection(&sgMemCrit); } void __fastcall dthread_remove_player(int pnum) { - int v1; // edi - TMegaPkt *i; // eax + int v1; // edi + TMegaPkt *i; // eax - v1 = pnum; - EnterCriticalSection(&sgMemCrit); - for (i = sgpInfoHead; i; i = i->pNext) { - if (i->dwSpaceLeft == v1) - i->dwSpaceLeft = 4; - } - LeaveCriticalSection(&sgMemCrit); + v1 = pnum; + EnterCriticalSection(&sgMemCrit); + for (i = sgpInfoHead; i; i = i->pNext) { + if (i->dwSpaceLeft == v1) + i->dwSpaceLeft = 4; + } + LeaveCriticalSection(&sgMemCrit); } void __fastcall dthread_send_delta(int pnum, char cmd, void *pbSrc, int dwLen) { - TMegaPkt *v5; // eax - TMegaPkt *v6; // esi - TMegaPkt *v7; // eax - TMegaPkt **v8; // ecx - int v9; // [esp+4h] [ebp-4h] + TMegaPkt *v5; // eax + TMegaPkt *v6; // esi + TMegaPkt *v7; // eax + TMegaPkt **v8; // ecx + int v9; // [esp+4h] [ebp-4h] - v9 = pnum; - if (gbMaxPlayers != 1) { - v5 = (TMegaPkt *)DiabloAllocPtr(dwLen + 20); - v6 = v5; - v5->pNext = 0; - v5->dwSpaceLeft = v9; - v5->data[0] = cmd; - *(_DWORD *)&v5->data[4] = dwLen; - memcpy(&v5->data[8], pbSrc, dwLen); - EnterCriticalSection(&sgMemCrit); - v7 = sgpInfoHead; - v8 = &sgpInfoHead; - while (v7) { - v8 = &v7->pNext; - v7 = v7->pNext; - } - *v8 = v6; - SetEvent(sghWorkToDoEvent); - LeaveCriticalSection(&sgMemCrit); - } + v9 = pnum; + if (gbMaxPlayers != 1) { + v5 = (TMegaPkt *)DiabloAllocPtr(dwLen + 20); + v6 = v5; + v5->pNext = 0; + v5->dwSpaceLeft = v9; + v5->data[0] = cmd; + *(_DWORD *)&v5->data[4] = dwLen; + memcpy(&v5->data[8], pbSrc, dwLen); + EnterCriticalSection(&sgMemCrit); + v7 = sgpInfoHead; + v8 = &sgpInfoHead; + while (v7) { + v8 = &v7->pNext; + v7 = v7->pNext; + } + *v8 = v6; + SetEvent(sghWorkToDoEvent); + LeaveCriticalSection(&sgMemCrit); + } } // 679660: using guessed type char gbMaxPlayers; void __cdecl dthread_start() { - char *v0; // eax - char *v1; // eax + char *v0; // eax + char *v1; // eax - if (gbMaxPlayers != 1) { - sghWorkToDoEvent = CreateEvent(NULL, TRUE, FALSE, NULL); - if (!sghWorkToDoEvent) { - v0 = TraceLastError(); - TermMsg("dthread:1\n%s", v0); - } - byte_52A508 = 1; - sghThread = (HANDLE)_beginthreadex(NULL, 0, dthread_handler, NULL, 0, &glpDThreadId); - if (sghThread == (HANDLE)-1) { - v1 = TraceLastError(); - TermMsg("dthread2:\n%s", v1); - } - } + if (gbMaxPlayers != 1) { + sghWorkToDoEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + if (!sghWorkToDoEvent) { + v0 = TraceLastError(); + TermMsg("dthread:1\n%s", v0); + } + byte_52A508 = 1; + sghThread = (HANDLE)_beginthreadex(NULL, 0, dthread_handler, NULL, 0, &glpDThreadId); + if (sghThread == (HANDLE)-1) { + v1 = TraceLastError(); + TermMsg("dthread2:\n%s", v1); + } + } } // 52A508: using guessed type char byte_52A508; // 679660: using guessed type char gbMaxPlayers; unsigned int __stdcall dthread_handler(void *a1) { - char *v1; // eax - TMegaPkt *v2; // esi - int v3; // ecx - unsigned int v4; // edi + char *v1; // eax + TMegaPkt *v2; // esi + int v3; // ecx + unsigned int v4; // edi - while (byte_52A508) { - if (!sgpInfoHead && WaitForSingleObject(sghWorkToDoEvent, 0xFFFFFFFF) == -1) { - v1 = TraceLastError(); - TermMsg("dthread4:\n%s", v1); - } - EnterCriticalSection(&sgMemCrit); - v2 = sgpInfoHead; - if (sgpInfoHead) - sgpInfoHead = sgpInfoHead->pNext; - else - ResetEvent(sghWorkToDoEvent); - LeaveCriticalSection(&sgMemCrit); - if (v2) { - v3 = v2->dwSpaceLeft; - if (v3 != 4) - multi_send_zero_packet(v3, v2->data[0], &v2->data[8], *(_DWORD *)&v2->data[4]); - v4 = 1000 * *(_DWORD *)&v2->data[4] / (unsigned int)gdwDeltaBytesSec; - if (v4 >= 1) - v4 = 1; - mem_free_dbg(v2); - if (v4) - Sleep(v4); - } - } - return 0; + while (byte_52A508) { + if (!sgpInfoHead && WaitForSingleObject(sghWorkToDoEvent, 0xFFFFFFFF) == -1) { + v1 = TraceLastError(); + TermMsg("dthread4:\n%s", v1); + } + EnterCriticalSection(&sgMemCrit); + v2 = sgpInfoHead; + if (sgpInfoHead) + sgpInfoHead = sgpInfoHead->pNext; + else + ResetEvent(sghWorkToDoEvent); + LeaveCriticalSection(&sgMemCrit); + if (v2) { + v3 = v2->dwSpaceLeft; + if (v3 != 4) + multi_send_zero_packet(v3, v2->data[0], &v2->data[8], *(_DWORD *)&v2->data[4]); + v4 = 1000 * *(_DWORD *)&v2->data[4] / (unsigned int)gdwDeltaBytesSec; + if (v4 >= 1) + v4 = 1; + mem_free_dbg(v2); + if (v4) + Sleep(v4); + } + } + return 0; } // 52A508: using guessed type char byte_52A508; // 679730: using guessed type int gdwDeltaBytesSec; void __cdecl dthread_cleanup() { - char *v0; // eax - TMegaPkt *v1; // eax - TMegaPkt *v2; // esi + char *v0; // eax + TMegaPkt *v1; // eax + TMegaPkt *v2; // esi - if (sghWorkToDoEvent) { - byte_52A508 = 0; - SetEvent(sghWorkToDoEvent); - if (sghThread != (HANDLE)-1 && glpDThreadId != GetCurrentThreadId()) { - if (WaitForSingleObject(sghThread, 0xFFFFFFFF) == -1) { - v0 = TraceLastError(); - TermMsg("dthread3:\n(%s)", v0); - } - CloseHandle(sghThread); - sghThread = (HANDLE)-1; - } - CloseHandle(sghWorkToDoEvent); - v1 = sgpInfoHead; - sghWorkToDoEvent = 0; - if (sgpInfoHead) { - do { - v2 = v1->pNext; - sgpInfoHead = 0; - mem_free_dbg(v1); - v1 = v2; - sgpInfoHead = v2; - } while (v2); - } - } + if (sghWorkToDoEvent) { + byte_52A508 = 0; + SetEvent(sghWorkToDoEvent); + if (sghThread != (HANDLE)-1 && glpDThreadId != GetCurrentThreadId()) { + if (WaitForSingleObject(sghThread, 0xFFFFFFFF) == -1) { + v0 = TraceLastError(); + TermMsg("dthread3:\n(%s)", v0); + } + CloseHandle(sghThread); + sghThread = (HANDLE)-1; + } + CloseHandle(sghWorkToDoEvent); + v1 = sgpInfoHead; + sghWorkToDoEvent = 0; + if (sgpInfoHead) { + do { + v2 = v1->pNext; + sgpInfoHead = 0; + mem_free_dbg(v1); + v1 = v2; + sgpInfoHead = v2; + } while (v2); + } + } } // 52A508: using guessed type char byte_52A508; diff --git a/Source/dx.cpp b/Source/dx.cpp index e3b2025c..882b50b9 100644 --- a/Source/dx.cpp +++ b/Source/dx.cpp @@ -21,269 +21,269 @@ HMODULE ghDiabMod; // idb int dx_inf = 0x7F800000; // weak struct dx_cpp_init_1 { - dx_cpp_init_1() - { - dx_cpp_init_value = dx_inf; - } + dx_cpp_init_1() + { + dx_cpp_init_value = dx_inf; + } } _dx_cpp_init_1; // 47A464: using guessed type int dx_inf; // 52A514: using guessed type int dx_cpp_init_value; struct dx_cpp_init_2 { - dx_cpp_init_2() - { - dx_init_mutex(); - dx_cleanup_mutex_atexit(); - } + dx_cpp_init_2() + { + dx_init_mutex(); + dx_cleanup_mutex_atexit(); + } } _dx_cpp_init_2; void __cdecl dx_init_mutex() { - InitializeCriticalSection(&sgMemCrit); + InitializeCriticalSection(&sgMemCrit); } void __cdecl dx_cleanup_mutex_atexit() { - atexit(dx_cleanup_mutex); + atexit(dx_cleanup_mutex); } void __cdecl dx_cleanup_mutex() { - DeleteCriticalSection(&sgMemCrit); + DeleteCriticalSection(&sgMemCrit); } void __fastcall dx_init(HWND hWnd) { - HWND v1; // esi - GUID *v2; // ecx - int v3; // eax - int v4; // eax - //int v5; // ecx - int v6; // edi - int v7; // eax - int v8; // eax - HWND hWnda; // [esp+1Ch] [ebp-4h] + HWND v1; // esi + GUID *v2; // ecx + int v3; // eax + int v4; // eax + //int v5; // ecx + int v6; // edi + int v7; // eax + int v8; // eax + HWND hWnda; // [esp+1Ch] [ebp-4h] - v1 = hWnd; - hWnda = hWnd; - SetFocus(hWnd); - ShowWindow(v1, SW_SHOWNORMAL); - v2 = NULL; - if (gbEmulate) - v2 = (GUID *)DDCREATE_EMULATIONONLY; - v3 = dx_DirectDrawCreate(v2, &lpDDInterface, NULL); - if (v3) - ErrDlg(IDD_DIALOG1, v3, "C:\\Src\\Diablo\\Source\\dx.cpp", 149); - fullscreen = 1; - v4 = lpDDInterface->SetCooperativeLevel(v1, DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT | DDSCL_FULLSCREEN); - if (v4 == DDERR_EXCLUSIVEMODEALREADYSET) { - MI_Dummy(0); // v5 - } else if (v4) { - ErrDlg(IDD_DIALOG1, v4, "C:\\Src\\Diablo\\Source\\dx.cpp", 170); - } - if (lpDDInterface->SetDisplayMode(640, 480, 8)) { - v6 = GetSystemMetrics(SM_CXSCREEN); - v7 = GetSystemMetrics(SM_CYSCREEN); - v8 = lpDDInterface->SetDisplayMode(v6, v7, 8); - if (v8) - ErrDlg(IDD_DIALOG1, v8, "C:\\Src\\Diablo\\Source\\dx.cpp", 183); - } - dx_create_primary_surface(); - palette_init(); - GdiSetBatchLimit(1); - dx_create_back_buffer(); - SDrawManualInitialize(hWnda, lpDDInterface, lpDDSPrimary, 0, 0, lpDDSBackBuf, lpDDPalette, 0); + v1 = hWnd; + hWnda = hWnd; + SetFocus(hWnd); + ShowWindow(v1, SW_SHOWNORMAL); + v2 = NULL; + if (gbEmulate) + v2 = (GUID *)DDCREATE_EMULATIONONLY; + v3 = dx_DirectDrawCreate(v2, &lpDDInterface, NULL); + if (v3) + ErrDlg(IDD_DIALOG1, v3, "C:\\Src\\Diablo\\Source\\dx.cpp", 149); + fullscreen = 1; + v4 = lpDDInterface->SetCooperativeLevel(v1, DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT | DDSCL_FULLSCREEN); + if (v4 == DDERR_EXCLUSIVEMODEALREADYSET) { + MI_Dummy(0); // v5 + } else if (v4) { + ErrDlg(IDD_DIALOG1, v4, "C:\\Src\\Diablo\\Source\\dx.cpp", 170); + } + if (lpDDInterface->SetDisplayMode(640, 480, 8)) { + v6 = GetSystemMetrics(SM_CXSCREEN); + v7 = GetSystemMetrics(SM_CYSCREEN); + v8 = lpDDInterface->SetDisplayMode(v6, v7, 8); + if (v8) + ErrDlg(IDD_DIALOG1, v8, "C:\\Src\\Diablo\\Source\\dx.cpp", 183); + } + dx_create_primary_surface(); + palette_init(); + GdiSetBatchLimit(1); + dx_create_back_buffer(); + SDrawManualInitialize(hWnda, lpDDInterface, lpDDSPrimary, 0, 0, lpDDSBackBuf, lpDDPalette, 0); } // 52A549: using guessed type char gbEmulate; void __cdecl dx_create_back_buffer() { - DDSCAPS caps; - HRESULT error_code = lpDDSPrimary->GetCaps(&caps); - if (error_code != DD_OK) - DDErrMsg(error_code, 59, "C:\\Src\\Diablo\\Source\\dx.cpp"); + DDSCAPS caps; + HRESULT error_code = lpDDSPrimary->GetCaps(&caps); + if (error_code != DD_OK) + DDErrMsg(error_code, 59, "C:\\Src\\Diablo\\Source\\dx.cpp"); - DDSURFACEDESC ddsd; - if (gbBackBuf == NULL) { - ddsd.dwSize = sizeof(ddsd); - error_code = lpDDSPrimary->Lock(NULL, &ddsd, DDLOCK_WRITEONLY | DDLOCK_WAIT, NULL); - if (error_code == DD_OK) { - lpDDSPrimary->Unlock(NULL); - sgpBackBuf = (Screen *)DiabloAllocPtr(sizeof(Screen)); - return; - } - if (error_code != DDERR_CANTLOCKSURFACE) - ErrDlg(IDD_DIALOG1, error_code, "C:\\Src\\Diablo\\Source\\dx.cpp", 81); - } + DDSURFACEDESC ddsd; + if (gbBackBuf == NULL) { + ddsd.dwSize = sizeof(ddsd); + error_code = lpDDSPrimary->Lock(NULL, &ddsd, DDLOCK_WRITEONLY | DDLOCK_WAIT, NULL); + if (error_code == DD_OK) { + lpDDSPrimary->Unlock(NULL); + sgpBackBuf = (Screen *)DiabloAllocPtr(sizeof(Screen)); + return; + } + if (error_code != DDERR_CANTLOCKSURFACE) + ErrDlg(IDD_DIALOG1, error_code, "C:\\Src\\Diablo\\Source\\dx.cpp", 81); + } - memset(&ddsd, 0, sizeof(ddsd)); - ddsd.dwWidth = 768; - ddsd.lPitch = 768; - ddsd.dwSize = sizeof(ddsd); - ddsd.dwFlags = DDSD_PIXELFORMAT | DDSD_PITCH | DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS; - ddsd.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN; - ddsd.dwHeight = 656; - ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat); - error_code = lpDDSPrimary->GetPixelFormat(&ddsd.ddpfPixelFormat); - if (error_code != DD_OK) - ErrDlg(IDD_DIALOG1, error_code, "C:\\Src\\Diablo\\Source\\dx.cpp", 94); - error_code = lpDDInterface->CreateSurface(&ddsd, &lpDDSBackBuf, NULL); - if (error_code != DD_OK) - ErrDlg(IDD_DIALOG1, error_code, "C:\\Src\\Diablo\\Source\\dx.cpp", 96); + memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwWidth = 768; + ddsd.lPitch = 768; + ddsd.dwSize = sizeof(ddsd); + ddsd.dwFlags = DDSD_PIXELFORMAT | DDSD_PITCH | DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS; + ddsd.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN; + ddsd.dwHeight = 656; + ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat); + error_code = lpDDSPrimary->GetPixelFormat(&ddsd.ddpfPixelFormat); + if (error_code != DD_OK) + ErrDlg(IDD_DIALOG1, error_code, "C:\\Src\\Diablo\\Source\\dx.cpp", 94); + error_code = lpDDInterface->CreateSurface(&ddsd, &lpDDSBackBuf, NULL); + if (error_code != DD_OK) + ErrDlg(IDD_DIALOG1, error_code, "C:\\Src\\Diablo\\Source\\dx.cpp", 96); } // 52A548: using guessed type char gbBackBuf; void __cdecl dx_create_primary_surface() { - DDSURFACEDESC ddsd; - memset(&ddsd, 0, sizeof(ddsd)); - ddsd.dwSize = sizeof(ddsd); - ddsd.dwFlags = DDSD_CAPS; - ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; - HRESULT error_code = lpDDInterface->CreateSurface(&ddsd, &lpDDSPrimary, NULL); - if (error_code != DD_OK) - ErrDlg(IDD_DIALOG1, error_code, "C:\\Src\\Diablo\\Source\\dx.cpp", 109); + DDSURFACEDESC ddsd; + memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + ddsd.dwFlags = DDSD_CAPS; + ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; + HRESULT error_code = lpDDInterface->CreateSurface(&ddsd, &lpDDSPrimary, NULL); + if (error_code != DD_OK) + ErrDlg(IDD_DIALOG1, error_code, "C:\\Src\\Diablo\\Source\\dx.cpp", 109); } HRESULT __fastcall dx_DirectDrawCreate(LPGUID guid, LPDIRECTDRAW *lplpDD, LPUNKNOWN pUnkOuter) { - if (ghDiabMod == NULL) { - ghDiabMod = LoadLibrary("ddraw.dll"); - if (ghDiabMod == NULL) { - ErrDlg(IDD_DIALOG4, GetLastError(), "C:\\Src\\Diablo\\Source\\dx.cpp", 122); - } - } + if (ghDiabMod == NULL) { + ghDiabMod = LoadLibrary("ddraw.dll"); + if (ghDiabMod == NULL) { + ErrDlg(IDD_DIALOG4, GetLastError(), "C:\\Src\\Diablo\\Source\\dx.cpp", 122); + } + } - HRESULT(WINAPI * DirectDrawCreate) - (LPGUID lpGuid, LPDIRECTDRAW * lplpDD, LPUNKNOWN pUnkOuter); - DirectDrawCreate = (HRESULT(WINAPI *)(LPGUID, LPDIRECTDRAW *, LPUNKNOWN))GetProcAddress(ghDiabMod, "DirectDrawCreate"); - if (DirectDrawCreate == NULL) { - ErrDlg(IDD_DIALOG4, GetLastError(), "C:\\Src\\Diablo\\Source\\dx.cpp", 127); - } - return DirectDrawCreate(guid, lplpDD, pUnkOuter); + HRESULT(WINAPI * DirectDrawCreate) + (LPGUID lpGuid, LPDIRECTDRAW * lplpDD, LPUNKNOWN pUnkOuter); + DirectDrawCreate = (HRESULT(WINAPI *)(LPGUID, LPDIRECTDRAW *, LPUNKNOWN))GetProcAddress(ghDiabMod, "DirectDrawCreate"); + if (DirectDrawCreate == NULL) { + ErrDlg(IDD_DIALOG4, GetLastError(), "C:\\Src\\Diablo\\Source\\dx.cpp", 127); + } + return DirectDrawCreate(guid, lplpDD, pUnkOuter); } void __fastcall j_lock_buf_priv(BYTE idx) { #ifdef _DEBUG - ++locktbl[idx]; + ++locktbl[idx]; #endif - lock_buf_priv(); + lock_buf_priv(); } void __cdecl lock_buf_priv() { - EnterCriticalSection(&sgMemCrit); - if (sgpBackBuf != NULL) { - gpBuffer = sgpBackBuf; - sgdwLockCount++; - return; - } + EnterCriticalSection(&sgMemCrit); + if (sgpBackBuf != NULL) { + gpBuffer = sgpBackBuf; + sgdwLockCount++; + return; + } - if (lpDDSBackBuf == NULL) { - Sleep(20000); - TermMsg("lock_buf_priv"); - sgdwLockCount++; - return; - } + if (lpDDSBackBuf == NULL) { + Sleep(20000); + TermMsg("lock_buf_priv"); + sgdwLockCount++; + return; + } - if (sgdwLockCount != 0) { - sgdwLockCount++; - return; - } - DDSURFACEDESC ddsd; - ddsd.dwSize = sizeof(ddsd); - HRESULT error_code = lpDDSBackBuf->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL); - if (error_code != DD_OK) - DDErrMsg(error_code, 235, "C:\\Src\\Diablo\\Source\\dx.cpp"); + if (sgdwLockCount != 0) { + sgdwLockCount++; + return; + } + DDSURFACEDESC ddsd; + ddsd.dwSize = sizeof(ddsd); + HRESULT error_code = lpDDSBackBuf->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL); + if (error_code != DD_OK) + DDErrMsg(error_code, 235, "C:\\Src\\Diablo\\Source\\dx.cpp"); - gpBufEnd += (int)ddsd.lpSurface; - gpBuffer = (Screen *)ddsd.lpSurface; - sgdwLockCount++; + gpBufEnd += (int)ddsd.lpSurface; + gpBuffer = (Screen *)ddsd.lpSurface; + sgdwLockCount++; } void __fastcall j_unlock_buf_priv(BYTE idx) { #ifdef _DEBUG - if (!locktbl[idx]) - TermMsg("Draw lock underflow: 0x%x", idx); - --locktbl[idx]; + if (!locktbl[idx]) + TermMsg("Draw lock underflow: 0x%x", idx); + --locktbl[idx]; #endif - unlock_buf_priv(); + unlock_buf_priv(); } void __cdecl unlock_buf_priv() { - if (sgdwLockCount == 0) - TermMsg("draw main unlock error"); - if (!gpBuffer) - TermMsg("draw consistency error"); + if (sgdwLockCount == 0) + TermMsg("draw main unlock error"); + if (!gpBuffer) + TermMsg("draw consistency error"); - sgdwLockCount--; - if (sgdwLockCount == 0) { - gpBufEnd -= (int)gpBuffer; - gpBuffer = NULL; - if (sgpBackBuf == NULL) { - HRESULT error_code = lpDDSBackBuf->Unlock(NULL); - if (error_code != DD_OK) - DDErrMsg(error_code, 273, "C:\\Src\\Diablo\\Source\\dx.cpp"); - } - } - LeaveCriticalSection(&sgMemCrit); + sgdwLockCount--; + if (sgdwLockCount == 0) { + gpBufEnd -= (int)gpBuffer; + gpBuffer = NULL; + if (sgpBackBuf == NULL) { + HRESULT error_code = lpDDSBackBuf->Unlock(NULL); + if (error_code != DD_OK) + DDErrMsg(error_code, 273, "C:\\Src\\Diablo\\Source\\dx.cpp"); + } + } + LeaveCriticalSection(&sgMemCrit); } void __cdecl dx_cleanup() { - Screen *v0; // ecx + Screen *v0; // ecx - if (ghMainWnd) - ShowWindow(ghMainWnd, SW_HIDE); - SDrawDestroy(); - EnterCriticalSection(&sgMemCrit); - if (sgpBackBuf != NULL) { - v0 = sgpBackBuf; - sgpBackBuf = 0; - mem_free_dbg(v0); - } else if (lpDDSBackBuf != NULL) { - lpDDSBackBuf->Release(); - lpDDSBackBuf = NULL; - } - sgdwLockCount = 0; - gpBuffer = 0; - LeaveCriticalSection(&sgMemCrit); - if (lpDDSPrimary) { - lpDDSPrimary->Release(); - lpDDSPrimary = 0; - } - if (lpDDPalette) { - lpDDPalette->Release(); - lpDDPalette = 0; - } - if (lpDDInterface) { - lpDDInterface->Release(); - lpDDInterface = 0; - } + if (ghMainWnd) + ShowWindow(ghMainWnd, SW_HIDE); + SDrawDestroy(); + EnterCriticalSection(&sgMemCrit); + if (sgpBackBuf != NULL) { + v0 = sgpBackBuf; + sgpBackBuf = 0; + mem_free_dbg(v0); + } else if (lpDDSBackBuf != NULL) { + lpDDSBackBuf->Release(); + lpDDSBackBuf = NULL; + } + sgdwLockCount = 0; + gpBuffer = 0; + LeaveCriticalSection(&sgMemCrit); + if (lpDDSPrimary) { + lpDDSPrimary->Release(); + lpDDSPrimary = 0; + } + if (lpDDPalette) { + lpDDPalette->Release(); + lpDDPalette = 0; + } + if (lpDDInterface) { + lpDDInterface->Release(); + lpDDInterface = 0; + } } void __cdecl dx_reinit() { - EnterCriticalSection(&sgMemCrit); - ClearCursor(); - int lockCount = sgdwLockCount; + EnterCriticalSection(&sgMemCrit); + ClearCursor(); + int lockCount = sgdwLockCount; - while (sgdwLockCount != 0) - unlock_buf_priv(); + while (sgdwLockCount != 0) + unlock_buf_priv(); - dx_cleanup(); + dx_cleanup(); - drawpanflag = 255; + drawpanflag = 255; - dx_init(ghMainWnd); + dx_init(ghMainWnd); - while (lockCount != 0) { - lock_buf_priv(); - lockCount--; - } + while (lockCount != 0) { + lock_buf_priv(); + lockCount--; + } - LeaveCriticalSection(&sgMemCrit); + LeaveCriticalSection(&sgMemCrit); } diff --git a/Source/effects.cpp b/Source/effects.cpp index 5653dc93..b8343b4c 100644 --- a/Source/effects.cpp +++ b/Source/effects.cpp @@ -14,7 +14,7 @@ const char monster_action_sounds[] = { 'a', 'h', 'd', 's' }; // idb /* data */ TSFX sgSFX[NUM_SFX] = { - // clang-format off + // clang-format off // bFlags, pszName, pSnd { 2, "Sfx\\Misc\\Walk1.wav", NULL }, { 2, "Sfx\\Misc\\Walk2.wav", NULL }, @@ -874,364 +874,364 @@ TSFX sgSFX[NUM_SFX] = { { 1, "Sfx\\Monsters\\Zhar01.wav", NULL }, { 1, "Sfx\\Monsters\\Zhar02.wav", NULL }, { 1, "Sfx\\Monsters\\DiabloD.wav", NULL } - // clang-format on + // clang-format on }; struct effects_cpp_init { - effects_cpp_init() - { - effects_cpp_init_value = effects_inf; - } + effects_cpp_init() + { + effects_cpp_init_value = effects_inf; + } } _effects_cpp_init; // 47A468: using guessed type int effects_inf; // 52A550: using guessed type int effects_cpp_init_value; BOOL __fastcall effect_is_playing(int nSFX) { - TSFX *sfx = &sgSFX[nSFX]; - if (sfx->pSnd) - return snd_playing(sfx->pSnd); + TSFX *sfx = &sgSFX[nSFX]; + if (sfx->pSnd) + return snd_playing(sfx->pSnd); - if (sfx->bFlags & SFX_STREAM) - return sfx == sfx_data_cur; + if (sfx->bFlags & SFX_STREAM) + return sfx == sfx_data_cur; - return FALSE; + return FALSE; } void __cdecl sfx_stop() { - if (sfx_stream) { - SFileDdaEnd(sfx_stream); - SFileCloseFile(sfx_stream); - sfx_stream = NULL; - sfx_data_cur = NULL; - } + if (sfx_stream) { + SFileDdaEnd(sfx_stream); + SFileCloseFile(sfx_stream); + sfx_stream = NULL; + sfx_data_cur = NULL; + } } void __fastcall InitMonsterSND(int monst) { - TSnd *pSnd; - char name[MAX_PATH]; - char *path; + TSnd *pSnd; + char name[MAX_PATH]; + char *path; - if (!gbSndInited) { - return; - } + if (!gbSndInited) { + return; + } - int mtype = Monsters[monst].mtype; - for (int i = 0; i < 4; i++) { - if (monster_action_sounds[i] != 's' || monsterdata[mtype].snd_special) { - for (int j = 0; j < 2; j++) { - sprintf(name, monsterdata[mtype].sndfile, monster_action_sounds[i], j + 1); - path = (char *)DiabloAllocPtr(strlen(name) + 1); - strcpy(path, name); - pSnd = sound_file_load(path); - Monsters[monst].Snds[i][j] = pSnd; - if (!pSnd) - mem_free_dbg(path); - } - } - } + int mtype = Monsters[monst].mtype; + for (int i = 0; i < 4; i++) { + if (monster_action_sounds[i] != 's' || monsterdata[mtype].snd_special) { + for (int j = 0; j < 2; j++) { + sprintf(name, monsterdata[mtype].sndfile, monster_action_sounds[i], j + 1); + path = (char *)DiabloAllocPtr(strlen(name) + 1); + strcpy(path, name); + pSnd = sound_file_load(path); + Monsters[monst].Snds[i][j] = pSnd; + if (!pSnd) + mem_free_dbg(path); + } + } + } } void __cdecl FreeEffects() { - for (int i = 0; i < nummtypes; i++) { - int mtype = Monsters[i].mtype; - for (int j = 0; j < 4; ++j) { - for (int k = 0; k < 2; ++k) { - TSnd *pSnd = Monsters[i].Snds[j][k]; - if (pSnd) { - Monsters[i].Snds[j][k] = NULL; - char *file = pSnd->sound_path; - pSnd->sound_path = NULL; - sound_file_cleanup(pSnd); - mem_free_dbg(file); - } - } - } - } + for (int i = 0; i < nummtypes; i++) { + int mtype = Monsters[i].mtype; + for (int j = 0; j < 4; ++j) { + for (int k = 0; k < 2; ++k) { + TSnd *pSnd = Monsters[i].Snds[j][k]; + if (pSnd) { + Monsters[i].Snds[j][k] = NULL; + char *file = pSnd->sound_path; + pSnd->sound_path = NULL; + sound_file_cleanup(pSnd); + mem_free_dbg(file); + } + } + } + } } void __fastcall PlayEffect(int i, int mode) { - if (plr[myplr].pLvlLoad) { - return; - } + if (plr[myplr].pLvlLoad) { + return; + } - int sndIdx = random(164, 2); - if (!gbSndInited || !gbSoundOn || gbBufferMsgs) { - return; - } + int sndIdx = random(164, 2); + if (!gbSndInited || !gbSoundOn || gbBufferMsgs) { + return; + } - int mi = monster[i]._mMTidx; - TSnd *snd = Monsters[mi].Snds[mode][sndIdx]; - if (!snd || snd_playing(snd)) { - return; - } + int mi = monster[i]._mMTidx; + TSnd *snd = Monsters[mi].Snds[mode][sndIdx]; + if (!snd || snd_playing(snd)) { + return; + } - int lVolume, lPan; - if (!calc_snd_position(monster[i]._mx, monster[i]._my, &lVolume, &lPan)) - return; + int lVolume, lPan; + if (!calc_snd_position(monster[i]._mx, monster[i]._my, &lVolume, &lPan)) + return; - snd_play_snd(snd, lVolume, lPan); + snd_play_snd(snd, lVolume, lPan); } // 676194: using guessed type char gbBufferMsgs; BOOL __fastcall calc_snd_position(int x, int y, int *plVolume, int *plPan) { - x -= plr[myplr].WorldX; - y -= plr[myplr].WorldY; + x -= plr[myplr].WorldX; + y -= plr[myplr].WorldY; - int pan = (x - y) << 8; - *plPan = pan; + int pan = (x - y) << 8; + *plPan = pan; - if (abs(pan) > 6400) - return FALSE; + if (abs(pan) > 6400) + return FALSE; - int volume = abs(x) > abs(y) ? abs(x) : abs(y); - volume <<= 6; - *plVolume = volume; + int volume = abs(x) > abs(y) ? abs(x) : abs(y); + volume <<= 6; + *plVolume = volume; - if (volume >= 6400) - return FALSE; + if (volume >= 6400) + return FALSE; - *plVolume = -volume; + *plVolume = -volume; - return TRUE; + return TRUE; } void __fastcall PlaySFX(int psfx) { - psfx = RndSFX(psfx); - PlaySFX_priv(&sgSFX[psfx], 0, 0, 0); + psfx = RndSFX(psfx); + PlaySFX_priv(&sgSFX[psfx], 0, 0, 0); } void __fastcall PlaySFX_priv(TSFX *pSFX, BOOL loc, int x, int y) { - if (plr[myplr].pLvlLoad && gbMaxPlayers != 1) { - return; - } - if (!gbSndInited || !gbSoundOn || gbBufferMsgs) { - return; - } + if (plr[myplr].pLvlLoad && gbMaxPlayers != 1) { + return; + } + if (!gbSndInited || !gbSoundOn || gbBufferMsgs) { + return; + } - if (!(pSFX->bFlags & (SFX_STREAM | SFX_MISC)) && pSFX->pSnd != 0 && snd_playing(pSFX->pSnd)) { - return; - } + if (!(pSFX->bFlags & (SFX_STREAM | SFX_MISC)) && pSFX->pSnd != 0 && snd_playing(pSFX->pSnd)) { + return; + } - int lPan = 0; - int lVolume = 0; - if (loc && !calc_snd_position(x, y, &lVolume, &lPan)) { - return; - } + int lPan = 0; + int lVolume = 0; + if (loc && !calc_snd_position(x, y, &lVolume, &lPan)) { + return; + } - if (pSFX->bFlags & SFX_STREAM) { - stream_play(pSFX, lVolume, lPan); - return; - } + if (pSFX->bFlags & SFX_STREAM) { + stream_play(pSFX, lVolume, lPan); + return; + } - if (!pSFX->pSnd) - pSFX->pSnd = sound_file_load(pSFX->pszName); + if (!pSFX->pSnd) + pSFX->pSnd = sound_file_load(pSFX->pszName); - if (pSFX->pSnd) - snd_play_snd(pSFX->pSnd, lVolume, lPan); + if (pSFX->pSnd) + snd_play_snd(pSFX->pSnd, lVolume, lPan); } // 676194: using guessed type char gbBufferMsgs; // 679660: using guessed type char gbMaxPlayers; void __fastcall stream_play(TSFX *pSFX, int lVolume, int lPan) { - sfx_stop(); - lVolume += sound_get_or_set_sound_volume(1); - if (lVolume >= VOLUME_MIN) { - if (lVolume > VOLUME_MAX) - lVolume = VOLUME_MAX; - if (!SFileOpenFile(pSFX->pszName, &sfx_stream)) { - sfx_stream = 0; - } else { - if (!SFileDdaBeginEx(sfx_stream, 0x40000, 0, 0, lVolume, lPan, 0)) - sfx_stop(); - else - sfx_data_cur = pSFX; - } - } + sfx_stop(); + lVolume += sound_get_or_set_sound_volume(1); + if (lVolume >= VOLUME_MIN) { + if (lVolume > VOLUME_MAX) + lVolume = VOLUME_MAX; + if (!SFileOpenFile(pSFX->pszName, &sfx_stream)) { + sfx_stream = 0; + } else { + if (!SFileDdaBeginEx(sfx_stream, 0x40000, 0, 0, lVolume, lPan, 0)) + sfx_stop(); + else + sfx_data_cur = pSFX; + } + } } int __fastcall RndSFX(int psfx) { - int v1; // esi - int v3; // [esp-4h] [ebp-8h] + int v1; // esi + int v3; // [esp-4h] [ebp-8h] - v1 = psfx; - switch (psfx) { - case PS_WARR69: - goto LABEL_12; - case PS_WARR14: - case PS_WARR15: - case PS_WARR16: - goto LABEL_19; - case PS_MAGE69: - case PS_ROGUE69: - case PS_SWING: - case LS_ACID: - case IS_FMAG: - case IS_MAGIC: - case IS_BHIT: - LABEL_12: - v3 = 2; - LABEL_15: - return v1 + random(165, v3); - case PS_WARR2: - LABEL_19: - v3 = 3; - goto LABEL_15; - } - return psfx; + v1 = psfx; + switch (psfx) { + case PS_WARR69: + goto LABEL_12; + case PS_WARR14: + case PS_WARR15: + case PS_WARR16: + goto LABEL_19; + case PS_MAGE69: + case PS_ROGUE69: + case PS_SWING: + case LS_ACID: + case IS_FMAG: + case IS_MAGIC: + case IS_BHIT: + LABEL_12: + v3 = 2; + LABEL_15: + return v1 + random(165, v3); + case PS_WARR2: + LABEL_19: + v3 = 3; + goto LABEL_15; + } + return psfx; } void __fastcall PlaySfxLoc(int psfx, int x, int y) { - psfx = RndSFX(psfx); + psfx = RndSFX(psfx); - if (psfx >= 0 && psfx <= 3) { - TSnd *pSnd = sgSFX[psfx].pSnd; - if (pSnd) - pSnd->start_tc = 0; - } + if (psfx >= 0 && psfx <= 3) { + TSnd *pSnd = sgSFX[psfx].pSnd; + if (pSnd) + pSnd->start_tc = 0; + } - PlaySFX_priv(&sgSFX[psfx], 1, x, y); + PlaySFX_priv(&sgSFX[psfx], 1, x, y); } void __cdecl FreeMonsterSnd() { - snd_update(TRUE); - sfx_stop(); - sound_stop(); + snd_update(TRUE); + sfx_stop(); + sound_stop(); - for (int i = 0; i < nummtypes; i++) { - for (int j = 0; j < 4; j++) { - for (int k = 0; k < 2; k++) { - snd_stop_snd(Monsters[i].Snds[j][k]); - } - } - } + for (int i = 0; i < nummtypes; i++) { + for (int j = 0; j < 4; j++) { + for (int k = 0; k < 2; k++) { + snd_stop_snd(Monsters[i].Snds[j][k]); + } + } + } } void __cdecl sound_stop() { - int i; // edi + int i; // edi - for (i = 0; i < NUM_SFX; i++) { - if (sgSFX[i].pSnd) - snd_stop_snd(sgSFX[i].pSnd); - } + for (i = 0; i < NUM_SFX; i++) { + if (sgSFX[i].pSnd) + snd_stop_snd(sgSFX[i].pSnd); + } } void __cdecl sound_update() { - //int v0; // ebp - //unsigned int v1; // ecx - // int v2; // eax - unsigned int v3; // [esp-Ch] [ebp-Ch] - unsigned int v4; // [esp-8h] [ebp-8h] - //int v5; // [esp-4h] [ebp-4h] + //int v0; // ebp + //unsigned int v1; // ecx + // int v2; // eax + unsigned int v3; // [esp-Ch] [ebp-Ch] + unsigned int v4; // [esp-8h] [ebp-8h] + //int v5; // [esp-4h] [ebp-4h] - if (gbSndInited) { - snd_update(0); - //v5 = v0; - //v4 = v1; - //v3 = v1; - if (sfx_stream) { - //_LOBYTE(v2) = SFileDdaGetPos(sfx_stream, (int)&v4, (int)&v3); - if (SFileDdaGetPos(sfx_stream, (int)&v4, (int)&v3)) { - if (v4 >= v3) - sfx_stop(); - } - } - } + if (gbSndInited) { + snd_update(0); + //v5 = v0; + //v4 = v1; + //v3 = v1; + if (sfx_stream) { + //_LOBYTE(v2) = SFileDdaGetPos(sfx_stream, (int)&v4, (int)&v3); + if (SFileDdaGetPos(sfx_stream, (int)&v4, (int)&v3)) { + if (v4 >= v3) + sfx_stop(); + } + } + } } // 415DBA: could not find valid save-restore pair for ebp void __cdecl effects_cleanup_sfx() { - FreeMonsterSnd(); + FreeMonsterSnd(); - for (DWORD i = 0; i < NUM_SFX; i++) { - if (sgSFX[i].pSnd) { - sound_file_cleanup(sgSFX[i].pSnd); - sgSFX[i].pSnd = NULL; - } - } + for (DWORD i = 0; i < NUM_SFX; i++) { + if (sgSFX[i].pSnd) { + sound_file_cleanup(sgSFX[i].pSnd); + sgSFX[i].pSnd = NULL; + } + } } void __cdecl stream_update() { - UCHAR mask = 0; - if (gbMaxPlayers > 1) { - mask = SFX_WARRIOR | SFX_ROGUE | SFX_SORCEROR; - } else if (plr[myplr]._pClass == PC_WARRIOR) { - mask = SFX_WARRIOR; - } else if (plr[myplr]._pClass == PC_ROGUE) { - mask = SFX_ROGUE; - } else if (plr[myplr]._pClass == PC_SORCERER) { - mask = SFX_SORCEROR; - } else { - TermMsg("effects:1"); - } + UCHAR mask = 0; + if (gbMaxPlayers > 1) { + mask = SFX_WARRIOR | SFX_ROGUE | SFX_SORCEROR; + } else if (plr[myplr]._pClass == PC_WARRIOR) { + mask = SFX_WARRIOR; + } else if (plr[myplr]._pClass == PC_ROGUE) { + mask = SFX_ROGUE; + } else if (plr[myplr]._pClass == PC_SORCERER) { + mask = SFX_SORCEROR; + } else { + TermMsg("effects:1"); + } - priv_sound_init(mask); + priv_sound_init(mask); } // 679660: using guessed type char gbMaxPlayers; void __fastcall priv_sound_init(UCHAR bLoadMask) { - if (!gbSndInited) { - return; - } + if (!gbSndInited) { + return; + } - UCHAR pc = bLoadMask & (SFX_ROGUE | SFX_WARRIOR | SFX_SORCEROR); - bLoadMask ^= pc; + UCHAR pc = bLoadMask & (SFX_ROGUE | SFX_WARRIOR | SFX_SORCEROR); + bLoadMask ^= pc; - for (DWORD i = 0; i < NUM_SFX; i++) { - if (sgSFX[i].pSnd) { - continue; - } + for (DWORD i = 0; i < NUM_SFX; i++) { + if (sgSFX[i].pSnd) { + continue; + } - UCHAR bFlags = sgSFX[i].bFlags; - if (bFlags & SFX_STREAM) { - continue; - } + UCHAR bFlags = sgSFX[i].bFlags; + if (bFlags & SFX_STREAM) { + continue; + } - if (bLoadMask && !(bFlags & bLoadMask)) { - continue; - } + if (bLoadMask && !(bFlags & bLoadMask)) { + continue; + } - if (bFlags & (SFX_ROGUE | SFX_WARRIOR | SFX_SORCEROR) && !(bFlags & pc)) { - continue; - } + if (bFlags & (SFX_ROGUE | SFX_WARRIOR | SFX_SORCEROR) && !(bFlags & pc)) { + continue; + } - sgSFX[i].pSnd = sound_file_load(sgSFX[i].pszName); - } + sgSFX[i].pSnd = sound_file_load(sgSFX[i].pszName); + } } void __cdecl sound_init() { - priv_sound_init(SFX_UI); + priv_sound_init(SFX_UI); } void __stdcall effects_play_sound(char *snd_file) { - if (!gbSndInited || !gbSoundOn) { - return; - } + if (!gbSndInited || !gbSoundOn) { + return; + } - for (DWORD i = 0; i < NUM_SFX; i++) { - if (!_strcmpi(sgSFX[i].pszName, snd_file) && sgSFX[i].pSnd) { - if (!snd_playing(sgSFX[i].pSnd)) - snd_play_snd(sgSFX[i].pSnd, 0, 0); + for (DWORD i = 0; i < NUM_SFX; i++) { + if (!_strcmpi(sgSFX[i].pszName, snd_file) && sgSFX[i].pSnd) { + if (!snd_playing(sgSFX[i].pSnd)) + snd_play_snd(sgSFX[i].pSnd, 0, 0); - return; - } - } + return; + } + } } diff --git a/Source/encrypt.cpp b/Source/encrypt.cpp index b9453a6a..e95b2f1a 100644 --- a/Source/encrypt.cpp +++ b/Source/encrypt.cpp @@ -6,191 +6,191 @@ int hashtable[1280]; void __fastcall Decrypt(void *block, int size, int key) { - unsigned int v3; // edx - int v4; // eax - unsigned int v5; // edi - unsigned int v6; // edx - int v7; // eax - int v8; // esi + unsigned int v3; // edx + int v4; // eax + unsigned int v5; // edi + unsigned int v6; // edx + int v7; // eax + int v8; // esi - v3 = (unsigned int)size >> 2; - v4 = 0xEEEEEEEE; - if (v3) { - v5 = v3; - v6 = key; - do { - v7 = hashtable[(unsigned char)v6 + 1024] + v4; - *(_DWORD *)block ^= v7 + v6; - v8 = *(_DWORD *)block; - block = (char *)block + 4; - v4 = 33 * v7 + v8 + 3; - v6 = ((~v6 << 21) + 0x11111111) | (v6 >> 11); - --v5; - } while (v5); - } + v3 = (unsigned int)size >> 2; + v4 = 0xEEEEEEEE; + if (v3) { + v5 = v3; + v6 = key; + do { + v7 = hashtable[(unsigned char)v6 + 1024] + v4; + *(_DWORD *)block ^= v7 + v6; + v8 = *(_DWORD *)block; + block = (char *)block + 4; + v4 = 33 * v7 + v8 + 3; + v6 = ((~v6 << 21) + 0x11111111) | (v6 >> 11); + --v5; + } while (v5); + } } void __fastcall Encrypt(void *block, int size, int key) { - unsigned int v3; // edx - int v4; // eax - unsigned int v5; // edi - unsigned int v6; // edx - int v7; // eax - int v8; // ebx + unsigned int v3; // edx + int v4; // eax + unsigned int v5; // edi + unsigned int v6; // edx + int v7; // eax + int v8; // ebx - v3 = (unsigned int)size >> 2; - v4 = 0xEEEEEEEE; - if (v3) { - v5 = v3; - v6 = key; - do { - v7 = hashtable[(unsigned char)v6 + 1024] + v4; - v8 = *(_DWORD *)block ^ (v7 + v6); - v4 = 33 * v7 + *(_DWORD *)block + 3; - *(_DWORD *)block = v8; - block = (char *)block + 4; - v6 = ((~v6 << 21) + 0x11111111) | (v6 >> 11); - --v5; - } while (v5); - } + v3 = (unsigned int)size >> 2; + v4 = 0xEEEEEEEE; + if (v3) { + v5 = v3; + v6 = key; + do { + v7 = hashtable[(unsigned char)v6 + 1024] + v4; + v8 = *(_DWORD *)block ^ (v7 + v6); + v4 = 33 * v7 + *(_DWORD *)block + 3; + *(_DWORD *)block = v8; + block = (char *)block + 4; + v6 = ((~v6 << 21) + 0x11111111) | (v6 >> 11); + --v5; + } while (v5); + } } int __fastcall Hash(const char *s, int type) { - int v2; // ebp - const char *v3; // ebx - signed int v4; // esi - int v5; // edi - int v6; // ST00_4 - char v7; // al + int v2; // ebp + const char *v3; // ebx + signed int v4; // esi + int v5; // edi + int v6; // ST00_4 + char v7; // al - v2 = type; - v3 = s; - v4 = 0x7FED7FED; - v5 = 0xEEEEEEEE; - while (v3 && *v3) { - v6 = *v3++; - v7 = toupper(v6); - v4 = (v5 + v4) ^ hashtable[v7 + (v2 << 8)]; - v5 = v7 + 33 * v5 + v4 + 3; - } - return v4; + v2 = type; + v3 = s; + v4 = 0x7FED7FED; + v5 = 0xEEEEEEEE; + while (v3 && *v3) { + v6 = *v3++; + v7 = toupper(v6); + v4 = (v5 + v4) ^ hashtable[v7 + (v2 << 8)]; + v5 = v7 + 33 * v5 + v4 + 3; + } + return v4; } void __cdecl InitHash() { - unsigned int v0; // eax - int *v1; // edi - unsigned int v2; // eax - int v3; // ecx - signed int v4; // [esp+Ch] [ebp-8h] - int *v5; // [esp+10h] [ebp-4h] + unsigned int v0; // eax + int *v1; // edi + unsigned int v2; // eax + int v3; // ecx + signed int v4; // [esp+Ch] [ebp-8h] + int *v5; // [esp+10h] [ebp-4h] - v0 = 0x100001; - v5 = hashtable; - do { - v1 = v5; - v4 = 5; - do { - v2 = (125 * v0 + 3) % 0x2AAAAB; - v3 = (unsigned short)v2 << 16; - v0 = (125 * v2 + 3) % 0x2AAAAB; - *v1 = (unsigned short)v0 | v3; - v1 += 256; - --v4; - } while (v4); - ++v5; - } while ((signed int)v5 < (signed int)&hashtable[256]); + v0 = 0x100001; + v5 = hashtable; + do { + v1 = v5; + v4 = 5; + do { + v2 = (125 * v0 + 3) % 0x2AAAAB; + v3 = (unsigned short)v2 << 16; + v0 = (125 * v2 + 3) % 0x2AAAAB; + *v1 = (unsigned short)v0 | v3; + v1 += 256; + --v4; + } while (v4); + ++v5; + } while ((signed int)v5 < (signed int)&hashtable[256]); } int __fastcall PkwareCompress(void *buf, int size) { - unsigned char *v2; // ebx - unsigned char *v3; // esi - int v4; // ecx - unsigned char *v5; // edi - TDataInfo param; // [esp+Ch] [ebp-20h] - unsigned int type; // [esp+20h] [ebp-Ch] - unsigned int dsize; // [esp+24h] [ebp-8h] - char *ptr; // [esp+28h] [ebp-4h] + unsigned char *v2; // ebx + unsigned char *v3; // esi + int v4; // ecx + unsigned char *v5; // edi + TDataInfo param; // [esp+Ch] [ebp-20h] + unsigned int type; // [esp+20h] [ebp-Ch] + unsigned int dsize; // [esp+24h] [ebp-8h] + char *ptr; // [esp+28h] [ebp-4h] - v2 = (unsigned char *)buf; - v3 = (unsigned char *)size; - ptr = (char *)DiabloAllocPtr(CMP_BUFFER_SIZE); // 36312 - v4 = 2 * (_DWORD)v3; - if ((unsigned int)(2 * (_DWORD)v3) < 0x2000) - v4 = 0x2000; - v5 = (unsigned char *)DiabloAllocPtr(v4); - param.pbInBuffEnd = 0; - param.pbOutBuffEnd = 0; - type = 0; - param.pbInBuff = v2; - param.pbOutBuff = v5; - param.pbSize = v3; - dsize = 4096; - implode( - PkwareBufferRead, - PkwareBufferWrite, - ptr, - ¶m, - &type, - &dsize); - if (param.pbOutBuffEnd < v3) { - memcpy(v2, v5, (size_t)param.pbOutBuffEnd); - v3 = param.pbOutBuffEnd; - } - mem_free_dbg(ptr); - mem_free_dbg(v5); - return (int)v3; + v2 = (unsigned char *)buf; + v3 = (unsigned char *)size; + ptr = (char *)DiabloAllocPtr(CMP_BUFFER_SIZE); // 36312 + v4 = 2 * (_DWORD)v3; + if ((unsigned int)(2 * (_DWORD)v3) < 0x2000) + v4 = 0x2000; + v5 = (unsigned char *)DiabloAllocPtr(v4); + param.pbInBuffEnd = 0; + param.pbOutBuffEnd = 0; + type = 0; + param.pbInBuff = v2; + param.pbOutBuff = v5; + param.pbSize = v3; + dsize = 4096; + implode( + PkwareBufferRead, + PkwareBufferWrite, + ptr, + ¶m, + &type, + &dsize); + if (param.pbOutBuffEnd < v3) { + memcpy(v2, v5, (size_t)param.pbOutBuffEnd); + v3 = param.pbOutBuffEnd; + } + mem_free_dbg(ptr); + mem_free_dbg(v5); + return (int)v3; } unsigned int __cdecl PkwareBufferRead(char *buf, unsigned int *size, void *param) { - TDataInfo *pInfo = (TDataInfo *)param; - int v3; // edi - unsigned char *v4; // ecx + TDataInfo *pInfo = (TDataInfo *)param; + int v3; // edi + unsigned char *v4; // ecx - v3 = *size; - v4 = pInfo->pbInBuffEnd; - if (*size >= (unsigned int)(pInfo->pbSize - v4)) - v3 = pInfo->pbSize - v4; - memcpy(buf, &v4[(unsigned int)pInfo->pbInBuff], v3); - pInfo->pbInBuffEnd += v3; - return v3; + v3 = *size; + v4 = pInfo->pbInBuffEnd; + if (*size >= (unsigned int)(pInfo->pbSize - v4)) + v3 = pInfo->pbSize - v4; + memcpy(buf, &v4[(unsigned int)pInfo->pbInBuff], v3); + pInfo->pbInBuffEnd += v3; + return v3; } void __cdecl PkwareBufferWrite(char *buf, unsigned int *size, void *param) { - TDataInfo *pInfo = (TDataInfo *)param; + TDataInfo *pInfo = (TDataInfo *)param; - memcpy(&pInfo->pbOutBuffEnd[(unsigned int)pInfo->pbOutBuff], buf, *size); - pInfo->pbOutBuffEnd += *size; + memcpy(&pInfo->pbOutBuffEnd[(unsigned int)pInfo->pbOutBuff], buf, *size); + pInfo->pbOutBuffEnd += *size; } void __fastcall PkwareDecompress(void *param, int recv_size, int dwMaxBytes) { - unsigned char *v3; // edi - unsigned char *v4; // ebx - unsigned char *v5; // esi - TDataInfo info; // [esp+Ch] [ebp-18h] - char *ptr; // [esp+20h] [ebp-4h] + unsigned char *v3; // edi + unsigned char *v4; // ebx + unsigned char *v5; // esi + TDataInfo info; // [esp+Ch] [ebp-18h] + char *ptr; // [esp+20h] [ebp-4h] - v3 = (unsigned char *)param; - v4 = (unsigned char *)recv_size; - ptr = (char *)DiabloAllocPtr(CMP_BUFFER_SIZE); // 36312 - v5 = (unsigned char *)DiabloAllocPtr(dwMaxBytes); - info.pbInBuffEnd = 0; - info.pbOutBuffEnd = 0; - info.pbInBuff = v3; - info.pbOutBuff = v5; - info.pbSize = v4; - explode( - PkwareBufferRead, - PkwareBufferWrite, - ptr, - &info); - memcpy(v3, v5, (size_t)info.pbOutBuffEnd); - mem_free_dbg(ptr); - mem_free_dbg(v5); + v3 = (unsigned char *)param; + v4 = (unsigned char *)recv_size; + ptr = (char *)DiabloAllocPtr(CMP_BUFFER_SIZE); // 36312 + v5 = (unsigned char *)DiabloAllocPtr(dwMaxBytes); + info.pbInBuffEnd = 0; + info.pbOutBuffEnd = 0; + info.pbInBuff = v3; + info.pbOutBuff = v5; + info.pbSize = v4; + explode( + PkwareBufferRead, + PkwareBufferWrite, + ptr, + &info); + memcpy(v3, v5, (size_t)info.pbOutBuffEnd); + mem_free_dbg(ptr); + mem_free_dbg(v5); } diff --git a/Source/engine.cpp b/Source/engine.cpp index 4c4c43fd..0ccd2c60 100644 --- a/Source/engine.cpp +++ b/Source/engine.cpp @@ -3,21 +3,20 @@ #include "../types.h" int engine_cpp_init_value; // weak -char gbPixelCol; // automap pixel color 8-bit (palette entry) -int dword_52B970; // bool flip - if y < x -int orgseed; // weak +char gbPixelCol; // automap pixel color 8-bit (palette entry) +int dword_52B970; // bool flip - if y < x +int orgseed; // weak int sgnWidth; int sglGameSeed; // weak static CRITICAL_SECTION sgMemCrit; -int SeedCount; // weak +int SeedCount; // weak int dword_52B99C; // bool valid - if x/y are in bounds -const int engine_inf = 0x7F800000; // weak -const int rand_increment = 1; // unused +const int engine_inf = 0x7F800000; // weak +const int rand_increment = 1; // unused const int rand_multiplier = 0x015A4E35; // unused -struct engine_cpp_init_1 -{ +struct engine_cpp_init_1 { engine_cpp_init_1() { engine_cpp_init_value = engine_inf; @@ -28,121 +27,108 @@ struct engine_cpp_init_1 void __fastcall CelDrawDatOnly(char *pDecodeTo, char *pRLEBytes, int dwRLESize, int dwRLEWdt) { - char *v4; // esi - char *v5; // edi - int v6; // edx - unsigned int v7; // eax - unsigned int v8; // ecx - char v9; // cf + char *v4; // esi + char *v5; // edi + int v6; // edx + unsigned int v7; // eax + unsigned int v8; // ecx + char v9; // cf unsigned int v10; // ecx - char *v11; // [esp+4h] [ebp-8h] + char *v11; // [esp+4h] [ebp-8h] v11 = pRLEBytes; - if ( pDecodeTo && pRLEBytes ) - { + if (pDecodeTo && pRLEBytes) { v4 = pRLEBytes; v5 = pDecodeTo; - do - { + do { v6 = dwRLEWdt; - do - { - while ( 1 ) - { + do { + while (1) { v7 = (unsigned char)*v4++; - if ( (v7 & 0x80u) == 0 ) + if ((v7 & 0x80u) == 0) break; _LOBYTE(v7) = -(char)v7; v5 += v7; v6 -= v7; - if ( !v6 ) + if (!v6) goto LABEL_14; } v6 -= v7; v8 = v7 >> 1; - if ( v7 & 1 ) - { + if (v7 & 1) { *v5++ = *v4++; - if ( !v8 ) + if (!v8) continue; } v9 = v8 & 1; v10 = v7 >> 2; - if ( v9 ) - { + if (v9) { *(_WORD *)v5 = *(_WORD *)v4; v4 += 2; v5 += 2; - if ( !v10 ) + if (!v10) continue; } qmemcpy(v5, v4, 4 * v10); v4 += 4 * v10; v5 += 4 * v10; - } - while ( v6 ); -LABEL_14: + } while (v6); + LABEL_14: v5 += -dwRLEWdt - 768; - } - while ( &v11[dwRLESize] != v4 ); + } while (&v11[dwRLESize] != v4); } } void __fastcall CelDecodeOnly(int screen_x, int screen_y, void *pCelBuff, int frame, int frame_width) { - if ( gpBuffer ) - { - if ( pCelBuff ) + if (gpBuffer) { + if (pCelBuff) CelDrawDatOnly( - (char *)gpBuffer + screen_y_times_768[screen_y] + screen_x, - (char *)pCelBuff + *((_DWORD *)pCelBuff + frame), - *((_DWORD *)pCelBuff + frame + 1) - *((_DWORD *)pCelBuff + frame), - frame_width); + (char *)gpBuffer + screen_y_times_768[screen_y] + screen_x, + (char *)pCelBuff + *((_DWORD *)pCelBuff + frame), + *((_DWORD *)pCelBuff + frame + 1) - *((_DWORD *)pCelBuff + frame), + frame_width); } } void __fastcall CelDecDatOnly(char *pBuff, char *pCelBuff, int frame, int frame_width) { - if ( pCelBuff ) - { - if ( pBuff ) + if (pCelBuff) { + if (pBuff) CelDrawDatOnly( - pBuff, - &pCelBuff[*(_DWORD *)&pCelBuff[4 * frame]], - *(_DWORD *)&pCelBuff[4 * frame + 4] - *(_DWORD *)&pCelBuff[4 * frame], - frame_width); + pBuff, + &pCelBuff[*(_DWORD *)&pCelBuff[4 * frame]], + *(_DWORD *)&pCelBuff[4 * frame + 4] - *(_DWORD *)&pCelBuff[4 * frame], + frame_width); } } void __fastcall CelDrawHdrOnly(int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int always_0, int direction) { - int v7; // edx + int v7; // edx char *v8; // eax - int v9; // edi - int v10; // ecx - int v11; // [esp+Ch] [ebp-8h] - int v12; // [esp+10h] [ebp-4h] + int v9; // edi + int v10; // ecx + int v11; // [esp+Ch] [ebp-8h] + int v12; // [esp+10h] [ebp-4h] v12 = screen_y; v11 = screen_x; - if ( gpBuffer ) - { - if ( pCelBuff ) - { + if (gpBuffer) { + if (pCelBuff) { v7 = *(_DWORD *)&pCelBuff[4 * frame]; v8 = &pCelBuff[v7]; v9 = *(unsigned short *)&pCelBuff[v7 + always_0]; - if ( *(_WORD *)&pCelBuff[v7 + always_0] ) - { - if ( direction != 8 && *(_WORD *)&v8[direction] ) + if (*(_WORD *)&pCelBuff[v7 + always_0]) { + if (direction != 8 && *(_WORD *)&v8[direction]) v10 = *(unsigned short *)&v8[direction] - v9; else v10 = *(_DWORD *)&pCelBuff[4 * frame + 4] - v7 - v9; CelDrawDatOnly( - (char *)gpBuffer + screen_y_times_768[v12 - 16 * always_0] + v11, - &v8[v9], - v10, - frame_width); + (char *)gpBuffer + screen_y_times_768[v12 - 16 * always_0] + v11, + &v8[v9], + v10, + frame_width); } } } @@ -150,23 +136,20 @@ void __fastcall CelDrawHdrOnly(int screen_x, int screen_y, char *pCelBuff, int f void __fastcall CelDecodeHdrOnly(char *pBuff, char *pCelBuff, int frame, int frame_width, int always_0, int direction) { - int v6; // esi + int v6; // esi char *v7; // eax - int v8; // ebx - int v9; // edx - int v10; // edx + int v8; // ebx + int v9; // edx + int v10; // edx - if ( pCelBuff ) - { - if ( pBuff ) - { + if (pCelBuff) { + if (pBuff) { v6 = *(_DWORD *)&pCelBuff[4 * frame]; v7 = &pCelBuff[v6]; v8 = *(unsigned short *)&pCelBuff[v6 + always_0]; - if ( *(_WORD *)&pCelBuff[v6 + always_0] ) - { + if (*(_WORD *)&pCelBuff[v6 + always_0]) { v9 = *(_DWORD *)&pCelBuff[4 * frame + 4] - v6; - if ( direction != 8 && *(_WORD *)&v7[direction] ) + if (direction != 8 && *(_WORD *)&v7[direction]) v10 = *(unsigned short *)&v7[direction] - v8; else v10 = v9 - v8; @@ -181,62 +164,55 @@ void __fastcall CelDecDatLightOnly(char *pDecodeTo, char *pRLEBytes, int frame_c char *v4; // esi char *v5; // edi char *v6; // ebx - int v7; // edx - int v8; // eax - int v9; // ST00_4 + int v7; // edx + int v8; // eax + int v9; // ST00_4 char *a3; // [esp+Ch] [ebp-10h] - if ( pDecodeTo && pRLEBytes ) - { + if (pDecodeTo && pRLEBytes) { a3 = &pLightTbl[256 * light_table_index]; v4 = pRLEBytes; v5 = pDecodeTo; v6 = &pRLEBytes[frame_content_size]; - do - { + do { v7 = frame_width; - do - { - while ( 1 ) - { + do { + while (1) { v8 = (unsigned char)*v4++; - if ( (v8 & 0x80u) != 0 ) /* check sign */ + if ((v8 & 0x80u) != 0) /* check sign */ break; v9 = v7 - v8; CelDecDatLightEntry(v8, a3, v5, v4); v7 = v9; - if ( !v9 ) + if (!v9) goto LABEL_9; } _LOBYTE(v8) = -(char)v8; v5 += v8; v7 -= v8; - } - while ( v7 ); -LABEL_9: + } while (v7); + LABEL_9: v5 += -frame_width - 768; - } - while ( v6 != v4 ); + } while (v6 != v4); } } // 69BEF8: using guessed type int light_table_index; void __fastcall CelDecDatLightEntry(unsigned char shift, char *LightIndex, char *&pDecodeTo, char *&pRLEBytes) { - char v5; // cf + char v5; // cf unsigned char v6; // cl - char v7; // cl - int v8; // eax - char v9; // ch - int tmp; // eax - char v11; // ch - char v12; // ch + char v7; // cl + int v8; // eax + char v9; // ch + int tmp; // eax + char v11; // ch + char v12; // ch unsigned char a1; v5 = shift & 1; v6 = shift >> 1; - if ( v5 ) - { + if (v5) { a1 = *pRLEBytes; *pDecodeTo = LightIndex[a1]; ++pRLEBytes; @@ -244,8 +220,7 @@ void __fastcall CelDecDatLightEntry(unsigned char shift, char *LightIndex, char } v5 = v6 & 1; v7 = v6 >> 1; - if ( v5 ) - { + if (v5) { a1 = *pRLEBytes; *pDecodeTo = LightIndex[a1]; a1 = pRLEBytes[1]; @@ -253,8 +228,7 @@ void __fastcall CelDecDatLightEntry(unsigned char shift, char *LightIndex, char pRLEBytes += 2; pDecodeTo += 2; } - for ( ; v7; --v7 ) - { + for (; v7; --v7) { v8 = *(_DWORD *)pRLEBytes; pRLEBytes += 4; a1 = v8; @@ -275,165 +249,147 @@ void __fastcall CelDecDatLightEntry(unsigned char shift, char *LightIndex, char void __fastcall CelDecDatLightTrans(char *pDecodeTo, char *pRLEBytes, int frame_content_size, int frame_width) { - char *v4; // esi - int v5; // edi - char *v6; // ebx - int v7; // edx - unsigned int v8; // eax + char *v4; // esi + int v5; // edi + char *v6; // ebx + int v7; // edx + unsigned int v8; // eax unsigned int v10; // ecx - char v11; // cf + char v11; // cf unsigned int v12; // ecx - char *v13; // esi - _BYTE *v14; // edi - _BYTE *v18; // edi + char *v13; // esi + _BYTE *v14; // edi + _BYTE *v18; // edi unsigned int v21; // ecx - _BYTE *v25; // edi - char *v26; // [esp-4h] [ebp-24h] - char *v27; // [esp+Ch] [ebp-14h] - int v28; // [esp+14h] [ebp-Ch] + _BYTE *v25; // edi + char *v26; // [esp-4h] [ebp-24h] + char *v27; // [esp+Ch] [ebp-14h] + int v28; // [esp+14h] [ebp-Ch] int _EAX; char *_EBX; - if ( pDecodeTo && pRLEBytes ) - { + if (pDecodeTo && pRLEBytes) { v27 = &pLightTbl[256 * light_table_index]; v4 = pRLEBytes; v5 = (int)pDecodeTo; v6 = &pRLEBytes[frame_content_size]; v28 = (unsigned char)pDecodeTo & 1; - do - { + do { v7 = frame_width; - do - { - while ( 1 ) - { + do { + while (1) { v8 = (unsigned char)*v4++; - if ( (v8 & 0x80u) != 0 ) + if ((v8 & 0x80u) != 0) break; v26 = v6; _EBX = v27; v7 -= v8; - if ( (v5 & 1) == v28 ) - { + if ((v5 & 1) == v28) { v10 = v8 >> 1; - if ( !(v8 & 1) ) + if (!(v8 & 1)) goto LABEL_10; ++v4; ++v5; - if ( v10 ) - { -LABEL_17: + if (v10) { + LABEL_17: v11 = v10 & 1; v21 = v10 >> 1; - if ( !v11 ) + if (!v11) goto LABEL_26; _EAX = *v4; - ASM_XLAT(_EAX,_EBX); + ASM_XLAT(_EAX, _EBX); *(_BYTE *)v5 = _EAX; v4 += 2; v5 += 2; - if ( v21 ) - { -LABEL_26: - do - { + if (v21) { + LABEL_26: + do { _EAX = *(_DWORD *)v4; v4 += 4; - ASM_XLAT(_EAX,_EBX); + ASM_XLAT(_EAX, _EBX); *(_BYTE *)v5 = _EAX; v25 = (_BYTE *)(v5 + 2); _EAX = __ROR4__(_EAX, 16); - ASM_XLAT(_EAX,_EBX); + ASM_XLAT(_EAX, _EBX); *v25 = _EAX; v5 = (int)(v25 + 2); --v21; - } - while ( v21 ); + } while (v21); } goto LABEL_20; } - } - else - { + } else { v10 = v8 >> 1; - if ( !(v8 & 1) ) + if (!(v8 & 1)) goto LABEL_17; _EAX = *v4++; - ASM_XLAT(_EAX,_EBX); + ASM_XLAT(_EAX, _EBX); *(_BYTE *)v5++ = _EAX; - if ( v10 ) - { -LABEL_10: + if (v10) { + LABEL_10: v11 = v10 & 1; v12 = v10 >> 1; - if ( !v11 ) + if (!v11) goto LABEL_27; v13 = v4 + 1; v14 = (_BYTE *)(v5 + 1); _EAX = *v13; v4 = v13 + 1; - ASM_XLAT(_EAX,_EBX); + ASM_XLAT(_EAX, _EBX); *v14 = _EAX; v5 = (int)(v14 + 1); - if ( v12 ) - { -LABEL_27: - do - { + if (v12) { + LABEL_27: + do { _EAX = *(_DWORD *)v4; v4 += 4; v18 = (_BYTE *)(v5 + 1); _EAX = __ROR4__(_EAX, 8); - ASM_XLAT(_EAX,_EBX); + ASM_XLAT(_EAX, _EBX); *v18 = _EAX; _EAX = __ROR4__(_EAX, 16); v18 += 2; - ASM_XLAT(_EAX,_EBX); + ASM_XLAT(_EAX, _EBX); *v18 = _EAX; v5 = (int)(v18 + 1); --v12; - } - while ( v12 ); + } while (v12); } goto LABEL_20; } } -LABEL_20: + LABEL_20: v6 = v26; - if ( !v7 ) + if (!v7) goto LABEL_23; } _LOBYTE(v8) = -(char)v8; v5 += v8; v7 -= v8; - } - while ( v7 ); -LABEL_23: + } while (v7); + LABEL_23: v5 -= frame_width + 768; v28 = ((_BYTE)v28 + 1) & 1; - } - while ( v6 != v4 ); + } while (v6 != v4); } } // 69BEF8: using guessed type int light_table_index; void __fastcall CelDecodeLightOnly(int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width) { - int v5; // ebx - int v6; // esi + int v5; // ebx + int v6; // esi char *v7; // edx char *v8; // ecx - int v9; // [esp-8h] [ebp-14h] + int v9; // [esp-8h] [ebp-14h] v5 = screen_y; - if ( gpBuffer && pCelBuff ) - { + if (gpBuffer && pCelBuff) { v6 = *(_DWORD *)&pCelBuff[4 * frame]; v7 = &pCelBuff[v6]; v8 = (char *)gpBuffer + screen_y_times_768[v5] + screen_x; v9 = *(_DWORD *)&pCelBuff[4 * frame + 4] - v6; - if ( light_table_index ) + if (light_table_index) CelDecDatLightOnly(v8, v7, v9, frame_width); else CelDrawDatOnly(v8, v7, v9, frame_width); @@ -443,37 +399,34 @@ void __fastcall CelDecodeLightOnly(int screen_x, int screen_y, char *pCelBuff, i void __fastcall CelDecodeHdrLightOnly(int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int always_0, int direction) { - int v7; // esi - char *v8; // ecx - int v9; // edi - char *v10; // edx - int v11; // ebx - int v12; // ebx - char *v13; // edx - char *v14; // ecx - int v15; // [esp+Ch] [ebp-4h] + int v7; // esi + char *v8; // ecx + int v9; // edi + char *v10; // edx + int v11; // ebx + int v12; // ebx + char *v13; // edx + char *v14; // ecx + int v15; // [esp+Ch] [ebp-4h] char *cel_buf; // [esp+18h] [ebp+8h] v7 = screen_y; v15 = screen_x; - if ( gpBuffer ) - { + if (gpBuffer) { v8 = pCelBuff; - if ( pCelBuff ) - { + if (pCelBuff) { v9 = *(_DWORD *)&pCelBuff[4 * frame]; v10 = &pCelBuff[v9]; v11 = *(unsigned short *)&pCelBuff[v9 + always_0]; cel_buf = (char *)*(unsigned short *)&pCelBuff[v9 + always_0]; - if ( v11 ) - { - if ( direction != 8 && *(_WORD *)&v10[direction] ) + if (v11) { + if (direction != 8 && *(_WORD *)&v10[direction]) v12 = *(unsigned short *)&v10[direction] - (_DWORD)cel_buf; else v12 = *(_DWORD *)&v8[4 * frame + 4] - v9 - (_DWORD)cel_buf; v13 = &v10[(_DWORD)cel_buf]; v14 = (char *)gpBuffer + screen_y_times_768[v7 - 16 * always_0] + v15; - if ( light_table_index ) + if (light_table_index) CelDecDatLightOnly(v14, v13, v12, frame_width); else CelDrawDatOnly(v14, v13, v12, frame_width); @@ -485,40 +438,32 @@ void __fastcall CelDecodeHdrLightOnly(int screen_x, int screen_y, char *pCelBuff void __fastcall CelDecodeHdrLightTrans(char *pBuff, char *pCelBuff, int frame, int frame_width, int always_0, int direction) { - char *v6; // eax - int v7; // esi - char *v8; // edx - int v9; // ebx - int v10; // eax - int v11; // eax + char *v6; // eax + int v7; // esi + char *v8; // edx + int v9; // ebx + int v10; // eax + int v11; // eax char *v12; // edx v6 = pCelBuff; - if ( pCelBuff ) - { - if ( pBuff ) - { + if (pCelBuff) { + if (pBuff) { v7 = *(_DWORD *)&pCelBuff[4 * frame]; v8 = &pCelBuff[v7]; v9 = *(unsigned short *)&v6[v7 + always_0]; - if ( *(_WORD *)&v6[v7 + always_0] ) - { + if (*(_WORD *)&v6[v7 + always_0]) { v10 = *(_DWORD *)&v6[4 * frame + 4] - v7; - if ( direction != 8 && *(_WORD *)&v8[direction] ) + if (direction != 8 && *(_WORD *)&v8[direction]) v11 = *(unsigned short *)&v8[direction] - v9; else v11 = v10 - v9; v12 = &v8[v9]; - if ( cel_transparency_active ) - { + if (cel_transparency_active) { CelDecDatLightTrans(pBuff, v12, v11, frame_width); - } - else if ( light_table_index ) - { + } else if (light_table_index) { CelDecDatLightOnly(pBuff, v12, v11, frame_width); - } - else - { + } else { CelDrawDatOnly(pBuff, v12, v11, frame_width); } } @@ -530,42 +475,39 @@ void __fastcall CelDecodeHdrLightTrans(char *pBuff, char *pCelBuff, int frame, i void __fastcall CelDrawHdrLightRed(int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int always_0, int direction, char always_1) { - char *v8; // esi - int v9; // ebx - int v10; // eax - char *v11; // edi - int v12; // ecx - int v13; // esi - int v14; // eax - int v15; // eax - _BYTE *v16; // esi - char *v17; // edi - int v18; // edx - int v19; // eax - int v20; // ecx - int v21; // [esp+Ch] [ebp-4h] - char *v22; // [esp+Ch] [ebp-4h] - char *cel_buf; // [esp+18h] [ebp+8h] + char *v8; // esi + int v9; // ebx + int v10; // eax + char *v11; // edi + int v12; // ecx + int v13; // esi + int v14; // eax + int v15; // eax + _BYTE *v16; // esi + char *v17; // edi + int v18; // edx + int v19; // eax + int v20; // ecx + int v21; // [esp+Ch] [ebp-4h] + char *v22; // [esp+Ch] [ebp-4h] + char *cel_buf; // [esp+18h] [ebp+8h] char *cel_bufa; // [esp+18h] [ebp+8h] - int framea; // [esp+1Ch] [ebp+Ch] - int always_0a; // [esp+24h] [ebp+14h] + int framea; // [esp+1Ch] [ebp+Ch] + int always_0a; // [esp+24h] [ebp+14h] int directiona; // [esp+28h] [ebp+18h] v21 = screen_x; - if ( gpBuffer ) - { + if (gpBuffer) { v8 = pCelBuff; - if ( pCelBuff ) - { + if (pCelBuff) { v9 = *(_DWORD *)&pCelBuff[4 * frame]; v10 = always_0; v11 = &pCelBuff[v9]; v12 = *(unsigned short *)&pCelBuff[v9 + always_0]; cel_buf = (char *)*(unsigned short *)&pCelBuff[v9 + always_0]; - if ( v12 ) - { + if (v12) { v13 = *(_DWORD *)&v8[4 * frame + 4] - v9; - if ( direction != 8 && *(_WORD *)&v11[direction] ) + if (direction != 8 && *(_WORD *)&v11[direction]) always_0a = *(unsigned short *)&v11[direction] - (_DWORD)cel_buf; else always_0a = v13 - (_DWORD)cel_buf; @@ -575,48 +517,40 @@ void __fastcall CelDrawHdrLightRed(int screen_x, int screen_y, char *pCelBuff, i _LOWORD(v14) = v14 & 0xF400; v15 = v14 + 4096; framea = v15; - if ( always_1 == 2 ) - { + if (always_1 == 2) { v15 += 256; framea = v15; } - if ( always_1 >= 4 ) + if (always_1 >= 4) framea = v15 + (always_1 << 8) - 256; v22 = &pLightTbl[framea]; v16 = (_BYTE *)directiona; v17 = cel_bufa; - do - { + do { v18 = frame_width; - do - { - while ( 1 ) - { + do { + while (1) { v19 = (unsigned char)*v16++; - if ( (v19 & 0x80u) == 0 ) + if ((v19 & 0x80u) == 0) break; _LOBYTE(v19) = -(char)v19; v17 += v19; v18 -= v19; - if ( !v18 ) + if (!v18) goto LABEL_20; } v18 -= v19; v20 = v19; - do - { + do { _LOBYTE(v19) = *v16++; *v17 = v22[v19]; --v20; ++v17; - } - while ( v20 ); - } - while ( v18 ); -LABEL_20: + } while (v20); + } while (v18); + LABEL_20: v17 += -frame_width - 768; - } - while ( (_BYTE *)(directiona + always_0a) != v16 ); + } while ((_BYTE *)(directiona + always_0a) != v16); } } } @@ -625,96 +559,82 @@ LABEL_20: void __fastcall Cel2DecDatOnly(char *pDecodeTo, char *pRLEBytes, int frame_content_size, int frame_width) { - char *v4; // esi - char *v5; // edi - int v6; // edx - unsigned int v7; // eax - unsigned int v8; // ecx - char v9; // cf + char *v4; // esi + char *v5; // edi + int v6; // edx + unsigned int v7; // eax + unsigned int v8; // ecx + char v9; // cf unsigned int v10; // ecx - char *v11; // [esp+4h] [ebp-8h] + char *v11; // [esp+4h] [ebp-8h] v11 = pRLEBytes; - if ( pDecodeTo && pRLEBytes && gpBuffer ) - { + if (pDecodeTo && pRLEBytes && gpBuffer) { v4 = pRLEBytes; v5 = pDecodeTo; - do - { + do { v6 = frame_width; - do - { - while ( 1 ) - { + do { + while (1) { v7 = (unsigned char)*v4++; - if ( (v7 & 0x80u) == 0 ) + if ((v7 & 0x80u) == 0) break; _LOBYTE(v7) = -(char)v7; v5 += v7; v6 -= v7; - if ( !v6 ) + if (!v6) goto LABEL_17; } v6 -= v7; - if ( v5 < (char *)gpBufEnd ) - { + if (v5 < (char *)gpBufEnd) { v8 = v7 >> 1; - if ( !(v7 & 1) || (*v5 = *v4, ++v4, ++v5, v8) ) - { + if (!(v7 & 1) || (*v5 = *v4, ++v4, ++v5, v8)) { v9 = v8 & 1; v10 = v7 >> 2; - if ( !v9 || (*(_WORD *)v5 = *(_WORD *)v4, v4 += 2, v5 += 2, v10) ) - { + if (!v9 || (*(_WORD *)v5 = *(_WORD *)v4, v4 += 2, v5 += 2, v10)) { qmemcpy(v5, v4, 4 * v10); v4 += 4 * v10; v5 += 4 * v10; } } - } - else - { + } else { v4 += v7; v5 += v7; } - } - while ( v6 ); -LABEL_17: + } while (v6); + LABEL_17: v5 += -frame_width - 768; - } - while ( &v11[frame_content_size] != v4 ); + } while (&v11[frame_content_size] != v4); } } // 69CF0C: using guessed type int gpBufEnd; void __fastcall Cel2DrawHdrOnly(int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int a6, int direction) { - int v7; // edx + int v7; // edx char *v8; // eax - int v9; // edi - int v10; // ecx - int v11; // [esp+Ch] [ebp-8h] - int v12; // [esp+10h] [ebp-4h] + int v9; // edi + int v10; // ecx + int v11; // [esp+Ch] [ebp-8h] + int v12; // [esp+10h] [ebp-4h] v12 = screen_y; v11 = screen_x; - if ( gpBuffer ) - { - if ( pCelBuff ) - { + if (gpBuffer) { + if (pCelBuff) { v7 = *(_DWORD *)&pCelBuff[4 * frame]; v8 = &pCelBuff[v7]; v9 = *(unsigned short *)&pCelBuff[v7 + a6]; - if ( *(_WORD *)&pCelBuff[v7 + a6] ) - { - if ( direction != 8 && *(_WORD *)&v8[direction] ) + if (*(_WORD *)&pCelBuff[v7 + a6]) { + if (direction != 8 && *(_WORD *)&v8[direction]) v10 = *(unsigned short *)&v8[direction] - v9; else v10 = *(_DWORD *)&pCelBuff[4 * frame + 4] - v7 - v9; Cel2DecDatOnly( - (char *)gpBuffer + screen_y_times_768[v12 - 16 * a6] + v11, - &v8[v9], - v10, - frame_width); + (char *)gpBuffer + screen_y_times_768[v12 - 16 * a6] + v11, + &v8[v9], + v10, + frame_width); } } } @@ -722,27 +642,24 @@ void __fastcall Cel2DrawHdrOnly(int screen_x, int screen_y, char *pCelBuff, int void __fastcall Cel2DecodeHdrOnly(char *pBuff, char *pCelBuff, int frame, int frame_width, int a5, int direction) { - int v6; // edi + int v6; // edi char *v7; // esi - int v8; // ebx - int v9; // eax - int v10; // edx - int v11; // eax + int v8; // ebx + int v9; // eax + int v10; // edx + int v11; // eax - if ( pCelBuff ) - { - if ( pBuff ) - { + if (pCelBuff) { + if (pBuff) { v6 = *(_DWORD *)&pCelBuff[4 * frame]; v7 = &pCelBuff[v6]; v8 = *(unsigned short *)&pCelBuff[v6 + a5]; - if ( *(_WORD *)&pCelBuff[v6 + a5] ) - { + if (*(_WORD *)&pCelBuff[v6 + a5]) { v9 = *(_DWORD *)&pCelBuff[4 * frame + 4] - v6; v10 = *(unsigned short *)&v7[direction]; - if ( direction == 8 ) + if (direction == 8) v10 = 0; - if ( v10 ) + if (v10) v11 = v10 - v8; else v11 = v9 - v8; @@ -757,51 +674,42 @@ void __fastcall Cel2DecDatLightOnly(char *pDecodeTo, char *pRLEBytes, int frame_ char *v4; // esi char *v5; // edi char *v6; // ebx - int v7; // edx - int v8; // eax - int v9; // ST00_4 + int v7; // edx + int v8; // eax + int v9; // ST00_4 char *a3; // [esp+Ch] [ebp-10h] - if ( pDecodeTo && pRLEBytes && gpBuffer ) - { + if (pDecodeTo && pRLEBytes && gpBuffer) { a3 = &pLightTbl[256 * light_table_index]; v4 = pRLEBytes; v5 = pDecodeTo; v6 = &pRLEBytes[frame_content_size]; - do - { + do { v7 = frame_width; - do - { - while ( 1 ) - { + do { + while (1) { v8 = (unsigned __int8)*v4++; - if ( (v8 & 0x80u) == 0 ) /* check sign */ + if ((v8 & 0x80u) == 0) /* check sign */ break; _LOBYTE(v8) = -(char)v8; v5 += v8; v7 -= v8; - if ( !v7 ) + if (!v7) goto LABEL_13; } v7 -= v8; - if ( v5 < (char *)gpBufEnd ) - { + if (v5 < (char *)gpBufEnd) { v9 = v7; Cel2DecDatLightEntry(v8, a3, v5, v4); v7 = v9; - } - else - { + } else { v4 += v8; v5 += v8; } - } - while ( v7 ); -LABEL_13: + } while (v7); + LABEL_13: v5 += -frame_width - 768; - } - while ( v6 != v4 ); + } while (v6 != v4); } } // 69BEF8: using guessed type int light_table_index; @@ -809,20 +717,19 @@ LABEL_13: void __fastcall Cel2DecDatLightEntry(unsigned char shift, char *LightIndex, char *&pDecodeTo, char *&pRLEBytes) { - char v5; // cf + char v5; // cf unsigned char v6; // cl - char v7; // cl - int v8; // eax - char v9; // ch - int tmp; // eax - char v11; // ch - char v12; // ch + char v7; // cl + int v8; // eax + char v9; // ch + int tmp; // eax + char v11; // ch + char v12; // ch unsigned char a1; v5 = shift & 1; v6 = shift >> 1; - if ( v5 ) - { + if (v5) { a1 = *pRLEBytes; *pDecodeTo = LightIndex[a1]; ++pRLEBytes; @@ -830,8 +737,7 @@ void __fastcall Cel2DecDatLightEntry(unsigned char shift, char *LightIndex, char } v5 = v6 & 1; v7 = v6 >> 1; - if ( v5 ) - { + if (v5) { a1 = *pRLEBytes; *pDecodeTo = LightIndex[a1]; a1 = pRLEBytes[1]; @@ -839,8 +745,7 @@ void __fastcall Cel2DecDatLightEntry(unsigned char shift, char *LightIndex, char pRLEBytes += 2; pDecodeTo += 2; } - for ( ; v7; --v7 ) - { + for (; v7; --v7) { v8 = *(_DWORD *)pRLEBytes; pRLEBytes += 4; a1 = v8; @@ -861,153 +766,133 @@ void __fastcall Cel2DecDatLightEntry(unsigned char shift, char *LightIndex, char void __fastcall Cel2DecDatLightTrans(char *pDecodeTo, char *pRLEBytes, int frame_content_size, int frame_width) { - char *v4; // esi - unsigned int v5; // edi - char *v6; // ebx - int v7; // edx - unsigned int v8; // eax + char *v4; // esi + unsigned int v5; // edi + char *v6; // ebx + int v7; // edx + unsigned int v8; // eax unsigned int v10; // ecx - char v11; // cf + char v11; // cf unsigned int v12; // ecx - char *v13; // esi - _BYTE *v14; // edi - _BYTE *v18; // edi + char *v13; // esi + _BYTE *v14; // edi + _BYTE *v18; // edi unsigned int v21; // ecx - _BYTE *v25; // edi - char *v26; // [esp-4h] [ebp-24h] - char *v27; // [esp+Ch] [ebp-14h] - int v28; // [esp+14h] [ebp-Ch] + _BYTE *v25; // edi + char *v26; // [esp-4h] [ebp-24h] + char *v27; // [esp+Ch] [ebp-14h] + int v28; // [esp+14h] [ebp-Ch] int _EAX; char *_EBX; - if ( pDecodeTo && pRLEBytes && gpBuffer ) - { + if (pDecodeTo && pRLEBytes && gpBuffer) { v27 = &pLightTbl[256 * light_table_index]; v4 = pRLEBytes; v5 = (unsigned int)pDecodeTo; v6 = &pRLEBytes[frame_content_size]; v28 = (unsigned char)pDecodeTo & 1; - do - { + do { v7 = frame_width; - do - { - while ( 1 ) - { + do { + while (1) { v8 = (unsigned char)*v4++; - if ( (v8 & 0x80u) != 0 ) + if ((v8 & 0x80u) != 0) break; v26 = v6; _EBX = v27; v7 -= v8; - if ( v5 < (unsigned int)gpBufEnd ) - { - if ( (v5 & 1) == v28 ) - { + if (v5 < (unsigned int)gpBufEnd) { + if ((v5 & 1) == v28) { v10 = v8 >> 1; - if ( !(v8 & 1) ) + if (!(v8 & 1)) goto LABEL_13; ++v4; ++v5; - if ( v10 ) - { -LABEL_20: + if (v10) { + LABEL_20: v11 = v10 & 1; v21 = v10 >> 1; - if ( !v11 ) + if (!v11) goto LABEL_29; _EAX = *v4; - ASM_XLAT(_EAX,_EBX); + ASM_XLAT(_EAX, _EBX); *(_BYTE *)v5 = _EAX; v4 += 2; v5 += 2; - if ( v21 ) - { -LABEL_29: - do - { + if (v21) { + LABEL_29: + do { _EAX = *(_DWORD *)v4; v4 += 4; - ASM_XLAT(_EAX,_EBX); + ASM_XLAT(_EAX, _EBX); *(_BYTE *)v5 = _EAX; v25 = (_BYTE *)(v5 + 2); _EAX = __ROR4__(_EAX, 16); - ASM_XLAT(_EAX,_EBX); + ASM_XLAT(_EAX, _EBX); *v25 = _EAX; v5 = (unsigned int)(v25 + 2); --v21; - } - while ( v21 ); + } while (v21); } goto LABEL_23; } - } - else - { + } else { v10 = v8 >> 1; - if ( !(v8 & 1) ) + if (!(v8 & 1)) goto LABEL_20; _EAX = *v4++; - ASM_XLAT(_EAX,_EBX); + ASM_XLAT(_EAX, _EBX); *(_BYTE *)v5++ = _EAX; - if ( v10 ) - { -LABEL_13: + if (v10) { + LABEL_13: v11 = v10 & 1; v12 = v10 >> 1; - if ( !v11 ) + if (!v11) goto LABEL_30; v13 = v4 + 1; v14 = (_BYTE *)(v5 + 1); _EAX = *v13; v4 = v13 + 1; - ASM_XLAT(_EAX,_EBX); + ASM_XLAT(_EAX, _EBX); *v14 = _EAX; v5 = (unsigned int)(v14 + 1); - if ( v12 ) - { -LABEL_30: - do - { + if (v12) { + LABEL_30: + do { _EAX = *(_DWORD *)v4; v4 += 4; v18 = (_BYTE *)(v5 + 1); _EAX = __ROR4__(_EAX, 8); - ASM_XLAT(_EAX,_EBX); + ASM_XLAT(_EAX, _EBX); *v18 = _EAX; _EAX = __ROR4__(_EAX, 16); v18 += 2; - ASM_XLAT(_EAX,_EBX); + ASM_XLAT(_EAX, _EBX); *v18 = _EAX; v5 = (unsigned int)(v18 + 1); --v12; - } - while ( v12 ); + } while (v12); } goto LABEL_23; } } - } - else - { + } else { v4 += v8; v5 += v8; } -LABEL_23: + LABEL_23: v6 = v26; - if ( !v7 ) + if (!v7) goto LABEL_26; } _LOBYTE(v8) = -(char)v8; v5 += v8; v7 -= v8; - } - while ( v7 ); -LABEL_26: + } while (v7); + LABEL_26: v5 -= frame_width + 768; v28 = ((_BYTE)v28 + 1) & 1; - } - while ( v6 != v4 ); + } while (v6 != v4); } } // 69BEF8: using guessed type int light_table_index; @@ -1015,41 +900,38 @@ LABEL_26: void __fastcall Cel2DecodeHdrLight(int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int a6, int direction) { - int v7; // esi - char *v8; // eax - int v9; // edi - char *v10; // edx - int v11; // ebx - int v12; // eax - int v13; // edi - int v14; // eax - char *v15; // edx - char *v16; // ecx + int v7; // esi + char *v8; // eax + int v9; // edi + char *v10; // edx + int v11; // ebx + int v12; // eax + int v13; // edi + int v14; // eax + char *v15; // edx + char *v16; // ecx char *cel_buf; // [esp+18h] [ebp+8h] v7 = screen_y; - if ( gpBuffer ) - { + if (gpBuffer) { v8 = pCelBuff; - if ( pCelBuff ) - { + if (pCelBuff) { v9 = *(_DWORD *)&pCelBuff[4 * frame]; v10 = &pCelBuff[v9]; v11 = *(unsigned short *)&pCelBuff[v9 + a6]; cel_buf = (char *)*(unsigned short *)&pCelBuff[v9 + a6]; - if ( v11 ) - { + if (v11) { v12 = *(_DWORD *)&v8[4 * frame + 4] - v9; v13 = *(unsigned short *)&v10[direction]; - if ( direction == 8 ) + if (direction == 8) v13 = 0; - if ( v13 ) + if (v13) v14 = v13 - (_DWORD)cel_buf; else v14 = v12 - (_DWORD)cel_buf; v15 = &v10[(_DWORD)cel_buf]; v16 = (char *)gpBuffer + screen_y_times_768[v7 - 16 * a6] + screen_x; - if ( light_table_index ) + if (light_table_index) Cel2DecDatLightOnly(v16, v15, v14, frame_width); else Cel2DecDatOnly(v16, v15, v14, frame_width); @@ -1061,42 +943,35 @@ void __fastcall Cel2DecodeHdrLight(int screen_x, int screen_y, char *pCelBuff, i void __fastcall Cel2DecodeLightTrans(char *dst_buf, char *pCelBuff, int frame, int frame_width, int a5, int direction) { - char *v6; // eax - int v7; // esi - char *v8; // edx - int v9; // ebx - int v10; // eax - int v11; // esi - int v12; // eax + char *v6; // eax + int v7; // esi + char *v8; // edx + int v9; // ebx + int v10; // eax + int v11; // esi + int v12; // eax char *v13; // edx v6 = pCelBuff; - if ( pCelBuff ) - { + if (pCelBuff) { v7 = *(_DWORD *)&pCelBuff[4 * frame]; v8 = &pCelBuff[v7]; v9 = *(unsigned short *)&v6[v7 + a5]; - if ( *(_WORD *)&v6[v7 + a5] ) - { + if (*(_WORD *)&v6[v7 + a5]) { v10 = *(_DWORD *)&v6[4 * frame + 4] - v7; v11 = *(unsigned short *)&v8[direction]; - if ( direction == 8 ) + if (direction == 8) v11 = 0; - if ( v11 ) + if (v11) v12 = v11 - v9; else v12 = v10 - v9; v13 = &v8[v9]; - if ( cel_transparency_active ) - { + if (cel_transparency_active) { Cel2DecDatLightTrans(dst_buf, v13, v12, frame_width); - } - else if ( light_table_index ) - { + } else if (light_table_index) { Cel2DecDatLightOnly(dst_buf, v13, v12, frame_width); - } - else - { + } else { Cel2DecDatOnly(dst_buf, v13, v12, frame_width); } } @@ -1107,41 +982,38 @@ void __fastcall Cel2DecodeLightTrans(char *dst_buf, char *pCelBuff, int frame, i void __fastcall Cel2DrawHdrLightRed(int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int always_0, int direction, char always_1) { - char *v8; // esi - int v9; // ebx - char *v10; // edi - int v11; // ecx - int v12; // esi - int v13; // eax - int v14; // eax - _BYTE *v15; // esi - _BYTE *v16; // edi - int v17; // ecx - int v18; // edx - int v19; // ecx - int v20; // eax - _BYTE *v21; // [esp-4h] [ebp-14h] - int v22; // [esp+Ch] [ebp-4h] - char *cel_buf; // [esp+18h] [ebp+8h] - char *cel_bufa; // [esp+18h] [ebp+8h] - int framea; // [esp+1Ch] [ebp+Ch] + char *v8; // esi + int v9; // ebx + char *v10; // edi + int v11; // ecx + int v12; // esi + int v13; // eax + int v14; // eax + _BYTE *v15; // esi + _BYTE *v16; // edi + int v17; // ecx + int v18; // edx + int v19; // ecx + int v20; // eax + _BYTE *v21; // [esp-4h] [ebp-14h] + int v22; // [esp+Ch] [ebp-4h] + char *cel_buf; // [esp+18h] [ebp+8h] + char *cel_bufa; // [esp+18h] [ebp+8h] + int framea; // [esp+1Ch] [ebp+Ch] char *always_0a; // [esp+24h] [ebp+14h] - int directiona; // [esp+28h] [ebp+18h] + int directiona; // [esp+28h] [ebp+18h] v22 = screen_x; - if ( gpBuffer ) - { + if (gpBuffer) { v8 = pCelBuff; - if ( pCelBuff ) - { + if (pCelBuff) { v9 = *(_DWORD *)&pCelBuff[4 * frame]; v10 = &pCelBuff[v9]; v11 = *(unsigned short *)&pCelBuff[v9 + always_0]; cel_buf = (char *)*(unsigned short *)&pCelBuff[v9 + always_0]; - if ( v11 ) - { + if (v11) { v12 = *(_DWORD *)&v8[4 * frame + 4] - v9; - if ( direction != 8 && *(_WORD *)&v10[direction] ) + if (direction != 8 && *(_WORD *)&v10[direction]) framea = *(unsigned short *)&v10[direction] - (_DWORD)cel_buf; else framea = v12 - (_DWORD)cel_buf; @@ -1150,56 +1022,46 @@ void __fastcall Cel2DrawHdrLightRed(int screen_x, int screen_y, char *pCelBuff, v13 = -(light4flag != 0); _LOWORD(v13) = v13 & 0xF400; v14 = v13 + 4096; - if ( always_1 == 2 ) + if (always_1 == 2) v14 += 256; - if ( always_1 >= 4 ) + if (always_1 >= 4) v14 = v14 + (always_1 << 8) - 256; cel_bufa = &pLightTbl[v14]; v15 = (_BYTE *)directiona; v16 = (unsigned char *)always_0a; v17 = directiona + framea; - do - { + do { v21 = (_BYTE *)v17; v18 = frame_width; v19 = 0; - do - { - while ( 1 ) - { + do { + while (1) { v20 = (unsigned char)*v15++; - if ( (v20 & 0x80u) == 0 ) + if ((v20 & 0x80u) == 0) break; _LOBYTE(v20) = -(char)v20; v16 += v20; v18 -= v20; - if ( !v18 ) + if (!v18) goto LABEL_21; } v18 -= v20; - if ( v16 < gpBufEnd ) - { - do - { + if (v16 < gpBufEnd) { + do { _LOBYTE(v19) = *v15++; *v16 = cel_bufa[v19]; --v20; ++v16; - } - while ( v20 ); - } - else - { + } while (v20); + } else { v15 += v20; v16 += v20; } - } - while ( v18 ); -LABEL_21: + } while (v18); + LABEL_21: v17 = (int)v21; v16 += -frame_width - 768; - } - while ( v21 != v15 ); + } while (v21 != v15); } } } @@ -1209,128 +1071,112 @@ LABEL_21: void __fastcall CelDecodeRect(char *pBuff, int always_0, int dst_height, int dst_width, char *pCelBuff, int frame, int frame_width) { - char *v7; // ebx - char *v8; // esi - char *v9; // edi - int v10; // ebx - int v11; // edx + char *v7; // ebx + char *v8; // esi + char *v9; // edi + int v10; // ebx + int v11; // edx unsigned int v12; // eax unsigned int v13; // ecx - char v14; // cf + char v14; // cf unsigned int v15; // ecx - int dst_widtha; // [esp+14h] [ebp+Ch] + int dst_widtha; // [esp+14h] [ebp+Ch] - if ( pCelBuff && pBuff ) - { + if (pCelBuff && pBuff) { v7 = &pCelBuff[4 * frame]; v8 = &pCelBuff[*(_DWORD *)v7]; v9 = &pBuff[dst_width * dst_height + always_0]; dst_widtha = frame_width + dst_width; v10 = (int)&v8[*((_DWORD *)v7 + 1) - *(_DWORD *)v7]; - do - { + do { v11 = frame_width; - do - { - while ( 1 ) - { + do { + while (1) { v12 = (unsigned char)*v8++; - if ( (v12 & 0x80u) == 0 ) + if ((v12 & 0x80u) == 0) break; _LOBYTE(v12) = -(char)v12; v9 += v12; v11 -= v12; - if ( !v11 ) + if (!v11) goto LABEL_14; } v11 -= v12; v13 = v12 >> 1; - if ( v12 & 1 ) - { + if (v12 & 1) { *v9++ = *v8++; - if ( !v13 ) + if (!v13) continue; } v14 = v13 & 1; v15 = v12 >> 2; - if ( v14 ) - { + if (v14) { *(_WORD *)v9 = *(_WORD *)v8; v8 += 2; v9 += 2; - if ( !v15 ) + if (!v15) continue; } qmemcpy(v9, v8, 4 * v15); v8 += 4 * v15; v9 += 4 * v15; - } - while ( v11 ); -LABEL_14: + } while (v11); + LABEL_14: v9 -= dst_widtha; - } - while ( (char *)v10 != v8 ); + } while ((char *)v10 != v8); } } void __fastcall CelDecodeClr(BYTE colour, int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int a7, int direction) { - char *v8; // ebx - int v9; // eax + char *v8; // ebx + int v9; // eax char *v10; // esi char *v11; // edi - int v12; // edx - int v13; // eax - int v14; // ecx - char v15; // al - int v16; // [esp+Ch] [ebp-10h] + int v12; // edx + int v13; // eax + int v14; // ecx + char v15; // al + int v16; // [esp+Ch] [ebp-10h] char *v17; // [esp+10h] [ebp-Ch] - int v18; // [esp+14h] [ebp-8h] - char v19; // [esp+18h] [ebp-4h] + int v18; // [esp+14h] [ebp-8h] + char v19; // [esp+18h] [ebp-4h] v19 = colour; - if ( pCelBuff ) - { - if ( gpBuffer ) - { + if (pCelBuff) { + if (gpBuffer) { v8 = &pCelBuff[4 * frame]; v17 = &pCelBuff[*(_DWORD *)v8]; v16 = *(unsigned short *)&v17[a7]; - if ( *(_WORD *)&v17[a7] ) - { - if ( direction == 8 ) + if (*(_WORD *)&v17[a7]) { + if (direction == 8) v9 = 0; else v9 = *(unsigned short *)&v17[direction]; - if ( v9 ) + if (v9) v18 = v9 - v16; else v18 = *((_DWORD *)v8 + 1) - *(_DWORD *)v8 - v16; v10 = &v17[v16]; v11 = (char *)gpBuffer + screen_y_times_768[screen_y - 16 * a7] + screen_x; - do - { + do { v12 = frame_width; - do - { - while ( 1 ) - { + do { + while (1) { v13 = (unsigned char)*v10++; - if ( (v13 & 0x80u) == 0 ) + if ((v13 & 0x80u) == 0) break; _LOBYTE(v13) = -(char)v13; v11 += v13; v12 -= v13; - if ( !v12 ) + if (!v12) goto LABEL_20; } v12 -= v13; v14 = v13; - do - { + do { v15 = *v10++; - if ( v15 ) - { + if (v15) { *(v11 - 768) = v19; *(v11 - 1) = v19; v11[1] = v19; @@ -1338,14 +1184,11 @@ void __fastcall CelDecodeClr(BYTE colour, int screen_x, int screen_y, char *pCel } ++v11; --v14; - } - while ( v14 ); - } - while ( v12 ); -LABEL_20: + } while (v14); + } while (v12); + LABEL_20: v11 += -frame_width - 768; - } - while ( &v17[v16 + v18] != v10 ); + } while (&v17[v16 + v18] != v10); } } } @@ -1353,85 +1196,70 @@ LABEL_20: void __fastcall CelDrawHdrClrHL(char colour, int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int a7, int direction) { - char *v8; // ebx - int v9; // eax + char *v8; // ebx + int v9; // eax char *v10; // esi char *v11; // edi - int v12; // edx - int v13; // eax - int v14; // ecx - char v15; // al - int v16; // ecx - char v17; // al - int v18; // [esp+Ch] [ebp-10h] + int v12; // edx + int v13; // eax + int v14; // ecx + char v15; // al + int v16; // ecx + char v17; // al + int v18; // [esp+Ch] [ebp-10h] char *v19; // [esp+10h] [ebp-Ch] - int v20; // [esp+14h] [ebp-8h] - char v21; // [esp+18h] [ebp-4h] + int v20; // [esp+14h] [ebp-8h] + char v21; // [esp+18h] [ebp-4h] v21 = colour; - if ( pCelBuff ) - { - if ( gpBuffer ) - { + if (pCelBuff) { + if (gpBuffer) { v8 = &pCelBuff[4 * frame]; v19 = &pCelBuff[*(_DWORD *)v8]; v18 = *(unsigned short *)&v19[a7]; - if ( *(_WORD *)&v19[a7] ) - { - if ( direction == 8 ) + if (*(_WORD *)&v19[a7]) { + if (direction == 8) v9 = 0; else v9 = *(unsigned short *)&v19[direction]; - if ( v9 ) + if (v9) v20 = v9 - v18; else v20 = *((_DWORD *)v8 + 1) - *(_DWORD *)v8 - v18; v10 = &v19[v18]; v11 = (char *)gpBuffer + screen_y_times_768[screen_y - 16 * a7] + screen_x; - do - { + do { v12 = frame_width; - do - { - while ( 1 ) - { + do { + while (1) { v13 = (unsigned char)*v10++; - if ( (v13 & 0x80u) == 0 ) + if ((v13 & 0x80u) == 0) break; _LOBYTE(v13) = -(char)v13; v11 += v13; v12 -= v13; - if ( !v12 ) + if (!v12) goto LABEL_28; } v12 -= v13; - if ( v11 < (char *)gpBufEnd ) - { - if ( v11 >= (char *)gpBufEnd - 768 ) - { + if (v11 < (char *)gpBufEnd) { + if (v11 >= (char *)gpBufEnd - 768) { v16 = v13; - do - { + do { v17 = *v10++; - if ( v17 ) - { + if (v17) { *(v11 - 768) = v21; *(v11 - 1) = v21; v11[1] = v21; } ++v11; --v16; - } - while ( v16 ); - } - else - { + } while (v16); + } else { v14 = v13; - do - { + do { v15 = *v10++; - if ( v15 ) - { + if (v15) { *(v11 - 768) = v21; *(v11 - 1) = v21; v11[1] = v21; @@ -1439,21 +1267,16 @@ void __fastcall CelDrawHdrClrHL(char colour, int screen_x, int screen_y, char *p } ++v11; --v14; - } - while ( v14 ); + } while (v14); } - } - else - { + } else { v10 += v13; v11 += v13; } - } - while ( v12 ); -LABEL_28: + } while (v12); + LABEL_28: v11 += -frame_width - 768; - } - while ( &v19[v18 + v20] != v10 ); + } while (&v19[v18 + v20] != v10); } } } @@ -1464,10 +1287,9 @@ void __fastcall ENG_set_pixel(int screen_x, int screen_y, UCHAR pixel) { UCHAR *v3; // edi - if ( screen_y >= 0 && screen_y < 640 && screen_x >= 64 && screen_x < 704 ) - { + if (screen_y >= 0 && screen_y < 640 && screen_x >= 64 && screen_x < 704) { v3 = (UCHAR *)gpBuffer + screen_y_times_768[screen_y] + screen_x; - if ( v3 < gpBufEnd ) + if (v3 < gpBufEnd) *v3 = pixel; } } @@ -1477,19 +1299,15 @@ void __fastcall engine_draw_pixel(int x, int y) { _BYTE *v2; // eax - if ( dword_52B970 ) - { - if ( !dword_52B99C || x >= 0 && x < 640 && y >= 64 && y < 704 ) - { + if (dword_52B970) { + if (!dword_52B99C || x >= 0 && x < 640 && y >= 64 && y < 704) { v2 = (unsigned char *)gpBuffer + screen_y_times_768[x] + y; goto LABEL_14; } - } - else if ( !dword_52B99C || y >= 0 && y < 640 && x >= 64 && x < 704 ) - { + } else if (!dword_52B99C || y >= 0 && y < 640 && x >= 64 && x < 704) { v2 = (unsigned char *)gpBuffer + screen_y_times_768[y] + x; -LABEL_14: - if ( v2 < gpBufEnd ) + LABEL_14: + if (v2 < gpBufEnd) *v2 = gbPixelCol; return; } @@ -1501,77 +1319,74 @@ LABEL_14: void __fastcall DrawLine(int x0, int y0, int x1, int y1, UCHAR col) { - int v5; // ST18_4 - int v6; // ST2C_4 - int v7; // ST20_4 - int v8; // [esp+Ch] [ebp-48h] - int v9; // [esp+10h] [ebp-44h] - int v10; // [esp+14h] [ebp-40h] - int v11; // [esp+18h] [ebp-3Ch] + int v5; // ST18_4 + int v6; // ST2C_4 + int v7; // ST20_4 + int v8; // [esp+Ch] [ebp-48h] + int v9; // [esp+10h] [ebp-44h] + int v10; // [esp+14h] [ebp-40h] + int v11; // [esp+18h] [ebp-3Ch] signed int v12; // [esp+1Ch] [ebp-38h] - int v13; // [esp+20h] [ebp-34h] - int v14; // [esp+24h] [ebp-30h] - int v15; // [esp+28h] [ebp-2Ch] - int y; // [esp+2Ch] [ebp-28h] - int ya; // [esp+2Ch] [ebp-28h] - int yb; // [esp+2Ch] [ebp-28h] - int yc; // [esp+2Ch] [ebp-28h] - int j; // [esp+30h] [ebp-24h] - int i; // [esp+30h] [ebp-24h] - int x; // [esp+34h] [ebp-20h] - int xa; // [esp+34h] [ebp-20h] - int xb; // [esp+34h] [ebp-20h] - int xc; // [esp+34h] [ebp-20h] - int xd; // [esp+34h] [ebp-20h] - int xe; // [esp+34h] [ebp-20h] - int xf; // [esp+34h] [ebp-20h] - int xg; // [esp+34h] [ebp-20h] - int xh; // [esp+34h] [ebp-20h] - int v31; // [esp+38h] [ebp-1Ch] - int v32; // [esp+3Ch] [ebp-18h] - int v33; // [esp+3Ch] [ebp-18h] - int v34; // [esp+3Ch] [ebp-18h] + int v13; // [esp+20h] [ebp-34h] + int v14; // [esp+24h] [ebp-30h] + int v15; // [esp+28h] [ebp-2Ch] + int y; // [esp+2Ch] [ebp-28h] + int ya; // [esp+2Ch] [ebp-28h] + int yb; // [esp+2Ch] [ebp-28h] + int yc; // [esp+2Ch] [ebp-28h] + int j; // [esp+30h] [ebp-24h] + int i; // [esp+30h] [ebp-24h] + int x; // [esp+34h] [ebp-20h] + int xa; // [esp+34h] [ebp-20h] + int xb; // [esp+34h] [ebp-20h] + int xc; // [esp+34h] [ebp-20h] + int xd; // [esp+34h] [ebp-20h] + int xe; // [esp+34h] [ebp-20h] + int xf; // [esp+34h] [ebp-20h] + int xg; // [esp+34h] [ebp-20h] + int xh; // [esp+34h] [ebp-20h] + int v31; // [esp+38h] [ebp-1Ch] + int v32; // [esp+3Ch] [ebp-18h] + int v33; // [esp+3Ch] [ebp-18h] + int v34; // [esp+3Ch] [ebp-18h] signed int v35; // [esp+40h] [ebp-14h] signed int v36; // [esp+44h] [ebp-10h] - int v37; // [esp+48h] [ebp-Ch] - int v38; // [esp+48h] [ebp-Ch] - int v39; // [esp+4Ch] [ebp-8h] - int v40; // [esp+4Ch] [ebp-8h] - int v41; // [esp+50h] [ebp-4h] - int x2a; // [esp+5Ch] [ebp+8h] + int v37; // [esp+48h] [ebp-Ch] + int v38; // [esp+48h] [ebp-Ch] + int v39; // [esp+4Ch] [ebp-8h] + int v40; // [esp+4Ch] [ebp-8h] + int v41; // [esp+50h] [ebp-4h] + int x2a; // [esp+5Ch] [ebp+8h] v8 = y0; v9 = x0; gbPixelCol = col; dword_52B99C = 0; - if ( x0 < 64 || x0 >= 704 ) + if (x0 < 64 || x0 >= 704) dword_52B99C = 1; - if ( x1 < 64 || x1 >= 704 ) + if (x1 < 64 || x1 >= 704) dword_52B99C = 1; - if ( y0 < 160 || y0 >= 512 ) + if (y0 < 160 || y0 >= 512) dword_52B99C = 1; - if ( y1 < 160 || y1 >= 512 ) + if (y1 < 160 || y1 >= 512) dword_52B99C = 1; - if ( x1 - x0 < 0 ) + if (x1 - x0 < 0) v36 = -1; else v36 = 1; v11 = v36 * (x1 - x0); - if ( y1 - y0 < 0 ) + if (y1 - y0 < 0) v35 = -1; else v35 = 1; v10 = v35 * (y1 - y0); - if ( v35 == v36 ) + if (v35 == v36) v12 = 1; else v12 = -1; - if ( v11 >= v10 ) - { + if (v11 >= v10) { dword_52B970 = 0; - } - else - { + } else { v8 = y0 ^ x0 ^ y0; v9 = v8 ^ y0 ^ x0; x2a = y1 ^ x1; @@ -1582,15 +1397,12 @@ void __fastcall DrawLine(int x0, int y0, int x1, int y1, UCHAR col) v11 = v10 ^ v5; dword_52B970 = 1; } - if ( x1 >= v9 ) - { + if (x1 >= v9) { x = v9; y = v8; v32 = x1; v13 = y1; - } - else - { + } else { x = x1; y = y1; v32 = v9; @@ -1601,28 +1413,22 @@ void __fastcall DrawLine(int x0, int y0, int x1, int y1, UCHAR col) engine_draw_pixel(x, y); engine_draw_pixel(v32, v13); v14 = 4 * v10 - 2 * v11; - if ( v14 >= 0 ) - { + if (v14 >= 0) { v40 = 2 * (v10 - v11); v15 = 4 * (v10 - v11); v38 = v15 + v11; - for ( i = 0; i < v31; ++i ) - { + for (i = 0; i < v31; ++i) { xe = x + 1; v34 = v32 - 1; - if ( v38 <= 0 ) - { - if ( v40 <= v38 ) - { + if (v38 <= 0) { + if (v40 <= v38) { y += v12; engine_draw_pixel(xe, y); x = xe + 1; engine_draw_pixel(x, y); v13 -= v12; engine_draw_pixel(v34, v13); - } - else - { + } else { engine_draw_pixel(xe, y); y += v12; x = xe + 1; @@ -1633,9 +1439,7 @@ void __fastcall DrawLine(int x0, int y0, int x1, int y1, UCHAR col) v32 = v34 - 1; engine_draw_pixel(v32, v13); v38 += v14; - } - else - { + } else { v6 = v12 + y; engine_draw_pixel(xe, v6); y = v12 + v6; @@ -1649,68 +1453,53 @@ void __fastcall DrawLine(int x0, int y0, int x1, int y1, UCHAR col) v38 += v15; } } - if ( v41 ) - { - if ( v38 <= 0 ) - { - if ( v40 <= v38 ) - { + if (v41) { + if (v38 <= 0) { + if (v40 <= v38) { yc = v12 + y; xh = x + 1; engine_draw_pixel(xh, yc); - if ( v41 > 1 ) + if (v41 > 1) engine_draw_pixel(xh + 1, yc); - if ( v41 > 2 ) - { - if ( v40 >= v38 ) + if (v41 > 2) { + if (v40 >= v38) engine_draw_pixel(v32 - 1, v13); else engine_draw_pixel(v32 - 1, v13 - v12); } - } - else - { + } else { xg = x + 1; engine_draw_pixel(xg, y); - if ( v41 > 1 ) + if (v41 > 1) engine_draw_pixel(xg + 1, v12 + y); - if ( v41 > 2 ) + if (v41 > 2) engine_draw_pixel(v32 - 1, v13); } - } - else - { + } else { yb = v12 + y; xf = x + 1; engine_draw_pixel(xf, yb); - if ( v41 > 1 ) + if (v41 > 1) engine_draw_pixel(xf + 1, v12 + yb); - if ( v41 > 2 ) + if (v41 > 2) engine_draw_pixel(v32 - 1, v13 - v12); } } - } - else - { + } else { v39 = 2 * v10; v37 = 4 * v10 - v11; - for ( j = 0; j < v31; ++j ) - { + for (j = 0; j < v31; ++j) { xa = x + 1; v33 = v32 - 1; - if ( v37 >= 0 ) - { - if ( v39 <= v37 ) - { + if (v37 >= 0) { + if (v39 <= v37) { y += v12; engine_draw_pixel(xa, y); x = xa + 1; engine_draw_pixel(x, y); v13 -= v12; engine_draw_pixel(v33, v13); - } - else - { + } else { engine_draw_pixel(xa, y); y += v12; x = xa + 1; @@ -1721,9 +1510,7 @@ void __fastcall DrawLine(int x0, int y0, int x1, int y1, UCHAR col) v32 = v33 - 1; engine_draw_pixel(v32, v13); v37 += v14; - } - else - { + } else { engine_draw_pixel(xa, y); x = xa + 1; engine_draw_pixel(x, y); @@ -1733,37 +1520,30 @@ void __fastcall DrawLine(int x0, int y0, int x1, int y1, UCHAR col) v37 += 4 * v10; } } - if ( v41 ) - { - if ( v37 >= 0 ) - { - if ( v39 <= v37 ) - { + if (v41) { + if (v37 >= 0) { + if (v39 <= v37) { ya = v12 + y; xd = x + 1; engine_draw_pixel(xd, ya); - if ( v41 > 1 ) + if (v41 > 1) engine_draw_pixel(xd + 1, ya); - if ( v41 > 2 ) + if (v41 > 2) engine_draw_pixel(v32 - 1, v13 - v12); - } - else - { + } else { xc = x + 1; engine_draw_pixel(xc, y); - if ( v41 > 1 ) + if (v41 > 1) engine_draw_pixel(xc + 1, v12 + y); - if ( v41 > 2 ) + if (v41 > 2) engine_draw_pixel(v32 - 1, v13); } - } - else - { + } else { xb = x + 1; engine_draw_pixel(xb, y); - if ( v41 > 1 ) + if (v41 > 1) engine_draw_pixel(xb + 1, y); - if ( v41 > 2 ) + if (v41 > 2) engine_draw_pixel(v32 - 1, v13); } } @@ -1775,52 +1555,43 @@ void __fastcall DrawLine(int x0, int y0, int x1, int y1, UCHAR col) int __fastcall GetDirection(int x1, int y1, int x2, int y2) { - int v4; // esi - int v5; // ecx - int v6; // edx + int v4; // esi + int v5; // ecx + int v6; // edx int result; // eax - int v8; // esi - int v9; // edx + int v8; // esi + int v9; // edx v4 = x2 - x1; v5 = y2 - y1; - if ( v4 < 0 ) - { + if (v4 < 0) { v8 = -v4; v9 = 2 * v8; - if ( v5 < 0 ) - { + if (v5 < 0) { v5 = -v5; result = 4; - if ( v9 < v5 ) + if (v9 < v5) result = 5; - } - else - { + } else { result = 2; - if ( v9 < v5 ) + if (v9 < v5) result = 1; } - if ( 2 * v5 < v8 ) + if (2 * v5 < v8) return 3; - } - else - { + } else { v6 = 2 * v4; - if ( v5 < 0 ) - { + if (v5 < 0) { v5 = -v5; result = 6; - if ( v6 < v5 ) + if (v6 < v5) result = 5; - } - else - { + } else { result = 0; - if ( v6 < v5 ) + if (v6 < v5) result = 1; } - if ( 2 * v5 < v4 ) + if (2 * v5 < v4) return 7; } return result; @@ -1847,15 +1618,14 @@ int __cdecl GetRndSeed() int __fastcall random(BYTE idx, int v) { - if ( v <= 0 ) + if (v <= 0) return 0; - if ( v >= 0xFFFF ) + if (v >= 0xFFFF) return GetRndSeed() % v; return (GetRndSeed() >> 16) % v; } -struct engine_cpp_init_2 -{ +struct engine_cpp_init_2 { engine_cpp_init_2() { mem_init_mutex(); @@ -1880,16 +1650,15 @@ void __cdecl mem_free_mutex() unsigned char *__fastcall DiabloAllocPtr(int dwBytes) { - int v1; // ebx + int v1; // ebx unsigned char *v2; // ebx - int v3; // eax + int v3; // eax v1 = dwBytes; EnterCriticalSection(&sgMemCrit); v2 = (unsigned char *)SMemAlloc(v1, "C:\\Src\\Diablo\\Source\\ENGINE.CPP", 2236, 0); LeaveCriticalSection(&sgMemCrit); - if ( !v2 ) - { + if (!v2) { v3 = GetLastError(); ErrDlg(IDD_DIALOG2, v3, "C:\\Src\\Diablo\\Source\\ENGINE.CPP", 2269); } @@ -1901,8 +1670,7 @@ void __fastcall mem_free_dbg(void *p) void *v1; // edi v1 = p; - if ( p ) - { + if (p) { EnterCriticalSection(&sgMemCrit); SMemFree(v1, "C:\\Src\\Diablo\\Source\\ENGINE.CPP", 2317, 0); LeaveCriticalSection(&sgMemCrit); @@ -1911,10 +1679,10 @@ void __fastcall mem_free_dbg(void *p) unsigned char *__fastcall LoadFileInMem(char *pszName, int *pdwFileLen) { - int *v2; // edi + int *v2; // edi char *v3; // ebx - int v4; // eax - int v5; // esi + int v4; // eax + int v5; // esi char *v6; // edi void *a1; // [esp+Ch] [ebp-4h] @@ -1923,9 +1691,9 @@ unsigned char *__fastcall LoadFileInMem(char *pszName, int *pdwFileLen) WOpenFile(pszName, &a1, 0); v4 = WGetFileSize(a1, 0); v5 = v4; - if ( v2 ) + if (v2) *v2 = v4; - if ( !v4 ) + if (!v4) TermMsg("Zero length SFILE:\n%s", v3); v6 = (char *)DiabloAllocPtr(v5); WReadFile(a1, v6, v5); @@ -1937,16 +1705,16 @@ void __fastcall LoadFileWithMem(char *pszName, void *buf) { char *v2; // ebx char *v3; // edi - int v4; // esi + int v4; // esi void *a1; // [esp+Ch] [ebp-4h] v2 = (char *)buf; v3 = pszName; - if ( !buf ) + if (!buf) TermMsg("LoadFileWithMem(NULL):\n%s", pszName); WOpenFile(v3, &a1, 0); v4 = WGetFileSize(a1, 0); - if ( !v4 ) + if (!v4) TermMsg("Zero length SFILE:\n%s", v3); WReadFile(a1, v2, v4); WCloseFile(a1); @@ -1954,45 +1722,36 @@ void __fastcall LoadFileWithMem(char *pszName, void *buf) void __fastcall Cl2ApplyTrans(unsigned char *p, unsigned char *ttbl, int last_frame) { - int v3; // eax - int v4; // edi - int v5; // esi + int v3; // eax + int v4; // edi + int v5; // esi unsigned char *v6; // eax - char v7; // bl - unsigned char v8; // bl - int v9; // edi - int i; // [esp+0h] [ebp-4h] + char v7; // bl + unsigned char v8; // bl + int v9; // edi + int i; // [esp+0h] [ebp-4h] v3 = 1; - for ( i = 1; i <= last_frame; ++i ) - { + for (i = 1; i <= last_frame; ++i) { v4 = *(_DWORD *)&p[4 * v3]; v5 = *(_DWORD *)&p[4 * v3 + 4] - v4 - 10; v6 = &p[v4 + 10]; - while ( v5 ) - { + while (v5) { v7 = *v6++; --v5; - if ( v7 < 0 ) - { + if (v7 < 0) { v8 = -v7; - if ( (char)v8 <= 65 ) - { + if ((char)v8 <= 65) { v5 -= (char)v8; - if ( v8 ) - { + if (v8) { v9 = v8; - do - { + do { *v6 = ttbl[*v6]; ++v6; --v9; - } - while ( v9 ); + } while (v9); } - } - else - { + } else { --v5; *v6 = ttbl[*v6]; ++v6; @@ -2005,31 +1764,27 @@ void __fastcall Cl2ApplyTrans(unsigned char *p, unsigned char *ttbl, int last_fr void __fastcall Cl2DecodeFrm1(int x, int y, char *pCelBuff, int nCel, int width, int dir1, int dir2) { - char *v8; // edx - char *v9; // ecx - int v10; // ecx - int v11; // eax + char *v8; // edx + char *v9; // ecx + int v10; // ecx + int v11; // eax char *pCelBuffa; // [esp+18h] [ebp+8h] - if ( gpBuffer ) - { + if (gpBuffer) { v8 = pCelBuff; - if ( pCelBuff ) - { - if ( nCel > 0 ) - { + if (pCelBuff) { + if (nCel > 0) { v9 = *(char **)&pCelBuff[4 * nCel]; pCelBuffa = v9; v10 = (int)&v9[(_DWORD)v8]; - if ( *(_WORD *)(v10 + dir1) ) - { - if ( dir2 == 8 || (v11 = *(unsigned short *)(v10 + dir2), !*(_WORD *)(v10 + dir2)) ) + if (*(_WORD *)(v10 + dir1)) { + if (dir2 == 8 || (v11 = *(unsigned short *)(v10 + dir2), !*(_WORD *)(v10 + dir2))) v11 = *((_DWORD *)v8 + nCel + 1) - (_DWORD)pCelBuffa; Cl2DecDatFrm1( - (char *)gpBuffer + screen_y_times_768[y - 16 * dir1] + x, - (char *)(*(unsigned short *)(v10 + dir1) + v10), - v11 - *(unsigned short *)(v10 + dir1), - width); + (char *)gpBuffer + screen_y_times_768[y - 16 * dir1] + x, + (char *)(*(unsigned short *)(v10 + dir1) + v10), + v11 - *(unsigned short *)(v10 + dir1), + width); } } } @@ -2040,113 +1795,90 @@ void __fastcall Cl2DecDatFrm1(char *buffer, char *frame_content, int a3, int wid { char *v4; // esi char *v5; // edi - int v6; // eax - int v7; // ebx - int v8; // ecx - char v9; // dl + int v6; // eax + int v7; // ebx + int v8; // ecx + char v9; // dl char v10; // dl - int v11; // edx + int v11; // edx v4 = frame_content; v5 = buffer; v6 = 0; v7 = width; v8 = a3; - do - { + do { _LOBYTE(v6) = *v4++; --v8; - if ( (v6 & 0x80u) == 0 ) - { - do - { - if ( v6 <= v7 ) - { + if ((v6 & 0x80u) == 0) { + do { + if (v6 <= v7) { v11 = v6; v5 += v6; v6 = 0; - } - else - { + } else { v11 = v7; v5 += v7; v6 -= v7; } v7 -= v11; - if ( !v7 ) - { + if (!v7) { v7 = width; v5 = &v5[-width - 768]; } - } - while ( v6 ); - } - else - { + } while (v6); + } else { _LOBYTE(v6) = -(char)v6; - if ( (char)v6 <= 65 ) - { + if ((char)v6 <= 65) { v8 -= v6; v7 -= v6; - do - { + do { v10 = *v4++; *v5 = v10; --v6; ++v5; - } - while ( v6 ); - } - else - { + } while (v6); + } else { _LOBYTE(v6) = v6 - 65; --v8; v9 = *v4++; v7 -= v6; - do - { + do { *v5 = v9; --v6; ++v5; - } - while ( v6 ); + } while (v6); } - if ( !v7 ) - { + if (!v7) { v7 = width; v5 = &v5[-width - 768]; } } - } - while ( v8 ); + } while (v8); } void __fastcall Cl2DecodeFrm2(char colour, int screen_x, int screen_y, char *pCelBuff, int nCel, int frame_width, int a7, int a8) { - int v8; // ebx + int v8; // ebx char *v9; // edx - int v10; // eax - int v11; // [esp+Ch] [ebp-8h] + int v10; // eax + int v11; // [esp+Ch] [ebp-8h] v11 = screen_x; - if ( gpBuffer ) - { - if ( pCelBuff ) - { - if ( nCel > 0 ) - { + if (gpBuffer) { + if (pCelBuff) { + if (nCel > 0) { v8 = *(_DWORD *)&pCelBuff[4 * nCel]; v9 = &pCelBuff[v8]; - if ( *(_WORD *)&pCelBuff[v8 + a7] ) - { - if ( a8 == 8 || (v10 = *(unsigned short *)&v9[a8], !*(_WORD *)&v9[a8]) ) + if (*(_WORD *)&pCelBuff[v8 + a7]) { + if (a8 == 8 || (v10 = *(unsigned short *)&v9[a8], !*(_WORD *)&v9[a8])) v10 = *(_DWORD *)&pCelBuff[4 * nCel + 4] - v8; Cl2DecDatFrm2( - (char *)gpBuffer + screen_y_times_768[screen_y - 16 * a7] + v11, - &v9[*(unsigned short *)&pCelBuff[v8 + a7]], - v10 - *(unsigned short *)&pCelBuff[v8 + a7], - frame_width, - colour); + (char *)gpBuffer + screen_y_times_768[screen_y - 16 * a7] + v11, + &v9[*(unsigned short *)&pCelBuff[v8 + a7]], + v10 - *(unsigned short *)&pCelBuff[v8 + a7], + frame_width, + colour); } } } @@ -2157,13 +1889,13 @@ void __fastcall Cl2DecDatFrm2(char *buffer, char *frame_content, int a3, int fra { char *v5; // esi char *v6; // edi - int v7; // eax - int v8; // ebx - int v9; // ecx + int v7; // eax + int v8; // ebx + int v9; // ecx char v10; // dl char v11; // dh char v12; // dh - int v13; // edx + int v13; // edx v5 = frame_content; v6 = buffer; @@ -2171,22 +1903,17 @@ void __fastcall Cl2DecDatFrm2(char *buffer, char *frame_content, int a3, int fra v8 = frame_width; v9 = a3; v10 = colour; - do - { + do { _LOBYTE(v7) = *v5++; --v9; - if ( (v7 & 0x80u) != 0 ) - { + if ((v7 & 0x80u) != 0) { _LOBYTE(v7) = -(char)v7; - if ( (char)v7 <= 65 ) - { + if ((char)v7 <= 65) { v9 -= v7; v8 -= v7; - do - { + do { v12 = *v5++; - if ( v12 ) - { + if (v12) { *(v6 - 1) = v10; v6[1] = v10; *(v6 - 768) = v10; @@ -2194,105 +1921,89 @@ void __fastcall Cl2DecDatFrm2(char *buffer, char *frame_content, int a3, int fra } --v7; ++v6; - } - while ( v7 ); + } while (v7); goto LABEL_12; } _LOBYTE(v7) = v7 - 65; --v9; v11 = *v5++; - if ( v11 ) - { + if (v11) { *(v6 - 1) = v10; v8 -= v7; v6[v7] = v10; - do - { + do { *(v6 - 768) = v10; v6[768] = v10; --v7; ++v6; - } - while ( v7 ); -LABEL_12: - if ( !v8 ) - { + } while (v7); + LABEL_12: + if (!v8) { v8 = frame_width; v6 = &v6[-frame_width - 768]; } continue; } } - do - { - if ( v7 <= v8 ) - { + do { + if (v7 <= v8) { v13 = v7; v6 += v7; v7 = 0; - } - else - { + } else { v13 = v8; v6 += v8; v7 -= v8; } v8 -= v13; - if ( !v8 ) - { + if (!v8) { v8 = frame_width; v6 = &v6[-frame_width - 768]; } - } - while ( v7 ); + } while (v7); v10 = colour; - } - while ( v9 ); + } while (v9); } void __fastcall Cl2DecodeFrm3(int screen_x, int screen_y, char *pCelBuff, int nCel, int frame_width, int a6, int a7, char a8) { - char *v8; // edi - int v9; // ebx - char *v10; // esi - int v11; // eax - int v12; // eax - char *v13; // esi - int v14; // edi - int v15; // eax - int v16; // eax + char *v8; // edi + int v9; // ebx + char *v10; // esi + int v11; // eax + int v12; // eax + char *v13; // esi + int v14; // edi + int v15; // eax + int v16; // eax char *pCelBuffa; // [esp+18h] [ebp+8h] - if ( gpBuffer ) - { + if (gpBuffer) { v8 = pCelBuff; - if ( pCelBuff ) - { - if ( nCel > 0 ) - { + if (pCelBuff) { + if (nCel > 0) { v9 = *(_DWORD *)&pCelBuff[4 * nCel]; v10 = &pCelBuff[v9]; v11 = *(unsigned short *)&pCelBuff[v9 + a6]; pCelBuffa = (char *)*(unsigned short *)&pCelBuff[v9 + a6]; - if ( v11 ) - { - if ( a7 == 8 || (v12 = *(unsigned short *)&v10[a7], !*(_WORD *)&v10[a7]) ) + if (v11) { + if (a7 == 8 || (v12 = *(unsigned short *)&v10[a7], !*(_WORD *)&v10[a7])) v12 = *(_DWORD *)&v8[4 * nCel + 4] - v9; v13 = &v10[(_DWORD)pCelBuffa]; v14 = v12 - (_DWORD)pCelBuffa; v15 = -(light4flag != 0); _LOWORD(v15) = v15 & 0xF400; v16 = v15 + 4096; - if ( a8 == 2 ) + if (a8 == 2) v16 += 256; - if ( a8 >= 4 ) + if (a8 >= 4) v16 = v16 + (a8 << 8) - 256; Cl2DecDatLightTbl1( - (char *)gpBuffer + screen_y_times_768[screen_y - 16 * a6] + screen_x, - v13, - v14, - frame_width, - &pLightTbl[v16]); + (char *)gpBuffer + screen_y_times_768[screen_y - 16 * a6] + screen_x, + v13, + v14, + frame_width, + &pLightTbl[v16]); } } } @@ -2304,10 +2015,10 @@ void __fastcall Cl2DecDatLightTbl1(char *a1, char *a2, int a3, int a4, char *unu { char *v5; // esi char *v6; // edi - int v7; // ebx - int v8; // ecx - int v9; // eax - int v10; // edx + int v7; // ebx + int v8; // ecx + int v9; // eax + int v10; // edx char v11; // dl v5 = a2; @@ -2317,116 +2028,93 @@ void __fastcall Cl2DecDatLightTbl1(char *a1, char *a2, int a3, int a4, char *unu sgnWidth = a4; v9 = 0; v10 = 0; - do - { + do { _LOBYTE(v9) = *v5++; --v8; - if ( (v9 & 0x80u) == 0 ) - { - do - { - if ( v9 <= v7 ) - { + if ((v9 & 0x80u) == 0) { + do { + if (v9 <= v7) { v10 = v9; v6 += v9; v9 = 0; - } - else - { + } else { v10 = v7; v6 += v7; v9 -= v7; } v7 -= v10; - if ( !v7 ) - { + if (!v7) { v7 = sgnWidth; v6 = &v6[-sgnWidth - 768]; } - } - while ( v9 ); - } - else - { + } while (v9); + } else { _LOBYTE(v9) = -(char)v9; - if ( (char)v9 <= 65 ) - { + if ((char)v9 <= 65) { v8 -= v9; v7 -= v9; - do - { + do { _LOBYTE(v10) = *v5++; *v6 = unused_lindex[v10]; --v9; ++v6; - } - while ( v9 ); - } - else - { + } while (v9); + } else { _LOBYTE(v9) = v9 - 65; --v8; v7 -= v9; _LOBYTE(v10) = *v5++; v11 = unused_lindex[v10]; - do - { + do { *v6 = v11; --v9; ++v6; - } - while ( v9 ); + } while (v9); } - if ( !v7 ) - { + if (!v7) { v7 = sgnWidth; v6 = &v6[-sgnWidth - 768]; } } - } - while ( v8 ); + } while (v8); } // 52B978: using guessed type int sgnWidth; void __fastcall Cl2DecodeLightTbl(int screen_x, int screen_y, char *pCelBuff, int nCel, int frame_width, int a6, int a7) { - int v7; // esi - char *v8; // edi - int v9; // ebx - char *v10; // edx - int v11; // eax - int v12; // eax - int v13; // eax - char *v14; // edx - char *v15; // ecx + int v7; // esi + char *v8; // edi + int v9; // ebx + char *v10; // edx + int v11; // eax + int v12; // eax + int v13; // eax + char *v14; // edx + char *v15; // ecx char *pCelBuffa; // [esp+18h] [ebp+8h] v7 = screen_y; - if ( gpBuffer ) - { + if (gpBuffer) { v8 = pCelBuff; - if ( pCelBuff ) - { - if ( nCel > 0 ) - { + if (pCelBuff) { + if (nCel > 0) { v9 = *(_DWORD *)&pCelBuff[4 * nCel]; v10 = &pCelBuff[v9]; v11 = *(unsigned short *)&pCelBuff[v9 + a6]; pCelBuffa = (char *)*(unsigned short *)&pCelBuff[v9 + a6]; - if ( v11 ) - { - if ( a7 == 8 || (v12 = *(unsigned short *)&v10[a7], !*(_WORD *)&v10[a7]) ) + if (v11) { + if (a7 == 8 || (v12 = *(unsigned short *)&v10[a7], !*(_WORD *)&v10[a7])) v12 = *(_DWORD *)&v8[4 * nCel + 4] - v9; v13 = v12 - (_DWORD)pCelBuffa; v14 = &v10[(_DWORD)pCelBuffa]; v15 = (char *)gpBuffer + screen_y_times_768[v7 - 16 * a6] + screen_x; - if ( light_table_index ) + if (light_table_index) Cl2DecDatLightTbl1( - v15, - v14, - v13, - frame_width, - &pLightTbl[256 * light_table_index]); + v15, + v14, + v13, + frame_width, + &pLightTbl[256 * light_table_index]); else Cl2DecDatFrm1(v15, v14, v13, frame_width); } @@ -2438,35 +2126,31 @@ void __fastcall Cl2DecodeLightTbl(int screen_x, int screen_y, char *pCelBuff, in void __fastcall Cl2DecodeFrm4(int screen_x, int screen_y, char *pCelBuff, int nCel, int frame_width, int a6, int a7) { - int v7; // ebx - char *v8; // edx - char *v9; // ecx - int v10; // ecx - int v11; // eax - int v12; // [esp+Ch] [ebp-4h] + int v7; // ebx + char *v8; // edx + char *v9; // ecx + int v10; // ecx + int v11; // eax + int v12; // [esp+Ch] [ebp-4h] char *pCelBuffa; // [esp+18h] [ebp+8h] v7 = screen_y; v12 = screen_x; - if ( gpBuffer ) - { + if (gpBuffer) { v8 = pCelBuff; - if ( pCelBuff ) - { - if ( nCel > 0 ) - { + if (pCelBuff) { + if (nCel > 0) { v9 = *(char **)&pCelBuff[4 * nCel]; pCelBuffa = v9; v10 = (int)&v9[(_DWORD)v8]; - if ( *(_WORD *)(v10 + a6) ) - { - if ( a7 == 8 || (v11 = *(unsigned short *)(v10 + a7), !*(_WORD *)(v10 + a7)) ) + if (*(_WORD *)(v10 + a6)) { + if (a7 == 8 || (v11 = *(unsigned short *)(v10 + a7), !*(_WORD *)(v10 + a7))) v11 = *(_DWORD *)&v8[4 * nCel + 4] - (_DWORD)pCelBuffa; Cl2DecDatFrm4( - (char *)gpBuffer + screen_y_times_768[v7 - 16 * a6] + v12, - (char *)(*(unsigned short *)(v10 + a6) + v10), - v11 - *(unsigned short *)(v10 + a6), - frame_width); + (char *)gpBuffer + screen_y_times_768[v7 - 16 * a6] + v12, + (char *)(*(unsigned short *)(v10 + a6) + v10), + v11 - *(unsigned short *)(v10 + a6), + frame_width); } } } @@ -2477,61 +2161,49 @@ void __fastcall Cl2DecDatFrm4(char *buffer, char *a2, int a3, int frame_width) { char *v4; // esi char *v5; // edi - int v6; // eax - int v7; // ebx - int v8; // ecx - char v9; // dl + int v6; // eax + int v7; // ebx + int v8; // ecx + char v9; // dl char v10; // dl - int v11; // edx + int v11; // edx v4 = a2; v5 = buffer; v6 = 0; v7 = frame_width; v8 = a3; - do - { + do { _LOBYTE(v6) = *v4++; --v8; - if ( (v6 & 0x80u) != 0 ) - { + if ((v6 & 0x80u) != 0) { _LOBYTE(v6) = -(char)v6; - if ( (char)v6 <= 65 ) - { + if ((char)v6 <= 65) { v8 -= v6; - if ( v5 < (char *)gpBufEnd ) - { + if (v5 < (char *)gpBufEnd) { v7 -= v6; - do - { + do { v10 = *v4++; *v5 = v10; --v6; ++v5; - } - while ( v6 ); + } while (v6); goto LABEL_12; } v4 += v6; - } - else - { + } else { _LOBYTE(v6) = v6 - 65; --v8; v9 = *v4++; - if ( v5 < (char *)gpBufEnd ) - { + if (v5 < (char *)gpBufEnd) { v7 -= v6; - do - { + do { *v5 = v9; --v6; ++v5; - } - while ( v6 ); -LABEL_12: - if ( !v7 ) - { + } while (v6); + LABEL_12: + if (!v7) { v7 = frame_width; v5 = &v5[-frame_width - 768]; } @@ -2539,64 +2211,53 @@ LABEL_12: } } } - do - { - if ( v6 <= v7 ) - { + do { + if (v6 <= v7) { v11 = v6; v5 += v6; v6 = 0; - } - else - { + } else { v11 = v7; v5 += v7; v6 -= v7; } v7 -= v11; - if ( !v7 ) - { + if (!v7) { v7 = frame_width; v5 = &v5[-frame_width - 768]; } - } - while ( v6 ); - } - while ( v8 ); + } while (v6); + } while (v8); } // 69CF0C: using guessed type int gpBufEnd; void __fastcall Cl2DecodeClrHL(char colour, int screen_x, int screen_y, char *pCelBuff, int nCel, int frame_width, int a7, int a8) { - int v8; // ebx + int v8; // ebx char *v9; // edx - int v10; // ecx - int v11; // eax - int v12; // [esp+Ch] [ebp-8h] - char a5; // [esp+10h] [ebp-4h] + int v10; // ecx + int v11; // eax + int v12; // [esp+Ch] [ebp-8h] + char a5; // [esp+10h] [ebp-4h] v12 = screen_x; a5 = colour; - if ( gpBuffer ) - { - if ( pCelBuff ) - { - if ( nCel > 0 ) - { + if (gpBuffer) { + if (pCelBuff) { + if (nCel > 0) { v8 = *(_DWORD *)&pCelBuff[4 * nCel]; v9 = &pCelBuff[v8]; v10 = *(unsigned short *)&pCelBuff[v8 + a7]; - if ( *(_WORD *)&pCelBuff[v8 + a7] ) - { - if ( a8 == 8 || (v11 = *(unsigned short *)&v9[a8], !*(_WORD *)&v9[a8]) ) + if (*(_WORD *)&pCelBuff[v8 + a7]) { + if (a8 == 8 || (v11 = *(unsigned short *)&v9[a8], !*(_WORD *)&v9[a8])) v11 = *(_DWORD *)&pCelBuff[4 * nCel + 4] - v8; gpBufEnd -= 768; Cl2DecDatClrHL( - (char *)gpBuffer + screen_y_times_768[screen_y - 16 * a7] + v12, - &v9[v10], - v11 - v10, - frame_width, - a5); + (char *)gpBuffer + screen_y_times_768[screen_y - 16 * a7] + v12, + &v9[v10], + v11 - v10, + frame_width, + a5); gpBufEnd += 768; } } @@ -2609,13 +2270,13 @@ void __fastcall Cl2DecDatClrHL(char *dst_buf, char *frame_content, int a3, int f { char *v5; // esi char *v6; // edi - int v7; // eax - int v8; // ebx - int v9; // ecx + int v7; // eax + int v8; // ebx + int v9; // ecx char v10; // dl char v11; // dh char v12; // dh - int v13; // edx + int v13; // edx v5 = frame_content; v6 = dst_buf; @@ -2623,24 +2284,18 @@ void __fastcall Cl2DecDatClrHL(char *dst_buf, char *frame_content, int a3, int f v8 = frame_width; v9 = a3; v10 = colour; - do - { + do { _LOBYTE(v7) = *v5++; --v9; - if ( (v7 & 0x80u) != 0 ) - { + if ((v7 & 0x80u) != 0) { _LOBYTE(v7) = -(char)v7; - if ( (char)v7 <= 65 ) - { + if ((char)v7 <= 65) { v9 -= v7; - if ( v6 < (char *)gpBufEnd ) - { + if (v6 < (char *)gpBufEnd) { v8 -= v7; - do - { + do { v12 = *v5++; - if ( v12 ) - { + if (v12) { *(v6 - 1) = v10; v6[1] = v10; *(v6 - 768) = v10; @@ -2648,33 +2303,26 @@ void __fastcall Cl2DecDatClrHL(char *dst_buf, char *frame_content, int a3, int f } --v7; ++v6; - } - while ( v7 ); + } while (v7); goto LABEL_15; } v5 += v7; - } - else - { + } else { _LOBYTE(v7) = v7 - 65; --v9; v11 = *v5++; - if ( v11 && v6 < (char *)gpBufEnd ) - { + if (v11 && v6 < (char *)gpBufEnd) { *(v6 - 1) = v10; v8 -= v7; v6[v7] = v10; - do - { + do { *(v6 - 768) = v10; v6[768] = v10; --v7; ++v6; - } - while ( v7 ); -LABEL_15: - if ( !v8 ) - { + } while (v7); + LABEL_15: + if (!v8) { v8 = frame_width; v6 = &v6[-frame_width - 768]; } @@ -2682,77 +2330,66 @@ LABEL_15: } } } - do - { - if ( v7 <= v8 ) - { + do { + if (v7 <= v8) { v13 = v7; v6 += v7; v7 = 0; - } - else - { + } else { v13 = v8; v6 += v8; v7 -= v8; } v8 -= v13; - if ( !v8 ) - { + if (!v8) { v8 = frame_width; v6 = &v6[-frame_width - 768]; } - } - while ( v7 ); + } while (v7); v10 = colour; - } - while ( v9 ); + } while (v9); } // 69CF0C: using guessed type int gpBufEnd; void __fastcall Cl2DecodeFrm5(int screen_x, int screen_y, char *pCelBuff, int nCel, int frame_width, int a6, int a7, char a8) { - char *v8; // edi - int v9; // ebx - char *v10; // esi - int v11; // eax - int v12; // eax - char *v13; // esi - int v14; // edi - int v15; // eax - int v16; // eax + char *v8; // edi + int v9; // ebx + char *v10; // esi + int v11; // eax + int v12; // eax + char *v13; // esi + int v14; // edi + int v15; // eax + int v16; // eax char *pCelBuffa; // [esp+18h] [ebp+8h] - if ( gpBuffer ) - { + if (gpBuffer) { v8 = pCelBuff; - if ( pCelBuff ) - { - if ( nCel > 0 ) - { + if (pCelBuff) { + if (nCel > 0) { v9 = *(_DWORD *)&pCelBuff[4 * nCel]; v10 = &pCelBuff[v9]; v11 = *(unsigned __int16 *)&pCelBuff[v9 + a6]; pCelBuffa = (char *)*(unsigned __int16 *)&pCelBuff[v9 + a6]; - if ( v11 ) - { - if ( a7 == 8 || (v12 = *(unsigned __int16 *)&v10[a7], !*(_WORD *)&v10[a7]) ) + if (v11) { + if (a7 == 8 || (v12 = *(unsigned __int16 *)&v10[a7], !*(_WORD *)&v10[a7])) v12 = *(_DWORD *)&v8[4 * nCel + 4] - v9; v13 = &v10[(_DWORD)pCelBuffa]; v14 = v12 - (_DWORD)pCelBuffa; v15 = -(light4flag != 0); _LOWORD(v15) = v15 & 0xF400; v16 = v15 + 4096; - if ( a8 == 2 ) + if (a8 == 2) v16 += 256; - if ( a8 >= 4 ) + if (a8 >= 4) v16 = v16 + (a8 << 8) - 256; Cl2DecDatLightTbl2( - (char *)gpBuffer + screen_y_times_768[screen_y - 16 * a6] + screen_x, - v13, - v14, - frame_width, - &pLightTbl[v16]); + (char *)gpBuffer + screen_y_times_768[screen_y - 16 * a6] + screen_x, + v13, + v14, + frame_width, + &pLightTbl[v16]); } } } @@ -2764,10 +2401,10 @@ void __fastcall Cl2DecDatLightTbl2(char *dst_buf, char *a2, int a3, int frame_wi { char *v5; // esi char *v6; // edi - int v7; // ebx - int v8; // ecx - int v9; // eax - int v10; // edx + int v7; // ebx + int v8; // ecx + int v9; // eax + int v10; // edx char v11; // dl v5 = a2; @@ -2777,50 +2414,38 @@ void __fastcall Cl2DecDatLightTbl2(char *dst_buf, char *a2, int a3, int frame_wi sgnWidth = frame_width; v9 = 0; v10 = 0; - do - { + do { _LOBYTE(v9) = *v5++; --v8; - if ( (v9 & 0x80u) != 0 ) - { + if ((v9 & 0x80u) != 0) { _LOBYTE(v9) = -(char)v9; - if ( (char)v9 <= 65 ) - { + if ((char)v9 <= 65) { v8 -= v9; - if ( v6 < (char *)gpBufEnd ) - { + if (v6 < (char *)gpBufEnd) { v7 -= v9; - do - { + do { _LOBYTE(v10) = *v5++; *v6 = a5[v10]; --v9; ++v6; - } - while ( v9 ); + } while (v9); goto LABEL_12; } v5 += v9; - } - else - { + } else { _LOBYTE(v9) = v9 - 65; --v8; _LOBYTE(v10) = *v5++; v11 = a5[v10]; - if ( v6 < (char *)gpBufEnd ) - { + if (v6 < (char *)gpBufEnd) { v7 -= v9; - do - { + do { *v6 = v11; --v9; ++v6; - } - while ( v9 ); -LABEL_12: - if ( !v7 ) - { + } while (v9); + LABEL_12: + if (!v7) { v7 = sgnWidth; v6 = &v6[-sgnWidth - 768]; } @@ -2828,67 +2453,56 @@ LABEL_12: } } } - do - { - if ( v9 <= v7 ) - { + do { + if (v9 <= v7) { v10 = v9; v6 += v9; v9 = 0; - } - else - { + } else { v10 = v7; v6 += v7; v9 -= v7; } v7 -= v10; - if ( !v7 ) - { + if (!v7) { v7 = sgnWidth; v6 = &v6[-sgnWidth - 768]; } - } - while ( v9 ); - } - while ( v8 ); + } while (v9); + } while (v8); } // 52B978: using guessed type int sgnWidth; // 69CF0C: using guessed type int gpBufEnd; void __fastcall Cl2DecodeFrm6(int screen_x, int screen_y, char *pCelBuff, int nCel, int frame_width, int a6, int a7) { - int v7; // esi - char *v8; // edi - int v9; // ebx - char *v10; // edx - int v11; // eax - int v12; // eax - int v13; // eax - char *v14; // edx - char *v15; // ecx + int v7; // esi + char *v8; // edi + int v9; // ebx + char *v10; // edx + int v11; // eax + int v12; // eax + int v13; // eax + char *v14; // edx + char *v15; // ecx char *pCelBuffa; // [esp+18h] [ebp+8h] v7 = screen_y; - if ( gpBuffer ) - { + if (gpBuffer) { v8 = pCelBuff; - if ( pCelBuff ) - { - if ( nCel > 0 ) - { + if (pCelBuff) { + if (nCel > 0) { v9 = *(_DWORD *)&pCelBuff[4 * nCel]; v10 = &pCelBuff[v9]; v11 = *(unsigned short *)&pCelBuff[v9 + a6]; pCelBuffa = (char *)*(unsigned short *)&pCelBuff[v9 + a6]; - if ( v11 ) - { - if ( a7 == 8 || (v12 = *(unsigned short *)&v10[a7], !*(_WORD *)&v10[a7]) ) + if (v11) { + if (a7 == 8 || (v12 = *(unsigned short *)&v10[a7], !*(_WORD *)&v10[a7])) v12 = *(_DWORD *)&v8[4 * nCel + 4] - v9; v13 = v12 - (_DWORD)pCelBuffa; v14 = &v10[(_DWORD)pCelBuffa]; v15 = (char *)gpBuffer + screen_y_times_768[v7 - 16 * a6] + screen_x; - if ( light_table_index ) + if (light_table_index) Cl2DecDatLightTbl2(v15, v14, v13, frame_width, &pLightTbl[256 * light_table_index]); else Cl2DecDatFrm4(v15, v14, v13, frame_width); diff --git a/Source/engine.h b/Source/engine.h index 36902808..124ca4a6 100644 --- a/Source/engine.h +++ b/Source/engine.h @@ -6,12 +6,12 @@ //pCelBuff->pFrameTable[0] extern int engine_cpp_init_value; // weak -extern char gbPixelCol; // automap pixel color 8-bit (palette entry) -extern int dword_52B970; // bool flip - if y < x -extern int orgseed; // weak +extern char gbPixelCol; // automap pixel color 8-bit (palette entry) +extern int dword_52B970; // bool flip - if y < x +extern int orgseed; // weak extern int sgnWidth; -extern int sglGameSeed; // weak -extern int SeedCount; // weak +extern int sglGameSeed; // weak +extern int SeedCount; // weak extern int dword_52B99C; // bool valid - if x/y are in bounds void __cdecl engine_cpp_init_1(); @@ -73,8 +73,8 @@ void __fastcall PlayInGameMovie(char *pszMovie); /* rdata */ -extern const int engine_inf; // weak -extern const int rand_increment; // unused +extern const int engine_inf; // weak +extern const int rand_increment; // unused extern const int rand_multiplier; // unused #endif /* __ENGINE_H__ */ diff --git a/Source/error.cpp b/Source/error.cpp index bc20d2a9..63c971e9 100644 --- a/Source/error.cpp +++ b/Source/error.cpp @@ -8,112 +8,112 @@ char msgflag; char msgcnt; char *MsgStrings[44] = { - "", - "No automap available in town", - "No multiplayer functions in demo", - "Direct Sound Creation Failed", - "Not available in shareware version", - "Not enough space to save", - "No Pause in town", - "Copying to a hard disk is recommended", - "Multiplayer sync problem", - "No pause in multiplayer", - "Loading...", - "Saving...", - "Some are weakened as one grows strong", - "New strength is forged through destruction", - "Those who defend seldom attack", - "The sword of justice is swift and sharp", - "While the spirit is vigilant the body thrives", - "The powers of mana refocused renews", - "Time cannot diminish the power of steel", - "Magic is not always what it seems to be", - "What once was opened now is closed", - "Intensity comes at the cost of wisdom", - "Arcane power brings destruction", - "That which cannot be held cannot be harmed", - "Crimson and Azure become as the sun", - "Knowledge and wisdom at the cost of self", - "Drink and be refreshed", - "Wherever you go, there you are", - "Energy comes at the cost of wisdom", - "Riches abound when least expected", - "Where avarice fails, patience gains reward", - "Blessed by a benevolent companion!", - "The hands of men may be guided by fate", - "Strength is bolstered by heavenly faith", - "The essence of life flows from within", - "The way is made clear when viewed from above", - "Salvation comes at the cost of wisdom", - "Mysteries are revealed in the light of reason", - "Those who are last may yet be first", - "Generosity brings its own rewards", - "You must be at least level 8 to use this.", - "You must be at least level 13 to use this.", - "You must be at least level 17 to use this.", - "Arcane knowledge gained!" + "", + "No automap available in town", + "No multiplayer functions in demo", + "Direct Sound Creation Failed", + "Not available in shareware version", + "Not enough space to save", + "No Pause in town", + "Copying to a hard disk is recommended", + "Multiplayer sync problem", + "No pause in multiplayer", + "Loading...", + "Saving...", + "Some are weakened as one grows strong", + "New strength is forged through destruction", + "Those who defend seldom attack", + "The sword of justice is swift and sharp", + "While the spirit is vigilant the body thrives", + "The powers of mana refocused renews", + "Time cannot diminish the power of steel", + "Magic is not always what it seems to be", + "What once was opened now is closed", + "Intensity comes at the cost of wisdom", + "Arcane power brings destruction", + "That which cannot be held cannot be harmed", + "Crimson and Azure become as the sun", + "Knowledge and wisdom at the cost of self", + "Drink and be refreshed", + "Wherever you go, there you are", + "Energy comes at the cost of wisdom", + "Riches abound when least expected", + "Where avarice fails, patience gains reward", + "Blessed by a benevolent companion!", + "The hands of men may be guided by fate", + "Strength is bolstered by heavenly faith", + "The essence of life flows from within", + "The way is made clear when viewed from above", + "Salvation comes at the cost of wisdom", + "Mysteries are revealed in the light of reason", + "Those who are last may yet be first", + "Generosity brings its own rewards", + "You must be at least level 8 to use this.", + "You must be at least level 13 to use this.", + "You must be at least level 17 to use this.", + "Arcane knowledge gained!" }; void __fastcall InitDiabloMsg(char e) { - for (int i = 0; i < msgcnt; i++) { - if (msgtable[i] == e) - return; - } + for (int i = 0; i < msgcnt; i++) { + if (msgtable[i] == e) + return; + } - msgtable[msgcnt] = e; - if (msgcnt < (BYTE)sizeof(msgtable)) - msgcnt++; + msgtable[msgcnt] = e; + if (msgcnt < (BYTE)sizeof(msgtable)) + msgcnt++; - msgflag = msgtable[0]; - msgdelay = 70; + msgflag = msgtable[0]; + msgdelay = 70; } void __cdecl ClrDiabloMsg() { - for (int i = 0; i < sizeof(msgtable); i++) - msgtable[i] = 0; + for (int i = 0; i < sizeof(msgtable); i++) + msgtable[i] = 0; - msgflag = 0; - msgcnt = 0; + msgflag = 0; + msgcnt = 0; } void __cdecl DrawDiabloMsg() { - int v0; // esi - signed int v1; // edi - int v8; // edi - signed int v9; // ebx - signed int v10; // eax - signed int v11; // ecx - int v12; // esi - signed int v13; // esi - unsigned char v14; // bl - bool v15; // zf - signed int v16; // [esp+Ch] [ebp-8h] - signed int v17; // [esp+Ch] [ebp-8h] - signed int screen_x; // [esp+10h] [ebp-4h] + int v0; // esi + signed int v1; // edi + int v8; // edi + signed int v9; // ebx + signed int v10; // eax + signed int v11; // ecx + int v12; // esi + signed int v13; // esi + unsigned char v14; // bl + bool v15; // zf + signed int v16; // [esp+Ch] [ebp-8h] + signed int v17; // [esp+Ch] [ebp-8h] + signed int screen_x; // [esp+10h] [ebp-4h] - CelDecodeOnly(165, 318, pSTextSlidCels, 1, 12); - CelDecodeOnly(591, 318, pSTextSlidCels, 4, 12); - CelDecodeOnly(165, 366, pSTextSlidCels, 2, 12); - CelDecodeOnly(591, 366, pSTextSlidCels, 3, 12); - screen_x = 173; - v16 = 35; - do { - CelDecodeOnly(screen_x, 318, pSTextSlidCels, 5, 12); - CelDecodeOnly(screen_x, 366, pSTextSlidCels, 7, 12); - screen_x += 12; - --v16; - } while (v16); - v0 = 330; - v1 = 3; - do { - CelDecodeOnly(165, v0, pSTextSlidCels, 6, 12); - CelDecodeOnly(591, v0, pSTextSlidCels, 8, 12); - v0 += 12; - --v1; - } while (v1); + CelDecodeOnly(165, 318, pSTextSlidCels, 1, 12); + CelDecodeOnly(591, 318, pSTextSlidCels, 4, 12); + CelDecodeOnly(165, 366, pSTextSlidCels, 2, 12); + CelDecodeOnly(591, 366, pSTextSlidCels, 3, 12); + screen_x = 173; + v16 = 35; + do { + CelDecodeOnly(screen_x, 318, pSTextSlidCels, 5, 12); + CelDecodeOnly(screen_x, 366, pSTextSlidCels, 7, 12); + screen_x += 12; + --v16; + } while (v16); + v0 = 330; + v1 = 3; + do { + CelDecodeOnly(165, v0, pSTextSlidCels, 6, 12); + CelDecodeOnly(591, v0, pSTextSlidCels, 8, 12); + v0 += 12; + --v1; + } while (v1); #define TRANS_RECT_X 104 #define TRANS_RECT_Y 150 @@ -121,40 +121,40 @@ void __cdecl DrawDiabloMsg() #define TRANS_RECT_HEIGHT 54 #include "asm_trans_rect.inc" - strcpy(tempstr, MsgStrings[msgflag]); - v8 = screen_y_times_768[342] + 165; - v9 = strlen(tempstr); - v10 = 0; - v11 = 0; - v17 = v9; - if (v9 <= 0) - goto LABEL_27; - do { - v12 = (unsigned char)tempstr[v11++]; - v10 += fontkern[fontframe[fontidx[v12]]] + 1; - } while (v11 < v9); - if (v10 < 442) - LABEL_27: - v8 += (442 - v10) >> 1; - v13 = 0; - if (v9 > 0) { - do { - v14 = fontframe[fontidx[(unsigned char)tempstr[v13]]]; - if (v14) - CPrintString(v8, v14, 3); - ++v13; - v8 += fontkern[v14] + 1; - } while (v13 < v17); - } - v15 = msgdelay == 0; - if (msgdelay > 0) - v15 = --msgdelay == 0; - if (v15) { - v15 = msgcnt-- == 1; - msgdelay = 70; - if (v15) - msgflag = 0; - else - msgflag = msgtable[msgcnt]; - } + strcpy(tempstr, MsgStrings[msgflag]); + v8 = screen_y_times_768[342] + 165; + v9 = strlen(tempstr); + v10 = 0; + v11 = 0; + v17 = v9; + if (v9 <= 0) + goto LABEL_27; + do { + v12 = (unsigned char)tempstr[v11++]; + v10 += fontkern[fontframe[fontidx[v12]]] + 1; + } while (v11 < v9); + if (v10 < 442) + LABEL_27: + v8 += (442 - v10) >> 1; + v13 = 0; + if (v9 > 0) { + do { + v14 = fontframe[fontidx[(unsigned char)tempstr[v13]]]; + if (v14) + CPrintString(v8, v14, 3); + ++v13; + v8 += fontkern[v14] + 1; + } while (v13 < v17); + } + v15 = msgdelay == 0; + if (msgdelay > 0) + v15 = --msgdelay == 0; + if (v15) { + v15 = msgcnt-- == 1; + msgdelay = 70; + if (v15) + msgflag = 0; + else + msgflag = msgtable[msgcnt]; + } } diff --git a/Source/fault.cpp b/Source/fault.cpp index 168fa204..e161549c 100644 --- a/Source/fault.cpp +++ b/Source/fault.cpp @@ -5,236 +5,236 @@ LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter; // idb struct exception_cpp_init { - exception_cpp_init() - { - exception_install_filter(); - j_exception_init_filter(); - } + exception_cpp_init() + { + exception_install_filter(); + j_exception_init_filter(); + } } _exception_cpp_init; void __cdecl exception_install_filter() { - exception_set_filter(); + exception_set_filter(); } void __cdecl j_exception_init_filter() { - atexit(exception_init_filter); + atexit(exception_init_filter); } void __cdecl exception_init_filter() { - exception_set_filter_ptr(); + exception_set_filter_ptr(); } LONG __stdcall TopLevelExceptionFilter(PEXCEPTION_POINTERS ExceptionInfo) { - log_dump_computer_info(); - PEXCEPTION_RECORD xcpt = ExceptionInfo->ExceptionRecord; + log_dump_computer_info(); + PEXCEPTION_RECORD xcpt = ExceptionInfo->ExceptionRecord; - char szExceptionNameBuf[MAX_PATH]; - char *pszExceptionName = exception_get_error_type(ExceptionInfo->ExceptionRecord->ExceptionCode, szExceptionNameBuf, sizeof(szExceptionNameBuf)); - log_printf("Exception code: %08X %s\r\n", xcpt->ExceptionCode, pszExceptionName); + char szExceptionNameBuf[MAX_PATH]; + char *pszExceptionName = exception_get_error_type(ExceptionInfo->ExceptionRecord->ExceptionCode, szExceptionNameBuf, sizeof(szExceptionNameBuf)); + log_printf("Exception code: %08X %s\r\n", xcpt->ExceptionCode, pszExceptionName); - char szModuleName[MAX_PATH]; - int sectionNumber, sectionOffset; - exception_unknown_module(xcpt->ExceptionAddress, szModuleName, MAX_PATH, §ionNumber, §ionOffset); - log_printf("Fault address:\t%08X %02X:%08X %s\r\n", xcpt->ExceptionAddress, sectionNumber, sectionOffset, szModuleName); + char szModuleName[MAX_PATH]; + int sectionNumber, sectionOffset; + exception_unknown_module(xcpt->ExceptionAddress, szModuleName, MAX_PATH, §ionNumber, §ionOffset); + log_printf("Fault address:\t%08X %02X:%08X %s\r\n", xcpt->ExceptionAddress, sectionNumber, sectionOffset, szModuleName); - PCONTEXT ctx = ExceptionInfo->ContextRecord; + PCONTEXT ctx = ExceptionInfo->ContextRecord; - log_printf("\r\nRegisters:\r\n"); - log_printf( - "EAX:%08X\r\nEBX:%08X\r\nECX:%08X\r\nEDX:%08X\r\nESI:%08X\r\nEDI:%08X\r\n", - ctx->Eax, - ctx->Ebx, - ctx->Ecx, - ctx->Edx, - ctx->Esi, - ctx->Edi); - log_printf("CS:EIP:%04X:%08X\r\n", ctx->SegCs, ctx->Eip); - log_printf("SS:ESP:%04X:%08X EBP:%08X\r\n", ctx->SegSs, ctx->Esp, ctx->Ebp); - log_printf("DS:%04X ES:%04X FS:%04X GS:%04X\r\n", ctx->SegDs, ctx->SegEs, ctx->SegFs, ctx->SegGs); + log_printf("\r\nRegisters:\r\n"); + log_printf( + "EAX:%08X\r\nEBX:%08X\r\nECX:%08X\r\nEDX:%08X\r\nESI:%08X\r\nEDI:%08X\r\n", + ctx->Eax, + ctx->Ebx, + ctx->Ecx, + ctx->Edx, + ctx->Esi, + ctx->Edi); + log_printf("CS:EIP:%04X:%08X\r\n", ctx->SegCs, ctx->Eip); + log_printf("SS:ESP:%04X:%08X EBP:%08X\r\n", ctx->SegSs, ctx->Esp, ctx->Ebp); + log_printf("DS:%04X ES:%04X FS:%04X GS:%04X\r\n", ctx->SegDs, ctx->SegEs, ctx->SegFs, ctx->SegGs); - log_printf("Flags:%08X\r\n", ctx->EFlags); - exception_call_stack((void *)ctx->Eip, (STACK_FRAME *)ctx->Ebp); + log_printf("Flags:%08X\r\n", ctx->EFlags); + exception_call_stack((void *)ctx->Eip, (STACK_FRAME *)ctx->Ebp); - log_printf("Stack bytes:\r\n"); - exception_hex_format((BYTE *)ctx->Esp, 768); + log_printf("Stack bytes:\r\n"); + exception_hex_format((BYTE *)ctx->Esp, 768); - log_printf("Code bytes:\r\n"); - exception_hex_format((BYTE *)ctx->Eip, 16); + log_printf("Code bytes:\r\n"); + exception_hex_format((BYTE *)ctx->Eip, 16); - log_printf("\r\n"); - log_flush(1); + log_printf("\r\n"); + log_flush(1); - if (lpTopLevelExceptionFilter) - return lpTopLevelExceptionFilter(ExceptionInfo); - return EXCEPTION_CONTINUE_SEARCH; + if (lpTopLevelExceptionFilter) + return lpTopLevelExceptionFilter(ExceptionInfo); + return EXCEPTION_CONTINUE_SEARCH; } void __fastcall exception_hex_format(BYTE *ptr, unsigned int numBytes) { - DWORD i; + DWORD i; - while (numBytes > 0) { - DWORD bytesRead; - if (numBytes < 16) - bytesRead = numBytes; - else - bytesRead = 16; + while (numBytes > 0) { + DWORD bytesRead; + if (numBytes < 16) + bytesRead = numBytes; + else + bytesRead = 16; - if (IsBadReadPtr(ptr, bytesRead)) - break; + if (IsBadReadPtr(ptr, bytesRead)) + break; - log_printf("0x%08x: ", ptr); + log_printf("0x%08x: ", ptr); - for (i = 0; i < 16; ++i) { - const char *fmt = "%02x "; - if (i >= bytesRead) - fmt = " "; - log_printf(fmt, ptr[i]); - if (i % 4 == 3) - log_printf(" "); - } + for (i = 0; i < 16; ++i) { + const char *fmt = "%02x "; + if (i >= bytesRead) + fmt = " "; + log_printf(fmt, ptr[i]); + if (i % 4 == 3) + log_printf(" "); + } - for (i = 0; i < bytesRead; i++) { - BYTE c; - if (isprint(ptr[i])) - c = ptr[i]; - else - c = '.'; - log_printf("%c", c); - } + for (i = 0; i < bytesRead; i++) { + BYTE c; + if (isprint(ptr[i])) + c = ptr[i]; + else + c = '.'; + log_printf("%c", c); + } - log_printf("\r\n"); - ptr += bytesRead; - numBytes -= bytesRead; - } - log_printf("\r\n"); + log_printf("\r\n"); + ptr += bytesRead; + numBytes -= bytesRead; + } + log_printf("\r\n"); } void __fastcall exception_unknown_module(LPCVOID lpAddress, LPSTR lpModuleName, int iMaxLength, int *sectionNum, int *sectionOffset) { - lstrcpyn(lpModuleName, "*unknown*", iMaxLength); - *sectionNum = 0; - *sectionOffset = 0; + lstrcpyn(lpModuleName, "*unknown*", iMaxLength); + *sectionNum = 0; + *sectionOffset = 0; - MEMORY_BASIC_INFORMATION memInfo; - if (!VirtualQuery(lpAddress, &memInfo, sizeof(memInfo))) - return; + MEMORY_BASIC_INFORMATION memInfo; + if (!VirtualQuery(lpAddress, &memInfo, sizeof(memInfo))) + return; - PIMAGE_DOS_HEADER dosHeader = (PIMAGE_DOS_HEADER)memInfo.AllocationBase; - if (!memInfo.AllocationBase) - dosHeader = (PIMAGE_DOS_HEADER)GetModuleHandle(0); + PIMAGE_DOS_HEADER dosHeader = (PIMAGE_DOS_HEADER)memInfo.AllocationBase; + if (!memInfo.AllocationBase) + dosHeader = (PIMAGE_DOS_HEADER)GetModuleHandle(0); - if (!GetModuleFileName((HMODULE)dosHeader, lpModuleName, iMaxLength)) { - lstrcpyn(lpModuleName, "*unknown*", iMaxLength); - return; - } + if (!GetModuleFileName((HMODULE)dosHeader, lpModuleName, iMaxLength)) { + lstrcpyn(lpModuleName, "*unknown*", iMaxLength); + return; + } - if (dosHeader && dosHeader->e_magic == IMAGE_DOS_SIGNATURE) { - LONG ntOffset = dosHeader->e_lfanew; - if (ntOffset) { - PIMAGE_NT_HEADERS ntHeader = (PIMAGE_NT_HEADERS)((DWORD)dosHeader + ntOffset); - if (ntHeader->Signature == IMAGE_NT_SIGNATURE) { - PIMAGE_SECTION_HEADER section = IMAGE_FIRST_SECTION(ntHeader); - DWORD numSections = ntHeader->FileHeader.NumberOfSections; - DWORD moduleOffset = (BYTE *)lpAddress - (BYTE *)dosHeader; - for (int i = 0; i < numSections; i++, section++) { - DWORD sectionSize = section->SizeOfRawData; - DWORD sectionAddress = section->VirtualAddress; - if (section->SizeOfRawData <= section->Misc.VirtualSize) - sectionSize = section->Misc.VirtualSize; + if (dosHeader && dosHeader->e_magic == IMAGE_DOS_SIGNATURE) { + LONG ntOffset = dosHeader->e_lfanew; + if (ntOffset) { + PIMAGE_NT_HEADERS ntHeader = (PIMAGE_NT_HEADERS)((DWORD)dosHeader + ntOffset); + if (ntHeader->Signature == IMAGE_NT_SIGNATURE) { + PIMAGE_SECTION_HEADER section = IMAGE_FIRST_SECTION(ntHeader); + DWORD numSections = ntHeader->FileHeader.NumberOfSections; + DWORD moduleOffset = (BYTE *)lpAddress - (BYTE *)dosHeader; + for (int i = 0; i < numSections; i++, section++) { + DWORD sectionSize = section->SizeOfRawData; + DWORD sectionAddress = section->VirtualAddress; + if (section->SizeOfRawData <= section->Misc.VirtualSize) + sectionSize = section->Misc.VirtualSize; - if (moduleOffset >= sectionAddress && moduleOffset <= sectionAddress + sectionSize) { - *sectionNum = i + 1; - *sectionOffset = moduleOffset - sectionAddress; - return; - } - } - } - } - } + if (moduleOffset >= sectionAddress && moduleOffset <= sectionAddress + sectionSize) { + *sectionNum = i + 1; + *sectionOffset = moduleOffset - sectionAddress; + return; + } + } + } + } + } } void __fastcall exception_call_stack(void *instr, STACK_FRAME *stackFrame) { - STACK_FRAME *oldStackFrame; + STACK_FRAME *oldStackFrame; - log_printf("Call stack:\r\nAddress Frame Logical addr Module\r\n"); - do { - char szModuleName[MAX_PATH]; - int sectionNumber, sectionOffset; - exception_unknown_module(instr, szModuleName, MAX_PATH, §ionNumber, §ionOffset); - log_printf("%08X %08X %04X:%08X %s\r\n", instr, stackFrame, sectionNumber, sectionOffset, szModuleName); + log_printf("Call stack:\r\nAddress Frame Logical addr Module\r\n"); + do { + char szModuleName[MAX_PATH]; + int sectionNumber, sectionOffset; + exception_unknown_module(instr, szModuleName, MAX_PATH, §ionNumber, §ionOffset); + log_printf("%08X %08X %04X:%08X %s\r\n", instr, stackFrame, sectionNumber, sectionOffset, szModuleName); - if (IsBadWritePtr(stackFrame, 8)) - break; + if (IsBadWritePtr(stackFrame, 8)) + break; - instr = stackFrame->pCallRet; - oldStackFrame = stackFrame; - stackFrame = stackFrame->pNext; + instr = stackFrame->pCallRet; + oldStackFrame = stackFrame; + stackFrame = stackFrame->pNext; - if ((DWORD)stackFrame % 4 != 0) - break; - } while (stackFrame > oldStackFrame && !IsBadWritePtr(stackFrame, 8)); + if ((DWORD)stackFrame % 4 != 0) + break; + } while (stackFrame > oldStackFrame && !IsBadWritePtr(stackFrame, 8)); - log_printf("\r\n"); + log_printf("\r\n"); } #define CASE_EXCEPTION(v, errName) \ - case EXCEPTION_##errName: \ - v = #errName; \ - break; + case EXCEPTION_##errName: \ + v = #errName; \ + break; char *__fastcall exception_get_error_type(DWORD dwMessageId, LPSTR lpString1, DWORD nSize) { - const char *v4; // eax + const char *v4; // eax - switch (dwMessageId) { - CASE_EXCEPTION(v4, STACK_OVERFLOW); - CASE_EXCEPTION(v4, FLT_DIVIDE_BY_ZERO); - CASE_EXCEPTION(v4, FLT_INEXACT_RESULT); - CASE_EXCEPTION(v4, FLT_INVALID_OPERATION); - CASE_EXCEPTION(v4, FLT_OVERFLOW); - CASE_EXCEPTION(v4, FLT_STACK_CHECK); - CASE_EXCEPTION(v4, FLT_UNDERFLOW); - CASE_EXCEPTION(v4, INT_DIVIDE_BY_ZERO); - CASE_EXCEPTION(v4, INT_OVERFLOW); - CASE_EXCEPTION(v4, PRIV_INSTRUCTION); - CASE_EXCEPTION(v4, FLT_DENORMAL_OPERAND); - CASE_EXCEPTION(v4, INVALID_HANDLE); - CASE_EXCEPTION(v4, ILLEGAL_INSTRUCTION); - CASE_EXCEPTION(v4, NONCONTINUABLE_EXCEPTION); - CASE_EXCEPTION(v4, INVALID_DISPOSITION); - CASE_EXCEPTION(v4, ARRAY_BOUNDS_EXCEEDED); - CASE_EXCEPTION(v4, IN_PAGE_ERROR); - CASE_EXCEPTION(v4, GUARD_PAGE); - CASE_EXCEPTION(v4, DATATYPE_MISALIGNMENT); - CASE_EXCEPTION(v4, BREAKPOINT); - CASE_EXCEPTION(v4, SINGLE_STEP); - CASE_EXCEPTION(v4, ACCESS_VIOLATION); - default: - HMODULE ntdll = GetModuleHandle("NTDLL.DLL"); - if (!FormatMessage(FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_IGNORE_INSERTS, ntdll, dwMessageId, 0, lpString1, nSize, NULL)) { - v4 = "*unknown*"; - } - } - lstrcpyn(lpString1, v4, nSize); - return lpString1; + switch (dwMessageId) { + CASE_EXCEPTION(v4, STACK_OVERFLOW); + CASE_EXCEPTION(v4, FLT_DIVIDE_BY_ZERO); + CASE_EXCEPTION(v4, FLT_INEXACT_RESULT); + CASE_EXCEPTION(v4, FLT_INVALID_OPERATION); + CASE_EXCEPTION(v4, FLT_OVERFLOW); + CASE_EXCEPTION(v4, FLT_STACK_CHECK); + CASE_EXCEPTION(v4, FLT_UNDERFLOW); + CASE_EXCEPTION(v4, INT_DIVIDE_BY_ZERO); + CASE_EXCEPTION(v4, INT_OVERFLOW); + CASE_EXCEPTION(v4, PRIV_INSTRUCTION); + CASE_EXCEPTION(v4, FLT_DENORMAL_OPERAND); + CASE_EXCEPTION(v4, INVALID_HANDLE); + CASE_EXCEPTION(v4, ILLEGAL_INSTRUCTION); + CASE_EXCEPTION(v4, NONCONTINUABLE_EXCEPTION); + CASE_EXCEPTION(v4, INVALID_DISPOSITION); + CASE_EXCEPTION(v4, ARRAY_BOUNDS_EXCEEDED); + CASE_EXCEPTION(v4, IN_PAGE_ERROR); + CASE_EXCEPTION(v4, GUARD_PAGE); + CASE_EXCEPTION(v4, DATATYPE_MISALIGNMENT); + CASE_EXCEPTION(v4, BREAKPOINT); + CASE_EXCEPTION(v4, SINGLE_STEP); + CASE_EXCEPTION(v4, ACCESS_VIOLATION); + default: + HMODULE ntdll = GetModuleHandle("NTDLL.DLL"); + if (!FormatMessage(FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_IGNORE_INSERTS, ntdll, dwMessageId, 0, lpString1, nSize, NULL)) { + v4 = "*unknown*"; + } + } + lstrcpyn(lpString1, v4, nSize); + return lpString1; } void __fastcall exception_set_filter() { - lpTopLevelExceptionFilter = SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER)TopLevelExceptionFilter); + lpTopLevelExceptionFilter = SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER)TopLevelExceptionFilter); } LPTOP_LEVEL_EXCEPTION_FILTER __cdecl exception_set_filter_ptr() { - return SetUnhandledExceptionFilter(lpTopLevelExceptionFilter); + return SetUnhandledExceptionFilter(lpTopLevelExceptionFilter); } LPTOP_LEVEL_EXCEPTION_FILTER __cdecl exception_get_filter() { - return lpTopLevelExceptionFilter; + return lpTopLevelExceptionFilter; } diff --git a/Source/fault.h b/Source/fault.h index a9848307..e0194d24 100644 --- a/Source/fault.h +++ b/Source/fault.h @@ -3,8 +3,8 @@ #define __FAULT_H__ struct STACK_FRAME { - STACK_FRAME *pNext; - void *pCallRet; + STACK_FRAME *pNext; + void *pCallRet; }; //int dword_52B9F4; diff --git a/Source/gamemenu.cpp b/Source/gamemenu.cpp index a73fe5b9..6a43e97a 100644 --- a/Source/gamemenu.cpp +++ b/Source/gamemenu.cpp @@ -3,7 +3,7 @@ #include "../types.h" TMenuItem sgSingleMenu[6] = { - // clang-format off + // clang-format off // dwFlags, pszStr, fnMenu { 0x80000000, "Save Game", &gamemenu_save_game }, { 0x80000000, "Options", &gamemenu_options }, @@ -11,20 +11,20 @@ TMenuItem sgSingleMenu[6] = { { 0x80000000, "Load Game", &gamemenu_load_game }, { 0x80000000, "Quit Diablo", &gamemenu_quit_game }, { 0x80000000, NULL, NULL } - // clang-format on + // clang-format on }; TMenuItem sgMultiMenu[5] = { - // clang-format off + // clang-format off // dwFlags, pszStr, fnMenu { 0x80000000, "Options", &gamemenu_options }, { 0x80000000, "New Game", &gamemenu_new_game }, { 0x80000000, "Restart In Town", &gamemenu_restart_town }, { 0x80000000, "Quit Diablo", &gamemenu_quit_game }, { 0x80000000, NULL, NULL } - // clang-format on + // clang-format on }; TMenuItem sgOptionMenu[6] = { - // clang-format off + // clang-format off // dwFlags, pszStr, fnMenu { 0xC0000000, NULL, (void(__cdecl *)(void)) & gamemenu_music_volume }, { 0xC0000000, NULL, (void(__cdecl *)(void)) & gamemenu_sound_volume }, @@ -32,7 +32,7 @@ TMenuItem sgOptionMenu[6] = { { 0x80000000, NULL, &gamemenu_color_cycling }, { 0x80000000, "Previous Menu", &gamemenu_previous }, { 0x80000000, NULL, NULL } - // clang-format on + // clang-format on }; char *music_toggle_names[] = { "Music", "Music Disabled" }; char *sound_toggle_names[] = { "Sound", "Sound Disabled" }; @@ -40,257 +40,257 @@ char *color_cycling_toggle_names[] = { "Color Cycling Off", "Color Cycling On" } void __cdecl gamemenu_previous() { - void(__cdecl * proc)(); - TMenuItem *item; + void(__cdecl * proc)(); + TMenuItem *item; - if (gbMaxPlayers == 1) { - proc = gamemenu_enable_single; - item = sgSingleMenu; - } else { - proc = gamemenu_enable_multi; - item = sgMultiMenu; - } - gmenu_call_proc(item, proc); - PressEscKey(); + if (gbMaxPlayers == 1) { + proc = gamemenu_enable_single; + item = sgSingleMenu; + } else { + proc = gamemenu_enable_multi; + item = sgMultiMenu; + } + gmenu_call_proc(item, proc); + PressEscKey(); } void __cdecl gamemenu_enable_single() { - bool v0; // dl + bool v0; // dl - gmenu_enable(&sgSingleMenu[3], gbValidSaveFile); - v0 = 0; - if (plr[myplr]._pmode != PM_DEATH && !deathflag) - v0 = 1; - gmenu_enable(sgSingleMenu, v0); + gmenu_enable(&sgSingleMenu[3], gbValidSaveFile); + v0 = 0; + if (plr[myplr]._pmode != PM_DEATH && !deathflag) + v0 = 1; + gmenu_enable(sgSingleMenu, v0); } void __cdecl gamemenu_enable_multi() { - gmenu_enable(&sgMultiMenu[2], deathflag); + gmenu_enable(&sgMultiMenu[2], deathflag); } void __cdecl gamemenu_off() { - gmenu_call_proc(0, NULL); + gmenu_call_proc(0, NULL); } void __cdecl gamemenu_handle_previous() { - if (gmenu_exception()) - gamemenu_off(); - else - gamemenu_previous(); + if (gmenu_exception()) + gamemenu_off(); + else + gamemenu_previous(); } void __cdecl gamemenu_new_game() { - for (int i = 0; i < MAX_PLRS; i++) { - plr[i]._pmode = PM_QUIT; - plr[i]._pInvincible = TRUE; - } + for (int i = 0; i < MAX_PLRS; i++) { + plr[i]._pmode = PM_QUIT; + plr[i]._pInvincible = TRUE; + } - deathflag = FALSE; - drawpanflag = 255; - scrollrt_draw_game_screen(TRUE); - gbRunGame = FALSE; - gamemenu_off(); + deathflag = FALSE; + drawpanflag = 255; + scrollrt_draw_game_screen(TRUE); + gbRunGame = FALSE; + gamemenu_off(); } // 52571C: using guessed type int drawpanflag; void __cdecl gamemenu_quit_game() { - gamemenu_new_game(); - gbRunGameResult = FALSE; + gamemenu_new_game(); + gbRunGameResult = FALSE; } void __cdecl gamemenu_load_game() { - WNDPROC saveProc = SetWindowProc(DisableInputWndProc); - gamemenu_off(); - SetCursor(CURSOR_NONE); - InitDiabloMsg(EMSG_LOADING); - drawpanflag = 255; - DrawAndBlit(); - LoadGame(FALSE); - ClrDiabloMsg(); - PaletteFadeOut(8); - deathflag = FALSE; - drawpanflag = 255; - DrawAndBlit(); - PaletteFadeIn(8); - SetCursor(CURSOR_HAND); - interface_msg_pump(); - SetWindowProc(saveProc); + WNDPROC saveProc = SetWindowProc(DisableInputWndProc); + gamemenu_off(); + SetCursor(CURSOR_NONE); + InitDiabloMsg(EMSG_LOADING); + drawpanflag = 255; + DrawAndBlit(); + LoadGame(FALSE); + ClrDiabloMsg(); + PaletteFadeOut(8); + deathflag = FALSE; + drawpanflag = 255; + DrawAndBlit(); + PaletteFadeIn(8); + SetCursor(CURSOR_HAND); + interface_msg_pump(); + SetWindowProc(saveProc); } // 52571C: using guessed type int drawpanflag; void __cdecl gamemenu_save_game() { - if (pcurs == CURSOR_HAND) { - if (plr[myplr]._pmode == PM_DEATH || deathflag) { - gamemenu_off(); - } else { - WNDPROC saveProc = SetWindowProc(DisableInputWndProc); - SetCursor(CURSOR_NONE); - gamemenu_off(); - InitDiabloMsg(EMSG_SAVING); - drawpanflag = 255; - DrawAndBlit(); - SaveGame(); - ClrDiabloMsg(); - drawpanflag = 255; - SetCursor(CURSOR_HAND); - interface_msg_pump(); - SetWindowProc(saveProc); - } - } + if (pcurs == CURSOR_HAND) { + if (plr[myplr]._pmode == PM_DEATH || deathflag) { + gamemenu_off(); + } else { + WNDPROC saveProc = SetWindowProc(DisableInputWndProc); + SetCursor(CURSOR_NONE); + gamemenu_off(); + InitDiabloMsg(EMSG_SAVING); + drawpanflag = 255; + DrawAndBlit(); + SaveGame(); + ClrDiabloMsg(); + drawpanflag = 255; + SetCursor(CURSOR_HAND); + interface_msg_pump(); + SetWindowProc(saveProc); + } + } } // 52571C: using guessed type int drawpanflag; void __cdecl gamemenu_restart_town() { - NetSendCmd(TRUE, CMD_RETOWN); + NetSendCmd(TRUE, CMD_RETOWN); } void __cdecl gamemenu_options() { - gamemenu_get_music(); - gamemenu_get_sound(); - gamemenu_get_gamma(); - gamemenu_get_color_cycling(); - gmenu_call_proc(sgOptionMenu, NULL); + gamemenu_get_music(); + gamemenu_get_sound(); + gamemenu_get_gamma(); + gamemenu_get_color_cycling(); + gmenu_call_proc(sgOptionMenu, NULL); } void __cdecl gamemenu_get_music() { - gamemenu_sound_music_toggle(music_toggle_names, sgOptionMenu, sound_get_or_set_music_volume(1)); + gamemenu_sound_music_toggle(music_toggle_names, sgOptionMenu, sound_get_or_set_music_volume(1)); } void __fastcall gamemenu_sound_music_toggle(char **names, TMenuItem *menu_item, int volume) { - if (gbSndInited) { - menu_item->dwFlags |= 0xC0000000; - menu_item->pszStr = *names; - gmenu_slider_3(menu_item, 17); - gmenu_slider_1(menu_item, VOLUME_MIN, VOLUME_MAX, volume); - } else { - menu_item->dwFlags &= 0x3FFFFFFF; - menu_item->pszStr = names[1]; - } + if (gbSndInited) { + menu_item->dwFlags |= 0xC0000000; + menu_item->pszStr = *names; + gmenu_slider_3(menu_item, 17); + gmenu_slider_1(menu_item, VOLUME_MIN, VOLUME_MAX, volume); + } else { + menu_item->dwFlags &= 0x3FFFFFFF; + menu_item->pszStr = names[1]; + } } void __cdecl gamemenu_get_sound() { - gamemenu_sound_music_toggle(sound_toggle_names, &sgOptionMenu[1], sound_get_or_set_sound_volume(1)); + gamemenu_sound_music_toggle(sound_toggle_names, &sgOptionMenu[1], sound_get_or_set_sound_volume(1)); } void __cdecl gamemenu_get_color_cycling() { - sgOptionMenu[3].pszStr = color_cycling_toggle_names[palette_get_colour_cycling() & 1]; + sgOptionMenu[3].pszStr = color_cycling_toggle_names[palette_get_colour_cycling() & 1]; } void __cdecl gamemenu_get_gamma() { - gmenu_slider_3(&sgOptionMenu[2], 15); - gmenu_slider_1(&sgOptionMenu[2], 30, 100, UpdateGamma(0)); + gmenu_slider_3(&sgOptionMenu[2], 15); + gmenu_slider_1(&sgOptionMenu[2], 30, 100, UpdateGamma(0)); } void __fastcall gamemenu_music_volume(int volume) { - if (volume) { - if (gbMusicOn) { - gbMusicOn = FALSE; - music_stop(); - sound_get_or_set_music_volume(VOLUME_MIN); - gamemenu_get_music(); - return; - } - gbMusicOn = TRUE; - sound_get_or_set_music_volume(VOLUME_MAX); - music_start(leveltype); - gamemenu_get_music(); - return; - } + if (volume) { + if (gbMusicOn) { + gbMusicOn = FALSE; + music_stop(); + sound_get_or_set_music_volume(VOLUME_MIN); + gamemenu_get_music(); + return; + } + gbMusicOn = TRUE; + sound_get_or_set_music_volume(VOLUME_MAX); + music_start(leveltype); + gamemenu_get_music(); + return; + } - volume = gamemenu_slider_music_sound(sgOptionMenu); - sound_get_or_set_music_volume(volume); + volume = gamemenu_slider_music_sound(sgOptionMenu); + sound_get_or_set_music_volume(volume); - if (volume == VOLUME_MIN) { + if (volume == VOLUME_MIN) { - if (gbMusicOn) { - gbMusicOn = FALSE; - music_stop(); - } + if (gbMusicOn) { + gbMusicOn = FALSE; + music_stop(); + } - gamemenu_get_music(); - return; - } + gamemenu_get_music(); + return; + } - if (gbMusicOn) { - gamemenu_get_music(); - return; - } + if (gbMusicOn) { + gamemenu_get_music(); + return; + } - gbMusicOn = TRUE; - music_start(leveltype); - gamemenu_get_music(); + gbMusicOn = TRUE; + music_start(leveltype); + gamemenu_get_music(); } int __fastcall gamemenu_slider_music_sound(TMenuItem *menu_item) { - return gmenu_slider_get(menu_item, VOLUME_MIN, VOLUME_MAX); + return gmenu_slider_get(menu_item, VOLUME_MIN, VOLUME_MAX); } void __fastcall gamemenu_sound_volume(int volume) { - if (volume) { - if (gbSoundOn) { - gbSoundOn = FALSE; - FreeMonsterSnd(); - sound_get_or_set_sound_volume(VOLUME_MIN); - } else { - gbSoundOn = TRUE; - sound_get_or_set_sound_volume(VOLUME_MAX); - } - } else { - volume = gamemenu_slider_music_sound(&sgOptionMenu[1]); - sound_get_or_set_sound_volume(volume); - if (volume == VOLUME_MIN) { - if (gbSoundOn) { - gbSoundOn = FALSE; - FreeMonsterSnd(); - } - } else if (!gbSoundOn) { - gbSoundOn = TRUE; - } - } - PlaySFX(IS_TITLEMOV); - gamemenu_get_sound(); + if (volume) { + if (gbSoundOn) { + gbSoundOn = FALSE; + FreeMonsterSnd(); + sound_get_or_set_sound_volume(VOLUME_MIN); + } else { + gbSoundOn = TRUE; + sound_get_or_set_sound_volume(VOLUME_MAX); + } + } else { + volume = gamemenu_slider_music_sound(&sgOptionMenu[1]); + sound_get_or_set_sound_volume(volume); + if (volume == VOLUME_MIN) { + if (gbSoundOn) { + gbSoundOn = FALSE; + FreeMonsterSnd(); + } + } else if (!gbSoundOn) { + gbSoundOn = TRUE; + } + } + PlaySFX(IS_TITLEMOV); + gamemenu_get_sound(); } void __fastcall gamemenu_gamma(int gamma) { - if (gamma) { - if (UpdateGamma(0) == 30) - gamma = 100; - else - gamma = 30; - } else { - gamma = gamemenu_slider_gamma(); - } + if (gamma) { + if (UpdateGamma(0) == 30) + gamma = 100; + else + gamma = 30; + } else { + gamma = gamemenu_slider_gamma(); + } - UpdateGamma(gamma); - gamemenu_get_gamma(); + UpdateGamma(gamma); + gamemenu_get_gamma(); } int __cdecl gamemenu_slider_gamma() { - return gmenu_slider_get(&sgOptionMenu[2], 30, 100); + return gmenu_slider_get(&sgOptionMenu[2], 30, 100); } void __cdecl gamemenu_color_cycling() { - palette_set_color_cycling(palette_get_colour_cycling() == 0); - sgOptionMenu[3].pszStr = color_cycling_toggle_names[palette_get_colour_cycling() & 1]; + palette_set_color_cycling(palette_get_colour_cycling() == 0); + sgOptionMenu[3].pszStr = color_cycling_toggle_names[palette_get_colour_cycling() & 1]; } diff --git a/Source/gendung.cpp b/Source/gendung.cpp index 13208d14..3d60b806 100644 --- a/Source/gendung.cpp +++ b/Source/gendung.cpp @@ -72,268 +72,229 @@ short dpiece_defs_map_2[16][MAXDUNX][MAXDUNY]; void __cdecl FillSolidBlockTbls() { unsigned char *v0; // eax - char *v1; // ecx + char *v1; // ecx unsigned char *v2; // esi - int v3; // edx - unsigned char v4; // bl - int size; // [esp+8h] [ebp-4h] + int v3; // edx + unsigned char v4; // bl + int size; // [esp+8h] [ebp-4h] memset(nBlockTable, 0, sizeof(nBlockTable)); memset(nSolidTable, 0, sizeof(nSolidTable)); memset(nTransTable, 0, sizeof(nTransTable)); memset(nMissileTable, 0, sizeof(nMissileTable)); memset(nTrapTable, 0, sizeof(nTrapTable)); - if ( leveltype != DTYPE_TOWN ) - { - switch ( leveltype ) - { - case DTYPE_CATHEDRAL: - v1 = "Levels\\L1Data\\L1.SOL"; - break; - case DTYPE_CATACOMBS: - v1 = "Levels\\L2Data\\L2.SOL"; - break; - case DTYPE_CAVES: - v1 = "Levels\\L3Data\\L3.SOL"; - break; - case DTYPE_HELL: - v1 = "Levels\\L4Data\\L4.SOL"; - break; - default: - TermMsg("FillSolidBlockTbls"); - // v0 = (unsigned char *)size; /* check error */ - goto LABEL_13; + if (leveltype != DTYPE_TOWN) { + switch (leveltype) { + case DTYPE_CATHEDRAL: + v1 = "Levels\\L1Data\\L1.SOL"; + break; + case DTYPE_CATACOMBS: + v1 = "Levels\\L2Data\\L2.SOL"; + break; + case DTYPE_CAVES: + v1 = "Levels\\L3Data\\L3.SOL"; + break; + case DTYPE_HELL: + v1 = "Levels\\L4Data\\L4.SOL"; + break; + default: + TermMsg("FillSolidBlockTbls"); + // v0 = (unsigned char *)size; /* check error */ + goto LABEL_13; } - } - else - { + } else { v1 = "Levels\\TownData\\Town.SOL"; } v0 = LoadFileInMem(v1, &size); LABEL_13: v2 = v0; - if ( (unsigned int)size >= 1 ) - { + if ((unsigned int)size >= 1) { v3 = 0; - do - { + do { v4 = *v2++; - if ( v4 & 1 ) + if (v4 & 1) nSolidTable[v3 + 1] = 1; - if ( v4 & 2 ) + if (v4 & 2) nBlockTable[v3 + 1] = 1; - if ( v4 & 4 ) + if (v4 & 4) nMissileTable[v3 + 1] = 1; - if ( v4 & 8 ) + if (v4 & 8) nTransTable[v3 + 1] = 1; - if ( (v4 & 0x80u) != 0 ) + if ((v4 & 0x80u) != 0) nTrapTable[v3 + 1] = 1; block_lvid[v3++ + 1] = (v4 >> 4) & 7; - } - while ( v3 + 1 <= (unsigned int)size ); + } while (v3 + 1 <= (unsigned int)size); } mem_free_dbg(v0); } void __cdecl gendung_418D91() { - signed int v0; // edx - short (*v1)[112][112]; // edi - short (*v2)[112][112]; // esi - signed int v3; // ebx - int i; // edx - short v5; // ax - int v6; // ecx - signed int v7; // edx - int v8; // eax - int v9; // edi - char *v10; // esi - int j; // ecx - unsigned char v12; // al - unsigned char *v13; // esi - int v14; // ecx - signed int v15; // edx - int v16; // eax - int v17; // ecx - unsigned char v18; // al - signed int v19; // ecx - int v20; // edi - int v21; // edx - int v22; // edi - int v23; // eax - int v24; // eax - bool v25; // zf - int v26; // edx - char *v27; // esi - char *v28; // edi - int k; // ecx - char *v33; // esi - char *v34; // edi - int v36; // ecx - signed int v37; // edx - int v38; // eax - int v39; // ecx - short (*v42)[112][112]; // esi - short v43; // ax - unsigned short v44; // dx - short v45; // ax - int v46; // [esp-4h] [ebp-38h] - int v47; // [esp-4h] [ebp-38h] - int v48; // [esp+Ch] [ebp-28h] - int (*v49)[128]; // [esp+10h] [ebp-24h] - int (*v50)[112]; // [esp+10h] [ebp-24h] - int v51; // [esp+14h] [ebp-20h] - short (*v52)[112][112]; // [esp+14h] [ebp-20h] - signed int v53; // [esp+18h] [ebp-1Ch] - int v54; // [esp+18h] [ebp-1Ch] - short (*v55)[112][112]; // [esp+18h] [ebp-1Ch] - int v56; // [esp+1Ch] [ebp-18h] - int (*v57)[112]; // [esp+1Ch] [ebp-18h] - signed int v58; // [esp+20h] [ebp-14h] - int v59; // [esp+20h] [ebp-14h] - int v60; // [esp+24h] [ebp-10h] - signed int v61; // [esp+24h] [ebp-10h] - int v62; // [esp+28h] [ebp-Ch] - int v63; // [esp+2Ch] [ebp-8h] - signed int v64; // [esp+30h] [ebp-4h] - signed int v65; // [esp+30h] [ebp-4h] + signed int v0; // edx + short(*v1)[112][112]; // edi + short(*v2)[112][112]; // esi + signed int v3; // ebx + int i; // edx + short v5; // ax + int v6; // ecx + signed int v7; // edx + int v8; // eax + int v9; // edi + char *v10; // esi + int j; // ecx + unsigned char v12; // al + unsigned char *v13; // esi + int v14; // ecx + signed int v15; // edx + int v16; // eax + int v17; // ecx + unsigned char v18; // al + signed int v19; // ecx + int v20; // edi + int v21; // edx + int v22; // edi + int v23; // eax + int v24; // eax + bool v25; // zf + int v26; // edx + char *v27; // esi + char *v28; // edi + int k; // ecx + char *v33; // esi + char *v34; // edi + int v36; // ecx + signed int v37; // edx + int v38; // eax + int v39; // ecx + short(*v42)[112][112]; // esi + short v43; // ax + unsigned short v44; // dx + short v45; // ax + int v46; // [esp-4h] [ebp-38h] + int v47; // [esp-4h] [ebp-38h] + int v48; // [esp+Ch] [ebp-28h] + int(*v49)[128]; // [esp+10h] [ebp-24h] + int(*v50)[112]; // [esp+10h] [ebp-24h] + int v51; // [esp+14h] [ebp-20h] + short(*v52)[112][112]; // [esp+14h] [ebp-20h] + signed int v53; // [esp+18h] [ebp-1Ch] + int v54; // [esp+18h] [ebp-1Ch] + short(*v55)[112][112]; // [esp+18h] [ebp-1Ch] + int v56; // [esp+1Ch] [ebp-18h] + int(*v57)[112]; // [esp+1Ch] [ebp-18h] + signed int v58; // [esp+20h] [ebp-14h] + int v59; // [esp+20h] [ebp-14h] + int v60; // [esp+24h] [ebp-10h] + signed int v61; // [esp+24h] [ebp-10h] + int v62; // [esp+28h] [ebp-Ch] + int v63; // [esp+2Ch] [ebp-8h] + signed int v64; // [esp+30h] [ebp-4h] + signed int v65; // [esp+30h] [ebp-4h] int _EAX; char *_EBX; v0 = 0; memset(level_frame_types, 0, sizeof(level_frame_types)); memset(level_frame_count, 0, sizeof(level_frame_count)); - do - { + do { tile_defs[v0] = v0; ++v0; - } - while ( v0 < 2048 ); + } while (v0 < 2048); v1 = dpiece_defs_map_2; v48 = 2 * (leveltype == DTYPE_HELL) + 10; - do - { + do { v2 = v1; v3 = 112; - do - { - for ( i = 0; i < v48; ++i ) - { + do { + for (i = 0; i < v48; ++i) { v5 = (*v2)[0][i]; - if ( (*v2)[0][i] ) - { + if ((*v2)[0][i]) { v6 = v5 & 0xFFF; ++level_frame_count[v6]; level_frame_types[v6] = v5 & 0x7000; } } - v2 = (short (*)[112][112])((char *)v2 + 3584); + v2 = (short(*)[112][112])((char *)v2 + 3584); --v3; - } - while ( v3 ); - v1 = (short (*)[112][112])((char *)v1 + 32); - } - while ( (signed int)v1 < (signed int)dpiece_defs_map_2[0][16] ); /* check */ + } while (v3); + v1 = (short(*)[112][112])((char *)v1 + 32); + } while ((signed int)v1 < (signed int)dpiece_defs_map_2[0][16]); /* check */ v7 = 1; nlevel_frames = *(_DWORD *)pDungeonCels & 0xFFFF; v8 = nlevel_frames; - if ( nlevel_frames > 1 ) - { - do - { + if (nlevel_frames > 1) { + do { level_frame_sizes[v7] = (*((_DWORD *)pDungeonCels + v7 + 1) - *((_DWORD *)pDungeonCels + v7)) & 0xFFFF; v8 = nlevel_frames; ++v7; - } - while ( v7 < nlevel_frames ); + } while (v7 < nlevel_frames); } v9 = 0; level_frame_sizes[0] = 0; - if ( leveltype == DTYPE_HELL && v8 > 0 ) - { - do - { - if ( !v9 ) + if (leveltype == DTYPE_HELL && v8 > 0) { + do { + if (!v9) level_frame_count[0] = 0; v53 = 1; - if ( level_frame_count[v9] ) - { - if ( level_frame_types[v9] == 4096 ) - { + if (level_frame_count[v9]) { + if (level_frame_types[v9] == 4096) { v13 = (unsigned char *)pDungeonCels + *((_DWORD *)pDungeonCels + v9); v14 = 32; - do - { + do { v46 = v14; v15 = 32; - do - { - while ( 1 ) - { + do { + while (1) { v16 = *v13++; - if ( (v16 & 0x80u) == 0 ) + if ((v16 & 0x80u) == 0) break; _LOBYTE(v16) = -(char)v16; v15 -= v16; - if ( !v15 ) + if (!v15) goto LABEL_36; } v15 -= v16; v17 = v16; - do - { + do { v18 = *v13++; - if ( v18 && v18 < 0x20u ) + if (v18 && v18 < 0x20u) v53 = 0; --v17; - } - while ( v17 ); - } - while ( v15 ); -LABEL_36: + } while (v17); + } while (v15); + LABEL_36: v14 = v46 - 1; - } - while ( v46 != 1 ); - } - else - { + } while (v46 != 1); + } else { v10 = (char *)pDungeonCels + *((_DWORD *)pDungeonCels + v9); - for ( j = level_frame_sizes[v9]; j; --j ) - { + for (j = level_frame_sizes[v9]; j; --j) { v12 = *v10++; - if ( v12 && v12 < 0x20u ) + if (v12 && v12 < 0x20u) v53 = 0; } } - if ( !v53 ) + if (!v53) level_frame_count[v9] = 0; } ++v9; - } - while ( v9 < nlevel_frames ); + } while (v9 < nlevel_frames); } gendung_4191BF(2047); v19 = 0; v20 = 0; - if ( light4flag ) - { - do - { + if (light4flag) { + do { v21 = level_frame_sizes[v20++]; v19 += 2 * v21; - } - while ( v19 < 0x100000 ); - } - else - { + } while (v19 < 0x100000); + } else { do v19 += 14 * level_frame_sizes[v20++]; - while ( v19 < 0x100000 ); + while (v19 < 0x100000); } v22 = v20 - 1; v58 = v22; - if ( v22 > 128 ) - { + if (v22 > 128) { v58 = 128; v22 = 128; } @@ -342,171 +303,136 @@ LABEL_36: _LOBYTE(v23) = v23 & 0xF4; v54 = 0; v60 = v23 + 15; - if ( v22 > 0 ) - { + if (v22 > 0) { v56 = 0; v49 = speed_cel_frame_num_from_light_index_frame_num; - do - { + do { v24 = v54; v25 = level_frame_types[v54] == 4096; v62 = tile_defs[v54]; (*v49)[0] = v62; - if ( v25 ) - { + if (v25) { v65 = 1; - if ( v60 > 1 ) - { - do - { + if (v60 > 1) { + do { speed_cel_frame_num_from_light_index_frame_num[0][v65 + v56] = v63; v33 = (char *)pDungeonCels + *((_DWORD *)pDungeonCels + v62); v34 = (char *)pSpeedCels + v63; _EBX = &pLightTbl[256 * v65]; v36 = 32; - do - { + do { v47 = v36; v37 = 32; - do - { - while ( 1 ) - { + do { + while (1) { v38 = (unsigned char)*v33++; *v34++ = v38; - if ( (v38 & 0x80u) == 0 ) + if ((v38 & 0x80u) == 0) break; _LOBYTE(v38) = -(char)v38; v37 -= v38; - if ( !v37 ) + if (!v37) goto LABEL_63; } v37 -= v38; v39 = v38; - do - { + do { _EAX = *v33++; - ASM_XLAT(_EAX,_EBX); + ASM_XLAT(_EAX, _EBX); *v34++ = _EAX; --v39; - } - while ( v39 ); - } - while ( v37 ); -LABEL_63: + } while (v39); + } while (v37); + LABEL_63: v36 = v47 - 1; - } - while ( v47 != 1 ); + } while (v47 != 1); v63 += level_frame_sizes[v54]; ++v65; - } - while ( v65 < v60 ); + } while (v65 < v60); goto LABEL_65; } - } - else - { + } else { v26 = level_frame_sizes[v24]; v51 = level_frame_sizes[v24]; v64 = 1; - if ( v60 > 1 ) - { - do - { + if (v60 > 1) { + do { speed_cel_frame_num_from_light_index_frame_num[0][v64 + v56] = v63; v27 = (char *)pDungeonCels + *((_DWORD *)pDungeonCels + v62); v28 = (char *)pSpeedCels + v63; _EBX = &pLightTbl[256 * v64]; - for ( k = v51; k; --k ) - { + for (k = v51; k; --k) { _EAX = *v27++; - ASM_XLAT(_EAX,_EBX); + ASM_XLAT(_EAX, _EBX); *v28++ = _EAX; } v63 += v26; ++v64; - } - while ( v64 < v60 ); -LABEL_65: + } while (v64 < v60); + LABEL_65: v22 = v58; goto LABEL_66; } } -LABEL_66: + LABEL_66: ++v54; - v49 = (int (*)[128])((char *)v49 + 64); + v49 = (int(*)[128])((char *)v49 + 64); v56 += 16; - } - while ( v54 < v22 ); + } while (v54 < v22); } v57 = dPiece; v55 = dpiece_defs_map_2; - do - { + do { v61 = 112; v52 = v55; v50 = v57; - do - { - if ( (*v50)[0] && v48 > 0 ) - { + do { + if ((*v50)[0] && v48 > 0) { v42 = v52; v59 = v48; - do - { + do { v43 = *(_WORD *)v42; - if ( *(_WORD *)v42 ) - { + if (*(_WORD *)v42) { v44 = 0; - if ( v22 > 0 ) - { - do - { - if ( (v43 & 0xFFF) == tile_defs[v44] ) - { + if (v22 > 0) { + do { + if ((v43 & 0xFFF) == tile_defs[v44]) { v45 = v44 + level_frame_types[v44]; v44 = v22; v43 = v45 + -32768; } ++v44; - } - while ( v44 < v22 ); + } while (v44 < v22); *(_WORD *)v42 = v43; } } - v42 = (short (*)[112][112])((char *)v42 + 2); + v42 = (short(*)[112][112])((char *)v42 + 2); --v59; - } - while ( v59 ); + } while (v59); } ++v50; - v52 = (short (*)[112][112])((char *)v52 + 3584); + v52 = (short(*)[112][112])((char *)v52 + 3584); --v61; - } - while ( v61 ); - v55 = (short (*)[112][112])((char *)v55 + 32); - v57 = (int (*)[112])((char *)v57 + 4); - } - while ( (signed int)v55 < (signed int)dpiece_defs_map_2[0][16] ); /* check */ + } while (v61); + v55 = (short(*)[112][112])((char *)v55 + 32); + v57 = (int(*)[112])((char *)v57 + 4); + } while ((signed int)v55 < (signed int)dpiece_defs_map_2[0][16]); /* check */ } // 525728: using guessed type int light4flag; // 53CD4C: using guessed type int nlevel_frames; void __fastcall gendung_4191BF(int frames) { - int v1; // edi + int v1; // edi signed int v2; // eax - int i; // esi + int i; // esi v1 = frames; v2 = 0; - while ( v1 > 0 && !v2 ) - { + while (v1 > 0 && !v2) { v2 = 1; - for ( i = 0; i < v1; ++i ) - { - if ( level_frame_count[i] < level_frame_count[i + 1] ) - { + for (i = 0; i < v1; ++i) { + if (level_frame_count[i] < level_frame_count[i + 1]) { gendung_4191FB(i, i + 1); v2 = 0; } @@ -517,15 +443,15 @@ void __fastcall gendung_4191BF(int frames) void __fastcall gendung_4191FB(int a1, int a2) { - int v2; // esi - int *v3; // edi + int v2; // esi + int *v3; // edi short *v4; // edx - int v5; // ST10_4 - int *v6; // edi - int *v7; // eax - int v8; // ST10_4 + int v5; // ST10_4 + int *v6; // edi + int *v7; // eax + int v8; // ST10_4 short *v9; // ecx - int v10; // edx + int v10; // edx v2 = a2; v3 = &level_frame_count[a1]; @@ -552,7 +478,7 @@ int __fastcall gendung_get_dpiece_num_from_coord(int x, int y) { __int64 v3; // rax - if ( x < 112 - y ) + if (x < 112 - y) return (y * (y + 1) + x * (x + 2 * y + 3)) / 2; v3 = (111 - y) * (111 - y + 1) + (111 - x) * (111 - x + 2 * (111 - y) + 3); return 12543 - (((signed int)v3 - HIDWORD(v3)) >> 1); @@ -560,103 +486,85 @@ int __fastcall gendung_get_dpiece_num_from_coord(int x, int y) void __cdecl gendung_4192C2() { - short (*v0)[112][112]; // ebx - int v1; // ebp - short (*v2)[112][112]; // esi - char *v3; // edi - int x; // [esp+10h] [ebp-4h] + short(*v0)[112][112]; // ebx + int v1; // ebp + short(*v2)[112][112]; // esi + char *v3; // edi + int x; // [esp+10h] [ebp-4h] x = 0; v0 = dpiece_defs_map_2; - do - { + do { v1 = 0; - do - { + do { v2 = v0; v3 = (char *)dpiece_defs_map_1 + 32 * gendung_get_dpiece_num_from_coord(x, v1++); - v0 = (short (*)[112][112])((char *)v0 + 32); + v0 = (short(*)[112][112])((char *)v0 + 32); qmemcpy(v3, v2, 0x20u); - } - while ( v1 < 112 ); + } while (v1 < 112); ++x; - } - while ( (signed int)v0 < (signed int)&dpiece_defs_map_2[16][0][0] ); + } while ((signed int)v0 < (signed int)&dpiece_defs_map_2[16][0][0]); } void __cdecl SetDungeonMicros() { - signed int v0; // esi - short (*v1)[112][112]; // edx - int (*v2)[112]; // ebp - int v3; // eax - char *v4; // eax - signed int i; // ecx - _WORD *v6; // edi - int j; // ecx - short (*v8)[112][112]; // [esp+8h] [ebp-Ch] - int (*v9)[112]; // [esp+Ch] [ebp-8h] - signed int v10; // [esp+10h] [ebp-4h] + signed int v0; // esi + short(*v1)[112][112]; // edx + int(*v2)[112]; // ebp + int v3; // eax + char *v4; // eax + signed int i; // ecx + _WORD *v6; // edi + int j; // ecx + short(*v8)[112][112]; // [esp+8h] [ebp-Ch] + int(*v9)[112]; // [esp+Ch] [ebp-8h] + signed int v10; // [esp+10h] [ebp-4h] - if ( leveltype == DTYPE_HELL ) - { + if (leveltype == DTYPE_HELL) { dword_5A5594 = 12; v0 = 16; - } - else - { + } else { dword_5A5594 = 10; v0 = 10; } v9 = dPiece; v8 = dpiece_defs_map_2; - do - { + do { v1 = v8; v2 = v9; v10 = 112; - do - { - if ( (*v2)[0] ) - { + do { + if ((*v2)[0]) { v3 = (*v2)[0] - 1; - if ( leveltype == DTYPE_HELL ) + if (leveltype == DTYPE_HELL) v4 = (char *)pLevelPieces + 32 * v3; else v4 = (char *)pLevelPieces + 20 * v3; - for ( i = 0; i < v0; ++i ) + for (i = 0; i < v0; ++i) (*v1)[0][i] = *(_WORD *)&v4[2 * (v0 + (i & 1) - (i & 0xE)) - 4]; - } - else if ( v0 > 0 ) - { + } else if (v0 > 0) { memset(v1, 0, 4 * ((unsigned int)v0 >> 1)); v6 = (_WORD *)((char *)v1 + 4 * ((unsigned int)v0 >> 1)); - for ( j = v0 & 1; j; --j ) - { + for (j = v0 & 1; j; --j) { *v6 = 0; ++v6; } } ++v2; - v1 = (short (*)[112][112])((char *)v1 + 3584); + v1 = (short(*)[112][112])((char *)v1 + 3584); --v10; - } - while ( v10 ); - v8 = (short (*)[112][112])((char *)v8 + 32); - v9 = (int (*)[112])((char *)v9 + 4); - } - while ( (signed int)v8 < (signed int)dpiece_defs_map_2[0][16] ); /* check */ + } while (v10); + v8 = (short(*)[112][112])((char *)v8 + 32); + v9 = (int(*)[112])((char *)v9 + 4); + } while ((signed int)v8 < (signed int)dpiece_defs_map_2[0][16]); /* check */ gendung_418D91(); gendung_4192C2(); - if ( zoomflag ) - { + if (zoomflag) { scr_pix_width = 640; scr_pix_height = 352; dword_5C2FF8 = 10; dword_5C2FFC = 11; - } - else - { + } else { scr_pix_width = 384; scr_pix_height = 224; dword_5C2FF8 = 6; @@ -679,29 +587,25 @@ void __cdecl DRLG_InitTrans() void __fastcall DRLG_MRectTrans(int x1, int y1, int x2, int y2) { - int v4; // esi - int v5; // edi - int i; // eax - char *v7; // edx - int j; // ecx + int v4; // esi + int v5; // edi + int i; // eax + char *v7; // edx + int j; // ecx int ty_enda; // [esp+10h] [ebp+8h] v4 = 2 * x1 + 17; v5 = 2 * x2 + 16; i = 2 * y1 + 17; - for ( ty_enda = 2 * y2 + 16; i <= ty_enda; ++i ) - { - if ( v4 <= v5 ) - { + for (ty_enda = 2 * y2 + 16; i <= ty_enda; ++i) { + if (v4 <= v5) { v7 = &dung_map[v4][i]; j = v5 - v4 + 1; - do - { + do { *v7 = TransVal; v7 += 112; --j; - } - while ( j ); + } while (j); } } ++TransVal; @@ -710,23 +614,19 @@ void __fastcall DRLG_MRectTrans(int x1, int y1, int x2, int y2) void __fastcall DRLG_RectTrans(int x1, int y1, int x2, int y2) { - int i; // esi + int i; // esi char *v5; // edx - int j; // eax + int j; // eax - for ( i = y1; i <= y2; ++i ) - { - if ( x1 <= x2 ) - { + for (i = y1; i <= y2; ++i) { + if (x1 <= x2) { v5 = &dung_map[x1][i]; j = x2 - x1 + 1; - do - { + do { *v5 = TransVal; v5 += 112; --j; - } - while ( j ); + } while (j); } } ++TransVal; @@ -741,19 +641,17 @@ void __fastcall DRLG_CopyTrans(int sx, int sy, int dx, int dy) void __fastcall DRLG_ListTrans(int num, unsigned char *List) { unsigned char *v2; // esi - int v3; // edi - unsigned char v4; // al + int v3; // edi + unsigned char v4; // al unsigned char *v5; // esi - unsigned char v6; // cl - unsigned char v7; // dl - unsigned char v8; // bl + unsigned char v6; // cl + unsigned char v7; // dl + unsigned char v8; // bl v2 = List; - if ( num > 0 ) - { + if (num > 0) { v3 = num; - do - { + do { v4 = *v2; v5 = v2 + 1; v6 = *v5++; @@ -762,27 +660,24 @@ void __fastcall DRLG_ListTrans(int num, unsigned char *List) v2 = v5 + 1; DRLG_RectTrans(v4, v6, v7, v8); --v3; - } - while ( v3 ); + } while (v3); } } void __fastcall DRLG_AreaTrans(int num, unsigned char *List) { unsigned char *v2; // esi - int v3; // edi - unsigned char v4; // al + int v3; // edi + unsigned char v4; // al unsigned char *v5; // esi - unsigned char v6; // cl - unsigned char v7; // dl - unsigned char v8; // bl + unsigned char v6; // cl + unsigned char v7; // dl + unsigned char v8; // bl v2 = List; - if ( num > 0 ) - { + if (num > 0) { v3 = num; - do - { + do { v4 = *v2; v5 = v2 + 1; v6 = *v5++; @@ -792,8 +687,7 @@ void __fastcall DRLG_AreaTrans(int num, unsigned char *List) DRLG_RectTrans(v4, v6, v7, v8); --TransVal; --v3; - } - while ( v3 ); + } while (v3); } ++TransVal; } @@ -811,31 +705,27 @@ void __cdecl DRLG_InitSetPC() void __cdecl DRLG_SetPC() { - int v0; // ebx - int v1; // edx - int v2; // ecx - int v3; // esi - int i; // eax - int v5; // ebp + int v0; // ebx + int v1; // edx + int v2; // ecx + int v3; // esi + int i; // eax + int v5; // ebp char *v6; // edi v0 = 0; v1 = 2 * setpc_w; v2 = 2 * setpc_h; v3 = 2 * setpc_x + 16; - for ( i = 2 * setpc_y + 16; v0 < v2; ++v0 ) - { - if ( v1 > 0 ) - { + for (i = 2 * setpc_y + 16; v0 < v2; ++v0) { + if (v1 > 0) { v5 = v1; v6 = &dFlags[v3][v0 + i]; - do - { + do { *v6 |= DFLAG_POPULATED; v6 += 112; --v5; - } - while ( v5 ); + } while (v5); } } } @@ -844,60 +734,56 @@ void __cdecl DRLG_SetPC() void __fastcall Make_SetPC(int x, int y, int w, int h) { - int v4; // eax - int v5; // esi - int v6; // ebx - int i; // eax - int v8; // edx + int v4; // eax + int v5; // esi + int v6; // ebx + int i; // eax + int v8; // edx char *v9; // ecx - int wa; // [esp+14h] [ebp+8h] + int wa; // [esp+14h] [ebp+8h] v4 = w; wa = 0; v5 = 2 * v4; v6 = 2 * x + 16; - for ( i = 2 * y + 16; wa < 2 * h; ++wa ) - { - if ( v5 > 0 ) - { + for (i = 2 * y + 16; wa < 2 * h; ++wa) { + if (v5 > 0) { v8 = v5; v9 = &dFlags[v6][wa + i]; - do - { + do { *v9 |= DFLAG_POPULATED; v9 += 112; --v8; - } - while ( v8 ); + } while (v8); } } } bool __fastcall DRLG_WillThemeRoomFit(int floor, int x, int y, int minSize, int maxSize, int *width, int *height) { - int v7; // esi - int v8; // edi - int v10; // ebx - int v11; // edx + int v7; // esi + int v8; // edi + int v10; // ebx + int v11; // edx unsigned char *v12; // eax - int v13; // eax - int i; // eax - int v15; // eax - int v16; // esi - int v17; // eax - int v18; // edx - int v19; // ecx - int v21; // eax - int v22; // esi - int yArray[20]; // [esp+8h] [ebp-BCh] - int xArray[20]; // [esp+58h] [ebp-6Ch] - int v25; // [esp+A8h] [ebp-1Ch] - int v26; // [esp+ACh] [ebp-18h] - int v27; // [esp+B0h] [ebp-14h] - int v28; // [esp+B4h] [ebp-10h] - char *v29; // [esp+B8h] [ebp-Ch] - int v30; // [esp+BCh] [ebp-8h] - int v31; // [esp+C0h] [ebp-4h] + int v13; // eax + int i; // eax + int v15; // eax + int v16; // esi + int v17; // eax + int v18; // edx + int v19; // ecx + int v21; // eax + int v22; // esi + int yArray[20]; // [esp+8h] [ebp-BCh] + int xArray[20]; // [esp+58h] [ebp-6Ch] + int v25; // [esp+A8h] [ebp-1Ch] + int v26; // [esp+ACh] [ebp-18h] + int v27; // [esp+B0h] [ebp-14h] + int v28; // [esp+B4h] [ebp-10h] + char *v29; // [esp+B8h] [ebp-Ch] + int v30; // [esp+BCh] [ebp-8h] + int v31; // [esp+C0h] [ebp-4h] v28 = 1; v27 = 1; @@ -906,67 +792,51 @@ bool __fastcall DRLG_WillThemeRoomFit(int floor, int x, int y, int minSize, int v25 = floor; v31 = 0; v30 = 0; - if ( x > 40 - maxSize && y > 40 - maxSize ) + if (x > 40 - maxSize && y > 40 - maxSize) return 0; - if ( !SkipThemeRoom(x, y) ) + if (!SkipThemeRoom(x, y)) return 0; memset(xArray, 0, sizeof(xArray)); memset(yArray, 0, sizeof(yArray)); - if ( maxSize > 0 ) - { + if (maxSize > 0) { v10 = 40 * v7; v26 = 40 * v7; v29 = dungeon[v7]; - do - { - if ( v27 ) - { + do { + if (v27) { v11 = v7; - if ( v7 < v7 + maxSize ) - { + if (v7 < v7 + maxSize) { v12 = (unsigned char *)dungeon + v8 + v10 + y; - do - { - if ( *v12 == v25 ) - { + do { + if (*v12 == v25) { ++v31; - } - else - { - if ( v11 >= minSize ) + } else { + if (v11 >= minSize) break; v27 = 0; } ++v11; v12 += 40; - } - while ( v11 < v7 + maxSize ); + } while (v11 < v7 + maxSize); v10 = v26; } - if ( v27 ) - { + if (v27) { v13 = v31; v31 = 0; xArray[v8] = v13; } } - if ( v28 ) - { - for ( i = y; i < y + maxSize; ++i ) - { - if ( (unsigned char)v29[i] == v25 ) - { + if (v28) { + for (i = y; i < y + maxSize; ++i) { + if ((unsigned char)v29[i] == v25) { ++v30; - } - else - { - if ( i >= minSize ) + } else { + if (i >= minSize) break; v28 = 0; } } - if ( v28 ) - { + if (v28) { v15 = v30; v30 = 0; yArray[v8] = v15; @@ -974,17 +844,14 @@ bool __fastcall DRLG_WillThemeRoomFit(int floor, int x, int y, int minSize, int } v29 += 40; ++v8; - } - while ( v8 < maxSize ); + } while (v8 < maxSize); v8 = 0; } v16 = minSize; v17 = 0; - if ( minSize > 0 ) - { - while ( xArray[v17] >= minSize && yArray[v17] >= minSize ) - { - if ( ++v17 >= minSize ) + if (minSize > 0) { + while (xArray[v17] >= minSize && yArray[v17] >= minSize) { + if (++v17 >= minSize) goto LABEL_32; } return 0; @@ -992,21 +859,19 @@ bool __fastcall DRLG_WillThemeRoomFit(int floor, int x, int y, int minSize, int LABEL_32: v18 = xArray[0]; v19 = yArray[0]; - if ( maxSize > 0 ) - { - while ( 1 ) - { + if (maxSize > 0) { + while (1) { v21 = xArray[v8]; - if ( v21 < v16 ) + if (v21 < v16) break; v22 = yArray[v8]; - if ( v22 < minSize ) + if (v22 < minSize) break; - if ( v21 < v18 ) + if (v21 < v18) v18 = xArray[v8]; - if ( v22 < v19 ) + if (v22 < v19) v19 = yArray[v8]; - if ( ++v8 >= maxSize ) + if (++v8 >= maxSize) break; v16 = minSize; } @@ -1020,26 +885,26 @@ LABEL_32: void __fastcall DRLG_CreateThemeRoom(int themeIndex) { - int v1; // esi - int v2; // eax - int v3; // edi - int v4; // ebx - int v5; // ecx - int v6; // ecx - int v7; // ebx - int v8; // edx - int v9; // ebx - int v10; // edx - int v11; // ebx - int v12; // edx - int v13; // eax - int v14; // eax - int v15; // eax - int v16; // ecx + int v1; // esi + int v2; // eax + int v3; // edi + int v4; // ebx + int v5; // ecx + int v6; // ecx + int v7; // ebx + int v8; // edx + int v9; // ebx + int v10; // edx + int v11; // ebx + int v12; // edx + int v13; // eax + int v14; // eax + int v15; // eax + int v16; // ecx char *v17; // eax - int v18; // ecx + int v18; // ecx char *v19; // eax - int v20; // [esp+Ch] [ebp-8h] + int v20; // [esp+Ch] [ebp-8h] char *v21; // [esp+10h] [ebp-4h] v1 = themeIndex; @@ -1047,186 +912,156 @@ void __fastcall DRLG_CreateThemeRoom(int themeIndex) v3 = themeLoc[themeIndex].height; v4 = v2; v5 = v3 + v2; - if ( v2 < v3 + v2 ) - { + if (v2 < v3 + v2) { v20 = themeLoc[v1].x + themeLoc[v1].width; - while ( 1 ) - { + while (1) { v6 = themeLoc[v1].x; - if ( v6 < v20 ) + if (v6 < v20) break; -LABEL_52: + LABEL_52: ++v4; v5 = v3 + v2; - if ( v4 >= v3 + v2 ) + if (v4 >= v3 + v2) goto LABEL_53; } v21 = &dungeon[v6][v4]; - while ( 1 ) - { - if ( leveltype != DTYPE_CATACOMBS ) + while (1) { + if (leveltype != DTYPE_CATACOMBS) goto LABEL_21; - if ( v4 == v2 && v6 >= themeLoc[v1].x && v6 <= v20 ) + if (v4 == v2 && v6 >= themeLoc[v1].x && v6 <= v20) goto LABEL_12; - if ( v4 != v3 + v2 - 1 ) + if (v4 != v3 + v2 - 1) goto LABEL_13; - if ( v6 >= themeLoc[v1].x ) + if (v6 >= themeLoc[v1].x) break; -LABEL_16: - if ( v6 == v20 - 1 && v4 >= v2 && v4 <= v3 + v2 ) + LABEL_16: + if (v6 == v20 - 1 && v4 >= v2 && v4 <= v3 + v2) goto LABEL_19; *v21 = 3; -LABEL_21: - if ( leveltype == DTYPE_CAVES ) - { - if ( v4 == v2 && v6 >= themeLoc[v1].x && v6 <= v20 ) - { -LABEL_28: + LABEL_21: + if (leveltype == DTYPE_CAVES) { + if (v4 == v2 && v6 >= themeLoc[v1].x && v6 <= v20) { + LABEL_28: *v21 = -122; goto LABEL_51; } - if ( v4 == v3 + v2 - 1 ) - { - if ( v6 >= themeLoc[v1].x ) - { - if ( v6 <= v20 ) + if (v4 == v3 + v2 - 1) { + if (v6 >= themeLoc[v1].x) { + if (v6 <= v20) goto LABEL_28; goto LABEL_29; } - } - else - { -LABEL_29: - if ( v6 == themeLoc[v1].x && v4 >= v2 && v4 <= v3 + v2 ) - { -LABEL_35: + } else { + LABEL_29: + if (v6 == themeLoc[v1].x && v4 >= v2 && v4 <= v3 + v2) { + LABEL_35: *v21 = -119; goto LABEL_51; } } - if ( v6 == v20 - 1 && v4 >= v2 && v4 <= v3 + v2 ) + if (v6 == v20 - 1 && v4 >= v2 && v4 <= v3 + v2) goto LABEL_35; *v21 = 7; } - if ( leveltype != DTYPE_HELL ) + if (leveltype != DTYPE_HELL) goto LABEL_51; - if ( v4 != v2 || v6 < themeLoc[v1].x || v6 > v20 ) - { - if ( v4 != v3 + v2 - 1 ) + if (v4 != v2 || v6 < themeLoc[v1].x || v6 > v20) { + if (v4 != v3 + v2 - 1) goto LABEL_44; - if ( v6 < themeLoc[v1].x ) + if (v6 < themeLoc[v1].x) goto LABEL_47; - if ( v6 > v20 ) - { -LABEL_44: - if ( v6 != themeLoc[v1].x || v4 < v2 || v4 > v3 + v2 ) - { -LABEL_47: - if ( v6 != v20 - 1 || v4 < v2 || v4 > v3 + v2 ) - { + if (v6 > v20) { + LABEL_44: + if (v6 != themeLoc[v1].x || v4 < v2 || v4 > v3 + v2) { + LABEL_47: + if (v6 != v20 - 1 || v4 < v2 || v4 > v3 + v2) { *v21 = 6; goto LABEL_51; } } -LABEL_19: + LABEL_19: *v21 = 1; goto LABEL_51; } } -LABEL_12: + LABEL_12: *v21 = 2; -LABEL_51: + LABEL_51: v21 += 40; - if ( ++v6 >= v20 ) + if (++v6 >= v20) goto LABEL_52; } - if ( v6 <= v20 ) + if (v6 <= v20) goto LABEL_12; -LABEL_13: - if ( v6 == themeLoc[v1].x && v4 >= v2 && v4 <= v3 + v2 ) + LABEL_13: + if (v6 == themeLoc[v1].x && v4 >= v2 && v4 <= v3 + v2) goto LABEL_19; goto LABEL_16; } LABEL_53: - if ( leveltype == DTYPE_CATACOMBS ) - { + if (leveltype == DTYPE_CATACOMBS) { v7 = themeLoc[v1].x; v8 = 10 * (v7 + themeLoc[v1].width); dungeon[v7][v2] = 8; v5 = v3 + 40 * v7; - dungeon[-1][v8 * 4 + v2] = 7; // *((_BYTE *)&dMonster[111][v8 + 102] + v2) = 7; /* check */ - dungeon[0][v5 + v2 - 1] = 9; // *((_BYTE *)&dMonster[111][111] + v5 + v2 + 3) = 9; + dungeon[-1][v8 * 4 + v2] = 7; // *((_BYTE *)&dMonster[111][v8 + 102] + v2) = 7; /* check */ + dungeon[0][v5 + v2 - 1] = 9; // *((_BYTE *)&dMonster[111][111] + v5 + v2 + 3) = 9; dungeon[-1][v3 + v8 * 4 + v2 - 1] = 6; // *((_BYTE *)&dMonster[111][101] + v3 + v8 * 4 + v2 + 3) = 6; } - if ( leveltype == DTYPE_CAVES ) - { + if (leveltype == DTYPE_CAVES) { v9 = themeLoc[v1].x; v10 = 10 * (v9 + themeLoc[v1].width); dungeon[v9][v2] = 150; v5 = v3 + 40 * v9; - dungeon[-1][v10 * 4 + v2] = 151; // *((_BYTE *)&dMonster[111][v10 + 102] + v2) = -105; - dungeon[0][v5 + v2 - 1] = 152; // *((_BYTE *)&dMonster[111][111] + v5 + v2 + 3) = -104; + dungeon[-1][v10 * 4 + v2] = 151; // *((_BYTE *)&dMonster[111][v10 + 102] + v2) = -105; + dungeon[0][v5 + v2 - 1] = 152; // *((_BYTE *)&dMonster[111][111] + v5 + v2 + 3) = -104; dungeon[-1][v3 + v10 * 4 + v2 - 1] = 138; // *((_BYTE *)&dMonster[111][101] + v3 + v10 * 4 + v2 + 3) = -118; } - if ( leveltype == DTYPE_HELL ) - { + if (leveltype == DTYPE_HELL) { v11 = themeLoc[v1].x; v12 = 10 * (v11 + themeLoc[v1].width); dungeon[v11][v2] = 9; v5 = v3 + 40 * v11; - dungeon[-1][v12 * 4 + v2] = 16; // *((_BYTE *)&dMonster[111][v12 + 102] + v2) = 16; - dungeon[0][v5 + v2 - 1] = 15; // *((_BYTE *)&dMonster[111][111] + v5 + v2 + 3) = 15; + dungeon[-1][v12 * 4 + v2] = 16; // *((_BYTE *)&dMonster[111][v12 + 102] + v2) = 16; + dungeon[0][v5 + v2 - 1] = 15; // *((_BYTE *)&dMonster[111][111] + v5 + v2 + 3) = 15; dungeon[-1][v3 + v12 * 4 + v2 - 1] = 12; // *((_BYTE *)&dMonster[111][101] + v3 + v12 * 4 + v2 + 3) = 12; } - if ( leveltype == DTYPE_CATACOMBS ) - { + if (leveltype == DTYPE_CATACOMBS) { v13 = random(0, 2); - if ( v13 ) - { - if ( v13 == 1 ) - { + if (v13) { + if (v13 == 1) { v5 = themeLoc[v1].height; dungeon[themeLoc[v1].x + themeLoc[v1].width / 2][themeLoc[v1].y + v5 - 1] = 5; /* *((_BYTE *)&dMonster[111][10 * (themeLoc[v1].x + themeLoc[v1].width / 2) + 111] + themeLoc[v1].y + v5 + 3) = 5; */ } - } - else - { + } else { v5 = themeLoc[v1].y; - dungeon[themeLoc[v1].x + themeLoc[v1].width -1][themeLoc[v1].height / 2 + v5] = 4; + dungeon[themeLoc[v1].x + themeLoc[v1].width - 1][themeLoc[v1].height / 2 + v5] = 4; // *((_BYTE *)&dMonster[111][10 * (themeLoc[v1].x + themeLoc[v1].width) + 102] + themeLoc[v1].height / 2 + v5) = 4; } } - if ( leveltype == DTYPE_CAVES ) - { + if (leveltype == DTYPE_CAVES) { v14 = random(0, 2); - if ( v14 ) - { - if ( v14 == 1 ) - { + if (v14) { + if (v14 == 1) { v5 = themeLoc[v1].height; dungeon[themeLoc[v1].x + themeLoc[v1].width / 2][themeLoc[v1].y + v5 - 1] = 146; /* *((_BYTE *)&dMonster[111][10 * (themeLoc[v1].x + themeLoc[v1].width / 2) + 111] + themeLoc[v1].y + v5 + 3) = -110; */ } - } - else - { + } else { v5 = themeLoc[v1].y; - dungeon[themeLoc[v1].x + themeLoc[v1].width -1][themeLoc[v1].height / 2 + v5] = 147; + dungeon[themeLoc[v1].x + themeLoc[v1].width - 1][themeLoc[v1].height / 2 + v5] = 147; // *((_BYTE *)&dMonster[111][10 * (themeLoc[v1].x + themeLoc[v1].width) + 102] + themeLoc[v1].height / 2 + v5) = -109; } } - if ( leveltype == DTYPE_HELL ) - { + if (leveltype == DTYPE_HELL) { v15 = random(0, 2); - if ( v15 ) - { - if ( v15 == 1 ) - { + if (v15) { + if (v15 == 1) { v16 = themeLoc[v1].y + 40 * (themeLoc[v1].x + themeLoc[v1].width / 2) + themeLoc[v1].height; v17 = (char *)dungeon + v16; *(v17 - 41) = 57; @@ -1235,9 +1070,7 @@ LABEL_53: *(v17 - 2) = 59; *(v17 - 42) = 58; } - } - else - { + } else { v18 = themeLoc[v1].height / 2 + 40 * (themeLoc[v1].x + themeLoc[v1].width) + themeLoc[v1].y; v19 = (char *)dungeon + v18; *(v19 - 41) = 53; @@ -1252,60 +1085,52 @@ void __fastcall DRLG_PlaceThemeRooms(int minSize, int maxSize, int floor, int fr { int v5; // ebx //int v7; // eax - int v8; // esi - int v9; // edi - int v10; // eax - int v12; // eax - int v14; // eax - int v16; // eax - int v17; // edi - int v18; // esi - int v19; // ecx - int v20; // ecx - int v21; // eax - int minSize2; // [esp+10h] [ebp-1Ch] - int maxSize2; // [esp+14h] [ebp-18h] + int v8; // esi + int v9; // edi + int v10; // eax + int v12; // eax + int v14; // eax + int v16; // eax + int v17; // edi + int v18; // esi + int v19; // ecx + int v20; // ecx + int v21; // eax + int minSize2; // [esp+10h] [ebp-1Ch] + int maxSize2; // [esp+14h] [ebp-18h] unsigned char *v24; // [esp+18h] [ebp-14h] signed int x_start; // [esp+1Ch] [ebp-10h] - int x; // [esp+20h] [ebp-Ch] - int width; // [esp+24h] [ebp-8h] - int height; // [esp+28h] [ebp-4h] + int x; // [esp+20h] [ebp-Ch] + int width; // [esp+24h] [ebp-8h] + int height; // [esp+28h] [ebp-4h] v5 = 0; maxSize2 = maxSize; minSize2 = minSize; themeCount = 0; memset(themeLoc, 0, sizeof(*themeLoc)); - do - { + do { x = 0; x_start = 20; v24 = (unsigned char *)dungeon + v5; - do - { - if ( *v24 == floor ) - { - if ( !random(0, freq) ) - { + do { + if (*v24 == floor) { + if (!random(0, freq)) { //_LOBYTE(v7) = DRLG_WillThemeRoomFit(floor, x, v5, minSize2, maxSize2, &width, &height); - if ( DRLG_WillThemeRoomFit(floor, x, v5, minSize2, maxSize2, &width, &height) ) - { - if ( rndSize ) - { + if (DRLG_WillThemeRoomFit(floor, x, v5, minSize2, maxSize2, &width, &height)) { + if (rndSize) { v8 = minSize2 - 2; v9 = maxSize2 - 2; v10 = random(0, width - (minSize2 - 2) + 1); v12 = minSize2 - 2 + random(0, v10); - if ( v12 < minSize2 - 2 || (width = v12, v12 > v9) ) + if (v12 < minSize2 - 2 || (width = v12, v12 > v9)) width = minSize2 - 2; v14 = random(0, height - v8 + 1); v16 = v8 + random(0, v14); - if ( v16 < v8 || v16 > v9 ) + if (v16 < v8 || v16 > v9) v16 = minSize2 - 2; height = v16; - } - else - { + } else { v16 = height; } v17 = themeCount; @@ -1317,7 +1142,7 @@ void __fastcall DRLG_PlaceThemeRooms(int minSize, int maxSize, int floor, int fr themeLoc[v18].height = v16; v20 = x + v19; v21 = v5 + v16; - if ( leveltype == DTYPE_CAVES ) + if (leveltype == DTYPE_CAVES) DRLG_RectTrans(x_start, 2 * v5 + 20, 2 * v20 + 15, 2 * v21 + 15); else DRLG_MRectTrans(x + 1, v5 + 1, v20, v21); @@ -1330,48 +1155,40 @@ void __fastcall DRLG_PlaceThemeRooms(int minSize, int maxSize, int floor, int fr x_start += 2; ++x; v24 += 40; - } - while ( x_start < 100 ); + } while (x_start < 100); ++v5; - } - while ( v5 < 40 ); + } while (v5 < 40); } // 5A5590: using guessed type char TransVal; void __cdecl DRLG_HoldThemeRooms() { int *v0; // esi - int v1; // edi - int v2; // edx - int v3; // ebx - int v4; // edi - int v5; // ecx - int v6; // eax - int v7; // [esp+0h] [ebp-Ch] - int v8; // [esp+4h] [ebp-8h] - int v9; // [esp+8h] [ebp-4h] + int v1; // edi + int v2; // edx + int v3; // ebx + int v4; // edi + int v5; // ecx + int v6; // eax + int v7; // [esp+0h] [ebp-Ch] + int v8; // [esp+4h] [ebp-8h] + int v9; // [esp+8h] [ebp-4h] - if ( themeCount > 0 ) - { + if (themeCount > 0) { v0 = &themeLoc[0].height; v8 = themeCount; - do - { + do { v1 = *(v0 - 3); - if ( v1 < v1 + *v0 - 1 ) - { + if (v1 < v1 + *v0 - 1) { v2 = *(v0 - 4); v3 = 2 * v1 + 16; v7 = v2 + *(v0 - 1) - 1; v9 = *v0 - 1; - do - { - if ( v2 < v7 ) - { + do { + if (v2 < v7) { v4 = 224 * (v2 + 8); v5 = v7 - v2; - do - { + do { v6 = v3 + v4; v4 += 224; dFlags[0][v6] |= DFLAG_POPULATED; @@ -1379,42 +1196,37 @@ void __cdecl DRLG_HoldThemeRooms() dFlags[0][v6 + 1] |= DFLAG_POPULATED; dFlags[1][v6 + 1] |= DFLAG_POPULATED; --v5; - } - while ( v5 ); + } while (v5); } v3 += 2; --v9; - } - while ( v9 ); + } while (v9); } v0 += 5; --v8; - } - while ( v8 ); + } while (v8); } } bool __fastcall SkipThemeRoom(int x, int y) { - int i; // ebx + int i; // ebx THEME_LOC *v3; // eax - int v4; // esi + int v4; // esi i = 0; - if ( themeCount <= 0 ) + if (themeCount <= 0) return 1; v3 = themeLoc; - while ( 1 ) - { - if ( x >= v3->x - 2 && x <= v3->x + v3->width + 2 ) - { + while (1) { + if (x >= v3->x - 2 && x <= v3->x + v3->width + 2) { v4 = v3->y; - if ( y >= v4 - 2 && y <= v4 + v3->height + 2 ) + if (y >= v4 - 2 && y <= v4 + v3->height + 2) break; } ++i; ++v3; - if ( i >= themeCount ) + if (i >= themeCount) return 1; } return 0; @@ -1422,8 +1234,7 @@ bool __fastcall SkipThemeRoom(int x, int y) void __cdecl InitLevels() { - if ( !leveldebug ) - { + if (!leveldebug) { currlevel = 0; leveltype = 0; setlevel = 0; diff --git a/Source/gmenu.cpp b/Source/gmenu.cpp index 51d2b3b2..c012101a 100644 --- a/Source/gmenu.cpp +++ b/Source/gmenu.cpp @@ -16,98 +16,98 @@ void *sgpLogo; int dword_63448C; // weak const unsigned char lfontframe[127] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 37, 49, 38, 0, 39, 40, 47, - 42, 43, 41, 45, 52, 44, 53, 55, 36, 27, - 28, 29, 30, 31, 32, 33, 34, 35, 51, 50, - 0, 46, 0, 54, 0, 1, 2, 3, 4, 5, - 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, - 26, 42, 0, 43, 0, 0, 0, 1, 2, 3, - 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 20, 0, 21, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 37, 49, 38, 0, 39, 40, 47, + 42, 43, 41, 45, 52, 44, 53, 55, 36, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 51, 50, + 0, 46, 0, 54, 0, 1, 2, 3, 4, 5, + 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, + 26, 42, 0, 43, 0, 0, 0, 1, 2, 3, + 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 20, 0, 21, 0 }; const unsigned char lfontkern[56] = { - 18, 33, 21, 26, 28, 19, 19, 26, 25, 11, - 12, 25, 19, 34, 28, 32, 20, 32, 28, 20, - 28, 36, 35, 46, 33, 33, 24, 11, 23, 22, - 22, 21, 22, 21, 21, 21, 32, 10, 20, 36, - 31, 17, 13, 12, 13, 18, 16, 11, 20, 21, - 11, 10, 12, 11, 21, 23 + 18, 33, 21, 26, 28, 19, 19, 26, 25, 11, + 12, 25, 19, 34, 28, 32, 20, 32, 28, 20, + 28, 36, 35, 46, 33, 33, 24, 11, 23, 22, + 22, 21, 22, 21, 21, 21, 32, 10, 20, 36, + 31, 17, 13, 12, 13, 18, 16, 11, 20, 21, + 11, 10, 12, 11, 21, 23 }; void __cdecl gmenu_draw_pause() { - if (currlevel) - RedBack(); - if (!dword_634480) { - light_table_index = 0; - gmenu_print_text(316, 336, "Pause"); - } + if (currlevel) + RedBack(); + if (!dword_634480) { + light_table_index = 0; + gmenu_print_text(316, 336, "Pause"); + } } // 69BEF8: using guessed type int light_table_index; void __fastcall gmenu_print_text(int x, int y, char *pszStr) { - char *v3; // edi - int v4; // ebp - int v5; // esi - unsigned char i; // al - unsigned char v7; // bl + char *v3; // edi + int v4; // ebp + int v5; // esi + unsigned char i; // al + unsigned char v7; // bl - v3 = pszStr; - v4 = y; - v5 = x; - for (i = *pszStr; *v3; i = *v3) { - ++v3; - v7 = lfontframe[fontidx[i]]; - if (v7) - CelDecodeLightOnly(v5, v4, (char *)BigTGold_cel, v7, 46); - v5 += lfontkern[v7] + 2; - } + v3 = pszStr; + v4 = y; + v5 = x; + for (i = *pszStr; *v3; i = *v3) { + ++v3; + v7 = lfontframe[fontidx[i]]; + if (v7) + CelDecodeLightOnly(v5, v4, (char *)BigTGold_cel, v7, 46); + v5 += lfontkern[v7] + 2; + } } void __cdecl FreeGMenu() { - void *v0; // ecx - void *v1; // ecx - void *v2; // ecx - void *v3; // ecx - void *v4; // ecx + void *v0; // ecx + void *v1; // ecx + void *v2; // ecx + void *v3; // ecx + void *v4; // ecx - v0 = sgpLogo; - sgpLogo = 0; - mem_free_dbg(v0); - v1 = BigTGold_cel; - BigTGold_cel = 0; - mem_free_dbg(v1); - v2 = PentSpin_cel; - PentSpin_cel = 0; - mem_free_dbg(v2); - v3 = option_cel; - option_cel = 0; - mem_free_dbg(v3); - v4 = optbar_cel; - optbar_cel = 0; - mem_free_dbg(v4); + v0 = sgpLogo; + sgpLogo = 0; + mem_free_dbg(v0); + v1 = BigTGold_cel; + BigTGold_cel = 0; + mem_free_dbg(v1); + v2 = PentSpin_cel; + PentSpin_cel = 0; + mem_free_dbg(v2); + v3 = option_cel; + option_cel = 0; + mem_free_dbg(v3); + v4 = optbar_cel; + optbar_cel = 0; + mem_free_dbg(v4); } void __cdecl gmenu_init_menu() { - byte_634478 = 1; - dword_634480 = 0; - sgpCurrItem = 0; - dword_63447C = 0; - dword_63448C = 0; - byte_634464 = 0; - sgpLogo = LoadFileInMem("Data\\Diabsmal.CEL", 0); - BigTGold_cel = LoadFileInMem("Data\\BigTGold.CEL", 0); - PentSpin_cel = LoadFileInMem("Data\\PentSpin.CEL", 0); - option_cel = LoadFileInMem("Data\\option.CEL", 0); - optbar_cel = LoadFileInMem("Data\\optbar.CEL", 0); + byte_634478 = 1; + dword_634480 = 0; + sgpCurrItem = 0; + dword_63447C = 0; + dword_63448C = 0; + byte_634464 = 0; + sgpLogo = LoadFileInMem("Data\\Diabsmal.CEL", 0); + BigTGold_cel = LoadFileInMem("Data\\BigTGold.CEL", 0); + PentSpin_cel = LoadFileInMem("Data\\PentSpin.CEL", 0); + option_cel = LoadFileInMem("Data\\option.CEL", 0); + optbar_cel = LoadFileInMem("Data\\optbar.CEL", 0); } // 634464: using guessed type char byte_634464; // 634478: using guessed type char byte_634478; @@ -115,36 +115,36 @@ void __cdecl gmenu_init_menu() BOOL __cdecl gmenu_exception() { - return dword_634480 != 0; + return dword_634480 != 0; } void __fastcall gmenu_call_proc(TMenuItem *pItem, void(__cdecl *gmFunc)()) { - TMenuItem *v2; // eax - int v3; // ecx - void(__cdecl * *v4)(); // edx + TMenuItem *v2; // eax + int v3; // ecx + void(__cdecl * *v4)(); // edx - PauseMode = 0; - byte_634464 = 0; - v2 = pItem; - dword_63447C = gmFunc; - dword_634480 = pItem; - if (gmFunc) { - gmFunc(); - v2 = dword_634480; - } - v3 = 0; - dword_63448C = 0; - if (v2) { - v4 = &v2->fnMenu; - while (*v4) { - ++v3; - v4 += 3; - dword_63448C = v3; - } - } - sgpCurrItem = &v2[v3 - 1]; - gmenu_up_down(1); + PauseMode = 0; + byte_634464 = 0; + v2 = pItem; + dword_63447C = gmFunc; + dword_634480 = pItem; + if (gmFunc) { + gmFunc(); + v2 = dword_634480; + } + v3 = 0; + dword_63448C = 0; + if (v2) { + v4 = &v2->fnMenu; + while (*v4) { + ++v3; + v4 += 3; + dword_63448C = v3; + } + } + sgpCurrItem = &v2[v3 - 1]; + gmenu_up_down(1); } // 525740: using guessed type int PauseMode; // 634464: using guessed type char byte_634464; @@ -152,320 +152,320 @@ void __fastcall gmenu_call_proc(TMenuItem *pItem, void(__cdecl *gmFunc)()) void __fastcall gmenu_up_down(int a1) { - TMenuItem *v1; // eax - int v2; // edi + TMenuItem *v1; // eax + int v2; // edi - v1 = sgpCurrItem; - if (sgpCurrItem) { - byte_634464 = 0; - v2 = dword_63448C; - while (v2) { - --v2; - if (a1) { - ++v1; - sgpCurrItem = v1; - if (v1->fnMenu) - goto LABEL_10; - v1 = dword_634480; - } else { - if (v1 == dword_634480) - v1 = &dword_634480[dword_63448C]; - --v1; - } - sgpCurrItem = v1; - LABEL_10: - if ((v1->dwFlags & 0x80000000) != 0) { - if (v2) - PlaySFX(IS_TITLEMOV); - return; - } - } - } + v1 = sgpCurrItem; + if (sgpCurrItem) { + byte_634464 = 0; + v2 = dword_63448C; + while (v2) { + --v2; + if (a1) { + ++v1; + sgpCurrItem = v1; + if (v1->fnMenu) + goto LABEL_10; + v1 = dword_634480; + } else { + if (v1 == dword_634480) + v1 = &dword_634480[dword_63448C]; + --v1; + } + sgpCurrItem = v1; + LABEL_10: + if ((v1->dwFlags & 0x80000000) != 0) { + if (v2) + PlaySFX(IS_TITLEMOV); + return; + } + } + } } // 634464: using guessed type char byte_634464; // 63448C: using guessed type int dword_63448C; void __cdecl gmenu_draw() { - int v0; // edi - TMenuItem *i; // esi - DWORD v2; // eax + int v0; // edi + TMenuItem *i; // esi + DWORD v2; // eax - if (dword_634480) { - if (dword_63447C) - dword_63447C(); - CelDecodeOnly(236, 262, sgpLogo, 1, 296); - v0 = 320; - for (i = dword_634480; i->fnMenu; v0 += 45) { - gmenu_draw_menu_item(i, v0); - ++i; - } - v2 = GetTickCount(); - if ((signed int)(v2 - dword_634474) > 25) { - if (++byte_634478 == 9) - byte_634478 = 1; - dword_634474 = v2; - } - } + if (dword_634480) { + if (dword_63447C) + dword_63447C(); + CelDecodeOnly(236, 262, sgpLogo, 1, 296); + v0 = 320; + for (i = dword_634480; i->fnMenu; v0 += 45) { + gmenu_draw_menu_item(i, v0); + ++i; + } + v2 = GetTickCount(); + if ((signed int)(v2 - dword_634474) > 25) { + if (++byte_634478 == 9) + byte_634478 = 1; + dword_634474 = v2; + } + } } // 634474: using guessed type int dword_634474; // 634478: using guessed type char byte_634478; void __fastcall gmenu_draw_menu_item(TMenuItem *pItem, int a2) { - int v2; // edi - TMenuItem *v3; // ebx - unsigned int v4; // eax - unsigned int v5; // ebp - int v6; // esi - unsigned int v7; // ecx - unsigned int v8; // eax - int v9; // ecx - unsigned int v10; // ebp - int v11; // esi - int v12; // eax - int v13; // edi - unsigned int v14; // [esp+10h] [ebp-4h] + int v2; // edi + TMenuItem *v3; // ebx + unsigned int v4; // eax + unsigned int v5; // ebp + int v6; // esi + unsigned int v7; // ecx + unsigned int v8; // eax + int v9; // ecx + unsigned int v10; // ebp + int v11; // esi + int v12; // eax + int v13; // edi + unsigned int v14; // [esp+10h] [ebp-4h] - v2 = a2; - v3 = pItem; - v4 = gmenu_get_lfont(pItem); - v5 = v4; - v14 = v4; - if (v3->dwFlags & 0x40000000) { - v6 = (v4 >> 1) + 80; - CelDecodeOnly(v6, v2 - 10, optbar_cel, 1, 287); - v7 = (v3->dwFlags >> 12) & 0xFFF; - if (v7 < 2) - v7 = 2; - v8 = ((v3->dwFlags & 0xFFF) << 8) / v7; - v9 = (v5 >> 1) + 82; - v10 = v8; - gmenu_clear_buffer(v9, v2 - 12, v8 + 13, 28); - CelDecodeOnly(v6 + v10 + 2, v2 - 12, option_cel, 1, 27); - v5 = v14; - } - v11 = 384 - (v5 >> 1); - v12 = -((v3->dwFlags & 0x80000000) != 0); - _LOBYTE(v12) = v12 & 0xF1; - light_table_index = v12 + 15; - gmenu_print_text(384 - (v5 >> 1), v2, v3->pszStr); - if (v3 == sgpCurrItem) { - v13 = v2 + 1; - CelDecodeOnly(v11 - 54, v13, PentSpin_cel, (unsigned char)byte_634478, 48); - CelDecodeOnly(v11 + v5 + 4, v13, PentSpin_cel, (unsigned char)byte_634478, 48); - } + v2 = a2; + v3 = pItem; + v4 = gmenu_get_lfont(pItem); + v5 = v4; + v14 = v4; + if (v3->dwFlags & 0x40000000) { + v6 = (v4 >> 1) + 80; + CelDecodeOnly(v6, v2 - 10, optbar_cel, 1, 287); + v7 = (v3->dwFlags >> 12) & 0xFFF; + if (v7 < 2) + v7 = 2; + v8 = ((v3->dwFlags & 0xFFF) << 8) / v7; + v9 = (v5 >> 1) + 82; + v10 = v8; + gmenu_clear_buffer(v9, v2 - 12, v8 + 13, 28); + CelDecodeOnly(v6 + v10 + 2, v2 - 12, option_cel, 1, 27); + v5 = v14; + } + v11 = 384 - (v5 >> 1); + v12 = -((v3->dwFlags & 0x80000000) != 0); + _LOBYTE(v12) = v12 & 0xF1; + light_table_index = v12 + 15; + gmenu_print_text(384 - (v5 >> 1), v2, v3->pszStr); + if (v3 == sgpCurrItem) { + v13 = v2 + 1; + CelDecodeOnly(v11 - 54, v13, PentSpin_cel, (unsigned char)byte_634478, 48); + CelDecodeOnly(v11 + v5 + 4, v13, PentSpin_cel, (unsigned char)byte_634478, 48); + } } // 634478: using guessed type char byte_634478; // 69BEF8: using guessed type int light_table_index; void __fastcall gmenu_clear_buffer(int x, int y, int width, int height) { - int v4; // edi - char *i; // esi + int v4; // edi + char *i; // esi - v4 = height; - for (i = (char *)gpBuffer + screen_y_times_768[y] + x; v4; --v4) { - memset(i, 205, width); - i -= 768; - } + v4 = height; + for (i = (char *)gpBuffer + screen_y_times_768[y] + x; v4; --v4) { + memset(i, 205, width); + i -= 768; + } } int __fastcall gmenu_get_lfont(TMenuItem *pItem) { - char *v2; // eax - int i; // edx - unsigned char v4; // cl + char *v2; // eax + int i; // edx + unsigned char v4; // cl - if (pItem->dwFlags & 0x40000000) - return 490; - v2 = pItem->pszStr; - for (i = 0;; i += lfontkern[lfontframe[fontidx[v4]]] + 2) { - v4 = *v2; - if (!*v2) - break; - ++v2; - } - return i - 2; + if (pItem->dwFlags & 0x40000000) + return 490; + v2 = pItem->pszStr; + for (i = 0;; i += lfontkern[lfontframe[fontidx[v4]]] + 2) { + v4 = *v2; + if (!*v2) + break; + ++v2; + } + return i - 2; } int __fastcall gmenu_presskeys(int a1) { - int v1; // ecx - int v2; // ecx + int v1; // ecx + int v2; // ecx - if (!dword_634480) - return 0; - switch (a1) { - case VK_RETURN: - if ((sgpCurrItem->dwFlags & 0x80000000) != 0) { - PlaySFX(IS_TITLEMOV); - ((void(__fastcall *)(signed int))sgpCurrItem->fnMenu)(1); - } - return 1; - case VK_ESCAPE: - PlaySFX(IS_TITLEMOV); - gmenu_call_proc(0, 0); - return 1; - case VK_SPACE: - return 0; - case VK_LEFT: - v2 = 0; - goto LABEL_12; - case VK_UP: - v1 = 0; - goto LABEL_10; - case VK_RIGHT: - v2 = 1; - LABEL_12: - gmenu_left_right(v2); - return 1; - case VK_DOWN: - v1 = 1; - LABEL_10: - gmenu_up_down(v1); - break; - } - return 1; + if (!dword_634480) + return 0; + switch (a1) { + case VK_RETURN: + if ((sgpCurrItem->dwFlags & 0x80000000) != 0) { + PlaySFX(IS_TITLEMOV); + ((void(__fastcall *)(signed int))sgpCurrItem->fnMenu)(1); + } + return 1; + case VK_ESCAPE: + PlaySFX(IS_TITLEMOV); + gmenu_call_proc(0, 0); + return 1; + case VK_SPACE: + return 0; + case VK_LEFT: + v2 = 0; + goto LABEL_12; + case VK_UP: + v1 = 0; + goto LABEL_10; + case VK_RIGHT: + v2 = 1; + LABEL_12: + gmenu_left_right(v2); + return 1; + case VK_DOWN: + v1 = 1; + LABEL_10: + gmenu_up_down(v1); + break; + } + return 1; } void __fastcall gmenu_left_right(int a1) { - signed int v1; // edx - unsigned int v2; // eax - int v3; // eax + signed int v1; // edx + unsigned int v2; // eax + int v3; // eax - v1 = sgpCurrItem->dwFlags; - if (sgpCurrItem->dwFlags & 0x40000000) { - v2 = sgpCurrItem->dwFlags & 0xFFF; - if (a1) { - if (v2 == ((v1 >> 12) & 0xFFF)) - return; - v3 = v2 + 1; - } else { - if (!(v1 & 0xFFF)) - return; - v3 = v2 - 1; - } - _LOWORD(v1) = v1 & 0xF000; - sgpCurrItem->dwFlags = v1; - sgpCurrItem->dwFlags |= v3; - ((void(__fastcall *)(_DWORD))sgpCurrItem->fnMenu)(0); - } + v1 = sgpCurrItem->dwFlags; + if (sgpCurrItem->dwFlags & 0x40000000) { + v2 = sgpCurrItem->dwFlags & 0xFFF; + if (a1) { + if (v2 == ((v1 >> 12) & 0xFFF)) + return; + v3 = v2 + 1; + } else { + if (!(v1 & 0xFFF)) + return; + v3 = v2 - 1; + } + _LOWORD(v1) = v1 & 0xF000; + sgpCurrItem->dwFlags = v1; + sgpCurrItem->dwFlags |= v3; + ((void(__fastcall *)(_DWORD))sgpCurrItem->fnMenu)(0); + } } int __fastcall gmenu_on_mouse_move(LPARAM lParam) { - int v2; // edx - int a1; // [esp+0h] [ebp-4h] + int v2; // edx + int a1; // [esp+0h] [ebp-4h] - a1 = lParam; - if (!byte_634464) - return 0; - gmenu_valid_mouse_pos(&a1); - v2 = a1 * ((sgpCurrItem->dwFlags >> 12) & 0xFFF) % 256; - a1 = a1 * ((sgpCurrItem->dwFlags >> 12) & 0xFFF) / 256; - _LOWORD(sgpCurrItem->dwFlags) &= 0xF000u; - sgpCurrItem->dwFlags |= a1; - ((void(__fastcall *)(_DWORD, int))sgpCurrItem->fnMenu)(0, v2); - return 1; + a1 = lParam; + if (!byte_634464) + return 0; + gmenu_valid_mouse_pos(&a1); + v2 = a1 * ((sgpCurrItem->dwFlags >> 12) & 0xFFF) % 256; + a1 = a1 * ((sgpCurrItem->dwFlags >> 12) & 0xFFF) / 256; + _LOWORD(sgpCurrItem->dwFlags) &= 0xF000u; + sgpCurrItem->dwFlags |= a1; + ((void(__fastcall *)(_DWORD, int))sgpCurrItem->fnMenu)(0, v2); + return 1; } // 41A37A: could not find valid save-restore pair for esi // 634464: using guessed type char byte_634464; bool __fastcall gmenu_valid_mouse_pos(int *plOffset) { - *plOffset = 282; - if (MouseX < 282) { - *plOffset = 0; - return 0; - } - if (MouseX > 538) { - *plOffset = 256; - return 0; - } - *plOffset = MouseX - 282; - return 1; + *plOffset = 282; + if (MouseX < 282) { + *plOffset = 0; + return 0; + } + if (MouseX > 538) { + *plOffset = 256; + return 0; + } + *plOffset = MouseX - 282; + return 1; } int __fastcall gmenu_left_mouse(int a1) { - int result; // eax - unsigned int v2; // eax - unsigned int v3; // eax - TMenuItem *v4; // esi - unsigned int v5; // eax - //LPARAM v6; // ecx - int a1a; // [esp+4h] [ebp-4h] + int result; // eax + unsigned int v2; // eax + unsigned int v3; // eax + TMenuItem *v4; // esi + unsigned int v5; // eax + //LPARAM v6; // ecx + int a1a; // [esp+4h] [ebp-4h] - if (a1) { - if (!dword_634480 || MouseY >= 352) - return 0; - if (MouseY - 117 >= 0) { - v2 = (MouseY - 117) / 45; - if (v2 < dword_63448C) { - v3 = v2; - v4 = &dword_634480[v3]; - if ((v4->dwFlags & 0x80000000) != 0) { - v5 = (unsigned int)gmenu_get_lfont(&dword_634480[v3]) >> 1; - if (MouseX >= 320 - v5 && MouseX <= v5 + 320) { - sgpCurrItem = v4; - PlaySFX(IS_TITLEMOV); - if (v4->dwFlags & 0x40000000) { - byte_634464 = gmenu_valid_mouse_pos(&a1a); - gmenu_on_mouse_move(a1); /* v6 */ - } else { - ((void(__fastcall *)(signed int))sgpCurrItem->fnMenu)(1); - } - } - } - } - } - } else { - result = 0; - if (!byte_634464) - return result; - byte_634464 = 0; - } - return 1; + if (a1) { + if (!dword_634480 || MouseY >= 352) + return 0; + if (MouseY - 117 >= 0) { + v2 = (MouseY - 117) / 45; + if (v2 < dword_63448C) { + v3 = v2; + v4 = &dword_634480[v3]; + if ((v4->dwFlags & 0x80000000) != 0) { + v5 = (unsigned int)gmenu_get_lfont(&dword_634480[v3]) >> 1; + if (MouseX >= 320 - v5 && MouseX <= v5 + 320) { + sgpCurrItem = v4; + PlaySFX(IS_TITLEMOV); + if (v4->dwFlags & 0x40000000) { + byte_634464 = gmenu_valid_mouse_pos(&a1a); + gmenu_on_mouse_move(a1); /* v6 */ + } else { + ((void(__fastcall *)(signed int))sgpCurrItem->fnMenu)(1); + } + } + } + } + } + } else { + result = 0; + if (!byte_634464) + return result; + byte_634464 = 0; + } + return 1; } // 634464: using guessed type char byte_634464; // 63448C: using guessed type int dword_63448C; void __fastcall gmenu_enable(TMenuItem *pMenuItem, BOOL enable) { - if (enable) - pMenuItem->dwFlags |= 0x80000000; - else - pMenuItem->dwFlags &= 0x7F000000; + if (enable) + pMenuItem->dwFlags |= 0x80000000; + else + pMenuItem->dwFlags &= 0x7F000000; } void __fastcall gmenu_slider_1(TMenuItem *pItem, int min, int max, int gamma) { - unsigned int v4; // esi - int v5; // eax + unsigned int v4; // esi + int v5; // eax - v4 = pItem->dwFlags; - v5 = (pItem->dwFlags >> 12) & 0xFFF; - if (v5 < 2) - v5 = 2; - _LOWORD(v4) = v4 & 0xF000; - pItem->dwFlags = v4 | (v5 * (gamma - min) + (max - min - 1) / 2) / (max - min); + v4 = pItem->dwFlags; + v5 = (pItem->dwFlags >> 12) & 0xFFF; + if (v5 < 2) + v5 = 2; + _LOWORD(v4) = v4 & 0xF000; + pItem->dwFlags = v4 | (v5 * (gamma - min) + (max - min - 1) / 2) / (max - min); } int __fastcall gmenu_slider_get(TMenuItem *pItem, int min, int max) { - int v3; // eax - unsigned int v4; // ecx + int v3; // eax + unsigned int v4; // ecx - v3 = (pItem->dwFlags >> 12) & 0xFFF; - v4 = pItem->dwFlags & 0xFFF; - if (v3 < 2) - v3 = 2; - return min + (v4 * (max - min) + (v3 - 1) / 2) / v3; + v3 = (pItem->dwFlags >> 12) & 0xFFF; + v4 = pItem->dwFlags & 0xFFF; + if (v3 < 2) + v3 = 2; + return min + (v4 * (max - min) + (v3 - 1) / 2) / v3; } void __fastcall gmenu_slider_3(TMenuItem *pItem, int dwTicks) { - pItem->dwFlags ^= (pItem->dwFlags ^ (dwTicks << 12)) & 0xFFF000; + pItem->dwFlags ^= (pItem->dwFlags ^ (dwTicks << 12)) & 0xFFF000; } diff --git a/Source/help.cpp b/Source/help.cpp index f1445711..c04fec50 100644 --- a/Source/help.cpp +++ b/Source/help.cpp @@ -9,240 +9,240 @@ int displayinghelp[22]; /* check, does nothing? */ int HelpTop; // weak const char gszHelpText[] = { - "$Keyboard Shortcuts:|" - "F1: Open Help Screen|" - "Esc: Display Main Menu|" - "Tab: Display Auto-map|" - "Space: Hide all info screens|" - "S: Open Speedbook|" - "B: Open Spellbook|" - "I: Open Inventory screen|" - "C: Open Character screen|" - "Q: Open Quest log|" - "F: Reduce screen brightness|" - "G: Increase screen brightness|" - "Z: Zoom Game Screen|" - "+ / -: Zoom Automap|" - "1 - 8: Use Belt item|" - "F5, F6, F7, F8: Set hot key for skill or spell|" - "Shift + Left Click: Attack without moving|" - "|" - "$Movement:|" - "If you hold the mouse button down while moving, the character " - "will continue to move in that direction.|" - "|" - "$Combat:|" - "Holding down the shift key and then left-clicking allows the " - "character to attack without moving.|" - "|" - "$Auto-map:|" - "To access the auto-map, click the 'MAP' button on the " - "Information Bar or press 'TAB' on the keyboard. Zooming in and " - "out of the map is done with the + and - keys. Scrolling the map " - "uses the arrow keys.|" - "|" - "$Picking up Objects:|" - "Useable items that are small in size, such as potions or scrolls, " - "are automatically placed in your 'belt' located at the top of " - "the Interface bar . When an item is placed in the belt, a small " - "number appears in that box. Items may be used by either pressing " - "the corresponding number or right-clicking on the item.|" - "|" - "$Gold|" - "You can select a specific amount of gold to drop by right " - "clicking on a pile of gold in your inventory.|" - "|" - "$Skills & Spells:|" - "You can access your list of skills and spells by left-clicking on " - "the 'SPELLS' button in the interface bar. Memorized spells and " - "those available through staffs are listed here. Left-clicking on " - "the spell you wish to cast will ready the spell. A readied spell " - "may be cast by simply right-clicking in the play area.|" - "|" - "$Using the Speedbook for Spells|" - "Left-clicking on the 'readied spell' button will open the 'Speedbook' " - "which allows you to select a skill or spell for immediate use. " - "To use a readied skill or spell, simply right-click in the main play " - "area.|" - "|" - "$Setting Spell Hotkeys|" - "You can assign up to four Hot Keys for skills, spells or scrolls. " - "Start by opening the 'speedbook' as described in the section above. " - "Press the F5, F6, F7 or F8 keys after highlighting the spell you " - "wish to assign.|" - "|" - "$Spell Books|" - "Reading more than one book increases your knowledge of that " - "spell, allowing you to cast the spell more effectively.|" - "&" + "$Keyboard Shortcuts:|" + "F1: Open Help Screen|" + "Esc: Display Main Menu|" + "Tab: Display Auto-map|" + "Space: Hide all info screens|" + "S: Open Speedbook|" + "B: Open Spellbook|" + "I: Open Inventory screen|" + "C: Open Character screen|" + "Q: Open Quest log|" + "F: Reduce screen brightness|" + "G: Increase screen brightness|" + "Z: Zoom Game Screen|" + "+ / -: Zoom Automap|" + "1 - 8: Use Belt item|" + "F5, F6, F7, F8: Set hot key for skill or spell|" + "Shift + Left Click: Attack without moving|" + "|" + "$Movement:|" + "If you hold the mouse button down while moving, the character " + "will continue to move in that direction.|" + "|" + "$Combat:|" + "Holding down the shift key and then left-clicking allows the " + "character to attack without moving.|" + "|" + "$Auto-map:|" + "To access the auto-map, click the 'MAP' button on the " + "Information Bar or press 'TAB' on the keyboard. Zooming in and " + "out of the map is done with the + and - keys. Scrolling the map " + "uses the arrow keys.|" + "|" + "$Picking up Objects:|" + "Useable items that are small in size, such as potions or scrolls, " + "are automatically placed in your 'belt' located at the top of " + "the Interface bar . When an item is placed in the belt, a small " + "number appears in that box. Items may be used by either pressing " + "the corresponding number or right-clicking on the item.|" + "|" + "$Gold|" + "You can select a specific amount of gold to drop by right " + "clicking on a pile of gold in your inventory.|" + "|" + "$Skills & Spells:|" + "You can access your list of skills and spells by left-clicking on " + "the 'SPELLS' button in the interface bar. Memorized spells and " + "those available through staffs are listed here. Left-clicking on " + "the spell you wish to cast will ready the spell. A readied spell " + "may be cast by simply right-clicking in the play area.|" + "|" + "$Using the Speedbook for Spells|" + "Left-clicking on the 'readied spell' button will open the 'Speedbook' " + "which allows you to select a skill or spell for immediate use. " + "To use a readied skill or spell, simply right-click in the main play " + "area.|" + "|" + "$Setting Spell Hotkeys|" + "You can assign up to four Hot Keys for skills, spells or scrolls. " + "Start by opening the 'speedbook' as described in the section above. " + "Press the F5, F6, F7 or F8 keys after highlighting the spell you " + "wish to assign.|" + "|" + "$Spell Books|" + "Reading more than one book increases your knowledge of that " + "spell, allowing you to cast the spell more effectively.|" + "&" }; void __cdecl InitHelp() { - helpflag = 0; - dword_634494 = 0; - displayinghelp[0] = 0; + helpflag = 0; + dword_634494 = 0; + displayinghelp[0] = 0; } // 634494: using guessed type int dword_634494; void __cdecl DrawHelp() { - int v0; // edi - const char *v1; // esi - int v2; // edx - signed int v3; // ecx - char v4; // al - unsigned char v5; // al - _BYTE *i; // eax - int v7; // eax - signed int v8; // edx - char v9; // cl - unsigned char v10; // cl - text_color color; // [esp+Ch] [ebp-8h] - int help_line_nr; // [esp+10h] [ebp-4h] - signed int help_line_nra; // [esp+10h] [ebp-4h] + int v0; // edi + const char *v1; // esi + int v2; // edx + signed int v3; // ecx + char v4; // al + unsigned char v5; // al + _BYTE *i; // eax + int v7; // eax + signed int v8; // edx + char v9; // cl + unsigned char v10; // cl + text_color color; // [esp+Ch] [ebp-8h] + int help_line_nr; // [esp+10h] [ebp-4h] + signed int help_line_nra; // [esp+10h] [ebp-4h] - DrawSTextHelp(); - DrawQTextBack(); - PrintSString(0, 2, 1u, "Diablo Help", COL_GOLD, 0); - DrawSLine(5); - v0 = help_select_line; - v1 = gszHelpText; - if (help_select_line > 0) { - help_line_nr = help_select_line; - do { - v2 = 0; - v3 = 0; - while (!*v1) - ++v1; - if (*v1 == '$') - ++v1; - v4 = *v1; - if (*v1 != '&') { - if (v4 == ('|')) - goto LABEL_47; - while (v3 < 577) { - if (!v4) { - do - ++v1; - while (!*v1); - } - v5 = *v1; - tempstr[v2++] = *v1++; - v3 += fontkern[fontframe[fontidx[v5]]] + 1; - v4 = *v1; - if (*v1 == ('|')) { - if (v3 < 577) - goto LABEL_18; - break; - } - } - for (i = (unsigned char *)&tempstr[v2] - 1; *i != ' '; --i) - --v1; - LABEL_18: - if (*v1 == ('|')) - LABEL_47: - ++v1; - } - --help_line_nr; - } while (help_line_nr); - } - help_line_nra = 7; - do { - v7 = 0; - v8 = 0; - while (!*v1) - ++v1; - if (*v1 == '$') { - ++v1; - _LOBYTE(color) = COL_RED; - } else { - _LOBYTE(color) = COL_WHITE; - } - v9 = *v1; - if (*v1 == '&') { - HelpTop = v0; - } else { - if (v9 == ('|')) - goto LABEL_48; - while (v8 < 577) { - if (!v9) { - do - ++v1; - while (!*v1); - } - v10 = *v1; - tempstr[v7++] = *v1++; - v8 += fontkern[fontframe[fontidx[v10]]] + 1; - v9 = *v1; - if (*v1 == ('|')) { - if (v8 < 577) - goto LABEL_39; - break; - } - } - while (tempstr[--v7] != ' ') - --v1; - LABEL_39: - if (v7) { - tempstr[v7] = 0; - DrawHelpLine(0, help_line_nra, tempstr, color); - v0 = help_select_line; - } - if (*v1 == ('|')) - LABEL_48: - ++v1; - } - ++help_line_nra; - } while (help_line_nra < 22); - PrintSString(0, 23, 1u, "Press ESC to end or the arrow keys to scroll.", COL_GOLD, 0); + DrawSTextHelp(); + DrawQTextBack(); + PrintSString(0, 2, 1u, "Diablo Help", COL_GOLD, 0); + DrawSLine(5); + v0 = help_select_line; + v1 = gszHelpText; + if (help_select_line > 0) { + help_line_nr = help_select_line; + do { + v2 = 0; + v3 = 0; + while (!*v1) + ++v1; + if (*v1 == '$') + ++v1; + v4 = *v1; + if (*v1 != '&') { + if (v4 == ('|')) + goto LABEL_47; + while (v3 < 577) { + if (!v4) { + do + ++v1; + while (!*v1); + } + v5 = *v1; + tempstr[v2++] = *v1++; + v3 += fontkern[fontframe[fontidx[v5]]] + 1; + v4 = *v1; + if (*v1 == ('|')) { + if (v3 < 577) + goto LABEL_18; + break; + } + } + for (i = (unsigned char *)&tempstr[v2] - 1; *i != ' '; --i) + --v1; + LABEL_18: + if (*v1 == ('|')) + LABEL_47: + ++v1; + } + --help_line_nr; + } while (help_line_nr); + } + help_line_nra = 7; + do { + v7 = 0; + v8 = 0; + while (!*v1) + ++v1; + if (*v1 == '$') { + ++v1; + _LOBYTE(color) = COL_RED; + } else { + _LOBYTE(color) = COL_WHITE; + } + v9 = *v1; + if (*v1 == '&') { + HelpTop = v0; + } else { + if (v9 == ('|')) + goto LABEL_48; + while (v8 < 577) { + if (!v9) { + do + ++v1; + while (!*v1); + } + v10 = *v1; + tempstr[v7++] = *v1++; + v8 += fontkern[fontframe[fontidx[v10]]] + 1; + v9 = *v1; + if (*v1 == ('|')) { + if (v8 < 577) + goto LABEL_39; + break; + } + } + while (tempstr[--v7] != ' ') + --v1; + LABEL_39: + if (v7) { + tempstr[v7] = 0; + DrawHelpLine(0, help_line_nra, tempstr, color); + v0 = help_select_line; + } + if (*v1 == ('|')) + LABEL_48: + ++v1; + } + ++help_line_nra; + } while (help_line_nra < 22); + PrintSString(0, 23, 1u, "Press ESC to end or the arrow keys to scroll.", COL_GOLD, 0); } // 634490: using guessed type int help_select_line; // 634960: using guessed type int HelpTop; void __fastcall DrawHelpLine(int always_0, int help_line_nr, char *text, text_color color) { - signed int v4; // ebx - int v5; // edi - unsigned char i; // al - unsigned char v7; // al - int v8; // esi + signed int v4; // ebx + int v5; // edi + unsigned char i; // al + unsigned char v7; // al + int v8; // esi - v4 = 0; - v5 = screen_y_times_768[SStringY[help_line_nr] + 204] + always_0 + 96; - for (i = *text; *text; i = *text) { - ++text; - v7 = fontframe[fontidx[i]]; - v8 = v7; - v4 += fontkern[v7] + 1; - if (v7) { - if (v4 <= 577) - CPrintString(v5, v7, color); - } - v5 += fontkern[v8] + 1; - } + v4 = 0; + v5 = screen_y_times_768[SStringY[help_line_nr] + 204] + always_0 + 96; + for (i = *text; *text; i = *text) { + ++text; + v7 = fontframe[fontidx[i]]; + v8 = v7; + v4 += fontkern[v7] + 1; + if (v7) { + if (v4 <= 577) + CPrintString(v5, v7, color); + } + v5 += fontkern[v8] + 1; + } } void __cdecl DisplayHelp() { - help_select_line = 0; - helpflag = 1; - HelpTop = 5000; + help_select_line = 0; + helpflag = 1; + HelpTop = 5000; } // 634490: using guessed type int help_select_line; // 634960: using guessed type int HelpTop; void __cdecl HelpScrollUp() { - if (help_select_line > 0) - --help_select_line; + if (help_select_line > 0) + --help_select_line; } // 634490: using guessed type int help_select_line; void __cdecl HelpScrollDown() { - if (help_select_line < HelpTop) - ++help_select_line; + if (help_select_line < HelpTop) + ++help_select_line; } // 634490: using guessed type int help_select_line; // 634960: using guessed type int HelpTop; diff --git a/Source/init.cpp b/Source/init.cpp index 00a67c1c..e2d3e3af 100644 --- a/Source/init.cpp +++ b/Source/init.cpp @@ -23,464 +23,464 @@ char gszVersionNumber[260] = "internal version unknown"; char gszProductName[260] = "Diablo v1.09"; struct init_cpp_init { - init_cpp_init() - { - init_cpp_init_value = init_inf; - } + init_cpp_init() + { + init_cpp_init_value = init_inf; + } } _init_cpp_init; // 47AE20: using guessed type int init_inf; // 63497C: using guessed type int init_cpp_init_value; void __fastcall init_cleanup(bool show_cursor) { - int v1; // edi + int v1; // edi - v1 = show_cursor; - pfile_flush_W(); - init_disable_screensaver(0); - init_run_office_from_start_menu(); - if (diabdat_mpq) { - SFileCloseArchive(diabdat_mpq); - diabdat_mpq = 0; - } - if (patch_rt_mpq) { - SFileCloseArchive(patch_rt_mpq); - patch_rt_mpq = 0; - } - if (unused_mpq) { - SFileCloseArchive(unused_mpq); - unused_mpq = 0; - } - UiDestroy(); - effects_cleanup_sfx(); - sound_cleanup(); - NetClose(); - dx_cleanup(); - MI_Dummy(v1); - StormDestroy(); - if (v1) - ShowCursor(1); + v1 = show_cursor; + pfile_flush_W(); + init_disable_screensaver(0); + init_run_office_from_start_menu(); + if (diabdat_mpq) { + SFileCloseArchive(diabdat_mpq); + diabdat_mpq = 0; + } + if (patch_rt_mpq) { + SFileCloseArchive(patch_rt_mpq); + patch_rt_mpq = 0; + } + if (unused_mpq) { + SFileCloseArchive(unused_mpq); + unused_mpq = 0; + } + UiDestroy(); + effects_cleanup_sfx(); + sound_cleanup(); + NetClose(); + dx_cleanup(); + MI_Dummy(v1); + StormDestroy(); + if (v1) + ShowCursor(1); } void __cdecl init_run_office_from_start_menu() { - HWND v0; // eax - char pszPath[256]; // [esp+0h] [ebp-104h] - LPITEMIDLIST ppidl; // [esp+100h] [ebp-4h] + HWND v0; // eax + char pszPath[256]; // [esp+0h] [ebp-104h] + LPITEMIDLIST ppidl; // [esp+100h] [ebp-4h] - if (killed_mom_parent) { - *pszPath = empty_string; - killed_mom_parent = 0; - memset(pszPath + 1, 0, sizeof(pszPath) - 1); - // *(_WORD *)&pszPath[253] = 0; - //pszPath[255] = 0; - ppidl = 0; - v0 = GetDesktopWindow(); - if (!SHGetSpecialFolderLocation(v0, CSIDL_STARTMENU, &ppidl)) { - SHGetPathFromIDList(ppidl, pszPath); - init_run_office(pszPath); - } - } + if (killed_mom_parent) { + *pszPath = empty_string; + killed_mom_parent = 0; + memset(pszPath + 1, 0, sizeof(pszPath) - 1); + // *(_WORD *)&pszPath[253] = 0; + //pszPath[255] = 0; + ppidl = 0; + v0 = GetDesktopWindow(); + if (!SHGetSpecialFolderLocation(v0, CSIDL_STARTMENU, &ppidl)) { + SHGetPathFromIDList(ppidl, pszPath); + init_run_office(pszPath); + } + } } // 634CA0: using guessed type int killed_mom_parent; void __fastcall init_run_office(char *dir) { - char *v1; // esi - HANDLE v2; // ebx - bool v3; // zf - HWND v4; // eax - char Directory[260]; // [esp+8h] [ebp-348h] - char FileName[260]; // [esp+10Ch] [ebp-244h] - struct _WIN32_FIND_DATAA FindFileData; // [esp+210h] [ebp-140h] + char *v1; // esi + HANDLE v2; // ebx + bool v3; // zf + HWND v4; // eax + char Directory[260]; // [esp+8h] [ebp-348h] + char FileName[260]; // [esp+10Ch] [ebp-244h] + struct _WIN32_FIND_DATAA FindFileData; // [esp+210h] [ebp-140h] - v1 = dir; - strcpy(FileName, dir); - if (FileName[0] && Directory[strlen(FileName) + 259] == '\\') - strcat(FileName, "*"); - else - strcat(FileName, "\\*"); - v2 = FindFirstFile(FileName, &FindFileData); - if (v2 != (HANDLE)-1) { - do { - if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { - if (strcmp(FindFileData.cFileName, ".") && strcmp(FindFileData.cFileName, "..")) { - *Directory = empty_string; - memset(Directory + 1, 0, sizeof(Directory) - 1); - v3 = *v1 == 0; - // *(_WORD *)&Directory[257] = 0; - //Directory[259] = 0; - if (v3 || v1[strlen(v1) - 1] != '\\') - sprintf(Directory, "%s\\%s\\", v1, FindFileData.cFileName); - else - sprintf(Directory, "%s%s\\", v1, FindFileData.cFileName); - init_run_office(Directory); - } - } else if (!_strcmpi(FindFileData.cFileName, "Microsoft Office Shortcut Bar.lnk")) { - v4 = GetDesktopWindow(); - ShellExecute(v4, "open", FindFileData.cFileName, &empty_string, v1, SW_SHOWNORMAL); - } - } while (FindNextFile(v2, &FindFileData)); - FindClose(v2); - } + v1 = dir; + strcpy(FileName, dir); + if (FileName[0] && Directory[strlen(FileName) + 259] == '\\') + strcat(FileName, "*"); + else + strcat(FileName, "\\*"); + v2 = FindFirstFile(FileName, &FindFileData); + if (v2 != (HANDLE)-1) { + do { + if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { + if (strcmp(FindFileData.cFileName, ".") && strcmp(FindFileData.cFileName, "..")) { + *Directory = empty_string; + memset(Directory + 1, 0, sizeof(Directory) - 1); + v3 = *v1 == 0; + // *(_WORD *)&Directory[257] = 0; + //Directory[259] = 0; + if (v3 || v1[strlen(v1) - 1] != '\\') + sprintf(Directory, "%s\\%s\\", v1, FindFileData.cFileName); + else + sprintf(Directory, "%s%s\\", v1, FindFileData.cFileName); + init_run_office(Directory); + } + } else if (!_strcmpi(FindFileData.cFileName, "Microsoft Office Shortcut Bar.lnk")) { + v4 = GetDesktopWindow(); + ShellExecute(v4, "open", FindFileData.cFileName, &empty_string, v1, SW_SHOWNORMAL); + } + } while (FindNextFile(v2, &FindFileData)); + FindClose(v2); + } } void __fastcall init_disable_screensaver(bool disable) { - bool v1; // al - char Data[16]; // [esp+4h] [ebp-20h] - DWORD Type; // [esp+14h] [ebp-10h] - DWORD cbData; // [esp+18h] [ebp-Ch] - HKEY phkResult; // [esp+1Ch] [ebp-8h] - bool v6; // [esp+20h] [ebp-4h] + bool v1; // al + char Data[16]; // [esp+4h] [ebp-20h] + DWORD Type; // [esp+14h] [ebp-10h] + DWORD cbData; // [esp+18h] [ebp-Ch] + HKEY phkResult; // [esp+1Ch] [ebp-8h] + bool v6; // [esp+20h] [ebp-4h] - // BUGFIX: this is probably the worst possible way to do this. Alternatives: ExtEscape() with SETPOWERMANAGEMENT, - // SystemParametersInfo() with SPI_SETSCREENSAVEACTIVE/SPI_SETPOWEROFFACTIVE/SPI_SETLOWPOWERACTIVE + // BUGFIX: this is probably the worst possible way to do this. Alternatives: ExtEscape() with SETPOWERMANAGEMENT, + // SystemParametersInfo() with SPI_SETSCREENSAVEACTIVE/SPI_SETPOWEROFFACTIVE/SPI_SETLOWPOWERACTIVE - v6 = disable; - if (!RegOpenKeyEx(HKEY_CURRENT_USER, "Control Panel\\Desktop", 0, KEY_READ | KEY_WRITE, &phkResult)) { - if (v6) { - cbData = 16; - if (!RegQueryValueEx(phkResult, "ScreenSaveActive", 0, &Type, (LPBYTE)Data, &cbData)) - screensaver_enabled_prev = Data[0] != '0'; - v1 = 0; - } else { - v1 = screensaver_enabled_prev; - } - Data[1] = 0; - Data[0] = (v1 != 0) + '0'; - RegSetValueEx(phkResult, "ScreenSaveActive", 0, REG_SZ, (const BYTE *)Data, 2u); - RegCloseKey(phkResult); - } + v6 = disable; + if (!RegOpenKeyEx(HKEY_CURRENT_USER, "Control Panel\\Desktop", 0, KEY_READ | KEY_WRITE, &phkResult)) { + if (v6) { + cbData = 16; + if (!RegQueryValueEx(phkResult, "ScreenSaveActive", 0, &Type, (LPBYTE)Data, &cbData)) + screensaver_enabled_prev = Data[0] != '0'; + v1 = 0; + } else { + v1 = screensaver_enabled_prev; + } + Data[1] = 0; + Data[0] = (v1 != 0) + '0'; + RegSetValueEx(phkResult, "ScreenSaveActive", 0, REG_SZ, (const BYTE *)Data, 2u); + RegCloseKey(phkResult); + } } void __fastcall init_create_window(int nCmdShow) { - int nHeight; // eax - HWND hWnd; // esi - WNDCLASSEXA wcex; // [esp+8h] [ebp-34h] - int nWidth; // [esp+38h] [ebp-4h] + int nHeight; // eax + HWND hWnd; // esi + WNDCLASSEXA wcex; // [esp+8h] [ebp-34h] + int nWidth; // [esp+38h] [ebp-4h] - init_kill_mom_parent(); - pfile_init_save_directory(); - memset(&wcex, 0, sizeof(wcex)); - wcex.cbSize = sizeof(wcex); - wcex.style = CS_HREDRAW | CS_VREDRAW; - wcex.lpfnWndProc = WindowProc; - wcex.hInstance = ghInst; - wcex.hIcon = LoadIcon(ghInst, MAKEINTRESOURCE(IDI_ICON1)); - wcex.hCursor = LoadCursor(0, IDC_ARROW); - wcex.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); - wcex.lpszMenuName = "DIABLO"; - wcex.lpszClassName = "DIABLO"; - wcex.hIconSm = (HICON)LoadImage(ghInst, MAKEINTRESOURCE(IDI_ICON1), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); - if (!RegisterClassEx(&wcex)) - TermMsg("Unable to register window class"); - if (GetSystemMetrics(SM_CXSCREEN) >= 640) - nWidth = GetSystemMetrics(SM_CXSCREEN); - else - nWidth = 640; - if (GetSystemMetrics(SM_CYSCREEN) >= 480) - nHeight = GetSystemMetrics(SM_CYSCREEN); - else - nHeight = 480; - hWnd = CreateWindowEx(0, "DIABLO", "DIABLO", WS_POPUP, 0, 0, nWidth, nHeight, NULL, NULL, ghInst, NULL); - if (!hWnd) - TermMsg("Unable to create main window"); - ShowWindow(hWnd, SW_SHOWNORMAL); // nCmdShow used only in beta: ShowWindow(hWnd, nCmdShow) - UpdateWindow(hWnd); - init_await_mom_parent_exit(); - dx_init(hWnd); - BlackPalette(); - snd_init(hWnd); - init_archives(); - init_disable_screensaver(1); + init_kill_mom_parent(); + pfile_init_save_directory(); + memset(&wcex, 0, sizeof(wcex)); + wcex.cbSize = sizeof(wcex); + wcex.style = CS_HREDRAW | CS_VREDRAW; + wcex.lpfnWndProc = WindowProc; + wcex.hInstance = ghInst; + wcex.hIcon = LoadIcon(ghInst, MAKEINTRESOURCE(IDI_ICON1)); + wcex.hCursor = LoadCursor(0, IDC_ARROW); + wcex.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); + wcex.lpszMenuName = "DIABLO"; + wcex.lpszClassName = "DIABLO"; + wcex.hIconSm = (HICON)LoadImage(ghInst, MAKEINTRESOURCE(IDI_ICON1), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); + if (!RegisterClassEx(&wcex)) + TermMsg("Unable to register window class"); + if (GetSystemMetrics(SM_CXSCREEN) >= 640) + nWidth = GetSystemMetrics(SM_CXSCREEN); + else + nWidth = 640; + if (GetSystemMetrics(SM_CYSCREEN) >= 480) + nHeight = GetSystemMetrics(SM_CYSCREEN); + else + nHeight = 480; + hWnd = CreateWindowEx(0, "DIABLO", "DIABLO", WS_POPUP, 0, 0, nWidth, nHeight, NULL, NULL, ghInst, NULL); + if (!hWnd) + TermMsg("Unable to create main window"); + ShowWindow(hWnd, SW_SHOWNORMAL); // nCmdShow used only in beta: ShowWindow(hWnd, nCmdShow) + UpdateWindow(hWnd); + init_await_mom_parent_exit(); + dx_init(hWnd); + BlackPalette(); + snd_init(hWnd); + init_archives(); + init_disable_screensaver(1); } void __cdecl init_kill_mom_parent() { - HWND v0; // eax + HWND v0; // eax - v0 = init_find_mom_parent(); - if (v0) { - PostMessage(v0, WM_CLOSE, 0, 0); - killed_mom_parent = 1; - } + v0 = init_find_mom_parent(); + if (v0) { + PostMessage(v0, WM_CLOSE, 0, 0); + killed_mom_parent = 1; + } } // 634CA0: using guessed type int killed_mom_parent; HWND __cdecl init_find_mom_parent() { - HWND i; // eax - HWND v1; // esi - char ClassName[256]; // [esp+4h] [ebp-100h] + HWND i; // eax + HWND v1; // esi + char ClassName[256]; // [esp+4h] [ebp-100h] - for (i = GetForegroundWindow();; i = GetWindow(v1, GW_HWNDNEXT)) { - v1 = i; - if (!i) - break; - GetClassName(i, ClassName, 255); - if (!_strcmpi(ClassName, "MOM Parent")) - break; - } - return v1; + for (i = GetForegroundWindow();; i = GetWindow(v1, GW_HWNDNEXT)) { + v1 = i; + if (!i) + break; + GetClassName(i, ClassName, 255); + if (!_strcmpi(ClassName, "MOM Parent")) + break; + } + return v1; } void __cdecl init_await_mom_parent_exit() { - DWORD v0; // edi + DWORD v0; // edi - v0 = GetTickCount(); - do { - if (!init_find_mom_parent()) - break; - Sleep(250); - } while (GetTickCount() - v0 <= 4000); + v0 = GetTickCount(); + do { + if (!init_find_mom_parent()) + break; + Sleep(250); + } while (GetTickCount() - v0 <= 4000); } void __cdecl init_archives() { - void *a1; // [esp+8h] [ebp-8h] + void *a1; // [esp+8h] [ebp-8h] #ifdef COPYPROT - int v1; // [esp+Ch] [ebp-4h] + int v1; // [esp+Ch] [ebp-4h] #endif - fileinfo.size = 20; - fileinfo.versionstring = gszVersionNumber; - fileinfo.executablefile = diablo_exe_path; - fileinfo.originalarchivefile = diabdat_mpq_path; - fileinfo.patcharchivefile = patch_rt_mpq_path; - init_get_file_info(); + fileinfo.size = 20; + fileinfo.versionstring = gszVersionNumber; + fileinfo.executablefile = diablo_exe_path; + fileinfo.originalarchivefile = diabdat_mpq_path; + fileinfo.patcharchivefile = patch_rt_mpq_path; + init_get_file_info(); #ifdef COPYPROT - while (1) { + while (1) { #endif - diabdat_mpq = init_test_access(diabdat_mpq_path, "\\diabdat.mpq", "DiabloCD", 1000, 1); + diabdat_mpq = init_test_access(diabdat_mpq_path, "\\diabdat.mpq", "DiabloCD", 1000, 1); #ifdef COPYPROT - if (diabdat_mpq) - break; - UiCopyProtError(&v1); - if (v1 == COPYPROT_CANCEL) - FileErrDlg("diabdat.mpq"); - } + if (diabdat_mpq) + break; + UiCopyProtError(&v1); + if (v1 == COPYPROT_CANCEL) + FileErrDlg("diabdat.mpq"); + } #endif - if (!WOpenFile("ui_art\\title.pcx", &a1, 1)) - FileErrDlg("Main program archive: diabdat.mpq"); - WCloseFile(a1); - patch_rt_mpq = init_test_access(patch_rt_mpq_path, "\\patch_rt.mpq", "DiabloInstall", 2000, 0); + if (!WOpenFile("ui_art\\title.pcx", &a1, 1)) + FileErrDlg("Main program archive: diabdat.mpq"); + WCloseFile(a1); + patch_rt_mpq = init_test_access(patch_rt_mpq_path, "\\patch_rt.mpq", "DiabloInstall", 2000, 0); } void *__fastcall init_test_access(char *mpq_path, char *mpq_name, char *reg_loc, int flags, bool on_cd) { - char *v5; // esi - char *v7; // eax - char Filename[260]; // [esp+Ch] [ebp-314h] - char Buffer[260]; // [esp+110h] [ebp-210h] - char v15[260]; // [esp+214h] [ebp-10Ch] - char *mpq_namea; // [esp+318h] [ebp-8h] - void *archive; // [esp+31Ch] [ebp-4h] + char *v5; // esi + char *v7; // eax + char Filename[260]; // [esp+Ch] [ebp-314h] + char Buffer[260]; // [esp+110h] [ebp-210h] + char v15[260]; // [esp+214h] [ebp-10Ch] + char *mpq_namea; // [esp+318h] [ebp-8h] + void *archive; // [esp+31Ch] [ebp-4h] - mpq_namea = mpq_name; - v5 = mpq_path; - if (!GetCurrentDirectory(0x104u, Buffer)) - TermMsg("Can't get program path"); - init_strip_trailing_slash(Buffer); - if (!SFileSetBasePath(Buffer)) - TermMsg("SFileSetBasePath"); - if (!GetModuleFileName(ghInst, Filename, 0x104u)) - TermMsg("Can't get program name"); - v7 = strrchr(Filename, '\\'); - if (v7) - *v7 = 0; - init_strip_trailing_slash(Filename); - strcpy(v5, Buffer); - strcat(v5, mpq_namea); + mpq_namea = mpq_name; + v5 = mpq_path; + if (!GetCurrentDirectory(0x104u, Buffer)) + TermMsg("Can't get program path"); + init_strip_trailing_slash(Buffer); + if (!SFileSetBasePath(Buffer)) + TermMsg("SFileSetBasePath"); + if (!GetModuleFileName(ghInst, Filename, 0x104u)) + TermMsg("Can't get program name"); + v7 = strrchr(Filename, '\\'); + if (v7) + *v7 = 0; + init_strip_trailing_slash(Filename); + strcpy(v5, Buffer); + strcat(v5, mpq_namea); #ifdef COPYPROT - if (SFileOpenArchive(v5, flags, on_cd, &archive)) + if (SFileOpenArchive(v5, flags, on_cd, &archive)) #else - if (SFileOpenArchive(v5, flags, 0, &archive)) + if (SFileOpenArchive(v5, flags, 0, &archive)) #endif - return archive; - if (strcmp(Filename, Buffer)) { - strcpy(v5, Filename); - strcat(v5, mpq_namea); + return archive; + if (strcmp(Filename, Buffer)) { + strcpy(v5, Filename); + strcat(v5, mpq_namea); #ifdef COPYPROT - if (SFileOpenArchive(v5, flags, on_cd, &archive)) + if (SFileOpenArchive(v5, flags, on_cd, &archive)) #else - if (SFileOpenArchive(v5, flags, 0, &archive)) + if (SFileOpenArchive(v5, flags, 0, &archive)) #endif - return archive; - } - v15[0] = 0; - if (reg_loc) { - if (SRegLoadString("Archives", (const char *)reg_loc, 0, v15, 260)) { - init_strip_trailing_slash(v15); - strcpy(v5, v15); - strcat(v5, mpq_namea); + return archive; + } + v15[0] = 0; + if (reg_loc) { + if (SRegLoadString("Archives", (const char *)reg_loc, 0, v15, 260)) { + init_strip_trailing_slash(v15); + strcpy(v5, v15); + strcat(v5, mpq_namea); #ifdef COPYPROT - if (SFileOpenArchive(v5, flags, on_cd, &archive)) + if (SFileOpenArchive(v5, flags, on_cd, &archive)) #else - if (SFileOpenArchive(v5, flags, 0, &archive)) + if (SFileOpenArchive(v5, flags, 0, &archive)) #endif - return archive; - } - } - if (on_cd && init_read_test_file(v15, mpq_namea, flags, &archive)) { - strcpy(v5, v15); - return archive; - } - return 0; + return archive; + } + } + if (on_cd && init_read_test_file(v15, mpq_namea, flags, &archive)) { + strcpy(v5, v15); + return archive; + } + return 0; } char *__fastcall init_strip_trailing_slash(char *path) { - char *result; // eax + char *result; // eax - result = strrchr(path, '\\'); - if (result) { - if (!result[1]) - *result = 0; - } - return result; + result = strrchr(path, '\\'); + if (result) { + if (!result[1]) + *result = 0; + } + return result; } int __fastcall init_read_test_file(char *mpq_path, char *mpq_name, int flags, void **archive) { - char *v4; // edi - DWORD v5; // eax - const char *v7; // ebx - const char *v8; // esi - char Buffer[260]; // [esp+Ch] [ebp-108h] - char *mpq_patha; // [esp+110h] [ebp-4h] + char *v4; // edi + DWORD v5; // eax + const char *v7; // ebx + const char *v8; // esi + char Buffer[260]; // [esp+Ch] [ebp-108h] + char *mpq_patha; // [esp+110h] [ebp-4h] - v4 = mpq_name; - mpq_patha = mpq_path; - v5 = GetLogicalDriveStrings(0x104u, Buffer); - if (!v5 || v5 > 0x104) - return 0; - while (*v4 == '\\') - ++v4; - v7 = Buffer; - if (!Buffer[0]) - return 0; - while (1) { - v8 = v7; - v7 += strlen(v7) + 1; - if (GetDriveType(v8) == DRIVE_CDROM) { - strcpy(mpq_patha, v8); - strcat(mpq_patha, v4); - if (SFileOpenArchive(mpq_patha, flags, 1, archive)) - break; - } - if (!*v7) - return 0; - } - return 1; + v4 = mpq_name; + mpq_patha = mpq_path; + v5 = GetLogicalDriveStrings(0x104u, Buffer); + if (!v5 || v5 > 0x104) + return 0; + while (*v4 == '\\') + ++v4; + v7 = Buffer; + if (!Buffer[0]) + return 0; + while (1) { + v8 = v7; + v7 += strlen(v7) + 1; + if (GetDriveType(v8) == DRIVE_CDROM) { + strcpy(mpq_patha, v8); + strcat(mpq_patha, v4); + if (SFileOpenArchive(mpq_patha, flags, 1, archive)) + break; + } + if (!*v7) + return 0; + } + return 1; } void __cdecl init_get_file_info() { - int v0; // eax - DWORD v1; // edi - void *v2; // ebx - unsigned int uBytes; // [esp+8h] [ebp-Ch] - DWORD dwHandle; // [esp+Ch] [ebp-8h] - VS_FIXEDFILEINFO *lpBuffer; // [esp+10h] [ebp-4h] + int v0; // eax + DWORD v1; // edi + void *v2; // ebx + unsigned int uBytes; // [esp+8h] [ebp-Ch] + DWORD dwHandle; // [esp+Ch] [ebp-8h] + VS_FIXEDFILEINFO *lpBuffer; // [esp+10h] [ebp-4h] - if (GetModuleFileName(ghInst, diablo_exe_path, 0x104u)) { - v0 = GetFileVersionInfoSize(diablo_exe_path, &dwHandle); - v1 = v0; - if (v0) { - v2 = DiabloAllocPtr(v0); - if (GetFileVersionInfo(diablo_exe_path, 0, v1, v2)) { - if (VerQueryValue(v2, "\\", (LPVOID *)&lpBuffer, &uBytes)) - sprintf( - gszVersionNumber, - "version %d.%d.%d.%d", - lpBuffer->dwProductVersionMS >> 16, - lpBuffer->dwProductVersionMS & 0xFFFF, - lpBuffer->dwProductVersionLS >> 16, - lpBuffer->dwProductVersionLS & 0xFFFF); - } - mem_free_dbg(v2); - } - } + if (GetModuleFileName(ghInst, diablo_exe_path, 0x104u)) { + v0 = GetFileVersionInfoSize(diablo_exe_path, &dwHandle); + v1 = v0; + if (v0) { + v2 = DiabloAllocPtr(v0); + if (GetFileVersionInfo(diablo_exe_path, 0, v1, v2)) { + if (VerQueryValue(v2, "\\", (LPVOID *)&lpBuffer, &uBytes)) + sprintf( + gszVersionNumber, + "version %d.%d.%d.%d", + lpBuffer->dwProductVersionMS >> 16, + lpBuffer->dwProductVersionMS & 0xFFFF, + lpBuffer->dwProductVersionLS >> 16, + lpBuffer->dwProductVersionLS & 0xFFFF); + } + mem_free_dbg(v2); + } + } } LRESULT __stdcall MainWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { - if (Msg > WM_ERASEBKGND) { - if (Msg == WM_ACTIVATEAPP) { - init_activate_window(hWnd, wParam); - } else { - if (Msg == WM_QUERYNEWPALETTE) { - SDrawRealizePalette(); - return 1; - } - if (Msg == WM_PALETTECHANGED && (HWND)wParam != hWnd) - SDrawRealizePalette(); - } - } else { - switch (Msg) { - case WM_ERASEBKGND: - return 0; - case WM_CREATE: - ghMainWnd = hWnd; - break; - case WM_DESTROY: - init_cleanup(1); - ghMainWnd = 0; - PostQuitMessage(0); - break; - case WM_PAINT: - drawpanflag = 255; - break; - case WM_CLOSE: - return 0; - } - } - return DefWindowProc(hWnd, Msg, wParam, lParam); + if (Msg > WM_ERASEBKGND) { + if (Msg == WM_ACTIVATEAPP) { + init_activate_window(hWnd, wParam); + } else { + if (Msg == WM_QUERYNEWPALETTE) { + SDrawRealizePalette(); + return 1; + } + if (Msg == WM_PALETTECHANGED && (HWND)wParam != hWnd) + SDrawRealizePalette(); + } + } else { + switch (Msg) { + case WM_ERASEBKGND: + return 0; + case WM_CREATE: + ghMainWnd = hWnd; + break; + case WM_DESTROY: + init_cleanup(1); + ghMainWnd = 0; + PostQuitMessage(0); + break; + case WM_PAINT: + drawpanflag = 255; + break; + case WM_CLOSE: + return 0; + } + } + return DefWindowProc(hWnd, Msg, wParam, lParam); } // 52571C: using guessed type int drawpanflag; void __fastcall init_activate_window(HWND hWnd, bool bActive) { - LONG dwNewLong; // eax + LONG dwNewLong; // eax - gbActive = bActive; - UiAppActivate(bActive); - dwNewLong = GetWindowLong(hWnd, GWL_STYLE); + gbActive = bActive; + UiAppActivate(bActive); + dwNewLong = GetWindowLong(hWnd, GWL_STYLE); - if (gbActive && fullscreen) - dwNewLong &= ~WS_SYSMENU; - else - dwNewLong |= WS_SYSMENU; + if (gbActive && fullscreen) + dwNewLong &= ~WS_SYSMENU; + else + dwNewLong |= WS_SYSMENU; - SetWindowLong(hWnd, GWL_STYLE, dwNewLong); + SetWindowLong(hWnd, GWL_STYLE, dwNewLong); - if (gbActive) { - drawpanflag = 255; - ResetPal(); - } + if (gbActive) { + drawpanflag = 255; + ResetPal(); + } } // 52571C: using guessed type int drawpanflag; // 634980: using guessed type int gbActive; LRESULT __stdcall WindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { - LRESULT result; // eax + LRESULT result; // eax - if (CurrentProc) - result = CurrentProc(hWnd, Msg, wParam, lParam); - else - result = MainWndProc(hWnd, Msg, wParam, lParam); - return result; + if (CurrentProc) + result = CurrentProc(hWnd, Msg, wParam, lParam); + else + result = MainWndProc(hWnd, Msg, wParam, lParam); + return result; } WNDPROC __fastcall SetWindowProc(WNDPROC NewProc) { - WNDPROC OldProc; // eax + WNDPROC OldProc; // eax - OldProc = CurrentProc; - CurrentProc = NewProc; - return OldProc; + OldProc = CurrentProc; + CurrentProc = NewProc; + return OldProc; } diff --git a/Source/interfac.cpp b/Source/interfac.cpp index 7e03a985..a59e1515 100644 --- a/Source/interfac.cpp +++ b/Source/interfac.cpp @@ -12,219 +12,219 @@ const unsigned char progress_bar_colours[3] = { 138u, 43u, 254u }; const int progress_bar_screen_pos[3][2] = { { 53, 37 }, { 53, 421 }, { 53, 37 } }; struct interfac_cpp_init { - interfac_cpp_init() - { - interfac_cpp_init_value = interfac_inf; - } + interfac_cpp_init() + { + interfac_cpp_init_value = interfac_inf; + } } _interfac_cpp_init; // 47AE40: using guessed type int interfac_inf; void __cdecl interface_msg_pump() { - MSG Msg; // [esp+8h] [ebp-1Ch] + MSG Msg; // [esp+8h] [ebp-1Ch] - while (PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE)) { - if (Msg.message != WM_QUIT) { - TranslateMessage(&Msg); - DispatchMessage(&Msg); - } - } + while (PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE)) { + if (Msg.message != WM_QUIT) { + TranslateMessage(&Msg); + DispatchMessage(&Msg); + } + } } bool __cdecl IncProgress() { - interface_msg_pump(); - sgdwProgress += 15; - if ((unsigned int)sgdwProgress > 0x216) - sgdwProgress = 534; - if (sgpBackCel) - DrawCutscene(); - return (unsigned int)sgdwProgress >= 0x216; + interface_msg_pump(); + sgdwProgress += 15; + if ((unsigned int)sgdwProgress > 0x216) + sgdwProgress = 534; + if (sgpBackCel) + DrawCutscene(); + return (unsigned int)sgdwProgress >= 0x216; } void __cdecl DrawCutscene() { - unsigned int v0; // esi + unsigned int v0; // esi - j_lock_buf_priv(1); - CelDecodeOnly(64, 639, sgpBackCel, 1, 640); - v0 = 0; - if (sgdwProgress) { - do - DrawProgress( - progress_bar_screen_pos[progress_id][0] + v0++ + 64, - progress_bar_screen_pos[progress_id][1] + 160, - progress_id); - while (v0 < sgdwProgress); - } - j_unlock_buf_priv(1); - drawpanflag = 255; - scrollrt_draw_game_screen(0); + j_lock_buf_priv(1); + CelDecodeOnly(64, 639, sgpBackCel, 1, 640); + v0 = 0; + if (sgdwProgress) { + do + DrawProgress( + progress_bar_screen_pos[progress_id][0] + v0++ + 64, + progress_bar_screen_pos[progress_id][1] + 160, + progress_id); + while (v0 < sgdwProgress); + } + j_unlock_buf_priv(1); + drawpanflag = 255; + scrollrt_draw_game_screen(0); } // 52571C: using guessed type int drawpanflag; void __fastcall DrawProgress(int screen_x, int screen_y, int progress_id) { - _BYTE *v3; // eax - signed int v4; // ecx + _BYTE *v3; // eax + signed int v4; // ecx - v3 = (unsigned char *)gpBuffer + screen_y_times_768[screen_y] + screen_x; - v4 = 22; - do { - *v3 = progress_bar_colours[progress_id]; - v3 += 768; - --v4; - } while (v4); + v3 = (unsigned char *)gpBuffer + screen_y_times_768[screen_y] + screen_x; + v4 = 22; + do { + *v3 = progress_bar_colours[progress_id]; + v3 += 768; + --v4; + } while (v4); } void __fastcall ShowProgress(int uMsg) { - WNDPROC saveProc; // edi - BOOL v3; // cl - int v4; // eax - int v5; // edx - signed int v7; // [esp-4h] [ebp-10h] + WNDPROC saveProc; // edi + BOOL v3; // cl + int v4; // eax + int v5; // edx + signed int v7; // [esp-4h] [ebp-10h] - gbSomebodyWonGameKludge = 0; - plrmsg_delay(1); - saveProc = SetWindowProc(DisableInputWndProc); - interface_msg_pump(); - ClearScreenBuffer(); - scrollrt_draw_game_screen(1); - InitCutscene(uMsg); - BlackPalette(); - DrawCutscene(); - PaletteFadeIn(8); - IncProgress(); - stream_update(); - IncProgress(); - switch (uMsg) { - case WM_DIABNEXTLVL: - IncProgress(); - if (gbMaxPlayers == 1) - SaveLevel(); - else - DeltaSaveLevel(); - FreeGameMem(); - v4 = ++currlevel; - goto LABEL_38; - case WM_DIABPREVLVL: - IncProgress(); - if (gbMaxPlayers == 1) - SaveLevel(); - else - DeltaSaveLevel(); - IncProgress(); - FreeGameMem(); - leveltype = gnLevelTypeTbl[--currlevel]; - IncProgress(); - v5 = 1; - goto LABEL_33; - case WM_DIABRTNLVL: - if (gbMaxPlayers == 1) - SaveLevel(); - else - DeltaSaveLevel(); - setlevel = 0; - FreeGameMem(); - IncProgress(); - GetReturnLvlPos(); - v7 = 3; - goto LABEL_32; - case WM_DIABSETLVL: - SetReturnLvlPos(); - if (gbMaxPlayers == 1) - SaveLevel(); - else - DeltaSaveLevel(); - setlevel = 1; - leveltype = setlvltype; - FreeGameMem(); - IncProgress(); - v7 = 2; - goto LABEL_32; - case WM_DIABWARPLVL: - IncProgress(); - if (gbMaxPlayers == 1) - SaveLevel(); - else - DeltaSaveLevel(); - FreeGameMem(); - GetPortalLevel(); - IncProgress(); - v7 = 5; - goto LABEL_32; - case WM_DIABTOWNWARP: - IncProgress(); - if (gbMaxPlayers == 1) - SaveLevel(); - else - DeltaSaveLevel(); - FreeGameMem(); - currlevel = plr[myplr].plrlevel; - leveltype = gnLevelTypeTbl[currlevel]; - IncProgress(); - v7 = 6; - goto LABEL_32; - case WM_DIABTWARPUP: - IncProgress(); - if (gbMaxPlayers == 1) - SaveLevel(); - else - DeltaSaveLevel(); - FreeGameMem(); - currlevel = plr[myplr].plrlevel; - leveltype = gnLevelTypeTbl[currlevel]; - IncProgress(); - v7 = 7; - LABEL_32: - v5 = v7; - LABEL_33: - v3 = FALSE; - goto LABEL_40; - case WM_DIABRETOWN: - IncProgress(); - if (gbMaxPlayers == 1) - SaveLevel(); - else - DeltaSaveLevel(); - FreeGameMem(); - currlevel = plr[myplr].plrlevel; - v4 = currlevel; - LABEL_38: - leveltype = gnLevelTypeTbl[v4]; - IncProgress(); - v3 = FALSE; - goto LABEL_39; - case WM_DIABNEWGAME: - IncProgress(); - FreeGameMem(); - IncProgress(); - pfile_remove_temp_files(); - v3 = TRUE; - LABEL_39: - v5 = 0; - LABEL_40: - LoadGameLevel(v3, v5); - goto LABEL_41; - case WM_DIABLOADGAME: - IncProgress(); - LoadGame(TRUE); - LABEL_41: - IncProgress(); - break; - default: - break; - } - PaletteFadeOut(8); - FreeInterface(); - SetWindowProc(saveProc); - NetSendCmdLocParam1(TRUE, CMD_PLAYER_JOINLEVEL, plr[myplr].WorldX, plr[myplr].WorldY, plr[myplr].plrlevel); - plrmsg_delay(0); - ResetPal(); - if (gbSomebodyWonGameKludge && plr[myplr].plrlevel == 16) - PrepDoEnding(); - gbSomebodyWonGameKludge = 0; + gbSomebodyWonGameKludge = 0; + plrmsg_delay(1); + saveProc = SetWindowProc(DisableInputWndProc); + interface_msg_pump(); + ClearScreenBuffer(); + scrollrt_draw_game_screen(1); + InitCutscene(uMsg); + BlackPalette(); + DrawCutscene(); + PaletteFadeIn(8); + IncProgress(); + stream_update(); + IncProgress(); + switch (uMsg) { + case WM_DIABNEXTLVL: + IncProgress(); + if (gbMaxPlayers == 1) + SaveLevel(); + else + DeltaSaveLevel(); + FreeGameMem(); + v4 = ++currlevel; + goto LABEL_38; + case WM_DIABPREVLVL: + IncProgress(); + if (gbMaxPlayers == 1) + SaveLevel(); + else + DeltaSaveLevel(); + IncProgress(); + FreeGameMem(); + leveltype = gnLevelTypeTbl[--currlevel]; + IncProgress(); + v5 = 1; + goto LABEL_33; + case WM_DIABRTNLVL: + if (gbMaxPlayers == 1) + SaveLevel(); + else + DeltaSaveLevel(); + setlevel = 0; + FreeGameMem(); + IncProgress(); + GetReturnLvlPos(); + v7 = 3; + goto LABEL_32; + case WM_DIABSETLVL: + SetReturnLvlPos(); + if (gbMaxPlayers == 1) + SaveLevel(); + else + DeltaSaveLevel(); + setlevel = 1; + leveltype = setlvltype; + FreeGameMem(); + IncProgress(); + v7 = 2; + goto LABEL_32; + case WM_DIABWARPLVL: + IncProgress(); + if (gbMaxPlayers == 1) + SaveLevel(); + else + DeltaSaveLevel(); + FreeGameMem(); + GetPortalLevel(); + IncProgress(); + v7 = 5; + goto LABEL_32; + case WM_DIABTOWNWARP: + IncProgress(); + if (gbMaxPlayers == 1) + SaveLevel(); + else + DeltaSaveLevel(); + FreeGameMem(); + currlevel = plr[myplr].plrlevel; + leveltype = gnLevelTypeTbl[currlevel]; + IncProgress(); + v7 = 6; + goto LABEL_32; + case WM_DIABTWARPUP: + IncProgress(); + if (gbMaxPlayers == 1) + SaveLevel(); + else + DeltaSaveLevel(); + FreeGameMem(); + currlevel = plr[myplr].plrlevel; + leveltype = gnLevelTypeTbl[currlevel]; + IncProgress(); + v7 = 7; + LABEL_32: + v5 = v7; + LABEL_33: + v3 = FALSE; + goto LABEL_40; + case WM_DIABRETOWN: + IncProgress(); + if (gbMaxPlayers == 1) + SaveLevel(); + else + DeltaSaveLevel(); + FreeGameMem(); + currlevel = plr[myplr].plrlevel; + v4 = currlevel; + LABEL_38: + leveltype = gnLevelTypeTbl[v4]; + IncProgress(); + v3 = FALSE; + goto LABEL_39; + case WM_DIABNEWGAME: + IncProgress(); + FreeGameMem(); + IncProgress(); + pfile_remove_temp_files(); + v3 = TRUE; + LABEL_39: + v5 = 0; + LABEL_40: + LoadGameLevel(v3, v5); + goto LABEL_41; + case WM_DIABLOADGAME: + IncProgress(); + LoadGame(TRUE); + LABEL_41: + IncProgress(); + break; + default: + break; + } + PaletteFadeOut(8); + FreeInterface(); + SetWindowProc(saveProc); + NetSendCmdLocParam1(TRUE, CMD_PLAYER_JOINLEVEL, plr[myplr].WorldX, plr[myplr].WorldY, plr[myplr].plrlevel); + plrmsg_delay(0); + ResetPal(); + if (gbSomebodyWonGameKludge && plr[myplr].plrlevel == 16) + PrepDoEnding(); + gbSomebodyWonGameKludge = 0; } // 5CF31C: using guessed type char setlvltype; // 5CF31D: using guessed type char setlevel; @@ -233,136 +233,136 @@ void __fastcall ShowProgress(int uMsg) void __cdecl FreeInterface() { - void *v0; // ecx + void *v0; // ecx - v0 = sgpBackCel; - sgpBackCel = 0; - mem_free_dbg(v0); + v0 = sgpBackCel; + sgpBackCel = 0; + mem_free_dbg(v0); } void __fastcall InitCutscene(int uMsg) { - int v1; // eax - int v2; // eax - int v3; // eax - int v4; // eax - unsigned char *v5; // eax - char *v6; // ecx - int *v7; // eax - int v8; // eax - int v9; // eax - int v10; // eax - int v11; // eax - int v12; // eax - int v13; // eax - int v14; // eax + int v1; // eax + int v2; // eax + int v3; // eax + int v4; // eax + unsigned char *v5; // eax + char *v6; // ecx + int *v7; // eax + int v8; // eax + int v9; // eax + int v10; // eax + int v11; // eax + int v12; // eax + int v13; // eax + int v14; // eax - switch (uMsg) { - case WM_DIABNEXTLVL: - v1 = gnLevelTypeTbl[currlevel]; - if (!v1) - goto LABEL_31; - v2 = v1 - 1; - if (!v2) - goto LABEL_10; - v3 = v2 - 1; - if (!v3) - goto LABEL_9; - v4 = v3 - 1; - if (!v4) - goto LABEL_29; - if (v4 != 1) - goto LABEL_10; - if (currlevel < 0xFu) - goto LABEL_28; - v5 = LoadFileInMem("Gendata\\Cutgate.CEL", 0); - v6 = "Gendata\\Cutgate.pal"; - goto LABEL_30; - case WM_DIABPREVLVL: - v7 = &gnLevelTypeTbl[currlevel]; - if (!*(v7 - 1)) - goto LABEL_31; - v8 = *v7; - if (!v8) - goto LABEL_31; - v9 = v8 - 1; - if (!v9) - goto LABEL_10; - v10 = v9 - 1; - if (!v10) { - LABEL_9: - sgpBackCel = LoadFileInMem("Gendata\\Cut2.CEL", 0); - LoadPalette("Gendata\\Cut2.pal"); - progress_id = 2; - goto LABEL_33; - } - v11 = v10 - 1; - if (!v11) - goto LABEL_29; - if (v11 == 1) - goto LABEL_28; - LABEL_10: - sgpBackCel = LoadFileInMem("Gendata\\Cutl1d.CEL", 0); - LoadPalette("Gendata\\Cutl1d.pal"); - progress_id = 0; - goto LABEL_33; - case WM_DIABRTNLVL: - case WM_DIABSETLVL: - if (setlvlnum == SL_BONECHAMB) - goto LABEL_21; - if (setlvlnum != SL_VILEBETRAYER) - goto LABEL_10; - v5 = LoadFileInMem("Gendata\\Cutportr.CEL", 0); - v6 = "Gendata\\Cutportr.pal"; - goto LABEL_30; - case WM_DIABWARPLVL: - v5 = LoadFileInMem("Gendata\\Cutportl.CEL", 0); - v6 = "Gendata\\Cutportl.pal"; - goto LABEL_30; - case WM_DIABTOWNWARP: - case WM_DIABTWARPUP: - v12 = gnLevelTypeTbl[plr[myplr].plrlevel]; - if (!v12) - goto LABEL_31; - v13 = v12 - 2; - if (!v13) { - LABEL_21: - sgpBackCel = LoadFileInMem("Gendata\\Cut2.CEL", 0); - LoadPalette("Gendata\\Cut2.pal"); - progress_id = SL_BONECHAMB; - goto LABEL_33; - } - v14 = v13 - 1; - if (v14) { - if (v14 != 1) - goto LABEL_33; - LABEL_28: - v5 = LoadFileInMem("Gendata\\Cut4.CEL", 0); - v6 = "Gendata\\Cut4.pal"; - } else { - LABEL_29: - v5 = LoadFileInMem("Gendata\\Cut3.CEL", 0); - v6 = "Gendata\\Cut3.pal"; - } - LABEL_30: - sgpBackCel = v5; - LoadPalette(v6); - progress_id = 1; - LABEL_33: - sgdwProgress = 0; - return; - case WM_DIABRETOWN: - LABEL_31: - v5 = LoadFileInMem("Gendata\\Cuttt.CEL", 0); - v6 = "Gendata\\Cuttt.pal"; - goto LABEL_30; - case WM_DIABNEWGAME: - case WM_DIABLOADGAME: - v5 = LoadFileInMem("Gendata\\Cutstart.CEL", 0); - v6 = "Gendata\\Cutstart.pal"; - goto LABEL_30; - default: - TermMsg("Unknown progress mode"); - goto LABEL_33; - } + switch (uMsg) { + case WM_DIABNEXTLVL: + v1 = gnLevelTypeTbl[currlevel]; + if (!v1) + goto LABEL_31; + v2 = v1 - 1; + if (!v2) + goto LABEL_10; + v3 = v2 - 1; + if (!v3) + goto LABEL_9; + v4 = v3 - 1; + if (!v4) + goto LABEL_29; + if (v4 != 1) + goto LABEL_10; + if (currlevel < 0xFu) + goto LABEL_28; + v5 = LoadFileInMem("Gendata\\Cutgate.CEL", 0); + v6 = "Gendata\\Cutgate.pal"; + goto LABEL_30; + case WM_DIABPREVLVL: + v7 = &gnLevelTypeTbl[currlevel]; + if (!*(v7 - 1)) + goto LABEL_31; + v8 = *v7; + if (!v8) + goto LABEL_31; + v9 = v8 - 1; + if (!v9) + goto LABEL_10; + v10 = v9 - 1; + if (!v10) { + LABEL_9: + sgpBackCel = LoadFileInMem("Gendata\\Cut2.CEL", 0); + LoadPalette("Gendata\\Cut2.pal"); + progress_id = 2; + goto LABEL_33; + } + v11 = v10 - 1; + if (!v11) + goto LABEL_29; + if (v11 == 1) + goto LABEL_28; + LABEL_10: + sgpBackCel = LoadFileInMem("Gendata\\Cutl1d.CEL", 0); + LoadPalette("Gendata\\Cutl1d.pal"); + progress_id = 0; + goto LABEL_33; + case WM_DIABRTNLVL: + case WM_DIABSETLVL: + if (setlvlnum == SL_BONECHAMB) + goto LABEL_21; + if (setlvlnum != SL_VILEBETRAYER) + goto LABEL_10; + v5 = LoadFileInMem("Gendata\\Cutportr.CEL", 0); + v6 = "Gendata\\Cutportr.pal"; + goto LABEL_30; + case WM_DIABWARPLVL: + v5 = LoadFileInMem("Gendata\\Cutportl.CEL", 0); + v6 = "Gendata\\Cutportl.pal"; + goto LABEL_30; + case WM_DIABTOWNWARP: + case WM_DIABTWARPUP: + v12 = gnLevelTypeTbl[plr[myplr].plrlevel]; + if (!v12) + goto LABEL_31; + v13 = v12 - 2; + if (!v13) { + LABEL_21: + sgpBackCel = LoadFileInMem("Gendata\\Cut2.CEL", 0); + LoadPalette("Gendata\\Cut2.pal"); + progress_id = SL_BONECHAMB; + goto LABEL_33; + } + v14 = v13 - 1; + if (v14) { + if (v14 != 1) + goto LABEL_33; + LABEL_28: + v5 = LoadFileInMem("Gendata\\Cut4.CEL", 0); + v6 = "Gendata\\Cut4.pal"; + } else { + LABEL_29: + v5 = LoadFileInMem("Gendata\\Cut3.CEL", 0); + v6 = "Gendata\\Cut3.pal"; + } + LABEL_30: + sgpBackCel = v5; + LoadPalette(v6); + progress_id = 1; + LABEL_33: + sgdwProgress = 0; + return; + case WM_DIABRETOWN: + LABEL_31: + v5 = LoadFileInMem("Gendata\\Cuttt.CEL", 0); + v6 = "Gendata\\Cuttt.pal"; + goto LABEL_30; + case WM_DIABNEWGAME: + case WM_DIABLOADGAME: + v5 = LoadFileInMem("Gendata\\Cutstart.CEL", 0); + v6 = "Gendata\\Cutstart.pal"; + goto LABEL_30; + default: + TermMsg("Unknown progress mode"); + goto LABEL_33; + } } diff --git a/Source/inv.cpp b/Source/inv.cpp index dbd1989f..76ebc8da 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -8,7 +8,7 @@ int drawsbarflag; // idb int sgdwLastTime; // check name const InvXY InvRect[73] = { - // clang-format off + // clang-format off // X, Y { 452, 31 }, // helmet { 480, 31 }, // helmet @@ -83,7 +83,7 @@ const InvXY InvRect[73] = { { 350, 385 }, // belt { 379, 385 }, // belt { 408, 385 } // belt - // clang-format on + // clang-format on }; /* data */ @@ -92,299 +92,299 @@ int AP2x2Tbl[10] = { 8, 28, 6, 26, 4, 24, 2, 22, 0, 20 }; // weak void __cdecl FreeInvGFX() { - void *invCels = pInvCels; + void *invCels = pInvCels; - pInvCels = NULL; - mem_free_dbg(invCels); + pInvCels = NULL; + mem_free_dbg(invCels); } void __cdecl InitInv() { - if (plr[myplr]._pClass == PC_WARRIOR) { - pInvCels = LoadFileInMem("Data\\Inv\\Inv.CEL", 0); - } else if (plr[myplr]._pClass == PC_ROGUE) { - pInvCels = LoadFileInMem("Data\\Inv\\Inv_rog.CEL", 0); - } else if (plr[myplr]._pClass == PC_SORCERER) { - pInvCels = LoadFileInMem("Data\\Inv\\Inv_Sor.CEL", 0); - } + if (plr[myplr]._pClass == PC_WARRIOR) { + pInvCels = LoadFileInMem("Data\\Inv\\Inv.CEL", 0); + } else if (plr[myplr]._pClass == PC_ROGUE) { + pInvCels = LoadFileInMem("Data\\Inv\\Inv_rog.CEL", 0); + } else if (plr[myplr]._pClass == PC_SORCERER) { + pInvCels = LoadFileInMem("Data\\Inv\\Inv_Sor.CEL", 0); + } - invflag = 0; - drawsbarflag = 0; + invflag = 0; + drawsbarflag = 0; } void __fastcall InvDrawSlotBack(int X, int Y, int W, int H) { - unsigned char *v4; // edi - int v5; // edx - int v6; // ecx - unsigned char v7; // al - unsigned char v8; // al + unsigned char *v4; // edi + int v5; // edx + int v6; // ecx + unsigned char v7; // al + unsigned char v8; // al - v4 = (unsigned char *)gpBuffer + screen_y_times_768[Y] + X; - v5 = (unsigned short)H; - do { - v6 = (unsigned short)W; - do { - v7 = *v4; - if (*v4 < 0xB0u) - goto LABEL_9; - if (v7 > 0xBFu) { - if (v7 < 0xF0u) - goto LABEL_9; - v8 = v7 - 80; - } else { - v8 = v7 - 16; - } - *v4 = v8; - LABEL_9: - ++v4; - --v6; - } while (v6); - v4 = &v4[-(unsigned short)W - 768]; - --v5; - } while (v5); + v4 = (unsigned char *)gpBuffer + screen_y_times_768[Y] + X; + v5 = (unsigned short)H; + do { + v6 = (unsigned short)W; + do { + v7 = *v4; + if (*v4 < 0xB0u) + goto LABEL_9; + if (v7 > 0xBFu) { + if (v7 < 0xF0u) + goto LABEL_9; + v8 = v7 - 80; + } else { + v8 = v7 - 16; + } + *v4 = v8; + LABEL_9: + ++v4; + --v6; + } while (v6); + v4 = &v4[-(unsigned short)W - 768]; + --v5; + } while (v5); } void __cdecl DrawInv() { - BOOL invtest[40]; + BOOL invtest[40]; - CelDecodeOnly(384, 511, pInvCels, 1, 320); + CelDecodeOnly(384, 511, pInvCels, 1, 320); - if (plr[myplr].InvBody[INVLOC_HEAD]._itype != ITYPE_NONE) { - InvDrawSlotBack(517, 219, 2 * INV_SLOT_SIZE_PX, 2 * INV_SLOT_SIZE_PX); + if (plr[myplr].InvBody[INVLOC_HEAD]._itype != ITYPE_NONE) { + InvDrawSlotBack(517, 219, 2 * INV_SLOT_SIZE_PX, 2 * INV_SLOT_SIZE_PX); - int frame = plr[myplr].InvBody[INVLOC_HEAD]._iCurs + 12; - int frame_width = InvItemWidth[frame]; + int frame = plr[myplr].InvBody[INVLOC_HEAD]._iCurs + 12; + int frame_width = InvItemWidth[frame]; - if (pcursinvitem == INVITEM_HEAD) { - int colour = ICOL_WHITE; - if (plr[myplr].InvBody[INVLOC_HEAD]._iMagical != ITEM_QUALITY_NORMAL) { - colour = ICOL_BLUE; - } - if (!plr[myplr].InvBody[INVLOC_HEAD]._iStatFlag) { - colour = ICOL_RED; - } - CelDecodeClr(colour, 517, 219, (char *)pCursCels, frame, frame_width, 0, 8); - } + if (pcursinvitem == INVITEM_HEAD) { + int colour = ICOL_WHITE; + if (plr[myplr].InvBody[INVLOC_HEAD]._iMagical != ITEM_QUALITY_NORMAL) { + colour = ICOL_BLUE; + } + if (!plr[myplr].InvBody[INVLOC_HEAD]._iStatFlag) { + colour = ICOL_RED; + } + CelDecodeClr(colour, 517, 219, (char *)pCursCels, frame, frame_width, 0, 8); + } - if (plr[myplr].InvBody[INVLOC_HEAD]._iStatFlag) { - CelDrawHdrOnly(517, 219, (char *)pCursCels, frame, frame_width, 0, 8); - } else { - CelDrawHdrLightRed(517, 219, (char *)pCursCels, frame, frame_width, 0, 8, 1); - } - } + if (plr[myplr].InvBody[INVLOC_HEAD]._iStatFlag) { + CelDrawHdrOnly(517, 219, (char *)pCursCels, frame, frame_width, 0, 8); + } else { + CelDrawHdrLightRed(517, 219, (char *)pCursCels, frame, frame_width, 0, 8, 1); + } + } - if (plr[myplr].InvBody[INVLOC_RING_LEFT]._itype != ITYPE_NONE) { - InvDrawSlotBack(432, 365, INV_SLOT_SIZE_PX, INV_SLOT_SIZE_PX); + if (plr[myplr].InvBody[INVLOC_RING_LEFT]._itype != ITYPE_NONE) { + InvDrawSlotBack(432, 365, INV_SLOT_SIZE_PX, INV_SLOT_SIZE_PX); - int frame = plr[myplr].InvBody[INVLOC_RING_LEFT]._iCurs + 12; - int frame_width = InvItemWidth[frame]; + int frame = plr[myplr].InvBody[INVLOC_RING_LEFT]._iCurs + 12; + int frame_width = InvItemWidth[frame]; - if (pcursinvitem == INVITEM_RING_LEFT) { - int colour = ICOL_WHITE; - if (plr[myplr].InvBody[INVLOC_RING_LEFT]._iMagical != ITEM_QUALITY_NORMAL) { - colour = ICOL_BLUE; - } - if (!plr[myplr].InvBody[INVLOC_RING_LEFT]._iStatFlag) { - colour = ICOL_RED; - } - CelDecodeClr(colour, 432, 365, (char *)pCursCels, frame, frame_width, 0, 8); - } + if (pcursinvitem == INVITEM_RING_LEFT) { + int colour = ICOL_WHITE; + if (plr[myplr].InvBody[INVLOC_RING_LEFT]._iMagical != ITEM_QUALITY_NORMAL) { + colour = ICOL_BLUE; + } + if (!plr[myplr].InvBody[INVLOC_RING_LEFT]._iStatFlag) { + colour = ICOL_RED; + } + CelDecodeClr(colour, 432, 365, (char *)pCursCels, frame, frame_width, 0, 8); + } - if (plr[myplr].InvBody[INVLOC_RING_LEFT]._iStatFlag) { - CelDrawHdrOnly(432, 365, (char *)pCursCels, frame, frame_width, 0, 8); - } else { - CelDrawHdrLightRed(432, 365, (char *)pCursCels, frame, frame_width, 0, 8, 1); - } - } + if (plr[myplr].InvBody[INVLOC_RING_LEFT]._iStatFlag) { + CelDrawHdrOnly(432, 365, (char *)pCursCels, frame, frame_width, 0, 8); + } else { + CelDrawHdrLightRed(432, 365, (char *)pCursCels, frame, frame_width, 0, 8, 1); + } + } - if (plr[myplr].InvBody[INVLOC_RING_RIGHT]._itype != ITYPE_NONE) { - InvDrawSlotBack(633, 365, INV_SLOT_SIZE_PX, INV_SLOT_SIZE_PX); + if (plr[myplr].InvBody[INVLOC_RING_RIGHT]._itype != ITYPE_NONE) { + InvDrawSlotBack(633, 365, INV_SLOT_SIZE_PX, INV_SLOT_SIZE_PX); - int frame = plr[myplr].InvBody[INVLOC_RING_RIGHT]._iCurs + 12; - int frame_width = InvItemWidth[frame]; + int frame = plr[myplr].InvBody[INVLOC_RING_RIGHT]._iCurs + 12; + int frame_width = InvItemWidth[frame]; - if (pcursinvitem == INVITEM_RING_RIGHT) { - int colour = ICOL_WHITE; - if (plr[myplr].InvBody[INVLOC_RING_RIGHT]._iMagical != ITEM_QUALITY_NORMAL) { - colour = ICOL_BLUE; - } - if (!plr[myplr].InvBody[INVLOC_RING_RIGHT]._iStatFlag) { - colour = ICOL_RED; - } - CelDecodeClr(colour, 633, 365, (char *)pCursCels, frame, frame_width, 0, 8); - } + if (pcursinvitem == INVITEM_RING_RIGHT) { + int colour = ICOL_WHITE; + if (plr[myplr].InvBody[INVLOC_RING_RIGHT]._iMagical != ITEM_QUALITY_NORMAL) { + colour = ICOL_BLUE; + } + if (!plr[myplr].InvBody[INVLOC_RING_RIGHT]._iStatFlag) { + colour = ICOL_RED; + } + CelDecodeClr(colour, 633, 365, (char *)pCursCels, frame, frame_width, 0, 8); + } - if (plr[myplr].InvBody[INVLOC_RING_RIGHT]._iStatFlag) { - CelDrawHdrOnly(633, 365, (char *)pCursCels, frame, frame_width, 0, 8); - } else { - CelDrawHdrLightRed(633, 365, (char *)pCursCels, frame, frame_width, 0, 8, 1); - } - } + if (plr[myplr].InvBody[INVLOC_RING_RIGHT]._iStatFlag) { + CelDrawHdrOnly(633, 365, (char *)pCursCels, frame, frame_width, 0, 8); + } else { + CelDrawHdrLightRed(633, 365, (char *)pCursCels, frame, frame_width, 0, 8, 1); + } + } - if (plr[myplr].InvBody[INVLOC_AMULET]._itype != ITYPE_NONE) { - InvDrawSlotBack(589, 220, INV_SLOT_SIZE_PX, INV_SLOT_SIZE_PX); + if (plr[myplr].InvBody[INVLOC_AMULET]._itype != ITYPE_NONE) { + InvDrawSlotBack(589, 220, INV_SLOT_SIZE_PX, INV_SLOT_SIZE_PX); - int frame = plr[myplr].InvBody[INVLOC_AMULET]._iCurs + 12; - int frame_width = InvItemWidth[frame]; + int frame = plr[myplr].InvBody[INVLOC_AMULET]._iCurs + 12; + int frame_width = InvItemWidth[frame]; - if (pcursinvitem == INVITEM_AMULET) { - int colour = ICOL_WHITE; - if (plr[myplr].InvBody[INVLOC_AMULET]._iMagical != ITEM_QUALITY_NORMAL) { - colour = ICOL_BLUE; - } - if (!plr[myplr].InvBody[INVLOC_AMULET]._iStatFlag) { - colour = ICOL_RED; - } - CelDecodeClr(colour, 589, 220, (char *)pCursCels, frame, frame_width, 0, 8); - } + if (pcursinvitem == INVITEM_AMULET) { + int colour = ICOL_WHITE; + if (plr[myplr].InvBody[INVLOC_AMULET]._iMagical != ITEM_QUALITY_NORMAL) { + colour = ICOL_BLUE; + } + if (!plr[myplr].InvBody[INVLOC_AMULET]._iStatFlag) { + colour = ICOL_RED; + } + CelDecodeClr(colour, 589, 220, (char *)pCursCels, frame, frame_width, 0, 8); + } - if (plr[myplr].InvBody[INVLOC_AMULET]._iStatFlag) { - CelDrawHdrOnly(589, 220, (char *)pCursCels, frame, frame_width, 0, 8); - } else { - CelDrawHdrLightRed(589, 220, (char *)pCursCels, frame, frame_width, 0, 8, 1); - } - } + if (plr[myplr].InvBody[INVLOC_AMULET]._iStatFlag) { + CelDrawHdrOnly(589, 220, (char *)pCursCels, frame, frame_width, 0, 8); + } else { + CelDrawHdrLightRed(589, 220, (char *)pCursCels, frame, frame_width, 0, 8, 1); + } + } - if (plr[myplr].InvBody[INVLOC_HAND_LEFT]._itype != ITYPE_NONE) { - InvDrawSlotBack(401, 320, 2 * INV_SLOT_SIZE_PX, 3 * INV_SLOT_SIZE_PX); + if (plr[myplr].InvBody[INVLOC_HAND_LEFT]._itype != ITYPE_NONE) { + InvDrawSlotBack(401, 320, 2 * INV_SLOT_SIZE_PX, 3 * INV_SLOT_SIZE_PX); - int frame = plr[myplr].InvBody[INVLOC_HAND_LEFT]._iCurs + 12; - int frame_width = InvItemWidth[frame]; - // calc item offsets for weapons smaller than 2x3 slots - int screen_x = frame_width == INV_SLOT_SIZE_PX ? 415 : 401; - int screen_y = InvItemHeight[frame] == (3 * INV_SLOT_SIZE_PX) ? 320 : 306; + int frame = plr[myplr].InvBody[INVLOC_HAND_LEFT]._iCurs + 12; + int frame_width = InvItemWidth[frame]; + // calc item offsets for weapons smaller than 2x3 slots + int screen_x = frame_width == INV_SLOT_SIZE_PX ? 415 : 401; + int screen_y = InvItemHeight[frame] == (3 * INV_SLOT_SIZE_PX) ? 320 : 306; - if (pcursinvitem == INVITEM_HAND_LEFT) { - int colour = ICOL_WHITE; - if (plr[myplr].InvBody[INVLOC_HAND_LEFT]._iMagical != ITEM_QUALITY_NORMAL) { - colour = ICOL_BLUE; - } - if (!plr[myplr].InvBody[INVLOC_HAND_LEFT]._iStatFlag) { - colour = ICOL_RED; - } - CelDecodeClr(colour, screen_x, screen_y, (char *)pCursCels, frame, frame_width, 0, 8); - } + if (pcursinvitem == INVITEM_HAND_LEFT) { + int colour = ICOL_WHITE; + if (plr[myplr].InvBody[INVLOC_HAND_LEFT]._iMagical != ITEM_QUALITY_NORMAL) { + colour = ICOL_BLUE; + } + if (!plr[myplr].InvBody[INVLOC_HAND_LEFT]._iStatFlag) { + colour = ICOL_RED; + } + CelDecodeClr(colour, screen_x, screen_y, (char *)pCursCels, frame, frame_width, 0, 8); + } - if (plr[myplr].InvBody[INVLOC_HAND_LEFT]._iStatFlag) { - CelDrawHdrOnly(screen_x, screen_y, (char *)pCursCels, frame, frame_width, 0, 8); - } else { - CelDrawHdrLightRed(screen_x, screen_y, (char *)pCursCels, frame, frame_width, 0, 8, 1); - } + if (plr[myplr].InvBody[INVLOC_HAND_LEFT]._iStatFlag) { + CelDrawHdrOnly(screen_x, screen_y, (char *)pCursCels, frame, frame_width, 0, 8); + } else { + CelDrawHdrLightRed(screen_x, screen_y, (char *)pCursCels, frame, frame_width, 0, 8, 1); + } - if (plr[myplr].InvBody[INVLOC_HAND_LEFT]._iLoc == ILOC_TWOHAND) { - InvDrawSlotBack(631, 320, 2 * INV_SLOT_SIZE_PX, 3 * INV_SLOT_SIZE_PX); - light_table_index = 0; - cel_transparency_active = 1; + if (plr[myplr].InvBody[INVLOC_HAND_LEFT]._iLoc == ILOC_TWOHAND) { + InvDrawSlotBack(631, 320, 2 * INV_SLOT_SIZE_PX, 3 * INV_SLOT_SIZE_PX); + light_table_index = 0; + cel_transparency_active = 1; - CelDecodeHdrLightTrans( - frame_width == INV_SLOT_SIZE_PX - ? &gpBuffer->row[160].pixels[581] - : &gpBuffer->row[160].pixels[567], - (char *)pCursCels, frame, frame_width, 0, 8); + CelDecodeHdrLightTrans( + frame_width == INV_SLOT_SIZE_PX + ? &gpBuffer->row[160].pixels[581] + : &gpBuffer->row[160].pixels[567], + (char *)pCursCels, frame, frame_width, 0, 8); - cel_transparency_active = 0; - } - } - if (plr[myplr].InvBody[INVLOC_HAND_RIGHT]._itype != ITYPE_NONE) { - InvDrawSlotBack(631, 320, 2 * INV_SLOT_SIZE_PX, 3 * INV_SLOT_SIZE_PX); + cel_transparency_active = 0; + } + } + if (plr[myplr].InvBody[INVLOC_HAND_RIGHT]._itype != ITYPE_NONE) { + InvDrawSlotBack(631, 320, 2 * INV_SLOT_SIZE_PX, 3 * INV_SLOT_SIZE_PX); - int frame = plr[myplr].InvBody[INVLOC_HAND_RIGHT]._iCurs + 12; - int frame_width = InvItemWidth[frame]; - // calc item offsets for weapons smaller than 2x3 slots - int screen_x = frame_width == INV_SLOT_SIZE_PX ? 645 : 633; - int screen_y = InvItemHeight[frame] == 3 * INV_SLOT_SIZE_PX ? 320 : 306; + int frame = plr[myplr].InvBody[INVLOC_HAND_RIGHT]._iCurs + 12; + int frame_width = InvItemWidth[frame]; + // calc item offsets for weapons smaller than 2x3 slots + int screen_x = frame_width == INV_SLOT_SIZE_PX ? 645 : 633; + int screen_y = InvItemHeight[frame] == 3 * INV_SLOT_SIZE_PX ? 320 : 306; - if (pcursinvitem == INVITEM_HAND_RIGHT) { - int colour = ICOL_WHITE; - if (plr[myplr].InvBody[INVLOC_HAND_RIGHT]._iMagical != ITEM_QUALITY_NORMAL) { - colour = ICOL_BLUE; - } - if (!plr[myplr].InvBody[INVLOC_HAND_RIGHT]._iStatFlag) { - colour = ICOL_RED; - } - CelDecodeClr(colour, screen_x, screen_y, (char *)pCursCels, frame, frame_width, 0, 8); - } + if (pcursinvitem == INVITEM_HAND_RIGHT) { + int colour = ICOL_WHITE; + if (plr[myplr].InvBody[INVLOC_HAND_RIGHT]._iMagical != ITEM_QUALITY_NORMAL) { + colour = ICOL_BLUE; + } + if (!plr[myplr].InvBody[INVLOC_HAND_RIGHT]._iStatFlag) { + colour = ICOL_RED; + } + CelDecodeClr(colour, screen_x, screen_y, (char *)pCursCels, frame, frame_width, 0, 8); + } - if (plr[myplr].InvBody[INVLOC_HAND_RIGHT]._iStatFlag) { - CelDrawHdrOnly(screen_x, screen_y, (char *)pCursCels, frame, frame_width, 0, 8); - } else { - CelDrawHdrLightRed(screen_x, screen_y, (char *)pCursCels, frame, frame_width, 0, 8, 1); - } - } + if (plr[myplr].InvBody[INVLOC_HAND_RIGHT]._iStatFlag) { + CelDrawHdrOnly(screen_x, screen_y, (char *)pCursCels, frame, frame_width, 0, 8); + } else { + CelDrawHdrLightRed(screen_x, screen_y, (char *)pCursCels, frame, frame_width, 0, 8, 1); + } + } - if (plr[myplr].InvBody[INVLOC_CHEST]._itype != ITYPE_NONE) { - InvDrawSlotBack(517, 320, 2 * INV_SLOT_SIZE_PX, 3 * INV_SLOT_SIZE_PX); + if (plr[myplr].InvBody[INVLOC_CHEST]._itype != ITYPE_NONE) { + InvDrawSlotBack(517, 320, 2 * INV_SLOT_SIZE_PX, 3 * INV_SLOT_SIZE_PX); - int frame = plr[myplr].InvBody[INVLOC_CHEST]._iCurs + 12; - int frame_width = InvItemWidth[frame]; + int frame = plr[myplr].InvBody[INVLOC_CHEST]._iCurs + 12; + int frame_width = InvItemWidth[frame]; - if (pcursinvitem == INVITEM_CHEST) { - int colour = ICOL_WHITE; - if (plr[myplr].InvBody[INVLOC_CHEST]._iMagical != ITEM_QUALITY_NORMAL) { - colour = ICOL_BLUE; - } - if (!plr[myplr].InvBody[INVLOC_CHEST]._iStatFlag) { - colour = ICOL_RED; - } - CelDecodeClr(colour, 517, 320, (char *)pCursCels, frame, frame_width, 0, 8); - } + if (pcursinvitem == INVITEM_CHEST) { + int colour = ICOL_WHITE; + if (plr[myplr].InvBody[INVLOC_CHEST]._iMagical != ITEM_QUALITY_NORMAL) { + colour = ICOL_BLUE; + } + if (!plr[myplr].InvBody[INVLOC_CHEST]._iStatFlag) { + colour = ICOL_RED; + } + CelDecodeClr(colour, 517, 320, (char *)pCursCels, frame, frame_width, 0, 8); + } - if (plr[myplr].InvBody[INVLOC_CHEST]._iStatFlag) { - CelDrawHdrOnly(517, 320, (char *)pCursCels, frame, frame_width, 0, 8); - } else { - CelDrawHdrLightRed(517, 320, (char *)pCursCels, frame, frame_width, 0, 8, 1); - } - } + if (plr[myplr].InvBody[INVLOC_CHEST]._iStatFlag) { + CelDrawHdrOnly(517, 320, (char *)pCursCels, frame, frame_width, 0, 8); + } else { + CelDrawHdrLightRed(517, 320, (char *)pCursCels, frame, frame_width, 0, 8, 1); + } + } - for (int i = 0; i < NUM_INV_GRID_ELEM; i++) { - if (plr[myplr].InvGrid[i] != 0) { - InvDrawSlotBack( - InvRect[i + SLOTXY_INV_FIRST].X + 64, - InvRect[i + SLOTXY_INV_FIRST].Y + 159, - INV_SLOT_SIZE_PX, - INV_SLOT_SIZE_PX); - } - } + for (int i = 0; i < NUM_INV_GRID_ELEM; i++) { + if (plr[myplr].InvGrid[i] != 0) { + InvDrawSlotBack( + InvRect[i + SLOTXY_INV_FIRST].X + 64, + InvRect[i + SLOTXY_INV_FIRST].Y + 159, + INV_SLOT_SIZE_PX, + INV_SLOT_SIZE_PX); + } + } - for (int j = 0; j < NUM_INV_GRID_ELEM; j++) { - if (plr[myplr].InvGrid[j] > 0) // first slot of an item - { - int ii = plr[myplr].InvGrid[j] - 1; + for (int j = 0; j < NUM_INV_GRID_ELEM; j++) { + if (plr[myplr].InvGrid[j] > 0) // first slot of an item + { + int ii = plr[myplr].InvGrid[j] - 1; - invtest[j] = TRUE; + invtest[j] = TRUE; - int frame = plr[myplr].InvList[ii]._iCurs + 12; - int frame_width = InvItemWidth[frame]; - if (pcursinvitem == ii + INVITEM_INV_FIRST) { - int colour = ICOL_WHITE; - if (plr[myplr].InvList[ii]._iMagical != ITEM_QUALITY_NORMAL) { - colour = ICOL_BLUE; - } - if (!plr[myplr].InvList[ii]._iStatFlag) { - colour = ICOL_RED; - } - CelDecodeClr( - colour, - InvRect[j + SLOTXY_INV_FIRST].X + 64, - InvRect[j + SLOTXY_INV_FIRST].Y + 159, - (char *)pCursCels, frame, frame_width, 0, 8); - } + int frame = plr[myplr].InvList[ii]._iCurs + 12; + int frame_width = InvItemWidth[frame]; + if (pcursinvitem == ii + INVITEM_INV_FIRST) { + int colour = ICOL_WHITE; + if (plr[myplr].InvList[ii]._iMagical != ITEM_QUALITY_NORMAL) { + colour = ICOL_BLUE; + } + if (!plr[myplr].InvList[ii]._iStatFlag) { + colour = ICOL_RED; + } + CelDecodeClr( + colour, + InvRect[j + SLOTXY_INV_FIRST].X + 64, + InvRect[j + SLOTXY_INV_FIRST].Y + 159, + (char *)pCursCels, frame, frame_width, 0, 8); + } - if (plr[myplr].InvList[ii]._iStatFlag) { - CelDrawHdrOnly( - InvRect[j + SLOTXY_INV_FIRST].X + 64, - InvRect[j + SLOTXY_INV_FIRST].Y + 159, - (char *)pCursCels, frame, frame_width, 0, 8); - } else { - CelDrawHdrLightRed( - InvRect[j + SLOTXY_INV_FIRST].X + 64, - InvRect[j + SLOTXY_INV_FIRST].Y + 159, - (char *)pCursCels, frame, frame_width, 0, 8, 1); - } - } - } + if (plr[myplr].InvList[ii]._iStatFlag) { + CelDrawHdrOnly( + InvRect[j + SLOTXY_INV_FIRST].X + 64, + InvRect[j + SLOTXY_INV_FIRST].Y + 159, + (char *)pCursCels, frame, frame_width, 0, 8); + } else { + CelDrawHdrLightRed( + InvRect[j + SLOTXY_INV_FIRST].X + 64, + InvRect[j + SLOTXY_INV_FIRST].Y + 159, + (char *)pCursCels, frame, frame_width, 0, 8, 1); + } + } + } } // 4B8CB8: using guessed type char pcursinvitem; // 69BEF8: using guessed type int light_table_index; @@ -393,981 +393,981 @@ void __cdecl DrawInv() void __cdecl DrawInvBelt() { - int v0; // ebx - signed int v1; // esi - int v2; // ecx - int v3; // eax - int v4; // edi - char v5; // cl - int v6; // edx - bool v7; // zf - int v8; // ecx - int v9; // eax - unsigned char v10; // edx - signed int v11; // [esp+4h] [ebp-Ch] - int frame_width; // [esp+8h] [ebp-8h] - int v13; // [esp+Ch] [ebp-4h] + int v0; // ebx + signed int v1; // esi + int v2; // ecx + int v3; // eax + int v4; // edi + char v5; // cl + int v6; // edx + bool v7; // zf + int v8; // ecx + int v9; // eax + unsigned char v10; // edx + signed int v11; // [esp+4h] [ebp-Ch] + int frame_width; // [esp+8h] [ebp-8h] + int v13; // [esp+Ch] [ebp-4h] - v0 = 0; - if (!talkflag) { - DrawPanelBox(205, 21, 0xE8u, 0x1Cu, 269, 517); - v11 = 0; - v13 = 0; - do { - if (*(int *)((char *)&plr[myplr].SpdList[0]._itype + v0) != -1) { - v1 = v11; - InvDrawSlotBack(InvRect[v11 + 65].X + 64, InvRect[v11 + 65].Y + 159, 28, 28); - v2 = myplr; - v3 = v0 + 21720 * myplr; - v4 = *(int *)((char *)&plr[0].SpdList[0]._iCurs + v3) + 12; - frame_width = InvItemWidth[v4]; - if (pcursinvitem == v11 + 47) { - v5 = -59; - if (*(&plr[0].SpdList[0]._iMagical + v3)) - v5 = -75; - if (!*(int *)((char *)&plr[0].SpdList[0]._iStatFlag + v3)) - v5 = -27; - CelDecodeClr( - v5, - InvRect[v1 + 65].X + 64, - InvRect[v1 + 65].Y + 159, - (char *)pCursCels, - v4, - frame_width, - 0, - 8); - v2 = myplr; - } - v0 = v13; - v6 = InvRect[v1 + 65].Y + 159; - v7 = *(int *)((char *)&plr[v2].SpdList[0]._iStatFlag + v13) == 0; - v8 = InvRect[v1 + 65].X; - if (v7) - CelDrawHdrLightRed(v8 + 64, v6, (char *)pCursCels, v4, frame_width, 0, 8, 1); - else - CelDrawHdrOnly(v8 + 64, v6, (char *)pCursCels, v4, frame_width, 0, 8); - v9 = v13 + 21720 * myplr; - if (AllItemsList[*(int *)((char *)&plr[0].SpdList[0].IDidx + v9)].iUsable - && *(int *)((char *)&plr[0].SpdList[0]._iStatFlag + v9) - && *(int *)((char *)&plr[0].SpdList[0]._itype + v9) != 11) { - v10 = fontframe[fontidx[(unsigned char)(v11 + 49)]]; - CPrintString( - screen_y_times_768[InvRect[v1 + 65].Y + 159] - - fontkern[v10] - + InvRect[v1 + 65].X - + 92, - v10, - 0); - } - } - ++v11; - v0 += 368; - v13 = v0; - } while (v11 < MAXBELTITEMS); - } + v0 = 0; + if (!talkflag) { + DrawPanelBox(205, 21, 0xE8u, 0x1Cu, 269, 517); + v11 = 0; + v13 = 0; + do { + if (*(int *)((char *)&plr[myplr].SpdList[0]._itype + v0) != -1) { + v1 = v11; + InvDrawSlotBack(InvRect[v11 + 65].X + 64, InvRect[v11 + 65].Y + 159, 28, 28); + v2 = myplr; + v3 = v0 + 21720 * myplr; + v4 = *(int *)((char *)&plr[0].SpdList[0]._iCurs + v3) + 12; + frame_width = InvItemWidth[v4]; + if (pcursinvitem == v11 + 47) { + v5 = -59; + if (*(&plr[0].SpdList[0]._iMagical + v3)) + v5 = -75; + if (!*(int *)((char *)&plr[0].SpdList[0]._iStatFlag + v3)) + v5 = -27; + CelDecodeClr( + v5, + InvRect[v1 + 65].X + 64, + InvRect[v1 + 65].Y + 159, + (char *)pCursCels, + v4, + frame_width, + 0, + 8); + v2 = myplr; + } + v0 = v13; + v6 = InvRect[v1 + 65].Y + 159; + v7 = *(int *)((char *)&plr[v2].SpdList[0]._iStatFlag + v13) == 0; + v8 = InvRect[v1 + 65].X; + if (v7) + CelDrawHdrLightRed(v8 + 64, v6, (char *)pCursCels, v4, frame_width, 0, 8, 1); + else + CelDrawHdrOnly(v8 + 64, v6, (char *)pCursCels, v4, frame_width, 0, 8); + v9 = v13 + 21720 * myplr; + if (AllItemsList[*(int *)((char *)&plr[0].SpdList[0].IDidx + v9)].iUsable + && *(int *)((char *)&plr[0].SpdList[0]._iStatFlag + v9) + && *(int *)((char *)&plr[0].SpdList[0]._itype + v9) != 11) { + v10 = fontframe[fontidx[(unsigned char)(v11 + 49)]]; + CPrintString( + screen_y_times_768[InvRect[v1 + 65].Y + 159] + - fontkern[v10] + + InvRect[v1 + 65].X + + 92, + v10, + 0); + } + } + ++v11; + v0 += 368; + v13 = v0; + } while (v11 < MAXBELTITEMS); + } } // 4B8960: using guessed type int talkflag; // 4B8CB8: using guessed type char pcursinvitem; int __fastcall AutoPlace(int pnum, int ii, int sx, int sy, int saveflag) { - __int64 v5; // rax - int v6; // ebx - signed int v7; // edx - signed int v8; // eax - signed int v9; // esi - int j; // edi - int v11; // eax - signed int v12; // esi - signed int v13; // ecx - int v14; // edi - char *v15; // ecx - char v16; // dl - signed int v18; // [esp+Ch] [ebp-Ch] - int p; // [esp+10h] [ebp-8h] - int v20; // [esp+14h] [ebp-4h] - int i; // [esp+14h] [ebp-4h] + __int64 v5; // rax + int v6; // ebx + signed int v7; // edx + signed int v8; // eax + signed int v9; // esi + int j; // edi + int v11; // eax + signed int v12; // esi + signed int v13; // ecx + int v14; // edi + char *v15; // ecx + char v16; // dl + signed int v18; // [esp+Ch] [ebp-Ch] + int p; // [esp+10h] [ebp-8h] + int v20; // [esp+14h] [ebp-4h] + int i; // [esp+14h] [ebp-4h] - p = pnum; - v5 = ii; - v6 = 1; - v18 = v5 % 10; - v7 = 10 * (unsigned __int64)(v5 / 10); - v8 = v7; - if (v7 < 0) - v8 = 0; - v20 = 0; - if (sy <= 0) { - LABEL_16: - if (saveflag) { - v11 = pnum; - qmemcpy( - &plr[pnum].InvList[plr[pnum]._pNumInv], - &plr[pnum].HoldItem, - sizeof(plr[pnum].InvList[plr[pnum]._pNumInv])); - ++plr[v11]._pNumInv; - v12 = v7; - if (v7 < 0) - v12 = 0; - for (i = 0; i < sy; ++i) { - v13 = v18; - if (v18 < 0) - v13 = 0; - v14 = 0; - if (sx > 0) { - v15 = &plr[v11].InvGrid[v13 + v12]; - do { - if (v14 || i != sy - 1) - v16 = -_LOBYTE(plr[v11]._pNumInv); - else - v16 = plr[v11]._pNumInv; - *v15++ = v16; - ++v14; - } while (v14 < sx); - } - v12 += 10; - } - CalcPlrScrolls(p); - } - } else { - while (v6) { - if (v8 >= 40) - v6 = 0; - v9 = v18; - if (v18 < 0) - v9 = 0; - for (j = 0; j < sx; ++j) { - if (!v6) - break; - v6 = 0; - if (v9 < 10) - _LOBYTE(v6) = plr[pnum].InvGrid[v9 + v8] == 0; - ++v9; - } - v8 += 10; - if (++v20 >= sy) { - if (!v6) - return v6; - goto LABEL_16; - } - } - } - return v6; + p = pnum; + v5 = ii; + v6 = 1; + v18 = v5 % 10; + v7 = 10 * (unsigned __int64)(v5 / 10); + v8 = v7; + if (v7 < 0) + v8 = 0; + v20 = 0; + if (sy <= 0) { + LABEL_16: + if (saveflag) { + v11 = pnum; + qmemcpy( + &plr[pnum].InvList[plr[pnum]._pNumInv], + &plr[pnum].HoldItem, + sizeof(plr[pnum].InvList[plr[pnum]._pNumInv])); + ++plr[v11]._pNumInv; + v12 = v7; + if (v7 < 0) + v12 = 0; + for (i = 0; i < sy; ++i) { + v13 = v18; + if (v18 < 0) + v13 = 0; + v14 = 0; + if (sx > 0) { + v15 = &plr[v11].InvGrid[v13 + v12]; + do { + if (v14 || i != sy - 1) + v16 = -_LOBYTE(plr[v11]._pNumInv); + else + v16 = plr[v11]._pNumInv; + *v15++ = v16; + ++v14; + } while (v14 < sx); + } + v12 += 10; + } + CalcPlrScrolls(p); + } + } else { + while (v6) { + if (v8 >= 40) + v6 = 0; + v9 = v18; + if (v18 < 0) + v9 = 0; + for (j = 0; j < sx; ++j) { + if (!v6) + break; + v6 = 0; + if (v9 < 10) + _LOBYTE(v6) = plr[pnum].InvGrid[v9 + v8] == 0; + ++v9; + } + v8 += 10; + if (++v20 >= sy) { + if (!v6) + return v6; + goto LABEL_16; + } + } + } + return v6; } int __fastcall SpecialAutoPlace(int pnum, int ii, int sx, int sy, int saveflag) { - __int64 v5; // rax - int v6; // ebx - signed int v7; // edx - signed int v8; // eax - signed int v9; // esi - int j; // edi - signed int v11; // ecx - int *v12; // eax - int v13; // eax - signed int v14; // esi - signed int v15; // ecx - int v16; // edi - char *v17; // ecx - char v18; // dl - signed int v20; // [esp+Ch] [ebp-Ch] - int p; // [esp+10h] [ebp-8h] - int v22; // [esp+14h] [ebp-4h] - int i; // [esp+14h] [ebp-4h] + __int64 v5; // rax + int v6; // ebx + signed int v7; // edx + signed int v8; // eax + signed int v9; // esi + int j; // edi + signed int v11; // ecx + int *v12; // eax + int v13; // eax + signed int v14; // esi + signed int v15; // ecx + int v16; // edi + char *v17; // ecx + char v18; // dl + signed int v20; // [esp+Ch] [ebp-Ch] + int p; // [esp+10h] [ebp-8h] + int v22; // [esp+14h] [ebp-4h] + int i; // [esp+14h] [ebp-4h] - p = pnum; - v5 = ii; - v6 = 1; - v20 = v5 % 10; - v7 = 10 * (unsigned __int64)(v5 / 10); - v8 = v7; - if (v7 < 0) - v8 = 0; - v22 = 0; - if (sy <= 0) { - LABEL_25: - if (saveflag) { - v13 = p; - qmemcpy(&plr[p].InvList[plr[p]._pNumInv], &plr[p].HoldItem, sizeof(plr[p].InvList[plr[p]._pNumInv])); - ++plr[v13]._pNumInv; - v14 = v7; - if (v7 < 0) - v14 = 0; - for (i = 0; i < sy; ++i) { - v15 = v20; - if (v20 < 0) - v15 = 0; - v16 = 0; - if (sx > 0) { - v17 = &plr[v13].InvGrid[v15 + v14]; - do { - if (v16 || i != sy - 1) - v18 = -_LOBYTE(plr[v13]._pNumInv); - else - v18 = plr[v13]._pNumInv; - *v17++ = v18; - ++v16; - } while (v16 < sx); - } - v14 += 10; - } - CalcPlrScrolls(p); - } - return v6; - } - while (v6) { - if (v8 >= 40) - v6 = 0; - v9 = v20; - if (v20 < 0) - v9 = 0; - for (j = 0; j < sx; ++j) { - if (!v6) - break; - v6 = 0; - if (v9 < 10) - _LOBYTE(v6) = plr[pnum].InvGrid[v9 + v8] == 0; - ++v9; - } - v8 += 10; - if (++v22 >= sy) { - if (v6) - goto LABEL_25; - break; - } - } - if (sx <= 1 && sy <= 1) { - v11 = 0; - v12 = &plr[p].SpdList[0]._itype; - while (*v12 != -1) { - ++v11; - v12 += 92; - if (v11 >= MAXBELTITEMS) - goto LABEL_24; - } - v6 = 1; - goto LABEL_25; - } - v6 = 0; + p = pnum; + v5 = ii; + v6 = 1; + v20 = v5 % 10; + v7 = 10 * (unsigned __int64)(v5 / 10); + v8 = v7; + if (v7 < 0) + v8 = 0; + v22 = 0; + if (sy <= 0) { + LABEL_25: + if (saveflag) { + v13 = p; + qmemcpy(&plr[p].InvList[plr[p]._pNumInv], &plr[p].HoldItem, sizeof(plr[p].InvList[plr[p]._pNumInv])); + ++plr[v13]._pNumInv; + v14 = v7; + if (v7 < 0) + v14 = 0; + for (i = 0; i < sy; ++i) { + v15 = v20; + if (v20 < 0) + v15 = 0; + v16 = 0; + if (sx > 0) { + v17 = &plr[v13].InvGrid[v15 + v14]; + do { + if (v16 || i != sy - 1) + v18 = -_LOBYTE(plr[v13]._pNumInv); + else + v18 = plr[v13]._pNumInv; + *v17++ = v18; + ++v16; + } while (v16 < sx); + } + v14 += 10; + } + CalcPlrScrolls(p); + } + return v6; + } + while (v6) { + if (v8 >= 40) + v6 = 0; + v9 = v20; + if (v20 < 0) + v9 = 0; + for (j = 0; j < sx; ++j) { + if (!v6) + break; + v6 = 0; + if (v9 < 10) + _LOBYTE(v6) = plr[pnum].InvGrid[v9 + v8] == 0; + ++v9; + } + v8 += 10; + if (++v22 >= sy) { + if (v6) + goto LABEL_25; + break; + } + } + if (sx <= 1 && sy <= 1) { + v11 = 0; + v12 = &plr[p].SpdList[0]._itype; + while (*v12 != -1) { + ++v11; + v12 += 92; + if (v11 >= MAXBELTITEMS) + goto LABEL_24; + } + v6 = 1; + goto LABEL_25; + } + v6 = 0; LABEL_24: - if (v6) - goto LABEL_25; - return v6; + if (v6) + goto LABEL_25; + return v6; } int __fastcall GoldAutoPlace(int pnum) { - int v1; // ebp - int v2; // edi - int v3; // ecx - int *v4; // esi - int v5; // eax - int v6; // edi - int *v7; // esi - int v8; // eax - signed int v9; // ebx - char *v10; // edx - int v11; // eax - int v12; // ecx - int pnuma; // [esp+10h] [ebp-4h] + int v1; // ebp + int v2; // edi + int v3; // ecx + int *v4; // esi + int v5; // eax + int v6; // edi + int *v7; // esi + int v8; // eax + signed int v9; // ebx + char *v10; // edx + int v11; // eax + int v12; // ecx + int pnuma; // [esp+10h] [ebp-4h] - pnuma = pnum; - v1 = pnum; - v2 = 0; - v3 = 0; - if (plr[v1]._pNumInv <= 0) { - LABEL_14: - v6 = 0; - if (plr[v1]._pNumInv <= 0) { - LABEL_28: - v9 = 39; - do { - if (v3) - break; - v10 = &plr[0].InvGrid[10 * (v9 / 10) + v1 * 21720 + v9 % 10]; - if (!*v10) { - v11 = v1 * 21720 + 368 * plr[v1]._pNumInv; - qmemcpy((char *)plr[0].InvList + v11, &plr[v1].HoldItem, 0x170u); - ++plr[v1]._pNumInv; - *v10 = plr[v1]._pNumInv; - v12 = plr[v1].HoldItem._ivalue; - if (v12 < 2500) { - if (v12 > 1000) - *(int *)((char *)&plr[0].InvList[0]._iCurs + v11) = 5; - else - *(int *)((char *)&plr[0].InvList[0]._iCurs + v11) = 4; - } else { - *(int *)((char *)&plr[0].InvList[0]._iCurs + v11) = 6; - } - plr[v1]._pGold = CalculateGold(pnuma); - v3 = 1; - } - --v9; - } while (v9 >= 0); - } else { - v7 = &plr[v1].InvList[0]._ivalue; - while (!v3) { - if (*(v7 - 47) == 11 && *v7 < 5000) { - v8 = plr[v1].HoldItem._ivalue + *v7; - if (v8 <= 5000) { - *v7 = v8; - if (v8 < 2500) { - if (v8 > 1000) - *(v7 - 1) = 5; - else - *(v7 - 1) = 4; - } else { - *(v7 - 1) = 6; - } - plr[v1]._pGold = CalculateGold(pnuma); - v3 = 1; - } - } - ++v6; - v7 += 92; - if (v6 >= plr[v1]._pNumInv) { - if (v3) - return v3; - goto LABEL_28; - } - } - } - } else { - v4 = &plr[v1].InvList[0]._ivalue; - while (!v3) { - if (*(v4 - 47) == 11) { - v5 = *v4 + plr[v1].HoldItem._ivalue; - if (v5 <= 5000) { - *v4 = v5; - if (v5 < 2500) { - if (v5 > 1000) - *(v4 - 1) = 5; - else - *(v4 - 1) = 4; - } else { - *(v4 - 1) = 6; - } - plr[v1]._pGold = CalculateGold(pnuma); - v3 = 1; - } - } - ++v2; - v4 += 92; - if (v2 >= plr[v1]._pNumInv) { - if (v3) - return v3; - goto LABEL_14; - } - } - } - return v3; + pnuma = pnum; + v1 = pnum; + v2 = 0; + v3 = 0; + if (plr[v1]._pNumInv <= 0) { + LABEL_14: + v6 = 0; + if (plr[v1]._pNumInv <= 0) { + LABEL_28: + v9 = 39; + do { + if (v3) + break; + v10 = &plr[0].InvGrid[10 * (v9 / 10) + v1 * 21720 + v9 % 10]; + if (!*v10) { + v11 = v1 * 21720 + 368 * plr[v1]._pNumInv; + qmemcpy((char *)plr[0].InvList + v11, &plr[v1].HoldItem, 0x170u); + ++plr[v1]._pNumInv; + *v10 = plr[v1]._pNumInv; + v12 = plr[v1].HoldItem._ivalue; + if (v12 < 2500) { + if (v12 > 1000) + *(int *)((char *)&plr[0].InvList[0]._iCurs + v11) = 5; + else + *(int *)((char *)&plr[0].InvList[0]._iCurs + v11) = 4; + } else { + *(int *)((char *)&plr[0].InvList[0]._iCurs + v11) = 6; + } + plr[v1]._pGold = CalculateGold(pnuma); + v3 = 1; + } + --v9; + } while (v9 >= 0); + } else { + v7 = &plr[v1].InvList[0]._ivalue; + while (!v3) { + if (*(v7 - 47) == 11 && *v7 < 5000) { + v8 = plr[v1].HoldItem._ivalue + *v7; + if (v8 <= 5000) { + *v7 = v8; + if (v8 < 2500) { + if (v8 > 1000) + *(v7 - 1) = 5; + else + *(v7 - 1) = 4; + } else { + *(v7 - 1) = 6; + } + plr[v1]._pGold = CalculateGold(pnuma); + v3 = 1; + } + } + ++v6; + v7 += 92; + if (v6 >= plr[v1]._pNumInv) { + if (v3) + return v3; + goto LABEL_28; + } + } + } + } else { + v4 = &plr[v1].InvList[0]._ivalue; + while (!v3) { + if (*(v4 - 47) == 11) { + v5 = *v4 + plr[v1].HoldItem._ivalue; + if (v5 <= 5000) { + *v4 = v5; + if (v5 < 2500) { + if (v5 > 1000) + *(v4 - 1) = 5; + else + *(v4 - 1) = 4; + } else { + *(v4 - 1) = 6; + } + plr[v1]._pGold = CalculateGold(pnuma); + v3 = 1; + } + } + ++v2; + v4 += 92; + if (v2 >= plr[v1]._pNumInv) { + if (v3) + return v3; + goto LABEL_14; + } + } + } + return v3; } int __fastcall WeaponAutoPlace(int pnum) { - int v1; // edi - int v2; // eax - int v3; // ecx - ItemStruct *v4; // esi - ItemStruct *v5; // edi - int result; // eax + int v1; // edi + int v2; // eax + int v3; // ecx + ItemStruct *v4; // esi + ItemStruct *v5; // edi + int result; // eax - v1 = pnum; - if (plr[pnum].HoldItem._iLoc == ILOC_TWOHAND) { - if (plr[v1].InvBody[INVLOC_HAND_LEFT]._itype != -1 || plr[v1].InvBody[INVLOC_HAND_RIGHT]._itype != -1) - return 0; - LABEL_12: - NetSendCmdChItem(TRUE, 4u); - v4 = &plr[v1].HoldItem; - v5 = &plr[v1].InvBody[INVLOC_HAND_LEFT]; - goto LABEL_13; - } - v2 = plr[v1].InvBody[INVLOC_HAND_LEFT]._itype; - if (v2 != -1 && plr[v1].InvBody[INVLOC_HAND_LEFT]._iClass == 1) - return 0; - v3 = plr[v1].InvBody[INVLOC_HAND_RIGHT]._itype; - if (v3 != -1 && plr[v1].InvBody[INVLOC_HAND_RIGHT]._iClass == 1) - return 0; - if (v2 == -1) - goto LABEL_12; - if (v3 == -1 && plr[v1].InvBody[INVLOC_HAND_LEFT]._iLoc != ILOC_TWOHAND) { - NetSendCmdChItem(TRUE, 5u); - v4 = &plr[v1].HoldItem; - v5 = &plr[v1].InvBody[INVLOC_HAND_RIGHT]; - LABEL_13: - result = 1; - qmemcpy(v5, v4, sizeof(ItemStruct)); - return result; - } - return 0; + v1 = pnum; + if (plr[pnum].HoldItem._iLoc == ILOC_TWOHAND) { + if (plr[v1].InvBody[INVLOC_HAND_LEFT]._itype != -1 || plr[v1].InvBody[INVLOC_HAND_RIGHT]._itype != -1) + return 0; + LABEL_12: + NetSendCmdChItem(TRUE, 4u); + v4 = &plr[v1].HoldItem; + v5 = &plr[v1].InvBody[INVLOC_HAND_LEFT]; + goto LABEL_13; + } + v2 = plr[v1].InvBody[INVLOC_HAND_LEFT]._itype; + if (v2 != -1 && plr[v1].InvBody[INVLOC_HAND_LEFT]._iClass == 1) + return 0; + v3 = plr[v1].InvBody[INVLOC_HAND_RIGHT]._itype; + if (v3 != -1 && plr[v1].InvBody[INVLOC_HAND_RIGHT]._iClass == 1) + return 0; + if (v2 == -1) + goto LABEL_12; + if (v3 == -1 && plr[v1].InvBody[INVLOC_HAND_LEFT]._iLoc != ILOC_TWOHAND) { + NetSendCmdChItem(TRUE, 5u); + v4 = &plr[v1].HoldItem; + v5 = &plr[v1].InvBody[INVLOC_HAND_RIGHT]; + LABEL_13: + result = 1; + qmemcpy(v5, v4, sizeof(ItemStruct)); + return result; + } + return 0; } int __fastcall SwapItem(ItemStruct *a, ItemStruct *b) { - int v2; // eax - ItemStruct h; // [esp+8h] [ebp-170h] + int v2; // eax + ItemStruct h; // [esp+8h] [ebp-170h] - qmemcpy(&h, a, sizeof(h)); - v2 = h._iCurs; - qmemcpy(a, b, sizeof(ItemStruct)); - qmemcpy(b, &h, sizeof(ItemStruct)); - return v2 + 12; + qmemcpy(&h, a, sizeof(h)); + v2 = h._iCurs; + qmemcpy(a, b, sizeof(ItemStruct)); + qmemcpy(b, &h, sizeof(ItemStruct)); + return v2 + 12; } void __fastcall CheckInvPaste(int pnum, int mx, int my) { - int v3; // ebx - int v4; // edi - int v5; // eax - int v6; // esi - signed int v7; // edi - int v8; // edx - int v9; // edx - signed int v10; // edi - char v11; // al - signed int v12; // ecx - int v13; // eax - int v14; // eax - char *v15; // edi - int v16; // esi - int v17; // ecx - int v18; // edx - int v21; // esi - ItemStruct *v22; // edi - ItemStruct *v23; // ecx - int v24; // eax - int v25; // eax - int v26; // edx - ItemStruct *v27; // esi - int v28; // eax - int v29; // ecx - int v30; // esi - int v31; // eax - int v32; // eax - int v33; // ecx - int v34; // eax - int v35; // ecx - char *v36; // eax - int v37; // edx - int v38; // ecx - int v39; // edi - int v40; // esi - int v41; // ebx - int v42; // edx - int v43; // eax - int v44; // eax - signed int v45; // ecx - int v46; // edx - char *v47; // eax - int v48; // edi - int v49; // eax - int v50; // ecx - char *v51; // esi - char v52; // cl - int v53; // ecx - int v54; // eax - int v55; // edi - int v56; // edx - int v57; // esi - int v58; // ebx - int v59; // eax - int v60; // esi - ItemStruct tempitem; // [esp+Ch] [ebp-190h] - int v62; // [esp+17Ch] [ebp-20h] - int p; // [esp+180h] [ebp-1Ch] - int v64; // [esp+184h] [ebp-18h] - int v65; // [esp+188h] [ebp-14h] - int v66; // [esp+18Ch] [ebp-10h] - int v67; // [esp+190h] [ebp-Ch] - int v68; // [esp+194h] [ebp-8h] - int v69; // [esp+198h] [ebp-4h] - int cursor_id; // [esp+1A4h] [ebp+8h] - int cursor_ida; // [esp+1A4h] [ebp+8h] + int v3; // ebx + int v4; // edi + int v5; // eax + int v6; // esi + signed int v7; // edi + int v8; // edx + int v9; // edx + signed int v10; // edi + char v11; // al + signed int v12; // ecx + int v13; // eax + int v14; // eax + char *v15; // edi + int v16; // esi + int v17; // ecx + int v18; // edx + int v21; // esi + ItemStruct *v22; // edi + ItemStruct *v23; // ecx + int v24; // eax + int v25; // eax + int v26; // edx + ItemStruct *v27; // esi + int v28; // eax + int v29; // ecx + int v30; // esi + int v31; // eax + int v32; // eax + int v33; // ecx + int v34; // eax + int v35; // ecx + char *v36; // eax + int v37; // edx + int v38; // ecx + int v39; // edi + int v40; // esi + int v41; // ebx + int v42; // edx + int v43; // eax + int v44; // eax + signed int v45; // ecx + int v46; // edx + char *v47; // eax + int v48; // edi + int v49; // eax + int v50; // ecx + char *v51; // esi + char v52; // cl + int v53; // ecx + int v54; // eax + int v55; // edi + int v56; // edx + int v57; // esi + int v58; // ebx + int v59; // eax + int v60; // esi + ItemStruct tempitem; // [esp+Ch] [ebp-190h] + int v62; // [esp+17Ch] [ebp-20h] + int p; // [esp+180h] [ebp-1Ch] + int v64; // [esp+184h] [ebp-18h] + int v65; // [esp+188h] [ebp-14h] + int v66; // [esp+18Ch] [ebp-10h] + int v67; // [esp+190h] [ebp-Ch] + int v68; // [esp+194h] [ebp-8h] + int v69; // [esp+198h] [ebp-4h] + int cursor_id; // [esp+1A4h] [ebp+8h] + int cursor_ida; // [esp+1A4h] [ebp+8h] - p = pnum; - v3 = pnum; - v4 = mx; - SetICursor(plr[pnum].HoldItem._iCurs + 12); - v5 = my + (icursH >> 1); - v6 = v4 + (icursW >> 1); - v64 = icursW28; - v7 = 0; - v67 = icursH28; - v68 = 0; - do { - if (v7) - goto LABEL_18; - v8 = InvRect[v68].X; - if (v6 >= v8 && v6 < v8 + 28) { - v9 = InvRect[v68].Y; - if (v5 >= v9 - 29 && v5 < v9) { - v7 = 1; - --v68; - } - } - if (v68 != 24) - goto LABEL_13; - if (!(v64 & 1)) - v6 -= 14; - if (!(v67 & 1)) { - v5 -= 14; - LABEL_13: - if (v68 == 64 && !(v67 & 1)) - v5 += 14; - } - ++v68; - } while ((unsigned int)v68 < 0x49); - if (!v7) - return; + p = pnum; + v3 = pnum; + v4 = mx; + SetICursor(plr[pnum].HoldItem._iCurs + 12); + v5 = my + (icursH >> 1); + v6 = v4 + (icursW >> 1); + v64 = icursW28; + v7 = 0; + v67 = icursH28; + v68 = 0; + do { + if (v7) + goto LABEL_18; + v8 = InvRect[v68].X; + if (v6 >= v8 && v6 < v8 + 28) { + v9 = InvRect[v68].Y; + if (v5 >= v9 - 29 && v5 < v9) { + v7 = 1; + --v68; + } + } + if (v68 != 24) + goto LABEL_13; + if (!(v64 & 1)) + v6 -= 14; + if (!(v67 & 1)) { + v5 -= 14; + LABEL_13: + if (v68 == 64 && !(v67 & 1)) + v5 += 14; + } + ++v68; + } while ((unsigned int)v68 < 0x49); + if (!v7) + return; LABEL_18: - v10 = v68; - v69 = ILOC_UNEQUIPABLE; - if (v68 >= 0 && v68 <= ILOC_ARMOR) - v69 = ILOC_HELM; - if (v68 >= ILOC_HELM && v68 <= ILOC_RING) - v69 = ILOC_RING; - if (v68 == ILOC_AMULET) - v69 = ILOC_AMULET; - if (v68 >= ILOC_UNEQUIPABLE && v68 <= 18) - v69 = ILOC_ONEHAND; - if (v68 >= 19 && v68 <= 24) - v69 = ILOC_ARMOR; - if (v68 >= 65 && v68 <= 72) - v69 = ILOC_BELT; - v11 = plr[v3].HoldItem._iLoc; - v12 = 0; - if ((char)v11 == v69) - v12 = 1; - if (v69 == 1 && v11 == ILOC_TWOHAND) { - v69 = ILOC_TWOHAND; - v12 = 1; - } - if (v11 != 7 || v69 != ILOC_BELT) { - LABEL_50: - if (v69 != ILOC_UNEQUIPABLE) - goto LABEL_81; - v66 = 0; - cursor_id = 1; - v13 = (v68 - 25) / 10; - if (plr[v3].HoldItem._itype == ITYPE_GOLD) { - _LOBYTE(v13) = plr[0].InvGrid[10 * v13 + v3 * 21720 + (v68 - 25) % 10]; - if (!(_BYTE)v13) - goto LABEL_93; - v13 = (char)v13; - if ((char)v13 <= 0) { - v13 = -v13; - } else if (*(int *)((char *)&plr[0].InvBody[v13 + 6]._itype + v3 * 21720) == ITYPE_GOLD) { - goto LABEL_93; - } - v66 = v13; - LABEL_93: - v21 = p; - if (p == myplr) { - PlaySFX(ItemInvSnds[ItemCAnimTbl[plr[v3].HoldItem._iCurs]]); - v10 = v68; - } - cursor_ida = 1; - switch (v69) { - case ILOC_ONEHAND: - if (v10 > 12) { - if (plr[v3].InvBody[INVLOC_HAND_RIGHT]._itype == ITYPE_NONE) { - v25 = plr[v3].InvBody[INVLOC_HAND_LEFT]._itype; - if (v25 == ITYPE_NONE) - goto LABEL_232; - if (plr[v3].InvBody[INVLOC_HAND_LEFT]._iLoc == ILOC_TWOHAND) { - NetSendCmdDelItem(FALSE, 4u); - NetSendCmdChItem(FALSE, 5u); - SwapItem(&plr[v3].InvBody[INVLOC_HAND_RIGHT], &plr[v3].InvBody[INVLOC_HAND_LEFT]); - v23 = &plr[v3].InvBody[INVLOC_HAND_RIGHT]; - LABEL_99: - v24 = SwapItem(v23, &plr[v3].HoldItem); - LABEL_172: - cursor_ida = v24; - goto LABEL_226; - } - if (v25 == ITYPE_NONE || plr[v3].InvBody[INVLOC_HAND_LEFT]._iClass != plr[v3].HoldItem._iClass) { - LABEL_232: - NetSendCmdChItem(FALSE, 5u); - v22 = &plr[v3].InvBody[INVLOC_HAND_RIGHT]; - LABEL_158: - qmemcpy(v22, &plr[v3].HoldItem, sizeof(ItemStruct)); - goto LABEL_226; - } - } else if (plr[v3].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_NONE - || plr[v3].InvBody[INVLOC_HAND_LEFT]._iClass != plr[v3].HoldItem._iClass) { - goto LABEL_114; - } - } else { - if (plr[v3].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_NONE) { - if (plr[v3].InvBody[INVLOC_HAND_RIGHT]._itype != ITYPE_NONE - && plr[v3].InvBody[INVLOC_HAND_RIGHT]._iClass == plr[v3].HoldItem._iClass) { - LABEL_114: - NetSendCmdChItem(FALSE, 5u); - v23 = &plr[v3].InvBody[INVLOC_HAND_RIGHT]; - goto LABEL_99; - } - NetSendCmdChItem(FALSE, 4u); - v22 = &plr[v3].InvBody[INVLOC_HAND_LEFT]; - goto LABEL_158; - } - if (plr[v3].InvBody[INVLOC_HAND_RIGHT]._itype != ITYPE_NONE - && plr[v3].InvBody[INVLOC_HAND_RIGHT]._iClass == plr[v3].HoldItem._iClass) { - goto LABEL_114; - } - } - NetSendCmdChItem(FALSE, 4u); - v23 = &plr[v3].InvBody[INVLOC_HAND_LEFT]; - goto LABEL_99; - case ILOC_TWOHAND: - NetSendCmdDelItem(FALSE, 5u); - if (plr[v3].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_NONE) - goto LABEL_147; - v26 = plr[v3].InvBody[INVLOC_HAND_RIGHT]._itype; - if (v26 == -1) - goto LABEL_146; - qmemcpy(&tempitem, &plr[v3].HoldItem, sizeof(tempitem)); - v27 = &plr[v3].InvBody[INVLOC_HAND_RIGHT]; - if (v26 != 5) - v27 = &plr[v3].InvBody[INVLOC_HAND_LEFT]; - v28 = p; - qmemcpy(&plr[v3].HoldItem, v27, sizeof(plr[v3].HoldItem)); - v29 = plr[v3].HoldItem._iCurs + 12; - if (v28 == myplr) - SetCursor(v29); - else - SetICursor(v29); - v67 = 0; - v30 = 0; - do { - if (v67) - break; - v31 = AutoPlace(p, v30++, icursW28, icursH28, 1); - v67 = v31; - } while (v30 < 40); - v32 = p; - qmemcpy(&plr[v3].HoldItem, &tempitem, sizeof(plr[v3].HoldItem)); - v33 = plr[v3].HoldItem._iCurs + 12; - if (v32 == myplr) - SetCursor(v33); - else - SetICursor(v33); - if (!v67) - return; - if (plr[v3].InvBody[INVLOC_HAND_RIGHT]._itype == ITYPE_SHIELD) - plr[v3].InvBody[INVLOC_HAND_RIGHT]._itype = ITYPE_NONE; - else - plr[v3].InvBody[INVLOC_HAND_LEFT]._itype = ITYPE_NONE; - LABEL_146: - if (plr[v3].InvBody[INVLOC_HAND_LEFT]._itype != ITYPE_NONE) - goto LABEL_149; - LABEL_147: - if (plr[v3].InvBody[INVLOC_HAND_RIGHT]._itype == ITYPE_NONE) { - NetSendCmdChItem(FALSE, 4u); - qmemcpy(&plr[v3].InvBody[INVLOC_HAND_LEFT], &plr[v3].HoldItem, sizeof(plr[v3].InvBody[INVLOC_HAND_LEFT])); - } else { - LABEL_149: - NetSendCmdChItem(FALSE, 4u); - if (plr[v3].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_NONE) - SwapItem(&plr[v3].InvBody[INVLOC_HAND_LEFT], &plr[v3].InvBody[INVLOC_HAND_RIGHT]); - cursor_ida = SwapItem(&plr[v3].InvBody[INVLOC_HAND_LEFT], &plr[v3].HoldItem); - } - if (plr[v3].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_STAFF) { - v34 = plr[v3].InvBody[INVLOC_HAND_LEFT]._iSpell; - if (v34) { - if (plr[v3].InvBody[INVLOC_HAND_LEFT]._iCharges > 0) { - plr[v3]._pRSpell = v34; - _LOBYTE(plr[v3]._pRSplType) = RSPLTYPE_CHARGES; - drawpanflag = 255; - } - } - } - goto LABEL_226; - case ILOC_ARMOR: - NetSendCmdChItem(FALSE, 6u); - if (plr[v3].InvBody[INVLOC_CHEST]._itype == ITYPE_NONE) { - v22 = &plr[v3].InvBody[INVLOC_CHEST]; - goto LABEL_158; - } - v23 = &plr[v3].InvBody[INVLOC_CHEST]; - goto LABEL_99; - case ILOC_HELM: - NetSendCmdChItem(FALSE, 0); - if (plr[v3].InvBody[INVLOC_HEAD]._itype == ITYPE_NONE) { - v22 = plr[v3].InvBody; - goto LABEL_158; - } - v23 = plr[v3].InvBody; - goto LABEL_99; - case ILOC_RING: - if (v10 == 4) { - NetSendCmdChItem(FALSE, 1u); - if (plr[v3].InvBody[INVLOC_RING_LEFT]._itype == ITYPE_NONE) { - v22 = &plr[v3].InvBody[INVLOC_RING_LEFT]; - goto LABEL_158; - } - v23 = &plr[v3].InvBody[INVLOC_RING_LEFT]; - } else { - NetSendCmdChItem(FALSE, 2u); - if (plr[v3].InvBody[INVLOC_RING_RIGHT]._itype == ITYPE_NONE) { - v22 = &plr[v3].InvBody[INVLOC_RING_RIGHT]; - goto LABEL_158; - } - v23 = &plr[v3].InvBody[INVLOC_RING_RIGHT]; - } - goto LABEL_99; - case ILOC_AMULET: - NetSendCmdChItem(FALSE, 3u); - if (plr[v3].InvBody[INVLOC_AMULET]._itype == ITYPE_NONE) { - v22 = &plr[v3].InvBody[INVLOC_AMULET]; - goto LABEL_158; - } - v23 = &plr[v3].InvBody[INVLOC_AMULET]; - goto LABEL_99; - case ILOC_UNEQUIPABLE: - v35 = plr[v3].HoldItem._itype; - if (v35 == 11) { - if (!v66) { - v36 = &plr[0].InvGrid[10 * ((v68 - 25) / 10) + v3 * 21720 + (v68 - 25) % 10]; - if (*v36 <= 0) { - v42 = 368 * plr[v3]._pNumInv + v3 * 21720; - qmemcpy((char *)plr[0].InvList + v42, &plr[v3].HoldItem, 0x170u); - ++plr[v3]._pNumInv; - *v36 = plr[v3]._pNumInv; - v43 = plr[v3].HoldItem._ivalue; - plr[v3]._pGold += v43; - if (v43 <= 5000) { - if (v43 < 2500) { - if (v43 > 1000) - *(int *)((char *)&plr[0].InvList[0]._iCurs + v42) = 5; - else - *(int *)((char *)&plr[0].InvList[0]._iCurs + v42) = 4; - } else { - *(int *)((char *)&plr[0].InvList[0]._iCurs + v42) = 6; - } - } - goto LABEL_226; - } - v37 = plr[v3].HoldItem._ivalue; - v38 = 368 * (*v36 - 1) + v3 * 21720; - v39 = *(int *)((char *)&plr[0].InvList[0]._ivalue + v38); - v40 = v37 + v39; - if (v37 + v39 <= 5000) { - *(int *)((char *)&plr[0].InvList[0]._ivalue + v38) = v40; - plr[v3]._pGold += plr[v3].HoldItem._ivalue; - if (v40 < 2500) { - if (v40 > 1000) - *(int *)((char *)&plr[0].InvList[0]._iCurs + v38) = 5; - else - *(int *)((char *)&plr[0].InvList[0]._iCurs + v38) = 4; - } else { - *(int *)((char *)&plr[0].InvList[0]._iCurs + v38) = 6; - } - goto LABEL_226; - } - plr[v3]._pGold += 5000 - v39; - plr[v3].HoldItem._ivalue = v37 - (5000 - v39); - *(int *)((char *)&plr[0].InvList[0]._ivalue + v38) = 5000; - *(int *)((char *)&plr[0].InvList[0]._iCurs + v38) = 6; - v41 = plr[v3].HoldItem._ivalue; - if (v41 >= 2500) { - cursor_ida = 18; - goto LABEL_226; - } - v24 = (v41 > 1000) + 16; - goto LABEL_172; - } - } else if (!v66) { - qmemcpy((char *)&plr[0].InvList[plr[v3]._pNumInv++] + v3 * 21720, &plr[v3].HoldItem, 0x170u); - v66 = plr[v3]._pNumInv; - LABEL_191: - v48 = v67; - v49 = 10 * ((v68 - 25) / 10 - ((v67 - 1) >> 1)); - if (v49 < 0) - v49 = 0; - v65 = 0; - if (v67 > 0) { - v69 = (v68 - 25) % 10 - ((v64 - 1) >> 1); - do { - v50 = v69; - if (v69 < 0) - v50 = 0; - v67 = 0; - if (v64 > 0) { - v51 = &plr[v3].InvGrid[v50 + v49]; - do { - if (v67 || v65 != v48 - 1) - v52 = -(char)v66; - else - v52 = v66; - *v51++ = v52; - ++v67; - } while (v67 < v64); - } - v49 += 10; - ++v65; - } while (v65 < v48); - } - goto LABEL_226; - } - v44 = v66 - 1; - if (v35 == 11) - plr[v3]._pGold += plr[v3].HoldItem._ivalue; - cursor_ida = SwapItem((ItemStruct *)((char *)&plr[0].InvList[v44] + v3 * 21720), &plr[v3].HoldItem); - if (plr[v3].HoldItem._itype == ITYPE_GOLD) - plr[v3]._pGold = CalculateGold(v21); - v45 = 0; - v46 = -v66; - do { - v47 = &plr[v3].InvGrid[v45]; - if (*v47 == v66) - *v47 = 0; - if (*v47 == v46) - *v47 = 0; - ++v45; - } while (v45 < 40); - goto LABEL_191; - case ILOC_BELT: - v53 = v3 * 21720 + 368 * (v68 - 65); - if (plr[v3].HoldItem._itype != ITYPE_GOLD) { - if (*(int *)((char *)&plr[0].SpdList[0]._itype + v53) == ITYPE_NONE) { - qmemcpy((char *)plr[0].SpdList + v53, &plr[v3].HoldItem, 0x170u); - } else { - cursor_ida = SwapItem((ItemStruct *)((char *)plr[0].SpdList + v53), &plr[v3].HoldItem); - if (plr[v3].HoldItem._itype == ITYPE_GOLD) - plr[v3]._pGold = CalculateGold(p); - } - goto LABEL_225; - } - v54 = *(int *)((char *)&plr[0].SpdList[0]._itype + v53); - if (v54 != -1) { - if (v54 == 11) { - v55 = *(int *)((char *)&plr[0].SpdList[0]._ivalue + v53); - v56 = plr[v3].HoldItem._ivalue; - v57 = v55 + v56; - if (v55 + v56 <= 5000) { - *(int *)((char *)&plr[0].SpdList[0]._ivalue + v53) = v57; - plr[v3]._pGold += plr[v3].HoldItem._ivalue; - if (v57 < 2500) { - if (v57 > 1000) - *(int *)((char *)&plr[0].SpdList[0]._iCurs + v53) = 5; - else - *(int *)((char *)&plr[0].SpdList[0]._iCurs + v53) = 4; - } else { - *(int *)((char *)&plr[0].SpdList[0]._iCurs + v53) = 6; - } - goto LABEL_225; - } - plr[v3]._pGold += 5000 - v55; - plr[v3].HoldItem._ivalue = v56 - (5000 - v55); - *(int *)((char *)&plr[0].SpdList[0]._ivalue + v53) = 5000; - *(int *)((char *)&plr[0].SpdList[0]._iCurs + v53) = 6; - v58 = plr[v3].HoldItem._ivalue; - if (v58 >= 2500) { - cursor_ida = 18; - goto LABEL_225; - } - v59 = (v58 > 1000) + 16; - } else { - plr[v3]._pGold += plr[v3].HoldItem._ivalue; - v59 = SwapItem((ItemStruct *)((char *)plr[0].SpdList + v53), &plr[v3].HoldItem); - } - cursor_ida = v59; - goto LABEL_225; - } - qmemcpy((char *)plr[0].SpdList + v53, &plr[v3].HoldItem, 0x170u); - plr[v3]._pGold += plr[v3].HoldItem._ivalue; - LABEL_225: - drawsbarflag = 1; - LABEL_226: - v60 = p; - CalcPlrInv(p, 1u); - if (v60 == myplr) { - if (cursor_ida == 1) - SetCursorPos(MouseX + (cursW >> 1), MouseY + (cursH >> 1)); - SetCursor(cursor_ida); - } - return; - default: - goto LABEL_226; - } - } - v62 = (v68 - 25) % 10; - v14 = 10 * (v13 - ((v67 - 1) >> 1)); - if (v14 < 0) - v14 = 0; - v65 = 0; - if (v67 <= 0) - goto LABEL_93; - v15 = &plr[v3].InvGrid[v14]; - while (1) { - if (cursor_id == CURSOR_NONE) - return; - if (v14 >= 40) - cursor_id = 0; - v16 = v62 - ((v64 - 1) >> 1); - if (v16 < 0) - v16 = 0; - v17 = 0; - if (v64 > 0) - break; - LABEL_79: - v14 += 10; - v15 += 10; - if (++v65 >= v67) { - v12 = cursor_id; - v10 = v68; - goto LABEL_81; - } - } - while (1) { - if (cursor_id == CURSOR_NONE) - goto LABEL_79; - if (v16 >= 10) - goto LABEL_233; - _LOBYTE(v18) = v15[v16]; - if ((_BYTE)v18) { - v18 = (char)v18; - if ((v18 & 0x80u) != 0) - v18 = -v18; - if (!v66) { - v66 = v18; - goto LABEL_78; - } - if (v66 != v18) - LABEL_233: - cursor_id = 0; - } - LABEL_78: - ++v16; - if (++v17 >= v64) - goto LABEL_79; - } - } - if (v64 == 1 && v67 == 1) { - v12 = 1; - if (!AllItemsList[plr[v3].HoldItem.IDidx].iUsable) - v12 = 0; - if (!plr[v3].HoldItem._iStatFlag) - v12 = 0; - if (plr[v3].HoldItem._itype == ITYPE_GOLD) { - v12 = 0; - goto LABEL_50; - } - } + v10 = v68; + v69 = ILOC_UNEQUIPABLE; + if (v68 >= 0 && v68 <= ILOC_ARMOR) + v69 = ILOC_HELM; + if (v68 >= ILOC_HELM && v68 <= ILOC_RING) + v69 = ILOC_RING; + if (v68 == ILOC_AMULET) + v69 = ILOC_AMULET; + if (v68 >= ILOC_UNEQUIPABLE && v68 <= 18) + v69 = ILOC_ONEHAND; + if (v68 >= 19 && v68 <= 24) + v69 = ILOC_ARMOR; + if (v68 >= 65 && v68 <= 72) + v69 = ILOC_BELT; + v11 = plr[v3].HoldItem._iLoc; + v12 = 0; + if ((char)v11 == v69) + v12 = 1; + if (v69 == 1 && v11 == ILOC_TWOHAND) { + v69 = ILOC_TWOHAND; + v12 = 1; + } + if (v11 != 7 || v69 != ILOC_BELT) { + LABEL_50: + if (v69 != ILOC_UNEQUIPABLE) + goto LABEL_81; + v66 = 0; + cursor_id = 1; + v13 = (v68 - 25) / 10; + if (plr[v3].HoldItem._itype == ITYPE_GOLD) { + _LOBYTE(v13) = plr[0].InvGrid[10 * v13 + v3 * 21720 + (v68 - 25) % 10]; + if (!(_BYTE)v13) + goto LABEL_93; + v13 = (char)v13; + if ((char)v13 <= 0) { + v13 = -v13; + } else if (*(int *)((char *)&plr[0].InvBody[v13 + 6]._itype + v3 * 21720) == ITYPE_GOLD) { + goto LABEL_93; + } + v66 = v13; + LABEL_93: + v21 = p; + if (p == myplr) { + PlaySFX(ItemInvSnds[ItemCAnimTbl[plr[v3].HoldItem._iCurs]]); + v10 = v68; + } + cursor_ida = 1; + switch (v69) { + case ILOC_ONEHAND: + if (v10 > 12) { + if (plr[v3].InvBody[INVLOC_HAND_RIGHT]._itype == ITYPE_NONE) { + v25 = plr[v3].InvBody[INVLOC_HAND_LEFT]._itype; + if (v25 == ITYPE_NONE) + goto LABEL_232; + if (plr[v3].InvBody[INVLOC_HAND_LEFT]._iLoc == ILOC_TWOHAND) { + NetSendCmdDelItem(FALSE, 4u); + NetSendCmdChItem(FALSE, 5u); + SwapItem(&plr[v3].InvBody[INVLOC_HAND_RIGHT], &plr[v3].InvBody[INVLOC_HAND_LEFT]); + v23 = &plr[v3].InvBody[INVLOC_HAND_RIGHT]; + LABEL_99: + v24 = SwapItem(v23, &plr[v3].HoldItem); + LABEL_172: + cursor_ida = v24; + goto LABEL_226; + } + if (v25 == ITYPE_NONE || plr[v3].InvBody[INVLOC_HAND_LEFT]._iClass != plr[v3].HoldItem._iClass) { + LABEL_232: + NetSendCmdChItem(FALSE, 5u); + v22 = &plr[v3].InvBody[INVLOC_HAND_RIGHT]; + LABEL_158: + qmemcpy(v22, &plr[v3].HoldItem, sizeof(ItemStruct)); + goto LABEL_226; + } + } else if (plr[v3].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_NONE + || plr[v3].InvBody[INVLOC_HAND_LEFT]._iClass != plr[v3].HoldItem._iClass) { + goto LABEL_114; + } + } else { + if (plr[v3].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_NONE) { + if (plr[v3].InvBody[INVLOC_HAND_RIGHT]._itype != ITYPE_NONE + && plr[v3].InvBody[INVLOC_HAND_RIGHT]._iClass == plr[v3].HoldItem._iClass) { + LABEL_114: + NetSendCmdChItem(FALSE, 5u); + v23 = &plr[v3].InvBody[INVLOC_HAND_RIGHT]; + goto LABEL_99; + } + NetSendCmdChItem(FALSE, 4u); + v22 = &plr[v3].InvBody[INVLOC_HAND_LEFT]; + goto LABEL_158; + } + if (plr[v3].InvBody[INVLOC_HAND_RIGHT]._itype != ITYPE_NONE + && plr[v3].InvBody[INVLOC_HAND_RIGHT]._iClass == plr[v3].HoldItem._iClass) { + goto LABEL_114; + } + } + NetSendCmdChItem(FALSE, 4u); + v23 = &plr[v3].InvBody[INVLOC_HAND_LEFT]; + goto LABEL_99; + case ILOC_TWOHAND: + NetSendCmdDelItem(FALSE, 5u); + if (plr[v3].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_NONE) + goto LABEL_147; + v26 = plr[v3].InvBody[INVLOC_HAND_RIGHT]._itype; + if (v26 == -1) + goto LABEL_146; + qmemcpy(&tempitem, &plr[v3].HoldItem, sizeof(tempitem)); + v27 = &plr[v3].InvBody[INVLOC_HAND_RIGHT]; + if (v26 != 5) + v27 = &plr[v3].InvBody[INVLOC_HAND_LEFT]; + v28 = p; + qmemcpy(&plr[v3].HoldItem, v27, sizeof(plr[v3].HoldItem)); + v29 = plr[v3].HoldItem._iCurs + 12; + if (v28 == myplr) + SetCursor(v29); + else + SetICursor(v29); + v67 = 0; + v30 = 0; + do { + if (v67) + break; + v31 = AutoPlace(p, v30++, icursW28, icursH28, 1); + v67 = v31; + } while (v30 < 40); + v32 = p; + qmemcpy(&plr[v3].HoldItem, &tempitem, sizeof(plr[v3].HoldItem)); + v33 = plr[v3].HoldItem._iCurs + 12; + if (v32 == myplr) + SetCursor(v33); + else + SetICursor(v33); + if (!v67) + return; + if (plr[v3].InvBody[INVLOC_HAND_RIGHT]._itype == ITYPE_SHIELD) + plr[v3].InvBody[INVLOC_HAND_RIGHT]._itype = ITYPE_NONE; + else + plr[v3].InvBody[INVLOC_HAND_LEFT]._itype = ITYPE_NONE; + LABEL_146: + if (plr[v3].InvBody[INVLOC_HAND_LEFT]._itype != ITYPE_NONE) + goto LABEL_149; + LABEL_147: + if (plr[v3].InvBody[INVLOC_HAND_RIGHT]._itype == ITYPE_NONE) { + NetSendCmdChItem(FALSE, 4u); + qmemcpy(&plr[v3].InvBody[INVLOC_HAND_LEFT], &plr[v3].HoldItem, sizeof(plr[v3].InvBody[INVLOC_HAND_LEFT])); + } else { + LABEL_149: + NetSendCmdChItem(FALSE, 4u); + if (plr[v3].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_NONE) + SwapItem(&plr[v3].InvBody[INVLOC_HAND_LEFT], &plr[v3].InvBody[INVLOC_HAND_RIGHT]); + cursor_ida = SwapItem(&plr[v3].InvBody[INVLOC_HAND_LEFT], &plr[v3].HoldItem); + } + if (plr[v3].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_STAFF) { + v34 = plr[v3].InvBody[INVLOC_HAND_LEFT]._iSpell; + if (v34) { + if (plr[v3].InvBody[INVLOC_HAND_LEFT]._iCharges > 0) { + plr[v3]._pRSpell = v34; + _LOBYTE(plr[v3]._pRSplType) = RSPLTYPE_CHARGES; + drawpanflag = 255; + } + } + } + goto LABEL_226; + case ILOC_ARMOR: + NetSendCmdChItem(FALSE, 6u); + if (plr[v3].InvBody[INVLOC_CHEST]._itype == ITYPE_NONE) { + v22 = &plr[v3].InvBody[INVLOC_CHEST]; + goto LABEL_158; + } + v23 = &plr[v3].InvBody[INVLOC_CHEST]; + goto LABEL_99; + case ILOC_HELM: + NetSendCmdChItem(FALSE, 0); + if (plr[v3].InvBody[INVLOC_HEAD]._itype == ITYPE_NONE) { + v22 = plr[v3].InvBody; + goto LABEL_158; + } + v23 = plr[v3].InvBody; + goto LABEL_99; + case ILOC_RING: + if (v10 == 4) { + NetSendCmdChItem(FALSE, 1u); + if (plr[v3].InvBody[INVLOC_RING_LEFT]._itype == ITYPE_NONE) { + v22 = &plr[v3].InvBody[INVLOC_RING_LEFT]; + goto LABEL_158; + } + v23 = &plr[v3].InvBody[INVLOC_RING_LEFT]; + } else { + NetSendCmdChItem(FALSE, 2u); + if (plr[v3].InvBody[INVLOC_RING_RIGHT]._itype == ITYPE_NONE) { + v22 = &plr[v3].InvBody[INVLOC_RING_RIGHT]; + goto LABEL_158; + } + v23 = &plr[v3].InvBody[INVLOC_RING_RIGHT]; + } + goto LABEL_99; + case ILOC_AMULET: + NetSendCmdChItem(FALSE, 3u); + if (plr[v3].InvBody[INVLOC_AMULET]._itype == ITYPE_NONE) { + v22 = &plr[v3].InvBody[INVLOC_AMULET]; + goto LABEL_158; + } + v23 = &plr[v3].InvBody[INVLOC_AMULET]; + goto LABEL_99; + case ILOC_UNEQUIPABLE: + v35 = plr[v3].HoldItem._itype; + if (v35 == 11) { + if (!v66) { + v36 = &plr[0].InvGrid[10 * ((v68 - 25) / 10) + v3 * 21720 + (v68 - 25) % 10]; + if (*v36 <= 0) { + v42 = 368 * plr[v3]._pNumInv + v3 * 21720; + qmemcpy((char *)plr[0].InvList + v42, &plr[v3].HoldItem, 0x170u); + ++plr[v3]._pNumInv; + *v36 = plr[v3]._pNumInv; + v43 = plr[v3].HoldItem._ivalue; + plr[v3]._pGold += v43; + if (v43 <= 5000) { + if (v43 < 2500) { + if (v43 > 1000) + *(int *)((char *)&plr[0].InvList[0]._iCurs + v42) = 5; + else + *(int *)((char *)&plr[0].InvList[0]._iCurs + v42) = 4; + } else { + *(int *)((char *)&plr[0].InvList[0]._iCurs + v42) = 6; + } + } + goto LABEL_226; + } + v37 = plr[v3].HoldItem._ivalue; + v38 = 368 * (*v36 - 1) + v3 * 21720; + v39 = *(int *)((char *)&plr[0].InvList[0]._ivalue + v38); + v40 = v37 + v39; + if (v37 + v39 <= 5000) { + *(int *)((char *)&plr[0].InvList[0]._ivalue + v38) = v40; + plr[v3]._pGold += plr[v3].HoldItem._ivalue; + if (v40 < 2500) { + if (v40 > 1000) + *(int *)((char *)&plr[0].InvList[0]._iCurs + v38) = 5; + else + *(int *)((char *)&plr[0].InvList[0]._iCurs + v38) = 4; + } else { + *(int *)((char *)&plr[0].InvList[0]._iCurs + v38) = 6; + } + goto LABEL_226; + } + plr[v3]._pGold += 5000 - v39; + plr[v3].HoldItem._ivalue = v37 - (5000 - v39); + *(int *)((char *)&plr[0].InvList[0]._ivalue + v38) = 5000; + *(int *)((char *)&plr[0].InvList[0]._iCurs + v38) = 6; + v41 = plr[v3].HoldItem._ivalue; + if (v41 >= 2500) { + cursor_ida = 18; + goto LABEL_226; + } + v24 = (v41 > 1000) + 16; + goto LABEL_172; + } + } else if (!v66) { + qmemcpy((char *)&plr[0].InvList[plr[v3]._pNumInv++] + v3 * 21720, &plr[v3].HoldItem, 0x170u); + v66 = plr[v3]._pNumInv; + LABEL_191: + v48 = v67; + v49 = 10 * ((v68 - 25) / 10 - ((v67 - 1) >> 1)); + if (v49 < 0) + v49 = 0; + v65 = 0; + if (v67 > 0) { + v69 = (v68 - 25) % 10 - ((v64 - 1) >> 1); + do { + v50 = v69; + if (v69 < 0) + v50 = 0; + v67 = 0; + if (v64 > 0) { + v51 = &plr[v3].InvGrid[v50 + v49]; + do { + if (v67 || v65 != v48 - 1) + v52 = -(char)v66; + else + v52 = v66; + *v51++ = v52; + ++v67; + } while (v67 < v64); + } + v49 += 10; + ++v65; + } while (v65 < v48); + } + goto LABEL_226; + } + v44 = v66 - 1; + if (v35 == 11) + plr[v3]._pGold += plr[v3].HoldItem._ivalue; + cursor_ida = SwapItem((ItemStruct *)((char *)&plr[0].InvList[v44] + v3 * 21720), &plr[v3].HoldItem); + if (plr[v3].HoldItem._itype == ITYPE_GOLD) + plr[v3]._pGold = CalculateGold(v21); + v45 = 0; + v46 = -v66; + do { + v47 = &plr[v3].InvGrid[v45]; + if (*v47 == v66) + *v47 = 0; + if (*v47 == v46) + *v47 = 0; + ++v45; + } while (v45 < 40); + goto LABEL_191; + case ILOC_BELT: + v53 = v3 * 21720 + 368 * (v68 - 65); + if (plr[v3].HoldItem._itype != ITYPE_GOLD) { + if (*(int *)((char *)&plr[0].SpdList[0]._itype + v53) == ITYPE_NONE) { + qmemcpy((char *)plr[0].SpdList + v53, &plr[v3].HoldItem, 0x170u); + } else { + cursor_ida = SwapItem((ItemStruct *)((char *)plr[0].SpdList + v53), &plr[v3].HoldItem); + if (plr[v3].HoldItem._itype == ITYPE_GOLD) + plr[v3]._pGold = CalculateGold(p); + } + goto LABEL_225; + } + v54 = *(int *)((char *)&plr[0].SpdList[0]._itype + v53); + if (v54 != -1) { + if (v54 == 11) { + v55 = *(int *)((char *)&plr[0].SpdList[0]._ivalue + v53); + v56 = plr[v3].HoldItem._ivalue; + v57 = v55 + v56; + if (v55 + v56 <= 5000) { + *(int *)((char *)&plr[0].SpdList[0]._ivalue + v53) = v57; + plr[v3]._pGold += plr[v3].HoldItem._ivalue; + if (v57 < 2500) { + if (v57 > 1000) + *(int *)((char *)&plr[0].SpdList[0]._iCurs + v53) = 5; + else + *(int *)((char *)&plr[0].SpdList[0]._iCurs + v53) = 4; + } else { + *(int *)((char *)&plr[0].SpdList[0]._iCurs + v53) = 6; + } + goto LABEL_225; + } + plr[v3]._pGold += 5000 - v55; + plr[v3].HoldItem._ivalue = v56 - (5000 - v55); + *(int *)((char *)&plr[0].SpdList[0]._ivalue + v53) = 5000; + *(int *)((char *)&plr[0].SpdList[0]._iCurs + v53) = 6; + v58 = plr[v3].HoldItem._ivalue; + if (v58 >= 2500) { + cursor_ida = 18; + goto LABEL_225; + } + v59 = (v58 > 1000) + 16; + } else { + plr[v3]._pGold += plr[v3].HoldItem._ivalue; + v59 = SwapItem((ItemStruct *)((char *)plr[0].SpdList + v53), &plr[v3].HoldItem); + } + cursor_ida = v59; + goto LABEL_225; + } + qmemcpy((char *)plr[0].SpdList + v53, &plr[v3].HoldItem, 0x170u); + plr[v3]._pGold += plr[v3].HoldItem._ivalue; + LABEL_225: + drawsbarflag = 1; + LABEL_226: + v60 = p; + CalcPlrInv(p, 1u); + if (v60 == myplr) { + if (cursor_ida == 1) + SetCursorPos(MouseX + (cursW >> 1), MouseY + (cursH >> 1)); + SetCursor(cursor_ida); + } + return; + default: + goto LABEL_226; + } + } + v62 = (v68 - 25) % 10; + v14 = 10 * (v13 - ((v67 - 1) >> 1)); + if (v14 < 0) + v14 = 0; + v65 = 0; + if (v67 <= 0) + goto LABEL_93; + v15 = &plr[v3].InvGrid[v14]; + while (1) { + if (cursor_id == CURSOR_NONE) + return; + if (v14 >= 40) + cursor_id = 0; + v16 = v62 - ((v64 - 1) >> 1); + if (v16 < 0) + v16 = 0; + v17 = 0; + if (v64 > 0) + break; + LABEL_79: + v14 += 10; + v15 += 10; + if (++v65 >= v67) { + v12 = cursor_id; + v10 = v68; + goto LABEL_81; + } + } + while (1) { + if (cursor_id == CURSOR_NONE) + goto LABEL_79; + if (v16 >= 10) + goto LABEL_233; + _LOBYTE(v18) = v15[v16]; + if ((_BYTE)v18) { + v18 = (char)v18; + if ((v18 & 0x80u) != 0) + v18 = -v18; + if (!v66) { + v66 = v18; + goto LABEL_78; + } + if (v66 != v18) + LABEL_233: + cursor_id = 0; + } + LABEL_78: + ++v16; + if (++v17 >= v64) + goto LABEL_79; + } + } + if (v64 == 1 && v67 == 1) { + v12 = 1; + if (!AllItemsList[plr[v3].HoldItem.IDidx].iUsable) + v12 = 0; + if (!plr[v3].HoldItem._iStatFlag) + v12 = 0; + if (plr[v3].HoldItem._itype == ITYPE_GOLD) { + v12 = 0; + goto LABEL_50; + } + } LABEL_81: - if (!v12) - return; - if (v69 == ILOC_UNEQUIPABLE || v69 == ILOC_BELT || plr[v3].HoldItem._iStatFlag) { - goto LABEL_93; - } - if (plr[v3]._pClass == PC_WARRIOR) { - PlaySFX(PS_WARR13); - } else if (plr[v3]._pClass == PC_ROGUE) { - PlaySFX(PS_ROGUE13); - } else if (plr[v3]._pClass == PC_SORCERER) { - PlaySFX(PS_MAGE13); - } + if (!v12) + return; + if (v69 == ILOC_UNEQUIPABLE || v69 == ILOC_BELT || plr[v3].HoldItem._iStatFlag) { + goto LABEL_93; + } + if (plr[v3]._pClass == PC_WARRIOR) { + PlaySFX(PS_WARR13); + } else if (plr[v3]._pClass == PC_ROGUE) { + PlaySFX(PS_ROGUE13); + } else if (plr[v3]._pClass == PC_SORCERER) { + PlaySFX(PS_MAGE13); + } } // 4B8C9C: using guessed type int cursH; // 4B8CB4: using guessed type int icursH; @@ -1376,1271 +1376,1271 @@ LABEL_81: void __fastcall CheckInvSwap(int pnum, BYTE bLoc, int idx, WORD wCI, int seed, BOOL bId) { - RecreateItem(MAXITEMS, idx, wCI, seed, 0); + RecreateItem(MAXITEMS, idx, wCI, seed, 0); - PlayerStruct *p = &plr[pnum]; - p->HoldItem = item[MAXITEMS]; + PlayerStruct *p = &plr[pnum]; + p->HoldItem = item[MAXITEMS]; - if (bId) { - p->HoldItem._iIdentified = TRUE; - } + if (bId) { + p->HoldItem._iIdentified = TRUE; + } - if (bLoc < NUM_INVLOC) { - p->InvBody[bLoc] = p->HoldItem; + if (bLoc < NUM_INVLOC) { + p->InvBody[bLoc] = p->HoldItem; - if (bLoc == INVLOC_HAND_LEFT && p->HoldItem._iLoc == ILOC_TWOHAND) { - p->InvBody[INVLOC_HAND_RIGHT]._itype = ITYPE_NONE; - } else if (bLoc == INVLOC_HAND_RIGHT && p->HoldItem._iLoc == ILOC_TWOHAND) { - p->InvBody[INVLOC_HAND_LEFT]._itype = ITYPE_NONE; - } - } + if (bLoc == INVLOC_HAND_LEFT && p->HoldItem._iLoc == ILOC_TWOHAND) { + p->InvBody[INVLOC_HAND_RIGHT]._itype = ITYPE_NONE; + } else if (bLoc == INVLOC_HAND_RIGHT && p->HoldItem._iLoc == ILOC_TWOHAND) { + p->InvBody[INVLOC_HAND_LEFT]._itype = ITYPE_NONE; + } + } - CalcPlrInv(pnum, TRUE); + CalcPlrInv(pnum, TRUE); } void __fastcall CheckInvCut(int pnum, int mx, int my) { - if (plr[pnum]._pmode > PM_WALK3) { - return; - } + if (plr[pnum]._pmode > PM_WALK3) { + return; + } - if (dropGoldFlag) { - dropGoldFlag = 0; - dropGoldValue = 0; - } + if (dropGoldFlag) { + dropGoldFlag = 0; + dropGoldValue = 0; + } - int r; - BOOL done = FALSE; + int r; + BOOL done = FALSE; - // TODO: this loop is compiled differently (via InvRect pointers) - for (r = 0; (DWORD)r < NUM_XY_SLOTS && !done; r++) { - // check which inventory rectangle the mouse is in, if any - if (mx >= InvRect[r].X - && mx < InvRect[r].X + (INV_SLOT_SIZE_PX + 1) - && my >= InvRect[r].Y - (INV_SLOT_SIZE_PX + 1) - && my < InvRect[r].Y) { - done = TRUE; - r--; - } - } + // TODO: this loop is compiled differently (via InvRect pointers) + for (r = 0; (DWORD)r < NUM_XY_SLOTS && !done; r++) { + // check which inventory rectangle the mouse is in, if any + if (mx >= InvRect[r].X + && mx < InvRect[r].X + (INV_SLOT_SIZE_PX + 1) + && my >= InvRect[r].Y - (INV_SLOT_SIZE_PX + 1) + && my < InvRect[r].Y) { + done = TRUE; + r--; + } + } - if (!done) { - // not on an inventory slot rectangle - return; - } + if (!done) { + // not on an inventory slot rectangle + return; + } - plr[pnum].HoldItem._itype = ITYPE_NONE; + plr[pnum].HoldItem._itype = ITYPE_NONE; - if ( - r >= SLOTXY_HEAD_FIRST - && r <= SLOTXY_HEAD_LAST - && plr[pnum].InvBody[INVLOC_HEAD]._itype != ITYPE_NONE) { - NetSendCmdDelItem(FALSE, INVLOC_HEAD); - plr[pnum].HoldItem = plr[pnum].InvBody[INVLOC_HEAD]; - plr[pnum].InvBody[INVLOC_HEAD]._itype = ITYPE_NONE; - } + if ( + r >= SLOTXY_HEAD_FIRST + && r <= SLOTXY_HEAD_LAST + && plr[pnum].InvBody[INVLOC_HEAD]._itype != ITYPE_NONE) { + NetSendCmdDelItem(FALSE, INVLOC_HEAD); + plr[pnum].HoldItem = plr[pnum].InvBody[INVLOC_HEAD]; + plr[pnum].InvBody[INVLOC_HEAD]._itype = ITYPE_NONE; + } - if ( - r == SLOTXY_RING_LEFT - && plr[pnum].InvBody[INVLOC_RING_LEFT]._itype != ITYPE_NONE) { - NetSendCmdDelItem(FALSE, INVLOC_RING_LEFT); - plr[pnum].HoldItem = plr[pnum].InvBody[INVLOC_RING_LEFT]; - plr[pnum].InvBody[INVLOC_RING_LEFT]._itype = ITYPE_NONE; - } + if ( + r == SLOTXY_RING_LEFT + && plr[pnum].InvBody[INVLOC_RING_LEFT]._itype != ITYPE_NONE) { + NetSendCmdDelItem(FALSE, INVLOC_RING_LEFT); + plr[pnum].HoldItem = plr[pnum].InvBody[INVLOC_RING_LEFT]; + plr[pnum].InvBody[INVLOC_RING_LEFT]._itype = ITYPE_NONE; + } - if ( - r == SLOTXY_RING_RIGHT - && plr[pnum].InvBody[INVLOC_RING_RIGHT]._itype != ITYPE_NONE) { - NetSendCmdDelItem(FALSE, INVLOC_RING_RIGHT); - plr[pnum].HoldItem = plr[pnum].InvBody[INVLOC_RING_RIGHT]; - plr[pnum].InvBody[INVLOC_RING_RIGHT]._itype = ITYPE_NONE; - } + if ( + r == SLOTXY_RING_RIGHT + && plr[pnum].InvBody[INVLOC_RING_RIGHT]._itype != ITYPE_NONE) { + NetSendCmdDelItem(FALSE, INVLOC_RING_RIGHT); + plr[pnum].HoldItem = plr[pnum].InvBody[INVLOC_RING_RIGHT]; + plr[pnum].InvBody[INVLOC_RING_RIGHT]._itype = ITYPE_NONE; + } - if ( - r == SLOTXY_AMULET - && plr[pnum].InvBody[INVLOC_AMULET]._itype != ITYPE_NONE) { - NetSendCmdDelItem(FALSE, INVLOC_AMULET); - plr[pnum].HoldItem = plr[pnum].InvBody[INVLOC_AMULET]; - plr[pnum].InvBody[INVLOC_AMULET]._itype = ITYPE_NONE; - } + if ( + r == SLOTXY_AMULET + && plr[pnum].InvBody[INVLOC_AMULET]._itype != ITYPE_NONE) { + NetSendCmdDelItem(FALSE, INVLOC_AMULET); + plr[pnum].HoldItem = plr[pnum].InvBody[INVLOC_AMULET]; + plr[pnum].InvBody[INVLOC_AMULET]._itype = ITYPE_NONE; + } - if ( - r >= SLOTXY_HAND_LEFT_FIRST - && r <= SLOTXY_HAND_LEFT_LAST - && plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype != ITYPE_NONE) { - NetSendCmdDelItem(FALSE, INVLOC_HAND_LEFT); - plr[pnum].HoldItem = plr[pnum].InvBody[INVLOC_HAND_LEFT]; - plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype = ITYPE_NONE; - } + if ( + r >= SLOTXY_HAND_LEFT_FIRST + && r <= SLOTXY_HAND_LEFT_LAST + && plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype != ITYPE_NONE) { + NetSendCmdDelItem(FALSE, INVLOC_HAND_LEFT); + plr[pnum].HoldItem = plr[pnum].InvBody[INVLOC_HAND_LEFT]; + plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype = ITYPE_NONE; + } - if ( - r >= SLOTXY_HAND_RIGHT_FIRST - && r <= SLOTXY_HAND_RIGHT_LAST - && plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype != ITYPE_NONE) { - NetSendCmdDelItem(FALSE, INVLOC_HAND_RIGHT); - plr[pnum].HoldItem = plr[pnum].InvBody[INVLOC_HAND_RIGHT]; - plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype = ITYPE_NONE; - } + if ( + r >= SLOTXY_HAND_RIGHT_FIRST + && r <= SLOTXY_HAND_RIGHT_LAST + && plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype != ITYPE_NONE) { + NetSendCmdDelItem(FALSE, INVLOC_HAND_RIGHT); + plr[pnum].HoldItem = plr[pnum].InvBody[INVLOC_HAND_RIGHT]; + plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype = ITYPE_NONE; + } - if ( - r >= SLOTXY_CHEST_FIRST - && r <= SLOTXY_CHEST_LAST - && plr[pnum].InvBody[INVLOC_CHEST]._itype != ITYPE_NONE) { - NetSendCmdDelItem(FALSE, INVLOC_CHEST); - plr[pnum].HoldItem = plr[pnum].InvBody[INVLOC_CHEST]; - plr[pnum].InvBody[INVLOC_CHEST]._itype = ITYPE_NONE; - } + if ( + r >= SLOTXY_CHEST_FIRST + && r <= SLOTXY_CHEST_LAST + && plr[pnum].InvBody[INVLOC_CHEST]._itype != ITYPE_NONE) { + NetSendCmdDelItem(FALSE, INVLOC_CHEST); + plr[pnum].HoldItem = plr[pnum].InvBody[INVLOC_CHEST]; + plr[pnum].InvBody[INVLOC_CHEST]._itype = ITYPE_NONE; + } - if (r >= SLOTXY_INV_FIRST && r <= SLOTXY_INV_LAST) { - char ii = plr[pnum].InvGrid[r - SLOTXY_INV_FIRST]; - if (ii) { - int iv = ii; - if (ii <= 0) { - iv = -ii; - } + if (r >= SLOTXY_INV_FIRST && r <= SLOTXY_INV_LAST) { + char ii = plr[pnum].InvGrid[r - SLOTXY_INV_FIRST]; + if (ii) { + int iv = ii; + if (ii <= 0) { + iv = -ii; + } - for (int i = 0; i < NUM_INV_GRID_ELEM; i++) { - if (plr[pnum].InvGrid[i] == iv || plr[pnum].InvGrid[i] == -iv) { - plr[pnum].InvGrid[i] = 0; - } - } + for (int i = 0; i < NUM_INV_GRID_ELEM; i++) { + if (plr[pnum].InvGrid[i] == iv || plr[pnum].InvGrid[i] == -iv) { + plr[pnum].InvGrid[i] = 0; + } + } - iv--; + iv--; - plr[pnum].HoldItem = plr[pnum].InvList[iv]; - plr[pnum]._pNumInv--; + plr[pnum].HoldItem = plr[pnum].InvList[iv]; + plr[pnum]._pNumInv--; - if (plr[pnum]._pNumInv > 0 && plr[pnum]._pNumInv != iv) { - plr[pnum].InvList[iv] = plr[pnum].InvList[plr[pnum]._pNumInv]; + if (plr[pnum]._pNumInv > 0 && plr[pnum]._pNumInv != iv) { + plr[pnum].InvList[iv] = plr[pnum].InvList[plr[pnum]._pNumInv]; - for (int j = 0; j < NUM_INV_GRID_ELEM; j++) { - if (plr[pnum].InvGrid[j] == plr[pnum]._pNumInv + 1) { - plr[pnum].InvGrid[j] = iv + 1; - } - if (plr[pnum].InvGrid[j] == -(plr[pnum]._pNumInv + 1)) { - plr[pnum].InvGrid[j] = -iv - 1; - } - } - } - } - } + for (int j = 0; j < NUM_INV_GRID_ELEM; j++) { + if (plr[pnum].InvGrid[j] == plr[pnum]._pNumInv + 1) { + plr[pnum].InvGrid[j] = iv + 1; + } + if (plr[pnum].InvGrid[j] == -(plr[pnum]._pNumInv + 1)) { + plr[pnum].InvGrid[j] = -iv - 1; + } + } + } + } + } - if (r >= SLOTXY_BELT_FIRST) { - int offs = r - SLOTXY_BELT_FIRST; - if (plr[pnum].SpdList[offs]._itype != ITYPE_NONE) { - plr[pnum].HoldItem = plr[pnum].SpdList[offs]; - plr[pnum].SpdList[offs]._itype = ITYPE_NONE; - drawsbarflag = 1; - } - } + if (r >= SLOTXY_BELT_FIRST) { + int offs = r - SLOTXY_BELT_FIRST; + if (plr[pnum].SpdList[offs]._itype != ITYPE_NONE) { + plr[pnum].HoldItem = plr[pnum].SpdList[offs]; + plr[pnum].SpdList[offs]._itype = ITYPE_NONE; + drawsbarflag = 1; + } + } - if (plr[pnum].HoldItem._itype != ITYPE_NONE) { - if (plr[pnum].HoldItem._itype == ITYPE_GOLD) { - plr[pnum]._pGold = CalculateGold(pnum); - } + if (plr[pnum].HoldItem._itype != ITYPE_NONE) { + if (plr[pnum].HoldItem._itype == ITYPE_GOLD) { + plr[pnum]._pGold = CalculateGold(pnum); + } - CalcPlrInv(pnum, TRUE); - CheckItemStats(pnum); + CalcPlrInv(pnum, TRUE); + CheckItemStats(pnum); - if (pnum == myplr) { - PlaySFX(IS_IGRAB); - SetCursor(plr[pnum].HoldItem._iCurs + CURSOR_FIRSTITEM); - SetCursorPos(mx - (cursW >> 1), MouseY - (cursH >> 1)); - } - } + if (pnum == myplr) { + PlaySFX(IS_IGRAB); + SetCursor(plr[pnum].HoldItem._iCurs + CURSOR_FIRSTITEM); + SetCursorPos(mx - (cursW >> 1), MouseY - (cursH >> 1)); + } + } } void __fastcall inv_update_rem_item(int pnum, BYTE iv) { - if (iv < NUM_INVLOC) { - plr[pnum].InvBody[iv]._itype = ITYPE_NONE; - } + if (iv < NUM_INVLOC) { + plr[pnum].InvBody[iv]._itype = ITYPE_NONE; + } - BOOL Loadgfx = FALSE; + BOOL Loadgfx = FALSE; - if (plr[pnum]._pmode != PM_DEATH) { - Loadgfx = TRUE; - } + if (plr[pnum]._pmode != PM_DEATH) { + Loadgfx = TRUE; + } - CalcPlrInv(pnum, Loadgfx); + CalcPlrInv(pnum, Loadgfx); } void __fastcall RemoveInvItem(int pnum, int iv) { - iv++; + iv++; - for (int i = 0; i < NUM_INV_GRID_ELEM; i++) { - if (plr[pnum].InvGrid[i] == iv || plr[pnum].InvGrid[i] == -iv) { - plr[pnum].InvGrid[i] = 0; - } - } + for (int i = 0; i < NUM_INV_GRID_ELEM; i++) { + if (plr[pnum].InvGrid[i] == iv || plr[pnum].InvGrid[i] == -iv) { + plr[pnum].InvGrid[i] = 0; + } + } - iv--; - plr[pnum]._pNumInv--; + iv--; + plr[pnum]._pNumInv--; - if (plr[pnum]._pNumInv > 0 && plr[pnum]._pNumInv != iv) { - plr[pnum].InvList[iv] = plr[pnum].InvList[plr[pnum]._pNumInv]; + if (plr[pnum]._pNumInv > 0 && plr[pnum]._pNumInv != iv) { + plr[pnum].InvList[iv] = plr[pnum].InvList[plr[pnum]._pNumInv]; - for (int j = 0; j < NUM_INV_GRID_ELEM; j++) { - if (plr[pnum].InvGrid[j] == plr[pnum]._pNumInv + 1) { - plr[pnum].InvGrid[j] = iv + 1; - } - if (plr[pnum].InvGrid[j] == -(plr[pnum]._pNumInv + 1)) { - plr[pnum].InvGrid[j] = -(iv + 1); - } - } - } + for (int j = 0; j < NUM_INV_GRID_ELEM; j++) { + if (plr[pnum].InvGrid[j] == plr[pnum]._pNumInv + 1) { + plr[pnum].InvGrid[j] = iv + 1; + } + if (plr[pnum].InvGrid[j] == -(plr[pnum]._pNumInv + 1)) { + plr[pnum].InvGrid[j] = -(iv + 1); + } + } + } - CalcPlrScrolls(pnum); + CalcPlrScrolls(pnum); - if (plr[pnum]._pRSplType == RSPLTYPE_SCROLL) { - if (plr[pnum]._pRSpell != SPL_INVALID) { - // BUGFIX: Cast the literal `1` to `unsigned __int64` to make that bitshift 64bit - // this causes the last 4 skills to not reset correctly after use - if (!( - plr[pnum]._pScrlSpells - & (1 << (plr[pnum]._pRSpell - 1)))) { - plr[pnum]._pRSpell = SPL_INVALID; - } + if (plr[pnum]._pRSplType == RSPLTYPE_SCROLL) { + if (plr[pnum]._pRSpell != SPL_INVALID) { + // BUGFIX: Cast the literal `1` to `unsigned __int64` to make that bitshift 64bit + // this causes the last 4 skills to not reset correctly after use + if (!( + plr[pnum]._pScrlSpells + & (1 << (plr[pnum]._pRSpell - 1)))) { + plr[pnum]._pRSpell = SPL_INVALID; + } - drawpanflag = 255; - } - } + drawpanflag = 255; + } + } } void __fastcall RemoveSpdBarItem(int pnum, int iv) { - plr[pnum].SpdList[iv]._itype = ITYPE_NONE; + plr[pnum].SpdList[iv]._itype = ITYPE_NONE; - CalcPlrScrolls(pnum); + CalcPlrScrolls(pnum); - if (plr[pnum]._pRSplType == RSPLTYPE_SCROLL) { - if (plr[pnum]._pRSpell != SPL_INVALID) { - // BUGFIX: Cast the literal `1` to `unsigned __int64` to make that bitshift 64bit - // this causes the last 4 skills to not reset correctly after use - if (!( - plr[pnum]._pScrlSpells - & (1 << (plr[pnum]._pRSpell - 1)))) { - plr[pnum]._pRSpell = SPL_INVALID; - } - } - } - drawpanflag = 255; + if (plr[pnum]._pRSplType == RSPLTYPE_SCROLL) { + if (plr[pnum]._pRSpell != SPL_INVALID) { + // BUGFIX: Cast the literal `1` to `unsigned __int64` to make that bitshift 64bit + // this causes the last 4 skills to not reset correctly after use + if (!( + plr[pnum]._pScrlSpells + & (1 << (plr[pnum]._pRSpell - 1)))) { + plr[pnum]._pRSpell = SPL_INVALID; + } + } + } + drawpanflag = 255; } void __cdecl CheckInvItem() { - if (pcurs >= CURSOR_FIRSTITEM) { - CheckInvPaste(myplr, MouseX, MouseY); - } else { - CheckInvCut(myplr, MouseX, MouseY); - } + if (pcurs >= CURSOR_FIRSTITEM) { + CheckInvPaste(myplr, MouseX, MouseY); + } else { + CheckInvCut(myplr, MouseX, MouseY); + } } void __cdecl CheckInvScrn() { - if (MouseX > 190 && MouseX < 437 - && MouseY > 352 && MouseY < 385) { - CheckInvItem(); - } + if (MouseX > 190 && MouseX < 437 + && MouseY > 352 && MouseY < 385) { + CheckInvItem(); + } } void __fastcall CheckItemStats(int pnum) { - PlayerStruct *p = &plr[pnum]; + PlayerStruct *p = &plr[pnum]; - p->HoldItem._iStatFlag = FALSE; + p->HoldItem._iStatFlag = FALSE; - if (p->_pStrength >= p->HoldItem._iMinStr - && p->_pMagic >= p->HoldItem._iMinMag - && p->_pDexterity >= p->HoldItem._iMinDex) { - p->HoldItem._iStatFlag = TRUE; - } + if (p->_pStrength >= p->HoldItem._iMinStr + && p->_pMagic >= p->HoldItem._iMinMag + && p->_pDexterity >= p->HoldItem._iMinDex) { + p->HoldItem._iStatFlag = TRUE; + } } void __fastcall CheckBookLevel(int pnum) { - int v1; // ecx - int v2; // eax - unsigned char v3; // bl - int v4; // edi + int v1; // ecx + int v2; // eax + unsigned char v3; // bl + int v4; // edi - v1 = pnum; - if (plr[v1].HoldItem._iMiscId == IMISC_BOOK) { - v2 = plr[v1].HoldItem._iSpell; - v3 = spelldata[plr[v1].HoldItem._iSpell].sMinInt; - plr[v1].HoldItem._iMinMag = v3; - v4 = plr[0]._pSplLvl[v2 + v1 * 21720]; - if (plr[0]._pSplLvl[v2 + v1 * 21720]) { - do { - v3 += 20 * v3 / 100; - --v4; - if (v3 + 20 * v3 / 100 > 255) { - v3 = -1; - v4 = 0; - } - } while (v4); - plr[v1].HoldItem._iMinMag = v3; - } - } + v1 = pnum; + if (plr[v1].HoldItem._iMiscId == IMISC_BOOK) { + v2 = plr[v1].HoldItem._iSpell; + v3 = spelldata[plr[v1].HoldItem._iSpell].sMinInt; + plr[v1].HoldItem._iMinMag = v3; + v4 = plr[0]._pSplLvl[v2 + v1 * 21720]; + if (plr[0]._pSplLvl[v2 + v1 * 21720]) { + do { + v3 += 20 * v3 / 100; + --v4; + if (v3 + 20 * v3 / 100 > 255) { + v3 = -1; + v4 = 0; + } + } while (v4); + plr[v1].HoldItem._iMinMag = v3; + } + } } void __fastcall CheckQuestItem(int pnum) { - int v1; // ecx - int v2; // esi + int v1; // ecx + int v2; // esi - v1 = pnum; - v2 = plr[v1].HoldItem.IDidx; - if (v2 == IDI_OPTAMULET) - quests[QTYPE_BLIND]._qactive = 3; - if (v2 == IDI_MUSHROOM && quests[QTYPE_BLKM]._qactive == 2 && quests[QTYPE_BLKM]._qvar1 == QS_MUSHSPAWNED) { - sfxdelay = IDI_OPTAMULET; - if (plr[v1]._pClass == PC_WARRIOR) { - sfxdnum = PS_WARR95; - } else if (plr[v1]._pClass == PC_ROGUE) { - sfxdnum = PS_ROGUE95; - } else if (plr[v1]._pClass == PC_SORCERER) { - sfxdnum = PS_MAGE95; - } - quests[QTYPE_BLKM]._qvar1 = QS_MUSHPICKED; - } - if (v2 == IDI_ANVIL) { - if (quests[QTYPE_ANVIL]._qactive == 1) { - quests[QTYPE_ANVIL]._qactive = 2; - quests[QTYPE_ANVIL]._qvar1 = 1; - } - if (quests[QTYPE_ANVIL]._qlog == 1) { - sfxdelay = IDI_OPTAMULET; - if (plr[v1]._pClass == PC_WARRIOR) { - sfxdnum = PS_WARR89; - } else if (plr[v1]._pClass == PC_ROGUE) { - sfxdnum = PS_ROGUE89; - } else if (plr[v1]._pClass == PC_SORCERER) { - sfxdnum = PS_MAGE89; - } - } - } - if (v2 == IDI_GLDNELIX) { - sfxdelay = 30; - if (plr[v1]._pClass == PC_WARRIOR) { - sfxdnum = PS_WARR88; - } else if (plr[v1]._pClass == PC_ROGUE) { - sfxdnum = PS_ROGUE88; - } else if (plr[v1]._pClass == PC_SORCERER) { - sfxdnum = PS_MAGE88; - } - } - if (v2 == IDI_ROCK) { - if (quests[QTYPE_INFRA]._qactive == 1) { - quests[QTYPE_INFRA]._qactive = 2; - quests[QTYPE_INFRA]._qvar1 = 1; - } - if (quests[QTYPE_INFRA]._qlog == 1) { - sfxdelay = IDI_OPTAMULET; - if (plr[v1]._pClass == PC_WARRIOR) { - sfxdnum = PS_WARR87; - } else if (plr[v1]._pClass == PC_ROGUE) { - sfxdnum = PS_ROGUE87; - } else if (plr[v1]._pClass == PC_SORCERER) { - sfxdnum = PS_MAGE87; - } - } - } - if (v2 == IDI_ARMOFVAL) { - quests[QTYPE_BLOOD]._qactive = 3; - sfxdelay = 20; - if (plr[v1]._pClass == PC_WARRIOR) { - sfxdnum = PS_WARR91; - } else if (plr[v1]._pClass == PC_ROGUE) { - sfxdnum = PS_ROGUE91; - } else if (plr[v1]._pClass == PC_SORCERER) { - sfxdnum = PS_MAGE91; - } - } + v1 = pnum; + v2 = plr[v1].HoldItem.IDidx; + if (v2 == IDI_OPTAMULET) + quests[QTYPE_BLIND]._qactive = 3; + if (v2 == IDI_MUSHROOM && quests[QTYPE_BLKM]._qactive == 2 && quests[QTYPE_BLKM]._qvar1 == QS_MUSHSPAWNED) { + sfxdelay = IDI_OPTAMULET; + if (plr[v1]._pClass == PC_WARRIOR) { + sfxdnum = PS_WARR95; + } else if (plr[v1]._pClass == PC_ROGUE) { + sfxdnum = PS_ROGUE95; + } else if (plr[v1]._pClass == PC_SORCERER) { + sfxdnum = PS_MAGE95; + } + quests[QTYPE_BLKM]._qvar1 = QS_MUSHPICKED; + } + if (v2 == IDI_ANVIL) { + if (quests[QTYPE_ANVIL]._qactive == 1) { + quests[QTYPE_ANVIL]._qactive = 2; + quests[QTYPE_ANVIL]._qvar1 = 1; + } + if (quests[QTYPE_ANVIL]._qlog == 1) { + sfxdelay = IDI_OPTAMULET; + if (plr[v1]._pClass == PC_WARRIOR) { + sfxdnum = PS_WARR89; + } else if (plr[v1]._pClass == PC_ROGUE) { + sfxdnum = PS_ROGUE89; + } else if (plr[v1]._pClass == PC_SORCERER) { + sfxdnum = PS_MAGE89; + } + } + } + if (v2 == IDI_GLDNELIX) { + sfxdelay = 30; + if (plr[v1]._pClass == PC_WARRIOR) { + sfxdnum = PS_WARR88; + } else if (plr[v1]._pClass == PC_ROGUE) { + sfxdnum = PS_ROGUE88; + } else if (plr[v1]._pClass == PC_SORCERER) { + sfxdnum = PS_MAGE88; + } + } + if (v2 == IDI_ROCK) { + if (quests[QTYPE_INFRA]._qactive == 1) { + quests[QTYPE_INFRA]._qactive = 2; + quests[QTYPE_INFRA]._qvar1 = 1; + } + if (quests[QTYPE_INFRA]._qlog == 1) { + sfxdelay = IDI_OPTAMULET; + if (plr[v1]._pClass == PC_WARRIOR) { + sfxdnum = PS_WARR87; + } else if (plr[v1]._pClass == PC_ROGUE) { + sfxdnum = PS_ROGUE87; + } else if (plr[v1]._pClass == PC_SORCERER) { + sfxdnum = PS_MAGE87; + } + } + } + if (v2 == IDI_ARMOFVAL) { + quests[QTYPE_BLOOD]._qactive = 3; + sfxdelay = 20; + if (plr[v1]._pClass == PC_WARRIOR) { + sfxdnum = PS_WARR91; + } else if (plr[v1]._pClass == PC_ROGUE) { + sfxdnum = PS_ROGUE91; + } else if (plr[v1]._pClass == PC_SORCERER) { + sfxdnum = PS_MAGE91; + } + } } // 52A554: using guessed type int sfxdelay; void __fastcall InvGetItem(int pnum, int ii) { - int v2; // ebp - int v3; // edx - int v4; // ecx - int v5; // ecx - int pnuma; // [esp+4h] [ebp-8h] - int v7; // [esp+8h] [ebp-4h] + int v2; // ebp + int v3; // edx + int v4; // ecx + int v5; // ecx + int pnuma; // [esp+4h] [ebp-8h] + int v7; // [esp+8h] [ebp-4h] - v7 = ii; - pnuma = pnum; - if (dropGoldFlag) { - dropGoldFlag = 0; - dropGoldValue = 0; - } - v2 = ii; - if (dItem[item[ii]._ix][item[ii]._iy]) { - if (myplr == pnum && pcurs >= CURSOR_FIRSTITEM) - NetSendCmdPItem(TRUE, CMD_SYNCPUTITEM, plr[myplr].WorldX, plr[myplr].WorldY); - _HIBYTE(item[v2]._iCreateInfo) &= 0x7Fu; - qmemcpy(&plr[pnuma].HoldItem, &item[v2], sizeof(plr[pnuma].HoldItem)); - CheckQuestItem(pnuma); - CheckBookLevel(pnuma); - CheckItemStats(pnuma); - v3 = 0; - dItem[item[v2]._ix][item[v2]._iy] = 0; - while (v3 < numitems) { - v4 = itemactive[v3]; - if (v4 == v7) { - DeleteItem(v4, v3); - v3 = 0; - } else { - ++v3; - } - } - v5 = plr[pnuma].HoldItem._iCurs; - pcursitem = -1; - SetCursor(v5 + 12); - } + v7 = ii; + pnuma = pnum; + if (dropGoldFlag) { + dropGoldFlag = 0; + dropGoldValue = 0; + } + v2 = ii; + if (dItem[item[ii]._ix][item[ii]._iy]) { + if (myplr == pnum && pcurs >= CURSOR_FIRSTITEM) + NetSendCmdPItem(TRUE, CMD_SYNCPUTITEM, plr[myplr].WorldX, plr[myplr].WorldY); + _HIBYTE(item[v2]._iCreateInfo) &= 0x7Fu; + qmemcpy(&plr[pnuma].HoldItem, &item[v2], sizeof(plr[pnuma].HoldItem)); + CheckQuestItem(pnuma); + CheckBookLevel(pnuma); + CheckItemStats(pnuma); + v3 = 0; + dItem[item[v2]._ix][item[v2]._iy] = 0; + while (v3 < numitems) { + v4 = itemactive[v3]; + if (v4 == v7) { + DeleteItem(v4, v3); + v3 = 0; + } else { + ++v3; + } + } + v5 = plr[pnuma].HoldItem._iCurs; + pcursitem = -1; + SetCursor(v5 + 12); + } } // 4B84DC: using guessed type int dropGoldFlag; // 4B8CC0: using guessed type char pcursitem; void __fastcall AutoGetItem(int pnum, int ii) { - int v2; // ebx - int v3; // ebp - int v4; // eax - int v5; // ecx - int v6; // edi - int v7; // edi - int v8; // edi - int v9; // edi - int v10; // edx - int v11; // ecx - int v13; // ecx - int iia; // [esp+10h] [ebp-18h] - signed int iib; // [esp+10h] [ebp-18h] - signed int iic; // [esp+10h] [ebp-18h] - signed int iid; // [esp+10h] [ebp-18h] - signed int iie; // [esp+10h] [ebp-18h] - signed int iif; // [esp+10h] [ebp-18h] - signed int iig; // [esp+10h] [ebp-18h] - signed int iih; // [esp+10h] [ebp-18h] - signed int iii; // [esp+10h] [ebp-18h] - signed int iij; // [esp+10h] [ebp-18h] - ItemStruct *v24; // [esp+14h] [ebp-14h] - int *v25; // [esp+14h] [ebp-14h] - int v26; // [esp+18h] [ebp-10h] - int i; // [esp+1Ch] [ebp-Ch] - int v28; // [esp+20h] [ebp-8h] - int v29; // [esp+24h] [ebp-4h] + int v2; // ebx + int v3; // ebp + int v4; // eax + int v5; // ecx + int v6; // edi + int v7; // edi + int v8; // edi + int v9; // edi + int v10; // edx + int v11; // ecx + int v13; // ecx + int iia; // [esp+10h] [ebp-18h] + signed int iib; // [esp+10h] [ebp-18h] + signed int iic; // [esp+10h] [ebp-18h] + signed int iid; // [esp+10h] [ebp-18h] + signed int iie; // [esp+10h] [ebp-18h] + signed int iif; // [esp+10h] [ebp-18h] + signed int iig; // [esp+10h] [ebp-18h] + signed int iih; // [esp+10h] [ebp-18h] + signed int iii; // [esp+10h] [ebp-18h] + signed int iij; // [esp+10h] [ebp-18h] + ItemStruct *v24; // [esp+14h] [ebp-14h] + int *v25; // [esp+14h] [ebp-14h] + int v26; // [esp+18h] [ebp-10h] + int i; // [esp+1Ch] [ebp-Ch] + int v28; // [esp+20h] [ebp-8h] + int v29; // [esp+24h] [ebp-4h] - v2 = pnum; - i = ii; - if (dropGoldFlag) { - dropGoldFlag = 0; - dropGoldValue = 0; - } - if (ii == 127 || dItem[item[ii]._ix][item[ii]._iy]) { - v3 = pnum; - _HIBYTE(item[ii]._iCreateInfo) &= 0x7Fu; - v28 = ii; - qmemcpy(&plr[pnum].HoldItem, &item[ii], sizeof(plr[pnum].HoldItem)); - CheckQuestItem(pnum); - CheckBookLevel(v2); - CheckItemStats(v2); - SetICursor(plr[v2].HoldItem._iCurs + 12); - if (plr[v2].HoldItem._itype == ITYPE_GOLD) { - v4 = GoldAutoPlace(v2); - } else { - v4 = 0; - if (((plr[v3]._pgfxnum & 0xF) == ANIM_ID_UNARMED || (plr[v3]._pgfxnum & 0xF) == ANIM_ID_UNARMED_SHIELD) && plr[v3]._pmode <= PM_WALK3) { - if (plr[v3].HoldItem._iStatFlag) { - if (plr[v3].HoldItem._iClass == 1) { - v4 = WeaponAutoPlace(v2); - if (v4) { - CalcPlrInv(v2, TRUE); - goto LABEL_71; - } - } - } - } - v5 = icursW28; - v29 = icursW28; - v26 = icursH28; - if (icursW28 == 1) { - if (icursH28 == 1) { - if (plr[v3].HoldItem._iStatFlag && AllItemsList[plr[v3].HoldItem.IDidx].iUsable) { - iia = 0; - v24 = plr[v3].SpdList; - do { - if (v4) - break; - if (v24->_itype == -1) { - qmemcpy(v24, &plr[v3].HoldItem, sizeof(ItemStruct)); - CalcPlrScrolls(v2); - v4 = 1; - drawsbarflag = 1; - } - ++iia; - ++v24; - } while (iia < 8); - } - v6 = 30; - do { - if (v4) - break; - v4 = AutoPlace(v2, v6++, 1, 1, 1); - } while (v6 <= 39); - v7 = 20; - do { - if (v4) - break; - v4 = AutoPlace(v2, v7++, 1, 1, 1); - } while (v7 <= 29); - v8 = 10; - do { - if (v4) - break; - v4 = AutoPlace(v2, v8++, 1, 1, 1); - } while (v8 <= 19); - v9 = 0; - while (!v4) { - v4 = AutoPlace(v2, v9++, 1, 1, 1); - if (v9 > 9) - goto LABEL_35; - } - goto LABEL_71; - } - LABEL_35: - if (v26 == 2) { - iib = 29; - do { - if (v4) - break; - v4 = AutoPlace(v2, iib--, 1, 2, 1); - } while (iib >= 20); - iic = 9; - do { - if (v4) - break; - v4 = AutoPlace(v2, iic--, 1, 2, 1); - } while (iic >= 0); - iid = 19; - while (!v4) { - v4 = AutoPlace(v2, iid--, 1, 2, 1); - if (iid < 10) - goto LABEL_45; - } - goto LABEL_71; - } - LABEL_45: - if (v26 == 3) { - iie = 0; - while (!v4) { - v4 = AutoPlace(v2, iie++, 1, 3, 1); - if (iie >= 20) - goto LABEL_49; - } - goto LABEL_71; - } - } else { - LABEL_49: - if (v29 == 2) { - if (v26 == 2) { - v25 = AP2x2Tbl; - do { - if (v4) - break; - v4 = AutoPlace(v2, *v25, 2, 2, 1); - ++v25; - } while ((signed int)v25 < (signed int)&AP2x2Tbl[10]); - iif = 21; - do { - if (v4) - break; - v4 = AutoPlace(v2, iif, 2, 2, 1); - iif += 2; - } while (iif < 29); - iig = 1; - do { - if (v4) - break; - v4 = AutoPlace(v2, iig, 2, 2, 1); - iig += 2; - } while (iig < 9); - iih = 10; - while (!v4) { - v4 = AutoPlace(v2, iih++, 2, 2, 1); - if (iih >= 19) - goto LABEL_63; - } - goto LABEL_71; - } - LABEL_63: - if (v26 == 3) { - iii = 0; - do { - if (v4) - break; - v4 = AutoPlace(v2, iii++, 2, 3, 1); - } while (iii < 9); - iij = 10; - while (!v4) { - v4 = AutoPlace(v2, iij++, 2, 3, 1); - if (iij >= 19) - goto LABEL_70; - } - goto LABEL_71; - } - } - } - } - LABEL_70: - if (v4) { - LABEL_71: - v10 = 0; - dItem[item[v28]._ix][item[v28]._iy] = 0; - while (v10 < numitems) { - v11 = itemactive[v10]; - if (v11 == i) { - DeleteItem(v11, v10); - v10 = 0; - } else { - ++v10; - } - } - return; - } - if (v2 == myplr) { - switch (plr[v3]._pClass) { - case PC_WARRIOR: - v13 = random(0, 3) + PS_WARR14; - PlaySFX(v13); - break; - case PC_ROGUE: - v13 = random(0, 3) + PS_ROGUE14; - PlaySFX(v13); - break; - case PC_SORCERER: - v13 = random(0, 3) + PS_MAGE14; - PlaySFX(v13); - break; - } - } - qmemcpy(&plr[v3].HoldItem, &item[v28], sizeof(plr[v3].HoldItem)); - RespawnItem(i, 1); - NetSendCmdPItem(TRUE, CMD_RESPAWNITEM, item[v28]._ix, item[v28]._iy); - plr[v3].HoldItem._itype = ITYPE_NONE; - } + v2 = pnum; + i = ii; + if (dropGoldFlag) { + dropGoldFlag = 0; + dropGoldValue = 0; + } + if (ii == 127 || dItem[item[ii]._ix][item[ii]._iy]) { + v3 = pnum; + _HIBYTE(item[ii]._iCreateInfo) &= 0x7Fu; + v28 = ii; + qmemcpy(&plr[pnum].HoldItem, &item[ii], sizeof(plr[pnum].HoldItem)); + CheckQuestItem(pnum); + CheckBookLevel(v2); + CheckItemStats(v2); + SetICursor(plr[v2].HoldItem._iCurs + 12); + if (plr[v2].HoldItem._itype == ITYPE_GOLD) { + v4 = GoldAutoPlace(v2); + } else { + v4 = 0; + if (((plr[v3]._pgfxnum & 0xF) == ANIM_ID_UNARMED || (plr[v3]._pgfxnum & 0xF) == ANIM_ID_UNARMED_SHIELD) && plr[v3]._pmode <= PM_WALK3) { + if (plr[v3].HoldItem._iStatFlag) { + if (plr[v3].HoldItem._iClass == 1) { + v4 = WeaponAutoPlace(v2); + if (v4) { + CalcPlrInv(v2, TRUE); + goto LABEL_71; + } + } + } + } + v5 = icursW28; + v29 = icursW28; + v26 = icursH28; + if (icursW28 == 1) { + if (icursH28 == 1) { + if (plr[v3].HoldItem._iStatFlag && AllItemsList[plr[v3].HoldItem.IDidx].iUsable) { + iia = 0; + v24 = plr[v3].SpdList; + do { + if (v4) + break; + if (v24->_itype == -1) { + qmemcpy(v24, &plr[v3].HoldItem, sizeof(ItemStruct)); + CalcPlrScrolls(v2); + v4 = 1; + drawsbarflag = 1; + } + ++iia; + ++v24; + } while (iia < 8); + } + v6 = 30; + do { + if (v4) + break; + v4 = AutoPlace(v2, v6++, 1, 1, 1); + } while (v6 <= 39); + v7 = 20; + do { + if (v4) + break; + v4 = AutoPlace(v2, v7++, 1, 1, 1); + } while (v7 <= 29); + v8 = 10; + do { + if (v4) + break; + v4 = AutoPlace(v2, v8++, 1, 1, 1); + } while (v8 <= 19); + v9 = 0; + while (!v4) { + v4 = AutoPlace(v2, v9++, 1, 1, 1); + if (v9 > 9) + goto LABEL_35; + } + goto LABEL_71; + } + LABEL_35: + if (v26 == 2) { + iib = 29; + do { + if (v4) + break; + v4 = AutoPlace(v2, iib--, 1, 2, 1); + } while (iib >= 20); + iic = 9; + do { + if (v4) + break; + v4 = AutoPlace(v2, iic--, 1, 2, 1); + } while (iic >= 0); + iid = 19; + while (!v4) { + v4 = AutoPlace(v2, iid--, 1, 2, 1); + if (iid < 10) + goto LABEL_45; + } + goto LABEL_71; + } + LABEL_45: + if (v26 == 3) { + iie = 0; + while (!v4) { + v4 = AutoPlace(v2, iie++, 1, 3, 1); + if (iie >= 20) + goto LABEL_49; + } + goto LABEL_71; + } + } else { + LABEL_49: + if (v29 == 2) { + if (v26 == 2) { + v25 = AP2x2Tbl; + do { + if (v4) + break; + v4 = AutoPlace(v2, *v25, 2, 2, 1); + ++v25; + } while ((signed int)v25 < (signed int)&AP2x2Tbl[10]); + iif = 21; + do { + if (v4) + break; + v4 = AutoPlace(v2, iif, 2, 2, 1); + iif += 2; + } while (iif < 29); + iig = 1; + do { + if (v4) + break; + v4 = AutoPlace(v2, iig, 2, 2, 1); + iig += 2; + } while (iig < 9); + iih = 10; + while (!v4) { + v4 = AutoPlace(v2, iih++, 2, 2, 1); + if (iih >= 19) + goto LABEL_63; + } + goto LABEL_71; + } + LABEL_63: + if (v26 == 3) { + iii = 0; + do { + if (v4) + break; + v4 = AutoPlace(v2, iii++, 2, 3, 1); + } while (iii < 9); + iij = 10; + while (!v4) { + v4 = AutoPlace(v2, iij++, 2, 3, 1); + if (iij >= 19) + goto LABEL_70; + } + goto LABEL_71; + } + } + } + } + LABEL_70: + if (v4) { + LABEL_71: + v10 = 0; + dItem[item[v28]._ix][item[v28]._iy] = 0; + while (v10 < numitems) { + v11 = itemactive[v10]; + if (v11 == i) { + DeleteItem(v11, v10); + v10 = 0; + } else { + ++v10; + } + } + return; + } + if (v2 == myplr) { + switch (plr[v3]._pClass) { + case PC_WARRIOR: + v13 = random(0, 3) + PS_WARR14; + PlaySFX(v13); + break; + case PC_ROGUE: + v13 = random(0, 3) + PS_ROGUE14; + PlaySFX(v13); + break; + case PC_SORCERER: + v13 = random(0, 3) + PS_MAGE14; + PlaySFX(v13); + break; + } + } + qmemcpy(&plr[v3].HoldItem, &item[v28], sizeof(plr[v3].HoldItem)); + RespawnItem(i, 1); + NetSendCmdPItem(TRUE, CMD_RESPAWNITEM, item[v28]._ix, item[v28]._iy); + plr[v3].HoldItem._itype = ITYPE_NONE; + } } // 48E9A8: using guessed type int AP2x2Tbl[10]; // 4B84DC: using guessed type int dropGoldFlag; int __fastcall FindGetItem(int indx, unsigned short ci, int iseed) { - int i; // ebx - int ii; // esi + int i; // ebx + int ii; // esi - i = 0; - if (numitems <= 0) - return -1; - while (1) { - ii = itemactive[i]; - if (item[ii].IDidx == indx && item[ii]._iSeed == iseed && item[ii]._iCreateInfo == ci) - break; - if (++i >= numitems) - return -1; - } - return ii; + i = 0; + if (numitems <= 0) + return -1; + while (1) { + ii = itemactive[i]; + if (item[ii].IDidx == indx && item[ii]._iSeed == iseed && item[ii]._iCreateInfo == ci) + break; + if (++i >= numitems) + return -1; + } + return ii; } void __fastcall SyncGetItem(int x, int y, int idx, unsigned short ci, int iseed) { - char v5; // cl - int v6; // esi - int v7; // eax - int v8; // edx - int v9; // ecx - //int v10; // ecx + char v5; // cl + int v6; // esi + int v7; // eax + int v8; // edx + int v9; // ecx + //int v10; // ecx - v5 = dItem[x][y]; - if (v5 - && (v6 = v5 - 1, v7 = v6, item[v7].IDidx == idx) - && item[v7]._iSeed == iseed - && item[v7]._iCreateInfo == ci) { - FindGetItem(idx, ci, iseed); - } else { - v6 = FindGetItem(idx, ci, iseed); - } - if (v6 != -1) { - v8 = 0; - dItem[item[v6]._ix][item[v6]._iy] = 0; - while (v8 < numitems) { - v9 = itemactive[v8]; - if (v9 == v6) { - DeleteItem(v9, v8); - FindGetItem(idx, ci, iseed); - FindGetItem(idx, ci, iseed); /* check idx */ - v8 = 0; - } else { - ++v8; - } - } - FindGetItem(idx, ci, iseed); - } + v5 = dItem[x][y]; + if (v5 + && (v6 = v5 - 1, v7 = v6, item[v7].IDidx == idx) + && item[v7]._iSeed == iseed + && item[v7]._iCreateInfo == ci) { + FindGetItem(idx, ci, iseed); + } else { + v6 = FindGetItem(idx, ci, iseed); + } + if (v6 != -1) { + v8 = 0; + dItem[item[v6]._ix][item[v6]._iy] = 0; + while (v8 < numitems) { + v9 = itemactive[v8]; + if (v9 == v6) { + DeleteItem(v9, v8); + FindGetItem(idx, ci, iseed); + FindGetItem(idx, ci, iseed); /* check idx */ + v8 = 0; + } else { + ++v8; + } + } + FindGetItem(idx, ci, iseed); + } } int __fastcall CanPut(int i, int j) { - int v2; // ecx - int v3; // esi - char v4; // al - int v5; // eax - char v6; // al - bool v7; // sf - char v8; // al - char v9; // cl + int v2; // ecx + int v3; // esi + char v4; // al + int v5; // eax + char v6; // al + bool v7; // sf + char v8; // al + char v9; // cl - v2 = i; - if (dItem[v2][j]) - return 0; - v3 = v2 * 112 + j; - if (nSolidTable[dPiece[0][v3]]) - return 0; - v4 = dObject[v2][j]; - if (v4) { - v5 = v4 <= 0 ? -1 - v4 : v4 - 1; - if (object[v5]._oSolidFlag) - return 0; - } - v6 = dObject[v2 + 1][j + 1]; - v7 = v6 < 0; - if (v6 > 0) { - if (object[v6 - 1]._oSelFlag) /* check */ - return 0; - v7 = v6 < 0; - } - if (v7 && object[-(v6 + 1)]._oSelFlag) - return 0; - v8 = dObject[v2 + 1][j]; - if (v8 > 0) { - v9 = dObject[v2][j + 1]; - if (v9 > 0 && object[v8 - 1]._oSelFlag && object[v9 - 1]._oSelFlag) - return 0; - } - if (!currlevel && (dMonster[0][v3] || dMonster[1][v3 + 1])) - return 0; - return 1; + v2 = i; + if (dItem[v2][j]) + return 0; + v3 = v2 * 112 + j; + if (nSolidTable[dPiece[0][v3]]) + return 0; + v4 = dObject[v2][j]; + if (v4) { + v5 = v4 <= 0 ? -1 - v4 : v4 - 1; + if (object[v5]._oSolidFlag) + return 0; + } + v6 = dObject[v2 + 1][j + 1]; + v7 = v6 < 0; + if (v6 > 0) { + if (object[v6 - 1]._oSelFlag) /* check */ + return 0; + v7 = v6 < 0; + } + if (v7 && object[-(v6 + 1)]._oSelFlag) + return 0; + v8 = dObject[v2 + 1][j]; + if (v8 > 0) { + v9 = dObject[v2][j + 1]; + if (v9 > 0 && object[v8 - 1]._oSelFlag && object[v9 - 1]._oSelFlag) + return 0; + } + if (!currlevel && (dMonster[0][v3] || dMonster[1][v3 + 1])) + return 0; + return 1; } int __cdecl TryInvPut() { - int result; // eax - int v1; // eax - char v2; // si - int v3; // edi - int v4; // ebx - int v5; // esi + int result; // eax + int v1; // eax + char v2; // si + int v3; // edi + int v4; // ebx + int v5; // esi - if (numitems >= 127) - return 0; - v1 = GetDirection(plr[myplr].WorldX, plr[myplr].WorldY, cursmx, cursmy); - v2 = v1; - v3 = plr[myplr].WorldY; - v4 = plr[myplr].WorldX; - if (CanPut(v4 + offset_x[v1], v3 + offset_y[v1]) - || (v5 = (v2 - 1) & 7, CanPut(v4 + offset_x[v5], v3 + offset_y[v5])) - || CanPut(v4 + offset_x[((_BYTE)v5 + 2) & 7], v3 + offset_y[((_BYTE)v5 + 2) & 7])) { - result = 1; - } else { - result = CanPut(v4, v3); - } - return result; + if (numitems >= 127) + return 0; + v1 = GetDirection(plr[myplr].WorldX, plr[myplr].WorldY, cursmx, cursmy); + v2 = v1; + v3 = plr[myplr].WorldY; + v4 = plr[myplr].WorldX; + if (CanPut(v4 + offset_x[v1], v3 + offset_y[v1]) + || (v5 = (v2 - 1) & 7, CanPut(v4 + offset_x[v5], v3 + offset_y[v5])) + || CanPut(v4 + offset_x[((_BYTE)v5 + 2) & 7], v3 + offset_y[((_BYTE)v5 + 2) & 7])) { + result = 1; + } else { + result = CanPut(v4, v3); + } + return result; } void __fastcall DrawInvMsg(char *msg) { - char *v1; // esi - int v2; // eax + char *v1; // esi + int v2; // eax - v1 = msg; - v2 = GetTickCount(); - if ((unsigned int)(v2 - sgdwLastTime) >= 5000) { - sgdwLastTime = v2; - ErrorPlrMsg(v1); - } + v1 = msg; + v2 = GetTickCount(); + if ((unsigned int)(v2 - sgdwLastTime) >= 5000) { + sgdwLastTime = v2; + ErrorPlrMsg(v1); + } } int __fastcall InvPutItem(int pnum, int x, int y) { - int v3; // edi - int *v4; // esi - int v5; // ebx - int v6; // esi - int v7; // eax - int v8; // edi - int v9; // esi - int v10; // esi - int v11; // eax - int v12; // edx - int v13; // esi - int v15; // eax - int *v16; // edx - int v17; // edx - ItemStruct *v18; // [esp+Ch] [ebp-1Ch] - int v19; // [esp+10h] [ebp-18h] - signed int v20; // [esp+14h] [ebp-14h] - int v21; // [esp+18h] [ebp-10h] - int v22; // [esp+1Ch] [ebp-Ch] - signed int v23; // [esp+20h] [ebp-8h] - int xa; // [esp+24h] [ebp-4h] - int ya; // [esp+30h] [ebp+8h] - int yb; // [esp+30h] [ebp+8h] - int yc; // [esp+30h] [ebp+8h] + int v3; // edi + int *v4; // esi + int v5; // ebx + int v6; // esi + int v7; // eax + int v8; // edi + int v9; // esi + int v10; // esi + int v11; // eax + int v12; // edx + int v13; // esi + int v15; // eax + int *v16; // edx + int v17; // edx + ItemStruct *v18; // [esp+Ch] [ebp-1Ch] + int v19; // [esp+10h] [ebp-18h] + signed int v20; // [esp+14h] [ebp-14h] + int v21; // [esp+18h] [ebp-10h] + int v22; // [esp+1Ch] [ebp-Ch] + signed int v23; // [esp+20h] [ebp-8h] + int xa; // [esp+24h] [ebp-4h] + int ya; // [esp+30h] [ebp+8h] + int yb; // [esp+30h] [ebp+8h] + int yc; // [esp+30h] [ebp+8h] - xa = x; - if (numitems >= 127) - return -1; - v3 = pnum; - _LOWORD(x) = plr[pnum].HoldItem._iCreateInfo; - v4 = &plr[pnum].HoldItem._iSeed; - v18 = &plr[pnum].HoldItem; - v5 = y; - if (FindGetItem(plr[pnum].HoldItem.IDidx, x, plr[pnum].HoldItem._iSeed) != -1) { - DrawInvMsg("A duplicate item has been detected. Destroying duplicate..."); - SyncGetItem(xa, y, plr[v3].HoldItem.IDidx, plr[v3].HoldItem._iCreateInfo, *v4); - } - ya = GetDirection(plr[v3].WorldX, plr[v3].WorldY, xa, y); - v6 = v5 - plr[v3].WorldY; - if (abs(xa - plr[v3].WorldX) > 1 || abs(v6) > 1) { - v5 = plr[v3].WorldY + offset_y[ya]; - xa = plr[v3].WorldX + offset_x[ya]; - } - if (!CanPut(xa, v5)) { - v7 = plr[v3].WorldX; - v8 = plr[v3].WorldY; - v9 = ((_BYTE)ya - 1) & 7; - v19 = v7; - v5 = v8 + offset_y[v9]; - xa = v7 + offset_x[v9]; - if (!CanPut(xa, v8 + offset_y[v9])) { - v10 = ((_BYTE)v9 + 2) & 7; - v5 = v8 + offset_y[v10]; - xa = v19 + offset_x[v10]; - if (!CanPut(xa, v8 + offset_y[v10])) { - v23 = 0; - v11 = -1; - yb = 1; - v20 = -1; - while (!v23) { - v22 = v11; - while (v11 <= yb && !v23) { - v21 = v20; - v12 = v8 + v22; - v13 = v19 + v20; - do { - if (v23) - break; - if (CanPut(v13, v12)) { - v23 = 1; - xa = v13; - v5 = v12; - } - ++v21; - ++v13; - } while (v21 <= yb); - v11 = ++v22; - } - ++yb; - v11 = v20-- - 1; - if (v20 <= -50) { - if (v23) - break; - return -1; - } - } - } - } - } - CanPut(xa, v5); - v15 = itemavail[0]; - dItem[xa][v5] = _LOBYTE(itemavail[0]) + 1; - yc = v15; - v16 = &itemavail[MAXITEMS - numitems - 1]; - itemactive[numitems] = v15; - itemavail[0] = *v16; - v17 = v15; - qmemcpy(&item[v15], v18, sizeof(ItemStruct)); - item[v17]._iy = v5; - item[v17]._ix = xa; - RespawnItem(v15, 1); - ++numitems; - SetCursor(CURSOR_HAND); - return yc; + xa = x; + if (numitems >= 127) + return -1; + v3 = pnum; + _LOWORD(x) = plr[pnum].HoldItem._iCreateInfo; + v4 = &plr[pnum].HoldItem._iSeed; + v18 = &plr[pnum].HoldItem; + v5 = y; + if (FindGetItem(plr[pnum].HoldItem.IDidx, x, plr[pnum].HoldItem._iSeed) != -1) { + DrawInvMsg("A duplicate item has been detected. Destroying duplicate..."); + SyncGetItem(xa, y, plr[v3].HoldItem.IDidx, plr[v3].HoldItem._iCreateInfo, *v4); + } + ya = GetDirection(plr[v3].WorldX, plr[v3].WorldY, xa, y); + v6 = v5 - plr[v3].WorldY; + if (abs(xa - plr[v3].WorldX) > 1 || abs(v6) > 1) { + v5 = plr[v3].WorldY + offset_y[ya]; + xa = plr[v3].WorldX + offset_x[ya]; + } + if (!CanPut(xa, v5)) { + v7 = plr[v3].WorldX; + v8 = plr[v3].WorldY; + v9 = ((_BYTE)ya - 1) & 7; + v19 = v7; + v5 = v8 + offset_y[v9]; + xa = v7 + offset_x[v9]; + if (!CanPut(xa, v8 + offset_y[v9])) { + v10 = ((_BYTE)v9 + 2) & 7; + v5 = v8 + offset_y[v10]; + xa = v19 + offset_x[v10]; + if (!CanPut(xa, v8 + offset_y[v10])) { + v23 = 0; + v11 = -1; + yb = 1; + v20 = -1; + while (!v23) { + v22 = v11; + while (v11 <= yb && !v23) { + v21 = v20; + v12 = v8 + v22; + v13 = v19 + v20; + do { + if (v23) + break; + if (CanPut(v13, v12)) { + v23 = 1; + xa = v13; + v5 = v12; + } + ++v21; + ++v13; + } while (v21 <= yb); + v11 = ++v22; + } + ++yb; + v11 = v20-- - 1; + if (v20 <= -50) { + if (v23) + break; + return -1; + } + } + } + } + } + CanPut(xa, v5); + v15 = itemavail[0]; + dItem[xa][v5] = _LOBYTE(itemavail[0]) + 1; + yc = v15; + v16 = &itemavail[MAXITEMS - numitems - 1]; + itemactive[numitems] = v15; + itemavail[0] = *v16; + v17 = v15; + qmemcpy(&item[v15], v18, sizeof(ItemStruct)); + item[v17]._iy = v5; + item[v17]._ix = xa; + RespawnItem(v15, 1); + ++numitems; + SetCursor(CURSOR_HAND); + return yc; } int __fastcall SyncPutItem(int pnum, int x, int y, int idx, WORD icreateinfo, int iseed, int Id, int dur, int mdur, int ch, int mch, int ivalue, unsigned int ibuff) { - int v13; // ebx - int v14; // edi - int v15; // esi - int v17; // edi - int v18; // ecx - int v19; // edi - int v20; // eax - int v21; // eax - int v22; // eax - int v23; // edx - int v25; // ecx - int *v26; // edx - int v27; // eax - int v28; // eax - int v29; // [esp+Ch] [ebp-18h] - int v30; // [esp+Ch] [ebp-18h] - signed int v31; // [esp+10h] [ebp-14h] - int v32; // [esp+14h] [ebp-10h] - int v33; // [esp+18h] [ebp-Ch] - int o1; // [esp+1Ch] [ebp-8h] - signed int v35; // [esp+20h] [ebp-4h] - int i; // [esp+2Ch] [ebp+8h] - int ia; // [esp+2Ch] [ebp+8h] - int ib; // [esp+2Ch] [ebp+8h] - int ic; // [esp+2Ch] [ebp+8h] + int v13; // ebx + int v14; // edi + int v15; // esi + int v17; // edi + int v18; // ecx + int v19; // edi + int v20; // eax + int v21; // eax + int v22; // eax + int v23; // edx + int v25; // ecx + int *v26; // edx + int v27; // eax + int v28; // eax + int v29; // [esp+Ch] [ebp-18h] + int v30; // [esp+Ch] [ebp-18h] + signed int v31; // [esp+10h] [ebp-14h] + int v32; // [esp+14h] [ebp-10h] + int v33; // [esp+18h] [ebp-Ch] + int o1; // [esp+1Ch] [ebp-8h] + signed int v35; // [esp+20h] [ebp-4h] + int i; // [esp+2Ch] [ebp+8h] + int ia; // [esp+2Ch] [ebp+8h] + int ib; // [esp+2Ch] [ebp+8h] + int ic; // [esp+2Ch] [ebp+8h] - v13 = x; - v14 = pnum; - if (numitems >= 127) - return -1; - v15 = y; - if (FindGetItem(idx, icreateinfo, iseed) != -1) { - DrawInvMsg("A duplicate item has been detected from another player."); - SyncGetItem(v13, y, idx, icreateinfo, iseed); - } - v17 = v14; - i = GetDirection(plr[v17].WorldX, plr[v17].WorldY, v13, y); - v29 = v15 - plr[v17].WorldY; - if (abs(v13 - plr[v17].WorldX) > 1 || abs(v29) > 1) { - v13 = plr[v17].WorldX + offset_x[i]; - v15 = plr[v17].WorldY + offset_y[i]; - } - if (!CanPut(v13, v15)) { - v18 = plr[v17].WorldX; - v19 = plr[v17].WorldY; - v20 = ((_BYTE)i - 1) & 7; - v30 = v18; - ia = v20; - v20 *= 4; - v13 = v18 + *(int *)((char *)offset_x + v20); - v15 = v19 + *(int *)((char *)offset_y + v20); - if (!CanPut(v18 + *(int *)((char *)offset_x + v20), v19 + *(int *)((char *)offset_y + v20))) { - v21 = ((_BYTE)ia + 2) & 7; - v13 = v30 + offset_x[v21]; - v15 = v19 + offset_y[v21]; - if (!CanPut(v30 + offset_x[v21], v19 + offset_y[v21])) { - v35 = 0; - v22 = -1; - ib = 1; - v31 = -1; - while (!v35) { - v33 = v22; - while (v22 <= ib && !v35) { - v23 = v19 + v33; - v32 = v31; - o1 = v30 + v31; - do { - if (v35) - break; - if (CanPut(o1, v23)) { - v13 = o1; - v35 = 1; - v15 = v23; - } - ++v32; - ++o1; - } while (v32 <= ib); - v22 = ++v33; - } - ++ib; - v22 = v31-- - 1; - if (v31 <= -50) { - if (v35) - break; - return -1; - } - } - } - } - } - CanPut(v13, v15); - v25 = itemavail[0]; - ic = itemavail[0]; - dItem[v13][v15] = _LOBYTE(itemavail[0]) + 1; - v26 = &itemavail[MAXITEMS - numitems - 1]; - itemactive[numitems] = v25; - itemavail[0] = *v26; - if (idx == IDI_EAR) { - RecreateEar(v25, icreateinfo, iseed, Id, dur, mdur, ch, mch, ivalue, ibuff); - } else { - RecreateItem(v25, idx, icreateinfo, iseed, ivalue); - if (Id) - item[ic]._iIdentified = TRUE; - v27 = ic; - item[v27]._iDurability = dur; - item[v27]._iMaxDur = mdur; - item[v27]._iCharges = ch; - item[v27]._iMaxCharges = mch; - } - v28 = ic; - item[v28]._ix = v13; - item[v28]._iy = v15; - RespawnItem(ic, 1); - ++numitems; - return ic; + v13 = x; + v14 = pnum; + if (numitems >= 127) + return -1; + v15 = y; + if (FindGetItem(idx, icreateinfo, iseed) != -1) { + DrawInvMsg("A duplicate item has been detected from another player."); + SyncGetItem(v13, y, idx, icreateinfo, iseed); + } + v17 = v14; + i = GetDirection(plr[v17].WorldX, plr[v17].WorldY, v13, y); + v29 = v15 - plr[v17].WorldY; + if (abs(v13 - plr[v17].WorldX) > 1 || abs(v29) > 1) { + v13 = plr[v17].WorldX + offset_x[i]; + v15 = plr[v17].WorldY + offset_y[i]; + } + if (!CanPut(v13, v15)) { + v18 = plr[v17].WorldX; + v19 = plr[v17].WorldY; + v20 = ((_BYTE)i - 1) & 7; + v30 = v18; + ia = v20; + v20 *= 4; + v13 = v18 + *(int *)((char *)offset_x + v20); + v15 = v19 + *(int *)((char *)offset_y + v20); + if (!CanPut(v18 + *(int *)((char *)offset_x + v20), v19 + *(int *)((char *)offset_y + v20))) { + v21 = ((_BYTE)ia + 2) & 7; + v13 = v30 + offset_x[v21]; + v15 = v19 + offset_y[v21]; + if (!CanPut(v30 + offset_x[v21], v19 + offset_y[v21])) { + v35 = 0; + v22 = -1; + ib = 1; + v31 = -1; + while (!v35) { + v33 = v22; + while (v22 <= ib && !v35) { + v23 = v19 + v33; + v32 = v31; + o1 = v30 + v31; + do { + if (v35) + break; + if (CanPut(o1, v23)) { + v13 = o1; + v35 = 1; + v15 = v23; + } + ++v32; + ++o1; + } while (v32 <= ib); + v22 = ++v33; + } + ++ib; + v22 = v31-- - 1; + if (v31 <= -50) { + if (v35) + break; + return -1; + } + } + } + } + } + CanPut(v13, v15); + v25 = itemavail[0]; + ic = itemavail[0]; + dItem[v13][v15] = _LOBYTE(itemavail[0]) + 1; + v26 = &itemavail[MAXITEMS - numitems - 1]; + itemactive[numitems] = v25; + itemavail[0] = *v26; + if (idx == IDI_EAR) { + RecreateEar(v25, icreateinfo, iseed, Id, dur, mdur, ch, mch, ivalue, ibuff); + } else { + RecreateItem(v25, idx, icreateinfo, iseed, ivalue); + if (Id) + item[ic]._iIdentified = TRUE; + v27 = ic; + item[v27]._iDurability = dur; + item[v27]._iMaxDur = mdur; + item[v27]._iCharges = ch; + item[v27]._iMaxCharges = mch; + } + v28 = ic; + item[v28]._ix = v13; + item[v28]._iy = v15; + RespawnItem(ic, 1); + ++numitems; + return ic; } int __cdecl CheckInvHLight() { - signed int v0; // ebx - int result; // eax - ItemStruct *v2; // edi - PlayerStruct *v3; // esi - int v4; // eax - int v5; // ebx - int v6; // edi - char *v7; // eax - char v9; // [esp+Fh] [ebp-1h] + signed int v0; // ebx + int result; // eax + ItemStruct *v2; // edi + PlayerStruct *v3; // esi + int v4; // eax + int v5; // ebx + int v6; // edi + char *v7; // eax + char v9; // [esp+Fh] [ebp-1h] - v0 = 0; - do { - result = InvRect[v0].X; - if (MouseX >= result) { - result += 29; - if (MouseX < result) { - result = InvRect[v0].Y; - if (MouseY >= result - 29 && MouseY < result) - break; - } - } - ++v0; - } while ((unsigned int)v0 < 0x49); - if ((unsigned int)v0 >= 0x49) - goto LABEL_37; - v9 = -1; - infoclr = COL_WHITE; - v2 = 0; - v3 = &plr[myplr]; - ClearPanel(); - if (v0 >= 0 && v0 <= 3) { - v9 = 0; - v2 = v3->InvBody; - goto LABEL_36; - } - switch (v0) { - case 4: - v9 = 1; - v2 = &v3->InvBody[INVLOC_RING_LEFT]; - goto LABEL_36; - case 5: - v9 = 2; - v2 = &v3->InvBody[INVLOC_RING_RIGHT]; - goto LABEL_36; - case 6: - v9 = 3; - v2 = &v3->InvBody[INVLOC_AMULET]; - goto LABEL_36; - } - if (v0 >= 7 && v0 <= 12) { - v9 = 4; - v2 = &v3->InvBody[INVLOC_HAND_LEFT]; - goto LABEL_36; - } - if (v0 < 13 || v0 > 18) { - if (v0 >= 19 && v0 <= 24) { - v9 = 6; - v2 = &v3->InvBody[INVLOC_CHEST]; - goto LABEL_36; - } - if (v0 < 25 || v0 > 64) { - if (v0 < 65) - goto LABEL_36; - v5 = v0 - 65; - drawsbarflag = 1; - result = 368 * v5; - v2 = &v3->SpdList[v5]; - if (v3->SpdList[v5]._itype != -1) { - v9 = v5 + 47; - goto LABEL_36; - } - } else { - result = abs(v3->InvGrid[v0 - 25]); // abs(*((char *)&v3->InvList[39]._iVAdd2 + v0 + 3)); /* find right address */ - if (result) { - v4 = result - 1; - v9 = v4 + 7; - v2 = &v3->InvList[v4]; - goto LABEL_36; - } - } - LABEL_37: - _LOBYTE(result) = -1; - return result; - } - v2 = &v3->InvBody[INVLOC_HAND_LEFT]; - if (v3->InvBody[INVLOC_HAND_LEFT]._itype == -1 || v3->InvBody[INVLOC_HAND_LEFT]._iLoc != 2) { - v9 = 5; - v2 = &v3->InvBody[INVLOC_HAND_RIGHT]; - } else { - v9 = 4; - } + v0 = 0; + do { + result = InvRect[v0].X; + if (MouseX >= result) { + result += 29; + if (MouseX < result) { + result = InvRect[v0].Y; + if (MouseY >= result - 29 && MouseY < result) + break; + } + } + ++v0; + } while ((unsigned int)v0 < 0x49); + if ((unsigned int)v0 >= 0x49) + goto LABEL_37; + v9 = -1; + infoclr = COL_WHITE; + v2 = 0; + v3 = &plr[myplr]; + ClearPanel(); + if (v0 >= 0 && v0 <= 3) { + v9 = 0; + v2 = v3->InvBody; + goto LABEL_36; + } + switch (v0) { + case 4: + v9 = 1; + v2 = &v3->InvBody[INVLOC_RING_LEFT]; + goto LABEL_36; + case 5: + v9 = 2; + v2 = &v3->InvBody[INVLOC_RING_RIGHT]; + goto LABEL_36; + case 6: + v9 = 3; + v2 = &v3->InvBody[INVLOC_AMULET]; + goto LABEL_36; + } + if (v0 >= 7 && v0 <= 12) { + v9 = 4; + v2 = &v3->InvBody[INVLOC_HAND_LEFT]; + goto LABEL_36; + } + if (v0 < 13 || v0 > 18) { + if (v0 >= 19 && v0 <= 24) { + v9 = 6; + v2 = &v3->InvBody[INVLOC_CHEST]; + goto LABEL_36; + } + if (v0 < 25 || v0 > 64) { + if (v0 < 65) + goto LABEL_36; + v5 = v0 - 65; + drawsbarflag = 1; + result = 368 * v5; + v2 = &v3->SpdList[v5]; + if (v3->SpdList[v5]._itype != -1) { + v9 = v5 + 47; + goto LABEL_36; + } + } else { + result = abs(v3->InvGrid[v0 - 25]); // abs(*((char *)&v3->InvList[39]._iVAdd2 + v0 + 3)); /* find right address */ + if (result) { + v4 = result - 1; + v9 = v4 + 7; + v2 = &v3->InvList[v4]; + goto LABEL_36; + } + } + LABEL_37: + _LOBYTE(result) = -1; + return result; + } + v2 = &v3->InvBody[INVLOC_HAND_LEFT]; + if (v3->InvBody[INVLOC_HAND_LEFT]._itype == -1 || v3->InvBody[INVLOC_HAND_LEFT]._iLoc != 2) { + v9 = 5; + v2 = &v3->InvBody[INVLOC_HAND_RIGHT]; + } else { + v9 = 4; + } LABEL_36: - result = v2->_itype; - if (result == ITYPE_NONE) - goto LABEL_37; - if (result == ITYPE_GOLD) { - v6 = v2->_ivalue; - v7 = get_pieces_str(v6); - result = sprintf(infostr, "%i gold %s", v6, v7); - } else { - if (v2->_iMagical == ITEM_QUALITY_MAGIC) { - infoclr = COL_BLUE; - } else if (v2->_iMagical == ITEM_QUALITY_UNIQUE) { - infoclr = COL_GOLD; - } - strcpy(infostr, v2->_iName); - if (v2->_iIdentified) { - strcpy(infostr, v2->_iIName); - PrintItemDetails(v2); - } else { - PrintItemDur(v2); - } - } - _LOBYTE(result) = v9; - return result; + result = v2->_itype; + if (result == ITYPE_NONE) + goto LABEL_37; + if (result == ITYPE_GOLD) { + v6 = v2->_ivalue; + v7 = get_pieces_str(v6); + result = sprintf(infostr, "%i gold %s", v6, v7); + } else { + if (v2->_iMagical == ITEM_QUALITY_MAGIC) { + infoclr = COL_BLUE; + } else if (v2->_iMagical == ITEM_QUALITY_UNIQUE) { + infoclr = COL_GOLD; + } + strcpy(infostr, v2->_iName); + if (v2->_iIdentified) { + strcpy(infostr, v2->_iIName); + PrintItemDetails(v2); + } else { + PrintItemDur(v2); + } + } + _LOBYTE(result) = v9; + return result; } // 4B883C: using guessed type int infoclr; void __fastcall RemoveScroll(int pnum) { - int v1; // eax - int v2; // esi - int v3; // edx - int *v4; // ecx - int v5; // edx - int *v6; // ecx - int p; // [esp+Ch] [ebp-4h] + int v1; // eax + int v2; // esi + int v3; // edx + int *v4; // ecx + int v5; // edx + int *v6; // ecx + int p; // [esp+Ch] [ebp-4h] - p = pnum; - v1 = pnum; - v2 = plr[pnum]._pNumInv; - v3 = 0; - if (v2 <= 0) { - LABEL_8: - v5 = 0; - v6 = &plr[v1].SpdList[0]._iMiscId; - while (*(v6 - 53) == -1 || *v6 != IMISC_SCROLL && *v6 != IMISC_SCROLLT || v6[1] != plr[v1]._pSpell) { - ++v5; - v6 += 92; - if (v5 >= MAXBELTITEMS) - return; - } - RemoveSpdBarItem(p, v5); - } else { - v4 = &plr[v1].InvList[0]._iMiscId; - while (*(v4 - 53) == -1 || *v4 != IMISC_SCROLL && *v4 != IMISC_SCROLLT || v4[1] != plr[v1]._pSpell) { - ++v3; - v4 += 92; - if (v3 >= v2) - goto LABEL_8; - } - RemoveInvItem(p, v3); - } - CalcPlrScrolls(p); + p = pnum; + v1 = pnum; + v2 = plr[pnum]._pNumInv; + v3 = 0; + if (v2 <= 0) { + LABEL_8: + v5 = 0; + v6 = &plr[v1].SpdList[0]._iMiscId; + while (*(v6 - 53) == -1 || *v6 != IMISC_SCROLL && *v6 != IMISC_SCROLLT || v6[1] != plr[v1]._pSpell) { + ++v5; + v6 += 92; + if (v5 >= MAXBELTITEMS) + return; + } + RemoveSpdBarItem(p, v5); + } else { + v4 = &plr[v1].InvList[0]._iMiscId; + while (*(v4 - 53) == -1 || *v4 != IMISC_SCROLL && *v4 != IMISC_SCROLLT || v4[1] != plr[v1]._pSpell) { + ++v3; + v4 += 92; + if (v3 >= v2) + goto LABEL_8; + } + RemoveInvItem(p, v3); + } + CalcPlrScrolls(p); } BOOL __cdecl UseScroll() { - int v0; // eax - int v1; // esi - int v2; // ecx - int *v3; // edx - signed int v4; // esi - int *v5; // ecx + int v0; // eax + int v1; // esi + int v2; // ecx + int *v3; // edx + signed int v4; // esi + int *v5; // ecx - if (pcurs != CURSOR_HAND || leveltype == DTYPE_TOWN && !spelldata[plr[myplr]._pRSpell].sTownSpell) - return FALSE; - v0 = myplr; - v1 = 0; - v2 = plr[myplr]._pNumInv; - if (v2 <= 0) { - LABEL_11: - v4 = 0; - v5 = &plr[v0].SpdList[0]._iMiscId; - while (*(v5 - 53) == -1 || *v5 != IMISC_SCROLL && *v5 != IMISC_SCROLLT || v5[1] != plr[v0]._pRSpell) { - ++v4; - v5 += 92; - if (v4 >= MAXBELTITEMS) - return FALSE; - } - } else { - v3 = &plr[v0].InvList[0]._iMiscId; - while (*(v3 - 53) == -1 || *v3 != IMISC_SCROLL && *v3 != IMISC_SCROLLT || v3[1] != plr[v0]._pRSpell) { - ++v1; - v3 += 92; - if (v1 >= v2) - goto LABEL_11; - } - } - return TRUE; + if (pcurs != CURSOR_HAND || leveltype == DTYPE_TOWN && !spelldata[plr[myplr]._pRSpell].sTownSpell) + return FALSE; + v0 = myplr; + v1 = 0; + v2 = plr[myplr]._pNumInv; + if (v2 <= 0) { + LABEL_11: + v4 = 0; + v5 = &plr[v0].SpdList[0]._iMiscId; + while (*(v5 - 53) == -1 || *v5 != IMISC_SCROLL && *v5 != IMISC_SCROLLT || v5[1] != plr[v0]._pRSpell) { + ++v4; + v5 += 92; + if (v4 >= MAXBELTITEMS) + return FALSE; + } + } else { + v3 = &plr[v0].InvList[0]._iMiscId; + while (*(v3 - 53) == -1 || *v3 != IMISC_SCROLL && *v3 != IMISC_SCROLLT || v3[1] != plr[v0]._pRSpell) { + ++v1; + v3 += 92; + if (v1 >= v2) + goto LABEL_11; + } + } + return TRUE; } void __fastcall UseStaffCharge(int pnum) { - int v1; // eax - int *v2; // eax + int v1; // eax + int *v2; // eax - v1 = pnum; - if (plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype != ITYPE_NONE - && plr[v1].InvBody[INVLOC_HAND_LEFT]._iMiscId == IMISC_STAFF - && plr[v1].InvBody[INVLOC_HAND_LEFT]._iSpell == plr[v1]._pRSpell) { - v2 = &plr[v1].InvBody[INVLOC_HAND_LEFT]._iCharges; - if (*v2 > 0) { - --*v2; - CalcPlrStaff(pnum); - } - } + v1 = pnum; + if (plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype != ITYPE_NONE + && plr[v1].InvBody[INVLOC_HAND_LEFT]._iMiscId == IMISC_STAFF + && plr[v1].InvBody[INVLOC_HAND_LEFT]._iSpell == plr[v1]._pRSpell) { + v2 = &plr[v1].InvBody[INVLOC_HAND_LEFT]._iCharges; + if (*v2 > 0) { + --*v2; + CalcPlrStaff(pnum); + } + } } BOOL __cdecl UseStaff() { - int v0; // eax - BOOL result; // al + int v0; // eax + BOOL result; // al - result = FALSE; - if (pcurs == CURSOR_HAND) { - v0 = myplr; - if (plr[myplr].InvBody[INVLOC_HAND_LEFT]._itype != ITYPE_NONE - && plr[v0].InvBody[INVLOC_HAND_LEFT]._iMiscId == IMISC_STAFF - && plr[v0].InvBody[INVLOC_HAND_LEFT]._iSpell == plr[v0]._pRSpell - && plr[v0].InvBody[INVLOC_HAND_LEFT]._iCharges > 0) { - result = TRUE; - } - } - return result; + result = FALSE; + if (pcurs == CURSOR_HAND) { + v0 = myplr; + if (plr[myplr].InvBody[INVLOC_HAND_LEFT]._itype != ITYPE_NONE + && plr[v0].InvBody[INVLOC_HAND_LEFT]._iMiscId == IMISC_STAFF + && plr[v0].InvBody[INVLOC_HAND_LEFT]._iSpell == plr[v0]._pRSpell + && plr[v0].InvBody[INVLOC_HAND_LEFT]._iCharges > 0) { + result = TRUE; + } + } + return result; } void __cdecl StartGoldDrop() { - int v0; // eax + int v0; // eax - initialDropGoldIndex = pcursinvitem; - if (pcursinvitem > 46) - v0 = plr[myplr].InvBody[pcursinvitem]._iMaxDur; - else - v0 = plr[myplr].InvBody[pcursinvitem]._ivalue; - dropGoldValue = 0; - initialDropGoldValue = v0; - dropGoldFlag = 1; - if (talkflag) - control_reset_talk(); + initialDropGoldIndex = pcursinvitem; + if (pcursinvitem > 46) + v0 = plr[myplr].InvBody[pcursinvitem]._iMaxDur; + else + v0 = plr[myplr].InvBody[pcursinvitem]._ivalue; + dropGoldValue = 0; + initialDropGoldValue = v0; + dropGoldFlag = 1; + if (talkflag) + control_reset_talk(); } // 4B84DC: using guessed type int dropGoldFlag; // 4B8960: using guessed type int talkflag; @@ -2648,103 +2648,103 @@ void __cdecl StartGoldDrop() int __fastcall UseInvItem(int pnum, int cii) { - int v2; // esi - int result; // eax - int v4; // ebx - int v5; // ebp - _DWORD *v6; // edi - int v9; // eax - int v10; // ecx - int p; // [esp+10h] [ebp-8h] - signed int v14; // [esp+14h] [ebp-4h] + int v2; // esi + int result; // eax + int v4; // ebx + int v5; // ebp + _DWORD *v6; // edi + int v9; // eax + int v10; // ecx + int p; // [esp+10h] [ebp-8h] + signed int v14; // [esp+14h] [ebp-4h] - v2 = pnum; - p = pnum; - if (plr[pnum]._pInvincible && !plr[v2]._pHitPoints && pnum == myplr) - return 1; - result = 1; - if (pcurs == 1 && !stextflag) { - if (cii <= 5) - return 0; - if (cii > 46) { - if (talkflag) - return result; - v4 = cii - 47; - v14 = 1; - v5 = 368 * (cii - 47) + v2 * 21720; - v6 = (_DWORD *)((char *)plr[0].SpdList + v5); - } else { - v4 = cii - 7; - v14 = 0; - v5 = 368 * (cii - 7) + v2 * 21720; - v6 = (_DWORD *)((char *)plr[0].InvList + v5); - } - if (v6[90] == 17) { - sfxdelay = 10; - if (plr[v2]._pClass == PC_WARRIOR) { - sfxdnum = PS_WARR95; - } else if (plr[v2]._pClass == PC_ROGUE) { - sfxdnum = PS_ROGUE95; - } else if (plr[v2]._pClass == PC_SORCERER) { - sfxdnum = PS_MAGE95; - } - return 1; - } - if (v6[90] == 19) { - PlaySFX(IS_IBOOK); - sfxdelay = 10; - if (plr[v2]._pClass == PC_WARRIOR) { - sfxdnum = PS_WARR29; - } else if (plr[v2]._pClass == PC_ROGUE) { - sfxdnum = PS_ROGUE29; - } else if (plr[v2]._pClass == PC_SORCERER) { - sfxdnum = PS_MAGE29; - } - return 1; - } - if (!AllItemsList[v6[90]].iUsable) - return 0; - if (!v6[89]) { - if (plr[v2]._pClass == PC_WARRIOR) { - PlaySFX(PS_WARR13); - } else if (plr[v2]._pClass == PC_ROGUE) { - PlaySFX(PS_ROGUE13); - } else if (plr[v2]._pClass == PC_SORCERER) { - PlaySFX(PS_MAGE13); - } - return 1; - } - v9 = v6[55]; - if (!v9 && v6[2] == 11) { - StartGoldDrop(); - return 1; - } - if (dropGoldFlag) { - dropGoldFlag = 0; - dropGoldValue = 0; - } - if (v9 == 21 && !currlevel && !spelldata[v6[56]].sTownSpell - || v9 == 22 && !currlevel && !spelldata[v6[56]].sTownSpell) { - return 1; - } - if (v9 == 24) { - v10 = 65; - } else { - if (pnum != myplr) - goto LABEL_39; - v10 = ItemInvSnds[ItemCAnimTbl[v6[48]]]; - } - PlaySFX(v10); - LABEL_39: - UseItem(p, v6[55], v6[56]); - if (v14) { - RemoveSpdBarItem(p, v4); - } else if (*(int *)((char *)&plr[0].InvList[0]._iMiscId + v5) != IMISC_MAPOFDOOM) { - RemoveInvItem(p, v4); - } - return 1; - } - return result; + v2 = pnum; + p = pnum; + if (plr[pnum]._pInvincible && !plr[v2]._pHitPoints && pnum == myplr) + return 1; + result = 1; + if (pcurs == 1 && !stextflag) { + if (cii <= 5) + return 0; + if (cii > 46) { + if (talkflag) + return result; + v4 = cii - 47; + v14 = 1; + v5 = 368 * (cii - 47) + v2 * 21720; + v6 = (_DWORD *)((char *)plr[0].SpdList + v5); + } else { + v4 = cii - 7; + v14 = 0; + v5 = 368 * (cii - 7) + v2 * 21720; + v6 = (_DWORD *)((char *)plr[0].InvList + v5); + } + if (v6[90] == 17) { + sfxdelay = 10; + if (plr[v2]._pClass == PC_WARRIOR) { + sfxdnum = PS_WARR95; + } else if (plr[v2]._pClass == PC_ROGUE) { + sfxdnum = PS_ROGUE95; + } else if (plr[v2]._pClass == PC_SORCERER) { + sfxdnum = PS_MAGE95; + } + return 1; + } + if (v6[90] == 19) { + PlaySFX(IS_IBOOK); + sfxdelay = 10; + if (plr[v2]._pClass == PC_WARRIOR) { + sfxdnum = PS_WARR29; + } else if (plr[v2]._pClass == PC_ROGUE) { + sfxdnum = PS_ROGUE29; + } else if (plr[v2]._pClass == PC_SORCERER) { + sfxdnum = PS_MAGE29; + } + return 1; + } + if (!AllItemsList[v6[90]].iUsable) + return 0; + if (!v6[89]) { + if (plr[v2]._pClass == PC_WARRIOR) { + PlaySFX(PS_WARR13); + } else if (plr[v2]._pClass == PC_ROGUE) { + PlaySFX(PS_ROGUE13); + } else if (plr[v2]._pClass == PC_SORCERER) { + PlaySFX(PS_MAGE13); + } + return 1; + } + v9 = v6[55]; + if (!v9 && v6[2] == 11) { + StartGoldDrop(); + return 1; + } + if (dropGoldFlag) { + dropGoldFlag = 0; + dropGoldValue = 0; + } + if (v9 == 21 && !currlevel && !spelldata[v6[56]].sTownSpell + || v9 == 22 && !currlevel && !spelldata[v6[56]].sTownSpell) { + return 1; + } + if (v9 == 24) { + v10 = 65; + } else { + if (pnum != myplr) + goto LABEL_39; + v10 = ItemInvSnds[ItemCAnimTbl[v6[48]]]; + } + PlaySFX(v10); + LABEL_39: + UseItem(p, v6[55], v6[56]); + if (v14) { + RemoveSpdBarItem(p, v4); + } else if (*(int *)((char *)&plr[0].InvList[0]._iMiscId + v5) != IMISC_MAPOFDOOM) { + RemoveInvItem(p, v4); + } + return 1; + } + return result; } // 4B84DC: using guessed type int dropGoldFlag; // 4B8960: using guessed type int talkflag; @@ -2753,57 +2753,57 @@ int __fastcall UseInvItem(int pnum, int cii) void __cdecl DoTelekinesis() { - if (pcursobj != -1) - NetSendCmdParam1(TRUE, CMD_OPOBJT, pcursobj); - if (pcursitem != -1) - NetSendCmdGItem(TRUE, CMD_REQUESTAGITEM, myplr, myplr, pcursitem); - if (pcursmonst != -1 && !M_Talker(pcursmonst) && !monster[pcursmonst].mtalkmsg) - NetSendCmdParam1(TRUE, CMD_KNOCKBACK, pcursmonst); - SetCursor(CURSOR_HAND); + if (pcursobj != -1) + NetSendCmdParam1(TRUE, CMD_OPOBJT, pcursobj); + if (pcursitem != -1) + NetSendCmdGItem(TRUE, CMD_REQUESTAGITEM, myplr, myplr, pcursitem); + if (pcursmonst != -1 && !M_Talker(pcursmonst) && !monster[pcursmonst].mtalkmsg) + NetSendCmdParam1(TRUE, CMD_KNOCKBACK, pcursmonst); + SetCursor(CURSOR_HAND); } // 4B8CC0: using guessed type char pcursitem; // 4B8CC1: using guessed type char pcursobj; int __fastcall CalculateGold(int pnum) { - int result; // eax - int v2; // ecx - int *v3; // edx - signed int v4; // esi - int v5; // edx - int *v6; // ecx + int result; // eax + int v2; // ecx + int *v3; // edx + signed int v4; // esi + int v5; // edx + int *v6; // ecx - result = 0; - v2 = pnum; - v3 = &plr[v2].SpdList[0]._ivalue; - v4 = MAXBELTITEMS; - do { - if (*(v3 - 47) == 11) { - result += *v3; - drawpanflag = 255; - } - v3 += 92; - --v4; - } while (v4); - v5 = plr[v2]._pNumInv; - if (v5 > 0) { - v6 = &plr[v2].InvList[0]._ivalue; - do { - if (*(v6 - 47) == 11) - result += *v6; - v6 += 92; - --v5; - } while (v5); - } - return result; + result = 0; + v2 = pnum; + v3 = &plr[v2].SpdList[0]._ivalue; + v4 = MAXBELTITEMS; + do { + if (*(v3 - 47) == 11) { + result += *v3; + drawpanflag = 255; + } + v3 += 92; + --v4; + } while (v4); + v5 = plr[v2]._pNumInv; + if (v5 > 0) { + v6 = &plr[v2].InvList[0]._ivalue; + do { + if (*(v6 - 47) == 11) + result += *v6; + v6 += 92; + --v5; + } while (v5); + } + return result; } // 52571C: using guessed type int drawpanflag; int __cdecl DropItemBeforeTrig() { - if (!TryInvPut()) - return 0; - NetSendCmdPItem(TRUE, CMD_PUTITEM, cursmx, cursmy); - SetCursor(CURSOR_HAND); - return 1; + if (!TryInvPut()) + return 0; + NetSendCmdPItem(TRUE, CMD_PUTITEM, cursmx, cursmy); + SetCursor(CURSOR_HAND); + return 1; } diff --git a/Source/items.cpp b/Source/items.cpp index 0f7bf088..76ca1b75 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -15,7 +15,7 @@ int numitems; int gnNumGetRecords; const PLStruct PL_Prefix[84] = { - // clang-format off + // clang-format off // PLName, PLPower, PLParam1, PLParam2, PLMinLvl, PLIType, PLGOE, PLDouble, PLOk, PLMinVal, PLMaxVal, PLMultVal { "Tin", IPL_TOHIT_CURSE, 6, 10, 3, PLT_WEAP | PLT_BOW | PLT_MISC, 0, 1, 0, 0, 0, -3 }, { "Brass", IPL_TOHIT_CURSE, 1, 5, 1, PLT_WEAP | PLT_BOW | PLT_MISC, 0, 1, 0, 0, 0, -2 }, @@ -101,10 +101,10 @@ const PLStruct PL_Prefix[84] = { { "Flaming", IPL_FIREDAM, 1, 10, 7, PLT_WEAP | PLT_STAFF , 0, 0, 1, 5000, 5000, 2 }, { "Lightning", IPL_LIGHTDAM, 2, 20, 18, PLT_WEAP | PLT_STAFF , 0, 0, 1, 10000, 10000, 2 }, { &empty_string, IPL_INVALID, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0 } - // clang-format on + // clang-format on }; const PLStruct PL_Suffix[96] = { - // clang-format off + // clang-format off // PLName, PLPower, PLParam1, PLParam2, PLMinLvl, PLIType, PLGOE, PLDouble, PLOk, PLMinVal, PLMaxVal, PLMultVal { "quality", IPL_DAMMOD, 1, 2, 2, PLT_WEAP | PLT_BOW , 0, 0, 1, 100, 200, 2 }, { "maiming", IPL_DAMMOD, 3, 5, 7, PLT_WEAP | PLT_BOW , 0, 0, 1, 1300, 1500, 3 }, @@ -202,10 +202,10 @@ const PLStruct PL_Suffix[96] = { { "harmony", IPL_FASTRECOVER, 3, 3, 20, PLT_ARMO | PLT_MISC, 0, 0, 1, 8000, 8000, 8 }, { "blocking", IPL_FASTBLOCK, 1, 1, 5, PLT_SHLD , 0, 0, 1, 4000, 4000, 4 }, { &empty_string, IPL_INVALID, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0 } - // clang-format on + // clang-format on }; const UItemStruct UniqueItemList[91] = { - // clang-format off + // clang-format off // UIName, UIItemId, UIMinLvl, UINumPL, UIValue, UIPower1, UIParam1, UIParam2, UIPower2, UIParam3, UIParam4, UIPower3, UIParam5, UIParam6, UIPower4, UIParam7, UIParam8, UIPower5, UIParam9, UIParam10, UIPower6, UIParam11, UIParam12 { "The Butcher's Cleaver", UITYPE_CLEAVER, 1, 3, 3650, IPL_STR, 10, 10, IPL_SETDAM, 4, 24, IPL_SETDUR, 10, 10, IPL_TOHIT, 0, 0, IPL_TOHIT, 0, 0, IPL_TOHIT, 0, 0 }, { "The Undead Crown", UITYPE_SKCROWN, 1, 3, 16650, IPL_RNDSTEALLIFE, 0, 0, IPL_SETAC, 8, 8, IPL_INVCURS, 77, 0, IPL_TOHIT, 0, 0, IPL_TOHIT, 0, 0, IPL_TOHIT, 0, 0 }, @@ -298,13 +298,13 @@ const UItemStruct UniqueItemList[91] = { { "Constricting Ring", UITYPE_RING, 5, 3, 62000, IPL_ALLRES, 75, 75, IPL_DRAINLIFE, 0, 0, IPL_INVCURS, 14, 0, IPL_TOHIT, 0, 0, IPL_TOHIT, 0, 0, IPL_TOHIT, 0, 0 }, { "Ring of Engagement", UITYPE_RING, 11, 5, 12476, IPL_GETHIT, 1, 2, IPL_THORNS, 1, 3, IPL_SETAC, 5, 5, IPL_TARGAC, 4, 12, IPL_INVCURS, 13, 0, IPL_TOHIT, 0, 0 }, { &empty_string, UITYPE_INVALID, 0, 0, 0, IPL_TOHIT, 0, 0, IPL_TOHIT, 0, 0, IPL_TOHIT, 0, 0, IPL_TOHIT, 0, 0, IPL_TOHIT, 0, 0, IPL_TOHIT, 0, 0 } - // clang-format on + // clang-format on }; /* data */ ItemDataStruct AllItemsList[157] = { - // clang-format off + // clang-format off // iRnd, iClass, iLoc, iCurs, itype, iItemId, iName, iSName, iMinMLvl, iDurability, iMinDam, iMaxDam, iMinAC, iMaxAC, iMinStr, iMinMag, iMinDex, iFlags, iMiscId, iSpell, iUsable, iValue, iMaxValue { IDROP_REGULAR, ICLASS_GOLD, ILOC_UNEQUIPABLE, ICURS_GOLD, 11, UITYPE_NONE, "Gold", NULL, 1, 0, 0, 0, 0, 0, 0, 0, 0, ISPL_NONE, IMISC_NONE, SPL_NULL, 1, 0, 0 }, { IDROP_NEVER, ICLASS_WEAPON, ILOC_ONEHAND, ICURS_SHORT_SWORD, 1, UITYPE_NONE, "Short Sword", NULL, 2, 20, 2, 6, 0, 0, 18, 0, 0, ISPL_NONE, IMISC_NONE, SPL_NULL, 0, 50, 50 }, @@ -463,3272 +463,3272 @@ ItemDataStruct AllItemsList[157] = { { IDROP_REGULAR, ICLASS_MISC, ILOC_AMULET, ICURS_AMULET, 13, UITYPE_AMULET, "Amulet", "Amulet", 8, 0, 0, 0, 0, 0, 0, 0, 0, ISPL_NONE, IMISC_AMULET, SPL_NULL, 0, 1200, 1200 }, { IDROP_REGULAR, ICLASS_MISC, ILOC_AMULET, ICURS_AMULET, 13, UITYPE_AMULET, "Amulet", "Amulet", 16, 0, 0, 0, 0, 0, 0, 0, 0, ISPL_NONE, IMISC_AMULET, SPL_NULL, 0, 1200, 1200 }, { IDROP_NEVER, ICLASS_NONE, ILOC_INVALID, ICURS_POTION_OF_FULL_MANA, 0, UITYPE_NONE, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, ISPL_NONE, IMISC_NONE, SPL_NULL, 0, 0, 0 } - // clang-format on + // clang-format on }; unsigned char ItemCAnimTbl[169] = { - 20, 16, 16, 16, 4, 4, 4, 12, 12, 12, - 12, 12, 12, 12, 12, 21, 21, 25, 12, 28, - 28, 28, 0, 0, 0, 32, 0, 0, 0, 24, - 24, 26, 2, 25, 22, 23, 24, 25, 27, 27, - 29, 0, 0, 0, 12, 12, 12, 12, 12, 0, - 8, 8, 0, 8, 8, 8, 8, 8, 8, 6, - 8, 8, 8, 6, 8, 8, 6, 8, 8, 6, - 6, 6, 8, 8, 8, 5, 9, 13, 13, 13, - 5, 5, 5, 15, 5, 5, 18, 18, 18, 30, - 5, 5, 14, 5, 14, 13, 16, 18, 5, 5, - 7, 1, 3, 17, 1, 15, 10, 14, 3, 11, - 8, 0, 1, 7, 0, 7, 15, 7, 3, 3, - 3, 6, 6, 11, 11, 11, 31, 14, 14, 14, - 6, 6, 7, 3, 8, 14, 0, 14, 14, 0, - 33, 1, 1, 1, 1, 1, 7, 7, 7, 14, - 14, 17, 17, 17, 0, 34, 1, 0, 3, 17, - 8, 8, 6, 1, 3, 3, 11, 3, 4 + 20, 16, 16, 16, 4, 4, 4, 12, 12, 12, + 12, 12, 12, 12, 12, 21, 21, 25, 12, 28, + 28, 28, 0, 0, 0, 32, 0, 0, 0, 24, + 24, 26, 2, 25, 22, 23, 24, 25, 27, 27, + 29, 0, 0, 0, 12, 12, 12, 12, 12, 0, + 8, 8, 0, 8, 8, 8, 8, 8, 8, 6, + 8, 8, 8, 6, 8, 8, 6, 8, 8, 6, + 6, 6, 8, 8, 8, 5, 9, 13, 13, 13, + 5, 5, 5, 15, 5, 5, 18, 18, 18, 30, + 5, 5, 14, 5, 14, 13, 16, 18, 5, 5, + 7, 1, 3, 17, 1, 15, 10, 14, 3, 11, + 8, 0, 1, 7, 0, 7, 15, 7, 3, 3, + 3, 6, 6, 11, 11, 11, 31, 14, 14, 14, + 6, 6, 7, 3, 8, 14, 0, 14, 14, 0, + 33, 1, 1, 1, 1, 1, 7, 7, 7, 14, + 14, 17, 17, 17, 0, 34, 1, 0, 3, 17, + 8, 8, 6, 1, 3, 3, 11, 3, 4 }; char *ItemDropStrs[35] = { - "Armor2", - "Axe", - "FBttle", - "Bow", - "GoldFlip", - "Helmut", - "Mace", - "Shield", - "SwrdFlip", - "Rock", - "Cleaver", - "Staff", - "Ring", - "CrownF", - "LArmor", - "WShield", - "Scroll", - "FPlateAr", - "FBook", - "Food", - "FBttleBB", - "FBttleDY", - "FBttleOR", - "FBttleBR", - "FBttleBL", - "FBttleBY", - "FBttleWH", - "FBttleDB", - "FEar", - "FBrain", - "FMush", - "Innsign", - "Bldstn", - "Fanvil", - "FLazStaf" + "Armor2", + "Axe", + "FBttle", + "Bow", + "GoldFlip", + "Helmut", + "Mace", + "Shield", + "SwrdFlip", + "Rock", + "Cleaver", + "Staff", + "Ring", + "CrownF", + "LArmor", + "WShield", + "Scroll", + "FPlateAr", + "FBook", + "Food", + "FBttleBB", + "FBttleDY", + "FBttleOR", + "FBttleBR", + "FBttleBL", + "FBttleBY", + "FBttleWH", + "FBttleDB", + "FEar", + "FBrain", + "FMush", + "Innsign", + "Bldstn", + "Fanvil", + "FLazStaf" }; unsigned char ItemAnimLs[35] = { - 15u, - 13u, - 16u, - 13u, - 10u, - 13u, - 13u, - 13u, - 13u, - 10u, - 13u, - 13u, - 13u, - 13u, - 13u, - 13u, - 13u, - 13u, - 13u, - 1u, - 16u, - 16u, - 16u, - 16u, - 16u, - 16u, - 16u, - 16u, - 13u, - 12u, - 12u, - 13u, - 13u, - 13u, - 8u + 15u, + 13u, + 16u, + 13u, + 10u, + 13u, + 13u, + 13u, + 13u, + 10u, + 13u, + 13u, + 13u, + 13u, + 13u, + 13u, + 13u, + 13u, + 13u, + 1u, + 16u, + 16u, + 16u, + 16u, + 16u, + 16u, + 16u, + 16u, + 13u, + 12u, + 12u, + 13u, + 13u, + 13u, + 8u }; int ItemDropSnds[35] = { - IS_FHARM, - IS_FAXE, - IS_FPOT, - IS_FBOW, - IS_GOLD, - IS_FCAP, - IS_FSWOR, - IS_FSHLD, - IS_FSWOR, - IS_FROCK, - IS_FAXE, - IS_FSTAF, - IS_FRING, - IS_FCAP, - IS_FLARM, - IS_FSHLD, - IS_FSCRL, - IS_FHARM, - IS_FBOOK, - IS_FLARM, - IS_FPOT, - IS_FPOT, - IS_FPOT, - IS_FPOT, - IS_FPOT, - IS_FPOT, - IS_FPOT, - IS_FPOT, - IS_FBODY, - IS_FBODY, - IS_FMUSH, - IS_ISIGN, - IS_FBLST, - IS_FANVL, - IS_FSTAF + IS_FHARM, + IS_FAXE, + IS_FPOT, + IS_FBOW, + IS_GOLD, + IS_FCAP, + IS_FSWOR, + IS_FSHLD, + IS_FSWOR, + IS_FROCK, + IS_FAXE, + IS_FSTAF, + IS_FRING, + IS_FCAP, + IS_FLARM, + IS_FSHLD, + IS_FSCRL, + IS_FHARM, + IS_FBOOK, + IS_FLARM, + IS_FPOT, + IS_FPOT, + IS_FPOT, + IS_FPOT, + IS_FPOT, + IS_FPOT, + IS_FPOT, + IS_FPOT, + IS_FBODY, + IS_FBODY, + IS_FMUSH, + IS_ISIGN, + IS_FBLST, + IS_FANVL, + IS_FSTAF }; int ItemInvSnds[35] = { - IS_IHARM, - IS_IAXE, - IS_IPOT, - IS_IBOW, - IS_GOLD, - IS_ICAP, - IS_ISWORD, - IS_ISHIEL, - IS_ISWORD, - IS_IROCK, - IS_IAXE, - IS_ISTAF, - IS_IRING, - IS_ICAP, - IS_ILARM, - IS_ISHIEL, - IS_ISCROL, - IS_IHARM, - IS_IBOOK, - IS_IHARM, - IS_IPOT, - IS_IPOT, - IS_IPOT, - IS_IPOT, - IS_IPOT, - IS_IPOT, - IS_IPOT, - IS_IPOT, - IS_IBODY, - IS_IBODY, - IS_IMUSH, - IS_ISIGN, - IS_IBLST, - IS_IANVL, - IS_ISTAF + IS_IHARM, + IS_IAXE, + IS_IPOT, + IS_IBOW, + IS_GOLD, + IS_ICAP, + IS_ISWORD, + IS_ISHIEL, + IS_ISWORD, + IS_IROCK, + IS_IAXE, + IS_ISTAF, + IS_IRING, + IS_ICAP, + IS_ILARM, + IS_ISHIEL, + IS_ISCROL, + IS_IHARM, + IS_IBOOK, + IS_IHARM, + IS_IPOT, + IS_IPOT, + IS_IPOT, + IS_IPOT, + IS_IPOT, + IS_IPOT, + IS_IPOT, + IS_IPOT, + IS_IBODY, + IS_IBODY, + IS_IMUSH, + IS_ISIGN, + IS_IBLST, + IS_IANVL, + IS_ISTAF }; int idoppely = 16; // weak int premiumlvladd[6] = { -1, -1, 0, 0, 1, 2 }; void __cdecl InitItemGFX() { - signed int v0; // esi - char arglist[64]; // [esp+4h] [ebp-40h] + signed int v0; // esi + char arglist[64]; // [esp+4h] [ebp-40h] - v0 = 0; - do { - sprintf(arglist, "Items\\%s.CEL", ItemDropStrs[v0]); - Item2Frm[v0] = LoadFileInMem(arglist, 0); - ++v0; - } while (v0 < 35); - memset(UniqueItemFlag, 0, sizeof(UniqueItemFlag)); + v0 = 0; + do { + sprintf(arglist, "Items\\%s.CEL", ItemDropStrs[v0]); + Item2Frm[v0] = LoadFileInMem(arglist, 0); + ++v0; + } while (v0 < 35); + memset(UniqueItemFlag, 0, sizeof(UniqueItemFlag)); } bool __fastcall ItemPlace(int xp, int yp) { - int v2; // ecx - int v3; // eax - bool result; // al + int v2; // ecx + int v3; // eax + bool result; // al - v2 = xp; - v3 = v2 * 112 + yp; - if (dMonster[0][v3] || dPlayer[v2][yp] || dItem[v2][yp] || dObject[v2][yp] || dFlags[v2][yp] & DFLAG_POPULATED) - result = 0; - else - result = nSolidTable[dPiece[0][v3]] == 0; - return result; + v2 = xp; + v3 = v2 * 112 + yp; + if (dMonster[0][v3] || dPlayer[v2][yp] || dItem[v2][yp] || dObject[v2][yp] || dFlags[v2][yp] & DFLAG_POPULATED) + result = 0; + else + result = nSolidTable[dPiece[0][v3]] == 0; + return result; } void __cdecl AddInitItems() { - int i; // eax - int ii; // ebx - int xx; // esi - int yy; // eax - int j; // eax + int i; // eax + int ii; // ebx + int xx; // esi + int yy; // eax + int j; // eax - i = random(11, 3) + 3; - if (i > 0) { - do { - ii = itemavail[0]; - itemactive[numitems] = itemavail[0]; - itemavail[0] = itemavail[MAXITEMS - numitems - 1]; - do { - xx = random(12, 80) + 16; - yy = random(12, 80) + 16; - } while (!ItemPlace(xx, yy)); - item[ii]._ix = xx; - item[ii]._iy = yy; - dItem[xx][yy] = ii + 1; - j = GetRndSeed(); - item[ii]._iSeed = j; - SetRndSeed(j); - if (random(12, 2)) - GetItemAttrs(ii, IDI_HEAL, currlevel); - else - GetItemAttrs(ii, IDI_MANA, currlevel); - item[ii]._iCreateInfo = currlevel + -32768; - SetupItem(ii); - item[ii]._iAnimFlag = 0; - item[ii]._iAnimFrame = item[ii]._iAnimLen; - item[ii]._iSelFlag = 1; - DeltaAddItem(ii); - ++numitems; - --i; - } while (i); - } + i = random(11, 3) + 3; + if (i > 0) { + do { + ii = itemavail[0]; + itemactive[numitems] = itemavail[0]; + itemavail[0] = itemavail[MAXITEMS - numitems - 1]; + do { + xx = random(12, 80) + 16; + yy = random(12, 80) + 16; + } while (!ItemPlace(xx, yy)); + item[ii]._ix = xx; + item[ii]._iy = yy; + dItem[xx][yy] = ii + 1; + j = GetRndSeed(); + item[ii]._iSeed = j; + SetRndSeed(j); + if (random(12, 2)) + GetItemAttrs(ii, IDI_HEAL, currlevel); + else + GetItemAttrs(ii, IDI_MANA, currlevel); + item[ii]._iCreateInfo = currlevel + -32768; + SetupItem(ii); + item[ii]._iAnimFlag = 0; + item[ii]._iAnimFrame = item[ii]._iAnimLen; + item[ii]._iSelFlag = 1; + DeltaAddItem(ii); + ++numitems; + --i; + } while (i); + } } void __cdecl InitItems() { - int *v0; // eax - int v1; // edx + int *v0; // eax + int v1; // edx - GetItemAttrs(0, IDI_GOLD, 1); - numitems = 0; - qmemcpy(&golditem, item, sizeof(golditem)); - golditem._iStatFlag = 1; - v0 = &item[0]._ix; - do { - *(v0 - 1) = 0; - *v0 = 0; - v0[1] = 0; - v0[2] = 0; - *((_BYTE *)v0 + 36) = 0; - v0[11] = 0; - v0[10] = 0; - v0 += 92; - } while ((signed int)v0 < (signed int)&item[MAXITEMS + 1]._ix); - v1 = 0; - memset(itemactive, 0, sizeof(itemactive)); - do { - itemavail[v1] = v1; - ++v1; - } while (v1 < MAXITEMS); - if (!setlevel) { - GetRndSeed(); - if (QuestStatus(QTYPE_INFRA)) - SpawnRock(); - if (QuestStatus(QTYPE_ANVIL)) - SpawnQuestItem(16, 2 * setpc_x + 27, 2 * setpc_y + 27, 0, 1); - if (currlevel > 0u && currlevel < 0x10u) - AddInitItems(); - } - uitemflag = 0; + GetItemAttrs(0, IDI_GOLD, 1); + numitems = 0; + qmemcpy(&golditem, item, sizeof(golditem)); + golditem._iStatFlag = 1; + v0 = &item[0]._ix; + do { + *(v0 - 1) = 0; + *v0 = 0; + v0[1] = 0; + v0[2] = 0; + *((_BYTE *)v0 + 36) = 0; + v0[11] = 0; + v0[10] = 0; + v0 += 92; + } while ((signed int)v0 < (signed int)&item[MAXITEMS + 1]._ix); + v1 = 0; + memset(itemactive, 0, sizeof(itemactive)); + do { + itemavail[v1] = v1; + ++v1; + } while (v1 < MAXITEMS); + if (!setlevel) { + GetRndSeed(); + if (QuestStatus(QTYPE_INFRA)) + SpawnRock(); + if (QuestStatus(QTYPE_ANVIL)) + SpawnQuestItem(16, 2 * setpc_x + 27, 2 * setpc_y + 27, 0, 1); + if (currlevel > 0u && currlevel < 0x10u) + AddInitItems(); + } + uitemflag = 0; } // 5CF31D: using guessed type char setlevel; void __fastcall CalcPlrItemVals(int p, BOOL Loadgfx) { - int mind = 0; // min damage - int maxd = 0; // max damage - int tac = 0; // accuracy + int mind = 0; // min damage + int maxd = 0; // max damage + int tac = 0; // accuracy - int g; - int i; - int mi; + int g; + int i; + int mi; - int bdam = 0; // bonus damage - int btohit = 0; // bonus chance to hit - int bac = 0; // bonus accuracy + int bdam = 0; // bonus damage + int btohit = 0; // bonus chance to hit + int bac = 0; // bonus accuracy - int iflgs = 0; // item_special_effect flags + int iflgs = 0; // item_special_effect flags - int sadd = 0; // added stregth - int madd = 0; // added magic - int dadd = 0; // added dexterity - int vadd = 0; // added vitality + int sadd = 0; // added stregth + int madd = 0; // added magic + int dadd = 0; // added dexterity + int vadd = 0; // added vitality - unsigned __int64 spl = 0; // bitarray for all enabled/active spells + unsigned __int64 spl = 0; // bitarray for all enabled/active spells - signed int fr = 0; // fire resistance - signed int lr = 0; // lightning resistance - signed int mr = 0; // magic resistance + signed int fr = 0; // fire resistance + signed int lr = 0; // lightning resistance + signed int mr = 0; // magic resistance - int dmod = 0; // bonus damage mod? - int ghit = 0; // (reduced) chance to get hit + int dmod = 0; // bonus damage mod? + int ghit = 0; // (reduced) chance to get hit - signed int lrad = 10; // light radius + signed int lrad = 10; // light radius - int ihp = 0; // increased HP - int imana = 0; // increased mana + int ihp = 0; // increased HP + int imana = 0; // increased mana - int spllvladd = 0; // increased spell level - int enac = 0; // enhanced accuracy + int spllvladd = 0; // increased spell level + int enac = 0; // enhanced accuracy - int fmin = 0; // minimum fire damage - int fmax = 0; // maximum fire damage - int lmin = 0; // minimum lightning damage - int lmax = 0; // maximum lightning damage + int fmin = 0; // minimum fire damage + int fmax = 0; // maximum fire damage + int lmin = 0; // minimum lightning damage + int lmax = 0; // maximum lightning damage - // didn't find a use for t for now - // int t; + // didn't find a use for t for now + // int t; - for (i = 0; i < NUM_INVLOC; i++) { - ItemStruct *itm = &plr[p].InvBody[i]; - if (itm->_itype != ITYPE_NONE && itm->_iStatFlag) { + for (i = 0; i < NUM_INVLOC; i++) { + ItemStruct *itm = &plr[p].InvBody[i]; + if (itm->_itype != ITYPE_NONE && itm->_iStatFlag) { - mind += itm->_iMinDam; - tac += itm->_iAC; - maxd += itm->_iMaxDam; + mind += itm->_iMinDam; + tac += itm->_iAC; + maxd += itm->_iMaxDam; - if (itm->_iSpell != SPL_NULL) { - spl |= (unsigned __int64)1 << (itm->_iSpell - 1); - } + if (itm->_iSpell != SPL_NULL) { + spl |= (unsigned __int64)1 << (itm->_iSpell - 1); + } - if (itm->_iMagical == ITEM_QUALITY_NORMAL || itm->_iIdentified) { - bdam += itm->_iPLDam; - btohit += itm->_iPLToHit; - if (itm->_iPLAC) { - int tmpac = itm->_iPLAC * itm->_iAC / 100; - if (tmpac == 0) - tmpac = 1; - bac += tmpac; - } - dmod += itm->_iPLDamMod; - iflgs |= itm->_iFlags; - sadd += itm->_iPLStr; - madd += itm->_iPLMag; - dadd += itm->_iPLDex; - vadd += itm->_iPLVit; - fr += itm->_iPLFR; - lr += itm->_iPLLR; - mr += itm->_iPLMR; - ghit += itm->_iPLGetHit; - lrad += itm->_iPLLight; - ihp += itm->_iPLHP; - imana += itm->_iPLMana; - spllvladd += itm->_iSplLvlAdd; - enac += itm->_iPLEnAc; - fmin += itm->_iFMinDam; - fmax += itm->_iFMaxDam; - lmin += itm->_iLMinDam; - lmax += itm->_iLMaxDam; - } - } - } + if (itm->_iMagical == ITEM_QUALITY_NORMAL || itm->_iIdentified) { + bdam += itm->_iPLDam; + btohit += itm->_iPLToHit; + if (itm->_iPLAC) { + int tmpac = itm->_iPLAC * itm->_iAC / 100; + if (tmpac == 0) + tmpac = 1; + bac += tmpac; + } + dmod += itm->_iPLDamMod; + iflgs |= itm->_iFlags; + sadd += itm->_iPLStr; + madd += itm->_iPLMag; + dadd += itm->_iPLDex; + vadd += itm->_iPLVit; + fr += itm->_iPLFR; + lr += itm->_iPLLR; + mr += itm->_iPLMR; + ghit += itm->_iPLGetHit; + lrad += itm->_iPLLight; + ihp += itm->_iPLHP; + imana += itm->_iPLMana; + spllvladd += itm->_iSplLvlAdd; + enac += itm->_iPLEnAc; + fmin += itm->_iFMinDam; + fmax += itm->_iFMaxDam; + lmin += itm->_iLMinDam; + lmax += itm->_iLMaxDam; + } + } + } - if (mind == 0 && maxd == 0) { - mind = 1; - maxd = 1; + if (mind == 0 && maxd == 0) { + mind = 1; + maxd = 1; - if (plr[p].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_SHIELD && plr[p].InvBody[INVLOC_HAND_LEFT]._iStatFlag) { - maxd = 3; - } + if (plr[p].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_SHIELD && plr[p].InvBody[INVLOC_HAND_LEFT]._iStatFlag) { + maxd = 3; + } - if (plr[p].InvBody[INVLOC_HAND_RIGHT]._itype == ITYPE_SHIELD && plr[p].InvBody[INVLOC_HAND_RIGHT]._iStatFlag) { - maxd = 3; - } - } + if (plr[p].InvBody[INVLOC_HAND_RIGHT]._itype == ITYPE_SHIELD && plr[p].InvBody[INVLOC_HAND_RIGHT]._iStatFlag) { + maxd = 3; + } + } - plr[p]._pIMaxDam = maxd; - plr[p]._pIAC = tac; - plr[p]._pIBonusDam = bdam; - plr[p]._pIBonusToHit = btohit; - plr[p]._pIBonusAC = bac; - plr[p]._pIFlags = iflgs; - plr[p]._pIGetHit = ghit; - plr[p]._pIMinDam = mind; - plr[p]._pIBonusDamMod = dmod; + plr[p]._pIMaxDam = maxd; + plr[p]._pIAC = tac; + plr[p]._pIBonusDam = bdam; + plr[p]._pIBonusToHit = btohit; + plr[p]._pIBonusAC = bac; + plr[p]._pIFlags = iflgs; + plr[p]._pIGetHit = ghit; + plr[p]._pIMinDam = mind; + plr[p]._pIBonusDamMod = dmod; - if (lrad < 2) { - lrad = 2; - } - if (lrad > 15) { - lrad = 15; - } + if (lrad < 2) { + lrad = 2; + } + if (lrad > 15) { + lrad = 15; + } - if (plr[p]._pLightRad != lrad && p == myplr) { - ChangeLightRadius(plr[p]._plid, lrad); + if (plr[p]._pLightRad != lrad && p == myplr) { + ChangeLightRadius(plr[p]._plid, lrad); - int pvid = plr[p]._pvid; - if (lrad >= 10) { - ChangeVisionRadius(pvid, lrad); - } else { - ChangeVisionRadius(pvid, 10); - } + int pvid = plr[p]._pvid; + if (lrad >= 10) { + ChangeVisionRadius(pvid, lrad); + } else { + ChangeVisionRadius(pvid, 10); + } - plr[p]._pLightRad = lrad; - } + plr[p]._pLightRad = lrad; + } - plr[p]._pStrength = sadd + plr[p]._pBaseStr; - if (plr[myplr]._pStrength <= 0) { - plr[myplr]._pStrength = 0; - } + plr[p]._pStrength = sadd + plr[p]._pBaseStr; + if (plr[myplr]._pStrength <= 0) { + plr[myplr]._pStrength = 0; + } - plr[p]._pMagic = madd + plr[p]._pBaseMag; - if (plr[myplr]._pMagic <= 0) { - plr[myplr]._pMagic = 0; - } + plr[p]._pMagic = madd + plr[p]._pBaseMag; + if (plr[myplr]._pMagic <= 0) { + plr[myplr]._pMagic = 0; + } - plr[p]._pDexterity = dadd + plr[p]._pBaseDex; - if (plr[myplr]._pDexterity <= 0) { - plr[myplr]._pDexterity = 0; - } + plr[p]._pDexterity = dadd + plr[p]._pBaseDex; + if (plr[myplr]._pDexterity <= 0) { + plr[myplr]._pDexterity = 0; + } - plr[p]._pVitality = vadd + plr[p]._pBaseVit; - if (plr[myplr]._pVitality <= 0) { - plr[myplr]._pVitality = 0; - } + plr[p]._pVitality = vadd + plr[p]._pBaseVit; + if (plr[myplr]._pVitality <= 0) { + plr[myplr]._pVitality = 0; + } - if (plr[p]._pClass == PC_ROGUE) { - plr[p]._pDamageMod = plr[p]._pLevel * (plr[p]._pStrength + plr[p]._pDexterity) / 200; - } else { - plr[p]._pDamageMod = plr[p]._pLevel * plr[p]._pStrength / 100; - } + if (plr[p]._pClass == PC_ROGUE) { + plr[p]._pDamageMod = plr[p]._pLevel * (plr[p]._pStrength + plr[p]._pDexterity) / 200; + } else { + plr[p]._pDamageMod = plr[p]._pLevel * plr[p]._pStrength / 100; + } - plr[p]._pISpells = spl; + plr[p]._pISpells = spl; - // check if the current RSplType is a valid/allowed spell - if (plr[p]._pRSplType == RSPLTYPE_CHARGES - && !(spl & ((unsigned __int64)1 << (plr[p]._pRSpell - 1)))) { - plr[p]._pRSpell = SPL_INVALID; - plr[p]._pRSplType = RSPLTYPE_INVALID; - drawpanflag = 255; - } + // check if the current RSplType is a valid/allowed spell + if (plr[p]._pRSplType == RSPLTYPE_CHARGES + && !(spl & ((unsigned __int64)1 << (plr[p]._pRSpell - 1)))) { + plr[p]._pRSpell = SPL_INVALID; + plr[p]._pRSplType = RSPLTYPE_INVALID; + drawpanflag = 255; + } - plr[p]._pISplLvlAdd = spllvladd; - plr[p]._pIEnAc = enac; + plr[p]._pISplLvlAdd = spllvladd; + plr[p]._pIEnAc = enac; - if (iflgs & ISPL_ALLRESZERO) { - // reset resistances to zero if the respective special effect is active - mr = 0; - fr = 0; - lr = 0; - } + if (iflgs & ISPL_ALLRESZERO) { + // reset resistances to zero if the respective special effect is active + mr = 0; + fr = 0; + lr = 0; + } - if (mr > 75) { - mr = 75; - } - plr[p]._pMagResist = mr; + if (mr > 75) { + mr = 75; + } + plr[p]._pMagResist = mr; - if (fr > 75) { - fr = 75; - } - plr[p]._pFireResist = fr; + if (fr > 75) { + fr = 75; + } + plr[p]._pFireResist = fr; - if (lr > 75) { - lr = 75; - } - plr[p]._pLghtResist = lr; + if (lr > 75) { + lr = 75; + } + plr[p]._pLghtResist = lr; - if (plr[p]._pClass == PC_WARRIOR) { - vadd *= 2; - } - if (plr[p]._pClass == PC_ROGUE) { - vadd += vadd >> 1; - } - ihp += (vadd << 6); + if (plr[p]._pClass == PC_WARRIOR) { + vadd *= 2; + } + if (plr[p]._pClass == PC_ROGUE) { + vadd += vadd >> 1; + } + ihp += (vadd << 6); - if (plr[p]._pClass == PC_SORCERER) { - madd *= 2; - } - if (plr[p]._pClass == PC_ROGUE) { - madd += madd >> 1; - } - imana += (madd << 6); + if (plr[p]._pClass == PC_SORCERER) { + madd *= 2; + } + if (plr[p]._pClass == PC_ROGUE) { + madd += madd >> 1; + } + imana += (madd << 6); - plr[p]._pHitPoints = ihp + plr[p]._pHPBase; - plr[p]._pMaxHP = ihp + plr[p]._pMaxHPBase; + plr[p]._pHitPoints = ihp + plr[p]._pHPBase; + plr[p]._pMaxHP = ihp + plr[p]._pMaxHPBase; - if (p == myplr && (plr[p]._pHitPoints >> 6) <= 0) { - SetPlayerHitPoints(p, 0); - } + if (p == myplr && (plr[p]._pHitPoints >> 6) <= 0) { + SetPlayerHitPoints(p, 0); + } - plr[p]._pMana = imana + plr[p]._pManaBase; - plr[p]._pMaxMana = imana + plr[p]._pMaxManaBase; + plr[p]._pMana = imana + plr[p]._pManaBase; + plr[p]._pMaxMana = imana + plr[p]._pMaxManaBase; - plr[p]._pIFMinDam = fmin; - plr[p]._pIFMaxDam = fmax; - plr[p]._pILMinDam = lmin; - plr[p]._pILMaxDam = lmax; + plr[p]._pIFMinDam = fmin; + plr[p]._pIFMaxDam = fmax; + plr[p]._pILMinDam = lmin; + plr[p]._pILMaxDam = lmax; - if (iflgs & ISPL_INFRAVISION) { - plr[p]._pInfraFlag = 1; - } else { - plr[p]._pInfraFlag = 0; - } + if (iflgs & ISPL_INFRAVISION) { + plr[p]._pInfraFlag = 1; + } else { + plr[p]._pInfraFlag = 0; + } - plr[p]._pBlockFlag = 0; - plr[p]._pwtype = 0; + plr[p]._pBlockFlag = 0; + plr[p]._pwtype = 0; - g = 0; + g = 0; - if (plr[p].InvBody[INVLOC_HAND_LEFT]._itype != ITYPE_NONE - && plr[p].InvBody[INVLOC_HAND_LEFT]._iClass == ICLASS_WEAPON - && plr[p].InvBody[INVLOC_HAND_LEFT]._iStatFlag) { - g = plr[p].InvBody[INVLOC_HAND_LEFT]._itype; - } + if (plr[p].InvBody[INVLOC_HAND_LEFT]._itype != ITYPE_NONE + && plr[p].InvBody[INVLOC_HAND_LEFT]._iClass == ICLASS_WEAPON + && plr[p].InvBody[INVLOC_HAND_LEFT]._iStatFlag) { + g = plr[p].InvBody[INVLOC_HAND_LEFT]._itype; + } - if (plr[p].InvBody[INVLOC_HAND_RIGHT]._itype != ITYPE_NONE - && plr[p].InvBody[INVLOC_HAND_RIGHT]._iClass == ICLASS_WEAPON - && plr[p].InvBody[INVLOC_HAND_RIGHT]._iStatFlag) { - g = plr[p].InvBody[INVLOC_HAND_RIGHT]._itype; - } + if (plr[p].InvBody[INVLOC_HAND_RIGHT]._itype != ITYPE_NONE + && plr[p].InvBody[INVLOC_HAND_RIGHT]._iClass == ICLASS_WEAPON + && plr[p].InvBody[INVLOC_HAND_RIGHT]._iStatFlag) { + g = plr[p].InvBody[INVLOC_HAND_RIGHT]._itype; + } - switch (g) { - case ITYPE_SWORD: - g = ANIM_ID_SWORD; - break; - case ITYPE_AXE: - g = ANIM_ID_AXE; - break; - case ITYPE_BOW: - plr[p]._pwtype = 1; - g = ANIM_ID_BOW; - break; - case ITYPE_MACE: - g = ANIM_ID_MACE; - break; - case ITYPE_STAFF: - g = ANIM_ID_STAFF; - break; - } + switch (g) { + case ITYPE_SWORD: + g = ANIM_ID_SWORD; + break; + case ITYPE_AXE: + g = ANIM_ID_AXE; + break; + case ITYPE_BOW: + plr[p]._pwtype = 1; + g = ANIM_ID_BOW; + break; + case ITYPE_MACE: + g = ANIM_ID_MACE; + break; + case ITYPE_STAFF: + g = ANIM_ID_STAFF; + break; + } - if (plr[p].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_SHIELD && plr[p].InvBody[INVLOC_HAND_LEFT]._iStatFlag) { - plr[p]._pBlockFlag = 1; - g++; - } - if (plr[p].InvBody[INVLOC_HAND_RIGHT]._itype == ITYPE_SHIELD && plr[p].InvBody[INVLOC_HAND_RIGHT]._iStatFlag) { - plr[p]._pBlockFlag = 1; - g++; - } + if (plr[p].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_SHIELD && plr[p].InvBody[INVLOC_HAND_LEFT]._iStatFlag) { + plr[p]._pBlockFlag = 1; + g++; + } + if (plr[p].InvBody[INVLOC_HAND_RIGHT]._itype == ITYPE_SHIELD && plr[p].InvBody[INVLOC_HAND_RIGHT]._iStatFlag) { + plr[p]._pBlockFlag = 1; + g++; + } - if (plr[p].InvBody[INVLOC_CHEST]._itype == ITYPE_MARMOR && plr[p].InvBody[INVLOC_CHEST]._iStatFlag) { - g += ANIM_ID_MEDIUM_ARMOR; - } - if (plr[p].InvBody[INVLOC_CHEST]._itype == ITYPE_HARMOR && plr[p].InvBody[INVLOC_CHEST]._iStatFlag) { - g += ANIM_ID_HEAVY_ARMOR; - } + if (plr[p].InvBody[INVLOC_CHEST]._itype == ITYPE_MARMOR && plr[p].InvBody[INVLOC_CHEST]._iStatFlag) { + g += ANIM_ID_MEDIUM_ARMOR; + } + if (plr[p].InvBody[INVLOC_CHEST]._itype == ITYPE_HARMOR && plr[p].InvBody[INVLOC_CHEST]._iStatFlag) { + g += ANIM_ID_HEAVY_ARMOR; + } - if (plr[p]._pgfxnum != g && Loadgfx) { - plr[p]._pgfxnum = g; - plr[p]._pGFXLoad = 0; - LoadPlrGFX(p, PFILE_STAND); - SetPlrAnims(p); + if (plr[p]._pgfxnum != g && Loadgfx) { + plr[p]._pgfxnum = g; + plr[p]._pGFXLoad = 0; + LoadPlrGFX(p, PFILE_STAND); + SetPlrAnims(p); - int d = plr[p]._pdir; + int d = plr[p]._pdir; - // TODO: Add debug assert here ( plr[p]._pNAnim[d] != NULL ) - plr[p]._pAnimData = plr[p]._pNAnim[d]; + // TODO: Add debug assert here ( plr[p]._pNAnim[d] != NULL ) + plr[p]._pAnimData = plr[p]._pNAnim[d]; - plr[p]._pAnimLen = plr[p]._pNFrames; - plr[p]._pAnimFrame = 1; - plr[p]._pAnimCnt = 0; - plr[p]._pAnimDelay = 3; - plr[p]._pAnimWidth = plr[p]._pNWidth; - plr[p]._pAnimWidth2 = (plr[p]._pNWidth - 64) >> 1; - } else { - plr[p]._pgfxnum = g; - } + plr[p]._pAnimLen = plr[p]._pNFrames; + plr[p]._pAnimFrame = 1; + plr[p]._pAnimCnt = 0; + plr[p]._pAnimDelay = 3; + plr[p]._pAnimWidth = plr[p]._pNWidth; + plr[p]._pAnimWidth2 = (plr[p]._pNWidth - 64) >> 1; + } else { + plr[p]._pgfxnum = g; + } - for (i = 0; i < nummissiles; i++) { - mi = missileactive[i]; - if (missile[mi]._mitype == 13 && missile[mi]._misource == p) { - missile[mi]._miVar1 = plr[p]._pHitPoints; - missile[mi]._miVar2 = plr[p]._pHPBase; - } - } + for (i = 0; i < nummissiles; i++) { + mi = missileactive[i]; + if (missile[mi]._mitype == 13 && missile[mi]._misource == p) { + missile[mi]._miVar1 = plr[p]._pHitPoints; + missile[mi]._miVar2 = plr[p]._pHPBase; + } + } - drawmanaflag = TRUE; - drawhpflag = TRUE; + drawmanaflag = TRUE; + drawhpflag = TRUE; } void __fastcall CalcPlrScrolls(int p) { - plr[p]._pScrlSpells = 0; - for (int i = 0; i < plr[p]._pNumInv; i++) { - if (plr[p].InvList[i]._itype != ITYPE_NONE && (plr[p].InvList[i]._iMiscId == IMISC_SCROLL || plr[p].InvList[i]._iMiscId == IMISC_SCROLLT)) { - if (plr[p].InvList[i]._iStatFlag) - plr[p]._pScrlSpells |= (__int64)1 << (plr[p].InvList[i]._iSpell - 1); - } - } + plr[p]._pScrlSpells = 0; + for (int i = 0; i < plr[p]._pNumInv; i++) { + if (plr[p].InvList[i]._itype != ITYPE_NONE && (plr[p].InvList[i]._iMiscId == IMISC_SCROLL || plr[p].InvList[i]._iMiscId == IMISC_SCROLLT)) { + if (plr[p].InvList[i]._iStatFlag) + plr[p]._pScrlSpells |= (__int64)1 << (plr[p].InvList[i]._iSpell - 1); + } + } - for (int j = 0; j < MAXBELTITEMS; j++) { - if (plr[p].SpdList[j]._itype != ITYPE_NONE && (plr[p].SpdList[j]._iMiscId == IMISC_SCROLL || plr[p].SpdList[j]._iMiscId == IMISC_SCROLLT)) { - if (plr[p].SpdList[j]._iStatFlag) - plr[p]._pScrlSpells |= (__int64)1 << (plr[p].SpdList[j]._iSpell - 1); - } - } - if (plr[p]._pRSplType == RSPLTYPE_SCROLL) { - if (!(plr[p]._pScrlSpells & 1 << (plr[p]._pRSpell - 1))) { - plr[p]._pRSpell = SPL_INVALID; - plr[p]._pRSplType = RSPLTYPE_INVALID; - drawpanflag = 255; - } - } + for (int j = 0; j < MAXBELTITEMS; j++) { + if (plr[p].SpdList[j]._itype != ITYPE_NONE && (plr[p].SpdList[j]._iMiscId == IMISC_SCROLL || plr[p].SpdList[j]._iMiscId == IMISC_SCROLLT)) { + if (plr[p].SpdList[j]._iStatFlag) + plr[p]._pScrlSpells |= (__int64)1 << (plr[p].SpdList[j]._iSpell - 1); + } + } + if (plr[p]._pRSplType == RSPLTYPE_SCROLL) { + if (!(plr[p]._pScrlSpells & 1 << (plr[p]._pRSpell - 1))) { + plr[p]._pRSpell = SPL_INVALID; + plr[p]._pRSplType = RSPLTYPE_INVALID; + drawpanflag = 255; + } + } } // 52571C: using guessed type int drawpanflag; void __fastcall CalcPlrStaff(int pnum) { - plr[pnum]._pISpells = 0; - if (plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype != ITYPE_NONE && plr[pnum].InvBody[INVLOC_HAND_LEFT]._iStatFlag && plr[pnum].InvBody[INVLOC_HAND_LEFT]._iCharges > 0) { - plr[pnum]._pISpells |= (__int64)1 << (plr[pnum].InvBody[INVLOC_HAND_LEFT]._iSpell - 1); - } + plr[pnum]._pISpells = 0; + if (plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype != ITYPE_NONE && plr[pnum].InvBody[INVLOC_HAND_LEFT]._iStatFlag && plr[pnum].InvBody[INVLOC_HAND_LEFT]._iCharges > 0) { + plr[pnum]._pISpells |= (__int64)1 << (plr[pnum].InvBody[INVLOC_HAND_LEFT]._iSpell - 1); + } } void __fastcall CalcSelfItems(int pnum) { - PlayerStruct *v1; // ecx - int v2; // edx - int v3; // esi - int v4; // edi - int *v5; // eax - signed int v6; // ebx - bool v7; // zf - char *v8; // eax - signed int v9; // [esp+Ch] [ebp-10h] - signed int v10; // [esp+10h] [ebp-Ch] - int v11; // [esp+14h] [ebp-8h] - signed int v12; // [esp+18h] [ebp-4h] + PlayerStruct *v1; // ecx + int v2; // edx + int v3; // esi + int v4; // edi + int *v5; // eax + signed int v6; // ebx + bool v7; // zf + char *v8; // eax + signed int v9; // [esp+Ch] [ebp-10h] + signed int v10; // [esp+10h] [ebp-Ch] + int v11; // [esp+14h] [ebp-8h] + signed int v12; // [esp+18h] [ebp-4h] - v1 = &plr[pnum]; - v2 = 0; - v3 = 0; - v4 = 0; - v5 = &v1->InvBody[0]._iStatFlag; - v6 = 7; - do { - if (*(v5 - 87) != -1) { - v7 = *(v5 - 75) == 0; - *v5 = 1; - if (!v7) { - v2 += *(v5 - 25); - v3 += *(v5 - 24); - v4 += *(v5 - 23); - } - } - v5 += 92; - --v6; - } while (v6); - v11 = v4; - do { - v9 = 0; - v8 = &v1->InvBody[0]._iMinStr; - v10 = 7; - do { - if (*((_DWORD *)v8 - 86) != -1 && *((_DWORD *)v8 + 1)) { - v12 = 1; - if (v2 + v1->_pBaseStr < *v8) - v12 = 0; - if (v3 + v1->_pBaseMag < (unsigned char)v8[1]) - v12 = 0; - if (v11 + v1->_pBaseDex < v8[2]) - v12 = 0; - if (!v12) { - v7 = *((_DWORD *)v8 - 74) == 0; - v9 = 1; - *((_DWORD *)v8 + 1) = 0; - if (!v7) { - v2 -= *((_DWORD *)v8 - 24); - v3 -= *((_DWORD *)v8 - 23); - v11 -= *((_DWORD *)v8 - 22); - } - } - } - v8 += 368; - --v10; - } while (v10); - } while (v9); + v1 = &plr[pnum]; + v2 = 0; + v3 = 0; + v4 = 0; + v5 = &v1->InvBody[0]._iStatFlag; + v6 = 7; + do { + if (*(v5 - 87) != -1) { + v7 = *(v5 - 75) == 0; + *v5 = 1; + if (!v7) { + v2 += *(v5 - 25); + v3 += *(v5 - 24); + v4 += *(v5 - 23); + } + } + v5 += 92; + --v6; + } while (v6); + v11 = v4; + do { + v9 = 0; + v8 = &v1->InvBody[0]._iMinStr; + v10 = 7; + do { + if (*((_DWORD *)v8 - 86) != -1 && *((_DWORD *)v8 + 1)) { + v12 = 1; + if (v2 + v1->_pBaseStr < *v8) + v12 = 0; + if (v3 + v1->_pBaseMag < (unsigned char)v8[1]) + v12 = 0; + if (v11 + v1->_pBaseDex < v8[2]) + v12 = 0; + if (!v12) { + v7 = *((_DWORD *)v8 - 74) == 0; + v9 = 1; + *((_DWORD *)v8 + 1) = 0; + if (!v7) { + v2 -= *((_DWORD *)v8 - 24); + v3 -= *((_DWORD *)v8 - 23); + v11 -= *((_DWORD *)v8 - 22); + } + } + } + v8 += 368; + --v10; + } while (v10); + } while (v9); } void __fastcall CalcPlrItemMin(int pnum) { - PlayerStruct *v1; // ecx - PlayerStruct *v2; // esi - ItemStruct *v3; // edi - int v4; // ebp - ItemStruct *v6; // edi - signed int v7; // ebp + PlayerStruct *v1; // ecx + PlayerStruct *v2; // esi + ItemStruct *v3; // edi + int v4; // ebp + ItemStruct *v6; // edi + signed int v7; // ebp - v1 = &plr[pnum]; - v2 = v1; - v3 = v1->InvList; - if (v1->_pNumInv) { - v4 = v1->_pNumInv; - do { - v3->_iStatFlag = ItemMinStats(v2, v3); - ++v3; - --v4; - } while (v4); - } - v6 = v2->SpdList; - v7 = MAXBELTITEMS; - do { - if (v6->_itype != -1) { - v6->_iStatFlag = ItemMinStats(v2, v6); - } - ++v6; - --v7; - } while (v7); + v1 = &plr[pnum]; + v2 = v1; + v3 = v1->InvList; + if (v1->_pNumInv) { + v4 = v1->_pNumInv; + do { + v3->_iStatFlag = ItemMinStats(v2, v3); + ++v3; + --v4; + } while (v4); + } + v6 = v2->SpdList; + v7 = MAXBELTITEMS; + do { + if (v6->_itype != -1) { + v6->_iStatFlag = ItemMinStats(v2, v6); + } + ++v6; + --v7; + } while (v7); } bool __fastcall ItemMinStats(PlayerStruct *p, ItemStruct *x) { - if (p->_pStrength < x->_iMinStr || p->_pMagic < x->_iMinMag || p->_pDexterity < x->_iMinDex) - return 0; - else - return 1; + if (p->_pStrength < x->_iMinStr || p->_pMagic < x->_iMinMag || p->_pDexterity < x->_iMinDex) + return 0; + else + return 1; } void __fastcall CalcPlrBookVals(int p) { - int v1; // esi - int v2; // ebx - int *v3; // edi - int v5; // esi - int *v6; // edi - int v7; // eax - unsigned char v8; // cl - unsigned char v9; // cl - int v10; // eax - int v12; // [esp+Ch] [ebp-Ch] - int v13; // [esp+10h] [ebp-8h] - unsigned char v14; // [esp+17h] [ebp-1h] + int v1; // esi + int v2; // ebx + int *v3; // edi + int v5; // esi + int *v6; // edi + int v7; // eax + unsigned char v8; // cl + unsigned char v9; // cl + int v10; // eax + int v12; // [esp+Ch] [ebp-Ch] + int v13; // [esp+10h] [ebp-8h] + unsigned char v14; // [esp+17h] [ebp-1h] - v1 = p; - if (!currlevel) { - v2 = 1; - if (witchitem[1]._itype != -1) { - v3 = &witchitem[1]._iStatFlag; - do { - WitchBookLevel(v2); - *v3 = StoreStatOk((ItemStruct *)(v3 - 89)); - v3 += 92; - ++v2; - } while (*(v3 - 87) != -1); - } - } - v5 = v1; - v12 = 0; - if (plr[v5]._pNumInv > 0) { - v6 = &plr[v5].InvList[0]._iSpell; - do { - if (!*(v6 - 54) && *(v6 - 1) == 24) { - v7 = *v6; - v8 = spelldata[*v6].sMinInt; - *((_BYTE *)v6 + 129) = v8; - v13 = plr[0]._pSplLvl[v7 + v5 * 21720]; - if (plr[0]._pSplLvl[v7 + v5 * 21720]) { - do { - v9 = 20 * v8 / 100 + v8; - --v13; - v14 = v9; - v10 = v9 + 20 * v9 / 100; - v8 = -1; - if (v10 <= 255) - v8 = v14; - else - v13 = 0; - } while (v13); - *((_BYTE *)v6 + 129) = v8; - } - v6[33] = ItemMinStats(&plr[v5], (ItemStruct *)(v6 - 56)); - } - ++v12; - v6 += 92; - } while (v12 < plr[v5]._pNumInv); - } + v1 = p; + if (!currlevel) { + v2 = 1; + if (witchitem[1]._itype != -1) { + v3 = &witchitem[1]._iStatFlag; + do { + WitchBookLevel(v2); + *v3 = StoreStatOk((ItemStruct *)(v3 - 89)); + v3 += 92; + ++v2; + } while (*(v3 - 87) != -1); + } + } + v5 = v1; + v12 = 0; + if (plr[v5]._pNumInv > 0) { + v6 = &plr[v5].InvList[0]._iSpell; + do { + if (!*(v6 - 54) && *(v6 - 1) == 24) { + v7 = *v6; + v8 = spelldata[*v6].sMinInt; + *((_BYTE *)v6 + 129) = v8; + v13 = plr[0]._pSplLvl[v7 + v5 * 21720]; + if (plr[0]._pSplLvl[v7 + v5 * 21720]) { + do { + v9 = 20 * v8 / 100 + v8; + --v13; + v14 = v9; + v10 = v9 + 20 * v9 / 100; + v8 = -1; + if (v10 <= 255) + v8 = v14; + else + v13 = 0; + } while (v13); + *((_BYTE *)v6 + 129) = v8; + } + v6[33] = ItemMinStats(&plr[v5], (ItemStruct *)(v6 - 56)); + } + ++v12; + v6 += 92; + } while (v12 < plr[v5]._pNumInv); + } } void __fastcall CalcPlrInv(int p, BOOL Loadgfx) { - CalcPlrItemMin(p); - CalcSelfItems(p); - CalcPlrItemVals(p, Loadgfx); - CalcPlrItemMin(p); - if (p == myplr) { - CalcPlrBookVals(p); - CalcPlrScrolls(p); - CalcPlrStaff(p); - if (p == myplr && !currlevel) - RecalcStoreStats(); - } + CalcPlrItemMin(p); + CalcSelfItems(p); + CalcPlrItemVals(p, Loadgfx); + CalcPlrItemMin(p); + if (p == myplr) { + CalcPlrBookVals(p); + CalcPlrScrolls(p); + CalcPlrStaff(p); + if (p == myplr && !currlevel) + RecalcStoreStats(); + } } void __fastcall SetPlrHandItem(ItemStruct *h, int idata) { - ItemDataStruct *pAllItem; + ItemDataStruct *pAllItem; - pAllItem = &AllItemsList[idata]; + pAllItem = &AllItemsList[idata]; - // zero-initialize struct - memset(h, 0, sizeof(*h)); + // zero-initialize struct + memset(h, 0, sizeof(*h)); - h->_itype = pAllItem->itype; - h->_iCurs = pAllItem->iCurs; - strcpy(h->_iName, pAllItem->iName); - strcpy(h->_iIName, pAllItem->iName); - h->_iLoc = pAllItem->iLoc; - h->_iClass = pAllItem->iClass; - h->_iMinDam = pAllItem->iMinDam; - h->_iMaxDam = pAllItem->iMaxDam; - h->_iAC = pAllItem->iMinAC; - h->_iMiscId = pAllItem->iMiscId; - h->_iSpell = pAllItem->iSpell; + h->_itype = pAllItem->itype; + h->_iCurs = pAllItem->iCurs; + strcpy(h->_iName, pAllItem->iName); + strcpy(h->_iIName, pAllItem->iName); + h->_iLoc = pAllItem->iLoc; + h->_iClass = pAllItem->iClass; + h->_iMinDam = pAllItem->iMinDam; + h->_iMaxDam = pAllItem->iMaxDam; + h->_iAC = pAllItem->iMinAC; + h->_iMiscId = pAllItem->iMiscId; + h->_iSpell = pAllItem->iSpell; - if (pAllItem->iMiscId == IMISC_STAFF) { - h->_iCharges = 40; - } + if (pAllItem->iMiscId == IMISC_STAFF) { + h->_iCharges = 40; + } - h->_iMaxCharges = h->_iCharges; - h->_iDurability = pAllItem->iDurability; - h->_iMaxDur = pAllItem->iDurability; - h->_iMinStr = pAllItem->iMinStr; - h->_iMinMag = pAllItem->iMinMag; - h->_iMinDex = pAllItem->iMinDex; - h->_ivalue = pAllItem->iValue; - h->_iIvalue = pAllItem->iValue; - h->_iPrePower = -1; - h->_iSufPower = -1; - h->_iMagical = ITEM_QUALITY_NORMAL; - h->IDidx = idata; + h->_iMaxCharges = h->_iCharges; + h->_iDurability = pAllItem->iDurability; + h->_iMaxDur = pAllItem->iDurability; + h->_iMinStr = pAllItem->iMinStr; + h->_iMinMag = pAllItem->iMinMag; + h->_iMinDex = pAllItem->iMinDex; + h->_ivalue = pAllItem->iValue; + h->_iIvalue = pAllItem->iValue; + h->_iPrePower = -1; + h->_iSufPower = -1; + h->_iMagical = ITEM_QUALITY_NORMAL; + h->IDidx = idata; } void __fastcall GetPlrHandSeed(ItemStruct *h) { - h->_iSeed = GetRndSeed(); + h->_iSeed = GetRndSeed(); } void __fastcall GetGoldSeed(int pnum, ItemStruct *h) { - int v3; // edi - signed int v4; // esi - int v5; // eax - int i; // ecx - int v7; // edx - ItemStruct *v8; // ecx + int v3; // edi + signed int v4; // esi + int v5; // eax + int i; // ecx + int v7; // edx + ItemStruct *v8; // ecx - v3 = pnum; - do { - v4 = 1; - v5 = GetRndSeed(); - for (i = 0; i < numitems; ++i) { - if (item[itemactive[i]]._iSeed == v5) - v4 = 0; - } - if (v3 == myplr) { - v7 = plr[v3]._pNumInv; - if (v7 > 0) { - v8 = plr[v3].InvList; - do { - if (v8->_iSeed == v5) - v4 = 0; - ++v8; - --v7; - } while (v7); - } - } - } while (!v4); - h->_iSeed = v5; + v3 = pnum; + do { + v4 = 1; + v5 = GetRndSeed(); + for (i = 0; i < numitems; ++i) { + if (item[itemactive[i]]._iSeed == v5) + v4 = 0; + } + if (v3 == myplr) { + v7 = plr[v3]._pNumInv; + if (v7 > 0) { + v8 = plr[v3].InvList; + do { + if (v8->_iSeed == v5) + v4 = 0; + ++v8; + --v7; + } while (v7); + } + } + } while (!v4); + h->_iSeed = v5; } void __fastcall SetPlrHandSeed(ItemStruct *h, int iseed) { - h->_iSeed = iseed; + h->_iSeed = iseed; } void __fastcall SetPlrHandGoldCurs(ItemStruct *h) { - int v1; // eax + int v1; // eax - v1 = h->_ivalue; - if (v1 < 2500) { - if (v1 > 1000) - h->_iCurs = ICURS_GOLD_MEDIUM; - else - h->_iCurs = ICURS_GOLD_SMALL; - } else { - h->_iCurs = ICURS_GOLD_LARGE; - } + v1 = h->_ivalue; + if (v1 < 2500) { + if (v1 > 1000) + h->_iCurs = ICURS_GOLD_MEDIUM; + else + h->_iCurs = ICURS_GOLD_SMALL; + } else { + h->_iCurs = ICURS_GOLD_LARGE; + } } void __fastcall CreatePlrItems(int p) { - int i; - ItemStruct *pi = plr[p].InvBody; + int i; + ItemStruct *pi = plr[p].InvBody; - for (i = 0; i < NUM_INVLOC; i++) { - pi[i]._itype = ITYPE_NONE; - } + for (i = 0; i < NUM_INVLOC; i++) { + pi[i]._itype = ITYPE_NONE; + } - // converting this to a for loop creates a `rep stosd` instruction, - // so this probably actually was a memset - memset(&plr[p].InvGrid, 0, sizeof(plr[p].InvGrid)); + // converting this to a for loop creates a `rep stosd` instruction, + // so this probably actually was a memset + memset(&plr[p].InvGrid, 0, sizeof(plr[p].InvGrid)); - pi = plr[p].InvList; - for (i = 0; i < NUM_INV_GRID_ELEM; i++) { - pi[i]._itype = ITYPE_NONE; - } + pi = plr[p].InvList; + for (i = 0; i < NUM_INV_GRID_ELEM; i++) { + pi[i]._itype = ITYPE_NONE; + } - plr[p]._pNumInv = 0; + plr[p]._pNumInv = 0; - pi = plr[p].SpdList; - for (i = 0; i < MAXBELTITEMS; i++) { - pi[i]._itype = ITYPE_NONE; - } + pi = plr[p].SpdList; + for (i = 0; i < MAXBELTITEMS; i++) { + pi[i]._itype = ITYPE_NONE; + } - switch (plr[p]._pClass) { - case PC_WARRIOR: - SetPlrHandItem(&plr[p].InvBody[INVLOC_HAND_LEFT], IDI_WARRIOR); - GetPlrHandSeed(&plr[p].InvBody[INVLOC_HAND_LEFT]); + switch (plr[p]._pClass) { + case PC_WARRIOR: + SetPlrHandItem(&plr[p].InvBody[INVLOC_HAND_LEFT], IDI_WARRIOR); + GetPlrHandSeed(&plr[p].InvBody[INVLOC_HAND_LEFT]); - SetPlrHandItem(&plr[p].InvBody[INVLOC_HAND_RIGHT], IDI_WARRSHLD); - GetPlrHandSeed(&plr[p].InvBody[INVLOC_HAND_RIGHT]); + SetPlrHandItem(&plr[p].InvBody[INVLOC_HAND_RIGHT], IDI_WARRSHLD); + GetPlrHandSeed(&plr[p].InvBody[INVLOC_HAND_RIGHT]); - // TODO: Add debug logic from 1.00 here + // TODO: Add debug logic from 1.00 here - SetPlrHandItem(&plr[p].HoldItem, IDI_WARRCLUB); - GetPlrHandSeed(&plr[p].HoldItem); - AutoPlace(p, 0, 1, 3, 1); + SetPlrHandItem(&plr[p].HoldItem, IDI_WARRCLUB); + GetPlrHandSeed(&plr[p].HoldItem); + AutoPlace(p, 0, 1, 3, 1); - SetPlrHandItem(&plr[p].SpdList[0], IDI_HEAL); - GetPlrHandSeed(&plr[p].SpdList[0]); + SetPlrHandItem(&plr[p].SpdList[0], IDI_HEAL); + GetPlrHandSeed(&plr[p].SpdList[0]); - SetPlrHandItem(&plr[p].SpdList[1], IDI_HEAL); - GetPlrHandSeed(&plr[p].SpdList[1]); - break; - case PC_ROGUE: - SetPlrHandItem(&plr[p].InvBody[INVLOC_HAND_LEFT], IDI_ROGUE); - GetPlrHandSeed(&plr[p].InvBody[INVLOC_HAND_LEFT]); + SetPlrHandItem(&plr[p].SpdList[1], IDI_HEAL); + GetPlrHandSeed(&plr[p].SpdList[1]); + break; + case PC_ROGUE: + SetPlrHandItem(&plr[p].InvBody[INVLOC_HAND_LEFT], IDI_ROGUE); + GetPlrHandSeed(&plr[p].InvBody[INVLOC_HAND_LEFT]); - SetPlrHandItem(&plr[p].SpdList[0], IDI_HEAL); - GetPlrHandSeed(&plr[p].SpdList[0]); + SetPlrHandItem(&plr[p].SpdList[0], IDI_HEAL); + GetPlrHandSeed(&plr[p].SpdList[0]); - SetPlrHandItem(&plr[p].SpdList[1], IDI_HEAL); - GetPlrHandSeed(&plr[p].SpdList[1]); - break; - case PC_SORCERER: - SetPlrHandItem(&plr[p].InvBody[INVLOC_HAND_LEFT], IDI_SORCEROR); - GetPlrHandSeed(&plr[p].InvBody[INVLOC_HAND_LEFT]); + SetPlrHandItem(&plr[p].SpdList[1], IDI_HEAL); + GetPlrHandSeed(&plr[p].SpdList[1]); + break; + case PC_SORCERER: + SetPlrHandItem(&plr[p].InvBody[INVLOC_HAND_LEFT], IDI_SORCEROR); + GetPlrHandSeed(&plr[p].InvBody[INVLOC_HAND_LEFT]); - SetPlrHandItem(&plr[p].SpdList[0], IDI_MANA); - GetPlrHandSeed(&plr[p].SpdList[0]); + SetPlrHandItem(&plr[p].SpdList[0], IDI_MANA); + GetPlrHandSeed(&plr[p].SpdList[0]); - SetPlrHandItem(&plr[p].SpdList[1], IDI_MANA); - GetPlrHandSeed(&plr[p].SpdList[1]); - break; - } + SetPlrHandItem(&plr[p].SpdList[1], IDI_MANA); + GetPlrHandSeed(&plr[p].SpdList[1]); + break; + } - SetPlrHandItem(&plr[p].HoldItem, IDI_GOLD); - GetPlrHandSeed(&plr[p].HoldItem); + SetPlrHandItem(&plr[p].HoldItem, IDI_GOLD); + GetPlrHandSeed(&plr[p].HoldItem); - // TODO: Add debug logic from 1.00 here + // TODO: Add debug logic from 1.00 here - plr[p].HoldItem._iCurs = CURSOR_RECHARGE; - plr[p].HoldItem._ivalue = 100; - plr[p]._pGold = 100; + plr[p].HoldItem._iCurs = CURSOR_RECHARGE; + plr[p].HoldItem._ivalue = 100; + plr[p]._pGold = 100; - plr[p].InvList[plr[p]._pNumInv++] = plr[p].HoldItem; - plr[p].InvGrid[30] = plr[p]._pNumInv; + plr[p].InvList[plr[p]._pNumInv++] = plr[p].HoldItem; + plr[p].InvGrid[30] = plr[p]._pNumInv; - CalcPlrItemVals(p, FALSE); + CalcPlrItemVals(p, FALSE); } BOOL __fastcall ItemSpaceOk(int i, int j) { - int v2; // eax - int v3; // esi - char v4; // cl - int v5; // ecx - char v6; // cl - bool v7; // sf - char v8; // cl - char v9; // al + int v2; // eax + int v3; // esi + char v4; // cl + int v5; // ecx + char v6; // cl + bool v7; // sf + char v8; // cl + char v9; // al - if (i < 0) - return 0; - if (i >= 112) - return 0; - if (j < 0) - return 0; - if (j >= 112) - return 0; - v2 = i; - v3 = 112 * i + j; - if (dMonster[0][v3] || dPlayer[v2][j] || dItem[v2][j]) - return 0; - v4 = dObject[v2][j]; - if (v4) { - v5 = v4 <= 0 ? -1 - v4 : v4 - 1; - if (object[v5]._oSolidFlag) - return 0; - } - v6 = dObject[v2 + 1][j + 1]; - v7 = v6 < 0; - if (v6 > 0) { - if (object[v6 - 1]._oSelFlag) /* check */ - return 0; - v7 = v6 < 0; - } - if (!v7 || !object[-(v6 + 1)]._oSelFlag) { - v8 = dObject[v2 + 1][j]; - if (v8 <= 0) - return nSolidTable[dPiece[0][v3]] == 0; - v9 = dObject[v2][j + 1]; - if (v9 <= 0 || !object[v8 - 1]._oSelFlag || !object[v9 - 1]._oSelFlag) - return nSolidTable[dPiece[0][v3]] == 0; - } - return 0; + if (i < 0) + return 0; + if (i >= 112) + return 0; + if (j < 0) + return 0; + if (j >= 112) + return 0; + v2 = i; + v3 = 112 * i + j; + if (dMonster[0][v3] || dPlayer[v2][j] || dItem[v2][j]) + return 0; + v4 = dObject[v2][j]; + if (v4) { + v5 = v4 <= 0 ? -1 - v4 : v4 - 1; + if (object[v5]._oSolidFlag) + return 0; + } + v6 = dObject[v2 + 1][j + 1]; + v7 = v6 < 0; + if (v6 > 0) { + if (object[v6 - 1]._oSelFlag) /* check */ + return 0; + v7 = v6 < 0; + } + if (!v7 || !object[-(v6 + 1)]._oSelFlag) { + v8 = dObject[v2 + 1][j]; + if (v8 <= 0) + return nSolidTable[dPiece[0][v3]] == 0; + v9 = dObject[v2][j + 1]; + if (v9 <= 0 || !object[v8 - 1]._oSelFlag || !object[v9 - 1]._oSelFlag) + return nSolidTable[dPiece[0][v3]] == 0; + } + return 0; } bool __fastcall GetItemSpace(int x, int y, char inum) { - int v3; // eax - int v4; // edx - BOOL *v5; // edi - int v6; // ebx - BOOL *v7; // esi - signed int v9; // esi - BOOL *v10; // eax - int v11; // ecx - int v12; // eax - int v14; // ecx - int v15; // edx - int v16; // eax - int v17; // esi - int v18; // ecx - int v19; // [esp+8h] [ebp-Ch] - int v20; // [esp+Ch] [ebp-8h] - BOOL *v21; // [esp+10h] [ebp-4h] + int v3; // eax + int v4; // edx + BOOL *v5; // edi + int v6; // ebx + BOOL *v7; // esi + signed int v9; // esi + BOOL *v10; // eax + int v11; // ecx + int v12; // eax + int v14; // ecx + int v15; // edx + int v16; // eax + int v17; // esi + int v18; // ecx + int v19; // [esp+8h] [ebp-Ch] + int v20; // [esp+Ch] [ebp-8h] + BOOL *v21; // [esp+10h] [ebp-4h] - v3 = y; - v19 = y; - v4 = y - 1; - v20 = x; - v5 = itemhold[0]; - if (v4 <= v19 + 1) { - v21 = itemhold[0]; - do { - v6 = x - 1; - if ((unsigned char)(__OFSUB__(x - 1, x + 1) ^ 1) | (x - 1 == x + 1)) { - v7 = v21; - do { - *v7 = ItemSpaceOk(v6, v4); - v7 += 3; - ++v6; - } while (v6 <= v20 + 1); - v3 = v19; - x = v20; - } - ++v21; - ++v4; - } while (v4 <= v3 + 1); - } - v9 = 0; - do { - v10 = v5; - v11 = 3; - do { - if (*v10) - v9 = 1; - v10 += 3; - --v11; - } while (v11); - ++v5; - } while (v5 < itemhold[1]); - v12 = random(13, 15) + 1; - if (!v9) - return 0; - v14 = 0; - v15 = 0; - if (v12 > 0) { - while (1) { - if (itemhold[v14][v15]) - --v12; - if (v12 <= 0) - break; - if (++v14 == 3) { - v14 = 0; - if (++v15 == 3) - v15 = 0; - } - } - } - v16 = v14 + v20 - 1; - v17 = v15 + v19 - 1; - v18 = inum; - item[v18]._ix = v16; - dItem[v16][v17] = inum + 1; - item[v18]._iy = v17; - return 1; + v3 = y; + v19 = y; + v4 = y - 1; + v20 = x; + v5 = itemhold[0]; + if (v4 <= v19 + 1) { + v21 = itemhold[0]; + do { + v6 = x - 1; + if ((unsigned char)(__OFSUB__(x - 1, x + 1) ^ 1) | (x - 1 == x + 1)) { + v7 = v21; + do { + *v7 = ItemSpaceOk(v6, v4); + v7 += 3; + ++v6; + } while (v6 <= v20 + 1); + v3 = v19; + x = v20; + } + ++v21; + ++v4; + } while (v4 <= v3 + 1); + } + v9 = 0; + do { + v10 = v5; + v11 = 3; + do { + if (*v10) + v9 = 1; + v10 += 3; + --v11; + } while (v11); + ++v5; + } while (v5 < itemhold[1]); + v12 = random(13, 15) + 1; + if (!v9) + return 0; + v14 = 0; + v15 = 0; + if (v12 > 0) { + while (1) { + if (itemhold[v14][v15]) + --v12; + if (v12 <= 0) + break; + if (++v14 == 3) { + v14 = 0; + if (++v15 == 3) + v15 = 0; + } + } + } + v16 = v14 + v20 - 1; + v17 = v15 + v19 - 1; + v18 = inum; + item[v18]._ix = v16; + dItem[v16][v17] = inum + 1; + item[v18]._iy = v17; + return 1; } void __fastcall GetSuperItemSpace(int x, int y, char inum) { - signed int v4; // edi - signed int v5; // ebx - int v6; // edx - int v7; // esi - int v9; // eax - int v10; // [esp+Ch] [ebp-10h] - int v11; // [esp+10h] [ebp-Ch] - signed int v12; // [esp+14h] [ebp-8h] - signed int v13; // [esp+18h] [ebp-4h] + signed int v4; // edi + signed int v5; // ebx + int v6; // edx + int v7; // esi + int v9; // eax + int v10; // [esp+Ch] [ebp-10h] + int v11; // [esp+10h] [ebp-Ch] + signed int v12; // [esp+14h] [ebp-8h] + signed int v13; // [esp+18h] [ebp-4h] - v11 = y; - v10 = x; - if (!GetItemSpace(x, y, inum)) { - v13 = 2; - v4 = -2; - do { - v5 = v4; - if (v4 <= v13) { - while (2) { - v12 = v4; - v6 = v5 + v11; - v7 = v4 + v10; - do { - if (ItemSpaceOk(v7, v6)) { - v9 = inum; - item[v9]._ix = v7; - item[v9]._iy = v6; - dItem[v7][v6] = inum + 1; - return; - } - ++v12; - ++v7; - } while (v12 <= v13); - if (++v5 <= v13) - continue; - break; - } - } - ++v13; - --v4; - } while (v4 > -50); - } + v11 = y; + v10 = x; + if (!GetItemSpace(x, y, inum)) { + v13 = 2; + v4 = -2; + do { + v5 = v4; + if (v4 <= v13) { + while (2) { + v12 = v4; + v6 = v5 + v11; + v7 = v4 + v10; + do { + if (ItemSpaceOk(v7, v6)) { + v9 = inum; + item[v9]._ix = v7; + item[v9]._iy = v6; + dItem[v7][v6] = inum + 1; + return; + } + ++v12; + ++v7; + } while (v12 <= v13); + if (++v5 <= v13) + continue; + break; + } + } + ++v13; + --v4; + } while (v4 > -50); + } } void __fastcall GetSuperItemLoc(int x, int y, int *xx, int *yy) { - signed int v4; // edi - signed int v5; // ebx - int v6; // esi - int v8; // [esp+Ch] [ebp-10h] - int v9; // [esp+10h] [ebp-Ch] - signed int v10; // [esp+14h] [ebp-8h] - signed int v11; // [esp+18h] [ebp-4h] + signed int v4; // edi + signed int v5; // ebx + int v6; // esi + int v8; // [esp+Ch] [ebp-10h] + int v9; // [esp+10h] [ebp-Ch] + signed int v10; // [esp+14h] [ebp-8h] + signed int v11; // [esp+18h] [ebp-4h] - v9 = y; - v8 = x; - v11 = 1; - v4 = -1; - while (1) { - v5 = v4; - if (v4 <= v11) - break; - LABEL_7: - ++v11; - if (--v4 <= -50) - return; - } + v9 = y; + v8 = x; + v11 = 1; + v4 = -1; + while (1) { + v5 = v4; + if (v4 <= v11) + break; + LABEL_7: + ++v11; + if (--v4 <= -50) + return; + } LABEL_3: - v10 = v4; - *yy = v5 + v9; - v6 = v4 + v8; - while (1) { - *xx = v6; - if (ItemSpaceOk(v6, *yy)) - break; - ++v10; - ++v6; - if (v10 > v11) { - if (++v5 <= v11) - goto LABEL_3; - goto LABEL_7; - } - } + v10 = v4; + *yy = v5 + v9; + v6 = v4 + v8; + while (1) { + *xx = v6; + if (ItemSpaceOk(v6, *yy)) + break; + ++v10; + ++v6; + if (v10 > v11) { + if (++v5 <= v11) + goto LABEL_3; + goto LABEL_7; + } + } } void __fastcall CalcItemValue(int i) { - int v1; // ecx - int v2; // esi - bool v3; // sf - int v4; // esi + int v1; // ecx + int v2; // esi + bool v3; // sf + int v4; // esi - v1 = i; - v2 = item[v1]._iVMult1 + item[v1]._iVMult2; - v3 = v2 < 0; - if (v2 > 0) { - v2 *= item[v1]._ivalue; - v3 = v2 < 0; - } - if (v3) - v2 = item[v1]._ivalue / v2; - v4 = item[v1]._iVAdd1 + item[v1]._iVAdd2 + v2; - if (v4 <= 0) - v4 = 1; - item[v1]._iIvalue = v4; + v1 = i; + v2 = item[v1]._iVMult1 + item[v1]._iVMult2; + v3 = v2 < 0; + if (v2 > 0) { + v2 *= item[v1]._ivalue; + v3 = v2 < 0; + } + if (v3) + v2 = item[v1]._ivalue / v2; + v4 = item[v1]._iVAdd1 + item[v1]._iVAdd2 + v2; + if (v4 <= 0) + v4 = 1; + item[v1]._iIvalue = v4; } void __fastcall GetBookSpell(int i, int lvl) { - int v2; // edi - int v3; // esi - int v4; // eax - int v5; // edx - signed int v6; // ecx - int v7; // esi - const char **v8; // ebx - int v9; // eax - char v10; // al - int v11; // [esp+8h] [ebp-4h] + int v2; // edi + int v3; // esi + int v4; // eax + int v5; // edx + signed int v6; // ecx + int v7; // esi + const char **v8; // ebx + int v9; // eax + char v10; // al + int v11; // [esp+8h] [ebp-4h] - v2 = lvl; - v3 = i; - if (!lvl) - v2 = lvl + 1; - v4 = random(14, MAX_SPELLS) + 1; + v2 = lvl; + v3 = i; + if (!lvl) + v2 = lvl + 1; + v4 = random(14, MAX_SPELLS) + 1; LABEL_13: - v6 = 1; - while (v4 > 0) { - v5 = spelldata[v6].sBookLvl; - if (v5 != -1 && v2 >= v5) { - --v4; - v11 = v6; - } - ++v6; - if (gbMaxPlayers == 1) { - if (v6 == SPL_RESURRECT) - v6 = SPL_TELEKINESIS; - if (v6 == SPL_HEALOTHER) - v6 = SPL_FLARE; - } - if (v6 == MAX_SPELLS) - goto LABEL_13; - } - v7 = v3; - v8 = (const char **)&spelldata[v11].sNameText; - strcat(item[v7]._iName, *v8); - strcat(item[v7]._iIName, *v8); - item[v7]._iSpell = v11; - item[v7]._iMinMag = spelldata[v11].sMinInt; - v9 = spelldata[v11].sBookCost; - item[v7]._ivalue += v9; - item[v7]._iIvalue += v9; - v10 = spelldata[v11].sType; - if (v10 == STYPE_FIRE) - item[v7]._iCurs = ICURS_BOOK_RED; - if (v10 == STYPE_LIGHTNING) - item[v7]._iCurs = ICURS_BOOK_BLUE; - if (v10 == STYPE_MAGIC) - item[v7]._iCurs = ICURS_BOOK_GREY; + v6 = 1; + while (v4 > 0) { + v5 = spelldata[v6].sBookLvl; + if (v5 != -1 && v2 >= v5) { + --v4; + v11 = v6; + } + ++v6; + if (gbMaxPlayers == 1) { + if (v6 == SPL_RESURRECT) + v6 = SPL_TELEKINESIS; + if (v6 == SPL_HEALOTHER) + v6 = SPL_FLARE; + } + if (v6 == MAX_SPELLS) + goto LABEL_13; + } + v7 = v3; + v8 = (const char **)&spelldata[v11].sNameText; + strcat(item[v7]._iName, *v8); + strcat(item[v7]._iIName, *v8); + item[v7]._iSpell = v11; + item[v7]._iMinMag = spelldata[v11].sMinInt; + v9 = spelldata[v11].sBookCost; + item[v7]._ivalue += v9; + item[v7]._iIvalue += v9; + v10 = spelldata[v11].sType; + if (v10 == STYPE_FIRE) + item[v7]._iCurs = ICURS_BOOK_RED; + if (v10 == STYPE_LIGHTNING) + item[v7]._iCurs = ICURS_BOOK_BLUE; + if (v10 == STYPE_MAGIC) + item[v7]._iCurs = ICURS_BOOK_GREY; } // 679660: using guessed type char gbMaxPlayers; void __fastcall GetStaffPower(int i, int lvl, int bs, unsigned char onlygood) { - int v4; // esi - int v5; // ebx - int v6; // edx - int v7; // ecx - int v9; // edi - int v10; // ecx - int v11; // ST14_4 - int v12; // esi - char *v13; // edi - int l[256]; // [esp+Ch] [ebp-484h] - char istr[128]; // [esp+40Ch] [ebp-84h] - int ia; // [esp+48Ch] [ebp-4h] - char *v17; // [esp+49Ch] [ebp+Ch] + int v4; // esi + int v5; // ebx + int v6; // edx + int v7; // ecx + int v9; // edi + int v10; // ecx + int v11; // ST14_4 + int v12; // esi + char *v13; // edi + int l[256]; // [esp+Ch] [ebp-484h] + char istr[128]; // [esp+40Ch] [ebp-84h] + int ia; // [esp+48Ch] [ebp-4h] + char *v17; // [esp+49Ch] [ebp+Ch] - v4 = lvl; - ia = i; - v5 = -1; - if (!random(15, 10) || onlygood) { - v6 = 0; - v7 = 0; - if (PL_Prefix[0].PLPower != -1) { - do { - if (PL_Prefix[v7].PLIType & 0x100 && PL_Prefix[v7].PLMinLvl <= v4 && (!onlygood || PL_Prefix[v7].PLOk)) { - l[v6++] = v7; - if (PL_Prefix[v7].PLDouble) - l[v6++] = v7; - } - ++v7; - } while (PL_Prefix[v7].PLPower != -1); - if (v6) { - v5 = l[random(16, v6)]; - v9 = ia; - v17 = item[ia]._iIName; - sprintf(istr, "%s %s", PL_Prefix[v5].PLName, item[ia]._iIName); - strcpy(v17, istr); - v10 = ia; - v11 = PL_Prefix[v5].PLMultVal; - item[v9]._iMagical = ITEM_QUALITY_MAGIC; - SaveItemPower( - v10, - PL_Prefix[v5].PLPower, - PL_Prefix[v5].PLParam1, - PL_Prefix[v5].PLParam2, - PL_Prefix[v5].PLMinVal, - PL_Prefix[v5].PLMaxVal, - v11); - item[v9]._iPrePower = PL_Prefix[v5].PLPower; - } - } - } - v12 = ia; - v13 = item[ia]._iIName; - if (!control_WriteStringToBuffer(item[ia]._iIName)) { - strcpy(v13, AllItemsList[item[v12].IDidx].iSName); - if (v5 != -1) { - sprintf(istr, "%s %s", PL_Prefix[v5].PLName, v13); - strcpy(v13, istr); - } - sprintf(istr, "%s of %s", v13, spelldata[bs].sNameText); - strcpy(v13, istr); - if (item[v12]._iMagical == ITEM_QUALITY_NORMAL) - strcpy(item[v12]._iName, v13); - } - CalcItemValue(ia); + v4 = lvl; + ia = i; + v5 = -1; + if (!random(15, 10) || onlygood) { + v6 = 0; + v7 = 0; + if (PL_Prefix[0].PLPower != -1) { + do { + if (PL_Prefix[v7].PLIType & 0x100 && PL_Prefix[v7].PLMinLvl <= v4 && (!onlygood || PL_Prefix[v7].PLOk)) { + l[v6++] = v7; + if (PL_Prefix[v7].PLDouble) + l[v6++] = v7; + } + ++v7; + } while (PL_Prefix[v7].PLPower != -1); + if (v6) { + v5 = l[random(16, v6)]; + v9 = ia; + v17 = item[ia]._iIName; + sprintf(istr, "%s %s", PL_Prefix[v5].PLName, item[ia]._iIName); + strcpy(v17, istr); + v10 = ia; + v11 = PL_Prefix[v5].PLMultVal; + item[v9]._iMagical = ITEM_QUALITY_MAGIC; + SaveItemPower( + v10, + PL_Prefix[v5].PLPower, + PL_Prefix[v5].PLParam1, + PL_Prefix[v5].PLParam2, + PL_Prefix[v5].PLMinVal, + PL_Prefix[v5].PLMaxVal, + v11); + item[v9]._iPrePower = PL_Prefix[v5].PLPower; + } + } + } + v12 = ia; + v13 = item[ia]._iIName; + if (!control_WriteStringToBuffer(item[ia]._iIName)) { + strcpy(v13, AllItemsList[item[v12].IDidx].iSName); + if (v5 != -1) { + sprintf(istr, "%s %s", PL_Prefix[v5].PLName, v13); + strcpy(v13, istr); + } + sprintf(istr, "%s of %s", v13, spelldata[bs].sNameText); + strcpy(v13, istr); + if (item[v12]._iMagical == ITEM_QUALITY_NORMAL) + strcpy(item[v12]._iName, v13); + } + CalcItemValue(ia); } // 420514: using guessed type int var_484[256]; void __fastcall GetStaffSpell(int i, int lvl, unsigned char onlygood) { - int l; // esi - int rv; // eax - int s; // ecx - int minc; // ebx - int maxc; // edx - int v; // eax - char istr[64]; // [esp+4h] [ebp-4Ch] - int bs; // [esp+4Ch] [ebp-4h] + int l; // esi + int rv; // eax + int s; // ecx + int minc; // ebx + int maxc; // edx + int v; // eax + char istr[64]; // [esp+4h] [ebp-4Ch] + int bs; // [esp+4Ch] [ebp-4h] - if (random(17, 4)) { - l = lvl >> 1; - if (!l) - l = 1; - rv = random(18, MAX_SPELLS) + 1; - LABEL_15: - s = 1; - while (rv > 0) { - if (spelldata[s].sStaffLvl != -1 && l >= spelldata[s].sStaffLvl) { - --rv; - bs = s; - } - ++s; - if (gbMaxPlayers == 1) { - if (s == SPL_RESURRECT) - s = SPL_TELEKINESIS; - if (s == SPL_HEALOTHER) - s = SPL_FLARE; - } - if (s == MAX_SPELLS) - goto LABEL_15; - } - sprintf(istr, "%s of %s", item[i]._iName, spelldata[bs].sNameText); - if (!control_WriteStringToBuffer(istr)) - sprintf(istr, "Staff of %s", spelldata[bs].sNameText); - strcpy(item[i]._iName, istr); - strcpy(item[i]._iIName, istr); - minc = spelldata[bs].sStaffMin; - maxc = spelldata[bs].sStaffMax - minc + 1; - item[i]._iSpell = bs; - v = random(19, maxc) + minc; - item[i]._iMinMag = spelldata[bs].sMinInt; - item[i]._iCharges = v; - item[i]._iMaxCharges = v; - v = (v * spelldata[bs].sStaffCost) / 5; - item[i]._ivalue += v; - item[i]._iIvalue += v; - GetStaffPower(i, lvl, bs, onlygood); - } else { - GetItemPower(i, lvl >> 1, lvl, 256, onlygood); - } + if (random(17, 4)) { + l = lvl >> 1; + if (!l) + l = 1; + rv = random(18, MAX_SPELLS) + 1; + LABEL_15: + s = 1; + while (rv > 0) { + if (spelldata[s].sStaffLvl != -1 && l >= spelldata[s].sStaffLvl) { + --rv; + bs = s; + } + ++s; + if (gbMaxPlayers == 1) { + if (s == SPL_RESURRECT) + s = SPL_TELEKINESIS; + if (s == SPL_HEALOTHER) + s = SPL_FLARE; + } + if (s == MAX_SPELLS) + goto LABEL_15; + } + sprintf(istr, "%s of %s", item[i]._iName, spelldata[bs].sNameText); + if (!control_WriteStringToBuffer(istr)) + sprintf(istr, "Staff of %s", spelldata[bs].sNameText); + strcpy(item[i]._iName, istr); + strcpy(item[i]._iIName, istr); + minc = spelldata[bs].sStaffMin; + maxc = spelldata[bs].sStaffMax - minc + 1; + item[i]._iSpell = bs; + v = random(19, maxc) + minc; + item[i]._iMinMag = spelldata[bs].sMinInt; + item[i]._iCharges = v; + item[i]._iMaxCharges = v; + v = (v * spelldata[bs].sStaffCost) / 5; + item[i]._ivalue += v; + item[i]._iIvalue += v; + GetStaffPower(i, lvl, bs, onlygood); + } else { + GetItemPower(i, lvl >> 1, lvl, 256, onlygood); + } } // 679660: using guessed type char gbMaxPlayers; void __fastcall GetItemAttrs(int i, int idata, int lvl) { - int rndv; // eax + int rndv; // eax - item[i]._itype = AllItemsList[idata].itype; - item[i]._iCurs = AllItemsList[idata].iCurs; - strcpy(item[i]._iName, AllItemsList[idata].iName); - strcpy(item[i]._iIName, AllItemsList[idata].iName); - item[i]._iLoc = AllItemsList[idata].iLoc; - item[i]._iClass = AllItemsList[idata].iClass; - item[i]._iMinDam = AllItemsList[idata].iMinDam; - item[i]._iMaxDam = AllItemsList[idata].iMaxDam; - item[i]._iMiscId = AllItemsList[idata].iMiscId; - item[i]._iAC = AllItemsList[idata].iMinAC + random(20, AllItemsList[idata].iMaxAC - AllItemsList[idata].iMinAC + 1); - item[i]._iFlags = AllItemsList[idata].iFlags; - item[i]._iSpell = AllItemsList[idata].iSpell; - item[i]._ivalue = AllItemsList[idata].iValue; - item[i]._iIvalue = AllItemsList[idata].iValue; - item[i]._iMagical = ITEM_QUALITY_NORMAL; - item[i]._iDurability = AllItemsList[idata].iDurability; - item[i]._iMaxDur = AllItemsList[idata].iDurability; - item[i]._iVAdd1 = 0; - item[i]._iMinStr = AllItemsList[idata].iMinStr; - item[i]._iMinMag = AllItemsList[idata].iMinMag; - item[i]._iMinDex = AllItemsList[idata].iMinDex; - item[i]._iVMult1 = 0; - item[i]._iVAdd2 = 0; - item[i]._iVMult2 = 0; - item[i]._iPLDam = 0; - item[i]._iPLToHit = 0; - item[i]._iPLAC = 0; - item[i]._iPLStr = 0; - item[i]._iPLMag = 0; - item[i]._iPLDex = 0; - item[i]._iPLVit = 0; - item[i]._iCharges = 0; - item[i]._iMaxCharges = 0; - item[i]._iPLFR = 0; - item[i]._iPLLR = 0; - item[i]._iPLMR = 0; - item[i].IDidx = idata; - item[i]._iPLDamMod = 0; - item[i]._iPLGetHit = 0; - item[i]._iPLLight = 0; - item[i]._iSplLvlAdd = 0; - item[i]._iPrePower = -1; - item[i]._iSufPower = -1; - item[i]._iRequest = FALSE; - item[i]._iFMinDam = 0; - item[i]._iFMaxDam = 0; - item[i]._iLMinDam = 0; - item[i]._iLMaxDam = 0; - item[i]._iPLEnAc = 0; - item[i]._iPLMana = 0; - item[i]._iPLHP = 0; + item[i]._itype = AllItemsList[idata].itype; + item[i]._iCurs = AllItemsList[idata].iCurs; + strcpy(item[i]._iName, AllItemsList[idata].iName); + strcpy(item[i]._iIName, AllItemsList[idata].iName); + item[i]._iLoc = AllItemsList[idata].iLoc; + item[i]._iClass = AllItemsList[idata].iClass; + item[i]._iMinDam = AllItemsList[idata].iMinDam; + item[i]._iMaxDam = AllItemsList[idata].iMaxDam; + item[i]._iMiscId = AllItemsList[idata].iMiscId; + item[i]._iAC = AllItemsList[idata].iMinAC + random(20, AllItemsList[idata].iMaxAC - AllItemsList[idata].iMinAC + 1); + item[i]._iFlags = AllItemsList[idata].iFlags; + item[i]._iSpell = AllItemsList[idata].iSpell; + item[i]._ivalue = AllItemsList[idata].iValue; + item[i]._iIvalue = AllItemsList[idata].iValue; + item[i]._iMagical = ITEM_QUALITY_NORMAL; + item[i]._iDurability = AllItemsList[idata].iDurability; + item[i]._iMaxDur = AllItemsList[idata].iDurability; + item[i]._iVAdd1 = 0; + item[i]._iMinStr = AllItemsList[idata].iMinStr; + item[i]._iMinMag = AllItemsList[idata].iMinMag; + item[i]._iMinDex = AllItemsList[idata].iMinDex; + item[i]._iVMult1 = 0; + item[i]._iVAdd2 = 0; + item[i]._iVMult2 = 0; + item[i]._iPLDam = 0; + item[i]._iPLToHit = 0; + item[i]._iPLAC = 0; + item[i]._iPLStr = 0; + item[i]._iPLMag = 0; + item[i]._iPLDex = 0; + item[i]._iPLVit = 0; + item[i]._iCharges = 0; + item[i]._iMaxCharges = 0; + item[i]._iPLFR = 0; + item[i]._iPLLR = 0; + item[i]._iPLMR = 0; + item[i].IDidx = idata; + item[i]._iPLDamMod = 0; + item[i]._iPLGetHit = 0; + item[i]._iPLLight = 0; + item[i]._iSplLvlAdd = 0; + item[i]._iPrePower = -1; + item[i]._iSufPower = -1; + item[i]._iRequest = FALSE; + item[i]._iFMinDam = 0; + item[i]._iFMaxDam = 0; + item[i]._iLMinDam = 0; + item[i]._iLMaxDam = 0; + item[i]._iPLEnAc = 0; + item[i]._iPLMana = 0; + item[i]._iPLHP = 0; - if (AllItemsList[idata].iMiscId == IMISC_BOOK) - GetBookSpell(i, lvl); + if (AllItemsList[idata].iMiscId == IMISC_BOOK) + GetBookSpell(i, lvl); - if (item[i]._itype == ITYPE_GOLD) { - if (gnDifficulty) /* clean this up, NORMAL */ - rndv = lvl; - else - rndv = 5 * currlevel + random(21, 10 * currlevel); + if (item[i]._itype == ITYPE_GOLD) { + if (gnDifficulty) /* clean this up, NORMAL */ + rndv = lvl; + else + rndv = 5 * currlevel + random(21, 10 * currlevel); - if (gnDifficulty == DIFF_NIGHTMARE) - rndv = 5 * (currlevel + 16) + random(21, 10 * (currlevel + 16)); - if (gnDifficulty == DIFF_HELL) - rndv = 5 * (currlevel + 32) + random(21, 10 * (currlevel + 32)); + if (gnDifficulty == DIFF_NIGHTMARE) + rndv = 5 * (currlevel + 16) + random(21, 10 * (currlevel + 16)); + if (gnDifficulty == DIFF_HELL) + rndv = 5 * (currlevel + 32) + random(21, 10 * (currlevel + 32)); - if (leveltype == DTYPE_HELL) - rndv += rndv >> 3; - if (rndv > 5000) - rndv = 5000; + if (leveltype == DTYPE_HELL) + rndv += rndv >> 3; + if (rndv > 5000) + rndv = 5000; - item[i]._ivalue = rndv; + item[i]._ivalue = rndv; - if (rndv < 2500) - item[i]._iCurs = (rndv > 1000) + 4; - else - item[i]._iCurs = ICURS_GOLD_LARGE; - } + if (rndv < 2500) + item[i]._iCurs = (rndv > 1000) + 4; + else + item[i]._iCurs = ICURS_GOLD_LARGE; + } } // 5BB1ED: using guessed type char leveltype; int __fastcall RndPL(int param1, int param2) { - return param1 + random(22, param2 - param1 + 1); + return param1 + random(22, param2 - param1 + 1); } int __fastcall PLVal(int pv, int p1, int p2, int minv, int maxv) { - if (p1 == p2) - return minv; - if (minv == maxv) - return minv; - return minv + (maxv - minv) * (100 * (pv - p1) / (p2 - p1)) / 100; + if (p1 == p2) + return minv; + if (minv == maxv) + return minv; + return minv + (maxv - minv) * (100 * (pv - p1) / (p2 - p1)) / 100; } void __fastcall SaveItemPower(int i, int power, int param1, int param2, int minval, int maxval, int multval) { - int v7; // edi - int v8; // esi - int v9; // eax - int v10; // ebx - int *v11; // eax - int *v12; // eax - int v13; // edi - int v14; // eax - int v15; // edi - int v16; // eax - int v17; // eax - int v18; // ecx - int v19; // edx - int v20; // edi - int *v21; // edx - int v22; // eax - int v23; // eax - int v24; // eax - int v25; // eax - int v26; // eax - int v27; // eax - int v28; // ecx - int *v29; // eax - int v30; // ecx - int *v31; // eax - int v32; // ecx - int v33; // eax - int v34; // ST18_4 - int v35; // eax - int v36; // ecx - int v37; // edx - signed int v38; // ecx - int v39; // eax - int v40; // eax - int v41; // ecx - int *v42; // eax - int v43; // esi + int v7; // edi + int v8; // esi + int v9; // eax + int v10; // ebx + int *v11; // eax + int *v12; // eax + int v13; // edi + int v14; // eax + int v15; // edi + int v16; // eax + int v17; // eax + int v18; // ecx + int v19; // edx + int v20; // edi + int *v21; // edx + int v22; // eax + int v23; // eax + int v24; // eax + int v25; // eax + int v26; // eax + int v27; // eax + int v28; // ecx + int *v29; // eax + int v30; // ecx + int *v31; // eax + int v32; // ecx + int v33; // eax + int v34; // ST18_4 + int v35; // eax + int v36; // ecx + int v37; // edx + signed int v38; // ecx + int v39; // eax + int v40; // eax + int v41; // ecx + int *v42; // eax + int v43; // esi - v7 = power; - v8 = i; - v9 = RndPL(param1, param2); - v10 = v9; - switch (v7) { - case IPL_TOHIT: - v11 = &item[v8]._iPLToHit; - goto LABEL_115; - case IPL_TOHIT_CURSE: - v12 = &item[v8]._iPLToHit; - goto LABEL_62; - case IPL_DAMP: - v11 = &item[v8]._iPLDam; - goto LABEL_115; - case IPL_DAMP_CURSE: - v12 = &item[v8]._iPLDam; - goto LABEL_62; - case IPL_TOHIT_DAMP: - v10 = RndPL(param1, param2); - v13 = v8; - item[v13]._iPLDam += v10; - if (param1 == 20) - v14 = RndPL(1, 5); - else - v14 = param1; - if (param1 == 36) - v14 = RndPL(6, 10); - if (param1 == 51) - v14 = RndPL(11, 15); - if (param1 == 66) - v14 = RndPL(16, 20); - if (param1 == 81) - v14 = RndPL(21, 30); - if (param1 == 96) - v14 = RndPL(31, 40); - if (param1 == 111) - v14 = RndPL(41, 50); - if (param1 == 126) - v14 = RndPL(51, 75); - if (param1 == 151) - v14 = RndPL(76, 100); - item[v13]._iPLToHit += v14; - break; - case IPL_TOHIT_DAMP_CURSE: - v15 = v8; - item[v15]._iPLDam -= v9; - if (param1 == 25) - v16 = RndPL(1, 5); - else - v16 = param1; - if (param1 == 50) - v16 = RndPL(6, 10); - item[v15]._iPLToHit -= v16; - break; - case IPL_ACP: - v11 = &item[v8]._iPLAC; - goto LABEL_115; - case IPL_ACP_CURSE: - v12 = &item[v8]._iPLAC; - goto LABEL_62; - case IPL_FIRERES: - v11 = &item[v8]._iPLFR; - goto LABEL_115; - case IPL_LIGHTRES: - v11 = &item[v8]._iPLLR; - goto LABEL_115; - case IPL_MAGICRES: - v11 = &item[v8]._iPLMR; - goto LABEL_115; - case IPL_ALLRES: - v17 = v8; - item[v17]._iPLFR += v10; - v18 = item[v8]._iPLFR; - item[v17]._iPLLR += v10; - item[v17]._iPLMR += v10; - v19 = item[v8]._iPLLR; - v20 = item[v8]._iPLMR; - if (v18 < 0) - item[v17]._iPLFR = 0; - if (v19 < 0) - item[v17]._iPLLR = 0; - if (v20 < 0) - item[v17]._iPLMR = 0; - break; - case IPL_SPLLVLADD: - item[v8]._iSplLvlAdd = v9; - break; - case IPL_CHARGES: - v21 = &item[v8]._iCharges; - v22 = param1 * *v21; - *v21 = v22; - item[v8]._iMaxCharges = v22; - break; - case IPL_FIREDAM: - v24 = v8; - item[v24]._iFlags |= 0x10u; - goto LABEL_77; - case IPL_LIGHTDAM: - v25 = v8; - item[v25]._iFlags |= 0x20u; - goto LABEL_79; - case IPL_STR: - v11 = &item[v8]._iPLStr; - goto LABEL_115; - case IPL_STR_CURSE: - v12 = &item[v8]._iPLStr; - goto LABEL_62; - case IPL_MAG: - v11 = &item[v8]._iPLMag; - goto LABEL_115; - case IPL_MAG_CURSE: - v12 = &item[v8]._iPLMag; - goto LABEL_62; - case IPL_DEX: - v11 = &item[v8]._iPLDex; - goto LABEL_115; - case IPL_DEX_CURSE: - v12 = &item[v8]._iPLDex; - goto LABEL_62; - case IPL_VIT: - v11 = &item[v8]._iPLVit; - goto LABEL_115; - case IPL_VIT_CURSE: - v12 = &item[v8]._iPLVit; - goto LABEL_62; - case IPL_ATTRIBS: - v26 = v8; - item[v26]._iPLStr += v10; - item[v26]._iPLMag += v10; - item[v26]._iPLDex += v10; - item[v26]._iPLVit += v10; - break; - case IPL_ATTRIBS_CURSE: - v27 = v8; - item[v27]._iPLStr -= v10; - item[v27]._iPLMag -= v10; - item[v27]._iPLDex -= v10; - item[v27]._iPLVit -= v10; - break; - case IPL_GETHIT_CURSE: - v11 = &item[v8]._iPLGetHit; - goto LABEL_115; - case IPL_GETHIT: - v12 = &item[v8]._iPLGetHit; - goto LABEL_62; - case IPL_LIFE: - v28 = v9 << 6; - v29 = &item[v8]._iPLHP; - goto LABEL_73; - case IPL_LIFE_CURSE: - v30 = v9 << 6; - v31 = &item[v8]._iPLHP; - goto LABEL_75; - case IPL_MANA: - item[v8]._iPLMana += v9 << 6; - goto LABEL_92; - case IPL_MANA_CURSE: - item[v8]._iPLMana -= v9 << 6; - goto LABEL_92; - case IPL_DUR: - v32 = v8; - v33 = item[v8]._iMaxDur; - v34 = v33; - v35 = v10 * v33 / 100; - item[v32]._iDurability += v35; - item[v32]._iMaxDur = v35 + v34; - break; - case IPL_DUR_CURSE: - v36 = v8; - v37 = item[v8]._iMaxDur - v9 * item[v8]._iMaxDur / 100; - item[v8]._iMaxDur = v37; - if (v37 < 1) - item[v36]._iMaxDur = 1; - item[v36]._iDurability = item[v36]._iMaxDur; - break; - case IPL_INDESTRUCTIBLE: - v38 = DUR_INDESTRUCTIBLE; - goto LABEL_119; - case IPL_LIGHT: - v28 = param1; - v29 = &item[v8]._iPLLight; - LABEL_73: - *v29 += v28; - break; - case IPL_LIGHT_CURSE: - v30 = param1; - v31 = &item[v8]._iPLLight; - LABEL_75: - *v31 -= v30; - break; - case IPL_FIRE_ARROWS: - v24 = v8; - item[v24]._iFlags |= 8u; - LABEL_77: - item[v24]._iFMinDam = param1; - item[v24]._iFMaxDam = param2; - break; - case IPL_LIGHT_ARROWS: - v25 = v8; - _HIBYTE(item[v8]._iFlags) |= 2u; - LABEL_79: - item[v25]._iLMinDam = param1; - item[v25]._iLMaxDam = param2; - break; - case IPL_INVCURS: - item[v8]._iCurs = param1; - break; - case IPL_THORNS: - _HIBYTE(item[v8]._iFlags) |= 4u; - break; - case IPL_NOMANA: - _HIBYTE(item[v8]._iFlags) |= 8u; - goto LABEL_92; - case IPL_NOHEALPLR: - BYTE1(item[v8]._iFlags) |= 1u; - break; - case IPL_ABSHALFTRAP: - _HIBYTE(item[v8]._iFlags) |= 0x10u; - break; - case IPL_KNOCKBACK: - BYTE1(item[v8]._iFlags) |= 8u; - break; - case IPL_NOHEALMON: - BYTE1(item[v8]._iFlags) |= 0x10u; - break; - case IPL_STEALMANA: - if (param1 == 3) - BYTE1(item[v8]._iFlags) |= 0x20u; - if (param1 == 5) - BYTE1(item[v8]._iFlags) |= 0x40u; - LABEL_92: - drawmanaflag = TRUE; - break; - case IPL_STEALLIFE: - if (param1 == 3) - BYTE1(item[v8]._iFlags) |= 0x80u; - if (param1 == 5) - BYTE2(item[v8]._iFlags) |= 1u; - drawhpflag = TRUE; - break; - case IPL_TARGAC: - v11 = &item[v8]._iPLEnAc; - goto LABEL_115; - case IPL_FASTATTACK: - if (param1 == 1) - BYTE2(item[v8]._iFlags) |= 2u; - if (param1 == 2) - BYTE2(item[v8]._iFlags) |= 4u; - if (param1 == 3) - BYTE2(item[v8]._iFlags) |= 8u; - if (param1 == 4) - BYTE2(item[v8]._iFlags) |= 0x10u; - break; - case IPL_FASTRECOVER: - if (param1 == 1) - BYTE2(item[v8]._iFlags) |= 0x20u; - if (param1 == 2) - BYTE2(item[v8]._iFlags) |= 0x40u; - if (param1 == 3) - BYTE2(item[v8]._iFlags) |= 0x80u; - break; - case IPL_FASTBLOCK: - _HIBYTE(item[v8]._iFlags) |= 1u; - break; - case IPL_DAMMOD: - v11 = &item[v8]._iPLDamMod; - LABEL_115: - *v11 += v10; - break; - case IPL_RNDARROWVEL: - item[v8]._iFlags |= 4u; - break; - case IPL_SETDAM: - v39 = v8; - item[v39]._iMinDam = param1; - item[v39]._iMaxDam = param2; - break; - case IPL_SETDUR: - v38 = param1; - LABEL_119: - v40 = v8; - item[v40]._iDurability = v38; - item[v40]._iMaxDur = v38; - break; - case IPL_NOMINSTR: - item[v8]._iMinStr = 0; - break; - case IPL_SPELL: - v23 = v8; - item[v23]._iSpell = param1; - item[v23]._iCharges = param1; - item[v23]._iMaxCharges = param2; - break; - case IPL_FASTSWING: - BYTE2(item[v8]._iFlags) |= 8u; - break; - case IPL_ONEHAND: - item[v8]._iLoc = ILOC_ONEHAND; - break; - case IPL_3XDAMVDEM: - _HIBYTE(item[v8]._iFlags) |= 0x40u; - break; - case IPL_ALLRESZERO: - _HIBYTE(item[v8]._iFlags) |= 0x80u; - break; - case IPL_DRAINLIFE: - item[v8]._iFlags |= 0x40u; - break; - case IPL_RNDSTEALLIFE: - item[v8]._iFlags |= 2u; - break; - case IPL_INFRAVISION: - item[v8]._iFlags |= 1u; - break; - case IPL_SETAC: - item[v8]._iAC = v9; - break; - case IPL_ADDACLIFE: - item[v8]._iPLHP = (plr[myplr]._pIBonusAC + plr[myplr]._pIAC + plr[myplr]._pDexterity / 5) << 6; - break; - case IPL_ADDMANAAC: - item[v8]._iAC += (plr[myplr]._pMaxManaBase >> 6) / 10; - break; - case IPL_FIRERESCLVL: - v41 = 30 - plr[myplr]._pLevel; - v42 = &item[v8]._iPLFR; - *v42 = v41; - if (v41 < 0) - *v42 = 0; - break; - case IPL_AC_CURSE: - v12 = &item[v8]._iAC; - LABEL_62: - *v12 -= v10; - break; - default: - break; - } - v43 = v8; - if (item[v43]._iVAdd1 || item[v43]._iVMult1) { - item[v43]._iVAdd2 = PLVal(v10, param1, param2, minval, maxval); - item[v43]._iVMult2 = multval; - } else { - item[v43]._iVAdd1 = PLVal(v10, param1, param2, minval, maxval); - item[v43]._iVMult1 = multval; - } + v7 = power; + v8 = i; + v9 = RndPL(param1, param2); + v10 = v9; + switch (v7) { + case IPL_TOHIT: + v11 = &item[v8]._iPLToHit; + goto LABEL_115; + case IPL_TOHIT_CURSE: + v12 = &item[v8]._iPLToHit; + goto LABEL_62; + case IPL_DAMP: + v11 = &item[v8]._iPLDam; + goto LABEL_115; + case IPL_DAMP_CURSE: + v12 = &item[v8]._iPLDam; + goto LABEL_62; + case IPL_TOHIT_DAMP: + v10 = RndPL(param1, param2); + v13 = v8; + item[v13]._iPLDam += v10; + if (param1 == 20) + v14 = RndPL(1, 5); + else + v14 = param1; + if (param1 == 36) + v14 = RndPL(6, 10); + if (param1 == 51) + v14 = RndPL(11, 15); + if (param1 == 66) + v14 = RndPL(16, 20); + if (param1 == 81) + v14 = RndPL(21, 30); + if (param1 == 96) + v14 = RndPL(31, 40); + if (param1 == 111) + v14 = RndPL(41, 50); + if (param1 == 126) + v14 = RndPL(51, 75); + if (param1 == 151) + v14 = RndPL(76, 100); + item[v13]._iPLToHit += v14; + break; + case IPL_TOHIT_DAMP_CURSE: + v15 = v8; + item[v15]._iPLDam -= v9; + if (param1 == 25) + v16 = RndPL(1, 5); + else + v16 = param1; + if (param1 == 50) + v16 = RndPL(6, 10); + item[v15]._iPLToHit -= v16; + break; + case IPL_ACP: + v11 = &item[v8]._iPLAC; + goto LABEL_115; + case IPL_ACP_CURSE: + v12 = &item[v8]._iPLAC; + goto LABEL_62; + case IPL_FIRERES: + v11 = &item[v8]._iPLFR; + goto LABEL_115; + case IPL_LIGHTRES: + v11 = &item[v8]._iPLLR; + goto LABEL_115; + case IPL_MAGICRES: + v11 = &item[v8]._iPLMR; + goto LABEL_115; + case IPL_ALLRES: + v17 = v8; + item[v17]._iPLFR += v10; + v18 = item[v8]._iPLFR; + item[v17]._iPLLR += v10; + item[v17]._iPLMR += v10; + v19 = item[v8]._iPLLR; + v20 = item[v8]._iPLMR; + if (v18 < 0) + item[v17]._iPLFR = 0; + if (v19 < 0) + item[v17]._iPLLR = 0; + if (v20 < 0) + item[v17]._iPLMR = 0; + break; + case IPL_SPLLVLADD: + item[v8]._iSplLvlAdd = v9; + break; + case IPL_CHARGES: + v21 = &item[v8]._iCharges; + v22 = param1 * *v21; + *v21 = v22; + item[v8]._iMaxCharges = v22; + break; + case IPL_FIREDAM: + v24 = v8; + item[v24]._iFlags |= 0x10u; + goto LABEL_77; + case IPL_LIGHTDAM: + v25 = v8; + item[v25]._iFlags |= 0x20u; + goto LABEL_79; + case IPL_STR: + v11 = &item[v8]._iPLStr; + goto LABEL_115; + case IPL_STR_CURSE: + v12 = &item[v8]._iPLStr; + goto LABEL_62; + case IPL_MAG: + v11 = &item[v8]._iPLMag; + goto LABEL_115; + case IPL_MAG_CURSE: + v12 = &item[v8]._iPLMag; + goto LABEL_62; + case IPL_DEX: + v11 = &item[v8]._iPLDex; + goto LABEL_115; + case IPL_DEX_CURSE: + v12 = &item[v8]._iPLDex; + goto LABEL_62; + case IPL_VIT: + v11 = &item[v8]._iPLVit; + goto LABEL_115; + case IPL_VIT_CURSE: + v12 = &item[v8]._iPLVit; + goto LABEL_62; + case IPL_ATTRIBS: + v26 = v8; + item[v26]._iPLStr += v10; + item[v26]._iPLMag += v10; + item[v26]._iPLDex += v10; + item[v26]._iPLVit += v10; + break; + case IPL_ATTRIBS_CURSE: + v27 = v8; + item[v27]._iPLStr -= v10; + item[v27]._iPLMag -= v10; + item[v27]._iPLDex -= v10; + item[v27]._iPLVit -= v10; + break; + case IPL_GETHIT_CURSE: + v11 = &item[v8]._iPLGetHit; + goto LABEL_115; + case IPL_GETHIT: + v12 = &item[v8]._iPLGetHit; + goto LABEL_62; + case IPL_LIFE: + v28 = v9 << 6; + v29 = &item[v8]._iPLHP; + goto LABEL_73; + case IPL_LIFE_CURSE: + v30 = v9 << 6; + v31 = &item[v8]._iPLHP; + goto LABEL_75; + case IPL_MANA: + item[v8]._iPLMana += v9 << 6; + goto LABEL_92; + case IPL_MANA_CURSE: + item[v8]._iPLMana -= v9 << 6; + goto LABEL_92; + case IPL_DUR: + v32 = v8; + v33 = item[v8]._iMaxDur; + v34 = v33; + v35 = v10 * v33 / 100; + item[v32]._iDurability += v35; + item[v32]._iMaxDur = v35 + v34; + break; + case IPL_DUR_CURSE: + v36 = v8; + v37 = item[v8]._iMaxDur - v9 * item[v8]._iMaxDur / 100; + item[v8]._iMaxDur = v37; + if (v37 < 1) + item[v36]._iMaxDur = 1; + item[v36]._iDurability = item[v36]._iMaxDur; + break; + case IPL_INDESTRUCTIBLE: + v38 = DUR_INDESTRUCTIBLE; + goto LABEL_119; + case IPL_LIGHT: + v28 = param1; + v29 = &item[v8]._iPLLight; + LABEL_73: + *v29 += v28; + break; + case IPL_LIGHT_CURSE: + v30 = param1; + v31 = &item[v8]._iPLLight; + LABEL_75: + *v31 -= v30; + break; + case IPL_FIRE_ARROWS: + v24 = v8; + item[v24]._iFlags |= 8u; + LABEL_77: + item[v24]._iFMinDam = param1; + item[v24]._iFMaxDam = param2; + break; + case IPL_LIGHT_ARROWS: + v25 = v8; + _HIBYTE(item[v8]._iFlags) |= 2u; + LABEL_79: + item[v25]._iLMinDam = param1; + item[v25]._iLMaxDam = param2; + break; + case IPL_INVCURS: + item[v8]._iCurs = param1; + break; + case IPL_THORNS: + _HIBYTE(item[v8]._iFlags) |= 4u; + break; + case IPL_NOMANA: + _HIBYTE(item[v8]._iFlags) |= 8u; + goto LABEL_92; + case IPL_NOHEALPLR: + BYTE1(item[v8]._iFlags) |= 1u; + break; + case IPL_ABSHALFTRAP: + _HIBYTE(item[v8]._iFlags) |= 0x10u; + break; + case IPL_KNOCKBACK: + BYTE1(item[v8]._iFlags) |= 8u; + break; + case IPL_NOHEALMON: + BYTE1(item[v8]._iFlags) |= 0x10u; + break; + case IPL_STEALMANA: + if (param1 == 3) + BYTE1(item[v8]._iFlags) |= 0x20u; + if (param1 == 5) + BYTE1(item[v8]._iFlags) |= 0x40u; + LABEL_92: + drawmanaflag = TRUE; + break; + case IPL_STEALLIFE: + if (param1 == 3) + BYTE1(item[v8]._iFlags) |= 0x80u; + if (param1 == 5) + BYTE2(item[v8]._iFlags) |= 1u; + drawhpflag = TRUE; + break; + case IPL_TARGAC: + v11 = &item[v8]._iPLEnAc; + goto LABEL_115; + case IPL_FASTATTACK: + if (param1 == 1) + BYTE2(item[v8]._iFlags) |= 2u; + if (param1 == 2) + BYTE2(item[v8]._iFlags) |= 4u; + if (param1 == 3) + BYTE2(item[v8]._iFlags) |= 8u; + if (param1 == 4) + BYTE2(item[v8]._iFlags) |= 0x10u; + break; + case IPL_FASTRECOVER: + if (param1 == 1) + BYTE2(item[v8]._iFlags) |= 0x20u; + if (param1 == 2) + BYTE2(item[v8]._iFlags) |= 0x40u; + if (param1 == 3) + BYTE2(item[v8]._iFlags) |= 0x80u; + break; + case IPL_FASTBLOCK: + _HIBYTE(item[v8]._iFlags) |= 1u; + break; + case IPL_DAMMOD: + v11 = &item[v8]._iPLDamMod; + LABEL_115: + *v11 += v10; + break; + case IPL_RNDARROWVEL: + item[v8]._iFlags |= 4u; + break; + case IPL_SETDAM: + v39 = v8; + item[v39]._iMinDam = param1; + item[v39]._iMaxDam = param2; + break; + case IPL_SETDUR: + v38 = param1; + LABEL_119: + v40 = v8; + item[v40]._iDurability = v38; + item[v40]._iMaxDur = v38; + break; + case IPL_NOMINSTR: + item[v8]._iMinStr = 0; + break; + case IPL_SPELL: + v23 = v8; + item[v23]._iSpell = param1; + item[v23]._iCharges = param1; + item[v23]._iMaxCharges = param2; + break; + case IPL_FASTSWING: + BYTE2(item[v8]._iFlags) |= 8u; + break; + case IPL_ONEHAND: + item[v8]._iLoc = ILOC_ONEHAND; + break; + case IPL_3XDAMVDEM: + _HIBYTE(item[v8]._iFlags) |= 0x40u; + break; + case IPL_ALLRESZERO: + _HIBYTE(item[v8]._iFlags) |= 0x80u; + break; + case IPL_DRAINLIFE: + item[v8]._iFlags |= 0x40u; + break; + case IPL_RNDSTEALLIFE: + item[v8]._iFlags |= 2u; + break; + case IPL_INFRAVISION: + item[v8]._iFlags |= 1u; + break; + case IPL_SETAC: + item[v8]._iAC = v9; + break; + case IPL_ADDACLIFE: + item[v8]._iPLHP = (plr[myplr]._pIBonusAC + plr[myplr]._pIAC + plr[myplr]._pDexterity / 5) << 6; + break; + case IPL_ADDMANAAC: + item[v8]._iAC += (plr[myplr]._pMaxManaBase >> 6) / 10; + break; + case IPL_FIRERESCLVL: + v41 = 30 - plr[myplr]._pLevel; + v42 = &item[v8]._iPLFR; + *v42 = v41; + if (v41 < 0) + *v42 = 0; + break; + case IPL_AC_CURSE: + v12 = &item[v8]._iAC; + LABEL_62: + *v12 -= v10; + break; + default: + break; + } + v43 = v8; + if (item[v43]._iVAdd1 || item[v43]._iVMult1) { + item[v43]._iVAdd2 = PLVal(v10, param1, param2, minval, maxval); + item[v43]._iVMult2 = multval; + } else { + item[v43]._iVAdd1 = PLVal(v10, param1, param2, minval, maxval); + item[v43]._iVMult1 = multval; + } } void __fastcall GetItemPower(int i, int minlvl, int maxlvl, int flgs, int onlygood) { - //int v6; // ecx - int pre; // esi - //int v9; // ecx - unsigned char goe; // bl - int v11; // edx - int v14; // ecx - int l[256]; // [esp+4h] [ebp-494h] - char istr[128]; // [esp+404h] [ebp-94h] - int post; // [esp+488h] [ebp-10h] - int sufidx; // [esp+48Ch] [ebp-Ch] - int preidx; // [esp+490h] [ebp-8h] + //int v6; // ecx + int pre; // esi + //int v9; // ecx + unsigned char goe; // bl + int v11; // edx + int v14; // ecx + int l[256]; // [esp+4h] [ebp-494h] + char istr[128]; // [esp+404h] [ebp-94h] + int post; // [esp+488h] [ebp-10h] + int sufidx; // [esp+48Ch] [ebp-Ch] + int preidx; // [esp+490h] [ebp-8h] - pre = random(23, 4); - post = random(23, 3); - if (pre && !post) { - if (random(23, 2)) - post = 1; - else - pre = 0; - } - preidx = -1; - sufidx = -1; - goe = 0; - if (!onlygood) { - if (random(0, 3)) - onlygood = 1; - } - if (!pre) { - v11 = 0; - if (PL_Prefix[0].PLPower != -1) { - v14 = 0; - do { - if (flgs & PL_Prefix[v14].PLIType) { - if (PL_Prefix[v14].PLMinLvl >= minlvl && PL_Prefix[v14].PLMinLvl <= maxlvl && (!onlygood || PL_Prefix[v14].PLOk) && (flgs != 256 || PL_Prefix[v14].PLPower != 15)) { - l[v11++] = v14; - if (PL_Prefix[v14].PLDouble) - l[v11++] = v14; - } - } - v14++; - } while (PL_Prefix[v14].PLPower != -1); - if (v11) { - preidx = l[random(23, v11)]; - sprintf(istr, "%s %s", PL_Prefix[preidx].PLName, item[i]._iIName); - strcpy(item[i]._iIName, istr); - item[i]._iMagical = ITEM_QUALITY_MAGIC; - SaveItemPower( - i, - PL_Prefix[preidx].PLPower, - PL_Prefix[preidx].PLParam1, - PL_Prefix[preidx].PLParam2, - PL_Prefix[preidx].PLMinVal, - PL_Prefix[preidx].PLMaxVal, - PL_Prefix[preidx].PLMultVal); - goe = PL_Prefix[preidx].PLGOE; - item[i]._iPrePower = PL_Prefix[preidx].PLPower; - } - } - } - if (post) { - v11 = 0; - if (PL_Suffix[0].PLPower != -1) { - v14 = 0; - do { - if (flgs & PL_Suffix[v14].PLIType) { - if (PL_Suffix[v14].PLMinLvl >= minlvl && PL_Suffix[v14].PLMinLvl <= maxlvl && (goe | PL_Suffix[v14].PLGOE) != 0x11 && (!onlygood || PL_Suffix[v14].PLOk)) - l[v11++] = v14; - } - v14++; - } while (PL_Suffix[v14].PLPower != -1); - if (v11) { - sufidx = l[random(23, v11)]; - sprintf(istr, "%s of %s", item[i]._iIName, PL_Suffix[sufidx].PLName); - strcpy(item[i]._iIName, istr); - item[i]._iMagical = ITEM_QUALITY_MAGIC; - SaveItemPower( - i, - PL_Suffix[sufidx].PLPower, - PL_Suffix[sufidx].PLParam1, - PL_Suffix[sufidx].PLParam2, - PL_Suffix[sufidx].PLMinVal, - PL_Suffix[sufidx].PLMaxVal, - PL_Suffix[sufidx].PLMultVal); - item[i]._iSufPower = PL_Suffix[sufidx].PLPower; - } - } - } - if (!control_WriteStringToBuffer(item[i]._iIName)) { - strcpy(item[i]._iIName, AllItemsList[item[i].IDidx].iSName); - if (preidx != -1) { - sprintf(istr, "%s %s", PL_Prefix[preidx].PLName, item[i]._iIName); - strcpy(item[i]._iIName, istr); - } - if (sufidx != -1) { - sprintf(istr, "%s of %s", item[i]._iIName, PL_Suffix[sufidx].PLName); - strcpy(item[i]._iIName, istr); - } - } - if (preidx != -1 || sufidx != -1) - CalcItemValue(i); + pre = random(23, 4); + post = random(23, 3); + if (pre && !post) { + if (random(23, 2)) + post = 1; + else + pre = 0; + } + preidx = -1; + sufidx = -1; + goe = 0; + if (!onlygood) { + if (random(0, 3)) + onlygood = 1; + } + if (!pre) { + v11 = 0; + if (PL_Prefix[0].PLPower != -1) { + v14 = 0; + do { + if (flgs & PL_Prefix[v14].PLIType) { + if (PL_Prefix[v14].PLMinLvl >= minlvl && PL_Prefix[v14].PLMinLvl <= maxlvl && (!onlygood || PL_Prefix[v14].PLOk) && (flgs != 256 || PL_Prefix[v14].PLPower != 15)) { + l[v11++] = v14; + if (PL_Prefix[v14].PLDouble) + l[v11++] = v14; + } + } + v14++; + } while (PL_Prefix[v14].PLPower != -1); + if (v11) { + preidx = l[random(23, v11)]; + sprintf(istr, "%s %s", PL_Prefix[preidx].PLName, item[i]._iIName); + strcpy(item[i]._iIName, istr); + item[i]._iMagical = ITEM_QUALITY_MAGIC; + SaveItemPower( + i, + PL_Prefix[preidx].PLPower, + PL_Prefix[preidx].PLParam1, + PL_Prefix[preidx].PLParam2, + PL_Prefix[preidx].PLMinVal, + PL_Prefix[preidx].PLMaxVal, + PL_Prefix[preidx].PLMultVal); + goe = PL_Prefix[preidx].PLGOE; + item[i]._iPrePower = PL_Prefix[preidx].PLPower; + } + } + } + if (post) { + v11 = 0; + if (PL_Suffix[0].PLPower != -1) { + v14 = 0; + do { + if (flgs & PL_Suffix[v14].PLIType) { + if (PL_Suffix[v14].PLMinLvl >= minlvl && PL_Suffix[v14].PLMinLvl <= maxlvl && (goe | PL_Suffix[v14].PLGOE) != 0x11 && (!onlygood || PL_Suffix[v14].PLOk)) + l[v11++] = v14; + } + v14++; + } while (PL_Suffix[v14].PLPower != -1); + if (v11) { + sufidx = l[random(23, v11)]; + sprintf(istr, "%s of %s", item[i]._iIName, PL_Suffix[sufidx].PLName); + strcpy(item[i]._iIName, istr); + item[i]._iMagical = ITEM_QUALITY_MAGIC; + SaveItemPower( + i, + PL_Suffix[sufidx].PLPower, + PL_Suffix[sufidx].PLParam1, + PL_Suffix[sufidx].PLParam2, + PL_Suffix[sufidx].PLMinVal, + PL_Suffix[sufidx].PLMaxVal, + PL_Suffix[sufidx].PLMultVal); + item[i]._iSufPower = PL_Suffix[sufidx].PLPower; + } + } + } + if (!control_WriteStringToBuffer(item[i]._iIName)) { + strcpy(item[i]._iIName, AllItemsList[item[i].IDidx].iSName); + if (preidx != -1) { + sprintf(istr, "%s %s", PL_Prefix[preidx].PLName, item[i]._iIName); + strcpy(item[i]._iIName, istr); + } + if (sufidx != -1) { + sprintf(istr, "%s of %s", item[i]._iIName, PL_Suffix[sufidx].PLName); + strcpy(item[i]._iIName, istr); + } + } + if (preidx != -1 || sufidx != -1) + CalcItemValue(i); } // 4215EF: using guessed type int var_494[256]; void __fastcall GetItemBonus(int i, int idata, int minlvl, int maxlvl, int onlygood) { - if (item[i]._iClass != ICLASS_GOLD) { - if (minlvl > 25) - minlvl = 25; + if (item[i]._iClass != ICLASS_GOLD) { + if (minlvl > 25) + minlvl = 25; - switch (item[i]._itype) { - case ITYPE_SWORD: - case ITYPE_AXE: - case ITYPE_MACE: - GetItemPower(i, minlvl, maxlvl, 0x1000, onlygood); - break; - case ITYPE_BOW: - GetItemPower(i, minlvl, maxlvl, 0x10, onlygood); - break; - case ITYPE_SHIELD: - GetItemPower(i, minlvl, maxlvl, 0x10000, onlygood); - break; - case ITYPE_LARMOR: - case ITYPE_HELM: - case ITYPE_MARMOR: - case ITYPE_HARMOR: - GetItemPower(i, minlvl, maxlvl, 0x100000, onlygood); - break; - case ITYPE_STAFF: - GetStaffSpell(i, maxlvl, onlygood); - break; - case ITYPE_RING: - case ITYPE_AMULET: - GetItemPower(i, minlvl, maxlvl, 1, onlygood); - break; - default: - return; - } - } + switch (item[i]._itype) { + case ITYPE_SWORD: + case ITYPE_AXE: + case ITYPE_MACE: + GetItemPower(i, minlvl, maxlvl, 0x1000, onlygood); + break; + case ITYPE_BOW: + GetItemPower(i, minlvl, maxlvl, 0x10, onlygood); + break; + case ITYPE_SHIELD: + GetItemPower(i, minlvl, maxlvl, 0x10000, onlygood); + break; + case ITYPE_LARMOR: + case ITYPE_HELM: + case ITYPE_MARMOR: + case ITYPE_HARMOR: + GetItemPower(i, minlvl, maxlvl, 0x100000, onlygood); + break; + case ITYPE_STAFF: + GetStaffSpell(i, maxlvl, onlygood); + break; + case ITYPE_RING: + case ITYPE_AMULET: + GetItemPower(i, minlvl, maxlvl, 1, onlygood); + break; + default: + return; + } + } } void __fastcall SetupItem(int i) { - int it; // eax - int il; // eax + int it; // eax + int il; // eax - it = ItemCAnimTbl[item[i]._iCurs]; - item[i]._iAnimWidth = 96; - item[i]._iAnimWidth2 = 16; - il = ItemAnimLs[it]; - item[i]._iAnimData = Item2Frm[it]; - item[i]._iAnimLen = il; - item[i]._iIdentified = FALSE; - item[i]._iPostDraw = 0; + it = ItemCAnimTbl[item[i]._iCurs]; + item[i]._iAnimWidth = 96; + item[i]._iAnimWidth2 = 16; + il = ItemAnimLs[it]; + item[i]._iAnimData = Item2Frm[it]; + item[i]._iAnimLen = il; + item[i]._iIdentified = FALSE; + item[i]._iPostDraw = 0; - if (!plr[myplr].pLvlLoad) { - item[i]._iSelFlag = 0; - il = 1; - item[i]._iAnimFlag = 1; - } else { - item[i]._iAnimFlag = 0; - item[i]._iSelFlag = 1; - } + if (!plr[myplr].pLvlLoad) { + item[i]._iSelFlag = 0; + il = 1; + item[i]._iAnimFlag = 1; + } else { + item[i]._iAnimFlag = 0; + item[i]._iSelFlag = 1; + } - item[i]._iAnimFrame = il; + item[i]._iAnimFrame = il; } int __fastcall RndItem(int m) { - int ri; // esi - int i; // edx - int ril[512]; // [esp+4h] [ebp-800h] + int ri; // esi + int i; // edx + int ril[512]; // [esp+4h] [ebp-800h] - if ((monster[m].MData->mTreasure & 0x8000) != 0) - return -1 - (monster[m].MData->mTreasure & 0xFFF); - if (monster[m].MData->mTreasure & 0x4000) - return 0; + if ((monster[m].MData->mTreasure & 0x8000) != 0) + return -1 - (monster[m].MData->mTreasure & 0xFFF); + if (monster[m].MData->mTreasure & 0x4000) + return 0; - if (random(24, 100) > 40) - return 0; - if (random(24, 100) > 25) - return 1; + if (random(24, 100) > 40) + return 0; + if (random(24, 100) > 25) + return 1; - ri = 0; - i = 0; - if (AllItemsList[0].iLoc != -1) { - do { - if (AllItemsList[i].iRnd == 2 && monster[m].mLevel >= AllItemsList[i].iMinMLvl) - ril[ri++] = i; - if (AllItemsList[i].iRnd && monster[m].mLevel >= AllItemsList[i].iMinMLvl) - ril[ri++] = i; - if (AllItemsList[i].iSpell == SPL_RESURRECT && gbMaxPlayers == 1) - --ri; - if (AllItemsList[i].iSpell == SPL_HEALOTHER && gbMaxPlayers == 1) - --ri; - ++i; - } while (AllItemsList[i].iLoc != -1); - } + ri = 0; + i = 0; + if (AllItemsList[0].iLoc != -1) { + do { + if (AllItemsList[i].iRnd == 2 && monster[m].mLevel >= AllItemsList[i].iMinMLvl) + ril[ri++] = i; + if (AllItemsList[i].iRnd && monster[m].mLevel >= AllItemsList[i].iMinMLvl) + ril[ri++] = i; + if (AllItemsList[i].iSpell == SPL_RESURRECT && gbMaxPlayers == 1) + --ri; + if (AllItemsList[i].iSpell == SPL_HEALOTHER && gbMaxPlayers == 1) + --ri; + ++i; + } while (AllItemsList[i].iLoc != -1); + } - return ril[random(24, ri)] + 1; + return ril[random(24, ri)] + 1; } // 679660: using guessed type char gbMaxPlayers; // 421A4B: using guessed type int var_800[512]; int __fastcall RndUItem(int m) { - int ri; // edx - int i; // ebp - bool okflag; // edi - int ril[512]; // [esp+0h] [ebp-800h] + int ri; // edx + int i; // ebp + bool okflag; // edi + int ril[512]; // [esp+0h] [ebp-800h] - if (m != -1) { - if ((monster[m].MData->mTreasure & 0x8000) != 0 && gbMaxPlayers == 1) - return -1 - (monster[m].MData->mTreasure & 0xFFF); - } - ri = 0; - i = 0; - if (AllItemsList[0].iLoc != -1) { - do { - okflag = 1; - if (!AllItemsList[i].iRnd) - okflag = 0; - if (m == -1) { - if (2 * currlevel - AllItemsList[i].iMinMLvl < 0) - okflag = 0; - } else { - if (monster[m].mLevel - AllItemsList[i].iMinMLvl < 0) - okflag = 0; - } - if (!AllItemsList[i].itype) - okflag = 0; - if (AllItemsList[i].itype == ITYPE_GOLD) - okflag = 0; - if (AllItemsList[i].itype == ITYPE_0E) - okflag = 0; - if (AllItemsList[i].iMiscId == IMISC_BOOK) - okflag = 1; - if (AllItemsList[i].iSpell == SPL_RESURRECT && gbMaxPlayers == 1) - okflag = 0; - if (AllItemsList[i].iSpell == SPL_HEALOTHER && gbMaxPlayers == 1) - okflag = 0; - if (okflag) - ril[ri++] = i; - ++i; - } while (AllItemsList[i].iLoc != -1); - } + if (m != -1) { + if ((monster[m].MData->mTreasure & 0x8000) != 0 && gbMaxPlayers == 1) + return -1 - (monster[m].MData->mTreasure & 0xFFF); + } + ri = 0; + i = 0; + if (AllItemsList[0].iLoc != -1) { + do { + okflag = 1; + if (!AllItemsList[i].iRnd) + okflag = 0; + if (m == -1) { + if (2 * currlevel - AllItemsList[i].iMinMLvl < 0) + okflag = 0; + } else { + if (monster[m].mLevel - AllItemsList[i].iMinMLvl < 0) + okflag = 0; + } + if (!AllItemsList[i].itype) + okflag = 0; + if (AllItemsList[i].itype == ITYPE_GOLD) + okflag = 0; + if (AllItemsList[i].itype == ITYPE_0E) + okflag = 0; + if (AllItemsList[i].iMiscId == IMISC_BOOK) + okflag = 1; + if (AllItemsList[i].iSpell == SPL_RESURRECT && gbMaxPlayers == 1) + okflag = 0; + if (AllItemsList[i].iSpell == SPL_HEALOTHER && gbMaxPlayers == 1) + okflag = 0; + if (okflag) + ril[ri++] = i; + ++i; + } while (AllItemsList[i].iLoc != -1); + } - return ril[random(25, ri)]; + return ril[random(25, ri)]; } // 679660: using guessed type char gbMaxPlayers; // 421B32: using guessed type int var_800[512]; int __cdecl RndAllItems() { - int ri; // esi - int i; // edi - int ril[512]; // [esp+0h] [ebp-800h] + int ri; // esi + int i; // edi + int ril[512]; // [esp+0h] [ebp-800h] - if (random(26, 100) > 25) - return 0; + if (random(26, 100) > 25) + return 0; - ri = 0; - i = 0; - if (AllItemsList[0].iLoc != -1) { - do { - if (AllItemsList[i].iRnd && 2 * currlevel >= AllItemsList[i].iMinMLvl) - ril[ri++] = i; - if (AllItemsList[i].iSpell == SPL_RESURRECT && gbMaxPlayers == 1) - --ri; - if (AllItemsList[i].iSpell == SPL_HEALOTHER && gbMaxPlayers == 1) - --ri; - ++i; - } while (AllItemsList[i].iLoc != -1); - } - return ril[random(26, ri)]; + ri = 0; + i = 0; + if (AllItemsList[0].iLoc != -1) { + do { + if (AllItemsList[i].iRnd && 2 * currlevel >= AllItemsList[i].iMinMLvl) + ril[ri++] = i; + if (AllItemsList[i].iSpell == SPL_RESURRECT && gbMaxPlayers == 1) + --ri; + if (AllItemsList[i].iSpell == SPL_HEALOTHER && gbMaxPlayers == 1) + --ri; + ++i; + } while (AllItemsList[i].iLoc != -1); + } + return ril[random(26, ri)]; } // 679660: using guessed type char gbMaxPlayers; // 421C2A: using guessed type int var_800[512]; int __fastcall RndTypeItems(int itype, int imid) { - int i; // edi - bool okflag; // esi - int ril[512]; // [esp+4h] [ebp-80Ch] - int ri; // [esp+80Ch] [ebp-4h] + int i; // edi + bool okflag; // esi + int ril[512]; // [esp+4h] [ebp-80Ch] + int ri; // [esp+80Ch] [ebp-4h] - ri = 0; - i = 0; + ri = 0; + i = 0; - if (AllItemsList[0].iLoc != -1) { - do { - okflag = 1; - if (!AllItemsList[i].iRnd) - okflag = 0; - if (2 * currlevel < AllItemsList[i].iMinMLvl) - okflag = 0; - if (AllItemsList[i].itype != itype) - okflag = 0; - if (imid != -1 && AllItemsList[i].iMiscId != imid) - okflag = 0; - if (okflag) - ril[ri++] = i; - ++i; - } while (AllItemsList[i].iLoc != -1); - } + if (AllItemsList[0].iLoc != -1) { + do { + okflag = 1; + if (!AllItemsList[i].iRnd) + okflag = 0; + if (2 * currlevel < AllItemsList[i].iMinMLvl) + okflag = 0; + if (AllItemsList[i].itype != itype) + okflag = 0; + if (imid != -1 && AllItemsList[i].iMiscId != imid) + okflag = 0; + if (okflag) + ril[ri++] = i; + ++i; + } while (AllItemsList[i].iLoc != -1); + } - return ril[random(27, ri)]; + return ril[random(27, ri)]; } // 421CB7: using guessed type int var_80C[512]; int __fastcall CheckUnique(int i, int lvl, int uper, bool recreate) { - int numu; // ebx - int j; // esi - int idata; // eax - char uok[128]; // [esp+8h] [ebp-84h] + int numu; // ebx + int j; // esi + int idata; // eax + char uok[128]; // [esp+8h] [ebp-84h] - if (random(28, 100) > uper) - return -1; - numu = 0; - memset(uok, 0, sizeof(uok)); + if (random(28, 100) > uper) + return -1; + numu = 0; + memset(uok, 0, sizeof(uok)); - if (UniqueItemList[0].UIItemId == -1) - return -1; - j = 0; - do { - if (UniqueItemList[j].UIItemId == AllItemsList[item[i].IDidx].iItemId - && lvl >= UniqueItemList[j].UIMinLvl - && (recreate || !UniqueItemFlag[j] || gbMaxPlayers != 1)) { - uok[j] = 1; - ++numu; - } - j++; - } while (UniqueItemList[j].UIItemId != -1); - if (!numu) - return -1; + if (UniqueItemList[0].UIItemId == -1) + return -1; + j = 0; + do { + if (UniqueItemList[j].UIItemId == AllItemsList[item[i].IDidx].iItemId + && lvl >= UniqueItemList[j].UIMinLvl + && (recreate || !UniqueItemFlag[j] || gbMaxPlayers != 1)) { + uok[j] = 1; + ++numu; + } + j++; + } while (UniqueItemList[j].UIItemId != -1); + if (!numu) + return -1; - random(29, 10); - idata = 0; - if (numu > 0) { - while (1) { - if (uok[idata]) - --numu; - if (numu <= 0) - break; - if (++idata == 128) - idata = 0; - } - } - return idata; + random(29, 10); + idata = 0; + if (numu > 0) { + while (1) { + if (uok[idata]) + --numu; + if (numu <= 0) + break; + if (++idata == 128) + idata = 0; + } + } + return idata; } // 679660: using guessed type char gbMaxPlayers; // 421D41: using guessed type char var_84[128]; void __fastcall GetUniqueItem(int i, int uid) { - UniqueItemFlag[uid] = 1; - SaveItemPower(i, UniqueItemList[uid].UIPower1, UniqueItemList[uid].UIParam1, UniqueItemList[uid].UIParam2, 0, 0, 1); + UniqueItemFlag[uid] = 1; + SaveItemPower(i, UniqueItemList[uid].UIPower1, UniqueItemList[uid].UIParam1, UniqueItemList[uid].UIParam2, 0, 0, 1); - if (UniqueItemList[uid].UINumPL > 1) - SaveItemPower(i, UniqueItemList[uid].UIPower2, UniqueItemList[uid].UIParam3, UniqueItemList[uid].UIParam4, 0, 0, 1); - if (UniqueItemList[uid].UINumPL > 2) - SaveItemPower(i, UniqueItemList[uid].UIPower3, UniqueItemList[uid].UIParam5, UniqueItemList[uid].UIParam6, 0, 0, 1); - if (UniqueItemList[uid].UINumPL > 3) - SaveItemPower(i, UniqueItemList[uid].UIPower4, UniqueItemList[uid].UIParam7, UniqueItemList[uid].UIParam8, 0, 0, 1); - if (UniqueItemList[uid].UINumPL > 4) - SaveItemPower(i, UniqueItemList[uid].UIPower5, UniqueItemList[uid].UIParam9, UniqueItemList[uid].UIParam10, 0, 0, 1); - if (UniqueItemList[uid].UINumPL > 5) - SaveItemPower(i, UniqueItemList[uid].UIPower6, UniqueItemList[uid].UIParam11, UniqueItemList[uid].UIParam12, 0, 0, 1); + if (UniqueItemList[uid].UINumPL > 1) + SaveItemPower(i, UniqueItemList[uid].UIPower2, UniqueItemList[uid].UIParam3, UniqueItemList[uid].UIParam4, 0, 0, 1); + if (UniqueItemList[uid].UINumPL > 2) + SaveItemPower(i, UniqueItemList[uid].UIPower3, UniqueItemList[uid].UIParam5, UniqueItemList[uid].UIParam6, 0, 0, 1); + if (UniqueItemList[uid].UINumPL > 3) + SaveItemPower(i, UniqueItemList[uid].UIPower4, UniqueItemList[uid].UIParam7, UniqueItemList[uid].UIParam8, 0, 0, 1); + if (UniqueItemList[uid].UINumPL > 4) + SaveItemPower(i, UniqueItemList[uid].UIPower5, UniqueItemList[uid].UIParam9, UniqueItemList[uid].UIParam10, 0, 0, 1); + if (UniqueItemList[uid].UINumPL > 5) + SaveItemPower(i, UniqueItemList[uid].UIPower6, UniqueItemList[uid].UIParam11, UniqueItemList[uid].UIParam12, 0, 0, 1); - strcpy(item[i]._iIName, UniqueItemList[uid].UIName); - item[i]._iIvalue = UniqueItemList[uid].UIValue; + strcpy(item[i]._iIName, UniqueItemList[uid].UIName); + item[i]._iIvalue = UniqueItemList[uid].UIValue; - if (item[i]._iMiscId == IMISC_UNIQUE) - item[i]._iSeed = uid; + if (item[i]._iMiscId == IMISC_UNIQUE) + item[i]._iSeed = uid; - item[i]._iCreateInfo |= 0x0200; - item[i]._iUid = uid; - item[i]._iMagical = ITEM_QUALITY_UNIQUE; + item[i]._iCreateInfo |= 0x0200; + item[i]._iUid = uid; + item[i]._iMagical = ITEM_QUALITY_UNIQUE; } void __fastcall SpawnUnique(int uid, int x, int y) { - int ii; // esi - int itype; // edx + int ii; // esi + int itype; // edx - if (numitems < MAXITEMS) { - ii = itemavail[0]; - GetSuperItemSpace(x, y, itemavail[0]); - itype = 0; - itemactive[numitems] = ii; - itemavail[0] = itemavail[MAXITEMS - numitems - 1]; + if (numitems < MAXITEMS) { + ii = itemavail[0]; + GetSuperItemSpace(x, y, itemavail[0]); + itype = 0; + itemactive[numitems] = ii; + itemavail[0] = itemavail[MAXITEMS - numitems - 1]; - if (AllItemsList[0].iItemId != UniqueItemList[uid].UIItemId) { - while (AllItemsList[itype].iItemId != UniqueItemList[uid].UIItemId) { - itype++; - } - } + if (AllItemsList[0].iItemId != UniqueItemList[uid].UIItemId) { + while (AllItemsList[itype].iItemId != UniqueItemList[uid].UIItemId) { + itype++; + } + } - GetItemAttrs(ii, itype, currlevel); - GetUniqueItem(ii, uid); - SetupItem(ii); - ++numitems; - } + GetItemAttrs(ii, itype, currlevel); + GetUniqueItem(ii, uid); + SetupItem(ii); + ++numitems; + } } // 421F5C: could not find valid save-restore pair for esi void __fastcall ItemRndDur(int ii) { - if (item[ii]._iDurability && item[ii]._iDurability != DUR_INDESTRUCTIBLE) - item[ii]._iDurability = random(0, item[ii]._iMaxDur >> 1) + (item[ii]._iMaxDur >> 2) + 1; + if (item[ii]._iDurability && item[ii]._iDurability != DUR_INDESTRUCTIBLE) + item[ii]._iDurability = random(0, item[ii]._iMaxDur >> 1) + (item[ii]._iMaxDur >> 2) + 1; } void __fastcall SetupAllItems(int ii, int idx, int iseed, int lvl, int uper, int onlygood, int recreate, int pregen) { - int iblvl; // edi - int uid; // eax + int iblvl; // edi + int uid; // eax - item[ii]._iSeed = iseed; - SetRndSeed(iseed); - GetItemAttrs(ii, idx, lvl >> 1); - item[ii]._iCreateInfo = lvl; + item[ii]._iSeed = iseed; + SetRndSeed(iseed); + GetItemAttrs(ii, idx, lvl >> 1); + item[ii]._iCreateInfo = lvl; - if (pregen) - item[ii]._iCreateInfo = lvl | 0x8000; - if (onlygood) - item[ii]._iCreateInfo |= 0x40; + if (pregen) + item[ii]._iCreateInfo = lvl | 0x8000; + if (onlygood) + item[ii]._iCreateInfo |= 0x40; - if (uper == 15) - item[ii]._iCreateInfo |= 0x80; - else if (uper == 1) - item[ii]._iCreateInfo |= 0x0100; + if (uper == 15) + item[ii]._iCreateInfo |= 0x80; + else if (uper == 1) + item[ii]._iCreateInfo |= 0x0100; - if (item[ii]._iMiscId == IMISC_UNIQUE) { - if (item[ii]._iLoc != ILOC_UNEQUIPABLE) - GetUniqueItem(ii, iseed); - } else { - iblvl = -1; - if (random(32, 100) > 10 && random(33, 100) > lvl || (iblvl = lvl, lvl == -1)) { + if (item[ii]._iMiscId == IMISC_UNIQUE) { + if (item[ii]._iLoc != ILOC_UNEQUIPABLE) + GetUniqueItem(ii, iseed); + } else { + iblvl = -1; + if (random(32, 100) > 10 && random(33, 100) > lvl || (iblvl = lvl, lvl == -1)) { - if (item[ii]._iMiscId != IMISC_STAFF || (iblvl = lvl, lvl == -1)) { - if (item[ii]._iMiscId != IMISC_RING || (iblvl = lvl, lvl == -1)) { - if (item[ii]._iMiscId == IMISC_AMULET) - iblvl = lvl; - } - } - } - if (onlygood) - iblvl = lvl; - if (uper == 15) - iblvl = lvl + 4; - if (iblvl != -1) { - uid = CheckUnique(ii, iblvl, uper, recreate); - if (uid == -1) { - GetItemBonus(ii, idx, iblvl >> 1, iblvl, onlygood); - } else { - GetUniqueItem(ii, uid); - item[ii]._iCreateInfo |= 0x0200; - } - } - if (item[ii]._iMagical != ITEM_QUALITY_UNIQUE) - ItemRndDur(ii); - } - SetupItem(ii); + if (item[ii]._iMiscId != IMISC_STAFF || (iblvl = lvl, lvl == -1)) { + if (item[ii]._iMiscId != IMISC_RING || (iblvl = lvl, lvl == -1)) { + if (item[ii]._iMiscId == IMISC_AMULET) + iblvl = lvl; + } + } + } + if (onlygood) + iblvl = lvl; + if (uper == 15) + iblvl = lvl + 4; + if (iblvl != -1) { + uid = CheckUnique(ii, iblvl, uper, recreate); + if (uid == -1) { + GetItemBonus(ii, idx, iblvl >> 1, iblvl, onlygood); + } else { + GetUniqueItem(ii, uid); + item[ii]._iCreateInfo |= 0x0200; + } + } + if (item[ii]._iMagical != ITEM_QUALITY_UNIQUE) + ItemRndDur(ii); + } + SetupItem(ii); } void __fastcall SpawnItem(int m, int x, int y, BOOL sendmsg) { - int ii; // edi - int onlygood; // [esp+Ch] [ebp-Ch] - int idx; // [esp+14h] [ebp-4h] + int ii; // edi + int onlygood; // [esp+Ch] [ebp-Ch] + int idx; // [esp+14h] [ebp-4h] - if (!monster[m]._uniqtype && ((monster[m].MData->mTreasure & 0x8000) == 0 || gbMaxPlayers == 1)) { - if (quests[QTYPE_BLKM]._qactive == 2 && quests[QTYPE_BLKM]._qvar1 == QS_MUSHGIVEN) { - idx = IDI_BRAIN; - quests[QTYPE_BLKM]._qvar1 = QS_BRAINSPAWNED; - goto LABEL_13; - } - idx = RndItem(m); - if (!idx) - return; - if (idx > 0) { - onlygood = 0; - idx--; - goto LABEL_13; - } - LABEL_10: - SpawnUnique(-1 - idx, x, y); - return; - } - idx = RndUItem(m); - if (idx < 0) - goto LABEL_10; - onlygood = 1; + if (!monster[m]._uniqtype && ((monster[m].MData->mTreasure & 0x8000) == 0 || gbMaxPlayers == 1)) { + if (quests[QTYPE_BLKM]._qactive == 2 && quests[QTYPE_BLKM]._qvar1 == QS_MUSHGIVEN) { + idx = IDI_BRAIN; + quests[QTYPE_BLKM]._qvar1 = QS_BRAINSPAWNED; + goto LABEL_13; + } + idx = RndItem(m); + if (!idx) + return; + if (idx > 0) { + onlygood = 0; + idx--; + goto LABEL_13; + } + LABEL_10: + SpawnUnique(-1 - idx, x, y); + return; + } + idx = RndUItem(m); + if (idx < 0) + goto LABEL_10; + onlygood = 1; LABEL_13: - if (numitems < MAXITEMS) { - ii = itemavail[0]; - GetSuperItemSpace(x, y, itemavail[0]); - itemactive[numitems] = ii; - itemavail[0] = itemavail[MAXITEMS - numitems - 1]; + if (numitems < MAXITEMS) { + ii = itemavail[0]; + GetSuperItemSpace(x, y, itemavail[0]); + itemactive[numitems] = ii; + itemavail[0] = itemavail[MAXITEMS - numitems - 1]; - if (!monster[m]._uniqtype) - SetupAllItems(ii, idx, GetRndSeed(), monster[m].MData->mLevel, 1, onlygood, 0, 0); - else - SetupAllItems(ii, idx, GetRndSeed(), monster[m].MData->mLevel, 15, onlygood, 0, 0); + if (!monster[m]._uniqtype) + SetupAllItems(ii, idx, GetRndSeed(), monster[m].MData->mLevel, 1, onlygood, 0, 0); + else + SetupAllItems(ii, idx, GetRndSeed(), monster[m].MData->mLevel, 15, onlygood, 0, 0); - ++numitems; - if (sendmsg) - NetSendCmdDItem(FALSE, ii); - } + ++numitems; + if (sendmsg) + NetSendCmdDItem(FALSE, ii); + } } // 679660: using guessed type char gbMaxPlayers; void __fastcall CreateItem(int uid, int x, int y) { - int ii; // esi - int idx; // edx + int ii; // esi + int idx; // edx - if (numitems < MAXITEMS) { - ii = itemavail[0]; - GetSuperItemSpace(x, y, itemavail[0]); - idx = 0; - itemactive[numitems] = ii; - itemavail[0] = itemavail[MAXITEMS - numitems - 1]; + if (numitems < MAXITEMS) { + ii = itemavail[0]; + GetSuperItemSpace(x, y, itemavail[0]); + idx = 0; + itemactive[numitems] = ii; + itemavail[0] = itemavail[MAXITEMS - numitems - 1]; - if (AllItemsList[0].iItemId != UniqueItemList[uid].UIItemId) { - while (AllItemsList[idx].iItemId != UniqueItemList[uid].UIItemId) { - idx++; - } - } + if (AllItemsList[0].iItemId != UniqueItemList[uid].UIItemId) { + while (AllItemsList[idx].iItemId != UniqueItemList[uid].UIItemId) { + idx++; + } + } - GetItemAttrs(ii, idx, currlevel); - GetUniqueItem(ii, uid); - SetupItem(ii); - ++numitems; - item[ii]._iMagical = ITEM_QUALITY_UNIQUE; - } + GetItemAttrs(ii, idx, currlevel); + GetUniqueItem(ii, uid); + SetupItem(ii); + ++numitems; + item[ii]._iMagical = ITEM_QUALITY_UNIQUE; + } } // 422290: could not find valid save-restore pair for esi void __fastcall CreateRndItem(int x, int y, unsigned char onlygood, unsigned char sendmsg, int delta) { - int idx; // edi - int ii; // esi + int idx; // edi + int ii; // esi - if (onlygood) - idx = RndUItem(-1); - else - idx = RndAllItems(); + if (onlygood) + idx = RndUItem(-1); + else + idx = RndAllItems(); - if (numitems < MAXITEMS) { - ii = itemavail[0]; - GetSuperItemSpace(x, y, itemavail[0]); - itemactive[numitems] = ii; - itemavail[0] = itemavail[MAXITEMS - numitems - 1]; - SetupAllItems(ii, idx, GetRndSeed(), 2 * currlevel, 1, onlygood, 0, delta); + if (numitems < MAXITEMS) { + ii = itemavail[0]; + GetSuperItemSpace(x, y, itemavail[0]); + itemactive[numitems] = ii; + itemavail[0] = itemavail[MAXITEMS - numitems - 1]; + SetupAllItems(ii, idx, GetRndSeed(), 2 * currlevel, 1, onlygood, 0, delta); - if (sendmsg) - NetSendCmdDItem(FALSE, ii); - if (delta) - DeltaAddItem(ii); + if (sendmsg) + NetSendCmdDItem(FALSE, ii); + if (delta) + DeltaAddItem(ii); - ++numitems; - } + ++numitems; + } } void __fastcall SetupAllUseful(int ii, int iseed, int lvl) { - int idx; // esi + int idx; // esi - item[ii]._iSeed = iseed; - SetRndSeed(iseed); - idx = 25 - (random(34, 2) != 0); + item[ii]._iSeed = iseed; + SetRndSeed(iseed); + idx = 25 - (random(34, 2) != 0); - if (lvl > 1) { - if (!random(34, 3)) - idx = 27; // unique? - } + if (lvl > 1) { + if (!random(34, 3)) + idx = 27; // unique? + } - GetItemAttrs(ii, idx, lvl); - item[ii]._iCreateInfo = lvl + 0x180; - SetupItem(ii); + GetItemAttrs(ii, idx, lvl); + item[ii]._iCreateInfo = lvl + 0x180; + SetupItem(ii); } void __fastcall CreateRndUseful(int pnum, int x, int y, unsigned char sendmsg) { - int ii; // esi + int ii; // esi - if (numitems < MAXITEMS) { - ii = itemavail[0]; - GetSuperItemSpace(x, y, itemavail[0]); - itemactive[numitems] = ii; - itemavail[0] = itemavail[MAXITEMS - numitems - 1]; - SetupAllUseful(ii, GetRndSeed(), currlevel); + if (numitems < MAXITEMS) { + ii = itemavail[0]; + GetSuperItemSpace(x, y, itemavail[0]); + itemactive[numitems] = ii; + itemavail[0] = itemavail[MAXITEMS - numitems - 1]; + SetupAllUseful(ii, GetRndSeed(), currlevel); - if (sendmsg) - NetSendCmdDItem(FALSE, ii); + if (sendmsg) + NetSendCmdDItem(FALSE, ii); - ++numitems; - } + ++numitems; + } } void __fastcall CreateTypeItem(int x, int y, unsigned char onlygood, int itype, int imisc, int sendmsg, int delta) { - int idx; // edi - int ii; // esi + int idx; // edi + int ii; // esi - if (itype == ITYPE_GOLD) - idx = 0; - else - idx = RndTypeItems(itype, imisc); + if (itype == ITYPE_GOLD) + idx = 0; + else + idx = RndTypeItems(itype, imisc); - if (numitems < MAXITEMS) { - ii = itemavail[0]; - GetSuperItemSpace(x, y, itemavail[0]); - itemactive[numitems] = ii; - itemavail[0] = itemavail[MAXITEMS - numitems - 1]; - SetupAllItems(ii, idx, GetRndSeed(), 2 * currlevel, 1, onlygood, 0, delta); + if (numitems < MAXITEMS) { + ii = itemavail[0]; + GetSuperItemSpace(x, y, itemavail[0]); + itemactive[numitems] = ii; + itemavail[0] = itemavail[MAXITEMS - numitems - 1]; + SetupAllItems(ii, idx, GetRndSeed(), 2 * currlevel, 1, onlygood, 0, delta); - if (sendmsg) - NetSendCmdDItem(FALSE, ii); - if (delta) - DeltaAddItem(ii); + if (sendmsg) + NetSendCmdDItem(FALSE, ii); + if (delta) + DeltaAddItem(ii); - ++numitems; - } + ++numitems; + } } void __fastcall RecreateItem(int ii, int idx, unsigned short ic, int iseed, int ivalue) { - int uper; // esi - int onlygood; // edx - int recreate; // ebx - int pregen; // edi + int uper; // esi + int onlygood; // edx + int recreate; // ebx + int pregen; // edi - if (idx) { - if (ic) { - if (ic & 0x7C00) { - RecreateTownItem(ii, idx, ic, iseed, ivalue); - } else if ((ic & 0x0180) == 0x0180) { - SetupAllUseful(ii, iseed, ic & 0x3F); - } else { - uper = 0; - onlygood = 0; - recreate = 0; - pregen = 0; - if (ic & 0x0100) - uper = 1; - if (ic & 0x80) - uper = 15; - if (ic & 0x40) - onlygood = 1; - if (ic & 0x0200) - recreate = 1; - if (ic & 0x8000) - pregen = 1; - SetupAllItems(ii, idx, iseed, ic & 0x3F, uper, onlygood, recreate, pregen); - } - } else { - SetPlrHandItem(&item[ii], idx); - SetPlrHandSeed(&item[ii], iseed); - } - } else { - SetPlrHandItem(&item[ii], IDI_GOLD); - item[ii]._iSeed = iseed; - item[ii]._iCreateInfo = ic; - item[ii]._ivalue = ivalue; - if (ivalue < 2500) { - if (ivalue > 1000) - item[ii]._iCurs = ICURS_GOLD_MEDIUM; - else - item[ii]._iCurs = ICURS_GOLD_SMALL; - } else { - item[ii]._iCurs = ICURS_GOLD_LARGE; - } - } + if (idx) { + if (ic) { + if (ic & 0x7C00) { + RecreateTownItem(ii, idx, ic, iseed, ivalue); + } else if ((ic & 0x0180) == 0x0180) { + SetupAllUseful(ii, iseed, ic & 0x3F); + } else { + uper = 0; + onlygood = 0; + recreate = 0; + pregen = 0; + if (ic & 0x0100) + uper = 1; + if (ic & 0x80) + uper = 15; + if (ic & 0x40) + onlygood = 1; + if (ic & 0x0200) + recreate = 1; + if (ic & 0x8000) + pregen = 1; + SetupAllItems(ii, idx, iseed, ic & 0x3F, uper, onlygood, recreate, pregen); + } + } else { + SetPlrHandItem(&item[ii], idx); + SetPlrHandSeed(&item[ii], iseed); + } + } else { + SetPlrHandItem(&item[ii], IDI_GOLD); + item[ii]._iSeed = iseed; + item[ii]._iCreateInfo = ic; + item[ii]._ivalue = ivalue; + if (ivalue < 2500) { + if (ivalue > 1000) + item[ii]._iCurs = ICURS_GOLD_MEDIUM; + else + item[ii]._iCurs = ICURS_GOLD_SMALL; + } else { + item[ii]._iCurs = ICURS_GOLD_LARGE; + } + } } void __fastcall RecreateEar(int ii, unsigned short ic, int iseed, unsigned char Id, int dur, int mdur, int ch, int mch, int ivalue, int ibuff) { - SetPlrHandItem(&item[ii], IDI_EAR); - tempstr[0] = (ic >> 8) & 0x7F; - tempstr[1] = ic & 0x7F; - tempstr[2] = (iseed >> 24) & 0x7F; - tempstr[3] = (iseed >> 16) & 0x7F; - tempstr[4] = (iseed >> 8) & 0x7F; - tempstr[5] = iseed & 0x7F; - tempstr[6] = Id & 0x7F; - tempstr[7] = dur & 0x7F; - tempstr[8] = mdur & 0x7F; - tempstr[9] = ch & 0x7F; - tempstr[10] = mch & 0x7F; - tempstr[11] = (ivalue >> 8) & 0x7F; - tempstr[12] = (ibuff >> 24) & 0x7F; - tempstr[13] = (ibuff >> 16) & 0x7F; - tempstr[14] = (ibuff >> 8) & 0x7F; - tempstr[15] = ibuff & 0x7F; - tempstr[16] = '\0'; - sprintf(item[ii]._iName, "Ear of %s", tempstr); - item[ii]._iCurs = ((ivalue >> 6) & 3) + 19; - item[ii]._iCreateInfo = ic; - item[ii]._ivalue = ivalue & 0x3F; - item[ii]._iSeed = iseed; + SetPlrHandItem(&item[ii], IDI_EAR); + tempstr[0] = (ic >> 8) & 0x7F; + tempstr[1] = ic & 0x7F; + tempstr[2] = (iseed >> 24) & 0x7F; + tempstr[3] = (iseed >> 16) & 0x7F; + tempstr[4] = (iseed >> 8) & 0x7F; + tempstr[5] = iseed & 0x7F; + tempstr[6] = Id & 0x7F; + tempstr[7] = dur & 0x7F; + tempstr[8] = mdur & 0x7F; + tempstr[9] = ch & 0x7F; + tempstr[10] = mch & 0x7F; + tempstr[11] = (ivalue >> 8) & 0x7F; + tempstr[12] = (ibuff >> 24) & 0x7F; + tempstr[13] = (ibuff >> 16) & 0x7F; + tempstr[14] = (ibuff >> 8) & 0x7F; + tempstr[15] = ibuff & 0x7F; + tempstr[16] = '\0'; + sprintf(item[ii]._iName, "Ear of %s", tempstr); + item[ii]._iCurs = ((ivalue >> 6) & 3) + 19; + item[ii]._iCreateInfo = ic; + item[ii]._ivalue = ivalue & 0x3F; + item[ii]._iSeed = iseed; } void __fastcall SpawnQuestItem(int itemid, int x, int y, int randarea, int selflag) { - int i; // ebx - BOOL failed; // eax - int j; // esi - int v12; // ebx - int v13; // esi - int tries; // [esp+10h] [ebp-4h] + int i; // ebx + BOOL failed; // eax + int j; // esi + int v12; // ebx + int v13; // esi + int tries; // [esp+10h] [ebp-4h] - if (randarea) { - tries = 0; - while (1) { - LABEL_3: - if (++tries > 1000 && randarea > 1) - --randarea; + if (randarea) { + tries = 0; + while (1) { + LABEL_3: + if (++tries > 1000 && randarea > 1) + --randarea; - x = random(0, 112); - y = random(0, 112); - i = 0; - failed = 0; - if (randarea <= 0) - break; - while (!failed) { - for (j = 0; j < randarea; j++) { - if (failed) - break; + x = random(0, 112); + y = random(0, 112); + i = 0; + failed = 0; + if (randarea <= 0) + break; + while (!failed) { + for (j = 0; j < randarea; j++) { + if (failed) + break; - failed = ItemSpaceOk(i + x, j + y) == 0; - } + failed = ItemSpaceOk(i + x, j + y) == 0; + } - if (++i >= randarea) { - if (failed) - goto LABEL_3; - goto LABEL_13; - } - } - } - } + if (++i >= randarea) { + if (failed) + goto LABEL_3; + goto LABEL_13; + } + } + } + } LABEL_13: - if (numitems < MAXITEMS) { - v12 = itemavail[0]; - v13 = itemavail[0]; - item[v13]._ix = x; - itemactive[numitems] = v12; - item[v13]._iy = y; - itemavail[0] = itemavail[MAXITEMS - numitems - 1]; - dItem[x][y] = v12 + 1; - GetItemAttrs(v12, itemid, currlevel); - SetupItem(v12); - item[v13]._iPostDraw = 1; - if (selflag) { - item[v13]._iAnimFlag = 0; - item[v13]._iSelFlag = selflag; - item[v13]._iAnimFrame = item[v13]._iAnimLen; - } - ++numitems; - } + if (numitems < MAXITEMS) { + v12 = itemavail[0]; + v13 = itemavail[0]; + item[v13]._ix = x; + itemactive[numitems] = v12; + item[v13]._iy = y; + itemavail[0] = itemavail[MAXITEMS - numitems - 1]; + dItem[x][y] = v12 + 1; + GetItemAttrs(v12, itemid, currlevel); + SetupItem(v12); + item[v13]._iPostDraw = 1; + if (selflag) { + item[v13]._iAnimFlag = 0; + item[v13]._iSelFlag = selflag; + item[v13]._iAnimFrame = item[v13]._iAnimLen; + } + ++numitems; + } } void __cdecl SpawnRock() { - BOOL v0; // edx - int v1; // eax - int v2; // ecx - BOOL v3; // ebx - int v4; // ebx - int v5; // ecx - int v6; // esi - int *v7; // edx - int v8; // eax - int v9; // edi - int v10; // ST04_4 - //int v11; // [esp+8h] [ebp-4h] + BOOL v0; // edx + int v1; // eax + int v2; // ecx + BOOL v3; // ebx + int v4; // ebx + int v5; // ecx + int v6; // esi + int *v7; // edx + int v8; // eax + int v9; // edi + int v10; // ST04_4 + //int v11; // [esp+8h] [ebp-4h] - v0 = 0; - v1 = 0; - if (nobjects > 0) { - v2 = 0; //v11; /* chceck */ - while (!v0) { - v2 = objectactive[v1]; - v3 = object[objectactive[v1++]]._otype == OBJ_STAND; - v0 = v3; - if (v1 >= nobjects) { - if (!v3) - return; - break; - } - } - v4 = itemavail[0]; - v5 = v2; - v6 = itemavail[0]; - v7 = &itemavail[MAXITEMS - numitems - 1]; - itemactive[numitems] = itemavail[0]; - v8 = object[v5]._ox; - item[v6]._ix = v8; - v9 = object[v5]._oy; - itemavail[0] = *v7; - dItem[v8][v9] = v4 + 1; - v10 = currlevel; - item[v6]._iy = v9; - GetItemAttrs(v4, IDI_ROCK, v10); - SetupItem(v4); - ++numitems; - item[v6]._iSelFlag = 2; - item[v6]._iPostDraw = 1; - item[v6]._iAnimFrame = 11; - } + v0 = 0; + v1 = 0; + if (nobjects > 0) { + v2 = 0; //v11; /* chceck */ + while (!v0) { + v2 = objectactive[v1]; + v3 = object[objectactive[v1++]]._otype == OBJ_STAND; + v0 = v3; + if (v1 >= nobjects) { + if (!v3) + return; + break; + } + } + v4 = itemavail[0]; + v5 = v2; + v6 = itemavail[0]; + v7 = &itemavail[MAXITEMS - numitems - 1]; + itemactive[numitems] = itemavail[0]; + v8 = object[v5]._ox; + item[v6]._ix = v8; + v9 = object[v5]._oy; + itemavail[0] = *v7; + dItem[v8][v9] = v4 + 1; + v10 = currlevel; + item[v6]._iy = v9; + GetItemAttrs(v4, IDI_ROCK, v10); + SetupItem(v4); + ++numitems; + item[v6]._iSelFlag = 2; + item[v6]._iPostDraw = 1; + item[v6]._iAnimFrame = 11; + } } void __fastcall RespawnItem(int i, BOOL FlipFlag) { - int it; // ecx - int il; // eax + int it; // ecx + int il; // eax - item[i]._iAnimWidth = 96; - item[i]._iAnimWidth2 = 16; - it = ItemCAnimTbl[item[i]._iCurs]; - il = ItemAnimLs[it]; - item[i]._iAnimLen = il; - item[i]._iAnimData = Item2Frm[it]; - item[i]._iPostDraw = 0; - item[i]._iRequest = FALSE; + item[i]._iAnimWidth = 96; + item[i]._iAnimWidth2 = 16; + it = ItemCAnimTbl[item[i]._iCurs]; + il = ItemAnimLs[it]; + item[i]._iAnimLen = il; + item[i]._iAnimData = Item2Frm[it]; + item[i]._iPostDraw = 0; + item[i]._iRequest = FALSE; - if (FlipFlag) { - item[i]._iSelFlag = 0; - il = 1; - item[i]._iAnimFlag = 1; - } else { - item[i]._iAnimFlag = 0; - item[i]._iSelFlag = 1; - } + if (FlipFlag) { + item[i]._iSelFlag = 0; + il = 1; + item[i]._iAnimFlag = 1; + } else { + item[i]._iAnimFlag = 0; + item[i]._iSelFlag = 1; + } - item[i]._iAnimFrame = il; + item[i]._iAnimFrame = il; - if (item[i]._iCurs == ICURS_MAGIC_ROCK) { - item[i]._iSelFlag = 1; - PlaySfxLoc(ItemDropSnds[it], item[i]._ix, item[i]._iy); - } - if (item[i]._iCurs == ICURS_TAVERN_SIGN) - item[i]._iSelFlag = 1; - if (item[i]._iCurs == ICURS_ANVIL_OF_FURY) - item[i]._iSelFlag = 1; + if (item[i]._iCurs == ICURS_MAGIC_ROCK) { + item[i]._iSelFlag = 1; + PlaySfxLoc(ItemDropSnds[it], item[i]._ix, item[i]._iy); + } + if (item[i]._iCurs == ICURS_TAVERN_SIGN) + item[i]._iSelFlag = 1; + if (item[i]._iCurs == ICURS_ANVIL_OF_FURY) + item[i]._iSelFlag = 1; } void __fastcall DeleteItem(int ii, int i) { - int v2; // eax - bool v3; // zf - bool v4; // sf + int v2; // eax + bool v3; // zf + bool v4; // sf - v2 = numitems - 1; - v3 = numitems == 1; - v4 = numitems - 1 < 0; - itemavail[-numitems + MAXITEMS] = ii; - numitems = v2; - if (!v4 && !v3 && i != v2) - itemactive[i] = itemactive[v2]; + v2 = numitems - 1; + v3 = numitems == 1; + v4 = numitems - 1 < 0; + itemavail[-numitems + MAXITEMS] = ii; + numitems = v2; + if (!v4 && !v3 && i != v2) + itemactive[i] = itemactive[v2]; } void __cdecl ItemDoppel() { - int idoppelx; // esi - ItemStruct *i; // edx + int idoppelx; // esi + ItemStruct *i; // edx - if (gbMaxPlayers != 1) { - for (idoppelx = 16; idoppelx < 96; idoppelx++) { - if (dItem[idoppelx][idoppely]) { - i = &item[dItem[idoppelx][idoppely] - 1]; - if (i->_ix != idoppelx || i->_iy != idoppely) - dItem[idoppelx][idoppely] = 0; - } - } + if (gbMaxPlayers != 1) { + for (idoppelx = 16; idoppelx < 96; idoppelx++) { + if (dItem[idoppelx][idoppely]) { + i = &item[dItem[idoppelx][idoppely] - 1]; + if (i->_ix != idoppelx || i->_iy != idoppely) + dItem[idoppelx][idoppely] = 0; + } + } - if (idoppely++ == 95) - idoppely = 16; - } + if (idoppely++ == 95) + idoppely = 16; + } } // 492EAC: using guessed type int idoppely; // 679660: using guessed type char gbMaxPlayers; void __cdecl ProcessItems() { - int i; // edi - int ii; // esi + int i; // edi + int ii; // esi - for (i = 0; i < numitems; i++) { - ii = itemactive[i]; - if (item[ii]._iAnimFlag) { - item[ii]._iAnimFrame++; - if (item[ii]._iCurs == ICURS_MAGIC_ROCK) { - if (item[ii]._iSelFlag == 1 && item[ii]._iAnimFrame == 11) - item[ii]._iAnimFrame = 1; - if (item[ii]._iSelFlag == 2 && item[ii]._iAnimFrame == 21) - item[ii]._iAnimFrame = 11; - } else { - if (item[ii]._iAnimFrame == item[ii]._iAnimLen >> 1) - PlaySfxLoc(ItemDropSnds[ItemCAnimTbl[item[ii]._iCurs]], item[ii]._ix, item[ii]._iy); + for (i = 0; i < numitems; i++) { + ii = itemactive[i]; + if (item[ii]._iAnimFlag) { + item[ii]._iAnimFrame++; + if (item[ii]._iCurs == ICURS_MAGIC_ROCK) { + if (item[ii]._iSelFlag == 1 && item[ii]._iAnimFrame == 11) + item[ii]._iAnimFrame = 1; + if (item[ii]._iSelFlag == 2 && item[ii]._iAnimFrame == 21) + item[ii]._iAnimFrame = 11; + } else { + if (item[ii]._iAnimFrame == item[ii]._iAnimLen >> 1) + PlaySfxLoc(ItemDropSnds[ItemCAnimTbl[item[ii]._iCurs]], item[ii]._ix, item[ii]._iy); - if (item[ii]._iAnimFrame >= item[ii]._iAnimLen) { - item[ii]._iAnimFlag = 0; - item[ii]._iAnimFrame = item[ii]._iAnimLen; - item[ii]._iSelFlag = 1; - } - } - } - } - ItemDoppel(); + if (item[ii]._iAnimFrame >= item[ii]._iAnimLen) { + item[ii]._iAnimFlag = 0; + item[ii]._iAnimFrame = item[ii]._iAnimLen; + item[ii]._iSelFlag = 1; + } + } + } + } + ItemDoppel(); } void __cdecl FreeItemGFX() { - int i; // esi - void *v1; // ecx + int i; // esi + void *v1; // ecx - for (i = 0; i < 35; i++) { - v1 = (void *)Item2Frm[i]; - Item2Frm[i] = 0; - mem_free_dbg(v1); - } + for (i = 0; i < 35; i++) { + v1 = (void *)Item2Frm[i]; + Item2Frm[i] = 0; + mem_free_dbg(v1); + } } void __fastcall GetItemFrm(int i) { - item[i]._iAnimData = Item2Frm[ItemCAnimTbl[item[i]._iCurs]]; + item[i]._iAnimData = Item2Frm[ItemCAnimTbl[item[i]._iCurs]]; } void __fastcall GetItemStr(int i) { - int nGold; // esi + int nGold; // esi - if (item[i]._itype == ITYPE_GOLD) { - nGold = item[i]._ivalue; - sprintf(infostr, "%i gold %s", nGold, get_pieces_str(nGold)); - } else { - if (!item[i]._iIdentified) - strcpy(infostr, item[i]._iName); - else - strcpy(infostr, item[i]._iIName); + if (item[i]._itype == ITYPE_GOLD) { + nGold = item[i]._ivalue; + sprintf(infostr, "%i gold %s", nGold, get_pieces_str(nGold)); + } else { + if (!item[i]._iIdentified) + strcpy(infostr, item[i]._iName); + else + strcpy(infostr, item[i]._iIName); - if (item[i]._iMagical == ITEM_QUALITY_MAGIC) - infoclr = COL_BLUE; - if (item[i]._iMagical == ITEM_QUALITY_UNIQUE) - infoclr = COL_GOLD; - } + if (item[i]._iMagical == ITEM_QUALITY_MAGIC) + infoclr = COL_BLUE; + if (item[i]._iMagical == ITEM_QUALITY_UNIQUE) + infoclr = COL_GOLD; + } } // 4B883C: using guessed type int infoclr; void __fastcall CheckIdentify(int pnum, int cii) { - ItemStruct *pi; // esi + ItemStruct *pi; // esi - pi = &plr[pnum].InvBody[cii]; - pi->_iIdentified = TRUE; + pi = &plr[pnum].InvBody[cii]; + pi->_iIdentified = TRUE; - CalcPlrInv(pnum, 1); + CalcPlrInv(pnum, 1); - if (pnum == myplr) - SetCursor(CURSOR_HAND); + if (pnum == myplr) + SetCursor(CURSOR_HAND); } void __fastcall DoRepair(int pnum, int cii) { - PlayerStruct *p; // eax - ItemStruct *pi; // esi + PlayerStruct *p; // eax + ItemStruct *pi; // esi - p = &plr[pnum]; - pi = &p->InvBody[cii]; + p = &plr[pnum]; + pi = &p->InvBody[cii]; - PlaySfxLoc(IS_REPAIR, p->WorldX, p->WorldY); - RepairItem(pi, p->_pLevel); - CalcPlrInv(pnum, 1); + PlaySfxLoc(IS_REPAIR, p->WorldX, p->WorldY); + RepairItem(pi, p->_pLevel); + CalcPlrInv(pnum, 1); - if (pnum == myplr) - SetCursor(CURSOR_HAND); + if (pnum == myplr) + SetCursor(CURSOR_HAND); } void __fastcall RepairItem(ItemStruct *i, int lvl) { - int rep; // edi - int d; // eax + int rep; // edi + int d; // eax - if (i->_iDurability != i->_iMaxDur) { - if (i->_iMaxDur > 0) { - rep = 0; - while (1) { - rep += lvl + random(37, lvl); - d = i->_iMaxDur / (lvl + 9); + if (i->_iDurability != i->_iMaxDur) { + if (i->_iMaxDur > 0) { + rep = 0; + while (1) { + rep += lvl + random(37, lvl); + d = i->_iMaxDur / (lvl + 9); - if (d < 1) - d = 1; - if (i->_iMaxDur == d) - break; + if (d < 1) + d = 1; + if (i->_iMaxDur == d) + break; - i->_iMaxDur -= d; + i->_iMaxDur -= d; - if (rep + i->_iDurability >= i->_iMaxDur) { - i->_iDurability += rep; - if (i->_iDurability > i->_iMaxDur) - i->_iDurability = i->_iMaxDur; - return; - } - } - } - i->_itype = -1; - } + if (rep + i->_iDurability >= i->_iMaxDur) { + i->_iDurability += rep; + if (i->_iDurability > i->_iMaxDur) + i->_iDurability = i->_iMaxDur; + return; + } + } + } + i->_itype = -1; + } } void __fastcall DoRecharge(int pnum, int cii) { - PlayerStruct *p; // eax - ItemStruct *pi; // esi + PlayerStruct *p; // eax + ItemStruct *pi; // esi - p = &plr[pnum]; - pi = &p->InvBody[cii]; + p = &plr[pnum]; + pi = &p->InvBody[cii]; - if (pi->_itype == ITYPE_STAFF && pi->_iSpell) { - RechargeItem(pi, random(38, p->_pLevel / spelldata[pi->_iSpell].sBookLvl) + 1); - CalcPlrInv(pnum, 1); - } + if (pi->_itype == ITYPE_STAFF && pi->_iSpell) { + RechargeItem(pi, random(38, p->_pLevel / spelldata[pi->_iSpell].sBookLvl) + 1); + CalcPlrInv(pnum, 1); + } - if (pnum == myplr) - SetCursor(CURSOR_HAND); + if (pnum == myplr) + SetCursor(CURSOR_HAND); } void __fastcall RechargeItem(ItemStruct *i, int r) { - if (i->_iCharges != i->_iMaxCharges) { - while (1) { - if (i->_iMaxCharges-- == 1) - break; + if (i->_iCharges != i->_iMaxCharges) { + while (1) { + if (i->_iMaxCharges-- == 1) + break; - i->_iCharges += r; + i->_iCharges += r; - if (i->_iCharges >= i->_iMaxCharges) { - if (i->_iCharges > i->_iMaxCharges) - i->_iCharges = i->_iMaxCharges; - return; - } - } - } + if (i->_iCharges >= i->_iMaxCharges) { + if (i->_iCharges > i->_iMaxCharges) + i->_iCharges = i->_iMaxCharges; + return; + } + } + } } void __fastcall PrintItemOil(char IDidx) { - switch (IDidx) { - case IMISC_FULLHEAL: - strcpy(tempstr, "fully recover life"); - break; - case IMISC_HEAL: - strcpy(tempstr, "recover partial life"); - break; - case IMISC_OLDHEAL: - strcpy(tempstr, "recover life"); - break; - case IMISC_DEADHEAL: - strcpy(tempstr, "deadly heal"); - break; - case IMISC_MANA: - strcpy(tempstr, "recover mana"); - break; - case IMISC_FULLMANA: - strcpy(tempstr, "fully recover mana"); - break; - case IMISC_ELIXSTR: - strcpy(tempstr, "increase strength"); - break; - case IMISC_ELIXMAG: - strcpy(tempstr, "increase magic"); - break; - case IMISC_ELIXDEX: - strcpy(tempstr, "increase dexterity"); - break; - case IMISC_ELIXVIT: - strcpy(tempstr, "increase vitality"); - break; - case IMISC_ELIXWEAK: - case IMISC_ELIXDIS: - strcpy(tempstr, "decrease strength"); - break; - case IMISC_ELIXCLUM: - strcpy(tempstr, "decrease dexterity"); - break; - case IMISC_ELIXSICK: - strcpy(tempstr, "decrease vitality"); - break; - case IMISC_REJUV: - strcpy(tempstr, "recover life and mana"); - break; - case IMISC_FULLREJUV: - strcpy(tempstr, "fully recover life and mana"); - break; - default: - return; - } + switch (IDidx) { + case IMISC_FULLHEAL: + strcpy(tempstr, "fully recover life"); + break; + case IMISC_HEAL: + strcpy(tempstr, "recover partial life"); + break; + case IMISC_OLDHEAL: + strcpy(tempstr, "recover life"); + break; + case IMISC_DEADHEAL: + strcpy(tempstr, "deadly heal"); + break; + case IMISC_MANA: + strcpy(tempstr, "recover mana"); + break; + case IMISC_FULLMANA: + strcpy(tempstr, "fully recover mana"); + break; + case IMISC_ELIXSTR: + strcpy(tempstr, "increase strength"); + break; + case IMISC_ELIXMAG: + strcpy(tempstr, "increase magic"); + break; + case IMISC_ELIXDEX: + strcpy(tempstr, "increase dexterity"); + break; + case IMISC_ELIXVIT: + strcpy(tempstr, "increase vitality"); + break; + case IMISC_ELIXWEAK: + case IMISC_ELIXDIS: + strcpy(tempstr, "decrease strength"); + break; + case IMISC_ELIXCLUM: + strcpy(tempstr, "decrease dexterity"); + break; + case IMISC_ELIXSICK: + strcpy(tempstr, "decrease vitality"); + break; + case IMISC_REJUV: + strcpy(tempstr, "recover life and mana"); + break; + case IMISC_FULLREJUV: + strcpy(tempstr, "fully recover life and mana"); + break; + default: + return; + } - AddPanelString(tempstr, 1); + AddPanelString(tempstr, 1); } void __fastcall PrintItemPower(char plidx, ItemStruct *x) { - ItemStruct *v2; // esi - int *v3; // esi - int *v4; // esi - int v5; // esi - const char *v6; // [esp-4h] [ebp-Ch] - const char *v7; // [esp-4h] [ebp-Ch] - const char *v8; // [esp-4h] [ebp-Ch] - const char *v9; // [esp-4h] [ebp-Ch] + ItemStruct *v2; // esi + int *v3; // esi + int *v4; // esi + int v5; // esi + const char *v6; // [esp-4h] [ebp-Ch] + const char *v7; // [esp-4h] [ebp-Ch] + const char *v8; // [esp-4h] [ebp-Ch] + const char *v9; // [esp-4h] [ebp-Ch] - v2 = x; - switch (plidx) { - case IPL_TOHIT: - case IPL_TOHIT_CURSE: - sprintf(tempstr, "chance to hit : %+i%%", x->_iPLToHit); - return; - case IPL_DAMP: - case IPL_DAMP_CURSE: - sprintf(tempstr, "%+i%% damage", x->_iPLDam); - return; - case IPL_TOHIT_DAMP: - case IPL_TOHIT_DAMP_CURSE: - sprintf(tempstr, "to hit: %+i%%, %+i%% damage", x->_iPLToHit, x->_iPLDam); - return; - case IPL_ACP: - case IPL_ACP_CURSE: - sprintf(tempstr, "%+i%% armor", x->_iPLAC); - return; - case IPL_FIRERES: - if (x->_iPLFR < 75) - sprintf(tempstr, "Resist Fire : %+i%%", x->_iPLFR); - if (v2->_iPLFR >= 75) { - v6 = "Resist Fire : 75%% MAX"; - goto LABEL_11; - } - return; - case IPL_LIGHTRES: - if (x->_iPLLR < 75) - sprintf(tempstr, "Resist Lightning : %+i%%", x->_iPLLR); - if (v2->_iPLLR >= 75) { - v6 = "Resist Lightning : 75%% MAX"; - goto LABEL_11; - } - return; - case IPL_MAGICRES: - if (x->_iPLMR < 75) - sprintf(tempstr, "Resist Magic : %+i%%", x->_iPLMR); - if (v2->_iPLMR >= 75) { - v6 = "Resist Magic : 75%% MAX"; - goto LABEL_11; - } - return; - case IPL_ALLRES: - if (x->_iPLFR < 75) - sprintf(tempstr, "Resist All : %+i%%", x->_iPLFR); - if (v2->_iPLFR >= 75) { - v6 = "Resist All : 75%% MAX"; - LABEL_11: - sprintf(tempstr, v6); - } - return; - case IPL_SPLLVLADD: - if (x->_iSplLvlAdd == 1) - strcpy(tempstr, "spells are increased 1 level"); - if (v2->_iSplLvlAdd == 2) - strcpy(tempstr, "spells are increased 2 levels"); - if (v2->_iSplLvlAdd < 1) { - v7 = "spells are decreased 1 level"; - goto LABEL_81; - } - return; - case IPL_CHARGES: - v8 = "Extra charges"; - goto LABEL_104; - case IPL_FIREDAM: - sprintf(tempstr, "Fire hit damage: %i-%i", x->_iFMinDam, x->_iFMaxDam); - return; - case IPL_LIGHTDAM: - sprintf(tempstr, "Lightning hit damage: %i-%i", x->_iLMinDam, x->_iLMaxDam); - return; - case IPL_STR: - case IPL_STR_CURSE: - sprintf(tempstr, "%+i to strength", x->_iPLStr); - return; - case IPL_MAG: - case IPL_MAG_CURSE: - sprintf(tempstr, "%+i to magic", x->_iPLMag); - return; - case IPL_DEX: - case IPL_DEX_CURSE: - sprintf(tempstr, "%+i to dexterity", x->_iPLDex); - return; - case IPL_VIT: - case IPL_VIT_CURSE: - sprintf(tempstr, "%+i to vitality", x->_iPLVit); - return; - case IPL_ATTRIBS: - case IPL_ATTRIBS_CURSE: - sprintf(tempstr, "%+i to all attributes", x->_iPLStr); - return; - case IPL_GETHIT_CURSE: - case IPL_GETHIT: - sprintf(tempstr, "%+i damage from enemies", x->_iPLGetHit); - return; - case IPL_LIFE: - case IPL_LIFE_CURSE: - sprintf(tempstr, "Hit Points : %+i", x->_iPLHP >> 6); - return; - case IPL_MANA: - case IPL_MANA_CURSE: - sprintf(tempstr, "Mana : %+i", x->_iPLMana >> 6); - return; - case IPL_DUR: - v8 = "high durability"; - goto LABEL_104; - case IPL_DUR_CURSE: - v8 = "decreased durability"; - goto LABEL_104; - case IPL_INDESTRUCTIBLE: - v8 = "indestructible"; - goto LABEL_104; - case IPL_LIGHT: - sprintf(tempstr, "+%i%% light radius", 10 * x->_iPLLight); - return; - case IPL_LIGHT_CURSE: - sprintf(tempstr, "-%i%% light radius", -10 * x->_iPLLight); - return; - case IPL_FIRE_ARROWS: - sprintf(tempstr, "fire arrows damage: %i-%i", x->_iFMinDam, x->_iFMaxDam); - return; - case IPL_LIGHT_ARROWS: - sprintf(tempstr, "lightning arrows damage %i-%i", x->_iLMinDam, x->_iLMaxDam); - return; - case IPL_INVCURS: - v8 = " "; - goto LABEL_104; - case IPL_THORNS: - v8 = "attacker takes 1-3 damage"; - goto LABEL_104; - case IPL_NOMANA: - v8 = "user loses all mana"; - goto LABEL_104; - case IPL_NOHEALPLR: - v8 = "you can't heal"; - goto LABEL_104; - case IPL_ABSHALFTRAP: - v8 = "absorbs half of trap damage"; - goto LABEL_104; - case IPL_KNOCKBACK: - v8 = "knocks target back"; - goto LABEL_104; - case IPL_NOHEALMON: - v8 = "hit monster doesn't heal"; - goto LABEL_104; - case IPL_STEALMANA: - v3 = &x->_iFlags; - if (x->_iFlags & 0x2000) - strcpy(tempstr, "hit steals 3% mana"); - if (!(*((_BYTE *)v3 + 1) & 0x40)) - return; - v7 = "hit steals 5% mana"; - goto LABEL_81; - case IPL_STEALLIFE: - v4 = &x->_iFlags; - if ((x->_iFlags & 0x8000) != 0) - strcpy(tempstr, "hit steals 3% life"); - if (!(*((_BYTE *)v4 + 2) & 1)) - return; - v7 = "hit steals 5% life"; - goto LABEL_81; - case IPL_TARGAC: - v8 = "damages target's armor"; - goto LABEL_104; - case IPL_FASTATTACK: - if (x->_iFlags & 0x20000) - strcpy(tempstr, "quick attack"); - if (v2->_iFlags & 0x40000) - strcpy(tempstr, "fast attack"); - if (v2->_iFlags & 0x80000) - strcpy(tempstr, "faster attack"); - if (!(v2->_iFlags & 0x100000)) - return; - v7 = "fastest attack"; - goto LABEL_81; - case IPL_FASTRECOVER: - if (x->_iFlags & 0x200000) - strcpy(tempstr, "fast hit recovery"); - if (v2->_iFlags & 0x400000) - strcpy(tempstr, "faster hit recovery"); - if ((v2->_iFlags & 0x800000) != 0) { - v7 = "fastest hit recovery"; - LABEL_81: - strcpy(tempstr, v7); - } - return; - case IPL_FASTBLOCK: - v8 = "fast block"; - goto LABEL_104; - case IPL_DAMMOD: - sprintf(tempstr, "adds %i points to damage", x->_iPLDamMod); - return; - case IPL_RNDARROWVEL: - v8 = "fires random speed arrows"; - goto LABEL_104; - case IPL_SETDAM: - v9 = "unusual item damage"; - goto LABEL_98; - case IPL_SETDUR: - v8 = "altered durability"; - goto LABEL_104; - case IPL_NOMINSTR: - v8 = "no strength requirement"; - goto LABEL_104; - case IPL_SPELL: - sprintf(tempstr, "%i %s charges", x->_iMaxCharges, spelldata[x->_iSpell].sNameText); - return; - case IPL_FASTSWING: - v8 = "Faster attack swing"; - goto LABEL_104; - case IPL_ONEHAND: - v8 = "one handed sword"; - goto LABEL_104; - case IPL_3XDAMVDEM: - v8 = "+200% damage vs. demons"; - goto LABEL_104; - case IPL_ALLRESZERO: - v8 = "All Resistance equals 0"; - goto LABEL_104; - case IPL_DRAINLIFE: - v8 = "constantly lose hit points"; - goto LABEL_104; - case IPL_RNDSTEALLIFE: - v8 = "life stealing"; - goto LABEL_104; - case IPL_INFRAVISION: - v8 = "see with infravision"; - goto LABEL_104; - case IPL_SETAC: - case IPL_AC_CURSE: - sprintf(tempstr, "armor class: %i", x->_iAC); - return; - case IPL_ADDACLIFE: - v8 = "Armor class added to life"; - goto LABEL_104; - case IPL_ADDMANAAC: - v8 = "10% of mana added to armor"; - goto LABEL_104; - case IPL_FIRERESCLVL: - v5 = x->_iPLFR; - if (v5 > 0) { - if (v5 >= 1) - sprintf(tempstr, "Resist Fire : %+i%%", v5); - } else { - v9 = " "; - LABEL_98: - sprintf(tempstr, v9); - } - break; - default: - v8 = "Another ability (NW)"; - LABEL_104: - strcpy(tempstr, v8); - break; - } + v2 = x; + switch (plidx) { + case IPL_TOHIT: + case IPL_TOHIT_CURSE: + sprintf(tempstr, "chance to hit : %+i%%", x->_iPLToHit); + return; + case IPL_DAMP: + case IPL_DAMP_CURSE: + sprintf(tempstr, "%+i%% damage", x->_iPLDam); + return; + case IPL_TOHIT_DAMP: + case IPL_TOHIT_DAMP_CURSE: + sprintf(tempstr, "to hit: %+i%%, %+i%% damage", x->_iPLToHit, x->_iPLDam); + return; + case IPL_ACP: + case IPL_ACP_CURSE: + sprintf(tempstr, "%+i%% armor", x->_iPLAC); + return; + case IPL_FIRERES: + if (x->_iPLFR < 75) + sprintf(tempstr, "Resist Fire : %+i%%", x->_iPLFR); + if (v2->_iPLFR >= 75) { + v6 = "Resist Fire : 75%% MAX"; + goto LABEL_11; + } + return; + case IPL_LIGHTRES: + if (x->_iPLLR < 75) + sprintf(tempstr, "Resist Lightning : %+i%%", x->_iPLLR); + if (v2->_iPLLR >= 75) { + v6 = "Resist Lightning : 75%% MAX"; + goto LABEL_11; + } + return; + case IPL_MAGICRES: + if (x->_iPLMR < 75) + sprintf(tempstr, "Resist Magic : %+i%%", x->_iPLMR); + if (v2->_iPLMR >= 75) { + v6 = "Resist Magic : 75%% MAX"; + goto LABEL_11; + } + return; + case IPL_ALLRES: + if (x->_iPLFR < 75) + sprintf(tempstr, "Resist All : %+i%%", x->_iPLFR); + if (v2->_iPLFR >= 75) { + v6 = "Resist All : 75%% MAX"; + LABEL_11: + sprintf(tempstr, v6); + } + return; + case IPL_SPLLVLADD: + if (x->_iSplLvlAdd == 1) + strcpy(tempstr, "spells are increased 1 level"); + if (v2->_iSplLvlAdd == 2) + strcpy(tempstr, "spells are increased 2 levels"); + if (v2->_iSplLvlAdd < 1) { + v7 = "spells are decreased 1 level"; + goto LABEL_81; + } + return; + case IPL_CHARGES: + v8 = "Extra charges"; + goto LABEL_104; + case IPL_FIREDAM: + sprintf(tempstr, "Fire hit damage: %i-%i", x->_iFMinDam, x->_iFMaxDam); + return; + case IPL_LIGHTDAM: + sprintf(tempstr, "Lightning hit damage: %i-%i", x->_iLMinDam, x->_iLMaxDam); + return; + case IPL_STR: + case IPL_STR_CURSE: + sprintf(tempstr, "%+i to strength", x->_iPLStr); + return; + case IPL_MAG: + case IPL_MAG_CURSE: + sprintf(tempstr, "%+i to magic", x->_iPLMag); + return; + case IPL_DEX: + case IPL_DEX_CURSE: + sprintf(tempstr, "%+i to dexterity", x->_iPLDex); + return; + case IPL_VIT: + case IPL_VIT_CURSE: + sprintf(tempstr, "%+i to vitality", x->_iPLVit); + return; + case IPL_ATTRIBS: + case IPL_ATTRIBS_CURSE: + sprintf(tempstr, "%+i to all attributes", x->_iPLStr); + return; + case IPL_GETHIT_CURSE: + case IPL_GETHIT: + sprintf(tempstr, "%+i damage from enemies", x->_iPLGetHit); + return; + case IPL_LIFE: + case IPL_LIFE_CURSE: + sprintf(tempstr, "Hit Points : %+i", x->_iPLHP >> 6); + return; + case IPL_MANA: + case IPL_MANA_CURSE: + sprintf(tempstr, "Mana : %+i", x->_iPLMana >> 6); + return; + case IPL_DUR: + v8 = "high durability"; + goto LABEL_104; + case IPL_DUR_CURSE: + v8 = "decreased durability"; + goto LABEL_104; + case IPL_INDESTRUCTIBLE: + v8 = "indestructible"; + goto LABEL_104; + case IPL_LIGHT: + sprintf(tempstr, "+%i%% light radius", 10 * x->_iPLLight); + return; + case IPL_LIGHT_CURSE: + sprintf(tempstr, "-%i%% light radius", -10 * x->_iPLLight); + return; + case IPL_FIRE_ARROWS: + sprintf(tempstr, "fire arrows damage: %i-%i", x->_iFMinDam, x->_iFMaxDam); + return; + case IPL_LIGHT_ARROWS: + sprintf(tempstr, "lightning arrows damage %i-%i", x->_iLMinDam, x->_iLMaxDam); + return; + case IPL_INVCURS: + v8 = " "; + goto LABEL_104; + case IPL_THORNS: + v8 = "attacker takes 1-3 damage"; + goto LABEL_104; + case IPL_NOMANA: + v8 = "user loses all mana"; + goto LABEL_104; + case IPL_NOHEALPLR: + v8 = "you can't heal"; + goto LABEL_104; + case IPL_ABSHALFTRAP: + v8 = "absorbs half of trap damage"; + goto LABEL_104; + case IPL_KNOCKBACK: + v8 = "knocks target back"; + goto LABEL_104; + case IPL_NOHEALMON: + v8 = "hit monster doesn't heal"; + goto LABEL_104; + case IPL_STEALMANA: + v3 = &x->_iFlags; + if (x->_iFlags & 0x2000) + strcpy(tempstr, "hit steals 3% mana"); + if (!(*((_BYTE *)v3 + 1) & 0x40)) + return; + v7 = "hit steals 5% mana"; + goto LABEL_81; + case IPL_STEALLIFE: + v4 = &x->_iFlags; + if ((x->_iFlags & 0x8000) != 0) + strcpy(tempstr, "hit steals 3% life"); + if (!(*((_BYTE *)v4 + 2) & 1)) + return; + v7 = "hit steals 5% life"; + goto LABEL_81; + case IPL_TARGAC: + v8 = "damages target's armor"; + goto LABEL_104; + case IPL_FASTATTACK: + if (x->_iFlags & 0x20000) + strcpy(tempstr, "quick attack"); + if (v2->_iFlags & 0x40000) + strcpy(tempstr, "fast attack"); + if (v2->_iFlags & 0x80000) + strcpy(tempstr, "faster attack"); + if (!(v2->_iFlags & 0x100000)) + return; + v7 = "fastest attack"; + goto LABEL_81; + case IPL_FASTRECOVER: + if (x->_iFlags & 0x200000) + strcpy(tempstr, "fast hit recovery"); + if (v2->_iFlags & 0x400000) + strcpy(tempstr, "faster hit recovery"); + if ((v2->_iFlags & 0x800000) != 0) { + v7 = "fastest hit recovery"; + LABEL_81: + strcpy(tempstr, v7); + } + return; + case IPL_FASTBLOCK: + v8 = "fast block"; + goto LABEL_104; + case IPL_DAMMOD: + sprintf(tempstr, "adds %i points to damage", x->_iPLDamMod); + return; + case IPL_RNDARROWVEL: + v8 = "fires random speed arrows"; + goto LABEL_104; + case IPL_SETDAM: + v9 = "unusual item damage"; + goto LABEL_98; + case IPL_SETDUR: + v8 = "altered durability"; + goto LABEL_104; + case IPL_NOMINSTR: + v8 = "no strength requirement"; + goto LABEL_104; + case IPL_SPELL: + sprintf(tempstr, "%i %s charges", x->_iMaxCharges, spelldata[x->_iSpell].sNameText); + return; + case IPL_FASTSWING: + v8 = "Faster attack swing"; + goto LABEL_104; + case IPL_ONEHAND: + v8 = "one handed sword"; + goto LABEL_104; + case IPL_3XDAMVDEM: + v8 = "+200% damage vs. demons"; + goto LABEL_104; + case IPL_ALLRESZERO: + v8 = "All Resistance equals 0"; + goto LABEL_104; + case IPL_DRAINLIFE: + v8 = "constantly lose hit points"; + goto LABEL_104; + case IPL_RNDSTEALLIFE: + v8 = "life stealing"; + goto LABEL_104; + case IPL_INFRAVISION: + v8 = "see with infravision"; + goto LABEL_104; + case IPL_SETAC: + case IPL_AC_CURSE: + sprintf(tempstr, "armor class: %i", x->_iAC); + return; + case IPL_ADDACLIFE: + v8 = "Armor class added to life"; + goto LABEL_104; + case IPL_ADDMANAAC: + v8 = "10% of mana added to armor"; + goto LABEL_104; + case IPL_FIRERESCLVL: + v5 = x->_iPLFR; + if (v5 > 0) { + if (v5 >= 1) + sprintf(tempstr, "Resist Fire : %+i%%", v5); + } else { + v9 = " "; + LABEL_98: + sprintf(tempstr, v9); + } + break; + default: + v8 = "Another ability (NW)"; + LABEL_104: + strcpy(tempstr, v8); + break; + } } void __cdecl DrawUBack() { - CelDecodeOnly(88, 487, pSTextBoxCels, 1, 271); + CelDecodeOnly(88, 487, pSTextBoxCels, 1, 271); #define TRANS_RECT_X 27 #define TRANS_RECT_Y 28 @@ -3739,1419 +3739,1419 @@ void __cdecl DrawUBack() void __fastcall PrintUString(int x, int y, int cjustflag, char *str, int col) { - char *v5; // edi - int v6; // ebx - size_t v7; // eax - int v8; // esi - int v9; // ecx - signed int v10; // eax - int v11; // edx - int v12; // eax - unsigned char v13; // al - int v14; // edi - int v15; // [esp+Ch] [ebp-4h] - int a3; // [esp+18h] [ebp+8h] + char *v5; // edi + int v6; // ebx + size_t v7; // eax + int v8; // esi + int v9; // ecx + signed int v10; // eax + int v11; // edx + int v12; // eax + unsigned char v13; // al + int v14; // edi + int v15; // [esp+Ch] [ebp-4h] + int a3; // [esp+18h] [ebp+8h] - v5 = str; - v6 = screen_y_times_768[SStringY[y] + 204] + x + 96; - v7 = strlen(str); - v8 = 0; - v9 = 0; - v15 = v7; - if (cjustflag) { - v10 = 0; - if (v15 <= 0) - goto LABEL_16; - do { - v11 = (unsigned char)str[v9++]; - v10 += fontkern[fontframe[fontidx[v11]]] + 1; - } while (v9 < v15); - if (v10 < 257) - LABEL_16: - v8 = (257 - v10) >> 1; - v6 += v8; - } - v12 = 0; - a3 = 0; - if (v15 > 0) { - while (1) { - v13 = fontframe[fontidx[(unsigned char)v5[v12]]]; - v14 = v13; - v8 += fontkern[v13] + 1; - if (v13) { - if (v8 <= 257) - CPrintString(v6, v13, col); - } - v6 += fontkern[v14] + 1; - v12 = a3++ + 1; - if (a3 >= v15) - break; - v5 = str; - } - } + v5 = str; + v6 = screen_y_times_768[SStringY[y] + 204] + x + 96; + v7 = strlen(str); + v8 = 0; + v9 = 0; + v15 = v7; + if (cjustflag) { + v10 = 0; + if (v15 <= 0) + goto LABEL_16; + do { + v11 = (unsigned char)str[v9++]; + v10 += fontkern[fontframe[fontidx[v11]]] + 1; + } while (v9 < v15); + if (v10 < 257) + LABEL_16: + v8 = (257 - v10) >> 1; + v6 += v8; + } + v12 = 0; + a3 = 0; + if (v15 > 0) { + while (1) { + v13 = fontframe[fontidx[(unsigned char)v5[v12]]]; + v14 = v13; + v8 += fontkern[v13] + 1; + if (v13) { + if (v8 <= 257) + CPrintString(v6, v13, col); + } + v6 += fontkern[v14] + 1; + v12 = a3++ + 1; + if (a3 >= v15) + break; + v5 = str; + } + } } void __fastcall DrawULine(int y) { - char *v1; // esi - char *v2; // edi - signed int v3; // edx + char *v1; // esi + char *v2; // edi + signed int v3; // edx - v1 = &gpBuffer->row[25].pixels[26]; - v2 = &gpBuffer->row_unused_1[0].pixels[screen_y_times_768[SStringY[y] + 198] + 26]; - v3 = 3; - do { - qmemcpy(v2, v1, 0x10A); /* find real fix */ - v1 += 264; - v2 += 264; - *v2 = *v1; - v1 += 504; - v2 += 504; - --v3; - } while (v3); + v1 = &gpBuffer->row[25].pixels[26]; + v2 = &gpBuffer->row_unused_1[0].pixels[screen_y_times_768[SStringY[y] + 198] + 26]; + v3 = 3; + do { + qmemcpy(v2, v1, 0x10A); /* find real fix */ + v1 += 264; + v2 += 264; + *v2 = *v1; + v1 += 504; + v2 += 504; + --v3; + } while (v3); } void __cdecl DrawUniqueInfo() { - int v0; // esi - int v1; // esi - int v2; // edi + int v0; // esi + int v1; // esi + int v2; // edi - if (!chrflag && !questlog) { - v0 = curruitem._iUid; - DrawUBack(); - v1 = v0; - PrintUString(0, 2, 1, UniqueItemList[v1].UIName, 3); - DrawULine(5); - PrintItemPower(UniqueItemList[v1].UIPower1, &curruitem); - v2 = 14 - (char)UniqueItemList[v1].UINumPL; - PrintUString(0, v2, 1, tempstr, 0); - if (UniqueItemList[v1].UINumPL > 1) { - PrintItemPower(UniqueItemList[v1].UIPower2, &curruitem); - PrintUString(0, v2 + 2, 1, tempstr, 0); - } - if (UniqueItemList[v1].UINumPL > 2) { - PrintItemPower(UniqueItemList[v1].UIPower3, &curruitem); - PrintUString(0, v2 + 4, 1, tempstr, 0); - } - if (UniqueItemList[v1].UINumPL > 3) { - PrintItemPower(UniqueItemList[v1].UIPower4, &curruitem); - PrintUString(0, v2 + 6, 1, tempstr, 0); - } - if (UniqueItemList[v1].UINumPL > 4) { - PrintItemPower(UniqueItemList[v1].UIPower5, &curruitem); - PrintUString(0, v2 + 8, 1, tempstr, 0); - } - if (UniqueItemList[v1].UINumPL > 5) { - PrintItemPower(UniqueItemList[v1].UIPower6, &curruitem); - PrintUString(0, v2 + 10, 1, tempstr, 0); - } - } + if (!chrflag && !questlog) { + v0 = curruitem._iUid; + DrawUBack(); + v1 = v0; + PrintUString(0, 2, 1, UniqueItemList[v1].UIName, 3); + DrawULine(5); + PrintItemPower(UniqueItemList[v1].UIPower1, &curruitem); + v2 = 14 - (char)UniqueItemList[v1].UINumPL; + PrintUString(0, v2, 1, tempstr, 0); + if (UniqueItemList[v1].UINumPL > 1) { + PrintItemPower(UniqueItemList[v1].UIPower2, &curruitem); + PrintUString(0, v2 + 2, 1, tempstr, 0); + } + if (UniqueItemList[v1].UINumPL > 2) { + PrintItemPower(UniqueItemList[v1].UIPower3, &curruitem); + PrintUString(0, v2 + 4, 1, tempstr, 0); + } + if (UniqueItemList[v1].UINumPL > 3) { + PrintItemPower(UniqueItemList[v1].UIPower4, &curruitem); + PrintUString(0, v2 + 6, 1, tempstr, 0); + } + if (UniqueItemList[v1].UINumPL > 4) { + PrintItemPower(UniqueItemList[v1].UIPower5, &curruitem); + PrintUString(0, v2 + 8, 1, tempstr, 0); + } + if (UniqueItemList[v1].UINumPL > 5) { + PrintItemPower(UniqueItemList[v1].UIPower6, &curruitem); + PrintUString(0, v2 + 10, 1, tempstr, 0); + } + } } // 69BD04: using guessed type int questlog; void __fastcall PrintItemMisc(ItemStruct *x) { - if (x->_iMiscId == IMISC_SCROLL) { - strcpy(tempstr, "Right-click to read"); - AddPanelString(tempstr, 1); - } - if (x->_iMiscId == IMISC_SCROLLT) { - strcpy(tempstr, "Right-click to read, then"); - AddPanelString(tempstr, 1); - strcpy(tempstr, "left-click to target"); - AddPanelString(tempstr, 1); - } - if (x->_iMiscId >= IMISC_USEFIRST && x->_iMiscId <= IMISC_USELAST) { - PrintItemOil(x->_iMiscId); - strcpy(tempstr, "Right click to use"); - AddPanelString(tempstr, 1); - } - if (x->_iMiscId == IMISC_BOOK) { - strcpy(tempstr, "Right click to read"); - AddPanelString(tempstr, 1); - } - if (x->_iMiscId == IMISC_MAPOFDOOM) { - strcpy(tempstr, "Right click to view"); - AddPanelString(tempstr, 1); - } - if (x->_iMiscId == IMISC_EAR) { - sprintf(tempstr, "Level : %i", x->_ivalue); - AddPanelString(tempstr, 1); - } + if (x->_iMiscId == IMISC_SCROLL) { + strcpy(tempstr, "Right-click to read"); + AddPanelString(tempstr, 1); + } + if (x->_iMiscId == IMISC_SCROLLT) { + strcpy(tempstr, "Right-click to read, then"); + AddPanelString(tempstr, 1); + strcpy(tempstr, "left-click to target"); + AddPanelString(tempstr, 1); + } + if (x->_iMiscId >= IMISC_USEFIRST && x->_iMiscId <= IMISC_USELAST) { + PrintItemOil(x->_iMiscId); + strcpy(tempstr, "Right click to use"); + AddPanelString(tempstr, 1); + } + if (x->_iMiscId == IMISC_BOOK) { + strcpy(tempstr, "Right click to read"); + AddPanelString(tempstr, 1); + } + if (x->_iMiscId == IMISC_MAPOFDOOM) { + strcpy(tempstr, "Right click to view"); + AddPanelString(tempstr, 1); + } + if (x->_iMiscId == IMISC_EAR) { + sprintf(tempstr, "Level : %i", x->_ivalue); + AddPanelString(tempstr, 1); + } } void __fastcall PrintItemDetails(ItemStruct *x) { - ItemStruct *v1; // ebp - char v2; // cl - char v3; // cl - char v4; // al - unsigned char v5; // al - char v6; // al + ItemStruct *v1; // ebp + char v2; // cl + char v3; // cl + char v4; // al + unsigned char v5; // al + char v6; // al - v1 = x; - if (x->_iClass == 1) { - if (x->_iMaxDur == 255) - sprintf(tempstr, "damage: %i-%i Indestructible", x->_iMinDam, x->_iMaxDam); - else - sprintf(tempstr, "damage: %i-%i Dur: %i/%i", x->_iMinDam, x->_iMaxDam, x->_iDurability, x->_iMaxDur); - AddPanelString(tempstr, 1); - } - if (v1->_iClass == 2) { - if (v1->_iMaxDur == 255) - sprintf(tempstr, "armor: %i Indestructible", v1->_iAC); - else - sprintf(tempstr, "armor: %i Dur: %i/%i", v1->_iAC, v1->_iDurability, v1->_iMaxDur); - AddPanelString(tempstr, 1); - } - if (v1->_iMiscId == IMISC_STAFF && v1->_iMaxCharges) { - sprintf(tempstr, "dam: %i-%i Dur: %i/%i", v1->_iMinDam, v1->_iMaxDam, v1->_iDurability, v1->_iMaxDur); - sprintf(tempstr, "Charges: %i/%i", v1->_iCharges, v1->_iMaxCharges); - AddPanelString(tempstr, 1); - } - v2 = v1->_iPrePower; - if (v2 != -1) { - PrintItemPower(v2, v1); - AddPanelString(tempstr, 1); - } - v3 = v1->_iSufPower; - if (v3 != -1) { - PrintItemPower(v3, v1); - AddPanelString(tempstr, 1); - } - if (v1->_iMagical == ITEM_QUALITY_UNIQUE) { - AddPanelString("unique item", 1); - uitemflag = 1; - qmemcpy(&curruitem, v1, sizeof(curruitem)); - } - PrintItemMisc(v1); - if ((unsigned char)v1->_iMinMag + v1->_iMinDex + v1->_iMinStr) { - strcpy(tempstr, "Required:"); - v4 = v1->_iMinStr; - if (v4) - sprintf(tempstr, "%s %i Str", tempstr, v4); - v5 = v1->_iMinMag; - if (v5) - sprintf(tempstr, "%s %i Mag", tempstr, v5); - v6 = v1->_iMinDex; - if (v6) - sprintf(tempstr, "%s %i Dex", tempstr, v6); - AddPanelString(tempstr, 1); - } - pinfoflag = 1; + v1 = x; + if (x->_iClass == 1) { + if (x->_iMaxDur == 255) + sprintf(tempstr, "damage: %i-%i Indestructible", x->_iMinDam, x->_iMaxDam); + else + sprintf(tempstr, "damage: %i-%i Dur: %i/%i", x->_iMinDam, x->_iMaxDam, x->_iDurability, x->_iMaxDur); + AddPanelString(tempstr, 1); + } + if (v1->_iClass == 2) { + if (v1->_iMaxDur == 255) + sprintf(tempstr, "armor: %i Indestructible", v1->_iAC); + else + sprintf(tempstr, "armor: %i Dur: %i/%i", v1->_iAC, v1->_iDurability, v1->_iMaxDur); + AddPanelString(tempstr, 1); + } + if (v1->_iMiscId == IMISC_STAFF && v1->_iMaxCharges) { + sprintf(tempstr, "dam: %i-%i Dur: %i/%i", v1->_iMinDam, v1->_iMaxDam, v1->_iDurability, v1->_iMaxDur); + sprintf(tempstr, "Charges: %i/%i", v1->_iCharges, v1->_iMaxCharges); + AddPanelString(tempstr, 1); + } + v2 = v1->_iPrePower; + if (v2 != -1) { + PrintItemPower(v2, v1); + AddPanelString(tempstr, 1); + } + v3 = v1->_iSufPower; + if (v3 != -1) { + PrintItemPower(v3, v1); + AddPanelString(tempstr, 1); + } + if (v1->_iMagical == ITEM_QUALITY_UNIQUE) { + AddPanelString("unique item", 1); + uitemflag = 1; + qmemcpy(&curruitem, v1, sizeof(curruitem)); + } + PrintItemMisc(v1); + if ((unsigned char)v1->_iMinMag + v1->_iMinDex + v1->_iMinStr) { + strcpy(tempstr, "Required:"); + v4 = v1->_iMinStr; + if (v4) + sprintf(tempstr, "%s %i Str", tempstr, v4); + v5 = v1->_iMinMag; + if (v5) + sprintf(tempstr, "%s %i Mag", tempstr, v5); + v6 = v1->_iMinDex; + if (v6) + sprintf(tempstr, "%s %i Dex", tempstr, v6); + AddPanelString(tempstr, 1); + } + pinfoflag = 1; } // 4B8824: using guessed type int pinfoflag; void __fastcall PrintItemDur(ItemStruct *x) { - ItemStruct *v1; // esi - int v2; // eax - char v3; // al - unsigned char v4; // al - char v5; // al + ItemStruct *v1; // esi + int v2; // eax + char v3; // al + unsigned char v4; // al + char v5; // al - v1 = x; - if (x->_iClass == 1) { - if (x->_iMaxDur == 255) - sprintf(tempstr, "damage: %i-%i Indestructible", x->_iMinDam, x->_iMaxDam); - else - sprintf(tempstr, "damage: %i-%i Dur: %i/%i", x->_iMinDam, x->_iMaxDam, x->_iDurability, x->_iMaxDur); - AddPanelString(tempstr, 1); - if (v1->_iMiscId == IMISC_STAFF && v1->_iMaxCharges) { - sprintf(tempstr, "Charges: %i/%i", v1->_iCharges, v1->_iMaxCharges); - AddPanelString(tempstr, 1); - } - if (v1->_iMagical != ITEM_QUALITY_NORMAL) - AddPanelString("Not Identified", 1); - } - if (v1->_iClass == 2) { - if (v1->_iMaxDur == 255) - sprintf(tempstr, "armor: %i Indestructible", v1->_iAC); - else - sprintf(tempstr, "armor: %i Dur: %i/%i", v1->_iAC, v1->_iDurability, v1->_iMaxDur); - AddPanelString(tempstr, 1); - if (v1->_iMagical != ITEM_QUALITY_NORMAL) - AddPanelString("Not Identified", 1); - if (v1->_iMiscId == IMISC_STAFF && v1->_iMaxCharges) { - sprintf(tempstr, "Charges: %i/%i", v1->_iCharges, v1->_iMaxCharges); - AddPanelString(tempstr, 1); - } - } - v2 = v1->_itype; - if (v2 == ITYPE_RING || v2 == ITYPE_AMULET) - AddPanelString("Not Identified", 1); - PrintItemMisc(v1); - if ((unsigned char)v1->_iMinMag + v1->_iMinDex + v1->_iMinStr) { - strcpy(tempstr, "Required:"); - v3 = v1->_iMinStr; - if (v3) - sprintf(tempstr, "%s %i Str", tempstr, v3); - v4 = v1->_iMinMag; - if (v4) - sprintf(tempstr, "%s %i Mag", tempstr, v4); - v5 = v1->_iMinDex; - if (v5) - sprintf(tempstr, "%s %i Dex", tempstr, v5); - AddPanelString(tempstr, 1); - } - pinfoflag = 1; + v1 = x; + if (x->_iClass == 1) { + if (x->_iMaxDur == 255) + sprintf(tempstr, "damage: %i-%i Indestructible", x->_iMinDam, x->_iMaxDam); + else + sprintf(tempstr, "damage: %i-%i Dur: %i/%i", x->_iMinDam, x->_iMaxDam, x->_iDurability, x->_iMaxDur); + AddPanelString(tempstr, 1); + if (v1->_iMiscId == IMISC_STAFF && v1->_iMaxCharges) { + sprintf(tempstr, "Charges: %i/%i", v1->_iCharges, v1->_iMaxCharges); + AddPanelString(tempstr, 1); + } + if (v1->_iMagical != ITEM_QUALITY_NORMAL) + AddPanelString("Not Identified", 1); + } + if (v1->_iClass == 2) { + if (v1->_iMaxDur == 255) + sprintf(tempstr, "armor: %i Indestructible", v1->_iAC); + else + sprintf(tempstr, "armor: %i Dur: %i/%i", v1->_iAC, v1->_iDurability, v1->_iMaxDur); + AddPanelString(tempstr, 1); + if (v1->_iMagical != ITEM_QUALITY_NORMAL) + AddPanelString("Not Identified", 1); + if (v1->_iMiscId == IMISC_STAFF && v1->_iMaxCharges) { + sprintf(tempstr, "Charges: %i/%i", v1->_iCharges, v1->_iMaxCharges); + AddPanelString(tempstr, 1); + } + } + v2 = v1->_itype; + if (v2 == ITYPE_RING || v2 == ITYPE_AMULET) + AddPanelString("Not Identified", 1); + PrintItemMisc(v1); + if ((unsigned char)v1->_iMinMag + v1->_iMinDex + v1->_iMinStr) { + strcpy(tempstr, "Required:"); + v3 = v1->_iMinStr; + if (v3) + sprintf(tempstr, "%s %i Str", tempstr, v3); + v4 = v1->_iMinMag; + if (v4) + sprintf(tempstr, "%s %i Mag", tempstr, v4); + v5 = v1->_iMinDex; + if (v5) + sprintf(tempstr, "%s %i Dex", tempstr, v5); + AddPanelString(tempstr, 1); + } + pinfoflag = 1; } // 4B8824: using guessed type int pinfoflag; void __fastcall UseItem(int p, int Mid, int spl) { - int v3; // esi - int v5; // edx - int v6; // edx - int v7; // edx - int v8; // edx - int v9; // esi - int v10; // esi - int v11; // edi - unsigned int v12; // edi - int v14; // edi - int v15; // ecx - int *v16; // eax - int *v17; // eax - int v18; // esi - int v21; // edx - int v22; // edx - int v23; // edx - int v24; // edx - int v25; // edi - char *v26; // eax - int v27; // edx - int *v28; // ecx - int v29; // eax - int *v30; // ecx - int v31; // edi - int v32; // edi - int v33; // eax - int v34; // ecx - int v35; // eax - bool v36; // zf - int v37; // ecx - int v38; // eax - int v39; // edx - int v40; // eax - int v41; // edx - int v42; // esi - int v43; // edi - unsigned int v44; // edi - int v46; // edi - int v47; // ecx - int *v48; // eax - int v49; // ecx - int *v50; // eax - int v51; // edi - int v52; // edx - unsigned int v53; // edi - int v55; // edi - int v56; // ecx - int *v57; // eax - int *v58; // eax - int v59; // esi - int v61; // esi - int v62; // edi - unsigned int v63; // edi - int v65; // edi - int v66; // ecx - int *v67; // eax - int *v68; // eax - int v69; // esi - int pa; // [esp+Ch] [ebp-4h] + int v3; // esi + int v5; // edx + int v6; // edx + int v7; // edx + int v8; // edx + int v9; // esi + int v10; // esi + int v11; // edi + unsigned int v12; // edi + int v14; // edi + int v15; // ecx + int *v16; // eax + int *v17; // eax + int v18; // esi + int v21; // edx + int v22; // edx + int v23; // edx + int v24; // edx + int v25; // edi + char *v26; // eax + int v27; // edx + int *v28; // ecx + int v29; // eax + int *v30; // ecx + int v31; // edi + int v32; // edi + int v33; // eax + int v34; // ecx + int v35; // eax + bool v36; // zf + int v37; // ecx + int v38; // eax + int v39; // edx + int v40; // eax + int v41; // edx + int v42; // esi + int v43; // edi + unsigned int v44; // edi + int v46; // edi + int v47; // ecx + int *v48; // eax + int v49; // ecx + int *v50; // eax + int v51; // edi + int v52; // edx + unsigned int v53; // edi + int v55; // edi + int v56; // ecx + int *v57; // eax + int *v58; // eax + int v59; // esi + int v61; // esi + int v62; // edi + unsigned int v63; // edi + int v65; // edi + int v66; // ecx + int *v67; // eax + int *v68; // eax + int v69; // esi + int pa; // [esp+Ch] [ebp-4h] - v3 = p; - pa = p; - if (Mid > 28) { - if (Mid == IMISC_MAPOFDOOM) { - doom_init(); - } else if (Mid == IMISC_SPECELIX) { - ModifyPlrStr(p, 3); - ModifyPlrMag(v3, 3); - ModifyPlrDex(v3, 3); - ModifyPlrVit(v3, 3); - } - return; - } - if (Mid == IMISC_HEAL_1C) - goto LABEL_71; - if (Mid <= 12) { - if (Mid == IMISC_ELIXDEX) { - ModifyPlrDex(p, 1); - return; - } - if (Mid == IMISC_FULLHEAL) { - plr[p]._pHitPoints = plr[p]._pMaxHP; - plr[p]._pHPBase = plr[p]._pMaxHPBase; - drawhpflag = TRUE; - return; - } - v5 = Mid - 3; - if (v5) { - v6 = v5 - 3; - if (v6) { - v7 = v6 - 1; - if (v7) { - v8 = v7 - 3; - if (v8) { - if (v8 == 1) - ModifyPlrMag(p, 1); - } else { - ModifyPlrStr(p, 1); - } - return; - } - v9 = p; - if (plr[p]._pIFlags & 0x8000000) - return; - plr[v9]._pMana = plr[v9]._pMaxMana; - plr[v9]._pManaBase = plr[v9]._pMaxManaBase; - LABEL_41: - drawmanaflag = TRUE; - return; - } - v10 = p; - v11 = plr[v10]._pMaxMana >> 8; - v12 = (v11 & 0xFFFFFFFE) + 2 * random(40, v11); - v14 = 32 * v12; - if (plr[v10]._pClass == PC_SORCERER) - v14 *= 2; - if (plr[v10]._pClass == PC_ROGUE) - v14 += v14 >> 1; - if (!(plr[v10]._pIFlags & 0x8000000)) { - v15 = plr[v10]._pMaxMana; - v16 = &plr[v10]._pMana; - *v16 += v14; - if (plr[v10]._pMana > v15) - *v16 = v15; - v17 = &plr[v10]._pManaBase; - v18 = plr[v10]._pMaxManaBase; - *v17 += v14; - if (*v17 > v18) - *v17 = v18; - goto LABEL_41; - } - return; - } - LABEL_71: - v61 = p; - v62 = plr[v61]._pMaxHP >> 8; - v63 = (v62 & 0xFFFFFFFE) + 2 * random(39, v62); - v65 = 32 * v63; - if (plr[v61]._pClass == PC_WARRIOR) - v65 *= 2; - if (plr[v61]._pClass == PC_ROGUE) - v65 += v65 >> 1; - v66 = plr[v61]._pMaxHP; - v67 = &plr[v61]._pHitPoints; - *v67 += v65; - if (plr[v61]._pHitPoints > v66) - *v67 = v66; - v68 = &plr[v61]._pHPBase; - v69 = plr[v61]._pMaxHPBase; - *v68 += v65; - if (*v68 > v69) - *v68 = v69; - drawhpflag = TRUE; - return; - } - if (Mid == IMISC_ELIXVIT) { - ModifyPlrVit(v3, 1); - return; - } - v21 = Mid - 18; - if (v21) { - v22 = v21 - 1; - if (v22) { - v23 = v22 - 2; - if (v23) { - v24 = v23 - 1; - if (v24) { - if (v24 != 2) - return; - v25 = p; - plr[p]._pMemSpells |= (__int64)1 << (spl - 1); - v26 = &plr[p]._pSplLvl[spl]; - if (*v26 < 15) - ++*v26; - v27 = plr[v25]._pMaxMana; - v28 = &plr[v25]._pMana; - v29 = spelldata[spl].sManaCost << 6; - *v28 += v29; - if (plr[v25]._pMana > v27) - *v28 = v27; - v30 = &plr[v25]._pManaBase; - v31 = plr[v25]._pMaxManaBase; - *v30 += v29; - if (*v30 > v31) - *v30 = v31; - if (pa == myplr) - CalcPlrBookVals(pa); - goto LABEL_41; - } - v32 = spl; - if (!spelldata[spl].sTargeted) { - ClrPlrPath(p); - v33 = v3; - plr[v33].destParam1 = cursmx; - v34 = cursmy; - plr[v33]._pSpell = spl; - plr[v33]._pSplType = 4; - plr[v33]._pSplFrom = 3; - plr[v33].destAction = ACTION_SPELL; - plr[v33].destParam2 = v34; - return; - } - } else { - v32 = spl; - if (!spelldata[spl].sTargeted) { - ClrPlrPath(p); - v37 = cursmx; - v38 = v3; - v39 = cursmy; - v36 = v3 == myplr; - plr[v38]._pSpell = spl; - plr[v38]._pSplType = 4; - plr[v38]._pSplFrom = 3; - plr[v38].destAction = ACTION_SPELL; - plr[v38].destParam1 = v37; - plr[v38].destParam2 = v39; - if (v36 && spl == SPL_NOVA) - NetSendCmdLoc(TRUE, CMD_NOVA, v37, v39); - return; - } - } - v35 = p; - v36 = p == myplr; - plr[v35]._pTSpell = v32; - _LOBYTE(plr[v35]._pTSplType) = 4; - if (v36) - SetCursor(CURSOR_TELEPORT); - return; - } - v40 = p; - plr[v40]._pHitPoints = plr[p]._pMaxHP; - plr[v40]._pHPBase = plr[p]._pMaxHPBase; - v36 = (plr[p]._pIFlags & 0x8000000) == 0; - drawhpflag = TRUE; - if (v36) { - v41 = plr[v40]._pMaxMana; - drawmanaflag = TRUE; - plr[v40]._pMana = v41; - plr[v40]._pManaBase = plr[v40]._pMaxManaBase; - } - } else { - v42 = p; - v43 = plr[v42]._pMaxHP >> 8; - v44 = (v43 & 0xFFFFFFFE) + 2 * random(39, v43); - v46 = 32 * v44; - if (plr[v42]._pClass == PC_WARRIOR) - v46 *= 2; - if (plr[v42]._pClass == PC_ROGUE) - v46 += v46 >> 1; - v47 = plr[v42]._pMaxHP; - v48 = &plr[v42]._pHitPoints; - *v48 += v46; - if (plr[v42]._pHitPoints > v47) - *v48 = v47; - v49 = plr[v42]._pMaxHPBase; - v50 = &plr[v42]._pHPBase; - *v50 += v46; - if (plr[v42]._pHPBase > v49) - *v50 = v49; - v51 = plr[v42]._pMaxMana >> 8; - v52 = plr[v42]._pMaxMana >> 8; - drawhpflag = TRUE; - v53 = (v51 & 0xFFFFFFFE) + 2 * random(40, v52); - v55 = 32 * v53; - if (plr[v42]._pClass == PC_SORCERER) - v55 *= 2; - if (plr[v42]._pClass == PC_ROGUE) - v55 += v55 >> 1; - if (!(plr[v42]._pIFlags & 0x8000000)) { - v56 = plr[v42]._pMaxMana; - v57 = &plr[v42]._pMana; - *v57 += v55; - if (plr[v42]._pMana > v56) - *v57 = v56; - v58 = &plr[v42]._pManaBase; - v59 = plr[v42]._pMaxManaBase; - *v58 += v55; - if (*v58 > v59) - *v58 = v59; - drawmanaflag = TRUE; - } - } + v3 = p; + pa = p; + if (Mid > 28) { + if (Mid == IMISC_MAPOFDOOM) { + doom_init(); + } else if (Mid == IMISC_SPECELIX) { + ModifyPlrStr(p, 3); + ModifyPlrMag(v3, 3); + ModifyPlrDex(v3, 3); + ModifyPlrVit(v3, 3); + } + return; + } + if (Mid == IMISC_HEAL_1C) + goto LABEL_71; + if (Mid <= 12) { + if (Mid == IMISC_ELIXDEX) { + ModifyPlrDex(p, 1); + return; + } + if (Mid == IMISC_FULLHEAL) { + plr[p]._pHitPoints = plr[p]._pMaxHP; + plr[p]._pHPBase = plr[p]._pMaxHPBase; + drawhpflag = TRUE; + return; + } + v5 = Mid - 3; + if (v5) { + v6 = v5 - 3; + if (v6) { + v7 = v6 - 1; + if (v7) { + v8 = v7 - 3; + if (v8) { + if (v8 == 1) + ModifyPlrMag(p, 1); + } else { + ModifyPlrStr(p, 1); + } + return; + } + v9 = p; + if (plr[p]._pIFlags & 0x8000000) + return; + plr[v9]._pMana = plr[v9]._pMaxMana; + plr[v9]._pManaBase = plr[v9]._pMaxManaBase; + LABEL_41: + drawmanaflag = TRUE; + return; + } + v10 = p; + v11 = plr[v10]._pMaxMana >> 8; + v12 = (v11 & 0xFFFFFFFE) + 2 * random(40, v11); + v14 = 32 * v12; + if (plr[v10]._pClass == PC_SORCERER) + v14 *= 2; + if (plr[v10]._pClass == PC_ROGUE) + v14 += v14 >> 1; + if (!(plr[v10]._pIFlags & 0x8000000)) { + v15 = plr[v10]._pMaxMana; + v16 = &plr[v10]._pMana; + *v16 += v14; + if (plr[v10]._pMana > v15) + *v16 = v15; + v17 = &plr[v10]._pManaBase; + v18 = plr[v10]._pMaxManaBase; + *v17 += v14; + if (*v17 > v18) + *v17 = v18; + goto LABEL_41; + } + return; + } + LABEL_71: + v61 = p; + v62 = plr[v61]._pMaxHP >> 8; + v63 = (v62 & 0xFFFFFFFE) + 2 * random(39, v62); + v65 = 32 * v63; + if (plr[v61]._pClass == PC_WARRIOR) + v65 *= 2; + if (plr[v61]._pClass == PC_ROGUE) + v65 += v65 >> 1; + v66 = plr[v61]._pMaxHP; + v67 = &plr[v61]._pHitPoints; + *v67 += v65; + if (plr[v61]._pHitPoints > v66) + *v67 = v66; + v68 = &plr[v61]._pHPBase; + v69 = plr[v61]._pMaxHPBase; + *v68 += v65; + if (*v68 > v69) + *v68 = v69; + drawhpflag = TRUE; + return; + } + if (Mid == IMISC_ELIXVIT) { + ModifyPlrVit(v3, 1); + return; + } + v21 = Mid - 18; + if (v21) { + v22 = v21 - 1; + if (v22) { + v23 = v22 - 2; + if (v23) { + v24 = v23 - 1; + if (v24) { + if (v24 != 2) + return; + v25 = p; + plr[p]._pMemSpells |= (__int64)1 << (spl - 1); + v26 = &plr[p]._pSplLvl[spl]; + if (*v26 < 15) + ++*v26; + v27 = plr[v25]._pMaxMana; + v28 = &plr[v25]._pMana; + v29 = spelldata[spl].sManaCost << 6; + *v28 += v29; + if (plr[v25]._pMana > v27) + *v28 = v27; + v30 = &plr[v25]._pManaBase; + v31 = plr[v25]._pMaxManaBase; + *v30 += v29; + if (*v30 > v31) + *v30 = v31; + if (pa == myplr) + CalcPlrBookVals(pa); + goto LABEL_41; + } + v32 = spl; + if (!spelldata[spl].sTargeted) { + ClrPlrPath(p); + v33 = v3; + plr[v33].destParam1 = cursmx; + v34 = cursmy; + plr[v33]._pSpell = spl; + plr[v33]._pSplType = 4; + plr[v33]._pSplFrom = 3; + plr[v33].destAction = ACTION_SPELL; + plr[v33].destParam2 = v34; + return; + } + } else { + v32 = spl; + if (!spelldata[spl].sTargeted) { + ClrPlrPath(p); + v37 = cursmx; + v38 = v3; + v39 = cursmy; + v36 = v3 == myplr; + plr[v38]._pSpell = spl; + plr[v38]._pSplType = 4; + plr[v38]._pSplFrom = 3; + plr[v38].destAction = ACTION_SPELL; + plr[v38].destParam1 = v37; + plr[v38].destParam2 = v39; + if (v36 && spl == SPL_NOVA) + NetSendCmdLoc(TRUE, CMD_NOVA, v37, v39); + return; + } + } + v35 = p; + v36 = p == myplr; + plr[v35]._pTSpell = v32; + _LOBYTE(plr[v35]._pTSplType) = 4; + if (v36) + SetCursor(CURSOR_TELEPORT); + return; + } + v40 = p; + plr[v40]._pHitPoints = plr[p]._pMaxHP; + plr[v40]._pHPBase = plr[p]._pMaxHPBase; + v36 = (plr[p]._pIFlags & 0x8000000) == 0; + drawhpflag = TRUE; + if (v36) { + v41 = plr[v40]._pMaxMana; + drawmanaflag = TRUE; + plr[v40]._pMana = v41; + plr[v40]._pManaBase = plr[v40]._pMaxManaBase; + } + } else { + v42 = p; + v43 = plr[v42]._pMaxHP >> 8; + v44 = (v43 & 0xFFFFFFFE) + 2 * random(39, v43); + v46 = 32 * v44; + if (plr[v42]._pClass == PC_WARRIOR) + v46 *= 2; + if (plr[v42]._pClass == PC_ROGUE) + v46 += v46 >> 1; + v47 = plr[v42]._pMaxHP; + v48 = &plr[v42]._pHitPoints; + *v48 += v46; + if (plr[v42]._pHitPoints > v47) + *v48 = v47; + v49 = plr[v42]._pMaxHPBase; + v50 = &plr[v42]._pHPBase; + *v50 += v46; + if (plr[v42]._pHPBase > v49) + *v50 = v49; + v51 = plr[v42]._pMaxMana >> 8; + v52 = plr[v42]._pMaxMana >> 8; + drawhpflag = TRUE; + v53 = (v51 & 0xFFFFFFFE) + 2 * random(40, v52); + v55 = 32 * v53; + if (plr[v42]._pClass == PC_SORCERER) + v55 *= 2; + if (plr[v42]._pClass == PC_ROGUE) + v55 += v55 >> 1; + if (!(plr[v42]._pIFlags & 0x8000000)) { + v56 = plr[v42]._pMaxMana; + v57 = &plr[v42]._pMana; + *v57 += v55; + if (plr[v42]._pMana > v56) + *v57 = v56; + v58 = &plr[v42]._pManaBase; + v59 = plr[v42]._pMaxManaBase; + *v58 += v55; + if (*v58 > v59) + *v58 = v59; + drawmanaflag = TRUE; + } + } } bool __fastcall StoreStatOk(ItemStruct *h) { - bool sf; // al + bool sf; // al - sf = 1; - if (plr[myplr]._pStrength < h->_iMinStr - || plr[myplr]._pMagic < h->_iMinMag - || plr[myplr]._pDexterity < h->_iMinDex) - sf = 0; - return sf; + sf = 1; + if (plr[myplr]._pStrength < h->_iMinStr + || plr[myplr]._pMagic < h->_iMinMag + || plr[myplr]._pDexterity < h->_iMinDex) + sf = 0; + return sf; } bool __fastcall SmithItemOk(int i) { - unsigned char v1; // cl - bool rv; // eax + unsigned char v1; // cl + bool rv; // eax - v1 = AllItemsList[i].itype; - rv = 1; - if (!v1 || v1 == ITYPE_GOLD || v1 == ITYPE_0E || v1 == ITYPE_STAFF || v1 == ITYPE_RING || v1 == ITYPE_AMULET) - rv = 0; - return rv; + v1 = AllItemsList[i].itype; + rv = 1; + if (!v1 || v1 == ITYPE_GOLD || v1 == ITYPE_0E || v1 == ITYPE_STAFF || v1 == ITYPE_RING || v1 == ITYPE_AMULET) + rv = 0; + return rv; } int __fastcall RndSmithItem(int lvl) { - int ri; // edx - int i; // edi - int ril[512]; // [esp+4h] [ebp-804h] + int ri; // edx + int i; // edi + int ril[512]; // [esp+4h] [ebp-804h] - ri = 0; - i = 1; - if (AllItemsList[1].iLoc != -1) { - do { - if (AllItemsList[i].iRnd && SmithItemOk(i) && lvl >= AllItemsList[i].iMinMLvl) { - ril[ri++] = i; - if (AllItemsList[i].iRnd == 2) - ril[ri++] = i; - } - ++i; - } while (AllItemsList[i].iLoc != -1); - } - return ril[random(50, ri)] + 1; + ri = 0; + i = 1; + if (AllItemsList[1].iLoc != -1) { + do { + if (AllItemsList[i].iRnd && SmithItemOk(i) && lvl >= AllItemsList[i].iMinMLvl) { + ril[ri++] = i; + if (AllItemsList[i].iRnd == 2) + ril[ri++] = i; + } + ++i; + } while (AllItemsList[i].iLoc != -1); + } + return ril[random(50, ri)] + 1; } // 424252: using guessed type int var_804[512]; void __fastcall BubbleSwapItem(ItemStruct *a, ItemStruct *b) { - ItemStruct h; // [esp+8h] [ebp-170h] + ItemStruct h; // [esp+8h] [ebp-170h] - qmemcpy(&h, a, sizeof(h)); - qmemcpy(a, b, sizeof(ItemStruct)); - qmemcpy(b, &h, sizeof(ItemStruct)); + qmemcpy(&h, a, sizeof(h)); + qmemcpy(a, b, sizeof(ItemStruct)); + qmemcpy(b, &h, sizeof(ItemStruct)); } void __cdecl SortSmith() { - int v0; // esi - int *v1; // eax - signed int v2; // ecx - int *v3; // eax - int v4; // ebx - int v5; // edi + int v0; // esi + int *v1; // eax + signed int v2; // ecx + int *v3; // eax + int v4; // ebx + int v5; // edi - v0 = 0; - if (smithitem[1]._itype != -1) { - v1 = &smithitem[1]._itype; - do { - v1 += 92; - ++v0; - } while (*v1 != -1); - } - v2 = 0; - while (v0 > 0 && !v2) { - v2 = 1; - if (v0 > 0) { - v3 = &smithitem[0].IDidx; - v4 = v0; - do { - v5 = (int)(v3 + 92); - if (*v3 > v3[92]) { - BubbleSwapItem((ItemStruct *)(v3 - 90), (ItemStruct *)(v3 + 2)); - v2 = 0; - } - --v4; - v3 = (int *)v5; - } while (v4); - } - --v0; - } + v0 = 0; + if (smithitem[1]._itype != -1) { + v1 = &smithitem[1]._itype; + do { + v1 += 92; + ++v0; + } while (*v1 != -1); + } + v2 = 0; + while (v0 > 0 && !v2) { + v2 = 1; + if (v0 > 0) { + v3 = &smithitem[0].IDidx; + v4 = v0; + do { + v5 = (int)(v3 + 92); + if (*v3 > v3[92]) { + BubbleSwapItem((ItemStruct *)(v3 - 90), (ItemStruct *)(v3 + 2)); + v2 = 0; + } + --v4; + v3 = (int *)v5; + } while (v4); + } + --v0; + } } void __fastcall SpawnSmith(int lvl) { - int v3; // ebp - ItemStruct *v4; // ebx - int v9; // [esp+Ch] [ebp-8h] + int v3; // ebp + ItemStruct *v4; // ebx + int v9; // [esp+Ch] [ebp-8h] - v3 = random(50, 10) + 10; - if (v3 > 0) { - v4 = smithitem; - v9 = v3; - while (1) { - do { - item[0]._iSeed = GetRndSeed(); - SetRndSeed(item[0]._iSeed); - GetItemAttrs(0, RndSmithItem(lvl) - 1, lvl); - } while (item[0]._iIvalue > 140000); - qmemcpy(v4, item, sizeof(ItemStruct)); - v4->_iCreateInfo = lvl | 0x400; - v4->_iIdentified = TRUE; - v4->_iStatFlag = StoreStatOk(v4); - ++v4; - if (!--v9) - break; - } - } - if (v3 < 20) { - do { - smithitem[v3]._itype = -1; - v3++; - } while (v3 < 20); - } - SortSmith(); + v3 = random(50, 10) + 10; + if (v3 > 0) { + v4 = smithitem; + v9 = v3; + while (1) { + do { + item[0]._iSeed = GetRndSeed(); + SetRndSeed(item[0]._iSeed); + GetItemAttrs(0, RndSmithItem(lvl) - 1, lvl); + } while (item[0]._iIvalue > 140000); + qmemcpy(v4, item, sizeof(ItemStruct)); + v4->_iCreateInfo = lvl | 0x400; + v4->_iIdentified = TRUE; + v4->_iStatFlag = StoreStatOk(v4); + ++v4; + if (!--v9) + break; + } + } + if (v3 < 20) { + do { + smithitem[v3]._itype = -1; + v3++; + } while (v3 < 20); + } + SortSmith(); } bool __fastcall PremiumItemOk(int i) { - unsigned char v1; // cl - bool rv; // eax + unsigned char v1; // cl + bool rv; // eax - v1 = AllItemsList[i].itype; - rv = 1; - if (!v1 || v1 == ITYPE_GOLD || v1 == ITYPE_0E || v1 == ITYPE_STAFF) - rv = 0; - if (gbMaxPlayers != 1 && (v1 == ITYPE_RING || v1 == ITYPE_AMULET)) { - rv = 0; - } - return rv; + v1 = AllItemsList[i].itype; + rv = 1; + if (!v1 || v1 == ITYPE_GOLD || v1 == ITYPE_0E || v1 == ITYPE_STAFF) + rv = 0; + if (gbMaxPlayers != 1 && (v1 == ITYPE_RING || v1 == ITYPE_AMULET)) { + rv = 0; + } + return rv; } // 679660: using guessed type char gbMaxPlayers; int __fastcall RndPremiumItem(int minlvl, int maxlvl) { - int ri; // edx - int i; // edi - int ril[512]; // [esp+8h] [ebp-804h] + int ri; // edx + int i; // edi + int ril[512]; // [esp+8h] [ebp-804h] - ri = 0; - i = 1; - if (AllItemsList[1].iLoc != -1) { - do { - if (AllItemsList[i].iRnd) { - if (PremiumItemOk(i)) { - if (AllItemsList[i].iMinMLvl >= minlvl && AllItemsList[i].iMinMLvl <= maxlvl) - ril[ri++] = i; - } - } - ++i; - } while (AllItemsList[i].iLoc != -1); - } - return ril[random(50, ri)] + 1; + ri = 0; + i = 1; + if (AllItemsList[1].iLoc != -1) { + do { + if (AllItemsList[i].iRnd) { + if (PremiumItemOk(i)) { + if (AllItemsList[i].iMinMLvl >= minlvl && AllItemsList[i].iMinMLvl <= maxlvl) + ril[ri++] = i; + } + } + ++i; + } while (AllItemsList[i].iLoc != -1); + } + return ril[random(50, ri)] + 1; } // 42445F: using guessed type int ril[512]; void __fastcall SpawnOnePremium(int i, int plvl) { - int itype; // esi - ItemStruct holditem; // [esp+Ch] [ebp-178h] + int itype; // esi + ItemStruct holditem; // [esp+Ch] [ebp-178h] - qmemcpy(&holditem, item, sizeof(ItemStruct)); - if (plvl > 30) - plvl = 30; - if (plvl < 1) - plvl = 1; - do { - item[0]._iSeed = GetRndSeed(); - SetRndSeed(item[0]._iSeed); - itype = RndPremiumItem(plvl >> 2, plvl) - 1; - GetItemAttrs(0, itype, plvl); - GetItemBonus(0, itype, plvl >> 1, plvl, 1); - } while (item[0]._iIvalue > 140000); - qmemcpy(&premiumitem[i], item, sizeof(ItemStruct)); - premiumitem[i]._iCreateInfo = plvl | 0x800; - premiumitem[i]._iIdentified = TRUE; - premiumitem[i]._iStatFlag = StoreStatOk(&premiumitem[i]); - qmemcpy(item, &holditem, sizeof(ItemStruct)); + qmemcpy(&holditem, item, sizeof(ItemStruct)); + if (plvl > 30) + plvl = 30; + if (plvl < 1) + plvl = 1; + do { + item[0]._iSeed = GetRndSeed(); + SetRndSeed(item[0]._iSeed); + itype = RndPremiumItem(plvl >> 2, plvl) - 1; + GetItemAttrs(0, itype, plvl); + GetItemBonus(0, itype, plvl >> 1, plvl, 1); + } while (item[0]._iIvalue > 140000); + qmemcpy(&premiumitem[i], item, sizeof(ItemStruct)); + premiumitem[i]._iCreateInfo = plvl | 0x800; + premiumitem[i]._iIdentified = TRUE; + premiumitem[i]._iStatFlag = StoreStatOk(&premiumitem[i]); + qmemcpy(item, &holditem, sizeof(ItemStruct)); } void __fastcall SpawnPremium(int lvl) { - int i; // eax + int i; // eax - if (numpremium < 6) { - for (i = 0; i < 6; i++) { - if (premiumitem[i]._itype == -1) - SpawnOnePremium(i, premiumlevel + premiumlvladd[i]); - } - numpremium = 6; - } - for (i = premiumlevel; premiumlevel < lvl; i = premiumlevel) { - qmemcpy(premiumitem, &premiumitem[2], sizeof(ItemStruct)); - qmemcpy(&premiumitem[1], &premiumitem[3], sizeof(ItemStruct)); - qmemcpy(&premiumitem[2], &premiumitem[4], sizeof(ItemStruct)); - premiumlevel = i + 1; - SpawnOnePremium(3, premiumlvladd[3] + i + 1); - qmemcpy(&premiumitem[4], &premiumitem[5], sizeof(ItemStruct)); - SpawnOnePremium(5, premiumlvladd[5] + premiumlevel); - } + if (numpremium < 6) { + for (i = 0; i < 6; i++) { + if (premiumitem[i]._itype == -1) + SpawnOnePremium(i, premiumlevel + premiumlvladd[i]); + } + numpremium = 6; + } + for (i = premiumlevel; premiumlevel < lvl; i = premiumlevel) { + qmemcpy(premiumitem, &premiumitem[2], sizeof(ItemStruct)); + qmemcpy(&premiumitem[1], &premiumitem[3], sizeof(ItemStruct)); + qmemcpy(&premiumitem[2], &premiumitem[4], sizeof(ItemStruct)); + premiumlevel = i + 1; + SpawnOnePremium(3, premiumlvladd[3] + i + 1); + qmemcpy(&premiumitem[4], &premiumitem[5], sizeof(ItemStruct)); + SpawnOnePremium(5, premiumlvladd[5] + premiumlevel); + } } // 69FB38: using guessed type int talker; bool __fastcall WitchItemOk(int i) { - bool rv; // eax - unsigned char v3; // dl - int v4; // edx - int v5; // ecx + bool rv; // eax + unsigned char v3; // dl + int v4; // edx + int v5; // ecx - rv = 0; - v3 = AllItemsList[i].itype; - if (!v3) - rv = 1; - if (v3 == ITYPE_STAFF) - rv = 1; - v4 = AllItemsList[i].iMiscId; - if (v4 == IMISC_MANA) - rv = 0; - if (v4 == IMISC_FULLMANA) - rv = 0; - if (v4 == IMISC_FULLHEAL) - rv = 0; - if (v4 == IMISC_HEAL) - rv = 0; - v5 = AllItemsList[i].iSpell; - if (v5 == SPL_TOWN) - rv = 0; - if (v5 == SPL_RESURRECT && gbMaxPlayers == 1) - rv = 0; - if (v5 == SPL_HEALOTHER && gbMaxPlayers == 1) - rv = 0; - return rv; + rv = 0; + v3 = AllItemsList[i].itype; + if (!v3) + rv = 1; + if (v3 == ITYPE_STAFF) + rv = 1; + v4 = AllItemsList[i].iMiscId; + if (v4 == IMISC_MANA) + rv = 0; + if (v4 == IMISC_FULLMANA) + rv = 0; + if (v4 == IMISC_FULLHEAL) + rv = 0; + if (v4 == IMISC_HEAL) + rv = 0; + v5 = AllItemsList[i].iSpell; + if (v5 == SPL_TOWN) + rv = 0; + if (v5 == SPL_RESURRECT && gbMaxPlayers == 1) + rv = 0; + if (v5 == SPL_HEALOTHER && gbMaxPlayers == 1) + rv = 0; + return rv; } // 679660: using guessed type char gbMaxPlayers; int __fastcall RndWitchItem(int lvl) { - int ri; // ebx - int i; // edi - int ril[512]; // [esp+8h] [ebp-804h] + int ri; // ebx + int i; // edi + int ril[512]; // [esp+8h] [ebp-804h] - ri = 0; - i = 1; - if (AllItemsList[1].iLoc != -1) { - do { - if (AllItemsList[i].iRnd && WitchItemOk(i) && lvl >= AllItemsList[i].iMinMLvl) - ril[ri++] = i; - ++i; - } while (AllItemsList[i].iLoc != -1); - } - return ril[random(51, ri)] + 1; + ri = 0; + i = 1; + if (AllItemsList[1].iLoc != -1) { + do { + if (AllItemsList[i].iRnd && WitchItemOk(i) && lvl >= AllItemsList[i].iMinMLvl) + ril[ri++] = i; + ++i; + } while (AllItemsList[i].iLoc != -1); + } + return ril[random(51, ri)] + 1; } // 4246D2: using guessed type int var_804[512]; void __cdecl SortWitch() { - signed int v0; // esi - int *v1; // eax - signed int v2; // ecx - int *v3; // eax - int v4; // ebx - int v5; // edi + signed int v0; // esi + int *v1; // eax + signed int v2; // ecx + int *v3; // eax + int v4; // ebx + int v5; // edi - v0 = 3; - if (witchitem[4]._itype != -1) { - v1 = &witchitem[4]._itype; - do { - v1 += 92; - ++v0; - } while (*v1 != -1); - } - v2 = 0; - while (v0 > 3 && !v2) { - v2 = 1; - if (v0 > 3) { - v3 = &witchitem[3].IDidx; - v4 = v0 - 3; - do { - v5 = (int)(v3 + 92); - if (*v3 > v3[92]) { - BubbleSwapItem((ItemStruct *)(v3 - 90), (ItemStruct *)(v3 + 2)); - v2 = 0; - } - --v4; - v3 = (int *)v5; - } while (v4); - } - --v0; - } + v0 = 3; + if (witchitem[4]._itype != -1) { + v1 = &witchitem[4]._itype; + do { + v1 += 92; + ++v0; + } while (*v1 != -1); + } + v2 = 0; + while (v0 > 3 && !v2) { + v2 = 1; + if (v0 > 3) { + v3 = &witchitem[3].IDidx; + v4 = v0 - 3; + do { + v5 = (int)(v3 + 92); + if (*v3 > v3[92]) { + BubbleSwapItem((ItemStruct *)(v3 - 90), (ItemStruct *)(v3 + 2)); + v2 = 0; + } + --v4; + v3 = (int *)v5; + } while (v4); + } + --v0; + } } void __fastcall WitchBookLevel(int ii) { - int slvl; // edi + int slvl; // edi - if (witchitem[ii]._iMiscId == IMISC_BOOK) { - witchitem[ii]._iMinMag = spelldata[witchitem[ii]._iSpell].sMinInt; - slvl = plr[myplr]._pSplLvl[witchitem[ii]._iSpell]; - if (slvl) { - do { - witchitem[ii]._iMinMag += 20 * witchitem[ii]._iMinMag / 100; - --slvl; - if (witchitem[ii]._iMinMag > 255) { - witchitem[ii]._iMinMag = -1; - slvl = 0; - } - } while (slvl); - } - } + if (witchitem[ii]._iMiscId == IMISC_BOOK) { + witchitem[ii]._iMinMag = spelldata[witchitem[ii]._iSpell].sMinInt; + slvl = plr[myplr]._pSplLvl[witchitem[ii]._iSpell]; + if (slvl) { + do { + witchitem[ii]._iMinMag += 20 * witchitem[ii]._iMinMag / 100; + --slvl; + if (witchitem[ii]._iMinMag > 255) { + witchitem[ii]._iMinMag = -1; + slvl = 0; + } + } while (slvl); + } + } } void __fastcall SpawnWitch(int lvl) { - int v2; // ebp - int itype; // esi - int iblvl; // eax - signed int ii; // [esp+10h] [ebp-8h] - ItemStruct *itm; // [esp+14h] [ebp-4h] + int v2; // ebp + int itype; // esi + int iblvl; // eax + signed int ii; // [esp+10h] [ebp-8h] + ItemStruct *itm; // [esp+14h] [ebp-4h] - GetItemAttrs(0, IDI_MANA, 1); - qmemcpy(witchitem, item, sizeof(ItemStruct)); - witchitem[0]._iCreateInfo = lvl; - witchitem[0]._iStatFlag = 1; - GetItemAttrs(0, IDI_FULLMANA, 1); - qmemcpy(&witchitem[1], item, sizeof(ItemStruct)); - witchitem[1]._iCreateInfo = lvl; - witchitem[1]._iStatFlag = 1; - GetItemAttrs(0, IDI_PORTAL, 1); - qmemcpy(&witchitem[2], item, sizeof(ItemStruct)); - witchitem[2]._iCreateInfo = lvl; - witchitem[2]._iStatFlag = 1; - v2 = random(51, 8) + 10; - ii = 3; - if (v2 > 3) { - itm = &witchitem[3]; - while (1) { - item[0]._iSeed = GetRndSeed(); - SetRndSeed(item[0]._iSeed); - itype = RndWitchItem(lvl) - 1; - GetItemAttrs(0, itype, lvl); - if (random(51, 100) > 5 || (iblvl = 2 * lvl, iblvl == -1)) { - if (item[0]._iMiscId != IMISC_STAFF) - continue; - iblvl = 2 * lvl; - if (iblvl == -1) - continue; - } - GetItemBonus(0, itype, iblvl >> 1, iblvl, 1); - if (item[0]._iIvalue <= 140000) { - qmemcpy(itm, item, sizeof(ItemStruct)); - itm->_iIdentified = TRUE; - itm->_iCreateInfo = lvl | 0x2000; - WitchBookLevel(ii); - ++ii; - itm->_iStatFlag = StoreStatOk(itm); - ++itm; - if (ii >= v2) - break; - } - } - } - if (v2 < 20) { - do { - witchitem[v2]._itype = -1; - v2++; - } while (v2 < 20); - } - SortWitch(); + GetItemAttrs(0, IDI_MANA, 1); + qmemcpy(witchitem, item, sizeof(ItemStruct)); + witchitem[0]._iCreateInfo = lvl; + witchitem[0]._iStatFlag = 1; + GetItemAttrs(0, IDI_FULLMANA, 1); + qmemcpy(&witchitem[1], item, sizeof(ItemStruct)); + witchitem[1]._iCreateInfo = lvl; + witchitem[1]._iStatFlag = 1; + GetItemAttrs(0, IDI_PORTAL, 1); + qmemcpy(&witchitem[2], item, sizeof(ItemStruct)); + witchitem[2]._iCreateInfo = lvl; + witchitem[2]._iStatFlag = 1; + v2 = random(51, 8) + 10; + ii = 3; + if (v2 > 3) { + itm = &witchitem[3]; + while (1) { + item[0]._iSeed = GetRndSeed(); + SetRndSeed(item[0]._iSeed); + itype = RndWitchItem(lvl) - 1; + GetItemAttrs(0, itype, lvl); + if (random(51, 100) > 5 || (iblvl = 2 * lvl, iblvl == -1)) { + if (item[0]._iMiscId != IMISC_STAFF) + continue; + iblvl = 2 * lvl; + if (iblvl == -1) + continue; + } + GetItemBonus(0, itype, iblvl >> 1, iblvl, 1); + if (item[0]._iIvalue <= 140000) { + qmemcpy(itm, item, sizeof(ItemStruct)); + itm->_iIdentified = TRUE; + itm->_iCreateInfo = lvl | 0x2000; + WitchBookLevel(ii); + ++ii; + itm->_iStatFlag = StoreStatOk(itm); + ++itm; + if (ii >= v2) + break; + } + } + } + if (v2 < 20) { + do { + witchitem[v2]._itype = -1; + v2++; + } while (v2 < 20); + } + SortWitch(); } int __fastcall RndBoyItem(int lvl) { - int ri; // edx - int i; // edi - int ril[512]; // [esp+8h] [ebp-800h] + int ri; // edx + int i; // edi + int ril[512]; // [esp+8h] [ebp-800h] - ri = 0; - i = 1; - if (AllItemsList[1].iLoc != -1) { - do { - if (AllItemsList[i].iRnd && PremiumItemOk(i) && lvl >= AllItemsList[i].iMinMLvl) - ril[ri++] = i; - ++i; - } while (AllItemsList[i].iLoc != -1); - } - return ril[random(49, ri)] + 1; + ri = 0; + i = 1; + if (AllItemsList[1].iLoc != -1) { + do { + if (AllItemsList[i].iRnd && PremiumItemOk(i) && lvl >= AllItemsList[i].iMinMLvl) + ril[ri++] = i; + ++i; + } while (AllItemsList[i].iLoc != -1); + } + return ril[random(49, ri)] + 1; } // 4249A4: using guessed type int var_800[512]; void __fastcall SpawnBoy(int lvl) { - int itype; // esi + int itype; // esi - if (boylevel> 1 || boyitem._itype == -1) { - do { - item[0]._iSeed = GetRndSeed(); - SetRndSeed(item[0]._iSeed); - itype = RndBoyItem(lvl) - 1; - GetItemAttrs(0, itype, lvl); - GetItemBonus(0, itype, lvl, 2 * lvl, 1); - } while (item[0]._iIvalue > 90000); - qmemcpy(&boyitem, item, sizeof(boyitem)); - boyitem._iCreateInfo = lvl | 0x10; - boyitem._iIdentified = TRUE; - boyitem._iStatFlag = StoreStatOk(&boyitem); - boylevel = lvl >> 1; - } + if (boylevel> 1 || boyitem._itype == -1) { + do { + item[0]._iSeed = GetRndSeed(); + SetRndSeed(item[0]._iSeed); + itype = RndBoyItem(lvl) - 1; + GetItemAttrs(0, itype, lvl); + GetItemBonus(0, itype, lvl, 2 * lvl, 1); + } while (item[0]._iIvalue > 90000); + qmemcpy(&boyitem, item, sizeof(boyitem)); + boyitem._iCreateInfo = lvl | 0x10; + boyitem._iIdentified = TRUE; + boyitem._iStatFlag = StoreStatOk(&boyitem); + boylevel = lvl >> 1; + } } // 6A8A3C: using guessed type int boylevel; bool __fastcall HealerItemOk(int i) { - int v1; // ecx - bool result; // eax - int v3; // esi + int v1; // ecx + bool result; // eax + int v3; // esi - v1 = i; - result = 0; - if (AllItemsList[v1].itype) - return 0; - v3 = AllItemsList[v1].iMiscId; - if (v3 == IMISC_SCROLL && AllItemsList[v1].iSpell == SPL_HEAL) - result = 1; - if (v3 != IMISC_SCROLLT) - goto LABEL_12; - if (AllItemsList[v1].iSpell == SPL_RESURRECT && gbMaxPlayers != 1) - result = 0; - if (AllItemsList[v1].iSpell != SPL_HEALOTHER) { - LABEL_12: - if (gbMaxPlayers != 1) - goto LABEL_21; - goto LABEL_13; - } - if (gbMaxPlayers != 1) { - result = 1; - goto LABEL_12; - } + v1 = i; + result = 0; + if (AllItemsList[v1].itype) + return 0; + v3 = AllItemsList[v1].iMiscId; + if (v3 == IMISC_SCROLL && AllItemsList[v1].iSpell == SPL_HEAL) + result = 1; + if (v3 != IMISC_SCROLLT) + goto LABEL_12; + if (AllItemsList[v1].iSpell == SPL_RESURRECT && gbMaxPlayers != 1) + result = 0; + if (AllItemsList[v1].iSpell != SPL_HEALOTHER) { + LABEL_12: + if (gbMaxPlayers != 1) + goto LABEL_21; + goto LABEL_13; + } + if (gbMaxPlayers != 1) { + result = 1; + goto LABEL_12; + } LABEL_13: - if (v3 == IMISC_ELIXSTR) - result = 1; - if (v3 == IMISC_ELIXMAG) - result = 1; - if (v3 == IMISC_ELIXDEX) - result = 1; - if (v3 == IMISC_ELIXVIT) - result = 1; + if (v3 == IMISC_ELIXSTR) + result = 1; + if (v3 == IMISC_ELIXMAG) + result = 1; + if (v3 == IMISC_ELIXDEX) + result = 1; + if (v3 == IMISC_ELIXVIT) + result = 1; LABEL_21: - if (v3 == IMISC_FULLHEAL) - result = 1; - if (v3 == IMISC_REJUV) - result = 1; - if (v3 == IMISC_FULLREJUV) - result = 1; - if (v3 == IMISC_HEAL) - result = 0; - if (v3 == IMISC_FULLHEAL) - result = 0; - if (v3 == IMISC_MANA) - result = 0; - if (v3 == IMISC_FULLMANA) - return 0; - return result; + if (v3 == IMISC_FULLHEAL) + result = 1; + if (v3 == IMISC_REJUV) + result = 1; + if (v3 == IMISC_FULLREJUV) + result = 1; + if (v3 == IMISC_HEAL) + result = 0; + if (v3 == IMISC_FULLHEAL) + result = 0; + if (v3 == IMISC_MANA) + result = 0; + if (v3 == IMISC_FULLMANA) + return 0; + return result; } // 679660: using guessed type char gbMaxPlayers; int __fastcall RndHealerItem(int lvl) { - int ri; // ebx - int i; // edi - int ril[512]; // [esp+8h] [ebp-804h] + int ri; // ebx + int i; // edi + int ril[512]; // [esp+8h] [ebp-804h] - ri = 0; - i = 1; - if (AllItemsList[1].iLoc != -1) { - do { - if (AllItemsList[i].iRnd && HealerItemOk(i) && lvl >= AllItemsList[i].iMinMLvl) - ril[ri++] = i; - ++i; - } while (AllItemsList[i].iLoc != -1); - } - return ril[random(50, ri)] + 1; + ri = 0; + i = 1; + if (AllItemsList[1].iLoc != -1) { + do { + if (AllItemsList[i].iRnd && HealerItemOk(i) && lvl >= AllItemsList[i].iMinMLvl) + ril[ri++] = i; + ++i; + } while (AllItemsList[i].iLoc != -1); + } + return ril[random(50, ri)] + 1; } // 424B49: using guessed type int var_804[512]; void __cdecl SortHealer() { - signed int v0; // esi - int *v1; // eax - signed int v2; // ecx - int *v3; // eax - int v4; // ebx - int v5; // edi + signed int v0; // esi + int *v1; // eax + signed int v2; // ecx + int *v3; // eax + int v4; // ebx + int v5; // edi - v0 = 2; - if (healitem[3]._itype != -1) { - v1 = &healitem[3]._itype; - do { - v1 += 92; - ++v0; - } while (*v1 != -1); - } - v2 = 0; - while (v0 > 2 && !v2) { - v2 = 1; - if (v0 > 2) { - v3 = &healitem[2].IDidx; - v4 = v0 - 2; - do { - v5 = (int)(v3 + 92); - if (*v3 > v3[92]) { - BubbleSwapItem((ItemStruct *)(v3 - 90), (ItemStruct *)(v3 + 2)); - v2 = 0; - } - --v4; - v3 = (int *)v5; - } while (v4); - } - --v0; - } + v0 = 2; + if (healitem[3]._itype != -1) { + v1 = &healitem[3]._itype; + do { + v1 += 92; + ++v0; + } while (*v1 != -1); + } + v2 = 0; + while (v0 > 2 && !v2) { + v2 = 1; + if (v0 > 2) { + v3 = &healitem[2].IDidx; + v4 = v0 - 2; + do { + v5 = (int)(v3 + 92); + if (*v3 > v3[92]) { + BubbleSwapItem((ItemStruct *)(v3 - 90), (ItemStruct *)(v3 + 2)); + v2 = 0; + } + --v4; + v3 = (int *)v5; + } while (v4); + } + --v0; + } } void __fastcall SpawnHealer(int lvl) { - int v3; // eax - ItemStruct *v4; // ebp - signed int v8; // [esp-4h] [ebp-20h] - int v10; // [esp+14h] [ebp-8h] + int v3; // eax + ItemStruct *v4; // ebp + signed int v8; // [esp-4h] [ebp-20h] + int v10; // [esp+14h] [ebp-8h] - GetItemAttrs(0, IDI_HEAL, 1); - qmemcpy(healitem, item, sizeof(ItemStruct)); - healitem[0]._iCreateInfo = lvl; - healitem[0]._iStatFlag = 1; - GetItemAttrs(0, IDI_FULLHEAL, 1); - qmemcpy(&healitem[1], item, sizeof(ItemStruct)); - healitem[1]._iCreateInfo = lvl; - healitem[1]._iStatFlag = 1; - if (gbMaxPlayers == 1) { - v8 = 2; - } else { - GetItemAttrs(0, IDI_RESURRECT, 1); - qmemcpy(&healitem[2], item, sizeof(ItemStruct)); - healitem[2]._iCreateInfo = lvl; - healitem[2]._iStatFlag = 1; - v8 = 3; - } - v3 = random(50, 8) + 10; - if (v8 < v3) { - v4 = &healitem[v8]; - v10 = v3 - v8; - do { - item[0]._iSeed = GetRndSeed(); - SetRndSeed(item[0]._iSeed); - GetItemAttrs(0, RndHealerItem(lvl) - 1, lvl); - qmemcpy(v4, item, sizeof(ItemStruct)); - v4->_iCreateInfo = lvl | 0x4000; - v4->_iIdentified = TRUE; - v4->_iStatFlag = StoreStatOk(v4); - ++v4; - --v10; - } while (v10); - } - if (v3 < 20) { - do { - healitem[v3]._itype = -1; - v3++; - } while (v3 < 20); - } - SortHealer(); + GetItemAttrs(0, IDI_HEAL, 1); + qmemcpy(healitem, item, sizeof(ItemStruct)); + healitem[0]._iCreateInfo = lvl; + healitem[0]._iStatFlag = 1; + GetItemAttrs(0, IDI_FULLHEAL, 1); + qmemcpy(&healitem[1], item, sizeof(ItemStruct)); + healitem[1]._iCreateInfo = lvl; + healitem[1]._iStatFlag = 1; + if (gbMaxPlayers == 1) { + v8 = 2; + } else { + GetItemAttrs(0, IDI_RESURRECT, 1); + qmemcpy(&healitem[2], item, sizeof(ItemStruct)); + healitem[2]._iCreateInfo = lvl; + healitem[2]._iStatFlag = 1; + v8 = 3; + } + v3 = random(50, 8) + 10; + if (v8 < v3) { + v4 = &healitem[v8]; + v10 = v3 - v8; + do { + item[0]._iSeed = GetRndSeed(); + SetRndSeed(item[0]._iSeed); + GetItemAttrs(0, RndHealerItem(lvl) - 1, lvl); + qmemcpy(v4, item, sizeof(ItemStruct)); + v4->_iCreateInfo = lvl | 0x4000; + v4->_iIdentified = TRUE; + v4->_iStatFlag = StoreStatOk(v4); + ++v4; + --v10; + } while (v10); + } + if (v3 < 20) { + do { + healitem[v3]._itype = -1; + v3++; + } while (v3 < 20); + } + SortHealer(); } // 679660: using guessed type char gbMaxPlayers; void __cdecl SpawnStoreGold() { - GetItemAttrs(0, IDI_GOLD, 1); - qmemcpy(&golditem, item, sizeof(golditem)); - golditem._iStatFlag = 1; + GetItemAttrs(0, IDI_GOLD, 1); + qmemcpy(&golditem, item, sizeof(golditem)); + golditem._iStatFlag = 1; } void __fastcall RecreateSmithItem(int ii, int idx, int plvl, int iseed) { - SetRndSeed(iseed); - GetItemAttrs(ii, RndSmithItem(plvl) - 1, plvl); - item[ii]._iSeed = iseed; - item[ii]._iCreateInfo = plvl | 0x400; - item[ii]._iIdentified = TRUE; + SetRndSeed(iseed); + GetItemAttrs(ii, RndSmithItem(plvl) - 1, plvl); + item[ii]._iSeed = iseed; + item[ii]._iCreateInfo = plvl | 0x400; + item[ii]._iIdentified = TRUE; } void __fastcall RecreatePremiumItem(int ii, int idx, int lvl, int iseed) { - int itype; // edi + int itype; // edi - SetRndSeed(iseed); - itype = RndPremiumItem(lvl >> 2, lvl) - 1; - GetItemAttrs(ii, itype, lvl); - GetItemBonus(ii, itype, lvl >> 1, lvl, 1); - item[ii]._iCreateInfo = lvl | 0x800; - item[ii]._iSeed = iseed; - item[ii]._iIdentified = TRUE; + SetRndSeed(iseed); + itype = RndPremiumItem(lvl >> 2, lvl) - 1; + GetItemAttrs(ii, itype, lvl); + GetItemBonus(ii, itype, lvl >> 1, lvl, 1); + item[ii]._iCreateInfo = lvl | 0x800; + item[ii]._iSeed = iseed; + item[ii]._iIdentified = TRUE; } void __fastcall RecreateBoyItem(int ii, int idx, int lvl, int iseed) { - int itype; // edi + int itype; // edi - SetRndSeed(iseed); - itype = RndBoyItem(lvl) - 1; - GetItemAttrs(ii, itype, lvl); - GetItemBonus(ii, itype, lvl, 2 * lvl, 1); - item[ii]._iCreateInfo = lvl | 0x1000; - item[ii]._iSeed = iseed; - item[ii]._iIdentified = TRUE; + SetRndSeed(iseed); + itype = RndBoyItem(lvl) - 1; + GetItemAttrs(ii, itype, lvl); + GetItemBonus(ii, itype, lvl, 2 * lvl, 1); + item[ii]._iCreateInfo = lvl | 0x1000; + item[ii]._iSeed = iseed; + item[ii]._iIdentified = TRUE; } void __fastcall RecreateWitchItem(int ii, int idx, int lvl, int iseed) { - int itype; // edi - int iblvl; // eax + int itype; // edi + int iblvl; // eax - if (idx == IDI_MANA || idx == IDI_FULLMANA || idx == IDI_PORTAL) { - GetItemAttrs(ii, idx, lvl); - } else { - SetRndSeed(iseed); - itype = RndWitchItem(lvl) - 1; - GetItemAttrs(ii, itype, lvl); - iblvl = 2 * lvl; - if (iblvl != -1 && (random(51, 100) <= 5 || item[ii]._iMiscId == IMISC_STAFF)) { - GetItemBonus(ii, itype, iblvl >> 1, iblvl, 1); - } - } - item[ii]._iCreateInfo = lvl | 0x2000; - item[ii]._iSeed = iseed; - item[ii]._iIdentified = TRUE; + if (idx == IDI_MANA || idx == IDI_FULLMANA || idx == IDI_PORTAL) { + GetItemAttrs(ii, idx, lvl); + } else { + SetRndSeed(iseed); + itype = RndWitchItem(lvl) - 1; + GetItemAttrs(ii, itype, lvl); + iblvl = 2 * lvl; + if (iblvl != -1 && (random(51, 100) <= 5 || item[ii]._iMiscId == IMISC_STAFF)) { + GetItemBonus(ii, itype, iblvl >> 1, iblvl, 1); + } + } + item[ii]._iCreateInfo = lvl | 0x2000; + item[ii]._iSeed = iseed; + item[ii]._iIdentified = TRUE; } void __fastcall RecreateHealerItem(int ii, int idx, int lvl, int iseed) { - if (idx != IDI_HEAL && idx != IDI_FULLHEAL && idx != IDI_RESURRECT) { - SetRndSeed(iseed); - idx = RndHealerItem(lvl) - 1; - } - GetItemAttrs(ii, idx, lvl); - item[ii]._iCreateInfo = lvl | 0x4000; - item[ii]._iSeed = iseed; - item[ii]._iIdentified = TRUE; + if (idx != IDI_HEAL && idx != IDI_FULLHEAL && idx != IDI_RESURRECT) { + SetRndSeed(iseed); + idx = RndHealerItem(lvl) - 1; + } + GetItemAttrs(ii, idx, lvl); + item[ii]._iCreateInfo = lvl | 0x4000; + item[ii]._iSeed = iseed; + item[ii]._iIdentified = TRUE; } void __fastcall RecreateTownItem(int ii, int idx, unsigned short icreateinfo, int iseed, int ivalue) { - if (icreateinfo & 0x400) - RecreateSmithItem(ii, idx, icreateinfo & 0x3F, iseed); - else if (icreateinfo & 0x800) - RecreatePremiumItem(ii, idx, icreateinfo & 0x3F, iseed); - else if (icreateinfo & 0x1000) - RecreateBoyItem(ii, idx, icreateinfo & 0x3F, iseed); - else if (icreateinfo & 0x2000) - RecreateWitchItem(ii, idx, icreateinfo & 0x3F, iseed); - else if (icreateinfo & 0x4000) - RecreateHealerItem(ii, idx, icreateinfo & 0x3F, iseed); + if (icreateinfo & 0x400) + RecreateSmithItem(ii, idx, icreateinfo & 0x3F, iseed); + else if (icreateinfo & 0x800) + RecreatePremiumItem(ii, idx, icreateinfo & 0x3F, iseed); + else if (icreateinfo & 0x1000) + RecreateBoyItem(ii, idx, icreateinfo & 0x3F, iseed); + else if (icreateinfo & 0x2000) + RecreateWitchItem(ii, idx, icreateinfo & 0x3F, iseed); + else if (icreateinfo & 0x4000) + RecreateHealerItem(ii, idx, icreateinfo & 0x3F, iseed); } void __cdecl RecalcStoreStats() { - int i; + int i; - for (i = 0; i < 20; i++) { - if (smithitem[i]._itype != -1) - smithitem[i]._iStatFlag = StoreStatOk(&smithitem[i]); - if (witchitem[i]._itype != -1) - witchitem[i]._iStatFlag = StoreStatOk(&witchitem[i]); - if (healitem[i]._itype != -1) - healitem[i]._iStatFlag = StoreStatOk(&healitem[i]); - } + for (i = 0; i < 20; i++) { + if (smithitem[i]._itype != -1) + smithitem[i]._iStatFlag = StoreStatOk(&smithitem[i]); + if (witchitem[i]._itype != -1) + witchitem[i]._iStatFlag = StoreStatOk(&witchitem[i]); + if (healitem[i]._itype != -1) + healitem[i]._iStatFlag = StoreStatOk(&healitem[i]); + } - for (i = 0; i < 6; i++) { - if (premiumitem[i]._itype != -1) - premiumitem[i]._iStatFlag = StoreStatOk(&premiumitem[i]); - } + for (i = 0; i < 6; i++) { + if (premiumitem[i]._itype != -1) + premiumitem[i]._iStatFlag = StoreStatOk(&premiumitem[i]); + } - boyitem._iStatFlag = StoreStatOk(&boyitem); + boyitem._iStatFlag = StoreStatOk(&boyitem); } // 6A6BB8: using guessed type int stextscrl; // 6AA700: using guessed type int stextdown; int __cdecl ItemNoFlippy() { - int r; // ecx + int r; // ecx - r = itemactive[numitems - 1]; - item[r]._iAnimFlag = 0; - item[r]._iAnimFrame = item[r]._iAnimLen; - item[r]._iSelFlag = 1; + r = itemactive[numitems - 1]; + item[r]._iAnimFlag = 0; + item[r]._iAnimFrame = item[r]._iAnimLen; + item[r]._iSelFlag = 1; - return r; + return r; } void __fastcall CreateSpellBook(int x, int y, int ispell, bool sendmsg, int delta) { - int ii; // edi - int idx; // [esp+8h] [ebp-8h] - bool done; // [esp+Ch] [ebp-4h] + int ii; // edi + int idx; // [esp+8h] [ebp-8h] + bool done; // [esp+Ch] [ebp-4h] - done = 0; - idx = RndTypeItems(0, 24); - if (numitems < MAXITEMS) { - ii = itemavail[0]; - GetSuperItemSpace(x, y, itemavail[0]); - itemactive[numitems] = ii; - itemavail[0] = itemavail[MAXITEMS - numitems - 1]; - do { - SetupAllItems(ii, idx, GetRndSeed(), 2 * currlevel, 1, 1, 0, delta); - if (item[ii]._iMiscId == IMISC_BOOK && item[ii]._iSpell == ispell) - done = 1; - } while (!done); - if (sendmsg) - NetSendCmdDItem(FALSE, ii); - if (delta) - DeltaAddItem(ii); - ++numitems; - } + done = 0; + idx = RndTypeItems(0, 24); + if (numitems < MAXITEMS) { + ii = itemavail[0]; + GetSuperItemSpace(x, y, itemavail[0]); + itemactive[numitems] = ii; + itemavail[0] = itemavail[MAXITEMS - numitems - 1]; + do { + SetupAllItems(ii, idx, GetRndSeed(), 2 * currlevel, 1, 1, 0, delta); + if (item[ii]._iMiscId == IMISC_BOOK && item[ii]._iSpell == ispell) + done = 1; + } while (!done); + if (sendmsg) + NetSendCmdDItem(FALSE, ii); + if (delta) + DeltaAddItem(ii); + ++numitems; + } } void __fastcall CreateMagicItem(int x, int y, int imisc, int icurs, int sendmsg, int delta) { - int ii; // esi - int idx; // ebx - bool done; // [esp+Ch] [ebp-4h] + int ii; // esi + int idx; // ebx + bool done; // [esp+Ch] [ebp-4h] - done = 0; - if (numitems < MAXITEMS) { - ii = itemavail[0]; - GetSuperItemSpace(x, y, itemavail[0]); - itemactive[numitems] = ii; - itemavail[0] = itemavail[MAXITEMS - numitems - 1]; - idx = RndTypeItems(imisc, 0); - do { - SetupAllItems(ii, idx, GetRndSeed(), 2 * currlevel, 1, 1, 0, delta); - if (item[ii]._iCurs == icurs) - done = 1; - else - idx = RndTypeItems(imisc, 0); - } while (!done); - if (sendmsg) - NetSendCmdDItem(FALSE, ii); - if (delta) - DeltaAddItem(ii); - ++numitems; - } + done = 0; + if (numitems < MAXITEMS) { + ii = itemavail[0]; + GetSuperItemSpace(x, y, itemavail[0]); + itemactive[numitems] = ii; + itemavail[0] = itemavail[MAXITEMS - numitems - 1]; + idx = RndTypeItems(imisc, 0); + do { + SetupAllItems(ii, idx, GetRndSeed(), 2 * currlevel, 1, 1, 0, delta); + if (item[ii]._iCurs == icurs) + done = 1; + else + idx = RndTypeItems(imisc, 0); + } while (!done); + if (sendmsg) + NetSendCmdDItem(FALSE, ii); + if (delta) + DeltaAddItem(ii); + ++numitems; + } } BOOL __fastcall GetItemRecord(int dwSeed, WORD CI, int indx) { - int v3; // edi - int *v4; // ebx - int v6; // [esp+Ch] [ebp-18h] - DWORD v7; // [esp+10h] [ebp-14h] - int *v8; // [esp+14h] [ebp-10h] - unsigned short *v9; // [esp+18h] [ebp-Ch] - ItemGetRecordStruct *v10; // [esp+1Ch] [ebp-8h] - short v11; // [esp+20h] [ebp-4h] + int v3; // edi + int *v4; // ebx + int v6; // [esp+Ch] [ebp-18h] + DWORD v7; // [esp+10h] [ebp-14h] + int *v8; // [esp+14h] [ebp-10h] + unsigned short *v9; // [esp+18h] [ebp-Ch] + ItemGetRecordStruct *v10; // [esp+1Ch] [ebp-8h] + short v11; // [esp+20h] [ebp-4h] - v11 = CI; - v6 = dwSeed; - v3 = 0; - v7 = GetTickCount(); - if (gnNumGetRecords <= 0) - return 1; - v8 = &itemrecord[0].nIndex; - v9 = &itemrecord[0].wCI; - v10 = itemrecord; - v4 = &itemrecord[0].dwTimestamp; - while (v7 - *v4 > 6000) { - NextItemRecord(v3); - --v10; - v9 -= 8; - --v3; - v4 -= 4; - v8 -= 4; - LABEL_8: - ++v10; - v9 += 8; - v8 += 4; - ++v3; - v4 += 4; - if (v3 >= gnNumGetRecords) - return 1; - } - if (v6 != v10->nSeed || v11 != *v9 || indx != *v8) - goto LABEL_8; - return 0; + v11 = CI; + v6 = dwSeed; + v3 = 0; + v7 = GetTickCount(); + if (gnNumGetRecords <= 0) + return 1; + v8 = &itemrecord[0].nIndex; + v9 = &itemrecord[0].wCI; + v10 = itemrecord; + v4 = &itemrecord[0].dwTimestamp; + while (v7 - *v4 > 6000) { + NextItemRecord(v3); + --v10; + v9 -= 8; + --v3; + v4 -= 4; + v8 -= 4; + LABEL_8: + ++v10; + v9 += 8; + v8 += 4; + ++v3; + v4 += 4; + if (v3 >= gnNumGetRecords) + return 1; + } + if (v6 != v10->nSeed || v11 != *v9 || indx != *v8) + goto LABEL_8; + return 0; } void __fastcall NextItemRecord(int i) { - int v1; // eax + int v1; // eax - v1 = gnNumGetRecords-- - 1; - if (gnNumGetRecords) { - itemrecord[i].nIndex = itemrecord[v1].nIndex; - itemrecord[i].nSeed = itemrecord[v1].nSeed; - itemrecord[i].wCI = itemrecord[v1].wCI; - itemrecord[i].dwTimestamp = itemrecord[v1].dwTimestamp; - } + v1 = gnNumGetRecords-- - 1; + if (gnNumGetRecords) { + itemrecord[i].nIndex = itemrecord[v1].nIndex; + itemrecord[i].nSeed = itemrecord[v1].nSeed; + itemrecord[i].wCI = itemrecord[v1].wCI; + itemrecord[i].dwTimestamp = itemrecord[v1].dwTimestamp; + } } void __fastcall SetItemRecord(int dwSeed, WORD CI, int indx) { - int i; // ecx + int i; // ecx - if (gnNumGetRecords != MAXITEMS) { - i = gnNumGetRecords++; - itemrecord[i].dwTimestamp = GetTickCount(); - itemrecord[i].nSeed = dwSeed; - itemrecord[i].wCI = CI; - itemrecord[i].nIndex = indx; - } + if (gnNumGetRecords != MAXITEMS) { + i = gnNumGetRecords++; + itemrecord[i].dwTimestamp = GetTickCount(); + itemrecord[i].nSeed = dwSeed; + itemrecord[i].wCI = CI; + itemrecord[i].nIndex = indx; + } } void __fastcall PutItemRecord(int seed, WORD ci, int index) { - int v3; // edi - int *v4; // ebx - int v5; // [esp+Ch] [ebp-18h] - DWORD v6; // [esp+10h] [ebp-14h] - int *v7; // [esp+14h] [ebp-10h] - unsigned short *v8; // [esp+18h] [ebp-Ch] - ItemGetRecordStruct *v9; // [esp+1Ch] [ebp-8h] - short v10; // [esp+20h] [ebp-4h] + int v3; // edi + int *v4; // ebx + int v5; // [esp+Ch] [ebp-18h] + DWORD v6; // [esp+10h] [ebp-14h] + int *v7; // [esp+14h] [ebp-10h] + unsigned short *v8; // [esp+18h] [ebp-Ch] + ItemGetRecordStruct *v9; // [esp+1Ch] [ebp-8h] + short v10; // [esp+20h] [ebp-4h] - v10 = ci; - v5 = seed; - v3 = 0; - v6 = GetTickCount(); - if (gnNumGetRecords > 0) { - v7 = &itemrecord[0].nIndex; - v8 = &itemrecord[0].wCI; - v9 = itemrecord; - v4 = &itemrecord[0].dwTimestamp; - do { - if (v6 - *v4 <= 6000) { - if (v5 == v9->nSeed && v10 == *v8 && index == *v7) { - NextItemRecord(v3); - return; - } - } else { - NextItemRecord(v3); - --v9; - v8 -= 8; - --v3; - v4 -= 4; - v7 -= 4; - } - ++v9; - v8 += 8; - v7 += 4; - ++v3; - v4 += 4; - } while (v3 < gnNumGetRecords); - } + v10 = ci; + v5 = seed; + v3 = 0; + v6 = GetTickCount(); + if (gnNumGetRecords > 0) { + v7 = &itemrecord[0].nIndex; + v8 = &itemrecord[0].wCI; + v9 = itemrecord; + v4 = &itemrecord[0].dwTimestamp; + do { + if (v6 - *v4 <= 6000) { + if (v5 == v9->nSeed && v10 == *v8 && index == *v7) { + NextItemRecord(v3); + return; + } + } else { + NextItemRecord(v3); + --v9; + v8 -= 8; + --v3; + v4 -= 4; + v7 -= 4; + } + ++v9; + v8 += 8; + v7 += 4; + ++v3; + v4 += 4; + } while (v3 < gnNumGetRecords); + } } diff --git a/Source/lighting.cpp b/Source/lighting.cpp index 29fc7ea9..f5cd9ad4 100644 --- a/Source/lighting.cpp +++ b/Source/lighting.cpp @@ -7,457 +7,455 @@ char lightactive[32]; LightListStruct LightList[32]; int numlights; char dung_map_radius[2048]; /* char [16][128] */ -int dovision; // weak +int dovision; // weak int numvision; -char lightmax; // weak -int dolighting; // weak +char lightmax; // weak +int dolighting; // weak char dung_map_rgba[16384]; /* int [64][64] short [64][128] char [64][256] */ int visionid; char *pLightTbl; /* todo: struct? */ BOOL lightflag; -char CrawlTable[2749] = -{ +char CrawlTable[2749] = { 1, - 0, 0, + 0, 0, 4, - 0, 1, 0, -1, -1, 0, 1, 0, + 0, 1, 0, -1, -1, 0, 1, 0, 16, - 0, 2, 0, -2, -1, 2, 1, 2, - -1, -2, 1, -2, -1, 1, 1, 1, - -1, -1, 1, -1, -2, 1, 2, 1, - -2, -1, 2, -1, -2, 0, 2, 0, + 0, 2, 0, -2, -1, 2, 1, 2, + -1, -2, 1, -2, -1, 1, 1, 1, + -1, -1, 1, -1, -2, 1, 2, 1, + -2, -1, 2, -1, -2, 0, 2, 0, 24, - 0, 3, 0, -3, -1, 3, 1, 3, - -1, -3, 1, -3, -2, 3, 2, 3, - -2, -3, 2, -3, -2, 2, 2, 2, - -2, -2, 2, -2, -3, 2, 3, 2, - -3, -2, 3, -2, -3, 1, 3, 1, - -3, -1, 3, -1, -3, 0, 3, 0, + 0, 3, 0, -3, -1, 3, 1, 3, + -1, -3, 1, -3, -2, 3, 2, 3, + -2, -3, 2, -3, -2, 2, 2, 2, + -2, -2, 2, -2, -3, 2, 3, 2, + -3, -2, 3, -2, -3, 1, 3, 1, + -3, -1, 3, -1, -3, 0, 3, 0, 32, - 0, 4, 0, -4, -1, 4, 1, 4, - -1, -4, 1, -4, -2, 4, 2, 4, - -2, -4, 2, -4, -3, 4, 3, 4, - -3, -4, 3, -4, -3, 3, 3, 3, - -3, -3, 3, -3, -4, 3, 4, 3, - -4, -3, 4, -3, -4, 2, 4, 2, - -4, -2, 4, -2, -4, 1, 4, 1, - -4, -1, 4, -1, -4, 0, 4, 0, + 0, 4, 0, -4, -1, 4, 1, 4, + -1, -4, 1, -4, -2, 4, 2, 4, + -2, -4, 2, -4, -3, 4, 3, 4, + -3, -4, 3, -4, -3, 3, 3, 3, + -3, -3, 3, -3, -4, 3, 4, 3, + -4, -3, 4, -3, -4, 2, 4, 2, + -4, -2, 4, -2, -4, 1, 4, 1, + -4, -1, 4, -1, -4, 0, 4, 0, 40, - 0, 5, 0, -5, -1, 5, 1, 5, - -1, -5, 1, -5, -2, 5, 2, 5, - -2, -5, 2, -5, -3, 5, 3, 5, - -3, -5, 3, -5, -4, 5, 4, 5, - -4, -5, 4, -5, -4, 4, 4, 4, - -4, -4, 4, -4, -5, 4, 5, 4, - -5, -4, 5, -4, -5, 3, 5, 3, - -5, -3, 5, -3, -5, 2, 5, 2, - -5, -2, 5, -2, -5, 1, 5, 1, - -5, -1, 5, -1, -5, 0, 5, 0, + 0, 5, 0, -5, -1, 5, 1, 5, + -1, -5, 1, -5, -2, 5, 2, 5, + -2, -5, 2, -5, -3, 5, 3, 5, + -3, -5, 3, -5, -4, 5, 4, 5, + -4, -5, 4, -5, -4, 4, 4, 4, + -4, -4, 4, -4, -5, 4, 5, 4, + -5, -4, 5, -4, -5, 3, 5, 3, + -5, -3, 5, -3, -5, 2, 5, 2, + -5, -2, 5, -2, -5, 1, 5, 1, + -5, -1, 5, -1, -5, 0, 5, 0, 48, - 0, 6, 0, -6, -1, 6, 1, 6, - -1, -6, 1, -6, -2, 6, 2, 6, - -2, -6, 2, -6, -3, 6, 3, 6, - -3, -6, 3, -6, -4, 6, 4, 6, - -4, -6, 4, -6, -5, 6, 5, 6, - -5, -6, 5, -6, -5, 5, 5, 5, - -5, -5, 5, -5, -6, 5, 6, 5, - -6, -5, 6, -5, -6, 4, 6, 4, - -6, -4, 6, -4, -6, 3, 6, 3, - -6, -3, 6, -3, -6, 2, 6, 2, - -6, -2, 6, -2, -6, 1, 6, 1, - -6, -1, 6, -1, -6, 0, 6, 0, + 0, 6, 0, -6, -1, 6, 1, 6, + -1, -6, 1, -6, -2, 6, 2, 6, + -2, -6, 2, -6, -3, 6, 3, 6, + -3, -6, 3, -6, -4, 6, 4, 6, + -4, -6, 4, -6, -5, 6, 5, 6, + -5, -6, 5, -6, -5, 5, 5, 5, + -5, -5, 5, -5, -6, 5, 6, 5, + -6, -5, 6, -5, -6, 4, 6, 4, + -6, -4, 6, -4, -6, 3, 6, 3, + -6, -3, 6, -3, -6, 2, 6, 2, + -6, -2, 6, -2, -6, 1, 6, 1, + -6, -1, 6, -1, -6, 0, 6, 0, 56, - 0, 7, 0, -7, -1, 7, 1, 7, - -1, -7, 1, -7, -2, 7, 2, 7, - -2, -7, 2, -7, -3, 7, 3, 7, - -3, -7, 3, -7, -4, 7, 4, 7, - -4, -7, 4, -7, -5, 7, 5, 7, - -5, -7, 5, -7, -6, 7, 6, 7, - -6, -7, 6, -7, -6, 6, 6, 6, - -6, -6, 6, -6, -7, 6, 7, 6, - -7, -6, 7, -6, -7, 5, 7, 5, - -7, -5, 7, -5, -7, 4, 7, 4, - -7, -4, 7, -4, -7, 3, 7, 3, - -7, -3, 7, -3, -7, 2, 7, 2, - -7, -2, 7, -2, -7, 1, 7, 1, - -7, -1, 7, -1, -7, 0, 7, 0, + 0, 7, 0, -7, -1, 7, 1, 7, + -1, -7, 1, -7, -2, 7, 2, 7, + -2, -7, 2, -7, -3, 7, 3, 7, + -3, -7, 3, -7, -4, 7, 4, 7, + -4, -7, 4, -7, -5, 7, 5, 7, + -5, -7, 5, -7, -6, 7, 6, 7, + -6, -7, 6, -7, -6, 6, 6, 6, + -6, -6, 6, -6, -7, 6, 7, 6, + -7, -6, 7, -6, -7, 5, 7, 5, + -7, -5, 7, -5, -7, 4, 7, 4, + -7, -4, 7, -4, -7, 3, 7, 3, + -7, -3, 7, -3, -7, 2, 7, 2, + -7, -2, 7, -2, -7, 1, 7, 1, + -7, -1, 7, -1, -7, 0, 7, 0, 64, - 0, 8, 0, -8, -1, 8, 1, 8, - -1, -8, 1, -8, -2, 8, 2, 8, - -2, -8, 2, -8, -3, 8, 3, 8, - -3, -8, 3, -8, -4, 8, 4, 8, - -4, -8, 4, -8, -5, 8, 5, 8, - -5, -8, 5, -8, -6, 8, 6, 8, - -6, -8, 6, -8, -7, 8, 7, 8, - -7, -8, 7, -8, -7, 7, 7, 7, - -7, -7, 7, -7, -8, 7, 8, 7, - -8, -7, 8, -7, -8, 6, 8, 6, - -8, -6, 8, -6, -8, 5, 8, 5, - -8, -5, 8, -5, -8, 4, 8, 4, - -8, -4, 8, -4, -8, 3, 8, 3, - -8, -3, 8, -3, -8, 2, 8, 2, - -8, -2, 8, -2, -8, 1, 8, 1, - -8, -1, 8, -1, -8, 0, 8, 0, + 0, 8, 0, -8, -1, 8, 1, 8, + -1, -8, 1, -8, -2, 8, 2, 8, + -2, -8, 2, -8, -3, 8, 3, 8, + -3, -8, 3, -8, -4, 8, 4, 8, + -4, -8, 4, -8, -5, 8, 5, 8, + -5, -8, 5, -8, -6, 8, 6, 8, + -6, -8, 6, -8, -7, 8, 7, 8, + -7, -8, 7, -8, -7, 7, 7, 7, + -7, -7, 7, -7, -8, 7, 8, 7, + -8, -7, 8, -7, -8, 6, 8, 6, + -8, -6, 8, -6, -8, 5, 8, 5, + -8, -5, 8, -5, -8, 4, 8, 4, + -8, -4, 8, -4, -8, 3, 8, 3, + -8, -3, 8, -3, -8, 2, 8, 2, + -8, -2, 8, -2, -8, 1, 8, 1, + -8, -1, 8, -1, -8, 0, 8, 0, 72, - 0, 9, 0, -9, -1, 9, 1, 9, - -1, -9, 1, -9, -2, 9, 2, 9, - -2, -9, 2, -9, -3, 9, 3, 9, - -3, -9, 3, -9, -4, 9, 4, 9, - -4, -9, 4, -9, -5, 9, 5, 9, - -5, -9, 5, -9, -6, 9, 6, 9, - -6, -9, 6, -9, -7, 9, 7, 9, - -7, -9, 7, -9, -8, 9, 8, 9, - -8, -9, 8, -9, -8, 8, 8, 8, - -8, -8, 8, -8, -9, 8, 9, 8, - -9, -8, 9, -8, -9, 7, 9, 7, - -9, -7, 9, -7, -9, 6, 9, 6, - -9, -6, 9, -6, -9, 5, 9, 5, - -9, -5, 9, -5, -9, 4, 9, 4, - -9, -4, 9, -4, -9, 3, 9, 3, - -9, -3, 9, -3, -9, 2, 9, 2, - -9, -2, 9, -2, -9, 1, 9, 1, - -9, -1, 9, -1, -9, 0, 9, 0, + 0, 9, 0, -9, -1, 9, 1, 9, + -1, -9, 1, -9, -2, 9, 2, 9, + -2, -9, 2, -9, -3, 9, 3, 9, + -3, -9, 3, -9, -4, 9, 4, 9, + -4, -9, 4, -9, -5, 9, 5, 9, + -5, -9, 5, -9, -6, 9, 6, 9, + -6, -9, 6, -9, -7, 9, 7, 9, + -7, -9, 7, -9, -8, 9, 8, 9, + -8, -9, 8, -9, -8, 8, 8, 8, + -8, -8, 8, -8, -9, 8, 9, 8, + -9, -8, 9, -8, -9, 7, 9, 7, + -9, -7, 9, -7, -9, 6, 9, 6, + -9, -6, 9, -6, -9, 5, 9, 5, + -9, -5, 9, -5, -9, 4, 9, 4, + -9, -4, 9, -4, -9, 3, 9, 3, + -9, -3, 9, -3, -9, 2, 9, 2, + -9, -2, 9, -2, -9, 1, 9, 1, + -9, -1, 9, -1, -9, 0, 9, 0, 80, - 0, 10, 0, -10, -1, 10, 1, 10, - -1, -10, 1, -10, -2, 10, 2, 10, - -2, -10, 2, -10, -3, 10, 3, 10, - -3, -10, 3, -10, -4, 10, 4, 10, - -4, -10, 4, -10, -5, 10, 5, 10, - -5, -10, 5, -10, -6, 10, 6, 10, - -6, -10, 6, -10, -7, 10, 7, 10, - -7, -10, 7, -10, -8, 10, 8, 10, - -8, -10, 8, -10, -9, 10, 9, 10, - -9, -10, 9, -10, -9, 9, 9, 9, - -9, -9, 9, -9, -10, 9, 10, 9, - -10, -9, 10, -9, -10, 8, 10, 8, - -10, -8, 10, -8, -10, 7, 10, 7, - -10, -7, 10, -7, -10, 6, 10, 6, - -10, -6, 10, -6, -10, 5, 10, 5, - -10, -5, 10, -5, -10, 4, 10, 4, - -10, -4, 10, -4, -10, 3, 10, 3, - -10, -3, 10, -3, -10, 2, 10, 2, - -10, -2, 10, -2, -10, 1, 10, 1, - -10, -1, 10, -1, -10, 0, 10, 0, + 0, 10, 0, -10, -1, 10, 1, 10, + -1, -10, 1, -10, -2, 10, 2, 10, + -2, -10, 2, -10, -3, 10, 3, 10, + -3, -10, 3, -10, -4, 10, 4, 10, + -4, -10, 4, -10, -5, 10, 5, 10, + -5, -10, 5, -10, -6, 10, 6, 10, + -6, -10, 6, -10, -7, 10, 7, 10, + -7, -10, 7, -10, -8, 10, 8, 10, + -8, -10, 8, -10, -9, 10, 9, 10, + -9, -10, 9, -10, -9, 9, 9, 9, + -9, -9, 9, -9, -10, 9, 10, 9, + -10, -9, 10, -9, -10, 8, 10, 8, + -10, -8, 10, -8, -10, 7, 10, 7, + -10, -7, 10, -7, -10, 6, 10, 6, + -10, -6, 10, -6, -10, 5, 10, 5, + -10, -5, 10, -5, -10, 4, 10, 4, + -10, -4, 10, -4, -10, 3, 10, 3, + -10, -3, 10, -3, -10, 2, 10, 2, + -10, -2, 10, -2, -10, 1, 10, 1, + -10, -1, 10, -1, -10, 0, 10, 0, 88, - 0, 11, 0, -11, -1, 11, 1, 11, - -1, -11, 1, -11, -2, 11, 2, 11, - -2, -11, 2, -11, -3, 11, 3, 11, - -3, -11, 3, -11, -4, 11, 4, 11, - -4, -11, 4, -11, -5, 11, 5, 11, - -5, -11, 5, -11, -6, 11, 6, 11, - -6, -11, 6, -11, -7, 11, 7, 11, - -7, -11, 7, -11, -8, 11, 8, 11, - -8, -11, 8, -11, -9, 11, 9, 11, - -9, -11, 9, -11, -10, 11, 10, 11, - -10, -11, 10, -11, -10, 10, 10, 10, - -10, -10, 10, -10, -11, 10, 11, 10, - -11, -10, 11, -10, -11, 9, 11, 9, - -11, -9, 11, -9, -11, 8, 11, 8, - -11, -8, 11, -8, -11, 7, 11, 7, - -11, -7, 11, -7, -11, 6, 11, 6, - -11, -6, 11, -6, -11, 5, 11, 5, - -11, -5, 11, -5, -11, 4, 11, 4, - -11, -4, 11, -4, -11, 3, 11, 3, - -11, -3, 11, -3, -11, 2, 11, 2, - -11, -2, 11, -2, -11, 1, 11, 1, - -11, -1, 11, -1, -11, 0, 11, 0, + 0, 11, 0, -11, -1, 11, 1, 11, + -1, -11, 1, -11, -2, 11, 2, 11, + -2, -11, 2, -11, -3, 11, 3, 11, + -3, -11, 3, -11, -4, 11, 4, 11, + -4, -11, 4, -11, -5, 11, 5, 11, + -5, -11, 5, -11, -6, 11, 6, 11, + -6, -11, 6, -11, -7, 11, 7, 11, + -7, -11, 7, -11, -8, 11, 8, 11, + -8, -11, 8, -11, -9, 11, 9, 11, + -9, -11, 9, -11, -10, 11, 10, 11, + -10, -11, 10, -11, -10, 10, 10, 10, + -10, -10, 10, -10, -11, 10, 11, 10, + -11, -10, 11, -10, -11, 9, 11, 9, + -11, -9, 11, -9, -11, 8, 11, 8, + -11, -8, 11, -8, -11, 7, 11, 7, + -11, -7, 11, -7, -11, 6, 11, 6, + -11, -6, 11, -6, -11, 5, 11, 5, + -11, -5, 11, -5, -11, 4, 11, 4, + -11, -4, 11, -4, -11, 3, 11, 3, + -11, -3, 11, -3, -11, 2, 11, 2, + -11, -2, 11, -2, -11, 1, 11, 1, + -11, -1, 11, -1, -11, 0, 11, 0, 96, - 0, 12, 0, -12, -1, 12, 1, 12, - -1, -12, 1, -12, -2, 12, 2, 12, - -2, -12, 2, -12, -3, 12, 3, 12, - -3, -12, 3, -12, -4, 12, 4, 12, - -4, -12, 4, -12, -5, 12, 5, 12, - -5, -12, 5, -12, -6, 12, 6, 12, - -6, -12, 6, -12, -7, 12, 7, 12, - -7, -12, 7, -12, -8, 12, 8, 12, - -8, -12, 8, -12, -9, 12, 9, 12, - -9, -12, 9, -12, -10, 12, 10, 12, - -10, -12, 10, -12, -11, 12, 11, 12, - -11, -12, 11, -12, -11, 11, 11, 11, - -11, -11, 11, -11, -12, 11, 12, 11, - -12, -11, 12, -11, -12, 10, 12, 10, - -12, -10, 12, -10, -12, 9, 12, 9, - -12, -9, 12, -9, -12, 8, 12, 8, - -12, -8, 12, -8, -12, 7, 12, 7, - -12, -7, 12, -7, -12, 6, 12, 6, - -12, -6, 12, -6, -12, 5, 12, 5, - -12, -5, 12, -5, -12, 4, 12, 4, - -12, -4, 12, -4, -12, 3, 12, 3, - -12, -3, 12, -3, -12, 2, 12, 2, - -12, -2, 12, -2, -12, 1, 12, 1, - -12, -1, 12, -1, -12, 0, 12, 0, + 0, 12, 0, -12, -1, 12, 1, 12, + -1, -12, 1, -12, -2, 12, 2, 12, + -2, -12, 2, -12, -3, 12, 3, 12, + -3, -12, 3, -12, -4, 12, 4, 12, + -4, -12, 4, -12, -5, 12, 5, 12, + -5, -12, 5, -12, -6, 12, 6, 12, + -6, -12, 6, -12, -7, 12, 7, 12, + -7, -12, 7, -12, -8, 12, 8, 12, + -8, -12, 8, -12, -9, 12, 9, 12, + -9, -12, 9, -12, -10, 12, 10, 12, + -10, -12, 10, -12, -11, 12, 11, 12, + -11, -12, 11, -12, -11, 11, 11, 11, + -11, -11, 11, -11, -12, 11, 12, 11, + -12, -11, 12, -11, -12, 10, 12, 10, + -12, -10, 12, -10, -12, 9, 12, 9, + -12, -9, 12, -9, -12, 8, 12, 8, + -12, -8, 12, -8, -12, 7, 12, 7, + -12, -7, 12, -7, -12, 6, 12, 6, + -12, -6, 12, -6, -12, 5, 12, 5, + -12, -5, 12, -5, -12, 4, 12, 4, + -12, -4, 12, -4, -12, 3, 12, 3, + -12, -3, 12, -3, -12, 2, 12, 2, + -12, -2, 12, -2, -12, 1, 12, 1, + -12, -1, 12, -1, -12, 0, 12, 0, 104, - 0, 13, 0, -13, -1, 13, 1, 13, - -1, -13, 1, -13, -2, 13, 2, 13, - -2, -13, 2, -13, -3, 13, 3, 13, - -3, -13, 3, -13, -4, 13, 4, 13, - -4, -13, 4, -13, -5, 13, 5, 13, - -5, -13, 5, -13, -6, 13, 6, 13, - -6, -13, 6, -13, -7, 13, 7, 13, - -7, -13, 7, -13, -8, 13, 8, 13, - -8, -13, 8, -13, -9, 13, 9, 13, - -9, -13, 9, -13, -10, 13, 10, 13, - -10, -13, 10, -13, -11, 13, 11, 13, - -11, -13, 11, -13, -12, 13, 12, 13, - -12, -13, 12, -13, -12, 12, 12, 12, - -12, -12, 12, -12, -13, 12, 13, 12, - -13, -12, 13, -12, -13, 11, 13, 11, - -13, -11, 13, -11, -13, 10, 13, 10, - -13, -10, 13, -10, -13, 9, 13, 9, - -13, -9, 13, -9, -13, 8, 13, 8, - -13, -8, 13, -8, -13, 7, 13, 7, - -13, -7, 13, -7, -13, 6, 13, 6, - -13, -6, 13, -6, -13, 5, 13, 5, - -13, -5, 13, -5, -13, 4, 13, 4, - -13, -4, 13, -4, -13, 3, 13, 3, - -13, -3, 13, -3, -13, 2, 13, 2, - -13, -2, 13, -2, -13, 1, 13, 1, - -13, -1, 13, -1, -13, 0, 13, 0, + 0, 13, 0, -13, -1, 13, 1, 13, + -1, -13, 1, -13, -2, 13, 2, 13, + -2, -13, 2, -13, -3, 13, 3, 13, + -3, -13, 3, -13, -4, 13, 4, 13, + -4, -13, 4, -13, -5, 13, 5, 13, + -5, -13, 5, -13, -6, 13, 6, 13, + -6, -13, 6, -13, -7, 13, 7, 13, + -7, -13, 7, -13, -8, 13, 8, 13, + -8, -13, 8, -13, -9, 13, 9, 13, + -9, -13, 9, -13, -10, 13, 10, 13, + -10, -13, 10, -13, -11, 13, 11, 13, + -11, -13, 11, -13, -12, 13, 12, 13, + -12, -13, 12, -13, -12, 12, 12, 12, + -12, -12, 12, -12, -13, 12, 13, 12, + -13, -12, 13, -12, -13, 11, 13, 11, + -13, -11, 13, -11, -13, 10, 13, 10, + -13, -10, 13, -10, -13, 9, 13, 9, + -13, -9, 13, -9, -13, 8, 13, 8, + -13, -8, 13, -8, -13, 7, 13, 7, + -13, -7, 13, -7, -13, 6, 13, 6, + -13, -6, 13, -6, -13, 5, 13, 5, + -13, -5, 13, -5, -13, 4, 13, 4, + -13, -4, 13, -4, -13, 3, 13, 3, + -13, -3, 13, -3, -13, 2, 13, 2, + -13, -2, 13, -2, -13, 1, 13, 1, + -13, -1, 13, -1, -13, 0, 13, 0, 112, - 0, 14, 0, -14, -1, 14, 1, 14, - -1, -14, 1, -14, -2, 14, 2, 14, - -2, -14, 2, -14, -3, 14, 3, 14, - -3, -14, 3, -14, -4, 14, 4, 14, - -4, -14, 4, -14, -5, 14, 5, 14, - -5, -14, 5, -14, -6, 14, 6, 14, - -6, -14, 6, -14, -7, 14, 7, 14, - -7, -14, 7, -14, -8, 14, 8, 14, - -8, -14, 8, -14, -9, 14, 9, 14, - -9, -14, 9, -14, -10, 14, 10, 14, - -10, -14, 10, -14, -11, 14, 11, 14, - -11, -14, 11, -14, -12, 14, 12, 14, - -12, -14, 12, -14, -13, 14, 13, 14, - -13, -14, 13, -14, -13, 13, 13, 13, - -13, -13, 13, -13, -14, 13, 14, 13, - -14, -13, 14, -13, -14, 12, 14, 12, - -14, -12, 14, -12, -14, 11, 14, 11, - -14, -11, 14, -11, -14, 10, 14, 10, - -14, -10, 14, -10, -14, 9, 14, 9, - -14, -9, 14, -9, -14, 8, 14, 8, - -14, -8, 14, -8, -14, 7, 14, 7, - -14, -7, 14, -7, -14, 6, 14, 6, - -14, -6, 14, -6, -14, 5, 14, 5, - -14, -5, 14, -5, -14, 4, 14, 4, - -14, -4, 14, -4, -14, 3, 14, 3, - -14, -3, 14, -3, -14, 2, 14, 2, - -14, -2, 14, -2, -14, 1, 14, 1, - -14, -1, 14, -1, -14, 0, 14, 0, + 0, 14, 0, -14, -1, 14, 1, 14, + -1, -14, 1, -14, -2, 14, 2, 14, + -2, -14, 2, -14, -3, 14, 3, 14, + -3, -14, 3, -14, -4, 14, 4, 14, + -4, -14, 4, -14, -5, 14, 5, 14, + -5, -14, 5, -14, -6, 14, 6, 14, + -6, -14, 6, -14, -7, 14, 7, 14, + -7, -14, 7, -14, -8, 14, 8, 14, + -8, -14, 8, -14, -9, 14, 9, 14, + -9, -14, 9, -14, -10, 14, 10, 14, + -10, -14, 10, -14, -11, 14, 11, 14, + -11, -14, 11, -14, -12, 14, 12, 14, + -12, -14, 12, -14, -13, 14, 13, 14, + -13, -14, 13, -14, -13, 13, 13, 13, + -13, -13, 13, -13, -14, 13, 14, 13, + -14, -13, 14, -13, -14, 12, 14, 12, + -14, -12, 14, -12, -14, 11, 14, 11, + -14, -11, 14, -11, -14, 10, 14, 10, + -14, -10, 14, -10, -14, 9, 14, 9, + -14, -9, 14, -9, -14, 8, 14, 8, + -14, -8, 14, -8, -14, 7, 14, 7, + -14, -7, 14, -7, -14, 6, 14, 6, + -14, -6, 14, -6, -14, 5, 14, 5, + -14, -5, 14, -5, -14, 4, 14, 4, + -14, -4, 14, -4, -14, 3, 14, 3, + -14, -3, 14, -3, -14, 2, 14, 2, + -14, -2, 14, -2, -14, 1, 14, 1, + -14, -1, 14, -1, -14, 0, 14, 0, 120, - 0, 15, 0, -15, -1, 15, 1, 15, - -1, -15, 1, -15, -2, 15, 2, 15, - -2, -15, 2, -15, -3, 15, 3, 15, - -3, -15, 3, -15, -4, 15, 4, 15, - -4, -15, 4, -15, -5, 15, 5, 15, - -5, -15, 5, -15, -6, 15, 6, 15, - -6, -15, 6, -15, -7, 15, 7, 15, - -7, -15, 7, -15, -8, 15, 8, 15, - -8, -15, 8, -15, -9, 15, 9, 15, - -9, -15, 9, -15, -10, 15, 10, 15, - -10, -15, 10, -15, -11, 15, 11, 15, - -11, -15, 11, -15, -12, 15, 12, 15, - -12, -15, 12, -15, -13, 15, 13, 15, - -13, -15, 13, -15, -14, 15, 14, 15, - -14, -15, 14, -15, -14, 14, 14, 14, - -14, -14, 14, -14, -15, 14, 15, 14, - -15, -14, 15, -14, -15, 13, 15, 13, - -15, -13, 15, -13, -15, 12, 15, 12, - -15, -12, 15, -12, -15, 11, 15, 11, - -15, -11, 15, -11, -15, 10, 15, 10, - -15, -10, 15, -10, -15, 9, 15, 9, - -15, -9, 15, -9, -15, 8, 15, 8, - -15, -8, 15, -8, -15, 7, 15, 7, - -15, -7, 15, -7, -15, 6, 15, 6, - -15, -6, 15, -6, -15, 5, 15, 5, - -15, -5, 15, -5, -15, 4, 15, 4, - -15, -4, 15, -4, -15, 3, 15, 3, - -15, -3, 15, -3, -15, 2, 15, 2, - -15, -2, 15, -2, -15, 1, 15, 1, - -15, -1, 15, -1, -15, 0, 15, 0, + 0, 15, 0, -15, -1, 15, 1, 15, + -1, -15, 1, -15, -2, 15, 2, 15, + -2, -15, 2, -15, -3, 15, 3, 15, + -3, -15, 3, -15, -4, 15, 4, 15, + -4, -15, 4, -15, -5, 15, 5, 15, + -5, -15, 5, -15, -6, 15, 6, 15, + -6, -15, 6, -15, -7, 15, 7, 15, + -7, -15, 7, -15, -8, 15, 8, 15, + -8, -15, 8, -15, -9, 15, 9, 15, + -9, -15, 9, -15, -10, 15, 10, 15, + -10, -15, 10, -15, -11, 15, 11, 15, + -11, -15, 11, -15, -12, 15, 12, 15, + -12, -15, 12, -15, -13, 15, 13, 15, + -13, -15, 13, -15, -14, 15, 14, 15, + -14, -15, 14, -15, -14, 14, 14, 14, + -14, -14, 14, -14, -15, 14, 15, 14, + -15, -14, 15, -14, -15, 13, 15, 13, + -15, -13, 15, -13, -15, 12, 15, 12, + -15, -12, 15, -12, -15, 11, 15, 11, + -15, -11, 15, -11, -15, 10, 15, 10, + -15, -10, 15, -10, -15, 9, 15, 9, + -15, -9, 15, -9, -15, 8, 15, 8, + -15, -8, 15, -8, -15, 7, 15, 7, + -15, -7, 15, -7, -15, 6, 15, 6, + -15, -6, 15, -6, -15, 5, 15, 5, + -15, -5, 15, -5, -15, 4, 15, 4, + -15, -4, 15, -4, -15, 3, 15, 3, + -15, -3, 15, -3, -15, 2, 15, 2, + -15, -2, 15, -2, -15, 1, 15, 1, + -15, -1, 15, -1, -15, 0, 15, 0, (char)128, - 0, 16, 0, -16, -1, 16, 1, 16, - -1, -16, 1, -16, -2, 16, 2, 16, - -2, -16, 2, -16, -3, 16, 3, 16, - -3, -16, 3, -16, -4, 16, 4, 16, - -4, -16, 4, -16, -5, 16, 5, 16, - -5, -16, 5, -16, -6, 16, 6, 16, - -6, -16, 6, -16, -7, 16, 7, 16, - -7, -16, 7, -16, -8, 16, 8, 16, - -8, -16, 8, -16, -9, 16, 9, 16, - -9, -16, 9, -16, -10, 16, 10, 16, - -10, -16, 10, -16, -11, 16, 11, 16, - -11, -16, 11, -16, -12, 16, 12, 16, - -12, -16, 12, -16, -13, 16, 13, 16, - -13, -16, 13, -16, -14, 16, 14, 16, - -14, -16, 14, -16, -15, 16, 15, 16, - -15, -16, 15, -16, -15, 15, 15, 15, - -15, -15, 15, -15, -16, 15, 16, 15, - -16, -15, 16, -15, -16, 14, 16, 14, - -16, -14, 16, -14, -16, 13, 16, 13, - -16, -13, 16, -13, -16, 12, 16, 12, - -16, -12, 16, -12, -16, 11, 16, 11, - -16, -11, 16, -11, -16, 10, 16, 10, - -16, -10, 16, -10, -16, 9, 16, 9, - -16, -9, 16, -9, -16, 8, 16, 8, - -16, -8, 16, -8, -16, 7, 16, 7, - -16, -7, 16, -7, -16, 6, 16, 6, - -16, -6, 16, -6, -16, 5, 16, 5, - -16, -5, 16, -5, -16, 4, 16, 4, - -16, -4, 16, -4, -16, 3, 16, 3, - -16, -3, 16, -3, -16, 2, 16, 2, - -16, -2, 16, -2, -16, 1, 16, 1, - -16, -1, 16, -1, -16, 0, 16, 0, + 0, 16, 0, -16, -1, 16, 1, 16, + -1, -16, 1, -16, -2, 16, 2, 16, + -2, -16, 2, -16, -3, 16, 3, 16, + -3, -16, 3, -16, -4, 16, 4, 16, + -4, -16, 4, -16, -5, 16, 5, 16, + -5, -16, 5, -16, -6, 16, 6, 16, + -6, -16, 6, -16, -7, 16, 7, 16, + -7, -16, 7, -16, -8, 16, 8, 16, + -8, -16, 8, -16, -9, 16, 9, 16, + -9, -16, 9, -16, -10, 16, 10, 16, + -10, -16, 10, -16, -11, 16, 11, 16, + -11, -16, 11, -16, -12, 16, 12, 16, + -12, -16, 12, -16, -13, 16, 13, 16, + -13, -16, 13, -16, -14, 16, 14, 16, + -14, -16, 14, -16, -15, 16, 15, 16, + -15, -16, 15, -16, -15, 15, 15, 15, + -15, -15, 15, -15, -16, 15, 16, 15, + -16, -15, 16, -15, -16, 14, 16, 14, + -16, -14, 16, -14, -16, 13, 16, 13, + -16, -13, 16, -13, -16, 12, 16, 12, + -16, -12, 16, -12, -16, 11, 16, 11, + -16, -11, 16, -11, -16, 10, 16, 10, + -16, -10, 16, -10, -16, 9, 16, 9, + -16, -9, 16, -9, -16, 8, 16, 8, + -16, -8, 16, -8, -16, 7, 16, 7, + -16, -7, 16, -7, -16, 6, 16, 6, + -16, -6, 16, -6, -16, 5, 16, 5, + -16, -5, 16, -5, -16, 4, 16, 4, + -16, -4, 16, -4, -16, 3, 16, 3, + -16, -3, 16, -3, -16, 2, 16, 2, + -16, -2, 16, -2, -16, 1, 16, 1, + -16, -1, 16, -1, -16, 0, 16, 0, (char)136, - 0, 17, 0, -17, -1, 17, 1, 17, - -1, -17, 1, -17, -2, 17, 2, 17, - -2, -17, 2, -17, -3, 17, 3, 17, - -3, -17, 3, -17, -4, 17, 4, 17, - -4, -17, 4, -17, -5, 17, 5, 17, - -5, -17, 5, -17, -6, 17, 6, 17, - -6, -17, 6, -17, -7, 17, 7, 17, - -7, -17, 7, -17, -8, 17, 8, 17, - -8, -17, 8, -17, -9, 17, 9, 17, - -9, -17, 9, -17, -10, 17, 10, 17, - -10, -17, 10, -17, -11, 17, 11, 17, - -11, -17, 11, -17, -12, 17, 12, 17, - -12, -17, 12, -17, -13, 17, 13, 17, - -13, -17, 13, -17, -14, 17, 14, 17, - -14, -17, 14, -17, -15, 17, 15, 17, - -15, -17, 15, -17, -16, 17, 16, 17, - -16, -17, 16, -17, -16, 16, 16, 16, - -16, -16, 16, -16, -17, 16, 17, 16, - -17, -16, 17, -16, -17, 15, 17, 15, - -17, -15, 17, -15, -17, 14, 17, 14, - -17, -14, 17, -14, -17, 13, 17, 13, - -17, -13, 17, -13, -17, 12, 17, 12, - -17, -12, 17, -12, -17, 11, 17, 11, - -17, -11, 17, -11, -17, 10, 17, 10, - -17, -10, 17, -10, -17, 9, 17, 9, - -17, -9, 17, -9, -17, 8, 17, 8, - -17, -8, 17, -8, -17, 7, 17, 7, - -17, -7, 17, -7, -17, 6, 17, 6, - -17, -6, 17, -6, -17, 5, 17, 5, - -17, -5, 17, -5, -17, 4, 17, 4, - -17, -4, 17, -4, -17, 3, 17, 3, - -17, -3, 17, -3, -17, 2, 17, 2, - -17, -2, 17, -2, -17, 1, 17, 1, - -17, -1, 17, -1, -17, 0, 17, 0, + 0, 17, 0, -17, -1, 17, 1, 17, + -1, -17, 1, -17, -2, 17, 2, 17, + -2, -17, 2, -17, -3, 17, 3, 17, + -3, -17, 3, -17, -4, 17, 4, 17, + -4, -17, 4, -17, -5, 17, 5, 17, + -5, -17, 5, -17, -6, 17, 6, 17, + -6, -17, 6, -17, -7, 17, 7, 17, + -7, -17, 7, -17, -8, 17, 8, 17, + -8, -17, 8, -17, -9, 17, 9, 17, + -9, -17, 9, -17, -10, 17, 10, 17, + -10, -17, 10, -17, -11, 17, 11, 17, + -11, -17, 11, -17, -12, 17, 12, 17, + -12, -17, 12, -17, -13, 17, 13, 17, + -13, -17, 13, -17, -14, 17, 14, 17, + -14, -17, 14, -17, -15, 17, 15, 17, + -15, -17, 15, -17, -16, 17, 16, 17, + -16, -17, 16, -17, -16, 16, 16, 16, + -16, -16, 16, -16, -17, 16, 17, 16, + -17, -16, 17, -16, -17, 15, 17, 15, + -17, -15, 17, -15, -17, 14, 17, 14, + -17, -14, 17, -14, -17, 13, 17, 13, + -17, -13, 17, -13, -17, 12, 17, 12, + -17, -12, 17, -12, -17, 11, 17, 11, + -17, -11, 17, -11, -17, 10, 17, 10, + -17, -10, 17, -10, -17, 9, 17, 9, + -17, -9, 17, -9, -17, 8, 17, 8, + -17, -8, 17, -8, -17, 7, 17, 7, + -17, -7, 17, -7, -17, 6, 17, 6, + -17, -6, 17, -6, -17, 5, 17, 5, + -17, -5, 17, -5, -17, 4, 17, 4, + -17, -4, 17, -4, -17, 3, 17, 3, + -17, -3, 17, -3, -17, 2, 17, 2, + -17, -2, 17, -2, -17, 1, 17, 1, + -17, -1, 17, -1, -17, 0, 17, 0, (char)144, - 0, 18, 0, -18, -1, 18, 1, 18, - -1, -18, 1, -18, -2, 18, 2, 18, - -2, -18, 2, -18, -3, 18, 3, 18, - -3, -18, 3, -18, -4, 18, 4, 18, - -4, -18, 4, -18, -5, 18, 5, 18, - -5, -18, 5, -18, -6, 18, 6, 18, - -6, -18, 6, -18, -7, 18, 7, 18, - -7, -18, 7, -18, -8, 18, 8, 18, - -8, -18, 8, -18, -9, 18, 9, 18, - -9, -18, 9, -18, -10, 18, 10, 18, - -10, -18, 10, -18, -11, 18, 11, 18, - -11, -18, 11, -18, -12, 18, 12, 18, - -12, -18, 12, -18, -13, 18, 13, 18, - -13, -18, 13, -18, -14, 18, 14, 18, - -14, -18, 14, -18, -15, 18, 15, 18, - -15, -18, 15, -18, -16, 18, 16, 18, - -16, -18, 16, -18, -17, 18, 17, 18, - -17, -18, 17, -18, -17, 17, 17, 17, - -17, -17, 17, -17, -18, 17, 18, 17, - -18, -17, 18, -17, -18, 16, 18, 16, - -18, -16, 18, -16, -18, 15, 18, 15, - -18, -15, 18, -15, -18, 14, 18, 14, - -18, -14, 18, -14, -18, 13, 18, 13, - -18, -13, 18, -13, -18, 12, 18, 12, - -18, -12, 18, -12, -18, 11, 18, 11, - -18, -11, 18, -11, -18, 10, 18, 10, - -18, -10, 18, -10, -18, 9, 18, 9, - -18, -9, 18, -9, -18, 8, 18, 8, - -18, -8, 18, -8, -18, 7, 18, 7, - -18, -7, 18, -7, -18, 6, 18, 6, - -18, -6, 18, -6, -18, 5, 18, 5, - -18, -5, 18, -5, -18, 4, 18, 4, - -18, -4, 18, -4, -18, 3, 18, 3, - -18, -3, 18, -3, -18, 2, 18, 2, - -18, -2, 18, -2, -18, 1, 18, 1, - -18, -1, 18, -1, -18, 0, 18, 0 + 0, 18, 0, -18, -1, 18, 1, 18, + -1, -18, 1, -18, -2, 18, 2, 18, + -2, -18, 2, -18, -3, 18, 3, 18, + -3, -18, 3, -18, -4, 18, 4, 18, + -4, -18, 4, -18, -5, 18, 5, 18, + -5, -18, 5, -18, -6, 18, 6, 18, + -6, -18, 6, -18, -7, 18, 7, 18, + -7, -18, 7, -18, -8, 18, 8, 18, + -8, -18, 8, -18, -9, 18, 9, 18, + -9, -18, 9, -18, -10, 18, 10, 18, + -10, -18, 10, -18, -11, 18, 11, 18, + -11, -18, 11, -18, -12, 18, 12, 18, + -12, -18, 12, -18, -13, 18, 13, 18, + -13, -18, 13, -18, -14, 18, 14, 18, + -14, -18, 14, -18, -15, 18, 15, 18, + -15, -18, 15, -18, -16, 18, 16, 18, + -16, -18, 16, -18, -17, 18, 17, 18, + -17, -18, 17, -18, -17, 17, 17, 17, + -17, -17, 17, -17, -18, 17, 18, 17, + -18, -17, 18, -17, -18, 16, 18, 16, + -18, -16, 18, -16, -18, 15, 18, 15, + -18, -15, 18, -15, -18, 14, 18, 14, + -18, -14, 18, -14, -18, 13, 18, 13, + -18, -13, 18, -13, -18, 12, 18, 12, + -18, -12, 18, -12, -18, 11, 18, 11, + -18, -11, 18, -11, -18, 10, 18, 10, + -18, -10, 18, -10, -18, 9, 18, 9, + -18, -9, 18, -9, -18, 8, 18, 8, + -18, -8, 18, -8, -18, 7, 18, 7, + -18, -7, 18, -7, -18, 6, 18, 6, + -18, -6, 18, -6, -18, 5, 18, 5, + -18, -5, 18, -5, -18, 4, 18, 4, + -18, -4, 18, -4, -18, 3, 18, 3, + -18, -3, 18, -3, -18, 2, 18, 2, + -18, -2, 18, -2, -18, 1, 18, 1, + -18, -1, 18, -1, -18, 0, 18, 0 }; char *pCrawlTable[19] = /* figure out what this is for */ -{ - CrawlTable, - CrawlTable+3, - CrawlTable+12, - CrawlTable+45, - CrawlTable+94, - CrawlTable+159, - CrawlTable+240, - CrawlTable+337, - CrawlTable+450, - CrawlTable+579, - CrawlTable+724, - CrawlTable+885, - CrawlTable+1062, - CrawlTable+1255, - CrawlTable+1464, - CrawlTable+1689, - CrawlTable+1930, - CrawlTable+2187, - CrawlTable+2460 -}; -unsigned char vCrawlTable[23][30] = -{ - { 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0 }, - { 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15, 1 }, - { 1, 0, 2, 0, 3, 0, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 2, 13, 2, 14, 2, 15, 2 }, - { 1, 0, 2, 0, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 2, 9, 2, 10, 2, 11, 2, 12, 2, 13, 3, 14, 3, 15, 3 }, - { 1, 0, 2, 1, 3, 1, 4, 1, 5, 1, 6, 2, 7, 2, 8, 2, 9, 3, 10, 3, 11, 3, 12, 3, 13, 4, 14, 4, 0, 0 }, - { 1, 0, 2, 1, 3, 1, 4, 1, 5, 2, 6, 2, 7, 3, 8, 3, 9, 3, 10, 4, 11, 4, 12, 4, 13, 5, 14, 5, 0, 0 }, - { 1, 0, 2, 1, 3, 1, 4, 2, 5, 2, 6, 3, 7, 3, 8, 3, 9, 4, 10, 4, 11, 5, 12, 5, 13, 6, 14, 6, 0, 0 }, - { 1, 1, 2, 1, 3, 2, 4, 2, 5, 3, 6, 3, 7, 4, 8, 4, 9, 5, 10, 5, 11, 6, 12, 6, 13, 7, 0, 0, 0, 0 }, - { 1, 1, 2, 1, 3, 2, 4, 2, 5, 3, 6, 4, 7, 4, 8, 5, 9, 6, 10, 6, 11, 7, 12, 7, 12, 8, 13, 8, 0, 0 }, - { 1, 1, 2, 2, 3, 2, 4, 3, 5, 4, 6, 5, 7, 5, 8, 6, 9, 7, 10, 7, 10, 8, 11, 8, 12, 9, 0, 0, 0, 0 }, - { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 9, 11, 10, 0, 0, 0, 0, 0, 0 }, - { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 9, 11, 10, 11, 0, 0, 0, 0, 0, 0 }, - { 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 5, 7, 6, 8, 7, 9, 7, 10, 8, 10, 8, 11, 9, 12, 0, 0, 0, 0 }, - { 1, 1, 1, 2, 2, 3, 2, 4, 3, 5, 4, 6, 4, 7, 5, 8, 6, 9, 6, 10, 7, 11, 7, 12, 8, 12, 8, 13, 0, 0 }, - { 1, 1, 1, 2, 2, 3, 2, 4, 3, 5, 3, 6, 4, 7, 4, 8, 5, 9, 5, 10, 6, 11, 6, 12, 7, 13, 0, 0, 0, 0 }, - { 0, 1, 1, 2, 1, 3, 2, 4, 2, 5, 3, 6, 3, 7, 3, 8, 4, 9, 4, 10, 5, 11, 5, 12, 6, 13, 6, 14, 0, 0 }, - { 0, 1, 1, 2, 1, 3, 1, 4, 2, 5, 2, 6, 3, 7, 3, 8, 3, 9, 4, 10, 4, 11, 4, 12, 5, 13, 5, 14, 0, 0 }, - { 0, 1, 1, 2, 1, 3, 1, 4, 1, 5, 2, 6, 2, 7, 2, 8, 3, 9, 3, 10, 3, 11, 3, 12, 4, 13, 4, 14, 0, 0 }, - { 0, 1, 0, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 2, 8, 2, 9, 2, 10, 2, 11, 2, 12, 3, 13, 3, 14, 3, 15 }, - { 0, 1, 0, 2, 0, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 2, 12, 2, 13, 2, 14, 2, 15 }, - { 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15 }, - { 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15 } + { + CrawlTable, + CrawlTable + 3, + CrawlTable + 12, + CrawlTable + 45, + CrawlTable + 94, + CrawlTable + 159, + CrawlTable + 240, + CrawlTable + 337, + CrawlTable + 450, + CrawlTable + 579, + CrawlTable + 724, + CrawlTable + 885, + CrawlTable + 1062, + CrawlTable + 1255, + CrawlTable + 1464, + CrawlTable + 1689, + CrawlTable + 1930, + CrawlTable + 2187, + CrawlTable + 2460 + }; +unsigned char vCrawlTable[23][30] = { + { 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0 }, + { 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15, 1 }, + { 1, 0, 2, 0, 3, 0, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 2, 13, 2, 14, 2, 15, 2 }, + { 1, 0, 2, 0, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 2, 9, 2, 10, 2, 11, 2, 12, 2, 13, 3, 14, 3, 15, 3 }, + { 1, 0, 2, 1, 3, 1, 4, 1, 5, 1, 6, 2, 7, 2, 8, 2, 9, 3, 10, 3, 11, 3, 12, 3, 13, 4, 14, 4, 0, 0 }, + { 1, 0, 2, 1, 3, 1, 4, 1, 5, 2, 6, 2, 7, 3, 8, 3, 9, 3, 10, 4, 11, 4, 12, 4, 13, 5, 14, 5, 0, 0 }, + { 1, 0, 2, 1, 3, 1, 4, 2, 5, 2, 6, 3, 7, 3, 8, 3, 9, 4, 10, 4, 11, 5, 12, 5, 13, 6, 14, 6, 0, 0 }, + { 1, 1, 2, 1, 3, 2, 4, 2, 5, 3, 6, 3, 7, 4, 8, 4, 9, 5, 10, 5, 11, 6, 12, 6, 13, 7, 0, 0, 0, 0 }, + { 1, 1, 2, 1, 3, 2, 4, 2, 5, 3, 6, 4, 7, 4, 8, 5, 9, 6, 10, 6, 11, 7, 12, 7, 12, 8, 13, 8, 0, 0 }, + { 1, 1, 2, 2, 3, 2, 4, 3, 5, 4, 6, 5, 7, 5, 8, 6, 9, 7, 10, 7, 10, 8, 11, 8, 12, 9, 0, 0, 0, 0 }, + { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 9, 11, 10, 0, 0, 0, 0, 0, 0 }, + { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 9, 11, 10, 11, 0, 0, 0, 0, 0, 0 }, + { 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 5, 7, 6, 8, 7, 9, 7, 10, 8, 10, 8, 11, 9, 12, 0, 0, 0, 0 }, + { 1, 1, 1, 2, 2, 3, 2, 4, 3, 5, 4, 6, 4, 7, 5, 8, 6, 9, 6, 10, 7, 11, 7, 12, 8, 12, 8, 13, 0, 0 }, + { 1, 1, 1, 2, 2, 3, 2, 4, 3, 5, 3, 6, 4, 7, 4, 8, 5, 9, 5, 10, 6, 11, 6, 12, 7, 13, 0, 0, 0, 0 }, + { 0, 1, 1, 2, 1, 3, 2, 4, 2, 5, 3, 6, 3, 7, 3, 8, 4, 9, 4, 10, 5, 11, 5, 12, 6, 13, 6, 14, 0, 0 }, + { 0, 1, 1, 2, 1, 3, 1, 4, 2, 5, 2, 6, 3, 7, 3, 8, 3, 9, 4, 10, 4, 11, 4, 12, 5, 13, 5, 14, 0, 0 }, + { 0, 1, 1, 2, 1, 3, 1, 4, 1, 5, 2, 6, 2, 7, 2, 8, 3, 9, 3, 10, 3, 11, 3, 12, 4, 13, 4, 14, 0, 0 }, + { 0, 1, 0, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 2, 8, 2, 9, 2, 10, 2, 11, 2, 12, 3, 13, 3, 14, 3, 15 }, + { 0, 1, 0, 2, 0, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 2, 12, 2, 13, 2, 14, 2, 15 }, + { 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15 }, + { 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15 } }; unsigned char byte_49463C[18][18] = /* unused */ -{ - { 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, - { 0, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, - { 0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, - { 0, 0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, - { 0, 0, 1, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, - { 0, 0, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, - { 0, 0, 0, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, - { 0, 0, 0, 1, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, - { 0, 0, 0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, - { 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3 }, - { 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3 }, - { 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3 }, - { 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3 }, - { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3 }, - { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3 }, - { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3 }, - { 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2 } -}; + { + { 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, + { 0, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, + { 0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, + { 0, 0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, + { 0, 0, 1, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, + { 0, 0, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, + { 0, 0, 0, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, + { 0, 0, 0, 1, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, + { 0, 0, 0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, + { 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3 }, + { 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3 }, + { 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3 }, + { 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3 }, + { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3 }, + { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3 }, + { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3 }, + { 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2 } + }; unsigned char RadiusAdj[23] = { 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 4, 3, 2, 2, 2, 1, 1, 1, 0, 0, 0, 0 }; void __fastcall SetLightFX(int *x, int *y, short *s_r, short *s_g, int *s_b, int *d_r, int *d_g, int *d_b) { - short *v8; // eax - int v9; // edx - int *v10; // [esp+Ch] [ebp-4h] + short *v8; // eax + int v9; // edx + int *v10; // [esp+Ch] [ebp-4h] short *s_ra; // [esp+18h] [ebp+8h] *d_g = 0; @@ -472,13 +470,11 @@ void __fastcall SetLightFX(int *x, int *y, short *s_r, short *s_g, int *s_b, int *d_r = (int)s_ra; *x = *(_DWORD *)v8 - *s_b; *v10 = *(_DWORD *)s_g - *d_r; - if ( *x < 0 ) - { + if (*x < 0) { *x += 8; *d_g = 1; } - if ( *v10 < 0 ) - { + if (*v10 < 0) { *v10 += 8; *d_b = 1; } @@ -486,62 +482,62 @@ void __fastcall SetLightFX(int *x, int *y, short *s_r, short *s_g, int *s_b, int void __fastcall DoLighting(int nXPos, int nYPos, int nRadius, int Lnum) { - int v4; // edi - int v5; // ebx - int v6; // ecx - int v7; // eax - int v8; // edx - int v9; // esi - int v10; // eax - char *v11; // edi - signed int v12; // ecx - int v13; // edx - _BYTE *v14; // ecx - int v15; // ebx - bool v16; // sf + int v4; // edi + int v5; // ebx + int v6; // ecx + int v7; // eax + int v8; // edx + int v9; // esi + int v10; // eax + char *v11; // edi + signed int v12; // ecx + int v13; // edx + _BYTE *v14; // ecx + int v15; // ebx + bool v16; // sf unsigned char v17; // of - int v18; // esi - int v19; // ecx - char *v20; // edi - signed int v21; // eax - int v22; // edx - _BYTE *v23; // eax - int v24; // ebx - int v25; // eax - int v26; // esi - char *v27; // edi - signed int v28; // ecx - int v29; // edx - _BYTE *v30; // ecx - int v31; // ebx - signed int v32; // ebx - int v33; // ecx - char *v34; // esi - signed int v35; // eax - int v36; // edx - _BYTE *v37; // eax - int v38; // edi - short s_r[2]; // [esp+Ch] [ebp-44h] - short s_g[2]; // [esp+10h] [ebp-40h] - int s_b; // [esp+14h] [ebp-3Ch] - int d_r; // [esp+18h] [ebp-38h] - int v43; // [esp+1Ch] [ebp-34h] - int v44; // [esp+20h] [ebp-30h] - int v45; // [esp+24h] [ebp-2Ch] - int v46; // [esp+28h] [ebp-28h] - int v47; // [esp+2Ch] [ebp-24h] - int v48; // [esp+30h] [ebp-20h] - int d_g; // [esp+34h] [ebp-1Ch] - int d_b; // [esp+38h] [ebp-18h] - int v51; // [esp+3Ch] [ebp-14h] - int v52; // [esp+40h] [ebp-10h] - int y; // [esp+44h] [ebp-Ch] - int x; // [esp+48h] [ebp-8h] - int v55; // [esp+4Ch] [ebp-4h] - int Lnuma; // [esp+5Ch] [ebp+Ch] - int Lnumb; // [esp+5Ch] [ebp+Ch] - int Lnumc; // [esp+5Ch] [ebp+Ch] - int Lnumd; // [esp+5Ch] [ebp+Ch] + int v18; // esi + int v19; // ecx + char *v20; // edi + signed int v21; // eax + int v22; // edx + _BYTE *v23; // eax + int v24; // ebx + int v25; // eax + int v26; // esi + char *v27; // edi + signed int v28; // ecx + int v29; // edx + _BYTE *v30; // ecx + int v31; // ebx + signed int v32; // ebx + int v33; // ecx + char *v34; // esi + signed int v35; // eax + int v36; // edx + _BYTE *v37; // eax + int v38; // edi + short s_r[2]; // [esp+Ch] [ebp-44h] + short s_g[2]; // [esp+10h] [ebp-40h] + int s_b; // [esp+14h] [ebp-3Ch] + int d_r; // [esp+18h] [ebp-38h] + int v43; // [esp+1Ch] [ebp-34h] + int v44; // [esp+20h] [ebp-30h] + int v45; // [esp+24h] [ebp-2Ch] + int v46; // [esp+28h] [ebp-28h] + int v47; // [esp+2Ch] [ebp-24h] + int v48; // [esp+30h] [ebp-20h] + int d_g; // [esp+34h] [ebp-1Ch] + int d_b; // [esp+38h] [ebp-18h] + int v51; // [esp+3Ch] [ebp-14h] + int v52; // [esp+40h] [ebp-10h] + int y; // [esp+44h] [ebp-Ch] + int x; // [esp+48h] [ebp-8h] + int v55; // [esp+4Ch] [ebp-4h] + int Lnuma; // [esp+5Ch] [ebp+Ch] + int Lnumb; // [esp+5Ch] [ebp+Ch] + int Lnumc; // [esp+5Ch] [ebp+Ch] + int Lnumd; // [esp+5Ch] [ebp+Ch] v4 = nYPos; v5 = nXPos; @@ -555,21 +551,18 @@ void __fastcall DoLighting(int nXPos, int nYPos, int nRadius, int Lnum) d_r = 0; d_g = 0; d_b = 0; - if ( Lnum >= 0 ) - { + if (Lnum >= 0) { v7 = LightList[Lnum]._yoff; x = LightList[Lnum]._xoff; v6 = x; y = v7; - if ( x < 0 ) - { + if (x < 0) { v6 = x + 8; --v5; x += 8; v52 = v5; } - if ( v7 < 0 ) - { + if (v7 < 0) { v7 += 8; v4 = nYPos - 1; y = v7; @@ -579,418 +572,359 @@ void __fastcall DoLighting(int nXPos, int nYPos, int nRadius, int Lnum) *(_DWORD *)s_r = v6; *(_DWORD *)s_g = v7; v8 = 15; - if ( v5 - 15 >= 0 ) + if (v5 - 15 >= 0) v44 = 15; else v44 = v5 + 1; - if ( v5 + 15 <= 112 ) + if (v5 + 15 <= 112) v46 = 15; else v46 = 112 - v5; - if ( v4 - 15 >= 0 ) + if (v4 - 15 >= 0) v43 = 15; else v43 = v4 + 1; - if ( v4 + 15 > 112 ) + if (v4 + 15 > 112) v8 = 112 - v4; v45 = v8; - if ( v5 >= 0 && v5 < 112 && v4 >= 0 && v4 < 112 ) + if (v5 >= 0 && v5 < 112 && v4 >= 0 && v4 < 112) dTransVal[v5][v4] = 0; v55 = 0; v51 = v6 + 8 * v7; - if ( v43 > 0 ) - { + if (v43 > 0) { v47 = v4; - do - { + do { Lnuma = 1; - if ( v46 > 1 ) - { + if (v46 > 1) { v9 = v5 + 1; v10 = 112 * (v5 + 1); v11 = &dung_map_rgba[16 * (v55 + 16 * v51)]; - do - { + do { v12 = (unsigned char)v11[Lnuma]; - if ( v12 < 128 ) - { + if (v12 < 128) { v13 = (unsigned char)dung_map_radius[128 * nRadius + v12]; - if ( v9 >= 0 && v9 < 112 && v47 >= 0 && v47 < 112 ) - { + if (v9 >= 0 && v9 < 112 && v47 >= 0 && v47 < 112) { v14 = (unsigned char *)dTransVal + v47 + v10; v15 = (char)*v14; v17 = __OFSUB__(v13, v15); v16 = v13 - v15 < 0; v5 = v52; - if ( v16 ^ v17 ) + if (v16 ^ v17) *v14 = v13; } } ++Lnuma; v10 += 112; ++v9; - } - while ( Lnuma < v46 ); + } while (Lnuma < v46); v4 = v48; } ++v55; ++v47; - } - while ( v55 < v43 ); + } while (v55 < v43); } SetLightFX(&x, &y, s_r, s_g, &s_b, &d_r, &d_g, &d_b); v18 = 0; v51 = x + 8 * y; - if ( v45 > 0 ) - { + if (v45 > 0) { v47 = 112 * v5; - do - { + do { Lnumb = 1; - if ( v46 > 1 ) - { + if (v46 > 1) { v19 = v4 - 1; v20 = &dung_map_rgba[16 * (d_b + v18 + 16 * v51) + d_g]; - do - { + do { v21 = (unsigned char)v20[Lnumb]; - if ( v21 < 128 ) - { + if (v21 < 128) { v22 = (unsigned char)dung_map_radius[128 * nRadius + v21]; - if ( v18 + v5 >= 0 && v18 + v5 < 112 && v19 >= 0 && v19 < 112 ) - { + if (v18 + v5 >= 0 && v18 + v5 < 112 && v19 >= 0 && v19 < 112) { v23 = (unsigned char *)dTransVal + v47 + v19; v24 = (char)*v23; v17 = __OFSUB__(v22, v24); v16 = v22 - v24 < 0; v5 = v52; - if ( v16 ^ v17 ) + if (v16 ^ v17) *v23 = v22; } } ++Lnumb; --v19; - } - while ( Lnumb < v46 ); + } while (Lnumb < v46); v4 = v48; } v47 += 112; ++v18; - } - while ( v18 < v45 ); + } while (v18 < v45); } SetLightFX(&x, &y, s_r, s_g, &s_b, &d_r, &d_g, &d_b); v55 = 0; v51 = x + 8 * y; - if ( v45 > 0 ) - { + if (v45 > 0) { v46 = v4; - do - { + do { Lnumc = 1; - if ( v44 > 1 ) - { + if (v44 > 1) { v25 = 112 * v5 - 112; v26 = v5 - 1; v27 = &dung_map_rgba[16 * (d_b + v55 + 16 * v51) + d_g]; - do - { + do { v28 = (unsigned char)v27[Lnumc]; - if ( v28 < 128 ) - { + if (v28 < 128) { v29 = (unsigned char)dung_map_radius[128 * nRadius + v28]; - if ( v26 >= 0 && v26 < 112 && v46 >= 0 && v46 < 112 ) - { + if (v26 >= 0 && v26 < 112 && v46 >= 0 && v46 < 112) { v30 = (unsigned char *)dTransVal + v46 + v25; v31 = (char)*v30; v17 = __OFSUB__(v29, v31); v16 = v29 - v31 < 0; v5 = v52; - if ( v16 ^ v17 ) + if (v16 ^ v17) *v30 = v29; } } ++Lnumc; v25 -= 112; --v26; - } - while ( Lnumc < v44 ); + } while (Lnumc < v44); v4 = v48; } ++v55; --v46; - } - while ( v55 < v45 ); + } while (v55 < v45); } SetLightFX(&x, &y, s_r, s_g, &s_b, &d_r, &d_g, &d_b); v55 = 0; v51 = x + 8 * y; - if ( v43 > 0 ) - { + if (v43 > 0) { Lnumd = v5; *(_DWORD *)s_r = 112 * v5; - do - { + do { v32 = 1; - if ( v44 > 1 ) - { + if (v44 > 1) { v33 = v4 + 1; v34 = &dung_map_rgba[16 * (d_b + v55 + 16 * v51) + d_g]; - do - { + do { v35 = (unsigned char)v34[v32]; - if ( v35 < 128 ) - { + if (v35 < 128) { v36 = (unsigned char)dung_map_radius[128 * nRadius + v35]; - if ( Lnumd >= 0 && Lnumd < 112 && v33 >= 0 && v33 < 112 ) - { + if (Lnumd >= 0 && Lnumd < 112 && v33 >= 0 && v33 < 112) { v37 = (unsigned char *)dTransVal + v33 + *(_DWORD *)s_r; v38 = (char)*v37; v17 = __OFSUB__(v36, v38); v16 = v36 - v38 < 0; v4 = v48; - if ( v16 ^ v17 ) + if (v16 ^ v17) *v37 = v36; } } ++v32; ++v33; - } - while ( v32 < v44 ); + } while (v32 < v44); } ++v55; --Lnumd; *(_DWORD *)s_r -= 112; - } - while ( v55 < v43 ); + } while (v55 < v43); } } void __fastcall DoUnLight(int nXPos, int nYPos, int nRadius) { - int max_y; // ebx - int y; // esi - int x; // edx - int max_x; // edi - signed int v7; // esi - int v8; // eax + int max_y; // ebx + int y; // esi + int x; // edx + int max_x; // edi + signed int v7; // esi + int v8; // eax int radius_block; // [esp+14h] [ebp+8h] max_y = nYPos + nRadius + 1; y = nYPos - (nRadius + 1); x = nXPos - (nRadius + 1); max_x = nXPos + nRadius + 1; - if ( y < 0 ) + if (y < 0) y = 0; - if ( max_y > 112 ) + if (max_y > 112) max_y = 112; - if ( x < 0 ) + if (x < 0) x = 0; - if ( max_x > 112 ) + if (max_x > 112) max_x = 112; - for ( radius_block = y; radius_block < max_y; ++radius_block ) - { + for (radius_block = y; radius_block < max_y; ++radius_block) { v7 = x; - if ( x < max_x ) - { + if (x < max_x) { v8 = radius_block + 112 * x; - do - { - if ( v7 >= 0 && v7 < 112 && radius_block >= 0 && radius_block < 112 ) + do { + if (v7 >= 0 && v7 < 112 && radius_block >= 0 && radius_block < 112) dTransVal[0][v8] = dTransVal2[0][v8]; ++v7; v8 += 112; - } - while ( v7 < max_x ); + } while (v7 < max_x); } } } void __fastcall DoUnVision(int nXPos, int nYPos, int nRadius) { - int y2; // edi - int y1; // esi - int x1; // edx - int x2; // ecx + int y2; // edi + int y1; // esi + int x1; // edx + int x2; // ecx char *v7; // eax - int i; // ecx - int j; // edx + int i; // ecx + int j; // edx y2 = nYPos + nRadius + 1; y1 = nYPos - (nRadius + 1); x1 = nXPos - (nRadius + 1); x2 = nRadius + 1 + nXPos; - if ( y1 < 0 ) + if (y1 < 0) y1 = 0; - if ( y2 > 112 ) + if (y2 > 112) y2 = 112; - if ( x1 < 0 ) + if (x1 < 0) x1 = 0; - if ( x2 > 112 ) + if (x2 > 112) x2 = 112; - if ( x1 < x2 ) - { + if (x1 < x2) { v7 = dFlags[x1]; i = x2 - x1; - do - { - for ( j = y1; j < y2; ++j ) + do { + for (j = y1; j < y2; ++j) v7[j] &= ~(DFLAG_VISIBLE | DFLAG_LIT); v7 += 112; --i; - } - while ( i ); + } while (i); } } void __fastcall DoVision(int nXPos, int nYPos, int nRadius, unsigned char doautomap, int visible) { - char *v5; // esi - int v6; // esi - int v7; // edi - unsigned char *v8; // eax - int v9; // ebx - int v10; // ecx - unsigned char v11; // dl - int v12; // ecx - int v13; // ecx - unsigned char v14; // cl - unsigned char v15; // dl - int v16; // ecx - int v17; // ecx - int i; // [esp+Ch] [ebp-34h] + char *v5; // esi + int v6; // esi + int v7; // edi + unsigned char *v8; // eax + int v9; // ebx + int v10; // ecx + unsigned char v11; // dl + int v12; // ecx + int v13; // ecx + unsigned char v14; // cl + unsigned char v15; // dl + int v16; // ecx + int v17; // ecx + int i; // [esp+Ch] [ebp-34h] unsigned char *v19; // [esp+10h] [ebp-30h] - int v20; // [esp+14h] [ebp-2Ch] - int v21; // [esp+18h] [ebp-28h] - int v22; // [esp+1Ch] [ebp-24h] - signed int v23; // [esp+20h] [ebp-20h] - signed int v24; // [esp+24h] [ebp-1Ch] - signed int v25; // [esp+28h] [ebp-18h] - signed int v26; // [esp+2Ch] [ebp-14h] - signed int v27; // [esp+30h] [ebp-10h] - int v28; // [esp+34h] [ebp-Ch] - int v29; // [esp+38h] [ebp-8h] - unsigned char v30; // [esp+3Fh] [ebp-1h] - unsigned char v31; // [esp+3Fh] [ebp-1h] + int v20; // [esp+14h] [ebp-2Ch] + int v21; // [esp+18h] [ebp-28h] + int v22; // [esp+1Ch] [ebp-24h] + signed int v23; // [esp+20h] [ebp-20h] + signed int v24; // [esp+24h] [ebp-1Ch] + signed int v25; // [esp+28h] [ebp-18h] + signed int v26; // [esp+2Ch] [ebp-14h] + signed int v27; // [esp+30h] [ebp-10h] + int v28; // [esp+34h] [ebp-Ch] + int v29; // [esp+38h] [ebp-8h] + unsigned char v30; // [esp+3Fh] [ebp-1h] + unsigned char v31; // [esp+3Fh] [ebp-1h] v28 = nYPos; v29 = nXPos; - if ( nXPos >= 0 && nXPos <= 112 && nYPos >= 0 && nYPos <= 112 ) - { - if ( doautomap ) - { + if (nXPos >= 0 && nXPos <= 112 && nYPos >= 0 && nYPos <= 112) { + if (doautomap) { v5 = &dFlags[nXPos][nYPos]; - if ( *v5 >= 0 ) - { + if (*v5 >= 0) { SetAutomapView(nXPos, nXPos); nYPos = v28; nXPos = v29; } *v5 |= DFLAG_EXPLORED; } - if ( visible ) + if (visible) dFlags[nXPos][nYPos] |= DFLAG_LIT; dFlags[nXPos][nYPos] |= DFLAG_VISIBLE; } v27 = 0; v6 = doautomap; v7 = doautomap; - do - { + do { v20 = 0; v8 = &vCrawlTable[0][1]; v19 = &vCrawlTable[0][1]; - do - { + do { v9 = 0; v21 = 0; - for ( i = 2 * (nRadius - RadiusAdj[v20]); v9 < i; v9 += 2 ) - { - if ( v21 ) + for (i = 2 * (nRadius - RadiusAdj[v20]); v9 < i; v9 += 2) { + if (v21) break; v26 = 0; v24 = 0; v25 = 0; v23 = 0; - if ( v27 ) - { - switch ( v27 ) - { - case 1: - v13 = v8[v9 - 1]; - v6 = v29 - (unsigned char)v13; - v31 = v8[v9]; - v7 = v28 - v31; - if ( (_BYTE)v13 && v31 ) - { - v25 = 1; + if (v27) { + switch (v27) { + case 1: + v13 = v8[v9 - 1]; + v6 = v29 - (unsigned char)v13; + v31 = v8[v9]; + v7 = v28 - v31; + if ((_BYTE)v13 && v31) { + v25 = 1; + v24 = 1; + } + break; + case 2: + v12 = v8[v9 - 1]; + v30 = v8[v9]; + v6 = v29 + (unsigned char)v12; + v7 = v28 - v30; + if ((_BYTE)v12 && v30) { + v26 = -1; + v23 = 1; + } + break; + case 3: + v10 = v8[v9 - 1]; + v6 = v29 - (unsigned char)v10; + v11 = v8[v9]; + v7 = v28 + v11; + if ((_BYTE)v10) { + if (v11) { + v25 = -1; v24 = 1; } - break; - case 2: - v12 = v8[v9 - 1]; - v30 = v8[v9]; - v6 = v29 + (unsigned char)v12; - v7 = v28 - v30; - if ( (_BYTE)v12 && v30 ) - { - v26 = -1; - v23 = 1; - } - break; - case 3: - v10 = v8[v9 - 1]; - v6 = v29 - (unsigned char)v10; - v11 = v8[v9]; - v7 = v28 + v11; - if ( (_BYTE)v10 ) - { - if ( v11 ) - { - v25 = -1; - v24 = 1; - } - } - break; + } + break; } - } - else - { + } else { v14 = v8[v9 - 1]; v15 = v8[v9]; v6 = v29 + v14; v7 = v28 + v15; - if ( v14 && v15 ) - { + if (v14 && v15) { v26 = -1; v23 = -1; } } - if ( v6 >= 0 && v6 <= 112 && v7 >= 0 && v7 <= 112 ) - { + if (v6 >= 0 && v6 <= 112 && v7 >= 0 && v7 <= 112) { v22 = v7 + 112 * v6; v21 = (unsigned char)nBlockTable[dPiece[0][v22]]; - if ( !nBlockTable[dPiece[0][v25 + v7 + 112 * (v6 + v26)]] - || !nBlockTable[dPiece[0][v23 + v7 + 112 * (v6 + v24)]] ) - { + if (!nBlockTable[dPiece[0][v25 + v7 + 112 * (v6 + v26)]] + || !nBlockTable[dPiece[0][v23 + v7 + 112 * (v6 + v24)]]) { v16 = v7 + 112 * v6; - if ( doautomap ) - { - if ( dFlags[0][v22] >= 0 ) - { + if (doautomap) { + if (dFlags[0][v22] >= 0) { SetAutomapView(v6, v7); v16 = v7 + 112 * v6; v8 = v19; } dFlags[0][v16] |= DFLAG_EXPLORED; } - if ( visible ) + if (visible) dFlags[0][v16] |= DFLAG_LIT; dFlags[0][v16] |= DFLAG_VISIBLE; - if ( !v21 ) - { + if (!v21) { v17 = dung_map[0][v16]; - if ( v17 ) + if (v17) TransList[v17] = 1; } } @@ -999,11 +933,9 @@ void __fastcall DoVision(int nXPos, int nYPos, int nRadius, unsigned char doauto ++v20; v8 += 30; v19 = v8; - } - while ( (signed int)v8 < (signed int)&vCrawlTable[23][1] ); + } while ((signed int)v8 < (signed int)&vCrawlTable[23][1]); ++v27; - } - while ( v27 < 4 ); + } while (v27 < 4); } void __cdecl FreeLightTable() @@ -1022,168 +954,140 @@ void __cdecl InitLightTable() void __cdecl MakeLightTable() { - char *v0; // ebx - signed int v1; // esi - unsigned char v2; // al - unsigned char v3; // cl - signed int v4; // edi - int v5; // edx - signed int v6; // edi - unsigned char v7; // cl - unsigned char v8; // al - signed int v9; // edx - unsigned char v10; // cl - unsigned char v11; // al - char *v12; // ebx - char *v13; // ebx - int v14; // ecx - signed int v15; // esi - char v16; // al - int v17; // edx - int v18; // ebx - signed int v19; // esi - _BYTE *v20; // ebx - char *v21; // ebx - int v22; // edi + char *v0; // ebx + signed int v1; // esi + unsigned char v2; // al + unsigned char v3; // cl + signed int v4; // edi + int v5; // edx + signed int v6; // edi + unsigned char v7; // cl + unsigned char v8; // al + signed int v9; // edx + unsigned char v10; // cl + unsigned char v11; // al + char *v12; // ebx + char *v13; // ebx + int v14; // ecx + signed int v15; // esi + char v16; // al + int v17; // edx + int v18; // ebx + signed int v19; // esi + _BYTE *v20; // ebx + char *v21; // ebx + int v22; // edi unsigned char *v23; // esi - signed int v24; // edx + signed int v24; // edx unsigned char *v25; // esi - signed int v26; // edx - signed int v27; // ecx - char v28; // al - _BYTE *v29; // ebx - signed int v30; // edx - char v31; // al - signed int v32; // ecx - signed int v33; // ecx - char v34; // al - int v35; // eax - signed int v36; // esi - char *v37; // eax - signed int v38; // ebx - int v39; // esi - double v40; // st7 - double v41; // st6 - int v42; // ecx - char *v43; // ecx - bool v44; // zf - char v45[16]; // [esp+14h] [ebp-2Ch] /* check */ - int v46; // [esp+24h] [ebp-1Ch] - int v47; // [esp+28h] [ebp-18h] - char *v48; // [esp+2Ch] [ebp-14h] - int v49; // [esp+30h] [ebp-10h] - int v50; // [esp+34h] [ebp-Ch] - int v51; // [esp+38h] [ebp-8h] - int v52; // [esp+3Ch] [ebp-4h] + signed int v26; // edx + signed int v27; // ecx + char v28; // al + _BYTE *v29; // ebx + signed int v30; // edx + char v31; // al + signed int v32; // ecx + signed int v33; // ecx + char v34; // al + int v35; // eax + signed int v36; // esi + char *v37; // eax + signed int v38; // ebx + int v39; // esi + double v40; // st7 + double v41; // st6 + int v42; // ecx + char *v43; // ecx + bool v44; // zf + char v45[16]; // [esp+14h] [ebp-2Ch] /* check */ + int v46; // [esp+24h] [ebp-1Ch] + int v47; // [esp+28h] [ebp-18h] + char *v48; // [esp+2Ch] [ebp-14h] + int v49; // [esp+30h] [ebp-10h] + int v50; // [esp+34h] [ebp-Ch] + int v51; // [esp+38h] [ebp-8h] + int v52; // [esp+3Ch] [ebp-4h] v51 = 0; v0 = pLightTbl; v1 = light4flag != 0 ? 3 : 15; v50 = light4flag != 0 ? 3 : 15; - if ( v1 > 0 ) - { + if (v1 > 0) { v49 = light4flag != 0 ? 3 : 15; - do - { + do { *v0++ = 0; v52 = 0; - do - { + do { v2 = 16 * v52 + 15; v3 = v51 + 16 * v52; v4 = 0; - do - { - if ( v4 || v52 ) + do { + if (v4 || v52) *v0++ = v3; - if ( v3 >= v2 ) - { + if (v3 >= v2) { v2 = 0; v3 = 0; - } - else - { + } else { ++v3; } ++v4; - } - while ( v4 < 16 ); + } while (v4 < 16); ++v52; - } - while ( v52 < 8 ); + } while (v52 < 8); v52 = 16; v5 = v51 >> 1; - do - { + do { v6 = 8; v7 = v5 + 8 * v52; v8 = 8 * v52 + 7; - do - { + do { *v0++ = v7; - if ( v7 >= v8 ) - { + if (v7 >= v8) { v8 = 0; v7 = 0; - } - else - { + } else { ++v7; } --v6; - } - while ( v6 ); + } while (v6); ++v52; - } - while ( v52 < 20 ); + } while (v52 < 20); v52 = 10; - do - { + do { v9 = 16; v10 = v51 + 16 * v52; v11 = 16 * v52 + 15; - do - { + do { *v0++ = v10; - if ( v10 >= v11 ) - { + if (v10 >= v11) { v11 = 0; v10 = 0; - } - else - { + } else { ++v10; } - if ( v10 == LOBYTE(-1) ) - { + if (v10 == LOBYTE(-1)) { v11 = 0; v10 = 0; } --v9; - } - while ( v9 ); + } while (v9); ++v52; - } - while ( v52 < 16 ); - if ( light4flag ) + } while (v52 < 16); + if (light4flag) v51 += 5; else ++v51; --v49; - } - while ( v49 ); + } while (v49); } memset(v0, 0, 0x100u); v12 = v0 + 256; - if ( leveltype == DTYPE_HELL ) - { + if (leveltype == DTYPE_HELL) { v13 = pLightTbl; - if ( v1 > 0 ) - { + if (v1 > 0) { v14 = v50; v49 = v50; - do - { + do { v52 = 0; v45[0] = 0; v51 = v14; @@ -1191,25 +1095,21 @@ void __cdecl MakeLightTable() v48 = (char *)(v50 / v14); v47 = v50 % v14; v16 = 1; - do - { + do { v17 = v51; v45[v15] = v16; v51 = v47 + v17; - if ( v47 + v17 > v14 && v15 < 15 ) - { + if (v47 + v17 > v14 && v15 < 15) { ++v15; v51 -= v14; v45[v15] = v16; } - if ( (char *)++v52 == v48 ) - { + if ((char *)++v52 == v48) { ++v16; v52 = 0; } ++v15; - } - while ( v15 < 16 ); + } while (v15 < 16); *v13 = 0; v18 = (int)(v13 + 1); *(_DWORD *)v18 = *(_DWORD *)&v45[1]; @@ -1221,13 +1121,12 @@ void __cdecl MakeLightTable() v20 = (_BYTE *)(v18 + 15); do *v20++ = v45[v19--]; - while ( v19 > 0 ); + while (v19 > 0); *v20 = 1; v13 = (char *)v20 + 225; --v14; --v49; - } - while ( v49 ); + } while (v49); } *v13 = 0; v21 = v13 + 1; @@ -1241,126 +1140,104 @@ void __cdecl MakeLightTable() v24 = 0; do *v12++ = v23[v24++]; - while ( v24 < 256 ); + while (v24 < 256); mem_free_dbg(v23); v25 = LoadFileInMem("PlrGFX\\Stone.TRN", 0); v26 = 0; do *v12++ = v25[v26++]; - while ( v26 < 256 ); + while (v26 < 256); mem_free_dbg(v25); v27 = 0; - do - { + do { v28 = -30; - do - { - if ( v27 || v28 != -30 ) + do { + if (v27 || v28 != -30) *v12 = v28; else *v12 = 0; ++v12; ++v28; - } - while ( (unsigned char)v28 < 0xEFu ); + } while ((unsigned char)v28 < 0xEFu); *v12 = 0; v29 = (unsigned char *)v12 + 1; *v29++ = 0; *v29 = 0; v12 = (char *)v29 + 1; ++v27; - } - while ( v27 < 8 ); + } while (v27 < 8); v30 = 4; - do - { + do { v31 = -32; v32 = 8; - do - { + do { *v12++ = v31; v31 += 2; --v32; - } - while ( v32 ); + } while (v32); --v30; - } - while ( v30 ); + } while (v30); v33 = 6; - do - { + do { v34 = -32; do *v12++ = v34++; - while ( (unsigned char)v34 < 0xEFu ); + while ((unsigned char)v34 < 0xEFu); *v12++ = 0; --v33; - } - while ( v33 ); + } while (v33); v35 = 0; v51 = (int)dung_map_radius; v52 = 8; - do - { + do { v36 = 0; v49 = 0; v50 = v35 + 1; - do - { - if ( v36 <= v52 ) + do { + if (v36 <= v52) *(_BYTE *)(v51 + v36) = (signed __int64)((double)v49 * 15.0 / ((double)v50 * 8.0) + 0.5); else *(_BYTE *)(v51 + v36) = 15; v49 = ++v36; - } - while ( v36 < 128 ); + } while (v36 < 128); v52 += 8; v51 += 128; v35 = v50; - } - while ( v52 < 136 ); + } while (v52 < 136); v49 = 0; v37 = dung_map_rgba; - do - { + do { v52 = 0; - do - { + do { v48 = v37; v50 = v49; v47 = 16; - do - { + do { v38 = 0; v39 = v50 * v50; v51 = v52; - do - { + do { v46 = v39 + v51 * v51; v46 = (unsigned char)(signed __int64)sqrt((double)v46); v40 = (double)v46; - if ( v40 >= 0.0 ) + if (v40 >= 0.0) v41 = 0.5; else v41 = -0.5; v42 = (int)v48; v51 += 8; v48[v38++] = (signed __int64)(v41 + v40); - } - while ( v38 < 16 ); + } while (v38 < 16); v50 += 8; v43 = (char *)(v42 + 16); v44 = v47-- == 1; v48 = v43; - } - while ( !v44 ); + } while (!v44); --v52; v37 = v43; - } - while ( v52 > -8 ); + } while (v52 > -8); --v49; - } - while ( (signed int)v43 < (signed int)&dung_map_rgba[16384] ); + } while ((signed int)v43 < (signed int)&dung_map_rgba[16384]); } // 525728: using guessed type int light4flag; @@ -1370,18 +1247,13 @@ void __cdecl ToggleLighting() int i; lightflag ^= 1; - if ( lightflag ) - { + if (lightflag) { memset(dTransVal, 0, sizeof(dTransVal)); - } - else - { + } else { memcpy(dTransVal, dTransVal2, sizeof(dTransVal)); - for(i = 0; i < 4; i++) - { - if ( plr[i].plractive ) - { - if ( currlevel == plr[i].plrlevel ) + for (i = 0; i < 4; i++) { + if (plr[i].plractive) { + if (currlevel == plr[i].plrlevel) DoLighting(plr[i].WorldX, plr[i].WorldY, plr[i]._pLightRad, -1); } } @@ -1404,12 +1276,10 @@ void __cdecl InitLighting() numlights = 0; dolighting = 0; lightflag = 0; - do - { + do { lightactive[v0] = v0; ++v0; - } - while ( v0 < 32 ); + } while (v0 < 32); } // 642A18: using guessed type int dolighting; // 646A28: using guessed type int lightflag; @@ -1419,8 +1289,7 @@ int __fastcall AddLight(int x, int y, int r) int lid; // eax lid = -1; - if ( !lightflag && numlights < 32 ) - { + if (!lightflag && numlights < 32) { lid = lightactive[numlights++]; dolighting = 1; LightList[lid]._lx = x; @@ -1438,8 +1307,7 @@ int __fastcall AddLight(int x, int y, int r) void __fastcall AddUnLight(int i) { - if ( !lightflag && i != -1 ) - { + if (!lightflag && i != -1) { LightList[i]._ldel = 1; dolighting = 1; } @@ -1449,8 +1317,7 @@ void __fastcall AddUnLight(int i) void __fastcall ChangeLightRadius(int i, int r) { - if ( !lightflag && i != -1 ) - { + if (!lightflag && i != -1) { LightList[i]._lunx = LightList[i]._lx; LightList[i]._luny = LightList[i]._ly; LightList[i]._lunflag = 1; @@ -1464,8 +1331,7 @@ void __fastcall ChangeLightRadius(int i, int r) void __fastcall ChangeLightXY(int i, int x, int y) { - if ( !lightflag && i != -1 ) - { + if (!lightflag && i != -1) { LightList[i]._lunx = LightList[i]._lx; LightList[i]._lunflag = 1; dolighting = 1; @@ -1480,8 +1346,7 @@ void __fastcall ChangeLightXY(int i, int x, int y) void __fastcall ChangeLightOff(int i, int x, int y) { - if ( !lightflag && i != -1 ) - { + if (!lightflag && i != -1) { LightList[i]._xoff = x; LightList[i]._lunx = LightList[i]._lx; LightList[i]._luny = LightList[i]._ly; @@ -1496,8 +1361,7 @@ void __fastcall ChangeLightOff(int i, int x, int y) void __fastcall ChangeLight(int i, int x, int y, int r) { - if ( !lightflag && i != -1 ) - { + if (!lightflag && i != -1) { LightList[i]._lunx = LightList[i]._lx; LightList[i]._luny = LightList[i]._ly; LightList[i]._lunr = LightList[i]._lradius; @@ -1513,65 +1377,52 @@ void __fastcall ChangeLight(int i, int x, int y, int r) void __cdecl ProcessLightList() { - int v0; // ebp - int v1; // edi - int v2; // esi - int i; // esi - int v4; // eax - int v5; // ecx + int v0; // ebp + int v1; // edi + int v2; // esi + int i; // esi + int v4; // eax + int v5; // ecx unsigned char v6; // bl - char v7; // dl + char v7; // dl v0 = 0; - if ( !lightflag ) - { - if ( dolighting ) - { + if (!lightflag) { + if (dolighting) { v1 = numlights; - if ( numlights > 0 ) - { - do - { + if (numlights > 0) { + do { v2 = (unsigned char)lightactive[v0]; - if ( LightList[v2]._ldel ) + if (LightList[v2]._ldel) DoUnLight(LightList[v2]._lx, LightList[v2]._ly, LightList[v2]._lradius); - if ( LightList[v2]._lunflag ) - { + if (LightList[v2]._lunflag) { DoUnLight(LightList[v2]._lunx, LightList[v2]._luny, LightList[v2]._lunr); LightList[v2]._lunflag = 0; } ++v0; - } - while ( v0 < v1 ); + } while (v0 < v1); } - for ( i = 0; i < v1; ++i ) - { + for (i = 0; i < v1; ++i) { v4 = (unsigned char)lightactive[i]; - if ( !LightList[v4]._ldel ) + if (!LightList[v4]._ldel) DoLighting( - LightList[v4]._lx, - LightList[v4]._ly, - LightList[v4]._lradius, - (unsigned char)lightactive[i]); + LightList[v4]._lx, + LightList[v4]._ly, + LightList[v4]._lradius, + (unsigned char)lightactive[i]); } v5 = 0; - if ( v1 > 0 ) - { - do - { + if (v1 > 0) { + do { v6 = lightactive[v5]; - if ( LightList[v6]._ldel ) - { + if (LightList[v6]._ldel) { v7 = lightactive[--v1]; lightactive[v1] = v6; lightactive[v5] = v7; - } - else - { + } else { ++v5; } - } - while ( v5 < v1 ); + } while (v5 < v1); numlights = v1; } } @@ -1591,7 +1442,7 @@ void __cdecl InitVision() numvision = 0; dovision = 0; visionid = 1; - if ( TransVal > 0 ) + if (TransVal > 0) memset(TransList, 0, TransVal); } // 5A5590: using guessed type char TransVal; @@ -1600,11 +1451,10 @@ void __cdecl InitVision() int __fastcall AddVision(int x, int y, int r, BOOL mine) { int vid; // eax - int v5; // esi + int v5; // esi vid = r; - if ( numvision < 32 ) - { + if (numvision < 32) { v5 = numvision; dovision = 1; VisionList[v5]._lx = x; @@ -1625,12 +1475,9 @@ void __fastcall ChangeVisionRadius(int id, int r) { int i; // esi - if ( numvision > 0 ) - { - for(i = 0; i < numvision; i++) - { - if ( VisionList[i]._lid == id ) - { + if (numvision > 0) { + for (i = 0; i < numvision; i++) { + if (VisionList[i]._lid == id) { VisionList[i]._lunflag = 1; VisionList[i]._lunx = VisionList[i]._lx; VisionList[i]._luny = VisionList[i]._ly; @@ -1647,12 +1494,9 @@ void __fastcall ChangeVisionXY(int id, int x, int y) { int i; // esi - if ( numvision > 0 ) - { - for(i = 0; i < numvision; i++) - { - if ( VisionList[i]._lid == id ) - { + if (numvision > 0) { + for (i = 0; i < numvision; i++) { + if (VisionList[i]._lid == id) { VisionList[i]._lunflag = 1; VisionList[i]._lunx = VisionList[i]._lx; VisionList[i]._luny = VisionList[i]._ly; @@ -1671,45 +1515,37 @@ void __cdecl ProcessVisionList() bool delflag; // ecx int i; - if ( dovision ) - { - for(i = 0; i < numvision; i++) - { - if ( VisionList[i]._ldel ) + if (dovision) { + for (i = 0; i < numvision; i++) { + if (VisionList[i]._ldel) DoUnVision(VisionList[i]._lx, VisionList[i]._ly, VisionList[i]._lradius); - if ( VisionList[i]._lunflag ) - { + if (VisionList[i]._lunflag) { DoUnVision(VisionList[i]._lunx, VisionList[i]._luny, VisionList[i]._lunr); VisionList[i]._lunflag = 0; } } - if ( TransVal > 0 ) + if (TransVal > 0) memset(TransList, 0, TransVal); - for(i = 0; i < numvision; i++) - { - if ( !VisionList[i]._ldel ) + for (i = 0; i < numvision; i++) { + if (!VisionList[i]._ldel) DoVision(VisionList[i]._lx, VisionList[i]._ly, VisionList[i]._lradius, VisionList[i]._lflags & 1, VisionList[i]._lflags & 1); } - do - { + do { delflag = 0; - if ( numvision <= 0 ) + if (numvision <= 0) break; - for(i = 0; i < numvision; i++) - { - if ( VisionList[i]._ldel ) - { + for (i = 0; i < numvision; i++) { + if (VisionList[i]._ldel) { --numvision; - if ( numvision > 0 && i != numvision ) + if (numvision > 0 && i != numvision) qmemcpy(&VisionList[i], &VisionList[numvision], sizeof(LightListStruct)); delflag = 1; } } - } - while ( delflag ); + } while (delflag); } dovision = 0; @@ -1719,21 +1555,18 @@ void __cdecl ProcessVisionList() void __cdecl lighting_color_cycling() { - char *v0; // eax - signed int v1; // ebx - char *v2; // eax - char *v3; // edi - char v4; // dl + char *v0; // eax + signed int v1; // ebx + char *v2; // eax + char *v3; // edi + char v4; // dl const void *v5; // esi - if ( leveltype == DTYPE_HELL ) - { + if (leveltype == DTYPE_HELL) { v0 = pLightTbl; - if ( (light4flag != 0 ? 4 : 16) > 0 ) - { + if ((light4flag != 0 ? 4 : 16) > 0) { v1 = light4flag != 0 ? 4 : 16; - do - { + do { v2 = v0 + 1; v3 = v2; v4 = *v2; @@ -1743,8 +1576,7 @@ void __cdecl lighting_color_cycling() *v2 = v4; v0 = v2 + 225; --v1; - } - while ( v1 ); + } while (v1); } } } diff --git a/Source/lighting.h b/Source/lighting.h index 7acd8a93..e7b28872 100644 --- a/Source/lighting.h +++ b/Source/lighting.h @@ -7,10 +7,10 @@ extern char lightactive[32]; extern LightListStruct LightList[32]; extern int numlights; extern char dung_map_radius[2048]; /* char [16][128] */ -extern int dovision; // weak +extern int dovision; // weak extern int numvision; -extern char lightmax; // weak -extern int dolighting; // weak +extern char lightmax; // weak +extern int dolighting; // weak extern char dung_map_rgba[16384]; /* int [64][64] short [64][128] char [64][256] */ extern int visionid; extern char *pLightTbl; /* todo: struct? */ diff --git a/Source/loadsave.cpp b/Source/loadsave.cpp index 1a228f34..fec5e68b 100644 --- a/Source/loadsave.cpp +++ b/Source/loadsave.cpp @@ -6,692 +6,692 @@ unsigned char *tbuff; void __fastcall LoadGame(BOOL firstflag) { - int i, j; - DWORD dwLen; - char szName[MAX_PATH]; + int i, j; + DWORD dwLen; + char szName[MAX_PATH]; - FreeGameMem(); - pfile_remove_temp_files(); - pfile_get_game_name(szName); - BYTE *LoadBuff = pfile_read(szName, &dwLen); - tbuff = LoadBuff; + FreeGameMem(); + pfile_remove_temp_files(); + pfile_get_game_name(szName); + BYTE *LoadBuff = pfile_read(szName, &dwLen); + tbuff = LoadBuff; - if (ILoad() != 'RETL') - TermMsg("Invalid save file"); + if (ILoad() != 'RETL') + TermMsg("Invalid save file"); - setlevel = OLoad(); - setlvlnum = WLoad(); - currlevel = WLoad(); - leveltype = WLoad(); - int _ViewX = WLoad(); - int _ViewY = WLoad(); - invflag = OLoad(); - chrflag = OLoad(); - int _nummonsters = WLoad(); - int _numitems = WLoad(); - int _nummissiles = WLoad(); - int _nobjects = WLoad(); + setlevel = OLoad(); + setlvlnum = WLoad(); + currlevel = WLoad(); + leveltype = WLoad(); + int _ViewX = WLoad(); + int _ViewY = WLoad(); + invflag = OLoad(); + chrflag = OLoad(); + int _nummonsters = WLoad(); + int _numitems = WLoad(); + int _nummissiles = WLoad(); + int _nobjects = WLoad(); - for (i = 0; i < NUMLEVELS; i++) { - glSeedTbl[i] = ILoad(); - gnLevelTypeTbl[i] = WLoad(); - } + for (i = 0; i < NUMLEVELS; i++) { + glSeedTbl[i] = ILoad(); + gnLevelTypeTbl[i] = WLoad(); + } - LoadPlayer(myplr); + LoadPlayer(myplr); - for (i = 0; i < MAXQUESTS; i++) - LoadQuest(i); - for (i = 0; i < MAXPORTAL; i++) - LoadPortal(i); + for (i = 0; i < MAXQUESTS; i++) + LoadQuest(i); + for (i = 0; i < MAXPORTAL; i++) + LoadPortal(i); - LoadGameLevel(firstflag, 4); - SyncInitPlr(myplr); - SyncPlrAnim(myplr); + LoadGameLevel(firstflag, 4); + SyncInitPlr(myplr); + SyncPlrAnim(myplr); - ViewX = _ViewX; - ViewY = _ViewY; - nummonsters = _nummonsters; - numitems = _numitems; - nummissiles = _nummissiles; - nobjects = _nobjects; + ViewX = _ViewX; + ViewY = _ViewY; + nummonsters = _nummonsters; + numitems = _numitems; + nummissiles = _nummissiles; + nobjects = _nobjects; - for (i = 0; i < MAXMONSTERS; i++) - monstkills[i] = ILoad(); + for (i = 0; i < MAXMONSTERS; i++) + monstkills[i] = ILoad(); - if (leveltype) { - for (i = 0; i < MAXMONSTERS; i++) - monstactive[i] = WLoad(); - for (i = 0; i < nummonsters; i++) - LoadMonster(monstactive[i]); - for (i = 0; i < MAXMISSILES; i++) - missileactive[i] = BLoad(); - for (i = 0; i < MAXMISSILES; i++) - missileavail[i] = BLoad(); - for (i = 0; i < nummissiles; i++) - LoadMissile(missileactive[i]); - for (i = 0; i < MAXOBJECTS; i++) - objectactive[i] = BLoad(); - for (i = 0; i < MAXOBJECTS; i++) - objectavail[i] = BLoad(); - for (i = 0; i < nobjects; i++) - LoadObject(objectactive[i]); - for (i = 0; i < nobjects; i++) - SyncObjectAnim(objectactive[i]); + if (leveltype) { + for (i = 0; i < MAXMONSTERS; i++) + monstactive[i] = WLoad(); + for (i = 0; i < nummonsters; i++) + LoadMonster(monstactive[i]); + for (i = 0; i < MAXMISSILES; i++) + missileactive[i] = BLoad(); + for (i = 0; i < MAXMISSILES; i++) + missileavail[i] = BLoad(); + for (i = 0; i < nummissiles; i++) + LoadMissile(missileactive[i]); + for (i = 0; i < MAXOBJECTS; i++) + objectactive[i] = BLoad(); + for (i = 0; i < MAXOBJECTS; i++) + objectavail[i] = BLoad(); + for (i = 0; i < nobjects; i++) + LoadObject(objectactive[i]); + for (i = 0; i < nobjects; i++) + SyncObjectAnim(objectactive[i]); - numlights = WLoad(); + numlights = WLoad(); - for (i = 0; i < 32; i++) - lightactive[i] = BLoad(); - for (i = 0; i < numlights; i++) - LoadLighting((unsigned char)lightactive[i]); + for (i = 0; i < 32; i++) + lightactive[i] = BLoad(); + for (i = 0; i < numlights; i++) + LoadLighting((unsigned char)lightactive[i]); - visionid = WLoad(); - numvision = WLoad(); + visionid = WLoad(); + numvision = WLoad(); - for (i = 0; i < numvision; i++) - LoadVision(i); - } + for (i = 0; i < numvision; i++) + LoadVision(i); + } - for (i = 0; i < MAXITEMS; i++) - itemactive[i] = BLoad(); - for (i = 0; i < MAXITEMS; i++) - itemavail[i] = BLoad(); - for (i = 0; i < numitems; i++) - LoadItem(itemactive[i]); - for (i = 0; i < 128; i++) - UniqueItemFlag[i] = OLoad(); + for (i = 0; i < MAXITEMS; i++) + itemactive[i] = BLoad(); + for (i = 0; i < MAXITEMS; i++) + itemavail[i] = BLoad(); + for (i = 0; i < numitems; i++) + LoadItem(itemactive[i]); + for (i = 0; i < 128; i++) + UniqueItemFlag[i] = OLoad(); - for (j = 0; j < MAXDUNY; j++) { - for (i = 0; i < MAXDUNX; i++) - dTransVal[i][j] = BLoad(); - } - for (j = 0; j < MAXDUNY; j++) { - for (i = 0; i < MAXDUNX; i++) - dFlags[i][j] = BLoad(); - } - for (j = 0; j < MAXDUNY; j++) { - for (i = 0; i < MAXDUNX; i++) - dPlayer[i][j] = BLoad(); - } - for (j = 0; j < MAXDUNY; j++) { - for (i = 0; i < MAXDUNX; i++) - dItem[i][j] = BLoad(); - } + for (j = 0; j < MAXDUNY; j++) { + for (i = 0; i < MAXDUNX; i++) + dTransVal[i][j] = BLoad(); + } + for (j = 0; j < MAXDUNY; j++) { + for (i = 0; i < MAXDUNX; i++) + dFlags[i][j] = BLoad(); + } + for (j = 0; j < MAXDUNY; j++) { + for (i = 0; i < MAXDUNX; i++) + dPlayer[i][j] = BLoad(); + } + for (j = 0; j < MAXDUNY; j++) { + for (i = 0; i < MAXDUNX; i++) + dItem[i][j] = BLoad(); + } - if (leveltype) { - for (j = 0; j < MAXDUNY; j++) { - for (i = 0; i < MAXDUNX; i++) - dMonster[i][j] = WLoad(); - } - for (j = 0; j < MAXDUNY; j++) { - for (i = 0; i < MAXDUNX; i++) - dDead[i][j] = BLoad(); - } - for (j = 0; j < MAXDUNY; j++) { - for (i = 0; i < MAXDUNX; i++) - dObject[i][j] = BLoad(); - } - for (j = 0; j < MAXDUNY; j++) { - for (i = 0; i < MAXDUNX; i++) - dTransVal[i][j] = BLoad(); - } - for (j = 0; j < MAXDUNY; j++) { - for (i = 0; i < MAXDUNX; i++) - dTransVal2[i][j] = BLoad(); - } - for (j = 0; j < DMAXY; j++) { - for (i = 0; i < DMAXX; i++) - automapview[i][j] = OLoad(); - } - for (j = 0; j < MAXDUNY; j++) { - for (i = 0; i < MAXDUNX; i++) - dMissile[i][j] = BLoad(); - } - } + if (leveltype) { + for (j = 0; j < MAXDUNY; j++) { + for (i = 0; i < MAXDUNX; i++) + dMonster[i][j] = WLoad(); + } + for (j = 0; j < MAXDUNY; j++) { + for (i = 0; i < MAXDUNX; i++) + dDead[i][j] = BLoad(); + } + for (j = 0; j < MAXDUNY; j++) { + for (i = 0; i < MAXDUNX; i++) + dObject[i][j] = BLoad(); + } + for (j = 0; j < MAXDUNY; j++) { + for (i = 0; i < MAXDUNX; i++) + dTransVal[i][j] = BLoad(); + } + for (j = 0; j < MAXDUNY; j++) { + for (i = 0; i < MAXDUNX; i++) + dTransVal2[i][j] = BLoad(); + } + for (j = 0; j < DMAXY; j++) { + for (i = 0; i < DMAXX; i++) + automapview[i][j] = OLoad(); + } + for (j = 0; j < MAXDUNY; j++) { + for (i = 0; i < MAXDUNX; i++) + dMissile[i][j] = BLoad(); + } + } - numpremium = WLoad(); - premiumlevel = WLoad(); + numpremium = WLoad(); + premiumlevel = WLoad(); - for (i = 0; i < 6; i++) - LoadPremium(i); + for (i = 0; i < 6; i++) + LoadPremium(i); - automapflag = OLoad(); - AutoMapScale = WLoad(); - mem_free_dbg(LoadBuff); - AutomapZoomReset(); - ResyncQuests(); + automapflag = OLoad(); + AutoMapScale = WLoad(); + mem_free_dbg(LoadBuff); + AutomapZoomReset(); + ResyncQuests(); - if (leveltype) - ProcessLightList(); + if (leveltype) + ProcessLightList(); - RedoPlayerVision(); - ProcessVisionList(); - missiles_process_charge(); - ResetPal(); - SetCursor(CURSOR_HAND); - gbProcessPlayers = TRUE; + RedoPlayerVision(); + ProcessVisionList(); + missiles_process_charge(); + ResetPal(); + SetCursor(CURSOR_HAND); + gbProcessPlayers = TRUE; } // 5CF31D: using guessed type char setlevel; char __cdecl BLoad() { - return *tbuff++; + return *tbuff++; } int __cdecl WLoad() { - int rv = *tbuff++ << 24; - rv |= *tbuff++ << 16; - rv |= *tbuff++ << 8; - rv |= *tbuff++; + int rv = *tbuff++ << 24; + rv |= *tbuff++ << 16; + rv |= *tbuff++ << 8; + rv |= *tbuff++; - return rv; + return rv; } int __cdecl ILoad() { - int rv = *tbuff++ << 24; - rv |= *tbuff++ << 16; - rv |= *tbuff++ << 8; - rv |= *tbuff++; + int rv = *tbuff++ << 24; + rv |= *tbuff++ << 16; + rv |= *tbuff++ << 8; + rv |= *tbuff++; - return rv; + return rv; } BOOL __cdecl OLoad() { - if (*tbuff++ == TRUE) - return TRUE; - else - return FALSE; + if (*tbuff++ == TRUE) + return TRUE; + else + return FALSE; } void __fastcall LoadPlayer(int i) { - memcpy(&plr[i], tbuff, sizeof(*plr) - (10 * sizeof(void *))); - tbuff += sizeof(*plr) - (10 * sizeof(void *)); // omit last 10 pointers + memcpy(&plr[i], tbuff, sizeof(*plr) - (10 * sizeof(void *))); + tbuff += sizeof(*plr) - (10 * sizeof(void *)); // omit last 10 pointers } void __fastcall LoadMonster(int i) { - memcpy(&monster[i], tbuff, sizeof(*monster) - (3 * sizeof(void *))); - tbuff += sizeof(*monster) - (3 * sizeof(void *)); // omit last 3 pointers - SyncMonsterAnim(i); + memcpy(&monster[i], tbuff, sizeof(*monster) - (3 * sizeof(void *))); + tbuff += sizeof(*monster) - (3 * sizeof(void *)); // omit last 3 pointers + SyncMonsterAnim(i); } void __fastcall LoadMissile(int i) { - memcpy(&missile[i], tbuff, sizeof(*missile)); - tbuff += sizeof(*missile); + memcpy(&missile[i], tbuff, sizeof(*missile)); + tbuff += sizeof(*missile); } void __fastcall LoadObject(int i) { - memcpy(&object[i], tbuff, sizeof(*object)); - tbuff += sizeof(*object); + memcpy(&object[i], tbuff, sizeof(*object)); + tbuff += sizeof(*object); } void __fastcall LoadItem(int i) { - memcpy(&item[i], tbuff, sizeof(*item)); - tbuff += sizeof(*item); - GetItemFrm(i); + memcpy(&item[i], tbuff, sizeof(*item)); + tbuff += sizeof(*item); + GetItemFrm(i); } void __fastcall LoadPremium(int i) { - memcpy(&premiumitem[i], tbuff, sizeof(*premiumitem)); - tbuff += sizeof(*premiumitem); + memcpy(&premiumitem[i], tbuff, sizeof(*premiumitem)); + tbuff += sizeof(*premiumitem); } void __fastcall LoadQuest(int i) { - memcpy(&quests[i], tbuff, sizeof(*quests)); - tbuff += sizeof(*quests); - ReturnLvlX = WLoad(); - ReturnLvlY = WLoad(); - ReturnLvl = WLoad(); - ReturnLvlT = WLoad(); - DoomQuestState = WLoad(); + memcpy(&quests[i], tbuff, sizeof(*quests)); + tbuff += sizeof(*quests); + ReturnLvlX = WLoad(); + ReturnLvlY = WLoad(); + ReturnLvl = WLoad(); + ReturnLvlT = WLoad(); + DoomQuestState = WLoad(); } void __fastcall LoadLighting(int i) { - memcpy(&LightList[i], tbuff, sizeof(*LightList)); - tbuff += sizeof(*LightList); + memcpy(&LightList[i], tbuff, sizeof(*LightList)); + tbuff += sizeof(*LightList); } void __fastcall LoadVision(int i) { - memcpy(&VisionList[i], tbuff, sizeof(*VisionList)); - tbuff += sizeof(*VisionList); + memcpy(&VisionList[i], tbuff, sizeof(*VisionList)); + tbuff += sizeof(*VisionList); } void __fastcall LoadPortal(int i) { - memcpy(&portal[i], tbuff, sizeof(*portal)); - tbuff += sizeof(*portal); + memcpy(&portal[i], tbuff, sizeof(*portal)); + tbuff += sizeof(*portal); } void __cdecl SaveGame() { - int i, j; - char szName[MAX_PATH]; + int i, j; + char szName[MAX_PATH]; - DWORD dwLen = codec_get_encoded_len(FILEBUFF); - BYTE *SaveBuff = DiabloAllocPtr(dwLen); - tbuff = SaveBuff; + DWORD dwLen = codec_get_encoded_len(FILEBUFF); + BYTE *SaveBuff = DiabloAllocPtr(dwLen); + tbuff = SaveBuff; - ISave('RETL'); - OSave((unsigned char)setlevel); - WSave(setlvlnum); - WSave(currlevel); - WSave((unsigned char)leveltype); - WSave(ViewX); - WSave(ViewY); - OSave(invflag); - OSave(chrflag); - WSave(nummonsters); - WSave(numitems); - WSave(nummissiles); - WSave(nobjects); + ISave('RETL'); + OSave((unsigned char)setlevel); + WSave(setlvlnum); + WSave(currlevel); + WSave((unsigned char)leveltype); + WSave(ViewX); + WSave(ViewY); + OSave(invflag); + OSave(chrflag); + WSave(nummonsters); + WSave(numitems); + WSave(nummissiles); + WSave(nobjects); - for (i = 0; i < NUMLEVELS; i++) { - ISave(glSeedTbl[i]); - WSave(gnLevelTypeTbl[i]); - } + for (i = 0; i < NUMLEVELS; i++) { + ISave(glSeedTbl[i]); + WSave(gnLevelTypeTbl[i]); + } - SavePlayer(myplr); + SavePlayer(myplr); - for (i = 0; i < MAXQUESTS; i++) - SaveQuest(i); - for (i = 0; i < MAXPORTAL; i++) - SavePortal(i); - for (i = 0; i < MAXMONSTERS; i++) - ISave(monstkills[i]); + for (i = 0; i < MAXQUESTS; i++) + SaveQuest(i); + for (i = 0; i < MAXPORTAL; i++) + SavePortal(i); + for (i = 0; i < MAXMONSTERS; i++) + ISave(monstkills[i]); - if (leveltype) { - for (i = 0; i < MAXMONSTERS; i++) - WSave(monstactive[i]); - for (i = 0; i < nummonsters; i++) - SaveMonster(monstactive[i]); - for (i = 0; i < MAXMISSILES; i++) - BSave(missileactive[i]); - for (i = 0; i < MAXMISSILES; i++) - BSave(missileavail[i]); - for (i = 0; i < nummissiles; i++) - SaveMissile(missileactive[i]); - for (i = 0; i < MAXOBJECTS; i++) - BSave(objectactive[i]); - for (i = 0; i < MAXOBJECTS; i++) - BSave(objectavail[i]); - for (i = 0; i < nobjects; i++) - SaveObject(objectactive[i]); + if (leveltype) { + for (i = 0; i < MAXMONSTERS; i++) + WSave(monstactive[i]); + for (i = 0; i < nummonsters; i++) + SaveMonster(monstactive[i]); + for (i = 0; i < MAXMISSILES; i++) + BSave(missileactive[i]); + for (i = 0; i < MAXMISSILES; i++) + BSave(missileavail[i]); + for (i = 0; i < nummissiles; i++) + SaveMissile(missileactive[i]); + for (i = 0; i < MAXOBJECTS; i++) + BSave(objectactive[i]); + for (i = 0; i < MAXOBJECTS; i++) + BSave(objectavail[i]); + for (i = 0; i < nobjects; i++) + SaveObject(objectactive[i]); - WSave(numlights); + WSave(numlights); - for (i = 0; i < 32; i++) - BSave(lightactive[i]); - for (i = 0; i < numlights; i++) - SaveLighting((unsigned char)lightactive[i]); + for (i = 0; i < 32; i++) + BSave(lightactive[i]); + for (i = 0; i < numlights; i++) + SaveLighting((unsigned char)lightactive[i]); - WSave(visionid); - WSave(numvision); + WSave(visionid); + WSave(numvision); - for (i = 0; i < numvision; i++) - SaveVision(i); - } + for (i = 0; i < numvision; i++) + SaveVision(i); + } - for (i = 0; i < MAXITEMS; i++) - BSave(itemactive[i]); - for (i = 0; i < MAXITEMS; i++) - BSave(itemavail[i]); - for (i = 0; i < numitems; i++) - SaveItem(itemactive[i]); - for (i = 0; i < 128; i++) - OSave(UniqueItemFlag[i]); + for (i = 0; i < MAXITEMS; i++) + BSave(itemactive[i]); + for (i = 0; i < MAXITEMS; i++) + BSave(itemavail[i]); + for (i = 0; i < numitems; i++) + SaveItem(itemactive[i]); + for (i = 0; i < 128; i++) + OSave(UniqueItemFlag[i]); - for (j = 0; j < MAXDUNY; j++) { - for (i = 0; i < MAXDUNX; i++) - BSave(dTransVal[i][j]); - } - for (j = 0; j < MAXDUNY; j++) { - for (i = 0; i < MAXDUNX; i++) - BSave(dFlags[i][j] & ~(DFLAG_MISSILE | DFLAG_VISIBLE | DFLAG_DEAD_PLAYER)); - } - for (j = 0; j < MAXDUNY; j++) { - for (i = 0; i < MAXDUNX; i++) - BSave(dPlayer[i][j]); - } - for (j = 0; j < MAXDUNY; j++) { - for (i = 0; i < MAXDUNX; i++) - BSave(dItem[i][j]); - } + for (j = 0; j < MAXDUNY; j++) { + for (i = 0; i < MAXDUNX; i++) + BSave(dTransVal[i][j]); + } + for (j = 0; j < MAXDUNY; j++) { + for (i = 0; i < MAXDUNX; i++) + BSave(dFlags[i][j] & ~(DFLAG_MISSILE | DFLAG_VISIBLE | DFLAG_DEAD_PLAYER)); + } + for (j = 0; j < MAXDUNY; j++) { + for (i = 0; i < MAXDUNX; i++) + BSave(dPlayer[i][j]); + } + for (j = 0; j < MAXDUNY; j++) { + for (i = 0; i < MAXDUNX; i++) + BSave(dItem[i][j]); + } - if (leveltype) { - for (j = 0; j < MAXDUNY; j++) { - for (i = 0; i < MAXDUNX; i++) - WSave(dMonster[i][j]); - } - for (j = 0; j < MAXDUNY; j++) { - for (i = 0; i < MAXDUNX; i++) - BSave(dDead[i][j]); - } - for (j = 0; j < MAXDUNY; j++) { - for (i = 0; i < MAXDUNX; i++) - BSave(dObject[i][j]); - } - for (j = 0; j < MAXDUNY; j++) { - for (i = 0; i < MAXDUNX; i++) - BSave(dTransVal[i][j]); - } - for (j = 0; j < MAXDUNY; j++) { - for (i = 0; i < MAXDUNX; i++) - BSave(dTransVal2[i][j]); - } - for (j = 0; j < DMAXY; j++) { - for (i = 0; i < DMAXX; i++) - OSave(automapview[i][j]); - } - for (j = 0; j < MAXDUNY; j++) { - for (i = 0; i < MAXDUNX; i++) - BSave(dMissile[i][j]); - } - } + if (leveltype) { + for (j = 0; j < MAXDUNY; j++) { + for (i = 0; i < MAXDUNX; i++) + WSave(dMonster[i][j]); + } + for (j = 0; j < MAXDUNY; j++) { + for (i = 0; i < MAXDUNX; i++) + BSave(dDead[i][j]); + } + for (j = 0; j < MAXDUNY; j++) { + for (i = 0; i < MAXDUNX; i++) + BSave(dObject[i][j]); + } + for (j = 0; j < MAXDUNY; j++) { + for (i = 0; i < MAXDUNX; i++) + BSave(dTransVal[i][j]); + } + for (j = 0; j < MAXDUNY; j++) { + for (i = 0; i < MAXDUNX; i++) + BSave(dTransVal2[i][j]); + } + for (j = 0; j < DMAXY; j++) { + for (i = 0; i < DMAXX; i++) + OSave(automapview[i][j]); + } + for (j = 0; j < MAXDUNY; j++) { + for (i = 0; i < MAXDUNX; i++) + BSave(dMissile[i][j]); + } + } - WSave(numpremium); - WSave(premiumlevel); + WSave(numpremium); + WSave(premiumlevel); - for (i = 0; i < 6; i++) - SavePremium(i); + for (i = 0; i < 6; i++) + SavePremium(i); - OSave(automapflag); - WSave(AutoMapScale); - pfile_get_game_name(szName); - dwLen = codec_get_encoded_len(tbuff - SaveBuff); - pfile_write_save_file(szName, SaveBuff, tbuff - SaveBuff, dwLen); - mem_free_dbg(SaveBuff); - gbValidSaveFile = TRUE; - pfile_rename_temp_to_perm(); - pfile_write_hero(); + OSave(automapflag); + WSave(AutoMapScale); + pfile_get_game_name(szName); + dwLen = codec_get_encoded_len(tbuff - SaveBuff); + pfile_write_save_file(szName, SaveBuff, tbuff - SaveBuff, dwLen); + mem_free_dbg(SaveBuff); + gbValidSaveFile = TRUE; + pfile_rename_temp_to_perm(); + pfile_write_hero(); } // 5CF31D: using guessed type char setlevel; void __fastcall BSave(char v) { - *tbuff++ = v; + *tbuff++ = v; } void __fastcall WSave(int v) { - *tbuff++ = v >> 24; - *tbuff++ = v >> 16; - *tbuff++ = v >> 8; - *tbuff++ = v; + *tbuff++ = v >> 24; + *tbuff++ = v >> 16; + *tbuff++ = v >> 8; + *tbuff++ = v; } void __fastcall ISave(int v) { - *tbuff++ = v >> 24; - *tbuff++ = v >> 16; - *tbuff++ = v >> 8; - *tbuff++ = v; + *tbuff++ = v >> 24; + *tbuff++ = v >> 16; + *tbuff++ = v >> 8; + *tbuff++ = v; } void __fastcall OSave(BOOL v) { - if (v != FALSE) - *tbuff++ = TRUE; - else - *tbuff++ = FALSE; + if (v != FALSE) + *tbuff++ = TRUE; + else + *tbuff++ = FALSE; } void __fastcall SavePlayer(int i) { - memcpy(tbuff, &plr[i], sizeof(*plr) - (10 * sizeof(void *))); - tbuff += sizeof(*plr) - (10 * sizeof(void *)); // omit last 10 pointers + memcpy(tbuff, &plr[i], sizeof(*plr) - (10 * sizeof(void *))); + tbuff += sizeof(*plr) - (10 * sizeof(void *)); // omit last 10 pointers } void __fastcall SaveMonster(int i) { - memcpy(tbuff, &monster[i], sizeof(*monster) - (3 * sizeof(void *))); - tbuff += sizeof(*monster) - (3 * sizeof(void *)); // omit last 3 pointers + memcpy(tbuff, &monster[i], sizeof(*monster) - (3 * sizeof(void *))); + tbuff += sizeof(*monster) - (3 * sizeof(void *)); // omit last 3 pointers } void __fastcall SaveMissile(int i) { - memcpy(tbuff, &missile[i], sizeof(*missile)); - tbuff += sizeof(*missile); + memcpy(tbuff, &missile[i], sizeof(*missile)); + tbuff += sizeof(*missile); } void __fastcall SaveObject(int i) { - memcpy(tbuff, &object[i], sizeof(*object)); - tbuff += sizeof(*object); + memcpy(tbuff, &object[i], sizeof(*object)); + tbuff += sizeof(*object); } void __fastcall SaveItem(int i) { - memcpy(tbuff, &item[i], sizeof(*item)); - tbuff += sizeof(*item); + memcpy(tbuff, &item[i], sizeof(*item)); + tbuff += sizeof(*item); } void __fastcall SavePremium(int i) { - memcpy(tbuff, &premiumitem[i], sizeof(*premiumitem)); - tbuff += sizeof(*premiumitem); + memcpy(tbuff, &premiumitem[i], sizeof(*premiumitem)); + tbuff += sizeof(*premiumitem); } void __fastcall SaveQuest(int i) { - memcpy(tbuff, &quests[i], sizeof(*quests)); - tbuff += sizeof(*quests); - WSave(ReturnLvlX); - WSave(ReturnLvlY); - WSave(ReturnLvl); - WSave(ReturnLvlT); - WSave(DoomQuestState); + memcpy(tbuff, &quests[i], sizeof(*quests)); + tbuff += sizeof(*quests); + WSave(ReturnLvlX); + WSave(ReturnLvlY); + WSave(ReturnLvl); + WSave(ReturnLvlT); + WSave(DoomQuestState); } void __fastcall SaveLighting(int i) { - memcpy(tbuff, &LightList[i], sizeof(*LightList)); - tbuff += sizeof(*LightList); + memcpy(tbuff, &LightList[i], sizeof(*LightList)); + tbuff += sizeof(*LightList); } void __fastcall SaveVision(int i) { - memcpy(tbuff, &VisionList[i], sizeof(*VisionList)); - tbuff += sizeof(*VisionList); + memcpy(tbuff, &VisionList[i], sizeof(*VisionList)); + tbuff += sizeof(*VisionList); } void __fastcall SavePortal(int i) { - memcpy(tbuff, &portal[i], sizeof(*portal)); - tbuff += sizeof(*portal); + memcpy(tbuff, &portal[i], sizeof(*portal)); + tbuff += sizeof(*portal); } void __cdecl SaveLevel() { - int i, j; - char szName[MAX_PATH]; + int i, j; + char szName[MAX_PATH]; - if (!currlevel) - glSeedTbl[0] = GetRndSeed(); + if (!currlevel) + glSeedTbl[0] = GetRndSeed(); - int dwLen = codec_get_encoded_len(FILEBUFF); - unsigned char *SaveBuff = DiabloAllocPtr(dwLen); - tbuff = SaveBuff; + int dwLen = codec_get_encoded_len(FILEBUFF); + unsigned char *SaveBuff = DiabloAllocPtr(dwLen); + tbuff = SaveBuff; - if (leveltype) { - for (j = 0; j < MAXDUNY; j++) { - for (i = 0; i < MAXDUNX; i++) - BSave(dDead[i][j]); - } - } + if (leveltype) { + for (j = 0; j < MAXDUNY; j++) { + for (i = 0; i < MAXDUNX; i++) + BSave(dDead[i][j]); + } + } - WSave(nummonsters); - WSave(numitems); - WSave(nobjects); + WSave(nummonsters); + WSave(numitems); + WSave(nobjects); - if (leveltype) { - for (i = 0; i < MAXMONSTERS; i++) - WSave(monstactive[i]); - for (i = 0; i < nummonsters; i++) - SaveMonster(monstactive[i]); - for (i = 0; i < MAXOBJECTS; i++) - BSave(objectactive[i]); - for (i = 0; i < MAXOBJECTS; i++) - BSave(objectavail[i]); - for (i = 0; i < nobjects; i++) - SaveObject(objectactive[i]); - } + if (leveltype) { + for (i = 0; i < MAXMONSTERS; i++) + WSave(monstactive[i]); + for (i = 0; i < nummonsters; i++) + SaveMonster(monstactive[i]); + for (i = 0; i < MAXOBJECTS; i++) + BSave(objectactive[i]); + for (i = 0; i < MAXOBJECTS; i++) + BSave(objectavail[i]); + for (i = 0; i < nobjects; i++) + SaveObject(objectactive[i]); + } - for (i = 0; i < MAXITEMS; i++) - BSave(itemactive[i]); - for (i = 0; i < MAXITEMS; i++) - BSave(itemavail[i]); - for (i = 0; i < numitems; i++) - SaveItem(itemactive[i]); + for (i = 0; i < MAXITEMS; i++) + BSave(itemactive[i]); + for (i = 0; i < MAXITEMS; i++) + BSave(itemavail[i]); + for (i = 0; i < numitems; i++) + SaveItem(itemactive[i]); - for (j = 0; j < MAXDUNY; j++) { - for (i = 0; i < MAXDUNX; i++) - BSave(dFlags[i][j] & ~(DFLAG_MISSILE | DFLAG_VISIBLE | DFLAG_DEAD_PLAYER)); - } - for (j = 0; j < MAXDUNY; j++) { - for (i = 0; i < MAXDUNX; i++) - BSave(dItem[i][j]); - } + for (j = 0; j < MAXDUNY; j++) { + for (i = 0; i < MAXDUNX; i++) + BSave(dFlags[i][j] & ~(DFLAG_MISSILE | DFLAG_VISIBLE | DFLAG_DEAD_PLAYER)); + } + for (j = 0; j < MAXDUNY; j++) { + for (i = 0; i < MAXDUNX; i++) + BSave(dItem[i][j]); + } - if (leveltype) { - for (j = 0; j < MAXDUNY; j++) { - for (i = 0; i < MAXDUNX; i++) - WSave(dMonster[i][j]); - } - for (j = 0; j < MAXDUNY; j++) { - for (i = 0; i < MAXDUNX; i++) - BSave(dObject[i][j]); - } - for (j = 0; j < MAXDUNY; j++) { - for (i = 0; i < MAXDUNX; i++) - BSave(dTransVal[i][j]); - } - for (j = 0; j < MAXDUNY; j++) { - for (i = 0; i < MAXDUNX; i++) - BSave(dTransVal2[i][j]); - } - for (j = 0; j < DMAXY; j++) { - for (i = 0; i < DMAXX; i++) - OSave(automapview[i][j]); - } - for (j = 0; j < MAXDUNY; j++) { - for (i = 0; i < MAXDUNX; i++) - BSave(dMissile[i][j]); - } - } + if (leveltype) { + for (j = 0; j < MAXDUNY; j++) { + for (i = 0; i < MAXDUNX; i++) + WSave(dMonster[i][j]); + } + for (j = 0; j < MAXDUNY; j++) { + for (i = 0; i < MAXDUNX; i++) + BSave(dObject[i][j]); + } + for (j = 0; j < MAXDUNY; j++) { + for (i = 0; i < MAXDUNX; i++) + BSave(dTransVal[i][j]); + } + for (j = 0; j < MAXDUNY; j++) { + for (i = 0; i < MAXDUNX; i++) + BSave(dTransVal2[i][j]); + } + for (j = 0; j < DMAXY; j++) { + for (i = 0; i < DMAXX; i++) + OSave(automapview[i][j]); + } + for (j = 0; j < MAXDUNY; j++) { + for (i = 0; i < MAXDUNX; i++) + BSave(dMissile[i][j]); + } + } - GetTempLevelNames(szName); - dwLen = codec_get_encoded_len(tbuff - SaveBuff); - pfile_write_save_file(szName, SaveBuff, tbuff - SaveBuff, dwLen); - mem_free_dbg(SaveBuff); + GetTempLevelNames(szName); + dwLen = codec_get_encoded_len(tbuff - SaveBuff); + pfile_write_save_file(szName, SaveBuff, tbuff - SaveBuff, dwLen); + mem_free_dbg(SaveBuff); - if (setlevel == 0) - plr[myplr]._pLvlVisited[currlevel] = 1; - else - plr[myplr]._pSLvlVisited[setlvlnum] = 1; + if (setlevel == 0) + plr[myplr]._pLvlVisited[currlevel] = 1; + else + plr[myplr]._pSLvlVisited[setlvlnum] = 1; } // 5CF31D: using guessed type char setlevel; void __cdecl LoadLevel() { - int i, j; - DWORD dwLen; - char szName[MAX_PATH]; + int i, j; + DWORD dwLen; + char szName[MAX_PATH]; - GetPermLevelNames(szName); - BYTE *LoadBuff = pfile_read(szName, &dwLen); - tbuff = LoadBuff; + GetPermLevelNames(szName); + BYTE *LoadBuff = pfile_read(szName, &dwLen); + tbuff = LoadBuff; - if (leveltype) { - for (j = 0; j < MAXDUNY; j++) { - for (i = 0; i < MAXDUNX; i++) - dDead[i][j] = BLoad(); - } - SetDead(); - } + if (leveltype) { + for (j = 0; j < MAXDUNY; j++) { + for (i = 0; i < MAXDUNX; i++) + dDead[i][j] = BLoad(); + } + SetDead(); + } - nummonsters = WLoad(); - numitems = WLoad(); - nobjects = WLoad(); + nummonsters = WLoad(); + numitems = WLoad(); + nobjects = WLoad(); - if (leveltype) { - for (i = 0; i < MAXMONSTERS; i++) - monstactive[i] = WLoad(); - for (i = 0; i < nummonsters; i++) - LoadMonster(monstactive[i]); - for (i = 0; i < MAXOBJECTS; i++) - objectactive[i] = BLoad(); - for (i = 0; i < MAXOBJECTS; i++) - objectavail[i] = BLoad(); - for (i = 0; i < nobjects; i++) - LoadObject(objectactive[i]); - for (i = 0; i < nobjects; i++) - SyncObjectAnim(objectactive[i]); - } + if (leveltype) { + for (i = 0; i < MAXMONSTERS; i++) + monstactive[i] = WLoad(); + for (i = 0; i < nummonsters; i++) + LoadMonster(monstactive[i]); + for (i = 0; i < MAXOBJECTS; i++) + objectactive[i] = BLoad(); + for (i = 0; i < MAXOBJECTS; i++) + objectavail[i] = BLoad(); + for (i = 0; i < nobjects; i++) + LoadObject(objectactive[i]); + for (i = 0; i < nobjects; i++) + SyncObjectAnim(objectactive[i]); + } - for (i = 0; i < MAXITEMS; i++) - itemactive[i] = BLoad(); - for (i = 0; i < MAXITEMS; i++) - itemavail[i] = BLoad(); - for (i = 0; i < numitems; i++) - LoadItem(itemactive[i]); + for (i = 0; i < MAXITEMS; i++) + itemactive[i] = BLoad(); + for (i = 0; i < MAXITEMS; i++) + itemavail[i] = BLoad(); + for (i = 0; i < numitems; i++) + LoadItem(itemactive[i]); - for (j = 0; j < MAXDUNY; j++) { - for (i = 0; i < MAXDUNX; i++) - dFlags[i][j] = BLoad(); - } - for (j = 0; j < MAXDUNY; j++) { - for (i = 0; i < MAXDUNX; i++) - dItem[i][j] = BLoad(); - } + for (j = 0; j < MAXDUNY; j++) { + for (i = 0; i < MAXDUNX; i++) + dFlags[i][j] = BLoad(); + } + for (j = 0; j < MAXDUNY; j++) { + for (i = 0; i < MAXDUNX; i++) + dItem[i][j] = BLoad(); + } - if (leveltype) { - for (j = 0; j < MAXDUNY; j++) { - for (i = 0; i < MAXDUNX; i++) - dMonster[i][j] = WLoad(); - } - for (j = 0; j < MAXDUNY; j++) { - for (i = 0; i < MAXDUNX; i++) - dObject[i][j] = BLoad(); - } - for (j = 0; j < MAXDUNY; j++) { - for (i = 0; i < MAXDUNX; i++) - dTransVal[i][j] = BLoad(); - } - for (j = 0; j < MAXDUNY; j++) { - for (i = 0; i < MAXDUNX; i++) - dTransVal2[i][j] = BLoad(); - } - for (j = 0; j < DMAXY; j++) { - for (i = 0; i < DMAXX; i++) - automapview[i][j] = OLoad(); - } - for (j = 0; j < MAXDUNY; j++) { - for (i = 0; i < MAXDUNX; i++) - dMissile[i][j] = 0; /// BUGFIX: supposed to load saved missiles with "BLoad()"? - } - } + if (leveltype) { + for (j = 0; j < MAXDUNY; j++) { + for (i = 0; i < MAXDUNX; i++) + dMonster[i][j] = WLoad(); + } + for (j = 0; j < MAXDUNY; j++) { + for (i = 0; i < MAXDUNX; i++) + dObject[i][j] = BLoad(); + } + for (j = 0; j < MAXDUNY; j++) { + for (i = 0; i < MAXDUNX; i++) + dTransVal[i][j] = BLoad(); + } + for (j = 0; j < MAXDUNY; j++) { + for (i = 0; i < MAXDUNX; i++) + dTransVal2[i][j] = BLoad(); + } + for (j = 0; j < DMAXY; j++) { + for (i = 0; i < DMAXX; i++) + automapview[i][j] = OLoad(); + } + for (j = 0; j < MAXDUNY; j++) { + for (i = 0; i < MAXDUNX; i++) + dMissile[i][j] = 0; /// BUGFIX: supposed to load saved missiles with "BLoad()"? + } + } - AutomapZoomReset(); - ResyncQuests(); - SyncPortals(); - dolighting = 1; + AutomapZoomReset(); + ResyncQuests(); + SyncPortals(); + dolighting = 1; - for (i = 0; i < MAX_PLRS; i++) { - if (plr[i].plractive && currlevel == plr[i].plrlevel) - LightList[plr[i]._plid]._lunflag = 1; - } + for (i = 0; i < MAX_PLRS; i++) { + if (plr[i].plractive && currlevel == plr[i].plrlevel) + LightList[plr[i]._plid]._lunflag = 1; + } - mem_free_dbg(LoadBuff); + mem_free_dbg(LoadBuff); } // 642A18: using guessed type int dolighting; diff --git a/Source/logging.cpp b/Source/logging.cpp index 92e08d4f..da9a9ade 100644 --- a/Source/logging.cpp +++ b/Source/logging.cpp @@ -17,201 +17,201 @@ int log_not_created = 1; // weak HANDLE log_file = (HANDLE)0xFFFFFFFF; // idb struct log_cpp_init_1 { - log_cpp_init_1() - { - log_cpp_init_value = log_inf; - } + log_cpp_init_1() + { + log_cpp_init_value = log_inf; + } } _log_cpp_init_1; // 47F070: using guessed type int log_inf; // 646A30: using guessed type int log_cpp_init_value; struct log_cpp_init_2 { - log_cpp_init_2() - { - log_init_mutex(); - j_log_cleanup_mutex(); - } + log_cpp_init_2() + { + log_init_mutex(); + j_log_cleanup_mutex(); + } } _log_cpp_init_2; void __cdecl log_init_mutex() { - InitializeCriticalSection(&sgMemCrit); + InitializeCriticalSection(&sgMemCrit); } void __cdecl j_log_cleanup_mutex() { - atexit(log_cleanup_mutex); + atexit(log_cleanup_mutex); } void __cdecl log_cleanup_mutex() { - DeleteCriticalSection(&sgMemCrit); + DeleteCriticalSection(&sgMemCrit); } void __cdecl log_flush(bool force_close) { - void *v1; // eax - DWORD NumberOfBytesWritten; // [esp+8h] [ebp-4h] + void *v1; // eax + DWORD NumberOfBytesWritten; // [esp+8h] [ebp-4h] - EnterCriticalSection(&sgMemCrit); - if (nNumberOfBytesToWrite) { - if (log_file == (HANDLE)-1) { - v1 = log_create(); - log_file = v1; - if (v1 == (void *)-1) { - nNumberOfBytesToWrite = 0; - return; - } - SetFilePointer(v1, 0, NULL, FILE_END); - } - WriteFile(log_file, lpAddress, nNumberOfBytesToWrite, &NumberOfBytesWritten, 0); - nNumberOfBytesToWrite = 0; - } - if (force_close && log_file != (HANDLE)-1) { - CloseHandle(log_file); - log_file = (HANDLE)-1; - } - LeaveCriticalSection(&sgMemCrit); + EnterCriticalSection(&sgMemCrit); + if (nNumberOfBytesToWrite) { + if (log_file == (HANDLE)-1) { + v1 = log_create(); + log_file = v1; + if (v1 == (void *)-1) { + nNumberOfBytesToWrite = 0; + return; + } + SetFilePointer(v1, 0, NULL, FILE_END); + } + WriteFile(log_file, lpAddress, nNumberOfBytesToWrite, &NumberOfBytesWritten, 0); + nNumberOfBytesToWrite = 0; + } + if (force_close && log_file != (HANDLE)-1) { + CloseHandle(log_file); + log_file = (HANDLE)-1; + } + LeaveCriticalSection(&sgMemCrit); } void *__cdecl log_create() { - char *v0; // eax - void *v1; // ebx - HANDLE v2; // eax - char *v3; // edx - char Filename[260]; // [esp+Ch] [ebp-15Ch] - VS_FIXEDFILEINFO file_info; // [esp+110h] [ebp-58h] - char Buffer[32]; // [esp+144h] [ebp-24h] - DWORD pcbBuffer; // [esp+164h] [ebp-4h] + char *v0; // eax + void *v1; // ebx + HANDLE v2; // eax + char *v3; // edx + char Filename[260]; // [esp+Ch] [ebp-15Ch] + VS_FIXEDFILEINFO file_info; // [esp+110h] [ebp-58h] + char Buffer[32]; // [esp+144h] [ebp-24h] + DWORD pcbBuffer; // [esp+164h] [ebp-4h] - if (log_not_created) { - if (GetModuleFileName(0, Filename, 0x104u) && (v0 = strrchr(Filename, '\\')) != 0) - v0[1] = 0; - else - Filename[0] = 0; - pcbBuffer = 32; - if (!GetUserName(Buffer, &pcbBuffer)) - Buffer[0] = 0; - log_get_version(&file_info); - _snprintf( - FileName, - 0x104u, - "%s%s%02u%02u%02u.ERR", - Filename, - Buffer, - _LOWORD(file_info.dwProductVersionMS), - file_info.dwProductVersionLS >> 16, - _LOWORD(file_info.dwProductVersionLS)); - } - v1 = (void *)-1; - for (pcbBuffer = log_not_created == 0; (signed int)pcbBuffer < 2; ++pcbBuffer) { - v2 = CreateFile(FileName, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - v1 = v2; - if (v2 != (HANDLE)-1) { - if (GetFileSize(v2, 0) > 0x10000) - SetEndOfFile(v1); - break; - } - v3 = strrchr(FileName, '\\'); - if (!v3) - v3 = FileName; - strcpy(Filename, "c:\\"); - memset(&Filename[4], 0, 0x100u); - strcat(Filename, v3); - strcpy(FileName, Filename); - } - log_not_created = 0; - return v1; + if (log_not_created) { + if (GetModuleFileName(0, Filename, 0x104u) && (v0 = strrchr(Filename, '\\')) != 0) + v0[1] = 0; + else + Filename[0] = 0; + pcbBuffer = 32; + if (!GetUserName(Buffer, &pcbBuffer)) + Buffer[0] = 0; + log_get_version(&file_info); + _snprintf( + FileName, + 0x104u, + "%s%s%02u%02u%02u.ERR", + Filename, + Buffer, + _LOWORD(file_info.dwProductVersionMS), + file_info.dwProductVersionLS >> 16, + _LOWORD(file_info.dwProductVersionLS)); + } + v1 = (void *)-1; + for (pcbBuffer = log_not_created == 0; (signed int)pcbBuffer < 2; ++pcbBuffer) { + v2 = CreateFile(FileName, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + v1 = v2; + if (v2 != (HANDLE)-1) { + if (GetFileSize(v2, 0) > 0x10000) + SetEndOfFile(v1); + break; + } + v3 = strrchr(FileName, '\\'); + if (!v3) + v3 = FileName; + strcpy(Filename, "c:\\"); + memset(&Filename[4], 0, 0x100u); + strcat(Filename, v3); + strcpy(FileName, Filename); + } + log_not_created = 0; + return v1; } // 4947D4: using guessed type int log_not_created; void __fastcall log_get_version(VS_FIXEDFILEINFO *file_info) { - DWORD v1; // eax - DWORD v2; // esi - void *v3; // ebx - unsigned int v4; // eax - char Filename[260]; // [esp+8h] [ebp-114h] - DWORD dwHandle; // [esp+10Ch] [ebp-10h] - LPVOID lpBuffer; // [esp+110h] [ebp-Ch] - unsigned int puLen; // [esp+114h] [ebp-8h] - void *v9; // [esp+118h] [ebp-4h] + DWORD v1; // eax + DWORD v2; // esi + void *v3; // ebx + unsigned int v4; // eax + char Filename[260]; // [esp+8h] [ebp-114h] + DWORD dwHandle; // [esp+10Ch] [ebp-10h] + LPVOID lpBuffer; // [esp+110h] [ebp-Ch] + unsigned int puLen; // [esp+114h] [ebp-8h] + void *v9; // [esp+118h] [ebp-4h] - v9 = file_info; - memset(file_info, 0, 0x34u); - if (GetModuleFileName(0, Filename, 0x104u)) { - v1 = GetFileVersionInfoSize(Filename, &dwHandle); - v2 = v1; - if (v1) { - v3 = VirtualAlloc(0, v1, 0x1000u, 4u); - if (GetFileVersionInfo(Filename, 0, v2, v3) && VerQueryValue(v3, "\\", &lpBuffer, &puLen)) { - v4 = puLen; - if (puLen >= 0x34) - v4 = 52; - memcpy(v9, lpBuffer, v4); - } - VirtualFree(v3, 0, 0x8000u); - } - } + v9 = file_info; + memset(file_info, 0, 0x34u); + if (GetModuleFileName(0, Filename, 0x104u)) { + v1 = GetFileVersionInfoSize(Filename, &dwHandle); + v2 = v1; + if (v1) { + v3 = VirtualAlloc(0, v1, 0x1000u, 4u); + if (GetFileVersionInfo(Filename, 0, v2, v3) && VerQueryValue(v3, "\\", &lpBuffer, &puLen)) { + v4 = puLen; + if (puLen >= 0x34) + v4 = 52; + memcpy(v9, lpBuffer, v4); + } + VirtualFree(v3, 0, 0x8000u); + } + } } void log_printf(const char *pszFmt, ...) { - size_t v1; // edi - char *v2; // eax - char v3[512]; // [esp+Ch] [ebp-200h] - va_list va; // [esp+218h] [ebp+Ch] + size_t v1; // edi + char *v2; // eax + char v3[512]; // [esp+Ch] [ebp-200h] + va_list va; // [esp+218h] [ebp+Ch] - va_start(va, pszFmt); - EnterCriticalSection(&sgMemCrit); - _vsnprintf(v3, 0x200u, pszFmt, va); - va_end(va); - v3[511] = 0; - v1 = strlen(v3); - if (v1 + nNumberOfBytesToWrite > 0x1000) - log_flush(0); - v2 = (char *)lpAddress; - if (lpAddress - || (v2 = (char *)VirtualAlloc((LPVOID)lpAddress, 0x1000u, 0x1000u, 4u), - nNumberOfBytesToWrite = 0, - (lpAddress = v2) != 0)) { - memcpy(&v2[nNumberOfBytesToWrite], v3, v1); - nNumberOfBytesToWrite += v1; - } - LeaveCriticalSection(&sgMemCrit); + va_start(va, pszFmt); + EnterCriticalSection(&sgMemCrit); + _vsnprintf(v3, 0x200u, pszFmt, va); + va_end(va); + v3[511] = 0; + v1 = strlen(v3); + if (v1 + nNumberOfBytesToWrite > 0x1000) + log_flush(0); + v2 = (char *)lpAddress; + if (lpAddress + || (v2 = (char *)VirtualAlloc((LPVOID)lpAddress, 0x1000u, 0x1000u, 4u), + nNumberOfBytesToWrite = 0, + (lpAddress = v2) != 0)) { + memcpy(&v2[nNumberOfBytesToWrite], v3, v1); + nNumberOfBytesToWrite += v1; + } + LeaveCriticalSection(&sgMemCrit); } void __cdecl log_dump_computer_info() { - char Buffer[64]; // [esp+0h] [ebp-88h] - VS_FIXEDFILEINFO file_info; // [esp+40h] [ebp-48h] - struct _SYSTEMTIME SystemTime; // [esp+74h] [ebp-14h] - DWORD pcbBuffer; // [esp+84h] [ebp-4h] + char Buffer[64]; // [esp+0h] [ebp-88h] + VS_FIXEDFILEINFO file_info; // [esp+40h] [ebp-48h] + struct _SYSTEMTIME SystemTime; // [esp+74h] [ebp-14h] + DWORD pcbBuffer; // [esp+84h] [ebp-4h] - GetLocalTime(&SystemTime); - pcbBuffer = 64; - if (!GetUserName(Buffer, &pcbBuffer)) - Buffer[0] = 0; - log_get_version(&file_info); - log_printf( - "\r\n" - "------------------------------------------------------\r\n" - "PROGRAM VERSION: %d.%d.%d.%d\r\n" - "COMPUTER NAME: %s\r\n" - "TIME: %02u/%02u/%02u %02u:%02u:%02u\r\n" - "INFO: %s\r\n" - "\r\n", - file_info.dwProductVersionMS >> 16, - _LOWORD(file_info.dwProductVersionMS), - file_info.dwProductVersionLS >> 16, - _LOWORD(file_info.dwProductVersionLS), - Buffer, - SystemTime.wMonth, - SystemTime.wDay, - SystemTime.wYear % 100, - SystemTime.wHour, - SystemTime.wMinute, - SystemTime.wSecond, - log_buffer); + GetLocalTime(&SystemTime); + pcbBuffer = 64; + if (!GetUserName(Buffer, &pcbBuffer)) + Buffer[0] = 0; + log_get_version(&file_info); + log_printf( + "\r\n" + "------------------------------------------------------\r\n" + "PROGRAM VERSION: %d.%d.%d.%d\r\n" + "COMPUTER NAME: %s\r\n" + "TIME: %02u/%02u/%02u %02u:%02u:%02u\r\n" + "INFO: %s\r\n" + "\r\n", + file_info.dwProductVersionMS >> 16, + _LOWORD(file_info.dwProductVersionMS), + file_info.dwProductVersionLS >> 16, + _LOWORD(file_info.dwProductVersionLS), + Buffer, + SystemTime.wMonth, + SystemTime.wDay, + SystemTime.wYear % 100, + SystemTime.wHour, + SystemTime.wMinute, + SystemTime.wSecond, + log_buffer); } diff --git a/Source/mainmenu.cpp b/Source/mainmenu.cpp index 89a6d318..f737f5d8 100644 --- a/Source/mainmenu.cpp +++ b/Source/mainmenu.cpp @@ -11,18 +11,18 @@ int menu_music_track_id = 5; void __cdecl mainmenu_refresh_music() { - music_start(menu_music_track_id); - do { - menu_music_track_id++; - if (menu_music_track_id == 6) - menu_music_track_id = 0; - } while (!menu_music_track_id || menu_music_track_id == 1); + music_start(menu_music_track_id); + do { + menu_music_track_id++; + if (menu_music_track_id == 6) + menu_music_track_id = 0; + } while (!menu_music_track_id || menu_music_track_id == 1); } void __stdcall mainmenu_create_hero(char *name_1, char *name_2) { - if (UiValidPlayerName(name_1)) - pfile_create_save_file(name_1, name_2); + if (UiValidPlayerName(name_1)) + pfile_create_save_file(name_1, name_2); } int __stdcall mainmenu_select_hero_dialog( @@ -35,121 +35,121 @@ int __stdcall mainmenu_select_hero_dialog( char *cdesc, DWORD cdlen, BOOL *multi) { - int a6 = 1; - int a5 = 0; - if (gbMaxPlayers == 1) { - if (!UiSelHeroSingDialog( - pfile_ui_set_hero_infos, - pfile_ui_save_create, - pfile_delete_save, - pfile_ui_set_class_stats, - &a5, - chr_name_str, - &gnDifficulty)) - TermMsg("Unable to display SelHeroSing"); + int a6 = 1; + int a5 = 0; + if (gbMaxPlayers == 1) { + if (!UiSelHeroSingDialog( + pfile_ui_set_hero_infos, + pfile_ui_save_create, + pfile_delete_save, + pfile_ui_set_class_stats, + &a5, + chr_name_str, + &gnDifficulty)) + TermMsg("Unable to display SelHeroSing"); - if (a5 == 2) - dword_5256E8 = TRUE; - else - dword_5256E8 = FALSE; + if (a5 == 2) + dword_5256E8 = TRUE; + else + dword_5256E8 = FALSE; - } else if (!UiSelHeroMultDialog( - pfile_ui_set_hero_infos, - pfile_ui_save_create, - pfile_delete_save, - pfile_ui_set_class_stats, - &a5, - &a6, - chr_name_str)) { - TermMsg("Can't load multiplayer dialog"); - } - if (a5 == 4) { - SErrSetLastError(1223); - return 0; - } + } else if (!UiSelHeroMultDialog( + pfile_ui_set_hero_infos, + pfile_ui_save_create, + pfile_delete_save, + pfile_ui_set_class_stats, + &a5, + &a6, + chr_name_str)) { + TermMsg("Can't load multiplayer dialog"); + } + if (a5 == 4) { + SErrSetLastError(1223); + return 0; + } - pfile_create_player_description(cdesc, cdlen); - if (multi) { - if (mode == 'BNET') - *multi = a6 || !plr[myplr].pBattleNet; - else - *multi = a6; - } - if (cname && clen) - SStrCopy(cname, chr_name_str, clen); + pfile_create_player_description(cdesc, cdlen); + if (multi) { + if (mode == 'BNET') + *multi = a6 || !plr[myplr].pBattleNet; + else + *multi = a6; + } + if (cname && clen) + SStrCopy(cname, chr_name_str, clen); - return 1; + return 1; } void __cdecl mainmenu_loop() { - int v1; // eax - int a2; // [esp+0h] [ebp-4h] + int v1; // eax + int a2; // [esp+0h] [ebp-4h] - mainmenu_refresh_music(); - do { - while (1) { - a2 = 0; - if (!UiMainMenuDialog("Diablo v1.09", &a2, effects_play_sound, 30)) - TermMsg("Unable to display mainmenu"); - if (a2 == 1) - break; - switch (a2) { - case MAINMENU_MULTIPLAYER: - v1 = mainmenu_multi_player(); - goto LABEL_15; - case MAINMENU_REPLAY_INTRO: - goto LABEL_10; - case MAINMENU_SHOW_CREDITS: - UiCreditsDialog(16); - break; - case MAINMENU_EXIT_DIABLO: - goto LABEL_16; - case MAINMENU_ATTRACT_MODE: - LABEL_10: - if (gbActive) - mainmenu_play_intro(); - break; - } - } - v1 = mainmenu_single_player(); - LABEL_15:; - } while (v1); + mainmenu_refresh_music(); + do { + while (1) { + a2 = 0; + if (!UiMainMenuDialog("Diablo v1.09", &a2, effects_play_sound, 30)) + TermMsg("Unable to display mainmenu"); + if (a2 == 1) + break; + switch (a2) { + case MAINMENU_MULTIPLAYER: + v1 = mainmenu_multi_player(); + goto LABEL_15; + case MAINMENU_REPLAY_INTRO: + goto LABEL_10; + case MAINMENU_SHOW_CREDITS: + UiCreditsDialog(16); + break; + case MAINMENU_EXIT_DIABLO: + goto LABEL_16; + case MAINMENU_ATTRACT_MODE: + LABEL_10: + if (gbActive) + mainmenu_play_intro(); + break; + } + } + v1 = mainmenu_single_player(); + LABEL_15:; + } while (v1); LABEL_16: - music_stop(); + music_stop(); } // 634980: using guessed type int gbActive; BOOL __cdecl mainmenu_single_player() { - gbMaxPlayers = 1; - return mainmenu_init_menu(1); + gbMaxPlayers = 1; + return mainmenu_init_menu(1); } // 679660: using guessed type char gbMaxPlayers; BOOL __fastcall mainmenu_init_menu(int type) { - if (type == 4) - return 1; + if (type == 4) + return 1; - music_stop(); + music_stop(); - int success = diablo_init_menu(type != 2, type != 3); - if (success) - mainmenu_refresh_music(); + int success = diablo_init_menu(type != 2, type != 3); + if (success) + mainmenu_refresh_music(); - return success; + return success; } BOOL __cdecl mainmenu_multi_player() { - gbMaxPlayers = MAX_PLRS; - return mainmenu_init_menu(3); + gbMaxPlayers = MAX_PLRS; + return mainmenu_init_menu(3); } void __cdecl mainmenu_play_intro() { - music_stop(); - play_movie("gendata\\diablo1.smk", 1); - mainmenu_refresh_music(); + music_stop(); + play_movie("gendata\\diablo1.smk", 1); + mainmenu_refresh_music(); } diff --git a/Source/minitext.cpp b/Source/minitext.cpp index 1999fd2c..f4e4440d 100644 --- a/Source/minitext.cpp +++ b/Source/minitext.cpp @@ -12,27 +12,27 @@ void *pMedTextCels; void *pTextBoxCels; const unsigned char mfontframe[127] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 37, 49, 38, 0, 39, 40, 47, - 42, 43, 41, 45, 52, 44, 53, 55, 36, 27, - 28, 29, 30, 31, 32, 33, 34, 35, 51, 50, - 48, 46, 49, 54, 0, 1, 2, 3, 4, 5, - 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, - 26, 42, 0, 43, 0, 0, 0, 1, 2, 3, - 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 48, 0, 49, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 37, 49, 38, 0, 39, 40, 47, + 42, 43, 41, 45, 52, 44, 53, 55, 36, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 51, 50, + 48, 46, 49, 54, 0, 1, 2, 3, 4, 5, + 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, + 26, 42, 0, 43, 0, 0, 0, 1, 2, 3, + 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 48, 0, 49, 0 }; const unsigned char mfontkern[56] = { - 5, 15, 10, 13, 14, 10, 9, 13, 11, 5, - 5, 11, 10, 16, 13, 16, 10, 15, 12, 10, - 14, 17, 17, 22, 17, 16, 11, 5, 11, 11, - 11, 10, 11, 11, 11, 11, 15, 5, 10, 18, - 15, 8, 6, 6, 7, 10, 9, 6, 10, 10, - 5, 5, 5, 5, 11, 12 + 5, 15, 10, 13, 14, 10, 9, 13, 11, 5, + 5, 11, 10, 16, 13, 16, 10, 15, 12, 10, + 14, 17, 17, 22, 17, 16, 11, 5, 11, 11, + 11, 10, 11, 11, 11, 11, 15, 5, 10, 18, + 15, 8, 6, 6, 7, 10, 9, 6, 10, 10, + 5, 5, 5, 5, 11, 12 }; /* data */ @@ -41,40 +41,40 @@ int qscroll_spd_tbl[9] = { 2, 4, 6, 8, 0, -1, -2, -3, -4 }; void __cdecl FreeQuestText() { - void *v0; // ecx - void *v1; // ecx + void *v0; // ecx + void *v1; // ecx - v0 = pMedTextCels; - pMedTextCels = 0; - mem_free_dbg(v0); - v1 = pTextBoxCels; - pTextBoxCels = 0; - mem_free_dbg(v1); + v0 = pMedTextCels; + pMedTextCels = 0; + mem_free_dbg(v0); + v1 = pTextBoxCels; + pTextBoxCels = 0; + mem_free_dbg(v1); } void __cdecl InitQuestText() { - unsigned char *v0; // eax + unsigned char *v0; // eax - pMedTextCels = LoadFileInMem("Data\\MedTextS.CEL", 0); - v0 = LoadFileInMem("Data\\TextBox.CEL", 0); - qtextflag = FALSE; - pTextBoxCels = v0; + pMedTextCels = LoadFileInMem("Data\\MedTextS.CEL", 0); + v0 = LoadFileInMem("Data\\TextBox.CEL", 0); + qtextflag = FALSE; + pTextBoxCels = v0; } // 646D00: using guessed type char qtextflag; void __fastcall InitQTextMsg(int m) { - if (alltext[m].scrlltxt) { - questlog = 0; - qtextptr = alltext[m].txtstr; - qtextflag = TRUE; - qtexty = 500; - sgLastScroll = qscroll_spd_tbl[alltext[m].txtspd - 1]; /* double check offset */ - scrolltexty = sgLastScroll; - qtextSpd = GetTickCount(); - } - PlaySFX(alltext[m].sfxnr); + if (alltext[m].scrlltxt) { + questlog = 0; + qtextptr = alltext[m].txtstr; + qtextflag = TRUE; + qtexty = 500; + sgLastScroll = qscroll_spd_tbl[alltext[m].txtspd - 1]; /* double check offset */ + scrolltexty = sgLastScroll; + qtextSpd = GetTickCount(); + } + PlaySFX(alltext[m].sfxnr); } // 646CF4: using guessed type int qtexty; // 646CFC: using guessed type int qtextSpd; @@ -85,7 +85,7 @@ void __fastcall InitQTextMsg(int m) void __cdecl DrawQTextBack() { - CelDecodeOnly(88, 487, pTextBoxCels, 1, 591); + CelDecodeOnly(88, 487, pTextBoxCels, 1, 591); #define TRANS_RECT_X 27 #define TRANS_RECT_Y 28 @@ -96,158 +96,158 @@ void __cdecl DrawQTextBack() void __fastcall PrintQTextChr(int screen_x, int screen_y, char *cel_buf, int frame) { - char *v4; // ebx - char *v5; // esi - char *v6; // edi - int v7; // ebx - signed int v8; // edx - unsigned int v9; // eax - unsigned int v10; // ecx - char v11; // cf - unsigned int v12; // ecx - char *v13; // [esp+14h] [ebp-8h] - char *v14; // [esp+18h] [ebp-4h] + char *v4; // ebx + char *v5; // esi + char *v6; // edi + int v7; // ebx + signed int v8; // edx + unsigned int v9; // eax + unsigned int v10; // ecx + char v11; // cf + unsigned int v12; // ecx + char *v13; // [esp+14h] [ebp-8h] + char *v14; // [esp+18h] [ebp-4h] - v13 = (char *)gpBuffer + screen_y_times_768[209]; - v14 = (char *)gpBuffer + screen_y_times_768[469]; - v4 = &cel_buf[4 * frame]; - v5 = &cel_buf[*(_DWORD *)v4]; - v6 = (char *)gpBuffer + screen_y_times_768[screen_y] + screen_x; - v7 = (int)&v5[*((_DWORD *)v4 + 1) - *(_DWORD *)v4]; - do { - v8 = 22; - do { - while (1) { - v9 = (unsigned char)*v5++; - if ((v9 & 0x80u) == 0) - break; - _LOBYTE(v9) = -(char)v9; - v6 += v9; - v8 -= v9; - if (!v8) - goto LABEL_15; - } - v8 -= v9; - if (v6 < v13 || v6 > v14) { - v5 += v9; - v6 += v9; - } else { - v10 = v9 >> 1; - if (!(v9 & 1) || (*v6 = *v5, ++v5, ++v6, v10)) { - v11 = v10 & 1; - v12 = v9 >> 2; - if (!v11 || (*(_WORD *)v6 = *(_WORD *)v5, v5 += 2, v6 += 2, v12)) { - qmemcpy(v6, v5, 4 * v12); - v5 += 4 * v12; - v6 += 4 * v12; - } - } - } - } while (v8); - LABEL_15: - v6 -= 790; - } while ((char *)v7 != v5); + v13 = (char *)gpBuffer + screen_y_times_768[209]; + v14 = (char *)gpBuffer + screen_y_times_768[469]; + v4 = &cel_buf[4 * frame]; + v5 = &cel_buf[*(_DWORD *)v4]; + v6 = (char *)gpBuffer + screen_y_times_768[screen_y] + screen_x; + v7 = (int)&v5[*((_DWORD *)v4 + 1) - *(_DWORD *)v4]; + do { + v8 = 22; + do { + while (1) { + v9 = (unsigned char)*v5++; + if ((v9 & 0x80u) == 0) + break; + _LOBYTE(v9) = -(char)v9; + v6 += v9; + v8 -= v9; + if (!v8) + goto LABEL_15; + } + v8 -= v9; + if (v6 < v13 || v6 > v14) { + v5 += v9; + v6 += v9; + } else { + v10 = v9 >> 1; + if (!(v9 & 1) || (*v6 = *v5, ++v5, ++v6, v10)) { + v11 = v10 & 1; + v12 = v9 >> 2; + if (!v11 || (*(_WORD *)v6 = *(_WORD *)v5, v5 += 2, v6 += 2, v12)) { + qmemcpy(v6, v5, 4 * v12); + v5 += 4 * v12; + v6 += 4 * v12; + } + } + } + } while (v8); + LABEL_15: + v6 -= 790; + } while ((char *)v7 != v5); } void __cdecl DrawQText() { - char *v0; // edi - signed int v1; // edx - int v2; // ecx - char *i; // esi - unsigned char v4; // al - unsigned char v5; // al - char v6; // dl - char *v7; // eax - unsigned char v8; // al - char *v9; // esi - unsigned char v10; // bl - DWORD v11; // eax - char qstr[128]; // [esp+8h] [ebp-90h] - char *v13; // [esp+88h] [ebp-10h] - int v14; // [esp+8Ch] [ebp-Ch] - int screen_y; // [esp+90h] [ebp-8h] - int screen_x; // [esp+94h] [ebp-4h] + char *v0; // edi + signed int v1; // edx + int v2; // ecx + char *i; // esi + unsigned char v4; // al + unsigned char v5; // al + char v6; // dl + char *v7; // eax + unsigned char v8; // al + char *v9; // esi + unsigned char v10; // bl + DWORD v11; // eax + char qstr[128]; // [esp+8h] [ebp-90h] + char *v13; // [esp+88h] [ebp-10h] + int v14; // [esp+8Ch] [ebp-Ch] + int screen_y; // [esp+90h] [ebp-8h] + int screen_x; // [esp+94h] [ebp-4h] - DrawQTextBack(); - v0 = qtextptr; - screen_x = 112; - v13 = 0; - screen_y = qtexty; - v14 = 0; - do { - v1 = 0; - v2 = 0; - for (i = v0; *i != 10; ++v2) { - if (*i == 124 || v1 >= 543) - break; - v4 = *i++; - v5 = fontidx[v4]; - if (v5) { - qstr[v2] = v5; - v1 += mfontkern[mfontframe[v5]] + 2; - } else { - --v2; - } - } - v6 = *i; - v7 = &qstr[v2]; - qstr[v2] = 0; - if (v6 == 124) { - *v7 = 0; - v14 = 1; - } else if (v6 != 10) { - while (*v7 != 32 && v2 > 0) { - *v7 = 0; - v7 = &qstr[--v2]; - } - } - v8 = qstr[0]; - if (qstr[0]) { - v9 = qstr; - do { - ++v0; - v10 = mfontframe[fontidx[v8]]; - if (*v0 == 10) - ++v0; - if (v10) - PrintQTextChr(screen_x, screen_y, (char *)pMedTextCels, v10); - ++v9; - screen_x += mfontkern[v10] + 2; - v8 = *v9; - } while (*v9); - } - if (!v13) - v13 = v0; - screen_y += 38; - screen_x = 112; - if (screen_y > 501) - v14 = 1; - } while (!v14); - v11 = GetTickCount(); - while (1) { - if (sgLastScroll <= 0) { - qtexty = qtexty + sgLastScroll - 1; - goto LABEL_33; - } - if (--scrolltexty) { - --qtexty; - LABEL_33: - if (scrolltexty) - goto LABEL_35; - } - scrolltexty = sgLastScroll; - LABEL_35: - if (qtexty <= 209) - break; - qtextSpd += 50; - if (v11 - qtextSpd >= 0x7FFFFFFF) - return; - } - qtexty += 38; - qtextptr = v13; - if (*v13 == 124) - qtextflag = FALSE; + DrawQTextBack(); + v0 = qtextptr; + screen_x = 112; + v13 = 0; + screen_y = qtexty; + v14 = 0; + do { + v1 = 0; + v2 = 0; + for (i = v0; *i != 10; ++v2) { + if (*i == 124 || v1 >= 543) + break; + v4 = *i++; + v5 = fontidx[v4]; + if (v5) { + qstr[v2] = v5; + v1 += mfontkern[mfontframe[v5]] + 2; + } else { + --v2; + } + } + v6 = *i; + v7 = &qstr[v2]; + qstr[v2] = 0; + if (v6 == 124) { + *v7 = 0; + v14 = 1; + } else if (v6 != 10) { + while (*v7 != 32 && v2 > 0) { + *v7 = 0; + v7 = &qstr[--v2]; + } + } + v8 = qstr[0]; + if (qstr[0]) { + v9 = qstr; + do { + ++v0; + v10 = mfontframe[fontidx[v8]]; + if (*v0 == 10) + ++v0; + if (v10) + PrintQTextChr(screen_x, screen_y, (char *)pMedTextCels, v10); + ++v9; + screen_x += mfontkern[v10] + 2; + v8 = *v9; + } while (*v9); + } + if (!v13) + v13 = v0; + screen_y += 38; + screen_x = 112; + if (screen_y > 501) + v14 = 1; + } while (!v14); + v11 = GetTickCount(); + while (1) { + if (sgLastScroll <= 0) { + qtexty = qtexty + sgLastScroll - 1; + goto LABEL_33; + } + if (--scrolltexty) { + --qtexty; + LABEL_33: + if (scrolltexty) + goto LABEL_35; + } + scrolltexty = sgLastScroll; + LABEL_35: + if (qtexty <= 209) + break; + qtextSpd += 50; + if (v11 - qtextSpd >= 0x7FFFFFFF) + return; + } + qtexty += 38; + qtextptr = v13; + if (*v13 == 124) + qtextflag = FALSE; } // 646CF4: using guessed type int qtexty; // 646CFC: using guessed type int qtextSpd; diff --git a/Source/missiles.cpp b/Source/missiles.cpp index 426ee4cf..ee92f9b1 100644 --- a/Source/missiles.cpp +++ b/Source/missiles.cpp @@ -12,77 +12,77 @@ int MissilePreFlag; // weak int numchains; // weak MissileData missiledata[68] = { - { MIS_ARROW, &AddArrow, &MI_Arrow, 1, 0u, 0u, MFILE_ARROWS, -1, -1 }, - { MIS_FIREBOLT, &AddFirebolt, &MI_Firebolt, 1, 1u, 1u, MFILE_FIREBA, LS_FBOLT1, LS_FIRIMP2 }, - { MIS_GUARDIAN, &AddGuardian, &MI_Guardian, 1, 1u, 0u, MFILE_GUARD, LS_GUARD, LS_GUARDLAN }, - { MIS_RNDTELEPORT, &AddRndTeleport, &MI_Teleport, 0, 1u, 0u, MFILE_NONE, LS_TELEPORT, -1 }, - { MIS_LIGHTBALL, &AddLightball, &MI_Lightball, 1, 1u, 2u, MFILE_LGHNING, -1, -1 }, - { MIS_FIREWALL, &AddFirewall, &MI_Firewall, 1, 1u, 1u, MFILE_FIREWAL, LS_WALLLOOP, LS_FIRIMP2 }, - { MIS_FIREBALL, &AddFireball, &MI_Fireball, 1, 1u, 1u, MFILE_FIREBA, LS_FBOLT1, LS_FIRIMP2 }, - { MIS_LIGHTCTRL, &AddLightctrl, &MI_Lightctrl, 0, 1u, 2u, MFILE_LGHNING, -1, -1 }, - { MIS_LIGHTNING, &AddLightning, &MI_Lightning, 1, 1u, 2u, MFILE_LGHNING, LS_LNING1, LS_ELECIMP1 }, - { MIS_MISEXP, &AddMisexp, &MI_Misexp, 1, 2u, 0u, MFILE_MAGBLOS, -1, -1 }, - { MIS_TOWN, &AddTown, &MI_Town, 1, 1u, 3u, MFILE_PORTAL, LS_SENTINEL, LS_ELEMENTL }, - { MIS_FLASH, &AddFlash, &MI_Flash, 1, 1u, 3u, MFILE_BLUEXFR, LS_NOVA, LS_ELECIMP1 }, - { MIS_FLASH2, &AddFlash2, &MI_Flash2, 1, 1u, 3u, MFILE_BLUEXBK, -1, -1 }, - { MIS_MANASHIELD, &AddManashield, &MI_SetManashield, 0, 1u, 3u, MFILE_MANASHLD, LS_MSHIELD, -1 }, - { MIS_FIREMOVE, &AddFiremove, &MI_Firemove, 1, 1u, 1u, MFILE_FIREWAL, -1, -1 }, - { MIS_CHAIN, &AddChain, &MI_Chain, 1, 1u, 2u, MFILE_LGHNING, LS_LNING1, LS_ELECIMP1 }, - { MIS_NULL_10, NULL, NULL, 1, 1u, 2u, MFILE_LGHNING, -1, -1 }, - { MIS_NULL_11, &miss_null_11, &mi_null_11, 1, 2u, 0u, MFILE_BLOOD, LS_BLODSTAR, LS_BLSIMPT }, - { MIS_NULL_12, &miss_null_12, &mi_null_11, 1, 2u, 0u, MFILE_BONE, -1, -1 }, - { MIS_NULL_13, &miss_null_13, &mi_null_11, 1, 2u, 0u, MFILE_METLHIT, -1, -1 }, - { MIS_RHINO, &AddRhino, &MI_Rhino, 1, 2u, 0u, MFILE_NONE, -1, -1 }, - { MIS_MAGMABALL, &AddMagmaball, &MI_Firebolt, 1, 1u, 1u, MFILE_MAGBALL, -1, -1 }, - { MIS_LIGHTCTRL2, &AddLightctrl, &MI_Lightctrl, 0, 1u, 2u, MFILE_THINLGHT, -1, -1 }, - { MIS_LIGHTNING2, &AddLightning, &MI_Lightning, 1, 1u, 2u, MFILE_THINLGHT, -1, -1 }, - { MIS_FLARE, &AddFlare, &MI_Firebolt, 1, 1u, 3u, MFILE_FLARE, -1, -1 }, - { MIS_MISEXP2, &AddMisexp, &MI_Misexp, 1, 2u, 3u, MFILE_FLAREEXP, -1, -1 }, - { MIS_TELEPORT, &AddTeleport, &MI_Teleport, 0, 1u, 0u, MFILE_NONE, LS_ELEMENTL, -1 }, - { MIS_FARROW, &AddLArrow, &MI_LArrow, 1, 0u, 1u, MFILE_FARROW, -1, -1 }, - { MIS_DOOMSERP, NULL, NULL, 0, 1u, 3u, MFILE_DOOM, LS_DSERP, -1 }, - { MIS_NULL_1D, &miss_null_1D, &MI_Firewall, 1, 2u, 1u, MFILE_FIREWAL, -1, -1 }, - { MIS_STONE, &AddStone, &MI_Stone, 0, 1u, 3u, MFILE_NONE, LS_SCURIMP, -1 }, - { MIS_NULL_1F, &miss_null_1F, &MI_Dummy, 1, 1u, 0u, MFILE_NONE, -1, -1 }, - { MIS_INVISIBL, NULL, NULL, 0, 1u, 0u, MFILE_NONE, LS_INVISIBL, -1 }, - { MIS_GOLEM, &AddGolem, &MI_Golem, 0, 1u, 0u, MFILE_NONE, LS_GOLUM, -1 }, - { MIS_ETHEREALIZE, &AddEtherealize, &MI_Etherealize, 1, 1u, 0u, MFILE_ETHRSHLD, LS_ETHEREAL, -1 }, - { MIS_NULL_23, &miss_null_23, &mi_null_11, 1, 2u, 0u, MFILE_BLODBUR, -1, -1 }, - { MIS_BOOM, &AddBoom, &MI_Boom, 1, 2u, 0u, MFILE_NEWEXP, -1, -1 }, - { MIS_HEAL, &AddHeal, &MI_Dummy, 0, 1u, 0u, MFILE_NONE, -1, -1 }, - { MIS_FIREWALLC, &AddFirewallC, &MI_FirewallC, 0, 1u, 1u, MFILE_FIREWAL, -1, -1 }, - { MIS_INFRA, &AddInfra, &MI_Infra, 0, 1u, 0u, MFILE_NONE, LS_INFRAVIS, -1 }, - { MIS_IDENTIFY, &AddIdentify, &MI_Dummy, 0, 1u, 0u, MFILE_NONE, -1, -1 }, - { MIS_WAVE, &AddWave, &MI_Wave, 1, 1u, 1u, MFILE_FIREWAL, LS_FLAMWAVE, -1 }, - { MIS_NOVA, &AddNova, &MI_Nova, 1, 1u, 2u, MFILE_LGHNING, LS_NOVA, -1 }, - { MIS_BLODBOIL, &miss_null_1F, &MI_Blodboil, 1, 1u, 0u, MFILE_NONE, -1, LS_BLODBOIL }, - { MIS_APOCA, &AddApoca, &MI_Apoca, 1, 1u, 3u, MFILE_NEWEXP, LS_APOC, -1 }, - { MIS_REPAIR, &AddRepair, &MI_Dummy, 0, 2u, 0u, MFILE_NONE, -1, -1 }, - { MIS_RECHARGE, &AddRecharge, &MI_Dummy, 0, 2u, 0u, MFILE_NONE, -1, -1 }, - { MIS_DISARM, &AddDisarm, &MI_Dummy, 0, 2u, 0u, MFILE_NONE, LS_TRAPDIS, -1 }, - { MIS_FLAME, &AddFlame, &MI_Flame, 1, 1u, 1u, MFILE_INFERNO, LS_SPOUTSTR, -1 }, - { MIS_FLAMEC, &AddFlamec, &MI_Flamec, 0, 1u, 1u, MFILE_NONE, -1, -1 }, - { MIS_NULL_32, &miss_null_32, &mi_null_32, 1, 2u, 0u, MFILE_NONE, -1, -1 }, - { MIS_NULL_33, &miss_null_33, &mi_null_33, 1, 0u, 1u, MFILE_KRULL, -1, -1 }, - { MIS_CBOLT, &AddCbolt, &MI_Cbolt, 1, 1u, 2u, MFILE_MINILTNG, LS_CBOLT, -1 }, - { MIS_HBOLT, &AddHbolt, &MI_Hbolt, 1, 1u, 0u, MFILE_HOLY, LS_HOLYBOLT, LS_ELECIMP1 }, - { MIS_RESURRECT, &AddResurrect, &MI_Dummy, 0, 1u, 3u, MFILE_NONE, -1, LS_RESUR }, - { MIS_TELEKINESIS, &AddTelekinesis, &MI_Dummy, 0, 1u, 0u, MFILE_NONE, LS_ETHEREAL, -1 }, - { MIS_LARROW, &AddLArrow, &MI_LArrow, 1, 0u, 2u, MFILE_LARROW, -1, -1 }, - { MIS_ACID, &AddAcid, &MI_Firebolt, 1, 1u, 4u, MFILE_ACIDBF, LS_ACID, -1 }, - { MIS_MISEXP3, &AddMisexp, &MI_Acidsplat, 1, 2u, 4u, MFILE_ACIDSPLA, -1, -1 }, - { MIS_ACIDPUD, &AddAcidpud, &MI_Acidpud, 1, 2u, 4u, MFILE_ACIDPUD, LS_PUDDLE, -1 }, - { MIS_HEALOTHER, &AddHealOther, &MI_Dummy, 0, 1u, 0u, MFILE_NONE, -1, -1 }, - { MIS_ELEMENT, &AddElement, &MI_Element, 1, 1u, 1u, MFILE_FIRERUN, LS_ELEMENTL, -1 }, - { MIS_RESURRECTBEAM, &AddResurrectBeam, &MI_ResurrectBeam, 1, 1u, 0u, MFILE_RESSUR1, -1, -1 }, - { MIS_BONESPIRIT, &AddBoneSpirit, &MI_Bonespirit, 1, 1u, 3u, MFILE_SKLBALL, LS_BONESP, LS_BSIMPCT }, - { MIS_WEAPEXP, &AddWeapexp, &MI_Weapexp, 1, 2u, 0u, MFILE_NONE, -1, -1 }, - { MIS_RPORTAL, &AddRportal, &MI_Rportal, 1, 2u, 0u, MFILE_RPORTAL, LS_SENTINEL, LS_ELEMENTL }, - { MIS_BOOM2, &AddBoom, &MI_Boom, 1, 2u, 0u, MFILE_FIREPLAR, -1, -1 }, - { MIS_DIABAPOCA, &AddDiabApoca, &MI_Dummy, 0, 2u, 0u, MFILE_NONE, -1, -1 } + { MIS_ARROW, &AddArrow, &MI_Arrow, 1, 0u, 0u, MFILE_ARROWS, -1, -1 }, + { MIS_FIREBOLT, &AddFirebolt, &MI_Firebolt, 1, 1u, 1u, MFILE_FIREBA, LS_FBOLT1, LS_FIRIMP2 }, + { MIS_GUARDIAN, &AddGuardian, &MI_Guardian, 1, 1u, 0u, MFILE_GUARD, LS_GUARD, LS_GUARDLAN }, + { MIS_RNDTELEPORT, &AddRndTeleport, &MI_Teleport, 0, 1u, 0u, MFILE_NONE, LS_TELEPORT, -1 }, + { MIS_LIGHTBALL, &AddLightball, &MI_Lightball, 1, 1u, 2u, MFILE_LGHNING, -1, -1 }, + { MIS_FIREWALL, &AddFirewall, &MI_Firewall, 1, 1u, 1u, MFILE_FIREWAL, LS_WALLLOOP, LS_FIRIMP2 }, + { MIS_FIREBALL, &AddFireball, &MI_Fireball, 1, 1u, 1u, MFILE_FIREBA, LS_FBOLT1, LS_FIRIMP2 }, + { MIS_LIGHTCTRL, &AddLightctrl, &MI_Lightctrl, 0, 1u, 2u, MFILE_LGHNING, -1, -1 }, + { MIS_LIGHTNING, &AddLightning, &MI_Lightning, 1, 1u, 2u, MFILE_LGHNING, LS_LNING1, LS_ELECIMP1 }, + { MIS_MISEXP, &AddMisexp, &MI_Misexp, 1, 2u, 0u, MFILE_MAGBLOS, -1, -1 }, + { MIS_TOWN, &AddTown, &MI_Town, 1, 1u, 3u, MFILE_PORTAL, LS_SENTINEL, LS_ELEMENTL }, + { MIS_FLASH, &AddFlash, &MI_Flash, 1, 1u, 3u, MFILE_BLUEXFR, LS_NOVA, LS_ELECIMP1 }, + { MIS_FLASH2, &AddFlash2, &MI_Flash2, 1, 1u, 3u, MFILE_BLUEXBK, -1, -1 }, + { MIS_MANASHIELD, &AddManashield, &MI_SetManashield, 0, 1u, 3u, MFILE_MANASHLD, LS_MSHIELD, -1 }, + { MIS_FIREMOVE, &AddFiremove, &MI_Firemove, 1, 1u, 1u, MFILE_FIREWAL, -1, -1 }, + { MIS_CHAIN, &AddChain, &MI_Chain, 1, 1u, 2u, MFILE_LGHNING, LS_LNING1, LS_ELECIMP1 }, + { MIS_NULL_10, NULL, NULL, 1, 1u, 2u, MFILE_LGHNING, -1, -1 }, + { MIS_NULL_11, &miss_null_11, &mi_null_11, 1, 2u, 0u, MFILE_BLOOD, LS_BLODSTAR, LS_BLSIMPT }, + { MIS_NULL_12, &miss_null_12, &mi_null_11, 1, 2u, 0u, MFILE_BONE, -1, -1 }, + { MIS_NULL_13, &miss_null_13, &mi_null_11, 1, 2u, 0u, MFILE_METLHIT, -1, -1 }, + { MIS_RHINO, &AddRhino, &MI_Rhino, 1, 2u, 0u, MFILE_NONE, -1, -1 }, + { MIS_MAGMABALL, &AddMagmaball, &MI_Firebolt, 1, 1u, 1u, MFILE_MAGBALL, -1, -1 }, + { MIS_LIGHTCTRL2, &AddLightctrl, &MI_Lightctrl, 0, 1u, 2u, MFILE_THINLGHT, -1, -1 }, + { MIS_LIGHTNING2, &AddLightning, &MI_Lightning, 1, 1u, 2u, MFILE_THINLGHT, -1, -1 }, + { MIS_FLARE, &AddFlare, &MI_Firebolt, 1, 1u, 3u, MFILE_FLARE, -1, -1 }, + { MIS_MISEXP2, &AddMisexp, &MI_Misexp, 1, 2u, 3u, MFILE_FLAREEXP, -1, -1 }, + { MIS_TELEPORT, &AddTeleport, &MI_Teleport, 0, 1u, 0u, MFILE_NONE, LS_ELEMENTL, -1 }, + { MIS_FARROW, &AddLArrow, &MI_LArrow, 1, 0u, 1u, MFILE_FARROW, -1, -1 }, + { MIS_DOOMSERP, NULL, NULL, 0, 1u, 3u, MFILE_DOOM, LS_DSERP, -1 }, + { MIS_NULL_1D, &miss_null_1D, &MI_Firewall, 1, 2u, 1u, MFILE_FIREWAL, -1, -1 }, + { MIS_STONE, &AddStone, &MI_Stone, 0, 1u, 3u, MFILE_NONE, LS_SCURIMP, -1 }, + { MIS_NULL_1F, &miss_null_1F, &MI_Dummy, 1, 1u, 0u, MFILE_NONE, -1, -1 }, + { MIS_INVISIBL, NULL, NULL, 0, 1u, 0u, MFILE_NONE, LS_INVISIBL, -1 }, + { MIS_GOLEM, &AddGolem, &MI_Golem, 0, 1u, 0u, MFILE_NONE, LS_GOLUM, -1 }, + { MIS_ETHEREALIZE, &AddEtherealize, &MI_Etherealize, 1, 1u, 0u, MFILE_ETHRSHLD, LS_ETHEREAL, -1 }, + { MIS_NULL_23, &miss_null_23, &mi_null_11, 1, 2u, 0u, MFILE_BLODBUR, -1, -1 }, + { MIS_BOOM, &AddBoom, &MI_Boom, 1, 2u, 0u, MFILE_NEWEXP, -1, -1 }, + { MIS_HEAL, &AddHeal, &MI_Dummy, 0, 1u, 0u, MFILE_NONE, -1, -1 }, + { MIS_FIREWALLC, &AddFirewallC, &MI_FirewallC, 0, 1u, 1u, MFILE_FIREWAL, -1, -1 }, + { MIS_INFRA, &AddInfra, &MI_Infra, 0, 1u, 0u, MFILE_NONE, LS_INFRAVIS, -1 }, + { MIS_IDENTIFY, &AddIdentify, &MI_Dummy, 0, 1u, 0u, MFILE_NONE, -1, -1 }, + { MIS_WAVE, &AddWave, &MI_Wave, 1, 1u, 1u, MFILE_FIREWAL, LS_FLAMWAVE, -1 }, + { MIS_NOVA, &AddNova, &MI_Nova, 1, 1u, 2u, MFILE_LGHNING, LS_NOVA, -1 }, + { MIS_BLODBOIL, &miss_null_1F, &MI_Blodboil, 1, 1u, 0u, MFILE_NONE, -1, LS_BLODBOIL }, + { MIS_APOCA, &AddApoca, &MI_Apoca, 1, 1u, 3u, MFILE_NEWEXP, LS_APOC, -1 }, + { MIS_REPAIR, &AddRepair, &MI_Dummy, 0, 2u, 0u, MFILE_NONE, -1, -1 }, + { MIS_RECHARGE, &AddRecharge, &MI_Dummy, 0, 2u, 0u, MFILE_NONE, -1, -1 }, + { MIS_DISARM, &AddDisarm, &MI_Dummy, 0, 2u, 0u, MFILE_NONE, LS_TRAPDIS, -1 }, + { MIS_FLAME, &AddFlame, &MI_Flame, 1, 1u, 1u, MFILE_INFERNO, LS_SPOUTSTR, -1 }, + { MIS_FLAMEC, &AddFlamec, &MI_Flamec, 0, 1u, 1u, MFILE_NONE, -1, -1 }, + { MIS_NULL_32, &miss_null_32, &mi_null_32, 1, 2u, 0u, MFILE_NONE, -1, -1 }, + { MIS_NULL_33, &miss_null_33, &mi_null_33, 1, 0u, 1u, MFILE_KRULL, -1, -1 }, + { MIS_CBOLT, &AddCbolt, &MI_Cbolt, 1, 1u, 2u, MFILE_MINILTNG, LS_CBOLT, -1 }, + { MIS_HBOLT, &AddHbolt, &MI_Hbolt, 1, 1u, 0u, MFILE_HOLY, LS_HOLYBOLT, LS_ELECIMP1 }, + { MIS_RESURRECT, &AddResurrect, &MI_Dummy, 0, 1u, 3u, MFILE_NONE, -1, LS_RESUR }, + { MIS_TELEKINESIS, &AddTelekinesis, &MI_Dummy, 0, 1u, 0u, MFILE_NONE, LS_ETHEREAL, -1 }, + { MIS_LARROW, &AddLArrow, &MI_LArrow, 1, 0u, 2u, MFILE_LARROW, -1, -1 }, + { MIS_ACID, &AddAcid, &MI_Firebolt, 1, 1u, 4u, MFILE_ACIDBF, LS_ACID, -1 }, + { MIS_MISEXP3, &AddMisexp, &MI_Acidsplat, 1, 2u, 4u, MFILE_ACIDSPLA, -1, -1 }, + { MIS_ACIDPUD, &AddAcidpud, &MI_Acidpud, 1, 2u, 4u, MFILE_ACIDPUD, LS_PUDDLE, -1 }, + { MIS_HEALOTHER, &AddHealOther, &MI_Dummy, 0, 1u, 0u, MFILE_NONE, -1, -1 }, + { MIS_ELEMENT, &AddElement, &MI_Element, 1, 1u, 1u, MFILE_FIRERUN, LS_ELEMENTL, -1 }, + { MIS_RESURRECTBEAM, &AddResurrectBeam, &MI_ResurrectBeam, 1, 1u, 0u, MFILE_RESSUR1, -1, -1 }, + { MIS_BONESPIRIT, &AddBoneSpirit, &MI_Bonespirit, 1, 1u, 3u, MFILE_SKLBALL, LS_BONESP, LS_BSIMPCT }, + { MIS_WEAPEXP, &AddWeapexp, &MI_Weapexp, 1, 2u, 0u, MFILE_NONE, -1, -1 }, + { MIS_RPORTAL, &AddRportal, &MI_Rportal, 1, 2u, 0u, MFILE_RPORTAL, LS_SENTINEL, LS_ELEMENTL }, + { MIS_BOOM2, &AddBoom, &MI_Boom, 1, 2u, 0u, MFILE_FIREPLAR, -1, -1 }, + { MIS_DIABAPOCA, &AddDiabApoca, &MI_Dummy, 0, 2u, 0u, MFILE_NONE, -1, -1 } }; MisFileData misfiledata[47] = { - // clang-format off + // clang-format off // mAnimName, mAnimFAmt, mName, mFlags, mAnimData[16], mAnimDelay[16], mAnimLen[16], mAnimWidth[16], mAnimWidth2[16] { MFILE_ARROWS, 1, "Arrows", 2, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, { MFILE_FIREBA, 16, "Fireba", 0, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14 }, { 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96 }, { 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 } }, diff --git a/Source/monster.cpp b/Source/monster.cpp index 5f892058..d1a9264d 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -25,7 +25,7 @@ const unsigned char counsmiss[4] = { MIS_FIREBOLT, MIS_CBOLT, MIS_LIGHTCTRL, MIS /* data */ MonsterData monsterdata[112] = { - // clang-format off + // clang-format off // flags, mType, GraphicType, has_special, sndfile, snd_special, has_trans, TransFile, Frames[6], Rate[6], mName, mMinDLvl, mMaxDLvl, mLevel, mMinHP, mMaxHP, mAi, mFlags, mInt, mHit, mAFNum, mMinDamage, mMaxDamage, mHit2, mAFNum2, mMinDamage2, mMaxDamage2, mArmorClass, mMonstClass, mMagicRes, mMagicRes2, mTreasure, mSelFlag, mExp { 128, 799, "Monsters\\Zombie\\Zombie%c.CL2", 0, "Monsters\\Zombie\\Zombie%c%i.WAV", 0, 0, NULL, { 11, 24, 12, 6, 16, 0 }, { 4, 0, 0, 0, 0, 0 }, "Zombie", 1, 3, 1, 4, 7, AI_ZOMBIE, 0, 0, 10, 8, 2, 5, 0, 0, 0, 0, 5, MC_UNDEAD, 72, 72, 0, 3, 54 }, { 128, 799, "Monsters\\Zombie\\Zombie%c.CL2", 0, "Monsters\\Zombie\\Zombie%c%i.WAV", 0, 1, "Monsters\\Zombie\\Bluered.TRN", { 11, 24, 12, 6, 16, 0 }, { 4, 0, 0, 0, 0, 0 }, "Ghoul", 2, 4, 2, 7, 11, AI_ZOMBIE, 0, 1, 10, 8, 3, 10, 0, 0, 0, 0, 10, MC_UNDEAD, 72, 72, 0, 3, 58 }, @@ -139,40 +139,40 @@ MonsterData monsterdata[112] = { { 96, 386, "Monsters\\Golem\\Golem%c.CL2", 1, "Monsters\\Golem\\Golm%c%i.WAV", 0, 0, NULL, { 0, 16, 12, 0, 12, 20 }, { 0, 0, 0, 0, 0, 0 }, "Golem", 0, 0, 12, 1, 1, AI_GOLUM, 512, 0, 0, 7, 1, 1, 0, 0, 0, 0, 1, MC_DEMON, 0, 0, 0, 0, 0 }, { 160, 2000, "Monsters\\Diablo\\Diablo%c.CL2", 1, "Monsters\\Diablo\\Diablo%c%i.WAV", 1, 0, NULL, { 16, 6, 16, 6, 16, 16 }, { 0, 0, 0, 0, 0, 0 }, "The Dark Lord", 50, 50, 30, 1666, 1666, AI_DIABLO, 896, 3, 220, 4, 30, 60, 0, 11, 0, 0, 70, MC_DEMON, 78, 78, 0, 7, 31666 }, { 128, 1060, "Monsters\\DarkMage\\Dmage%c.CL2", 1, "Monsters\\DarkMage\\Dmag%c%i.WAV", 0, 0, NULL, { 6, 1, 21, 6, 23, 18 }, { 0, 0, 0, 0, 0, 0 }, "The Arch-Litch Malignus", 30, 30, 30, 160, 160, AI_COUNSLR, 512, 3, 120, 8, 20, 40, 0, 0, 0, 0, 70, MC_DEMON, 71, 120, 0, 7, 4968 } - // clang-format on + // clang-format on }; char MonstConvTbl[128] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, - 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, - 20, 21, 22, 23, 24, 25, 26, 27, 29, 30, - 31, 32, 34, 35, 36, 37, 38, 40, 39, 41, - 42, 43, 44, 45, 46, 47, 48, 49, 50, 52, - 53, 54, 55, 56, 57, 59, 58, 60, 61, 62, - 63, 64, 65, 66, 67, 68, 69, 70, 71, 0, - 0, 0, 0, 72, 73, 74, 75, 0, 0, 0, - 0, 77, 76, 78, 79, 81, 82, 83, 84, 85, - 86, 87, 88, 89, 90, 92, 91, 93, 94, 95, - 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, - 106, 107, 108, 0, 110, 0, 109, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 80, 111 + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 29, 30, + 31, 32, 34, 35, 36, 37, 38, 40, 39, 41, + 42, 43, 44, 45, 46, 47, 48, 49, 50, 52, + 53, 54, 55, 56, 57, 59, 58, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 69, 70, 71, 0, + 0, 0, 0, 72, 73, 74, 75, 0, 0, 0, + 0, 77, 76, 78, 79, 81, 82, 83, 84, 85, + 86, 87, 88, 89, 90, 92, 91, 93, 94, 95, + 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, + 106, 107, 108, 0, 110, 0, 109, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 80, 111 }; unsigned char MonstAvailTbl[112] = { - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, - 2, 2, 2, 0, 2, 2, 2, 2, 1, 1, - 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, - 0, 0, 2, 2, 2, 2, 0, 0, 0, 0, - 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, - 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, - 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, - 0, 0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, + 2, 2, 2, 0, 2, 2, 2, 2, 1, 1, + 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, + 0, 0, 2, 2, 2, 2, 0, 0, 0, 0, + 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, + 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, + 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, + 0, 0 }; UniqMonstStruct UniqMonst[98] = { - // clang-format off + // clang-format off // mtype, mName, mMode, mlevel, mmaxhp, mAi, mint, mMinDamage, mMaxDamage, mMagicRes, mUnqAttr, mUnqVar1, mUnqVar2, mtalkmsg { MT_NGOATMC, "Gharbad the Weak", "BSDB", 4, 120, AI_GARBUD, 3, 8, 16, 96, 0, 0, 0, QUEST_GARBUD1 }, { MT_SKING, "Skeleton King", "GENRL", 0, 240, AI_SKELKING, 3, 6, 16, 78, 1, 0, 0, 0 }, @@ -272,33 +272,33 @@ UniqMonstStruct UniqMonst[98] = { { MT_OBLORD, "Grimspike", "GENERAL", 19, 534, AI_SNEAK, 1, 25, 40, 74, 3, 0, 0, 0 }, { MT_STORML, "Doomlock", "GENERAL", 28, 534, AI_SNEAK, 1, 35, 55, 78, 3, 0, 0, 0 }, { -1, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } - // clang-format on + // clang-format on }; int MWVel[24][3] = { - { 256, 512, 1024 }, - { 128, 256, 512 }, - { 85, 170, 341 }, - { 64, 128, 256 }, - { 51, 102, 204 }, - { 42, 85, 170 }, - { 36, 73, 146 }, - { 32, 64, 128 }, - { 28, 56, 113 }, - { 26, 51, 102 }, - { 23, 46, 93 }, - { 21, 42, 85 }, - { 19, 39, 78 }, - { 18, 36, 73 }, - { 17, 34, 68 }, - { 16, 32, 64 }, - { 15, 30, 60 }, - { 14, 28, 57 }, - { 13, 26, 54 }, - { 12, 25, 51 }, - { 12, 24, 48 }, - { 11, 23, 46 }, - { 11, 22, 44 }, - { 10, 21, 42 } + { 256, 512, 1024 }, + { 128, 256, 512 }, + { 85, 170, 341 }, + { 64, 128, 256 }, + { 51, 102, 204 }, + { 42, 85, 170 }, + { 36, 73, 146 }, + { 32, 64, 128 }, + { 28, 56, 113 }, + { 26, 51, 102 }, + { 23, 46, 93 }, + { 21, 42, 85 }, + { 19, 39, 78 }, + { 18, 36, 73 }, + { 17, 34, 68 }, + { 16, 32, 64 }, + { 15, 30, 60 }, + { 14, 28, 57 }, + { 13, 26, 54 }, + { 12, 25, 51 }, + { 12, 24, 48 }, + { 11, 23, 46 }, + { 11, 22, 44 }, + { 10, 21, 42 } }; char animletter[7] = "nwahds"; int left[8] = { 7, 0, 1, 2, 3, 4, 5, 6 }; @@ -315,1002 +315,1002 @@ int rnd60[4] = { 60, 70, 80, 90 }; // void(__fastcall *AiProc[])(int i) = { - &MAI_Zombie, - &MAI_Fat, - &MAI_SkelSd, - &MAI_SkelBow, - &MAI_Scav, - &MAI_Rhino, - &MAI_GoatMc, - &MAI_GoatBow, - &MAI_Fallen, - &MAI_Magma, - &MAI_SkelKing, - &MAI_Bat, - &MAI_Garg, - &MAI_Cleaver, - &MAI_Succ, - &MAI_Sneak, - &MAI_Storm, - &MAI_Fireman, - &MAI_Garbud, - &MAI_Acid, - &MAI_AcidUniq, - &MAI_Golum, - &MAI_Zhar, - &MAI_SnotSpil, - &MAI_Snake, - &MAI_Counselor, - &MAI_Mega, - &MAI_Diablo, - &MAI_Lazurus, - &MAI_Lazhelp, - &MAI_Lachdanan, - &MAI_Warlord + &MAI_Zombie, + &MAI_Fat, + &MAI_SkelSd, + &MAI_SkelBow, + &MAI_Scav, + &MAI_Rhino, + &MAI_GoatMc, + &MAI_GoatBow, + &MAI_Fallen, + &MAI_Magma, + &MAI_SkelKing, + &MAI_Bat, + &MAI_Garg, + &MAI_Cleaver, + &MAI_Succ, + &MAI_Sneak, + &MAI_Storm, + &MAI_Fireman, + &MAI_Garbud, + &MAI_Acid, + &MAI_AcidUniq, + &MAI_Golum, + &MAI_Zhar, + &MAI_SnotSpil, + &MAI_Snake, + &MAI_Counselor, + &MAI_Mega, + &MAI_Diablo, + &MAI_Lazurus, + &MAI_Lazhelp, + &MAI_Lachdanan, + &MAI_Warlord }; struct monster_cpp_init { - monster_cpp_init() - { - monster_cpp_init_value = monster_inf; - } + monster_cpp_init() + { + monster_cpp_init_value = monster_inf; + } } _monster_cpp_init; // 47F130: using guessed type int monster_inf; // 64CCE4: using guessed type int monster_cpp_init_value; void __fastcall InitMonsterTRN(int monst, BOOL special) { - BYTE *f = Monsters[monst].trans_file; - for (int i = 0; i < 256; i++) { - if (*f == 255) { - *f = 0; - } - f++; - } + BYTE *f = Monsters[monst].trans_file; + for (int i = 0; i < 256; i++) { + if (*f == 255) { + *f = 0; + } + f++; + } - int n = special ? 6 : 5; - for (int j = 0; j < n; ++j) { - if (j != 1 || Monsters[monst].mtype < MT_COUNSLR || Monsters[monst].mtype > MT_ADVOCATE) { - for (int k = 0; k < 8; k++) { - Cl2ApplyTrans( - Monsters[monst].Anims[j].Data[k], - Monsters[monst].trans_file, - Monsters[monst].Anims[j].Frames); - } - } - } + int n = special ? 6 : 5; + for (int j = 0; j < n; ++j) { + if (j != 1 || Monsters[monst].mtype < MT_COUNSLR || Monsters[monst].mtype > MT_ADVOCATE) { + for (int k = 0; k < 8; k++) { + Cl2ApplyTrans( + Monsters[monst].Anims[j].Data[k], + Monsters[monst].trans_file, + Monsters[monst].Anims[j].Frames); + } + } + } } void __cdecl InitLevelMonsters() { - int i; + int i; - nummtypes = 0; - monstimgtot = 0; - MissileFileFlag = 0; + nummtypes = 0; + monstimgtot = 0; + MissileFileFlag = 0; - for (i = 0; i < MAX_LVLMTYPES; i++) { - Monsters[i].mPlaceFlags = 0; - } + for (i = 0; i < MAX_LVLMTYPES; i++) { + Monsters[i].mPlaceFlags = 0; + } - ClrAllMonsters(); - nummonsters = 0; - totalmonsters = MAXMONSTERS; + ClrAllMonsters(); + nummonsters = 0; + totalmonsters = MAXMONSTERS; - for (i = 0; i < MAXMONSTERS; i++) { - monstactive[i] = i; - } + for (i = 0; i < MAXMONSTERS; i++) { + monstactive[i] = i; + } - uniquetrans = 0; + uniquetrans = 0; } int __fastcall AddMonsterType(int type, int placeflag) { - BOOL done = FALSE; - int i; + BOOL done = FALSE; + int i; - for (i = 0; i < nummtypes && !done; i++) { - done = Monsters[i].mtype == type; - } + for (i = 0; i < nummtypes && !done; i++) { + done = Monsters[i].mtype == type; + } - i--; + i--; - if (!done) { - i = nummtypes; - nummtypes++; - Monsters[i].mtype = type; - monstimgtot += monsterdata[type].mType; - InitMonsterGFX(i); - InitMonsterSND(i); - } + if (!done) { + i = nummtypes; + nummtypes++; + Monsters[i].mtype = type; + monstimgtot += monsterdata[type].mType; + InitMonsterGFX(i); + InitMonsterSND(i); + } - Monsters[i].mPlaceFlags |= placeflag; - return i; + Monsters[i].mPlaceFlags |= placeflag; + return i; } void __cdecl GetLevelMTypes() { - int i; + int i; - // this array is merged with skeltypes down below. - int typelist[MAXMONSTERS]; - int skeltypes[NUM_MTYPES]; + // this array is merged with skeltypes down below. + int typelist[MAXMONSTERS]; + int skeltypes[NUM_MTYPES]; - int minl; // min level - int maxl; // max level - char mamask = 3; // monster availability mask + int minl; // min level + int maxl; // max level + char mamask = 3; // monster availability mask - int nt; // number of types + int nt; // number of types - AddMonsterType(MT_GOLEM, 2); - if (currlevel == 16) { - AddMonsterType(MT_ADVOCATE, 1); - AddMonsterType(MT_RBLACK, 1); - AddMonsterType(MT_DIABLO, 2); - return; - } + AddMonsterType(MT_GOLEM, 2); + if (currlevel == 16) { + AddMonsterType(MT_ADVOCATE, 1); + AddMonsterType(MT_RBLACK, 1); + AddMonsterType(MT_DIABLO, 2); + return; + } - if (!setlevel) { - if (QuestStatus(QTYPE_BUTCH)) - AddMonsterType(MT_CLEAVER, 2); - if (QuestStatus(QTYPE_GARB)) - AddMonsterType(UniqMonst[0].mtype, 4); - if (QuestStatus(QTYPE_ZHAR)) - AddMonsterType(UniqMonst[2].mtype, 4); - if (QuestStatus(QTYPE_BOL)) - AddMonsterType(UniqMonst[3].mtype, 4); - if (QuestStatus(QTYPE_VEIL)) - AddMonsterType(UniqMonst[7].mtype, 4); - if (QuestStatus(QTYPE_WARLRD)) - AddMonsterType(UniqMonst[8].mtype, 4); + if (!setlevel) { + if (QuestStatus(QTYPE_BUTCH)) + AddMonsterType(MT_CLEAVER, 2); + if (QuestStatus(QTYPE_GARB)) + AddMonsterType(UniqMonst[0].mtype, 4); + if (QuestStatus(QTYPE_ZHAR)) + AddMonsterType(UniqMonst[2].mtype, 4); + if (QuestStatus(QTYPE_BOL)) + AddMonsterType(UniqMonst[3].mtype, 4); + if (QuestStatus(QTYPE_VEIL)) + AddMonsterType(UniqMonst[7].mtype, 4); + if (QuestStatus(QTYPE_WARLRD)) + AddMonsterType(UniqMonst[8].mtype, 4); - if (gbMaxPlayers != 1 && currlevel == quests[QTYPE_KING]._qlevel) { + if (gbMaxPlayers != 1 && currlevel == quests[QTYPE_KING]._qlevel) { - AddMonsterType(MT_SKING, 4); - const int numskeltypes = 19; + AddMonsterType(MT_SKING, 4); + const int numskeltypes = 19; - nt = 0; - for (i = MT_WSKELAX; i <= MT_WSKELAX + numskeltypes; i++) { - if (IsSkel(i)) { - minl = 15 * monsterdata[i].mMinDLvl / 30 + 1; - maxl = 15 * monsterdata[i].mMaxDLvl / 30 + 1; + nt = 0; + for (i = MT_WSKELAX; i <= MT_WSKELAX + numskeltypes; i++) { + if (IsSkel(i)) { + minl = 15 * monsterdata[i].mMinDLvl / 30 + 1; + maxl = 15 * monsterdata[i].mMaxDLvl / 30 + 1; - if (currlevel >= minl && currlevel <= maxl) { - if (MonstAvailTbl[i] & mamask) { - skeltypes[nt++] = i; - } - } - } - } - AddMonsterType(skeltypes[random(88, nt)], 1); - } + if (currlevel >= minl && currlevel <= maxl) { + if (MonstAvailTbl[i] & mamask) { + skeltypes[nt++] = i; + } + } + } + } + AddMonsterType(skeltypes[random(88, nt)], 1); + } - nt = 0; - for (i = 0; i < 111; i++) { - minl = 15 * monsterdata[i].mMinDLvl / 30 + 1; - maxl = 15 * monsterdata[i].mMaxDLvl / 30 + 1; + nt = 0; + for (i = 0; i < 111; i++) { + minl = 15 * monsterdata[i].mMinDLvl / 30 + 1; + maxl = 15 * monsterdata[i].mMaxDLvl / 30 + 1; - if (currlevel >= minl && currlevel <= maxl) { - if (MonstAvailTbl[i] & mamask) { - typelist[nt++] = i; - } - } - } + if (currlevel >= minl && currlevel <= maxl) { + if (MonstAvailTbl[i] & mamask) { + typelist[nt++] = i; + } + } + } - if (monstdebug) { - for (i = 0; i < debugmonsttypes; i++) - AddMonsterType(DebugMonsters[i], 1); - } else { + if (monstdebug) { + for (i = 0; i < debugmonsttypes; i++) + AddMonsterType(DebugMonsters[i], 1); + } else { - while (nt > 0 && nummtypes < MAX_LVLMTYPES && monstimgtot < 4000) { - for (i = 0; i < nt;) { - if (monsterdata[typelist[i]].mType > 4000 - monstimgtot) { - typelist[i] = typelist[--nt]; - continue; - } + while (nt > 0 && nummtypes < MAX_LVLMTYPES && monstimgtot < 4000) { + for (i = 0; i < nt;) { + if (monsterdata[typelist[i]].mType > 4000 - monstimgtot) { + typelist[i] = typelist[--nt]; + continue; + } - i++; - } + i++; + } - if (nt != 0) { - i = random(88, nt); - AddMonsterType(typelist[i], 1); - typelist[i] = typelist[--nt]; - } - } - } + if (nt != 0) { + i = random(88, nt); + AddMonsterType(typelist[i], 1); + typelist[i] = typelist[--nt]; + } + } + } - } else { - if (setlvlnum == SL_SKELKING) { - AddMonsterType(MT_SKING, 4); - } - } + } else { + if (setlvlnum == SL_SKELKING) { + AddMonsterType(MT_SKING, 4); + } + } } void __fastcall InitMonsterGFX(int monst) { - int mtype = (unsigned char)Monsters[monst].mtype; - char strBuff[256]; + int mtype = (unsigned char)Monsters[monst].mtype; + char strBuff[256]; - for (int anim = 0; anim < 6; anim++) { - if ((animletter[anim] != 's' || monsterdata[mtype].has_special) && monsterdata[mtype].Frames[anim] > 0) { - sprintf(strBuff, monsterdata[mtype].GraphicType, animletter[anim]); + for (int anim = 0; anim < 6; anim++) { + if ((animletter[anim] != 's' || monsterdata[mtype].has_special) && monsterdata[mtype].Frames[anim] > 0) { + sprintf(strBuff, monsterdata[mtype].GraphicType, animletter[anim]); - unsigned char *celBuf = LoadFileInMem(strBuff, NULL); - Monsters[monst].Anims[anim].CMem = celBuf; + unsigned char *celBuf = LoadFileInMem(strBuff, NULL); + Monsters[monst].Anims[anim].CMem = celBuf; - if (Monsters[monst].mtype != MT_GOLEM || (animletter[anim] != 's' && animletter[anim] != 'd')) { + if (Monsters[monst].mtype != MT_GOLEM || (animletter[anim] != 's' && animletter[anim] != 'd')) { - for (int i = 0; i < 8; i++) { - Monsters[monst].Anims[anim].Data[i] = &celBuf[((int *)celBuf)[i]]; - } - } else { - for (int i = 0; i < 8; i++) { - Monsters[monst].Anims[anim].Data[i] = celBuf; - } - } - } + for (int i = 0; i < 8; i++) { + Monsters[monst].Anims[anim].Data[i] = &celBuf[((int *)celBuf)[i]]; + } + } else { + for (int i = 0; i < 8; i++) { + Monsters[monst].Anims[anim].Data[i] = celBuf; + } + } + } - // TODO: either the AnimStruct members have wrong naming or the MonsterData ones it seems - Monsters[monst].Anims[anim].Frames = monsterdata[mtype].Frames[anim]; - Monsters[monst].Anims[anim].Rate = monsterdata[mtype].Rate[anim]; - } + // TODO: either the AnimStruct members have wrong naming or the MonsterData ones it seems + Monsters[monst].Anims[anim].Frames = monsterdata[mtype].Frames[anim]; + Monsters[monst].Anims[anim].Rate = monsterdata[mtype].Rate[anim]; + } - Monsters[monst].flags_1 = monsterdata[mtype].flags; - Monsters[monst].flags_2 = (monsterdata[mtype].flags - 64) >> 1; - Monsters[monst].mMinHP = monsterdata[mtype].mMinHP; - Monsters[monst].mMaxHP = monsterdata[mtype].mMaxHP; - Monsters[monst].has_special = monsterdata[mtype].has_special; - Monsters[monst].mAFNum = monsterdata[mtype].mAFNum; - Monsters[monst].MData = &monsterdata[mtype]; + Monsters[monst].flags_1 = monsterdata[mtype].flags; + Monsters[monst].flags_2 = (monsterdata[mtype].flags - 64) >> 1; + Monsters[monst].mMinHP = monsterdata[mtype].mMinHP; + Monsters[monst].mMaxHP = monsterdata[mtype].mMaxHP; + Monsters[monst].has_special = monsterdata[mtype].has_special; + Monsters[monst].mAFNum = monsterdata[mtype].mAFNum; + Monsters[monst].MData = &monsterdata[mtype]; - if (monsterdata[mtype].has_trans) { - Monsters[monst].trans_file = LoadFileInMem(monsterdata[mtype].TransFile, NULL); - InitMonsterTRN(monst, monsterdata[mtype].has_special); + if (monsterdata[mtype].has_trans) { + Monsters[monst].trans_file = LoadFileInMem(monsterdata[mtype].TransFile, NULL); + InitMonsterTRN(monst, monsterdata[mtype].has_special); - void *trans_file = Monsters[monst].trans_file; - Monsters[monst].trans_file = NULL; + void *trans_file = Monsters[monst].trans_file; + Monsters[monst].trans_file = NULL; - mem_free_dbg(trans_file); - } + mem_free_dbg(trans_file); + } - if (mtype >= MT_NMAGMA && mtype <= MT_WMAGMA && !(MissileFileFlag & 1)) { - MissileFileFlag |= 1; - LoadMissileGFX(MFILE_MAGBALL); - } - if (mtype >= MT_STORM && mtype <= MT_MAEL && !(MissileFileFlag & 2)) { - MissileFileFlag |= 2; - LoadMissileGFX(MFILE_THINLGHT); - } - if (mtype == MT_SUCCUBUS) { - if (MissileFileFlag & 4) - return; + if (mtype >= MT_NMAGMA && mtype <= MT_WMAGMA && !(MissileFileFlag & 1)) { + MissileFileFlag |= 1; + LoadMissileGFX(MFILE_MAGBALL); + } + if (mtype >= MT_STORM && mtype <= MT_MAEL && !(MissileFileFlag & 2)) { + MissileFileFlag |= 2; + LoadMissileGFX(MFILE_THINLGHT); + } + if (mtype == MT_SUCCUBUS) { + if (MissileFileFlag & 4) + return; - MissileFileFlag |= 4; - LoadMissileGFX(MFILE_FLARE); - LoadMissileGFX(MFILE_FLAREEXP); - } - if (mtype == MT_SNOWWICH) { - if (MissileFileFlag & 0x20) - return; + MissileFileFlag |= 4; + LoadMissileGFX(MFILE_FLARE); + LoadMissileGFX(MFILE_FLAREEXP); + } + if (mtype == MT_SNOWWICH) { + if (MissileFileFlag & 0x20) + return; - MissileFileFlag |= 0x20; - LoadMissileGFX(MFILE_SCUBMISB); - LoadMissileGFX(MFILE_SCBSEXPB); - } - if (mtype == MT_HLSPWN) { - if (MissileFileFlag & 0x40) - return; + MissileFileFlag |= 0x20; + LoadMissileGFX(MFILE_SCUBMISB); + LoadMissileGFX(MFILE_SCBSEXPB); + } + if (mtype == MT_HLSPWN) { + if (MissileFileFlag & 0x40) + return; - MissileFileFlag |= 0x40; - LoadMissileGFX(MFILE_SCUBMISD); - LoadMissileGFX(MFILE_SCBSEXPD); - } - if (mtype == MT_SOLBRNR) { - if (MissileFileFlag & 0x80) - return; + MissileFileFlag |= 0x40; + LoadMissileGFX(MFILE_SCUBMISD); + LoadMissileGFX(MFILE_SCBSEXPD); + } + if (mtype == MT_SOLBRNR) { + if (MissileFileFlag & 0x80) + return; - MissileFileFlag |= 0x80; - LoadMissileGFX(MFILE_SCUBMISC); - LoadMissileGFX(MFILE_SCBSEXPC); - } - if (mtype >= MT_INCIN && mtype <= MT_HELLBURN && !(MissileFileFlag & 8)) { - MissileFileFlag |= 8; - LoadMissileGFX(MFILE_KRULL); - } - if (mtype >= MT_NACID && mtype <= MT_XACID && !(MissileFileFlag & 0x10)) { - MissileFileFlag |= 0x10; - LoadMissileGFX(MFILE_ACIDBF); - LoadMissileGFX(MFILE_ACIDSPLA); - LoadMissileGFX(MFILE_ACIDPUD); - } - if (mtype == MT_DIABLO) { - LoadMissileGFX(MFILE_FIREPLAR); - } + MissileFileFlag |= 0x80; + LoadMissileGFX(MFILE_SCUBMISC); + LoadMissileGFX(MFILE_SCBSEXPC); + } + if (mtype >= MT_INCIN && mtype <= MT_HELLBURN && !(MissileFileFlag & 8)) { + MissileFileFlag |= 8; + LoadMissileGFX(MFILE_KRULL); + } + if (mtype >= MT_NACID && mtype <= MT_XACID && !(MissileFileFlag & 0x10)) { + MissileFileFlag |= 0x10; + LoadMissileGFX(MFILE_ACIDBF); + LoadMissileGFX(MFILE_ACIDSPLA); + LoadMissileGFX(MFILE_ACIDPUD); + } + if (mtype == MT_DIABLO) { + LoadMissileGFX(MFILE_FIREPLAR); + } } void __fastcall ClearMVars(int i) { - monster[i]._mVar1 = 0; - monster[i]._mVar2 = 0; - monster[i]._mVar3 = 0; - monster[i]._mVar4 = 0; - monster[i]._mVar5 = 0; - monster[i]._mVar6 = 0; - monster[i]._mVar7 = 0; - monster[i]._mVar8 = 0; + monster[i]._mVar1 = 0; + monster[i]._mVar2 = 0; + monster[i]._mVar3 = 0; + monster[i]._mVar4 = 0; + monster[i]._mVar5 = 0; + monster[i]._mVar6 = 0; + monster[i]._mVar7 = 0; + monster[i]._mVar8 = 0; } void __fastcall InitMonster(int i, int rd, int mtype, int x, int y) { - CMonster *monst = &Monsters[mtype]; + CMonster *monst = &Monsters[mtype]; - monster[i]._mdir = rd; - monster[i]._mx = x; - monster[i]._my = y; - monster[i]._mfutx = x; - monster[i]._mfuty = y; - monster[i]._moldx = x; - monster[i]._moldy = y; - monster[i]._mmode = MM_STAND; - monster[i]._mMTidx = mtype; - monster[i].mName = monst->MData->mName; - monster[i].MType = monst; - monster[i].MData = monst->MData; - monster[i]._mAnimData = monst->Anims[MA_STAND].Data[rd]; - monster[i]._mAnimDelay = monst->Anims[MA_STAND].Rate; - monster[i]._mAnimCnt = random(88, monst->Anims[MA_STAND].Rate - 1); - monster[i]._mAnimLen = monst->Anims[MA_STAND].Frames; - monster[i]._mAnimFrame = random(88, monst->Anims[MA_STAND].Frames - 1) + 1; + monster[i]._mdir = rd; + monster[i]._mx = x; + monster[i]._my = y; + monster[i]._mfutx = x; + monster[i]._mfuty = y; + monster[i]._moldx = x; + monster[i]._moldy = y; + monster[i]._mmode = MM_STAND; + monster[i]._mMTidx = mtype; + monster[i].mName = monst->MData->mName; + monster[i].MType = monst; + monster[i].MData = monst->MData; + monster[i]._mAnimData = monst->Anims[MA_STAND].Data[rd]; + monster[i]._mAnimDelay = monst->Anims[MA_STAND].Rate; + monster[i]._mAnimCnt = random(88, monst->Anims[MA_STAND].Rate - 1); + monster[i]._mAnimLen = monst->Anims[MA_STAND].Frames; + monster[i]._mAnimFrame = random(88, monst->Anims[MA_STAND].Frames - 1) + 1; - if (monst->mtype == MT_DIABLO) { - monster[i]._mmaxhp = (random(88, 1) + 1666) << 6; - } else { - monster[i]._mmaxhp = (monst->mMinHP + random(88, monst->mMaxHP - monst->mMinHP + 1)) << 6; - } + if (monst->mtype == MT_DIABLO) { + monster[i]._mmaxhp = (random(88, 1) + 1666) << 6; + } else { + monster[i]._mmaxhp = (monst->mMinHP + random(88, monst->mMaxHP - monst->mMinHP + 1)) << 6; + } - if (gbMaxPlayers == 1) { - monster[i]._mmaxhp >>= 1; - if (monster[i]._mmaxhp < 64) { - monster[i]._mmaxhp = 64; - } - } + if (gbMaxPlayers == 1) { + monster[i]._mmaxhp >>= 1; + if (monster[i]._mmaxhp < 64) { + monster[i]._mmaxhp = 64; + } + } - monster[i]._mhitpoints = monster[i]._mmaxhp; - monster[i]._mAi = monst->MData->mAi; - monster[i]._mint = monst->MData->mInt; - monster[i]._mgoal = 1; - monster[i]._mgoalvar1 = 0; - monster[i]._mgoalvar2 = 0; - monster[i]._mgoalvar3 = 0; - monster[i]._pathcount = 0; - monster[i]._uniqtype = 0; - monster[i]._msquelch = 0; - monster[i].field_18 = 0; - monster[i]._mDelFlag = FALSE; - monster[i]._mRndSeed = GetRndSeed(); - monster[i]._mAISeed = GetRndSeed(); - monster[i].mWhoHit = 0; - monster[i].mLevel = monst->MData->mLevel; - monster[i].mExp = monst->MData->mExp; - monster[i].mHit = monst->MData->mHit; - monster[i].mMinDamage = monst->MData->mMinDamage; - monster[i].mMaxDamage = monst->MData->mMaxDamage; - monster[i].mHit2 = monst->MData->mHit2; - monster[i].mMinDamage2 = monst->MData->mMinDamage2; - monster[i].mMaxDamage2 = monst->MData->mMaxDamage2; - monster[i].mArmorClass = monst->MData->mArmorClass; - monster[i].mMagicRes = monst->MData->mMagicRes; - monster[i].leader = 0; - monster[i].leaderflag = 0; - monster[i]._mFlags = monst->MData->mFlags; - monster[i].mtalkmsg = 0; + monster[i]._mhitpoints = monster[i]._mmaxhp; + monster[i]._mAi = monst->MData->mAi; + monster[i]._mint = monst->MData->mInt; + monster[i]._mgoal = 1; + monster[i]._mgoalvar1 = 0; + monster[i]._mgoalvar2 = 0; + monster[i]._mgoalvar3 = 0; + monster[i]._pathcount = 0; + monster[i]._uniqtype = 0; + monster[i]._msquelch = 0; + monster[i].field_18 = 0; + monster[i]._mDelFlag = FALSE; + monster[i]._mRndSeed = GetRndSeed(); + monster[i]._mAISeed = GetRndSeed(); + monster[i].mWhoHit = 0; + monster[i].mLevel = monst->MData->mLevel; + monster[i].mExp = monst->MData->mExp; + monster[i].mHit = monst->MData->mHit; + monster[i].mMinDamage = monst->MData->mMinDamage; + monster[i].mMaxDamage = monst->MData->mMaxDamage; + monster[i].mHit2 = monst->MData->mHit2; + monster[i].mMinDamage2 = monst->MData->mMinDamage2; + monster[i].mMaxDamage2 = monst->MData->mMaxDamage2; + monster[i].mArmorClass = monst->MData->mArmorClass; + monster[i].mMagicRes = monst->MData->mMagicRes; + monster[i].leader = 0; + monster[i].leaderflag = 0; + monster[i]._mFlags = monst->MData->mFlags; + monster[i].mtalkmsg = 0; - if (monster[i]._mAi == AI_GARG) { - monster[i]._mAnimData = monst->Anims[MA_SPECIAL].Data[rd]; - monster[i]._mAnimFrame = 1; - monster[i]._mFlags |= 4u; - monster[i]._mmode = MM_SATTACK; - } + if (monster[i]._mAi == AI_GARG) { + monster[i]._mAnimData = monst->Anims[MA_SPECIAL].Data[rd]; + monster[i]._mAnimFrame = 1; + monster[i]._mFlags |= 4u; + monster[i]._mmode = MM_SATTACK; + } - if (gnDifficulty == DIFF_NIGHTMARE) { - monster[i].mLevel += 15; - monster[i].mHit += 85; - monster[i].mHit2 += 85; - monster[i]._mmaxhp = 3 * monster[i]._mmaxhp + 64; - monster[i]._mhitpoints = monster[i]._mmaxhp; - monster[i].mExp = 2 * (monster[i].mExp + 1000); - monster[i].mMinDamage = 2 * (monster[i].mMinDamage + 2); - monster[i].mMaxDamage = 2 * (monster[i].mMaxDamage + 2); - monster[i].mMinDamage2 = 2 * (monster[i].mMinDamage2 + 2); - monster[i].mMaxDamage2 = 2 * (monster[i].mMaxDamage2 + 2); - monster[i].mArmorClass += 50; - } + if (gnDifficulty == DIFF_NIGHTMARE) { + monster[i].mLevel += 15; + monster[i].mHit += 85; + monster[i].mHit2 += 85; + monster[i]._mmaxhp = 3 * monster[i]._mmaxhp + 64; + monster[i]._mhitpoints = monster[i]._mmaxhp; + monster[i].mExp = 2 * (monster[i].mExp + 1000); + monster[i].mMinDamage = 2 * (monster[i].mMinDamage + 2); + monster[i].mMaxDamage = 2 * (monster[i].mMaxDamage + 2); + monster[i].mMinDamage2 = 2 * (monster[i].mMinDamage2 + 2); + monster[i].mMaxDamage2 = 2 * (monster[i].mMaxDamage2 + 2); + monster[i].mArmorClass += 50; + } - if (gnDifficulty == DIFF_HELL) { - monster[i].mLevel += 30; - monster[i]._mmaxhp = 4 * monster[i]._mmaxhp + 192; - monster[i]._mhitpoints = monster[i]._mmaxhp; - monster[i].mHit += 120; - monster[i].mHit2 += 120; - monster[i].mExp = 4 * (monster[i].mExp + 1000); - monster[i].mMinDamage = 4 * monster[i].mMinDamage + 6; - monster[i].mMaxDamage = 4 * monster[i].mMaxDamage + 6; - monster[i].mMinDamage2 = 4 * monster[i].mMinDamage2 + 6; - monster[i].mMaxDamage2 = 4 * monster[i].mMaxDamage2 + 6; - monster[i].mArmorClass += 80; - monster[i].mMagicRes = monst->MData->mMagicRes2; - } + if (gnDifficulty == DIFF_HELL) { + monster[i].mLevel += 30; + monster[i]._mmaxhp = 4 * monster[i]._mmaxhp + 192; + monster[i]._mhitpoints = monster[i]._mmaxhp; + monster[i].mHit += 120; + monster[i].mHit2 += 120; + monster[i].mExp = 4 * (monster[i].mExp + 1000); + monster[i].mMinDamage = 4 * monster[i].mMinDamage + 6; + monster[i].mMaxDamage = 4 * monster[i].mMaxDamage + 6; + monster[i].mMinDamage2 = 4 * monster[i].mMinDamage2 + 6; + monster[i].mMaxDamage2 = 4 * monster[i].mMaxDamage2 + 6; + monster[i].mArmorClass += 80; + monster[i].mMagicRes = monst->MData->mMagicRes2; + } } void __cdecl ClrAllMonsters() { - MonsterStruct *Monst; + MonsterStruct *Monst; - for (int i = 0; i < MAXMONSTERS; i++) { - Monst = &monster[i]; - ClearMVars(i); - Monst->mName = "Invalid Monster"; - Monst->_mgoal = 0; - Monst->_mmode = MM_STAND; - Monst->_mVar1 = 0; - Monst->_mVar2 = 0; - Monst->_mx = 0; - Monst->_my = 0; - Monst->_mfutx = 0; - Monst->_mfuty = 0; - Monst->_moldx = 0; - Monst->_moldy = 0; - Monst->_mdir = random(89, 8); - Monst->_mxvel = 0; - Monst->_myvel = 0; - Monst->_mAnimData = NULL; - Monst->_mAnimDelay = 0; - Monst->_mAnimCnt = 0; - Monst->_mAnimLen = 0; - Monst->_mAnimFrame = 0; - Monst->_mFlags = 0; - Monst->_mDelFlag = FALSE; - Monst->_menemy = random(89, gbActivePlayers); - Monst->_menemyx = plr[Monst->_menemy]._px; - Monst->_menemyy = plr[Monst->_menemy]._py; - } + for (int i = 0; i < MAXMONSTERS; i++) { + Monst = &monster[i]; + ClearMVars(i); + Monst->mName = "Invalid Monster"; + Monst->_mgoal = 0; + Monst->_mmode = MM_STAND; + Monst->_mVar1 = 0; + Monst->_mVar2 = 0; + Monst->_mx = 0; + Monst->_my = 0; + Monst->_mfutx = 0; + Monst->_mfuty = 0; + Monst->_moldx = 0; + Monst->_moldy = 0; + Monst->_mdir = random(89, 8); + Monst->_mxvel = 0; + Monst->_myvel = 0; + Monst->_mAnimData = NULL; + Monst->_mAnimDelay = 0; + Monst->_mAnimCnt = 0; + Monst->_mAnimLen = 0; + Monst->_mAnimFrame = 0; + Monst->_mFlags = 0; + Monst->_mDelFlag = FALSE; + Monst->_menemy = random(89, gbActivePlayers); + Monst->_menemyx = plr[Monst->_menemy]._px; + Monst->_menemyy = plr[Monst->_menemy]._py; + } } BOOL __fastcall MonstPlace(int xp, int yp) { - if (xp < 0 || xp >= MAXDUNX - || yp < 0 || yp >= MAXDUNY - || dMonster[xp][yp] - || dPlayer[xp][yp]) { - return FALSE; - } + if (xp < 0 || xp >= MAXDUNX + || yp < 0 || yp >= MAXDUNY + || dMonster[xp][yp] + || dPlayer[xp][yp]) { + return FALSE; + } - char f = dFlags[xp][yp]; + char f = dFlags[xp][yp]; - if (f & DFLAG_VISIBLE) { - return FALSE; - } + if (f & DFLAG_VISIBLE) { + return FALSE; + } - if (f & DFLAG_POPULATED) { - return FALSE; - } + if (f & DFLAG_POPULATED) { + return FALSE; + } - return !SolidLoc(xp, yp); + return !SolidLoc(xp, yp); } void __fastcall PlaceMonster(int i, int mtype, int x, int y) { - dMonster[x][y] = i + 1; + dMonster[x][y] = i + 1; - int rd = random(90, 8); - InitMonster(i, rd, mtype, x, y); + int rd = random(90, 8); + InitMonster(i, rd, mtype, x, y); } void __fastcall PlaceUniqueMonst(int uniqindex, int miniontype, int unpackfilesize) { - int xp; - int yp; - char filestr[64]; + int xp; + int yp; + char filestr[64]; - UniqMonstStruct *Uniq = &UniqMonst[uniqindex]; - MonsterStruct *Monst = &monster[nummonsters]; - int count = 0; + UniqMonstStruct *Uniq = &UniqMonst[uniqindex]; + MonsterStruct *Monst = &monster[nummonsters]; + int count = 0; - if ((uniquetrans + 19) << 8 >= LIGHTSIZE) { - return; - } + if ((uniquetrans + 19) << 8 >= LIGHTSIZE) { + return; + } - int uniqtype; - for (uniqtype = 0; uniqtype < nummtypes; uniqtype++) { - if (Monsters[uniqtype].mtype == Uniq->mtype) { - break; - } - } + int uniqtype; + for (uniqtype = 0; uniqtype < nummtypes; uniqtype++) { + if (Monsters[uniqtype].mtype == Uniq->mtype) { + break; + } + } - while (true) { + while (true) { - xp = random(91, 80) + 16; - yp = random(91, 80) + 16; - int count2 = 0; - for (int x = xp - 3; x < xp + 3; x++) { - for (int y = yp - 3; y < yp + 3; y++) { - if (y >= 0 && y < 112 && x >= 0 && x < 112 && MonstPlace(x, y)) { - count2++; - } - } - } + xp = random(91, 80) + 16; + yp = random(91, 80) + 16; + int count2 = 0; + for (int x = xp - 3; x < xp + 3; x++) { + for (int y = yp - 3; y < yp + 3; y++) { + if (y >= 0 && y < 112 && x >= 0 && x < 112 && MonstPlace(x, y)) { + count2++; + } + } + } - if (count2 < 9) { - count++; - if (count < 1000) { - continue; - } - } + if (count2 < 9) { + count++; + if (count < 1000) { + continue; + } + } - if (MonstPlace(xp, yp)) { - break; - } - } + if (MonstPlace(xp, yp)) { + break; + } + } - if (uniqindex == 3) { - xp = 2 * setpc_x + 24; - yp = 2 * setpc_y + 28; - } - if (uniqindex == 8) { - xp = 2 * setpc_x + 22; - yp = 2 * setpc_y + 23; - } - if (uniqindex == 2) { - BOOL zharflag = TRUE; - for (int i = 0; i < themeCount; i++) { - if (i == zharlib && zharflag == TRUE) { - zharflag = FALSE; - xp = 2 * themeLoc[i].x + 20; - yp = 2 * themeLoc[i].y + 20; - } - } - } - if (gbMaxPlayers == 1) { - if (uniqindex == 4) { - xp = 32; - yp = 46; - } - if (uniqindex == 5) { - xp = 40; - yp = 45; - } - if (uniqindex == 6) { - xp = 38; - yp = 49; - } - if (uniqindex == 1) { - xp = 35; - yp = 47; - } - } else { - if (uniqindex == 4) { - xp = 2 * setpc_x + 19; - yp = 2 * setpc_y + 22; - } - if (uniqindex == 5) { - xp = 2 * setpc_x + 21; - yp = 2 * setpc_y + 19; - } - if (uniqindex == 6) { - xp = 2 * setpc_x + 21; - yp = 2 * setpc_y + 25; - } - } - if (uniqindex == 9) { - BOOL done = FALSE; - for (yp = 0; yp < 112 && !done; yp++) { - for (xp = 0; xp < 112 && !done; xp++) { - done = dPiece[xp][yp] == 367; - } - } - } + if (uniqindex == 3) { + xp = 2 * setpc_x + 24; + yp = 2 * setpc_y + 28; + } + if (uniqindex == 8) { + xp = 2 * setpc_x + 22; + yp = 2 * setpc_y + 23; + } + if (uniqindex == 2) { + BOOL zharflag = TRUE; + for (int i = 0; i < themeCount; i++) { + if (i == zharlib && zharflag == TRUE) { + zharflag = FALSE; + xp = 2 * themeLoc[i].x + 20; + yp = 2 * themeLoc[i].y + 20; + } + } + } + if (gbMaxPlayers == 1) { + if (uniqindex == 4) { + xp = 32; + yp = 46; + } + if (uniqindex == 5) { + xp = 40; + yp = 45; + } + if (uniqindex == 6) { + xp = 38; + yp = 49; + } + if (uniqindex == 1) { + xp = 35; + yp = 47; + } + } else { + if (uniqindex == 4) { + xp = 2 * setpc_x + 19; + yp = 2 * setpc_y + 22; + } + if (uniqindex == 5) { + xp = 2 * setpc_x + 21; + yp = 2 * setpc_y + 19; + } + if (uniqindex == 6) { + xp = 2 * setpc_x + 21; + yp = 2 * setpc_y + 25; + } + } + if (uniqindex == 9) { + BOOL done = FALSE; + for (yp = 0; yp < 112 && !done; yp++) { + for (xp = 0; xp < 112 && !done; xp++) { + done = dPiece[xp][yp] == 367; + } + } + } - PlaceMonster(nummonsters, uniqtype, xp, yp); - Monst->_uniqtype = uniqindex + 1; + PlaceMonster(nummonsters, uniqtype, xp, yp); + Monst->_uniqtype = uniqindex + 1; - if (Uniq->mlevel) { - Monst->mLevel = 2 * Uniq->mlevel; - } else { - Monst->mLevel += 5; - } + if (Uniq->mlevel) { + Monst->mLevel = 2 * Uniq->mlevel; + } else { + Monst->mLevel += 5; + } - Monst->mExp *= 2; - Monst->mName = Uniq->mName; - Monst->_mmaxhp = Uniq->mmaxhp << 6; + Monst->mExp *= 2; + Monst->mName = Uniq->mName; + Monst->_mmaxhp = Uniq->mmaxhp << 6; - if (gbMaxPlayers == 1) { - Monst->_mmaxhp = Monst->_mmaxhp >> 1; - if (Monst->_mmaxhp < 64) { - Monst->_mmaxhp = 64; - } - } + if (gbMaxPlayers == 1) { + Monst->_mmaxhp = Monst->_mmaxhp >> 1; + if (Monst->_mmaxhp < 64) { + Monst->_mmaxhp = 64; + } + } - Monst->_mhitpoints = Monst->_mmaxhp; - Monst->_mAi = Uniq->mAi; - Monst->_mint = Uniq->mint; - Monst->mMinDamage = Uniq->mMinDamage; - Monst->mMaxDamage = Uniq->mMaxDamage; - Monst->mMinDamage2 = Uniq->mMinDamage; - Monst->mMaxDamage2 = Uniq->mMaxDamage; - Monst->mMagicRes = Uniq->mMagicRes; - Monst->mtalkmsg = Uniq->mtalkmsg; - Monst->mlid = AddLight(Monst->_mx, Monst->_my, 3); + Monst->_mhitpoints = Monst->_mmaxhp; + Monst->_mAi = Uniq->mAi; + Monst->_mint = Uniq->mint; + Monst->mMinDamage = Uniq->mMinDamage; + Monst->mMaxDamage = Uniq->mMaxDamage; + Monst->mMinDamage2 = Uniq->mMinDamage; + Monst->mMaxDamage2 = Uniq->mMaxDamage; + Monst->mMagicRes = Uniq->mMagicRes; + Monst->mtalkmsg = Uniq->mtalkmsg; + Monst->mlid = AddLight(Monst->_mx, Monst->_my, 3); - if (gbMaxPlayers == 1) { - if (Monst->mtalkmsg) { - Monst->_mgoal = 6; - } - } else { - if (Monst->_mAi == AI_LAZHELP) { - Monst->mtalkmsg = 0; - } + if (gbMaxPlayers == 1) { + if (Monst->mtalkmsg) { + Monst->_mgoal = 6; + } + } else { + if (Monst->_mAi == AI_LAZHELP) { + Monst->mtalkmsg = 0; + } - if (Monst->_mAi != AI_LAZURUS || quests[QTYPE_VB]._qvar1 <= 3) { - if (Monst->mtalkmsg) { - Monst->_mgoal = 6; - } - } else { - Monst->_mgoal = 1; - } - } + if (Monst->_mAi != AI_LAZURUS || quests[QTYPE_VB]._qvar1 <= 3) { + if (Monst->mtalkmsg) { + Monst->_mgoal = 6; + } + } else { + Monst->_mgoal = 1; + } + } - if (gnDifficulty == DIFF_NIGHTMARE) { - Monst->mLevel += 15; - Monst->_mmaxhp = 3 * Monst->_mmaxhp + 64; - Monst->_mhitpoints = Monst->_mmaxhp; - Monst->mExp = 2 * (Monst->mExp + 1000); - Monst->mMinDamage = 2 * (Monst->mMinDamage + 2); - Monst->mMaxDamage = 2 * (Monst->mMaxDamage + 2); - Monst->mMinDamage2 = 2 * (Monst->mMinDamage2 + 2); - Monst->mMaxDamage2 = 2 * (Monst->mMaxDamage2 + 2); - } + if (gnDifficulty == DIFF_NIGHTMARE) { + Monst->mLevel += 15; + Monst->_mmaxhp = 3 * Monst->_mmaxhp + 64; + Monst->_mhitpoints = Monst->_mmaxhp; + Monst->mExp = 2 * (Monst->mExp + 1000); + Monst->mMinDamage = 2 * (Monst->mMinDamage + 2); + Monst->mMaxDamage = 2 * (Monst->mMaxDamage + 2); + Monst->mMinDamage2 = 2 * (Monst->mMinDamage2 + 2); + Monst->mMaxDamage2 = 2 * (Monst->mMaxDamage2 + 2); + } - if (gnDifficulty == DIFF_HELL) { - Monst->mLevel += 30; - Monst->_mmaxhp = 4 * Monst->_mmaxhp + 192; - Monst->_mhitpoints = Monst->_mmaxhp; - Monst->mExp = 4 * (Monst->mExp + 1000); - Monst->mMinDamage = 4 * Monst->mMinDamage + 6; - Monst->mMaxDamage = 4 * Monst->mMaxDamage + 6; - Monst->mMinDamage2 = 4 * Monst->mMinDamage2 + 6; - Monst->mMaxDamage2 = 4 * Monst->mMaxDamage2 + 6; - } + if (gnDifficulty == DIFF_HELL) { + Monst->mLevel += 30; + Monst->_mmaxhp = 4 * Monst->_mmaxhp + 192; + Monst->_mhitpoints = Monst->_mmaxhp; + Monst->mExp = 4 * (Monst->mExp + 1000); + Monst->mMinDamage = 4 * Monst->mMinDamage + 6; + Monst->mMaxDamage = 4 * Monst->mMaxDamage + 6; + Monst->mMinDamage2 = 4 * Monst->mMinDamage2 + 6; + Monst->mMaxDamage2 = 4 * Monst->mMaxDamage2 + 6; + } - sprintf(filestr, "Monsters\\Monsters\\%s.TRN", Uniq->mMode); - LoadFileWithMem(filestr, &pLightTbl[256 * (uniquetrans + 19)]); + sprintf(filestr, "Monsters\\Monsters\\%s.TRN", Uniq->mMode); + LoadFileWithMem(filestr, &pLightTbl[256 * (uniquetrans + 19)]); - Monst->_uniqtrans = uniquetrans++; + Monst->_uniqtrans = uniquetrans++; - if (Uniq->mUnqAttr & 4) { - Monst->mHit = Uniq->mUnqVar1; - Monst->mHit2 = Uniq->mUnqVar1; - } - if (Uniq->mUnqAttr & 8) { - Monst->mArmorClass = Uniq->mUnqVar1; - } + if (Uniq->mUnqAttr & 4) { + Monst->mHit = Uniq->mUnqVar1; + Monst->mHit2 = Uniq->mUnqVar1; + } + if (Uniq->mUnqAttr & 8) { + Monst->mArmorClass = Uniq->mUnqVar1; + } - nummonsters++; + nummonsters++; - if (Uniq->mUnqAttr & 1) { - PlaceGroup(miniontype, unpackfilesize, Uniq->mUnqAttr, nummonsters - 1); - } + if (Uniq->mUnqAttr & 1) { + PlaceGroup(miniontype, unpackfilesize, Uniq->mUnqAttr, nummonsters - 1); + } - if (Monst->_mAi != AI_GARG) { - Monst->_mAnimData = Monst->MType->Anims[MA_STAND].Data[Monst->_mdir]; - Monst->_mAnimFrame = random(88, Monst->_mAnimLen - 1) + 1; - Monst->_mFlags &= 0xFFFFFFFB; - Monst->_mmode = MM_STAND; - } + if (Monst->_mAi != AI_GARG) { + Monst->_mAnimData = Monst->MType->Anims[MA_STAND].Data[Monst->_mdir]; + Monst->_mAnimFrame = random(88, Monst->_mAnimLen - 1) + 1; + Monst->_mFlags &= 0xFFFFFFFB; + Monst->_mmode = MM_STAND; + } } void __cdecl PlaceQuestMonsters() { - int skeltype; - unsigned char *setp; + int skeltype; + unsigned char *setp; - if (!setlevel) { - if (QuestStatus(QTYPE_BUTCH)) { - PlaceUniqueMonst(9, 0, 0); - } + if (!setlevel) { + if (QuestStatus(QTYPE_BUTCH)) { + PlaceUniqueMonst(9, 0, 0); + } - if (currlevel == quests[QTYPE_KING]._qlevel && gbMaxPlayers != 1) { - skeltype = 0; + if (currlevel == quests[QTYPE_KING]._qlevel && gbMaxPlayers != 1) { + skeltype = 0; - for (skeltype = 0; skeltype < nummtypes; skeltype++) { - if (IsSkel(Monsters[skeltype].mtype)) { - break; - } - } + for (skeltype = 0; skeltype < nummtypes; skeltype++) { + if (IsSkel(Monsters[skeltype].mtype)) { + break; + } + } - PlaceUniqueMonst(1, skeltype, 30); - } + PlaceUniqueMonst(1, skeltype, 30); + } - if (QuestStatus(QTYPE_BOL)) { - setp = LoadFileInMem("Levels\\L1Data\\Banner1.DUN", 0); - SetMapMonsters(setp, 2 * setpc_x, 2 * setpc_y); - mem_free_dbg(setp); - } - if (QuestStatus(QTYPE_BLOOD)) { - setp = LoadFileInMem("Levels\\L2Data\\Blood2.DUN", 0); - SetMapMonsters(setp, 2 * setpc_x, 2 * setpc_y); - mem_free_dbg(setp); - } - if (QuestStatus(QTYPE_BLIND)) { - setp = LoadFileInMem("Levels\\L2Data\\Blind2.DUN", 0); - SetMapMonsters(setp, 2 * setpc_x, 2 * setpc_y); - mem_free_dbg(setp); - } - if (QuestStatus(QTYPE_ANVIL)) { - setp = LoadFileInMem("Levels\\L3Data\\Anvil.DUN", 0); - SetMapMonsters(setp, 2 * setpc_x + 2, 2 * setpc_y + 2); - mem_free_dbg(setp); - } - if (QuestStatus(QTYPE_WARLRD)) { - setp = LoadFileInMem("Levels\\L4Data\\Warlord.DUN", 0); - SetMapMonsters(setp, 2 * setpc_x, 2 * setpc_y); - mem_free_dbg(setp); - AddMonsterType(UniqMonst[8].mtype, 1); - } - if (QuestStatus(QTYPE_VEIL)) { - AddMonsterType(UniqMonst[7].mtype, 1); - } - if (QuestStatus(QTYPE_ZHAR) && zharlib == -1) { - quests[QTYPE_ZHAR]._qactive = 0; - } + if (QuestStatus(QTYPE_BOL)) { + setp = LoadFileInMem("Levels\\L1Data\\Banner1.DUN", 0); + SetMapMonsters(setp, 2 * setpc_x, 2 * setpc_y); + mem_free_dbg(setp); + } + if (QuestStatus(QTYPE_BLOOD)) { + setp = LoadFileInMem("Levels\\L2Data\\Blood2.DUN", 0); + SetMapMonsters(setp, 2 * setpc_x, 2 * setpc_y); + mem_free_dbg(setp); + } + if (QuestStatus(QTYPE_BLIND)) { + setp = LoadFileInMem("Levels\\L2Data\\Blind2.DUN", 0); + SetMapMonsters(setp, 2 * setpc_x, 2 * setpc_y); + mem_free_dbg(setp); + } + if (QuestStatus(QTYPE_ANVIL)) { + setp = LoadFileInMem("Levels\\L3Data\\Anvil.DUN", 0); + SetMapMonsters(setp, 2 * setpc_x + 2, 2 * setpc_y + 2); + mem_free_dbg(setp); + } + if (QuestStatus(QTYPE_WARLRD)) { + setp = LoadFileInMem("Levels\\L4Data\\Warlord.DUN", 0); + SetMapMonsters(setp, 2 * setpc_x, 2 * setpc_y); + mem_free_dbg(setp); + AddMonsterType(UniqMonst[8].mtype, 1); + } + if (QuestStatus(QTYPE_VEIL)) { + AddMonsterType(UniqMonst[7].mtype, 1); + } + if (QuestStatus(QTYPE_ZHAR) && zharlib == -1) { + quests[QTYPE_ZHAR]._qactive = 0; + } - if (currlevel == quests[QTYPE_VB]._qlevel && gbMaxPlayers != 1) { - AddMonsterType(UniqMonst[4].mtype, 4); - AddMonsterType(UniqMonst[5].mtype, 4); - PlaceUniqueMonst(4, 0, 0); - PlaceUniqueMonst(5, 0, 0); - PlaceUniqueMonst(6, 0, 0); - setp = LoadFileInMem("Levels\\L4Data\\Vile1.DUN", 0); - SetMapMonsters(setp, 2 * setpc_x, 2 * setpc_y); - mem_free_dbg(setp); - } - } else { - if (setlvlnum == SL_SKELKING) { - PlaceUniqueMonst(1, 0, 0); - } - } + if (currlevel == quests[QTYPE_VB]._qlevel && gbMaxPlayers != 1) { + AddMonsterType(UniqMonst[4].mtype, 4); + AddMonsterType(UniqMonst[5].mtype, 4); + PlaceUniqueMonst(4, 0, 0); + PlaceUniqueMonst(5, 0, 0); + PlaceUniqueMonst(6, 0, 0); + setp = LoadFileInMem("Levels\\L4Data\\Vile1.DUN", 0); + SetMapMonsters(setp, 2 * setpc_x, 2 * setpc_y); + mem_free_dbg(setp); + } + } else { + if (setlvlnum == SL_SKELKING) { + PlaceUniqueMonst(1, 0, 0); + } + } } void __fastcall PlaceGroup(int mtype, int num, int leaderf, int leader) { - int placed = 0; - int xp; - int yp; - int x1; - int y1; + int placed = 0; + int xp; + int yp; + int x1; + int y1; - for (int try1 = 0; try1 < 10; try1++) { - while (placed) { - nummonsters--; - placed--; - dMonster[monster[nummonsters]._mx][monster[nummonsters]._my] = 0; - } + for (int try1 = 0; try1 < 10; try1++) { + while (placed) { + nummonsters--; + placed--; + dMonster[monster[nummonsters]._mx][monster[nummonsters]._my] = 0; + } - if (leaderf & 1) { - int offset = random(92, 8); - xp = monster[leader]._mx + offset_x[offset]; - yp = monster[leader]._my + offset_y[offset]; - x1 = xp; - y1 = yp; - } else { - do { - xp = random(93, 80) + 16; - x1 = xp; - yp = random(93, 80) + 16; - y1 = yp; - } while (!MonstPlace(xp, yp)); - } + if (leaderf & 1) { + int offset = random(92, 8); + xp = monster[leader]._mx + offset_x[offset]; + yp = monster[leader]._my + offset_y[offset]; + x1 = xp; + y1 = yp; + } else { + do { + xp = random(93, 80) + 16; + x1 = xp; + yp = random(93, 80) + 16; + y1 = yp; + } while (!MonstPlace(xp, yp)); + } - if (num + nummonsters > totalmonsters) { - num = totalmonsters - nummonsters; - } + if (num + nummonsters > totalmonsters) { + num = totalmonsters - nummonsters; + } - int j = 0; - for (int try2 = 0; j < num && try2 < 100; xp += offset_x[random(94, 8)], yp += offset_x[random(94, 8)]) { - if (!MonstPlace(xp, yp) - || (dung_map[x1][y1] != dung_map[xp][yp]) - || (leaderf & 2) && ((abs(xp - x1) >= 4) || (abs(yp - y1) >= 4))) { - try2++; - continue; - } + int j = 0; + for (int try2 = 0; j < num && try2 < 100; xp += offset_x[random(94, 8)], yp += offset_x[random(94, 8)]) { + if (!MonstPlace(xp, yp) + || (dung_map[x1][y1] != dung_map[xp][yp]) + || (leaderf & 2) && ((abs(xp - x1) >= 4) || (abs(yp - y1) >= 4))) { + try2++; + continue; + } - PlaceMonster(nummonsters, mtype, xp, yp); - if (leaderf & 1) { - monster[nummonsters]._mmaxhp *= 2; - monster[nummonsters]._mhitpoints = monster[nummonsters]._mmaxhp; - monster[nummonsters]._mint = monster[leader]._mint; + PlaceMonster(nummonsters, mtype, xp, yp); + if (leaderf & 1) { + monster[nummonsters]._mmaxhp *= 2; + monster[nummonsters]._mhitpoints = monster[nummonsters]._mmaxhp; + monster[nummonsters]._mint = monster[leader]._mint; - if (leaderf & 2) { - monster[nummonsters].leader = leader; - monster[nummonsters].leaderflag = 1; - monster[nummonsters]._mAi = monster[leader]._mAi; - } + if (leaderf & 2) { + monster[nummonsters].leader = leader; + monster[nummonsters].leaderflag = 1; + monster[nummonsters]._mAi = monster[leader]._mAi; + } - if (monster[nummonsters]._mAi != AI_GARG) { - monster[nummonsters]._mAnimData = monster[nummonsters].MType->Anims[MA_STAND].Data[monster[nummonsters]._mdir]; - monster[nummonsters]._mAnimFrame = random(88, monster[nummonsters]._mAnimLen - 1) + 1; - monster[nummonsters]._mFlags &= 0xFFFFFFFB; - monster[nummonsters]._mmode = MM_STAND; - } - } - nummonsters++; - placed++; - j++; - } + if (monster[nummonsters]._mAi != AI_GARG) { + monster[nummonsters]._mAnimData = monster[nummonsters].MType->Anims[MA_STAND].Data[monster[nummonsters]._mdir]; + monster[nummonsters]._mAnimFrame = random(88, monster[nummonsters]._mAnimLen - 1) + 1; + monster[nummonsters]._mFlags &= 0xFFFFFFFB; + monster[nummonsters]._mmode = MM_STAND; + } + } + nummonsters++; + placed++; + j++; + } - if (placed >= num) { - break; - } - } + if (placed >= num) { + break; + } + } - if (leaderf & 2) { - monster[leader].unpackfilesize = placed; - } + if (leaderf & 2) { + monster[leader].unpackfilesize = placed; + } } void __cdecl LoadDiabMonsts() { - unsigned char *lpSetPiece; // esi + unsigned char *lpSetPiece; // esi - lpSetPiece = LoadFileInMem("Levels\\L4Data\\diab1.DUN", 0); - SetMapMonsters(lpSetPiece, 2 * diabquad1x, 2 * diabquad1y); - mem_free_dbg(lpSetPiece); - lpSetPiece = LoadFileInMem("Levels\\L4Data\\diab2a.DUN", 0); - SetMapMonsters(lpSetPiece, 2 * diabquad2x, 2 * diabquad2y); - mem_free_dbg(lpSetPiece); - lpSetPiece = LoadFileInMem("Levels\\L4Data\\diab3a.DUN", 0); - SetMapMonsters(lpSetPiece, 2 * diabquad3x, 2 * diabquad3y); - mem_free_dbg(lpSetPiece); - lpSetPiece = LoadFileInMem("Levels\\L4Data\\diab4a.DUN", 0); - SetMapMonsters(lpSetPiece, 2 * diabquad4x, 2 * diabquad4y); - mem_free_dbg(lpSetPiece); + lpSetPiece = LoadFileInMem("Levels\\L4Data\\diab1.DUN", 0); + SetMapMonsters(lpSetPiece, 2 * diabquad1x, 2 * diabquad1y); + mem_free_dbg(lpSetPiece); + lpSetPiece = LoadFileInMem("Levels\\L4Data\\diab2a.DUN", 0); + SetMapMonsters(lpSetPiece, 2 * diabquad2x, 2 * diabquad2y); + mem_free_dbg(lpSetPiece); + lpSetPiece = LoadFileInMem("Levels\\L4Data\\diab3a.DUN", 0); + SetMapMonsters(lpSetPiece, 2 * diabquad3x, 2 * diabquad3y); + mem_free_dbg(lpSetPiece); + lpSetPiece = LoadFileInMem("Levels\\L4Data\\diab4a.DUN", 0); + SetMapMonsters(lpSetPiece, 2 * diabquad4x, 2 * diabquad4y); + mem_free_dbg(lpSetPiece); } // 5289C4: using guessed type int diabquad1x; // 5289C8: using guessed type int diabquad1y; void __cdecl InitMonsters() { - int v0; // ebp - int v1; // ebx - TriggerStruct *v2; // esi - signed int v3; // ebp - signed int v4; // edi - int v5; // edi - int v6; // esi - int v7; // eax - int v8; // ecx - int v9; // edx - int v10; // eax - int v11; // esi - unsigned char *v12; // edi - int v13; // ebx - int v15; // esi - int v17; // eax - int v18; // eax - int v19; // ebx - TriggerStruct *v20; // esi - signed int v21; // ebp - signed int v22; // edi - int max; // [esp+10h] [ebp-1C4h] - int v24; // [esp+14h] [ebp-1C0h] - int scattertypes[111]; // [esp+18h] [ebp-1BCh] + int v0; // ebp + int v1; // ebx + TriggerStruct *v2; // esi + signed int v3; // ebp + signed int v4; // edi + int v5; // edi + int v6; // esi + int v7; // eax + int v8; // ecx + int v9; // edx + int v10; // eax + int v11; // esi + unsigned char *v12; // edi + int v13; // ebx + int v15; // esi + int v17; // eax + int v18; // eax + int v19; // ebx + TriggerStruct *v20; // esi + signed int v21; // ebp + signed int v22; // edi + int max; // [esp+10h] [ebp-1C4h] + int v24; // [esp+14h] [ebp-1C0h] + int scattertypes[111]; // [esp+18h] [ebp-1BCh] - v0 = 0; - max = 0; - if (gbMaxPlayers != 1) - CheckDungeonClear(); - if (!setlevel) { - AddMonster(1, 0, 0, 0, 0); - AddMonster(1, 0, 0, 0, 0); - AddMonster(1, 0, 0, 0, 0); - AddMonster(1, 0, 0, 0, 0); - if (!setlevel && currlevel == 16) - LoadDiabMonsts(); - } - v24 = trigflag[4]; - if (currlevel == 15) - v24 = 1; - v1 = v24; - if (v24 > 0) { - v2 = trigs; - do { - v3 = -2; - do { - v4 = -2; - do - DoVision(v3 + v2->_tx, v4++ + v2->_ty, 15, 0, 0); - while (v4 < 2); - ++v3; - } while (v3 < 2); - ++v2; - --v1; - } while (v1); - v0 = 0; - } - PlaceQuestMonsters(); - if (!setlevel) { - PlaceUniques(); - v5 = 16; - do { - v6 = 16; - do { - if (!SolidLoc(v5, v6)) - ++v0; - ++v6; - } while (v6 < 96); - ++v5; - } while (v5 < 96); - v7 = v0 / 30; - if (gbMaxPlayers != 1) - v7 += v7 >> 1; - v8 = nummonsters; - if (nummonsters + v7 > 190) - v7 = 190 - nummonsters; - v9 = nummtypes; - v10 = nummonsters + v7; - v11 = 0; - totalmonsters = v10; - if (nummtypes > 0) { - v12 = &Monsters[0].mPlaceFlags; - do { - if (*v12 & 1) { - v13 = max++; - scattertypes[v13] = v11; - } - ++v11; - v12 += 328; - } while (v11 < v9); - } - if (v8 < v10) { - while (1) { - v15 = scattertypes[random(95, max)]; - if (currlevel == 1) - break; - if (!random(95, 2)) - break; - if (currlevel == 2) { - v17 = random(95, 2) + 1; - LABEL_40: - v18 = v17 + 1; - goto LABEL_41; - } - v18 = random(95, 3) + 3; - LABEL_41: - PlaceGroup(v15, v18, 0, 0); - if (nummonsters >= totalmonsters) - goto LABEL_42; - } - v17 = 0; - goto LABEL_40; - } - } + v0 = 0; + max = 0; + if (gbMaxPlayers != 1) + CheckDungeonClear(); + if (!setlevel) { + AddMonster(1, 0, 0, 0, 0); + AddMonster(1, 0, 0, 0, 0); + AddMonster(1, 0, 0, 0, 0); + AddMonster(1, 0, 0, 0, 0); + if (!setlevel && currlevel == 16) + LoadDiabMonsts(); + } + v24 = trigflag[4]; + if (currlevel == 15) + v24 = 1; + v1 = v24; + if (v24 > 0) { + v2 = trigs; + do { + v3 = -2; + do { + v4 = -2; + do + DoVision(v3 + v2->_tx, v4++ + v2->_ty, 15, 0, 0); + while (v4 < 2); + ++v3; + } while (v3 < 2); + ++v2; + --v1; + } while (v1); + v0 = 0; + } + PlaceQuestMonsters(); + if (!setlevel) { + PlaceUniques(); + v5 = 16; + do { + v6 = 16; + do { + if (!SolidLoc(v5, v6)) + ++v0; + ++v6; + } while (v6 < 96); + ++v5; + } while (v5 < 96); + v7 = v0 / 30; + if (gbMaxPlayers != 1) + v7 += v7 >> 1; + v8 = nummonsters; + if (nummonsters + v7 > 190) + v7 = 190 - nummonsters; + v9 = nummtypes; + v10 = nummonsters + v7; + v11 = 0; + totalmonsters = v10; + if (nummtypes > 0) { + v12 = &Monsters[0].mPlaceFlags; + do { + if (*v12 & 1) { + v13 = max++; + scattertypes[v13] = v11; + } + ++v11; + v12 += 328; + } while (v11 < v9); + } + if (v8 < v10) { + while (1) { + v15 = scattertypes[random(95, max)]; + if (currlevel == 1) + break; + if (!random(95, 2)) + break; + if (currlevel == 2) { + v17 = random(95, 2) + 1; + LABEL_40: + v18 = v17 + 1; + goto LABEL_41; + } + v18 = random(95, 3) + 3; + LABEL_41: + PlaceGroup(v15, v18, 0, 0); + if (nummonsters >= totalmonsters) + goto LABEL_42; + } + v17 = 0; + goto LABEL_40; + } + } LABEL_42: - v19 = v24; - if (v24 > 0) { - v20 = trigs; - do { - v21 = -2; - do { - v22 = -2; - do - DoUnVision(v21 + v20->_tx, v22++ + v20->_ty, 15); - while (v22 < 2); - ++v21; - } while (v21 < 2); - ++v20; - --v19; - } while (v19); - } + v19 = v24; + if (v24 > 0) { + v20 = trigs; + do { + v21 = -2; + do { + v22 = -2; + do + DoUnVision(v21 + v20->_tx, v22++ + v20->_ty, 15); + while (v22 < 2); + ++v21; + } while (v21 < 2); + ++v20; + --v19; + } while (v19); + } } // 5CF31D: using guessed type char setlevel; // 658550: using guessed type int totalmonsters; @@ -1319,1783 +1319,1783 @@ LABEL_42: void __cdecl PlaceUniques() { - int v0; // edi - int v1; // eax - UniqMonstStruct *v2; // ecx - int v3; // eax - int v4; // edx - CMonster *v5; // esi - int v6; // eax - int v7; // edx + int v0; // edi + int v1; // eax + UniqMonstStruct *v2; // ecx + int v3; // eax + int v4; // edx + CMonster *v5; // esi + int v6; // eax + int v7; // edx - v0 = 0; - if (UniqMonst[0].mtype != -1) { - v1 = 0; - v2 = UniqMonst; - while (UniqMonst[v1].mlevel != currlevel) { - LABEL_25: - v1 = ++v0; - v2 = &UniqMonst[v0]; - if (v2->mtype == -1) - return; - } - v3 = 0; - v4 = 0; - if (nummtypes > 0) { - v5 = Monsters; - do { - if (v3) - break; - v6 = -((char)v2->mtype != (unsigned char)v5->mtype); - ++v5; - v3 = v6 + 1; - ++v4; - } while (v4 < nummtypes); - } - v7 = v4 - 1; - if (!v0) { - if (quests[QTYPE_GARB]._qactive) - goto LABEL_23; - v3 = 0; - } - if (v0 == 2) { - if (quests[QTYPE_ZHAR]._qactive) - goto LABEL_23; - v3 = 0; - } - if (v0 == 3) { - if (quests[QTYPE_BOL]._qactive) - goto LABEL_23; - v3 = 0; - } - if (v0 != 7) { - LABEL_20: - if (v0 == 8 && !quests[QTYPE_WARLRD]._qactive) - v3 = 0; - goto LABEL_23; - } - if (!quests[QTYPE_VEIL]._qactive) { - v3 = 0; - goto LABEL_20; - } - LABEL_23: - if (v3) - PlaceUniqueMonst(v0, v7, 8); - goto LABEL_25; - } + v0 = 0; + if (UniqMonst[0].mtype != -1) { + v1 = 0; + v2 = UniqMonst; + while (UniqMonst[v1].mlevel != currlevel) { + LABEL_25: + v1 = ++v0; + v2 = &UniqMonst[v0]; + if (v2->mtype == -1) + return; + } + v3 = 0; + v4 = 0; + if (nummtypes > 0) { + v5 = Monsters; + do { + if (v3) + break; + v6 = -((char)v2->mtype != (unsigned char)v5->mtype); + ++v5; + v3 = v6 + 1; + ++v4; + } while (v4 < nummtypes); + } + v7 = v4 - 1; + if (!v0) { + if (quests[QTYPE_GARB]._qactive) + goto LABEL_23; + v3 = 0; + } + if (v0 == 2) { + if (quests[QTYPE_ZHAR]._qactive) + goto LABEL_23; + v3 = 0; + } + if (v0 == 3) { + if (quests[QTYPE_BOL]._qactive) + goto LABEL_23; + v3 = 0; + } + if (v0 != 7) { + LABEL_20: + if (v0 == 8 && !quests[QTYPE_WARLRD]._qactive) + v3 = 0; + goto LABEL_23; + } + if (!quests[QTYPE_VEIL]._qactive) { + v3 = 0; + goto LABEL_20; + } + LABEL_23: + if (v3) + PlaceUniqueMonst(v0, v7, 8); + goto LABEL_25; + } } void __fastcall SetMapMonsters(unsigned char *pMap, int startx, int starty) { - unsigned char *v3; // esi - unsigned short v4; // cx - int v5; // edx - int v6; // edi - int v7; // ecx - unsigned char *v8; // edx - int i; // esi - int v10; // eax - int v11; // ecx - int v12; // [esp+Ch] [ebp-Ch] - int v13; // [esp+10h] [ebp-8h] - unsigned char *v14; // [esp+14h] [ebp-4h] - int startya; // [esp+20h] [ebp+8h] + unsigned char *v3; // esi + unsigned short v4; // cx + int v5; // edx + int v6; // edi + int v7; // ecx + unsigned char *v8; // edx + int i; // esi + int v10; // eax + int v11; // ecx + int v12; // [esp+Ch] [ebp-Ch] + int v13; // [esp+10h] [ebp-8h] + unsigned char *v14; // [esp+14h] [ebp-4h] + int startya; // [esp+20h] [ebp+8h] - v12 = startx; - v3 = pMap; - AddMonsterType(MT_GOLEM, 2); - AddMonster(1, 0, 0, 0, 0); - AddMonster(1, 0, 0, 0, 0); - AddMonster(1, 0, 0, 0, 0); - AddMonster(1, 0, 0, 0, 0); - if (setlevel && setlvlnum == SL_VILEBETRAYER) { - AddMonsterType((char)UniqMonst[4].mtype, 4); - AddMonsterType((char)UniqMonst[5].mtype, 4); - AddMonsterType((char)UniqMonst[6].mtype, 4); - PlaceUniqueMonst(4, 0, 0); - PlaceUniqueMonst(5, 0, 0); - PlaceUniqueMonst(6, 0, 0); - } - v4 = *((_WORD *)v3 + 1); - v5 = *(unsigned short *)v3 * v4; - v6 = (unsigned short)(2 * *(_WORD *)v3); - v7 = (unsigned short)(2 * v4); - v8 = &v3[2 * v5 + 4 + 2 * v7 * v6]; - v14 = v8; - if (v7 > 0) { - v13 = v7; - startya = starty + 16; - do { - for (i = 0; i < v6; v14 += 2) { - if (*(_WORD *)v8) { - v10 = AddMonsterType(MonstConvTbl[*(unsigned short *)v8 - 1], 2); /* fix */ - v11 = nummonsters++; - PlaceMonster(v11, v10, i + v12 + 16, startya); - } - v8 = v14 + 2; - ++i; - } - ++startya; - --v13; - } while (v13); - } + v12 = startx; + v3 = pMap; + AddMonsterType(MT_GOLEM, 2); + AddMonster(1, 0, 0, 0, 0); + AddMonster(1, 0, 0, 0, 0); + AddMonster(1, 0, 0, 0, 0); + AddMonster(1, 0, 0, 0, 0); + if (setlevel && setlvlnum == SL_VILEBETRAYER) { + AddMonsterType((char)UniqMonst[4].mtype, 4); + AddMonsterType((char)UniqMonst[5].mtype, 4); + AddMonsterType((char)UniqMonst[6].mtype, 4); + PlaceUniqueMonst(4, 0, 0); + PlaceUniqueMonst(5, 0, 0); + PlaceUniqueMonst(6, 0, 0); + } + v4 = *((_WORD *)v3 + 1); + v5 = *(unsigned short *)v3 * v4; + v6 = (unsigned short)(2 * *(_WORD *)v3); + v7 = (unsigned short)(2 * v4); + v8 = &v3[2 * v5 + 4 + 2 * v7 * v6]; + v14 = v8; + if (v7 > 0) { + v13 = v7; + startya = starty + 16; + do { + for (i = 0; i < v6; v14 += 2) { + if (*(_WORD *)v8) { + v10 = AddMonsterType(MonstConvTbl[*(unsigned short *)v8 - 1], 2); /* fix */ + v11 = nummonsters++; + PlaceMonster(v11, v10, i + v12 + 16, startya); + } + v8 = v14 + 2; + ++i; + } + ++startya; + --v13; + } while (v13); + } } // 5CF31D: using guessed type char setlevel; void __fastcall DeleteMonster(int i) { - nummonsters--; - int temp = monstactive[nummonsters]; - monstactive[nummonsters] = monstactive[i]; - monstactive[i] = temp; + nummonsters--; + int temp = monstactive[nummonsters]; + monstactive[nummonsters] = monstactive[i]; + monstactive[i] = temp; } int __fastcall AddMonster(int x, int y, int dir, int mtype, int InMap) { - if (nummonsters < MAXMONSTERS) { - int i = monstactive[nummonsters++]; - if (InMap) - dMonster[x][y] = i + 1; - InitMonster(i, dir, mtype, x, y); - return i; - } + if (nummonsters < MAXMONSTERS) { + int i = monstactive[nummonsters++]; + if (InMap) + dMonster[x][y] = i + 1; + InitMonster(i, dir, mtype, x, y); + return i; + } - return -1; + return -1; } void __fastcall NewMonsterAnim(int i, AnimStruct *anim, int md) { - monster[i]._mAnimData = anim->Data[md]; - monster[i]._mAnimCnt = 0; - monster[i]._mAnimLen = anim->Frames; - monster[i]._mAnimFrame = 1; - monster[i]._mFlags &= 0xFFFFFFF9; - monster[i]._mAnimDelay = anim->Rate; - monster[i]._mdir = md; + monster[i]._mAnimData = anim->Data[md]; + monster[i]._mAnimCnt = 0; + monster[i]._mAnimLen = anim->Frames; + monster[i]._mAnimFrame = 1; + monster[i]._mFlags &= 0xFFFFFFF9; + monster[i]._mAnimDelay = anim->Rate; + monster[i]._mdir = md; } BOOL __fastcall M_Ranged(int i) { - char ai = monster[i]._mAi; - return ai == AI_SKELBOW || ai == AI_GOATBOW || ai == AI_SUCC || ai == AI_LAZHELP; + char ai = monster[i]._mAi; + return ai == AI_SKELBOW || ai == AI_GOATBOW || ai == AI_SUCC || ai == AI_LAZHELP; } BOOL __fastcall M_Talker(int i) { - char ai = monster[i]._mAi; - return ai == AI_LAZURUS - || ai == AI_WARLORD - || ai == AI_GARBUD - || ai == AI_ZHAR - || ai == AI_SNOTSPIL - || ai == AI_LACHDAN - || ai == AI_LAZHELP; + char ai = monster[i]._mAi; + return ai == AI_LAZURUS + || ai == AI_WARLORD + || ai == AI_GARBUD + || ai == AI_ZHAR + || ai == AI_SNOTSPIL + || ai == AI_LACHDAN + || ai == AI_LAZHELP; } void __fastcall M_Enemy(int i) { - MonsterStruct *v1; // esi - int *v2; // edi - int v3; // eax - int v4; // ecx - int v5; // ebx - int v6; // eax - int v7; // eax - int v8; // eax - int v9; // ecx - int v10; // edi - //int v11; // edx - int v12; // eax - int v13; // ecx - int v14; // ebx - int v15; // eax - int v16; // eax - int v17; // [esp+Ch] [ebp-20h] - int v18; // [esp+10h] [ebp-1Ch] - BOOL v19; // [esp+14h] [ebp-18h] - BOOL v20; // [esp+14h] [ebp-18h] - signed int v21; // [esp+18h] [ebp-14h] - int j; // [esp+18h] [ebp-14h] - signed int v23; // [esp+1Ch] [ebp-10h] - signed int v24; // [esp+20h] [ebp-Ch] - BOOL v25; // [esp+24h] [ebp-8h] - char v26; // [esp+2Ah] [ebp-2h] - char v27; // [esp+2Bh] [ebp-1h] + MonsterStruct *v1; // esi + int *v2; // edi + int v3; // eax + int v4; // ecx + int v5; // ebx + int v6; // eax + int v7; // eax + int v8; // eax + int v9; // ecx + int v10; // edi + //int v11; // edx + int v12; // eax + int v13; // ecx + int v14; // ebx + int v15; // eax + int v16; // eax + int v17; // [esp+Ch] [ebp-20h] + int v18; // [esp+10h] [ebp-1Ch] + BOOL v19; // [esp+14h] [ebp-18h] + BOOL v20; // [esp+14h] [ebp-18h] + signed int v21; // [esp+18h] [ebp-14h] + int j; // [esp+18h] [ebp-14h] + signed int v23; // [esp+1Ch] [ebp-10h] + signed int v24; // [esp+20h] [ebp-Ch] + BOOL v25; // [esp+24h] [ebp-8h] + char v26; // [esp+2Ah] [ebp-2h] + char v27; // [esp+2Bh] [ebp-1h] - v24 = -1; - v18 = i; - v23 = -1; - v1 = &monster[i]; - v25 = 0; - if (!(v1->_mFlags & 0x20)) { - v21 = 0; - v2 = &plr[0].plrlevel; - do { - if (!*((_BYTE *)v2 - 23) || currlevel != *v2 || *((_BYTE *)v2 + 267) || !v2[89] && gbMaxPlayers != 1) - goto LABEL_18; - v3 = v1->_my; - v4 = v2[2]; - v19 = dung_map[v2[1]][v4] == dung_map[v1->_mx][v3]; - v5 = abs(v3 - v4); - if (abs(v1->_mx - v2[1]) <= v5) - v6 = v1->_my - v2[2]; - else - v6 = v1->_mx - v2[1]; - v7 = abs(v6); - if (v19) { - if (!v25) - goto LABEL_17; - } else if (v25) { - goto LABEL_16; - } - if (v7 < v23) - goto LABEL_17; - LABEL_16: - if (v24 == -1) { - LABEL_17: - v1->_mFlags &= 0xFFFFFFEF; - v24 = v21; - v27 = *((_BYTE *)v2 + 12); - v26 = *((_BYTE *)v2 + 16); - v23 = v7; - v25 = v19; - } - LABEL_18: - ++v21; - v2 += 5430; - } while ((signed int)v2 < (signed int)&plr[4].plrlevel); - } - v8 = 0; - for (j = 0; j < nummonsters; v8 = j++ + 1) { - v9 = monstactive[v8]; - v17 = monstactive[v8]; - if (v9 == v18) - continue; - v10 = v9; - if (monster[v9]._mx == 1 && !monster[v10]._my) - continue; - if (M_Talker(v9) && monster[v10].mtalkmsg) - continue; - if (!(v1->_mFlags & 0x20) - && ((abs(monster[v10]._mx - v1->_mx) >= 2 || abs(monster[v10]._my - v1->_my) >= 2) && !M_Ranged(v18) /* v11 */ - || !(v1->_mFlags & 0x20) && !(monster[v10]._mFlags & 0x20))) { - continue; - } - v12 = v1->_my; - v13 = monster[v10]._my; - v20 = dung_map[monster[v10]._mx][v13] == dung_map[v1->_mx][v12]; - v14 = abs(v12 - v13); - if (abs(v1->_mx - monster[v10]._mx) <= v14) - v15 = v1->_my - monster[v10]._my; - else - v15 = v1->_mx - monster[v10]._mx; - v16 = abs(v15); - if (v20) { - if (!v25) - goto LABEL_40; - } else if (v25) { - goto LABEL_39; - } - if (v16 < v23) - goto LABEL_40; - LABEL_39: - if (v24 == -1) { - LABEL_40: - v1->_mFlags |= 0x10u; - v24 = v17; - v27 = monster[v10]._mfutx; - v26 = monster[v10]._mfuty; - v23 = v16; - v25 = v20; - } - } - if (v24 == -1) { - BYTE1(v1->_mFlags) |= 4u; - } else { - BYTE1(v1->_mFlags) &= 0xFBu; - v1->_menemy = v24; - v1->_menemyx = v27; - v1->_menemyy = v26; - } + v24 = -1; + v18 = i; + v23 = -1; + v1 = &monster[i]; + v25 = 0; + if (!(v1->_mFlags & 0x20)) { + v21 = 0; + v2 = &plr[0].plrlevel; + do { + if (!*((_BYTE *)v2 - 23) || currlevel != *v2 || *((_BYTE *)v2 + 267) || !v2[89] && gbMaxPlayers != 1) + goto LABEL_18; + v3 = v1->_my; + v4 = v2[2]; + v19 = dung_map[v2[1]][v4] == dung_map[v1->_mx][v3]; + v5 = abs(v3 - v4); + if (abs(v1->_mx - v2[1]) <= v5) + v6 = v1->_my - v2[2]; + else + v6 = v1->_mx - v2[1]; + v7 = abs(v6); + if (v19) { + if (!v25) + goto LABEL_17; + } else if (v25) { + goto LABEL_16; + } + if (v7 < v23) + goto LABEL_17; + LABEL_16: + if (v24 == -1) { + LABEL_17: + v1->_mFlags &= 0xFFFFFFEF; + v24 = v21; + v27 = *((_BYTE *)v2 + 12); + v26 = *((_BYTE *)v2 + 16); + v23 = v7; + v25 = v19; + } + LABEL_18: + ++v21; + v2 += 5430; + } while ((signed int)v2 < (signed int)&plr[4].plrlevel); + } + v8 = 0; + for (j = 0; j < nummonsters; v8 = j++ + 1) { + v9 = monstactive[v8]; + v17 = monstactive[v8]; + if (v9 == v18) + continue; + v10 = v9; + if (monster[v9]._mx == 1 && !monster[v10]._my) + continue; + if (M_Talker(v9) && monster[v10].mtalkmsg) + continue; + if (!(v1->_mFlags & 0x20) + && ((abs(monster[v10]._mx - v1->_mx) >= 2 || abs(monster[v10]._my - v1->_my) >= 2) && !M_Ranged(v18) /* v11 */ + || !(v1->_mFlags & 0x20) && !(monster[v10]._mFlags & 0x20))) { + continue; + } + v12 = v1->_my; + v13 = monster[v10]._my; + v20 = dung_map[monster[v10]._mx][v13] == dung_map[v1->_mx][v12]; + v14 = abs(v12 - v13); + if (abs(v1->_mx - monster[v10]._mx) <= v14) + v15 = v1->_my - monster[v10]._my; + else + v15 = v1->_mx - monster[v10]._mx; + v16 = abs(v15); + if (v20) { + if (!v25) + goto LABEL_40; + } else if (v25) { + goto LABEL_39; + } + if (v16 < v23) + goto LABEL_40; + LABEL_39: + if (v24 == -1) { + LABEL_40: + v1->_mFlags |= 0x10u; + v24 = v17; + v27 = monster[v10]._mfutx; + v26 = monster[v10]._mfuty; + v23 = v16; + v25 = v20; + } + } + if (v24 == -1) { + BYTE1(v1->_mFlags) |= 4u; + } else { + BYTE1(v1->_mFlags) &= 0xFBu; + v1->_menemy = v24; + v1->_menemyx = v27; + v1->_menemyy = v26; + } } // 679660: using guessed type char gbMaxPlayers; int __fastcall M_GetDir(int i) { - return GetDirection(monster[i]._mx, monster[i]._my, monster[i]._menemyx, monster[i]._menemyy); + return GetDirection(monster[i]._mx, monster[i]._my, monster[i]._menemyx, monster[i]._menemyy); } void __fastcall M_CheckEFlag(int i) { - int v1; // ecx - int v2; // edi - char *v3; // eax - signed int v4; // edx + int v1; // ecx + int v2; // edi + char *v3; // eax + signed int v4; // edx - v1 = i; - v2 = 0; - v3 = (char *)dpiece_defs_map_2 + 32 * (112 * (monster[v1]._mx - 1) + monster[v1]._my + 1); - if (v3 < (char *)dpiece_defs_map_2) - goto LABEL_9; - v4 = 2; - do - v2 |= *(unsigned short *)&v3[2 * v4++]; - while (v4 < 10); - if (v2 | dArch[monster[v1]._mx - 1][monster[v1]._my + 1]) - monster[v1]._meflag = 1; - else - LABEL_9: - monster[v1]._meflag = 0; + v1 = i; + v2 = 0; + v3 = (char *)dpiece_defs_map_2 + 32 * (112 * (monster[v1]._mx - 1) + monster[v1]._my + 1); + if (v3 < (char *)dpiece_defs_map_2) + goto LABEL_9; + v4 = 2; + do + v2 |= *(unsigned short *)&v3[2 * v4++]; + while (v4 < 10); + if (v2 | dArch[monster[v1]._mx - 1][monster[v1]._my + 1]) + monster[v1]._meflag = 1; + else + LABEL_9: + monster[v1]._meflag = 0; } void __fastcall M_StartStand(int i, int md) { - ClearMVars(i); - if (monster[i].MType->mtype == MT_GOLEM) - NewMonsterAnim(i, &monster[i].MType->Anims[MA_WALK], md); - else - NewMonsterAnim(i, &monster[i].MType->Anims[MA_STAND], md); - monster[i]._mVar1 = monster[i]._mmode; - monster[i]._mVar2 = 0; - monster[i]._mmode = MM_STAND; - monster[i]._mxoff = 0; - monster[i]._myoff = 0; - monster[i]._mfutx = monster[i]._mx; - monster[i]._mfuty = monster[i]._my; - monster[i]._moldx = monster[i]._mx; - monster[i]._moldy = monster[i]._my; - monster[i]._mdir = md; - M_CheckEFlag(i); - M_Enemy(i); + ClearMVars(i); + if (monster[i].MType->mtype == MT_GOLEM) + NewMonsterAnim(i, &monster[i].MType->Anims[MA_WALK], md); + else + NewMonsterAnim(i, &monster[i].MType->Anims[MA_STAND], md); + monster[i]._mVar1 = monster[i]._mmode; + monster[i]._mVar2 = 0; + monster[i]._mmode = MM_STAND; + monster[i]._mxoff = 0; + monster[i]._myoff = 0; + monster[i]._mfutx = monster[i]._mx; + monster[i]._mfuty = monster[i]._my; + monster[i]._moldx = monster[i]._mx; + monster[i]._moldy = monster[i]._my; + monster[i]._mdir = md; + M_CheckEFlag(i); + M_Enemy(i); } void __fastcall M_StartDelay(int i, int len) { - if (len <= 0) { - return; - } + if (len <= 0) { + return; + } - if (monster[i]._mAi != AI_LAZURUS) { - monster[i]._mVar2 = len; - monster[i]._mmode = MM_DELAY; - } + if (monster[i]._mAi != AI_LAZURUS) { + monster[i]._mVar2 = len; + monster[i]._mmode = MM_DELAY; + } } void __fastcall M_StartSpStand(int i, int md) { - NewMonsterAnim(i, &monster[i].MType->Anims[MA_SPECIAL], md); - monster[i]._mmode = MM_SPSTAND; - monster[i]._mxoff = 0; - monster[i]._myoff = 0; - monster[i]._mfutx = monster[i]._mx; - monster[i]._mfuty = monster[i]._my; - monster[i]._moldx = monster[i]._mx; - monster[i]._moldy = monster[i]._my; - monster[i]._mdir = md; - M_CheckEFlag(i); + NewMonsterAnim(i, &monster[i].MType->Anims[MA_SPECIAL], md); + monster[i]._mmode = MM_SPSTAND; + monster[i]._mxoff = 0; + monster[i]._myoff = 0; + monster[i]._mfutx = monster[i]._mx; + monster[i]._mfuty = monster[i]._my; + monster[i]._moldx = monster[i]._mx; + monster[i]._moldy = monster[i]._my; + monster[i]._mdir = md; + M_CheckEFlag(i); } void __fastcall M_StartWalk(int i, int xvel, int yvel, int xadd, int yadd, int EndDir) { - int fx = xadd + monster[i]._mx; - int fy = yadd + monster[i]._my; + int fx = xadd + monster[i]._mx; + int fy = yadd + monster[i]._my; - dMonster[fx][fy] = -(i + 1); - monster[i]._mmode = MM_WALK; - monster[i]._moldx = monster[i]._mx; - monster[i]._moldy = monster[i]._my; - monster[i]._mfutx = fx; - monster[i]._mfuty = fy; - monster[i]._mxvel = xvel; - monster[i]._myvel = yvel; - monster[i]._mVar1 = xadd; - monster[i]._mVar2 = yadd; - monster[i]._mVar3 = EndDir; - monster[i]._mdir = EndDir; - NewMonsterAnim(i, &monster[i].MType->Anims[MA_WALK], EndDir); - monster[i]._mVar6 = 0; - monster[i]._mVar7 = 0; - monster[i]._mVar8 = 0; - M_CheckEFlag(i); + dMonster[fx][fy] = -(i + 1); + monster[i]._mmode = MM_WALK; + monster[i]._moldx = monster[i]._mx; + monster[i]._moldy = monster[i]._my; + monster[i]._mfutx = fx; + monster[i]._mfuty = fy; + monster[i]._mxvel = xvel; + monster[i]._myvel = yvel; + monster[i]._mVar1 = xadd; + monster[i]._mVar2 = yadd; + monster[i]._mVar3 = EndDir; + monster[i]._mdir = EndDir; + NewMonsterAnim(i, &monster[i].MType->Anims[MA_WALK], EndDir); + monster[i]._mVar6 = 0; + monster[i]._mVar7 = 0; + monster[i]._mVar8 = 0; + M_CheckEFlag(i); } void __fastcall M_StartWalk2(int i, int xvel, int yvel, int xoff, int yoff, int xadd, int yadd, int EndDir) { - int fx = xadd + monster[i]._mx; - int fy = yadd + monster[i]._my; + int fx = xadd + monster[i]._mx; + int fy = yadd + monster[i]._my; - dMonster[monster[i]._mx][monster[i]._my] = -(i + 1); - monster[i]._mVar1 = monster[i]._mx; - monster[i]._mVar2 = monster[i]._my; - monster[i]._moldx = monster[i]._mx; - monster[i]._moldy = monster[i]._my; - monster[i]._mx = fx; - monster[i]._my = fy; - monster[i]._mfutx = fx; - monster[i]._mfuty = fy; - dMonster[fx][fy] = i + 1; - if (monster[i]._uniqtype != 0) - ChangeLightXY(monster[i].mlid, monster[i]._mx, monster[i]._my); - monster[i]._mxoff = xoff; - monster[i]._myoff = yoff; - monster[i]._mmode = MM_WALK2; - monster[i]._mxvel = xvel; - monster[i]._myvel = yvel; - monster[i]._mVar3 = EndDir; - monster[i]._mdir = EndDir; - NewMonsterAnim(i, &monster[i].MType->Anims[MA_WALK], EndDir); - monster[i]._mVar6 = 16 * xoff; - monster[i]._mVar7 = 16 * yoff; - monster[i]._mVar8 = 0; - M_CheckEFlag(i); + dMonster[monster[i]._mx][monster[i]._my] = -(i + 1); + monster[i]._mVar1 = monster[i]._mx; + monster[i]._mVar2 = monster[i]._my; + monster[i]._moldx = monster[i]._mx; + monster[i]._moldy = monster[i]._my; + monster[i]._mx = fx; + monster[i]._my = fy; + monster[i]._mfutx = fx; + monster[i]._mfuty = fy; + dMonster[fx][fy] = i + 1; + if (monster[i]._uniqtype != 0) + ChangeLightXY(monster[i].mlid, monster[i]._mx, monster[i]._my); + monster[i]._mxoff = xoff; + monster[i]._myoff = yoff; + monster[i]._mmode = MM_WALK2; + monster[i]._mxvel = xvel; + monster[i]._myvel = yvel; + monster[i]._mVar3 = EndDir; + monster[i]._mdir = EndDir; + NewMonsterAnim(i, &monster[i].MType->Anims[MA_WALK], EndDir); + monster[i]._mVar6 = 16 * xoff; + monster[i]._mVar7 = 16 * yoff; + monster[i]._mVar8 = 0; + M_CheckEFlag(i); } void __fastcall M_StartWalk3(int i, int xvel, int yvel, int xoff, int yoff, int xadd, int yadd, int mapx, int mapy, int EndDir) { - int fx = xadd + monster[i]._mx; - int fy = yadd + monster[i]._my; - int x = mapx + monster[i]._mx; - int y = mapy + monster[i]._my; + int fx = xadd + monster[i]._mx; + int fy = yadd + monster[i]._my; + int x = mapx + monster[i]._mx; + int y = mapy + monster[i]._my; - if (monster[i]._uniqtype != 0) - ChangeLightXY(monster[i].mlid, x, y); + if (monster[i]._uniqtype != 0) + ChangeLightXY(monster[i].mlid, x, y); - dMonster[monster[i]._mx][monster[i]._my] = -(i + 1); - dMonster[fx][fy] = -(i + 1); - monster[i]._mVar4 = x; - monster[i]._mVar5 = y; - dFlags[x][y] |= DFLAG_MONSTER; - monster[i]._moldx = monster[i]._mx; - monster[i]._moldy = monster[i]._my; - monster[i]._mfutx = fx; - monster[i]._mfuty = fy; - monster[i]._mxoff = xoff; - monster[i]._myoff = yoff; - monster[i]._mmode = MM_WALK3; - monster[i]._mxvel = xvel; - monster[i]._myvel = yvel; - monster[i]._mVar1 = fx; - monster[i]._mVar2 = fy; - monster[i]._mVar3 = EndDir; - monster[i]._mdir = EndDir; - NewMonsterAnim(i, &monster[i].MType->Anims[MA_WALK], EndDir); - monster[i]._mVar6 = 16 * xoff; - monster[i]._mVar7 = 16 * yoff; - monster[i]._mVar8 = 0; - M_CheckEFlag(i); + dMonster[monster[i]._mx][monster[i]._my] = -(i + 1); + dMonster[fx][fy] = -(i + 1); + monster[i]._mVar4 = x; + monster[i]._mVar5 = y; + dFlags[x][y] |= DFLAG_MONSTER; + monster[i]._moldx = monster[i]._mx; + monster[i]._moldy = monster[i]._my; + monster[i]._mfutx = fx; + monster[i]._mfuty = fy; + monster[i]._mxoff = xoff; + monster[i]._myoff = yoff; + monster[i]._mmode = MM_WALK3; + monster[i]._mxvel = xvel; + monster[i]._myvel = yvel; + monster[i]._mVar1 = fx; + monster[i]._mVar2 = fy; + monster[i]._mVar3 = EndDir; + monster[i]._mdir = EndDir; + NewMonsterAnim(i, &monster[i].MType->Anims[MA_WALK], EndDir); + monster[i]._mVar6 = 16 * xoff; + monster[i]._mVar7 = 16 * yoff; + monster[i]._mVar8 = 0; + M_CheckEFlag(i); } void __fastcall M_StartAttack(int i) { - int md = M_GetDir(i); - NewMonsterAnim(i, &monster[i].MType->Anims[MA_ATTACK], md); - monster[i]._mmode = MM_ATTACK; - monster[i]._mxoff = 0; - monster[i]._myoff = 0; - monster[i]._mfutx = monster[i]._mx; - monster[i]._mfuty = monster[i]._my; - monster[i]._moldx = monster[i]._mx; - monster[i]._moldy = monster[i]._my; - monster[i]._mdir = md; - M_CheckEFlag(i); + int md = M_GetDir(i); + NewMonsterAnim(i, &monster[i].MType->Anims[MA_ATTACK], md); + monster[i]._mmode = MM_ATTACK; + monster[i]._mxoff = 0; + monster[i]._myoff = 0; + monster[i]._mfutx = monster[i]._mx; + monster[i]._mfuty = monster[i]._my; + monster[i]._moldx = monster[i]._mx; + monster[i]._moldy = monster[i]._my; + monster[i]._mdir = md; + M_CheckEFlag(i); } void __fastcall M_StartRAttack(int i, int missile_type, int dam) { - int md = M_GetDir(i); - NewMonsterAnim(i, &monster[i].MType->Anims[MA_ATTACK], md); - monster[i]._mmode = MM_RATTACK; - monster[i]._mVar1 = missile_type; - monster[i]._mVar2 = dam; - monster[i]._mxoff = 0; - monster[i]._myoff = 0; - monster[i]._mfutx = monster[i]._mx; - monster[i]._mfuty = monster[i]._my; - monster[i]._moldx = monster[i]._mx; - monster[i]._moldy = monster[i]._my; - monster[i]._mdir = md; - M_CheckEFlag(i); + int md = M_GetDir(i); + NewMonsterAnim(i, &monster[i].MType->Anims[MA_ATTACK], md); + monster[i]._mmode = MM_RATTACK; + monster[i]._mVar1 = missile_type; + monster[i]._mVar2 = dam; + monster[i]._mxoff = 0; + monster[i]._myoff = 0; + monster[i]._mfutx = monster[i]._mx; + monster[i]._mfuty = monster[i]._my; + monster[i]._moldx = monster[i]._mx; + monster[i]._moldy = monster[i]._my; + monster[i]._mdir = md; + M_CheckEFlag(i); } void __fastcall M_StartRSpAttack(int i, int missile_type, int dam) { - int md = M_GetDir(i); - NewMonsterAnim(i, &monster[i].MType->Anims[MA_SPECIAL], md); - monster[i]._mmode = MM_RSPATTACK; - monster[i]._mVar1 = missile_type; - monster[i]._mVar2 = 0; - monster[i]._mVar3 = dam; - monster[i]._mxoff = 0; - monster[i]._myoff = 0; - monster[i]._mfutx = monster[i]._mx; - monster[i]._mfuty = monster[i]._my; - monster[i]._moldx = monster[i]._mx; - monster[i]._moldy = monster[i]._my; - monster[i]._mdir = md; - M_CheckEFlag(i); + int md = M_GetDir(i); + NewMonsterAnim(i, &monster[i].MType->Anims[MA_SPECIAL], md); + monster[i]._mmode = MM_RSPATTACK; + monster[i]._mVar1 = missile_type; + monster[i]._mVar2 = 0; + monster[i]._mVar3 = dam; + monster[i]._mxoff = 0; + monster[i]._myoff = 0; + monster[i]._mfutx = monster[i]._mx; + monster[i]._mfuty = monster[i]._my; + monster[i]._moldx = monster[i]._mx; + monster[i]._moldy = monster[i]._my; + monster[i]._mdir = md; + M_CheckEFlag(i); } void __fastcall M_StartSpAttack(int i) { - int md = M_GetDir(i); - NewMonsterAnim(i, &monster[i].MType->Anims[MA_SPECIAL], md); - monster[i]._mmode = MM_SATTACK; - monster[i]._mxoff = 0; - monster[i]._myoff = 0; - monster[i]._mfutx = monster[i]._mx; - monster[i]._mfuty = monster[i]._my; - monster[i]._moldx = monster[i]._mx; - monster[i]._moldy = monster[i]._my; - monster[i]._mdir = md; - M_CheckEFlag(i); + int md = M_GetDir(i); + NewMonsterAnim(i, &monster[i].MType->Anims[MA_SPECIAL], md); + monster[i]._mmode = MM_SATTACK; + monster[i]._mxoff = 0; + monster[i]._myoff = 0; + monster[i]._mfutx = monster[i]._mx; + monster[i]._mfuty = monster[i]._my; + monster[i]._moldx = monster[i]._mx; + monster[i]._moldy = monster[i]._my; + monster[i]._mdir = md; + M_CheckEFlag(i); } void __fastcall M_StartEat(int i) { - NewMonsterAnim(i, &monster[i].MType->Anims[MA_SPECIAL], monster[i]._mdir); - monster[i]._mmode = MM_SATTACK; - monster[i]._mxoff = 0; - monster[i]._myoff = 0; - monster[i]._mfutx = monster[i]._mx; - monster[i]._mfuty = monster[i]._my; - monster[i]._moldx = monster[i]._mx; - monster[i]._moldy = monster[i]._my; - M_CheckEFlag(i); + NewMonsterAnim(i, &monster[i].MType->Anims[MA_SPECIAL], monster[i]._mdir); + monster[i]._mmode = MM_SATTACK; + monster[i]._mxoff = 0; + monster[i]._myoff = 0; + monster[i]._mfutx = monster[i]._mx; + monster[i]._mfuty = monster[i]._my; + monster[i]._moldx = monster[i]._mx; + monster[i]._moldy = monster[i]._my; + M_CheckEFlag(i); } void __fastcall M_ClearSquares(int i) { - int mx = monster[i]._moldx; - int my = monster[i]._moldy; - int m1 = -1 - i; - int m2 = i + 1; + int mx = monster[i]._moldx; + int my = monster[i]._moldy; + int m1 = -1 - i; + int m2 = i + 1; - for (int y = my - 1; y <= my + 1; y++) { - if (y >= 0 && y < MAXDUNY) { - for (int x = mx - 1; x <= mx + 1; x++) { - if (x >= 0 && x < MAXDUNX && (dMonster[x][y] == m1 || dMonster[x][y] == m2)) - dMonster[x][y] = 0; - } - } - } + for (int y = my - 1; y <= my + 1; y++) { + if (y >= 0 && y < MAXDUNY) { + for (int x = mx - 1; x <= mx + 1; x++) { + if (x >= 0 && x < MAXDUNX && (dMonster[x][y] == m1 || dMonster[x][y] == m2)) + dMonster[x][y] = 0; + } + } + } - if (mx + 1 < MAXDUNX) - dFlags[mx + 1][my] &= ~DFLAG_MONSTER; - if (my + 1 < MAXDUNY) - dFlags[mx][my + 1] &= ~DFLAG_MONSTER; + if (mx + 1 < MAXDUNX) + dFlags[mx + 1][my] &= ~DFLAG_MONSTER; + if (my + 1 < MAXDUNY) + dFlags[mx][my + 1] &= ~DFLAG_MONSTER; } void __fastcall M_GetKnockback(int i) { - int d = (monster[i]._mdir - 4) & 7; - if (DirOK(i, d)) { - M_ClearSquares(i); - monster[i]._moldx += offset_x[d]; - monster[i]._moldy += offset_y[d]; - NewMonsterAnim(i, &monster[i].MType->Anims[MA_GOTHIT], monster[i]._mdir); - monster[i]._mmode = MM_GOTHIT; - monster[i]._mxoff = 0; - monster[i]._myoff = 0; - monster[i]._mx = monster[i]._moldx; - monster[i]._my = monster[i]._moldy; - monster[i]._mfutx = monster[i]._moldx; - monster[i]._mfuty = monster[i]._moldy; - M_CheckEFlag(i); - M_ClearSquares(i); - dMonster[monster[i]._mx][monster[i]._my] = i + 1; - } + int d = (monster[i]._mdir - 4) & 7; + if (DirOK(i, d)) { + M_ClearSquares(i); + monster[i]._moldx += offset_x[d]; + monster[i]._moldy += offset_y[d]; + NewMonsterAnim(i, &monster[i].MType->Anims[MA_GOTHIT], monster[i]._mdir); + monster[i]._mmode = MM_GOTHIT; + monster[i]._mxoff = 0; + monster[i]._myoff = 0; + monster[i]._mx = monster[i]._moldx; + monster[i]._my = monster[i]._moldy; + monster[i]._mfutx = monster[i]._moldx; + monster[i]._mfuty = monster[i]._moldy; + M_CheckEFlag(i); + M_ClearSquares(i); + dMonster[monster[i]._mx][monster[i]._my] = i + 1; + } } void __fastcall M_StartHit(int i, int pnum, int dam) { - if (pnum >= 0) - monster[i].mWhoHit |= 1 << pnum; - if (pnum == myplr) { - delta_monster_hp(i, monster[i]._mhitpoints, currlevel); - NetSendCmdParam2(FALSE, CMD_MONSTDAMAGE, i, dam); - } - PlayEffect(i, 1); - if (monster[i].MType->mtype >= MT_SNEAK && monster[i].MType->mtype <= MT_ILLWEAV || dam >> 6 >= monster[i].mLevel + 3) { - if (pnum >= 0) { - monster[i]._mFlags &= 0xFFFFFFEF; - monster[i]._menemy = pnum; - monster[i]._menemyx = plr[pnum]._px; - monster[i]._menemyy = plr[pnum]._py; - monster[i]._mdir = M_GetDir(i); - } - if (monster[i].MType->mtype == MT_BLINK) { - M_Teleport(i); - } else if (monster[i].MType->mtype >= MT_NSCAV && monster[i].MType->mtype <= MT_YSCAV) { - monster[i]._mgoal = 1; - } - if (monster[i]._mmode != MM_STONE) { - NewMonsterAnim(i, &monster[i].MType->Anims[MA_GOTHIT], monster[i]._mdir); - monster[i]._mmode = MM_GOTHIT; - monster[i]._mxoff = 0; - monster[i]._myoff = 0; - monster[i]._mx = monster[i]._moldx; - monster[i]._my = monster[i]._moldy; - monster[i]._mfutx = monster[i]._moldx; - monster[i]._mfuty = monster[i]._moldy; - M_CheckEFlag(i); - M_ClearSquares(i); - dMonster[monster[i]._mx][monster[i]._my] = i + 1; - } - } + if (pnum >= 0) + monster[i].mWhoHit |= 1 << pnum; + if (pnum == myplr) { + delta_monster_hp(i, monster[i]._mhitpoints, currlevel); + NetSendCmdParam2(FALSE, CMD_MONSTDAMAGE, i, dam); + } + PlayEffect(i, 1); + if (monster[i].MType->mtype >= MT_SNEAK && monster[i].MType->mtype <= MT_ILLWEAV || dam >> 6 >= monster[i].mLevel + 3) { + if (pnum >= 0) { + monster[i]._mFlags &= 0xFFFFFFEF; + monster[i]._menemy = pnum; + monster[i]._menemyx = plr[pnum]._px; + monster[i]._menemyy = plr[pnum]._py; + monster[i]._mdir = M_GetDir(i); + } + if (monster[i].MType->mtype == MT_BLINK) { + M_Teleport(i); + } else if (monster[i].MType->mtype >= MT_NSCAV && monster[i].MType->mtype <= MT_YSCAV) { + monster[i]._mgoal = 1; + } + if (monster[i]._mmode != MM_STONE) { + NewMonsterAnim(i, &monster[i].MType->Anims[MA_GOTHIT], monster[i]._mdir); + monster[i]._mmode = MM_GOTHIT; + monster[i]._mxoff = 0; + monster[i]._myoff = 0; + monster[i]._mx = monster[i]._moldx; + monster[i]._my = monster[i]._moldy; + monster[i]._mfutx = monster[i]._moldx; + monster[i]._mfuty = monster[i]._moldy; + M_CheckEFlag(i); + M_ClearSquares(i); + dMonster[monster[i]._mx][monster[i]._my] = i + 1; + } + } } void __fastcall M_DiabloDeath(int i, BOOL sendmsg) { - int v2; // esi - int v3; // edi - int v4; // eax - int v5; // ebx - int v6; // esi - int v7; // ecx - int v8; // eax - int v9; // esi - int v10; // eax - double v11; // st7 - int v12; // eax - int v13; // ecx - int v14; // esi - int v15; // [esp+8h] [ebp-8h] - int j; // [esp+Ch] [ebp-4h] - int v17; // [esp+Ch] [ebp-4h] + int v2; // esi + int v3; // edi + int v4; // eax + int v5; // ebx + int v6; // esi + int v7; // ecx + int v8; // eax + int v9; // esi + int v10; // eax + double v11; // st7 + int v12; // eax + int v13; // ecx + int v14; // esi + int v15; // [esp+8h] [ebp-8h] + int j; // [esp+Ch] [ebp-4h] + int v17; // [esp+Ch] [ebp-4h] - v15 = i; - v2 = sendmsg; - v3 = i; - PlaySFX(USFX_DIABLOD); - quests[QTYPE_MOD]._qactive = 3; - if (v2) - NetSendCmdQuest(TRUE, 5u); - gbProcessPlayers = FALSE; - _LOBYTE(sgbSaveSoundOn) = gbSoundOn; - v4 = 0; - for (j = 0; j < nummonsters; ++j) { - v5 = monstactive[v4]; - if (v5 != v15 && monster[v3]._msquelch) { - v6 = v5; - NewMonsterAnim(monstactive[v4], &monster[v5].MType->Anims[MA_DEATH], monster[v5]._mdir); - v7 = monster[v5]._moldy; - monster[v6]._mxoff = 0; - monster[v6]._myoff = 0; - monster[v6]._mVar1 = 0; - v8 = monster[v5]._moldx; - monster[v6]._my = v7; - monster[v6]._mfuty = v7; - monster[v6]._mmode = MM_DEATH; - monster[v6]._mx = v8; - monster[v6]._mfutx = v8; - M_CheckEFlag(v5); - M_ClearSquares(v5); - dMonster[0][monster[v6]._my + 112 * monster[v6]._mx] = v5 + 1; - } - v4 = j + 1; - } - AddLight(monster[v3]._mx, monster[v3]._my, 8); - DoVision(monster[v3]._mx, monster[v3]._my, 8, 0, 1); - v9 = abs(ViewY - monster[v3]._my); - if (abs(ViewX - monster[v3]._mx) <= v9) - v10 = ViewY - monster[v3]._my; - else - v10 = ViewX - monster[v3]._mx; - v17 = abs(v10); - if (v17 > 20) - v17 = 20; - v11 = (double)v17; - v12 = ViewX << 16; - v13 = monster[v3]._mx << 16; - monster[v3]._mVar3 = ViewX << 16; - v14 = ViewY << 16; - monster[v3]._mVar4 = ViewY << 16; - monster[v3]._mVar5 = (signed __int64)((double)(v12 - v13) / v11); - monster[v3]._mVar6 = (signed __int64)((double)(v14 - (monster[v3]._my << 16)) / v11); + v15 = i; + v2 = sendmsg; + v3 = i; + PlaySFX(USFX_DIABLOD); + quests[QTYPE_MOD]._qactive = 3; + if (v2) + NetSendCmdQuest(TRUE, 5u); + gbProcessPlayers = FALSE; + _LOBYTE(sgbSaveSoundOn) = gbSoundOn; + v4 = 0; + for (j = 0; j < nummonsters; ++j) { + v5 = monstactive[v4]; + if (v5 != v15 && monster[v3]._msquelch) { + v6 = v5; + NewMonsterAnim(monstactive[v4], &monster[v5].MType->Anims[MA_DEATH], monster[v5]._mdir); + v7 = monster[v5]._moldy; + monster[v6]._mxoff = 0; + monster[v6]._myoff = 0; + monster[v6]._mVar1 = 0; + v8 = monster[v5]._moldx; + monster[v6]._my = v7; + monster[v6]._mfuty = v7; + monster[v6]._mmode = MM_DEATH; + monster[v6]._mx = v8; + monster[v6]._mfutx = v8; + M_CheckEFlag(v5); + M_ClearSquares(v5); + dMonster[0][monster[v6]._my + 112 * monster[v6]._mx] = v5 + 1; + } + v4 = j + 1; + } + AddLight(monster[v3]._mx, monster[v3]._my, 8); + DoVision(monster[v3]._mx, monster[v3]._my, 8, 0, 1); + v9 = abs(ViewY - monster[v3]._my); + if (abs(ViewX - monster[v3]._mx) <= v9) + v10 = ViewY - monster[v3]._my; + else + v10 = ViewX - monster[v3]._mx; + v17 = abs(v10); + if (v17 > 20) + v17 = 20; + v11 = (double)v17; + v12 = ViewX << 16; + v13 = monster[v3]._mx << 16; + monster[v3]._mVar3 = ViewX << 16; + v14 = ViewY << 16; + monster[v3]._mVar4 = ViewY << 16; + monster[v3]._mVar5 = (signed __int64)((double)(v12 - v13) / v11); + monster[v3]._mVar6 = (signed __int64)((double)(v14 - (monster[v3]._my << 16)) / v11); } // 64D32C: using guessed type int sgbSaveSoundOn; void __fastcall M2MStartHit(int mid, int i, int dam) { - if ((DWORD)mid >= MAXMONSTERS) { - TermMsg("Invalid monster %d getting hit by monster", mid); - } + if ((DWORD)mid >= MAXMONSTERS) { + TermMsg("Invalid monster %d getting hit by monster", mid); + } - if (monster[mid].MType == NULL) { - TermMsg("Monster %d \"%s\" getting hit by monster: MType NULL", mid, monster[mid].mName); - } + if (monster[mid].MType == NULL) { + TermMsg("Monster %d \"%s\" getting hit by monster: MType NULL", mid, monster[mid].mName); + } - if (i >= 0) - monster[i].mWhoHit |= 1 << i; + if (i >= 0) + monster[i].mWhoHit |= 1 << i; - delta_monster_hp(mid, monster[mid]._mhitpoints, currlevel); - NetSendCmdParam2(FALSE, CMD_MONSTDAMAGE, mid, dam); - PlayEffect(mid, 1); + delta_monster_hp(mid, monster[mid]._mhitpoints, currlevel); + NetSendCmdParam2(FALSE, CMD_MONSTDAMAGE, mid, dam); + PlayEffect(mid, 1); - if (monster[mid].MType->mtype >= MT_SNEAK && monster[mid].MType->mtype <= MT_ILLWEAV || dam >> 6 >= monster[mid].mLevel + 3) { - if (i >= 0) - monster[mid]._mdir = (monster[i]._mdir - 4) & 7; + if (monster[mid].MType->mtype >= MT_SNEAK && monster[mid].MType->mtype <= MT_ILLWEAV || dam >> 6 >= monster[mid].mLevel + 3) { + if (i >= 0) + monster[mid]._mdir = (monster[i]._mdir - 4) & 7; - if (monster[mid].MType->mtype == MT_BLINK) { - M_Teleport(mid); - } else if (monster[mid].MType->mtype >= MT_NSCAV && monster[mid].MType->mtype <= MT_YSCAV) { - monster[mid]._mgoal = 1; - } + if (monster[mid].MType->mtype == MT_BLINK) { + M_Teleport(mid); + } else if (monster[mid].MType->mtype >= MT_NSCAV && monster[mid].MType->mtype <= MT_YSCAV) { + monster[mid]._mgoal = 1; + } - if (monster[mid]._mmode != MM_STONE) { - if (monster[mid].MType->mtype != MT_GOLEM) { - NewMonsterAnim(mid, &monster[mid].MType->Anims[MA_GOTHIT], monster[mid]._mdir); - monster[mid]._mmode = MM_GOTHIT; - } + if (monster[mid]._mmode != MM_STONE) { + if (monster[mid].MType->mtype != MT_GOLEM) { + NewMonsterAnim(mid, &monster[mid].MType->Anims[MA_GOTHIT], monster[mid]._mdir); + monster[mid]._mmode = MM_GOTHIT; + } - monster[mid]._mxoff = 0; - monster[mid]._myoff = 0; - monster[mid]._mx = monster[mid]._moldx; - monster[mid]._my = monster[mid]._moldy; - monster[mid]._mfutx = monster[mid]._moldx; - monster[mid]._mfuty = monster[mid]._moldy; - M_CheckEFlag(mid); - M_ClearSquares(mid); - dMonster[monster[mid]._mx][monster[mid]._my] = mid + 1; - } - } + monster[mid]._mxoff = 0; + monster[mid]._myoff = 0; + monster[mid]._mx = monster[mid]._moldx; + monster[mid]._my = monster[mid]._moldy; + monster[mid]._mfutx = monster[mid]._moldx; + monster[mid]._mfuty = monster[mid]._moldy; + M_CheckEFlag(mid); + M_ClearSquares(mid); + dMonster[monster[mid]._mx][monster[mid]._my] = mid + 1; + } + } } void __fastcall MonstStartKill(int i, int pnum, BOOL sendmsg) { - if ((DWORD)i >= MAXMONSTERS) { - TermMsg("MonstStartKill: Invalid monster %d", i); - } - if (!monster[i].MType) { - TermMsg("MonstStartKill: Monster %d \"%s\" MType NULL", i, monster[i].mName); - } + if ((DWORD)i >= MAXMONSTERS) { + TermMsg("MonstStartKill: Invalid monster %d", i); + } + if (!monster[i].MType) { + TermMsg("MonstStartKill: Monster %d \"%s\" MType NULL", i, monster[i].mName); + } - if (pnum >= 0) - monster[i].mWhoHit |= 1 << pnum; - if (pnum < 4 && i > 4) - AddPlrMonstExper(monster[i].mLevel, monster[i].mExp, monster[i].mWhoHit); - monstkills[monster[i].MType->mtype]++; - monster[i]._mhitpoints = 0; - SetRndSeed(monster[i]._mRndSeed); - if (QuestStatus(QTYPE_GARB) && monster[i].mName == UniqMonst[0].mName) { - CreateTypeItem(monster[i]._mx + 1, monster[i]._my + 1, TRUE, 4, FALSE, TRUE, FALSE); - } else if (i > 3) { - SpawnItem(i, monster[i]._mx, monster[i]._my, sendmsg); - } - if (monster[i].MType->mtype == MT_DIABLO) - M_DiabloDeath(i, TRUE); - else - PlayEffect(i, 2); - int md; - if (pnum >= 0) - md = M_GetDir(i); - else - md = monster[i]._mdir; - monster[i]._mdir = md; - NewMonsterAnim(i, &monster[i].MType->Anims[MA_DEATH], md); - monster[i]._mmode = MM_DEATH; - monster[i]._mxoff = 0; - monster[i]._myoff = 0; - monster[i]._mVar1 = 0; - monster[i]._mx = monster[i]._moldx; - monster[i]._my = monster[i]._moldy; - monster[i]._mfutx = monster[i]._moldx; - monster[i]._mfuty = monster[i]._moldy; - M_CheckEFlag(i); - M_ClearSquares(i); - dMonster[monster[i]._mx][monster[i]._my] = i + 1; - CheckQuestKill(i, sendmsg); - M_FallenFear(monster[i]._mx, monster[i]._my); - if (monster[i].MType->mtype >= MT_NACID && monster[i].MType->mtype <= MT_XACID) - AddMissile(monster[i]._mx, monster[i]._my, 0, 0, 0, MIS_ACIDPUD, 1, i, monster[i]._mint + 1, 0); + if (pnum >= 0) + monster[i].mWhoHit |= 1 << pnum; + if (pnum < 4 && i > 4) + AddPlrMonstExper(monster[i].mLevel, monster[i].mExp, monster[i].mWhoHit); + monstkills[monster[i].MType->mtype]++; + monster[i]._mhitpoints = 0; + SetRndSeed(monster[i]._mRndSeed); + if (QuestStatus(QTYPE_GARB) && monster[i].mName == UniqMonst[0].mName) { + CreateTypeItem(monster[i]._mx + 1, monster[i]._my + 1, TRUE, 4, FALSE, TRUE, FALSE); + } else if (i > 3) { + SpawnItem(i, monster[i]._mx, monster[i]._my, sendmsg); + } + if (monster[i].MType->mtype == MT_DIABLO) + M_DiabloDeath(i, TRUE); + else + PlayEffect(i, 2); + int md; + if (pnum >= 0) + md = M_GetDir(i); + else + md = monster[i]._mdir; + monster[i]._mdir = md; + NewMonsterAnim(i, &monster[i].MType->Anims[MA_DEATH], md); + monster[i]._mmode = MM_DEATH; + monster[i]._mxoff = 0; + monster[i]._myoff = 0; + monster[i]._mVar1 = 0; + monster[i]._mx = monster[i]._moldx; + monster[i]._my = monster[i]._moldy; + monster[i]._mfutx = monster[i]._moldx; + monster[i]._mfuty = monster[i]._moldy; + M_CheckEFlag(i); + M_ClearSquares(i); + dMonster[monster[i]._mx][monster[i]._my] = i + 1; + CheckQuestKill(i, sendmsg); + M_FallenFear(monster[i]._mx, monster[i]._my); + if (monster[i].MType->mtype >= MT_NACID && monster[i].MType->mtype <= MT_XACID) + AddMissile(monster[i]._mx, monster[i]._my, 0, 0, 0, MIS_ACIDPUD, 1, i, monster[i]._mint + 1, 0); } void __fastcall M2MStartKill(int i, int mid) { - if ((DWORD)i >= MAXMONSTERS) { - TermMsg("M2MStartKill: Invalid monster (attacker) %d", i); - TermMsg("M2MStartKill: Invalid monster (killed) %d", mid); - } - if (!monster[i].MType) - TermMsg("M2MStartKill: Monster %d \"%s\" MType NULL", mid, monster[mid].mName); + if ((DWORD)i >= MAXMONSTERS) { + TermMsg("M2MStartKill: Invalid monster (attacker) %d", i); + TermMsg("M2MStartKill: Invalid monster (killed) %d", mid); + } + if (!monster[i].MType) + TermMsg("M2MStartKill: Monster %d \"%s\" MType NULL", mid, monster[mid].mName); - delta_kill_monster(mid, monster[mid]._mx, monster[mid]._my, currlevel); - NetSendCmdLocParam1(FALSE, CMD_MONSTDEATH, monster[mid]._mx, monster[mid]._my, mid); + delta_kill_monster(mid, monster[mid]._mx, monster[mid]._my, currlevel); + NetSendCmdLocParam1(FALSE, CMD_MONSTDEATH, monster[mid]._mx, monster[mid]._my, mid); - monster[mid].mWhoHit |= 1 << i; - if (i < 4) - AddPlrMonstExper(monster[mid].mLevel, monster[mid].mExp, monster[mid].mWhoHit); + monster[mid].mWhoHit |= 1 << i; + if (i < 4) + AddPlrMonstExper(monster[mid].mLevel, monster[mid].mExp, monster[mid].mWhoHit); - monstkills[monster[mid].MType->mtype]++; - monster[mid]._mhitpoints = 0; - SetRndSeed(monster[mid]._mRndSeed); + monstkills[monster[mid].MType->mtype]++; + monster[mid]._mhitpoints = 0; + SetRndSeed(monster[mid]._mRndSeed); - if (mid >= 4) - SpawnItem(mid, monster[mid]._mx, monster[mid]._my, TRUE); + if (mid >= 4) + SpawnItem(mid, monster[mid]._mx, monster[mid]._my, TRUE); - if (monster[mid].MType->mtype == MT_DIABLO) - M_DiabloDeath(mid, TRUE); - else - PlayEffect(i, 2); + if (monster[mid].MType->mtype == MT_DIABLO) + M_DiabloDeath(mid, TRUE); + else + PlayEffect(i, 2); - PlayEffect(mid, 2); + PlayEffect(mid, 2); - int md = (monster[i]._mdir - 4) & 7; - if (monster[mid].MType->mtype == MT_GOLEM) - md = 0; + int md = (monster[i]._mdir - 4) & 7; + if (monster[mid].MType->mtype == MT_GOLEM) + md = 0; - monster[mid]._mdir = md; - NewMonsterAnim(mid, &monster[mid].MType->Anims[MA_DEATH], md); - monster[mid]._mmode = MM_DEATH; - monster[mid]._mxoff = 0; - monster[mid]._myoff = 0; - monster[mid]._mx = monster[mid]._moldx; - monster[mid]._my = monster[mid]._moldy; - monster[mid]._mfutx = monster[mid]._moldx; - monster[mid]._mfuty = monster[mid]._moldy; - M_CheckEFlag(mid); - M_ClearSquares(mid); - dMonster[monster[mid]._mx][monster[mid]._my] = mid + 1; - CheckQuestKill(mid, TRUE); - M_FallenFear(monster[mid]._mx, monster[mid]._my); - if (monster[mid].MType->mtype >= MT_NACID && monster[mid].MType->mtype <= MT_XACID) - AddMissile(monster[mid]._mx, monster[mid]._my, 0, 0, 0, MIS_ACIDPUD, 1, mid, monster[mid]._mint + 1, 0); + monster[mid]._mdir = md; + NewMonsterAnim(mid, &monster[mid].MType->Anims[MA_DEATH], md); + monster[mid]._mmode = MM_DEATH; + monster[mid]._mxoff = 0; + monster[mid]._myoff = 0; + monster[mid]._mx = monster[mid]._moldx; + monster[mid]._my = monster[mid]._moldy; + monster[mid]._mfutx = monster[mid]._moldx; + monster[mid]._mfuty = monster[mid]._moldy; + M_CheckEFlag(mid); + M_ClearSquares(mid); + dMonster[monster[mid]._mx][monster[mid]._my] = mid + 1; + CheckQuestKill(mid, TRUE); + M_FallenFear(monster[mid]._mx, monster[mid]._my); + if (monster[mid].MType->mtype >= MT_NACID && monster[mid].MType->mtype <= MT_XACID) + AddMissile(monster[mid]._mx, monster[mid]._my, 0, 0, 0, MIS_ACIDPUD, 1, mid, monster[mid]._mint + 1, 0); } void __fastcall M_StartKill(int i, int pnum) { - if ((DWORD)i >= MAXMONSTERS) { - TermMsg("M_StartKill: Invalid monster %d", i); - } + if ((DWORD)i >= MAXMONSTERS) { + TermMsg("M_StartKill: Invalid monster %d", i); + } - if (myplr == pnum) { - delta_kill_monster(i, monster[i]._mx, monster[i]._my, currlevel); - if (i != pnum) { - NetSendCmdLocParam1(FALSE, CMD_MONSTDEATH, monster[i]._mx, monster[i]._my, i); - } else { - NetSendCmdLocParam1(FALSE, CMD_KILLGOLEM, monster[i]._mx, monster[i]._my, currlevel); - } - } + if (myplr == pnum) { + delta_kill_monster(i, monster[i]._mx, monster[i]._my, currlevel); + if (i != pnum) { + NetSendCmdLocParam1(FALSE, CMD_MONSTDEATH, monster[i]._mx, monster[i]._my, i); + } else { + NetSendCmdLocParam1(FALSE, CMD_KILLGOLEM, monster[i]._mx, monster[i]._my, currlevel); + } + } - MonstStartKill(i, pnum, TRUE); + MonstStartKill(i, pnum, TRUE); } void __fastcall M_SyncStartKill(int i, int x, int y, int pnum) { - if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_SyncStartKill: Invalid monster %d", i); + if ((DWORD)i >= MAXMONSTERS) + TermMsg("M_SyncStartKill: Invalid monster %d", i); - if (monster[i]._mhitpoints == 0 || monster[i]._mmode == MM_DEATH) { - return; - } + if (monster[i]._mhitpoints == 0 || monster[i]._mmode == MM_DEATH) { + return; + } - if (dMonster[x][y] == 0) { - M_ClearSquares(i); - monster[i]._mx = x; - monster[i]._my = y; - monster[i]._moldx = x; - monster[i]._moldy = y; - } + if (dMonster[x][y] == 0) { + M_ClearSquares(i); + monster[i]._mx = x; + monster[i]._my = y; + monster[i]._moldx = x; + monster[i]._moldy = y; + } - if (monster[i]._mmode == MM_STONE) { - MonstStartKill(i, pnum, FALSE); - monster[i]._mmode = MM_STONE; - } else { - MonstStartKill(i, pnum, FALSE); - } + if (monster[i]._mmode == MM_STONE) { + MonstStartKill(i, pnum, FALSE); + monster[i]._mmode = MM_STONE; + } else { + MonstStartKill(i, pnum, FALSE); + } } void __fastcall M_StartFadein(int i, int md, BOOL backwards) { - if ((DWORD)i >= MAXMONSTERS) { - TermMsg("M_StartFadein: Invalid monster %d", i); - } + if ((DWORD)i >= MAXMONSTERS) { + TermMsg("M_StartFadein: Invalid monster %d", i); + } - if (monster[i].MType == NULL) - TermMsg("M_StartFadein: Monster %d \"%s\" MType NULL", i, monster[i].mName); + if (monster[i].MType == NULL) + TermMsg("M_StartFadein: Monster %d \"%s\" MType NULL", i, monster[i].mName); - NewMonsterAnim(i, &monster[i].MType->Anims[MA_SPECIAL], md); - monster[i]._mmode = MM_FADEIN; - monster[i]._mxoff = 0; - monster[i]._myoff = 0; - monster[i]._mfutx = monster[i]._mx; - monster[i]._mfuty = monster[i]._my; - monster[i]._moldx = monster[i]._mx; - monster[i]._moldy = monster[i]._my; - M_CheckEFlag(i); - monster[i]._mdir = md; - monster[i]._mFlags &= ~0x1; - if (backwards) { - monster[i]._mFlags |= 0x2; - monster[i]._mAnimFrame = monster[i]._mAnimLen; - } + NewMonsterAnim(i, &monster[i].MType->Anims[MA_SPECIAL], md); + monster[i]._mmode = MM_FADEIN; + monster[i]._mxoff = 0; + monster[i]._myoff = 0; + monster[i]._mfutx = monster[i]._mx; + monster[i]._mfuty = monster[i]._my; + monster[i]._moldx = monster[i]._mx; + monster[i]._moldy = monster[i]._my; + M_CheckEFlag(i); + monster[i]._mdir = md; + monster[i]._mFlags &= ~0x1; + if (backwards) { + monster[i]._mFlags |= 0x2; + monster[i]._mAnimFrame = monster[i]._mAnimLen; + } } void __fastcall M_StartFadeout(int i, int md, BOOL backwards) { - if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_StartFadeout: Invalid monster %d", i); + if ((DWORD)i >= MAXMONSTERS) + TermMsg("M_StartFadeout: Invalid monster %d", i); - if (monster[i].MType == NULL) - TermMsg("M_StartFadeout: Monster %d \"%s\" MType NULL", i, monster[i].mName); + if (monster[i].MType == NULL) + TermMsg("M_StartFadeout: Monster %d \"%s\" MType NULL", i, monster[i].mName); - NewMonsterAnim(i, &monster[i].MType->Anims[MA_SPECIAL], md); - monster[i]._mmode = MM_FADEOUT; - monster[i]._mxoff = 0; - monster[i]._myoff = 0; - monster[i]._mfutx = monster[i]._mx; - monster[i]._mfuty = monster[i]._my; - monster[i]._moldx = monster[i]._mx; - monster[i]._moldy = monster[i]._my; - M_CheckEFlag(i); - monster[i]._mdir = md; - if (backwards) { - monster[i]._mFlags |= 2; - monster[i]._mAnimFrame = monster[i]._mAnimLen; - } + NewMonsterAnim(i, &monster[i].MType->Anims[MA_SPECIAL], md); + monster[i]._mmode = MM_FADEOUT; + monster[i]._mxoff = 0; + monster[i]._myoff = 0; + monster[i]._mfutx = monster[i]._mx; + monster[i]._mfuty = monster[i]._my; + monster[i]._moldx = monster[i]._mx; + monster[i]._moldy = monster[i]._my; + M_CheckEFlag(i); + monster[i]._mdir = md; + if (backwards) { + monster[i]._mFlags |= 2; + monster[i]._mAnimFrame = monster[i]._mAnimLen; + } } void __fastcall M_StartHeal(int i) { - int v1; // edi - int v2; // esi - CMonster *v3; // eax - unsigned char *v4; // ecx - int v5; // eax + int v1; // edi + int v2; // esi + CMonster *v3; // eax + unsigned char *v4; // ecx + int v5; // eax - v1 = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_StartHeal: Invalid monster %d", i); - v2 = v1; - if (monster[v1].MType == NULL) - TermMsg("M_StartHeal: Monster %d \"%s\" MType NULL", v1, monster[v2].mName); - v3 = monster[v2].MType; - v4 = v3->Anims[MA_SPECIAL].Data[monster[v2]._mdir]; - monster[v2]._mAnimData = v4; - v5 = v3->Anims[MA_SPECIAL].Frames; - monster[v2]._mFlags |= 2u; - monster[v2]._mAnimFrame = v5; - monster[v2]._mmode = MM_HEAL; - monster[v2]._mVar1 = monster[v2]._mmaxhp / (16 * (random(97, 5) + 4)); + v1 = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("M_StartHeal: Invalid monster %d", i); + v2 = v1; + if (monster[v1].MType == NULL) + TermMsg("M_StartHeal: Monster %d \"%s\" MType NULL", v1, monster[v2].mName); + v3 = monster[v2].MType; + v4 = v3->Anims[MA_SPECIAL].Data[monster[v2]._mdir]; + monster[v2]._mAnimData = v4; + v5 = v3->Anims[MA_SPECIAL].Frames; + monster[v2]._mFlags |= 2u; + monster[v2]._mAnimFrame = v5; + monster[v2]._mmode = MM_HEAL; + monster[v2]._mVar1 = monster[v2]._mmaxhp / (16 * (random(97, 5) + 4)); } void __fastcall M_ChangeLightOffset(int monst) { - int v1; // esi - int v2; // ecx - int v3; // eax - int v4; // esi - int v5; // edx - int v6; // eax - signed int v7; // esi - int v8; // edx - signed int v9; // esi + int v1; // esi + int v2; // ecx + int v3; // eax + int v4; // esi + int v5; // edx + int v6; // eax + signed int v7; // esi + int v8; // edx + signed int v9; // esi - v1 = monst; - if ((unsigned int)monst >= MAXMONSTERS) - TermMsg("M_ChangeLightOffset: Invalid monster %d", monst); - v2 = v1; - v3 = monster[v1]._myoff; - v4 = monster[v1]._mxoff; - v3 *= 2; - v5 = v4 + v3; - v6 = v3 - v4; - if (v5 >= 0) { - v7 = 1; - } else { - v7 = -1; - v5 = -v5; - } - v8 = v7 * (v5 >> 3); - if (v6 >= 0) { - v9 = 1; - } else { - v9 = -1; - v6 = -v6; - } - ChangeLightOff((unsigned char)monster[v2].mlid, v8, v9 * (v6 >> 3)); + v1 = monst; + if ((unsigned int)monst >= MAXMONSTERS) + TermMsg("M_ChangeLightOffset: Invalid monster %d", monst); + v2 = v1; + v3 = monster[v1]._myoff; + v4 = monster[v1]._mxoff; + v3 *= 2; + v5 = v4 + v3; + v6 = v3 - v4; + if (v5 >= 0) { + v7 = 1; + } else { + v7 = -1; + v5 = -v5; + } + v8 = v7 * (v5 >> 3); + if (v6 >= 0) { + v9 = 1; + } else { + v9 = -1; + v6 = -v6; + } + ChangeLightOff((unsigned char)monster[v2].mlid, v8, v9 * (v6 >> 3)); } int __fastcall M_DoStand(int i) { - int v1; // edi - int v2; // esi - CMonster *v3; // eax - int v4; // ecx - unsigned char *v5; // eax + int v1; // edi + int v2; // esi + CMonster *v3; // eax + int v4; // ecx + unsigned char *v5; // eax - v1 = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_DoStand: Invalid monster %d", i); - v2 = v1; - if (monster[v1].MType == NULL) - TermMsg("M_DoStand: Monster %d \"%s\" MType NULL", v1, monster[v2].mName); - v3 = monster[v2].MType; - v4 = monster[v2]._mdir; - if (v3->mtype == MT_GOLEM) - v5 = v3->Anims[MA_WALK].Data[v4]; - else - v5 = v3->Anims[MA_STAND].Data[v4]; - monster[v2]._mAnimData = v5; - if (monster[v2]._mAnimFrame == monster[v2]._mAnimLen) - M_Enemy(v1); - ++monster[v2]._mVar2; - return 0; + v1 = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("M_DoStand: Invalid monster %d", i); + v2 = v1; + if (monster[v1].MType == NULL) + TermMsg("M_DoStand: Monster %d \"%s\" MType NULL", v1, monster[v2].mName); + v3 = monster[v2].MType; + v4 = monster[v2]._mdir; + if (v3->mtype == MT_GOLEM) + v5 = v3->Anims[MA_WALK].Data[v4]; + else + v5 = v3->Anims[MA_STAND].Data[v4]; + monster[v2]._mAnimData = v5; + if (monster[v2]._mAnimFrame == monster[v2]._mAnimLen) + M_Enemy(v1); + ++monster[v2]._mVar2; + return 0; } int __fastcall M_DoWalk(int i) { - int v1; // ebx - int v2; // esi - int v3; // edi - int v4; // eax - int v5; // edi - int v6; // ecx - int v7; // edx - int v8; // eax - bool v9; // zf - int v10; // ecx - int v11; // edx - int v12; // eax - int v13; // ecx + int v1; // ebx + int v2; // esi + int v3; // edi + int v4; // eax + int v5; // edi + int v6; // ecx + int v7; // edx + int v8; // eax + bool v9; // zf + int v10; // ecx + int v11; // edx + int v12; // eax + int v13; // ecx - v1 = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_DoWalk: Invalid monster %d", i); - v2 = v1; - v3 = 0; - if (monster[v1].MType == NULL) - TermMsg("M_DoWalk: Monster %d \"%s\" MType NULL", v1, monster[v2].mName); - v4 = monster[v2]._mVar8; - if (v4 == monster[v2].MType->Anims[MA_WALK].Frames) { - v5 = monster[v2]._my; - v6 = monster[v2]._mx; - dMonster[0][v5 + 112 * monster[v2]._mx] = 0; - v7 = v6 + monster[v2]._mVar1; - monster[v2]._mx = v7; - v8 = v5 + monster[v2]._mVar2; - v9 = monster[v2]._uniqtype == 0; - monster[v2]._my = v8; - dMonster[0][v8 + 112 * v7] = v1 + 1; - if (!v9) - ChangeLightXY((unsigned char)monster[v2].mlid, v7, v8); - M_StartStand(v1, monster[v2]._mdir); - v3 = 1; - } else if (!monster[v2]._mAnimCnt) { - v10 = monster[v2]._mxvel; - v11 = monster[v2]._myvel; - monster[v2]._mVar8 = v4 + 1; - monster[v2]._mVar6 += v10; - v12 = monster[v2]._mVar6 >> 4; - monster[v2]._mVar7 += v11; - v13 = monster[v2]._mVar7 >> 4; - monster[v2]._mxoff = v12; - monster[v2]._myoff = v13; - } - if (monster[v2]._uniqtype != 0) - M_ChangeLightOffset(v1); - return v3; + v1 = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("M_DoWalk: Invalid monster %d", i); + v2 = v1; + v3 = 0; + if (monster[v1].MType == NULL) + TermMsg("M_DoWalk: Monster %d \"%s\" MType NULL", v1, monster[v2].mName); + v4 = monster[v2]._mVar8; + if (v4 == monster[v2].MType->Anims[MA_WALK].Frames) { + v5 = monster[v2]._my; + v6 = monster[v2]._mx; + dMonster[0][v5 + 112 * monster[v2]._mx] = 0; + v7 = v6 + monster[v2]._mVar1; + monster[v2]._mx = v7; + v8 = v5 + monster[v2]._mVar2; + v9 = monster[v2]._uniqtype == 0; + monster[v2]._my = v8; + dMonster[0][v8 + 112 * v7] = v1 + 1; + if (!v9) + ChangeLightXY((unsigned char)monster[v2].mlid, v7, v8); + M_StartStand(v1, monster[v2]._mdir); + v3 = 1; + } else if (!monster[v2]._mAnimCnt) { + v10 = monster[v2]._mxvel; + v11 = monster[v2]._myvel; + monster[v2]._mVar8 = v4 + 1; + monster[v2]._mVar6 += v10; + v12 = monster[v2]._mVar6 >> 4; + monster[v2]._mVar7 += v11; + v13 = monster[v2]._mVar7 >> 4; + monster[v2]._mxoff = v12; + monster[v2]._myoff = v13; + } + if (monster[v2]._uniqtype != 0) + M_ChangeLightOffset(v1); + return v3; } int __fastcall M_DoWalk2(int i) { - int v1; // ebp - int v2; // esi - int v3; // eax - bool v4; // zf - int v5; // edi - int v6; // ecx - int v7; // edx - int v8; // eax - int v9; // ecx + int v1; // ebp + int v2; // esi + int v3; // eax + bool v4; // zf + int v5; // edi + int v6; // ecx + int v7; // edx + int v8; // eax + int v9; // ecx - v1 = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_DoWalk2: Invalid monster %d", i); - v2 = v1; - if (monster[v1].MType == NULL) - TermMsg("M_DoWalk2: Monster %d \"%s\" MType NULL", v1, monster[v2].mName); - v3 = monster[v2]._mVar8; - if (v3 == monster[v2].MType->Anims[MA_WALK].Frames) { - v4 = monster[v2]._uniqtype == 0; - dMonster[0][monster[v2]._mVar2 + 112 * monster[v2]._mVar1] = 0; - if (!v4) - ChangeLightXY((unsigned char)monster[v2].mlid, monster[v2]._mx, monster[v2]._my); - M_StartStand(v1, monster[v2]._mdir); - v5 = 1; - } else { - if (!monster[v2]._mAnimCnt) { - v6 = monster[v2]._mxvel; - v7 = monster[v2]._myvel; - monster[v2]._mVar8 = v3 + 1; - monster[v2]._mVar6 += v6; - v8 = monster[v2]._mVar6 >> 4; - monster[v2]._mVar7 += v7; - v9 = monster[v2]._mVar7 >> 4; - monster[v2]._mxoff = v8; - monster[v2]._myoff = v9; - } - v5 = 0; - } - if (monster[v2]._uniqtype != 0) - M_ChangeLightOffset(v1); - return v5; + v1 = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("M_DoWalk2: Invalid monster %d", i); + v2 = v1; + if (monster[v1].MType == NULL) + TermMsg("M_DoWalk2: Monster %d \"%s\" MType NULL", v1, monster[v2].mName); + v3 = monster[v2]._mVar8; + if (v3 == monster[v2].MType->Anims[MA_WALK].Frames) { + v4 = monster[v2]._uniqtype == 0; + dMonster[0][monster[v2]._mVar2 + 112 * monster[v2]._mVar1] = 0; + if (!v4) + ChangeLightXY((unsigned char)monster[v2].mlid, monster[v2]._mx, monster[v2]._my); + M_StartStand(v1, monster[v2]._mdir); + v5 = 1; + } else { + if (!monster[v2]._mAnimCnt) { + v6 = monster[v2]._mxvel; + v7 = monster[v2]._myvel; + monster[v2]._mVar8 = v3 + 1; + monster[v2]._mVar6 += v6; + v8 = monster[v2]._mVar6 >> 4; + monster[v2]._mVar7 += v7; + v9 = monster[v2]._mVar7 >> 4; + monster[v2]._mxoff = v8; + monster[v2]._myoff = v9; + } + v5 = 0; + } + if (monster[v2]._uniqtype != 0) + M_ChangeLightOffset(v1); + return v5; } int __fastcall M_DoWalk3(int i) { - int v1; // ebp - int v2; // esi - int v3; // eax - int v4; // edi - int v5; // edx - int v6; // ecx - int v7; // edx - char *v8; // eax - bool v9; // zf - int v10; // edi - int v11; // ecx - int v12; // edx - int v13; // eax - int v14; // ecx + int v1; // ebp + int v2; // esi + int v3; // eax + int v4; // edi + int v5; // edx + int v6; // ecx + int v7; // edx + char *v8; // eax + bool v9; // zf + int v10; // edi + int v11; // ecx + int v12; // edx + int v13; // eax + int v14; // ecx - v1 = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_DoWalk3: Invalid monster %d", i); - v2 = v1; - if (monster[v1].MType == NULL) - TermMsg("M_DoWalk3: Monster %d \"%s\" MType NULL", v1, monster[v2].mName); - v3 = monster[v2]._mVar8; - if (v3 == monster[v2].MType->Anims[MA_WALK].Frames) { - v4 = monster[v2]._mVar2; - v5 = monster[v2]._my + 112 * monster[v2]._mx; - monster[v2]._my = v4; - v6 = monster[v2]._mVar5; - dMonster[0][v5] = 0; - v7 = monster[v2]._mVar1; - monster[v2]._mx = v7; - v8 = &dFlags[monster[v2]._mVar4][v6]; - *v8 &= ~DFLAG_MONSTER; - v9 = monster[v2]._uniqtype == 0; - dMonster[0][v4 + 112 * v7] = v1 + 1; - if (!v9) - ChangeLightXY((unsigned char)monster[v2].mlid, v7, v4); - M_StartStand(v1, monster[v2]._mdir); - v10 = 1; - } else { - if (!monster[v2]._mAnimCnt) { - v11 = monster[v2]._mxvel; - v12 = monster[v2]._myvel; - monster[v2]._mVar8 = v3 + 1; - monster[v2]._mVar6 += v11; - v13 = monster[v2]._mVar6 >> 4; - monster[v2]._mVar7 += v12; - v14 = monster[v2]._mVar7 >> 4; - monster[v2]._mxoff = v13; - monster[v2]._myoff = v14; - } - v10 = 0; - } - if (monster[v2]._uniqtype != 0) - M_ChangeLightOffset(v1); - return v10; + v1 = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("M_DoWalk3: Invalid monster %d", i); + v2 = v1; + if (monster[v1].MType == NULL) + TermMsg("M_DoWalk3: Monster %d \"%s\" MType NULL", v1, monster[v2].mName); + v3 = monster[v2]._mVar8; + if (v3 == monster[v2].MType->Anims[MA_WALK].Frames) { + v4 = monster[v2]._mVar2; + v5 = monster[v2]._my + 112 * monster[v2]._mx; + monster[v2]._my = v4; + v6 = monster[v2]._mVar5; + dMonster[0][v5] = 0; + v7 = monster[v2]._mVar1; + monster[v2]._mx = v7; + v8 = &dFlags[monster[v2]._mVar4][v6]; + *v8 &= ~DFLAG_MONSTER; + v9 = monster[v2]._uniqtype == 0; + dMonster[0][v4 + 112 * v7] = v1 + 1; + if (!v9) + ChangeLightXY((unsigned char)monster[v2].mlid, v7, v4); + M_StartStand(v1, monster[v2]._mdir); + v10 = 1; + } else { + if (!monster[v2]._mAnimCnt) { + v11 = monster[v2]._mxvel; + v12 = monster[v2]._myvel; + monster[v2]._mVar8 = v3 + 1; + monster[v2]._mVar6 += v11; + v13 = monster[v2]._mVar6 >> 4; + monster[v2]._mVar7 += v12; + v14 = monster[v2]._mVar7 >> 4; + monster[v2]._mxoff = v13; + monster[v2]._myoff = v14; + } + v10 = 0; + } + if (monster[v2]._uniqtype != 0) + M_ChangeLightOffset(v1); + return v10; } void __fastcall M_TryM2MHit(int i, int mid, int hper, int mind, int maxd) { - int v5; // edi - //int v6; // ST08_4 - int v7; // esi - int v8; // ebx - //int v9; // eax - int v11; // eax - BOOL ret; // [esp+Ch] [ebp-Ch] - char v13[4]; // [esp+10h] [ebp-8h] - char arglist[4]; // [esp+14h] [ebp-4h] + int v5; // edi + //int v6; // ST08_4 + int v7; // esi + int v8; // ebx + //int v9; // eax + int v11; // eax + BOOL ret; // [esp+Ch] [ebp-Ch] + char v13[4]; // [esp+10h] [ebp-8h] + char arglist[4]; // [esp+14h] [ebp-4h] - v5 = mid; - *(_DWORD *)arglist = mid; - *(_DWORD *)v13 = i; - if ((unsigned int)mid >= MAXMONSTERS) { - TermMsg("M_TryM2MHit: Invalid monster %d", mid); - //i = v6; - } - v7 = v5; - if (monster[v5].MType == NULL) - TermMsg("M_TryM2MHit: Monster %d \"%s\" MType NULL", v5, monster[v7].mName); - if (monster[v7]._mhitpoints >> 6 > 0 - && (monster[v7].MType->mtype != MT_ILLWEAV || _LOBYTE(monster[v7]._mgoal) != 2)) { - v8 = random(4, 100); - if (monster[v7]._mmode == MM_STONE) - v8 = 0; - //_LOBYTE(v9) = CheckMonsterHit(*(int *)arglist, &ret); - if (!CheckMonsterHit(*(int *)arglist, &ret) && v8 < hper) { - v11 = (mind + random(5, maxd - mind + 1)) << 6; - monster[v7]._mhitpoints -= v11; - if (monster[v7]._mhitpoints >> 6 > 0) { - if (monster[v7]._mmode == MM_STONE) { - M2MStartHit(*(int *)arglist, *(int *)v13, v11); - goto LABEL_15; - } - M2MStartHit(*(int *)arglist, *(int *)v13, v11); - } else { - if (monster[v7]._mmode == MM_STONE) { - M2MStartKill(*(int *)v13, *(int *)arglist); - LABEL_15: - monster[v7]._mmode = MM_STONE; - return; - } - M2MStartKill(*(int *)v13, *(int *)arglist); - } - } - } + v5 = mid; + *(_DWORD *)arglist = mid; + *(_DWORD *)v13 = i; + if ((unsigned int)mid >= MAXMONSTERS) { + TermMsg("M_TryM2MHit: Invalid monster %d", mid); + //i = v6; + } + v7 = v5; + if (monster[v5].MType == NULL) + TermMsg("M_TryM2MHit: Monster %d \"%s\" MType NULL", v5, monster[v7].mName); + if (monster[v7]._mhitpoints >> 6 > 0 + && (monster[v7].MType->mtype != MT_ILLWEAV || _LOBYTE(monster[v7]._mgoal) != 2)) { + v8 = random(4, 100); + if (monster[v7]._mmode == MM_STONE) + v8 = 0; + //_LOBYTE(v9) = CheckMonsterHit(*(int *)arglist, &ret); + if (!CheckMonsterHit(*(int *)arglist, &ret) && v8 < hper) { + v11 = (mind + random(5, maxd - mind + 1)) << 6; + monster[v7]._mhitpoints -= v11; + if (monster[v7]._mhitpoints >> 6 > 0) { + if (monster[v7]._mmode == MM_STONE) { + M2MStartHit(*(int *)arglist, *(int *)v13, v11); + goto LABEL_15; + } + M2MStartHit(*(int *)arglist, *(int *)v13, v11); + } else { + if (monster[v7]._mmode == MM_STONE) { + M2MStartKill(*(int *)v13, *(int *)arglist); + LABEL_15: + monster[v7]._mmode = MM_STONE; + return; + } + M2MStartKill(*(int *)v13, *(int *)arglist); + } + } + } } void __fastcall M_TryH2HHit(int i, int pnum, int Hit, int MinDam, int MaxDam) { - int v5; // esi - int v6; // ebx - int v7; // esi - int v8; // edi - int v9; // eax - //int v10; // ST08_4 - int v12; // ecx - int v13; // edi - int v14; // eax - int v15; // eax - int *v16; // ecx - int v17; // eax - int v18; // edi - int v19; // edx - int v20; // eax - int v21; // eax - int v22; // edx - int v23; // eax - bool v24; // zf - bool v25; // sf - unsigned char v26; // of - int v27; // eax - int v29; // edi - int v30; // eax - int v31; // eax - int v32; // eax - int v33; // edi - int v34; // ebx - int v35; // edx - int v36; // [esp+Ch] [ebp-Ch] - int arglist; // [esp+10h] [ebp-8h] - int plr_num; // [esp+14h] [ebp-4h] - int hper; // [esp+20h] [ebp+8h] + int v5; // esi + int v6; // ebx + int v7; // esi + int v8; // edi + int v9; // eax + //int v10; // ST08_4 + int v12; // ecx + int v13; // edi + int v14; // eax + int v15; // eax + int *v16; // ecx + int v17; // eax + int v18; // edi + int v19; // edx + int v20; // eax + int v21; // eax + int v22; // edx + int v23; // eax + bool v24; // zf + bool v25; // sf + unsigned char v26; // of + int v27; // eax + int v29; // edi + int v30; // eax + int v31; // eax + int v32; // eax + int v33; // edi + int v34; // ebx + int v35; // edx + int v36; // [esp+Ch] [ebp-Ch] + int arglist; // [esp+10h] [ebp-8h] + int plr_num; // [esp+14h] [ebp-4h] + int hper; // [esp+20h] [ebp+8h] - v5 = i; - plr_num = pnum; - arglist = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_TryH2HHit: Invalid monster %d", i); - v6 = v5; - if (monster[v5].MType == NULL) - TermMsg("M_TryH2HHit: Monster %d \"%s\" MType NULL", v5, monster[v6].mName); - if (monster[v6]._mFlags & 0x10) { - M_TryM2MHit(v5, plr_num, Hit, MinDam, MaxDam); - return; - } - v7 = plr_num; - if (plr[plr_num]._pHitPoints >> 6 > 0 && !plr[v7]._pInvincible && !(plr[v7]._pSpellFlags & 1)) { - v8 = abs(monster[v6]._mx - plr[v7].WorldX); - v9 = abs(monster[v6]._my - plr[v7].WorldY); - //v11 = v10; - if (v8 < 2 && v9 < 2) { - v36 = random(98, 100); + v5 = i; + plr_num = pnum; + arglist = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("M_TryH2HHit: Invalid monster %d", i); + v6 = v5; + if (monster[v5].MType == NULL) + TermMsg("M_TryH2HHit: Monster %d \"%s\" MType NULL", v5, monster[v6].mName); + if (monster[v6]._mFlags & 0x10) { + M_TryM2MHit(v5, plr_num, Hit, MinDam, MaxDam); + return; + } + v7 = plr_num; + if (plr[plr_num]._pHitPoints >> 6 > 0 && !plr[v7]._pInvincible && !(plr[v7]._pSpellFlags & 1)) { + v8 = abs(monster[v6]._mx - plr[v7].WorldX); + v9 = abs(monster[v6]._my - plr[v7].WorldY); + //v11 = v10; + if (v8 < 2 && v9 < 2) { + v36 = random(98, 100); #ifdef _DEBUG - if (debug_mode_dollar_sign || debug_mode_key_inverted_v) - v36 = 1000; + if (debug_mode_dollar_sign || debug_mode_key_inverted_v) + v36 = 1000; #endif - v12 = 5; - v13 = Hit - + 2 * (SLOBYTE(monster[v6].mLevel) - plr[v7]._pLevel) - + 30 - - plr[v7]._pIBonusAC - - plr[v7]._pIAC - - plr[v7]._pDexterity / 5; - if (v13 < 15) - v13 = 15; - if (currlevel == 14) { - if (v13 >= 20) - goto LABEL_23; - v13 = 20; - } - if (currlevel != 15) { - LABEL_20: - if (currlevel == 16 && v13 < 30) - v13 = 30; - goto LABEL_23; - } - if (v13 < 25) { - v13 = 25; - goto LABEL_20; - } - LABEL_23: - v14 = plr[v7]._pmode; - if (v14 && v14 != 4 || !plr[v7]._pBlockFlag) { - v15 = 100; - } else { - v15 = random(98, 100); - } - v16 = (int *)(plr[v7]._pDexterity - + plr[v7]._pBaseToBlk - - 2 * SLOBYTE(monster[v6].mLevel) - + 2 * plr[v7]._pLevel); - if ((signed int)v16 < 0) - v16 = 0; - if ((signed int)v16 > 100) - v16 = (int *)100; - if (v36 < v13) { - if (v15 >= (signed int)v16) { - if (monster[v6].MType->mtype == MT_YZOMBIE && plr_num == myplr) { - v18 = -1; - v19 = 0; - for (hper = -1; v19 < nummissiles; ++v19) { - v20 = missileactive[v19]; - if (missile[v20]._mitype == 13) { - if (missile[v20]._misource == plr_num) { - v18 = missileactive[v19]; - hper = missileactive[v19]; - } else { - v18 = hper; - } - } - } - v16 = &plr[v7]._pMaxHP; - v21 = plr[v7]._pMaxHP; - if (v21 > 64) { - v22 = plr[v7]._pMaxHPBase; - if (v22 > 64) { - v23 = v21 - 64; - v26 = __OFSUB__(plr[v7]._pHitPoints, v23); - v24 = plr[v7]._pHitPoints == v23; - v25 = plr[v7]._pHitPoints - v23 < 0; - *v16 = v23; - if (!((unsigned char)(v25 ^ v26) | v24)) { - plr[v7]._pHitPoints = v23; - if (v18 >= 0) - missile[v18]._miVar1 = v23; - } - v16 = &plr[v7]._pHPBase; - v27 = v22 - 64; - plr[v7]._pMaxHPBase = v22 - 64; - if (plr[v7]._pHPBase > v22 - 64) { - *v16 = v27; - if (v18 >= 0) - missile[v18]._miVar2 = v27; - } - } - } - } - v29 = (plr[v7]._pIGetHit << 6) + (MinDam << 6) + random(99, (MaxDam - MinDam + 1) << 6); - if (v29 < 64) - v29 = 64; - if (plr_num == myplr) { - plr[v7]._pHitPoints -= v29; - plr[v7]._pHPBase -= v29; - } - if (plr[v7]._pIFlags & 0x4000000) { - v30 = (random(99, 3) + 1) << 6; - monster[v6]._mhitpoints -= v30; - if (monster[v6]._mhitpoints >> 6 > 0) - M_StartHit(arglist, plr_num, v30); - else - M_StartKill(arglist, plr_num); - } - if (!(monster[v6]._mFlags & 0x1000) && monster[v6].MType->mtype == MT_SKING && gbMaxPlayers != 1) - monster[v6]._mhitpoints += v29; - v31 = plr[v7]._pMaxHP; - if (plr[v7]._pHitPoints > v31) { - plr[v7]._pHitPoints = v31; - plr[v7]._pHPBase = plr[v7]._pMaxHPBase; - } - if (plr[v7]._pHitPoints >> 6 > 0) { - StartPlrHit(plr_num, v29, 0); - if (SLOBYTE(monster[v6]._mFlags) < 0) { - if (plr[v7]._pmode != PM_GOTHIT) - StartPlrHit(plr_num, 0, 1u); - v32 = monster[v6]._mdir; - v33 = plr[v7].WorldX + offset_x[v32]; - v34 = plr[v7].WorldY + offset_y[v32]; - if (PosOkPlayer(plr_num, v33, v34)) { - v35 = plr[v7]._pdir; - plr[v7].WorldX = v33; - plr[v7].WorldY = v34; - FixPlayerLocation(plr_num, v35); - FixPlrWalkTags(plr_num); - dPlayer[v33][v34] = plr_num + 1; - SetPlayerOld(plr_num); - } - } - } else { - SyncPlrKill(plr_num, 0); - } - } else { - v17 = GetDirection(plr[v7].WorldX, plr[v7].WorldY, monster[v6]._mx, monster[v6]._my); - StartPlrBlock(plr_num, v17); - } - } - return; - } - } + v12 = 5; + v13 = Hit + + 2 * (SLOBYTE(monster[v6].mLevel) - plr[v7]._pLevel) + + 30 + - plr[v7]._pIBonusAC + - plr[v7]._pIAC + - plr[v7]._pDexterity / 5; + if (v13 < 15) + v13 = 15; + if (currlevel == 14) { + if (v13 >= 20) + goto LABEL_23; + v13 = 20; + } + if (currlevel != 15) { + LABEL_20: + if (currlevel == 16 && v13 < 30) + v13 = 30; + goto LABEL_23; + } + if (v13 < 25) { + v13 = 25; + goto LABEL_20; + } + LABEL_23: + v14 = plr[v7]._pmode; + if (v14 && v14 != 4 || !plr[v7]._pBlockFlag) { + v15 = 100; + } else { + v15 = random(98, 100); + } + v16 = (int *)(plr[v7]._pDexterity + + plr[v7]._pBaseToBlk + - 2 * SLOBYTE(monster[v6].mLevel) + + 2 * plr[v7]._pLevel); + if ((signed int)v16 < 0) + v16 = 0; + if ((signed int)v16 > 100) + v16 = (int *)100; + if (v36 < v13) { + if (v15 >= (signed int)v16) { + if (monster[v6].MType->mtype == MT_YZOMBIE && plr_num == myplr) { + v18 = -1; + v19 = 0; + for (hper = -1; v19 < nummissiles; ++v19) { + v20 = missileactive[v19]; + if (missile[v20]._mitype == 13) { + if (missile[v20]._misource == plr_num) { + v18 = missileactive[v19]; + hper = missileactive[v19]; + } else { + v18 = hper; + } + } + } + v16 = &plr[v7]._pMaxHP; + v21 = plr[v7]._pMaxHP; + if (v21 > 64) { + v22 = plr[v7]._pMaxHPBase; + if (v22 > 64) { + v23 = v21 - 64; + v26 = __OFSUB__(plr[v7]._pHitPoints, v23); + v24 = plr[v7]._pHitPoints == v23; + v25 = plr[v7]._pHitPoints - v23 < 0; + *v16 = v23; + if (!((unsigned char)(v25 ^ v26) | v24)) { + plr[v7]._pHitPoints = v23; + if (v18 >= 0) + missile[v18]._miVar1 = v23; + } + v16 = &plr[v7]._pHPBase; + v27 = v22 - 64; + plr[v7]._pMaxHPBase = v22 - 64; + if (plr[v7]._pHPBase > v22 - 64) { + *v16 = v27; + if (v18 >= 0) + missile[v18]._miVar2 = v27; + } + } + } + } + v29 = (plr[v7]._pIGetHit << 6) + (MinDam << 6) + random(99, (MaxDam - MinDam + 1) << 6); + if (v29 < 64) + v29 = 64; + if (plr_num == myplr) { + plr[v7]._pHitPoints -= v29; + plr[v7]._pHPBase -= v29; + } + if (plr[v7]._pIFlags & 0x4000000) { + v30 = (random(99, 3) + 1) << 6; + monster[v6]._mhitpoints -= v30; + if (monster[v6]._mhitpoints >> 6 > 0) + M_StartHit(arglist, plr_num, v30); + else + M_StartKill(arglist, plr_num); + } + if (!(monster[v6]._mFlags & 0x1000) && monster[v6].MType->mtype == MT_SKING && gbMaxPlayers != 1) + monster[v6]._mhitpoints += v29; + v31 = plr[v7]._pMaxHP; + if (plr[v7]._pHitPoints > v31) { + plr[v7]._pHitPoints = v31; + plr[v7]._pHPBase = plr[v7]._pMaxHPBase; + } + if (plr[v7]._pHitPoints >> 6 > 0) { + StartPlrHit(plr_num, v29, 0); + if (SLOBYTE(monster[v6]._mFlags) < 0) { + if (plr[v7]._pmode != PM_GOTHIT) + StartPlrHit(plr_num, 0, 1u); + v32 = monster[v6]._mdir; + v33 = plr[v7].WorldX + offset_x[v32]; + v34 = plr[v7].WorldY + offset_y[v32]; + if (PosOkPlayer(plr_num, v33, v34)) { + v35 = plr[v7]._pdir; + plr[v7].WorldX = v33; + plr[v7].WorldY = v34; + FixPlayerLocation(plr_num, v35); + FixPlrWalkTags(plr_num); + dPlayer[v33][v34] = plr_num + 1; + SetPlayerOld(plr_num); + } + } + } else { + SyncPlrKill(plr_num, 0); + } + } else { + v17 = GetDirection(plr[v7].WorldX, plr[v7].WorldY, monster[v6]._mx, monster[v6]._my); + StartPlrBlock(plr_num, v17); + } + } + return; + } + } } // 679660: using guessed type char gbMaxPlayers; int __fastcall M_DoAttack(int i) { - int v1; // edi - int v2; // esi - CMonster **v3; // ebx - unsigned char v4; // al - unsigned char v5; // al + int v1; // edi + int v2; // esi + CMonster **v3; // ebx + unsigned char v4; // al + unsigned char v5; // al - v1 = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_DoAttack: Invalid monster %d", i); - v2 = v1; - v3 = &monster[v1].MType; - if (*v3 == NULL) { - TermMsg("M_DoAttack: Monster %d \"%s\" MType NULL", v1, monster[v2].mName); - if (*v3 == NULL) - TermMsg("M_DoAttack: Monster %d \"%s\" MData NULL", v1, monster[v2].mName); - } - if (monster[v2]._mAnimFrame == monster[v2].MData->mAFNum) { - M_TryH2HHit( - v1, - monster[v2]._menemy, - (unsigned char)monster[v2].mHit, - (unsigned char)monster[v2].mMinDamage, - (unsigned char)monster[v2].mMaxDamage); - if (monster[v2]._mAi != AI_SNAKE) - PlayEffect(v1, 0); - } - v4 = monster[v2].MType->mtype; - if (v4 >= MT_NMAGMA && v4 <= MT_WMAGMA && monster[v2]._mAnimFrame == 9) { - M_TryH2HHit( - v1, - monster[v2]._menemy, - (unsigned char)monster[v2].mHit + 10, - (unsigned char)monster[v2].mMinDamage - 2, - (unsigned char)monster[v2].mMaxDamage - 2); - PlayEffect(v1, 0); - } - v5 = monster[v2].MType->mtype; - if (v5 >= MT_STORM && v5 <= MT_MAEL && monster[v2]._mAnimFrame == 13) { - M_TryH2HHit( - v1, - monster[v2]._menemy, - (unsigned char)monster[v2].mHit - 20, - (unsigned char)monster[v2].mMinDamage + 4, - (unsigned char)monster[v2].mMaxDamage + 4); - PlayEffect(v1, 0); - } - if (monster[v2]._mAi == AI_SNAKE && monster[v2]._mAnimFrame == 1) - PlayEffect(v1, 0); - if (monster[v2]._mAnimFrame != monster[v2]._mAnimLen) - return 0; - M_StartStand(v1, monster[v2]._mdir); - return 1; + v1 = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("M_DoAttack: Invalid monster %d", i); + v2 = v1; + v3 = &monster[v1].MType; + if (*v3 == NULL) { + TermMsg("M_DoAttack: Monster %d \"%s\" MType NULL", v1, monster[v2].mName); + if (*v3 == NULL) + TermMsg("M_DoAttack: Monster %d \"%s\" MData NULL", v1, monster[v2].mName); + } + if (monster[v2]._mAnimFrame == monster[v2].MData->mAFNum) { + M_TryH2HHit( + v1, + monster[v2]._menemy, + (unsigned char)monster[v2].mHit, + (unsigned char)monster[v2].mMinDamage, + (unsigned char)monster[v2].mMaxDamage); + if (monster[v2]._mAi != AI_SNAKE) + PlayEffect(v1, 0); + } + v4 = monster[v2].MType->mtype; + if (v4 >= MT_NMAGMA && v4 <= MT_WMAGMA && monster[v2]._mAnimFrame == 9) { + M_TryH2HHit( + v1, + monster[v2]._menemy, + (unsigned char)monster[v2].mHit + 10, + (unsigned char)monster[v2].mMinDamage - 2, + (unsigned char)monster[v2].mMaxDamage - 2); + PlayEffect(v1, 0); + } + v5 = monster[v2].MType->mtype; + if (v5 >= MT_STORM && v5 <= MT_MAEL && monster[v2]._mAnimFrame == 13) { + M_TryH2HHit( + v1, + monster[v2]._menemy, + (unsigned char)monster[v2].mHit - 20, + (unsigned char)monster[v2].mMinDamage + 4, + (unsigned char)monster[v2].mMaxDamage + 4); + PlayEffect(v1, 0); + } + if (monster[v2]._mAi == AI_SNAKE && monster[v2]._mAnimFrame == 1) + PlayEffect(v1, 0); + if (monster[v2]._mAnimFrame != monster[v2]._mAnimLen) + return 0; + M_StartStand(v1, monster[v2]._mdir); + return 1; } int __fastcall M_DoRAttack(int i) { - int v1; // ebx - int v2; // esi - CMonster **v3; // edi - int v4; // eax - int v5; // eax - int v6; // edi + int v1; // ebx + int v2; // esi + CMonster **v3; // edi + int v4; // eax + int v5; // eax + int v6; // edi - v1 = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_DoRAttack: Invalid monster %d", i); - v2 = v1; - v3 = &monster[v1].MType; - if (*v3 == NULL) { - TermMsg("M_DoRAttack: Monster %d \"%s\" MType NULL", v1, monster[v2].mName); - if (*v3 == NULL) - TermMsg("M_DoRAttack: Monster %d \"%s\" MData NULL", v1, monster[v2].mName); - } - if (monster[v2]._mAnimFrame == monster[v2].MData->mAFNum) { - v4 = monster[v2]._mVar1; - if (v4 != -1) { - v5 = 2 * (v4 == 52) + 1; - if (v5 > 0) { - v6 = v5; - do { - AddMissile( - monster[v2]._mx, - monster[v2]._my, - (unsigned char)monster[v2]._menemyx, - (unsigned char)monster[v2]._menemyy, - monster[v2]._mdir, - monster[v2]._mVar1, - 1, - v1, - monster[v2]._mVar2, - 0); - --v6; - } while (v6); - } - } - PlayEffect(v1, 0); - } - if (monster[v2]._mAnimFrame != monster[v2]._mAnimLen) - return 0; - M_StartStand(v1, monster[v2]._mdir); - return 1; + v1 = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("M_DoRAttack: Invalid monster %d", i); + v2 = v1; + v3 = &monster[v1].MType; + if (*v3 == NULL) { + TermMsg("M_DoRAttack: Monster %d \"%s\" MType NULL", v1, monster[v2].mName); + if (*v3 == NULL) + TermMsg("M_DoRAttack: Monster %d \"%s\" MData NULL", v1, monster[v2].mName); + } + if (monster[v2]._mAnimFrame == monster[v2].MData->mAFNum) { + v4 = monster[v2]._mVar1; + if (v4 != -1) { + v5 = 2 * (v4 == 52) + 1; + if (v5 > 0) { + v6 = v5; + do { + AddMissile( + monster[v2]._mx, + monster[v2]._my, + (unsigned char)monster[v2]._menemyx, + (unsigned char)monster[v2]._menemyy, + monster[v2]._mdir, + monster[v2]._mVar1, + 1, + v1, + monster[v2]._mVar2, + 0); + --v6; + } while (v6); + } + } + PlayEffect(v1, 0); + } + if (monster[v2]._mAnimFrame != monster[v2]._mAnimLen) + return 0; + M_StartStand(v1, monster[v2]._mdir); + return 1; } int __fastcall M_DoRSpAttack(int i) { - int v1; // ebx - int v2; // esi - CMonster **v3; // edi - bool v4; // zf - int v5; // ecx + int v1; // ebx + int v2; // esi + CMonster **v3; // edi + bool v4; // zf + int v5; // ecx - v1 = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_DoRSpAttack: Invalid monster %d", i); - v2 = v1; - v3 = &monster[v1].MType; - v4 = *v3 == 0; - if (*v3 == NULL) { - TermMsg("M_DoRSpAttack: Monster %d \"%s\" MType NULL", v1, monster[v2].mName); - v4 = *v3 == NULL; - } - if (v4) - TermMsg("M_DoRSpAttack: Monster %d \"%s\" MData NULL", v1, monster[v2].mName); - if (monster[v2]._mAnimFrame == monster[v2].MData->mAFNum2 && !monster[v2]._mAnimCnt) { - AddMissile( - monster[v2]._mx, - monster[v2]._my, - (unsigned char)monster[v2]._menemyx, - (unsigned char)monster[v2]._menemyy, - monster[v2]._mdir, - monster[v2]._mVar1, - 1, - v1, - monster[v2]._mVar3, - 0); - PlayEffect(v1, 3); - } - if (monster[v2]._mAi == AI_MEGA && monster[v2]._mAnimFrame == 3) { - v5 = monster[v2]._mVar2; - monster[v2]._mVar2 = v5 + 1; - if (v5) { - if (v5 == 14) - monster[v2]._mFlags &= 0xFFFFFFFB; - } else { - monster[v2]._mFlags |= 4u; - } - } - if (monster[v2]._mAnimFrame != monster[v2]._mAnimLen) - return 0; - M_StartStand(v1, monster[v2]._mdir); - return 1; + v1 = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("M_DoRSpAttack: Invalid monster %d", i); + v2 = v1; + v3 = &monster[v1].MType; + v4 = *v3 == 0; + if (*v3 == NULL) { + TermMsg("M_DoRSpAttack: Monster %d \"%s\" MType NULL", v1, monster[v2].mName); + v4 = *v3 == NULL; + } + if (v4) + TermMsg("M_DoRSpAttack: Monster %d \"%s\" MData NULL", v1, monster[v2].mName); + if (monster[v2]._mAnimFrame == monster[v2].MData->mAFNum2 && !monster[v2]._mAnimCnt) { + AddMissile( + monster[v2]._mx, + monster[v2]._my, + (unsigned char)monster[v2]._menemyx, + (unsigned char)monster[v2]._menemyy, + monster[v2]._mdir, + monster[v2]._mVar1, + 1, + v1, + monster[v2]._mVar3, + 0); + PlayEffect(v1, 3); + } + if (monster[v2]._mAi == AI_MEGA && monster[v2]._mAnimFrame == 3) { + v5 = monster[v2]._mVar2; + monster[v2]._mVar2 = v5 + 1; + if (v5) { + if (v5 == 14) + monster[v2]._mFlags &= 0xFFFFFFFB; + } else { + monster[v2]._mFlags |= 4u; + } + } + if (monster[v2]._mAnimFrame != monster[v2]._mAnimLen) + return 0; + M_StartStand(v1, monster[v2]._mdir); + return 1; } int __fastcall M_DoSAttack(int i) { - int v1; // ebx - int v2; // esi - CMonster **v3; // edi - bool v4; // zf + int v1; // ebx + int v2; // esi + CMonster **v3; // edi + bool v4; // zf - v1 = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_DoSAttack: Invalid monster %d", i); - v2 = v1; - v3 = &monster[v1].MType; - v4 = *v3 == NULL; - if (*v3 == NULL) { - TermMsg("M_DoSAttack: Monster %d \"%s\" MType NULL", v1, monster[v2].mName); - v4 = *v3 == NULL; - } - if (v4) - TermMsg("M_DoSAttack: Monster %d \"%s\" MData NULL", v1, monster[v2].mName); - if (monster[v2]._mAnimFrame == monster[v2].MData->mAFNum2) - M_TryH2HHit( - v1, - monster[v2]._menemy, - (unsigned char)monster[v2].mHit2, - (unsigned char)monster[v2].mMinDamage2, - (unsigned char)monster[v2].mMaxDamage2); - if (monster[v2]._mAnimFrame != monster[v2]._mAnimLen) - return 0; - M_StartStand(v1, monster[v2]._mdir); - return 1; + v1 = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("M_DoSAttack: Invalid monster %d", i); + v2 = v1; + v3 = &monster[v1].MType; + v4 = *v3 == NULL; + if (*v3 == NULL) { + TermMsg("M_DoSAttack: Monster %d \"%s\" MType NULL", v1, monster[v2].mName); + v4 = *v3 == NULL; + } + if (v4) + TermMsg("M_DoSAttack: Monster %d \"%s\" MData NULL", v1, monster[v2].mName); + if (monster[v2]._mAnimFrame == monster[v2].MData->mAFNum2) + M_TryH2HHit( + v1, + monster[v2]._menemy, + (unsigned char)monster[v2].mHit2, + (unsigned char)monster[v2].mMinDamage2, + (unsigned char)monster[v2].mMaxDamage2); + if (monster[v2]._mAnimFrame != monster[v2]._mAnimLen) + return 0; + M_StartStand(v1, monster[v2]._mdir); + return 1; } int __fastcall M_DoFadein(int i) { - int v1; // edi - int v2; // esi + int v1; // edi + int v2; // esi - v1 = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_DoFadein: Invalid monster %d", i); - v2 = v1; - if ((!(monster[v1]._mFlags & 2) || monster[v2]._mAnimFrame != 1) - && (monster[v1]._mFlags & 2 || monster[v2]._mAnimFrame != monster[v2]._mAnimLen)) { - return 0; - } - M_StartStand(v1, monster[v2]._mdir); - monster[v2]._mFlags &= 0xFFFFFFFD; - return 1; + v1 = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("M_DoFadein: Invalid monster %d", i); + v2 = v1; + if ((!(monster[v1]._mFlags & 2) || monster[v2]._mAnimFrame != 1) + && (monster[v1]._mFlags & 2 || monster[v2]._mAnimFrame != monster[v2]._mAnimLen)) { + return 0; + } + M_StartStand(v1, monster[v2]._mdir); + monster[v2]._mFlags &= 0xFFFFFFFD; + return 1; } int __fastcall M_DoFadeout(int i) { - int v1; // esi - int v2; // eax - int v3; // ecx - signed int v4; // edx - int v5; // ecx - int v6; // edx + int v1; // esi + int v2; // eax + int v3; // ecx + signed int v4; // edx + int v5; // ecx + int v6; // edx - v1 = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_DoFadeout: Invalid monster %d", i); - v2 = v1; - v3 = monster[v1]._mFlags; - if ((!(monster[v1]._mFlags & 2) || monster[v2]._mAnimFrame != 1) - && (monster[v1]._mFlags & 2 || monster[v2]._mAnimFrame != monster[v2]._mAnimLen)) { - return 0; - } - v4 = monster[v2].MType->mtype; - if (v4 < MT_INCIN || v4 > MT_HELLBURN) - v5 = v3 & 0xFFFFFFFD | 1; - else - v5 = v3 & 0xFFFFFFFD; - v6 = monster[v2]._mdir; - monster[v2]._mFlags = v5; - M_StartStand(v1, v6); - return 1; + v1 = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("M_DoFadeout: Invalid monster %d", i); + v2 = v1; + v3 = monster[v1]._mFlags; + if ((!(monster[v1]._mFlags & 2) || monster[v2]._mAnimFrame != 1) + && (monster[v1]._mFlags & 2 || monster[v2]._mAnimFrame != monster[v2]._mAnimLen)) { + return 0; + } + v4 = monster[v2].MType->mtype; + if (v4 < MT_INCIN || v4 > MT_HELLBURN) + v5 = v3 & 0xFFFFFFFD | 1; + else + v5 = v3 & 0xFFFFFFFD; + v6 = monster[v2]._mdir; + monster[v2]._mFlags = v5; + M_StartStand(v1, v6); + return 1; } int __fastcall M_DoHeal(int i) { - int v1; // esi - int v2; // eax - int v3; // esi - int *v4; // edx - int v5; // ecx - int v6; // edi - int v7; // edi - int v8; // esi + int v1; // esi + int v2; // eax + int v3; // esi + int *v4; // edx + int v5; // ecx + int v6; // edi + int v7; // edi + int v8; // esi - v1 = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_DoHeal: Invalid monster %d", i); - v2 = v1; - if (monster[v1]._mFlags & 8) { - monster[v2]._mFlags &= 0xFFFFFFFB; - monster[v2]._mmode = MM_SATTACK; - } else if (monster[v2]._mAnimFrame == 1) { - v3 = monster[v2]._mVar1; - v4 = &monster[v2]._mhitpoints; - v5 = monster[v2]._mFlags & 0xFFFFFFFD | 4; - v6 = monster[v2]._mhitpoints; - monster[v2]._mFlags = v5; - v7 = v3 + v6; - v8 = monster[v2]._mmaxhp; - if (v7 >= v8) { - *v4 = v8; - monster[v2]._mFlags = v5 & 0xFFFFFFFB; - monster[v2]._mmode = MM_SATTACK; - } else { - *v4 = v7; - } - } - return 0; + v1 = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("M_DoHeal: Invalid monster %d", i); + v2 = v1; + if (monster[v1]._mFlags & 8) { + monster[v2]._mFlags &= 0xFFFFFFFB; + monster[v2]._mmode = MM_SATTACK; + } else if (monster[v2]._mAnimFrame == 1) { + v3 = monster[v2]._mVar1; + v4 = &monster[v2]._mhitpoints; + v5 = monster[v2]._mFlags & 0xFFFFFFFD | 4; + v6 = monster[v2]._mhitpoints; + monster[v2]._mFlags = v5; + v7 = v3 + v6; + v8 = monster[v2]._mmaxhp; + if (v7 >= v8) { + *v4 = v8; + monster[v2]._mFlags = v5 & 0xFFFFFFFB; + monster[v2]._mmode = MM_SATTACK; + } else { + *v4 = v7; + } + } + return 0; } int __fastcall M_DoTalk(int i) { - int v1; // edi - int v2; // esi - //int v3; // eax - int v4; // eax - int v5; // edx - int v6; // ecx - char v7; // bl - int v8; // eax - char *v9; // eax + int v1; // edi + int v2; // esi + //int v3; // eax + int v4; // eax + int v5; // edx + int v6; // ecx + char v7; // bl + int v8; // eax + char *v9; // eax - v1 = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_DoTalk: Invalid monster %d", i); - v2 = v1; - M_StartStand(v1, monster[v1]._mdir); - _LOBYTE(monster[v1]._mgoal) = 7; - //_LOBYTE(v3) = effect_is_playing(alltext[monster[v1].mtalkmsg].sfxnr); - if (!effect_is_playing(alltext[monster[v1].mtalkmsg].sfxnr)) { - InitQTextMsg(monster[v2].mtalkmsg); - if (monster[v2].mName == UniqMonst[0].mName) { - v4 = monster[v2].mtalkmsg; - if (v4 == QUEST_GARBUD1) - quests[QTYPE_GARB]._qactive = 2; - quests[QTYPE_GARB]._qlog = 1; - if (v4 == QUEST_GARBUD2 && !(monster[v2]._mFlags & 0x40)) { - SpawnItem(v1, monster[v2]._mx + 1, monster[v2]._my + 1, 1u); - monster[v2]._mFlags |= 0x40u; - } - } - if (monster[v2].mName == UniqMonst[2].mName - && monster[v2].mtalkmsg == QUEST_ZHAR1 - && !(monster[v2]._mFlags & 0x40)) { - v5 = monster[v2]._my + 1; - v6 = monster[v2]._mx + 1; - quests[QTYPE_ZHAR]._qactive = 2; - quests[QTYPE_ZHAR]._qlog = 1; - CreateTypeItem(v6, v5, 0, 0, 24, 1, 0); - monster[v2]._mFlags |= 0x40u; - } - if (monster[v2].mName == UniqMonst[3].mName) { - if (monster[v2].mtalkmsg == QUEST_BANNER10 && !(monster[v2]._mFlags & 0x40)) { - ObjChangeMap(setpc_x, setpc_y, (setpc_w >> 1) + setpc_x + 2, (setpc_h >> 1) + setpc_y - 2); - v7 = TransVal; - TransVal = 9; - DRLG_MRectTrans(setpc_x, setpc_y, (setpc_w >> 1) + setpc_x + 4, setpc_y + (setpc_h >> 1)); - TransVal = v7; - quests[QTYPE_BOL]._qvar1 = 2; - if (quests[QTYPE_BOL]._qactive == 1) - quests[QTYPE_BOL]._qactive = 2; - monster[v2]._mFlags |= 0x40u; - } - if (quests[QTYPE_BOL]._qvar1 < 2u) { - sprintf(tempstr, "SS Talk = %i, Flags = %i", monster[v2].mtalkmsg, monster[v2]._mFlags); - TermMsg(tempstr); - } - } - if (monster[v2].mName == UniqMonst[7].mName) { - v8 = monster[v2].mtalkmsg; - if (v8 == QUEST_VEIL9) { - quests[QTYPE_VEIL]._qactive = 2; - quests[QTYPE_VEIL]._qlog = 1; - } - if (v8 == QUEST_VEIL11 && !(monster[v2]._mFlags & 0x40)) { - SpawnUnique(UITEM_STEELVEIL, monster[v2]._mx + 1, monster[v2]._my + 1); - monster[v2]._mFlags |= 0x40u; - } - } - v9 = monster[v2].mName; - if (v9 == UniqMonst[8].mName) - quests[QTYPE_WARLRD]._qvar1 = 2; - if (v9 == UniqMonst[4].mName && gbMaxPlayers != 1) { - monster[v2]._msquelch = -1; - monster[v2].mtalkmsg = 0; - quests[QTYPE_VB]._qvar1 = 6; - _LOBYTE(monster[v2]._mgoal) = 1; - } - } - return 0; + v1 = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("M_DoTalk: Invalid monster %d", i); + v2 = v1; + M_StartStand(v1, monster[v1]._mdir); + _LOBYTE(monster[v1]._mgoal) = 7; + //_LOBYTE(v3) = effect_is_playing(alltext[monster[v1].mtalkmsg].sfxnr); + if (!effect_is_playing(alltext[monster[v1].mtalkmsg].sfxnr)) { + InitQTextMsg(monster[v2].mtalkmsg); + if (monster[v2].mName == UniqMonst[0].mName) { + v4 = monster[v2].mtalkmsg; + if (v4 == QUEST_GARBUD1) + quests[QTYPE_GARB]._qactive = 2; + quests[QTYPE_GARB]._qlog = 1; + if (v4 == QUEST_GARBUD2 && !(monster[v2]._mFlags & 0x40)) { + SpawnItem(v1, monster[v2]._mx + 1, monster[v2]._my + 1, 1u); + monster[v2]._mFlags |= 0x40u; + } + } + if (monster[v2].mName == UniqMonst[2].mName + && monster[v2].mtalkmsg == QUEST_ZHAR1 + && !(monster[v2]._mFlags & 0x40)) { + v5 = monster[v2]._my + 1; + v6 = monster[v2]._mx + 1; + quests[QTYPE_ZHAR]._qactive = 2; + quests[QTYPE_ZHAR]._qlog = 1; + CreateTypeItem(v6, v5, 0, 0, 24, 1, 0); + monster[v2]._mFlags |= 0x40u; + } + if (monster[v2].mName == UniqMonst[3].mName) { + if (monster[v2].mtalkmsg == QUEST_BANNER10 && !(monster[v2]._mFlags & 0x40)) { + ObjChangeMap(setpc_x, setpc_y, (setpc_w >> 1) + setpc_x + 2, (setpc_h >> 1) + setpc_y - 2); + v7 = TransVal; + TransVal = 9; + DRLG_MRectTrans(setpc_x, setpc_y, (setpc_w >> 1) + setpc_x + 4, setpc_y + (setpc_h >> 1)); + TransVal = v7; + quests[QTYPE_BOL]._qvar1 = 2; + if (quests[QTYPE_BOL]._qactive == 1) + quests[QTYPE_BOL]._qactive = 2; + monster[v2]._mFlags |= 0x40u; + } + if (quests[QTYPE_BOL]._qvar1 < 2u) { + sprintf(tempstr, "SS Talk = %i, Flags = %i", monster[v2].mtalkmsg, monster[v2]._mFlags); + TermMsg(tempstr); + } + } + if (monster[v2].mName == UniqMonst[7].mName) { + v8 = monster[v2].mtalkmsg; + if (v8 == QUEST_VEIL9) { + quests[QTYPE_VEIL]._qactive = 2; + quests[QTYPE_VEIL]._qlog = 1; + } + if (v8 == QUEST_VEIL11 && !(monster[v2]._mFlags & 0x40)) { + SpawnUnique(UITEM_STEELVEIL, monster[v2]._mx + 1, monster[v2]._my + 1); + monster[v2]._mFlags |= 0x40u; + } + } + v9 = monster[v2].mName; + if (v9 == UniqMonst[8].mName) + quests[QTYPE_WARLRD]._qvar1 = 2; + if (v9 == UniqMonst[4].mName && gbMaxPlayers != 1) { + monster[v2]._msquelch = -1; + monster[v2].mtalkmsg = 0; + quests[QTYPE_VB]._qvar1 = 6; + _LOBYTE(monster[v2]._mgoal) = 1; + } + } + return 0; } // 4351F5: could not find valid save-restore pair for ebp // 5A5590: using guessed type char TransVal; @@ -3105,176 +3105,176 @@ int __fastcall M_DoTalk(int i) void __fastcall M_Teleport(int i) { - int v1; // ebx - //int v2; // ST04_4 - MonsterStruct *v3; // esi - int v4; // eax - int v6; // edi - int v7; // ebx - int v8; // eax - int v9; // [esp+Ch] [ebp-24h] - int v10; // [esp+10h] [ebp-20h] - int v11; // [esp+14h] [ebp-1Ch] - int v12; // [esp+18h] [ebp-18h] - int v13; // [esp+1Ch] [ebp-14h] - int a1; // [esp+20h] [ebp-10h] - signed int v15; // [esp+24h] [ebp-Ch] - signed int v16; // [esp+28h] [ebp-8h] - signed int v17; // [esp+2Ch] [ebp-4h] + int v1; // ebx + //int v2; // ST04_4 + MonsterStruct *v3; // esi + int v4; // eax + int v6; // edi + int v7; // ebx + int v8; // eax + int v9; // [esp+Ch] [ebp-24h] + int v10; // [esp+10h] [ebp-20h] + int v11; // [esp+14h] [ebp-1Ch] + int v12; // [esp+18h] [ebp-18h] + int v13; // [esp+1Ch] [ebp-14h] + int a1; // [esp+20h] [ebp-10h] + signed int v15; // [esp+24h] [ebp-Ch] + signed int v16; // [esp+28h] [ebp-8h] + signed int v17; // [esp+2Ch] [ebp-4h] - v1 = i; - a1 = i; - if ((DWORD)i >= MAXMONSTERS) { - TermMsg("M_Teleport: Invalid monster %d", i); - //i = v2; - } - v15 = 0; - v3 = &monster[v1]; - if (v3->_mmode != MM_STONE) { - v10 = (unsigned char)v3->_menemyx; - v12 = (unsigned char)v3->_menemyy; - v4 = random(100, 2); - v11 = 2 * v4 - 1; - v17 = -1; - v6 = 0; /* v9 */ - v13 = 2 * random(100, 2) - 1; - while (!v15) { - v16 = -1; - v7 = v12 - v13; - do { - if (v15) - break; - if (v17 || v16) { - v9 = v7; - v6 = v10 + v11 * v17; - if (v7 >= 0 && v7 < 112 && v6 >= 0 && v6 < 112 && v6 != v3->_mx && v7 != v3->_my) { - if (PosOkMonst(a1, v10 + v11 * v17, v7)) - v15 = 1; - } - } - ++v16; - v7 += v13; - } while (v16 < 1); - if (++v17 > 1) { - if (!v15) - return; - v1 = a1; - break; - } - v1 = a1; - } - M_ClearSquares(v1); - v8 = v3->_my + 112 * v3->_mx; - v3->_moldx = v6; - dMonster[0][v8] = 0; - v3->_moldy = v9; - dMonster[0][v9 + 112 * v6] = v1 + 1; - v3->_mdir = M_GetDir(v1); - M_CheckEFlag(v1); - } + v1 = i; + a1 = i; + if ((DWORD)i >= MAXMONSTERS) { + TermMsg("M_Teleport: Invalid monster %d", i); + //i = v2; + } + v15 = 0; + v3 = &monster[v1]; + if (v3->_mmode != MM_STONE) { + v10 = (unsigned char)v3->_menemyx; + v12 = (unsigned char)v3->_menemyy; + v4 = random(100, 2); + v11 = 2 * v4 - 1; + v17 = -1; + v6 = 0; /* v9 */ + v13 = 2 * random(100, 2) - 1; + while (!v15) { + v16 = -1; + v7 = v12 - v13; + do { + if (v15) + break; + if (v17 || v16) { + v9 = v7; + v6 = v10 + v11 * v17; + if (v7 >= 0 && v7 < 112 && v6 >= 0 && v6 < 112 && v6 != v3->_mx && v7 != v3->_my) { + if (PosOkMonst(a1, v10 + v11 * v17, v7)) + v15 = 1; + } + } + ++v16; + v7 += v13; + } while (v16 < 1); + if (++v17 > 1) { + if (!v15) + return; + v1 = a1; + break; + } + v1 = a1; + } + M_ClearSquares(v1); + v8 = v3->_my + 112 * v3->_mx; + v3->_moldx = v6; + dMonster[0][v8] = 0; + v3->_moldy = v9; + dMonster[0][v9 + 112 * v6] = v1 + 1; + v3->_mdir = M_GetDir(v1); + M_CheckEFlag(v1); + } } int __fastcall M_DoGotHit(int i) { - int v1; // edi - int v2; // esi + int v1; // edi + int v2; // esi - v1 = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_DoGotHit: Invalid monster %d", i); - v2 = v1; - if (monster[v1].MType == NULL) - TermMsg("M_DoGotHit: Monster %d \"%s\" MType NULL", v1, monster[v2].mName); - if (monster[v2]._mAnimFrame != monster[v2]._mAnimLen) - return 0; - M_StartStand(v1, monster[v2]._mdir); - return 1; + v1 = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("M_DoGotHit: Invalid monster %d", i); + v2 = v1; + if (monster[v1].MType == NULL) + TermMsg("M_DoGotHit: Monster %d \"%s\" MType NULL", v1, monster[v2].mName); + if (monster[v2]._mAnimFrame != monster[v2]._mAnimLen) + return 0; + M_StartStand(v1, monster[v2]._mdir); + return 1; } void __fastcall M_UpdateLeader(int i) { - int v1; // edi - int v2; // esi - int j; // edx - int v4; // eax - unsigned char *v5; // eax + int v1; // edi + int v2; // esi + int j; // edx + int v4; // eax + unsigned char *v5; // eax - v1 = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_UpdateLeader: Invalid monster %d", i); - v2 = nummonsters; - for (j = 0; j < v2; ++j) { - v4 = monstactive[j]; - if (monster[v4].leaderflag == 1 && (unsigned char)monster[v4].leader == v1) - monster[v4].leaderflag = 0; - } - if (monster[v1].leaderflag == 1) { - v5 = &monster[(unsigned char)monster[v1].leader].unpackfilesize; - --*v5; - } + v1 = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("M_UpdateLeader: Invalid monster %d", i); + v2 = nummonsters; + for (j = 0; j < v2; ++j) { + v4 = monstactive[j]; + if (monster[v4].leaderflag == 1 && (unsigned char)monster[v4].leader == v1) + monster[v4].leaderflag = 0; + } + if (monster[v1].leaderflag == 1) { + v5 = &monster[(unsigned char)monster[v1].leader].unpackfilesize; + --*v5; + } } void __cdecl DoEnding() { - if (gbMaxPlayers > 1) { - SNetLeaveGame(0x40000004); - } + if (gbMaxPlayers > 1) { + SNetLeaveGame(0x40000004); + } - music_stop(); + music_stop(); - if (gbMaxPlayers > 1) { - Sleep(1000); - } + if (gbMaxPlayers > 1) { + Sleep(1000); + } - if (plr[myplr]._pClass == PC_WARRIOR) { - play_movie("gendata\\DiabVic2.smk", 0); - } else if (plr[myplr]._pClass == PC_SORCERER) { - play_movie("gendata\\DiabVic1.smk", 0); - } else { - play_movie("gendata\\DiabVic3.smk", 0); - } - play_movie("gendata\\Diabend.smk", 0); + if (plr[myplr]._pClass == PC_WARRIOR) { + play_movie("gendata\\DiabVic2.smk", 0); + } else if (plr[myplr]._pClass == PC_SORCERER) { + play_movie("gendata\\DiabVic1.smk", 0); + } else { + play_movie("gendata\\DiabVic3.smk", 0); + } + play_movie("gendata\\Diabend.smk", 0); - BOOL bMusicOn = gbMusicOn; - gbMusicOn = TRUE; + BOOL bMusicOn = gbMusicOn; + gbMusicOn = TRUE; - int musicVolume = sound_get_or_set_music_volume(1); - sound_get_or_set_music_volume(0); + int musicVolume = sound_get_or_set_music_volume(1); + sound_get_or_set_music_volume(0); - music_start(2); - loop_movie = TRUE; - play_movie("gendata\\loopdend.smk", 1); - loop_movie = FALSE; - music_stop(); + music_start(2); + loop_movie = TRUE; + play_movie("gendata\\loopdend.smk", 1); + loop_movie = FALSE; + music_stop(); - sound_get_or_set_music_volume(musicVolume); - gbMusicOn = bMusicOn; + sound_get_or_set_music_volume(musicVolume); + gbMusicOn = bMusicOn; } // 679660: using guessed type char gbMaxPlayers; void __cdecl PrepDoEnding() { - gbSoundOn = sgbSaveSoundOn; - gbRunGame = FALSE; - deathflag = FALSE; - cineflag = TRUE; + gbSoundOn = sgbSaveSoundOn; + gbRunGame = FALSE; + deathflag = FALSE; + cineflag = TRUE; - DWORD *killLevel = &plr[myplr].pDiabloKillLevel; - int newKillLevel = gnDifficulty + 1; - if (*killLevel > newKillLevel) - newKillLevel = *killLevel; - plr[myplr].pDiabloKillLevel = newKillLevel; + DWORD *killLevel = &plr[myplr].pDiabloKillLevel; + int newKillLevel = gnDifficulty + 1; + if (*killLevel > newKillLevel) + newKillLevel = *killLevel; + plr[myplr].pDiabloKillLevel = newKillLevel; - for (int i = 0; i < MAX_PLRS; i++) { - plr[i]._pmode = PM_QUIT; - plr[i]._pBlockFlag = TRUE; - if (gbMaxPlayers > 1) { - if (plr[i]._pHitPoints >> 6 == 0) - plr[i]._pHitPoints = 64; - if (plr[i]._pMana >> 6 == 0) - plr[i]._pMana = 64; - } - } + for (int i = 0; i < MAX_PLRS; i++) { + plr[i]._pmode = PM_QUIT; + plr[i]._pBlockFlag = TRUE; + if (gbMaxPlayers > 1) { + if (plr[i]._pHitPoints >> 6 == 0) + plr[i]._pHitPoints = 64; + if (plr[i]._pMana >> 6 == 0) + plr[i]._pMana = 64; + } + } } // 525718: using guessed type char cineflag; // 64D32C: using guessed type int sgbSaveSoundOn; @@ -3282,4401 +3282,4401 @@ void __cdecl PrepDoEnding() int __fastcall M_DoDeath(int i) { - int v1; // edi - int v2; // esi - CMonster *v3; // ecx - int v4; // eax - int v5; // ecx - signed int v6; // ecx - int v7; // esi - int v8; // esi - signed int v9; // ecx - char v10; // al - int v11; // eax + int v1; // edi + int v2; // esi + CMonster *v3; // ecx + int v4; // eax + int v5; // ecx + signed int v6; // ecx + int v7; // esi + int v8; // esi + signed int v9; // ecx + char v10; // al + int v11; // eax - v1 = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_DoDeath: Invalid monster %d", i); - v2 = v1; - if (monster[v1].MType == NULL) - TermMsg("M_DoDeath: Monster %d \"%s\" MType NULL", v1, monster[v2].mName); - v3 = monster[v2].MType; - v4 = ++monster[v2]._mVar1; - if (v3->mtype == MT_DIABLO) { - v5 = monster[v2]._mx - ViewX; - if (v5 >= 0) - v6 = v5 > 0; - else - v6 = -1; - v7 = monster[v2]._my; - ViewX += v6; - v8 = v7 - ViewY; - if (v8 >= 0) { - v9 = v8 < 0; - _LOBYTE(v9) = v8 > 0; - } else { - v9 = -1; - } - ViewY += v9; - if (v4 == 140) - PrepDoEnding(); - } else if (monster[v2]._mAnimFrame == monster[v2]._mAnimLen) { - if (monster[v2]._uniqtype != 0) - v10 = monster[v2]._udeadval; - else - v10 = v3->mdeadval; - AddDead(monster[v2]._mx, monster[v2]._my, v10, (direction)monster[v2]._mdir); - v11 = monster[v2]._my + 112 * monster[v2]._mx; - monster[v2]._mDelFlag = TRUE; - dMonster[0][v11] = 0; - M_UpdateLeader(v1); - } - return 0; + v1 = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("M_DoDeath: Invalid monster %d", i); + v2 = v1; + if (monster[v1].MType == NULL) + TermMsg("M_DoDeath: Monster %d \"%s\" MType NULL", v1, monster[v2].mName); + v3 = monster[v2].MType; + v4 = ++monster[v2]._mVar1; + if (v3->mtype == MT_DIABLO) { + v5 = monster[v2]._mx - ViewX; + if (v5 >= 0) + v6 = v5 > 0; + else + v6 = -1; + v7 = monster[v2]._my; + ViewX += v6; + v8 = v7 - ViewY; + if (v8 >= 0) { + v9 = v8 < 0; + _LOBYTE(v9) = v8 > 0; + } else { + v9 = -1; + } + ViewY += v9; + if (v4 == 140) + PrepDoEnding(); + } else if (monster[v2]._mAnimFrame == monster[v2]._mAnimLen) { + if (monster[v2]._uniqtype != 0) + v10 = monster[v2]._udeadval; + else + v10 = v3->mdeadval; + AddDead(monster[v2]._mx, monster[v2]._my, v10, (direction)monster[v2]._mdir); + v11 = monster[v2]._my + 112 * monster[v2]._mx; + monster[v2]._mDelFlag = TRUE; + dMonster[0][v11] = 0; + M_UpdateLeader(v1); + } + return 0; } int __fastcall M_DoSpStand(int i) { - int v1; // ebx - int v2; // esi + int v1; // ebx + int v2; // esi - v1 = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_DoSpStand: Invalid monster %d", i); - v2 = v1; - if (monster[v1].MType == NULL) - TermMsg("M_DoSpStand: Monster %d \"%s\" MType NULL", v1, monster[v2].mName); - if (monster[v2]._mAnimFrame == monster[v2].MData->mAFNum2) - PlayEffect(v1, 3); - if (monster[v2]._mAnimFrame != monster[v2]._mAnimLen) - return 0; - M_StartStand(v1, monster[v2]._mdir); - return 1; + v1 = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("M_DoSpStand: Invalid monster %d", i); + v2 = v1; + if (monster[v1].MType == NULL) + TermMsg("M_DoSpStand: Monster %d \"%s\" MType NULL", v1, monster[v2].mName); + if (monster[v2]._mAnimFrame == monster[v2].MData->mAFNum2) + PlayEffect(v1, 3); + if (monster[v2]._mAnimFrame != monster[v2]._mAnimLen) + return 0; + M_StartStand(v1, monster[v2]._mdir); + return 1; } int __fastcall M_DoDelay(int i) { - int v1; // ebp - int v2; // esi - int v3; // eax - bool v4; // zf - int v5; // ecx - int v6; // ecx - int v7; // ebx + int v1; // ebp + int v2; // esi + int v3; // eax + bool v4; // zf + int v5; // ecx + int v6; // ecx + int v7; // ebx - v1 = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_DoDelay: Invalid monster %d", i); - v2 = v1; - if (monster[v1].MType == NULL) - TermMsg("M_DoDelay: Monster %d \"%s\" MType NULL", v1, monster[v2].mName); - v3 = M_GetDir(v1); - v4 = monster[v2]._mAi == AI_LAZURUS; - monster[v2]._mAnimData = monster[v2].MType->Anims[MA_STAND].Data[v3]; - if (v4) { - v5 = monster[v2]._mVar2; - if (v5 > 8 || v5 < 0) - monster[v2]._mVar2 = 8; - } - v6 = monster[v2]._mVar2; - monster[v2]._mVar2 = v6 - 1; - if (v6) - return 0; - v7 = monster[v2]._mAnimFrame; - M_StartStand(v1, monster[v2]._mdir); - monster[v2]._mAnimFrame = v7; - return 1; + v1 = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("M_DoDelay: Invalid monster %d", i); + v2 = v1; + if (monster[v1].MType == NULL) + TermMsg("M_DoDelay: Monster %d \"%s\" MType NULL", v1, monster[v2].mName); + v3 = M_GetDir(v1); + v4 = monster[v2]._mAi == AI_LAZURUS; + monster[v2]._mAnimData = monster[v2].MType->Anims[MA_STAND].Data[v3]; + if (v4) { + v5 = monster[v2]._mVar2; + if (v5 > 8 || v5 < 0) + monster[v2]._mVar2 = 8; + } + v6 = monster[v2]._mVar2; + monster[v2]._mVar2 = v6 - 1; + if (v6) + return 0; + v7 = monster[v2]._mAnimFrame; + M_StartStand(v1, monster[v2]._mdir); + monster[v2]._mAnimFrame = v7; + return 1; } int __fastcall M_DoStone(int i) { - int v1; // esi - int v2; // eax - int v3; // ecx + int v1; // esi + int v2; // eax + int v3; // ecx - v1 = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_DoStone: Invalid monster %d", i); - v2 = v1; - if (!monster[v1]._mhitpoints) { - v3 = monster[v2]._mx; - monster[v2]._mDelFlag = TRUE; - dMonster[0][monster[v2]._my + 112 * v3] = 0; - } - return 0; + v1 = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("M_DoStone: Invalid monster %d", i); + v2 = v1; + if (!monster[v1]._mhitpoints) { + v3 = monster[v2]._mx; + monster[v2]._mDelFlag = TRUE; + dMonster[0][monster[v2]._my + 112 * v3] = 0; + } + return 0; } void __fastcall M_WalkDir(int i, int md) { - int v2; // esi - int v3; // edi - int v4; // eax - int v5; // eax - int v6; // edx - int v7; // ecx - int v8; // eax - int v9; // edx - int v10; // eax - int v11; // [esp-14h] [ebp-1Ch] - int v12; // [esp-Ch] [ebp-14h] - int v13; // [esp-Ch] [ebp-14h] - int v14; // [esp-8h] [ebp-10h] - int v15; // [esp-8h] [ebp-10h] - int v16; // [esp-4h] [ebp-Ch] - int v17; // [esp-4h] [ebp-Ch] + int v2; // esi + int v3; // edi + int v4; // eax + int v5; // eax + int v6; // edx + int v7; // ecx + int v8; // eax + int v9; // edx + int v10; // eax + int v11; // [esp-14h] [ebp-1Ch] + int v12; // [esp-Ch] [ebp-14h] + int v13; // [esp-Ch] [ebp-14h] + int v14; // [esp-8h] [ebp-10h] + int v15; // [esp-8h] [ebp-10h] + int v16; // [esp-4h] [ebp-Ch] + int v17; // [esp-4h] [ebp-Ch] - v2 = i; - v3 = md; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_WalkDir: Invalid monster %d", i); - v4 = monster[v2].MType->Anims[MA_WALK].Frames - 1; - switch (v3) { - case DIR_S: - M_StartWalk2(v2, 0, MWVel[v4][1], 0, -32, 1, 1, 0); - return; - case DIR_SW: - v17 = 1; - v8 = v4; - v15 = 1; - v13 = 0; - v11 = 32; - v9 = -MWVel[v8][1]; - goto LABEL_10; - case DIR_W: - M_StartWalk3(v2, -MWVel[v4][2], 0, 32, -16, -1, 1, 0, 1, 2); - return; - case DIR_NW: - v16 = 3; - v10 = v4; - v14 = 0; - v12 = -1; - v7 = -MWVel[v10][0]; - v6 = -MWVel[v10][1]; - goto LABEL_15; - case DIR_N: - M_StartWalk(v2, 0, -MWVel[v4][1], -1, -1, 4); - break; - case DIR_NE: - v16 = 5; - v5 = v4; - v14 = -1; - v12 = 0; - v6 = MWVel[v5][1]; - v7 = -MWVel[v5][0]; - LABEL_15: - M_StartWalk(v2, v6, v7, v12, v14, v16); - break; - case DIR_E: - M_StartWalk3(v2, MWVel[v4][2], 0, -32, -16, 1, -1, 1, 0, 6); - break; - case DIR_SE: - v17 = 7; - v8 = v4; - v15 = 0; - v13 = 1; - v9 = MWVel[v8][1]; - v11 = -32; - LABEL_10: - M_StartWalk2(v2, v9, MWVel[v8][0], v11, -16, v13, v15, v17); - break; - default: - return; - } + v2 = i; + v3 = md; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("M_WalkDir: Invalid monster %d", i); + v4 = monster[v2].MType->Anims[MA_WALK].Frames - 1; + switch (v3) { + case DIR_S: + M_StartWalk2(v2, 0, MWVel[v4][1], 0, -32, 1, 1, 0); + return; + case DIR_SW: + v17 = 1; + v8 = v4; + v15 = 1; + v13 = 0; + v11 = 32; + v9 = -MWVel[v8][1]; + goto LABEL_10; + case DIR_W: + M_StartWalk3(v2, -MWVel[v4][2], 0, 32, -16, -1, 1, 0, 1, 2); + return; + case DIR_NW: + v16 = 3; + v10 = v4; + v14 = 0; + v12 = -1; + v7 = -MWVel[v10][0]; + v6 = -MWVel[v10][1]; + goto LABEL_15; + case DIR_N: + M_StartWalk(v2, 0, -MWVel[v4][1], -1, -1, 4); + break; + case DIR_NE: + v16 = 5; + v5 = v4; + v14 = -1; + v12 = 0; + v6 = MWVel[v5][1]; + v7 = -MWVel[v5][0]; + LABEL_15: + M_StartWalk(v2, v6, v7, v12, v14, v16); + break; + case DIR_E: + M_StartWalk3(v2, MWVel[v4][2], 0, -32, -16, 1, -1, 1, 0, 6); + break; + case DIR_SE: + v17 = 7; + v8 = v4; + v15 = 0; + v13 = 1; + v9 = MWVel[v8][1]; + v11 = -32; + LABEL_10: + M_StartWalk2(v2, v9, MWVel[v8][0], v11, -16, v13, v15, v17); + break; + default: + return; + } } void __fastcall GroupUnity(int i) { - int v1; // ebx - int v2; // esi - int v3; // ebp - int v4; // edi - bool v5; // eax - int v6; // eax - int v7; // ecx - unsigned char v8; // al - int v9; // ebp - int j; // edi - int v11; // eax - int v12; // ecx - //int v13; // [esp+10h] [ebp-4h] + int v1; // ebx + int v2; // esi + int v3; // ebp + int v4; // edi + bool v5; // eax + int v6; // eax + int v7; // ecx + unsigned char v8; // al + int v9; // ebp + int j; // edi + int v11; // eax + int v12; // ecx + //int v13; // [esp+10h] [ebp-4h] - v1 = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("GroupUnity: Invalid monster %d", i); - v2 = v1; - if (monster[v1].leaderflag) { - v3 = (unsigned char)monster[v2].leader; - v4 = v3; - v5 = LineClearF( - CheckNoSolid, - monster[v2]._mx, - monster[v2]._my, - monster[v4]._mfutx, - monster[v4]._mfuty); - if (v5) { - if (monster[v2].leaderflag == 2 - && abs(monster[v2]._mx - monster[v4]._mfutx) < 4 - && abs(monster[v2]._my - monster[v4]._mfuty) < 4) { - ++monster[v4].unpackfilesize; - monster[v2].leaderflag = 1; - } - } else { - if (monster[v2].leaderflag != 1) - goto LABEL_18; - --monster[v4].unpackfilesize; - monster[v2].leaderflag = 2; - } - } else { - v3 = 0; /* v13 */ - } - if (monster[v2].leaderflag == 1) { - v6 = v3; - if (monster[v2]._msquelch > monster[v3]._msquelch) { - monster[v6]._lastx = monster[v2]._mx; - monster[v6]._lasty = monster[v2]._my; - monster[v6]._msquelch = monster[v2]._msquelch - 1; - } - if (monster[v6]._mAi == AI_GARG) { - v7 = monster[v6]._mFlags; - if (v7 & 4) { - monster[v6]._mmode = MM_SATTACK; - monster[v6]._mFlags = v7 & 0xFFFFFFFB; - } - } - return; - } + v1 = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("GroupUnity: Invalid monster %d", i); + v2 = v1; + if (monster[v1].leaderflag) { + v3 = (unsigned char)monster[v2].leader; + v4 = v3; + v5 = LineClearF( + CheckNoSolid, + monster[v2]._mx, + monster[v2]._my, + monster[v4]._mfutx, + monster[v4]._mfuty); + if (v5) { + if (monster[v2].leaderflag == 2 + && abs(monster[v2]._mx - monster[v4]._mfutx) < 4 + && abs(monster[v2]._my - monster[v4]._mfuty) < 4) { + ++monster[v4].unpackfilesize; + monster[v2].leaderflag = 1; + } + } else { + if (monster[v2].leaderflag != 1) + goto LABEL_18; + --monster[v4].unpackfilesize; + monster[v2].leaderflag = 2; + } + } else { + v3 = 0; /* v13 */ + } + if (monster[v2].leaderflag == 1) { + v6 = v3; + if (monster[v2]._msquelch > monster[v3]._msquelch) { + monster[v6]._lastx = monster[v2]._mx; + monster[v6]._lasty = monster[v2]._my; + monster[v6]._msquelch = monster[v2]._msquelch - 1; + } + if (monster[v6]._mAi == AI_GARG) { + v7 = monster[v6]._mFlags; + if (v7 & 4) { + monster[v6]._mmode = MM_SATTACK; + monster[v6]._mFlags = v7 & 0xFFFFFFFB; + } + } + return; + } LABEL_18: - v8 = monster[v2]._uniqtype; - if (v8 != 0) { - if (UniqMonst[v8 - 1].mUnqAttr & 2) { - v9 = nummonsters; - for (j = 0; j < v9; ++j) { - v11 = monstactive[j]; - if (monster[v11].leaderflag == 1 && (unsigned char)monster[v11].leader == v1) { - if (monster[v2]._msquelch > monster[v11]._msquelch) { - monster[v11]._lastx = monster[v2]._mx; - monster[v11]._lasty = monster[v2]._my; - monster[v11]._msquelch = monster[v2]._msquelch - 1; - } - if (monster[v11]._mAi == AI_GARG) { - v12 = monster[v11]._mFlags; - if (v12 & 4) { - monster[v11]._mmode = MM_SATTACK; - monster[v11]._mFlags = v12 & 0xFFFFFFFB; - } - } - } - } - } - } + v8 = monster[v2]._uniqtype; + if (v8 != 0) { + if (UniqMonst[v8 - 1].mUnqAttr & 2) { + v9 = nummonsters; + for (j = 0; j < v9; ++j) { + v11 = monstactive[j]; + if (monster[v11].leaderflag == 1 && (unsigned char)monster[v11].leader == v1) { + if (monster[v2]._msquelch > monster[v11]._msquelch) { + monster[v11]._lastx = monster[v2]._mx; + monster[v11]._lasty = monster[v2]._my; + monster[v11]._msquelch = monster[v2]._msquelch - 1; + } + if (monster[v11]._mAi == AI_GARG) { + v12 = monster[v11]._mFlags; + if (v12 & 4) { + monster[v11]._mmode = MM_SATTACK; + monster[v11]._mFlags = v12 & 0xFFFFFFFB; + } + } + } + } + } + } } bool __fastcall M_CallWalk(int i, int md) { - int v2; // esi - int v3; // edi - int v4; // ebp - //int v5; // eax - bool v7; // ebx - int v9; // ebx - //int v10; // eax - int v11; // ebx - //int v12; // eax - //int v13; // eax - signed int v14; // ebx - //int v15; // eax - //int v16; // eax - //int v17; // eax - unsigned char v18; // bl + int v2; // esi + int v3; // edi + int v4; // ebp + //int v5; // eax + bool v7; // ebx + int v9; // ebx + //int v10; // eax + int v11; // ebx + //int v12; // eax + //int v13; // eax + signed int v14; // ebx + //int v15; // eax + //int v16; // eax + //int v17; // eax + unsigned char v18; // bl - v2 = md; - v3 = i; - v4 = md; - //_LOBYTE(v5) = DirOK(i, md); - v7 = DirOK(i, md); - if (random(101, 2)) { - if (v7) - goto LABEL_10; - v9 = v2; - v2 = left[v2]; - //_LOBYTE(v10) = DirOK(v3, v2); - if (DirOK(v3, v2)) - goto LABEL_10; - v2 = right[v9]; - } else { - if (v7) - goto LABEL_10; - v11 = v2; - v2 = right[v2]; - //_LOBYTE(v12) = DirOK(v3, v2); - if (DirOK(v3, v2)) - goto LABEL_10; - v2 = left[v11]; - } - //_LOBYTE(v13) = DirOK(v3, v2); - if (!DirOK(v3, v2)) { - v14 = 0; - goto LABEL_11; - } + v2 = md; + v3 = i; + v4 = md; + //_LOBYTE(v5) = DirOK(i, md); + v7 = DirOK(i, md); + if (random(101, 2)) { + if (v7) + goto LABEL_10; + v9 = v2; + v2 = left[v2]; + //_LOBYTE(v10) = DirOK(v3, v2); + if (DirOK(v3, v2)) + goto LABEL_10; + v2 = right[v9]; + } else { + if (v7) + goto LABEL_10; + v11 = v2; + v2 = right[v2]; + //_LOBYTE(v12) = DirOK(v3, v2); + if (DirOK(v3, v2)) + goto LABEL_10; + v2 = left[v11]; + } + //_LOBYTE(v13) = DirOK(v3, v2); + if (!DirOK(v3, v2)) { + v14 = 0; + goto LABEL_11; + } LABEL_10: - v14 = 1; + v14 = 1; LABEL_11: - if (random(102, 2)) { - if (v14) - goto LABEL_20; - v2 = right[right[v4]]; - //_LOBYTE(v15) = DirOK(v3, v2); - if (DirOK(v3, v2)) - goto LABEL_20; - v2 = left[left[v4]]; - } else { - if (v14) - goto LABEL_20; - v2 = left[left[v4]]; - //_LOBYTE(v16) = DirOK(v3, v2); - if (DirOK(v3, v2)) - goto LABEL_20; - v2 = right[right[v4]]; - } - //_LOBYTE(v17) = DirOK(v3, v2); - if (DirOK(v3, v2)) { - LABEL_20: - v18 = 1; - M_WalkDir(v3, v2); - return v18; - } - return 0; + if (random(102, 2)) { + if (v14) + goto LABEL_20; + v2 = right[right[v4]]; + //_LOBYTE(v15) = DirOK(v3, v2); + if (DirOK(v3, v2)) + goto LABEL_20; + v2 = left[left[v4]]; + } else { + if (v14) + goto LABEL_20; + v2 = left[left[v4]]; + //_LOBYTE(v16) = DirOK(v3, v2); + if (DirOK(v3, v2)) + goto LABEL_20; + v2 = right[right[v4]]; + } + //_LOBYTE(v17) = DirOK(v3, v2); + if (DirOK(v3, v2)) { + LABEL_20: + v18 = 1; + M_WalkDir(v3, v2); + return v18; + } + return 0; } bool __fastcall M_PathWalk(int i) { - int v1; // esi - BOOL(__fastcall * Check) - (int, int, int); // ecx - char path[25]; // [esp+4h] [ebp-1Ch] + int v1; // esi + BOOL(__fastcall * Check) + (int, int, int); // ecx + char path[25]; // [esp+4h] [ebp-1Ch] - v1 = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("M_PathWalk: Invalid monster %d", i); - Check = PosOkMonst3; - if (!(monster[v1]._mFlags & 0x200)) - Check = PosOkMonst; - if (!FindPath( - Check, - v1, - monster[v1]._mx, - monster[v1]._my, - (unsigned char)monster[v1]._menemyx, - (unsigned char)monster[v1]._menemyy, - path)) - return 0; - M_CallWalk(v1, (char)plr2monst[path[0]]); /* plr2monst is local */ - return 1; + v1 = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("M_PathWalk: Invalid monster %d", i); + Check = PosOkMonst3; + if (!(monster[v1]._mFlags & 0x200)) + Check = PosOkMonst; + if (!FindPath( + Check, + v1, + monster[v1]._mx, + monster[v1]._my, + (unsigned char)monster[v1]._menemyx, + (unsigned char)monster[v1]._menemyy, + path)) + return 0; + M_CallWalk(v1, (char)plr2monst[path[0]]); /* plr2monst is local */ + return 1; } bool __fastcall M_CallWalk2(int i, int md) { - int v2; // esi - int v3; // ebx - //int v4; // eax - bool v6; // edi - int v7; // edi - //int v8; // eax - int v9; // edi - //int v10; // eax - //int v11; // eax - bool v12; // di + int v2; // esi + int v3; // ebx + //int v4; // eax + bool v6; // edi + int v7; // edi + //int v8; // eax + int v9; // edi + //int v10; // eax + //int v11; // eax + bool v12; // di - v2 = md; - v3 = i; - //_LOBYTE(v4) = DirOK(i, md); - v6 = DirOK(i, md); - if (random(101, 2)) { - if (v6) - goto LABEL_10; - v7 = v2; - v2 = left[v2]; - //_LOBYTE(v8) = DirOK(v3, v2); - if (DirOK(v3, v2)) - goto LABEL_10; - v2 = right[v7]; - } else { - if (v6) - goto LABEL_10; - v9 = v2; - v2 = right[v2]; - //_LOBYTE(v10) = DirOK(v3, v2); - if (DirOK(v3, v2)) - goto LABEL_10; - v2 = left[v9]; - } - //_LOBYTE(v11) = DirOK(v3, v2); - if (DirOK(v3, v2)) { - LABEL_10: - v12 = 1; - M_WalkDir(v3, v2); - return v12; - } - return 0; + v2 = md; + v3 = i; + //_LOBYTE(v4) = DirOK(i, md); + v6 = DirOK(i, md); + if (random(101, 2)) { + if (v6) + goto LABEL_10; + v7 = v2; + v2 = left[v2]; + //_LOBYTE(v8) = DirOK(v3, v2); + if (DirOK(v3, v2)) + goto LABEL_10; + v2 = right[v7]; + } else { + if (v6) + goto LABEL_10; + v9 = v2; + v2 = right[v2]; + //_LOBYTE(v10) = DirOK(v3, v2); + if (DirOK(v3, v2)) + goto LABEL_10; + v2 = left[v9]; + } + //_LOBYTE(v11) = DirOK(v3, v2); + if (DirOK(v3, v2)) { + LABEL_10: + v12 = 1; + M_WalkDir(v3, v2); + return v12; + } + return 0; } bool __fastcall M_DumbWalk(int i, int md) { - int v2; // esi - int v3; // edi - //int v4; // eax - bool v5; // bl + int v2; // esi + int v3; // edi + //int v4; // eax + bool v5; // bl - v2 = md; - v3 = i; - //_LOBYTE(v4) = DirOK(i, md); - v5 = DirOK(i, md); - if (v5) - M_WalkDir(v3, v2); - return v5; + v2 = md; + v3 = i; + //_LOBYTE(v4) = DirOK(i, md); + v5 = DirOK(i, md); + if (v5) + M_WalkDir(v3, v2); + return v5; } bool __fastcall M_RoundWalk(int i, int md, int *dir) { - int *v3; // ebp - int v4; // ebx - int v5; // esi - //int v6; // eax - bool v7; // di - int v8; // edi - //int v9; // eax - //int v10; // eax - int *v11; // ebp - //int v12; // eax - //int v13; // eax + int *v3; // ebp + int v4; // ebx + int v5; // esi + //int v6; // eax + bool v7; // di + int v8; // edi + //int v9; // eax + //int v10; // eax + int *v11; // ebp + //int v12; // eax + //int v13; // eax - v3 = dir; - v4 = i; - if (*dir) - v5 = left[left[md]]; - else - v5 = right[right[md]]; - //_LOBYTE(v6) = DirOK(i, v5); - v7 = DirOK(i, v5); - if (v7) - goto LABEL_12; - v8 = v5; - if (!*dir) { - v11 = &left[v8]; - v5 = left[v8]; - //_LOBYTE(v12) = DirOK(v4, left[v8]); - if (DirOK(v4, left[v8])) - goto LABEL_11; - v5 = left[*v11]; - //_LOBYTE(v13) = DirOK(v4, left[*v11]); - if (DirOK(v4, left[*v11])) - goto LABEL_11; - v3 = dir; - LABEL_14: - *v3 = *v3 == 0; - return M_CallWalk(v4, opposite[v8]); - } - v5 = right[v8]; - //_LOBYTE(v9) = DirOK(v4, right[v8]); - if (!DirOK(v4, right[v8])) { - v5 = right[right[v8]]; - //_LOBYTE(v10) = DirOK(v4, v5); - if (!DirOK(v4, v5)) - goto LABEL_14; - } + v3 = dir; + v4 = i; + if (*dir) + v5 = left[left[md]]; + else + v5 = right[right[md]]; + //_LOBYTE(v6) = DirOK(i, v5); + v7 = DirOK(i, v5); + if (v7) + goto LABEL_12; + v8 = v5; + if (!*dir) { + v11 = &left[v8]; + v5 = left[v8]; + //_LOBYTE(v12) = DirOK(v4, left[v8]); + if (DirOK(v4, left[v8])) + goto LABEL_11; + v5 = left[*v11]; + //_LOBYTE(v13) = DirOK(v4, left[*v11]); + if (DirOK(v4, left[*v11])) + goto LABEL_11; + v3 = dir; + LABEL_14: + *v3 = *v3 == 0; + return M_CallWalk(v4, opposite[v8]); + } + v5 = right[v8]; + //_LOBYTE(v9) = DirOK(v4, right[v8]); + if (!DirOK(v4, right[v8])) { + v5 = right[right[v8]]; + //_LOBYTE(v10) = DirOK(v4, v5); + if (!DirOK(v4, v5)) + goto LABEL_14; + } LABEL_11: - v7 = 1; + v7 = 1; LABEL_12: - M_WalkDir(v4, v5); - return v7; + M_WalkDir(v4, v5); + return v7; } void __fastcall MAI_Zombie(int i) { - int v1; // esi - //int v2; // ST04_4 - MonsterStruct *v3; // esi - int v4; // edi - int v5; // ebx - int v6; // edi - int v7; // eax - int v8; // ecx - int v9; // eax - int v10; // eax - int v11; // eax - int v12; // ecx - int md; // [esp+Ch] [ebp-Ch] - int v14; // [esp+10h] [ebp-8h] - int arglist; // [esp+14h] [ebp-4h] + int v1; // esi + //int v2; // ST04_4 + MonsterStruct *v3; // esi + int v4; // edi + int v5; // ebx + int v6; // edi + int v7; // eax + int v8; // ecx + int v9; // eax + int v10; // eax + int v11; // eax + int v12; // ecx + int md; // [esp+Ch] [ebp-Ch] + int v14; // [esp+10h] [ebp-8h] + int arglist; // [esp+14h] [ebp-4h] - v1 = i; - arglist = i; - if ((DWORD)i >= MAXMONSTERS) { - TermMsg("MAI_Zombie: Invalid monster %d", i); - //i = v2; - } - v3 = &monster[v1]; - if (v3->_mmode == MM_STAND) { - v4 = v3->_my; - if (dFlags[v3->_mx][v4] & DFLAG_VISIBLE) { - v5 = v3->_mx - (unsigned char)v3->_menemyx; - v6 = v4 - (unsigned char)v3->_menemyy; - md = v3->_mdir; - v14 = random(103, 100); - if (abs(v5) >= 2 || abs(v6) >= 2) { - if (v14 < 2 * (unsigned char)v3->_mint + 10) { - v7 = abs(v5); - v8 = 2 * (unsigned char)v3->_mint + 4; - if (v7 >= v8 || (v9 = abs(v6), v8 = 2 * (unsigned char)v3->_mint + 4, v9 >= v8)) { - v11 = random(104, 100); - v12 = 2 * (unsigned char)v3->_mint + 20; - if (v11 < v12) { - md = random(104, 8); - } - M_DumbWalk(arglist, md); - } else { - v10 = M_GetDir(arglist); - M_CallWalk(arglist, v10); - } - } - } else if (v14 < 2 * (unsigned char)v3->_mint + 10) { - M_StartAttack(arglist); - } - if (v3->_mmode == MM_STAND) - v3->_mAnimData = v3->MType->Anims[MA_STAND].Data[v3->_mdir]; - } - } + v1 = i; + arglist = i; + if ((DWORD)i >= MAXMONSTERS) { + TermMsg("MAI_Zombie: Invalid monster %d", i); + //i = v2; + } + v3 = &monster[v1]; + if (v3->_mmode == MM_STAND) { + v4 = v3->_my; + if (dFlags[v3->_mx][v4] & DFLAG_VISIBLE) { + v5 = v3->_mx - (unsigned char)v3->_menemyx; + v6 = v4 - (unsigned char)v3->_menemyy; + md = v3->_mdir; + v14 = random(103, 100); + if (abs(v5) >= 2 || abs(v6) >= 2) { + if (v14 < 2 * (unsigned char)v3->_mint + 10) { + v7 = abs(v5); + v8 = 2 * (unsigned char)v3->_mint + 4; + if (v7 >= v8 || (v9 = abs(v6), v8 = 2 * (unsigned char)v3->_mint + 4, v9 >= v8)) { + v11 = random(104, 100); + v12 = 2 * (unsigned char)v3->_mint + 20; + if (v11 < v12) { + md = random(104, 8); + } + M_DumbWalk(arglist, md); + } else { + v10 = M_GetDir(arglist); + M_CallWalk(arglist, v10); + } + } + } else if (v14 < 2 * (unsigned char)v3->_mint + 10) { + M_StartAttack(arglist); + } + if (v3->_mmode == MM_STAND) + v3->_mAnimData = v3->MType->Anims[MA_STAND].Data[v3->_mdir]; + } + } } void __fastcall MAI_SkelSd(int i) { - int v1; // esi - MonsterStruct *v2; // esi - int v3; // ecx - int v4; // edx - int v5; // edi - int v6; // ebp - int v7; // ebx - int v8; // eax - //int v9; // ST04_4 - int v11; // eax - //int v12; // ST04_4 - int v13; // eax - int v14; // ecx - int v15; // edx - int v16; // eax - int v17; // ecx - int arglist; // [esp+8h] [ebp-4h] + int v1; // esi + MonsterStruct *v2; // esi + int v3; // ecx + int v4; // edx + int v5; // edi + int v6; // ebp + int v7; // ebx + int v8; // eax + //int v9; // ST04_4 + int v11; // eax + //int v12; // ST04_4 + int v13; // eax + int v14; // ecx + int v15; // edx + int v16; // eax + int v17; // ecx + int arglist; // [esp+8h] [ebp-4h] - v1 = i; - arglist = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_SkelSd: Invalid monster %d", i); - v2 = &monster[v1]; - if (v2->_mmode == MM_STAND && v2->_msquelch) { - v3 = v2->_mx; - v4 = v2->_my; - v5 = v3 - (unsigned char)v2->_menemyx; - v6 = v4 - (unsigned char)v2->_menemyy; - v7 = GetDirection(v3, v4, v2->_lastx, v2->_lasty); - v2->_mdir = v7; - v8 = abs(v5); - //v10 = v9; - if (v8 >= 2 || (v11 = abs(v6), v11 >= 2)) /* v10 = v12, */ - { - if (v2->_mVar1 != 13) { - v16 = random(106, 100); - v17 = 4 * (unsigned char)v2->_mint; - if (v16 < 35 - v17) { - v15 = 15 - 2 * (unsigned char)v2->_mint + random(106, 10); - goto LABEL_10; - } - } - M_CallWalk(arglist, v7); - } else { - if (v2->_mVar1 != 13) { - v13 = random(105, 100); - v14 = 2 * (unsigned char)v2->_mint + 20; - if (v13 >= v14) { - v15 = random(105, 10) + 2 * (5 - (unsigned char)v2->_mint); - LABEL_10: - M_StartDelay(arglist, v15); - goto LABEL_16; - } - } - M_StartAttack(arglist); - } - LABEL_16: - if (v2->_mmode == MM_STAND) - v2->_mAnimData = v2->MType->Anims[MA_STAND].Data[v7]; - } + v1 = i; + arglist = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("MAI_SkelSd: Invalid monster %d", i); + v2 = &monster[v1]; + if (v2->_mmode == MM_STAND && v2->_msquelch) { + v3 = v2->_mx; + v4 = v2->_my; + v5 = v3 - (unsigned char)v2->_menemyx; + v6 = v4 - (unsigned char)v2->_menemyy; + v7 = GetDirection(v3, v4, v2->_lastx, v2->_lasty); + v2->_mdir = v7; + v8 = abs(v5); + //v10 = v9; + if (v8 >= 2 || (v11 = abs(v6), v11 >= 2)) /* v10 = v12, */ + { + if (v2->_mVar1 != 13) { + v16 = random(106, 100); + v17 = 4 * (unsigned char)v2->_mint; + if (v16 < 35 - v17) { + v15 = 15 - 2 * (unsigned char)v2->_mint + random(106, 10); + goto LABEL_10; + } + } + M_CallWalk(arglist, v7); + } else { + if (v2->_mVar1 != 13) { + v13 = random(105, 100); + v14 = 2 * (unsigned char)v2->_mint + 20; + if (v13 >= v14) { + v15 = random(105, 10) + 2 * (5 - (unsigned char)v2->_mint); + LABEL_10: + M_StartDelay(arglist, v15); + goto LABEL_16; + } + } + M_StartAttack(arglist); + } + LABEL_16: + if (v2->_mmode == MM_STAND) + v2->_mAnimData = v2->MType->Anims[MA_STAND].Data[v7]; + } } bool __fastcall MAI_Path(int i) { - int v1; // edi - MonsterStruct *v2; // esi - char v3; // al - bool v4; // eax - unsigned char v5; // al + int v1; // edi + MonsterStruct *v2; // esi + char v3; // al + bool v4; // eax + unsigned char v5; // al - v1 = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_Path: Invalid monster %d", i); - v2 = &monster[v1]; - if (v2->MType->mtype != MT_GOLEM) { - if (!v2->_msquelch) - return 0; - if (v2->_mmode) - return 0; - v3 = v2->_mgoal; - if (v3 != 1 && v3 != 4 && v3 != 5) - return 0; - if (v2->_mx == 1 && !v2->_my) - return 0; - } - v4 = LineClearF1( - PosOkMonst2, - v1, - v2->_mx, - v2->_my, - (unsigned char)v2->_menemyx, - (unsigned char)v2->_menemyy); - if (!v4 || (v5 = v2->_pathcount, v5 >= 5u) && v5 < 8u) { - if (v2->_mFlags & 0x200) - MonstCheckDoors(v1); - if (++_LOBYTE(v2->_pathcount) < 5u) - return 0; - if (M_PathWalk(v1)) - return 1; - } - if (v2->MType->mtype != MT_GOLEM) - _LOBYTE(v2->_pathcount) = 0; - return 0; + v1 = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("MAI_Path: Invalid monster %d", i); + v2 = &monster[v1]; + if (v2->MType->mtype != MT_GOLEM) { + if (!v2->_msquelch) + return 0; + if (v2->_mmode) + return 0; + v3 = v2->_mgoal; + if (v3 != 1 && v3 != 4 && v3 != 5) + return 0; + if (v2->_mx == 1 && !v2->_my) + return 0; + } + v4 = LineClearF1( + PosOkMonst2, + v1, + v2->_mx, + v2->_my, + (unsigned char)v2->_menemyx, + (unsigned char)v2->_menemyy); + if (!v4 || (v5 = v2->_pathcount, v5 >= 5u) && v5 < 8u) { + if (v2->_mFlags & 0x200) + MonstCheckDoors(v1); + if (++_LOBYTE(v2->_pathcount) < 5u) + return 0; + if (M_PathWalk(v1)) + return 1; + } + if (v2->MType->mtype != MT_GOLEM) + _LOBYTE(v2->_pathcount) = 0; + return 0; } void __fastcall MAI_Snake(int i) { - int esi1; // esi - MonsterStruct *esi3; // esi - bool v3; // zf - int v4; // ecx - int v5; // eax - int v6; // ST1C_4 - int v7; // edi - int v8; // edx - int v9; // ST18_4 - int v10; // ebx - int v11; // eax - //int v12; // ST1C_4 - int v14; // eax - int v15; // eax - int v16; // ecx - int v17; // edx - int v18; // ecx - int v19; // eax - //int v20; // ST1C_4 - int v22; // eax - //int v23; // ST1C_4 - int v24; // ebx - int v26; // ecx - int v27; // eax - int v28; // ecx - int v29; // ecx - int v30; // eax - int v31; // edx - int v32; // eax - int v33; // ecx - int v34; // ecx - int v35; // eax - char pattern[6]; // [esp+4h] [ebp-1Ch] - int micaster; // [esp+Ch] [ebp-14h] - int midir; // [esp+10h] [ebp-10h] - int v1; // [esp+14h] [ebp-Ch] - int v2; // [esp+18h] [ebp-8h] - int arglist; // [esp+1Ch] [ebp-4h] + int esi1; // esi + MonsterStruct *esi3; // esi + bool v3; // zf + int v4; // ecx + int v5; // eax + int v6; // ST1C_4 + int v7; // edi + int v8; // edx + int v9; // ST18_4 + int v10; // ebx + int v11; // eax + //int v12; // ST1C_4 + int v14; // eax + int v15; // eax + int v16; // ecx + int v17; // edx + int v18; // ecx + int v19; // eax + //int v20; // ST1C_4 + int v22; // eax + //int v23; // ST1C_4 + int v24; // ebx + int v26; // ecx + int v27; // eax + int v28; // ecx + int v29; // ecx + int v30; // eax + int v31; // edx + int v32; // eax + int v33; // ecx + int v34; // ecx + int v35; // eax + char pattern[6]; // [esp+4h] [ebp-1Ch] + int micaster; // [esp+Ch] [ebp-14h] + int midir; // [esp+10h] [ebp-10h] + int v1; // [esp+14h] [ebp-Ch] + int v2; // [esp+18h] [ebp-8h] + int arglist; // [esp+1Ch] [ebp-4h] - esi1 = i; - arglist = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_Snake: Invalid monster %d", i); - pattern[2] = 0; - pattern[3] = -1; - pattern[4] = -1; - pattern[5] = 0; - esi3 = &monster[esi1]; - pattern[0] = 1; - pattern[1] = 1; - v3 = esi3->_mmode == MM_STAND; - micaster = esi3->_menemy; - if (v3 && esi3->_msquelch) { - v4 = esi3->_mx; - v5 = (unsigned char)esi3->_menemyy; - v6 = esi3->_lasty; - v1 = (unsigned char)esi3->_menemyx; - v7 = v4 - v1; - v8 = esi3->_my; - v9 = esi3->_lastx; - v2 = v5; - v10 = v8 - v5; - midir = GetDirection(v4, v8, v9, v6); - esi3->_mdir = midir; - if (abs(v7) < 2) { - v11 = abs(v10); - //v13 = v12; - if (v11 < 2) { - v14 = esi3->_mVar1; - if (v14 == 13 - || v14 == 14 - || (v15 = random(105, 100), v16 = (unsigned char)esi3->_mint + 20, v15 < v16)) { - M_StartAttack(arglist); - LABEL_49: - if (esi3->_mmode == MM_STAND) - esi3->_mAnimData = esi3->MType->Anims[MA_STAND].Data[esi3->_mdir]; - return; - } - v17 = 10 - (unsigned char)esi3->_mint + random(105, 10); - v18 = arglist; - LABEL_11: - M_StartDelay(v18, v17); - goto LABEL_49; - } - } - v19 = abs(v7); - //v21 = v20; - if (v19 >= 3 || (v22 = abs(v10), v22 >= 3)) /* v21 = v23, */ - { - v24 = arglist; - } else { - v24 = arglist; - if (LineClearF1(PosOkMonst, arglist, esi3->_mx, esi3->_my, v1, v2) && esi3->_mVar1 != 14) { - if (AddMissile(esi3->_mx, esi3->_my, v1, v2, midir, 20, micaster, arglist, 0, 0) != -1) { - PlayEffect(arglist, 0); - v26 = esi3->_my + 112 * esi3->_mx; - esi3->_mmode = MM_CHARGE; - dMonster[0][v26] = -1 - v24; - } - goto LABEL_49; - } - } - if (esi3->_mVar1 != 13) { - v27 = random(106, 100); - v28 = 2 * (unsigned char)esi3->_mint; - if (v27 < 35 - v28) { - v17 = 15 - (unsigned char)esi3->_mint + random(106, 10); - v18 = v24; - goto LABEL_11; - } - } - v29 = esi3->_mgoalvar1; - v30 = midir + pattern[v29]; - if (v30 >= 0) { - v31 = v30 - 8; - if (v30 < 8) - v31 = midir + pattern[v29]; - } else { - v31 = v30 + 8; - } - esi3->_mgoalvar1 = v29 + 1; - if (v29 + 1 > 5) - esi3->_mgoalvar1 = 0; - v32 = esi3->_mgoalvar2; - v33 = v31 - v32; - if (v31 - v32 >= 0) { - if (v33 >= 8) - v33 -= 8; - } else { - v33 += 8; - } - if (v33 <= 0) { - LABEL_47: - if (!M_DumbWalk(v24, esi3->_mgoalvar2)) - M_CallWalk2(v24, esi3->_mdir); - goto LABEL_49; - } - if (v33 >= 4) { - if (v33 == 4) { - esi3->_mgoalvar2 = v31; - goto LABEL_47; - } - v34 = v32 - 1; - if (v32 - 1 < 0) { - v35 = v32 + 7; - goto LABEL_46; - } - if (v34 >= 8) { - v35 = v32 - 9; - goto LABEL_46; - } - } else { - v34 = v32 + 1; - if (v32 + 1 < 0) { - v35 = v32 + 9; - LABEL_46: - esi3->_mgoalvar2 = v35; - goto LABEL_47; - } - if (v34 >= 8) { - v35 = v32 - 7; - goto LABEL_46; - } - } - v35 = v34; - goto LABEL_46; - } + esi1 = i; + arglist = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("MAI_Snake: Invalid monster %d", i); + pattern[2] = 0; + pattern[3] = -1; + pattern[4] = -1; + pattern[5] = 0; + esi3 = &monster[esi1]; + pattern[0] = 1; + pattern[1] = 1; + v3 = esi3->_mmode == MM_STAND; + micaster = esi3->_menemy; + if (v3 && esi3->_msquelch) { + v4 = esi3->_mx; + v5 = (unsigned char)esi3->_menemyy; + v6 = esi3->_lasty; + v1 = (unsigned char)esi3->_menemyx; + v7 = v4 - v1; + v8 = esi3->_my; + v9 = esi3->_lastx; + v2 = v5; + v10 = v8 - v5; + midir = GetDirection(v4, v8, v9, v6); + esi3->_mdir = midir; + if (abs(v7) < 2) { + v11 = abs(v10); + //v13 = v12; + if (v11 < 2) { + v14 = esi3->_mVar1; + if (v14 == 13 + || v14 == 14 + || (v15 = random(105, 100), v16 = (unsigned char)esi3->_mint + 20, v15 < v16)) { + M_StartAttack(arglist); + LABEL_49: + if (esi3->_mmode == MM_STAND) + esi3->_mAnimData = esi3->MType->Anims[MA_STAND].Data[esi3->_mdir]; + return; + } + v17 = 10 - (unsigned char)esi3->_mint + random(105, 10); + v18 = arglist; + LABEL_11: + M_StartDelay(v18, v17); + goto LABEL_49; + } + } + v19 = abs(v7); + //v21 = v20; + if (v19 >= 3 || (v22 = abs(v10), v22 >= 3)) /* v21 = v23, */ + { + v24 = arglist; + } else { + v24 = arglist; + if (LineClearF1(PosOkMonst, arglist, esi3->_mx, esi3->_my, v1, v2) && esi3->_mVar1 != 14) { + if (AddMissile(esi3->_mx, esi3->_my, v1, v2, midir, 20, micaster, arglist, 0, 0) != -1) { + PlayEffect(arglist, 0); + v26 = esi3->_my + 112 * esi3->_mx; + esi3->_mmode = MM_CHARGE; + dMonster[0][v26] = -1 - v24; + } + goto LABEL_49; + } + } + if (esi3->_mVar1 != 13) { + v27 = random(106, 100); + v28 = 2 * (unsigned char)esi3->_mint; + if (v27 < 35 - v28) { + v17 = 15 - (unsigned char)esi3->_mint + random(106, 10); + v18 = v24; + goto LABEL_11; + } + } + v29 = esi3->_mgoalvar1; + v30 = midir + pattern[v29]; + if (v30 >= 0) { + v31 = v30 - 8; + if (v30 < 8) + v31 = midir + pattern[v29]; + } else { + v31 = v30 + 8; + } + esi3->_mgoalvar1 = v29 + 1; + if (v29 + 1 > 5) + esi3->_mgoalvar1 = 0; + v32 = esi3->_mgoalvar2; + v33 = v31 - v32; + if (v31 - v32 >= 0) { + if (v33 >= 8) + v33 -= 8; + } else { + v33 += 8; + } + if (v33 <= 0) { + LABEL_47: + if (!M_DumbWalk(v24, esi3->_mgoalvar2)) + M_CallWalk2(v24, esi3->_mdir); + goto LABEL_49; + } + if (v33 >= 4) { + if (v33 == 4) { + esi3->_mgoalvar2 = v31; + goto LABEL_47; + } + v34 = v32 - 1; + if (v32 - 1 < 0) { + v35 = v32 + 7; + goto LABEL_46; + } + if (v34 >= 8) { + v35 = v32 - 9; + goto LABEL_46; + } + } else { + v34 = v32 + 1; + if (v32 + 1 < 0) { + v35 = v32 + 9; + LABEL_46: + esi3->_mgoalvar2 = v35; + goto LABEL_47; + } + if (v34 >= 8) { + v35 = v32 - 7; + goto LABEL_46; + } + } + v35 = v34; + goto LABEL_46; + } } void __fastcall MAI_Bat(int i) { - int esi1; // esi - MonsterStruct *esi3; // esi - int v3; // ecx - int v4; // edx - int v5; // edi - int v6; // ebx - int v7; // eax - int v10; // edx - bool v11; // eax - int v12; // ecx - CMonster *v14; // eax - int v15; // edi - int v16; // eax - signed int v17; // ecx - int v18; // eax - int micaster; // [esp+Ch] [ebp-18h] - int v1; // [esp+10h] [ebp-14h] - int v2; // [esp+14h] [ebp-10h] - int v22; // [esp+18h] [ebp-Ch] - int midir; // [esp+1Ch] [ebp-8h] - int arglist; // [esp+20h] [ebp-4h] + int esi1; // esi + MonsterStruct *esi3; // esi + int v3; // ecx + int v4; // edx + int v5; // edi + int v6; // ebx + int v7; // eax + int v10; // edx + bool v11; // eax + int v12; // ecx + CMonster *v14; // eax + int v15; // edi + int v16; // eax + signed int v17; // ecx + int v18; // eax + int micaster; // [esp+Ch] [ebp-18h] + int v1; // [esp+10h] [ebp-14h] + int v2; // [esp+14h] [ebp-10h] + int v22; // [esp+18h] [ebp-Ch] + int midir; // [esp+1Ch] [ebp-8h] + int arglist; // [esp+20h] [ebp-4h] - esi1 = i; - arglist = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_Bat: Invalid monster %d", i); - esi3 = &monster[esi1]; - micaster = esi3->_menemy; - if (esi3->_mmode == MM_STAND && esi3->_msquelch) { - v3 = esi3->_mx; - v4 = esi3->_my; - v5 = v3 - (unsigned char)esi3->_menemyx; - v6 = v4 - (unsigned char)esi3->_menemyy; - v7 = GetDirection(v3, v4, esi3->_lastx, esi3->_lasty); - midir = v7; - esi3->_mdir = v7; - v22 = random(107, 100); - if (_LOBYTE(esi3->_mgoal) == 2) { - if (esi3->_mgoalvar1) { - if (random(108, 2)) - v10 = left[midir]; - else - v10 = right[midir]; - M_CallWalk(arglist, v10); - _LOBYTE(esi3->_mgoal) = 1; - } else { - M_CallWalk(arglist, opposite[midir]); - ++esi3->_mgoalvar1; - } - } else { - v1 = (unsigned char)esi3->_menemyx; - v2 = (unsigned char)esi3->_menemyy; - if (esi3->MType->mtype == MT_GLOOM - && (abs(v5) >= 5 || abs(v6) >= 5) - && v22 < 4 * (unsigned char)esi3->_mint + 33 - && (v11 = LineClearF1( - PosOkMonst, - arglist, - esi3->_mx, - esi3->_my, - v1, - v2), - v11)) { - if (AddMissile(esi3->_mx, esi3->_my, v1, v2, midir, 20, micaster, arglist, 0, 0) != -1) { - v12 = esi3->_my + 112 * esi3->_mx; - esi3->_mmode = MM_CHARGE; - dMonster[0][v12] = -1 - arglist; - } - } else if (abs(v5) >= 2 || abs(v6) >= 2) { - v17 = esi3->_mVar2; - if (v17 > 20 && v22 < (unsigned char)esi3->_mint + 13 - || ((v18 = esi3->_mVar1, v18 == 1) || v18 == 2 || v18 == 3) - && !v17 - && v22 < (unsigned char)esi3->_mint + 63) { - M_CallWalk(arglist, midir); - } - } else if (v22 < 4 * (unsigned char)esi3->_mint + 8) { - M_StartAttack(arglist); - v14 = esi3->MType; - esi3->_mgoalvar1 = 0; - _LOBYTE(esi3->_mgoal) = 2; - if (v14->mtype == MT_FAMILIAR) { - v15 = (unsigned char)esi3->_menemyx; - v16 = random(109, 10); - AddMissile(v15, (unsigned char)esi3->_menemyy, v15 + 1, 0, -1, 8, 1, arglist, v16 + 1, 0); - } - } - if (esi3->_mmode == MM_STAND) - esi3->_mAnimData = esi3->MType->Anims[MA_STAND].Data[midir]; - } - } + esi1 = i; + arglist = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("MAI_Bat: Invalid monster %d", i); + esi3 = &monster[esi1]; + micaster = esi3->_menemy; + if (esi3->_mmode == MM_STAND && esi3->_msquelch) { + v3 = esi3->_mx; + v4 = esi3->_my; + v5 = v3 - (unsigned char)esi3->_menemyx; + v6 = v4 - (unsigned char)esi3->_menemyy; + v7 = GetDirection(v3, v4, esi3->_lastx, esi3->_lasty); + midir = v7; + esi3->_mdir = v7; + v22 = random(107, 100); + if (_LOBYTE(esi3->_mgoal) == 2) { + if (esi3->_mgoalvar1) { + if (random(108, 2)) + v10 = left[midir]; + else + v10 = right[midir]; + M_CallWalk(arglist, v10); + _LOBYTE(esi3->_mgoal) = 1; + } else { + M_CallWalk(arglist, opposite[midir]); + ++esi3->_mgoalvar1; + } + } else { + v1 = (unsigned char)esi3->_menemyx; + v2 = (unsigned char)esi3->_menemyy; + if (esi3->MType->mtype == MT_GLOOM + && (abs(v5) >= 5 || abs(v6) >= 5) + && v22 < 4 * (unsigned char)esi3->_mint + 33 + && (v11 = LineClearF1( + PosOkMonst, + arglist, + esi3->_mx, + esi3->_my, + v1, + v2), + v11)) { + if (AddMissile(esi3->_mx, esi3->_my, v1, v2, midir, 20, micaster, arglist, 0, 0) != -1) { + v12 = esi3->_my + 112 * esi3->_mx; + esi3->_mmode = MM_CHARGE; + dMonster[0][v12] = -1 - arglist; + } + } else if (abs(v5) >= 2 || abs(v6) >= 2) { + v17 = esi3->_mVar2; + if (v17 > 20 && v22 < (unsigned char)esi3->_mint + 13 + || ((v18 = esi3->_mVar1, v18 == 1) || v18 == 2 || v18 == 3) + && !v17 + && v22 < (unsigned char)esi3->_mint + 63) { + M_CallWalk(arglist, midir); + } + } else if (v22 < 4 * (unsigned char)esi3->_mint + 8) { + M_StartAttack(arglist); + v14 = esi3->MType; + esi3->_mgoalvar1 = 0; + _LOBYTE(esi3->_mgoal) = 2; + if (v14->mtype == MT_FAMILIAR) { + v15 = (unsigned char)esi3->_menemyx; + v16 = random(109, 10); + AddMissile(v15, (unsigned char)esi3->_menemyy, v15 + 1, 0, -1, 8, 1, arglist, v16 + 1, 0); + } + } + if (esi3->_mmode == MM_STAND) + esi3->_mAnimData = esi3->MType->Anims[MA_STAND].Data[midir]; + } + } } void __fastcall MAI_SkelBow(int i) { - int v1; // esi - MonsterStruct *v2; // esi - int v3; // edi - int v4; // ebx - int v5; // eax - int v7; // eax - //int v8; // ST04_4 - int v9; // ecx - int v10; // eax - //int v11; // ST04_4 - int v12; // eax - //int v13; // eax - int v14; // edi - int v15; // ebx - //int v16; // eax - int v17; // [esp+4h] [ebp-10h] - bool v18; // [esp+8h] [ebp-Ch] - int v19; // [esp+Ch] [ebp-8h] - int arglist; // [esp+10h] [ebp-4h] + int v1; // esi + MonsterStruct *v2; // esi + int v3; // edi + int v4; // ebx + int v5; // eax + int v7; // eax + //int v8; // ST04_4 + int v9; // ecx + int v10; // eax + //int v11; // ST04_4 + int v12; // eax + //int v13; // eax + int v14; // edi + int v15; // ebx + //int v16; // eax + int v17; // [esp+4h] [ebp-10h] + bool v18; // [esp+8h] [ebp-Ch] + int v19; // [esp+Ch] [ebp-8h] + int arglist; // [esp+10h] [ebp-4h] - v18 = 0; - v1 = i; - arglist = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_SkelBow: Invalid monster %d", i); - v2 = &monster[v1]; - if (v2->_mmode == MM_STAND && v2->_msquelch) { - v3 = v2->_mx - (unsigned char)v2->_menemyx; - v4 = v2->_my - (unsigned char)v2->_menemyy; - v5 = M_GetDir(arglist); - v17 = v5; - v2->_mdir = v5; - v19 = random(110, 100); - v7 = abs(v3); - //v9 = v8; - if (v7 < 4) { - v10 = abs(v4); - //v9 = v11; - if (v10 < 4) { - if ((v9 = v2->_mVar2, v9 > 20) && v19 < 2 * (unsigned char)v2->_mint + 13 - || ((v12 = v2->_mVar1, v12 == 1) || v12 == 2 || v12 == 3) - && !v9 - && v19 < 2 * (unsigned char)v2->_mint + 63) { - //_LOBYTE(v13) = M_DumbWalk(arglist, opposite[v17]); - v18 = M_DumbWalk(arglist, opposite[v17]); - } - } - } - v14 = (unsigned char)v2->_menemyx; - v15 = (unsigned char)v2->_menemyy; - if (!v18) { - if (random(110, 100) < 2 * (unsigned char)v2->_mint + 3) { - //_LOBYTE(v16) = LineClear(v2->_mx, v2->_my, v14, v15); - if (LineClear(v2->_mx, v2->_my, v14, v15)) - M_StartRAttack(arglist, 0, 4); - } - } - if (v2->_mmode == MM_STAND) - v2->_mAnimData = v2->MType->Anims[MA_STAND].Data[v17]; - } + v18 = 0; + v1 = i; + arglist = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("MAI_SkelBow: Invalid monster %d", i); + v2 = &monster[v1]; + if (v2->_mmode == MM_STAND && v2->_msquelch) { + v3 = v2->_mx - (unsigned char)v2->_menemyx; + v4 = v2->_my - (unsigned char)v2->_menemyy; + v5 = M_GetDir(arglist); + v17 = v5; + v2->_mdir = v5; + v19 = random(110, 100); + v7 = abs(v3); + //v9 = v8; + if (v7 < 4) { + v10 = abs(v4); + //v9 = v11; + if (v10 < 4) { + if ((v9 = v2->_mVar2, v9 > 20) && v19 < 2 * (unsigned char)v2->_mint + 13 + || ((v12 = v2->_mVar1, v12 == 1) || v12 == 2 || v12 == 3) + && !v9 + && v19 < 2 * (unsigned char)v2->_mint + 63) { + //_LOBYTE(v13) = M_DumbWalk(arglist, opposite[v17]); + v18 = M_DumbWalk(arglist, opposite[v17]); + } + } + } + v14 = (unsigned char)v2->_menemyx; + v15 = (unsigned char)v2->_menemyy; + if (!v18) { + if (random(110, 100) < 2 * (unsigned char)v2->_mint + 3) { + //_LOBYTE(v16) = LineClear(v2->_mx, v2->_my, v14, v15); + if (LineClear(v2->_mx, v2->_my, v14, v15)) + M_StartRAttack(arglist, 0, 4); + } + } + if (v2->_mmode == MM_STAND) + v2->_mAnimData = v2->MType->Anims[MA_STAND].Data[v17]; + } } void __fastcall MAI_Fat(int i) { - int v1; // esi - MonsterStruct *v2; // esi - int v3; // edi - int v4; // ebx - int v5; // eax - int v7; // eax - signed int v8; // ecx - int v9; // eax - int md; // [esp+4h] [ebp-Ch] - int arglist; // [esp+8h] [ebp-8h] - int v12; // [esp+Ch] [ebp-4h] + int v1; // esi + MonsterStruct *v2; // esi + int v3; // edi + int v4; // ebx + int v5; // eax + int v7; // eax + signed int v8; // ecx + int v9; // eax + int md; // [esp+4h] [ebp-Ch] + int arglist; // [esp+8h] [ebp-8h] + int v12; // [esp+Ch] [ebp-4h] - v1 = i; - arglist = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_Fat: Invalid monster %d", i); - v2 = &monster[v1]; - if (v2->_mmode == MM_STAND && v2->_msquelch) { - v3 = v2->_mx - (unsigned char)v2->_menemyx; - v4 = v2->_my - (unsigned char)v2->_menemyy; - v5 = M_GetDir(arglist); - md = v5; - v2->_mdir = v5; - v12 = random(111, 100); - if (abs(v3) >= 2 || abs(v4) >= 2) { - v8 = v2->_mVar2; - if (v8 > 20 && v12 < 4 * (unsigned char)v2->_mint + 20 - || ((v9 = v2->_mVar1, v9 == 1) || v9 == 2 || v9 == 3) && !v8 && v12 < 4 * (unsigned char)v2->_mint + 70) { - M_CallWalk(arglist, md); - } - } else { - v7 = (unsigned char)v2->_mint; - if (v12 >= 4 * v7 + 15) { - if (v12 < 4 * v7 + 20) - M_StartSpAttack(arglist); - } else { - M_StartAttack(arglist); - } - } - if (v2->_mmode == MM_STAND) - v2->_mAnimData = v2->MType->Anims[MA_STAND].Data[md]; - } + v1 = i; + arglist = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("MAI_Fat: Invalid monster %d", i); + v2 = &monster[v1]; + if (v2->_mmode == MM_STAND && v2->_msquelch) { + v3 = v2->_mx - (unsigned char)v2->_menemyx; + v4 = v2->_my - (unsigned char)v2->_menemyy; + v5 = M_GetDir(arglist); + md = v5; + v2->_mdir = v5; + v12 = random(111, 100); + if (abs(v3) >= 2 || abs(v4) >= 2) { + v8 = v2->_mVar2; + if (v8 > 20 && v12 < 4 * (unsigned char)v2->_mint + 20 + || ((v9 = v2->_mVar1, v9 == 1) || v9 == 2 || v9 == 3) && !v8 && v12 < 4 * (unsigned char)v2->_mint + 70) { + M_CallWalk(arglist, md); + } + } else { + v7 = (unsigned char)v2->_mint; + if (v12 >= 4 * v7 + 15) { + if (v12 < 4 * v7 + 20) + M_StartSpAttack(arglist); + } else { + M_StartAttack(arglist); + } + } + if (v2->_mmode == MM_STAND) + v2->_mAnimData = v2->MType->Anims[MA_STAND].Data[md]; + } } void __fastcall MAI_Sneak(int i) { - int v1; // edi - MonsterStruct *v2; // esi - int v3; // ebx - int v4; // ebx - int v6; // edi - int v7; // eax - //int v8; // ST04_4 - int v9; // eax - //int v10; // ST04_4 - int v11; // eax - int v12; // edi - signed int v13; // ecx - int v14; // eax - int v15; // [esp+Ch] [ebp-10h] - int arglist; // [esp+10h] [ebp-Ch] - int v17; // [esp+14h] [ebp-8h] - int md; // [esp+18h] [ebp-4h] + int v1; // edi + MonsterStruct *v2; // esi + int v3; // ebx + int v4; // ebx + int v6; // edi + int v7; // eax + //int v8; // ST04_4 + int v9; // eax + //int v10; // ST04_4 + int v11; // eax + int v12; // edi + signed int v13; // ecx + int v14; // eax + int v15; // [esp+Ch] [ebp-10h] + int arglist; // [esp+10h] [ebp-Ch] + int v17; // [esp+14h] [ebp-8h] + int md; // [esp+18h] [ebp-4h] - v1 = i; - arglist = i; - if ((DWORD)i >= MAXMONSTERS) { - TermMsg("MAI_Sneak: Invalid monster %d", i); - } + v1 = i; + arglist = i; + if ((DWORD)i >= MAXMONSTERS) { + TermMsg("MAI_Sneak: Invalid monster %d", i); + } - v2 = &monster[v1]; - if (v2->_mmode == MM_STAND) { - v3 = v2->_my; - if (dTransVal[v2->_mx][v3] != lightmax) { - v17 = v2->_mx - (unsigned char)v2->_menemyx; - v4 = v3 - (unsigned char)v2->_menemyy; - md = M_GetDir(v1); - v6 = 5 - (unsigned char)v2->_mint; - if (v2->_mVar1 == 5) { - v2->_mgoalvar1 = 0; - _LOBYTE(v2->_mgoal) = 2; - } else { - v7 = abs(v17); - //v5 = v8; - if (v7 >= v6 + 3 || (v9 = abs(v4), v9 >= v6 + 3) || v2->_mgoalvar1 > 8) /* v5 = v10, */ - { - v2->_mgoalvar1 = 0; - _LOBYTE(v2->_mgoal) = 1; - } - } - if (_LOBYTE(v2->_mgoal) == 2) { - if (v2->_mFlags & 0x10) - md = GetDirection(v2->_mx, v2->_my, plr[v2->_menemy]._pownerx, plr[v2->_menemy]._pownery); - md = opposite[md]; - if (v2->MType->mtype == MT_UNSEEN) { - if (random(112, 2)) - v11 = left[md]; - else - v11 = right[md]; - md = v11; - } - } - v2->_mdir = md; - v15 = random(112, 100); - if (abs(v17) < v6 && abs(v4) < v6 && v2->_mFlags & 1) { - M_StartFadein(arglist, md, FALSE); - } else { - v12 = v6 + 1; - if (abs(v17) < v12 && abs(v4) < v12 || v2->_mFlags & 1) { - if (_LOBYTE(v2->_mgoal) == 2 - || (abs(v17) >= 2 || abs(v4) >= 2) - && ((v13 = v2->_mVar2, v13 > 20) && v15 < 4 * (unsigned char)v2->_mint + 14 - || ((v14 = v2->_mVar1, v14 == 1) || v14 == 2 || v14 == 3) - && !v13 - && v15 < 4 * (unsigned char)v2->_mint + 64)) { - ++v2->_mgoalvar1; - M_CallWalk(arglist, md); - } - } else { - M_StartFadeout(arglist, md, TRUE); - } - } - if (v2->_mmode == MM_STAND) { - if (abs(v17) >= 2 || abs(v4) >= 2 || v15 >= 4 * (unsigned char)v2->_mint + 10) - v2->_mAnimData = v2->MType->Anims[MA_STAND].Data[md]; - else - M_StartAttack(arglist); - } - } - } + v2 = &monster[v1]; + if (v2->_mmode == MM_STAND) { + v3 = v2->_my; + if (dTransVal[v2->_mx][v3] != lightmax) { + v17 = v2->_mx - (unsigned char)v2->_menemyx; + v4 = v3 - (unsigned char)v2->_menemyy; + md = M_GetDir(v1); + v6 = 5 - (unsigned char)v2->_mint; + if (v2->_mVar1 == 5) { + v2->_mgoalvar1 = 0; + _LOBYTE(v2->_mgoal) = 2; + } else { + v7 = abs(v17); + //v5 = v8; + if (v7 >= v6 + 3 || (v9 = abs(v4), v9 >= v6 + 3) || v2->_mgoalvar1 > 8) /* v5 = v10, */ + { + v2->_mgoalvar1 = 0; + _LOBYTE(v2->_mgoal) = 1; + } + } + if (_LOBYTE(v2->_mgoal) == 2) { + if (v2->_mFlags & 0x10) + md = GetDirection(v2->_mx, v2->_my, plr[v2->_menemy]._pownerx, plr[v2->_menemy]._pownery); + md = opposite[md]; + if (v2->MType->mtype == MT_UNSEEN) { + if (random(112, 2)) + v11 = left[md]; + else + v11 = right[md]; + md = v11; + } + } + v2->_mdir = md; + v15 = random(112, 100); + if (abs(v17) < v6 && abs(v4) < v6 && v2->_mFlags & 1) { + M_StartFadein(arglist, md, FALSE); + } else { + v12 = v6 + 1; + if (abs(v17) < v12 && abs(v4) < v12 || v2->_mFlags & 1) { + if (_LOBYTE(v2->_mgoal) == 2 + || (abs(v17) >= 2 || abs(v4) >= 2) + && ((v13 = v2->_mVar2, v13 > 20) && v15 < 4 * (unsigned char)v2->_mint + 14 + || ((v14 = v2->_mVar1, v14 == 1) || v14 == 2 || v14 == 3) + && !v13 + && v15 < 4 * (unsigned char)v2->_mint + 64)) { + ++v2->_mgoalvar1; + M_CallWalk(arglist, md); + } + } else { + M_StartFadeout(arglist, md, TRUE); + } + } + if (v2->_mmode == MM_STAND) { + if (abs(v17) >= 2 || abs(v4) >= 2 || v15 >= 4 * (unsigned char)v2->_mint + 10) + v2->_mAnimData = v2->MType->Anims[MA_STAND].Data[md]; + else + M_StartAttack(arglist); + } + } + } } // 642A14: using guessed type char lightmax; void __fastcall MAI_Fireman(int i) { - int esi1; // esi - int esi3; // esi - int v3; // ecx - int v4; // eax - int v5; // ebx - int v6; // edi - int v7; // edx - char v9; // al - //int v10; // eax - //int v11; // eax - int v13; // eax - //int v14; // eax - int v15; // edx - //int v16; // eax - int v17; // eax - int micaster; // [esp+Ch] [ebp-14h] - int v1; // [esp+10h] [ebp-10h] - int v2; // [esp+14h] [ebp-Ch] - int midir; // [esp+18h] [ebp-8h] - int arglist; // [esp+1Ch] [ebp-4h] + int esi1; // esi + int esi3; // esi + int v3; // ecx + int v4; // eax + int v5; // ebx + int v6; // edi + int v7; // edx + char v9; // al + //int v10; // eax + //int v11; // eax + int v13; // eax + //int v14; // eax + int v15; // edx + //int v16; // eax + int v17; // eax + int micaster; // [esp+Ch] [ebp-14h] + int v1; // [esp+10h] [ebp-10h] + int v2; // [esp+14h] [ebp-Ch] + int midir; // [esp+18h] [ebp-8h] + int arglist; // [esp+1Ch] [ebp-4h] - esi1 = i; - arglist = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_Fireman: Invalid monster %d", i); - esi3 = esi1; - if (monster[esi3]._mmode || !monster[esi3]._msquelch) - return; - v3 = (unsigned char)monster[esi3]._menemyy; - micaster = monster[esi3]._menemy; - v4 = (unsigned char)monster[esi3]._menemyx; - v2 = v3; - v5 = monster[esi3]._my - v3; - v1 = v4; - v6 = monster[esi3]._mx - v4; - v7 = M_GetDir(arglist); - v9 = monster[esi3]._mgoal; - midir = v7; - switch (v9) { - case 1: - //_LOBYTE(v10) = LineClear(monster[esi3]._mx, monster[esi3]._my, v1, v2); - if (!LineClear(monster[esi3]._mx, monster[esi3]._my, v1, v2) - || AddMissile(monster[esi3]._mx, monster[esi3]._my, v1, v2, midir, 50, micaster, arglist, 0, 0) == -1) { - break; - } - monster[esi3]._mgoalvar1 = 0; - monster[esi3]._mmode = MM_CHARGE; - goto LABEL_18; - case 5: - if (monster[esi3]._mgoalvar1 == 3) { - _LOBYTE(monster[esi3]._mgoal) = 1; - M_StartFadeout(arglist, v7, TRUE); - } else { - //_LOBYTE(v11) = LineClear(monster[esi3]._mx, monster[esi3]._my, v1, v2); - if (LineClear(monster[esi3]._mx, monster[esi3]._my, v1, v2)) { - M_StartRAttack(arglist, 51, 4); - } else { - //_LOBYTE(v11) = LineClear(monster[esi3]._mx, monster[esi3]._my, v1, v2); - if (LineClear(monster[esi3]._mx, monster[esi3]._my, v1, v2)) { - M_StartRAttack(arglist, 51, 4); - } else { - v13 = random(112, 10); - M_StartDelay(arglist, v13 + 5); - } - ++monster[esi3]._mgoalvar1; - } - ++monster[esi3]._mgoalvar1; - } - break; - case 2: - M_StartFadein(arglist, v7, FALSE); - LABEL_18: - _LOBYTE(monster[esi3]._mgoal) = 5; - break; - } - monster[esi3]._mdir = midir; - random(112, 100); - if (monster[esi3]._mmode == MM_STAND) - return; - if (abs(v6) < 2 && abs(v5) < 2 && _LOBYTE(monster[esi3]._mgoal) == 1) { - M_TryH2HHit( - arglist, - monster[esi3]._menemy, - (unsigned char)monster[esi3].mHit, - (unsigned char)monster[esi3].mMinDamage, - (unsigned char)monster[esi3].mMaxDamage); - _LOBYTE(monster[esi3]._mgoal) = 2; - //_LOBYTE(v14) = M_CallWalk(arglist, opposite[midir]); - if (M_CallWalk(arglist, opposite[midir])) - return; - v15 = midir; - goto LABEL_29; - } - //_LOBYTE(v16) = M_CallWalk(arglist, midir); - if (!M_CallWalk(arglist, midir)) { - v17 = _LOBYTE(monster[esi3]._mgoal); - if ((_BYTE)v17 == 1 || (_BYTE)v17 == 2) { - v15 = midir; - LABEL_29: - M_StartFadein(arglist, v15, FALSE); - _LOBYTE(monster[esi3]._mgoal) = 5; - return; - } - } + esi1 = i; + arglist = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("MAI_Fireman: Invalid monster %d", i); + esi3 = esi1; + if (monster[esi3]._mmode || !monster[esi3]._msquelch) + return; + v3 = (unsigned char)monster[esi3]._menemyy; + micaster = monster[esi3]._menemy; + v4 = (unsigned char)monster[esi3]._menemyx; + v2 = v3; + v5 = monster[esi3]._my - v3; + v1 = v4; + v6 = monster[esi3]._mx - v4; + v7 = M_GetDir(arglist); + v9 = monster[esi3]._mgoal; + midir = v7; + switch (v9) { + case 1: + //_LOBYTE(v10) = LineClear(monster[esi3]._mx, monster[esi3]._my, v1, v2); + if (!LineClear(monster[esi3]._mx, monster[esi3]._my, v1, v2) + || AddMissile(monster[esi3]._mx, monster[esi3]._my, v1, v2, midir, 50, micaster, arglist, 0, 0) == -1) { + break; + } + monster[esi3]._mgoalvar1 = 0; + monster[esi3]._mmode = MM_CHARGE; + goto LABEL_18; + case 5: + if (monster[esi3]._mgoalvar1 == 3) { + _LOBYTE(monster[esi3]._mgoal) = 1; + M_StartFadeout(arglist, v7, TRUE); + } else { + //_LOBYTE(v11) = LineClear(monster[esi3]._mx, monster[esi3]._my, v1, v2); + if (LineClear(monster[esi3]._mx, monster[esi3]._my, v1, v2)) { + M_StartRAttack(arglist, 51, 4); + } else { + //_LOBYTE(v11) = LineClear(monster[esi3]._mx, monster[esi3]._my, v1, v2); + if (LineClear(monster[esi3]._mx, monster[esi3]._my, v1, v2)) { + M_StartRAttack(arglist, 51, 4); + } else { + v13 = random(112, 10); + M_StartDelay(arglist, v13 + 5); + } + ++monster[esi3]._mgoalvar1; + } + ++monster[esi3]._mgoalvar1; + } + break; + case 2: + M_StartFadein(arglist, v7, FALSE); + LABEL_18: + _LOBYTE(monster[esi3]._mgoal) = 5; + break; + } + monster[esi3]._mdir = midir; + random(112, 100); + if (monster[esi3]._mmode == MM_STAND) + return; + if (abs(v6) < 2 && abs(v5) < 2 && _LOBYTE(monster[esi3]._mgoal) == 1) { + M_TryH2HHit( + arglist, + monster[esi3]._menemy, + (unsigned char)monster[esi3].mHit, + (unsigned char)monster[esi3].mMinDamage, + (unsigned char)monster[esi3].mMaxDamage); + _LOBYTE(monster[esi3]._mgoal) = 2; + //_LOBYTE(v14) = M_CallWalk(arglist, opposite[midir]); + if (M_CallWalk(arglist, opposite[midir])) + return; + v15 = midir; + goto LABEL_29; + } + //_LOBYTE(v16) = M_CallWalk(arglist, midir); + if (!M_CallWalk(arglist, midir)) { + v17 = _LOBYTE(monster[esi3]._mgoal); + if ((_BYTE)v17 == 1 || (_BYTE)v17 == 2) { + v15 = midir; + LABEL_29: + M_StartFadein(arglist, v15, FALSE); + _LOBYTE(monster[esi3]._mgoal) = 5; + return; + } + } } void __fastcall MAI_Fallen(int i) { - int v1; // edi - //int v2; // ST04_4 - int v3; // esi - int v4; // eax - int v5; // ecx - int *v6; // eax - int v7; // edx - int v8; // edx - int j; // edi - int k; // ecx - int v11; // eax - int v12; // eax - char v13; // al - int v14; // edx - int v15; // eax - int v16; // esi + int v1; // edi + //int v2; // ST04_4 + int v3; // esi + int v4; // eax + int v5; // ecx + int *v6; // eax + int v7; // edx + int v8; // edx + int j; // edi + int k; // ecx + int v11; // eax + int v12; // eax + char v13; // al + int v14; // edx + int v15; // eax + int v16; // esi - v1 = i; - if ((DWORD)i >= MAXMONSTERS) { - TermMsg("MAI_Fallen: Invalid monster %d", i); - //i = v2; - } - v3 = v1; - if (_LOBYTE(monster[v1]._mgoal) == 5) { - i = monster[v3]._mgoalvar1; - if (i) - monster[v3]._mgoalvar1 = --i; - else - _LOBYTE(monster[v3]._mgoal) = 1; - } - if (monster[v3]._mmode == MM_STAND && monster[v3]._msquelch) { - if (_LOBYTE(monster[v3]._mgoal) == 2) { - i = monster[v3]._mgoalvar1; - monster[v3]._mgoalvar1 = i - 1; - if (!i) { - v4 = monster[v3]._mdir; - _LOBYTE(monster[v3]._mgoal) = 1; - M_StartStand(v1, opposite[v4]); - } - } - if (monster[v3]._mAnimFrame != monster[v3]._mAnimLen) { - v13 = monster[v3]._mgoal; - if (v13 == 2) { - v14 = monster[v3]._mdir; - } else { - if (v13 != 5) { - MAI_SkelSd(v1); - return; - } - v15 = monster[v3]._mx - (unsigned char)monster[v3]._menemyx; - v16 = monster[v3]._my - (unsigned char)monster[v3]._menemyy; - if (abs(v15) < 2 && abs(v16) < 2) { - M_StartAttack(v1); - return; - } - v14 = M_GetDir(v1); - } - M_CallWalk(v1, v14); - return; - } - if (!random(113, 4)) { - if (!(monster[v3]._mFlags & 8)) { - M_StartSpStand(v1, monster[v3]._mdir); - v5 = 2 * (unsigned char)monster[v3]._mint + 2; - v6 = &monster[v3]._mhitpoints; - v7 = monster[v3]._mhitpoints; - if (monster[v3]._mmaxhp - v5 < v7) - *v6 = monster[v3]._mmaxhp; - else - *v6 = v5 + v7; - } - v8 = 2 * (unsigned char)monster[v3]._mint + 4; - for (j = -v8; j <= v8; ++j) { - for (k = -v8; k <= v8; ++k) { - if (j >= 0 && j < 112 && k >= 0 && k < 112) { - v11 = dMonster[0][j + monster[v3]._my + 112 * (k + monster[v3]._mx)]; - if (v11 > 0) { - v12 = v11 - 1; - if (monster[v12]._mAi == AI_FALLEN) { - _LOBYTE(monster[v12]._mgoal) = 5; - monster[v12]._mgoalvar1 = 30 * (unsigned char)monster[v3]._mint + 105; - } - } - } - } - } - } - } + v1 = i; + if ((DWORD)i >= MAXMONSTERS) { + TermMsg("MAI_Fallen: Invalid monster %d", i); + //i = v2; + } + v3 = v1; + if (_LOBYTE(monster[v1]._mgoal) == 5) { + i = monster[v3]._mgoalvar1; + if (i) + monster[v3]._mgoalvar1 = --i; + else + _LOBYTE(monster[v3]._mgoal) = 1; + } + if (monster[v3]._mmode == MM_STAND && monster[v3]._msquelch) { + if (_LOBYTE(monster[v3]._mgoal) == 2) { + i = monster[v3]._mgoalvar1; + monster[v3]._mgoalvar1 = i - 1; + if (!i) { + v4 = monster[v3]._mdir; + _LOBYTE(monster[v3]._mgoal) = 1; + M_StartStand(v1, opposite[v4]); + } + } + if (monster[v3]._mAnimFrame != monster[v3]._mAnimLen) { + v13 = monster[v3]._mgoal; + if (v13 == 2) { + v14 = monster[v3]._mdir; + } else { + if (v13 != 5) { + MAI_SkelSd(v1); + return; + } + v15 = monster[v3]._mx - (unsigned char)monster[v3]._menemyx; + v16 = monster[v3]._my - (unsigned char)monster[v3]._menemyy; + if (abs(v15) < 2 && abs(v16) < 2) { + M_StartAttack(v1); + return; + } + v14 = M_GetDir(v1); + } + M_CallWalk(v1, v14); + return; + } + if (!random(113, 4)) { + if (!(monster[v3]._mFlags & 8)) { + M_StartSpStand(v1, monster[v3]._mdir); + v5 = 2 * (unsigned char)monster[v3]._mint + 2; + v6 = &monster[v3]._mhitpoints; + v7 = monster[v3]._mhitpoints; + if (monster[v3]._mmaxhp - v5 < v7) + *v6 = monster[v3]._mmaxhp; + else + *v6 = v5 + v7; + } + v8 = 2 * (unsigned char)monster[v3]._mint + 4; + for (j = -v8; j <= v8; ++j) { + for (k = -v8; k <= v8; ++k) { + if (j >= 0 && j < 112 && k >= 0 && k < 112) { + v11 = dMonster[0][j + monster[v3]._my + 112 * (k + monster[v3]._mx)]; + if (v11 > 0) { + v12 = v11 - 1; + if (monster[v12]._mAi == AI_FALLEN) { + _LOBYTE(monster[v12]._mgoal) = 5; + monster[v12]._mgoalvar1 = 30 * (unsigned char)monster[v3]._mint + 105; + } + } + } + } + } + } + } } void __fastcall MAI_Cleaver(int i) { - int v1; // esi - MonsterStruct *v2; // esi - int v3; // ecx - int v4; // edx - int v5; // edi - int v6; // ebp - int v7; // ebx - int arglist; // [esp+8h] [ebp-4h] + int v1; // esi + MonsterStruct *v2; // esi + int v3; // ecx + int v4; // edx + int v5; // edi + int v6; // ebp + int v7; // ebx + int arglist; // [esp+8h] [ebp-4h] - v1 = i; - arglist = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_Cleaver: Invalid monster %d", i); - v2 = &monster[v1]; - if (v2->_mmode == MM_STAND && v2->_msquelch) { - v3 = v2->_mx; - v4 = v2->_my; - v5 = v3 - (unsigned char)v2->_menemyx; - v6 = v4 - (unsigned char)v2->_menemyy; - v7 = GetDirection(v3, v4, v2->_lastx, v2->_lasty); - v2->_mdir = v7; - if (abs(v5) >= 2 || abs(v6) >= 2) - M_CallWalk(arglist, v7); - else - M_StartAttack(arglist); - if (v2->_mmode == MM_STAND) - v2->_mAnimData = v2->MType->Anims[MA_STAND].Data[v7]; - } + v1 = i; + arglist = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("MAI_Cleaver: Invalid monster %d", i); + v2 = &monster[v1]; + if (v2->_mmode == MM_STAND && v2->_msquelch) { + v3 = v2->_mx; + v4 = v2->_my; + v5 = v3 - (unsigned char)v2->_menemyx; + v6 = v4 - (unsigned char)v2->_menemyy; + v7 = GetDirection(v3, v4, v2->_lastx, v2->_lasty); + v2->_mdir = v7; + if (abs(v5) >= 2 || abs(v6) >= 2) + M_CallWalk(arglist, v7); + else + M_StartAttack(arglist); + if (v2->_mmode == MM_STAND) + v2->_mAnimData = v2->MType->Anims[MA_STAND].Data[v7]; + } } void __fastcall MAI_Round(int i, unsigned char special) { - int v2; // esi - MonsterStruct *v3; // esi - int v4; // edx - int v5; // ecx - int v6; // edi - int v7; // ebx - int v9; // eax - //int v10; // ST04_4 - int v12; // eax - //int v13; // ST04_4 - int v15; // edi - int v16; // eax - int v17; // ecx - bool v18; // eax - //int v19; // eax - int v21; // eax - int v22; // eax - //int v23; // ST04_4 - signed int v25; // ecx - int v26; // eax - int v27; // [esp+4h] [ebp-18h] - int v28; // [esp+8h] [ebp-14h] - char *v29; // [esp+8h] [ebp-14h] - int v30; // [esp+Ch] [ebp-10h] - int md; // [esp+10h] [ebp-Ch] - int v32; // [esp+14h] [ebp-8h] - int arglist; // [esp+18h] [ebp-4h] + int v2; // esi + MonsterStruct *v3; // esi + int v4; // edx + int v5; // ecx + int v6; // edi + int v7; // ebx + int v9; // eax + //int v10; // ST04_4 + int v12; // eax + //int v13; // ST04_4 + int v15; // edi + int v16; // eax + int v17; // ecx + bool v18; // eax + //int v19; // eax + int v21; // eax + int v22; // eax + //int v23; // ST04_4 + signed int v25; // ecx + int v26; // eax + int v27; // [esp+4h] [ebp-18h] + int v28; // [esp+8h] [ebp-14h] + char *v29; // [esp+8h] [ebp-14h] + int v30; // [esp+Ch] [ebp-10h] + int md; // [esp+10h] [ebp-Ch] + int v32; // [esp+14h] [ebp-8h] + int arglist; // [esp+18h] [ebp-4h] - v2 = i; - v27 = special; - arglist = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_Round: Invalid monster %d", i); - v3 = &monster[v2]; - if (v3->_mmode == MM_STAND && v3->_msquelch) { - v4 = v3->_my; - v5 = v3->_mx; - v28 = (unsigned char)v3->_menemyy; - v6 = (unsigned char)v3->_menemyx; - v7 = v5 - v6; - v32 = v4 - v28; - md = GetDirection(v5, v4, v3->_lastx, v3->_lasty); - if (v3->_msquelch < 0xFFu) /* check sign */ - MonstCheckDoors(arglist); - v30 = random(114, 100); - if ((abs(v7) >= 2 || abs(v32) >= 2) && v3->_msquelch == -1) { - v29 = &dung_map[v6][v28]; - if (dung_map[v3->_mx][v3->_my] == *v29) { - if (_LOBYTE(v3->_mgoal) != 4) { - v9 = abs(v7); - //v11 = v10; - if (v9 < 4) { - v12 = abs(v32); - //v11 = v13; - if (v12 < 4) - goto LABEL_26; - } - if (random(115, 4)) - goto LABEL_26; - if (_LOBYTE(v3->_mgoal) != 4) { - v3->_mgoalvar1 = 0; - v3->_mgoalvar2 = random(116, 2); - } - } - _LOBYTE(v3->_mgoal) = 4; - v15 = abs(v32); - if (abs(v7) <= v15) - v16 = abs(v32); - else - v16 = abs(v7); - v17 = v3->_mgoalvar1; - v3->_mgoalvar1 = v17 + 1; - if (v17 < 2 * v16 || (v18 = DirOK(arglist, md), !v18)) { - if (dung_map[v3->_mx][v3->_my] == *v29) { - //_LOBYTE(v19) = M_RoundWalk(arglist, md, &v3->_mgoalvar2); - if (!M_RoundWalk(arglist, md, &v3->_mgoalvar2)) { - v21 = random(125, 10); - M_StartDelay(arglist, v21 + 10); - } - goto LABEL_26; - } - } - } - } - _LOBYTE(v3->_mgoal) = 1; - LABEL_26: - if (_LOBYTE(v3->_mgoal) == 1) { - if (abs(v7) >= 2 || (v22 = abs(v32), v22 >= 2)) /* v24 = v23, */ - { - v25 = v3->_mVar2; - if (v25 > 20 && v30 < 2 * (unsigned char)v3->_mint + 28 - || ((v26 = v3->_mVar1, v26 == 1) || v26 == 2 || v26 == 3) - && !v25 - && v30 < 2 * (unsigned char)v3->_mint + 78) { - M_CallWalk(arglist, md); - } - } else if (v30 < 2 * (unsigned char)v3->_mint + 23) { - v3->_mdir = md; - if (v27 && v3->_mhitpoints_mmaxhp>> 1 && random(117, 2)) - M_StartSpAttack(arglist); - else - M_StartAttack(arglist); - } - } - if (v3->_mmode == MM_STAND) - v3->_mAnimData = v3->MType->Anims[MA_STAND].Data[md]; - } + v2 = i; + v27 = special; + arglist = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("MAI_Round: Invalid monster %d", i); + v3 = &monster[v2]; + if (v3->_mmode == MM_STAND && v3->_msquelch) { + v4 = v3->_my; + v5 = v3->_mx; + v28 = (unsigned char)v3->_menemyy; + v6 = (unsigned char)v3->_menemyx; + v7 = v5 - v6; + v32 = v4 - v28; + md = GetDirection(v5, v4, v3->_lastx, v3->_lasty); + if (v3->_msquelch < 0xFFu) /* check sign */ + MonstCheckDoors(arglist); + v30 = random(114, 100); + if ((abs(v7) >= 2 || abs(v32) >= 2) && v3->_msquelch == -1) { + v29 = &dung_map[v6][v28]; + if (dung_map[v3->_mx][v3->_my] == *v29) { + if (_LOBYTE(v3->_mgoal) != 4) { + v9 = abs(v7); + //v11 = v10; + if (v9 < 4) { + v12 = abs(v32); + //v11 = v13; + if (v12 < 4) + goto LABEL_26; + } + if (random(115, 4)) + goto LABEL_26; + if (_LOBYTE(v3->_mgoal) != 4) { + v3->_mgoalvar1 = 0; + v3->_mgoalvar2 = random(116, 2); + } + } + _LOBYTE(v3->_mgoal) = 4; + v15 = abs(v32); + if (abs(v7) <= v15) + v16 = abs(v32); + else + v16 = abs(v7); + v17 = v3->_mgoalvar1; + v3->_mgoalvar1 = v17 + 1; + if (v17 < 2 * v16 || (v18 = DirOK(arglist, md), !v18)) { + if (dung_map[v3->_mx][v3->_my] == *v29) { + //_LOBYTE(v19) = M_RoundWalk(arglist, md, &v3->_mgoalvar2); + if (!M_RoundWalk(arglist, md, &v3->_mgoalvar2)) { + v21 = random(125, 10); + M_StartDelay(arglist, v21 + 10); + } + goto LABEL_26; + } + } + } + } + _LOBYTE(v3->_mgoal) = 1; + LABEL_26: + if (_LOBYTE(v3->_mgoal) == 1) { + if (abs(v7) >= 2 || (v22 = abs(v32), v22 >= 2)) /* v24 = v23, */ + { + v25 = v3->_mVar2; + if (v25 > 20 && v30 < 2 * (unsigned char)v3->_mint + 28 + || ((v26 = v3->_mVar1, v26 == 1) || v26 == 2 || v26 == 3) + && !v25 + && v30 < 2 * (unsigned char)v3->_mint + 78) { + M_CallWalk(arglist, md); + } + } else if (v30 < 2 * (unsigned char)v3->_mint + 23) { + v3->_mdir = md; + if (v27 && v3->_mhitpoints_mmaxhp>> 1 && random(117, 2)) + M_StartSpAttack(arglist); + else + M_StartAttack(arglist); + } + } + if (v3->_mmode == MM_STAND) + v3->_mAnimData = v3->MType->Anims[MA_STAND].Data[md]; + } } void __fastcall MAI_GoatMc(int i) { - MAI_Round(i, 1u); + MAI_Round(i, 1u); } void __fastcall MAI_Ranged(int i, int missile_type, unsigned char special) { - int v3; // edi - int v4; // esi - char v5; // al - int v6; // eax - int v7; // ecx - int v8; // ebx - int v9; // edi - bool v11; // zf - int v12; // eax - int v13; // eax - //int v14; // ST00_4 - //int v16; // eax - int x2; // [esp+8h] [ebp-14h] - int y2; // [esp+Ch] [ebp-10h] - int missile_typea; // [esp+10h] [ebp-Ch] - int v20; // [esp+14h] [ebp-8h] - int arglist; // [esp+18h] [ebp-4h] + int v3; // edi + int v4; // esi + char v5; // al + int v6; // eax + int v7; // ecx + int v8; // ebx + int v9; // edi + bool v11; // zf + int v12; // eax + int v13; // eax + //int v14; // ST00_4 + //int v16; // eax + int x2; // [esp+8h] [ebp-14h] + int y2; // [esp+Ch] [ebp-10h] + int missile_typea; // [esp+10h] [ebp-Ch] + int v20; // [esp+14h] [ebp-8h] + int arglist; // [esp+18h] [ebp-4h] - v3 = i; - missile_typea = missile_type; - arglist = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_Ranged: Invalid monster %d", i); - v4 = v3; - if (monster[v3]._mmode == MM_STAND) { - v5 = monster[v4]._msquelch; - if (v5 == -1 || monster[v4]._mFlags & 0x10) { - v7 = (unsigned char)monster[v4]._menemyy; - y2 = v7; - v8 = monster[v4]._my - v7; - x2 = (unsigned char)monster[v4]._menemyx; - v9 = monster[v4]._mx - x2; - v20 = M_GetDir(arglist); - if (monster[v4]._msquelch < 0xFFu) /* check sign */ - MonstCheckDoors(arglist); - v11 = monster[v4]._mVar1 == 10; - monster[v4]._mdir = v20; - if (v11) { - v12 = random(118, 20); - M_StartDelay(arglist, v12); - } else if (abs(v9) < 4) { - v13 = abs(v8); - //v15 = v14; - if (v13 < 4) { - if (random(119, 100) < 10 * ((unsigned char)monster[v4]._mint + 7)) - M_CallWalk(arglist, opposite[v20]); - } - } - if (monster[v4]._mmode == MM_STAND) { - //_LOBYTE(v16) = LineClear(monster[v4]._mx, monster[v4]._my, x2, y2); - if (LineClear(monster[v4]._mx, monster[v4]._my, x2, y2)) { - if (special) - M_StartRSpAttack(arglist, missile_typea, 4); - else - M_StartRAttack(arglist, missile_typea, 4); - } else { - monster[v4]._mAnimData = monster[v4].MType->Anims[MA_STAND].Data[v20]; - } - } - } else if (v5) { - v6 = GetDirection(monster[v4]._mx, monster[v4]._my, monster[v4]._lastx, monster[v4]._lasty); - M_CallWalk(v3, v6); - } - } + v3 = i; + missile_typea = missile_type; + arglist = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("MAI_Ranged: Invalid monster %d", i); + v4 = v3; + if (monster[v3]._mmode == MM_STAND) { + v5 = monster[v4]._msquelch; + if (v5 == -1 || monster[v4]._mFlags & 0x10) { + v7 = (unsigned char)monster[v4]._menemyy; + y2 = v7; + v8 = monster[v4]._my - v7; + x2 = (unsigned char)monster[v4]._menemyx; + v9 = monster[v4]._mx - x2; + v20 = M_GetDir(arglist); + if (monster[v4]._msquelch < 0xFFu) /* check sign */ + MonstCheckDoors(arglist); + v11 = monster[v4]._mVar1 == 10; + monster[v4]._mdir = v20; + if (v11) { + v12 = random(118, 20); + M_StartDelay(arglist, v12); + } else if (abs(v9) < 4) { + v13 = abs(v8); + //v15 = v14; + if (v13 < 4) { + if (random(119, 100) < 10 * ((unsigned char)monster[v4]._mint + 7)) + M_CallWalk(arglist, opposite[v20]); + } + } + if (monster[v4]._mmode == MM_STAND) { + //_LOBYTE(v16) = LineClear(monster[v4]._mx, monster[v4]._my, x2, y2); + if (LineClear(monster[v4]._mx, monster[v4]._my, x2, y2)) { + if (special) + M_StartRSpAttack(arglist, missile_typea, 4); + else + M_StartRAttack(arglist, missile_typea, 4); + } else { + monster[v4]._mAnimData = monster[v4].MType->Anims[MA_STAND].Data[v20]; + } + } + } else if (v5) { + v6 = GetDirection(monster[v4]._mx, monster[v4]._my, monster[v4]._lastx, monster[v4]._lasty); + M_CallWalk(v3, v6); + } + } } void __fastcall MAI_GoatBow(int i) { - MAI_Ranged(i, 0, 0); + MAI_Ranged(i, 0, 0); } void __fastcall MAI_Succ(int i) { - MAI_Ranged(i, 24, 0); + MAI_Ranged(i, 24, 0); } void __fastcall MAI_AcidUniq(int i) { - MAI_Ranged(i, 57, 1u); + MAI_Ranged(i, 57, 1u); } void __fastcall MAI_Scav(int i) { - int v1; // edi - int v2; // esi - unsigned char *v3; // eax - int v4; // ecx - int v5; // ecx - signed int v6; // ebx - signed int v7; // edi - int v8; // edx - int v9; // eax - bool v10; // eax - int v11; // ebx - int v12; // edi - signed int v13; // edi - int v14; // edx - int v15; // eax - bool v16; // eax - int v17; // eax - int v18; // eax - int arglist; // [esp+Ch] [ebp-8h] - BOOL v20; // [esp+10h] [ebp-4h] + int v1; // edi + int v2; // esi + unsigned char *v3; // eax + int v4; // ecx + int v5; // ecx + signed int v6; // ebx + signed int v7; // edi + int v8; // edx + int v9; // eax + bool v10; // eax + int v11; // ebx + int v12; // edi + signed int v13; // edi + int v14; // edx + int v15; // eax + bool v16; // eax + int v17; // eax + int v18; // eax + int arglist; // [esp+Ch] [ebp-8h] + BOOL v20; // [esp+10h] [ebp-4h] - v1 = i; - arglist = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_Scav: Invalid monster %d", i); - v2 = v1; - v20 = 0; - if (monster[v1]._mmode == MM_STAND) { - if (monster[v2]._mhitpoints> 1) { - if (_LOBYTE(monster[v2]._mgoal) == 3) - goto LABEL_10; - if (monster[v2].leaderflag) { - v3 = &monster[(unsigned char)monster[v2].leader].unpackfilesize; - --*v3; - monster[v2].leaderflag = 0; - } - _LOBYTE(monster[v2]._mgoal) = 3; - monster[v2]._mgoalvar3 = 10; - } - if (_LOBYTE(monster[v2]._mgoal) != 3) { - LABEL_52: - if (monster[v2]._mmode == MM_STAND) - MAI_SkelSd(arglist); - return; - } - LABEL_10: - v4 = monster[v2]._mgoalvar3; - if (v4) { - monster[v2]._mgoalvar3 = v4 - 1; - v5 = monster[v2]._my; - if (dDead[monster[v2]._mx][v5]) { - M_StartEat(v1); - if (!(monster[v2]._mFlags & 8)) - monster[v2]._mhitpoints += 64; - if (monster[v2]._mhitpoints >= (monster[v2]._mmaxhp >> 1) + (monster[v2]._mmaxhp >> 2)) { - _LOBYTE(monster[v2]._mgoal) = 1; - monster[v2]._mgoalvar1 = 0; - monster[v2]._mgoalvar2 = 0; - } - } else { - if (!monster[v2]._mgoalvar1) { - v6 = arglist; - if (random(120, 2)) { - v7 = -4; - do { - if (v20) - break; - v6 = -4; - do { - if (v20) - break; - if (v7 >= 0 && v7 < 112 && v6 >= 0 && v6 < 112) { - v8 = monster[v2]._mx; - v9 = monster[v2]._my; - v20 = dDead[v8 + v6][v9 + v7] - && (v10 = LineClearF( - CheckNoSolid, - v8, - v9, - v8 + v6, - v9 + v7), - v10); - } - ++v6; - } while (v6 <= 4); - ++v7; - } while (v7 <= 4); - v11 = v6 - 1; - v12 = v7 - 1; - } else { - v13 = 4; - do { - if (v20) - break; - v6 = 4; - do { - if (v20) - break; - if (v13 >= 0 && v13 < 112 && v6 >= 0 && v6 < 112) { - v14 = monster[v2]._mx; - v15 = monster[v2]._my; - v20 = dDead[v14 + v6][v15 + v13] - && (v16 = LineClearF( - CheckNoSolid, - v14, - v15, - v14 + v6, - v15 + v13), - v16); - } - --v6; - } while (v6 >= -4); - --v13; - } while (v13 >= -4); - v11 = v6 + 1; - v12 = v13 + 1; - } - if (v20) { - monster[v2]._mgoalvar1 = monster[v2]._mx + v11 + 1; - monster[v2]._mgoalvar2 = monster[v2]._my + v12 + 1; - } - } - v17 = monster[v2]._mgoalvar1; - if (v17) { - v18 = GetDirection(monster[v2]._mx, monster[v2]._my, v17 - 1, monster[v2]._mgoalvar2 - 1); - monster[v2]._mdir = v18; - M_CallWalk(arglist, v18); - } - } - } - goto LABEL_52; - } + v1 = i; + arglist = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("MAI_Scav: Invalid monster %d", i); + v2 = v1; + v20 = 0; + if (monster[v1]._mmode == MM_STAND) { + if (monster[v2]._mhitpoints> 1) { + if (_LOBYTE(monster[v2]._mgoal) == 3) + goto LABEL_10; + if (monster[v2].leaderflag) { + v3 = &monster[(unsigned char)monster[v2].leader].unpackfilesize; + --*v3; + monster[v2].leaderflag = 0; + } + _LOBYTE(monster[v2]._mgoal) = 3; + monster[v2]._mgoalvar3 = 10; + } + if (_LOBYTE(monster[v2]._mgoal) != 3) { + LABEL_52: + if (monster[v2]._mmode == MM_STAND) + MAI_SkelSd(arglist); + return; + } + LABEL_10: + v4 = monster[v2]._mgoalvar3; + if (v4) { + monster[v2]._mgoalvar3 = v4 - 1; + v5 = monster[v2]._my; + if (dDead[monster[v2]._mx][v5]) { + M_StartEat(v1); + if (!(monster[v2]._mFlags & 8)) + monster[v2]._mhitpoints += 64; + if (monster[v2]._mhitpoints >= (monster[v2]._mmaxhp >> 1) + (monster[v2]._mmaxhp >> 2)) { + _LOBYTE(monster[v2]._mgoal) = 1; + monster[v2]._mgoalvar1 = 0; + monster[v2]._mgoalvar2 = 0; + } + } else { + if (!monster[v2]._mgoalvar1) { + v6 = arglist; + if (random(120, 2)) { + v7 = -4; + do { + if (v20) + break; + v6 = -4; + do { + if (v20) + break; + if (v7 >= 0 && v7 < 112 && v6 >= 0 && v6 < 112) { + v8 = monster[v2]._mx; + v9 = monster[v2]._my; + v20 = dDead[v8 + v6][v9 + v7] + && (v10 = LineClearF( + CheckNoSolid, + v8, + v9, + v8 + v6, + v9 + v7), + v10); + } + ++v6; + } while (v6 <= 4); + ++v7; + } while (v7 <= 4); + v11 = v6 - 1; + v12 = v7 - 1; + } else { + v13 = 4; + do { + if (v20) + break; + v6 = 4; + do { + if (v20) + break; + if (v13 >= 0 && v13 < 112 && v6 >= 0 && v6 < 112) { + v14 = monster[v2]._mx; + v15 = monster[v2]._my; + v20 = dDead[v14 + v6][v15 + v13] + && (v16 = LineClearF( + CheckNoSolid, + v14, + v15, + v14 + v6, + v15 + v13), + v16); + } + --v6; + } while (v6 >= -4); + --v13; + } while (v13 >= -4); + v11 = v6 + 1; + v12 = v13 + 1; + } + if (v20) { + monster[v2]._mgoalvar1 = monster[v2]._mx + v11 + 1; + monster[v2]._mgoalvar2 = monster[v2]._my + v12 + 1; + } + } + v17 = monster[v2]._mgoalvar1; + if (v17) { + v18 = GetDirection(monster[v2]._mx, monster[v2]._my, v17 - 1, monster[v2]._mgoalvar2 - 1); + monster[v2]._mdir = v18; + M_CallWalk(arglist, v18); + } + } + } + goto LABEL_52; + } } void __fastcall MAI_Garg(int i) { - int v1; // ebp - MonsterStruct *v2; // esi - int v3; // edi - int v4; // ebx - char v5; // al - int v6; // edi - //int v7; // eax - int v8; // [esp+10h] [ebp-4h] + int v1; // ebp + MonsterStruct *v2; // esi + int v3; // edi + int v4; // ebx + char v5; // al + int v6; // edi + //int v7; // eax + int v8; // [esp+10h] [ebp-4h] - v1 = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_Garg: Invalid monster %d", i); - v2 = &monster[v1]; - v3 = v2->_mx - v2->_lastx; - v4 = v2->_my - v2->_lasty; - v8 = M_GetDir(v1); - v5 = v2->_msquelch; - if (v5 && v2->_mFlags & 4) { - M_Enemy(v1); - v6 = v2->_my - (unsigned char)v2->_menemyy; - if (abs(v2->_mx - (unsigned char)v2->_menemyx) < (unsigned char)v2->_mint + 2 - && abs(v6) < (unsigned char)v2->_mint + 2) { - v2->_mFlags &= 0xFFFFFFFB; - } - } else if (v2->_mmode == MM_STAND && v5) { - if (v2->_mhitpoints_mmaxhp>> 1 && !(v2->_mFlags & 8)) - _LOBYTE(v2->_mgoal) = 2; - if (_LOBYTE(v2->_mgoal) == 2) { - if (abs(v3) >= (unsigned char)v2->_mint + 2 || abs(v4) >= (unsigned char)v2->_mint + 2) { - _LOBYTE(v2->_mgoal) = 1; - M_StartHeal(v1); - } else { - //_LOBYTE(v7) = M_CallWalk(v1, opposite[v8]); - if (!M_CallWalk(v1, opposite[v8])) - _LOBYTE(v2->_mgoal) = 1; - } - } - MAI_Round(v1, 0); - } + v1 = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("MAI_Garg: Invalid monster %d", i); + v2 = &monster[v1]; + v3 = v2->_mx - v2->_lastx; + v4 = v2->_my - v2->_lasty; + v8 = M_GetDir(v1); + v5 = v2->_msquelch; + if (v5 && v2->_mFlags & 4) { + M_Enemy(v1); + v6 = v2->_my - (unsigned char)v2->_menemyy; + if (abs(v2->_mx - (unsigned char)v2->_menemyx) < (unsigned char)v2->_mint + 2 + && abs(v6) < (unsigned char)v2->_mint + 2) { + v2->_mFlags &= 0xFFFFFFFB; + } + } else if (v2->_mmode == MM_STAND && v5) { + if (v2->_mhitpoints_mmaxhp>> 1 && !(v2->_mFlags & 8)) + _LOBYTE(v2->_mgoal) = 2; + if (_LOBYTE(v2->_mgoal) == 2) { + if (abs(v3) >= (unsigned char)v2->_mint + 2 || abs(v4) >= (unsigned char)v2->_mint + 2) { + _LOBYTE(v2->_mgoal) = 1; + M_StartHeal(v1); + } else { + //_LOBYTE(v7) = M_CallWalk(v1, opposite[v8]); + if (!M_CallWalk(v1, opposite[v8])) + _LOBYTE(v2->_mgoal) = 1; + } + } + MAI_Round(v1, 0); + } } void __fastcall MAI_RoundRanged(int i, int missile_type, unsigned char checkdoors, int dam, int lessmissiles) { - int v5; // esi - MonsterStruct *v6; // esi - int v7; // edx - int v8; // ebx - int v9; // edi - int v11; // eax - //int v12; // ST04_4 - int v13; // ecx - int v14; // eax - //int v15; // ST04_4 - int v16; // eax - //int v17; // ST04_4 - int v18; // ecx - int v19; // ebx - int v20; // eax - int v21; // ecx - bool v22; // eax - bool v23; // eax - bool v24; // eax - int v25; // eax - //int v26; // ST04_4 - int v27; // eax - //int v28; // ST04_4 - int v29; // eax - int v30; // edx - int v31; // eax - int missile_typea; // [esp+4h] [ebp-18h] - int v33; // [esp+8h] [ebp-14h] - int x2; // [esp+Ch] [ebp-10h] - int md; // [esp+10h] [ebp-Ch] - int y2; // [esp+14h] [ebp-8h] - int arglist; // [esp+18h] [ebp-4h] - int checkdoorsa; // [esp+24h] [ebp+8h] + int v5; // esi + MonsterStruct *v6; // esi + int v7; // edx + int v8; // ebx + int v9; // edi + int v11; // eax + //int v12; // ST04_4 + int v13; // ecx + int v14; // eax + //int v15; // ST04_4 + int v16; // eax + //int v17; // ST04_4 + int v18; // ecx + int v19; // ebx + int v20; // eax + int v21; // ecx + bool v22; // eax + bool v23; // eax + bool v24; // eax + int v25; // eax + //int v26; // ST04_4 + int v27; // eax + //int v28; // ST04_4 + int v29; // eax + int v30; // edx + int v31; // eax + int missile_typea; // [esp+4h] [ebp-18h] + int v33; // [esp+8h] [ebp-14h] + int x2; // [esp+Ch] [ebp-10h] + int md; // [esp+10h] [ebp-Ch] + int y2; // [esp+14h] [ebp-8h] + int arglist; // [esp+18h] [ebp-4h] + int checkdoorsa; // [esp+24h] [ebp+8h] - v5 = i; - missile_typea = missile_type; - arglist = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_RoundRanged: Invalid monster %d", i); - v6 = &monster[v5]; - if (v6->_mmode == MM_STAND && v6->_msquelch) { - v7 = v6->_my; - y2 = (unsigned char)v6->_menemyy; - v8 = v7 - y2; - x2 = (unsigned char)v6->_menemyx; - v9 = v6->_mx - x2; - v33 = v7 - y2; - md = GetDirection(v6->_mx, v7, v6->_lastx, v6->_lasty); - if (checkdoors && v6->_msquelch < 0xFFu) /* check sign */ - MonstCheckDoors(arglist); - checkdoorsa = random(121, 10000); - v11 = abs(v9); - //v13 = v12; - if (v11 < 2) { - v14 = abs(v8); - //v13 = v15; - if (v14 < 2) - goto LABEL_50; - } - if (v6->_msquelch != -1) - goto LABEL_50; - //v13 = y2; - if (dung_map[v6->_mx][v6->_my] != dung_map[x2][y2]) - goto LABEL_50; - if (_LOBYTE(v6->_mgoal) != 4) { - if (abs(v9) < 3) { - v16 = abs(v8); - //v13 = v17; - if (v16 < 3) - goto LABEL_28; - } - v18 = lessmissiles; - if (random(122, 4 << lessmissiles)) - goto LABEL_28; - if (_LOBYTE(v6->_mgoal) != 4) { - v6->_mgoalvar1 = 0; - v6->_mgoalvar2 = random(123, 2); - } - } - _LOBYTE(v6->_mgoal) = 4; - v19 = abs(v8); - if (abs(v9) <= v19) { - v8 = v33; - v20 = abs(v33); - } else { - v20 = abs(v9); - v8 = v33; - } - v21 = v6->_mgoalvar1; - v6->_mgoalvar1 = v21 + 1; - if (v21 >= 2 * v20 && (v22 = DirOK(arglist, md), v22)) { - LABEL_50: - _LOBYTE(v6->_mgoal) = 1; - } else if (checkdoorsa<500 * ((unsigned char)v6->_mint + 1)>> lessmissiles - && (v23 = LineClear(v6->_mx, v6->_my, x2, y2), v23)) { - M_StartRSpAttack(arglist, missile_typea, dam); - } else { - M_RoundWalk(arglist, md, &v6->_mgoalvar2); - } - LABEL_28: - if (_LOBYTE(v6->_mgoal) == 1) { - if (((abs(v9) >= 3 || abs(v8) >= 3) && checkdoorsa<500 * ((unsigned char)v6->_mint + 2)>> lessmissiles - || checkdoorsa<500 * ((unsigned char)v6->_mint + 1)>> lessmissiles) - && (v24 = LineClear(v6->_mx, v6->_my, x2, y2), v24)) { - M_StartRSpAttack(arglist, missile_typea, dam); - } else { - v25 = abs(v9); - //v13 = v26; - if (v25 >= 2 || (v27 = abs(v8), v27 >= 2)) /* v13 = v28, */ - { - v29 = random(124, 100); - v30 = (unsigned char)v6->_mint; - if (v29 < 1000 * (v30 + 5) - || ((v13 = v6->_mVar1, v13 == 1) || v13 == 2 || v13 == 3) && !v6->_mVar2 && v29 < 1000 * (v30 + 8)) { - M_CallWalk(arglist, md); - } - } else if (checkdoorsa < 1000 * ((unsigned char)v6->_mint + 6)) { - v6->_mdir = md; - M_StartAttack(arglist); - } - } - } - if (v6->_mmode == MM_STAND) { - v31 = random(125, 10); - M_StartDelay(arglist, v31 + 5); - } - } + v5 = i; + missile_typea = missile_type; + arglist = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("MAI_RoundRanged: Invalid monster %d", i); + v6 = &monster[v5]; + if (v6->_mmode == MM_STAND && v6->_msquelch) { + v7 = v6->_my; + y2 = (unsigned char)v6->_menemyy; + v8 = v7 - y2; + x2 = (unsigned char)v6->_menemyx; + v9 = v6->_mx - x2; + v33 = v7 - y2; + md = GetDirection(v6->_mx, v7, v6->_lastx, v6->_lasty); + if (checkdoors && v6->_msquelch < 0xFFu) /* check sign */ + MonstCheckDoors(arglist); + checkdoorsa = random(121, 10000); + v11 = abs(v9); + //v13 = v12; + if (v11 < 2) { + v14 = abs(v8); + //v13 = v15; + if (v14 < 2) + goto LABEL_50; + } + if (v6->_msquelch != -1) + goto LABEL_50; + //v13 = y2; + if (dung_map[v6->_mx][v6->_my] != dung_map[x2][y2]) + goto LABEL_50; + if (_LOBYTE(v6->_mgoal) != 4) { + if (abs(v9) < 3) { + v16 = abs(v8); + //v13 = v17; + if (v16 < 3) + goto LABEL_28; + } + v18 = lessmissiles; + if (random(122, 4 << lessmissiles)) + goto LABEL_28; + if (_LOBYTE(v6->_mgoal) != 4) { + v6->_mgoalvar1 = 0; + v6->_mgoalvar2 = random(123, 2); + } + } + _LOBYTE(v6->_mgoal) = 4; + v19 = abs(v8); + if (abs(v9) <= v19) { + v8 = v33; + v20 = abs(v33); + } else { + v20 = abs(v9); + v8 = v33; + } + v21 = v6->_mgoalvar1; + v6->_mgoalvar1 = v21 + 1; + if (v21 >= 2 * v20 && (v22 = DirOK(arglist, md), v22)) { + LABEL_50: + _LOBYTE(v6->_mgoal) = 1; + } else if (checkdoorsa<500 * ((unsigned char)v6->_mint + 1)>> lessmissiles + && (v23 = LineClear(v6->_mx, v6->_my, x2, y2), v23)) { + M_StartRSpAttack(arglist, missile_typea, dam); + } else { + M_RoundWalk(arglist, md, &v6->_mgoalvar2); + } + LABEL_28: + if (_LOBYTE(v6->_mgoal) == 1) { + if (((abs(v9) >= 3 || abs(v8) >= 3) && checkdoorsa<500 * ((unsigned char)v6->_mint + 2)>> lessmissiles + || checkdoorsa<500 * ((unsigned char)v6->_mint + 1)>> lessmissiles) + && (v24 = LineClear(v6->_mx, v6->_my, x2, y2), v24)) { + M_StartRSpAttack(arglist, missile_typea, dam); + } else { + v25 = abs(v9); + //v13 = v26; + if (v25 >= 2 || (v27 = abs(v8), v27 >= 2)) /* v13 = v28, */ + { + v29 = random(124, 100); + v30 = (unsigned char)v6->_mint; + if (v29 < 1000 * (v30 + 5) + || ((v13 = v6->_mVar1, v13 == 1) || v13 == 2 || v13 == 3) && !v6->_mVar2 && v29 < 1000 * (v30 + 8)) { + M_CallWalk(arglist, md); + } + } else if (checkdoorsa < 1000 * ((unsigned char)v6->_mint + 6)) { + v6->_mdir = md; + M_StartAttack(arglist); + } + } + } + if (v6->_mmode == MM_STAND) { + v31 = random(125, 10); + M_StartDelay(arglist, v31 + 5); + } + } } void __fastcall MAI_Magma(int i) { - MAI_RoundRanged(i, 21, 1u, 4, 0); + MAI_RoundRanged(i, 21, 1u, 4, 0); } void __fastcall MAI_Storm(int i) { - MAI_RoundRanged(i, 22, 1u, 4, 0); + MAI_RoundRanged(i, 22, 1u, 4, 0); } void __fastcall MAI_Acid(int i) { - MAI_RoundRanged(i, 57, 0, 4, 1); + MAI_RoundRanged(i, 57, 0, 4, 1); } void __fastcall MAI_Diablo(int i) { - MAI_RoundRanged(i, 67, 0, 40, 0); + MAI_RoundRanged(i, 67, 0, 40, 0); } void __fastcall MAI_RR2(int i, int mistype, int dam) { - int v3; // ebx - MonsterStruct *v4; // esi - int v5; // edi - int v6; // edx - int v7; // ebx - int v8; // edi - int v10; // eax - //int v11; // ST04_4 - int v12; // ecx - int v13; // eax - //int v14; // ST04_4 - int v15; // eax - //int v16; // ST04_4 - int v17; // eax - //int v18; // ST04_4 - int v19; // ebx - int v20; // eax - bool v21; // eax - bool v22; // eax - int v23; // ecx - int v24; // eax - //int v25; // ST04_4 - int v27; // eax - //int v28; // ST04_4 - int v29; // eax - int v30; // eax - int v31; // eax - int v32; // edx - int v33; // eax - int missile_type; // [esp+Ch] [ebp-1Ch] - int x2; // [esp+10h] [ebp-18h] - int v36; // [esp+14h] [ebp-14h] - int y2; // [esp+18h] [ebp-10h] - int v38; // [esp+1Ch] [ebp-Ch] - int md; // [esp+20h] [ebp-8h] - int arglist; // [esp+24h] [ebp-4h] + int v3; // ebx + MonsterStruct *v4; // esi + int v5; // edi + int v6; // edx + int v7; // ebx + int v8; // edi + int v10; // eax + //int v11; // ST04_4 + int v12; // ecx + int v13; // eax + //int v14; // ST04_4 + int v15; // eax + //int v16; // ST04_4 + int v17; // eax + //int v18; // ST04_4 + int v19; // ebx + int v20; // eax + bool v21; // eax + bool v22; // eax + int v23; // ecx + int v24; // eax + //int v25; // ST04_4 + int v27; // eax + //int v28; // ST04_4 + int v29; // eax + int v30; // eax + int v31; // eax + int v32; // edx + int v33; // eax + int missile_type; // [esp+Ch] [ebp-1Ch] + int x2; // [esp+10h] [ebp-18h] + int v36; // [esp+14h] [ebp-14h] + int y2; // [esp+18h] [ebp-10h] + int v38; // [esp+1Ch] [ebp-Ch] + int md; // [esp+20h] [ebp-8h] + int arglist; // [esp+24h] [ebp-4h] - v3 = i; - missile_type = mistype; - arglist = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_RR2: Invalid monster %d", i); - v4 = &monster[v3]; - v5 = v4->_my - (unsigned char)v4->_menemyy; - if (abs(v4->_mx - (unsigned char)v4->_menemyx) >= 5 || abs(v5) >= 5) { - MAI_SkelSd(v3); - return; - } - if (v4->_mmode == MM_STAND && v4->_msquelch) { - v6 = v4->_my; - y2 = (unsigned char)v4->_menemyy; - v7 = v6 - y2; - x2 = (unsigned char)v4->_menemyx; - v8 = v4->_mx - x2; - v36 = v6 - y2; - md = GetDirection(v4->_mx, v6, v4->_lastx, v4->_lasty); - if (v4->_msquelch < 0xFFu) /* check sign */ - MonstCheckDoors(arglist); - v38 = random(121, 100); - v10 = abs(v8); - //v12 = v11; - if (v10 >= 2 || (v13 = abs(v7), v13 >= 2)) /* v12 = v14, */ - { - if (v4->_msquelch == -1) { - //v12 = y2; - if (dung_map[v4->_mx][v4->_my] == dung_map[x2][y2]) { - if (_LOBYTE(v4->_mgoal) != 4) { - v15 = abs(v8); - //v12 = v16; - if (v15 < 3) { - v17 = abs(v7); - //v12 = v18; - if (v17 < 3) - goto LABEL_26; - } - if (_LOBYTE(v4->_mgoal) != 4) { - v4->_mgoalvar1 = 0; - v4->_mgoalvar2 = random(123, 2); - } - } - _LOBYTE(v4->_mgoal) = 4; - v4->_mgoalvar3 = 4; - v19 = abs(v7); - if (abs(v8) <= v19) { - v7 = v36; - v20 = abs(v36); - } else { - v20 = abs(v8); - v7 = v36; - } - v12 = v4->_mgoalvar1; - v4->_mgoalvar1 = v12 + 1; - if (v12 < 2 * v20 || (v21 = DirOK(arglist, md), !v21)) { - if (v38 < 5 * ((unsigned char)v4->_mint + 16)) - M_RoundWalk(arglist, md, &v4->_mgoalvar2); - LABEL_26: - if (_LOBYTE(v4->_mgoal) != 1) - goto LABEL_48; - if (((abs(v8) >= 3 || abs(v7) >= 3) && v38 < 5 * ((unsigned char)v4->_mint + 2) - || v38 < 5 * ((unsigned char)v4->_mint + 1) - || v4->_mgoalvar3 == 4) - && (v22 = LineClear(v4->_mx, v4->_my, x2, y2), v22)) { - v23 = arglist; - } else { - v24 = abs(v8); - //v26 = v25; - if (v24 >= 2 || (v27 = abs(v7), v27 >= 2)) /* v26 = v28, */ - { - v31 = random(124, 100); - v12 = (unsigned char)v4->_mint; - if (v31 < 2 * (5 * v12 + 25) - || ((v32 = v4->_mVar1, v32 == 1) || v32 == 2 || v32 == 3) - && !v4->_mVar2 - && (v12 = 2 * (5 * v12 + 40), v31 < v12)) { - M_CallWalk(arglist, md); - } - goto LABEL_47; - } - v29 = random(124, 100); - v12 = 10 * ((unsigned char)v4->_mint + 4); - if (v29 >= v12) { - LABEL_47: - v4->_mgoalvar3 = 1; - LABEL_48: - if (v4->_mmode == MM_STAND) { - v33 = random(125, 10); - M_StartDelay(arglist, v33 + 5); - } - return; - } - v4->_mdir = md; - v30 = random(124, 2); - v23 = arglist; - if (v30) { - M_StartAttack(arglist); - goto LABEL_47; - } - } - M_StartRSpAttack(v23, missile_type, dam); - goto LABEL_47; - } - } - } - } - _LOBYTE(v4->_mgoal) = 1; - goto LABEL_26; - } + v3 = i; + missile_type = mistype; + arglist = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("MAI_RR2: Invalid monster %d", i); + v4 = &monster[v3]; + v5 = v4->_my - (unsigned char)v4->_menemyy; + if (abs(v4->_mx - (unsigned char)v4->_menemyx) >= 5 || abs(v5) >= 5) { + MAI_SkelSd(v3); + return; + } + if (v4->_mmode == MM_STAND && v4->_msquelch) { + v6 = v4->_my; + y2 = (unsigned char)v4->_menemyy; + v7 = v6 - y2; + x2 = (unsigned char)v4->_menemyx; + v8 = v4->_mx - x2; + v36 = v6 - y2; + md = GetDirection(v4->_mx, v6, v4->_lastx, v4->_lasty); + if (v4->_msquelch < 0xFFu) /* check sign */ + MonstCheckDoors(arglist); + v38 = random(121, 100); + v10 = abs(v8); + //v12 = v11; + if (v10 >= 2 || (v13 = abs(v7), v13 >= 2)) /* v12 = v14, */ + { + if (v4->_msquelch == -1) { + //v12 = y2; + if (dung_map[v4->_mx][v4->_my] == dung_map[x2][y2]) { + if (_LOBYTE(v4->_mgoal) != 4) { + v15 = abs(v8); + //v12 = v16; + if (v15 < 3) { + v17 = abs(v7); + //v12 = v18; + if (v17 < 3) + goto LABEL_26; + } + if (_LOBYTE(v4->_mgoal) != 4) { + v4->_mgoalvar1 = 0; + v4->_mgoalvar2 = random(123, 2); + } + } + _LOBYTE(v4->_mgoal) = 4; + v4->_mgoalvar3 = 4; + v19 = abs(v7); + if (abs(v8) <= v19) { + v7 = v36; + v20 = abs(v36); + } else { + v20 = abs(v8); + v7 = v36; + } + v12 = v4->_mgoalvar1; + v4->_mgoalvar1 = v12 + 1; + if (v12 < 2 * v20 || (v21 = DirOK(arglist, md), !v21)) { + if (v38 < 5 * ((unsigned char)v4->_mint + 16)) + M_RoundWalk(arglist, md, &v4->_mgoalvar2); + LABEL_26: + if (_LOBYTE(v4->_mgoal) != 1) + goto LABEL_48; + if (((abs(v8) >= 3 || abs(v7) >= 3) && v38 < 5 * ((unsigned char)v4->_mint + 2) + || v38 < 5 * ((unsigned char)v4->_mint + 1) + || v4->_mgoalvar3 == 4) + && (v22 = LineClear(v4->_mx, v4->_my, x2, y2), v22)) { + v23 = arglist; + } else { + v24 = abs(v8); + //v26 = v25; + if (v24 >= 2 || (v27 = abs(v7), v27 >= 2)) /* v26 = v28, */ + { + v31 = random(124, 100); + v12 = (unsigned char)v4->_mint; + if (v31 < 2 * (5 * v12 + 25) + || ((v32 = v4->_mVar1, v32 == 1) || v32 == 2 || v32 == 3) + && !v4->_mVar2 + && (v12 = 2 * (5 * v12 + 40), v31 < v12)) { + M_CallWalk(arglist, md); + } + goto LABEL_47; + } + v29 = random(124, 100); + v12 = 10 * ((unsigned char)v4->_mint + 4); + if (v29 >= v12) { + LABEL_47: + v4->_mgoalvar3 = 1; + LABEL_48: + if (v4->_mmode == MM_STAND) { + v33 = random(125, 10); + M_StartDelay(arglist, v33 + 5); + } + return; + } + v4->_mdir = md; + v30 = random(124, 2); + v23 = arglist; + if (v30) { + M_StartAttack(arglist); + goto LABEL_47; + } + } + M_StartRSpAttack(v23, missile_type, dam); + goto LABEL_47; + } + } + } + } + _LOBYTE(v4->_mgoal) = 1; + goto LABEL_26; + } } void __fastcall MAI_Mega(int i) { - MAI_RR2(i, 49, 0); + MAI_RR2(i, 49, 0); } void __fastcall MAI_Golum(int i) { - int v1; // edi - int v2; // esi - int v3; // eax - int v4; // eax - int v5; // edx - int v6; // edi - int v7; // ebx - int v8; // eax - char v9; // cl - //char v10; // eax - signed int v11; // edx - signed int v12; // ecx - int v13; // eax - bool v14; // eax - unsigned char *v15; // esi - bool v16; // eax - int v17; // esi - int v18; // edi - int v19; // [esp+Ch] [ebp-Ch] - unsigned int v20; // [esp+10h] [ebp-8h] - int arglist; // [esp+14h] [ebp-4h] + int v1; // edi + int v2; // esi + int v3; // eax + int v4; // eax + int v5; // edx + int v6; // edi + int v7; // ebx + int v8; // eax + char v9; // cl + //char v10; // eax + signed int v11; // edx + signed int v12; // ecx + int v13; // eax + bool v14; // eax + unsigned char *v15; // esi + bool v16; // eax + int v17; // esi + int v18; // edi + int v19; // [esp+Ch] [ebp-Ch] + unsigned int v20; // [esp+10h] [ebp-8h] + int arglist; // [esp+14h] [ebp-4h] - v1 = i; - arglist = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_Golum: Invalid monster %d", i); - v2 = v1; - if (monster[v1]._mx != 1 || monster[v2]._my) { - v3 = monster[v2]._mmode; - if (v3 != MM_DEATH && v3 != MM_SPSTAND && (v3 < MM_WALK || v3 > MM_WALK3)) { - if (!(monster[v2]._mFlags & 0x10)) - M_Enemy(v1); - v20 = ((unsigned int)~monster[v2]._mFlags >> 10) & 1; - if (monster[v2]._mmode != MM_ATTACK) { - v4 = monster[v2]._menemy; - v5 = monster[v2]._my; - v6 = monster[v2]._mx - monster[v4]._mfutx; - v7 = v5 - monster[v4]._mfuty; - v19 = GetDirection(monster[v2]._mx, v5, monster[v4]._mx, monster[v4]._my); - monster[v2]._mdir = v19; - if (abs(v6) >= 2 || abs(v7) >= 2) { - if (v20) { - v14 = MAI_Path(arglist); - if (v14) - return; - } - } else if (v20) { - v8 = monster[v2]._menemy; - monster[v2]._menemyx = monster[v8]._mx; - v9 = monster[v8]._my; - monster[v2]._menemyy = v9; - if (!monster[v8]._msquelch) { - monster[v8]._msquelch = -1; - monster[monster[v2]._menemy]._lastx = monster[v2]._mx; - v11 = 0; - monster[monster[v2]._menemy]._lasty = monster[v2]._my; - do { - v12 = 0; - do { - /* v13 = *(_DWORD *)&nTransTable[4 + v1 = i; + arglist = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("MAI_Golum: Invalid monster %d", i); + v2 = v1; + if (monster[v1]._mx != 1 || monster[v2]._my) { + v3 = monster[v2]._mmode; + if (v3 != MM_DEATH && v3 != MM_SPSTAND && (v3 < MM_WALK || v3 > MM_WALK3)) { + if (!(monster[v2]._mFlags & 0x10)) + M_Enemy(v1); + v20 = ((unsigned int)~monster[v2]._mFlags >> 10) & 1; + if (monster[v2]._mmode != MM_ATTACK) { + v4 = monster[v2]._menemy; + v5 = monster[v2]._my; + v6 = monster[v2]._mx - monster[v4]._mfutx; + v7 = v5 - monster[v4]._mfuty; + v19 = GetDirection(monster[v2]._mx, v5, monster[v4]._mx, monster[v4]._my); + monster[v2]._mdir = v19; + if (abs(v6) >= 2 || abs(v7) >= 2) { + if (v20) { + v14 = MAI_Path(arglist); + if (v14) + return; + } + } else if (v20) { + v8 = monster[v2]._menemy; + monster[v2]._menemyx = monster[v8]._mx; + v9 = monster[v8]._my; + monster[v2]._menemyy = v9; + if (!monster[v8]._msquelch) { + monster[v8]._msquelch = -1; + monster[monster[v2]._menemy]._lastx = monster[v2]._mx; + v11 = 0; + monster[monster[v2]._menemy]._lasty = monster[v2]._my; + do { + v12 = 0; + do { + /* v13 = *(_DWORD *)&nTransTable[4 * (monster[v2]._my + v11 + 112 * (v12 + monster[v2]._mx)) + 1148]; check */ - v13 = dMonster[monster[v2]._mx + v12 - 2][monster[v2]._my + v11 - 2]; - if (v13 > 0) - monster[v13]._msquelch = -1; - ++v12; - } while (v12 < 5); - ++v11; - } while (v11 < 5); - } - M_StartAttack(arglist); - return; - } - v15 = &monster[v2]._pathcount; - if (++*(_BYTE *)v15 > 8u) - *(_BYTE *)v15 = 5; - v16 = M_CallWalk(arglist, plr[arglist]._pdir); - if (!v16) { - v17 = ((_BYTE)v19 - 1) & 7; - v18 = 0; - while (!v16) { - v17 = ((_BYTE)v17 + 1) & 7; - v16 = DirOK(arglist, v17); - if (++v18 >= 8) { - if (!v16) - return; - break; - } - } - M_WalkDir(arglist, v17); - } - } - } - } + v13 = dMonster[monster[v2]._mx + v12 - 2][monster[v2]._my + v11 - 2]; + if (v13 > 0) + monster[v13]._msquelch = -1; + ++v12; + } while (v12 < 5); + ++v11; + } while (v11 < 5); + } + M_StartAttack(arglist); + return; + } + v15 = &monster[v2]._pathcount; + if (++*(_BYTE *)v15 > 8u) + *(_BYTE *)v15 = 5; + v16 = M_CallWalk(arglist, plr[arglist]._pdir); + if (!v16) { + v17 = ((_BYTE)v19 - 1) & 7; + v18 = 0; + while (!v16) { + v17 = ((_BYTE)v17 + 1) & 7; + v16 = DirOK(arglist, v17); + if (++v18 >= 8) { + if (!v16) + return; + break; + } + } + M_WalkDir(arglist, v17); + } + } + } + } } void __fastcall MAI_SkelKing(int i) { - int v1; // esi - MonsterStruct *v2; // esi - int v3; // edx - int v4; // ebx - int v5; // edi - int v7; // eax - //int v8; // ST04_4 - int v10; // eax - //int v11; // ST04_4 - int v13; // ebx - int v14; // eax - int v15; // ecx - bool v16; // eax - //int v17; // eax - int v19; // eax - bool v20; // eax - int v21; // edi - int v22; // ebx - int v23; // eax - //int v24; // ST04_4 - int v26; // eax - //int v27; // ST04_4 - int v28; // eax - int v29; // ecx - int v30; // edx - int v31; // eax - char *v32; // [esp+4h] [ebp-1Ch] - int x2; // [esp+8h] [ebp-18h] - int v34; // [esp+Ch] [ebp-14h] - int v35; // [esp+10h] [ebp-10h] - int y2; // [esp+14h] [ebp-Ch] - int md; // [esp+18h] [ebp-8h] - int arglist; // [esp+1Ch] [ebp-4h] + int v1; // esi + MonsterStruct *v2; // esi + int v3; // edx + int v4; // ebx + int v5; // edi + int v7; // eax + //int v8; // ST04_4 + int v10; // eax + //int v11; // ST04_4 + int v13; // ebx + int v14; // eax + int v15; // ecx + bool v16; // eax + //int v17; // eax + int v19; // eax + bool v20; // eax + int v21; // edi + int v22; // ebx + int v23; // eax + //int v24; // ST04_4 + int v26; // eax + //int v27; // ST04_4 + int v28; // eax + int v29; // ecx + int v30; // edx + int v31; // eax + char *v32; // [esp+4h] [ebp-1Ch] + int x2; // [esp+8h] [ebp-18h] + int v34; // [esp+Ch] [ebp-14h] + int v35; // [esp+10h] [ebp-10h] + int y2; // [esp+14h] [ebp-Ch] + int md; // [esp+18h] [ebp-8h] + int arglist; // [esp+1Ch] [ebp-4h] - v1 = i; - arglist = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_SkelKing: Invalid monster %d", i); - v2 = &monster[v1]; - if (v2->_mmode == MM_STAND && v2->_msquelch) { - v3 = v2->_my; - y2 = (unsigned char)v2->_menemyy; - v4 = v3 - y2; - x2 = (unsigned char)v2->_menemyx; - v5 = v2->_mx - x2; - v34 = v3 - y2; - md = GetDirection(v2->_mx, v3, v2->_lastx, v2->_lasty); - if (v2->_msquelch < 0xFFu) /* check sign */ - MonstCheckDoors(arglist); - v35 = random(126, 100); - if ((abs(v5) >= 2 || abs(v4) >= 2) && v2->_msquelch == -1) { - v32 = &dung_map[x2][y2]; - if (dung_map[v2->_mx][v2->_my] == *v32) { - if (_LOBYTE(v2->_mgoal) != 4) { - v7 = abs(v5); - //v9 = v8; - if (v7 < 3) { - v10 = abs(v4); - //v9 = v11; - if (v10 < 3) - goto LABEL_26; - } - if (random(127, 4)) - goto LABEL_26; - if (_LOBYTE(v2->_mgoal) != 4) { - v2->_mgoalvar1 = 0; - v2->_mgoalvar2 = random(128, 2); - } - } - _LOBYTE(v2->_mgoal) = 4; - v13 = abs(v4); - if (abs(v5) <= v13) { - v4 = v34; - v14 = abs(v34); - } else { - v14 = abs(v5); - v4 = v34; - } - v15 = v2->_mgoalvar1; - v2->_mgoalvar1 = v15 + 1; - if (v15 < 2 * v14 || (v16 = DirOK(arglist, md), !v16)) { - if (dung_map[v2->_mx][v2->_my] == *v32) { - //_LOBYTE(v17) = M_RoundWalk(arglist, md, &v2->_mgoalvar2); - if (!M_RoundWalk(arglist, md, &v2->_mgoalvar2)) { - v19 = random(125, 10); - M_StartDelay(arglist, v19 + 10); - } - goto LABEL_26; - } - } - } - } - _LOBYTE(v2->_mgoal) = 1; - LABEL_26: - if (_LOBYTE(v2->_mgoal) == 1) { - if (gbMaxPlayers == 1 - && ((abs(v5) >= 3 || abs(v4) >= 3) && v35 < 4 * (unsigned char)v2->_mint + 35 || v35 < 6) - && (v20 = LineClear(v2->_mx, v2->_my, x2, y2), v20)) { - v21 = v2->_mx + offset_x[md]; - v22 = v2->_my + offset_y[md]; - if (PosOkMonst(arglist, v21, v22) && nummonsters < MAXMONSTERS) { - M_SpawnSkel(v21, v22, md); - M_StartSpStand(arglist, md); - } - } else { - v23 = abs(v5); - //v25 = v24; - if (v23 >= 2 || (v26 = abs(v4), v26 >= 2)) /* v25 = v27, */ - { - v28 = random(129, 100); - v29 = (unsigned char)v2->_mint; - if (v28 >= v29 + 25 - && ((v30 = v2->_mVar1, v30 != 1) && v30 != 2 && v30 != 3 || v2->_mVar2 || (v29 += 75, v28 >= v29))) { - v31 = random(130, 10); - M_StartDelay(arglist, v31 + 10); - } else { - M_CallWalk(arglist, md); - } - } else if (v35 < (unsigned char)v2->_mint + 20) { - v2->_mdir = md; - M_StartAttack(arglist); - } - } - } - if (v2->_mmode == MM_STAND) - v2->_mAnimData = v2->MType->Anims[MA_STAND].Data[md]; - } + v1 = i; + arglist = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("MAI_SkelKing: Invalid monster %d", i); + v2 = &monster[v1]; + if (v2->_mmode == MM_STAND && v2->_msquelch) { + v3 = v2->_my; + y2 = (unsigned char)v2->_menemyy; + v4 = v3 - y2; + x2 = (unsigned char)v2->_menemyx; + v5 = v2->_mx - x2; + v34 = v3 - y2; + md = GetDirection(v2->_mx, v3, v2->_lastx, v2->_lasty); + if (v2->_msquelch < 0xFFu) /* check sign */ + MonstCheckDoors(arglist); + v35 = random(126, 100); + if ((abs(v5) >= 2 || abs(v4) >= 2) && v2->_msquelch == -1) { + v32 = &dung_map[x2][y2]; + if (dung_map[v2->_mx][v2->_my] == *v32) { + if (_LOBYTE(v2->_mgoal) != 4) { + v7 = abs(v5); + //v9 = v8; + if (v7 < 3) { + v10 = abs(v4); + //v9 = v11; + if (v10 < 3) + goto LABEL_26; + } + if (random(127, 4)) + goto LABEL_26; + if (_LOBYTE(v2->_mgoal) != 4) { + v2->_mgoalvar1 = 0; + v2->_mgoalvar2 = random(128, 2); + } + } + _LOBYTE(v2->_mgoal) = 4; + v13 = abs(v4); + if (abs(v5) <= v13) { + v4 = v34; + v14 = abs(v34); + } else { + v14 = abs(v5); + v4 = v34; + } + v15 = v2->_mgoalvar1; + v2->_mgoalvar1 = v15 + 1; + if (v15 < 2 * v14 || (v16 = DirOK(arglist, md), !v16)) { + if (dung_map[v2->_mx][v2->_my] == *v32) { + //_LOBYTE(v17) = M_RoundWalk(arglist, md, &v2->_mgoalvar2); + if (!M_RoundWalk(arglist, md, &v2->_mgoalvar2)) { + v19 = random(125, 10); + M_StartDelay(arglist, v19 + 10); + } + goto LABEL_26; + } + } + } + } + _LOBYTE(v2->_mgoal) = 1; + LABEL_26: + if (_LOBYTE(v2->_mgoal) == 1) { + if (gbMaxPlayers == 1 + && ((abs(v5) >= 3 || abs(v4) >= 3) && v35 < 4 * (unsigned char)v2->_mint + 35 || v35 < 6) + && (v20 = LineClear(v2->_mx, v2->_my, x2, y2), v20)) { + v21 = v2->_mx + offset_x[md]; + v22 = v2->_my + offset_y[md]; + if (PosOkMonst(arglist, v21, v22) && nummonsters < MAXMONSTERS) { + M_SpawnSkel(v21, v22, md); + M_StartSpStand(arglist, md); + } + } else { + v23 = abs(v5); + //v25 = v24; + if (v23 >= 2 || (v26 = abs(v4), v26 >= 2)) /* v25 = v27, */ + { + v28 = random(129, 100); + v29 = (unsigned char)v2->_mint; + if (v28 >= v29 + 25 + && ((v30 = v2->_mVar1, v30 != 1) && v30 != 2 && v30 != 3 || v2->_mVar2 || (v29 += 75, v28 >= v29))) { + v31 = random(130, 10); + M_StartDelay(arglist, v31 + 10); + } else { + M_CallWalk(arglist, md); + } + } else if (v35 < (unsigned char)v2->_mint + 20) { + v2->_mdir = md; + M_StartAttack(arglist); + } + } + } + if (v2->_mmode == MM_STAND) + v2->_mAnimData = v2->MType->Anims[MA_STAND].Data[md]; + } } // 679660: using guessed type char gbMaxPlayers; void __fastcall MAI_Rhino(int i) { - int esi1; // esi - MonsterStruct *esi3; // esi - int v3; // edx - int v4; // ebx - int v5; // edi - int v7; // eax - //int v8; // ST1C_4 - int v10; // eax - //int v11; // ST1C_4 - int v13; // ebx - int v14; // eax - int v15; // ecx - //int v16; // eax - int v18; // eax - bool v19; // eax - int v20; // ecx - int v21; // eax - //int v22; // ST1C_4 - int v24; // eax - //int v25; // ST1C_4 - int v26; // eax - int v27; // ecx - int v28; // edx - int v29; // eax - int v30; // [esp+4h] [ebp-18h] - int v31; // [esp+8h] [ebp-14h] - int v1; // [esp+Ch] [ebp-10h] - int midir; // [esp+10h] [ebp-Ch] - int v2; // [esp+14h] [ebp-8h] - int arglist; // [esp+18h] [ebp-4h] + int esi1; // esi + MonsterStruct *esi3; // esi + int v3; // edx + int v4; // ebx + int v5; // edi + int v7; // eax + //int v8; // ST1C_4 + int v10; // eax + //int v11; // ST1C_4 + int v13; // ebx + int v14; // eax + int v15; // ecx + //int v16; // eax + int v18; // eax + bool v19; // eax + int v20; // ecx + int v21; // eax + //int v22; // ST1C_4 + int v24; // eax + //int v25; // ST1C_4 + int v26; // eax + int v27; // ecx + int v28; // edx + int v29; // eax + int v30; // [esp+4h] [ebp-18h] + int v31; // [esp+8h] [ebp-14h] + int v1; // [esp+Ch] [ebp-10h] + int midir; // [esp+10h] [ebp-Ch] + int v2; // [esp+14h] [ebp-8h] + int arglist; // [esp+18h] [ebp-4h] - esi1 = i; - arglist = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_Rhino: Invalid monster %d", i); - esi3 = &monster[esi1]; - if (esi3->_mmode == MM_STAND && esi3->_msquelch) { - v3 = esi3->_my; - v2 = (unsigned char)esi3->_menemyy; - v4 = v3 - v2; - v1 = (unsigned char)esi3->_menemyx; - v5 = esi3->_mx - v1; - v31 = v3 - v2; - midir = GetDirection(esi3->_mx, v3, esi3->_lastx, esi3->_lasty); - if (esi3->_msquelch < 0xFFu) /* check sign */ - MonstCheckDoors(arglist); - v30 = random(131, 100); - if (abs(v5) >= 2 || abs(v4) >= 2) { - if (_LOBYTE(esi3->_mgoal) != 4) { - v7 = abs(v5); - //v9 = v8; - if (v7 < 5) { - v10 = abs(v4); - //v9 = v11; - if (v10 < 5) - goto LABEL_23; - } - if (!random(132, 4)) - goto LABEL_23; - if (_LOBYTE(esi3->_mgoal) != 4) { - esi3->_mgoalvar1 = 0; - esi3->_mgoalvar2 = random(133, 2); - } - } - _LOBYTE(esi3->_mgoal) = 4; - v13 = abs(v4); - if (abs(v5) <= v13) { - v4 = v31; - v14 = abs(v31); - } else { - v14 = abs(v5); - v4 = v31; - } - v15 = esi3->_mgoalvar1; - esi3->_mgoalvar1 = v15 + 1; - if (v15 < 2 * v14 && dung_map[esi3->_mx][esi3->_my] == dung_map[v1][v2]) { - //_LOBYTE(v16) = M_RoundWalk(arglist, midir, &esi3->_mgoalvar2); - if (!M_RoundWalk(arglist, midir, &esi3->_mgoalvar2)) { - v18 = random(125, 10); - M_StartDelay(arglist, v18 + 10); - } - goto LABEL_23; - } - } - _LOBYTE(esi3->_mgoal) = 1; - LABEL_23: - if (_LOBYTE(esi3->_mgoal) == 1) { - if ((abs(v5) >= 5 || abs(v4) >= 5) - && v30 < 2 * (unsigned char)esi3->_mint + 43 - && (v19 = LineClearF1( - PosOkMonst, - arglist, - esi3->_mx, - esi3->_my, - v1, - v2), - v19)) { - if (AddMissile(esi3->_mx, esi3->_my, v1, v2, midir, 20, esi3->_menemy, arglist, 0, 0) != -1) { - if (esi3->MData->snd_special) - PlayEffect(arglist, 3); - v20 = esi3->_my + 112 * esi3->_mx; - esi3->_mmode = MM_CHARGE; - dMonster[0][v20] = -1 - arglist; - } - } else { - v21 = abs(v5); - //v23 = v22; - if (v21 >= 2 || (v24 = abs(v4), v24 >= 2)) /* v23 = v25, */ - { - v26 = random(134, 100); - v27 = 2 * (unsigned char)esi3->_mint; - if (v26 >= v27 + 33 - && ((v28 = esi3->_mVar1, v28 != 1) && v28 != 2 && v28 != 3 - || esi3->_mVar2 - || (v27 += 83, v26 >= v27))) { - v29 = random(135, 10); - M_StartDelay(arglist, v29 + 10); - } else { - M_CallWalk(arglist, midir); - } - } else if (v30 < 2 * (unsigned char)esi3->_mint + 28) { - esi3->_mdir = midir; - M_StartAttack(arglist); - } - } - } - if (esi3->_mmode == MM_STAND) - esi3->_mAnimData = esi3->MType->Anims[MA_STAND].Data[esi3->_mdir]; - } + esi1 = i; + arglist = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("MAI_Rhino: Invalid monster %d", i); + esi3 = &monster[esi1]; + if (esi3->_mmode == MM_STAND && esi3->_msquelch) { + v3 = esi3->_my; + v2 = (unsigned char)esi3->_menemyy; + v4 = v3 - v2; + v1 = (unsigned char)esi3->_menemyx; + v5 = esi3->_mx - v1; + v31 = v3 - v2; + midir = GetDirection(esi3->_mx, v3, esi3->_lastx, esi3->_lasty); + if (esi3->_msquelch < 0xFFu) /* check sign */ + MonstCheckDoors(arglist); + v30 = random(131, 100); + if (abs(v5) >= 2 || abs(v4) >= 2) { + if (_LOBYTE(esi3->_mgoal) != 4) { + v7 = abs(v5); + //v9 = v8; + if (v7 < 5) { + v10 = abs(v4); + //v9 = v11; + if (v10 < 5) + goto LABEL_23; + } + if (!random(132, 4)) + goto LABEL_23; + if (_LOBYTE(esi3->_mgoal) != 4) { + esi3->_mgoalvar1 = 0; + esi3->_mgoalvar2 = random(133, 2); + } + } + _LOBYTE(esi3->_mgoal) = 4; + v13 = abs(v4); + if (abs(v5) <= v13) { + v4 = v31; + v14 = abs(v31); + } else { + v14 = abs(v5); + v4 = v31; + } + v15 = esi3->_mgoalvar1; + esi3->_mgoalvar1 = v15 + 1; + if (v15 < 2 * v14 && dung_map[esi3->_mx][esi3->_my] == dung_map[v1][v2]) { + //_LOBYTE(v16) = M_RoundWalk(arglist, midir, &esi3->_mgoalvar2); + if (!M_RoundWalk(arglist, midir, &esi3->_mgoalvar2)) { + v18 = random(125, 10); + M_StartDelay(arglist, v18 + 10); + } + goto LABEL_23; + } + } + _LOBYTE(esi3->_mgoal) = 1; + LABEL_23: + if (_LOBYTE(esi3->_mgoal) == 1) { + if ((abs(v5) >= 5 || abs(v4) >= 5) + && v30 < 2 * (unsigned char)esi3->_mint + 43 + && (v19 = LineClearF1( + PosOkMonst, + arglist, + esi3->_mx, + esi3->_my, + v1, + v2), + v19)) { + if (AddMissile(esi3->_mx, esi3->_my, v1, v2, midir, 20, esi3->_menemy, arglist, 0, 0) != -1) { + if (esi3->MData->snd_special) + PlayEffect(arglist, 3); + v20 = esi3->_my + 112 * esi3->_mx; + esi3->_mmode = MM_CHARGE; + dMonster[0][v20] = -1 - arglist; + } + } else { + v21 = abs(v5); + //v23 = v22; + if (v21 >= 2 || (v24 = abs(v4), v24 >= 2)) /* v23 = v25, */ + { + v26 = random(134, 100); + v27 = 2 * (unsigned char)esi3->_mint; + if (v26 >= v27 + 33 + && ((v28 = esi3->_mVar1, v28 != 1) && v28 != 2 && v28 != 3 + || esi3->_mVar2 + || (v27 += 83, v26 >= v27))) { + v29 = random(135, 10); + M_StartDelay(arglist, v29 + 10); + } else { + M_CallWalk(arglist, midir); + } + } else if (v30 < 2 * (unsigned char)esi3->_mint + 28) { + esi3->_mdir = midir; + M_StartAttack(arglist); + } + } + } + if (esi3->_mmode == MM_STAND) + esi3->_mAnimData = esi3->MType->Anims[MA_STAND].Data[esi3->_mdir]; + } } void __fastcall MAI_Counselor(int i) { - int v1; // ebx - int v2; // esi - int v3; // ecx - int v4; // edi - int v5; // edx - int v6; // ebp - char v9; // al - int v10; // ecx - bool v11; // zf - bool v12; // sf - unsigned char v13; // of - int v14; // edx - int v15; // ecx - int v16; // ebx - int v17; // eax - int v18; // ebx - int v19; // edx - int v20; // ecx - //int v21; // eax - int v22; // eax - //int v23; // ST1C_4 - int v25; // eax - //int v26; // ST1C_4 - int v27; // edx - int v28; // eax - int v29; // eax - int v30; // ecx - //int v31; // eax - int v32; // eax - int v33; // eax - int v34; // eax - int md; // [esp+8h] [ebp-14h] - int arglist; // [esp+Ch] [ebp-10h] - int y2; // [esp+10h] [ebp-Ch] - int x2; // [esp+14h] [ebp-8h] - int v39; // [esp+18h] [ebp-4h] + int v1; // ebx + int v2; // esi + int v3; // ecx + int v4; // edi + int v5; // edx + int v6; // ebp + char v9; // al + int v10; // ecx + bool v11; // zf + bool v12; // sf + unsigned char v13; // of + int v14; // edx + int v15; // ecx + int v16; // ebx + int v17; // eax + int v18; // ebx + int v19; // edx + int v20; // ecx + //int v21; // eax + int v22; // eax + //int v23; // ST1C_4 + int v25; // eax + //int v26; // ST1C_4 + int v27; // edx + int v28; // eax + int v29; // eax + int v30; // ecx + //int v31; // eax + int v32; // eax + int v33; // eax + int v34; // eax + int md; // [esp+8h] [ebp-14h] + int arglist; // [esp+Ch] [ebp-10h] + int y2; // [esp+10h] [ebp-Ch] + int x2; // [esp+14h] [ebp-8h] + int v39; // [esp+18h] [ebp-4h] - v1 = i; - arglist = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_Counselor: Invalid monster %d", i); - v2 = v1; - if (monster[v1]._mmode == MM_STAND && monster[v2]._msquelch) { - v3 = monster[v2]._mx; - x2 = (unsigned char)monster[v2]._menemyx; - v4 = v3 - x2; - v5 = monster[v2]._my; - y2 = (unsigned char)monster[v2]._menemyy; - v6 = v5 - y2; - md = GetDirection(v3, v5, monster[v2]._lastx, monster[v2]._lasty); - if (monster[v2]._msquelch < 0xFFu) /* check sign */ - MonstCheckDoors(v1); - v39 = random(121, 100); - v9 = monster[v2]._mgoal; - if (v9 == 2) { - v10 = monster[v2]._mgoalvar1; - v13 = __OFSUB__(v10, 3); - v11 = v10 == 3; - v12 = v10 - 3 < 0; - v14 = v10 + 1; - v15 = v1; - monster[v2]._mgoalvar1 = v14; - if ((unsigned char)(v12 ^ v13) | v11) { - M_CallWalk(v1, opposite[md]); - goto LABEL_39; - } - goto LABEL_21; - } - if (v9 == 4) { - v16 = abs(v6); - if (abs(v4) <= v16) - v17 = abs(v6); - else - v17 = abs(v4); - v18 = v17; - if (abs(v4) < 2 && abs(v6) < 2 - || monster[v2]._msquelch != -1 - || dung_map[monster[v2]._mx][monster[v2]._my] != dung_map[x2][y2]) { - v1 = arglist; - LABEL_20: - v15 = v1; - LABEL_21: - _LOBYTE(monster[v2]._mgoal) = 1; - M_StartFadein(v15, md, TRUE); - goto LABEL_39; - } - v19 = 2 * v18; - v1 = arglist; - v20 = monster[v2]._mgoalvar1; - monster[v2]._mgoalvar1 = v20 + 1; - if (v20 >= v19) { - //_LOBYTE(v21) = DirOK(arglist, md); - if (DirOK(arglist, md)) - goto LABEL_20; - } - M_RoundWalk(arglist, md, &monster[v2]._mgoalvar2); - LABEL_39: - if (monster[v2]._mmode == MM_STAND) { - v34 = random(125, 10); - M_StartDelay(v1, v34 + 5); - } - return; - } - if (v9 != 1) - goto LABEL_39; - v22 = abs(v4); - //v24 = v23; - if (v22 >= 2 || (v25 = abs(v6), v25 >= 2)) /* v24 = v26, */ - { - if (v39 < 5 * ((unsigned char)monster[v2]._mint + 10)) { - //_LOBYTE(v31) = LineClear(monster[v2]._mx, monster[v2]._my, x2, y2); - if (LineClear(monster[v2]._mx, monster[v2]._my, x2, y2)) { - v32 = random( - 77, - (unsigned char)monster[v2].mMaxDamage - (unsigned char)monster[v2].mMinDamage + 1); - M_StartRAttack( - v1, - (unsigned char)counsmiss[(unsigned char)monster[v2]._mint], /* counsmiss is local */ - (unsigned char)monster[v2].mMinDamage + v32); - goto LABEL_39; - } - } - if (random(124, 100) < 30) { - v27 = md; - _LOBYTE(monster[v2]._mgoal) = 4; - goto LABEL_29; - } - } else { - v27 = md; - v28 = monster[v2]._mmaxhp >> 1; - v13 = __OFSUB__(monster[v2]._mhitpoints, v28); - v12 = monster[v2]._mhitpoints - v28 < 0; - monster[v2]._mdir = md; - if (v12 ^ v13) { - _LOBYTE(monster[v2]._mgoal) = 2; - LABEL_29: - monster[v2]._mgoalvar1 = 0; - M_StartFadeout(v1, v27, FALSE); - goto LABEL_39; - } - if (monster[v2]._mVar1 == 13 - || (v29 = random(105, 100), - v30 = 2 * (unsigned char)monster[v2]._mint + 20, - v29 < v30)) { - M_StartRAttack(v1, -1, 0); - AddMissile(monster[v2]._mx, monster[v2]._my, 0, 0, monster[v2]._mdir, 11, 1, v1, 4, 0); - AddMissile(monster[v2]._mx, monster[v2]._my, 0, 0, monster[v2]._mdir, 12, 1, v1, 4, 0); - goto LABEL_39; - } - } - v33 = random(105, 10); - M_StartDelay(v1, v33 + 2 * (5 - (unsigned char)monster[v2]._mint)); - goto LABEL_39; - } + v1 = i; + arglist = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("MAI_Counselor: Invalid monster %d", i); + v2 = v1; + if (monster[v1]._mmode == MM_STAND && monster[v2]._msquelch) { + v3 = monster[v2]._mx; + x2 = (unsigned char)monster[v2]._menemyx; + v4 = v3 - x2; + v5 = monster[v2]._my; + y2 = (unsigned char)monster[v2]._menemyy; + v6 = v5 - y2; + md = GetDirection(v3, v5, monster[v2]._lastx, monster[v2]._lasty); + if (monster[v2]._msquelch < 0xFFu) /* check sign */ + MonstCheckDoors(v1); + v39 = random(121, 100); + v9 = monster[v2]._mgoal; + if (v9 == 2) { + v10 = monster[v2]._mgoalvar1; + v13 = __OFSUB__(v10, 3); + v11 = v10 == 3; + v12 = v10 - 3 < 0; + v14 = v10 + 1; + v15 = v1; + monster[v2]._mgoalvar1 = v14; + if ((unsigned char)(v12 ^ v13) | v11) { + M_CallWalk(v1, opposite[md]); + goto LABEL_39; + } + goto LABEL_21; + } + if (v9 == 4) { + v16 = abs(v6); + if (abs(v4) <= v16) + v17 = abs(v6); + else + v17 = abs(v4); + v18 = v17; + if (abs(v4) < 2 && abs(v6) < 2 + || monster[v2]._msquelch != -1 + || dung_map[monster[v2]._mx][monster[v2]._my] != dung_map[x2][y2]) { + v1 = arglist; + LABEL_20: + v15 = v1; + LABEL_21: + _LOBYTE(monster[v2]._mgoal) = 1; + M_StartFadein(v15, md, TRUE); + goto LABEL_39; + } + v19 = 2 * v18; + v1 = arglist; + v20 = monster[v2]._mgoalvar1; + monster[v2]._mgoalvar1 = v20 + 1; + if (v20 >= v19) { + //_LOBYTE(v21) = DirOK(arglist, md); + if (DirOK(arglist, md)) + goto LABEL_20; + } + M_RoundWalk(arglist, md, &monster[v2]._mgoalvar2); + LABEL_39: + if (monster[v2]._mmode == MM_STAND) { + v34 = random(125, 10); + M_StartDelay(v1, v34 + 5); + } + return; + } + if (v9 != 1) + goto LABEL_39; + v22 = abs(v4); + //v24 = v23; + if (v22 >= 2 || (v25 = abs(v6), v25 >= 2)) /* v24 = v26, */ + { + if (v39 < 5 * ((unsigned char)monster[v2]._mint + 10)) { + //_LOBYTE(v31) = LineClear(monster[v2]._mx, monster[v2]._my, x2, y2); + if (LineClear(monster[v2]._mx, monster[v2]._my, x2, y2)) { + v32 = random( + 77, + (unsigned char)monster[v2].mMaxDamage - (unsigned char)monster[v2].mMinDamage + 1); + M_StartRAttack( + v1, + (unsigned char)counsmiss[(unsigned char)monster[v2]._mint], /* counsmiss is local */ + (unsigned char)monster[v2].mMinDamage + v32); + goto LABEL_39; + } + } + if (random(124, 100) < 30) { + v27 = md; + _LOBYTE(monster[v2]._mgoal) = 4; + goto LABEL_29; + } + } else { + v27 = md; + v28 = monster[v2]._mmaxhp >> 1; + v13 = __OFSUB__(monster[v2]._mhitpoints, v28); + v12 = monster[v2]._mhitpoints - v28 < 0; + monster[v2]._mdir = md; + if (v12 ^ v13) { + _LOBYTE(monster[v2]._mgoal) = 2; + LABEL_29: + monster[v2]._mgoalvar1 = 0; + M_StartFadeout(v1, v27, FALSE); + goto LABEL_39; + } + if (monster[v2]._mVar1 == 13 + || (v29 = random(105, 100), + v30 = 2 * (unsigned char)monster[v2]._mint + 20, + v29 < v30)) { + M_StartRAttack(v1, -1, 0); + AddMissile(monster[v2]._mx, monster[v2]._my, 0, 0, monster[v2]._mdir, 11, 1, v1, 4, 0); + AddMissile(monster[v2]._mx, monster[v2]._my, 0, 0, monster[v2]._mdir, 12, 1, v1, 4, 0); + goto LABEL_39; + } + } + v33 = random(105, 10); + M_StartDelay(v1, v33 + 2 * (5 - (unsigned char)monster[v2]._mint)); + goto LABEL_39; + } } void __fastcall MAI_Garbud(int i) { - int v1; // esi - int v2; // esi - int v3; // ebx - int v4; // edi - int v5; // eax - //int v6; // eax - char v7; // al - int v8; // [esp+4h] [ebp-8h] - int arglist; // [esp+8h] [ebp-4h] + int v1; // esi + int v2; // esi + int v3; // ebx + int v4; // edi + int v5; // eax + //int v6; // eax + char v7; // al + int v8; // [esp+4h] [ebp-8h] + int arglist; // [esp+8h] [ebp-4h] - v1 = i; - arglist = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_Garbud: Invalid monster %d", i); - v2 = v1; - if (monster[v2]._mmode == MM_STAND) { - v3 = monster[v2]._my; - v4 = monster[v2]._mx; - v8 = M_GetDir(arglist); - v5 = monster[v2].mtalkmsg; - if (v5 < (signed int)QUEST_GARBUD4 - && v5 > (signed int)QUEST_DOOM10 - && !(dFlags[v4][v3] & DFLAG_VISIBLE) - && _LOBYTE(monster[v2]._mgoal) == 7) { - _LOBYTE(monster[v2]._mgoal) = 6; - monster[v2].mtalkmsg = v5 + 1; - } - if (dFlags[v4][v3] & DFLAG_VISIBLE) { - if (monster[v2].mtalkmsg == QUEST_GARBUD4) { - //_LOBYTE(v6) = effect_is_playing(USFX_GARBUD4); - if (!effect_is_playing(USFX_GARBUD4) && _LOBYTE(monster[v2]._mgoal) == 7) { - monster[v2]._msquelch = -1; - monster[v2].mtalkmsg = 0; - _LOBYTE(monster[v2]._mgoal) = 1; - } - } - } - v7 = monster[v2]._mgoal; - if (v7 == 1 || v7 == 4) - MAI_Round(arglist, 1u); - monster[v2]._mdir = v8; - if (monster[v2]._mmode == MM_STAND) - monster[v2]._mAnimData = monster[v2].MType->Anims[MA_STAND].Data[v8]; - } + v1 = i; + arglist = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("MAI_Garbud: Invalid monster %d", i); + v2 = v1; + if (monster[v2]._mmode == MM_STAND) { + v3 = monster[v2]._my; + v4 = monster[v2]._mx; + v8 = M_GetDir(arglist); + v5 = monster[v2].mtalkmsg; + if (v5 < (signed int)QUEST_GARBUD4 + && v5 > (signed int)QUEST_DOOM10 + && !(dFlags[v4][v3] & DFLAG_VISIBLE) + && _LOBYTE(monster[v2]._mgoal) == 7) { + _LOBYTE(monster[v2]._mgoal) = 6; + monster[v2].mtalkmsg = v5 + 1; + } + if (dFlags[v4][v3] & DFLAG_VISIBLE) { + if (monster[v2].mtalkmsg == QUEST_GARBUD4) { + //_LOBYTE(v6) = effect_is_playing(USFX_GARBUD4); + if (!effect_is_playing(USFX_GARBUD4) && _LOBYTE(monster[v2]._mgoal) == 7) { + monster[v2]._msquelch = -1; + monster[v2].mtalkmsg = 0; + _LOBYTE(monster[v2]._mgoal) = 1; + } + } + } + v7 = monster[v2]._mgoal; + if (v7 == 1 || v7 == 4) + MAI_Round(arglist, 1u); + monster[v2]._mdir = v8; + if (monster[v2]._mmode == MM_STAND) + monster[v2]._mAnimData = monster[v2].MType->Anims[MA_STAND].Data[v8]; + } } void __fastcall MAI_Zhar(int i) { - int v1; // ebp - int v2; // esi - int v3; // ebx - int v4; // edi - int v5; // edi - int v6; // ebx - int v7; // ebp - //int v8; // eax - char v9; // al - int arglist; // [esp+8h] [ebp-8h] - int v11; // [esp+Ch] [ebp-4h] + int v1; // ebp + int v2; // esi + int v3; // ebx + int v4; // edi + int v5; // edi + int v6; // ebx + int v7; // ebp + //int v8; // eax + char v9; // al + int arglist; // [esp+8h] [ebp-8h] + int v11; // [esp+Ch] [ebp-4h] - v1 = i; - arglist = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_Zhar: Invalid monster %d", i); - v2 = v1; - if (monster[v1]._mmode == MM_STAND) { - v3 = monster[v2]._my; - v4 = monster[v2]._mx; - v11 = M_GetDir(v1); - if (monster[v2].mtalkmsg == QUEST_ZHAR1 && !(dFlags[v4][v3] & DFLAG_VISIBLE) && _LOBYTE(monster[v2]._mgoal) == 7) { - monster[v2].mtalkmsg = QUEST_ZHAR2; - _LOBYTE(monster[v2]._mgoal) = 6; - } - if (dFlags[v4][v3] & DFLAG_VISIBLE) { - v5 = monster[v2]._mx - (unsigned char)monster[v2]._menemyx; - v6 = monster[v2]._my - (unsigned char)monster[v2]._menemyy; - v7 = abs(v6); - if (abs(v5) <= v7) - abs(v6); - else - abs(v5); - if (monster[v2].mtalkmsg == QUEST_ZHAR2) { - //_LOBYTE(v8) = effect_is_playing(USFX_ZHAR2); - if (!effect_is_playing(USFX_ZHAR2) && _LOBYTE(monster[v2]._mgoal) == 7) { - monster[v2]._msquelch = -1; - monster[v2].mtalkmsg = 0; - _LOBYTE(monster[v2]._mgoal) = 1; - } - } - } - v9 = monster[v2]._mgoal; - if (v9 == 1 || v9 == 2 || v9 == 4) - MAI_Counselor(arglist); - monster[v2]._mdir = v11; - if (monster[v2]._mmode == MM_STAND) - monster[v2]._mAnimData = monster[v2].MType->Anims[MA_STAND].Data[v11]; - } + v1 = i; + arglist = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("MAI_Zhar: Invalid monster %d", i); + v2 = v1; + if (monster[v1]._mmode == MM_STAND) { + v3 = monster[v2]._my; + v4 = monster[v2]._mx; + v11 = M_GetDir(v1); + if (monster[v2].mtalkmsg == QUEST_ZHAR1 && !(dFlags[v4][v3] & DFLAG_VISIBLE) && _LOBYTE(monster[v2]._mgoal) == 7) { + monster[v2].mtalkmsg = QUEST_ZHAR2; + _LOBYTE(monster[v2]._mgoal) = 6; + } + if (dFlags[v4][v3] & DFLAG_VISIBLE) { + v5 = monster[v2]._mx - (unsigned char)monster[v2]._menemyx; + v6 = monster[v2]._my - (unsigned char)monster[v2]._menemyy; + v7 = abs(v6); + if (abs(v5) <= v7) + abs(v6); + else + abs(v5); + if (monster[v2].mtalkmsg == QUEST_ZHAR2) { + //_LOBYTE(v8) = effect_is_playing(USFX_ZHAR2); + if (!effect_is_playing(USFX_ZHAR2) && _LOBYTE(monster[v2]._mgoal) == 7) { + monster[v2]._msquelch = -1; + monster[v2].mtalkmsg = 0; + _LOBYTE(monster[v2]._mgoal) = 1; + } + } + } + v9 = monster[v2]._mgoal; + if (v9 == 1 || v9 == 2 || v9 == 4) + MAI_Counselor(arglist); + monster[v2]._mdir = v11; + if (monster[v2]._mmode == MM_STAND) + monster[v2]._mAnimData = monster[v2].MType->Anims[MA_STAND].Data[v11]; + } } void __fastcall MAI_SnotSpil(int i) { - int v1; // ebp - int v2; // esi - int v3; // ebx - int v4; // edi - int v5; // ebp - //int v6; // eax - char v7; // al - int arglist; // [esp+8h] [ebp-4h] + int v1; // ebp + int v2; // esi + int v3; // ebx + int v4; // edi + int v5; // ebp + //int v6; // eax + char v7; // al + int arglist; // [esp+8h] [ebp-4h] - v1 = i; - arglist = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_SnotSpil: Invalid monster %d", i); - v2 = v1; - if (monster[v1]._mmode == MM_STAND) { - v3 = monster[v2]._my; - v4 = monster[v2]._mx; - v5 = M_GetDir(v1); - if (monster[v2].mtalkmsg == QUEST_BANNER10 && !(dFlags[v4][v3] & DFLAG_VISIBLE) && _LOBYTE(monster[v2]._mgoal) == 7) { - monster[v2].mtalkmsg = QUEST_BANNER11; - _LOBYTE(monster[v2]._mgoal) = 6; - } - if (monster[v2].mtalkmsg == QUEST_BANNER11 && quests[QTYPE_BOL]._qvar1 == 3) { - monster[v2].mtalkmsg = 0; - _LOBYTE(monster[v2]._mgoal) = 1; - } - if (dFlags[v4][v3] & DFLAG_VISIBLE) { - if (monster[v2].mtalkmsg == QUEST_BANNER12) { - //_LOBYTE(v6) = effect_is_playing(USFX_SNOT3); - if (!effect_is_playing(USFX_SNOT3) && _LOBYTE(monster[v2]._mgoal) == 7) { - ObjChangeMap(setpc_x, setpc_y, setpc_w + setpc_x + 1, setpc_h + setpc_y + 1); - quests[QTYPE_BOL]._qvar1 = 3; - RedoPlayerVision(); - monster[v2]._msquelch = -1; - monster[v2].mtalkmsg = 0; - _LOBYTE(monster[v2]._mgoal) = 1; - } - } - if (quests[QTYPE_BOL]._qvar1 == 3) { - v7 = monster[v2]._mgoal; - if (v7 == 1 || v7 == 5) - MAI_Fallen(arglist); - } - } - monster[v2]._mdir = v5; - if (monster[v2]._mmode == MM_STAND) - monster[v2]._mAnimData = monster[v2].MType->Anims[MA_STAND].Data[v5]; - } + v1 = i; + arglist = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("MAI_SnotSpil: Invalid monster %d", i); + v2 = v1; + if (monster[v1]._mmode == MM_STAND) { + v3 = monster[v2]._my; + v4 = monster[v2]._mx; + v5 = M_GetDir(v1); + if (monster[v2].mtalkmsg == QUEST_BANNER10 && !(dFlags[v4][v3] & DFLAG_VISIBLE) && _LOBYTE(monster[v2]._mgoal) == 7) { + monster[v2].mtalkmsg = QUEST_BANNER11; + _LOBYTE(monster[v2]._mgoal) = 6; + } + if (monster[v2].mtalkmsg == QUEST_BANNER11 && quests[QTYPE_BOL]._qvar1 == 3) { + monster[v2].mtalkmsg = 0; + _LOBYTE(monster[v2]._mgoal) = 1; + } + if (dFlags[v4][v3] & DFLAG_VISIBLE) { + if (monster[v2].mtalkmsg == QUEST_BANNER12) { + //_LOBYTE(v6) = effect_is_playing(USFX_SNOT3); + if (!effect_is_playing(USFX_SNOT3) && _LOBYTE(monster[v2]._mgoal) == 7) { + ObjChangeMap(setpc_x, setpc_y, setpc_w + setpc_x + 1, setpc_h + setpc_y + 1); + quests[QTYPE_BOL]._qvar1 = 3; + RedoPlayerVision(); + monster[v2]._msquelch = -1; + monster[v2].mtalkmsg = 0; + _LOBYTE(monster[v2]._mgoal) = 1; + } + } + if (quests[QTYPE_BOL]._qvar1 == 3) { + v7 = monster[v2]._mgoal; + if (v7 == 1 || v7 == 5) + MAI_Fallen(arglist); + } + } + monster[v2]._mdir = v5; + if (monster[v2]._mmode == MM_STAND) + monster[v2]._mAnimData = monster[v2].MType->Anims[MA_STAND].Data[v5]; + } } // 5CF330: using guessed type int setpc_h; // 5CF334: using guessed type int setpc_w; void __fastcall MAI_Lazurus(int i) { - int v1; // ebx - int v2; // esi - int v3; // ebp - int v4; // edi - int v5; // ebx - //int v6; // eax - char v7; // al - int v8; // eax - int arglist; // [esp+8h] [ebp-4h] + int v1; // ebx + int v2; // esi + int v3; // ebp + int v4; // edi + int v5; // ebx + //int v6; // eax + char v7; // al + int v8; // eax + int arglist; // [esp+8h] [ebp-4h] - v1 = i; - arglist = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_Lazurus: Invalid monster %d", i); - v2 = v1; - if (monster[v1]._mmode == MM_STAND) { - v3 = monster[v2]._my; - v4 = monster[v2]._mx; - v5 = M_GetDir(v1); - if (dFlags[v4][v3] & DFLAG_VISIBLE) { - if (gbMaxPlayers != 1) - goto LABEL_29; - if (monster[v2].mtalkmsg == QUEST_VILE13) { - if (_LOBYTE(monster[v2]._mgoal) == 6 && plr[myplr].WorldX == QUEST_VILE13 && plr[myplr].WorldY == 46) { - PlayInGameMovie("gendata\\fprst3.smk"); - monster[v2]._mmode = MM_TALK; - quests[QTYPE_VB]._qvar1 = 5; - } - if (monster[v2].mtalkmsg == QUEST_VILE13) { - //_LOBYTE(v6) = effect_is_playing(USFX_LAZ1); - if (!effect_is_playing(USFX_LAZ1) && _LOBYTE(monster[v2]._mgoal) == 7) { - ObjChangeMapResync(1, 18, 20, 24); - RedoPlayerVision(); - monster[v2]._msquelch = -1; - monster[v2].mtalkmsg = 0; - quests[QTYPE_VB]._qvar1 = 6; - _LOBYTE(monster[v2]._mgoal) = 1; - } - } - } - if (gbMaxPlayers != 1) { - LABEL_29: - if (monster[v2].mtalkmsg == QUEST_VILE13 && _LOBYTE(monster[v2]._mgoal) == 6 && quests[QTYPE_VB]._qvar1 <= 3u) - monster[v2]._mmode = MM_TALK; - } - } - v7 = monster[v2]._mgoal; - if (v7 == 1 || v7 == 2 || v7 == 4) { - monster[v2].mtalkmsg = 0; - MAI_Counselor(arglist); - } - monster[v2]._mdir = v5; - v8 = monster[v2]._mmode; - if (v8 == MM_STAND || v8 == MM_TALK) - monster[v2]._mAnimData = monster[v2].MType->Anims[MA_STAND].Data[v5]; - } + v1 = i; + arglist = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("MAI_Lazurus: Invalid monster %d", i); + v2 = v1; + if (monster[v1]._mmode == MM_STAND) { + v3 = monster[v2]._my; + v4 = monster[v2]._mx; + v5 = M_GetDir(v1); + if (dFlags[v4][v3] & DFLAG_VISIBLE) { + if (gbMaxPlayers != 1) + goto LABEL_29; + if (monster[v2].mtalkmsg == QUEST_VILE13) { + if (_LOBYTE(monster[v2]._mgoal) == 6 && plr[myplr].WorldX == QUEST_VILE13 && plr[myplr].WorldY == 46) { + PlayInGameMovie("gendata\\fprst3.smk"); + monster[v2]._mmode = MM_TALK; + quests[QTYPE_VB]._qvar1 = 5; + } + if (monster[v2].mtalkmsg == QUEST_VILE13) { + //_LOBYTE(v6) = effect_is_playing(USFX_LAZ1); + if (!effect_is_playing(USFX_LAZ1) && _LOBYTE(monster[v2]._mgoal) == 7) { + ObjChangeMapResync(1, 18, 20, 24); + RedoPlayerVision(); + monster[v2]._msquelch = -1; + monster[v2].mtalkmsg = 0; + quests[QTYPE_VB]._qvar1 = 6; + _LOBYTE(monster[v2]._mgoal) = 1; + } + } + } + if (gbMaxPlayers != 1) { + LABEL_29: + if (monster[v2].mtalkmsg == QUEST_VILE13 && _LOBYTE(monster[v2]._mgoal) == 6 && quests[QTYPE_VB]._qvar1 <= 3u) + monster[v2]._mmode = MM_TALK; + } + } + v7 = monster[v2]._mgoal; + if (v7 == 1 || v7 == 2 || v7 == 4) { + monster[v2].mtalkmsg = 0; + MAI_Counselor(arglist); + } + monster[v2]._mdir = v5; + v8 = monster[v2]._mmode; + if (v8 == MM_STAND || v8 == MM_TALK) + monster[v2]._mAnimData = monster[v2].MType->Anims[MA_STAND].Data[v5]; + } } // 679660: using guessed type char gbMaxPlayers; void __fastcall MAI_Lazhelp(int i) { - int v1; // esi - int v2; // esi - int v3; // ebx - int v4; // edi - int v5; // [esp+4h] [ebp-8h] - int ia; // [esp+8h] [ebp-4h] + int v1; // esi + int v2; // esi + int v3; // ebx + int v4; // edi + int v5; // [esp+4h] [ebp-8h] + int ia; // [esp+8h] [ebp-4h] - v1 = i; - ia = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_Lazhelp: Invalid monster %d", i); - v2 = v1; - if (monster[v2]._mmode == MM_STAND) { - v3 = monster[v2]._my; - v4 = monster[v2]._mx; - v5 = M_GetDir(ia); - if (dFlags[v4][v3] & DFLAG_VISIBLE) { - if (gbMaxPlayers == 1) { - if (quests[QTYPE_VB]._qvar1 <= 5u) { - _LOBYTE(monster[v2]._mgoal) = 6; - goto LABEL_10; - } - monster[v2].mtalkmsg = 0; - } - _LOBYTE(monster[v2]._mgoal) = 1; - } - LABEL_10: - if (_LOBYTE(monster[v2]._mgoal) == 1) - MAI_Succ(ia); - monster[v2]._mdir = v5; - if (monster[v2]._mmode == MM_STAND) - monster[v2]._mAnimData = monster[v2].MType->Anims[MA_STAND].Data[v5]; - } + v1 = i; + ia = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("MAI_Lazhelp: Invalid monster %d", i); + v2 = v1; + if (monster[v2]._mmode == MM_STAND) { + v3 = monster[v2]._my; + v4 = monster[v2]._mx; + v5 = M_GetDir(ia); + if (dFlags[v4][v3] & DFLAG_VISIBLE) { + if (gbMaxPlayers == 1) { + if (quests[QTYPE_VB]._qvar1 <= 5u) { + _LOBYTE(monster[v2]._mgoal) = 6; + goto LABEL_10; + } + monster[v2].mtalkmsg = 0; + } + _LOBYTE(monster[v2]._mgoal) = 1; + } + LABEL_10: + if (_LOBYTE(monster[v2]._mgoal) == 1) + MAI_Succ(ia); + monster[v2]._mdir = v5; + if (monster[v2]._mmode == MM_STAND) + monster[v2]._mAnimData = monster[v2].MType->Anims[MA_STAND].Data[v5]; + } } // 679660: using guessed type char gbMaxPlayers; void __fastcall MAI_Lachdanan(int i) { - int v1; // ebp - int v2; // esi - int v3; // ebx - int v4; // edi - //int v5; // eax - int v6; // [esp+8h] [ebp-4h] + int v1; // ebp + int v2; // esi + int v3; // ebx + int v4; // edi + //int v5; // eax + int v6; // [esp+8h] [ebp-4h] - v1 = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_Lachdanan: Invalid monster %d", i); - v2 = v1; - if (monster[v1]._mmode == MM_STAND) { - v3 = monster[v2]._my; - v4 = monster[v2]._mx; - v6 = M_GetDir(v1); - if (monster[v2].mtalkmsg == QUEST_VEIL9 && !(dFlags[v4][v3] & DFLAG_VISIBLE) && _LOBYTE(monster[v2]._mgoal) == 7) { - monster[v2].mtalkmsg = QUEST_VEIL10; - _LOBYTE(monster[v2]._mgoal) = 6; - } - if (dFlags[v4][v3] & DFLAG_VISIBLE) { - if (monster[v2].mtalkmsg == QUEST_VEIL11) { - //_LOBYTE(v5) = effect_is_playing(USFX_LACH3); - if (!effect_is_playing(USFX_LACH3) && _LOBYTE(monster[v2]._mgoal) == 7) { - monster[v2].mtalkmsg = 0; - quests[QTYPE_VEIL]._qactive = 3; - M_StartKill(v1, -1); - } - } - } - monster[v2]._mdir = v6; - if (monster[v2]._mmode == MM_STAND) - monster[v2]._mAnimData = monster[v2].MType->Anims[MA_STAND].Data[v6]; - } + v1 = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("MAI_Lachdanan: Invalid monster %d", i); + v2 = v1; + if (monster[v1]._mmode == MM_STAND) { + v3 = monster[v2]._my; + v4 = monster[v2]._mx; + v6 = M_GetDir(v1); + if (monster[v2].mtalkmsg == QUEST_VEIL9 && !(dFlags[v4][v3] & DFLAG_VISIBLE) && _LOBYTE(monster[v2]._mgoal) == 7) { + monster[v2].mtalkmsg = QUEST_VEIL10; + _LOBYTE(monster[v2]._mgoal) = 6; + } + if (dFlags[v4][v3] & DFLAG_VISIBLE) { + if (monster[v2].mtalkmsg == QUEST_VEIL11) { + //_LOBYTE(v5) = effect_is_playing(USFX_LACH3); + if (!effect_is_playing(USFX_LACH3) && _LOBYTE(monster[v2]._mgoal) == 7) { + monster[v2].mtalkmsg = 0; + quests[QTYPE_VEIL]._qactive = 3; + M_StartKill(v1, -1); + } + } + } + monster[v2]._mdir = v6; + if (monster[v2]._mmode == MM_STAND) + monster[v2]._mAnimData = monster[v2].MType->Anims[MA_STAND].Data[v6]; + } } void __fastcall MAI_Warlord(int i) { - int v1; // ebp - int v2; // esi - int v3; // ebx - int v4; // edi - int v5; // ebp - //int v6; // eax - int v7; // eax - int arglist; // [esp+8h] [ebp-4h] + int v1; // ebp + int v2; // esi + int v3; // ebx + int v4; // edi + int v5; // ebp + //int v6; // eax + int v7; // eax + int arglist; // [esp+8h] [ebp-4h] - v1 = i; - arglist = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("MAI_Warlord: Invalid monster %d", i); - v2 = v1; - if (monster[v1]._mmode == MM_STAND) { - v3 = monster[v2]._my; - v4 = monster[v2]._mx; - v5 = M_GetDir(v1); - if (dFlags[v4][v3] & DFLAG_VISIBLE && monster[v2].mtalkmsg == QUEST_WARLRD9) { - if (_LOBYTE(monster[v2]._mgoal) == 6) - monster[v2]._mmode = MM_TALK; - //_LOBYTE(v6) = effect_is_playing(USFX_WARLRD1); - if (!effect_is_playing(USFX_WARLRD1) && _LOBYTE(monster[v2]._mgoal) == 7) { - monster[v2]._msquelch = -1; - monster[v2].mtalkmsg = 0; - _LOBYTE(monster[v2]._mgoal) = 1; - } - } - if (_LOBYTE(monster[v2]._mgoal) == 1) - MAI_SkelSd(arglist); - monster[v2]._mdir = v5; - v7 = monster[v2]._mmode; - if (v7 == MM_STAND || v7 == MM_TALK) - monster[v2]._mAnimData = monster[v2].MType->Anims[MA_STAND].Data[v5]; - } + v1 = i; + arglist = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("MAI_Warlord: Invalid monster %d", i); + v2 = v1; + if (monster[v1]._mmode == MM_STAND) { + v3 = monster[v2]._my; + v4 = monster[v2]._mx; + v5 = M_GetDir(v1); + if (dFlags[v4][v3] & DFLAG_VISIBLE && monster[v2].mtalkmsg == QUEST_WARLRD9) { + if (_LOBYTE(monster[v2]._mgoal) == 6) + monster[v2]._mmode = MM_TALK; + //_LOBYTE(v6) = effect_is_playing(USFX_WARLRD1); + if (!effect_is_playing(USFX_WARLRD1) && _LOBYTE(monster[v2]._mgoal) == 7) { + monster[v2]._msquelch = -1; + monster[v2].mtalkmsg = 0; + _LOBYTE(monster[v2]._mgoal) = 1; + } + } + if (_LOBYTE(monster[v2]._mgoal) == 1) + MAI_SkelSd(arglist); + monster[v2]._mdir = v5; + v7 = monster[v2]._mmode; + if (v7 == MM_STAND || v7 == MM_TALK) + monster[v2]._mAnimData = monster[v2].MType->Anims[MA_STAND].Data[v5]; + } } void __cdecl DeleteMonsterList() { - int *v0; // eax - signed int v1; // ecx + int *v0; // eax + signed int v1; // ecx - v0 = &monster[0]._my; - do { - if (v0[18]) { - *(v0 - 1) = 1; - *v0 = 0; - v0[1] = 0; - v0[2] = 0; - v0[3] = 0; - v0[4] = 0; - v0[18] = 0; - } - v0 += 57; - } while ((signed int)v0 < (signed int)&monster[4]._my); - v1 = 4; - while (v1 < nummonsters) { - if (monster[monstactive[v1]]._mDelFlag) { - DeleteMonster(v1); - v1 = 0; - } else { - ++v1; - } - } + v0 = &monster[0]._my; + do { + if (v0[18]) { + *(v0 - 1) = 1; + *v0 = 0; + v0[1] = 0; + v0[2] = 0; + v0[3] = 0; + v0[4] = 0; + v0[18] = 0; + } + v0 += 57; + } while ((signed int)v0 < (signed int)&monster[4]._my); + v1 = 4; + while (v1 < nummonsters) { + if (monster[monstactive[v1]]._mDelFlag) { + DeleteMonster(v1); + v1 = 0; + } else { + ++v1; + } + } } void __cdecl ProcessMonsters() { - int v0; // edi - int v1; // esi - int v2; // ecx - int v3; // eax - char *v4; // ebx - unsigned int v5; // eax - int v6; // eax - int v7; // edx - int v8; // eax - unsigned int v9; // eax - int v10; // eax - bool v11; // zf - char *v12; // ecx - char *v13; // eax - int v14; // ecx - int v15; // eax - char v16; // al - int v17; // ecx - bool v18; // eax - int v19; // eax - int v20; // ecx - int *v21; // eax - int *v22; // eax - int v23; // [esp+0h] [ebp-Ch] - int v24; // [esp+4h] [ebp-8h] - int v25; // [esp+8h] [ebp-4h] + int v0; // edi + int v1; // esi + int v2; // ecx + int v3; // eax + char *v4; // ebx + unsigned int v5; // eax + int v6; // eax + int v7; // edx + int v8; // eax + unsigned int v9; // eax + int v10; // eax + bool v11; // zf + char *v12; // ecx + char *v13; // eax + int v14; // ecx + int v15; // eax + char v16; // al + int v17; // ecx + bool v18; // eax + int v19; // eax + int v20; // ecx + int *v21; // eax + int *v22; // eax + int v23; // [esp+0h] [ebp-Ch] + int v24; // [esp+4h] [ebp-8h] + int v25; // [esp+8h] [ebp-4h] - DeleteMonsterList(); - v24 = 0; - if (nummonsters <= 0) - goto LABEL_60; - do { - v25 = 0; - v23 = monstactive[v24]; - v0 = v23; - v1 = v23; - if ((unsigned char)gbMaxPlayers > 1u) { - SetRndSeed(monster[v1]._mAISeed); - monster[v1]._mAISeed = GetRndSeed(); - } - if (!(monster[v1]._mFlags & 8)) { - v2 = monster[v1]._mhitpoints; - if (v2 < monster[v1]._mmaxhp && v2 >> 6 > 0) { - v3 = SLOBYTE(monster[v1].mLevel); - if ((char)v3 > 1) - v3 = (char)v3 >> 1; - monster[v1]._mhitpoints = v2 + v3; - } - } - v4 = &dFlags[monster[v1]._mx][monster[v1]._my]; - if (*v4 & DFLAG_VISIBLE && !monster[v1]._msquelch && monster[v1].MType->mtype == MT_CLEAVER) - PlaySFX(USFX_CLEAVER); - if (monster[v1]._mFlags & 0x10) { - v5 = monster[v1]._menemy; - if (v5 >= MAXMONSTERS) - TermMsg("Illegal enemy monster %d for monster \"%s\"", v5, monster[v1].mName); - v6 = monster[v1]._menemy; - v7 = monster[v6]._mfutx; - monster[v1]._lastx = v7; - monster[v1]._menemyx = v7; - v8 = monster[v6]._mfuty; - monster[v1]._menemyy = v8; - monster[v1]._lasty = v8; - } else { - v9 = monster[v1]._menemy; - if (v9 >= MAX_PLRS) - TermMsg("Illegal enemy player %d for monster \"%s\"", v9, monster[v1].mName); - v10 = monster[v1]._menemy; - v11 = (*v4 & DFLAG_VISIBLE) == 0; - v12 = (char *)&plr[v10]._px; - v13 = (char *)&plr[v10]._py; - monster[v1]._menemyx = *v12; - monster[v1]._menemyy = *v13; - if (v11) { - v16 = monster[v1]._msquelch; - if (v16 && monster[v1]._mAi != MT_DIABLO) /// BUGFIX: test `MT_DIABLO` with 'MType->mtype' instead of '_mAi' - monster[v1]._msquelch = v16 - 1; - } else { - v14 = *(_DWORD *)v12; - v15 = *(_DWORD *)v13; - monster[v1]._msquelch = -1; - monster[v1]._lastx = v14; - monster[v1]._lasty = v15; - } - v0 = v23; - } - while (1) { - v17 = v0; - if (monster[v1]._mFlags & 0x100) { - v18 = MAI_Path(v0); - if (v18) - goto LABEL_30; - v17 = v0; - } - AiProc[(unsigned char)monster[v1]._mAi](v17); - LABEL_30: - switch (monster[v1]._mmode) { - case MM_STAND: - v19 = M_DoStand(v0); - goto LABEL_48; - case MM_WALK: - v19 = M_DoWalk(v0); - goto LABEL_48; - case MM_WALK2: - v19 = M_DoWalk2(v0); - goto LABEL_48; - case MM_WALK3: - v19 = M_DoWalk3(v0); - goto LABEL_48; - case MM_ATTACK: - v19 = M_DoAttack(v0); - goto LABEL_48; - case MM_GOTHIT: - v19 = M_DoGotHit(v0); - goto LABEL_48; - case MM_DEATH: - v19 = M_DoDeath(v0); - goto LABEL_48; - case MM_SATTACK: - v19 = M_DoSAttack(v0); - goto LABEL_48; - case MM_FADEIN: - v19 = M_DoFadein(v0); - goto LABEL_48; - case MM_FADEOUT: - v19 = M_DoFadeout(v0); - goto LABEL_48; - case MM_RATTACK: - v19 = M_DoRAttack(v0); - goto LABEL_48; - case MM_SPSTAND: - v19 = M_DoSpStand(v0); - goto LABEL_48; - case MM_RSPATTACK: - v19 = M_DoRSpAttack(v0); - goto LABEL_48; - case MM_DELAY: - v19 = M_DoDelay(v0); - goto LABEL_48; - case MM_CHARGE: - goto LABEL_51; - case MM_STONE: - v19 = M_DoStone(v0); - goto LABEL_48; - case MM_HEAL: - v19 = M_DoHeal(v0); - goto LABEL_48; - case MM_TALK: - v19 = M_DoTalk(v0); - LABEL_48: - v25 = v19; - break; - default: - break; - } - if (!v25) - break; - GroupUnity(v0); - } - LABEL_51: - if (monster[v1]._mmode != MM_STONE) { - v20 = monster[v1]._mFlags; - v21 = &monster[v1]._mAnimCnt; - ++*v21; - if (!(v20 & 4) && monster[v1]._mAnimCnt >= monster[v1]._mAnimDelay) { - *v21 = 0; - v22 = &monster[v1]._mAnimFrame; - if (v20 & 2) { - v11 = (*v22)-- == 1; - if (v11) - *v22 = monster[v1]._mAnimLen; - } else if (++*v22 > monster[v1]._mAnimLen) { - *v22 = 1; - } - } - } - ++v24; - } while (v24 < nummonsters); + DeleteMonsterList(); + v24 = 0; + if (nummonsters <= 0) + goto LABEL_60; + do { + v25 = 0; + v23 = monstactive[v24]; + v0 = v23; + v1 = v23; + if ((unsigned char)gbMaxPlayers > 1u) { + SetRndSeed(monster[v1]._mAISeed); + monster[v1]._mAISeed = GetRndSeed(); + } + if (!(monster[v1]._mFlags & 8)) { + v2 = monster[v1]._mhitpoints; + if (v2 < monster[v1]._mmaxhp && v2 >> 6 > 0) { + v3 = SLOBYTE(monster[v1].mLevel); + if ((char)v3 > 1) + v3 = (char)v3 >> 1; + monster[v1]._mhitpoints = v2 + v3; + } + } + v4 = &dFlags[monster[v1]._mx][monster[v1]._my]; + if (*v4 & DFLAG_VISIBLE && !monster[v1]._msquelch && monster[v1].MType->mtype == MT_CLEAVER) + PlaySFX(USFX_CLEAVER); + if (monster[v1]._mFlags & 0x10) { + v5 = monster[v1]._menemy; + if (v5 >= MAXMONSTERS) + TermMsg("Illegal enemy monster %d for monster \"%s\"", v5, monster[v1].mName); + v6 = monster[v1]._menemy; + v7 = monster[v6]._mfutx; + monster[v1]._lastx = v7; + monster[v1]._menemyx = v7; + v8 = monster[v6]._mfuty; + monster[v1]._menemyy = v8; + monster[v1]._lasty = v8; + } else { + v9 = monster[v1]._menemy; + if (v9 >= MAX_PLRS) + TermMsg("Illegal enemy player %d for monster \"%s\"", v9, monster[v1].mName); + v10 = monster[v1]._menemy; + v11 = (*v4 & DFLAG_VISIBLE) == 0; + v12 = (char *)&plr[v10]._px; + v13 = (char *)&plr[v10]._py; + monster[v1]._menemyx = *v12; + monster[v1]._menemyy = *v13; + if (v11) { + v16 = monster[v1]._msquelch; + if (v16 && monster[v1]._mAi != MT_DIABLO) /// BUGFIX: test `MT_DIABLO` with 'MType->mtype' instead of '_mAi' + monster[v1]._msquelch = v16 - 1; + } else { + v14 = *(_DWORD *)v12; + v15 = *(_DWORD *)v13; + monster[v1]._msquelch = -1; + monster[v1]._lastx = v14; + monster[v1]._lasty = v15; + } + v0 = v23; + } + while (1) { + v17 = v0; + if (monster[v1]._mFlags & 0x100) { + v18 = MAI_Path(v0); + if (v18) + goto LABEL_30; + v17 = v0; + } + AiProc[(unsigned char)monster[v1]._mAi](v17); + LABEL_30: + switch (monster[v1]._mmode) { + case MM_STAND: + v19 = M_DoStand(v0); + goto LABEL_48; + case MM_WALK: + v19 = M_DoWalk(v0); + goto LABEL_48; + case MM_WALK2: + v19 = M_DoWalk2(v0); + goto LABEL_48; + case MM_WALK3: + v19 = M_DoWalk3(v0); + goto LABEL_48; + case MM_ATTACK: + v19 = M_DoAttack(v0); + goto LABEL_48; + case MM_GOTHIT: + v19 = M_DoGotHit(v0); + goto LABEL_48; + case MM_DEATH: + v19 = M_DoDeath(v0); + goto LABEL_48; + case MM_SATTACK: + v19 = M_DoSAttack(v0); + goto LABEL_48; + case MM_FADEIN: + v19 = M_DoFadein(v0); + goto LABEL_48; + case MM_FADEOUT: + v19 = M_DoFadeout(v0); + goto LABEL_48; + case MM_RATTACK: + v19 = M_DoRAttack(v0); + goto LABEL_48; + case MM_SPSTAND: + v19 = M_DoSpStand(v0); + goto LABEL_48; + case MM_RSPATTACK: + v19 = M_DoRSpAttack(v0); + goto LABEL_48; + case MM_DELAY: + v19 = M_DoDelay(v0); + goto LABEL_48; + case MM_CHARGE: + goto LABEL_51; + case MM_STONE: + v19 = M_DoStone(v0); + goto LABEL_48; + case MM_HEAL: + v19 = M_DoHeal(v0); + goto LABEL_48; + case MM_TALK: + v19 = M_DoTalk(v0); + LABEL_48: + v25 = v19; + break; + default: + break; + } + if (!v25) + break; + GroupUnity(v0); + } + LABEL_51: + if (monster[v1]._mmode != MM_STONE) { + v20 = monster[v1]._mFlags; + v21 = &monster[v1]._mAnimCnt; + ++*v21; + if (!(v20 & 4) && monster[v1]._mAnimCnt >= monster[v1]._mAnimDelay) { + *v21 = 0; + v22 = &monster[v1]._mAnimFrame; + if (v20 & 2) { + v11 = (*v22)-- == 1; + if (v11) + *v22 = monster[v1]._mAnimLen; + } else if (++*v22 > monster[v1]._mAnimLen) { + *v22 = 1; + } + } + } + ++v24; + } while (v24 < nummonsters); LABEL_60: - DeleteMonsterList(); + DeleteMonsterList(); } // 679660: using guessed type char gbMaxPlayers; void __cdecl FreeMonsters() { - void **v0; // edi - int v1; // ebx - signed int v2; // ebp - void **v3; // esi - void *v4; // ecx - int v5; // [esp+0h] [ebp-4h] + void **v0; // edi + int v1; // ebx + signed int v2; // ebp + void **v3; // esi + void *v4; // ecx + int v5; // [esp+0h] [ebp-4h] - v5 = 0; - if (nummtypes > 0) { - v0 = (void **)Monsters[0].Anims; - do { - v1 = *((unsigned char *)v0 - 4); - v2 = 0; - v3 = v0; - do { - if (animletter[v2] != 's' || monsterdata[v1].has_special) { - v4 = *v3; - *v3 = 0; - mem_free_dbg(v4); - } - ++v2; - v3 += 11; - } while (v2 < 6); - ++v5; - v0 += 82; - } while (v5 < nummtypes); - } - FreeMissiles2(); + v5 = 0; + if (nummtypes > 0) { + v0 = (void **)Monsters[0].Anims; + do { + v1 = *((unsigned char *)v0 - 4); + v2 = 0; + v3 = v0; + do { + if (animletter[v2] != 's' || monsterdata[v1].has_special) { + v4 = *v3; + *v3 = 0; + mem_free_dbg(v4); + } + ++v2; + v3 += 11; + } while (v2 < 6); + ++v5; + v0 += 82; + } while (v5 < nummtypes); + } + FreeMissiles2(); } BOOL __fastcall DirOK(int i, int mdir) { - int v2; // ebx - int v3; // esi - int v4; // ebx - int v5; // edi - int v6; // esi - int v7; // edi - bool v8; // zf - int v9; // edx - unsigned char *v11; // ebx - unsigned char v12; // al - int v13; // edx - int v14; // eax - int v15; // edi - int v16; // ecx - signed int j; // esi - int v18; // eax - bool v19; // zf - int v20; // eax - int v21; // [esp+Ch] [ebp-14h] - int v22; // [esp+10h] [ebp-10h] - int v23; // [esp+14h] [ebp-Ch] - int a1; // [esp+18h] [ebp-8h] - int v25; // [esp+1Ch] [ebp-4h] - int v26; // [esp+1Ch] [ebp-4h] + int v2; // ebx + int v3; // esi + int v4; // ebx + int v5; // edi + int v6; // esi + int v7; // edi + bool v8; // zf + int v9; // edx + unsigned char *v11; // ebx + unsigned char v12; // al + int v13; // edx + int v14; // eax + int v15; // edi + int v16; // ecx + signed int j; // esi + int v18; // eax + bool v19; // zf + int v20; // eax + int v21; // [esp+Ch] [ebp-14h] + int v22; // [esp+10h] [ebp-10h] + int v23; // [esp+14h] [ebp-Ch] + int a1; // [esp+18h] [ebp-8h] + int v25; // [esp+1Ch] [ebp-4h] + int v26; // [esp+1Ch] [ebp-4h] - v2 = i; - v3 = mdir; - v25 = mdir; - a1 = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("DirOK: Invalid monster %d", i); - v4 = v2; - v5 = offset_y[v3]; - v6 = monster[v4]._mx + offset_x[v3]; - v7 = monster[v4]._my + v5; - if (v7 < 0 || v7 >= 112 || v6 < 0 || v6 >= 112 || !PosOkMonst(a1, v6, v7)) - return 0; - if (v25 == DIR_E) { - if (!SolidLoc(v6, v7 + 1)) { - v8 = (dFlags[v6][v7 + 1] & DFLAG_MONSTER) == 0; - goto LABEL_18; - } - return 0; - } - if (v25 == DIR_W) { - if (SolidLoc(v6 + 1, v7)) - return 0; - v8 = (dFlags[v6 + 1][v7] & DFLAG_MONSTER) == 0; - } else { - if (v25 == DIR_N) { - if (SolidLoc(v6 + 1, v7)) - return 0; - v9 = v7 + 1; - } else { - if (v25) - goto LABEL_24; - if (SolidLoc(v6 - 1, v7)) - return 0; - v9 = v7 - 1; - } - v8 = SolidLoc(v6, v9) == 0; - } + v2 = i; + v3 = mdir; + v25 = mdir; + a1 = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("DirOK: Invalid monster %d", i); + v4 = v2; + v5 = offset_y[v3]; + v6 = monster[v4]._mx + offset_x[v3]; + v7 = monster[v4]._my + v5; + if (v7 < 0 || v7 >= 112 || v6 < 0 || v6 >= 112 || !PosOkMonst(a1, v6, v7)) + return 0; + if (v25 == DIR_E) { + if (!SolidLoc(v6, v7 + 1)) { + v8 = (dFlags[v6][v7 + 1] & DFLAG_MONSTER) == 0; + goto LABEL_18; + } + return 0; + } + if (v25 == DIR_W) { + if (SolidLoc(v6 + 1, v7)) + return 0; + v8 = (dFlags[v6 + 1][v7] & DFLAG_MONSTER) == 0; + } else { + if (v25 == DIR_N) { + if (SolidLoc(v6 + 1, v7)) + return 0; + v9 = v7 + 1; + } else { + if (v25) + goto LABEL_24; + if (SolidLoc(v6 - 1, v7)) + return 0; + v9 = v7 - 1; + } + v8 = SolidLoc(v6, v9) == 0; + } LABEL_18: - if (!v8) - return 0; + if (!v8) + return 0; LABEL_24: - if (monster[v4].leaderflag == 1) { - v11 = &monster[v4].leader; - if (abs(v6 - monster[(unsigned char)*v11]._mfutx) >= 4 - || abs(v7 - monster[(unsigned char)*v11]._mfuty) >= 4) { - return 0; - } - return 1; - } - v12 = monster[v4]._uniqtype; - if (v12 == 0 || !(UniqMonst[v12 - 1].mUnqAttr & 2)) - return 1; - v26 = 0; - v13 = v6 - 3; - v21 = v6 + 3; - if (v6 - 3 <= v6 + 3) { - v14 = v7 - 3; - v15 = v7 + 3; - v23 = v14; - v22 = v15; - v16 = 112 * v13; - do { - for (j = v23; j <= v15; ++j) { - if (j >= 0 && j < 112 && v16 >= 0 && v16 < MAXDUNX * MAXDUNY) { - v18 = dMonster[0][v16 + j]; - v19 = v18 == 0; - if (v18 < 0) { - v18 = -v18; - v19 = v18 == 0; - } - if (!v19) - --v18; - v20 = v18; - if (monster[v20].leaderflag == 1 - && (unsigned char)monster[v20].leader == a1 - && monster[v20]._mfutx == v13 - && monster[v20]._mfuty == j) { - ++v26; - } - } - v15 = v22; - } - ++v13; - v16 += 112; - } while (v13 <= v21); - } - return v26 == (unsigned char)monster[v4].unpackfilesize; + if (monster[v4].leaderflag == 1) { + v11 = &monster[v4].leader; + if (abs(v6 - monster[(unsigned char)*v11]._mfutx) >= 4 + || abs(v7 - monster[(unsigned char)*v11]._mfuty) >= 4) { + return 0; + } + return 1; + } + v12 = monster[v4]._uniqtype; + if (v12 == 0 || !(UniqMonst[v12 - 1].mUnqAttr & 2)) + return 1; + v26 = 0; + v13 = v6 - 3; + v21 = v6 + 3; + if (v6 - 3 <= v6 + 3) { + v14 = v7 - 3; + v15 = v7 + 3; + v23 = v14; + v22 = v15; + v16 = 112 * v13; + do { + for (j = v23; j <= v15; ++j) { + if (j >= 0 && j < 112 && v16 >= 0 && v16 < MAXDUNX * MAXDUNY) { + v18 = dMonster[0][v16 + j]; + v19 = v18 == 0; + if (v18 < 0) { + v18 = -v18; + v19 = v18 == 0; + } + if (!v19) + --v18; + v20 = v18; + if (monster[v20].leaderflag == 1 + && (unsigned char)monster[v20].leader == a1 + && monster[v20]._mfutx == v13 + && monster[v20]._mfuty == j) { + ++v26; + } + } + v15 = v22; + } + ++v13; + v16 += 112; + } while (v13 <= v21); + } + return v26 == (unsigned char)monster[v4].unpackfilesize; } BOOL __fastcall PosOkMissile(int x, int y) { - return !nMissileTable[dPiece[x][y]] && !(dFlags[x][y] & DFLAG_MONSTER); + return !nMissileTable[dPiece[x][y]] && !(dFlags[x][y] & DFLAG_MONSTER); } BOOL __fastcall CheckNoSolid(int x, int y) { - return nSolidTable[dPiece[x][y]] == 0; + return nSolidTable[dPiece[x][y]] == 0; } BOOL __fastcall LineClearF(BOOL(__fastcall *Clear)(int, int), int x1, int y1, int x2, int y2) { - int v5; // esi - int v6; // edi - int v7; // ebx - int v8; // eax - int v9; // eax - int v10; // eax - int v11; // ebx - int v12; // esi - signed int v13; // edi - int v14; // edx - int v15; // ecx - int v16; // eax - int v17; // eax - int v18; // eax - int v19; // ebx - int v20; // edi - signed int v21; // esi - int v22; // ecx - int v25; // [esp+10h] [ebp-10h] - int v26; // [esp+14h] [ebp-Ch] - int v27; // [esp+18h] [ebp-8h] - int v28; // [esp+18h] [ebp-8h] - int v29; // [esp+1Ch] [ebp-4h] + int v5; // esi + int v6; // edi + int v7; // ebx + int v8; // eax + int v9; // eax + int v10; // eax + int v11; // ebx + int v12; // esi + signed int v13; // edi + int v14; // edx + int v15; // ecx + int v16; // eax + int v17; // eax + int v18; // eax + int v19; // ebx + int v20; // edi + signed int v21; // esi + int v22; // ecx + int v25; // [esp+10h] [ebp-10h] + int v26; // [esp+14h] [ebp-Ch] + int v27; // [esp+18h] [ebp-8h] + int v28; // [esp+18h] [ebp-8h] + int v29; // [esp+1Ch] [ebp-4h] - v5 = y2 - y1; - v29 = x1; - v25 = x1; - v26 = y1; - v6 = x2 - x1; - v7 = abs(y2 - y1); - if (abs(v6) <= v7) { - if (v5 < 0) { - v16 = y1; - y1 = y2; - y2 = v16; - v17 = v29; - v5 = -v5; - v29 = x2; - x2 = v17; - v6 = -v6; - } - v18 = 2 * v6; - v28 = 2 * v6; - if (v6 <= 0) { - v19 = v18 + v5; - v20 = 2 * (v5 + v6); - v21 = -1; - } else { - v19 = v18 - v5; - v20 = 2 * (v6 - v5); - v21 = 1; - } - while (1) { - v22 = v29; - if (y1 == y2 && v29 == x2) - break; - if (v19 <= 0 == v21 < 0) { - v19 += v20; - v22 = v21 + v29; - v29 += v21; - } else { - v19 += v28; - } - if ((++y1 != v26 || v22 != v25) && !Clear(v22, y1)) /* check args */ - goto LABEL_29; - } - } else { - if (v6 < 0) { - v8 = v29; - v29 = x2; - x2 = v8; - v9 = y1; - v6 = -v6; - y1 = y2; - y2 = v9; - v5 = -v5; - } - v10 = 2 * v5; - v27 = 2 * v5; - if (v5 <= 0) { - v11 = v10 + v6; - v12 = 2 * (v6 + v5); - v13 = -1; - } else { - v11 = v10 - v6; - v12 = 2 * (v5 - v6); - v13 = 1; - } - do { - v14 = y1; - if (v29 == x2 && y1 == y2) - break; - if (v11 <= 0 == v13 < 0) { - v11 += v12; - v14 = v13 + y1; - y1 += v13; - } else { - v11 += v27; - } - v15 = v29 + 1; - } while (++v29 == v25 && v14 == v26 || Clear(v15, v14)); - LABEL_29: - if (v29 != x2) - return 0; - } - if (y1 == y2) - return 1; - return 0; + v5 = y2 - y1; + v29 = x1; + v25 = x1; + v26 = y1; + v6 = x2 - x1; + v7 = abs(y2 - y1); + if (abs(v6) <= v7) { + if (v5 < 0) { + v16 = y1; + y1 = y2; + y2 = v16; + v17 = v29; + v5 = -v5; + v29 = x2; + x2 = v17; + v6 = -v6; + } + v18 = 2 * v6; + v28 = 2 * v6; + if (v6 <= 0) { + v19 = v18 + v5; + v20 = 2 * (v5 + v6); + v21 = -1; + } else { + v19 = v18 - v5; + v20 = 2 * (v6 - v5); + v21 = 1; + } + while (1) { + v22 = v29; + if (y1 == y2 && v29 == x2) + break; + if (v19 <= 0 == v21 < 0) { + v19 += v20; + v22 = v21 + v29; + v29 += v21; + } else { + v19 += v28; + } + if ((++y1 != v26 || v22 != v25) && !Clear(v22, y1)) /* check args */ + goto LABEL_29; + } + } else { + if (v6 < 0) { + v8 = v29; + v29 = x2; + x2 = v8; + v9 = y1; + v6 = -v6; + y1 = y2; + y2 = v9; + v5 = -v5; + } + v10 = 2 * v5; + v27 = 2 * v5; + if (v5 <= 0) { + v11 = v10 + v6; + v12 = 2 * (v6 + v5); + v13 = -1; + } else { + v11 = v10 - v6; + v12 = 2 * (v5 - v6); + v13 = 1; + } + do { + v14 = y1; + if (v29 == x2 && y1 == y2) + break; + if (v11 <= 0 == v13 < 0) { + v11 += v12; + v14 = v13 + y1; + y1 += v13; + } else { + v11 += v27; + } + v15 = v29 + 1; + } while (++v29 == v25 && v14 == v26 || Clear(v15, v14)); + LABEL_29: + if (v29 != x2) + return 0; + } + if (y1 == y2) + return 1; + return 0; } BOOL __fastcall LineClear(int x1, int y1, int x2, int y2) { - return LineClearF(PosOkMissile, x1, y1, x2, y2); + return LineClearF(PosOkMissile, x1, y1, x2, y2); } BOOL __fastcall LineClearF1(BOOL(__fastcall *Clear)(int, int, int), int monst, int x1, int y1, int x2, int y2) { - int v6; // esi - int v7; // edi - int v8; // ebx - int v9; // eax - int v10; // eax - int v11; // eax - int v12; // ebx - int v13; // esi - signed int v14; // edi - int v15; // eax - int v16; // eax - int v17; // eax - int v18; // eax - int v19; // ebx - int v20; // edi - signed int v21; // esi - int v22; // edx - int v25; // [esp+10h] [ebp-10h] - int v26; // [esp+14h] [ebp-Ch] - int v27; // [esp+18h] [ebp-8h] - int v28; // [esp+1Ch] [ebp-4h] - int v29; // [esp+1Ch] [ebp-4h] + int v6; // esi + int v7; // edi + int v8; // ebx + int v9; // eax + int v10; // eax + int v11; // eax + int v12; // ebx + int v13; // esi + signed int v14; // edi + int v15; // eax + int v16; // eax + int v17; // eax + int v18; // eax + int v19; // ebx + int v20; // edi + signed int v21; // esi + int v22; // edx + int v25; // [esp+10h] [ebp-10h] + int v26; // [esp+14h] [ebp-Ch] + int v27; // [esp+18h] [ebp-8h] + int v28; // [esp+1Ch] [ebp-4h] + int v29; // [esp+1Ch] [ebp-4h] - v6 = y2 - y1; - v25 = monst; - v26 = x1; - v27 = y1; - v7 = x2 - x1; - v8 = abs(y2 - y1); - if (abs(x2 - x1) <= v8) { - if (v6 < 0) { - v16 = y1; - y1 = y2; - y2 = v16; - v17 = x1; - v6 = -v6; - x1 = x2; - x2 = v17; - v7 = -v7; - } - v18 = 2 * v7; - v29 = 2 * v7; - if (v7 <= 0) { - v19 = v18 + v6; - v20 = 2 * (v6 + v7); - v21 = -1; - } else { - v19 = v18 - v6; - v20 = 2 * (v7 - v6); - v21 = 1; - } - while (1) { - v22 = x1; - if (y1 == y2 && x1 == x2) - break; - if (v19 <= 0 == v21 < 0) { - v19 += v20; - v22 = v21 + x1; - x1 += v21; - } else { - v19 += v29; - } - if ((++y1 != v27 || v22 != v26) && !Clear(v25, v22, y1)) - goto LABEL_29; - } - } else { - if (v7 < 0) { - v9 = x1; - x1 = x2; - x2 = v9; - v10 = y1; - v7 = -v7; - y1 = y2; - y2 = v10; - v6 = -v6; - } - v11 = 2 * v6; - v28 = 2 * v6; - if (v6 <= 0) { - v12 = v11 + v7; - v13 = 2 * (v7 + v6); - v14 = -1; - } else { - v12 = v11 - v7; - v13 = 2 * (v6 - v7); - v14 = 1; - } - do { - v15 = y1; - if (x1 == x2 && y1 == y2) - break; - if (v12 <= 0 == v14 < 0) { - v12 += v13; - v15 = v14 + y1; - y1 += v14; - } else { - v12 += v28; - } - } while (++x1 == v26 && v15 == v27 || Clear(v25, x1, v15)); /* check args */ - LABEL_29: - if (x1 != x2) - return 0; - } - if (y1 == y2) - return 1; - return 0; + v6 = y2 - y1; + v25 = monst; + v26 = x1; + v27 = y1; + v7 = x2 - x1; + v8 = abs(y2 - y1); + if (abs(x2 - x1) <= v8) { + if (v6 < 0) { + v16 = y1; + y1 = y2; + y2 = v16; + v17 = x1; + v6 = -v6; + x1 = x2; + x2 = v17; + v7 = -v7; + } + v18 = 2 * v7; + v29 = 2 * v7; + if (v7 <= 0) { + v19 = v18 + v6; + v20 = 2 * (v6 + v7); + v21 = -1; + } else { + v19 = v18 - v6; + v20 = 2 * (v7 - v6); + v21 = 1; + } + while (1) { + v22 = x1; + if (y1 == y2 && x1 == x2) + break; + if (v19 <= 0 == v21 < 0) { + v19 += v20; + v22 = v21 + x1; + x1 += v21; + } else { + v19 += v29; + } + if ((++y1 != v27 || v22 != v26) && !Clear(v25, v22, y1)) + goto LABEL_29; + } + } else { + if (v7 < 0) { + v9 = x1; + x1 = x2; + x2 = v9; + v10 = y1; + v7 = -v7; + y1 = y2; + y2 = v10; + v6 = -v6; + } + v11 = 2 * v6; + v28 = 2 * v6; + if (v6 <= 0) { + v12 = v11 + v7; + v13 = 2 * (v7 + v6); + v14 = -1; + } else { + v12 = v11 - v7; + v13 = 2 * (v6 - v7); + v14 = 1; + } + do { + v15 = y1; + if (x1 == x2 && y1 == y2) + break; + if (v12 <= 0 == v14 < 0) { + v12 += v13; + v15 = v14 + y1; + y1 += v14; + } else { + v12 += v28; + } + } while (++x1 == v26 && v15 == v27 || Clear(v25, x1, v15)); /* check args */ + LABEL_29: + if (x1 != x2) + return 0; + } + if (y1 == y2) + return 1; + return 0; } void __fastcall SyncMonsterAnim(int i) { - int v1; // esi - int v2; // eax - int v3; // edx - MonsterData *v4; // esi - CMonster *v5; // ecx - unsigned char v6; // dl - char *v7; // edx - int v8; // esi - int v9; // edx - unsigned char *v10; // ecx - unsigned char *v11; // edx - int v12; // ecx - unsigned char *v13; // edx + int v1; // esi + int v2; // eax + int v3; // edx + MonsterData *v4; // esi + CMonster *v5; // ecx + unsigned char v6; // dl + char *v7; // edx + int v8; // esi + int v9; // edx + unsigned char *v10; // ecx + unsigned char *v11; // edx + int v12; // ecx + unsigned char *v13; // edx - v1 = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("SyncMonsterAnim: Invalid monster %d", i); - v2 = v1; - v3 = monster[v1]._mMTidx; - v4 = Monsters[v3].MData; - v5 = &Monsters[v3]; - v6 = monster[v2]._uniqtype; - monster[v2].MType = v5; - monster[v2].MData = v4; - if (v6 != 0) - v7 = UniqMonst[v6 - 1].mName; - else - v7 = v4->mName; - v8 = monster[v2]._mmode; - monster[v2].mName = v7; - v9 = monster[v2]._mdir; - switch (v8) { - case MM_STAND: - case MM_DELAY: - case MM_TALK: - v10 = v5->Anims[MA_STAND].Data[v9]; - goto LABEL_13; - case MM_WALK: - case MM_WALK2: - case MM_WALK3: - v10 = v5->Anims[MA_WALK].Data[v9]; - goto LABEL_13; - case MM_ATTACK: - case MM_RATTACK: - v10 = v5->Anims[MA_ATTACK].Data[v9]; - goto LABEL_13; - case MM_GOTHIT: - v10 = v5->Anims[MA_GOTHIT].Data[v9]; - goto LABEL_13; - case MM_DEATH: - v10 = v5->Anims[MA_DEATH].Data[v9]; - goto LABEL_13; - case MM_SATTACK: - case MM_FADEIN: - case MM_FADEOUT: - case MM_SPSTAND: - case MM_RSPATTACK: - case MM_HEAL: - v10 = v5->Anims[MA_SPECIAL].Data[v9]; - LABEL_13: - monster[v2]._mAnimData = v10; - return; - case MM_CHARGE: - v11 = v5->Anims[MA_ATTACK].Data[v9]; - monster[v2]._mAnimFrame = 1; - monster[v2]._mAnimData = v11; - v12 = v5->Anims[MA_ATTACK].Frames; - break; - default: - v13 = v5->Anims[MA_STAND].Data[v9]; - monster[v2]._mAnimFrame = 1; - monster[v2]._mAnimData = v13; - v12 = v5->Anims[MA_STAND].Frames; - break; - } - monster[v2]._mAnimLen = v12; + v1 = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("SyncMonsterAnim: Invalid monster %d", i); + v2 = v1; + v3 = monster[v1]._mMTidx; + v4 = Monsters[v3].MData; + v5 = &Monsters[v3]; + v6 = monster[v2]._uniqtype; + monster[v2].MType = v5; + monster[v2].MData = v4; + if (v6 != 0) + v7 = UniqMonst[v6 - 1].mName; + else + v7 = v4->mName; + v8 = monster[v2]._mmode; + monster[v2].mName = v7; + v9 = monster[v2]._mdir; + switch (v8) { + case MM_STAND: + case MM_DELAY: + case MM_TALK: + v10 = v5->Anims[MA_STAND].Data[v9]; + goto LABEL_13; + case MM_WALK: + case MM_WALK2: + case MM_WALK3: + v10 = v5->Anims[MA_WALK].Data[v9]; + goto LABEL_13; + case MM_ATTACK: + case MM_RATTACK: + v10 = v5->Anims[MA_ATTACK].Data[v9]; + goto LABEL_13; + case MM_GOTHIT: + v10 = v5->Anims[MA_GOTHIT].Data[v9]; + goto LABEL_13; + case MM_DEATH: + v10 = v5->Anims[MA_DEATH].Data[v9]; + goto LABEL_13; + case MM_SATTACK: + case MM_FADEIN: + case MM_FADEOUT: + case MM_SPSTAND: + case MM_RSPATTACK: + case MM_HEAL: + v10 = v5->Anims[MA_SPECIAL].Data[v9]; + LABEL_13: + monster[v2]._mAnimData = v10; + return; + case MM_CHARGE: + v11 = v5->Anims[MA_ATTACK].Data[v9]; + monster[v2]._mAnimFrame = 1; + monster[v2]._mAnimData = v11; + v12 = v5->Anims[MA_ATTACK].Frames; + break; + default: + v13 = v5->Anims[MA_STAND].Data[v9]; + monster[v2]._mAnimFrame = 1; + monster[v2]._mAnimData = v13; + v12 = v5->Anims[MA_STAND].Frames; + break; + } + monster[v2]._mAnimLen = v12; } void __fastcall M_FallenFear(int x, int y) { - int v2; // eax - int *v3; // ebx - int v4; // edi - int v5; // esi - signed int v6; // eax - int v7; // eax - bool v8; // zf - int v9; // eax - int v10; // eax - signed int v11; // [esp-10h] [ebp-1Ch] - int v12; // [esp+0h] [ebp-Ch] - int x1; // [esp+4h] [ebp-8h] - int y1; // [esp+8h] [ebp-4h] + int v2; // eax + int *v3; // ebx + int v4; // edi + int v5; // esi + signed int v6; // eax + int v7; // eax + bool v8; // zf + int v9; // eax + int v10; // eax + signed int v11; // [esp-10h] [ebp-1Ch] + int v12; // [esp+0h] [ebp-Ch] + int x1; // [esp+4h] [ebp-8h] + int y1; // [esp+8h] [ebp-4h] - v2 = 0; - y1 = y; - x1 = x; - v12 = 0; - if (nummonsters > 0) { - v3 = &monster[0]._mx; - do { - v4 = 0; - v5 = monstactive[v2]; - v6 = monster[v5].MType->mtype; - if (v6 > MT_RFALLSD) { - v9 = v6 - 13; - v8 = v9 == 0; - } else { - if (v6 == MT_RFALLSD || (v7 = v6 - 4) == 0) { - v11 = 7; - goto LABEL_15; - } - v9 = v7 - 1; - v8 = v9 == 0; - } - if (v8) { - v11 = 5; - } else { - v10 = v9 - 1; - if (v10) { - if (v10 != 1) - goto LABEL_16; - v11 = 2; - } else { - v11 = 3; - } - } - LABEL_15: - v4 = v11; - LABEL_16: - if (monster[v5]._mAi == AI_FALLEN - && v4 - && abs(x1 - monster[v5]._mx) < 5 - && abs(y1 - monster[v5]._my) < 5 - && monster[v5]._mhitpoints >> 6 > 0) { - _LOBYTE(monster[v5]._mgoal) = 2; - monster[v5]._mgoalvar1 = v4; - monster[v5]._mdir = GetDirection(x1, y1, *v3, v3[1]); - } - v3 += 57; - v2 = v12++ + 1; - } while (v12 < nummonsters); - } + v2 = 0; + y1 = y; + x1 = x; + v12 = 0; + if (nummonsters > 0) { + v3 = &monster[0]._mx; + do { + v4 = 0; + v5 = monstactive[v2]; + v6 = monster[v5].MType->mtype; + if (v6 > MT_RFALLSD) { + v9 = v6 - 13; + v8 = v9 == 0; + } else { + if (v6 == MT_RFALLSD || (v7 = v6 - 4) == 0) { + v11 = 7; + goto LABEL_15; + } + v9 = v7 - 1; + v8 = v9 == 0; + } + if (v8) { + v11 = 5; + } else { + v10 = v9 - 1; + if (v10) { + if (v10 != 1) + goto LABEL_16; + v11 = 2; + } else { + v11 = 3; + } + } + LABEL_15: + v4 = v11; + LABEL_16: + if (monster[v5]._mAi == AI_FALLEN + && v4 + && abs(x1 - monster[v5]._mx) < 5 + && abs(y1 - monster[v5]._my) < 5 + && monster[v5]._mhitpoints >> 6 > 0) { + _LOBYTE(monster[v5]._mgoal) = 2; + monster[v5]._mgoalvar1 = v4; + monster[v5]._mdir = GetDirection(x1, y1, *v3, v3[1]); + } + v3 += 57; + v2 = v12++ + 1; + } while (v12 < nummonsters); + } } void __fastcall PrintMonstHistory(int mt) { - int v1; // edi - int *v2; // ebx - int v3; // ecx - int v4; // eax - int v5; // edi - short v6; // bx - int v7; // ebx + int v1; // edi + int *v2; // ebx + int v3; // ecx + int v4; // eax + int v5; // edi + short v6; // bx + int v7; // ebx - v1 = mt; - v2 = &monstkills[mt]; - sprintf(tempstr, "Total kills : %i", *v2); - AddPanelString(tempstr, 1); - if (*v2 >= 30) { - v3 = monsterdata[v1].mMinHP; - v4 = monsterdata[v1].mMaxHP; - if (gbMaxPlayers == 1) { - v3 = monsterdata[v1].mMinHP >> 1; - v4 = monsterdata[v1].mMaxHP >> 1; - } - if (v3 < 1) - v3 = 1; - if (v4 < 1) - v4 = 1; - if (gnDifficulty == DIFF_NIGHTMARE) { - v3 = 3 * v3 + 1; - v4 = 3 * v4 + 1; - } - if (gnDifficulty == DIFF_HELL) { - v3 = 4 * v3 + 3; - v4 = 4 * v4 + 3; - } - sprintf(tempstr, "Hit Points : %i-%i", v3, v4); - AddPanelString(tempstr, 1); - } - if (*v2 >= 15) { - v5 = v1 << 7; - if (gnDifficulty == DIFF_HELL) - v6 = *(short *)((char *)&monsterdata[0].mMagicRes2 + v5); - else - v6 = *(short *)((char *)&monsterdata[0].mMagicRes + v5); - v7 = v6 & 0x3F; - if (v7) { - if (v7 & 7) { - strcpy(tempstr, "Resists : "); - if (v7 & 1) - strcat(tempstr, "Magic "); - if (v7 & 2) - strcat(tempstr, "Fire "); - if (v7 & 4) - strcat(tempstr, "Lightning "); - tempstr[strlen(tempstr) - 1] = '\0'; - AddPanelString(tempstr, 1); - } - if (v7 & 0x38) { - strcpy(tempstr, "Immune : "); - if (v7 & 8) - strcat(tempstr, "Magic "); - if (v7 & 0x10) - strcat(tempstr, "Fire "); - if (v7 & 0x20) - strcat(tempstr, "Lightning "); - tempstr[strlen(tempstr) - 1] = '\0'; - AddPanelString(tempstr, 1); - } - } else { - strcpy(tempstr, "No magic resistance"); - AddPanelString(tempstr, 1); - } - } - pinfoflag = 1; + v1 = mt; + v2 = &monstkills[mt]; + sprintf(tempstr, "Total kills : %i", *v2); + AddPanelString(tempstr, 1); + if (*v2 >= 30) { + v3 = monsterdata[v1].mMinHP; + v4 = monsterdata[v1].mMaxHP; + if (gbMaxPlayers == 1) { + v3 = monsterdata[v1].mMinHP >> 1; + v4 = monsterdata[v1].mMaxHP >> 1; + } + if (v3 < 1) + v3 = 1; + if (v4 < 1) + v4 = 1; + if (gnDifficulty == DIFF_NIGHTMARE) { + v3 = 3 * v3 + 1; + v4 = 3 * v4 + 1; + } + if (gnDifficulty == DIFF_HELL) { + v3 = 4 * v3 + 3; + v4 = 4 * v4 + 3; + } + sprintf(tempstr, "Hit Points : %i-%i", v3, v4); + AddPanelString(tempstr, 1); + } + if (*v2 >= 15) { + v5 = v1 << 7; + if (gnDifficulty == DIFF_HELL) + v6 = *(short *)((char *)&monsterdata[0].mMagicRes2 + v5); + else + v6 = *(short *)((char *)&monsterdata[0].mMagicRes + v5); + v7 = v6 & 0x3F; + if (v7) { + if (v7 & 7) { + strcpy(tempstr, "Resists : "); + if (v7 & 1) + strcat(tempstr, "Magic "); + if (v7 & 2) + strcat(tempstr, "Fire "); + if (v7 & 4) + strcat(tempstr, "Lightning "); + tempstr[strlen(tempstr) - 1] = '\0'; + AddPanelString(tempstr, 1); + } + if (v7 & 0x38) { + strcpy(tempstr, "Immune : "); + if (v7 & 8) + strcat(tempstr, "Magic "); + if (v7 & 0x10) + strcat(tempstr, "Fire "); + if (v7 & 0x20) + strcat(tempstr, "Lightning "); + tempstr[strlen(tempstr) - 1] = '\0'; + AddPanelString(tempstr, 1); + } + } else { + strcpy(tempstr, "No magic resistance"); + AddPanelString(tempstr, 1); + } + } + pinfoflag = 1; } // 4B8824: using guessed type int pinfoflag; // 679660: using guessed type char gbMaxPlayers; void __cdecl PrintUniqueHistory() { - char v0; // bl + char v0; // bl - v0 = monster[pcursmonst].mMagicRes & 0x3F; - if (v0) { - if (monster[pcursmonst].mMagicRes & 7) - strcpy(tempstr, "Some Magic Resistances"); - else - strcpy(tempstr, "No resistances"); - AddPanelString(tempstr, 1); - if (v0 & 0x38) { - strcpy(tempstr, "Some Magic Immunities"); - goto LABEL_4; - } - } else { - strcpy(tempstr, "No resistances"); - AddPanelString(tempstr, 1); - } - strcpy(tempstr, "No Immunities"); + v0 = monster[pcursmonst].mMagicRes & 0x3F; + if (v0) { + if (monster[pcursmonst].mMagicRes & 7) + strcpy(tempstr, "Some Magic Resistances"); + else + strcpy(tempstr, "No resistances"); + AddPanelString(tempstr, 1); + if (v0 & 0x38) { + strcpy(tempstr, "Some Magic Immunities"); + goto LABEL_4; + } + } else { + strcpy(tempstr, "No resistances"); + AddPanelString(tempstr, 1); + } + strcpy(tempstr, "No Immunities"); LABEL_4: - AddPanelString(tempstr, 1); - pinfoflag = 1; + AddPanelString(tempstr, 1); + pinfoflag = 1; } // 4B8824: using guessed type int pinfoflag; void __fastcall MissToMonst(int i, int x, int y) { - int v3; // edi - MissileStruct *v4; // edi - unsigned int v5; // ebx - MonsterStruct *v6; // esi - int v7; // edx - char v8; // al - int v9; // eax - char *v10; // edi - int v11; // eax - int v12; // edx - char v13; // al - char v14; // al - int v15; // ebx - int v16; // eax - int v17; // esi - int v18; // edi - int v19; // esi - int v20; // edx - int *v21; // ebx - char v22; // cl - char v23; // al - int v24; // esi - int v25; // edi - int v26; // esi - int v27; // eax - int v28; // eax - int ia; // [esp+Ch] [ebp-10h] - int v30; // [esp+10h] [ebp-Ch] - int v31; // [esp+14h] [ebp-8h] - int v32; // [esp+18h] [ebp-4h] - int arglist; // [esp+24h] [ebp+8h] + int v3; // edi + MissileStruct *v4; // edi + unsigned int v5; // ebx + MonsterStruct *v6; // esi + int v7; // edx + char v8; // al + int v9; // eax + char *v10; // edi + int v11; // eax + int v12; // edx + char v13; // al + char v14; // al + int v15; // ebx + int v16; // eax + int v17; // esi + int v18; // edi + int v19; // esi + int v20; // edx + int *v21; // ebx + char v22; // cl + char v23; // al + int v24; // esi + int v25; // edi + int v26; // esi + int v27; // eax + int v28; // eax + int ia; // [esp+Ch] [ebp-10h] + int v30; // [esp+10h] [ebp-Ch] + int v31; // [esp+14h] [ebp-8h] + int v32; // [esp+18h] [ebp-4h] + int arglist; // [esp+24h] [ebp+8h] - v3 = i; - v30 = x; - if ((DWORD)i >= MAXMISSILES) - TermMsg("MissToMonst: Invalid missile %d", i); - v4 = &missile[v3]; - v5 = v4->_misource; - ia = v4->_misource; - if (v5 >= MAXMONSTERS) - TermMsg("MissToMonst: Invalid monster %d", v5); - v32 = v4->_mix; - v31 = v4->_miy; - v6 = &monster[v5]; - v6->_mx = v30; - dMonster[0][y + 112 * v30] = v5 + 1; - v7 = v4->_mimfnum; - v6->_mdir = v7; - v6->_my = y; - M_StartStand(v5, v7); - v8 = v6->MType->mtype; - if (v8 < MT_INCIN || v8 > MT_HELLBURN) { - if (v6->_mFlags & 0x10) - M2MStartHit(v5, -1, 0); - else - M_StartHit(v5, -1, 0); - } else { - M_StartFadein(v5, v6->_mdir, FALSE); - } - v9 = v32; - if (v6->_mFlags & 0x10) { - v21 = (int *)((char *)dMonster + 4 * (v31 + v9 * 112)); - if (*v21 > 0) { - v22 = v6->MType->mtype; - if (v22 != MT_GLOOM && (v22 < MT_INCIN || v22 > MT_HELLBURN)) { - M_TryM2MHit(ia, *v21 - 1, 500, (unsigned char)v6->mMinDamage2, (unsigned char)v6->mMaxDamage2); - v23 = v6->MType->mtype; - if (v23 < MT_NSNAKE || v23 > MT_GSNAKE) { - v24 = v6->_mdir; - v25 = v32 + offset_x[v24]; - v26 = v31 + offset_y[v24]; - if (PosOkMonst(*v21 - 1, v25, v26)) { - v27 = *v21; - dMonster[0][v26 + 112 * v25] = *v21; - *v21 = 0; - v28 = v27 - 1; - monster[v28]._mx = v25; - monster[v28]._mfutx = v25; - monster[v28]._my = v26; - monster[v28]._mfuty = v26; - } - } - } - } - } else { - v10 = &dPlayer[v9][v31]; - v11 = *v10; - v12 = v11 - 1; - arglist = v11 - 1; - if (*v10 > 0) { - v13 = v6->MType->mtype; - if (v13 != MT_GLOOM && (v13 < MT_INCIN || v13 > MT_HELLBURN)) { - M_TryH2HHit(v5, v12, 500, (unsigned char)v6->mMinDamage2, (unsigned char)v6->mMaxDamage2); - if (arglist == *v10 - 1) { - v14 = v6->MType->mtype; - if (v14 < MT_NSNAKE || v14 > MT_GSNAKE) { - v15 = arglist; - v16 = plr[arglist]._pmode; - if (v16 != 7 && v16 != 8) - StartPlrHit(arglist, 0, 1u); - v17 = v6->_mdir; - v18 = v32 + offset_x[v17]; - v19 = v31 + offset_y[v17]; - if (PosOkPlayer(arglist, v18, v19)) { - v20 = plr[v15]._pdir; - plr[v15].WorldX = v18; - plr[v15].WorldY = v19; - FixPlayerLocation(arglist, v20); - FixPlrWalkTags(arglist); - dPlayer[v18][v19] = arglist + 1; - SetPlayerOld(arglist); - } - } - } - } - } - } + v3 = i; + v30 = x; + if ((DWORD)i >= MAXMISSILES) + TermMsg("MissToMonst: Invalid missile %d", i); + v4 = &missile[v3]; + v5 = v4->_misource; + ia = v4->_misource; + if (v5 >= MAXMONSTERS) + TermMsg("MissToMonst: Invalid monster %d", v5); + v32 = v4->_mix; + v31 = v4->_miy; + v6 = &monster[v5]; + v6->_mx = v30; + dMonster[0][y + 112 * v30] = v5 + 1; + v7 = v4->_mimfnum; + v6->_mdir = v7; + v6->_my = y; + M_StartStand(v5, v7); + v8 = v6->MType->mtype; + if (v8 < MT_INCIN || v8 > MT_HELLBURN) { + if (v6->_mFlags & 0x10) + M2MStartHit(v5, -1, 0); + else + M_StartHit(v5, -1, 0); + } else { + M_StartFadein(v5, v6->_mdir, FALSE); + } + v9 = v32; + if (v6->_mFlags & 0x10) { + v21 = (int *)((char *)dMonster + 4 * (v31 + v9 * 112)); + if (*v21 > 0) { + v22 = v6->MType->mtype; + if (v22 != MT_GLOOM && (v22 < MT_INCIN || v22 > MT_HELLBURN)) { + M_TryM2MHit(ia, *v21 - 1, 500, (unsigned char)v6->mMinDamage2, (unsigned char)v6->mMaxDamage2); + v23 = v6->MType->mtype; + if (v23 < MT_NSNAKE || v23 > MT_GSNAKE) { + v24 = v6->_mdir; + v25 = v32 + offset_x[v24]; + v26 = v31 + offset_y[v24]; + if (PosOkMonst(*v21 - 1, v25, v26)) { + v27 = *v21; + dMonster[0][v26 + 112 * v25] = *v21; + *v21 = 0; + v28 = v27 - 1; + monster[v28]._mx = v25; + monster[v28]._mfutx = v25; + monster[v28]._my = v26; + monster[v28]._mfuty = v26; + } + } + } + } + } else { + v10 = &dPlayer[v9][v31]; + v11 = *v10; + v12 = v11 - 1; + arglist = v11 - 1; + if (*v10 > 0) { + v13 = v6->MType->mtype; + if (v13 != MT_GLOOM && (v13 < MT_INCIN || v13 > MT_HELLBURN)) { + M_TryH2HHit(v5, v12, 500, (unsigned char)v6->mMinDamage2, (unsigned char)v6->mMaxDamage2); + if (arglist == *v10 - 1) { + v14 = v6->MType->mtype; + if (v14 < MT_NSNAKE || v14 > MT_GSNAKE) { + v15 = arglist; + v16 = plr[arglist]._pmode; + if (v16 != 7 && v16 != 8) + StartPlrHit(arglist, 0, 1u); + v17 = v6->_mdir; + v18 = v32 + offset_x[v17]; + v19 = v31 + offset_y[v17]; + if (PosOkPlayer(arglist, v18, v19)) { + v20 = plr[v15]._pdir; + plr[v15].WorldX = v18; + plr[v15].WorldY = v19; + FixPlayerLocation(arglist, v20); + FixPlrWalkTags(arglist); + dPlayer[v18][v19] = arglist + 1; + SetPlayerOld(arglist); + } + } + } + } + } + } } BOOL __fastcall PosOkMonst(int i, int x, int y) { - int v3; // edi - signed int v4; // ebx - int v5; // ecx - char v6; // dl - bool result; // eax - int v8; // edx - int v9; // ecx - int v10; // [esp+Ch] [ebp-4h] + int v3; // edi + signed int v4; // ebx + int v5; // ecx + char v6; // dl + bool result; // eax + int v8; // edx + int v9; // ecx + int v10; // [esp+Ch] [ebp-4h] - v3 = x; - v10 = i; - v4 = 0; - if (SolidLoc(x, y)) - return 0; - v5 = 112 * v3; - if (dPlayer[v3][y] || dMonster[0][v5 + y]) - return 0; - v6 = dObject[0][v5 + y]; - result = 1; - if (v6) { - v8 = v6 <= 0 ? -1 - v6 : v6 - 1; - if (object[v8]._oSolidFlag) - return 0; - } - _LOBYTE(v5) = dMissile[0][v5 + y]; - if ((_BYTE)v5) { - if (v10 >= 0) { - v5 = (char)v5; - if ((char)v5 > 0) { - if (missile[v5]._mitype == 5) - goto LABEL_24; - v9 = 0; - if (nummissiles > 0) { - do { - if (missile[missileactive[v9]]._mitype == 5) - v4 = 1; - ++v9; - } while (v9 < nummissiles); - if (v4) { - LABEL_24: - if (!(monster[v10].mMagicRes & 0x10) || monster[v10].MType->mtype == MT_DIABLO) - return 0; - } - } - } - } - } - return result; + v3 = x; + v10 = i; + v4 = 0; + if (SolidLoc(x, y)) + return 0; + v5 = 112 * v3; + if (dPlayer[v3][y] || dMonster[0][v5 + y]) + return 0; + v6 = dObject[0][v5 + y]; + result = 1; + if (v6) { + v8 = v6 <= 0 ? -1 - v6 : v6 - 1; + if (object[v8]._oSolidFlag) + return 0; + } + _LOBYTE(v5) = dMissile[0][v5 + y]; + if ((_BYTE)v5) { + if (v10 >= 0) { + v5 = (char)v5; + if ((char)v5 > 0) { + if (missile[v5]._mitype == 5) + goto LABEL_24; + v9 = 0; + if (nummissiles > 0) { + do { + if (missile[missileactive[v9]]._mitype == 5) + v4 = 1; + ++v9; + } while (v9 < nummissiles); + if (v4) { + LABEL_24: + if (!(monster[v10].mMagicRes & 0x10) || monster[v10].MType->mtype == MT_DIABLO) + return 0; + } + } + } + } + } + return result; } BOOL __fastcall PosOkMonst2(int i, int x, int y) { - int v3; // edi - int v4; // ebx - signed int v5; // ebp - bool result; // eax - char v7; // dl - int v8; // edx - int v9; // ecx - int v10; // ecx + int v3; // edi + int v4; // ebx + signed int v5; // ebp + bool result; // eax + char v7; // dl + int v8; // edx + int v9; // ecx + int v10; // ecx - v3 = x; - v4 = i; - v5 = 0; - result = SolidLoc(x, y) == 0; - if (result) { - v7 = dObject[v3][y]; - if (v7) { - v8 = v7 <= 0 ? -1 - v7 : v7 - 1; - if (object[v8]._oSolidFlag) - result = 0; - } - if (result) { - _LOBYTE(v9) = dMissile[v3][y]; - if ((_BYTE)v9) { - if (v4 >= 0) { - v9 = (char)v9; - if ((char)v9 > 0) { - if (missile[v9]._mitype == 5) - goto LABEL_23; - v10 = 0; - if (nummissiles > 0) { - do { - if (missile[missileactive[v10]]._mitype == 5) - v5 = 1; - ++v10; - } while (v10 < nummissiles); - if (v5) { - LABEL_23: - if (!(monster[v4].mMagicRes & 0x10) || monster[v4].MType->mtype == MT_DIABLO) - result = 0; - } - } - } - } - } - } - } - return result; + v3 = x; + v4 = i; + v5 = 0; + result = SolidLoc(x, y) == 0; + if (result) { + v7 = dObject[v3][y]; + if (v7) { + v8 = v7 <= 0 ? -1 - v7 : v7 - 1; + if (object[v8]._oSolidFlag) + result = 0; + } + if (result) { + _LOBYTE(v9) = dMissile[v3][y]; + if ((_BYTE)v9) { + if (v4 >= 0) { + v9 = (char)v9; + if ((char)v9 > 0) { + if (missile[v9]._mitype == 5) + goto LABEL_23; + v10 = 0; + if (nummissiles > 0) { + do { + if (missile[missileactive[v10]]._mitype == 5) + v5 = 1; + ++v10; + } while (v10 < nummissiles); + if (v5) { + LABEL_23: + if (!(monster[v4].mMagicRes & 0x10) || monster[v4].MType->mtype == MT_DIABLO) + result = 0; + } + } + } + } + } + } + } + return result; } BOOL __fastcall PosOkMonst3(int i, int x, int y) { - int v3; // esi - signed int v4; // ebp - char v5; // al - int v6; // eax - int v7; // eax - int v8; // ecx - int v9; // ecx - bool result; // eax - int v11; // ecx - signed int v12; // [esp+10h] [ebp-8h] - int v13; // [esp+14h] [ebp-4h] + int v3; // esi + signed int v4; // ebp + char v5; // al + int v6; // eax + int v7; // eax + int v8; // ecx + int v9; // ecx + bool result; // eax + int v11; // ecx + signed int v12; // [esp+10h] [ebp-8h] + int v13; // [esp+14h] [ebp-4h] - v12 = 0; - v3 = x; - v4 = 0; - v13 = i; - v5 = dObject[x][y]; - if (v5) { - if (v5 <= 0) - v6 = -1 - v5; - else - v6 = v5 - 1; - v7 = v6; - v8 = object[v7]._otype; - v4 = 1; - if (v8 != 1 - && v8 != OBJ_L1RDOOR - && v8 != OBJ_L2LDOOR - && v8 != OBJ_L2RDOOR - && v8 != OBJ_L3LDOOR - && v8 != OBJ_L3RDOOR) { - v4 = 0; - } - if (object[v7]._oSolidFlag && !v4) - return 0; - } - if (SolidLoc(x, y) && !v4 || dPlayer[v3][y] || dMonster[0][v3 * 112 + y]) - return 0; - _LOBYTE(v9) = dMissile[v3][y]; - result = 1; - if ((_BYTE)v9) { - if (v13 >= 0) { - v9 = (char)v9; - if ((char)v9 > 0) { - if (missile[v9]._mitype == 5) - goto LABEL_33; - v11 = 0; - if (nummissiles > 0) { - do { - if (missile[missileactive[v11]]._mitype == 5) - v12 = 1; - ++v11; - } while (v11 < nummissiles); - if (v12) { - LABEL_33: - if (!(monster[v13].mMagicRes & 0x10) || monster[v13].MType->mtype == MT_DIABLO) - return 0; - } - } - } - } - } - return result; + v12 = 0; + v3 = x; + v4 = 0; + v13 = i; + v5 = dObject[x][y]; + if (v5) { + if (v5 <= 0) + v6 = -1 - v5; + else + v6 = v5 - 1; + v7 = v6; + v8 = object[v7]._otype; + v4 = 1; + if (v8 != 1 + && v8 != OBJ_L1RDOOR + && v8 != OBJ_L2LDOOR + && v8 != OBJ_L2RDOOR + && v8 != OBJ_L3LDOOR + && v8 != OBJ_L3RDOOR) { + v4 = 0; + } + if (object[v7]._oSolidFlag && !v4) + return 0; + } + if (SolidLoc(x, y) && !v4 || dPlayer[v3][y] || dMonster[0][v3 * 112 + y]) + return 0; + _LOBYTE(v9) = dMissile[v3][y]; + result = 1; + if ((_BYTE)v9) { + if (v13 >= 0) { + v9 = (char)v9; + if ((char)v9 > 0) { + if (missile[v9]._mitype == 5) + goto LABEL_33; + v11 = 0; + if (nummissiles > 0) { + do { + if (missile[missileactive[v11]]._mitype == 5) + v12 = 1; + ++v11; + } while (v11 < nummissiles); + if (v12) { + LABEL_33: + if (!(monster[v13].mMagicRes & 0x10) || monster[v13].MType->mtype == MT_DIABLO) + return 0; + } + } + } + } + } + return result; } BOOL __fastcall IsSkel(int mt) { - return mt >= MT_WSKELAX && mt <= MT_XSKELAX - || mt >= MT_WSKELBW && mt <= MT_XSKELBW - || mt >= MT_WSKELSD && mt <= MT_XSKELSD; + return mt >= MT_WSKELAX && mt <= MT_XSKELAX + || mt >= MT_WSKELBW && mt <= MT_XSKELBW + || mt >= MT_WSKELSD && mt <= MT_XSKELSD; } bool __fastcall IsGoat(int mt) { - return mt >= MT_NGOATMC && mt <= MT_GGOATMC || mt >= MT_NGOATBW && mt <= MT_GGOATBW; + return mt >= MT_NGOATMC && mt <= MT_GGOATMC || mt >= MT_NGOATBW && mt <= MT_GGOATBW; } int __fastcall M_SpawnSkel(int x, int y, int dir) { - CMonster *v3; // ebx - CMonster *v4; // esi - int v5; // edx - int v7; // esi - //int v8; // edx - int v9; // eax - int v10; // esi - int xa; // [esp+Ch] [ebp-10h] - int ya; // [esp+10h] [ebp-Ch] - int v14; // [esp+14h] [ebp-8h] - int v15; // [esp+18h] [ebp-4h] - int v16; // [esp+18h] [ebp-4h] + CMonster *v3; // ebx + CMonster *v4; // esi + int v5; // edx + int v7; // esi + //int v8; // edx + int v9; // eax + int v10; // esi + int xa; // [esp+Ch] [ebp-10h] + int ya; // [esp+10h] [ebp-Ch] + int v14; // [esp+14h] [ebp-8h] + int v15; // [esp+18h] [ebp-4h] + int v16; // [esp+18h] [ebp-4h] - ya = y; - xa = x; - v5 = 0; - if (nummtypes <= 0) - return -1; - v3 = Monsters; - v15 = nummtypes; - v4 = Monsters; - do { - if (IsSkel((unsigned char)v4->mtype)) - ++v5; - ++v4; - --v15; - } while (v15); - if (!v5) - return -1; - v7 = 0; - v14 = random(136, v5); - v16 = 0; - if (nummtypes > 0) { - do { - if (v16 > v14) - break; - if (IsSkel((unsigned char)v3->mtype)) - ++v16; - ++v7; - ++v3; - } while (v7 < nummtypes); /* v8 */ - } - v9 = AddMonster(xa, ya, dir, v7 - 1, 1); - v10 = v9; - if (v9 != -1) - M_StartSpStand(v9, dir); - return v10; + ya = y; + xa = x; + v5 = 0; + if (nummtypes <= 0) + return -1; + v3 = Monsters; + v15 = nummtypes; + v4 = Monsters; + do { + if (IsSkel((unsigned char)v4->mtype)) + ++v5; + ++v4; + --v15; + } while (v15); + if (!v5) + return -1; + v7 = 0; + v14 = random(136, v5); + v16 = 0; + if (nummtypes > 0) { + do { + if (v16 > v14) + break; + if (IsSkel((unsigned char)v3->mtype)) + ++v16; + ++v7; + ++v3; + } while (v7 < nummtypes); /* v8 */ + } + v9 = AddMonster(xa, ya, dir, v7 - 1, 1); + v10 = v9; + if (v9 != -1) + M_StartSpStand(v9, dir); + return v10; } void __fastcall ActivateSpawn(int i, int x, int y, int dir) { - int v4; // eax + int v4; // eax - dMonster[0][y + 112 * x] = i + 1; - v4 = i; - monster[v4]._mx = x; - monster[v4]._mfutx = x; - monster[v4]._moldx = x; - monster[v4]._my = y; - monster[v4]._mfuty = y; - monster[v4]._moldy = y; - M_StartSpStand(i, dir); + dMonster[0][y + 112 * x] = i + 1; + v4 = i; + monster[v4]._mx = x; + monster[v4]._mfutx = x; + monster[v4]._moldx = x; + monster[v4]._my = y; + monster[v4]._mfuty = y; + monster[v4]._moldy = y; + M_StartSpStand(i, dir); } bool __fastcall SpawnSkeleton(int ii, int x, int y) { - int v3; // esi - int v4; // ebx - int v5; // ST04_4 - int v6; // ecx - int v7; // edi - int *v8; // esi - bool v9; // eax - int v11; // eax - int v12; // ecx - int v13; // edx - int v14; // esi - int v15; // edi - int v16; // ST04_4 - int monstok[9]; // [esp+Ch] [ebp-34h] - int i; // [esp+30h] [ebp-10h] - int x2; // [esp+34h] [ebp-Ch] - int v20; // [esp+38h] [ebp-8h] - int *v21; // [esp+3Ch] [ebp-4h] - int a3; // [esp+48h] [ebp+8h] - int a3a; // [esp+48h] [ebp+8h] + int v3; // esi + int v4; // ebx + int v5; // ST04_4 + int v6; // ecx + int v7; // edi + int *v8; // esi + bool v9; // eax + int v11; // eax + int v12; // ecx + int v13; // edx + int v14; // esi + int v15; // edi + int v16; // ST04_4 + int monstok[9]; // [esp+Ch] [ebp-34h] + int i; // [esp+30h] [ebp-10h] + int x2; // [esp+34h] [ebp-Ch] + int v20; // [esp+38h] [ebp-8h] + int *v21; // [esp+3Ch] [ebp-4h] + int a3; // [esp+48h] [ebp+8h] + int a3a; // [esp+48h] [ebp+8h] - i = ii; - v3 = x; - x2 = x; - if (ii == -1) - return 0; - v4 = y; - if (!PosOkMonst(-1, x, y)) { - v20 = 0; - v6 = y - 1; - a3 = y - 1; - if ((unsigned char)(__OFSUB__(v4 - 1, v4 + 1) ^ 1) | (v4 - 1 == v4 + 1)) { - v21 = monstok; - do { - v7 = v3 - 1; - if ((unsigned char)(__OFSUB__(v3 - 1, v3 + 1) ^ 1) | (v3 - 1 == v3 + 1)) { - v8 = v21; - do { - v9 = PosOkMonst(-1, v7, a3); - v20 |= v9; - *v8 = v9; - v8 += 3; - ++v7; - } while (v7 <= x2 + 1); - v3 = x2; - } - ++v21; - ++a3; - } while (a3 <= v4 + 1); - if (v20) { - v11 = random(137, 15); - v12 = 0; - v13 = 0; - a3a = v11 + 1; - if (v11 + 1 > 0) { - while (1) { - if (monstok[v13 + 2 * v12 + v12]) - --a3a; - if (a3a <= 0) - break; - if (++v12 == 3) { - v12 = 0; - if (++v13 == 3) - v13 = 0; - } - } - } - v14 = v12 + v3 - 1; - v15 = v13 + v4 - 1; - v16 = GetDirection(v14, v15, x2, v4); - ActivateSpawn(i, v14, v15, v16); - return 1; - } - } - return 0; - } - v5 = GetDirection(v3, y, v3, y); - ActivateSpawn(i, v3, y, v5); - return 1; + i = ii; + v3 = x; + x2 = x; + if (ii == -1) + return 0; + v4 = y; + if (!PosOkMonst(-1, x, y)) { + v20 = 0; + v6 = y - 1; + a3 = y - 1; + if ((unsigned char)(__OFSUB__(v4 - 1, v4 + 1) ^ 1) | (v4 - 1 == v4 + 1)) { + v21 = monstok; + do { + v7 = v3 - 1; + if ((unsigned char)(__OFSUB__(v3 - 1, v3 + 1) ^ 1) | (v3 - 1 == v3 + 1)) { + v8 = v21; + do { + v9 = PosOkMonst(-1, v7, a3); + v20 |= v9; + *v8 = v9; + v8 += 3; + ++v7; + } while (v7 <= x2 + 1); + v3 = x2; + } + ++v21; + ++a3; + } while (a3 <= v4 + 1); + if (v20) { + v11 = random(137, 15); + v12 = 0; + v13 = 0; + a3a = v11 + 1; + if (v11 + 1 > 0) { + while (1) { + if (monstok[v13 + 2 * v12 + v12]) + --a3a; + if (a3a <= 0) + break; + if (++v12 == 3) { + v12 = 0; + if (++v13 == 3) + v13 = 0; + } + } + } + v14 = v12 + v3 - 1; + v15 = v13 + v4 - 1; + v16 = GetDirection(v14, v15, x2, v4); + ActivateSpawn(i, v14, v15, v16); + return 1; + } + } + return 0; + } + v5 = GetDirection(v3, y, v3, y); + ActivateSpawn(i, v3, y, v5); + return 1; } // 43A879: using guessed type int var_34[9]; int __cdecl PreSpawnSkeleton() { - int skeltypes; // edx // should be i/j - int j; // edx // remove - int skel; // eax - int i; // [esp+10h] [ebp-4h] // should be skeltypes + int skeltypes; // edx // should be i/j + int j; // edx // remove + int skel; // eax + int i; // [esp+10h] [ebp-4h] // should be skeltypes - skeltypes = 0; + skeltypes = 0; - if (nummtypes <= 0) - return -1; + if (nummtypes <= 0) + return -1; - for (i = 0; i < nummtypes; i++) { - if (IsSkel(Monsters[i].mtype)) - ++skeltypes; - } + for (i = 0; i < nummtypes; i++) { + if (IsSkel(Monsters[i].mtype)) + ++skeltypes; + } - if (!skeltypes) - return -1; + if (!skeltypes) + return -1; - j = random(136, skeltypes); /* check this code -i integer is messed up*/ - skeltypes = 0; + j = random(136, skeltypes); /* check this code -i integer is messed up*/ + skeltypes = 0; - for (i = 0; i < nummtypes; ++i) { - if (skeltypes > j) - break; - if (IsSkel(Monsters[i].mtype)) - ++skeltypes; - } - skel = AddMonster(0, 0, 0, i - 1, 0); - if (skel != -1) - M_StartStand(skel, 0); - return skel; + for (i = 0; i < nummtypes; ++i) { + if (skeltypes > j) + break; + if (IsSkel(Monsters[i].mtype)) + ++skeltypes; + } + skel = AddMonster(0, 0, 0, i - 1, 0); + if (skel != -1) + M_StartStand(skel, 0); + return skel; } void __fastcall TalktoMonster(int i) { - int v1; // esi - MonsterStruct *v2; // esi - char v3; // al - int v4; // edi - //int v5; // eax - //int v6; // eax - int inv_item_num; // [esp+8h] [ebp-4h] + int v1; // esi + MonsterStruct *v2; // esi + char v3; // al + int v4; // edi + //int v5; // eax + //int v6; // eax + int inv_item_num; // [esp+8h] [ebp-4h] - v1 = i; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("TalktoMonster: Invalid monster %d", i); - v2 = &monster[v1]; - v3 = v2->_mAi; - v4 = v2->_menemy; - v2->_mmode = MM_TALK; - if (v3 == AI_SNOTSPIL || v3 == AI_LACHDAN) { - //_LOBYTE(v5) = QuestStatus(QTYPE_BOL); - if (QuestStatus(QTYPE_BOL) && quests[QTYPE_BOL]._qvar1 == 2 && PlrHasItem(v4, IDI_BANNER, &inv_item_num)) { - RemoveInvItem(v4, inv_item_num); - quests[QTYPE_BOL]._qactive = 3; - v2->mtalkmsg = QUEST_BANNER12; - _LOBYTE(v2->_mgoal) = 6; - } - //_LOBYTE(v6) = QuestStatus(QTYPE_VEIL); - if (QuestStatus(QTYPE_VEIL) && v2->mtalkmsg >= (signed int)QUEST_VEIL9) { - if (PlrHasItem(v4, IDI_GLDNELIX, &inv_item_num)) { - RemoveInvItem(v4, inv_item_num); - v2->mtalkmsg = QUEST_VEIL11; - _LOBYTE(v2->_mgoal) = 6; - } - } - } + v1 = i; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("TalktoMonster: Invalid monster %d", i); + v2 = &monster[v1]; + v3 = v2->_mAi; + v4 = v2->_menemy; + v2->_mmode = MM_TALK; + if (v3 == AI_SNOTSPIL || v3 == AI_LACHDAN) { + //_LOBYTE(v5) = QuestStatus(QTYPE_BOL); + if (QuestStatus(QTYPE_BOL) && quests[QTYPE_BOL]._qvar1 == 2 && PlrHasItem(v4, IDI_BANNER, &inv_item_num)) { + RemoveInvItem(v4, inv_item_num); + quests[QTYPE_BOL]._qactive = 3; + v2->mtalkmsg = QUEST_BANNER12; + _LOBYTE(v2->_mgoal) = 6; + } + //_LOBYTE(v6) = QuestStatus(QTYPE_VEIL); + if (QuestStatus(QTYPE_VEIL) && v2->mtalkmsg >= (signed int)QUEST_VEIL9) { + if (PlrHasItem(v4, IDI_GLDNELIX, &inv_item_num)) { + RemoveInvItem(v4, inv_item_num); + v2->mtalkmsg = QUEST_VEIL11; + _LOBYTE(v2->_mgoal) = 6; + } + } + } } void __fastcall SpawnGolum(int i, int x, int y, int mi) { - int v4; // edi - int v5; // ebx - int v6; // esi - int v7; // eax - int *v8; // edx - int v9; // eax - char v10; // cl - int v11; // eax + int v4; // edi + int v5; // ebx + int v6; // esi + int v7; // eax + int *v8; // edx + int v9; // eax + char v10; // cl + int v11; // eax - v4 = i; - v5 = x; - if ((DWORD)i >= MAXMONSTERS) - TermMsg("SpawnGolum: Invalid monster %d", i); - v6 = v4; - monster[v6]._mx = v5; - monster[v6]._my = y; - monster[v6]._mfuty = y; - monster[v6]._moldy = y; - monster[v6]._mfutx = v5; - monster[v6]._moldx = v5; - v7 = plr[v4]._pMaxMana; - dMonster[0][y + 112 * v5] = v4 + 1; - _LOBYTE(monster[v6]._pathcount) = 0; - monster[v6]._mFlags |= 0x20u; - v8 = &missile[mi]._mispllvl; - monster[v6].mArmorClass = 25; - v9 = 320 * *v8 + v7 / 3; - v10 = *(_BYTE *)v8; - _LOBYTE(v8) = plr[v4]._pLevel; - v9 *= 2; - monster[v6]._mmaxhp = v9; - monster[v6]._mhitpoints = v9; - monster[v6].mHit = 5 * (v10 + 8) + 2 * (_BYTE)v8; - monster[v6].mMinDamage = 2 * (v10 + 4); - monster[v6].mMaxDamage = 2 * (v10 + 8); - M_StartSpStand(v4, 0); - M_Enemy(v4); - if (v4 == myplr) { - _LOBYTE(v11) = currlevel; - NetSendCmdGolem( - monster[v6]._mx, - monster[v6]._my, - monster[v6]._mdir, - monster[v6]._menemy, - monster[v6]._mhitpoints, - v11); - } + v4 = i; + v5 = x; + if ((DWORD)i >= MAXMONSTERS) + TermMsg("SpawnGolum: Invalid monster %d", i); + v6 = v4; + monster[v6]._mx = v5; + monster[v6]._my = y; + monster[v6]._mfuty = y; + monster[v6]._moldy = y; + monster[v6]._mfutx = v5; + monster[v6]._moldx = v5; + v7 = plr[v4]._pMaxMana; + dMonster[0][y + 112 * v5] = v4 + 1; + _LOBYTE(monster[v6]._pathcount) = 0; + monster[v6]._mFlags |= 0x20u; + v8 = &missile[mi]._mispllvl; + monster[v6].mArmorClass = 25; + v9 = 320 * *v8 + v7 / 3; + v10 = *(_BYTE *)v8; + _LOBYTE(v8) = plr[v4]._pLevel; + v9 *= 2; + monster[v6]._mmaxhp = v9; + monster[v6]._mhitpoints = v9; + monster[v6].mHit = 5 * (v10 + 8) + 2 * (_BYTE)v8; + monster[v6].mMinDamage = 2 * (v10 + 4); + monster[v6].mMaxDamage = 2 * (v10 + 8); + M_StartSpStand(v4, 0); + M_Enemy(v4); + if (v4 == myplr) { + _LOBYTE(v11) = currlevel; + NetSendCmdGolem( + monster[v6]._mx, + monster[v6]._my, + monster[v6]._mdir, + monster[v6]._menemy, + monster[v6]._mhitpoints, + v11); + } } BOOL __fastcall CanTalkToMonst(int m) { - if ((DWORD)m >= MAXMONSTERS) { - TermMsg("CanTalkToMonst: Invalid monster %d", m); - } + if ((DWORD)m >= MAXMONSTERS) { + TermMsg("CanTalkToMonst: Invalid monster %d", m); + } - if (monster[m]._mgoal == 6) { - return TRUE; - } + if (monster[m]._mgoal == 6) { + return TRUE; + } - return monster[m]._mgoal == 7; + return monster[m]._mgoal == 7; } BOOL __fastcall CheckMonsterHit(int m, BOOL *ret) { - if ((DWORD)m >= MAXMONSTERS) { - TermMsg("CheckMonsterHit: Invalid monster %d", m); - } + if ((DWORD)m >= MAXMONSTERS) { + TermMsg("CheckMonsterHit: Invalid monster %d", m); + } - if (monster[m]._mAi == AI_GARG && monster[m]._mFlags & 4) { - monster[m]._mmode = MM_SATTACK; - monster[m]._mFlags &= 0xFFFFFFFB; - *ret = TRUE; - return TRUE; - } + if (monster[m]._mAi == AI_GARG && monster[m]._mFlags & 4) { + monster[m]._mmode = MM_SATTACK; + monster[m]._mFlags &= 0xFFFFFFFB; + *ret = TRUE; + return TRUE; + } - if (monster[m].MType->mtype < MT_COUNSLR || monster[m].MType->mtype > MT_ADVOCATE || monster[m]._mgoal == 1) { - return FALSE; - } else { - *ret = FALSE; - } + if (monster[m].MType->mtype < MT_COUNSLR || monster[m].MType->mtype > MT_ADVOCATE || monster[m]._mgoal == 1) { + return FALSE; + } else { + *ret = FALSE; + } - return TRUE; + return TRUE; } int __fastcall encode_enemy(int m) { - int v1; // ecx - int result; // eax + int v1; // ecx + int result; // eax - v1 = m; - result = monster[v1]._menemy; - if (monster[v1]._mFlags & 0x10) - result += 4; - return result; + v1 = m; + result = monster[v1]._menemy; + if (monster[v1]._mFlags & 0x10) + result += 4; + return result; } void __fastcall decode_enemy(int m, int enemy) { - int v2; // eax - int v3; // edx - char v4; // cl - int v5; // edx + int v2; // eax + int v3; // edx + char v4; // cl + int v5; // edx - v2 = m; - if (enemy >= 4) { - monster[v2]._mFlags |= 0x10u; - v5 = enemy - 4; - monster[v2]._menemy = v5; - monster[v2]._menemyx = monster[v5]._mfutx; - v4 = monster[v5]._mfuty; - } else { - monster[v2]._mFlags &= 0xFFFFFFEF; - monster[v2]._menemy = enemy; - v3 = enemy; - monster[v2]._menemyx = plr[v3]._px; - v4 = plr[v3]._py; - } - monster[v2]._menemyy = v4; + v2 = m; + if (enemy >= 4) { + monster[v2]._mFlags |= 0x10u; + v5 = enemy - 4; + monster[v2]._menemy = v5; + monster[v2]._menemyx = monster[v5]._mfutx; + v4 = monster[v5]._mfuty; + } else { + monster[v2]._mFlags &= 0xFFFFFFEF; + monster[v2]._menemy = enemy; + v3 = enemy; + monster[v2]._menemyx = plr[v3]._px; + v4 = plr[v3]._py; + } + monster[v2]._menemyy = v4; } diff --git a/Source/movie.cpp b/Source/movie.cpp index 1012863c..30c0213c 100644 --- a/Source/movie.cpp +++ b/Source/movie.cpp @@ -9,68 +9,68 @@ BOOL loop_movie; const int movie_inf = 0x7F800000; // weak struct movie_cpp_init { - movie_cpp_init() - { - movie_cpp_init_value = movie_inf; - } + movie_cpp_init() + { + movie_cpp_init_value = movie_inf; + } } _movie_cpp_init; // 47F144: using guessed type int movie_inf; // 659AF4: using guessed type int movie_cpp_init_value; void __fastcall play_movie(char *pszMovie, BOOL user_can_close) { - if (!gbActive) { - return; - } + if (!gbActive) { + return; + } - WNDPROC saveProc = SetWindowProc(MovieWndProc); - InvalidateRect(ghMainWnd, 0, 0); - UpdateWindow(ghMainWnd); - movie_playing = TRUE; - sound_disable_music(TRUE); - sfx_stop(); - effects_play_sound("Sfx\\Misc\\blank.wav"); + WNDPROC saveProc = SetWindowProc(MovieWndProc); + InvalidateRect(ghMainWnd, 0, 0); + UpdateWindow(ghMainWnd); + movie_playing = TRUE; + sound_disable_music(TRUE); + sfx_stop(); + effects_play_sound("Sfx\\Misc\\blank.wav"); - void *video_stream; - SVidPlayBegin(pszMovie, 0, 0, 0, 0, loop_movie ? 0x100C0808 : 0x10280808, &video_stream); - if (video_stream) { - MSG Msg; - while (video_stream) { - if (!gbActive || user_can_close && !movie_playing) - break; - while (PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE)) { - if (Msg.message != WM_QUIT) { - TranslateMessage(&Msg); - DispatchMessage(&Msg); - } - } - if (!SVidPlayContinue()) - break; - } - if (video_stream) - SVidPlayEnd(video_stream); - } - SetWindowProc(saveProc); - sound_disable_music(FALSE); + void *video_stream; + SVidPlayBegin(pszMovie, 0, 0, 0, 0, loop_movie ? 0x100C0808 : 0x10280808, &video_stream); + if (video_stream) { + MSG Msg; + while (video_stream) { + if (!gbActive || user_can_close && !movie_playing) + break; + while (PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE)) { + if (Msg.message != WM_QUIT) { + TranslateMessage(&Msg); + DispatchMessage(&Msg); + } + } + if (!SVidPlayContinue()) + break; + } + if (video_stream) + SVidPlayEnd(video_stream); + } + SetWindowProc(saveProc); + sound_disable_music(FALSE); } // 634980: using guessed type int gbActive; LRESULT __stdcall MovieWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { - switch (Msg) { - case WM_KEYFIRST: - case WM_CHAR: - case WM_LBUTTONDOWN: - case WM_RBUTTONDOWN: - movie_playing = FALSE; - break; - case WM_SYSCOMMAND: - if (wParam == SC_CLOSE) { - movie_playing = FALSE; - return NULL; - } - break; - } + switch (Msg) { + case WM_KEYFIRST: + case WM_CHAR: + case WM_LBUTTONDOWN: + case WM_RBUTTONDOWN: + movie_playing = FALSE; + break; + case WM_SYSCOMMAND: + if (wParam == SC_CLOSE) { + movie_playing = FALSE; + return NULL; + } + break; + } - return MainWndProc(hWnd, Msg, wParam, lParam); + return MainWndProc(hWnd, Msg, wParam, lParam); } diff --git a/Source/mpqapi.cpp b/Source/mpqapi.cpp index c930b581..be3d9f9d 100644 --- a/Source/mpqapi.cpp +++ b/Source/mpqapi.cpp @@ -19,100 +19,100 @@ const int mpqapi_inf = 0x7F800000; // weak HANDLE sghArchive = (HANDLE)0xFFFFFFFF; // idb struct mpqapi_cpp_init { - mpqapi_cpp_init() - { - mpqapi_cpp_init_value = mpqapi_inf; - } + mpqapi_cpp_init() + { + mpqapi_cpp_init_value = mpqapi_inf; + } } _mpqapi_cpp_init; // 47F148: using guessed type int mpqapi_inf; // 659B00: using guessed type int mpqapi_cpp_init_value; bool __fastcall mpqapi_set_hidden(const char *pszArchive, bool hidden) { - const char *v2; // edi - BOOL v3; // esi - DWORD v4; // eax - bool result; // al - DWORD v6; // esi + const char *v2; // edi + BOOL v3; // esi + DWORD v4; // eax + bool result; // al + DWORD v6; // esi - v2 = pszArchive; - v3 = hidden; - v4 = GetFileAttributes(pszArchive); - if (v4 == -1) - return GetLastError() == ERROR_FILE_NOT_FOUND; - v6 = v3 != 0 ? FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN : 0; - if (v4 == v6) - result = 1; - else - result = SetFileAttributes(v2, v6); - return result; + v2 = pszArchive; + v3 = hidden; + v4 = GetFileAttributes(pszArchive); + if (v4 == -1) + return GetLastError() == ERROR_FILE_NOT_FOUND; + v6 = v3 != 0 ? FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN : 0; + if (v4 == v6) + result = 1; + else + result = SetFileAttributes(v2, v6); + return result; } void __fastcall mpqapi_store_creation_time(const char *pszArchive, int dwChar) { - int v2; // esi - const char *v3; // ebx - HANDLE v4; // eax - int v5; // esi - struct _WIN32_FIND_DATAA FindFileData; // [esp+8h] [ebp-1E0h] - char dst[160]; // [esp+148h] [ebp-A0h] + int v2; // esi + const char *v3; // ebx + HANDLE v4; // eax + int v5; // esi + struct _WIN32_FIND_DATAA FindFileData; // [esp+8h] [ebp-1E0h] + char dst[160]; // [esp+148h] [ebp-A0h] - v2 = dwChar; - v3 = pszArchive; - if (gbMaxPlayers != 1) { - mpqapi_reg_load_modification_time(dst, 160); - v4 = FindFirstFile(v3, &FindFileData); - if (v4 != (HANDLE)-1) { - FindClose(v4); - v5 = 16 * v2; - *(_DWORD *)&dst[v5] = FindFileData.ftCreationTime.dwLowDateTime; - *(_DWORD *)&dst[v5 + 4] = FindFileData.ftCreationTime.dwHighDateTime; - mpqapi_reg_store_modification_time(dst, 160); - } - } + v2 = dwChar; + v3 = pszArchive; + if (gbMaxPlayers != 1) { + mpqapi_reg_load_modification_time(dst, 160); + v4 = FindFirstFile(v3, &FindFileData); + if (v4 != (HANDLE)-1) { + FindClose(v4); + v5 = 16 * v2; + *(_DWORD *)&dst[v5] = FindFileData.ftCreationTime.dwLowDateTime; + *(_DWORD *)&dst[v5 + 4] = FindFileData.ftCreationTime.dwHighDateTime; + mpqapi_reg_store_modification_time(dst, 160); + } + } } // 679660: using guessed type char gbMaxPlayers; bool __fastcall mpqapi_reg_load_modification_time(char *dst, int size) { - unsigned int v2; // esi - char *v3; // edi - unsigned int v6; // esi - char *v7; // ecx - int nbytes_read; // [esp+8h] [ebp-4h] + unsigned int v2; // esi + char *v3; // edi + unsigned int v6; // esi + char *v7; // ecx + int nbytes_read; // [esp+8h] [ebp-4h] - v2 = size; - v3 = dst; - memset(dst, 0, size); - if (!SRegLoadData("Diablo", "Video Player ", 0, (unsigned char *)v3, v2, (unsigned long *)&nbytes_read) || nbytes_read != v2) - return 0; - if (v2 >= 8) { - v6 = v2 >> 3; - do { - v7 = v3; - v3 += 8; - mpqapi_xor_buf(v7); - --v6; - } while (v6); - } - return 1; + v2 = size; + v3 = dst; + memset(dst, 0, size); + if (!SRegLoadData("Diablo", "Video Player ", 0, (unsigned char *)v3, v2, (unsigned long *)&nbytes_read) || nbytes_read != v2) + return 0; + if (v2 >= 8) { + v6 = v2 >> 3; + do { + v7 = v3; + v3 += 8; + mpqapi_xor_buf(v7); + --v6; + } while (v6); + } + return 1; } void __fastcall mpqapi_xor_buf(char *pbData) { - signed int v1; // eax - char *v2; // esi - signed int v3; // edi + signed int v1; // eax + char *v2; // esi + signed int v3; // edi - v1 = 0xF0761AB; - v2 = pbData; - v3 = 8; - do { - *v2 ^= v1; - ++v2; - v1 = _rotl(v1, 1); - --v3; - } while (v3); + v1 = 0xF0761AB; + v2 = pbData; + v3 = 8; + do { + *v2 ^= v1; + ++v2; + v1 = _rotl(v1, 1); + --v3; + } while (v3); } void __fastcall mpqapi_update_multi_creation_time(DWORD dwChar) @@ -121,452 +121,452 @@ void __fastcall mpqapi_update_multi_creation_time(DWORD dwChar) bool __fastcall mpqapi_reg_store_modification_time(char *pbData, int dwLen) { - int v2; // ebx - char *v3; // ebp - char *v4; // edi - unsigned int v5; // esi - char *v6; // ecx + int v2; // ebx + char *v3; // ebp + char *v4; // edi + unsigned int v5; // esi + char *v6; // ecx - v2 = dwLen; - v3 = pbData; - v4 = pbData; - if ((unsigned int)dwLen >= 8) { - v5 = (unsigned int)dwLen >> 3; - do { - v6 = v4; - v4 += 8; - mpqapi_xor_buf(v6); - --v5; - } while (v5); - } - return SRegSaveData("Diablo", "Video Player ", 0, (unsigned char *)v3, v2); + v2 = dwLen; + v3 = pbData; + v4 = pbData; + if ((unsigned int)dwLen >= 8) { + v5 = (unsigned int)dwLen >> 3; + do { + v6 = v4; + v4 += 8; + mpqapi_xor_buf(v6); + --v5; + } while (v5); + } + return SRegSaveData("Diablo", "Video Player ", 0, (unsigned char *)v3, v2); } void __fastcall mpqapi_remove_hash_entry(const char *pszName) { - int v1; // eax - _HASHENTRY *v2; // ecx - _BLOCKENTRY *v3; // eax - int v4; // esi - int v5; // edi + int v1; // eax + _HASHENTRY *v2; // ecx + _BLOCKENTRY *v3; // eax + int v4; // esi + int v5; // edi - v1 = mpqapi_get_hash_index_of_path(pszName); - if (v1 != -1) { - v2 = &sgpHashTbl[v1]; - v3 = &sgpBlockTbl[v2->block]; - v2->block = -2; - v4 = v3->offset; - v5 = v3->sizealloc; - memset(v3, 0, 0x10u); - mpqapi_free_block(v4, v5); - save_archive_modified = 1; - } + v1 = mpqapi_get_hash_index_of_path(pszName); + if (v1 != -1) { + v2 = &sgpHashTbl[v1]; + v3 = &sgpBlockTbl[v2->block]; + v2->block = -2; + v4 = v3->offset; + v5 = v3->sizealloc; + memset(v3, 0, 0x10u); + mpqapi_free_block(v4, v5); + save_archive_modified = 1; + } } // 65AB0C: using guessed type int save_archive_modified; void __fastcall mpqapi_free_block(int block_offset, int block_size) { - int v2; // esi - int v3; // edi - _BLOCKENTRY *v4; // eax - signed int v5; // edx - signed int v6; // ecx - int v7; // ecx - bool v8; // zf - _BLOCKENTRY *v9; // eax + int v2; // esi + int v3; // edi + _BLOCKENTRY *v4; // eax + signed int v5; // edx + signed int v6; // ecx + int v7; // ecx + bool v8; // zf + _BLOCKENTRY *v9; // eax - v2 = block_size; - v3 = block_offset; + v2 = block_size; + v3 = block_offset; LABEL_2: - v4 = sgpBlockTbl; - v5 = 2048; - while (1) { - v6 = v5--; - if (!v6) - break; - v7 = v4->offset; - if (v4->offset && !v4->flags && !v4->sizefile) { - if (v7 + v4->sizealloc == v3) { - v3 = v4->offset; - LABEL_11: - v2 += v4->sizealloc; - memset(v4, 0, 0x10u); - goto LABEL_2; - } - if (v3 + v2 == v7) - goto LABEL_11; - } - ++v4; - } - v8 = v3 + v2 == sgdwMpqOffset; - if (v3 + v2 > sgdwMpqOffset) { - TermMsg("MPQ free list error"); - v8 = v3 + v2 == sgdwMpqOffset; - } - if (v8) { - sgdwMpqOffset = v3; - } else { - v9 = mpqapi_new_block(0); - v9->offset = v3; - v9->sizealloc = v2; - v9->sizefile = 0; - v9->flags = 0; - } + v4 = sgpBlockTbl; + v5 = 2048; + while (1) { + v6 = v5--; + if (!v6) + break; + v7 = v4->offset; + if (v4->offset && !v4->flags && !v4->sizefile) { + if (v7 + v4->sizealloc == v3) { + v3 = v4->offset; + LABEL_11: + v2 += v4->sizealloc; + memset(v4, 0, 0x10u); + goto LABEL_2; + } + if (v3 + v2 == v7) + goto LABEL_11; + } + ++v4; + } + v8 = v3 + v2 == sgdwMpqOffset; + if (v3 + v2 > sgdwMpqOffset) { + TermMsg("MPQ free list error"); + v8 = v3 + v2 == sgdwMpqOffset; + } + if (v8) { + sgdwMpqOffset = v3; + } else { + v9 = mpqapi_new_block(0); + v9->offset = v3; + v9->sizealloc = v2; + v9->sizefile = 0; + v9->flags = 0; + } } _BLOCKENTRY *__fastcall mpqapi_new_block(int *block_index) { - _BLOCKENTRY *result; // eax - unsigned int v2; // edx + _BLOCKENTRY *result; // eax + unsigned int v2; // edx - result = sgpBlockTbl; - v2 = 0; - while (result->offset || result->sizealloc || result->flags || result->sizefile) { - ++v2; - ++result; - if (v2 >= 0x800) { - TermMsg("Out of free block entries"); - return 0; - } - } - if (block_index) - *block_index = v2; - return result; + result = sgpBlockTbl; + v2 = 0; + while (result->offset || result->sizealloc || result->flags || result->sizefile) { + ++v2; + ++result; + if (v2 >= 0x800) { + TermMsg("Out of free block entries"); + return 0; + } + } + if (block_index) + *block_index = v2; + return result; } int __fastcall mpqapi_get_hash_index_of_path(const char *pszName) // FetchHandle { - const char *v1; // esi - int v2; // ST00_4 - int v3; // edi - short v4; // ax + const char *v1; // esi + int v2; // ST00_4 + int v3; // edi + short v4; // ax - v1 = pszName; - v2 = Hash(pszName, 2); // MPQ_HASH_NAME_B - v3 = Hash(v1, 1); // MPQ_HASH_NAME_A - v4 = Hash(v1, 0); // MPQ_HASH_TABLE_INDEX - return mpqapi_get_hash_index(v4, v3, v2, 0); + v1 = pszName; + v2 = Hash(pszName, 2); // MPQ_HASH_NAME_B + v3 = Hash(v1, 1); // MPQ_HASH_NAME_A + v4 = Hash(v1, 0); // MPQ_HASH_TABLE_INDEX + return mpqapi_get_hash_index(v4, v3, v2, 0); } int __fastcall mpqapi_get_hash_index(short index, int hash_a, int hash_b, int locale) { - int v4; // ecx - signed int v5; // eax - signed int v6; // edx - _HASHENTRY *v7; // ecx - int v8; // edi - int v10; // [esp+Ch] [ebp-8h] - int i; // [esp+10h] [ebp-4h] + int v4; // ecx + signed int v5; // eax + signed int v6; // edx + _HASHENTRY *v7; // ecx + int v8; // edi + int v10; // [esp+Ch] [ebp-8h] + int i; // [esp+10h] [ebp-4h] - v4 = index & 0x7FF; - v10 = hash_a; - v5 = 2048; - for (i = v4;; i = (i + 1) & 0x7FF) { - v7 = &sgpHashTbl[v4]; - v8 = v7->block; - if (v8 == -1) - return -1; - v6 = v5--; - if (!v6) - return -1; - if (v7->hashcheck[0] == v10 && v7->hashcheck[1] == hash_b && v7->lcid == locale && v8 != -2) - break; - v4 = (i + 1) & 0x7FF; - } - return i; + v4 = index & 0x7FF; + v10 = hash_a; + v5 = 2048; + for (i = v4;; i = (i + 1) & 0x7FF) { + v7 = &sgpHashTbl[v4]; + v8 = v7->block; + if (v8 == -1) + return -1; + v6 = v5--; + if (!v6) + return -1; + if (v7->hashcheck[0] == v10 && v7->hashcheck[1] == hash_b && v7->lcid == locale && v8 != -2) + break; + v4 = (i + 1) & 0x7FF; + } + return i; } void __fastcall mpqapi_remove_hash_entries(BOOL(__stdcall *fnGetName)(DWORD, char *)) { - BOOL(__stdcall * v1) - (DWORD, char *); // edi - DWORD v2; // esi - BOOL i; // eax - DWORD v4; // eax - char v5[260]; // [esp+8h] [ebp-104h] + BOOL(__stdcall * v1) + (DWORD, char *); // edi + DWORD v2; // esi + BOOL i; // eax + DWORD v4; // eax + char v5[260]; // [esp+8h] [ebp-104h] - v1 = fnGetName; - v2 = 1; - for (i = fnGetName(0, v5); i; i = v1(v4, v5)) { - mpqapi_remove_hash_entry(v5); - v4 = v2++; - } + v1 = fnGetName; + v2 = 1; + for (i = fnGetName(0, v5); i; i = v1(v4, v5)) { + mpqapi_remove_hash_entry(v5); + v4 = v2++; + } } BOOL __fastcall mpqapi_write_file(const char *pszName, const BYTE *pbData, DWORD dwLen) { - const BYTE *v3; // edi - const char *v4; // esi - _BLOCKENTRY *v5; // eax + const BYTE *v3; // edi + const char *v4; // esi + _BLOCKENTRY *v5; // eax - v3 = pbData; - v4 = pszName; - save_archive_modified = 1; - mpqapi_remove_hash_entry(pszName); - v5 = mpqapi_add_file(v4, 0, 0); - if (mpqapi_write_file_contents(v4, v3, dwLen, v5)) - return 1; - mpqapi_remove_hash_entry(v4); - return 0; + v3 = pbData; + v4 = pszName; + save_archive_modified = 1; + mpqapi_remove_hash_entry(pszName); + v5 = mpqapi_add_file(v4, 0, 0); + if (mpqapi_write_file_contents(v4, v3, dwLen, v5)) + return 1; + mpqapi_remove_hash_entry(v4); + return 0; } // 65AB0C: using guessed type int save_archive_modified; _BLOCKENTRY *__fastcall mpqapi_add_file(const char *pszName, _BLOCKENTRY *pBlk, int block_index) { - const char *v3; // edi - short v4; // si - int v5; // ebx - signed int v6; // edx - int v7; // esi - int v8; // ecx - int v9; // esi - int v11; // [esp+Ch] [ebp-8h] - _BLOCKENTRY *v12; // [esp+10h] [ebp-4h] + const char *v3; // edi + short v4; // si + int v5; // ebx + signed int v6; // edx + int v7; // esi + int v8; // ecx + int v9; // esi + int v11; // [esp+Ch] [ebp-8h] + _BLOCKENTRY *v12; // [esp+10h] [ebp-4h] - v12 = pBlk; - v3 = pszName; - v4 = Hash(pszName, 0); - v5 = Hash(v3, 1); - v11 = Hash(v3, 2); - if (mpqapi_get_hash_index(v4, v5, v11, 0) != -1) - TermMsg("Hash collision between \"%s\" and existing file\n", v3); - v6 = 2048; - v7 = v4 & 0x7FF; - while (1) { - --v6; - v8 = sgpHashTbl[v7].block; - if (v8 == -1 || v8 == -2) - break; - v7 = (v7 + 1) & 0x7FF; - if (!v6) { - v6 = -1; - break; - } - } - if (v6 < 0) - TermMsg("Out of hash space"); - if (!v12) - v12 = mpqapi_new_block(&block_index); - v9 = v7; - sgpHashTbl[v9].hashcheck[0] = v5; - sgpHashTbl[v9].hashcheck[1] = v11; - sgpHashTbl[v9].lcid = 0; - sgpHashTbl[v9].block = block_index; - return v12; + v12 = pBlk; + v3 = pszName; + v4 = Hash(pszName, 0); + v5 = Hash(v3, 1); + v11 = Hash(v3, 2); + if (mpqapi_get_hash_index(v4, v5, v11, 0) != -1) + TermMsg("Hash collision between \"%s\" and existing file\n", v3); + v6 = 2048; + v7 = v4 & 0x7FF; + while (1) { + --v6; + v8 = sgpHashTbl[v7].block; + if (v8 == -1 || v8 == -2) + break; + v7 = (v7 + 1) & 0x7FF; + if (!v6) { + v6 = -1; + break; + } + } + if (v6 < 0) + TermMsg("Out of hash space"); + if (!v12) + v12 = mpqapi_new_block(&block_index); + v9 = v7; + sgpHashTbl[v9].hashcheck[0] = v5; + sgpHashTbl[v9].hashcheck[1] = v11; + sgpHashTbl[v9].lcid = 0; + sgpHashTbl[v9].block = block_index; + return v12; } bool __fastcall mpqapi_write_file_contents(const char *pszName, const BYTE *pbData, int dwLen, _BLOCKENTRY *pBlk) { - const char *v4; // esi - const char *v5; // eax - unsigned int destsize; // ebx - const char *v7; // eax - unsigned int v8; // esi - _BLOCKENTRY *v9; // edi - int v10; // eax - signed int v11; // eax - unsigned int v13; // eax - unsigned int v14; // eax - int v15; // ecx - int size; // [esp+Ch] [ebp-10h] - const BYTE *v17; // [esp+10h] [ebp-Ch] - int v18; // [esp+14h] [ebp-8h] - DWORD nNumberOfBytesToWrite; // [esp+18h] [ebp-4h] + const char *v4; // esi + const char *v5; // eax + unsigned int destsize; // ebx + const char *v7; // eax + unsigned int v8; // esi + _BLOCKENTRY *v9; // edi + int v10; // eax + signed int v11; // eax + unsigned int v13; // eax + unsigned int v14; // eax + int v15; // ecx + int size; // [esp+Ch] [ebp-10h] + const BYTE *v17; // [esp+10h] [ebp-Ch] + int v18; // [esp+14h] [ebp-8h] + DWORD nNumberOfBytesToWrite; // [esp+18h] [ebp-4h] - v4 = pszName; - v17 = pbData; - v5 = strchr(pszName, ':'); - destsize = 0; - while (v5) { - v4 = v5 + 1; - v5 = strchr(v5 + 1, ':'); - } - while (1) { - v7 = strchr(v4, '\\'); - if (!v7) - break; - v4 = v7 + 1; - } - Hash(v4, 3); - v8 = dwLen; - v9 = pBlk; - size = 4 * ((unsigned int)(dwLen + 4095) >> 12) + 4; - nNumberOfBytesToWrite = 4 * ((unsigned int)(dwLen + 4095) >> 12) + 4; - v10 = mpqapi_find_free_block(size + dwLen, &pBlk->sizealloc); - v9->offset = v10; - v9->sizefile = v8; - v9->flags = 0x80000100; - if (SetFilePointer(sghArchive, v10, NULL, FILE_BEGIN) == -1) - return 0; - pBlk = 0; - v18 = 0; - while (v8) { - v11 = 0; - do - mpq_buf[v11++] -= 86; - while (v11 < 4096); - dwLen = v8; - if (v8 >= 0x1000) - dwLen = 4096; - memcpy(mpq_buf, v17, dwLen); - v17 += dwLen; - dwLen = PkwareCompress(mpq_buf, dwLen); - if (!v18) { - nNumberOfBytesToWrite = size; - pBlk = (_BLOCKENTRY *)DiabloAllocPtr(size); - memset(pBlk, 0, nNumberOfBytesToWrite); - if (!WriteFile(sghArchive, pBlk, nNumberOfBytesToWrite, &nNumberOfBytesToWrite, 0)) - goto LABEL_25; - destsize += nNumberOfBytesToWrite; - } - *(&pBlk->offset + v18) = destsize; - if (!WriteFile(sghArchive, mpq_buf, dwLen, (LPDWORD)&dwLen, 0)) - goto LABEL_25; - ++v18; - if (v8 <= 0x1000) - v8 = 0; - else - v8 -= 4096; - destsize += dwLen; - } - *(&pBlk->offset + v18) = destsize; - if (SetFilePointer(sghArchive, -destsize, NULL, FILE_CURRENT) == -1 - || !WriteFile(sghArchive, pBlk, nNumberOfBytesToWrite, &nNumberOfBytesToWrite, 0) - || SetFilePointer(sghArchive, destsize - nNumberOfBytesToWrite, NULL, FILE_CURRENT) == -1) { - LABEL_25: - if (pBlk) - mem_free_dbg(pBlk); - return 0; - } - mem_free_dbg(pBlk); - v13 = v9->sizealloc; - if (destsize < v13) { - v14 = v13 - destsize; - if (v14 >= 0x400) { - v15 = destsize + v9->offset; - v9->sizealloc = destsize; - mpqapi_free_block(v15, v14); - } - } - return 1; + v4 = pszName; + v17 = pbData; + v5 = strchr(pszName, ':'); + destsize = 0; + while (v5) { + v4 = v5 + 1; + v5 = strchr(v5 + 1, ':'); + } + while (1) { + v7 = strchr(v4, '\\'); + if (!v7) + break; + v4 = v7 + 1; + } + Hash(v4, 3); + v8 = dwLen; + v9 = pBlk; + size = 4 * ((unsigned int)(dwLen + 4095) >> 12) + 4; + nNumberOfBytesToWrite = 4 * ((unsigned int)(dwLen + 4095) >> 12) + 4; + v10 = mpqapi_find_free_block(size + dwLen, &pBlk->sizealloc); + v9->offset = v10; + v9->sizefile = v8; + v9->flags = 0x80000100; + if (SetFilePointer(sghArchive, v10, NULL, FILE_BEGIN) == -1) + return 0; + pBlk = 0; + v18 = 0; + while (v8) { + v11 = 0; + do + mpq_buf[v11++] -= 86; + while (v11 < 4096); + dwLen = v8; + if (v8 >= 0x1000) + dwLen = 4096; + memcpy(mpq_buf, v17, dwLen); + v17 += dwLen; + dwLen = PkwareCompress(mpq_buf, dwLen); + if (!v18) { + nNumberOfBytesToWrite = size; + pBlk = (_BLOCKENTRY *)DiabloAllocPtr(size); + memset(pBlk, 0, nNumberOfBytesToWrite); + if (!WriteFile(sghArchive, pBlk, nNumberOfBytesToWrite, &nNumberOfBytesToWrite, 0)) + goto LABEL_25; + destsize += nNumberOfBytesToWrite; + } + *(&pBlk->offset + v18) = destsize; + if (!WriteFile(sghArchive, mpq_buf, dwLen, (LPDWORD)&dwLen, 0)) + goto LABEL_25; + ++v18; + if (v8 <= 0x1000) + v8 = 0; + else + v8 -= 4096; + destsize += dwLen; + } + *(&pBlk->offset + v18) = destsize; + if (SetFilePointer(sghArchive, -destsize, NULL, FILE_CURRENT) == -1 + || !WriteFile(sghArchive, pBlk, nNumberOfBytesToWrite, &nNumberOfBytesToWrite, 0) + || SetFilePointer(sghArchive, destsize - nNumberOfBytesToWrite, NULL, FILE_CURRENT) == -1) { + LABEL_25: + if (pBlk) + mem_free_dbg(pBlk); + return 0; + } + mem_free_dbg(pBlk); + v13 = v9->sizealloc; + if (destsize < v13) { + v14 = v13 - destsize; + if (v14 >= 0x400) { + v15 = destsize + v9->offset; + v9->sizealloc = destsize; + mpqapi_free_block(v15, v14); + } + } + return 1; } int __fastcall mpqapi_find_free_block(int size, int *block_size) { - _BLOCKENTRY *v2; // eax - signed int v3; // esi - int result; // eax - int v5; // esi - bool v6; // zf + _BLOCKENTRY *v2; // eax + signed int v3; // esi + int result; // eax + int v5; // esi + bool v6; // zf - v2 = sgpBlockTbl; - v3 = 2048; - while (1) { - --v3; - if (v2->offset) { - if (!v2->flags && !v2->sizefile && v2->sizealloc >= (unsigned int)size) - break; - } - ++v2; - if (!v3) { - *block_size = size; - result = sgdwMpqOffset; - sgdwMpqOffset += size; - return result; - } - } - v5 = v2->offset; - *block_size = size; - v2->offset += size; - v6 = v2->sizealloc == size; - v2->sizealloc -= size; - if (v6) - memset(v2, 0, 0x10u); - return v5; + v2 = sgpBlockTbl; + v3 = 2048; + while (1) { + --v3; + if (v2->offset) { + if (!v2->flags && !v2->sizefile && v2->sizealloc >= (unsigned int)size) + break; + } + ++v2; + if (!v3) { + *block_size = size; + result = sgdwMpqOffset; + sgdwMpqOffset += size; + return result; + } + } + v5 = v2->offset; + *block_size = size; + v2->offset += size; + v6 = v2->sizealloc == size; + v2->sizealloc -= size; + if (v6) + memset(v2, 0, 0x10u); + return v5; } void __fastcall mpqapi_rename(char *pszOld, char *pszNew) { - char *v2; // esi - int v3; // eax - _HASHENTRY *v4; // eax - int v5; // ST00_4 - _BLOCKENTRY *v6; // edx + char *v2; // esi + int v3; // eax + _HASHENTRY *v4; // eax + int v5; // ST00_4 + _BLOCKENTRY *v6; // edx - v2 = pszNew; - v3 = mpqapi_get_hash_index_of_path(pszOld); - if (v3 != -1) { - v4 = &sgpHashTbl[v3]; - v5 = v4->block; - v6 = &sgpBlockTbl[v5]; - v4->block = -2; - mpqapi_add_file(v2, v6, v5); - save_archive_modified = 1; - } + v2 = pszNew; + v3 = mpqapi_get_hash_index_of_path(pszOld); + if (v3 != -1) { + v4 = &sgpHashTbl[v3]; + v5 = v4->block; + v6 = &sgpBlockTbl[v5]; + v4->block = -2; + mpqapi_add_file(v2, v6, v5); + save_archive_modified = 1; + } } // 65AB0C: using guessed type int save_archive_modified; BOOL __fastcall mpqapi_has_file(const char *pszName) { - return mpqapi_get_hash_index_of_path(pszName) != -1; + return mpqapi_get_hash_index_of_path(pszName) != -1; } BOOL __fastcall mpqapi_open_archive(const char *pszArchive, BOOL hidden, int dwChar) // OpenMPQ { - const char *v3; // ebp - BOOL v4; // esi - DWORD v6; // edi - int v8; // eax - int v10; // eax - const char *lpFileName; // [esp+10h] [ebp-70h] - DWORD dwTemp; // [esp+14h] [ebp-6Ch] - _FILEHEADER fhdr; // [esp+18h] [ebp-68h] + const char *v3; // ebp + BOOL v4; // esi + DWORD v6; // edi + int v8; // eax + int v10; // eax + const char *lpFileName; // [esp+10h] [ebp-70h] + DWORD dwTemp; // [esp+14h] [ebp-6Ch] + _FILEHEADER fhdr; // [esp+18h] [ebp-68h] - v3 = pszArchive; - v4 = hidden; - lpFileName = pszArchive; - InitHash(); - if (!mpqapi_set_hidden(v3, v4)) - return 0; - v6 = (unsigned char)gbMaxPlayers > 1u ? FILE_FLAG_WRITE_THROUGH : 0; - save_archive_open = 0; - sghArchive = CreateFile(v3, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, v6, NULL); - if (sghArchive == (HANDLE)-1) { - sghArchive = CreateFile(lpFileName, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, v6 | (v4 != 0 ? FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN : 0), NULL); - if (sghArchive == (HANDLE)-1) - return 0; - save_archive_open = 1; - save_archive_modified = 1; - } - if (!sgpBlockTbl || !sgpHashTbl) { - memset(&fhdr, 0, 0x68u); - if (!mpqapi_parse_archive_header(&fhdr, &sgdwMpqOffset)) { - LABEL_15: - mpqapi_close_archive(lpFileName, 1, dwChar); - return 0; - } - sgpBlockTbl = (_BLOCKENTRY *)DiabloAllocPtr(0x8000); - memset(sgpBlockTbl, 0, 0x8000u); - if (fhdr.blockcount) { - if (SetFilePointer(sghArchive, 104, NULL, FILE_BEGIN) == -1 - || !ReadFile(sghArchive, sgpBlockTbl, 0x8000u, &dwTemp, NULL)) { - goto LABEL_15; - } - v8 = Hash("(block table)", 3); - Decrypt(sgpBlockTbl, 0x8000, v8); - } - sgpHashTbl = (_HASHENTRY *)DiabloAllocPtr(0x8000); - memset(sgpHashTbl, 255, 0x8000u); - if (fhdr.hashcount) { - if (SetFilePointer(sghArchive, 32872, NULL, FILE_BEGIN) == -1 - || !ReadFile(sghArchive, sgpHashTbl, 0x8000u, &dwTemp, NULL)) { - goto LABEL_15; - } - v10 = Hash("(hash table)", 3); - Decrypt(sgpHashTbl, 0x8000, v10); - } - } - return 1; + v3 = pszArchive; + v4 = hidden; + lpFileName = pszArchive; + InitHash(); + if (!mpqapi_set_hidden(v3, v4)) + return 0; + v6 = (unsigned char)gbMaxPlayers > 1u ? FILE_FLAG_WRITE_THROUGH : 0; + save_archive_open = 0; + sghArchive = CreateFile(v3, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, v6, NULL); + if (sghArchive == (HANDLE)-1) { + sghArchive = CreateFile(lpFileName, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, v6 | (v4 != 0 ? FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN : 0), NULL); + if (sghArchive == (HANDLE)-1) + return 0; + save_archive_open = 1; + save_archive_modified = 1; + } + if (!sgpBlockTbl || !sgpHashTbl) { + memset(&fhdr, 0, 0x68u); + if (!mpqapi_parse_archive_header(&fhdr, &sgdwMpqOffset)) { + LABEL_15: + mpqapi_close_archive(lpFileName, 1, dwChar); + return 0; + } + sgpBlockTbl = (_BLOCKENTRY *)DiabloAllocPtr(0x8000); + memset(sgpBlockTbl, 0, 0x8000u); + if (fhdr.blockcount) { + if (SetFilePointer(sghArchive, 104, NULL, FILE_BEGIN) == -1 + || !ReadFile(sghArchive, sgpBlockTbl, 0x8000u, &dwTemp, NULL)) { + goto LABEL_15; + } + v8 = Hash("(block table)", 3); + Decrypt(sgpBlockTbl, 0x8000, v8); + } + sgpHashTbl = (_HASHENTRY *)DiabloAllocPtr(0x8000); + memset(sgpHashTbl, 255, 0x8000u); + if (fhdr.hashcount) { + if (SetFilePointer(sghArchive, 32872, NULL, FILE_BEGIN) == -1 + || !ReadFile(sghArchive, sgpHashTbl, 0x8000u, &dwTemp, NULL)) { + goto LABEL_15; + } + v10 = Hash("(hash table)", 3); + Decrypt(sgpHashTbl, 0x8000, v10); + } + } + return 1; } // 65AB0C: using guessed type int save_archive_modified; // 65AB14: using guessed type char save_archive_open; @@ -574,182 +574,182 @@ BOOL __fastcall mpqapi_open_archive(const char *pszArchive, BOOL hidden, int dwC bool __fastcall mpqapi_parse_archive_header(_FILEHEADER *pHdr, int *pdwNextFileStart) // ParseMPQHeader { - int *v2; // ebp - _FILEHEADER *v3; // esi - DWORD v4; // eax - DWORD v5; // edi - DWORD NumberOfBytesRead; // [esp+10h] [ebp-4h] + int *v2; // ebp + _FILEHEADER *v3; // esi + DWORD v4; // eax + DWORD v5; // edi + DWORD NumberOfBytesRead; // [esp+10h] [ebp-4h] - v2 = pdwNextFileStart; - v3 = pHdr; - v4 = GetFileSize(sghArchive, 0); - v5 = v4; - *v2 = v4; - if (v4 == -1 - || v4 < 0x68 - || !ReadFile(sghArchive, v3, 0x68u, &NumberOfBytesRead, NULL) - || NumberOfBytesRead != 104 - || v3->signature != '\x1AQPM' - || v3->headersize != 32 - || v3->version > 0u - || v3->sectorsizeid != 3 - || v3->filesize != v5 - || v3->hashoffset != 32872 - || v3->blockoffset != 104 - || v3->hashcount != 2048 - || v3->blockcount != 2048) { - if (SetFilePointer(sghArchive, 0, NULL, FILE_BEGIN) == -1 || !SetEndOfFile(sghArchive)) - return 0; - memset(v3, 0, 0x68u); - v3->signature = '\x1AQPM'; - v3->headersize = 32; - v3->sectorsizeid = 3; - v3->version = 0; - *v2 = 0x10068; - save_archive_modified = 1; - save_archive_open = 1; - } - return 1; + v2 = pdwNextFileStart; + v3 = pHdr; + v4 = GetFileSize(sghArchive, 0); + v5 = v4; + *v2 = v4; + if (v4 == -1 + || v4 < 0x68 + || !ReadFile(sghArchive, v3, 0x68u, &NumberOfBytesRead, NULL) + || NumberOfBytesRead != 104 + || v3->signature != '\x1AQPM' + || v3->headersize != 32 + || v3->version > 0u + || v3->sectorsizeid != 3 + || v3->filesize != v5 + || v3->hashoffset != 32872 + || v3->blockoffset != 104 + || v3->hashcount != 2048 + || v3->blockcount != 2048) { + if (SetFilePointer(sghArchive, 0, NULL, FILE_BEGIN) == -1 || !SetEndOfFile(sghArchive)) + return 0; + memset(v3, 0, 0x68u); + v3->signature = '\x1AQPM'; + v3->headersize = 32; + v3->sectorsizeid = 3; + v3->version = 0; + *v2 = 0x10068; + save_archive_modified = 1; + save_archive_open = 1; + } + return 1; } // 65AB0C: using guessed type int save_archive_modified; // 65AB14: using guessed type char save_archive_open; void __fastcall mpqapi_close_archive(const char *pszArchive, BOOL bFree, int dwChar) // CloseMPQ { - const char *v3; // esi - _BLOCKENTRY *v4; // ecx - _HASHENTRY *v5; // ecx + const char *v3; // esi + _BLOCKENTRY *v4; // ecx + _HASHENTRY *v5; // ecx - v3 = pszArchive; - if (bFree) { - v4 = sgpBlockTbl; - sgpBlockTbl = 0; - mem_free_dbg(v4); - v5 = sgpHashTbl; - sgpHashTbl = 0; - mem_free_dbg(v5); - } - if (sghArchive != (HANDLE)-1) { - CloseHandle(sghArchive); - sghArchive = (HANDLE)-1; - } - if (save_archive_modified) { - save_archive_modified = 0; - mpqapi_store_modified_time(v3, dwChar); - } - if (save_archive_open) { - save_archive_open = 0; - mpqapi_store_creation_time(v3, dwChar); - } + v3 = pszArchive; + if (bFree) { + v4 = sgpBlockTbl; + sgpBlockTbl = 0; + mem_free_dbg(v4); + v5 = sgpHashTbl; + sgpHashTbl = 0; + mem_free_dbg(v5); + } + if (sghArchive != (HANDLE)-1) { + CloseHandle(sghArchive); + sghArchive = (HANDLE)-1; + } + if (save_archive_modified) { + save_archive_modified = 0; + mpqapi_store_modified_time(v3, dwChar); + } + if (save_archive_open) { + save_archive_open = 0; + mpqapi_store_creation_time(v3, dwChar); + } } // 65AB0C: using guessed type int save_archive_modified; // 65AB14: using guessed type char save_archive_open; void __fastcall mpqapi_store_modified_time(const char *pszArchive, int dwChar) { - int v2; // esi - const char *v3; // ebx - HANDLE v4; // eax - int v5; // esi - struct _WIN32_FIND_DATAA FindFileData; // [esp+8h] [ebp-1E0h] - char dst[160]; // [esp+148h] [ebp-A0h] + int v2; // esi + const char *v3; // ebx + HANDLE v4; // eax + int v5; // esi + struct _WIN32_FIND_DATAA FindFileData; // [esp+8h] [ebp-1E0h] + char dst[160]; // [esp+148h] [ebp-A0h] - v2 = dwChar; - v3 = pszArchive; - if (gbMaxPlayers != 1) { - mpqapi_reg_load_modification_time(dst, 160); - v4 = FindFirstFile(v3, &FindFileData); - if (v4 != (HANDLE)-1) { - FindClose(v4); - v5 = 16 * v2; - *(_DWORD *)&dst[v5 + 8] = FindFileData.ftLastWriteTime.dwLowDateTime; - *(_DWORD *)&dst[v5 + 12] = FindFileData.ftLastWriteTime.dwHighDateTime; - mpqapi_reg_store_modification_time(dst, 160); - } - } + v2 = dwChar; + v3 = pszArchive; + if (gbMaxPlayers != 1) { + mpqapi_reg_load_modification_time(dst, 160); + v4 = FindFirstFile(v3, &FindFileData); + if (v4 != (HANDLE)-1) { + FindClose(v4); + v5 = 16 * v2; + *(_DWORD *)&dst[v5 + 8] = FindFileData.ftLastWriteTime.dwLowDateTime; + *(_DWORD *)&dst[v5 + 12] = FindFileData.ftLastWriteTime.dwHighDateTime; + mpqapi_reg_store_modification_time(dst, 160); + } + } } // 679660: using guessed type char gbMaxPlayers; void __fastcall mpqapi_flush_and_close(const char *pszArchive, BOOL bFree, int dwChar) { - if (sghArchive != (HANDLE)-1) { - if (save_archive_modified) { - if (mpqapi_can_seek()) { - if (mpqapi_write_header()) { - if (mpqapi_write_block_table()) - mpqapi_write_hash_table(); - } - } - } - } - mpqapi_close_archive(pszArchive, bFree, dwChar); + if (sghArchive != (HANDLE)-1) { + if (save_archive_modified) { + if (mpqapi_can_seek()) { + if (mpqapi_write_header()) { + if (mpqapi_write_block_table()) + mpqapi_write_hash_table(); + } + } + } + } + mpqapi_close_archive(pszArchive, bFree, dwChar); } // 65AB0C: using guessed type int save_archive_modified; bool __cdecl mpqapi_write_header() // WriteMPQHeader { - bool result; // al - _FILEHEADER fhdr; // [esp+8h] [ebp-6Ch] - DWORD NumberOfBytesWritten; // [esp+70h] [ebp-4h] + bool result; // al + _FILEHEADER fhdr; // [esp+8h] [ebp-6Ch] + DWORD NumberOfBytesWritten; // [esp+70h] [ebp-4h] - memset(&fhdr, 0, 0x68u); - fhdr.signature = '\x1AQPM'; - fhdr.headersize = 32; - fhdr.filesize = GetFileSize(sghArchive, 0); - fhdr.version = 0; - fhdr.sectorsizeid = 3; - fhdr.hashoffset = 32872; - fhdr.blockoffset = 104; - fhdr.hashcount = 2048; - fhdr.blockcount = 2048; - if (SetFilePointer(sghArchive, 0, NULL, FILE_BEGIN) != -1 && WriteFile(sghArchive, &fhdr, 0x68u, &NumberOfBytesWritten, 0)) - result = NumberOfBytesWritten == 104; - else - result = 0; - return result; + memset(&fhdr, 0, 0x68u); + fhdr.signature = '\x1AQPM'; + fhdr.headersize = 32; + fhdr.filesize = GetFileSize(sghArchive, 0); + fhdr.version = 0; + fhdr.sectorsizeid = 3; + fhdr.hashoffset = 32872; + fhdr.blockoffset = 104; + fhdr.hashcount = 2048; + fhdr.blockcount = 2048; + if (SetFilePointer(sghArchive, 0, NULL, FILE_BEGIN) != -1 && WriteFile(sghArchive, &fhdr, 0x68u, &NumberOfBytesWritten, 0)) + result = NumberOfBytesWritten == 104; + else + result = 0; + return result; } bool __cdecl mpqapi_write_block_table() { - int v1; // eax - BOOL v2; // ebx - int v3; // eax - DWORD NumberOfBytesWritten; // [esp+4h] [ebp-4h] + int v1; // eax + BOOL v2; // ebx + int v3; // eax + DWORD NumberOfBytesWritten; // [esp+4h] [ebp-4h] - if (SetFilePointer(sghArchive, 104, NULL, FILE_BEGIN) == -1) - return 0; - v1 = Hash("(block table)", 3); - Encrypt(sgpBlockTbl, 0x8000, v1); - v2 = WriteFile(sghArchive, sgpBlockTbl, 0x8000u, &NumberOfBytesWritten, 0); - v3 = Hash("(block table)", 3); - Decrypt(sgpBlockTbl, 0x8000, v3); - return v2 && NumberOfBytesWritten == 0x8000; + if (SetFilePointer(sghArchive, 104, NULL, FILE_BEGIN) == -1) + return 0; + v1 = Hash("(block table)", 3); + Encrypt(sgpBlockTbl, 0x8000, v1); + v2 = WriteFile(sghArchive, sgpBlockTbl, 0x8000u, &NumberOfBytesWritten, 0); + v3 = Hash("(block table)", 3); + Decrypt(sgpBlockTbl, 0x8000, v3); + return v2 && NumberOfBytesWritten == 0x8000; } bool __cdecl mpqapi_write_hash_table() { - int v1; // eax - BOOL v2; // ebx - int v3; // eax - DWORD NumberOfBytesWritten; // [esp+4h] [ebp-4h] + int v1; // eax + BOOL v2; // ebx + int v3; // eax + DWORD NumberOfBytesWritten; // [esp+4h] [ebp-4h] - if (SetFilePointer(sghArchive, 32872, NULL, FILE_BEGIN) == -1) - return 0; - v1 = Hash("(hash table)", 3); - Encrypt(sgpHashTbl, 0x8000, v1); - v2 = WriteFile(sghArchive, sgpHashTbl, 0x8000u, &NumberOfBytesWritten, 0); - v3 = Hash("(hash table)", 3); - Decrypt(sgpHashTbl, 0x8000, v3); - return v2 && NumberOfBytesWritten == 0x8000; + if (SetFilePointer(sghArchive, 32872, NULL, FILE_BEGIN) == -1) + return 0; + v1 = Hash("(hash table)", 3); + Encrypt(sgpHashTbl, 0x8000, v1); + v2 = WriteFile(sghArchive, sgpHashTbl, 0x8000u, &NumberOfBytesWritten, 0); + v3 = Hash("(hash table)", 3); + Decrypt(sgpHashTbl, 0x8000, v3); + return v2 && NumberOfBytesWritten == 0x8000; } bool __cdecl mpqapi_can_seek() { - bool result; // al + bool result; // al - if (SetFilePointer(sghArchive, sgdwMpqOffset, NULL, FILE_BEGIN) == -1) - result = 0; - else - result = SetEndOfFile(sghArchive); - return result; + if (SetFilePointer(sghArchive, sgdwMpqOffset, NULL, FILE_BEGIN) == -1) + result = 0; + else + result = SetEndOfFile(sghArchive); + return result; } diff --git a/Source/msg.cpp b/Source/msg.cpp index 1ad43c84..8d65966e 100644 --- a/Source/msg.cpp +++ b/Source/msg.cpp @@ -23,82 +23,82 @@ static float msg_cpp_init_value = INFINITY; void __fastcall msg_send_drop_pkt(int pnum, int reason) { - TFakeDropPlr cmd; // [esp+0h] [ebp-8h] + TFakeDropPlr cmd; // [esp+0h] [ebp-8h] - cmd.dwReason = reason; - cmd.bCmd = FAKE_CMD_DROPID; - cmd.bPlr = pnum; - msg_send_packet(pnum, &cmd, 6); + cmd.dwReason = reason; + cmd.bCmd = FAKE_CMD_DROPID; + cmd.bPlr = pnum; + msg_send_packet(pnum, &cmd, 6); } void __fastcall msg_send_packet(int pnum, const void *packet, DWORD dwSize) { - const void *v3; // edi - TMegaPkt *v4; // eax - TFakeCmdPlr cmd; // [esp+Ah] [ebp-2h] + const void *v3; // edi + TMegaPkt *v4; // eax + TFakeCmdPlr cmd; // [esp+Ah] [ebp-2h] - v3 = packet; - if (pnum != sgnCurrMegaPlayer) { - sgnCurrMegaPlayer = pnum; - cmd.bCmd = FAKE_CMD_SETID; - cmd.bPlr = pnum; - msg_send_packet(pnum, &cmd, 2); - } - v4 = sgpCurrPkt; - if (sgpCurrPkt->dwSpaceLeft < (unsigned int)dwSize) { - msg_get_next_packet(); - v4 = sgpCurrPkt; - } - memcpy((char *)&v4[1] - v4->dwSpaceLeft, v3, dwSize); - sgpCurrPkt->dwSpaceLeft -= dwSize; + v3 = packet; + if (pnum != sgnCurrMegaPlayer) { + sgnCurrMegaPlayer = pnum; + cmd.bCmd = FAKE_CMD_SETID; + cmd.bPlr = pnum; + msg_send_packet(pnum, &cmd, 2); + } + v4 = sgpCurrPkt; + if (sgpCurrPkt->dwSpaceLeft < (unsigned int)dwSize) { + msg_get_next_packet(); + v4 = sgpCurrPkt; + } + memcpy((char *)&v4[1] - v4->dwSpaceLeft, v3, dwSize); + sgpCurrPkt->dwSpaceLeft -= dwSize; } // 65AB24: using guessed type int sgnCurrMegaPlayer; TMegaPkt *__cdecl msg_get_next_packet() { - TMegaPkt *v0; // eax - TMegaPkt *v1; // ecx - TMegaPkt *result; // eax + TMegaPkt *v0; // eax + TMegaPkt *v1; // ecx + TMegaPkt *result; // eax - v0 = (TMegaPkt *)DiabloAllocPtr(32008); - sgpCurrPkt = v0; - v0->pNext = 0; - sgpCurrPkt->dwSpaceLeft = 32000; - v1 = sgpMegaPkt; - result = (TMegaPkt *)&sgpMegaPkt; - while (v1) { - result = v1; - v1 = v1->pNext; - } - result->pNext = sgpCurrPkt; - return result; + v0 = (TMegaPkt *)DiabloAllocPtr(32008); + sgpCurrPkt = v0; + v0->pNext = 0; + sgpCurrPkt->dwSpaceLeft = 32000; + v1 = sgpMegaPkt; + result = (TMegaPkt *)&sgpMegaPkt; + while (v1) { + result = v1; + v1 = v1->pNext; + } + result->pNext = sgpCurrPkt; + return result; } BOOL __cdecl msg_wait_resync() { - int v0; // eax + int v0; // eax - msg_get_next_packet(); - sgbDeltaChunks = 0; - sgnCurrMegaPlayer = -1; - sgbRecvCmd = CMD_DLEVEL_END; - gbBufferMsgs = 1; - sgdwOwnerWait = GetTickCount(); - v0 = UiProgressDialog(ghMainWnd, "Waiting for game data...", 1, msg_wait_for_turns, 20); - gbBufferMsgs = 0; - if (!v0) - goto LABEL_6; - if (gbGameDestroyed) { - DrawDlg("The game ended"); - LABEL_6: - msg_free_packets(); - return 0; - } - if (sgbDeltaChunks != 21) { - DrawDlg("Unable to get level data"); - goto LABEL_6; - } - return 1; + msg_get_next_packet(); + sgbDeltaChunks = 0; + sgnCurrMegaPlayer = -1; + sgbRecvCmd = CMD_DLEVEL_END; + gbBufferMsgs = 1; + sgdwOwnerWait = GetTickCount(); + v0 = UiProgressDialog(ghMainWnd, "Waiting for game data...", 1, msg_wait_for_turns, 20); + gbBufferMsgs = 0; + if (!v0) + goto LABEL_6; + if (gbGameDestroyed) { + DrawDlg("The game ended"); + LABEL_6: + msg_free_packets(); + return 0; + } + if (sgbDeltaChunks != 21) { + DrawDlg("Unable to get level data"); + goto LABEL_6; + } + return 1; } // 65AB18: using guessed type int sgdwOwnerWait; // 65AB24: using guessed type int sgnCurrMegaPlayer; @@ -108,54 +108,54 @@ BOOL __cdecl msg_wait_resync() void __cdecl msg_free_packets() { - TMegaPkt *v0; // eax - TMegaPkt *v1; // ecx + TMegaPkt *v0; // eax + TMegaPkt *v1; // ecx - v0 = sgpMegaPkt; - while (v0) { - v1 = v0->pNext; - sgpMegaPkt = 0; - sgpCurrPkt = v1; - mem_free_dbg(v0); - v0 = sgpCurrPkt; - sgpMegaPkt = sgpCurrPkt; - } + v0 = sgpMegaPkt; + while (v0) { + v1 = v0->pNext; + sgpMegaPkt = 0; + sgpCurrPkt = v1; + mem_free_dbg(v0); + v0 = sgpCurrPkt; + sgpMegaPkt = sgpCurrPkt; + } } int __cdecl msg_wait_for_turns() { - //int v0; // eax - //int v2; // eax - int recieved; // [esp+0h] [ebp-8h] - DWORD turns; // [esp+4h] [ebp-4h] + //int v0; // eax + //int v2; // eax + int recieved; // [esp+0h] [ebp-8h] + DWORD turns; // [esp+4h] [ebp-4h] - if (!sgbDeltaChunks) { - nthread_send_and_recv_turn(0, 0); - //_LOBYTE(v0) = SNetGetOwnerTurnsWaiting(&turns); - if (!SNetGetOwnerTurnsWaiting(&turns) && SErrGetLastError() == STORM_ERROR_NOT_IN_GAME) - return 100; - if (GetTickCount() - sgdwOwnerWait <= 2000 && turns < (unsigned int)gdwTurnsInTransit) - return 0; - ++sgbDeltaChunks; - } - multi_process_network_packets(); - nthread_send_and_recv_turn(0, 0); - //_LOBYTE(v2) = nthread_has_500ms_passed(); - if (nthread_has_500ms_passed()) - nthread_recv_turns(&recieved); - if (gbGameDestroyed) - return 100; - if ((unsigned char)gbDeltaSender >= 4u) { - sgbDeltaChunks = 0; - sgbRecvCmd = CMD_DLEVEL_END; - gbDeltaSender = myplr; - nthread_set_turn_upper_bit(); - } - if (sgbDeltaChunks == 20) { - sgbDeltaChunks = 21; - return 99; - } - return 100 * (unsigned char)sgbDeltaChunks / 21; + if (!sgbDeltaChunks) { + nthread_send_and_recv_turn(0, 0); + //_LOBYTE(v0) = SNetGetOwnerTurnsWaiting(&turns); + if (!SNetGetOwnerTurnsWaiting(&turns) && SErrGetLastError() == STORM_ERROR_NOT_IN_GAME) + return 100; + if (GetTickCount() - sgdwOwnerWait <= 2000 && turns < (unsigned int)gdwTurnsInTransit) + return 0; + ++sgbDeltaChunks; + } + multi_process_network_packets(); + nthread_send_and_recv_turn(0, 0); + //_LOBYTE(v2) = nthread_has_500ms_passed(); + if (nthread_has_500ms_passed()) + nthread_recv_turns(&recieved); + if (gbGameDestroyed) + return 100; + if ((unsigned char)gbDeltaSender >= 4u) { + sgbDeltaChunks = 0; + sgbRecvCmd = CMD_DLEVEL_END; + gbDeltaSender = myplr; + nthread_set_turn_upper_bit(); + } + if (sgbDeltaChunks == 20) { + sgbDeltaChunks = 21; + return 99; + } + return 100 * (unsigned char)sgbDeltaChunks / 21; } // 65AB18: using guessed type int sgdwOwnerWait; // 67618D: using guessed type char sgbDeltaChunks; @@ -165,311 +165,311 @@ int __cdecl msg_wait_for_turns() void __cdecl msg_process_net_packets() { - if (gbMaxPlayers != 1) { - gbBufferMsgs = 2; - msg_pre_packet(); - gbBufferMsgs = 0; - msg_free_packets(); - } + if (gbMaxPlayers != 1) { + gbBufferMsgs = 2; + msg_pre_packet(); + gbBufferMsgs = 0; + msg_free_packets(); + } } // 676194: using guessed type char gbBufferMsgs; // 679660: using guessed type char gbMaxPlayers; void __cdecl msg_pre_packet() { - TMegaPkt *v0; // edi - int i; // ebp - signed int v2; // ebx - TFakeCmdPlr *v3; // esi - TFakeCmdPlr *v4; // eax - TFakeDropPlr *v5; // eax - int v6; // eax + TMegaPkt *v0; // edi + int i; // ebp + signed int v2; // ebx + TFakeCmdPlr *v3; // esi + TFakeCmdPlr *v4; // eax + TFakeDropPlr *v5; // eax + int v6; // eax - v0 = sgpMegaPkt; - for (i = -1; v0; v0 = v0->pNext) { - v2 = 32000; - v3 = (TFakeCmdPlr *)v0->data; - while (v2 != v0->dwSpaceLeft) { - if (v3->bCmd == FAKE_CMD_SETID) { - v4 = v3; - ++v3; - i = (unsigned char)v4->bPlr; - v2 -= 2; - } else if (v3->bCmd == FAKE_CMD_DROPID) { - v5 = (TFakeDropPlr *)v3; - v3 += 3; - v2 -= 6; - multi_player_left((unsigned char)v5->bPlr, v5->dwReason); - } else { - v6 = ParseCmd(i, (TCmd *)v3); - v3 = (TFakeCmdPlr *)((char *)v3 + v6); - v2 -= v6; - } - } - } + v0 = sgpMegaPkt; + for (i = -1; v0; v0 = v0->pNext) { + v2 = 32000; + v3 = (TFakeCmdPlr *)v0->data; + while (v2 != v0->dwSpaceLeft) { + if (v3->bCmd == FAKE_CMD_SETID) { + v4 = v3; + ++v3; + i = (unsigned char)v4->bPlr; + v2 -= 2; + } else if (v3->bCmd == FAKE_CMD_DROPID) { + v5 = (TFakeDropPlr *)v3; + v3 += 3; + v2 -= 6; + multi_player_left((unsigned char)v5->bPlr, v5->dwReason); + } else { + v6 = ParseCmd(i, (TCmd *)v3); + v3 = (TFakeCmdPlr *)((char *)v3 + v6); + v2 -= v6; + } + } + } } void __fastcall DeltaExportData(int pnum) { - char *v1; // edi - DObjectStr *v2; // esi - void *v3; // ebx - void *v4; // eax - void *v5; // eax - void *v6; // eax - int v7; // eax - void *v8; // eax - int v9; // eax - int player_num; // [esp+0h] [ebp-Ch] - int v11; // [esp+4h] [ebp-8h] - char src; // [esp+Bh] [ebp-1h] + char *v1; // edi + DObjectStr *v2; // esi + void *v3; // ebx + void *v4; // eax + void *v5; // eax + void *v6; // eax + int v7; // eax + void *v8; // eax + int v9; // eax + int player_num; // [esp+0h] [ebp-Ch] + int v11; // [esp+4h] [ebp-8h] + char src; // [esp+Bh] [ebp-1h] - player_num = pnum; - if (sgbDeltaChanged) { - v11 = 0; - v1 = (char *)DiabloAllocPtr(4722); - v2 = sgLevels[0].object; - v3 = v1 + 1; - do { - v4 = DeltaExportItem(v3, &v2[-2794]); - v5 = DeltaExportObject(v4, v2); - v6 = DeltaExportMonster(v5, &v2[127]); - v7 = msg_comp_level(v1, v6); - dthread_send_delta(player_num, (_BYTE)v11++ + CMD_DLEVEL_0, v1, v7); - v2 += 4721; - } while ((signed int)v2 < (signed int)&sgLevels[NUMLEVELS].object); - v8 = DeltaExportJunk(v3); - v9 = msg_comp_level(v1, v8); - dthread_send_delta(player_num, CMD_DLEVEL_JUNK, v1, v9); - mem_free_dbg(v1); - } - src = 0; - dthread_send_delta(player_num, CMD_DLEVEL_END, &src, 1); + player_num = pnum; + if (sgbDeltaChanged) { + v11 = 0; + v1 = (char *)DiabloAllocPtr(4722); + v2 = sgLevels[0].object; + v3 = v1 + 1; + do { + v4 = DeltaExportItem(v3, &v2[-2794]); + v5 = DeltaExportObject(v4, v2); + v6 = DeltaExportMonster(v5, &v2[127]); + v7 = msg_comp_level(v1, v6); + dthread_send_delta(player_num, (_BYTE)v11++ + CMD_DLEVEL_0, v1, v7); + v2 += 4721; + } while ((signed int)v2 < (signed int)&sgLevels[NUMLEVELS].object); + v8 = DeltaExportJunk(v3); + v9 = msg_comp_level(v1, v8); + dthread_send_delta(player_num, CMD_DLEVEL_JUNK, v1, v9); + mem_free_dbg(v1); + } + src = 0; + dthread_send_delta(player_num, CMD_DLEVEL_END, &src, 1); } // 67618C: using guessed type char sgbDeltaChanged; void *__fastcall DeltaExportItem(void *dst, void *src) { - _BYTE *v2; // edi - _BYTE *v3; // esi - signed int v4; // ebx + _BYTE *v2; // edi + _BYTE *v3; // esi + signed int v4; // ebx - v2 = (unsigned char *)src; - v3 = (unsigned char *)dst; - v4 = 127; - do { - if (*v2 == -1) { - *v3++ = -1; - } else { - memcpy(v3, v2, 0x16u); - v3 += 22; - } - v2 += 22; - --v4; - } while (v4); - return v3; + v2 = (unsigned char *)src; + v3 = (unsigned char *)dst; + v4 = 127; + do { + if (*v2 == -1) { + *v3++ = -1; + } else { + memcpy(v3, v2, 0x16u); + v3 += 22; + } + v2 += 22; + --v4; + } while (v4); + return v3; } void *__fastcall DeltaExportObject(void *dst, void *src) { - char *v2; // esi + char *v2; // esi - v2 = (char *)dst; - memcpy(dst, src, 0x7Fu); - return v2 + 127; + v2 = (char *)dst; + memcpy(dst, src, 0x7Fu); + return v2 + 127; } void *__fastcall DeltaExportMonster(void *dst, void *src) { - _BYTE *v2; // edi - _BYTE *v3; // esi - signed int v4; // ebx + _BYTE *v2; // edi + _BYTE *v3; // esi + signed int v4; // ebx - v2 = (unsigned char *)src; - v3 = (unsigned char *)dst; - v4 = MAXMONSTERS; - do { - if (*v2 == -1) { - *v3++ = -1; - } else { - memcpy(v3, v2, 9u); - v3 += 9; - } - v2 += 9; - --v4; - } while (v4); - return v3; + v2 = (unsigned char *)src; + v3 = (unsigned char *)dst; + v4 = MAXMONSTERS; + do { + if (*v2 == -1) { + *v3++ = -1; + } else { + memcpy(v3, v2, 9u); + v3 += 9; + } + v2 += 9; + --v4; + } while (v4); + return v3; } void *__fastcall DeltaExportJunk(void *dst) { - char *v1; // ebx - DJunk *v2; // edi - MultiQuests *v3; // esi - unsigned char *v4; // edi - int *v5; // ebp + char *v1; // ebx + DJunk *v2; // edi + MultiQuests *v3; // esi + unsigned char *v4; // edi + int *v5; // ebp - v1 = (char *)dst; - v2 = &sgJunk; - v3 = sgJunk.quests; - do { - if (v2->portal[0].x == LOBYTE(-1)) { - *v1++ = -1; - } else { - memcpy(v1, v2, 5u); - v1 += 5; - } - v2 = (DJunk *)((char *)v2 + 5); - } while ((signed int)v2 < (signed int)sgJunk.quests); - v4 = &quests[0]._qactive; - v5 = &questlist[0]._qflags; - do { - if (*(_BYTE *)v5 & 1) { - v3->qlog = v4[18]; - v3->qstate = *v4; - v3->qvar1 = v4[13]; - memcpy(v1, v3, 3u); - v1 += 3; - ++v3; - } - v5 += 5; - v4 += 24; - } while ((signed int)v5 < (signed int)&questlist[16]._qflags); - return v1; + v1 = (char *)dst; + v2 = &sgJunk; + v3 = sgJunk.quests; + do { + if (v2->portal[0].x == LOBYTE(-1)) { + *v1++ = -1; + } else { + memcpy(v1, v2, 5u); + v1 += 5; + } + v2 = (DJunk *)((char *)v2 + 5); + } while ((signed int)v2 < (signed int)sgJunk.quests); + v4 = &quests[0]._qactive; + v5 = &questlist[0]._qflags; + do { + if (*(_BYTE *)v5 & 1) { + v3->qlog = v4[18]; + v3->qstate = *v4; + v3->qvar1 = v4[13]; + memcpy(v1, v3, 3u); + v1 += 3; + ++v3; + } + v5 += 5; + v4 += 24; + } while ((signed int)v5 < (signed int)&questlist[16]._qflags); + return v1; } int __fastcall msg_comp_level(char *begin, void *end) { - char *v2; // esi - int v3; // edi - int v4; // eax + char *v2; // esi + int v3; // edi + int v4; // eax - v2 = begin; - v3 = (char *)end - begin - 1; - v4 = PkwareCompress(begin + 1, v3); - *v2 = v3 != v4; - return v4 + 1; + v2 = begin; + v3 = (char *)end - begin - 1; + v4 = PkwareCompress(begin + 1, v3); + *v2 = v3 != v4; + return v4 + 1; } void __cdecl delta_init() { - sgbDeltaChanged = 0; - memset(&sgJunk, 255, 0x20u); - memset(sgLevels, 255, 0x13981u); - memset(sgLocals, 0, 0x6A40u); - deltaload = 0; + sgbDeltaChanged = 0; + memset(&sgJunk, 255, 0x20u); + memset(sgLevels, 255, 0x13981u); + memset(sgLocals, 0, 0x6A40u); + deltaload = 0; } // 67618C: using guessed type char sgbDeltaChanged; // 676190: using guessed type int deltaload; void __fastcall delta_kill_monster(int mi, BYTE x, BYTE y, BYTE bLevel) { - DMonsterStr *v4; // eax - char v5; // cl + DMonsterStr *v4; // eax + char v5; // cl - if (gbMaxPlayers != 1) { - v4 = &sgLevels[bLevel].monster[mi]; - sgbDeltaChanged = 1; - v5 = monster[mi]._mdir; - v4->_mhitpoints = 0; - v4->_mx = x; - v4->_mdir = v5; - v4->_my = y; - } + if (gbMaxPlayers != 1) { + v4 = &sgLevels[bLevel].monster[mi]; + sgbDeltaChanged = 1; + v5 = monster[mi]._mdir; + v4->_mhitpoints = 0; + v4->_mx = x; + v4->_mdir = v5; + v4->_my = y; + } } // 67618C: using guessed type char sgbDeltaChanged; // 679660: using guessed type char gbMaxPlayers; void __fastcall delta_monster_hp(int mi, int hp, BYTE bLevel) { - DMonsterStr *v3; // eax + DMonsterStr *v3; // eax - if (gbMaxPlayers != 1) { - sgbDeltaChanged = 1; - v3 = &sgLevels[bLevel].monster[mi]; - if (v3->_mhitpoints > hp) - v3->_mhitpoints = hp; - } + if (gbMaxPlayers != 1) { + sgbDeltaChanged = 1; + v3 = &sgLevels[bLevel].monster[mi]; + if (v3->_mhitpoints > hp) + v3->_mhitpoints = hp; + } } // 67618C: using guessed type char sgbDeltaChanged; // 679660: using guessed type char gbMaxPlayers; void __fastcall delta_sync_monster(TCmdLocParam1 *packet, BYTE level) { - DMonsterStr *v2; // eax - char v3; // dl + DMonsterStr *v2; // eax + char v3; // dl - if (gbMaxPlayers != 1) { - sgbDeltaChanged = 1; - v2 = &sgLevels[(unsigned char)level].monster[(unsigned char)packet->bCmd]; - if (v2->_mhitpoints) { - v2->_mx = packet->x; - v3 = packet->y; - v2->_mactive = -1; - v2->_my = v3; - v2->_menemy = packet->wParam1; - } - } + if (gbMaxPlayers != 1) { + sgbDeltaChanged = 1; + v2 = &sgLevels[(unsigned char)level].monster[(unsigned char)packet->bCmd]; + if (v2->_mhitpoints) { + v2->_mx = packet->x; + v3 = packet->y; + v2->_mactive = -1; + v2->_my = v3; + v2->_menemy = packet->wParam1; + } + } } // 67618C: using guessed type char sgbDeltaChanged; // 679660: using guessed type char gbMaxPlayers; void __fastcall delta_sync_golem(TCmdGolem *pG, int pnum, BYTE bLevel) { - DMonsterStr *v3; // eax - char v4; // dl + DMonsterStr *v3; // eax + char v4; // dl - if (gbMaxPlayers != 1) { - sgbDeltaChanged = 1; - v3 = &sgLevels[(unsigned char)bLevel].monster[pnum]; - v3->_mx = pG->_mx; - v4 = pG->_my; - v3->_mactive = -1; - v3->_my = v4; - v3->_menemy = pG->_menemy; - v3->_mdir = pG->_mdir; - v3->_mhitpoints = pG->_mhitpoints; - } + if (gbMaxPlayers != 1) { + sgbDeltaChanged = 1; + v3 = &sgLevels[(unsigned char)bLevel].monster[pnum]; + v3->_mx = pG->_mx; + v4 = pG->_my; + v3->_mactive = -1; + v3->_my = v4; + v3->_menemy = pG->_menemy; + v3->_mdir = pG->_mdir; + v3->_mhitpoints = pG->_mhitpoints; + } } // 67618C: using guessed type char sgbDeltaChanged; // 679660: using guessed type char gbMaxPlayers; void __fastcall delta_leave_sync(BYTE bLevel) { - unsigned char v1; // bl - bool v2; // zf - int v3; // eax - int i; // ebp - int v5; // ecx - int v6; // esi - DMonsterStr *v7; // edi + unsigned char v1; // bl + bool v2; // zf + int v3; // eax + int i; // ebp + int v5; // ecx + int v6; // esi + DMonsterStr *v7; // edi - v1 = bLevel; - if (gbMaxPlayers != 1) { - v2 = currlevel == 0; - if (currlevel == 0) { - v3 = GetRndSeed(); - v2 = currlevel == 0; - glSeedTbl[0] = v3; - } - if (!v2) { - for (i = 0; i < nummonsters; ++i) { - v5 = monstactive[i]; - v6 = monstactive[i]; - if (monster[v6]._mhitpoints) { - sgbDeltaChanged = 1; - v7 = &sgLevels[v1].monster[v5]; - v7->_mx = monster[v6]._mx; - v7->_my = monster[v6]._my; - v7->_mdir = monster[v6]._mdir; - v7->_menemy = encode_enemy(v5); - v7->_mhitpoints = monster[v6]._mhitpoints; - v7->_mactive = monster[v6]._msquelch; - } - } - memcpy(&sgLocals[v1], automapview, 0x640u); - } - } + v1 = bLevel; + if (gbMaxPlayers != 1) { + v2 = currlevel == 0; + if (currlevel == 0) { + v3 = GetRndSeed(); + v2 = currlevel == 0; + glSeedTbl[0] = v3; + } + if (!v2) { + for (i = 0; i < nummonsters; ++i) { + v5 = monstactive[i]; + v6 = monstactive[i]; + if (monster[v6]._mhitpoints) { + sgbDeltaChanged = 1; + v7 = &sgLevels[v1].monster[v5]; + v7->_mx = monster[v6]._mx; + v7->_my = monster[v6]._my; + v7->_mdir = monster[v6]._mdir; + v7->_menemy = encode_enemy(v5); + v7->_mhitpoints = monster[v6]._mhitpoints; + v7->_mactive = monster[v6]._msquelch; + } + } + memcpy(&sgLocals[v1], automapview, 0x640u); + } + } } // 43C17D: could not find valid save-restore pair for edi // 67618C: using guessed type char sgbDeltaChanged; @@ -477,981 +477,981 @@ void __fastcall delta_leave_sync(BYTE bLevel) BOOL __fastcall delta_portal_inited(int i) { - return sgJunk.portal[i].x == LOBYTE(-1); + return sgJunk.portal[i].x == LOBYTE(-1); } BOOL __fastcall delta_quest_inited(int i) { - return sgJunk.quests[i].qstate != LOBYTE(-1); + return sgJunk.quests[i].qstate != LOBYTE(-1); } void __fastcall DeltaAddItem(int ii) { - int v1; // eax - int v2; // ecx - signed int v3; // ebp - DLevel *v4; // edx - DLevel *v5; // edi - char v6; // bl - int v7; // esi - signed int v8; // esi - int v9; // eax - char v10; // cl - char v11; // cl + int v1; // eax + int v2; // ecx + signed int v3; // ebp + DLevel *v4; // edx + DLevel *v5; // edi + char v6; // bl + int v7; // esi + signed int v8; // esi + int v9; // eax + char v10; // cl + char v11; // cl - v1 = ii; - if (gbMaxPlayers != 1) { - v2 = currlevel; - v3 = 0; - v4 = &sgLevels[v2]; - v5 = &sgLevels[v2]; - while (1) { - v6 = v5->item[0].bCmd; - if (v5->item[0].bCmd != -1) { - v7 = v1; - if ((unsigned short)v5->item[0].wIndx == item[v1].IDidx - && v5->item[0].wCI == item[v7]._iCreateInfo - && v5->item[0].dwSeed == item[v7]._iSeed - && (v6 == 1 || !v6)) { - break; - } - } - ++v3; - v5 = (DLevel *)((char *)v5 + 22); - if (v3 >= 127) { - v8 = 0; - while (v4->item[0].bCmd != -1) { - ++v8; - v4 = (DLevel *)((char *)v4 + 22); - if (v8 >= 127) - return; - } - v4->item[0].bCmd = 0; - v9 = 368 * v1; - v10 = *((_BYTE *)&item[0]._ix + v9); - sgbDeltaChanged = 1; - v4->item[0].x = v10; - v4->item[0].y = *((_BYTE *)&item[0]._iy + v9); - v4->item[0].wIndx = *(_WORD *)((char *)&item[0].IDidx + v9); - v4->item[0].wCI = *(short *)((char *)&item[0]._iCreateInfo + v9); - v4->item[0].dwSeed = *(int *)((char *)&item[0]._iSeed + v9); - v4->item[0].bId = *((_BYTE *)&item[0]._iIdentified + v9); - v4->item[0].bDur = *((_BYTE *)&item[0]._iDurability + v9); - v4->item[0].bMDur = *((_BYTE *)&item[0]._iMaxDur + v9); - v4->item[0].bCh = *((_BYTE *)&item[0]._iCharges + v9); - v11 = *((_BYTE *)&item[0]._iMaxCharges + v9); - _LOWORD(v9) = *(_WORD *)((char *)&item[0]._ivalue + v9); - v4->item[0].bMCh = v11; - v4->item[0].wValue = v9; - return; - } - } - } + v1 = ii; + if (gbMaxPlayers != 1) { + v2 = currlevel; + v3 = 0; + v4 = &sgLevels[v2]; + v5 = &sgLevels[v2]; + while (1) { + v6 = v5->item[0].bCmd; + if (v5->item[0].bCmd != -1) { + v7 = v1; + if ((unsigned short)v5->item[0].wIndx == item[v1].IDidx + && v5->item[0].wCI == item[v7]._iCreateInfo + && v5->item[0].dwSeed == item[v7]._iSeed + && (v6 == 1 || !v6)) { + break; + } + } + ++v3; + v5 = (DLevel *)((char *)v5 + 22); + if (v3 >= 127) { + v8 = 0; + while (v4->item[0].bCmd != -1) { + ++v8; + v4 = (DLevel *)((char *)v4 + 22); + if (v8 >= 127) + return; + } + v4->item[0].bCmd = 0; + v9 = 368 * v1; + v10 = *((_BYTE *)&item[0]._ix + v9); + sgbDeltaChanged = 1; + v4->item[0].x = v10; + v4->item[0].y = *((_BYTE *)&item[0]._iy + v9); + v4->item[0].wIndx = *(_WORD *)((char *)&item[0].IDidx + v9); + v4->item[0].wCI = *(short *)((char *)&item[0]._iCreateInfo + v9); + v4->item[0].dwSeed = *(int *)((char *)&item[0]._iSeed + v9); + v4->item[0].bId = *((_BYTE *)&item[0]._iIdentified + v9); + v4->item[0].bDur = *((_BYTE *)&item[0]._iDurability + v9); + v4->item[0].bMDur = *((_BYTE *)&item[0]._iMaxDur + v9); + v4->item[0].bCh = *((_BYTE *)&item[0]._iCharges + v9); + v11 = *((_BYTE *)&item[0]._iMaxCharges + v9); + _LOWORD(v9) = *(_WORD *)((char *)&item[0]._ivalue + v9); + v4->item[0].bMCh = v11; + v4->item[0].wValue = v9; + return; + } + } + } } // 67618C: using guessed type char sgbDeltaChanged; // 679660: using guessed type char gbMaxPlayers; void __cdecl DeltaSaveLevel() { - int v0; // eax - int v1; // edx - int *v2; // ecx - unsigned char v3; // cl + int v0; // eax + int v1; // edx + int *v2; // ecx + unsigned char v3; // cl - if (gbMaxPlayers != 1) { - v0 = myplr; - v1 = 0; - v2 = &plr[0]._pGFXLoad; - do { - if (v1 != v0) - *v2 = 0; - v2 += 5430; - ++v1; - } while ((signed int)v2 < (signed int)&plr[4]._pGFXLoad); - v3 = currlevel; - plr[v0]._pLvlVisited[currlevel] = 1; - delta_leave_sync(v3); - } + if (gbMaxPlayers != 1) { + v0 = myplr; + v1 = 0; + v2 = &plr[0]._pGFXLoad; + do { + if (v1 != v0) + *v2 = 0; + v2 += 5430; + ++v1; + } while ((signed int)v2 < (signed int)&plr[4]._pGFXLoad); + v3 = currlevel; + plr[v0]._pLvlVisited[currlevel] = 1; + delta_leave_sync(v3); + } } // 679660: using guessed type char gbMaxPlayers; void __cdecl DeltaLoadLevel() { - int v0; // ebx - int *v1; // esi - int v2; // eax - int v3; // ecx - int v4; // edx - int v5; // edi - char v6; // al - int v7; // eax - signed int v8; // esi - int v9; // eax - char v10; // cl - int v11; // eax - char *v12; // edx - int v13; // eax - int v14; // ebx - int *v15; // edx - unsigned short v16; // cx - int v17; // ST1C_4 - int v18; // ST18_4 - int v19; // eax - int v20; // ecx - int v21; // edx - int v22; // eax - int v23; // eax - int v24; // esi - int v25; // edi - int v26; // eax - int v27; // eax - int v28; // esi - unsigned char v29; // al - int j; // esi - int v31; // eax - signed int v32; // [esp+0h] [ebp-24h] - int v33; // [esp+4h] [ebp-20h] - int o2; // [esp+8h] [ebp-1Ch] - int i; // [esp+Ch] [ebp-18h] - signed int v36; // [esp+10h] [ebp-14h] - int v37; // [esp+14h] [ebp-10h] - signed int v38; // [esp+18h] [ebp-Ch] - signed int v39; // [esp+1Ch] [ebp-8h] - int v40; // [esp+20h] [ebp-4h] - signed int v41; // [esp+20h] [ebp-4h] + int v0; // ebx + int *v1; // esi + int v2; // eax + int v3; // ecx + int v4; // edx + int v5; // edi + char v6; // al + int v7; // eax + signed int v8; // esi + int v9; // eax + char v10; // cl + int v11; // eax + char *v12; // edx + int v13; // eax + int v14; // ebx + int *v15; // edx + unsigned short v16; // cx + int v17; // ST1C_4 + int v18; // ST18_4 + int v19; // eax + int v20; // ecx + int v21; // edx + int v22; // eax + int v23; // eax + int v24; // esi + int v25; // edi + int v26; // eax + int v27; // eax + int v28; // esi + unsigned char v29; // al + int j; // esi + int v31; // eax + signed int v32; // [esp+0h] [ebp-24h] + int v33; // [esp+4h] [ebp-20h] + int o2; // [esp+8h] [ebp-1Ch] + int i; // [esp+Ch] [ebp-18h] + signed int v36; // [esp+10h] [ebp-14h] + int v37; // [esp+14h] [ebp-10h] + signed int v38; // [esp+18h] [ebp-Ch] + signed int v39; // [esp+1Ch] [ebp-8h] + int v40; // [esp+20h] [ebp-4h] + signed int v41; // [esp+20h] [ebp-4h] - if (gbMaxPlayers != 1) { - deltaload = 1; - if (currlevel != 0) { - v0 = 0; - if (nummonsters > 0) { - v40 = 0; - v1 = &monster[0]._mfuty; - do { - if (sgLevels[currlevel].monster[v40]._mx != -1) { - M_ClearSquares(v0); - v2 = v40 * 9 + 4721 * currlevel; - v3 = *((unsigned char *)&sgLevels[0].monster[0]._mx + v2); - v4 = *((unsigned char *)&sgLevels[0].monster[0]._my + v2); - v5 = *(int *)((char *)&sgLevels[0].monster[0]._mhitpoints + v2); - *(v1 - 3) = v3; - *(v1 - 2) = v4; - v1[1] = v3; - v1[2] = v4; - *(v1 - 1) = v3; - *v1 = v4; - if (v5 != -1) - v1[26] = v5; - if (v5) { - decode_enemy(v0, *((unsigned char *)&sgLevels[0].monster[0]._menemy + v2)); - v7 = *(v1 - 3); - if (v7 && v7 != 1 || *(v1 - 2)) - dMonster[0][*(v1 - 2) + 112 * v7] = v0 + 1; - if ((signed int)v1 >= (signed int)&monster[4]._mfuty) { - M_StartStand(v0, v1[7]); - } else { - MAI_Golum(v0); - v1[28] |= 0x30u; - } - *((_BYTE *)v1 + 116) = sgLevels[currlevel].monster[v40]._mactive; - } else { - v1[1] = v3; - v1[2] = v4; - M_ClearSquares(v0); - if (*((_BYTE *)v1 + 108) != 27) { - if (*((_BYTE *)v1 + 144)) - v6 = *((_BYTE *)v1 + 146); - else - v6 = *(_BYTE *)(v1[44] + 317); - AddDead(*(v1 - 3), *(v1 - 2), v6, (direction)v1[7]); - } - v1[16] = 1; - M_UpdateLeader(v0); - } - } - ++v40; - ++v0; - v1 += 57; - } while (v0 < nummonsters); - } - memcpy(automapview, &sgLocals[currlevel], 0x640u); - } - v8 = 0; - i = 0; - v32 = 0; - do { - v9 = v8 + 4721 * currlevel; - v10 = *(&sgLevels[0].item[0].bCmd + v9); - if (v10 != -1) { - if (v10 == 1) { - v11 = FindGetItem( - *(unsigned short *)((char *)&sgLevels[0].item[0].wIndx + v9), - *(short *)((char *)&sgLevels[0].item[0].wCI + v9), - *(int *)((char *)&sgLevels[0].item[0].dwSeed + v9)); - if (v11 != -1) { - v12 = &dItem[item[v11]._ix][item[v11]._iy]; - if (*v12 == v11 + 1) - *v12 = 0; - DeleteItem(v11, i); - } - } - v13 = v8 + 4721 * currlevel; - if (*(&sgLevels[0].item[0].bCmd + v13) == 2) { - v14 = itemavail[0]; - v33 = itemavail[0]; - v15 = &itemavail[MAXITEMS - numitems - 1]; - itemactive[numitems] = itemavail[0]; - v16 = *(short *)((char *)&sgLevels[0].item[0].wIndx + v13); - itemavail[0] = *v15; - if (v16 == IDI_EAR) { - RecreateEar( - v14, - *(short *)((char *)&sgLevels[0].item[0].wCI + v13), - *(int *)((char *)&sgLevels[0].item[0].dwSeed + v13), - *(&sgLevels[0].item[0].bId + v13), - *((unsigned char *)&sgLevels[0].item[0].bDur + v13), - *((unsigned char *)&sgLevels[0].item[0].bMDur + v13), - *((unsigned char *)&sgLevels[0].item[0].bCh + v13), - *((unsigned char *)&sgLevels[0].item[0].bMCh + v13), - *(unsigned short *)((char *)&sgLevels[0].item[0].wValue + v13), - *(int *)((char *)&sgLevels[0].item[0].dwBuff + v13)); - } else { - v17 = *(unsigned short *)((char *)&sgLevels[0].item[0].wValue + v13); - v18 = *(int *)((char *)&sgLevels[0].item[0].dwSeed + v13); - _LOWORD(v13) = *(short *)((char *)&sgLevels[0].item[0].wCI + v13); - RecreateItem(v14, v16, v13, v18, v17); - v19 = v8 + 4721 * currlevel; - if (*(&sgLevels[0].item[0].bId + v19)) - item[v14]._iIdentified = TRUE; - v20 = v14; - item[v20]._iDurability = *((unsigned char *)&sgLevels[0].item[0].bDur + v19); - item[v20]._iMaxDur = *((unsigned char *)&sgLevels[0].item[0].bMDur + v19); - v21 = *((unsigned char *)&sgLevels[0].item[0].bCh + v19); - v22 = *((unsigned char *)&sgLevels[0].item[0].bMCh + v19); - item[v20]._iCharges = v21; - item[v20]._iMaxCharges = v22; - } - v23 = v8 + 4721 * currlevel; - v24 = *((unsigned char *)&sgLevels[0].item[0].x + v23); - v25 = *((unsigned char *)&sgLevels[0].item[0].y + v23); - if (!CanPut(v24, v25)) { - v39 = 0; - v26 = -1; - v41 = 1; - v36 = -1; - do { - if (v39) - break; - v37 = v26; - while (v26 <= v41 && !v39) { - o2 = v25 + v37; - v38 = v36; - do { - if (v39) - break; - if (CanPut(v38 + v24, o2)) { - v25 = o2; - v39 = 1; - v24 += v38; - } - ++v38; - v14 = v33; - } while (v38 <= v41); - v26 = ++v37; - } - ++v41; - v26 = v36-- - 1; - } while (v36 > -50); - } - v27 = v14; - item[v27]._ix = v24; - item[v27]._iy = v25; - dItem[v24][v25] = v14 + 1; - RespawnItem(v14, 0); - ++numitems; - v8 = v32; - } - } - ++i; - v8 += 22; - v32 = v8; - } while (v8 < 2794); - if (currlevel != 0) { - v28 = 0; - do { - v29 = sgLevels[currlevel].object[v28].bCmd; - if (v29 >= CMD_OPENDOOR) { - if (v29 <= CMD_PLROPOBJ) { - SyncOpObject(-1, v29, v28); - } else if (v29 == CMD_BREAKOBJ) { - SyncBreakObj(-1, v28); - } - } - ++v28; - } while (v28 < 127); - for (j = 0; j < nobjects; ++j) { - v31 = object[objectactive[j]]._otype; - if (v31 == OBJ_TRAPL || v31 == OBJ_TRAPR) - Obj_Trap(objectactive[j]); - } - } - deltaload = 0; - } + if (gbMaxPlayers != 1) { + deltaload = 1; + if (currlevel != 0) { + v0 = 0; + if (nummonsters > 0) { + v40 = 0; + v1 = &monster[0]._mfuty; + do { + if (sgLevels[currlevel].monster[v40]._mx != -1) { + M_ClearSquares(v0); + v2 = v40 * 9 + 4721 * currlevel; + v3 = *((unsigned char *)&sgLevels[0].monster[0]._mx + v2); + v4 = *((unsigned char *)&sgLevels[0].monster[0]._my + v2); + v5 = *(int *)((char *)&sgLevels[0].monster[0]._mhitpoints + v2); + *(v1 - 3) = v3; + *(v1 - 2) = v4; + v1[1] = v3; + v1[2] = v4; + *(v1 - 1) = v3; + *v1 = v4; + if (v5 != -1) + v1[26] = v5; + if (v5) { + decode_enemy(v0, *((unsigned char *)&sgLevels[0].monster[0]._menemy + v2)); + v7 = *(v1 - 3); + if (v7 && v7 != 1 || *(v1 - 2)) + dMonster[0][*(v1 - 2) + 112 * v7] = v0 + 1; + if ((signed int)v1 >= (signed int)&monster[4]._mfuty) { + M_StartStand(v0, v1[7]); + } else { + MAI_Golum(v0); + v1[28] |= 0x30u; + } + *((_BYTE *)v1 + 116) = sgLevels[currlevel].monster[v40]._mactive; + } else { + v1[1] = v3; + v1[2] = v4; + M_ClearSquares(v0); + if (*((_BYTE *)v1 + 108) != 27) { + if (*((_BYTE *)v1 + 144)) + v6 = *((_BYTE *)v1 + 146); + else + v6 = *(_BYTE *)(v1[44] + 317); + AddDead(*(v1 - 3), *(v1 - 2), v6, (direction)v1[7]); + } + v1[16] = 1; + M_UpdateLeader(v0); + } + } + ++v40; + ++v0; + v1 += 57; + } while (v0 < nummonsters); + } + memcpy(automapview, &sgLocals[currlevel], 0x640u); + } + v8 = 0; + i = 0; + v32 = 0; + do { + v9 = v8 + 4721 * currlevel; + v10 = *(&sgLevels[0].item[0].bCmd + v9); + if (v10 != -1) { + if (v10 == 1) { + v11 = FindGetItem( + *(unsigned short *)((char *)&sgLevels[0].item[0].wIndx + v9), + *(short *)((char *)&sgLevels[0].item[0].wCI + v9), + *(int *)((char *)&sgLevels[0].item[0].dwSeed + v9)); + if (v11 != -1) { + v12 = &dItem[item[v11]._ix][item[v11]._iy]; + if (*v12 == v11 + 1) + *v12 = 0; + DeleteItem(v11, i); + } + } + v13 = v8 + 4721 * currlevel; + if (*(&sgLevels[0].item[0].bCmd + v13) == 2) { + v14 = itemavail[0]; + v33 = itemavail[0]; + v15 = &itemavail[MAXITEMS - numitems - 1]; + itemactive[numitems] = itemavail[0]; + v16 = *(short *)((char *)&sgLevels[0].item[0].wIndx + v13); + itemavail[0] = *v15; + if (v16 == IDI_EAR) { + RecreateEar( + v14, + *(short *)((char *)&sgLevels[0].item[0].wCI + v13), + *(int *)((char *)&sgLevels[0].item[0].dwSeed + v13), + *(&sgLevels[0].item[0].bId + v13), + *((unsigned char *)&sgLevels[0].item[0].bDur + v13), + *((unsigned char *)&sgLevels[0].item[0].bMDur + v13), + *((unsigned char *)&sgLevels[0].item[0].bCh + v13), + *((unsigned char *)&sgLevels[0].item[0].bMCh + v13), + *(unsigned short *)((char *)&sgLevels[0].item[0].wValue + v13), + *(int *)((char *)&sgLevels[0].item[0].dwBuff + v13)); + } else { + v17 = *(unsigned short *)((char *)&sgLevels[0].item[0].wValue + v13); + v18 = *(int *)((char *)&sgLevels[0].item[0].dwSeed + v13); + _LOWORD(v13) = *(short *)((char *)&sgLevels[0].item[0].wCI + v13); + RecreateItem(v14, v16, v13, v18, v17); + v19 = v8 + 4721 * currlevel; + if (*(&sgLevels[0].item[0].bId + v19)) + item[v14]._iIdentified = TRUE; + v20 = v14; + item[v20]._iDurability = *((unsigned char *)&sgLevels[0].item[0].bDur + v19); + item[v20]._iMaxDur = *((unsigned char *)&sgLevels[0].item[0].bMDur + v19); + v21 = *((unsigned char *)&sgLevels[0].item[0].bCh + v19); + v22 = *((unsigned char *)&sgLevels[0].item[0].bMCh + v19); + item[v20]._iCharges = v21; + item[v20]._iMaxCharges = v22; + } + v23 = v8 + 4721 * currlevel; + v24 = *((unsigned char *)&sgLevels[0].item[0].x + v23); + v25 = *((unsigned char *)&sgLevels[0].item[0].y + v23); + if (!CanPut(v24, v25)) { + v39 = 0; + v26 = -1; + v41 = 1; + v36 = -1; + do { + if (v39) + break; + v37 = v26; + while (v26 <= v41 && !v39) { + o2 = v25 + v37; + v38 = v36; + do { + if (v39) + break; + if (CanPut(v38 + v24, o2)) { + v25 = o2; + v39 = 1; + v24 += v38; + } + ++v38; + v14 = v33; + } while (v38 <= v41); + v26 = ++v37; + } + ++v41; + v26 = v36-- - 1; + } while (v36 > -50); + } + v27 = v14; + item[v27]._ix = v24; + item[v27]._iy = v25; + dItem[v24][v25] = v14 + 1; + RespawnItem(v14, 0); + ++numitems; + v8 = v32; + } + } + ++i; + v8 += 22; + v32 = v8; + } while (v8 < 2794); + if (currlevel != 0) { + v28 = 0; + do { + v29 = sgLevels[currlevel].object[v28].bCmd; + if (v29 >= CMD_OPENDOOR) { + if (v29 <= CMD_PLROPOBJ) { + SyncOpObject(-1, v29, v28); + } else if (v29 == CMD_BREAKOBJ) { + SyncBreakObj(-1, v28); + } + } + ++v28; + } while (v28 < 127); + for (j = 0; j < nobjects; ++j) { + v31 = object[objectactive[j]]._otype; + if (v31 == OBJ_TRAPL || v31 == OBJ_TRAPR) + Obj_Trap(objectactive[j]); + } + } + deltaload = 0; + } } // 676190: using guessed type int deltaload; // 679660: using guessed type char gbMaxPlayers; void __fastcall NetSendCmd(BOOL bHiPri, BYTE bCmd) { - TCmd cmd; // [esp+3h] [ebp-1h] + TCmd cmd; // [esp+3h] [ebp-1h] - cmd.bCmd = bCmd; - if (bHiPri) - NetSendHiPri((unsigned char *)&cmd, 1u); - else - NetSendLoPri((unsigned char *)&cmd, 1u); + cmd.bCmd = bCmd; + if (bHiPri) + NetSendHiPri((unsigned char *)&cmd, 1u); + else + NetSendLoPri((unsigned char *)&cmd, 1u); } void __fastcall NetSendCmdGolem(BYTE mx, BYTE my, BYTE dir, BYTE menemy, int hp, int cl) { - TCmdGolem cmd; // [esp+0h] [ebp-Ch] + TCmdGolem cmd; // [esp+0h] [ebp-Ch] - cmd._mx = mx; - cmd._mdir = dir; - cmd._menemy = menemy; - cmd._mhitpoints = hp; - cmd._my = my; - cmd.bCmd = CMD_AWAKEGOLEM; - cmd._currlevel = cl; - NetSendLoPri((unsigned char *)&cmd, 0xAu); + cmd._mx = mx; + cmd._mdir = dir; + cmd._menemy = menemy; + cmd._mhitpoints = hp; + cmd._my = my; + cmd.bCmd = CMD_AWAKEGOLEM; + cmd._currlevel = cl; + NetSendLoPri((unsigned char *)&cmd, 0xAu); } void __fastcall NetSendCmdLoc(BOOL bHiPri, BYTE bCmd, BYTE x, BYTE y) { - TCmdLoc cmd; // [esp+1h] [ebp-3h] + TCmdLoc cmd; // [esp+1h] [ebp-3h] - cmd.bCmd = bCmd; - cmd.x = x; - cmd.y = y; - if (bHiPri) - NetSendHiPri((unsigned char *)&cmd, 3u); - else - NetSendLoPri((unsigned char *)&cmd, 3u); + cmd.bCmd = bCmd; + cmd.x = x; + cmd.y = y; + if (bHiPri) + NetSendHiPri((unsigned char *)&cmd, 3u); + else + NetSendLoPri((unsigned char *)&cmd, 3u); } void __fastcall NetSendCmdLocParam1(BOOL bHiPri, BYTE bCmd, BYTE x, BYTE y, WORD wParam1) { - TCmdLocParam1 cmd; // [esp+0h] [ebp-8h] + TCmdLocParam1 cmd; // [esp+0h] [ebp-8h] - cmd.bCmd = bCmd; - cmd.x = x; - cmd.y = y; - cmd.wParam1 = wParam1; - if (bHiPri) - NetSendHiPri((unsigned char *)&cmd, 5u); - else - NetSendLoPri((unsigned char *)&cmd, 5u); + cmd.bCmd = bCmd; + cmd.x = x; + cmd.y = y; + cmd.wParam1 = wParam1; + if (bHiPri) + NetSendHiPri((unsigned char *)&cmd, 5u); + else + NetSendLoPri((unsigned char *)&cmd, 5u); } void __fastcall NetSendCmdLocParam2(BOOL bHiPri, BYTE bCmd, BYTE x, BYTE y, WORD wParam1, WORD wParam2) { - TCmdLocParam2 cmd; // [esp+0h] [ebp-8h] + TCmdLocParam2 cmd; // [esp+0h] [ebp-8h] - cmd.bCmd = bCmd; - cmd.x = x; - cmd.y = y; - cmd.wParam1 = wParam1; - cmd.wParam2 = wParam2; - if (bHiPri) - NetSendHiPri((unsigned char *)&cmd, 7u); - else - NetSendLoPri((unsigned char *)&cmd, 7u); + cmd.bCmd = bCmd; + cmd.x = x; + cmd.y = y; + cmd.wParam1 = wParam1; + cmd.wParam2 = wParam2; + if (bHiPri) + NetSendHiPri((unsigned char *)&cmd, 7u); + else + NetSendLoPri((unsigned char *)&cmd, 7u); } void __fastcall NetSendCmdLocParam3(BOOL bHiPri, BYTE bCmd, BYTE x, BYTE y, WORD wParam1, WORD wParam2, WORD wParam3) { - TCmdLocParam3 cmd; // [esp+0h] [ebp-Ch] + TCmdLocParam3 cmd; // [esp+0h] [ebp-Ch] - cmd.bCmd = bCmd; - cmd.x = x; - cmd.y = y; - cmd.wParam1 = wParam1; - cmd.wParam2 = wParam2; - cmd.wParam3 = wParam3; - if (bHiPri) - NetSendHiPri((unsigned char *)&cmd, 9u); - else - NetSendLoPri((unsigned char *)&cmd, 9u); + cmd.bCmd = bCmd; + cmd.x = x; + cmd.y = y; + cmd.wParam1 = wParam1; + cmd.wParam2 = wParam2; + cmd.wParam3 = wParam3; + if (bHiPri) + NetSendHiPri((unsigned char *)&cmd, 9u); + else + NetSendLoPri((unsigned char *)&cmd, 9u); } void __fastcall NetSendCmdParam1(BOOL bHiPri, BYTE bCmd, WORD wParam1) { - TCmdParam1 cmd; // [esp+1h] [ebp-3h] + TCmdParam1 cmd; // [esp+1h] [ebp-3h] - cmd.bCmd = bCmd; - cmd.wParam1 = wParam1; - if (bHiPri) - NetSendHiPri((unsigned char *)&cmd, 3u); - else - NetSendLoPri((unsigned char *)&cmd, 3u); + cmd.bCmd = bCmd; + cmd.wParam1 = wParam1; + if (bHiPri) + NetSendHiPri((unsigned char *)&cmd, 3u); + else + NetSendLoPri((unsigned char *)&cmd, 3u); } void __fastcall NetSendCmdParam2(BOOL bHiPri, BYTE bCmd, WORD wParam1, WORD wParam2) { - TCmdParam2 cmd; // [esp+0h] [ebp-8h] + TCmdParam2 cmd; // [esp+0h] [ebp-8h] - cmd.bCmd = bCmd; - cmd.wParam1 = wParam1; - cmd.wParam2 = wParam2; - if (bHiPri) - NetSendHiPri((unsigned char *)&cmd, 5u); - else - NetSendLoPri((unsigned char *)&cmd, 5u); + cmd.bCmd = bCmd; + cmd.wParam1 = wParam1; + cmd.wParam2 = wParam2; + if (bHiPri) + NetSendHiPri((unsigned char *)&cmd, 5u); + else + NetSendLoPri((unsigned char *)&cmd, 5u); } void __fastcall NetSendCmdParam3(BOOL bHiPri, BYTE bCmd, WORD wParam1, WORD wParam2, WORD wParam3) { - TCmdParam3 cmd; // [esp+0h] [ebp-8h] + TCmdParam3 cmd; // [esp+0h] [ebp-8h] - cmd.bCmd = bCmd; - cmd.wParam1 = wParam1; - cmd.wParam2 = wParam2; - cmd.wParam3 = wParam3; - if (bHiPri) - NetSendHiPri((unsigned char *)&cmd, 7u); - else - NetSendLoPri((unsigned char *)&cmd, 7u); + cmd.bCmd = bCmd; + cmd.wParam1 = wParam1; + cmd.wParam2 = wParam2; + cmd.wParam3 = wParam3; + if (bHiPri) + NetSendHiPri((unsigned char *)&cmd, 7u); + else + NetSendLoPri((unsigned char *)&cmd, 7u); } void __fastcall NetSendCmdQuest(BOOL bHiPri, BYTE q) { - int v2; // eax - char v3; // dl - TCmdQuest cmd; // [esp+0h] [ebp-8h] + int v2; // eax + char v3; // dl + TCmdQuest cmd; // [esp+0h] [ebp-8h] - cmd.q = q; - cmd.bCmd = CMD_SYNCQUEST; - v2 = 24 * q; - cmd.qstate = *(&quests[0]._qactive + v2); - v3 = *((_BYTE *)&quests[0]._qlog + v2); - _LOBYTE(v2) = *(&quests[0]._qvar1 + v2); - cmd.qlog = v3; - cmd.qvar1 = v2; - if (bHiPri) - NetSendHiPri((unsigned char *)&cmd, 5u); - else - NetSendLoPri((unsigned char *)&cmd, 5u); + cmd.q = q; + cmd.bCmd = CMD_SYNCQUEST; + v2 = 24 * q; + cmd.qstate = *(&quests[0]._qactive + v2); + v3 = *((_BYTE *)&quests[0]._qlog + v2); + _LOBYTE(v2) = *(&quests[0]._qvar1 + v2); + cmd.qlog = v3; + cmd.qvar1 = v2; + if (bHiPri) + NetSendHiPri((unsigned char *)&cmd, 5u); + else + NetSendLoPri((unsigned char *)&cmd, 5u); } void __fastcall NetSendCmdGItem(BOOL bHiPri, BYTE bCmd, BYTE mast, BYTE pnum, int ii) { - int v5; // eax - bool v6; // zf - short v7; // dx - short v8; // bx - int v9; // esi - int v10; // esi - char v11; // dl - short v12; // ax - TCmdGItem cmd; // [esp+4h] [ebp-20h] + int v5; // eax + bool v6; // zf + short v7; // dx + short v8; // bx + int v9; // esi + int v10; // esi + char v11; // dl + short v12; // ax + TCmdGItem cmd; // [esp+4h] [ebp-20h] - cmd.bCmd = bCmd; - cmd.bPnum = pnum; - cmd.bMaster = mast; - cmd.bLevel = currlevel; - cmd.bCursitem = ii; - cmd.dwTime = 0; - v5 = (unsigned char)ii; - cmd.x = item[v5]._ix; - cmd.y = item[v5]._iy; - v6 = item[v5].IDidx == IDI_EAR; - cmd.wIndx = item[v5].IDidx; - if (v6) { - _LOBYTE(v7) = 0; - _HIBYTE(v7) = item[v5]._iName[7]; - _LOBYTE(v8) = 0; - _HIBYTE(v8) = item[v5]._iName[18]; - v9 = item[v5]._iName[10]; - cmd.wCI = item[v5]._iName[8] | v7; - cmd.dwSeed = item[v5]._iName[12] | ((item[v5]._iName[11] | ((v9 | (item[v5]._iName[9] << 8)) << 8)) << 8); - cmd.bId = item[v5]._iName[13]; - cmd.bDur = item[v5]._iName[14]; - cmd.bMDur = item[v5]._iName[15]; - cmd.bCh = item[v5]._iName[16]; - cmd.bMCh = item[v5]._iName[17]; - v10 = item[v5]._iName[20]; - cmd.wValue = _LOWORD(item[v5]._ivalue) | v8 | ((_LOWORD(item[v5]._iCurs) - 19) << 6); - cmd.dwBuff = item[v5]._iName[22] | ((item[v5]._iName[21] | ((v10 | (item[v5]._iName[19] << 8)) << 8)) << 8); - } else { - cmd.wCI = item[v5]._iCreateInfo; - cmd.dwSeed = item[v5]._iSeed; - cmd.bId = item[v5]._iIdentified; - cmd.bDur = item[v5]._iDurability; - cmd.bMDur = item[v5]._iMaxDur; - cmd.bCh = item[v5]._iCharges; - v11 = item[v5]._iMaxCharges; - v12 = item[v5]._ivalue; - cmd.bMCh = v11; - cmd.wValue = v12; - } - if (bHiPri) - NetSendHiPri((unsigned char *)&cmd, 0x1Eu); - else - NetSendLoPri((unsigned char *)&cmd, 0x1Eu); + cmd.bCmd = bCmd; + cmd.bPnum = pnum; + cmd.bMaster = mast; + cmd.bLevel = currlevel; + cmd.bCursitem = ii; + cmd.dwTime = 0; + v5 = (unsigned char)ii; + cmd.x = item[v5]._ix; + cmd.y = item[v5]._iy; + v6 = item[v5].IDidx == IDI_EAR; + cmd.wIndx = item[v5].IDidx; + if (v6) { + _LOBYTE(v7) = 0; + _HIBYTE(v7) = item[v5]._iName[7]; + _LOBYTE(v8) = 0; + _HIBYTE(v8) = item[v5]._iName[18]; + v9 = item[v5]._iName[10]; + cmd.wCI = item[v5]._iName[8] | v7; + cmd.dwSeed = item[v5]._iName[12] | ((item[v5]._iName[11] | ((v9 | (item[v5]._iName[9] << 8)) << 8)) << 8); + cmd.bId = item[v5]._iName[13]; + cmd.bDur = item[v5]._iName[14]; + cmd.bMDur = item[v5]._iName[15]; + cmd.bCh = item[v5]._iName[16]; + cmd.bMCh = item[v5]._iName[17]; + v10 = item[v5]._iName[20]; + cmd.wValue = _LOWORD(item[v5]._ivalue) | v8 | ((_LOWORD(item[v5]._iCurs) - 19) << 6); + cmd.dwBuff = item[v5]._iName[22] | ((item[v5]._iName[21] | ((v10 | (item[v5]._iName[19] << 8)) << 8)) << 8); + } else { + cmd.wCI = item[v5]._iCreateInfo; + cmd.dwSeed = item[v5]._iSeed; + cmd.bId = item[v5]._iIdentified; + cmd.bDur = item[v5]._iDurability; + cmd.bMDur = item[v5]._iMaxDur; + cmd.bCh = item[v5]._iCharges; + v11 = item[v5]._iMaxCharges; + v12 = item[v5]._ivalue; + cmd.bMCh = v11; + cmd.wValue = v12; + } + if (bHiPri) + NetSendHiPri((unsigned char *)&cmd, 0x1Eu); + else + NetSendLoPri((unsigned char *)&cmd, 0x1Eu); } void __fastcall NetSendCmdGItem2(BOOL usonly, BYTE bCmd, BYTE mast, BYTE pnum, struct TCmdGItem *p) { - unsigned char v5; // bl - int v7; // eax - TCmdGItem cmd; // [esp+8h] [ebp-20h] + unsigned char v5; // bl + int v7; // eax + TCmdGItem cmd; // [esp+8h] [ebp-20h] - v5 = bCmd; - memcpy(&cmd, p, 0x1Eu); - cmd.bPnum = pnum; - cmd.bCmd = v5; - cmd.bMaster = mast; - if (!usonly) { - cmd.dwTime = 0; - NetSendHiPri((unsigned char *)&cmd, 0x1Eu); - return; - } - v7 = GetTickCount(); - if (cmd.dwTime) { - if (v7 - cmd.dwTime > 5000) - return; - } else { - cmd.dwTime = v7; - } - multi_msg_add(&cmd.bCmd, 0x1Eu); + v5 = bCmd; + memcpy(&cmd, p, 0x1Eu); + cmd.bPnum = pnum; + cmd.bCmd = v5; + cmd.bMaster = mast; + if (!usonly) { + cmd.dwTime = 0; + NetSendHiPri((unsigned char *)&cmd, 0x1Eu); + return; + } + v7 = GetTickCount(); + if (cmd.dwTime) { + if (v7 - cmd.dwTime > 5000) + return; + } else { + cmd.dwTime = v7; + } + multi_msg_add(&cmd.bCmd, 0x1Eu); } BOOL __fastcall NetSendCmdReq2(BYTE bCmd, BYTE mast, BYTE pnum, struct TCmdGItem *p) { - unsigned char v4; // bl - int v5; // eax - TCmdGItem cmd; // [esp+4h] [ebp-24h] - unsigned char v8; // [esp+24h] [ebp-4h] + unsigned char v4; // bl + int v5; // eax + TCmdGItem cmd; // [esp+4h] [ebp-24h] + unsigned char v8; // [esp+24h] [ebp-4h] - v4 = mast; - v8 = bCmd; - memcpy(&cmd, p, 0x1Eu); - cmd.bCmd = v8; - cmd.bPnum = pnum; - cmd.bMaster = v4; - v5 = GetTickCount(); - if (!cmd.dwTime) { - cmd.dwTime = v5; - LABEL_3: - multi_msg_add(&cmd.bCmd, 0x1Eu); - return 1; - } - if (v5 - cmd.dwTime <= 5000) - goto LABEL_3; - return 0; + v4 = mast; + v8 = bCmd; + memcpy(&cmd, p, 0x1Eu); + cmd.bCmd = v8; + cmd.bPnum = pnum; + cmd.bMaster = v4; + v5 = GetTickCount(); + if (!cmd.dwTime) { + cmd.dwTime = v5; + LABEL_3: + multi_msg_add(&cmd.bCmd, 0x1Eu); + return 1; + } + if (v5 - cmd.dwTime <= 5000) + goto LABEL_3; + return 0; } void __fastcall NetSendCmdExtra(struct TCmdGItem *p) { - TCmdGItem cmd; // [esp+0h] [ebp-20h] + TCmdGItem cmd; // [esp+0h] [ebp-20h] - memcpy(&cmd, p, 0x1Eu); - cmd.dwTime = 0; - cmd.bCmd = CMD_ITEMEXTRA; - NetSendHiPri((unsigned char *)&cmd, 0x1Eu); + memcpy(&cmd, p, 0x1Eu); + cmd.dwTime = 0; + cmd.bCmd = CMD_ITEMEXTRA; + NetSendHiPri((unsigned char *)&cmd, 0x1Eu); } void __fastcall NetSendCmdPItem(BOOL bHiPri, BYTE bCmd, BYTE x, BYTE y) { - int v4; // eax - short *v5; // edx - bool v6; // zf - short v7; // dx - short v8; // bx - int v9; // esi - int v10; // esi - char v11; // dl - short v12; // ax - TCmdPItem cmd; // [esp+4h] [ebp-18h] + int v4; // eax + short *v5; // edx + bool v6; // zf + short v7; // dx + short v8; // bx + int v9; // esi + int v10; // esi + char v11; // dl + short v12; // ax + TCmdPItem cmd; // [esp+4h] [ebp-18h] - cmd.bCmd = bCmd; - cmd.x = x; - cmd.y = y; - v4 = myplr; - v5 = (short *)&plr[myplr].HoldItem.IDidx; - v6 = *(_DWORD *)v5 == IDI_EAR; - cmd.wIndx = *v5; - if (v6) { - _LOBYTE(v7) = 0; - _HIBYTE(v7) = plr[v4].HoldItem._iName[7]; - _LOBYTE(v8) = 0; - _HIBYTE(v8) = plr[v4].HoldItem._iName[18]; - v9 = plr[v4].HoldItem._iName[10]; - cmd.wCI = plr[v4].HoldItem._iName[8] | v7; - cmd.dwSeed = plr[v4].HoldItem._iName[12] | ((plr[v4].HoldItem._iName[11] | ((v9 | (plr[v4].HoldItem._iName[9] << 8)) << 8)) << 8); - cmd.bId = plr[v4].HoldItem._iName[13]; - cmd.bDur = plr[v4].HoldItem._iName[14]; - cmd.bMDur = plr[v4].HoldItem._iName[15]; - cmd.bCh = plr[v4].HoldItem._iName[16]; - cmd.bMCh = plr[v4].HoldItem._iName[17]; - v10 = plr[v4].HoldItem._iName[20]; - cmd.wValue = _LOWORD(plr[v4].HoldItem._ivalue) | v8 | ((_LOWORD(plr[v4].HoldItem._iCurs) - 19) << 6); - cmd.dwBuff = plr[v4].HoldItem._iName[22] | ((plr[v4].HoldItem._iName[21] | ((v10 | (plr[v4].HoldItem._iName[19] << 8)) << 8)) << 8); - } else { - cmd.wCI = plr[v4].HoldItem._iCreateInfo; - cmd.dwSeed = plr[v4].HoldItem._iSeed; - cmd.bId = plr[v4].HoldItem._iIdentified; - cmd.bDur = plr[v4].HoldItem._iDurability; - cmd.bMDur = plr[v4].HoldItem._iMaxDur; - cmd.bCh = plr[v4].HoldItem._iCharges; - v11 = plr[v4].HoldItem._iMaxCharges; - v12 = plr[v4].HoldItem._ivalue; - cmd.bMCh = v11; - cmd.wValue = v12; - } - if (bHiPri) - NetSendHiPri((unsigned char *)&cmd, 0x16u); - else - NetSendLoPri((unsigned char *)&cmd, 0x16u); + cmd.bCmd = bCmd; + cmd.x = x; + cmd.y = y; + v4 = myplr; + v5 = (short *)&plr[myplr].HoldItem.IDidx; + v6 = *(_DWORD *)v5 == IDI_EAR; + cmd.wIndx = *v5; + if (v6) { + _LOBYTE(v7) = 0; + _HIBYTE(v7) = plr[v4].HoldItem._iName[7]; + _LOBYTE(v8) = 0; + _HIBYTE(v8) = plr[v4].HoldItem._iName[18]; + v9 = plr[v4].HoldItem._iName[10]; + cmd.wCI = plr[v4].HoldItem._iName[8] | v7; + cmd.dwSeed = plr[v4].HoldItem._iName[12] | ((plr[v4].HoldItem._iName[11] | ((v9 | (plr[v4].HoldItem._iName[9] << 8)) << 8)) << 8); + cmd.bId = plr[v4].HoldItem._iName[13]; + cmd.bDur = plr[v4].HoldItem._iName[14]; + cmd.bMDur = plr[v4].HoldItem._iName[15]; + cmd.bCh = plr[v4].HoldItem._iName[16]; + cmd.bMCh = plr[v4].HoldItem._iName[17]; + v10 = plr[v4].HoldItem._iName[20]; + cmd.wValue = _LOWORD(plr[v4].HoldItem._ivalue) | v8 | ((_LOWORD(plr[v4].HoldItem._iCurs) - 19) << 6); + cmd.dwBuff = plr[v4].HoldItem._iName[22] | ((plr[v4].HoldItem._iName[21] | ((v10 | (plr[v4].HoldItem._iName[19] << 8)) << 8)) << 8); + } else { + cmd.wCI = plr[v4].HoldItem._iCreateInfo; + cmd.dwSeed = plr[v4].HoldItem._iSeed; + cmd.bId = plr[v4].HoldItem._iIdentified; + cmd.bDur = plr[v4].HoldItem._iDurability; + cmd.bMDur = plr[v4].HoldItem._iMaxDur; + cmd.bCh = plr[v4].HoldItem._iCharges; + v11 = plr[v4].HoldItem._iMaxCharges; + v12 = plr[v4].HoldItem._ivalue; + cmd.bMCh = v11; + cmd.wValue = v12; + } + if (bHiPri) + NetSendHiPri((unsigned char *)&cmd, 0x16u); + else + NetSendLoPri((unsigned char *)&cmd, 0x16u); } void __fastcall NetSendCmdChItem(BOOL bHiPri, BYTE bLoc) { - short v2; // dx - char v3; // al - TCmdChItem cmd; // [esp+0h] [ebp-Ch] + short v2; // dx + char v3; // al + TCmdChItem cmd; // [esp+0h] [ebp-Ch] - cmd.bLoc = bLoc; - v2 = plr[myplr].HoldItem.IDidx; - cmd.bCmd = CMD_CHANGEPLRITEMS; - cmd.wIndx = v2; - cmd.wCI = plr[myplr].HoldItem._iCreateInfo; - v3 = plr[myplr].HoldItem._iIdentified; - cmd.dwSeed = plr[myplr].HoldItem._iSeed; - cmd.bId = v3; - if (bHiPri) - NetSendHiPri((unsigned char *)&cmd, 0xBu); - else - NetSendLoPri((unsigned char *)&cmd, 0xBu); + cmd.bLoc = bLoc; + v2 = plr[myplr].HoldItem.IDidx; + cmd.bCmd = CMD_CHANGEPLRITEMS; + cmd.wIndx = v2; + cmd.wCI = plr[myplr].HoldItem._iCreateInfo; + v3 = plr[myplr].HoldItem._iIdentified; + cmd.dwSeed = plr[myplr].HoldItem._iSeed; + cmd.bId = v3; + if (bHiPri) + NetSendHiPri((unsigned char *)&cmd, 0xBu); + else + NetSendLoPri((unsigned char *)&cmd, 0xBu); } void __fastcall NetSendCmdDelItem(BOOL bHiPri, BYTE bLoc) { - TCmdDelItem cmd; // [esp+2h] [ebp-2h] + TCmdDelItem cmd; // [esp+2h] [ebp-2h] - cmd.bLoc = bLoc; - cmd.bCmd = CMD_DELPLRITEMS; - if (bHiPri) - NetSendHiPri((unsigned char *)&cmd, 2u); - else - NetSendLoPri((unsigned char *)&cmd, 2u); + cmd.bLoc = bLoc; + cmd.bCmd = CMD_DELPLRITEMS; + if (bHiPri) + NetSendHiPri((unsigned char *)&cmd, 2u); + else + NetSendLoPri((unsigned char *)&cmd, 2u); } void __fastcall NetSendCmdDItem(BOOL bHiPri, int ii) { - int v2; // eax - short *v3; // edx - bool v4; // zf - short v5; // dx - short v6; // bx - int v7; // esi - int v8; // esi - char v9; // dl - short v10; // ax - TCmdPItem cmd; // [esp+4h] [ebp-18h] + int v2; // eax + short *v3; // edx + bool v4; // zf + short v5; // dx + short v6; // bx + int v7; // esi + int v8; // esi + char v9; // dl + short v10; // ax + TCmdPItem cmd; // [esp+4h] [ebp-18h] - v2 = ii; - cmd.bCmd = CMD_DROPITEM; - cmd.x = item[ii]._ix; - cmd.y = item[ii]._iy; - v3 = (short *)&item[ii].IDidx; - v4 = *(_DWORD *)v3 == IDI_EAR; - cmd.wIndx = *v3; - if (v4) { - _LOBYTE(v5) = 0; - _HIBYTE(v5) = item[v2]._iName[7]; - _LOBYTE(v6) = 0; - _HIBYTE(v6) = item[v2]._iName[18]; - v7 = item[v2]._iName[10]; - cmd.wCI = item[v2]._iName[8] | v5; - cmd.dwSeed = item[v2]._iName[12] | ((item[v2]._iName[11] | ((v7 | (item[v2]._iName[9] << 8)) << 8)) << 8); - cmd.bId = item[v2]._iName[13]; - cmd.bDur = item[v2]._iName[14]; - cmd.bMDur = item[v2]._iName[15]; - cmd.bCh = item[v2]._iName[16]; - cmd.bMCh = item[v2]._iName[17]; - v8 = item[v2]._iName[20]; - cmd.wValue = _LOWORD(item[v2]._ivalue) | v6 | ((_LOWORD(item[v2]._iCurs) - 19) << 6); - cmd.dwBuff = item[v2]._iName[22] | ((item[v2]._iName[21] | ((v8 | (item[v2]._iName[19] << 8)) << 8)) << 8); - } else { - cmd.wCI = item[v2]._iCreateInfo; - cmd.dwSeed = item[v2]._iSeed; - cmd.bId = item[v2]._iIdentified; - cmd.bDur = item[v2]._iDurability; - cmd.bMDur = item[v2]._iMaxDur; - cmd.bCh = item[v2]._iCharges; - v9 = item[v2]._iMaxCharges; - v10 = item[v2]._ivalue; - cmd.bMCh = v9; - cmd.wValue = v10; - } - if (bHiPri) - NetSendHiPri((unsigned char *)&cmd, 0x16u); - else - NetSendLoPri((unsigned char *)&cmd, 0x16u); + v2 = ii; + cmd.bCmd = CMD_DROPITEM; + cmd.x = item[ii]._ix; + cmd.y = item[ii]._iy; + v3 = (short *)&item[ii].IDidx; + v4 = *(_DWORD *)v3 == IDI_EAR; + cmd.wIndx = *v3; + if (v4) { + _LOBYTE(v5) = 0; + _HIBYTE(v5) = item[v2]._iName[7]; + _LOBYTE(v6) = 0; + _HIBYTE(v6) = item[v2]._iName[18]; + v7 = item[v2]._iName[10]; + cmd.wCI = item[v2]._iName[8] | v5; + cmd.dwSeed = item[v2]._iName[12] | ((item[v2]._iName[11] | ((v7 | (item[v2]._iName[9] << 8)) << 8)) << 8); + cmd.bId = item[v2]._iName[13]; + cmd.bDur = item[v2]._iName[14]; + cmd.bMDur = item[v2]._iName[15]; + cmd.bCh = item[v2]._iName[16]; + cmd.bMCh = item[v2]._iName[17]; + v8 = item[v2]._iName[20]; + cmd.wValue = _LOWORD(item[v2]._ivalue) | v6 | ((_LOWORD(item[v2]._iCurs) - 19) << 6); + cmd.dwBuff = item[v2]._iName[22] | ((item[v2]._iName[21] | ((v8 | (item[v2]._iName[19] << 8)) << 8)) << 8); + } else { + cmd.wCI = item[v2]._iCreateInfo; + cmd.dwSeed = item[v2]._iSeed; + cmd.bId = item[v2]._iIdentified; + cmd.bDur = item[v2]._iDurability; + cmd.bMDur = item[v2]._iMaxDur; + cmd.bCh = item[v2]._iCharges; + v9 = item[v2]._iMaxCharges; + v10 = item[v2]._ivalue; + cmd.bMCh = v9; + cmd.wValue = v10; + } + if (bHiPri) + NetSendHiPri((unsigned char *)&cmd, 0x16u); + else + NetSendLoPri((unsigned char *)&cmd, 0x16u); } void __fastcall NetSendCmdDamage(BOOL bHiPri, BYTE bPlr, DWORD dwDam) { - TCmdDamage cmd; // [esp+0h] [ebp-8h] + TCmdDamage cmd; // [esp+0h] [ebp-8h] - cmd.bPlr = bPlr; - cmd.bCmd = CMD_PLRDAMAGE; - cmd.dwDam = dwDam; - if (bHiPri) - NetSendHiPri((unsigned char *)&cmd, 6u); - else - NetSendLoPri((unsigned char *)&cmd, 6u); + cmd.bPlr = bPlr; + cmd.bCmd = CMD_PLRDAMAGE; + cmd.dwDam = dwDam; + if (bHiPri) + NetSendHiPri((unsigned char *)&cmd, 6u); + else + NetSendLoPri((unsigned char *)&cmd, 6u); } void __fastcall NetSendCmdString(int pmask, const char *pszStr) { - const char *v2; // esi - int v3; // edi - char dwStrLen; // bl - TCmdString cmd; // [esp+Ch] [ebp-54h] + const char *v2; // esi + int v3; // edi + char dwStrLen; // bl + TCmdString cmd; // [esp+Ch] [ebp-54h] - v2 = pszStr; - v3 = pmask; - dwStrLen = strlen(pszStr); - cmd.bCmd = CMD_STRING; - strcpy(cmd.str, v2); - multi_send_msg_packet(v3, &cmd.bCmd, dwStrLen + 2); + v2 = pszStr; + v3 = pmask; + dwStrLen = strlen(pszStr); + cmd.bCmd = CMD_STRING; + strcpy(cmd.str, v2); + multi_send_msg_packet(v3, &cmd.bCmd, dwStrLen + 2); } void __fastcall RemovePlrPortal(int pnum) { - memset(&sgJunk.portal[pnum], 255, 5u); - sgbDeltaChanged = 1; + memset(&sgJunk.portal[pnum], 255, 5u); + sgbDeltaChanged = 1; } // 67618C: using guessed type char sgbDeltaChanged; int __fastcall ParseCmd(int pnum, TCmd *pCmd) { - bool v2; // zf - TCmd *v3; // eax - char v4; // dl - unsigned char v5; // bl - int result; // eax - TCmd *v7; // esi + bool v2; // zf + TCmd *v3; // eax + char v4; // dl + unsigned char v5; // bl + int result; // eax + TCmd *v7; // esi - v2 = sgwPackPlrOffsetTbl[pnum] == 0; - v3 = pCmd; - v4 = pCmd->bCmd; - sbLastCmd = v4; - if (!v2 && v4 != CMD_ACK_PLRINFO && v4 != CMD_SEND_PLRINFO) - return 0; - v5 = v3->bCmd; - switch (v3->bCmd) { - case CMD_WALKXY: - return On_WALKXY((struct TCmdLoc *)v3, pnum); - case CMD_ACK_PLRINFO: - return On_ACK_PLRINFO((struct TCmdPlrInfoHdr *)v3, pnum); - case CMD_ADDSTR: - return On_ADDSTR((struct TCmdParam1 *)v3, pnum); - case CMD_ADDMAG: - return On_ADDMAG((struct TCmdParam1 *)v3, pnum); - case CMD_ADDDEX: - return On_ADDDEX((struct TCmdParam1 *)v3, pnum); - case CMD_ADDVIT: - return On_ADDVIT((struct TCmdParam1 *)v3, pnum); - case CMD_SBSPELL: - return On_SBSPELL((struct TCmdParam1 *)v3, pnum); - case CMD_GETITEM: - return On_GETITEM((struct TCmdGItem *)v3, pnum); - case CMD_AGETITEM: - return On_AGETITEM((struct TCmdGItem *)v3, pnum); - case CMD_PUTITEM: - return On_PUTITEM((struct TCmdPItem *)v3, pnum); - case CMD_RESPAWNITEM: - return On_RESPAWNITEM((struct TCmdPItem *)v3, pnum); - case CMD_ATTACKXY: - return On_ATTACKXY((struct TCmdLoc *)v3, pnum); - case CMD_RATTACKXY: - return On_RATTACKXY((struct TCmdLoc *)v3, pnum); - case CMD_SPELLXY: - return On_SPELLXY((struct TCmdLocParam2 *)v3, pnum); - case CMD_TSPELLXY: - return On_TSPELLXY((struct TCmdLocParam2 *)v3, pnum); - case CMD_OPOBJXY: - return On_OPOBJXY((struct TCmdLocParam1 *)v3, pnum); - case CMD_DISARMXY: - return On_DISARMXY((struct TCmdLocParam1 *)v3, pnum); - case CMD_ATTACKID: - return On_ATTACKID((struct TCmdParam1 *)v3, pnum); - case CMD_ATTACKPID: - return On_ATTACKPID((struct TCmdParam1 *)v3, pnum); - case CMD_RATTACKID: - return On_RATTACKID((struct TCmdParam1 *)v3, pnum); - case CMD_RATTACKPID: - return On_RATTACKPID((struct TCmdParam1 *)v3, pnum); - case CMD_SPELLID: - return On_SPELLID((struct TCmdParam3 *)v3, pnum); - case CMD_SPELLPID: - return On_SPELLPID((struct TCmdParam3 *)v3, pnum); - case CMD_TSPELLID: - return On_TSPELLID((struct TCmdParam3 *)v3, pnum); - case CMD_TSPELLPID: - return On_TSPELLPID((struct TCmdParam3 *)v3, pnum); - case CMD_RESURRECT: - return On_RESURRECT((struct TCmdParam1 *)v3, pnum); - case CMD_OPOBJT: - return On_OPOBJT((struct TCmdParam1 *)v3, pnum); - case CMD_KNOCKBACK: - return On_KNOCKBACK((struct TCmdParam1 *)v3, pnum); - case CMD_TALKXY: - return On_TALKXY((struct TCmdLocParam1 *)v3, pnum); - case CMD_NEWLVL: - return On_NEWLVL((struct TCmdParam2 *)v3, pnum); - case CMD_WARP: - return On_WARP((struct TCmdParam1 *)v3, pnum); + v2 = sgwPackPlrOffsetTbl[pnum] == 0; + v3 = pCmd; + v4 = pCmd->bCmd; + sbLastCmd = v4; + if (!v2 && v4 != CMD_ACK_PLRINFO && v4 != CMD_SEND_PLRINFO) + return 0; + v5 = v3->bCmd; + switch (v3->bCmd) { + case CMD_WALKXY: + return On_WALKXY((struct TCmdLoc *)v3, pnum); + case CMD_ACK_PLRINFO: + return On_ACK_PLRINFO((struct TCmdPlrInfoHdr *)v3, pnum); + case CMD_ADDSTR: + return On_ADDSTR((struct TCmdParam1 *)v3, pnum); + case CMD_ADDMAG: + return On_ADDMAG((struct TCmdParam1 *)v3, pnum); + case CMD_ADDDEX: + return On_ADDDEX((struct TCmdParam1 *)v3, pnum); + case CMD_ADDVIT: + return On_ADDVIT((struct TCmdParam1 *)v3, pnum); + case CMD_SBSPELL: + return On_SBSPELL((struct TCmdParam1 *)v3, pnum); + case CMD_GETITEM: + return On_GETITEM((struct TCmdGItem *)v3, pnum); + case CMD_AGETITEM: + return On_AGETITEM((struct TCmdGItem *)v3, pnum); + case CMD_PUTITEM: + return On_PUTITEM((struct TCmdPItem *)v3, pnum); + case CMD_RESPAWNITEM: + return On_RESPAWNITEM((struct TCmdPItem *)v3, pnum); + case CMD_ATTACKXY: + return On_ATTACKXY((struct TCmdLoc *)v3, pnum); + case CMD_RATTACKXY: + return On_RATTACKXY((struct TCmdLoc *)v3, pnum); + case CMD_SPELLXY: + return On_SPELLXY((struct TCmdLocParam2 *)v3, pnum); + case CMD_TSPELLXY: + return On_TSPELLXY((struct TCmdLocParam2 *)v3, pnum); + case CMD_OPOBJXY: + return On_OPOBJXY((struct TCmdLocParam1 *)v3, pnum); + case CMD_DISARMXY: + return On_DISARMXY((struct TCmdLocParam1 *)v3, pnum); + case CMD_ATTACKID: + return On_ATTACKID((struct TCmdParam1 *)v3, pnum); + case CMD_ATTACKPID: + return On_ATTACKPID((struct TCmdParam1 *)v3, pnum); + case CMD_RATTACKID: + return On_RATTACKID((struct TCmdParam1 *)v3, pnum); + case CMD_RATTACKPID: + return On_RATTACKPID((struct TCmdParam1 *)v3, pnum); + case CMD_SPELLID: + return On_SPELLID((struct TCmdParam3 *)v3, pnum); + case CMD_SPELLPID: + return On_SPELLPID((struct TCmdParam3 *)v3, pnum); + case CMD_TSPELLID: + return On_TSPELLID((struct TCmdParam3 *)v3, pnum); + case CMD_TSPELLPID: + return On_TSPELLPID((struct TCmdParam3 *)v3, pnum); + case CMD_RESURRECT: + return On_RESURRECT((struct TCmdParam1 *)v3, pnum); + case CMD_OPOBJT: + return On_OPOBJT((struct TCmdParam1 *)v3, pnum); + case CMD_KNOCKBACK: + return On_KNOCKBACK((struct TCmdParam1 *)v3, pnum); + case CMD_TALKXY: + return On_TALKXY((struct TCmdLocParam1 *)v3, pnum); + case CMD_NEWLVL: + return On_NEWLVL((struct TCmdParam2 *)v3, pnum); + case CMD_WARP: + return On_WARP((struct TCmdParam1 *)v3, pnum); #ifdef _DEBUG - case CMD_CHEAT_EXPERIENCE: - return On_CHEAT_EXPERIENCE(v3, pnum); - case CMD_CHEAT_SPELL_LEVEL: - return On_CHEAT_SPELL_LEVEL(v3, pnum); + case CMD_CHEAT_EXPERIENCE: + return On_CHEAT_EXPERIENCE(v3, pnum); + case CMD_CHEAT_SPELL_LEVEL: + return On_CHEAT_SPELL_LEVEL(v3, pnum); #else - case CMD_CHEAT_EXPERIENCE: - return On_DEBUG(v3); - case CMD_CHEAT_SPELL_LEVEL: - return On_DEBUG(v3); + case CMD_CHEAT_EXPERIENCE: + return On_DEBUG(v3); + case CMD_CHEAT_SPELL_LEVEL: + return On_DEBUG(v3); #endif - case CMD_DEBUG: - return On_DEBUG(v3); - case CMD_SYNCDATA: - return On_SYNCDATA(v3, pnum); - case CMD_MONSTDEATH: - return On_MONSTDEATH((struct TCmdLocParam1 *)v3, pnum); - case CMD_MONSTDAMAGE: - return On_MONSTDAMAGE((struct TCmdParam2 *)v3, pnum); - case CMD_PLRDEAD: - return On_PLRDEAD((struct TCmdParam1 *)v3, pnum); - case CMD_REQUESTGITEM: - return On_REQUESTGITEM((struct TCmdGItem *)v3, pnum); - case CMD_REQUESTAGITEM: - return On_REQUESTAGITEM((struct TCmdGItem *)v3, pnum); - case CMD_GOTOGETITEM: - return On_GOTOGETITEM((struct TCmdLocParam1 *)v3, pnum); - case CMD_GOTOAGETITEM: - return On_GOTOAGETITEM((struct TCmdLocParam1 *)v3, pnum); - case CMD_OPENDOOR: - return On_OPENDOOR((struct TCmdParam1 *)v3, pnum); - case CMD_CLOSEDOOR: - return On_CLOSEDOOR((struct TCmdParam1 *)v3, pnum); - case CMD_OPERATEOBJ: - return On_OPERATEOBJ((struct TCmdParam1 *)v3, pnum); - case CMD_PLROPOBJ: - return On_PLROPOBJ((struct TCmdParam2 *)v3, pnum); - case CMD_BREAKOBJ: - return On_BREAKOBJ((struct TCmdParam2 *)v3, pnum); - case CMD_CHANGEPLRITEMS: - return On_CHANGEPLRITEMS((struct TCmdChItem *)v3, pnum); - case CMD_DELPLRITEMS: - return On_DELPLRITEMS((struct TCmdDelItem *)v3, pnum); - case CMD_PLRDAMAGE: - return On_PLRDAMAGE((struct TCmdDamage *)v3, pnum); - case CMD_PLRLEVEL: - return On_PLRLEVEL((struct TCmdParam1 *)v3, pnum); - case CMD_DROPITEM: - return On_DROPITEM((struct TCmdPItem *)v3, pnum); - case CMD_PLAYER_JOINLEVEL: - return On_PLAYER_JOINLEVEL((struct TCmdLocParam1 *)v3, pnum); - case CMD_SEND_PLRINFO: - return On_SEND_PLRINFO((struct TCmdPlrInfoHdr *)v3, pnum); - case CMD_SATTACKXY: - return On_SATTACKXY((struct TCmdLoc *)v3, pnum); - case CMD_ACTIVATEPORTAL: - return On_ACTIVATEPORTAL((struct TCmdLocParam3 *)v3, pnum); - case CMD_DEACTIVATEPORTAL: - return On_DEACTIVATEPORTAL(v3, pnum); - case CMD_HEALOTHER: - return On_HEALOTHER((struct TCmdParam1 *)v3, pnum); - case CMD_STRING: - return On_STRING((struct TCmdString *)v3, pnum); - case CMD_SETSTR: - return On_SETSTR((struct TCmdParam1 *)v3, pnum); - case CMD_SETMAG: - return On_SETMAG((struct TCmdParam1 *)v3, pnum); - case CMD_SETDEX: - return On_SETDEX((struct TCmdParam1 *)v3, pnum); - case CMD_SETVIT: - return On_SETVIT((struct TCmdParam1 *)v3, pnum); - case CMD_RETOWN: - return On_RETOWN(v3, pnum); - case CMD_SPELLXYD: - return On_SPELLXYD((struct TCmdLocParam3 *)v3, pnum); - case CMD_ITEMEXTRA: - return On_ITEMEXTRA((struct TCmdGItem *)v3, pnum); - case CMD_SYNCPUTITEM: - return On_SYNCPUTITEM((struct TCmdPItem *)v3, pnum); - case CMD_KILLGOLEM: - return On_KILLGOLEM((struct TCmdLocParam1 *)v3, pnum); - case CMD_SYNCQUEST: - return On_SYNCQUEST((struct TCmdQuest *)v3, pnum); - case CMD_ENDSHIELD: - return On_ENDSHIELD(v3, pnum); - case CMD_AWAKEGOLEM: - return On_AWAKEGOLEM((struct TCmdGolem *)v3, pnum); - case CMD_NOVA: - return On_NOVA((struct TCmdLoc *)v3, pnum); - case CMD_SETSHIELD: - return On_SETSHIELD(v3, pnum); - case CMD_REMSHIELD: - return On_REMSHIELD(v3, pnum); - default: - if (v5 < CMD_DLEVEL_0 || v5 > CMD_DLEVEL_END) { - SNetDropPlayer(pnum, 0x40000006); - return 0; - } - v7 = v3; - if ((unsigned char)gbDeltaSender == pnum) { - if (sgbRecvCmd != CMD_DLEVEL_END) { - if (sgbRecvCmd == v3->bCmd) { - LABEL_99: - memcpy(&sgRecvBuf[*(unsigned short *)&v7[1].bCmd], &v7[5], *(unsigned short *)&v7[3].bCmd); - sgdwRecvOffset += *(unsigned short *)&v7[3].bCmd; - goto LABEL_100; - } - DeltaImportData(sgbRecvCmd, sgdwRecvOffset); - if (v7->bCmd == CMD_DLEVEL_END) { - sgbDeltaChunks = 20; - sgbRecvCmd = CMD_DLEVEL_END; - goto LABEL_100; - } - sgdwRecvOffset = 0; - LABEL_98: - sgbRecvCmd = v7->bCmd; - goto LABEL_99; - } - } else { - if (v3->bCmd != CMD_DLEVEL_END && (v3->bCmd != CMD_DLEVEL_0 || *(_WORD *)&v3[1].bCmd)) - goto LABEL_100; - gbDeltaSender = pnum; - sgbRecvCmd = CMD_DLEVEL_END; - } - if (v3->bCmd == CMD_DLEVEL_END) { - sgbDeltaChunks = 20; - goto LABEL_100; - } - if (v3->bCmd == CMD_DLEVEL_0 && !*(_WORD *)&v3[1].bCmd) { - sgdwRecvOffset = 0; - goto LABEL_98; - } - LABEL_100: - result = *(unsigned short *)&v7[3].bCmd + 5; - break; - } - return result; + case CMD_DEBUG: + return On_DEBUG(v3); + case CMD_SYNCDATA: + return On_SYNCDATA(v3, pnum); + case CMD_MONSTDEATH: + return On_MONSTDEATH((struct TCmdLocParam1 *)v3, pnum); + case CMD_MONSTDAMAGE: + return On_MONSTDAMAGE((struct TCmdParam2 *)v3, pnum); + case CMD_PLRDEAD: + return On_PLRDEAD((struct TCmdParam1 *)v3, pnum); + case CMD_REQUESTGITEM: + return On_REQUESTGITEM((struct TCmdGItem *)v3, pnum); + case CMD_REQUESTAGITEM: + return On_REQUESTAGITEM((struct TCmdGItem *)v3, pnum); + case CMD_GOTOGETITEM: + return On_GOTOGETITEM((struct TCmdLocParam1 *)v3, pnum); + case CMD_GOTOAGETITEM: + return On_GOTOAGETITEM((struct TCmdLocParam1 *)v3, pnum); + case CMD_OPENDOOR: + return On_OPENDOOR((struct TCmdParam1 *)v3, pnum); + case CMD_CLOSEDOOR: + return On_CLOSEDOOR((struct TCmdParam1 *)v3, pnum); + case CMD_OPERATEOBJ: + return On_OPERATEOBJ((struct TCmdParam1 *)v3, pnum); + case CMD_PLROPOBJ: + return On_PLROPOBJ((struct TCmdParam2 *)v3, pnum); + case CMD_BREAKOBJ: + return On_BREAKOBJ((struct TCmdParam2 *)v3, pnum); + case CMD_CHANGEPLRITEMS: + return On_CHANGEPLRITEMS((struct TCmdChItem *)v3, pnum); + case CMD_DELPLRITEMS: + return On_DELPLRITEMS((struct TCmdDelItem *)v3, pnum); + case CMD_PLRDAMAGE: + return On_PLRDAMAGE((struct TCmdDamage *)v3, pnum); + case CMD_PLRLEVEL: + return On_PLRLEVEL((struct TCmdParam1 *)v3, pnum); + case CMD_DROPITEM: + return On_DROPITEM((struct TCmdPItem *)v3, pnum); + case CMD_PLAYER_JOINLEVEL: + return On_PLAYER_JOINLEVEL((struct TCmdLocParam1 *)v3, pnum); + case CMD_SEND_PLRINFO: + return On_SEND_PLRINFO((struct TCmdPlrInfoHdr *)v3, pnum); + case CMD_SATTACKXY: + return On_SATTACKXY((struct TCmdLoc *)v3, pnum); + case CMD_ACTIVATEPORTAL: + return On_ACTIVATEPORTAL((struct TCmdLocParam3 *)v3, pnum); + case CMD_DEACTIVATEPORTAL: + return On_DEACTIVATEPORTAL(v3, pnum); + case CMD_HEALOTHER: + return On_HEALOTHER((struct TCmdParam1 *)v3, pnum); + case CMD_STRING: + return On_STRING((struct TCmdString *)v3, pnum); + case CMD_SETSTR: + return On_SETSTR((struct TCmdParam1 *)v3, pnum); + case CMD_SETMAG: + return On_SETMAG((struct TCmdParam1 *)v3, pnum); + case CMD_SETDEX: + return On_SETDEX((struct TCmdParam1 *)v3, pnum); + case CMD_SETVIT: + return On_SETVIT((struct TCmdParam1 *)v3, pnum); + case CMD_RETOWN: + return On_RETOWN(v3, pnum); + case CMD_SPELLXYD: + return On_SPELLXYD((struct TCmdLocParam3 *)v3, pnum); + case CMD_ITEMEXTRA: + return On_ITEMEXTRA((struct TCmdGItem *)v3, pnum); + case CMD_SYNCPUTITEM: + return On_SYNCPUTITEM((struct TCmdPItem *)v3, pnum); + case CMD_KILLGOLEM: + return On_KILLGOLEM((struct TCmdLocParam1 *)v3, pnum); + case CMD_SYNCQUEST: + return On_SYNCQUEST((struct TCmdQuest *)v3, pnum); + case CMD_ENDSHIELD: + return On_ENDSHIELD(v3, pnum); + case CMD_AWAKEGOLEM: + return On_AWAKEGOLEM((struct TCmdGolem *)v3, pnum); + case CMD_NOVA: + return On_NOVA((struct TCmdLoc *)v3, pnum); + case CMD_SETSHIELD: + return On_SETSHIELD(v3, pnum); + case CMD_REMSHIELD: + return On_REMSHIELD(v3, pnum); + default: + if (v5 < CMD_DLEVEL_0 || v5 > CMD_DLEVEL_END) { + SNetDropPlayer(pnum, 0x40000006); + return 0; + } + v7 = v3; + if ((unsigned char)gbDeltaSender == pnum) { + if (sgbRecvCmd != CMD_DLEVEL_END) { + if (sgbRecvCmd == v3->bCmd) { + LABEL_99: + memcpy(&sgRecvBuf[*(unsigned short *)&v7[1].bCmd], &v7[5], *(unsigned short *)&v7[3].bCmd); + sgdwRecvOffset += *(unsigned short *)&v7[3].bCmd; + goto LABEL_100; + } + DeltaImportData(sgbRecvCmd, sgdwRecvOffset); + if (v7->bCmd == CMD_DLEVEL_END) { + sgbDeltaChunks = 20; + sgbRecvCmd = CMD_DLEVEL_END; + goto LABEL_100; + } + sgdwRecvOffset = 0; + LABEL_98: + sgbRecvCmd = v7->bCmd; + goto LABEL_99; + } + } else { + if (v3->bCmd != CMD_DLEVEL_END && (v3->bCmd != CMD_DLEVEL_0 || *(_WORD *)&v3[1].bCmd)) + goto LABEL_100; + gbDeltaSender = pnum; + sgbRecvCmd = CMD_DLEVEL_END; + } + if (v3->bCmd == CMD_DLEVEL_END) { + sgbDeltaChunks = 20; + goto LABEL_100; + } + if (v3->bCmd == CMD_DLEVEL_0 && !*(_WORD *)&v3[1].bCmd) { + sgdwRecvOffset = 0; + goto LABEL_98; + } + LABEL_100: + result = *(unsigned short *)&v7[3].bCmd + 5; + break; + } + return result; } // 66E4A9: using guessed type char sbLastCmd; // 67618D: using guessed type char sgbDeltaChunks; @@ -1459,1354 +1459,1354 @@ int __fastcall ParseCmd(int pnum, TCmd *pCmd) void __fastcall DeltaImportData(BYTE cmd, DWORD recv_offset) { - unsigned char v2; // bl - int v3; // esi - void *v4; // eax - void *v5; // eax + unsigned char v2; // bl + int v3; // esi + void *v4; // eax + void *v5; // eax - v2 = cmd; - if (sgRecvBuf[0]) - PkwareDecompress(&sgRecvBuf[1], recv_offset, 4721); - if (v2 == CMD_DLEVEL_JUNK) { - DeltaImportJunk(&sgRecvBuf[1]); - } else if (v2 < CMD_DLEVEL_0 || v2 > CMD_DLEVEL_16) { - TermMsg("msg:1"); - } else { - v3 = (unsigned char)(v2 - CMD_DLEVEL_0); - v4 = DeltaImportItem(&sgRecvBuf[1], &sgLevels[v3]); - v5 = DeltaImportObject(v4, sgLevels[v3].object); - DeltaImportMonster(v5, sgLevels[v3].monster); - } - ++sgbDeltaChunks; - sgbDeltaChanged = 1; + v2 = cmd; + if (sgRecvBuf[0]) + PkwareDecompress(&sgRecvBuf[1], recv_offset, 4721); + if (v2 == CMD_DLEVEL_JUNK) { + DeltaImportJunk(&sgRecvBuf[1]); + } else if (v2 < CMD_DLEVEL_0 || v2 > CMD_DLEVEL_16) { + TermMsg("msg:1"); + } else { + v3 = (unsigned char)(v2 - CMD_DLEVEL_0); + v4 = DeltaImportItem(&sgRecvBuf[1], &sgLevels[v3]); + v5 = DeltaImportObject(v4, sgLevels[v3].object); + DeltaImportMonster(v5, sgLevels[v3].monster); + } + ++sgbDeltaChunks; + sgbDeltaChanged = 1; } // 67618C: using guessed type char sgbDeltaChanged; // 67618D: using guessed type char sgbDeltaChunks; void *__fastcall DeltaImportItem(void *src, void *dst) { - char *v2; // edi - _BYTE *v3; // esi - signed int v4; // ebx + char *v2; // edi + _BYTE *v3; // esi + signed int v4; // ebx - v2 = (char *)dst; - v3 = (unsigned char *)src; - v4 = 127; - do { - if (*v3 == -1) { - memset(v2, 255, 0x16u); - ++v3; - } else { - memcpy(v2, v3, 0x16u); - v3 += 22; - } - v2 += 22; - --v4; - } while (v4); - return v3; + v2 = (char *)dst; + v3 = (unsigned char *)src; + v4 = 127; + do { + if (*v3 == -1) { + memset(v2, 255, 0x16u); + ++v3; + } else { + memcpy(v2, v3, 0x16u); + v3 += 22; + } + v2 += 22; + --v4; + } while (v4); + return v3; } void *__fastcall DeltaImportObject(void *src, void *dst) { - char *v2; // esi + char *v2; // esi - v2 = (char *)src; - memcpy(dst, src, 0x7Fu); - return v2 + 127; + v2 = (char *)src; + memcpy(dst, src, 0x7Fu); + return v2 + 127; } void *__fastcall DeltaImportMonster(void *src, void *dst) { - char *v2; // edi - _BYTE *v3; // esi - signed int v4; // ebx + char *v2; // edi + _BYTE *v3; // esi + signed int v4; // ebx - v2 = (char *)dst; - v3 = (unsigned char *)src; - v4 = MAXMONSTERS; - do { - if (*v3 == -1) { - memset(v2, 255, 9u); - ++v3; - } else { - memcpy(v2, v3, 9u); - v3 += 9; - } - v2 += 9; - --v4; - } while (v4); - return v3; + v2 = (char *)dst; + v3 = (unsigned char *)src; + v4 = MAXMONSTERS; + do { + if (*v3 == -1) { + memset(v2, 255, 9u); + ++v3; + } else { + memcpy(v2, v3, 9u); + v3 += 9; + } + v2 += 9; + --v4; + } while (v4); + return v3; } void __fastcall DeltaImportJunk(void *src) { - _BYTE *v1; // ebx - int v2; // edi - DJunk *v3; // esi - char result; // al - MultiQuests *v5; // esi - unsigned char *v6; // edi - int *v7; // ebp + _BYTE *v1; // ebx + int v2; // edi + DJunk *v3; // esi + char result; // al + MultiQuests *v5; // esi + unsigned char *v6; // edi + int *v7; // ebp - v1 = (_BYTE *)src; - v2 = 0; - v3 = &sgJunk; - do { - if (*v1 == -1) { - memset(v3, 255, 5u); - ++v1; - SetPortalStats(v2, 0, 0, 0, 0, 0); - } else { - memcpy(v3, v1, 5u); - v1 += 5; - SetPortalStats( - v2, - 1, - (unsigned char)v3->portal[0].x, - (unsigned char)v3->portal[0].y, - (unsigned char)v3->portal[0].level, - (unsigned char)v3->portal[0].ltype); - } - v3 = (DJunk *)((char *)v3 + 5); - ++v2; - } while ((signed int)v3 < (signed int)sgJunk.quests); - v5 = sgJunk.quests; - v6 = &quests[0]._qactive; - v7 = &questlist[0]._qflags; - do { - if (*(_BYTE *)v7 & 1) { - memcpy(v5, v1, 3u); - *(_DWORD *)(v6 + 18) = (unsigned char)v5->qlog; - *v6 = v5->qstate; - result = v5->qvar1; - v1 += 3; - v6[13] = result; - ++v5; - } - v7 += 5; - v6 += 24; - } while ((signed int)v7 < (signed int)&questlist[16]._qflags); + v1 = (_BYTE *)src; + v2 = 0; + v3 = &sgJunk; + do { + if (*v1 == -1) { + memset(v3, 255, 5u); + ++v1; + SetPortalStats(v2, 0, 0, 0, 0, 0); + } else { + memcpy(v3, v1, 5u); + v1 += 5; + SetPortalStats( + v2, + 1, + (unsigned char)v3->portal[0].x, + (unsigned char)v3->portal[0].y, + (unsigned char)v3->portal[0].level, + (unsigned char)v3->portal[0].ltype); + } + v3 = (DJunk *)((char *)v3 + 5); + ++v2; + } while ((signed int)v3 < (signed int)sgJunk.quests); + v5 = sgJunk.quests; + v6 = &quests[0]._qactive; + v7 = &questlist[0]._qflags; + do { + if (*(_BYTE *)v7 & 1) { + memcpy(v5, v1, 3u); + *(_DWORD *)(v6 + 18) = (unsigned char)v5->qlog; + *v6 = v5->qstate; + result = v5->qvar1; + v1 += 3; + v6[13] = result; + ++v5; + } + v7 += 5; + v6 += 24; + } while ((signed int)v7 < (signed int)&questlist[16]._qflags); } int __fastcall On_SYNCDATA(void *packet, int pnum) { - return SyncData(pnum, (TSyncHeader *)packet); + return SyncData(pnum, (TSyncHeader *)packet); } int __fastcall On_WALKXY(struct TCmdLoc *pCmd, int pnum) { - if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - ClrPlrPath(pnum); - MakePlrPath(pnum, pCmd->x, pCmd->y, TRUE); - plr[pnum].destAction = ACTION_NONE; - } + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { + ClrPlrPath(pnum); + MakePlrPath(pnum, pCmd->x, pCmd->y, TRUE); + plr[pnum].destAction = ACTION_NONE; + } - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_ADDSTR(struct TCmdParam1 *pCmd, int pnum) { - if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else if (pCmd->wParam1 <= 256) - ModifyPlrStr(pnum, pCmd->wParam1); + if (gbBufferMsgs == 1) + msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + else if (pCmd->wParam1 <= 256) + ModifyPlrStr(pnum, pCmd->wParam1); - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_ADDMAG(struct TCmdParam1 *pCmd, int pnum) { - if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else if (pCmd->wParam1 <= 256) - ModifyPlrMag(pnum, pCmd->wParam1); + if (gbBufferMsgs == 1) + msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + else if (pCmd->wParam1 <= 256) + ModifyPlrMag(pnum, pCmd->wParam1); - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_ADDDEX(struct TCmdParam1 *pCmd, int pnum) { - if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else if (pCmd->wParam1 <= 256) - ModifyPlrDex(pnum, pCmd->wParam1); + if (gbBufferMsgs == 1) + msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + else if (pCmd->wParam1 <= 256) + ModifyPlrDex(pnum, pCmd->wParam1); - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_ADDVIT(struct TCmdParam1 *pCmd, int pnum) { - if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else if (pCmd->wParam1 <= 256) - ModifyPlrVit(pnum, pCmd->wParam1); + if (gbBufferMsgs == 1) + msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + else if (pCmd->wParam1 <= 256) + ModifyPlrVit(pnum, pCmd->wParam1); - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_SBSPELL(struct TCmdParam1 *pCmd, int pnum) { - if (gbBufferMsgs != 1) { - if (currlevel != 0 || spelldata[pCmd->wParam1].sTownSpell) { - plr[pnum]._pSpell = pCmd->wParam1; - plr[pnum]._pSplType = plr[pnum]._pSBkSplType; - plr[pnum]._pSplFrom = 1; - plr[pnum].destAction = ACTION_SPELL; - } else - msg_errorf("%s has cast an illegal spell.", plr[pnum]._pName); - } + if (gbBufferMsgs != 1) { + if (currlevel != 0 || spelldata[pCmd->wParam1].sTownSpell) { + plr[pnum]._pSpell = pCmd->wParam1; + plr[pnum]._pSplType = plr[pnum]._pSBkSplType; + plr[pnum]._pSplFrom = 1; + plr[pnum].destAction = ACTION_SPELL; + } else + msg_errorf("%s has cast an illegal spell.", plr[pnum]._pName); + } - return sizeof(*pCmd); + return sizeof(*pCmd); } void msg_errorf(const char *pszFmt, ...) { - static DWORD msg_err_timer; - DWORD v1; // eax - char v2[256]; // [esp+0h] [ebp-100h] - va_list va; // [esp+10Ch] [ebp+Ch] + static DWORD msg_err_timer; + DWORD v1; // eax + char v2[256]; // [esp+0h] [ebp-100h] + va_list va; // [esp+10Ch] [ebp+Ch] - va_start(va, pszFmt); - v1 = GetTickCount(); - if (v1 - msg_err_timer >= 5000) { - msg_err_timer = v1; - vsprintf(v2, pszFmt, va); - ErrorPlrMsg(v2); - } - va_end(va); + va_start(va, pszFmt); + v1 = GetTickCount(); + if (v1 - msg_err_timer >= 5000) { + msg_err_timer = v1; + vsprintf(v2, pszFmt, va); + ErrorPlrMsg(v2); + } + va_end(va); } int __fastcall On_GOTOGETITEM(struct TCmdLocParam1 *pCmd, int pnum) { - if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - MakePlrPath(pnum, pCmd->x, pCmd->y, FALSE); - plr[pnum].destAction = ACTION_PICKUPITEM; - plr[pnum].destParam1 = pCmd->wParam1; - } + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { + MakePlrPath(pnum, pCmd->x, pCmd->y, FALSE); + plr[pnum].destAction = ACTION_PICKUPITEM; + plr[pnum].destParam1 = pCmd->wParam1; + } - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_REQUESTGITEM(struct TCmdGItem *pCmd, int pnum) { - if (gbBufferMsgs != 1 && i_own_level(plr[pnum].plrlevel)) { - if (GetItemRecord(pCmd->dwSeed, pCmd->wCI, pCmd->wIndx)) { - int ii = FindGetItem(pCmd->wIndx, pCmd->wCI, pCmd->dwSeed); - if (ii != -1) { - NetSendCmdGItem2(FALSE, CMD_GETITEM, myplr, pCmd->bPnum, pCmd); - if (pCmd->bPnum != myplr) - SyncGetItem(pCmd->x, pCmd->y, pCmd->wIndx, pCmd->wCI, pCmd->dwSeed); - else - InvGetItem(myplr, ii); - SetItemRecord(pCmd->dwSeed, pCmd->wCI, pCmd->wIndx); - } else if (!NetSendCmdReq2(CMD_REQUESTGITEM, myplr, pCmd->bPnum, pCmd)) - NetSendCmdExtra(pCmd); - } - } + if (gbBufferMsgs != 1 && i_own_level(plr[pnum].plrlevel)) { + if (GetItemRecord(pCmd->dwSeed, pCmd->wCI, pCmd->wIndx)) { + int ii = FindGetItem(pCmd->wIndx, pCmd->wCI, pCmd->dwSeed); + if (ii != -1) { + NetSendCmdGItem2(FALSE, CMD_GETITEM, myplr, pCmd->bPnum, pCmd); + if (pCmd->bPnum != myplr) + SyncGetItem(pCmd->x, pCmd->y, pCmd->wIndx, pCmd->wCI, pCmd->dwSeed); + else + InvGetItem(myplr, ii); + SetItemRecord(pCmd->dwSeed, pCmd->wCI, pCmd->wIndx); + } else if (!NetSendCmdReq2(CMD_REQUESTGITEM, myplr, pCmd->bPnum, pCmd)) + NetSendCmdExtra(pCmd); + } + } - return sizeof(*pCmd); + return sizeof(*pCmd); } BOOL __fastcall i_own_level(int nReqLevel) { - int v1; // edx - unsigned char *v2; // eax + int v1; // edx + unsigned char *v2; // eax - v1 = 0; - v2 = &plr[0]._pLvlChanging; - do { - if (*(v2 - 290) && !*v2 && *(_DWORD *)(v2 - 267) == nReqLevel && (v1 != myplr || !gbBufferMsgs)) - break; - v2 += 21720; - ++v1; - } while ((signed int)v2 < (signed int)&plr[4]._pLvlChanging); - return v1 == myplr; + v1 = 0; + v2 = &plr[0]._pLvlChanging; + do { + if (*(v2 - 290) && !*v2 && *(_DWORD *)(v2 - 267) == nReqLevel && (v1 != myplr || !gbBufferMsgs)) + break; + v2 += 21720; + ++v1; + } while ((signed int)v2 < (signed int)&plr[4]._pLvlChanging); + return v1 == myplr; } // 676194: using guessed type char gbBufferMsgs; int __fastcall On_GETITEM(struct TCmdGItem *pCmd, int pnum) { - if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else { - int ii = FindGetItem(pCmd->wIndx, pCmd->wCI, pCmd->dwSeed); - if (delta_get_item(pCmd, pCmd->bLevel)) { - if ((currlevel == pCmd->bLevel || pCmd->bPnum == myplr) && pCmd->bMaster != myplr) { - if (pCmd->bPnum == myplr) { - if (currlevel != pCmd->bLevel) { - ii = SyncPutItem(myplr, plr[myplr].WorldX, plr[myplr].WorldY, pCmd->wIndx, pCmd->wCI, pCmd->dwSeed, pCmd->bId, pCmd->bDur, pCmd->bMDur, pCmd->bCh, pCmd->bMCh, pCmd->wValue, pCmd->dwBuff); - if (ii != -1) - InvGetItem(myplr, ii); - } else - InvGetItem(myplr, ii); - } else - SyncGetItem(pCmd->x, pCmd->y, pCmd->wIndx, pCmd->wCI, pCmd->dwSeed); - } - } else - NetSendCmdGItem2(TRUE, CMD_GETITEM, pCmd->bMaster, pCmd->bPnum, pCmd); - } + if (gbBufferMsgs == 1) + msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + else { + int ii = FindGetItem(pCmd->wIndx, pCmd->wCI, pCmd->dwSeed); + if (delta_get_item(pCmd, pCmd->bLevel)) { + if ((currlevel == pCmd->bLevel || pCmd->bPnum == myplr) && pCmd->bMaster != myplr) { + if (pCmd->bPnum == myplr) { + if (currlevel != pCmd->bLevel) { + ii = SyncPutItem(myplr, plr[myplr].WorldX, plr[myplr].WorldY, pCmd->wIndx, pCmd->wCI, pCmd->dwSeed, pCmd->bId, pCmd->bDur, pCmd->bMDur, pCmd->bCh, pCmd->bMCh, pCmd->wValue, pCmd->dwBuff); + if (ii != -1) + InvGetItem(myplr, ii); + } else + InvGetItem(myplr, ii); + } else + SyncGetItem(pCmd->x, pCmd->y, pCmd->wIndx, pCmd->wCI, pCmd->dwSeed); + } + } else + NetSendCmdGItem2(TRUE, CMD_GETITEM, pCmd->bMaster, pCmd->bPnum, pCmd); + } - return sizeof(*pCmd); + return sizeof(*pCmd); } BOOL __fastcall delta_get_item(struct TCmdGItem *pI, BYTE bLevel) { - struct TCmdGItem *v2; // esi - signed int v3; // ecx - DLevel *v4; // edi - DLevel *v5; // eax - char v6; // cl - DLevel *v8; // eax - signed int v9; // ecx + struct TCmdGItem *v2; // esi + signed int v3; // ecx + DLevel *v4; // edi + DLevel *v5; // eax + char v6; // cl + DLevel *v8; // eax + signed int v9; // ecx - v2 = pI; - if (gbMaxPlayers != 1) { - v3 = 0; - v4 = &sgLevels[bLevel]; - v5 = &sgLevels[bLevel]; - while (v5->item[0].bCmd == -1 - || v5->item[0].wIndx != v2->wIndx - || v5->item[0].wCI != v2->wCI - || v5->item[0].dwSeed != v2->dwSeed) { - ++v3; - v5 = (DLevel *)((char *)v5 + 22); - if (v3 >= 127) - goto LABEL_15; - } - v6 = v5->item[0].bCmd; - if (v5->item[0].bCmd == 1) - return 1; - if (!v6) { - sgbDeltaChanged = 1; - v5->item[0].bCmd = 1; - return 1; - } - if (v6 == 2) { - v5->item[0].bCmd = -1; - sgbDeltaChanged = 1; - return 1; - } - TermMsg("delta:1"); - LABEL_15: - if (v2->wCI >= 0) - return 0; - v8 = v4; - v9 = 0; - while (v8->item[0].bCmd != -1) { - ++v9; - v8 = (DLevel *)((char *)v8 + 22); - if (v9 >= 127) - return 1; - } - sgbDeltaChanged = 1; - v8->item[0].bCmd = 1; - v8->item[0].x = v2->x; - v8->item[0].y = v2->y; - v8->item[0].wIndx = v2->wIndx; - v8->item[0].wCI = v2->wCI; - v8->item[0].dwSeed = v2->dwSeed; - v8->item[0].bId = v2->bId; - v8->item[0].bDur = v2->bDur; - v8->item[0].bMDur = v2->bMDur; - v8->item[0].bCh = v2->bCh; - v8->item[0].bMCh = v2->bMCh; - v8->item[0].wValue = v2->wValue; - v8->item[0].dwBuff = v2->dwBuff; - } - return 1; + v2 = pI; + if (gbMaxPlayers != 1) { + v3 = 0; + v4 = &sgLevels[bLevel]; + v5 = &sgLevels[bLevel]; + while (v5->item[0].bCmd == -1 + || v5->item[0].wIndx != v2->wIndx + || v5->item[0].wCI != v2->wCI + || v5->item[0].dwSeed != v2->dwSeed) { + ++v3; + v5 = (DLevel *)((char *)v5 + 22); + if (v3 >= 127) + goto LABEL_15; + } + v6 = v5->item[0].bCmd; + if (v5->item[0].bCmd == 1) + return 1; + if (!v6) { + sgbDeltaChanged = 1; + v5->item[0].bCmd = 1; + return 1; + } + if (v6 == 2) { + v5->item[0].bCmd = -1; + sgbDeltaChanged = 1; + return 1; + } + TermMsg("delta:1"); + LABEL_15: + if (v2->wCI >= 0) + return 0; + v8 = v4; + v9 = 0; + while (v8->item[0].bCmd != -1) { + ++v9; + v8 = (DLevel *)((char *)v8 + 22); + if (v9 >= 127) + return 1; + } + sgbDeltaChanged = 1; + v8->item[0].bCmd = 1; + v8->item[0].x = v2->x; + v8->item[0].y = v2->y; + v8->item[0].wIndx = v2->wIndx; + v8->item[0].wCI = v2->wCI; + v8->item[0].dwSeed = v2->dwSeed; + v8->item[0].bId = v2->bId; + v8->item[0].bDur = v2->bDur; + v8->item[0].bMDur = v2->bMDur; + v8->item[0].bCh = v2->bCh; + v8->item[0].bMCh = v2->bMCh; + v8->item[0].wValue = v2->wValue; + v8->item[0].dwBuff = v2->dwBuff; + } + return 1; } // 67618C: using guessed type char sgbDeltaChanged; // 679660: using guessed type char gbMaxPlayers; int __fastcall On_GOTOAGETITEM(struct TCmdLocParam1 *pCmd, int pnum) { - if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - MakePlrPath(pnum, pCmd->x, pCmd->y, FALSE); - plr[pnum].destAction = ACTION_PICKUPAITEM; - plr[pnum].destParam1 = pCmd->wParam1; - } + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { + MakePlrPath(pnum, pCmd->x, pCmd->y, FALSE); + plr[pnum].destAction = ACTION_PICKUPAITEM; + plr[pnum].destParam1 = pCmd->wParam1; + } - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_REQUESTAGITEM(struct TCmdGItem *pCmd, int pnum) { - if (gbBufferMsgs != 1 && i_own_level(plr[pnum].plrlevel)) { - if (GetItemRecord(pCmd->dwSeed, pCmd->wCI, pCmd->wIndx)) { - int ii = FindGetItem(pCmd->wIndx, pCmd->wCI, pCmd->dwSeed); - if (ii != -1) { - NetSendCmdGItem2(FALSE, CMD_AGETITEM, myplr, pCmd->bPnum, pCmd); - if (pCmd->bPnum != myplr) - SyncGetItem(pCmd->x, pCmd->y, pCmd->wIndx, pCmd->wCI, pCmd->dwSeed); - else - AutoGetItem(myplr, pCmd->bCursitem); - SetItemRecord(pCmd->dwSeed, pCmd->wCI, pCmd->wIndx); - } else if (!NetSendCmdReq2(CMD_REQUESTAGITEM, myplr, pCmd->bPnum, pCmd)) - NetSendCmdExtra(pCmd); - } - } + if (gbBufferMsgs != 1 && i_own_level(plr[pnum].plrlevel)) { + if (GetItemRecord(pCmd->dwSeed, pCmd->wCI, pCmd->wIndx)) { + int ii = FindGetItem(pCmd->wIndx, pCmd->wCI, pCmd->dwSeed); + if (ii != -1) { + NetSendCmdGItem2(FALSE, CMD_AGETITEM, myplr, pCmd->bPnum, pCmd); + if (pCmd->bPnum != myplr) + SyncGetItem(pCmd->x, pCmd->y, pCmd->wIndx, pCmd->wCI, pCmd->dwSeed); + else + AutoGetItem(myplr, pCmd->bCursitem); + SetItemRecord(pCmd->dwSeed, pCmd->wCI, pCmd->wIndx); + } else if (!NetSendCmdReq2(CMD_REQUESTAGITEM, myplr, pCmd->bPnum, pCmd)) + NetSendCmdExtra(pCmd); + } + } - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_AGETITEM(struct TCmdGItem *pCmd, int pnum) { - if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else { - FindGetItem(pCmd->wIndx, pCmd->wCI, pCmd->dwSeed); - if (delta_get_item(pCmd, pCmd->bLevel)) { - if ((currlevel == pCmd->bLevel || pCmd->bPnum == myplr) && pCmd->bMaster != myplr) { - if (pCmd->bPnum == myplr) { - if (currlevel != pCmd->bLevel) { - int ii = SyncPutItem(myplr, plr[myplr].WorldX, plr[myplr].WorldY, pCmd->wIndx, pCmd->wCI, pCmd->dwSeed, pCmd->bId, pCmd->bDur, pCmd->bMDur, pCmd->bCh, pCmd->bMCh, pCmd->wValue, pCmd->dwBuff); - if (ii != -1) - AutoGetItem(myplr, ii); - } else - AutoGetItem(myplr, pCmd->bCursitem); - } else - SyncGetItem(pCmd->x, pCmd->y, pCmd->wIndx, pCmd->wCI, pCmd->dwSeed); - } - } else - NetSendCmdGItem2(TRUE, CMD_AGETITEM, pCmd->bMaster, pCmd->bPnum, pCmd); - } + if (gbBufferMsgs == 1) + msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + else { + FindGetItem(pCmd->wIndx, pCmd->wCI, pCmd->dwSeed); + if (delta_get_item(pCmd, pCmd->bLevel)) { + if ((currlevel == pCmd->bLevel || pCmd->bPnum == myplr) && pCmd->bMaster != myplr) { + if (pCmd->bPnum == myplr) { + if (currlevel != pCmd->bLevel) { + int ii = SyncPutItem(myplr, plr[myplr].WorldX, plr[myplr].WorldY, pCmd->wIndx, pCmd->wCI, pCmd->dwSeed, pCmd->bId, pCmd->bDur, pCmd->bMDur, pCmd->bCh, pCmd->bMCh, pCmd->wValue, pCmd->dwBuff); + if (ii != -1) + AutoGetItem(myplr, ii); + } else + AutoGetItem(myplr, pCmd->bCursitem); + } else + SyncGetItem(pCmd->x, pCmd->y, pCmd->wIndx, pCmd->wCI, pCmd->dwSeed); + } + } else + NetSendCmdGItem2(TRUE, CMD_AGETITEM, pCmd->bMaster, pCmd->bPnum, pCmd); + } - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_ITEMEXTRA(struct TCmdGItem *pCmd, int pnum) { - if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else { - delta_get_item(pCmd, pCmd->bLevel); - if (currlevel == plr[pnum].plrlevel) - SyncGetItem(pCmd->x, pCmd->y, pCmd->wIndx, pCmd->wCI, pCmd->dwSeed); - } + if (gbBufferMsgs == 1) + msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + else { + delta_get_item(pCmd, pCmd->bLevel); + if (currlevel == plr[pnum].plrlevel) + SyncGetItem(pCmd->x, pCmd->y, pCmd->wIndx, pCmd->wCI, pCmd->dwSeed); + } - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_PUTITEM(struct TCmdPItem *pCmd, int pnum) { - if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else if (currlevel == plr[pnum].plrlevel) { - int ii; - if (pnum == myplr) - ii = InvPutItem(pnum, pCmd->x, pCmd->y); - else - ii = SyncPutItem(pnum, pCmd->x, pCmd->y, pCmd->wIndx, pCmd->wCI, pCmd->dwSeed, pCmd->bId, pCmd->bDur, pCmd->bMDur, pCmd->bCh, pCmd->bMCh, pCmd->wValue, pCmd->dwBuff); - if (ii != -1) { - PutItemRecord(pCmd->dwSeed, pCmd->wCI, pCmd->wIndx); - delta_put_item(pCmd, item[ii]._ix, item[ii]._iy, plr[pnum].plrlevel); - check_update_plr(pnum); - } - return sizeof(*pCmd); - } else { - PutItemRecord(pCmd->dwSeed, pCmd->wCI, pCmd->wIndx); - delta_put_item(pCmd, pCmd->x, pCmd->y, plr[pnum].plrlevel); - check_update_plr(pnum); - } + if (gbBufferMsgs == 1) + msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + else if (currlevel == plr[pnum].plrlevel) { + int ii; + if (pnum == myplr) + ii = InvPutItem(pnum, pCmd->x, pCmd->y); + else + ii = SyncPutItem(pnum, pCmd->x, pCmd->y, pCmd->wIndx, pCmd->wCI, pCmd->dwSeed, pCmd->bId, pCmd->bDur, pCmd->bMDur, pCmd->bCh, pCmd->bMCh, pCmd->wValue, pCmd->dwBuff); + if (ii != -1) { + PutItemRecord(pCmd->dwSeed, pCmd->wCI, pCmd->wIndx); + delta_put_item(pCmd, item[ii]._ix, item[ii]._iy, plr[pnum].plrlevel); + check_update_plr(pnum); + } + return sizeof(*pCmd); + } else { + PutItemRecord(pCmd->dwSeed, pCmd->wCI, pCmd->wIndx); + delta_put_item(pCmd, pCmd->x, pCmd->y, plr[pnum].plrlevel); + check_update_plr(pnum); + } - return sizeof(*pCmd); + return sizeof(*pCmd); } void __fastcall delta_put_item(struct TCmdPItem *pI, int x, int y, BYTE bLevel) { - struct TCmdPItem *v4; // ebx - int v5; // eax - DLevel *v6; // esi - DLevel *v7; // edi - char v8; // al - signed int v9; // eax - char v10; // [esp+Ch] [ebp-4h] - signed int bLevela; // [esp+1Ch] [ebp+Ch] + struct TCmdPItem *v4; // ebx + int v5; // eax + DLevel *v6; // esi + DLevel *v7; // edi + char v8; // al + signed int v9; // eax + char v10; // [esp+Ch] [ebp-4h] + signed int bLevela; // [esp+1Ch] [ebp+Ch] - v10 = x; - v4 = pI; - if (gbMaxPlayers != 1) { - v5 = bLevel; - bLevela = 0; - v6 = &sgLevels[v5]; - v7 = &sgLevels[v5]; - do { - v8 = v7->item[0].bCmd; - if (v7->item[0].bCmd != 1 - && v8 != -1 - && v7->item[0].wIndx == v4->wIndx - && v7->item[0].wCI == v4->wCI - && v7->item[0].dwSeed == v4->dwSeed) { - if (v8 == 2) - return; - TermMsg("Trying to drop a floor item?"); - } - ++bLevela; - v7 = (DLevel *)((char *)v7 + 22); - } while (bLevela < 127); - v9 = 0; - while (v6->item[0].bCmd != -1) { - ++v9; - v6 = (DLevel *)((char *)v6 + 22); - if (v9 >= 127) - return; - } - sgbDeltaChanged = 1; - memcpy(v6, v4, 0x16u); - v6->item[0].x = v10; - v6->item[0].bCmd = 2; - v6->item[0].y = y; - } + v10 = x; + v4 = pI; + if (gbMaxPlayers != 1) { + v5 = bLevel; + bLevela = 0; + v6 = &sgLevels[v5]; + v7 = &sgLevels[v5]; + do { + v8 = v7->item[0].bCmd; + if (v7->item[0].bCmd != 1 + && v8 != -1 + && v7->item[0].wIndx == v4->wIndx + && v7->item[0].wCI == v4->wCI + && v7->item[0].dwSeed == v4->dwSeed) { + if (v8 == 2) + return; + TermMsg("Trying to drop a floor item?"); + } + ++bLevela; + v7 = (DLevel *)((char *)v7 + 22); + } while (bLevela < 127); + v9 = 0; + while (v6->item[0].bCmd != -1) { + ++v9; + v6 = (DLevel *)((char *)v6 + 22); + if (v9 >= 127) + return; + } + sgbDeltaChanged = 1; + memcpy(v6, v4, 0x16u); + v6->item[0].x = v10; + v6->item[0].bCmd = 2; + v6->item[0].y = y; + } } // 67618C: using guessed type char sgbDeltaChanged; // 679660: using guessed type char gbMaxPlayers; void __fastcall check_update_plr(int pnum) { - if (gbMaxPlayers != 1 && pnum == myplr) - pfile_update(1); + if (gbMaxPlayers != 1 && pnum == myplr) + pfile_update(1); } // 679660: using guessed type char gbMaxPlayers; int __fastcall On_SYNCPUTITEM(struct TCmdPItem *pCmd, int pnum) { - if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else if (currlevel == plr[pnum].plrlevel) { - int ii = SyncPutItem(pnum, pCmd->x, pCmd->y, pCmd->wIndx, pCmd->wCI, pCmd->dwSeed, pCmd->bId, pCmd->bDur, pCmd->bMDur, pCmd->bCh, pCmd->bMCh, pCmd->wValue, pCmd->dwBuff); - if (ii != -1) { - PutItemRecord(pCmd->dwSeed, pCmd->wCI, pCmd->wIndx); - delta_put_item(pCmd, item[ii]._ix, item[ii]._iy, plr[pnum].plrlevel); - check_update_plr(pnum); - } - return sizeof(*pCmd); - } else { - PutItemRecord(pCmd->dwSeed, pCmd->wCI, pCmd->wIndx); - delta_put_item(pCmd, pCmd->x, pCmd->y, plr[pnum].plrlevel); - check_update_plr(pnum); - } + if (gbBufferMsgs == 1) + msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + else if (currlevel == plr[pnum].plrlevel) { + int ii = SyncPutItem(pnum, pCmd->x, pCmd->y, pCmd->wIndx, pCmd->wCI, pCmd->dwSeed, pCmd->bId, pCmd->bDur, pCmd->bMDur, pCmd->bCh, pCmd->bMCh, pCmd->wValue, pCmd->dwBuff); + if (ii != -1) { + PutItemRecord(pCmd->dwSeed, pCmd->wCI, pCmd->wIndx); + delta_put_item(pCmd, item[ii]._ix, item[ii]._iy, plr[pnum].plrlevel); + check_update_plr(pnum); + } + return sizeof(*pCmd); + } else { + PutItemRecord(pCmd->dwSeed, pCmd->wCI, pCmd->wIndx); + delta_put_item(pCmd, pCmd->x, pCmd->y, plr[pnum].plrlevel); + check_update_plr(pnum); + } - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_RESPAWNITEM(struct TCmdPItem *pCmd, int pnum) { - if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else { - if (currlevel == plr[pnum].plrlevel && pnum != myplr) - SyncPutItem(pnum, pCmd->x, pCmd->y, pCmd->wIndx, pCmd->wCI, pCmd->dwSeed, pCmd->bId, pCmd->bDur, pCmd->bMDur, pCmd->bCh, pCmd->bMCh, pCmd->wValue, pCmd->dwBuff); - PutItemRecord(pCmd->dwSeed, pCmd->wCI, pCmd->wIndx); - delta_put_item(pCmd, pCmd->x, pCmd->y, plr[pnum].plrlevel); - } + if (gbBufferMsgs == 1) + msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + else { + if (currlevel == plr[pnum].plrlevel && pnum != myplr) + SyncPutItem(pnum, pCmd->x, pCmd->y, pCmd->wIndx, pCmd->wCI, pCmd->dwSeed, pCmd->bId, pCmd->bDur, pCmd->bMDur, pCmd->bCh, pCmd->bMCh, pCmd->wValue, pCmd->dwBuff); + PutItemRecord(pCmd->dwSeed, pCmd->wCI, pCmd->wIndx); + delta_put_item(pCmd, pCmd->x, pCmd->y, plr[pnum].plrlevel); + } - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_ATTACKXY(struct TCmdLoc *pCmd, int pnum) { - if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - MakePlrPath(pnum, pCmd->x, pCmd->y, FALSE); - plr[pnum].destAction = ACTION_ATTACK; - plr[pnum].destParam1 = pCmd->x; - plr[pnum].destParam2 = pCmd->y; - } + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { + MakePlrPath(pnum, pCmd->x, pCmd->y, FALSE); + plr[pnum].destAction = ACTION_ATTACK; + plr[pnum].destParam1 = pCmd->x; + plr[pnum].destParam2 = pCmd->y; + } - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_SATTACKXY(struct TCmdLoc *pCmd, int pnum) { - if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - ClrPlrPath(pnum); - plr[pnum].destAction = ACTION_ATTACK; - plr[pnum].destParam1 = pCmd->x; - plr[pnum].destParam2 = pCmd->y; - } + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { + ClrPlrPath(pnum); + plr[pnum].destAction = ACTION_ATTACK; + plr[pnum].destParam1 = pCmd->x; + plr[pnum].destParam2 = pCmd->y; + } - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_RATTACKXY(struct TCmdLoc *pCmd, int pnum) { - if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - ClrPlrPath(pnum); - plr[pnum].destAction = ACTION_RATTACK; - plr[pnum].destParam1 = pCmd->x; - plr[pnum].destParam2 = pCmd->y; - } + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { + ClrPlrPath(pnum); + plr[pnum].destAction = ACTION_RATTACK; + plr[pnum].destParam1 = pCmd->x; + plr[pnum].destParam2 = pCmd->y; + } - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_SPELLXYD(struct TCmdLocParam3 *pCmd, int pnum) { - if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - if (currlevel != 0 || spelldata[pCmd->wParam1].sTownSpell) { - ClrPlrPath(pnum); - plr[pnum].destAction = ACTION_SPELLWALL; - plr[pnum].destParam1 = pCmd->x; - plr[pnum].destParam2 = pCmd->y; - plr[pnum].destParam3 = pCmd->wParam2; - plr[pnum].destParam4 = pCmd->wParam3; - plr[pnum]._pSpell = pCmd->wParam1; - plr[pnum]._pSplType = plr[pnum]._pRSplType; - plr[pnum]._pSplFrom = 0; - } else - msg_errorf("%s has cast an illegal spell.", plr[pnum]._pName); - } + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { + if (currlevel != 0 || spelldata[pCmd->wParam1].sTownSpell) { + ClrPlrPath(pnum); + plr[pnum].destAction = ACTION_SPELLWALL; + plr[pnum].destParam1 = pCmd->x; + plr[pnum].destParam2 = pCmd->y; + plr[pnum].destParam3 = pCmd->wParam2; + plr[pnum].destParam4 = pCmd->wParam3; + plr[pnum]._pSpell = pCmd->wParam1; + plr[pnum]._pSplType = plr[pnum]._pRSplType; + plr[pnum]._pSplFrom = 0; + } else + msg_errorf("%s has cast an illegal spell.", plr[pnum]._pName); + } - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_SPELLXY(struct TCmdLocParam2 *pCmd, int pnum) { - if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - if (currlevel != 0 || spelldata[pCmd->wParam1].sTownSpell) { - ClrPlrPath(pnum); - plr[pnum].destAction = ACTION_SPELL; - plr[pnum].destParam1 = pCmd->x; - plr[pnum].destParam2 = pCmd->y; - plr[pnum].destParam3 = pCmd->wParam2; - plr[pnum]._pSpell = pCmd->wParam1; - plr[pnum]._pSplType = plr[pnum]._pRSplType; - plr[pnum]._pSplFrom = 0; - } else - msg_errorf("%s has cast an illegal spell.", plr[pnum]._pName); - } + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { + if (currlevel != 0 || spelldata[pCmd->wParam1].sTownSpell) { + ClrPlrPath(pnum); + plr[pnum].destAction = ACTION_SPELL; + plr[pnum].destParam1 = pCmd->x; + plr[pnum].destParam2 = pCmd->y; + plr[pnum].destParam3 = pCmd->wParam2; + plr[pnum]._pSpell = pCmd->wParam1; + plr[pnum]._pSplType = plr[pnum]._pRSplType; + plr[pnum]._pSplFrom = 0; + } else + msg_errorf("%s has cast an illegal spell.", plr[pnum]._pName); + } - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_TSPELLXY(struct TCmdLocParam2 *pCmd, int pnum) { - if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - if (currlevel != 0 || spelldata[pCmd->wParam1].sTownSpell) { - ClrPlrPath(pnum); - plr[pnum].destAction = ACTION_SPELL; - plr[pnum].destParam1 = pCmd->x; - plr[pnum].destParam2 = pCmd->y; - plr[pnum].destParam3 = pCmd->wParam2; - plr[pnum]._pSpell = pCmd->wParam1; - plr[pnum]._pSplType = plr[pnum]._pTSplType; - plr[pnum]._pSplFrom = 2; - } else - msg_errorf("%s has cast an illegal spell.", plr[pnum]._pName); - } + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { + if (currlevel != 0 || spelldata[pCmd->wParam1].sTownSpell) { + ClrPlrPath(pnum); + plr[pnum].destAction = ACTION_SPELL; + plr[pnum].destParam1 = pCmd->x; + plr[pnum].destParam2 = pCmd->y; + plr[pnum].destParam3 = pCmd->wParam2; + plr[pnum]._pSpell = pCmd->wParam1; + plr[pnum]._pSplType = plr[pnum]._pTSplType; + plr[pnum]._pSplFrom = 2; + } else + msg_errorf("%s has cast an illegal spell.", plr[pnum]._pName); + } - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_OPOBJXY(struct TCmdLocParam1 *pCmd, int pnum) { - if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - if (object[pCmd->wParam1]._oSolidFlag || object[pCmd->wParam1]._oDoorFlag) - MakePlrPath(pnum, pCmd->x, pCmd->y, FALSE); - else - MakePlrPath(pnum, pCmd->x, pCmd->y, TRUE); - plr[pnum].destAction = ACTION_OPERATE; - plr[pnum].destParam1 = pCmd->wParam1; - } + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { + if (object[pCmd->wParam1]._oSolidFlag || object[pCmd->wParam1]._oDoorFlag) + MakePlrPath(pnum, pCmd->x, pCmd->y, FALSE); + else + MakePlrPath(pnum, pCmd->x, pCmd->y, TRUE); + plr[pnum].destAction = ACTION_OPERATE; + plr[pnum].destParam1 = pCmd->wParam1; + } - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_DISARMXY(struct TCmdLocParam1 *pCmd, int pnum) { - if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - if (object[pCmd->wParam1]._oSolidFlag || object[pCmd->wParam1]._oDoorFlag) - MakePlrPath(pnum, pCmd->x, pCmd->y, FALSE); - else - MakePlrPath(pnum, pCmd->x, pCmd->y, TRUE); - plr[pnum].destAction = ACTION_DISARM; - plr[pnum].destParam1 = pCmd->wParam1; - } + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { + if (object[pCmd->wParam1]._oSolidFlag || object[pCmd->wParam1]._oDoorFlag) + MakePlrPath(pnum, pCmd->x, pCmd->y, FALSE); + else + MakePlrPath(pnum, pCmd->x, pCmd->y, TRUE); + plr[pnum].destAction = ACTION_DISARM; + plr[pnum].destParam1 = pCmd->wParam1; + } - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_OPOBJT(struct TCmdParam1 *pCmd, int pnum) { - if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - plr[pnum].destAction = ACTION_OPERATETK; - plr[pnum].destParam1 = pCmd->wParam1; - } + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { + plr[pnum].destAction = ACTION_OPERATETK; + plr[pnum].destParam1 = pCmd->wParam1; + } - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_ATTACKID(struct TCmdParam1 *pCmd, int pnum) { - if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - int distx = abs(plr[pnum].WorldX - monster[pCmd->wParam1]._mfutx); - int disty = abs(plr[pnum].WorldY - monster[pCmd->wParam1]._mfuty); - if (distx > 1 || disty > 1) - MakePlrPath(pnum, monster[pCmd->wParam1]._mfutx, monster[pCmd->wParam1]._mfuty, FALSE); - plr[pnum].destAction = ACTION_ATTACKMON; - plr[pnum].destParam1 = pCmd->wParam1; - } + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { + int distx = abs(plr[pnum].WorldX - monster[pCmd->wParam1]._mfutx); + int disty = abs(plr[pnum].WorldY - monster[pCmd->wParam1]._mfuty); + if (distx > 1 || disty > 1) + MakePlrPath(pnum, monster[pCmd->wParam1]._mfutx, monster[pCmd->wParam1]._mfuty, FALSE); + plr[pnum].destAction = ACTION_ATTACKMON; + plr[pnum].destParam1 = pCmd->wParam1; + } - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_ATTACKPID(struct TCmdParam1 *pCmd, int pnum) { - if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - MakePlrPath(pnum, plr[pCmd->wParam1]._px, plr[pCmd->wParam1]._py, FALSE); - plr[pnum].destAction = ACTION_ATTACKPLR; - plr[pnum].destParam1 = pCmd->wParam1; - } + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { + MakePlrPath(pnum, plr[pCmd->wParam1]._px, plr[pCmd->wParam1]._py, FALSE); + plr[pnum].destAction = ACTION_ATTACKPLR; + plr[pnum].destParam1 = pCmd->wParam1; + } - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_RATTACKID(struct TCmdParam1 *pCmd, int pnum) { - if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - ClrPlrPath(pnum); - plr[pnum].destAction = ACTION_RATTACKMON; - plr[pnum].destParam1 = pCmd->wParam1; - } + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { + ClrPlrPath(pnum); + plr[pnum].destAction = ACTION_RATTACKMON; + plr[pnum].destParam1 = pCmd->wParam1; + } - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_RATTACKPID(struct TCmdParam1 *pCmd, int pnum) { - if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - ClrPlrPath(pnum); - plr[pnum].destAction = ACTION_RATTACKPLR; - plr[pnum].destParam1 = pCmd->wParam1; - } + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { + ClrPlrPath(pnum); + plr[pnum].destAction = ACTION_RATTACKPLR; + plr[pnum].destParam1 = pCmd->wParam1; + } - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_SPELLID(struct TCmdParam3 *pCmd, int pnum) { - if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - if (currlevel != 0 || spelldata[pCmd->wParam2].sTownSpell) { - ClrPlrPath(pnum); - plr[pnum].destAction = ACTION_SPELLMON; - plr[pnum].destParam1 = pCmd->wParam1; - plr[pnum].destParam2 = pCmd->wParam3; - plr[pnum]._pSpell = pCmd->wParam2; - plr[pnum]._pSplType = plr[pnum]._pRSplType; - plr[pnum]._pSplFrom = 0; - } else - msg_errorf("%s has cast an illegal spell.", plr[pnum]._pName); - } + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { + if (currlevel != 0 || spelldata[pCmd->wParam2].sTownSpell) { + ClrPlrPath(pnum); + plr[pnum].destAction = ACTION_SPELLMON; + plr[pnum].destParam1 = pCmd->wParam1; + plr[pnum].destParam2 = pCmd->wParam3; + plr[pnum]._pSpell = pCmd->wParam2; + plr[pnum]._pSplType = plr[pnum]._pRSplType; + plr[pnum]._pSplFrom = 0; + } else + msg_errorf("%s has cast an illegal spell.", plr[pnum]._pName); + } - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_SPELLPID(struct TCmdParam3 *pCmd, int pnum) { - if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - if (currlevel != 0 || spelldata[pCmd->wParam2].sTownSpell) { - ClrPlrPath(pnum); - plr[pnum].destAction = ACTION_SPELLPLR; - plr[pnum].destParam1 = pCmd->wParam1; - plr[pnum].destParam2 = pCmd->wParam3; - plr[pnum]._pSpell = pCmd->wParam2; - plr[pnum]._pSplType = plr[pnum]._pRSplType; - plr[pnum]._pSplFrom = 0; - } else - msg_errorf("%s has cast an illegal spell.", plr[pnum]._pName); - } + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { + if (currlevel != 0 || spelldata[pCmd->wParam2].sTownSpell) { + ClrPlrPath(pnum); + plr[pnum].destAction = ACTION_SPELLPLR; + plr[pnum].destParam1 = pCmd->wParam1; + plr[pnum].destParam2 = pCmd->wParam3; + plr[pnum]._pSpell = pCmd->wParam2; + plr[pnum]._pSplType = plr[pnum]._pRSplType; + plr[pnum]._pSplFrom = 0; + } else + msg_errorf("%s has cast an illegal spell.", plr[pnum]._pName); + } - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_TSPELLID(struct TCmdParam3 *pCmd, int pnum) { - if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - if (currlevel != 0 || spelldata[pCmd->wParam2].sTownSpell) { - ClrPlrPath(pnum); - plr[pnum].destAction = ACTION_SPELLMON; - plr[pnum].destParam1 = pCmd->wParam1; - plr[pnum].destParam2 = pCmd->wParam3; - plr[pnum]._pSpell = pCmd->wParam2; - plr[pnum]._pSplType = plr[pnum]._pTSplType; - plr[pnum]._pSplFrom = 2; - } else - msg_errorf("%s has cast an illegal spell.", plr[pnum]._pName); - } + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { + if (currlevel != 0 || spelldata[pCmd->wParam2].sTownSpell) { + ClrPlrPath(pnum); + plr[pnum].destAction = ACTION_SPELLMON; + plr[pnum].destParam1 = pCmd->wParam1; + plr[pnum].destParam2 = pCmd->wParam3; + plr[pnum]._pSpell = pCmd->wParam2; + plr[pnum]._pSplType = plr[pnum]._pTSplType; + plr[pnum]._pSplFrom = 2; + } else + msg_errorf("%s has cast an illegal spell.", plr[pnum]._pName); + } - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_TSPELLPID(struct TCmdParam3 *pCmd, int pnum) { - if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - if (currlevel != 0 || spelldata[pCmd->wParam2].sTownSpell) { - ClrPlrPath(pnum); - plr[pnum].destAction = ACTION_SPELLPLR; - plr[pnum].destParam1 = pCmd->wParam1; - plr[pnum].destParam2 = pCmd->wParam3; - plr[pnum]._pSpell = pCmd->wParam2; - plr[pnum]._pSplType = plr[pnum]._pTSplType; - plr[pnum]._pSplFrom = 2; - } else - msg_errorf("%s has cast an illegal spell.", plr[pnum]._pName); - } + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { + if (currlevel != 0 || spelldata[pCmd->wParam2].sTownSpell) { + ClrPlrPath(pnum); + plr[pnum].destAction = ACTION_SPELLPLR; + plr[pnum].destParam1 = pCmd->wParam1; + plr[pnum].destParam2 = pCmd->wParam3; + plr[pnum]._pSpell = pCmd->wParam2; + plr[pnum]._pSplType = plr[pnum]._pTSplType; + plr[pnum]._pSplFrom = 2; + } else + msg_errorf("%s has cast an illegal spell.", plr[pnum]._pName); + } - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_KNOCKBACK(struct TCmdParam1 *pCmd, int pnum) { - if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - M_GetKnockback(pCmd->wParam1); - M_StartHit(pCmd->wParam1, pnum, 0); - } + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { + M_GetKnockback(pCmd->wParam1); + M_StartHit(pCmd->wParam1, pnum, 0); + } - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_RESURRECT(struct TCmdParam1 *pCmd, int pnum) { - if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else { - DoResurrect(pnum, pCmd->wParam1); - check_update_plr(pnum); - } + if (gbBufferMsgs == 1) + msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + else { + DoResurrect(pnum, pCmd->wParam1); + check_update_plr(pnum); + } - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_HEALOTHER(struct TCmdParam1 *pCmd, int pnum) { - if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) - DoHealOther(pnum, pCmd->wParam1); + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) + DoHealOther(pnum, pCmd->wParam1); - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_TALKXY(struct TCmdLocParam1 *pCmd, int pnum) { - if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - MakePlrPath(pnum, pCmd->x, pCmd->y, FALSE); - plr[pnum].destAction = ACTION_TALK; - plr[pnum].destParam1 = pCmd->wParam1; - } + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { + MakePlrPath(pnum, pCmd->x, pCmd->y, FALSE); + plr[pnum].destAction = ACTION_TALK; + plr[pnum].destParam1 = pCmd->wParam1; + } - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_NEWLVL(struct TCmdParam2 *pCmd, int pnum) { - if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else if (pnum != myplr) - StartNewLvl(pnum, pCmd->wParam1, pCmd->wParam2); + if (gbBufferMsgs == 1) + msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + else if (pnum != myplr) + StartNewLvl(pnum, pCmd->wParam1, pCmd->wParam2); - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_WARP(struct TCmdParam1 *pCmd, int pnum) { - if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else { - StartWarpLvl(pnum, pCmd->wParam1); - if (pnum == myplr && pcurs >= CURSOR_FIRSTITEM) { - item[MAXITEMS] = plr[myplr].HoldItem; - AutoGetItem(myplr, MAXITEMS); - } - } + if (gbBufferMsgs == 1) + msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + else { + StartWarpLvl(pnum, pCmd->wParam1); + if (pnum == myplr && pcurs >= CURSOR_FIRSTITEM) { + item[MAXITEMS] = plr[myplr].HoldItem; + AutoGetItem(myplr, MAXITEMS); + } + } - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_MONSTDEATH(struct TCmdLocParam1 *pCmd, int pnum) { - if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else if (pnum != myplr) { - if (currlevel == plr[pnum].plrlevel) - M_SyncStartKill(pCmd->wParam1, pCmd->x, pCmd->y, pnum); - delta_kill_monster(pCmd->wParam1, pCmd->x, pCmd->y, plr[pnum].plrlevel); - } + if (gbBufferMsgs == 1) + msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + else if (pnum != myplr) { + if (currlevel == plr[pnum].plrlevel) + M_SyncStartKill(pCmd->wParam1, pCmd->x, pCmd->y, pnum); + delta_kill_monster(pCmd->wParam1, pCmd->x, pCmd->y, plr[pnum].plrlevel); + } - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_KILLGOLEM(struct TCmdLocParam1 *pCmd, int pnum) { - if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else if (pnum != myplr) { - if (currlevel == pCmd->wParam1) - M_SyncStartKill(pnum, pCmd->x, pCmd->y, pnum); - delta_kill_monster(pnum, pCmd->x, pCmd->y, plr[pnum].plrlevel); - } + if (gbBufferMsgs == 1) + msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + else if (pnum != myplr) { + if (currlevel == pCmd->wParam1) + M_SyncStartKill(pnum, pCmd->x, pCmd->y, pnum); + delta_kill_monster(pnum, pCmd->x, pCmd->y, plr[pnum].plrlevel); + } - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_AWAKEGOLEM(struct TCmdGolem *pCmd, int pnum) { - if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else if (currlevel != plr[pnum].plrlevel) - delta_sync_golem(pCmd, pnum, pCmd->_currlevel); - else if (pnum != myplr) { - int i; - // check if this player already has an active golem - BOOL addGolem = TRUE; - for (i = 0; i < nummissiles; i++) { - int mi = missileactive[i]; - if (missile[mi]._mitype == MIS_GOLEM && missile[mi]._misource == pnum) { - addGolem = FALSE; - // BUGFIX: break, don't need to check the rest - } - } - if (addGolem) - AddMissile(plr[pnum].WorldX, plr[pnum].WorldY, pCmd->_mx, pCmd->_my, pCmd->_mdir, MIS_GOLEM, 0, pnum, 0, 1); - } + if (gbBufferMsgs == 1) + msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + else if (currlevel != plr[pnum].plrlevel) + delta_sync_golem(pCmd, pnum, pCmd->_currlevel); + else if (pnum != myplr) { + int i; + // check if this player already has an active golem + BOOL addGolem = TRUE; + for (i = 0; i < nummissiles; i++) { + int mi = missileactive[i]; + if (missile[mi]._mitype == MIS_GOLEM && missile[mi]._misource == pnum) { + addGolem = FALSE; + // BUGFIX: break, don't need to check the rest + } + } + if (addGolem) + AddMissile(plr[pnum].WorldX, plr[pnum].WorldY, pCmd->_mx, pCmd->_my, pCmd->_mdir, MIS_GOLEM, 0, pnum, 0, 1); + } - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_MONSTDAMAGE(struct TCmdParam2 *pCmd, int pnum) { - if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else if (pnum != myplr) { - if (currlevel == plr[pnum].plrlevel) { - monster[pCmd->wParam1].mWhoHit |= 1 << pnum; + if (gbBufferMsgs == 1) + msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + else if (pnum != myplr) { + if (currlevel == plr[pnum].plrlevel) { + monster[pCmd->wParam1].mWhoHit |= 1 << pnum; - if (monster[pCmd->wParam1]._mhitpoints) { - monster[pCmd->wParam1]._mhitpoints -= pCmd->wParam2; - if ((monster[pCmd->wParam1]._mhitpoints >> 6) < 1) - monster[pCmd->wParam1]._mhitpoints = 1 << 6; - delta_monster_hp(pCmd->wParam1, monster[pCmd->wParam1]._mhitpoints, plr[pnum].plrlevel); - } - } - } + if (monster[pCmd->wParam1]._mhitpoints) { + monster[pCmd->wParam1]._mhitpoints -= pCmd->wParam2; + if ((monster[pCmd->wParam1]._mhitpoints >> 6) < 1) + monster[pCmd->wParam1]._mhitpoints = 1 << 6; + delta_monster_hp(pCmd->wParam1, monster[pCmd->wParam1]._mhitpoints, plr[pnum].plrlevel); + } + } + } - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_PLRDEAD(struct TCmdParam1 *pCmd, int pnum) { - if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else if (pnum != myplr) - StartPlayerKill(pnum, pCmd->wParam1); - else - check_update_plr(pnum); + if (gbBufferMsgs == 1) + msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + else if (pnum != myplr) + StartPlayerKill(pnum, pCmd->wParam1); + else + check_update_plr(pnum); - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_PLRDAMAGE(struct TCmdDamage *pCmd, int pnum) { - if (pCmd->bPlr == myplr && currlevel != 0) { - if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel && pCmd->dwDam <= 192000) { - if ((plr[myplr]._pHitPoints >> 6) > 0) { - drawhpflag = TRUE; - plr[myplr]._pHitPoints -= pCmd->dwDam; - plr[myplr]._pHPBase -= pCmd->dwDam; - if (plr[myplr]._pHitPoints > plr[myplr]._pMaxHP) { - plr[myplr]._pHitPoints = plr[myplr]._pMaxHP; - plr[myplr]._pHPBase = plr[myplr]._pMaxHPBase; - } - if ((plr[myplr]._pHitPoints >> 6) <= 0) - SyncPlrKill(myplr, 1); - } - } - } + if (pCmd->bPlr == myplr && currlevel != 0) { + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel && pCmd->dwDam <= 192000) { + if ((plr[myplr]._pHitPoints >> 6) > 0) { + drawhpflag = TRUE; + plr[myplr]._pHitPoints -= pCmd->dwDam; + plr[myplr]._pHPBase -= pCmd->dwDam; + if (plr[myplr]._pHitPoints > plr[myplr]._pMaxHP) { + plr[myplr]._pHitPoints = plr[myplr]._pMaxHP; + plr[myplr]._pHPBase = plr[myplr]._pMaxHPBase; + } + if ((plr[myplr]._pHitPoints >> 6) <= 0) + SyncPlrKill(myplr, 1); + } + } + } - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_OPENDOOR(struct TCmdParam1 *pCmd, int pnum) { - if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else { - if (currlevel == plr[pnum].plrlevel) - SyncOpObject(pnum, CMD_OPENDOOR, pCmd->wParam1); - delta_sync_object(pCmd->wParam1, CMD_OPENDOOR, plr[pnum].plrlevel); - } + if (gbBufferMsgs == 1) + msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + else { + if (currlevel == plr[pnum].plrlevel) + SyncOpObject(pnum, CMD_OPENDOOR, pCmd->wParam1); + delta_sync_object(pCmd->wParam1, CMD_OPENDOOR, plr[pnum].plrlevel); + } - return sizeof(*pCmd); + return sizeof(*pCmd); } void __fastcall delta_sync_object(int oi, BYTE bCmd, BYTE bLevel) { - if (gbMaxPlayers != 1) { - sgbDeltaChanged = 1; - sgLevels[bLevel].object[oi].bCmd = bCmd; - } + if (gbMaxPlayers != 1) { + sgbDeltaChanged = 1; + sgLevels[bLevel].object[oi].bCmd = bCmd; + } } // 67618C: using guessed type char sgbDeltaChanged; // 679660: using guessed type char gbMaxPlayers; int __fastcall On_CLOSEDOOR(struct TCmdParam1 *pCmd, int pnum) { - if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else { - if (currlevel == plr[pnum].plrlevel) - SyncOpObject(pnum, CMD_CLOSEDOOR, pCmd->wParam1); - delta_sync_object(pCmd->wParam1, CMD_CLOSEDOOR, plr[pnum].plrlevel); - } + if (gbBufferMsgs == 1) + msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + else { + if (currlevel == plr[pnum].plrlevel) + SyncOpObject(pnum, CMD_CLOSEDOOR, pCmd->wParam1); + delta_sync_object(pCmd->wParam1, CMD_CLOSEDOOR, plr[pnum].plrlevel); + } - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_OPERATEOBJ(struct TCmdParam1 *pCmd, int pnum) { - if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else { - if (currlevel == plr[pnum].plrlevel) - SyncOpObject(pnum, CMD_OPERATEOBJ, pCmd->wParam1); - delta_sync_object(pCmd->wParam1, CMD_OPERATEOBJ, plr[pnum].plrlevel); - } + if (gbBufferMsgs == 1) + msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + else { + if (currlevel == plr[pnum].plrlevel) + SyncOpObject(pnum, CMD_OPERATEOBJ, pCmd->wParam1); + delta_sync_object(pCmd->wParam1, CMD_OPERATEOBJ, plr[pnum].plrlevel); + } - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_PLROPOBJ(struct TCmdParam2 *pCmd, int pnum) { - if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else { - if (currlevel == plr[pnum].plrlevel) - SyncOpObject(pCmd->wParam1, CMD_PLROPOBJ, pCmd->wParam2); - delta_sync_object(pCmd->wParam2, CMD_PLROPOBJ, plr[pnum].plrlevel); - } + if (gbBufferMsgs == 1) + msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + else { + if (currlevel == plr[pnum].plrlevel) + SyncOpObject(pCmd->wParam1, CMD_PLROPOBJ, pCmd->wParam2); + delta_sync_object(pCmd->wParam2, CMD_PLROPOBJ, plr[pnum].plrlevel); + } - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_BREAKOBJ(struct TCmdParam2 *pCmd, int pnum) { - if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else { - if (currlevel == plr[pnum].plrlevel) - SyncBreakObj(pCmd->wParam1, pCmd->wParam2); - delta_sync_object(pCmd->wParam2, CMD_BREAKOBJ, plr[pnum].plrlevel); - } + if (gbBufferMsgs == 1) + msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + else { + if (currlevel == plr[pnum].plrlevel) + SyncBreakObj(pCmd->wParam1, pCmd->wParam2); + delta_sync_object(pCmd->wParam2, CMD_BREAKOBJ, plr[pnum].plrlevel); + } - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_CHANGEPLRITEMS(struct TCmdChItem *pCmd, int pnum) { - if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else if (pnum != myplr) - CheckInvSwap(pnum, pCmd->bLoc, pCmd->wIndx, pCmd->wCI, pCmd->dwSeed, pCmd->bId); + if (gbBufferMsgs == 1) + msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + else if (pnum != myplr) + CheckInvSwap(pnum, pCmd->bLoc, pCmd->wIndx, pCmd->wCI, pCmd->dwSeed, pCmd->bId); - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_DELPLRITEMS(struct TCmdDelItem *pCmd, int pnum) { - if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else if (pnum != myplr) - inv_update_rem_item(pnum, pCmd->bLoc); + if (gbBufferMsgs == 1) + msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + else if (pnum != myplr) + inv_update_rem_item(pnum, pCmd->bLoc); - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_PLRLEVEL(struct TCmdParam1 *pCmd, int pnum) { - if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else if (pCmd->wParam1 <= MAXCHARLEVEL && pnum != myplr) - plr[pnum]._pLevel = pCmd->wParam1; + if (gbBufferMsgs == 1) + msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + else if (pCmd->wParam1 <= MAXCHARLEVEL && pnum != myplr) + plr[pnum]._pLevel = pCmd->wParam1; - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_DROPITEM(struct TCmdPItem *pCmd, int pnum) { - if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else - delta_put_item(pCmd, pCmd->x, pCmd->y, plr[pnum].plrlevel); + if (gbBufferMsgs == 1) + msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + else + delta_put_item(pCmd, pCmd->x, pCmd->y, plr[pnum].plrlevel); - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_SEND_PLRINFO(struct TCmdPlrInfoHdr *pCmd, int pnum) { - if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, pCmd->wBytes + sizeof(*pCmd)); - else - multi_player_joins(pnum, pCmd, pCmd->bCmd == CMD_ACK_PLRINFO); + if (gbBufferMsgs == 1) + msg_send_packet(pnum, pCmd, pCmd->wBytes + sizeof(*pCmd)); + else + multi_player_joins(pnum, pCmd, pCmd->bCmd == CMD_ACK_PLRINFO); - return pCmd->wBytes + sizeof(*pCmd); + return pCmd->wBytes + sizeof(*pCmd); } int __fastcall On_ACK_PLRINFO(struct TCmdPlrInfoHdr *pCmd, int pnum) { - return On_SEND_PLRINFO(pCmd, pnum); + return On_SEND_PLRINFO(pCmd, pnum); } int __fastcall On_PLAYER_JOINLEVEL(struct TCmdLocParam1 *pCmd, int pnum) { - if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else { - plr[pnum]._pLvlChanging = 0; - if (plr[pnum]._pName[0] && !plr[pnum].plractive) { - plr[pnum].plractive = 1; - gbActivePlayers++; - EventPlrMsg("Player '%s' (level %d) just joined the game", plr[pnum]._pName, plr[pnum]._pLevel); - } + if (gbBufferMsgs == 1) + msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + else { + plr[pnum]._pLvlChanging = 0; + if (plr[pnum]._pName[0] && !plr[pnum].plractive) { + plr[pnum].plractive = 1; + gbActivePlayers++; + EventPlrMsg("Player '%s' (level %d) just joined the game", plr[pnum]._pName, plr[pnum]._pLevel); + } - if (plr[pnum].plractive && myplr != pnum) { - plr[pnum].WorldX = pCmd->x; - plr[pnum].WorldY = pCmd->y; - plr[pnum].plrlevel = pCmd->wParam1; - plr[pnum]._pGFXLoad = 0; - if (currlevel == plr[pnum].plrlevel) { - LoadPlrGFX(pnum, PFILE_STAND); - SyncInitPlr(pnum); - if ((plr[pnum]._pHitPoints >> 6) > 0) - StartStand(pnum, 0); - else { - plr[pnum]._pgfxnum = 0; - LoadPlrGFX(pnum, PFILE_DEATH); - plr[pnum]._pmode = PM_DEATH; - NewPlrAnim(pnum, plr[pnum]._pDAnim[0], plr[pnum]._pDFrames, 1, plr[pnum]._pDWidth); - plr[pnum]._pAnimFrame = plr[pnum]._pAnimLen - 1; - plr[pnum]._pVar8 = plr[pnum]._pAnimLen << 1; - dFlags[plr[pnum].WorldX][plr[pnum].WorldY] |= DFLAG_DEAD_PLAYER; - } + if (plr[pnum].plractive && myplr != pnum) { + plr[pnum].WorldX = pCmd->x; + plr[pnum].WorldY = pCmd->y; + plr[pnum].plrlevel = pCmd->wParam1; + plr[pnum]._pGFXLoad = 0; + if (currlevel == plr[pnum].plrlevel) { + LoadPlrGFX(pnum, PFILE_STAND); + SyncInitPlr(pnum); + if ((plr[pnum]._pHitPoints >> 6) > 0) + StartStand(pnum, 0); + else { + plr[pnum]._pgfxnum = 0; + LoadPlrGFX(pnum, PFILE_DEATH); + plr[pnum]._pmode = PM_DEATH; + NewPlrAnim(pnum, plr[pnum]._pDAnim[0], plr[pnum]._pDFrames, 1, plr[pnum]._pDWidth); + plr[pnum]._pAnimFrame = plr[pnum]._pAnimLen - 1; + plr[pnum]._pVar8 = plr[pnum]._pAnimLen << 1; + dFlags[plr[pnum].WorldX][plr[pnum].WorldY] |= DFLAG_DEAD_PLAYER; + } - plr[pnum]._pvid = AddVision(plr[pnum].WorldX, plr[pnum].WorldY, plr[pnum]._pLightRad, pnum == myplr); - plr[pnum]._plid = -1; - } - } - } + plr[pnum]._pvid = AddVision(plr[pnum].WorldX, plr[pnum].WorldY, plr[pnum]._pLightRad, pnum == myplr); + plr[pnum]._plid = -1; + } + } + } - return sizeof(*pCmd); + return sizeof(*pCmd); } // 67862C: using guessed type char gbActivePlayers; int __fastcall On_ACTIVATEPORTAL(struct TCmdLocParam3 *pCmd, int pnum) { - if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else { - ActivatePortal(pnum, pCmd->x, pCmd->y, pCmd->wParam1, pCmd->wParam2, pCmd->wParam3); - if (pnum != myplr) { - if (currlevel == 0) - AddInTownPortal(pnum); - else if (currlevel == plr[pnum].plrlevel) { - int i; - BOOL addPortal = TRUE; - for (i = 0; i < nummissiles; i++) { - int mi = missileactive[i]; - if (missile[mi]._mitype == MIS_TOWN && missile[mi]._misource == pnum) { - addPortal = FALSE; - // BUGFIX: break - } - } - if (addPortal) - AddWarpMissile(pnum, pCmd->x, pCmd->y); - } else - RemovePortalMissile(pnum); - } - delta_open_portal(pnum, pCmd->x, pCmd->y, pCmd->wParam1, pCmd->wParam2, pCmd->wParam3); - } + if (gbBufferMsgs == 1) + msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + else { + ActivatePortal(pnum, pCmd->x, pCmd->y, pCmd->wParam1, pCmd->wParam2, pCmd->wParam3); + if (pnum != myplr) { + if (currlevel == 0) + AddInTownPortal(pnum); + else if (currlevel == plr[pnum].plrlevel) { + int i; + BOOL addPortal = TRUE; + for (i = 0; i < nummissiles; i++) { + int mi = missileactive[i]; + if (missile[mi]._mitype == MIS_TOWN && missile[mi]._misource == pnum) { + addPortal = FALSE; + // BUGFIX: break + } + } + if (addPortal) + AddWarpMissile(pnum, pCmd->x, pCmd->y); + } else + RemovePortalMissile(pnum); + } + delta_open_portal(pnum, pCmd->x, pCmd->y, pCmd->wParam1, pCmd->wParam2, pCmd->wParam3); + } - return sizeof(*pCmd); + return sizeof(*pCmd); } void __fastcall delta_open_portal(int pnum, BYTE x, BYTE y, BYTE bLevel, BYTE bLType, BYTE bSetLvl) { - int v6; // eax + int v6; // eax - v6 = pnum; - sgbDeltaChanged = 1; - sgJunk.portal[v6].y = y; - sgJunk.portal[v6].level = bLevel; - sgJunk.portal[v6].ltype = bLType; - sgJunk.portal[v6].x = x; - sgJunk.portal[v6].setlvl = bSetLvl; + v6 = pnum; + sgbDeltaChanged = 1; + sgJunk.portal[v6].y = y; + sgJunk.portal[v6].level = bLevel; + sgJunk.portal[v6].ltype = bLType; + sgJunk.portal[v6].x = x; + sgJunk.portal[v6].setlvl = bSetLvl; } // 67618C: using guessed type char sgbDeltaChanged; int __fastcall On_DEACTIVATEPORTAL(struct TCmd *pCmd, int pnum) { - if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else { - if (PortalOnLevel(pnum)) - RemovePortalMissile(pnum); - DeactivatePortal(pnum); - RemovePlrPortal(pnum); - } + if (gbBufferMsgs == 1) + msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + else { + if (PortalOnLevel(pnum)) + RemovePortalMissile(pnum); + DeactivatePortal(pnum); + RemovePlrPortal(pnum); + } - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_RETOWN(struct TCmd *pCmd, int pnum) { - if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else { - if (pnum == myplr) { - deathflag = FALSE; - gamemenu_off(); - } - RestartTownLvl(pnum); - } + if (gbBufferMsgs == 1) + msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + else { + if (pnum == myplr) { + deathflag = FALSE; + gamemenu_off(); + } + RestartTownLvl(pnum); + } - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_SETSTR(struct TCmdParam1 *pCmd, int pnum) { - if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else if (pCmd->wParam1 <= 750 && pnum != myplr) - SetPlrStr(pnum, pCmd->wParam1); + if (gbBufferMsgs == 1) + msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + else if (pCmd->wParam1 <= 750 && pnum != myplr) + SetPlrStr(pnum, pCmd->wParam1); - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_SETDEX(struct TCmdParam1 *pCmd, int pnum) { - if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else if (pCmd->wParam1 <= 750 && pnum != myplr) - SetPlrDex(pnum, pCmd->wParam1); + if (gbBufferMsgs == 1) + msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + else if (pCmd->wParam1 <= 750 && pnum != myplr) + SetPlrDex(pnum, pCmd->wParam1); - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_SETMAG(struct TCmdParam1 *pCmd, int pnum) { - if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else if (pCmd->wParam1 <= 750 && pnum != myplr) - SetPlrMag(pnum, pCmd->wParam1); + if (gbBufferMsgs == 1) + msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + else if (pCmd->wParam1 <= 750 && pnum != myplr) + SetPlrMag(pnum, pCmd->wParam1); - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_SETVIT(struct TCmdParam1 *pCmd, int pnum) { - if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else if (pCmd->wParam1 <= 750 && pnum != myplr) - SetPlrVit(pnum, pCmd->wParam1); + if (gbBufferMsgs == 1) + msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + else if (pCmd->wParam1 <= 750 && pnum != myplr) + SetPlrVit(pnum, pCmd->wParam1); - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_STRING(struct TCmdString *pCmd, int pnum) { - return On_STRING2(pnum, pCmd); + return On_STRING2(pnum, pCmd); } int __fastcall On_STRING2(int pnum, struct TCmdString *pCmd) { - int len = strlen(pCmd->str); - if (!gbBufferMsgs) - SendPlrMsg(pnum, pCmd->str); + int len = strlen(pCmd->str); + if (!gbBufferMsgs) + SendPlrMsg(pnum, pCmd->str); - return len + 2; // length of string + nul terminator + sizeof(pCmd->bCmd) + return len + 2; // length of string + nul terminator + sizeof(pCmd->bCmd) } int __fastcall On_SYNCQUEST(struct TCmdQuest *pCmd, int pnum) { - if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else { - if (pnum != myplr) - SetMultiQuest(pCmd->q, pCmd->qstate, pCmd->qlog, pCmd->qvar1); - sgbDeltaChanged = 1; - } + if (gbBufferMsgs == 1) + msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + else { + if (pnum != myplr) + SetMultiQuest(pCmd->q, pCmd->qstate, pCmd->qlog, pCmd->qvar1); + sgbDeltaChanged = 1; + } - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_ENDSHIELD(struct TCmd *pCmd, int pnum) { - if (gbBufferMsgs != 1 && pnum != myplr && currlevel == plr[pnum].plrlevel) { - int i; - for (i = 0; i < nummissiles; i++) { - int mi = missileactive[i]; - if (missile[mi]._mitype == MIS_MANASHIELD && missile[mi]._misource == pnum) { - ClearMissileSpot(mi); - DeleteMissile(mi, i); - } - } - } + if (gbBufferMsgs != 1 && pnum != myplr && currlevel == plr[pnum].plrlevel) { + int i; + for (i = 0; i < nummissiles; i++) { + int mi = missileactive[i]; + if (missile[mi]._mitype == MIS_MANASHIELD && missile[mi]._misource == pnum) { + ClearMissileSpot(mi); + DeleteMissile(mi, i); + } + } + } - return sizeof(*pCmd); + return sizeof(*pCmd); } #ifdef _DEBUG int __fastcall On_CHEAT_EXPERIENCE(struct TCmd *pCmd, int pnum) { - if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else if (plr[pnum]._pLevel < MAXCHARLEVEL - 1) { - plr[pnum]._pExperience = plr[pnum]._pNextExper; - NextPlrLevel(pnum); - } + if (gbBufferMsgs == 1) + msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + else if (plr[pnum]._pLevel < MAXCHARLEVEL - 1) { + plr[pnum]._pExperience = plr[pnum]._pNextExper; + NextPlrLevel(pnum); + } - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_CHEAT_SPELL_LEVEL(struct TCmd *pCmd, int pnum) { - if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else - plr[pnum]._pSplLvl[plr[pnum]._pRSpell]++; + if (gbBufferMsgs == 1) + msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + else + plr[pnum]._pSplLvl[plr[pnum]._pRSpell]++; - return sizeof(*pCmd); + return sizeof(*pCmd); } #endif int __cdecl On_DEBUG(struct TCmd *pCmd) { - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_NOVA(struct TCmdLoc *pCmd, int pnum) { - if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel && pnum != myplr) { - ClrPlrPath(pnum); - plr[pnum]._pSpell = SPL_NOVA; - plr[pnum]._pSplType = 4; - plr[pnum]._pSplFrom = 3; - plr[pnum].destAction = ACTION_SPELL; - plr[pnum].destParam1 = pCmd->x; - plr[pnum].destParam2 = pCmd->y; - } + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel && pnum != myplr) { + ClrPlrPath(pnum); + plr[pnum]._pSpell = SPL_NOVA; + plr[pnum]._pSplType = 4; + plr[pnum]._pSplFrom = 3; + plr[pnum].destAction = ACTION_SPELL; + plr[pnum].destParam1 = pCmd->x; + plr[pnum].destParam2 = pCmd->y; + } - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_SETSHIELD(struct TCmd *pCmd, int pnum) { - if (gbBufferMsgs != 1) - plr[pnum].pManaShield = 1; + if (gbBufferMsgs != 1) + plr[pnum].pManaShield = 1; - return sizeof(*pCmd); + return sizeof(*pCmd); } int __fastcall On_REMSHIELD(struct TCmd *pCmd, int pnum) { - if (gbBufferMsgs != 1) - plr[pnum].pManaShield = 0; + if (gbBufferMsgs != 1) + plr[pnum].pManaShield = 0; - return sizeof(*pCmd); + return sizeof(*pCmd); } diff --git a/Source/msgcmd.cpp b/Source/msgcmd.cpp index 9417ea41..2282f959 100644 --- a/Source/msgcmd.cpp +++ b/Source/msgcmd.cpp @@ -10,8 +10,7 @@ int sgdwMsgCmdTimer; const int msgcmd_inf = 0x7F800000; // weak -struct msgcmd_cpp_init_1 -{ +struct msgcmd_cpp_init_1 { msgcmd_cpp_init_1() { msgcmd_cpp_init_value = msgcmd_inf; @@ -20,8 +19,7 @@ struct msgcmd_cpp_init_1 // 47F150: using guessed type int msgcmd_inf; // 6761A0: using guessed type int msgcmd_cpp_init_value; -struct msgcmd_cpp_init_2 -{ +struct msgcmd_cpp_init_2 { msgcmd_cpp_init_2() { msgcmd_init_event(); @@ -53,14 +51,12 @@ void __cdecl msgcmd_cmd_cleanup() void __cdecl msgcmd_send_chat() { ServerCommand *v0; // esi - int v1; // eax + int v1; // eax - if ( (signed int)sgChat_Cmd.extern_msgs[1] > 0 ) - { + if ((signed int)sgChat_Cmd.extern_msgs[1] > 0) { v0 = sgChat_Cmd.extern_msgs[1]; v1 = GetTickCount(); - if ( (unsigned int)(v1 - sgdwMsgCmdTimer) >= 2000 ) - { + if ((unsigned int)(v1 - sgdwMsgCmdTimer) >= 2000) { sgdwMsgCmdTimer = v1; SNetSendServerChatCommand(v0->command); msgcmd_delete_server_cmd_W(&sgChat_Cmd, v0); @@ -70,7 +66,7 @@ void __cdecl msgcmd_send_chat() bool __fastcall msgcmd_add_server_cmd_W(char *chat_message) { - if ( *chat_message != '/' ) + if (*chat_message != '/') return 0; msgcmd_add_server_cmd(chat_message); return 1; @@ -78,19 +74,17 @@ bool __fastcall msgcmd_add_server_cmd_W(char *chat_message) void __fastcall msgcmd_add_server_cmd(char *command) { - char *v1; // edi - size_t v2; // eax - int v3; // edx - size_t v4; // esi + char *v1; // edi + size_t v2; // eax + int v3; // edx + size_t v4; // esi ChatCmd *v5; // eax v1 = command; v2 = strlen(command); - if ( v2 ) - { + if (v2) { v4 = v2 + 1; - if ( v2 + 1 <= 0x80 ) - { + if (v2 + 1 <= 0x80) { v5 = msgcmd_alloc_event(&sgChat_Cmd, v3, 2, 0, 0); memcpy(&v5->extern_msgs[1], v1, v4); } @@ -111,15 +105,14 @@ void __fastcall msgcmd_init_chatcmd(ChatCmd *chat_cmd) void __fastcall msgcmd_free_event(ChatCmd *a1) { - int v1; // edx + int v1; // edx ChatCmd *v2; // edi ChatCmd *v3; // esi v2 = a1; - while ( 1 ) - { + while (1) { v3 = (ChatCmd *)v2->extern_msgs[1]; - if ( (signed int)v3 <= 0 ) + if ((signed int)v3 <= 0) break; msgcmd_remove_event(v3, v1); SMemFree(v3, ".?AUEXTERNMESSAGE@@", -2, 0); @@ -128,16 +121,16 @@ void __fastcall msgcmd_free_event(ChatCmd *a1) bool __fastcall msgcmd_delete_server_cmd_W(ChatCmd *cmd, ServerCommand *extern_msg) { - char *v2; // eax + char *v2; // eax ServerCommand *v3; // eax - bool v4; // si - ChatCmd *ptr; // [esp+Ch] [ebp+4h] + bool v4; // si + ChatCmd *ptr; // [esp+Ch] [ebp+4h] v2 = (char *)ptr; - if ( !ptr ) + if (!ptr) v2 = (char *)cmd->extern_msgs; v3 = (ServerCommand *)*((_DWORD *)v2 + 1); - if ( (signed int)v3 > 0 ) + if ((signed int)v3 > 0) v4 = (char)v3; else v4 = 0; @@ -148,27 +141,24 @@ bool __fastcall msgcmd_delete_server_cmd_W(ChatCmd *cmd, ServerCommand *extern_m ChatCmd *__fastcall msgcmd_alloc_event(ChatCmd *a1, int a2, int a3, int a4, int a5) { - int v5; // eax + int v5; // eax ChatCmd *v6; // edi ChatCmd *v7; // eax - int v8; // edx + int v8; // edx ChatCmd *v9; // esi v5 = a5; _LOBYTE(v5) = a5 | 8; v6 = a1; v7 = (ChatCmd *)SMemAlloc(a4 + 136, ".?AUEXTERNMESSAGE@@", -2, v5); - if ( v7 ) - { + if (v7) { v7->next = 0; v7->extern_msgs[0] = 0; v9 = v7; - } - else - { + } else { v9 = 0; } - if ( a3 ) + if (a3) msgcmd_event_type(v6, v8, (int *)v9, a3, 0); return v9; } @@ -180,9 +170,8 @@ void __fastcall msgcmd_remove_event(ChatCmd *a1, int a2) v2 = (ServerCommand **)a1; msgcmd_cleanup_extern_msg((ServerCommand **)a1); msgcmd_cleanup_extern_msg(v2); - if ( a2 & 1 ) - { - if ( v2 ) + if (a2 & 1) { + if (v2) SMemFree(v2, "delete", -1, 0); } } @@ -190,43 +179,37 @@ void __fastcall msgcmd_remove_event(ChatCmd *a1, int a2) void __fastcall msgcmd_event_type(ChatCmd *a1, int a2, int *a3, int a4, int a5) { ChatCmd *v5; // edi - int *v6; // esi - int *v7; // eax - int v8; // ecx - int v9; // edx - int v10; // ecx - int v11; // edx + int *v6; // esi + int *v7; // eax + int v8; // ecx + int v9; // edx + int v10; // ecx + int v11; // edx v5 = a1; v6 = a3; - if ( !a3 ) + if (!a3) v6 = (int *)a1->extern_msgs; - if ( *v6 ) + if (*v6) msgcmd_cleanup_extern_msg((ServerCommand **)v6); v7 = (int *)a5; - if ( !a5 ) + if (!a5) v7 = (int *)v5->extern_msgs; - if ( a4 == 1 ) - { + if (a4 == 1) { *v6 = (int)v7; v6[1] = v7[1]; v9 = v7[1]; v10 = (int)v5->next; - if ( v9 > 0 ) - { - if ( v10 < 0 ) + if (v9 > 0) { + if (v10 < 0) v10 = (int)v7 - *(_DWORD *)(*v7 + 4); v11 = v10 + v9; - } - else - { + } else { v11 = ~v9; } *(_DWORD *)v11 = (unsigned int)v6; v7[1] = (int)a3; - } - else if ( a4 == 2 ) - { + } else if (a4 == 2) { v8 = *v7; *v6 = *v7; v6[1] = *(_DWORD *)(v8 + 4); @@ -237,14 +220,13 @@ void __fastcall msgcmd_event_type(ChatCmd *a1, int a2, int *a3, int a4, int a5) void __fastcall msgcmd_cleanup_chatcmd_1(ChatCmd *a1) { - ChatCmd *v1; // esi + ChatCmd *v1; // esi ServerCommand **v2; // ecx v1 = a1; - while ( 1 ) - { + while (1) { v2 = (ServerCommand **)v1->extern_msgs[1]; - if ( (signed int)v2 <= 0 ) + if ((signed int)v2 <= 0) break; msgcmd_cleanup_extern_msg(v2); } @@ -253,14 +235,13 @@ void __fastcall msgcmd_cleanup_chatcmd_1(ChatCmd *a1) void __fastcall msgcmd_cleanup_extern_msg(ServerCommand **extern_msgs) { ServerCommand *v1; // esi - signed int v2; // edx - int v3; // edx + signed int v2; // edx + int v3; // edx v1 = *extern_msgs; - if ( *extern_msgs ) - { + if (*extern_msgs) { v2 = (signed int)extern_msgs[1]; - if ( v2 > 0 ) + if (v2 > 0) v3 = (int)extern_msgs + v2 - v1->field_4; else v3 = ~v2; diff --git a/Source/multi.cpp b/Source/multi.cpp index 3173f5c9..7a2cb7a5 100644 --- a/Source/multi.cpp +++ b/Source/multi.cpp @@ -30,342 +30,342 @@ int player_state[MAX_PLRS]; const int multi_inf = 0x7F800000; // weak const int event_types[3] = { - EVENT_TYPE_PLAYER_LEAVE_GAME, - EVENT_TYPE_PLAYER_CREATE_GAME, - EVENT_TYPE_PLAYER_MESSAGE + EVENT_TYPE_PLAYER_LEAVE_GAME, + EVENT_TYPE_PLAYER_CREATE_GAME, + EVENT_TYPE_PLAYER_MESSAGE }; struct multi_cpp_init { - multi_cpp_init() - { - multi_cpp_init_value = multi_inf; - } + multi_cpp_init() + { + multi_cpp_init_value = multi_inf; + } } _multi_cpp_init; // 47F154: using guessed type int multi_inf; // 678620: using guessed type int multi_cpp_init_value; void __fastcall multi_msg_add(unsigned char *a1, unsigned char a2) { - if (a1) { - if (a2) - tmsg_add(a1, a2); - } + if (a1) { + if (a2) + tmsg_add(a1, a2); + } } void __fastcall NetSendLoPri(unsigned char *pbMsg, unsigned char bLen) { - unsigned char *v2; // esi - unsigned char v3; // bl - int v4; // edx + unsigned char *v2; // esi + unsigned char v3; // bl + int v4; // edx - v2 = pbMsg; - v3 = bLen; - if (pbMsg) { - if (bLen) { - multi_copy_packet(pkdata_678658, pbMsg, bLen); - _LOBYTE(v4) = v3; - multi_send_packet(v2, v4); - } - } + v2 = pbMsg; + v3 = bLen; + if (pbMsg) { + if (bLen) { + multi_copy_packet(pkdata_678658, pbMsg, bLen); + _LOBYTE(v4) = v3; + multi_send_packet(v2, v4); + } + } } void __fastcall multi_copy_packet(void *a1, void *packet, int size) { - int v3; // eax - int v4; // ebx - char *v5; // esi + int v3; // eax + int v4; // ebx + char *v5; // esi - v3 = *(_DWORD *)a1; - v4 = *(_DWORD *)a1 + (unsigned char)size; - if ((unsigned int)(v4 + 2) <= 0x1000) { - *(_DWORD *)a1 = v4 + 1; - *((_BYTE *)a1 + v3 + 4) = size; - v5 = (char *)a1 + v3 + 5; - memcpy(v5, packet, (unsigned char)size); - v5[(unsigned char)size] = 0; - } + v3 = *(_DWORD *)a1; + v4 = *(_DWORD *)a1 + (unsigned char)size; + if ((unsigned int)(v4 + 2) <= 0x1000) { + *(_DWORD *)a1 = v4 + 1; + *((_BYTE *)a1 + v3 + 4) = size; + v5 = (char *)a1 + v3 + 5; + memcpy(v5, packet, (unsigned char)size); + v5[(unsigned char)size] = 0; + } } void __fastcall multi_send_packet(void *packet, int dwSize) { - void *v2; // esi - unsigned char v3; // bl - TPkt pkt; // [esp+8h] [ebp-200h] + void *v2; // esi + unsigned char v3; // bl + TPkt pkt; // [esp+8h] [ebp-200h] - v2 = packet; - v3 = dwSize; - NetRecvPlrData(&pkt); - pkt.hdr.wLen = v3 + 19; - memcpy(pkt.body, v2, v3); - if (!SNetSendMessage(myplr, &pkt.hdr, (unsigned short)pkt.hdr.wLen)) - nthread_terminate_game("SNetSendMessage0"); + v2 = packet; + v3 = dwSize; + NetRecvPlrData(&pkt); + pkt.hdr.wLen = v3 + 19; + memcpy(pkt.body, v2, v3); + if (!SNetSendMessage(myplr, &pkt.hdr, (unsigned short)pkt.hdr.wLen)) + nthread_terminate_game("SNetSendMessage0"); } void __fastcall NetRecvPlrData(TPkt *pkt) { - pkt->hdr.wCheck = 'ip'; - pkt->hdr.px = plr[myplr].WorldX; - pkt->hdr.py = plr[myplr].WorldY; - pkt->hdr.targx = plr[myplr]._ptargx; - pkt->hdr.targy = plr[myplr]._ptargy; - pkt->hdr.php = plr[myplr]._pHitPoints; - pkt->hdr.pmhp = plr[myplr]._pMaxHP; - pkt->hdr.bstr = plr[myplr]._pBaseStr; - pkt->hdr.bmag = plr[myplr]._pBaseMag; - pkt->hdr.bdex = plr[myplr]._pBaseDex; + pkt->hdr.wCheck = 'ip'; + pkt->hdr.px = plr[myplr].WorldX; + pkt->hdr.py = plr[myplr].WorldY; + pkt->hdr.targx = plr[myplr]._ptargx; + pkt->hdr.targy = plr[myplr]._ptargy; + pkt->hdr.php = plr[myplr]._pHitPoints; + pkt->hdr.pmhp = plr[myplr]._pMaxHP; + pkt->hdr.bstr = plr[myplr]._pBaseStr; + pkt->hdr.bmag = plr[myplr]._pBaseMag; + pkt->hdr.bdex = plr[myplr]._pBaseDex; } void __fastcall NetSendHiPri(BYTE *pbMsg, BYTE bLen) { - unsigned char *v2; // edi - unsigned char v3; // bl - int v4; // edx - unsigned char *v5; // eax - TSyncHeader *v6; // eax - int v7; // eax - int v8; // eax - TPkt pkt; // [esp+Ch] [ebp-204h] - int size; // [esp+20Ch] [ebp-4h] + unsigned char *v2; // edi + unsigned char v3; // bl + int v4; // edx + unsigned char *v5; // eax + TSyncHeader *v6; // eax + int v7; // eax + int v8; // eax + TPkt pkt; // [esp+Ch] [ebp-204h] + int size; // [esp+20Ch] [ebp-4h] - v2 = pbMsg; - v3 = bLen; - if (pbMsg && bLen) { - multi_copy_packet(pkdata_6761C0, pbMsg, bLen); - _LOBYTE(v4) = v3; - multi_send_packet(v2, v4); - } - if (!dword_678628) { - dword_678628 = 1; - NetRecvPlrData(&pkt); - size = gdwNormalMsgSize - 19; - v5 = multi_recv_packet(pkdata_6761C0, pkt.body, &size); - v6 = (TSyncHeader *)multi_recv_packet(pkdata_678658, v5, &size); - v7 = sync_all_monsters(v6, size); - size = v7; - v8 = gdwNormalMsgSize - v7; - pkt.hdr.wLen = v8; - if (!SNetSendMessage(-2, &pkt.hdr, v8)) - nthread_terminate_game("SNetSendMessage"); - } + v2 = pbMsg; + v3 = bLen; + if (pbMsg && bLen) { + multi_copy_packet(pkdata_6761C0, pbMsg, bLen); + _LOBYTE(v4) = v3; + multi_send_packet(v2, v4); + } + if (!dword_678628) { + dword_678628 = 1; + NetRecvPlrData(&pkt); + size = gdwNormalMsgSize - 19; + v5 = multi_recv_packet(pkdata_6761C0, pkt.body, &size); + v6 = (TSyncHeader *)multi_recv_packet(pkdata_678658, v5, &size); + v7 = sync_all_monsters(v6, size); + size = v7; + v8 = gdwNormalMsgSize - v7; + pkt.hdr.wLen = v8; + if (!SNetSendMessage(-2, &pkt.hdr, v8)) + nthread_terminate_game("SNetSendMessage"); + } } // 678628: using guessed type int dword_678628; // 679760: using guessed type int gdwNormalMsgSize; unsigned char *__fastcall multi_recv_packet(void *packet, unsigned char *a2, int *a3) { - char *v3; // esi - unsigned char *result; // eax - char *v5; // ebx - size_t v6; // edi - char *v7; // ebx - unsigned char *v8; // [esp+4h] [ebp-4h] + char *v3; // esi + unsigned char *result; // eax + char *v5; // ebx + size_t v6; // edi + char *v7; // ebx + unsigned char *v8; // [esp+4h] [ebp-4h] - v3 = (char *)packet; - result = a2; - v8 = a2; - if (*(_DWORD *)packet) { - v5 = (char *)packet + 4; - while (*v5) { - v6 = (unsigned char)*v5; - if (v6 > *a3) - break; - v7 = v5 + 1; - memcpy(v8, v7, v6); - v8 += v6; - v5 = &v7[v6]; - *a3 -= v6; - } - memcpy(v3 + 4, v5, (size_t)&v3[*(_DWORD *)v3 - (_DWORD)v5 + 5]); - *(_DWORD *)v3 += v3 - v5 + 4; - result = v8; - } - return result; + v3 = (char *)packet; + result = a2; + v8 = a2; + if (*(_DWORD *)packet) { + v5 = (char *)packet + 4; + while (*v5) { + v6 = (unsigned char)*v5; + if (v6 > *a3) + break; + v7 = v5 + 1; + memcpy(v8, v7, v6); + v8 += v6; + v5 = &v7[v6]; + *a3 -= v6; + } + memcpy(v3 + 4, v5, (size_t)&v3[*(_DWORD *)v3 - (_DWORD)v5 + 5]); + *(_DWORD *)v3 += v3 - v5 + 4; + result = v8; + } + return result; } void __fastcall multi_send_msg_packet(int a1, unsigned char *a2, unsigned char len) { - //const void *v3; // edx - signed int v4; // ebx - unsigned int v5; // edi - TPkt pkt; // [esp+Ch] [ebp-204h] - int v8; // [esp+20Ch] [ebp-4h] + //const void *v3; // edx + signed int v4; // ebx + unsigned int v5; // edi + TPkt pkt; // [esp+Ch] [ebp-204h] + int v8; // [esp+20Ch] [ebp-4h] - v8 = a1; - NetRecvPlrData(&pkt); - pkt.hdr.wLen = len + 19; - memcpy(pkt.body, a2, len); - v4 = 1; - v5 = 0; - while (1) { - if (v4 & v8) { - if (!SNetSendMessage(v5, &pkt.hdr, len + 19) && SErrGetLastError() != STORM_ERROR_INVALID_PLAYER) - break; - } - ++v5; - v4 *= 2; - if (v5 >= 4) - return; - } - nthread_terminate_game("SNetSendMessage"); + v8 = a1; + NetRecvPlrData(&pkt); + pkt.hdr.wLen = len + 19; + memcpy(pkt.body, a2, len); + v4 = 1; + v5 = 0; + while (1) { + if (v4 & v8) { + if (!SNetSendMessage(v5, &pkt.hdr, len + 19) && SErrGetLastError() != STORM_ERROR_INVALID_PLAYER) + break; + } + ++v5; + v4 *= 2; + if (v5 >= 4) + return; + } + nthread_terminate_game("SNetSendMessage"); } void __cdecl multi_msg_countdown() { - int v0; // esi + int v0; // esi - v0 = 0; - do { - if (player_state[v0] & 0x20000) { - if (gdwMsgLenTbl[v0] == 4) - multi_parse_turn(v0, *(_DWORD *)glpMsgTbl[v0]); - } - ++v0; - } while (v0 < MAX_PLRS); + v0 = 0; + do { + if (player_state[v0] & 0x20000) { + if (gdwMsgLenTbl[v0] == 4) + multi_parse_turn(v0, *(_DWORD *)glpMsgTbl[v0]); + } + ++v0; + } while (v0 < MAX_PLRS); } void __fastcall multi_parse_turn(int pnum, int turn) { - int v2; // esi - unsigned int v3; // esi + int v2; // esi + unsigned int v3; // esi - v2 = turn; - if (turn < 0) - multi_handle_turn_upper_bit(pnum); - v3 = v2 & 0x7FFFFFFF; - if (sgbSentThisCycle < gdwTurnsInTransit + v3) { - if (v3 >= 0x7FFFFFFF) - v3 = (unsigned short)v3; - sgbSentThisCycle = v3 + gdwTurnsInTransit; - sgdwGameLoops = 4 * v3 * (unsigned char)byte_679704; - } + v2 = turn; + if (turn < 0) + multi_handle_turn_upper_bit(pnum); + v3 = v2 & 0x7FFFFFFF; + if (sgbSentThisCycle < gdwTurnsInTransit + v3) { + if (v3 >= 0x7FFFFFFF) + v3 = (unsigned short)v3; + sgbSentThisCycle = v3 + gdwTurnsInTransit; + sgdwGameLoops = 4 * v3 * (unsigned char)byte_679704; + } } // 679704: using guessed type char byte_679704; // 679738: using guessed type int gdwTurnsInTransit; void __fastcall multi_handle_turn_upper_bit(int pnum) { - signed int v1; // eax + signed int v1; // eax - v1 = 0; - do { - if (player_state[v1] & 0x10000 && v1 != pnum) - break; - ++v1; - } while (v1 < MAX_PLRS); - if (myplr == v1) { - sgbSendDeltaTbl[pnum] = 1; - } else if (myplr == pnum) { - gbDeltaSender = v1; - } + v1 = 0; + do { + if (player_state[v1] & 0x10000 && v1 != pnum) + break; + ++v1; + } while (v1 < MAX_PLRS); + if (myplr == v1) { + sgbSendDeltaTbl[pnum] = 1; + } else if (myplr == pnum) { + gbDeltaSender = v1; + } } // 6796E4: using guessed type char gbDeltaSender; void __fastcall multi_player_left(int pnum, int reason) { - sgbPlayerLeftGameTbl[pnum] = 1; - sgdwPlayerLeftReasonTbl[pnum] = reason; - multi_clear_left_tbl(); + sgbPlayerLeftGameTbl[pnum] = 1; + sgdwPlayerLeftReasonTbl[pnum] = reason; + multi_clear_left_tbl(); } void __cdecl multi_clear_left_tbl() { - int v0; // esi + int v0; // esi - v0 = 0; - do { - if (sgbPlayerLeftGameTbl[v0]) { - if (gbBufferMsgs == 1) - msg_send_drop_pkt(v0, sgdwPlayerLeftReasonTbl[v0]); - else - multi_player_left_msg(v0, 1); - sgbPlayerLeftGameTbl[v0] = 0; - sgdwPlayerLeftReasonTbl[v0] = 0; - } - ++v0; - } while (v0 < MAX_PLRS); + v0 = 0; + do { + if (sgbPlayerLeftGameTbl[v0]) { + if (gbBufferMsgs == 1) + msg_send_drop_pkt(v0, sgdwPlayerLeftReasonTbl[v0]); + else + multi_player_left_msg(v0, 1); + sgbPlayerLeftGameTbl[v0] = 0; + sgdwPlayerLeftReasonTbl[v0] = 0; + } + ++v0; + } while (v0 < MAX_PLRS); } // 676194: using guessed type char gbBufferMsgs; void __fastcall multi_player_left_msg(int pnum, int left) { - int v2; // edi - int v3; // ebx - int v4; // esi - char *v5; // eax - int v6; // edi + int v2; // edi + int v3; // ebx + int v4; // esi + char *v5; // eax + int v6; // edi - v2 = pnum; - v3 = left; - v4 = pnum; - if (plr[pnum].plractive) { - RemovePlrFromMap(pnum); - RemovePortalMissile(v2); - DeactivatePortal(v2); - RemovePlrPortal(v2); - RemovePlrMissiles(v2); - if (v3) { - v5 = "Player '%s' just left the game"; - v6 = sgdwPlayerLeftReasonTbl[v2] - 0x40000004; - if (v6) { - if (v6 == 2) - v5 = "Player '%s' dropped due to timeout"; - } else { - v5 = "Player '%s' killed Diablo and left the game!"; - gbSomebodyWonGameKludge = 1; - } - EventPlrMsg(v5, plr[v4]._pName); - } - plr[v4].plractive = 0; - plr[v4]._pName[0] = 0; - --gbActivePlayers; - } + v2 = pnum; + v3 = left; + v4 = pnum; + if (plr[pnum].plractive) { + RemovePlrFromMap(pnum); + RemovePortalMissile(v2); + DeactivatePortal(v2); + RemovePlrPortal(v2); + RemovePlrMissiles(v2); + if (v3) { + v5 = "Player '%s' just left the game"; + v6 = sgdwPlayerLeftReasonTbl[v2] - 0x40000004; + if (v6) { + if (v6 == 2) + v5 = "Player '%s' dropped due to timeout"; + } else { + v5 = "Player '%s' killed Diablo and left the game!"; + gbSomebodyWonGameKludge = 1; + } + EventPlrMsg(v5, plr[v4]._pName); + } + plr[v4].plractive = 0; + plr[v4]._pName[0] = 0; + --gbActivePlayers; + } } // 6761B8: using guessed type char gbSomebodyWonGameKludge; // 67862C: using guessed type char gbActivePlayers; void __cdecl multi_net_ping() { - sgbTimeout = 1; - sglTimeoutStart = GetTickCount(); + sgbTimeout = 1; + sglTimeoutStart = GetTickCount(); } // 678644: using guessed type int sglTimeoutStart; // 679661: using guessed type char sgbTimeout; int __cdecl multi_handle_delta() { - int v0; // esi - int recieved; // [esp+4h] [ebp-4h] + int v0; // esi + int recieved; // [esp+4h] [ebp-4h] - if (gbGameDestroyed) { - gbRunGame = FALSE; - return 0; - } - v0 = 0; - do { - if (sgbSendDeltaTbl[v0]) { - sgbSendDeltaTbl[v0] = 0; - DeltaExportData(v0); - } - ++v0; - } while (v0 < MAX_PLRS); - sgbSentThisCycle = nthread_send_and_recv_turn(sgbSentThisCycle, 1); - if (!nthread_recv_turns(&recieved)) { - multi_begin_timeout(); - return 0; - } - sgbTimeout = 0; - if (recieved) { - if (dword_678628) { - dword_678628 = 0; - if (!multi_check_pkt_valid(pkdata_6761C0)) - NetSendHiPri(0, 0); - } else { - NetSendHiPri(0, 0); - dword_678628 = 0; - } - } - multi_mon_seeds(); - return 1; + if (gbGameDestroyed) { + gbRunGame = FALSE; + return 0; + } + v0 = 0; + do { + if (sgbSendDeltaTbl[v0]) { + sgbSendDeltaTbl[v0] = 0; + DeltaExportData(v0); + } + ++v0; + } while (v0 < MAX_PLRS); + sgbSentThisCycle = nthread_send_and_recv_turn(sgbSentThisCycle, 1); + if (!nthread_recv_turns(&recieved)) { + multi_begin_timeout(); + return 0; + } + sgbTimeout = 0; + if (recieved) { + if (dword_678628) { + dword_678628 = 0; + if (!multi_check_pkt_valid(pkdata_6761C0)) + NetSendHiPri(0, 0); + } else { + NetSendHiPri(0, 0); + dword_678628 = 0; + } + } + multi_mon_seeds(); + return 1; } // 678628: using guessed type int dword_678628; // 67862D: using guessed type char gbGameDestroyed; @@ -374,76 +374,76 @@ int __cdecl multi_handle_delta() // Microsoft VisualC 2-11/net runtime int __fastcall multi_check_pkt_valid(char *a1) { - return *(_DWORD *)a1 == 0; + return *(_DWORD *)a1 == 0; } void __cdecl multi_mon_seeds() { - unsigned int v0; // eax - int v1; // edx - int *v2; // ecx - int v3; // esi + unsigned int v0; // eax + int v1; // edx + int *v2; // ecx + int v3; // esi - v0 = _rotr(++sgdwGameLoops, 8); - v1 = 0; - v2 = &monster[0]._mAISeed; - do { - v3 = v1++ + v0; - *v2 = v3; - v2 += 57; - } while ((signed int)v2 < (signed int)&monster[MAXMONSTERS]._mAISeed); + v0 = _rotr(++sgdwGameLoops, 8); + v1 = 0; + v2 = &monster[0]._mAISeed; + do { + v3 = v1++ + v0; + *v2 = v3; + v2 += 57; + } while ((signed int)v2 < (signed int)&monster[MAXMONSTERS]._mAISeed); } void __cdecl multi_begin_timeout() { - unsigned char bGroupPlayers; // bl - signed int v1; // eax - signed int nLowestActive; // esi - signed int nLowestPlayer; // edi - signed int v4; // eax - int v5; // edx - unsigned char v6; // [esp+Fh] [ebp-1h] + unsigned char bGroupPlayers; // bl + signed int v1; // eax + signed int nLowestActive; // esi + signed int nLowestPlayer; // edi + signed int v4; // eax + int v5; // edx + unsigned char v6; // [esp+Fh] [ebp-1h] - bGroupPlayers = 0; + bGroupPlayers = 0; #ifdef _DEBUG - if (sgbTimeout && !debug_mode_key_i) + if (sgbTimeout && !debug_mode_key_i) #else - if (sgbTimeout) + if (sgbTimeout) #endif - { - v1 = GetTickCount() - sglTimeoutStart; - if (v1 <= 20000) { - if (v1 >= 10000) { - v6 = 0; - nLowestActive = -1; - nLowestPlayer = -1; - v4 = 0; - do { - v5 = player_state[v4]; - if (v5 & 0x10000) { - if (nLowestPlayer == -1) - nLowestPlayer = v4; - if (v5 & 0x40000) { - ++bGroupPlayers; - if (nLowestActive == -1) - nLowestActive = v4; - } else { - ++v6; - } - } - ++v4; - } while (v4 < MAX_PLRS); - if (bGroupPlayers >= v6 && (bGroupPlayers != v6 || nLowestPlayer == nLowestActive)) { - if (nLowestActive == myplr) - multi_check_drop_player(); - } else { - gbGameDestroyed = 1; - } - } - } else { - gbRunGame = FALSE; - } - } + { + v1 = GetTickCount() - sglTimeoutStart; + if (v1 <= 20000) { + if (v1 >= 10000) { + v6 = 0; + nLowestActive = -1; + nLowestPlayer = -1; + v4 = 0; + do { + v5 = player_state[v4]; + if (v5 & 0x10000) { + if (nLowestPlayer == -1) + nLowestPlayer = v4; + if (v5 & 0x40000) { + ++bGroupPlayers; + if (nLowestActive == -1) + nLowestActive = v4; + } else { + ++v6; + } + } + ++v4; + } while (v4 < MAX_PLRS); + if (bGroupPlayers >= v6 && (bGroupPlayers != v6 || nLowestPlayer == nLowestActive)) { + if (nLowestActive == myplr) + multi_check_drop_player(); + } else { + gbGameDestroyed = 1; + } + } + } else { + gbRunGame = FALSE; + } + } } // 67862D: using guessed type char gbGameDestroyed; // 678644: using guessed type int sglTimeoutStart; @@ -451,369 +451,369 @@ void __cdecl multi_begin_timeout() void __cdecl multi_check_drop_player() { - int v0; // esi - int v1; // eax + int v0; // esi + int v1; // eax - v0 = 0; - do { - v1 = player_state[v0]; - if (!(v1 & 0x40000)) { - if (v1 & 0x10000) - SNetDropPlayer(v0, 0x40000006); - } - ++v0; - } while (v0 < MAX_PLRS); + v0 = 0; + do { + v1 = player_state[v0]; + if (!(v1 & 0x40000)) { + if (v1 & 0x10000) + SNetDropPlayer(v0, 0x40000006); + } + ++v0; + } while (v0 < MAX_PLRS); } void __cdecl multi_process_network_packets() { - //int v0; // eax - TPktHdr *v1; // ecx - TPktHdr *v2; // edi - int v3; // eax - bool v4; // zf - unsigned char *v5; // esi - int v6; // ebx - int v7; // eax - int v8; // ecx - int v9; // eax - int v10; // eax - int v11; // esi - int v12; // eax - int v13; // ecx - int v14; // eax - //int v15; // eax - TPktHdr *pkt; // [esp+0h] [ebp-Ch] - int len; // [esp+4h] [ebp-8h] - char arglist[4]; // [esp+8h] [ebp-4h] /* fix, int */ + //int v0; // eax + TPktHdr *v1; // ecx + TPktHdr *v2; // edi + int v3; // eax + bool v4; // zf + unsigned char *v5; // esi + int v6; // ebx + int v7; // eax + int v8; // ecx + int v9; // eax + int v10; // eax + int v11; // esi + int v12; // eax + int v13; // ecx + int v14; // eax + //int v15; // eax + TPktHdr *pkt; // [esp+0h] [ebp-Ch] + int len; // [esp+4h] [ebp-8h] + char arglist[4]; // [esp+8h] [ebp-4h] /* fix, int */ - multi_clear_left_tbl(); - multi_process_tmsgs(); - //_LOBYTE(v0) = SNetReceiveMessage((int *)arglist, (char **)&pkt, &len); - if (SNetReceiveMessage((int *)arglist, (char **)&pkt, &len)) { - do { - ++pkt_counter; - multi_clear_left_tbl(); - v1 = pkt; - v2 = pkt; - if ((unsigned int)len >= 0x13 - && *(_DWORD *)arglist < 4u - && pkt->wCheck == 'ip' - && (unsigned short)pkt->wLen == len) { - v3 = *(_DWORD *)arglist; - v4 = *(_DWORD *)arglist == myplr; - plr[v3]._pownerx = (unsigned char)pkt->px; - v5 = &v1->py; - plr[v3]._pownery = (unsigned char)v1->py; - if (!v4) { - v4 = gbBufferMsgs == 1; - plr[v3]._pHitPoints = v1->php; - plr[v3]._pMaxHP = v1->pmhp; - plr[v3]._pBaseStr = (unsigned char)v1->bstr; - plr[v3]._pBaseMag = (unsigned char)v1->bmag; - plr[v3]._pBaseDex = (unsigned char)v1->bdex; - if (!v4 && plr[v3].plractive && plr[v3]._pHitPoints) { - if (currlevel != plr[v3].plrlevel || plr[v3]._pLvlChanging) { - plr[v3].WorldX = (unsigned char)v1->px; - plr[v3].WorldY = (unsigned char)*v5; - plr[v3]._px = (unsigned char)v1->px; - plr[v3]._py = (unsigned char)*v5; - plr[v3]._ptargx = (unsigned char)v1->targx; - plr[v3]._ptargy = (unsigned char)v1->targy; - } else { - v6 = abs(plr[v3].WorldX - (unsigned char)v1->px); - v7 = abs(plr[*(_DWORD *)arglist].WorldY - (unsigned char)*v5); - if ((v6 > 3 || v7 > 3) && !dPlayer[(unsigned char)v2->px][(unsigned char)*v5]) { - FixPlrWalkTags(*(int *)arglist); - v8 = *(_DWORD *)arglist; - v9 = *(_DWORD *)arglist; - plr[v9]._poldx = plr[*(_DWORD *)arglist].WorldX; - plr[v9]._poldy = plr[v9].WorldY; - FixPlrWalkTags(v8); - v10 = *(_DWORD *)arglist; - plr[v10].WorldX = (unsigned char)v2->px; - plr[v10].WorldY = (unsigned char)*v5; - plr[v10]._px = (unsigned char)v2->px; - plr[v10]._py = (unsigned char)*v5; - dPlayer[plr[v10].WorldX][plr[v10].WorldY] = arglist[0] + 1; - } - v11 = abs(plr[*(_DWORD *)arglist]._px - plr[*(_DWORD *)arglist].WorldX); - v12 = abs(plr[*(_DWORD *)arglist]._py - plr[*(_DWORD *)arglist].WorldY); - v13 = *(_DWORD *)arglist; - if (v11 > 1 || v12 > 1) { - v14 = *(_DWORD *)arglist; - plr[v14]._px = plr[*(_DWORD *)arglist].WorldX; - plr[v14]._py = plr[v13].WorldY; - } - MakePlrPath(v13, (unsigned char)v2->targx, (unsigned char)v2->targy, 1u); - } - } - } - multi_handle_all_packets(*(int *)arglist, (TPkt *)&v2[1], len - 19); - } - //_LOBYTE(v15) = SNetReceiveMessage((int *)arglist, (char **)&pkt, &len); - } while (SNetReceiveMessage((int *)arglist, (char **)&pkt, &len)); - } - if (SErrGetLastError() != STORM_ERROR_NO_MESSAGES_WAITING) - nthread_terminate_game("SNetReceiveMsg"); + multi_clear_left_tbl(); + multi_process_tmsgs(); + //_LOBYTE(v0) = SNetReceiveMessage((int *)arglist, (char **)&pkt, &len); + if (SNetReceiveMessage((int *)arglist, (char **)&pkt, &len)) { + do { + ++pkt_counter; + multi_clear_left_tbl(); + v1 = pkt; + v2 = pkt; + if ((unsigned int)len >= 0x13 + && *(_DWORD *)arglist < 4u + && pkt->wCheck == 'ip' + && (unsigned short)pkt->wLen == len) { + v3 = *(_DWORD *)arglist; + v4 = *(_DWORD *)arglist == myplr; + plr[v3]._pownerx = (unsigned char)pkt->px; + v5 = &v1->py; + plr[v3]._pownery = (unsigned char)v1->py; + if (!v4) { + v4 = gbBufferMsgs == 1; + plr[v3]._pHitPoints = v1->php; + plr[v3]._pMaxHP = v1->pmhp; + plr[v3]._pBaseStr = (unsigned char)v1->bstr; + plr[v3]._pBaseMag = (unsigned char)v1->bmag; + plr[v3]._pBaseDex = (unsigned char)v1->bdex; + if (!v4 && plr[v3].plractive && plr[v3]._pHitPoints) { + if (currlevel != plr[v3].plrlevel || plr[v3]._pLvlChanging) { + plr[v3].WorldX = (unsigned char)v1->px; + plr[v3].WorldY = (unsigned char)*v5; + plr[v3]._px = (unsigned char)v1->px; + plr[v3]._py = (unsigned char)*v5; + plr[v3]._ptargx = (unsigned char)v1->targx; + plr[v3]._ptargy = (unsigned char)v1->targy; + } else { + v6 = abs(plr[v3].WorldX - (unsigned char)v1->px); + v7 = abs(plr[*(_DWORD *)arglist].WorldY - (unsigned char)*v5); + if ((v6 > 3 || v7 > 3) && !dPlayer[(unsigned char)v2->px][(unsigned char)*v5]) { + FixPlrWalkTags(*(int *)arglist); + v8 = *(_DWORD *)arglist; + v9 = *(_DWORD *)arglist; + plr[v9]._poldx = plr[*(_DWORD *)arglist].WorldX; + plr[v9]._poldy = plr[v9].WorldY; + FixPlrWalkTags(v8); + v10 = *(_DWORD *)arglist; + plr[v10].WorldX = (unsigned char)v2->px; + plr[v10].WorldY = (unsigned char)*v5; + plr[v10]._px = (unsigned char)v2->px; + plr[v10]._py = (unsigned char)*v5; + dPlayer[plr[v10].WorldX][plr[v10].WorldY] = arglist[0] + 1; + } + v11 = abs(plr[*(_DWORD *)arglist]._px - plr[*(_DWORD *)arglist].WorldX); + v12 = abs(plr[*(_DWORD *)arglist]._py - plr[*(_DWORD *)arglist].WorldY); + v13 = *(_DWORD *)arglist; + if (v11 > 1 || v12 > 1) { + v14 = *(_DWORD *)arglist; + plr[v14]._px = plr[*(_DWORD *)arglist].WorldX; + plr[v14]._py = plr[v13].WorldY; + } + MakePlrPath(v13, (unsigned char)v2->targx, (unsigned char)v2->targy, 1u); + } + } + } + multi_handle_all_packets(*(int *)arglist, (TPkt *)&v2[1], len - 19); + } + //_LOBYTE(v15) = SNetReceiveMessage((int *)arglist, (char **)&pkt, &len); + } while (SNetReceiveMessage((int *)arglist, (char **)&pkt, &len)); + } + if (SErrGetLastError() != STORM_ERROR_NO_MESSAGES_WAITING) + nthread_terminate_game("SNetReceiveMsg"); } // 676194: using guessed type char gbBufferMsgs; // 676198: using guessed type int pkt_counter; void __fastcall multi_handle_all_packets(int players, TPkt *packet, int a3) { - TCmd *v3; // esi - int i; // edi - int v5; // eax + TCmd *v3; // esi + int i; // edi + int v5; // eax - v3 = (TCmd *)packet; - for (i = players; a3; a3 -= v5) { - v5 = ParseCmd(i, v3); - if (!v5) - break; - v3 += v5; - } + v3 = (TCmd *)packet; + for (i = players; a3; a3 -= v5) { + v5 = ParseCmd(i, v3); + if (!v5) + break; + v3 += v5; + } } void __cdecl multi_process_tmsgs() { - int v0; // eax - TPkt pkt; // [esp+0h] [ebp-200h] + int v0; // eax + TPkt pkt; // [esp+0h] [ebp-200h] - while (1) { - v0 = tmsg_get((unsigned char *)&pkt, 512); - if (!v0) - break; - multi_handle_all_packets(myplr, &pkt, v0); - } + while (1) { + v0 = tmsg_get((unsigned char *)&pkt, 512); + if (!v0) + break; + multi_handle_all_packets(myplr, &pkt, v0); + } } void __fastcall multi_send_zero_packet(int pnum, char a2, void *pbSrc, int dwLen) { - unsigned int v4; // edi - short v5; // si - unsigned short dwBody; // ax - TPkt pkt; // [esp+Ch] [ebp-208h] - int pnuma; // [esp+20Ch] [ebp-8h] - int v10; // [esp+210h] [ebp-4h] + unsigned int v4; // edi + short v5; // si + unsigned short dwBody; // ax + TPkt pkt; // [esp+Ch] [ebp-208h] + int pnuma; // [esp+20Ch] [ebp-8h] + int v10; // [esp+210h] [ebp-4h] - v4 = dwLen; - _LOBYTE(v10) = a2; - pnuma = pnum; - v5 = 0; - while (v4) { - pkt.hdr.wCheck = 'ip'; - pkt.body[0] = v10; - dwBody = gdwLargestMsgSize - 24; - pkt.hdr.px = 0; - pkt.hdr.py = 0; - pkt.hdr.targx = 0; - pkt.hdr.targy = 0; - pkt.hdr.php = 0; - pkt.hdr.pmhp = 0; - pkt.hdr.bstr = 0; - pkt.hdr.bmag = 0; - pkt.hdr.bdex = 0; - *(_WORD *)&pkt.body[1] = v5; - if (v4 < gdwLargestMsgSize - 24) - dwBody = v4; - *(_WORD *)&pkt.body[3] = dwBody; - memcpy(&pkt.body[5], pbSrc, dwBody); - pkt.hdr.wLen = *(_WORD *)&pkt.body[3] + 24; - if (!SNetSendMessage(pnuma, &pkt.hdr, *(unsigned short *)&pkt.body[3] + 24)) { - nthread_terminate_game("SNetSendMessage2"); - return; - } - pbSrc = (char *)pbSrc + *(unsigned short *)&pkt.body[3]; - v4 -= *(unsigned short *)&pkt.body[3]; - v5 += *(_WORD *)&pkt.body[3]; - } + v4 = dwLen; + _LOBYTE(v10) = a2; + pnuma = pnum; + v5 = 0; + while (v4) { + pkt.hdr.wCheck = 'ip'; + pkt.body[0] = v10; + dwBody = gdwLargestMsgSize - 24; + pkt.hdr.px = 0; + pkt.hdr.py = 0; + pkt.hdr.targx = 0; + pkt.hdr.targy = 0; + pkt.hdr.php = 0; + pkt.hdr.pmhp = 0; + pkt.hdr.bstr = 0; + pkt.hdr.bmag = 0; + pkt.hdr.bdex = 0; + *(_WORD *)&pkt.body[1] = v5; + if (v4 < gdwLargestMsgSize - 24) + dwBody = v4; + *(_WORD *)&pkt.body[3] = dwBody; + memcpy(&pkt.body[5], pbSrc, dwBody); + pkt.hdr.wLen = *(_WORD *)&pkt.body[3] + 24; + if (!SNetSendMessage(pnuma, &pkt.hdr, *(unsigned short *)&pkt.body[3] + 24)) { + nthread_terminate_game("SNetSendMessage2"); + return; + } + pbSrc = (char *)pbSrc + *(unsigned short *)&pkt.body[3]; + v4 -= *(unsigned short *)&pkt.body[3]; + v5 += *(_WORD *)&pkt.body[3]; + } } // 67975C: using guessed type int gdwLargestMsgSize; void __cdecl NetClose() { - if (sgbNetInited) { - sgbNetInited = 0; - nthread_cleanup(); - dthread_cleanup(); - tmsg_cleanup(); - multi_event_handler(0); - SNetLeaveGame(3); - msgcmd_cmd_cleanup(); - if ((unsigned char)gbMaxPlayers > 1u) - Sleep(2000); - } + if (sgbNetInited) { + sgbNetInited = 0; + nthread_cleanup(); + dthread_cleanup(); + tmsg_cleanup(); + multi_event_handler(0); + SNetLeaveGame(3); + msgcmd_cmd_cleanup(); + if ((unsigned char)gbMaxPlayers > 1u) + Sleep(2000); + } } // 679660: using guessed type char gbMaxPlayers; // 6796E8: using guessed type int sgbNetInited; char __fastcall multi_event_handler(int a1) { - int v1; // edi - void *(__stdcall * v2)(int, void(__stdcall *)(_SNETEVENT *)); // ebx - unsigned int v3; // esi - int v4; // eax - char *v5; // eax + int v1; // edi + void *(__stdcall * v2)(int, void(__stdcall *)(_SNETEVENT *)); // ebx + unsigned int v3; // esi + int v4; // eax + char *v5; // eax - v1 = a1; - v2 = SNetRegisterEventHandler; - if (!a1) - v2 = SNetUnregisterEventHandler; - v3 = 0; - do { - v4 = (int)v2(event_types[v3], multi_handle_events); - if (!v4 && v1) { - v5 = TraceLastError(); - TermMsg("SNetRegisterEventHandler:\n%s", v5); - } - ++v3; - } while (v3 < 3); - return v4; + v1 = a1; + v2 = SNetRegisterEventHandler; + if (!a1) + v2 = SNetUnregisterEventHandler; + v3 = 0; + do { + v4 = (int)v2(event_types[v3], multi_handle_events); + if (!v4 && v1) { + v5 = TraceLastError(); + TermMsg("SNetRegisterEventHandler:\n%s", v5); + } + ++v3; + } while (v3 < 3); + return v4; } void __stdcall multi_handle_events(_SNETEVENT *pEvt) { - int v1; // ecx - int *v2; // eax - int *v3; // eax + int v1; // ecx + int *v2; // eax + int *v3; // eax - switch (pEvt->eventid) { - case EVENT_TYPE_PLAYER_CREATE_GAME: - v3 = (int *)pEvt->data; - sgGameInitInfo.dwSeed = *v3; - _LOBYTE(sgGameInitInfo.bDiff) = *((_BYTE *)v3 + 4); - sgbPlayerTurnBitTbl[pEvt->playerid] = 1; - break; - case EVENT_TYPE_PLAYER_LEAVE_GAME: - v1 = 0; - sgbPlayerLeftGameTbl[pEvt->playerid] = 1; - sgbPlayerTurnBitTbl[pEvt->playerid] = 0; - v2 = (int *)pEvt->data; - if (v2 && pEvt->databytes >= 4u) - v1 = *v2; - sgdwPlayerLeftReasonTbl[pEvt->playerid] = v1; - if (v1 == 0x40000004) - gbSomebodyWonGameKludge = 1; - sgbSendDeltaTbl[pEvt->playerid] = 0; - dthread_remove_player(pEvt->playerid); - if (gbDeltaSender == pEvt->playerid) - gbDeltaSender = 4; - break; - case EVENT_TYPE_PLAYER_MESSAGE: - ErrorPlrMsg((char *)pEvt->data); - break; - } + switch (pEvt->eventid) { + case EVENT_TYPE_PLAYER_CREATE_GAME: + v3 = (int *)pEvt->data; + sgGameInitInfo.dwSeed = *v3; + _LOBYTE(sgGameInitInfo.bDiff) = *((_BYTE *)v3 + 4); + sgbPlayerTurnBitTbl[pEvt->playerid] = 1; + break; + case EVENT_TYPE_PLAYER_LEAVE_GAME: + v1 = 0; + sgbPlayerLeftGameTbl[pEvt->playerid] = 1; + sgbPlayerTurnBitTbl[pEvt->playerid] = 0; + v2 = (int *)pEvt->data; + if (v2 && pEvt->databytes >= 4u) + v1 = *v2; + sgdwPlayerLeftReasonTbl[pEvt->playerid] = v1; + if (v1 == 0x40000004) + gbSomebodyWonGameKludge = 1; + sgbSendDeltaTbl[pEvt->playerid] = 0; + dthread_remove_player(pEvt->playerid); + if (gbDeltaSender == pEvt->playerid) + gbDeltaSender = 4; + break; + case EVENT_TYPE_PLAYER_MESSAGE: + ErrorPlrMsg((char *)pEvt->data); + break; + } } // 6761B8: using guessed type char gbSomebodyWonGameKludge; // 6796E4: using guessed type char gbDeltaSender; int __fastcall NetInit(int bSinglePlayer, int *pfExitProgram) { - int v2; // ebx - int v4; // eax - //int v5; // ecx - bool v7; // zf - //int v9; // eax - //int v10; // eax - _SNETPROGRAMDATA ProgramData; // [esp+8h] [ebp-A8h] - _SNETUIDATA UiData; // [esp+44h] [ebp-6Ch] - _SNETPLAYERDATA a2; // [esp+94h] [ebp-1Ch] - int v14; // [esp+A4h] [ebp-Ch] - unsigned int len; // [esp+A8h] [ebp-8h] - int *a4; // [esp+ACh] [ebp-4h] + int v2; // ebx + int v4; // eax + //int v5; // ecx + bool v7; // zf + //int v9; // eax + //int v10; // eax + _SNETPROGRAMDATA ProgramData; // [esp+8h] [ebp-A8h] + _SNETUIDATA UiData; // [esp+44h] [ebp-6Ch] + _SNETPLAYERDATA a2; // [esp+94h] [ebp-1Ch] + int v14; // [esp+A4h] [ebp-Ch] + unsigned int len; // [esp+A8h] [ebp-8h] + int *a4; // [esp+ACh] [ebp-4h] - a4 = pfExitProgram; - v14 = bSinglePlayer; - v2 = 0; - while (1) { - *a4 = 0; - SetRndSeed(0); - sgGameInitInfo.dwSeed = time(NULL); - _LOBYTE(sgGameInitInfo.bDiff) = gnDifficulty; - memset(&ProgramData, 0, 0x3Cu); - ProgramData.size = 60; - ProgramData.programname = "Diablo Retail"; - ProgramData.programdescription = gszVersionNumber; - ProgramData.programid = 'DRTL'; - ProgramData.versionid = 42; - ProgramData.maxplayers = MAX_PLRS; - ProgramData.initdata = &sgGameInitInfo; - ProgramData.initdatabytes = 8; - ProgramData.optcategorybits = 15; - ProgramData.lcid = 1033; /* LANG_ENGLISH */ - memset(&a2, 0, 0x10u); - a2.size = 16; - memset(&UiData, 0, 0x50u); - UiData.size = 80; - UiData.parentwindow = SDrawGetFrameWindow(0); - UiData.artcallback = (void(__cdecl *)())UiArtCallback; - UiData.createcallback = (void(__cdecl *)())UiCreateGameCallback; - UiData.drawdesccallback = (void(__cdecl *)())UiDrawDescCallback; - UiData.messageboxcallback = (void(__cdecl *)())UiMessageBoxCallback; - UiData.soundcallback = (void(__cdecl *)())UiSoundCallback; - UiData.authcallback = (void(__cdecl *)())UiAuthCallback; - UiData.getdatacallback = (void(__cdecl *)())UiGetDataCallback; - UiData.categorycallback = (void(__cdecl *)())UiCategoryCallback; - UiData.selectnamecallback = mainmenu_select_hero_dialog; - UiData.changenamecallback = (void(__cdecl *)())mainmenu_create_hero; - UiData.profilebitmapcallback = UiProfileDraw; - UiData.profilecallback = UiProfileCallback; - UiData.profilefields = UiProfileGetString(); - memset(sgbPlayerTurnBitTbl, 0, 4u); - gbGameDestroyed = 0; - memset(sgbPlayerLeftGameTbl, 0, 4u); - memset(sgdwPlayerLeftReasonTbl, 0, 0x10u); - memset(sgbSendDeltaTbl, 0, 4u); - memset(plr, 0, 0x15360u); - memset(sgwPackPlrOffsetTbl, 0, 8u); - SNetSetBasePlayer(0); - if (v14) - v4 = multi_init_single(&ProgramData, &a2, &UiData); - else - v4 = multi_init_multi(&ProgramData, &a2, &UiData, a4); - if (!v4) - return 0; - sgbNetInited = 1; - sgbTimeout = 0; - delta_init(); - InitPlrMsg(); - multi_clear_pkt(pkdata_6761C0); - multi_clear_pkt(pkdata_678658); - dword_678628 = 0; - sync_clear_pkt(); - nthread_start(sgbPlayerTurnBitTbl[myplr]); - dthread_start(); - MI_Dummy(0); /* v5 */ - sgdwGameLoops = 0; - sgbSentThisCycle = 0; - gbDeltaSender = myplr; - gbSomebodyWonGameKludge = 0; - nthread_send_and_recv_turn(0, 0); - SetupLocalCoords(); - multi_send_pinfo(-2, CMD_SEND_PLRINFO); - gbActivePlayers = 1; - v7 = sgbPlayerTurnBitTbl[myplr] == 0; - plr[myplr].plractive = 1; - if (v7 || msg_wait_resync()) - break; - NetClose(); - byte_678640 = 0; - } - gnDifficulty = _LOBYTE(sgGameInitInfo.bDiff); - SetRndSeed(sgGameInitInfo.dwSeed); - do { - glSeedTbl[v2] = GetRndSeed(); - gnLevelTypeTbl[v2] = InitNewSeed(v2); - ++v2; - } while (v2 < 17); - //_LOBYTE(v9) = SNetGetGameInfo(GAMEINFO_NAME, szPlayerName, 128, len); - if (!SNetGetGameInfo(GAMEINFO_NAME, szPlayerName, 128, &len)) - nthread_terminate_game("SNetGetGameInfo1"); - //_LOBYTE(v10) = SNetGetGameInfo(GAMEINFO_PASSWORD, szPlayerDescript, 128, len); - if (!SNetGetGameInfo(GAMEINFO_PASSWORD, szPlayerDescript, 128, &len)) - nthread_terminate_game("SNetGetGameInfo2"); - return 1; + a4 = pfExitProgram; + v14 = bSinglePlayer; + v2 = 0; + while (1) { + *a4 = 0; + SetRndSeed(0); + sgGameInitInfo.dwSeed = time(NULL); + _LOBYTE(sgGameInitInfo.bDiff) = gnDifficulty; + memset(&ProgramData, 0, 0x3Cu); + ProgramData.size = 60; + ProgramData.programname = "Diablo Retail"; + ProgramData.programdescription = gszVersionNumber; + ProgramData.programid = 'DRTL'; + ProgramData.versionid = 42; + ProgramData.maxplayers = MAX_PLRS; + ProgramData.initdata = &sgGameInitInfo; + ProgramData.initdatabytes = 8; + ProgramData.optcategorybits = 15; + ProgramData.lcid = 1033; /* LANG_ENGLISH */ + memset(&a2, 0, 0x10u); + a2.size = 16; + memset(&UiData, 0, 0x50u); + UiData.size = 80; + UiData.parentwindow = SDrawGetFrameWindow(0); + UiData.artcallback = (void(__cdecl *)())UiArtCallback; + UiData.createcallback = (void(__cdecl *)())UiCreateGameCallback; + UiData.drawdesccallback = (void(__cdecl *)())UiDrawDescCallback; + UiData.messageboxcallback = (void(__cdecl *)())UiMessageBoxCallback; + UiData.soundcallback = (void(__cdecl *)())UiSoundCallback; + UiData.authcallback = (void(__cdecl *)())UiAuthCallback; + UiData.getdatacallback = (void(__cdecl *)())UiGetDataCallback; + UiData.categorycallback = (void(__cdecl *)())UiCategoryCallback; + UiData.selectnamecallback = mainmenu_select_hero_dialog; + UiData.changenamecallback = (void(__cdecl *)())mainmenu_create_hero; + UiData.profilebitmapcallback = UiProfileDraw; + UiData.profilecallback = UiProfileCallback; + UiData.profilefields = UiProfileGetString(); + memset(sgbPlayerTurnBitTbl, 0, 4u); + gbGameDestroyed = 0; + memset(sgbPlayerLeftGameTbl, 0, 4u); + memset(sgdwPlayerLeftReasonTbl, 0, 0x10u); + memset(sgbSendDeltaTbl, 0, 4u); + memset(plr, 0, 0x15360u); + memset(sgwPackPlrOffsetTbl, 0, 8u); + SNetSetBasePlayer(0); + if (v14) + v4 = multi_init_single(&ProgramData, &a2, &UiData); + else + v4 = multi_init_multi(&ProgramData, &a2, &UiData, a4); + if (!v4) + return 0; + sgbNetInited = 1; + sgbTimeout = 0; + delta_init(); + InitPlrMsg(); + multi_clear_pkt(pkdata_6761C0); + multi_clear_pkt(pkdata_678658); + dword_678628 = 0; + sync_clear_pkt(); + nthread_start(sgbPlayerTurnBitTbl[myplr]); + dthread_start(); + MI_Dummy(0); /* v5 */ + sgdwGameLoops = 0; + sgbSentThisCycle = 0; + gbDeltaSender = myplr; + gbSomebodyWonGameKludge = 0; + nthread_send_and_recv_turn(0, 0); + SetupLocalCoords(); + multi_send_pinfo(-2, CMD_SEND_PLRINFO); + gbActivePlayers = 1; + v7 = sgbPlayerTurnBitTbl[myplr] == 0; + plr[myplr].plractive = 1; + if (v7 || msg_wait_resync()) + break; + NetClose(); + byte_678640 = 0; + } + gnDifficulty = _LOBYTE(sgGameInitInfo.bDiff); + SetRndSeed(sgGameInitInfo.dwSeed); + do { + glSeedTbl[v2] = GetRndSeed(); + gnLevelTypeTbl[v2] = InitNewSeed(v2); + ++v2; + } while (v2 < 17); + //_LOBYTE(v9) = SNetGetGameInfo(GAMEINFO_NAME, szPlayerName, 128, len); + if (!SNetGetGameInfo(GAMEINFO_NAME, szPlayerName, 128, &len)) + nthread_terminate_game("SNetGetGameInfo1"); + //_LOBYTE(v10) = SNetGetGameInfo(GAMEINFO_PASSWORD, szPlayerDescript, 128, len); + if (!SNetGetGameInfo(GAMEINFO_PASSWORD, szPlayerDescript, 128, &len)) + nthread_terminate_game("SNetGetGameInfo2"); + return 1; } // 6761B8: using guessed type char gbSomebodyWonGameKludge; // 678628: using guessed type int dword_678628; @@ -826,74 +826,74 @@ int __fastcall NetInit(int bSinglePlayer, int *pfExitProgram) void __fastcall multi_clear_pkt(char *a1) { - *(_DWORD *)a1 = 0; - a1[4] = 0; + *(_DWORD *)a1 = 0; + a1[4] = 0; } void __fastcall multi_send_pinfo(int pnum, char cmd) { - char v2; // bl - int v3; // esi - PkPlayerStruct pkplr; // [esp+8h] [ebp-4F4h] + char v2; // bl + int v3; // esi + PkPlayerStruct pkplr; // [esp+8h] [ebp-4F4h] - v2 = cmd; - v3 = pnum; - PackPlayer(&pkplr, myplr, 1); - dthread_send_delta(v3, v2, &pkplr, 1266); + v2 = cmd; + v3 = pnum; + PackPlayer(&pkplr, myplr, 1); + dthread_send_delta(v3, v2, &pkplr, 1266); } int __fastcall InitNewSeed(int newseed) { - int result; // eax + int result; // eax - result = 0; - if (newseed) { - result = 1; - if (newseed < 1 || newseed > 4) { - if (newseed < 5 || newseed > 8) { - if (newseed < 9 || newseed > 12) - result = 4; - else - result = 3; - } else { - result = 2; - } - } - } - return result; + result = 0; + if (newseed) { + result = 1; + if (newseed < 1 || newseed > 4) { + if (newseed < 5 || newseed > 8) { + if (newseed < 9 || newseed > 12) + result = 4; + else + result = 3; + } else { + result = 2; + } + } + } + return result; } void __cdecl SetupLocalCoords() { - int x; // ecx - int y; // edx + int x; // ecx + int y; // edx - if (!leveldebug || (unsigned char)gbMaxPlayers > 1u) { - currlevel = 0; - leveltype = 0; - setlevel = 0; - } - x = 75; - y = 68; + if (!leveldebug || (unsigned char)gbMaxPlayers > 1u) { + currlevel = 0; + leveltype = 0; + setlevel = 0; + } + x = 75; + y = 68; #ifdef _DEBUG - if (debug_mode_key_inverted_v || debug_mode_key_d) { - x = 49; - y = 23; - } + if (debug_mode_key_inverted_v || debug_mode_key_d) { + x = 49; + y = 23; + } #endif - x += plrxoff[myplr]; - y += plryoff[myplr]; - plr[myplr].WorldX = x; - plr[myplr].WorldY = y; - plr[myplr]._px = x; - plr[myplr]._py = y; - plr[myplr]._ptargx = x; - plr[myplr]._ptargy = y; - plr[myplr].plrlevel = currlevel; - plr[myplr]._pLvlChanging = 1; - plr[myplr].pLvlLoad = 0; - plr[myplr]._pmode = PM_NEWLVL; - plr[myplr].destAction = ACTION_NONE; + x += plrxoff[myplr]; + y += plryoff[myplr]; + plr[myplr].WorldX = x; + plr[myplr].WorldY = y; + plr[myplr]._px = x; + plr[myplr]._py = y; + plr[myplr]._ptargx = x; + plr[myplr]._ptargy = y; + plr[myplr].plrlevel = currlevel; + plr[myplr]._pLvlChanging = 1; + plr[myplr].pLvlLoad = 0; + plr[myplr]._pmode = PM_NEWLVL; + plr[myplr].destAction = ACTION_NONE; } // 52572C: using guessed type int leveldebug; // 5CF31D: using guessed type char setlevel; @@ -901,148 +901,148 @@ void __cdecl SetupLocalCoords() int __fastcall multi_init_single(_SNETPROGRAMDATA *client_info, _SNETPLAYERDATA *user_info, _SNETUIDATA *ui_info) { - //int v3; // eax - int result; // eax - //int v5; // eax - char *v6; // eax + //int v3; // eax + int result; // eax + //int v5; // eax + char *v6; // eax - //_LOBYTE(v3) = SNetInitializeProvider(0, client_info, user_info, ui_info, &fileinfo); - if (SNetInitializeProvider(0, client_info, user_info, ui_info, &fileinfo)) { - ui_info = 0; - //_LOBYTE(v5) = SNetCreateGame("local", "local", "local", 0, (char *)&sgGameInitInfo.dwSeed, 8, 1, "local", "local", (int *)&ui_info); - if (!SNetCreateGame("local", "local", "local", 0, (char *)&sgGameInitInfo.dwSeed, 8, 1, "local", "local", (int *)&ui_info)) { - v6 = TraceLastError(); - TermMsg("SNetCreateGame1:\n%s", v6); - } - myplr = 0; - gbMaxPlayers = 1; - result = 1; - } else { - SErrGetLastError(); - result = 0; - } - return result; + //_LOBYTE(v3) = SNetInitializeProvider(0, client_info, user_info, ui_info, &fileinfo); + if (SNetInitializeProvider(0, client_info, user_info, ui_info, &fileinfo)) { + ui_info = 0; + //_LOBYTE(v5) = SNetCreateGame("local", "local", "local", 0, (char *)&sgGameInitInfo.dwSeed, 8, 1, "local", "local", (int *)&ui_info); + if (!SNetCreateGame("local", "local", "local", 0, (char *)&sgGameInitInfo.dwSeed, 8, 1, "local", "local", (int *)&ui_info)) { + v6 = TraceLastError(); + TermMsg("SNetCreateGame1:\n%s", v6); + } + myplr = 0; + gbMaxPlayers = 1; + result = 1; + } else { + SErrGetLastError(); + result = 0; + } + return result; } // 679660: using guessed type char gbMaxPlayers; int __fastcall multi_init_multi(_SNETPROGRAMDATA *client_info, _SNETPLAYERDATA *user_info, _SNETUIDATA *ui_info, int *a4) { - _SNETPLAYERDATA *v4; // ebx - signed int i; // edi - int a6; // [esp+Ch] [ebp-Ch] - int a2; // [esp+10h] [ebp-8h] - int type; // [esp+14h] [ebp-4h] + _SNETPLAYERDATA *v4; // ebx + signed int i; // edi + int a6; // [esp+Ch] [ebp-Ch] + int a2; // [esp+10h] [ebp-8h] + int type; // [esp+14h] [ebp-4h] - v4 = user_info; - a2 = (int)client_info; - for (i = 1;; i = 0) { - type = 0; - if (byte_678640) { - if (!UiSelectProvider(0, (_SNETPROGRAMDATA *)a2, v4, ui_info, &fileinfo, &type) - && (!i || SErrGetLastError() != STORM_ERROR_REQUIRES_UPGRADE || !multi_upgrade(a4))) { - return 0; - } - if (type == 'BNET') - plr[0].pBattleNet = 1; - } - multi_event_handler(1); - if (UiSelectGame(1, (_SNETPROGRAMDATA *)a2, v4, ui_info, &fileinfo, &a6)) - break; - byte_678640 = 1; - } - if ((unsigned int)a6 >= MAX_PLRS) - return 0; - myplr = a6; - gbMaxPlayers = MAX_PLRS; - pfile_read_player_from_save(); - if (type == 'BNET') - plr[myplr].pBattleNet = 1; - return 1; + v4 = user_info; + a2 = (int)client_info; + for (i = 1;; i = 0) { + type = 0; + if (byte_678640) { + if (!UiSelectProvider(0, (_SNETPROGRAMDATA *)a2, v4, ui_info, &fileinfo, &type) + && (!i || SErrGetLastError() != STORM_ERROR_REQUIRES_UPGRADE || !multi_upgrade(a4))) { + return 0; + } + if (type == 'BNET') + plr[0].pBattleNet = 1; + } + multi_event_handler(1); + if (UiSelectGame(1, (_SNETPROGRAMDATA *)a2, v4, ui_info, &fileinfo, &a6)) + break; + byte_678640 = 1; + } + if ((unsigned int)a6 >= MAX_PLRS) + return 0; + myplr = a6; + gbMaxPlayers = MAX_PLRS; + pfile_read_player_from_save(); + if (type == 'BNET') + plr[myplr].pBattleNet = 1; + return 1; } // 678640: using guessed type char byte_678640; // 679660: using guessed type char gbMaxPlayers; int __fastcall multi_upgrade(int *a1) { - int *v1; // esi - int result; // eax - int status; // [esp+4h] [ebp-4h] + int *v1; // esi + int result; // eax + int status; // [esp+4h] [ebp-4h] - v1 = a1; - SNetPerformUpgrade((unsigned long *)&status); - result = 1; - if (status && status != 1) { - if (status == 2) { - *v1 = 1; - } else if (status == -1) { - DrawDlg("Network upgrade failed"); - } - result = 0; - } - return result; + v1 = a1; + SNetPerformUpgrade((unsigned long *)&status); + result = 1; + if (status && status != 1) { + if (status == 2) { + *v1 = 1; + } else if (status == -1) { + DrawDlg("Network upgrade failed"); + } + result = 0; + } + return result; } void __fastcall multi_player_joins(int pnum, TCmdPlrInfoHdr *cmd, int a3) { - int v3; // ebx - TCmdPlrInfoHdr *v4; // edi - short *v5; // esi - int v6; // esi - bool v7; // zf - char *v8; // eax - int v9; // ST08_4 - unsigned char *v10; // edx - int v11; // eax - int v12; // ecx - int v13; // eax + int v3; // ebx + TCmdPlrInfoHdr *v4; // edi + short *v5; // esi + int v6; // esi + bool v7; // zf + char *v8; // eax + int v9; // ST08_4 + unsigned char *v10; // edx + int v11; // eax + int v12; // ecx + int v13; // eax - v3 = pnum; - v4 = cmd; - if (myplr != pnum) { - v5 = &sgwPackPlrOffsetTbl[pnum]; - if (*v5 == cmd->wOffset || (*v5 = 0, !cmd->wOffset)) { - if (!a3 && !*v5) { - multi_send_pinfo(pnum, CMD_ACK_PLRINFO); - } - memcpy((char *)&netplr[v3] + (unsigned short)v4->wOffset, &v4[1], (unsigned short)v4->wBytes); - *v5 += v4->wBytes; - if (*v5 == 1266) { - *v5 = 0; - multi_player_left_msg(v3, 0); - v6 = v3; - plr[v3]._pGFXLoad = 0; - UnPackPlayer(&netplr[v3], v3, 1); - if (a3) { - ++gbActivePlayers; - v7 = sgbPlayerTurnBitTbl[v3] == 0; - plr[v6].plractive = 1; - v8 = "Player '%s' (level %d) just joined the game"; - if (v7) - v8 = "Player '%s' (level %d) is already in the game"; - EventPlrMsg(v8, plr[v6]._pName, plr[v6]._pLevel); - LoadPlrGFX(v3, PFILE_STAND); - SyncInitPlr(v3); - if (plr[v6].plrlevel == currlevel) { - if (plr[v6]._pHitPoints >> 6 <= 0) { - plr[v6]._pgfxnum = 0; - LoadPlrGFX(v3, PFILE_DEATH); - v9 = plr[v6]._pDWidth; - v10 = plr[v6]._pDAnim[0]; - plr[v6]._pmode = 8; - NewPlrAnim(v3, v10, plr[v6]._pDFrames, 1, v9); - v11 = plr[v6]._pAnimLen; - v12 = v11 - 1; - plr[v6]._pVar8 = 2 * v11; - v13 = plr[v6].WorldX; - plr[v6]._pAnimFrame = v12; - dFlags[v13][plr[v6].WorldY] |= DFLAG_DEAD_PLAYER; - } else { - StartStand(v3, 0); - } - } - } - } - } - } + v3 = pnum; + v4 = cmd; + if (myplr != pnum) { + v5 = &sgwPackPlrOffsetTbl[pnum]; + if (*v5 == cmd->wOffset || (*v5 = 0, !cmd->wOffset)) { + if (!a3 && !*v5) { + multi_send_pinfo(pnum, CMD_ACK_PLRINFO); + } + memcpy((char *)&netplr[v3] + (unsigned short)v4->wOffset, &v4[1], (unsigned short)v4->wBytes); + *v5 += v4->wBytes; + if (*v5 == 1266) { + *v5 = 0; + multi_player_left_msg(v3, 0); + v6 = v3; + plr[v3]._pGFXLoad = 0; + UnPackPlayer(&netplr[v3], v3, 1); + if (a3) { + ++gbActivePlayers; + v7 = sgbPlayerTurnBitTbl[v3] == 0; + plr[v6].plractive = 1; + v8 = "Player '%s' (level %d) just joined the game"; + if (v7) + v8 = "Player '%s' (level %d) is already in the game"; + EventPlrMsg(v8, plr[v6]._pName, plr[v6]._pLevel); + LoadPlrGFX(v3, PFILE_STAND); + SyncInitPlr(v3); + if (plr[v6].plrlevel == currlevel) { + if (plr[v6]._pHitPoints >> 6 <= 0) { + plr[v6]._pgfxnum = 0; + LoadPlrGFX(v3, PFILE_DEATH); + v9 = plr[v6]._pDWidth; + v10 = plr[v6]._pDAnim[0]; + plr[v6]._pmode = 8; + NewPlrAnim(v3, v10, plr[v6]._pDFrames, 1, v9); + v11 = plr[v6]._pAnimLen; + v12 = v11 - 1; + plr[v6]._pVar8 = 2 * v11; + v13 = plr[v6].WorldX; + plr[v6]._pAnimFrame = v12; + dFlags[v13][plr[v6].WorldY] |= DFLAG_DEAD_PLAYER; + } else { + StartStand(v3, 0); + } + } + } + } + } + } } // 67862C: using guessed type char gbActivePlayers; diff --git a/Source/nthread.cpp b/Source/nthread.cpp index 26f7dbf8..528a1c15 100644 --- a/Source/nthread.cpp +++ b/Source/nthread.cpp @@ -26,121 +26,121 @@ const int nthread_inf = 0x7F800000; // weak static HANDLE sghThread = (HANDLE)0xFFFFFFFF; // idb struct nthread_cpp_init_1 { - nthread_cpp_init_1() - { - nthread_cpp_init_value = nthread_inf; - } + nthread_cpp_init_1() + { + nthread_cpp_init_value = nthread_inf; + } } _nthread_cpp_init_1; // 47F164: using guessed type int nthread_inf; // 679700: using guessed type int nthread_cpp_init_value; struct nthread_cpp_init_2 { - nthread_cpp_init_2() - { - nthread_init_mutex(); - nthread_cleanup_mutex_atexit(); - } + nthread_cpp_init_2() + { + nthread_init_mutex(); + nthread_cleanup_mutex_atexit(); + } } _nthread_cpp_init_2; void __cdecl nthread_init_mutex() { - InitializeCriticalSection(&sgMemCrit); + InitializeCriticalSection(&sgMemCrit); } void __cdecl nthread_cleanup_mutex_atexit() { - atexit(nthread_cleanup_mutex); + atexit(nthread_cleanup_mutex); } void __cdecl nthread_cleanup_mutex() { - DeleteCriticalSection(&sgMemCrit); + DeleteCriticalSection(&sgMemCrit); } void __fastcall nthread_terminate_game(const char *pszFcn) { - DWORD sErr; // eax + DWORD sErr; // eax - sErr = SErrGetLastError(); - if (sErr != STORM_ERROR_INVALID_PLAYER) { - if (sErr == STORM_ERROR_GAME_TERMINATED || sErr == STORM_ERROR_NOT_IN_GAME) { - gbGameDestroyed = 1; - } else { - TermMsg("%s:\n%s", pszFcn, TraceLastError()); - } - } + sErr = SErrGetLastError(); + if (sErr != STORM_ERROR_INVALID_PLAYER) { + if (sErr == STORM_ERROR_GAME_TERMINATED || sErr == STORM_ERROR_NOT_IN_GAME) { + gbGameDestroyed = 1; + } else { + TermMsg("%s:\n%s", pszFcn, TraceLastError()); + } + } } // 67862D: using guessed type char gbGameDestroyed; int __fastcall nthread_send_and_recv_turn(int cur_turn, int turn_delta) { - unsigned int new_cur_turn; // edi - const char *lastStormFn; // ecx - int turn_tmp; // eax - int turn; // [esp+Ch] [ebp-8h] - int curTurnsInTransit; // [esp+10h] [ebp-4h] + unsigned int new_cur_turn; // edi + const char *lastStormFn; // ecx + int turn_tmp; // eax + int turn; // [esp+Ch] [ebp-8h] + int curTurnsInTransit; // [esp+10h] [ebp-4h] - new_cur_turn = cur_turn; - if (SNetGetTurnsInTransit(&curTurnsInTransit)) { - if (curTurnsInTransit >= (unsigned int)gdwTurnsInTransit) - return new_cur_turn; - while (1) { - ++curTurnsInTransit; + new_cur_turn = cur_turn; + if (SNetGetTurnsInTransit(&curTurnsInTransit)) { + if (curTurnsInTransit >= (unsigned int)gdwTurnsInTransit) + return new_cur_turn; + while (1) { + ++curTurnsInTransit; - turn_tmp = turn_upper_bit | new_cur_turn & 0x7FFFFFFF; - turn_upper_bit = 0; - turn = turn_tmp; + turn_tmp = turn_upper_bit | new_cur_turn & 0x7FFFFFFF; + turn_upper_bit = 0; + turn = turn_tmp; - if (!SNetSendTurn((char *)&turn, sizeof(turn))) - break; + if (!SNetSendTurn((char *)&turn, sizeof(turn))) + break; - new_cur_turn += turn_delta; - if (new_cur_turn >= 0x7FFFFFFF) - new_cur_turn = (unsigned short)new_cur_turn; - if (curTurnsInTransit >= (unsigned int)gdwTurnsInTransit) - return new_cur_turn; - } - lastStormFn = "SNetSendTurn"; - } else { - lastStormFn = "SNetGetTurnsInTransit"; - } - nthread_terminate_game(lastStormFn); - return 0; + new_cur_turn += turn_delta; + if (new_cur_turn >= 0x7FFFFFFF) + new_cur_turn = (unsigned short)new_cur_turn; + if (curTurnsInTransit >= (unsigned int)gdwTurnsInTransit) + return new_cur_turn; + } + lastStormFn = "SNetSendTurn"; + } else { + lastStormFn = "SNetGetTurnsInTransit"; + } + nthread_terminate_game(lastStormFn); + return 0; } // 679738: using guessed type int gdwTurnsInTransit; // 679754: using guessed type int turn_upper_bit; int __fastcall nthread_recv_turns(int *pfSendAsync) { - bool hasCountedDown; // zf + bool hasCountedDown; // zf - *pfSendAsync = 0; - if (--sgbPacketCountdown) { - last_tick += 50; - return 1; - } - hasCountedDown = sgbSyncCountdown-- == 1; - sgbPacketCountdown = byte_679704; - if (!hasCountedDown) - goto LABEL_11; - if (SNetReceiveTurns(0, 4, (char **)glpMsgTbl, (unsigned int *)gdwMsgLenTbl, (unsigned long *)player_state)) { - if (!byte_679758) { - byte_679758 = 1; - last_tick = GetTickCount(); - } - sgbSyncCountdown = 4; - multi_msg_countdown(); - LABEL_11: - *pfSendAsync = 1; - last_tick += 50; - return 1; - } - if (SErrGetLastError() != STORM_ERROR_NO_MESSAGES_WAITING) - nthread_terminate_game("SNetReceiveTurns"); - byte_679758 = 0; - sgbSyncCountdown = 1; - sgbPacketCountdown = 1; - return 0; + *pfSendAsync = 0; + if (--sgbPacketCountdown) { + last_tick += 50; + return 1; + } + hasCountedDown = sgbSyncCountdown-- == 1; + sgbPacketCountdown = byte_679704; + if (!hasCountedDown) + goto LABEL_11; + if (SNetReceiveTurns(0, 4, (char **)glpMsgTbl, (unsigned int *)gdwMsgLenTbl, (unsigned long *)player_state)) { + if (!byte_679758) { + byte_679758 = 1; + last_tick = GetTickCount(); + } + sgbSyncCountdown = 4; + multi_msg_countdown(); + LABEL_11: + *pfSendAsync = 1; + last_tick += 50; + return 1; + } + if (SErrGetLastError() != STORM_ERROR_NO_MESSAGES_WAITING) + nthread_terminate_game("SNetReceiveTurns"); + byte_679758 = 0; + sgbSyncCountdown = 1; + sgbPacketCountdown = 1; + return 0; } // 679704: using guessed type char byte_679704; // 679750: using guessed type char sgbSyncCountdown; @@ -150,67 +150,67 @@ int __fastcall nthread_recv_turns(int *pfSendAsync) void __cdecl nthread_set_turn_upper_bit() { - turn_upper_bit = 0x80000000; + turn_upper_bit = 0x80000000; } // 679754: using guessed type int turn_upper_bit; void __fastcall nthread_start(bool set_turn_upper_bit) { - char *err; // eax - unsigned int largestMsgSize; // esi - unsigned int normalMsgSize; // eax - char *err2; // eax - _SNETCAPS caps; // [esp+8h] [ebp-24h] + char *err; // eax + unsigned int largestMsgSize; // esi + unsigned int normalMsgSize; // eax + char *err2; // eax + _SNETCAPS caps; // [esp+8h] [ebp-24h] - last_tick = GetTickCount(); - sgbPacketCountdown = 1; - sgbSyncCountdown = 1; - byte_679758 = 1; - if (set_turn_upper_bit) - nthread_set_turn_upper_bit(); - else - turn_upper_bit = 0; - caps.size = 36; - if (!SNetGetProviderCaps(&caps)) { - err = TraceLastError(); - TermMsg("SNetGetProviderCaps:\n%s", err); - } - gdwTurnsInTransit = caps.defaultturnsintransit; - if (!caps.defaultturnsintransit) - gdwTurnsInTransit = 1; - if (caps.defaultturnssec <= 0x14u && caps.defaultturnssec) - byte_679704 = 0x14u / caps.defaultturnssec; - else - byte_679704 = 1; - largestMsgSize = 512; - if (caps.maxmessagesize < 0x200u) - largestMsgSize = caps.maxmessagesize; - gdwDeltaBytesSec = (unsigned int)caps.bytessec >> 2; - gdwLargestMsgSize = largestMsgSize; - if (caps.maxplayers > 4u) - caps.maxplayers = 4; - normalMsgSize = (3 * (caps.bytessec * (unsigned int)(unsigned char)byte_679704 / 0x14) >> 2) / caps.maxplayers; - gdwNormalMsgSize = normalMsgSize; - if (normalMsgSize < 0x80) { - do { - byte_679704 *= 2; - normalMsgSize *= 2; - } while (normalMsgSize < 0x80); - gdwNormalMsgSize = normalMsgSize; - } - if (normalMsgSize > largestMsgSize) - gdwNormalMsgSize = largestMsgSize; - if ((unsigned char)gbMaxPlayers > 1u) { - sgbThreadIsRunning = 0; - EnterCriticalSection(&sgMemCrit); - nthread_should_run = 1; - sghThread = (HANDLE)_beginthreadex(NULL, 0, nthread_handler, NULL, 0, &glpNThreadId); - if (sghThread == (HANDLE)-1) { - err2 = TraceLastError(); - TermMsg("nthread2:\n%s", err2); - } - SetThreadPriority(sghThread, THREAD_PRIORITY_HIGHEST); - } + last_tick = GetTickCount(); + sgbPacketCountdown = 1; + sgbSyncCountdown = 1; + byte_679758 = 1; + if (set_turn_upper_bit) + nthread_set_turn_upper_bit(); + else + turn_upper_bit = 0; + caps.size = 36; + if (!SNetGetProviderCaps(&caps)) { + err = TraceLastError(); + TermMsg("SNetGetProviderCaps:\n%s", err); + } + gdwTurnsInTransit = caps.defaultturnsintransit; + if (!caps.defaultturnsintransit) + gdwTurnsInTransit = 1; + if (caps.defaultturnssec <= 0x14u && caps.defaultturnssec) + byte_679704 = 0x14u / caps.defaultturnssec; + else + byte_679704 = 1; + largestMsgSize = 512; + if (caps.maxmessagesize < 0x200u) + largestMsgSize = caps.maxmessagesize; + gdwDeltaBytesSec = (unsigned int)caps.bytessec >> 2; + gdwLargestMsgSize = largestMsgSize; + if (caps.maxplayers > 4u) + caps.maxplayers = 4; + normalMsgSize = (3 * (caps.bytessec * (unsigned int)(unsigned char)byte_679704 / 0x14) >> 2) / caps.maxplayers; + gdwNormalMsgSize = normalMsgSize; + if (normalMsgSize < 0x80) { + do { + byte_679704 *= 2; + normalMsgSize *= 2; + } while (normalMsgSize < 0x80); + gdwNormalMsgSize = normalMsgSize; + } + if (normalMsgSize > largestMsgSize) + gdwNormalMsgSize = largestMsgSize; + if ((unsigned char)gbMaxPlayers > 1u) { + sgbThreadIsRunning = 0; + EnterCriticalSection(&sgMemCrit); + nthread_should_run = 1; + sghThread = (HANDLE)_beginthreadex(NULL, 0, nthread_handler, NULL, 0, &glpNThreadId); + if (sghThread == (HANDLE)-1) { + err2 = TraceLastError(); + TermMsg("nthread2:\n%s", err2); + } + SetThreadPriority(sghThread, THREAD_PRIORITY_HIGHEST); + } } // 679660: using guessed type char gbMaxPlayers; // 679704: using guessed type char byte_679704; @@ -228,47 +228,47 @@ void __fastcall nthread_start(bool set_turn_upper_bit) unsigned int __stdcall nthread_handler(void *a1) { - signed int delta; // esi - int received; // [esp+Ch] [ebp-4h] + signed int delta; // esi + int received; // [esp+Ch] [ebp-4h] - if (nthread_should_run) { - while (1) { - EnterCriticalSection(&sgMemCrit); - if (!nthread_should_run) - break; - nthread_send_and_recv_turn(0, 0); - if (nthread_recv_turns(&received)) - delta = last_tick - GetTickCount(); - else - delta = 50; - LeaveCriticalSection(&sgMemCrit); - if (delta > 0) - Sleep(delta); - if (!nthread_should_run) - return 0; - } - LeaveCriticalSection(&sgMemCrit); - } - return 0; + if (nthread_should_run) { + while (1) { + EnterCriticalSection(&sgMemCrit); + if (!nthread_should_run) + break; + nthread_send_and_recv_turn(0, 0); + if (nthread_recv_turns(&received)) + delta = last_tick - GetTickCount(); + else + delta = 50; + LeaveCriticalSection(&sgMemCrit); + if (delta > 0) + Sleep(delta); + if (!nthread_should_run) + return 0; + } + LeaveCriticalSection(&sgMemCrit); + } + return 0; } // 679734: using guessed type char nthread_should_run; // 679764: using guessed type int last_tick; void __cdecl nthread_cleanup() { - nthread_should_run = 0; - gdwTurnsInTransit = 0; - gdwNormalMsgSize = 0; - gdwLargestMsgSize = 0; - if (sghThread != (HANDLE)-1 && glpNThreadId != GetCurrentThreadId()) { - if (!sgbThreadIsRunning) - LeaveCriticalSection(&sgMemCrit); - if (WaitForSingleObject(sghThread, 0xFFFFFFFF) == -1) { - TermMsg("nthread3:\n(%s)", TraceLastError()); - } - CloseHandle(sghThread); - sghThread = (HANDLE)-1; - } + nthread_should_run = 0; + gdwTurnsInTransit = 0; + gdwNormalMsgSize = 0; + gdwLargestMsgSize = 0; + if (sghThread != (HANDLE)-1 && glpNThreadId != GetCurrentThreadId()) { + if (!sgbThreadIsRunning) + LeaveCriticalSection(&sgMemCrit); + if (WaitForSingleObject(sghThread, 0xFFFFFFFF) == -1) { + TermMsg("nthread3:\n(%s)", TraceLastError()); + } + CloseHandle(sghThread); + sghThread = (HANDLE)-1; + } } // 679734: using guessed type char nthread_should_run; // 679738: using guessed type int gdwTurnsInTransit; @@ -278,28 +278,28 @@ void __cdecl nthread_cleanup() void __fastcall nthread_ignore_mutex(bool bStart) { - if (sghThread != (HANDLE)-1) { - if (bStart) - LeaveCriticalSection(&sgMemCrit); - else - EnterCriticalSection(&sgMemCrit); - sgbThreadIsRunning = bStart; - } + if (sghThread != (HANDLE)-1) { + if (bStart) + LeaveCriticalSection(&sgMemCrit); + else + EnterCriticalSection(&sgMemCrit); + sgbThreadIsRunning = bStart; + } } // 67975A: using guessed type char sgbThreadIsRunning; BOOL __cdecl nthread_has_500ms_passed() { - DWORD currentTickCount; // eax - int ticksElapsed; // ecx + DWORD currentTickCount; // eax + int ticksElapsed; // ecx - currentTickCount = GetTickCount(); - ticksElapsed = currentTickCount - last_tick; - if (gbMaxPlayers == 1 && ticksElapsed > 500) { - last_tick = currentTickCount; - ticksElapsed = 0; - } - return ticksElapsed >= 0; + currentTickCount = GetTickCount(); + ticksElapsed = currentTickCount - last_tick; + if (gbMaxPlayers == 1 && ticksElapsed > 500) { + last_tick = currentTickCount; + ticksElapsed = 0; + } + return ticksElapsed >= 0; } // 679660: using guessed type char gbMaxPlayers; // 679764: using guessed type int last_tick; diff --git a/Source/objects.cpp b/Source/objects.cpp index 7a70e314..bcfaad4b 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -15,122 +15,122 @@ int InitObjFlag; // weak int numobjfiles; // weak int ObjTypeConv[113] = { - 0, - 4, - 20, - 21, - 22, - 24, - 11, - 12, - 13, - 0, - 0, - 0, - 0, - 0, - 25, - 41, - 26, - 0, - 8, - 9, - 10, - 80, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 49, - 0, - 0, - 0, - 0, - 0, - 84, - 85, - 3, - 14, - 15, - 16, - 17, - 18, - 19, - 0, - 0, - 0, - 0, - 0, - 0, - 28, - 0, - 53, - 54, - 36, - 37, - 38, - 39, - 40, - 0, - 0, - 0, - 0, - 0, - 27, - 0, - 0, - 0, - 0, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 5, - 5, - 5, - 6, - 6, - 6, - 7, - 7, - 7, - 0, - 0, - 0, - 0, - 0, - 73, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 83, - 0, - 0, - 89, - 90, - 47, - 46, - 94 + 0, + 4, + 20, + 21, + 22, + 24, + 11, + 12, + 13, + 0, + 0, + 0, + 0, + 0, + 25, + 41, + 26, + 0, + 8, + 9, + 10, + 80, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 49, + 0, + 0, + 0, + 0, + 0, + 84, + 85, + 3, + 14, + 15, + 16, + 17, + 18, + 19, + 0, + 0, + 0, + 0, + 0, + 0, + 28, + 0, + 53, + 54, + 36, + 37, + 38, + 39, + 40, + 0, + 0, + 0, + 0, + 0, + 27, + 0, + 0, + 0, + 0, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 5, + 5, + 5, + 6, + 6, + 6, + 7, + 7, + 7, + 0, + 0, + 0, + 0, + 0, + 73, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 83, + 0, + 0, + 89, + 90, + 47, + 46, + 94 }; ObjDataStruct AllObjects[99] = { - // clang-format off + // clang-format off // oload, ofindex, ominlvl, omaxlvl, olvltype, otheme, oquest, oAnimFlag, oAnimDelay, oAnimLen, oAnimWidth, oSolidFlag, oMissFlag, oLightFlag, oBreak, oSelFlag, oTrapFlag { 1, OFILE_L1BRAZ, 1, 4, 1, -1, -1, 1, 1, 26, 64, 1, 1, 0, 0, 0, 0 }, { 1, OFILE_L1DOORS, 1, 4, 1, -1, -1, 0, 1, 0, 64, 0, 0, 1, 0, 3, 1 }, @@ -231,380 +231,380 @@ ObjDataStruct AllObjects[99] = { { 1, OFILE_DECAP, 9, 9, 3, -1, -1, 0, 2, 0, 96, 1, 1, 1, 0, 1, 0 }, { 2, OFILE_CHEST3, 0, 0, 0, -1, -1, 0, 1, 0, 96, 1, 1, 1, 0, 1, 1 }, { -1, 0, 0, 0, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } - // clang-format on + // clang-format on }; char *ObjMasterLoadList[56] = { - "L1Braz", - "L1Doors", - "Lever", - "Chest1", - "Chest2", - "Banner", - "SkulPile", - "SkulFire", - "SkulStik", - "CruxSk1", - "CruxSk2", - "CruxSk3", - "Book1", - "Book2", - "Rockstan", - "Angel", - "Chest3", - "Burncros", - "Candle2", - "Nude2", - "Switch4", - "TNudeM", - "TNudeW", - "TSoul", - "L2Doors", - "WTorch4", - "WTorch3", - "Sarc", - "Flame1", - "Prsrplt1", - "Traphole", - "MiniWatr", - "WTorch2", - "WTorch1", - "BCase", - "BShelf", - "WeapStnd", - "Barrel", - "Barrelex", - "LShrineG", - "RShrineG", - "Bloodfnt", - "Decap", - "Pedistl", - "L3Doors", - "PFountn", - "Armstand", - "Goatshrn", - "Cauldren", - "MFountn", - "TFountn", - "Altboy", - "Mcirl", - "Bkslbrnt", - "Mushptch", - "LzStand" + "L1Braz", + "L1Doors", + "Lever", + "Chest1", + "Chest2", + "Banner", + "SkulPile", + "SkulFire", + "SkulStik", + "CruxSk1", + "CruxSk2", + "CruxSk3", + "Book1", + "Book2", + "Rockstan", + "Angel", + "Chest3", + "Burncros", + "Candle2", + "Nude2", + "Switch4", + "TNudeM", + "TNudeW", + "TSoul", + "L2Doors", + "WTorch4", + "WTorch3", + "Sarc", + "Flame1", + "Prsrplt1", + "Traphole", + "MiniWatr", + "WTorch2", + "WTorch1", + "BCase", + "BShelf", + "WeapStnd", + "Barrel", + "Barrelex", + "LShrineG", + "RShrineG", + "Bloodfnt", + "Decap", + "Pedistl", + "L3Doors", + "PFountn", + "Armstand", + "Goatshrn", + "Cauldren", + "MFountn", + "TFountn", + "Altboy", + "Mcirl", + "Bkslbrnt", + "Mushptch", + "LzStand" }; int bxadd[8] = { -1, 0, 1, -1, 1, -1, 0, 1 }; int byadd[8] = { -1, -1, -1, 0, 0, 1, 1, 1 }; char *shrinestrs[NUM_SHRINETYPE] = { - "Mysterious", - "Hidden", - "Gloomy", - "Weird", - "Magical", - "Stone", - "Religious", - "Enchanted", - "Thaumaturgic", - "Fascinating", - "Cryptic", - "Magical", - "Eldritch", - "Eerie", - "Divine", - "Holy", - "Sacred", - "Spiritual", - "Spooky", - "Abandoned", - "Creepy", - "Quiet", - "Secluded", - "Ornate", - "Glimmering", - "Tainted" + "Mysterious", + "Hidden", + "Gloomy", + "Weird", + "Magical", + "Stone", + "Religious", + "Enchanted", + "Thaumaturgic", + "Fascinating", + "Cryptic", + "Magical", + "Eldritch", + "Eerie", + "Divine", + "Holy", + "Sacred", + "Spiritual", + "Spooky", + "Abandoned", + "Creepy", + "Quiet", + "Secluded", + "Ornate", + "Glimmering", + "Tainted" }; unsigned char shrinemin[NUM_SHRINETYPE] = { - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1 }; unsigned char shrinemax[NUM_SHRINETYPE] = { - 16, 16, 16, 16, 16, 16, 16, 8, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16 + 16, 16, 16, 16, 16, 16, 16, 8, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16 }; // 0 - sp+mp, 1 - sp only, 2 - mp only unsigned char shrineavail[NUM_SHRINETYPE] = { - 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, - 0, 0, 0, 0, 0, 2 + 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, + 0, 0, 0, 0, 0, 2 }; char *StoryBookName[9] = { - "The Great Conflict", - "The Wages of Sin are War", - "The Tale of the Horadrim", - "The Dark Exile", - "The Sin War", - "The Binding of the Three", - "The Realms Beyond", - "Tale of the Three", - "The Black King" + "The Great Conflict", + "The Wages of Sin are War", + "The Tale of the Horadrim", + "The Dark Exile", + "The Sin War", + "The Binding of the Three", + "The Realms Beyond", + "Tale of the Three", + "The Black King" }; int StoryText[3][3] = { - { QUEST_BOOK11, QUEST_BOOK12, QUEST_BOOK13 }, - { QUEST_BOOK21, QUEST_BOOK22, QUEST_BOOK23 }, - { QUEST_BOOK31, QUEST_BOOK32, QUEST_BOOK33 } + { QUEST_BOOK11, QUEST_BOOK12, QUEST_BOOK13 }, + { QUEST_BOOK21, QUEST_BOOK22, QUEST_BOOK23 }, + { QUEST_BOOK31, QUEST_BOOK32, QUEST_BOOK33 } }; void __cdecl InitObjectGFX() { - ObjDataStruct *v0; // eax - char *v1; // esi - unsigned char v2; // cl - int v3; // edx - int i; // eax - char v5; // al - signed int v7; // ebx - char *v8; // ST08_4 - unsigned char *v9; // eax - int v10; // ecx - unsigned char fileload[56]; // [esp+4h] [ebp-58h] - char filestr[32]; // [esp+3Ch] [ebp-20h] + ObjDataStruct *v0; // eax + char *v1; // esi + unsigned char v2; // cl + int v3; // edx + int i; // eax + char v5; // al + signed int v7; // ebx + char *v8; // ST08_4 + unsigned char *v9; // eax + int v10; // ecx + unsigned char fileload[56]; // [esp+4h] [ebp-58h] + char filestr[32]; // [esp+3Ch] [ebp-20h] - memset(fileload, 0, sizeof(fileload)); - if (AllObjects[0].oload != -1) { - v0 = AllObjects; - v1 = &AllObjects[0].otheme; - do { - if (v0->oload == 1 && currlevel >= (signed int)(char)*(v1 - 3) && currlevel <= (signed int)(char)*(v1 - 2)) - fileload[(char)*(v1 - 4)] = 1; - v2 = *v1; - if (*v1 != -1) { - v3 = numthemes; - for (i = 0; i < v3; ++i) { - if (themes[i].ttype == v2) - fileload[(char)*(v1 - 4)] = 1; - } - } - v5 = v1[1]; - if (v5 != -1) { - if (QuestStatus(v5)) - fileload[(char)*(v1 - 4)] = 1; - } - v1 += 44; - v0 = (ObjDataStruct *)(v1 - 5); - } while (*(v1 - 5) != -1); - } - v7 = 0; - do { - if (fileload[v7]) { - v8 = ObjMasterLoadList[v7]; - ObjFileList[numobjfiles] = v7; - sprintf(filestr, "Objects\\%s.CEL", v8); - v9 = LoadFileInMem(filestr, 0); - v10 = numobjfiles++; - pObjCels[v10] = v9; - } - ++v7; - } while (v7 < 56); + memset(fileload, 0, sizeof(fileload)); + if (AllObjects[0].oload != -1) { + v0 = AllObjects; + v1 = &AllObjects[0].otheme; + do { + if (v0->oload == 1 && currlevel >= (signed int)(char)*(v1 - 3) && currlevel <= (signed int)(char)*(v1 - 2)) + fileload[(char)*(v1 - 4)] = 1; + v2 = *v1; + if (*v1 != -1) { + v3 = numthemes; + for (i = 0; i < v3; ++i) { + if (themes[i].ttype == v2) + fileload[(char)*(v1 - 4)] = 1; + } + } + v5 = v1[1]; + if (v5 != -1) { + if (QuestStatus(v5)) + fileload[(char)*(v1 - 4)] = 1; + } + v1 += 44; + v0 = (ObjDataStruct *)(v1 - 5); + } while (*(v1 - 5) != -1); + } + v7 = 0; + do { + if (fileload[v7]) { + v8 = ObjMasterLoadList[v7]; + ObjFileList[numobjfiles] = v7; + sprintf(filestr, "Objects\\%s.CEL", v8); + v9 = LoadFileInMem(filestr, 0); + v10 = numobjfiles++; + pObjCels[v10] = v9; + } + ++v7; + } while (v7 < 56); } // 67D7C4: using guessed type int numobjfiles; // 44121D: using guessed type char fileload[56]; void __cdecl FreeObjectGFX() { - int i; // esi - void *v1; // ecx + int i; // esi + void *v1; // ecx - for (i = 0; i < numobjfiles; ++i) { - v1 = (void *)pObjCels[i]; - pObjCels[i] = 0; - mem_free_dbg(v1); - } - numobjfiles = 0; + for (i = 0; i < numobjfiles; ++i) { + v1 = (void *)pObjCels[i]; + pObjCels[i] = 0; + mem_free_dbg(v1); + } + numobjfiles = 0; } // 67D7C4: using guessed type int numobjfiles; bool __fastcall RndLocOk(int xp, int yp) { - int v2; // ecx - int v3; // eax - int v4; // eax - bool result; // eax + int v2; // ecx + int v3; // eax + int v4; // eax + bool result; // eax - v2 = xp; - v3 = v2 * 112 + yp; - result = 0; - if (!dMonster[0][v3] && !dPlayer[v2][yp] && !dObject[v2][yp] && !(dFlags[v2][yp] & DFLAG_POPULATED)) { - v4 = dPiece[0][v3]; - if (!nSolidTable[v4] && (leveltype != 1 || v4 <= 126 || v4 >= 144)) - result = 1; - } - return result; + v2 = xp; + v3 = v2 * 112 + yp; + result = 0; + if (!dMonster[0][v3] && !dPlayer[v2][yp] && !dObject[v2][yp] && !(dFlags[v2][yp] & DFLAG_POPULATED)) { + v4 = dPiece[0][v3]; + if (!nSolidTable[v4] && (leveltype != 1 || v4 <= 126 || v4 >= 144)) + result = 1; + } + return result; } void __fastcall InitRndLocObj(int min, int max, int objtype) { - int numobjs; // ebx - int xp; // esi - int yp; // edi - int i; // [esp+8h] [ebp-4h] + int numobjs; // ebx + int xp; // esi + int yp; // edi + int i; // [esp+8h] [ebp-4h] - i = 0; - numobjs = min + random(139, max - min); - if (numobjs > 0) { - while (1) { - do { - xp = random(139, 80) + 16; - yp = random(139, 80) + 16; - } while (!RndLocOk(xp - 1, yp - 1)); - if (RndLocOk(xp, yp - 1)) { - if (RndLocOk(xp + 1, yp - 1)) /* check */ - { - if (RndLocOk(xp - 1, yp)) { - if (RndLocOk(xp, yp)) { - if (RndLocOk(xp + 1, yp)) { - if (RndLocOk(xp - 1, yp + 1)) { - if (RndLocOk(xp, yp + 1)) { - if (RndLocOk(xp + 1, yp + 1)) { - AddObject(objtype, xp, yp); - if (++i >= numobjs) - break; - } - } - } - } - } - } - } - } - } - } + i = 0; + numobjs = min + random(139, max - min); + if (numobjs > 0) { + while (1) { + do { + xp = random(139, 80) + 16; + yp = random(139, 80) + 16; + } while (!RndLocOk(xp - 1, yp - 1)); + if (RndLocOk(xp, yp - 1)) { + if (RndLocOk(xp + 1, yp - 1)) /* check */ + { + if (RndLocOk(xp - 1, yp)) { + if (RndLocOk(xp, yp)) { + if (RndLocOk(xp + 1, yp)) { + if (RndLocOk(xp - 1, yp + 1)) { + if (RndLocOk(xp, yp + 1)) { + if (RndLocOk(xp + 1, yp + 1)) { + AddObject(objtype, xp, yp); + if (++i >= numobjs) + break; + } + } + } + } + } + } + } + } + } + } } void __fastcall InitRndLocBigObj(int min, int max, int objtype) { - int xp; // edi - int yp; // esi - int numobjs; // [esp+4h] [ebp-8h] - int i; // [esp+8h] [ebp-4h] + int xp; // edi + int yp; // esi + int numobjs; // [esp+4h] [ebp-8h] + int i; // [esp+8h] [ebp-4h] - i = 0; - numobjs = min + random(140, max - min); - if (numobjs > 0) { - while (1) { - do { - xp = random(140, 80) + 16; - yp = random(140, 80) + 16; - } while (!RndLocOk(xp - 1, yp - 2)); - if (RndLocOk(xp, yp - 2)) { - if (RndLocOk(xp + 1, yp - 2)) /* check */ - { - if (RndLocOk(xp - 1, yp - 1)) { - if (RndLocOk(xp, yp - 1)) { - if (RndLocOk(xp + 1, yp - 1)) { - if (RndLocOk(xp - 1, yp)) { - if (RndLocOk(xp, yp)) { - if (RndLocOk(xp + 1, yp)) { - if (RndLocOk(xp - 1, yp + 1)) { - if (RndLocOk(xp, yp + 1)) { - if (RndLocOk(xp + 1, yp + 1)) { - AddObject(objtype, xp, yp); - if (++i >= numobjs) - break; - } - } - } - } - } - } - } - } - } - } - } - } - } + i = 0; + numobjs = min + random(140, max - min); + if (numobjs > 0) { + while (1) { + do { + xp = random(140, 80) + 16; + yp = random(140, 80) + 16; + } while (!RndLocOk(xp - 1, yp - 2)); + if (RndLocOk(xp, yp - 2)) { + if (RndLocOk(xp + 1, yp - 2)) /* check */ + { + if (RndLocOk(xp - 1, yp - 1)) { + if (RndLocOk(xp, yp - 1)) { + if (RndLocOk(xp + 1, yp - 1)) { + if (RndLocOk(xp - 1, yp)) { + if (RndLocOk(xp, yp)) { + if (RndLocOk(xp + 1, yp)) { + if (RndLocOk(xp - 1, yp + 1)) { + if (RndLocOk(xp, yp + 1)) { + if (RndLocOk(xp + 1, yp + 1)) { + AddObject(objtype, xp, yp); + if (++i >= numobjs) + break; + } + } + } + } + } + } + } + } + } + } + } + } + } } void __fastcall InitRndLocObj5x5(int min, int max, int objtype) { - int v3; // esi - int v4; // edx - int v6; // ebx - int v7; // eax - int v9; // edi - int v10; // esi - int v11; // edx - signed int v12; // [esp+Ch] [ebp-14h] - int v13; // [esp+10h] [ebp-10h] - int v14; // [esp+14h] [ebp-Ch] - signed int v15; // [esp+18h] [ebp-8h] - signed int v16; // [esp+1Ch] [ebp-4h] + int v3; // esi + int v4; // edx + int v6; // ebx + int v7; // eax + int v9; // edi + int v10; // esi + int v11; // edx + signed int v12; // [esp+Ch] [ebp-14h] + int v13; // [esp+10h] [ebp-10h] + int v14; // [esp+14h] [ebp-Ch] + signed int v15; // [esp+18h] [ebp-8h] + signed int v16; // [esp+1Ch] [ebp-4h] - v3 = min; - v4 = max - min; - v13 = 0; - v6 = v3 + random(139, v4); - if (v6 > 0) { - do { - v14 = 0; - while (1) { - v12 = 1; - v7 = random(139, 80); - v9 = v7 + 16; - v15 = -2; - v10 = random(139, 80) + 16; - do { - v16 = -2; - v11 = v15 + v10; - do { - if (!RndLocOk(v16 + v9, v11)) - v12 = 0; - ++v16; - } while (v16 <= 2); - ++v15; - } while (v15 <= 2); - if (v12) - break; - if (++v14 > 20000) - return; - } - AddObject(objtype, v9, v10); - ++v13; - } while (v13 < v6); - } + v3 = min; + v4 = max - min; + v13 = 0; + v6 = v3 + random(139, v4); + if (v6 > 0) { + do { + v14 = 0; + while (1) { + v12 = 1; + v7 = random(139, 80); + v9 = v7 + 16; + v15 = -2; + v10 = random(139, 80) + 16; + do { + v16 = -2; + v11 = v15 + v10; + do { + if (!RndLocOk(v16 + v9, v11)) + v12 = 0; + ++v16; + } while (v16 <= 2); + ++v15; + } while (v15 <= 2); + if (v12) + break; + if (++v14 > 20000) + return; + } + AddObject(objtype, v9, v10); + ++v13; + } while (v13 < v6); + } } void __cdecl ClrAllObjects() { - int *v0; // eax - int v1; // edx + int *v0; // eax + int v1; // edx - v0 = &object[0]._oy; - do { - *(v0 - 1) = 0; - *v0 = 0; - v0[3] = 0; - v0[4] = 0; - v0[5] = 0; - v0[6] = 0; - v0[7] = 0; - v0[10] = 0; - v0[20] = 0; - v0[21] = 0; - v0[22] = 0; - v0[23] = 0; - v0 += 30; - } while ((signed int)v0 < (signed int)&object[MAXOBJECTS]._oy); - v1 = 0; - memset(objectactive, 0, sizeof(objectactive)); - nobjects = 0; - do { - objectavail[v1] = v1; - ++v1; - } while (v1 < MAXOBJECTS); - trapdir = 0; - trapid = 1; - leverid = 1; + v0 = &object[0]._oy; + do { + *(v0 - 1) = 0; + *v0 = 0; + v0[3] = 0; + v0[4] = 0; + v0[5] = 0; + v0[6] = 0; + v0[7] = 0; + v0[10] = 0; + v0[20] = 0; + v0[21] = 0; + v0[22] = 0; + v0[23] = 0; + v0 += 30; + } while ((signed int)v0 < (signed int)&object[MAXOBJECTS]._oy); + v1 = 0; + memset(objectactive, 0, sizeof(objectactive)); + nobjects = 0; + do { + objectavail[v1] = v1; + ++v1; + } while (v1 < MAXOBJECTS); + trapdir = 0; + trapid = 1; + leverid = 1; } // 679768: using guessed type int trapid; // 67976C: using guessed type int trapdir; @@ -612,827 +612,827 @@ void __cdecl ClrAllObjects() void __cdecl AddTortures() { - int v0; // esi - int v1; // edi - _DWORD *v2; // [esp+Ch] [ebp-4h] + int v0; // esi + int v1; // edi + _DWORD *v2; // [esp+Ch] [ebp-4h] - v0 = 0; - do { - v1 = 2; - v2 = (_DWORD *)((char *)dPiece + 4 * v0); - do { - if (*v2 == 367) { - AddObject(OBJ_TORTURE1, v1 - 2, v0 + 1); - AddObject(OBJ_TORTURE3, v1, v0 - 1); - AddObject(OBJ_TORTURE2, v1 - 2, v0 + 3); - AddObject(OBJ_TORTURE4, v1 + 2, v0 - 1); - AddObject(OBJ_TORTURE5, v1 - 2, v0 + 5); - AddObject(OBJ_TNUDEM1, v1 - 1, v0 + 3); - AddObject(OBJ_TNUDEM2, v1 + 2, v0 + 5); - AddObject(OBJ_TNUDEM3, v1, v0); - AddObject(OBJ_TNUDEM4, v1 + 1, v0 + 2); - AddObject(OBJ_TNUDEW1, v1, v0 + 4); - AddObject(OBJ_TNUDEW2, v1, v0 + 1); - AddObject(OBJ_TNUDEW3, v1 + 2, v0 + 2); - } - v2 += 112; - ++v1; - } while (v1 - 2 < 112); - ++v0; - } while (v0 < 112); + v0 = 0; + do { + v1 = 2; + v2 = (_DWORD *)((char *)dPiece + 4 * v0); + do { + if (*v2 == 367) { + AddObject(OBJ_TORTURE1, v1 - 2, v0 + 1); + AddObject(OBJ_TORTURE3, v1, v0 - 1); + AddObject(OBJ_TORTURE2, v1 - 2, v0 + 3); + AddObject(OBJ_TORTURE4, v1 + 2, v0 - 1); + AddObject(OBJ_TORTURE5, v1 - 2, v0 + 5); + AddObject(OBJ_TNUDEM1, v1 - 1, v0 + 3); + AddObject(OBJ_TNUDEM2, v1 + 2, v0 + 5); + AddObject(OBJ_TNUDEM3, v1, v0); + AddObject(OBJ_TNUDEM4, v1 + 1, v0 + 2); + AddObject(OBJ_TNUDEW1, v1, v0 + 4); + AddObject(OBJ_TNUDEW2, v1, v0 + 1); + AddObject(OBJ_TNUDEW3, v1 + 2, v0 + 2); + } + v2 += 112; + ++v1; + } while (v1 - 2 < 112); + ++v0; + } while (v0 < 112); } void __cdecl AddCandles() { - int v0; // esi - int v1; // edi - int v2; // ebx + int v0; // esi + int v1; // edi + int v2; // ebx - v0 = quests[QTYPE_PW]._qtx; - v1 = quests[QTYPE_PW]._qty; - v2 = quests[QTYPE_PW]._qty + 1; - AddObject(OBJ_STORYCANDLE, quests[QTYPE_PW]._qtx - 2, quests[QTYPE_PW]._qty + 1); - AddObject(OBJ_STORYCANDLE, v0 + 3, v2); - v1 += 2; - AddObject(OBJ_STORYCANDLE, v0 - 1, v1); - AddObject(OBJ_STORYCANDLE, v0 + 2, v1); + v0 = quests[QTYPE_PW]._qtx; + v1 = quests[QTYPE_PW]._qty; + v2 = quests[QTYPE_PW]._qty + 1; + AddObject(OBJ_STORYCANDLE, quests[QTYPE_PW]._qtx - 2, quests[QTYPE_PW]._qty + 1); + AddObject(OBJ_STORYCANDLE, v0 + 3, v2); + v1 += 2; + AddObject(OBJ_STORYCANDLE, v0 - 1, v1); + AddObject(OBJ_STORYCANDLE, v0 + 2, v1); } void __fastcall AddBookLever(int lx1, int ly1, int lx2, int ly2, int x1, int y1, int x2, int y2, int msg) { - int v9; // esi - int v10; // edi - signed int v11; // ebx - int v12; // edx - //int v13; // eax - //int v14; // eax - //int v15; // eax - int v16; // esi - signed int v17; // [esp+Ch] [ebp-Ch] - int v18; // [esp+10h] [ebp-8h] - signed int v19; // [esp+14h] [ebp-4h] + int v9; // esi + int v10; // edi + signed int v11; // ebx + int v12; // edx + //int v13; // eax + //int v14; // eax + //int v15; // eax + int v16; // esi + signed int v17; // [esp+Ch] [ebp-Ch] + int v18; // [esp+10h] [ebp-8h] + signed int v19; // [esp+14h] [ebp-4h] - v18 = 0; - while (1) { - v17 = 1; - v9 = random(139, 80) + 16; - v10 = random(139, 80) + 16; - v11 = -2; - do { - v19 = -2; - v12 = v11 + v10; - do { - if (!RndLocOk(v19 + v9, v12)) - v17 = 0; - ++v19; - } while (v19 <= 2); - ++v11; - } while (v11 <= 2); - if (v17) - break; - if (++v18 > 20000) - return; - } - //_LOBYTE(v13) = QuestStatus(QTYPE_BLIND); - if (QuestStatus(QTYPE_BLIND)) - AddObject(OBJ_BLINDBOOK, v9, v10); - //_LOBYTE(v14) = QuestStatus(QTYPE_WARLRD); - if (QuestStatus(QTYPE_WARLRD)) - AddObject(OBJ_STEELTOME, v9, v10); - //_LOBYTE(v15) = QuestStatus(QTYPE_BLOOD); - if (QuestStatus(QTYPE_BLOOD)) { - v9 = 2 * setpc_x + 25; - v10 = 2 * setpc_y + 40; - AddObject(OBJ_BLOODBOOK, v9, v10); - } - v16 = dObject[v9][v10] - 1; - SetObjMapRange(v16, x1, y1, x2, y2, leverid); - SetBookMsg(v16, msg); - ++leverid; - object[v16]._oVar6 = object[v16]._oAnimFrame + 1; + v18 = 0; + while (1) { + v17 = 1; + v9 = random(139, 80) + 16; + v10 = random(139, 80) + 16; + v11 = -2; + do { + v19 = -2; + v12 = v11 + v10; + do { + if (!RndLocOk(v19 + v9, v12)) + v17 = 0; + ++v19; + } while (v19 <= 2); + ++v11; + } while (v11 <= 2); + if (v17) + break; + if (++v18 > 20000) + return; + } + //_LOBYTE(v13) = QuestStatus(QTYPE_BLIND); + if (QuestStatus(QTYPE_BLIND)) + AddObject(OBJ_BLINDBOOK, v9, v10); + //_LOBYTE(v14) = QuestStatus(QTYPE_WARLRD); + if (QuestStatus(QTYPE_WARLRD)) + AddObject(OBJ_STEELTOME, v9, v10); + //_LOBYTE(v15) = QuestStatus(QTYPE_BLOOD); + if (QuestStatus(QTYPE_BLOOD)) { + v9 = 2 * setpc_x + 25; + v10 = 2 * setpc_y + 40; + AddObject(OBJ_BLOODBOOK, v9, v10); + } + v16 = dObject[v9][v10] - 1; + SetObjMapRange(v16, x1, y1, x2, y2, leverid); + SetBookMsg(v16, msg); + ++leverid; + object[v16]._oVar6 = object[v16]._oAnimFrame + 1; } void __cdecl InitRndBarrels() { - int v0; // ebp - int v1; // esi - int v2; // edi - int v3; // eax - bool v4; // ebx - int v5; // edx - int v6; // eax - int v7; // eax - signed int v8; // [esp+4h] [ebp-Ch] - signed int v9; // [esp+8h] [ebp-8h] - int v10; // [esp+Ch] [ebp-4h] + int v0; // ebp + int v1; // esi + int v2; // edi + int v3; // eax + bool v4; // ebx + int v5; // edx + int v6; // eax + int v7; // eax + signed int v8; // [esp+4h] [ebp-Ch] + signed int v9; // [esp+8h] [ebp-8h] + int v10; // [esp+Ch] [ebp-4h] - v10 = 0; - v0 = random(143, 5) + 3; - if (v0 > 0) { - do { - do { - v1 = random(143, 80) + 16; - v2 = random(143, 80) + 16; - } while (!RndLocOk(v1, v2)); - v3 = random(143, 4); - AddObject(OBJ_BARRELEX - (v3 != 0), v1, v2); - v4 = 1; - v5 = 0; - v9 = 1; - while (!random(143, v5) && v4) { - v8 = 0; - v4 = 0; - do { - if (v8 >= 3) - break; - v6 = random(143, 8); - v1 += bxadd[v6]; - v2 += byadd[v6]; - ++v8; - v4 = RndLocOk(v1, v2); - } while (!v4); - if (v4) { - v7 = random(143, 5); - AddObject(OBJ_BARRELEX - (v7 != 0), v1, v2); - ++v9; - } - v5 = v9 >> 1; - } - ++v10; - } while (v10 < v0); - } + v10 = 0; + v0 = random(143, 5) + 3; + if (v0 > 0) { + do { + do { + v1 = random(143, 80) + 16; + v2 = random(143, 80) + 16; + } while (!RndLocOk(v1, v2)); + v3 = random(143, 4); + AddObject(OBJ_BARRELEX - (v3 != 0), v1, v2); + v4 = 1; + v5 = 0; + v9 = 1; + while (!random(143, v5) && v4) { + v8 = 0; + v4 = 0; + do { + if (v8 >= 3) + break; + v6 = random(143, 8); + v1 += bxadd[v6]; + v2 += byadd[v6]; + ++v8; + v4 = RndLocOk(v1, v2); + } while (!v4); + if (v4) { + v7 = random(143, 5); + AddObject(OBJ_BARRELEX - (v7 != 0), v1, v2); + ++v9; + } + v5 = v9 >> 1; + } + ++v10; + } while (v10 < v0); + } } void __fastcall AddL1Objs(int x1, int y1, int x2, int y2) { - int v4; // ebx - int *v5; // edi - int v6; // esi - int x; // [esp+0h] [ebp-8h] - int y; // [esp+4h] [ebp-4h] + int v4; // ebx + int *v5; // edi + int v6; // esi + int x; // [esp+0h] [ebp-8h] + int y; // [esp+4h] [ebp-4h] - x = x1; - for (y = y1; y < y2; ++y) { - v4 = x; - if (x < x2) { - v5 = (int *)((char *)dPiece + 4 * (y + 112 * x)); - do { - v6 = *v5; - if (*v5 == 270) - AddObject(OBJ_L1LIGHT, v4, y); - if (v6 == 44 || v6 == 51 || v6 == 214) - AddObject(OBJ_L1LDOOR, v4, y); - if (v6 == 46 || v6 == 56) - AddObject(OBJ_L1RDOOR, v4, y); - ++v4; - v5 += 112; - } while (v4 < x2); - } - } + x = x1; + for (y = y1; y < y2; ++y) { + v4 = x; + if (x < x2) { + v5 = (int *)((char *)dPiece + 4 * (y + 112 * x)); + do { + v6 = *v5; + if (*v5 == 270) + AddObject(OBJ_L1LIGHT, v4, y); + if (v6 == 44 || v6 == 51 || v6 == 214) + AddObject(OBJ_L1LDOOR, v4, y); + if (v6 == 46 || v6 == 56) + AddObject(OBJ_L1RDOOR, v4, y); + ++v4; + v5 += 112; + } while (v4 < x2); + } + } } void __fastcall AddL2Objs(int x1, int y1, int x2, int y2) { - int v4; // ebx - int *v5; // esi - int v6; // edi - int x; // [esp+0h] [ebp-8h] - int y; // [esp+4h] [ebp-4h] + int v4; // ebx + int *v5; // esi + int v6; // edi + int x; // [esp+0h] [ebp-8h] + int y; // [esp+4h] [ebp-4h] - x = x1; - for (y = y1; y < y2; ++y) { - v4 = x; - if (x < x2) { - v5 = (int *)((char *)dPiece + 4 * (y + 112 * x)); - do { - v6 = *v5; - if (*v5 == 13 || v6 == 541) - AddObject(OBJ_L2LDOOR, v4, y); - if (v6 == 17 || v6 == 542) - AddObject(OBJ_L2RDOOR, v4, y); - ++v4; - v5 += 112; - } while (v4 < x2); - } - } + x = x1; + for (y = y1; y < y2; ++y) { + v4 = x; + if (x < x2) { + v5 = (int *)((char *)dPiece + 4 * (y + 112 * x)); + do { + v6 = *v5; + if (*v5 == 13 || v6 == 541) + AddObject(OBJ_L2LDOOR, v4, y); + if (v6 == 17 || v6 == 542) + AddObject(OBJ_L2RDOOR, v4, y); + ++v4; + v5 += 112; + } while (v4 < x2); + } + } } void __fastcall AddL3Objs(int x1, int y1, int x2, int y2) { - int v4; // edi - int *v5; // esi - int v6; // ebx - int x; // [esp+0h] [ebp-8h] - int y; // [esp+4h] [ebp-4h] + int v4; // edi + int *v5; // esi + int v6; // ebx + int x; // [esp+0h] [ebp-8h] + int y; // [esp+4h] [ebp-4h] - x = x1; - for (y = y1; y < y2; ++y) { - v4 = x; - if (x < x2) { - v5 = (int *)((char *)dPiece + 4 * (y + 112 * x)); - do { - v6 = *v5; - if (*v5 == 531) - AddObject(OBJ_L3LDOOR, v4, y); - if (v6 == 534) - AddObject(OBJ_L3RDOOR, v4, y); - ++v4; - v5 += 112; - } while (v4 < x2); - } - } + x = x1; + for (y = y1; y < y2; ++y) { + v4 = x; + if (x < x2) { + v5 = (int *)((char *)dPiece + 4 * (y + 112 * x)); + do { + v6 = *v5; + if (*v5 == 531) + AddObject(OBJ_L3LDOOR, v4, y); + if (v6 == 534) + AddObject(OBJ_L3RDOOR, v4, y); + ++v4; + v5 += 112; + } while (v4 < x2); + } + } } bool __fastcall WallTrapLocOk(int xp, int yp) { - return (~dFlags[xp][yp] & DFLAG_POPULATED) >> 3; + return (~dFlags[xp][yp] & DFLAG_POPULATED) >> 3; } void __cdecl AddL2Torches() { - int v0; // esi - int v1; // edi - char *v2; // ebx - //int v3; // eax - int(*v5)[112]; // [esp+Ch] [ebp-Ch] - int v6; // [esp+10h] [ebp-8h] - int(*v7)[112]; // [esp+14h] [ebp-4h] + int v0; // esi + int v1; // edi + char *v2; // ebx + //int v3; // eax + int(*v5)[112]; // [esp+Ch] [ebp-Ch] + int v6; // [esp+10h] [ebp-8h] + int(*v7)[112]; // [esp+14h] [ebp-4h] - v0 = 0; - v7 = dPiece; - do { - v1 = 0; - v2 = &dObject[0][v0 - 1]; /* &dungeon[39][v0 + 39]; */ - v5 = v7; - do { - //_LOBYTE(v3) = WallTrapLocOk(v1, v0); - if (!WallTrapLocOk(v1, v0)) - goto LABEL_18; - v6 = (*v5)[0]; - if ((*v5)[0] == 1) { - if (random(145, 3)) - goto LABEL_18; - AddObject(OBJ_TORCHL2, v1, v0); - } - if (v6 == 5) { - if (random(145, 3)) - goto LABEL_18; - AddObject(OBJ_TORCHR2, v1, v0); - } - if (v6 == 37) { - if (random(145, 10) || *(v2 - 111)) - goto LABEL_18; - AddObject(OBJ_TORCHL, v1 - 1, v0); - } - if (v6 == 41) { - if (!random(145, 10) && !*v2) - AddObject(OBJ_TORCHR, v1, v0 - 1); - } - LABEL_18: - ++v5; - ++v1; - v2 += 112; - } while (v1 < 112); - v7 = (int(*)[112])((char *)v7 + 4); - ++v0; - } while ((signed int)v7 < (signed int)dPiece[1]); + v0 = 0; + v7 = dPiece; + do { + v1 = 0; + v2 = &dObject[0][v0 - 1]; /* &dungeon[39][v0 + 39]; */ + v5 = v7; + do { + //_LOBYTE(v3) = WallTrapLocOk(v1, v0); + if (!WallTrapLocOk(v1, v0)) + goto LABEL_18; + v6 = (*v5)[0]; + if ((*v5)[0] == 1) { + if (random(145, 3)) + goto LABEL_18; + AddObject(OBJ_TORCHL2, v1, v0); + } + if (v6 == 5) { + if (random(145, 3)) + goto LABEL_18; + AddObject(OBJ_TORCHR2, v1, v0); + } + if (v6 == 37) { + if (random(145, 10) || *(v2 - 111)) + goto LABEL_18; + AddObject(OBJ_TORCHL, v1 - 1, v0); + } + if (v6 == 41) { + if (!random(145, 10) && !*v2) + AddObject(OBJ_TORCHR, v1, v0 - 1); + } + LABEL_18: + ++v5; + ++v1; + v2 += 112; + } while (v1 < 112); + v7 = (int(*)[112])((char *)v7 + 4); + ++v0; + } while ((signed int)v7 < (signed int)dPiece[1]); } bool __fastcall TorchLocOK(int xp, int yp) { - int v2; // ecx - bool result; // al + int v2; // ecx + bool result; // al - v2 = xp; - if (dFlags[v2][yp] & DFLAG_POPULATED) - result = 0; - else - result = nTrapTable[dPiece[0][yp + v2 * 112]] != 0; - return result; + v2 = xp; + if (dFlags[v2][yp] & DFLAG_POPULATED) + result = 0; + else + result = nTrapTable[dPiece[0][yp + v2 * 112]] != 0; + return result; } void __cdecl AddObjTraps() { - int v0; // esi - int *v1; // eax - char *v2; // edi - int v3; // ebx - int v4; // edi - int *j; // eax - //int v6; // eax - char v7; // al - int v8; // edi - int *i; // eax - //int v10; // eax - int v11; // eax - int *v12; // [esp+0h] [ebp-18h] - char *v13; // [esp+4h] [ebp-14h] - int *v14; // [esp+8h] [ebp-10h] - int v15; // [esp+Ch] [ebp-Ch] - signed int v16; // [esp+10h] [ebp-8h] - int x; // [esp+14h] [ebp-4h] + int v0; // esi + int *v1; // eax + char *v2; // edi + int v3; // ebx + int v4; // edi + int *j; // eax + //int v6; // eax + char v7; // al + int v8; // edi + int *i; // eax + //int v10; // eax + int v11; // eax + int *v12; // [esp+0h] [ebp-18h] + char *v13; // [esp+4h] [ebp-14h] + int *v14; // [esp+8h] [ebp-10h] + int v15; // [esp+Ch] [ebp-Ch] + signed int v16; // [esp+10h] [ebp-8h] + int x; // [esp+14h] [ebp-4h] - if (currlevel == 1) - v15 = 10; - if (currlevel >= 2u) - v15 = 15; - if (currlevel >= 5u) - v15 = 20; - if (currlevel >= 7u) - v15 = 25; - v0 = 0; - v1 = dPiece[-1]; - v12 = dPiece[-1]; - do { - x = 0; - v16 = 0; - v2 = (char *)dObject + v0; - v14 = v1; - v13 = (char *)dObject + v0; - do { - if (*v2 > 0 && random(144, 100) < v15) { - v3 = (char)(*v2 - 1); - if (AllObjects[object[v3]._otype].oTrapFlag) { - if (random(144, 2)) { - v8 = v0 - 1; - for (i = &dPiece[v16][v0 - 1]; !nSolidTable[*i]; i--) /* check dpiece */ - --v8; - //_LOBYTE(v10) = TorchLocOK(x, v8); - if (TorchLocOK(x, v8) && v0 - v8 > 1) { - AddObject(OBJ_TRAPR, x, v8); - v7 = dObject[v16][v8]; - goto LABEL_27; - } - } else { - v4 = x - 1; - for (j = v14; !nSolidTable[*j]; j -= 112) - --v4; - //_LOBYTE(v6) = TorchLocOK(v4, v0); - if (TorchLocOK(v4, v0) && x - v4 > 1) { - AddObject(OBJ_TRAPL, v4, v0); - v7 = dObject[v4][v0]; - LABEL_27: - v11 = (char)(v7 - 1); - object[v11]._oVar2 = v0; - object[v11]._oVar1 = x; - object[v3]._oTrapFlag = 1; - goto LABEL_28; - } - } - } - } - LABEL_28: - ++v16; - ++x; - v14 += 112; - v2 = (char *)v13 + 112; - v13 += 112; - } while (v16 < 112); - ++v0; - v1 = v12 + 1; - ++v12; - } while ((signed int)v12 < (signed int)dPiece); + if (currlevel == 1) + v15 = 10; + if (currlevel >= 2u) + v15 = 15; + if (currlevel >= 5u) + v15 = 20; + if (currlevel >= 7u) + v15 = 25; + v0 = 0; + v1 = dPiece[-1]; + v12 = dPiece[-1]; + do { + x = 0; + v16 = 0; + v2 = (char *)dObject + v0; + v14 = v1; + v13 = (char *)dObject + v0; + do { + if (*v2 > 0 && random(144, 100) < v15) { + v3 = (char)(*v2 - 1); + if (AllObjects[object[v3]._otype].oTrapFlag) { + if (random(144, 2)) { + v8 = v0 - 1; + for (i = &dPiece[v16][v0 - 1]; !nSolidTable[*i]; i--) /* check dpiece */ + --v8; + //_LOBYTE(v10) = TorchLocOK(x, v8); + if (TorchLocOK(x, v8) && v0 - v8 > 1) { + AddObject(OBJ_TRAPR, x, v8); + v7 = dObject[v16][v8]; + goto LABEL_27; + } + } else { + v4 = x - 1; + for (j = v14; !nSolidTable[*j]; j -= 112) + --v4; + //_LOBYTE(v6) = TorchLocOK(v4, v0); + if (TorchLocOK(v4, v0) && x - v4 > 1) { + AddObject(OBJ_TRAPL, v4, v0); + v7 = dObject[v4][v0]; + LABEL_27: + v11 = (char)(v7 - 1); + object[v11]._oVar2 = v0; + object[v11]._oVar1 = x; + object[v3]._oTrapFlag = 1; + goto LABEL_28; + } + } + } + } + LABEL_28: + ++v16; + ++x; + v14 += 112; + v2 = (char *)v13 + 112; + v13 += 112; + } while (v16 < 112); + ++v0; + v1 = v12 + 1; + ++v12; + } while ((signed int)v12 < (signed int)dPiece); } void __cdecl AddChestTraps() { - signed int v0; // ebp - _BYTE *v1; // ebx - int v2; // esi - int v3; // eax - bool v4; // zf - int v5; // eax - signed int v6; // [esp+10h] [ebp-4h] + signed int v0; // ebp + _BYTE *v1; // ebx + int v2; // esi + int v3; // eax + bool v4; // zf + int v5; // eax + signed int v6; // [esp+10h] [ebp-4h] - v0 = 0; - do { - v1 = (unsigned char *)dObject + v0; - v6 = 112; - do { - if (*v1 > 0) { - v2 = (char)(*v1 - 1); - v3 = object[v2]._otype; - if (v3 >= OBJ_CHEST1 && v3 <= OBJ_CHEST3 && !object[v2]._oTrapFlag && random(0, 100) < 10) { - object[v2]._otype += OBJ_BOOKCASER; - v4 = leveltype == DTYPE_CATACOMBS; - object[v2]._oTrapFlag = 1; - if (v4) - v5 = random(0, 2); - else - v5 = random(0, 3); - object[v2]._oVar4 = v5; - } - } - v1 += 112; - --v6; - } while (v6); - ++v0; - } while (v0 < 112); + v0 = 0; + do { + v1 = (unsigned char *)dObject + v0; + v6 = 112; + do { + if (*v1 > 0) { + v2 = (char)(*v1 - 1); + v3 = object[v2]._otype; + if (v3 >= OBJ_CHEST1 && v3 <= OBJ_CHEST3 && !object[v2]._oTrapFlag && random(0, 100) < 10) { + object[v2]._otype += OBJ_BOOKCASER; + v4 = leveltype == DTYPE_CATACOMBS; + object[v2]._oTrapFlag = 1; + if (v4) + v5 = random(0, 2); + else + v5 = random(0, 3); + object[v2]._oVar4 = v5; + } + } + v1 += 112; + --v6; + } while (v6); + ++v0; + } while (v0 < 112); } void __fastcall LoadMapObjects(unsigned char *pMap, int startx, int starty, int x1, int y1, int w, int h, int leveridx) { - unsigned char *v8; // ebx - int v9; // esi - int v10; // ecx - int v11; // eax - int v12; // ecx - int v13; // eax - int v14; // esi - unsigned char *v15; // ebx - int i; // edi - int v17; // eax - int v18; // [esp+8h] [ebp-10h] - int v19; // [esp+Ch] [ebp-Ch] - int v20; // [esp+10h] [ebp-8h] - int v21; // [esp+14h] [ebp-4h] - int y; // [esp+20h] [ebp+8h] + unsigned char *v8; // ebx + int v9; // esi + int v10; // ecx + int v11; // eax + int v12; // ecx + int v13; // eax + int v14; // esi + unsigned char *v15; // ebx + int i; // edi + int v17; // eax + int v18; // [esp+8h] [ebp-10h] + int v19; // [esp+Ch] [ebp-Ch] + int v20; // [esp+10h] [ebp-8h] + int v21; // [esp+14h] [ebp-4h] + int y; // [esp+20h] [ebp+8h] - v8 = pMap + 2; - InitObjFlag = 1; - v9 = *pMap; - v10 = pMap[2]; - v11 = v10; - v12 = 2 * v10; - v20 = startx; - v13 = v9 * v11; - v14 = 2 * v9; - v19 = v14; - v18 = v12; - v15 = &v8[4 * v14 * v12 + 2 + 2 * v13]; - if (v12 > 0) { - v21 = -16 - starty; - y = starty + 16; - do { - for (i = 0; i < v14; ++i) { - if (*v15) { - AddObject(ObjTypeConv[*v15], i + v20 + 16, y); - v17 = ObjIndex(i + v20 + 16, y); - SetObjMapRange(v17, x1, y1, x1 + w, y1 + h, leveridx); - v14 = v19; - v12 = v18; - } - v15 += 2; - } - ++y; - } while (y + v21 < v12); - } - InitObjFlag = 0; + v8 = pMap + 2; + InitObjFlag = 1; + v9 = *pMap; + v10 = pMap[2]; + v11 = v10; + v12 = 2 * v10; + v20 = startx; + v13 = v9 * v11; + v14 = 2 * v9; + v19 = v14; + v18 = v12; + v15 = &v8[4 * v14 * v12 + 2 + 2 * v13]; + if (v12 > 0) { + v21 = -16 - starty; + y = starty + 16; + do { + for (i = 0; i < v14; ++i) { + if (*v15) { + AddObject(ObjTypeConv[*v15], i + v20 + 16, y); + v17 = ObjIndex(i + v20 + 16, y); + SetObjMapRange(v17, x1, y1, x1 + w, y1 + h, leveridx); + v14 = v19; + v12 = v18; + } + v15 += 2; + } + ++y; + } while (y + v21 < v12); + } + InitObjFlag = 0; } // 67D7C0: using guessed type int InitObjFlag; void __fastcall LoadMapObjs(unsigned char *pMap, int startx, int starty) { - unsigned char *v3; // esi - int v4; // eax - int v5; // edi - int v6; // ecx - int v7; // eax - int v8; // ecx - int v9; // edi - unsigned char *v10; // esi - int i; // ebx - int v12; // [esp+8h] [ebp-8h] - int v13; // [esp+Ch] [ebp-4h] - int y; // [esp+18h] [ebp+8h] + unsigned char *v3; // esi + int v4; // eax + int v5; // edi + int v6; // ecx + int v7; // eax + int v8; // ecx + int v9; // edi + unsigned char *v10; // esi + int i; // ebx + int v12; // [esp+8h] [ebp-8h] + int v13; // [esp+Ch] [ebp-4h] + int y; // [esp+18h] [ebp+8h] - v3 = pMap + 2; - InitObjFlag = 1; - v4 = pMap[2]; - v5 = *pMap; - v6 = v4; - v7 = 2 * v4; - v12 = startx; - v8 = v5 * v6; - v9 = 2 * v5; - v10 = &v3[4 * v9 * v7 + 2 + 2 * v8]; - if (v7 > 0) { - v13 = v7; - y = starty + 16; - do { - for (i = 0; i < v9; ++i) { - if (*v10) - AddObject(ObjTypeConv[*v10], i + v12 + 16, y); - v10 += 2; - } - ++y; - --v13; - } while (v13); - } - InitObjFlag = 0; + v3 = pMap + 2; + InitObjFlag = 1; + v4 = pMap[2]; + v5 = *pMap; + v6 = v4; + v7 = 2 * v4; + v12 = startx; + v8 = v5 * v6; + v9 = 2 * v5; + v10 = &v3[4 * v9 * v7 + 2 + 2 * v8]; + if (v7 > 0) { + v13 = v7; + y = starty + 16; + do { + for (i = 0; i < v9; ++i) { + if (*v10) + AddObject(ObjTypeConv[*v10], i + v12 + 16, y); + v10 += 2; + } + ++y; + --v13; + } while (v13); + } + InitObjFlag = 0; } // 67D7C0: using guessed type int InitObjFlag; void __cdecl AddDiabObjs() { - unsigned char *v0; // esi - unsigned char *v1; // esi - unsigned char *v2; // esi + unsigned char *v0; // esi + unsigned char *v1; // esi + unsigned char *v2; // esi - v0 = LoadFileInMem("Levels\\L4Data\\diab1.DUN", 0); - LoadMapObjects(v0, 2 * diabquad1x, 2 * diabquad1y, diabquad2x, diabquad2y, 11, 12, 1); - mem_free_dbg(v0); - v1 = LoadFileInMem("Levels\\L4Data\\diab2a.DUN", 0); - LoadMapObjects(v1, 2 * diabquad2x, 2 * diabquad2y, diabquad3x, diabquad3y, 11, 11, 2); - mem_free_dbg(v1); - v2 = LoadFileInMem("Levels\\L4Data\\diab3a.DUN", 0); - LoadMapObjects(v2, 2 * diabquad3x, 2 * diabquad3y, diabquad4x, diabquad4y, 9, 9, 3); - mem_free_dbg(v2); + v0 = LoadFileInMem("Levels\\L4Data\\diab1.DUN", 0); + LoadMapObjects(v0, 2 * diabquad1x, 2 * diabquad1y, diabquad2x, diabquad2y, 11, 12, 1); + mem_free_dbg(v0); + v1 = LoadFileInMem("Levels\\L4Data\\diab2a.DUN", 0); + LoadMapObjects(v1, 2 * diabquad2x, 2 * diabquad2y, diabquad3x, diabquad3y, 11, 11, 2); + mem_free_dbg(v1); + v2 = LoadFileInMem("Levels\\L4Data\\diab3a.DUN", 0); + LoadMapObjects(v2, 2 * diabquad3x, 2 * diabquad3y, diabquad4x, diabquad4y, 9, 9, 3); + mem_free_dbg(v2); } // 5289C4: using guessed type int diabquad1x; // 5289C8: using guessed type int diabquad1y; void __cdecl AddStoryBooks() { - int v0; // esi - int v1; // edi - signed int v2; // ebx - int v3; // edx - int v4; // esi - int y; // [esp+Ch] [ebp-Ch] - int v6; // [esp+10h] [ebp-8h] - signed int v7; // [esp+14h] [ebp-4h] + int v0; // esi + int v1; // edi + signed int v2; // ebx + int v3; // edx + int v4; // esi + int y; // [esp+Ch] [ebp-Ch] + int v6; // [esp+10h] [ebp-8h] + signed int v7; // [esp+14h] [ebp-4h] - v6 = 0; - while (1) { - y = 1; - v0 = random(139, 80) + 16; - v1 = random(139, 80) + 16; - v2 = -2; - do { - v7 = -3; - v3 = v2 + v1; - do { - if (!RndLocOk(v7 + v0, v3)) - y = 0; - ++v7; - } while (v7 <= 3); - ++v2; - } while (v2 <= 2); - if (y) - break; - if (++v6 > 20000) - return; - } - AddObject(OBJ_STORYBOOK, v0, v1); - AddObject(OBJ_STORYCANDLE, v0 - 2, v1 + 1); - AddObject(OBJ_STORYCANDLE, v0 - 2, v1); - AddObject(OBJ_STORYCANDLE, v0 - 1, v1 - 1); - AddObject(OBJ_STORYCANDLE, v0 + 1, v1 - 1); - v4 = v0 + 2; - AddObject(OBJ_STORYCANDLE, v4, v1); - AddObject(OBJ_STORYCANDLE, v4, v1 + 1); + v6 = 0; + while (1) { + y = 1; + v0 = random(139, 80) + 16; + v1 = random(139, 80) + 16; + v2 = -2; + do { + v7 = -3; + v3 = v2 + v1; + do { + if (!RndLocOk(v7 + v0, v3)) + y = 0; + ++v7; + } while (v7 <= 3); + ++v2; + } while (v2 <= 2); + if (y) + break; + if (++v6 > 20000) + return; + } + AddObject(OBJ_STORYBOOK, v0, v1); + AddObject(OBJ_STORYCANDLE, v0 - 2, v1 + 1); + AddObject(OBJ_STORYCANDLE, v0 - 2, v1); + AddObject(OBJ_STORYCANDLE, v0 - 1, v1 - 1); + AddObject(OBJ_STORYCANDLE, v0 + 1, v1 - 1); + v4 = v0 + 2; + AddObject(OBJ_STORYCANDLE, v4, v1); + AddObject(OBJ_STORYCANDLE, v4, v1 + 1); } void __fastcall AddHookedBodies(int freq) { - int v1; // ebx - char *v2; // esi - int v3; // edi - //int v4; // eax - int v5; // eax - int v6; // eax - int v7; // eax - int v8; // [esp-8h] [ebp-20h] - int v9; // [esp-4h] [ebp-1Ch] - int max; // [esp+Ch] [ebp-Ch] - int x; // [esp+10h] [ebp-8h] - int y; // [esp+14h] [ebp-4h] + int v1; // ebx + char *v2; // esi + int v3; // edi + //int v4; // eax + int v5; // eax + int v6; // eax + int v7; // eax + int v8; // [esp-8h] [ebp-20h] + int v9; // [esp-4h] [ebp-1Ch] + int max; // [esp+Ch] [ebp-Ch] + int x; // [esp+10h] [ebp-8h] + int y; // [esp+14h] [ebp-4h] - y = 0; - max = freq; - v1 = 16; - do { - x = 0; - v2 = (char *)dungeon + y; - v3 = 17; - do { - if (*v2 == 1 || *v2 == 2) { - if (!random(0, max)) { - //_LOBYTE(v4) = SkipThemeRoom(x, y); - if (SkipThemeRoom(x, y)) { - if (*v2 != 1 || v2[40] != 6) { - if (*v2 == 2 && v2[1] == 6) { - v7 = random(0, 2); - if (v7) { - if (v7 != 1) - goto LABEL_22; - v9 = v1; - v8 = 39; - } else { - v9 = v1; - v8 = 38; - } - AddObject(v8, v3 - 1, v9); - } - } else { - v5 = random(0, 3); - if (v5) { - v6 = v5 - 1; - if (v6) { - if (v6 == 1) - AddObject(OBJ_TORTURE5, v3, v1); - } else { - AddObject(OBJ_TORTURE2, v3, v1); - } - } else { - AddObject(OBJ_TORTURE1, v3, v1); - } - } - } - } - } - LABEL_22: - ++x; - v3 += 2; - v2 += 40; - } while (v3 < 97); - ++y; - v1 += 2; - } while (v1 < 96); + y = 0; + max = freq; + v1 = 16; + do { + x = 0; + v2 = (char *)dungeon + y; + v3 = 17; + do { + if (*v2 == 1 || *v2 == 2) { + if (!random(0, max)) { + //_LOBYTE(v4) = SkipThemeRoom(x, y); + if (SkipThemeRoom(x, y)) { + if (*v2 != 1 || v2[40] != 6) { + if (*v2 == 2 && v2[1] == 6) { + v7 = random(0, 2); + if (v7) { + if (v7 != 1) + goto LABEL_22; + v9 = v1; + v8 = 39; + } else { + v9 = v1; + v8 = 38; + } + AddObject(v8, v3 - 1, v9); + } + } else { + v5 = random(0, 3); + if (v5) { + v6 = v5 - 1; + if (v6) { + if (v6 == 1) + AddObject(OBJ_TORTURE5, v3, v1); + } else { + AddObject(OBJ_TORTURE2, v3, v1); + } + } else { + AddObject(OBJ_TORTURE1, v3, v1); + } + } + } + } + } + LABEL_22: + ++x; + v3 += 2; + v2 += 40; + } while (v3 < 97); + ++y; + v1 += 2; + } while (v1 < 96); } void __cdecl AddL4Goodies() { - AddHookedBodies(6); - InitRndLocObj(2, 6, OBJ_TNUDEM1); - InitRndLocObj(2, 6, OBJ_TNUDEM2); - InitRndLocObj(2, 6, OBJ_TNUDEM3); - InitRndLocObj(2, 6, OBJ_TNUDEM4); - InitRndLocObj(2, 6, OBJ_TNUDEW1); - InitRndLocObj(2, 6, OBJ_TNUDEW2); - InitRndLocObj(2, 6, OBJ_TNUDEW3); - InitRndLocObj(2, 6, OBJ_DECAP); - InitRndLocObj(1, 3, OBJ_CAULDRON); + AddHookedBodies(6); + InitRndLocObj(2, 6, OBJ_TNUDEM1); + InitRndLocObj(2, 6, OBJ_TNUDEM2); + InitRndLocObj(2, 6, OBJ_TNUDEM3); + InitRndLocObj(2, 6, OBJ_TNUDEM4); + InitRndLocObj(2, 6, OBJ_TNUDEW1); + InitRndLocObj(2, 6, OBJ_TNUDEW2); + InitRndLocObj(2, 6, OBJ_TNUDEW3); + InitRndLocObj(2, 6, OBJ_DECAP); + InitRndLocObj(1, 3, OBJ_CAULDRON); } void __cdecl AddLazStand() { - int v0; // edi - int v1; // esi - signed int v2; // ebx - int v3; // edx - int v4; // edi - signed int v5; // [esp+Ch] [ebp-Ch] - int v6; // [esp+10h] [ebp-8h] - signed int v7; // [esp+14h] [ebp-4h] + int v0; // edi + int v1; // esi + signed int v2; // ebx + int v3; // edx + int v4; // edi + signed int v5; // [esp+Ch] [ebp-Ch] + int v6; // [esp+10h] [ebp-8h] + signed int v7; // [esp+14h] [ebp-4h] - v6 = 0; - while (1) { - v5 = 1; - v0 = random(139, 80) + 16; - v1 = random(139, 80) + 16; - v2 = -3; - do { - v7 = -2; - v3 = v2 + v1; - do { - if (!RndLocOk(v7 + v0, v3)) - v5 = 0; - ++v7; - } while (v7 <= 3); - ++v2; - } while (v2 <= 3); - if (v5) - break; - if (++v6 > 10000) { - InitRndLocObj(1, 1, OBJ_LAZSTAND); - return; - } - } - AddObject(OBJ_LAZSTAND, v0, v1); - AddObject(OBJ_TNUDEM2, v0, v1 + 2); - AddObject(OBJ_STORYCANDLE, v0 + 1, v1 + 2); - AddObject(OBJ_TNUDEM3, v0 + 2, v1 + 2); - AddObject(OBJ_TNUDEW1, v0, v1 - 2); - AddObject(OBJ_STORYCANDLE, v0 + 1, v1 - 2); - AddObject(OBJ_TNUDEW2, v0 + 2, v1 - 2); - v4 = v0 - 1; - AddObject(OBJ_STORYCANDLE, v4, v1 - 1); - AddObject(OBJ_TNUDEW3, v4, v1); - AddObject(OBJ_STORYCANDLE, v4, v1 + 1); + v6 = 0; + while (1) { + v5 = 1; + v0 = random(139, 80) + 16; + v1 = random(139, 80) + 16; + v2 = -3; + do { + v7 = -2; + v3 = v2 + v1; + do { + if (!RndLocOk(v7 + v0, v3)) + v5 = 0; + ++v7; + } while (v7 <= 3); + ++v2; + } while (v2 <= 3); + if (v5) + break; + if (++v6 > 10000) { + InitRndLocObj(1, 1, OBJ_LAZSTAND); + return; + } + } + AddObject(OBJ_LAZSTAND, v0, v1); + AddObject(OBJ_TNUDEM2, v0, v1 + 2); + AddObject(OBJ_STORYCANDLE, v0 + 1, v1 + 2); + AddObject(OBJ_TNUDEM3, v0 + 2, v1 + 2); + AddObject(OBJ_TNUDEW1, v0, v1 - 2); + AddObject(OBJ_STORYCANDLE, v0 + 1, v1 - 2); + AddObject(OBJ_TNUDEW2, v0 + 2, v1 - 2); + v4 = v0 - 1; + AddObject(OBJ_STORYCANDLE, v4, v1 - 1); + AddObject(OBJ_TNUDEW3, v4, v1); + AddObject(OBJ_STORYCANDLE, v4, v1 + 1); } void __cdecl InitObjects() { - //int v1; // eax - //int v2; // eax - //int v3; // eax - //int v4; // eax - //int v5; // eax - //int v6; // eax - signed int v8; // ebx - unsigned char *v9; // esi - //int v10; // eax - //int v12; // eax - unsigned char *v14; // esi - //int v15; // eax - //int v16; // [esp+0h] [ebp-4h] + //int v1; // eax + //int v2; // eax + //int v3; // eax + //int v4; // eax + //int v5; // eax + //int v6; // eax + signed int v8; // ebx + unsigned char *v9; // esi + //int v10; // eax + //int v12; // eax + unsigned char *v14; // esi + //int v15; // eax + //int v16; // [esp+0h] [ebp-4h] - ClrAllObjects(); - if (currlevel == 16) { - AddDiabObjs(); - } else { - InitObjFlag = 1; - GetRndSeed(); - if (currlevel == 9 && gbMaxPlayers == 1) - AddSlainHero(); - if (currlevel == quests[QTYPE_BLKM]._qlevel && quests[QTYPE_BLKM]._qactive == 1) - AddMushPatch(); - if (currlevel == 4) - AddStoryBooks(); - if (currlevel == 8) - AddStoryBooks(); - if (currlevel == 12) - AddStoryBooks(); - if (leveltype == DTYPE_CATHEDRAL) { - //_LOBYTE(v1) = QuestStatus(QTYPE_BUTCH); - if (QuestStatus(QTYPE_BUTCH)) - AddTortures(); - //_LOBYTE(v2) = QuestStatus(QTYPE_PW); - if (QuestStatus(QTYPE_PW)) - AddCandles(); - //_LOBYTE(v3) = QuestStatus(QTYPE_BOL); - if (QuestStatus(QTYPE_BOL)) - AddObject(OBJ_SIGNCHEST, 2 * setpc_x + 26, 2 * setpc_y + 19); - InitRndLocBigObj(10, 15, OBJ_SARC); - AddL1Objs(0, 0, 112, 112); - InitRndBarrels(); - } - if (leveltype == DTYPE_CATACOMBS) { - //_LOBYTE(v4) = QuestStatus(QTYPE_INFRA); - if (QuestStatus(QTYPE_INFRA)) - InitRndLocObj5x5(1, 1, OBJ_STAND); - //_LOBYTE(v5) = QuestStatus(QTYPE_BONE); - if (QuestStatus(QTYPE_BONE)) - InitRndLocObj5x5(1, 1, OBJ_BOOK2R); - AddL2Objs(0, 0, 112, 112); - AddL2Torches(); - //_LOBYTE(v6) = QuestStatus(QTYPE_BLIND); - if (QuestStatus(QTYPE_BLIND)) { - if (plr[myplr]._pClass == PC_WARRIOR) { - v8 = QUEST_BLINDING; - } else if (plr[myplr]._pClass == PC_ROGUE) { - v8 = QUEST_RBLINDING; - } else if (plr[myplr]._pClass == PC_SORCERER) { - v8 = QUEST_MBLINDING; - } - quests[QTYPE_BLIND]._qmsg = v8; - AddBookLever(0, 0, 112, 112, setpc_x, setpc_y, setpc_w + setpc_x + 1, setpc_h + setpc_y + 1, v8); - v9 = LoadFileInMem("Levels\\L2Data\\Blind2.DUN", 0); - LoadMapObjs(v9, 2 * setpc_x, 2 * setpc_y); - mem_free_dbg(v9); - } - //_LOBYTE(v10) = QuestStatus(QTYPE_BLOOD); - if (QuestStatus(QTYPE_BLOOD)) { - if (plr[myplr]._pClass == PC_WARRIOR) { - v8 = QUEST_BLOODY; - } else if (plr[myplr]._pClass == PC_ROGUE) { - v8 = QUEST_RBLOODY; - } else if (plr[myplr]._pClass == PC_SORCERER) { - v8 = QUEST_MBLOODY; - } - quests[QTYPE_BLOOD]._qmsg = v8; - AddBookLever(0, 0, 112, 112, setpc_x, setpc_y + 3, setpc_x + 2, setpc_y + 7, v8); - AddObject(OBJ_PEDISTAL, 2 * setpc_x + 25, 2 * setpc_y + 32); - } - InitRndBarrels(); - } - if (leveltype == DTYPE_CAVES) { - AddL3Objs(0, 0, 112, 112); - InitRndBarrels(); - } - if (leveltype == DTYPE_HELL) { - //_LOBYTE(v12) = QuestStatus(QTYPE_WARLRD); - if (QuestStatus(QTYPE_WARLRD)) { - if (plr[myplr]._pClass == PC_WARRIOR) { - v8 = QUEST_BLOODWAR; - } else if (plr[myplr]._pClass == PC_ROGUE) { - v8 = QUEST_RBLOODWAR; - } else if (plr[myplr]._pClass == PC_SORCERER) { - v8 = QUEST_MBLOODWAR; - } - quests[QTYPE_WARLRD]._qmsg = v8; - AddBookLever(0, 0, 112, 112, setpc_x, setpc_y, setpc_x + setpc_w, setpc_y + setpc_h, v8); - v14 = LoadFileInMem("Levels\\L4Data\\Warlord.DUN", 0); - LoadMapObjs(v14, 2 * setpc_x, 2 * setpc_y); - mem_free_dbg(v14); - } - //_LOBYTE(v15) = QuestStatus(QTYPE_VB); - if (QuestStatus(QTYPE_VB) && gbMaxPlayers == 1) - AddLazStand(); - InitRndBarrels(); - AddL4Goodies(); - } - InitRndLocObj(5, 10, 5); - InitRndLocObj(3, 6, 6); - InitRndLocObj(1, 5, 7); - if (leveltype != 4) - AddObjTraps(); - if (leveltype > 1u) - AddChestTraps(); - InitObjFlag = 0; - } + ClrAllObjects(); + if (currlevel == 16) { + AddDiabObjs(); + } else { + InitObjFlag = 1; + GetRndSeed(); + if (currlevel == 9 && gbMaxPlayers == 1) + AddSlainHero(); + if (currlevel == quests[QTYPE_BLKM]._qlevel && quests[QTYPE_BLKM]._qactive == 1) + AddMushPatch(); + if (currlevel == 4) + AddStoryBooks(); + if (currlevel == 8) + AddStoryBooks(); + if (currlevel == 12) + AddStoryBooks(); + if (leveltype == DTYPE_CATHEDRAL) { + //_LOBYTE(v1) = QuestStatus(QTYPE_BUTCH); + if (QuestStatus(QTYPE_BUTCH)) + AddTortures(); + //_LOBYTE(v2) = QuestStatus(QTYPE_PW); + if (QuestStatus(QTYPE_PW)) + AddCandles(); + //_LOBYTE(v3) = QuestStatus(QTYPE_BOL); + if (QuestStatus(QTYPE_BOL)) + AddObject(OBJ_SIGNCHEST, 2 * setpc_x + 26, 2 * setpc_y + 19); + InitRndLocBigObj(10, 15, OBJ_SARC); + AddL1Objs(0, 0, 112, 112); + InitRndBarrels(); + } + if (leveltype == DTYPE_CATACOMBS) { + //_LOBYTE(v4) = QuestStatus(QTYPE_INFRA); + if (QuestStatus(QTYPE_INFRA)) + InitRndLocObj5x5(1, 1, OBJ_STAND); + //_LOBYTE(v5) = QuestStatus(QTYPE_BONE); + if (QuestStatus(QTYPE_BONE)) + InitRndLocObj5x5(1, 1, OBJ_BOOK2R); + AddL2Objs(0, 0, 112, 112); + AddL2Torches(); + //_LOBYTE(v6) = QuestStatus(QTYPE_BLIND); + if (QuestStatus(QTYPE_BLIND)) { + if (plr[myplr]._pClass == PC_WARRIOR) { + v8 = QUEST_BLINDING; + } else if (plr[myplr]._pClass == PC_ROGUE) { + v8 = QUEST_RBLINDING; + } else if (plr[myplr]._pClass == PC_SORCERER) { + v8 = QUEST_MBLINDING; + } + quests[QTYPE_BLIND]._qmsg = v8; + AddBookLever(0, 0, 112, 112, setpc_x, setpc_y, setpc_w + setpc_x + 1, setpc_h + setpc_y + 1, v8); + v9 = LoadFileInMem("Levels\\L2Data\\Blind2.DUN", 0); + LoadMapObjs(v9, 2 * setpc_x, 2 * setpc_y); + mem_free_dbg(v9); + } + //_LOBYTE(v10) = QuestStatus(QTYPE_BLOOD); + if (QuestStatus(QTYPE_BLOOD)) { + if (plr[myplr]._pClass == PC_WARRIOR) { + v8 = QUEST_BLOODY; + } else if (plr[myplr]._pClass == PC_ROGUE) { + v8 = QUEST_RBLOODY; + } else if (plr[myplr]._pClass == PC_SORCERER) { + v8 = QUEST_MBLOODY; + } + quests[QTYPE_BLOOD]._qmsg = v8; + AddBookLever(0, 0, 112, 112, setpc_x, setpc_y + 3, setpc_x + 2, setpc_y + 7, v8); + AddObject(OBJ_PEDISTAL, 2 * setpc_x + 25, 2 * setpc_y + 32); + } + InitRndBarrels(); + } + if (leveltype == DTYPE_CAVES) { + AddL3Objs(0, 0, 112, 112); + InitRndBarrels(); + } + if (leveltype == DTYPE_HELL) { + //_LOBYTE(v12) = QuestStatus(QTYPE_WARLRD); + if (QuestStatus(QTYPE_WARLRD)) { + if (plr[myplr]._pClass == PC_WARRIOR) { + v8 = QUEST_BLOODWAR; + } else if (plr[myplr]._pClass == PC_ROGUE) { + v8 = QUEST_RBLOODWAR; + } else if (plr[myplr]._pClass == PC_SORCERER) { + v8 = QUEST_MBLOODWAR; + } + quests[QTYPE_WARLRD]._qmsg = v8; + AddBookLever(0, 0, 112, 112, setpc_x, setpc_y, setpc_x + setpc_w, setpc_y + setpc_h, v8); + v14 = LoadFileInMem("Levels\\L4Data\\Warlord.DUN", 0); + LoadMapObjs(v14, 2 * setpc_x, 2 * setpc_y); + mem_free_dbg(v14); + } + //_LOBYTE(v15) = QuestStatus(QTYPE_VB); + if (QuestStatus(QTYPE_VB) && gbMaxPlayers == 1) + AddLazStand(); + InitRndBarrels(); + AddL4Goodies(); + } + InitRndLocObj(5, 10, 5); + InitRndLocObj(3, 6, 6); + InitRndLocObj(1, 5, 7); + if (leveltype != 4) + AddObjTraps(); + if (leveltype > 1u) + AddChestTraps(); + InitObjFlag = 0; + } } // 5CF330: using guessed type int setpc_h; // 5CF334: using guessed type int setpc_w; @@ -1441,91 +1441,91 @@ void __cdecl InitObjects() void __fastcall SetMapObjects(unsigned char *pMap, int startx, int starty) { - unsigned char *v3; // esi - int v6; // edi - int v7; // eax - int v8; // esi - int v9; // ecx - int v10; // esi - int v11; // ecx - int v12; // edi - _BYTE *v13; // eax - int v14; // ebx - signed int v15; // ebx - char *v16; // ST08_4 - unsigned char *v17; // eax - int v18; // ecx - int i; // ebx - int fileload[56]; // [esp+Ch] [ebp-10Ch] - char filestr[32]; // [esp+ECh] [ebp-2Ch] - _BYTE *v22; // [esp+10Ch] [ebp-Ch] - int v23; // [esp+110h] [ebp-8h] - _BYTE *v24; // [esp+114h] [ebp-4h] - int y; // [esp+120h] [ebp+8h] + unsigned char *v3; // esi + int v6; // edi + int v7; // eax + int v8; // esi + int v9; // ecx + int v10; // esi + int v11; // ecx + int v12; // edi + _BYTE *v13; // eax + int v14; // ebx + signed int v15; // ebx + char *v16; // ST08_4 + unsigned char *v17; // eax + int v18; // ecx + int i; // ebx + int fileload[56]; // [esp+Ch] [ebp-10Ch] + char filestr[32]; // [esp+ECh] [ebp-2Ch] + _BYTE *v22; // [esp+10Ch] [ebp-Ch] + int v23; // [esp+110h] [ebp-8h] + _BYTE *v24; // [esp+114h] [ebp-4h] + int y; // [esp+120h] [ebp+8h] - v23 = startx; - v3 = pMap; - ClrAllObjects(); - memset(fileload, 0, sizeof(fileload)); - InitObjFlag = 1; - if (AllObjects[0].oload != -1) { - i = 0; - do { - if (AllObjects[i].oload == 1 && leveltype == AllObjects[i].olvltype) - fileload[AllObjects[i].ofindex] = 1; - i++; - } while (AllObjects[i].oload != -1); - } - v6 = (unsigned char)*v3; - v7 = (int)(v3 + 2); - v8 = (unsigned char)v3[2]; - v9 = v8; - v10 = 2 * v8; - v11 = v6 * v9; - v12 = 2 * v6; - v13 = (_BYTE *)(2 * v11 + 2 + 4 * v12 * v10 + v7); - v22 = v13; - if (v10 > 0) { - v24 = (_BYTE *)v10; - do { - if (v12 > 0) { - v14 = v12; - do { - if (*v13) - fileload[(char)AllObjects[ObjTypeConv[(unsigned char)*v13]].ofindex] = 1; - v13 += 2; - --v14; - } while (v14); - } - --v24; - } while (v24); - } - v15 = 0; - do { - if (fileload[v15]) { - v16 = ObjMasterLoadList[v15]; - ObjFileList[numobjfiles] = v15; - sprintf(filestr, "Objects\\%s.CEL", v16); - v17 = LoadFileInMem(filestr, 0); - v18 = numobjfiles++; - pObjCels[v18] = v17; - } - ++v15; - } while (v15 < 56); - v24 = v22; - if (v10 > 0) { - y = starty + 16; - do { - for (i = 0; i < v12; ++i) { - if (*v24) - AddObject(ObjTypeConv[(unsigned char)*v24], i + v23 + 16, y); - v24 += 2; - } - ++y; - --v10; - } while (v10); - } - InitObjFlag = 0; + v23 = startx; + v3 = pMap; + ClrAllObjects(); + memset(fileload, 0, sizeof(fileload)); + InitObjFlag = 1; + if (AllObjects[0].oload != -1) { + i = 0; + do { + if (AllObjects[i].oload == 1 && leveltype == AllObjects[i].olvltype) + fileload[AllObjects[i].ofindex] = 1; + i++; + } while (AllObjects[i].oload != -1); + } + v6 = (unsigned char)*v3; + v7 = (int)(v3 + 2); + v8 = (unsigned char)v3[2]; + v9 = v8; + v10 = 2 * v8; + v11 = v6 * v9; + v12 = 2 * v6; + v13 = (_BYTE *)(2 * v11 + 2 + 4 * v12 * v10 + v7); + v22 = v13; + if (v10 > 0) { + v24 = (_BYTE *)v10; + do { + if (v12 > 0) { + v14 = v12; + do { + if (*v13) + fileload[(char)AllObjects[ObjTypeConv[(unsigned char)*v13]].ofindex] = 1; + v13 += 2; + --v14; + } while (v14); + } + --v24; + } while (v24); + } + v15 = 0; + do { + if (fileload[v15]) { + v16 = ObjMasterLoadList[v15]; + ObjFileList[numobjfiles] = v15; + sprintf(filestr, "Objects\\%s.CEL", v16); + v17 = LoadFileInMem(filestr, 0); + v18 = numobjfiles++; + pObjCels[v18] = v17; + } + ++v15; + } while (v15 < 56); + v24 = v22; + if (v10 > 0) { + y = starty + 16; + do { + for (i = 0; i < v12; ++i) { + if (*v24) + AddObject(ObjTypeConv[(unsigned char)*v24], i + v23 + 16, y); + v24 += 2; + } + ++y; + --v10; + } while (v10); + } + InitObjFlag = 0; } // 67D7C0: using guessed type int InitObjFlag; // 67D7C4: using guessed type int numobjfiles; @@ -1533,3576 +1533,3576 @@ void __fastcall SetMapObjects(unsigned char *pMap, int startx, int starty) void __fastcall DeleteObject(int oi, int i) { - int v2; // eax - bool v3; // zf - bool v4; // sf + int v2; // eax + bool v3; // zf + bool v4; // sf - dObject[object[oi]._ox][object[oi]._oy] = 0; - v2 = nobjects - 1; - v3 = nobjects == 1; - v4 = nobjects - 1 < 0; - objectavail[-nobjects + MAXOBJECTS] = oi; /* *(&object[0]._otype - nobjects) = oi; */ - nobjects = v2; - if (!v4 && !v3 && i != v2) - objectactive[i] = objectactive[v2]; + dObject[object[oi]._ox][object[oi]._oy] = 0; + v2 = nobjects - 1; + v3 = nobjects == 1; + v4 = nobjects - 1 < 0; + objectavail[-nobjects + MAXOBJECTS] = oi; /* *(&object[0]._otype - nobjects) = oi; */ + nobjects = v2; + if (!v4 && !v3 && i != v2) + objectactive[i] = objectactive[v2]; } void __fastcall SetupObject(int i, int x, int y, int ot) { - int v4; // esi - int v5; // edi - int v6; // ecx - int v7; // edx - int v8; // eax - int v9; // eax - int v10; // edx - int v11; // eax - int v13; // eax - int v14; // eax + int v4; // esi + int v5; // edi + int v6; // ecx + int v7; // edx + int v8; // eax + int v9; // eax + int v10; // edx + int v11; // eax + int v13; // eax + int v14; // eax - v4 = i; - object[v4]._otype = ot; - v5 = ot; - v6 = AllObjects[ot].ofindex; - object[v4]._ox = x; - object[v4]._oy = y; - v7 = ObjFileList[0]; - v8 = 0; - while (v7 != v6) - v7 = ObjFileList[v8++ + 1]; - object[v4]._oAnimData = pObjCels[v8]; - v9 = AllObjects[v5].oAnimFlag; - object[v4]._oAnimFlag = v9; - if (v9) { - v10 = AllObjects[v5].oAnimDelay; - object[v4]._oAnimDelay = v10; - object[v4]._oAnimCnt = random(146, v10); - v11 = AllObjects[v5].oAnimLen; - object[v4]._oAnimLen = v11; - v13 = random(146, v11 - 1) + 1; - } else { - v14 = AllObjects[v5].oAnimLen; - object[v4]._oAnimDelay = 1000; - object[v4]._oAnimLen = v14; - v13 = AllObjects[v5].oAnimDelay; - object[v4]._oAnimCnt = 0; - } - object[v4]._oAnimFrame = v13; - object[v4]._oAnimWidth = AllObjects[v5].oAnimWidth; - object[v4]._oSolidFlag = AllObjects[v5].oSolidFlag; - object[v4]._oMissFlag = AllObjects[v5].oMissFlag; - object[v4]._oLight = AllObjects[v5].oLightFlag; - object[v4]._oBreak = AllObjects[v5].oBreak; - object[v4]._oDelFlag = 0; - object[v4]._oSelFlag = AllObjects[v5].oSelFlag; - object[v4]._oPreFlag = 0; - object[v4]._oTrapFlag = 0; - object[v4]._oDoorFlag = 0; + v4 = i; + object[v4]._otype = ot; + v5 = ot; + v6 = AllObjects[ot].ofindex; + object[v4]._ox = x; + object[v4]._oy = y; + v7 = ObjFileList[0]; + v8 = 0; + while (v7 != v6) + v7 = ObjFileList[v8++ + 1]; + object[v4]._oAnimData = pObjCels[v8]; + v9 = AllObjects[v5].oAnimFlag; + object[v4]._oAnimFlag = v9; + if (v9) { + v10 = AllObjects[v5].oAnimDelay; + object[v4]._oAnimDelay = v10; + object[v4]._oAnimCnt = random(146, v10); + v11 = AllObjects[v5].oAnimLen; + object[v4]._oAnimLen = v11; + v13 = random(146, v11 - 1) + 1; + } else { + v14 = AllObjects[v5].oAnimLen; + object[v4]._oAnimDelay = 1000; + object[v4]._oAnimLen = v14; + v13 = AllObjects[v5].oAnimDelay; + object[v4]._oAnimCnt = 0; + } + object[v4]._oAnimFrame = v13; + object[v4]._oAnimWidth = AllObjects[v5].oAnimWidth; + object[v4]._oSolidFlag = AllObjects[v5].oSolidFlag; + object[v4]._oMissFlag = AllObjects[v5].oMissFlag; + object[v4]._oLight = AllObjects[v5].oLightFlag; + object[v4]._oBreak = AllObjects[v5].oBreak; + object[v4]._oDelFlag = 0; + object[v4]._oSelFlag = AllObjects[v5].oSelFlag; + object[v4]._oPreFlag = 0; + object[v4]._oTrapFlag = 0; + object[v4]._oDoorFlag = 0; } void __fastcall SetObjMapRange(int i, int x1, int y1, int x2, int y2, int v) { - object[i]._oVar1 = x1; - object[i]._oVar2 = y1; - object[i]._oVar3 = x2; - object[i]._oVar4 = y2; - object[i]._oVar8 = v; + object[i]._oVar1 = x1; + object[i]._oVar2 = y1; + object[i]._oVar3 = x2; + object[i]._oVar4 = y2; + object[i]._oVar8 = v; } void __fastcall SetBookMsg(int i, int msg) { - object[i]._oVar7 = msg; + object[i]._oVar7 = msg; } void __fastcall AddL1Door(int i, int x, int y, int ot) { - int v4; // ecx - int v5; // edx - int *v6; // eax - int v7; // edx - int v8; // eax - int v9; // eax + int v4; // ecx + int v5; // edx + int *v6; // eax + int v7; // edx + int v8; // eax + int v9; // eax - v4 = i; - v5 = 112 * x; - object[v4]._oDoorFlag = 1; - if (ot == 1) { - v6 = (int *)((char *)dPiece + 4 * (y + v5)); - v7 = *v6; - v8 = *(v6 - 1); - } else { - v9 = v5 + y; - v7 = dPiece[0][v5 + y]; - v8 = dPiece[-1][v5 + y]; // *(_DWORD *)&dflags[28][4 * v9 + 32]; /* check */ - } - object[v4]._oVar4 = 0; - object[v4]._oVar1 = v7; - object[v4]._oVar2 = v8; + v4 = i; + v5 = 112 * x; + object[v4]._oDoorFlag = 1; + if (ot == 1) { + v6 = (int *)((char *)dPiece + 4 * (y + v5)); + v7 = *v6; + v8 = *(v6 - 1); + } else { + v9 = v5 + y; + v7 = dPiece[0][v5 + y]; + v8 = dPiece[-1][v5 + y]; // *(_DWORD *)&dflags[28][4 * v9 + 32]; /* check */ + } + object[v4]._oVar4 = 0; + object[v4]._oVar1 = v7; + object[v4]._oVar2 = v8; } void __fastcall AddSCambBook(int i) { - object[i]._oVar1 = setpc_x; - object[i]._oVar2 = setpc_y; - object[i]._oVar3 = setpc_w + setpc_x + 1; - object[i]._oVar4 = setpc_h + setpc_y + 1; - object[i]._oVar6 = object[i]._oAnimFrame + 1; + object[i]._oVar1 = setpc_x; + object[i]._oVar2 = setpc_y; + object[i]._oVar3 = setpc_w + setpc_x + 1; + object[i]._oVar4 = setpc_h + setpc_y + 1; + object[i]._oVar6 = object[i]._oAnimFrame + 1; } // 5CF330: using guessed type int setpc_h; // 5CF334: using guessed type int setpc_w; void __fastcall AddChest(int i, int t) { - int v2; // edi - int v3; // esi - int v4; // esi - int v6; // [esp-4h] [ebp-Ch] + int v2; // edi + int v3; // esi + int v4; // esi + int v6; // [esp-4h] [ebp-Ch] - v2 = t; - v3 = i; - if (!random(147, 2)) - object[v3]._oAnimFrame += 3; - v4 = v3; - object[v4]._oRndSeed = GetRndSeed(); - switch (v2) { - case OBJ_CHEST1: - goto LABEL_22; - case OBJ_CHEST2: - LABEL_12: - if (setlevel) { - object[v4]._oVar1 = 2; - break; - } - v6 = 3; - goto LABEL_18; - case OBJ_CHEST3: - LABEL_9: - if (setlevel) { - object[v4]._oVar1 = 3; - break; - } - v6 = 4; - LABEL_18: - object[v4]._oVar1 = random(147, v6); - break; - case OBJ_TCHEST1: - LABEL_22: - if (setlevel) { - object[v4]._oVar1 = 1; - break; - } - v6 = 2; - goto LABEL_18; - case OBJ_TCHEST2: - goto LABEL_12; - case OBJ_TCHEST3: - goto LABEL_9; - } - object[v4]._oVar2 = random(147, 8); + v2 = t; + v3 = i; + if (!random(147, 2)) + object[v3]._oAnimFrame += 3; + v4 = v3; + object[v4]._oRndSeed = GetRndSeed(); + switch (v2) { + case OBJ_CHEST1: + goto LABEL_22; + case OBJ_CHEST2: + LABEL_12: + if (setlevel) { + object[v4]._oVar1 = 2; + break; + } + v6 = 3; + goto LABEL_18; + case OBJ_CHEST3: + LABEL_9: + if (setlevel) { + object[v4]._oVar1 = 3; + break; + } + v6 = 4; + LABEL_18: + object[v4]._oVar1 = random(147, v6); + break; + case OBJ_TCHEST1: + LABEL_22: + if (setlevel) { + object[v4]._oVar1 = 1; + break; + } + v6 = 2; + goto LABEL_18; + case OBJ_TCHEST2: + goto LABEL_12; + case OBJ_TCHEST3: + goto LABEL_9; + } + object[v4]._oVar2 = random(147, 8); } // 5CF31D: using guessed type char setlevel; void __fastcall AddL2Door(int i, int x, int y, int ot) { - int v4; // esi + int v4; // esi - v4 = i; - object[i]._oDoorFlag = 1; - if (ot == OBJ_L2LDOOR) - ObjSetMicro(x, y, 538); - else - ObjSetMicro(x, y, 540); - object[v4]._oVar4 = 0; + v4 = i; + object[i]._oDoorFlag = 1; + if (ot == OBJ_L2LDOOR) + ObjSetMicro(x, y, 538); + else + ObjSetMicro(x, y, 540); + object[v4]._oVar4 = 0; } void __fastcall AddL3Door(int i, int x, int y, int ot) { - int v4; // esi + int v4; // esi - v4 = i; - object[i]._oDoorFlag = 1; - if (ot == OBJ_L3LDOOR) - ObjSetMicro(x, y, 531); - else - ObjSetMicro(x, y, 534); - object[v4]._oVar4 = 0; + v4 = i; + object[i]._oDoorFlag = 1; + if (ot == OBJ_L3LDOOR) + ObjSetMicro(x, y, 531); + else + ObjSetMicro(x, y, 534); + object[v4]._oVar4 = 0; } void __fastcall AddSarc(int i) { - int v1; // esi - char v2; // al - int v3; // ecx - int v4; // eax - bool v5; // sf - unsigned char v6; // of + int v1; // esi + char v2; // al + int v3; // ecx + int v4; // eax + bool v5; // sf + unsigned char v6; // of - v1 = i; - v2 = -1 - i; - v3 = 112 * object[i]._ox; - dObject[0][v3 + object[v1]._oy - 1] = v2; /* dungeon[39][v3 + 39 + object[v1]._oy] = v2; */ - object[v1]._oVar1 = random(153, 10); - v4 = GetRndSeed(); - v6 = __OFSUB__(object[v1]._oVar1, 8); - v5 = object[v1]._oVar1 - 8 < 0; - object[v1]._oRndSeed = v4; - if (!(v5 ^ v6)) - object[v1]._oVar2 = PreSpawnSkeleton(); + v1 = i; + v2 = -1 - i; + v3 = 112 * object[i]._ox; + dObject[0][v3 + object[v1]._oy - 1] = v2; /* dungeon[39][v3 + 39 + object[v1]._oy] = v2; */ + object[v1]._oVar1 = random(153, 10); + v4 = GetRndSeed(); + v6 = __OFSUB__(object[v1]._oVar1, 8); + v5 = object[v1]._oVar1 - 8 < 0; + object[v1]._oRndSeed = v4; + if (!(v5 ^ v6)) + object[v1]._oVar2 = PreSpawnSkeleton(); } void __fastcall AddFlameTrap(int i) { - object[i]._oVar1 = trapid; - object[i]._oVar2 = 0; - object[i]._oVar3 = trapdir; - object[i]._oVar4 = 0; + object[i]._oVar1 = trapid; + object[i]._oVar2 = 0; + object[i]._oVar3 = trapdir; + object[i]._oVar4 = 0; } // 679768: using guessed type int trapid; // 67976C: using guessed type int trapdir; void __fastcall AddFlameLvr(int i) { - object[i]._oVar1 = trapid; - object[i]._oVar2 = 49; + object[i]._oVar1 = trapid; + object[i]._oVar2 = 49; } // 679768: using guessed type int trapid; void __fastcall AddTrap(int i) { - int mt; // eax + int mt; // eax - mt = random(148, currlevel / 3 + 1); - if (!mt) - object[i]._oVar3 = 0; - if (mt == 1) - object[i]._oVar3 = 1; - if (mt == 2) - object[i]._oVar3 = 7; - object[i]._oVar4 = 0; + mt = random(148, currlevel / 3 + 1); + if (!mt) + object[i]._oVar3 = 0; + if (mt == 1) + object[i]._oVar3 = 1; + if (mt == 2) + object[i]._oVar3 = 7; + object[i]._oVar4 = 0; } void __fastcall AddObjLight(int i, int r) { - if (InitObjFlag) { - DoLighting(object[i]._ox, object[i]._oy, r, -1); - object[i]._oVar1 = -1; - } else { - object[i]._oVar1 = 0; - } + if (InitObjFlag) { + DoLighting(object[i]._ox, object[i]._oy, r, -1); + object[i]._oVar1 = -1; + } else { + object[i]._oVar1 = 0; + } } // 67D7C0: using guessed type int InitObjFlag; void __fastcall AddBarrel(int i) { - int v1; // esi - int v2; // eax - int v4; // eax - int v6; // eax - bool v7; // sf - unsigned char v8; // of + int v1; // esi + int v2; // eax + int v4; // eax + int v6; // eax + bool v7; // sf + unsigned char v8; // of - v1 = i; - object[i]._oVar1 = 0; - v2 = GetRndSeed(); - object[v1]._oRndSeed = v2; - v4 = random(149, 10); - object[v1]._oVar2 = v4; - v6 = random(149, 3); - v8 = __OFSUB__(object[v1]._oVar2, 8); - v7 = object[v1]._oVar2 - 8 < 0; - object[v1]._oVar3 = v6; - if (!(v7 ^ v8)) - object[v1]._oVar4 = PreSpawnSkeleton(); + v1 = i; + object[i]._oVar1 = 0; + v2 = GetRndSeed(); + object[v1]._oRndSeed = v2; + v4 = random(149, 10); + object[v1]._oVar2 = v4; + v6 = random(149, 3); + v8 = __OFSUB__(object[v1]._oVar2, 8); + v7 = object[v1]._oVar2 - 8 < 0; + object[v1]._oVar3 = v6; + if (!(v7 ^ v8)) + object[v1]._oVar4 = PreSpawnSkeleton(); } void __fastcall AddShrine(int i) { - int v1; // esi - signed int v2; // edi - signed int v3; // eax - int *v4; // ecx - bool v5; // zf - int v6; // eax - int slist[26]; // [esp+8h] [ebp-68h] + int v1; // esi + signed int v2; // edi + signed int v3; // eax + int *v4; // ecx + bool v5; // zf + int v6; // eax + int slist[26]; // [esp+8h] [ebp-68h] - v1 = i; - v2 = currlevel; - v3 = 0; - object[i]._oPreFlag = 1; - do { - if (v2 < (char)shrinemin[v3] || v2 > (char)shrinemax[v3]) { - v4 = &slist[v3]; - *v4 = 0; - } else { - v4 = &slist[v3]; - *v4 = 1; - } - if (gbMaxPlayers == 1) - v5 = shrineavail[v3] == 2; - else - v5 = shrineavail[v3] == 1; - if (v5) - *v4 = 0; - ++v3; - } while (v3 < 26); - do { - v6 = random(150, 26); - } while (!slist[v6]); - object[v1]._oVar1 = v6; - if (random(150, 2)) { - object[v1]._oAnimFrame = 12; - object[v1]._oAnimLen = 22; - } + v1 = i; + v2 = currlevel; + v3 = 0; + object[i]._oPreFlag = 1; + do { + if (v2 < (char)shrinemin[v3] || v2 > (char)shrinemax[v3]) { + v4 = &slist[v3]; + *v4 = 0; + } else { + v4 = &slist[v3]; + *v4 = 1; + } + if (gbMaxPlayers == 1) + v5 = shrineavail[v3] == 2; + else + v5 = shrineavail[v3] == 1; + if (v5) + *v4 = 0; + ++v3; + } while (v3 < 26); + do { + v6 = random(150, 26); + } while (!slist[v6]); + object[v1]._oVar1 = v6; + if (random(150, 2)) { + object[v1]._oAnimFrame = 12; + object[v1]._oAnimLen = 22; + } } // 679660: using guessed type char gbMaxPlayers; // 442E0F: using guessed type int var_68[26]; void __fastcall AddBookcase(int i) { - int v1; // esi + int v1; // esi - v1 = i; - object[v1]._oRndSeed = GetRndSeed(); - object[v1]._oPreFlag = 1; + v1 = i; + object[v1]._oRndSeed = GetRndSeed(); + object[v1]._oPreFlag = 1; } void __fastcall AddPurifyingFountain(int i) { - char *v1; // eax + char *v1; // eax - v1 = &dObject[object[i]._ox][object[i]._oy]; - *(v1 - 1) = -1 - i; - *(v1 - 112) = -1 - i; - *(v1 - 113) = -1 - i; - object[i]._oRndSeed = GetRndSeed(); + v1 = &dObject[object[i]._ox][object[i]._oy]; + *(v1 - 1) = -1 - i; + *(v1 - 112) = -1 - i; + *(v1 - 113) = -1 - i; + object[i]._oRndSeed = GetRndSeed(); } void __fastcall AddArmorStand(int i) { - int v1; // eax + int v1; // eax - if (!armorFlag) { - v1 = i; - object[v1]._oSelFlag = 0; - object[v1]._oAnimFlag = 2; - } - object[i]._oRndSeed = GetRndSeed(); + if (!armorFlag) { + v1 = i; + object[v1]._oSelFlag = 0; + object[v1]._oAnimFlag = 2; + } + object[i]._oRndSeed = GetRndSeed(); } // 6AAA3C: using guessed type int armorFlag; void __fastcall AddDecap(int i) { - int v1; // esi - int v2; // eax - int v4; // eax + int v1; // esi + int v2; // eax + int v4; // eax - v1 = i; - v2 = GetRndSeed(); - object[v1]._oRndSeed = v2; - v4 = random(151, 8); - object[v1]._oPreFlag = 1; - object[v1]._oAnimFrame = v4 + 1; + v1 = i; + v2 = GetRndSeed(); + object[v1]._oRndSeed = v2; + v4 = random(151, 8); + object[v1]._oPreFlag = 1; + object[v1]._oAnimFrame = v4 + 1; } void __fastcall AddVilebook(int i) { - if (setlevel) { - if (setlvlnum == SL_VILEBETRAYER) - object[i]._oAnimFrame = 4; - } + if (setlevel) { + if (setlvlnum == SL_VILEBETRAYER) + object[i]._oAnimFrame = 4; + } } // 5CF31D: using guessed type char setlevel; void __fastcall AddMagicCircle(int i) { - int v1; // esi - int v2; // eax + int v1; // esi + int v2; // eax - v1 = i; - v2 = GetRndSeed(); - object[v1]._oVar6 = 0; - object[v1]._oRndSeed = v2; - object[v1]._oPreFlag = 1; - object[v1]._oVar5 = 1; + v1 = i; + v2 = GetRndSeed(); + object[v1]._oVar6 = 0; + object[v1]._oRndSeed = v2; + object[v1]._oPreFlag = 1; + object[v1]._oVar5 = 1; } void __fastcall AddBookstand(int i) { - object[i]._oRndSeed = GetRndSeed(); + object[i]._oRndSeed = GetRndSeed(); } void __fastcall AddPedistal(int i) { - int v1; // ecx - int v2; // eax - int v3; // edx - int v4; // esi - int v5; // esi - int v6; // eax + int v1; // ecx + int v2; // eax + int v3; // edx + int v4; // esi + int v5; // esi + int v6; // eax - v1 = i; - v2 = setpc_x; - v3 = setpc_y; - v4 = setpc_w; - object[v1]._oVar1 = setpc_x; - v5 = v2 + v4; - v6 = setpc_h; - object[v1]._oVar3 = v5; - object[v1]._oVar2 = v3; - object[v1]._oVar4 = v3 + v6; + v1 = i; + v2 = setpc_x; + v3 = setpc_y; + v4 = setpc_w; + object[v1]._oVar1 = setpc_x; + v5 = v2 + v4; + v6 = setpc_h; + object[v1]._oVar3 = v5; + object[v1]._oVar2 = v3; + object[v1]._oVar4 = v3 + v6; } // 5CF330: using guessed type int setpc_h; // 5CF334: using guessed type int setpc_w; void __fastcall AddStoryBook(int i) { - int bookframe; // eax - int v7; // eax + int bookframe; // eax + int v7; // eax - SetRndSeed(glSeedTbl[16]); - bookframe = random(0, 3); + SetRndSeed(glSeedTbl[16]); + bookframe = random(0, 3); - object[i]._oVar1 = bookframe; - if (currlevel == 4) - object[i]._oVar2 = StoryText[bookframe][0]; - if (currlevel == 8) - object[i]._oVar2 = StoryText[bookframe][1]; - if (currlevel == 12) - object[i]._oVar2 = StoryText[bookframe][2]; - object[i]._oVar3 = ((unsigned int)currlevel >> 2) + 3 * bookframe - 1; - v7 = 5 - 2 * bookframe; - object[i]._oAnimFrame = v7; - object[i]._oVar4 = v7 + 1; + object[i]._oVar1 = bookframe; + if (currlevel == 4) + object[i]._oVar2 = StoryText[bookframe][0]; + if (currlevel == 8) + object[i]._oVar2 = StoryText[bookframe][1]; + if (currlevel == 12) + object[i]._oVar2 = StoryText[bookframe][2]; + object[i]._oVar3 = ((unsigned int)currlevel >> 2) + 3 * bookframe - 1; + v7 = 5 - 2 * bookframe; + object[i]._oAnimFrame = v7; + object[i]._oVar4 = v7 + 1; } void __fastcall AddWeaponRack(int i) { - if (!weaponFlag) { - object[i]._oSelFlag = 0; - object[i]._oAnimFlag = 2; - } - object[i]._oRndSeed = GetRndSeed(); + if (!weaponFlag) { + object[i]._oSelFlag = 0; + object[i]._oAnimFlag = 2; + } + object[i]._oRndSeed = GetRndSeed(); } // 6AAA50: using guessed type int weaponFlag; void __fastcall AddTorturedBody(int i) { - object[i]._oRndSeed = GetRndSeed(); - object[i]._oPreFlag = 1; - object[i]._oAnimFrame = random(0, 4) + 1; + object[i]._oRndSeed = GetRndSeed(); + object[i]._oPreFlag = 1; + object[i]._oAnimFrame = random(0, 4) + 1; } void __fastcall GetRndObjLoc(int randarea, int *xx, int *yy) { - int *v3; // ebx - int v4; // eax - int v6; // eax - int v7; // esi - bool v8; // eax - int v9; // edi - int v10; // [esp+Ch] [ebp-Ch] - int v11; // [esp+10h] [ebp-8h] - int v12; // [esp+14h] [ebp-4h] + int *v3; // ebx + int v4; // eax + int v6; // eax + int v7; // esi + bool v8; // eax + int v9; // edi + int v10; // [esp+Ch] [ebp-Ch] + int v11; // [esp+10h] [ebp-8h] + int v12; // [esp+14h] [ebp-4h] - v3 = xx; - v12 = randarea; - if (randarea) { - v10 = 0; - while (1) { - LABEL_3: - if (++v10 > 1000 && v12 > 1) - --v12; - v4 = random(0, 112); - *v3 = v4; - v6 = random(0, 112); - v7 = v6; - *yy = v6; - v8 = 0; - v11 = 0; - if (v12 <= 0) - break; - while (!v8) { - v9 = 0; - do { - if (v8) - break; - v8 = RndLocOk(v11 + *v3, v7 + v9++) == 0; - } while (v9 < v12); - randarea = ++v11; - if (v11 >= v12) { - if (v8) - goto LABEL_3; - return; - } - } - } - } + v3 = xx; + v12 = randarea; + if (randarea) { + v10 = 0; + while (1) { + LABEL_3: + if (++v10 > 1000 && v12 > 1) + --v12; + v4 = random(0, 112); + *v3 = v4; + v6 = random(0, 112); + v7 = v6; + *yy = v6; + v8 = 0; + v11 = 0; + if (v12 <= 0) + break; + while (!v8) { + v9 = 0; + do { + if (v8) + break; + v8 = RndLocOk(v11 + *v3, v7 + v9++) == 0; + } while (v9 < v12); + randarea = ++v11; + if (v11 >= v12) { + if (v8) + goto LABEL_3; + return; + } + } + } + } } void __cdecl AddMushPatch() { - int i; // bl - int y; // [esp+0h] [ebp-8h] - int x; // [esp+4h] [ebp-4h] + int i; // bl + int y; // [esp+0h] [ebp-8h] + int x; // [esp+4h] [ebp-4h] - if (nobjects < MAXOBJECTS) { - i = objectavail[0]; - GetRndObjLoc(5, &x, &y); - dObject[x + 1][y + 1] = -1 - i; - dObject[x + 2][y + 1] = -1 - i; - dObject[x + 1][y + 2] = -1 - i; - AddObject(OBJ_MUSHPATCH, x + 2, y + 2); - } + if (nobjects < MAXOBJECTS) { + i = objectavail[0]; + GetRndObjLoc(5, &x, &y); + dObject[x + 1][y + 1] = -1 - i; + dObject[x + 2][y + 1] = -1 - i; + dObject[x + 1][y + 2] = -1 - i; + AddObject(OBJ_MUSHPATCH, x + 2, y + 2); + } } void __cdecl AddSlainHero() { - int x; // [esp+0h] [ebp-8h] - int y; // [esp+4h] [ebp-4h] + int x; // [esp+0h] [ebp-8h] + int y; // [esp+4h] [ebp-4h] - GetRndObjLoc(5, &x, &y); - AddObject(OBJ_SLAINHERO, x + 2, y + 2); + GetRndObjLoc(5, &x, &y); + AddObject(OBJ_SLAINHERO, x + 2, y + 2); } void __fastcall AddObject(int ot, int ox, int oy) { - int v3; // ebp - int v4; // esi - //unsigned int v5; // eax - int v6; // ebx - int v7; // ebx - int v8; // eax + int v3; // ebp + int v4; // esi + //unsigned int v5; // eax + int v6; // ebx + int v7; // ebx + int v8; // eax - v3 = ox; - v4 = ot; - if (nobjects < MAXOBJECTS) { - //v5 = 4 * nobjects; - v6 = objectavail[0]; - objectactive[nobjects] = objectavail[0]; - objectavail[0] = objectavail[-nobjects + 126]; /* double check, MAXOBJECTS */ - dObject[ox][oy] = v6 + 1; - SetupObject(v6, ox, oy, ot); - switch (v4) { - case OBJ_L1LIGHT: - case OBJ_SKFIRE: - case OBJ_CANDLE1: - case OBJ_CANDLE2: - case OBJ_BOOKCANDLE: - goto LABEL_31; - case OBJ_L1LDOOR: - case OBJ_L1RDOOR: - AddL1Door(v6, v3, oy, v4); - break; - case OBJ_CHEST1: - case OBJ_CHEST2: - case OBJ_CHEST3: - case OBJ_TCHEST1: - case OBJ_TCHEST2: - case OBJ_TCHEST3: - AddChest(v6, v4); - break; - case OBJ_BOOK2L: - AddVilebook(v6); - break; - case OBJ_BCROSS: - case OBJ_TBCROSS: - AddBookstand(v6); - LABEL_31: - AddObjLight(v6, 5); - break; - case OBJ_TNUDEM2: - AddTorturedBody(v6); - break; - case OBJ_BOOK2R: - AddSCambBook(v6); - break; - case OBJ_L2LDOOR: - case OBJ_L2RDOOR: - AddL2Door(v6, v3, oy, v4); - break; - case OBJ_TORCHL: - case OBJ_TORCHR: - case OBJ_TORCHL2: - case OBJ_TORCHR2: - AddObjLight(v6, 8); - break; - case OBJ_SARC: - AddSarc(v6); - break; - case OBJ_FLAMEHOLE: - AddFlameTrap(v6); - break; - case OBJ_FLAMELVR: - AddFlameLvr(v6); - break; - case OBJ_WATER: - object[v6]._oAnimFrame = 1; - break; - case OBJ_TRAPL: - case OBJ_TRAPR: - AddTrap(v6); - break; - case OBJ_BARREL: - case OBJ_BARRELEX: - AddBarrel(v6); - break; - case OBJ_SHRINEL: - case OBJ_SHRINER: - AddShrine(v6); - break; - case OBJ_SKELBOOK: - case OBJ_BOOKSTAND: - AddBookstand(v6); - break; - case OBJ_BOOKCASEL: - case OBJ_BOOKCASER: - AddBookcase(v6); - break; - case OBJ_BLOODFTN: - AddBookstand(v6); - break; - case OBJ_DECAP: - AddDecap(v6); - break; - case OBJ_PEDISTAL: - AddPedistal(v6); - break; - case OBJ_L3LDOOR: - case OBJ_L3RDOOR: - AddL3Door(v6, v3, oy, v4); - break; - case OBJ_PURIFYINGFTN: - AddPurifyingFountain(v6); - break; - case OBJ_ARMORSTAND: - case OBJ_WARARMOR: - AddArmorStand(v6); - break; - case OBJ_GOATSHRINE: - AddBookstand(v6); - break; - case OBJ_CAULDRON: - AddBookstand(v6); - break; - case OBJ_MURKYFTN: - AddPurifyingFountain(v6); - break; - case OBJ_TEARFTN: - AddBookstand(v6); - break; - case OBJ_MCIRCLE1: - case OBJ_MCIRCLE2: - AddMagicCircle(v6); - break; - case OBJ_STORYBOOK: - AddStoryBook(v6); - break; - case OBJ_STORYCANDLE: - AddObjLight(v6, 3); - break; - case OBJ_WARWEAP: - case OBJ_WEAPONRACK: - AddWeaponRack(v6); - break; - default: - break; - } - v7 = v6; - v8 = object[v7]._oAnimWidth - 64; - ++nobjects; - object[v7]._oAnimWidth2 = v8 >> 1; - } + v3 = ox; + v4 = ot; + if (nobjects < MAXOBJECTS) { + //v5 = 4 * nobjects; + v6 = objectavail[0]; + objectactive[nobjects] = objectavail[0]; + objectavail[0] = objectavail[-nobjects + 126]; /* double check, MAXOBJECTS */ + dObject[ox][oy] = v6 + 1; + SetupObject(v6, ox, oy, ot); + switch (v4) { + case OBJ_L1LIGHT: + case OBJ_SKFIRE: + case OBJ_CANDLE1: + case OBJ_CANDLE2: + case OBJ_BOOKCANDLE: + goto LABEL_31; + case OBJ_L1LDOOR: + case OBJ_L1RDOOR: + AddL1Door(v6, v3, oy, v4); + break; + case OBJ_CHEST1: + case OBJ_CHEST2: + case OBJ_CHEST3: + case OBJ_TCHEST1: + case OBJ_TCHEST2: + case OBJ_TCHEST3: + AddChest(v6, v4); + break; + case OBJ_BOOK2L: + AddVilebook(v6); + break; + case OBJ_BCROSS: + case OBJ_TBCROSS: + AddBookstand(v6); + LABEL_31: + AddObjLight(v6, 5); + break; + case OBJ_TNUDEM2: + AddTorturedBody(v6); + break; + case OBJ_BOOK2R: + AddSCambBook(v6); + break; + case OBJ_L2LDOOR: + case OBJ_L2RDOOR: + AddL2Door(v6, v3, oy, v4); + break; + case OBJ_TORCHL: + case OBJ_TORCHR: + case OBJ_TORCHL2: + case OBJ_TORCHR2: + AddObjLight(v6, 8); + break; + case OBJ_SARC: + AddSarc(v6); + break; + case OBJ_FLAMEHOLE: + AddFlameTrap(v6); + break; + case OBJ_FLAMELVR: + AddFlameLvr(v6); + break; + case OBJ_WATER: + object[v6]._oAnimFrame = 1; + break; + case OBJ_TRAPL: + case OBJ_TRAPR: + AddTrap(v6); + break; + case OBJ_BARREL: + case OBJ_BARRELEX: + AddBarrel(v6); + break; + case OBJ_SHRINEL: + case OBJ_SHRINER: + AddShrine(v6); + break; + case OBJ_SKELBOOK: + case OBJ_BOOKSTAND: + AddBookstand(v6); + break; + case OBJ_BOOKCASEL: + case OBJ_BOOKCASER: + AddBookcase(v6); + break; + case OBJ_BLOODFTN: + AddBookstand(v6); + break; + case OBJ_DECAP: + AddDecap(v6); + break; + case OBJ_PEDISTAL: + AddPedistal(v6); + break; + case OBJ_L3LDOOR: + case OBJ_L3RDOOR: + AddL3Door(v6, v3, oy, v4); + break; + case OBJ_PURIFYINGFTN: + AddPurifyingFountain(v6); + break; + case OBJ_ARMORSTAND: + case OBJ_WARARMOR: + AddArmorStand(v6); + break; + case OBJ_GOATSHRINE: + AddBookstand(v6); + break; + case OBJ_CAULDRON: + AddBookstand(v6); + break; + case OBJ_MURKYFTN: + AddPurifyingFountain(v6); + break; + case OBJ_TEARFTN: + AddBookstand(v6); + break; + case OBJ_MCIRCLE1: + case OBJ_MCIRCLE2: + AddMagicCircle(v6); + break; + case OBJ_STORYBOOK: + AddStoryBook(v6); + break; + case OBJ_STORYCANDLE: + AddObjLight(v6, 3); + break; + case OBJ_WARWEAP: + case OBJ_WEAPONRACK: + AddWeaponRack(v6); + break; + default: + break; + } + v7 = v6; + v8 = object[v7]._oAnimWidth - 64; + ++nobjects; + object[v7]._oAnimWidth2 = v8 >> 1; + } } void __fastcall Obj_Light(int i, int lr) { - int v2; // esi - int v3; // ebx - int *v4; // edi - int v5; // ST18_4 - int v6; // eax - int r; // [esp+Ch] [ebp-14h] - int x; // [esp+14h] [ebp-Ch] - int y; // [esp+18h] [ebp-8h] - signed int v10; // [esp+1Ch] [ebp-4h] + int v2; // esi + int v3; // ebx + int *v4; // edi + int v5; // ST18_4 + int v6; // eax + int r; // [esp+Ch] [ebp-14h] + int x; // [esp+14h] [ebp-Ch] + int y; // [esp+18h] [ebp-8h] + signed int v10; // [esp+1Ch] [ebp-4h] - v2 = i; - r = lr; - if (object[i]._oVar1 != -1) { - v10 = 0; - x = object[v2]._ox; - v3 = lr + 10; - y = object[v2]._oy; - if (lightflag) { - LABEL_15: - if (object[v2]._oVar1 == 1) - AddUnLight(object[v2]._olid); - object[v2]._oVar1 = 0; - } else { - v4 = &plr[0].plrlevel; - while (!v10) { - if (*((_BYTE *)v4 - 23)) { - if (currlevel == *v4) { - v5 = abs(v4[1] - x); - v6 = abs(v4[2] - y); - if (v5 < v3 && v6 < v3) - v10 = 1; - } - } - v4 += 5430; - if ((signed int)v4 >= (signed int)&plr[4].plrlevel) { - if (!v10) - goto LABEL_15; - break; - } - } - if (!object[v2]._oVar1) - object[v2]._olid = AddLight(x, y, r); - object[v2]._oVar1 = 1; - } - } + v2 = i; + r = lr; + if (object[i]._oVar1 != -1) { + v10 = 0; + x = object[v2]._ox; + v3 = lr + 10; + y = object[v2]._oy; + if (lightflag) { + LABEL_15: + if (object[v2]._oVar1 == 1) + AddUnLight(object[v2]._olid); + object[v2]._oVar1 = 0; + } else { + v4 = &plr[0].plrlevel; + while (!v10) { + if (*((_BYTE *)v4 - 23)) { + if (currlevel == *v4) { + v5 = abs(v4[1] - x); + v6 = abs(v4[2] - y); + if (v5 < v3 && v6 < v3) + v10 = 1; + } + } + v4 += 5430; + if ((signed int)v4 >= (signed int)&plr[4].plrlevel) { + if (!v10) + goto LABEL_15; + break; + } + } + if (!object[v2]._oVar1) + object[v2]._olid = AddLight(x, y, r); + object[v2]._oVar1 = 1; + } + } } // 646A28: using guessed type int lightflag; void __fastcall Obj_Circle(int i) { - int v1; // ecx - int v2; // edx - int v3; // esi - int v4; // eax - int v5; // ST1C_4 - int v6; // edx - int v7; // eax + int v1; // ecx + int v2; // edx + int v3; // esi + int v4; // eax + int v5; // ST1C_4 + int v6; // edx + int v7; // eax - v1 = i; - v2 = object[v1]._ox; - v3 = object[v1]._oy; - if (plr[myplr].WorldX != v2 || plr[myplr].WorldY != v3) { - v7 = object[v1]._otype; - if (v7 == OBJ_MCIRCLE1) - object[v1]._oAnimFrame = 1; - if (v7 == OBJ_MCIRCLE2) - object[v1]._oAnimFrame = 3; - object[v1]._oVar6 = 0; - } else { - v4 = object[v1]._otype; - if (v4 == OBJ_MCIRCLE1) - object[v1]._oAnimFrame = 2; - if (v4 == OBJ_MCIRCLE2) - object[v1]._oAnimFrame = 4; - if (v2 == 45) { - if (v3 == 47) { - object[v1]._oVar6 = 2; - return; - } - } else if (v2 == 26 && v3 == 46) { - object[v1]._oVar6 = 1; - return; - } - object[v1]._oVar6 = 0; - if (v2 == 35 && v3 == 36 && object[v1]._oVar5 == 3) { - v5 = object[v1]._oVar4; - v6 = object[v1]._oVar2; - object[v1]._oVar6 = 4; - ObjChangeMapResync(object[v1]._oVar1, v6, object[v1]._oVar3, v5); - if (quests[QTYPE_VB]._qactive == 2) - quests[QTYPE_VB]._qvar1 = 4; - AddMissile(plr[myplr].WorldX, plr[myplr].WorldY, 35, 46, plr[myplr]._pdir, 3, 0, myplr, 0, 0); - track_repeat_walk(0); - sgbMouseDown = 0; - ReleaseCapture(); - ClrPlrPath(myplr); - StartStand(myplr, 0); - } - } + v1 = i; + v2 = object[v1]._ox; + v3 = object[v1]._oy; + if (plr[myplr].WorldX != v2 || plr[myplr].WorldY != v3) { + v7 = object[v1]._otype; + if (v7 == OBJ_MCIRCLE1) + object[v1]._oAnimFrame = 1; + if (v7 == OBJ_MCIRCLE2) + object[v1]._oAnimFrame = 3; + object[v1]._oVar6 = 0; + } else { + v4 = object[v1]._otype; + if (v4 == OBJ_MCIRCLE1) + object[v1]._oAnimFrame = 2; + if (v4 == OBJ_MCIRCLE2) + object[v1]._oAnimFrame = 4; + if (v2 == 45) { + if (v3 == 47) { + object[v1]._oVar6 = 2; + return; + } + } else if (v2 == 26 && v3 == 46) { + object[v1]._oVar6 = 1; + return; + } + object[v1]._oVar6 = 0; + if (v2 == 35 && v3 == 36 && object[v1]._oVar5 == 3) { + v5 = object[v1]._oVar4; + v6 = object[v1]._oVar2; + object[v1]._oVar6 = 4; + ObjChangeMapResync(object[v1]._oVar1, v6, object[v1]._oVar3, v5); + if (quests[QTYPE_VB]._qactive == 2) + quests[QTYPE_VB]._qvar1 = 4; + AddMissile(plr[myplr].WorldX, plr[myplr].WorldY, 35, 46, plr[myplr]._pdir, 3, 0, myplr, 0, 0); + track_repeat_walk(0); + sgbMouseDown = 0; + ReleaseCapture(); + ClrPlrPath(myplr); + StartStand(myplr, 0); + } + } } // 525748: using guessed type char sgbMouseDown; void __fastcall Obj_StopAnim(int i) { - if (object[i]._oAnimFrame == object[i]._oAnimLen) { - object[i]._oAnimCnt = 0; - object[i]._oAnimDelay = 1000; - } + if (object[i]._oAnimFrame == object[i]._oAnimLen) { + object[i]._oAnimCnt = 0; + object[i]._oAnimDelay = 1000; + } } void __fastcall Obj_Door(int i) { - int dy; // edx - int dx; // eax + int dy; // edx + int dx; // eax - if (object[i]._oVar4) { - dy = object[i]._oy; - dx = object[i]._ox; - object[i]._oSelFlag = 2; - object[i]._oMissFlag = 1; - object[i]._oVar4 = ((dItem[dx][dy] == 0 - && dDead[dx][dy] == 0 - && dPlayer[dx][dy] == 0 - && dMonster[dx][dy] == 0) - == 0) - + 1; - } else { - object[i]._oMissFlag = 0; - object[i]._oSelFlag = 3; - } + if (object[i]._oVar4) { + dy = object[i]._oy; + dx = object[i]._ox; + object[i]._oSelFlag = 2; + object[i]._oMissFlag = 1; + object[i]._oVar4 = ((dItem[dx][dy] == 0 + && dDead[dx][dy] == 0 + && dPlayer[dx][dy] == 0 + && dMonster[dx][dy] == 0) + == 0) + + 1; + } else { + object[i]._oMissFlag = 0; + object[i]._oSelFlag = 3; + } } void __fastcall Obj_Sarc(int i) { - if (object[i]._oAnimFrame == object[i]._oAnimLen) - object[i]._oAnimFlag = 0; + if (object[i]._oAnimFrame == object[i]._oAnimLen) + object[i]._oAnimFlag = 0; } void __fastcall ActivateTrapLine(int ttype, int tid) { - int v2; // edi - int i; // ebp - int v4; // esi - int v5; // edx - int v6; // ecx - int v7; // [esp+8h] [ebp-4h] + int v2; // edi + int i; // ebp + int v4; // esi + int v5; // edx + int v6; // ecx + int v7; // [esp+8h] [ebp-4h] - v2 = 0; - v7 = tid; - for (i = ttype; v2 < nobjects; ++v2) { - v4 = objectactive[v2]; - if (object[v4]._otype == i && object[v4]._oVar1 == v7) { - v5 = object[v4]._oy; - v6 = object[v4]._ox; - object[v4]._oVar4 = 1; - object[v4]._oAnimFlag = 1; - object[v4]._oAnimDelay = 1; - object[v4]._olid = AddLight(v6, v5, 1); - } - } + v2 = 0; + v7 = tid; + for (i = ttype; v2 < nobjects; ++v2) { + v4 = objectactive[v2]; + if (object[v4]._otype == i && object[v4]._oVar1 == v7) { + v5 = object[v4]._oy; + v6 = object[v4]._ox; + object[v4]._oVar4 = 1; + object[v4]._oAnimFlag = 1; + object[v4]._oAnimDelay = 1; + object[v4]._olid = AddLight(v6, v5, 1); + } + } } void __fastcall Obj_FlameTrap(int i) { - int v1; // ecx - int *v2; // esi - int v3; // eax - int v4; // ecx - bool v5; // zf - bool v6; // sf - unsigned char v7; // of - int v8; // edx - int v9; // eax - signed int v10; // esi - int v11; // eax - _BYTE *v12; // edx - _DWORD *v13; // eax - int v14; // eax - _BYTE *v15; // edx - _DWORD *v16; // eax - int *v17; // eax + int v1; // ecx + int *v2; // esi + int v3; // eax + int v4; // ecx + bool v5; // zf + bool v6; // sf + unsigned char v7; // of + int v8; // edx + int v9; // eax + signed int v10; // esi + int v11; // eax + _BYTE *v12; // edx + _DWORD *v13; // eax + int v14; // eax + _BYTE *v15; // edx + _DWORD *v16; // eax + int *v17; // eax - v1 = i; - if (object[v1]._oVar2) { - v2 = &object[v1]._oVar4; - if (!object[v1]._oVar4) - return; - v3 = --object[v1]._oAnimFrame; - if (v3 == 1) { - v4 = object[v1]._olid; - *v2 = 0; - AddUnLight(v4); - return; - } - v7 = __OFSUB__(v3, 4); - v5 = v3 == 4; - v6 = v3 - 4 < 0; - goto LABEL_24; - } - if (object[v1]._oVar4) { - v17 = &object[v1]._oAnimFrame; - if (object[v1]._oAnimFrame == object[v1]._oAnimLen) - *v17 = 11; - v3 = *v17; - v7 = __OFSUB__(v3, 5); - v5 = v3 == 5; - v6 = v3 - 5 < 0; - LABEL_24: - if ((unsigned char)(v6 ^ v7) | v5) - ChangeLightRadius(object[v1]._olid, v3); - return; - } - v8 = object[v1]._oy; - v9 = object[v1]._ox; - v10 = 5; - if (object[v1]._oVar3 == 2) { - v11 = v8 + 112 * (v9 - 2); - v12 = (unsigned char *)dPlayer + v11; - v13 = (_DWORD *)((char *)dMonster + 4 * v11); - do { - if (*v12 || *v13) - object[v1]._oVar4 = 1; - v13 += 112; - v12 += 112; - --v10; - } while (v10); - } else { - v14 = v8 - 2 + 112 * v9; - v15 = (unsigned char *)dPlayer + v14; - v16 = (_DWORD *)((char *)dMonster + 4 * v14); - do { - if (*v15 || *v16) - object[v1]._oVar4 = 1; - ++v16; - ++v15; - --v10; - } while (v10); - } - if (object[v1]._oVar4) - ActivateTrapLine(object[v1]._otype, object[v1]._oVar1); + v1 = i; + if (object[v1]._oVar2) { + v2 = &object[v1]._oVar4; + if (!object[v1]._oVar4) + return; + v3 = --object[v1]._oAnimFrame; + if (v3 == 1) { + v4 = object[v1]._olid; + *v2 = 0; + AddUnLight(v4); + return; + } + v7 = __OFSUB__(v3, 4); + v5 = v3 == 4; + v6 = v3 - 4 < 0; + goto LABEL_24; + } + if (object[v1]._oVar4) { + v17 = &object[v1]._oAnimFrame; + if (object[v1]._oAnimFrame == object[v1]._oAnimLen) + *v17 = 11; + v3 = *v17; + v7 = __OFSUB__(v3, 5); + v5 = v3 == 5; + v6 = v3 - 5 < 0; + LABEL_24: + if ((unsigned char)(v6 ^ v7) | v5) + ChangeLightRadius(object[v1]._olid, v3); + return; + } + v8 = object[v1]._oy; + v9 = object[v1]._ox; + v10 = 5; + if (object[v1]._oVar3 == 2) { + v11 = v8 + 112 * (v9 - 2); + v12 = (unsigned char *)dPlayer + v11; + v13 = (_DWORD *)((char *)dMonster + 4 * v11); + do { + if (*v12 || *v13) + object[v1]._oVar4 = 1; + v13 += 112; + v12 += 112; + --v10; + } while (v10); + } else { + v14 = v8 - 2 + 112 * v9; + v15 = (unsigned char *)dPlayer + v14; + v16 = (_DWORD *)((char *)dMonster + 4 * v14); + do { + if (*v15 || *v16) + object[v1]._oVar4 = 1; + ++v16; + ++v15; + --v10; + } while (v10); + } + if (object[v1]._oVar4) + ActivateTrapLine(object[v1]._otype, object[v1]._oVar1); } void __fastcall Obj_Trap(int i) { - int edi1; // edi - int v2; // esi - int v3; // eax - int v4; // eax - int v5; // ebx - int v6; // ecx - int v7; // eax - int v8; // ecx - char *j; // edx - int v10; // eax - int v11; // [esp+8h] [ebp-1Ch] - int v12; // [esp+10h] [ebp-14h] - int sx; // [esp+14h] [ebp-10h] - int sy; // [esp+18h] [ebp-Ch] - int v15; // [esp+1Ch] [ebp-8h] - int v1; // [esp+20h] [ebp-4h] + int edi1; // edi + int v2; // esi + int v3; // eax + int v4; // eax + int v5; // ebx + int v6; // ecx + int v7; // eax + int v8; // ecx + char *j; // edx + int v10; // eax + int v11; // [esp+8h] [ebp-1Ch] + int v12; // [esp+10h] [ebp-14h] + int sx; // [esp+14h] [ebp-10h] + int sy; // [esp+18h] [ebp-Ch] + int v15; // [esp+1Ch] [ebp-8h] + int v1; // [esp+20h] [ebp-4h] - edi1 = i; - if (object[i]._oVar4) - return; - v2 = dObject[object[edi1]._oVar1][object[edi1]._oVar2] - 1; - v3 = object[v2]._otype; - if (v3 <= OBJ_L2RDOOR) { - if (v3 < OBJ_L2LDOOR) { - if (v3 <= 0) - return; - if (v3 > OBJ_L1RDOOR) { - if (v3 <= OBJ_SKFIRE || v3 > OBJ_CHEST3 && v3 != OBJ_SWITCHSKL) - return; - goto LABEL_9; - } - } - LABEL_17: - if (!object[v2]._oVar4) - return; - goto LABEL_10; - } - if (v3 != OBJ_SARC) { - if (v3 <= OBJ_PEDISTAL || v3 > OBJ_L3RDOOR) - return; - goto LABEL_17; - } + edi1 = i; + if (object[i]._oVar4) + return; + v2 = dObject[object[edi1]._oVar1][object[edi1]._oVar2] - 1; + v3 = object[v2]._otype; + if (v3 <= OBJ_L2RDOOR) { + if (v3 < OBJ_L2LDOOR) { + if (v3 <= 0) + return; + if (v3 > OBJ_L1RDOOR) { + if (v3 <= OBJ_SKFIRE || v3 > OBJ_CHEST3 && v3 != OBJ_SWITCHSKL) + return; + goto LABEL_9; + } + } + LABEL_17: + if (!object[v2]._oVar4) + return; + goto LABEL_10; + } + if (v3 != OBJ_SARC) { + if (v3 <= OBJ_PEDISTAL || v3 > OBJ_L3RDOOR) + return; + goto LABEL_17; + } LABEL_9: - if (object[v2]._oSelFlag) - return; + if (object[v2]._oSelFlag) + return; LABEL_10: - v4 = object[edi1]._ox; - object[edi1]._oVar4 = 1; - v5 = object[v2]._oy; - v6 = object[v2]._ox; - sx = v4; - sy = object[edi1]._oy; - v7 = v5 - 1; - v1 = object[v2]._ox; - v11 = v5 + 1; - if ((unsigned char)(__OFSUB__(v5 - 1, v5 + 1) ^ 1) | (v5 - 1 == v5 + 1)) { - v12 = v6 - 1; - v15 = v6 + 1; - do { - v8 = v12; - if (v12 <= v15) { - for (j = &dPlayer[v12][v7];; j += 112) { - if (*j) { - v1 = v8; - v5 = v7; - } - if (++v8 > v15) - break; - } - } - ++v7; - } while (v7 <= v11); - v6 = v1; - } - if (!deltaload) { - v10 = GetDirection(sx, sy, v6, v5); - AddMissile(sx, sy, v1, v5, v10, object[edi1]._oVar3, 1, -1, 0, 0); - PlaySfxLoc(IS_TRAP, object[v2]._ox, object[v2]._oy); - } - object[v2]._oTrapFlag = 0; + v4 = object[edi1]._ox; + object[edi1]._oVar4 = 1; + v5 = object[v2]._oy; + v6 = object[v2]._ox; + sx = v4; + sy = object[edi1]._oy; + v7 = v5 - 1; + v1 = object[v2]._ox; + v11 = v5 + 1; + if ((unsigned char)(__OFSUB__(v5 - 1, v5 + 1) ^ 1) | (v5 - 1 == v5 + 1)) { + v12 = v6 - 1; + v15 = v6 + 1; + do { + v8 = v12; + if (v12 <= v15) { + for (j = &dPlayer[v12][v7];; j += 112) { + if (*j) { + v1 = v8; + v5 = v7; + } + if (++v8 > v15) + break; + } + } + ++v7; + } while (v7 <= v11); + v6 = v1; + } + if (!deltaload) { + v10 = GetDirection(sx, sy, v6, v5); + AddMissile(sx, sy, v1, v5, v10, object[edi1]._oVar3, 1, -1, 0, 0); + PlaySfxLoc(IS_TRAP, object[v2]._ox, object[v2]._oy); + } + object[v2]._oTrapFlag = 0; } // 676190: using guessed type int deltaload; void __fastcall Obj_BCrossDamage(int i) { - int v1; // esi - bool v2; // zf - int v3; // ecx - int v4; // edx - int v6; // ecx - int damage[4]; // [esp+4h] [ebp-18h] - int v8; // [esp+18h] [ebp-4h] + int v1; // esi + bool v2; // zf + int v3; // ecx + int v4; // edx + int v6; // ecx + int damage[4]; // [esp+4h] [ebp-18h] + int v8; // [esp+18h] [ebp-4h] - v1 = myplr; - v8 = i; - v2 = plr[myplr]._pmode == PM_DEATH; - damage[0] = 6; - damage[1] = 8; - damage[2] = 10; - damage[3] = 12; - if (!v2) { - v3 = plr[v1]._pFireResist; - if (v3 > 0) - damage[leveltype - 1] -= v3 * damage[leveltype - 1] / 100; - if (plr[v1].WorldX == object[v8]._ox && plr[v1].WorldY == object[v8]._oy - 1) { - v4 = damage[leveltype - 1]; - plr[v1]._pHitPoints -= v4; - plr[v1]._pHPBase -= v4; - if (plr[v1]._pHitPoints >> 6 <= 0) { - SyncPlrKill(myplr, 0); - drawhpflag = TRUE; - return; - } - if (plr[myplr]._pClass == PC_WARRIOR) { - v6 = PS_WARR68; - } else if (plr[myplr]._pClass == PC_ROGUE) { - v6 = PS_ROGUE68; - } else if (plr[myplr]._pClass == PC_SORCERER) { - v6 = PS_MAGE68; - } - PlaySfxLoc(v6, plr[v1].WorldX, plr[v1].WorldY); - drawhpflag = TRUE; - } - } + v1 = myplr; + v8 = i; + v2 = plr[myplr]._pmode == PM_DEATH; + damage[0] = 6; + damage[1] = 8; + damage[2] = 10; + damage[3] = 12; + if (!v2) { + v3 = plr[v1]._pFireResist; + if (v3 > 0) + damage[leveltype - 1] -= v3 * damage[leveltype - 1] / 100; + if (plr[v1].WorldX == object[v8]._ox && plr[v1].WorldY == object[v8]._oy - 1) { + v4 = damage[leveltype - 1]; + plr[v1]._pHitPoints -= v4; + plr[v1]._pHPBase -= v4; + if (plr[v1]._pHitPoints >> 6 <= 0) { + SyncPlrKill(myplr, 0); + drawhpflag = TRUE; + return; + } + if (plr[myplr]._pClass == PC_WARRIOR) { + v6 = PS_WARR68; + } else if (plr[myplr]._pClass == PC_ROGUE) { + v6 = PS_ROGUE68; + } else if (plr[myplr]._pClass == PC_SORCERER) { + v6 = PS_MAGE68; + } + PlaySfxLoc(v6, plr[v1].WorldX, plr[v1].WorldY); + drawhpflag = TRUE; + } + } } void __cdecl ProcessObjects() { - int v0; // ebx - int v1; // edi - int v2; // esi - int v3; // eax - int *v4; // eax - int *v5; // eax - int v6; // edx + int v0; // ebx + int v1; // edi + int v2; // esi + int v3; // eax + int *v4; // eax + int *v5; // eax + int v6; // edx - v0 = 0; - if (nobjects > 0) { - while (1) { - v1 = objectactive[v0]; - v2 = objectactive[v0]; - v3 = object[v2]._otype; - if (v3 <= OBJ_SARC) - break; - if (v3 <= OBJ_L3RDOOR) { - if (v3 >= OBJ_L3LDOOR) - goto LABEL_32; - if (v3 == OBJ_FLAMEHOLE) { - Obj_FlameTrap(v1); - goto LABEL_40; - } - if (v3 <= OBJ_BOOKLVR) - goto LABEL_40; - if (v3 <= OBJ_TRAPR) { - Obj_Trap(v1); - goto LABEL_40; - } - if (v3 <= OBJ_WEAPRACK) - goto LABEL_40; - if (v3 <= OBJ_SHRINER) { - LABEL_29: - Obj_StopAnim(v1); - goto LABEL_40; - } - if (v3 != OBJ_BOOKCANDLE) - goto LABEL_40; - LABEL_28: - Obj_Light(v1, 5); - goto LABEL_40; - } - if (v3 < OBJ_MCIRCLE1) - goto LABEL_40; - if (v3 <= OBJ_MCIRCLE2) { - Obj_Circle(v1); - } else { - if (v3 != OBJ_STORYCANDLE) { - if (v3 != OBJ_TBCROSS) - goto LABEL_40; - goto LABEL_37; - } - Obj_Light(v1, 3); - } - LABEL_40: - if (object[v2]._oAnimFlag) { - v4 = &object[v2]._oAnimCnt; - ++*v4; - if (object[v2]._oAnimCnt >= object[v2]._oAnimDelay) { - *v4 = 0; - v5 = &object[v2]._oAnimFrame; - ++*v5; - if (object[v2]._oAnimFrame > object[v2]._oAnimLen) - *v5 = 1; - } - } - if (++v0 >= nobjects) - goto LABEL_45; - } - if (v3 == OBJ_SARC) { - Obj_Sarc(v1); - goto LABEL_40; - } - if (v3 > OBJ_CRUX3) { - if (v3 != OBJ_BCROSS) { - if (v3 <= OBJ_BOOK2R) - goto LABEL_40; - if (v3 > OBJ_L2RDOOR) { - if (v3 <= OBJ_TORCHR2) - Obj_Light(v1, 8); - goto LABEL_40; - } - LABEL_32: - Obj_Door(v1); - goto LABEL_40; - } - LABEL_37: - Obj_Light(v1, 10); - Obj_BCrossDamage(v1); - goto LABEL_40; - } - if (v3 >= OBJ_CRUX1) - goto LABEL_29; - if (!v3) { - Obj_Light(v1, 10); - goto LABEL_40; - } - if (v3 <= 0) - goto LABEL_40; - if (v3 <= OBJ_L1RDOOR) - goto LABEL_32; - if (v3 != OBJ_SKFIRE && v3 != OBJ_CANDLE2) - goto LABEL_40; - goto LABEL_28; - } + v0 = 0; + if (nobjects > 0) { + while (1) { + v1 = objectactive[v0]; + v2 = objectactive[v0]; + v3 = object[v2]._otype; + if (v3 <= OBJ_SARC) + break; + if (v3 <= OBJ_L3RDOOR) { + if (v3 >= OBJ_L3LDOOR) + goto LABEL_32; + if (v3 == OBJ_FLAMEHOLE) { + Obj_FlameTrap(v1); + goto LABEL_40; + } + if (v3 <= OBJ_BOOKLVR) + goto LABEL_40; + if (v3 <= OBJ_TRAPR) { + Obj_Trap(v1); + goto LABEL_40; + } + if (v3 <= OBJ_WEAPRACK) + goto LABEL_40; + if (v3 <= OBJ_SHRINER) { + LABEL_29: + Obj_StopAnim(v1); + goto LABEL_40; + } + if (v3 != OBJ_BOOKCANDLE) + goto LABEL_40; + LABEL_28: + Obj_Light(v1, 5); + goto LABEL_40; + } + if (v3 < OBJ_MCIRCLE1) + goto LABEL_40; + if (v3 <= OBJ_MCIRCLE2) { + Obj_Circle(v1); + } else { + if (v3 != OBJ_STORYCANDLE) { + if (v3 != OBJ_TBCROSS) + goto LABEL_40; + goto LABEL_37; + } + Obj_Light(v1, 3); + } + LABEL_40: + if (object[v2]._oAnimFlag) { + v4 = &object[v2]._oAnimCnt; + ++*v4; + if (object[v2]._oAnimCnt >= object[v2]._oAnimDelay) { + *v4 = 0; + v5 = &object[v2]._oAnimFrame; + ++*v5; + if (object[v2]._oAnimFrame > object[v2]._oAnimLen) + *v5 = 1; + } + } + if (++v0 >= nobjects) + goto LABEL_45; + } + if (v3 == OBJ_SARC) { + Obj_Sarc(v1); + goto LABEL_40; + } + if (v3 > OBJ_CRUX3) { + if (v3 != OBJ_BCROSS) { + if (v3 <= OBJ_BOOK2R) + goto LABEL_40; + if (v3 > OBJ_L2RDOOR) { + if (v3 <= OBJ_TORCHR2) + Obj_Light(v1, 8); + goto LABEL_40; + } + LABEL_32: + Obj_Door(v1); + goto LABEL_40; + } + LABEL_37: + Obj_Light(v1, 10); + Obj_BCrossDamage(v1); + goto LABEL_40; + } + if (v3 >= OBJ_CRUX1) + goto LABEL_29; + if (!v3) { + Obj_Light(v1, 10); + goto LABEL_40; + } + if (v3 <= 0) + goto LABEL_40; + if (v3 <= OBJ_L1RDOOR) + goto LABEL_32; + if (v3 != OBJ_SKFIRE && v3 != OBJ_CANDLE2) + goto LABEL_40; + goto LABEL_28; + } LABEL_45: - v6 = 0; - while (v6 < nobjects) { - if (object[objectactive[v6]]._oDelFlag) { - DeleteObject(objectactive[v6], v6); - v6 = 0; - } else { - ++v6; - } - } + v6 = 0; + while (v6 < nobjects) { + if (object[objectactive[v6]]._oDelFlag) { + DeleteObject(objectactive[v6], v6); + v6 = 0; + } else { + ++v6; + } + } } void __fastcall ObjSetMicro(int dx, int dy, int pn) { - int v3; // esi - char *v4; // eax - char *v5; // edx - signed int v6; // ecx - char *v7; // esi - signed int v8; // ecx + int v3; // esi + char *v4; // eax + char *v5; // edx + signed int v6; // ecx + char *v7; // esi + signed int v8; // ecx - dPiece[0][dy + 112 * dx] = pn; - v3 = pn - 1; - v4 = (char *)dpiece_defs_map_1 + 32 * gendung_get_dpiece_num_from_coord(dx, dy); - if (leveltype == DTYPE_HELL) { - v7 = (char *)pLevelPieces + 32 * v3; - v8 = 0; - do { - *(_WORD *)&v4[2 * v8] = *(_WORD *)&v7[2 * ((v8 & 1) - (v8 & 0xE)) + 28]; - ++v8; - } while (v8 < 16); - } else { - v5 = (char *)pLevelPieces + 20 * v3; - v6 = 0; - do { - *(_WORD *)&v4[2 * v6] = *(_WORD *)&v5[2 * ((v6 & 1) - (v6 & 0xE)) + 16]; - ++v6; - } while (v6 < 10); - } + dPiece[0][dy + 112 * dx] = pn; + v3 = pn - 1; + v4 = (char *)dpiece_defs_map_1 + 32 * gendung_get_dpiece_num_from_coord(dx, dy); + if (leveltype == DTYPE_HELL) { + v7 = (char *)pLevelPieces + 32 * v3; + v8 = 0; + do { + *(_WORD *)&v4[2 * v8] = *(_WORD *)&v7[2 * ((v8 & 1) - (v8 & 0xE)) + 28]; + ++v8; + } while (v8 < 16); + } else { + v5 = (char *)pLevelPieces + 20 * v3; + v6 = 0; + do { + *(_WORD *)&v4[2 * v6] = *(_WORD *)&v5[2 * ((v6 & 1) - (v6 & 0xE)) + 16]; + ++v6; + } while (v6 < 10); + } } void __fastcall objects_set_door_piece(int x, int y) { - int v2; // edi - int v3; // ST10_4 - int v4; // ST18_4 - short v5; // ST14_2 - short v6; // ST0C_2 + int v2; // edi + int v3; // ST10_4 + int v4; // ST18_4 + short v5; // ST14_2 + short v6; // ST0C_2 - v2 = y; - v3 = x; - v4 = dPiece[0][y + 112 * x] - 1; - v5 = *((_WORD *)pLevelPieces + 10 * (unsigned short)v4 + 8); - v6 = *((_WORD *)pLevelPieces + 10 * (unsigned short)v4 + 9); - dpiece_defs_map_1[0][0][16 * gendung_get_dpiece_num_from_coord(x, y)] = v5; - dpiece_defs_map_1[0][0][16 * gendung_get_dpiece_num_from_coord(v3, v2) + 1] = v6; + v2 = y; + v3 = x; + v4 = dPiece[0][y + 112 * x] - 1; + v5 = *((_WORD *)pLevelPieces + 10 * (unsigned short)v4 + 8); + v6 = *((_WORD *)pLevelPieces + 10 * (unsigned short)v4 + 9); + dpiece_defs_map_1[0][0][16 * gendung_get_dpiece_num_from_coord(x, y)] = v5; + dpiece_defs_map_1[0][0][16 * gendung_get_dpiece_num_from_coord(v3, v2) + 1] = v6; } void __fastcall ObjSetMini(int x, int y, int v) { - unsigned short *v3; // esi - unsigned short v4; // ax - int v5; // eax - int pn; // ST1C_4 - int v7; // ST18_4 - int v8; // ST14_4 - int v9; // ST10_4 - int v10; // esi - int v11; // edi + unsigned short *v3; // esi + unsigned short v4; // ax + int v5; // eax + int pn; // ST1C_4 + int v7; // ST18_4 + int v8; // ST14_4 + int v9; // ST10_4 + int v10; // esi + int v11; // edi - v3 = (unsigned short *)((char *)pMegaTiles + 8 * ((unsigned short)v - 1)); - v4 = *v3; - ++v3; - v5 = v4 + 1; - pn = v5; - _LOWORD(v5) = *v3; - ++v3; - v7 = ++v5; - _LOWORD(v5) = *v3; - v8 = ++v5; - _LOWORD(v5) = v3[1]; - v9 = v5 + 1; - v10 = 2 * x + 16; - v11 = 2 * y + 16; - ObjSetMicro(v10, v11, pn); - ObjSetMicro(v10 + 1, v11++, v7); - ObjSetMicro(v10, v11, v8); - ObjSetMicro(v10 + 1, v11, v9); + v3 = (unsigned short *)((char *)pMegaTiles + 8 * ((unsigned short)v - 1)); + v4 = *v3; + ++v3; + v5 = v4 + 1; + pn = v5; + _LOWORD(v5) = *v3; + ++v3; + v7 = ++v5; + _LOWORD(v5) = *v3; + v8 = ++v5; + _LOWORD(v5) = v3[1]; + v9 = v5 + 1; + v10 = 2 * x + 16; + v11 = 2 * y + 16; + ObjSetMicro(v10, v11, pn); + ObjSetMicro(v10 + 1, v11++, v7); + ObjSetMicro(v10, v11, v8); + ObjSetMicro(v10 + 1, v11, v9); } void __fastcall ObjL1Special(int x1, int y1, int x2, int y2) { - int i; // ebx - int v5; // edx - _BYTE *v6; // eax - int *v7; // edi - int v8; // edx - int v9; // esi + int i; // ebx + int v5; // edx + _BYTE *v6; // eax + int *v7; // edi + int v8; // edx + int v9; // esi - for (i = y1; i <= y2; ++i) { - if (x1 <= x2) { - v5 = 112 * x1 + i; - v6 = (unsigned char *)dArch + v5; - v7 = (int *)((char *)dPiece + 4 * v5); - v8 = x2 - x1 + 1; - do { - v9 = *v7; - *v6 = 0; - if (v9 == 12) - *v6 = 1; - if (v9 == 11) - *v6 = 2; - if (v9 == 71) - *v6 = 1; - if (v9 == 259) - *v6 = 5; - if (v9 == 249) - *v6 = 2; - if (v9 == 325) - *v6 = 2; - if (v9 == 321) - *v6 = 1; - if (v9 == 255) - *v6 = 4; - if (v9 == 211) - *v6 = 1; - if (v9 == 344) - *v6 = 2; - if (v9 == 341) - *v6 = 1; - if (v9 == 331) - *v6 = 2; - if (v9 == 418) - *v6 = 1; - if (v9 == 421) - *v6 = 2; - v7 += 112; - v6 += 112; - --v8; - } while (v8); - } - } + for (i = y1; i <= y2; ++i) { + if (x1 <= x2) { + v5 = 112 * x1 + i; + v6 = (unsigned char *)dArch + v5; + v7 = (int *)((char *)dPiece + 4 * v5); + v8 = x2 - x1 + 1; + do { + v9 = *v7; + *v6 = 0; + if (v9 == 12) + *v6 = 1; + if (v9 == 11) + *v6 = 2; + if (v9 == 71) + *v6 = 1; + if (v9 == 259) + *v6 = 5; + if (v9 == 249) + *v6 = 2; + if (v9 == 325) + *v6 = 2; + if (v9 == 321) + *v6 = 1; + if (v9 == 255) + *v6 = 4; + if (v9 == 211) + *v6 = 1; + if (v9 == 344) + *v6 = 2; + if (v9 == 341) + *v6 = 1; + if (v9 == 331) + *v6 = 2; + if (v9 == 418) + *v6 = 1; + if (v9 == 421) + *v6 = 2; + v7 += 112; + v6 += 112; + --v8; + } while (v8); + } + } } void __fastcall ObjL2Special(int x1, int y1, int x2, int y2) { - int v4; // edi - int v5; // esi - _BYTE *v6; // eax - int *v7; // ebx - int v8; // esi - int v9; // edx - int i; // edi - int v11; // eax - char *v12; // edx - int *v13; // esi - int v14; // eax - int v15; // ebx - int v16; // [esp+Ch] [ebp-4h] + int v4; // edi + int v5; // esi + _BYTE *v6; // eax + int *v7; // ebx + int v8; // esi + int v9; // edx + int i; // edi + int v11; // eax + char *v12; // edx + int *v13; // esi + int v14; // eax + int v15; // ebx + int v16; // [esp+Ch] [ebp-4h] - v4 = y1; - v16 = y1; - if (y1 <= y2) { - do { - if (x1 <= x2) { - v5 = 112 * x1 + v4; - v6 = (unsigned char *)dArch + v5; - v7 = (int *)((char *)dPiece + 4 * v5); - v8 = x2 - x1 + 1; - do { - v9 = *v7; - *v6 = 0; - if (v9 == 541) - *v6 = 5; - if (v9 == 178) - *v6 = 5; - if (v9 == 551) - *v6 = 5; - if (v9 == 542) - *v6 = 6; - if (v9 == 553) - *v6 = 6; - if (v9 == 13) - *v6 = 5; - if (v9 == 17) - *v6 = 6; - v7 += 112; - v6 += 112; - --v8; - } while (v8); - } - ++v4; - } while (v4 <= y2); - for (i = v16; i <= y2; ++i) { - if (x1 <= x2) { - v11 = i + 112 * x1; - v12 = &dArch[0][v11 + 2]; - v13 = (int *)((char *)dPiece + 4 * v11); - v14 = x2 - x1 + 1; - do { - v15 = *v13; - if (*v13 == 132) { - *(v12 - 1) = 2; - *v12 = 1; - } - if (v15 == 135 || v15 == 139) { - v12[110] = 3; - v12[222] = 4; - } - v13 += 112; - v12 += 112; - --v14; - } while (v14); - } - } - } + v4 = y1; + v16 = y1; + if (y1 <= y2) { + do { + if (x1 <= x2) { + v5 = 112 * x1 + v4; + v6 = (unsigned char *)dArch + v5; + v7 = (int *)((char *)dPiece + 4 * v5); + v8 = x2 - x1 + 1; + do { + v9 = *v7; + *v6 = 0; + if (v9 == 541) + *v6 = 5; + if (v9 == 178) + *v6 = 5; + if (v9 == 551) + *v6 = 5; + if (v9 == 542) + *v6 = 6; + if (v9 == 553) + *v6 = 6; + if (v9 == 13) + *v6 = 5; + if (v9 == 17) + *v6 = 6; + v7 += 112; + v6 += 112; + --v8; + } while (v8); + } + ++v4; + } while (v4 <= y2); + for (i = v16; i <= y2; ++i) { + if (x1 <= x2) { + v11 = i + 112 * x1; + v12 = &dArch[0][v11 + 2]; + v13 = (int *)((char *)dPiece + 4 * v11); + v14 = x2 - x1 + 1; + do { + v15 = *v13; + if (*v13 == 132) { + *(v12 - 1) = 2; + *v12 = 1; + } + if (v15 == 135 || v15 == 139) { + v12[110] = 3; + v12[222] = 4; + } + v13 += 112; + v12 += 112; + --v14; + } while (v14); + } + } + } } void __fastcall DoorSet(int oi, int dx, int dy) { - int v3; // esi - int v4; // ebp - int v5; // ebx - ObjectStruct *v6; // ebp + int v3; // esi + int v4; // ebp + int v5; // ebx + ObjectStruct *v6; // ebp - v3 = dx; - v4 = oi; - v5 = dPiece[0][dy + 112 * dx]; - if (v5 == 43) - ObjSetMicro(dx, dy, 392); - if (v5 == 45) - ObjSetMicro(v3, dy, 394); - if (v5 != 50) - goto LABEL_10; - v6 = &object[v4]; - if (v6->_otype == OBJ_L1LDOOR) - ObjSetMicro(v3, dy, 411); - if (v6->_otype == OBJ_L1RDOOR) { - ObjSetMicro(v3, dy, 412); - LABEL_10: - if (v5 == 54) - ObjSetMicro(v3, dy, 397); - if (v5 == 55) - ObjSetMicro(v3, dy, 398); - if (v5 == 61) - ObjSetMicro(v3, dy, 399); - if (v5 == 67) - ObjSetMicro(v3, dy, 400); - if (v5 == 68) - ObjSetMicro(v3, dy, 401); - if (v5 == 69) - ObjSetMicro(v3, dy, 403); - if (v5 == 70) - ObjSetMicro(v3, dy, 404); - if (v5 == 72) - ObjSetMicro(v3, dy, 406); - if (v5 == 212) - ObjSetMicro(v3, dy, 407); - if (v5 == 354) - ObjSetMicro(v3, dy, 409); - if (v5 == 355) - ObjSetMicro(v3, dy, 410); - if (v5 == 411) - ObjSetMicro(v3, dy, 396); - if (v5 == 412) - ObjSetMicro(v3, dy, 396); - } + v3 = dx; + v4 = oi; + v5 = dPiece[0][dy + 112 * dx]; + if (v5 == 43) + ObjSetMicro(dx, dy, 392); + if (v5 == 45) + ObjSetMicro(v3, dy, 394); + if (v5 != 50) + goto LABEL_10; + v6 = &object[v4]; + if (v6->_otype == OBJ_L1LDOOR) + ObjSetMicro(v3, dy, 411); + if (v6->_otype == OBJ_L1RDOOR) { + ObjSetMicro(v3, dy, 412); + LABEL_10: + if (v5 == 54) + ObjSetMicro(v3, dy, 397); + if (v5 == 55) + ObjSetMicro(v3, dy, 398); + if (v5 == 61) + ObjSetMicro(v3, dy, 399); + if (v5 == 67) + ObjSetMicro(v3, dy, 400); + if (v5 == 68) + ObjSetMicro(v3, dy, 401); + if (v5 == 69) + ObjSetMicro(v3, dy, 403); + if (v5 == 70) + ObjSetMicro(v3, dy, 404); + if (v5 == 72) + ObjSetMicro(v3, dy, 406); + if (v5 == 212) + ObjSetMicro(v3, dy, 407); + if (v5 == 354) + ObjSetMicro(v3, dy, 409); + if (v5 == 355) + ObjSetMicro(v3, dy, 410); + if (v5 == 411) + ObjSetMicro(v3, dy, 396); + if (v5 == 412) + ObjSetMicro(v3, dy, 396); + } } void __cdecl RedoPlayerVision() { - int *v0; // esi + int *v0; // esi - v0 = &plr[0].plrlevel; - do { - if (*((_BYTE *)v0 - 23)) { - if (currlevel == *v0) - ChangeVisionXY(v0[27], v0[1], v0[2]); - } - v0 += 5430; - } while ((signed int)v0 < (signed int)&plr[4].plrlevel); + v0 = &plr[0].plrlevel; + do { + if (*((_BYTE *)v0 - 23)) { + if (currlevel == *v0) + ChangeVisionXY(v0[27], v0[1], v0[2]); + } + v0 += 5430; + } while ((signed int)v0 < (signed int)&plr[4].plrlevel); } void __fastcall OperateL1RDoor(int pnum, int oi, unsigned char sendflag) { - int v3; // esi - int v4; // eax - int v5; // ebx - int v6; // edi - int v7; // ST04_4 - int v8; // [esp+Ch] [ebp-Ch] - int v9; // [esp+10h] [ebp-8h] - int param1; // [esp+14h] [ebp-4h] + int v3; // esi + int v4; // eax + int v5; // ebx + int v6; // edi + int v7; // ST04_4 + int v8; // [esp+Ch] [ebp-Ch] + int v9; // [esp+10h] [ebp-8h] + int param1; // [esp+14h] [ebp-4h] - v3 = oi; - param1 = oi; - v9 = pnum; - v4 = object[oi]._oVar4; - if (v4 != 2) { - v5 = object[v3]._ox; - v6 = object[v3]._oy; - if (v4) { - if (!deltaload) - PlaySfxLoc(IS_DOORCLOS, v5, object[v3]._oy); - v8 = v6 + 112 * v5; - if (dDead[0][v8] != 0 || dMonster[0][v8] != 0 || dItem[0][v8] != 0) { - object[v3]._oVar4 = 2; - return; - } - if (v9 == myplr && sendflag) - NetSendCmdParam1(TRUE, CMD_CLOSEDOOR, param1); - v7 = object[v3]._oVar1; - object[v3]._oVar4 = 0; - object[v3]._oSelFlag = 3; - ObjSetMicro(v5, v6, v7); - if (object[v3]._oVar2 == 50) { - if (dPiece[-1][v8] == 396) /* check *(_DWORD *)&dflags[28][4 * v8 + 32] == 396 ) */ - ObjSetMicro(v5 - 1, v6, 411); - else - ObjSetMicro(v5 - 1, v6, 50); - } else { - ObjSetMicro(v5 - 1, v6, object[v3]._oVar2); - } - object[v3]._oAnimFrame -= 2; - object[v3]._oPreFlag = 0; - } else { - if (pnum == myplr && sendflag) - NetSendCmdParam1(TRUE, CMD_OPENDOOR, oi); - if (!deltaload) - PlaySfxLoc(IS_DOOROPEN, object[v3]._ox, object[v3]._oy); - ObjSetMicro(v5, v6, 395); - dArch[v5][v6] = 8; - objects_set_door_piece(v5, v6 - 1); - object[v3]._oAnimFrame += 2; - object[v3]._oPreFlag = 1; - DoorSet(param1, v5 - 1, v6); - object[v3]._oVar4 = 1; - object[v3]._oSelFlag = 2; - } - RedoPlayerVision(); - return; - } - if (!deltaload) - PlaySfxLoc(IS_DOORCLOS, object[v3]._ox, object[v3]._oy); + v3 = oi; + param1 = oi; + v9 = pnum; + v4 = object[oi]._oVar4; + if (v4 != 2) { + v5 = object[v3]._ox; + v6 = object[v3]._oy; + if (v4) { + if (!deltaload) + PlaySfxLoc(IS_DOORCLOS, v5, object[v3]._oy); + v8 = v6 + 112 * v5; + if (dDead[0][v8] != 0 || dMonster[0][v8] != 0 || dItem[0][v8] != 0) { + object[v3]._oVar4 = 2; + return; + } + if (v9 == myplr && sendflag) + NetSendCmdParam1(TRUE, CMD_CLOSEDOOR, param1); + v7 = object[v3]._oVar1; + object[v3]._oVar4 = 0; + object[v3]._oSelFlag = 3; + ObjSetMicro(v5, v6, v7); + if (object[v3]._oVar2 == 50) { + if (dPiece[-1][v8] == 396) /* check *(_DWORD *)&dflags[28][4 * v8 + 32] == 396 ) */ + ObjSetMicro(v5 - 1, v6, 411); + else + ObjSetMicro(v5 - 1, v6, 50); + } else { + ObjSetMicro(v5 - 1, v6, object[v3]._oVar2); + } + object[v3]._oAnimFrame -= 2; + object[v3]._oPreFlag = 0; + } else { + if (pnum == myplr && sendflag) + NetSendCmdParam1(TRUE, CMD_OPENDOOR, oi); + if (!deltaload) + PlaySfxLoc(IS_DOOROPEN, object[v3]._ox, object[v3]._oy); + ObjSetMicro(v5, v6, 395); + dArch[v5][v6] = 8; + objects_set_door_piece(v5, v6 - 1); + object[v3]._oAnimFrame += 2; + object[v3]._oPreFlag = 1; + DoorSet(param1, v5 - 1, v6); + object[v3]._oVar4 = 1; + object[v3]._oSelFlag = 2; + } + RedoPlayerVision(); + return; + } + if (!deltaload) + PlaySfxLoc(IS_DOORCLOS, object[v3]._ox, object[v3]._oy); } // 676190: using guessed type int deltaload; void __fastcall OperateL1LDoor(int pnum, int oi, unsigned char sendflag) { - int v3; // esi - int v4; // eax - int v5; // ebx - int v6; // edi - int v7; // ST04_4 - int v8; // [esp+Ch] [ebp-Ch] - int v9; // [esp+10h] [ebp-8h] - int param1; // [esp+14h] [ebp-4h] + int v3; // esi + int v4; // eax + int v5; // ebx + int v6; // edi + int v7; // ST04_4 + int v8; // [esp+Ch] [ebp-Ch] + int v9; // [esp+10h] [ebp-8h] + int param1; // [esp+14h] [ebp-4h] - v3 = oi; - param1 = oi; - v9 = pnum; - v4 = object[oi]._oVar4; - if (v4 != 2) { - v5 = object[v3]._ox; - v6 = object[v3]._oy; - if (v4) { - if (!deltaload) - PlaySfxLoc(IS_DOORCLOS, v5, object[v3]._oy); - v8 = v6 + 112 * v5; - if (dDead[v5][v6] != 0 || dMonster[0][v8] != 0 || dItem[v5][v6] != 0) { - object[v3]._oVar4 = 2; - return; - } - if (v9 == myplr && sendflag) - NetSendCmdParam1(TRUE, CMD_CLOSEDOOR, param1); - v7 = object[v3]._oVar1; - object[v3]._oVar4 = 0; - object[v3]._oSelFlag = 3; - ObjSetMicro(v5, v6, v7); - if (object[v3]._oVar2 == 50) { - if (dPiece[0][v8 - 1] == 396) /* check *(_DWORD *)&dflags[39][v8 * 4 + 36] == 396 ) */ - ObjSetMicro(v5, v6 - 1, 412); - else - ObjSetMicro(v5, v6 - 1, 50); - } else { - ObjSetMicro(v5, v6 - 1, object[v3]._oVar2); - } - object[v3]._oAnimFrame -= 2; - object[v3]._oPreFlag = 0; - } else { - if (pnum == myplr && sendflag) - NetSendCmdParam1(TRUE, CMD_OPENDOOR, oi); - if (!deltaload) - PlaySfxLoc(IS_DOOROPEN, object[v3]._ox, object[v3]._oy); - if (object[v3]._oVar1 == 214) - ObjSetMicro(v5, v6, 408); - else - ObjSetMicro(v5, v6, 393); - dArch[v5][v6] = 7; - objects_set_door_piece(v5 - 1, v6); - object[v3]._oAnimFrame += 2; - object[v3]._oPreFlag = 1; - DoorSet(param1, v5, v6 - 1); - object[v3]._oVar4 = 1; - object[v3]._oSelFlag = 2; - } - RedoPlayerVision(); - return; - } - if (!deltaload) - PlaySfxLoc(IS_DOORCLOS, object[v3]._ox, object[v3]._oy); + v3 = oi; + param1 = oi; + v9 = pnum; + v4 = object[oi]._oVar4; + if (v4 != 2) { + v5 = object[v3]._ox; + v6 = object[v3]._oy; + if (v4) { + if (!deltaload) + PlaySfxLoc(IS_DOORCLOS, v5, object[v3]._oy); + v8 = v6 + 112 * v5; + if (dDead[v5][v6] != 0 || dMonster[0][v8] != 0 || dItem[v5][v6] != 0) { + object[v3]._oVar4 = 2; + return; + } + if (v9 == myplr && sendflag) + NetSendCmdParam1(TRUE, CMD_CLOSEDOOR, param1); + v7 = object[v3]._oVar1; + object[v3]._oVar4 = 0; + object[v3]._oSelFlag = 3; + ObjSetMicro(v5, v6, v7); + if (object[v3]._oVar2 == 50) { + if (dPiece[0][v8 - 1] == 396) /* check *(_DWORD *)&dflags[39][v8 * 4 + 36] == 396 ) */ + ObjSetMicro(v5, v6 - 1, 412); + else + ObjSetMicro(v5, v6 - 1, 50); + } else { + ObjSetMicro(v5, v6 - 1, object[v3]._oVar2); + } + object[v3]._oAnimFrame -= 2; + object[v3]._oPreFlag = 0; + } else { + if (pnum == myplr && sendflag) + NetSendCmdParam1(TRUE, CMD_OPENDOOR, oi); + if (!deltaload) + PlaySfxLoc(IS_DOOROPEN, object[v3]._ox, object[v3]._oy); + if (object[v3]._oVar1 == 214) + ObjSetMicro(v5, v6, 408); + else + ObjSetMicro(v5, v6, 393); + dArch[v5][v6] = 7; + objects_set_door_piece(v5 - 1, v6); + object[v3]._oAnimFrame += 2; + object[v3]._oPreFlag = 1; + DoorSet(param1, v5, v6 - 1); + object[v3]._oVar4 = 1; + object[v3]._oSelFlag = 2; + } + RedoPlayerVision(); + return; + } + if (!deltaload) + PlaySfxLoc(IS_DOORCLOS, object[v3]._ox, object[v3]._oy); } // 676190: using guessed type int deltaload; void __fastcall OperateL2RDoor(int pnum, int oi, unsigned char sendflag) { - int v3; // esi - int v4; // eax - int v5; // ebx - short param1; // [esp+Ch] [ebp-Ch] - int v7; // [esp+10h] [ebp-8h] - int v8; // [esp+14h] [ebp-4h] + int v3; // esi + int v4; // eax + int v5; // ebx + short param1; // [esp+Ch] [ebp-Ch] + int v7; // [esp+10h] [ebp-8h] + int v8; // [esp+14h] [ebp-4h] - v3 = oi; - param1 = oi; - v7 = pnum; - v4 = object[oi]._oVar4; - if (v4 != 2) { - v5 = object[v3]._oy; - v8 = object[v3]._ox; - if (v4) { - if (!deltaload) - PlaySfxLoc(IS_DOORCLOS, object[v3]._ox, v5); - if (dDead[v8][v5] != 0 || dMonster[0][v5 + 112 * v8] != 0 || dItem[v8][v5] != 0) { - object[v3]._oVar4 = 2; - return; - } - if (v7 == myplr && sendflag) - NetSendCmdParam1(TRUE, CMD_CLOSEDOOR, param1); - object[v3]._oVar4 = 0; - object[v3]._oSelFlag = 3; - ObjSetMicro(v8, v5, 540); - object[v3]._oAnimFrame -= 2; - object[v3]._oPreFlag = 0; - } else { - if (pnum == myplr && sendflag) - NetSendCmdParam1(TRUE, CMD_OPENDOOR, oi); - if (!deltaload) - PlaySfxLoc(IS_DOOROPEN, object[v3]._ox, object[v3]._oy); - ObjSetMicro(v8, v5, 17); - object[v3]._oAnimFrame += 2; - object[v3]._oPreFlag = 1; - object[v3]._oVar4 = 1; - object[v3]._oSelFlag = 2; - } - RedoPlayerVision(); - return; - } - if (!deltaload) - PlaySfxLoc(IS_DOORCLOS, object[v3]._ox, object[v3]._oy); + v3 = oi; + param1 = oi; + v7 = pnum; + v4 = object[oi]._oVar4; + if (v4 != 2) { + v5 = object[v3]._oy; + v8 = object[v3]._ox; + if (v4) { + if (!deltaload) + PlaySfxLoc(IS_DOORCLOS, object[v3]._ox, v5); + if (dDead[v8][v5] != 0 || dMonster[0][v5 + 112 * v8] != 0 || dItem[v8][v5] != 0) { + object[v3]._oVar4 = 2; + return; + } + if (v7 == myplr && sendflag) + NetSendCmdParam1(TRUE, CMD_CLOSEDOOR, param1); + object[v3]._oVar4 = 0; + object[v3]._oSelFlag = 3; + ObjSetMicro(v8, v5, 540); + object[v3]._oAnimFrame -= 2; + object[v3]._oPreFlag = 0; + } else { + if (pnum == myplr && sendflag) + NetSendCmdParam1(TRUE, CMD_OPENDOOR, oi); + if (!deltaload) + PlaySfxLoc(IS_DOOROPEN, object[v3]._ox, object[v3]._oy); + ObjSetMicro(v8, v5, 17); + object[v3]._oAnimFrame += 2; + object[v3]._oPreFlag = 1; + object[v3]._oVar4 = 1; + object[v3]._oSelFlag = 2; + } + RedoPlayerVision(); + return; + } + if (!deltaload) + PlaySfxLoc(IS_DOORCLOS, object[v3]._ox, object[v3]._oy); } // 676190: using guessed type int deltaload; void __fastcall OperateL2LDoor(int pnum, int oi, unsigned char sendflag) { - int v3; // esi - int v4; // eax - int v5; // ebx - short param1; // [esp+Ch] [ebp-Ch] - int v7; // [esp+10h] [ebp-8h] - int v8; // [esp+14h] [ebp-4h] + int v3; // esi + int v4; // eax + int v5; // ebx + short param1; // [esp+Ch] [ebp-Ch] + int v7; // [esp+10h] [ebp-8h] + int v8; // [esp+14h] [ebp-4h] - v3 = oi; - param1 = oi; - v7 = pnum; - v4 = object[oi]._oVar4; - if (v4 != 2) { - v5 = object[v3]._oy; - v8 = object[v3]._ox; - if (v4) { - if (!deltaload) - PlaySfxLoc(IS_DOORCLOS, object[v3]._ox, v5); - if (dDead[v8][v5] != 0 || dMonster[0][v5 + 112 * v8] != 0 || dItem[v8][v5] != 0) { - object[v3]._oVar4 = 2; - return; - } - if (v7 == myplr && sendflag) - NetSendCmdParam1(TRUE, CMD_CLOSEDOOR, param1); - object[v3]._oVar4 = 0; - object[v3]._oSelFlag = 3; - ObjSetMicro(v8, v5, 538); - object[v3]._oAnimFrame -= 2; - object[v3]._oPreFlag = 0; - } else { - if (pnum == myplr && sendflag) - NetSendCmdParam1(TRUE, CMD_OPENDOOR, oi); - if (!deltaload) - PlaySfxLoc(IS_DOOROPEN, object[v3]._ox, object[v3]._oy); - ObjSetMicro(v8, v5, 13); - object[v3]._oAnimFrame += 2; - object[v3]._oPreFlag = 1; - object[v3]._oVar4 = 1; - object[v3]._oSelFlag = 2; - } - RedoPlayerVision(); - return; - } - if (!deltaload) - PlaySfxLoc(IS_DOORCLOS, object[v3]._ox, object[v3]._oy); + v3 = oi; + param1 = oi; + v7 = pnum; + v4 = object[oi]._oVar4; + if (v4 != 2) { + v5 = object[v3]._oy; + v8 = object[v3]._ox; + if (v4) { + if (!deltaload) + PlaySfxLoc(IS_DOORCLOS, object[v3]._ox, v5); + if (dDead[v8][v5] != 0 || dMonster[0][v5 + 112 * v8] != 0 || dItem[v8][v5] != 0) { + object[v3]._oVar4 = 2; + return; + } + if (v7 == myplr && sendflag) + NetSendCmdParam1(TRUE, CMD_CLOSEDOOR, param1); + object[v3]._oVar4 = 0; + object[v3]._oSelFlag = 3; + ObjSetMicro(v8, v5, 538); + object[v3]._oAnimFrame -= 2; + object[v3]._oPreFlag = 0; + } else { + if (pnum == myplr && sendflag) + NetSendCmdParam1(TRUE, CMD_OPENDOOR, oi); + if (!deltaload) + PlaySfxLoc(IS_DOOROPEN, object[v3]._ox, object[v3]._oy); + ObjSetMicro(v8, v5, 13); + object[v3]._oAnimFrame += 2; + object[v3]._oPreFlag = 1; + object[v3]._oVar4 = 1; + object[v3]._oSelFlag = 2; + } + RedoPlayerVision(); + return; + } + if (!deltaload) + PlaySfxLoc(IS_DOORCLOS, object[v3]._ox, object[v3]._oy); } // 676190: using guessed type int deltaload; void __fastcall OperateL3RDoor(int pnum, int oi, unsigned char sendflag) { - int v3; // esi - int v4; // eax - int v5; // ebx - short param1; // [esp+Ch] [ebp-Ch] - int v7; // [esp+10h] [ebp-8h] - int v8; // [esp+14h] [ebp-4h] + int v3; // esi + int v4; // eax + int v5; // ebx + short param1; // [esp+Ch] [ebp-Ch] + int v7; // [esp+10h] [ebp-8h] + int v8; // [esp+14h] [ebp-4h] - v3 = oi; - param1 = oi; - v7 = pnum; - v4 = object[oi]._oVar4; - if (v4 != 2) { - v5 = object[v3]._oy; - v8 = object[v3]._ox; - if (v4) { - if (!deltaload) - PlaySfxLoc(IS_DOORCLOS, object[v3]._ox, v5); - if (dDead[v8][v5] != 0 || dMonster[0][v5 + 112 * v8] != 0 || dItem[v8][v5] != 0) { - object[v3]._oVar4 = 2; - return; - } - if (v7 == myplr && sendflag) - NetSendCmdParam1(TRUE, CMD_CLOSEDOOR, param1); - object[v3]._oVar4 = 0; - object[v3]._oSelFlag = 3; - ObjSetMicro(v8, v5, 534); - object[v3]._oAnimFrame -= 2; - object[v3]._oPreFlag = 0; - } else { - if (pnum == myplr && sendflag) - NetSendCmdParam1(TRUE, CMD_OPENDOOR, oi); - if (!deltaload) - PlaySfxLoc(IS_DOOROPEN, object[v3]._ox, object[v3]._oy); - ObjSetMicro(v8, v5, 541); - object[v3]._oAnimFrame += 2; - object[v3]._oPreFlag = 1; - object[v3]._oVar4 = 1; - object[v3]._oSelFlag = 2; - } - RedoPlayerVision(); - return; - } - if (!deltaload) - PlaySfxLoc(IS_DOORCLOS, object[v3]._ox, object[v3]._oy); + v3 = oi; + param1 = oi; + v7 = pnum; + v4 = object[oi]._oVar4; + if (v4 != 2) { + v5 = object[v3]._oy; + v8 = object[v3]._ox; + if (v4) { + if (!deltaload) + PlaySfxLoc(IS_DOORCLOS, object[v3]._ox, v5); + if (dDead[v8][v5] != 0 || dMonster[0][v5 + 112 * v8] != 0 || dItem[v8][v5] != 0) { + object[v3]._oVar4 = 2; + return; + } + if (v7 == myplr && sendflag) + NetSendCmdParam1(TRUE, CMD_CLOSEDOOR, param1); + object[v3]._oVar4 = 0; + object[v3]._oSelFlag = 3; + ObjSetMicro(v8, v5, 534); + object[v3]._oAnimFrame -= 2; + object[v3]._oPreFlag = 0; + } else { + if (pnum == myplr && sendflag) + NetSendCmdParam1(TRUE, CMD_OPENDOOR, oi); + if (!deltaload) + PlaySfxLoc(IS_DOOROPEN, object[v3]._ox, object[v3]._oy); + ObjSetMicro(v8, v5, 541); + object[v3]._oAnimFrame += 2; + object[v3]._oPreFlag = 1; + object[v3]._oVar4 = 1; + object[v3]._oSelFlag = 2; + } + RedoPlayerVision(); + return; + } + if (!deltaload) + PlaySfxLoc(IS_DOORCLOS, object[v3]._ox, object[v3]._oy); } // 676190: using guessed type int deltaload; void __fastcall OperateL3LDoor(int pnum, int oi, unsigned char sendflag) { - int v3; // esi - int v4; // eax - int v5; // ebx - short param1; // [esp+Ch] [ebp-Ch] - int v7; // [esp+10h] [ebp-8h] - int v8; // [esp+14h] [ebp-4h] + int v3; // esi + int v4; // eax + int v5; // ebx + short param1; // [esp+Ch] [ebp-Ch] + int v7; // [esp+10h] [ebp-8h] + int v8; // [esp+14h] [ebp-4h] - v3 = oi; - param1 = oi; - v7 = pnum; - v4 = object[oi]._oVar4; - if (v4 != 2) { - v5 = object[v3]._oy; - v8 = object[v3]._ox; - if (v4) { - if (!deltaload) - PlaySfxLoc(IS_DOORCLOS, object[v3]._ox, v5); - if (dDead[v8][v5] != 0 || dMonster[0][v5 + 112 * v8] != 0 || dItem[v8][v5] != 0) { - object[v3]._oVar4 = 2; - return; - } - if (v7 == myplr && sendflag) - NetSendCmdParam1(TRUE, CMD_CLOSEDOOR, param1); - object[v3]._oVar4 = 0; - object[v3]._oSelFlag = 3; - ObjSetMicro(v8, v5, 531); - object[v3]._oAnimFrame -= 2; - object[v3]._oPreFlag = 0; - } else { - if (pnum == myplr && sendflag) - NetSendCmdParam1(TRUE, CMD_OPENDOOR, oi); - if (!deltaload) - PlaySfxLoc(IS_DOOROPEN, object[v3]._ox, object[v3]._oy); - ObjSetMicro(v8, v5, 538); - object[v3]._oAnimFrame += 2; - object[v3]._oPreFlag = 1; - object[v3]._oVar4 = 1; - object[v3]._oSelFlag = 2; - } - RedoPlayerVision(); - return; - } - if (!deltaload) - PlaySfxLoc(IS_DOORCLOS, object[v3]._ox, object[v3]._oy); + v3 = oi; + param1 = oi; + v7 = pnum; + v4 = object[oi]._oVar4; + if (v4 != 2) { + v5 = object[v3]._oy; + v8 = object[v3]._ox; + if (v4) { + if (!deltaload) + PlaySfxLoc(IS_DOORCLOS, object[v3]._ox, v5); + if (dDead[v8][v5] != 0 || dMonster[0][v5 + 112 * v8] != 0 || dItem[v8][v5] != 0) { + object[v3]._oVar4 = 2; + return; + } + if (v7 == myplr && sendflag) + NetSendCmdParam1(TRUE, CMD_CLOSEDOOR, param1); + object[v3]._oVar4 = 0; + object[v3]._oSelFlag = 3; + ObjSetMicro(v8, v5, 531); + object[v3]._oAnimFrame -= 2; + object[v3]._oPreFlag = 0; + } else { + if (pnum == myplr && sendflag) + NetSendCmdParam1(TRUE, CMD_OPENDOOR, oi); + if (!deltaload) + PlaySfxLoc(IS_DOOROPEN, object[v3]._ox, object[v3]._oy); + ObjSetMicro(v8, v5, 538); + object[v3]._oAnimFrame += 2; + object[v3]._oPreFlag = 1; + object[v3]._oVar4 = 1; + object[v3]._oSelFlag = 2; + } + RedoPlayerVision(); + return; + } + if (!deltaload) + PlaySfxLoc(IS_DOORCLOS, object[v3]._ox, object[v3]._oy); } // 676190: using guessed type int deltaload; void __fastcall MonstCheckDoors(int m) { - int v1; // ecx - int v2; // eax - int v3; // ecx - int v4; // eax - char *v5; // ecx - int v6; // eax - int v7; // esi - int v8; // esi - int v9; // eax - int v10; // ebx - int v11; // eax - bool v12; // zf - bool v13; // sf - unsigned char v14; // of - int v15; // eax - int v16; // ebx - int v17; // eax - bool v18; // zf - bool v19; // sf - unsigned char v20; // of - int v21; // eax - int v22; // ebx - int v23; // eax - bool v24; // zf - bool v25; // sf - unsigned char v26; // of - int v27; // [esp+0h] [ebp-14h] - int v28; // [esp+4h] [ebp-10h] - int v29; // [esp+8h] [ebp-Ch] - int v30; // [esp+Ch] [ebp-8h] - int v31; // [esp+Ch] [ebp-8h] - int v32; // [esp+Ch] [ebp-8h] - int oi; // [esp+10h] [ebp-4h] + int v1; // ecx + int v2; // eax + int v3; // ecx + int v4; // eax + char *v5; // ecx + int v6; // eax + int v7; // esi + int v8; // esi + int v9; // eax + int v10; // ebx + int v11; // eax + bool v12; // zf + bool v13; // sf + unsigned char v14; // of + int v15; // eax + int v16; // ebx + int v17; // eax + bool v18; // zf + bool v19; // sf + unsigned char v20; // of + int v21; // eax + int v22; // ebx + int v23; // eax + bool v24; // zf + bool v25; // sf + unsigned char v26; // of + int v27; // [esp+0h] [ebp-14h] + int v28; // [esp+4h] [ebp-10h] + int v29; // [esp+8h] [ebp-Ch] + int v30; // [esp+Ch] [ebp-8h] + int v31; // [esp+Ch] [ebp-8h] + int v32; // [esp+Ch] [ebp-8h] + int oi; // [esp+10h] [ebp-4h] - v1 = m; - v2 = monster[v1]._mx; - v3 = monster[v1]._my; - v29 = v2; - v4 = v3 + 112 * v2; - v28 = v3; - v5 = (char *)dObject + v4; - if (dObject[-1][v4 - 1] - || *(v5 - 1) - || dObject[0][v4 + 111] - || *(v5 - 112) - || dObject[1][v4] - || dObject[-1][v4 + 1] - || dObject[0][v4 + 1] - || dObject[1][v4 + 1]) { - v6 = 0; - v27 = 0; - if (nobjects > 0) { - while (1) { - v7 = objectactive[v6]; - oi = v7; - v8 = v7; - v9 = object[v8]._otype; - if (v9 != 1 && v9 != OBJ_L1RDOOR || object[v8]._oVar4) - goto LABEL_21; - v10 = abs(object[v8]._ox - v29); - v11 = abs(object[v8]._oy - v28); - v14 = __OFSUB__(v10, 1); - v12 = v10 == 1; - v13 = v10 - 1 < 0; - v30 = v11; - if (v10 != 1) - goto LABEL_17; - if (v11 <= 1 && object[v8]._otype == 1) - break; - LABEL_18: - if (v30 == 1 && object[v8]._otype == OBJ_L1RDOOR) - OperateL1RDoor(myplr, oi, 1u); - LABEL_21: - v15 = object[v8]._otype; - if (v15 != OBJ_L2LDOOR && v15 != OBJ_L2RDOOR || object[v8]._oVar4) - goto LABEL_32; - v16 = abs(object[v8]._ox - v29); - v17 = abs(object[v8]._oy - v28); - v20 = __OFSUB__(v16, 1); - v18 = v16 == 1; - v19 = v16 - 1 < 0; - v31 = v17; - if (v16 != 1) - goto LABEL_28; - if (v17 <= 1 && object[v8]._otype == OBJ_L2LDOOR) { - OperateL2LDoor(myplr, oi, 1u); - v20 = 0; - v18 = 1; - v19 = 0; - LABEL_28: - if (!((unsigned char)(v19 ^ v20) | v18)) - goto LABEL_32; - } - if (v31 == 1 && object[v8]._otype == OBJ_L2RDOOR) - OperateL2RDoor(myplr, oi, 1u); - LABEL_32: - v21 = object[v8]._otype; - if (v21 != OBJ_L3LDOOR && v21 != OBJ_L3RDOOR || object[v8]._oVar4) - goto LABEL_43; - v22 = abs(object[v8]._ox - v29); - v23 = abs(object[v8]._oy - v28); - v26 = __OFSUB__(v22, 1); - v24 = v22 == 1; - v25 = v22 - 1 < 0; - v32 = v23; - if (v22 == 1) { - if (v23 > 1 || object[v8]._otype != OBJ_L3RDOOR) { - LABEL_40: - if (v32 == 1 && object[v8]._otype == OBJ_L3LDOOR) - OperateL3LDoor(myplr, oi, 1u); - goto LABEL_43; - } - OperateL3RDoor(myplr, oi, 1u); - v26 = 0; - v24 = 1; - v25 = 0; - } - if ((unsigned char)(v25 ^ v26) | v24) - goto LABEL_40; - LABEL_43: - v6 = v27++ + 1; - if (v27 >= nobjects) - return; - } - OperateL1LDoor(myplr, oi, 1u); - v14 = 0; - v12 = 1; - v13 = 0; - LABEL_17: - if (!((unsigned char)(v13 ^ v14) | v12)) - goto LABEL_21; - goto LABEL_18; - } - } + v1 = m; + v2 = monster[v1]._mx; + v3 = monster[v1]._my; + v29 = v2; + v4 = v3 + 112 * v2; + v28 = v3; + v5 = (char *)dObject + v4; + if (dObject[-1][v4 - 1] + || *(v5 - 1) + || dObject[0][v4 + 111] + || *(v5 - 112) + || dObject[1][v4] + || dObject[-1][v4 + 1] + || dObject[0][v4 + 1] + || dObject[1][v4 + 1]) { + v6 = 0; + v27 = 0; + if (nobjects > 0) { + while (1) { + v7 = objectactive[v6]; + oi = v7; + v8 = v7; + v9 = object[v8]._otype; + if (v9 != 1 && v9 != OBJ_L1RDOOR || object[v8]._oVar4) + goto LABEL_21; + v10 = abs(object[v8]._ox - v29); + v11 = abs(object[v8]._oy - v28); + v14 = __OFSUB__(v10, 1); + v12 = v10 == 1; + v13 = v10 - 1 < 0; + v30 = v11; + if (v10 != 1) + goto LABEL_17; + if (v11 <= 1 && object[v8]._otype == 1) + break; + LABEL_18: + if (v30 == 1 && object[v8]._otype == OBJ_L1RDOOR) + OperateL1RDoor(myplr, oi, 1u); + LABEL_21: + v15 = object[v8]._otype; + if (v15 != OBJ_L2LDOOR && v15 != OBJ_L2RDOOR || object[v8]._oVar4) + goto LABEL_32; + v16 = abs(object[v8]._ox - v29); + v17 = abs(object[v8]._oy - v28); + v20 = __OFSUB__(v16, 1); + v18 = v16 == 1; + v19 = v16 - 1 < 0; + v31 = v17; + if (v16 != 1) + goto LABEL_28; + if (v17 <= 1 && object[v8]._otype == OBJ_L2LDOOR) { + OperateL2LDoor(myplr, oi, 1u); + v20 = 0; + v18 = 1; + v19 = 0; + LABEL_28: + if (!((unsigned char)(v19 ^ v20) | v18)) + goto LABEL_32; + } + if (v31 == 1 && object[v8]._otype == OBJ_L2RDOOR) + OperateL2RDoor(myplr, oi, 1u); + LABEL_32: + v21 = object[v8]._otype; + if (v21 != OBJ_L3LDOOR && v21 != OBJ_L3RDOOR || object[v8]._oVar4) + goto LABEL_43; + v22 = abs(object[v8]._ox - v29); + v23 = abs(object[v8]._oy - v28); + v26 = __OFSUB__(v22, 1); + v24 = v22 == 1; + v25 = v22 - 1 < 0; + v32 = v23; + if (v22 == 1) { + if (v23 > 1 || object[v8]._otype != OBJ_L3RDOOR) { + LABEL_40: + if (v32 == 1 && object[v8]._otype == OBJ_L3LDOOR) + OperateL3LDoor(myplr, oi, 1u); + goto LABEL_43; + } + OperateL3RDoor(myplr, oi, 1u); + v26 = 0; + v24 = 1; + v25 = 0; + } + if ((unsigned char)(v25 ^ v26) | v24) + goto LABEL_40; + LABEL_43: + v6 = v27++ + 1; + if (v27 >= nobjects) + return; + } + OperateL1LDoor(myplr, oi, 1u); + v14 = 0; + v12 = 1; + v13 = 0; + LABEL_17: + if (!((unsigned char)(v13 ^ v14) | v12)) + goto LABEL_21; + goto LABEL_18; + } + } } void __fastcall ObjChangeMap(int x1, int y1, int x2, int y2) { - int v4; // ebx - int v5; // edi - int v6; // esi - //int v7; // ecx - int v8; // edi - int v9; // ebx - //int v10; // ecx - int v11; // [esp+Ch] [ebp-8h] - int a2; // [esp+10h] [ebp-4h] - int i; // [esp+1Ch] [ebp+8h] - int y_end; // [esp+20h] [ebp+Ch] + int v4; // ebx + int v5; // edi + int v6; // esi + //int v7; // ecx + int v8; // edi + int v9; // ebx + //int v10; // ecx + int v11; // [esp+Ch] [ebp-8h] + int a2; // [esp+10h] [ebp-4h] + int i; // [esp+1Ch] [ebp+8h] + int y_end; // [esp+20h] [ebp+Ch] - v4 = y1; - v5 = x2; - v6 = x1; - for (a2 = y1; a2 <= y2; ++a2) { - i = v6; - if (v6 <= v5) { - v11 = a2 + 40 * v6; - do { - ObjSetMini(i++, a2, (unsigned char)pdungeon[0][v11]); - dungeon[0][v11] = pdungeon[0][v11]; - v11 += 40; - } while (i <= v5); - } - } - if (leveltype == DTYPE_CATHEDRAL) { - ObjL1Special(2 * v6 + 16, 2 * v4 + 16, 2 * v5 + 17, 2 * y2 + 17); - AddL1Objs(2 * v6 + 16, 2 * v4 + 16, 2 * v5 + 17, 2 * y2 + 17); /* v7 */ - } - if (leveltype == DTYPE_CATACOMBS) { - v8 = 2 * v5 + 17; - v9 = 2 * v4 + 16; - y_end = 2 * y2 + 17; - ObjL2Special(2 * v6 + 16, v9, v8, y_end); - AddL2Objs(2 * v6 + 16, v9, v8, y_end); /* v10 */ - } + v4 = y1; + v5 = x2; + v6 = x1; + for (a2 = y1; a2 <= y2; ++a2) { + i = v6; + if (v6 <= v5) { + v11 = a2 + 40 * v6; + do { + ObjSetMini(i++, a2, (unsigned char)pdungeon[0][v11]); + dungeon[0][v11] = pdungeon[0][v11]; + v11 += 40; + } while (i <= v5); + } + } + if (leveltype == DTYPE_CATHEDRAL) { + ObjL1Special(2 * v6 + 16, 2 * v4 + 16, 2 * v5 + 17, 2 * y2 + 17); + AddL1Objs(2 * v6 + 16, 2 * v4 + 16, 2 * v5 + 17, 2 * y2 + 17); /* v7 */ + } + if (leveltype == DTYPE_CATACOMBS) { + v8 = 2 * v5 + 17; + v9 = 2 * v4 + 16; + y_end = 2 * y2 + 17; + ObjL2Special(2 * v6 + 16, v9, v8, y_end); + AddL2Objs(2 * v6 + 16, v9, v8, y_end); /* v10 */ + } } void __fastcall ObjChangeMapResync(int x1, int y1, int x2, int y2) { - int v4; // edi - int v5; // esi - int v6; // ebx - int v7; // edi - int v8; // [esp+Ch] [ebp-Ch] - int i; // [esp+10h] [ebp-8h] - int a2; // [esp+14h] [ebp-4h] + int v4; // edi + int v5; // esi + int v6; // ebx + int v7; // edi + int v8; // [esp+Ch] [ebp-Ch] + int i; // [esp+10h] [ebp-8h] + int a2; // [esp+14h] [ebp-4h] - v4 = y2; - v5 = y1; - v6 = x1; - v8 = y1; - for (a2 = y1; a2 <= v4; ++a2) { - i = v6; - if (v6 <= x2) { - v7 = a2 + 40 * v6; - do { - ObjSetMini(i++, a2, (unsigned char)pdungeon[0][v7]); - dungeon[0][v7] = pdungeon[0][v7]; - v7 += 40; - } while (i <= x2); - v4 = y2; - v5 = v8; - } - } - if (leveltype == DTYPE_CATHEDRAL) - ObjL1Special(2 * v6 + 16, 2 * v5 + 16, 2 * x2 + 17, 2 * v4 + 17); - if (leveltype == DTYPE_CATACOMBS) - ObjL2Special(2 * v6 + 16, 2 * v5 + 16, 2 * x2 + 17, 2 * v4 + 17); + v4 = y2; + v5 = y1; + v6 = x1; + v8 = y1; + for (a2 = y1; a2 <= v4; ++a2) { + i = v6; + if (v6 <= x2) { + v7 = a2 + 40 * v6; + do { + ObjSetMini(i++, a2, (unsigned char)pdungeon[0][v7]); + dungeon[0][v7] = pdungeon[0][v7]; + v7 += 40; + } while (i <= x2); + v4 = y2; + v5 = v8; + } + } + if (leveltype == DTYPE_CATHEDRAL) + ObjL1Special(2 * v6 + 16, 2 * v5 + 16, 2 * x2 + 17, 2 * v4 + 17); + if (leveltype == DTYPE_CATACOMBS) + ObjL2Special(2 * v6 + 16, 2 * v5 + 16, 2 * x2 + 17, 2 * v4 + 17); } void __fastcall OperateL1Door(int pnum, int i, unsigned char sendflag) { - int v3; // ebx - int v4; // edi - int v5; // esi - int v6; // ST1C_4 - int v7; // eax - bool v8; // zf - bool v9; // sf - unsigned char v10; // of - int v11; // [esp+Ch] [ebp-Ch] - int pnuma; // [esp+10h] [ebp-8h] + int v3; // ebx + int v4; // edi + int v5; // esi + int v6; // ST1C_4 + int v7; // eax + bool v8; // zf + bool v9; // sf + unsigned char v10; // of + int v11; // [esp+Ch] [ebp-Ch] + int pnuma; // [esp+10h] [ebp-8h] - v3 = i; - v4 = i; - pnuma = pnum; - v5 = pnum; - v6 = abs(object[i]._ox - plr[pnum].WorldX); - v7 = abs(object[v4]._oy - plr[v5].WorldY); - v10 = __OFSUB__(v6, 1); - v8 = v6 == 1; - v9 = v6 - 1 < 0; - v11 = v7; - if (v6 != 1) { - LABEL_5: - if (!((unsigned char)(v9 ^ v10) | v8)) - return; - goto LABEL_6; - } - if (v7 <= 1 && object[v4]._otype == 1) { - OperateL1LDoor(pnuma, v3, sendflag); - v10 = 0; - v8 = 1; - v9 = 0; - goto LABEL_5; - } + v3 = i; + v4 = i; + pnuma = pnum; + v5 = pnum; + v6 = abs(object[i]._ox - plr[pnum].WorldX); + v7 = abs(object[v4]._oy - plr[v5].WorldY); + v10 = __OFSUB__(v6, 1); + v8 = v6 == 1; + v9 = v6 - 1 < 0; + v11 = v7; + if (v6 != 1) { + LABEL_5: + if (!((unsigned char)(v9 ^ v10) | v8)) + return; + goto LABEL_6; + } + if (v7 <= 1 && object[v4]._otype == 1) { + OperateL1LDoor(pnuma, v3, sendflag); + v10 = 0; + v8 = 1; + v9 = 0; + goto LABEL_5; + } LABEL_6: - if (v11 == 1 && object[v4]._otype == OBJ_L1RDOOR) - OperateL1RDoor(pnuma, v3, sendflag); + if (v11 == 1 && object[v4]._otype == OBJ_L1RDOOR) + OperateL1RDoor(pnuma, v3, sendflag); } void __fastcall OperateLever(int pnum, int i) { - int v2; // esi - int *v3; // edi - signed int v4; // edi - int v5; // ecx - int v6; // eax - short param1; // [esp+8h] [ebp-8h] - int v8; // [esp+Ch] [ebp-4h] + int v2; // esi + int *v3; // edi + signed int v4; // edi + int v5; // ecx + int v6; // eax + short param1; // [esp+8h] [ebp-8h] + int v8; // [esp+Ch] [ebp-4h] - param1 = i; - v2 = i; - v3 = (int *)&object[i]._oSelFlag; - v8 = pnum; - if (*(_BYTE *)v3) { - if (!deltaload) - PlaySfxLoc(IS_LEVER, object[v2]._ox, object[v2]._oy); - *(_BYTE *)v3 = 0; - ++object[v2]._oAnimFrame; - v4 = 1; - if (currlevel != 16) - goto LABEL_17; - v5 = 0; - if (nobjects <= 0) - goto LABEL_17; - do { - v6 = objectactive[v5]; - if (object[v6]._otype == OBJ_SWITCHSKL - && object[v2]._oVar8 == object[v6]._oVar8 - && object[v6]._oSelFlag) { - v4 = 0; - } - ++v5; - } while (v5 < nobjects); - if (v4) - LABEL_17: - ObjChangeMap(object[v2]._oVar1, object[v2]._oVar2, object[v2]._oVar3, object[v2]._oVar4); - if (v8 == myplr) - NetSendCmdParam1(FALSE, CMD_OPERATEOBJ, param1); - } + param1 = i; + v2 = i; + v3 = (int *)&object[i]._oSelFlag; + v8 = pnum; + if (*(_BYTE *)v3) { + if (!deltaload) + PlaySfxLoc(IS_LEVER, object[v2]._ox, object[v2]._oy); + *(_BYTE *)v3 = 0; + ++object[v2]._oAnimFrame; + v4 = 1; + if (currlevel != 16) + goto LABEL_17; + v5 = 0; + if (nobjects <= 0) + goto LABEL_17; + do { + v6 = objectactive[v5]; + if (object[v6]._otype == OBJ_SWITCHSKL + && object[v2]._oVar8 == object[v6]._oVar8 + && object[v6]._oSelFlag) { + v4 = 0; + } + ++v5; + } while (v5 < nobjects); + if (v4) + LABEL_17: + ObjChangeMap(object[v2]._oVar1, object[v2]._oVar2, object[v2]._oVar3, object[v2]._oVar4); + if (v8 == myplr) + NetSendCmdParam1(FALSE, CMD_OPERATEOBJ, param1); + } } // 676190: using guessed type int deltaload; void __fastcall OperateBook(int pnum, int i) { - signed int v4; // ecx - int v5; // eax - bool v6; // zf - int j; // esi - signed int v11; // [esp+10h] [ebp-10h] - signed int v1; // [esp+14h] [ebp-Ch] - signed int v2; // [esp+18h] [ebp-8h] - int v14; // [esp+1Ch] [ebp-4h] + signed int v4; // ecx + int v5; // eax + bool v6; // zf + int j; // esi + signed int v11; // [esp+10h] [ebp-10h] + signed int v1; // [esp+14h] [ebp-Ch] + signed int v2; // [esp+18h] [ebp-8h] + int v14; // [esp+1Ch] [ebp-4h] - if (!object[i]._oSelFlag) - return; - if (!setlevel || setlvlnum != SL_VILEBETRAYER) - goto LABEL_17; - v4 = 0; - v11 = 0; - v14 = 0; - if (nobjects > 0) { - while (1) { - v5 = objectactive[v14]; - if (object[v5]._otype == OBJ_MCIRCLE2) { - if (object[v5]._oVar6 == 1) { - v1 = 27; - v2 = 29; - object[v5]._oVar6 = 4; - v4 = 1; - } - if (object[v5]._oVar6 == 2) { - v1 = 43; - v2 = 29; - object[v5]._oVar6 = 4; - v4 = 1; - } - } - if (v4) { - ++object[dObject[35][36] - 1]._oVar5; // ++objectavail[30 * dObject[35][36] + 123]; /* fix */ - AddMissile(plr[pnum].WorldX, plr[pnum].WorldY, v1, v2, plr[pnum]._pdir, MIS_RNDTELEPORT, 0, pnum, 0, 0); - v11 = 1; - v4 = 0; - } - if (++v14 >= nobjects) - break; - } - if (v11) { - LABEL_17: - ++object[i]._oAnimFrame; - v6 = setlevel == 0; - object[i]._oSelFlag = 0; - if (!v6) { - if (setlvlnum == SL_BONECHAMB) { - plr[myplr]._pMemSpells |= (__int64)1 << (SPL_GUARDIAN - 1); - if (plr[pnum]._pSplLvl[SPL_GUARDIAN] < 15) - plr[myplr]._pSplLvl[SPL_GUARDIAN]++; - quests[QTYPE_BONE]._qactive = 3; - if (!deltaload) - PlaySfxLoc(IS_QUESTDN, object[i]._ox, object[i]._oy); - InitDiabloMsg(EMSG_BONECHAMB); - AddMissile( - plr[myplr].WorldX, - plr[myplr].WorldY, - object[i]._ox - 2, - object[i]._oy - 4, - plr[myplr]._pdir, - MIS_GUARDIAN, - 0, - myplr, - 0, - 0); - } - if (setlevel) { - if (setlvlnum == SL_VILEBETRAYER) { - ObjChangeMapResync( - object[i]._oVar1, - object[i]._oVar2, - object[i]._oVar3, - object[i]._oVar4); - for (j = 0; j < nobjects; ++j) - SyncObjectAnim(objectactive[j]); - } - } - } - return; - } - } + if (!object[i]._oSelFlag) + return; + if (!setlevel || setlvlnum != SL_VILEBETRAYER) + goto LABEL_17; + v4 = 0; + v11 = 0; + v14 = 0; + if (nobjects > 0) { + while (1) { + v5 = objectactive[v14]; + if (object[v5]._otype == OBJ_MCIRCLE2) { + if (object[v5]._oVar6 == 1) { + v1 = 27; + v2 = 29; + object[v5]._oVar6 = 4; + v4 = 1; + } + if (object[v5]._oVar6 == 2) { + v1 = 43; + v2 = 29; + object[v5]._oVar6 = 4; + v4 = 1; + } + } + if (v4) { + ++object[dObject[35][36] - 1]._oVar5; // ++objectavail[30 * dObject[35][36] + 123]; /* fix */ + AddMissile(plr[pnum].WorldX, plr[pnum].WorldY, v1, v2, plr[pnum]._pdir, MIS_RNDTELEPORT, 0, pnum, 0, 0); + v11 = 1; + v4 = 0; + } + if (++v14 >= nobjects) + break; + } + if (v11) { + LABEL_17: + ++object[i]._oAnimFrame; + v6 = setlevel == 0; + object[i]._oSelFlag = 0; + if (!v6) { + if (setlvlnum == SL_BONECHAMB) { + plr[myplr]._pMemSpells |= (__int64)1 << (SPL_GUARDIAN - 1); + if (plr[pnum]._pSplLvl[SPL_GUARDIAN] < 15) + plr[myplr]._pSplLvl[SPL_GUARDIAN]++; + quests[QTYPE_BONE]._qactive = 3; + if (!deltaload) + PlaySfxLoc(IS_QUESTDN, object[i]._ox, object[i]._oy); + InitDiabloMsg(EMSG_BONECHAMB); + AddMissile( + plr[myplr].WorldX, + plr[myplr].WorldY, + object[i]._ox - 2, + object[i]._oy - 4, + plr[myplr]._pdir, + MIS_GUARDIAN, + 0, + myplr, + 0, + 0); + } + if (setlevel) { + if (setlvlnum == SL_VILEBETRAYER) { + ObjChangeMapResync( + object[i]._oVar1, + object[i]._oVar2, + object[i]._oVar3, + object[i]._oVar4); + for (j = 0; j < nobjects; ++j) + SyncObjectAnim(objectactive[j]); + } + } + } + return; + } + } } // 5CF31D: using guessed type char setlevel; // 676190: using guessed type int deltaload; void __fastcall OperateBookLever(int pnum, int i) { - int v2; // esi - int v3; // edi - int v4; // ebp - int v5; // edx - int v6; // eax - int v7; // ST0C_4 - int v8; // edx - char v9; // bl - int v10; // ST08_4 - int v11; // ecx - int v12; // ecx - int v13; // [esp+Ch] [ebp-8h] - short param1; // [esp+10h] [ebp-4h] + int v2; // esi + int v3; // edi + int v4; // ebp + int v5; // edx + int v6; // eax + int v7; // ST0C_4 + int v8; // edx + char v9; // bl + int v10; // ST08_4 + int v11; // ecx + int v12; // ecx + int v13; // [esp+Ch] [ebp-8h] + short param1; // [esp+10h] [ebp-4h] - param1 = i; - v2 = i; - v13 = pnum; - v3 = 2 * setpc_x + 16; - v4 = 2 * setpc_y + 16; - if (object[i]._oSelFlag && !qtextflag) { - v5 = object[v2]._otype; - if (v5 == OBJ_BLINDBOOK && !quests[QTYPE_BLIND]._qvar1) { - quests[QTYPE_BLIND]._qactive = 2; - quests[QTYPE_BLIND]._qlog = 1; - quests[QTYPE_BLIND]._qvar1 = 1; - } - if (v5 == OBJ_BLOODBOOK && !quests[QTYPE_BLOOD]._qvar1) { - quests[QTYPE_BLOOD]._qactive = 2; - quests[QTYPE_BLOOD]._qlog = 1; - quests[QTYPE_BLOOD]._qvar1 = 1; - SpawnQuestItem(21, 2 * setpc_x + 19, 2 * setpc_y + 26, 0, 1); - SpawnQuestItem(21, 2 * setpc_x + 31, 2 * setpc_y + 26, 0, 1); - SpawnQuestItem(21, 2 * setpc_x + 25, 2 * setpc_y + 33, 0, 1); - } - v6 = object[v2]._otype; - if (v6 == OBJ_STEELTOME && !quests[QTYPE_WARLRD]._qvar1) { - quests[QTYPE_WARLRD]._qactive = 2; - quests[QTYPE_WARLRD]._qlog = 1; - quests[QTYPE_WARLRD]._qvar1 = 1; - } - if (object[v2]._oAnimFrame != object[v2]._oVar6) { - if (v6 != OBJ_BLOODBOOK) - ObjChangeMap(object[v2]._oVar1, object[v2]._oVar2, object[v2]._oVar3, object[v2]._oVar4); - if (object[v2]._otype == OBJ_BLINDBOOK) { - CreateItem(3, v3 + 5, v4 + 5); - v7 = object[v2]._oVar4; - v8 = object[v2]._oVar2; - v9 = TransVal; - v10 = object[v2]._oVar3; - v11 = object[v2]._oVar1; - TransVal = 9; - DRLG_MRectTrans(v11, v8, v10, v7); - TransVal = v9; - } - } - v12 = object[v2]._oVar7; - object[v2]._oAnimFrame = object[v2]._oVar6; - InitQTextMsg(v12); - if (v13 == myplr) - NetSendCmdParam1(FALSE, CMD_OPERATEOBJ, param1); - } + param1 = i; + v2 = i; + v13 = pnum; + v3 = 2 * setpc_x + 16; + v4 = 2 * setpc_y + 16; + if (object[i]._oSelFlag && !qtextflag) { + v5 = object[v2]._otype; + if (v5 == OBJ_BLINDBOOK && !quests[QTYPE_BLIND]._qvar1) { + quests[QTYPE_BLIND]._qactive = 2; + quests[QTYPE_BLIND]._qlog = 1; + quests[QTYPE_BLIND]._qvar1 = 1; + } + if (v5 == OBJ_BLOODBOOK && !quests[QTYPE_BLOOD]._qvar1) { + quests[QTYPE_BLOOD]._qactive = 2; + quests[QTYPE_BLOOD]._qlog = 1; + quests[QTYPE_BLOOD]._qvar1 = 1; + SpawnQuestItem(21, 2 * setpc_x + 19, 2 * setpc_y + 26, 0, 1); + SpawnQuestItem(21, 2 * setpc_x + 31, 2 * setpc_y + 26, 0, 1); + SpawnQuestItem(21, 2 * setpc_x + 25, 2 * setpc_y + 33, 0, 1); + } + v6 = object[v2]._otype; + if (v6 == OBJ_STEELTOME && !quests[QTYPE_WARLRD]._qvar1) { + quests[QTYPE_WARLRD]._qactive = 2; + quests[QTYPE_WARLRD]._qlog = 1; + quests[QTYPE_WARLRD]._qvar1 = 1; + } + if (object[v2]._oAnimFrame != object[v2]._oVar6) { + if (v6 != OBJ_BLOODBOOK) + ObjChangeMap(object[v2]._oVar1, object[v2]._oVar2, object[v2]._oVar3, object[v2]._oVar4); + if (object[v2]._otype == OBJ_BLINDBOOK) { + CreateItem(3, v3 + 5, v4 + 5); + v7 = object[v2]._oVar4; + v8 = object[v2]._oVar2; + v9 = TransVal; + v10 = object[v2]._oVar3; + v11 = object[v2]._oVar1; + TransVal = 9; + DRLG_MRectTrans(v11, v8, v10, v7); + TransVal = v9; + } + } + v12 = object[v2]._oVar7; + object[v2]._oAnimFrame = object[v2]._oVar6; + InitQTextMsg(v12); + if (v13 == myplr) + NetSendCmdParam1(FALSE, CMD_OPERATEOBJ, param1); + } } // 5A5590: using guessed type char TransVal; // 646D00: using guessed type char qtextflag; void __fastcall OperateSChambBk(int pnum, int i) { - int v2; // esi - int j; // edi - signed int v5; // ecx - //int speech_id; // [esp+4h] [ebp-4h] + int v2; // esi + int j; // edi + signed int v5; // ecx + //int speech_id; // [esp+4h] [ebp-4h] - v2 = i; - if (object[i]._oSelFlag && !qtextflag) { - if (object[v2]._oAnimFrame != object[v2]._oVar6) { - ObjChangeMapResync(object[v2]._oVar1, object[v2]._oVar2, object[v2]._oVar3, object[v2]._oVar4); - for (j = 0; j < nobjects; ++j) - SyncObjectAnim(objectactive[j]); - } - object[v2]._oAnimFrame = object[v2]._oVar6; - if (quests[QTYPE_BONE]._qactive == 1) { - quests[QTYPE_BONE]._qactive = 2; - quests[QTYPE_BONE]._qlog = 1; - } - if (plr[myplr]._pClass == PC_WARRIOR) { - v5 = QUEST_BONER; - } else if (plr[myplr]._pClass == PC_ROGUE) { - v5 = QUEST_RBONER; - } else if (plr[myplr]._pClass == PC_SORCERER) { - v5 = QUEST_MBONER; - } - quests[QTYPE_BONE]._qmsg = v5; - InitQTextMsg(v5); - } + v2 = i; + if (object[i]._oSelFlag && !qtextflag) { + if (object[v2]._oAnimFrame != object[v2]._oVar6) { + ObjChangeMapResync(object[v2]._oVar1, object[v2]._oVar2, object[v2]._oVar3, object[v2]._oVar4); + for (j = 0; j < nobjects; ++j) + SyncObjectAnim(objectactive[j]); + } + object[v2]._oAnimFrame = object[v2]._oVar6; + if (quests[QTYPE_BONE]._qactive == 1) { + quests[QTYPE_BONE]._qactive = 2; + quests[QTYPE_BONE]._qlog = 1; + } + if (plr[myplr]._pClass == PC_WARRIOR) { + v5 = QUEST_BONER; + } else if (plr[myplr]._pClass == PC_ROGUE) { + v5 = QUEST_RBONER; + } else if (plr[myplr]._pClass == PC_SORCERER) { + v5 = QUEST_MBONER; + } + quests[QTYPE_BONE]._qmsg = v5; + InitQTextMsg(v5); + } } // 646D00: using guessed type char qtextflag; void __fastcall OperateChest(int pnum, int i, unsigned char sendmsg) { - int v3; // esi - bool v4; // zf - int v5; // edi - int v6; // eax - int v7; // eax - int v8; // ecx - int v9; // ecx - int v10; // ecx - signed int v11; // [esp-8h] [ebp-18h] - short param2; // [esp+8h] [ebp-8h] - int param1; // [esp+Ch] [ebp-4h] + int v3; // esi + bool v4; // zf + int v5; // edi + int v6; // eax + int v7; // eax + int v8; // ecx + int v9; // ecx + int v10; // ecx + signed int v11; // [esp-8h] [ebp-18h] + short param2; // [esp+8h] [ebp-8h] + int param1; // [esp+Ch] [ebp-4h] - param2 = i; - v3 = i; - param1 = pnum; - if (object[i]._oSelFlag) { - if (!deltaload) - PlaySfxLoc(IS_CHEST, object[v3]._ox, object[v3]._oy); - object[v3]._oAnimFrame += 2; - v4 = deltaload == 0; - object[v3]._oSelFlag = 0; - if (v4) { - SetRndSeed(object[v3]._oRndSeed); - v5 = 0; - if (setlevel) { - if (object[v3]._oVar1 > 0) { - do { - CreateRndItem(object[v3]._ox, object[v3]._oy, 1u, sendmsg, 0); - ++v5; - } while (v5 < object[v3]._oVar1); - } - } else if (object[v3]._oVar1 > 0) { - do { - if (object[v3]._oVar2) - CreateRndItem(object[v3]._ox, object[v3]._oy, 0, sendmsg, 0); - else - CreateRndUseful(param1, object[v3]._ox, object[v3]._oy, sendmsg); - ++v5; - } while (v5 < object[v3]._oVar1); - } - if (!object[v3]._oTrapFlag) - goto LABEL_26; - v6 = object[v3]._otype; - if (v6 < OBJ_TCHEST1 || v6 > OBJ_TCHEST3) - goto LABEL_26; - v7 = GetDirection(object[v3]._ox, object[v3]._oy, plr[param1].WorldX, plr[param1].WorldY); - v8 = object[v3]._oVar4; - if (v8) { - v9 = v8 - 1; - if (v9) { - if (v9 != 1) { - v10 = sendmsg; - goto LABEL_25; - } - v11 = 42; - } else { - v11 = 27; - } - v10 = v11; - } else { - v10 = 0; - } - LABEL_25: - AddMissile(object[v3]._ox, object[v3]._oy, plr[param1].WorldX, plr[param1].WorldY, v7, v10, 1, -1, 0, 0); - object[v3]._oTrapFlag = 0; - LABEL_26: - if (param1 == myplr) - NetSendCmdParam2(FALSE, CMD_PLROPOBJ, param1, param2); - return; - } - } + param2 = i; + v3 = i; + param1 = pnum; + if (object[i]._oSelFlag) { + if (!deltaload) + PlaySfxLoc(IS_CHEST, object[v3]._ox, object[v3]._oy); + object[v3]._oAnimFrame += 2; + v4 = deltaload == 0; + object[v3]._oSelFlag = 0; + if (v4) { + SetRndSeed(object[v3]._oRndSeed); + v5 = 0; + if (setlevel) { + if (object[v3]._oVar1 > 0) { + do { + CreateRndItem(object[v3]._ox, object[v3]._oy, 1u, sendmsg, 0); + ++v5; + } while (v5 < object[v3]._oVar1); + } + } else if (object[v3]._oVar1 > 0) { + do { + if (object[v3]._oVar2) + CreateRndItem(object[v3]._ox, object[v3]._oy, 0, sendmsg, 0); + else + CreateRndUseful(param1, object[v3]._ox, object[v3]._oy, sendmsg); + ++v5; + } while (v5 < object[v3]._oVar1); + } + if (!object[v3]._oTrapFlag) + goto LABEL_26; + v6 = object[v3]._otype; + if (v6 < OBJ_TCHEST1 || v6 > OBJ_TCHEST3) + goto LABEL_26; + v7 = GetDirection(object[v3]._ox, object[v3]._oy, plr[param1].WorldX, plr[param1].WorldY); + v8 = object[v3]._oVar4; + if (v8) { + v9 = v8 - 1; + if (v9) { + if (v9 != 1) { + v10 = sendmsg; + goto LABEL_25; + } + v11 = 42; + } else { + v11 = 27; + } + v10 = v11; + } else { + v10 = 0; + } + LABEL_25: + AddMissile(object[v3]._ox, object[v3]._oy, plr[param1].WorldX, plr[param1].WorldY, v7, v10, 1, -1, 0, 0); + object[v3]._oTrapFlag = 0; + LABEL_26: + if (param1 == myplr) + NetSendCmdParam2(FALSE, CMD_PLROPOBJ, param1, param2); + return; + } + } } // 5CF31D: using guessed type char setlevel; // 676190: using guessed type int deltaload; void __fastcall OperateMushPatch(int pnum, int i) { - int v2; // esi - bool v3; // zf - int v5; // ecx - int xx; // [esp+8h] [ebp-8h] - int yy; // [esp+Ch] [ebp-4h] + int v2; // esi + bool v3; // zf + int v5; // ecx + int xx; // [esp+8h] [ebp-8h] + int yy; // [esp+Ch] [ebp-4h] - if (quests[QTYPE_BLKM]._qactive != 2 || quests[QTYPE_BLKM]._qvar1 < QS_TOMEGIVEN) { - if (!deltaload && pnum == myplr) { - if (plr[myplr]._pClass == PC_WARRIOR) { - v5 = PS_WARR13; - } else if (plr[myplr]._pClass == PC_ROGUE) { - v5 = PS_ROGUE13; - } else if (plr[myplr]._pClass == PC_SORCERER) { - v5 = PS_MAGE13; - } - PlaySFX(v5); - } - } else { - v2 = i; - if (object[i]._oSelFlag) { - if (!deltaload) - PlaySfxLoc(IS_CHEST, object[v2]._ox, object[v2]._oy); - ++object[v2]._oAnimFrame; - v3 = deltaload == 0; - object[v2]._oSelFlag = 0; - if (v3) { - GetSuperItemLoc(object[v2]._ox, object[v2]._oy, &xx, &yy); - SpawnQuestItem(IDI_MUSHROOM, xx, yy, 0, 0); - quests[QTYPE_BLKM]._qvar1 = QS_MUSHSPAWNED; - } - } - } + if (quests[QTYPE_BLKM]._qactive != 2 || quests[QTYPE_BLKM]._qvar1 < QS_TOMEGIVEN) { + if (!deltaload && pnum == myplr) { + if (plr[myplr]._pClass == PC_WARRIOR) { + v5 = PS_WARR13; + } else if (plr[myplr]._pClass == PC_ROGUE) { + v5 = PS_ROGUE13; + } else if (plr[myplr]._pClass == PC_SORCERER) { + v5 = PS_MAGE13; + } + PlaySFX(v5); + } + } else { + v2 = i; + if (object[i]._oSelFlag) { + if (!deltaload) + PlaySfxLoc(IS_CHEST, object[v2]._ox, object[v2]._oy); + ++object[v2]._oAnimFrame; + v3 = deltaload == 0; + object[v2]._oSelFlag = 0; + if (v3) { + GetSuperItemLoc(object[v2]._ox, object[v2]._oy, &xx, &yy); + SpawnQuestItem(IDI_MUSHROOM, xx, yy, 0, 0); + quests[QTYPE_BLKM]._qvar1 = QS_MUSHSPAWNED; + } + } + } } // 676190: using guessed type int deltaload; void __fastcall OperateInnSignChest(int pnum, int i) { - int v4; // esi - bool v5; // zf - int xx; // [esp+8h] [ebp-8h] - int yy; // [esp+Ch] [ebp-4h] + int v4; // esi + bool v5; // zf + int xx; // [esp+8h] [ebp-8h] + int yy; // [esp+Ch] [ebp-4h] - if (quests[QTYPE_BOL]._qvar1 == 2) { - v4 = i; - if (object[i]._oSelFlag) { - if (!deltaload) - PlaySfxLoc(IS_CHEST, object[v4]._ox, object[v4]._oy); - object[v4]._oAnimFrame += 2; - v5 = deltaload == 0; - object[v4]._oSelFlag = 0; - if (v5) { - GetSuperItemLoc(object[v4]._ox, object[v4]._oy, &xx, &yy); - SpawnQuestItem(IDI_BANNER, xx, yy, 0, 0); - } - } - } else if (!deltaload && pnum == myplr) { - switch (plr[myplr]._pClass) { - case PC_WARRIOR: - PlaySFX(PS_WARR24); - break; - case PC_ROGUE: - PlaySFX(PS_ROGUE24); - break; - case PC_SORCERER: - PlaySFX(PS_MAGE24); - break; - } - } + if (quests[QTYPE_BOL]._qvar1 == 2) { + v4 = i; + if (object[i]._oSelFlag) { + if (!deltaload) + PlaySfxLoc(IS_CHEST, object[v4]._ox, object[v4]._oy); + object[v4]._oAnimFrame += 2; + v5 = deltaload == 0; + object[v4]._oSelFlag = 0; + if (v5) { + GetSuperItemLoc(object[v4]._ox, object[v4]._oy, &xx, &yy); + SpawnQuestItem(IDI_BANNER, xx, yy, 0, 0); + } + } + } else if (!deltaload && pnum == myplr) { + switch (plr[myplr]._pClass) { + case PC_WARRIOR: + PlaySFX(PS_WARR24); + break; + case PC_ROGUE: + PlaySFX(PS_ROGUE24); + break; + case PC_SORCERER: + PlaySFX(PS_MAGE24); + break; + } + } } // 676190: using guessed type int deltaload; void __fastcall OperateSlainHero(int pnum, int i, unsigned char sendmsg) { - unsigned short v3; // di - int v4; // esi - int v5; // eax - bool v6; // zf - int v8; // ecx + unsigned short v3; // di + int v4; // esi + int v5; // eax + bool v6; // zf + int v8; // ecx - v3 = i; - v4 = pnum; - v5 = i; - if (object[i]._oSelFlag) { - v6 = deltaload == 0; - object[v5]._oSelFlag = 0; - if (v6) { - if (plr[pnum]._pClass == PC_WARRIOR) { - CreateMagicItem(object[v5]._ox, object[v5]._oy, 9, ICURS_BREAST_PLATE, 0, 1); - v8 = PS_WARR9; - } else if (plr[pnum]._pClass == PC_ROGUE) { - CreateMagicItem(object[v5]._ox, object[v5]._oy, 3, ICURS_LONG_WAR_BOW, 0, 1); - v8 = PS_ROGUE9; - } else if (plr[pnum]._pClass == PC_SORCERER) { - CreateSpellBook(object[v5]._ox, object[v5]._oy, 3, 0, 1); - v8 = PS_MAGE9; - } - PlaySfxLoc(v8, plr[myplr].WorldX, plr[myplr].WorldY); + v3 = i; + v4 = pnum; + v5 = i; + if (object[i]._oSelFlag) { + v6 = deltaload == 0; + object[v5]._oSelFlag = 0; + if (v6) { + if (plr[pnum]._pClass == PC_WARRIOR) { + CreateMagicItem(object[v5]._ox, object[v5]._oy, 9, ICURS_BREAST_PLATE, 0, 1); + v8 = PS_WARR9; + } else if (plr[pnum]._pClass == PC_ROGUE) { + CreateMagicItem(object[v5]._ox, object[v5]._oy, 3, ICURS_LONG_WAR_BOW, 0, 1); + v8 = PS_ROGUE9; + } else if (plr[pnum]._pClass == PC_SORCERER) { + CreateSpellBook(object[v5]._ox, object[v5]._oy, 3, 0, 1); + v8 = PS_MAGE9; + } + PlaySfxLoc(v8, plr[myplr].WorldX, plr[myplr].WorldY); - if (v4 == myplr) - NetSendCmdParam1(FALSE, CMD_OPERATEOBJ, v3); - return; - } - } + if (v4 == myplr) + NetSendCmdParam1(FALSE, CMD_OPERATEOBJ, v3); + return; + } + } } // 676190: using guessed type int deltaload; void __fastcall OperateTrapLvr(int i) { - int v1; // ecx - int v2; // eax - int v3; // esi - int v4; // edx - int v5; // eax - int v6; // eax + int v1; // ecx + int v2; // eax + int v3; // esi + int v4; // edx + int v5; // eax + int v6; // eax - v1 = i; - v2 = object[v1]._oAnimFrame; - v3 = nobjects; - v4 = 0; - if (v2 == 1) { - object[v1]._oAnimFrame = 2; - if (v3 > 0) { - do { - v5 = objectactive[v4]; - if (object[v5]._otype == object[v1]._oVar2 && object[v5]._oVar1 == object[v1]._oVar1) { - object[v5]._oAnimFlag = 0; - object[v5]._oVar2 = 1; - } - ++v4; - } while (v4 < v3); - } - } else { - object[v1]._oAnimFrame = v2 - 1; - if (v3 > 0) { - do { - v6 = objectactive[v4]; - if (object[v6]._otype == object[v1]._oVar2 && object[v6]._oVar1 == object[v1]._oVar1) { - object[v6]._oVar2 = 0; - if (object[v6]._oVar4) - object[v6]._oAnimFlag = 1; - } - ++v4; - } while (v4 < v3); - } - } + v1 = i; + v2 = object[v1]._oAnimFrame; + v3 = nobjects; + v4 = 0; + if (v2 == 1) { + object[v1]._oAnimFrame = 2; + if (v3 > 0) { + do { + v5 = objectactive[v4]; + if (object[v5]._otype == object[v1]._oVar2 && object[v5]._oVar1 == object[v1]._oVar1) { + object[v5]._oAnimFlag = 0; + object[v5]._oVar2 = 1; + } + ++v4; + } while (v4 < v3); + } + } else { + object[v1]._oAnimFrame = v2 - 1; + if (v3 > 0) { + do { + v6 = objectactive[v4]; + if (object[v6]._otype == object[v1]._oVar2 && object[v6]._oVar1 == object[v1]._oVar1) { + object[v6]._oVar2 = 0; + if (object[v6]._oVar4) + object[v6]._oAnimFlag = 1; + } + ++v4; + } while (v4 < v3); + } + } } void __fastcall OperateSarc(int pnum, int i, unsigned char sendmsg) { - unsigned short v3; // bp - int v4; // esi - bool v5; // zf - int v6; // ecx - int v7; // [esp+Ch] [ebp-4h] + unsigned short v3; // bp + int v4; // esi + bool v5; // zf + int v6; // ecx + int v7; // [esp+Ch] [ebp-4h] - v3 = i; - v4 = i; - v7 = pnum; - if (object[i]._oSelFlag) { - if (!deltaload) - PlaySfxLoc(IS_SARC, object[v4]._ox, object[v4]._oy); - v5 = deltaload == 0; - object[v4]._oSelFlag = 0; - if (v5) { - v6 = object[v4]._oRndSeed; - object[v4]._oAnimFlag = 1; - object[v4]._oAnimDelay = 3; - SetRndSeed(v6); - if (object[v4]._oVar1 <= 2) - CreateRndItem(object[v4]._ox, object[v4]._oy, 0, sendmsg, 0); - if (object[v4]._oVar1 >= 8) - SpawnSkeleton(object[v4]._oVar2, object[v4]._ox, object[v4]._oy); - if (v7 == myplr) - NetSendCmdParam1(FALSE, CMD_OPERATEOBJ, v3); - } else { - object[v4]._oAnimFrame = object[v4]._oAnimLen; - } - } + v3 = i; + v4 = i; + v7 = pnum; + if (object[i]._oSelFlag) { + if (!deltaload) + PlaySfxLoc(IS_SARC, object[v4]._ox, object[v4]._oy); + v5 = deltaload == 0; + object[v4]._oSelFlag = 0; + if (v5) { + v6 = object[v4]._oRndSeed; + object[v4]._oAnimFlag = 1; + object[v4]._oAnimDelay = 3; + SetRndSeed(v6); + if (object[v4]._oVar1 <= 2) + CreateRndItem(object[v4]._ox, object[v4]._oy, 0, sendmsg, 0); + if (object[v4]._oVar1 >= 8) + SpawnSkeleton(object[v4]._oVar2, object[v4]._ox, object[v4]._oy); + if (v7 == myplr) + NetSendCmdParam1(FALSE, CMD_OPERATEOBJ, v3); + } else { + object[v4]._oAnimFrame = object[v4]._oAnimLen; + } + } } // 676190: using guessed type int deltaload; void __fastcall OperateL2Door(int pnum, int i, unsigned char sendflag) { - int v3; // ebx - int v4; // edi - int v5; // esi - int v6; // ST1C_4 - int v7; // eax - bool v8; // zf - bool v9; // sf - unsigned char v10; // of - int v11; // [esp+Ch] [ebp-Ch] - int pnuma; // [esp+10h] [ebp-8h] + int v3; // ebx + int v4; // edi + int v5; // esi + int v6; // ST1C_4 + int v7; // eax + bool v8; // zf + bool v9; // sf + unsigned char v10; // of + int v11; // [esp+Ch] [ebp-Ch] + int pnuma; // [esp+10h] [ebp-8h] - v3 = i; - v4 = i; - pnuma = pnum; - v5 = pnum; - v6 = abs(object[i]._ox - plr[pnum].WorldX); - v7 = abs(object[v4]._oy - plr[v5].WorldY); - v10 = __OFSUB__(v6, 1); - v8 = v6 == 1; - v9 = v6 - 1 < 0; - v11 = v7; - if (v6 != 1) { - LABEL_5: - if (!((unsigned char)(v9 ^ v10) | v8)) - return; - goto LABEL_6; - } - if (v7 <= 1 && object[v4]._otype == OBJ_L2LDOOR) { - OperateL2LDoor(pnuma, v3, sendflag); - v10 = 0; - v8 = 1; - v9 = 0; - goto LABEL_5; - } + v3 = i; + v4 = i; + pnuma = pnum; + v5 = pnum; + v6 = abs(object[i]._ox - plr[pnum].WorldX); + v7 = abs(object[v4]._oy - plr[v5].WorldY); + v10 = __OFSUB__(v6, 1); + v8 = v6 == 1; + v9 = v6 - 1 < 0; + v11 = v7; + if (v6 != 1) { + LABEL_5: + if (!((unsigned char)(v9 ^ v10) | v8)) + return; + goto LABEL_6; + } + if (v7 <= 1 && object[v4]._otype == OBJ_L2LDOOR) { + OperateL2LDoor(pnuma, v3, sendflag); + v10 = 0; + v8 = 1; + v9 = 0; + goto LABEL_5; + } LABEL_6: - if (v11 == 1 && object[v4]._otype == OBJ_L2RDOOR) - OperateL2RDoor(pnuma, v3, sendflag); + if (v11 == 1 && object[v4]._otype == OBJ_L2RDOOR) + OperateL2RDoor(pnuma, v3, sendflag); } void __fastcall OperateL3Door(int pnum, int i, unsigned char sendflag) { - int v3; // ebx - int v4; // edi - int v5; // esi - int v6; // ST1C_4 - int v7; // eax - bool v8; // zf - bool v9; // sf - unsigned char v10; // of - int v11; // [esp+Ch] [ebp-Ch] - int pnuma; // [esp+10h] [ebp-8h] + int v3; // ebx + int v4; // edi + int v5; // esi + int v6; // ST1C_4 + int v7; // eax + bool v8; // zf + bool v9; // sf + unsigned char v10; // of + int v11; // [esp+Ch] [ebp-Ch] + int pnuma; // [esp+10h] [ebp-8h] - v3 = i; - v4 = i; - pnuma = pnum; - v5 = pnum; - v6 = abs(object[i]._ox - plr[pnum].WorldX); - v7 = abs(object[v4]._oy - plr[v5].WorldY); - v10 = __OFSUB__(v6, 1); - v8 = v6 == 1; - v9 = v6 - 1 < 0; - v11 = v7; - if (v6 != 1) { - LABEL_5: - if (!((unsigned char)(v9 ^ v10) | v8)) - return; - goto LABEL_6; - } - if (v7 <= 1 && object[v4]._otype == OBJ_L3RDOOR) { - OperateL3RDoor(pnuma, v3, sendflag); - v10 = 0; - v8 = 1; - v9 = 0; - goto LABEL_5; - } + v3 = i; + v4 = i; + pnuma = pnum; + v5 = pnum; + v6 = abs(object[i]._ox - plr[pnum].WorldX); + v7 = abs(object[v4]._oy - plr[v5].WorldY); + v10 = __OFSUB__(v6, 1); + v8 = v6 == 1; + v9 = v6 - 1 < 0; + v11 = v7; + if (v6 != 1) { + LABEL_5: + if (!((unsigned char)(v9 ^ v10) | v8)) + return; + goto LABEL_6; + } + if (v7 <= 1 && object[v4]._otype == OBJ_L3RDOOR) { + OperateL3RDoor(pnuma, v3, sendflag); + v10 = 0; + v8 = 1; + v9 = 0; + goto LABEL_5; + } LABEL_6: - if (v11 == 1 && object[v4]._otype == OBJ_L3LDOOR) - OperateL3LDoor(pnuma, v3, sendflag); + if (v11 == 1 && object[v4]._otype == OBJ_L3LDOOR) + OperateL3LDoor(pnuma, v3, sendflag); } void __fastcall OperatePedistal(int pnum, int i) { - int v2; // esi - int v3; // edi - unsigned char *v4; // edi - int inv_item_num; // [esp+8h] [ebp-4h] + int v2; // esi + int v3; // edi + unsigned char *v4; // edi + int inv_item_num; // [esp+8h] [ebp-4h] - v2 = i; - v3 = pnum; - if (object[i]._oVar6 != 3) { - if (PlrHasItem(pnum, 21, &inv_item_num)) { - RemoveInvItem(v3, inv_item_num); - ++object[v2]._oAnimFrame; - ++object[v2]._oVar6; - } - if (object[v2]._oVar6 == 1) { - if (!deltaload) - PlaySfxLoc(LS_PUDDLE, object[v2]._ox, object[v2]._oy); - ObjChangeMap(setpc_x, setpc_y + 3, setpc_x + 2, setpc_y + 7); - } - if (object[v2]._oVar6 == 2) { - if (!deltaload) - PlaySfxLoc(LS_PUDDLE, object[v2]._ox, object[v2]._oy); - ObjChangeMap(setpc_x + 6, setpc_y + 3, setpc_x + setpc_w, setpc_y + 7); - } - if (object[v2]._oVar6 == 3) { - if (!deltaload) - PlaySfxLoc(LS_BLODSTAR, object[v2]._ox, object[v2]._oy); - ObjChangeMap(object[v2]._oVar1, object[v2]._oVar2, object[v2]._oVar3, object[v2]._oVar4); - v4 = LoadFileInMem("Levels\\L2Data\\Blood2.DUN", 0); - LoadMapObjs(v4, 2 * setpc_x, 2 * setpc_y); - mem_free_dbg(v4); - CreateItem(7, 2 * setpc_x + 25, 2 * setpc_y + 19); - object[v2]._oSelFlag = 0; - } - } + v2 = i; + v3 = pnum; + if (object[i]._oVar6 != 3) { + if (PlrHasItem(pnum, 21, &inv_item_num)) { + RemoveInvItem(v3, inv_item_num); + ++object[v2]._oAnimFrame; + ++object[v2]._oVar6; + } + if (object[v2]._oVar6 == 1) { + if (!deltaload) + PlaySfxLoc(LS_PUDDLE, object[v2]._ox, object[v2]._oy); + ObjChangeMap(setpc_x, setpc_y + 3, setpc_x + 2, setpc_y + 7); + } + if (object[v2]._oVar6 == 2) { + if (!deltaload) + PlaySfxLoc(LS_PUDDLE, object[v2]._ox, object[v2]._oy); + ObjChangeMap(setpc_x + 6, setpc_y + 3, setpc_x + setpc_w, setpc_y + 7); + } + if (object[v2]._oVar6 == 3) { + if (!deltaload) + PlaySfxLoc(LS_BLODSTAR, object[v2]._ox, object[v2]._oy); + ObjChangeMap(object[v2]._oVar1, object[v2]._oVar2, object[v2]._oVar3, object[v2]._oVar4); + v4 = LoadFileInMem("Levels\\L2Data\\Blood2.DUN", 0); + LoadMapObjs(v4, 2 * setpc_x, 2 * setpc_y); + mem_free_dbg(v4); + CreateItem(7, 2 * setpc_x + 25, 2 * setpc_y + 19); + object[v2]._oSelFlag = 0; + } + } } // 5CF334: using guessed type int setpc_w; // 676190: using guessed type int deltaload; void __fastcall TryDisarm(int pnum, int i) { - int v2; // edi - int v3; // esi - int v4; // esi - int v5; // edi - int v6; // ebx - int j; // edx - signed int v8; // edi - int v9; // eax - int v10; // ecx - int v11; // eax - int v12; // [esp+Ch] [ebp-4h] + int v2; // edi + int v3; // esi + int v4; // esi + int v5; // edi + int v6; // ebx + int j; // edx + signed int v8; // edi + int v9; // eax + int v10; // ecx + int v11; // eax + int v12; // [esp+Ch] [ebp-4h] - v2 = pnum; - v3 = i; - v12 = i; - if (pnum == myplr) - SetCursor(CURSOR_HAND); - v4 = v3; - if (object[v4]._oTrapFlag) { - v5 = 2 * plr[v2]._pDexterity - 5 * currlevel; - if (random(154, 100) <= v5) { - v6 = nobjects; - for (j = 0; j < v6; ++j) { - v8 = 0; - v9 = objectactive[j]; - v10 = object[v9]._otype; - if (v10 == OBJ_TRAPL) - v8 = 1; - if (v10 == OBJ_TRAPR) - v8 = 1; - if (v8 && dObject[object[v9]._oVar1][object[v9]._oVar2] - 1 == v12) { - object[v9]._oVar4 = 1; - object[v4]._oTrapFlag = 0; - } - } - v11 = object[v4]._otype; - if (v11 >= OBJ_TCHEST1 && v11 <= OBJ_TCHEST3) - object[v4]._oTrapFlag = 0; - } - } + v2 = pnum; + v3 = i; + v12 = i; + if (pnum == myplr) + SetCursor(CURSOR_HAND); + v4 = v3; + if (object[v4]._oTrapFlag) { + v5 = 2 * plr[v2]._pDexterity - 5 * currlevel; + if (random(154, 100) <= v5) { + v6 = nobjects; + for (j = 0; j < v6; ++j) { + v8 = 0; + v9 = objectactive[j]; + v10 = object[v9]._otype; + if (v10 == OBJ_TRAPL) + v8 = 1; + if (v10 == OBJ_TRAPR) + v8 = 1; + if (v8 && dObject[object[v9]._oVar1][object[v9]._oVar2] - 1 == v12) { + object[v9]._oVar4 = 1; + object[v4]._oTrapFlag = 0; + } + } + v11 = object[v4]._otype; + if (v11 >= OBJ_TCHEST1 && v11 <= OBJ_TCHEST3) + object[v4]._oTrapFlag = 0; + } + } } int __fastcall ItemMiscIdIdx(int imiscid) { - int result; // eax - int *i; // edx + int result; // eax + int *i; // edx - result = 0; - for (i = &AllItemsList[0].iMiscId; !*(i - 14) || *i != imiscid; i += 19) - ++result; - return result; + result = 0; + for (i = &AllItemsList[0].iMiscId; !*(i - 14) || *i != imiscid; i += 19) + ++result; + return result; } void __fastcall OperateShrine(int pnum, int i, int sType) { - int v3; // esi - int *v4; // ebx - int v5; // eax - int v6; // ecx - int v7; // ecx - int v9; // eax - int v10; // eax - int v11; // eax - int v12; // edx - int v13; // esi - signed int v14; // ebx - int *v15; // eax - int *v16; // eax - int v17; // edx - int v18; // ebx - int *v19; // eax - signed int v20; // edx - int v21; // eax - int v22; // ecx - int *v23; // eax - int v24; // edx - int v25; // esi - int v26; // eax - int v27; // ecx - int v28; // edx - int *v29; // ecx - int v30; // edx - int v31; // ebx - signed int v32; // edx - int v33; // edx - int v34; // eax - int v35; // ecx - int v36; // esi - signed int v37; // edx - int v38; // eax - int *v39; // ecx - signed int v40; // esi - int v41; // esi - int *v42; // ecx - int *v43; // eax - signed int v44; // ecx - int v45; // eax - int *v46; // ecx - signed int v47; // edx - int v48; // ebx - int *v49; // ecx - int *v50; // eax - signed int v51; // ecx - __int64 v52; // edi - int v53; // esi - bool v56; // zf - __int64 v57; // ebx - signed int v59; // edx - int v60; // ebx - char *v61; // esi - int j; // edi - int v63; // esi - int v64; // eax - char v67; // al - char v68; // al - int v69; // esi - int v70; // edx - int v71; // ebx - int v72; // edi - int v73; // eax - int v74; // edx - int v75; // edx - int v76; // edx - int v77; // esi - int v78; // ebx - int *v79; // eax - int v80; // eax - int v81; // eax - int *v82; // eax - int v83; // eax - int v84; // eax - int v85; // ecx - int v86; // edx - int v87; // eax - int v88; // ebx - int v89; // eax - int v91; // esi - int v92; // eax - int v93; // edx - char v96; // al - char v97; // al - int v98; // esi - int v99; // edx - int v100; // ebx - int v101; // edi - int v102; // eax - int v103; // edx - int v104; // edx - int v105; // edx - int v106; // ebx - int v107; // ST38_4 - int v108; // ST34_4 - int v109; // ST3C_4 - int v110; // eax - _BYTE *v111; // eax - signed int v112; // edx - char v115; // al - char v116; // al - int v117; // esi - int v118; // edx - int v119; // ebx - int v120; // edi - int v121; // eax - int v122; // edx - int v123; // edx - int v124; // edx - int v125; // eax - int *v126; // ecx - signed int v127; // esi - int v128; // esi - int *v129; // ecx - int *v130; // eax - signed int v131; // ecx - int v133; // eax - int v134; // ebx - int v135; // edi - int v136; // esi - unsigned short param2; // [esp+Ch] [ebp-18h] - signed int v139; // [esp+1Ch] [ebp-8h] - int *v140; // [esp+1Ch] [ebp-8h] - signed int v141; // [esp+1Ch] [ebp-8h] - int arglist; // [esp+20h] [ebp-4h] - int sfx_ida; // [esp+2Ch] [ebp+8h] - int sfx_ide; // [esp+2Ch] [ebp+8h] - int sfx_idb; // [esp+2Ch] [ebp+8h] - int *sfx_idc; // [esp+2Ch] [ebp+8h] - int sfx_idf; // [esp+2Ch] [ebp+8h] - int sfx_idd; // [esp+2Ch] [ebp+8h] - int sfx_idg; // [esp+2Ch] [ebp+8h] + int v3; // esi + int *v4; // ebx + int v5; // eax + int v6; // ecx + int v7; // ecx + int v9; // eax + int v10; // eax + int v11; // eax + int v12; // edx + int v13; // esi + signed int v14; // ebx + int *v15; // eax + int *v16; // eax + int v17; // edx + int v18; // ebx + int *v19; // eax + signed int v20; // edx + int v21; // eax + int v22; // ecx + int *v23; // eax + int v24; // edx + int v25; // esi + int v26; // eax + int v27; // ecx + int v28; // edx + int *v29; // ecx + int v30; // edx + int v31; // ebx + signed int v32; // edx + int v33; // edx + int v34; // eax + int v35; // ecx + int v36; // esi + signed int v37; // edx + int v38; // eax + int *v39; // ecx + signed int v40; // esi + int v41; // esi + int *v42; // ecx + int *v43; // eax + signed int v44; // ecx + int v45; // eax + int *v46; // ecx + signed int v47; // edx + int v48; // ebx + int *v49; // ecx + int *v50; // eax + signed int v51; // ecx + __int64 v52; // edi + int v53; // esi + bool v56; // zf + __int64 v57; // ebx + signed int v59; // edx + int v60; // ebx + char *v61; // esi + int j; // edi + int v63; // esi + int v64; // eax + char v67; // al + char v68; // al + int v69; // esi + int v70; // edx + int v71; // ebx + int v72; // edi + int v73; // eax + int v74; // edx + int v75; // edx + int v76; // edx + int v77; // esi + int v78; // ebx + int *v79; // eax + int v80; // eax + int v81; // eax + int *v82; // eax + int v83; // eax + int v84; // eax + int v85; // ecx + int v86; // edx + int v87; // eax + int v88; // ebx + int v89; // eax + int v91; // esi + int v92; // eax + int v93; // edx + char v96; // al + char v97; // al + int v98; // esi + int v99; // edx + int v100; // ebx + int v101; // edi + int v102; // eax + int v103; // edx + int v104; // edx + int v105; // edx + int v106; // ebx + int v107; // ST38_4 + int v108; // ST34_4 + int v109; // ST3C_4 + int v110; // eax + _BYTE *v111; // eax + signed int v112; // edx + char v115; // al + char v116; // al + int v117; // esi + int v118; // edx + int v119; // ebx + int v120; // edi + int v121; // eax + int v122; // edx + int v123; // edx + int v124; // edx + int v125; // eax + int *v126; // ecx + signed int v127; // esi + int v128; // esi + int *v129; // ecx + int *v130; // eax + signed int v131; // ecx + int v133; // eax + int v134; // ebx + int v135; // edi + int v136; // esi + unsigned short param2; // [esp+Ch] [ebp-18h] + signed int v139; // [esp+1Ch] [ebp-8h] + int *v140; // [esp+1Ch] [ebp-8h] + signed int v141; // [esp+1Ch] [ebp-8h] + int arglist; // [esp+20h] [ebp-4h] + int sfx_ida; // [esp+2Ch] [ebp+8h] + int sfx_ide; // [esp+2Ch] [ebp+8h] + int sfx_idb; // [esp+2Ch] [ebp+8h] + int *sfx_idc; // [esp+2Ch] [ebp+8h] + int sfx_idf; // [esp+2Ch] [ebp+8h] + int sfx_idd; // [esp+2Ch] [ebp+8h] + int sfx_idg; // [esp+2Ch] [ebp+8h] - param2 = i; - arglist = pnum; - if (dropGoldFlag) { - dropGoldFlag = 0; - dropGoldValue = 0; - } - v3 = i; - v4 = (int *)&object[i]._oSelFlag; - if (object[i]._oSelFlag) { - SetRndSeed(object[v3]._oRndSeed); - v5 = deltaload; - *(_BYTE *)v4 = 0; - if (v5) { - v6 = object[v3]._oAnimLen; - object[v3]._oAnimFlag = 0; - object[v3]._oAnimFrame = v6; - } else { - PlaySfxLoc(sType, object[v3]._ox, object[v3]._oy); - object[v3]._oAnimFlag = 1; - object[v3]._oAnimDelay = 1; - v5 = deltaload; - } - v7 = object[v3]._oVar1; - switch (v7) { - case SHRINE_MYSTERIOUS: - if (!v5 && arglist == myplr) { - ModifyPlrStr(arglist, -1); - ModifyPlrMag(arglist, -1); - ModifyPlrDex(arglist, -1); - ModifyPlrVit(arglist, -1); - v9 = random(0, 4); - if (v9) { - v10 = v9 - 1; - if (v10) { - v11 = v10 - 1; - if (v11) { - if (v11 == 1) - ModifyPlrVit(arglist, 6); - } else { - ModifyPlrDex(arglist, 6); - } - } else { - ModifyPlrMag(arglist, 6); - } - } else { - ModifyPlrStr(arglist, 6); - } - CheckStats(arglist); - _LOBYTE(v7) = EMSG_SHRINE_MYSTERIOUS; - goto LABEL_221; - } - return; - case SHRINE_HIDDEN: - v12 = 0; - if (v5 || arglist != myplr) - return; - v13 = arglist; - v14 = 7; - v15 = &plr[arglist].InvBody[INVLOC_HEAD]._itype; - v7 = 7; - do { - if (*v15 != -1) - ++v12; - v15 += 92; - --v7; - } while (v7); - if (v12 <= 0) - goto LABEL_47; - v16 = &plr[v13].InvBody[INVLOC_HEAD]._iMaxDur; - do { - if (*(v16 - 58) != -1) { - v7 = *v16; - if (*v16 != 255) { - if (v7) { - *(v16 - 1) += 10; - v17 = *(v16 - 1); - v7 += 10; - *v16 = v7; - if (v17 > v7) - *(v16 - 1) = v7; - } - } - } - v16 += 92; - --v14; - } while (v14); - while (1) { - v18 = 0; - v19 = &plr[v13].InvBody[INVLOC_HEAD]._iMaxDur; - v20 = 7; - do { - if (*(v19 - 58) != -1) { - v7 = *v19; - if (*v19 != 255) { - if (v7) - ++v18; - } - } - v19 += 92; - --v20; - } while (v20); - if (!v18) - goto LABEL_47; - v21 = random(0, 7); - v7 = v13 * 21720 + 368 * v21; - if (*(int *)((char *)&plr[0].InvBody[INVLOC_HEAD]._itype + v7) != -1) { - v7 = *(int *)((char *)&plr[0].InvBody[INVLOC_HEAD]._iMaxDur + v7); - if (v7 != 255) { - if (v7) - break; - } - } - } - v22 = 368 * v21 + v13 * 21720; - v23 = (int *)((char *)&plr[0].InvBody[INVLOC_HEAD]._iDurability + v22); - v7 = (int)&plr[0].InvBody[INVLOC_HEAD]._iMaxDur + v22; - *v23 -= 20; - v24 = *v23; - *(_DWORD *)v7 -= 20; - v25 = *(_DWORD *)v7; - if (v24 <= 0) - *v23 = 1; - if (v25 <= 0) - *(_DWORD *)v7 = 1; - LABEL_47: - _LOBYTE(v7) = EMSG_SHRINE_HIDDEN; - goto LABEL_221; - case SHRINE_GLOOMY: - if (v5) - return; - if (arglist != myplr) - goto LABEL_280; - v26 = arglist; - if (plr[arglist].InvBody[INVLOC_HEAD]._itype != ITYPE_NONE) - plr[v26].InvBody[INVLOC_HEAD]._iAC += 2; - if (plr[v26].InvBody[INVLOC_CHEST]._itype != ITYPE_NONE) - plr[v26].InvBody[INVLOC_CHEST]._iAC += 2; - v27 = plr[v26].InvBody[INVLOC_HAND_LEFT]._itype; - if (v27 != ITYPE_NONE) { - if (v27 == ITYPE_SHIELD) { - plr[v26].InvBody[INVLOC_HAND_LEFT]._iAC += 2; - } else { - v28 = plr[v26].InvBody[INVLOC_HAND_LEFT]._iMinDam; - v29 = &plr[v26].InvBody[INVLOC_HAND_LEFT]._iMaxDam; - --*v29; - if (plr[v26].InvBody[INVLOC_HAND_LEFT]._iMaxDam < v28) - *v29 = v28; - } - } - v7 = plr[v26].InvBody[INVLOC_HAND_RIGHT]._itype; - if (v7 != ITYPE_NONE) { - if (v7 == ITYPE_SHIELD) { - plr[v26].InvBody[INVLOC_HAND_RIGHT]._iAC += 2; - } else { - v30 = plr[v26].InvBody[INVLOC_HAND_RIGHT]._iMinDam; - v7 = (int)&plr[v26].InvBody[INVLOC_HAND_RIGHT]._iMaxDam; - --*(_DWORD *)v7; - if (plr[v26].InvBody[INVLOC_HAND_RIGHT]._iMaxDam < v30) - *(_DWORD *)v7 = v30; - } - } - v31 = 0; - if (plr[v26]._pNumInv <= 0) - goto LABEL_73; - v7 = (int)&plr[v26].InvList[0]._iAC; - break; - case SHRINE_WEIRD: - if (v5) - return; - if (arglist != myplr) - goto LABEL_280; - v34 = arglist; - v35 = plr[arglist].InvBody[INVLOC_HAND_LEFT]._itype; - if (v35 != ITYPE_NONE && v35 != ITYPE_SHIELD) - ++plr[v34].InvBody[INVLOC_HAND_LEFT]._iMaxDam; - v7 = plr[v34].InvBody[INVLOC_HAND_RIGHT]._itype; - if (v7 != ITYPE_NONE && v7 != ITYPE_SHIELD) - ++plr[v34].InvBody[INVLOC_HAND_RIGHT]._iMaxDam; - v36 = 0; - if (plr[v34]._pNumInv > 0) { - v7 = (int)&plr[v34].InvList[0]._iMaxDam; - do { - v37 = *(_DWORD *)(v7 - 200); - if (v37 > 0 && (v37 <= 4 || v37 == 10)) - ++*(_DWORD *)v7; - ++v36; - v7 += 368; - } while (v36 < plr[v34]._pNumInv); - } - _LOBYTE(v7) = EMSG_SHRINE_WEIRD; - goto LABEL_221; - case SHRINE_MAGICAL: - case SHRINE_MAGICAL2: - if (v5) - return; - AddMissile( - plr[arglist].WorldX, - plr[arglist].WorldY, - plr[arglist].WorldX, - plr[arglist].WorldY, - plr[arglist]._pdir, - 13, - -1, - arglist, - 0, - 2 * leveltype); - if (arglist != myplr) - return; - _LOBYTE(v7) = EMSG_SHRINE_MAGICAL; - goto LABEL_221; - case SHRINE_STONE: - if (v5) - return; - if (arglist != myplr) - goto LABEL_280; - v38 = arglist; - v39 = &plr[arglist].InvBody[INVLOC_HEAD]._iMaxCharges; - v40 = 7; - do { - if (*(v39 - 56) == 10) - *(v39 - 1) = *v39; - v39 += 92; - --v40; - } while (v40); - v41 = 0; - if (plr[v38]._pNumInv > 0) { - v42 = &plr[v38].InvList[0]._iMaxCharges; - do { - if (*(v42 - 56) == 10) - *(v42 - 1) = *v42; - ++v41; - v42 += 92; - } while (v41 < plr[v38]._pNumInv); - } - v43 = &plr[v38].SpdList[0]._iMaxCharges; - v44 = MAXBELTITEMS; - do { - if (*(v43 - 56) == 10) - *(v43 - 1) = *v43; - v43 += 92; - --v44; - } while (v44); - v7 = EMSG_SHRINE_STONE; - goto LABEL_221; - case SHRINE_RELIGIOUS: - if (v5) - return; - if (arglist != myplr) - goto LABEL_280; - v45 = arglist; - v46 = &plr[arglist].InvBody[INVLOC_HEAD]._iDurability; - v47 = 7; - do { - *v46 = v46[1]; - v46 += 92; - --v47; - } while (v47); - v48 = 0; - if (plr[v45]._pNumInv > 0) { - v49 = &plr[v45].InvList[0]._iDurability; - do { - ++v48; - *v49 = v49[1]; - v49 += 92; - } while (v48 < plr[v45]._pNumInv); - } - v50 = &plr[v45].SpdList[0]._iDurability; - v51 = MAXBELTITEMS; - do { - *v50 = v50[1]; - v50 += 92; - --v51; - } while (v51); - v7 = EMSG_SHRINE_RELIGIOUS; - goto LABEL_221; - case SHRINE_ENCHANTED: - if (v5 || arglist != myplr) - return; - sfx_ida = 0; - v52 = 1; - v53 = arglist; - v139 = MAX_SPELLS; - do { - if (v52 & plr[arglist]._pMemSpells) - ++sfx_ida; - v52 *= 2; - v56 = v139-- == 1; - } while (!v56); - v57 = 1; - if (sfx_ida > 1) { - v59 = 1; - do { - if (v57 & plr[v53]._pMemSpells) { - v7 = (int)&plr[v53]._pSplLvl[v59]; - if (*(_BYTE *)v7 < 15) - ++*(_BYTE *)v7; - } - v57 *= 2; - ++v59; - } while (v59 <= MAX_SPELLS); - do { - v60 = random(0, MAX_SPELLS); - } while (!(plr[v53]._pMemSpells & ((__int64)1 << v60))); - v61 = &plr[v53]._pSplLvl[v60 + 1]; - if (*v61 < 2) - *v61 = 0; - else - *v61 -= 2; - } - _LOBYTE(v7) = EMSG_SHRINE_ENCHANTED; - goto LABEL_221; - case SHRINE_THAUMATURGIC: - for (j = 0; j < nobjects; ++j) { - v63 = objectactive[j]; - v7 = object[v63]._otype; - if ((v7 == OBJ_CHEST1 || v7 == OBJ_CHEST2 || v7 == OBJ_CHEST3) && !object[v63]._oSelFlag) { - v64 = GetRndSeed(); - object[v63]._oAnimFrame -= 2; - object[v63]._oRndSeed = v64; - v5 = deltaload; - object[v63]._oSelFlag = 1; - } - } - if (v5) - return; - if (arglist != myplr) - goto LABEL_280; - _LOBYTE(v7) = EMSG_SHRINE_THAUMATURGIC; - goto LABEL_221; - case SHRINE_FASCINATING: - if (v5 || arglist != myplr) - return; - v7 = 21720 * arglist; - plr[arglist]._pMemSpells |= (__int64)1 << (SPL_FIREBOLT - 1); - v67 = plr[arglist]._pSplLvl[SPL_FIREBOLT]; - if (v67 < 15) - plr[0]._pSplLvl[v7 + SPL_FIREBOLT] = v67 + 1; - v68 = plr[0]._pSplLvl[v7 + SPL_FIREBOLT]; - if (v68 < 15) - plr[0]._pSplLvl[v7 + SPL_FIREBOLT] = v68 + 1; - v69 = *(int *)((char *)&plr[0]._pMaxManaBase + v7); - v70 = *(int *)((char *)&plr[0]._pManaBase + v7); - v71 = *(int *)((char *)&plr[0]._pMana + v7) - v70; - v72 = *(int *)((char *)&plr[0]._pMaxManaBase + v7) / 10; - v73 = *(int *)((char *)&plr[0]._pMaxMana + v7) - v69; - *(int *)((char *)&plr[0]._pManaBase + v7) = v70 - v72; - v74 = *(int *)((char *)&plr[0]._pMana + v7) - v72; - sfx_ide = v74; - *(int *)((char *)&plr[0]._pMana + v7) = v74; - v75 = *(int *)((char *)&plr[0]._pMaxMana + v7); - *(int *)((char *)&plr[0]._pMaxManaBase + v7) = v69 - v72; - v76 = v75 - v72; - *(int *)((char *)&plr[0]._pMaxMana + v7) = v76; - if ((signed int)(sfx_ide & 0xFFFFFFC0) <= 0) { - *(int *)((char *)&plr[0]._pManaBase + v7) = 0; - *(int *)((char *)&plr[0]._pMana + v7) = v71; - } - if ((signed int)(v76 & 0xFFFFFFC0) <= 0) { - *(int *)((char *)&plr[0]._pMaxManaBase + v7) = 0; - *(int *)((char *)&plr[0]._pMaxMana + v7) = v73; - } - _LOBYTE(v7) = EMSG_SHRINE_FASCINATING; - goto LABEL_221; - case SHRINE_CRYPTIC: - if (v5) - return; - v77 = arglist; - AddMissile( - plr[arglist].WorldX, - plr[arglist].WorldY, - plr[arglist].WorldX, - plr[arglist].WorldY, - plr[arglist]._pdir, - 42, - -1, - arglist, - 0, - 2 * leveltype); - if (arglist != myplr) - return; - _LOBYTE(v7) = EMSG_SHRINE_CRYPTIC; - plr[v77]._pMana = plr[v77]._pMaxMana; - plr[v77]._pManaBase = plr[v77]._pMaxManaBase; - goto LABEL_221; - case SHRINE_ELDRITCH: - if (v5) - return; - if (arglist != myplr) - goto LABEL_280; - sfx_idb = 0; - v78 = arglist; - if (plr[arglist]._pNumInv > 0) { - v79 = &plr[v78].InvList[0]._iMiscId; - v140 = &plr[v78].InvList[0]._iMiscId; - do { - if (!*(v79 - 53)) { - if (*v79 == IMISC_HEAL || *v79 == IMISC_MANA) { - v80 = ItemMiscIdIdx(IMISC_REJUV); - SetPlrHandItem(&plr[v78].HoldItem, v80); - GetPlrHandSeed(&plr[v78].HoldItem); - v79 = v140; - plr[v78].HoldItem._iStatFlag = 1; - qmemcpy(v140 - 55, &plr[v78].HoldItem, 0x170u); - } - if (*v79 == IMISC_FULLHEAL || *v79 == IMISC_FULLMANA) { - v81 = ItemMiscIdIdx(IMISC_FULLREJUV); - SetPlrHandItem(&plr[v78].HoldItem, v81); - GetPlrHandSeed(&plr[v78].HoldItem); - v79 = v140; - plr[v78].HoldItem._iStatFlag = 1; - qmemcpy(v140 - 55, &plr[v78].HoldItem, 0x170u); - } - } - ++sfx_idb; - v79 += 92; - v7 = sfx_idb; - v140 = v79; - } while (sfx_idb < plr[v78]._pNumInv); - } - v82 = &plr[v78].SpdList[0]._iMiscId; - v141 = MAXBELTITEMS; - sfx_idc = &plr[v78].SpdList[0]._iMiscId; - do { - if (!*(v82 - 53)) { - if (*v82 == IMISC_HEAL || *v82 == IMISC_MANA) { - v83 = ItemMiscIdIdx(IMISC_REJUV); - SetPlrHandItem(&plr[v78].HoldItem, v83); - GetPlrHandSeed(&plr[v78].HoldItem); - v82 = sfx_idc; - plr[v78].HoldItem._iStatFlag = 1; - qmemcpy(sfx_idc - 55, &plr[v78].HoldItem, 0x170u); - } - v7 = *v82; - if (*v82 == IMISC_FULLHEAL || v7 == IMISC_FULLMANA) { - v84 = ItemMiscIdIdx(IMISC_FULLREJUV); - SetPlrHandItem(&plr[v78].HoldItem, v84); - GetPlrHandSeed(&plr[v78].HoldItem); - v82 = sfx_idc; - plr[v78].HoldItem._iStatFlag = 1; - qmemcpy(sfx_idc - 55, &plr[v78].HoldItem, 0x170u); - v7 = 0; - } - } - v82 += 92; - v56 = v141-- == 1; - sfx_idc = v82; - } while (!v56); - _LOBYTE(v7) = EMSG_SHRINE_ELDRITCH; - goto LABEL_221; - case SHRINE_EERIE: - if (v5 || arglist != myplr) - return; - ModifyPlrMag(arglist, 2); - CheckStats(arglist); - _LOBYTE(v7) = EMSG_SHRINE_EERIE; - goto LABEL_221; - case SHRINE_DIVINE: - if (v5 || arglist != myplr) - return; - v85 = object[v3]._ox; - v86 = object[v3]._oy; - if (2 * currlevel >= 7) { - CreateTypeItem(v85, v86, 0, ITYPE_MISC, 19, 0, 1); - CreateTypeItem(object[v3]._ox, object[v3]._oy, 0, ITYPE_MISC, 19, 0, 1); - } else { - CreateTypeItem(v85, v86, 0, ITYPE_MISC, 7, 0, 1); - CreateTypeItem(object[v3]._ox, object[v3]._oy, 0, ITYPE_MISC, 2, 0, 1); - } - v87 = arglist; - plr[v87]._pMana = plr[arglist]._pMaxMana; - plr[v87]._pManaBase = plr[arglist]._pMaxManaBase; - plr[v87]._pHitPoints = plr[arglist]._pMaxHP; - v7 = plr[arglist]._pMaxHPBase; - plr[v87]._pHPBase = v7; - _LOBYTE(v7) = EMSG_SHRINE_DIVINE; - goto LABEL_221; - case SHRINE_HOLY: - if (v5) - return; - v88 = 0; - do { - v89 = random(159, 112); - v91 = v89; - v92 = random(159, 112); - if (++v88 > MAXDUNX * MAXDUNY) - break; - v7 = v92 + 112 * v91; - v93 = v92 + 112 * v91; - } while (nSolidTable[dPiece[0][v93]] || dObject[0][v7] || dMonster[0][v93]); - AddMissile( - plr[arglist].WorldX, - plr[arglist].WorldY, - v91, - v92, - plr[arglist]._pdir, - 3, - -1, - arglist, - 0, - 2 * leveltype); - if (arglist != myplr) - return; - _LOBYTE(v7) = EMSG_SHRINE_HOLY; - goto LABEL_221; - case SHRINE_SACRED: - if (v5 || arglist != myplr) - return; - v7 = 21720 * arglist; - plr[arglist]._pMemSpells |= (__int64)1 << (SPL_CBOLT - 1); - v96 = plr[arglist]._pSplLvl[SPL_CBOLT]; - if (v96 < 15) - plr[0]._pSplLvl[v7 + SPL_CBOLT] = v96 + 1; - v97 = plr[0]._pSplLvl[v7 + SPL_CBOLT]; - if (v97 < 15) - plr[0]._pSplLvl[v7 + SPL_CBOLT] = v97 + 1; - v98 = *(int *)((char *)&plr[0]._pMaxManaBase + v7); - v99 = *(int *)((char *)&plr[0]._pManaBase + v7); - v100 = *(int *)((char *)&plr[0]._pMana + v7) - v99; - v101 = *(int *)((char *)&plr[0]._pMaxManaBase + v7) / 10; - v102 = *(int *)((char *)&plr[0]._pMaxMana + v7) - v98; - *(int *)((char *)&plr[0]._pManaBase + v7) = v99 - v101; - v103 = *(int *)((char *)&plr[0]._pMana + v7) - v101; - sfx_idf = v103; - *(int *)((char *)&plr[0]._pMana + v7) = v103; - v104 = *(int *)((char *)&plr[0]._pMaxMana + v7); - *(int *)((char *)&plr[0]._pMaxManaBase + v7) = v98 - v101; - v105 = v104 - v101; - *(int *)((char *)&plr[0]._pMaxMana + v7) = v105; - if (sfx_idf >> 6 <= 0) { - *(int *)((char *)&plr[0]._pManaBase + v7) = 0; - *(int *)((char *)&plr[0]._pMana + v7) = v100; - } - if (v105 >> 6 <= 0) { - *(int *)((char *)&plr[0]._pMaxManaBase + v7) = 0; - *(int *)((char *)&plr[0]._pMaxMana + v7) = v102; - } - _LOBYTE(v7) = EMSG_SHRINE_SACRED; - goto LABEL_221; - case SHRINE_SPIRITUAL: - if (v5 || arglist != myplr) - return; - sfx_idd = 0; - v106 = arglist; - do { - if (!plr[v106].InvGrid[sfx_idd]) { - v107 = 5 * leveltype + random(160, 10 * leveltype); - v108 = plr[v106]._pNumInv; - v109 = v106 * 21720 + 368 * v108; - qmemcpy((char *)plr[0].InvList + v109, &golditem, 0x170u); - *(int *)((char *)&plr[0].InvList[0]._iSeed + v109) = GetRndSeed(); - ++plr[v106]._pNumInv; - plr[v106].InvGrid[sfx_idd] = plr[v106]._pNumInv; - *(int *)((char *)&plr[0].InvList[0]._ivalue + v109) = v107; - plr[v106]._pGold += v107; - SetGoldCurs(arglist, v108); - } - ++sfx_idd; - } while (sfx_idd < 40); - _LOBYTE(v7) = EMSG_SHRINE_SPIRITUAL; - goto LABEL_221; - case SHRINE_SPOOKY: - if (v5) - return; - if (arglist == myplr) { - _LOBYTE(v7) = EMSG_SHRINE_SPOOKY1; - goto LABEL_221; - } - InitDiabloMsg(EMSG_SHRINE_SPOOKY2); - v110 = myplr; - plr[v110]._pHitPoints = plr[myplr]._pMaxHP; - plr[v110]._pHPBase = plr[v110]._pMaxHPBase; - plr[v110]._pMana = plr[v110]._pMaxMana; - plr[v110]._pManaBase = plr[v110]._pMaxManaBase; - goto LABEL_280; - case SHRINE_ABANDONED: - if (v5 || arglist != myplr) - return; - ModifyPlrDex(arglist, 2); - CheckStats(arglist); - if (arglist != myplr) - goto LABEL_280; - _LOBYTE(v7) = EMSG_SHRINE_ABANDONED; - goto LABEL_221; - case SHRINE_CREEPY: - if (v5 || arglist != myplr) - return; - ModifyPlrStr(arglist, 2); - CheckStats(arglist); - if (arglist != myplr) - goto LABEL_280; - _LOBYTE(v7) = EMSG_SHRINE_CREEPY; - goto LABEL_221; - case SHRINE_QUIET: - if (v5 || arglist != myplr) - return; - ModifyPlrVit(arglist, 2); - CheckStats(arglist); - if (arglist != myplr) - goto LABEL_280; - _LOBYTE(v7) = EMSG_SHRINE_QUIET; - goto LABEL_221; - case SHRINE_SECLUDED: - if (v5) - return; - if (arglist != myplr) - goto LABEL_280; - v7 = 0; - do { - v111 = (unsigned char *)automapview + v7; - v112 = 40; - do { - *v111 = 1; - v111 += 40; - --v112; - } while (v112); - ++v7; - } while (v7 < 40); - _LOBYTE(v7) = EMSG_SHRINE_SECLUDED; - goto LABEL_221; - case SHRINE_ORNATE: - if (v5 || arglist != myplr) - return; - v7 = 21720 * arglist; - plr[arglist]._pMemSpells |= (__int64)1 << (SPL_HBOLT - 1); - v115 = plr[arglist]._pSplLvl[SPL_HBOLT]; - if (v115 < 15) - plr[0]._pSplLvl[v7 + SPL_HBOLT] = v115 + 1; - v116 = plr[0]._pSplLvl[v7 + SPL_HBOLT]; - if (v116 < 15) - plr[0]._pSplLvl[v7 + SPL_HBOLT] = v116 + 1; - v117 = *(int *)((char *)&plr[0]._pMaxManaBase + v7); - v118 = *(int *)((char *)&plr[0]._pManaBase + v7); - v119 = *(int *)((char *)&plr[0]._pMana + v7) - v118; - v120 = *(int *)((char *)&plr[0]._pMaxManaBase + v7) / 10; - v121 = *(int *)((char *)&plr[0]._pMaxMana + v7) - v117; - *(int *)((char *)&plr[0]._pManaBase + v7) = v118 - v120; - v122 = *(int *)((char *)&plr[0]._pMana + v7) - v120; - sfx_idg = v122; - *(int *)((char *)&plr[0]._pMana + v7) = v122; - v123 = *(int *)((char *)&plr[0]._pMaxMana + v7); - *(int *)((char *)&plr[0]._pMaxManaBase + v7) = v117 - v120; - v124 = v123 - v120; - *(int *)((char *)&plr[0]._pMaxMana + v7) = v124; - if (sfx_idg >> 6 <= 0) { - *(int *)((char *)&plr[0]._pManaBase + v7) = 0; - *(int *)((char *)&plr[0]._pMana + v7) = v119; - } - if (v124 >> 6 <= 0) { - *(int *)((char *)&plr[0]._pMaxManaBase + v7) = 0; - *(int *)((char *)&plr[0]._pMaxMana + v7) = v121; - } - _LOBYTE(v7) = EMSG_SHRINE_ORNATE; - goto LABEL_221; - case SHRINE_GLIMMERING: - if (v5 || arglist != myplr) - return; - v125 = arglist; - v126 = &plr[arglist].InvBody[INVLOC_HEAD]._iIdentified; - v127 = 7; - do { - if (*((_BYTE *)v126 + 4) && !*v126) - *v126 = 1; - v126 += 92; - --v127; - } while (v127); - v128 = 0; - if (plr[v125]._pNumInv > 0) { - v129 = &plr[v125].InvList[0]._iIdentified; - do { - if (*((_BYTE *)v129 + 4) && !*v129) - *v129 = 1; - ++v128; - v129 += 92; - } while (v128 < plr[v125]._pNumInv); - } - v130 = &plr[v125].SpdList[0]._iIdentified; - v131 = MAXBELTITEMS; - do { - if (*((_BYTE *)v130 + 4) && !*v130) - *v130 = 1; - v130 += 92; - --v131; - } while (v131); - v7 = EMSG_SHRINE_GLIMMERING; - goto LABEL_221; - case SHRINE_TAINTED: - if (v5) - return; - if (arglist == myplr) { - _LOBYTE(v7) = EMSG_SHRINE_TAINTED1; - goto LABEL_221; - } - InitDiabloMsg(EMSG_SHRINE_TAINTED2); - v133 = random(155, 4); - v134 = 1; - v135 = 2 * (v133 == 1) - 1; - if (v133 == 2 || (v134 = -1, v133 != 3)) - v136 = -1; - else - v136 = 1; - ModifyPlrStr(myplr, 2 * (v133 == 0) - 1); - ModifyPlrMag(myplr, v135); - ModifyPlrDex(myplr, v134); - ModifyPlrVit(myplr, v136); - CheckStats(myplr); - goto LABEL_280; - default: - goto LABEL_280; - } - while (1) { - v32 = *(_DWORD *)(v7 - 204); - if (v32 > 0) { - if (v32 <= 4) - goto LABEL_70; - if (v32 <= 9) { - *(_DWORD *)v7 += 2; - } else if (v32 == 10) { - LABEL_70: - --*(_DWORD *)(v7 - 4); - v33 = *(_DWORD *)(v7 - 8); - if (*(_DWORD *)(v7 - 4) < v33) - *(_DWORD *)(v7 - 4) = v33; - goto LABEL_72; - } - } - LABEL_72: - ++v31; - v7 += 368; - if (v31 >= plr[v26]._pNumInv) { - LABEL_73: - _LOBYTE(v7) = 14; - LABEL_221: - InitDiabloMsg(v7); - LABEL_280: - CalcPlrInv(arglist, 1u); - drawpanflag = 255; - if (arglist == myplr) - NetSendCmdParam2(FALSE, CMD_PLROPOBJ, arglist, param2); - return; - } - } - } + param2 = i; + arglist = pnum; + if (dropGoldFlag) { + dropGoldFlag = 0; + dropGoldValue = 0; + } + v3 = i; + v4 = (int *)&object[i]._oSelFlag; + if (object[i]._oSelFlag) { + SetRndSeed(object[v3]._oRndSeed); + v5 = deltaload; + *(_BYTE *)v4 = 0; + if (v5) { + v6 = object[v3]._oAnimLen; + object[v3]._oAnimFlag = 0; + object[v3]._oAnimFrame = v6; + } else { + PlaySfxLoc(sType, object[v3]._ox, object[v3]._oy); + object[v3]._oAnimFlag = 1; + object[v3]._oAnimDelay = 1; + v5 = deltaload; + } + v7 = object[v3]._oVar1; + switch (v7) { + case SHRINE_MYSTERIOUS: + if (!v5 && arglist == myplr) { + ModifyPlrStr(arglist, -1); + ModifyPlrMag(arglist, -1); + ModifyPlrDex(arglist, -1); + ModifyPlrVit(arglist, -1); + v9 = random(0, 4); + if (v9) { + v10 = v9 - 1; + if (v10) { + v11 = v10 - 1; + if (v11) { + if (v11 == 1) + ModifyPlrVit(arglist, 6); + } else { + ModifyPlrDex(arglist, 6); + } + } else { + ModifyPlrMag(arglist, 6); + } + } else { + ModifyPlrStr(arglist, 6); + } + CheckStats(arglist); + _LOBYTE(v7) = EMSG_SHRINE_MYSTERIOUS; + goto LABEL_221; + } + return; + case SHRINE_HIDDEN: + v12 = 0; + if (v5 || arglist != myplr) + return; + v13 = arglist; + v14 = 7; + v15 = &plr[arglist].InvBody[INVLOC_HEAD]._itype; + v7 = 7; + do { + if (*v15 != -1) + ++v12; + v15 += 92; + --v7; + } while (v7); + if (v12 <= 0) + goto LABEL_47; + v16 = &plr[v13].InvBody[INVLOC_HEAD]._iMaxDur; + do { + if (*(v16 - 58) != -1) { + v7 = *v16; + if (*v16 != 255) { + if (v7) { + *(v16 - 1) += 10; + v17 = *(v16 - 1); + v7 += 10; + *v16 = v7; + if (v17 > v7) + *(v16 - 1) = v7; + } + } + } + v16 += 92; + --v14; + } while (v14); + while (1) { + v18 = 0; + v19 = &plr[v13].InvBody[INVLOC_HEAD]._iMaxDur; + v20 = 7; + do { + if (*(v19 - 58) != -1) { + v7 = *v19; + if (*v19 != 255) { + if (v7) + ++v18; + } + } + v19 += 92; + --v20; + } while (v20); + if (!v18) + goto LABEL_47; + v21 = random(0, 7); + v7 = v13 * 21720 + 368 * v21; + if (*(int *)((char *)&plr[0].InvBody[INVLOC_HEAD]._itype + v7) != -1) { + v7 = *(int *)((char *)&plr[0].InvBody[INVLOC_HEAD]._iMaxDur + v7); + if (v7 != 255) { + if (v7) + break; + } + } + } + v22 = 368 * v21 + v13 * 21720; + v23 = (int *)((char *)&plr[0].InvBody[INVLOC_HEAD]._iDurability + v22); + v7 = (int)&plr[0].InvBody[INVLOC_HEAD]._iMaxDur + v22; + *v23 -= 20; + v24 = *v23; + *(_DWORD *)v7 -= 20; + v25 = *(_DWORD *)v7; + if (v24 <= 0) + *v23 = 1; + if (v25 <= 0) + *(_DWORD *)v7 = 1; + LABEL_47: + _LOBYTE(v7) = EMSG_SHRINE_HIDDEN; + goto LABEL_221; + case SHRINE_GLOOMY: + if (v5) + return; + if (arglist != myplr) + goto LABEL_280; + v26 = arglist; + if (plr[arglist].InvBody[INVLOC_HEAD]._itype != ITYPE_NONE) + plr[v26].InvBody[INVLOC_HEAD]._iAC += 2; + if (plr[v26].InvBody[INVLOC_CHEST]._itype != ITYPE_NONE) + plr[v26].InvBody[INVLOC_CHEST]._iAC += 2; + v27 = plr[v26].InvBody[INVLOC_HAND_LEFT]._itype; + if (v27 != ITYPE_NONE) { + if (v27 == ITYPE_SHIELD) { + plr[v26].InvBody[INVLOC_HAND_LEFT]._iAC += 2; + } else { + v28 = plr[v26].InvBody[INVLOC_HAND_LEFT]._iMinDam; + v29 = &plr[v26].InvBody[INVLOC_HAND_LEFT]._iMaxDam; + --*v29; + if (plr[v26].InvBody[INVLOC_HAND_LEFT]._iMaxDam < v28) + *v29 = v28; + } + } + v7 = plr[v26].InvBody[INVLOC_HAND_RIGHT]._itype; + if (v7 != ITYPE_NONE) { + if (v7 == ITYPE_SHIELD) { + plr[v26].InvBody[INVLOC_HAND_RIGHT]._iAC += 2; + } else { + v30 = plr[v26].InvBody[INVLOC_HAND_RIGHT]._iMinDam; + v7 = (int)&plr[v26].InvBody[INVLOC_HAND_RIGHT]._iMaxDam; + --*(_DWORD *)v7; + if (plr[v26].InvBody[INVLOC_HAND_RIGHT]._iMaxDam < v30) + *(_DWORD *)v7 = v30; + } + } + v31 = 0; + if (plr[v26]._pNumInv <= 0) + goto LABEL_73; + v7 = (int)&plr[v26].InvList[0]._iAC; + break; + case SHRINE_WEIRD: + if (v5) + return; + if (arglist != myplr) + goto LABEL_280; + v34 = arglist; + v35 = plr[arglist].InvBody[INVLOC_HAND_LEFT]._itype; + if (v35 != ITYPE_NONE && v35 != ITYPE_SHIELD) + ++plr[v34].InvBody[INVLOC_HAND_LEFT]._iMaxDam; + v7 = plr[v34].InvBody[INVLOC_HAND_RIGHT]._itype; + if (v7 != ITYPE_NONE && v7 != ITYPE_SHIELD) + ++plr[v34].InvBody[INVLOC_HAND_RIGHT]._iMaxDam; + v36 = 0; + if (plr[v34]._pNumInv > 0) { + v7 = (int)&plr[v34].InvList[0]._iMaxDam; + do { + v37 = *(_DWORD *)(v7 - 200); + if (v37 > 0 && (v37 <= 4 || v37 == 10)) + ++*(_DWORD *)v7; + ++v36; + v7 += 368; + } while (v36 < plr[v34]._pNumInv); + } + _LOBYTE(v7) = EMSG_SHRINE_WEIRD; + goto LABEL_221; + case SHRINE_MAGICAL: + case SHRINE_MAGICAL2: + if (v5) + return; + AddMissile( + plr[arglist].WorldX, + plr[arglist].WorldY, + plr[arglist].WorldX, + plr[arglist].WorldY, + plr[arglist]._pdir, + 13, + -1, + arglist, + 0, + 2 * leveltype); + if (arglist != myplr) + return; + _LOBYTE(v7) = EMSG_SHRINE_MAGICAL; + goto LABEL_221; + case SHRINE_STONE: + if (v5) + return; + if (arglist != myplr) + goto LABEL_280; + v38 = arglist; + v39 = &plr[arglist].InvBody[INVLOC_HEAD]._iMaxCharges; + v40 = 7; + do { + if (*(v39 - 56) == 10) + *(v39 - 1) = *v39; + v39 += 92; + --v40; + } while (v40); + v41 = 0; + if (plr[v38]._pNumInv > 0) { + v42 = &plr[v38].InvList[0]._iMaxCharges; + do { + if (*(v42 - 56) == 10) + *(v42 - 1) = *v42; + ++v41; + v42 += 92; + } while (v41 < plr[v38]._pNumInv); + } + v43 = &plr[v38].SpdList[0]._iMaxCharges; + v44 = MAXBELTITEMS; + do { + if (*(v43 - 56) == 10) + *(v43 - 1) = *v43; + v43 += 92; + --v44; + } while (v44); + v7 = EMSG_SHRINE_STONE; + goto LABEL_221; + case SHRINE_RELIGIOUS: + if (v5) + return; + if (arglist != myplr) + goto LABEL_280; + v45 = arglist; + v46 = &plr[arglist].InvBody[INVLOC_HEAD]._iDurability; + v47 = 7; + do { + *v46 = v46[1]; + v46 += 92; + --v47; + } while (v47); + v48 = 0; + if (plr[v45]._pNumInv > 0) { + v49 = &plr[v45].InvList[0]._iDurability; + do { + ++v48; + *v49 = v49[1]; + v49 += 92; + } while (v48 < plr[v45]._pNumInv); + } + v50 = &plr[v45].SpdList[0]._iDurability; + v51 = MAXBELTITEMS; + do { + *v50 = v50[1]; + v50 += 92; + --v51; + } while (v51); + v7 = EMSG_SHRINE_RELIGIOUS; + goto LABEL_221; + case SHRINE_ENCHANTED: + if (v5 || arglist != myplr) + return; + sfx_ida = 0; + v52 = 1; + v53 = arglist; + v139 = MAX_SPELLS; + do { + if (v52 & plr[arglist]._pMemSpells) + ++sfx_ida; + v52 *= 2; + v56 = v139-- == 1; + } while (!v56); + v57 = 1; + if (sfx_ida > 1) { + v59 = 1; + do { + if (v57 & plr[v53]._pMemSpells) { + v7 = (int)&plr[v53]._pSplLvl[v59]; + if (*(_BYTE *)v7 < 15) + ++*(_BYTE *)v7; + } + v57 *= 2; + ++v59; + } while (v59 <= MAX_SPELLS); + do { + v60 = random(0, MAX_SPELLS); + } while (!(plr[v53]._pMemSpells & ((__int64)1 << v60))); + v61 = &plr[v53]._pSplLvl[v60 + 1]; + if (*v61 < 2) + *v61 = 0; + else + *v61 -= 2; + } + _LOBYTE(v7) = EMSG_SHRINE_ENCHANTED; + goto LABEL_221; + case SHRINE_THAUMATURGIC: + for (j = 0; j < nobjects; ++j) { + v63 = objectactive[j]; + v7 = object[v63]._otype; + if ((v7 == OBJ_CHEST1 || v7 == OBJ_CHEST2 || v7 == OBJ_CHEST3) && !object[v63]._oSelFlag) { + v64 = GetRndSeed(); + object[v63]._oAnimFrame -= 2; + object[v63]._oRndSeed = v64; + v5 = deltaload; + object[v63]._oSelFlag = 1; + } + } + if (v5) + return; + if (arglist != myplr) + goto LABEL_280; + _LOBYTE(v7) = EMSG_SHRINE_THAUMATURGIC; + goto LABEL_221; + case SHRINE_FASCINATING: + if (v5 || arglist != myplr) + return; + v7 = 21720 * arglist; + plr[arglist]._pMemSpells |= (__int64)1 << (SPL_FIREBOLT - 1); + v67 = plr[arglist]._pSplLvl[SPL_FIREBOLT]; + if (v67 < 15) + plr[0]._pSplLvl[v7 + SPL_FIREBOLT] = v67 + 1; + v68 = plr[0]._pSplLvl[v7 + SPL_FIREBOLT]; + if (v68 < 15) + plr[0]._pSplLvl[v7 + SPL_FIREBOLT] = v68 + 1; + v69 = *(int *)((char *)&plr[0]._pMaxManaBase + v7); + v70 = *(int *)((char *)&plr[0]._pManaBase + v7); + v71 = *(int *)((char *)&plr[0]._pMana + v7) - v70; + v72 = *(int *)((char *)&plr[0]._pMaxManaBase + v7) / 10; + v73 = *(int *)((char *)&plr[0]._pMaxMana + v7) - v69; + *(int *)((char *)&plr[0]._pManaBase + v7) = v70 - v72; + v74 = *(int *)((char *)&plr[0]._pMana + v7) - v72; + sfx_ide = v74; + *(int *)((char *)&plr[0]._pMana + v7) = v74; + v75 = *(int *)((char *)&plr[0]._pMaxMana + v7); + *(int *)((char *)&plr[0]._pMaxManaBase + v7) = v69 - v72; + v76 = v75 - v72; + *(int *)((char *)&plr[0]._pMaxMana + v7) = v76; + if ((signed int)(sfx_ide & 0xFFFFFFC0) <= 0) { + *(int *)((char *)&plr[0]._pManaBase + v7) = 0; + *(int *)((char *)&plr[0]._pMana + v7) = v71; + } + if ((signed int)(v76 & 0xFFFFFFC0) <= 0) { + *(int *)((char *)&plr[0]._pMaxManaBase + v7) = 0; + *(int *)((char *)&plr[0]._pMaxMana + v7) = v73; + } + _LOBYTE(v7) = EMSG_SHRINE_FASCINATING; + goto LABEL_221; + case SHRINE_CRYPTIC: + if (v5) + return; + v77 = arglist; + AddMissile( + plr[arglist].WorldX, + plr[arglist].WorldY, + plr[arglist].WorldX, + plr[arglist].WorldY, + plr[arglist]._pdir, + 42, + -1, + arglist, + 0, + 2 * leveltype); + if (arglist != myplr) + return; + _LOBYTE(v7) = EMSG_SHRINE_CRYPTIC; + plr[v77]._pMana = plr[v77]._pMaxMana; + plr[v77]._pManaBase = plr[v77]._pMaxManaBase; + goto LABEL_221; + case SHRINE_ELDRITCH: + if (v5) + return; + if (arglist != myplr) + goto LABEL_280; + sfx_idb = 0; + v78 = arglist; + if (plr[arglist]._pNumInv > 0) { + v79 = &plr[v78].InvList[0]._iMiscId; + v140 = &plr[v78].InvList[0]._iMiscId; + do { + if (!*(v79 - 53)) { + if (*v79 == IMISC_HEAL || *v79 == IMISC_MANA) { + v80 = ItemMiscIdIdx(IMISC_REJUV); + SetPlrHandItem(&plr[v78].HoldItem, v80); + GetPlrHandSeed(&plr[v78].HoldItem); + v79 = v140; + plr[v78].HoldItem._iStatFlag = 1; + qmemcpy(v140 - 55, &plr[v78].HoldItem, 0x170u); + } + if (*v79 == IMISC_FULLHEAL || *v79 == IMISC_FULLMANA) { + v81 = ItemMiscIdIdx(IMISC_FULLREJUV); + SetPlrHandItem(&plr[v78].HoldItem, v81); + GetPlrHandSeed(&plr[v78].HoldItem); + v79 = v140; + plr[v78].HoldItem._iStatFlag = 1; + qmemcpy(v140 - 55, &plr[v78].HoldItem, 0x170u); + } + } + ++sfx_idb; + v79 += 92; + v7 = sfx_idb; + v140 = v79; + } while (sfx_idb < plr[v78]._pNumInv); + } + v82 = &plr[v78].SpdList[0]._iMiscId; + v141 = MAXBELTITEMS; + sfx_idc = &plr[v78].SpdList[0]._iMiscId; + do { + if (!*(v82 - 53)) { + if (*v82 == IMISC_HEAL || *v82 == IMISC_MANA) { + v83 = ItemMiscIdIdx(IMISC_REJUV); + SetPlrHandItem(&plr[v78].HoldItem, v83); + GetPlrHandSeed(&plr[v78].HoldItem); + v82 = sfx_idc; + plr[v78].HoldItem._iStatFlag = 1; + qmemcpy(sfx_idc - 55, &plr[v78].HoldItem, 0x170u); + } + v7 = *v82; + if (*v82 == IMISC_FULLHEAL || v7 == IMISC_FULLMANA) { + v84 = ItemMiscIdIdx(IMISC_FULLREJUV); + SetPlrHandItem(&plr[v78].HoldItem, v84); + GetPlrHandSeed(&plr[v78].HoldItem); + v82 = sfx_idc; + plr[v78].HoldItem._iStatFlag = 1; + qmemcpy(sfx_idc - 55, &plr[v78].HoldItem, 0x170u); + v7 = 0; + } + } + v82 += 92; + v56 = v141-- == 1; + sfx_idc = v82; + } while (!v56); + _LOBYTE(v7) = EMSG_SHRINE_ELDRITCH; + goto LABEL_221; + case SHRINE_EERIE: + if (v5 || arglist != myplr) + return; + ModifyPlrMag(arglist, 2); + CheckStats(arglist); + _LOBYTE(v7) = EMSG_SHRINE_EERIE; + goto LABEL_221; + case SHRINE_DIVINE: + if (v5 || arglist != myplr) + return; + v85 = object[v3]._ox; + v86 = object[v3]._oy; + if (2 * currlevel >= 7) { + CreateTypeItem(v85, v86, 0, ITYPE_MISC, 19, 0, 1); + CreateTypeItem(object[v3]._ox, object[v3]._oy, 0, ITYPE_MISC, 19, 0, 1); + } else { + CreateTypeItem(v85, v86, 0, ITYPE_MISC, 7, 0, 1); + CreateTypeItem(object[v3]._ox, object[v3]._oy, 0, ITYPE_MISC, 2, 0, 1); + } + v87 = arglist; + plr[v87]._pMana = plr[arglist]._pMaxMana; + plr[v87]._pManaBase = plr[arglist]._pMaxManaBase; + plr[v87]._pHitPoints = plr[arglist]._pMaxHP; + v7 = plr[arglist]._pMaxHPBase; + plr[v87]._pHPBase = v7; + _LOBYTE(v7) = EMSG_SHRINE_DIVINE; + goto LABEL_221; + case SHRINE_HOLY: + if (v5) + return; + v88 = 0; + do { + v89 = random(159, 112); + v91 = v89; + v92 = random(159, 112); + if (++v88 > MAXDUNX * MAXDUNY) + break; + v7 = v92 + 112 * v91; + v93 = v92 + 112 * v91; + } while (nSolidTable[dPiece[0][v93]] || dObject[0][v7] || dMonster[0][v93]); + AddMissile( + plr[arglist].WorldX, + plr[arglist].WorldY, + v91, + v92, + plr[arglist]._pdir, + 3, + -1, + arglist, + 0, + 2 * leveltype); + if (arglist != myplr) + return; + _LOBYTE(v7) = EMSG_SHRINE_HOLY; + goto LABEL_221; + case SHRINE_SACRED: + if (v5 || arglist != myplr) + return; + v7 = 21720 * arglist; + plr[arglist]._pMemSpells |= (__int64)1 << (SPL_CBOLT - 1); + v96 = plr[arglist]._pSplLvl[SPL_CBOLT]; + if (v96 < 15) + plr[0]._pSplLvl[v7 + SPL_CBOLT] = v96 + 1; + v97 = plr[0]._pSplLvl[v7 + SPL_CBOLT]; + if (v97 < 15) + plr[0]._pSplLvl[v7 + SPL_CBOLT] = v97 + 1; + v98 = *(int *)((char *)&plr[0]._pMaxManaBase + v7); + v99 = *(int *)((char *)&plr[0]._pManaBase + v7); + v100 = *(int *)((char *)&plr[0]._pMana + v7) - v99; + v101 = *(int *)((char *)&plr[0]._pMaxManaBase + v7) / 10; + v102 = *(int *)((char *)&plr[0]._pMaxMana + v7) - v98; + *(int *)((char *)&plr[0]._pManaBase + v7) = v99 - v101; + v103 = *(int *)((char *)&plr[0]._pMana + v7) - v101; + sfx_idf = v103; + *(int *)((char *)&plr[0]._pMana + v7) = v103; + v104 = *(int *)((char *)&plr[0]._pMaxMana + v7); + *(int *)((char *)&plr[0]._pMaxManaBase + v7) = v98 - v101; + v105 = v104 - v101; + *(int *)((char *)&plr[0]._pMaxMana + v7) = v105; + if (sfx_idf >> 6 <= 0) { + *(int *)((char *)&plr[0]._pManaBase + v7) = 0; + *(int *)((char *)&plr[0]._pMana + v7) = v100; + } + if (v105 >> 6 <= 0) { + *(int *)((char *)&plr[0]._pMaxManaBase + v7) = 0; + *(int *)((char *)&plr[0]._pMaxMana + v7) = v102; + } + _LOBYTE(v7) = EMSG_SHRINE_SACRED; + goto LABEL_221; + case SHRINE_SPIRITUAL: + if (v5 || arglist != myplr) + return; + sfx_idd = 0; + v106 = arglist; + do { + if (!plr[v106].InvGrid[sfx_idd]) { + v107 = 5 * leveltype + random(160, 10 * leveltype); + v108 = plr[v106]._pNumInv; + v109 = v106 * 21720 + 368 * v108; + qmemcpy((char *)plr[0].InvList + v109, &golditem, 0x170u); + *(int *)((char *)&plr[0].InvList[0]._iSeed + v109) = GetRndSeed(); + ++plr[v106]._pNumInv; + plr[v106].InvGrid[sfx_idd] = plr[v106]._pNumInv; + *(int *)((char *)&plr[0].InvList[0]._ivalue + v109) = v107; + plr[v106]._pGold += v107; + SetGoldCurs(arglist, v108); + } + ++sfx_idd; + } while (sfx_idd < 40); + _LOBYTE(v7) = EMSG_SHRINE_SPIRITUAL; + goto LABEL_221; + case SHRINE_SPOOKY: + if (v5) + return; + if (arglist == myplr) { + _LOBYTE(v7) = EMSG_SHRINE_SPOOKY1; + goto LABEL_221; + } + InitDiabloMsg(EMSG_SHRINE_SPOOKY2); + v110 = myplr; + plr[v110]._pHitPoints = plr[myplr]._pMaxHP; + plr[v110]._pHPBase = plr[v110]._pMaxHPBase; + plr[v110]._pMana = plr[v110]._pMaxMana; + plr[v110]._pManaBase = plr[v110]._pMaxManaBase; + goto LABEL_280; + case SHRINE_ABANDONED: + if (v5 || arglist != myplr) + return; + ModifyPlrDex(arglist, 2); + CheckStats(arglist); + if (arglist != myplr) + goto LABEL_280; + _LOBYTE(v7) = EMSG_SHRINE_ABANDONED; + goto LABEL_221; + case SHRINE_CREEPY: + if (v5 || arglist != myplr) + return; + ModifyPlrStr(arglist, 2); + CheckStats(arglist); + if (arglist != myplr) + goto LABEL_280; + _LOBYTE(v7) = EMSG_SHRINE_CREEPY; + goto LABEL_221; + case SHRINE_QUIET: + if (v5 || arglist != myplr) + return; + ModifyPlrVit(arglist, 2); + CheckStats(arglist); + if (arglist != myplr) + goto LABEL_280; + _LOBYTE(v7) = EMSG_SHRINE_QUIET; + goto LABEL_221; + case SHRINE_SECLUDED: + if (v5) + return; + if (arglist != myplr) + goto LABEL_280; + v7 = 0; + do { + v111 = (unsigned char *)automapview + v7; + v112 = 40; + do { + *v111 = 1; + v111 += 40; + --v112; + } while (v112); + ++v7; + } while (v7 < 40); + _LOBYTE(v7) = EMSG_SHRINE_SECLUDED; + goto LABEL_221; + case SHRINE_ORNATE: + if (v5 || arglist != myplr) + return; + v7 = 21720 * arglist; + plr[arglist]._pMemSpells |= (__int64)1 << (SPL_HBOLT - 1); + v115 = plr[arglist]._pSplLvl[SPL_HBOLT]; + if (v115 < 15) + plr[0]._pSplLvl[v7 + SPL_HBOLT] = v115 + 1; + v116 = plr[0]._pSplLvl[v7 + SPL_HBOLT]; + if (v116 < 15) + plr[0]._pSplLvl[v7 + SPL_HBOLT] = v116 + 1; + v117 = *(int *)((char *)&plr[0]._pMaxManaBase + v7); + v118 = *(int *)((char *)&plr[0]._pManaBase + v7); + v119 = *(int *)((char *)&plr[0]._pMana + v7) - v118; + v120 = *(int *)((char *)&plr[0]._pMaxManaBase + v7) / 10; + v121 = *(int *)((char *)&plr[0]._pMaxMana + v7) - v117; + *(int *)((char *)&plr[0]._pManaBase + v7) = v118 - v120; + v122 = *(int *)((char *)&plr[0]._pMana + v7) - v120; + sfx_idg = v122; + *(int *)((char *)&plr[0]._pMana + v7) = v122; + v123 = *(int *)((char *)&plr[0]._pMaxMana + v7); + *(int *)((char *)&plr[0]._pMaxManaBase + v7) = v117 - v120; + v124 = v123 - v120; + *(int *)((char *)&plr[0]._pMaxMana + v7) = v124; + if (sfx_idg >> 6 <= 0) { + *(int *)((char *)&plr[0]._pManaBase + v7) = 0; + *(int *)((char *)&plr[0]._pMana + v7) = v119; + } + if (v124 >> 6 <= 0) { + *(int *)((char *)&plr[0]._pMaxManaBase + v7) = 0; + *(int *)((char *)&plr[0]._pMaxMana + v7) = v121; + } + _LOBYTE(v7) = EMSG_SHRINE_ORNATE; + goto LABEL_221; + case SHRINE_GLIMMERING: + if (v5 || arglist != myplr) + return; + v125 = arglist; + v126 = &plr[arglist].InvBody[INVLOC_HEAD]._iIdentified; + v127 = 7; + do { + if (*((_BYTE *)v126 + 4) && !*v126) + *v126 = 1; + v126 += 92; + --v127; + } while (v127); + v128 = 0; + if (plr[v125]._pNumInv > 0) { + v129 = &plr[v125].InvList[0]._iIdentified; + do { + if (*((_BYTE *)v129 + 4) && !*v129) + *v129 = 1; + ++v128; + v129 += 92; + } while (v128 < plr[v125]._pNumInv); + } + v130 = &plr[v125].SpdList[0]._iIdentified; + v131 = MAXBELTITEMS; + do { + if (*((_BYTE *)v130 + 4) && !*v130) + *v130 = 1; + v130 += 92; + --v131; + } while (v131); + v7 = EMSG_SHRINE_GLIMMERING; + goto LABEL_221; + case SHRINE_TAINTED: + if (v5) + return; + if (arglist == myplr) { + _LOBYTE(v7) = EMSG_SHRINE_TAINTED1; + goto LABEL_221; + } + InitDiabloMsg(EMSG_SHRINE_TAINTED2); + v133 = random(155, 4); + v134 = 1; + v135 = 2 * (v133 == 1) - 1; + if (v133 == 2 || (v134 = -1, v133 != 3)) + v136 = -1; + else + v136 = 1; + ModifyPlrStr(myplr, 2 * (v133 == 0) - 1); + ModifyPlrMag(myplr, v135); + ModifyPlrDex(myplr, v134); + ModifyPlrVit(myplr, v136); + CheckStats(myplr); + goto LABEL_280; + default: + goto LABEL_280; + } + while (1) { + v32 = *(_DWORD *)(v7 - 204); + if (v32 > 0) { + if (v32 <= 4) + goto LABEL_70; + if (v32 <= 9) { + *(_DWORD *)v7 += 2; + } else if (v32 == 10) { + LABEL_70: + --*(_DWORD *)(v7 - 4); + v33 = *(_DWORD *)(v7 - 8); + if (*(_DWORD *)(v7 - 4) < v33) + *(_DWORD *)(v7 - 4) = v33; + goto LABEL_72; + } + } + LABEL_72: + ++v31; + v7 += 368; + if (v31 >= plr[v26]._pNumInv) { + LABEL_73: + _LOBYTE(v7) = 14; + LABEL_221: + InitDiabloMsg(v7); + LABEL_280: + CalcPlrInv(arglist, 1u); + drawpanflag = 255; + if (arglist == myplr) + NetSendCmdParam2(FALSE, CMD_PLROPOBJ, arglist, param2); + return; + } + } + } } // 4B84DC: using guessed type int dropGoldFlag; // 52571C: using guessed type int drawpanflag; @@ -5110,1336 +5110,1336 @@ void __fastcall OperateShrine(int pnum, int i, int sType) void __fastcall OperateSkelBook(int pnum, int i, unsigned char sendmsg) { - unsigned short v3; // di - int v4; // esi - bool v5; // zf - int v7; // eax - int v8; // ecx - int v9; // edx - int v10; // [esp+Ch] [ebp-4h] + unsigned short v3; // di + int v4; // esi + bool v5; // zf + int v7; // eax + int v8; // ecx + int v9; // edx + int v10; // [esp+Ch] [ebp-4h] - v3 = i; - v4 = i; - v10 = pnum; - if (object[i]._oSelFlag) { - if (!deltaload) - PlaySfxLoc(IS_ISCROL, object[v4]._ox, object[v4]._oy); - object[v4]._oAnimFrame += 2; - v5 = deltaload == 0; - object[v4]._oSelFlag = 0; - if (v5) { - SetRndSeed(object[v4]._oRndSeed); - v7 = random(161, 5); - v8 = object[v4]._ox; - v9 = object[v4]._oy; - if (v7) - CreateTypeItem(v8, v9, 0, ITYPE_MISC, 21, sendmsg, 0); - else - CreateTypeItem(v8, v9, 0, ITYPE_MISC, 24, sendmsg, 0); - if (v10 == myplr) - NetSendCmdParam1(FALSE, CMD_OPERATEOBJ, v3); - } - } + v3 = i; + v4 = i; + v10 = pnum; + if (object[i]._oSelFlag) { + if (!deltaload) + PlaySfxLoc(IS_ISCROL, object[v4]._ox, object[v4]._oy); + object[v4]._oAnimFrame += 2; + v5 = deltaload == 0; + object[v4]._oSelFlag = 0; + if (v5) { + SetRndSeed(object[v4]._oRndSeed); + v7 = random(161, 5); + v8 = object[v4]._ox; + v9 = object[v4]._oy; + if (v7) + CreateTypeItem(v8, v9, 0, ITYPE_MISC, 21, sendmsg, 0); + else + CreateTypeItem(v8, v9, 0, ITYPE_MISC, 24, sendmsg, 0); + if (v10 == myplr) + NetSendCmdParam1(FALSE, CMD_OPERATEOBJ, v3); + } + } } // 676190: using guessed type int deltaload; void __fastcall OperateBookCase(int pnum, int i, unsigned char sendmsg) { - unsigned short v3; // di - int v4; // ebp - int v5; // esi - bool v6; // zf - //int v7; // eax + unsigned short v3; // di + int v4; // ebp + int v5; // esi + bool v6; // zf + //int v7; // eax - v3 = i; - v4 = pnum; - v5 = i; - if (object[i]._oSelFlag) { - if (!deltaload) - PlaySfxLoc(IS_ISCROL, object[v5]._ox, object[v5]._oy); - object[v5]._oAnimFrame -= 2; - v6 = deltaload == 0; - object[v5]._oSelFlag = 0; - if (v6) { - SetRndSeed(object[v5]._oRndSeed); - CreateTypeItem(object[v5]._ox, object[v5]._oy, 0, ITYPE_MISC, 24, sendmsg, 0); - //_LOBYTE(v7) = QuestStatus(QTYPE_ZHAR); - if (QuestStatus(QTYPE_ZHAR) - && monster[4].mName == UniqMonst[2].mName - && monster[4]._msquelch == -1 - && monster[4]._mhitpoints) { - monster[4].mtalkmsg = QUEST_ZHAR2; - M_StartStand(0, monster[4]._mdir); - _LOBYTE(monster[4]._mgoal) = 5; - monster[4]._mmode = MM_TALK; - } - if (v4 == myplr) - NetSendCmdParam1(FALSE, CMD_OPERATEOBJ, v3); - } - } + v3 = i; + v4 = pnum; + v5 = i; + if (object[i]._oSelFlag) { + if (!deltaload) + PlaySfxLoc(IS_ISCROL, object[v5]._ox, object[v5]._oy); + object[v5]._oAnimFrame -= 2; + v6 = deltaload == 0; + object[v5]._oSelFlag = 0; + if (v6) { + SetRndSeed(object[v5]._oRndSeed); + CreateTypeItem(object[v5]._ox, object[v5]._oy, 0, ITYPE_MISC, 24, sendmsg, 0); + //_LOBYTE(v7) = QuestStatus(QTYPE_ZHAR); + if (QuestStatus(QTYPE_ZHAR) + && monster[4].mName == UniqMonst[2].mName + && monster[4]._msquelch == -1 + && monster[4]._mhitpoints) { + monster[4].mtalkmsg = QUEST_ZHAR2; + M_StartStand(0, monster[4]._mdir); + _LOBYTE(monster[4]._mgoal) = 5; + monster[4]._mmode = MM_TALK; + } + if (v4 == myplr) + NetSendCmdParam1(FALSE, CMD_OPERATEOBJ, v3); + } + } } // 676190: using guessed type int deltaload; void __fastcall OperateDecap(int pnum, int i, unsigned char sendmsg) { - unsigned short v3; // bp - int v4; // esi - int v5; // edi - int *v6; // eax - bool v7; // zf + unsigned short v3; // bp + int v4; // esi + int v5; // edi + int *v6; // eax + bool v7; // zf - v3 = i; - v4 = i; - v5 = pnum; - v6 = (int *)&object[i]._oSelFlag; - if (*(_BYTE *)v6) { - v7 = deltaload == 0; - *(_BYTE *)v6 = 0; - if (v7) { - SetRndSeed(object[v4]._oRndSeed); - CreateRndItem(object[v4]._ox, object[v4]._oy, 0, sendmsg, 0); - if (v5 == myplr) - NetSendCmdParam1(FALSE, CMD_OPERATEOBJ, v3); - } - } + v3 = i; + v4 = i; + v5 = pnum; + v6 = (int *)&object[i]._oSelFlag; + if (*(_BYTE *)v6) { + v7 = deltaload == 0; + *(_BYTE *)v6 = 0; + if (v7) { + SetRndSeed(object[v4]._oRndSeed); + CreateRndItem(object[v4]._ox, object[v4]._oy, 0, sendmsg, 0); + if (v5 == myplr) + NetSendCmdParam1(FALSE, CMD_OPERATEOBJ, v3); + } + } } // 676190: using guessed type int deltaload; void __fastcall OperateArmorStand(int pnum, int i, unsigned char sendmsg) { - unsigned short v3; // di - int v4; // esi - int *v5; // eax - bool v6; // zf - unsigned char v8; // al - int v9; // [esp-10h] [ebp-20h] - int v10; // [esp-8h] [ebp-18h] - int v11; // [esp+Ch] [ebp-4h] + unsigned short v3; // di + int v4; // esi + int *v5; // eax + bool v6; // zf + unsigned char v8; // al + int v9; // [esp-10h] [ebp-20h] + int v10; // [esp-8h] [ebp-18h] + int v11; // [esp+Ch] [ebp-4h] - v3 = i; - v4 = i; - v11 = pnum; - v5 = (int *)&object[i]._oSelFlag; - if (*(_BYTE *)v5) { - ++object[v4]._oAnimFrame; - v6 = deltaload == 0; - *(_BYTE *)v5 = 0; - if (v6) { - SetRndSeed(object[v4]._oRndSeed); - v8 = random(0, 2); - if (currlevel > 5u) { - if (currlevel >= 6u && currlevel <= 9u) { - CreateTypeItem(object[v4]._ox, object[v4]._oy, v8, ITYPE_MARMOR, 0, sendmsg, 0); - goto LABEL_15; - } - if (currlevel >= 0xAu && currlevel <= 0xCu) { - CreateTypeItem(object[v4]._ox, object[v4]._oy, 0, ITYPE_HARMOR, 0, sendmsg, 0); - goto LABEL_15; - } - if (currlevel < 0xDu || currlevel > 0x10u) - goto LABEL_15; - v10 = sendmsg; - v9 = ITYPE_HARMOR; - } else { - v10 = sendmsg; - v9 = ITYPE_LARMOR; - } - CreateTypeItem(object[v4]._ox, object[v4]._oy, 1u, v9, 0, v10, 0); - LABEL_15: - if (v11 == myplr) - NetSendCmdParam1(FALSE, CMD_OPERATEOBJ, v3); - return; - } - } + v3 = i; + v4 = i; + v11 = pnum; + v5 = (int *)&object[i]._oSelFlag; + if (*(_BYTE *)v5) { + ++object[v4]._oAnimFrame; + v6 = deltaload == 0; + *(_BYTE *)v5 = 0; + if (v6) { + SetRndSeed(object[v4]._oRndSeed); + v8 = random(0, 2); + if (currlevel > 5u) { + if (currlevel >= 6u && currlevel <= 9u) { + CreateTypeItem(object[v4]._ox, object[v4]._oy, v8, ITYPE_MARMOR, 0, sendmsg, 0); + goto LABEL_15; + } + if (currlevel >= 0xAu && currlevel <= 0xCu) { + CreateTypeItem(object[v4]._ox, object[v4]._oy, 0, ITYPE_HARMOR, 0, sendmsg, 0); + goto LABEL_15; + } + if (currlevel < 0xDu || currlevel > 0x10u) + goto LABEL_15; + v10 = sendmsg; + v9 = ITYPE_HARMOR; + } else { + v10 = sendmsg; + v9 = ITYPE_LARMOR; + } + CreateTypeItem(object[v4]._ox, object[v4]._oy, 1u, v9, 0, v10, 0); + LABEL_15: + if (v11 == myplr) + NetSendCmdParam1(FALSE, CMD_OPERATEOBJ, v3); + return; + } + } } // 676190: using guessed type int deltaload; int __fastcall FindValidShrine(int i) { - bool done; // esi - int rv; // eax - bool v3; // zf + bool done; // esi + int rv; // eax + bool v3; // zf - do { - done = 0; - do { - rv = random(0, 26); - if (currlevel >= shrinemin[rv] && currlevel <= shrinemax[rv] && rv != 8) - done = 1; - } while (!done); - if (gbMaxPlayers == 1) - v3 = shrineavail[rv] == 2; - else - v3 = shrineavail[rv] == 1; - } while (v3); - return rv; + do { + done = 0; + do { + rv = random(0, 26); + if (currlevel >= shrinemin[rv] && currlevel <= shrinemax[rv] && rv != 8) + done = 1; + } while (!done); + if (gbMaxPlayers == 1) + v3 = shrineavail[rv] == 2; + else + v3 = shrineavail[rv] == 1; + } while (v3); + return rv; } // 679660: using guessed type char gbMaxPlayers; void __fastcall OperateGoatShrine(int pnum, int i, int sType) { - int v3; // edi - int v4; // ebx - int v5; // esi + int v3; // edi + int v4; // ebx + int v5; // esi - v3 = i; - v4 = pnum; - v5 = i; - SetRndSeed(object[i]._oRndSeed); - object[v5]._oVar1 = FindValidShrine(v3); - OperateShrine(v4, v3, sType); - object[v5]._oAnimDelay = 2; - drawpanflag = 255; + v3 = i; + v4 = pnum; + v5 = i; + SetRndSeed(object[i]._oRndSeed); + object[v5]._oVar1 = FindValidShrine(v3); + OperateShrine(v4, v3, sType); + object[v5]._oAnimDelay = 2; + drawpanflag = 255; } // 52571C: using guessed type int drawpanflag; void __fastcall OperateCauldron(int pnum, int i, int sType) { - int v3; // edi - int v4; // ebx - int v5; // esi + int v3; // edi + int v4; // ebx + int v5; // esi - v3 = i; - v4 = pnum; - v5 = i; - SetRndSeed(object[i]._oRndSeed); - object[v5]._oVar1 = FindValidShrine(v3); - OperateShrine(v4, v3, sType); - object[v5]._oAnimFlag = 0; - object[v5]._oAnimFrame = 3; - drawpanflag = 255; + v3 = i; + v4 = pnum; + v5 = i; + SetRndSeed(object[i]._oRndSeed); + object[v5]._oVar1 = FindValidShrine(v3); + OperateShrine(v4, v3, sType); + object[v5]._oAnimFlag = 0; + object[v5]._oAnimFrame = 3; + drawpanflag = 255; } // 52571C: using guessed type int drawpanflag; bool __fastcall OperateFountains(int pnum, int i) { - unsigned short v2; // bx - int v3; // esi - int v4; // edi - bool v5; // bp - signed int v7; // ebx - int v8; // ebp - int v10; // eax - int v11; // esi - int v12; // eax - int v13; // eax - int v14; // edi - int v15; // edx - int v16; // edx - int v17; // ecx - int *v18; // eax - int v19; // ecx - int v20; // edi - int v21; // edx - int v22; // ecx - int v23; // [esp-4h] [ebp-20h] - signed int v24; // [esp+10h] [ebp-Ch] - signed int v25; // [esp+14h] [ebp-8h] - short param1; // [esp+18h] [ebp-4h] + unsigned short v2; // bx + int v3; // esi + int v4; // edi + bool v5; // bp + signed int v7; // ebx + int v8; // ebp + int v10; // eax + int v11; // esi + int v12; // eax + int v13; // eax + int v14; // edi + int v15; // edx + int v16; // edx + int v17; // ecx + int *v18; // eax + int v19; // ecx + int v20; // edi + int v21; // edx + int v22; // ecx + int v23; // [esp-4h] [ebp-20h] + signed int v24; // [esp+10h] [ebp-Ch] + signed int v25; // [esp+14h] [ebp-8h] + short param1; // [esp+18h] [ebp-4h] - v2 = i; - v3 = i; - v4 = pnum; - param1 = i; - v5 = 0; - SetRndSeed(object[i]._oRndSeed); - switch (object[v3]._otype) { - case OBJ_BLOODFTN: - if (!deltaload && v4 == myplr) { - v20 = v4; - v23 = object[v3]._oy; - v15 = object[v3]._ox; - if (plr[v20]._pHitPoints < plr[v20]._pMaxHP) { - PlaySfxLoc(LS_FOUNTAIN, v15, v23); - plr[v20]._pHitPoints += 64; - v21 = plr[v20]._pHitPoints; - v22 = plr[v20]._pMaxHP; - v18 = &plr[v20]._pHPBase; - *v18 += 64; - if (v21 <= v22) - goto LABEL_39; - plr[v20]._pHitPoints = v22; - v19 = plr[v20]._pMaxHPBase; - goto LABEL_38; - } - LABEL_45: - PlaySfxLoc(LS_FOUNTAIN, v15, v23); - break; - } - return 0; - case OBJ_PURIFYINGFTN: - if (!deltaload && v4 == myplr) { - v14 = v4; - v23 = object[v3]._oy; - v15 = object[v3]._ox; - if (plr[v14]._pMana < plr[v14]._pMaxMana) { - PlaySfxLoc(LS_FOUNTAIN, v15, v23); - plr[v14]._pMana += 64; - v16 = plr[v14]._pMana; - v17 = plr[v14]._pMaxMana; - v18 = &plr[v14]._pManaBase; - *v18 += 64; - if (v16 <= v17) { - LABEL_39: - v5 = 1; - break; - } - plr[v14]._pMana = v17; - v19 = plr[v14]._pMaxManaBase; - LABEL_38: - *v18 = v19; - goto LABEL_39; - } - goto LABEL_45; - } - return 0; - case OBJ_MURKYFTN: - if (object[v3]._oSelFlag) { - if (!deltaload) - PlaySfxLoc(LS_FOUNTAIN, object[v3]._ox, object[v3]._oy); - object[v3]._oSelFlag = 0; - if (deltaload) - return 0; - AddMissile( - plr[v4].WorldX, - plr[v4].WorldY, - plr[v4].WorldX, - plr[v4].WorldY, - plr[v4]._pdir, - 39, - -1, - v4, - 0, - 2 * leveltype); - v5 = 1; - if (v4 == myplr) - NetSendCmdParam1(FALSE, CMD_OPERATEOBJ, v2); - } - break; - default: - if (object[v3]._otype == OBJ_TEARFTN && object[v3]._oSelFlag) { - v7 = -1; - v8 = -1; - v25 = 0; - v24 = 0; - if (!deltaload) - PlaySfxLoc(LS_FOUNTAIN, object[v3]._ox, object[v3]._oy); - object[v3]._oSelFlag = 0; - if (deltaload || v4 != myplr) - return 0; - do { - v10 = random(0, 4); - v11 = v10; - if (v10 != v7) { - if (v10) { - v12 = v10 - 1; - if (v12) { - v13 = v12 - 1; - if (v13) { - if (v13 == 1) - ModifyPlrVit(v4, v8); - } else { - ModifyPlrDex(v4, v8); - } - } else { - ModifyPlrMag(v4, v8); - } - } else { - ModifyPlrStr(v4, v8); - } - v7 = v11; - v8 = 1; - ++v24; - } - if (v24 > 1) - v25 = 1; - } while (!v25); - CheckStats(v4); - v5 = 1; - if (v4 == myplr) - NetSendCmdParam1(FALSE, CMD_OPERATEOBJ, param1); - } - break; - } - drawpanflag = 255; - return v5; + v2 = i; + v3 = i; + v4 = pnum; + param1 = i; + v5 = 0; + SetRndSeed(object[i]._oRndSeed); + switch (object[v3]._otype) { + case OBJ_BLOODFTN: + if (!deltaload && v4 == myplr) { + v20 = v4; + v23 = object[v3]._oy; + v15 = object[v3]._ox; + if (plr[v20]._pHitPoints < plr[v20]._pMaxHP) { + PlaySfxLoc(LS_FOUNTAIN, v15, v23); + plr[v20]._pHitPoints += 64; + v21 = plr[v20]._pHitPoints; + v22 = plr[v20]._pMaxHP; + v18 = &plr[v20]._pHPBase; + *v18 += 64; + if (v21 <= v22) + goto LABEL_39; + plr[v20]._pHitPoints = v22; + v19 = plr[v20]._pMaxHPBase; + goto LABEL_38; + } + LABEL_45: + PlaySfxLoc(LS_FOUNTAIN, v15, v23); + break; + } + return 0; + case OBJ_PURIFYINGFTN: + if (!deltaload && v4 == myplr) { + v14 = v4; + v23 = object[v3]._oy; + v15 = object[v3]._ox; + if (plr[v14]._pMana < plr[v14]._pMaxMana) { + PlaySfxLoc(LS_FOUNTAIN, v15, v23); + plr[v14]._pMana += 64; + v16 = plr[v14]._pMana; + v17 = plr[v14]._pMaxMana; + v18 = &plr[v14]._pManaBase; + *v18 += 64; + if (v16 <= v17) { + LABEL_39: + v5 = 1; + break; + } + plr[v14]._pMana = v17; + v19 = plr[v14]._pMaxManaBase; + LABEL_38: + *v18 = v19; + goto LABEL_39; + } + goto LABEL_45; + } + return 0; + case OBJ_MURKYFTN: + if (object[v3]._oSelFlag) { + if (!deltaload) + PlaySfxLoc(LS_FOUNTAIN, object[v3]._ox, object[v3]._oy); + object[v3]._oSelFlag = 0; + if (deltaload) + return 0; + AddMissile( + plr[v4].WorldX, + plr[v4].WorldY, + plr[v4].WorldX, + plr[v4].WorldY, + plr[v4]._pdir, + 39, + -1, + v4, + 0, + 2 * leveltype); + v5 = 1; + if (v4 == myplr) + NetSendCmdParam1(FALSE, CMD_OPERATEOBJ, v2); + } + break; + default: + if (object[v3]._otype == OBJ_TEARFTN && object[v3]._oSelFlag) { + v7 = -1; + v8 = -1; + v25 = 0; + v24 = 0; + if (!deltaload) + PlaySfxLoc(LS_FOUNTAIN, object[v3]._ox, object[v3]._oy); + object[v3]._oSelFlag = 0; + if (deltaload || v4 != myplr) + return 0; + do { + v10 = random(0, 4); + v11 = v10; + if (v10 != v7) { + if (v10) { + v12 = v10 - 1; + if (v12) { + v13 = v12 - 1; + if (v13) { + if (v13 == 1) + ModifyPlrVit(v4, v8); + } else { + ModifyPlrDex(v4, v8); + } + } else { + ModifyPlrMag(v4, v8); + } + } else { + ModifyPlrStr(v4, v8); + } + v7 = v11; + v8 = 1; + ++v24; + } + if (v24 > 1) + v25 = 1; + } while (!v25); + CheckStats(v4); + v5 = 1; + if (v4 == myplr) + NetSendCmdParam1(FALSE, CMD_OPERATEOBJ, param1); + } + break; + } + drawpanflag = 255; + return v5; } // 52571C: using guessed type int drawpanflag; // 676190: using guessed type int deltaload; void __fastcall OperateWeaponRack(int pnum, int i, unsigned char sendmsg) { - unsigned short v3; // di - int v4; // esi - int v6; // eax - int v7; // eax - int v8; // eax - int v9; // eax - bool v10; // zf - int v11; // ecx - int v12; // edx - signed int v13; // [esp-4h] [ebp-14h] - int v14; // [esp+Ch] [ebp-4h] + unsigned short v3; // di + int v4; // esi + int v6; // eax + int v7; // eax + int v8; // eax + int v9; // eax + bool v10; // zf + int v11; // ecx + int v12; // edx + signed int v13; // [esp-4h] [ebp-14h] + int v14; // [esp+Ch] [ebp-4h] - v3 = i; - v4 = i; - v14 = pnum; - if (!object[i]._oSelFlag) - return; - SetRndSeed(object[v4]._oRndSeed); - v6 = random(0, 4); - if (v6) { - v7 = v6 - 1; - if (!v7) { - v13 = ITYPE_AXE; - goto LABEL_7; - } - v8 = v7 - 1; - if (!v8) { - v13 = ITYPE_BOW; - goto LABEL_7; - } - if (v8 == 1) { - v13 = ITYPE_MACE; - LABEL_7: - v9 = v13; - goto LABEL_12; - } - v9 = sendmsg; - } else { - v9 = ITYPE_SWORD; - } + v3 = i; + v4 = i; + v14 = pnum; + if (!object[i]._oSelFlag) + return; + SetRndSeed(object[v4]._oRndSeed); + v6 = random(0, 4); + if (v6) { + v7 = v6 - 1; + if (!v7) { + v13 = ITYPE_AXE; + goto LABEL_7; + } + v8 = v7 - 1; + if (!v8) { + v13 = ITYPE_BOW; + goto LABEL_7; + } + if (v8 == 1) { + v13 = ITYPE_MACE; + LABEL_7: + v9 = v13; + goto LABEL_12; + } + v9 = sendmsg; + } else { + v9 = ITYPE_SWORD; + } LABEL_12: - ++object[v4]._oAnimFrame; - v10 = deltaload == 0; - object[v4]._oSelFlag = 0; - if (v10) { - v11 = object[v4]._ox; - v12 = object[v4]._oy; - if (leveltype <= 1u) - CreateTypeItem(v11, v12, 0, v9, 0, sendmsg, 0); - else - CreateTypeItem(v11, v12, 1u, v9, 0, sendmsg, 0); - if (v14 == myplr) - NetSendCmdParam1(FALSE, CMD_OPERATEOBJ, v3); - } + ++object[v4]._oAnimFrame; + v10 = deltaload == 0; + object[v4]._oSelFlag = 0; + if (v10) { + v11 = object[v4]._ox; + v12 = object[v4]._oy; + if (leveltype <= 1u) + CreateTypeItem(v11, v12, 0, v9, 0, sendmsg, 0); + else + CreateTypeItem(v11, v12, 1u, v9, 0, sendmsg, 0); + if (v14 == myplr) + NetSendCmdParam1(FALSE, CMD_OPERATEOBJ, v3); + } } // 676190: using guessed type int deltaload; void __fastcall OperateStoryBook(int pnum, int i) { - unsigned short v2; // di - int v3; // esi - int v4; // ST04_4 - int v5; // edx + unsigned short v2; // di + int v3; // esi + int v4; // ST04_4 + int v5; // edx - v2 = i; - v3 = i; - if (object[i]._oSelFlag && !deltaload && !qtextflag && pnum == myplr) { - v4 = object[v3]._oy; - v5 = object[v3]._ox; - object[v3]._oAnimFrame = object[v3]._oVar4; - PlaySfxLoc(IS_ISCROL, v5, v4); - InitQTextMsg(object[v3]._oVar2); - NetSendCmdParam1(FALSE, CMD_OPERATEOBJ, v2); - } + v2 = i; + v3 = i; + if (object[i]._oSelFlag && !deltaload && !qtextflag && pnum == myplr) { + v4 = object[v3]._oy; + v5 = object[v3]._ox; + object[v3]._oAnimFrame = object[v3]._oVar4; + PlaySfxLoc(IS_ISCROL, v5, v4); + InitQTextMsg(object[v3]._oVar2); + NetSendCmdParam1(FALSE, CMD_OPERATEOBJ, v2); + } } // 646D00: using guessed type char qtextflag; // 676190: using guessed type int deltaload; void __fastcall OperateLazStand(int pnum, int i) { - int v2; // eax - int v3; // edx - int xx; // [esp+4h] [ebp-8h] - int yy; // [esp+8h] [ebp-4h] + int v2; // eax + int v3; // edx + int xx; // [esp+4h] [ebp-8h] + int yy; // [esp+8h] [ebp-4h] - v2 = i; - if (object[i]._oSelFlag && !deltaload && !qtextflag && pnum == myplr) { - v3 = object[v2]._oy; - ++object[v2]._oAnimFrame; - object[v2]._oSelFlag = 0; - GetSuperItemLoc(object[v2]._ox, v3, &xx, &yy); - SpawnQuestItem(33, xx, yy, 0, 0); - } + v2 = i; + if (object[i]._oSelFlag && !deltaload && !qtextflag && pnum == myplr) { + v3 = object[v2]._oy; + ++object[v2]._oAnimFrame; + object[v2]._oSelFlag = 0; + GetSuperItemLoc(object[v2]._ox, v3, &xx, &yy); + SpawnQuestItem(33, xx, yy, 0, 0); + } } // 646D00: using guessed type char qtextflag; // 676190: using guessed type int deltaload; void __fastcall OperateObject(int pnum, int i, BOOL TeleFlag) { - int v3; // esi - int v4; // edi - ObjectStruct *v5; // ebx - int v6; // ecx - bool sendmsg; // [esp+Ch] [ebp-4h] + int v3; // esi + int v4; // edi + ObjectStruct *v5; // ebx + int v6; // ecx + bool sendmsg; // [esp+Ch] [ebp-4h] - v3 = pnum; - v4 = i; - sendmsg = pnum == myplr; - v5 = &object[i]; - v6 = v5->_otype; - switch (v5->_otype) { - case OBJ_L1LDOOR: - case OBJ_L1RDOOR: - if (TeleFlag) { - if (v6 == OBJ_L1LDOOR) - OperateL1LDoor(v3, i, OBJ_L1LDOOR); - if (v5->_otype == OBJ_L1RDOOR) - OperateL1RDoor(v3, v4, 1u); - } else if (v3 == myplr) { - OperateL1Door(v3, i, 1u); - } - break; - case OBJ_LEVER: - case OBJ_SWITCHSKL: - OperateLever(v3, i); - break; - case OBJ_CHEST1: - case OBJ_CHEST2: - case OBJ_CHEST3: - case OBJ_TCHEST1: - case OBJ_TCHEST2: - case OBJ_TCHEST3: - OperateChest(v3, i, sendmsg); - break; - case OBJ_BOOK2L: - OperateBook(v3, i); - break; - case OBJ_BOOK2R: - OperateSChambBk(v3, i); - break; - case OBJ_L2LDOOR: - case OBJ_L2RDOOR: - if (TeleFlag) { - if (v6 == OBJ_L2LDOOR) - OperateL2LDoor(v3, i, 1u); - if (v5->_otype == OBJ_L2RDOOR) - OperateL2RDoor(v3, v4, 1u); - } else if (v3 == myplr) { - OperateL2Door(v3, i, 1u); - } - break; - case OBJ_SARC: - OperateSarc(v3, i, sendmsg); - break; - case OBJ_FLAMELVR: - OperateTrapLvr(i); - break; - case OBJ_SHRINEL: - case OBJ_SHRINER: - OperateShrine(v3, i, IS_MAGIC); - break; - case OBJ_SKELBOOK: - case OBJ_BOOKSTAND: - OperateSkelBook(v3, i, sendmsg); - break; - case OBJ_BOOKCASEL: - case OBJ_BOOKCASER: - OperateBookCase(v3, i, sendmsg); - break; - case OBJ_BLOODFTN: - case OBJ_PURIFYINGFTN: - case OBJ_MURKYFTN: - case OBJ_TEARFTN: - OperateFountains(v3, i); - break; - case OBJ_DECAP: - OperateDecap(v3, i, sendmsg); - break; - case OBJ_BLINDBOOK: - case OBJ_BLOODBOOK: - case OBJ_STEELTOME: - OperateBookLever(v3, i); - break; - case OBJ_PEDISTAL: - OperatePedistal(v3, i); - break; - case OBJ_L3LDOOR: - case OBJ_L3RDOOR: - if (TeleFlag) { - if (v6 == OBJ_L3LDOOR) - OperateL3LDoor(v3, i, 1u); - if (v5->_otype == OBJ_L3RDOOR) - OperateL3RDoor(v3, v4, 1u); - } else if (v3 == myplr) { - OperateL3Door(v3, i, 1u); - } - break; - case OBJ_ARMORSTAND: - case OBJ_WARARMOR: - OperateArmorStand(v3, i, sendmsg); - break; - case OBJ_GOATSHRINE: - OperateGoatShrine(v3, i, LS_GSHRINE); - break; - case OBJ_CAULDRON: - OperateCauldron(v3, i, LS_CALDRON); - break; - case OBJ_STORYBOOK: - OperateStoryBook(v3, i); - break; - case OBJ_WARWEAP: - case OBJ_WEAPONRACK: - OperateWeaponRack(v3, i, sendmsg); - break; - case OBJ_MUSHPATCH: - OperateMushPatch(v3, i); - break; - case OBJ_LAZSTAND: - OperateLazStand(v3, i); - break; - case OBJ_SLAINHERO: - OperateSlainHero(v3, i, sendmsg); - break; - case OBJ_SIGNCHEST: - OperateInnSignChest(v3, i); - break; - default: - return; - } + v3 = pnum; + v4 = i; + sendmsg = pnum == myplr; + v5 = &object[i]; + v6 = v5->_otype; + switch (v5->_otype) { + case OBJ_L1LDOOR: + case OBJ_L1RDOOR: + if (TeleFlag) { + if (v6 == OBJ_L1LDOOR) + OperateL1LDoor(v3, i, OBJ_L1LDOOR); + if (v5->_otype == OBJ_L1RDOOR) + OperateL1RDoor(v3, v4, 1u); + } else if (v3 == myplr) { + OperateL1Door(v3, i, 1u); + } + break; + case OBJ_LEVER: + case OBJ_SWITCHSKL: + OperateLever(v3, i); + break; + case OBJ_CHEST1: + case OBJ_CHEST2: + case OBJ_CHEST3: + case OBJ_TCHEST1: + case OBJ_TCHEST2: + case OBJ_TCHEST3: + OperateChest(v3, i, sendmsg); + break; + case OBJ_BOOK2L: + OperateBook(v3, i); + break; + case OBJ_BOOK2R: + OperateSChambBk(v3, i); + break; + case OBJ_L2LDOOR: + case OBJ_L2RDOOR: + if (TeleFlag) { + if (v6 == OBJ_L2LDOOR) + OperateL2LDoor(v3, i, 1u); + if (v5->_otype == OBJ_L2RDOOR) + OperateL2RDoor(v3, v4, 1u); + } else if (v3 == myplr) { + OperateL2Door(v3, i, 1u); + } + break; + case OBJ_SARC: + OperateSarc(v3, i, sendmsg); + break; + case OBJ_FLAMELVR: + OperateTrapLvr(i); + break; + case OBJ_SHRINEL: + case OBJ_SHRINER: + OperateShrine(v3, i, IS_MAGIC); + break; + case OBJ_SKELBOOK: + case OBJ_BOOKSTAND: + OperateSkelBook(v3, i, sendmsg); + break; + case OBJ_BOOKCASEL: + case OBJ_BOOKCASER: + OperateBookCase(v3, i, sendmsg); + break; + case OBJ_BLOODFTN: + case OBJ_PURIFYINGFTN: + case OBJ_MURKYFTN: + case OBJ_TEARFTN: + OperateFountains(v3, i); + break; + case OBJ_DECAP: + OperateDecap(v3, i, sendmsg); + break; + case OBJ_BLINDBOOK: + case OBJ_BLOODBOOK: + case OBJ_STEELTOME: + OperateBookLever(v3, i); + break; + case OBJ_PEDISTAL: + OperatePedistal(v3, i); + break; + case OBJ_L3LDOOR: + case OBJ_L3RDOOR: + if (TeleFlag) { + if (v6 == OBJ_L3LDOOR) + OperateL3LDoor(v3, i, 1u); + if (v5->_otype == OBJ_L3RDOOR) + OperateL3RDoor(v3, v4, 1u); + } else if (v3 == myplr) { + OperateL3Door(v3, i, 1u); + } + break; + case OBJ_ARMORSTAND: + case OBJ_WARARMOR: + OperateArmorStand(v3, i, sendmsg); + break; + case OBJ_GOATSHRINE: + OperateGoatShrine(v3, i, LS_GSHRINE); + break; + case OBJ_CAULDRON: + OperateCauldron(v3, i, LS_CALDRON); + break; + case OBJ_STORYBOOK: + OperateStoryBook(v3, i); + break; + case OBJ_WARWEAP: + case OBJ_WEAPONRACK: + OperateWeaponRack(v3, i, sendmsg); + break; + case OBJ_MUSHPATCH: + OperateMushPatch(v3, i); + break; + case OBJ_LAZSTAND: + OperateLazStand(v3, i); + break; + case OBJ_SLAINHERO: + OperateSlainHero(v3, i, sendmsg); + break; + case OBJ_SIGNCHEST: + OperateInnSignChest(v3, i); + break; + default: + return; + } } void __fastcall SyncOpL1Door(int pnum, int cmd, int i) { - signed int v3; // eax - ObjectStruct *v4; // esi + signed int v3; // eax + ObjectStruct *v4; // esi - if (pnum != myplr) { - v3 = 0; - if (cmd == 43) { - if (object[i]._oVar4) - return; - v3 = 1; - } - if (cmd == 44 && object[i]._oVar4 == 1) - v3 = 1; - if (v3) { - v4 = &object[i]; - if (v4->_otype == 1) - OperateL1LDoor(-1, i, 0); - if (v4->_otype == OBJ_L1RDOOR) - OperateL1RDoor(-1, i, 0); - } - } + if (pnum != myplr) { + v3 = 0; + if (cmd == 43) { + if (object[i]._oVar4) + return; + v3 = 1; + } + if (cmd == 44 && object[i]._oVar4 == 1) + v3 = 1; + if (v3) { + v4 = &object[i]; + if (v4->_otype == 1) + OperateL1LDoor(-1, i, 0); + if (v4->_otype == OBJ_L1RDOOR) + OperateL1RDoor(-1, i, 0); + } + } } void __fastcall SyncOpL2Door(int pnum, int cmd, int i) { - signed int v3; // eax - ObjectStruct *v4; // esi + signed int v3; // eax + ObjectStruct *v4; // esi - if (pnum != myplr) { - v3 = 0; - if (cmd == 43) { - if (object[i]._oVar4) - return; - v3 = 1; - } - if (cmd == 44 && object[i]._oVar4 == 1) - v3 = 1; - if (v3) { - v4 = &object[i]; - if (v4->_otype == OBJ_L2LDOOR) - OperateL2LDoor(-1, i, 0); - if (v4->_otype == OBJ_L2RDOOR) - OperateL2RDoor(-1, i, 0); - } - } + if (pnum != myplr) { + v3 = 0; + if (cmd == 43) { + if (object[i]._oVar4) + return; + v3 = 1; + } + if (cmd == 44 && object[i]._oVar4 == 1) + v3 = 1; + if (v3) { + v4 = &object[i]; + if (v4->_otype == OBJ_L2LDOOR) + OperateL2LDoor(-1, i, 0); + if (v4->_otype == OBJ_L2RDOOR) + OperateL2RDoor(-1, i, 0); + } + } } void __fastcall SyncOpL3Door(int pnum, int cmd, int i) { - signed int v3; // eax - ObjectStruct *v4; // esi + signed int v3; // eax + ObjectStruct *v4; // esi - if (pnum != myplr) { - v3 = 0; - if (cmd == 43) { - if (object[i]._oVar4) - return; - v3 = 1; - } - if (cmd == 44 && object[i]._oVar4 == 1) - v3 = 1; - if (v3) { - v4 = &object[i]; - if (v4->_otype == OBJ_L3LDOOR) - OperateL3LDoor(-1, i, 0); - if (v4->_otype == OBJ_L3RDOOR) - OperateL3RDoor(-1, i, 0); - } - } + if (pnum != myplr) { + v3 = 0; + if (cmd == 43) { + if (object[i]._oVar4) + return; + v3 = 1; + } + if (cmd == 44 && object[i]._oVar4 == 1) + v3 = 1; + if (v3) { + v4 = &object[i]; + if (v4->_otype == OBJ_L3LDOOR) + OperateL3LDoor(-1, i, 0); + if (v4->_otype == OBJ_L3RDOOR) + OperateL3RDoor(-1, i, 0); + } + } } void __fastcall SyncOpObject(int pnum, int cmd, int i) { - switch (object[i]._otype) { - case OBJ_L1LDOOR: - case OBJ_L1RDOOR: - SyncOpL1Door(pnum, cmd, i); - break; - case OBJ_LEVER: - case OBJ_SWITCHSKL: - OperateLever(pnum, i); - break; - case OBJ_CHEST1: - case OBJ_CHEST2: - case OBJ_CHEST3: - case OBJ_TCHEST1: - case OBJ_TCHEST2: - case OBJ_TCHEST3: - OperateChest(pnum, i, 0); - break; - case OBJ_L2LDOOR: - case OBJ_L2RDOOR: - SyncOpL2Door(pnum, cmd, i); - break; - case OBJ_SARC: - OperateSarc(pnum, i, 0); - break; - case OBJ_SHRINEL: - case OBJ_SHRINER: - OperateShrine(pnum, i, IS_MAGIC); - break; - case OBJ_SKELBOOK: - case OBJ_BOOKSTAND: - OperateSkelBook(pnum, i, 0); - break; - case OBJ_BOOKCASEL: - case OBJ_BOOKCASER: - OperateBookCase(pnum, i, 0); - break; - case OBJ_DECAP: - OperateDecap(pnum, i, 0); - break; - case OBJ_BLINDBOOK: - case OBJ_BLOODBOOK: - case OBJ_STEELTOME: - OperateBookLever(pnum, i); - break; - case OBJ_PEDISTAL: - OperatePedistal(pnum, i); - break; - case OBJ_L3LDOOR: - case OBJ_L3RDOOR: - SyncOpL3Door(pnum, cmd, i); - break; - case OBJ_ARMORSTAND: - case OBJ_WARARMOR: - OperateArmorStand(pnum, i, 0); - break; - case OBJ_GOATSHRINE: - OperateGoatShrine(pnum, i, LS_GSHRINE); - break; - case OBJ_CAULDRON: - OperateCauldron(pnum, i, LS_CALDRON); - break; - case OBJ_MURKYFTN: - case OBJ_TEARFTN: - OperateFountains(pnum, i); - break; - case OBJ_STORYBOOK: - OperateStoryBook(pnum, i); - break; - case OBJ_WARWEAP: - case OBJ_WEAPONRACK: - OperateWeaponRack(pnum, i, 0); - break; - case OBJ_MUSHPATCH: - OperateMushPatch(pnum, i); - break; - case OBJ_SLAINHERO: - OperateSlainHero(pnum, i, 0); - break; - case OBJ_SIGNCHEST: - OperateInnSignChest(pnum, i); - break; - default: - return; - } + switch (object[i]._otype) { + case OBJ_L1LDOOR: + case OBJ_L1RDOOR: + SyncOpL1Door(pnum, cmd, i); + break; + case OBJ_LEVER: + case OBJ_SWITCHSKL: + OperateLever(pnum, i); + break; + case OBJ_CHEST1: + case OBJ_CHEST2: + case OBJ_CHEST3: + case OBJ_TCHEST1: + case OBJ_TCHEST2: + case OBJ_TCHEST3: + OperateChest(pnum, i, 0); + break; + case OBJ_L2LDOOR: + case OBJ_L2RDOOR: + SyncOpL2Door(pnum, cmd, i); + break; + case OBJ_SARC: + OperateSarc(pnum, i, 0); + break; + case OBJ_SHRINEL: + case OBJ_SHRINER: + OperateShrine(pnum, i, IS_MAGIC); + break; + case OBJ_SKELBOOK: + case OBJ_BOOKSTAND: + OperateSkelBook(pnum, i, 0); + break; + case OBJ_BOOKCASEL: + case OBJ_BOOKCASER: + OperateBookCase(pnum, i, 0); + break; + case OBJ_DECAP: + OperateDecap(pnum, i, 0); + break; + case OBJ_BLINDBOOK: + case OBJ_BLOODBOOK: + case OBJ_STEELTOME: + OperateBookLever(pnum, i); + break; + case OBJ_PEDISTAL: + OperatePedistal(pnum, i); + break; + case OBJ_L3LDOOR: + case OBJ_L3RDOOR: + SyncOpL3Door(pnum, cmd, i); + break; + case OBJ_ARMORSTAND: + case OBJ_WARARMOR: + OperateArmorStand(pnum, i, 0); + break; + case OBJ_GOATSHRINE: + OperateGoatShrine(pnum, i, LS_GSHRINE); + break; + case OBJ_CAULDRON: + OperateCauldron(pnum, i, LS_CALDRON); + break; + case OBJ_MURKYFTN: + case OBJ_TEARFTN: + OperateFountains(pnum, i); + break; + case OBJ_STORYBOOK: + OperateStoryBook(pnum, i); + break; + case OBJ_WARWEAP: + case OBJ_WEAPONRACK: + OperateWeaponRack(pnum, i, 0); + break; + case OBJ_MUSHPATCH: + OperateMushPatch(pnum, i); + break; + case OBJ_SLAINHERO: + OperateSlainHero(pnum, i, 0); + break; + case OBJ_SIGNCHEST: + OperateInnSignChest(pnum, i); + break; + default: + return; + } } void __fastcall BreakCrux(int i) { - int v1; // esi - int v2; // edi - int v3; // edx - signed int v4; // eax - int v5; // ecx - int v6; // ebx + int v1; // esi + int v2; // edi + int v3; // edx + signed int v4; // eax + int v5; // ecx + int v6; // ebx - v1 = i; - v2 = nobjects; - object[v1]._oBreak = -1; - object[v1]._oSelFlag = 0; - v3 = 0; - v4 = 1; - object[v1]._oAnimFlag = 1; - object[v1]._oAnimFrame = 1; - object[v1]._oAnimDelay = 1; - object[v1]._oSolidFlag = TRUE; - object[v1]._oMissFlag = 1; - if (v2 <= 0) - goto LABEL_15; - do { - v5 = objectactive[v3]; - v6 = object[v5]._otype; - if ((v6 == OBJ_CRUX1 || v6 == OBJ_CRUX2 || v6 == OBJ_CRUX3) - && object[v1]._oVar8 == object[v5]._oVar8 - && object[v5]._oBreak != -1) { - v4 = 0; - } - ++v3; - } while (v3 < v2); - if (v4) { - LABEL_15: - if (!deltaload) - PlaySfxLoc(IS_LEVER, object[v1]._ox, object[v1]._oy); - ObjChangeMap(object[v1]._oVar1, object[v1]._oVar2, object[v1]._oVar3, object[v1]._oVar4); - } + v1 = i; + v2 = nobjects; + object[v1]._oBreak = -1; + object[v1]._oSelFlag = 0; + v3 = 0; + v4 = 1; + object[v1]._oAnimFlag = 1; + object[v1]._oAnimFrame = 1; + object[v1]._oAnimDelay = 1; + object[v1]._oSolidFlag = TRUE; + object[v1]._oMissFlag = 1; + if (v2 <= 0) + goto LABEL_15; + do { + v5 = objectactive[v3]; + v6 = object[v5]._otype; + if ((v6 == OBJ_CRUX1 || v6 == OBJ_CRUX2 || v6 == OBJ_CRUX3) + && object[v1]._oVar8 == object[v5]._oVar8 + && object[v5]._oBreak != -1) { + v4 = 0; + } + ++v3; + } while (v3 < v2); + if (v4) { + LABEL_15: + if (!deltaload) + PlaySfxLoc(IS_LEVER, object[v1]._ox, object[v1]._oy); + ObjChangeMap(object[v1]._oVar1, object[v1]._oVar2, object[v1]._oVar3, object[v1]._oVar4); + } } // 676190: using guessed type int deltaload; void __fastcall BreakBarrel(int pnum, int i, int dam, unsigned char forcebreak, int sendmsg) { - int v5; // esi - bool v6; // zf - int v7; // eax - int v8; // edx - int v9; // eax - int v10; // eax - int v11; // eax - char v12; // al - char v13; // al - int v14; // edx - int v15; // [esp-4h] [ebp-24h] - short param2; // [esp+Ch] [ebp-14h] - int param1; // [esp+10h] [ebp-10h] - int v18; // [esp+14h] [ebp-Ch] - int *v19; // [esp+18h] [ebp-8h] - int v20; // [esp+1Ch] [ebp-4h] - int forcebreaka; // [esp+2Ch] [ebp+Ch] + int v5; // esi + bool v6; // zf + int v7; // eax + int v8; // edx + int v9; // eax + int v10; // eax + int v11; // eax + char v12; // al + char v13; // al + int v14; // edx + int v15; // [esp-4h] [ebp-24h] + short param2; // [esp+Ch] [ebp-14h] + int param1; // [esp+10h] [ebp-10h] + int v18; // [esp+14h] [ebp-Ch] + int *v19; // [esp+18h] [ebp-8h] + int v20; // [esp+1Ch] [ebp-4h] + int forcebreaka; // [esp+2Ch] [ebp+Ch] - param2 = i; - v5 = i; - param1 = pnum; - if (object[i]._oSelFlag) { - if (forcebreak) { - object[v5]._oVar1 = 0; - } else { - object[v5]._oVar1 -= dam; - if (pnum != myplr && object[v5]._oVar1 <= 0) - object[v5]._oVar1 = 1; - } - if (object[v5]._oVar1 <= 0) { - object[v5]._oBreak = -1; - v6 = deltaload == 0; - object[v5]._oVar1 = 0; - object[v5]._oAnimFlag = 1; - object[v5]._oAnimFrame = 1; - object[v5]._oAnimDelay = 1; - object[v5]._oSolidFlag = FALSE; - object[v5]._oMissFlag = 1; - object[v5]._oSelFlag = 0; - object[v5]._oPreFlag = 1; - if (v6) { - v8 = object[v5]._ox; - v15 = object[v5]._oy; - if (object[v5]._otype == OBJ_BARRELEX) { - PlaySfxLoc(IS_BARLFIRE, v8, v15); - v9 = object[v5]._oy; - v20 = v9 - 1; - if (v9 - 1 <= v9 + 1) { - do { - v10 = object[v5]._ox; - v18 = v10 - 1; - if (v10 - 1 <= v10 + 1) { - forcebreaka = 112 * (v10 - 1) + v20; - v19 = (int *)((char *)dMonster + 4 * forcebreaka); - do { - v11 = *v19; - if (*v19 > 0) - MonsterTrapHit(v11 - 1, 1, 4, 0, 1, 0); - v12 = dPlayer[0][forcebreaka]; - if (v12 > 0) - PlayerMHit(v12 - 1, -1, 0, 8, 16, 1, 0, 0); - v13 = dObject[0][forcebreaka]; - if (v13 > 0) { - v14 = v13 - 1; - if (object[v14]._otype == OBJ_BARRELEX && object[v14]._oBreak != -1) - BreakBarrel(param1, v14, dam, 1u, sendmsg); - } - ++v18; - v19 += 112; - forcebreaka += 112; - } while (v18 <= object[v5]._ox + 1); - } - ++v20; - } while (v20 <= object[v5]._oy + 1); - } - } else { - PlaySfxLoc(IS_BARREL, v8, v15); - SetRndSeed(object[v5]._oRndSeed); - if (object[v5]._oVar2 <= 1) { - if (object[v5]._oVar3) - CreateRndItem(object[v5]._ox, object[v5]._oy, 0, sendmsg, 0); - else - CreateRndUseful(param1, object[v5]._ox, object[v5]._oy, sendmsg); - } - if (object[v5]._oVar2 >= 8) - SpawnSkeleton(object[v5]._oVar4, object[v5]._ox, object[v5]._oy); - } - if (param1 == myplr) - NetSendCmdParam2(FALSE, CMD_BREAKOBJ, param1, param2); - } else { - v7 = object[v5]._oAnimLen; - object[v5]._oAnimCnt = 0; - object[v5]._oAnimFrame = v7; - object[v5]._oAnimDelay = 1000; - } - } else if (!deltaload) { - PlaySfxLoc(IS_IBOW, object[v5]._ox, object[v5]._oy); - } - } + param2 = i; + v5 = i; + param1 = pnum; + if (object[i]._oSelFlag) { + if (forcebreak) { + object[v5]._oVar1 = 0; + } else { + object[v5]._oVar1 -= dam; + if (pnum != myplr && object[v5]._oVar1 <= 0) + object[v5]._oVar1 = 1; + } + if (object[v5]._oVar1 <= 0) { + object[v5]._oBreak = -1; + v6 = deltaload == 0; + object[v5]._oVar1 = 0; + object[v5]._oAnimFlag = 1; + object[v5]._oAnimFrame = 1; + object[v5]._oAnimDelay = 1; + object[v5]._oSolidFlag = FALSE; + object[v5]._oMissFlag = 1; + object[v5]._oSelFlag = 0; + object[v5]._oPreFlag = 1; + if (v6) { + v8 = object[v5]._ox; + v15 = object[v5]._oy; + if (object[v5]._otype == OBJ_BARRELEX) { + PlaySfxLoc(IS_BARLFIRE, v8, v15); + v9 = object[v5]._oy; + v20 = v9 - 1; + if (v9 - 1 <= v9 + 1) { + do { + v10 = object[v5]._ox; + v18 = v10 - 1; + if (v10 - 1 <= v10 + 1) { + forcebreaka = 112 * (v10 - 1) + v20; + v19 = (int *)((char *)dMonster + 4 * forcebreaka); + do { + v11 = *v19; + if (*v19 > 0) + MonsterTrapHit(v11 - 1, 1, 4, 0, 1, 0); + v12 = dPlayer[0][forcebreaka]; + if (v12 > 0) + PlayerMHit(v12 - 1, -1, 0, 8, 16, 1, 0, 0); + v13 = dObject[0][forcebreaka]; + if (v13 > 0) { + v14 = v13 - 1; + if (object[v14]._otype == OBJ_BARRELEX && object[v14]._oBreak != -1) + BreakBarrel(param1, v14, dam, 1u, sendmsg); + } + ++v18; + v19 += 112; + forcebreaka += 112; + } while (v18 <= object[v5]._ox + 1); + } + ++v20; + } while (v20 <= object[v5]._oy + 1); + } + } else { + PlaySfxLoc(IS_BARREL, v8, v15); + SetRndSeed(object[v5]._oRndSeed); + if (object[v5]._oVar2 <= 1) { + if (object[v5]._oVar3) + CreateRndItem(object[v5]._ox, object[v5]._oy, 0, sendmsg, 0); + else + CreateRndUseful(param1, object[v5]._ox, object[v5]._oy, sendmsg); + } + if (object[v5]._oVar2 >= 8) + SpawnSkeleton(object[v5]._oVar4, object[v5]._ox, object[v5]._oy); + } + if (param1 == myplr) + NetSendCmdParam2(FALSE, CMD_BREAKOBJ, param1, param2); + } else { + v7 = object[v5]._oAnimLen; + object[v5]._oAnimCnt = 0; + object[v5]._oAnimFrame = v7; + object[v5]._oAnimDelay = 1000; + } + } else if (!deltaload) { + PlaySfxLoc(IS_IBOW, object[v5]._ox, object[v5]._oy); + } + } } // 676190: using guessed type int deltaload; void __fastcall BreakObject(int pnum, int oi) { - int v2; // ebx - int v3; // ebp - int v4; // esi - int v5; // edi - int v6; // ecx - int v7; // ecx - int v8; // eax + int v2; // ebx + int v3; // ebp + int v4; // esi + int v5; // edi + int v6; // ecx + int v7; // ecx + int v8; // eax - v2 = pnum; - v3 = oi; - if (pnum == -1) { - v7 = 10; - } else { - v4 = pnum; - v5 = plr[v2]._pIMinDam; - v6 = v5 + random(163, plr[v2]._pIMaxDam - v5 + 1); - v7 = plr[v4]._pIBonusDamMod + plr[v4]._pDamageMod + v6 * plr[v4]._pIBonusDam / 100 + v6; - } - v8 = object[v3]._otype; - if (v8 >= OBJ_CRUX1) { - if (v8 <= OBJ_CRUX3) { - BreakCrux(v3); - } else if (v8 > OBJ_WEAPRACK && v8 <= OBJ_BARRELEX) { - BreakBarrel(v2, v3, v7, 0, 1); - } - } + v2 = pnum; + v3 = oi; + if (pnum == -1) { + v7 = 10; + } else { + v4 = pnum; + v5 = plr[v2]._pIMinDam; + v6 = v5 + random(163, plr[v2]._pIMaxDam - v5 + 1); + v7 = plr[v4]._pIBonusDamMod + plr[v4]._pDamageMod + v6 * plr[v4]._pIBonusDam / 100 + v6; + } + v8 = object[v3]._otype; + if (v8 >= OBJ_CRUX1) { + if (v8 <= OBJ_CRUX3) { + BreakCrux(v3); + } else if (v8 > OBJ_WEAPRACK && v8 <= OBJ_BARRELEX) { + BreakBarrel(v2, v3, v7, 0, 1); + } + } } void __fastcall SyncBreakObj(int pnum, int oi) { - int v2; // eax + int v2; // eax - v2 = object[oi]._otype; - if (v2 >= OBJ_BARREL && v2 <= OBJ_BARRELEX) - BreakBarrel(pnum, oi, 0, 1u, 0); + v2 = object[oi]._otype; + if (v2 >= OBJ_BARREL && v2 <= OBJ_BARRELEX) + BreakBarrel(pnum, oi, 0, 1u, 0); } void __fastcall SyncL1Doors(int i) { - int v1; // ebx - int v2; // eax - int v3; // esi - int v4; // edi - bool v5; // zf + int v1; // ebx + int v2; // eax + int v3; // esi + int v4; // edi + bool v5; // zf - v1 = i; - v2 = i; - if (object[i]._oVar4) { - v3 = object[v2]._oy; - v4 = object[v2]._ox; - v5 = object[v2]._otype == 1; - object[v2]._oMissFlag = 1; - object[v2]._oSelFlag = 2; - if (v5) { - if (object[v2]._oVar1 == 214) - ObjSetMicro(v4, v3, 408); - else - ObjSetMicro(v4, v3, 393); - dArch[v4][v3] = 7; - objects_set_door_piece(v4 - 1, v3--); - } else { - ObjSetMicro(v4, v3, 395); - dArch[v4][v3] = 8; - objects_set_door_piece(v4--, v3 - 1); - } - DoorSet(v1, v4, v3); - } else { - object[v2]._oMissFlag = 0; - } + v1 = i; + v2 = i; + if (object[i]._oVar4) { + v3 = object[v2]._oy; + v4 = object[v2]._ox; + v5 = object[v2]._otype == 1; + object[v2]._oMissFlag = 1; + object[v2]._oSelFlag = 2; + if (v5) { + if (object[v2]._oVar1 == 214) + ObjSetMicro(v4, v3, 408); + else + ObjSetMicro(v4, v3, 393); + dArch[v4][v3] = 7; + objects_set_door_piece(v4 - 1, v3--); + } else { + ObjSetMicro(v4, v3, 395); + dArch[v4][v3] = 8; + objects_set_door_piece(v4--, v3 - 1); + } + DoorSet(v1, v4, v3); + } else { + object[v2]._oMissFlag = 0; + } } void __fastcall SyncCrux(int i) { - signed int v1; // ebx - int v2; // edx - int v3; // eax - int v4; // esi + signed int v1; // ebx + int v2; // edx + int v3; // eax + int v4; // esi - v1 = 1; - v2 = 0; - if (nobjects <= 0) - goto LABEL_13; - do { - v3 = objectactive[v2]; - v4 = object[v3]._otype; - if ((v4 == OBJ_CRUX1 || v4 == OBJ_CRUX2 || v4 == OBJ_CRUX3) - && object[i]._oVar8 == object[v3]._oVar8 - && object[v3]._oBreak != -1) { - v1 = 0; - } - ++v2; - } while (v2 < nobjects); - if (v1) - LABEL_13: - ObjChangeMap(object[i]._oVar1, object[i]._oVar2, object[i]._oVar3, object[i]._oVar4); + v1 = 1; + v2 = 0; + if (nobjects <= 0) + goto LABEL_13; + do { + v3 = objectactive[v2]; + v4 = object[v3]._otype; + if ((v4 == OBJ_CRUX1 || v4 == OBJ_CRUX2 || v4 == OBJ_CRUX3) + && object[i]._oVar8 == object[v3]._oVar8 + && object[v3]._oBreak != -1) { + v1 = 0; + } + ++v2; + } while (v2 < nobjects); + if (v1) + LABEL_13: + ObjChangeMap(object[i]._oVar1, object[i]._oVar2, object[i]._oVar3, object[i]._oVar4); } void __fastcall SyncLever(int i) { - int v1; // ecx + int v1; // ecx - v1 = i; - if (!object[v1]._oSelFlag) - ObjChangeMap(object[v1]._oVar1, object[v1]._oVar2, object[v1]._oVar3, object[v1]._oVar4); + v1 = i; + if (!object[v1]._oSelFlag) + ObjChangeMap(object[v1]._oVar1, object[v1]._oVar2, object[v1]._oVar3, object[v1]._oVar4); } void __fastcall SyncQSTLever(int i) { - int v1; // esi - int v2; // edx - int v3; // ecx - int v4; // ST04_4 - char v5; // bl - int v6; // ST00_4 + int v1; // esi + int v2; // edx + int v3; // ecx + int v4; // ST04_4 + char v5; // bl + int v6; // ST00_4 - v1 = i; - if (object[i]._oAnimFrame == object[i]._oVar6) { - ObjChangeMapResync(object[v1]._oVar1, object[v1]._oVar2, object[v1]._oVar3, object[v1]._oVar4); - if (object[v1]._otype == OBJ_BLINDBOOK) { - v2 = object[v1]._oVar2; - v3 = object[v1]._oVar1; - v4 = object[v1]._oVar4; - v5 = TransVal; - v6 = object[v1]._oVar3; - TransVal = 9; - DRLG_MRectTrans(v3, v2, v6, v4); - TransVal = v5; - } - } + v1 = i; + if (object[i]._oAnimFrame == object[i]._oVar6) { + ObjChangeMapResync(object[v1]._oVar1, object[v1]._oVar2, object[v1]._oVar3, object[v1]._oVar4); + if (object[v1]._otype == OBJ_BLINDBOOK) { + v2 = object[v1]._oVar2; + v3 = object[v1]._oVar1; + v4 = object[v1]._oVar4; + v5 = TransVal; + v6 = object[v1]._oVar3; + TransVal = 9; + DRLG_MRectTrans(v3, v2, v6, v4); + TransVal = v5; + } + } } // 5A5590: using guessed type char TransVal; void __fastcall SyncPedistal(int i) { - int v1; // esi - unsigned char *v2; // esi + int v1; // esi + unsigned char *v2; // esi - v1 = i; - if (object[i]._oVar6 == 1) - ObjChangeMapResync(setpc_x, setpc_y + 3, setpc_x + 2, setpc_y + 7); - if (object[v1]._oVar6 == 2) { - ObjChangeMapResync(setpc_x, setpc_y + 3, setpc_x + 2, setpc_y + 7); - ObjChangeMapResync(setpc_x + 6, setpc_y + 3, setpc_x + setpc_w, setpc_y + 7); - } - if (object[v1]._oVar6 == 3) { - ObjChangeMapResync(object[v1]._oVar1, object[v1]._oVar2, object[v1]._oVar3, object[v1]._oVar4); - v2 = LoadFileInMem("Levels\\L2Data\\Blood2.DUN", 0); - LoadMapObjs(v2, 2 * setpc_x, 2 * setpc_y); - mem_free_dbg(v2); - } + v1 = i; + if (object[i]._oVar6 == 1) + ObjChangeMapResync(setpc_x, setpc_y + 3, setpc_x + 2, setpc_y + 7); + if (object[v1]._oVar6 == 2) { + ObjChangeMapResync(setpc_x, setpc_y + 3, setpc_x + 2, setpc_y + 7); + ObjChangeMapResync(setpc_x + 6, setpc_y + 3, setpc_x + setpc_w, setpc_y + 7); + } + if (object[v1]._oVar6 == 3) { + ObjChangeMapResync(object[v1]._oVar1, object[v1]._oVar2, object[v1]._oVar3, object[v1]._oVar4); + v2 = LoadFileInMem("Levels\\L2Data\\Blood2.DUN", 0); + LoadMapObjs(v2, 2 * setpc_x, 2 * setpc_y); + mem_free_dbg(v2); + } } // 5CF334: using guessed type int setpc_w; void __fastcall SyncL2Doors(int i) { - int v1; // eax - int v2; // esi - int v3; // ecx - int v4; // edx - int v5; // eax + int v1; // eax + int v2; // esi + int v3; // ecx + int v4; // edx + int v5; // eax - v1 = i; - v2 = object[i]._oVar4; - if (v2) - object[v1]._oMissFlag = 1; - else - object[v1]._oMissFlag = 0; - v3 = object[v1]._ox; - v4 = object[v1]._oy; - object[v1]._oSelFlag = 2; - v5 = object[v1]._otype; - if (v5 != OBJ_L2LDOOR) - goto LABEL_18; - if (!v2) { - ObjSetMicro(v3, v4, 538); - return; - } - if (v2 != 1 && v2 != 2) { - LABEL_18: - if (v5 == OBJ_L2RDOOR) { - if (v2) { - if (v2 == 1 || v2 == 2) - ObjSetMicro(v3, v4, 17); - } else { - ObjSetMicro(v3, v4, 540); - } - } - } else { - ObjSetMicro(v3, v4, 13); - } + v1 = i; + v2 = object[i]._oVar4; + if (v2) + object[v1]._oMissFlag = 1; + else + object[v1]._oMissFlag = 0; + v3 = object[v1]._ox; + v4 = object[v1]._oy; + object[v1]._oSelFlag = 2; + v5 = object[v1]._otype; + if (v5 != OBJ_L2LDOOR) + goto LABEL_18; + if (!v2) { + ObjSetMicro(v3, v4, 538); + return; + } + if (v2 != 1 && v2 != 2) { + LABEL_18: + if (v5 == OBJ_L2RDOOR) { + if (v2) { + if (v2 == 1 || v2 == 2) + ObjSetMicro(v3, v4, 17); + } else { + ObjSetMicro(v3, v4, 540); + } + } + } else { + ObjSetMicro(v3, v4, 13); + } } void __fastcall SyncL3Doors(int i) { - int v1; // eax - int v2; // esi - int v3; // ecx - int v4; // edx - int v5; // ebx - int v6; // eax + int v1; // eax + int v2; // esi + int v3; // ecx + int v4; // edx + int v5; // ebx + int v6; // eax - v1 = i; - v2 = object[i]._otype; - v3 = object[i]._ox; - v4 = object[v1]._oy; - object[v1]._oMissFlag = 1; - object[v1]._oSelFlag = 2; - if (v2 != OBJ_L3LDOOR) - goto LABEL_15; - if (!object[v1]._oVar4) { - ObjSetMicro(v3, v4, 531); - return; - } - v5 = object[v1]._oVar4; - if (v5 != 1 && v5 != 2) { - LABEL_15: - if (v2 == OBJ_L3RDOOR) { - if (object[v1]._oVar4) { - v6 = object[v1]._oVar4; - if (v6 == 1 || v6 == 2) - ObjSetMicro(v3, v4, 541); - } else { - ObjSetMicro(v3, v4, 534); - } - } - } else { - ObjSetMicro(v3, v4, 538); - } + v1 = i; + v2 = object[i]._otype; + v3 = object[i]._ox; + v4 = object[v1]._oy; + object[v1]._oMissFlag = 1; + object[v1]._oSelFlag = 2; + if (v2 != OBJ_L3LDOOR) + goto LABEL_15; + if (!object[v1]._oVar4) { + ObjSetMicro(v3, v4, 531); + return; + } + v5 = object[v1]._oVar4; + if (v5 != 1 && v5 != 2) { + LABEL_15: + if (v2 == OBJ_L3RDOOR) { + if (object[v1]._oVar4) { + v6 = object[v1]._oVar4; + if (v6 == 1 || v6 == 2) + ObjSetMicro(v3, v4, 541); + } else { + ObjSetMicro(v3, v4, 534); + } + } + } else { + ObjSetMicro(v3, v4, 538); + } } void __fastcall SyncObjectAnim(int o) { - int v1; // edx - int v2; // ebx - int v3; // esi + int v1; // edx + int v2; // ebx + int v3; // esi - v1 = object[o]._otype; - v2 = ObjFileList[0]; - v3 = 0; - while (v2 != (char)AllObjects[object[o]._otype].ofindex) - v2 = ObjFileList[v3++ + 1]; - object[o]._oAnimData = pObjCels[v3]; - if (v1 <= OBJ_BOOK2R) { - if (v1 != OBJ_BOOK2R) { - if (v1 > OBJ_L1LIGHT) { - if (v1 <= OBJ_L1RDOOR) { - SyncL1Doors(o); - } else { - if (v1 == OBJ_LEVER) - goto LABEL_30; - if (v1 > OBJ_SKSTICK5) { - if (v1 <= OBJ_CRUX3) { - SyncCrux(o); - return; - } - if (v1 == OBJ_BOOK2L || v1 == OBJ_SWITCHSKL) - LABEL_30: - SyncLever(o); - } - } - } - return; - } - LABEL_24: - SyncQSTLever(o); - return; - } - if (v1 >= OBJ_L2LDOOR) { - if (v1 <= OBJ_L2RDOOR) { - SyncL2Doors(o); - return; - } - if (v1 == OBJ_BLINDBOOK) - goto LABEL_24; - if (v1 == OBJ_PEDISTAL) { - SyncPedistal(o); - return; - } - if (v1 > OBJ_PEDISTAL) { - if (v1 <= OBJ_L3RDOOR) { - SyncL3Doors(o); - return; - } - if (v1 == OBJ_STEELTOME) - goto LABEL_24; - } - } + v1 = object[o]._otype; + v2 = ObjFileList[0]; + v3 = 0; + while (v2 != (char)AllObjects[object[o]._otype].ofindex) + v2 = ObjFileList[v3++ + 1]; + object[o]._oAnimData = pObjCels[v3]; + if (v1 <= OBJ_BOOK2R) { + if (v1 != OBJ_BOOK2R) { + if (v1 > OBJ_L1LIGHT) { + if (v1 <= OBJ_L1RDOOR) { + SyncL1Doors(o); + } else { + if (v1 == OBJ_LEVER) + goto LABEL_30; + if (v1 > OBJ_SKSTICK5) { + if (v1 <= OBJ_CRUX3) { + SyncCrux(o); + return; + } + if (v1 == OBJ_BOOK2L || v1 == OBJ_SWITCHSKL) + LABEL_30: + SyncLever(o); + } + } + } + return; + } + LABEL_24: + SyncQSTLever(o); + return; + } + if (v1 >= OBJ_L2LDOOR) { + if (v1 <= OBJ_L2RDOOR) { + SyncL2Doors(o); + return; + } + if (v1 == OBJ_BLINDBOOK) + goto LABEL_24; + if (v1 == OBJ_PEDISTAL) { + SyncPedistal(o); + return; + } + if (v1 > OBJ_PEDISTAL) { + if (v1 <= OBJ_L3RDOOR) { + SyncL3Doors(o); + return; + } + if (v1 == OBJ_STEELTOME) + goto LABEL_24; + } + } } void __fastcall GetObjectStr(int i) { - int v1; // edi + int v1; // edi - v1 = i; - switch (object[i]._otype) { - case OBJ_L1LDOOR: - case OBJ_L1RDOOR: - case OBJ_L2LDOOR: - case OBJ_L2RDOOR: - case OBJ_L3LDOOR: - case OBJ_L3RDOOR: - if (object[v1]._oVar4 == 1) - strcpy(infostr, "Open Door"); - if (!object[v1]._oVar4) - strcpy(infostr, "Closed Door"); - if (object[v1]._oVar4 == 2) - strcpy(infostr, "Blocked Door"); - break; - case OBJ_LEVER: - case OBJ_FLAMELVR: - strcpy(infostr, "Lever"); - break; - case OBJ_CHEST1: - case OBJ_TCHEST1: - strcpy(infostr, "Small Chest"); - break; - case OBJ_CHEST2: - case OBJ_TCHEST2: - strcpy(infostr, "Chest"); - break; - case OBJ_CHEST3: - case OBJ_TCHEST3: - case OBJ_SIGNCHEST: - strcpy(infostr, "Large Chest"); - break; - case OBJ_CRUX1: - case OBJ_CRUX2: - case OBJ_CRUX3: - strcpy(infostr, "Crucified Skeleton"); - break; - case OBJ_BOOK2L: - if (setlevel) { - if (setlvlnum == SL_BONECHAMB) { - strcpy(infostr, "Ancient Tome"); - } else if (setlvlnum == SL_VILEBETRAYER) { - strcpy(infostr, "Book of Vileness"); - } - } - break; - case OBJ_SWITCHSKL: - strcpy(infostr, "Skull Lever"); - break; - case OBJ_BOOK2R: - strcpy(infostr, "Mythical Book"); - break; - case OBJ_SARC: - strcpy(infostr, "Sarcophagus"); - break; - case OBJ_BOOKSHELF: - strcpy(infostr, "Bookshelf"); - break; - case OBJ_BARREL: - case OBJ_BARRELEX: - strcpy(infostr, "Barrel"); - break; - case OBJ_SHRINEL: - case OBJ_SHRINER: - sprintf(tempstr, "%s Shrine", shrinestrs[object[v1]._oVar1]); - strcpy(infostr, tempstr); - break; - case OBJ_SKELBOOK: - strcpy(infostr, "Skeleton Tome"); - break; - case OBJ_BOOKCASEL: - case OBJ_BOOKCASER: - strcpy(infostr, "Bookcase"); - break; - case OBJ_BOOKSTAND: - strcpy(infostr, "Library Book"); - break; - case OBJ_BLOODFTN: - strcpy(infostr, "Blood Fountain"); - break; - case OBJ_DECAP: - strcpy(infostr, "Decapitated Body"); - break; - case OBJ_BLINDBOOK: - strcpy(infostr, "Book of the Blind"); - break; - case OBJ_BLOODBOOK: - strcpy(infostr, "Book of Blood"); - break; - case OBJ_PEDISTAL: - strcpy(infostr, "Pedestal of Blood"); - break; - case OBJ_PURIFYINGFTN: - strcpy(infostr, "Purifying Spring"); - break; - case OBJ_ARMORSTAND: - case OBJ_WARARMOR: - strcpy(infostr, "Armor"); - break; - case OBJ_GOATSHRINE: - strcpy(infostr, "Goat Shrine"); - break; - case OBJ_CAULDRON: - strcpy(infostr, "Cauldron"); - break; - case OBJ_MURKYFTN: - strcpy(infostr, "Murky Pool"); - break; - case OBJ_TEARFTN: - strcpy(infostr, "Fountain of Tears"); - break; - case OBJ_STORYBOOK: - strcpy(infostr, StoryBookName[object[v1]._oVar3]); - break; - case OBJ_STEELTOME: - strcpy(infostr, "Steel Tome"); - break; - case OBJ_WARWEAP: - case OBJ_WEAPONRACK: - strcpy(infostr, "Weapon Rack"); - break; - case OBJ_MUSHPATCH: - strcpy(infostr, "Mushroom Patch"); - break; - case OBJ_LAZSTAND: - strcpy(infostr, "Vile Stand"); - break; - case OBJ_SLAINHERO: - strcpy(infostr, "Slain Hero"); - break; - default: - break; - } - if (plr[myplr]._pClass == PC_ROGUE) { - if (object[v1]._oTrapFlag) { - sprintf(tempstr, "Trapped %s", infostr); - strcpy(infostr, tempstr); - infoclr = COL_RED; - } - } + v1 = i; + switch (object[i]._otype) { + case OBJ_L1LDOOR: + case OBJ_L1RDOOR: + case OBJ_L2LDOOR: + case OBJ_L2RDOOR: + case OBJ_L3LDOOR: + case OBJ_L3RDOOR: + if (object[v1]._oVar4 == 1) + strcpy(infostr, "Open Door"); + if (!object[v1]._oVar4) + strcpy(infostr, "Closed Door"); + if (object[v1]._oVar4 == 2) + strcpy(infostr, "Blocked Door"); + break; + case OBJ_LEVER: + case OBJ_FLAMELVR: + strcpy(infostr, "Lever"); + break; + case OBJ_CHEST1: + case OBJ_TCHEST1: + strcpy(infostr, "Small Chest"); + break; + case OBJ_CHEST2: + case OBJ_TCHEST2: + strcpy(infostr, "Chest"); + break; + case OBJ_CHEST3: + case OBJ_TCHEST3: + case OBJ_SIGNCHEST: + strcpy(infostr, "Large Chest"); + break; + case OBJ_CRUX1: + case OBJ_CRUX2: + case OBJ_CRUX3: + strcpy(infostr, "Crucified Skeleton"); + break; + case OBJ_BOOK2L: + if (setlevel) { + if (setlvlnum == SL_BONECHAMB) { + strcpy(infostr, "Ancient Tome"); + } else if (setlvlnum == SL_VILEBETRAYER) { + strcpy(infostr, "Book of Vileness"); + } + } + break; + case OBJ_SWITCHSKL: + strcpy(infostr, "Skull Lever"); + break; + case OBJ_BOOK2R: + strcpy(infostr, "Mythical Book"); + break; + case OBJ_SARC: + strcpy(infostr, "Sarcophagus"); + break; + case OBJ_BOOKSHELF: + strcpy(infostr, "Bookshelf"); + break; + case OBJ_BARREL: + case OBJ_BARRELEX: + strcpy(infostr, "Barrel"); + break; + case OBJ_SHRINEL: + case OBJ_SHRINER: + sprintf(tempstr, "%s Shrine", shrinestrs[object[v1]._oVar1]); + strcpy(infostr, tempstr); + break; + case OBJ_SKELBOOK: + strcpy(infostr, "Skeleton Tome"); + break; + case OBJ_BOOKCASEL: + case OBJ_BOOKCASER: + strcpy(infostr, "Bookcase"); + break; + case OBJ_BOOKSTAND: + strcpy(infostr, "Library Book"); + break; + case OBJ_BLOODFTN: + strcpy(infostr, "Blood Fountain"); + break; + case OBJ_DECAP: + strcpy(infostr, "Decapitated Body"); + break; + case OBJ_BLINDBOOK: + strcpy(infostr, "Book of the Blind"); + break; + case OBJ_BLOODBOOK: + strcpy(infostr, "Book of Blood"); + break; + case OBJ_PEDISTAL: + strcpy(infostr, "Pedestal of Blood"); + break; + case OBJ_PURIFYINGFTN: + strcpy(infostr, "Purifying Spring"); + break; + case OBJ_ARMORSTAND: + case OBJ_WARARMOR: + strcpy(infostr, "Armor"); + break; + case OBJ_GOATSHRINE: + strcpy(infostr, "Goat Shrine"); + break; + case OBJ_CAULDRON: + strcpy(infostr, "Cauldron"); + break; + case OBJ_MURKYFTN: + strcpy(infostr, "Murky Pool"); + break; + case OBJ_TEARFTN: + strcpy(infostr, "Fountain of Tears"); + break; + case OBJ_STORYBOOK: + strcpy(infostr, StoryBookName[object[v1]._oVar3]); + break; + case OBJ_STEELTOME: + strcpy(infostr, "Steel Tome"); + break; + case OBJ_WARWEAP: + case OBJ_WEAPONRACK: + strcpy(infostr, "Weapon Rack"); + break; + case OBJ_MUSHPATCH: + strcpy(infostr, "Mushroom Patch"); + break; + case OBJ_LAZSTAND: + strcpy(infostr, "Vile Stand"); + break; + case OBJ_SLAINHERO: + strcpy(infostr, "Slain Hero"); + break; + default: + break; + } + if (plr[myplr]._pClass == PC_ROGUE) { + if (object[v1]._oTrapFlag) { + sprintf(tempstr, "Trapped %s", infostr); + strcpy(infostr, tempstr); + infoclr = COL_RED; + } + } } // 4B883C: using guessed type int infoclr; // 5CF31D: using guessed type char setlevel; diff --git a/Source/pack.cpp b/Source/pack.cpp index 0cb0e136..b49f6ce2 100644 --- a/Source/pack.cpp +++ b/Source/pack.cpp @@ -7,261 +7,261 @@ int pack_cpp_init_value; // weak const int pack_inf = 0x7F800000; // weak struct pack_cpp_init { - pack_cpp_init() - { - pack_cpp_init_value = pack_inf; - } + pack_cpp_init() + { + pack_cpp_init_value = pack_inf; + } } _pack_cpp_init; // 47F168: using guessed type int pack_inf; // 67D7C8: using guessed type int pack_cpp_init_value; void __fastcall PackPlayer(PkPlayerStruct *pPack, int pnum, BOOL manashield) { - PlayerStruct *pPlayer; // edi - int i; // [esp+8h] [ebp-Ch] - ItemStruct *pi; // [esp+Ch] [ebp-8h] - PkItemStruct *pki; // [esp+10h] [ebp-4h] + PlayerStruct *pPlayer; // edi + int i; // [esp+8h] [ebp-Ch] + ItemStruct *pi; // [esp+Ch] [ebp-8h] + PkItemStruct *pki; // [esp+10h] [ebp-4h] - memset(pPack, 0, 0x4F2); - pPlayer = &plr[pnum]; - pPack->destAction = pPlayer->destAction; - pPack->destParam1 = pPlayer->destParam1; - pPack->destParam2 = pPlayer->destParam2; - pPack->plrlevel = pPlayer->plrlevel; - pPack->px = pPlayer->WorldX; - pPack->py = pPlayer->WorldY; - pPack->targx = pPlayer->_ptargx; - pPack->targy = pPlayer->_ptargy; - strcpy(pPack->pName, pPlayer->_pName); - pPack->pClass = pPlayer->_pClass; - pPack->pBaseStr = pPlayer->_pBaseStr; - pPack->pBaseMag = pPlayer->_pBaseMag; - pPack->pBaseDex = pPlayer->_pBaseDex; - pPack->pBaseVit = pPlayer->_pBaseVit; - pPack->pLevel = pPlayer->_pLevel; - pPack->pStatPts = pPlayer->_pStatPts; - pPack->pExperience = pPlayer->_pExperience; - pPack->pGold = pPlayer->_pGold; - pPack->pHPBase = pPlayer->_pHPBase; - pPack->pMaxHPBase = pPlayer->_pMaxHPBase; - pPack->pManaBase = pPlayer->_pManaBase; - pPack->pMaxManaBase = pPlayer->_pMaxManaBase; - pPack->pMemSpells = pPlayer->_pMemSpells; + memset(pPack, 0, 0x4F2); + pPlayer = &plr[pnum]; + pPack->destAction = pPlayer->destAction; + pPack->destParam1 = pPlayer->destParam1; + pPack->destParam2 = pPlayer->destParam2; + pPack->plrlevel = pPlayer->plrlevel; + pPack->px = pPlayer->WorldX; + pPack->py = pPlayer->WorldY; + pPack->targx = pPlayer->_ptargx; + pPack->targy = pPlayer->_ptargy; + strcpy(pPack->pName, pPlayer->_pName); + pPack->pClass = pPlayer->_pClass; + pPack->pBaseStr = pPlayer->_pBaseStr; + pPack->pBaseMag = pPlayer->_pBaseMag; + pPack->pBaseDex = pPlayer->_pBaseDex; + pPack->pBaseVit = pPlayer->_pBaseVit; + pPack->pLevel = pPlayer->_pLevel; + pPack->pStatPts = pPlayer->_pStatPts; + pPack->pExperience = pPlayer->_pExperience; + pPack->pGold = pPlayer->_pGold; + pPack->pHPBase = pPlayer->_pHPBase; + pPack->pMaxHPBase = pPlayer->_pMaxHPBase; + pPack->pManaBase = pPlayer->_pManaBase; + pPack->pMaxManaBase = pPlayer->_pMaxManaBase; + pPack->pMemSpells = pPlayer->_pMemSpells; - for (i = 0; i < MAX_SPELLS; i++) - pPack->pSplLvl[i] = pPlayer->_pSplLvl[i]; + for (i = 0; i < MAX_SPELLS; i++) + pPack->pSplLvl[i] = pPlayer->_pSplLvl[i]; - pki = pPack->InvBody; - pi = pPlayer->InvBody; + pki = pPack->InvBody; + pi = pPlayer->InvBody; - for (i = 0; i < 7; i++) - PackItem(pki++, pi++); + for (i = 0; i < 7; i++) + PackItem(pki++, pi++); - pki = pPack->InvList; - pi = pPlayer->InvList; + pki = pPack->InvList; + pi = pPlayer->InvList; - for (i = 0; i < 40; i++) - PackItem(pki++, pi++); + for (i = 0; i < 40; i++) + PackItem(pki++, pi++); - for (i = 0; i < 40; i++) - pPack->InvGrid[i] = pPlayer->InvGrid[i]; + for (i = 0; i < 40; i++) + pPack->InvGrid[i] = pPlayer->InvGrid[i]; - pPack->_pNumInv = pPlayer->_pNumInv; - pki = pPack->SpdList; - pi = pPlayer->SpdList; + pPack->_pNumInv = pPlayer->_pNumInv; + pki = pPack->SpdList; + pi = pPlayer->SpdList; - for (i = 0; i < MAXBELTITEMS; i++) - PackItem(pki++, pi++); + for (i = 0; i < MAXBELTITEMS; i++) + PackItem(pki++, pi++); - pPack->pDiabloKillLevel = pPlayer->pDiabloKillLevel; + pPack->pDiabloKillLevel = pPlayer->pDiabloKillLevel; - if (gbMaxPlayers == 1 || manashield) - pPack->pManaShield = pPlayer->pManaShield; - else - pPack->pManaShield = 0; + if (gbMaxPlayers == 1 || manashield) + pPack->pManaShield = pPlayer->pManaShield; + else + pPack->pManaShield = 0; } // 679660: using guessed type char gbMaxPlayers; void __fastcall PackItem(PkItemStruct *id, ItemStruct *is) { - short v2; // ax - short v3; // bx + short v2; // ax + short v3; // bx - if (is->_itype == -1) { - id->idx = -1; - } else { - id->idx = is->IDidx; - if (is->IDidx == IDI_EAR) { - _LOBYTE(v2) = 0; - _LOBYTE(v3) = 0; - _HIBYTE(v2) = is->_iName[7]; - id->iCreateInfo = is->_iName[8] | v2; - id->iSeed = is->_iName[12] | ((is->_iName[11] | ((is->_iName[10] | (is->_iName[9] << 8)) << 8)) << 8); - id->bId = is->_iName[13]; - id->bDur = is->_iName[14]; - id->bMDur = is->_iName[15]; - id->bCh = is->_iName[16]; - id->bMCh = is->_iName[17]; - _HIBYTE(v3) = is->_iName[18]; - id->wValue = _LOWORD(is->_ivalue) | v3 | ((_LOWORD(is->_iCurs) - 19) << 6); - id->dwBuff = is->_iName[22] | ((is->_iName[21] | ((is->_iName[20] | (is->_iName[19] << 8)) << 8)) << 8); - } else { - id->iSeed = is->_iSeed; - id->iCreateInfo = is->_iCreateInfo; - id->bId = _LOBYTE(is->_iIdentified) + 2 * is->_iMagical; - id->bDur = is->_iDurability; - id->bMDur = is->_iMaxDur; - id->bCh = is->_iCharges; - id->bMCh = is->_iMaxCharges; - if (!is->IDidx) - id->wValue = is->_ivalue; - } - } + if (is->_itype == -1) { + id->idx = -1; + } else { + id->idx = is->IDidx; + if (is->IDidx == IDI_EAR) { + _LOBYTE(v2) = 0; + _LOBYTE(v3) = 0; + _HIBYTE(v2) = is->_iName[7]; + id->iCreateInfo = is->_iName[8] | v2; + id->iSeed = is->_iName[12] | ((is->_iName[11] | ((is->_iName[10] | (is->_iName[9] << 8)) << 8)) << 8); + id->bId = is->_iName[13]; + id->bDur = is->_iName[14]; + id->bMDur = is->_iName[15]; + id->bCh = is->_iName[16]; + id->bMCh = is->_iName[17]; + _HIBYTE(v3) = is->_iName[18]; + id->wValue = _LOWORD(is->_ivalue) | v3 | ((_LOWORD(is->_iCurs) - 19) << 6); + id->dwBuff = is->_iName[22] | ((is->_iName[21] | ((is->_iName[20] | (is->_iName[19] << 8)) << 8)) << 8); + } else { + id->iSeed = is->_iSeed; + id->iCreateInfo = is->_iCreateInfo; + id->bId = _LOBYTE(is->_iIdentified) + 2 * is->_iMagical; + id->bDur = is->_iDurability; + id->bMDur = is->_iMaxDur; + id->bCh = is->_iCharges; + id->bMCh = is->_iMaxCharges; + if (!is->IDidx) + id->wValue = is->_ivalue; + } + } } void __fastcall VerifyGoldSeeds(PlayerStruct *pPlayer) { - int i; // ebp - int j; // ecx + int i; // ebp + int j; // ecx - for (i = 0; i < pPlayer->_pNumInv; i++) { - if (pPlayer->InvList[i].IDidx == IDI_GOLD && pPlayer->_pNumInv > 0) { - for (j = 0; j < pPlayer->_pNumInv; j++) { - if (i != j) { - if (pPlayer->InvList[j].IDidx == IDI_GOLD && pPlayer->InvList[i]._iSeed == pPlayer->InvList[j]._iSeed) { - pPlayer->InvList[i]._iSeed = GetRndSeed(); - j = -1; - } - } - } - } - } + for (i = 0; i < pPlayer->_pNumInv; i++) { + if (pPlayer->InvList[i].IDidx == IDI_GOLD && pPlayer->_pNumInv > 0) { + for (j = 0; j < pPlayer->_pNumInv; j++) { + if (i != j) { + if (pPlayer->InvList[j].IDidx == IDI_GOLD && pPlayer->InvList[i]._iSeed == pPlayer->InvList[j]._iSeed) { + pPlayer->InvList[i]._iSeed = GetRndSeed(); + j = -1; + } + } + } + } + } } void __fastcall UnPackPlayer(PkPlayerStruct *pPack, int pnum, bool killok) { - PlayerStruct *pPlayer; // esi - signed int v6; // eax - int i; // [esp+10h] [ebp-8h] - ItemStruct *pi; // [esp+14h] [ebp-4h] - PkItemStruct *pki; // [esp+20h] [ebp+8h] + PlayerStruct *pPlayer; // esi + signed int v6; // eax + int i; // [esp+10h] [ebp-8h] + ItemStruct *pi; // [esp+14h] [ebp-4h] + PkItemStruct *pki; // [esp+20h] [ebp+8h] - pPlayer = &plr[pnum]; - ClearPlrRVars(&plr[pnum]); - pPlayer->WorldX = (unsigned char)pPack->px; - pPlayer->WorldY = (unsigned char)pPack->py; - pPlayer->_px = (unsigned char)pPack->px; - pPlayer->_py = (unsigned char)pPack->py; - pPlayer->_ptargx = (unsigned char)pPack->targx; - pPlayer->_ptargy = (unsigned char)pPack->targy; - pPlayer->plrlevel = (unsigned char)pPack->plrlevel; - ClrPlrPath(pnum); - pPlayer->destAction = ACTION_NONE; - strcpy(pPlayer->_pName, pPack->pName); - pPlayer->_pClass = pPack->pClass; - InitPlayer(pnum, TRUE); - pPlayer->_pBaseStr = (unsigned char)pPack->pBaseStr; - pPlayer->_pStrength = (unsigned char)pPack->pBaseStr; - pPlayer->_pBaseMag = (unsigned char)pPack->pBaseMag; - pPlayer->_pMagic = (unsigned char)pPack->pBaseMag; - pPlayer->_pBaseDex = (unsigned char)pPack->pBaseDex; - pPlayer->_pDexterity = (unsigned char)pPack->pBaseDex; - pPlayer->_pBaseVit = (unsigned char)pPack->pBaseVit; - pPlayer->_pVitality = (unsigned char)pPack->pBaseVit; - pPlayer->_pLevel = pPack->pLevel; - pPlayer->_pStatPts = (unsigned char)pPack->pStatPts; - pPlayer->_pExperience = pPack->pExperience; - pPlayer->_pGold = pPack->pGold; - pPlayer->_pMaxHPBase = pPack->pMaxHPBase; - v6 = pPack->pHPBase; - pPlayer->_pHPBase = v6; - if (!killok) { - _LOBYTE(v6) = v6 & 0xC0; - if (v6 < 64) - pPlayer->_pHPBase = 64; - } - pPlayer->_pMaxManaBase = pPack->pMaxManaBase; - pPlayer->_pManaBase = pPack->pManaBase; - pPlayer->_pMemSpells = pPack->pMemSpells; + pPlayer = &plr[pnum]; + ClearPlrRVars(&plr[pnum]); + pPlayer->WorldX = (unsigned char)pPack->px; + pPlayer->WorldY = (unsigned char)pPack->py; + pPlayer->_px = (unsigned char)pPack->px; + pPlayer->_py = (unsigned char)pPack->py; + pPlayer->_ptargx = (unsigned char)pPack->targx; + pPlayer->_ptargy = (unsigned char)pPack->targy; + pPlayer->plrlevel = (unsigned char)pPack->plrlevel; + ClrPlrPath(pnum); + pPlayer->destAction = ACTION_NONE; + strcpy(pPlayer->_pName, pPack->pName); + pPlayer->_pClass = pPack->pClass; + InitPlayer(pnum, TRUE); + pPlayer->_pBaseStr = (unsigned char)pPack->pBaseStr; + pPlayer->_pStrength = (unsigned char)pPack->pBaseStr; + pPlayer->_pBaseMag = (unsigned char)pPack->pBaseMag; + pPlayer->_pMagic = (unsigned char)pPack->pBaseMag; + pPlayer->_pBaseDex = (unsigned char)pPack->pBaseDex; + pPlayer->_pDexterity = (unsigned char)pPack->pBaseDex; + pPlayer->_pBaseVit = (unsigned char)pPack->pBaseVit; + pPlayer->_pVitality = (unsigned char)pPack->pBaseVit; + pPlayer->_pLevel = pPack->pLevel; + pPlayer->_pStatPts = (unsigned char)pPack->pStatPts; + pPlayer->_pExperience = pPack->pExperience; + pPlayer->_pGold = pPack->pGold; + pPlayer->_pMaxHPBase = pPack->pMaxHPBase; + v6 = pPack->pHPBase; + pPlayer->_pHPBase = v6; + if (!killok) { + _LOBYTE(v6) = v6 & 0xC0; + if (v6 < 64) + pPlayer->_pHPBase = 64; + } + pPlayer->_pMaxManaBase = pPack->pMaxManaBase; + pPlayer->_pManaBase = pPack->pManaBase; + pPlayer->_pMemSpells = pPack->pMemSpells; - for (i = 0; i < MAX_SPELLS; i++) - pPlayer->_pSplLvl[i] = pPack->pSplLvl[i]; + for (i = 0; i < MAX_SPELLS; i++) + pPlayer->_pSplLvl[i] = pPack->pSplLvl[i]; - pki = pPack->InvBody; - pi = pPlayer->InvBody; + pki = pPack->InvBody; + pi = pPlayer->InvBody; - for (i = 0; i < 7; i++) - UnPackItem(pki++, pi++); + for (i = 0; i < 7; i++) + UnPackItem(pki++, pi++); - pki = pPack->InvList; - pi = pPlayer->InvList; + pki = pPack->InvList; + pi = pPlayer->InvList; - for (i = 0; i < 40; i++) - UnPackItem(pki++, pi++); + for (i = 0; i < 40; i++) + UnPackItem(pki++, pi++); - for (i = 0; i < 40; i++) - pPlayer->InvGrid[i] = pPack->InvGrid[i]; + for (i = 0; i < 40; i++) + pPlayer->InvGrid[i] = pPack->InvGrid[i]; - pPlayer->_pNumInv = (unsigned char)pPack->_pNumInv; - VerifyGoldSeeds(pPlayer); + pPlayer->_pNumInv = (unsigned char)pPack->_pNumInv; + VerifyGoldSeeds(pPlayer); - pki = pPack->SpdList; - pi = pPlayer->SpdList; + pki = pPack->SpdList; + pi = pPlayer->SpdList; - for (i = 0; i < MAXBELTITEMS; i++) - UnPackItem(pki++, pi++); + for (i = 0; i < MAXBELTITEMS; i++) + UnPackItem(pki++, pi++); - if (pnum == myplr) { - for (i = 0; i < 20; i++) - witchitem[i]._itype = -1; - } + if (pnum == myplr) { + for (i = 0; i < 20; i++) + witchitem[i]._itype = -1; + } - CalcPlrInv(pnum, 0); - pPlayer->pTownWarps = 0; - pPlayer->pDungMsgs = 0; - pPlayer->pLvlLoad = 0; - pPlayer->pDiabloKillLevel = pPack->pDiabloKillLevel; - pPlayer->pBattleNet = pPack->pBattleNet; - pPlayer->pManaShield = pPack->pManaShield; + CalcPlrInv(pnum, 0); + pPlayer->pTownWarps = 0; + pPlayer->pDungMsgs = 0; + pPlayer->pLvlLoad = 0; + pPlayer->pDiabloKillLevel = pPack->pDiabloKillLevel; + pPlayer->pBattleNet = pPack->pBattleNet; + pPlayer->pManaShield = pPack->pManaShield; } // Note: last slot of item[MAXITEMS+1] used as temporary buffer // find real name reference below, possibly [sizeof(item[])/sizeof(ItemStruct)] void __fastcall UnPackItem(PkItemStruct *is, ItemStruct *id) { - PkItemStruct *v2; // esi - ItemStruct *v3; // edi - int v5; // ecx + PkItemStruct *v2; // esi + ItemStruct *v3; // edi + int v5; // ecx - v2 = is; - v3 = id; + v2 = is; + v3 = id; - if (is->idx == -1) { - id->_itype = -1; - } else { - if (is->idx == IDI_EAR) { - RecreateEar( - MAXITEMS, - is->iCreateInfo, - is->iSeed, - is->bId, - (unsigned char)is->bDur, - (unsigned char)is->bMDur, - (unsigned char)is->bCh, - (unsigned char)is->bMCh, - (unsigned short)is->wValue, - is->dwBuff); - } else { - v5 = (unsigned short)is->wValue; - _LOWORD(v5) = v2->iCreateInfo; - RecreateItem(MAXITEMS, is->idx, v5, v2->iSeed, (unsigned short)v2->wValue); - item[MAXITEMS]._iMagical = (unsigned char)v2->bId >> 1; - item[MAXITEMS]._iIdentified = v2->bId & 1; - item[MAXITEMS]._iDurability = (unsigned char)v2->bDur; - item[MAXITEMS]._iMaxDur = (unsigned char)v2->bMDur; - item[MAXITEMS]._iCharges = (unsigned char)v2->bCh; - item[MAXITEMS]._iMaxCharges = (unsigned char)v2->bMCh; - } - qmemcpy(v3, &item[MAXITEMS], sizeof(ItemStruct)); - } + if (is->idx == -1) { + id->_itype = -1; + } else { + if (is->idx == IDI_EAR) { + RecreateEar( + MAXITEMS, + is->iCreateInfo, + is->iSeed, + is->bId, + (unsigned char)is->bDur, + (unsigned char)is->bMDur, + (unsigned char)is->bCh, + (unsigned char)is->bMCh, + (unsigned short)is->wValue, + is->dwBuff); + } else { + v5 = (unsigned short)is->wValue; + _LOWORD(v5) = v2->iCreateInfo; + RecreateItem(MAXITEMS, is->idx, v5, v2->iSeed, (unsigned short)v2->wValue); + item[MAXITEMS]._iMagical = (unsigned char)v2->bId >> 1; + item[MAXITEMS]._iIdentified = v2->bId & 1; + item[MAXITEMS]._iDurability = (unsigned char)v2->bDur; + item[MAXITEMS]._iMaxDur = (unsigned char)v2->bMDur; + item[MAXITEMS]._iCharges = (unsigned char)v2->bCh; + item[MAXITEMS]._iMaxCharges = (unsigned char)v2->bMCh; + } + qmemcpy(v3, &item[MAXITEMS], sizeof(ItemStruct)); + } } diff --git a/Source/palette.cpp b/Source/palette.cpp index d25f4570..eaff6611 100644 --- a/Source/palette.cpp +++ b/Source/palette.cpp @@ -17,281 +17,281 @@ BOOL color_cycling_enabled = TRUE; bool sgbFadedIn = 1; struct palette_cpp_init { - palette_cpp_init() - { - palette_cpp_init_value = palette_inf; - } + palette_cpp_init() + { + palette_cpp_init_value = palette_inf; + } } _palette_cpp_init; // 47F16C: using guessed type int palette_inf; // 67DBCC: using guessed type int palette_cpp_init_value; void __cdecl SaveGamma() { - SRegSaveValue("Diablo", "Gamma Correction", 0, gamma_correction); - SRegSaveValue("Diablo", "Color Cycling", FALSE, color_cycling_enabled); + SRegSaveValue("Diablo", "Gamma Correction", 0, gamma_correction); + SRegSaveValue("Diablo", "Color Cycling", FALSE, color_cycling_enabled); } void __cdecl palette_init() { - int v0; // eax - int v1; // eax + int v0; // eax + int v1; // eax - LoadGamma(); - memcpy(system_palette, orig_palette, 0x400u); - LoadSysPal(); - v0 = lpDDInterface->CreatePalette(DDPCAPS_ALLOW256 | DDPCAPS_8BIT, system_palette, &lpDDPalette, NULL); - if (v0) - ErrDlg(IDD_DIALOG8, v0, "C:\\Src\\Diablo\\Source\\PALETTE.CPP", 143); - v1 = lpDDSPrimary->SetPalette(lpDDPalette); - if (v1) - ErrDlg(IDD_DIALOG8, v1, "C:\\Src\\Diablo\\Source\\PALETTE.CPP", 146); + LoadGamma(); + memcpy(system_palette, orig_palette, 0x400u); + LoadSysPal(); + v0 = lpDDInterface->CreatePalette(DDPCAPS_ALLOW256 | DDPCAPS_8BIT, system_palette, &lpDDPalette, NULL); + if (v0) + ErrDlg(IDD_DIALOG8, v0, "C:\\Src\\Diablo\\Source\\PALETTE.CPP", 143); + v1 = lpDDSPrimary->SetPalette(lpDDPalette); + if (v1) + ErrDlg(IDD_DIALOG8, v1, "C:\\Src\\Diablo\\Source\\PALETTE.CPP", 146); } void __cdecl LoadGamma() { - int v3; // eax - int value; // [esp+8h] [ebp-4h] + int v3; // eax + int value; // [esp+8h] [ebp-4h] - value = gamma_correction; - if (!SRegLoadValue("Diablo", "Gamma Correction", 0, &value)) - value = 100; - if (value >= 30) { - if (value > 100) - value = 100; - } else { - value = 30; - } - gamma_correction = value - value % 5; - if (SRegLoadValue("Diablo", "Color Cycling", 0, &value)) - v3 = value; - else - v3 = TRUE; - color_cycling_enabled = v3; + value = gamma_correction; + if (!SRegLoadValue("Diablo", "Gamma Correction", 0, &value)) + value = 100; + if (value >= 30) { + if (value > 100) + value = 100; + } else { + value = 30; + } + gamma_correction = value - value % 5; + if (SRegLoadValue("Diablo", "Color Cycling", 0, &value)) + v3 = value; + else + v3 = TRUE; + color_cycling_enabled = v3; } void __cdecl LoadSysPal() { - HDC hDC; // ebx - int i; // ecx - int iStartIndex; // edi + HDC hDC; // ebx + int i; // ecx + int iStartIndex; // edi - for (i = 0; i < 256; i++) - system_palette[i].peFlags = PC_NOCOLLAPSE | PC_RESERVED; + for (i = 0; i < 256; i++) + system_palette[i].peFlags = PC_NOCOLLAPSE | PC_RESERVED; - if (!fullscreen) { - hDC = GetDC(NULL); - gdwPalEntries = GetDeviceCaps(hDC, NUMRESERVED) / 2; - GetSystemPaletteEntries(hDC, 0, gdwPalEntries, system_palette); - for (i = 0; i < gdwPalEntries; i++) - system_palette[i].peFlags = 0; - iStartIndex = 256 - gdwPalEntries; - GetSystemPaletteEntries(hDC, iStartIndex, gdwPalEntries, &system_palette[iStartIndex]); - if (iStartIndex < 256) { - for (i = iStartIndex; i < 256; i++) - system_palette[i].peFlags = 0; - } - ReleaseDC(NULL, hDC); - } + if (!fullscreen) { + hDC = GetDC(NULL); + gdwPalEntries = GetDeviceCaps(hDC, NUMRESERVED) / 2; + GetSystemPaletteEntries(hDC, 0, gdwPalEntries, system_palette); + for (i = 0; i < gdwPalEntries; i++) + system_palette[i].peFlags = 0; + iStartIndex = 256 - gdwPalEntries; + GetSystemPaletteEntries(hDC, iStartIndex, gdwPalEntries, &system_palette[iStartIndex]); + if (iStartIndex < 256) { + for (i = iStartIndex; i < 256; i++) + system_palette[i].peFlags = 0; + } + ReleaseDC(NULL, hDC); + } } void __fastcall LoadPalette(char *pszFileName) { - int i; // eax - char PalData[256][3]; // [esp+0h] [ebp-304h] - void *pBuf; // [esp+300h] [ebp-4h] + int i; // eax + char PalData[256][3]; // [esp+0h] [ebp-304h] + void *pBuf; // [esp+300h] [ebp-4h] - WOpenFile(pszFileName, &pBuf, 0); - WReadFile(pBuf, (char *)PalData, 768); - WCloseFile(pBuf); + WOpenFile(pszFileName, &pBuf, 0); + WReadFile(pBuf, (char *)PalData, 768); + WCloseFile(pBuf); - for (i = 0; i < 256; i++) { - orig_palette[i].peFlags = 0; - orig_palette[i].peRed = PalData[i][0]; - orig_palette[i].peGreen = PalData[i][1]; - orig_palette[i].peBlue = PalData[i][2]; - } + for (i = 0; i < 256; i++) { + orig_palette[i].peFlags = 0; + orig_palette[i].peRed = PalData[i][0]; + orig_palette[i].peGreen = PalData[i][1]; + orig_palette[i].peBlue = PalData[i][2]; + } } void __fastcall LoadRndLvlPal(int l) { - char *pszPal; // ecx - char szTemp[260]; // [esp+4h] [ebp-104h] + char *pszPal; // ecx + char szTemp[260]; // [esp+4h] [ebp-104h] - if (l) { - sprintf(szTemp, "Levels\\L%iData\\L%i_%i.PAL", l, l, random(0, 4) + 1); - pszPal = szTemp; - } else { - pszPal = "Levels\\TownData\\Town.pal"; - } - LoadPalette(pszPal); + if (l) { + sprintf(szTemp, "Levels\\L%iData\\L%i_%i.PAL", l, l, random(0, 4) + 1); + pszPal = szTemp; + } else { + pszPal = "Levels\\TownData\\Town.pal"; + } + LoadPalette(pszPal); } void __cdecl ResetPal() { - if (!lpDDSPrimary - || lpDDSPrimary->IsLost() != DDERR_SURFACELOST - || !lpDDSPrimary->Restore()) { - SDrawRealizePalette(); - } + if (!lpDDSPrimary + || lpDDSPrimary->IsLost() != DDERR_SURFACELOST + || !lpDDSPrimary->Restore()) { + SDrawRealizePalette(); + } } void __cdecl IncreaseGamma() { - if (gamma_correction < 100) { - gamma_correction += 5; - if (gamma_correction > 100) - gamma_correction = 100; - ApplyGamma(system_palette, logical_palette, 256); - palette_update(); - } + if (gamma_correction < 100) { + gamma_correction += 5; + if (gamma_correction > 100) + gamma_correction = 100; + ApplyGamma(system_palette, logical_palette, 256); + palette_update(); + } } void __cdecl palette_update() { - int v0; // ecx - int v1; // eax + int v0; // ecx + int v1; // eax - if (lpDDPalette) { - v0 = 0; - v1 = 256; - if (!fullscreen) { - v0 = gdwPalEntries; - v1 = 2 * (128 - gdwPalEntries); - } - SDrawUpdatePalette(v0, v1, &system_palette[v0], 0); - } + if (lpDDPalette) { + v0 = 0; + v1 = 256; + if (!fullscreen) { + v0 = gdwPalEntries; + v1 = 2 * (128 - gdwPalEntries); + } + SDrawUpdatePalette(v0, v1, &system_palette[v0], 0); + } } void __fastcall ApplyGamma(PALETTEENTRY *dst, PALETTEENTRY *src, int n) { - PALETTEENTRY *v3; // edi - PALETTEENTRY *v4; // esi - double v5; // [esp+18h] [ebp-Ch] + PALETTEENTRY *v3; // edi + PALETTEENTRY *v4; // esi + double v5; // [esp+18h] [ebp-Ch] - v3 = src; - v4 = dst; - v5 = (double)gamma_correction * 0.01; - if (n > 0) { - do { - v4->peRed = pow(v3->peRed * 0.00390625, v5) * 256.0; - v4->peGreen = pow(v3->peGreen * 0.00390625, v5) * 256.0; - v4->peBlue = pow(v3->peBlue * 0.00390625, v5) * 256.0; - ++v4; - ++v3; - --n; - } while (n); - } + v3 = src; + v4 = dst; + v5 = (double)gamma_correction * 0.01; + if (n > 0) { + do { + v4->peRed = pow(v3->peRed * 0.00390625, v5) * 256.0; + v4->peGreen = pow(v3->peGreen * 0.00390625, v5) * 256.0; + v4->peBlue = pow(v3->peBlue * 0.00390625, v5) * 256.0; + ++v4; + ++v3; + --n; + } while (n); + } } void __cdecl DecreaseGamma() { - if (gamma_correction > 30) { - gamma_correction -= 5; - if (gamma_correction < 30) - gamma_correction = 30; - ApplyGamma(system_palette, logical_palette, 256); - palette_update(); - } + if (gamma_correction > 30) { + gamma_correction -= 5; + if (gamma_correction < 30) + gamma_correction = 30; + ApplyGamma(system_palette, logical_palette, 256); + palette_update(); + } } int __fastcall UpdateGamma(int gamma) { - if (gamma) { - gamma_correction = 130 - gamma; - ApplyGamma(system_palette, logical_palette, 256); - palette_update(); - } - return 130 - gamma_correction; + if (gamma) { + gamma_correction = 130 - gamma; + ApplyGamma(system_palette, logical_palette, 256); + palette_update(); + } + return 130 - gamma_correction; } void __cdecl BlackPalette() { - SetFadeLevel(0); + SetFadeLevel(0); } void __fastcall SetFadeLevel(int fadeval) { - int i; // eax + int i; // eax - if (lpDDInterface) { - for (i = 0; i < 255; i++) { - system_palette[i].peRed = (fadeval * logical_palette[i].peRed) >> 8; - system_palette[i].peGreen = (fadeval * logical_palette[i].peGreen) >> 8; - system_palette[i].peBlue = (fadeval * logical_palette[i].peBlue) >> 8; - } - Sleep(3); - lpDDInterface->WaitForVerticalBlank(DDWAITVB_BLOCKBEGIN, NULL); - palette_update(); - } + if (lpDDInterface) { + for (i = 0; i < 255; i++) { + system_palette[i].peRed = (fadeval * logical_palette[i].peRed) >> 8; + system_palette[i].peGreen = (fadeval * logical_palette[i].peGreen) >> 8; + system_palette[i].peBlue = (fadeval * logical_palette[i].peBlue) >> 8; + } + Sleep(3); + lpDDInterface->WaitForVerticalBlank(DDWAITVB_BLOCKBEGIN, NULL); + palette_update(); + } } void __fastcall PaletteFadeIn(int fr) { - int i; // ebp + int i; // ebp - ApplyGamma(logical_palette, orig_palette, 256); + ApplyGamma(logical_palette, orig_palette, 256); - for (i = 0; i < 256; i += fr) - SetFadeLevel(i); + for (i = 0; i < 256; i += fr) + SetFadeLevel(i); - SetFadeLevel(256); - memcpy(logical_palette, orig_palette, 0x400u); - sgbFadedIn = 1; + SetFadeLevel(256); + memcpy(logical_palette, orig_palette, 0x400u); + sgbFadedIn = 1; } void __fastcall PaletteFadeOut(int fr) { - int i; // esi + int i; // esi - if (sgbFadedIn) { - for (i = 256; i > 0; i -= fr) - SetFadeLevel(i); + if (sgbFadedIn) { + for (i = 256; i > 0; i -= fr) + SetFadeLevel(i); - SetFadeLevel(0); - sgbFadedIn = 0; - } + SetFadeLevel(0); + sgbFadedIn = 0; + } } void __cdecl palette_update_caves() { - BYTE v0; // cx - signed int v1; // esi - signed int v2; // eax - BYTE v4; // [esp+6h] [ebp-2h] - BYTE v5; + BYTE v0; // cx + signed int v1; // esi + signed int v2; // eax + BYTE v4; // [esp+6h] [ebp-2h] + BYTE v5; - v0 = system_palette[1].peRed; - v5 = system_palette[1].peGreen; - v4 = system_palette[1].peBlue; - v1 = 1; - do { - v2 = v1++; - system_palette[v2].peRed = system_palette[v2 + 1].peRed; - system_palette[v2].peGreen = system_palette[v2 + 1].peGreen; - system_palette[v2].peBlue = system_palette[v2 + 1].peBlue; - } while (v1 < 31); - system_palette[v1].peRed = v0; - system_palette[v1].peGreen = v5; - system_palette[v1].peBlue = v4; - palette_update(); + v0 = system_palette[1].peRed; + v5 = system_palette[1].peGreen; + v4 = system_palette[1].peBlue; + v1 = 1; + do { + v2 = v1++; + system_palette[v2].peRed = system_palette[v2 + 1].peRed; + system_palette[v2].peGreen = system_palette[v2 + 1].peGreen; + system_palette[v2].peBlue = system_palette[v2 + 1].peBlue; + } while (v1 < 31); + system_palette[v1].peRed = v0; + system_palette[v1].peGreen = v5; + system_palette[v1].peBlue = v4; + palette_update(); } void __fastcall palette_update_quest_palette(int n) { - int i; // eax + int i; // eax - for (i = 32 - n; i >= 0; --i) - logical_palette[i] = orig_palette[i]; - ApplyGamma(system_palette, logical_palette, 32); - palette_update(); + for (i = 32 - n; i >= 0; --i) + logical_palette[i] = orig_palette[i]; + ApplyGamma(system_palette, logical_palette, 32); + palette_update(); } bool __cdecl palette_get_colour_cycling() { - return color_cycling_enabled; + return color_cycling_enabled; } void __fastcall palette_set_color_cycling(bool enabled) { - color_cycling_enabled = enabled; + color_cycling_enabled = enabled; } diff --git a/Source/path.cpp b/Source/path.cpp index 02d9e20b..fb81a7b0 100644 --- a/Source/path.cpp +++ b/Source/path.cpp @@ -41,85 +41,85 @@ char path_directions[9] = { 5, 1, 6, 2, 0, 3, 8, 4, 7 }; */ int __fastcall FindPath(BOOL(__fastcall *PosOk)(int, int, int), int PosOkArg, int sx, int sy, int dx, int dy, char *path) { - PATHNODE *path_start; // esi - char initial_h; // al - PATHNODE *next_node; // eax - int result; // eax - PATHNODE *current; // edx - PATHNODE **previous; // eax - int path_length; // edi - bool path_is_full; // zf - int *step_ptr; // ecx - char step; // dl + PATHNODE *path_start; // esi + char initial_h; // al + PATHNODE *next_node; // eax + int result; // eax + PATHNODE *current; // edx + PATHNODE **previous; // eax + int path_length; // edi + bool path_is_full; // zf + int *step_ptr; // ecx + char step; // dl - // clear all nodes, create root nodes for the visited/frontier linked lists - gdwCurNodes = 0; - path_2_nodes = path_new_step(); - gdwCurPathStep = 0; - pnode_ptr = path_new_step(); - path_start = path_new_step(); - path_start->g = 0; - initial_h = path_get_h_cost(sx, sy, dx, dy); - path_start->h = initial_h; - path_start->x = sx; - path_start->f = initial_h + path_start->g; - path_start->y = sy; - path_2_nodes->NextNode = path_start; - // A* search until we find (dx,dy) or fail - while (TRUE) { - next_node = GetNextPath(); - // frontier is empty, no path! - if (!next_node) - return 0; - // reached the end, success! - if (next_node->x == dx && next_node->y == dy) - break; - // ran out of nodes, abort! - if (!path_get_path(PosOk, PosOkArg, next_node, dx, dy)) - return 0; - } - current = next_node; - previous = &next_node->Parent; - path_length = 0; - if (*previous) { - while (TRUE) { - path_is_full = path_length == 25; - if (path_length >= 25) - break; - pnode_vals[++path_length - 1] = path_directions[3 * (current->y - (*previous)->y) - (*previous)->x + 4 + current->x]; - current = *previous; - previous = &(*previous)->Parent; - if (!*previous) { - path_is_full = path_length == 25; - break; - } - } - if (path_is_full) - return 0; - } - result = 0; - if (path_length > 0) { - step_ptr = &pnode_vals[path_length - 1]; - do { - step = *(_BYTE *)step_ptr; - --step_ptr; - path[result++] = step; - } while (result < path_length); - } - return result; + // clear all nodes, create root nodes for the visited/frontier linked lists + gdwCurNodes = 0; + path_2_nodes = path_new_step(); + gdwCurPathStep = 0; + pnode_ptr = path_new_step(); + path_start = path_new_step(); + path_start->g = 0; + initial_h = path_get_h_cost(sx, sy, dx, dy); + path_start->h = initial_h; + path_start->x = sx; + path_start->f = initial_h + path_start->g; + path_start->y = sy; + path_2_nodes->NextNode = path_start; + // A* search until we find (dx,dy) or fail + while (TRUE) { + next_node = GetNextPath(); + // frontier is empty, no path! + if (!next_node) + return 0; + // reached the end, success! + if (next_node->x == dx && next_node->y == dy) + break; + // ran out of nodes, abort! + if (!path_get_path(PosOk, PosOkArg, next_node, dx, dy)) + return 0; + } + current = next_node; + previous = &next_node->Parent; + path_length = 0; + if (*previous) { + while (TRUE) { + path_is_full = path_length == 25; + if (path_length >= 25) + break; + pnode_vals[++path_length - 1] = path_directions[3 * (current->y - (*previous)->y) - (*previous)->x + 4 + current->x]; + current = *previous; + previous = &(*previous)->Parent; + if (!*previous) { + path_is_full = path_length == 25; + break; + } + } + if (path_is_full) + return 0; + } + result = 0; + if (path_length > 0) { + step_ptr = &pnode_vals[path_length - 1]; + do { + step = *(_BYTE *)step_ptr; + --step_ptr; + path[result++] = step; + } while (result < path_length); + } + return result; } /* heuristic, estimated cost from (sx,sy) to (dx,dy) */ int __fastcall path_get_h_cost(int sx, int sy, int dx, int dy) { - int delta_x = abs(sx - dx); - int delta_y = abs(sy - dy); + int delta_x = abs(sx - dx); + int delta_y = abs(sy - dy); - int min = delta_x < delta_y ? delta_x : delta_y; - int max = delta_x > delta_y ? delta_x : delta_y; + int min = delta_x < delta_y ? delta_x : delta_y; + int max = delta_x > delta_y ? delta_x : delta_y; - // see path_check_equal for why this is times 2 - return 2 * (min + max); + // see path_check_equal for why this is times 2 + return 2 * (min + max); } /* return 2 if pPath is horizontally/vertically aligned with (dx,dy), else 3 @@ -130,10 +130,10 @@ int __fastcall path_get_h_cost(int sx, int sy, int dx, int dy) */ int __fastcall path_check_equal(PATHNODE *pPath, int dx, int dy) { - if (pPath->x == dx || pPath->y == dy) - return 2; + if (pPath->x == dx || pPath->y == dy) + return 2; - return 3; + return 3; } /* get the next node on the A* frontier to explore (estimated to be closest to @@ -141,17 +141,17 @@ int __fastcall path_check_equal(PATHNODE *pPath, int dx, int dy) */ PATHNODE *__cdecl GetNextPath() { - PATHNODE *result; + PATHNODE *result; - result = path_2_nodes->NextNode; - if (result == NULL) { - return result; - } + result = path_2_nodes->NextNode; + if (result == NULL) { + return result; + } - path_2_nodes->NextNode = result->NextNode; - result->NextNode = pnode_ptr->NextNode; - pnode_ptr->NextNode = result; - return result; + path_2_nodes->NextNode = result->NextNode; + result->NextNode = pnode_ptr->NextNode; + pnode_ptr->NextNode = result; + return result; } /* check if stepping from pPath to (dx,dy) cuts a corner. If you step from A to @@ -164,22 +164,22 @@ PATHNODE *__cdecl GetNextPath() */ BOOL __fastcall path_solid_pieces(PATHNODE *pPath, int dx, int dy) { - BOOL rv = TRUE; - switch (path_directions[3 * (dy - pPath->y) + 3 - pPath->x + 1 + dx]) { - case 5: - rv = !nSolidTable[dPiece[dx][dy + 1]] && !nSolidTable[dPiece[dx + 1][dy]]; - break; - case 6: - rv = !nSolidTable[dPiece[dx][dy + 1]] && !nSolidTable[dPiece[dx - 1][dy]]; - break; - case 7: - rv = !nSolidTable[dPiece[dx][dy - 1]] && !nSolidTable[dPiece[dx - 1][dy]]; - break; - case 8: - rv = !nSolidTable[dPiece[dx + 1][dy]] && !nSolidTable[dPiece[dx][dy - 1]]; - break; - } - return rv; + BOOL rv = TRUE; + switch (path_directions[3 * (dy - pPath->y) + 3 - pPath->x + 1 + dx]) { + case 5: + rv = !nSolidTable[dPiece[dx][dy + 1]] && !nSolidTable[dPiece[dx + 1][dy]]; + break; + case 6: + rv = !nSolidTable[dPiece[dx][dy + 1]] && !nSolidTable[dPiece[dx - 1][dy]]; + break; + case 7: + rv = !nSolidTable[dPiece[dx][dy - 1]] && !nSolidTable[dPiece[dx - 1][dy]]; + break; + case 8: + rv = !nSolidTable[dPiece[dx + 1][dy]] && !nSolidTable[dPiece[dx][dy - 1]]; + break; + } + return rv; } /* perform a single step of A* bread-first search by trying to step in every @@ -189,21 +189,21 @@ BOOL __fastcall path_solid_pieces(PATHNODE *pPath, int dx, int dy) */ BOOL __fastcall path_get_path(BOOL(__fastcall *PosOk)(int, int, int), int PosOkArg, PATHNODE *pPath, int x, int y) { - int dx, dy; - int i; - BOOL ok; + int dx, dy; + int i; + BOOL ok; - for (i = 0; i < 8; i++) { - dx = pPath->x + pathxdir[i]; - dy = pPath->y + pathydir[i]; - ok = PosOk(PosOkArg, dx, dy); - if (ok && path_solid_pieces(pPath, dx, dy) || !ok && dx == x && dy == y) { - if (!path_parent_path(pPath, dx, dy, x, y)) - return FALSE; - } - } + for (i = 0; i < 8; i++) { + dx = pPath->x + pathxdir[i]; + dy = pPath->y + pathydir[i]; + ok = PosOk(PosOkArg, dx, dy); + if (ok && path_solid_pieces(pPath, dx, dy) || !ok && dx == x && dy == y) { + if (!path_parent_path(pPath, dx, dy, x, y)) + return FALSE; + } + } - return TRUE; + return TRUE; } /* add a step from pPath to (dx,dy), return 1 if successful, and update the @@ -213,160 +213,160 @@ BOOL __fastcall path_get_path(BOOL(__fastcall *PosOk)(int, int, int), int PosOkA */ BOOL __fastcall path_parent_path(PATHNODE *pPath, int dx, int dy, int sx, int sy) { - int next_g; - PATHNODE *dxdy; - int i; + int next_g; + PATHNODE *dxdy; + int i; - next_g = pPath->g + path_check_equal(pPath, dx, dy); + next_g = pPath->g + path_check_equal(pPath, dx, dy); - // 3 cases to consider - // case 1: (dx,dy) is already on the frontier - dxdy = path_get_node1(dx, dy); - if (dxdy != NULL) { - for (i = 0; i < 8; i++) { - if (pPath->Child[i] == NULL) - break; - } - pPath->Child[i] = dxdy; - if (next_g < dxdy->g) { - if (path_solid_pieces(pPath, dx, dy)) { - // we'll explore it later, just update - dxdy->Parent = pPath; - dxdy->g = next_g; - dxdy->f = next_g + dxdy->h; - } - } - } else { - // case 2: (dx,dy) was already visited - dxdy = path_get_node2(dx, dy); - if (dxdy != NULL) { - for (i = 0; i < 8; i++) { - if (pPath->Child[i] == NULL) - break; - } - pPath->Child[i] = dxdy; - if (next_g < dxdy->g && path_solid_pieces(pPath, dx, dy)) { - // update the node - dxdy->Parent = pPath; - dxdy->g = next_g; - dxdy->f = next_g + dxdy->h; - // already explored, so re-update others starting from that node - path_set_coords(dxdy); - } - } else { - // case 3: (dx,dy) is totally new - dxdy = path_new_step(); - if (dxdy == NULL) - return FALSE; - dxdy->Parent = pPath; - dxdy->g = next_g; - dxdy->h = path_get_h_cost(dx, dy, sx, sy); - dxdy->f = next_g + dxdy->h; - dxdy->x = dx; - dxdy->y = dy; - // add it to the frontier - path_next_node(dxdy); + // 3 cases to consider + // case 1: (dx,dy) is already on the frontier + dxdy = path_get_node1(dx, dy); + if (dxdy != NULL) { + for (i = 0; i < 8; i++) { + if (pPath->Child[i] == NULL) + break; + } + pPath->Child[i] = dxdy; + if (next_g < dxdy->g) { + if (path_solid_pieces(pPath, dx, dy)) { + // we'll explore it later, just update + dxdy->Parent = pPath; + dxdy->g = next_g; + dxdy->f = next_g + dxdy->h; + } + } + } else { + // case 2: (dx,dy) was already visited + dxdy = path_get_node2(dx, dy); + if (dxdy != NULL) { + for (i = 0; i < 8; i++) { + if (pPath->Child[i] == NULL) + break; + } + pPath->Child[i] = dxdy; + if (next_g < dxdy->g && path_solid_pieces(pPath, dx, dy)) { + // update the node + dxdy->Parent = pPath; + dxdy->g = next_g; + dxdy->f = next_g + dxdy->h; + // already explored, so re-update others starting from that node + path_set_coords(dxdy); + } + } else { + // case 3: (dx,dy) is totally new + dxdy = path_new_step(); + if (dxdy == NULL) + return FALSE; + dxdy->Parent = pPath; + dxdy->g = next_g; + dxdy->h = path_get_h_cost(dx, dy, sx, sy); + dxdy->f = next_g + dxdy->h; + dxdy->x = dx; + dxdy->y = dy; + // add it to the frontier + path_next_node(dxdy); - for (i = 0; i < 8; i++) { - if (pPath->Child[i] == NULL) - break; - } - pPath->Child[i] = dxdy; - } - } - return TRUE; + for (i = 0; i < 8; i++) { + if (pPath->Child[i] == NULL) + break; + } + pPath->Child[i] = dxdy; + } + } + return TRUE; } /* return a node for (dx,dy) on the frontier, or NULL if not found */ PATHNODE *__fastcall path_get_node1(int dx, int dy) { - PATHNODE *result = path_2_nodes; - while (result != NULL && (result->x != dx || result->y != dy)) - result = result->NextNode; - return result; + PATHNODE *result = path_2_nodes; + while (result != NULL && (result->x != dx || result->y != dy)) + result = result->NextNode; + return result; } /* return a node for (dx,dy) if it was visited, or NULL if not found */ PATHNODE *__fastcall path_get_node2(int dx, int dy) { - PATHNODE *result = pnode_ptr; - while (result != NULL && (result->x != dx || result->y != dy)) - result = result->NextNode; - return result; + PATHNODE *result = pnode_ptr; + while (result != NULL && (result->x != dx || result->y != dy)) + result = result->NextNode; + return result; } /* insert pPath into the frontier (keeping the frontier sorted by total * distance) */ void __fastcall path_next_node(PATHNODE *pPath) { - PATHNODE *current; // edx - PATHNODE *next; // eax + PATHNODE *current; // edx + PATHNODE *next; // eax - current = path_2_nodes; - next = path_2_nodes->NextNode; - if (next != NULL) { - do { - if (next->f >= pPath->f) - break; - current = next; - next = next->NextNode; - } while (next != NULL); - pPath->NextNode = next; - } - current->NextNode = pPath; + current = path_2_nodes; + next = path_2_nodes->NextNode; + if (next != NULL) { + do { + if (next->f >= pPath->f) + break; + current = next; + next = next->NextNode; + } while (next != NULL); + pPath->NextNode = next; + } + current->NextNode = pPath; } /* update all path costs using depth-first search starting at pPath */ void __fastcall path_set_coords(PATHNODE *pPath) { - PATHNODE *PathOld; - PATHNODE *PathAct; - int i; + PATHNODE *PathOld; + PATHNODE *PathAct; + int i; - path_push_active_step(pPath); - while (gdwCurPathStep) { - PathOld = path_pop_active_step(); - for (i = 0; i < 8; i++) { - PathAct = PathOld->Child[i]; - if (PathAct == NULL) - break; + path_push_active_step(pPath); + while (gdwCurPathStep) { + PathOld = path_pop_active_step(); + for (i = 0; i < 8; i++) { + PathAct = PathOld->Child[i]; + if (PathAct == NULL) + break; - if (PathOld->g + path_check_equal(PathOld, PathAct->x, PathAct->y) < PathAct->g) { - if (path_solid_pieces(PathOld, PathAct->x, PathAct->y)) { - PathAct->Parent = PathOld; - PathAct->g = PathOld->g + path_check_equal(PathOld, PathAct->x, PathAct->y); - PathAct->f = PathAct->g + PathAct->h; - path_push_active_step(PathAct); - } - } - } - } + if (PathOld->g + path_check_equal(PathOld, PathAct->x, PathAct->y) < PathAct->g) { + if (path_solid_pieces(PathOld, PathAct->x, PathAct->y)) { + PathAct->Parent = PathOld; + PathAct->g = PathOld->g + path_check_equal(PathOld, PathAct->x, PathAct->y); + PathAct->f = PathAct->g + PathAct->h; + path_push_active_step(PathAct); + } + } + } + } } /* push pPath onto the pnode_tblptr stack */ void __fastcall path_push_active_step(PATHNODE *pPath) { - int stack_index = gdwCurPathStep; - gdwCurPathStep++; - pnode_tblptr[stack_index] = pPath; + int stack_index = gdwCurPathStep; + gdwCurPathStep++; + pnode_tblptr[stack_index] = pPath; } /* pop and return a node from the pnode_tblptr stack */ PATHNODE *__cdecl path_pop_active_step() { - gdwCurPathStep--; - return pnode_tblptr[gdwCurPathStep]; + gdwCurPathStep--; + return pnode_tblptr[gdwCurPathStep]; } /* zero one of the preallocated nodes and return a pointer to it, or NULL if * none are available */ PATHNODE *__cdecl path_new_step() { - if (gdwCurNodes == MAXPATHNODES) - return NULL; + if (gdwCurNodes == MAXPATHNODES) + return NULL; - PATHNODE *new_node = &path_nodes[gdwCurNodes]; - gdwCurNodes++; - memset(new_node, 0, sizeof(PATHNODE)); - return new_node; + PATHNODE *new_node = &path_nodes[gdwCurNodes]; + gdwCurNodes++; + memset(new_node, 0, sizeof(PATHNODE)); + return new_node; } diff --git a/Source/pfile.cpp b/Source/pfile.cpp index 7a64a7a3..5bebe4ef 100644 --- a/Source/pfile.cpp +++ b/Source/pfile.cpp @@ -12,685 +12,685 @@ BOOL gbValidSaveFile; void __cdecl pfile_init_save_directory() { - DWORD len; - char Buffer[MAX_PATH]; + DWORD len; + char Buffer[MAX_PATH]; - len = GetWindowsDirectory(Buffer, sizeof(Buffer)); - if (len) { - pfile_check_available_space(Buffer); - len = GetModuleFileName(ghInst, Buffer, sizeof(Buffer)); - } + len = GetWindowsDirectory(Buffer, sizeof(Buffer)); + if (len) { + pfile_check_available_space(Buffer); + len = GetModuleFileName(ghInst, Buffer, sizeof(Buffer)); + } - if (!len) - TermMsg("Unable to initialize save directory"); - else - pfile_check_available_space(Buffer); + if (!len) + TermMsg("Unable to initialize save directory"); + else + pfile_check_available_space(Buffer); } void __fastcall pfile_check_available_space(char *pszDir) { - char *s; - BOOL hasSpace; - DWORD TotalNumberOfClusters; - DWORD NumberOfFreeClusters; - DWORD BytesPerSector; - DWORD SectorsPerCluster; + char *s; + BOOL hasSpace; + DWORD TotalNumberOfClusters; + DWORD NumberOfFreeClusters; + DWORD BytesPerSector; + DWORD SectorsPerCluster; - s = pszDir; - while (*s) { - if (*s++ != '\\') - continue; - *s = '\0'; - break; - } + s = pszDir; + while (*s) { + if (*s++ != '\\') + continue; + *s = '\0'; + break; + } - hasSpace = GetDiskFreeSpace(pszDir, &SectorsPerCluster, &BytesPerSector, &NumberOfFreeClusters, &TotalNumberOfClusters); - if (hasSpace) { - // 10MB is the amount hardcoded in the error dialog - if ((__int64)SectorsPerCluster * BytesPerSector * NumberOfFreeClusters < (__int64)(10 << 20)) - hasSpace = FALSE; - } + hasSpace = GetDiskFreeSpace(pszDir, &SectorsPerCluster, &BytesPerSector, &NumberOfFreeClusters, &TotalNumberOfClusters); + if (hasSpace) { + // 10MB is the amount hardcoded in the error dialog + if ((__int64)SectorsPerCluster * BytesPerSector * NumberOfFreeClusters < (__int64)(10 << 20)) + hasSpace = FALSE; + } - if (!hasSpace) - DiskFreeDlg(pszDir); + if (!hasSpace) + DiskFreeDlg(pszDir); } void __cdecl pfile_write_hero() { - unsigned int save_num; - PkPlayerStruct pkplr; + unsigned int save_num; + PkPlayerStruct pkplr; - save_num = pfile_get_save_num_from_name(plr[myplr]._pName); - if (pfile_open_archive(TRUE, save_num)) { - PackPlayer(&pkplr, myplr, gbMaxPlayers == 1); - pfile_encode_hero(&pkplr); - pfile_flush(gbMaxPlayers == 1, save_num); - } + save_num = pfile_get_save_num_from_name(plr[myplr]._pName); + if (pfile_open_archive(TRUE, save_num)) { + PackPlayer(&pkplr, myplr, gbMaxPlayers == 1); + pfile_encode_hero(&pkplr); + pfile_flush(gbMaxPlayers == 1, save_num); + } } unsigned int __fastcall pfile_get_save_num_from_name(const char *name) { - unsigned int i; + unsigned int i; - for (i = 0; i < MAX_CHARACTERS; i++) { - if (!_strcmpi(hero_names[i], name)) - break; - } + for (i = 0; i < MAX_CHARACTERS; i++) { + if (!_strcmpi(hero_names[i], name)) + break; + } - return i; + return i; } void __fastcall pfile_encode_hero(const PkPlayerStruct *pPack) { - BYTE *packed; - DWORD packed_len; - char password[16] = PASSWORD_SINGLE; + BYTE *packed; + DWORD packed_len; + char password[16] = PASSWORD_SINGLE; - if (gbMaxPlayers > 1) - strcpy(password, PASSWORD_MULTI); + if (gbMaxPlayers > 1) + strcpy(password, PASSWORD_MULTI); - packed_len = codec_get_encoded_len(sizeof(*pPack)); - packed = (BYTE *)DiabloAllocPtr(packed_len); - memcpy(packed, pPack, sizeof(*pPack)); - codec_encode(packed, sizeof(*pPack), packed_len, password); - mpqapi_write_file("hero", packed, packed_len); - mem_free_dbg(packed); + packed_len = codec_get_encoded_len(sizeof(*pPack)); + packed = (BYTE *)DiabloAllocPtr(packed_len); + memcpy(packed, pPack, sizeof(*pPack)); + codec_encode(packed, sizeof(*pPack), packed_len, password); + mpqapi_write_file("hero", packed, packed_len); + mem_free_dbg(packed); } BOOL __fastcall pfile_open_archive(BOOL a1, unsigned int save_num) { - char FileName[MAX_PATH]; + char FileName[MAX_PATH]; - pfile_get_save_path(FileName, sizeof(FileName), save_num); - if (mpqapi_open_archive(FileName, FALSE, save_num)) - return TRUE; + pfile_get_save_path(FileName, sizeof(FileName), save_num); + if (mpqapi_open_archive(FileName, FALSE, save_num)) + return TRUE; - if (a1 && gbMaxPlayers > 1) - mpqapi_update_multi_creation_time(save_num); - return FALSE; + if (a1 && gbMaxPlayers > 1) + mpqapi_update_multi_creation_time(save_num); + return FALSE; } void __fastcall pfile_get_save_path(char *pszBuf, DWORD dwBufSize, unsigned int save_num) { - DWORD plen; - char *s; - char path[MAX_PATH]; - const char *fmt = "\\multi_%d.sv"; + DWORD plen; + char *s; + char path[MAX_PATH]; + const char *fmt = "\\multi_%d.sv"; - if (gbMaxPlayers <= 1) - fmt = "\\single_%d.sv"; + if (gbMaxPlayers <= 1) + fmt = "\\single_%d.sv"; - // BUGFIX: ignores dwBufSize and uses MAX_PATH instead - plen = GetModuleFileName(ghInst, pszBuf, MAX_PATH); - s = strrchr(pszBuf, '\\'); - if (s) - *s = '\0'; + // BUGFIX: ignores dwBufSize and uses MAX_PATH instead + plen = GetModuleFileName(ghInst, pszBuf, MAX_PATH); + s = strrchr(pszBuf, '\\'); + if (s) + *s = '\0'; - if (!plen) - TermMsg("Unable to get save directory"); + if (!plen) + TermMsg("Unable to get save directory"); - sprintf(path, fmt, save_num); - strcat(pszBuf, path); - _strlwr(pszBuf); + sprintf(path, fmt, save_num); + strcat(pszBuf, path); + _strlwr(pszBuf); } void __fastcall pfile_flush(BOOL is_single_player, unsigned int save_num) { - char FileName[MAX_PATH]; + char FileName[MAX_PATH]; - pfile_get_save_path(FileName, sizeof(FileName), save_num); - mpqapi_flush_and_close(FileName, is_single_player, save_num); + pfile_get_save_path(FileName, sizeof(FileName), save_num); + mpqapi_flush_and_close(FileName, is_single_player, save_num); } BOOL __fastcall pfile_create_player_description(char *dst, unsigned int len) { - char desc[128]; - _uiheroinfo uihero; + char desc[128]; + _uiheroinfo uihero; - myplr = 0; - pfile_read_player_from_save(); - game_2_ui_player(plr, &uihero, gbValidSaveFile); - UiSetupPlayerInfo(chr_name_str, &uihero, GAME_ID); + myplr = 0; + pfile_read_player_from_save(); + game_2_ui_player(plr, &uihero, gbValidSaveFile); + UiSetupPlayerInfo(chr_name_str, &uihero, GAME_ID); - if (dst != NULL && len) { - if (UiCreatePlayerDescription(&uihero, GAME_ID, desc) == 0) - return FALSE; - SStrCopy(dst, desc, len); - } - return TRUE; + if (dst != NULL && len) { + if (UiCreatePlayerDescription(&uihero, GAME_ID, desc) == 0) + return FALSE; + SStrCopy(dst, desc, len); + } + return TRUE; } BOOL __fastcall pfile_create_save_file(const char *name_1, const char *name_2) { - int i; - unsigned int save_num; - _uiheroinfo uihero; - BOOL found = FALSE; + int i; + unsigned int save_num; + _uiheroinfo uihero; + BOOL found = FALSE; - if (pfile_get_save_num_from_name(name_2) == MAX_CHARACTERS) { - for (i = 0; i != MAX_PLRS; i++) { - if (!_strcmpi(name_1, plr[i]._pName)) { - found = TRUE; - break; - } - } - } + if (pfile_get_save_num_from_name(name_2) == MAX_CHARACTERS) { + for (i = 0; i != MAX_PLRS; i++) { + if (!_strcmpi(name_1, plr[i]._pName)) { + found = TRUE; + break; + } + } + } - if (!found) - return FALSE; - save_num = pfile_get_save_num_from_name(name_1); - if (save_num == MAX_CHARACTERS) - return FALSE; + if (!found) + return FALSE; + save_num = pfile_get_save_num_from_name(name_1); + if (save_num == MAX_CHARACTERS) + return FALSE; - SStrCopy(hero_names[save_num], name_2, PLR_NAME_LEN); - SStrCopy(plr[i]._pName, name_2, PLR_NAME_LEN); - if (!_strcmpi(chr_name_str, name_1)) - SStrCopy(chr_name_str, name_2, sizeof(chr_name_str)); - game_2_ui_player(plr, &uihero, gbValidSaveFile); - UiSetupPlayerInfo(chr_name_str, &uihero, GAME_ID); - pfile_write_hero(); - return TRUE; + SStrCopy(hero_names[save_num], name_2, PLR_NAME_LEN); + SStrCopy(plr[i]._pName, name_2, PLR_NAME_LEN); + if (!_strcmpi(chr_name_str, name_1)) + SStrCopy(chr_name_str, name_2, sizeof(chr_name_str)); + game_2_ui_player(plr, &uihero, gbValidSaveFile); + UiSetupPlayerInfo(chr_name_str, &uihero, GAME_ID); + pfile_write_hero(); + return TRUE; } void __cdecl pfile_flush_W() { - pfile_flush(TRUE, pfile_get_save_num_from_name(plr[myplr]._pName)); + pfile_flush(TRUE, pfile_get_save_num_from_name(plr[myplr]._pName)); } void __fastcall game_2_ui_player(const PlayerStruct *p, _uiheroinfo *heroinfo, BOOL bHasSaveFile) { - memset(heroinfo, 0, sizeof(*heroinfo)); - strncpy(heroinfo->name, p->_pName, sizeof(heroinfo->name) - 1); - heroinfo->name[sizeof(heroinfo->name) - 1] = '\0'; - heroinfo->level = p->_pLevel; - heroinfo->heroclass = game_2_ui_class(p); - heroinfo->strength = p->_pStrength; - heroinfo->magic = p->_pMagic; - heroinfo->dexterity = p->_pDexterity; - heroinfo->vitality = p->_pVitality; - heroinfo->gold = p->_pGold; - heroinfo->hassaved = bHasSaveFile; - heroinfo->herorank = (unsigned char)p->pDiabloKillLevel; - heroinfo->spawned = 0; + memset(heroinfo, 0, sizeof(*heroinfo)); + strncpy(heroinfo->name, p->_pName, sizeof(heroinfo->name) - 1); + heroinfo->name[sizeof(heroinfo->name) - 1] = '\0'; + heroinfo->level = p->_pLevel; + heroinfo->heroclass = game_2_ui_class(p); + heroinfo->strength = p->_pStrength; + heroinfo->magic = p->_pMagic; + heroinfo->dexterity = p->_pDexterity; + heroinfo->vitality = p->_pVitality; + heroinfo->gold = p->_pGold; + heroinfo->hassaved = bHasSaveFile; + heroinfo->herorank = (unsigned char)p->pDiabloKillLevel; + heroinfo->spawned = 0; } unsigned char __fastcall game_2_ui_class(const PlayerStruct *p) { - unsigned char uiclass; - if (p->_pClass == PC_WARRIOR) - uiclass = UI_WARRIOR; - else if (p->_pClass == PC_ROGUE) - uiclass = UI_ROGUE; - else - uiclass = UI_SORCERER; + unsigned char uiclass; + if (p->_pClass == PC_WARRIOR) + uiclass = UI_WARRIOR; + else if (p->_pClass == PC_ROGUE) + uiclass = UI_ROGUE; + else + uiclass = UI_SORCERER; - return uiclass; + return uiclass; } BOOL __stdcall pfile_ui_set_hero_infos(BOOL(__stdcall *ui_add_hero_info)(_uiheroinfo *)) { - unsigned int i, save_num; - char FileName[MAX_PATH]; - char NewFileName[MAX_PATH]; - int a1; + unsigned int i, save_num; + char FileName[MAX_PATH]; + char NewFileName[MAX_PATH]; + int a1; - memset(hero_names, 0, sizeof(hero_names)); - if (gbMaxPlayers > 1) { - for (i = 0, save_num = 0; i < MAX_CHARACTERS && save_num < MAX_CHARACTERS; i++) { - struct _OFSTRUCT ReOpenBuff; - const char *s; + memset(hero_names, 0, sizeof(hero_names)); + if (gbMaxPlayers > 1) { + for (i = 0, save_num = 0; i < MAX_CHARACTERS && save_num < MAX_CHARACTERS; i++) { + struct _OFSTRUCT ReOpenBuff; + const char *s; - GetSaveDirectory(FileName, sizeof(FileName), i); - s = strrchr(FileName, '\\') + 1; - if (s == (const char *)1) - continue; - if (OpenFile(FileName, &ReOpenBuff, OF_EXIST) == HFILE_ERROR) - continue; - if (!SRegLoadString("Diablo\\Converted", s, 0, NewFileName, sizeof(NewFileName))) { - while (save_num < MAX_CHARACTERS) { - pfile_get_save_path(NewFileName, sizeof(NewFileName), save_num++); - if (OpenFile(NewFileName, &ReOpenBuff, OF_EXIST) == HFILE_ERROR) { - if (CopyFile(FileName, NewFileName, TRUE)) { - DWORD attrib; - SRegSaveString("Diablo\\Converted", s, 0, NewFileName); - attrib = GetFileAttributes(NewFileName); - if (attrib != INVALID_FILE_ATTRIBUTES) { - attrib &= ~(FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM); - SetFileAttributes(NewFileName, attrib); - } - } - break; - } - } - } - } - } + GetSaveDirectory(FileName, sizeof(FileName), i); + s = strrchr(FileName, '\\') + 1; + if (s == (const char *)1) + continue; + if (OpenFile(FileName, &ReOpenBuff, OF_EXIST) == HFILE_ERROR) + continue; + if (!SRegLoadString("Diablo\\Converted", s, 0, NewFileName, sizeof(NewFileName))) { + while (save_num < MAX_CHARACTERS) { + pfile_get_save_path(NewFileName, sizeof(NewFileName), save_num++); + if (OpenFile(NewFileName, &ReOpenBuff, OF_EXIST) == HFILE_ERROR) { + if (CopyFile(FileName, NewFileName, TRUE)) { + DWORD attrib; + SRegSaveString("Diablo\\Converted", s, 0, NewFileName); + attrib = GetFileAttributes(NewFileName); + if (attrib != INVALID_FILE_ATTRIBUTES) { + attrib &= ~(FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM); + SetFileAttributes(NewFileName, attrib); + } + } + break; + } + } + } + } + } - a1 = 1; - for (i = 0; i < MAX_CHARACTERS; i++) { - PkPlayerStruct pkplr; - HANDLE archive = pfile_open_save_archive(&a1, i); - if (archive) { - if (pfile_read_hero(archive, &pkplr)) { - _uiheroinfo uihero; - strcpy(hero_names[i], pkplr.pName); - UnPackPlayer(&pkplr, 0, FALSE); - game_2_ui_player(plr, &uihero, pfile_archive_contains_game(archive, i)); - ui_add_hero_info(&uihero); - } - pfile_SFileCloseArchive(archive); - } - } + a1 = 1; + for (i = 0; i < MAX_CHARACTERS; i++) { + PkPlayerStruct pkplr; + HANDLE archive = pfile_open_save_archive(&a1, i); + if (archive) { + if (pfile_read_hero(archive, &pkplr)) { + _uiheroinfo uihero; + strcpy(hero_names[i], pkplr.pName); + UnPackPlayer(&pkplr, 0, FALSE); + game_2_ui_player(plr, &uihero, pfile_archive_contains_game(archive, i)); + ui_add_hero_info(&uihero); + } + pfile_SFileCloseArchive(archive); + } + } - return TRUE; + return TRUE; } char *__fastcall GetSaveDirectory(char *dst, int dst_size, unsigned int save_num) { - DWORD dirLen; - char FileName[MAX_PATH]; - const char *savename; + DWORD dirLen; + char FileName[MAX_PATH]; + const char *savename; - // BUGFIX: ignores dst_size and uses MAX_PATH instead - if (gbMaxPlayers > 1) { - savename = "\\dlinfo_%d.drv"; - dirLen = GetWindowsDirectory(dst, MAX_PATH); - } else { - char *s; - savename = "\\single_%d.sv"; - dirLen = GetModuleFileName(ghInst, dst, MAX_PATH); - s = strrchr(dst, '\\'); - if (s) - *s = '\0'; - } + // BUGFIX: ignores dst_size and uses MAX_PATH instead + if (gbMaxPlayers > 1) { + savename = "\\dlinfo_%d.drv"; + dirLen = GetWindowsDirectory(dst, MAX_PATH); + } else { + char *s; + savename = "\\single_%d.sv"; + dirLen = GetModuleFileName(ghInst, dst, MAX_PATH); + s = strrchr(dst, '\\'); + if (s) + *s = '\0'; + } - if (!dirLen) - TermMsg("Unable to get save directory"); + if (!dirLen) + TermMsg("Unable to get save directory"); - sprintf(FileName, savename, save_num); - strcat(dst, FileName); - return _strlwr(dst); + sprintf(FileName, savename, save_num); + strcat(dst, FileName); + return _strlwr(dst); } BOOL __fastcall pfile_read_hero(HANDLE archive, PkPlayerStruct *pPack) { - HANDLE file; + HANDLE file; - if (!SFileOpenFileEx(archive, "hero", 0, &file)) - return FALSE; - else { - DWORD dwlen; - BOOL ret = FALSE; - char password[16] = PASSWORD_SINGLE; - DWORD nSize = 16; + if (!SFileOpenFileEx(archive, "hero", 0, &file)) + return FALSE; + else { + DWORD dwlen; + BOOL ret = FALSE; + char password[16] = PASSWORD_SINGLE; + DWORD nSize = 16; - if (gbMaxPlayers > 1) - strcpy(password, PASSWORD_MULTI); + if (gbMaxPlayers > 1) + strcpy(password, PASSWORD_MULTI); - dwlen = SFileGetFileSize(file, NULL); - if (dwlen) { - DWORD read; - unsigned char *buf = DiabloAllocPtr(dwlen); - if (SFileReadFile(file, buf, dwlen, &read, NULL)) { - BOOL decoded = TRUE; - read = codec_decode(buf, dwlen, password); - if (!read && gbMaxPlayers > 1) { - GetComputerName(password, &nSize); - if (SFileSetFilePointer(file, 0, NULL, 0) || !SFileReadFile(file, buf, dwlen, &read, NULL)) - decoded = FALSE; - else - read = codec_decode(buf, dwlen, password); - } - if (decoded && read == sizeof(*pPack)) { - memcpy(pPack, buf, sizeof(*pPack)); - ret = TRUE; - } - } - if (buf) - mem_free_dbg(buf); - } - SFileCloseFile(file); - return ret; - } + dwlen = SFileGetFileSize(file, NULL); + if (dwlen) { + DWORD read; + unsigned char *buf = DiabloAllocPtr(dwlen); + if (SFileReadFile(file, buf, dwlen, &read, NULL)) { + BOOL decoded = TRUE; + read = codec_decode(buf, dwlen, password); + if (!read && gbMaxPlayers > 1) { + GetComputerName(password, &nSize); + if (SFileSetFilePointer(file, 0, NULL, 0) || !SFileReadFile(file, buf, dwlen, &read, NULL)) + decoded = FALSE; + else + read = codec_decode(buf, dwlen, password); + } + if (decoded && read == sizeof(*pPack)) { + memcpy(pPack, buf, sizeof(*pPack)); + ret = TRUE; + } + } + if (buf) + mem_free_dbg(buf); + } + SFileCloseFile(file); + return ret; + } } HANDLE __fastcall pfile_open_save_archive(int *unused, unsigned int save_num) { - char SrcStr[MAX_PATH]; - HANDLE archive; + char SrcStr[MAX_PATH]; + HANDLE archive; - pfile_get_save_path(SrcStr, sizeof(SrcStr), save_num); - if (SFileOpenArchive(SrcStr, 0x7000, 0, &archive)) - return archive; - return NULL; + pfile_get_save_path(SrcStr, sizeof(SrcStr), save_num); + if (SFileOpenArchive(SrcStr, 0x7000, 0, &archive)) + return archive; + return NULL; } void __fastcall pfile_SFileCloseArchive(HANDLE hsArchive) { - SFileCloseArchive(hsArchive); + SFileCloseArchive(hsArchive); } BOOL __fastcall pfile_archive_contains_game(HANDLE hsArchive, unsigned int save_num) { - HANDLE file; + HANDLE file; - if (gbMaxPlayers != 1) - return FALSE; + if (gbMaxPlayers != 1) + return FALSE; - if (!SFileOpenFileEx(hsArchive, "game", 0, &file)) - return FALSE; + if (!SFileOpenFileEx(hsArchive, "game", 0, &file)) + return FALSE; - SFileCloseFile(file); - return TRUE; + SFileCloseFile(file); + return TRUE; } BOOL __stdcall pfile_ui_set_class_stats(unsigned int player_class_nr, _uidefaultstats *class_stats) { - int c; + int c; - c = pfile_get_player_class(player_class_nr); - class_stats->strength = StrengthTbl[c]; - class_stats->magic = MagicTbl[c]; - class_stats->dexterity = DexterityTbl[c]; - class_stats->vitality = VitalityTbl[c]; - return TRUE; + c = pfile_get_player_class(player_class_nr); + class_stats->strength = StrengthTbl[c]; + class_stats->magic = MagicTbl[c]; + class_stats->dexterity = DexterityTbl[c]; + class_stats->vitality = VitalityTbl[c]; + return TRUE; } char __fastcall pfile_get_player_class(unsigned int player_class_nr) { - char pc_class; + char pc_class; - if (player_class_nr == UI_WARRIOR) - pc_class = PC_WARRIOR; - else if (player_class_nr == UI_ROGUE) - pc_class = PC_ROGUE; - else - pc_class = PC_SORCERER; - return pc_class; + if (player_class_nr == UI_WARRIOR) + pc_class = PC_WARRIOR; + else if (player_class_nr == UI_ROGUE) + pc_class = PC_ROGUE; + else + pc_class = PC_SORCERER; + return pc_class; } BOOL __stdcall pfile_ui_save_create(_uiheroinfo *heroinfo) { - unsigned int save_num; - char cl; - PkPlayerStruct pkplr; + unsigned int save_num; + char cl; + PkPlayerStruct pkplr; - save_num = pfile_get_save_num_from_name(heroinfo->name); - if (save_num == MAX_CHARACTERS) { - for (save_num = 0; save_num < MAX_CHARACTERS; save_num++) { - if (!hero_names[save_num][0]) - break; - } - if (save_num == MAX_CHARACTERS) - return false; - } - if (!pfile_open_archive(FALSE, save_num)) - return FALSE; - mpqapi_remove_hash_entries(pfile_get_file_name); - strncpy(hero_names[save_num], heroinfo->name, PLR_NAME_LEN); - hero_names[save_num][PLR_NAME_LEN - 1] = '\0'; - cl = pfile_get_player_class(heroinfo->heroclass); - CreatePlayer(0, cl); - strncpy(plr[0]._pName, heroinfo->name, PLR_NAME_LEN); - plr[0]._pName[PLR_NAME_LEN - 1] = '\0'; - PackPlayer(&pkplr, 0, TRUE); - pfile_encode_hero(&pkplr); - game_2_ui_player(&plr[0], heroinfo, FALSE); - pfile_flush(TRUE, save_num); - return TRUE; + save_num = pfile_get_save_num_from_name(heroinfo->name); + if (save_num == MAX_CHARACTERS) { + for (save_num = 0; save_num < MAX_CHARACTERS; save_num++) { + if (!hero_names[save_num][0]) + break; + } + if (save_num == MAX_CHARACTERS) + return false; + } + if (!pfile_open_archive(FALSE, save_num)) + return FALSE; + mpqapi_remove_hash_entries(pfile_get_file_name); + strncpy(hero_names[save_num], heroinfo->name, PLR_NAME_LEN); + hero_names[save_num][PLR_NAME_LEN - 1] = '\0'; + cl = pfile_get_player_class(heroinfo->heroclass); + CreatePlayer(0, cl); + strncpy(plr[0]._pName, heroinfo->name, PLR_NAME_LEN); + plr[0]._pName[PLR_NAME_LEN - 1] = '\0'; + PackPlayer(&pkplr, 0, TRUE); + pfile_encode_hero(&pkplr); + game_2_ui_player(&plr[0], heroinfo, FALSE); + pfile_flush(TRUE, save_num); + return TRUE; } BOOL __stdcall pfile_get_file_name(DWORD lvl, char *dst) { - const char *fmt; + const char *fmt; - if (gbMaxPlayers > 1) { - if (lvl) - return FALSE; - fmt = "hero"; - } else { - if (lvl < 17) - fmt = "perml%02d"; - else if (lvl < 34) { - lvl -= 17; - fmt = "perms%02d"; - } else if (lvl == 34) - fmt = "game"; - else if (lvl == 35) - fmt = "hero"; - else - return FALSE; - } - sprintf(dst, fmt, lvl); - return TRUE; + if (gbMaxPlayers > 1) { + if (lvl) + return FALSE; + fmt = "hero"; + } else { + if (lvl < 17) + fmt = "perml%02d"; + else if (lvl < 34) { + lvl -= 17; + fmt = "perms%02d"; + } else if (lvl == 34) + fmt = "game"; + else if (lvl == 35) + fmt = "hero"; + else + return FALSE; + } + sprintf(dst, fmt, lvl); + return TRUE; } BOOL __stdcall pfile_delete_save(_uiheroinfo *hero_info) { - unsigned int save_num; - char FileName[MAX_PATH]; + unsigned int save_num; + char FileName[MAX_PATH]; - save_num = pfile_get_save_num_from_name(hero_info->name); - if (save_num < MAX_CHARACTERS) { - hero_names[save_num][0] = '\0'; - pfile_get_save_path(FileName, sizeof(FileName), save_num); - DeleteFile(FileName); - } - return TRUE; + save_num = pfile_get_save_num_from_name(hero_info->name); + if (save_num < MAX_CHARACTERS) { + hero_names[save_num][0] = '\0'; + pfile_get_save_path(FileName, sizeof(FileName), save_num); + DeleteFile(FileName); + } + return TRUE; } void __cdecl pfile_read_player_from_save() { - HANDLE archive; - unsigned int save_num; - PkPlayerStruct pkplr; + HANDLE archive; + unsigned int save_num; + PkPlayerStruct pkplr; - save_num = pfile_get_save_num_from_name(chr_name_str); - archive = pfile_open_save_archive(NULL, save_num); - if (archive == NULL) - TermMsg("Unable to open archive"); - if (!pfile_read_hero(archive, &pkplr)) - TermMsg("Unable to load character"); + save_num = pfile_get_save_num_from_name(chr_name_str); + archive = pfile_open_save_archive(NULL, save_num); + if (archive == NULL) + TermMsg("Unable to open archive"); + if (!pfile_read_hero(archive, &pkplr)) + TermMsg("Unable to load character"); - UnPackPlayer(&pkplr, myplr, FALSE); - gbValidSaveFile = pfile_archive_contains_game(archive, save_num); - pfile_SFileCloseArchive(archive); + UnPackPlayer(&pkplr, myplr, FALSE); + gbValidSaveFile = pfile_archive_contains_game(archive, save_num); + pfile_SFileCloseArchive(archive); } void __fastcall GetTempLevelNames(char *szTemp) { - // BUGFIX: function call has no purpose - pfile_get_save_num_from_name(plr[myplr]._pName); - if (setlevel) - sprintf(szTemp, "temps%02d", setlvlnum); - else - sprintf(szTemp, "templ%02d", currlevel); + // BUGFIX: function call has no purpose + pfile_get_save_num_from_name(plr[myplr]._pName); + if (setlevel) + sprintf(szTemp, "temps%02d", setlvlnum); + else + sprintf(szTemp, "templ%02d", currlevel); } void __fastcall GetPermLevelNames(char *szPerm) { - unsigned int save_num; - BOOL has_file; + unsigned int save_num; + BOOL has_file; - save_num = pfile_get_save_num_from_name(plr[myplr]._pName); - GetTempLevelNames(szPerm); - if (!pfile_open_archive(FALSE, save_num)) - TermMsg("Unable to read to save file archive"); + save_num = pfile_get_save_num_from_name(plr[myplr]._pName); + GetTempLevelNames(szPerm); + if (!pfile_open_archive(FALSE, save_num)) + TermMsg("Unable to read to save file archive"); - has_file = mpqapi_has_file(szPerm); - pfile_flush(TRUE, save_num); - if (!has_file) { - if (setlevel) - sprintf(szPerm, "perms%02d", setlvlnum); - else - sprintf(szPerm, "perml%02d", currlevel); - } + has_file = mpqapi_has_file(szPerm); + pfile_flush(TRUE, save_num); + if (!has_file) { + if (setlevel) + sprintf(szPerm, "perms%02d", setlvlnum); + else + sprintf(szPerm, "perml%02d", currlevel); + } } void __fastcall pfile_get_game_name(char *dst) { - // BUGFIX: function call with no purpose - pfile_get_save_num_from_name(plr[myplr]._pName); - strcpy(dst, "game"); + // BUGFIX: function call with no purpose + pfile_get_save_num_from_name(plr[myplr]._pName); + strcpy(dst, "game"); } void __cdecl pfile_remove_temp_files() { - if (gbMaxPlayers <= 1) { - unsigned int save_num = pfile_get_save_num_from_name(plr[myplr]._pName); - if (!pfile_open_archive(FALSE, save_num)) - TermMsg("Unable to write to save file archive"); - mpqapi_remove_hash_entries(GetTempSaveNames); - pfile_flush(TRUE, save_num); - } + if (gbMaxPlayers <= 1) { + unsigned int save_num = pfile_get_save_num_from_name(plr[myplr]._pName); + if (!pfile_open_archive(FALSE, save_num)) + TermMsg("Unable to write to save file archive"); + mpqapi_remove_hash_entries(GetTempSaveNames); + pfile_flush(TRUE, save_num); + } } BOOL __stdcall GetTempSaveNames(DWORD dwIndex, char *szTemp) { - const char *fmt; + const char *fmt; - if (dwIndex < 17) - fmt = "templ%02d"; - else if (dwIndex < 34) { - dwIndex -= 17; - fmt = "temps%02d"; - } else - return FALSE; + if (dwIndex < 17) + fmt = "templ%02d"; + else if (dwIndex < 34) { + dwIndex -= 17; + fmt = "temps%02d"; + } else + return FALSE; - sprintf(szTemp, fmt, dwIndex); - return TRUE; + sprintf(szTemp, fmt, dwIndex); + return TRUE; } void __cdecl pfile_rename_temp_to_perm() { - unsigned int save_num; - unsigned int i; - char TempName[MAX_PATH]; - char PermName[MAX_PATH]; + unsigned int save_num; + unsigned int i; + char TempName[MAX_PATH]; + char PermName[MAX_PATH]; - save_num = pfile_get_save_num_from_name(plr[myplr]._pName); - if (!pfile_open_archive(FALSE, save_num)) - TermMsg("Unable to write to save file archive"); + save_num = pfile_get_save_num_from_name(plr[myplr]._pName); + if (!pfile_open_archive(FALSE, save_num)) + TermMsg("Unable to write to save file archive"); - i = 0; - while (GetTempSaveNames(i, TempName)) { - GetPermSaveNames(i, PermName); - i++; - if (mpqapi_has_file(TempName)) { - if (mpqapi_has_file(PermName)) - mpqapi_remove_hash_entry(PermName); - mpqapi_rename(TempName, PermName); - } - } - GetPermSaveNames(i, PermName); - pfile_flush(TRUE, save_num); + i = 0; + while (GetTempSaveNames(i, TempName)) { + GetPermSaveNames(i, PermName); + i++; + if (mpqapi_has_file(TempName)) { + if (mpqapi_has_file(PermName)) + mpqapi_remove_hash_entry(PermName); + mpqapi_rename(TempName, PermName); + } + } + GetPermSaveNames(i, PermName); + pfile_flush(TRUE, save_num); } BOOL __stdcall GetPermSaveNames(DWORD dwIndex, char *szPerm) { - const char *fmt; + const char *fmt; - if (dwIndex < 17) - fmt = "perml%02d"; - else if (dwIndex < 34) { - dwIndex -= 17; - fmt = "perms%02d"; - } else - return FALSE; + if (dwIndex < 17) + fmt = "perml%02d"; + else if (dwIndex < 34) { + dwIndex -= 17; + fmt = "perms%02d"; + } else + return FALSE; - sprintf(szPerm, fmt, dwIndex); - return TRUE; + sprintf(szPerm, fmt, dwIndex); + return TRUE; } void __fastcall pfile_write_save_file(const char *pszName, BYTE *pbData, DWORD dwLen, DWORD qwLen) { - unsigned int save_num; - char FileName[MAX_PATH]; + unsigned int save_num; + char FileName[MAX_PATH]; - pfile_strcpy(FileName, pszName); - save_num = pfile_get_save_num_from_name(plr[myplr]._pName); - { - char password[16] = PASSWORD_SINGLE; - if (gbMaxPlayers > 1) - strcpy(password, PASSWORD_MULTI); + pfile_strcpy(FileName, pszName); + save_num = pfile_get_save_num_from_name(plr[myplr]._pName); + { + char password[16] = PASSWORD_SINGLE; + if (gbMaxPlayers > 1) + strcpy(password, PASSWORD_MULTI); - codec_encode(pbData, dwLen, qwLen, password); - } - if (!pfile_open_archive(FALSE, save_num)) - TermMsg("Unable to write so save file archive"); - mpqapi_write_file(FileName, pbData, qwLen); - pfile_flush(TRUE, save_num); + codec_encode(pbData, dwLen, qwLen, password); + } + if (!pfile_open_archive(FALSE, save_num)) + TermMsg("Unable to write so save file archive"); + mpqapi_write_file(FileName, pbData, qwLen); + pfile_flush(TRUE, save_num); } void __fastcall pfile_strcpy(char *dst, const char *src) { - strcpy(dst, src); + strcpy(dst, src); } BYTE *__fastcall pfile_read(const char *pszName, DWORD *pdwLen) { - unsigned int save_num; - char FileName[MAX_PATH]; - HANDLE archive, save; - BYTE *buf; - DWORD nread; + unsigned int save_num; + char FileName[MAX_PATH]; + HANDLE archive, save; + BYTE *buf; + DWORD nread; - pfile_strcpy(FileName, pszName); - save_num = pfile_get_save_num_from_name(plr[myplr]._pName); - archive = pfile_open_save_archive(NULL, save_num); - if (archive == NULL) - TermMsg("Unable to open save file archive"); + pfile_strcpy(FileName, pszName); + save_num = pfile_get_save_num_from_name(plr[myplr]._pName); + archive = pfile_open_save_archive(NULL, save_num); + if (archive == NULL) + TermMsg("Unable to open save file archive"); - if (!SFileOpenFileEx(archive, FileName, 0, &save)) - TermMsg("Unable to open save file"); + if (!SFileOpenFileEx(archive, FileName, 0, &save)) + TermMsg("Unable to open save file"); - *pdwLen = SFileGetFileSize(save, NULL); - if (*pdwLen == 0) - TermMsg("Invalid save file"); + *pdwLen = SFileGetFileSize(save, NULL); + if (*pdwLen == 0) + TermMsg("Invalid save file"); - buf = (BYTE *)DiabloAllocPtr(*pdwLen); - if (!SFileReadFile(save, buf, *pdwLen, &nread, NULL)) - TermMsg("Unable to read save file"); - SFileCloseFile(save); - pfile_SFileCloseArchive(archive); + buf = (BYTE *)DiabloAllocPtr(*pdwLen); + if (!SFileReadFile(save, buf, *pdwLen, &nread, NULL)) + TermMsg("Unable to read save file"); + SFileCloseFile(save); + pfile_SFileCloseArchive(archive); - { - char password[16] = PASSWORD_SINGLE; - DWORD nSize = 16; + { + char password[16] = PASSWORD_SINGLE; + DWORD nSize = 16; - if (gbMaxPlayers > 1) - strcpy(password, PASSWORD_MULTI); + if (gbMaxPlayers > 1) + strcpy(password, PASSWORD_MULTI); - *pdwLen = codec_decode(buf, *pdwLen, password); - if (*pdwLen == 0) { - // BUGFIFX: *pdwLen has already been overwritten with zero and the savefile has been closed - // there is no way this can work correctly - if (gbMaxPlayers > 1) { - GetComputerName(password, &nSize); - if (SFileSetFilePointer(save, 0, NULL, 0)) - TermMsg("Unable to read save file"); + *pdwLen = codec_decode(buf, *pdwLen, password); + if (*pdwLen == 0) { + // BUGFIFX: *pdwLen has already been overwritten with zero and the savefile has been closed + // there is no way this can work correctly + if (gbMaxPlayers > 1) { + GetComputerName(password, &nSize); + if (SFileSetFilePointer(save, 0, NULL, 0)) + TermMsg("Unable to read save file"); - if (!SFileReadFile(save, buf, *pdwLen, &nread, NULL)) - TermMsg("Unable to read save file"); - *pdwLen = codec_decode(buf, *pdwLen, password); - } - if (*pdwLen == 0) - TermMsg("Invalid save file"); - } - } - return buf; + if (!SFileReadFile(save, buf, *pdwLen, &nread, NULL)) + TermMsg("Unable to read save file"); + *pdwLen = codec_decode(buf, *pdwLen, password); + } + if (*pdwLen == 0) + TermMsg("Invalid save file"); + } + } + return buf; } void __fastcall pfile_update(BOOL force_save) { - // BUGFIX: these tick values should be treated as unsigned to handle overflows correctly - static int save_prev_tc; + // BUGFIX: these tick values should be treated as unsigned to handle overflows correctly + static int save_prev_tc; - if (gbMaxPlayers != 1) { - int tick = GetTickCount(); - if (force_save || tick - save_prev_tc > 60000) { - save_prev_tc = tick; - pfile_write_hero(); - } - } + if (gbMaxPlayers != 1) { + int tick = GetTickCount(); + if (force_save || tick - save_prev_tc > 60000) { + save_prev_tc = tick; + pfile_write_hero(); + } + } } diff --git a/Source/player.cpp b/Source/player.cpp index 5d31493f..4808c529 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -31,15 +31,15 @@ int plryoff[9] = { 0, 2, 2, 0, 1, 1, 0, 1, 2 }; int plrxoff2[9] = { 0, 1, 0, 1, 2, 0, 1, 2, 2 }; int plryoff2[9] = { 0, 0, 1, 1, 0, 2, 2, 1, 2 }; char PlrGFXAnimLens[3][11] = { - { 10, 16, 8, 2, 20, 20, 6, 20, 8, 9, 14 }, - { 8, 18, 8, 4, 20, 16, 7, 20, 8, 10, 12 }, - { 8, 16, 8, 6, 20, 12, 8, 20, 8, 12, 8 } + { 10, 16, 8, 2, 20, 20, 6, 20, 8, 9, 14 }, + { 8, 18, 8, 4, 20, 16, 7, 20, 8, 10, 12 }, + { 8, 16, 8, 6, 20, 12, 8, 20, 8, 12, 8 } }; int PWVel[4][3] = { - { 2048, 1024, 512 }, - { 2048, 1024, 512 }, - { 2048, 1024, 512 }, - { 8, 8, 8 } + { 2048, 1024, 512 }, + { 2048, 1024, 512 }, + { 2048, 1024, 512 }, + { 8, 8, 8 } }; int StrengthTbl[3] = { 30, 20, 15 }; int MagicTbl[3] = { 10, 15, 35 }; @@ -48,4011 +48,4011 @@ int VitalityTbl[3] = { 25, 20, 20 }; int ToBlkTbl[3] = { 30, 20, 10 }; char *ClassStrTblOld[3] = { "Warrior", "Rogue", "Sorceror" }; // unused int MaxStats[3][4] = { - { 250, 50, 60, 100 }, - { 55, 70, 250, 80 }, - { 45, 250, 85, 80 } + { 250, 50, 60, 100 }, + { 55, 70, 250, 80 }, + { 45, 250, 85, 80 } }; int ExpLvlsTbl[MAXCHARLEVEL] = { - 0, - 2000, - 4620, - 8040, - 12489, - 18258, - 25712, - 35309, - 47622, - 63364, - 83419, - 108879, - 141086, - 181683, - 231075, - 313656, - 424067, - 571190, - 766569, - 1025154, - 1366227, - 1814568, - 2401895, - 3168651, - 4166200, - 5459523, - 7130496, - 9281874, - 12042092, - 15571031, - 20066900, - 25774405, - 32994399, - 42095202, - 53525811, - 67831218, - 85670061, - 107834823, - 135274799, - 169122009, - 210720231, - 261657253, - 323800420, - 399335440, - 490808349, - 601170414, - 733825617, - 892680222, - 1082908612, - 1310707109, - 1583495809 + 0, + 2000, + 4620, + 8040, + 12489, + 18258, + 25712, + 35309, + 47622, + 63364, + 83419, + 108879, + 141086, + 181683, + 231075, + 313656, + 424067, + 571190, + 766569, + 1025154, + 1366227, + 1814568, + 2401895, + 3168651, + 4166200, + 5459523, + 7130496, + 9281874, + 12042092, + 15571031, + 20066900, + 25774405, + 32994399, + 42095202, + 53525811, + 67831218, + 85670061, + 107834823, + 135274799, + 169122009, + 210720231, + 261657253, + 323800420, + 399335440, + 490808349, + 601170414, + 733825617, + 892680222, + 1082908612, + 1310707109, + 1583495809 }; char *ClassStrTbl[3] = { "Warrior", "Rogue", "Sorceror" }; unsigned char fix[9] = { 0u, 0u, 3u, 3u, 3u, 6u, 6u, 6u, 8u }; /* PM_ChangeLightOff local type */ struct player_cpp_init { - player_cpp_init() - { - player_cpp_init_value = player_inf; - } + player_cpp_init() + { + player_cpp_init_value = player_inf; + } } _player_cpp_init; // 47F204: using guessed type int player_inf; // 68643C: using guessed type int player_cpp_init_value; void __fastcall SetPlayerGPtrs(UCHAR *pData, UCHAR **pAnim) { - for (int i = 0; i < 8; i++) { - pAnim[i] = pData + ((DWORD *)pData)[i]; - } + for (int i = 0; i < 8; i++) { + pAnim[i] = pData + ((DWORD *)pData)[i]; + } } void __fastcall LoadPlrGFX(int pnum, player_graphic gfxflag) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("LoadPlrGFX: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("LoadPlrGFX: illegal player %d", pnum); + } - char prefix[16]; - char pszName[256]; - char *szCel; - PlayerStruct *p = &plr[pnum]; - sprintf(prefix, "%c%c%c", CharChar[p->_pClass], ArmourChar[p->_pgfxnum >> 4], WepChar[p->_pgfxnum & 0xF]); - char *cs = ClassStrTbl[p->_pClass]; - UCHAR *pData; - UCHAR *pAnim; + char prefix[16]; + char pszName[256]; + char *szCel; + PlayerStruct *p = &plr[pnum]; + sprintf(prefix, "%c%c%c", CharChar[p->_pClass], ArmourChar[p->_pgfxnum >> 4], WepChar[p->_pgfxnum & 0xF]); + char *cs = ClassStrTbl[p->_pClass]; + UCHAR *pData; + UCHAR *pAnim; - for (DWORD i = 1; i <= PFILE_NONDEATH; i <<= 1) { - if (!(i & gfxflag)) { - continue; - } + for (DWORD i = 1; i <= PFILE_NONDEATH; i <<= 1) { + if (!(i & gfxflag)) { + continue; + } - switch (i) { - case PFILE_STAND: - szCel = "AS"; - if (leveltype == DTYPE_TOWN) { - szCel = "ST"; - } - pData = p->_pNData; - pAnim = (UCHAR *)p->_pNAnim; - break; - case PFILE_WALK: - szCel = "AW"; - if (leveltype == DTYPE_TOWN) { - szCel = "WL"; - } - pData = p->_pWData; - pAnim = (UCHAR *)p->_pWAnim; - break; - case PFILE_ATTACK: - if (leveltype == DTYPE_TOWN) { - continue; - } - szCel = "AT"; - pData = p->_pAData; - pAnim = (UCHAR *)p->_pAAnim; - break; - case PFILE_HIT: - if (leveltype == DTYPE_TOWN) { - continue; - } - szCel = "HT"; - pData = p->_pHData; - pAnim = (UCHAR *)p->_pHAnim; - break; - case PFILE_LIGHTNING: - if (leveltype == DTYPE_TOWN) { - continue; - } - szCel = "LM"; - pData = p->_pLData; - pAnim = (UCHAR *)p->_pLAnim; - break; - case PFILE_FIRE: - if (leveltype == DTYPE_TOWN) { - continue; - } - szCel = "FM"; - pData = p->_pFData; - pAnim = (UCHAR *)p->_pFAnim; - break; - case PFILE_MAGIC: - if (leveltype == DTYPE_TOWN) { - continue; - } - szCel = "QM"; - pData = p->_pTData; - pAnim = (UCHAR *)p->_pTAnim; - break; - case PFILE_DEATH: - if (p->_pgfxnum & 0xF) { - continue; - } - szCel = "DT"; - pData = p->_pDData; - pAnim = (UCHAR *)p->_pDAnim; - break; - case PFILE_BLOCK: - if (leveltype == DTYPE_TOWN) { - continue; - } - if (!p->_pBlockFlag) { - continue; - } + switch (i) { + case PFILE_STAND: + szCel = "AS"; + if (leveltype == DTYPE_TOWN) { + szCel = "ST"; + } + pData = p->_pNData; + pAnim = (UCHAR *)p->_pNAnim; + break; + case PFILE_WALK: + szCel = "AW"; + if (leveltype == DTYPE_TOWN) { + szCel = "WL"; + } + pData = p->_pWData; + pAnim = (UCHAR *)p->_pWAnim; + break; + case PFILE_ATTACK: + if (leveltype == DTYPE_TOWN) { + continue; + } + szCel = "AT"; + pData = p->_pAData; + pAnim = (UCHAR *)p->_pAAnim; + break; + case PFILE_HIT: + if (leveltype == DTYPE_TOWN) { + continue; + } + szCel = "HT"; + pData = p->_pHData; + pAnim = (UCHAR *)p->_pHAnim; + break; + case PFILE_LIGHTNING: + if (leveltype == DTYPE_TOWN) { + continue; + } + szCel = "LM"; + pData = p->_pLData; + pAnim = (UCHAR *)p->_pLAnim; + break; + case PFILE_FIRE: + if (leveltype == DTYPE_TOWN) { + continue; + } + szCel = "FM"; + pData = p->_pFData; + pAnim = (UCHAR *)p->_pFAnim; + break; + case PFILE_MAGIC: + if (leveltype == DTYPE_TOWN) { + continue; + } + szCel = "QM"; + pData = p->_pTData; + pAnim = (UCHAR *)p->_pTAnim; + break; + case PFILE_DEATH: + if (p->_pgfxnum & 0xF) { + continue; + } + szCel = "DT"; + pData = p->_pDData; + pAnim = (UCHAR *)p->_pDAnim; + break; + case PFILE_BLOCK: + if (leveltype == DTYPE_TOWN) { + continue; + } + if (!p->_pBlockFlag) { + continue; + } - szCel = "BL"; - pData = p->_pBData; - pAnim = (UCHAR *)p->_pBAnim; - break; - default: - TermMsg("PLR:2"); - break; - } + szCel = "BL"; + pData = p->_pBData; + pAnim = (UCHAR *)p->_pBAnim; + break; + default: + TermMsg("PLR:2"); + break; + } - sprintf(pszName, "PlrGFX\\%s\\%s\\%s%s.CL2", cs, prefix, prefix, szCel); - LoadFileWithMem(pszName, pData); - SetPlayerGPtrs((UCHAR *)pData, (UCHAR **)pAnim); - p->_pGFXLoad |= i; - } + sprintf(pszName, "PlrGFX\\%s\\%s\\%s%s.CL2", cs, prefix, prefix, szCel); + LoadFileWithMem(pszName, pData); + SetPlayerGPtrs((UCHAR *)pData, (UCHAR **)pAnim); + p->_pGFXLoad |= i; + } } void __fastcall InitPlayerGFX(int pnum) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("InitPlayerGFX: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("InitPlayerGFX: illegal player %d", pnum); + } - if (plr[pnum]._pHitPoints >> 6 == 0) { - plr[pnum]._pgfxnum = 0; - LoadPlrGFX(pnum, PFILE_DEATH); - } else { - LoadPlrGFX(pnum, PFILE_NONDEATH); - } + if (plr[pnum]._pHitPoints >> 6 == 0) { + plr[pnum]._pgfxnum = 0; + LoadPlrGFX(pnum, PFILE_DEATH); + } else { + LoadPlrGFX(pnum, PFILE_NONDEATH); + } } void __fastcall InitPlrGFXMem(int pnum) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("InitPlrGFXMem: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("InitPlrGFXMem: illegal player %d", pnum); + } - if (!(plr_gfx_flag & 0x1)) { //STAND - plr_gfx_flag |= 0x1; - if (GetPlrGFXSize("ST") > GetPlrGFXSize("AS")) { - plr_sframe_size = GetPlrGFXSize("ST"); //TOWN - } else { - plr_sframe_size = GetPlrGFXSize("AS"); //DUNGION - } - } - plr[pnum]._pNData = DiabloAllocPtr(plr_sframe_size); + if (!(plr_gfx_flag & 0x1)) { //STAND + plr_gfx_flag |= 0x1; + if (GetPlrGFXSize("ST") > GetPlrGFXSize("AS")) { + plr_sframe_size = GetPlrGFXSize("ST"); //TOWN + } else { + plr_sframe_size = GetPlrGFXSize("AS"); //DUNGION + } + } + plr[pnum]._pNData = DiabloAllocPtr(plr_sframe_size); - if (!(plr_gfx_flag & 0x2)) { //WALK - plr_gfx_flag |= 0x2; - if (GetPlrGFXSize("WL") > GetPlrGFXSize("AW")) { - plr_wframe_size = GetPlrGFXSize("WL"); //TOWN - } else { - plr_wframe_size = GetPlrGFXSize("AW"); //DUNGION - } - } - plr[pnum]._pWData = DiabloAllocPtr(plr_wframe_size); + if (!(plr_gfx_flag & 0x2)) { //WALK + plr_gfx_flag |= 0x2; + if (GetPlrGFXSize("WL") > GetPlrGFXSize("AW")) { + plr_wframe_size = GetPlrGFXSize("WL"); //TOWN + } else { + plr_wframe_size = GetPlrGFXSize("AW"); //DUNGION + } + } + plr[pnum]._pWData = DiabloAllocPtr(plr_wframe_size); - if (!(plr_gfx_flag & 0x4)) { //ATTACK - plr_gfx_flag |= 0x4; - plr_aframe_size = GetPlrGFXSize("AT"); - } - plr[pnum]._pAData = DiabloAllocPtr(plr_aframe_size); + if (!(plr_gfx_flag & 0x4)) { //ATTACK + plr_gfx_flag |= 0x4; + plr_aframe_size = GetPlrGFXSize("AT"); + } + plr[pnum]._pAData = DiabloAllocPtr(plr_aframe_size); - if (!(plr_gfx_flag & 0x8)) { //HIT - plr_gfx_flag |= 0x8; - plr_hframe_size = GetPlrGFXSize("HT"); - } - plr[pnum]._pHData = DiabloAllocPtr(plr_hframe_size); + if (!(plr_gfx_flag & 0x8)) { //HIT + plr_gfx_flag |= 0x8; + plr_hframe_size = GetPlrGFXSize("HT"); + } + plr[pnum]._pHData = DiabloAllocPtr(plr_hframe_size); - if (!(plr_gfx_flag & 0x10)) { //LIGHTNING - plr_gfx_flag |= 0x10; - plr_lframe_size = GetPlrGFXSize("LM"); - } - plr[pnum]._pLData = DiabloAllocPtr(plr_lframe_size); + if (!(plr_gfx_flag & 0x10)) { //LIGHTNING + plr_gfx_flag |= 0x10; + plr_lframe_size = GetPlrGFXSize("LM"); + } + plr[pnum]._pLData = DiabloAllocPtr(plr_lframe_size); - if (!(plr_gfx_flag & 0x20)) { //FIRE - plr_gfx_flag |= 0x20; - plr_fframe_size = GetPlrGFXSize("FM"); - } - plr[pnum]._pFData = DiabloAllocPtr(plr_fframe_size); + if (!(plr_gfx_flag & 0x20)) { //FIRE + plr_gfx_flag |= 0x20; + plr_fframe_size = GetPlrGFXSize("FM"); + } + plr[pnum]._pFData = DiabloAllocPtr(plr_fframe_size); - if (!(plr_gfx_flag & 0x40)) { //MAGIC - plr_gfx_flag |= 0x40; - plr_qframe_size = GetPlrGFXSize("QM"); - } - plr[pnum]._pTData = DiabloAllocPtr(plr_qframe_size); + if (!(plr_gfx_flag & 0x40)) { //MAGIC + plr_gfx_flag |= 0x40; + plr_qframe_size = GetPlrGFXSize("QM"); + } + plr[pnum]._pTData = DiabloAllocPtr(plr_qframe_size); - if (!(plr_gfx_flag & 0x80)) { //DEATH - plr_gfx_flag |= 0x80; - plr_dframe_size = GetPlrGFXSize("DT"); - } - plr[pnum]._pDData = DiabloAllocPtr(plr_dframe_size); + if (!(plr_gfx_flag & 0x80)) { //DEATH + plr_gfx_flag |= 0x80; + plr_dframe_size = GetPlrGFXSize("DT"); + } + plr[pnum]._pDData = DiabloAllocPtr(plr_dframe_size); - if (!(plr_gfx_bflag & 0x1)) { //BLOCK - plr_gfx_bflag |= 0x1; - plr_bframe_size = GetPlrGFXSize("BL"); - } - plr[pnum]._pBData = DiabloAllocPtr(plr_bframe_size); + if (!(plr_gfx_bflag & 0x1)) { //BLOCK + plr_gfx_bflag |= 0x1; + plr_bframe_size = GetPlrGFXSize("BL"); + } + plr[pnum]._pBData = DiabloAllocPtr(plr_bframe_size); - plr[pnum]._pGFXLoad = 0; + plr[pnum]._pGFXLoad = 0; } DWORD __fastcall GetPlrGFXSize(char *szCel) { - char prefix[16]; - char pszName[256]; - void *file; - DWORD size = 0; - DWORD result = 0; - int a = 0; - int w = 0; + char prefix[16]; + char pszName[256]; + void *file; + DWORD size = 0; + DWORD result = 0; + int a = 0; + int w = 0; - for (int c = 0; c < sizeof(ClassStrTbl) / sizeof(ClassStrTbl[0]); c++) { - for (a = 0; ArmourChar[a]; a++) { - for (w = 0; WepChar[w]; w++) { - sprintf(prefix, "%c%c%c", CharChar[c], ArmourChar[a], WepChar[w]); - sprintf(pszName, "PlrGFX\\%s\\%s\\%s%s.CL2", ClassStrTbl[c], prefix, prefix, szCel); - if (WOpenFile(pszName, &file, TRUE)) { - size = WGetFileSize(file, 0); - WCloseFile(file); - if (result <= size) { - result = size; - } - } - } - } - } + for (int c = 0; c < sizeof(ClassStrTbl) / sizeof(ClassStrTbl[0]); c++) { + for (a = 0; ArmourChar[a]; a++) { + for (w = 0; WepChar[w]; w++) { + sprintf(prefix, "%c%c%c", CharChar[c], ArmourChar[a], WepChar[w]); + sprintf(pszName, "PlrGFX\\%s\\%s\\%s%s.CL2", ClassStrTbl[c], prefix, prefix, szCel); + if (WOpenFile(pszName, &file, TRUE)) { + size = WGetFileSize(file, 0); + WCloseFile(file); + if (result <= size) { + result = size; + } + } + } + } + } - return result; + return result; } void __fastcall FreePlayerGFX(int pnum) { - void *ptr; + void *ptr; - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("FreePlayerGFX: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("FreePlayerGFX: illegal player %d", pnum); + } - ptr = plr[pnum]._pNData; - plr[pnum]._pNData = NULL; - mem_free_dbg(ptr); - ptr = plr[pnum]._pWData; - plr[pnum]._pWData = NULL; - mem_free_dbg(ptr); - ptr = plr[pnum]._pAData; - plr[pnum]._pAData = NULL; - mem_free_dbg(ptr); - ptr = plr[pnum]._pHData; - plr[pnum]._pHData = NULL; - mem_free_dbg(ptr); - ptr = plr[pnum]._pLData; - plr[pnum]._pLData = NULL; - mem_free_dbg(ptr); - ptr = plr[pnum]._pFData; - plr[pnum]._pFData = NULL; - mem_free_dbg(ptr); - ptr = plr[pnum]._pTData; - plr[pnum]._pTData = NULL; - mem_free_dbg(ptr); - ptr = plr[pnum]._pDData; - plr[pnum]._pDData = NULL; - mem_free_dbg(ptr); - ptr = plr[pnum]._pBData; - plr[pnum]._pBData = NULL; - mem_free_dbg(ptr); - plr[pnum]._pGFXLoad = 0; + ptr = plr[pnum]._pNData; + plr[pnum]._pNData = NULL; + mem_free_dbg(ptr); + ptr = plr[pnum]._pWData; + plr[pnum]._pWData = NULL; + mem_free_dbg(ptr); + ptr = plr[pnum]._pAData; + plr[pnum]._pAData = NULL; + mem_free_dbg(ptr); + ptr = plr[pnum]._pHData; + plr[pnum]._pHData = NULL; + mem_free_dbg(ptr); + ptr = plr[pnum]._pLData; + plr[pnum]._pLData = NULL; + mem_free_dbg(ptr); + ptr = plr[pnum]._pFData; + plr[pnum]._pFData = NULL; + mem_free_dbg(ptr); + ptr = plr[pnum]._pTData; + plr[pnum]._pTData = NULL; + mem_free_dbg(ptr); + ptr = plr[pnum]._pDData; + plr[pnum]._pDData = NULL; + mem_free_dbg(ptr); + ptr = plr[pnum]._pBData; + plr[pnum]._pBData = NULL; + mem_free_dbg(ptr); + plr[pnum]._pGFXLoad = 0; } void __fastcall NewPlrAnim(int pnum, unsigned char *Peq, int numFrames, int Delay, int width) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("NewPlrAnim: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("NewPlrAnim: illegal player %d", pnum); + } - plr[pnum]._pAnimData = Peq; - plr[pnum]._pAnimLen = numFrames; - plr[pnum]._pAnimFrame = 1; - plr[pnum]._pAnimCnt = 0; - plr[pnum]._pAnimDelay = Delay; - plr[pnum]._pAnimWidth = width; - plr[pnum]._pAnimWidth2 = (width - 64) >> 1; + plr[pnum]._pAnimData = Peq; + plr[pnum]._pAnimLen = numFrames; + plr[pnum]._pAnimFrame = 1; + plr[pnum]._pAnimCnt = 0; + plr[pnum]._pAnimDelay = Delay; + plr[pnum]._pAnimWidth = width; + plr[pnum]._pAnimWidth2 = (width - 64) >> 1; } void __fastcall ClearPlrPVars(int pnum) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("ClearPlrPVars: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("ClearPlrPVars: illegal player %d", pnum); + } - plr[pnum]._pVar1 = 0; - plr[pnum]._pVar2 = 0; - plr[pnum]._pVar3 = 0; - plr[pnum]._pVar4 = 0; - plr[pnum]._pVar5 = 0; - plr[pnum]._pVar6 = 0; - plr[pnum]._pVar7 = 0; - plr[pnum]._pVar8 = 0; + plr[pnum]._pVar1 = 0; + plr[pnum]._pVar2 = 0; + plr[pnum]._pVar3 = 0; + plr[pnum]._pVar4 = 0; + plr[pnum]._pVar5 = 0; + plr[pnum]._pVar6 = 0; + plr[pnum]._pVar7 = 0; + plr[pnum]._pVar8 = 0; } void __fastcall SetPlrAnims(int pnum) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("SetPlrAnims: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("SetPlrAnims: illegal player %d", pnum); + } - int pc = plr[pnum]._pClass; + int pc = plr[pnum]._pClass; - plr[pnum]._pNWidth = 96; - plr[pnum]._pWWidth = 96; - plr[pnum]._pAWidth = 128; - plr[pnum]._pHWidth = 96; - plr[pnum]._pSWidth = 96; - plr[pnum]._pDWidth = 128; - plr[pnum]._pBWidth = 96; + plr[pnum]._pNWidth = 96; + plr[pnum]._pWWidth = 96; + plr[pnum]._pAWidth = 128; + plr[pnum]._pHWidth = 96; + plr[pnum]._pSWidth = 96; + plr[pnum]._pDWidth = 128; + plr[pnum]._pBWidth = 96; - if (leveltype == DTYPE_TOWN) { - plr[pnum]._pNFrames = PlrGFXAnimLens[pc][7]; - plr[pnum]._pWFrames = PlrGFXAnimLens[pc][8]; - plr[pnum]._pDFrames = PlrGFXAnimLens[pc][4]; - plr[pnum]._pSFrames = PlrGFXAnimLens[pc][5]; - } else { - plr[pnum]._pNFrames = PlrGFXAnimLens[pc][0]; - plr[pnum]._pWFrames = PlrGFXAnimLens[pc][2]; - plr[pnum]._pAFrames = PlrGFXAnimLens[pc][1]; - plr[pnum]._pHFrames = PlrGFXAnimLens[pc][6]; - plr[pnum]._pSFrames = PlrGFXAnimLens[pc][5]; - plr[pnum]._pDFrames = PlrGFXAnimLens[pc][4]; - plr[pnum]._pBFrames = PlrGFXAnimLens[pc][3]; - plr[pnum]._pAFNum = PlrGFXAnimLens[pc][9]; - } - plr[pnum]._pSFNum = PlrGFXAnimLens[pc][10]; + if (leveltype == DTYPE_TOWN) { + plr[pnum]._pNFrames = PlrGFXAnimLens[pc][7]; + plr[pnum]._pWFrames = PlrGFXAnimLens[pc][8]; + plr[pnum]._pDFrames = PlrGFXAnimLens[pc][4]; + plr[pnum]._pSFrames = PlrGFXAnimLens[pc][5]; + } else { + plr[pnum]._pNFrames = PlrGFXAnimLens[pc][0]; + plr[pnum]._pWFrames = PlrGFXAnimLens[pc][2]; + plr[pnum]._pAFrames = PlrGFXAnimLens[pc][1]; + plr[pnum]._pHFrames = PlrGFXAnimLens[pc][6]; + plr[pnum]._pSFrames = PlrGFXAnimLens[pc][5]; + plr[pnum]._pDFrames = PlrGFXAnimLens[pc][4]; + plr[pnum]._pBFrames = PlrGFXAnimLens[pc][3]; + plr[pnum]._pAFNum = PlrGFXAnimLens[pc][9]; + } + plr[pnum]._pSFNum = PlrGFXAnimLens[pc][10]; - int gn = plr[pnum]._pgfxnum & 0xF; - if (pc == PC_WARRIOR) { - if (gn == ANIM_ID_BOW) { - if (leveltype != DTYPE_TOWN) { - plr[pnum]._pNFrames = 8; - } - plr[pnum]._pAWidth = 96; - plr[pnum]._pAFNum = 11; - } else if (gn == ANIM_ID_AXE) { - plr[pnum]._pAFrames = 20; - plr[pnum]._pAFNum = 10; - } else if (gn == ANIM_ID_STAFF) { - plr[pnum]._pAFrames = 16; - plr[pnum]._pAFNum = 11; - } - } else if (pc == PC_ROGUE) { - if (gn == ANIM_ID_AXE) { - plr[pnum]._pAFrames = 22; - plr[pnum]._pAFNum = 13; - } else if (gn == ANIM_ID_BOW) { - plr[pnum]._pAFrames = 12; - plr[pnum]._pAFNum = 7; - } else if (gn == ANIM_ID_STAFF) { - plr[pnum]._pAFrames = 16; - plr[pnum]._pAFNum = 11; - } - } else if (pc == PC_SORCERER) { - plr[pnum]._pSWidth = 128; - if (gn == ANIM_ID_UNARMED) { - plr[pnum]._pAFrames = 20; - } else if (gn == ANIM_ID_UNARMED_SHIELD) { - plr[pnum]._pAFNum = 9; - } else if (gn == ANIM_ID_BOW) { - plr[pnum]._pAFrames = 20; - plr[pnum]._pAFNum = 16; - } else if (gn == ANIM_ID_AXE) { - plr[pnum]._pAFrames = 24; - plr[pnum]._pAFNum = 16; - } - } + int gn = plr[pnum]._pgfxnum & 0xF; + if (pc == PC_WARRIOR) { + if (gn == ANIM_ID_BOW) { + if (leveltype != DTYPE_TOWN) { + plr[pnum]._pNFrames = 8; + } + plr[pnum]._pAWidth = 96; + plr[pnum]._pAFNum = 11; + } else if (gn == ANIM_ID_AXE) { + plr[pnum]._pAFrames = 20; + plr[pnum]._pAFNum = 10; + } else if (gn == ANIM_ID_STAFF) { + plr[pnum]._pAFrames = 16; + plr[pnum]._pAFNum = 11; + } + } else if (pc == PC_ROGUE) { + if (gn == ANIM_ID_AXE) { + plr[pnum]._pAFrames = 22; + plr[pnum]._pAFNum = 13; + } else if (gn == ANIM_ID_BOW) { + plr[pnum]._pAFrames = 12; + plr[pnum]._pAFNum = 7; + } else if (gn == ANIM_ID_STAFF) { + plr[pnum]._pAFrames = 16; + plr[pnum]._pAFNum = 11; + } + } else if (pc == PC_SORCERER) { + plr[pnum]._pSWidth = 128; + if (gn == ANIM_ID_UNARMED) { + plr[pnum]._pAFrames = 20; + } else if (gn == ANIM_ID_UNARMED_SHIELD) { + plr[pnum]._pAFNum = 9; + } else if (gn == ANIM_ID_BOW) { + plr[pnum]._pAFrames = 20; + plr[pnum]._pAFNum = 16; + } else if (gn == ANIM_ID_AXE) { + plr[pnum]._pAFrames = 24; + plr[pnum]._pAFNum = 16; + } + } } void __fastcall ClearPlrRVars(PlayerStruct *p) { - // TODO: Missing debug assert p != NULL - p->bReserved[0] = 0; - p->bReserved[1] = 0; - p->bReserved[2] = 0; - p->wReserved[0] = 0; - p->wReserved[1] = 0; - p->wReserved[2] = 0; - p->wReserved[3] = 0; - p->wReserved[4] = 0; - p->wReserved[5] = 0; - p->wReserved[6] = 0; - p->wReserved[7] = 0; - p->dwReserved[0] = 0; - p->dwReserved[1] = 0; - p->dwReserved[2] = 0; - p->dwReserved[3] = 0; - p->dwReserved[4] = 0; - p->dwReserved[5] = 0; - p->dwReserved[6] = 0; + // TODO: Missing debug assert p != NULL + p->bReserved[0] = 0; + p->bReserved[1] = 0; + p->bReserved[2] = 0; + p->wReserved[0] = 0; + p->wReserved[1] = 0; + p->wReserved[2] = 0; + p->wReserved[3] = 0; + p->wReserved[4] = 0; + p->wReserved[5] = 0; + p->wReserved[6] = 0; + p->wReserved[7] = 0; + p->dwReserved[0] = 0; + p->dwReserved[1] = 0; + p->dwReserved[2] = 0; + p->dwReserved[3] = 0; + p->dwReserved[4] = 0; + p->dwReserved[5] = 0; + p->dwReserved[6] = 0; } // c: plr_classes value void __fastcall CreatePlayer(int pnum, char c) { - ClearPlrRVars(&plr[pnum]); - SetRndSeed(GetTickCount()); + ClearPlrRVars(&plr[pnum]); + SetRndSeed(GetTickCount()); - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("CreatePlayer: illegal player %d", pnum); - } - plr[pnum]._pClass = c; + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("CreatePlayer: illegal player %d", pnum); + } + plr[pnum]._pClass = c; - char val = StrengthTbl[c]; - if (val < 0) { - val = 0; - } - plr[pnum]._pStrength = val; - plr[pnum]._pBaseStr = val; + char val = StrengthTbl[c]; + if (val < 0) { + val = 0; + } + plr[pnum]._pStrength = val; + plr[pnum]._pBaseStr = val; - val = MagicTbl[c]; - if (val < 0) { - val = 0; - } - plr[pnum]._pMagic = val; - plr[pnum]._pBaseMag = val; + val = MagicTbl[c]; + if (val < 0) { + val = 0; + } + plr[pnum]._pMagic = val; + plr[pnum]._pBaseMag = val; - val = DexterityTbl[c]; - if (val < 0) { - val = 0; - } - plr[pnum]._pDexterity = val; - plr[pnum]._pBaseDex = val; + val = DexterityTbl[c]; + if (val < 0) { + val = 0; + } + plr[pnum]._pDexterity = val; + plr[pnum]._pBaseDex = val; - val = VitalityTbl[c]; - if (val < 0) { - val = 0; - } - plr[pnum]._pVitality = val; - plr[pnum]._pBaseVit = val; + val = VitalityTbl[c]; + if (val < 0) { + val = 0; + } + plr[pnum]._pVitality = val; + plr[pnum]._pBaseVit = val; - plr[pnum]._pStatPts = 0; - plr[pnum].pTownWarps = 0; - plr[pnum].pDungMsgs = 0; - plr[pnum].pLvlLoad = 0; - plr[pnum].pDiabloKillLevel = 0; + plr[pnum]._pStatPts = 0; + plr[pnum].pTownWarps = 0; + plr[pnum].pDungMsgs = 0; + plr[pnum].pLvlLoad = 0; + plr[pnum].pDiabloKillLevel = 0; - if (c == PC_ROGUE) { - plr[pnum]._pDamageMod = plr[pnum]._pLevel * (plr[pnum]._pStrength + plr[pnum]._pDexterity) / 200; - } else { - plr[pnum]._pDamageMod = plr[pnum]._pStrength * plr[pnum]._pLevel / 100; - } + if (c == PC_ROGUE) { + plr[pnum]._pDamageMod = plr[pnum]._pLevel * (plr[pnum]._pStrength + plr[pnum]._pDexterity) / 200; + } else { + plr[pnum]._pDamageMod = plr[pnum]._pStrength * plr[pnum]._pLevel / 100; + } - plr[pnum]._pBaseToBlk = ToBlkTbl[c]; + plr[pnum]._pBaseToBlk = ToBlkTbl[c]; - plr[pnum]._pHitPoints = (val + 10) << 6; - if (c == PC_WARRIOR) { - plr[pnum]._pHitPoints *= 2; - } - if (c == PC_ROGUE) { - plr[pnum]._pHitPoints += plr[pnum]._pHitPoints >> 1; - } + plr[pnum]._pHitPoints = (val + 10) << 6; + if (c == PC_WARRIOR) { + plr[pnum]._pHitPoints *= 2; + } + if (c == PC_ROGUE) { + plr[pnum]._pHitPoints += plr[pnum]._pHitPoints >> 1; + } - int hp = plr[pnum]._pHitPoints; - plr[pnum]._pMaxHP = hp; - plr[pnum]._pHPBase = hp; - plr[pnum]._pMaxHPBase = hp; + int hp = plr[pnum]._pHitPoints; + plr[pnum]._pMaxHP = hp; + plr[pnum]._pHPBase = hp; + plr[pnum]._pMaxHPBase = hp; - plr[pnum]._pMana = plr[pnum]._pMagic << 6; - if (c == PC_SORCERER) { - plr[pnum]._pMana *= 2; - } - if (c == PC_ROGUE) { - plr[pnum]._pMana += plr[pnum]._pMana >> 1; - } + plr[pnum]._pMana = plr[pnum]._pMagic << 6; + if (c == PC_SORCERER) { + plr[pnum]._pMana *= 2; + } + if (c == PC_ROGUE) { + plr[pnum]._pMana += plr[pnum]._pMana >> 1; + } - int mana = plr[pnum]._pMana; - plr[pnum]._pMaxMana = mana; - plr[pnum]._pManaBase = mana; - plr[pnum]._pMaxManaBase = mana; + int mana = plr[pnum]._pMana; + plr[pnum]._pMaxMana = mana; + plr[pnum]._pManaBase = mana; + plr[pnum]._pMaxManaBase = mana; - plr[pnum]._pLevel = 1; - plr[pnum]._pMaxLvl = 1; - plr[pnum]._pExperience = 0; - plr[pnum]._pMaxExp = 0; - plr[pnum]._pNextExper = ExpLvlsTbl[1]; - plr[pnum]._pArmorClass = 0; - plr[pnum]._pMagResist = 0; - plr[pnum]._pFireResist = 0; - plr[pnum]._pLghtResist = 0; - plr[pnum]._pLightRad = 10; - plr[pnum]._pInfraFlag = 0; + plr[pnum]._pLevel = 1; + plr[pnum]._pMaxLvl = 1; + plr[pnum]._pExperience = 0; + plr[pnum]._pMaxExp = 0; + plr[pnum]._pNextExper = ExpLvlsTbl[1]; + plr[pnum]._pArmorClass = 0; + plr[pnum]._pMagResist = 0; + plr[pnum]._pFireResist = 0; + plr[pnum]._pLghtResist = 0; + plr[pnum]._pLightRad = 10; + plr[pnum]._pInfraFlag = 0; - if (c == PC_WARRIOR) { - plr[pnum]._pAblSpells = (__int64)1 << (SPL_REPAIR - 1); - } else if (c == PC_ROGUE) { - plr[pnum]._pAblSpells = (__int64)1 << (SPL_DISARM - 1); - } else if (c == PC_SORCERER) { - plr[pnum]._pAblSpells = (__int64)1 << (SPL_RECHARGE - 1); - } + if (c == PC_WARRIOR) { + plr[pnum]._pAblSpells = (__int64)1 << (SPL_REPAIR - 1); + } else if (c == PC_ROGUE) { + plr[pnum]._pAblSpells = (__int64)1 << (SPL_DISARM - 1); + } else if (c == PC_SORCERER) { + plr[pnum]._pAblSpells = (__int64)1 << (SPL_RECHARGE - 1); + } - if (c == PC_SORCERER) { - plr[pnum]._pMemSpells = 1; - } else { - plr[pnum]._pMemSpells = 0; - } + if (c == PC_SORCERER) { + plr[pnum]._pMemSpells = 1; + } else { + plr[pnum]._pMemSpells = 0; + } - int i; - for (i = 0; i < sizeof(plr[pnum]._pSplLvl); i++) { - plr[pnum]._pSplLvl[i] = 0; - } + int i; + for (i = 0; i < sizeof(plr[pnum]._pSplLvl); i++) { + plr[pnum]._pSplLvl[i] = 0; + } - plr[pnum]._pSpellFlags = 0; + plr[pnum]._pSpellFlags = 0; - if (plr[pnum]._pClass == PC_SORCERER) { - plr[pnum]._pSplLvl[SPL_FIREBOLT] = 2; - } + if (plr[pnum]._pClass == PC_SORCERER) { + plr[pnum]._pSplLvl[SPL_FIREBOLT] = 2; + } - // interestingly, only the first three hotkeys are reset - // TODO: BUGFIX: clear all 4 hotkeys instead of 3 (demo leftover) - for (i = 0; i < 3; i++) { - plr[pnum]._pSplHotKey[i] = -1; - } + // interestingly, only the first three hotkeys are reset + // TODO: BUGFIX: clear all 4 hotkeys instead of 3 (demo leftover) + for (i = 0; i < 3; i++) { + plr[pnum]._pSplHotKey[i] = -1; + } - if (c == PC_WARRIOR) { - plr[pnum]._pgfxnum = ANIM_ID_SWORD_SHIELD; - } else if (c == PC_ROGUE) { - plr[pnum]._pgfxnum = ANIM_ID_BOW; - } else if (c == PC_SORCERER) { - plr[pnum]._pgfxnum = ANIM_ID_STAFF; - } + if (c == PC_WARRIOR) { + plr[pnum]._pgfxnum = ANIM_ID_SWORD_SHIELD; + } else if (c == PC_ROGUE) { + plr[pnum]._pgfxnum = ANIM_ID_BOW; + } else if (c == PC_SORCERER) { + plr[pnum]._pgfxnum = ANIM_ID_STAFF; + } - for (i = 0; i < sizeof(plr[pnum]._pLvlVisited); i++) { - plr[pnum]._pLvlVisited[i] = 0; - } + for (i = 0; i < sizeof(plr[pnum]._pLvlVisited); i++) { + plr[pnum]._pLvlVisited[i] = 0; + } - for (i = 0; i < 10; i++) { - plr[pnum]._pSLvlVisited[i] = 0; // TODO double check size of _pSLvlVisited - } + for (i = 0; i < 10; i++) { + plr[pnum]._pSLvlVisited[i] = 0; // TODO double check size of _pSLvlVisited + } - plr[pnum]._pLvlChanging = 0; - plr[pnum].pTownWarps = 0; - plr[pnum].pLvlLoad = 0; - plr[pnum].pBattleNet = 0; - plr[pnum].pManaShield = 0; + plr[pnum]._pLvlChanging = 0; + plr[pnum].pTownWarps = 0; + plr[pnum].pLvlLoad = 0; + plr[pnum].pBattleNet = 0; + plr[pnum].pManaShield = 0; - InitDungMsgs(pnum); - CreatePlrItems(pnum); - SetRndSeed(0); + InitDungMsgs(pnum); + CreatePlrItems(pnum); + SetRndSeed(0); } int __fastcall CalcStatDiff(int pnum) { - int c = plr[pnum]._pClass; - return MaxStats[c][ATTRIB_STR] - - plr[pnum]._pBaseStr - + MaxStats[c][ATTRIB_MAG] - - plr[pnum]._pBaseMag - + MaxStats[c][ATTRIB_DEX] - - plr[pnum]._pBaseDex - + MaxStats[c][ATTRIB_VIT] - - plr[pnum]._pBaseVit; + int c = plr[pnum]._pClass; + return MaxStats[c][ATTRIB_STR] + - plr[pnum]._pBaseStr + + MaxStats[c][ATTRIB_MAG] + - plr[pnum]._pBaseMag + + MaxStats[c][ATTRIB_DEX] + - plr[pnum]._pBaseDex + + MaxStats[c][ATTRIB_VIT] + - plr[pnum]._pBaseVit; } void __fastcall NextPlrLevel(int pnum) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("NextPlrLevel: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("NextPlrLevel: illegal player %d", pnum); + } - plr[pnum]._pLevel++; - char l = plr[pnum]._pLevel; + plr[pnum]._pLevel++; + char l = plr[pnum]._pLevel; - plr[pnum]._pMaxLvl++; + plr[pnum]._pMaxLvl++; - if (CalcStatDiff(pnum) < 5) { - plr[pnum]._pStatPts = CalcStatDiff(pnum); - } else { - plr[pnum]._pStatPts += 5; - } + if (CalcStatDiff(pnum) < 5) { + plr[pnum]._pStatPts = CalcStatDiff(pnum); + } else { + plr[pnum]._pStatPts += 5; + } - plr[pnum]._pNextExper = ExpLvlsTbl[l]; + plr[pnum]._pNextExper = ExpLvlsTbl[l]; - char c = plr[pnum]._pClass; + char c = plr[pnum]._pClass; - int hp = c == PC_SORCERER ? 64 : 128; - if (gbMaxPlayers == 1) { - hp++; - } - plr[pnum]._pMaxHP += hp; - plr[pnum]._pHitPoints = plr[pnum]._pMaxHP; - plr[pnum]._pMaxHPBase += hp; - plr[pnum]._pHPBase = plr[pnum]._pMaxHPBase; + int hp = c == PC_SORCERER ? 64 : 128; + if (gbMaxPlayers == 1) { + hp++; + } + plr[pnum]._pMaxHP += hp; + plr[pnum]._pHitPoints = plr[pnum]._pMaxHP; + plr[pnum]._pMaxHPBase += hp; + plr[pnum]._pHPBase = plr[pnum]._pMaxHPBase; - if (pnum == myplr) { - drawhpflag = TRUE; - } + if (pnum == myplr) { + drawhpflag = TRUE; + } - int mana = c != PC_WARRIOR ? 128 : 64; - if (gbMaxPlayers == 1) { - mana++; - } - plr[pnum]._pMaxMana += mana; - plr[pnum]._pMaxManaBase += mana; + int mana = c != PC_WARRIOR ? 128 : 64; + if (gbMaxPlayers == 1) { + mana++; + } + plr[pnum]._pMaxMana += mana; + plr[pnum]._pMaxManaBase += mana; - if (!(plr[pnum]._pIFlags & ISPL_NOMANA)) { - plr[pnum]._pMana = plr[pnum]._pMaxMana; - plr[pnum]._pManaBase = plr[pnum]._pMaxManaBase; - } + if (!(plr[pnum]._pIFlags & ISPL_NOMANA)) { + plr[pnum]._pMana = plr[pnum]._pMaxMana; + plr[pnum]._pManaBase = plr[pnum]._pMaxManaBase; + } - if (pnum == myplr) { - drawmanaflag = TRUE; - } + if (pnum == myplr) { + drawmanaflag = TRUE; + } } void __fastcall AddPlrExperience(int pnum, int lvl, int exp) { - if (pnum != myplr) { - return; - } + if (pnum != myplr) { + return; + } - if ((DWORD)myplr >= MAX_PLRS) { - TermMsg("AddPlrExperience: illegal player %d", myplr); - } + if ((DWORD)myplr >= MAX_PLRS) { + TermMsg("AddPlrExperience: illegal player %d", myplr); + } - if (plr[myplr]._pHitPoints <= 0) { - return; - } + if (plr[myplr]._pHitPoints <= 0) { + return; + } - // Adjust xp based on difference in level between player and monster - exp *= 1 + ((double)lvl - plr[pnum]._pLevel) / 10; - if (exp < 0) { - exp = 0; - } + // Adjust xp based on difference in level between player and monster + exp *= 1 + ((double)lvl - plr[pnum]._pLevel) / 10; + if (exp < 0) { + exp = 0; + } - // Prevent power leveling - if (gbMaxPlayers > 1) { - int powerLvlCap = plr[pnum]._pLevel < 0 ? 0 : plr[pnum]._pLevel; - if (powerLvlCap >= 50) { - powerLvlCap = 50; - } - // cap to 1/20 of current levels xp - if (exp >= ExpLvlsTbl[powerLvlCap] / 20) { - exp = ExpLvlsTbl[powerLvlCap] / 20; - } - // cap to 200 * current level - int expCap = 200 * powerLvlCap; - if (exp >= expCap) { - exp = expCap; - } - } + // Prevent power leveling + if (gbMaxPlayers > 1) { + int powerLvlCap = plr[pnum]._pLevel < 0 ? 0 : plr[pnum]._pLevel; + if (powerLvlCap >= 50) { + powerLvlCap = 50; + } + // cap to 1/20 of current levels xp + if (exp >= ExpLvlsTbl[powerLvlCap] / 20) { + exp = ExpLvlsTbl[powerLvlCap] / 20; + } + // cap to 200 * current level + int expCap = 200 * powerLvlCap; + if (exp >= expCap) { + exp = expCap; + } + } - plr[pnum]._pExperience += exp; - if ((DWORD)plr[pnum]._pExperience > MAXEXP) { - plr[pnum]._pExperience = MAXEXP; - } + plr[pnum]._pExperience += exp; + if ((DWORD)plr[pnum]._pExperience > MAXEXP) { + plr[pnum]._pExperience = MAXEXP; + } - if (plr[pnum]._pExperience >= ExpLvlsTbl[49]) { - plr[pnum]._pLevel = 50; - return; - } + if (plr[pnum]._pExperience >= ExpLvlsTbl[49]) { + plr[pnum]._pLevel = 50; + return; + } - // Increase player level if applicable - int newLvl = 0; - while (plr[pnum]._pExperience >= ExpLvlsTbl[newLvl]) { - newLvl++; - } - if (newLvl != plr[pnum]._pLevel) { - for (int i = newLvl - plr[pnum]._pLevel; i > 0; i--) { - NextPlrLevel(pnum); - } - } + // Increase player level if applicable + int newLvl = 0; + while (plr[pnum]._pExperience >= ExpLvlsTbl[newLvl]) { + newLvl++; + } + if (newLvl != plr[pnum]._pLevel) { + for (int i = newLvl - plr[pnum]._pLevel; i > 0; i--) { + NextPlrLevel(pnum); + } + } - NetSendCmdParam1(FALSE, CMD_PLRLEVEL, plr[myplr]._pLevel); + NetSendCmdParam1(FALSE, CMD_PLRLEVEL, plr[myplr]._pLevel); } void __fastcall AddPlrMonstExper(int lvl, int exp, char pmask) { - int totplrs = 0; - for (int i = 0; i < MAX_PLRS; i++) { - if ((1 << i) & pmask) { - totplrs++; - } - } + int totplrs = 0; + for (int i = 0; i < MAX_PLRS; i++) { + if ((1 << i) & pmask) { + totplrs++; + } + } - if (totplrs && (1 << myplr) & pmask) { - AddPlrExperience(myplr, lvl, exp / totplrs); - } + if (totplrs && (1 << myplr) & pmask) { + AddPlrExperience(myplr, lvl, exp / totplrs); + } } void __fastcall InitPlayer(int pnum, BOOL FirstTime) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("InitPlayer: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("InitPlayer: illegal player %d", pnum); + } - ClearPlrRVars(&plr[pnum]); + ClearPlrRVars(&plr[pnum]); - if (FirstTime) { - plr[pnum]._pRSpell = SPL_INVALID; - plr[pnum]._pSBkSpell = SPL_INVALID; - plr[pnum]._pSpell = SPL_INVALID; - plr[pnum]._pRSplType = RSPLTYPE_INVALID; - plr[pnum]._pSplType = RSPLTYPE_INVALID; - if ((plr[pnum]._pgfxnum & 0xF) == ANIM_ID_BOW) { - plr[pnum]._pwtype = TRUE; - } else { - plr[pnum]._pwtype = FALSE; - } - plr[pnum].pManaShield = 0; - } + if (FirstTime) { + plr[pnum]._pRSpell = SPL_INVALID; + plr[pnum]._pSBkSpell = SPL_INVALID; + plr[pnum]._pSpell = SPL_INVALID; + plr[pnum]._pRSplType = RSPLTYPE_INVALID; + plr[pnum]._pSplType = RSPLTYPE_INVALID; + if ((plr[pnum]._pgfxnum & 0xF) == ANIM_ID_BOW) { + plr[pnum]._pwtype = TRUE; + } else { + plr[pnum]._pwtype = FALSE; + } + plr[pnum].pManaShield = 0; + } - if (plr[pnum].plrlevel == currlevel || leveldebug) { + if (plr[pnum].plrlevel == currlevel || leveldebug) { - SetPlrAnims(pnum); + SetPlrAnims(pnum); - plr[pnum]._pxoff = 0; - plr[pnum]._pyoff = 0; - plr[pnum]._pxvel = 0; - plr[pnum]._pyvel = 0; + plr[pnum]._pxoff = 0; + plr[pnum]._pyoff = 0; + plr[pnum]._pxvel = 0; + plr[pnum]._pyvel = 0; - ClearPlrPVars(pnum); + ClearPlrPVars(pnum); - if (plr[pnum]._pHitPoints >> 6 > 0) { - plr[pnum]._pmode = PM_STAND; - NewPlrAnim(pnum, plr[pnum]._pNAnim[0], plr[pnum]._pNFrames, 3, plr[pnum]._pNWidth); - plr[pnum]._pAnimFrame = random(2, plr[pnum]._pNFrames - 1) + 1; - plr[pnum]._pAnimCnt = random(2, 3); - } else { - plr[pnum]._pmode = PM_DEATH; - NewPlrAnim(pnum, plr[pnum]._pDAnim[0], plr[pnum]._pDFrames, 1, plr[pnum]._pDWidth); - plr[pnum]._pAnimFrame = plr[pnum]._pAnimLen - 1; - plr[pnum]._pVar8 = 2 * plr[pnum]._pAnimLen; - } + if (plr[pnum]._pHitPoints >> 6 > 0) { + plr[pnum]._pmode = PM_STAND; + NewPlrAnim(pnum, plr[pnum]._pNAnim[0], plr[pnum]._pNFrames, 3, plr[pnum]._pNWidth); + plr[pnum]._pAnimFrame = random(2, plr[pnum]._pNFrames - 1) + 1; + plr[pnum]._pAnimCnt = random(2, 3); + } else { + plr[pnum]._pmode = PM_DEATH; + NewPlrAnim(pnum, plr[pnum]._pDAnim[0], plr[pnum]._pDFrames, 1, plr[pnum]._pDWidth); + plr[pnum]._pAnimFrame = plr[pnum]._pAnimLen - 1; + plr[pnum]._pVar8 = 2 * plr[pnum]._pAnimLen; + } - plr[pnum]._pdir = 0; - plr[pnum]._peflag = 0; + plr[pnum]._pdir = 0; + plr[pnum]._peflag = 0; - if (pnum == myplr) { - if (!FirstTime || currlevel != 0) { - plr[pnum].WorldX = ViewX; - plr[pnum].WorldY = ViewY; - } - plr[pnum]._ptargx = plr[pnum].WorldX; - plr[pnum]._ptargy = plr[pnum].WorldY; - } else { - plr[pnum]._ptargx = plr[pnum].WorldX; - plr[pnum]._ptargy = plr[pnum].WorldY; - DWORD i; - for (i = 0; i < 8 && !PosOkPlayer(pnum, plrxoff2[i] + plr[pnum].WorldX, plryoff2[i] + plr[pnum].WorldY); ++i) - ; - plr[pnum].WorldX += plrxoff2[i]; - plr[pnum].WorldY += plryoff2[i]; - } + if (pnum == myplr) { + if (!FirstTime || currlevel != 0) { + plr[pnum].WorldX = ViewX; + plr[pnum].WorldY = ViewY; + } + plr[pnum]._ptargx = plr[pnum].WorldX; + plr[pnum]._ptargy = plr[pnum].WorldY; + } else { + plr[pnum]._ptargx = plr[pnum].WorldX; + plr[pnum]._ptargy = plr[pnum].WorldY; + DWORD i; + for (i = 0; i < 8 && !PosOkPlayer(pnum, plrxoff2[i] + plr[pnum].WorldX, plryoff2[i] + plr[pnum].WorldY); ++i) + ; + plr[pnum].WorldX += plrxoff2[i]; + plr[pnum].WorldY += plryoff2[i]; + } - plr[pnum]._px = plr[pnum].WorldX; - plr[pnum]._py = plr[pnum].WorldY; - plr[pnum].walkpath[0] = WALK_NONE; - plr[pnum].destAction = ACTION_NONE; + plr[pnum]._px = plr[pnum].WorldX; + plr[pnum]._py = plr[pnum].WorldY; + plr[pnum].walkpath[0] = WALK_NONE; + plr[pnum].destAction = ACTION_NONE; - if (pnum == myplr) { - plr[pnum]._plid = AddLight(plr[pnum].WorldX, plr[pnum].WorldY, plr[pnum]._pLightRad); - } else { - plr[pnum]._plid = WALK_NONE; - } - plr[pnum]._pvid = AddVision(plr[pnum].WorldX, plr[pnum].WorldY, plr[pnum]._pLightRad, pnum == myplr); - } + if (pnum == myplr) { + plr[pnum]._plid = AddLight(plr[pnum].WorldX, plr[pnum].WorldY, plr[pnum]._pLightRad); + } else { + plr[pnum]._plid = WALK_NONE; + } + plr[pnum]._pvid = AddVision(plr[pnum].WorldX, plr[pnum].WorldY, plr[pnum]._pLightRad, pnum == myplr); + } - if (plr[pnum]._pClass == PC_WARRIOR) { - plr[pnum]._pAblSpells = 1 << (SPL_REPAIR - 1); - } else if (plr[pnum]._pClass == PC_ROGUE) { - plr[pnum]._pAblSpells = 1 << (SPL_DISARM - 1); - } else if (plr[pnum]._pClass == PC_SORCERER) { - plr[pnum]._pAblSpells = 1 << (SPL_RECHARGE - 1); - } + if (plr[pnum]._pClass == PC_WARRIOR) { + plr[pnum]._pAblSpells = 1 << (SPL_REPAIR - 1); + } else if (plr[pnum]._pClass == PC_ROGUE) { + plr[pnum]._pAblSpells = 1 << (SPL_DISARM - 1); + } else if (plr[pnum]._pClass == PC_SORCERER) { + plr[pnum]._pAblSpells = 1 << (SPL_RECHARGE - 1); + } #ifdef _DEBUG - if (debug_mode_dollar_sign && FirstTime) { - plr[pnum]._pMemSpells |= 1 << (SPL_TELEPORT - 1); - if (!plr[myplr]._pSplLvl[SPL_TELEPORT]) { - plr[myplr]._pSplLvl[SPL_TELEPORT] = 1; - } - } - if (debug_mode_key_inverted_v && FirstTime) { - plr[pnum]._pMemSpells = SPL_INVALID; - } + if (debug_mode_dollar_sign && FirstTime) { + plr[pnum]._pMemSpells |= 1 << (SPL_TELEPORT - 1); + if (!plr[myplr]._pSplLvl[SPL_TELEPORT]) { + plr[myplr]._pSplLvl[SPL_TELEPORT] = 1; + } + } + if (debug_mode_key_inverted_v && FirstTime) { + plr[pnum]._pMemSpells = SPL_INVALID; + } #endif - plr[pnum]._pNextExper = ExpLvlsTbl[plr[pnum]._pLevel]; - plr[pnum]._pInvincible = FALSE; + plr[pnum]._pNextExper = ExpLvlsTbl[plr[pnum]._pLevel]; + plr[pnum]._pInvincible = FALSE; - if (pnum == myplr) { - deathdelay = 0; - deathflag = FALSE; - ScrollInfo._sxoff = 0; - ScrollInfo._syoff = 0; - ScrollInfo._sdir = 0; - } + if (pnum == myplr) { + deathdelay = 0; + deathflag = FALSE; + ScrollInfo._sxoff = 0; + ScrollInfo._syoff = 0; + ScrollInfo._sdir = 0; + } } // 52572C: using guessed type int leveldebug; void __cdecl InitMultiView() { - if ((DWORD)myplr >= MAX_PLRS) { - TermMsg("InitPlayer: illegal player %d", myplr); - } + if ((DWORD)myplr >= MAX_PLRS) { + TermMsg("InitPlayer: illegal player %d", myplr); + } - ViewX = plr[myplr].WorldX; - ViewY = plr[myplr].WorldY; + ViewX = plr[myplr].WorldX; + ViewY = plr[myplr].WorldY; } void __fastcall InitPlayerLoc(int pnum, BOOL flag) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("InitPlayer: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("InitPlayer: illegal player %d", pnum); + } - int x = plr[pnum].WorldX - 1; - int y = plr[pnum].WorldY + 1; - int bitflags = 0; - USHORT *pieces = (USHORT *)dpiece_defs_map_1 + 16 * gendung_get_dpiece_num_from_coord(x, y); + int x = plr[pnum].WorldX - 1; + int y = plr[pnum].WorldY + 1; + int bitflags = 0; + USHORT *pieces = (USHORT *)dpiece_defs_map_1 + 16 * gendung_get_dpiece_num_from_coord(x, y); - int i; - for (i = 2; i < 10; i++) { - bitflags |= pieces[i]; - } + int i; + for (i = 2; i < 10; i++) { + bitflags |= pieces[i]; + } - if (bitflags | nSolidTable[dPiece[x][y]] | dArch[x][y]) { - plr[pnum]._peflag = 1; - } else { - plr[pnum]._peflag = 0; - } + if (bitflags | nSolidTable[dPiece[x][y]] | dArch[x][y]) { + plr[pnum]._peflag = 1; + } else { + plr[pnum]._peflag = 0; + } - if (flag != 1 || plr[pnum]._peflag != 1) { - return; - } + if (flag != 1 || plr[pnum]._peflag != 1) { + return; + } - x = plr[pnum].WorldX; - y = plr[pnum].WorldY + 2; - bitflags = 0; - pieces = (USHORT *)dpiece_defs_map_1 + 16 * gendung_get_dpiece_num_from_coord(x, y); + x = plr[pnum].WorldX; + y = plr[pnum].WorldY + 2; + bitflags = 0; + pieces = (USHORT *)dpiece_defs_map_1 + 16 * gendung_get_dpiece_num_from_coord(x, y); - for (i = 2; i < 10; i++) { - bitflags |= pieces[i]; - } + for (i = 2; i < 10; i++) { + bitflags |= pieces[i]; + } - if (bitflags | dArch[x][y]) { - return; - } + if (bitflags | dArch[x][y]) { + return; + } - x = plr[pnum].WorldX - 2; - y = plr[pnum].WorldY + 1; - bitflags = 0; - pieces = (USHORT *)dpiece_defs_map_1 + 16 * gendung_get_dpiece_num_from_coord(x, y); + x = plr[pnum].WorldX - 2; + y = plr[pnum].WorldY + 1; + bitflags = 0; + pieces = (USHORT *)dpiece_defs_map_1 + 16 * gendung_get_dpiece_num_from_coord(x, y); - for (i = 2; i < 10; i++) { - bitflags |= pieces[i]; - } + for (i = 2; i < 10; i++) { + bitflags |= pieces[i]; + } - if (bitflags | dArch[x][y]) { - plr[pnum]._peflag = 2; - } + if (bitflags | dArch[x][y]) { + plr[pnum]._peflag = 2; + } } BOOL __fastcall SolidLoc(int x, int y) { - if (x < 0 || y < 0 || x >= MAXDUNX || y >= MAXDUNY) { - return FALSE; - } + if (x < 0 || y < 0 || x >= MAXDUNX || y >= MAXDUNY) { + return FALSE; + } - return nSolidTable[dPiece[x][y]]; + return nSolidTable[dPiece[x][y]]; } BOOL __fastcall PlrDirOK(int pnum, int dir) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("PlrDirOK: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("PlrDirOK: illegal player %d", pnum); + } - int px = plr[pnum].WorldX + offset_x[dir]; - int py = plr[pnum].WorldY + offset_y[dir]; + int px = plr[pnum].WorldX + offset_x[dir]; + int py = plr[pnum].WorldY + offset_y[dir]; - if (px < 0 || !dPiece[px][py] || !PosOkPlayer(pnum, px, py)) { - return FALSE; - } + if (px < 0 || !dPiece[px][py] || !PosOkPlayer(pnum, px, py)) { + return FALSE; + } - BOOL isOk = TRUE; - if (dir == DIR_E) { - isOk = !SolidLoc(px, py + 1) && !(dFlags[px][py + 1] & DFLAG_PLAYER); - } + BOOL isOk = TRUE; + if (dir == DIR_E) { + isOk = !SolidLoc(px, py + 1) && !(dFlags[px][py + 1] & DFLAG_PLAYER); + } - if (isOk && dir == DIR_W) { - isOk = !SolidLoc(px + 1, py) && !(dFlags[px + 1][py] & DFLAG_PLAYER); - } + if (isOk && dir == DIR_W) { + isOk = !SolidLoc(px + 1, py) && !(dFlags[px + 1][py] & DFLAG_PLAYER); + } - return isOk; + return isOk; } void __fastcall PlrClrTrans(int x, int y) { - for (int i = y - 1; i <= y + 1; i++) { - for (int j = x - 1; j <= x + 1; j++) { - TransList[dung_map[j][i]] = 0; - } - } + for (int i = y - 1; i <= y + 1; i++) { + for (int j = x - 1; j <= x + 1; j++) { + TransList[dung_map[j][i]] = 0; + } + } } void __fastcall PlrDoTrans(int x, int y) { - if (leveltype != DTYPE_CATHEDRAL && leveltype != DTYPE_CATACOMBS) { - TransList[1] = 1; - } else { - for (int i = y - 1; i <= y + 1; i++) { - for (int j = x - 1; j <= x + 1; j++) { - if (!nSolidTable[dPiece[j][i]] && dung_map[j][i]) { - TransList[dung_map[j][i]] = 1; - } - } - } - } + if (leveltype != DTYPE_CATHEDRAL && leveltype != DTYPE_CATACOMBS) { + TransList[1] = 1; + } else { + for (int i = y - 1; i <= y + 1; i++) { + for (int j = x - 1; j <= x + 1; j++) { + if (!nSolidTable[dPiece[j][i]] && dung_map[j][i]) { + TransList[dung_map[j][i]] = 1; + } + } + } + } } void __fastcall SetPlayerOld(int pnum) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("SetPlayerOld: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("SetPlayerOld: illegal player %d", pnum); + } - plr[pnum]._poldx = plr[pnum].WorldX; - plr[pnum]._poldy = plr[pnum].WorldY; + plr[pnum]._poldx = plr[pnum].WorldX; + plr[pnum]._poldy = plr[pnum].WorldY; } void __fastcall FixPlayerLocation(int pnum, int dir) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("FixPlayerLocation: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("FixPlayerLocation: illegal player %d", pnum); + } - plr[pnum]._px = plr[pnum].WorldX; - plr[pnum]._py = plr[pnum].WorldY; - plr[pnum]._ptargx = plr[pnum].WorldX; - plr[pnum]._ptargy = plr[pnum].WorldY; - plr[pnum]._pxoff = 0; - plr[pnum]._pyoff = 0; - InitPlayerLoc(pnum, FALSE); - plr[pnum]._pdir = dir; - if (pnum == myplr) { - ScrollInfo._sxoff = 0; - ScrollInfo._syoff = 0; - ScrollInfo._sdir = 0; - ViewX = plr[pnum].WorldX; - ViewY = plr[pnum].WorldY; - } + plr[pnum]._px = plr[pnum].WorldX; + plr[pnum]._py = plr[pnum].WorldY; + plr[pnum]._ptargx = plr[pnum].WorldX; + plr[pnum]._ptargy = plr[pnum].WorldY; + plr[pnum]._pxoff = 0; + plr[pnum]._pyoff = 0; + InitPlayerLoc(pnum, FALSE); + plr[pnum]._pdir = dir; + if (pnum == myplr) { + ScrollInfo._sxoff = 0; + ScrollInfo._syoff = 0; + ScrollInfo._sdir = 0; + ViewX = plr[pnum].WorldX; + ViewY = plr[pnum].WorldY; + } } void __fastcall StartStand(int pnum, int dir) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("StartStand: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("StartStand: illegal player %d", pnum); + } - if (!plr[pnum]._pInvincible || plr[pnum]._pHitPoints || pnum != myplr) { - if (!(plr[pnum]._pGFXLoad & PFILE_STAND)) { - LoadPlrGFX(pnum, PFILE_STAND); - } + if (!plr[pnum]._pInvincible || plr[pnum]._pHitPoints || pnum != myplr) { + if (!(plr[pnum]._pGFXLoad & PFILE_STAND)) { + LoadPlrGFX(pnum, PFILE_STAND); + } - NewPlrAnim(pnum, plr[pnum]._pNAnim[dir], plr[pnum]._pNFrames, 3, plr[pnum]._pNWidth); - plr[pnum]._pmode = PM_STAND; - FixPlayerLocation(pnum, dir); - FixPlrWalkTags(pnum); - dPlayer[plr[pnum].WorldX][plr[pnum].WorldY] = pnum + 1; - SetPlayerOld(pnum); - } else { - SyncPlrKill(pnum, -1); - } + NewPlrAnim(pnum, plr[pnum]._pNAnim[dir], plr[pnum]._pNFrames, 3, plr[pnum]._pNWidth); + plr[pnum]._pmode = PM_STAND; + FixPlayerLocation(pnum, dir); + FixPlrWalkTags(pnum); + dPlayer[plr[pnum].WorldX][plr[pnum].WorldY] = pnum + 1; + SetPlayerOld(pnum); + } else { + SyncPlrKill(pnum, -1); + } } void __fastcall StartWalkStand(int pnum) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("StartWalkStand: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("StartWalkStand: illegal player %d", pnum); + } - plr[pnum]._pmode = 0; - plr[pnum]._px = plr[pnum].WorldX; - plr[pnum]._py = plr[pnum].WorldY; - plr[pnum]._pxoff = 0; - plr[pnum]._pyoff = 0; + plr[pnum]._pmode = 0; + plr[pnum]._px = plr[pnum].WorldX; + plr[pnum]._py = plr[pnum].WorldY; + plr[pnum]._pxoff = 0; + plr[pnum]._pyoff = 0; - InitPlayerLoc(pnum, 0); + InitPlayerLoc(pnum, 0); - if (pnum == myplr) { - ScrollInfo._sxoff = 0; - ScrollInfo._syoff = 0; - ScrollInfo._sdir = 0; - ViewX = plr[pnum].WorldX; - ViewY = plr[pnum].WorldY; - } + if (pnum == myplr) { + ScrollInfo._sxoff = 0; + ScrollInfo._syoff = 0; + ScrollInfo._sdir = 0; + ViewX = plr[pnum].WorldX; + ViewY = plr[pnum].WorldY; + } } void __fastcall PM_ChangeLightOff(int pnum) { - int x, y; - int xmul, ymul; - int lx, ly; - int offx, offy; - const LightListStruct *l; + int x, y; + int xmul, ymul; + int lx, ly; + int offx, offy; + const LightListStruct *l; - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("PM_ChangeLightOff: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("PM_ChangeLightOff: illegal player %d", pnum); + } - l = &LightList[plr[pnum]._plid]; - ymul = -1; - x = 2 * plr[pnum]._pyoff + plr[pnum]._pxoff; - y = 2 * plr[pnum]._pyoff - plr[pnum]._pxoff; - if (x < 0) { - xmul = -1; - x = -x; - } else { - xmul = 1; - } - if (y < 0) { - y = -y; - } else { - ymul = 1; - } + l = &LightList[plr[pnum]._plid]; + ymul = -1; + x = 2 * plr[pnum]._pyoff + plr[pnum]._pxoff; + y = 2 * plr[pnum]._pyoff - plr[pnum]._pxoff; + if (x < 0) { + xmul = -1; + x = -x; + } else { + xmul = 1; + } + if (y < 0) { + y = -y; + } else { + ymul = 1; + } - x = (x >> 3) * xmul; - y = (y >> 3) * ymul; - lx = x + (l->_lx << 3); - ly = y + (l->_ly << 3); - offx = l->_xoff + (l->_lx << 3); - offy = l->_yoff + (l->_ly << 3); + x = (x >> 3) * xmul; + y = (y >> 3) * ymul; + lx = x + (l->_lx << 3); + ly = y + (l->_ly << 3); + offx = l->_xoff + (l->_lx << 3); + offy = l->_yoff + (l->_ly << 3); - if (abs(lx - offx) < 3 && abs(ly - offy) < 3) - return; + if (abs(lx - offx) < 3 && abs(ly - offy) < 3) + return; - ChangeLightOff(plr[pnum]._plid, x, y); + ChangeLightOff(plr[pnum]._plid, x, y); } void __fastcall PM_ChangeOffset(int pnum) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("PM_ChangeOffset: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("PM_ChangeOffset: illegal player %d", pnum); + } - plr[pnum]._pVar8++; - int px = plr[pnum]._pVar6 >> 8; - int py = plr[pnum]._pVar7 >> 8; + plr[pnum]._pVar8++; + int px = plr[pnum]._pVar6 >> 8; + int py = plr[pnum]._pVar7 >> 8; - plr[pnum]._pVar6 += plr[pnum]._pxvel; - plr[pnum]._pVar7 += plr[pnum]._pyvel; - plr[pnum]._pxoff = plr[pnum]._pVar6 >> 8; - plr[pnum]._pyoff = plr[pnum]._pVar7 >> 8; + plr[pnum]._pVar6 += plr[pnum]._pxvel; + plr[pnum]._pVar7 += plr[pnum]._pyvel; + plr[pnum]._pxoff = plr[pnum]._pVar6 >> 8; + plr[pnum]._pyoff = plr[pnum]._pVar7 >> 8; - if (pnum == myplr && ScrollInfo._sdir) { - ScrollInfo._sxoff += px - plr[pnum]._pxoff; - ScrollInfo._syoff += py - plr[pnum]._pyoff; - } + if (pnum == myplr && ScrollInfo._sdir) { + ScrollInfo._sxoff += px - plr[pnum]._pxoff; + ScrollInfo._syoff += py - plr[pnum]._pyoff; + } - PM_ChangeLightOff(pnum); + PM_ChangeLightOff(pnum); } void __fastcall StartWalk(int pnum, int xvel, int yvel, int xadd, int yadd, int EndDir, int sdir) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("StartWalk: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("StartWalk: illegal player %d", pnum); + } - if (plr[pnum]._pInvincible && !plr[pnum]._pHitPoints && pnum == myplr) { - SyncPlrKill(pnum, -1); - return; - } + if (plr[pnum]._pInvincible && !plr[pnum]._pHitPoints && pnum == myplr) { + SyncPlrKill(pnum, -1); + return; + } - SetPlayerOld(pnum); + SetPlayerOld(pnum); - int px = xadd + plr[pnum].WorldX; - int py = yadd + plr[pnum].WorldY; + int px = xadd + plr[pnum].WorldX; + int py = yadd + plr[pnum].WorldY; - if (!PlrDirOK(pnum, EndDir)) { - return; - } + if (!PlrDirOK(pnum, EndDir)) { + return; + } - plr[pnum]._px = px; - plr[pnum]._py = py; + plr[pnum]._px = px; + plr[pnum]._py = py; - if (pnum == myplr) { - ScrollInfo._sdx = plr[pnum].WorldX - ViewX; - ScrollInfo._sdy = plr[pnum].WorldY - ViewY; - } + if (pnum == myplr) { + ScrollInfo._sdx = plr[pnum].WorldX - ViewX; + ScrollInfo._sdy = plr[pnum].WorldY - ViewY; + } - dPlayer[px][py] = -(pnum + 1); - plr[pnum]._pmode = PM_WALK; - plr[pnum]._pxvel = xvel; - plr[pnum]._pyvel = yvel; - plr[pnum]._pxoff = 0; - plr[pnum]._pyoff = 0; - plr[pnum]._pVar1 = xadd; - plr[pnum]._pVar2 = yadd; - plr[pnum]._pVar3 = EndDir; + dPlayer[px][py] = -(pnum + 1); + plr[pnum]._pmode = PM_WALK; + plr[pnum]._pxvel = xvel; + plr[pnum]._pyvel = yvel; + plr[pnum]._pxoff = 0; + plr[pnum]._pyoff = 0; + plr[pnum]._pVar1 = xadd; + plr[pnum]._pVar2 = yadd; + plr[pnum]._pVar3 = EndDir; - if (!(plr[pnum]._pGFXLoad & PFILE_WALK)) { - LoadPlrGFX(pnum, PFILE_WALK); - } + if (!(plr[pnum]._pGFXLoad & PFILE_WALK)) { + LoadPlrGFX(pnum, PFILE_WALK); + } - NewPlrAnim(pnum, plr[pnum]._pWAnim[EndDir], plr[pnum]._pWFrames, 0, plr[pnum]._pWWidth); + NewPlrAnim(pnum, plr[pnum]._pWAnim[EndDir], plr[pnum]._pWFrames, 0, plr[pnum]._pWWidth); - plr[pnum]._pdir = EndDir; - plr[pnum]._pVar6 = 0; - plr[pnum]._pVar7 = 0; - plr[pnum]._pVar8 = 0; + plr[pnum]._pdir = EndDir; + plr[pnum]._pVar6 = 0; + plr[pnum]._pVar7 = 0; + plr[pnum]._pVar8 = 0; - InitPlayerLoc(pnum, FALSE); + InitPlayerLoc(pnum, FALSE); - if (pnum != myplr) { - return; - } + if (pnum != myplr) { + return; + } - if (zoomflag) { - if (abs(ScrollInfo._sdx) >= 3 || abs(ScrollInfo._sdy) >= 3) { - ScrollInfo._sdir = SDIR_NONE; - } else { - ScrollInfo._sdir = sdir; - } - } else if (abs(ScrollInfo._sdx) >= 2 || abs(ScrollInfo._sdy) >= 2) { - ScrollInfo._sdir = SDIR_NONE; - } else { - ScrollInfo._sdir = sdir; - } + if (zoomflag) { + if (abs(ScrollInfo._sdx) >= 3 || abs(ScrollInfo._sdy) >= 3) { + ScrollInfo._sdir = SDIR_NONE; + } else { + ScrollInfo._sdir = sdir; + } + } else if (abs(ScrollInfo._sdx) >= 2 || abs(ScrollInfo._sdy) >= 2) { + ScrollInfo._sdir = SDIR_NONE; + } else { + ScrollInfo._sdir = sdir; + } } // 52569C: using guessed type int zoomflag; void __fastcall StartWalk2(int pnum, int xvel, int yvel, int xoff, int yoff, int xadd, int yadd, int EndDir, int sdir) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("StartWalk2: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("StartWalk2: illegal player %d", pnum); + } - if (plr[pnum]._pInvincible && !plr[pnum]._pHitPoints && pnum == myplr) { - SyncPlrKill(pnum, -1); - return; - } + if (plr[pnum]._pInvincible && !plr[pnum]._pHitPoints && pnum == myplr) { + SyncPlrKill(pnum, -1); + return; + } - SetPlayerOld(pnum); - int px = xadd + plr[pnum].WorldX; - int py = yadd + plr[pnum].WorldY; + SetPlayerOld(pnum); + int px = xadd + plr[pnum].WorldX; + int py = yadd + plr[pnum].WorldY; - if (!PlrDirOK(pnum, EndDir)) { - return; - } + if (!PlrDirOK(pnum, EndDir)) { + return; + } - plr[pnum]._px = px; - plr[pnum]._py = py; + plr[pnum]._px = px; + plr[pnum]._py = py; - if (pnum == myplr) { - ScrollInfo._sdx = plr[pnum].WorldX - ViewX; - ScrollInfo._sdy = plr[pnum].WorldY - ViewY; - } + if (pnum == myplr) { + ScrollInfo._sdx = plr[pnum].WorldX - ViewX; + ScrollInfo._sdy = plr[pnum].WorldY - ViewY; + } - dPlayer[plr[pnum].WorldX][plr[pnum].WorldY] = -1 - pnum; - plr[pnum]._pVar1 = plr[pnum].WorldX; - plr[pnum]._pVar2 = plr[pnum].WorldY; - plr[pnum].WorldX = px; - plr[pnum].WorldY = py; - dPlayer[plr[pnum].WorldX][plr[pnum].WorldY] = pnum + 1; - plr[pnum]._pxoff = xoff; - plr[pnum]._pyoff = yoff; + dPlayer[plr[pnum].WorldX][plr[pnum].WorldY] = -1 - pnum; + plr[pnum]._pVar1 = plr[pnum].WorldX; + plr[pnum]._pVar2 = plr[pnum].WorldY; + plr[pnum].WorldX = px; + plr[pnum].WorldY = py; + dPlayer[plr[pnum].WorldX][plr[pnum].WorldY] = pnum + 1; + plr[pnum]._pxoff = xoff; + plr[pnum]._pyoff = yoff; - ChangeLightXY(plr[pnum]._plid, plr[pnum].WorldX, plr[pnum].WorldY); - PM_ChangeLightOff(pnum); + ChangeLightXY(plr[pnum]._plid, plr[pnum].WorldX, plr[pnum].WorldY); + PM_ChangeLightOff(pnum); - plr[pnum]._pmode = PM_WALK2; - plr[pnum]._pxvel = xvel; - plr[pnum]._pyvel = yvel; - plr[pnum]._pVar6 = xoff << 8; - plr[pnum]._pVar7 = yoff << 8; - plr[pnum]._pVar3 = EndDir; + plr[pnum]._pmode = PM_WALK2; + plr[pnum]._pxvel = xvel; + plr[pnum]._pyvel = yvel; + plr[pnum]._pVar6 = xoff << 8; + plr[pnum]._pVar7 = yoff << 8; + plr[pnum]._pVar3 = EndDir; - if (!(plr[pnum]._pGFXLoad & PFILE_WALK)) { - LoadPlrGFX(pnum, PFILE_WALK); - } - NewPlrAnim(pnum, plr[pnum]._pWAnim[EndDir], plr[pnum]._pWFrames, 0, plr[pnum]._pWWidth); + if (!(plr[pnum]._pGFXLoad & PFILE_WALK)) { + LoadPlrGFX(pnum, PFILE_WALK); + } + NewPlrAnim(pnum, plr[pnum]._pWAnim[EndDir], plr[pnum]._pWFrames, 0, plr[pnum]._pWWidth); - plr[pnum]._pdir = EndDir; - plr[pnum]._pVar8 = 0; + plr[pnum]._pdir = EndDir; + plr[pnum]._pVar8 = 0; - if (EndDir == DIR_SE) { - InitPlayerLoc(pnum, TRUE); - } else { - InitPlayerLoc(pnum, FALSE); - } + if (EndDir == DIR_SE) { + InitPlayerLoc(pnum, TRUE); + } else { + InitPlayerLoc(pnum, FALSE); + } - if (pnum != myplr) { - return; - } + if (pnum != myplr) { + return; + } - if (zoomflag) { - if (abs(ScrollInfo._sdx) >= 3 || abs(ScrollInfo._sdy) >= 3) { - ScrollInfo._sdir = SDIR_NONE; - } else { - ScrollInfo._sdir = sdir; - } - } else if (abs(ScrollInfo._sdx) >= 2 || abs(ScrollInfo._sdy) >= 2) { - ScrollInfo._sdir = SDIR_NONE; - } else { - ScrollInfo._sdir = sdir; - } + if (zoomflag) { + if (abs(ScrollInfo._sdx) >= 3 || abs(ScrollInfo._sdy) >= 3) { + ScrollInfo._sdir = SDIR_NONE; + } else { + ScrollInfo._sdir = sdir; + } + } else if (abs(ScrollInfo._sdx) >= 2 || abs(ScrollInfo._sdy) >= 2) { + ScrollInfo._sdir = SDIR_NONE; + } else { + ScrollInfo._sdir = sdir; + } } // 52569C: using guessed type int zoomflag; void __fastcall StartWalk3(int pnum, int xvel, int yvel, int xoff, int yoff, int xadd, int yadd, int mapx, int mapy, int EndDir, int sdir) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("StartWalk3: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("StartWalk3: illegal player %d", pnum); + } - if (plr[pnum]._pInvincible && !plr[pnum]._pHitPoints && pnum == myplr) { - SyncPlrKill(pnum, -1); - return; - } + if (plr[pnum]._pInvincible && !plr[pnum]._pHitPoints && pnum == myplr) { + SyncPlrKill(pnum, -1); + return; + } - SetPlayerOld(pnum); - int px = xadd + plr[pnum].WorldX; - int py = yadd + plr[pnum].WorldY; - int x = mapx + plr[pnum].WorldX; - int y = mapy + plr[pnum].WorldY; + SetPlayerOld(pnum); + int px = xadd + plr[pnum].WorldX; + int py = yadd + plr[pnum].WorldY; + int x = mapx + plr[pnum].WorldX; + int y = mapy + plr[pnum].WorldY; - if (!PlrDirOK(pnum, EndDir)) { - return; - } + if (!PlrDirOK(pnum, EndDir)) { + return; + } - plr[pnum]._px = px; - plr[pnum]._py = py; + plr[pnum]._px = px; + plr[pnum]._py = py; - if (pnum == myplr) { - ScrollInfo._sdx = plr[pnum].WorldX - ViewX; - ScrollInfo._sdy = plr[pnum].WorldY - ViewY; - } + if (pnum == myplr) { + ScrollInfo._sdx = plr[pnum].WorldX - ViewX; + ScrollInfo._sdy = plr[pnum].WorldY - ViewY; + } - dPlayer[plr[pnum].WorldX][plr[pnum].WorldY] = -1 - pnum; - dPlayer[px][py] = -1 - pnum; - plr[pnum]._pVar4 = x; - plr[pnum]._pVar5 = y; - dFlags[x][y] |= DFLAG_PLAYER; - plr[pnum]._pxoff = xoff; - plr[pnum]._pyoff = yoff; + dPlayer[plr[pnum].WorldX][plr[pnum].WorldY] = -1 - pnum; + dPlayer[px][py] = -1 - pnum; + plr[pnum]._pVar4 = x; + plr[pnum]._pVar5 = y; + dFlags[x][y] |= DFLAG_PLAYER; + plr[pnum]._pxoff = xoff; + plr[pnum]._pyoff = yoff; - if (leveltype) { - ChangeLightXY(plr[pnum]._plid, x, y); - PM_ChangeLightOff(pnum); - } + if (leveltype) { + ChangeLightXY(plr[pnum]._plid, x, y); + PM_ChangeLightOff(pnum); + } - plr[pnum]._pmode = PM_WALK3; - plr[pnum]._pxvel = xvel; - plr[pnum]._pyvel = yvel; - plr[pnum]._pVar1 = px; - plr[pnum]._pVar2 = py; - plr[pnum]._pVar6 = xoff << 8; - plr[pnum]._pVar7 = yoff << 8; - plr[pnum]._pVar3 = EndDir; + plr[pnum]._pmode = PM_WALK3; + plr[pnum]._pxvel = xvel; + plr[pnum]._pyvel = yvel; + plr[pnum]._pVar1 = px; + plr[pnum]._pVar2 = py; + plr[pnum]._pVar6 = xoff << 8; + plr[pnum]._pVar7 = yoff << 8; + plr[pnum]._pVar3 = EndDir; - if (!(plr[pnum]._pGFXLoad & PFILE_WALK)) { - LoadPlrGFX(pnum, PFILE_WALK); - } - NewPlrAnim(pnum, plr[pnum]._pWAnim[EndDir], plr[pnum]._pWFrames, 0, plr[pnum]._pWWidth); + if (!(plr[pnum]._pGFXLoad & PFILE_WALK)) { + LoadPlrGFX(pnum, PFILE_WALK); + } + NewPlrAnim(pnum, plr[pnum]._pWAnim[EndDir], plr[pnum]._pWFrames, 0, plr[pnum]._pWWidth); - plr[pnum]._pdir = EndDir; - plr[pnum]._pVar8 = 0; + plr[pnum]._pdir = EndDir; + plr[pnum]._pVar8 = 0; - InitPlayerLoc(pnum, FALSE); + InitPlayerLoc(pnum, FALSE); - if (pnum != myplr) { - return; - } + if (pnum != myplr) { + return; + } - if (zoomflag) { - if (abs(ScrollInfo._sdx) >= 3 || abs(ScrollInfo._sdy) >= 3) { - ScrollInfo._sdir = SDIR_NONE; - } else { - ScrollInfo._sdir = sdir; - } - } else if (abs(ScrollInfo._sdx) >= 2 || abs(ScrollInfo._sdy) >= 2) { - ScrollInfo._sdir = SDIR_NONE; - } else { - ScrollInfo._sdir = sdir; - } + if (zoomflag) { + if (abs(ScrollInfo._sdx) >= 3 || abs(ScrollInfo._sdy) >= 3) { + ScrollInfo._sdir = SDIR_NONE; + } else { + ScrollInfo._sdir = sdir; + } + } else if (abs(ScrollInfo._sdx) >= 2 || abs(ScrollInfo._sdy) >= 2) { + ScrollInfo._sdir = SDIR_NONE; + } else { + ScrollInfo._sdir = sdir; + } } // 52569C: using guessed type int zoomflag; void __fastcall StartAttack(int pnum, int d) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("StartAttack: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("StartAttack: illegal player %d", pnum); + } - if (plr[pnum]._pInvincible && !plr[pnum]._pHitPoints && pnum == myplr) { - SyncPlrKill(pnum, -1); - return; - } + if (plr[pnum]._pInvincible && !plr[pnum]._pHitPoints && pnum == myplr) { + SyncPlrKill(pnum, -1); + return; + } - if (!(plr[pnum]._pGFXLoad & PFILE_ATTACK)) { - LoadPlrGFX(pnum, PFILE_ATTACK); - } + if (!(plr[pnum]._pGFXLoad & PFILE_ATTACK)) { + LoadPlrGFX(pnum, PFILE_ATTACK); + } - NewPlrAnim(pnum, plr[pnum]._pAAnim[d], plr[pnum]._pAFrames, 0, plr[pnum]._pAWidth); - plr[pnum]._pmode = PM_ATTACK; - FixPlayerLocation(pnum, d); - SetPlayerOld(pnum); + NewPlrAnim(pnum, plr[pnum]._pAAnim[d], plr[pnum]._pAFrames, 0, plr[pnum]._pAWidth); + plr[pnum]._pmode = PM_ATTACK; + FixPlayerLocation(pnum, d); + SetPlayerOld(pnum); } void __fastcall StartRangeAttack(int pnum, int d, int cx, int cy) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("StartRangeAttack: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("StartRangeAttack: illegal player %d", pnum); + } - if (plr[pnum]._pInvincible && !plr[pnum]._pHitPoints && pnum == myplr) { - SyncPlrKill(pnum, -1); - return; - } + if (plr[pnum]._pInvincible && !plr[pnum]._pHitPoints && pnum == myplr) { + SyncPlrKill(pnum, -1); + return; + } - if (!(plr[pnum]._pGFXLoad & PFILE_ATTACK)) { - LoadPlrGFX(pnum, PFILE_ATTACK); - } - NewPlrAnim(pnum, plr[pnum]._pAAnim[d], plr[pnum]._pAFrames, 0, plr[pnum]._pAWidth); + if (!(plr[pnum]._pGFXLoad & PFILE_ATTACK)) { + LoadPlrGFX(pnum, PFILE_ATTACK); + } + NewPlrAnim(pnum, plr[pnum]._pAAnim[d], plr[pnum]._pAFrames, 0, plr[pnum]._pAWidth); - plr[pnum]._pmode = PM_RATTACK; - FixPlayerLocation(pnum, d); - SetPlayerOld(pnum); - plr[pnum]._pVar1 = cx; - plr[pnum]._pVar2 = cy; + plr[pnum]._pmode = PM_RATTACK; + FixPlayerLocation(pnum, d); + SetPlayerOld(pnum); + plr[pnum]._pVar1 = cx; + plr[pnum]._pVar2 = cy; } void __fastcall StartPlrBlock(int pnum, int dir) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("StartPlrBlock: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("StartPlrBlock: illegal player %d", pnum); + } - if (plr[pnum]._pInvincible && !plr[pnum]._pHitPoints && pnum == myplr) { - SyncPlrKill(pnum, -1); - return; - } + if (plr[pnum]._pInvincible && !plr[pnum]._pHitPoints && pnum == myplr) { + SyncPlrKill(pnum, -1); + return; + } - PlaySfxLoc(IS_ISWORD, plr[pnum].WorldX, plr[pnum].WorldY); + PlaySfxLoc(IS_ISWORD, plr[pnum].WorldX, plr[pnum].WorldY); - if (!(plr[pnum]._pGFXLoad & PFILE_BLOCK)) { - LoadPlrGFX(pnum, PFILE_BLOCK); - } - NewPlrAnim(pnum, plr[pnum]._pBAnim[dir], plr[pnum]._pBFrames, 2, plr[pnum]._pBWidth); + if (!(plr[pnum]._pGFXLoad & PFILE_BLOCK)) { + LoadPlrGFX(pnum, PFILE_BLOCK); + } + NewPlrAnim(pnum, plr[pnum]._pBAnim[dir], plr[pnum]._pBFrames, 2, plr[pnum]._pBWidth); - plr[pnum]._pmode = PM_BLOCK; - FixPlayerLocation(pnum, dir); - SetPlayerOld(pnum); + plr[pnum]._pmode = PM_BLOCK; + FixPlayerLocation(pnum, dir); + SetPlayerOld(pnum); } void __fastcall StartSpell(int pnum, int d, int cx, int cy) { - if ((DWORD)pnum >= MAX_PLRS) - TermMsg("StartSpell: illegal player %d", pnum); + if ((DWORD)pnum >= MAX_PLRS) + TermMsg("StartSpell: illegal player %d", pnum); - if (plr[pnum]._pInvincible && !plr[pnum]._pHitPoints && pnum == myplr) { - SyncPlrKill(pnum, -1); - return; - } + if (plr[pnum]._pInvincible && !plr[pnum]._pHitPoints && pnum == myplr) { + SyncPlrKill(pnum, -1); + return; + } - if (leveltype != DTYPE_TOWN) { - switch (spelldata[plr[pnum]._pSpell].sType) { - case STYPE_FIRE: - if (!(plr[pnum]._pGFXLoad & PFILE_FIRE)) { - LoadPlrGFX(pnum, PFILE_FIRE); - } - NewPlrAnim(pnum, plr[pnum]._pFAnim[d], plr[pnum]._pSFrames, 0, plr[pnum]._pSWidth); - break; - case STYPE_LIGHTNING: - if (!(plr[pnum]._pGFXLoad & PFILE_LIGHTNING)) { - LoadPlrGFX(pnum, PFILE_LIGHTNING); - } - NewPlrAnim(pnum, plr[pnum]._pLAnim[d], plr[pnum]._pSFrames, 0, plr[pnum]._pSWidth); - break; - case STYPE_MAGIC: - if (!(plr[pnum]._pGFXLoad & PFILE_MAGIC)) { - LoadPlrGFX(pnum, PFILE_MAGIC); - } - NewPlrAnim(pnum, plr[pnum]._pTAnim[d], plr[pnum]._pSFrames, 0, plr[pnum]._pSWidth); - break; - } - } + if (leveltype != DTYPE_TOWN) { + switch (spelldata[plr[pnum]._pSpell].sType) { + case STYPE_FIRE: + if (!(plr[pnum]._pGFXLoad & PFILE_FIRE)) { + LoadPlrGFX(pnum, PFILE_FIRE); + } + NewPlrAnim(pnum, plr[pnum]._pFAnim[d], plr[pnum]._pSFrames, 0, plr[pnum]._pSWidth); + break; + case STYPE_LIGHTNING: + if (!(plr[pnum]._pGFXLoad & PFILE_LIGHTNING)) { + LoadPlrGFX(pnum, PFILE_LIGHTNING); + } + NewPlrAnim(pnum, plr[pnum]._pLAnim[d], plr[pnum]._pSFrames, 0, plr[pnum]._pSWidth); + break; + case STYPE_MAGIC: + if (!(plr[pnum]._pGFXLoad & PFILE_MAGIC)) { + LoadPlrGFX(pnum, PFILE_MAGIC); + } + NewPlrAnim(pnum, plr[pnum]._pTAnim[d], plr[pnum]._pSFrames, 0, plr[pnum]._pSWidth); + break; + } + } - PlaySfxLoc(spelldata[plr[pnum]._pSpell].sSFX, plr[pnum].WorldX, plr[pnum].WorldY); + PlaySfxLoc(spelldata[plr[pnum]._pSpell].sSFX, plr[pnum].WorldX, plr[pnum].WorldY); - plr[pnum]._pmode = PM_SPELL; + plr[pnum]._pmode = PM_SPELL; - FixPlayerLocation(pnum, d); - SetPlayerOld(pnum); + FixPlayerLocation(pnum, d); + SetPlayerOld(pnum); - plr[pnum]._pVar1 = cx; - plr[pnum]._pVar2 = cy; - plr[pnum]._pVar4 = GetSpellLevel(pnum, plr[pnum]._pSpell); - plr[pnum]._pVar8 = 1; + plr[pnum]._pVar1 = cx; + plr[pnum]._pVar2 = cy; + plr[pnum]._pVar4 = GetSpellLevel(pnum, plr[pnum]._pSpell); + plr[pnum]._pVar8 = 1; } void __fastcall FixPlrWalkTags(int pnum) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("FixPlrWalkTags: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("FixPlrWalkTags: illegal player %d", pnum); + } - int pp = pnum + 1; - int pn = -(pnum + 1); - int dx = plr[pnum]._poldx; - int dy = plr[pnum]._poldy; - for (int y = dy - 1; y <= dy + 1; y++) { - for (int x = dx - 1; x <= dx + 1; x++) { - if (x >= 0 && x < MAXDUNX && y >= 0 && y < MAXDUNY && (dPlayer[x][y] == pp || dPlayer[x][y] == pn)) { - dPlayer[x][y] = 0; - } - } - } + int pp = pnum + 1; + int pn = -(pnum + 1); + int dx = plr[pnum]._poldx; + int dy = plr[pnum]._poldy; + for (int y = dy - 1; y <= dy + 1; y++) { + for (int x = dx - 1; x <= dx + 1; x++) { + if (x >= 0 && x < MAXDUNX && y >= 0 && y < MAXDUNY && (dPlayer[x][y] == pp || dPlayer[x][y] == pn)) { + dPlayer[x][y] = 0; + } + } + } - if (dx >= 0 && dx < MAXDUNX - 1 && dy >= 0 && dy < MAXDUNY - 1) { - dFlags[dx + 1][dy] &= ~DFLAG_PLAYER; - dFlags[dx][dy + 1] &= ~DFLAG_PLAYER; - } + if (dx >= 0 && dx < MAXDUNX - 1 && dy >= 0 && dy < MAXDUNY - 1) { + dFlags[dx + 1][dy] &= ~DFLAG_PLAYER; + dFlags[dx][dy + 1] &= ~DFLAG_PLAYER; + } } void __fastcall RemovePlrFromMap(int pnum) { - int x, y; - int pp = pnum + 1; - int pn = -(pnum + 1); + int x, y; + int pp = pnum + 1; + int pn = -(pnum + 1); - for (y = 1; y < MAXDUNY; y++) - for (x = 1; x < MAXDUNX; x++) - if (dPlayer[x][y - 1] == pn || dPlayer[x - 1][y] == pn) - if (dFlags[x][y] & DFLAG_PLAYER) - dFlags[x][y] &= ~DFLAG_PLAYER; + for (y = 1; y < MAXDUNY; y++) + for (x = 1; x < MAXDUNX; x++) + if (dPlayer[x][y - 1] == pn || dPlayer[x - 1][y] == pn) + if (dFlags[x][y] & DFLAG_PLAYER) + dFlags[x][y] &= ~DFLAG_PLAYER; - for (y = 0; y < MAXDUNY; y++) - for (x = 0; x < MAXDUNX; x++) - if (dPlayer[x][y] == pp || dPlayer[x][y] == pn) - dPlayer[x][y] = 0; + for (y = 0; y < MAXDUNY; y++) + for (x = 0; x < MAXDUNX; x++) + if (dPlayer[x][y] == pp || dPlayer[x][y] == pn) + dPlayer[x][y] = 0; } void __fastcall StartPlrHit(int pnum, int dam, BOOL forcehit) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("StartPlrHit: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("StartPlrHit: illegal player %d", pnum); + } - if (plr[pnum]._pInvincible && !plr[pnum]._pHitPoints && pnum == myplr) { - SyncPlrKill(pnum, -1); - return; - } + if (plr[pnum]._pInvincible && !plr[pnum]._pHitPoints && pnum == myplr) { + SyncPlrKill(pnum, -1); + return; + } - if (plr[pnum]._pClass == PC_WARRIOR) { - PlaySfxLoc(PS_WARR69, plr[pnum].WorldX, plr[pnum].WorldY); - } else if (plr[pnum]._pClass == PC_ROGUE) { - PlaySfxLoc(PS_ROGUE69, plr[pnum].WorldX, plr[pnum].WorldY); - } else if (plr[pnum]._pClass == PC_SORCERER) { - PlaySfxLoc(PS_MAGE69, plr[pnum].WorldX, plr[pnum].WorldY); - } + if (plr[pnum]._pClass == PC_WARRIOR) { + PlaySfxLoc(PS_WARR69, plr[pnum].WorldX, plr[pnum].WorldY); + } else if (plr[pnum]._pClass == PC_ROGUE) { + PlaySfxLoc(PS_ROGUE69, plr[pnum].WorldX, plr[pnum].WorldY); + } else if (plr[pnum]._pClass == PC_SORCERER) { + PlaySfxLoc(PS_MAGE69, plr[pnum].WorldX, plr[pnum].WorldY); + } - drawhpflag = TRUE; - if (dam >> 6 >= plr[pnum]._pLevel || forcehit) { - int dir = plr[pnum]._pdir; + drawhpflag = TRUE; + if (dam >> 6 >= plr[pnum]._pLevel || forcehit) { + int dir = plr[pnum]._pdir; - if (!(plr[pnum]._pGFXLoad & PFILE_HIT)) { - LoadPlrGFX(pnum, PFILE_HIT); - } - NewPlrAnim(pnum, plr[pnum]._pHAnim[dir], plr[pnum]._pHFrames, 0, plr[pnum]._pHWidth); + if (!(plr[pnum]._pGFXLoad & PFILE_HIT)) { + LoadPlrGFX(pnum, PFILE_HIT); + } + NewPlrAnim(pnum, plr[pnum]._pHAnim[dir], plr[pnum]._pHFrames, 0, plr[pnum]._pHWidth); - plr[pnum]._pmode = PM_GOTHIT; - FixPlayerLocation(pnum, dir); - plr[pnum]._pVar8 = 1; - FixPlrWalkTags(pnum); - dPlayer[plr[pnum].WorldX][plr[pnum].WorldY] = pnum + 1; - SetPlayerOld(pnum); - } + plr[pnum]._pmode = PM_GOTHIT; + FixPlayerLocation(pnum, dir); + plr[pnum]._pVar8 = 1; + FixPlrWalkTags(pnum); + dPlayer[plr[pnum].WorldX][plr[pnum].WorldY] = pnum + 1; + SetPlayerOld(pnum); + } } void __fastcall RespawnDeadItem(ItemStruct *itm, int x, int y) { - if (numitems >= MAXITEMS) { - return; - } + if (numitems >= MAXITEMS) { + return; + } - if (FindGetItem(itm->IDidx, itm->_iCreateInfo, itm->_iSeed) >= 0) { - DrawInvMsg("A duplicate item has been detected. Destroying duplicate..."); - SyncGetItem(x, y, itm->IDidx, itm->_iCreateInfo, itm->_iSeed); - } + if (FindGetItem(itm->IDidx, itm->_iCreateInfo, itm->_iSeed) >= 0) { + DrawInvMsg("A duplicate item has been detected. Destroying duplicate..."); + SyncGetItem(x, y, itm->IDidx, itm->_iCreateInfo, itm->_iSeed); + } - int i = itemavail[0]; - dItem[x][y] = i + 1; - itemavail[0] = itemavail[MAXITEMS - numitems - 1]; - itemactive[numitems] = i; - item[i] = *itm; - item[i]._ix = x; - item[i]._iy = y; - RespawnItem(i, TRUE); - numitems++; - itm->_itype = ITYPE_NONE; + int i = itemavail[0]; + dItem[x][y] = i + 1; + itemavail[0] = itemavail[MAXITEMS - numitems - 1]; + itemactive[numitems] = i; + item[i] = *itm; + item[i]._ix = x; + item[i]._iy = y; + RespawnItem(i, TRUE); + numitems++; + itm->_itype = ITYPE_NONE; } void __fastcall StartPlayerKill(int pnum, int earflag) { - if (plr[pnum]._pHitPoints <= 0 && plr[pnum]._pmode == PM_DEATH) { - return; - } + if (plr[pnum]._pHitPoints <= 0 && plr[pnum]._pmode == PM_DEATH) { + return; + } - if (myplr == pnum) { - NetSendCmdParam1(TRUE, CMD_PLRDEAD, earflag); - } + if (myplr == pnum) { + NetSendCmdParam1(TRUE, CMD_PLRDEAD, earflag); + } - BOOL diablolevel = gbMaxPlayers > 1 && plr[pnum].plrlevel == 16; + BOOL diablolevel = gbMaxPlayers > 1 && plr[pnum].plrlevel == 16; - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("StartPlayerKill: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("StartPlayerKill: illegal player %d", pnum); + } - if (plr[pnum]._pClass == PC_WARRIOR) { - PlaySfxLoc(PS_DEAD, plr[pnum].WorldX, plr[pnum].WorldY); // BUGFIX: should use `PS_WARR71` like other classes - } else if (plr[pnum]._pClass == PC_ROGUE) { - PlaySfxLoc(PS_ROGUE71, plr[pnum].WorldX, plr[pnum].WorldY); - } else if (plr[pnum]._pClass == PC_SORCERER) { - PlaySfxLoc(PS_MAGE71, plr[pnum].WorldX, plr[pnum].WorldY); - } + if (plr[pnum]._pClass == PC_WARRIOR) { + PlaySfxLoc(PS_DEAD, plr[pnum].WorldX, plr[pnum].WorldY); // BUGFIX: should use `PS_WARR71` like other classes + } else if (plr[pnum]._pClass == PC_ROGUE) { + PlaySfxLoc(PS_ROGUE71, plr[pnum].WorldX, plr[pnum].WorldY); + } else if (plr[pnum]._pClass == PC_SORCERER) { + PlaySfxLoc(PS_MAGE71, plr[pnum].WorldX, plr[pnum].WorldY); + } - if (plr[pnum]._pgfxnum) { - plr[pnum]._pgfxnum = 0; - plr[pnum]._pGFXLoad = 0; - SetPlrAnims(pnum); - } + if (plr[pnum]._pgfxnum) { + plr[pnum]._pgfxnum = 0; + plr[pnum]._pGFXLoad = 0; + SetPlrAnims(pnum); + } - if (!(plr[pnum]._pGFXLoad & PFILE_DEATH)) { - LoadPlrGFX(pnum, PFILE_DEATH); - } + if (!(plr[pnum]._pGFXLoad & PFILE_DEATH)) { + LoadPlrGFX(pnum, PFILE_DEATH); + } - PlayerStruct *p = &plr[pnum]; - NewPlrAnim(pnum, p->_pDAnim[plr[pnum]._pdir], p->_pDFrames, 1, p->_pDWidth); + PlayerStruct *p = &plr[pnum]; + NewPlrAnim(pnum, p->_pDAnim[plr[pnum]._pdir], p->_pDFrames, 1, p->_pDWidth); - plr[pnum]._pBlockFlag = FALSE; - plr[pnum]._pmode = PM_DEATH; - plr[pnum]._pInvincible = TRUE; - SetPlayerHitPoints(pnum, 0); - plr[pnum]._pVar8 = 1; + plr[pnum]._pBlockFlag = FALSE; + plr[pnum]._pmode = PM_DEATH; + plr[pnum]._pInvincible = TRUE; + SetPlayerHitPoints(pnum, 0); + plr[pnum]._pVar8 = 1; - int i; - if (pnum != myplr && !earflag && !diablolevel) { - for (i = 0; i < NUM_INVLOC; i++) { - plr[pnum].InvBody[i]._itype = ITYPE_NONE; - } - CalcPlrInv(pnum, FALSE); - } + int i; + if (pnum != myplr && !earflag && !diablolevel) { + for (i = 0; i < NUM_INVLOC; i++) { + plr[pnum].InvBody[i]._itype = ITYPE_NONE; + } + CalcPlrInv(pnum, FALSE); + } - if (plr[pnum].plrlevel == currlevel) { - FixPlayerLocation(pnum, plr[pnum]._pdir); - RemovePlrFromMap(pnum); - dFlags[plr[pnum].WorldX][plr[pnum].WorldY] |= DFLAG_DEAD_PLAYER; - SetPlayerOld(pnum); + if (plr[pnum].plrlevel == currlevel) { + FixPlayerLocation(pnum, plr[pnum]._pdir); + RemovePlrFromMap(pnum); + dFlags[plr[pnum].WorldX][plr[pnum].WorldY] |= DFLAG_DEAD_PLAYER; + SetPlayerOld(pnum); - if (pnum == myplr) { - drawhpflag = TRUE; - deathdelay = 30; + if (pnum == myplr) { + drawhpflag = TRUE; + deathdelay = 30; - if (pcurs >= CURSOR_FIRSTITEM) { - PlrDeadItem(pnum, &plr[pnum].HoldItem, 0, 0); - SetCursor(CURSOR_HAND); - } + if (pcurs >= CURSOR_FIRSTITEM) { + PlrDeadItem(pnum, &plr[pnum].HoldItem, 0, 0); + SetCursor(CURSOR_HAND); + } - if (!diablolevel) { - DropHalfPlayersGold(pnum); - if (earflag != -1) { - if (earflag != 0) { - ItemStruct ear; - SetPlrHandItem(&ear, IDI_EAR); - sprintf(ear._iName, "Ear of %s", plr[pnum]._pName); - if (plr[pnum]._pClass == PC_SORCERER) { - ear._iCurs = ICURS_EAR_SORCEROR; - } else if (plr[pnum]._pClass == PC_WARRIOR) { - ear._iCurs = ICURS_EAR_WARRIOR; - } else if (plr[pnum]._pClass == PC_ROGUE) { - ear._iCurs = ICURS_EAR_ROGUE; - } + if (!diablolevel) { + DropHalfPlayersGold(pnum); + if (earflag != -1) { + if (earflag != 0) { + ItemStruct ear; + SetPlrHandItem(&ear, IDI_EAR); + sprintf(ear._iName, "Ear of %s", plr[pnum]._pName); + if (plr[pnum]._pClass == PC_SORCERER) { + ear._iCurs = ICURS_EAR_SORCEROR; + } else if (plr[pnum]._pClass == PC_WARRIOR) { + ear._iCurs = ICURS_EAR_WARRIOR; + } else if (plr[pnum]._pClass == PC_ROGUE) { + ear._iCurs = ICURS_EAR_ROGUE; + } - ear._iCreateInfo = plr[pnum]._pName[0] << 8 | plr[pnum]._pName[1]; - ear._iSeed = plr[pnum]._pName[2] << 24 | plr[pnum]._pName[3] << 16 | plr[pnum]._pName[4] << 8 | plr[pnum]._pName[5]; - ear._ivalue = plr[pnum]._pLevel; + ear._iCreateInfo = plr[pnum]._pName[0] << 8 | plr[pnum]._pName[1]; + ear._iSeed = plr[pnum]._pName[2] << 24 | plr[pnum]._pName[3] << 16 | plr[pnum]._pName[4] << 8 | plr[pnum]._pName[5]; + ear._ivalue = plr[pnum]._pLevel; - if (FindGetItem(IDI_EAR, ear._iCreateInfo, ear._iSeed) == -1) { - PlrDeadItem(pnum, &ear, 0, 0); - } - } else { - ItemStruct *pi = &plr[pnum].InvBody[0]; - i = NUM_INVLOC; - while (i != 0) { - i--; - int pdd = (i + plr[pnum]._pdir) & 7; - PlrDeadItem(pnum, pi, offset_x[pdd], offset_y[pdd]); - pi++; - } + if (FindGetItem(IDI_EAR, ear._iCreateInfo, ear._iSeed) == -1) { + PlrDeadItem(pnum, &ear, 0, 0); + } + } else { + ItemStruct *pi = &plr[pnum].InvBody[0]; + i = NUM_INVLOC; + while (i != 0) { + i--; + int pdd = (i + plr[pnum]._pdir) & 7; + PlrDeadItem(pnum, pi, offset_x[pdd], offset_y[pdd]); + pi++; + } - CalcPlrInv(pnum, FALSE); - } - } - } - } - } - SetPlayerHitPoints(pnum, 0); + CalcPlrInv(pnum, FALSE); + } + } + } + } + } + SetPlayerHitPoints(pnum, 0); } void __fastcall PlrDeadItem(int pnum, struct ItemStruct *itm, int xx, int yy) { - int x, y; - int i, j; + int x, y; + int i, j; - if (itm->_itype == ITYPE_NONE) - return; + if (itm->_itype == ITYPE_NONE) + return; - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("PlrDeadItem: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("PlrDeadItem: illegal player %d", pnum); + } - x = xx + plr[pnum].WorldX; - y = yy + plr[pnum].WorldY; - if ((xx || yy) && ItemSpaceOk(x, y)) { - RespawnDeadItem(itm, x, y); - plr[pnum].HoldItem = *itm; - NetSendCmdPItem(FALSE, CMD_RESPAWNITEM, x, y); - return; - } + x = xx + plr[pnum].WorldX; + y = yy + plr[pnum].WorldY; + if ((xx || yy) && ItemSpaceOk(x, y)) { + RespawnDeadItem(itm, x, y); + plr[pnum].HoldItem = *itm; + NetSendCmdPItem(FALSE, CMD_RESPAWNITEM, x, y); + return; + } - for (yy = -1, xx = 1; yy > -50; xx++, yy--) { - for (j = yy; j <= xx; j++) { - y = j + plr[pnum].WorldY; - for (i = yy; i <= xx; i++) { - x = i + plr[pnum].WorldX; - if (ItemSpaceOk(x, y)) { - RespawnDeadItem(itm, x, y); - plr[pnum].HoldItem = *itm; - NetSendCmdPItem(FALSE, CMD_RESPAWNITEM, x, y); - return; - } - } - } - } + for (yy = -1, xx = 1; yy > -50; xx++, yy--) { + for (j = yy; j <= xx; j++) { + y = j + plr[pnum].WorldY; + for (i = yy; i <= xx; i++) { + x = i + plr[pnum].WorldX; + if (ItemSpaceOk(x, y)) { + RespawnDeadItem(itm, x, y); + plr[pnum].HoldItem = *itm; + NetSendCmdPItem(FALSE, CMD_RESPAWNITEM, x, y); + return; + } + } + } + } } void __fastcall DropHalfPlayersGold(int pnum) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("DropHalfPlayersGold: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("DropHalfPlayersGold: illegal player %d", pnum); + } - int i; - int hGold = plr[pnum]._pGold >> 1; - for (i = 0; i < MAXBELTITEMS && hGold > 0; i++) { - if (plr[pnum].SpdList[i]._itype == ITYPE_GOLD && plr[pnum].SpdList[i]._ivalue != 5000) { - if (hGold < plr[pnum].SpdList[i]._ivalue) { - plr[pnum].SpdList[i]._ivalue -= hGold; - SetSpdbarGoldCurs(pnum, i); - SetPlrHandItem(&plr[pnum].HoldItem, IDI_GOLD); - GetGoldSeed(pnum, &plr[pnum].HoldItem); - SetPlrHandGoldCurs(&plr[pnum].HoldItem); - plr[pnum].HoldItem._ivalue = hGold; - PlrDeadItem(pnum, &plr[pnum].HoldItem, 0, 0); - hGold = 0; - } else { - hGold -= plr[pnum].SpdList[i]._ivalue; - RemoveSpdBarItem(pnum, i); - SetPlrHandItem(&plr[pnum].HoldItem, IDI_GOLD); - GetGoldSeed(pnum, &plr[pnum].HoldItem); - SetPlrHandGoldCurs(&plr[pnum].HoldItem); - plr[pnum].HoldItem._ivalue = plr[pnum].SpdList[i]._ivalue; - PlrDeadItem(pnum, &plr[pnum].HoldItem, 0, 0); - i = -1; - } - } - } - if (hGold > 0) { - for (i = 0; i < MAXBELTITEMS && hGold > 0; i++) { - if (plr[pnum].SpdList[i]._itype == ITYPE_GOLD) { - if (hGold < plr[pnum].SpdList[i]._ivalue) { - plr[pnum].SpdList[i]._ivalue -= hGold; - SetSpdbarGoldCurs(pnum, i); - SetPlrHandItem(&plr[pnum].HoldItem, IDI_GOLD); - GetGoldSeed(pnum, &plr[pnum].HoldItem); - SetPlrHandGoldCurs(&plr[pnum].HoldItem); - plr[pnum].HoldItem._ivalue = hGold; - PlrDeadItem(pnum, &plr[pnum].HoldItem, 0, 0); - hGold = 0; - } else { - hGold -= plr[pnum].SpdList[i]._ivalue; - RemoveSpdBarItem(pnum, i); - SetPlrHandItem(&plr[pnum].HoldItem, IDI_GOLD); - GetGoldSeed(pnum, &plr[pnum].HoldItem); - SetPlrHandGoldCurs(&plr[pnum].HoldItem); - plr[pnum].HoldItem._ivalue = plr[pnum].SpdList[i]._ivalue; - PlrDeadItem(pnum, &plr[pnum].HoldItem, 0, 0); - i = -1; - } - } - } - } - drawpanflag = 255; - if (hGold > 0) { - for (i = 0; i < plr[pnum]._pNumInv && hGold > 0; i++) { - if (plr[pnum].InvList[i]._itype == ITYPE_GOLD && plr[pnum].InvList[i]._ivalue != 5000) { - if (hGold < plr[pnum].InvList[i]._ivalue) { - plr[pnum].InvList[i]._ivalue -= hGold; - SetGoldCurs(pnum, i); - SetPlrHandItem(&plr[pnum].HoldItem, IDI_GOLD); - GetGoldSeed(pnum, &plr[pnum].HoldItem); - SetPlrHandGoldCurs(&plr[pnum].HoldItem); - plr[pnum].HoldItem._ivalue = hGold; - PlrDeadItem(pnum, &plr[pnum].HoldItem, 0, 0); - hGold = 0; - } else { - hGold -= plr[pnum].InvList[i]._ivalue; - RemoveInvItem(pnum, i); - SetPlrHandItem(&plr[pnum].HoldItem, IDI_GOLD); - GetGoldSeed(pnum, &plr[pnum].HoldItem); - SetPlrHandGoldCurs(&plr[pnum].HoldItem); - plr[pnum].HoldItem._ivalue = plr[pnum].InvList[i]._ivalue; - PlrDeadItem(pnum, &plr[pnum].HoldItem, 0, 0); - i = -1; - } - } - } - } - if (hGold > 0) { - for (i = 0; i < plr[pnum]._pNumInv && hGold > 0; i++) { - if (plr[pnum].InvList[i]._itype == ITYPE_GOLD) { - if (hGold < plr[pnum].InvList[i]._ivalue) { - plr[pnum].InvList[i]._ivalue -= hGold; - SetGoldCurs(pnum, i); - SetPlrHandItem(&plr[pnum].HoldItem, IDI_GOLD); - GetGoldSeed(pnum, &plr[pnum].HoldItem); - SetPlrHandGoldCurs(&plr[pnum].HoldItem); - plr[pnum].HoldItem._ivalue = hGold; - PlrDeadItem(pnum, &plr[pnum].HoldItem, 0, 0); - hGold = 0; - } else { - hGold -= plr[pnum].InvList[i]._ivalue; - RemoveInvItem(pnum, i); - SetPlrHandItem(&plr[pnum].HoldItem, IDI_GOLD); - GetGoldSeed(pnum, &plr[pnum].HoldItem); - SetPlrHandGoldCurs(&plr[pnum].HoldItem); - plr[pnum].HoldItem._ivalue = plr[pnum].InvList[i]._ivalue; - PlrDeadItem(pnum, &plr[pnum].HoldItem, 0, 0); - i = -1; - } - } - } - } - plr[pnum]._pGold = CalculateGold(pnum); + int i; + int hGold = plr[pnum]._pGold >> 1; + for (i = 0; i < MAXBELTITEMS && hGold > 0; i++) { + if (plr[pnum].SpdList[i]._itype == ITYPE_GOLD && plr[pnum].SpdList[i]._ivalue != 5000) { + if (hGold < plr[pnum].SpdList[i]._ivalue) { + plr[pnum].SpdList[i]._ivalue -= hGold; + SetSpdbarGoldCurs(pnum, i); + SetPlrHandItem(&plr[pnum].HoldItem, IDI_GOLD); + GetGoldSeed(pnum, &plr[pnum].HoldItem); + SetPlrHandGoldCurs(&plr[pnum].HoldItem); + plr[pnum].HoldItem._ivalue = hGold; + PlrDeadItem(pnum, &plr[pnum].HoldItem, 0, 0); + hGold = 0; + } else { + hGold -= plr[pnum].SpdList[i]._ivalue; + RemoveSpdBarItem(pnum, i); + SetPlrHandItem(&plr[pnum].HoldItem, IDI_GOLD); + GetGoldSeed(pnum, &plr[pnum].HoldItem); + SetPlrHandGoldCurs(&plr[pnum].HoldItem); + plr[pnum].HoldItem._ivalue = plr[pnum].SpdList[i]._ivalue; + PlrDeadItem(pnum, &plr[pnum].HoldItem, 0, 0); + i = -1; + } + } + } + if (hGold > 0) { + for (i = 0; i < MAXBELTITEMS && hGold > 0; i++) { + if (plr[pnum].SpdList[i]._itype == ITYPE_GOLD) { + if (hGold < plr[pnum].SpdList[i]._ivalue) { + plr[pnum].SpdList[i]._ivalue -= hGold; + SetSpdbarGoldCurs(pnum, i); + SetPlrHandItem(&plr[pnum].HoldItem, IDI_GOLD); + GetGoldSeed(pnum, &plr[pnum].HoldItem); + SetPlrHandGoldCurs(&plr[pnum].HoldItem); + plr[pnum].HoldItem._ivalue = hGold; + PlrDeadItem(pnum, &plr[pnum].HoldItem, 0, 0); + hGold = 0; + } else { + hGold -= plr[pnum].SpdList[i]._ivalue; + RemoveSpdBarItem(pnum, i); + SetPlrHandItem(&plr[pnum].HoldItem, IDI_GOLD); + GetGoldSeed(pnum, &plr[pnum].HoldItem); + SetPlrHandGoldCurs(&plr[pnum].HoldItem); + plr[pnum].HoldItem._ivalue = plr[pnum].SpdList[i]._ivalue; + PlrDeadItem(pnum, &plr[pnum].HoldItem, 0, 0); + i = -1; + } + } + } + } + drawpanflag = 255; + if (hGold > 0) { + for (i = 0; i < plr[pnum]._pNumInv && hGold > 0; i++) { + if (plr[pnum].InvList[i]._itype == ITYPE_GOLD && plr[pnum].InvList[i]._ivalue != 5000) { + if (hGold < plr[pnum].InvList[i]._ivalue) { + plr[pnum].InvList[i]._ivalue -= hGold; + SetGoldCurs(pnum, i); + SetPlrHandItem(&plr[pnum].HoldItem, IDI_GOLD); + GetGoldSeed(pnum, &plr[pnum].HoldItem); + SetPlrHandGoldCurs(&plr[pnum].HoldItem); + plr[pnum].HoldItem._ivalue = hGold; + PlrDeadItem(pnum, &plr[pnum].HoldItem, 0, 0); + hGold = 0; + } else { + hGold -= plr[pnum].InvList[i]._ivalue; + RemoveInvItem(pnum, i); + SetPlrHandItem(&plr[pnum].HoldItem, IDI_GOLD); + GetGoldSeed(pnum, &plr[pnum].HoldItem); + SetPlrHandGoldCurs(&plr[pnum].HoldItem); + plr[pnum].HoldItem._ivalue = plr[pnum].InvList[i]._ivalue; + PlrDeadItem(pnum, &plr[pnum].HoldItem, 0, 0); + i = -1; + } + } + } + } + if (hGold > 0) { + for (i = 0; i < plr[pnum]._pNumInv && hGold > 0; i++) { + if (plr[pnum].InvList[i]._itype == ITYPE_GOLD) { + if (hGold < plr[pnum].InvList[i]._ivalue) { + plr[pnum].InvList[i]._ivalue -= hGold; + SetGoldCurs(pnum, i); + SetPlrHandItem(&plr[pnum].HoldItem, IDI_GOLD); + GetGoldSeed(pnum, &plr[pnum].HoldItem); + SetPlrHandGoldCurs(&plr[pnum].HoldItem); + plr[pnum].HoldItem._ivalue = hGold; + PlrDeadItem(pnum, &plr[pnum].HoldItem, 0, 0); + hGold = 0; + } else { + hGold -= plr[pnum].InvList[i]._ivalue; + RemoveInvItem(pnum, i); + SetPlrHandItem(&plr[pnum].HoldItem, IDI_GOLD); + GetGoldSeed(pnum, &plr[pnum].HoldItem); + SetPlrHandGoldCurs(&plr[pnum].HoldItem); + plr[pnum].HoldItem._ivalue = plr[pnum].InvList[i]._ivalue; + PlrDeadItem(pnum, &plr[pnum].HoldItem, 0, 0); + i = -1; + } + } + } + } + plr[pnum]._pGold = CalculateGold(pnum); } // 52571C: using guessed type int drawpanflag; void __fastcall SyncPlrKill(int pnum, int earflag) { - if (plr[pnum]._pHitPoints == 0 && currlevel == 0) { - SetPlayerHitPoints(pnum, 64); - return; - } + if (plr[pnum]._pHitPoints == 0 && currlevel == 0) { + SetPlayerHitPoints(pnum, 64); + return; + } - for (int i = 0; i < nummissiles; i++) { - int ma = missileactive[i]; - if (missile[ma]._mitype == MIS_MANASHIELD && missile[ma]._misource == pnum && missile[ma]._miDelFlag == 0) { - if (earflag != -1) { - missile[ma]._miVar8 = earflag; - } + for (int i = 0; i < nummissiles; i++) { + int ma = missileactive[i]; + if (missile[ma]._mitype == MIS_MANASHIELD && missile[ma]._misource == pnum && missile[ma]._miDelFlag == 0) { + if (earflag != -1) { + missile[ma]._miVar8 = earflag; + } - return; - } - } + return; + } + } - SetPlayerHitPoints(pnum, 0); - StartPlayerKill(pnum, earflag); + SetPlayerHitPoints(pnum, 0); + StartPlayerKill(pnum, earflag); } void __fastcall RemovePlrMissiles(int pnum) { - if (currlevel != 0 && pnum == myplr && (monster[myplr]._mx != 1 || monster[myplr]._my != 0)) { - M_StartKill(myplr, myplr); - AddDead(monster[myplr]._mx, monster[myplr]._my, monster[myplr].MType->mdeadval, (direction)monster[myplr]._mdir); - dMonster[monster[myplr]._mx][monster[myplr]._my] = 0; - monster[myplr]._mDelFlag = TRUE; - DeleteMonsterList(); - } + if (currlevel != 0 && pnum == myplr && (monster[myplr]._mx != 1 || monster[myplr]._my != 0)) { + M_StartKill(myplr, myplr); + AddDead(monster[myplr]._mx, monster[myplr]._my, monster[myplr].MType->mdeadval, (direction)monster[myplr]._mdir); + dMonster[monster[myplr]._mx][monster[myplr]._my] = 0; + monster[myplr]._mDelFlag = TRUE; + DeleteMonsterList(); + } - for (int mi = 0; mi < nummissiles; mi++) { - int am = missileactive[mi]; - if (missile[am]._mitype == MIS_STONE && missile[am]._misource == pnum) { - monster[missile[am]._miVar2]._mmode = missile[am]._miVar1; - } - if (missile[am]._mitype == MIS_MANASHIELD && missile[am]._misource == pnum) { - ClearMissileSpot(am); - DeleteMissile(am, mi); - } - if (missile[am]._mitype == MIS_ETHEREALIZE && missile[am]._misource == pnum) { - ClearMissileSpot(am); - DeleteMissile(am, mi); - } - } + for (int mi = 0; mi < nummissiles; mi++) { + int am = missileactive[mi]; + if (missile[am]._mitype == MIS_STONE && missile[am]._misource == pnum) { + monster[missile[am]._miVar2]._mmode = missile[am]._miVar1; + } + if (missile[am]._mitype == MIS_MANASHIELD && missile[am]._misource == pnum) { + ClearMissileSpot(am); + DeleteMissile(am, mi); + } + if (missile[am]._mitype == MIS_ETHEREALIZE && missile[am]._misource == pnum) { + ClearMissileSpot(am); + DeleteMissile(am, mi); + } + } } void __fastcall InitLevelChange(int pnum) { - RemovePlrMissiles(pnum); - if (pnum == myplr && qtextflag) { - qtextflag = FALSE; - sfx_stop(); - } + RemovePlrMissiles(pnum); + if (pnum == myplr && qtextflag) { + qtextflag = FALSE; + sfx_stop(); + } - RemovePlrFromMap(pnum); - SetPlayerOld(pnum); - if (pnum == myplr) { - dPlayer[plr[myplr].WorldX][plr[myplr].WorldY] = myplr + 1; - } else { - plr[pnum]._pLvlVisited[plr[pnum].plrlevel] = 1; - } + RemovePlrFromMap(pnum); + SetPlayerOld(pnum); + if (pnum == myplr) { + dPlayer[plr[myplr].WorldX][plr[myplr].WorldY] = myplr + 1; + } else { + plr[pnum]._pLvlVisited[plr[pnum].plrlevel] = 1; + } - ClrPlrPath(pnum); - plr[pnum].destAction = ACTION_NONE; - plr[pnum]._pLvlChanging = 1; + ClrPlrPath(pnum); + plr[pnum].destAction = ACTION_NONE; + plr[pnum]._pLvlChanging = 1; - if (pnum == myplr) { - plr[pnum].pLvlLoad = 10; - } + if (pnum == myplr) { + plr[pnum].pLvlLoad = 10; + } } // 646D00: using guessed type char qtextflag; void __fastcall StartNewLvl(int pnum, int fom, int lvl) { - InitLevelChange(pnum); + InitLevelChange(pnum); - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("StartNewLvl: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("StartNewLvl: illegal player %d", pnum); + } - switch (fom) { - case WM_DIABNEXTLVL: - case WM_DIABPREVLVL: - plr[pnum].plrlevel = lvl; - break; - case WM_DIABRTNLVL: - case WM_DIABTOWNWARP: - plr[pnum].plrlevel = lvl; - break; - case WM_DIABSETLVL: - setlvlnum = lvl; - break; - case WM_DIABTWARPUP: - plr[myplr].pTownWarps |= 1 << (leveltype - 2); - plr[pnum].plrlevel = lvl; - break; - case WM_DIABRETOWN: - break; - default: - TermMsg("StartNewLvl"); - break; - } + switch (fom) { + case WM_DIABNEXTLVL: + case WM_DIABPREVLVL: + plr[pnum].plrlevel = lvl; + break; + case WM_DIABRTNLVL: + case WM_DIABTOWNWARP: + plr[pnum].plrlevel = lvl; + break; + case WM_DIABSETLVL: + setlvlnum = lvl; + break; + case WM_DIABTWARPUP: + plr[myplr].pTownWarps |= 1 << (leveltype - 2); + plr[pnum].plrlevel = lvl; + break; + case WM_DIABRETOWN: + break; + default: + TermMsg("StartNewLvl"); + break; + } - if (pnum == myplr) { - plr[pnum]._pmode = PM_NEWLVL; - plr[pnum]._pInvincible = TRUE; - PostMessage(ghMainWnd, fom, 0, 0); - if (gbMaxPlayers > 1) { - NetSendCmdParam2(TRUE, CMD_NEWLVL, fom, lvl); - } - } + if (pnum == myplr) { + plr[pnum]._pmode = PM_NEWLVL; + plr[pnum]._pInvincible = TRUE; + PostMessage(ghMainWnd, fom, 0, 0); + if (gbMaxPlayers > 1) { + NetSendCmdParam2(TRUE, CMD_NEWLVL, fom, lvl); + } + } } void __fastcall RestartTownLvl(int pnum) { - InitLevelChange(pnum); - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("RestartTownLvl: illegal player %d", pnum); - } + InitLevelChange(pnum); + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("RestartTownLvl: illegal player %d", pnum); + } - plr[pnum].plrlevel = 0; - plr[pnum]._pInvincible = FALSE; + plr[pnum].plrlevel = 0; + plr[pnum]._pInvincible = FALSE; - SetPlayerHitPoints(pnum, 64); + SetPlayerHitPoints(pnum, 64); - plr[pnum]._pMana = 0; - plr[pnum]._pManaBase = plr[pnum]._pMaxManaBase - plr[pnum]._pMaxMana; + plr[pnum]._pMana = 0; + plr[pnum]._pManaBase = plr[pnum]._pMaxManaBase - plr[pnum]._pMaxMana; - CalcPlrInv(pnum, FALSE); + CalcPlrInv(pnum, FALSE); - if (pnum == myplr) { - plr[pnum]._pmode = PM_NEWLVL; - plr[pnum]._pInvincible = TRUE; - PostMessage(ghMainWnd, WM_DIABRETOWN, 0, 0); - } + if (pnum == myplr) { + plr[pnum]._pmode = PM_NEWLVL; + plr[pnum]._pInvincible = TRUE; + PostMessage(ghMainWnd, WM_DIABRETOWN, 0, 0); + } } void __fastcall StartWarpLvl(int pnum, int pidx) { - InitLevelChange(pnum); + InitLevelChange(pnum); - if (gbMaxPlayers != 1) { - if (plr[pnum].plrlevel != 0) { - plr[pnum].plrlevel = 0; - } else { - plr[pnum].plrlevel = portal[pidx].level; - } - } + if (gbMaxPlayers != 1) { + if (plr[pnum].plrlevel != 0) { + plr[pnum].plrlevel = 0; + } else { + plr[pnum].plrlevel = portal[pidx].level; + } + } - if (pnum == myplr) { - SetCurrentPortal(pidx); - plr[pnum]._pmode = PM_NEWLVL; - plr[pnum]._pInvincible = TRUE; - PostMessage(ghMainWnd, WM_DIABWARPLVL, 0, 0); - } + if (pnum == myplr) { + SetCurrentPortal(pidx); + plr[pnum]._pmode = PM_NEWLVL; + plr[pnum]._pInvincible = TRUE; + PostMessage(ghMainWnd, WM_DIABWARPLVL, 0, 0); + } } BOOL __fastcall PM_DoStand(int pnum) { - return FALSE; + return FALSE; } BOOL __fastcall PM_DoWalk(int pnum) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("PM_DoWalk: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("PM_DoWalk: illegal player %d", pnum); + } - if (plr[pnum]._pAnimFrame == 3 - || (plr[pnum]._pWFrames == 8 && plr[pnum]._pAnimFrame == 7) - || (plr[pnum]._pWFrames != 8 && plr[pnum]._pAnimFrame == 4)) { - PlaySfxLoc(PS_WALK1, plr[pnum].WorldX, plr[pnum].WorldY); - } + if (plr[pnum]._pAnimFrame == 3 + || (plr[pnum]._pWFrames == 8 && plr[pnum]._pAnimFrame == 7) + || (plr[pnum]._pWFrames != 8 && plr[pnum]._pAnimFrame == 4)) { + PlaySfxLoc(PS_WALK1, plr[pnum].WorldX, plr[pnum].WorldY); + } - int vel = 8; - if (currlevel != 0) { - vel = PWVel[3][plr[pnum]._pClass]; - } + int vel = 8; + if (currlevel != 0) { + vel = PWVel[3][plr[pnum]._pClass]; + } - if (plr[pnum]._pVar8 == vel) { - dPlayer[plr[pnum].WorldX][plr[pnum].WorldY] = 0; - plr[pnum].WorldX += plr[pnum]._pVar1; - plr[pnum].WorldY += plr[pnum]._pVar2; - dPlayer[plr[pnum].WorldX][plr[pnum].WorldY] = pnum + 1; + if (plr[pnum]._pVar8 == vel) { + dPlayer[plr[pnum].WorldX][plr[pnum].WorldY] = 0; + plr[pnum].WorldX += plr[pnum]._pVar1; + plr[pnum].WorldY += plr[pnum]._pVar2; + dPlayer[plr[pnum].WorldX][plr[pnum].WorldY] = pnum + 1; - if (leveltype != DTYPE_TOWN) { - ChangeLightXY(plr[pnum]._plid, plr[pnum].WorldX, plr[pnum].WorldY); - ChangeVisionXY(plr[pnum]._pvid, plr[pnum].WorldX, plr[pnum].WorldY); - } + if (leveltype != DTYPE_TOWN) { + ChangeLightXY(plr[pnum]._plid, plr[pnum].WorldX, plr[pnum].WorldY); + ChangeVisionXY(plr[pnum]._pvid, plr[pnum].WorldX, plr[pnum].WorldY); + } - if (pnum == myplr && ScrollInfo._sdir) { - ViewX = plr[pnum].WorldX - ScrollInfo._sdx; - ViewY = plr[pnum].WorldY - ScrollInfo._sdy; - } + if (pnum == myplr && ScrollInfo._sdir) { + ViewX = plr[pnum].WorldX - ScrollInfo._sdx; + ViewY = plr[pnum].WorldY - ScrollInfo._sdy; + } - if (plr[pnum].walkpath[0] != WALK_NONE) { - StartWalkStand(pnum); - } else { - StartStand(pnum, plr[pnum]._pVar3); - } + if (plr[pnum].walkpath[0] != WALK_NONE) { + StartWalkStand(pnum); + } else { + StartStand(pnum, plr[pnum]._pVar3); + } - ClearPlrPVars(pnum); - if (leveltype != DTYPE_TOWN) { - ChangeLightOff(plr[pnum]._plid, 0, 0); - } + ClearPlrPVars(pnum); + if (leveltype != DTYPE_TOWN) { + ChangeLightOff(plr[pnum]._plid, 0, 0); + } - return TRUE; - } + return TRUE; + } - PM_ChangeOffset(pnum); - return FALSE; + PM_ChangeOffset(pnum); + return FALSE; } BOOL __fastcall PM_DoWalk2(int pnum) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("PM_DoWalk2: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("PM_DoWalk2: illegal player %d", pnum); + } - if (plr[pnum]._pAnimFrame == 3 - || (plr[pnum]._pWFrames == 8 && plr[pnum]._pAnimFrame == 7) - || (plr[pnum]._pWFrames != 8 && plr[pnum]._pAnimFrame == 4)) { - PlaySfxLoc(PS_WALK1, plr[pnum].WorldX, plr[pnum].WorldY); - } + if (plr[pnum]._pAnimFrame == 3 + || (plr[pnum]._pWFrames == 8 && plr[pnum]._pAnimFrame == 7) + || (plr[pnum]._pWFrames != 8 && plr[pnum]._pAnimFrame == 4)) { + PlaySfxLoc(PS_WALK1, plr[pnum].WorldX, plr[pnum].WorldY); + } - int vel = 8; - if (currlevel != 0) { - vel = PWVel[3][plr[pnum]._pClass]; - } + int vel = 8; + if (currlevel != 0) { + vel = PWVel[3][plr[pnum]._pClass]; + } - if (plr[pnum]._pVar8 == vel) { - dPlayer[plr[pnum]._pVar1][plr[pnum]._pVar2] = 0; - if (leveltype != DTYPE_TOWN) { - ChangeLightXY(plr[pnum]._plid, plr[pnum].WorldX, plr[pnum].WorldY); - ChangeVisionXY(plr[pnum]._pvid, plr[pnum].WorldX, plr[pnum].WorldY); - } + if (plr[pnum]._pVar8 == vel) { + dPlayer[plr[pnum]._pVar1][plr[pnum]._pVar2] = 0; + if (leveltype != DTYPE_TOWN) { + ChangeLightXY(plr[pnum]._plid, plr[pnum].WorldX, plr[pnum].WorldY); + ChangeVisionXY(plr[pnum]._pvid, plr[pnum].WorldX, plr[pnum].WorldY); + } - if (pnum == myplr && ScrollInfo._sdir) { - ViewX = plr[pnum].WorldX - ScrollInfo._sdx; - ViewY = plr[pnum].WorldY - ScrollInfo._sdy; - } + if (pnum == myplr && ScrollInfo._sdir) { + ViewX = plr[pnum].WorldX - ScrollInfo._sdx; + ViewY = plr[pnum].WorldY - ScrollInfo._sdy; + } - if (plr[pnum].walkpath[0] != WALK_NONE) { - StartWalkStand(pnum); - } else { - StartStand(pnum, plr[pnum]._pVar3); - } + if (plr[pnum].walkpath[0] != WALK_NONE) { + StartWalkStand(pnum); + } else { + StartStand(pnum, plr[pnum]._pVar3); + } - ClearPlrPVars(pnum); + ClearPlrPVars(pnum); - if (leveltype != DTYPE_TOWN) { - ChangeLightOff(plr[pnum]._plid, 0, 0); - } + if (leveltype != DTYPE_TOWN) { + ChangeLightOff(plr[pnum]._plid, 0, 0); + } - return TRUE; - } + return TRUE; + } - PM_ChangeOffset(pnum); - return FALSE; + PM_ChangeOffset(pnum); + return FALSE; } BOOL __fastcall PM_DoWalk3(int pnum) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("PM_DoWalk3: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("PM_DoWalk3: illegal player %d", pnum); + } - if (plr[pnum]._pAnimFrame == 3 - || (plr[pnum]._pWFrames == 8 && plr[pnum]._pAnimFrame == 7) - || (plr[pnum]._pWFrames != 8 && plr[pnum]._pAnimFrame == 4)) { - PlaySfxLoc(PS_WALK1, plr[pnum].WorldX, plr[pnum].WorldY); - } + if (plr[pnum]._pAnimFrame == 3 + || (plr[pnum]._pWFrames == 8 && plr[pnum]._pAnimFrame == 7) + || (plr[pnum]._pWFrames != 8 && plr[pnum]._pAnimFrame == 4)) { + PlaySfxLoc(PS_WALK1, plr[pnum].WorldX, plr[pnum].WorldY); + } - int vel = 8; - if (currlevel != 0) { - vel = PWVel[3][plr[pnum]._pClass]; - } + int vel = 8; + if (currlevel != 0) { + vel = PWVel[3][plr[pnum]._pClass]; + } - if (plr[pnum]._pVar8 == vel) { - dPlayer[plr[pnum].WorldX][plr[pnum].WorldY] = 0; - dFlags[plr[pnum]._pVar4][plr[pnum]._pVar5] &= ~DFLAG_PLAYER; - plr[pnum].WorldX = plr[pnum]._pVar1; - plr[pnum].WorldY = plr[pnum]._pVar2; - dPlayer[plr[pnum]._pVar1][plr[pnum]._pVar2] = pnum + 1; + if (plr[pnum]._pVar8 == vel) { + dPlayer[plr[pnum].WorldX][plr[pnum].WorldY] = 0; + dFlags[plr[pnum]._pVar4][plr[pnum]._pVar5] &= ~DFLAG_PLAYER; + plr[pnum].WorldX = plr[pnum]._pVar1; + plr[pnum].WorldY = plr[pnum]._pVar2; + dPlayer[plr[pnum]._pVar1][plr[pnum]._pVar2] = pnum + 1; - if (leveltype != DTYPE_TOWN) { - ChangeLightXY(plr[pnum]._plid, plr[pnum]._pVar1, plr[pnum]._pVar2); - ChangeVisionXY(plr[pnum]._pvid, plr[pnum].WorldX, plr[pnum].WorldY); - } + if (leveltype != DTYPE_TOWN) { + ChangeLightXY(plr[pnum]._plid, plr[pnum]._pVar1, plr[pnum]._pVar2); + ChangeVisionXY(plr[pnum]._pvid, plr[pnum].WorldX, plr[pnum].WorldY); + } - if (pnum == myplr && ScrollInfo._sdir) { - ViewX = plr[pnum].WorldX - ScrollInfo._sdx; - ViewY = plr[pnum].WorldY - ScrollInfo._sdy; - } + if (pnum == myplr && ScrollInfo._sdir) { + ViewX = plr[pnum].WorldX - ScrollInfo._sdx; + ViewY = plr[pnum].WorldY - ScrollInfo._sdy; + } - if (plr[pnum].walkpath[0] != WALK_NONE) { - StartWalkStand(pnum); - } else { - StartStand(pnum, plr[pnum]._pVar3); - } + if (plr[pnum].walkpath[0] != WALK_NONE) { + StartWalkStand(pnum); + } else { + StartStand(pnum, plr[pnum]._pVar3); + } - ClearPlrPVars(pnum); + ClearPlrPVars(pnum); - if (leveltype != DTYPE_TOWN) { - ChangeLightOff(plr[pnum]._plid, 0, 0); - } + if (leveltype != DTYPE_TOWN) { + ChangeLightOff(plr[pnum]._plid, 0, 0); + } - return TRUE; - } + return TRUE; + } - PM_ChangeOffset(pnum); - return FALSE; + PM_ChangeOffset(pnum); + return FALSE; } BOOL __fastcall WeaponDur(int pnum, int durrnd) { - if (pnum != myplr) { - return FALSE; - } + if (pnum != myplr) { + return FALSE; + } - if (random(3, durrnd) != 0) { - return FALSE; - } + if (random(3, durrnd) != 0) { + return FALSE; + } - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("WeaponDur: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("WeaponDur: illegal player %d", pnum); + } - if (plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype != ITYPE_NONE && plr[pnum].InvBody[INVLOC_HAND_LEFT]._iClass == ICLASS_WEAPON) { - if (plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability == DUR_INDESTRUCTIBLE) { - return FALSE; - } + if (plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype != ITYPE_NONE && plr[pnum].InvBody[INVLOC_HAND_LEFT]._iClass == ICLASS_WEAPON) { + if (plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability == DUR_INDESTRUCTIBLE) { + return FALSE; + } - plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability--; - if (plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability == 0) { - NetSendCmdDelItem(TRUE, INVLOC_HAND_LEFT); - plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype = ITYPE_NONE; - CalcPlrInv(pnum, TRUE); - return TRUE; - } - } + plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability--; + if (plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability == 0) { + NetSendCmdDelItem(TRUE, INVLOC_HAND_LEFT); + plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype = ITYPE_NONE; + CalcPlrInv(pnum, TRUE); + return TRUE; + } + } - if (plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype != ITYPE_NONE && plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iClass == ICLASS_WEAPON) { - if (plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iDurability == DUR_INDESTRUCTIBLE) { - return FALSE; - } + if (plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype != ITYPE_NONE && plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iClass == ICLASS_WEAPON) { + if (plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iDurability == DUR_INDESTRUCTIBLE) { + return FALSE; + } - plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iDurability--; - if (plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iDurability == 0) { - NetSendCmdDelItem(TRUE, INVLOC_HAND_RIGHT); - plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype = ITYPE_NONE; - CalcPlrInv(pnum, TRUE); - return TRUE; - } - } + plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iDurability--; + if (plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iDurability == 0) { + NetSendCmdDelItem(TRUE, INVLOC_HAND_RIGHT); + plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype = ITYPE_NONE; + CalcPlrInv(pnum, TRUE); + return TRUE; + } + } - if (plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_NONE && plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype == ITYPE_SHIELD) { - if (plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iDurability == DUR_INDESTRUCTIBLE) { - return FALSE; - } + if (plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_NONE && plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype == ITYPE_SHIELD) { + if (plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iDurability == DUR_INDESTRUCTIBLE) { + return FALSE; + } - plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iDurability--; - if (plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iDurability == 0) { - NetSendCmdDelItem(TRUE, INVLOC_HAND_RIGHT); - plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype = ITYPE_NONE; - CalcPlrInv(pnum, TRUE); - return TRUE; - } - } + plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iDurability--; + if (plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iDurability == 0) { + NetSendCmdDelItem(TRUE, INVLOC_HAND_RIGHT); + plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype = ITYPE_NONE; + CalcPlrInv(pnum, TRUE); + return TRUE; + } + } - if (plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype == ITYPE_NONE && plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_SHIELD) { - if (plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability == DUR_INDESTRUCTIBLE) { - return FALSE; - } + if (plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype == ITYPE_NONE && plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_SHIELD) { + if (plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability == DUR_INDESTRUCTIBLE) { + return FALSE; + } - plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability--; - if (plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability == 0) { - NetSendCmdDelItem(TRUE, INVLOC_HAND_LEFT); - plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype = ITYPE_NONE; - CalcPlrInv(pnum, TRUE); - return TRUE; - } - } + plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability--; + if (plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability == 0) { + NetSendCmdDelItem(TRUE, INVLOC_HAND_LEFT); + plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype = ITYPE_NONE; + CalcPlrInv(pnum, TRUE); + return TRUE; + } + } - return FALSE; + return FALSE; } BOOL __fastcall PlrHitMonst(int pnum, int m) { - if ((DWORD)m >= MAXMONSTERS) { - TermMsg("PlrHitMonst: illegal monster %d", m); - } + if ((DWORD)m >= MAXMONSTERS) { + TermMsg("PlrHitMonst: illegal monster %d", m); + } - if ((monster[m]._mhitpoints >> 6) <= 0) { - return FALSE; - } + if ((monster[m]._mhitpoints >> 6) <= 0) { + return FALSE; + } - if (monster[m].MType->mtype == MT_ILLWEAV && monster[m]._mgoal == 2) { - return FALSE; - } + if (monster[m].MType->mtype == MT_ILLWEAV && monster[m]._mgoal == 2) { + return FALSE; + } - if (monster[m]._mmode == MM_CHARGE) { - return FALSE; - } + if (monster[m]._mmode == MM_CHARGE) { + return FALSE; + } - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("PlrHitMonst: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("PlrHitMonst: illegal player %d", pnum); + } - BOOL rv = FALSE; + BOOL rv = FALSE; - int hit = random(4, 100); - if (monster[m]._mmode == MM_STONE) { - hit = 0; - } + int hit = random(4, 100); + if (monster[m]._mmode == MM_STONE) { + hit = 0; + } - int hper = (plr[pnum]._pDexterity >> 1) + plr[pnum]._pLevel + 50 - (monster[m].mArmorClass - plr[pnum]._pIEnAc); - if (plr[pnum]._pClass == PC_WARRIOR) { - hper += 20; - } - hper += plr[pnum]._pIBonusToHit; - if (hper < 5) { - hper = 5; - } - if (hper > 95) { - hper = 95; - } + int hper = (plr[pnum]._pDexterity >> 1) + plr[pnum]._pLevel + 50 - (monster[m].mArmorClass - plr[pnum]._pIEnAc); + if (plr[pnum]._pClass == PC_WARRIOR) { + hper += 20; + } + hper += plr[pnum]._pIBonusToHit; + if (hper < 5) { + hper = 5; + } + if (hper > 95) { + hper = 95; + } - BOOL ret; - if (CheckMonsterHit(m, &ret)) { - return ret; - } + BOOL ret; + if (CheckMonsterHit(m, &ret)) { + return ret; + } #ifdef _DEBUG - if (hit < hper || debug_mode_key_inverted_v || debug_mode_dollar_sign) { + if (hit < hper || debug_mode_key_inverted_v || debug_mode_dollar_sign) { #else - if (hit < hper) { + if (hit < hper) { #endif - int mind = plr[pnum]._pIMinDam; - int maxd = random(5, plr[pnum]._pIMaxDam - mind + 1); - int dam = maxd + mind; - dam += plr[pnum]._pDamageMod + plr[pnum]._pIBonusDamMod + dam * plr[pnum]._pIBonusDam / 100; - if (plr[pnum]._pClass == PC_WARRIOR) { - int lvl = plr[pnum]._pLevel; - if (random(6, 100) < lvl) { - dam *= 2; - } - } + int mind = plr[pnum]._pIMinDam; + int maxd = random(5, plr[pnum]._pIMaxDam - mind + 1); + int dam = maxd + mind; + dam += plr[pnum]._pDamageMod + plr[pnum]._pIBonusDamMod + dam * plr[pnum]._pIBonusDam / 100; + if (plr[pnum]._pClass == PC_WARRIOR) { + int lvl = plr[pnum]._pLevel; + if (random(6, 100) < lvl) { + dam *= 2; + } + } - int phanditype = ITYPE_NONE; - if (plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_SWORD || plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype == ITYPE_SWORD) { - phanditype = ITYPE_SWORD; - } - if (plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_MACE || plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype == ITYPE_MACE) { - phanditype = ITYPE_MACE; - } + int phanditype = ITYPE_NONE; + if (plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_SWORD || plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype == ITYPE_SWORD) { + phanditype = ITYPE_SWORD; + } + if (plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_MACE || plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype == ITYPE_MACE) { + phanditype = ITYPE_MACE; + } - int mClass = monster[m].MData->mMonstClass; - switch (mClass) { - case MC_UNDEAD: - if (phanditype == ITYPE_SWORD) { - dam -= dam >> 1; - } - if (phanditype == ITYPE_MACE) { - dam += dam >> 1; - } - break; - case MC_ANIMAL: - if (phanditype == ITYPE_MACE) { - dam -= dam >> 1; - } - if (phanditype == ITYPE_SWORD) { - dam += dam >> 1; - } - break; - } + int mClass = monster[m].MData->mMonstClass; + switch (mClass) { + case MC_UNDEAD: + if (phanditype == ITYPE_SWORD) { + dam -= dam >> 1; + } + if (phanditype == ITYPE_MACE) { + dam += dam >> 1; + } + break; + case MC_ANIMAL: + if (phanditype == ITYPE_MACE) { + dam -= dam >> 1; + } + if (phanditype == ITYPE_SWORD) { + dam += dam >> 1; + } + break; + } - if (plr[pnum]._pIFlags & ISPL_3XDAMVDEM && monster[m].MData->mMonstClass == MC_DEMON) { - dam *= 3; - } + if (plr[pnum]._pIFlags & ISPL_3XDAMVDEM && monster[m].MData->mMonstClass == MC_DEMON) { + dam *= 3; + } - int skdam = dam << 6; - if (pnum == myplr) { - monster[m]._mhitpoints -= skdam; - } + int skdam = dam << 6; + if (pnum == myplr) { + monster[m]._mhitpoints -= skdam; + } - int tac; - if (plr[pnum]._pIFlags & ISPL_RNDSTEALLIFE) { - tac = random(7, skdam >> 3); - plr[pnum]._pHitPoints += tac; - if (plr[pnum]._pHitPoints > plr[pnum]._pMaxHP) { - plr[pnum]._pHitPoints = plr[pnum]._pMaxHP; - } - plr[pnum]._pHPBase += tac; - if (plr[pnum]._pHPBase > plr[pnum]._pMaxHPBase) { - plr[pnum]._pHPBase = plr[pnum]._pMaxHPBase; - } - drawhpflag = TRUE; - } - if (plr[pnum]._pIFlags & (ISPL_STEALMANA_3 | ISPL_STEALMANA_5) && !(plr[pnum]._pIFlags & ISPL_NOMANA)) { - if (plr[pnum]._pIFlags & ISPL_STEALMANA_3) { - tac = 3 * skdam / 100; - } - if (plr[pnum]._pIFlags & ISPL_STEALMANA_5) { - tac = 5 * skdam / 100; - } - plr[pnum]._pMana += tac; - if (plr[pnum]._pMana > plr[pnum]._pMaxMana) { - plr[pnum]._pMana = plr[pnum]._pMaxMana; - } - plr[pnum]._pManaBase += tac; - if (plr[pnum]._pManaBase > plr[pnum]._pMaxManaBase) { - plr[pnum]._pManaBase = plr[pnum]._pMaxManaBase; - } - drawmanaflag = TRUE; - } - if (plr[pnum]._pIFlags & (ISPL_STEALLIFE_3 | ISPL_STEALLIFE_5)) { - if (plr[pnum]._pIFlags & ISPL_STEALLIFE_3) { - tac = 3 * skdam / 100; - } - if (plr[pnum]._pIFlags & ISPL_STEALLIFE_5) { - tac = 5 * skdam / 100; - } - plr[pnum]._pHitPoints += tac; - if (plr[pnum]._pHitPoints > plr[pnum]._pMaxHP) { - plr[pnum]._pHitPoints = plr[pnum]._pMaxHP; - } - plr[pnum]._pHPBase += tac; - if (plr[pnum]._pHPBase > plr[pnum]._pMaxHPBase) { - plr[pnum]._pHPBase = plr[pnum]._pMaxHPBase; - } - drawhpflag = TRUE; - } - if (plr[pnum]._pIFlags & ISPL_NOHEALPLR) { - monster[m]._mFlags |= 8; - } + int tac; + if (plr[pnum]._pIFlags & ISPL_RNDSTEALLIFE) { + tac = random(7, skdam >> 3); + plr[pnum]._pHitPoints += tac; + if (plr[pnum]._pHitPoints > plr[pnum]._pMaxHP) { + plr[pnum]._pHitPoints = plr[pnum]._pMaxHP; + } + plr[pnum]._pHPBase += tac; + if (plr[pnum]._pHPBase > plr[pnum]._pMaxHPBase) { + plr[pnum]._pHPBase = plr[pnum]._pMaxHPBase; + } + drawhpflag = TRUE; + } + if (plr[pnum]._pIFlags & (ISPL_STEALMANA_3 | ISPL_STEALMANA_5) && !(plr[pnum]._pIFlags & ISPL_NOMANA)) { + if (plr[pnum]._pIFlags & ISPL_STEALMANA_3) { + tac = 3 * skdam / 100; + } + if (plr[pnum]._pIFlags & ISPL_STEALMANA_5) { + tac = 5 * skdam / 100; + } + plr[pnum]._pMana += tac; + if (plr[pnum]._pMana > plr[pnum]._pMaxMana) { + plr[pnum]._pMana = plr[pnum]._pMaxMana; + } + plr[pnum]._pManaBase += tac; + if (plr[pnum]._pManaBase > plr[pnum]._pMaxManaBase) { + plr[pnum]._pManaBase = plr[pnum]._pMaxManaBase; + } + drawmanaflag = TRUE; + } + if (plr[pnum]._pIFlags & (ISPL_STEALLIFE_3 | ISPL_STEALLIFE_5)) { + if (plr[pnum]._pIFlags & ISPL_STEALLIFE_3) { + tac = 3 * skdam / 100; + } + if (plr[pnum]._pIFlags & ISPL_STEALLIFE_5) { + tac = 5 * skdam / 100; + } + plr[pnum]._pHitPoints += tac; + if (plr[pnum]._pHitPoints > plr[pnum]._pMaxHP) { + plr[pnum]._pHitPoints = plr[pnum]._pMaxHP; + } + plr[pnum]._pHPBase += tac; + if (plr[pnum]._pHPBase > plr[pnum]._pMaxHPBase) { + plr[pnum]._pHPBase = plr[pnum]._pMaxHPBase; + } + drawhpflag = TRUE; + } + if (plr[pnum]._pIFlags & ISPL_NOHEALPLR) { + monster[m]._mFlags |= 8; + } #ifdef _DEBUG - if (debug_mode_dollar_sign || debug_mode_key_inverted_v) { - monster[m]._mhitpoints = 0; /* double check */ - } + if (debug_mode_dollar_sign || debug_mode_key_inverted_v) { + monster[m]._mhitpoints = 0; /* double check */ + } #endif - if ((monster[m]._mhitpoints >> 6) <= 0) { - if (monster[m]._mmode == MM_STONE) { - M_StartKill(m, pnum); - monster[m]._mmode = MM_STONE; - } else { - M_StartKill(m, pnum); - } - } else { - if (monster[m]._mmode == MM_STONE) { - M_StartHit(m, pnum, skdam); - monster[m]._mmode = MM_STONE; - } else { - if (plr[pnum]._pIFlags & ISPL_KNOCKBACK) { - M_GetKnockback(m); - } - M_StartHit(m, pnum, skdam); - } - } - rv = TRUE; - } + if ((monster[m]._mhitpoints >> 6) <= 0) { + if (monster[m]._mmode == MM_STONE) { + M_StartKill(m, pnum); + monster[m]._mmode = MM_STONE; + } else { + M_StartKill(m, pnum); + } + } else { + if (monster[m]._mmode == MM_STONE) { + M_StartHit(m, pnum, skdam); + monster[m]._mmode = MM_STONE; + } else { + if (plr[pnum]._pIFlags & ISPL_KNOCKBACK) { + M_GetKnockback(m); + } + M_StartHit(m, pnum, skdam); + } + } + rv = TRUE; + } - return rv; + return rv; } BOOL __fastcall PlrHitPlr(int pnum, char p) { - if ((DWORD)p >= MAX_PLRS) { - TermMsg("PlrHitPlr: illegal target player %d", p); - } + if ((DWORD)p >= MAX_PLRS) { + TermMsg("PlrHitPlr: illegal target player %d", p); + } - BOOL rv = FALSE; + BOOL rv = FALSE; - if (plr[p]._pInvincible) { - return rv; - } + if (plr[p]._pInvincible) { + return rv; + } - if (plr[p]._pSpellFlags & 1) { - return rv; - } + if (plr[p]._pSpellFlags & 1) { + return rv; + } - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("PlrHitPlr: illegal attacking player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("PlrHitPlr: illegal attacking player %d", pnum); + } - int hit = random(4, 100); + int hit = random(4, 100); - int hper = (plr[pnum]._pDexterity >> 1) + plr[pnum]._pLevel + 50 - (plr[p]._pIBonusAC + plr[p]._pIAC + plr[p]._pDexterity / 5); + int hper = (plr[pnum]._pDexterity >> 1) + plr[pnum]._pLevel + 50 - (plr[p]._pIBonusAC + plr[p]._pIAC + plr[p]._pDexterity / 5); - if (plr[pnum]._pClass == PC_WARRIOR) { - hper += 20; - } - hper += plr[pnum]._pIBonusToHit; - if (hper < 5) { - hper = 5; - } - if (hper > 95) { - hper = 95; - } + if (plr[pnum]._pClass == PC_WARRIOR) { + hper += 20; + } + hper += plr[pnum]._pIBonusToHit; + if (hper < 5) { + hper = 5; + } + if (hper > 95) { + hper = 95; + } - int blk; - if ((plr[p]._pmode == PM_STAND || plr[p]._pmode == PM_ATTACK) && plr[p]._pBlockFlag) { - blk = random(5, 100); - } else { - blk = 100; - } + int blk; + if ((plr[p]._pmode == PM_STAND || plr[p]._pmode == PM_ATTACK) && plr[p]._pBlockFlag) { + blk = random(5, 100); + } else { + blk = 100; + } - int blkper = plr[p]._pDexterity + plr[p]._pBaseToBlk + (plr[p]._pLevel << 1) - (plr[pnum]._pLevel << 1); - if (blkper < 0) { - blkper = 0; - } - if (blkper > 100) { - blkper = 100; - } + int blkper = plr[p]._pDexterity + plr[p]._pBaseToBlk + (plr[p]._pLevel << 1) - (plr[pnum]._pLevel << 1); + if (blkper < 0) { + blkper = 0; + } + if (blkper > 100) { + blkper = 100; + } - if (hit < hper) { - if (blk < blkper) { - int dir = GetDirection(plr[p].WorldX, plr[p].WorldY, plr[pnum].WorldX, plr[pnum].WorldY); - StartPlrBlock(p, dir); - } else { - int mind = plr[pnum]._pIMinDam; - int maxd = random(5, plr[pnum]._pIMaxDam - mind + 1); - int dam = maxd + mind; - dam += plr[pnum]._pDamageMod + plr[pnum]._pIBonusDamMod + dam * plr[pnum]._pIBonusDam / 100; + if (hit < hper) { + if (blk < blkper) { + int dir = GetDirection(plr[p].WorldX, plr[p].WorldY, plr[pnum].WorldX, plr[pnum].WorldY); + StartPlrBlock(p, dir); + } else { + int mind = plr[pnum]._pIMinDam; + int maxd = random(5, plr[pnum]._pIMaxDam - mind + 1); + int dam = maxd + mind; + dam += plr[pnum]._pDamageMod + plr[pnum]._pIBonusDamMod + dam * plr[pnum]._pIBonusDam / 100; - if (plr[pnum]._pClass == PC_WARRIOR) { - int lvl = plr[pnum]._pLevel; - if (random(6, 100) < lvl) { - dam *= 2; - } - } - int skdam = dam << 6; - if (plr[pnum]._pIFlags & ISPL_RNDSTEALLIFE) { - int tac = random(7, skdam >> 3); - plr[pnum]._pHitPoints += tac; - if (plr[pnum]._pHitPoints > plr[pnum]._pMaxHP) { - plr[pnum]._pHitPoints = plr[pnum]._pMaxHP; - } - plr[pnum]._pHPBase += tac; - if (plr[pnum]._pHPBase > plr[pnum]._pMaxHPBase) { - plr[pnum]._pHPBase = plr[pnum]._pMaxHPBase; - } - drawhpflag = TRUE; - } - if (pnum == myplr) { - NetSendCmdDamage(TRUE, p, skdam); - } - StartPlrHit(p, skdam, FALSE); - } + if (plr[pnum]._pClass == PC_WARRIOR) { + int lvl = plr[pnum]._pLevel; + if (random(6, 100) < lvl) { + dam *= 2; + } + } + int skdam = dam << 6; + if (plr[pnum]._pIFlags & ISPL_RNDSTEALLIFE) { + int tac = random(7, skdam >> 3); + plr[pnum]._pHitPoints += tac; + if (plr[pnum]._pHitPoints > plr[pnum]._pMaxHP) { + plr[pnum]._pHitPoints = plr[pnum]._pMaxHP; + } + plr[pnum]._pHPBase += tac; + if (plr[pnum]._pHPBase > plr[pnum]._pMaxHPBase) { + plr[pnum]._pHPBase = plr[pnum]._pMaxHPBase; + } + drawhpflag = TRUE; + } + if (pnum == myplr) { + NetSendCmdDamage(TRUE, p, skdam); + } + StartPlrHit(p, skdam, FALSE); + } - rv = TRUE; - } + rv = TRUE; + } - return rv; + return rv; } BOOL __fastcall PlrHitObj(int pnum, int mx, int my) { - int oi; + int oi; - if (dObject[mx][my] > 0) { - oi = dObject[mx][my] - 1; - } else { - oi = -dObject[mx][my] - 1; - } + if (dObject[mx][my] > 0) { + oi = dObject[mx][my] - 1; + } else { + oi = -dObject[mx][my] - 1; + } - if (object[oi]._oBreak == 1) { - BreakObject(pnum, oi); - return TRUE; - } + if (object[oi]._oBreak == 1) { + BreakObject(pnum, oi); + return TRUE; + } - return FALSE; + return FALSE; } BOOL __fastcall PM_DoAttack(int pnum) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("PM_DoAttack: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("PM_DoAttack: illegal player %d", pnum); + } - int frame = plr[pnum]._pAnimFrame; - if (plr[pnum]._pIFlags & ISPL_QUICKATTACK && frame == 1) { - plr[pnum]._pAnimFrame++; - } - if (plr[pnum]._pIFlags & ISPL_FASTATTACK && (frame == 1 || frame == 3)) { - plr[pnum]._pAnimFrame++; - } - if (plr[pnum]._pIFlags & ISPL_FASTERATTACK && (frame == 1 || frame == 3 || frame == 5)) { - plr[pnum]._pAnimFrame++; - } - if (plr[pnum]._pIFlags & ISPL_FASTESTATTACK && (frame == 1 || frame == 4)) { - plr[pnum]._pAnimFrame += 2; - } - if (plr[pnum]._pAnimFrame == plr[pnum]._pAFNum - 1) { - PlaySfxLoc(PS_SWING, plr[pnum].WorldX, plr[pnum].WorldY); - } + int frame = plr[pnum]._pAnimFrame; + if (plr[pnum]._pIFlags & ISPL_QUICKATTACK && frame == 1) { + plr[pnum]._pAnimFrame++; + } + if (plr[pnum]._pIFlags & ISPL_FASTATTACK && (frame == 1 || frame == 3)) { + plr[pnum]._pAnimFrame++; + } + if (plr[pnum]._pIFlags & ISPL_FASTERATTACK && (frame == 1 || frame == 3 || frame == 5)) { + plr[pnum]._pAnimFrame++; + } + if (plr[pnum]._pIFlags & ISPL_FASTESTATTACK && (frame == 1 || frame == 4)) { + plr[pnum]._pAnimFrame += 2; + } + if (plr[pnum]._pAnimFrame == plr[pnum]._pAFNum - 1) { + PlaySfxLoc(PS_SWING, plr[pnum].WorldX, plr[pnum].WorldY); + } - if (plr[pnum]._pAnimFrame == plr[pnum]._pAFNum) { - int dir = plr[pnum]._pdir; - int dx = plr[pnum].WorldX + offset_x[dir]; - int dy = plr[pnum].WorldY + offset_y[dir]; + if (plr[pnum]._pAnimFrame == plr[pnum]._pAFNum) { + int dir = plr[pnum]._pdir; + int dx = plr[pnum].WorldX + offset_x[dir]; + int dy = plr[pnum].WorldY + offset_y[dir]; - int m; - if (dMonster[dx][dy]) { - if (dMonster[dx][dy] > 0) { - m = dMonster[dx][dy] - 1; - } else { - m = -(dMonster[dx][dy] + 1); - } - if (CanTalkToMonst(m)) { - plr[pnum]._pVar1 = 0; - return FALSE; - } - } + int m; + if (dMonster[dx][dy]) { + if (dMonster[dx][dy] > 0) { + m = dMonster[dx][dy] - 1; + } else { + m = -(dMonster[dx][dy] + 1); + } + if (CanTalkToMonst(m)) { + plr[pnum]._pVar1 = 0; + return FALSE; + } + } - if (plr[pnum]._pIFlags & ISPL_FIREDAM) { - AddMissile(dx, dy, 1, 0, 0, MIS_WEAPEXP, 0, pnum, 0, 0); - } - if (plr[pnum]._pIFlags & ISPL_LIGHTDAM) { - AddMissile(dx, dy, 2, 0, 0, MIS_WEAPEXP, 0, pnum, 0, 0); - } + if (plr[pnum]._pIFlags & ISPL_FIREDAM) { + AddMissile(dx, dy, 1, 0, 0, MIS_WEAPEXP, 0, pnum, 0, 0); + } + if (plr[pnum]._pIFlags & ISPL_LIGHTDAM) { + AddMissile(dx, dy, 2, 0, 0, MIS_WEAPEXP, 0, pnum, 0, 0); + } - BOOL didhit = FALSE; - if (dMonster[dx][dy]) { - m = dMonster[dx][dy]; - if (dMonster[dx][dy] > 0) { - m = dMonster[dx][dy] - 1; - } else { - m = -(dMonster[dx][dy] + 1); - } - didhit = PlrHitMonst(pnum, m); - } else if (dPlayer[dx][dy] && !FriendlyMode) { - UCHAR p = dPlayer[dx][dy]; - if (dPlayer[dx][dy] > 0) { - p = dPlayer[dx][dy] - 1; - } else { - p = -(dPlayer[dx][dy] + 1); - } - didhit = PlrHitPlr(pnum, p); - } else if (dObject[dx][dy] > 0) { - didhit = PlrHitObj(pnum, dx, dy); - } + BOOL didhit = FALSE; + if (dMonster[dx][dy]) { + m = dMonster[dx][dy]; + if (dMonster[dx][dy] > 0) { + m = dMonster[dx][dy] - 1; + } else { + m = -(dMonster[dx][dy] + 1); + } + didhit = PlrHitMonst(pnum, m); + } else if (dPlayer[dx][dy] && !FriendlyMode) { + UCHAR p = dPlayer[dx][dy]; + if (dPlayer[dx][dy] > 0) { + p = dPlayer[dx][dy] - 1; + } else { + p = -(dPlayer[dx][dy] + 1); + } + didhit = PlrHitPlr(pnum, p); + } else if (dObject[dx][dy] > 0) { + didhit = PlrHitObj(pnum, dx, dy); + } - if (didhit && WeaponDur(pnum, 30)) { - StartStand(pnum, plr[pnum]._pdir); - ClearPlrPVars(pnum); - return TRUE; - } - } + if (didhit && WeaponDur(pnum, 30)) { + StartStand(pnum, plr[pnum]._pdir); + ClearPlrPVars(pnum); + return TRUE; + } + } - if (plr[pnum]._pAnimFrame == plr[pnum]._pAFrames) { - StartStand(pnum, plr[pnum]._pdir); - ClearPlrPVars(pnum); - return TRUE; - } else { - return FALSE; - } + if (plr[pnum]._pAnimFrame == plr[pnum]._pAFrames) { + StartStand(pnum, plr[pnum]._pdir); + ClearPlrPVars(pnum); + return TRUE; + } else { + return FALSE; + } } BOOL __fastcall PM_DoRangeAttack(int pnum) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("PM_DoRangeAttack: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("PM_DoRangeAttack: illegal player %d", pnum); + } - int origFrame = plr[pnum]._pAnimFrame; - if (plr[pnum]._pIFlags & ISPL_QUICKATTACK && origFrame == 1) { - plr[pnum]._pAnimFrame++; - } - if (plr[pnum]._pIFlags & ISPL_FASTATTACK && (origFrame == 1 || origFrame == 3)) { - plr[pnum]._pAnimFrame++; - } + int origFrame = plr[pnum]._pAnimFrame; + if (plr[pnum]._pIFlags & ISPL_QUICKATTACK && origFrame == 1) { + plr[pnum]._pAnimFrame++; + } + if (plr[pnum]._pIFlags & ISPL_FASTATTACK && (origFrame == 1 || origFrame == 3)) { + plr[pnum]._pAnimFrame++; + } - if (plr[pnum]._pAnimFrame == plr[pnum]._pAFNum) { - int mistype = MIS_ARROW; - if (plr[pnum]._pIFlags & ISPL_FIRE_ARROWS) { - mistype = MIS_FARROW; - } - if (plr[pnum]._pIFlags & ISPL_LIGHT_ARROWS) { - mistype = MIS_LARROW; - } - AddMissile( - plr[pnum].WorldX, - plr[pnum].WorldY, - plr[pnum]._pVar1, - plr[pnum]._pVar2, - plr[pnum]._pdir, - mistype, - 0, - pnum, - 4, - 0); + if (plr[pnum]._pAnimFrame == plr[pnum]._pAFNum) { + int mistype = MIS_ARROW; + if (plr[pnum]._pIFlags & ISPL_FIRE_ARROWS) { + mistype = MIS_FARROW; + } + if (plr[pnum]._pIFlags & ISPL_LIGHT_ARROWS) { + mistype = MIS_LARROW; + } + AddMissile( + plr[pnum].WorldX, + plr[pnum].WorldY, + plr[pnum]._pVar1, + plr[pnum]._pVar2, + plr[pnum]._pdir, + mistype, + 0, + pnum, + 4, + 0); - PlaySfxLoc(PS_BFIRE, plr[pnum].WorldX, plr[pnum].WorldY); + PlaySfxLoc(PS_BFIRE, plr[pnum].WorldX, plr[pnum].WorldY); - if (WeaponDur(pnum, 40)) { - StartStand(pnum, plr[pnum]._pdir); - ClearPlrPVars(pnum); - return TRUE; - } - } + if (WeaponDur(pnum, 40)) { + StartStand(pnum, plr[pnum]._pdir); + ClearPlrPVars(pnum); + return TRUE; + } + } - if (plr[pnum]._pAnimFrame >= plr[pnum]._pAFrames) { - StartStand(pnum, plr[pnum]._pdir); - ClearPlrPVars(pnum); - return TRUE; - } else { - return FALSE; - } + if (plr[pnum]._pAnimFrame >= plr[pnum]._pAFrames) { + StartStand(pnum, plr[pnum]._pdir); + ClearPlrPVars(pnum); + return TRUE; + } else { + return FALSE; + } } void __fastcall ShieldDur(int pnum) { - if (pnum != myplr) { - return; - } + if (pnum != myplr) { + return; + } - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("ShieldDur: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("ShieldDur: illegal player %d", pnum); + } - if (plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_SHIELD) { - if (plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability == DUR_INDESTRUCTIBLE) { - return; - } + if (plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_SHIELD) { + if (plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability == DUR_INDESTRUCTIBLE) { + return; + } - plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability--; - if (plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability == 0) { - NetSendCmdDelItem(TRUE, INVLOC_HAND_LEFT); - plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype = ITYPE_NONE; - CalcPlrInv(pnum, TRUE); - } - } + plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability--; + if (plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability == 0) { + NetSendCmdDelItem(TRUE, INVLOC_HAND_LEFT); + plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype = ITYPE_NONE; + CalcPlrInv(pnum, TRUE); + } + } - if (plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype == ITYPE_SHIELD) { - if (plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iDurability != DUR_INDESTRUCTIBLE) { - plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iDurability--; - if (plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iDurability == 0) { - NetSendCmdDelItem(TRUE, INVLOC_HAND_RIGHT); - plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype = ITYPE_NONE; - CalcPlrInv(pnum, TRUE); - } - } - } + if (plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype == ITYPE_SHIELD) { + if (plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iDurability != DUR_INDESTRUCTIBLE) { + plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iDurability--; + if (plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iDurability == 0) { + NetSendCmdDelItem(TRUE, INVLOC_HAND_RIGHT); + plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype = ITYPE_NONE; + CalcPlrInv(pnum, TRUE); + } + } + } } BOOL __fastcall PM_DoBlock(int pnum) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("PM_DoBlock: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("PM_DoBlock: illegal player %d", pnum); + } - if (plr[pnum]._pIFlags & ISPL_FASTBLOCK && plr[pnum]._pAnimFrame != 1) { - plr[pnum]._pAnimFrame = plr[pnum]._pBFrames; - } + if (plr[pnum]._pIFlags & ISPL_FASTBLOCK && plr[pnum]._pAnimFrame != 1) { + plr[pnum]._pAnimFrame = plr[pnum]._pBFrames; + } - if (plr[pnum]._pAnimFrame >= plr[pnum]._pBFrames) { - StartStand(pnum, plr[pnum]._pdir); - ClearPlrPVars(pnum); + if (plr[pnum]._pAnimFrame >= plr[pnum]._pBFrames) { + StartStand(pnum, plr[pnum]._pdir); + ClearPlrPVars(pnum); - if (!random(3, 10)) { - ShieldDur(pnum); - } - return TRUE; - } + if (!random(3, 10)) { + ShieldDur(pnum); + } + return TRUE; + } - return FALSE; + return FALSE; } BOOL __fastcall PM_DoSpell(int pnum) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("PM_DoSpell: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("PM_DoSpell: illegal player %d", pnum); + } - if (plr[pnum]._pVar8 == plr[pnum]._pSFNum) { - CastSpell( - pnum, - plr[pnum]._pSpell, - plr[pnum].WorldX, - plr[pnum].WorldY, - plr[pnum]._pVar1, - plr[pnum]._pVar2, - FALSE, - plr[pnum]._pVar4); + if (plr[pnum]._pVar8 == plr[pnum]._pSFNum) { + CastSpell( + pnum, + plr[pnum]._pSpell, + plr[pnum].WorldX, + plr[pnum].WorldY, + plr[pnum]._pVar1, + plr[pnum]._pVar2, + FALSE, + plr[pnum]._pVar4); - if (!plr[pnum]._pSplFrom) { - if (plr[pnum]._pRSplType == RSPLTYPE_SCROLL) { - if (!(plr[pnum]._pScrlSpells - & (unsigned __int64)1 << (plr[pnum]._pRSpell - 1))) { - plr[pnum]._pRSpell = SPL_INVALID; - plr[pnum]._pRSplType = RSPLTYPE_INVALID; - drawpanflag = 255; - } - } + if (!plr[pnum]._pSplFrom) { + if (plr[pnum]._pRSplType == RSPLTYPE_SCROLL) { + if (!(plr[pnum]._pScrlSpells + & (unsigned __int64)1 << (plr[pnum]._pRSpell - 1))) { + plr[pnum]._pRSpell = SPL_INVALID; + plr[pnum]._pRSplType = RSPLTYPE_INVALID; + drawpanflag = 255; + } + } - if (plr[pnum]._pRSplType == RSPLTYPE_CHARGES) { - if (!(plr[pnum]._pISpells - & (unsigned __int64)1 << (plr[pnum]._pRSpell - 1))) { - plr[pnum]._pRSpell = SPL_INVALID; - plr[pnum]._pRSplType = RSPLTYPE_INVALID; - drawpanflag = 255; - } - } - } - } + if (plr[pnum]._pRSplType == RSPLTYPE_CHARGES) { + if (!(plr[pnum]._pISpells + & (unsigned __int64)1 << (plr[pnum]._pRSpell - 1))) { + plr[pnum]._pRSpell = SPL_INVALID; + plr[pnum]._pRSplType = RSPLTYPE_INVALID; + drawpanflag = 255; + } + } + } + } - plr[pnum]._pVar8++; + plr[pnum]._pVar8++; - if (leveltype == DTYPE_TOWN) { - if (plr[pnum]._pVar8 > plr[pnum]._pSFrames) { - StartWalkStand(pnum); - ClearPlrPVars(pnum); - return TRUE; - } - } else if (plr[pnum]._pAnimFrame == plr[pnum]._pSFrames) { - StartStand(pnum, plr[pnum]._pdir); - ClearPlrPVars(pnum); - return TRUE; - } + if (leveltype == DTYPE_TOWN) { + if (plr[pnum]._pVar8 > plr[pnum]._pSFrames) { + StartWalkStand(pnum); + ClearPlrPVars(pnum); + return TRUE; + } + } else if (plr[pnum]._pAnimFrame == plr[pnum]._pSFrames) { + StartStand(pnum, plr[pnum]._pdir); + ClearPlrPVars(pnum); + return TRUE; + } - return FALSE; + return FALSE; } // 52571C: using guessed type int drawpanflag; BOOL __fastcall PM_DoGotHit(int pnum) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("PM_DoGotHit: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("PM_DoGotHit: illegal player %d", pnum); + } - int frame = plr[pnum]._pAnimFrame; - if (plr[pnum]._pIFlags & ISPL_FASTRECOVER && frame == 3) { - plr[pnum]._pAnimFrame++; - } - if (plr[pnum]._pIFlags & ISPL_FASTERRECOVER && (frame == 3 || frame == 5)) { - plr[pnum]._pAnimFrame++; - } - if (plr[pnum]._pIFlags & ISPL_FASTESTRECOVER && (frame == 1 || frame == 3 || frame == 5)) { - plr[pnum]._pAnimFrame++; - } + int frame = plr[pnum]._pAnimFrame; + if (plr[pnum]._pIFlags & ISPL_FASTRECOVER && frame == 3) { + plr[pnum]._pAnimFrame++; + } + if (plr[pnum]._pIFlags & ISPL_FASTERRECOVER && (frame == 3 || frame == 5)) { + plr[pnum]._pAnimFrame++; + } + if (plr[pnum]._pIFlags & ISPL_FASTESTRECOVER && (frame == 1 || frame == 3 || frame == 5)) { + plr[pnum]._pAnimFrame++; + } - if (plr[pnum]._pAnimFrame >= plr[pnum]._pHFrames) { - StartStand(pnum, plr[pnum]._pdir); - ClearPlrPVars(pnum); - if (random(3, 4)) { - ArmorDur(pnum); - } + if (plr[pnum]._pAnimFrame >= plr[pnum]._pHFrames) { + StartStand(pnum, plr[pnum]._pdir); + ClearPlrPVars(pnum); + if (random(3, 4)) { + ArmorDur(pnum); + } - return TRUE; - } + return TRUE; + } - return FALSE; + return FALSE; } void __fastcall ArmorDur(int pnum) { - if (pnum != myplr) { - return; - } + if (pnum != myplr) { + return; + } - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("ArmorDur: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("ArmorDur: illegal player %d", pnum); + } - PlayerStruct *p = &plr[pnum]; - if (p->InvBody[INVLOC_CHEST]._itype == ITYPE_NONE && p->InvBody[INVLOC_HEAD]._itype == ITYPE_NONE) { - return; - } + PlayerStruct *p = &plr[pnum]; + if (p->InvBody[INVLOC_CHEST]._itype == ITYPE_NONE && p->InvBody[INVLOC_HEAD]._itype == ITYPE_NONE) { + return; + } - int a = random(8, 3); - if (p->InvBody[INVLOC_CHEST]._itype != ITYPE_NONE && p->InvBody[INVLOC_HEAD]._itype == ITYPE_NONE) { - a = 1; - } - if (p->InvBody[INVLOC_CHEST]._itype == ITYPE_NONE && p->InvBody[INVLOC_HEAD]._itype != ITYPE_NONE) { - a = 0; - } + int a = random(8, 3); + if (p->InvBody[INVLOC_CHEST]._itype != ITYPE_NONE && p->InvBody[INVLOC_HEAD]._itype == ITYPE_NONE) { + a = 1; + } + if (p->InvBody[INVLOC_CHEST]._itype == ITYPE_NONE && p->InvBody[INVLOC_HEAD]._itype != ITYPE_NONE) { + a = 0; + } - ItemStruct *pi; - if (a != 0) { - pi = &p->InvBody[INVLOC_CHEST]; - } else { - pi = &p->InvBody[INVLOC_HEAD]; - } - if (pi->_iDurability == DUR_INDESTRUCTIBLE) { - return; - } + ItemStruct *pi; + if (a != 0) { + pi = &p->InvBody[INVLOC_CHEST]; + } else { + pi = &p->InvBody[INVLOC_HEAD]; + } + if (pi->_iDurability == DUR_INDESTRUCTIBLE) { + return; + } - pi->_iDurability--; - if (pi->_iDurability != 0) { - return; - } + pi->_iDurability--; + if (pi->_iDurability != 0) { + return; + } - if (a != 0) { - NetSendCmdDelItem(TRUE, INVLOC_CHEST); - } else { - NetSendCmdDelItem(TRUE, INVLOC_HEAD); - } - pi->_itype = ITYPE_NONE; - CalcPlrInv(pnum, TRUE); + if (a != 0) { + NetSendCmdDelItem(TRUE, INVLOC_CHEST); + } else { + NetSendCmdDelItem(TRUE, INVLOC_HEAD); + } + pi->_itype = ITYPE_NONE; + CalcPlrInv(pnum, TRUE); } BOOL __fastcall PM_DoDeath(int pnum) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("PM_DoDeath: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("PM_DoDeath: illegal player %d", pnum); + } - if (plr[pnum]._pVar8 >= 2 * plr[pnum]._pDFrames) { - if (deathdelay > 1 && pnum == myplr) { - deathdelay--; - if (deathdelay) { - deathflag = TRUE; - if (gbMaxPlayers == 1) { - gamemenu_previous(); - } - } - } + if (plr[pnum]._pVar8 >= 2 * plr[pnum]._pDFrames) { + if (deathdelay > 1 && pnum == myplr) { + deathdelay--; + if (deathdelay) { + deathflag = TRUE; + if (gbMaxPlayers == 1) { + gamemenu_previous(); + } + } + } - plr[pnum]._pAnimFrame = plr[pnum]._pAnimLen; - plr[pnum]._pAnimDelay = 10000; - dFlags[plr[pnum].WorldX][plr[pnum].WorldY] |= DFLAG_DEAD_PLAYER; - } + plr[pnum]._pAnimFrame = plr[pnum]._pAnimLen; + plr[pnum]._pAnimDelay = 10000; + dFlags[plr[pnum].WorldX][plr[pnum].WorldY] |= DFLAG_DEAD_PLAYER; + } - if (plr[pnum]._pVar8 < 100) { - plr[pnum]._pVar8++; - } + if (plr[pnum]._pVar8 < 100) { + plr[pnum]._pVar8++; + } - return FALSE; + return FALSE; } // 69B7C4: using guessed type int deathdelay; BOOL __fastcall PM_DoNewLvl(int pnum) { - return FALSE; + return FALSE; } void __fastcall CheckNewPath(int pnum) { - int i; - int x; - int y; - int d; - int xvel3; - int xvel; - int yvel; + int i; + int x; + int y; + int d; + int xvel3; + int xvel; + int yvel; - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("CheckNewPath: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("CheckNewPath: illegal player %d", pnum); + } - if (plr[pnum].destAction == ACTION_ATTACKMON) { - MakePlrPath(pnum, monster[plr[pnum].destParam1]._mfutx, monster[plr[pnum].destParam1]._mfuty, FALSE); - } + if (plr[pnum].destAction == ACTION_ATTACKMON) { + MakePlrPath(pnum, monster[plr[pnum].destParam1]._mfutx, monster[plr[pnum].destParam1]._mfuty, FALSE); + } - if (plr[pnum].destAction == ACTION_ATTACKPLR) { - MakePlrPath(pnum, plr[plr[pnum].destParam1]._px, plr[plr[pnum].destParam1]._py, FALSE); - } + if (plr[pnum].destAction == ACTION_ATTACKPLR) { + MakePlrPath(pnum, plr[plr[pnum].destParam1]._px, plr[plr[pnum].destParam1]._py, FALSE); + } - if (plr[pnum].walkpath[0] != WALK_NONE) { - if (plr[pnum]._pmode == PM_STAND) { - if (pnum == myplr) { - if (plr[pnum].destAction == ACTION_ATTACKMON || plr[pnum].destAction == ACTION_ATTACKPLR) { - i = plr[pnum].destParam1; + if (plr[pnum].walkpath[0] != WALK_NONE) { + if (plr[pnum]._pmode == PM_STAND) { + if (pnum == myplr) { + if (plr[pnum].destAction == ACTION_ATTACKMON || plr[pnum].destAction == ACTION_ATTACKPLR) { + i = plr[pnum].destParam1; - if (plr[pnum].destAction == ACTION_ATTACKMON) { - x = abs(plr[pnum]._px - monster[i]._mfutx); - y = abs(plr[pnum]._py - monster[i]._mfuty); - d = GetDirection(plr[pnum]._px, plr[pnum]._py, monster[i]._mfutx, monster[i]._mfuty); - } else { - x = abs(plr[pnum]._px - plr[i]._px); - y = abs(plr[pnum]._py - plr[i]._py); - d = GetDirection(plr[pnum]._px, plr[pnum]._py, plr[i]._px, plr[i]._py); - } + if (plr[pnum].destAction == ACTION_ATTACKMON) { + x = abs(plr[pnum]._px - monster[i]._mfutx); + y = abs(plr[pnum]._py - monster[i]._mfuty); + d = GetDirection(plr[pnum]._px, plr[pnum]._py, monster[i]._mfutx, monster[i]._mfuty); + } else { + x = abs(plr[pnum]._px - plr[i]._px); + y = abs(plr[pnum]._py - plr[i]._py); + d = GetDirection(plr[pnum]._px, plr[pnum]._py, plr[i]._px, plr[i]._py); + } - if (x < 2 && y < 2) { - ClrPlrPath(pnum); - if (monster[i].mtalkmsg && monster[i].mtalkmsg != QUEST_VILE14) { - TalktoMonster(i); - } else { - StartAttack(pnum, d); - } - plr[pnum].destAction = ACTION_NONE; - } - } - } + if (x < 2 && y < 2) { + ClrPlrPath(pnum); + if (monster[i].mtalkmsg && monster[i].mtalkmsg != QUEST_VILE14) { + TalktoMonster(i); + } else { + StartAttack(pnum, d); + } + plr[pnum].destAction = ACTION_NONE; + } + } + } - if (currlevel != 0) { - xvel3 = PWVel[plr[pnum]._pClass][0]; - xvel = PWVel[plr[pnum]._pClass][1]; - yvel = PWVel[plr[pnum]._pClass][2]; - } else { - xvel3 = 2048; - xvel = 1024; - yvel = 512; - } + if (currlevel != 0) { + xvel3 = PWVel[plr[pnum]._pClass][0]; + xvel = PWVel[plr[pnum]._pClass][1]; + yvel = PWVel[plr[pnum]._pClass][2]; + } else { + xvel3 = 2048; + xvel = 1024; + yvel = 512; + } - switch (plr[pnum].walkpath[0]) { - case WALK_N: - StartWalk(pnum, 0, -xvel, -1, -1, DIR_N, SDIR_N); - break; - case WALK_NE: - StartWalk(pnum, xvel, -yvel, 0, -1, DIR_NE, SDIR_NE); - break; - case WALK_E: - StartWalk3(pnum, xvel3, 0, -32, -16, 1, -1, 1, 0, DIR_E, SDIR_E); - break; - case WALK_SE: - StartWalk2(pnum, xvel, yvel, -32, -16, 1, 0, DIR_SE, SDIR_SE); - break; - case WALK_S: - StartWalk2(pnum, 0, xvel, 0, -32, 1, 1, DIR_S, SDIR_S); - break; - case WALK_SW: - StartWalk2(pnum, -xvel, yvel, 32, -16, 0, 1, DIR_SW, SDIR_SW); - break; - case WALK_W: - StartWalk3(pnum, -xvel3, 0, 32, -16, -1, 1, 0, 1, DIR_W, SDIR_W); - break; - case WALK_NW: - StartWalk(pnum, -xvel, -yvel, -1, 0, DIR_NW, SDIR_NW); - break; - } + switch (plr[pnum].walkpath[0]) { + case WALK_N: + StartWalk(pnum, 0, -xvel, -1, -1, DIR_N, SDIR_N); + break; + case WALK_NE: + StartWalk(pnum, xvel, -yvel, 0, -1, DIR_NE, SDIR_NE); + break; + case WALK_E: + StartWalk3(pnum, xvel3, 0, -32, -16, 1, -1, 1, 0, DIR_E, SDIR_E); + break; + case WALK_SE: + StartWalk2(pnum, xvel, yvel, -32, -16, 1, 0, DIR_SE, SDIR_SE); + break; + case WALK_S: + StartWalk2(pnum, 0, xvel, 0, -32, 1, 1, DIR_S, SDIR_S); + break; + case WALK_SW: + StartWalk2(pnum, -xvel, yvel, 32, -16, 0, 1, DIR_SW, SDIR_SW); + break; + case WALK_W: + StartWalk3(pnum, -xvel3, 0, 32, -16, -1, 1, 0, 1, DIR_W, SDIR_W); + break; + case WALK_NW: + StartWalk(pnum, -xvel, -yvel, -1, 0, DIR_NW, SDIR_NW); + break; + } - for (i = 1; i < 25; i++) { - plr[pnum].walkpath[i - 1] = plr[pnum].walkpath[i]; - } + for (i = 1; i < 25; i++) { + plr[pnum].walkpath[i - 1] = plr[pnum].walkpath[i]; + } - plr[pnum].walkpath[24] = WALK_NONE; + plr[pnum].walkpath[24] = WALK_NONE; - if (plr[pnum]._pmode == PM_STAND) { - StartStand(pnum, plr[pnum]._pdir); - plr[pnum].destAction = ACTION_NONE; - } - } + if (plr[pnum]._pmode == PM_STAND) { + StartStand(pnum, plr[pnum]._pdir); + plr[pnum].destAction = ACTION_NONE; + } + } - return; - } - if (plr[pnum].destAction == ACTION_NONE) { - return; - } + return; + } + if (plr[pnum].destAction == ACTION_NONE) { + return; + } - if (plr[pnum]._pmode == PM_STAND) { - switch (plr[pnum].destAction) { - case ACTION_ATTACK: - d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, plr[pnum].destParam1, plr[pnum].destParam2); - StartAttack(pnum, d); - break; - case ACTION_ATTACKMON: - i = plr[pnum].destParam1; - x = abs(plr[pnum].WorldX - monster[i]._mfutx); - y = abs(plr[pnum].WorldY - monster[i]._mfuty); - if (x <= 1 && y <= 1) { - d = GetDirection(plr[pnum]._px, plr[pnum]._py, monster[i]._mfutx, monster[i]._mfuty); - if (monster[i].mtalkmsg && monster[i].mtalkmsg != QUEST_VILE14) { - TalktoMonster(i); - } else { - StartAttack(pnum, d); - } - } - break; - case ACTION_ATTACKPLR: - i = plr[pnum].destParam1; - x = abs(plr[pnum].WorldX - plr[i]._px); - y = abs(plr[pnum].WorldY - plr[i]._py); - if (x <= 1 && y <= 1) { - d = GetDirection(plr[pnum]._px, plr[pnum]._py, plr[i]._px, plr[i]._py); - StartAttack(pnum, d); - } - break; - case ACTION_RATTACK: - d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, plr[pnum].destParam1, plr[pnum].destParam2); - StartRangeAttack(pnum, d, plr[pnum].destParam1, plr[pnum].destParam2); - break; - case ACTION_RATTACKMON: - i = plr[pnum].destParam1; - d = GetDirection(plr[pnum]._px, plr[pnum]._py, monster[i]._mfutx, monster[i]._mfuty); - if (monster[i].mtalkmsg && monster[i].mtalkmsg != QUEST_VILE14) { - TalktoMonster(i); - } else { - StartRangeAttack(pnum, d, monster[i]._mfutx, monster[i]._mfuty); - } - break; - case ACTION_RATTACKPLR: - i = plr[pnum].destParam1; - d = GetDirection(plr[pnum]._px, plr[pnum]._py, plr[i]._px, plr[i]._py); - StartRangeAttack(pnum, d, plr[i]._px, plr[i]._py); - break; - case ACTION_SPELL: - d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, plr[pnum].destParam1, plr[pnum].destParam2); - StartSpell(pnum, d, plr[pnum].destParam1, plr[pnum].destParam2); - plr[pnum]._pVar4 = plr[pnum].destParam3; - break; - case ACTION_SPELLWALL: - StartSpell(pnum, plr[pnum].destParam3, plr[pnum].destParam1, plr[pnum].destParam2); - plr[pnum]._pVar3 = plr[pnum].destParam3; - plr[pnum]._pVar4 = plr[pnum].destParam4; - break; - case ACTION_SPELLMON: - i = plr[pnum].destParam1; - d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, monster[i]._mfutx, monster[i]._mfuty); - StartSpell(pnum, d, monster[i]._mfutx, monster[i]._mfuty); - plr[pnum]._pVar4 = plr[pnum].destParam2; - break; - case ACTION_SPELLPLR: - i = plr[pnum].destParam1; - d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, plr[i]._px, plr[i]._py); - StartSpell(pnum, d, plr[i]._px, plr[i]._py); - plr[pnum]._pVar4 = plr[pnum].destParam2; - break; - case ACTION_OPERATE: - i = plr[pnum].destParam1; - x = abs(plr[pnum].WorldX - object[i]._ox); - y = abs(plr[pnum].WorldY - object[i]._oy); - if (y > 1 && dObject[object[i]._ox][object[i]._oy - 1] == -1 - i) { - y = abs(plr[pnum].WorldY - object[i]._oy + 1); - } - if (x <= 1 && y <= 1) { - if (object[i]._oBreak == 1) { - d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, object[i]._ox, object[i]._oy); - StartAttack(pnum, d); - } else { - OperateObject(pnum, i, FALSE); - } - } - break; - case ACTION_DISARM: - i = plr[pnum].destParam1; - x = abs(plr[pnum].WorldX - object[i]._ox); - y = abs(plr[pnum].WorldY - object[i]._oy); - if (y > 1 && dObject[object[i]._ox][object[i]._oy - 1] == -1 - i) { - y = abs(plr[pnum].WorldY - object[i]._oy + 1); - } - if (x <= 1 && y <= 1) { - if (object[i]._oBreak == 1) { - d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, object[i]._ox, object[i]._oy); - StartAttack(pnum, d); - } else { - TryDisarm(pnum, i); - OperateObject(pnum, i, FALSE); - } - } - break; - case ACTION_OPERATETK: - i = plr[pnum].destParam1; - if (object[i]._oBreak != 1) { - OperateObject(pnum, i, TRUE); - } - break; - case ACTION_PICKUPITEM: - if (pnum == myplr) { - i = plr[pnum].destParam1; - x = abs(plr[pnum].WorldX - item[i]._ix); - y = abs(plr[pnum].WorldY - item[i]._iy); - if (x <= 1 && y <= 1 && pcurs == 1 && !item[i]._iRequest) { - NetSendCmdGItem(TRUE, CMD_REQUESTGITEM, myplr, myplr, i); - item[i]._iRequest = TRUE; - } - } - break; - case ACTION_PICKUPAITEM: - if (pnum == myplr) { - i = plr[pnum].destParam1; - x = abs(plr[pnum].WorldX - item[i]._ix); - y = abs(plr[pnum].WorldY - item[i]._iy); - if (x <= 1 && y <= 1 && pcurs == 1) { - NetSendCmdGItem(TRUE, CMD_REQUESTAGITEM, myplr, myplr, i); - } - } - break; - case ACTION_TALK: - if (pnum == myplr) { - TalkToTowner(pnum, plr[pnum].destParam1); - } - break; - } + if (plr[pnum]._pmode == PM_STAND) { + switch (plr[pnum].destAction) { + case ACTION_ATTACK: + d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, plr[pnum].destParam1, plr[pnum].destParam2); + StartAttack(pnum, d); + break; + case ACTION_ATTACKMON: + i = plr[pnum].destParam1; + x = abs(plr[pnum].WorldX - monster[i]._mfutx); + y = abs(plr[pnum].WorldY - monster[i]._mfuty); + if (x <= 1 && y <= 1) { + d = GetDirection(plr[pnum]._px, plr[pnum]._py, monster[i]._mfutx, monster[i]._mfuty); + if (monster[i].mtalkmsg && monster[i].mtalkmsg != QUEST_VILE14) { + TalktoMonster(i); + } else { + StartAttack(pnum, d); + } + } + break; + case ACTION_ATTACKPLR: + i = plr[pnum].destParam1; + x = abs(plr[pnum].WorldX - plr[i]._px); + y = abs(plr[pnum].WorldY - plr[i]._py); + if (x <= 1 && y <= 1) { + d = GetDirection(plr[pnum]._px, plr[pnum]._py, plr[i]._px, plr[i]._py); + StartAttack(pnum, d); + } + break; + case ACTION_RATTACK: + d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, plr[pnum].destParam1, plr[pnum].destParam2); + StartRangeAttack(pnum, d, plr[pnum].destParam1, plr[pnum].destParam2); + break; + case ACTION_RATTACKMON: + i = plr[pnum].destParam1; + d = GetDirection(plr[pnum]._px, plr[pnum]._py, monster[i]._mfutx, monster[i]._mfuty); + if (monster[i].mtalkmsg && monster[i].mtalkmsg != QUEST_VILE14) { + TalktoMonster(i); + } else { + StartRangeAttack(pnum, d, monster[i]._mfutx, monster[i]._mfuty); + } + break; + case ACTION_RATTACKPLR: + i = plr[pnum].destParam1; + d = GetDirection(plr[pnum]._px, plr[pnum]._py, plr[i]._px, plr[i]._py); + StartRangeAttack(pnum, d, plr[i]._px, plr[i]._py); + break; + case ACTION_SPELL: + d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, plr[pnum].destParam1, plr[pnum].destParam2); + StartSpell(pnum, d, plr[pnum].destParam1, plr[pnum].destParam2); + plr[pnum]._pVar4 = plr[pnum].destParam3; + break; + case ACTION_SPELLWALL: + StartSpell(pnum, plr[pnum].destParam3, plr[pnum].destParam1, plr[pnum].destParam2); + plr[pnum]._pVar3 = plr[pnum].destParam3; + plr[pnum]._pVar4 = plr[pnum].destParam4; + break; + case ACTION_SPELLMON: + i = plr[pnum].destParam1; + d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, monster[i]._mfutx, monster[i]._mfuty); + StartSpell(pnum, d, monster[i]._mfutx, monster[i]._mfuty); + plr[pnum]._pVar4 = plr[pnum].destParam2; + break; + case ACTION_SPELLPLR: + i = plr[pnum].destParam1; + d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, plr[i]._px, plr[i]._py); + StartSpell(pnum, d, plr[i]._px, plr[i]._py); + plr[pnum]._pVar4 = plr[pnum].destParam2; + break; + case ACTION_OPERATE: + i = plr[pnum].destParam1; + x = abs(plr[pnum].WorldX - object[i]._ox); + y = abs(plr[pnum].WorldY - object[i]._oy); + if (y > 1 && dObject[object[i]._ox][object[i]._oy - 1] == -1 - i) { + y = abs(plr[pnum].WorldY - object[i]._oy + 1); + } + if (x <= 1 && y <= 1) { + if (object[i]._oBreak == 1) { + d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, object[i]._ox, object[i]._oy); + StartAttack(pnum, d); + } else { + OperateObject(pnum, i, FALSE); + } + } + break; + case ACTION_DISARM: + i = plr[pnum].destParam1; + x = abs(plr[pnum].WorldX - object[i]._ox); + y = abs(plr[pnum].WorldY - object[i]._oy); + if (y > 1 && dObject[object[i]._ox][object[i]._oy - 1] == -1 - i) { + y = abs(plr[pnum].WorldY - object[i]._oy + 1); + } + if (x <= 1 && y <= 1) { + if (object[i]._oBreak == 1) { + d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, object[i]._ox, object[i]._oy); + StartAttack(pnum, d); + } else { + TryDisarm(pnum, i); + OperateObject(pnum, i, FALSE); + } + } + break; + case ACTION_OPERATETK: + i = plr[pnum].destParam1; + if (object[i]._oBreak != 1) { + OperateObject(pnum, i, TRUE); + } + break; + case ACTION_PICKUPITEM: + if (pnum == myplr) { + i = plr[pnum].destParam1; + x = abs(plr[pnum].WorldX - item[i]._ix); + y = abs(plr[pnum].WorldY - item[i]._iy); + if (x <= 1 && y <= 1 && pcurs == 1 && !item[i]._iRequest) { + NetSendCmdGItem(TRUE, CMD_REQUESTGITEM, myplr, myplr, i); + item[i]._iRequest = TRUE; + } + } + break; + case ACTION_PICKUPAITEM: + if (pnum == myplr) { + i = plr[pnum].destParam1; + x = abs(plr[pnum].WorldX - item[i]._ix); + y = abs(plr[pnum].WorldY - item[i]._iy); + if (x <= 1 && y <= 1 && pcurs == 1) { + NetSendCmdGItem(TRUE, CMD_REQUESTAGITEM, myplr, myplr, i); + } + } + break; + case ACTION_TALK: + if (pnum == myplr) { + TalkToTowner(pnum, plr[pnum].destParam1); + } + break; + } - FixPlayerLocation(pnum, plr[pnum]._pdir); - plr[pnum].destAction = ACTION_NONE; + FixPlayerLocation(pnum, plr[pnum]._pdir); + plr[pnum].destAction = ACTION_NONE; - return; - } + return; + } - if (plr[pnum]._pmode == PM_ATTACK && plr[pnum]._pAnimFrame > plr[myplr]._pAFNum) { - if (plr[pnum].destAction == ACTION_ATTACK) { - d = GetDirection(plr[pnum]._px, plr[pnum]._py, plr[pnum].destParam1, plr[pnum].destParam2); - StartAttack(pnum, d); - plr[pnum].destAction = ACTION_NONE; - } else if (plr[pnum].destAction == ACTION_ATTACKMON) { - i = plr[pnum].destParam1; - x = abs(plr[pnum].WorldX - monster[i]._mfutx); - y = abs(plr[pnum].WorldY - monster[i]._mfuty); - if (x <= 1 && y <= 1) { - d = GetDirection(plr[pnum]._px, plr[pnum]._py, monster[i]._mfutx, monster[i]._mfuty); - StartAttack(pnum, d); - } - plr[pnum].destAction = ACTION_NONE; - } else if (plr[pnum].destAction == ACTION_ATTACKPLR) { - i = plr[pnum].destParam1; - x = abs(plr[pnum].WorldX - plr[i]._px); - y = abs(plr[pnum].WorldY - plr[i]._py); - if (x <= 1 && y <= 1) { - d = GetDirection(plr[pnum]._px, plr[pnum]._py, plr[i]._px, plr[i]._py); - StartAttack(pnum, d); - } - plr[pnum].destAction = ACTION_NONE; - } else if (plr[pnum].destAction == ACTION_OPERATE) { - i = plr[pnum].destParam1; - x = abs(plr[pnum].WorldX - object[i]._ox); - y = abs(plr[pnum].WorldY - object[i]._oy); - if (y > 1 && dObject[object[i]._ox][object[i]._oy - 1] == -1 - i) { - y = abs(plr[pnum].WorldY - object[i]._oy + 1); - } - if (x <= 1 && y <= 1) { - if (object[i]._oBreak == 1) { - d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, object[i]._ox, object[i]._oy); - StartAttack(pnum, d); - } else { - OperateObject(pnum, i, FALSE); - } - } - } - } + if (plr[pnum]._pmode == PM_ATTACK && plr[pnum]._pAnimFrame > plr[myplr]._pAFNum) { + if (plr[pnum].destAction == ACTION_ATTACK) { + d = GetDirection(plr[pnum]._px, plr[pnum]._py, plr[pnum].destParam1, plr[pnum].destParam2); + StartAttack(pnum, d); + plr[pnum].destAction = ACTION_NONE; + } else if (plr[pnum].destAction == ACTION_ATTACKMON) { + i = plr[pnum].destParam1; + x = abs(plr[pnum].WorldX - monster[i]._mfutx); + y = abs(plr[pnum].WorldY - monster[i]._mfuty); + if (x <= 1 && y <= 1) { + d = GetDirection(plr[pnum]._px, plr[pnum]._py, monster[i]._mfutx, monster[i]._mfuty); + StartAttack(pnum, d); + } + plr[pnum].destAction = ACTION_NONE; + } else if (plr[pnum].destAction == ACTION_ATTACKPLR) { + i = plr[pnum].destParam1; + x = abs(plr[pnum].WorldX - plr[i]._px); + y = abs(plr[pnum].WorldY - plr[i]._py); + if (x <= 1 && y <= 1) { + d = GetDirection(plr[pnum]._px, plr[pnum]._py, plr[i]._px, plr[i]._py); + StartAttack(pnum, d); + } + plr[pnum].destAction = ACTION_NONE; + } else if (plr[pnum].destAction == ACTION_OPERATE) { + i = plr[pnum].destParam1; + x = abs(plr[pnum].WorldX - object[i]._ox); + y = abs(plr[pnum].WorldY - object[i]._oy); + if (y > 1 && dObject[object[i]._ox][object[i]._oy - 1] == -1 - i) { + y = abs(plr[pnum].WorldY - object[i]._oy + 1); + } + if (x <= 1 && y <= 1) { + if (object[i]._oBreak == 1) { + d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, object[i]._ox, object[i]._oy); + StartAttack(pnum, d); + } else { + OperateObject(pnum, i, FALSE); + } + } + } + } - if (plr[pnum]._pmode == PM_RATTACK && plr[pnum]._pAnimFrame > plr[myplr]._pAFNum) { - if (plr[pnum].destAction == ACTION_RATTACK) { - d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, plr[pnum].destParam1, plr[pnum].destParam2); - StartRangeAttack(pnum, d, plr[pnum].destParam1, plr[pnum].destParam2); - plr[pnum].destAction = ACTION_NONE; - } else if (plr[pnum].destAction == ACTION_RATTACKMON) { - i = plr[pnum].destParam1; - d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, monster[i]._mfutx, monster[i]._mfuty); - StartRangeAttack(pnum, d, monster[i]._mfutx, monster[i]._mfuty); - plr[pnum].destAction = ACTION_NONE; - } else if (plr[pnum].destAction == ACTION_RATTACKPLR) { - i = plr[pnum].destParam1; - d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, plr[i]._px, plr[i]._py); - StartRangeAttack(pnum, d, plr[i]._px, plr[i]._py); - plr[pnum].destAction = ACTION_NONE; - } - } + if (plr[pnum]._pmode == PM_RATTACK && plr[pnum]._pAnimFrame > plr[myplr]._pAFNum) { + if (plr[pnum].destAction == ACTION_RATTACK) { + d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, plr[pnum].destParam1, plr[pnum].destParam2); + StartRangeAttack(pnum, d, plr[pnum].destParam1, plr[pnum].destParam2); + plr[pnum].destAction = ACTION_NONE; + } else if (plr[pnum].destAction == ACTION_RATTACKMON) { + i = plr[pnum].destParam1; + d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, monster[i]._mfutx, monster[i]._mfuty); + StartRangeAttack(pnum, d, monster[i]._mfutx, monster[i]._mfuty); + plr[pnum].destAction = ACTION_NONE; + } else if (plr[pnum].destAction == ACTION_RATTACKPLR) { + i = plr[pnum].destParam1; + d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, plr[i]._px, plr[i]._py); + StartRangeAttack(pnum, d, plr[i]._px, plr[i]._py); + plr[pnum].destAction = ACTION_NONE; + } + } - if (plr[pnum]._pmode == PM_SPELL && plr[pnum]._pAnimFrame > plr[pnum]._pSFNum) { - if (plr[pnum].destAction == ACTION_SPELL) { - d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, plr[pnum].destParam1, plr[pnum].destParam2); - StartSpell(pnum, d, plr[pnum].destParam1, plr[pnum].destParam2); - plr[pnum].destAction = ACTION_NONE; - } else if (plr[pnum].destAction == ACTION_SPELLMON) { - i = plr[pnum].destParam1; - d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, monster[i]._mfutx, monster[i]._mfuty); - StartSpell(pnum, d, monster[i]._mfutx, monster[i]._mfuty); - plr[pnum].destAction = ACTION_NONE; - } else if (plr[pnum].destAction == ACTION_SPELLPLR) { - i = plr[pnum].destParam1; - d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, plr[i]._px, plr[i]._py); - StartSpell(pnum, d, plr[i]._px, plr[i]._py); - plr[pnum].destAction = ACTION_NONE; - } - } + if (plr[pnum]._pmode == PM_SPELL && plr[pnum]._pAnimFrame > plr[pnum]._pSFNum) { + if (plr[pnum].destAction == ACTION_SPELL) { + d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, plr[pnum].destParam1, plr[pnum].destParam2); + StartSpell(pnum, d, plr[pnum].destParam1, plr[pnum].destParam2); + plr[pnum].destAction = ACTION_NONE; + } else if (plr[pnum].destAction == ACTION_SPELLMON) { + i = plr[pnum].destParam1; + d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, monster[i]._mfutx, monster[i]._mfuty); + StartSpell(pnum, d, monster[i]._mfutx, monster[i]._mfuty); + plr[pnum].destAction = ACTION_NONE; + } else if (plr[pnum].destAction == ACTION_SPELLPLR) { + i = plr[pnum].destParam1; + d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, plr[i]._px, plr[i]._py); + StartSpell(pnum, d, plr[i]._px, plr[i]._py); + plr[pnum].destAction = ACTION_NONE; + } + } } BOOL __fastcall PlrDeathModeOK(int pnum) { - if (pnum != myplr) { - return TRUE; - } + if (pnum != myplr) { + return TRUE; + } - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("PlrDeathModeOK: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("PlrDeathModeOK: illegal player %d", pnum); + } - if (plr[pnum]._pmode == PM_DEATH) { - return TRUE; - } else if (plr[pnum]._pmode == PM_QUIT) { - return TRUE; - } else if (plr[pnum]._pmode == PM_NEWLVL) { - return TRUE; - } + if (plr[pnum]._pmode == PM_DEATH) { + return TRUE; + } else if (plr[pnum]._pmode == PM_QUIT) { + return TRUE; + } else if (plr[pnum]._pmode == PM_NEWLVL) { + return TRUE; + } - return FALSE; + return FALSE; } void __cdecl ValidatePlayer() { - __int64 msk = 0; + __int64 msk = 0; - if ((DWORD)myplr >= MAX_PLRS) { - TermMsg("ValidatePlayer: illegal player %d", myplr); - } - if (plr[myplr]._pLevel > 50) - plr[myplr]._pLevel = 50; - if (plr[myplr]._pExperience > plr[myplr]._pNextExper) - plr[myplr]._pExperience = plr[myplr]._pNextExper; + if ((DWORD)myplr >= MAX_PLRS) { + TermMsg("ValidatePlayer: illegal player %d", myplr); + } + if (plr[myplr]._pLevel > 50) + plr[myplr]._pLevel = 50; + if (plr[myplr]._pExperience > plr[myplr]._pNextExper) + plr[myplr]._pExperience = plr[myplr]._pNextExper; - int gt = 0; - for (int i = 0; i < plr[myplr]._pNumInv; i++) { - if (plr[myplr].InvList[i]._itype == ITYPE_GOLD) { - if (plr[myplr].InvList[i]._ivalue > 5000) { - plr[myplr].InvList[i]._ivalue = 5000; - } - gt += plr[myplr].InvList[i]._ivalue; - } - } - if (gt != plr[myplr]._pGold) - plr[myplr]._pGold = gt; + int gt = 0; + for (int i = 0; i < plr[myplr]._pNumInv; i++) { + if (plr[myplr].InvList[i]._itype == ITYPE_GOLD) { + if (plr[myplr].InvList[i]._ivalue > 5000) { + plr[myplr].InvList[i]._ivalue = 5000; + } + gt += plr[myplr].InvList[i]._ivalue; + } + } + if (gt != plr[myplr]._pGold) + plr[myplr]._pGold = gt; - int pc = plr[myplr]._pClass; - if (plr[myplr]._pBaseStr > MaxStats[pc][ATTRIB_STR]) { - plr[myplr]._pBaseStr = MaxStats[pc][ATTRIB_STR]; - } - if (plr[myplr]._pBaseMag > MaxStats[pc][ATTRIB_MAG]) { - plr[myplr]._pBaseMag = MaxStats[pc][ATTRIB_MAG]; - } - if (plr[myplr]._pBaseDex > MaxStats[pc][ATTRIB_DEX]) { - plr[myplr]._pBaseDex = MaxStats[pc][ATTRIB_DEX]; - } - if (plr[myplr]._pBaseVit > MaxStats[pc][ATTRIB_VIT]) { - plr[myplr]._pBaseVit = MaxStats[pc][ATTRIB_VIT]; - } + int pc = plr[myplr]._pClass; + if (plr[myplr]._pBaseStr > MaxStats[pc][ATTRIB_STR]) { + plr[myplr]._pBaseStr = MaxStats[pc][ATTRIB_STR]; + } + if (plr[myplr]._pBaseMag > MaxStats[pc][ATTRIB_MAG]) { + plr[myplr]._pBaseMag = MaxStats[pc][ATTRIB_MAG]; + } + if (plr[myplr]._pBaseDex > MaxStats[pc][ATTRIB_DEX]) { + plr[myplr]._pBaseDex = MaxStats[pc][ATTRIB_DEX]; + } + if (plr[myplr]._pBaseVit > MaxStats[pc][ATTRIB_VIT]) { + plr[myplr]._pBaseVit = MaxStats[pc][ATTRIB_VIT]; + } - for (int b = 1; b < MAX_SPELLS; b++) { - if (spelldata[b].sBookLvl != -1) { - msk |= (__int64)1 << (b - 1); - if (plr[myplr]._pSplLvl[b] > 15) - plr[myplr]._pSplLvl[b] = 15; - } - } + for (int b = 1; b < MAX_SPELLS; b++) { + if (spelldata[b].sBookLvl != -1) { + msk |= (__int64)1 << (b - 1); + if (plr[myplr]._pSplLvl[b] > 15) + plr[myplr]._pSplLvl[b] = 15; + } + } - plr[myplr]._pMemSpells &= msk; + plr[myplr]._pMemSpells &= msk; } void __cdecl ProcessPlayers() { - if ((DWORD)myplr >= MAX_PLRS) { - TermMsg("ProcessPlayers: illegal player %d", myplr); - } + if ((DWORD)myplr >= MAX_PLRS) { + TermMsg("ProcessPlayers: illegal player %d", myplr); + } - if (plr[myplr].pLvlLoad > 0) { - plr[myplr].pLvlLoad--; - } + if (plr[myplr].pLvlLoad > 0) { + plr[myplr].pLvlLoad--; + } - if (sfxdelay > 0) { - sfxdelay--; - if (sfxdelay == 0) { - PlaySFX(sfxdnum); - } - } + if (sfxdelay > 0) { + sfxdelay--; + if (sfxdelay == 0) { + PlaySFX(sfxdnum); + } + } - ValidatePlayer(); + ValidatePlayer(); - for (int pnum = 0; pnum < MAX_PLRS; pnum++) { - if (plr[pnum].plractive && currlevel == plr[pnum].plrlevel && (pnum == myplr || !plr[pnum]._pLvlChanging)) { - CheckCheatStats(pnum); + for (int pnum = 0; pnum < MAX_PLRS; pnum++) { + if (plr[pnum].plractive && currlevel == plr[pnum].plrlevel && (pnum == myplr || !plr[pnum]._pLvlChanging)) { + CheckCheatStats(pnum); - if (!PlrDeathModeOK(pnum) && (plr[pnum]._pHitPoints >> 6) <= 0) { - SyncPlrKill(pnum, -1); - } + if (!PlrDeathModeOK(pnum) && (plr[pnum]._pHitPoints >> 6) <= 0) { + SyncPlrKill(pnum, -1); + } - if (pnum == myplr) { - if ((plr[pnum]._pIFlags & ISPL_DRAINLIFE) && currlevel != 0) { - plr[pnum]._pHitPoints -= 4; - plr[pnum]._pHPBase -= 4; - if ((plr[pnum]._pHitPoints >> 6) <= 0) { - SyncPlrKill(pnum, 0); - } - drawhpflag = TRUE; - } - if (plr[pnum]._pIFlags & ISPL_NOMANA && plr[pnum]._pManaBase > 0) { - plr[pnum]._pManaBase -= plr[pnum]._pMana; - plr[pnum]._pMana = 0; - drawmanaflag = TRUE; - } - } + if (pnum == myplr) { + if ((plr[pnum]._pIFlags & ISPL_DRAINLIFE) && currlevel != 0) { + plr[pnum]._pHitPoints -= 4; + plr[pnum]._pHPBase -= 4; + if ((plr[pnum]._pHitPoints >> 6) <= 0) { + SyncPlrKill(pnum, 0); + } + drawhpflag = TRUE; + } + if (plr[pnum]._pIFlags & ISPL_NOMANA && plr[pnum]._pManaBase > 0) { + plr[pnum]._pManaBase -= plr[pnum]._pMana; + plr[pnum]._pMana = 0; + drawmanaflag = TRUE; + } + } - BOOL tplayer = FALSE; - do { - switch (plr[pnum]._pmode) { - case PM_STAND: - tplayer = PM_DoStand(pnum); - break; - case PM_WALK: - tplayer = PM_DoWalk(pnum); - break; - case PM_WALK2: - tplayer = PM_DoWalk2(pnum); - break; - case PM_WALK3: - tplayer = PM_DoWalk3(pnum); - break; - case PM_ATTACK: - tplayer = PM_DoAttack(pnum); - break; - case PM_RATTACK: - tplayer = PM_DoRangeAttack(pnum); - break; - case PM_BLOCK: - tplayer = PM_DoBlock(pnum); - break; - case PM_SPELL: - tplayer = PM_DoSpell(pnum); - break; - case PM_GOTHIT: - tplayer = PM_DoGotHit(pnum); - break; - case PM_DEATH: - tplayer = PM_DoDeath(pnum); - break; - case PM_NEWLVL: - tplayer = PM_DoNewLvl(pnum); - break; - } - CheckNewPath(pnum); - } while (tplayer); + BOOL tplayer = FALSE; + do { + switch (plr[pnum]._pmode) { + case PM_STAND: + tplayer = PM_DoStand(pnum); + break; + case PM_WALK: + tplayer = PM_DoWalk(pnum); + break; + case PM_WALK2: + tplayer = PM_DoWalk2(pnum); + break; + case PM_WALK3: + tplayer = PM_DoWalk3(pnum); + break; + case PM_ATTACK: + tplayer = PM_DoAttack(pnum); + break; + case PM_RATTACK: + tplayer = PM_DoRangeAttack(pnum); + break; + case PM_BLOCK: + tplayer = PM_DoBlock(pnum); + break; + case PM_SPELL: + tplayer = PM_DoSpell(pnum); + break; + case PM_GOTHIT: + tplayer = PM_DoGotHit(pnum); + break; + case PM_DEATH: + tplayer = PM_DoDeath(pnum); + break; + case PM_NEWLVL: + tplayer = PM_DoNewLvl(pnum); + break; + } + CheckNewPath(pnum); + } while (tplayer); - plr[pnum]._pAnimCnt++; - if (plr[pnum]._pAnimCnt > plr[pnum]._pAnimDelay) { - plr[pnum]._pAnimCnt = 0; - plr[pnum]._pAnimFrame++; - if (plr[pnum]._pAnimFrame > plr[pnum]._pAnimLen) { - plr[pnum]._pAnimFrame = 1; - } - } - } - } + plr[pnum]._pAnimCnt++; + if (plr[pnum]._pAnimCnt > plr[pnum]._pAnimDelay) { + plr[pnum]._pAnimCnt = 0; + plr[pnum]._pAnimFrame++; + if (plr[pnum]._pAnimFrame > plr[pnum]._pAnimLen) { + plr[pnum]._pAnimFrame = 1; + } + } + } + } } // 52A554: using guessed type int sfxdelay; void __fastcall CheckCheatStats(int pnum) { - if (plr[pnum]._pStrength > 750) { - plr[pnum]._pStrength = 750; - } + if (plr[pnum]._pStrength > 750) { + plr[pnum]._pStrength = 750; + } - if (plr[pnum]._pDexterity > 750) { - plr[pnum]._pDexterity = 750; - } + if (plr[pnum]._pDexterity > 750) { + plr[pnum]._pDexterity = 750; + } - if (plr[pnum]._pMagic > 750) { - plr[pnum]._pMagic = 750; - } + if (plr[pnum]._pMagic > 750) { + plr[pnum]._pMagic = 750; + } - if (plr[pnum]._pVitality > 750) { - plr[pnum]._pVitality = 750; - } + if (plr[pnum]._pVitality > 750) { + plr[pnum]._pVitality = 750; + } - if (plr[pnum]._pHitPoints > 128000) { - plr[pnum]._pHitPoints = 128000; - } + if (plr[pnum]._pHitPoints > 128000) { + plr[pnum]._pHitPoints = 128000; + } - if (plr[pnum]._pMana > 128000) { - plr[pnum]._pMana = 128000; - } + if (plr[pnum]._pMana > 128000) { + plr[pnum]._pMana = 128000; + } } void __fastcall ClrPlrPath(int pnum) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("ClrPlrPath: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("ClrPlrPath: illegal player %d", pnum); + } - memset(plr[pnum].walkpath, WALK_NONE, sizeof(plr[pnum].walkpath)); + memset(plr[pnum].walkpath, WALK_NONE, sizeof(plr[pnum].walkpath)); } BOOL __fastcall PosOkPlayer(int pnum, int px, int py) { - BOOL PosOK = FALSE; - if (px >= 0 && px < MAXDUNX && py >= 0 && py < MAXDUNY && !SolidLoc(px, py) && dPiece[px][py]) { + BOOL PosOK = FALSE; + if (px >= 0 && px < MAXDUNX && py >= 0 && py < MAXDUNY && !SolidLoc(px, py) && dPiece[px][py]) { - if (dPlayer[px][py]) { - DWORD p; - if (dPlayer[px][py] > 0) { - p = dPlayer[px][py] - 1; - } else { - p = -(dPlayer[px][py] + 1); - } - if (p != pnum && p < MAX_PLRS && plr[p]._pHitPoints) { - return FALSE; - } - } + if (dPlayer[px][py]) { + DWORD p; + if (dPlayer[px][py] > 0) { + p = dPlayer[px][py] - 1; + } else { + p = -(dPlayer[px][py] + 1); + } + if (p != pnum && p < MAX_PLRS && plr[p]._pHitPoints) { + return FALSE; + } + } - if (dMonster[px][py]) { - if (currlevel == 0) { - return FALSE; - } - if (dMonster[px][py] <= 0) { - return FALSE; - } - if ((monster[dMonster[px][py] - 1]._mhitpoints >> 6) > 0) { - return FALSE; - } - } + if (dMonster[px][py]) { + if (currlevel == 0) { + return FALSE; + } + if (dMonster[px][py] <= 0) { + return FALSE; + } + if ((monster[dMonster[px][py] - 1]._mhitpoints >> 6) > 0) { + return FALSE; + } + } - if (dObject[px][py]) { - char bv; - if (dObject[px][py] > 0) { - bv = dObject[px][py] - 1; - } else { - bv = -(dObject[px][py] + 1); - } - if (object[bv]._oSolidFlag) { - return FALSE; - } - } + if (dObject[px][py]) { + char bv; + if (dObject[px][py] > 0) { + bv = dObject[px][py] - 1; + } else { + bv = -(dObject[px][py] + 1); + } + if (object[bv]._oSolidFlag) { + return FALSE; + } + } - PosOK = TRUE; - } + PosOK = TRUE; + } - if (!PosOK) - return FALSE; - return TRUE; + if (!PosOK) + return FALSE; + return TRUE; } void __fastcall MakePlrPath(int pnum, int xx, int yy, BOOL endspace) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("MakePlrPath: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("MakePlrPath: illegal player %d", pnum); + } - plr[pnum]._ptargx = xx; - plr[pnum]._ptargy = yy; - if (plr[pnum]._px == xx && plr[pnum]._py == yy) { - return; - } + plr[pnum]._ptargx = xx; + plr[pnum]._ptargy = yy; + if (plr[pnum]._px == xx && plr[pnum]._py == yy) { + return; + } - int path = FindPath(PosOkPlayer, pnum, plr[pnum]._px, plr[pnum]._py, xx, yy, plr[pnum].walkpath); - if (!path) { - return; - } + int path = FindPath(PosOkPlayer, pnum, plr[pnum]._px, plr[pnum]._py, xx, yy, plr[pnum].walkpath); + if (!path) { + return; + } - if (!endspace) { - path--; + if (!endspace) { + path--; - switch (plr[pnum].walkpath[path]) { - case WALK_NE: - yy++; - break; - case WALK_NW: - xx++; - break; - case WALK_SE: - xx--; - break; - case WALK_SW: - yy--; - break; - case WALK_N: - xx++; - yy++; - break; - case WALK_E: - xx--; - yy++; - break; - case WALK_S: - xx--; - yy--; - break; - case WALK_W: - xx++; - yy--; - break; - } + switch (plr[pnum].walkpath[path]) { + case WALK_NE: + yy++; + break; + case WALK_NW: + xx++; + break; + case WALK_SE: + xx--; + break; + case WALK_SW: + yy--; + break; + case WALK_N: + xx++; + yy++; + break; + case WALK_E: + xx--; + yy++; + break; + case WALK_S: + xx--; + yy--; + break; + case WALK_W: + xx++; + yy--; + break; + } - plr[pnum]._ptargx = xx; - plr[pnum]._ptargy = yy; - } + plr[pnum]._ptargx = xx; + plr[pnum]._ptargy = yy; + } - plr[pnum].walkpath[path] = WALK_NONE; + plr[pnum].walkpath[path] = WALK_NONE; } void __fastcall CheckPlrSpell() { - if ((DWORD)myplr >= MAX_PLRS) { - TermMsg("CheckPlrSpell: illegal player %d", myplr); - } + if ((DWORD)myplr >= MAX_PLRS) { + TermMsg("CheckPlrSpell: illegal player %d", myplr); + } - int rspell = plr[myplr]._pRSpell; - if (rspell == SPL_INVALID) { - if (plr[myplr]._pClass == PC_WARRIOR) { - PlaySFX(PS_WARR34); - } else if (plr[myplr]._pClass == PC_ROGUE) { - PlaySFX(PS_ROGUE34); - } else if (plr[myplr]._pClass == PC_SORCERER) { - PlaySFX(PS_MAGE34); - } - return; - } + int rspell = plr[myplr]._pRSpell; + if (rspell == SPL_INVALID) { + if (plr[myplr]._pClass == PC_WARRIOR) { + PlaySFX(PS_WARR34); + } else if (plr[myplr]._pClass == PC_ROGUE) { + PlaySFX(PS_ROGUE34); + } else if (plr[myplr]._pClass == PC_SORCERER) { + PlaySFX(PS_MAGE34); + } + return; + } - if (leveltype == DTYPE_TOWN && !spelldata[rspell].sTownSpell) { - if (plr[myplr]._pClass == PC_WARRIOR) { - PlaySFX(PS_WARR27); - } else if (plr[myplr]._pClass == PC_ROGUE) { - PlaySFX(PS_ROGUE27); - } else if (plr[myplr]._pClass == PC_SORCERER) { - PlaySFX(PS_MAGE27); - } - return; - } + if (leveltype == DTYPE_TOWN && !spelldata[rspell].sTownSpell) { + if (plr[myplr]._pClass == PC_WARRIOR) { + PlaySFX(PS_WARR27); + } else if (plr[myplr]._pClass == PC_ROGUE) { + PlaySFX(PS_ROGUE27); + } else if (plr[myplr]._pClass == PC_SORCERER) { + PlaySFX(PS_MAGE27); + } + return; + } - if (pcurs != CURSOR_HAND - || MouseY >= 352 - || (chrflag && MouseX < 320 || invflag && MouseX > 320) - && rspell != SPL_HEAL - && rspell != SPL_IDENTIFY - && rspell != SPL_REPAIR - && rspell != SPL_INFRA - && rspell != SPL_RECHARGE) { - return; - } + if (pcurs != CURSOR_HAND + || MouseY >= 352 + || (chrflag && MouseX < 320 || invflag && MouseX > 320) + && rspell != SPL_HEAL + && rspell != SPL_IDENTIFY + && rspell != SPL_REPAIR + && rspell != SPL_INFRA + && rspell != SPL_RECHARGE) { + return; + } - BOOL addflag = FALSE; - switch (plr[myplr]._pRSplType) { - case RSPLTYPE_SKILL: - case RSPLTYPE_SPELL: - addflag = CheckSpell(myplr, rspell, plr[myplr]._pRSplType, FALSE); - break; - case RSPLTYPE_SCROLL: - addflag = UseScroll(); - break; - case RSPLTYPE_CHARGES: - addflag = UseStaff(); - break; - } + BOOL addflag = FALSE; + switch (plr[myplr]._pRSplType) { + case RSPLTYPE_SKILL: + case RSPLTYPE_SPELL: + addflag = CheckSpell(myplr, rspell, plr[myplr]._pRSplType, FALSE); + break; + case RSPLTYPE_SCROLL: + addflag = UseScroll(); + break; + case RSPLTYPE_CHARGES: + addflag = UseStaff(); + break; + } - if (addflag) { - if (plr[myplr]._pRSpell == SPL_FIREWALL) { - int sd = GetDirection(plr[myplr].WorldX, plr[myplr].WorldY, cursmx, cursmy); - int sl = GetSpellLevel(myplr, plr[myplr]._pRSpell); - NetSendCmdLocParam3(TRUE, CMD_SPELLXYD, cursmx, cursmy, plr[myplr]._pRSpell, sd, sl); - } else if (pcursmonst != -1) { - int sl = GetSpellLevel(myplr, plr[myplr]._pRSpell); - NetSendCmdParam3(TRUE, CMD_SPELLID, pcursmonst, plr[myplr]._pRSpell, sl); - } else if (pcursplr != -1) { - int sl = GetSpellLevel(myplr, plr[myplr]._pRSpell); - NetSendCmdParam3(TRUE, CMD_SPELLPID, pcursplr, plr[myplr]._pRSpell, sl); - } else { //145 - int sl = GetSpellLevel(myplr, plr[myplr]._pRSpell); - NetSendCmdLocParam2(TRUE, CMD_SPELLXY, cursmx, cursmy, plr[myplr]._pRSpell, sl); - } - return; - } + if (addflag) { + if (plr[myplr]._pRSpell == SPL_FIREWALL) { + int sd = GetDirection(plr[myplr].WorldX, plr[myplr].WorldY, cursmx, cursmy); + int sl = GetSpellLevel(myplr, plr[myplr]._pRSpell); + NetSendCmdLocParam3(TRUE, CMD_SPELLXYD, cursmx, cursmy, plr[myplr]._pRSpell, sd, sl); + } else if (pcursmonst != -1) { + int sl = GetSpellLevel(myplr, plr[myplr]._pRSpell); + NetSendCmdParam3(TRUE, CMD_SPELLID, pcursmonst, plr[myplr]._pRSpell, sl); + } else if (pcursplr != -1) { + int sl = GetSpellLevel(myplr, plr[myplr]._pRSpell); + NetSendCmdParam3(TRUE, CMD_SPELLPID, pcursplr, plr[myplr]._pRSpell, sl); + } else { //145 + int sl = GetSpellLevel(myplr, plr[myplr]._pRSpell); + NetSendCmdLocParam2(TRUE, CMD_SPELLXY, cursmx, cursmy, plr[myplr]._pRSpell, sl); + } + return; + } - if (plr[myplr]._pRSplType == RSPLTYPE_SPELL) { - if (plr[myplr]._pClass == PC_WARRIOR) { - PlaySFX(PS_WARR35); - } else if (plr[myplr]._pClass == PC_ROGUE) { - PlaySFX(PS_ROGUE35); - } else if (plr[myplr]._pClass == PC_SORCERER) { - PlaySFX(PS_MAGE35); - } - } + if (plr[myplr]._pRSplType == RSPLTYPE_SPELL) { + if (plr[myplr]._pClass == PC_WARRIOR) { + PlaySFX(PS_WARR35); + } else if (plr[myplr]._pClass == PC_ROGUE) { + PlaySFX(PS_ROGUE35); + } else if (plr[myplr]._pClass == PC_SORCERER) { + PlaySFX(PS_MAGE35); + } + } } // 4B8CC2: using guessed type char pcursplr; void __fastcall SyncPlrAnim(int pnum) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("SyncPlrAnim: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("SyncPlrAnim: illegal player %d", pnum); + } - int dir = plr[pnum]._pdir; - switch (plr[pnum]._pmode) { - case PM_BLOCK: - plr[pnum]._pAnimData = plr[pnum]._pBAnim[dir]; - break; - case PM_GOTHIT: - plr[pnum]._pAnimData = plr[pnum]._pHAnim[dir]; - break; - case PM_DEATH: - plr[pnum]._pAnimData = plr[pnum]._pDAnim[dir]; - break; - case PM_SPELL: - int sType; - if (pnum == myplr) { - sType = spelldata[plr[pnum]._pSpell].sType; - } else { - sType = STYPE_FIRE; - } - if (sType == STYPE_FIRE) - plr[pnum]._pAnimData = plr[pnum]._pFAnim[dir]; - if (sType == STYPE_LIGHTNING) - plr[pnum]._pAnimData = plr[pnum]._pLAnim[dir]; - if (sType == STYPE_MAGIC) { - plr[pnum]._pAnimData = plr[pnum]._pTAnim[dir]; - } - break; - case PM_STAND: - case PM_NEWLVL: - case PM_QUIT: - plr[pnum]._pAnimData = plr[pnum]._pNAnim[dir]; - break; - case PM_WALK: - case PM_WALK2: - case PM_WALK3: - plr[pnum]._pAnimData = plr[pnum]._pWAnim[dir]; - break; - case PM_ATTACK: - case PM_RATTACK: - plr[pnum]._pAnimData = plr[pnum]._pAAnim[dir]; - break; - default: - TermMsg("SyncPlrAnim"); - break; - } + int dir = plr[pnum]._pdir; + switch (plr[pnum]._pmode) { + case PM_BLOCK: + plr[pnum]._pAnimData = plr[pnum]._pBAnim[dir]; + break; + case PM_GOTHIT: + plr[pnum]._pAnimData = plr[pnum]._pHAnim[dir]; + break; + case PM_DEATH: + plr[pnum]._pAnimData = plr[pnum]._pDAnim[dir]; + break; + case PM_SPELL: + int sType; + if (pnum == myplr) { + sType = spelldata[plr[pnum]._pSpell].sType; + } else { + sType = STYPE_FIRE; + } + if (sType == STYPE_FIRE) + plr[pnum]._pAnimData = plr[pnum]._pFAnim[dir]; + if (sType == STYPE_LIGHTNING) + plr[pnum]._pAnimData = plr[pnum]._pLAnim[dir]; + if (sType == STYPE_MAGIC) { + plr[pnum]._pAnimData = plr[pnum]._pTAnim[dir]; + } + break; + case PM_STAND: + case PM_NEWLVL: + case PM_QUIT: + plr[pnum]._pAnimData = plr[pnum]._pNAnim[dir]; + break; + case PM_WALK: + case PM_WALK2: + case PM_WALK3: + plr[pnum]._pAnimData = plr[pnum]._pWAnim[dir]; + break; + case PM_ATTACK: + case PM_RATTACK: + plr[pnum]._pAnimData = plr[pnum]._pAAnim[dir]; + break; + default: + TermMsg("SyncPlrAnim"); + break; + } } void __fastcall SyncInitPlrPos(int pnum) { - plr[pnum]._ptargx = plr[pnum].WorldX; - plr[pnum]._ptargy = plr[pnum].WorldY; + plr[pnum]._ptargx = plr[pnum].WorldX; + plr[pnum]._ptargy = plr[pnum].WorldY; - if (gbMaxPlayers == 1 || plr[pnum].plrlevel != currlevel) { - return; - } + if (gbMaxPlayers == 1 || plr[pnum].plrlevel != currlevel) { + return; + } - int x; - int y; - for (DWORD i = 0; i < 8; i++) { - x = plr[pnum].WorldX + plrxoff2[i]; - y = plr[pnum].WorldY + plryoff2[i]; - if (PosOkPlayer(pnum, x, y)) { - break; - } - } + int x; + int y; + for (DWORD i = 0; i < 8; i++) { + x = plr[pnum].WorldX + plrxoff2[i]; + y = plr[pnum].WorldY + plryoff2[i]; + if (PosOkPlayer(pnum, x, y)) { + break; + } + } - if (!PosOkPlayer(pnum, x, y)) { - BOOL posOk = FALSE; - int xx; - int yy; - for (int range = 1; range < 50 && !posOk; range++) { - for (yy = -range; yy <= range && !posOk; yy++) { - y = yy + plr[pnum].WorldY; - for (xx = -range; xx <= range && !posOk; xx++) { - x = xx + plr[pnum].WorldX; - if (PosOkPlayer(pnum, x, y) && !PosOkPortal(currlevel, x, y)) { - posOk = TRUE; - } - } - } - } - } + if (!PosOkPlayer(pnum, x, y)) { + BOOL posOk = FALSE; + int xx; + int yy; + for (int range = 1; range < 50 && !posOk; range++) { + for (yy = -range; yy <= range && !posOk; yy++) { + y = yy + plr[pnum].WorldY; + for (xx = -range; xx <= range && !posOk; xx++) { + x = xx + plr[pnum].WorldX; + if (PosOkPlayer(pnum, x, y) && !PosOkPortal(currlevel, x, y)) { + posOk = TRUE; + } + } + } + } + } - plr[pnum].WorldX = x; - plr[pnum].WorldY = y; - dPlayer[x][y] = pnum + 1; + plr[pnum].WorldX = x; + plr[pnum].WorldY = y; + dPlayer[x][y] = pnum + 1; - if (pnum == myplr) { - plr[pnum]._px = x; - plr[pnum]._py = y; - plr[pnum]._ptargx = x; - plr[pnum]._ptargy = y; - ViewX = x; - ViewY = y; - } + if (pnum == myplr) { + plr[pnum]._px = x; + plr[pnum]._py = y; + plr[pnum]._ptargx = x; + plr[pnum]._ptargy = y; + ViewX = x; + ViewY = y; + } } void __fastcall SyncInitPlr(int pnum) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("SyncInitPlr: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("SyncInitPlr: illegal player %d", pnum); + } - SetPlrAnims(pnum); - SyncInitPlrPos(pnum); + SetPlrAnims(pnum); + SyncInitPlrPos(pnum); } void __fastcall CheckStats(int pnum) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("CheckStats: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("CheckStats: illegal player %d", pnum); + } - int c; - if (plr[pnum]._pClass == PC_WARRIOR) { - c = PC_WARRIOR; - } else if (plr[pnum]._pClass == PC_ROGUE) { - c = PC_ROGUE; - } else if (plr[pnum]._pClass == PC_SORCERER) { - c = PC_SORCERER; - } + int c; + if (plr[pnum]._pClass == PC_WARRIOR) { + c = PC_WARRIOR; + } else if (plr[pnum]._pClass == PC_ROGUE) { + c = PC_ROGUE; + } else if (plr[pnum]._pClass == PC_SORCERER) { + c = PC_SORCERER; + } - for (int i = 0; i < 4; i++) { - switch (i) { - case ATTRIB_STR: - if (plr[pnum]._pBaseStr > MaxStats[c][ATTRIB_STR]) { - plr[pnum]._pBaseStr = MaxStats[c][ATTRIB_STR]; - } else if (plr[pnum]._pBaseStr < 0) { - plr[pnum]._pBaseStr = 0; - } - break; - case ATTRIB_MAG: - if (plr[pnum]._pBaseMag > MaxStats[c][ATTRIB_MAG]) { - plr[pnum]._pBaseMag = MaxStats[c][ATTRIB_MAG]; - } else if (plr[pnum]._pBaseMag < 0) { - plr[pnum]._pBaseMag = 0; - } - break; - case ATTRIB_DEX: - if (plr[pnum]._pBaseDex > MaxStats[c][ATTRIB_DEX]) { - plr[pnum]._pBaseDex = MaxStats[c][ATTRIB_DEX]; - } else if (plr[pnum]._pBaseDex < 0) { - plr[pnum]._pBaseDex = 0; - } - break; - case ATTRIB_VIT: - if (plr[pnum]._pBaseVit > MaxStats[c][ATTRIB_VIT]) { - plr[pnum]._pBaseVit = MaxStats[c][ATTRIB_VIT]; - } else if (plr[pnum]._pBaseVit < 0) { - plr[pnum]._pBaseVit = 0; - } - break; - } - } + for (int i = 0; i < 4; i++) { + switch (i) { + case ATTRIB_STR: + if (plr[pnum]._pBaseStr > MaxStats[c][ATTRIB_STR]) { + plr[pnum]._pBaseStr = MaxStats[c][ATTRIB_STR]; + } else if (plr[pnum]._pBaseStr < 0) { + plr[pnum]._pBaseStr = 0; + } + break; + case ATTRIB_MAG: + if (plr[pnum]._pBaseMag > MaxStats[c][ATTRIB_MAG]) { + plr[pnum]._pBaseMag = MaxStats[c][ATTRIB_MAG]; + } else if (plr[pnum]._pBaseMag < 0) { + plr[pnum]._pBaseMag = 0; + } + break; + case ATTRIB_DEX: + if (plr[pnum]._pBaseDex > MaxStats[c][ATTRIB_DEX]) { + plr[pnum]._pBaseDex = MaxStats[c][ATTRIB_DEX]; + } else if (plr[pnum]._pBaseDex < 0) { + plr[pnum]._pBaseDex = 0; + } + break; + case ATTRIB_VIT: + if (plr[pnum]._pBaseVit > MaxStats[c][ATTRIB_VIT]) { + plr[pnum]._pBaseVit = MaxStats[c][ATTRIB_VIT]; + } else if (plr[pnum]._pBaseVit < 0) { + plr[pnum]._pBaseVit = 0; + } + break; + } + } } void __fastcall ModifyPlrStr(int pnum, int l) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("ModifyPlrStr: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("ModifyPlrStr: illegal player %d", pnum); + } - int max = MaxStats[plr[pnum]._pClass][ATTRIB_STR]; - if (plr[pnum]._pBaseStr + l > max) { - l = max - plr[pnum]._pBaseStr; - } + int max = MaxStats[plr[pnum]._pClass][ATTRIB_STR]; + if (plr[pnum]._pBaseStr + l > max) { + l = max - plr[pnum]._pBaseStr; + } - plr[pnum]._pStrength += l; - plr[pnum]._pBaseStr += l; + plr[pnum]._pStrength += l; + plr[pnum]._pBaseStr += l; - if (plr[pnum]._pClass == PC_ROGUE) { - plr[pnum]._pDamageMod = plr[pnum]._pLevel * (plr[pnum]._pStrength + plr[pnum]._pDexterity) / 200; - } else { - plr[pnum]._pDamageMod = plr[pnum]._pLevel * plr[pnum]._pStrength / 100; - } + if (plr[pnum]._pClass == PC_ROGUE) { + plr[pnum]._pDamageMod = plr[pnum]._pLevel * (plr[pnum]._pStrength + plr[pnum]._pDexterity) / 200; + } else { + plr[pnum]._pDamageMod = plr[pnum]._pLevel * plr[pnum]._pStrength / 100; + } - CalcPlrInv(pnum, TRUE); + CalcPlrInv(pnum, TRUE); - if (pnum == myplr) { - NetSendCmdParam1(FALSE, CMD_SETSTR, plr[pnum]._pBaseStr); //60 - } + if (pnum == myplr) { + NetSendCmdParam1(FALSE, CMD_SETSTR, plr[pnum]._pBaseStr); //60 + } } void __fastcall ModifyPlrMag(int pnum, int l) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("ModifyPlrMag: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("ModifyPlrMag: illegal player %d", pnum); + } - int max = MaxStats[plr[pnum]._pClass][ATTRIB_MAG]; - if (plr[pnum]._pBaseMag + l > max) { - l = max - plr[pnum]._pBaseMag; - } + int max = MaxStats[plr[pnum]._pClass][ATTRIB_MAG]; + if (plr[pnum]._pBaseMag + l > max) { + l = max - plr[pnum]._pBaseMag; + } - plr[pnum]._pMagic += l; - plr[pnum]._pBaseMag += l; + plr[pnum]._pMagic += l; + plr[pnum]._pBaseMag += l; - int ms = l << 6; - if (plr[pnum]._pClass == PC_SORCERER) { - ms *= 2; - } + int ms = l << 6; + if (plr[pnum]._pClass == PC_SORCERER) { + ms *= 2; + } - plr[pnum]._pMaxManaBase += ms; - plr[pnum]._pMaxMana += ms; - if (!(plr[pnum]._pIFlags & ISPL_NOMANA)) { - plr[pnum]._pManaBase += ms; - plr[pnum]._pMana += ms; - } + plr[pnum]._pMaxManaBase += ms; + plr[pnum]._pMaxMana += ms; + if (!(plr[pnum]._pIFlags & ISPL_NOMANA)) { + plr[pnum]._pManaBase += ms; + plr[pnum]._pMana += ms; + } - CalcPlrInv(pnum, TRUE); + CalcPlrInv(pnum, TRUE); - if (pnum == myplr) { - NetSendCmdParam1(FALSE, CMD_SETMAG, plr[pnum]._pBaseMag); - } + if (pnum == myplr) { + NetSendCmdParam1(FALSE, CMD_SETMAG, plr[pnum]._pBaseMag); + } } void __fastcall ModifyPlrDex(int pnum, int l) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("ModifyPlrDex: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("ModifyPlrDex: illegal player %d", pnum); + } - int max = MaxStats[plr[pnum]._pClass][ATTRIB_DEX]; - if (plr[pnum]._pBaseDex + l > max) { - l = max - plr[pnum]._pBaseDex; - } + int max = MaxStats[plr[pnum]._pClass][ATTRIB_DEX]; + if (plr[pnum]._pBaseDex + l > max) { + l = max - plr[pnum]._pBaseDex; + } - plr[pnum]._pDexterity += l; - plr[pnum]._pBaseDex += l; - CalcPlrInv(pnum, TRUE); + plr[pnum]._pDexterity += l; + plr[pnum]._pBaseDex += l; + CalcPlrInv(pnum, TRUE); - if (plr[pnum]._pClass == PC_ROGUE) { - plr[pnum]._pDamageMod = plr[pnum]._pLevel * (plr[pnum]._pDexterity + plr[pnum]._pStrength) / 200; - } + if (plr[pnum]._pClass == PC_ROGUE) { + plr[pnum]._pDamageMod = plr[pnum]._pLevel * (plr[pnum]._pDexterity + plr[pnum]._pStrength) / 200; + } - if (pnum == myplr) { - NetSendCmdParam1(FALSE, CMD_SETDEX, plr[pnum]._pBaseDex); - } + if (pnum == myplr) { + NetSendCmdParam1(FALSE, CMD_SETDEX, plr[pnum]._pBaseDex); + } } void __fastcall ModifyPlrVit(int pnum, int l) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("ModifyPlrVit: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("ModifyPlrVit: illegal player %d", pnum); + } - int max = MaxStats[plr[pnum]._pClass][ATTRIB_VIT]; - if (plr[pnum]._pBaseVit + l > max) { - l = max - plr[pnum]._pBaseVit; - } + int max = MaxStats[plr[pnum]._pClass][ATTRIB_VIT]; + if (plr[pnum]._pBaseVit + l > max) { + l = max - plr[pnum]._pBaseVit; + } - plr[pnum]._pVitality += l; - plr[pnum]._pBaseVit += l; + plr[pnum]._pVitality += l; + plr[pnum]._pBaseVit += l; - int ms = l << 6; - if (plr[pnum]._pClass == PC_WARRIOR) { - ms *= 2; - } + int ms = l << 6; + if (plr[pnum]._pClass == PC_WARRIOR) { + ms *= 2; + } - plr[pnum]._pHPBase += ms; - plr[pnum]._pMaxHPBase += ms; - plr[pnum]._pHitPoints += ms; - plr[pnum]._pMaxHP += ms; + plr[pnum]._pHPBase += ms; + plr[pnum]._pMaxHPBase += ms; + plr[pnum]._pHitPoints += ms; + plr[pnum]._pMaxHP += ms; - CalcPlrInv(pnum, TRUE); + CalcPlrInv(pnum, TRUE); - if (pnum == myplr) { - NetSendCmdParam1(FALSE, CMD_SETVIT, plr[pnum]._pBaseVit); - } + if (pnum == myplr) { + NetSendCmdParam1(FALSE, CMD_SETVIT, plr[pnum]._pBaseVit); + } } void __fastcall SetPlayerHitPoints(int pnum, int newhp) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("SetPlayerHitPoints: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("SetPlayerHitPoints: illegal player %d", pnum); + } - plr[pnum]._pHitPoints = newhp; - plr[pnum]._pHPBase = newhp + plr[pnum]._pMaxHPBase - plr[pnum]._pMaxHP; + plr[pnum]._pHitPoints = newhp; + plr[pnum]._pHPBase = newhp + plr[pnum]._pMaxHPBase - plr[pnum]._pMaxHP; - if (pnum == myplr) { - drawhpflag = TRUE; - } + if (pnum == myplr) { + drawhpflag = TRUE; + } } void __fastcall SetPlrStr(int pnum, int v) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("SetPlrStr: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("SetPlrStr: illegal player %d", pnum); + } - plr[pnum]._pBaseStr = v; - CalcPlrInv(pnum, TRUE); + plr[pnum]._pBaseStr = v; + CalcPlrInv(pnum, TRUE); - int dm; - if (plr[pnum]._pClass == PC_ROGUE) { - dm = plr[pnum]._pLevel * (plr[pnum]._pStrength + plr[pnum]._pDexterity) / 200; - } else { - dm = plr[pnum]._pLevel * plr[pnum]._pStrength / 100; - } + int dm; + if (plr[pnum]._pClass == PC_ROGUE) { + dm = plr[pnum]._pLevel * (plr[pnum]._pStrength + plr[pnum]._pDexterity) / 200; + } else { + dm = plr[pnum]._pLevel * plr[pnum]._pStrength / 100; + } - plr[pnum]._pDamageMod = dm; + plr[pnum]._pDamageMod = dm; } void __fastcall SetPlrMag(int pnum, int v) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("SetPlrMag: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("SetPlrMag: illegal player %d", pnum); + } - plr[pnum]._pBaseMag = v; + plr[pnum]._pBaseMag = v; - int m = v << 6; - if (plr[pnum]._pClass == PC_SORCERER) { - m *= 2; - } + int m = v << 6; + if (plr[pnum]._pClass == PC_SORCERER) { + m *= 2; + } - plr[pnum]._pMaxManaBase = m; - plr[pnum]._pMaxMana = m; - CalcPlrInv(pnum, TRUE); + plr[pnum]._pMaxManaBase = m; + plr[pnum]._pMaxMana = m; + CalcPlrInv(pnum, TRUE); } void __fastcall SetPlrDex(int pnum, int v) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("SetPlrDex: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("SetPlrDex: illegal player %d", pnum); + } - plr[pnum]._pBaseDex = v; - CalcPlrInv(pnum, TRUE); + plr[pnum]._pBaseDex = v; + CalcPlrInv(pnum, TRUE); - int dm; - if (plr[pnum]._pClass == PC_ROGUE) { - dm = plr[pnum]._pLevel * (plr[pnum]._pStrength + plr[pnum]._pDexterity) / 200; - } else { - dm = plr[pnum]._pStrength * plr[pnum]._pLevel / 100; - } + int dm; + if (plr[pnum]._pClass == PC_ROGUE) { + dm = plr[pnum]._pLevel * (plr[pnum]._pStrength + plr[pnum]._pDexterity) / 200; + } else { + dm = plr[pnum]._pStrength * plr[pnum]._pLevel / 100; + } - plr[pnum]._pDamageMod = dm; + plr[pnum]._pDamageMod = dm; } void __fastcall SetPlrVit(int pnum, int v) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("SetPlrVit: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("SetPlrVit: illegal player %d", pnum); + } - plr[pnum]._pBaseVit = v; + plr[pnum]._pBaseVit = v; - int hp = v << 6; - if (plr[pnum]._pClass == PC_WARRIOR) { - hp *= 2; - } + int hp = v << 6; + if (plr[pnum]._pClass == PC_WARRIOR) { + hp *= 2; + } - plr[pnum]._pHPBase = hp; - plr[pnum]._pMaxHPBase = hp; - CalcPlrInv(pnum, TRUE); + plr[pnum]._pHPBase = hp; + plr[pnum]._pMaxHPBase = hp; + CalcPlrInv(pnum, TRUE); } void __fastcall InitDungMsgs(int pnum) { - if ((DWORD)pnum >= MAX_PLRS) { - TermMsg("InitDungMsgs: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("InitDungMsgs: illegal player %d", pnum); + } - plr[pnum].pDungMsgs = 0; + plr[pnum].pDungMsgs = 0; } void __cdecl PlayDungMsgs() { - if ((DWORD)myplr >= MAX_PLRS) { - TermMsg("PlayDungMsgs: illegal player %d", myplr); - } + if ((DWORD)myplr >= MAX_PLRS) { + TermMsg("PlayDungMsgs: illegal player %d", myplr); + } - if (currlevel == 1 && !plr[myplr]._pLvlVisited[1] && gbMaxPlayers == 1 && !(plr[myplr].pDungMsgs & DMSG_CATHEDRAL)) { - sfxdelay = 40; - if (plr[myplr]._pClass == PC_WARRIOR) { - sfxdnum = PS_WARR97; - } else if (plr[myplr]._pClass == PC_ROGUE) { - sfxdnum = PS_ROGUE97; - } else if (plr[myplr]._pClass == PC_SORCERER) { - sfxdnum = PS_MAGE97; - } - plr[myplr].pDungMsgs = plr[myplr].pDungMsgs | DMSG_CATHEDRAL; - } else if (currlevel == 5 && !plr[myplr]._pLvlVisited[5] && gbMaxPlayers == 1 && !(plr[myplr].pDungMsgs & DMSG_CATACOMBS)) { - sfxdelay = 40; - if (plr[myplr]._pClass == PC_WARRIOR) { - sfxdnum = PS_WARR96B; - } else if (plr[myplr]._pClass == PC_ROGUE) { - sfxdnum = PS_ROGUE96; - } else if (plr[myplr]._pClass == PC_SORCERER) { - sfxdnum = PS_MAGE96; - } - plr[myplr].pDungMsgs |= DMSG_CATACOMBS; - } else if (currlevel == 9 && !plr[myplr]._pLvlVisited[9] && gbMaxPlayers == 1 && !(plr[myplr].pDungMsgs & DMSG_CAVES)) { - sfxdelay = 40; - if (plr[myplr]._pClass == PC_WARRIOR) { - sfxdnum = PS_WARR98; - } else if (plr[myplr]._pClass == PC_ROGUE) { - sfxdnum = PS_ROGUE98; - } else if (plr[myplr]._pClass == PC_SORCERER) { - sfxdnum = PS_MAGE98; - } - plr[myplr].pDungMsgs |= DMSG_CAVES; - } else if (currlevel == 13 && !plr[myplr]._pLvlVisited[13] && gbMaxPlayers == 1 && !(plr[myplr].pDungMsgs & DMSG_HELL)) { - sfxdelay = 40; - if (plr[myplr]._pClass == PC_WARRIOR) { - sfxdnum = PS_WARR99; - } else if (plr[myplr]._pClass == PC_ROGUE) { - sfxdnum = PS_ROGUE99; - } else if (plr[myplr]._pClass == PC_SORCERER) { - sfxdnum = PS_MAGE99; - } - plr[myplr].pDungMsgs |= DMSG_HELL; - } else if (currlevel == 16 && !plr[myplr]._pLvlVisited[15] && gbMaxPlayers == 1 && !(plr[myplr].pDungMsgs & DMSG_DIABLO)) { - sfxdelay = 40; - if (plr[myplr]._pClass == PC_WARRIOR || plr[myplr]._pClass == PC_ROGUE || plr[myplr]._pClass == PC_SORCERER) { - sfxdnum = PS_DIABLVLINT; - } - plr[myplr].pDungMsgs |= DMSG_DIABLO; - } else { - sfxdelay = 0; - } + if (currlevel == 1 && !plr[myplr]._pLvlVisited[1] && gbMaxPlayers == 1 && !(plr[myplr].pDungMsgs & DMSG_CATHEDRAL)) { + sfxdelay = 40; + if (plr[myplr]._pClass == PC_WARRIOR) { + sfxdnum = PS_WARR97; + } else if (plr[myplr]._pClass == PC_ROGUE) { + sfxdnum = PS_ROGUE97; + } else if (plr[myplr]._pClass == PC_SORCERER) { + sfxdnum = PS_MAGE97; + } + plr[myplr].pDungMsgs = plr[myplr].pDungMsgs | DMSG_CATHEDRAL; + } else if (currlevel == 5 && !plr[myplr]._pLvlVisited[5] && gbMaxPlayers == 1 && !(plr[myplr].pDungMsgs & DMSG_CATACOMBS)) { + sfxdelay = 40; + if (plr[myplr]._pClass == PC_WARRIOR) { + sfxdnum = PS_WARR96B; + } else if (plr[myplr]._pClass == PC_ROGUE) { + sfxdnum = PS_ROGUE96; + } else if (plr[myplr]._pClass == PC_SORCERER) { + sfxdnum = PS_MAGE96; + } + plr[myplr].pDungMsgs |= DMSG_CATACOMBS; + } else if (currlevel == 9 && !plr[myplr]._pLvlVisited[9] && gbMaxPlayers == 1 && !(plr[myplr].pDungMsgs & DMSG_CAVES)) { + sfxdelay = 40; + if (plr[myplr]._pClass == PC_WARRIOR) { + sfxdnum = PS_WARR98; + } else if (plr[myplr]._pClass == PC_ROGUE) { + sfxdnum = PS_ROGUE98; + } else if (plr[myplr]._pClass == PC_SORCERER) { + sfxdnum = PS_MAGE98; + } + plr[myplr].pDungMsgs |= DMSG_CAVES; + } else if (currlevel == 13 && !plr[myplr]._pLvlVisited[13] && gbMaxPlayers == 1 && !(plr[myplr].pDungMsgs & DMSG_HELL)) { + sfxdelay = 40; + if (plr[myplr]._pClass == PC_WARRIOR) { + sfxdnum = PS_WARR99; + } else if (plr[myplr]._pClass == PC_ROGUE) { + sfxdnum = PS_ROGUE99; + } else if (plr[myplr]._pClass == PC_SORCERER) { + sfxdnum = PS_MAGE99; + } + plr[myplr].pDungMsgs |= DMSG_HELL; + } else if (currlevel == 16 && !plr[myplr]._pLvlVisited[15] && gbMaxPlayers == 1 && !(plr[myplr].pDungMsgs & DMSG_DIABLO)) { + sfxdelay = 40; + if (plr[myplr]._pClass == PC_WARRIOR || plr[myplr]._pClass == PC_ROGUE || plr[myplr]._pClass == PC_SORCERER) { + sfxdnum = PS_DIABLVLINT; + } + plr[myplr].pDungMsgs |= DMSG_DIABLO; + } else { + sfxdelay = 0; + } } // 52A554: using guessed type int sfxdelay; diff --git a/Source/plrmsg.cpp b/Source/plrmsg.cpp index 5dc4422b..aa6015e6 100644 --- a/Source/plrmsg.cpp +++ b/Source/plrmsg.cpp @@ -9,139 +9,139 @@ const char text_color_from_player_num[MAX_PLRS + 1] = { COL_WHITE, COL_WHITE, CO void __fastcall plrmsg_delay(BOOL delay) { - int i; - _plrmsg *pMsg; - static DWORD plrmsg_ticks; + int i; + _plrmsg *pMsg; + static DWORD plrmsg_ticks; - if (delay) { - plrmsg_ticks = -GetTickCount(); - return; - } + if (delay) { + plrmsg_ticks = -GetTickCount(); + return; + } - plrmsg_ticks += GetTickCount(); - pMsg = plr_msgs; - for (i = 0; i < PMSG_COUNT; i++, pMsg++) - pMsg->time += plrmsg_ticks; + plrmsg_ticks += GetTickCount(); + pMsg = plr_msgs; + for (i = 0; i < PMSG_COUNT; i++, pMsg++) + pMsg->time += plrmsg_ticks; } char *__fastcall ErrorPlrMsg(const char *pszMsg) { - char *result; - _plrmsg *pMsg = &plr_msgs[plr_msg_slot]; - plr_msg_slot = (plr_msg_slot + 1) & (PMSG_COUNT - 1); - pMsg->player = MAX_PLRS; - pMsg->time = GetTickCount(); - result = strncpy(pMsg->str, pszMsg, sizeof(pMsg->str)); - pMsg->str[sizeof(pMsg->str) - 1] = '\0'; - return result; + char *result; + _plrmsg *pMsg = &plr_msgs[plr_msg_slot]; + plr_msg_slot = (plr_msg_slot + 1) & (PMSG_COUNT - 1); + pMsg->player = MAX_PLRS; + pMsg->time = GetTickCount(); + result = strncpy(pMsg->str, pszMsg, sizeof(pMsg->str)); + pMsg->str[sizeof(pMsg->str) - 1] = '\0'; + return result; } size_t EventPlrMsg(const char *pszFmt, ...) { - _plrmsg *pMsg; - va_list va; + _plrmsg *pMsg; + va_list va; - va_start(va, pszFmt); - pMsg = &plr_msgs[plr_msg_slot]; - plr_msg_slot = (plr_msg_slot + 1) & (PMSG_COUNT - 1); - pMsg->player = MAX_PLRS; - pMsg->time = GetTickCount(); - vsprintf(pMsg->str, pszFmt, va); - va_end(va); - return strlen(pMsg->str); + va_start(va, pszFmt); + pMsg = &plr_msgs[plr_msg_slot]; + plr_msg_slot = (plr_msg_slot + 1) & (PMSG_COUNT - 1); + pMsg->player = MAX_PLRS; + pMsg->time = GetTickCount(); + vsprintf(pMsg->str, pszFmt, va); + va_end(va); + return strlen(pMsg->str); } void __fastcall SendPlrMsg(int pnum, const char *pszStr) { - _plrmsg *pMsg = &plr_msgs[plr_msg_slot]; - plr_msg_slot = (plr_msg_slot + 1) & (PMSG_COUNT - 1); - pMsg->player = pnum; - pMsg->time = GetTickCount(); - strlen(plr[pnum]._pName); /* these are used in debug */ - strlen(pszStr); - sprintf(pMsg->str, "%s (lvl %d): %s", plr[pnum]._pName, plr[pnum]._pLevel, pszStr); + _plrmsg *pMsg = &plr_msgs[plr_msg_slot]; + plr_msg_slot = (plr_msg_slot + 1) & (PMSG_COUNT - 1); + pMsg->player = pnum; + pMsg->time = GetTickCount(); + strlen(plr[pnum]._pName); /* these are used in debug */ + strlen(pszStr); + sprintf(pMsg->str, "%s (lvl %d): %s", plr[pnum]._pName, plr[pnum]._pLevel, pszStr); } void __cdecl ClearPlrMsg() { - int i; - _plrmsg *pMsg = plr_msgs; - DWORD tick = GetTickCount(); + int i; + _plrmsg *pMsg = plr_msgs; + DWORD tick = GetTickCount(); - for (i = 0; i < PMSG_COUNT; i++, pMsg++) { - if ((int)(tick - pMsg->time) > 10000) - pMsg->str[0] = '\0'; - } + for (i = 0; i < PMSG_COUNT; i++, pMsg++) { + if ((int)(tick - pMsg->time) > 10000) + pMsg->str[0] = '\0'; + } } void __cdecl InitPlrMsg() { - memset(plr_msgs, 0, sizeof(plr_msgs)); - plr_msg_slot = 0; + memset(plr_msgs, 0, sizeof(plr_msgs)); + plr_msg_slot = 0; } void __cdecl DrawPlrMsg() { - int i; - int x = 74; - int y = 230; - int width = 620; - _plrmsg *pMsg; + int i; + int x = 74; + int y = 230; + int width = 620; + _plrmsg *pMsg; - if (chrflag || questlog) { - if (invflag || sbookflag) - return; - x = 394; - width = 300; - } else if (invflag || sbookflag) - width = 300; + if (chrflag || questlog) { + if (invflag || sbookflag) + return; + x = 394; + width = 300; + } else if (invflag || sbookflag) + width = 300; - pMsg = plr_msgs; - for (i = 0; i < 8; i++) { - if (pMsg->str[0]) - PrintPlrMsg(x, y, width, pMsg->str, text_color_from_player_num[pMsg->player]); - pMsg++; - y += 35; - } + pMsg = plr_msgs; + for (i = 0; i < 8; i++) { + if (pMsg->str[0]) + PrintPlrMsg(x, y, width, pMsg->str, text_color_from_player_num[pMsg->player]); + pMsg++; + y += 35; + } } void __fastcall PrintPlrMsg(unsigned int x, unsigned int y, unsigned int width, const char *str, unsigned char col) { - int line = 0; + int line = 0; - while (*str) { - unsigned char c; - int screen = screen_y_times_768[y] + x; - const char *sstr = str; - unsigned int len = 0; - const char *endstr = sstr; + while (*str) { + unsigned char c; + int screen = screen_y_times_768[y] + x; + const char *sstr = str; + unsigned int len = 0; + const char *endstr = sstr; - while (1) { - if (*sstr) { - c = fontidx[(unsigned char)*sstr++]; - c = fontframe[c]; - len += fontkern[c] + 1; - if (!c) // allow wordwrap on blank glyph - endstr = sstr; - else if (len >= width) - break; - } else { - endstr = sstr; - break; - } - } + while (1) { + if (*sstr) { + c = fontidx[(unsigned char)*sstr++]; + c = fontframe[c]; + len += fontkern[c] + 1; + if (!c) // allow wordwrap on blank glyph + endstr = sstr; + else if (len >= width) + break; + } else { + endstr = sstr; + break; + } + } - while (str < endstr) { - c = fontidx[(unsigned char)*str++]; - c = fontframe[c]; - if (c) - CPrintString(screen, c, col); - screen += fontkern[c] + 1; - } + while (str < endstr) { + c = fontidx[(unsigned char)*str++]; + c = fontframe[c]; + if (c) + CPrintString(screen, c, col); + screen += fontkern[c] + 1; + } - y += 10; - line++; - if (line == 3) - break; - } + y += 10; + line++; + if (line == 3) + break; + } } diff --git a/Source/portal.cpp b/Source/portal.cpp index bb34c0cf..95c1f84b 100644 --- a/Source/portal.cpp +++ b/Source/portal.cpp @@ -10,167 +10,167 @@ int WarpDropY[MAXPORTAL] = { 40, 40, 40, 40 }; void __cdecl InitPortals() { - int i; + int i; - for (i = 0; i < MAXPORTAL; i++) { - if (delta_portal_inited(i)) - portal[i].open = FALSE; - } + for (i = 0; i < MAXPORTAL; i++) { + if (delta_portal_inited(i)) + portal[i].open = FALSE; + } } void __fastcall SetPortalStats(int i, BOOL o, int x, int y, int lvl, int lvltype) { - portal[i].setlvl = FALSE; - portal[i].x = x; - portal[i].y = y; - portal[i].open = o; - portal[i].level = lvl; - portal[i].ltype = lvltype; + portal[i].setlvl = FALSE; + portal[i].x = x; + portal[i].y = y; + portal[i].open = o; + portal[i].level = lvl; + portal[i].ltype = lvltype; } void __fastcall AddWarpMissile(int i, int x, int y) { - int mi; + int mi; - missiledata[MIS_TOWN].mlSFX = -1; - dMissile[x][y] = 0; - mi = AddMissile(0, 0, x, y, 0, MIS_TOWN, 0, i, 0, 0); + missiledata[MIS_TOWN].mlSFX = -1; + dMissile[x][y] = 0; + mi = AddMissile(0, 0, x, y, 0, MIS_TOWN, 0, i, 0, 0); - if (mi != -1) { - SetMissDir(mi, 1); + if (mi != -1) { + SetMissDir(mi, 1); - if (currlevel != 0) - missile[mi]._mlid = AddLight(missile[mi]._mix, missile[mi]._miy, 15); + if (currlevel != 0) + missile[mi]._mlid = AddLight(missile[mi]._mix, missile[mi]._miy, 15); - missiledata[MIS_TOWN].mlSFX = LS_SENTINEL; - } + missiledata[MIS_TOWN].mlSFX = LS_SENTINEL; + } } void __cdecl SyncPortals() { - int i; + int i; - for (i = 0; i < MAXPORTAL; i++) { - if (!portal[i].open) - continue; - if (currlevel == 0) - AddWarpMissile(i, WarpDropX[i], WarpDropY[i]); - else { - int lvl = currlevel; - if (setlevel) - lvl = setlvlnum; - if (portal[i].level == lvl) - AddWarpMissile(i, portal[i].x, portal[i].y); - } - } + for (i = 0; i < MAXPORTAL; i++) { + if (!portal[i].open) + continue; + if (currlevel == 0) + AddWarpMissile(i, WarpDropX[i], WarpDropY[i]); + else { + int lvl = currlevel; + if (setlevel) + lvl = setlvlnum; + if (portal[i].level == lvl) + AddWarpMissile(i, portal[i].x, portal[i].y); + } + } } // 5CF31D: using guessed type char setlevel; void __fastcall AddInTownPortal(int i) { - AddWarpMissile(i, WarpDropX[i], WarpDropY[i]); + AddWarpMissile(i, WarpDropX[i], WarpDropY[i]); } void __fastcall ActivatePortal(int i, int x, int y, int lvl, int lvltype, BOOL sp) { - portal[i].open = TRUE; + portal[i].open = TRUE; - if (lvl != 0) { - portal[i].x = x; - portal[i].y = y; - portal[i].level = lvl; - portal[i].ltype = lvltype; - portal[i].setlvl = sp; - } + if (lvl != 0) { + portal[i].x = x; + portal[i].y = y; + portal[i].level = lvl; + portal[i].ltype = lvltype; + portal[i].setlvl = sp; + } } void __fastcall DeactivatePortal(int i) { - portal[i].open = FALSE; + portal[i].open = FALSE; } BOOL __fastcall PortalOnLevel(int i) { - if (portal[i].level == currlevel) - return TRUE; - else - return currlevel == 0; + if (portal[i].level == currlevel) + return TRUE; + else + return currlevel == 0; } void __fastcall RemovePortalMissile(int id) { - int i; - int mi; + int i; + int mi; - for (i = 0; i < nummissiles; i++) { - mi = missileactive[i]; - if (missile[mi]._mitype == MIS_TOWN && missile[mi]._misource == id) { - dFlags[missile[mi]._mix][missile[mi]._miy] &= ~DFLAG_MISSILE; - dMissile[missile[mi]._mix][missile[mi]._miy] = 0; + for (i = 0; i < nummissiles; i++) { + mi = missileactive[i]; + if (missile[mi]._mitype == MIS_TOWN && missile[mi]._misource == id) { + dFlags[missile[mi]._mix][missile[mi]._miy] &= ~DFLAG_MISSILE; + dMissile[missile[mi]._mix][missile[mi]._miy] = 0; - if (portal[id].level) - AddUnLight(missile[mi]._mlid); + if (portal[id].level) + AddUnLight(missile[mi]._mlid); - DeleteMissile(mi, i); - } - } + DeleteMissile(mi, i); + } + } } void __fastcall SetCurrentPortal(int p) { - portalindex = p; + portalindex = p; } void __cdecl GetPortalLevel() { - if (currlevel) { - setlevel = 0; - currlevel = 0; - leveltype = 0; - plr[myplr].plrlevel = 0; - } else { - if (portal[portalindex].setlvl) { - setlevel = 1; - setlvlnum = portal[portalindex].level; - } else { - setlevel = 0; - } + if (currlevel) { + setlevel = 0; + currlevel = 0; + leveltype = 0; + plr[myplr].plrlevel = 0; + } else { + if (portal[portalindex].setlvl) { + setlevel = 1; + setlvlnum = portal[portalindex].level; + } else { + setlevel = 0; + } - currlevel = portal[portalindex].level; - leveltype = portal[portalindex].ltype; - plr[myplr].plrlevel = portal[portalindex].level; + currlevel = portal[portalindex].level; + leveltype = portal[portalindex].ltype; + plr[myplr].plrlevel = portal[portalindex].level; - if (portalindex == myplr) { - NetSendCmd(TRUE, CMD_DEACTIVATEPORTAL); - DeactivatePortal(portalindex); - } - } + if (portalindex == myplr) { + NetSendCmd(TRUE, CMD_DEACTIVATEPORTAL); + DeactivatePortal(portalindex); + } + } } // 5CF31D: using guessed type char setlevel; void __cdecl GetPortalLvlPos() { - if (currlevel == 0) { - ViewX = WarpDropX[portalindex] + 1; - ViewY = WarpDropY[portalindex] + 1; - } else { - ViewX = portal[portalindex].x; - ViewY = portal[portalindex].y; + if (currlevel == 0) { + ViewX = WarpDropX[portalindex] + 1; + ViewY = WarpDropY[portalindex] + 1; + } else { + ViewX = portal[portalindex].x; + ViewY = portal[portalindex].y; - if (portalindex != myplr) { - ViewX++; - ViewY++; - } - } + if (portalindex != myplr) { + ViewX++; + ViewY++; + } + } } BOOL __fastcall PosOkPortal(int lvl, int x, int y) { - int i; + int i; - for (i = 0; i < MAXPORTAL; i++) { - if (portal[i].open && portal[i].level == lvl && ((portal[i].x == x && portal[i].y == y) || (portal[i].x == x - 1 && portal[i].y == y - 1))) - return TRUE; - } - return FALSE; + for (i = 0; i < MAXPORTAL; i++) { + if (portal[i].open && portal[i].level == lvl && ((portal[i].x == x && portal[i].y == y) || (portal[i].x == x - 1 && portal[i].y == y - 1))) + return TRUE; + } + return FALSE; } diff --git a/Source/quests.cpp b/Source/quests.cpp index e31b177c..ad7b3148 100644 --- a/Source/quests.cpp +++ b/Source/quests.cpp @@ -17,7 +17,7 @@ int ALLQUESTS; // idb int ReturnLvl; // idb QuestData questlist[MAXQUESTS] = { - // clang-format off + // clang-format off // _qdlvl, _qdmultlvl, _qlvlt, _qdtype, _qdrnd, _qslvl, _qflags, _qdmsg, _qlstr { 5, -1, DTYPE_NONE, QTYPE_INFRA, 100, 0, 0, QUEST_INFRA5, "The Magic Rock" }, { 9, -1, DTYPE_NONE, QTYPE_BLKM, 100, 0, 0, QUEST_MUSH8, "Black Mushroom" }, @@ -35,16 +35,16 @@ QuestData questlist[MAXQUESTS] = { { 2, -1, DTYPE_CAVES, QTYPE_PW, 100, 4, 0, QUEST_POISON3, "Poisoned Water Supply" }, { 6, -1, DTYPE_CATACOMBS, QTYPE_BONE, 100, 2, 0, QUEST_BONER, "The Chamber of Bone" }, { 15, 15, DTYPE_CATHEDRAL, QTYPE_VB, 100, 5, 1, QUEST_VILE1, "Archbishop Lazarus" } - // clang-format on + // clang-format on }; char questxoff[7] = { 0, -1, 0, -1, -2, -1, -2 }; char questyoff[7] = { 0, 0, -1, -1, -1, -2, -2 }; char *questtrigstr[5] = { - "King Leoric's Tomb", - "The Chamber of Bone", - "Maze", - "A Dark Passage", - "Unholy Altar" + "King Leoric's Tomb", + "The Chamber of Bone", + "Maze", + "A Dark Passage", + "Unholy Altar" }; int QuestGroup1[3] = { QTYPE_BUTCH, QTYPE_BOL, QTYPE_GARB }; int QuestGroup2[3] = { QTYPE_BLIND, QTYPE_INFRA, QTYPE_BLOOD }; @@ -53,108 +53,108 @@ int QuestGroup4[2] = { QTYPE_VEIL, QTYPE_WARLRD }; void __cdecl InitQuests() { - char v0; // dl - unsigned char *v1; // esi - unsigned char *v2; // eax - unsigned char *v3; // ecx - int *v4; // eax - int v5; // ebp - unsigned int v6; // edi - //int v7; // eax - unsigned char v8; // al - unsigned char v9; // al - char v10; // al - int v13; // eax - int v15; // eax - int v17; // eax - int v19; // eax - char v20; // [esp+8h] [ebp-4h] + char v0; // dl + unsigned char *v1; // esi + unsigned char *v2; // eax + unsigned char *v3; // ecx + int *v4; // eax + int v5; // ebp + unsigned int v6; // edi + //int v7; // eax + unsigned char v8; // al + unsigned char v9; // al + char v10; // al + int v13; // eax + int v15; // eax + int v17; // eax + int v19; // eax + char v20; // [esp+8h] [ebp-4h] - v0 = gbMaxPlayers; - v1 = &quests[0]._qactive; - if (gbMaxPlayers == 1) { - v2 = &quests[0]._qactive; - do { - *v2 = 0; - v2 += 24; - } while ((signed int)v2 < (signed int)&quests[MAXQUESTS]._qactive); - } else { - v3 = &quests[0]._qactive; - v4 = &questlist[0]._qflags; - do { - if (!(*(_BYTE *)v4 & 1)) - *v3 = 0; - v4 += 5; - v3 += 24; - } while ((signed int)v4 < (signed int)&questlist[MAXQUESTS]._qflags); - } - v5 = 0; - questlog = 0; - ALLQUESTS = 1; - WaterDone = 0; - v20 = 0; - v6 = 0; - do { - if ((unsigned char)v0 <= 1u || questlist[v6]._qflags & 1) { - *(v1 - 1) = questlist[v6]._qdtype; - if ((unsigned char)v0 <= 1u) { - v8 = questlist[v6]._qdlvl; - *v1 = 1; - *(v1 - 2) = v8; - v1[13] = 0; - *(_DWORD *)(v1 + 18) = 0; - } else { - *(v1 - 2) = questlist[v6]._qdmultlvl; - //_LOBYTE(v7) = delta_quest_inited(v5); - if (!delta_quest_inited(v5)) { - *v1 = 1; - v1[13] = 0; - *(_DWORD *)(v1 + 18) = 0; - } - v0 = gbMaxPlayers; - ++v5; - } - v9 = questlist[v6]._qslvl; - *(_DWORD *)(v1 + 2) = 0; - v1[10] = v9; - v1[11] = v20; - v1[1] = questlist[v6]._qlvlt; - v10 = questlist[v6]._qdmsg; - *(_DWORD *)(v1 + 6) = 0; - v1[14] = 0; - v1[12] = v10; - } - ++v20; - ++v6; - v1 += 24; - } while (v6 < MAXQUESTS); - if (v0 == 1) { - SetRndSeed(glSeedTbl[15]); - if (random(0, 2)) - quests[QTYPE_PW]._qactive = 0; - else - quests[QTYPE_KING]._qactive = 0; - v13 = random(0, 3); - quests[QuestGroup1[v13]]._qactive = 0; - v15 = random(0, 3); - quests[QuestGroup2[v15]]._qactive = 0; - v17 = random(0, 3); - quests[QuestGroup3[v17]]._qactive = 0; - v19 = random(0, 2); - v0 = gbMaxPlayers; - quests[QuestGroup4[v19]]._qactive = 0; - } + v0 = gbMaxPlayers; + v1 = &quests[0]._qactive; + if (gbMaxPlayers == 1) { + v2 = &quests[0]._qactive; + do { + *v2 = 0; + v2 += 24; + } while ((signed int)v2 < (signed int)&quests[MAXQUESTS]._qactive); + } else { + v3 = &quests[0]._qactive; + v4 = &questlist[0]._qflags; + do { + if (!(*(_BYTE *)v4 & 1)) + *v3 = 0; + v4 += 5; + v3 += 24; + } while ((signed int)v4 < (signed int)&questlist[MAXQUESTS]._qflags); + } + v5 = 0; + questlog = 0; + ALLQUESTS = 1; + WaterDone = 0; + v20 = 0; + v6 = 0; + do { + if ((unsigned char)v0 <= 1u || questlist[v6]._qflags & 1) { + *(v1 - 1) = questlist[v6]._qdtype; + if ((unsigned char)v0 <= 1u) { + v8 = questlist[v6]._qdlvl; + *v1 = 1; + *(v1 - 2) = v8; + v1[13] = 0; + *(_DWORD *)(v1 + 18) = 0; + } else { + *(v1 - 2) = questlist[v6]._qdmultlvl; + //_LOBYTE(v7) = delta_quest_inited(v5); + if (!delta_quest_inited(v5)) { + *v1 = 1; + v1[13] = 0; + *(_DWORD *)(v1 + 18) = 0; + } + v0 = gbMaxPlayers; + ++v5; + } + v9 = questlist[v6]._qslvl; + *(_DWORD *)(v1 + 2) = 0; + v1[10] = v9; + v1[11] = v20; + v1[1] = questlist[v6]._qlvlt; + v10 = questlist[v6]._qdmsg; + *(_DWORD *)(v1 + 6) = 0; + v1[14] = 0; + v1[12] = v10; + } + ++v20; + ++v6; + v1 += 24; + } while (v6 < MAXQUESTS); + if (v0 == 1) { + SetRndSeed(glSeedTbl[15]); + if (random(0, 2)) + quests[QTYPE_PW]._qactive = 0; + else + quests[QTYPE_KING]._qactive = 0; + v13 = random(0, 3); + quests[QuestGroup1[v13]]._qactive = 0; + v15 = random(0, 3); + quests[QuestGroup2[v15]]._qactive = 0; + v17 = random(0, 3); + quests[QuestGroup3[v17]]._qactive = 0; + v19 = random(0, 2); + v0 = gbMaxPlayers; + quests[QuestGroup4[v19]]._qactive = 0; + } #ifdef _DEBUG - if (questdebug != -1) - quests[questdebug]._qactive = 2; + if (questdebug != -1) + quests[questdebug]._qactive = 2; #endif - if (!quests[QTYPE_KING]._qactive) - quests[QTYPE_KING]._qvar2 = 2; - if (!quests[QTYPE_INFRA]._qactive) - quests[QTYPE_INFRA]._qvar2 = 2; - quests[QTYPE_BOL]._qvar1 = 1; - if (v0 != 1) - quests[QTYPE_VB]._qvar1 = 2; + if (!quests[QTYPE_KING]._qactive) + quests[QTYPE_KING]._qvar2 = 2; + if (!quests[QTYPE_INFRA]._qactive) + quests[QTYPE_INFRA]._qvar2 = 2; + quests[QTYPE_BOL]._qvar1 = 1; + if (v0 != 1) + quests[QTYPE_VB]._qvar1 = 2; } // 679660: using guessed type char gbMaxPlayers; // 69BD04: using guessed type int questlog; @@ -162,77 +162,77 @@ void __cdecl InitQuests() void __cdecl CheckQuests() { - //int v0; // eax - unsigned char *v1; // esi - unsigned char v2; // cl + //int v0; // eax + unsigned char *v1; // esi + unsigned char v2; // cl - //_LOBYTE(v0) = QuestStatus(QTYPE_VB); - if (QuestStatus(QTYPE_VB)) { - if (gbMaxPlayers == 1) - goto LABEL_6; - if (quests[QTYPE_VB]._qvar1 == 2) { - AddObject(OBJ_ALTBOY, 2 * setpc_x + 20, 2 * setpc_y + 22); - quests[QTYPE_VB]._qvar1 = 3; - NetSendCmdQuest(TRUE, 0xFu); - } - } - if (gbMaxPlayers != 1) - return; + //_LOBYTE(v0) = QuestStatus(QTYPE_VB); + if (QuestStatus(QTYPE_VB)) { + if (gbMaxPlayers == 1) + goto LABEL_6; + if (quests[QTYPE_VB]._qvar1 == 2) { + AddObject(OBJ_ALTBOY, 2 * setpc_x + 20, 2 * setpc_y + 22); + quests[QTYPE_VB]._qvar1 = 3; + NetSendCmdQuest(TRUE, 0xFu); + } + } + if (gbMaxPlayers != 1) + return; LABEL_6: - if (currlevel == quests[QTYPE_VB]._qlevel && !setlevel && quests[QTYPE_VB]._qvar1 >= 2u) { - if (quests[QTYPE_VB]._qactive != 2 && quests[QTYPE_VB]._qactive != 3) - goto LABEL_29; - if (!quests[QTYPE_VB]._qvar2 || quests[QTYPE_VB]._qvar2 == 2) { - quests[QTYPE_VB]._qtx = 2 * quests[QTYPE_VB]._qtx + 16; - quests[QTYPE_VB]._qty = 2 * quests[QTYPE_VB]._qty + 16; - AddMissile(quests[QTYPE_VB]._qtx, quests[QTYPE_VB]._qty, quests[QTYPE_VB]._qtx, quests[QTYPE_VB]._qty, 0, 65, 0, myplr, 0, 0); - quests[QTYPE_VB]._qvar2 = 1; - if (quests[QTYPE_VB]._qactive == 2) - quests[QTYPE_VB]._qvar1 = 3; - } - } - if (quests[QTYPE_VB]._qactive == 3) { - if (!setlevel) - goto LABEL_29; - if (setlvlnum == SL_VILEBETRAYER && quests[QTYPE_VB]._qvar2 == 4) { - AddMissile(35, 32, 35, 32, 0, 65, 0, myplr, 0, 0); - quests[QTYPE_VB]._qvar2 = 3; - } - } - if (setlevel) { - if (setlvlnum == quests[QTYPE_PW]._qslvl - && quests[QTYPE_PW]._qactive != 1 - && leveltype == quests[QTYPE_PW]._qlvltype - && nummonsters == 4 - && quests[QTYPE_PW]._qactive != 3) { - quests[QTYPE_PW]._qactive = 3; - PlaySfxLoc(IS_QUESTDN, plr[myplr].WorldX, plr[myplr].WorldY); - LoadPalette("Levels\\L3Data\\L3pwater.pal"); - WaterDone = 32; - } - if (WaterDone > 0) { - palette_update_quest_palette(WaterDone); - --WaterDone; - } - return; - } + if (currlevel == quests[QTYPE_VB]._qlevel && !setlevel && quests[QTYPE_VB]._qvar1 >= 2u) { + if (quests[QTYPE_VB]._qactive != 2 && quests[QTYPE_VB]._qactive != 3) + goto LABEL_29; + if (!quests[QTYPE_VB]._qvar2 || quests[QTYPE_VB]._qvar2 == 2) { + quests[QTYPE_VB]._qtx = 2 * quests[QTYPE_VB]._qtx + 16; + quests[QTYPE_VB]._qty = 2 * quests[QTYPE_VB]._qty + 16; + AddMissile(quests[QTYPE_VB]._qtx, quests[QTYPE_VB]._qty, quests[QTYPE_VB]._qtx, quests[QTYPE_VB]._qty, 0, 65, 0, myplr, 0, 0); + quests[QTYPE_VB]._qvar2 = 1; + if (quests[QTYPE_VB]._qactive == 2) + quests[QTYPE_VB]._qvar1 = 3; + } + } + if (quests[QTYPE_VB]._qactive == 3) { + if (!setlevel) + goto LABEL_29; + if (setlvlnum == SL_VILEBETRAYER && quests[QTYPE_VB]._qvar2 == 4) { + AddMissile(35, 32, 35, 32, 0, 65, 0, myplr, 0, 0); + quests[QTYPE_VB]._qvar2 = 3; + } + } + if (setlevel) { + if (setlvlnum == quests[QTYPE_PW]._qslvl + && quests[QTYPE_PW]._qactive != 1 + && leveltype == quests[QTYPE_PW]._qlvltype + && nummonsters == 4 + && quests[QTYPE_PW]._qactive != 3) { + quests[QTYPE_PW]._qactive = 3; + PlaySfxLoc(IS_QUESTDN, plr[myplr].WorldX, plr[myplr].WorldY); + LoadPalette("Levels\\L3Data\\L3pwater.pal"); + WaterDone = 32; + } + if (WaterDone > 0) { + palette_update_quest_palette(WaterDone); + --WaterDone; + } + return; + } LABEL_29: - if (plr[myplr]._pmode == PM_STAND) { - v1 = &quests[0]._qactive; - do { - if (currlevel == *(v1 - 2)) { - v2 = v1[10]; - if (v2) { - if (*v1 && plr[myplr].WorldX == *(_DWORD *)(v1 + 2) && plr[myplr].WorldY == *(_DWORD *)(v1 + 6)) { - if (v1[1] != -1) - setlvltype = v1[1]; - StartNewLvl(myplr, WM_DIABSETLVL, v2); - } - } - } - v1 += 24; - } while ((signed int)v1 < (signed int)&quests[MAXQUESTS]._qactive); - } + if (plr[myplr]._pmode == PM_STAND) { + v1 = &quests[0]._qactive; + do { + if (currlevel == *(v1 - 2)) { + v2 = v1[10]; + if (v2) { + if (*v1 && plr[myplr].WorldX == *(_DWORD *)(v1 + 2) && plr[myplr].WorldY == *(_DWORD *)(v1 + 6)) { + if (v1[1] != -1) + setlvltype = v1[1]; + StartNewLvl(myplr, WM_DIABSETLVL, v2); + } + } + } + v1 += 24; + } while ((signed int)v1 < (signed int)&quests[MAXQUESTS]._qactive); + } } // 5BB1ED: using guessed type char leveltype; // 5CF31C: using guessed type char setlvltype; @@ -242,681 +242,681 @@ LABEL_29: bool __cdecl ForceQuests() { - QuestStruct *v0; // eax - int v1; // esi - int v2; // edi - int v3; // edx + QuestStruct *v0; // eax + int v1; // esi + int v2; // edi + int v3; // edx - if (gbMaxPlayers != 1) - return 0; - v0 = (QuestStruct *)((char *)quests + 12); - while (v0 == (QuestStruct *)&quests[15]._qslvl || currlevel != v0[-1]._qslvl || !v0->_qlevel) { - LABEL_10: - ++v0; - if ((signed int)v0 >= (signed int)&quests[MAXQUESTS]._qslvl) /* fix */ - return 0; - } - v1 = *(_DWORD *)&v0[-1]._qvar2; - v2 = v0[-1]._qlog; - v3 = 0; - while (v1 + questxoff[v3] != cursmx || v2 + questyoff[v3] != cursmy) { - if (++v3 >= 7) - goto LABEL_10; - } - sprintf(infostr, "To %s", questtrigstr[(unsigned char)quests[(unsigned char)v0->_qtype]._qslvl - 1]); - cursmx = v1; - cursmy = v2; - return 1; + if (gbMaxPlayers != 1) + return 0; + v0 = (QuestStruct *)((char *)quests + 12); + while (v0 == (QuestStruct *)&quests[15]._qslvl || currlevel != v0[-1]._qslvl || !v0->_qlevel) { + LABEL_10: + ++v0; + if ((signed int)v0 >= (signed int)&quests[MAXQUESTS]._qslvl) /* fix */ + return 0; + } + v1 = *(_DWORD *)&v0[-1]._qvar2; + v2 = v0[-1]._qlog; + v3 = 0; + while (v1 + questxoff[v3] != cursmx || v2 + questyoff[v3] != cursmy) { + if (++v3 >= 7) + goto LABEL_10; + } + sprintf(infostr, "To %s", questtrigstr[(unsigned char)quests[(unsigned char)v0->_qtype]._qslvl - 1]); + cursmx = v1; + cursmy = v2; + return 1; } // 679660: using guessed type char gbMaxPlayers; BOOL __fastcall QuestStatus(int i) { - BOOL result; // al + BOOL result; // al - if (setlevel - || currlevel != quests[i]._qlevel - || !quests[i]._qactive - || (result = 1, gbMaxPlayers != 1) && !(questlist[i]._qflags & 1)) { - result = FALSE; - } - return result; + if (setlevel + || currlevel != quests[i]._qlevel + || !quests[i]._qactive + || (result = 1, gbMaxPlayers != 1) && !(questlist[i]._qflags & 1)) { + result = FALSE; + } + return result; } // 5CF31D: using guessed type char setlevel; // 679660: using guessed type char gbMaxPlayers; void __fastcall CheckQuestKill(int m, BOOL sendmsg) { - int v2; // ecx - char v3; // al - unsigned char v5; // dl - char *v7; // ecx - int v10; // edi - int(*v11)[112]; // esi - signed int v12; // ecx - int *v13; // eax - int(*v14)[112]; // ebx + int v2; // ecx + char v3; // al + unsigned char v5; // dl + char *v7; // ecx + int v10; // edi + int(*v11)[112]; // esi + signed int v12; // ecx + int *v13; // eax + int(*v14)[112]; // ebx - v2 = m; - v3 = monster[v2].MType->mtype; - if (v3 == MT_SKING) { - quests[QTYPE_KING]._qactive = 3; - sfxdelay = 30; - if (plr[myplr]._pClass == PC_WARRIOR) { - sfxdnum = PS_WARR82; - } else if (plr[myplr]._pClass == PC_ROGUE) { - sfxdnum = PS_ROGUE82; - } else if (plr[myplr]._pClass == PC_SORCERER) { - sfxdnum = PS_MAGE82; - } + v2 = m; + v3 = monster[v2].MType->mtype; + if (v3 == MT_SKING) { + quests[QTYPE_KING]._qactive = 3; + sfxdelay = 30; + if (plr[myplr]._pClass == PC_WARRIOR) { + sfxdnum = PS_WARR82; + } else if (plr[myplr]._pClass == PC_ROGUE) { + sfxdnum = PS_ROGUE82; + } else if (plr[myplr]._pClass == PC_SORCERER) { + sfxdnum = PS_MAGE82; + } - if (sendmsg) { - v5 = 12; - LABEL_10: - NetSendCmdQuest(TRUE, v5); - return; - } - } else { - if (v3 != MT_CLEAVER) { - v7 = monster[v2].mName; - if (v7 == UniqMonst[0].mName) { - quests[QTYPE_GARB]._qactive = 3; - sfxdelay = 30; - if (plr[myplr]._pClass == PC_WARRIOR) { - sfxdnum = PS_WARR61; - } else if (plr[myplr]._pClass == PC_ROGUE) { - sfxdnum = PS_ROGUE61; - } else if (plr[myplr]._pClass == PC_SORCERER) { - sfxdnum = PS_MAGE61; - } - return; - } - if (v7 == UniqMonst[2].mName) { - quests[QTYPE_ZHAR]._qactive = 3; - sfxdelay = 30; - if (plr[myplr]._pClass == PC_WARRIOR) { - sfxdnum = PS_WARR62; - } else if (plr[myplr]._pClass == PC_ROGUE) { - sfxdnum = PS_ROGUE62; - } else if (plr[myplr]._pClass == PC_SORCERER) { - sfxdnum = PS_MAGE62; - } - return; - } - if (v7 == UniqMonst[4].mName) { - if (gbMaxPlayers != 1) { - quests[QTYPE_VB]._qactive = 3; - quests[QTYPE_VB]._qvar1 = 7; - sfxdelay = 30; - quests[QTYPE_MOD]._qactive = 2; - v10 = 0; - v11 = dPiece; - do { - v12 = 0; - v13 = &trigs[trigflag[4]]._ty; - v14 = v11; - do { - if ((*v14)[0] == 370) { - ++trigflag[4]; - *(v13 - 1) = v12; - *v13 = v10; - v13[1] = 1026; - v13 += 4; - } - ++v12; - ++v14; - } while (v12 < 112); - v11 = (int(*)[112])((char *)v11 + 4); - ++v10; - } while ((signed int)v11 < (signed int)dPiece[1]); - if (plr[myplr]._pClass == PC_WARRIOR) { - sfxdnum = PS_WARR83; - } else if (plr[myplr]._pClass == PC_ROGUE) { - sfxdnum = PS_ROGUE83; - } else if (plr[myplr]._pClass == PC_SORCERER) { - sfxdnum = PS_MAGE83; - } - if (sendmsg) { - NetSendCmdQuest(TRUE, 0xFu); - v5 = 5; - goto LABEL_10; - } - return; - } - if (v7 == UniqMonst[4].mName && gbMaxPlayers == 1) { - quests[QTYPE_VB]._qactive = 3; - sfxdelay = 30; - InitVPTriggers(); - quests[QTYPE_VB]._qvar1 = 7; - quests[QTYPE_VB]._qvar2 = 4; - quests[QTYPE_MOD]._qactive = 2; - AddMissile(35, 32, 35, 32, 0, 65, 0, myplr, 0, 0); - if (plr[myplr]._pClass == PC_WARRIOR) { - sfxdnum = PS_WARR83; - } else if (plr[myplr]._pClass == PC_ROGUE) { - sfxdnum = PS_ROGUE83; - } else if (plr[myplr]._pClass == PC_SORCERER) { - sfxdnum = PS_MAGE83; - } - return; - } - } - if (v7 == UniqMonst[8].mName) { - quests[QTYPE_WARLRD]._qactive = 3; - sfxdelay = 30; - if (plr[myplr]._pClass == PC_WARRIOR) { - sfxdnum = PS_WARR94; - } else if (plr[myplr]._pClass == PC_ROGUE) { - sfxdnum = PS_ROGUE94; - } else if (plr[myplr]._pClass == PC_SORCERER) { - sfxdnum = PS_MAGE94; - } - } - return; - } - quests[QTYPE_BUTCH]._qactive = 3; - sfxdelay = 30; - if (plr[myplr]._pClass == PC_WARRIOR) { - sfxdnum = PS_WARR80; - } else if (plr[myplr]._pClass == PC_ROGUE) { - sfxdnum = PS_ROGUE80; - } else if (plr[myplr]._pClass == PC_SORCERER) { - sfxdnum = PS_MAGE80; - } - if (sendmsg) { - v5 = 6; - goto LABEL_10; - } - } + if (sendmsg) { + v5 = 12; + LABEL_10: + NetSendCmdQuest(TRUE, v5); + return; + } + } else { + if (v3 != MT_CLEAVER) { + v7 = monster[v2].mName; + if (v7 == UniqMonst[0].mName) { + quests[QTYPE_GARB]._qactive = 3; + sfxdelay = 30; + if (plr[myplr]._pClass == PC_WARRIOR) { + sfxdnum = PS_WARR61; + } else if (plr[myplr]._pClass == PC_ROGUE) { + sfxdnum = PS_ROGUE61; + } else if (plr[myplr]._pClass == PC_SORCERER) { + sfxdnum = PS_MAGE61; + } + return; + } + if (v7 == UniqMonst[2].mName) { + quests[QTYPE_ZHAR]._qactive = 3; + sfxdelay = 30; + if (plr[myplr]._pClass == PC_WARRIOR) { + sfxdnum = PS_WARR62; + } else if (plr[myplr]._pClass == PC_ROGUE) { + sfxdnum = PS_ROGUE62; + } else if (plr[myplr]._pClass == PC_SORCERER) { + sfxdnum = PS_MAGE62; + } + return; + } + if (v7 == UniqMonst[4].mName) { + if (gbMaxPlayers != 1) { + quests[QTYPE_VB]._qactive = 3; + quests[QTYPE_VB]._qvar1 = 7; + sfxdelay = 30; + quests[QTYPE_MOD]._qactive = 2; + v10 = 0; + v11 = dPiece; + do { + v12 = 0; + v13 = &trigs[trigflag[4]]._ty; + v14 = v11; + do { + if ((*v14)[0] == 370) { + ++trigflag[4]; + *(v13 - 1) = v12; + *v13 = v10; + v13[1] = 1026; + v13 += 4; + } + ++v12; + ++v14; + } while (v12 < 112); + v11 = (int(*)[112])((char *)v11 + 4); + ++v10; + } while ((signed int)v11 < (signed int)dPiece[1]); + if (plr[myplr]._pClass == PC_WARRIOR) { + sfxdnum = PS_WARR83; + } else if (plr[myplr]._pClass == PC_ROGUE) { + sfxdnum = PS_ROGUE83; + } else if (plr[myplr]._pClass == PC_SORCERER) { + sfxdnum = PS_MAGE83; + } + if (sendmsg) { + NetSendCmdQuest(TRUE, 0xFu); + v5 = 5; + goto LABEL_10; + } + return; + } + if (v7 == UniqMonst[4].mName && gbMaxPlayers == 1) { + quests[QTYPE_VB]._qactive = 3; + sfxdelay = 30; + InitVPTriggers(); + quests[QTYPE_VB]._qvar1 = 7; + quests[QTYPE_VB]._qvar2 = 4; + quests[QTYPE_MOD]._qactive = 2; + AddMissile(35, 32, 35, 32, 0, 65, 0, myplr, 0, 0); + if (plr[myplr]._pClass == PC_WARRIOR) { + sfxdnum = PS_WARR83; + } else if (plr[myplr]._pClass == PC_ROGUE) { + sfxdnum = PS_ROGUE83; + } else if (plr[myplr]._pClass == PC_SORCERER) { + sfxdnum = PS_MAGE83; + } + return; + } + } + if (v7 == UniqMonst[8].mName) { + quests[QTYPE_WARLRD]._qactive = 3; + sfxdelay = 30; + if (plr[myplr]._pClass == PC_WARRIOR) { + sfxdnum = PS_WARR94; + } else if (plr[myplr]._pClass == PC_ROGUE) { + sfxdnum = PS_ROGUE94; + } else if (plr[myplr]._pClass == PC_SORCERER) { + sfxdnum = PS_MAGE94; + } + } + return; + } + quests[QTYPE_BUTCH]._qactive = 3; + sfxdelay = 30; + if (plr[myplr]._pClass == PC_WARRIOR) { + sfxdnum = PS_WARR80; + } else if (plr[myplr]._pClass == PC_ROGUE) { + sfxdnum = PS_ROGUE80; + } else if (plr[myplr]._pClass == PC_SORCERER) { + sfxdnum = PS_MAGE80; + } + if (sendmsg) { + v5 = 6; + goto LABEL_10; + } + } } // 52A554: using guessed type int sfxdelay; // 679660: using guessed type char gbMaxPlayers; void __cdecl DrawButcher() { - DRLG_RectTrans(2 * setpc_x + 19, 2 * setpc_y + 19, 2 * setpc_x + 26, 2 * setpc_y + 26); + DRLG_RectTrans(2 * setpc_x + 19, 2 * setpc_y + 19, 2 * setpc_x + 26, 2 * setpc_y + 26); } void __fastcall DrawSkelKing(int q, int x, int y) { - int v3; // eax + int v3; // eax - v3 = q; - quests[v3]._qtx = 2 * x + 28; - quests[v3]._qty = 2 * y + 23; + v3 = q; + quests[v3]._qtx = 2 * x + 28; + quests[v3]._qty = 2 * y + 23; } void __fastcall DrawWarLord(int x, int y) { - int v2; // esi - int v3; // edi - unsigned char *v4; // eax - int v5; // ebx - int v6; // edx - int v7; // edx - char *v8; // eax - int v9; // ecx - char *v10; // esi - char v11; // bl - unsigned char *ptr; // [esp+Ch] [ebp-Ch] - int v13; // [esp+10h] [ebp-8h] - int v14; // [esp+14h] [ebp-4h] + int v2; // esi + int v3; // edi + unsigned char *v4; // eax + int v5; // ebx + int v6; // edx + int v7; // edx + char *v8; // eax + int v9; // ecx + char *v10; // esi + char v11; // bl + unsigned char *ptr; // [esp+Ch] [ebp-Ch] + int v13; // [esp+10h] [ebp-8h] + int v14; // [esp+14h] [ebp-4h] - v2 = y; - v3 = x; - v4 = LoadFileInMem("Levels\\L4Data\\Warlord2.DUN", 0); - v5 = *v4; - ptr = v4; - v4 += 2; - v14 = v2; - v6 = *v4; - setpc_h = v6; - v7 = v2 + v6; - v8 = (char *)(v4 + 2); - setpc_w = v5; - setpc_x = v3; - setpc_y = v2; - if (v2 < v7) { - v13 = v3 + v5; - do { - if (v3 < v13) { - v9 = v13 - v3; - v10 = &dungeon[v3][v14]; - do { - v11 = *v8; - if (!*v8) - v11 = 6; - *v10 = v11; - v8 += 2; - v10 += 40; - --v9; - } while (v9); - } - ++v14; - } while (v14 < v7); - } - mem_free_dbg(ptr); + v2 = y; + v3 = x; + v4 = LoadFileInMem("Levels\\L4Data\\Warlord2.DUN", 0); + v5 = *v4; + ptr = v4; + v4 += 2; + v14 = v2; + v6 = *v4; + setpc_h = v6; + v7 = v2 + v6; + v8 = (char *)(v4 + 2); + setpc_w = v5; + setpc_x = v3; + setpc_y = v2; + if (v2 < v7) { + v13 = v3 + v5; + do { + if (v3 < v13) { + v9 = v13 - v3; + v10 = &dungeon[v3][v14]; + do { + v11 = *v8; + if (!*v8) + v11 = 6; + *v10 = v11; + v8 += 2; + v10 += 40; + --v9; + } while (v9); + } + ++v14; + } while (v14 < v7); + } + mem_free_dbg(ptr); } // 5CF330: using guessed type int setpc_h; // 5CF334: using guessed type int setpc_w; void __fastcall DrawSChamber(int q, int x, int y) { - int v3; // esi - unsigned char *v4; // eax - int v5; // edi - int v6; // ebx - int v7; // eax - char *v8; // ecx - int v9; // eax - char *v10; // edx - char v11; // bl - int v12; // edx - unsigned char *ptr; // [esp+Ch] [ebp-10h] - int v14; // [esp+10h] [ebp-Ch] - int v15; // [esp+14h] [ebp-8h] - int v16; // [esp+18h] [ebp-4h] + int v3; // esi + unsigned char *v4; // eax + int v5; // edi + int v6; // ebx + int v7; // eax + char *v8; // ecx + int v9; // eax + char *v10; // edx + char v11; // bl + int v12; // edx + unsigned char *ptr; // [esp+Ch] [ebp-10h] + int v14; // [esp+10h] [ebp-Ch] + int v15; // [esp+14h] [ebp-8h] + int v16; // [esp+18h] [ebp-4h] - v3 = x; - v14 = q; - v4 = LoadFileInMem("Levels\\L2Data\\Bonestr1.DUN", 0); - v5 = y; - ptr = v4; - v6 = y; - v7 = *v4; - setpc_h = ptr[2]; - v8 = (char *)(ptr + 4); - setpc_w = v7; - setpc_x = v3; - setpc_y = y; - v15 = y + setpc_h; - if (y < y + setpc_h) { - v16 = v3 + v7; - do { - if (v3 < v16) { - v9 = v16 - v3; - v10 = &dungeon[v3][v6]; - do { - v11 = *v8; - if (!*v8) - v11 = 3; - *v10 = v11; - v8 += 2; - v10 += 40; - --v9; - } while (v9); - } - v6 = y++ + 1; - } while (y < v15); - } - v12 = v14; - quests[v12]._qtx = 2 * v3 + 22; - quests[v12]._qty = 2 * v5 + 23; - mem_free_dbg(ptr); + v3 = x; + v14 = q; + v4 = LoadFileInMem("Levels\\L2Data\\Bonestr1.DUN", 0); + v5 = y; + ptr = v4; + v6 = y; + v7 = *v4; + setpc_h = ptr[2]; + v8 = (char *)(ptr + 4); + setpc_w = v7; + setpc_x = v3; + setpc_y = y; + v15 = y + setpc_h; + if (y < y + setpc_h) { + v16 = v3 + v7; + do { + if (v3 < v16) { + v9 = v16 - v3; + v10 = &dungeon[v3][v6]; + do { + v11 = *v8; + if (!*v8) + v11 = 3; + *v10 = v11; + v8 += 2; + v10 += 40; + --v9; + } while (v9); + } + v6 = y++ + 1; + } while (y < v15); + } + v12 = v14; + quests[v12]._qtx = 2 * v3 + 22; + quests[v12]._qty = 2 * v5 + 23; + mem_free_dbg(ptr); } // 5CF330: using guessed type int setpc_h; // 5CF334: using guessed type int setpc_w; void __fastcall DrawLTBanner(int x, int y) { - int v2; // ebx - int v3; // esi - unsigned char *v4; // eax - unsigned char *v5; // ecx - int v6; // edi - int v7; // edx - int v8; // eax - char *v9; // edx - char *v10; // ecx - unsigned char *ptr; // [esp+Ch] [ebp-10h] - int v12; // [esp+10h] [ebp-Ch] - int v13; // [esp+14h] [ebp-8h] - int v14; // [esp+18h] [ebp-4h] + int v2; // ebx + int v3; // esi + unsigned char *v4; // eax + unsigned char *v5; // ecx + int v6; // edi + int v7; // edx + int v8; // eax + char *v9; // edx + char *v10; // ecx + unsigned char *ptr; // [esp+Ch] [ebp-10h] + int v12; // [esp+10h] [ebp-Ch] + int v13; // [esp+14h] [ebp-8h] + int v14; // [esp+18h] [ebp-4h] - v2 = y; - v3 = x; - v12 = y; - v4 = LoadFileInMem("Levels\\L1Data\\Banner1.DUN", 0); - v5 = v4; - v14 = 0; - ptr = v4; - v6 = *v4; - v7 = (int)(v4 + 2); - v8 = v4[2]; - setpc_w = v6; - v9 = (char *)(v7 + 2); - setpc_h = v8; - setpc_x = v3; - setpc_y = v2; - if (v8 > 0) { - do { - if (v6 > 0) { - v13 = v6; - v10 = &pdungeon[v3][v14 + v12]; - do { - if (*v9) - *v10 = *v9; - v10 += 40; - v9 += 2; - --v13; - } while (v13); - v5 = ptr; - } - ++v14; - } while (v14 < v8); - } - mem_free_dbg(v5); + v2 = y; + v3 = x; + v12 = y; + v4 = LoadFileInMem("Levels\\L1Data\\Banner1.DUN", 0); + v5 = v4; + v14 = 0; + ptr = v4; + v6 = *v4; + v7 = (int)(v4 + 2); + v8 = v4[2]; + setpc_w = v6; + v9 = (char *)(v7 + 2); + setpc_h = v8; + setpc_x = v3; + setpc_y = v2; + if (v8 > 0) { + do { + if (v6 > 0) { + v13 = v6; + v10 = &pdungeon[v3][v14 + v12]; + do { + if (*v9) + *v10 = *v9; + v10 += 40; + v9 += 2; + --v13; + } while (v13); + v5 = ptr; + } + ++v14; + } while (v14 < v8); + } + mem_free_dbg(v5); } // 5CF330: using guessed type int setpc_h; // 5CF334: using guessed type int setpc_w; void __fastcall DrawBlind(int x, int y) { - int v2; // ebx - int v3; // esi - unsigned char *v4; // eax - unsigned char *v5; // ecx - int v6; // edi - int v7; // edx - int v8; // eax - char *v9; // edx - char *v10; // ecx - unsigned char *ptr; // [esp+Ch] [ebp-10h] - int v12; // [esp+10h] [ebp-Ch] - int v13; // [esp+14h] [ebp-8h] - int v14; // [esp+18h] [ebp-4h] + int v2; // ebx + int v3; // esi + unsigned char *v4; // eax + unsigned char *v5; // ecx + int v6; // edi + int v7; // edx + int v8; // eax + char *v9; // edx + char *v10; // ecx + unsigned char *ptr; // [esp+Ch] [ebp-10h] + int v12; // [esp+10h] [ebp-Ch] + int v13; // [esp+14h] [ebp-8h] + int v14; // [esp+18h] [ebp-4h] - v2 = y; - v3 = x; - v12 = y; - v4 = LoadFileInMem("Levels\\L2Data\\Blind1.DUN", 0); - v5 = v4; - v14 = 0; - ptr = v4; - v6 = *v4; - v7 = (int)(v4 + 2); - v8 = v4[2]; - setpc_x = v3; - v9 = (char *)(v7 + 2); - setpc_y = v2; - setpc_w = v6; - setpc_h = v8; - if (v8 > 0) { - do { - if (v6 > 0) { - v13 = v6; - v10 = &pdungeon[v3][v14 + v12]; - do { - if (*v9) - *v10 = *v9; - v10 += 40; - v9 += 2; - --v13; - } while (v13); - v5 = ptr; - } - ++v14; - } while (v14 < v8); - } - mem_free_dbg(v5); + v2 = y; + v3 = x; + v12 = y; + v4 = LoadFileInMem("Levels\\L2Data\\Blind1.DUN", 0); + v5 = v4; + v14 = 0; + ptr = v4; + v6 = *v4; + v7 = (int)(v4 + 2); + v8 = v4[2]; + setpc_x = v3; + v9 = (char *)(v7 + 2); + setpc_y = v2; + setpc_w = v6; + setpc_h = v8; + if (v8 > 0) { + do { + if (v6 > 0) { + v13 = v6; + v10 = &pdungeon[v3][v14 + v12]; + do { + if (*v9) + *v10 = *v9; + v10 += 40; + v9 += 2; + --v13; + } while (v13); + v5 = ptr; + } + ++v14; + } while (v14 < v8); + } + mem_free_dbg(v5); } // 5CF330: using guessed type int setpc_h; // 5CF334: using guessed type int setpc_w; void __fastcall DrawBlood(int x, int y) { - int v2; // ebx - int v3; // esi - unsigned char *v4; // eax - unsigned char *v5; // ecx - int v6; // edi - int v7; // edx - int v8; // eax - char *v9; // edx - char *v10; // ecx - unsigned char *ptr; // [esp+Ch] [ebp-10h] - int v12; // [esp+10h] [ebp-Ch] - int v13; // [esp+14h] [ebp-8h] - int v14; // [esp+18h] [ebp-4h] + int v2; // ebx + int v3; // esi + unsigned char *v4; // eax + unsigned char *v5; // ecx + int v6; // edi + int v7; // edx + int v8; // eax + char *v9; // edx + char *v10; // ecx + unsigned char *ptr; // [esp+Ch] [ebp-10h] + int v12; // [esp+10h] [ebp-Ch] + int v13; // [esp+14h] [ebp-8h] + int v14; // [esp+18h] [ebp-4h] - v2 = y; - v3 = x; - v12 = y; - v4 = LoadFileInMem("Levels\\L2Data\\Blood2.DUN", 0); - v5 = v4; - v14 = 0; - ptr = v4; - v6 = *v4; - v7 = (int)(v4 + 2); - v8 = v4[2]; - setpc_x = v3; - v9 = (char *)(v7 + 2); - setpc_y = v2; - setpc_w = v6; - setpc_h = v8; - if (v8 > 0) { - do { - if (v6 > 0) { - v13 = v6; - v10 = &dungeon[v3][v14 + v12]; - do { - if (*v9) - *v10 = *v9; - v10 += 40; - v9 += 2; - --v13; - } while (v13); - v5 = ptr; - } - ++v14; - } while (v14 < v8); - } - mem_free_dbg(v5); + v2 = y; + v3 = x; + v12 = y; + v4 = LoadFileInMem("Levels\\L2Data\\Blood2.DUN", 0); + v5 = v4; + v14 = 0; + ptr = v4; + v6 = *v4; + v7 = (int)(v4 + 2); + v8 = v4[2]; + setpc_x = v3; + v9 = (char *)(v7 + 2); + setpc_y = v2; + setpc_w = v6; + setpc_h = v8; + if (v8 > 0) { + do { + if (v6 > 0) { + v13 = v6; + v10 = &dungeon[v3][v14 + v12]; + do { + if (*v9) + *v10 = *v9; + v10 += 40; + v9 += 2; + --v13; + } while (v13); + v5 = ptr; + } + ++v14; + } while (v14 < v8); + } + mem_free_dbg(v5); } // 5CF330: using guessed type int setpc_h; // 5CF334: using guessed type int setpc_w; void __fastcall DRLG_CheckQuests(int x, int y) { - int v2; // esi - int v3; // edi - int v4; // ebx - unsigned char *v5; // ebp - //int v6; // eax + int v2; // esi + int v3; // edi + int v4; // ebx + unsigned char *v5; // ebp + //int v6; // eax - v2 = y; - v3 = x; - v4 = 0; - v5 = &quests[0]._qtype; - do { - //_LOBYTE(v6) = QuestStatus(v4); - if (QuestStatus(v4)) { - switch (*v5) { - case QTYPE_BUTCH: - DrawButcher(); - break; - case QTYPE_BOL: - DrawLTBanner(v3, v2); - break; - case QTYPE_BLIND: - DrawBlind(v3, v2); - break; - case QTYPE_BLOOD: - DrawBlood(v3, v2); - break; - case QTYPE_WARLRD: - DrawWarLord(v3, v2); - break; - case QTYPE_KING: - DrawSkelKing(v4, v3, v2); - break; - case QTYPE_BONE: - DrawSChamber(v4, v3, v2); - break; - } - } - v5 += 24; - ++v4; - } while ((signed int)v5 < (signed int)&quests[MAXQUESTS]._qtype); + v2 = y; + v3 = x; + v4 = 0; + v5 = &quests[0]._qtype; + do { + //_LOBYTE(v6) = QuestStatus(v4); + if (QuestStatus(v4)) { + switch (*v5) { + case QTYPE_BUTCH: + DrawButcher(); + break; + case QTYPE_BOL: + DrawLTBanner(v3, v2); + break; + case QTYPE_BLIND: + DrawBlind(v3, v2); + break; + case QTYPE_BLOOD: + DrawBlood(v3, v2); + break; + case QTYPE_WARLRD: + DrawWarLord(v3, v2); + break; + case QTYPE_KING: + DrawSkelKing(v4, v3, v2); + break; + case QTYPE_BONE: + DrawSChamber(v4, v3, v2); + break; + } + } + v5 += 24; + ++v4; + } while ((signed int)v5 < (signed int)&quests[MAXQUESTS]._qtype); } // 69BE90: using guessed type int qline; void __cdecl SetReturnLvlPos() { - int v0; // eax + int v0; // eax - switch (setlvlnum) { - case SL_SKELKING: - ReturnLvlX = quests[QTYPE_KING]._qtx + 1; - ReturnLvlY = quests[QTYPE_KING]._qty; - v0 = (unsigned char)quests[QTYPE_KING]._qlevel; - goto LABEL_9; - case SL_BONECHAMB: - ReturnLvlT = 2; - ReturnLvlX = quests[QTYPE_BONE]._qtx + 1; - ReturnLvlY = quests[QTYPE_BONE]._qty; - v0 = (unsigned char)quests[QTYPE_BONE]._qlevel; - goto LABEL_10; - case SL_POISONWATER: - ReturnLvlX = quests[QTYPE_PW]._qtx; - ReturnLvlY = quests[QTYPE_PW]._qty + 1; - v0 = (unsigned char)quests[QTYPE_PW]._qlevel; - LABEL_9: - ReturnLvlT = 1; - goto LABEL_10; - } - if (setlvlnum != 5) - return; - ReturnLvlT = 4; - ReturnLvlX = quests[QTYPE_VB]._qtx + 1; - ReturnLvlY = quests[QTYPE_VB]._qty - 1; - v0 = (unsigned char)quests[QTYPE_VB]._qlevel; + switch (setlvlnum) { + case SL_SKELKING: + ReturnLvlX = quests[QTYPE_KING]._qtx + 1; + ReturnLvlY = quests[QTYPE_KING]._qty; + v0 = (unsigned char)quests[QTYPE_KING]._qlevel; + goto LABEL_9; + case SL_BONECHAMB: + ReturnLvlT = 2; + ReturnLvlX = quests[QTYPE_BONE]._qtx + 1; + ReturnLvlY = quests[QTYPE_BONE]._qty; + v0 = (unsigned char)quests[QTYPE_BONE]._qlevel; + goto LABEL_10; + case SL_POISONWATER: + ReturnLvlX = quests[QTYPE_PW]._qtx; + ReturnLvlY = quests[QTYPE_PW]._qty + 1; + v0 = (unsigned char)quests[QTYPE_PW]._qlevel; + LABEL_9: + ReturnLvlT = 1; + goto LABEL_10; + } + if (setlvlnum != 5) + return; + ReturnLvlT = 4; + ReturnLvlX = quests[QTYPE_VB]._qtx + 1; + ReturnLvlY = quests[QTYPE_VB]._qty - 1; + v0 = (unsigned char)quests[QTYPE_VB]._qlevel; LABEL_10: - ReturnLvl = v0; + ReturnLvl = v0; } void __cdecl GetReturnLvlPos() { - if (quests[QTYPE_VB]._qactive == 3) - quests[QTYPE_VB]._qvar2 = 2; - ViewX = ReturnLvlX; - ViewY = ReturnLvlY; - currlevel = ReturnLvl; - leveltype = ReturnLvlT; + if (quests[QTYPE_VB]._qactive == 3) + quests[QTYPE_VB]._qvar2 = 2; + ViewX = ReturnLvlX; + ViewY = ReturnLvlY; + currlevel = ReturnLvl; + leveltype = ReturnLvlT; } // 5BB1ED: using guessed type char leveltype; void __cdecl ResyncMPQuests() { - if (quests[QTYPE_KING]._qactive == 1 - && currlevel >= (unsigned char)quests[QTYPE_KING]._qlevel - 1 - && currlevel <= (unsigned char)quests[QTYPE_KING]._qlevel + 1) { - quests[QTYPE_KING]._qactive = 2; - NetSendCmdQuest(TRUE, 0xCu); - } - if (quests[QTYPE_BUTCH]._qactive == 1 - && currlevel >= (unsigned char)quests[QTYPE_BUTCH]._qlevel - 1 - && currlevel <= (unsigned char)quests[QTYPE_BUTCH]._qlevel + 1) { - quests[QTYPE_BUTCH]._qactive = 2; - NetSendCmdQuest(TRUE, 6u); - } - if (quests[QTYPE_VB]._qactive == 1 && currlevel == (unsigned char)quests[QTYPE_VB]._qlevel - 1) { - quests[QTYPE_VB]._qactive = 2; - NetSendCmdQuest(TRUE, 0xFu); - } - if (QuestStatus(QTYPE_VB)) - AddObject(OBJ_ALTBOY, 2 * setpc_x + 20, 2 * setpc_y + 22); + if (quests[QTYPE_KING]._qactive == 1 + && currlevel >= (unsigned char)quests[QTYPE_KING]._qlevel - 1 + && currlevel <= (unsigned char)quests[QTYPE_KING]._qlevel + 1) { + quests[QTYPE_KING]._qactive = 2; + NetSendCmdQuest(TRUE, 0xCu); + } + if (quests[QTYPE_BUTCH]._qactive == 1 + && currlevel >= (unsigned char)quests[QTYPE_BUTCH]._qlevel - 1 + && currlevel <= (unsigned char)quests[QTYPE_BUTCH]._qlevel + 1) { + quests[QTYPE_BUTCH]._qactive = 2; + NetSendCmdQuest(TRUE, 6u); + } + if (quests[QTYPE_VB]._qactive == 1 && currlevel == (unsigned char)quests[QTYPE_VB]._qlevel - 1) { + quests[QTYPE_VB]._qactive = 2; + NetSendCmdQuest(TRUE, 0xFu); + } + if (QuestStatus(QTYPE_VB)) + AddObject(OBJ_ALTBOY, 2 * setpc_x + 20, 2 * setpc_y + 22); } void __cdecl ResyncQuests() { - char *v0; // ecx - int v1; // esi - //int v2; // eax - int i; // esi - char v4; // bl - int j; // esi - char v6; // bl - int k; // esi + char *v0; // ecx + int v1; // esi + //int v2; // eax + int i; // esi + char v4; // bl + int j; // esi + char v6; // bl + int k; // esi - if (setlevel && setlvlnum == quests[QTYPE_PW]._qslvl && quests[QTYPE_PW]._qactive != 1 && leveltype == quests[QTYPE_PW]._qlvltype) { - v0 = "Levels\\L3Data\\L3pwater.pal"; - if (quests[QTYPE_PW]._qactive != 3) - v0 = "Levels\\L3Data\\L3pfoul.pal"; - LoadPalette(v0); - v1 = 0; - do - palette_update_quest_palette(v1++); - while (v1 <= 32); - } - //_LOBYTE(v2) = QuestStatus(QTYPE_BOL); - if (QuestStatus(QTYPE_BOL)) { - if (quests[QTYPE_BOL]._qvar1 == 1) - ObjChangeMapResync( - setpc_w + setpc_x - 2, - setpc_h + setpc_y - 2, - setpc_w + setpc_x + 1, - setpc_h + setpc_y + 1); - if (quests[QTYPE_BOL]._qvar1 == 2) { - ObjChangeMapResync( - setpc_w + setpc_x - 2, - setpc_h + setpc_y - 2, - setpc_w + setpc_x + 1, - setpc_h + setpc_y + 1); - ObjChangeMapResync(setpc_x, setpc_y, (setpc_w >> 1) + setpc_x + 2, (setpc_h >> 1) + setpc_y - 2); - for (i = 0; i < nobjects; ++i) - SyncObjectAnim(objectactive[i]); - v4 = TransVal; - TransVal = 9; - DRLG_MRectTrans(setpc_x, setpc_y, (setpc_w >> 1) + setpc_x + 4, setpc_y + (setpc_h >> 1)); - TransVal = v4; - } - if (quests[QTYPE_BOL]._qvar1 == 3) { - ObjChangeMapResync(setpc_x, setpc_y, setpc_w + setpc_x + 1, setpc_h + setpc_y + 1); - for (j = 0; j < nobjects; ++j) - SyncObjectAnim(objectactive[j]); - v6 = TransVal; - TransVal = 9; - DRLG_MRectTrans(setpc_x, setpc_y, (setpc_w >> 1) + setpc_x + 4, setpc_y + (setpc_h >> 1)); - TransVal = v6; - } - } - if (currlevel == quests[QTYPE_BLKM]._qlevel) { - if (quests[QTYPE_BLKM]._qactive == 1) { - if (!quests[QTYPE_BLKM]._qvar1) { - SpawnQuestItem(IDI_FUNGALTM, 0, 0, 5, 1); - quests[QTYPE_BLKM]._qvar1 = QS_TOMESPAWNED; - } - } else if (quests[QTYPE_BLKM]._qactive == 2) { - if (quests[QTYPE_BLKM]._qvar1 < QS_MUSHGIVEN) { - if (quests[QTYPE_BLKM]._qvar1 >= QS_BRAINGIVEN) - Qtalklist[TOWN_HEALER]._qblkm = -1; - } else { - Qtalklist[TOWN_WITCH]._qblkm = -1; - Qtalklist[TOWN_HEALER]._qblkm = QUEST_MUSH3; - } - } - } - if (currlevel == (unsigned char)quests[QTYPE_VEIL]._qlevel + 1 && quests[QTYPE_VEIL]._qactive == 2 && !quests[QTYPE_VEIL]._qvar1) { - quests[QTYPE_VEIL]._qvar1 = 1; - SpawnQuestItem(15, 0, 0, 5, 1); - } - if (setlevel && setlvlnum == 5) { - if (quests[QTYPE_VB]._qvar1 >= 4u) - ObjChangeMapResync(1, 11, 20, 18); - if (quests[QTYPE_VB]._qvar1 >= 6u) - ObjChangeMapResync(1, 18, 20, 24); - if (quests[QTYPE_VB]._qvar1 >= 7u) - InitVPTriggers(); - for (k = 0; k < nobjects; ++k) - SyncObjectAnim(objectactive[k]); - } - if (currlevel == quests[QTYPE_VB]._qlevel - && !setlevel - && (quests[QTYPE_VB]._qvar2 == 1 || quests[QTYPE_VB]._qvar2 >= 3u) - && (quests[QTYPE_VB]._qactive == 2 || quests[QTYPE_VB]._qactive == 3)) { - quests[QTYPE_VB]._qvar2 = 2; - } + if (setlevel && setlvlnum == quests[QTYPE_PW]._qslvl && quests[QTYPE_PW]._qactive != 1 && leveltype == quests[QTYPE_PW]._qlvltype) { + v0 = "Levels\\L3Data\\L3pwater.pal"; + if (quests[QTYPE_PW]._qactive != 3) + v0 = "Levels\\L3Data\\L3pfoul.pal"; + LoadPalette(v0); + v1 = 0; + do + palette_update_quest_palette(v1++); + while (v1 <= 32); + } + //_LOBYTE(v2) = QuestStatus(QTYPE_BOL); + if (QuestStatus(QTYPE_BOL)) { + if (quests[QTYPE_BOL]._qvar1 == 1) + ObjChangeMapResync( + setpc_w + setpc_x - 2, + setpc_h + setpc_y - 2, + setpc_w + setpc_x + 1, + setpc_h + setpc_y + 1); + if (quests[QTYPE_BOL]._qvar1 == 2) { + ObjChangeMapResync( + setpc_w + setpc_x - 2, + setpc_h + setpc_y - 2, + setpc_w + setpc_x + 1, + setpc_h + setpc_y + 1); + ObjChangeMapResync(setpc_x, setpc_y, (setpc_w >> 1) + setpc_x + 2, (setpc_h >> 1) + setpc_y - 2); + for (i = 0; i < nobjects; ++i) + SyncObjectAnim(objectactive[i]); + v4 = TransVal; + TransVal = 9; + DRLG_MRectTrans(setpc_x, setpc_y, (setpc_w >> 1) + setpc_x + 4, setpc_y + (setpc_h >> 1)); + TransVal = v4; + } + if (quests[QTYPE_BOL]._qvar1 == 3) { + ObjChangeMapResync(setpc_x, setpc_y, setpc_w + setpc_x + 1, setpc_h + setpc_y + 1); + for (j = 0; j < nobjects; ++j) + SyncObjectAnim(objectactive[j]); + v6 = TransVal; + TransVal = 9; + DRLG_MRectTrans(setpc_x, setpc_y, (setpc_w >> 1) + setpc_x + 4, setpc_y + (setpc_h >> 1)); + TransVal = v6; + } + } + if (currlevel == quests[QTYPE_BLKM]._qlevel) { + if (quests[QTYPE_BLKM]._qactive == 1) { + if (!quests[QTYPE_BLKM]._qvar1) { + SpawnQuestItem(IDI_FUNGALTM, 0, 0, 5, 1); + quests[QTYPE_BLKM]._qvar1 = QS_TOMESPAWNED; + } + } else if (quests[QTYPE_BLKM]._qactive == 2) { + if (quests[QTYPE_BLKM]._qvar1 < QS_MUSHGIVEN) { + if (quests[QTYPE_BLKM]._qvar1 >= QS_BRAINGIVEN) + Qtalklist[TOWN_HEALER]._qblkm = -1; + } else { + Qtalklist[TOWN_WITCH]._qblkm = -1; + Qtalklist[TOWN_HEALER]._qblkm = QUEST_MUSH3; + } + } + } + if (currlevel == (unsigned char)quests[QTYPE_VEIL]._qlevel + 1 && quests[QTYPE_VEIL]._qactive == 2 && !quests[QTYPE_VEIL]._qvar1) { + quests[QTYPE_VEIL]._qvar1 = 1; + SpawnQuestItem(15, 0, 0, 5, 1); + } + if (setlevel && setlvlnum == 5) { + if (quests[QTYPE_VB]._qvar1 >= 4u) + ObjChangeMapResync(1, 11, 20, 18); + if (quests[QTYPE_VB]._qvar1 >= 6u) + ObjChangeMapResync(1, 18, 20, 24); + if (quests[QTYPE_VB]._qvar1 >= 7u) + InitVPTriggers(); + for (k = 0; k < nobjects; ++k) + SyncObjectAnim(objectactive[k]); + } + if (currlevel == quests[QTYPE_VB]._qlevel + && !setlevel + && (quests[QTYPE_VB]._qvar2 == 1 || quests[QTYPE_VB]._qvar2 >= 3u) + && (quests[QTYPE_VB]._qactive == 2 || quests[QTYPE_VB]._qactive == 3)) { + quests[QTYPE_VB]._qvar2 = 2; + } } // 5A5590: using guessed type char TransVal; // 5BB1ED: using guessed type char leveltype; @@ -926,123 +926,123 @@ void __cdecl ResyncQuests() void __fastcall PrintQLString(int x, int y, unsigned char cjustflag, char *str, int col) { - int v5; // ebx - int v6; // edi - size_t v7; // eax - int v8; // esi - signed int v9; // ecx - signed int v10; // eax - int v11; // edx - int v12; // ecx - signed int v13; // ecx - unsigned char v14; // al - int v15; // edi - int v16; // ecx - int v17; // [esp+Ch] [ebp-14h] - int v18; // [esp+10h] [ebp-10h] - signed int v19; // [esp+14h] [ebp-Ch] - signed int v20; // [esp+18h] [ebp-8h] - int width; // [esp+1Ch] [ebp-4h] + int v5; // ebx + int v6; // edi + size_t v7; // eax + int v8; // esi + signed int v9; // ecx + signed int v10; // eax + int v11; // edx + int v12; // ecx + signed int v13; // ecx + unsigned char v14; // al + int v15; // edi + int v16; // ecx + int v17; // [esp+Ch] [ebp-14h] + int v18; // [esp+10h] [ebp-10h] + signed int v19; // [esp+14h] [ebp-Ch] + signed int v20; // [esp+18h] [ebp-8h] + int width; // [esp+1Ch] [ebp-4h] - v5 = SStringY[y]; - v6 = x; - v18 = y; - v17 = x; - width = screen_y_times_768[v5 + 204] + x + 96; - v7 = strlen(str); - v8 = 0; - v9 = 0; - v20 = v7; - if (cjustflag) { - v10 = 0; - if (v20 <= 0) - goto LABEL_24; - do { - v11 = (unsigned char)str[v9++]; - v10 += fontkern[fontframe[fontidx[v11]]] + 1; - } while (v9 < v20); - if (v10 < 257) - LABEL_24: - v8 = (257 - v10) >> 1; - width += v8; - } - if (qline == v18) { - v12 = v8 + v6 + 76; - if (!cjustflag) - v12 = v6 + 76; - CelDecodeOnly(v12, v5 + 205, pCelBuff, ALLQUESTS, 12); - } - v13 = 0; - v19 = 0; - if (v20 > 0) { - do { - v14 = fontframe[fontidx[(unsigned char)str[v13]]]; - v15 = v14; - v8 += fontkern[v14] + 1; - if (v14 && v8 <= 257) { - CPrintString(width, v14, col); - v13 = v19; - } - v19 = ++v13; - width += fontkern[v15] + 1; - } while (v13 < v20); - v6 = v17; - } - if (qline == v18) { - if (cjustflag) - v16 = v8 + v6 + 100; - else - v16 = 340 - v6; - CelDecodeOnly(v16, v5 + 205, pCelBuff, ALLQUESTS, 12); - } + v5 = SStringY[y]; + v6 = x; + v18 = y; + v17 = x; + width = screen_y_times_768[v5 + 204] + x + 96; + v7 = strlen(str); + v8 = 0; + v9 = 0; + v20 = v7; + if (cjustflag) { + v10 = 0; + if (v20 <= 0) + goto LABEL_24; + do { + v11 = (unsigned char)str[v9++]; + v10 += fontkern[fontframe[fontidx[v11]]] + 1; + } while (v9 < v20); + if (v10 < 257) + LABEL_24: + v8 = (257 - v10) >> 1; + width += v8; + } + if (qline == v18) { + v12 = v8 + v6 + 76; + if (!cjustflag) + v12 = v6 + 76; + CelDecodeOnly(v12, v5 + 205, pCelBuff, ALLQUESTS, 12); + } + v13 = 0; + v19 = 0; + if (v20 > 0) { + do { + v14 = fontframe[fontidx[(unsigned char)str[v13]]]; + v15 = v14; + v8 += fontkern[v14] + 1; + if (v14 && v8 <= 257) { + CPrintString(width, v14, col); + v13 = v19; + } + v19 = ++v13; + width += fontkern[v15] + 1; + } while (v13 < v20); + v6 = v17; + } + if (qline == v18) { + if (cjustflag) + v16 = v8 + v6 + 100; + else + v16 = 340 - v6; + CelDecodeOnly(v16, v5 + 205, pCelBuff, ALLQUESTS, 12); + } } // 69BE90: using guessed type int qline; void __cdecl DrawQuestLog() { - int v0; // edi - int i; // esi + int v0; // edi + int i; // esi - PrintQLString(0, 2, 1u, "Quest Log", 3); - CelDecodeOnly(64, 511, pQLogCel, 1, 320); - v0 = qtopline; - for (i = 0; i < numqlines; ++i) { - PrintQLString(0, v0, 1u, questlist[qlist[i]]._qlstr, 0); - v0 += 2; - } - PrintQLString(0, 22, 1u, "Close Quest Log", 0); - ALLQUESTS = (ALLQUESTS & 7) + 1; + PrintQLString(0, 2, 1u, "Quest Log", 3); + CelDecodeOnly(64, 511, pQLogCel, 1, 320); + v0 = qtopline; + for (i = 0; i < numqlines; ++i) { + PrintQLString(0, v0, 1u, questlist[qlist[i]]._qlstr, 0); + v0 += 2; + } + PrintQLString(0, 22, 1u, "Close Quest Log", 0); + ALLQUESTS = (ALLQUESTS & 7) + 1; } // 69BED4: using guessed type int numqlines; void __cdecl StartQuestlog() { - signed int v0; // eax - int v1; // edx - unsigned int v2; // ecx - int v3; // ecx + signed int v0; // eax + int v1; // edx + unsigned int v2; // ecx + int v3; // ecx - v0 = 0; - v1 = 0; - numqlines = 0; - v2 = 0; - do { - if (quests[v2]._qactive == 2 && quests[v2]._qlog) - qlist[v0++] = v1; - ++v2; - ++v1; - } while (v2 < MAXQUESTS); - numqlines = v0; - if (v0 <= 5) - v3 = 8; - else - v3 = 5 - (v0 >> 1); - qtopline = v3; - qline = 22; - if (v0) - qline = v3; - questlog = 1; - ALLQUESTS = 1; + v0 = 0; + v1 = 0; + numqlines = 0; + v2 = 0; + do { + if (quests[v2]._qactive == 2 && quests[v2]._qlog) + qlist[v0++] = v1; + ++v2; + ++v1; + } while (v2 < MAXQUESTS); + numqlines = v0; + if (v0 <= 5) + v3 = 8; + else + v3 = 5 - (v0 >> 1); + qtopline = v3; + qline = 22; + if (v0) + qline = v3; + questlog = 1; + ALLQUESTS = 1; } // 69BD04: using guessed type int questlog; // 69BE90: using guessed type int qline; @@ -1050,42 +1050,42 @@ void __cdecl StartQuestlog() void __cdecl QuestlogUp() { - if (numqlines) { - if (qline == qtopline) { - qline = 22; - } else if (qline == 22) { - qline = qtopline + 2 * numqlines - 2; - } else { - qline -= 2; - } - PlaySFX(IS_TITLEMOV); - } + if (numqlines) { + if (qline == qtopline) { + qline = 22; + } else if (qline == 22) { + qline = qtopline + 2 * numqlines - 2; + } else { + qline -= 2; + } + PlaySFX(IS_TITLEMOV); + } } // 69BE90: using guessed type int qline; // 69BED4: using guessed type int numqlines; void __cdecl QuestlogDown() { - if (numqlines) { - if (qline == 22) { - qline = qtopline; - } else if (qline == qtopline + 2 * numqlines - 2) { - qline = 22; - } else { - qline += 2; - } - PlaySFX(IS_TITLEMOV); - } + if (numqlines) { + if (qline == 22) { + qline = qtopline; + } else if (qline == qtopline + 2 * numqlines - 2) { + qline = 22; + } else { + qline += 2; + } + PlaySFX(IS_TITLEMOV); + } } // 69BE90: using guessed type int qline; // 69BED4: using guessed type int numqlines; void __cdecl QuestlogEnter() { - PlaySFX(IS_TITLSLCT); - if (numqlines && qline != 22) - InitQTextMsg((unsigned char)quests[qlist[(qline - qtopline) >> 1]]._qmsg); - questlog = 0; + PlaySFX(IS_TITLSLCT); + if (numqlines && qline != 22) + InitQTextMsg((unsigned char)quests[qlist[(qline - qtopline) >> 1]]._qmsg); + questlog = 0; } // 69BD04: using guessed type int questlog; // 69BE90: using guessed type int qline; @@ -1093,40 +1093,40 @@ void __cdecl QuestlogEnter() void __cdecl QuestlogESC() { - int v0; // esi - int i; // edi + int v0; // esi + int i; // edi - v0 = (MouseY - 32) / 12; - if (numqlines) { - for (i = 0; i < numqlines; ++i) { - if (v0 == qtopline + 2 * i) { - qline = v0; - QuestlogEnter(); - } - } - } - if (v0 == 22) { - qline = 22; - QuestlogEnter(); - } + v0 = (MouseY - 32) / 12; + if (numqlines) { + for (i = 0; i < numqlines; ++i) { + if (v0 == qtopline + 2 * i) { + qline = v0; + QuestlogEnter(); + } + } + } + if (v0 == 22) { + qline = 22; + QuestlogEnter(); + } } // 69BE90: using guessed type int qline; // 69BED4: using guessed type int numqlines; void __fastcall SetMultiQuest(int q, int s, int l, int v1) { - int v4; // eax - unsigned char *v5; // ecx - unsigned char *v6; // eax + int v4; // eax + unsigned char *v5; // ecx + unsigned char *v6; // eax - v4 = q; - v5 = &quests[q]._qactive; - if (*v5 != 3) { - if (s > (unsigned char)*v5) - *v5 = s; - quests[v4]._qlog |= l; - v6 = &quests[v4]._qvar1; - if (v1 > (unsigned char)*v6) - *v6 = v1; - } + v4 = q; + v5 = &quests[q]._qactive; + if (*v5 != 3) { + if (s > (unsigned char)*v5) + *v5 = s; + quests[v4]._qlog |= l; + v6 = &quests[v4]._qvar1; + if (v1 > (unsigned char)*v6) + *v6 = v1; + } } diff --git a/Source/render.cpp b/Source/render.cpp index a59d38f4..91534edd 100644 --- a/Source/render.cpp +++ b/Source/render.cpp @@ -11,43 +11,43 @@ unsigned int *gpDrawMask = NULL; // char world_4B326D[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; unsigned int RightMask[32] = { - 0xEAAAAAAA, 0xF5555555, 0xFEAAAAAA, 0xFF555555, 0xFFEAAAAA, 0xFFF55555, 0xFFFEAAAA, 0xFFFF5555, - 0xFFFFEAAA, 0xFFFFF555, 0xFFFFFEAA, 0xFFFFFF55, 0xFFFFFFEA, 0xFFFFFFF5, 0xFFFFFFFE, 0xFFFFFFFF, - 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, - 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF + 0xEAAAAAAA, 0xF5555555, 0xFEAAAAAA, 0xFF555555, 0xFFEAAAAA, 0xFFF55555, 0xFFFEAAAA, 0xFFFF5555, + 0xFFFFEAAA, 0xFFFFF555, 0xFFFFFEAA, 0xFFFFFF55, 0xFFFFFFEA, 0xFFFFFFF5, 0xFFFFFFFE, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }; unsigned int LeftMask[32] = { - 0xAAAAAAAB, 0x5555555F, 0xAAAAAABF, 0x555555FF, 0xAAAAABFF, 0x55555FFF, 0xAAAABFFF, 0x5555FFFF, - 0xAAABFFFF, 0x555FFFFF, 0xAABFFFFF, 0x55FFFFFF, 0xABFFFFFF, 0x5FFFFFFF, 0xBFFFFFFF, 0xFFFFFFFF, - 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, - 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF + 0xAAAAAAAB, 0x5555555F, 0xAAAAAABF, 0x555555FF, 0xAAAAABFF, 0x55555FFF, 0xAAAABFFF, 0x5555FFFF, + 0xAAABFFFF, 0x555FFFFF, 0xAABFFFFF, 0x55FFFFFF, 0xABFFFFFF, 0x5FFFFFFF, 0xBFFFFFFF, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }; unsigned int WallMask[32] = { - 0xAAAAAAAA, 0x55555555, 0xAAAAAAAA, 0x55555555, 0xAAAAAAAA, 0x55555555, 0xAAAAAAAA, 0x55555555, - 0xAAAAAAAA, 0x55555555, 0xAAAAAAAA, 0x55555555, 0xAAAAAAAA, 0x55555555, 0xAAAAAAAA, 0x55555555, - 0xAAAAAAAA, 0x55555555, 0xAAAAAAAA, 0x55555555, 0xAAAAAAAA, 0x55555555, 0xAAAAAAAA, 0x55555555, - 0xAAAAAAAA, 0x55555555, 0xAAAAAAAA, 0x55555555, 0xAAAAAAAA, 0x55555555, 0xAAAAAAAA, 0x55555555 + 0xAAAAAAAA, 0x55555555, 0xAAAAAAAA, 0x55555555, 0xAAAAAAAA, 0x55555555, 0xAAAAAAAA, 0x55555555, + 0xAAAAAAAA, 0x55555555, 0xAAAAAAAA, 0x55555555, 0xAAAAAAAA, 0x55555555, 0xAAAAAAAA, 0x55555555, + 0xAAAAAAAA, 0x55555555, 0xAAAAAAAA, 0x55555555, 0xAAAAAAAA, 0x55555555, 0xAAAAAAAA, 0x55555555, + 0xAAAAAAAA, 0x55555555, 0xAAAAAAAA, 0x55555555, 0xAAAAAAAA, 0x55555555, 0xAAAAAAAA, 0x55555555 }; int WorldTbl3x16[48] = { - 0, 0, 0, - 4, 4, 4, - 8, 8, 8, - 12, 12, 12, - 16, 16, 16, - 20, 20, 20, - 24, 24, 24, - 28, 28, 28, - 32, 32, 32, - 36, 36, 36, - 40, 40, 40, - 44, 44, 44, - 48, 48, 48, - 52, 52, 52, - 56, 56, 56, - 60, 60, 60 + 0, 0, 0, + 4, 4, 4, + 8, 8, 8, + 12, 12, 12, + 16, 16, 16, + 20, 20, 20, + 24, 24, 24, + 28, 28, 28, + 32, 32, 32, + 36, 36, 36, + 40, 40, 40, + 44, 44, 44, + 48, 48, 48, + 52, 52, 52, + 56, 56, 56, + 60, 60, 60 }; // slope/angle tables, left and right @@ -79,2087 +79,1691 @@ int WorldTbl17_2[17] = { 0, 32, 60, 88, 112, 136, 156, 176, 192, 208, 220, 232, void __fastcall drawTopArchesUpperScreen(unsigned char *pbDst) { - unsigned char *dst; // edi MAPDST - unsigned char *tbl; // ebx - unsigned char *src; // esi MAPDST - short cel_type_16; // ax MAPDST - signed int xx_32; // ebp MAPDST - signed int yy_32; // edx MAPDST - unsigned int width; // eax MAPDST - unsigned int chk_sh_and; // ecx MAPDST + unsigned char *dst; // edi MAPDST + unsigned char *tbl; // ebx + unsigned char *src; // esi MAPDST + short cel_type_16; // ax MAPDST + signed int xx_32; // ebp MAPDST + signed int yy_32; // edx MAPDST + unsigned int width; // eax MAPDST + unsigned int chk_sh_and; // ecx MAPDST unsigned int n_draw_shift; // ecx MAPDST - unsigned int x_minus; // ecx MAPDST - unsigned int y_minus; // ecx MAPDST - signed int i; // edx MAPDST - signed int j; // ecx MAPDST + unsigned int x_minus; // ecx MAPDST + unsigned int y_minus; // ecx MAPDST + signed int i; // edx MAPDST + signed int j; // ecx MAPDST gpCelFrame = (unsigned char *)speed_cel_frame_num_from_light_index_frame_num; dst = pbDst; - if ( !(_BYTE)light_table_index ) - { - if ( level_cel_block & 0x8000 ) + if (!(_BYTE)light_table_index) { + if (level_cel_block & 0x8000) level_cel_block = *(_DWORD *)&gpCelFrame[64 * (level_cel_block & 0xFFF)] - + (unsigned short)(level_cel_block & 0xF000); + + (unsigned short)(level_cel_block & 0xF000); src = (unsigned char *)pDungeonCels + *((_DWORD *)pDungeonCels + (level_cel_block & 0xFFF)); cel_type_16 = ((level_cel_block >> 12) & 7) + 8; goto LABEL_11; } - if ( (_BYTE)light_table_index != lightmax ) - { - if ( !(level_cel_block & 0x8000) ) - { + if ((_BYTE)light_table_index != lightmax) { + if (!(level_cel_block & 0x8000)) { src = (unsigned char *)pDungeonCels + *((_DWORD *)pDungeonCels + (level_cel_block & 0xFFF)); tbl = (unsigned char *)&pLightTbl[256 * light_table_index]; cel_type_16 = (unsigned char)(level_cel_block >> 12); - switch ( cel_type_16 ) - { - case 0: // upper (top transparent), with lighting - i = 16; - do - { - if ( dst < gpBufEnd ) - break; - asm_trans_light_square_1_3(8, tbl, dst, src); - dst -= 800; - if ( dst < gpBufEnd ) - break; - asm_trans_light_square_0_2(8, tbl, dst, src); - dst -= 800; - --i; - } - while ( i ); - break; - case 1: // upper (top transparent), with lighting - WorldBoolFlag = (unsigned char)pbDst & 1; - xx_32 = 32; - do - { - yy_32 = 32; - do - { - while ( 1 ) - { - width = (unsigned char)*src++; - if ( (width & 0x80u) == 0 ) - break; - _LOBYTE(width) = -(char)width; - dst += width; - yy_32 -= width; - if ( !yy_32 ) - goto LABEL_67; - } - if ( dst < gpBufEnd ) - return; - if ( ((unsigned char)dst & 1) == WorldBoolFlag ) - { - asm_trans_light_cel_0_2(width, tbl, dst, src); - } - else - { - asm_trans_light_cel_1_3(width, tbl, dst, src); - } + switch (cel_type_16) { + case 0: // upper (top transparent), with lighting + i = 16; + do { + if (dst < gpBufEnd) + break; + asm_trans_light_square_1_3(8, tbl, dst, src); + dst -= 800; + if (dst < gpBufEnd) + break; + asm_trans_light_square_0_2(8, tbl, dst, src); + dst -= 800; + --i; + } while (i); + break; + case 1: // upper (top transparent), with lighting + WorldBoolFlag = (unsigned char)pbDst & 1; + xx_32 = 32; + do { + yy_32 = 32; + do { + while (1) { + width = (unsigned char)*src++; + if ((width & 0x80u) == 0) + break; + _LOBYTE(width) = -(char)width; + dst += width; yy_32 -= width; + if (!yy_32) + goto LABEL_67; } - while ( yy_32 ); -LABEL_67: - WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; - dst -= 800; - --xx_32; - } - while ( xx_32 ); - break; - case 2: // upper (top transparent), with lighting - WorldBoolFlag = 0; - xx_32 = 30; - while ( dst >= gpBufEnd ) - { - dst += xx_32; - src += (32 - (_BYTE)xx_32) & 2; - WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; - if ( WorldBoolFlag ) - { - asm_trans_light_cel_0_2(32 - xx_32, tbl, dst, src); - } - else - { - asm_trans_light_cel_1_3(32 - xx_32, tbl, dst, src); - } - dst -= 800; - xx_32 -= 2; - if ( xx_32 < 0 ) - { - yy_32 = 2; - do - { - if ( dst < gpBufEnd ) - break; - dst += yy_32; - src += (32 - (_BYTE)yy_32) & 2; - WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; - if ( WorldBoolFlag ) - { - asm_trans_light_cel_0_2(32 - yy_32, tbl, dst, src); - } - else - { - asm_trans_light_cel_1_3(32 - yy_32, tbl, dst, src); - } - dst -= 800; - yy_32 += 2; - } - while ( yy_32 != 32 ); + if (dst < gpBufEnd) return; + if (((unsigned char)dst & 1) == WorldBoolFlag) { + asm_trans_light_cel_0_2(width, tbl, dst, src); + } else { + asm_trans_light_cel_1_3(width, tbl, dst, src); } + yy_32 -= width; + } while (yy_32); + LABEL_67: + WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; + dst -= 800; + --xx_32; + } while (xx_32); + break; + case 2: // upper (top transparent), with lighting + WorldBoolFlag = 0; + xx_32 = 30; + while (dst >= gpBufEnd) { + dst += xx_32; + src += (32 - (_BYTE)xx_32) & 2; + WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; + if (WorldBoolFlag) { + asm_trans_light_cel_0_2(32 - xx_32, tbl, dst, src); + } else { + asm_trans_light_cel_1_3(32 - xx_32, tbl, dst, src); } - break; - case 3: // upper (top transparent), with lighting - WorldBoolFlag = 0; - xx_32 = 30; - while ( dst >= gpBufEnd ) - { - WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; - if ( WorldBoolFlag ) - { - asm_trans_light_cel_0_2(32 - xx_32, tbl, dst, src); - } - else - { - asm_trans_light_cel_1_3(32 - xx_32, tbl, dst, src); - } - src += (unsigned char)src & 2; - dst = &dst[xx_32 - 800]; - xx_32 -= 2; - if ( xx_32 < 0 ) - { - yy_32 = 2; - do - { - if ( dst < gpBufEnd ) - break; - WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; - if ( WorldBoolFlag ) - { - asm_trans_light_cel_0_2(32 - yy_32, tbl, dst, src); - } - else - { - asm_trans_light_cel_1_3(32 - yy_32, tbl, dst, src); - } - src += (unsigned char)src & 2; - dst = &dst[yy_32 - 800]; - yy_32 += 2; + dst -= 800; + xx_32 -= 2; + if (xx_32 < 0) { + yy_32 = 2; + do { + if (dst < gpBufEnd) + break; + dst += yy_32; + src += (32 - (_BYTE)yy_32) & 2; + WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; + if (WorldBoolFlag) { + asm_trans_light_cel_0_2(32 - yy_32, tbl, dst, src); + } else { + asm_trans_light_cel_1_3(32 - yy_32, tbl, dst, src); } - while ( yy_32 != 32 ); - return; - } + dst -= 800; + yy_32 += 2; + } while (yy_32 != 32); + return; } - break; - case 4: // upper (top transparent), with lighting - WorldBoolFlag = 0; - xx_32 = 30; - while ( dst >= gpBufEnd ) - { - dst += xx_32; - src += (32 - (_BYTE)xx_32) & 2; - WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; - if ( WorldBoolFlag ) - { - asm_trans_light_cel_0_2(32 - xx_32, tbl, dst, src); - } - else - { - asm_trans_light_cel_1_3(32 - xx_32, tbl, dst, src); - } - dst -= 800; - xx_32 -= 2; - if ( xx_32 < 0 ) - { - i = 8; - do - { - if ( dst < gpBufEnd ) - break; - asm_trans_light_square_1_3(8, tbl, dst, src); - dst -= 800; - if ( dst < gpBufEnd ) - break; - asm_trans_light_square_0_2(8, tbl, dst, src); - dst -= 800; - --i; + } + break; + case 3: // upper (top transparent), with lighting + WorldBoolFlag = 0; + xx_32 = 30; + while (dst >= gpBufEnd) { + WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; + if (WorldBoolFlag) { + asm_trans_light_cel_0_2(32 - xx_32, tbl, dst, src); + } else { + asm_trans_light_cel_1_3(32 - xx_32, tbl, dst, src); + } + src += (unsigned char)src & 2; + dst = &dst[xx_32 - 800]; + xx_32 -= 2; + if (xx_32 < 0) { + yy_32 = 2; + do { + if (dst < gpBufEnd) + break; + WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; + if (WorldBoolFlag) { + asm_trans_light_cel_0_2(32 - yy_32, tbl, dst, src); + } else { + asm_trans_light_cel_1_3(32 - yy_32, tbl, dst, src); } - while ( i ); - return; - } + src += (unsigned char)src & 2; + dst = &dst[yy_32 - 800]; + yy_32 += 2; + } while (yy_32 != 32); + return; } - break; - default: // upper (top transparent), with lighting - WorldBoolFlag = 0; - xx_32 = 30; - while ( dst >= gpBufEnd ) - { - WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; - if ( WorldBoolFlag ) - { - asm_trans_light_cel_0_2(32 - xx_32, tbl, dst, src); - } - else - { - asm_trans_light_cel_1_3(32 - xx_32, tbl, dst, src); - } - src += (unsigned char)src & 2; - dst = &dst[xx_32 - 800]; - xx_32 -= 2; - if ( xx_32 < 0 ) - { - i = 8; - do - { - if ( dst < gpBufEnd ) - break; - asm_trans_light_square_1_3(8, tbl, dst, src); - dst -= 800; - if ( dst < gpBufEnd ) - break; - asm_trans_light_square_0_2(8, tbl, dst, src); - dst -= 800; - --i; - } - while ( i ); - return; - } + } + break; + case 4: // upper (top transparent), with lighting + WorldBoolFlag = 0; + xx_32 = 30; + while (dst >= gpBufEnd) { + dst += xx_32; + src += (32 - (_BYTE)xx_32) & 2; + WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; + if (WorldBoolFlag) { + asm_trans_light_cel_0_2(32 - xx_32, tbl, dst, src); + } else { + asm_trans_light_cel_1_3(32 - xx_32, tbl, dst, src); } - break; + dst -= 800; + xx_32 -= 2; + if (xx_32 < 0) { + i = 8; + do { + if (dst < gpBufEnd) + break; + asm_trans_light_square_1_3(8, tbl, dst, src); + dst -= 800; + if (dst < gpBufEnd) + break; + asm_trans_light_square_0_2(8, tbl, dst, src); + dst -= 800; + --i; + } while (i); + return; + } + } + break; + default: // upper (top transparent), with lighting + WorldBoolFlag = 0; + xx_32 = 30; + while (dst >= gpBufEnd) { + WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; + if (WorldBoolFlag) { + asm_trans_light_cel_0_2(32 - xx_32, tbl, dst, src); + } else { + asm_trans_light_cel_1_3(32 - xx_32, tbl, dst, src); + } + src += (unsigned char)src & 2; + dst = &dst[xx_32 - 800]; + xx_32 -= 2; + if (xx_32 < 0) { + i = 8; + do { + if (dst < gpBufEnd) + break; + asm_trans_light_square_1_3(8, tbl, dst, src); + dst -= 800; + if (dst < gpBufEnd) + break; + asm_trans_light_square_0_2(8, tbl, dst, src); + dst -= 800; + --i; + } while (i); + return; + } + } + break; } return; } src = (unsigned char *)pSpeedCels - + *(_DWORD *)&gpCelFrame[4 * (light_table_index + 16 * (level_cel_block & 0xFFF))]; + + *(_DWORD *)&gpCelFrame[4 * (light_table_index + 16 * (level_cel_block & 0xFFF))]; cel_type_16 = (unsigned char)(level_cel_block >> 12); -LABEL_11: + LABEL_11: - switch ( cel_type_16 ) - { - case 8: // upper (top transparent), without lighting - i = 16; - do - { - if ( dst < gpBufEnd ) + switch (cel_type_16) { + case 8: // upper (top transparent), without lighting + i = 16; + do { + if (dst < gpBufEnd) + break; + j = 8; + do { + dst[1] = src[1]; + dst[3] = src[3]; + src += 4; + dst += 4; + --j; + } while (j); + dst -= 800; + if (dst < gpBufEnd) + break; + j = 8; + do { + dst[0] = src[0]; + dst[2] = src[2]; + src += 4; + dst += 4; + --j; + } while (j); + dst -= 800; + --i; + } while (i); + break; + case 9: // upper (top transparent), without lighting + WorldBoolFlag = (unsigned char)pbDst & 1; + yy_32 = 32; + LABEL_251: + xx_32 = 32; + while (1) { + while (1) { + width = (unsigned char)*src++; + if ((width & 0x80u) == 0) break; - j = 8; - do - { + _LOBYTE(width) = -(char)width; + dst += width; + xx_32 -= width; + if (!xx_32) { + LABEL_271: + WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; + dst -= 800; + if (!--yy_32) + return; + goto LABEL_251; + } + } + xx_32 -= width; + if (dst < gpBufEnd) + return; + if (((unsigned char)dst & 1) == WorldBoolFlag) { + chk_sh_and = width >> 1; + if (!(width & 1)) + goto LABEL_258; + ++src; + ++dst; + if (chk_sh_and) { + LABEL_265: + n_draw_shift = chk_sh_and >> 1; + if (chk_sh_and & 1) { + dst[0] = src[0]; + src += 2; + dst += 2; + } + if (n_draw_shift) { + do { + dst[0] = src[0]; + dst[2] = src[2]; + src += 4; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + goto LABEL_268; + } + } else { + chk_sh_and = width >> 1; + if (!(width & 1)) + goto LABEL_265; + *dst++ = *src++; + if (chk_sh_and) { + LABEL_258: + n_draw_shift = chk_sh_and >> 1; + if (chk_sh_and & 1) { + dst[1] = src[1]; + src += 2; + dst += 2; + } + if (n_draw_shift) { + do { + dst[1] = src[1]; + dst[3] = src[3]; + src += 4; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + goto LABEL_268; + } + } + LABEL_268: + if (!xx_32) + goto LABEL_271; + } + break; + case 10: // upper (top transparent), without lighting + WorldBoolFlag = 0; + xx_32 = 30; + while (dst >= gpBufEnd) { + dst += xx_32; + x_minus = 32 - xx_32; + WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; + if (WorldBoolFlag) { + n_draw_shift = x_minus >> 2; + if (x_minus & 2) { + dst[1] = src[3]; + src += 4; + dst += 2; + } + if (n_draw_shift) { + do { + dst[1] = src[1]; + dst[3] = src[3]; + src += 4; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + } else { + n_draw_shift = x_minus >> 2; + if (x_minus & 2) { + dst[0] = src[2]; + src += 4; + dst += 2; + } + if (n_draw_shift) { + do { + dst[0] = src[0]; + dst[2] = src[2]; + src += 4; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + } + dst -= 800; + xx_32 -= 2; + if (xx_32 < 0) { + yy_32 = 2; + do { + if (dst < gpBufEnd) + break; + dst += yy_32; + y_minus = 32 - yy_32; + WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; + if (WorldBoolFlag) { + n_draw_shift = y_minus >> 2; + if (y_minus & 2) { + dst[1] = src[3]; + src += 4; + dst += 2; + } + if (n_draw_shift) { + do { + dst[1] = src[1]; + dst[3] = src[3]; + src += 4; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + } else { + n_draw_shift = y_minus >> 2; + if (y_minus & 2) { + dst[0] = src[2]; + src += 4; + dst += 2; + } + if (n_draw_shift) { + do { + dst[0] = src[0]; + dst[2] = src[2]; + src += 4; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + } + dst -= 800; + yy_32 += 2; + } while (yy_32 != 32); + return; + } + } + break; + case 11: // upper (top transparent), without lighting + WorldBoolFlag = 0; + xx_32 = 30; + while (dst >= gpBufEnd) { + x_minus = 32 - xx_32; + WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; + if (WorldBoolFlag) { + for (n_draw_shift = x_minus >> 2; n_draw_shift; --n_draw_shift) { dst[1] = src[1]; dst[3] = src[3]; src += 4; dst += 4; - --j; } - while ( j ); - dst -= 800; - if ( dst < gpBufEnd ) - break; - j = 8; - do - { + if (x_minus & 2) { + dst[1] = src[1]; + src += 4; + dst += 2; + } + } else { + for (n_draw_shift = x_minus >> 2; n_draw_shift; --n_draw_shift) { dst[0] = src[0]; dst[2] = src[2]; src += 4; dst += 4; - --j; } - while ( j ); - dst -= 800; - --i; + if (x_minus & 2) { + dst[0] = src[0]; + src += 4; + dst += 2; + } } - while ( i ); - break; - case 9: // upper (top transparent), without lighting - WorldBoolFlag = (unsigned char)pbDst & 1; - yy_32 = 32; -LABEL_251: - xx_32 = 32; - while ( 1 ) - { - while ( 1 ) - { - width = (unsigned char)*src++; - if ( (width & 0x80u) == 0 ) + dst = &dst[xx_32 - 800]; + xx_32 -= 2; + if (xx_32 < 0) { + yy_32 = 2; + do { + if (dst < gpBufEnd) break; - _LOBYTE(width) = -(char)width; - dst += width; - xx_32 -= width; - if ( !xx_32 ) - { -LABEL_271: - WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; - dst -= 800; - if ( !--yy_32 ) - return; - goto LABEL_251; - } - } - xx_32 -= width; - if ( dst < gpBufEnd ) - return; - if ( ((unsigned char)dst & 1) == WorldBoolFlag ) - { - chk_sh_and = width >> 1; - if ( !(width & 1) ) - goto LABEL_258; - ++src; - ++dst; - if ( chk_sh_and ) - { -LABEL_265: - n_draw_shift = chk_sh_and >> 1; - if ( chk_sh_and & 1 ) - { - dst[0] = src[0]; - src += 2; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - dst[0] = src[0]; - dst[2] = src[2]; - src += 4; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - goto LABEL_268; - } - } - else - { - chk_sh_and = width >> 1; - if ( !(width & 1) ) - goto LABEL_265; - *dst++ = *src++; - if ( chk_sh_and ) - { -LABEL_258: - n_draw_shift = chk_sh_and >> 1; - if ( chk_sh_and & 1 ) - { - dst[1] = src[1]; - src += 2; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - dst[1] = src[1]; - dst[3] = src[3]; - src += 4; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - goto LABEL_268; - } - } -LABEL_268: - if ( !xx_32 ) - goto LABEL_271; - } - break; - case 10: // upper (top transparent), without lighting - WorldBoolFlag = 0; - xx_32 = 30; - while ( dst >= gpBufEnd ) - { - dst += xx_32; - x_minus = 32 - xx_32; - WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; - if ( WorldBoolFlag ) - { - n_draw_shift = x_minus >> 2; - if ( x_minus & 2 ) - { - dst[1] = src[3]; - src += 4; - dst += 2; - } - if ( n_draw_shift ) - { - do - { + y_minus = 32 - yy_32; + WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; + if (WorldBoolFlag) { + for (n_draw_shift = y_minus >> 2; n_draw_shift; --n_draw_shift) { dst[1] = src[1]; dst[3] = src[3]; src += 4; dst += 4; - --n_draw_shift; } - while ( n_draw_shift ); - } - } - else - { - n_draw_shift = x_minus >> 2; - if ( x_minus & 2 ) - { - dst[0] = src[2]; - src += 4; - dst += 2; - } - if ( n_draw_shift ) - { - do + if (x_minus & 2) /// BUGFIX: change to `y_minus & 2` { + dst[1] = src[1]; + src += 4; + dst += 2; + } + } else { + for (n_draw_shift = y_minus >> 2; n_draw_shift; --n_draw_shift) { dst[0] = src[0]; dst[2] = src[2]; src += 4; dst += 4; - --n_draw_shift; } - while ( n_draw_shift ); - } - } - dst -= 800; - xx_32 -= 2; - if ( xx_32 < 0 ) - { - yy_32 = 2; - do - { - if ( dst < gpBufEnd ) - break; - dst += yy_32; - y_minus = 32 - yy_32; - WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; - if ( WorldBoolFlag ) + if (x_minus & 2) /// BUGFIX: change to `y_minus & 2` { - n_draw_shift = y_minus >> 2; - if ( y_minus & 2 ) - { - dst[1] = src[3]; - src += 4; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - dst[1] = src[1]; - dst[3] = src[3]; - src += 4; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } + dst[0] = src[0]; + src += 4; + dst += 2; } - else - { - n_draw_shift = y_minus >> 2; - if ( y_minus & 2 ) - { - dst[0] = src[2]; - src += 4; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - dst[0] = src[0]; - dst[2] = src[2]; - src += 4; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - } - dst -= 800; - yy_32 += 2; } - while ( yy_32 != 32 ); - return; - } + dst = &dst[yy_32 - 800]; + yy_32 += 2; + } while (yy_32 != 32); + return; } - break; - case 11: // upper (top transparent), without lighting - WorldBoolFlag = 0; - xx_32 = 30; - while ( dst >= gpBufEnd ) - { - x_minus = 32 - xx_32; - WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; - if ( WorldBoolFlag ) - { - for ( n_draw_shift = x_minus >> 2; n_draw_shift; --n_draw_shift ) - { + } + break; + case 12: // upper (top transparent), without lighting + WorldBoolFlag = 0; + xx_32 = 30; + while (dst >= gpBufEnd) { + dst += xx_32; + x_minus = 32 - xx_32; + WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; + if (WorldBoolFlag) { + n_draw_shift = x_minus >> 2; + if (x_minus & 2) { + dst[1] = src[3]; + src += 4; + dst += 2; + } + if (n_draw_shift) { + do { dst[1] = src[1]; dst[3] = src[3]; src += 4; dst += 4; - } - if ( x_minus & 2 ) - { - dst[1] = src[1]; - src += 4; - dst += 2; - } + --n_draw_shift; + } while (n_draw_shift); } - else - { - for ( n_draw_shift = x_minus >> 2; n_draw_shift; --n_draw_shift ) - { + } else { + n_draw_shift = x_minus >> 2; + if (x_minus & 2) { + dst[0] = src[2]; + src += 4; + dst += 2; + } + if (n_draw_shift) { + do { dst[0] = src[0]; dst[2] = src[2]; src += 4; dst += 4; - } - if ( x_minus & 2 ) - { - dst[0] = src[0]; - src += 4; - dst += 2; - } - } - dst = &dst[xx_32 - 800]; - xx_32 -= 2; - if ( xx_32 < 0 ) - { - yy_32 = 2; - do - { - if ( dst < gpBufEnd ) - break; - y_minus = 32 - yy_32; - WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; - if ( WorldBoolFlag ) - { - for ( n_draw_shift = y_minus >> 2; n_draw_shift; --n_draw_shift ) - { - dst[1] = src[1]; - dst[3] = src[3]; - src += 4; - dst += 4; - } - if ( x_minus & 2 ) /// BUGFIX: change to `y_minus & 2` - { - dst[1] = src[1]; - src += 4; - dst += 2; - } - } - else - { - for ( n_draw_shift = y_minus >> 2; n_draw_shift; --n_draw_shift ) - { - dst[0] = src[0]; - dst[2] = src[2]; - src += 4; - dst += 4; - } - if ( x_minus & 2 ) /// BUGFIX: change to `y_minus & 2` - { - dst[0] = src[0]; - src += 4; - dst += 2; - } - } - dst = &dst[yy_32 - 800]; - yy_32 += 2; - } - while ( yy_32 != 32 ); - return; + --n_draw_shift; + } while (n_draw_shift); } } - break; - case 12: // upper (top transparent), without lighting - WorldBoolFlag = 0; - xx_32 = 30; - while ( dst >= gpBufEnd ) - { - dst += xx_32; - x_minus = 32 - xx_32; - WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; - if ( WorldBoolFlag ) - { - n_draw_shift = x_minus >> 2; - if ( x_minus & 2 ) - { - dst[1] = src[3]; - src += 4; - dst += 2; - } - if ( n_draw_shift) - { - do - { - dst[1] = src[1]; - dst[3] = src[3]; - src += 4; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - } - else - { - n_draw_shift = x_minus >> 2; - if ( x_minus & 2 ) - { - dst[0] = src[2]; - src += 4; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - dst[0] = src[0]; - dst[2] = src[2]; - src += 4; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - } - dst -= 800; - xx_32 -= 2; - if ( xx_32 < 0 ) - { - i = 8; - do - { - if ( dst < gpBufEnd ) - break; - j = 8; - do - { - dst[1] = src[1]; - dst[3] = src[3]; - src += 4; - dst += 4; - --j; - } - while ( j ); - dst -= 800; - if ( dst < gpBufEnd ) - break; - j = 8; - do - { - dst[0] = src[0]; - dst[2] = src[2]; - src += 4; - dst += 4; - --j; - } - while ( j ); - dst -= 800; - --i; - } - while ( i ); - return; - } - } - break; - default: // upper (top transparent), without lighting - WorldBoolFlag = 0; - xx_32 = 30; - while ( dst >= gpBufEnd ) - { - x_minus = 32 - xx_32; - WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; - if ( WorldBoolFlag ) - { - for ( n_draw_shift = x_minus >> 2; n_draw_shift; --n_draw_shift ) - { + dst -= 800; + xx_32 -= 2; + if (xx_32 < 0) { + i = 8; + do { + if (dst < gpBufEnd) + break; + j = 8; + do { dst[1] = src[1]; dst[3] = src[3]; src += 4; dst += 4; - } - if ( (32 - (_BYTE)xx_32) & 2 ) - { - dst[1] = src[1]; - src += 4; - dst += 2; - } - } - else - { - for ( n_draw_shift = x_minus >> 2; n_draw_shift; --n_draw_shift ) - { + --j; + } while (j); + dst -= 800; + if (dst < gpBufEnd) + break; + j = 8; + do { dst[0] = src[0]; dst[2] = src[2]; src += 4; dst += 4; - } - if ( (32 - (_BYTE)xx_32) & 2 ) - { - dst[0] = src[0]; - src += 4; - dst += 2; - } + --j; + } while (j); + dst -= 800; + --i; + } while (i); + return; + } + } + break; + default: // upper (top transparent), without lighting + WorldBoolFlag = 0; + xx_32 = 30; + while (dst >= gpBufEnd) { + x_minus = 32 - xx_32; + WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; + if (WorldBoolFlag) { + for (n_draw_shift = x_minus >> 2; n_draw_shift; --n_draw_shift) { + dst[1] = src[1]; + dst[3] = src[3]; + src += 4; + dst += 4; } - dst = &dst[xx_32 - 800]; - xx_32 -= 2; - if ( xx_32 < 0 ) - { - i = 8; - do - { - if ( dst < gpBufEnd ) - break; - j = 8; - do - { - dst[1] = src[1]; - dst[3] = src[3]; - src += 4; - dst += 4; - --j; - } - while ( j ); - dst -= 800; - if ( dst < gpBufEnd ) - break; - j = 8; - do - { - dst[0] = src[0]; - dst[2] = src[2]; - src += 4; - dst += 4; - --j; - } - while ( j ); - dst -= 800; - --i; - } - while ( i ); - return; + if ((32 - (_BYTE)xx_32) & 2) { + dst[1] = src[1]; + src += 4; + dst += 2; + } + } else { + for (n_draw_shift = x_minus >> 2; n_draw_shift; --n_draw_shift) { + dst[0] = src[0]; + dst[2] = src[2]; + src += 4; + dst += 4; + } + if ((32 - (_BYTE)xx_32) & 2) { + dst[0] = src[0]; + src += 4; + dst += 2; } } - break; + dst = &dst[xx_32 - 800]; + xx_32 -= 2; + if (xx_32 < 0) { + i = 8; + do { + if (dst < gpBufEnd) + break; + j = 8; + do { + dst[1] = src[1]; + dst[3] = src[3]; + src += 4; + dst += 4; + --j; + } while (j); + dst -= 800; + if (dst < gpBufEnd) + break; + j = 8; + do { + dst[0] = src[0]; + dst[2] = src[2]; + src += 4; + dst += 4; + --j; + } while (j); + dst -= 800; + --i; + } while (i); + return; + } + } + break; } return; } - if ( level_cel_block & 0x8000 ) + if (level_cel_block & 0x8000) level_cel_block = *(_DWORD *)&gpCelFrame[64 * (level_cel_block & 0xFFF)] - + (unsigned short)(level_cel_block & 0xF000); + + (unsigned short)(level_cel_block & 0xF000); src = (unsigned char *)pDungeonCels + *((_DWORD *)pDungeonCels + (level_cel_block & 0xFFF)); cel_type_16 = (level_cel_block >> 12) & 7; - switch ( cel_type_16 ) - { - case 0: // upper (top transparent), black - i = 16; - do - { - if ( dst < gpBufEnd ) - break; - j = 8; - do - { - dst[1] = 0; - dst[3] = 0; - dst += 4; - --j; - } - while ( j ); - dst -= 800; - if ( dst < gpBufEnd ) - break; - j = 8; - do - { - dst[0] = 0; - dst[2] = 0; - dst += 4; - --j; - } - while ( j ); - dst -= 800; - --i; - } - while ( i ); - break; - case 1: // upper (top transparent), black - WorldBoolFlag = (unsigned char)pbDst & 1; - xx_32 = 32; - while ( 1 ) - { - yy_32 = 32; - do - { - while ( 1 ) - { - width = (unsigned char)*src++; - if ( (width & 0x80u) != 0 ) - break; - yy_32 -= width; - if ( dst < gpBufEnd ) - return; - src += width; - if ( ((unsigned char)dst & 1) == WorldBoolFlag ) - { - chk_sh_and = width >> 1; - if ( !(width & 1) ) - goto LABEL_378; - ++dst; - if ( chk_sh_and ) - { -LABEL_385: - n_draw_shift = chk_sh_and >> 1; - if ( chk_sh_and & 1 ) - { - dst[0] = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - dst[0] = 0; - dst[2] = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - goto LABEL_388; - } - } - else - { - chk_sh_and = width >> 1; - if ( !(width & 1) ) - goto LABEL_385; - *dst++ = 0; - if ( chk_sh_and ) - { -LABEL_378: - n_draw_shift = chk_sh_and >> 1; - if ( chk_sh_and & 1 ) - { - dst[1] = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - dst[1] = 0; - dst[3] = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - goto LABEL_388; - } - } -LABEL_388: - if ( !yy_32 ) - goto LABEL_391; - } - _LOBYTE(width) = -(char)width; - dst += width; + switch (cel_type_16) { + case 0: // upper (top transparent), black + i = 16; + do { + if (dst < gpBufEnd) + break; + j = 8; + do { + dst[1] = 0; + dst[3] = 0; + dst += 4; + --j; + } while (j); + dst -= 800; + if (dst < gpBufEnd) + break; + j = 8; + do { + dst[0] = 0; + dst[2] = 0; + dst += 4; + --j; + } while (j); + dst -= 800; + --i; + } while (i); + break; + case 1: // upper (top transparent), black + WorldBoolFlag = (unsigned char)pbDst & 1; + xx_32 = 32; + while (1) { + yy_32 = 32; + do { + while (1) { + width = (unsigned char)*src++; + if ((width & 0x80u) != 0) + break; yy_32 -= width; - } - while ( yy_32 ); -LABEL_391: - WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; - dst -= 800; - if ( !--xx_32 ) - return; - } - case 2: // upper (top transparent), black - WorldBoolFlag = 0; - for ( xx_32 = 30; ; xx_32 -= 2 ) - { - if ( dst < gpBufEnd ) - return; - dst += xx_32; - x_minus = 32 - xx_32; - WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; - if ( WorldBoolFlag ) - { - n_draw_shift = x_minus >> 2; - if ( x_minus & 2 ) - { - dst[1] = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - dst[1] = 0; - dst[3] = 0; - dst += 4; - --n_draw_shift; + if (dst < gpBufEnd) + return; + src += width; + if (((unsigned char)dst & 1) == WorldBoolFlag) { + chk_sh_and = width >> 1; + if (!(width & 1)) + goto LABEL_378; + ++dst; + if (chk_sh_and) { + LABEL_385: + n_draw_shift = chk_sh_and >> 1; + if (chk_sh_and & 1) { + dst[0] = 0; + dst += 2; + } + if (n_draw_shift) { + do { + dst[0] = 0; + dst[2] = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + goto LABEL_388; } - while ( n_draw_shift ); - } - } - else - { - n_draw_shift = x_minus >> 2; - if ( x_minus & 2 ) - { - dst[0] = 0; - dst += 2; - } - if ( n_draw_shift) - { - do - { - dst[0] = 0; - dst[2] = 0; - dst += 4; - --n_draw_shift; + } else { + chk_sh_and = width >> 1; + if (!(width & 1)) + goto LABEL_385; + *dst++ = 0; + if (chk_sh_and) { + LABEL_378: + n_draw_shift = chk_sh_and >> 1; + if (chk_sh_and & 1) { + dst[1] = 0; + dst += 2; + } + if (n_draw_shift) { + do { + dst[1] = 0; + dst[3] = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + goto LABEL_388; } - while ( n_draw_shift ); } + LABEL_388: + if (!yy_32) + goto LABEL_391; } - dst -= 800; - if ( !xx_32 ) - break; - } - yy_32 = 2; - do - { - if ( dst < gpBufEnd ) - break; - dst += yy_32; - y_minus = 32 - yy_32; - WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; - if ( WorldBoolFlag ) - { - n_draw_shift = y_minus >> 2; - if ( y_minus & 2 ) - { - dst[1] = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - dst[1] = 0; - dst[3] = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - } - else - { - n_draw_shift = y_minus >> 2; - if ( y_minus & 2 ) - { - dst[0] = 0; - dst += 2; - } - if ( n_draw_shift) - { - do - { - dst[0] = 0; - dst[2] = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - } - dst -= 800; - yy_32 += 2; - } - while ( yy_32 != 32 ); - break; - case 3: // upper (top transparent), black - WorldBoolFlag = 0; - for ( xx_32 = 30; ; xx_32 -= 2 ) - { - if ( dst < gpBufEnd ) - return; - x_minus = 32 - xx_32; - WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; - if ( WorldBoolFlag ) - { - n_draw_shift = x_minus >> 2; - if ( x_minus & 2 ) - { - dst[1] = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - dst[1] = 0; - dst[3] = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - } - else - { - n_draw_shift = x_minus >> 2; - if ( x_minus & 2 ) - { - dst[0] = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - dst[0] = 0; - dst[2] = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - } - dst -= 800; - if ( !xx_32 ) - break; - dst += xx_32; - } - yy_32 = 2; - do - { - if ( dst < gpBufEnd ) - break; - y_minus = 32 - yy_32; - WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; - if ( WorldBoolFlag ) - { - n_draw_shift = y_minus >> 2; - if ( y_minus & 2 ) - { - dst[1] = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - dst[1] = 0; - dst[3] = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - } - else - { - n_draw_shift = y_minus >> 2; - if ( y_minus & 2 ) - { - dst[0] = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - dst[0] = 0; - dst[2] = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - } - dst = &dst[yy_32 - 800]; - yy_32 += 2; - } - while ( yy_32 != 32 ); - break; - case 4: // upper (top transparent), black - WorldBoolFlag = 0; - for ( xx_32 = 30; ; xx_32 -= 2 ) - { - if ( dst < gpBufEnd ) - return; - dst += xx_32; - x_minus = 32 - xx_32; - WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; - if ( WorldBoolFlag ) - { - n_draw_shift = x_minus >> 2; - if ( x_minus & 2 ) - { - dst[1] = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - dst[1] = 0; - dst[3] = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - } - else - { - n_draw_shift = x_minus >> 2; - if ( x_minus & 2 ) - { - dst[0] = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - dst[0] = 0; - dst[2] = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - } - dst -= 800; - if ( !xx_32 ) - break; - } - i = 8; - do - { - if ( dst < gpBufEnd ) - break; - j = 8; - do - { + _LOBYTE(width) = -(char)width; + dst += width; + yy_32 -= width; + } while (yy_32); + LABEL_391: + WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; + dst -= 800; + if (!--xx_32) + return; + } + case 2: // upper (top transparent), black + WorldBoolFlag = 0; + for (xx_32 = 30;; xx_32 -= 2) { + if (dst < gpBufEnd) + return; + dst += xx_32; + x_minus = 32 - xx_32; + WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; + if (WorldBoolFlag) { + n_draw_shift = x_minus >> 2; + if (x_minus & 2) { dst[1] = 0; - dst[3] = 0; - dst += 4; - --j; + dst += 2; } - while ( j ); - dst -= 800; - if ( dst < gpBufEnd ) - break; - j = 8; - do - { - dst[0] = 0; - dst[2] = 0; - dst += 4; - --j; - } - while ( j ); - dst -= 800; - --i; - } - while ( i ); - break; - default: // upper (top transparent), black - WorldBoolFlag = 0; - for ( xx_32 = 30; ; xx_32 -= 2 ) - { - if ( dst < gpBufEnd ) - return; - x_minus = 32 - xx_32; - WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; - if ( WorldBoolFlag ) - { - n_draw_shift = x_minus >> 2; - if ( x_minus & 2 ) - { + if (n_draw_shift) { + do { dst[1] = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - dst[1] = 0; - dst[3] = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } + dst[3] = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); } - else - { - n_draw_shift = x_minus >> 2; - if ( x_minus & 2 ) - { - dst[0] = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - dst[0] = 0; - dst[2] = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - } - dst -= 800; - if ( !xx_32 ) - break; - dst += xx_32; - } - i = 8; - do - { - if ( dst < gpBufEnd ) - break; - j = 8; - do - { - dst[1] = 0; - dst[3] = 0; - dst += 4; - --j; - } - while ( j ); - dst -= 800; - if ( dst < gpBufEnd ) - break; - j = 8; - do - { + } else { + n_draw_shift = x_minus >> 2; + if (x_minus & 2) { dst[0] = 0; - dst[2] = 0; - dst += 4; - --j; + dst += 2; + } + if (n_draw_shift) { + do { + dst[0] = 0; + dst[2] = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); } - while ( j ); - dst -= 800; - --i; } - while ( i ); - break; + dst -= 800; + if (!xx_32) + break; + } + yy_32 = 2; + do { + if (dst < gpBufEnd) + break; + dst += yy_32; + y_minus = 32 - yy_32; + WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; + if (WorldBoolFlag) { + n_draw_shift = y_minus >> 2; + if (y_minus & 2) { + dst[1] = 0; + dst += 2; + } + if (n_draw_shift) { + do { + dst[1] = 0; + dst[3] = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + } else { + n_draw_shift = y_minus >> 2; + if (y_minus & 2) { + dst[0] = 0; + dst += 2; + } + if (n_draw_shift) { + do { + dst[0] = 0; + dst[2] = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + } + dst -= 800; + yy_32 += 2; + } while (yy_32 != 32); + break; + case 3: // upper (top transparent), black + WorldBoolFlag = 0; + for (xx_32 = 30;; xx_32 -= 2) { + if (dst < gpBufEnd) + return; + x_minus = 32 - xx_32; + WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; + if (WorldBoolFlag) { + n_draw_shift = x_minus >> 2; + if (x_minus & 2) { + dst[1] = 0; + dst += 2; + } + if (n_draw_shift) { + do { + dst[1] = 0; + dst[3] = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + } else { + n_draw_shift = x_minus >> 2; + if (x_minus & 2) { + dst[0] = 0; + dst += 2; + } + if (n_draw_shift) { + do { + dst[0] = 0; + dst[2] = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + } + dst -= 800; + if (!xx_32) + break; + dst += xx_32; + } + yy_32 = 2; + do { + if (dst < gpBufEnd) + break; + y_minus = 32 - yy_32; + WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; + if (WorldBoolFlag) { + n_draw_shift = y_minus >> 2; + if (y_minus & 2) { + dst[1] = 0; + dst += 2; + } + if (n_draw_shift) { + do { + dst[1] = 0; + dst[3] = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + } else { + n_draw_shift = y_minus >> 2; + if (y_minus & 2) { + dst[0] = 0; + dst += 2; + } + if (n_draw_shift) { + do { + dst[0] = 0; + dst[2] = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + } + dst = &dst[yy_32 - 800]; + yy_32 += 2; + } while (yy_32 != 32); + break; + case 4: // upper (top transparent), black + WorldBoolFlag = 0; + for (xx_32 = 30;; xx_32 -= 2) { + if (dst < gpBufEnd) + return; + dst += xx_32; + x_minus = 32 - xx_32; + WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; + if (WorldBoolFlag) { + n_draw_shift = x_minus >> 2; + if (x_minus & 2) { + dst[1] = 0; + dst += 2; + } + if (n_draw_shift) { + do { + dst[1] = 0; + dst[3] = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + } else { + n_draw_shift = x_minus >> 2; + if (x_minus & 2) { + dst[0] = 0; + dst += 2; + } + if (n_draw_shift) { + do { + dst[0] = 0; + dst[2] = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + } + dst -= 800; + if (!xx_32) + break; + } + i = 8; + do { + if (dst < gpBufEnd) + break; + j = 8; + do { + dst[1] = 0; + dst[3] = 0; + dst += 4; + --j; + } while (j); + dst -= 800; + if (dst < gpBufEnd) + break; + j = 8; + do { + dst[0] = 0; + dst[2] = 0; + dst += 4; + --j; + } while (j); + dst -= 800; + --i; + } while (i); + break; + default: // upper (top transparent), black + WorldBoolFlag = 0; + for (xx_32 = 30;; xx_32 -= 2) { + if (dst < gpBufEnd) + return; + x_minus = 32 - xx_32; + WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; + if (WorldBoolFlag) { + n_draw_shift = x_minus >> 2; + if (x_minus & 2) { + dst[1] = 0; + dst += 2; + } + if (n_draw_shift) { + do { + dst[1] = 0; + dst[3] = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + } else { + n_draw_shift = x_minus >> 2; + if (x_minus & 2) { + dst[0] = 0; + dst += 2; + } + if (n_draw_shift) { + do { + dst[0] = 0; + dst[2] = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + } + dst -= 800; + if (!xx_32) + break; + dst += xx_32; + } + i = 8; + do { + if (dst < gpBufEnd) + break; + j = 8; + do { + dst[1] = 0; + dst[3] = 0; + dst += 4; + --j; + } while (j); + dst -= 800; + if (dst < gpBufEnd) + break; + j = 8; + do { + dst[0] = 0; + dst[2] = 0; + dst += 4; + --j; + } while (j); + dst -= 800; + --i; + } while (i); + break; } } void __fastcall drawBottomArchesUpperScreen(unsigned char *pbDst, unsigned int *pMask) { - unsigned char *dst; // edi MAPDST - unsigned char *src; // esi MAPDST - short cel_type_16; // ax MAPDST - int xx_32; // edx MAPDST - unsigned int left_shift; // edx MAPDST - int yy_32; // edx MAPDST - int width; // eax MAPDST - int and80_i; // ecx MAPDST + unsigned char *dst; // edi MAPDST + unsigned char *src; // esi MAPDST + short cel_type_16; // ax MAPDST + int xx_32; // edx MAPDST + unsigned int left_shift; // edx MAPDST + int yy_32; // edx MAPDST + int width; // eax MAPDST + int and80_i; // ecx MAPDST unsigned int n_draw_shift; // ecx MAPDST - signed int i; // ecx MAPDST + signed int i; // ecx MAPDST unsigned char *tbl; gpCelFrame = (unsigned char *)speed_cel_frame_num_from_light_index_frame_num; dst = pbDst; gpDrawMask = pMask; - if ( !(_BYTE)light_table_index ) - { - if ( level_cel_block & 0x8000 ) + if (!(_BYTE)light_table_index) { + if (level_cel_block & 0x8000) level_cel_block = *(_DWORD *)&gpCelFrame[64 * (level_cel_block & 0xFFF)] - + (unsigned short)(level_cel_block & 0xF000); + + (unsigned short)(level_cel_block & 0xF000); src = (unsigned char *)pDungeonCels + *((_DWORD *)pDungeonCels + (level_cel_block & 0xFFF)); cel_type_16 = ((level_cel_block >> 12) & 7) + 8; -LABEL_12: - switch ( cel_type_16 ) - { - case 8: // upper (bottom transparent), without lighting - xx_32 = 32; - do - { - if ( dst < gpBufEnd ) - break; - left_shift = *gpDrawMask; - i = 32; - do - { - if ( left_shift & 0x80000000 ) + LABEL_12: + switch (cel_type_16) { + case 8: // upper (bottom transparent), without lighting + xx_32 = 32; + do { + if (dst < gpBufEnd) + break; + left_shift = *gpDrawMask; + i = 32; + do { + if (left_shift & 0x80000000) + dst[0] = src[0]; + left_shift *= 2; + ++src; + ++dst; + --i; + } while (i); + dst -= 800; + --gpDrawMask; + --xx_32; + } while (xx_32); + break; + case 9: // upper (bottom transparent), without lighting + xx_32 = 32; + do { + gdwCurrentMask = *gpDrawMask; + yy_32 = 32; + do { + while (1) { + width = (unsigned char)*src++; + if ((width & 0x80u) == 0) + break; + _LOBYTE(width) = -(char)width; + dst += width; + if (width & 0x1F) + gdwCurrentMask <<= width & 0x1F; + yy_32 -= width; + if (!yy_32) + goto LABEL_129; + } + yy_32 -= width; + if (dst < gpBufEnd) + return; + left_shift = gdwCurrentMask; + and80_i = width; + do { + if (left_shift & 0x80000000) dst[0] = src[0]; left_shift *= 2; ++src; ++dst; - --i; - } - while ( i ); - dst -= 800; - --gpDrawMask; - --xx_32; + --and80_i; + } while (and80_i); + gdwCurrentMask = left_shift; + } while (yy_32); + LABEL_129: + dst -= 800; + --gpDrawMask; + --xx_32; + } while (xx_32); + break; + case 10: // upper (bottom transparent), without lighting + xx_32 = 30; + while (dst >= gpBufEnd) { + dst += xx_32; + n_draw_shift = (unsigned int)(32 - xx_32) >> 2; + if ((32 - xx_32) & 2) { + *(_WORD *)dst = *((_WORD *)src + 1); + src += 4; + dst += 2; } - while ( xx_32 ); - break; - case 9: // upper (bottom transparent), without lighting - xx_32 = 32; - do - { - gdwCurrentMask = *gpDrawMask; - yy_32 = 32; - do - { - while ( 1 ) - { - width = (unsigned char)*src++; - if ( (width & 0x80u) == 0 ) - break; - _LOBYTE(width) = -(char)width; - dst += width; - if ( width & 0x1F ) - gdwCurrentMask <<= width & 0x1F; - yy_32 -= width; - if ( !yy_32 ) - goto LABEL_129; + if (n_draw_shift) { + do { + *(_DWORD *)dst = *(_DWORD *)src; + src += 4; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + dst -= 800; + xx_32 -= 2; + if (xx_32 < 0) { + yy_32 = 2; + do { + if (dst < gpBufEnd) + break; + dst += yy_32; + n_draw_shift = (unsigned int)(32 - yy_32) >> 2; + if ((32 - yy_32) & 2) { + *(_WORD *)dst = *((_WORD *)src + 1); + src += 4; + dst += 2; } - yy_32 -= width; - if ( dst < gpBufEnd ) - return; - left_shift = gdwCurrentMask; - and80_i = width; - do - { - if ( left_shift & 0x80000000 ) + if (n_draw_shift) { + do { + *(_DWORD *)dst = *(_DWORD *)src; + src += 4; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + dst -= 800; + yy_32 += 2; + } while (yy_32 != 32); + return; + } + } + break; + case 11: // upper (bottom transparent), without lighting + xx_32 = 30; + while (dst >= gpBufEnd) { + for (n_draw_shift = (unsigned int)(32 - xx_32) >> 2; n_draw_shift; --n_draw_shift) { + *(_DWORD *)dst = *(_DWORD *)src; + src += 4; + dst += 4; + } + if ((32 - (_BYTE)xx_32) & 2) { + *(_WORD *)dst = *(_WORD *)src; + src += 4; + dst += 2; + } + dst = &dst[xx_32 - 800]; + xx_32 -= 2; + if (xx_32 < 0) { + yy_32 = 2; + do { + if (dst < gpBufEnd) + break; + for (n_draw_shift = (unsigned int)(32 - yy_32) >> 2; n_draw_shift; --n_draw_shift) { + *(_DWORD *)dst = *(_DWORD *)src; + src += 4; + dst += 4; + } + if ((32 - (_BYTE)yy_32) & 2) { + *(_WORD *)dst = *(_WORD *)src; + src += 4; + dst += 2; + } + dst = &dst[yy_32 - 800]; + yy_32 += 2; + } while (yy_32 != 32); + return; + } + } + break; + case 12: // upper (bottom transparent), without lighting + xx_32 = 30; + while (dst >= gpBufEnd) { + dst += xx_32; + n_draw_shift = (unsigned int)(32 - xx_32) >> 2; + if ((32 - xx_32) & 2) { + *(_WORD *)dst = *((_WORD *)src + 1); + src += 4; + dst += 2; + } + if (n_draw_shift) { + do { + *(_DWORD *)dst = *(_DWORD *)src; + src += 4; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + dst -= 800; + xx_32 -= 2; + if (xx_32 < 0) { + gpDrawMask -= 16; + yy_32 = 16; + do { + if (dst < gpBufEnd) + break; + left_shift = *gpDrawMask; + i = 32; + do { + if (left_shift & 0x80000000) dst[0] = src[0]; left_shift *= 2; ++src; ++dst; - --and80_i; - } - while ( and80_i ); - gdwCurrentMask = left_shift; - } - while ( yy_32 ); -LABEL_129: + --i; + } while (i); + dst -= 800; + --gpDrawMask; + --yy_32; + } while (yy_32); + return; + } + } + break; + default: // upper (bottom transparent), without lighting + xx_32 = 30; + while (dst >= gpBufEnd) { + for (n_draw_shift = (unsigned int)(32 - xx_32) >> 2; n_draw_shift; --n_draw_shift) { + *(_DWORD *)dst = *(_DWORD *)src; + src += 4; + dst += 4; + } + if ((32 - (_BYTE)xx_32) & 2) { + *(_WORD *)dst = *(_WORD *)src; + src += 4; + dst += 2; + } + dst = &dst[xx_32 - 800]; + xx_32 -= 2; + if (xx_32 < 0) { + gpDrawMask -= 16; + yy_32 = 16; + do { + if (dst < gpBufEnd) + break; + left_shift = *gpDrawMask; + i = 32; + do { + if (left_shift & 0x80000000) + dst[0] = src[0]; + left_shift *= 2; + ++src; + ++dst; + --i; + } while (i); + src += (unsigned char)src & 2; + dst -= 800; + --gpDrawMask; + --yy_32; + } while (yy_32); + return; + } + } + break; + } + return; + } + if ((_BYTE)light_table_index != lightmax) { + if (!(level_cel_block & 0x8000)) { + src = (unsigned char *)pDungeonCels + *((_DWORD *)pDungeonCels + (level_cel_block & 0xFFF)); + tbl = (unsigned char *)&pLightTbl[256 * light_table_index]; + cel_type_16 = (unsigned char)(level_cel_block >> 12); + switch (cel_type_16) { + case 0: // upper (bottom transparent), with lighting + xx_32 = 32; + do { + if (dst < gpBufEnd) + break; + asm_trans_light_mask(32, tbl, dst, src, *gpDrawMask); dst -= 800; --gpDrawMask; --xx_32; - } - while ( xx_32 ); + } while (xx_32); break; - case 10: // upper (bottom transparent), without lighting - xx_32 = 30; - while ( dst >= gpBufEnd ) - { - dst += xx_32; - n_draw_shift = (unsigned int)(32 - xx_32) >> 2; - if ( (32 - xx_32) & 2 ) - { - *(_WORD *)dst = *((_WORD *)src + 1); - src += 4; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - *(_DWORD *)dst = *(_DWORD *)src; - src += 4; - dst += 4; - --n_draw_shift; + case 1: // upper (bottom transparent), with lighting + xx_32 = 32; + do { + gdwCurrentMask = *gpDrawMask; + yy_32 = 32; + do { + while (1) { + width = (unsigned char)*src++; + if ((width & 0x80u) == 0) + break; + _LOBYTE(width) = -(char)width; + dst += width; + if (width & 0x1F) + gdwCurrentMask <<= width & 0x1F; + yy_32 -= width; + if (!yy_32) + goto LABEL_50; } - while ( n_draw_shift ); - } + yy_32 -= width; + if (dst < gpBufEnd) + return; + gdwCurrentMask = asm_trans_light_mask(width, tbl, dst, src, gdwCurrentMask); + } while (yy_32); + LABEL_50: + dst -= 800; + --gpDrawMask; + --xx_32; + } while (xx_32); + break; + case 2: // upper (bottom transparent), with lighting + xx_32 = 30; + while (dst >= gpBufEnd) { + dst += xx_32; + src += (32 - (_BYTE)xx_32) & 2; + asm_cel_light_edge(32 - xx_32, tbl, dst, src); dst -= 800; xx_32 -= 2; - if ( xx_32 < 0 ) - { + if (xx_32 < 0) { yy_32 = 2; - do - { - if ( dst < gpBufEnd ) + do { + if (dst < gpBufEnd) break; dst += yy_32; - n_draw_shift = (unsigned int)(32 - yy_32) >> 2; - if ( (32 - yy_32) & 2 ) - { - *(_WORD *)dst = *((_WORD *)src + 1); - src += 4; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - *(_DWORD *)dst = *(_DWORD *)src; - src += 4; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } + src += (32 - (_BYTE)yy_32) & 2; + asm_cel_light_edge(32 - yy_32, tbl, dst, src); dst -= 800; yy_32 += 2; - } - while ( yy_32 != 32 ); + } while (yy_32 != 32); return; } } break; - case 11: // upper (bottom transparent), without lighting + case 3: // upper (bottom transparent), with lighting xx_32 = 30; - while ( dst >= gpBufEnd ) - { - for ( n_draw_shift = (unsigned int)(32 - xx_32) >> 2; n_draw_shift; --n_draw_shift ) - { - *(_DWORD *)dst = *(_DWORD *)src; - src += 4; - dst += 4; - } - if ( (32 - (_BYTE)xx_32) & 2 ) - { - *(_WORD *)dst = *(_WORD *)src; - src += 4; - dst += 2; - } + while (dst >= gpBufEnd) { + asm_cel_light_edge(32 - xx_32, tbl, dst, src); + src += (unsigned char)src & 2; dst = &dst[xx_32 - 800]; xx_32 -= 2; - if ( xx_32 < 0 ) - { + if (xx_32 < 0) { yy_32 = 2; - do - { - if ( dst < gpBufEnd ) + do { + if (dst < gpBufEnd) break; - for ( n_draw_shift = (unsigned int)(32 - yy_32) >> 2; n_draw_shift; --n_draw_shift ) - { - *(_DWORD *)dst = *(_DWORD *)src; - src += 4; - dst += 4; - } - if ( (32 - (_BYTE)yy_32) & 2 ) - { - *(_WORD *)dst = *(_WORD *)src; - src += 4; - dst += 2; - } + asm_cel_light_edge(32 - yy_32, tbl, dst, src); + src += (unsigned char)src & 2; dst = &dst[yy_32 - 800]; yy_32 += 2; - } - while ( yy_32 != 32 ); + } while (yy_32 != 32); return; } } break; - case 12: // upper (bottom transparent), without lighting + case 4: // upper (bottom transparent), with lighting xx_32 = 30; - while ( dst >= gpBufEnd ) - { + while (dst >= gpBufEnd) { dst += xx_32; - n_draw_shift = (unsigned int)(32 - xx_32) >> 2; - if ( (32 - xx_32) & 2 ) - { - *(_WORD *)dst = *((_WORD *)src + 1); - src += 4; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - *(_DWORD *)dst = *(_DWORD *)src; - src += 4; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } + src += (32 - (_BYTE)xx_32) & 2; + asm_cel_light_edge(32 - xx_32, tbl, dst, src); dst -= 800; xx_32 -= 2; - if ( xx_32 < 0 ) - { + if (xx_32 < 0) { gpDrawMask -= 16; yy_32 = 16; - do - { - if ( dst < gpBufEnd ) + do { + if (dst < gpBufEnd) break; - left_shift = *gpDrawMask; - i = 32; - do - { - if ( left_shift & 0x80000000 ) - dst[0] = src[0]; - left_shift *= 2; - ++src; - ++dst; - --i; - } - while ( i ); + src += (unsigned char)src & 2; + asm_trans_light_mask(32, tbl, dst, src, *gpDrawMask); dst -= 800; --gpDrawMask; --yy_32; - } - while ( yy_32 ); + } while (yy_32); return; } } break; - default: // upper (bottom transparent), without lighting + default: // upper (bottom transparent), with lighting xx_32 = 30; - while ( dst >= gpBufEnd ) - { - for ( n_draw_shift = (unsigned int)(32 - xx_32) >> 2; n_draw_shift; --n_draw_shift ) - { - *(_DWORD *)dst = *(_DWORD *)src; - src += 4; - dst += 4; - } - if ( (32 - (_BYTE)xx_32) & 2 ) - { - *(_WORD *)dst = *(_WORD *)src; - src += 4; - dst += 2; - } + while (dst >= gpBufEnd) { + asm_cel_light_edge(32 - xx_32, tbl, dst, src); + src += (unsigned char)src & 2; dst = &dst[xx_32 - 800]; xx_32 -= 2; - if ( xx_32 < 0 ) - { + if (xx_32 < 0) { gpDrawMask -= 16; yy_32 = 16; - do - { - if ( dst < gpBufEnd ) + do { + if (dst < gpBufEnd) break; - left_shift = *gpDrawMask; - i = 32; - do - { - if ( left_shift & 0x80000000 ) - dst[0] = src[0]; - left_shift *= 2; - ++src; - ++dst; - --i; - } - while ( i ); + asm_trans_light_mask(32, tbl, dst, src, *gpDrawMask); src += (unsigned char)src & 2; dst -= 800; --gpDrawMask; --yy_32; - } - while ( yy_32 ); + } while (yy_32); return; } } break; - } - return; - } - if ( (_BYTE)light_table_index != lightmax ) - { - if ( !(level_cel_block & 0x8000) ) - { - src = (unsigned char *)pDungeonCels + *((_DWORD *)pDungeonCels + (level_cel_block & 0xFFF)); - tbl = (unsigned char *)&pLightTbl[256 * light_table_index]; - cel_type_16 = (unsigned char)(level_cel_block >> 12); - switch ( cel_type_16 ) - { - case 0: // upper (bottom transparent), with lighting - xx_32 = 32; - do - { - if ( dst < gpBufEnd ) - break; - asm_trans_light_mask(32, tbl, dst, src, *gpDrawMask); - dst -= 800; - --gpDrawMask; - --xx_32; - } - while ( xx_32 ); - break; - case 1: // upper (bottom transparent), with lighting - xx_32 = 32; - do - { - gdwCurrentMask = *gpDrawMask; - yy_32 = 32; - do - { - while ( 1 ) - { - width = (unsigned char)*src++; - if ( (width & 0x80u) == 0 ) - break; - _LOBYTE(width) = -(char)width; - dst += width; - if ( width & 0x1F ) - gdwCurrentMask <<= width & 0x1F; - yy_32 -= width; - if ( !yy_32 ) - goto LABEL_50; - } - yy_32 -= width; - if ( dst < gpBufEnd ) - return; - gdwCurrentMask = asm_trans_light_mask(width, tbl, dst, src, gdwCurrentMask); - } - while ( yy_32 ); -LABEL_50: - dst -= 800; - --gpDrawMask; - --xx_32; - } - while ( xx_32 ); - break; - case 2: // upper (bottom transparent), with lighting - xx_32 = 30; - while ( dst >= gpBufEnd ) - { - dst += xx_32; - src += (32 - (_BYTE)xx_32) & 2; - asm_cel_light_edge(32 - xx_32, tbl, dst, src); - dst -= 800; - xx_32 -= 2; - if ( xx_32 < 0 ) - { - yy_32 = 2; - do - { - if ( dst < gpBufEnd ) - break; - dst += yy_32; - src += (32 - (_BYTE)yy_32) & 2; - asm_cel_light_edge(32 - yy_32, tbl, dst, src); - dst -= 800; - yy_32 += 2; - } - while ( yy_32 != 32 ); - return; - } - } - break; - case 3: // upper (bottom transparent), with lighting - xx_32 = 30; - while ( dst >= gpBufEnd ) - { - asm_cel_light_edge(32 - xx_32, tbl, dst, src); - src += (unsigned char)src & 2; - dst = &dst[xx_32 - 800]; - xx_32 -= 2; - if ( xx_32 < 0 ) - { - yy_32 = 2; - do - { - if ( dst < gpBufEnd ) - break; - asm_cel_light_edge(32 - yy_32, tbl, dst, src); - src += (unsigned char)src & 2; - dst = &dst[yy_32 - 800]; - yy_32 += 2; - } - while ( yy_32 != 32 ); - return; - } - } - break; - case 4: // upper (bottom transparent), with lighting - xx_32 = 30; - while ( dst >= gpBufEnd ) - { - dst += xx_32; - src += (32 - (_BYTE)xx_32) & 2; - asm_cel_light_edge(32 - xx_32, tbl, dst, src); - dst -= 800; - xx_32 -= 2; - if ( xx_32 < 0 ) - { - gpDrawMask -= 16; - yy_32 = 16; - do - { - if ( dst < gpBufEnd ) - break; - src += (unsigned char)src & 2; - asm_trans_light_mask(32, tbl, dst, src, *gpDrawMask); - dst -= 800; - --gpDrawMask; - --yy_32; - } - while ( yy_32 ); - return; - } - } - break; - default: // upper (bottom transparent), with lighting - xx_32 = 30; - while ( dst >= gpBufEnd ) - { - asm_cel_light_edge(32 - xx_32, tbl, dst, src); - src += (unsigned char)src & 2; - dst = &dst[xx_32 - 800]; - xx_32 -= 2; - if ( xx_32 < 0 ) - { - gpDrawMask -= 16; - yy_32 = 16; - do - { - if ( dst < gpBufEnd ) - break; - asm_trans_light_mask(32, tbl, dst, src, *gpDrawMask); - src += (unsigned char)src & 2; - dst -= 800; - --gpDrawMask; - --yy_32; - } - while ( yy_32 ); - return; - } - } - break; } return; } src = (unsigned char *)pSpeedCels - + *(_DWORD *)&gpCelFrame[4 * (light_table_index + 16 * (level_cel_block & 0xFFF))]; + + *(_DWORD *)&gpCelFrame[4 * (light_table_index + 16 * (level_cel_block & 0xFFF))]; cel_type_16 = (unsigned char)(level_cel_block >> 12); goto LABEL_12; } - if ( level_cel_block & 0x8000 ) + if (level_cel_block & 0x8000) level_cel_block = *(_DWORD *)&gpCelFrame[64 * (level_cel_block & 0xFFF)] - + (unsigned short)(level_cel_block & 0xF000); + + (unsigned short)(level_cel_block & 0xF000); src = (unsigned char *)pDungeonCels + *((_DWORD *)pDungeonCels + (level_cel_block & 0xFFF)); cel_type_16 = (level_cel_block >> 12) & 7; - switch ( cel_type_16 ) - { - case 0: // upper (bottom transparent), black - xx_32 = 32; - do - { - if ( dst < gpBufEnd ) - break; - left_shift = *gpDrawMask; - i = 32; - do - { - if ( left_shift & 0x80000000 ) + switch (cel_type_16) { + case 0: // upper (bottom transparent), black + xx_32 = 32; + do { + if (dst < gpBufEnd) + break; + left_shift = *gpDrawMask; + i = 32; + do { + if (left_shift & 0x80000000) + dst[0] = 0; + left_shift *= 2; + ++dst; + --i; + } while (i); + dst -= 800; + --gpDrawMask; + --xx_32; + } while (xx_32); + break; + case 1: // upper (bottom transparent), black + xx_32 = 32; + do { + gdwCurrentMask = *gpDrawMask; + yy_32 = 32; + do { + while (1) { + width = (unsigned char)*src++; + if ((width & 0x80u) == 0) + break; + _LOBYTE(width) = -(char)width; + dst += width; + if (width & 0x1F) + gdwCurrentMask <<= width & 0x1F; + yy_32 -= width; + if (!yy_32) + goto LABEL_208; + } + yy_32 -= width; + if (dst < gpBufEnd) + return; + left_shift = gdwCurrentMask; + and80_i = width; + src += width; + do { + if (left_shift & 0x80000000) dst[0] = 0; left_shift *= 2; ++dst; - --i; - } - while ( i ); - dst -= 800; - --gpDrawMask; - --xx_32; + --and80_i; + } while (and80_i); + gdwCurrentMask = left_shift; + } while (yy_32); + LABEL_208: + dst -= 800; + --gpDrawMask; + --xx_32; + } while (xx_32); + break; + case 2: // upper (bottom transparent), black + xx_32 = 30; + while (dst >= gpBufEnd) { + dst += xx_32; + n_draw_shift = (unsigned int)(32 - xx_32) >> 2; + if ((32 - xx_32) & 2) { + *(_WORD *)dst = 0; + dst += 2; } - while ( xx_32 ); - break; - case 1: // upper (bottom transparent), black - xx_32 = 32; - do - { - gdwCurrentMask = *gpDrawMask; - yy_32 = 32; - do - { - while ( 1 ) - { - width = (unsigned char)*src++; - if ( (width & 0x80u) == 0 ) - break; - _LOBYTE(width) = -(char)width; - dst += width; - if ( width & 0x1F ) - gdwCurrentMask <<= width & 0x1F; - yy_32 -= width; - if ( !yy_32 ) - goto LABEL_208; + if (n_draw_shift) { + do { + *(_DWORD *)dst = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + dst -= 800; + if (!xx_32) { + yy_32 = 2; + do { + if (dst < gpBufEnd) + break; + dst += yy_32; + n_draw_shift = (unsigned int)(32 - yy_32) >> 2; + if ((32 - yy_32) & 2) { + *(_WORD *)dst = 0; + dst += 2; } - yy_32 -= width; - if ( dst < gpBufEnd ) - return; - left_shift = gdwCurrentMask; - and80_i = width; - src += width; - do - { - if ( left_shift & 0x80000000 ) + if (n_draw_shift) { + do { + *(_DWORD *)dst = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + dst -= 800; + yy_32 += 2; + } while (yy_32 != 32); + return; + } + xx_32 -= 2; + } + break; + case 3: // upper (bottom transparent), black + xx_32 = 30; + while (dst >= gpBufEnd) { + n_draw_shift = (unsigned int)(32 - xx_32) >> 2; + if ((32 - xx_32) & 2) { + *(_WORD *)dst = 0; + dst += 2; + } + if (n_draw_shift) { + do { + *(_DWORD *)dst = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + dst -= 800; + if (!xx_32) { + yy_32 = 2; + do { + if (dst < gpBufEnd) + break; + n_draw_shift = (unsigned int)(32 - yy_32) >> 2; + if ((32 - yy_32) & 2) { + *(_WORD *)dst = 0; + dst += 2; + } + if (n_draw_shift) { + do { + *(_DWORD *)dst = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + dst = &dst[yy_32 - 800]; + yy_32 += 2; + } while (yy_32 != 32); + return; + } + dst += xx_32; + xx_32 -= 2; + } + break; + case 4: // upper (bottom transparent), black + xx_32 = 30; + while (dst >= gpBufEnd) { + dst += xx_32; + n_draw_shift = (unsigned int)(32 - xx_32) >> 2; + if ((32 - xx_32) & 2) { + *(_WORD *)dst = 0; + dst += 2; + } + if (n_draw_shift) { + do { + *(_DWORD *)dst = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + dst -= 800; + if (!xx_32) { + gpDrawMask -= 16; + yy_32 = 16; + do { + if (dst < gpBufEnd) + break; + left_shift = *gpDrawMask; + i = 32; + do { + if (left_shift & 0x80000000) dst[0] = 0; left_shift *= 2; ++dst; - --and80_i; - } - while ( and80_i ); - gdwCurrentMask = left_shift; - } - while ( yy_32 ); -LABEL_208: - dst -= 800; - --gpDrawMask; - --xx_32; + --i; + } while (i); + dst -= 800; + --gpDrawMask; + --yy_32; + } while (yy_32); + return; } - while ( xx_32 ); - break; - case 2: // upper (bottom transparent), black - xx_32 = 30; - while ( dst >= gpBufEnd ) - { - dst += xx_32; - n_draw_shift = (unsigned int)(32 - xx_32) >> 2; - if ( (32 - xx_32) & 2 ) - { - *(_WORD *)dst = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - *(_DWORD *)dst = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - dst -= 800; - if ( !xx_32 ) - { - yy_32 = 2; - do - { - if ( dst < gpBufEnd ) - break; - dst += yy_32; - n_draw_shift = (unsigned int)(32 - yy_32) >> 2; - if ( (32 - yy_32) & 2 ) - { - *(_WORD *)dst = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - *(_DWORD *)dst = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - dst -= 800; - yy_32 += 2; - } - while ( yy_32 != 32 ); - return; - } - xx_32 -= 2; + xx_32 -= 2; + } + break; + default: // upper (bottom transparent), black + xx_32 = 30; + while (dst >= gpBufEnd) { + n_draw_shift = (unsigned int)(32 - xx_32) >> 2; + if ((32 - xx_32) & 2) { + *(_WORD *)dst = 0; + dst += 2; } - break; - case 3: // upper (bottom transparent), black - xx_32 = 30; - while ( dst >= gpBufEnd ) - { - n_draw_shift = (unsigned int)(32 - xx_32) >> 2; - if ( (32 - xx_32) & 2 ) - { - *(_WORD *)dst = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - *(_DWORD *)dst = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - dst -= 800; - if ( !xx_32 ) - { - yy_32 = 2; - do - { - if ( dst < gpBufEnd ) - break; - n_draw_shift = (unsigned int)(32 - yy_32) >> 2; - if ( (32 - yy_32) & 2 ) - { - *(_WORD *)dst = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - *(_DWORD *)dst = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - dst = &dst[yy_32 - 800]; - yy_32 += 2; - } - while ( yy_32 != 32 ); - return; - } - dst += xx_32; - xx_32 -= 2; + if (n_draw_shift) { + do { + *(_DWORD *)dst = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); } - break; - case 4: // upper (bottom transparent), black - xx_32 = 30; - while ( dst >= gpBufEnd ) - { - dst += xx_32; - n_draw_shift = (unsigned int)(32 - xx_32) >> 2; - if ( (32 - xx_32) & 2 ) - { - *(_WORD *)dst = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - *(_DWORD *)dst = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - dst -= 800; - if ( !xx_32 ) - { - gpDrawMask -= 16; - yy_32 = 16; - do - { - if ( dst < gpBufEnd ) - break; - left_shift = *gpDrawMask; - i = 32; - do - { - if ( left_shift & 0x80000000 ) - dst[0] = 0; - left_shift *= 2; - ++dst; - --i; - } - while ( i ); - dst -= 800; - --gpDrawMask; - --yy_32; - } - while ( yy_32 ); - return; - } - xx_32 -= 2; + dst -= 800; + if (!xx_32) { + gpDrawMask -= 16; + yy_32 = 16; + do { + if (dst < gpBufEnd) + break; + left_shift = *gpDrawMask; + i = 32; + do { + if (left_shift & 0x80000000) + dst[0] = 0; + left_shift *= 2; + ++dst; + --i; + } while (i); + dst -= 800; + --gpDrawMask; + --yy_32; + } while (yy_32); + return; } - break; - default: // upper (bottom transparent), black - xx_32 = 30; - while ( dst >= gpBufEnd ) - { - n_draw_shift = (unsigned int)(32 - xx_32) >> 2; - if ( (32 - xx_32) & 2 ) - { - *(_WORD *)dst = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - *(_DWORD *)dst = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - dst -= 800; - if ( !xx_32 ) - { - gpDrawMask -= 16; - yy_32 = 16; - do - { - if ( dst < gpBufEnd ) - break; - left_shift = *gpDrawMask; - i = 32; - do - { - if ( left_shift & 0x80000000 ) - dst[0] = 0; - left_shift *= 2; - ++dst; - --i; - } - while ( i ); - dst -= 800; - --gpDrawMask; - --yy_32; - } - while ( yy_32 ); - return; - } - dst += xx_32; - xx_32 -= 2; - } - break; + dst += xx_32; + xx_32 -= 2; + } + break; } } void __fastcall drawUpperScreen(unsigned char *pbDst) { - unsigned char *dst; // edi MAPDST - unsigned char *tbl; // ebx - unsigned char *src; // esi MAPDST - short cel_type_16; // ax MAPDST - signed int xx_32; // ebp MAPDST - signed int yy_32; // edx MAPDST - unsigned int width; // eax MAPDST - unsigned int chk_sh_and; // ecx MAPDST + unsigned char *dst; // edi MAPDST + unsigned char *tbl; // ebx + unsigned char *src; // esi MAPDST + short cel_type_16; // ax MAPDST + signed int xx_32; // ebp MAPDST + signed int yy_32; // edx MAPDST + unsigned int width; // eax MAPDST + unsigned int chk_sh_and; // ecx MAPDST unsigned int n_draw_shift; // ecx MAPDST - signed int i; // edx MAPDST - signed int j; // ecx MAPDST + signed int i; // edx MAPDST + signed int j; // ecx MAPDST - if ( cel_transparency_active ) - { - if ( !arch_draw_type ) - { + if (cel_transparency_active) { + if (!arch_draw_type) { drawTopArchesUpperScreen(pbDst); return; } - if ( arch_draw_type == 1 ) - { - if ( block_lvid[level_piece_id] == 1 || block_lvid[level_piece_id] == 3 ) - { + if (arch_draw_type == 1) { + if (block_lvid[level_piece_id] == 1 || block_lvid[level_piece_id] == 3) { drawBottomArchesUpperScreen(pbDst, &LeftMask[31]); return; } } - if ( arch_draw_type == 2 ) - { - if ( block_lvid[level_piece_id] == 2 || block_lvid[level_piece_id] == 3 ) - { + if (arch_draw_type == 2) { + if (block_lvid[level_piece_id] == 2 || block_lvid[level_piece_id] == 3) { drawBottomArchesUpperScreen(pbDst, &RightMask[31]); return; } @@ -2167,1862 +1771,1136 @@ void __fastcall drawUpperScreen(unsigned char *pbDst) } gpCelFrame = (unsigned char *)speed_cel_frame_num_from_light_index_frame_num; dst = pbDst; - if ( !(_BYTE)light_table_index ) - { - if ( level_cel_block & 0x8000 ) + if (!(_BYTE)light_table_index) { + if (level_cel_block & 0x8000) level_cel_block = *(_DWORD *)&gpCelFrame[64 * (level_cel_block & 0xFFF)] - + (unsigned short)(level_cel_block & 0xF000); + + (unsigned short)(level_cel_block & 0xF000); src = (unsigned char *)pDungeonCels + *((_DWORD *)pDungeonCels + (level_cel_block & 0xFFF)); cel_type_16 = ((level_cel_block >> 12) & 7) + 8; -LABEL_22: - switch ( cel_type_16 ) - { - case 8: // upper (solid), without lighting - i = 32; - do - { - if ( dst < gpBufEnd ) - break; - j = 8; - do - { - *(_DWORD *)dst = *(_DWORD *)src; - src += 4; - dst += 4; - --j; - } - while ( j ); - dst -= 800; - --i; - } - while ( i ); - break; - case 9: // upper (solid), without lighting - xx_32 = 32; - do - { - yy_32 = 32; - do - { - while ( 1 ) - { - width = *src++; - if ( (width & 0x80u) == 0 ) - break; - _LOBYTE(width) = -(char)width; - dst += width; - yy_32 -= width; - if ( !yy_32 ) - goto LABEL_133; - } - yy_32 -= width; - if ( dst < gpBufEnd ) - return; - chk_sh_and = width >> 1; - if ( width & 1 ) - { - *dst++ = *src++; - if ( !chk_sh_and ) - continue; - } - n_draw_shift = chk_sh_and >> 1; - if ( chk_sh_and & 1 ) - { - *(_WORD *)dst = *(_WORD *)src; - src += 2; - dst += 2; - if ( !n_draw_shift ) - continue; - } - do - { - *(_DWORD *)dst = *(_DWORD *)src; - src += 4; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - while ( yy_32 ); -LABEL_133: - dst -= 800; - --xx_32; - } - while ( xx_32 ); - break; - case 10: // upper (solid), without lighting - xx_32 = 30; - while ( dst >= gpBufEnd ) - { - dst += xx_32; - n_draw_shift = (unsigned int)(32 - xx_32) >> 2; - if ( (32 - xx_32) & 2 ) - { - *(_WORD *)dst = *((_WORD *)src + 1); - src += 4; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - *(_DWORD *)dst = *(_DWORD *)src; - src += 4; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - dst -= 800; - xx_32 -= 2; - if ( xx_32 < 0 ) - { - yy_32 = 2; - do - { - if ( dst < gpBufEnd ) - break; - dst += yy_32; - n_draw_shift = (unsigned int)(32 - yy_32) >> 2; - if ( (32 - yy_32) & 2 ) - { - *(_WORD *)dst = *((_WORD *)src + 1); - src += 4; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - *(_DWORD *)dst = *(_DWORD *)src; - src += 4; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - dst -= 800; - yy_32 += 2; - } - while ( yy_32 != 32 ); - return; - } - } - break; - case 11: // upper (solid), without lighting - xx_32 = 30; - while ( dst >= gpBufEnd ) - { - for ( n_draw_shift = (unsigned int)(32 - xx_32) >> 2; n_draw_shift; --n_draw_shift ) - { - *(_DWORD *)dst = *(_DWORD *)src; - src += 4; - dst += 4; - } - if ( (32 - (_BYTE)xx_32) & 2 ) - { - *(_WORD *)dst = *(_WORD *)src; - src += 4; - dst += 2; - } - dst = &dst[xx_32 - 800]; - xx_32 -= 2; - if ( xx_32 < 0 ) - { - yy_32 = 2; - do - { - if ( dst < gpBufEnd ) - break; - for ( n_draw_shift = (unsigned int)(32 - yy_32) >> 2; n_draw_shift; --n_draw_shift ) - { - *(_DWORD *)dst = *(_DWORD *)src; - src += 4; - dst += 4; - } - if ( (32 - (_BYTE)yy_32) & 2 ) - { - *(_WORD *)dst = *(_WORD *)src; - src += 4; - dst += 2; - } - dst = &dst[yy_32 - 800]; - yy_32 += 2; - } - while ( yy_32 != 32 ); - return; - } - } - break; - case 12: // upper (solid), without lighting - xx_32 = 30; - while ( dst >= gpBufEnd ) - { - dst += xx_32; - n_draw_shift = (unsigned int)(32 - xx_32) >> 2; - if ( (32 - xx_32) & 2 ) - { - *(_WORD *)dst = *((_WORD *)src + 1); - src += 4; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - *(_DWORD *)dst = *(_DWORD *)src; - src += 4; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - dst -= 800; - xx_32 -= 2; - if ( xx_32 < 0 ) - { - i = 16; - do - { - if ( dst < gpBufEnd ) - break; - j = 8; - do - { - *(_DWORD *)dst = *(_DWORD *)src; - src += 4; - dst += 4; - --j; - } - while ( j ); - dst -= 800; - --i; - } - while ( i ); - return; - } - } - break; - default: // upper (solid), without lighting - xx_32 = 30; - while ( dst >= gpBufEnd ) - { - for ( n_draw_shift = (unsigned int)(32 - xx_32) >> 2; n_draw_shift; --n_draw_shift ) - { - *(_DWORD *)dst = *(_DWORD *)src; - src += 4; - dst += 4; - } - if ( (32 - (_BYTE)xx_32) & 2 ) - { - *(_WORD *)dst = *(_WORD *)src; - src += 4; - dst += 2; - } - dst = &dst[xx_32 - 800]; - xx_32 -= 2; - if ( xx_32 < 0 ) - { - i = 16; - do - { - if ( dst < gpBufEnd ) - break; - j = 8; - do - { - *(_DWORD *)dst = *(_DWORD *)src; - src += 4; - dst += 4; - --j; - } - while ( j ); - dst -= 800; - --i; - } - while ( i ); - return; - } - } - break; - } - return; - } - if ( (_BYTE)light_table_index != lightmax ) - { - if ( !(level_cel_block & 0x8000) ) - { - src = (unsigned char *)pDungeonCels + *((_DWORD *)pDungeonCels + (level_cel_block & 0xFFF)); - tbl = (unsigned char *)&pLightTbl[256 * light_table_index]; - cel_type_16 = (unsigned short)level_cel_block >> 12; - switch ( cel_type_16 ) - { - case 0: // upper (solid), with lighting - xx_32 = 32; - do - { - if ( dst < gpBufEnd ) - break; - asm_cel_light_square(8, tbl, dst, src); - dst -= 800; - --xx_32; - } - while ( xx_32 ); - break; - case 1: // upper (solid), with lighting - xx_32 = 32; - do - { - yy_32 = 32; - do - { - while ( 1 ) - { - width = *src++; - if ( (width & 0x80u) == 0 ) - break; - _LOBYTE(width) = -(char)width; - dst += width; - yy_32 -= width; - if ( !yy_32 ) - goto LABEL_58; - } - yy_32 -= width; - if ( dst < gpBufEnd ) - return; - asm_cel_light_edge(width, tbl, dst, src); - } - while ( yy_32 ); -LABEL_58: - dst -= 800; - --xx_32; - } - while ( xx_32 ); - break; - case 2: // upper (solid), with lighting - xx_32 = 30; - while ( dst >= gpBufEnd ) - { - dst += xx_32; - src += (32 - (_BYTE)xx_32) & 2; - asm_cel_light_edge(32 - xx_32, tbl, dst, src); - dst -= 800; - xx_32 -= 2; - if ( xx_32 < 0 ) - { - yy_32 = 2; - do - { - if ( dst < gpBufEnd ) - break; - dst += yy_32; - src += (32 - (_BYTE)yy_32) & 2; - asm_cel_light_edge(32 - yy_32, tbl, dst, src); - dst -= 800; - yy_32 += 2; - } - while ( yy_32 != 32 ); - return; - } - } - break; - case 3: // upper (solid), with lighting - xx_32 = 30; - while ( dst >= gpBufEnd ) - { - asm_cel_light_edge(32 - xx_32, tbl, dst, src); - src += (unsigned char)src & 2; - dst = &dst[xx_32 - 800]; - xx_32 -= 2; - if ( xx_32 < 0 ) - { - yy_32 = 2; - do - { - if ( dst < gpBufEnd ) - break; - asm_cel_light_edge(32 - yy_32, tbl, dst, src); - src += (unsigned char)src & 2; - dst = &dst[yy_32 - 800]; - yy_32 += 2; - } - while ( yy_32 != 32 ); - return; - } - } - break; - case 4: // upper (solid), with lighting - xx_32 = 30; - while ( dst >= gpBufEnd ) - { - dst += xx_32; - src += (32 - (_BYTE)xx_32) & 2; - asm_cel_light_edge(32 - xx_32, tbl, dst, src); - dst -= 800; - xx_32 -= 2; - if ( xx_32 < 0 ) - { - yy_32 = 16; - do - { - if ( dst < gpBufEnd ) - break; - asm_cel_light_square(8, tbl, dst, src); - dst -= 800; - --yy_32; - } - while ( yy_32 ); - return; - } - } - break; - default: // upper (solid), with lighting - xx_32 = 30; - while ( dst >= gpBufEnd ) - { - asm_cel_light_edge(32 - xx_32, tbl, dst, src); - src += (unsigned char)src & 2; - dst = &dst[xx_32 - 800]; - xx_32 -= 2; - if ( xx_32 < 0 ) - { - yy_32 = 16; - do - { - if ( dst < gpBufEnd ) - break; - asm_cel_light_square(8, tbl, dst, src); - dst -= 800; - --yy_32; - } - while ( yy_32 ); - return; - } - } - break; - } - return; - } - src = (unsigned char *)pSpeedCels - + *(_DWORD *)&gpCelFrame[4 * (light_table_index + 16 * (level_cel_block & 0xFFF))]; - cel_type_16 = (unsigned short)level_cel_block >> 12; - goto LABEL_22; - } - if ( level_cel_block & 0x8000 ) - level_cel_block = *(_DWORD *)&gpCelFrame[64 * (level_cel_block & 0xFFF)] - + (unsigned short)(level_cel_block & 0xF000); - src = (unsigned char *)pDungeonCels + *((_DWORD *)pDungeonCels + (level_cel_block & 0xFFF)); - cel_type_16 = ((unsigned int)level_cel_block >> 12) & 7; - switch ( cel_type_16 ) - { - case 0: // upper (solid), black + LABEL_22: + switch (cel_type_16) { + case 8: // upper (solid), without lighting i = 32; - do - { - if ( dst < gpBufEnd ) + do { + if (dst < gpBufEnd) break; j = 8; - do - { - *(_DWORD *)dst = 0; + do { + *(_DWORD *)dst = *(_DWORD *)src; + src += 4; dst += 4; --j; - } - while ( j ); + } while (j); dst -= 800; --i; - } - while ( i ); + } while (i); break; - case 1: // upper (solid), black + case 9: // upper (solid), without lighting xx_32 = 32; - do - { + do { yy_32 = 32; - do - { - while ( 1 ) - { + do { + while (1) { width = *src++; - if ( (width & 0x80u) == 0 ) + if ((width & 0x80u) == 0) break; _LOBYTE(width) = -(char)width; dst += width; yy_32 -= width; - if ( !yy_32 ) - goto LABEL_205; + if (!yy_32) + goto LABEL_133; } yy_32 -= width; - if ( dst < gpBufEnd ) + if (dst < gpBufEnd) return; - src += width; chk_sh_and = width >> 1; - if ( width & 1 ) - { - *dst++ = 0; - if ( !chk_sh_and ) + if (width & 1) { + *dst++ = *src++; + if (!chk_sh_and) continue; } - n_draw_shift = width >> 2; - if ( chk_sh_and & 1 ) - { - *(_WORD *)dst = 0; + n_draw_shift = chk_sh_and >> 1; + if (chk_sh_and & 1) { + *(_WORD *)dst = *(_WORD *)src; + src += 2; dst += 2; - if ( !n_draw_shift ) + if (!n_draw_shift) continue; } - do - { - *(_DWORD *)dst = 0; + do { + *(_DWORD *)dst = *(_DWORD *)src; + src += 4; dst += 4; --n_draw_shift; - } - while ( n_draw_shift ); - } - while ( yy_32 ); -LABEL_205: + } while (n_draw_shift); + } while (yy_32); + LABEL_133: dst -= 800; --xx_32; - } - while ( xx_32 ); + } while (xx_32); break; - case 2: // upper (solid), black + case 10: // upper (solid), without lighting xx_32 = 30; - while ( dst >= gpBufEnd ) - { + while (dst >= gpBufEnd) { dst += xx_32; n_draw_shift = (unsigned int)(32 - xx_32) >> 2; - if ( (32 - xx_32) & 2 ) - { - *(_WORD *)dst = 0; + if ((32 - xx_32) & 2) { + *(_WORD *)dst = *((_WORD *)src + 1); + src += 4; dst += 2; } - if ( n_draw_shift ) - { - do - { - *(_DWORD *)dst = 0; + if (n_draw_shift) { + do { + *(_DWORD *)dst = *(_DWORD *)src; + src += 4; dst += 4; --n_draw_shift; - } - while ( n_draw_shift ); + } while (n_draw_shift); } dst -= 800; - if ( !xx_32 ) - { + xx_32 -= 2; + if (xx_32 < 0) { yy_32 = 2; - do - { - if ( dst < gpBufEnd ) + do { + if (dst < gpBufEnd) break; dst += yy_32; n_draw_shift = (unsigned int)(32 - yy_32) >> 2; - if ( (32 - yy_32) & 2 ) - { - *(_WORD *)dst = 0; + if ((32 - yy_32) & 2) { + *(_WORD *)dst = *((_WORD *)src + 1); + src += 4; dst += 2; } - if ( n_draw_shift ) - { - do - { - *(_DWORD *)dst = 0; + if (n_draw_shift) { + do { + *(_DWORD *)dst = *(_DWORD *)src; + src += 4; dst += 4; --n_draw_shift; - } - while ( n_draw_shift ); + } while (n_draw_shift); } dst -= 800; yy_32 += 2; - } - while ( yy_32 != 32 ); + } while (yy_32 != 32); return; } - xx_32 -= 2; } break; - case 3: // upper (solid), black + case 11: // upper (solid), without lighting xx_32 = 30; - while ( dst >= gpBufEnd ) - { - n_draw_shift = (unsigned int)(32 - xx_32) >> 2; - if ( (32 - xx_32) & 2 ) - { - *(_WORD *)dst = 0; + while (dst >= gpBufEnd) { + for (n_draw_shift = (unsigned int)(32 - xx_32) >> 2; n_draw_shift; --n_draw_shift) { + *(_DWORD *)dst = *(_DWORD *)src; + src += 4; + dst += 4; + } + if ((32 - (_BYTE)xx_32) & 2) { + *(_WORD *)dst = *(_WORD *)src; + src += 4; dst += 2; } - if ( n_draw_shift ) - { - do - { - *(_DWORD *)dst = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - dst -= 800; - if ( !xx_32 ) - { + dst = &dst[xx_32 - 800]; + xx_32 -= 2; + if (xx_32 < 0) { yy_32 = 2; - do - { - if ( dst < gpBufEnd ) + do { + if (dst < gpBufEnd) break; - n_draw_shift = (unsigned int)(32 - yy_32) >> 2; - if ( (32 - yy_32) & 2 ) - { - *(_WORD *)dst = 0; - dst += 2; + for (n_draw_shift = (unsigned int)(32 - yy_32) >> 2; n_draw_shift; --n_draw_shift) { + *(_DWORD *)dst = *(_DWORD *)src; + src += 4; + dst += 4; } - if ( n_draw_shift ) - { - do - { - *(_DWORD *)dst = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); + if ((32 - (_BYTE)yy_32) & 2) { + *(_WORD *)dst = *(_WORD *)src; + src += 4; + dst += 2; } dst = &dst[yy_32 - 800]; yy_32 += 2; - } - while ( yy_32 != 32 ); + } while (yy_32 != 32); return; } - dst += xx_32; - xx_32 -= 2; } break; - case 4: // upper (solid), black + case 12: // upper (solid), without lighting xx_32 = 30; - while ( dst >= gpBufEnd ) - { + while (dst >= gpBufEnd) { dst += xx_32; n_draw_shift = (unsigned int)(32 - xx_32) >> 2; - if ( (32 - xx_32) & 2 ) - { - *(_WORD *)dst = 0; + if ((32 - xx_32) & 2) { + *(_WORD *)dst = *((_WORD *)src + 1); + src += 4; dst += 2; } - if ( n_draw_shift ) - { - do - { - *(_DWORD *)dst = 0; + if (n_draw_shift) { + do { + *(_DWORD *)dst = *(_DWORD *)src; + src += 4; dst += 4; --n_draw_shift; - } - while ( n_draw_shift ); + } while (n_draw_shift); } dst -= 800; - if ( !xx_32 ) - { + xx_32 -= 2; + if (xx_32 < 0) { i = 16; - do - { - if ( dst < gpBufEnd ) + do { + if (dst < gpBufEnd) break; j = 8; - do - { - *(_DWORD *)dst = 0; + do { + *(_DWORD *)dst = *(_DWORD *)src; + src += 4; dst += 4; --j; - } - while ( j ); + } while (j); dst -= 800; --i; - } - while ( i ); + } while (i); return; } - xx_32 -= 2; } break; - default: // upper (solid), black + default: // upper (solid), without lighting xx_32 = 30; - while ( dst >= gpBufEnd ) - { - n_draw_shift = (unsigned int)(32 - xx_32) >> 2; - if ( (32 - xx_32) & 2 ) - { - *(_WORD *)dst = 0; + while (dst >= gpBufEnd) { + for (n_draw_shift = (unsigned int)(32 - xx_32) >> 2; n_draw_shift; --n_draw_shift) { + *(_DWORD *)dst = *(_DWORD *)src; + src += 4; + dst += 4; + } + if ((32 - (_BYTE)xx_32) & 2) { + *(_WORD *)dst = *(_WORD *)src; + src += 4; dst += 2; } - if ( n_draw_shift ) - { - do - { - *(_DWORD *)dst = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - dst -= 800; - if ( !xx_32 ) - { + dst = &dst[xx_32 - 800]; + xx_32 -= 2; + if (xx_32 < 0) { i = 16; - do - { - if ( dst < gpBufEnd ) + do { + if (dst < gpBufEnd) break; j = 8; - do - { - *(_DWORD *)dst = 0; + do { + *(_DWORD *)dst = *(_DWORD *)src; + src += 4; dst += 4; --j; - } - while ( j ); + } while (j); dst -= 800; --i; - } - while ( i ); + } while (i); return; } - dst += xx_32; - xx_32 -= 2; } break; + } + return; + } + if ((_BYTE)light_table_index != lightmax) { + if (!(level_cel_block & 0x8000)) { + src = (unsigned char *)pDungeonCels + *((_DWORD *)pDungeonCels + (level_cel_block & 0xFFF)); + tbl = (unsigned char *)&pLightTbl[256 * light_table_index]; + cel_type_16 = (unsigned short)level_cel_block >> 12; + switch (cel_type_16) { + case 0: // upper (solid), with lighting + xx_32 = 32; + do { + if (dst < gpBufEnd) + break; + asm_cel_light_square(8, tbl, dst, src); + dst -= 800; + --xx_32; + } while (xx_32); + break; + case 1: // upper (solid), with lighting + xx_32 = 32; + do { + yy_32 = 32; + do { + while (1) { + width = *src++; + if ((width & 0x80u) == 0) + break; + _LOBYTE(width) = -(char)width; + dst += width; + yy_32 -= width; + if (!yy_32) + goto LABEL_58; + } + yy_32 -= width; + if (dst < gpBufEnd) + return; + asm_cel_light_edge(width, tbl, dst, src); + } while (yy_32); + LABEL_58: + dst -= 800; + --xx_32; + } while (xx_32); + break; + case 2: // upper (solid), with lighting + xx_32 = 30; + while (dst >= gpBufEnd) { + dst += xx_32; + src += (32 - (_BYTE)xx_32) & 2; + asm_cel_light_edge(32 - xx_32, tbl, dst, src); + dst -= 800; + xx_32 -= 2; + if (xx_32 < 0) { + yy_32 = 2; + do { + if (dst < gpBufEnd) + break; + dst += yy_32; + src += (32 - (_BYTE)yy_32) & 2; + asm_cel_light_edge(32 - yy_32, tbl, dst, src); + dst -= 800; + yy_32 += 2; + } while (yy_32 != 32); + return; + } + } + break; + case 3: // upper (solid), with lighting + xx_32 = 30; + while (dst >= gpBufEnd) { + asm_cel_light_edge(32 - xx_32, tbl, dst, src); + src += (unsigned char)src & 2; + dst = &dst[xx_32 - 800]; + xx_32 -= 2; + if (xx_32 < 0) { + yy_32 = 2; + do { + if (dst < gpBufEnd) + break; + asm_cel_light_edge(32 - yy_32, tbl, dst, src); + src += (unsigned char)src & 2; + dst = &dst[yy_32 - 800]; + yy_32 += 2; + } while (yy_32 != 32); + return; + } + } + break; + case 4: // upper (solid), with lighting + xx_32 = 30; + while (dst >= gpBufEnd) { + dst += xx_32; + src += (32 - (_BYTE)xx_32) & 2; + asm_cel_light_edge(32 - xx_32, tbl, dst, src); + dst -= 800; + xx_32 -= 2; + if (xx_32 < 0) { + yy_32 = 16; + do { + if (dst < gpBufEnd) + break; + asm_cel_light_square(8, tbl, dst, src); + dst -= 800; + --yy_32; + } while (yy_32); + return; + } + } + break; + default: // upper (solid), with lighting + xx_32 = 30; + while (dst >= gpBufEnd) { + asm_cel_light_edge(32 - xx_32, tbl, dst, src); + src += (unsigned char)src & 2; + dst = &dst[xx_32 - 800]; + xx_32 -= 2; + if (xx_32 < 0) { + yy_32 = 16; + do { + if (dst < gpBufEnd) + break; + asm_cel_light_square(8, tbl, dst, src); + dst -= 800; + --yy_32; + } while (yy_32); + return; + } + } + break; + } + return; + } + src = (unsigned char *)pSpeedCels + + *(_DWORD *)&gpCelFrame[4 * (light_table_index + 16 * (level_cel_block & 0xFFF))]; + cel_type_16 = (unsigned short)level_cel_block >> 12; + goto LABEL_22; + } + if (level_cel_block & 0x8000) + level_cel_block = *(_DWORD *)&gpCelFrame[64 * (level_cel_block & 0xFFF)] + + (unsigned short)(level_cel_block & 0xF000); + src = (unsigned char *)pDungeonCels + *((_DWORD *)pDungeonCels + (level_cel_block & 0xFFF)); + cel_type_16 = ((unsigned int)level_cel_block >> 12) & 7; + switch (cel_type_16) { + case 0: // upper (solid), black + i = 32; + do { + if (dst < gpBufEnd) + break; + j = 8; + do { + *(_DWORD *)dst = 0; + dst += 4; + --j; + } while (j); + dst -= 800; + --i; + } while (i); + break; + case 1: // upper (solid), black + xx_32 = 32; + do { + yy_32 = 32; + do { + while (1) { + width = *src++; + if ((width & 0x80u) == 0) + break; + _LOBYTE(width) = -(char)width; + dst += width; + yy_32 -= width; + if (!yy_32) + goto LABEL_205; + } + yy_32 -= width; + if (dst < gpBufEnd) + return; + src += width; + chk_sh_and = width >> 1; + if (width & 1) { + *dst++ = 0; + if (!chk_sh_and) + continue; + } + n_draw_shift = width >> 2; + if (chk_sh_and & 1) { + *(_WORD *)dst = 0; + dst += 2; + if (!n_draw_shift) + continue; + } + do { + *(_DWORD *)dst = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } while (yy_32); + LABEL_205: + dst -= 800; + --xx_32; + } while (xx_32); + break; + case 2: // upper (solid), black + xx_32 = 30; + while (dst >= gpBufEnd) { + dst += xx_32; + n_draw_shift = (unsigned int)(32 - xx_32) >> 2; + if ((32 - xx_32) & 2) { + *(_WORD *)dst = 0; + dst += 2; + } + if (n_draw_shift) { + do { + *(_DWORD *)dst = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + dst -= 800; + if (!xx_32) { + yy_32 = 2; + do { + if (dst < gpBufEnd) + break; + dst += yy_32; + n_draw_shift = (unsigned int)(32 - yy_32) >> 2; + if ((32 - yy_32) & 2) { + *(_WORD *)dst = 0; + dst += 2; + } + if (n_draw_shift) { + do { + *(_DWORD *)dst = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + dst -= 800; + yy_32 += 2; + } while (yy_32 != 32); + return; + } + xx_32 -= 2; + } + break; + case 3: // upper (solid), black + xx_32 = 30; + while (dst >= gpBufEnd) { + n_draw_shift = (unsigned int)(32 - xx_32) >> 2; + if ((32 - xx_32) & 2) { + *(_WORD *)dst = 0; + dst += 2; + } + if (n_draw_shift) { + do { + *(_DWORD *)dst = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + dst -= 800; + if (!xx_32) { + yy_32 = 2; + do { + if (dst < gpBufEnd) + break; + n_draw_shift = (unsigned int)(32 - yy_32) >> 2; + if ((32 - yy_32) & 2) { + *(_WORD *)dst = 0; + dst += 2; + } + if (n_draw_shift) { + do { + *(_DWORD *)dst = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + dst = &dst[yy_32 - 800]; + yy_32 += 2; + } while (yy_32 != 32); + return; + } + dst += xx_32; + xx_32 -= 2; + } + break; + case 4: // upper (solid), black + xx_32 = 30; + while (dst >= gpBufEnd) { + dst += xx_32; + n_draw_shift = (unsigned int)(32 - xx_32) >> 2; + if ((32 - xx_32) & 2) { + *(_WORD *)dst = 0; + dst += 2; + } + if (n_draw_shift) { + do { + *(_DWORD *)dst = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + dst -= 800; + if (!xx_32) { + i = 16; + do { + if (dst < gpBufEnd) + break; + j = 8; + do { + *(_DWORD *)dst = 0; + dst += 4; + --j; + } while (j); + dst -= 800; + --i; + } while (i); + return; + } + xx_32 -= 2; + } + break; + default: // upper (solid), black + xx_32 = 30; + while (dst >= gpBufEnd) { + n_draw_shift = (unsigned int)(32 - xx_32) >> 2; + if ((32 - xx_32) & 2) { + *(_WORD *)dst = 0; + dst += 2; + } + if (n_draw_shift) { + do { + *(_DWORD *)dst = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + dst -= 800; + if (!xx_32) { + i = 16; + do { + if (dst < gpBufEnd) + break; + j = 8; + do { + *(_DWORD *)dst = 0; + dst += 4; + --j; + } while (j); + dst -= 800; + --i; + } while (i); + return; + } + dst += xx_32; + xx_32 -= 2; + } + break; } } void __fastcall drawTopArchesLowerScreen(unsigned char *pbDst) { - unsigned char *dst; // edi MAPDST - unsigned char *tbl; // ebx - unsigned char *src; // esi MAPDST - short cel_type_16; // ax MAPDST - signed int tile_42_45; // eax MAPDST - unsigned int world_tbl; // ecx MAPDST - unsigned int width; // eax MAPDST - unsigned int chk_sh_and; // ecx MAPDST - int xx_32; // edx MAPDST - unsigned int x_minus; // ecx MAPDST + unsigned char *dst; // edi MAPDST + unsigned char *tbl; // ebx + unsigned char *src; // esi MAPDST + short cel_type_16; // ax MAPDST + signed int tile_42_45; // eax MAPDST + unsigned int world_tbl; // ecx MAPDST + unsigned int width; // eax MAPDST + unsigned int chk_sh_and; // ecx MAPDST + int xx_32; // edx MAPDST + unsigned int x_minus; // ecx MAPDST unsigned int n_draw_shift; // ecx MAPDST - int yy_32; // edx MAPDST - unsigned int y_minus; // ecx MAPDST - signed int i; // edx MAPDST - signed int j; // ecx MAPDST + int yy_32; // edx MAPDST + unsigned int y_minus; // ecx MAPDST + signed int i; // edx MAPDST + signed int j; // ecx MAPDST gpCelFrame = (unsigned char *)speed_cel_frame_num_from_light_index_frame_num; dst = pbDst; - if ( !(_BYTE)light_table_index ) - { - if ( level_cel_block & 0x8000 ) + if (!(_BYTE)light_table_index) { + if (level_cel_block & 0x8000) level_cel_block = *(_DWORD *)&gpCelFrame[64 * (level_cel_block & 0xFFF)] - + (unsigned short)(level_cel_block & 0xF000); + + (unsigned short)(level_cel_block & 0xF000); src = (unsigned char *)pDungeonCels + *((_DWORD *)pDungeonCels + (level_cel_block & 0xFFF)); cel_type_16 = ((level_cel_block >> 12) & 7) + 8; goto LABEL_11; } - if ( (_BYTE)light_table_index == lightmax ) - { - if ( level_cel_block & 0x8000 ) + if ((_BYTE)light_table_index == lightmax) { + if (level_cel_block & 0x8000) level_cel_block = *(_DWORD *)&gpCelFrame[64 * (level_cel_block & 0xFFF)] - + (unsigned short)(level_cel_block & 0xF000); + + (unsigned short)(level_cel_block & 0xF000); src = (unsigned char *)pDungeonCels + *((_DWORD *)pDungeonCels + (level_cel_block & 0xFFF)); cel_type_16 = (level_cel_block >> 12) & 7; - switch ( cel_type_16 ) - { - case 0: // lower (top transparent), black - i = 16; - do - { - if ( dst < gpBufEnd ) - { - j = 8; - do - { - dst[1] = 0; - dst[3] = 0; - dst += 4; - --j; - } - while ( j ); - } - else - { - src += 32; - dst += 32; - } - dst -= 800; - if ( dst < gpBufEnd ) - { - j = 8; - do - { - dst[0] = 0; - dst[2] = 0; - dst += 4; - --j; - } - while ( j ); - } - else - { - src += 32; - dst += 32; - } - dst -= 800; - --i; - } - while ( i ); - break; - case 1: // lower (top transparent), black - WorldBoolFlag = (unsigned char)pbDst & 1; - xx_32 = 32; -LABEL_412: - yy_32 = 32; - while ( 1 ) - { - while ( 1 ) - { - width = (unsigned char)*src++; - if ( (width & 0x80u) == 0 ) - break; - _LOBYTE(width) = -(char)width; - dst += width; - yy_32 -= width; - if ( !yy_32 ) - { -LABEL_433: - WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; - dst -= 800; - if ( !--xx_32 ) - return; - goto LABEL_412; - } - } - yy_32 -= width; - if ( dst < gpBufEnd ) - { - src += width; - if ( ((unsigned char)dst & 1) == WorldBoolFlag ) - { - chk_sh_and = width >> 1; - if ( !(width & 1) ) - goto LABEL_420; - ++dst; - if ( chk_sh_and ) - { -LABEL_427: - n_draw_shift = chk_sh_and >> 1; - if ( chk_sh_and & 1 ) - { - dst[0] = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - dst[0] = 0; - dst[2] = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - goto LABEL_430; - } - } - else - { - chk_sh_and = width >> 1; - if ( !(width & 1) ) - goto LABEL_427; - *dst++ = 0; - if ( chk_sh_and ) - { -LABEL_420: - n_draw_shift = chk_sh_and >> 1; - if ( chk_sh_and & 1 ) - { - dst[1] = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - dst[1] = 0; - dst[3] = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - goto LABEL_430; - } - } - } - else - { - src += width; - dst += width; - } -LABEL_430: - if ( !yy_32 ) - goto LABEL_433; - } - break; - case 2: // lower (top transparent), black - WorldBoolFlag = 0; - for ( xx_32 = 30; ; xx_32 -= 2 ) - { - if ( dst < gpBufEnd ) - { - dst += xx_32; - x_minus = 32 - xx_32; - WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; - if ( WorldBoolFlag ) - { - n_draw_shift = x_minus >> 2; - if ( x_minus & 2 ) - { - dst[1] = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - dst[1] = 0; - dst[3] = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - } - else - { - n_draw_shift = x_minus >> 2; - if ( x_minus & 2 ) - { - dst[0] = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - dst[0] = 0; - dst[2] = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - } - } - else - { - src = &src[-xx_32 + 32]; - dst += 32; - } - dst -= 800; - if ( !xx_32 ) - break; - } - yy_32 = 2; - do - { - if ( dst < gpBufEnd ) - { - dst += yy_32; - y_minus = 32 - yy_32; - WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; - if ( WorldBoolFlag ) - { - n_draw_shift = y_minus >> 2; - if ( y_minus & 2 ) - { - dst[1] = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - dst[1] = 0; - dst[3] = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - } - else - { - n_draw_shift = y_minus >> 2; - if ( y_minus & 2 ) - { - dst[0] = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - dst[0] = 0; - dst[2] = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - } - } - else - { - src = &src[-yy_32 + 32]; - dst += 32; - } - dst -= 800; - yy_32 += 2; - } - while ( yy_32 != 32 ); - break; - case 3: // lower (top transparent), black - WorldBoolFlag = 0; - for ( xx_32 = 30; ; xx_32 -= 2 ) - { - if ( dst < gpBufEnd ) - { - x_minus = 32 - xx_32; - WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; - if ( WorldBoolFlag ) - { - n_draw_shift = x_minus >> 2; - if ( x_minus & 2 ) - { - dst[1] = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - dst[1] = 0; - dst[3] = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - } - else - { - n_draw_shift = x_minus >> 2; - if ( x_minus & 2 ) - { - dst[0] = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - dst[0] = 0; - dst[2] = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - } - } - else - { - src = &src[-xx_32 + 32]; - dst = &dst[-xx_32 + 32]; - } - dst -= 800; - if ( !xx_32 ) - break; - dst += xx_32; - } - yy_32 = 2; - do - { - if ( dst < gpBufEnd ) - { - y_minus = 32 - yy_32; - WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; - if ( WorldBoolFlag ) - { - n_draw_shift = y_minus >> 2; - if ( y_minus & 2 ) - { - dst[1] = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - dst[1] = 0; - dst[3] = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - } - else - { - n_draw_shift = y_minus >> 2; - if ( y_minus & 2 ) - { - dst[0] = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - dst[0] = 0; - dst[2] = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - } - } - else - { - src = &src[-yy_32 + 32]; - dst = &dst[-yy_32 + 32]; - } - dst = &dst[yy_32 - 800]; - yy_32 += 2; - } - while ( yy_32 != 32 ); - break; - case 4: // lower (top transparent), black - WorldBoolFlag = 0; - for ( xx_32 = 30; ; xx_32 -= 2 ) - { - if ( dst < gpBufEnd ) - { - dst += xx_32; - x_minus = 32 - xx_32; - WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; - if ( WorldBoolFlag ) - { - n_draw_shift = x_minus >> 2; - if ( x_minus & 2 ) - { - dst[1] = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - dst[1] = 0; - dst[3] = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - } - else - { - n_draw_shift = x_minus >> 2; - if ( x_minus & 2 ) - { - dst[0] = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - dst[0] = 0; - dst[2] = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - } - } - else - { - src = &src[-xx_32 + 32]; - dst += 32; - } - dst -= 800; - if ( !xx_32 ) - break; - } - i = 8; - do - { - if ( dst < gpBufEnd ) - { - j = 8; - do - { - dst[1] = 0; - dst[3] = 0; - dst += 4; - --j; - } - while ( j ); - } - else - { - src += 32; - dst += 32; - } - dst -= 800; - if ( dst < gpBufEnd ) - { - j = 8; - do - { - dst[0] = 0; - dst[2] = 0; - dst += 4; - --j; - } - while ( j ); - } - else - { - src += 32; - dst += 32; - } - dst -= 800; - --i; - } - while ( i ); - break; - default: // lower (top transparent), black - WorldBoolFlag = 0; - for ( xx_32 = 30; ; xx_32 -= 2 ) - { - if ( dst < gpBufEnd ) - { - x_minus = 32 - xx_32; - WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; - if ( WorldBoolFlag ) - { - n_draw_shift = x_minus >> 2; - if ( x_minus & 2 ) - { - dst[1] = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - dst[1] = 0; - dst[3] = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - } - else - { - n_draw_shift = x_minus >> 2; - if ( x_minus & 2 ) - { - dst[0] = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - dst[0] = 0; - dst[2] = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - } - } - else - { - src = &src[-xx_32 + 32]; - dst = &dst[-xx_32 + 32]; - } - dst -= 800; - if ( !xx_32 ) - break; - dst += xx_32; - } - i = 8; - do - { - if ( dst < gpBufEnd ) - { - j = 8; - do - { - dst[1] = 0; - dst[3] = 0; - dst += 4; - --j; - } - while ( j ); - } - else - { - src += 32; - dst += 32; - } - dst -= 800; - if ( dst < gpBufEnd ) - { - j = 8; - do - { - dst[0] = 0; - dst[2] = 0; - dst += 4; - --j; - } - while ( j ); - } - else - { - src += 32; - dst += 32; - } - dst -= 800; - --i; - } - while ( i ); - break; - } - return; - } - if ( !(level_cel_block & 0x8000) ) - { - src = (unsigned char *)pDungeonCels + *((_DWORD *)pDungeonCels + (level_cel_block & 0xFFF)); - tbl = (unsigned char *)&pLightTbl[256 * light_table_index]; - cel_type_16 = (unsigned char)(level_cel_block >> 12); - switch ( cel_type_16 ) - { - case 0: // lower (top transparent), with lighting - i = 16; - do - { - if ( dst < gpBufEnd ) - { - asm_trans_light_square_1_3(8, tbl, dst, src); - } - else - { - src += 32; - dst += 32; - } - dst -= 800; - if ( dst < gpBufEnd ) - { - asm_trans_light_square_0_2(8, tbl, dst, src); - } - else - { - src += 32; - dst += 32; - } - dst -= 800; - --i; - } - while ( i ); - break; - case 1: // lower (top transparent), with lighting - WorldBoolFlag = (unsigned char)pbDst & 1; - xx_32 = 32; - do - { - yy_32 = 32; - do - { - while ( 1 ) - { - width = (unsigned char)*src++; - if ( (width & 0x80u) == 0 ) - break; - _LOBYTE(width) = -(char)width; - dst += width; - yy_32 -= width; - if ( !yy_32 ) - goto LABEL_69; - } - yy_32 -= width; - if ( dst < gpBufEnd ) - { - if ( ((unsigned char)dst & 1) == WorldBoolFlag ) - { - asm_trans_light_cel_0_2(width, tbl, dst, src); - } - else - { - asm_trans_light_cel_1_3(width, tbl, dst, src); - } - } - else - { - src += width; - dst += width; - } - } - while ( yy_32 ); -LABEL_69: - WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; - dst -= 800; - --xx_32; - } - while ( xx_32 ); - break; - case 2: // lower (top transparent), with lighting - WorldBoolFlag = 0; - xx_32 = 30; - if ( pbDst >= gpBufEnd ) - { - tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; - if ( tile_42_45 > 45 ) - { - dst = pbDst - 12288; - src += 288; -LABEL_98: - yy_32 = 2; - if ( dst >= gpBufEnd ) - { - tile_42_45 = (unsigned int)(dst - gpBufEnd + 1023) >> 8; - if ( tile_42_45 > 42 ) - return; - world_tbl = WorldTbl3x16[tile_42_45]; - src += WorldTbl17_2[world_tbl >> 2]; - dst -= 192 * world_tbl; - world_tbl >>= 1; - yy_32 = world_tbl + 2; - WorldBoolFlag += world_tbl >> 1; - } - do - { - dst += yy_32; - src += (32 - (_BYTE)yy_32) & 2; - WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; - if ( WorldBoolFlag ) - { - asm_trans_light_cel_0_2(32 - yy_32, tbl, dst, src); - } - else - { - asm_trans_light_cel_1_3(32 - yy_32, tbl, dst, src); - } - dst -= 800; - yy_32 += 2; - } - while ( yy_32 != 32 ); - return; - } - world_tbl = WorldTbl3x16[tile_42_45]; - src += WorldTbl17_1[world_tbl >> 2]; - dst -= 192 * world_tbl; - world_tbl >>= 1; - xx_32 = 30 - world_tbl; - WorldBoolFlag += world_tbl >> 1; - } - do - { - dst += xx_32; - src += (32 - (_BYTE)xx_32) & 2; - WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; - if ( WorldBoolFlag ) - { - asm_trans_light_cel_0_2(32 - xx_32, tbl, dst, src); - } - else - { - asm_trans_light_cel_1_3(32 - xx_32, tbl, dst, src); - } - dst -= 800; - xx_32 -= 2; - } - while ( xx_32 >= 0 ); - goto LABEL_98; - case 3: // lower (top transparent), with lighting - WorldBoolFlag = 0; - xx_32 = 30; - if ( pbDst >= gpBufEnd ) - { - tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; - if ( tile_42_45 > 45 ) - { - dst = pbDst - 12288; - src += 288; -LABEL_154: - yy_32 = 2; - if ( dst >= gpBufEnd ) - { - tile_42_45 = (unsigned int)(dst - gpBufEnd + 1023) >> 8; - if ( tile_42_45 > 42 ) - return; - world_tbl = WorldTbl3x16[tile_42_45]; - src += WorldTbl17_2[world_tbl >> 2]; - dst -= 192 * world_tbl; - world_tbl >>= 1; - yy_32 = world_tbl + 2; - WorldBoolFlag += world_tbl >> 1; - } - do - { - WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; - if ( WorldBoolFlag ) - { - asm_trans_light_cel_0_2(32 - yy_32, tbl, dst, src); - } - else - { - asm_trans_light_cel_1_3(32 - yy_32, tbl, dst, src); - } - src += (unsigned char)src & 2; - dst = &dst[yy_32 - 800]; - yy_32 += 2; - } - while ( yy_32 != 32 ); - return; - } - world_tbl = WorldTbl3x16[tile_42_45]; - src += WorldTbl17_1[world_tbl >> 2]; - dst -= 192 * world_tbl; - world_tbl >>= 1; - xx_32 = 30 - world_tbl; - WorldBoolFlag += world_tbl >> 1; - } - do - { - WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; - if ( WorldBoolFlag ) - { - asm_trans_light_cel_0_2(32 - xx_32, tbl, dst, src); - } - else - { - asm_trans_light_cel_1_3(32 - xx_32, tbl, dst, src); - } - src += (unsigned char)src & 2; - dst = &dst[xx_32 - 800]; - xx_32 -= 2; - } - while ( xx_32 >= 0 ); - goto LABEL_154; - case 4: // lower (top transparent), with lighting - WorldBoolFlag = 0; - xx_32 = 30; - if ( pbDst >= gpBufEnd ) - { - tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; - if ( tile_42_45 > 45 ) - { - dst = pbDst - 12288; - src += 288; -LABEL_210: - i = 8; - do - { - if ( dst < gpBufEnd ) - { - asm_trans_light_square_1_3(8, tbl, dst, src); - } - else - { - src += 32; - dst += 32; - } - dst -= 800; - if ( dst < gpBufEnd ) - { - asm_trans_light_square_0_2(8, tbl, dst, src); - } - else - { - src += 32; - dst += 32; - } - dst -= 800; - --i; - } - while ( i ); - return; - } - world_tbl = WorldTbl3x16[tile_42_45]; - src += WorldTbl17_1[world_tbl >> 2]; - dst -= 192 * world_tbl; - world_tbl >>= 1; - xx_32 = 30 - world_tbl; - WorldBoolFlag += world_tbl >> 1; - } - do - { - dst += xx_32; - src += (32 - (_BYTE)xx_32) & 2; - WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; - if ( WorldBoolFlag ) - { - asm_trans_light_cel_0_2(32 - xx_32, tbl, dst, src); - } - else - { - asm_trans_light_cel_1_3(32 - xx_32, tbl, dst, src); - } - dst -= 800; - xx_32 -= 2; - } - while ( xx_32 >= 0 ); - goto LABEL_210; - default: // lower (top transparent), with lighting - WorldBoolFlag = 0; - xx_32 = 30; - if ( pbDst >= gpBufEnd ) - { - tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; - if ( tile_42_45 > 45 ) - { - dst = pbDst - 12288; - src += 288; -LABEL_249: - i = 8; - do - { - if ( dst < gpBufEnd ) - { - asm_trans_light_square_1_3(8, tbl, dst, src); - } - else - { - src += 32; - dst += 32; - } - dst -= 800; - if ( dst < gpBufEnd ) - { - asm_trans_light_square_0_2(8, tbl, dst, src); - } - else - { - src += 32; - dst += 32; - } - dst -= 800; - --i; - } - while ( i ); - return; - } - world_tbl = WorldTbl3x16[tile_42_45]; - src += WorldTbl17_1[world_tbl >> 2]; - dst -= 192 * world_tbl; - world_tbl >>= 1; - xx_32 = 30 - world_tbl; - WorldBoolFlag += world_tbl >> 1; - } - do - { - WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; - if ( WorldBoolFlag ) - { - asm_trans_light_cel_0_2(32 - xx_32, tbl, dst, src); - } - else - { - asm_trans_light_cel_1_3(32 - xx_32, tbl, dst, src); - } - src += (unsigned char)src & 2; - dst = &dst[xx_32 - 800]; - xx_32 -= 2; - } - while ( xx_32 >= 0 ); - goto LABEL_249; - } - return; - } - src = (unsigned char *)pSpeedCels + *(_DWORD *)&gpCelFrame[4 * (light_table_index + 16 * (level_cel_block & 0xFFF))]; - cel_type_16 = (unsigned char)(level_cel_block >> 12); -LABEL_11: - switch ( cel_type_16 ) - { - case 8: // lower (top transparent), without lighting + switch (cel_type_16) { + case 0: // lower (top transparent), black i = 16; - do - { - if ( dst < gpBufEnd ) - { + do { + if (dst < gpBufEnd) { j = 8; - do - { - dst[1] = src[1]; - dst[3] = src[3]; - src += 4; + do { + dst[1] = 0; + dst[3] = 0; dst += 4; --j; - } - while ( j ); - } - else - { + } while (j); + } else { src += 32; dst += 32; } dst -= 800; - if ( dst < gpBufEnd ) - { + if (dst < gpBufEnd) { j = 8; - do - { - dst[0] = src[0]; - dst[2] = src[2]; - src += 4; + do { + dst[0] = 0; + dst[2] = 0; dst += 4; --j; - } - while ( j ); - } - else - { + } while (j); + } else { src += 32; dst += 32; } dst -= 800; --i; - } - while ( i ); + } while (i); break; - case 9: // lower (top transparent), without lighting + case 1: // lower (top transparent), black WorldBoolFlag = (unsigned char)pbDst & 1; xx_32 = 32; - while ( 1 ) - { - yy_32 = 32; - do - { - while ( 1 ) - { - width = (unsigned char)*src++; - if ( (width & 0x80u) != 0 ) - break; - yy_32 -= width; - if ( dst < gpBufEnd ) - { - if ( ((unsigned char)dst & 1) == WorldBoolFlag ) - { - chk_sh_and = width >> 1; - if ( !(width & 1) ) - goto LABEL_280; - ++src; - ++dst; - if ( chk_sh_and ) - { -LABEL_287: - n_draw_shift = chk_sh_and >> 1; - if ( chk_sh_and & 1 ) - { - dst[0] = src[0]; - src += 2; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - dst[0] = src[0]; - dst[2] = src[2]; - src += 4; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - goto LABEL_290; - } - } - else - { - chk_sh_and = width >> 1; - if ( !(width & 1) ) - goto LABEL_287; - *dst++ = *src++; - if ( chk_sh_and ) - { -LABEL_280: - n_draw_shift = chk_sh_and >> 1; - if ( chk_sh_and & 1 ) - { - dst[1] = src[1]; - src += 2; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - dst[1] = src[1]; - dst[3] = src[3]; - src += 4; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - goto LABEL_290; - } - } - } - else - { - src += width; - dst += width; - } -LABEL_290: - if ( !yy_32 ) - goto LABEL_293; - } + LABEL_412: + yy_32 = 32; + while (1) { + while (1) { + width = (unsigned char)*src++; + if ((width & 0x80u) == 0) + break; _LOBYTE(width) = -(char)width; dst += width; yy_32 -= width; + if (!yy_32) { + LABEL_433: + WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; + dst -= 800; + if (!--xx_32) + return; + goto LABEL_412; + } } - while ( yy_32 ); -LABEL_293: + yy_32 -= width; + if (dst < gpBufEnd) { + src += width; + if (((unsigned char)dst & 1) == WorldBoolFlag) { + chk_sh_and = width >> 1; + if (!(width & 1)) + goto LABEL_420; + ++dst; + if (chk_sh_and) { + LABEL_427: + n_draw_shift = chk_sh_and >> 1; + if (chk_sh_and & 1) { + dst[0] = 0; + dst += 2; + } + if (n_draw_shift) { + do { + dst[0] = 0; + dst[2] = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + goto LABEL_430; + } + } else { + chk_sh_and = width >> 1; + if (!(width & 1)) + goto LABEL_427; + *dst++ = 0; + if (chk_sh_and) { + LABEL_420: + n_draw_shift = chk_sh_and >> 1; + if (chk_sh_and & 1) { + dst[1] = 0; + dst += 2; + } + if (n_draw_shift) { + do { + dst[1] = 0; + dst[3] = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + goto LABEL_430; + } + } + } else { + src += width; + dst += width; + } + LABEL_430: + if (!yy_32) + goto LABEL_433; + } + break; + case 2: // lower (top transparent), black + WorldBoolFlag = 0; + for (xx_32 = 30;; xx_32 -= 2) { + if (dst < gpBufEnd) { + dst += xx_32; + x_minus = 32 - xx_32; + WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; + if (WorldBoolFlag) { + n_draw_shift = x_minus >> 2; + if (x_minus & 2) { + dst[1] = 0; + dst += 2; + } + if (n_draw_shift) { + do { + dst[1] = 0; + dst[3] = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + } else { + n_draw_shift = x_minus >> 2; + if (x_minus & 2) { + dst[0] = 0; + dst += 2; + } + if (n_draw_shift) { + do { + dst[0] = 0; + dst[2] = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + } + } else { + src = &src[-xx_32 + 32]; + dst += 32; + } + dst -= 800; + if (!xx_32) + break; + } + yy_32 = 2; + do { + if (dst < gpBufEnd) { + dst += yy_32; + y_minus = 32 - yy_32; + WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; + if (WorldBoolFlag) { + n_draw_shift = y_minus >> 2; + if (y_minus & 2) { + dst[1] = 0; + dst += 2; + } + if (n_draw_shift) { + do { + dst[1] = 0; + dst[3] = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + } else { + n_draw_shift = y_minus >> 2; + if (y_minus & 2) { + dst[0] = 0; + dst += 2; + } + if (n_draw_shift) { + do { + dst[0] = 0; + dst[2] = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + } + } else { + src = &src[-yy_32 + 32]; + dst += 32; + } + dst -= 800; + yy_32 += 2; + } while (yy_32 != 32); + break; + case 3: // lower (top transparent), black + WorldBoolFlag = 0; + for (xx_32 = 30;; xx_32 -= 2) { + if (dst < gpBufEnd) { + x_minus = 32 - xx_32; + WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; + if (WorldBoolFlag) { + n_draw_shift = x_minus >> 2; + if (x_minus & 2) { + dst[1] = 0; + dst += 2; + } + if (n_draw_shift) { + do { + dst[1] = 0; + dst[3] = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + } else { + n_draw_shift = x_minus >> 2; + if (x_minus & 2) { + dst[0] = 0; + dst += 2; + } + if (n_draw_shift) { + do { + dst[0] = 0; + dst[2] = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + } + } else { + src = &src[-xx_32 + 32]; + dst = &dst[-xx_32 + 32]; + } + dst -= 800; + if (!xx_32) + break; + dst += xx_32; + } + yy_32 = 2; + do { + if (dst < gpBufEnd) { + y_minus = 32 - yy_32; + WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; + if (WorldBoolFlag) { + n_draw_shift = y_minus >> 2; + if (y_minus & 2) { + dst[1] = 0; + dst += 2; + } + if (n_draw_shift) { + do { + dst[1] = 0; + dst[3] = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + } else { + n_draw_shift = y_minus >> 2; + if (y_minus & 2) { + dst[0] = 0; + dst += 2; + } + if (n_draw_shift) { + do { + dst[0] = 0; + dst[2] = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + } + } else { + src = &src[-yy_32 + 32]; + dst = &dst[-yy_32 + 32]; + } + dst = &dst[yy_32 - 800]; + yy_32 += 2; + } while (yy_32 != 32); + break; + case 4: // lower (top transparent), black + WorldBoolFlag = 0; + for (xx_32 = 30;; xx_32 -= 2) { + if (dst < gpBufEnd) { + dst += xx_32; + x_minus = 32 - xx_32; + WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; + if (WorldBoolFlag) { + n_draw_shift = x_minus >> 2; + if (x_minus & 2) { + dst[1] = 0; + dst += 2; + } + if (n_draw_shift) { + do { + dst[1] = 0; + dst[3] = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + } else { + n_draw_shift = x_minus >> 2; + if (x_minus & 2) { + dst[0] = 0; + dst += 2; + } + if (n_draw_shift) { + do { + dst[0] = 0; + dst[2] = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + } + } else { + src = &src[-xx_32 + 32]; + dst += 32; + } + dst -= 800; + if (!xx_32) + break; + } + i = 8; + do { + if (dst < gpBufEnd) { + j = 8; + do { + dst[1] = 0; + dst[3] = 0; + dst += 4; + --j; + } while (j); + } else { + src += 32; + dst += 32; + } + dst -= 800; + if (dst < gpBufEnd) { + j = 8; + do { + dst[0] = 0; + dst[2] = 0; + dst += 4; + --j; + } while (j); + } else { + src += 32; + dst += 32; + } + dst -= 800; + --i; + } while (i); + break; + default: // lower (top transparent), black + WorldBoolFlag = 0; + for (xx_32 = 30;; xx_32 -= 2) { + if (dst < gpBufEnd) { + x_minus = 32 - xx_32; + WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; + if (WorldBoolFlag) { + n_draw_shift = x_minus >> 2; + if (x_minus & 2) { + dst[1] = 0; + dst += 2; + } + if (n_draw_shift) { + do { + dst[1] = 0; + dst[3] = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + } else { + n_draw_shift = x_minus >> 2; + if (x_minus & 2) { + dst[0] = 0; + dst += 2; + } + if (n_draw_shift) { + do { + dst[0] = 0; + dst[2] = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + } + } else { + src = &src[-xx_32 + 32]; + dst = &dst[-xx_32 + 32]; + } + dst -= 800; + if (!xx_32) + break; + dst += xx_32; + } + i = 8; + do { + if (dst < gpBufEnd) { + j = 8; + do { + dst[1] = 0; + dst[3] = 0; + dst += 4; + --j; + } while (j); + } else { + src += 32; + dst += 32; + } + dst -= 800; + if (dst < gpBufEnd) { + j = 8; + do { + dst[0] = 0; + dst[2] = 0; + dst += 4; + --j; + } while (j); + } else { + src += 32; + dst += 32; + } + dst -= 800; + --i; + } while (i); + break; + } + return; + } + if (!(level_cel_block & 0x8000)) { + src = (unsigned char *)pDungeonCels + *((_DWORD *)pDungeonCels + (level_cel_block & 0xFFF)); + tbl = (unsigned char *)&pLightTbl[256 * light_table_index]; + cel_type_16 = (unsigned char)(level_cel_block >> 12); + switch (cel_type_16) { + case 0: // lower (top transparent), with lighting + i = 16; + do { + if (dst < gpBufEnd) { + asm_trans_light_square_1_3(8, tbl, dst, src); + } else { + src += 32; + dst += 32; + } + dst -= 800; + if (dst < gpBufEnd) { + asm_trans_light_square_0_2(8, tbl, dst, src); + } else { + src += 32; + dst += 32; + } + dst -= 800; + --i; + } while (i); + break; + case 1: // lower (top transparent), with lighting + WorldBoolFlag = (unsigned char)pbDst & 1; + xx_32 = 32; + do { + yy_32 = 32; + do { + while (1) { + width = (unsigned char)*src++; + if ((width & 0x80u) == 0) + break; + _LOBYTE(width) = -(char)width; + dst += width; + yy_32 -= width; + if (!yy_32) + goto LABEL_69; + } + yy_32 -= width; + if (dst < gpBufEnd) { + if (((unsigned char)dst & 1) == WorldBoolFlag) { + asm_trans_light_cel_0_2(width, tbl, dst, src); + } else { + asm_trans_light_cel_1_3(width, tbl, dst, src); + } + } else { + src += width; + dst += width; + } + } while (yy_32); + LABEL_69: WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; dst -= 800; - if ( !--xx_32 ) - return; - } - case 10: // lower (top transparent), without lighting + --xx_32; + } while (xx_32); + break; + case 2: // lower (top transparent), with lighting WorldBoolFlag = 0; xx_32 = 30; - if ( pbDst >= gpBufEnd ) - { + if (pbDst >= gpBufEnd) { tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; - if ( tile_42_45 > 45 ) - { + if (tile_42_45 > 45) { dst = pbDst - 12288; src += 288; -LABEL_308: + LABEL_98: yy_32 = 2; - if ( dst >= gpBufEnd ) - { + if (dst >= gpBufEnd) { tile_42_45 = (unsigned int)(dst - gpBufEnd + 1023) >> 8; - if ( tile_42_45 > 42 ) + if (tile_42_45 > 42) return; world_tbl = WorldTbl3x16[tile_42_45]; src += WorldTbl17_2[world_tbl >> 2]; @@ -4031,60 +2909,18 @@ LABEL_308: yy_32 = world_tbl + 2; WorldBoolFlag += world_tbl >> 1; } - do - { + do { dst += yy_32; - y_minus = 32 - yy_32; + src += (32 - (_BYTE)yy_32) & 2; WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; - if ( WorldBoolFlag ) - { - n_draw_shift = y_minus >> 2; - if ( y_minus & 2 ) - { - dst[1] = src[3]; - src += 4; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - dst[1] = src[1]; - dst[3] = src[3]; - src += 4; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - } - else - { - n_draw_shift = y_minus >> 2; - if ( y_minus & 2 ) - { - dst[0] = src[2]; - src += 4; - dst += 2; - --n_draw_shift; /// BUGFIX: delete this line - } - if ( n_draw_shift ) - { - do - { - dst[0] = src[0]; - dst[2] = src[2]; - src += 4; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } + if (WorldBoolFlag) { + asm_trans_light_cel_0_2(32 - yy_32, tbl, dst, src); + } else { + asm_trans_light_cel_1_3(32 - yy_32, tbl, dst, src); } dst -= 800; yy_32 += 2; - } - while ( yy_32 != 32 ); + } while (yy_32 != 32); return; } world_tbl = WorldTbl3x16[tile_42_45]; @@ -4094,387 +2930,439 @@ LABEL_308: xx_32 = 30 - world_tbl; WorldBoolFlag += world_tbl >> 1; } - do - { + do { dst += xx_32; - x_minus = 32 - xx_32; + src += (32 - (_BYTE)xx_32) & 2; WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; - if ( WorldBoolFlag ) - { - n_draw_shift = x_minus >> 2; - if ( x_minus & 2 ) - { - dst[1] = src[3]; - src += 4; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - dst[1] = src[1]; - dst[3] = src[3]; - src += 4; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - } - else - { - n_draw_shift = x_minus >> 2; - if ( x_minus & 2 ) - { - dst[0] = src[2]; - src += 4; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - dst[0] = src[0]; - dst[2] = src[2]; - src += 4; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } + if (WorldBoolFlag) { + asm_trans_light_cel_0_2(32 - xx_32, tbl, dst, src); + } else { + asm_trans_light_cel_1_3(32 - xx_32, tbl, dst, src); } dst -= 800; xx_32 -= 2; - } - while ( xx_32 >= 0 ); - goto LABEL_308; - case 11: // lower (top transparent), without lighting + } while (xx_32 >= 0); + goto LABEL_98; + case 3: // lower (top transparent), with lighting WorldBoolFlag = 0; xx_32 = 30; - if ( pbDst < gpBufEnd ) - goto LABEL_326; + if (pbDst >= gpBufEnd) { + tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; + if (tile_42_45 > 45) { + dst = pbDst - 12288; + src += 288; + LABEL_154: + yy_32 = 2; + if (dst >= gpBufEnd) { + tile_42_45 = (unsigned int)(dst - gpBufEnd + 1023) >> 8; + if (tile_42_45 > 42) + return; + world_tbl = WorldTbl3x16[tile_42_45]; + src += WorldTbl17_2[world_tbl >> 2]; + dst -= 192 * world_tbl; + world_tbl >>= 1; + yy_32 = world_tbl + 2; + WorldBoolFlag += world_tbl >> 1; + } + do { + WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; + if (WorldBoolFlag) { + asm_trans_light_cel_0_2(32 - yy_32, tbl, dst, src); + } else { + asm_trans_light_cel_1_3(32 - yy_32, tbl, dst, src); + } + src += (unsigned char)src & 2; + dst = &dst[yy_32 - 800]; + yy_32 += 2; + } while (yy_32 != 32); + return; + } + world_tbl = WorldTbl3x16[tile_42_45]; + src += WorldTbl17_1[world_tbl >> 2]; + dst -= 192 * world_tbl; + world_tbl >>= 1; + xx_32 = 30 - world_tbl; + WorldBoolFlag += world_tbl >> 1; + } + do { + WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; + if (WorldBoolFlag) { + asm_trans_light_cel_0_2(32 - xx_32, tbl, dst, src); + } else { + asm_trans_light_cel_1_3(32 - xx_32, tbl, dst, src); + } + src += (unsigned char)src & 2; + dst = &dst[xx_32 - 800]; + xx_32 -= 2; + } while (xx_32 >= 0); + goto LABEL_154; + case 4: // lower (top transparent), with lighting + WorldBoolFlag = 0; + xx_32 = 30; + if (pbDst >= gpBufEnd) { + tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; + if (tile_42_45 > 45) { + dst = pbDst - 12288; + src += 288; + LABEL_210: + i = 8; + do { + if (dst < gpBufEnd) { + asm_trans_light_square_1_3(8, tbl, dst, src); + } else { + src += 32; + dst += 32; + } + dst -= 800; + if (dst < gpBufEnd) { + asm_trans_light_square_0_2(8, tbl, dst, src); + } else { + src += 32; + dst += 32; + } + dst -= 800; + --i; + } while (i); + return; + } + world_tbl = WorldTbl3x16[tile_42_45]; + src += WorldTbl17_1[world_tbl >> 2]; + dst -= 192 * world_tbl; + world_tbl >>= 1; + xx_32 = 30 - world_tbl; + WorldBoolFlag += world_tbl >> 1; + } + do { + dst += xx_32; + src += (32 - (_BYTE)xx_32) & 2; + WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; + if (WorldBoolFlag) { + asm_trans_light_cel_0_2(32 - xx_32, tbl, dst, src); + } else { + asm_trans_light_cel_1_3(32 - xx_32, tbl, dst, src); + } + dst -= 800; + xx_32 -= 2; + } while (xx_32 >= 0); + goto LABEL_210; + default: // lower (top transparent), with lighting + WorldBoolFlag = 0; + xx_32 = 30; + if (pbDst >= gpBufEnd) { + tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; + if (tile_42_45 > 45) { + dst = pbDst - 12288; + src += 288; + LABEL_249: + i = 8; + do { + if (dst < gpBufEnd) { + asm_trans_light_square_1_3(8, tbl, dst, src); + } else { + src += 32; + dst += 32; + } + dst -= 800; + if (dst < gpBufEnd) { + asm_trans_light_square_0_2(8, tbl, dst, src); + } else { + src += 32; + dst += 32; + } + dst -= 800; + --i; + } while (i); + return; + } + world_tbl = WorldTbl3x16[tile_42_45]; + src += WorldTbl17_1[world_tbl >> 2]; + dst -= 192 * world_tbl; + world_tbl >>= 1; + xx_32 = 30 - world_tbl; + WorldBoolFlag += world_tbl >> 1; + } + do { + WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; + if (WorldBoolFlag) { + asm_trans_light_cel_0_2(32 - xx_32, tbl, dst, src); + } else { + asm_trans_light_cel_1_3(32 - xx_32, tbl, dst, src); + } + src += (unsigned char)src & 2; + dst = &dst[xx_32 - 800]; + xx_32 -= 2; + } while (xx_32 >= 0); + goto LABEL_249; + } + return; + } + src = (unsigned char *)pSpeedCels + *(_DWORD *)&gpCelFrame[4 * (light_table_index + 16 * (level_cel_block & 0xFFF))]; + cel_type_16 = (unsigned char)(level_cel_block >> 12); +LABEL_11: + switch (cel_type_16) { + case 8: // lower (top transparent), without lighting + i = 16; + do { + if (dst < gpBufEnd) { + j = 8; + do { + dst[1] = src[1]; + dst[3] = src[3]; + src += 4; + dst += 4; + --j; + } while (j); + } else { + src += 32; + dst += 32; + } + dst -= 800; + if (dst < gpBufEnd) { + j = 8; + do { + dst[0] = src[0]; + dst[2] = src[2]; + src += 4; + dst += 4; + --j; + } while (j); + } else { + src += 32; + dst += 32; + } + dst -= 800; + --i; + } while (i); + break; + case 9: // lower (top transparent), without lighting + WorldBoolFlag = (unsigned char)pbDst & 1; + xx_32 = 32; + while (1) { + yy_32 = 32; + do { + while (1) { + width = (unsigned char)*src++; + if ((width & 0x80u) != 0) + break; + yy_32 -= width; + if (dst < gpBufEnd) { + if (((unsigned char)dst & 1) == WorldBoolFlag) { + chk_sh_and = width >> 1; + if (!(width & 1)) + goto LABEL_280; + ++src; + ++dst; + if (chk_sh_and) { + LABEL_287: + n_draw_shift = chk_sh_and >> 1; + if (chk_sh_and & 1) { + dst[0] = src[0]; + src += 2; + dst += 2; + } + if (n_draw_shift) { + do { + dst[0] = src[0]; + dst[2] = src[2]; + src += 4; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + goto LABEL_290; + } + } else { + chk_sh_and = width >> 1; + if (!(width & 1)) + goto LABEL_287; + *dst++ = *src++; + if (chk_sh_and) { + LABEL_280: + n_draw_shift = chk_sh_and >> 1; + if (chk_sh_and & 1) { + dst[1] = src[1]; + src += 2; + dst += 2; + } + if (n_draw_shift) { + do { + dst[1] = src[1]; + dst[3] = src[3]; + src += 4; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + goto LABEL_290; + } + } + } else { + src += width; + dst += width; + } + LABEL_290: + if (!yy_32) + goto LABEL_293; + } + _LOBYTE(width) = -(char)width; + dst += width; + yy_32 -= width; + } while (yy_32); + LABEL_293: + WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; + dst -= 800; + if (!--xx_32) + return; + } + case 10: // lower (top transparent), without lighting + WorldBoolFlag = 0; + xx_32 = 30; + if (pbDst >= gpBufEnd) { tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; - if ( tile_42_45 <= 45 ) - { - world_tbl = WorldTbl3x16[tile_42_45]; - src += WorldTbl17_1[world_tbl >> 2]; - dst -= 192 * world_tbl; - world_tbl >>= 1; - xx_32 = 30 - world_tbl; - WorldBoolFlag += world_tbl >> 1; - do - { -LABEL_326: - x_minus = 32 - xx_32; + if (tile_42_45 > 45) { + dst = pbDst - 12288; + src += 288; + LABEL_308: + yy_32 = 2; + if (dst >= gpBufEnd) { + tile_42_45 = (unsigned int)(dst - gpBufEnd + 1023) >> 8; + if (tile_42_45 > 42) + return; + world_tbl = WorldTbl3x16[tile_42_45]; + src += WorldTbl17_2[world_tbl >> 2]; + dst -= 192 * world_tbl; + world_tbl >>= 1; + yy_32 = world_tbl + 2; + WorldBoolFlag += world_tbl >> 1; + } + do { + dst += yy_32; + y_minus = 32 - yy_32; WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; - if ( WorldBoolFlag ) - { - for ( n_draw_shift = x_minus >> 2; n_draw_shift; --n_draw_shift ) - { - dst[1] = src[1]; - dst[3] = src[3]; - src += 4; - dst += 4; - } - if ( (32 - (_BYTE)xx_32) & 2 ) - { - dst[1] = src[1]; + if (WorldBoolFlag) { + n_draw_shift = y_minus >> 2; + if (y_minus & 2) { + dst[1] = src[3]; src += 4; dst += 2; } - } - else - { - for ( n_draw_shift = x_minus >> 2; n_draw_shift; --n_draw_shift ) - { - dst[0] = src[0]; - dst[2] = src[2]; - src += 4; - dst += 4; + if (n_draw_shift) { + do { + dst[1] = src[1]; + dst[3] = src[3]; + src += 4; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); } - if ( (32 - (_BYTE)xx_32) & 2 ) - { - dst[0] = src[0]; + } else { + n_draw_shift = y_minus >> 2; + if (y_minus & 2) { + dst[0] = src[2]; src += 4; dst += 2; + --n_draw_shift; /// BUGFIX: delete this line + } + if (n_draw_shift) { + do { + dst[0] = src[0]; + dst[2] = src[2]; + src += 4; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); } } - dst = &dst[xx_32 - 800]; - xx_32 -= 2; + dst -= 800; + yy_32 += 2; + } while (yy_32 != 32); + return; + } + world_tbl = WorldTbl3x16[tile_42_45]; + src += WorldTbl17_1[world_tbl >> 2]; + dst -= 192 * world_tbl; + world_tbl >>= 1; + xx_32 = 30 - world_tbl; + WorldBoolFlag += world_tbl >> 1; + } + do { + dst += xx_32; + x_minus = 32 - xx_32; + WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; + if (WorldBoolFlag) { + n_draw_shift = x_minus >> 2; + if (x_minus & 2) { + dst[1] = src[3]; + src += 4; + dst += 2; + } + if (n_draw_shift) { + do { + dst[1] = src[1]; + dst[3] = src[3]; + src += 4; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + } else { + n_draw_shift = x_minus >> 2; + if (x_minus & 2) { + dst[0] = src[2]; + src += 4; + dst += 2; + } + if (n_draw_shift) { + do { + dst[0] = src[0]; + dst[2] = src[2]; + src += 4; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); } - while ( xx_32 >= 0 ); - goto LABEL_336; } - dst = pbDst - 12288; - src += 288; -LABEL_336: - yy_32 = 2; - if ( dst >= gpBufEnd ) - { - tile_42_45 = (unsigned int)(dst - gpBufEnd + 1023) >> 8; - if ( tile_42_45 > 42 ) - return; - world_tbl = WorldTbl3x16[tile_42_45]; - src += WorldTbl17_2[world_tbl >> 2]; - dst -= 192 * world_tbl; - world_tbl >>= 1; - yy_32 = world_tbl + 2; - WorldBoolFlag += world_tbl >> 1; - } - do - { - y_minus = 32 - yy_32; + dst -= 800; + xx_32 -= 2; + } while (xx_32 >= 0); + goto LABEL_308; + case 11: // lower (top transparent), without lighting + WorldBoolFlag = 0; + xx_32 = 30; + if (pbDst < gpBufEnd) + goto LABEL_326; + tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; + if (tile_42_45 <= 45) { + world_tbl = WorldTbl3x16[tile_42_45]; + src += WorldTbl17_1[world_tbl >> 2]; + dst -= 192 * world_tbl; + world_tbl >>= 1; + xx_32 = 30 - world_tbl; + WorldBoolFlag += world_tbl >> 1; + do { + LABEL_326: + x_minus = 32 - xx_32; WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; - if ( WorldBoolFlag ) - { - for ( n_draw_shift = y_minus >> 2; n_draw_shift; --n_draw_shift ) - { + if (WorldBoolFlag) { + for (n_draw_shift = x_minus >> 2; n_draw_shift; --n_draw_shift) { dst[1] = src[1]; dst[3] = src[3]; src += 4; dst += 4; } - if ( (32 - (_BYTE)yy_32) & 2 ) - { + if ((32 - (_BYTE)xx_32) & 2) { dst[1] = src[1]; src += 4; dst += 2; } - } - else - { - for ( n_draw_shift = y_minus >> 2; n_draw_shift; --n_draw_shift ) - { + } else { + for (n_draw_shift = x_minus >> 2; n_draw_shift; --n_draw_shift) { dst[0] = src[0]; dst[2] = src[2]; src += 4; dst += 4; } - if ( (32 - (_BYTE)yy_32) & 2 ) - { - dst[0] = src[0]; - src += 4; - dst += 2; - } - } - dst = &dst[yy_32 - 800]; - yy_32 += 2; - } - while ( yy_32 != 32 ); - break; - case 12: // lower (top transparent), without lighting - WorldBoolFlag = 0; - xx_32 = 30; - if ( pbDst >= gpBufEnd ) - { - tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; - if ( tile_42_45 > 45 ) - { - dst = pbDst - 12288; - src += 288; -LABEL_364: - i = 8; - do - { - if ( dst < gpBufEnd ) - { - j = 8; - do - { - dst[1] = src[1]; - dst[3] = src[3]; - src += 4; - dst += 4; - --j; - } - while ( j ); - } - else - { - src += 32; - dst += 32; - } - dst -= 800; - if ( dst < gpBufEnd ) - { - j = 8; - do - { - dst[0] = src[0]; - dst[2] = src[2]; - src += 4; - dst += 4; - --j; - } - while ( j ); - } - else - { - src += 32; - dst += 32; - } - dst -= 800; - --i; - } - while ( i ); - return; - } - world_tbl = WorldTbl3x16[tile_42_45]; - src += WorldTbl17_1[world_tbl >> 2]; - dst -= 192 * world_tbl; - world_tbl >>= 1; - xx_32 = 30 - world_tbl; - WorldBoolFlag += world_tbl >> 1; - } - do - { - dst += xx_32; - x_minus = 32 - xx_32; - WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; - if ( WorldBoolFlag ) - { - n_draw_shift = x_minus >> 2; - if ( x_minus & 2 ) - { - dst[1] = src[3]; - src += 4; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - dst[1] = src[1]; - dst[3] = src[3]; - src += 4; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - } - else - { - n_draw_shift = x_minus >> 2; - if ( x_minus & 2 ) - { - dst[0] = src[2]; - src += 4; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - dst[0] = src[0]; - dst[2] = src[2]; - src += 4; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - } - dst -= 800; - xx_32 -= 2; - } - while ( xx_32 >= 0 ); - goto LABEL_364; - default: // lower (top transparent), without lighting - WorldBoolFlag = 0; - xx_32 = 30; - if ( pbDst >= gpBufEnd ) - { - tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; - if ( tile_42_45 > 45 ) - { - dst = pbDst - 12288; - src += 288; -LABEL_389: - i = 8; - do - { - if ( dst < gpBufEnd ) - { - j = 8; - do - { - dst[1] = src[1]; - dst[3] = src[3]; - src += 4; - dst += 4; - --j; - } - while ( j ); - } - else - { - src += 32; - dst += 32; - } - dst -= 800; - if ( dst < gpBufEnd ) - { - j = 8; - do - { - dst[0] = src[0]; - dst[2] = src[2]; - src += 4; - dst += 4; - --j; - } - while ( j ); - } - else - { - src += 32; - dst += 32; - } - dst -= 800; - --i; - } - while ( i ); - return; - } - world_tbl = WorldTbl3x16[tile_42_45]; - src += WorldTbl17_1[world_tbl >> 2]; - dst -= 192 * world_tbl; - world_tbl >>= 1; - xx_32 = 30 - world_tbl; - WorldBoolFlag += world_tbl >> 1; - } - do - { - x_minus = 32 - xx_32; - WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; - if ( WorldBoolFlag ) - { - for ( n_draw_shift = x_minus >> 2; n_draw_shift; --n_draw_shift ) - { - dst[1] = src[1]; - dst[3] = src[3]; - src += 4; - dst += 4; - } - if ( (32 - (_BYTE)xx_32) & 2 ) - { - dst[1] = src[1]; - src += 4; - dst += 2; - } - } - else - { - for ( n_draw_shift = x_minus >> 2; n_draw_shift; --n_draw_shift ) - { - dst[0] = src[0]; - dst[2] = src[2]; - src += 4; - dst += 4; - } - if ( (32 - (_BYTE)xx_32) & 2 ) - { + if ((32 - (_BYTE)xx_32) & 2) { dst[0] = src[0]; src += 4; dst += 2; @@ -4482,1045 +3370,1055 @@ LABEL_389: } dst = &dst[xx_32 - 800]; xx_32 -= 2; + } while (xx_32 >= 0); + goto LABEL_336; + } + dst = pbDst - 12288; + src += 288; + LABEL_336: + yy_32 = 2; + if (dst >= gpBufEnd) { + tile_42_45 = (unsigned int)(dst - gpBufEnd + 1023) >> 8; + if (tile_42_45 > 42) + return; + world_tbl = WorldTbl3x16[tile_42_45]; + src += WorldTbl17_2[world_tbl >> 2]; + dst -= 192 * world_tbl; + world_tbl >>= 1; + yy_32 = world_tbl + 2; + WorldBoolFlag += world_tbl >> 1; + } + do { + y_minus = 32 - yy_32; + WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; + if (WorldBoolFlag) { + for (n_draw_shift = y_minus >> 2; n_draw_shift; --n_draw_shift) { + dst[1] = src[1]; + dst[3] = src[3]; + src += 4; + dst += 4; + } + if ((32 - (_BYTE)yy_32) & 2) { + dst[1] = src[1]; + src += 4; + dst += 2; + } + } else { + for (n_draw_shift = y_minus >> 2; n_draw_shift; --n_draw_shift) { + dst[0] = src[0]; + dst[2] = src[2]; + src += 4; + dst += 4; + } + if ((32 - (_BYTE)yy_32) & 2) { + dst[0] = src[0]; + src += 4; + dst += 2; + } } - while ( xx_32 >= 0 ); - goto LABEL_389; + dst = &dst[yy_32 - 800]; + yy_32 += 2; + } while (yy_32 != 32); + break; + case 12: // lower (top transparent), without lighting + WorldBoolFlag = 0; + xx_32 = 30; + if (pbDst >= gpBufEnd) { + tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; + if (tile_42_45 > 45) { + dst = pbDst - 12288; + src += 288; + LABEL_364: + i = 8; + do { + if (dst < gpBufEnd) { + j = 8; + do { + dst[1] = src[1]; + dst[3] = src[3]; + src += 4; + dst += 4; + --j; + } while (j); + } else { + src += 32; + dst += 32; + } + dst -= 800; + if (dst < gpBufEnd) { + j = 8; + do { + dst[0] = src[0]; + dst[2] = src[2]; + src += 4; + dst += 4; + --j; + } while (j); + } else { + src += 32; + dst += 32; + } + dst -= 800; + --i; + } while (i); + return; + } + world_tbl = WorldTbl3x16[tile_42_45]; + src += WorldTbl17_1[world_tbl >> 2]; + dst -= 192 * world_tbl; + world_tbl >>= 1; + xx_32 = 30 - world_tbl; + WorldBoolFlag += world_tbl >> 1; + } + do { + dst += xx_32; + x_minus = 32 - xx_32; + WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; + if (WorldBoolFlag) { + n_draw_shift = x_minus >> 2; + if (x_minus & 2) { + dst[1] = src[3]; + src += 4; + dst += 2; + } + if (n_draw_shift) { + do { + dst[1] = src[1]; + dst[3] = src[3]; + src += 4; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + } else { + n_draw_shift = x_minus >> 2; + if (x_minus & 2) { + dst[0] = src[2]; + src += 4; + dst += 2; + } + if (n_draw_shift) { + do { + dst[0] = src[0]; + dst[2] = src[2]; + src += 4; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + } + dst -= 800; + xx_32 -= 2; + } while (xx_32 >= 0); + goto LABEL_364; + default: // lower (top transparent), without lighting + WorldBoolFlag = 0; + xx_32 = 30; + if (pbDst >= gpBufEnd) { + tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; + if (tile_42_45 > 45) { + dst = pbDst - 12288; + src += 288; + LABEL_389: + i = 8; + do { + if (dst < gpBufEnd) { + j = 8; + do { + dst[1] = src[1]; + dst[3] = src[3]; + src += 4; + dst += 4; + --j; + } while (j); + } else { + src += 32; + dst += 32; + } + dst -= 800; + if (dst < gpBufEnd) { + j = 8; + do { + dst[0] = src[0]; + dst[2] = src[2]; + src += 4; + dst += 4; + --j; + } while (j); + } else { + src += 32; + dst += 32; + } + dst -= 800; + --i; + } while (i); + return; + } + world_tbl = WorldTbl3x16[tile_42_45]; + src += WorldTbl17_1[world_tbl >> 2]; + dst -= 192 * world_tbl; + world_tbl >>= 1; + xx_32 = 30 - world_tbl; + WorldBoolFlag += world_tbl >> 1; + } + do { + x_minus = 32 - xx_32; + WorldBoolFlag = ((_BYTE)WorldBoolFlag + 1) & 1; + if (WorldBoolFlag) { + for (n_draw_shift = x_minus >> 2; n_draw_shift; --n_draw_shift) { + dst[1] = src[1]; + dst[3] = src[3]; + src += 4; + dst += 4; + } + if ((32 - (_BYTE)xx_32) & 2) { + dst[1] = src[1]; + src += 4; + dst += 2; + } + } else { + for (n_draw_shift = x_minus >> 2; n_draw_shift; --n_draw_shift) { + dst[0] = src[0]; + dst[2] = src[2]; + src += 4; + dst += 4; + } + if ((32 - (_BYTE)xx_32) & 2) { + dst[0] = src[0]; + src += 4; + dst += 2; + } + } + dst = &dst[xx_32 - 800]; + xx_32 -= 2; + } while (xx_32 >= 0); + goto LABEL_389; } } void __fastcall drawBottomArchesLowerScreen(unsigned char *pbDst, unsigned int *pMask) { - unsigned char *dst; // edi MAPDST - short cel_type_16; // ax MAPDST - unsigned char *src; // esi MAPDST - int and80_i; // ecx MAPDST - signed int tile_42_45; // eax MAPDST - unsigned int world_tbl; // ecx MAPDST - int xx_32; // ecx MAPDST - int yy_32; // edx MAPDST - int width; // eax MAPDST - unsigned int left_shift; // edx MAPDST - signed int i; // edx MAPDST + unsigned char *dst; // edi MAPDST + short cel_type_16; // ax MAPDST + unsigned char *src; // esi MAPDST + int and80_i; // ecx MAPDST + signed int tile_42_45; // eax MAPDST + unsigned int world_tbl; // ecx MAPDST + int xx_32; // ecx MAPDST + int yy_32; // edx MAPDST + int width; // eax MAPDST + unsigned int left_shift; // edx MAPDST + signed int i; // edx MAPDST unsigned int n_draw_shift; // ecx MAPDST unsigned char *tbl; gpCelFrame = (unsigned char *)speed_cel_frame_num_from_light_index_frame_num; dst = pbDst; gpDrawMask = pMask; - if ( (_BYTE)light_table_index ) - { - if ( (_BYTE)light_table_index == lightmax ) - { - if ( level_cel_block & 0x8000 ) + if ((_BYTE)light_table_index) { + if ((_BYTE)light_table_index == lightmax) { + if (level_cel_block & 0x8000) level_cel_block = *(_DWORD *)&gpCelFrame[64 * (level_cel_block & 0xFFF)] - + (unsigned short)(level_cel_block & 0xF000); + + (unsigned short)(level_cel_block & 0xF000); src = (unsigned char *)pDungeonCels + *((_DWORD *)pDungeonCels + (level_cel_block & 0xFFF)); cel_type_16 = (level_cel_block >> 12) & 7; - switch ( cel_type_16 ) - { - case 0: // lower (bottom transparent), black + switch (cel_type_16) { + case 0: // lower (bottom transparent), black + yy_32 = 32; + do { + if (dst < gpBufEnd) { + left_shift = *gpDrawMask; + i = 32; + do { + if (left_shift & 0x80000000) + dst[0] = 0; + left_shift *= 2; + ++dst; + --i; + } while (i); + } else { + src += 32; + dst += 32; + } + dst -= 800; + --gpDrawMask; + --yy_32; + } while (yy_32); + break; + case 1: // lower (bottom transparent), black + xx_32 = 32; + do { + gdwCurrentMask = *gpDrawMask; yy_32 = 32; - do - { - if ( dst < gpBufEnd ) - { - left_shift = *gpDrawMask; - i = 32; - do - { - if ( left_shift & 0x80000000 ) - dst[0] = 0; - left_shift *= 2; - ++dst; - --i; - } - while ( i ); - } - else - { - src += 32; - dst += 32; - } - dst -= 800; - --gpDrawMask; - --yy_32; - } - while ( yy_32 ); - break; - case 1: // lower (bottom transparent), black - xx_32 = 32; - do - { - gdwCurrentMask = *gpDrawMask; - yy_32 = 32; - do - { - while ( 1 ) - { - width = (unsigned char)*src++; - if ( (width & 0x80u) != 0 ) - break; - yy_32 -= width; - if ( dst < gpBufEnd ) - { - and80_i = width; - src += width; - left_shift = gdwCurrentMask; - do - { - if ( left_shift & 0x80000000 ) - dst[0] = 0; - left_shift *= 2; - ++dst; - --and80_i; - } - while ( and80_i ); - gdwCurrentMask = left_shift; - } - else - { - src += width; - dst += width; - } - if ( !yy_32 ) - goto LABEL_252; - } - _LOBYTE(width) = -(char)width; - dst += width; - if ( width & 0x1F ) - gdwCurrentMask <<= width & 0x1F; + do { + while (1) { + width = (unsigned char)*src++; + if ((width & 0x80u) != 0) + break; yy_32 -= width; - } - while ( yy_32 ); -LABEL_252: - dst -= 800; - --gpDrawMask; - --xx_32; - } - while ( xx_32 ); - break; - case 2: // lower (bottom transparent), black - for ( i = 30; ; i -= 2 ) - { - if ( dst < gpBufEnd ) - { - dst += i; - n_draw_shift = (unsigned int)(32 - i) >> 2; - if ( (32 - i) & 2 ) - { - *(_WORD *)dst = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - *(_DWORD *)dst = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); + if (dst < gpBufEnd) { + and80_i = width; + src += width; + left_shift = gdwCurrentMask; + do { + if (left_shift & 0x80000000) + dst[0] = 0; + left_shift *= 2; + ++dst; + --and80_i; + } while (and80_i); + gdwCurrentMask = left_shift; + } else { + src += width; + dst += width; } + if (!yy_32) + goto LABEL_252; } - else - { - src = &src[32 - i]; - dst += 32; - } - dst -= 800; - if ( !i ) - break; - } - i = 2; - do - { - if ( dst < gpBufEnd ) - { - dst += i; - n_draw_shift = (unsigned int)(32 - i) >> 2; - if ( (32 - i) & 2 ) - { - *(_WORD *)dst = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - *(_DWORD *)dst = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - } - else - { - src = &src[32 - i]; - dst += 32; - } - dst -= 800; - i += 2; - } - while ( i != 32 ); - break; - case 3: // lower (bottom transparent), black - for ( i = 30; ; i -= 2 ) - { - if ( dst < gpBufEnd ) - { - n_draw_shift = (unsigned int)(32 - i) >> 2; - if ( (32 - i) & 2 ) - { - *(_WORD *)dst = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - *(_DWORD *)dst = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - } - else - { - src = &src[32 - i]; - dst = &dst[32 - i]; - } - dst -= 800; - if ( !i ) - break; + _LOBYTE(width) = -(char)width; + dst += width; + if (width & 0x1F) + gdwCurrentMask <<= width & 0x1F; + yy_32 -= width; + } while (yy_32); + LABEL_252: + dst -= 800; + --gpDrawMask; + --xx_32; + } while (xx_32); + break; + case 2: // lower (bottom transparent), black + for (i = 30;; i -= 2) { + if (dst < gpBufEnd) { dst += i; + n_draw_shift = (unsigned int)(32 - i) >> 2; + if ((32 - i) & 2) { + *(_WORD *)dst = 0; + dst += 2; + } + if (n_draw_shift) { + do { + *(_DWORD *)dst = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + } else { + src = &src[32 - i]; + dst += 32; } - i = 2; - do - { - if ( dst < gpBufEnd ) - { - n_draw_shift = (unsigned int)(32 - i) >> 2; - if ( (32 - i) & 2 ) - { - *(_WORD *)dst = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - *(_DWORD *)dst = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - } - else - { - src = &src[32 - i]; - dst = &dst[32 - i]; - } - dst = &dst[i - 800]; - i += 2; - } - while ( i != 32 ); - break; - case 4: // lower (bottom transparent), black - for ( i = 30; ; i -= 2 ) - { - if ( dst < gpBufEnd ) - { - dst += i; - n_draw_shift = (unsigned int)(32 - i) >> 2; - if ( (32 - i) & 2 ) - { - *(_WORD *)dst = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - *(_DWORD *)dst = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - } - else - { - src = &src[32 - i]; - dst += 32; - } - dst -= 800; - if ( !i ) - break; - } - gpDrawMask -= 16; - yy_32 = 16; - do - { - if ( dst < gpBufEnd ) - { - left_shift = *gpDrawMask; - i = 32; - do - { - if ( left_shift & 0x80000000 ) - dst[0] = 0; - left_shift *= 2; - ++dst; - --i; - } - while ( i ); - } - else - { - src += 32; - dst += 32; - } - dst -= 800; - --gpDrawMask; - --yy_32; - } - while ( yy_32 ); - break; - default: // lower (bottom transparent), black - for ( i = 30; ; i -= 2 ) - { - if ( dst < gpBufEnd ) - { - n_draw_shift = (unsigned int)(32 - i) >> 2; - if ( (32 - i) & 2 ) - { - *(_WORD *)dst = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - *(_DWORD *)dst = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - } - else - { - src = &src[32 - i]; - dst = &dst[32 - i]; - } - dst -= 800; - if ( !i ) - break; + dst -= 800; + if (!i) + break; + } + i = 2; + do { + if (dst < gpBufEnd) { dst += i; - } - gpDrawMask -= 16; - yy_32 = 16; - do - { - if ( dst < gpBufEnd ) - { - left_shift = *gpDrawMask; - i = 32; - do - { - if ( left_shift & 0x80000000 ) - dst[0] = 0; - left_shift *= 2; - ++dst; - --i; - } - while ( i ); + n_draw_shift = (unsigned int)(32 - i) >> 2; + if ((32 - i) & 2) { + *(_WORD *)dst = 0; + dst += 2; } - else - { - src += 32; - dst += 32; + if (n_draw_shift) { + do { + *(_DWORD *)dst = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); } - dst -= 800; - --gpDrawMask; - --yy_32; + } else { + src = &src[32 - i]; + dst += 32; } - while ( yy_32 ); - break; + dst -= 800; + i += 2; + } while (i != 32); + break; + case 3: // lower (bottom transparent), black + for (i = 30;; i -= 2) { + if (dst < gpBufEnd) { + n_draw_shift = (unsigned int)(32 - i) >> 2; + if ((32 - i) & 2) { + *(_WORD *)dst = 0; + dst += 2; + } + if (n_draw_shift) { + do { + *(_DWORD *)dst = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + } else { + src = &src[32 - i]; + dst = &dst[32 - i]; + } + dst -= 800; + if (!i) + break; + dst += i; + } + i = 2; + do { + if (dst < gpBufEnd) { + n_draw_shift = (unsigned int)(32 - i) >> 2; + if ((32 - i) & 2) { + *(_WORD *)dst = 0; + dst += 2; + } + if (n_draw_shift) { + do { + *(_DWORD *)dst = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + } else { + src = &src[32 - i]; + dst = &dst[32 - i]; + } + dst = &dst[i - 800]; + i += 2; + } while (i != 32); + break; + case 4: // lower (bottom transparent), black + for (i = 30;; i -= 2) { + if (dst < gpBufEnd) { + dst += i; + n_draw_shift = (unsigned int)(32 - i) >> 2; + if ((32 - i) & 2) { + *(_WORD *)dst = 0; + dst += 2; + } + if (n_draw_shift) { + do { + *(_DWORD *)dst = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + } else { + src = &src[32 - i]; + dst += 32; + } + dst -= 800; + if (!i) + break; + } + gpDrawMask -= 16; + yy_32 = 16; + do { + if (dst < gpBufEnd) { + left_shift = *gpDrawMask; + i = 32; + do { + if (left_shift & 0x80000000) + dst[0] = 0; + left_shift *= 2; + ++dst; + --i; + } while (i); + } else { + src += 32; + dst += 32; + } + dst -= 800; + --gpDrawMask; + --yy_32; + } while (yy_32); + break; + default: // lower (bottom transparent), black + for (i = 30;; i -= 2) { + if (dst < gpBufEnd) { + n_draw_shift = (unsigned int)(32 - i) >> 2; + if ((32 - i) & 2) { + *(_WORD *)dst = 0; + dst += 2; + } + if (n_draw_shift) { + do { + *(_DWORD *)dst = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + } else { + src = &src[32 - i]; + dst = &dst[32 - i]; + } + dst -= 800; + if (!i) + break; + dst += i; + } + gpDrawMask -= 16; + yy_32 = 16; + do { + if (dst < gpBufEnd) { + left_shift = *gpDrawMask; + i = 32; + do { + if (left_shift & 0x80000000) + dst[0] = 0; + left_shift *= 2; + ++dst; + --i; + } while (i); + } else { + src += 32; + dst += 32; + } + dst -= 800; + --gpDrawMask; + --yy_32; + } while (yy_32); + break; } return; } - if ( !(level_cel_block & 0x8000) ) - { + if (!(level_cel_block & 0x8000)) { src = (unsigned char *)pDungeonCels + *((_DWORD *)pDungeonCels + (level_cel_block & 0xFFF)); tbl = (unsigned char *)&pLightTbl[256 * light_table_index]; cel_type_16 = (unsigned char)(level_cel_block >> 12); - switch ( cel_type_16 ) - { - case 0: // lower (bottom transparent), with lighting + switch (cel_type_16) { + case 0: // lower (bottom transparent), with lighting + yy_32 = 32; + do { + if (dst < gpBufEnd) { + asm_trans_light_mask(32, tbl, dst, src, *gpDrawMask); + } else { + src += 32; + dst += 32; + } + dst -= 800; + --gpDrawMask; + --yy_32; + } while (yy_32); + break; + case 1: // lower (bottom transparent), with lighting + xx_32 = 32; + do { + gdwCurrentMask = *gpDrawMask; yy_32 = 32; - do - { - if ( dst < gpBufEnd ) - { - asm_trans_light_mask(32, tbl, dst, src, *gpDrawMask); - } - else - { - src += 32; - dst += 32; - } - dst -= 800; - --gpDrawMask; - --yy_32; - } - while ( yy_32 ); - break; - case 1: // lower (bottom transparent), with lighting - xx_32 = 32; - do - { - gdwCurrentMask = *gpDrawMask; - yy_32 = 32; - do - { - while ( 1 ) - { - width = (unsigned char)*src++; - if ( (width & 0x80u) != 0 ) - break; - yy_32 -= width; - if ( dst < gpBufEnd ) - { - gdwCurrentMask = asm_trans_light_mask(width, tbl, dst, src, gdwCurrentMask); - } - else - { - src += width; - dst += width; - } - if ( !yy_32 ) - goto LABEL_52; - } - _LOBYTE(width) = -(char)width; - dst += width; - if ( width & 0x1F ) - gdwCurrentMask <<= width & 0x1F; + do { + while (1) { + width = (unsigned char)*src++; + if ((width & 0x80u) != 0) + break; yy_32 -= width; + if (dst < gpBufEnd) { + gdwCurrentMask = asm_trans_light_mask(width, tbl, dst, src, gdwCurrentMask); + } else { + src += width; + dst += width; + } + if (!yy_32) + goto LABEL_52; } - while ( yy_32 ); -LABEL_52: - dst -= 800; - --gpDrawMask; - --xx_32; - } - while ( xx_32 ); - break; - case 2: // lower (bottom transparent), with lighting - xx_32 = 30; - if ( pbDst >= gpBufEnd ) - { - tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; - if ( tile_42_45 > 45 ) - { - dst = pbDst - 12288; - src += 288; -LABEL_62: - yy_32 = 2; - if ( dst >= gpBufEnd ) - { - tile_42_45 = (unsigned int)(dst - gpBufEnd + 1023) >> 8; - if ( tile_42_45 > 42 ) - return; - world_tbl = WorldTbl3x16[tile_42_45]; - src += WorldTbl17_2[world_tbl >> 2]; - dst -= 192 * world_tbl; - yy_32 = (world_tbl >> 1) + 2; - } - do - { - dst += yy_32; - src += (32 - (_BYTE)yy_32) & 2; - asm_cel_light_edge(32 - yy_32, tbl, dst, src); - yy_32 += 2; - dst -= 800; - } - while ( yy_32 != 32 ); - return; + _LOBYTE(width) = -(char)width; + dst += width; + if (width & 0x1F) + gdwCurrentMask <<= width & 0x1F; + yy_32 -= width; + } while (yy_32); + LABEL_52: + dst -= 800; + --gpDrawMask; + --xx_32; + } while (xx_32); + break; + case 2: // lower (bottom transparent), with lighting + xx_32 = 30; + if (pbDst >= gpBufEnd) { + tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; + if (tile_42_45 > 45) { + dst = pbDst - 12288; + src += 288; + LABEL_62: + yy_32 = 2; + if (dst >= gpBufEnd) { + tile_42_45 = (unsigned int)(dst - gpBufEnd + 1023) >> 8; + if (tile_42_45 > 42) + return; + world_tbl = WorldTbl3x16[tile_42_45]; + src += WorldTbl17_2[world_tbl >> 2]; + dst -= 192 * world_tbl; + yy_32 = (world_tbl >> 1) + 2; } - world_tbl = WorldTbl3x16[tile_42_45]; - src += WorldTbl17_1[world_tbl >> 2]; - dst -= 192 * world_tbl; - xx_32 = 30 - (world_tbl >> 1); + do { + dst += yy_32; + src += (32 - (_BYTE)yy_32) & 2; + asm_cel_light_edge(32 - yy_32, tbl, dst, src); + yy_32 += 2; + dst -= 800; + } while (yy_32 != 32); + return; } - do - { - dst += xx_32; - src += (32 - (_BYTE)xx_32) & 2; - asm_cel_light_edge(32 - xx_32, tbl, dst, src); - dst -= 800; - xx_32 -= 2; - } - while ( xx_32 >= 0 ); - goto LABEL_62; - case 3: // lower (bottom transparent), with lighting - xx_32 = 30; - if ( pbDst >= gpBufEnd ) - { - tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; - if ( tile_42_45 > 45 ) - { - dst = pbDst - 12288; - src += 288; -LABEL_80: - yy_32 = 2; - if ( dst >= gpBufEnd ) - { - tile_42_45 = (unsigned int)(dst - gpBufEnd + 1023) >> 8; - if ( tile_42_45 > 42 ) - return; - world_tbl = WorldTbl3x16[tile_42_45]; - src += WorldTbl17_2[world_tbl >> 2]; - dst -= 192 * world_tbl; - yy_32 = (world_tbl >> 1) + 2; - } - do - { - asm_cel_light_edge(32 - yy_32, tbl, dst, src); - /// BUGFIX: uncomment this line - // src += (unsigned char)src & 2; - dst = &dst[yy_32 - 800]; - yy_32 += 2; - } - while ( yy_32 != 32 ); - return; + world_tbl = WorldTbl3x16[tile_42_45]; + src += WorldTbl17_1[world_tbl >> 2]; + dst -= 192 * world_tbl; + xx_32 = 30 - (world_tbl >> 1); + } + do { + dst += xx_32; + src += (32 - (_BYTE)xx_32) & 2; + asm_cel_light_edge(32 - xx_32, tbl, dst, src); + dst -= 800; + xx_32 -= 2; + } while (xx_32 >= 0); + goto LABEL_62; + case 3: // lower (bottom transparent), with lighting + xx_32 = 30; + if (pbDst >= gpBufEnd) { + tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; + if (tile_42_45 > 45) { + dst = pbDst - 12288; + src += 288; + LABEL_80: + yy_32 = 2; + if (dst >= gpBufEnd) { + tile_42_45 = (unsigned int)(dst - gpBufEnd + 1023) >> 8; + if (tile_42_45 > 42) + return; + world_tbl = WorldTbl3x16[tile_42_45]; + src += WorldTbl17_2[world_tbl >> 2]; + dst -= 192 * world_tbl; + yy_32 = (world_tbl >> 1) + 2; } - world_tbl = WorldTbl3x16[tile_42_45]; - src += WorldTbl17_1[world_tbl >> 2]; - dst -= 192 * world_tbl; - xx_32 = 30 - (world_tbl >> 1); + do { + asm_cel_light_edge(32 - yy_32, tbl, dst, src); + /// BUGFIX: uncomment this line + // src += (unsigned char)src & 2; + dst = &dst[yy_32 - 800]; + yy_32 += 2; + } while (yy_32 != 32); + return; } - do - { - asm_cel_light_edge(32 - xx_32, tbl, dst, src); - src += (unsigned char)src & 2; - dst = &dst[xx_32 - 800]; - xx_32 -= 2; - } - while ( xx_32 >= 0 ); - goto LABEL_80; - case 4: // lower (bottom transparent), with lighting - xx_32 = 30; - if ( pbDst >= gpBufEnd ) - { - tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; - if ( tile_42_45 > 45 ) - { - dst = pbDst - 12288; - src += 288; -LABEL_98: - gpDrawMask -= 16; - yy_32 = 16; - do - { - if ( dst < gpBufEnd ) - { - asm_trans_light_mask(32, tbl, dst, src, *gpDrawMask); - } - else - { - src += 32; - dst += 32; - } - dst -= 800; - --gpDrawMask; - --yy_32; + world_tbl = WorldTbl3x16[tile_42_45]; + src += WorldTbl17_1[world_tbl >> 2]; + dst -= 192 * world_tbl; + xx_32 = 30 - (world_tbl >> 1); + } + do { + asm_cel_light_edge(32 - xx_32, tbl, dst, src); + src += (unsigned char)src & 2; + dst = &dst[xx_32 - 800]; + xx_32 -= 2; + } while (xx_32 >= 0); + goto LABEL_80; + case 4: // lower (bottom transparent), with lighting + xx_32 = 30; + if (pbDst >= gpBufEnd) { + tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; + if (tile_42_45 > 45) { + dst = pbDst - 12288; + src += 288; + LABEL_98: + gpDrawMask -= 16; + yy_32 = 16; + do { + if (dst < gpBufEnd) { + asm_trans_light_mask(32, tbl, dst, src, *gpDrawMask); + } else { + src += 32; + dst += 32; } - while ( yy_32 ); - return; - } - world_tbl = WorldTbl3x16[tile_42_45]; - src += WorldTbl17_1[world_tbl >> 2]; - dst -= 192 * world_tbl; - xx_32 = 30 - (world_tbl >> 1); + dst -= 800; + --gpDrawMask; + --yy_32; + } while (yy_32); + return; } - do - { - dst += xx_32; - src += (32 - (_BYTE)xx_32) & 2; - asm_cel_light_edge(32 - xx_32, tbl, dst, src); - dst -= 800; - xx_32 -= 2; - } - while ( xx_32 >= 0 ); - goto LABEL_98; - default: // lower (bottom transparent), with lighting - xx_32 = 30; - if ( pbDst >= gpBufEnd ) - { - tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; - if ( tile_42_45 > 45 ) - { - dst = pbDst - 12288; - src += 288; -LABEL_117: - gpDrawMask -= 16; - yy_32 = 16; - do - { - if ( dst < gpBufEnd ) - { - asm_trans_light_mask(32, tbl, dst, src, *gpDrawMask); - src += (unsigned char)src & 2; - } - else - { - src += 32; - dst += 32; - } - dst -= 800; - --gpDrawMask; - --yy_32; + world_tbl = WorldTbl3x16[tile_42_45]; + src += WorldTbl17_1[world_tbl >> 2]; + dst -= 192 * world_tbl; + xx_32 = 30 - (world_tbl >> 1); + } + do { + dst += xx_32; + src += (32 - (_BYTE)xx_32) & 2; + asm_cel_light_edge(32 - xx_32, tbl, dst, src); + dst -= 800; + xx_32 -= 2; + } while (xx_32 >= 0); + goto LABEL_98; + default: // lower (bottom transparent), with lighting + xx_32 = 30; + if (pbDst >= gpBufEnd) { + tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; + if (tile_42_45 > 45) { + dst = pbDst - 12288; + src += 288; + LABEL_117: + gpDrawMask -= 16; + yy_32 = 16; + do { + if (dst < gpBufEnd) { + asm_trans_light_mask(32, tbl, dst, src, *gpDrawMask); + src += (unsigned char)src & 2; + } else { + src += 32; + dst += 32; } - while ( yy_32 ); - return; - } - world_tbl = WorldTbl3x16[tile_42_45]; - src += WorldTbl17_1[world_tbl >> 2]; - dst -= 192 * world_tbl; - xx_32 = 30 - (world_tbl >> 1); + dst -= 800; + --gpDrawMask; + --yy_32; + } while (yy_32); + return; } - do - { - asm_cel_light_edge(32 - xx_32, tbl, dst, src); - src += (unsigned char)src & 2; - dst = &dst[xx_32 - 800]; - xx_32 -= 2; - } - while ( xx_32 >= 0 ); - goto LABEL_117; + world_tbl = WorldTbl3x16[tile_42_45]; + src += WorldTbl17_1[world_tbl >> 2]; + dst -= 192 * world_tbl; + xx_32 = 30 - (world_tbl >> 1); + } + do { + asm_cel_light_edge(32 - xx_32, tbl, dst, src); + src += (unsigned char)src & 2; + dst = &dst[xx_32 - 800]; + xx_32 -= 2; + } while (xx_32 >= 0); + goto LABEL_117; } return; } src = (unsigned char *)pSpeedCels - + *(_DWORD *)&gpCelFrame[4 * (light_table_index + 16 * (level_cel_block & 0xFFF))]; + + *(_DWORD *)&gpCelFrame[4 * (light_table_index + 16 * (level_cel_block & 0xFFF))]; cel_type_16 = (unsigned char)(level_cel_block >> 12); - } - else - { - if ( level_cel_block & 0x8000 ) + } else { + if (level_cel_block & 0x8000) level_cel_block = *(_DWORD *)&gpCelFrame[64 * (level_cel_block & 0xFFF)] - + (unsigned short)(level_cel_block & 0xF000); + + (unsigned short)(level_cel_block & 0xF000); src = (unsigned char *)pDungeonCels + *((_DWORD *)pDungeonCels + (level_cel_block & 0xFFF)); cel_type_16 = ((level_cel_block >> 12) & 7) + 8; } - switch ( cel_type_16 ) - { - case 8: // lower (bottom transparent), without lighting + switch (cel_type_16) { + case 8: // lower (bottom transparent), without lighting + yy_32 = 32; + do { + if (dst < gpBufEnd) { + left_shift = *gpDrawMask; + i = 32; + do { + if (left_shift & 0x80000000) + dst[0] = src[0]; + left_shift *= 2; + ++src; + ++dst; + --i; + } while (i); + } else { + src += 32; + dst += 32; + } + dst -= 800; + --gpDrawMask; + --yy_32; + } while (yy_32); + break; + case 9: // lower (bottom transparent), without lighting + xx_32 = 32; + do { + gdwCurrentMask = *gpDrawMask; yy_32 = 32; - do - { - if ( dst < gpBufEnd ) - { - left_shift = *gpDrawMask; - i = 32; - do - { - if ( left_shift & 0x80000000 ) - dst[0] = src[0]; - left_shift *= 2; - ++src; - ++dst; - --i; - } - while ( i ); - } - else - { - src += 32; - dst += 32; - } - dst -= 800; - --gpDrawMask; - --yy_32; - } - while ( yy_32 ); - break; - case 9: // lower (bottom transparent), without lighting - xx_32 = 32; - do - { - gdwCurrentMask = *gpDrawMask; - yy_32 = 32; - do - { - while ( 1 ) - { - width = (unsigned char)*src++; - if ( (width & 0x80u) != 0 ) - break; - yy_32 -= width; - if ( dst < gpBufEnd ) - { - and80_i = width; - left_shift = gdwCurrentMask; - do - { - if ( left_shift & 0x80000000 ) - dst[0] = src[0]; - left_shift *= 2; - ++src; - ++dst; - --and80_i; - } - while ( and80_i ); - gdwCurrentMask = left_shift; - } - else - { - src += width; - dst += width; - } - if ( !yy_32 ) - goto LABEL_152; - } - _LOBYTE(width) = -(char)width; - dst += width; - if ( width & 0x1F ) - gdwCurrentMask <<= width & 0x1F; + do { + while (1) { + width = (unsigned char)*src++; + if ((width & 0x80u) != 0) + break; yy_32 -= width; - } - while ( yy_32 ); -LABEL_152: - dst -= 800; - --gpDrawMask; - --xx_32; - } - while ( xx_32 ); - break; - case 10: // lower (bottom transparent), without lighting - xx_32 = 30; - if ( pbDst >= gpBufEnd ) - { - tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; - if ( tile_42_45 > 45 ) - { - dst = pbDst - 12288; - src += 288; -LABEL_162: - yy_32 = 2; - if ( dst >= gpBufEnd ) - { - tile_42_45 = (unsigned int)(dst - gpBufEnd + 1023) >> 8; - if ( tile_42_45 > 42 ) - return; - world_tbl = WorldTbl3x16[tile_42_45]; - src += WorldTbl17_2[world_tbl >> 2]; - dst -= 192 * world_tbl; - yy_32 = (world_tbl >> 1) + 2; + if (dst < gpBufEnd) { + and80_i = width; + left_shift = gdwCurrentMask; + do { + if (left_shift & 0x80000000) + dst[0] = src[0]; + left_shift *= 2; + ++src; + ++dst; + --and80_i; + } while (and80_i); + gdwCurrentMask = left_shift; + } else { + src += width; + dst += width; } - do - { - dst += yy_32; - n_draw_shift = (unsigned int)(32 - yy_32) >> 2; - if ( (32 - yy_32) & 2 ) - { - *(_WORD *)dst = *((_WORD *)src + 1); - src += 4; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - *(_DWORD *)dst = *(_DWORD *)src; - src += 4; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - dst -= 800; - yy_32 += 2; - } - while ( yy_32 != 32 ); - return; + if (!yy_32) + goto LABEL_152; } - world_tbl = WorldTbl3x16[tile_42_45]; - src += WorldTbl17_1[world_tbl >> 2]; - dst -= 192 * world_tbl; - xx_32 = 30 - (world_tbl >> 1); - } - do - { - dst += xx_32; - n_draw_shift = (unsigned int)(32 - xx_32) >> 2; - if ( (32 - xx_32) & 2 ) - { - *(_WORD *)dst = *((_WORD *)src + 1); - src += 4; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - *(_DWORD *)dst = *(_DWORD *)src; - src += 4; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - dst -= 800; - xx_32 -= 2; - } - while ( xx_32 >= 0 ); - goto LABEL_162; - case 11: // lower (bottom transparent), without lighting - xx_32 = 30; - if ( pbDst < gpBufEnd ) - goto LABEL_175; + _LOBYTE(width) = -(char)width; + dst += width; + if (width & 0x1F) + gdwCurrentMask <<= width & 0x1F; + yy_32 -= width; + } while (yy_32); + LABEL_152: + dst -= 800; + --gpDrawMask; + --xx_32; + } while (xx_32); + break; + case 10: // lower (bottom transparent), without lighting + xx_32 = 30; + if (pbDst >= gpBufEnd) { tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; - if ( tile_42_45 <= 45 ) - { - world_tbl = WorldTbl3x16[tile_42_45]; - src += WorldTbl17_1[world_tbl >> 2]; - dst -= 192 * world_tbl; - xx_32 = 30 - (world_tbl >> 1); - do - { -LABEL_175: - for ( n_draw_shift = (unsigned int)(32 - xx_32) >> 2; n_draw_shift; --n_draw_shift ) - { - *(_DWORD *)dst = *(_DWORD *)src; - src += 4; - dst += 4; - } - if ( (32 - (_BYTE)xx_32) & 2 ) - { - *(_WORD *)dst = *(_WORD *)src; + if (tile_42_45 > 45) { + dst = pbDst - 12288; + src += 288; + LABEL_162: + yy_32 = 2; + if (dst >= gpBufEnd) { + tile_42_45 = (unsigned int)(dst - gpBufEnd + 1023) >> 8; + if (tile_42_45 > 42) + return; + world_tbl = WorldTbl3x16[tile_42_45]; + src += WorldTbl17_2[world_tbl >> 2]; + dst -= 192 * world_tbl; + yy_32 = (world_tbl >> 1) + 2; + } + do { + dst += yy_32; + n_draw_shift = (unsigned int)(32 - yy_32) >> 2; + if ((32 - yy_32) & 2) { + *(_WORD *)dst = *((_WORD *)src + 1); src += 4; dst += 2; } - dst = &dst[xx_32 - 800]; - xx_32 -= 2; - } - while ( xx_32 >= 0 ); - goto LABEL_180; + if (n_draw_shift) { + do { + *(_DWORD *)dst = *(_DWORD *)src; + src += 4; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + dst -= 800; + yy_32 += 2; + } while (yy_32 != 32); + return; } - dst = pbDst - 12288; - src += 288; -LABEL_180: - yy_32 = 2; - if ( dst >= gpBufEnd ) - { - tile_42_45 = (unsigned int)(dst - gpBufEnd + 1023) >> 8; - if ( tile_42_45 > 42 ) - return; - world_tbl = WorldTbl3x16[tile_42_45]; - src += WorldTbl17_2[world_tbl >> 2]; - dst -= 192 * world_tbl; - yy_32 = (world_tbl >> 1) + 2; + world_tbl = WorldTbl3x16[tile_42_45]; + src += WorldTbl17_1[world_tbl >> 2]; + dst -= 192 * world_tbl; + xx_32 = 30 - (world_tbl >> 1); + } + do { + dst += xx_32; + n_draw_shift = (unsigned int)(32 - xx_32) >> 2; + if ((32 - xx_32) & 2) { + *(_WORD *)dst = *((_WORD *)src + 1); + src += 4; + dst += 2; } - do - { - for ( n_draw_shift = (unsigned int)(32 - yy_32) >> 2; n_draw_shift; --n_draw_shift ) - { + if (n_draw_shift) { + do { + *(_DWORD *)dst = *(_DWORD *)src; + src += 4; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + dst -= 800; + xx_32 -= 2; + } while (xx_32 >= 0); + goto LABEL_162; + case 11: // lower (bottom transparent), without lighting + xx_32 = 30; + if (pbDst < gpBufEnd) + goto LABEL_175; + tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; + if (tile_42_45 <= 45) { + world_tbl = WorldTbl3x16[tile_42_45]; + src += WorldTbl17_1[world_tbl >> 2]; + dst -= 192 * world_tbl; + xx_32 = 30 - (world_tbl >> 1); + do { + LABEL_175: + for (n_draw_shift = (unsigned int)(32 - xx_32) >> 2; n_draw_shift; --n_draw_shift) { *(_DWORD *)dst = *(_DWORD *)src; src += 4; dst += 4; } - if ( (32 - (_BYTE)yy_32) & 2 ) - { - *(_WORD *)dst = *(_WORD *)src; - src += 4; - dst += 2; - } - dst = &dst[yy_32 - 800]; - yy_32 += 2; - } - while ( yy_32 != 32 ); - break; - case 12: // lower (bottom transparent), without lighting - xx_32 = 30; - if ( pbDst >= gpBufEnd ) - { - tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; - if ( tile_42_45 > 45 ) - { - dst = pbDst - 12288; - src += 288; -LABEL_198: - gpDrawMask -= 16; - yy_32 = 16; - do - { - if ( dst < gpBufEnd ) - { - left_shift = *gpDrawMask; - i = 32; - do - { - if ( left_shift & 0x80000000 ) - dst[0] = src[0]; - left_shift *= 2; - ++src; - ++dst; - --i; - } - while ( i ); - } - else - { - src += 32; - dst += 32; - } - dst -= 800; - --gpDrawMask; - --yy_32; - } - while ( yy_32 ); - return; - } - world_tbl = WorldTbl3x16[tile_42_45]; - src += WorldTbl17_1[world_tbl >> 2]; - dst -= 192 * world_tbl; - xx_32 = 30 - (world_tbl >> 1); - } - do - { - dst += xx_32; - n_draw_shift = (unsigned int)(32 - xx_32) >> 2; - if ( (32 - xx_32) & 2 ) - { - *(_WORD *)dst = *((_WORD *)src + 1); - src += 4; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - *(_DWORD *)dst = *(_DWORD *)src; - src += 4; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - dst -= 800; - xx_32 -= 2; - } - while ( xx_32 >= 0 ); - goto LABEL_198; - default: // lower (bottom transparent), without lighting - xx_32 = 30; - if ( pbDst >= gpBufEnd ) - { - tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; - if ( tile_42_45 > 45 ) - { - dst = pbDst - 12288; - src += 288; -LABEL_217: - gpDrawMask -= 16; - yy_32 = 16; - do - { - if ( dst < gpBufEnd ) - { - left_shift = *gpDrawMask; - i = 32; - do - { - if ( left_shift & 0x80000000 ) - dst[0] = src[0]; - left_shift *= 2; - ++src; - ++dst; - --i; - } - while ( i ); - src += (unsigned char)src & 2; - } - else - { - src += 32; - dst += 32; - } - dst -= 800; - --gpDrawMask; - --yy_32; - } - while ( yy_32 ); - return; - } - world_tbl = WorldTbl3x16[tile_42_45]; - src += WorldTbl17_1[world_tbl >> 2]; - dst -= 192 * world_tbl; - xx_32 = 30 - (world_tbl >> 1); - } - do - { - for ( n_draw_shift = (unsigned int)(32 - xx_32) >> 2; n_draw_shift; --n_draw_shift ) - { - *(_DWORD *)dst = *(_DWORD *)src; - src += 4; - dst += 4; - } - if ( (32 - (_BYTE)xx_32) & 2 ) - { + if ((32 - (_BYTE)xx_32) & 2) { *(_WORD *)dst = *(_WORD *)src; src += 4; dst += 2; } dst = &dst[xx_32 - 800]; xx_32 -= 2; + } while (xx_32 >= 0); + goto LABEL_180; + } + dst = pbDst - 12288; + src += 288; + LABEL_180: + yy_32 = 2; + if (dst >= gpBufEnd) { + tile_42_45 = (unsigned int)(dst - gpBufEnd + 1023) >> 8; + if (tile_42_45 > 42) + return; + world_tbl = WorldTbl3x16[tile_42_45]; + src += WorldTbl17_2[world_tbl >> 2]; + dst -= 192 * world_tbl; + yy_32 = (world_tbl >> 1) + 2; + } + do { + for (n_draw_shift = (unsigned int)(32 - yy_32) >> 2; n_draw_shift; --n_draw_shift) { + *(_DWORD *)dst = *(_DWORD *)src; + src += 4; + dst += 4; } - while ( xx_32 >= 0 ); - goto LABEL_217; + if ((32 - (_BYTE)yy_32) & 2) { + *(_WORD *)dst = *(_WORD *)src; + src += 4; + dst += 2; + } + dst = &dst[yy_32 - 800]; + yy_32 += 2; + } while (yy_32 != 32); + break; + case 12: // lower (bottom transparent), without lighting + xx_32 = 30; + if (pbDst >= gpBufEnd) { + tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; + if (tile_42_45 > 45) { + dst = pbDst - 12288; + src += 288; + LABEL_198: + gpDrawMask -= 16; + yy_32 = 16; + do { + if (dst < gpBufEnd) { + left_shift = *gpDrawMask; + i = 32; + do { + if (left_shift & 0x80000000) + dst[0] = src[0]; + left_shift *= 2; + ++src; + ++dst; + --i; + } while (i); + } else { + src += 32; + dst += 32; + } + dst -= 800; + --gpDrawMask; + --yy_32; + } while (yy_32); + return; + } + world_tbl = WorldTbl3x16[tile_42_45]; + src += WorldTbl17_1[world_tbl >> 2]; + dst -= 192 * world_tbl; + xx_32 = 30 - (world_tbl >> 1); + } + do { + dst += xx_32; + n_draw_shift = (unsigned int)(32 - xx_32) >> 2; + if ((32 - xx_32) & 2) { + *(_WORD *)dst = *((_WORD *)src + 1); + src += 4; + dst += 2; + } + if (n_draw_shift) { + do { + *(_DWORD *)dst = *(_DWORD *)src; + src += 4; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + dst -= 800; + xx_32 -= 2; + } while (xx_32 >= 0); + goto LABEL_198; + default: // lower (bottom transparent), without lighting + xx_32 = 30; + if (pbDst >= gpBufEnd) { + tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; + if (tile_42_45 > 45) { + dst = pbDst - 12288; + src += 288; + LABEL_217: + gpDrawMask -= 16; + yy_32 = 16; + do { + if (dst < gpBufEnd) { + left_shift = *gpDrawMask; + i = 32; + do { + if (left_shift & 0x80000000) + dst[0] = src[0]; + left_shift *= 2; + ++src; + ++dst; + --i; + } while (i); + src += (unsigned char)src & 2; + } else { + src += 32; + dst += 32; + } + dst -= 800; + --gpDrawMask; + --yy_32; + } while (yy_32); + return; + } + world_tbl = WorldTbl3x16[tile_42_45]; + src += WorldTbl17_1[world_tbl >> 2]; + dst -= 192 * world_tbl; + xx_32 = 30 - (world_tbl >> 1); + } + do { + for (n_draw_shift = (unsigned int)(32 - xx_32) >> 2; n_draw_shift; --n_draw_shift) { + *(_DWORD *)dst = *(_DWORD *)src; + src += 4; + dst += 4; + } + if ((32 - (_BYTE)xx_32) & 2) { + *(_WORD *)dst = *(_WORD *)src; + src += 4; + dst += 2; + } + dst = &dst[xx_32 - 800]; + xx_32 -= 2; + } while (xx_32 >= 0); + goto LABEL_217; } } void __fastcall drawLowerScreen(unsigned char *pbDst) { - unsigned char *dst; // edi MAPDST - unsigned char *src; // esi MAPDST - unsigned char *tbl; // ebx - short cel_type_16; // ax MAPDST - int xx_32; // edx MAPDST - int yy_32; // ebp MAPDST - unsigned int chk_sh_and; // ecx MAPDST - signed int tile_42_45; // eax MAPDST - unsigned int world_tbl; // ecx MAPDST + unsigned char *dst; // edi MAPDST + unsigned char *src; // esi MAPDST + unsigned char *tbl; // ebx + short cel_type_16; // ax MAPDST + int xx_32; // edx MAPDST + int yy_32; // ebp MAPDST + unsigned int chk_sh_and; // ecx MAPDST + signed int tile_42_45; // eax MAPDST + unsigned int world_tbl; // ecx MAPDST unsigned int n_draw_shift; // ecx MAPDST - unsigned int width; // eax MAPDST - signed int i; // edx MAPDST - signed int j; // ecx MAPDST + unsigned int width; // eax MAPDST + signed int i; // edx MAPDST + signed int j; // ecx MAPDST - if ( cel_transparency_active ) - { - if ( !arch_draw_type ) - { + if (cel_transparency_active) { + if (!arch_draw_type) { drawTopArchesLowerScreen(pbDst); return; } - if ( arch_draw_type == 1 ) - { - if ( block_lvid[level_piece_id] == 1 || block_lvid[level_piece_id] == 3 ) - { + if (arch_draw_type == 1) { + if (block_lvid[level_piece_id] == 1 || block_lvid[level_piece_id] == 3) { drawBottomArchesLowerScreen(pbDst, &LeftMask[31]); return; } } - if ( arch_draw_type == 2 ) - { - if ( block_lvid[level_piece_id] == 2 || block_lvid[level_piece_id] == 3 ) - { + if (arch_draw_type == 2) { + if (block_lvid[level_piece_id] == 2 || block_lvid[level_piece_id] == 3) { drawBottomArchesLowerScreen(pbDst, &RightMask[31]); return; } @@ -5528,1006 +4426,785 @@ void __fastcall drawLowerScreen(unsigned char *pbDst) } gpCelFrame = (unsigned char *)speed_cel_frame_num_from_light_index_frame_num; dst = pbDst; - if ( (_BYTE)light_table_index ) - { - if ( (_BYTE)light_table_index == lightmax ) - { - if ( level_cel_block & 0x8000 ) + if ((_BYTE)light_table_index) { + if ((_BYTE)light_table_index == lightmax) { + if (level_cel_block & 0x8000) level_cel_block = *(_DWORD *)&gpCelFrame[64 * (level_cel_block & 0xFFF)] - + (unsigned short)(level_cel_block & 0xF000); + + (unsigned short)(level_cel_block & 0xF000); src = (unsigned char *)pDungeonCels + *((_DWORD *)pDungeonCels + (level_cel_block & 0xFFF)); cel_type_16 = (level_cel_block >> 12) & 7; - switch ( cel_type_16 ) - { - case 0: // lower (solid), black - i = 32; - do - { - if ( dst < gpBufEnd ) - { - j = 8; - do - { - *(_DWORD *)dst = 0; - dst += 4; - --j; - } - while ( j ); - } - else - { - src += 32; - dst += 32; - } - dst -= 800; - --i; + switch (cel_type_16) { + case 0: // lower (solid), black + i = 32; + do { + if (dst < gpBufEnd) { + j = 8; + do { + *(_DWORD *)dst = 0; + dst += 4; + --j; + } while (j); + } else { + src += 32; + dst += 32; } - while ( i ); - break; - case 1: // lower (solid), black - xx_32 = 32; - do - { - yy_32 = 32; - do - { - while ( 1 ) - { - width = (unsigned char)*src++; - if ( (width & 0x80u) == 0 ) - break; - _LOBYTE(width) = -(char)width; - dst += width; - yy_32 -= width; - if ( !yy_32 ) - goto LABEL_232; - } + dst -= 800; + --i; + } while (i); + break; + case 1: // lower (solid), black + xx_32 = 32; + do { + yy_32 = 32; + do { + while (1) { + width = (unsigned char)*src++; + if ((width & 0x80u) == 0) + break; + _LOBYTE(width) = -(char)width; + dst += width; yy_32 -= width; - if ( dst < gpBufEnd ) - { - src += width; - chk_sh_and = width >> 1; - if ( width & 1 ) - { - dst[0] = 0; - ++dst; + if (!yy_32) + goto LABEL_232; + } + yy_32 -= width; + if (dst < gpBufEnd) { + src += width; + chk_sh_and = width >> 1; + if (width & 1) { + dst[0] = 0; + ++dst; + } + if (chk_sh_and) { + n_draw_shift = width >> 2; + if (chk_sh_and & 1) { + *(_WORD *)dst = 0; + dst += 2; } - if ( chk_sh_and ) - { - n_draw_shift = width >> 2; - if ( chk_sh_and & 1 ) - { - *(_WORD *)dst = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - *(_DWORD *)dst = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } + if (n_draw_shift) { + do { + *(_DWORD *)dst = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); } } - else - { - src += width; - dst += width; - } + } else { + src += width; + dst += width; } - while ( yy_32 ); -LABEL_232: - dst -= 800; - --xx_32; - } - while ( xx_32 ); - break; - case 2: // lower (solid), black - for ( i = 30; ; i -= 2 ) - { - if ( dst < gpBufEnd ) - { - dst += i; - n_draw_shift = (unsigned int)(32 - i) >> 2; - if ( (32 - i) & 2 ) - { - *(_WORD *)dst = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - *(_DWORD *)dst = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - } - else - { - src = &src[32 - i]; - dst += 32; - } - dst -= 800; - if ( !i ) - break; - } - i = 2; - do - { - if ( dst < gpBufEnd ) - { - dst += i; - n_draw_shift = (unsigned int)(32 - i) >> 2; - if ( (32 - i) & 2 ) - { - *(_WORD *)dst = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - *(_DWORD *)dst = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - } - else - { - src = &src[32 - i]; - dst += 32; - } - dst -= 800; - i += 2; - } - while ( i != 32 ); - break; - case 3: // lower (solid), black - for ( i = 30; ; i -= 2 ) - { - if ( dst < gpBufEnd ) - { - n_draw_shift = (unsigned int)(32 - i) >> 2; - if ( (32 - i) & 2 ) - { - *(_WORD *)dst = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - *(_DWORD *)dst = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - } - else - { - src = &src[32 - i]; - dst = &dst[32 - i]; - } - dst -= 800; - if ( !i ) - break; + } while (yy_32); + LABEL_232: + dst -= 800; + --xx_32; + } while (xx_32); + break; + case 2: // lower (solid), black + for (i = 30;; i -= 2) { + if (dst < gpBufEnd) { dst += i; - } - i = 2; - do - { - if ( dst < gpBufEnd ) - { - n_draw_shift = (unsigned int)(32 - i) >> 2; - if ( (32 - i) & 2 ) - { - *(_WORD *)dst = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - *(_DWORD *)dst = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } + n_draw_shift = (unsigned int)(32 - i) >> 2; + if ((32 - i) & 2) { + *(_WORD *)dst = 0; + dst += 2; } - else - { - src = &src[32 - i]; - dst = &dst[32 - i]; - } - dst = &dst[i - 800]; - i += 2; - } - while ( i != 32 ); - break; - case 4: // lower (solid), black - for ( i = 30; ; i -= 2 ) - { - if ( dst < gpBufEnd ) - { - dst += i; - n_draw_shift = (unsigned int)(32 - i) >> 2; - if ( (32 - i) & 2 ) - { - *(_WORD *)dst = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - *(_DWORD *)dst = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - } - else - { - src = &src[32 - i]; - dst += 32; - } - dst -= 800; - if ( !i ) - break; - } - i = 16; - do - { - if ( dst < gpBufEnd ) - { - j = 8; - do - { + if (n_draw_shift) { + do { *(_DWORD *)dst = 0; dst += 4; - --j; - } - while ( j ); + --n_draw_shift; + } while (n_draw_shift); } - else - { - src += 32; - dst += 32; - } - dst -= 800; - --i; + } else { + src = &src[32 - i]; + dst += 32; } - while ( i ); - break; - default: // lower (solid), black - for ( i = 30; ; i -= 2 ) - { - if ( dst < gpBufEnd ) - { - n_draw_shift = (unsigned int)(32 - i) >> 2; - if ( (32 - i) & 2 ) - { - *(_WORD *)dst = 0; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - *(_DWORD *)dst = 0; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - } - else - { - src = &src[32 - i]; - dst = &dst[32 - i]; - } - dst -= 800; - if ( !i ) - break; + dst -= 800; + if (!i) + break; + } + i = 2; + do { + if (dst < gpBufEnd) { dst += i; - } - i = 16; - do - { - if ( dst < gpBufEnd ) - { - j = 8; - do - { + n_draw_shift = (unsigned int)(32 - i) >> 2; + if ((32 - i) & 2) { + *(_WORD *)dst = 0; + dst += 2; + } + if (n_draw_shift) { + do { *(_DWORD *)dst = 0; dst += 4; - --j; - } - while ( j ); + --n_draw_shift; + } while (n_draw_shift); } - else - { - src += 32; - dst += 32; - } - dst -= 800; - --i; + } else { + src = &src[32 - i]; + dst += 32; } - while ( i ); - break; + dst -= 800; + i += 2; + } while (i != 32); + break; + case 3: // lower (solid), black + for (i = 30;; i -= 2) { + if (dst < gpBufEnd) { + n_draw_shift = (unsigned int)(32 - i) >> 2; + if ((32 - i) & 2) { + *(_WORD *)dst = 0; + dst += 2; + } + if (n_draw_shift) { + do { + *(_DWORD *)dst = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + } else { + src = &src[32 - i]; + dst = &dst[32 - i]; + } + dst -= 800; + if (!i) + break; + dst += i; + } + i = 2; + do { + if (dst < gpBufEnd) { + n_draw_shift = (unsigned int)(32 - i) >> 2; + if ((32 - i) & 2) { + *(_WORD *)dst = 0; + dst += 2; + } + if (n_draw_shift) { + do { + *(_DWORD *)dst = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + } else { + src = &src[32 - i]; + dst = &dst[32 - i]; + } + dst = &dst[i - 800]; + i += 2; + } while (i != 32); + break; + case 4: // lower (solid), black + for (i = 30;; i -= 2) { + if (dst < gpBufEnd) { + dst += i; + n_draw_shift = (unsigned int)(32 - i) >> 2; + if ((32 - i) & 2) { + *(_WORD *)dst = 0; + dst += 2; + } + if (n_draw_shift) { + do { + *(_DWORD *)dst = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + } else { + src = &src[32 - i]; + dst += 32; + } + dst -= 800; + if (!i) + break; + } + i = 16; + do { + if (dst < gpBufEnd) { + j = 8; + do { + *(_DWORD *)dst = 0; + dst += 4; + --j; + } while (j); + } else { + src += 32; + dst += 32; + } + dst -= 800; + --i; + } while (i); + break; + default: // lower (solid), black + for (i = 30;; i -= 2) { + if (dst < gpBufEnd) { + n_draw_shift = (unsigned int)(32 - i) >> 2; + if ((32 - i) & 2) { + *(_WORD *)dst = 0; + dst += 2; + } + if (n_draw_shift) { + do { + *(_DWORD *)dst = 0; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + } else { + src = &src[32 - i]; + dst = &dst[32 - i]; + } + dst -= 800; + if (!i) + break; + dst += i; + } + i = 16; + do { + if (dst < gpBufEnd) { + j = 8; + do { + *(_DWORD *)dst = 0; + dst += 4; + --j; + } while (j); + } else { + src += 32; + dst += 32; + } + dst -= 800; + --i; + } while (i); + break; } return; } - if ( !(level_cel_block & 0x8000) ) - { + if (!(level_cel_block & 0x8000)) { src = (unsigned char *)pDungeonCels + *((_DWORD *)pDungeonCels + (level_cel_block & 0xFFF)); tbl = (unsigned char *)&pLightTbl[256 * light_table_index]; cel_type_16 = (unsigned short)level_cel_block >> 12; - switch ( cel_type_16 ) - { - case 0: // lower (solid), with lighting - xx_32 = 32; - do - { - if ( dst < gpBufEnd ) - { - asm_cel_light_square(8, tbl, dst, src); - } - else - { - src += 32; - dst += 32; - } - dst -= 800; - --xx_32; + switch (cel_type_16) { + case 0: // lower (solid), with lighting + xx_32 = 32; + do { + if (dst < gpBufEnd) { + asm_cel_light_square(8, tbl, dst, src); + } else { + src += 32; + dst += 32; } - while ( xx_32 ); - break; - case 1: // lower (solid), with lighting - xx_32 = 32; - do - { - yy_32 = 32; - do - { - width = (unsigned char)*src++; - if ( (width & 0x80u) == 0 ) - { - yy_32 -= width; - if ( dst < gpBufEnd ) - { - asm_cel_light_edge(width, tbl, dst, src); - } - else - { - src += width; - dst += width; - } - } - else - { - _LOBYTE(width) = -(char)width; + dst -= 800; + --xx_32; + } while (xx_32); + break; + case 1: // lower (solid), with lighting + xx_32 = 32; + do { + yy_32 = 32; + do { + width = (unsigned char)*src++; + if ((width & 0x80u) == 0) { + yy_32 -= width; + if (dst < gpBufEnd) { + asm_cel_light_edge(width, tbl, dst, src); + } else { + src += width; dst += width; - yy_32 -= width; } + } else { + _LOBYTE(width) = -(char)width; + dst += width; + yy_32 -= width; } - while ( yy_32 ); - dst -= 800; - --xx_32; - } - while ( xx_32 ); - break; - case 2: // lower (solid), with lighting - xx_32 = 30; - if ( pbDst >= gpBufEnd ) - { - tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; - if ( tile_42_45 > 45 ) - { - dst = pbDst - 12288; - src += 288; -LABEL_68: - yy_32 = 2; - if ( dst >= gpBufEnd ) - { - tile_42_45 = (unsigned int)(dst - gpBufEnd + 1023) >> 8; - if ( tile_42_45 > 42 ) - return; - world_tbl = WorldTbl3x16[tile_42_45]; - src += WorldTbl17_2[world_tbl >> 2]; - dst -= 192 * world_tbl; - yy_32 = (world_tbl >> 1) + 2; - } - do - { - dst += yy_32; - src += (32 - (_BYTE)yy_32) & 2; - asm_cel_light_edge(32 - yy_32, tbl, dst, src); - yy_32 += 2; - dst -= 800; - } - while ( yy_32 != 32 ); - return; + } while (yy_32); + dst -= 800; + --xx_32; + } while (xx_32); + break; + case 2: // lower (solid), with lighting + xx_32 = 30; + if (pbDst >= gpBufEnd) { + tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; + if (tile_42_45 > 45) { + dst = pbDst - 12288; + src += 288; + LABEL_68: + yy_32 = 2; + if (dst >= gpBufEnd) { + tile_42_45 = (unsigned int)(dst - gpBufEnd + 1023) >> 8; + if (tile_42_45 > 42) + return; + world_tbl = WorldTbl3x16[tile_42_45]; + src += WorldTbl17_2[world_tbl >> 2]; + dst -= 192 * world_tbl; + yy_32 = (world_tbl >> 1) + 2; } - world_tbl = WorldTbl3x16[tile_42_45]; - src += WorldTbl17_1[world_tbl >> 2]; - dst -= 192 * world_tbl; - xx_32 = 30 - (world_tbl >> 1); + do { + dst += yy_32; + src += (32 - (_BYTE)yy_32) & 2; + asm_cel_light_edge(32 - yy_32, tbl, dst, src); + yy_32 += 2; + dst -= 800; + } while (yy_32 != 32); + return; } - do - { - dst += xx_32; - src += (32 - (_BYTE)xx_32) & 2; - asm_cel_light_edge(32 - xx_32, tbl, dst, src); - dst -= 800; - xx_32 -= 2; - } - while ( xx_32 >= 0 ); - goto LABEL_68; - case 3: // lower (solid), with lighting - xx_32 = 30; - if ( pbDst >= gpBufEnd ) - { - tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; - if ( tile_42_45 > 45 ) - { - dst = pbDst - 12288; - src += 288; -LABEL_83: - yy_32 = 2; - if ( dst >= gpBufEnd ) - { - tile_42_45 = (unsigned int)(dst - gpBufEnd + 1023) >> 8; - if ( tile_42_45 > 42 ) - return; - world_tbl = WorldTbl3x16[tile_42_45]; - src += WorldTbl17_2[world_tbl >> 2]; - dst -= 192 * world_tbl; - yy_32 = (world_tbl >> 1) + 2; - } - do - { - asm_cel_light_edge(32 - yy_32, tbl, dst, src); - src += (unsigned char)src & 2; - dst = &dst[yy_32 - 800]; - yy_32 += 2; - } - while ( yy_32 != 32 ); - return; + world_tbl = WorldTbl3x16[tile_42_45]; + src += WorldTbl17_1[world_tbl >> 2]; + dst -= 192 * world_tbl; + xx_32 = 30 - (world_tbl >> 1); + } + do { + dst += xx_32; + src += (32 - (_BYTE)xx_32) & 2; + asm_cel_light_edge(32 - xx_32, tbl, dst, src); + dst -= 800; + xx_32 -= 2; + } while (xx_32 >= 0); + goto LABEL_68; + case 3: // lower (solid), with lighting + xx_32 = 30; + if (pbDst >= gpBufEnd) { + tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; + if (tile_42_45 > 45) { + dst = pbDst - 12288; + src += 288; + LABEL_83: + yy_32 = 2; + if (dst >= gpBufEnd) { + tile_42_45 = (unsigned int)(dst - gpBufEnd + 1023) >> 8; + if (tile_42_45 > 42) + return; + world_tbl = WorldTbl3x16[tile_42_45]; + src += WorldTbl17_2[world_tbl >> 2]; + dst -= 192 * world_tbl; + yy_32 = (world_tbl >> 1) + 2; } - world_tbl = WorldTbl3x16[tile_42_45]; - src += WorldTbl17_1[world_tbl >> 2]; - dst -= 192 * world_tbl; - xx_32 = 30 - (world_tbl >> 1); + do { + asm_cel_light_edge(32 - yy_32, tbl, dst, src); + src += (unsigned char)src & 2; + dst = &dst[yy_32 - 800]; + yy_32 += 2; + } while (yy_32 != 32); + return; } - do - { - asm_cel_light_edge(32 - xx_32, tbl, dst, src); - src += (unsigned char)src & 2; - dst = &dst[xx_32 - 800]; - xx_32 -= 2; - } - while ( xx_32 >= 0 ); - goto LABEL_83; - case 4: // lower (solid), with lighting - xx_32 = 30; - if ( pbDst >= gpBufEnd ) - { - tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; - if ( tile_42_45 > 45 ) - { - dst = pbDst - 12288; - src += 288; -LABEL_100: - i = 16; - do - { - if ( dst < gpBufEnd ) - { - asm_cel_light_square(8, tbl, dst, src); - } - else - { - src += 32; - dst += 32; - } - dst -= 800; - --i; + world_tbl = WorldTbl3x16[tile_42_45]; + src += WorldTbl17_1[world_tbl >> 2]; + dst -= 192 * world_tbl; + xx_32 = 30 - (world_tbl >> 1); + } + do { + asm_cel_light_edge(32 - xx_32, tbl, dst, src); + src += (unsigned char)src & 2; + dst = &dst[xx_32 - 800]; + xx_32 -= 2; + } while (xx_32 >= 0); + goto LABEL_83; + case 4: // lower (solid), with lighting + xx_32 = 30; + if (pbDst >= gpBufEnd) { + tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; + if (tile_42_45 > 45) { + dst = pbDst - 12288; + src += 288; + LABEL_100: + i = 16; + do { + if (dst < gpBufEnd) { + asm_cel_light_square(8, tbl, dst, src); + } else { + src += 32; + dst += 32; } - while ( i ); - return; - } - world_tbl = WorldTbl3x16[tile_42_45]; - src += WorldTbl17_1[world_tbl >> 2]; - dst -= 192 * world_tbl; - xx_32 = 30 - (world_tbl >> 1); + dst -= 800; + --i; + } while (i); + return; } - do - { - dst += xx_32; - src += (32 - (_BYTE)xx_32) & 2; - asm_cel_light_edge(32 - xx_32, tbl, dst, src); - dst -= 800; - xx_32 -= 2; - } - while ( xx_32 >= 0 ); - goto LABEL_100; - default: // lower (solid), with lighting - xx_32 = 30; - if ( pbDst >= gpBufEnd ) - { - tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; - if ( tile_42_45 > 45 ) - { - dst = pbDst - 12288; - src += 288; -LABEL_116: - j = 16; - do - { - if ( dst < gpBufEnd ) - { - asm_cel_light_square(8, tbl, dst, src); - } - else - { - src += 32; - dst += 32; - } - dst -= 800; - --j; + world_tbl = WorldTbl3x16[tile_42_45]; + src += WorldTbl17_1[world_tbl >> 2]; + dst -= 192 * world_tbl; + xx_32 = 30 - (world_tbl >> 1); + } + do { + dst += xx_32; + src += (32 - (_BYTE)xx_32) & 2; + asm_cel_light_edge(32 - xx_32, tbl, dst, src); + dst -= 800; + xx_32 -= 2; + } while (xx_32 >= 0); + goto LABEL_100; + default: // lower (solid), with lighting + xx_32 = 30; + if (pbDst >= gpBufEnd) { + tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; + if (tile_42_45 > 45) { + dst = pbDst - 12288; + src += 288; + LABEL_116: + j = 16; + do { + if (dst < gpBufEnd) { + asm_cel_light_square(8, tbl, dst, src); + } else { + src += 32; + dst += 32; } - while ( j ); - return; - } - world_tbl = WorldTbl3x16[tile_42_45]; - src += WorldTbl17_1[world_tbl >> 2]; - dst -= 192 * world_tbl; - xx_32 = 30 - (world_tbl >> 1); + dst -= 800; + --j; + } while (j); + return; } - do - { - asm_cel_light_edge(32 - xx_32, tbl, dst, src); - src += (unsigned char)src & 2; - dst = &dst[xx_32 - 800]; - xx_32 -= 2; - } - while ( xx_32 >= 0 ); - goto LABEL_116; + world_tbl = WorldTbl3x16[tile_42_45]; + src += WorldTbl17_1[world_tbl >> 2]; + dst -= 192 * world_tbl; + xx_32 = 30 - (world_tbl >> 1); + } + do { + asm_cel_light_edge(32 - xx_32, tbl, dst, src); + src += (unsigned char)src & 2; + dst = &dst[xx_32 - 800]; + xx_32 -= 2; + } while (xx_32 >= 0); + goto LABEL_116; } return; } src = (unsigned char *)pSpeedCels - + *(_DWORD *)&gpCelFrame[4 * (light_table_index + 16 * (level_cel_block & 0xFFF))]; + + *(_DWORD *)&gpCelFrame[4 * (light_table_index + 16 * (level_cel_block & 0xFFF))]; cel_type_16 = (unsigned short)level_cel_block >> 12; - } - else - { - if ( level_cel_block & 0x8000 ) + } else { + if (level_cel_block & 0x8000) level_cel_block = *(_DWORD *)&gpCelFrame[64 * (level_cel_block & 0xFFF)] - + (unsigned short)(level_cel_block & 0xF000); + + (unsigned short)(level_cel_block & 0xF000); src = (unsigned char *)pDungeonCels + *((_DWORD *)pDungeonCels + (level_cel_block & 0xFFF)); cel_type_16 = (((unsigned int)level_cel_block >> 12) & 7) + 8; } - switch ( cel_type_16 ) - { - case 8: // lower (solid), without lighting - i = 32; - do - { - if ( dst < gpBufEnd ) - { - j = 8; - do - { - *(_DWORD *)dst = *(_DWORD *)src; - src += 4; - dst += 4; - --j; - } - while ( j ); - } - else - { - src += 32; - dst += 32; - } - dst -= 800; - --i; + switch (cel_type_16) { + case 8: // lower (solid), without lighting + i = 32; + do { + if (dst < gpBufEnd) { + j = 8; + do { + *(_DWORD *)dst = *(_DWORD *)src; + src += 4; + dst += 4; + --j; + } while (j); + } else { + src += 32; + dst += 32; } - while ( i ); - break; - case 9: // lower (solid), without lighting - xx_32 = 32; - do - { - yy_32 = 32; - do - { - while ( 1 ) - { - width = (unsigned char)*src++; - if ( (width & 0x80u) == 0 ) - break; - _LOBYTE(width) = -(char)width; - dst += width; - yy_32 -= width; - if ( !yy_32 ) - goto LABEL_143; - } + dst -= 800; + --i; + } while (i); + break; + case 9: // lower (solid), without lighting + xx_32 = 32; + do { + yy_32 = 32; + do { + while (1) { + width = (unsigned char)*src++; + if ((width & 0x80u) == 0) + break; + _LOBYTE(width) = -(char)width; + dst += width; yy_32 -= width; - if ( dst < gpBufEnd ) - { - chk_sh_and = width >> 1; - if ( width & 1 ) - { - dst[0] = src[0]; - ++src; - ++dst; - } - if ( chk_sh_and ) - { - n_draw_shift = chk_sh_and >> 1; - if ( chk_sh_and & 1 ) - { - *(_WORD *)dst = *(_WORD *)src; - src += 2; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - *(_DWORD *)dst = *(_DWORD *)src; - src += 4; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - } - } - else - { - src += width; - dst += width; - } + if (!yy_32) + goto LABEL_143; } - while ( yy_32 ); -LABEL_143: - dst -= 800; - --xx_32; - } - while ( xx_32 ); - break; - case 10: // lower (solid), without lighting - xx_32 = 30; - if ( pbDst >= gpBufEnd ) - { - tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; - if ( tile_42_45 > 45 ) - { - dst = pbDst - 12288; - src += 288; -LABEL_153: - yy_32 = 2; - if ( dst >= gpBufEnd ) - { - tile_42_45 = (unsigned int)(dst - gpBufEnd + 1023) >> 8; - if ( tile_42_45 > 42 ) - return; - world_tbl = WorldTbl3x16[tile_42_45]; - src += WorldTbl17_2[world_tbl >> 2]; - dst -= 192 * world_tbl; - yy_32 = (world_tbl >> 1) + 2; + yy_32 -= width; + if (dst < gpBufEnd) { + chk_sh_and = width >> 1; + if (width & 1) { + dst[0] = src[0]; + ++src; + ++dst; } - do - { - dst += yy_32; - n_draw_shift = (unsigned int)(32 - yy_32) >> 2; - if ( (32 - yy_32) & 2 ) - { - *(_WORD *)dst = *((_WORD *)src + 1); - src += 4; + if (chk_sh_and) { + n_draw_shift = chk_sh_and >> 1; + if (chk_sh_and & 1) { + *(_WORD *)dst = *(_WORD *)src; + src += 2; dst += 2; } - if ( n_draw_shift ) - { - do - { + if (n_draw_shift) { + do { *(_DWORD *)dst = *(_DWORD *)src; src += 4; dst += 4; --n_draw_shift; - } - while ( n_draw_shift ); + } while (n_draw_shift); } - yy_32 += 2; - dst -= 800; } - while ( yy_32 < 32 ); - return; + } else { + src += width; + dst += width; } - world_tbl = WorldTbl3x16[tile_42_45]; - src += WorldTbl17_1[world_tbl >> 2]; - dst -= 192 * world_tbl; - xx_32 = 30 - (world_tbl >> 1); - } - do - { - dst += xx_32; - n_draw_shift = (unsigned int)(32 - xx_32) >> 2; - if ( (32 - xx_32) & 2 ) - { - *(_WORD *)dst = *((_WORD *)src + 1); - src += 4; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - *(_DWORD *)dst = *(_DWORD *)src; - src += 4; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - dst -= 800; - xx_32 -= 2; - } - while ( xx_32 >= 0 ); - goto LABEL_153; - case 11: // lower (solid), without lighting - xx_32 = 30; - if ( pbDst < gpBufEnd ) - goto LABEL_166; + } while (yy_32); + LABEL_143: + dst -= 800; + --xx_32; + } while (xx_32); + break; + case 10: // lower (solid), without lighting + xx_32 = 30; + if (pbDst >= gpBufEnd) { tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; - if ( tile_42_45 <= 45 ) - { - world_tbl = WorldTbl3x16[tile_42_45]; - src += WorldTbl17_1[world_tbl >> 2]; - dst -= 192 * world_tbl; - xx_32 = 30 - (world_tbl >> 1); - do - { -LABEL_166: - for ( n_draw_shift = (unsigned int)(32 - xx_32) >> 2; n_draw_shift; --n_draw_shift ) - { - *(_DWORD *)dst = *(_DWORD *)src; - src += 4; - dst += 4; - } - if ( (32 - (_BYTE)xx_32) & 2 ) - { - *(_WORD *)dst = *(_WORD *)src; + if (tile_42_45 > 45) { + dst = pbDst - 12288; + src += 288; + LABEL_153: + yy_32 = 2; + if (dst >= gpBufEnd) { + tile_42_45 = (unsigned int)(dst - gpBufEnd + 1023) >> 8; + if (tile_42_45 > 42) + return; + world_tbl = WorldTbl3x16[tile_42_45]; + src += WorldTbl17_2[world_tbl >> 2]; + dst -= 192 * world_tbl; + yy_32 = (world_tbl >> 1) + 2; + } + do { + dst += yy_32; + n_draw_shift = (unsigned int)(32 - yy_32) >> 2; + if ((32 - yy_32) & 2) { + *(_WORD *)dst = *((_WORD *)src + 1); src += 4; dst += 2; } - dst = &dst[xx_32 - 800]; - xx_32 -= 2; - } - while ( xx_32 >= 0 ); - goto LABEL_171; + if (n_draw_shift) { + do { + *(_DWORD *)dst = *(_DWORD *)src; + src += 4; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + yy_32 += 2; + dst -= 800; + } while (yy_32 < 32); + return; } - dst = pbDst - 12288; - src += 288; -LABEL_171: - yy_32 = 2; - if ( dst >= gpBufEnd ) - { - tile_42_45 = (unsigned int)(dst - gpBufEnd + 1023) >> 8; - if ( tile_42_45 > 42 ) - return; - world_tbl = WorldTbl3x16[tile_42_45]; - src += WorldTbl17_2[world_tbl >> 2]; - dst -= 192 * world_tbl; - yy_32 = (world_tbl >> 1) + 2; + world_tbl = WorldTbl3x16[tile_42_45]; + src += WorldTbl17_1[world_tbl >> 2]; + dst -= 192 * world_tbl; + xx_32 = 30 - (world_tbl >> 1); + } + do { + dst += xx_32; + n_draw_shift = (unsigned int)(32 - xx_32) >> 2; + if ((32 - xx_32) & 2) { + *(_WORD *)dst = *((_WORD *)src + 1); + src += 4; + dst += 2; } - do - { - for ( n_draw_shift = (unsigned int)(32 - yy_32) >> 2; n_draw_shift; --n_draw_shift ) - { + if (n_draw_shift) { + do { + *(_DWORD *)dst = *(_DWORD *)src; + src += 4; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + dst -= 800; + xx_32 -= 2; + } while (xx_32 >= 0); + goto LABEL_153; + case 11: // lower (solid), without lighting + xx_32 = 30; + if (pbDst < gpBufEnd) + goto LABEL_166; + tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; + if (tile_42_45 <= 45) { + world_tbl = WorldTbl3x16[tile_42_45]; + src += WorldTbl17_1[world_tbl >> 2]; + dst -= 192 * world_tbl; + xx_32 = 30 - (world_tbl >> 1); + do { + LABEL_166: + for (n_draw_shift = (unsigned int)(32 - xx_32) >> 2; n_draw_shift; --n_draw_shift) { *(_DWORD *)dst = *(_DWORD *)src; src += 4; dst += 4; } - if ( (32 - (_BYTE)yy_32) & 2 ) - { - *(_WORD *)dst = *(_WORD *)src; - src += 4; - dst += 2; - } - dst += yy_32; - yy_32 += 2; - dst -= 800; - } - while ( yy_32 < 32 ); - break; - case 12: // lower (solid), without lighting - xx_32 = 30; - if ( pbDst >= gpBufEnd ) - { - tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; - if ( tile_42_45 > 45 ) - { - dst = pbDst - 12288; - src += 288; -LABEL_189: - i = 16; - do - { - if ( dst < gpBufEnd ) - { - j = 8; - do - { - *(_DWORD *)dst = *(_DWORD *)src; - src += 4; - dst += 4; - --j; - } - while ( j ); - } - else - { - src += 32; - dst += 32; - } - dst -= 800; - --i; - } - while ( i ); - return; - } - world_tbl = WorldTbl3x16[tile_42_45]; - src += WorldTbl17_1[world_tbl >> 2]; - dst -= 192 * world_tbl; - xx_32 = 30 - (world_tbl >> 1); - } - do - { - dst += xx_32; - n_draw_shift = (unsigned int)(32 - xx_32) >> 2; - if ( (32 - xx_32) & 2 ) - { - *(_WORD *)dst = *((_WORD *)src + 1); - src += 4; - dst += 2; - } - if ( n_draw_shift ) - { - do - { - *(_DWORD *)dst = *(_DWORD *)src; - src += 4; - dst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); - } - dst -= 800; - xx_32 -= 2; - } - while ( xx_32 >= 0 ); - goto LABEL_189; - default: // lower (solid), without lighting - xx_32 = 30; - if ( pbDst >= gpBufEnd ) - { - tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; - if ( tile_42_45 > 45 ) - { - dst = pbDst - 12288; - src += 288; -LABEL_205: - i = 16; - do - { - if ( dst < gpBufEnd ) - { - j = 8; - do - { - *(_DWORD *)dst = *(_DWORD *)src; - src += 4; - dst += 4; - --j; - } - while ( j ); - } - else - { - src += 32; - dst += 32; - } - dst -= 800; - --i; - } - while ( i ); - return; - } - world_tbl = WorldTbl3x16[tile_42_45]; - src += WorldTbl17_1[world_tbl >> 2]; - dst -= 192 * world_tbl; - xx_32 = 30 - (world_tbl >> 1); - } - do - { - for ( n_draw_shift = (unsigned int)(32 - xx_32) >> 2; n_draw_shift; --n_draw_shift ) - { - *(_DWORD *)dst = *(_DWORD *)src; - src += 4; - dst += 4; - } - if ( (32 - (_BYTE)xx_32) & 2 ) - { + if ((32 - (_BYTE)xx_32) & 2) { *(_WORD *)dst = *(_WORD *)src; src += 4; dst += 2; } dst = &dst[xx_32 - 800]; xx_32 -= 2; + } while (xx_32 >= 0); + goto LABEL_171; + } + dst = pbDst - 12288; + src += 288; + LABEL_171: + yy_32 = 2; + if (dst >= gpBufEnd) { + tile_42_45 = (unsigned int)(dst - gpBufEnd + 1023) >> 8; + if (tile_42_45 > 42) + return; + world_tbl = WorldTbl3x16[tile_42_45]; + src += WorldTbl17_2[world_tbl >> 2]; + dst -= 192 * world_tbl; + yy_32 = (world_tbl >> 1) + 2; + } + do { + for (n_draw_shift = (unsigned int)(32 - yy_32) >> 2; n_draw_shift; --n_draw_shift) { + *(_DWORD *)dst = *(_DWORD *)src; + src += 4; + dst += 4; } - while ( xx_32 >= 0 ); - goto LABEL_205; + if ((32 - (_BYTE)yy_32) & 2) { + *(_WORD *)dst = *(_WORD *)src; + src += 4; + dst += 2; + } + dst += yy_32; + yy_32 += 2; + dst -= 800; + } while (yy_32 < 32); + break; + case 12: // lower (solid), without lighting + xx_32 = 30; + if (pbDst >= gpBufEnd) { + tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; + if (tile_42_45 > 45) { + dst = pbDst - 12288; + src += 288; + LABEL_189: + i = 16; + do { + if (dst < gpBufEnd) { + j = 8; + do { + *(_DWORD *)dst = *(_DWORD *)src; + src += 4; + dst += 4; + --j; + } while (j); + } else { + src += 32; + dst += 32; + } + dst -= 800; + --i; + } while (i); + return; + } + world_tbl = WorldTbl3x16[tile_42_45]; + src += WorldTbl17_1[world_tbl >> 2]; + dst -= 192 * world_tbl; + xx_32 = 30 - (world_tbl >> 1); + } + do { + dst += xx_32; + n_draw_shift = (unsigned int)(32 - xx_32) >> 2; + if ((32 - xx_32) & 2) { + *(_WORD *)dst = *((_WORD *)src + 1); + src += 4; + dst += 2; + } + if (n_draw_shift) { + do { + *(_DWORD *)dst = *(_DWORD *)src; + src += 4; + dst += 4; + --n_draw_shift; + } while (n_draw_shift); + } + dst -= 800; + xx_32 -= 2; + } while (xx_32 >= 0); + goto LABEL_189; + default: // lower (solid), without lighting + xx_32 = 30; + if (pbDst >= gpBufEnd) { + tile_42_45 = (unsigned int)(pbDst - gpBufEnd + 1023) >> 8; + if (tile_42_45 > 45) { + dst = pbDst - 12288; + src += 288; + LABEL_205: + i = 16; + do { + if (dst < gpBufEnd) { + j = 8; + do { + *(_DWORD *)dst = *(_DWORD *)src; + src += 4; + dst += 4; + --j; + } while (j); + } else { + src += 32; + dst += 32; + } + dst -= 800; + --i; + } while (i); + return; + } + world_tbl = WorldTbl3x16[tile_42_45]; + src += WorldTbl17_1[world_tbl >> 2]; + dst -= 192 * world_tbl; + xx_32 = 30 - (world_tbl >> 1); + } + do { + for (n_draw_shift = (unsigned int)(32 - xx_32) >> 2; n_draw_shift; --n_draw_shift) { + *(_DWORD *)dst = *(_DWORD *)src; + src += 4; + dst += 4; + } + if ((32 - (_BYTE)xx_32) & 2) { + *(_WORD *)dst = *(_WORD *)src; + src += 4; + dst += 2; + } + dst = &dst[xx_32 - 800]; + xx_32 -= 2; + } while (xx_32 >= 0); + goto LABEL_205; } } void __fastcall world_draw_black_tile(unsigned char *pbDst) { unsigned char *dst; // edi MAPDST - signed int xx_32; // edx - signed int i; // ebx MAPDST - signed int j; // ecx MAPDST - signed int yy_32; // edx + signed int xx_32; // edx + signed int i; // ebx MAPDST + signed int j; // ecx MAPDST + signed int yy_32; // edx dst = pbDst; xx_32 = 30; - for ( i = 1; ; ++i ) - { + for (i = 1;; ++i) { dst += xx_32; j = i; - do - { + do { *(_DWORD *)dst = 0; dst += 4; --j; - } - while ( j ); + } while (j); dst = &dst[xx_32 - 832]; - if ( !xx_32 ) + if (!xx_32) break; xx_32 -= 2; } yy_32 = 2; i = 15; - do - { + do { dst += yy_32; j = i; - do - { + do { *(_DWORD *)dst = 0; dst += 4; --j; - } - while ( j ); + } while (j); dst = &dst[yy_32 - 832]; --i; yy_32 += 2; - } - while ( yy_32 != 32 ); + } while (yy_32 != 32); } diff --git a/Source/restrict.cpp b/Source/restrict.cpp index a737957b..c3aa5203 100644 --- a/Source/restrict.cpp +++ b/Source/restrict.cpp @@ -4,57 +4,57 @@ BOOL __cdecl SystemSupported() { - OSVERSIONINFO VersionInformation; - BOOL ret = FALSE; + OSVERSIONINFO VersionInformation; + BOOL ret = FALSE; - memset(&VersionInformation, 0, sizeof(VersionInformation)); - VersionInformation.dwOSVersionInfoSize = sizeof(VersionInformation); - if (GetVersionEx(&VersionInformation) - && VersionInformation.dwPlatformId == VER_PLATFORM_WIN32_NT - && VersionInformation.dwMajorVersion >= 5) { - ret = TRUE; - } - return ret; + memset(&VersionInformation, 0, sizeof(VersionInformation)); + VersionInformation.dwOSVersionInfoSize = sizeof(VersionInformation); + if (GetVersionEx(&VersionInformation) + && VersionInformation.dwPlatformId == VER_PLATFORM_WIN32_NT + && VersionInformation.dwMajorVersion >= 5) { + ret = TRUE; + } + return ret; } BOOL __cdecl RestrictedTest() { - FILE *f; - char Buffer[MAX_PATH]; - BOOL ret = FALSE; + FILE *f; + char Buffer[MAX_PATH]; + BOOL ret = FALSE; - if (SystemSupported() && GetWindowsDirectory(Buffer, sizeof(Buffer))) { - strcat(Buffer, "\\Diablo1RestrictedTest.foo"); - f = fopen(Buffer, "wt"); - if (f) { - fclose(f); - remove(Buffer); - } else { - ret = TRUE; - } - } - return ret; + if (SystemSupported() && GetWindowsDirectory(Buffer, sizeof(Buffer))) { + strcat(Buffer, "\\Diablo1RestrictedTest.foo"); + f = fopen(Buffer, "wt"); + if (f) { + fclose(f); + remove(Buffer); + } else { + ret = TRUE; + } + } + return ret; } BOOL __cdecl ReadOnlyTest() { - char *c; - FILE *f; - char Filename[MAX_PATH]; - BOOL ret = FALSE; + char *c; + FILE *f; + char Filename[MAX_PATH]; + BOOL ret = FALSE; - if (GetModuleFileName(ghInst, Filename, sizeof(Filename))) { - c = strrchr(Filename, '\\'); - if (c) { - strcpy(c + 1, "Diablo1ReadOnlyTest.foo"); - f = fopen(Filename, "wt"); - if (f) { - fclose(f); - remove(Filename); - } else { - ret = TRUE; - } - } - } - return ret; + if (GetModuleFileName(ghInst, Filename, sizeof(Filename))) { + c = strrchr(Filename, '\\'); + if (c) { + strcpy(c + 1, "Diablo1ReadOnlyTest.foo"); + f = fopen(Filename, "wt"); + if (f) { + fclose(f); + remove(Filename); + } else { + ret = TRUE; + } + } + } + return ret; } diff --git a/Source/scrollrt.cpp b/Source/scrollrt.cpp index ba3c9034..28559df0 100644 --- a/Source/scrollrt.cpp +++ b/Source/scrollrt.cpp @@ -6,30 +6,29 @@ int light_table_index; // weak int screen_y_times_768[1024]; int scrollrt_cpp_init_value; // weak unsigned int sgdwCursWdtOld; // idb -int sgdwCursX; // idb -int sgdwCursY; // idb -unsigned char *gpBufEnd; // weak +int sgdwCursX; // idb +int sgdwCursY; // idb +unsigned char *gpBufEnd; // weak int sgdwCursHgt; int level_cel_block; // weak -int sgdwCursXOld; // idb -int sgdwCursYOld; // idb +int sgdwCursXOld; // idb +int sgdwCursYOld; // idb char arch_draw_type; // weak DDSURFACEDESC DDS_desc; int cel_transparency_active; // weak -int level_piece_id; // weak +int level_piece_id; // weak int sgdwCursWdt; -int (__fastcall *DrawPlrProc)(int player_num, int x, int y, int screen_x, int screen_y, void *cl2_buf, int frame, int frame_width, int a9, int a10); +int(__fastcall *DrawPlrProc)(int player_num, int x, int y, int screen_x, int screen_y, void *cl2_buf, int frame, int frame_width, int a9, int a10); char sgSaveBack[8192]; int draw_monster_num; // weak -int sgdwCursHgtOld; // idb +int sgdwCursHgtOld; // idb const int scrollrt_inf = 0x7F800000; // weak /* data */ /* used in 1.00 debug */ -char *szMonModeAssert[18] = -{ +char *szMonModeAssert[18] = { "standing", "walking (1)", "walking (2)", @@ -50,8 +49,7 @@ char *szMonModeAssert[18] = "talking" }; -char *szPlrModeAssert[12] = -{ +char *szPlrModeAssert[12] = { "standing", "walking (1)", "walking (2)", @@ -66,8 +64,7 @@ char *szPlrModeAssert[12] = "quitting" }; -struct scrollrt_cpp_init -{ +struct scrollrt_cpp_init { scrollrt_cpp_init() { scrollrt_cpp_init_value = scrollrt_inf; @@ -84,92 +81,77 @@ void __cdecl ClearCursor() // CODE_FIX: this was supposed to be in cursor.cpp void __fastcall DrawMissile(int x, int y, int sx, int sy, int a5, int a6, int del_flag) { - int v7; // ebx - char v8; // al - int v9; // eax - int v10; // eax + int v7; // ebx + char v8; // al + int v9; // eax + int v10; // eax MissileStruct *v11; // eax - char *v12; // edi - int v13; // edx - int v14; // esi - int v15; // ecx + char *v12; // edi + int v13; // edx + int v14; // esi + int v15; // ecx MissileStruct *v16; // eax - char *v17; // edi - int v18; // edx - int v19; // esi - int v20; // ecx - int v21; // [esp-10h] [ebp-28h] - int v22; // [esp-10h] [ebp-28h] - int v23; // [esp-Ch] [ebp-24h] - int v24; // [esp-Ch] [ebp-24h] - int v25; // [esp+Ch] [ebp-Ch] - int v26; // [esp+10h] [ebp-8h] - int i; // [esp+14h] [ebp-4h] + char *v17; // edi + int v18; // edx + int v19; // esi + int v20; // ecx + int v21; // [esp-10h] [ebp-28h] + int v22; // [esp-10h] [ebp-28h] + int v23; // [esp-Ch] [ebp-24h] + int v24; // [esp-Ch] [ebp-24h] + int v25; // [esp+Ch] [ebp-Ch] + int v26; // [esp+10h] [ebp-8h] + int i; // [esp+14h] [ebp-4h] v26 = x; v7 = y; v8 = dMissile[x][y]; v25 = y; - if ( v8 == -1 ) - { + if (v8 == -1) { v9 = 0; - for ( i = 0; i < nummissiles; v9 = i++ + 1 ) - { + for (i = 0; i < nummissiles; v9 = i++ + 1) { v10 = missileactive[v9]; - if ( v10 >= MAXMISSILES ) + if (v10 >= MAXMISSILES) break; v11 = &missile[v10]; - if ( v11->_mix == v26 && v11->_miy == v7 && v11->_miPreFlag == del_flag && v11->_miDrawFlag ) - { + if (v11->_mix == v26 && v11->_miy == v7 && v11->_miPreFlag == del_flag && v11->_miDrawFlag) { v12 = (char *)v11->_miAnimData; - if ( !v12 ) + if (!v12) return; v13 = v11->_miAnimFrame; - if ( v13 < 1 || (unsigned int)*v12 > 0x32 || v13 > *v12 ) + if (v13 < 1 || (unsigned int)*v12 > 0x32 || v13 > *v12) return; v14 = sy + v11->_miyoff; v15 = sx + v11->_mixoff - v11->_miAnimWidth2; - if ( v11->_miUniqTrans ) - { + if (v11->_miUniqTrans) { Cl2DecodeFrm3(v15, v14, v12, v13, v11->_miAnimWidth, a5, a6, _LOBYTE(v11->_miUniqTrans) + 3); v7 = v25; - } - else - { + } else { v23 = v11->_miAnimWidth; v21 = v11->_miAnimFrame; - if ( v11->_miLightFlag ) + if (v11->_miLightFlag) Cl2DecodeLightTbl(v15, v14, v12, v21, v23, a5, a6); else Cl2DecodeFrm1(v15, v14, v12, v21, v23, a5, a6); } } } - } - else - { - v16 = &missile[v8-1]; - if ( v16->_miPreFlag == del_flag ) - { - if ( v16->_miDrawFlag ) - { + } else { + v16 = &missile[v8 - 1]; + if (v16->_miPreFlag == del_flag) { + if (v16->_miDrawFlag) { v17 = (char *)v16->_miAnimData; - if ( v17 ) - { + if (v17) { v18 = v16->_miAnimFrame; - if ( v18 >= 1 && (unsigned int)*v17 <= 0x32 && v18 <= *v17 ) - { + if (v18 >= 1 && (unsigned int)*v17 <= 0x32 && v18 <= *v17) { v19 = sy + v16->_miyoff; v20 = sx + v16->_mixoff - v16->_miAnimWidth2; - if ( v16->_miUniqTrans ) - { + if (v16->_miUniqTrans) { Cl2DecodeFrm3(v20, v19, v17, v18, v16->_miAnimWidth, a5, a6, LOBYTE(v16->_miUniqTrans) + 3); - } - else - { + } else { v24 = v16->_miAnimWidth; v22 = v16->_miAnimFrame; - if ( v16->_miLightFlag ) + if (v16->_miLightFlag) Cl2DecodeLightTbl(v20, v19, v17, v22, v24, a5, a6); else Cl2DecodeFrm1(v20, v19, v17, v22, v24, a5, a6); @@ -183,92 +165,77 @@ void __fastcall DrawMissile(int x, int y, int sx, int sy, int a5, int a6, int de void __fastcall DrawClippedMissile(int x, int y, int sx, int sy, int a5, int a6, int a7) { - int v7; // ebx - char v8; // al - int v9; // eax - int v10; // eax + int v7; // ebx + char v8; // al + int v9; // eax + int v10; // eax MissileStruct *v11; // eax - char *v12; // edi - int v13; // edx - int v14; // esi - int v15; // ecx + char *v12; // edi + int v13; // edx + int v14; // esi + int v15; // ecx MissileStruct *v16; // eax - char *v17; // edi - int v18; // edx - int v19; // esi - int v20; // ecx - int v21; // [esp-10h] [ebp-28h] - int v22; // [esp-10h] [ebp-28h] - int v23; // [esp-Ch] [ebp-24h] - int v24; // [esp-Ch] [ebp-24h] - int v25; // [esp+Ch] [ebp-Ch] - int v26; // [esp+10h] [ebp-8h] - int i; // [esp+14h] [ebp-4h] + char *v17; // edi + int v18; // edx + int v19; // esi + int v20; // ecx + int v21; // [esp-10h] [ebp-28h] + int v22; // [esp-10h] [ebp-28h] + int v23; // [esp-Ch] [ebp-24h] + int v24; // [esp-Ch] [ebp-24h] + int v25; // [esp+Ch] [ebp-Ch] + int v26; // [esp+10h] [ebp-8h] + int i; // [esp+14h] [ebp-4h] v26 = x; v7 = y; v8 = dMissile[x][y]; v25 = y; - if ( v8 == -1 ) - { + if (v8 == -1) { v9 = 0; - for ( i = 0; i < nummissiles; v9 = i++ + 1 ) - { + for (i = 0; i < nummissiles; v9 = i++ + 1) { v10 = missileactive[v9]; - if ( v10 >= MAXMISSILES ) + if (v10 >= MAXMISSILES) break; v11 = &missile[v10]; - if ( v11->_mix == v26 && v11->_miy == v7 && v11->_miPreFlag == a7 && v11->_miDrawFlag ) - { + if (v11->_mix == v26 && v11->_miy == v7 && v11->_miPreFlag == a7 && v11->_miDrawFlag) { v12 = (char *)v11->_miAnimData; - if ( !v12 ) + if (!v12) return; v13 = v11->_miAnimFrame; - if ( v13 < 1 || (unsigned int)*v12 > 0x32 || v13 > *v12 ) + if (v13 < 1 || (unsigned int)*v12 > 0x32 || v13 > *v12) return; v14 = sy + v11->_miyoff; v15 = sx + v11->_mixoff - v11->_miAnimWidth2; - if ( v11->_miUniqTrans ) - { + if (v11->_miUniqTrans) { Cl2DecodeFrm5(v15, v14, v12, v13, v11->_miAnimWidth, a5, a6, _LOBYTE(v11->_miUniqTrans) + 3); v7 = v25; - } - else - { + } else { v23 = v11->_miAnimWidth; v21 = v11->_miAnimFrame; - if ( v11->_miLightFlag ) + if (v11->_miLightFlag) Cl2DecodeFrm6(v15, v14, v12, v21, v23, a5, a6); else Cl2DecodeFrm4(v15, v14, v12, v21, v23, a5, a6); } } } - } - else - { - v16 = &missile[v8-1]; - if ( v16->_miPreFlag == a7 ) - { - if ( v16->_miDrawFlag ) - { + } else { + v16 = &missile[v8 - 1]; + if (v16->_miPreFlag == a7) { + if (v16->_miDrawFlag) { v17 = (char *)v16->_miAnimData; - if ( v17 ) - { + if (v17) { v18 = v16->_miAnimFrame; - if ( v18 >= 1 && (unsigned int)*v17 <= 0x32 && v18 <= *v17 ) - { + if (v18 >= 1 && (unsigned int)*v17 <= 0x32 && v18 <= *v17) { v19 = sy + v16->_miyoff; v20 = sx + v16->_mixoff - v16->_miAnimWidth2; - if ( v16->_miUniqTrans ) - { + if (v16->_miUniqTrans) { Cl2DecodeFrm5(v20, v19, v17, v18, v16->_miAnimWidth, a5, a6, LOBYTE(v16->_miUniqTrans) + 3); - } - else - { + } else { v24 = v16->_miAnimWidth; v22 = v16->_miAnimFrame; - if ( v16->_miLightFlag ) + if (v16->_miLightFlag) Cl2DecodeFrm6(v20, v19, v17, v22, v24, a5, a6); else Cl2DecodeFrm4(v20, v19, v17, v22, v24, a5, a6); @@ -282,113 +249,102 @@ void __fastcall DrawClippedMissile(int x, int y, int sx, int sy, int a5, int a6, void __fastcall DrawDeadPlayer(int x, int y, int sx, int sy, int a5, int a6, bool clipped) { - int v7; // ebx - int *v8; // esi - char *v9; // edi - int *v10; // eax - int v11; // ecx - int xa; // [esp+Ch] [ebp-4h] + int v7; // ebx + int *v8; // esi + char *v9; // edi + int *v10; // eax + int v11; // ecx + int xa; // [esp+Ch] [ebp-4h] int player_num; // [esp+28h] [ebp+18h] v7 = y; xa = x; - DrawPlrProc = (int (__fastcall *)(int, int, int, int, int, void *, int, int, int, int))DrawClippedPlayer; - if ( !clipped ) - DrawPlrProc = (int (__fastcall *)(int, int, int, int, int, void *, int, int, int, int))DrawPlayer; + DrawPlrProc = (int(__fastcall *)(int, int, int, int, int, void *, int, int, int, int))DrawClippedPlayer; + if (!clipped) + DrawPlrProc = (int(__fastcall *)(int, int, int, int, int, void *, int, int, int, int))DrawPlayer; v8 = &plr[0]._pHitPoints; v9 = &dFlags[x][y]; *v9 &= ~DFLAG_DEAD_PLAYER; player_num = 0; - do - { - if ( !*((_BYTE *)v8 - 379) || *v8 || *(v8 - 89) != currlevel || *(v8 - 88) != xa || *(v8 - 87) != v7 ) + do { + if (!*((_BYTE *)v8 - 379) || *v8 || *(v8 - 89) != currlevel || *(v8 - 88) != xa || *(v8 - 87) != v7) goto LABEL_14; v10 = (int *)*(v8 - 71); - if ( !v10 ) + if (!v10) break; v11 = *(v8 - 67); - if ( v11 < 1 || (unsigned int)*v10 > 0x32 || v11 > *v10 ) + if (v11 < 1 || (unsigned int)*v10 > 0x32 || v11 > *v10) break; *v9 |= DFLAG_DEAD_PLAYER; DrawPlrProc(player_num, xa, v7, sx + *(v8 - 78) - *(v8 - 65), sy + *(v8 - 77), v10, v11, *(v8 - 66), a5, a6); -LABEL_14: + LABEL_14: ++player_num; v8 += 5430; - } - while ( (signed int)v8 < (signed int)&plr[4]._pHitPoints ); + } while ((signed int)v8 < (signed int)&plr[4]._pHitPoints); } void __fastcall DrawPlayer(int pnum, int x, int y, int px, int py, unsigned char *animdata, int animframe, int animwidth, int a9, int a10) { - char *v10; // edx - int v11; // eax - char *v12; // ecx - int v13; // [esp+Ch] [ebp-4h] - int ya; // [esp+18h] [ebp+8h] + char *v10; // edx + int v11; // eax + char *v12; // ecx + int v13; // [esp+Ch] [ebp-4h] + int ya; // [esp+18h] [ebp+8h] int animdataa; // [esp+24h] [ebp+14h] v10 = &dFlags[x][y]; v11 = myplr; v13 = pnum; ya = (int)v10; - if ( *v10 & DFLAG_LIT || plr[myplr]._pInfraFlag || !setlevel && !currlevel ) - { + if (*v10 & DFLAG_LIT || plr[myplr]._pInfraFlag || !setlevel && !currlevel) { v12 = (char *)animdata; - if ( animdata ) - { - if ( animframe >= 1 && *(_DWORD *)animdata <= 0x32u && animframe <= *(_DWORD *)animdata ) - { - if ( v13 == pcursplr ) - { + if (animdata) { + if (animframe >= 1 && *(_DWORD *)animdata <= 0x32u && animframe <= *(_DWORD *)animdata) { + if (v13 == pcursplr) { Cl2DecodeFrm2(165, px, py, (char *)animdata, animframe, animwidth, a9, a10); v11 = myplr; v12 = (char *)animdata; v10 = (char *)ya; } - if ( v13 == v11 ) - { + if (v13 == v11) { Cl2DecodeFrm1(px, py, v12, animframe, animwidth, a9, a10); - if ( plr[v13].pManaShield ) + if (plr[v13].pManaShield) Cl2DecodeFrm1( - px + plr[v13]._pAnimWidth2 - misfiledata[9].mAnimWidth2[0], - py, - (char *)misfiledata[9].mAnimData[0], - 1, - misfiledata[9].mAnimWidth[0], - a9, - a10); - } - else if ( !(*v10 & DFLAG_LIT) || plr[v11]._pInfraFlag && light_table_index > 8 ) - { + px + plr[v13]._pAnimWidth2 - misfiledata[9].mAnimWidth2[0], + py, + (char *)misfiledata[9].mAnimData[0], + 1, + misfiledata[9].mAnimWidth[0], + a9, + a10); + } else if (!(*v10 & DFLAG_LIT) || plr[v11]._pInfraFlag && light_table_index > 8) { Cl2DecodeFrm3(px, py, v12, animframe, animwidth, a9, a10, 1); - if ( plr[v13].pManaShield ) + if (plr[v13].pManaShield) Cl2DecodeFrm3( - px + plr[v13]._pAnimWidth2 - misfiledata[9].mAnimWidth2[0], - py, - (char *)misfiledata[9].mAnimData[0], - 1, - misfiledata[9].mAnimWidth[0], - a9, - a10, - 1); - } - else - { + px + plr[v13]._pAnimWidth2 - misfiledata[9].mAnimWidth2[0], + py, + (char *)misfiledata[9].mAnimData[0], + 1, + misfiledata[9].mAnimWidth[0], + a9, + a10, + 1); + } else { animdataa = light_table_index; - if ( light_table_index >= 5 ) + if (light_table_index >= 5) light_table_index -= 5; else light_table_index = 0; Cl2DecodeLightTbl(px, py, v12, animframe, animwidth, a9, a10); - if ( plr[v13].pManaShield ) + if (plr[v13].pManaShield) Cl2DecodeLightTbl( - px + plr[v13]._pAnimWidth2 - misfiledata[9].mAnimWidth2[0], - py, - (char *)misfiledata[9].mAnimData[0], - 1, - misfiledata[9].mAnimWidth[0], - a9, - a10); + px + plr[v13]._pAnimWidth2 - misfiledata[9].mAnimWidth2[0], + py, + (char *)misfiledata[9].mAnimData[0], + 1, + misfiledata[9].mAnimWidth[0], + a9, + a10); light_table_index = animdataa; } } @@ -401,75 +357,66 @@ void __fastcall DrawPlayer(int pnum, int x, int y, int px, int py, unsigned char void __fastcall DrawClippedPlayer(int pnum, int x, int y, int px, int py, unsigned char *animdata, int animframe, int animwidth, int a9, int a10) { - char *v10; // edx - int v11; // eax - char *v12; // ecx - int v13; // [esp+Ch] [ebp-4h] - int ya; // [esp+18h] [ebp+8h] + char *v10; // edx + int v11; // eax + char *v12; // ecx + int v13; // [esp+Ch] [ebp-4h] + int ya; // [esp+18h] [ebp+8h] int animdataa; // [esp+24h] [ebp+14h] v10 = &dFlags[x][y]; v11 = myplr; v13 = pnum; ya = (int)v10; - if ( *v10 & DFLAG_LIT || plr[myplr]._pInfraFlag ) - { + if (*v10 & DFLAG_LIT || plr[myplr]._pInfraFlag) { v12 = (char *)animdata; - if ( animdata ) - { - if ( animframe >= 1 && *(_DWORD *)animdata <= 0x32u && animframe <= *(_DWORD *)animdata ) - { - if ( v13 == pcursplr ) - { + if (animdata) { + if (animframe >= 1 && *(_DWORD *)animdata <= 0x32u && animframe <= *(_DWORD *)animdata) { + if (v13 == pcursplr) { Cl2DecodeClrHL(165, px, py, (char *)animdata, animframe, animwidth, a9, a10); v11 = myplr; v12 = (char *)animdata; v10 = (char *)ya; } - if ( v13 == v11 ) - { + if (v13 == v11) { Cl2DecodeFrm4(px, py, v12, animframe, animwidth, a9, a10); - if ( plr[v13].pManaShield ) + if (plr[v13].pManaShield) Cl2DecodeFrm4( - px + plr[v13]._pAnimWidth2 - misfiledata[9].mAnimWidth2[0], - py, - (char *)misfiledata[9].mAnimData[0], - 1, - misfiledata[9].mAnimWidth[0], - a9, - a10); - } - else if ( !(*v10 & DFLAG_LIT) || plr[v11]._pInfraFlag && light_table_index > 8 ) - { + px + plr[v13]._pAnimWidth2 - misfiledata[9].mAnimWidth2[0], + py, + (char *)misfiledata[9].mAnimData[0], + 1, + misfiledata[9].mAnimWidth[0], + a9, + a10); + } else if (!(*v10 & DFLAG_LIT) || plr[v11]._pInfraFlag && light_table_index > 8) { Cl2DecodeFrm5(px, py, v12, animframe, animwidth, a9, a10, 1); - if ( plr[v13].pManaShield ) + if (plr[v13].pManaShield) Cl2DecodeFrm5( - px + plr[v13]._pAnimWidth2 - misfiledata[9].mAnimWidth2[0], - py, - (char *)misfiledata[9].mAnimData[0], - 1, - misfiledata[9].mAnimWidth[0], - a9, - a10, - 1); - } - else - { + px + plr[v13]._pAnimWidth2 - misfiledata[9].mAnimWidth2[0], + py, + (char *)misfiledata[9].mAnimData[0], + 1, + misfiledata[9].mAnimWidth[0], + a9, + a10, + 1); + } else { animdataa = light_table_index; - if ( light_table_index >= 5 ) + if (light_table_index >= 5) light_table_index -= 5; else light_table_index = 0; Cl2DecodeFrm6(px, py, v12, animframe, animwidth, a9, a10); - if ( plr[v13].pManaShield ) + if (plr[v13].pManaShield) Cl2DecodeFrm6( - px + plr[v13]._pAnimWidth2 - misfiledata[9].mAnimWidth2[0], - py, - (char *)misfiledata[9].mAnimData[0], - 1, - misfiledata[9].mAnimWidth[0], - a9, - a10); + px + plr[v13]._pAnimWidth2 - misfiledata[9].mAnimWidth2[0], + py, + (char *)misfiledata[9].mAnimData[0], + 1, + misfiledata[9].mAnimWidth[0], + a9, + a10); light_table_index = animdataa; } } @@ -481,44 +428,44 @@ void __fastcall DrawClippedPlayer(int pnum, int x, int y, int px, int py, unsign void __fastcall DrawView(int StartX, int StartY) { - if ( zoomflag ) + if (zoomflag) DrawGame(StartX, StartY); else DrawZoom(StartX, StartY); - if ( automapflag ) + if (automapflag) DrawAutomap(); - if ( invflag ) + if (invflag) DrawInv(); - else if ( sbookflag ) + else if (sbookflag) DrawSpellBook(); DrawDurIcon(); - if ( chrflag ) + if (chrflag) DrawChr(); - else if ( questlog ) + else if (questlog) DrawQuestLog(); - else if ( plr[myplr]._pStatPts && !spselflag ) + else if (plr[myplr]._pStatPts && !spselflag) DrawLevelUpIcon(); - if ( uitemflag ) + if (uitemflag) DrawUniqueInfo(); - if ( qtextflag ) + if (qtextflag) DrawQText(); - if ( spselflag ) + if (spselflag) DrawSpellList(); - if ( dropGoldFlag ) + if (dropGoldFlag) DrawGoldSplit(dropGoldValue); - if ( helpflag ) + if (helpflag) DrawHelp(); - if ( msgflag ) + if (msgflag) DrawDiabloMsg(); - if ( deathflag ) + if (deathflag) RedBack(); - else if ( PauseMode ) + else if (PauseMode) gmenu_draw_pause(); DrawPlrMsg(); @@ -539,20 +486,20 @@ void __fastcall DrawView(int StartX, int StartY) void __fastcall DrawGame(int x, int y) { - int v2; // esi - int v3; // ebx - int v4; // edi - int v5; // edi - int v6; // esi - int v7; // edi - int v8; // esi - int v9; // edi - int v10; // esi + int v2; // esi + int v3; // ebx + int v4; // edi + int v5; // edi + int v6; // esi + int v7; // edi + int v8; // esi + int v9; // edi + int v10; // esi signed int v11; // [esp+Ch] [ebp-10h] - signed int a6; // [esp+10h] [ebp-Ch] + 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] + signed int a5; // [esp+14h] [ebp-8h] + int ya; // [esp+18h] [ebp-4h] dword_5C2FF8 = 10; v2 = ScrollInfo._sxoff + 64; @@ -564,64 +511,60 @@ void __fastcall DrawGame(int x, int y) scr_pix_height = 352; dword_5C2FFC = 11; v11 = 8; - if ( chrflag || questlog ) - { + if (chrflag || questlog) { ya = y - 3; v3 += 2; v2 = ScrollInfo._sxoff + 352; a5 = 6; } - if ( invflag || sbookflag ) - { + if (invflag || sbookflag) { ya -= 2; v3 += 2; v2 -= 32; a5 = 6; } - switch ( ScrollInfo._sdir ) - { - case DIR_SW: - goto LABEL_9; - case DIR_W: - ++a5; -LABEL_9: - v4 = ScrollInfo._syoff + 143; - --v3; - --ya; - goto LABEL_15; - case DIR_NW: - goto LABEL_13; - case DIR_N: - v11 = 9; - goto LABEL_13; - case DIR_NE: - goto LABEL_15; - case DIR_E: - v11 = 9; - goto LABEL_12; - case DIR_SE: -LABEL_12: - v2 -= 64; - --v3; - ++ya; -LABEL_13: - ++a5; - break; - case DIR_OMNI: - v2 -= 64; - v4 = ScrollInfo._syoff + 143; - v3 -= 2; - ++a5; -LABEL_15: - v11 = 9; - break; - default: - break; + switch (ScrollInfo._sdir) { + case DIR_SW: + goto LABEL_9; + case DIR_W: + ++a5; + LABEL_9: + v4 = ScrollInfo._syoff + 143; + --v3; + --ya; + goto LABEL_15; + case DIR_NW: + goto LABEL_13; + case DIR_N: + v11 = 9; + goto LABEL_13; + case DIR_NE: + goto LABEL_15; + case DIR_E: + v11 = 9; + goto LABEL_12; + case DIR_SE: + LABEL_12: + v2 -= 64; + --v3; + ++ya; + LABEL_13: + ++a5; + break; + case DIR_OMNI: + v2 -= 64; + v4 = ScrollInfo._syoff + 143; + v3 -= 2; + ++a5; + LABEL_15: + v11 = 9; + break; + default: + break; } a6 = 0; gpBufEnd = (unsigned char *)gpBuffer + screen_y_times_768[160]; - do - { + do { scrollrt_draw_upper(v3, ya++, v2, v4, a5, a6, 0); v5 = v4 + 16; v6 = v2 - 32; @@ -629,13 +572,10 @@ LABEL_15: v2 = v6 + 32; v4 = v5 + 16; ++a6; - } - while ( a6 < 4 ); + } while (a6 < 4); gpBufEnd = (unsigned char *)gpBuffer + screen_y_times_768[512]; - if ( v11 > 0 ) - { - do - { + if (v11 > 0) { + do { scrollrt_draw_lower(v3, ya++, v2, v4, a5, 0); v7 = v4 + 16; v8 = v2 - 32; @@ -643,13 +583,11 @@ LABEL_15: v2 = v8 + 32; v4 = v7 + 16; --v11; - } - while ( v11 ); + } while (v11); } arch_draw_type = 0; a6a = 0; - do - { + do { scrollrt_draw_lower_2(v3, ya++, v2, v4, a5, a6a, 0); v9 = v4 + 16; v10 = v2 - 32; @@ -657,8 +595,7 @@ LABEL_15: v2 = v10 + 32; v4 = v9 + 16; ++a6a; - } - while ( a6a < 4 ); + } while (a6a < 4); } // 4B8968: using guessed type int sbookflag; // 5C2FF8: using guessed type int dword_5C2FF8; @@ -671,68 +608,65 @@ LABEL_15: void __fastcall scrollrt_draw_lower(int x, int y, int sx, int sy, int a5, int some_flag) { - unsigned int v6; // edi - unsigned int v7; // ebx + unsigned int v6; // edi + unsigned int v7; // ebx unsigned short *v8; // esi - unsigned int v9; // ebx - int v10; // eax - int v11; // ecx - int v12; // edx - char *v13; // edx - int v14; // edi - int v15; // eax + unsigned int v9; // ebx + int v10; // eax + int v11; // ecx + int v12; // edx + char *v13; // edx + int v14; // edi + int v15; // eax unsigned char *v16; // edi unsigned char *v17; // edi unsigned char *v18; // edi unsigned char *v19; // edi - int v20; // eax - int v21; // edi - int v22; // ecx - int v23; // ecx - int v24; // eax - int *v25; // ebx - int v26; // ecx - int v27; // eax - int v28; // edi + int v20; // eax + int v21; // edi + int v22; // ecx + int v23; // ecx + int v24; // eax + int *v25; // ebx + int v26; // ecx + int v27; // eax + int v28; // edi unsigned char *v29; // edi - int v30; // eax - int v31; // eax - int v32; // eax - int v33; // ecx - int v34; // eax - int *v35; // edi - int v36; // ecx - int v37; // eax - char *v38; // edi + int v30; // eax + int v31; // eax + int v32; // eax + int v33; // ecx + int v34; // eax + int *v35; // edi + int v36; // ecx + int v37; // eax + char *v38; // edi unsigned char *v39; // edi - int v40; // eax + int v40; // eax unsigned char *v41; // edi unsigned char *v42; // edi unsigned char *v43; // edi unsigned char *v44; // edi - int v45; // eax - int v46; // [esp+Ch] [ebp-10h] - int v47; // [esp+10h] [ebp-Ch] - signed int sya; // [esp+14h] [ebp-8h] - unsigned int sxa; // [esp+18h] [ebp-4h] - signed int i; // [esp+2Ch] [ebp+10h] - int *v51; // [esp+2Ch] [ebp+10h] + int v45; // eax + int v46; // [esp+Ch] [ebp-10h] + int v47; // [esp+10h] [ebp-Ch] + signed int sya; // [esp+14h] [ebp-8h] + unsigned int sxa; // [esp+18h] [ebp-4h] + signed int i; // [esp+2Ch] [ebp+10h] + int *v51; // [esp+2Ch] [ebp+10h] v6 = y; v7 = x; sya = y; sxa = x; v8 = (unsigned short *)((char *)dpiece_defs_map_1 + 32 * gendung_get_dpiece_num_from_coord(x, y)); - if ( some_flag ) - { - if ( v6 < 0x70 && v7 < 0x70 ) - { + if (some_flag) { + if (v6 < 0x70 && v7 < 0x70) { v9 = v7; v10 = dPiece[0][v9 * 112 + v6]; light_table_index = dTransVal[v9][v6]; level_piece_id = v10; - if ( v10 ) - { + if (v10) { v11 = (unsigned char)(nTransTable[v10] & TransList[dung_map[v9][v6]]); arch_draw_type = 2; v12 = screen_y_times_768[sy]; @@ -740,29 +674,29 @@ void __fastcall scrollrt_draw_lower(int x, int y, int sx, int sy, int a5, int so v13 = (char *)gpBuffer + v12; level_cel_block = v8[1]; v14 = (int)&v13[sx + 32]; - if ( level_cel_block ) + if (level_cel_block) drawLowerScreen((unsigned char *)&v13[sx + 32]); v15 = v8[3]; arch_draw_type = 0; v16 = (unsigned char *)(v14 - 24576); level_cel_block = v15; - if ( v15 ) + if (v15) drawLowerScreen(v16); v17 = v16 - 24576; level_cel_block = v8[5]; - if ( level_cel_block ) + if (level_cel_block) drawLowerScreen(v17); v18 = v17 - 24576; level_cel_block = v8[7]; - if ( level_cel_block ) + if (level_cel_block) drawLowerScreen(v18); v19 = v18 - 24576; level_cel_block = v8[9]; - if ( level_cel_block ) + if (level_cel_block) drawLowerScreen(v19); v20 = v8[11]; level_cel_block = v8[11]; - if ( v20 && leveltype == DTYPE_HELL ) + if (v20 && leveltype == DTYPE_HELL) drawLowerScreen(v19 - 24576); v21 = sy; scrollrt_draw_clipped_dungeon((char *)gpBuffer + screen_y_times_768[sy] + sx, sxa, sya, sx, sy, 0); @@ -771,7 +705,7 @@ void __fastcall scrollrt_draw_lower(int x, int y, int sx, int sy, int a5, int so world_draw_black_tile((unsigned char *)gpBuffer + screen_y_times_768[sy] + sx); } v21 = sy; -LABEL_21: + LABEL_21: ++sxa; --sya; sx += 64; @@ -782,23 +716,19 @@ LABEL_21: v21 = sy; LABEL_23: v46 = a5; - if ( a5 ) - { + if (a5) { v22 = 112 * sxa; v47 = 112 * sxa; - do - { + do { --v46; - if ( sya < 0 || v22 >= MAXDUNX * MAXDUNY ) + if (sya < 0 || v22 >= MAXDUNX * MAXDUNY) break; - if ( sya < 112 && v22 >= 0 ) - { + if (sya < 112 && v22 >= 0) { v23 = sya + v22; v24 = dPiece[0][v23]; light_table_index = dTransVal[0][v23]; level_piece_id = v24; - if ( v24 ) - { + if (v24) { v25 = &screen_y_times_768[v21]; v26 = (unsigned char)(nTransTable[v24] & TransList[dung_map[0][v23]]); v27 = *v8; @@ -807,32 +737,29 @@ LABEL_23: arch_draw_type = 1; level_cel_block = v27; v29 = (unsigned char *)gpBuffer + v28 + sx; - if ( v27 ) + if (v27) drawLowerScreen(v29); v30 = v8[1]; arch_draw_type = 2; level_cel_block = v30; - if ( v30 ) + if (v30) drawLowerScreen(v29 + 32); arch_draw_type = 0; v31 = 2; - for ( i = 2; i < dword_5A5594; i += 2 ) - { + for (i = 2; i < dword_5A5594; i += 2) { v29 -= 24576; level_cel_block = v8[v31]; - if ( level_cel_block ) + if (level_cel_block) drawLowerScreen(v29); v32 = v8[i + 1]; level_cel_block = v8[i + 1]; - if ( v32 ) + if (v32) drawLowerScreen(v29 + 32); v31 = i + 2; } scrollrt_draw_clipped_dungeon((char *)gpBuffer + *v25 + sx, sxa, sya, sx, sy, 1); v21 = sy; - } - else - { + } else { world_draw_black_tile((unsigned char *)gpBuffer + screen_y_times_768[v21] + sx); } v22 = v47; @@ -843,17 +770,14 @@ LABEL_23: --sya; v8 += 16; v47 = v22; - } - while ( v46 ); + } while (v46); } - if ( some_flag && (unsigned int)sya < 0x70 && sxa < 0x70 ) - { + if (some_flag && (unsigned int)sya < 0x70 && sxa < 0x70) { v33 = sya + 112 * sxa; v34 = dPiece[0][v33]; light_table_index = dTransVal[0][v33]; level_piece_id = v34; - if ( v34 ) - { + if (v34) { v35 = &screen_y_times_768[v21]; v36 = (unsigned char)(nTransTable[v34] & TransList[dung_map[0][v33]]); v37 = *v8; @@ -863,37 +787,34 @@ LABEL_23: arch_draw_type = 1; level_cel_block = v37; v39 = (unsigned char *)&v38[sx]; - if ( v37 ) + if (v37) drawLowerScreen(v39); v40 = v8[2]; arch_draw_type = 0; v41 = v39 - 24576; level_cel_block = v40; - if ( v40 ) + if (v40) drawLowerScreen(v41); v42 = v41 - 24576; level_cel_block = v8[4]; - if ( level_cel_block ) + if (level_cel_block) drawLowerScreen(v42); v43 = v42 - 24576; level_cel_block = v8[6]; - if ( level_cel_block ) + if (level_cel_block) drawLowerScreen(v43); v44 = v43 - 24576; level_cel_block = v8[8]; - if ( level_cel_block ) + if (level_cel_block) drawLowerScreen(v44); v45 = v8[10]; level_cel_block = v8[10]; - if ( v45 ) - { - if ( leveltype == DTYPE_HELL ) + if (v45) { + if (leveltype == DTYPE_HELL) drawLowerScreen(v44 - 24576); } scrollrt_draw_clipped_dungeon((char *)gpBuffer + *v51 + sx, sxa, sya, sx, sy, 0); - } - else - { + } else { world_draw_black_tile((unsigned char *)gpBuffer + screen_y_times_768[v21] + sx); } } @@ -906,51 +827,51 @@ LABEL_23: void __fastcall scrollrt_draw_clipped_dungeon(char *a1, int sx, int sy, int a4, int a5, int a6) { - int v6; // eax - char v7; // bl - char v8; // cl - char v9; // dl - int *v10; // eax - DeadStruct *v11; // eax - int *v12; // esi - int v13; // ecx - int v14; // edx - char v15; // bl - ItemStruct *v16; // esi - char *v17; // eax - signed int v18; // ebx - int v19; // ebx - unsigned int v20; // ecx - PlayerStruct *v21; // esi - int v22; // esi - int v23; // eax + int v6; // eax + char v7; // bl + char v8; // cl + char v9; // dl + int *v10; // eax + DeadStruct *v11; // eax + int *v12; // esi + int v13; // ecx + int v14; // edx + char v15; // bl + ItemStruct *v16; // esi + char *v17; // eax + signed int v18; // ebx + int v19; // ebx + unsigned int v20; // ecx + PlayerStruct *v21; // esi + int v22; // esi + int v23; // eax MonsterStruct *v24; // esi - CMonster *v25; // ecx - int v26; // ebx - int v27; // edi - unsigned int v28; // ecx - PlayerStruct *v29; // esi - int v30; // esi - int v31; // eax + CMonster *v25; // ecx + int v26; // ebx + int v27; // edi + unsigned int v28; // ecx + PlayerStruct *v29; // esi + int v30; // esi + int v31; // eax MonsterStruct *v32; // esi - CMonster *v33; // ecx - int v34; // ebx - int v35; // edi - ItemStruct *v36; // esi - char *v37; // ecx - signed int v38; // ebx - int v39; // ebx - int v40; // [esp+Ch] [ebp-18h] - int v41; // [esp+10h] [ebp-14h] - char *dst_buf; // [esp+14h] [ebp-10h] - int a1a; // [esp+18h] [ebp-Ch] - char v44; // [esp+1Dh] [ebp-7h] - char v45; // [esp+1Eh] [ebp-6h] - char v46; // [esp+1Fh] [ebp-5h] - char v47; // [esp+20h] [ebp-4h] - char v48; // [esp+21h] [ebp-3h] - char v49; // [esp+22h] [ebp-2h] - char v50; // [esp+23h] [ebp-1h] + CMonster *v33; // ecx + int v34; // ebx + int v35; // edi + ItemStruct *v36; // esi + char *v37; // ecx + signed int v38; // ebx + int v39; // ebx + int v40; // [esp+Ch] [ebp-18h] + int v41; // [esp+10h] [ebp-14h] + char *dst_buf; // [esp+14h] [ebp-10h] + int a1a; // [esp+18h] [ebp-Ch] + char v44; // [esp+1Dh] [ebp-7h] + char v45; // [esp+1Eh] [ebp-6h] + char v46; // [esp+1Fh] [ebp-5h] + char v47; // [esp+20h] [ebp-4h] + char v48; // [esp+21h] [ebp-3h] + char v49; // [esp+22h] [ebp-2h] + char v50; // [esp+23h] [ebp-1h] a1a = sx; dst_buf = a1; @@ -968,199 +889,167 @@ void __fastcall scrollrt_draw_clipped_dungeon(char *a1, int sx, int sy, int a4, v45 = v8; v40 = *v10; v41 = *(v10 - 1); - if ( visiondebug && v50 & DFLAG_LIT ) + if (visiondebug && v50 & DFLAG_LIT) Cel2DecodeHdrOnly(dst_buf, (char *)pSquareCel, 1, 64, 0, 8); - if ( MissilePreFlag && v50 & DFLAG_MISSILE ) + if (MissilePreFlag && v50 & DFLAG_MISSILE) DrawClippedMissile(a1a, sy, a4, a5, 0, 8, 1); - if ( light_table_index < lightmax ) - { - if ( v7 ) - { + if (light_table_index < lightmax) { + if (v7) { v11 = &dead[(v7 & 0x1F) - 1]; v12 = (int *)v11->_deadData[(v7 >> 5) & 7]; v13 = a4 - v11->_deadWidth2; - if ( v12 ) - { + if (v12) { v14 = v11->_deadFrame; - if ( v14 >= 1 && (unsigned int)*v12 <= 0x32 && v14 <= *v12 ) - { + if (v14 >= 1 && (unsigned int)*v12 <= 0x32 && v14 <= *v12) { v15 = v11->_deadtrans; - if ( v15 ) + if (v15) Cl2DecodeFrm5(v13, a5, (char *)v12, v14, v11->_deadWidth, 0, 8, v15); else Cl2DecodeFrm6(v13, a5, (char *)v12, v14, v11->_deadWidth, 0, 8); } } } - if ( v47 ) + if (v47) DrawClippedObject(a1a, sy, a4, a5, 1, 0, 8); } - if ( v49 ) - { - v16 = &item[v49-1]; - if ( !v16->_iPostDraw && (unsigned char)v49 <= MAXITEMS ) - { + if (v49) { + v16 = &item[v49 - 1]; + if (!v16->_iPostDraw && (unsigned char)v49 <= MAXITEMS) { v17 = (char *)v16->_iAnimData; - if ( v17 ) - { + if (v17) { v18 = v16->_iAnimFrame; - if ( v18 >= 1 && *(_DWORD *)v17 <= 0x32u && v18 <= *(_DWORD *)v17 ) - { + if (v18 >= 1 && *(_DWORD *)v17 <= 0x32u && v18 <= *(_DWORD *)v17) { v19 = a4 - v16->_iAnimWidth2; - if ( v49 - 1 == pcursitem ) + if (v49 - 1 == pcursitem) CelDrawHdrClrHL(ICOL_BLUE, v19, a5, v17, v16->_iAnimFrame, v16->_iAnimWidth, 0, 8); Cel2DecodeHdrLight(v19, a5, (char *)v16->_iAnimData, v16->_iAnimFrame, v16->_iAnimWidth, 0, 8); } } } } - if ( v50 & DFLAG_PLAYER ) - { + if (v50 & DFLAG_PLAYER) { v20 = -1 - v45; - if ( v20 < 4 ) - { + if (v20 < 4) { v21 = &plr[v20]; DrawClippedPlayer( - v20, - a1a, - sy - 1, - a4 + v21->_pxoff - v21->_pAnimWidth2, - a5 + v21->_pyoff, - v21->_pAnimData, - v21->_pAnimFrame, - v21->_pAnimWidth, - 0, - 8); - if ( a6 ) - { + v20, + a1a, + sy - 1, + a4 + v21->_pxoff - v21->_pAnimWidth2, + a5 + v21->_pyoff, + v21->_pAnimData, + v21->_pAnimFrame, + v21->_pAnimWidth, + 0, + 8); + if (a6) { v22 = v21->_peflag; - if ( v22 ) - { - if ( v22 == 2 ) + if (v22) { + if (v22 == 2) scrollrt_draw_clipped_e_flag(dst_buf - 12384, a1a - 2, sy + 1, a4 - 96, a5 - 16); scrollrt_draw_clipped_e_flag(dst_buf - 64, a1a - 1, sy + 1, a4 - 64, a5); } } } } - if ( v50 & DFLAG_MONSTER && (v50 & DFLAG_LIT || plr[myplr]._pInfraFlag) && v41 < 0 ) - { + if (v50 & DFLAG_MONSTER && (v50 & DFLAG_LIT || plr[myplr]._pInfraFlag) && v41 < 0) { v23 = -1 - v41; draw_monster_num = -1 - v41; - if ( (unsigned int)(-1 - v41) < MAXMONSTERS ) - { + if ((unsigned int)(-1 - v41) < MAXMONSTERS) { v24 = &monster[v23]; - if ( !(v24->_mFlags & 1) ) - { + if (!(v24->_mFlags & 1)) { v25 = v24->MType; - if ( v25 ) - { + if (v25) { v26 = a5 + v24->_myoff; v27 = a4 + v24->_mxoff - v25->flags_2; - if ( v23 == pcursmonst ) - { + if (v23 == pcursmonst) { Cl2DecodeClrHL(233, v27, v26, (char *)v24->_mAnimData, v24->_mAnimFrame, v25->flags_1, 0, 8); v23 = draw_monster_num; } DrawClippedMonster(a1a, sy, v27, v26, v23, 0, 8); - if ( a6 && v24->_meflag ) + if (a6 && v24->_meflag) scrollrt_draw_clipped_e_flag(dst_buf - 64, a1a - 1, sy + 1, a4 - 64, a5); } } } } - if ( v50 & 4 ) + if (v50 & 4) DrawDeadPlayer(a1a, sy, a4, a5, 0, 8, 1); - if ( v48 > 0 ) - { + if (v48 > 0) { v28 = v48 - 1; - if ( v28 < 4 ) - { + if (v28 < 4) { v29 = &plr[v28]; DrawClippedPlayer( - v28, - a1a, - sy, - a4 + v29->_pxoff - v29->_pAnimWidth2, - a5 + v29->_pyoff, - v29->_pAnimData, - v29->_pAnimFrame, - v29->_pAnimWidth, - 0, - 8); - if ( a6 ) - { + v28, + a1a, + sy, + a4 + v29->_pxoff - v29->_pAnimWidth2, + a5 + v29->_pyoff, + v29->_pAnimData, + v29->_pAnimFrame, + v29->_pAnimWidth, + 0, + 8); + if (a6) { v30 = v29->_peflag; - if ( v30 ) - { - if ( v30 == 2 ) + if (v30) { + if (v30 == 2) scrollrt_draw_clipped_e_flag(dst_buf - 12384, a1a - 2, sy + 1, a4 - 96, a5 - 16); scrollrt_draw_clipped_e_flag(dst_buf - 64, a1a - 1, sy + 1, a4 - 64, a5); } } } } - if ( v40 > 0 && (v50 & 0x40 || plr[myplr]._pInfraFlag) ) - { + if (v40 > 0 && (v50 & 0x40 || plr[myplr]._pInfraFlag)) { v31 = v40 - 1; draw_monster_num = v40 - 1; - if ( (unsigned int)(v40 - 1) < MAXMONSTERS ) - { + if ((unsigned int)(v40 - 1) < MAXMONSTERS) { v32 = &monster[v31]; - if ( !(v32->_mFlags & 1) ) - { + if (!(v32->_mFlags & 1)) { v33 = v32->MType; - if ( v33 ) - { + if (v33) { v34 = a5 + v32->_myoff; v35 = a4 + v32->_mxoff - v33->flags_2; - if ( v31 == pcursmonst ) - { + if (v31 == pcursmonst) { Cl2DecodeClrHL(233, v35, v34, (char *)v32->_mAnimData, v32->_mAnimFrame, v33->flags_1, 0, 8); v31 = draw_monster_num; } DrawClippedMonster(a1a, sy, v35, v34, v31, 0, 8); - if ( a6 && v32->_meflag ) + if (a6 && v32->_meflag) scrollrt_draw_clipped_e_flag(dst_buf - 64, a1a - 1, sy + 1, a4 - 64, a5); } } } } - if ( v50 & 1 ) + if (v50 & 1) DrawClippedMissile(a1a, sy, a4, a5, 0, 8, 0); - if ( v47 && light_table_index < lightmax ) + if (v47 && light_table_index < lightmax) DrawClippedObject(a1a, sy, a4, a5, 0, 0, 8); - if ( v49 ) - { - v36 = &item[v49-1]; - if ( v36->_iPostDraw ) - { - if ( (unsigned char)v49 <= MAXITEMS ) - { + if (v49) { + v36 = &item[v49 - 1]; + if (v36->_iPostDraw) { + if ((unsigned char)v49 <= MAXITEMS) { v37 = (char *)v36->_iAnimData; - if ( v37 ) - { + if (v37) { v38 = v36->_iAnimFrame; - if ( v38 >= 1 && *(_DWORD *)v37 <= 0x32u && v38 <= *(_DWORD *)v37 ) - { + if (v38 >= 1 && *(_DWORD *)v37 <= 0x32u && v38 <= *(_DWORD *)v37) { v39 = a4 - v36->_iAnimWidth2; - if ( v49 - 1 == pcursitem ) + if (v49 - 1 == pcursitem) CelDrawHdrClrHL(ICOL_BLUE, v39, a5, v37, v36->_iAnimFrame, v36->_iAnimWidth, 0, 8); Cel2DecodeHdrLight( - v39, - a5, - (char *)v36->_iAnimData, - v36->_iAnimFrame, - v36->_iAnimWidth, - 0, - 8); + v39, + a5, + (char *)v36->_iAnimData, + v36->_iAnimFrame, + v36->_iAnimWidth, + 0, + 8); } } } } } - if ( v46 ) - { + if (v46) { cel_transparency_active = (unsigned char)TransList[v44]; Cel2DecodeLightTrans(dst_buf, (char *)level_special_cel, v46, 64, 0, 8); } @@ -1175,49 +1064,40 @@ void __fastcall scrollrt_draw_clipped_dungeon(char *a1, int sx, int sy, int a4, void __fastcall DrawClippedMonster(int x, int y, int a3, int a4, int mon_id, int a6, int a7) { - int v7; // eax - char *v8; // esi + int v7; // eax + char *v8; // esi signed int v9; // ebx - char v10; // cl + char v10; // cl CMonster *v11; // eax - char mon_ida; // [esp+1Ch] [ebp+10h] + char mon_ida; // [esp+1Ch] [ebp+10h] - if ( (unsigned int)mon_id < MAXMONSTERS ) - { + if ((unsigned int)mon_id < MAXMONSTERS) { v7 = mon_id; v8 = (char *)monster[mon_id]._mAnimData; - if ( v8 ) - { + if (v8) { v9 = monster[v7]._mAnimFrame; - if ( v9 >= 1 && (unsigned int)*v8 <= 0x32 && v9 <= *v8 ) - { - if ( dFlags[x][y] & DFLAG_LIT ) - { + if (v9 >= 1 && (unsigned int)*v8 <= 0x32 && v9 <= *v8) { + if (dFlags[x][y] & DFLAG_LIT) { v10 = 0; mon_ida = 0; - if ( monster[v7]._uniqtype ) - { + if (monster[v7]._uniqtype) { v10 = monster[v7]._uniqtrans + 4; mon_ida = monster[v7]._uniqtrans + 4; } - if ( monster[v7]._mmode == MM_STONE ) - { + if (monster[v7]._mmode == MM_STONE) { v10 = 2; mon_ida = 2; } - if ( plr[myplr]._pInfraFlag && light_table_index > 8 ) - { + if (plr[myplr]._pInfraFlag && light_table_index > 8) { v10 = 1; mon_ida = 1; } v11 = monster[v7].MType; - if ( v10 ) + if (v10) Cl2DecodeFrm5(a3, a4, v8, v9, v11->flags_1, a6, a7, mon_ida); else Cl2DecodeFrm6(a3, a4, v8, v9, v11->flags_1, a6, a7); - } - else - { + } else { Cl2DecodeFrm5(a3, a4, v8, v9, monster[v7].MType->flags_1, a6, a7, 1); } } @@ -1228,29 +1108,28 @@ void __fastcall DrawClippedMonster(int x, int y, int a3, int a4, int mon_id, int void __fastcall DrawClippedObject(int x, int y, int a3, int a4, int pre_flag, int a6, int dir) { - int v7; // edi - char v8; // al + int v7; // edi + char v8; // al unsigned char v9; // dl - int v10; // esi - int v11; // ebx - int v12; // edi - int v13; // eax - int v14; // ecx - char *v15; // eax - signed int v16; // ecx - char *v17; // [esp-14h] [ebp-24h] - int v18; // [esp-10h] [ebp-20h] - int v19; // [esp-Ch] [ebp-1Ch] - char v20; // [esp+Fh] [ebp-1h] + int v10; // esi + int v11; // ebx + int v12; // edi + int v13; // eax + int v14; // ecx + char *v15; // eax + signed int v16; // ecx + char *v17; // [esp-14h] [ebp-24h] + int v18; // [esp-10h] [ebp-20h] + int v19; // [esp-Ch] [ebp-1Ch] + char v20; // [esp+Fh] [ebp-1h] v7 = y; v8 = dObject[x][y]; - if ( v8 <= 0 ) - { + if (v8 <= 0) { v9 = -1 - v8; v10 = (char)(-1 - v8); v20 = -1 - v8; - if ( object[v10]._oPreFlag != pre_flag ) + if (object[v10]._oPreFlag != pre_flag) return; dir = 8; v13 = object[v10]._ox - x; @@ -1258,31 +1137,26 @@ void __fastcall DrawClippedObject(int x, int y, int a3, int a4, int pre_flag, in v12 = a3 + 32 * v13 - object[v10]._oAnimWidth2 - 32 * v14; v11 = a4 + 16 * (v14 + v13); a6 = 0; - } - else - { + } else { v9 = v8 - 1; v10 = (char)(v8 - 1); v20 = v8 - 1; - if ( object[v10]._oPreFlag != pre_flag ) + if (object[v10]._oPreFlag != pre_flag) return; v11 = a4; v12 = a3 - object[v10]._oAnimWidth2; } - if ( v9 < MAXOBJECTS ) - { + if (v9 < MAXOBJECTS) { v15 = (char *)object[v10]._oAnimData; - if ( v15 ) - { + if (v15) { v16 = object[v10]._oAnimFrame; - if ( v16 >= 1 && *(_DWORD *)v15 <= 0x32u && v16 <= *(_DWORD *)v15 ) - { - if ( v20 == pcursobj ) + if (v16 >= 1 && *(_DWORD *)v15 <= 0x32u && v16 <= *(_DWORD *)v15) { + if (v20 == pcursobj) CelDrawHdrClrHL(194, v12, v11, v15, v16, object[v10]._oAnimWidth, a6, dir); v19 = object[v10]._oAnimWidth; v18 = object[v10]._oAnimFrame; v17 = (char *)object[v10]._oAnimData; - if ( object[v10]._oLight ) + if (object[v10]._oLight) Cel2DecodeHdrLight(v12, v11, v17, v18, v19, a6, dir); else Cel2DrawHdrOnly(v12, v11, v17, v18, v19, a6, dir); @@ -1294,23 +1168,23 @@ void __fastcall DrawClippedObject(int x, int y, int a3, int a4, int pre_flag, in void __fastcall scrollrt_draw_clipped_e_flag(char *buffer, int x, int y, int a4, int a5) { - int v5; // eax - int v6; // ebx - int v7; // ecx - int v8; // esi - int v9; // eax - int v10; // edi - int v11; // eax - int v12; // eax - unsigned short *v13; // esi - int v14; // eax - int v15; // eax - int v16; // eax - int v17; // eax - int v18; // [esp+Ch] [ebp-14h] - int xa; // [esp+10h] [ebp-10h] - int i; // [esp+14h] [ebp-Ch] - unsigned char *a1; // [esp+18h] [ebp-8h] + int v5; // eax + int v6; // ebx + int v7; // ecx + int v8; // esi + int v9; // eax + int v10; // edi + int v11; // eax + int v12; // eax + unsigned short *v13; // esi + int v14; // eax + int v15; // eax + int v16; // eax + int v17; // eax + int v18; // [esp+Ch] [ebp-14h] + int xa; // [esp+10h] [ebp-10h] + int i; // [esp+14h] [ebp-Ch] + unsigned char *a1; // [esp+18h] [ebp-8h] unsigned char *pbDst; // [esp+1Ch] [ebp-4h] xa = x; @@ -1331,25 +1205,24 @@ void __fastcall scrollrt_draw_clipped_e_flag(char *buffer, int x, int y, int a4, v13 = (unsigned short *)((char *)dpiece_defs_map_1 + 32 * v12); v14 = *v13; level_cel_block = *v13; - if ( v14 ) + if (v14) drawLowerScreen(a1); v15 = v13[1]; arch_draw_type = 2; level_cel_block = v15; - if ( v15 ) + if (v15) drawLowerScreen(a1 + 32); arch_draw_type = 0; pbDst = a1; v16 = 2; - for ( i = 2; i < dword_5A5594; i += 2 ) - { + for (i = 2; i < dword_5A5594; i += 2) { pbDst -= 24576; level_cel_block = v13[v16]; - if ( level_cel_block ) + if (level_cel_block) drawLowerScreen(pbDst); v17 = v13[i + 1]; level_cel_block = v13[i + 1]; - if ( v17 ) + if (v17) drawLowerScreen(pbDst + 32); v16 = i + 2; } @@ -1366,33 +1239,33 @@ void __fastcall scrollrt_draw_clipped_e_flag(char *buffer, int x, int y, int a4, void __fastcall scrollrt_draw_lower_2(int x, int y, int sx, int sy, int a5, int a6, int some_flag) { - signed int v7; // ebx - int v8; // edi - int v9; // ecx - int v10; // eax - int v11; // eax - int v12; // eax - int v13; // ecx - int v14; // ecx - int v15; // eax - unsigned char *v16; // ebx - int v17; // eax - int v18; // eax - int v19; // ecx - int v20; // eax - int v21; // eax - int v22; // eax - int v23; // [esp+Ch] [ebp-14h] + signed int v7; // ebx + int v8; // edi + int v9; // ecx + int v10; // eax + int v11; // eax + int v12; // eax + int v13; // ecx + int v14; // ecx + int v15; // eax + unsigned char *v16; // ebx + int v17; // eax + int v18; // eax + int v19; // ecx + int v20; // eax + int v21; // eax + int v22; // eax + int v23; // [esp+Ch] [ebp-14h] unsigned short *v24; // [esp+10h] [ebp-10h] - int v25; // [esp+10h] [ebp-10h] - int a1; // [esp+14h] [ebp-Ch] - unsigned char *a1a; // [esp+14h] [ebp-Ch] - unsigned char *a1b; // [esp+14h] [ebp-Ch] - char *v29; // [esp+18h] [ebp-8h] - signed int xa; // [esp+1Ch] [ebp-4h] - int a6a; // [esp+28h] [ebp+8h] - int a6b; // [esp+28h] [ebp+8h] - int a6c; // [esp+28h] [ebp+8h] + int v25; // [esp+10h] [ebp-10h] + int a1; // [esp+14h] [ebp-Ch] + unsigned char *a1a; // [esp+14h] [ebp-Ch] + unsigned char *a1b; // [esp+14h] [ebp-Ch] + char *v29; // [esp+18h] [ebp-8h] + signed int xa; // [esp+1Ch] [ebp-4h] + int a6a; // [esp+28h] [ebp+8h] + int a6b; // [esp+28h] [ebp+8h] + int a6c; // [esp+28h] [ebp+8h] unsigned short *a5a; // [esp+30h] [ebp+10h] unsigned short *a5b; // [esp+30h] [ebp+10h] @@ -1401,48 +1274,41 @@ void __fastcall scrollrt_draw_lower_2(int x, int y, int sx, int sy, int a5, int xa = x; v8 = sx; v29 = (char *)dpiece_defs_map_1 + 32 * gendung_get_dpiece_num_from_coord(x, y); - if ( some_flag ) - { - if ( v7 >= 0 && v7 < 112 && xa >= 0 && xa < 112 ) - { + if (some_flag) { + if (v7 >= 0 && v7 < 112 && xa >= 0 && xa < 112) { v9 = 112 * xa + v7; v10 = dPiece[0][v9]; light_table_index = dTransVal[0][v9]; level_piece_id = v10; - if ( v10 ) - { + if (v10) { a6a = 0; cel_transparency_active = (unsigned char)(nTransTable[v10] & TransList[dung_map[0][v9]]); a1a = (unsigned char *)gpBuffer + screen_y_times_768[sy] + v8 - 24544; - if ( (dword_5A5594 >> 1) - 1 > 0 ) - { + if ((dword_5A5594 >> 1) - 1 > 0) { v24 = (unsigned short *)(v29 + 6); - do - { - if ( a6 <= a6a ) - { + do { + if (a6 <= a6a) { v11 = *v24; level_cel_block = *v24; - if ( v11 ) + if (v11) drawLowerScreen(a1a); } a1a -= 24576; ++a6a; v24 += 2; - } - while ( a6a < (dword_5A5594 >> 1) - 1 ); + } while (a6a < (dword_5A5594 >> 1) - 1); } v12 = 2 * a6 + 2; - if ( v12 < 8 ) + if (v12 < 8) scrollrt_draw_clipped_dungeon_2( - (char *)gpBuffer + screen_y_times_768[sy] - 12288 * v12 + v8, - xa, - v7, - a6, - 2 * a6 + 2, - v8, - sy, - 0); + (char *)gpBuffer + screen_y_times_768[sy] - 12288 * v12 + v8, + xa, + v7, + a6, + 2 * a6 + 2, + v8, + sy, + 0); } } ++xa; @@ -1453,58 +1319,50 @@ void __fastcall scrollrt_draw_lower_2(int x, int y, int sx, int sy, int a5, int a1 = v7; } v25 = a5; - if ( a5 ) - { + if (a5) { v13 = 112 * xa; v23 = 112 * xa; - do - { + do { --v25; - if ( v13 >= MAXDUNX * MAXDUNY || v7 < 0 ) + if (v13 >= MAXDUNX * MAXDUNY || v7 < 0) break; - if ( v7 < 112 && v13 >= 0 ) - { + if (v7 < 112 && v13 >= 0) { v14 = v7 + v13; v15 = dPiece[0][v14]; light_table_index = dTransVal[0][v14]; level_piece_id = v15; - if ( v15 ) - { + if (v15) { a6b = 0; cel_transparency_active = (unsigned char)(nTransTable[v15] & TransList[dung_map[0][v14]]); v16 = (unsigned char *)gpBuffer + screen_y_times_768[sy] + v8 - 24576; - if ( (dword_5A5594 >> 1) - 1 > 0 ) - { + if ((dword_5A5594 >> 1) - 1 > 0) { a5a = (unsigned short *)(v29 + 6); - do - { - if ( a6 <= a6b ) - { + do { + if (a6 <= a6b) { v17 = *(a5a - 1); level_cel_block = *(a5a - 1); - if ( v17 ) + if (v17) drawLowerScreen(v16); v18 = *a5a; level_cel_block = *a5a; - if ( v18 ) + if (v18) drawLowerScreen(v16 + 32); } ++a6b; a5a += 2; v16 -= 24576; - } - while ( a6b < (dword_5A5594 >> 1) - 1 ); + } while (a6b < (dword_5A5594 >> 1) - 1); } - if ( 2 * a6 + 2 < 8 ) + if (2 * a6 + 2 < 8) scrollrt_draw_clipped_dungeon_2( - (char *)gpBuffer + screen_y_times_768[sy] - ((3 * a6 + 3) << 13) + v8, - xa, - a1, - a6, - 2 * a6 + 2, - v8, - sy, - 1); + (char *)gpBuffer + screen_y_times_768[sy] - ((3 * a6 + 3) << 13) + v8, + xa, + a1, + a6, + 2 * a6 + 2, + v8, + sy, + 1); v7 = a1; } } @@ -1515,51 +1373,43 @@ void __fastcall scrollrt_draw_lower_2(int x, int y, int sx, int sy, int a5, int v8 += 64; v23 += 112; a1 = v7; - } - while ( v25 ); + } while (v25); } - if ( some_flag ) - { - if ( (unsigned int)v7 < 0x70 && (unsigned int)xa < 0x70 ) - { + if (some_flag) { + if ((unsigned int)v7 < 0x70 && (unsigned int)xa < 0x70) { v19 = 112 * xa + v7; v20 = dPiece[0][v19]; light_table_index = dTransVal[0][v19]; level_piece_id = v20; - if ( v20 ) - { + if (v20) { a6c = 0; cel_transparency_active = (unsigned char)(nTransTable[v20] & TransList[dung_map[0][v19]]); a1b = (unsigned char *)gpBuffer + screen_y_times_768[sy] + v8 - 24576; - if ( (dword_5A5594 >> 1) - 1 > 0 ) - { + if ((dword_5A5594 >> 1) - 1 > 0) { a5b = (unsigned short *)(v29 + 4); - do - { - if ( a6 <= a6c ) - { + do { + if (a6 <= a6c) { v21 = *a5b; level_cel_block = *a5b; - if ( v21 ) + if (v21) drawLowerScreen(a1b); } a1b -= 24576; ++a6c; a5b += 2; - } - while ( a6c < (dword_5A5594 >> 1) - 1 ); + } while (a6c < (dword_5A5594 >> 1) - 1); } v22 = 2 * a6 + 2; - if ( v22 < 8 ) + if (v22 < 8) scrollrt_draw_clipped_dungeon_2( - (char *)gpBuffer + screen_y_times_768[sy] - 12288 * v22 + v8, - xa, - v7, - a6, - 2 * a6 + 2, - v8, - sy, - 0); + (char *)gpBuffer + screen_y_times_768[sy] - 12288 * v22 + v8, + xa, + v7, + a6, + 2 * a6 + 2, + v8, + sy, + 0); } } } @@ -1571,52 +1421,52 @@ void __fastcall scrollrt_draw_lower_2(int x, int y, int sx, int sy, int a5, int void __fastcall scrollrt_draw_clipped_dungeon_2(char *buffer, int x, int y, int a4, int a5, int sx, int sy, int me_flag) { - int v8; // eax - char v9; // bl - char v10; // cl - char v11; // dl - int *v12; // eax - int v13; // edi - DeadStruct *v14; // eax - int *v15; // esi - int v16; // ecx - int v17; // edx - char v18; // bl - ItemStruct *v19; // esi - char *v20; // eax - signed int v21; // ebx - int v22; // ebx - unsigned int v23; // ecx - PlayerStruct *v24; // esi - int v25; // esi - int v26; // eax + int v8; // eax + char v9; // bl + char v10; // cl + char v11; // dl + int *v12; // eax + int v13; // edi + DeadStruct *v14; // eax + int *v15; // esi + int v16; // ecx + int v17; // edx + char v18; // bl + ItemStruct *v19; // esi + char *v20; // eax + signed int v21; // ebx + int v22; // ebx + unsigned int v23; // ecx + PlayerStruct *v24; // esi + int v25; // esi + int v26; // eax MonsterStruct *v27; // esi - CMonster *v28; // ecx - int v29; // ebx - int v30; // edi - unsigned int v31; // ecx - PlayerStruct *v32; // esi - int v33; // esi - int v34; // eax + CMonster *v28; // ecx + int v29; // ebx + int v30; // edi + unsigned int v31; // ecx + PlayerStruct *v32; // esi + int v33; // esi + int v34; // eax MonsterStruct *v35; // esi - CMonster *v36; // ecx - int v37; // ebx - int v38; // edi - ItemStruct *v39; // esi - char *v40; // eax - int v41; // ecx - int v42; // edi - int v43; // [esp+Ch] [ebp-18h] - int v44; // [esp+10h] [ebp-14h] - char *dst_buf; // [esp+14h] [ebp-10h] - int a1; // [esp+18h] [ebp-Ch] - char v47; // [esp+1Dh] [ebp-7h] - char v48; // [esp+1Eh] [ebp-6h] - char v49; // [esp+1Fh] [ebp-5h] - char v50; // [esp+20h] [ebp-4h] - char v51; // [esp+21h] [ebp-3h] - char v52; // [esp+22h] [ebp-2h] - char v53; // [esp+23h] [ebp-1h] + CMonster *v36; // ecx + int v37; // ebx + int v38; // edi + ItemStruct *v39; // esi + char *v40; // eax + int v41; // ecx + int v42; // edi + int v43; // [esp+Ch] [ebp-18h] + int v44; // [esp+10h] [ebp-14h] + char *dst_buf; // [esp+14h] [ebp-10h] + int a1; // [esp+18h] [ebp-Ch] + char v47; // [esp+1Dh] [ebp-7h] + char v48; // [esp+1Eh] [ebp-6h] + char v49; // [esp+1Fh] [ebp-5h] + char v50; // [esp+20h] [ebp-4h] + char v51; // [esp+21h] [ebp-3h] + char v52; // [esp+22h] [ebp-2h] + char v53; // [esp+23h] [ebp-1h] a1 = x; dst_buf = buffer; @@ -1634,208 +1484,173 @@ void __fastcall scrollrt_draw_clipped_dungeon_2(char *buffer, int x, int y, int v48 = v10; v43 = *v12; v44 = *(v12 - 1); - if ( visiondebug && v53 & DFLAG_LIT ) + if (visiondebug && v53 & DFLAG_LIT) Cel2DecodeHdrOnly(dst_buf, (char *)pSquareCel, 1, 64, a5, 8); - if ( MissilePreFlag && v53 & DFLAG_MISSILE ) - { + if (MissilePreFlag && v53 & DFLAG_MISSILE) { v13 = sx; DrawClippedMissile(a1, y, sx, sy, a5, 8, 1); - } - else - { + } else { v13 = sx; } - if ( light_table_index < lightmax ) - { - if ( v9 ) - { + if (light_table_index < lightmax) { + if (v9) { v14 = &dead[(v9 & 0x1F) - 1]; v15 = (int *)v14->_deadData[(v9 >> 5) & 7]; v16 = v13 - v14->_deadWidth2; - if ( v15 ) - { + if (v15) { v17 = v14->_deadFrame; - if ( v17 >= 1 && (unsigned int)*v15 <= 0x32 && v17 <= *v15 ) - { + if (v17 >= 1 && (unsigned int)*v15 <= 0x32 && v17 <= *v15) { v18 = v14->_deadtrans; - if ( v18 ) + if (v18) Cl2DecodeFrm5(v16, sy, (char *)v15, v17, v14->_deadWidth, a5, 8, v18); else Cl2DecodeFrm6(v16, sy, (char *)v15, v17, v14->_deadWidth, a5, 8); } } } - if ( v50 ) + if (v50) DrawClippedObject(a1, y, v13, sy, 1, a5, 8); } - if ( v52 ) - { - v19 = &item[v52-1]; - if ( !v19->_iPostDraw && (unsigned char)v52 <= MAXITEMS ) - { + if (v52) { + v19 = &item[v52 - 1]; + if (!v19->_iPostDraw && (unsigned char)v52 <= MAXITEMS) { v20 = (char *)v19->_iAnimData; - if ( v20 ) - { + if (v20) { v21 = v19->_iAnimFrame; - if ( v21 >= 1 && *(_DWORD *)v20 <= 0x32u && v21 <= *(_DWORD *)v20 ) - { + if (v21 >= 1 && *(_DWORD *)v20 <= 0x32u && v21 <= *(_DWORD *)v20) { v22 = v13 - v19->_iAnimWidth2; - if ( v52 - 1 == pcursitem ) + if (v52 - 1 == pcursitem) CelDrawHdrClrHL(ICOL_BLUE, v22, sy, v20, v19->_iAnimFrame, v19->_iAnimWidth, a5, 8); Cel2DecodeHdrLight(v22, sy, (char *)v19->_iAnimData, v19->_iAnimFrame, v19->_iAnimWidth, a5, 8); } } } } - if ( v53 & DFLAG_PLAYER ) - { + if (v53 & DFLAG_PLAYER) { v23 = -1 - v48; - if ( v23 < 4 ) - { + if (v23 < 4) { v24 = &plr[v23]; DrawClippedPlayer( - v23, - a1, - y - 1, - v13 + v24->_pxoff - v24->_pAnimWidth2, - sy + v24->_pyoff, - v24->_pAnimData, - v24->_pAnimFrame, - v24->_pAnimWidth, - a5, - 8); - if ( me_flag ) - { + v23, + a1, + y - 1, + v13 + v24->_pxoff - v24->_pAnimWidth2, + sy + v24->_pyoff, + v24->_pAnimData, + v24->_pAnimFrame, + v24->_pAnimWidth, + a5, + 8); + if (me_flag) { v25 = v24->_peflag; - if ( v25 ) - { - if ( v25 == 2 ) + if (v25) { + if (v25 == 2) scrollrt_draw_clipped_e_flag_2(dst_buf - 12384, a1 - 2, y + 1, a4, a5, v13 - 96, sy - 16); scrollrt_draw_clipped_e_flag_2(dst_buf - 64, a1 - 1, y + 1, a4, a5, v13 - 64, sy); } } } } - if ( v53 & DFLAG_MONSTER && (v53 & DFLAG_LIT || plr[myplr]._pInfraFlag) && v44 < 0 ) - { + if (v53 & DFLAG_MONSTER && (v53 & DFLAG_LIT || plr[myplr]._pInfraFlag) && v44 < 0) { v26 = -1 - v44; draw_monster_num = -1 - v44; - if ( (unsigned int)(-1 - v44) < MAXMONSTERS ) - { + if ((unsigned int)(-1 - v44) < MAXMONSTERS) { v27 = &monster[v26]; - if ( !(v27->_mFlags & 1) ) - { + if (!(v27->_mFlags & 1)) { v28 = v27->MType; - if ( v28 ) - { + if (v28) { v29 = sy + v27->_myoff; v30 = sx + v27->_mxoff - v28->flags_2; - if ( v26 == pcursmonst ) - { + if (v26 == pcursmonst) { Cl2DecodeClrHL(233, v30, v29, (char *)v27->_mAnimData, v27->_mAnimFrame, v28->flags_1, a5, 8); v26 = draw_monster_num; } DrawClippedMonster(a1, y, v30, v29, v26, a5, 8); - if ( me_flag && !v27->_meflag ) + if (me_flag && !v27->_meflag) scrollrt_draw_clipped_e_flag_2(dst_buf - 64, a1 - 1, y + 1, a4, a5, sx - 64, sy); v13 = sx; } } } } - if ( v53 & DFLAG_DEAD_PLAYER ) + if (v53 & DFLAG_DEAD_PLAYER) DrawDeadPlayer(a1, y, v13, sy, a5, 8, 1); - if ( v51 > 0 ) - { + if (v51 > 0) { v31 = v51 - 1; - if ( v31 < 4 ) - { + if (v31 < 4) { v32 = &plr[v31]; DrawClippedPlayer( - v31, - a1, - y, - v13 + v32->_pxoff - v32->_pAnimWidth2, - sy + v32->_pyoff, - v32->_pAnimData, - v32->_pAnimFrame, - v32->_pAnimWidth, - a5, - 8); - if ( me_flag ) - { + v31, + a1, + y, + v13 + v32->_pxoff - v32->_pAnimWidth2, + sy + v32->_pyoff, + v32->_pAnimData, + v32->_pAnimFrame, + v32->_pAnimWidth, + a5, + 8); + if (me_flag) { v33 = v32->_peflag; - if ( v33 ) - { - if ( v33 == 2 ) + if (v33) { + if (v33 == 2) scrollrt_draw_clipped_e_flag_2(dst_buf - 12384, a1 - 2, y + 1, a4, a5, v13 - 96, sy - 16); scrollrt_draw_clipped_e_flag_2(dst_buf - 64, a1 - 1, y + 1, a4, a5, v13 - 64, sy); } } } } - if ( v43 > 0 && (v53 & DFLAG_LIT || plr[myplr]._pInfraFlag) ) - { + if (v43 > 0 && (v53 & DFLAG_LIT || plr[myplr]._pInfraFlag)) { v34 = v43 - 1; draw_monster_num = v43 - 1; - if ( (unsigned int)(v43 - 1) < MAXMONSTERS ) - { + if ((unsigned int)(v43 - 1) < MAXMONSTERS) { v35 = &monster[v34]; - if ( !(v35->_mFlags & 1) ) - { + if (!(v35->_mFlags & 1)) { v36 = v35->MType; - if ( v36 ) - { + if (v36) { v37 = sy + v35->_myoff; v38 = sx + v35->_mxoff - v36->flags_2; - if ( v34 == pcursmonst ) - { + if (v34 == pcursmonst) { Cl2DecodeClrHL(233, v38, v37, (char *)v35->_mAnimData, v35->_mAnimFrame, v36->flags_1, a5, 8); v34 = draw_monster_num; } DrawClippedMonster(a1, y, v38, v37, v34, a5, 8); - if ( me_flag && !v35->_meflag ) + if (me_flag && !v35->_meflag) scrollrt_draw_clipped_e_flag_2(dst_buf - 64, a1 - 1, y + 1, a4, a5, sx - 64, sy); v13 = sx; } } } } - if ( v53 & DFLAG_MISSILE ) + if (v53 & DFLAG_MISSILE) DrawClippedMissile(a1, y, v13, sy, a5, 8, 0); - if ( v50 && light_table_index < lightmax ) + if (v50 && light_table_index < lightmax) DrawClippedObject(a1, y, v13, sy, 0, a5, 8); - if ( v52 ) - { - v39 = &item[v52-1]; - if ( v39->_iPostDraw ) - { - if ( (unsigned char)v52 <= MAXITEMS ) - { + if (v52) { + v39 = &item[v52 - 1]; + if (v39->_iPostDraw) { + if ((unsigned char)v52 <= MAXITEMS) { v40 = (char *)v39->_iAnimData; - if ( v40 ) - { + if (v40) { v41 = v39->_iAnimFrame; - if ( v41 >= 1 && *(_DWORD *)v40 <= 0x32u && v41 <= *(_DWORD *)v40 ) - { + if (v41 >= 1 && *(_DWORD *)v40 <= 0x32u && v41 <= *(_DWORD *)v40) { v42 = v13 - v39->_iAnimWidth2; - if ( v52 - 1 == pcursitem ) + if (v52 - 1 == pcursitem) CelDrawHdrClrHL(ICOL_BLUE, v42, sy, v40, v41, v39->_iAnimWidth, a5, 8); Cel2DecodeHdrLight( - v42, - sy, - (char *)v39->_iAnimData, - v39->_iAnimFrame, - v39->_iAnimWidth, - a5, - 8); + v42, + sy, + (char *)v39->_iAnimData, + v39->_iAnimFrame, + v39->_iAnimWidth, + a5, + 8); } } } } } - if ( v49 ) - { + if (v49) { cel_transparency_active = (unsigned char)TransList[v47]; Cel2DecodeLightTrans(dst_buf, (char *)level_special_cel, v49, 64, a5, 8); } @@ -1850,24 +1665,24 @@ void __fastcall scrollrt_draw_clipped_dungeon_2(char *buffer, int x, int y, int void __fastcall scrollrt_draw_clipped_e_flag_2(char *buffer, int x, int y, int a4, signed int a5, int sx, int sy) { - int v7; // eax - int v8; // ecx - int v9; // esi - int v10; // eax - unsigned char *v11; // edi - int v12; // eax + int v7; // eax + int v8; // ecx + int v9; // esi + int v10; // eax + unsigned char *v11; // edi + int v12; // eax unsigned short *v13; // esi - int v14; // eax - int v15; // eax - int v16; // eax - int v17; // eax - unsigned char *v18; // edi - int v19; // eax - int v20; // [esp+Ch] [ebp-14h] - int v21; // [esp+10h] [ebp-10h] - int v22; // [esp+14h] [ebp-Ch] - char *a1; // [esp+18h] [ebp-8h] - int xa; // [esp+1Ch] [ebp-4h] + int v14; // eax + int v15; // eax + int v16; // eax + int v17; // eax + unsigned char *v18; // edi + int v19; // eax + int v20; // [esp+Ch] [ebp-14h] + int v21; // [esp+10h] [ebp-10h] + int v22; // [esp+14h] [ebp-Ch] + char *a1; // [esp+18h] [ebp-8h] + int xa; // [esp+1Ch] [ebp-4h] xa = x; v22 = light_table_index; @@ -1884,57 +1699,54 @@ void __fastcall scrollrt_draw_clipped_e_flag_2(char *buffer, int x, int y, int a light_table_index = v9; cel_transparency_active = v12; v13 = (unsigned short *)((char *)dpiece_defs_map_1 + 32 * gendung_get_dpiece_num_from_coord(x, y)); - if ( !a4 ) - { + if (!a4) { v14 = v13[2]; level_cel_block = v13[2]; - if ( v14 ) + if (v14) drawLowerScreen(v11); v15 = v13[3]; level_cel_block = v13[3]; - if ( v15 ) + if (v15) drawLowerScreen(v11 + 32); goto LABEL_10; } - if ( a4 == 1 ) - { -LABEL_10: + if (a4 == 1) { + LABEL_10: v11 -= 24576; level_cel_block = v13[4]; - if ( level_cel_block ) + if (level_cel_block) drawLowerScreen(v11); v16 = v13[5]; level_cel_block = v13[5]; - if ( v16 ) + if (v16) drawLowerScreen(v11 + 32); goto LABEL_14; } - if ( a4 != 2 ) - { - if ( a4 != 3 ) + if (a4 != 2) { + if (a4 != 3) goto LABEL_22; goto LABEL_18; } LABEL_14: v11 -= 24576; level_cel_block = v13[6]; - if ( level_cel_block ) + if (level_cel_block) drawLowerScreen(v11); v17 = v13[7]; level_cel_block = v13[7]; - if ( v17 ) + if (v17) drawLowerScreen(v11 + 32); LABEL_18: v18 = v11 - 24576; level_cel_block = v13[8]; - if ( level_cel_block ) + if (level_cel_block) drawLowerScreen(v18); v19 = v13[9]; level_cel_block = v13[9]; - if ( v19 ) + if (v19) drawLowerScreen(v18 + 32); LABEL_22: - if ( a5 < 8 ) + if (a5 < 8) scrollrt_draw_clipped_dungeon_2(a1, xa, y, a4, a5, sx, sy, 0); light_table_index = v22; cel_transparency_active = v21; @@ -1947,45 +1759,45 @@ LABEL_22: void __fastcall scrollrt_draw_upper(int x, int y, int sx, int sy, int a5, int a6, int some_flag) { - int v7; // edi - int v8; // esi + int v7; // edi + int v8; // esi unsigned short *v9; // ebx - int v10; // ecx - int v11; // eax - char *v12; // edx - int v13; // edi - int v14; // eax + int v10; // ecx + int v11; // eax + char *v12; // edx + int v13; // edi + int v14; // eax unsigned char *v15; // edi - int v16; // eax + int v16; // eax unsigned char *v17; // edi - int v18; // eax - int v19; // eax - int v20; // esi - int v21; // eax - int v22; // ecx - int v23; // ecx - int v24; // eax - int v25; // esi + int v18; // eax + int v19; // eax + int v20; // esi + int v21; // eax + int v22; // ecx + int v23; // ecx + int v24; // eax + int v25; // esi unsigned char *v26; // esi - int v27; // eax - int v28; // eax - int v29; // eax - bool v30; // zf - int v31; // ecx - int v32; // eax + int v27; // eax + int v28; // eax + int v29; // eax + bool v30; // zf + int v31; // ecx + int v32; // eax unsigned char *v33; // esi - int v34; // eax + int v34; // eax unsigned char *v35; // esi - int v36; // eax + int v36; // eax unsigned char *v37; // esi - int v38; // eax - int v39; // eax - int v40; // [esp+Ch] [ebp-14h] - int v41; // [esp+10h] [ebp-10h] - int a5a; // [esp+14h] [ebp-Ch] - int ya; // [esp+18h] [ebp-8h] - signed int xa; // [esp+1Ch] [ebp-4h] - int i; // [esp+30h] [ebp+10h] + int v38; // eax + int v39; // eax + int v40; // [esp+Ch] [ebp-14h] + int v41; // [esp+10h] [ebp-10h] + int a5a; // [esp+14h] [ebp-Ch] + int ya; // [esp+18h] [ebp-8h] + signed int xa; // [esp+1Ch] [ebp-4h] + int i; // [esp+30h] [ebp+10h] v7 = y; v8 = x; @@ -1993,60 +1805,50 @@ void __fastcall scrollrt_draw_upper(int x, int y, int sx, int sy, int a5, int a6 xa = x; v9 = (unsigned short *)((char *)dpiece_defs_map_1 + 32 * gendung_get_dpiece_num_from_coord(x, y)); a5a = 2 * a6 + 2; - if ( a5a > 8 ) + if (a5a > 8) a5a = 8; - if ( some_flag ) - { - if ( v7 >= 0 && v7 < 112 && v8 >= 0 && v8 < 112 ) - { + if (some_flag) { + if (v7 >= 0 && v7 < 112 && v8 >= 0 && v8 < 112) { v10 = 112 * v8 + v7; v11 = dPiece[0][v10]; light_table_index = dTransVal[0][v10]; level_piece_id = v11; - if ( v11 ) - { + if (v11) { cel_transparency_active = (unsigned char)(nTransTable[v11] & TransList[dung_map[0][v10]]); v12 = (char *)gpBuffer + screen_y_times_768[sy]; v13 = (int)&v12[sx + 32]; - if ( a6 >= 0 ) - { + if (a6 >= 0) { v14 = v9[1]; level_cel_block = v9[1]; - if ( v14 ) - { + if (v14) { arch_draw_type = 2; drawUpperScreen((unsigned char *)&v12[sx + 32]); arch_draw_type = 0; } } v15 = (unsigned char *)(v13 - 24576); - if ( a6 >= 1 ) - { + if (a6 >= 1) { v16 = v9[3]; level_cel_block = v9[3]; - if ( v16 ) + if (v16) drawUpperScreen(v15); } v17 = v15 - 24576; - if ( a6 >= 2 ) - { + if (a6 >= 2) { v18 = v9[5]; level_cel_block = v9[5]; - if ( v18 ) + if (v18) drawUpperScreen(v17); } - if ( a6 >= 3 ) - { + if (a6 >= 3) { v19 = v9[7]; level_cel_block = v9[7]; - if ( v19 ) + if (v19) drawUpperScreen(v17 - 24576); } v7 = ya; scrollrt_draw_dungeon((char *)gpBuffer + screen_y_times_768[sy] + sx, xa, ya, a6, a5a, sx, sy, 0); - } - else - { + } else { world_draw_black_tile((unsigned char *)gpBuffer + screen_y_times_768[sy] + sx); } } @@ -2058,20 +1860,16 @@ void __fastcall scrollrt_draw_upper(int x, int y, int sx, int sy, int a5, int a6 ya = v7; v9 += 16; } - if ( a5 > 0 ) - { + if (a5 > 0) { v20 = 112 * v8; v41 = v20; v40 = a5; - do - { - if ( v7 >= 0 && v7 < 112 && v20 >= 0 && v20 < MAXDUNX * MAXDUNY ) - { + do { + if (v7 >= 0 && v7 < 112 && v20 >= 0 && v20 < MAXDUNX * MAXDUNY) { v21 = dPiece[0][v20 + v7]; light_table_index = dTransVal[0][v20 + v7]; level_piece_id = v21; - if ( v21 ) - { + if (v21) { v22 = dung_map[0][v20 + v7]; arch_draw_type = 1; v23 = (unsigned char)(nTransTable[v21] & TransList[v22]); @@ -2080,35 +1878,31 @@ void __fastcall scrollrt_draw_upper(int x, int y, int sx, int sy, int a5, int a6 cel_transparency_active = v23; level_cel_block = v24; v26 = (unsigned char *)gpBuffer + v25 + sx; - if ( v24 ) + if (v24) drawUpperScreen(v26); v27 = v9[1]; arch_draw_type = 2; level_cel_block = v27; - if ( v27 ) + if (v27) drawUpperScreen(v26 + 32); arch_draw_type = 0; - for ( i = 1; i < (dword_5A5594 >> 1) - 1; ++i ) - { + for (i = 1; i < (dword_5A5594 >> 1) - 1; ++i) { v26 -= 24576; - if ( a6 >= i ) - { + if (a6 >= i) { v28 = v9[2 * i]; level_cel_block = v9[2 * i]; - if ( v28 ) + if (v28) drawUpperScreen(v26); v29 = v9[2 * i + 1]; level_cel_block = v9[2 * i + 1]; - if ( v29 ) + if (v29) drawUpperScreen(v26 + 32); } } scrollrt_draw_dungeon((char *)gpBuffer + screen_y_times_768[sy] + sx, xa, ya, a6, a5a, sx, sy, 1); v7 = ya; v20 = v41; - } - else - { + } else { world_draw_black_tile((unsigned char *)gpBuffer + screen_y_times_768[sy] + sx); } } @@ -2120,55 +1914,46 @@ void __fastcall scrollrt_draw_upper(int x, int y, int sx, int sy, int a5, int a6 v30 = v40-- == 1; v41 = v20; ya = v7; - } - while ( !v30 ); + } while (!v30); } - if ( some_flag && v7 >= 0 && v7 < 112 && xa >= 0 && xa < 112 ) - { + if (some_flag && v7 >= 0 && v7 < 112 && xa >= 0 && xa < 112) { v31 = 112 * xa + v7; v32 = dPiece[0][v31]; light_table_index = dTransVal[0][v31]; level_piece_id = v32; - if ( v32 ) - { + if (v32) { arch_draw_type = 1; cel_transparency_active = (unsigned char)(nTransTable[v32] & TransList[dung_map[0][v31]]); v33 = (unsigned char *)gpBuffer + screen_y_times_768[sy] + sx; - if ( a6 >= 0 ) - { + if (a6 >= 0) { v34 = *v9; level_cel_block = *v9; - if ( v34 ) + if (v34) drawUpperScreen(v33); } arch_draw_type = 0; v35 = v33 - 24576; - if ( a6 >= 1 ) - { + if (a6 >= 1) { v36 = v9[2]; level_cel_block = v9[2]; - if ( v36 ) + if (v36) drawUpperScreen(v35); } v37 = v35 - 24576; - if ( a6 >= 2 ) - { + if (a6 >= 2) { v38 = v9[4]; level_cel_block = v9[4]; - if ( v38 ) + if (v38) drawUpperScreen(v37); } - if ( a6 >= 3 ) - { + if (a6 >= 3) { v39 = v9[6]; level_cel_block = v9[6]; - if ( v39 ) + if (v39) drawUpperScreen(v37 - 24576); } scrollrt_draw_dungeon((char *)gpBuffer + screen_y_times_768[sy] + sx, xa, ya, a6, a5a, sx, sy, 0); - } - else - { + } else { world_draw_black_tile((unsigned char *)gpBuffer + screen_y_times_768[sy] + sx); } } @@ -2181,51 +1966,51 @@ void __fastcall scrollrt_draw_upper(int x, int y, int sx, int sy, int a5, int a6 void __fastcall scrollrt_draw_dungeon(char *buffer, int x, int y, int a4, int a5, int sx, int sy, int me_flag) { - int v8; // eax - char v9; // bl - char v10; // cl - char v11; // dl - int *v12; // eax - DeadStruct *v13; // eax - int *v14; // esi - int v15; // ecx - int v16; // edx - char v17; // bl - ItemStruct *v18; // esi - char *v19; // eax - signed int v20; // ebx - int v21; // ebx - unsigned int v22; // ecx - PlayerStruct *v23; // esi - int v24; // esi - int v25; // eax + int v8; // eax + char v9; // bl + char v10; // cl + char v11; // dl + int *v12; // eax + DeadStruct *v13; // eax + int *v14; // esi + int v15; // ecx + int v16; // edx + char v17; // bl + ItemStruct *v18; // esi + char *v19; // eax + signed int v20; // ebx + int v21; // ebx + unsigned int v22; // ecx + PlayerStruct *v23; // esi + int v24; // esi + int v25; // eax MonsterStruct *v26; // esi - CMonster *v27; // ecx - int v28; // ebx - int v29; // edi - unsigned int v30; // ecx - PlayerStruct *v31; // esi - int v32; // esi - int v33; // eax + CMonster *v27; // ecx + int v28; // ebx + int v29; // edi + unsigned int v30; // ecx + PlayerStruct *v31; // esi + int v32; // esi + int v33; // eax MonsterStruct *v34; // esi - CMonster *v35; // ecx - int v36; // ebx - int v37; // edi - ItemStruct *v38; // esi - char *v39; // ecx - signed int v40; // ebx - int v41; // ebx - int v42; // [esp+Ch] [ebp-18h] - int v43; // [esp+10h] [ebp-14h] - char *dst_buf; // [esp+14h] [ebp-10h] - int xa; // [esp+18h] [ebp-Ch] - char v46; // [esp+1Dh] [ebp-7h] - char v47; // [esp+1Eh] [ebp-6h] - char v48; // [esp+1Fh] [ebp-5h] - char v49; // [esp+20h] [ebp-4h] - char v50; // [esp+21h] [ebp-3h] - char v51; // [esp+22h] [ebp-2h] - char v52; // [esp+23h] [ebp-1h] + CMonster *v35; // ecx + int v36; // ebx + int v37; // edi + ItemStruct *v38; // esi + char *v39; // ecx + signed int v40; // ebx + int v41; // ebx + int v42; // [esp+Ch] [ebp-18h] + int v43; // [esp+10h] [ebp-14h] + char *dst_buf; // [esp+14h] [ebp-10h] + int xa; // [esp+18h] [ebp-Ch] + char v46; // [esp+1Dh] [ebp-7h] + char v47; // [esp+1Eh] [ebp-6h] + char v48; // [esp+1Fh] [ebp-5h] + char v49; // [esp+20h] [ebp-4h] + char v50; // [esp+21h] [ebp-3h] + char v51; // [esp+22h] [ebp-2h] + char v52; // [esp+23h] [ebp-1h] xa = x; dst_buf = buffer; @@ -2243,199 +2028,167 @@ void __fastcall scrollrt_draw_dungeon(char *buffer, int x, int y, int a4, int a5 v47 = v10; v42 = *v12; v43 = *(v12 - 1); - if ( visiondebug && v52 & DFLAG_LIT ) + if (visiondebug && v52 & DFLAG_LIT) CelDecodeHdrOnly(dst_buf, (char *)pSquareCel, 1, 64, 0, a5); - if ( MissilePreFlag && v52 & DFLAG_MISSILE ) + if (MissilePreFlag && v52 & DFLAG_MISSILE) DrawMissile(xa, y, sx, sy, 0, a5, 1); - if ( light_table_index < lightmax ) - { - if ( v9 ) - { + if (light_table_index < lightmax) { + if (v9) { v13 = &dead[(v9 & 0x1F) - 1]; v14 = (int *)v13->_deadData[(v9 >> 5) & 7]; v15 = sx - v13->_deadWidth2; - if ( v14 ) - { + if (v14) { v16 = v13->_deadFrame; - if ( v16 >= 1 && (unsigned int)*v14 <= 0x32 && v16 <= *v14 ) - { + if (v16 >= 1 && (unsigned int)*v14 <= 0x32 && v16 <= *v14) { v17 = v13->_deadtrans; - if ( v17 ) + if (v17) Cl2DecodeFrm3(v15, sy, (char *)v14, v16, v13->_deadWidth, 0, a5, v17); else Cl2DecodeLightTbl(v15, sy, (char *)v14, v16, v13->_deadWidth, 0, a5); } } } - if ( v49 ) + if (v49) DrawObject(xa, y, sx, sy, 1, 0, a5); } - if ( v51 ) - { - v18 = &item[v51-1]; - if ( !v18->_iPostDraw && (unsigned char)v51 <= MAXITEMS ) - { + if (v51) { + v18 = &item[v51 - 1]; + if (!v18->_iPostDraw && (unsigned char)v51 <= MAXITEMS) { v19 = (char *)v18->_iAnimData; - if ( v19 ) - { + if (v19) { v20 = v18->_iAnimFrame; - if ( v20 >= 1 && *(_DWORD *)v19 <= 0x32u && v20 <= *(_DWORD *)v19 ) - { + if (v20 >= 1 && *(_DWORD *)v19 <= 0x32u && v20 <= *(_DWORD *)v19) { v21 = sx - v18->_iAnimWidth2; - if ( v51 - 1 == pcursitem ) + if (v51 - 1 == pcursitem) CelDecodeClr(ICOL_BLUE, v21, sy, v19, v18->_iAnimFrame, v18->_iAnimWidth, 0, a5); CelDecodeHdrLightOnly(v21, sy, (char *)v18->_iAnimData, v18->_iAnimFrame, v18->_iAnimWidth, 0, a5); } } } } - if ( v52 & DFLAG_PLAYER ) - { + if (v52 & DFLAG_PLAYER) { v22 = -1 - v47; - if ( v22 < 4 ) - { + if (v22 < 4) { v23 = &plr[v22]; DrawPlayer( - v22, - xa, - y - 1, - sx + v23->_pxoff - v23->_pAnimWidth2, - sy + v23->_pyoff, - v23->_pAnimData, - v23->_pAnimFrame, - v23->_pAnimWidth, - 0, - a5); - if ( me_flag ) - { + v22, + xa, + y - 1, + sx + v23->_pxoff - v23->_pAnimWidth2, + sy + v23->_pyoff, + v23->_pAnimData, + v23->_pAnimFrame, + v23->_pAnimWidth, + 0, + a5); + if (me_flag) { v24 = v23->_peflag; - if ( v24 ) - { - if ( v24 == 2 ) + if (v24) { + if (v24 == 2) scrollrt_draw_e_flag(dst_buf - 12384, xa - 2, y + 1, a4, a5, sx - 96, sy - 16); scrollrt_draw_e_flag(dst_buf - 64, xa - 1, y + 1, a4, a5, sx - 64, sy); } } } } - if ( v52 & DFLAG_MONSTER && (v52 & DFLAG_LIT || plr[myplr]._pInfraFlag) && v43 < 0 ) - { + if (v52 & DFLAG_MONSTER && (v52 & DFLAG_LIT || plr[myplr]._pInfraFlag) && v43 < 0) { v25 = -1 - v43; draw_monster_num = -1 - v43; - if ( (unsigned int)(-1 - v43) < MAXMONSTERS ) - { + if ((unsigned int)(-1 - v43) < MAXMONSTERS) { v26 = &monster[v25]; - if ( !(v26->_mFlags & 1) ) - { + if (!(v26->_mFlags & 1)) { v27 = v26->MType; - if ( v27 ) - { + if (v27) { v28 = sy + v26->_myoff; v29 = sx + v26->_mxoff - v27->flags_2; - if ( v25 == pcursmonst ) - { + if (v25 == pcursmonst) { Cl2DecodeFrm2(233, v29, v28, (char *)v26->_mAnimData, v26->_mAnimFrame, v27->flags_1, 0, a5); v25 = draw_monster_num; } DrawMonster(xa, y, v29, v28, v25, 0, a5); - if ( me_flag && !v26->_meflag ) + if (me_flag && !v26->_meflag) scrollrt_draw_e_flag(dst_buf - 64, xa - 1, y + 1, a4, a5, sx - 64, sy); } } } } - if ( v52 & DFLAG_DEAD_PLAYER ) + if (v52 & DFLAG_DEAD_PLAYER) DrawDeadPlayer(xa, y, sx, sy, 0, a5, 0); - if ( v50 > 0 ) - { + if (v50 > 0) { v30 = v50 - 1; - if ( v30 < 4 ) - { + if (v30 < 4) { v31 = &plr[v30]; DrawPlayer( - v30, - xa, - y, - sx + v31->_pxoff - v31->_pAnimWidth2, - sy + v31->_pyoff, - v31->_pAnimData, - v31->_pAnimFrame, - v31->_pAnimWidth, - 0, - a5); - if ( me_flag ) - { + v30, + xa, + y, + sx + v31->_pxoff - v31->_pAnimWidth2, + sy + v31->_pyoff, + v31->_pAnimData, + v31->_pAnimFrame, + v31->_pAnimWidth, + 0, + a5); + if (me_flag) { v32 = v31->_peflag; - if ( v32 ) - { - if ( v32 == 2 ) + if (v32) { + if (v32 == 2) scrollrt_draw_e_flag(dst_buf - 12384, xa - 2, y + 1, a4, a5, sx - 96, sy - 16); scrollrt_draw_e_flag(dst_buf - 64, xa - 1, y + 1, a4, a5, sx - 64, sy); } } } } - if ( v42 > 0 && (v52 & DFLAG_LIT || plr[myplr]._pInfraFlag) ) - { + if (v42 > 0 && (v52 & DFLAG_LIT || plr[myplr]._pInfraFlag)) { v33 = v42 - 1; draw_monster_num = v42 - 1; - if ( (unsigned int)(v42 - 1) < MAXMONSTERS ) - { + if ((unsigned int)(v42 - 1) < MAXMONSTERS) { v34 = &monster[v33]; - if ( !(v34->_mFlags & 1) ) - { + if (!(v34->_mFlags & 1)) { v35 = v34->MType; - if ( v35 ) - { + if (v35) { v36 = sy + v34->_myoff; v37 = sx + v34->_mxoff - v35->flags_2; - if ( v33 == pcursmonst ) - { + if (v33 == pcursmonst) { Cl2DecodeFrm2(233, v37, v36, (char *)v34->_mAnimData, v34->_mAnimFrame, v35->flags_1, 0, a5); v33 = draw_monster_num; } DrawMonster(xa, y, v37, v36, v33, 0, a5); - if ( me_flag && !v34->_meflag ) + if (me_flag && !v34->_meflag) scrollrt_draw_e_flag(dst_buf - 64, xa - 1, y + 1, a4, a5, sx - 64, sy); } } } } - if ( v52 & DFLAG_MISSILE ) + if (v52 & DFLAG_MISSILE) DrawMissile(xa, y, sx, sy, 0, a5, 0); - if ( v49 && light_table_index < lightmax ) + if (v49 && light_table_index < lightmax) DrawObject(xa, y, sx, sy, 0, 0, a5); - if ( v51 ) - { - v38 = &item[v51-1]; - if ( v38->_iPostDraw ) - { - if ( (unsigned char)v51 <= MAXITEMS ) - { + if (v51) { + v38 = &item[v51 - 1]; + if (v38->_iPostDraw) { + if ((unsigned char)v51 <= MAXITEMS) { v39 = (char *)v38->_iAnimData; - if ( v39 ) - { + if (v39) { v40 = v38->_iAnimFrame; - if ( v40 >= 1 && *(_DWORD *)v39 <= 0x32u && v40 <= *(_DWORD *)v39 ) - { + if (v40 >= 1 && *(_DWORD *)v39 <= 0x32u && v40 <= *(_DWORD *)v39) { v41 = sx - v38->_iAnimWidth2; - if ( v51 - 1 == pcursitem ) + if (v51 - 1 == pcursitem) CelDecodeClr(ICOL_BLUE, v41, sy, v39, v38->_iAnimFrame, v38->_iAnimWidth, 0, a5); CelDecodeHdrLightOnly( - v41, - sy, - (char *)v38->_iAnimData, - v38->_iAnimFrame, - v38->_iAnimWidth, - 0, - a5); + v41, + sy, + (char *)v38->_iAnimData, + v38->_iAnimFrame, + v38->_iAnimWidth, + 0, + a5); } } } } } - if ( v48 ) - { + if (v48) { cel_transparency_active = (unsigned char)TransList[v46]; CelDecodeHdrLightTrans(dst_buf, (char *)level_special_cel, v48, 64, 0, a5); } @@ -2450,49 +2203,40 @@ void __fastcall scrollrt_draw_dungeon(char *buffer, int x, int y, int a4, int a5 void __fastcall DrawMonster(int x, int y, int a3, int a4, int mon_id, int a6, int a7) { - int v7; // eax - char *v8; // esi + int v7; // eax + char *v8; // esi signed int v9; // ebx - char v10; // cl + char v10; // cl CMonster *v11; // eax - char mon_ida; // [esp+1Ch] [ebp+10h] + char mon_ida; // [esp+1Ch] [ebp+10h] - if ( (unsigned int)mon_id < MAXMONSTERS ) - { + if ((unsigned int)mon_id < MAXMONSTERS) { v7 = mon_id; v8 = (char *)monster[mon_id]._mAnimData; - if ( v8 ) - { + if (v8) { v9 = monster[v7]._mAnimFrame; - if ( v9 >= 1 && (unsigned int)*v8 <= 0x32 && v9 <= *v8 ) - { - if ( dFlags[x][y] & DFLAG_LIT ) - { + if (v9 >= 1 && (unsigned int)*v8 <= 0x32 && v9 <= *v8) { + if (dFlags[x][y] & DFLAG_LIT) { v10 = 0; mon_ida = 0; - if ( monster[v7]._uniqtype ) - { + if (monster[v7]._uniqtype) { v10 = monster[v7]._uniqtrans + 4; mon_ida = monster[v7]._uniqtrans + 4; } - if ( monster[v7]._mmode == MM_STONE ) - { + if (monster[v7]._mmode == MM_STONE) { v10 = 2; mon_ida = 2; } - if ( plr[myplr]._pInfraFlag && light_table_index > 8 ) - { + if (plr[myplr]._pInfraFlag && light_table_index > 8) { v10 = 1; mon_ida = 1; } v11 = monster[v7].MType; - if ( v10 ) + if (v10) Cl2DecodeFrm3(a3, a4, v8, v9, v11->flags_1, a6, a7, mon_ida); else Cl2DecodeLightTbl(a3, a4, v8, v9, v11->flags_1, a6, a7); - } - else - { + } else { Cl2DecodeFrm3(a3, a4, v8, v9, monster[v7].MType->flags_1, a6, a7, 1); } } @@ -2503,27 +2247,26 @@ void __fastcall DrawMonster(int x, int y, int a3, int a4, int mon_id, int a6, in void __fastcall DrawObject(int x, int y, int a3, int a4, int pre_flag, int a6, int dir) { - int v7; // edi - char v8; // al + int v7; // edi + char v8; // al unsigned char v9; // dl - int v10; // esi - int v11; // ebx - int v12; // edi - int v13; // eax - int v14; // ecx - char *v15; // eax - signed int v16; // ecx - char *v17; // eax - char v18; // [esp+Fh] [ebp-1h] + int v10; // esi + int v11; // ebx + int v12; // edi + int v13; // eax + int v14; // ecx + char *v15; // eax + signed int v16; // ecx + char *v17; // eax + char v18; // [esp+Fh] [ebp-1h] v7 = y; v8 = dObject[x][y]; - if ( v8 <= 0 ) - { + if (v8 <= 0) { v9 = -1 - v8; v10 = (char)(-1 - v8); v18 = -1 - v8; - if ( object[v10]._oPreFlag != pre_flag ) + if (object[v10]._oPreFlag != pre_flag) return; dir = 8; v13 = object[v10]._ox - x; @@ -2531,42 +2274,34 @@ void __fastcall DrawObject(int x, int y, int a3, int a4, int pre_flag, int a6, i v12 = a3 + 32 * v13 - object[v10]._oAnimWidth2 - 32 * v14; v11 = a4 + 16 * (v14 + v13); a6 = 0; - } - else - { + } else { v9 = v8 - 1; v10 = (char)(v8 - 1); v18 = v8 - 1; - if ( object[v10]._oPreFlag != pre_flag ) + if (object[v10]._oPreFlag != pre_flag) return; v11 = a4; v12 = a3 - object[v10]._oAnimWidth2; } - if ( v9 < MAXOBJECTS ) - { + if (v9 < MAXOBJECTS) { v15 = (char *)object[v10]._oAnimData; - if ( v15 ) - { + if (v15) { v16 = object[v10]._oAnimFrame; - if ( v16 >= 1 && *(_DWORD *)v15 <= 0x32u && v16 <= *(_DWORD *)v15 ) - { - if ( v18 == pcursobj ) + if (v16 >= 1 && *(_DWORD *)v15 <= 0x32u && v16 <= *(_DWORD *)v15) { + if (v18 == pcursobj) CelDecodeClr(194, v12, v11, v15, v16, object[v10]._oAnimWidth, a6, dir); - if ( object[v10]._oLight ) - { + if (object[v10]._oLight) { CelDecodeHdrLightOnly( - v12, - v11, - (char *)object[v10]._oAnimData, - object[v10]._oAnimFrame, - object[v10]._oAnimWidth, - a6, - dir); - } - else - { + v12, + v11, + (char *)object[v10]._oAnimData, + object[v10]._oAnimFrame, + object[v10]._oAnimWidth, + a6, + dir); + } else { v17 = (char *)object[v10]._oAnimData; - if ( v17 ) + if (v17) CelDrawHdrOnly(v12, v11, v17, object[v10]._oAnimFrame, object[v10]._oAnimWidth, a6, dir); } } @@ -2577,26 +2312,26 @@ void __fastcall DrawObject(int x, int y, int a3, int a4, int pre_flag, int a6, i void __fastcall scrollrt_draw_e_flag(char *buffer, int x, int y, int a4, int a5, int sx, int sy) { - int v7; // eax - char *v8; // esi - int v9; // ecx - int v10; // ebx - int v11; // edx - int v12; // eax - int v13; // eax - int v14; // ecx - int v15; // edi - int v16; // eax + int v7; // eax + char *v8; // esi + int v9; // ecx + int v10; // ebx + int v11; // edx + int v12; // eax + int v13; // eax + int v14; // ecx + int v15; // edi + int v16; // eax unsigned short *v17; // esi - int v18; // eax - int v19; // eax - int v20; // eax - int v21; // eax - int v22; // [esp+Ch] [ebp-14h] - int xa; // [esp+10h] [ebp-10h] - unsigned char *a1; // [esp+14h] [ebp-Ch] - unsigned char *v25; // [esp+18h] [ebp-8h] - int i; // [esp+1Ch] [ebp-4h] + int v18; // eax + int v19; // eax + int v20; // eax + int v21; // eax + int v22; // [esp+Ch] [ebp-14h] + int xa; // [esp+10h] [ebp-10h] + unsigned char *a1; // [esp+14h] [ebp-Ch] + unsigned char *v25; // [esp+18h] [ebp-8h] + int i; // [esp+1Ch] [ebp-4h] xa = x; v22 = level_piece_id; @@ -2619,26 +2354,24 @@ void __fastcall scrollrt_draw_e_flag(char *buffer, int x, int y, int a4, int a5, v17 = (unsigned short *)((char *)dpiece_defs_map_1 + 32 * v16); v18 = *v17; level_cel_block = *v17; - if ( v18 ) + if (v18) drawUpperScreen(a1); v19 = v17[1]; arch_draw_type = 2; level_cel_block = v19; - if ( v19 ) + if (v19) drawUpperScreen(a1 + 32); arch_draw_type = 0; - for ( i = 1; i < (dword_5A5594 >> 1) - 1; ++i ) - { + for (i = 1; i < (dword_5A5594 >> 1) - 1; ++i) { v25 -= 24576; - if ( a4 >= i ) - { + if (a4 >= i) { v20 = v17[2 * i]; level_cel_block = v17[2 * i]; - if ( v20 ) + if (v20) drawUpperScreen(v25); v21 = v17[2 * i + 1]; level_cel_block = v17[2 * i + 1]; - if ( v21 ) + if (v21) drawUpperScreen(v25 + 32); } } @@ -2655,30 +2388,30 @@ void __fastcall scrollrt_draw_e_flag(char *buffer, int x, int y, int a4, int a5, void __fastcall 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 + 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 + short v16; // ax + int v17; // eax signed int v18; // [esp+Ch] [ebp-10h] signed int v19; // [esp+Ch] [ebp-10h] - signed int a5; // [esp+10h] [ebp-Ch] - int a5a; // [esp+10h] [ebp-Ch] - signed int a6; // [esp+14h] [ebp-8h] + signed int a5; // [esp+10h] [ebp-Ch] + int a5a; // [esp+10h] [ebp-Ch] + signed int a6; // [esp+14h] [ebp-8h] signed int a6a; // [esp+14h] [ebp-8h] - int a6b; // [esp+14h] [ebp-8h] - int ya; // [esp+18h] [ebp-4h] + int a6b; // [esp+14h] [ebp-8h] + int ya; // [esp+18h] [ebp-4h] v2 = ScrollInfo._sxoff + 64; dword_5C2FF8 = 6; @@ -2690,50 +2423,48 @@ void __fastcall DrawZoom(int x, int y) scr_pix_width = 384; scr_pix_height = 192; v18 = 3; - switch ( ScrollInfo._sdir ) - { - case DIR_SW: - goto LABEL_3; - case DIR_W: - a5 = 7; -LABEL_3: - v4 = ScrollInfo._syoff + 111; - v3 = x - 7; - ya = y - 2; - goto LABEL_9; - case DIR_NW: - goto LABEL_7; - case DIR_N: - v18 = 4; - goto LABEL_7; - case DIR_NE: - goto LABEL_9; - case DIR_E: - v18 = 4; - goto LABEL_6; - case DIR_SE: -LABEL_6: - v2 = ScrollInfo._sxoff; - v3 = x - 7; - ya = y; -LABEL_7: - a5 = 7; - break; - case DIR_OMNI: - v2 = ScrollInfo._sxoff; - v4 = ScrollInfo._syoff + 111; - a5 = 7; - v3 = x - 8; -LABEL_9: - v18 = 4; - break; - default: - break; + switch (ScrollInfo._sdir) { + case DIR_SW: + goto LABEL_3; + case DIR_W: + a5 = 7; + LABEL_3: + v4 = ScrollInfo._syoff + 111; + v3 = x - 7; + ya = y - 2; + goto LABEL_9; + case DIR_NW: + goto LABEL_7; + case DIR_N: + v18 = 4; + goto LABEL_7; + case DIR_NE: + goto LABEL_9; + case DIR_E: + v18 = 4; + goto LABEL_6; + case DIR_SE: + LABEL_6: + v2 = ScrollInfo._sxoff; + v3 = x - 7; + ya = y; + LABEL_7: + a5 = 7; + break; + case DIR_OMNI: + v2 = ScrollInfo._sxoff; + v4 = ScrollInfo._syoff + 111; + a5 = 7; + v3 = x - 8; + LABEL_9: + v18 = 4; + break; + default: + break; } a6 = 0; gpBufEnd = (unsigned char *)gpBuffer + screen_y_times_768[143]; - do - { + do { scrollrt_draw_upper(v3, ya++, v2, v4, a5, a6, 0); v5 = v4 + 16; v6 = v2 - 32; @@ -2741,13 +2472,10 @@ LABEL_9: v2 = v6 + 32; v4 = v5 + 16; ++a6; - } - while ( a6 < 4 ); + } while (a6 < 4); gpBufEnd = (unsigned char *)gpBuffer + screen_y_times_768[320]; - if ( v18 > 0 ) - { - do - { + if (v18 > 0) { + do { scrollrt_draw_lower(v3, ya++, v2, v4, a5, 0); v7 = v4 + 16; v8 = v2 - 32; @@ -2755,13 +2483,11 @@ LABEL_9: v2 = v8 + 32; v4 = v7 + 16; --v18; - } - while ( v18 ); + } while (v18); } arch_draw_type = 0; a6a = 0; - do - { + do { scrollrt_draw_lower_2(v3, ya++, v2, v4, a5, a6a, 0); v9 = v4 + 16; v10 = v2 - 32; @@ -2769,17 +2495,14 @@ LABEL_9: v2 = v10 + 32; v4 = v9 + 16; ++a6a; - } - while ( a6a < 4 ); - if ( chrflag || questlog ) - { + } while (a6a < 4); + if (chrflag || questlog) { a6b = 392064; goto LABEL_23; } - if ( invflag || sbookflag ) - { + if (invflag || sbookflag) { a6b = 391744; -LABEL_23: + LABEL_23: a5a = 245168; v19 = 160; goto LABEL_24; @@ -2792,11 +2515,9 @@ LABEL_24: v12 = (char *)gpBuffer + a5a; v13 = &gpBuffer->row_unused_1[1].col_unused_1[a6b]; v14 = 176; - do - { + do { v15 = v19; - do - { + do { _LOBYTE(v16) = *v12++; _HIBYTE(v16) = v16; *v11 = v16; @@ -2804,15 +2525,13 @@ LABEL_24: ++v11; v13 += 2; --v15; - } - while ( v15 ); + } while (v15); v12 += -v19 - 768; v17 = 2 * (v19 + 768); v13 -= v17; v11 = (_WORD *)((char *)v11 - v17); --v14; - } - while ( v14 ); + } while (v14); } // 4B8968: using guessed type int sbookflag; // 5C2FF8: using guessed type int dword_5C2FF8; @@ -2829,7 +2548,7 @@ void __cdecl ClearScreenBuffer() j_lock_buf_priv(3); - for(i = 0; i < 480; i++) + for (i = 0; i < 480; i++) memset(gpBuffer->row[i].pixels, 0, 640); j_unlock_buf_priv(3); @@ -2839,113 +2558,91 @@ void __cdecl ClearScreenBuffer() void __cdecl ScrollView() { signed int v0; // esi - int v1; // edi - int v2; // edx + int v1; // edi + int v2; // edx - if ( pcurs < 12 ) - { + if (pcurs < 12) { v0 = 0; - if ( MouseX >= 20 ) - { + if (MouseX >= 20) { v2 = ViewX; v1 = ViewY; - } - else - { + } else { v1 = ViewY; v2 = ViewX; - if ( ViewY >= dmaxy - 1 || dminx >= ViewX ) - { - if ( ViewY < dmaxy - 1 ) - { + if (ViewY >= dmaxy - 1 || dminx >= ViewX) { + if (ViewY < dmaxy - 1) { v1 = ViewY + 1; v0 = 1; } - if ( dminx < ViewX ) - { + if (dminx < ViewX) { v2 = ViewX - 1; v0 = 1; } - } - else - { + } else { v1 = ViewY + 1; v2 = ViewX - 1; v0 = 1; } } - if ( MouseX > 620 ) - { - if ( dmaxx - 1 > v2 ) - { - if ( dminy < v1 ) - { + if (MouseX > 620) { + if (dmaxx - 1 > v2) { + if (dminy < v1) { --v1; ++v2; v0 = 1; goto LABEL_19; } - if ( dmaxx - 1 > v2 ) - { + if (dmaxx - 1 > v2) { ++v2; v0 = 1; } } - if ( dminy < v1 ) - { + if (dminy < v1) { --v1; v0 = 1; } } -LABEL_19: - if ( MouseY >= 20 ) + LABEL_19: + if (MouseY >= 20) goto LABEL_28; - if ( dminy < v1 ) - { - if ( dminx < v2 ) - { + if (dminy < v1) { + if (dminx < v2) { --v2; --v1; goto LABEL_27; } - if ( dminy < v1 ) - { + if (dminy < v1) { --v1; v0 = 1; } } - if ( dminx >= v2 ) + if (dminx >= v2) goto LABEL_28; --v2; -LABEL_27: + LABEL_27: v0 = 1; -LABEL_28: + LABEL_28: ViewX = v2; ViewY = v1; - if ( MouseY > 460 ) - { - if ( v1 >= dmaxy - 1 || dmaxx - 1 <= v2 ) - { + if (MouseY > 460) { + if (v1 >= dmaxy - 1 || dmaxx - 1 <= v2) { ViewY = v1; - if ( v1 < dmaxy - 1 ) - { + if (v1 < dmaxy - 1) { v0 = 1; ViewY = v1 + 1; } ViewX = v2; - if ( dmaxx - 1 <= v2 ) + if (dmaxx - 1 <= v2) goto LABEL_37; ViewX = v2 + 1; - } - else - { + } else { ViewX = v2 + 1; ViewY = v1 + 1; } v0 = 1; } -LABEL_37: - if ( v0 ) + LABEL_37: + if (v0) ScrollInfo._sdir = 0; } } @@ -2961,24 +2658,19 @@ void __fastcall scrollrt_draw_game_screen(BOOL draw_cursor) { int dwHgt; // edi - if ( drawpanflag == 255 ) - { + if (drawpanflag == 255) { drawpanflag = 0; dwHgt = 480; - } - else - { + } else { dwHgt = 0; } - if ( draw_cursor ) - { + if (draw_cursor) { j_lock_buf_priv(0); scrollrt_draw_cursor_item(); j_unlock_buf_priv(0); } DrawMain(dwHgt, 0, 0, 0, 0, 0); - if ( draw_cursor ) - { + if (draw_cursor) { j_lock_buf_priv(0); scrollrt_draw_cursor_back_buffer(); j_unlock_buf_priv(0); @@ -2988,32 +2680,28 @@ void __fastcall scrollrt_draw_game_screen(BOOL draw_cursor) void __cdecl scrollrt_draw_cursor_back_buffer() { - int v0; // edx - int v1; // eax + int v0; // edx + int v1; // eax char *v2; // edi char *v3; // esi - int v4; // ecx - int v5; // ebx + int v4; // ecx + int v5; // ebx v0 = sgdwCursWdt; - if ( sgdwCursWdt ) - { + if (sgdwCursWdt) { v1 = sgdwCursY; v2 = sgSaveBack; v3 = &gpBuffer->row[sgdwCursY].pixels[sgdwCursX]; v4 = sgdwCursHgt; - if ( sgdwCursHgt ) - { + if (sgdwCursHgt) { v5 = sgdwCursHgt; - do - { + do { memcpy(v3, v2, v0); v0 = sgdwCursWdt; v2 += sgdwCursWdt; v3 += 768; --v5; - } - while ( v5 ); + } while (v5); v1 = sgdwCursY; v4 = sgdwCursHgt; } @@ -3027,96 +2715,81 @@ void __cdecl scrollrt_draw_cursor_back_buffer() void __cdecl scrollrt_draw_cursor_item() { - int v0; // ebp - int v1; // edx - int v2; // edi - int v3; // esi - unsigned int v4; // eax - unsigned int v5; // eax - int v6; // eax - char *v7; // ebx - int v8; // ebp - int v9; // edi - int v10; // esi + int v0; // ebp + int v1; // edx + int v2; // edi + int v3; // esi + unsigned int v4; // eax + unsigned int v5; // eax + int v6; // eax + char *v7; // ebx + int v8; // ebp + int v9; // edi + int v10; // esi signed int colour; // ebx - int v12; // edi - int v13; // edx - char *v14; // [esp+10h] [ebp-4h] + int v12; // edi + int v13; // edx + char *v14; // [esp+10h] [ebp-4h] - if ( pcurs > 0 ) - { + if (pcurs > 0) { v0 = cursW; - if ( cursW ) - { + if (cursW) { v1 = cursH; - if ( cursH ) - { + if (cursH) { v2 = MouseX - 1; - if ( MouseX - 1 >= 0 ) - { - if ( v2 > 639 ) + if (MouseX - 1 >= 0) { + if (v2 > 639) return; - } - else - { + } else { v2 = 0; } v3 = MouseY - 1; - if ( MouseY - 1 >= 0 ) - { - if ( v3 > 479 ) + if (MouseY - 1 >= 0) { + if (v3 > 479) return; - } - else - { + } else { v3 = 0; } v4 = v2 + cursW + 1; - if ( v4 > 0x27F ) + if (v4 > 0x27F) v4 = 639; _LOBYTE(v4) = v4 | 3; sgdwCursY = v3; sgdwCursX = v2 & 0xFFFFFFFC; sgdwCursWdt = v4 - (v2 & 0xFFFFFFFC) + 1; v5 = cursH + v3 + 1; - if ( v5 > 0x1DF ) + if (v5 > 0x1DF) v5 = 479; v14 = sgSaveBack; v6 = 1 - v3 + v5; sgdwCursHgt = v6; v7 = &gpBuffer->row[v3].pixels[v2 & 0xFFFFFFFC]; - if ( v6 ) - { + if (v6) { v8 = v6; - do - { + do { memcpy(v14, v7, sgdwCursWdt); v14 += sgdwCursWdt; v7 += 768; --v8; - } - while ( v8 ); + } while (v8); v0 = cursW; v1 = cursH; } v9 = v2 + 1; v10 = v3 + 1; gpBufEnd = (unsigned char *)gpBuffer + screen_y_times_768[640] - v0 - 2; - if ( pcurs < 12 ) - { + if (pcurs < 12) { Cel2DrawHdrOnly(v9 + 64, v1 + v10 + 159, (char *)pCursCels, pcurs, v0, 0, 8); - } - else - { + } else { colour = ICOL_WHITE; - if ( plr[myplr].HoldItem._iMagical != ITEM_QUALITY_NORMAL ) + if (plr[myplr].HoldItem._iMagical != ITEM_QUALITY_NORMAL) colour = ICOL_BLUE; - if ( !plr[myplr].HoldItem._iStatFlag ) + if (!plr[myplr].HoldItem._iStatFlag) colour = ICOL_RED; v12 = v9 + 64; CelDrawHdrClrHL(colour, v12, v1 + v10 + 159, (char *)pCursCels, pcurs, v0, 0, 8); v13 = cursH + v10 + 159; - if ( colour == ICOL_RED ) + if (colour == ICOL_RED) Cel2DrawHdrLightRed(v12, v13, (char *)pCursCels, pcurs, cursW, 0, 8, 1); else Cel2DrawHdrOnly(v12, v13, (char *)pCursCels, pcurs, cursW, 0, 8); @@ -3131,49 +2804,42 @@ void __cdecl scrollrt_draw_cursor_item() void __fastcall DrawMain(int dwHgt, int draw_desc, int draw_hp, int draw_mana, int draw_sbar, int draw_btn) { signed int v6; // ebp - DWORD v7; // ebx - int v8; // esi - int v9; // eax + DWORD v7; // ebx + int v8; // esi + int v9; // eax signed int a4; // [esp+1Ch] [ebp-8h] a4 = dwHgt; - if ( gbActive && lpDDSPrimary ) - { - if ( lpDDSPrimary->IsLost() == DDERR_SURFACELOST ) - { - if ( lpDDSPrimary->Restore() ) + if (gbActive && lpDDSPrimary) { + if (lpDDSPrimary->IsLost() == DDERR_SURFACELOST) { + if (lpDDSPrimary->Restore()) return; ResetPal(); a4 = 480; } - if ( lpDDSBackBuf == NULL ) - { + if (lpDDSBackBuf == NULL) { v6 = 1; -LABEL_8: + LABEL_8: v7 = GetTickCount(); - while ( 1 ) - { + while (1) { DDS_desc.dwSize = 108; - v8 = lpDDSPrimary->Lock(NULL, &DDS_desc, DDLOCK_WRITEONLY|DDLOCK_WAIT, NULL); - if ( !v8 ) + v8 = lpDDSPrimary->Lock(NULL, &DDS_desc, DDLOCK_WRITEONLY | DDLOCK_WAIT, NULL); + if (!v8) break; - if ( v7 - GetTickCount() > 5000 ) + if (v7 - GetTickCount() > 5000) goto LABEL_17; Sleep(1u); - if ( v8 == DDERR_SURFACELOST ) + if (v8 == DDERR_SURFACELOST) return; - if ( v8 != DDERR_WASSTILLDRAWING && v8 != DDERR_SURFACEBUSY ) - { - if ( v6 && v8 == E_FAIL ) - { + if (v8 != DDERR_WASSTILLDRAWING && v8 != DDERR_SURFACEBUSY) { + if (v6 && v8 == E_FAIL) { v6 = 0; dx_reinit(); a4 = 480; goto LABEL_8; } -LABEL_17: - if ( v8 != DDERR_SURFACELOST && v8 != DDERR_WASSTILLDRAWING && v8 != DDERR_SURFACEBUSY ) - { + LABEL_17: + if (v8 != DDERR_SURFACELOST && v8 != DDERR_WASSTILLDRAWING && v8 != DDERR_SURFACEBUSY) { DDErrMsg(v8, 3707, "C:\\Src\\Diablo\\Source\\SCROLLRT.CPP"); break; } @@ -3181,42 +2847,36 @@ LABEL_17: } } } - if ( a4 > 0 ) + if (a4 > 0) DoBlitScreen(0, 0, 640, a4); - if ( a4 < 480 ) - { - if ( draw_sbar ) + if (a4 < 480) { + if (draw_sbar) DoBlitScreen(204, 357, 232, 28); - if ( draw_desc ) + if (draw_desc) DoBlitScreen(176, 398, 288, 60); - if ( draw_mana ) - { + if (draw_mana) { DoBlitScreen(460, 352, 88, 72); DoBlitScreen(564, 416, 56, 56); } - if ( draw_hp ) + if (draw_hp) DoBlitScreen(96, 352, 88, 72); - if ( draw_btn ) - { + if (draw_btn) { DoBlitScreen(8, 357, 72, 119); DoBlitScreen(556, 357, 72, 48); - if ( (unsigned char)gbMaxPlayers > 1u ) - { + if ((unsigned char)gbMaxPlayers > 1u) { DoBlitScreen(84, 443, 36, 32); DoBlitScreen(524, 443, 36, 32); } } - if ( sgdwCursWdtOld ) + if (sgdwCursWdtOld) DoBlitScreen(sgdwCursXOld, sgdwCursYOld, sgdwCursWdtOld, sgdwCursHgtOld); - if ( sgdwCursWdt ) + if (sgdwCursWdt) DoBlitScreen(sgdwCursX, sgdwCursY, sgdwCursWdt, sgdwCursHgt); } - if ( lpDDSBackBuf == NULL ) - { + if (lpDDSBackBuf == NULL) { v9 = lpDDSPrimary->Unlock(NULL); - if ( v9 != DDERR_SURFACELOST ) - { - if ( v9 ) + if (v9 != DDERR_SURFACELOST) { + if (v9) DDErrMsg(v9, 3779, "C:\\Src\\Diablo\\Source\\SCROLLRT.CPP"); } } @@ -3231,27 +2891,24 @@ LABEL_17: #ifdef _DEBUG void __cdecl DrawFPS() { - DWORD v0; // eax - int v1; // esi + DWORD v0; // eax + int v1; // esi char String[12]; // [esp+8h] [ebp-10h] - HDC hdc; // [esp+14h] [ebp-4h] + HDC hdc; // [esp+14h] [ebp-4h] - if ( frameflag && gbActive ) - { + if (frameflag && gbActive) { ++frameend; v0 = GetTickCount(); v1 = v0 - framestart; - if ( v0 - framestart >= 1000 ) - { + if (v0 - framestart >= 1000) { framestart = v0; framerate = 1000 * frameend / v1; frameend = 0; } - if ( framerate > 99 ) + if (framerate > 99) framerate = 99; wsprintf(String, "%2d", framerate); - if ( !lpDDSPrimary->GetDC(&hdc) ) - { + if (!lpDDSPrimary->GetDC(&hdc)) { TextOut(hdc, 0, 400, String, strlen(String)); lpDDSPrimary->ReleaseDC(hdc); } @@ -3261,50 +2918,45 @@ void __cdecl DrawFPS() void __fastcall DoBlitScreen(int dwX, int dwY, int dwWdt, int dwHgt) { - int v4; // esi - int v5; // edi - int v6; // ecx - char *v7; // esi - char *v8; // edi - int v9; // edx - RECT Rect; // [esp+Ch] [ebp-20h] - int v14; // [esp+1Ch] [ebp-10h] - LONG v15; // [esp+20h] [ebp-Ch] - int v16; // [esp+24h] [ebp-8h] - LONG v17; // [esp+28h] [ebp-4h] + int v4; // esi + int v5; // edi + int v6; // ecx + char *v7; // esi + char *v8; // edi + int v9; // edx + RECT Rect; // [esp+Ch] [ebp-20h] + int v14; // [esp+1Ch] [ebp-10h] + LONG v15; // [esp+20h] [ebp-Ch] + int v16; // [esp+24h] [ebp-8h] + LONG v17; // [esp+28h] [ebp-4h] HRESULT error_code; // [esp+34h] [ebp+8h] - int error_codea; // [esp+34h] [ebp+8h] - int a4; // [esp+38h] [ebp+Ch] + int error_codea; // [esp+34h] [ebp+8h] + int a4; // [esp+38h] [ebp+Ch] v4 = dwY; v5 = dwX; - if ( lpDDSBackBuf != NULL ) - { + if (lpDDSBackBuf != NULL) { Rect.left = dwX + 64; Rect.right = dwX + 64 + dwWdt - 1; Rect.top = dwY + 160; Rect.bottom = dwY + 160 + dwHgt - 1; a4 = GetTickCount(); - while ( 1 ) - { + while (1) { error_code = lpDDSPrimary->BltFast(v5, v4, lpDDSBackBuf, &Rect, DDBLTFAST_WAIT); - if ( !error_code ) + if (!error_code) break; - if ( a4 - GetTickCount() <= 5000 ) - { + if (a4 - GetTickCount() <= 5000) { Sleep(1u); - if ( error_code == DDERR_SURFACELOST ) + if (error_code == DDERR_SURFACELOST) return; - if ( error_code == DDERR_WASSTILLDRAWING || error_code == DDERR_SURFACEBUSY ) + if (error_code == DDERR_WASSTILLDRAWING || error_code == DDERR_SURFACEBUSY) continue; } - if ( error_code != DDERR_SURFACELOST && error_code != DDERR_WASSTILLDRAWING && error_code != DDERR_SURFACEBUSY ) + if (error_code != DDERR_SURFACELOST && error_code != DDERR_WASSTILLDRAWING && error_code != DDERR_SURFACEBUSY) DDErrMsg(error_code, 3596, "C:\\Src\\Diablo\\Source\\SCROLLRT.CPP"); return; } - } - else - { + } else { v14 = 768 * dwY + dwX + 0x1E040; v17 = DDS_desc.lPitch - dwWdt; v15 = dwX + dwY * DDS_desc.lPitch; @@ -3315,14 +2967,12 @@ void __fastcall DoBlitScreen(int dwX, int dwY, int dwWdt, int dwHgt) v7 = (char *)gpBuffer + v14; v8 = (char *)DDS_desc.lpSurface + v15; v9 = dwHgt; - do - { + do { qmemcpy(v8, v7, 4 * error_codea); v7 += 4 * error_codea + v16; v8 += 4 * error_codea + v17; --v9; - } - while ( v9 ); + } while (v9); j_unlock_buf_priv(6); } } @@ -3331,12 +2981,10 @@ void __cdecl DrawAndBlit() { bool ddsdesc; // ebp bool ctrlPan; // esi - int dwHgt; // edi + int dwHgt; // edi - if ( gbRunGame ) - { - if ( drawpanflag == 255 ) - { + if (gbRunGame) { + if (drawpanflag == 255) { drawhpflag = TRUE; drawmanaflag = TRUE; drawbtnflag = 1; @@ -3344,10 +2992,8 @@ void __cdecl DrawAndBlit() ddsdesc = 0; ctrlPan = 1; dwHgt = 480; - } - else - { - if ( drawpanflag != 1 ) + } else { + if (drawpanflag != 1) return; ddsdesc = 1; ctrlPan = 0; @@ -3355,22 +3001,21 @@ void __cdecl DrawAndBlit() } drawpanflag = 0; j_lock_buf_priv(0); - if ( leveltype ) + if (leveltype) DrawView(ViewX, ViewY); else T_DrawView(ViewX, ViewY); - if ( ctrlPan ) + if (ctrlPan) ClearCtrlPan(); - if ( drawhpflag ) + if (drawhpflag) UpdateLifeFlask(); - if ( drawmanaflag ) + if (drawmanaflag) UpdateManaFlask(); - if ( drawbtnflag ) + if (drawbtnflag) DrawCtrlPan(); - if ( drawsbarflag ) + if (drawsbarflag) DrawInvBelt(); - if ( talkflag ) - { + if (talkflag) { DrawTalkPan(); dwHgt = 480; } diff --git a/Source/scrollrt.h b/Source/scrollrt.h index ebd917dc..9f5207d2 100644 --- a/Source/scrollrt.h +++ b/Source/scrollrt.h @@ -6,22 +6,22 @@ extern int light_table_index; // weak extern int screen_y_times_768[1024]; extern int scrollrt_cpp_init_value; // weak extern unsigned int sgdwCursWdtOld; // idb -extern int sgdwCursX; // idb -extern int sgdwCursY; // idb -extern unsigned char *gpBufEnd; // weak +extern int sgdwCursX; // idb +extern int sgdwCursY; // idb +extern unsigned char *gpBufEnd; // weak extern int sgdwCursHgt; extern int level_cel_block; // weak -extern int sgdwCursXOld; // idb -extern int sgdwCursYOld; // idb +extern int sgdwCursXOld; // idb +extern int sgdwCursYOld; // idb extern char arch_draw_type; // weak extern DDSURFACEDESC DDS_desc; extern int cel_transparency_active; // weak -extern int level_piece_id; // weak +extern int level_piece_id; // weak extern int sgdwCursWdt; -extern int (__fastcall *DrawPlrProc)(int player_num, int x, int y, int screen_x, int screen_y, void *cl2_buf, int frame, int frame_width, int a9, int a10); +extern int(__fastcall *DrawPlrProc)(int player_num, int x, int y, int screen_x, int screen_y, void *cl2_buf, int frame, int frame_width, int a9, int a10); extern char sgSaveBack[8192]; extern int draw_monster_num; // weak -extern int sgdwCursHgtOld; // idb +extern int sgdwCursHgtOld; // idb void __cdecl scrollrt_cpp_init(); void __cdecl ClearCursor(); diff --git a/Source/setmaps.cpp b/Source/setmaps.cpp index f91bf44f..a67ade7c 100644 --- a/Source/setmaps.cpp +++ b/Source/setmaps.cpp @@ -4,189 +4,189 @@ // BUGFIX: constant data should be const unsigned char SkelKingTrans1[8] = { - 19, 47, 26, 55, - 26, 49, 30, 53 + 19, 47, 26, 55, + 26, 49, 30, 53 }; unsigned char SkelKingTrans2[8] = { - 33, 19, 47, 29, - 37, 29, 43, 39 + 33, 19, 47, 29, + 37, 29, 43, 39 }; unsigned char SkelKingTrans3[20] = { - 27, 53, 35, 61, - 27, 35, 34, 42, - 45, 35, 53, 43, - 45, 53, 53, 61, - 31, 39, 49, 57 + 27, 53, 35, 61, + 27, 35, 34, 42, + 45, 35, 53, 43, + 45, 53, 53, 61, + 31, 39, 49, 57 }; unsigned char SkelKingTrans4[28] = { - 49, 45, 58, 51, - 57, 31, 62, 37, - 63, 31, 69, 40, - 59, 41, 73, 55, - 63, 55, 69, 65, - 73, 45, 78, 51, - 79, 43, 89, 53 + 49, 45, 58, 51, + 57, 31, 62, 37, + 63, 31, 69, 40, + 59, 41, 73, 55, + 63, 55, 69, 65, + 73, 45, 78, 51, + 79, 43, 89, 53 }; unsigned char SkelChamTrans1[20] = { - 43, 19, 50, 26, - 51, 19, 59, 26, - 35, 27, 42, 34, - 43, 27, 49, 34, - 50, 27, 59, 34 + 43, 19, 50, 26, + 51, 19, 59, 26, + 35, 27, 42, 34, + 43, 27, 49, 34, + 50, 27, 59, 34 }; unsigned char SkelChamTrans2[8] = { - 19, 31, 34, 47, - 34, 35, 42, 42 + 19, 31, 34, 47, + 34, 35, 42, 42 }; unsigned char SkelChamTrans3[36] = { - 43, 35, 50, 42, - 51, 35, 62, 42, - 63, 31, 66, 46, - 67, 31, 78, 34, - 67, 35, 78, 42, - 67, 43, 78, 46, - 35, 43, 42, 51, - 43, 43, 49, 51, - 50, 43, 59, 51 + 43, 35, 50, 42, + 51, 35, 62, 42, + 63, 31, 66, 46, + 67, 31, 78, 34, + 67, 35, 78, 42, + 67, 43, 78, 46, + 35, 43, 42, 51, + 43, 43, 49, 51, + 50, 43, 59, 51 }; char *quest_level_names[] = { - "", - "Skeleton King's Lair", - "Bone Chamber", - "Maze", - "Poisoned Water Supply", - "Archbishop Lazarus' Lair" + "", + "Skeleton King's Lair", + "Bone Chamber", + "Maze", + "Poisoned Water Supply", + "Archbishop Lazarus' Lair" }; int __fastcall ObjIndex(int x, int y) { - int i; - int oi; + int i; + int oi; - for (i = 0; i < nobjects; i++) { - oi = objectactive[i]; - if (object[oi]._ox == x && object[oi]._oy == y) - return oi; - } - TermMsg("ObjIndex: Active object not found at (%d,%d)", x, y); - return -1; + for (i = 0; i < nobjects; i++) { + oi = objectactive[i]; + if (object[oi]._ox == x && object[oi]._oy == y) + return oi; + } + TermMsg("ObjIndex: Active object not found at (%d,%d)", x, y); + return -1; } void __cdecl AddSKingObjs() { - SetObjMapRange(ObjIndex(64, 34), 20, 7, 23, 10, 1); - SetObjMapRange(ObjIndex(64, 59), 20, 14, 21, 16, 2); - SetObjMapRange(ObjIndex(27, 37), 8, 1, 15, 11, 3); - SetObjMapRange(ObjIndex(46, 35), 8, 1, 15, 11, 3); - SetObjMapRange(ObjIndex(49, 53), 8, 1, 15, 11, 3); - SetObjMapRange(ObjIndex(27, 53), 8, 1, 15, 11, 3); + SetObjMapRange(ObjIndex(64, 34), 20, 7, 23, 10, 1); + SetObjMapRange(ObjIndex(64, 59), 20, 14, 21, 16, 2); + SetObjMapRange(ObjIndex(27, 37), 8, 1, 15, 11, 3); + SetObjMapRange(ObjIndex(46, 35), 8, 1, 15, 11, 3); + SetObjMapRange(ObjIndex(49, 53), 8, 1, 15, 11, 3); + SetObjMapRange(ObjIndex(27, 53), 8, 1, 15, 11, 3); } void __cdecl AddSChamObjs() { - SetObjMapRange(ObjIndex(37, 30), 17, 0, 21, 5, 1); - SetObjMapRange(ObjIndex(37, 46), 13, 0, 16, 5, 2); + SetObjMapRange(ObjIndex(37, 30), 17, 0, 21, 5, 1); + SetObjMapRange(ObjIndex(37, 46), 13, 0, 16, 5, 2); } void __cdecl AddVileObjs() { - SetObjMapRange(ObjIndex(26, 45), 1, 1, 9, 10, 1); - SetObjMapRange(ObjIndex(45, 46), 11, 1, 20, 10, 2); - SetObjMapRange(ObjIndex(35, 36), 7, 11, 13, 18, 3); + SetObjMapRange(ObjIndex(26, 45), 1, 1, 9, 10, 1); + SetObjMapRange(ObjIndex(45, 46), 11, 1, 20, 10, 2); + SetObjMapRange(ObjIndex(35, 36), 7, 11, 13, 18, 3); } void __fastcall DRLG_SetMapTrans(char *sFileName) { - int x, y; - int i, j; - UCHAR *pLevelMap; - UCHAR *d; - DWORD dwOffset; + int x, y; + int i, j; + UCHAR *pLevelMap; + UCHAR *d; + DWORD dwOffset; - pLevelMap = LoadFileInMem(sFileName, NULL); - d = pLevelMap + 2; - x = pLevelMap[0]; - y = *d; - dwOffset = (x * y + 1) * 2; - x <<= 1; - y <<= 1; - dwOffset += 3 * x * y * 2; - d += dwOffset; + pLevelMap = LoadFileInMem(sFileName, NULL); + d = pLevelMap + 2; + x = pLevelMap[0]; + y = *d; + dwOffset = (x * y + 1) * 2; + x <<= 1; + y <<= 1; + dwOffset += 3 * x * y * 2; + d += dwOffset; - for (j = 0; j < y; j++) { - for (i = 0; i < x; i++) { - dung_map[16 + i][16 + j] = *d; - d += 2; - } - } - mem_free_dbg(pLevelMap); + for (j = 0; j < y; j++) { + for (i = 0; i < x; i++) { + dung_map[16 + i][16 + j] = *d; + d += 2; + } + } + mem_free_dbg(pLevelMap); } void __cdecl LoadSetMap() { - switch (setlvlnum) { - case SL_SKELKING: - if (quests[QTYPE_KING]._qactive == 1) { - quests[QTYPE_KING]._qactive = 2; - quests[QTYPE_KING]._qvar1 = 1; - } - LoadPreL1Dungeon("Levels\\L1Data\\SklKng1.DUN", 83, 45); - LoadL1Dungeon("Levels\\L1Data\\SklKng2.DUN", 83, 45); - LoadPalette("Levels\\L1Data\\L1_2.pal"); - DRLG_AreaTrans(sizeof(SkelKingTrans1) / 4, SkelKingTrans1); - DRLG_ListTrans(sizeof(SkelKingTrans2) / 4, SkelKingTrans2); - DRLG_AreaTrans(sizeof(SkelKingTrans3) / 4, SkelKingTrans3); - DRLG_ListTrans(sizeof(SkelKingTrans4) / 4, SkelKingTrans4); - AddL1Objs(0, 0, MAXDUNX, MAXDUNY); - AddSKingObjs(); - InitSKingTriggers(); - break; - case SL_BONECHAMB: - LoadPreL2Dungeon("Levels\\L2Data\\Bonecha2.DUN", 69, 39); - LoadL2Dungeon("Levels\\L2Data\\Bonecha1.DUN", 69, 39); - LoadPalette("Levels\\L2Data\\L2_2.pal"); - DRLG_ListTrans(sizeof(SkelChamTrans1) / 4, SkelChamTrans1); - DRLG_AreaTrans(sizeof(SkelChamTrans2) / 4, SkelChamTrans2); - DRLG_ListTrans(sizeof(SkelChamTrans3) / 4, SkelChamTrans3); - AddL2Objs(0, 0, MAXDUNX, MAXDUNY); - AddSChamObjs(); - InitSChambTriggers(); - break; - case SL_MAZE: - LoadPreL1Dungeon("Levels\\L1Data\\Lv1MazeA.DUN", 20, 50); - LoadL1Dungeon("Levels\\L1Data\\Lv1MazeB.DUN", 20, 50); - LoadPalette("Levels\\L1Data\\L1_5.pal"); - AddL1Objs(0, 0, MAXDUNX, MAXDUNY); - DRLG_SetMapTrans("Levels\\L1Data\\Lv1MazeA.DUN"); - break; - case SL_POISONWATER: - if (quests[QTYPE_PW]._qactive == 1) - quests[QTYPE_PW]._qactive = 2; - LoadPreL3Dungeon("Levels\\L3Data\\Foulwatr.DUN", 19, 50); - LoadL3Dungeon("Levels\\L3Data\\Foulwatr.DUN", 20, 50); - LoadPalette("Levels\\L3Data\\L3pfoul.pal"); - InitPWaterTriggers(); - break; - case SL_VILEBETRAYER: - if (quests[QTYPE_VB]._qactive == 3) { - quests[QTYPE_VB]._qvar2 = 4; - } else if (quests[QTYPE_VB]._qactive == 2) { - quests[QTYPE_VB]._qvar2 = 3; - } - LoadPreL1Dungeon("Levels\\L1Data\\Vile1.DUN", 35, 36); - LoadL1Dungeon("Levels\\L1Data\\Vile2.DUN", 35, 36); - LoadPalette("Levels\\L1Data\\L1_2.pal"); - AddL1Objs(0, 0, MAXDUNX, MAXDUNY); - AddVileObjs(); - DRLG_SetMapTrans("Levels\\L1Data\\Vile1.DUN"); - InitNoTriggers(); - break; - } + switch (setlvlnum) { + case SL_SKELKING: + if (quests[QTYPE_KING]._qactive == 1) { + quests[QTYPE_KING]._qactive = 2; + quests[QTYPE_KING]._qvar1 = 1; + } + LoadPreL1Dungeon("Levels\\L1Data\\SklKng1.DUN", 83, 45); + LoadL1Dungeon("Levels\\L1Data\\SklKng2.DUN", 83, 45); + LoadPalette("Levels\\L1Data\\L1_2.pal"); + DRLG_AreaTrans(sizeof(SkelKingTrans1) / 4, SkelKingTrans1); + DRLG_ListTrans(sizeof(SkelKingTrans2) / 4, SkelKingTrans2); + DRLG_AreaTrans(sizeof(SkelKingTrans3) / 4, SkelKingTrans3); + DRLG_ListTrans(sizeof(SkelKingTrans4) / 4, SkelKingTrans4); + AddL1Objs(0, 0, MAXDUNX, MAXDUNY); + AddSKingObjs(); + InitSKingTriggers(); + break; + case SL_BONECHAMB: + LoadPreL2Dungeon("Levels\\L2Data\\Bonecha2.DUN", 69, 39); + LoadL2Dungeon("Levels\\L2Data\\Bonecha1.DUN", 69, 39); + LoadPalette("Levels\\L2Data\\L2_2.pal"); + DRLG_ListTrans(sizeof(SkelChamTrans1) / 4, SkelChamTrans1); + DRLG_AreaTrans(sizeof(SkelChamTrans2) / 4, SkelChamTrans2); + DRLG_ListTrans(sizeof(SkelChamTrans3) / 4, SkelChamTrans3); + AddL2Objs(0, 0, MAXDUNX, MAXDUNY); + AddSChamObjs(); + InitSChambTriggers(); + break; + case SL_MAZE: + LoadPreL1Dungeon("Levels\\L1Data\\Lv1MazeA.DUN", 20, 50); + LoadL1Dungeon("Levels\\L1Data\\Lv1MazeB.DUN", 20, 50); + LoadPalette("Levels\\L1Data\\L1_5.pal"); + AddL1Objs(0, 0, MAXDUNX, MAXDUNY); + DRLG_SetMapTrans("Levels\\L1Data\\Lv1MazeA.DUN"); + break; + case SL_POISONWATER: + if (quests[QTYPE_PW]._qactive == 1) + quests[QTYPE_PW]._qactive = 2; + LoadPreL3Dungeon("Levels\\L3Data\\Foulwatr.DUN", 19, 50); + LoadL3Dungeon("Levels\\L3Data\\Foulwatr.DUN", 20, 50); + LoadPalette("Levels\\L3Data\\L3pfoul.pal"); + InitPWaterTriggers(); + break; + case SL_VILEBETRAYER: + if (quests[QTYPE_VB]._qactive == 3) { + quests[QTYPE_VB]._qvar2 = 4; + } else if (quests[QTYPE_VB]._qactive == 2) { + quests[QTYPE_VB]._qvar2 = 3; + } + LoadPreL1Dungeon("Levels\\L1Data\\Vile1.DUN", 35, 36); + LoadL1Dungeon("Levels\\L1Data\\Vile2.DUN", 35, 36); + LoadPalette("Levels\\L1Data\\L1_2.pal"); + AddL1Objs(0, 0, MAXDUNX, MAXDUNY); + AddVileObjs(); + DRLG_SetMapTrans("Levels\\L1Data\\Vile1.DUN"); + InitNoTriggers(); + break; + } } diff --git a/Source/sha.cpp b/Source/sha.cpp index 2b32ed03..93927a98 100644 --- a/Source/sha.cpp +++ b/Source/sha.cpp @@ -6,119 +6,119 @@ SHA1Context sgSHA1[3]; void __cdecl SHA1Clear() { - memset(sgSHA1, 0, sizeof(sgSHA1)); + memset(sgSHA1, 0, sizeof(sgSHA1)); } void __fastcall SHA1Result(int n, char Message_Digest[SHA1HashSize]) { - DWORD *Message_Digest_Block = (DWORD *)Message_Digest; - if (Message_Digest) { - for (int i = 0; i < 5; i++) { - *Message_Digest_Block = sgSHA1[n].state[i]; - Message_Digest_Block++; - } - } + DWORD *Message_Digest_Block = (DWORD *)Message_Digest; + if (Message_Digest) { + for (int i = 0; i < 5; i++) { + *Message_Digest_Block = sgSHA1[n].state[i]; + Message_Digest_Block++; + } + } } void __fastcall SHA1Calculate(int n, const char *data, char Message_Digest[SHA1HashSize]) { - SHA1Input(&sgSHA1[n], data, 64); - if (Message_Digest) - SHA1Result(n, Message_Digest); + SHA1Input(&sgSHA1[n], data, 64); + if (Message_Digest) + SHA1Result(n, Message_Digest); } void __fastcall SHA1Input(SHA1Context *context, const char *message_array, int len) { - int count = context->count[0] + 8 * len; - if (count < context->count[0]) - context->count[1]++; + int count = context->count[0] + 8 * len; + if (count < context->count[0]) + context->count[1]++; - context->count[0] = count; - context->count[1] += len >> 29; + context->count[0] = count; + context->count[1] += len >> 29; - for (int i = len; i >= 64; i -= 64) { - memcpy(context->buffer, message_array, sizeof(context->buffer)); - SHA1ProcessMessageBlock(context); - message_array += 64; - } + for (int i = len; i >= 64; i -= 64) { + memcpy(context->buffer, message_array, sizeof(context->buffer)); + SHA1ProcessMessageBlock(context); + message_array += 64; + } } void __fastcall SHA1ProcessMessageBlock(SHA1Context *context) { - int i; - int temp; - int W[80]; - int A, B, C, D, E; + int i; + int temp; + int W[80]; + int A, B, C, D, E; - DWORD *buf = (DWORD *)context->buffer; - for (i = 0; i < 16; i++) - W[i] = buf[i]; + DWORD *buf = (DWORD *)context->buffer; + for (i = 0; i < 16; i++) + W[i] = buf[i]; - for (i = 16; i < 80; i++) { - W[i] = W[i - 16] ^ W[i - 14] ^ W[i - 8] ^ W[i - 3]; - } + for (i = 16; i < 80; i++) { + W[i] = W[i - 16] ^ W[i - 14] ^ W[i - 8] ^ W[i - 3]; + } - A = context->state[0]; - B = context->state[1]; - C = context->state[2]; - D = context->state[3]; - E = context->state[4]; + A = context->state[0]; + B = context->state[1]; + C = context->state[2]; + D = context->state[3]; + E = context->state[4]; - for (i = 0; i < 20; i++) { - temp = SHA1CircularShift(5, A) + ((B & C) | ((~B) & D)) + E + W[i] + 0x5A827999; - E = D; - D = C; - C = SHA1CircularShift(30, B); - B = A; - A = temp; - } + for (i = 0; i < 20; i++) { + temp = SHA1CircularShift(5, A) + ((B & C) | ((~B) & D)) + E + W[i] + 0x5A827999; + E = D; + D = C; + C = SHA1CircularShift(30, B); + B = A; + A = temp; + } - for (i = 20; i < 40; i++) { - temp = SHA1CircularShift(5, A) + (B ^ C ^ D) + E + W[i] + 0x6ED9EBA1; - E = D; - D = C; - C = SHA1CircularShift(30, B); - B = A; - A = temp; - } + for (i = 20; i < 40; i++) { + temp = SHA1CircularShift(5, A) + (B ^ C ^ D) + E + W[i] + 0x6ED9EBA1; + E = D; + D = C; + C = SHA1CircularShift(30, B); + B = A; + A = temp; + } - for (i = 40; i < 60; i++) { - temp = SHA1CircularShift(5, A) + ((B & C) | (B & D) | (C & D)) + E + W[i] + 0x8F1BBCDC; - E = D; - D = C; - C = SHA1CircularShift(30, B); - B = A; - A = temp; - } + for (i = 40; i < 60; i++) { + temp = SHA1CircularShift(5, A) + ((B & C) | (B & D) | (C & D)) + E + W[i] + 0x8F1BBCDC; + E = D; + D = C; + C = SHA1CircularShift(30, B); + B = A; + A = temp; + } - for (i = 60; i < 80; i++) { - temp = SHA1CircularShift(5, A) + (B ^ C ^ D) + E + W[i] + 0xCA62C1D6; - E = D; - D = C; - C = SHA1CircularShift(30, B); - B = A; - A = temp; - } + for (i = 60; i < 80; i++) { + temp = SHA1CircularShift(5, A) + (B ^ C ^ D) + E + W[i] + 0xCA62C1D6; + E = D; + D = C; + C = SHA1CircularShift(30, B); + B = A; + A = temp; + } - context->state[0] += A; - context->state[1] += B; - context->state[2] += C; - context->state[3] += D; - context->state[4] += E; + context->state[0] += A; + context->state[1] += B; + context->state[2] += C; + context->state[3] += D; + context->state[4] += E; } void __fastcall SHA1Reset(int n) { - SHA1Init(&sgSHA1[n]); + SHA1Init(&sgSHA1[n]); } void __fastcall SHA1Init(SHA1Context *context) { - context->count[0] = 0; - context->count[1] = 0; - context->state[0] = 0x67452301; - context->state[1] = 0xEFCDAB89; - context->state[2] = 0x98BADCFE; - context->state[3] = 0x10325476; - context->state[4] = 0xC3D2E1F0; + context->count[0] = 0; + context->count[1] = 0; + context->state[0] = 0x67452301; + context->state[1] = 0xEFCDAB89; + context->state[2] = 0x98BADCFE; + context->state[3] = 0x10325476; + context->state[4] = 0xC3D2E1F0; } diff --git a/Source/sha.h b/Source/sha.h index c6e61d49..fd47123e 100644 --- a/Source/sha.h +++ b/Source/sha.h @@ -6,7 +6,7 @@ * Define the SHA1 circular left shift macro */ #define SHA1CircularShift(bits, word) \ - (((word) << (bits)) | ((word) >> (32 - (bits)))) + (((word) << (bits)) | ((word) >> (32 - (bits)))) #define SHA1HashSize 20 //sha diff --git a/Source/sound.cpp b/Source/sound.cpp index df38a09b..64ec9c4f 100644 --- a/Source/sound.cpp +++ b/Source/sound.cpp @@ -21,393 +21,393 @@ BYTE gbSoundOn = TRUE; BYTE gbDupSounds = TRUE; int sgnMusicTrack = 6; char *sgszMusicTracks[NUM_MUSIC] = { - "Music\\DTowne.wav", - "Music\\DLvlA.wav", - "Music\\DLvlB.wav", - "Music\\DLvlC.wav", - "Music\\DLvlD.wav", - "Music\\Dintro.wav" + "Music\\DTowne.wav", + "Music\\DLvlA.wav", + "Music\\DLvlB.wav", + "Music\\DLvlC.wav", + "Music\\DLvlD.wav", + "Music\\Dintro.wav" }; char unk_volume[4][2] = { - { 15, -16 }, - { 15, -16 }, - { 30, -31 }, - { 30, -31 } + { 15, -16 }, + { 15, -16 }, + { 30, -31 }, + { 30, -31 } }; struct sound_cpp_init { - sound_cpp_init() - { - sound_cpp_init_value = sound_inf; - } + sound_cpp_init() + { + sound_cpp_init_value = sound_inf; + } } _sound_cpp_init; // 47F24C: using guessed type int sound_inf; void __fastcall snd_update(BOOL bStopAll) { - DWORD error_code; + DWORD error_code; - for (DWORD i = 0; i < 8; i++) { - if (!DSBs[i]) - continue; + for (DWORD i = 0; i < 8; i++) { + if (!DSBs[i]) + continue; - if (!bStopAll && !DSBs[i]->GetStatus(&error_code) && error_code == DSBSTATUS_PLAYING) - continue; + if (!bStopAll && !DSBs[i]->GetStatus(&error_code) && error_code == DSBSTATUS_PLAYING) + continue; - DSBs[i]->Stop(); - DSBs[i]->Release(); - DSBs[i] = NULL; - } + DSBs[i]->Stop(); + DSBs[i]->Release(); + DSBs[i] = NULL; + } } void __fastcall snd_stop_snd(TSnd *pSnd) { - if (pSnd && pSnd->DSB) - pSnd->DSB->Stop(); + if (pSnd && pSnd->DSB) + pSnd->DSB->Stop(); } BOOL __fastcall snd_playing(TSnd *pSnd) { - DWORD error_code; + DWORD error_code; - if (!pSnd) - return FALSE; + if (!pSnd) + return FALSE; - if (pSnd->DSB == NULL) - return FALSE; + if (pSnd->DSB == NULL) + return FALSE; - if (pSnd->DSB->GetStatus(&error_code)) - return FALSE; + if (pSnd->DSB->GetStatus(&error_code)) + return FALSE; - return error_code == DSBSTATUS_PLAYING; + return error_code == DSBSTATUS_PLAYING; } void __fastcall snd_play_snd(TSnd *pSnd, int lVolume, int lPan) { - if (!pSnd || !gbSoundOn) { - return; - } + if (!pSnd || !gbSoundOn) { + return; + } - LPDIRECTSOUNDBUFFER DSB = pSnd->DSB; - if (!DSB) { - return; - } + LPDIRECTSOUNDBUFFER DSB = pSnd->DSB; + if (!DSB) { + return; + } - DWORD tc = GetTickCount(); - if (tc - pSnd->start_tc < 80) { - pSnd->start_tc = GetTickCount(); - return; - } + DWORD tc = GetTickCount(); + if (tc - pSnd->start_tc < 80) { + pSnd->start_tc = GetTickCount(); + return; + } - if (snd_playing(pSnd)) { - DSB = sound_dup_channel(pSnd->DSB); - if (DSB == 0) { - return; - } - } + if (snd_playing(pSnd)) { + DSB = sound_dup_channel(pSnd->DSB); + if (DSB == 0) { + return; + } + } - lVolume += sglSoundVolume; - if (lVolume < VOLUME_MIN) { - lVolume = VOLUME_MIN; - } else if (lVolume > VOLUME_MAX) { - lVolume = VOLUME_MAX; - } - DSB->SetVolume(lVolume); + lVolume += sglSoundVolume; + if (lVolume < VOLUME_MIN) { + lVolume = VOLUME_MIN; + } else if (lVolume > VOLUME_MAX) { + lVolume = VOLUME_MAX; + } + DSB->SetVolume(lVolume); - DSB->SetPan(lPan); + DSB->SetPan(lPan); - HRESULT error_code = DSB->Play(0, 0, 0); - if (error_code != DSERR_BUFFERLOST) { - if (error_code != DS_OK) { - DSErrMsg(error_code, 261, "C:\\Src\\Diablo\\Source\\SOUND.CPP"); - } - } else if (sound_file_reload(pSnd, DSB)) { - DSB->Play(0, 0, 0); - } + HRESULT error_code = DSB->Play(0, 0, 0); + if (error_code != DSERR_BUFFERLOST) { + if (error_code != DS_OK) { + DSErrMsg(error_code, 261, "C:\\Src\\Diablo\\Source\\SOUND.CPP"); + } + } else if (sound_file_reload(pSnd, DSB)) { + DSB->Play(0, 0, 0); + } - pSnd->start_tc = tc; + pSnd->start_tc = tc; } LPDIRECTSOUNDBUFFER __fastcall sound_dup_channel(LPDIRECTSOUNDBUFFER DSB) { - if (!gbDupSounds) { - return NULL; - } + if (!gbDupSounds) { + return NULL; + } - for (DWORD i = 0; i < 8; i++) { - if (!DSBs[i]) { - if (sglpDS->DuplicateSoundBuffer(DSB, &DSBs[i]) != DS_OK) { - return NULL; - } + for (DWORD i = 0; i < 8; i++) { + if (!DSBs[i]) { + if (sglpDS->DuplicateSoundBuffer(DSB, &DSBs[i]) != DS_OK) { + return NULL; + } - return DSBs[i]; - } - } + return DSBs[i]; + } + } - return NULL; + return NULL; } BOOL __fastcall sound_file_reload(TSnd *sound_file, LPDIRECTSOUNDBUFFER DSB) { - if (DSB->Restore()) - return FALSE; + if (DSB->Restore()) + return FALSE; - HANDLE file; - LPVOID buf1, buf2; - DWORD size1, size2; + HANDLE file; + LPVOID buf1, buf2; + DWORD size1, size2; - BOOL rv = FALSE; + BOOL rv = FALSE; - WOpenFile(sound_file->sound_path, &file, 0); - WSetFilePointer(file, sound_file->chunk.dwOffset, 0, 0); - if (DSB->Lock(0, sound_file->chunk.dwSize, &buf1, &size1, &buf2, &size2, 0) == DS_OK) { - WReadFile(file, buf1, size1); - if (DSB->Unlock(buf1, size1, buf2, size2) == DS_OK) { - rv = TRUE; - } - } + WOpenFile(sound_file->sound_path, &file, 0); + WSetFilePointer(file, sound_file->chunk.dwOffset, 0, 0); + if (DSB->Lock(0, sound_file->chunk.dwSize, &buf1, &size1, &buf2, &size2, 0) == DS_OK) { + WReadFile(file, buf1, size1); + if (DSB->Unlock(buf1, size1, buf2, size2) == DS_OK) { + rv = TRUE; + } + } - WCloseFile(file); + WCloseFile(file); - return rv; + return rv; } TSnd *__fastcall sound_file_load(char *path) { - if (!sglpDS) - return NULL; + if (!sglpDS) + return NULL; - void *file, *wave_file; - WOpenFile(path, &file, 0); - TSnd *pSnd = (TSnd *)DiabloAllocPtr(40); - memset(pSnd, 0, sizeof(TSnd)); - pSnd->sound_path = path; - pSnd->start_tc = GetTickCount() - 81; + void *file, *wave_file; + WOpenFile(path, &file, 0); + TSnd *pSnd = (TSnd *)DiabloAllocPtr(40); + memset(pSnd, 0, sizeof(TSnd)); + pSnd->sound_path = path; + pSnd->start_tc = GetTickCount() - 81; - wave_file = LoadWaveFile(file, &pSnd->fmt, &pSnd->chunk); - if (!wave_file) - TermMsg("Invalid sound format on file %s", pSnd->sound_path); + wave_file = LoadWaveFile(file, &pSnd->fmt, &pSnd->chunk); + if (!wave_file) + TermMsg("Invalid sound format on file %s", pSnd->sound_path); - sound_CreateSoundBuffer(pSnd); + sound_CreateSoundBuffer(pSnd); - LPVOID buf1, buf2; - DWORD size1, size2; - HRESULT error_code = pSnd->DSB->Lock(0, pSnd->chunk.dwSize, &buf1, &size1, &buf2, &size2, 0); - if (error_code != DS_OK) - DSErrMsg(error_code, 318, "C:\\Src\\Diablo\\Source\\SOUND.CPP"); + LPVOID buf1, buf2; + DWORD size1, size2; + HRESULT error_code = pSnd->DSB->Lock(0, pSnd->chunk.dwSize, &buf1, &size1, &buf2, &size2, 0); + if (error_code != DS_OK) + DSErrMsg(error_code, 318, "C:\\Src\\Diablo\\Source\\SOUND.CPP"); - memcpy(buf1, (char *)wave_file + pSnd->chunk.dwOffset, size1); + memcpy(buf1, (char *)wave_file + pSnd->chunk.dwOffset, size1); - error_code = pSnd->DSB->Unlock(buf1, size1, buf2, size2); - if (error_code != DS_OK) - DSErrMsg(error_code, 325, "C:\\Src\\Diablo\\Source\\SOUND.CPP"); + error_code = pSnd->DSB->Unlock(buf1, size1, buf2, size2); + if (error_code != DS_OK) + DSErrMsg(error_code, 325, "C:\\Src\\Diablo\\Source\\SOUND.CPP"); - mem_free_dbg(wave_file); - WCloseFile(file); + mem_free_dbg(wave_file); + WCloseFile(file); - return pSnd; + return pSnd; } // 456F07: could not find valid save-restore pair for esi void __fastcall sound_CreateSoundBuffer(TSnd *sound_file) { - DSBUFFERDESC DSB; - memset(&DSB, 0, sizeof(DSBUFFERDESC)); + DSBUFFERDESC DSB; + memset(&DSB, 0, sizeof(DSBUFFERDESC)); - DSB.dwBufferBytes = sound_file->chunk.dwSize; - DSB.lpwfxFormat = &sound_file->fmt; - DSB.dwSize = sizeof(DSBUFFERDESC); - DSB.dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLPAN | DSBCAPS_STATIC; + DSB.dwBufferBytes = sound_file->chunk.dwSize; + DSB.lpwfxFormat = &sound_file->fmt; + DSB.dwSize = sizeof(DSBUFFERDESC); + DSB.dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLPAN | DSBCAPS_STATIC; - HRESULT error_code = sglpDS->CreateSoundBuffer(&DSB, &sound_file->DSB, NULL); - if (error_code != ERROR_SUCCESS) - DSErrMsg(error_code, 282, "C:\\Src\\Diablo\\Source\\SOUND.CPP"); + HRESULT error_code = sglpDS->CreateSoundBuffer(&DSB, &sound_file->DSB, NULL); + if (error_code != ERROR_SUCCESS) + DSErrMsg(error_code, 282, "C:\\Src\\Diablo\\Source\\SOUND.CPP"); } void __fastcall sound_file_cleanup(TSnd *sound_file) { - if (sound_file) { - if (sound_file->DSB) { - sound_file->DSB->Stop(); - sound_file->DSB->Release(); - sound_file->DSB = NULL; - } + if (sound_file) { + if (sound_file->DSB) { + sound_file->DSB->Stop(); + sound_file->DSB->Release(); + sound_file->DSB = NULL; + } - mem_free_dbg(sound_file); - } + mem_free_dbg(sound_file); + } } void __fastcall snd_init(HWND hWnd) { - sound_load_volume("Sound Volume", &sglSoundVolume); - gbSoundOn = sglSoundVolume > VOLUME_MIN; + sound_load_volume("Sound Volume", &sglSoundVolume); + gbSoundOn = sglSoundVolume > VOLUME_MIN; - sound_load_volume("Music Volume", &sglMusicVolume); - gbMusicOn = sglMusicVolume > VOLUME_MIN; + sound_load_volume("Music Volume", &sglMusicVolume); + gbMusicOn = sglMusicVolume > VOLUME_MIN; - if (sound_DirectSoundCreate(NULL, &sglpDS, NULL) != DS_OK) - sglpDS = NULL; + if (sound_DirectSoundCreate(NULL, &sglpDS, NULL) != DS_OK) + sglpDS = NULL; - if (sglpDS && sglpDS->SetCooperativeLevel(hWnd, DSSCL_EXCLUSIVE) == DS_OK) - sound_create_primary_buffer(0); + if (sglpDS && sglpDS->SetCooperativeLevel(hWnd, DSSCL_EXCLUSIVE) == DS_OK) + sound_create_primary_buffer(0); - SVidInitialize(sglpDS); - SFileDdaInitialize(sglpDS); + SVidInitialize(sglpDS); + SFileDdaInitialize(sglpDS); - gbSndInited = sglpDS != NULL; + gbSndInited = sglpDS != NULL; } void __fastcall sound_load_volume(char *value_name, int *value) { - int v = *value; - if (!SRegLoadValue("Diablo", value_name, 0, &v)) { - v = VOLUME_MAX; - } - *value = v; + int v = *value; + if (!SRegLoadValue("Diablo", value_name, 0, &v)) { + v = VOLUME_MAX; + } + *value = v; - if (*value < VOLUME_MIN) { - *value = VOLUME_MIN; - } else if (*value > VOLUME_MAX) { - *value = VOLUME_MAX; - } - *value -= *value % 100; + if (*value < VOLUME_MIN) { + *value = VOLUME_MIN; + } else if (*value > VOLUME_MAX) { + *value = VOLUME_MAX; + } + *value -= *value % 100; } void __fastcall sound_create_primary_buffer(HANDLE music_track) { - HRESULT error_code; - DSBUFFERDESC dsbuf; - WAVEFORMATEX format; + HRESULT error_code; + DSBUFFERDESC dsbuf; + WAVEFORMATEX format; - if (!music_track) { - memset(&dsbuf, 0, sizeof(DSBUFFERDESC)); - dsbuf.dwSize = sizeof(DSBUFFERDESC); - dsbuf.dwFlags = DSBCAPS_PRIMARYBUFFER; + if (!music_track) { + memset(&dsbuf, 0, sizeof(DSBUFFERDESC)); + dsbuf.dwSize = sizeof(DSBUFFERDESC); + dsbuf.dwFlags = DSBCAPS_PRIMARYBUFFER; - error_code = sglpDS->CreateSoundBuffer(&dsbuf, &sglpDSB, NULL); - if (error_code != DS_OK) - DSErrMsg(error_code, 375, "C:\\Src\\Diablo\\Source\\SOUND.CPP"); - } + error_code = sglpDS->CreateSoundBuffer(&dsbuf, &sglpDSB, NULL); + if (error_code != DS_OK) + DSErrMsg(error_code, 375, "C:\\Src\\Diablo\\Source\\SOUND.CPP"); + } - if (sglpDSB) { - DSCAPS dsbcaps; - dsbcaps.dwSize = sizeof(DSCAPS); + if (sglpDSB) { + DSCAPS dsbcaps; + dsbcaps.dwSize = sizeof(DSCAPS); - error_code = sglpDS->GetCaps(&dsbcaps); - if (error_code != DS_OK) - DSErrMsg(error_code, 383, "C:\\Src\\Diablo\\Source\\SOUND.CPP"); + error_code = sglpDS->GetCaps(&dsbcaps); + if (error_code != DS_OK) + DSErrMsg(error_code, 383, "C:\\Src\\Diablo\\Source\\SOUND.CPP"); - if (!music_track || !LoadWaveFormat(music_track, &format)) { - memset(&format, 0, sizeof(WAVEFORMATEX)); - format.wFormatTag = WAVE_FORMAT_PCM; - format.nSamplesPerSec = 22050; - format.wBitsPerSample = 16; - format.cbSize = 0; - } + if (!music_track || !LoadWaveFormat(music_track, &format)) { + memset(&format, 0, sizeof(WAVEFORMATEX)); + format.wFormatTag = WAVE_FORMAT_PCM; + format.nSamplesPerSec = 22050; + format.wBitsPerSample = 16; + format.cbSize = 0; + } - format.nChannels = 2; - format.nBlockAlign = format.nChannels * format.wBitsPerSample / 8; - format.nAvgBytesPerSec = format.nSamplesPerSec * format.nBlockAlign; + format.nChannels = 2; + format.nBlockAlign = format.nChannels * format.wBitsPerSample / 8; + format.nAvgBytesPerSec = format.nSamplesPerSec * format.nBlockAlign; - sglpDSB->SetFormat(&format); - } + sglpDSB->SetFormat(&format); + } } // 69F100: using guessed type int sglpDSB; HRESULT __fastcall sound_DirectSoundCreate(LPGUID lpGuid, LPDIRECTSOUND *ppDS, LPUNKNOWN pUnkOuter) { - if (hDsound_dll == NULL) { - hDsound_dll = LoadLibrary("dsound.dll"); - if (hDsound_dll == NULL) { - ErrDlg(IDD_DIALOG5, GetLastError(), "C:\\Src\\Diablo\\Source\\SOUND.CPP", 422); - } - } + if (hDsound_dll == NULL) { + hDsound_dll = LoadLibrary("dsound.dll"); + if (hDsound_dll == NULL) { + ErrDlg(IDD_DIALOG5, GetLastError(), "C:\\Src\\Diablo\\Source\\SOUND.CPP", 422); + } + } - HRESULT(WINAPI * DirectSoundCreate) - (LPGUID lpGuid, LPDIRECTSOUND * ppDS, LPUNKNOWN pUnkOuter); - DirectSoundCreate = (HRESULT(WINAPI *)(LPGUID, LPDIRECTSOUND *, LPUNKNOWN))GetProcAddress(hDsound_dll, "DirectSoundCreate"); - if (DirectSoundCreate == NULL) { - ErrDlg(IDD_DIALOG5, GetLastError(), "C:\\Src\\Diablo\\Source\\SOUND.CPP", 427); - } - return DirectSoundCreate(lpGuid, ppDS, pUnkOuter); + HRESULT(WINAPI * DirectSoundCreate) + (LPGUID lpGuid, LPDIRECTSOUND * ppDS, LPUNKNOWN pUnkOuter); + DirectSoundCreate = (HRESULT(WINAPI *)(LPGUID, LPDIRECTSOUND *, LPUNKNOWN))GetProcAddress(hDsound_dll, "DirectSoundCreate"); + if (DirectSoundCreate == NULL) { + ErrDlg(IDD_DIALOG5, GetLastError(), "C:\\Src\\Diablo\\Source\\SOUND.CPP", 427); + } + return DirectSoundCreate(lpGuid, ppDS, pUnkOuter); } void __cdecl sound_cleanup() { - snd_update(TRUE); - SVidDestroy(); - SFileDdaDestroy(); + snd_update(TRUE); + SVidDestroy(); + SFileDdaDestroy(); - if (sglpDS) { - sglpDS->Release(); - sglpDS = NULL; - } + if (sglpDS) { + sglpDS->Release(); + sglpDS = NULL; + } - if (gbSndInited) { - gbSndInited = FALSE; - sound_store_volume("Sound Volume", sglSoundVolume); - sound_store_volume("Music Volume", sglMusicVolume); - } + if (gbSndInited) { + gbSndInited = FALSE; + sound_store_volume("Sound Volume", sglSoundVolume); + sound_store_volume("Music Volume", sglMusicVolume); + } } void __fastcall sound_store_volume(char *key, int value) { - SRegSaveValue("Diablo", key, 0, value); + SRegSaveValue("Diablo", key, 0, value); } void __cdecl music_stop() { - if (sgpMusicTrack) { - SFileDdaEnd(sgpMusicTrack); - SFileCloseFile(sgpMusicTrack); - sgpMusicTrack = 0; - sgnMusicTrack = 6; - } + if (sgpMusicTrack) { + SFileDdaEnd(sgpMusicTrack); + SFileCloseFile(sgpMusicTrack); + sgpMusicTrack = 0; + sgnMusicTrack = 6; + } } void __fastcall music_start(int nTrack) { - music_stop(); - if (sglpDS && gbMusicOn) { - BOOL success = SFileOpenFile(sgszMusicTracks[nTrack], &sgpMusicTrack); - sound_create_primary_buffer(sgpMusicTrack); - if (!success) { - sgpMusicTrack = 0; - } else { - SFileDdaBeginEx(sgpMusicTrack, 0x40000, 0x40000, 0, sglMusicVolume, 0, 0); - sgnMusicTrack = nTrack; - } - } + music_stop(); + if (sglpDS && gbMusicOn) { + BOOL success = SFileOpenFile(sgszMusicTracks[nTrack], &sgpMusicTrack); + sound_create_primary_buffer(sgpMusicTrack); + if (!success) { + sgpMusicTrack = 0; + } else { + SFileDdaBeginEx(sgpMusicTrack, 0x40000, 0x40000, 0, sglMusicVolume, 0, 0); + sgnMusicTrack = nTrack; + } + } } void __fastcall sound_disable_music(BOOL disable) { - if (disable) { - music_stop(); - } else if (sgnMusicTrack != 6) { - music_start(sgnMusicTrack); - } + if (disable) { + music_stop(); + } else if (sgnMusicTrack != 6) { + music_start(sgnMusicTrack); + } } int __fastcall sound_get_or_set_music_volume(int volume) { - if (volume == 1) - return sglMusicVolume; + if (volume == 1) + return sglMusicVolume; - sglMusicVolume = volume; + sglMusicVolume = volume; - if (sgpMusicTrack) - SFileDdaSetVolume(sgpMusicTrack, volume, 0); + if (sgpMusicTrack) + SFileDdaSetVolume(sgpMusicTrack, volume, 0); - return sglMusicVolume; + return sglMusicVolume; } int __fastcall sound_get_or_set_sound_volume(int volume) { - if (volume == 1) - return sglSoundVolume; + if (volume == 1) + return sglSoundVolume; - sglSoundVolume = volume; + sglSoundVolume = volume; - return sglSoundVolume; + return sglSoundVolume; } diff --git a/Source/spells.cpp b/Source/spells.cpp index fd2f6c2c..8aa83d0e 100644 --- a/Source/spells.cpp +++ b/Source/spells.cpp @@ -3,7 +3,7 @@ #include "../types.h" SpellData spelldata[MAX_SPELLS] = { - // clang-format off + // clang-format off // sName, sManaCost, sType, sNameText, sSkillText, sBookLvl, sStaffLvl, sTargeted, sTownSpell, sMinInt, sSFX, sMissiles[3], sManaAdj, sMinMana, sStaffMin, sStaffMax, sBookCost, sStaffCost { 0, 0, 0, NULL, NULL, 0, 0, FALSE, FALSE, 0, 0, { 0, 0, 0 }, 0, 0, 40, 80, 0, 0 }, { SPL_FIREBOLT, 6, STYPE_FIRE, "Firebolt", "Firebolt", 1, 1, TRUE, FALSE, 15, IS_CAST2, { MIS_FIREBOLT, 0, 0 }, 1, 3, 40, 80, 1000, 50 }, @@ -42,277 +42,277 @@ SpellData spelldata[MAX_SPELLS] = { { SPL_HEALOTHER, 5, STYPE_MAGIC, "Heal Other", NULL, 1, 1, FALSE, TRUE, 17, IS_CAST8, { MIS_HEALOTHER, 0, 0 }, 3, 1, 20, 40, 1000, 50 }, { SPL_FLARE, 25, STYPE_MAGIC, "Blood Star", NULL, 14, 13, FALSE, FALSE, 70, IS_CAST2, { MIS_FLARE, 0, 0 }, 2, 14, 20, 60, 27500, 1800 }, { SPL_BONESPIRIT, 24, STYPE_MAGIC, "Bone Spirit", NULL, 9, 7, FALSE, FALSE, 34, IS_CAST2, { MIS_BONESPIRIT, 0, 0 }, 1, 12, 20, 60, 11500, 800 } - // clang-format on + // clang-format on }; int __fastcall GetManaAmount(int id, int sn) { - int i; // "raw" mana cost - int ma; // mana amount + int i; // "raw" mana cost + int ma; // mana amount - // mana adjust - int adj = 0; + // mana adjust + int adj = 0; - // spell level - int sl = plr[id]._pSplLvl[sn] + plr[id]._pISplLvlAdd - 1; + // spell level + int sl = plr[id]._pSplLvl[sn] + plr[id]._pISplLvlAdd - 1; - if (sl < 0) { - sl = 0; - } + if (sl < 0) { + sl = 0; + } - if (sl > 0) { - adj = sl * spelldata[sn].sManaAdj; - } - if (sn == SPL_FIREBOLT) { - adj >>= 1; - } - if (sn == SPL_RESURRECT && sl > 0) { - adj = sl * (spelldata[SPL_RESURRECT].sManaCost / 8); - } + if (sl > 0) { + adj = sl * spelldata[sn].sManaAdj; + } + if (sn == SPL_FIREBOLT) { + adj >>= 1; + } + if (sn == SPL_RESURRECT && sl > 0) { + adj = sl * (spelldata[SPL_RESURRECT].sManaCost / 8); + } - if (spelldata[sn].sManaCost == 255) // TODO: check sign - { - i = (BYTE)plr[id]._pMaxManaBase; - } else { - i = spelldata[sn].sManaCost; - } + if (spelldata[sn].sManaCost == 255) // TODO: check sign + { + i = (BYTE)plr[id]._pMaxManaBase; + } else { + i = spelldata[sn].sManaCost; + } - ma = (i - adj) << 6; + ma = (i - adj) << 6; - if (sn == SPL_HEAL) { - ma = (spelldata[SPL_HEAL].sManaCost + 2 * plr[id]._pLevel - adj) << 6; - } - if (sn == SPL_HEALOTHER) { - ma = (spelldata[SPL_HEAL].sManaCost + 2 * plr[id]._pLevel - adj) << 6; - } + if (sn == SPL_HEAL) { + ma = (spelldata[SPL_HEAL].sManaCost + 2 * plr[id]._pLevel - adj) << 6; + } + if (sn == SPL_HEALOTHER) { + ma = (spelldata[SPL_HEAL].sManaCost + 2 * plr[id]._pLevel - adj) << 6; + } - if (plr[id]._pClass == PC_ROGUE) { - ma -= ma >> 2; - } + if (plr[id]._pClass == PC_ROGUE) { + ma -= ma >> 2; + } - if (spelldata[sn].sMinMana > ma >> 6) { - ma = spelldata[sn].sMinMana << 6; - } + if (spelldata[sn].sMinMana > ma >> 6) { + ma = spelldata[sn].sMinMana << 6; + } - return ma * (100 - plr[id]._pISplCost) / 100; + return ma * (100 - plr[id]._pISplCost) / 100; } void __fastcall UseMana(int id, int sn) { - int ma; // mana cost + int ma; // mana cost - if (id == myplr) { - switch (plr[id]._pSplType) { - case RSPLTYPE_SPELL: + if (id == myplr) { + switch (plr[id]._pSplType) { + case RSPLTYPE_SPELL: #ifdef _DEBUG - if (!debug_mode_key_inverted_v) { + if (!debug_mode_key_inverted_v) { #endif - ma = GetManaAmount(id, sn); - plr[id]._pMana -= ma; - plr[id]._pManaBase -= ma; - drawmanaflag = TRUE; + ma = GetManaAmount(id, sn); + plr[id]._pMana -= ma; + plr[id]._pManaBase -= ma; + drawmanaflag = TRUE; #ifdef _DEBUG - } + } #endif - break; - case RSPLTYPE_SCROLL: - RemoveScroll(id); - break; - case RSPLTYPE_CHARGES: - UseStaffCharge(id); - break; - } - } + break; + case RSPLTYPE_SCROLL: + RemoveScroll(id); + break; + case RSPLTYPE_CHARGES: + UseStaffCharge(id); + break; + } + } } BOOL __fastcall CheckSpell(int id, int sn, BYTE st, BOOL manaonly) { #ifdef _DEBUG - if (debug_mode_key_inverted_v) - return TRUE; + if (debug_mode_key_inverted_v) + return TRUE; #endif - BOOL result = TRUE; - if (!manaonly && pcurs != 1) { - result = FALSE; - } else { - if (st != RSPLTYPE_SKILL) { - if (GetSpellLevel(id, sn) <= 0) { - result = FALSE; - } else { - result = plr[id]._pMana >= GetManaAmount(id, sn); - } - } - } + BOOL result = TRUE; + if (!manaonly && pcurs != 1) { + result = FALSE; + } else { + if (st != RSPLTYPE_SKILL) { + if (GetSpellLevel(id, sn) <= 0) { + result = FALSE; + } else { + result = plr[id]._pMana >= GetManaAmount(id, sn); + } + } + } - return result; + return result; } void __fastcall CastSpell(int id, int spl, int sx, int sy, int dx, int dy, BOOL caster, int spllvl) { - int dir; // missile direction + int dir; // missile direction - // ugly switch, but generates the right code - switch (caster) { - case TRUE: - dir = monster[id]._mdir; - break; - case FALSE: - // caster must be 0 already in this case, but oh well, - // it's needed to generate the right code - caster = 0; - dir = plr[id]._pdir; + // ugly switch, but generates the right code + switch (caster) { + case TRUE: + dir = monster[id]._mdir; + break; + case FALSE: + // caster must be 0 already in this case, but oh well, + // it's needed to generate the right code + caster = 0; + dir = plr[id]._pdir; - if (spl == SPL_FIREWALL) { - dir = plr[id]._pVar3; - } - break; - } + if (spl == SPL_FIREWALL) { + dir = plr[id]._pVar3; + } + break; + } - for (int i = 0; spelldata[spl].sMissiles[i] != MIS_ARROW && i < 3; i++) { - AddMissile(sx, sy, dx, dy, dir, spelldata[spl].sMissiles[i], caster, id, 0, spllvl); - } + for (int i = 0; spelldata[spl].sMissiles[i] != MIS_ARROW && i < 3; i++) { + AddMissile(sx, sy, dx, dy, dir, spelldata[spl].sMissiles[i], caster, id, 0, spllvl); + } - if (spelldata[spl].sMissiles[0] == MIS_TOWN) { - UseMana(id, SPL_TOWN); - } - if (spelldata[spl].sMissiles[0] == MIS_CBOLT) { - UseMana(id, SPL_CBOLT); + if (spelldata[spl].sMissiles[0] == MIS_TOWN) { + UseMana(id, SPL_TOWN); + } + if (spelldata[spl].sMissiles[0] == MIS_CBOLT) { + UseMana(id, SPL_CBOLT); - for (int i = 0; i < (spllvl >> 1) + 3; i++) { - AddMissile(sx, sy, dx, dy, dir, MIS_CBOLT, caster, id, 0, spllvl); - } - } + for (int i = 0; i < (spllvl >> 1) + 3; i++) { + AddMissile(sx, sy, dx, dy, dir, MIS_CBOLT, caster, id, 0, spllvl); + } + } } // pnum: player index // rid: target player index void __fastcall DoResurrect(int pnum, int rid) { - if ((char)rid != -1) { - AddMissile(plr[rid].WorldX, plr[rid].WorldY, plr[rid].WorldX, plr[rid].WorldY, 0, MIS_RESURRECTBEAM, 0, pnum, 0, 0); - } + if ((char)rid != -1) { + AddMissile(plr[rid].WorldX, plr[rid].WorldY, plr[rid].WorldX, plr[rid].WorldY, 0, MIS_RESURRECTBEAM, 0, pnum, 0, 0); + } - if (pnum == myplr) { - NewCursor(CURSOR_HAND); - } + if (pnum == myplr) { + NewCursor(CURSOR_HAND); + } - if ((char)rid != -1 && plr[rid]._pHitPoints == 0) { - if (rid == myplr) { - deathflag = FALSE; - gamemenu_off(); - drawhpflag = TRUE; - drawmanaflag = TRUE; - } + if ((char)rid != -1 && plr[rid]._pHitPoints == 0) { + if (rid == myplr) { + deathflag = FALSE; + gamemenu_off(); + drawhpflag = TRUE; + drawmanaflag = TRUE; + } - ClrPlrPath(rid); - plr[rid].destAction = ACTION_NONE; - plr[rid]._pInvincible = 0; - PlacePlayer(rid); + ClrPlrPath(rid); + plr[rid].destAction = ACTION_NONE; + plr[rid]._pInvincible = 0; + PlacePlayer(rid); - int hp = 640; - if (plr[rid]._pMaxHPBase < 640) { - hp = plr[rid]._pMaxHPBase; - } - SetPlayerHitPoints(rid, hp); + int hp = 640; + if (plr[rid]._pMaxHPBase < 640) { + hp = plr[rid]._pMaxHPBase; + } + SetPlayerHitPoints(rid, hp); - plr[rid]._pMana = 0; - plr[rid]._pHPBase = plr[rid]._pHitPoints + (plr[rid]._pMaxHPBase - plr[rid]._pMaxHP); - plr[rid]._pManaBase = plr[rid]._pMaxManaBase - plr[rid]._pMaxMana; + plr[rid]._pMana = 0; + plr[rid]._pHPBase = plr[rid]._pHitPoints + (plr[rid]._pMaxHPBase - plr[rid]._pMaxHP); + plr[rid]._pManaBase = plr[rid]._pMaxManaBase - plr[rid]._pMaxMana; - CalcPlrInv(rid, TRUE); + CalcPlrInv(rid, TRUE); - if (plr[rid].plrlevel == currlevel) { - StartStand(rid, plr[rid]._pdir); - } else { - plr[rid]._pmode = 0; - } - } + if (plr[rid].plrlevel == currlevel) { + StartStand(rid, plr[rid]._pdir); + } else { + plr[rid]._pmode = 0; + } + } } void __fastcall PlacePlayer(int pnum) { - int nx; - int ny; + int nx; + int ny; - if (plr[pnum].plrlevel == currlevel) { - for (DWORD i = 0; i < 8; i++) { - nx = plr[pnum].WorldX + plrxoff2[i]; - ny = plr[pnum].WorldY + plryoff2[i]; + if (plr[pnum].plrlevel == currlevel) { + for (DWORD i = 0; i < 8; i++) { + nx = plr[pnum].WorldX + plrxoff2[i]; + ny = plr[pnum].WorldY + plryoff2[i]; - if (PosOkPlayer(pnum, nx, ny)) { - break; - } - } + if (PosOkPlayer(pnum, nx, ny)) { + break; + } + } - if (!PosOkPlayer(pnum, nx, ny)) { - BOOL done = FALSE; + if (!PosOkPlayer(pnum, nx, ny)) { + BOOL done = FALSE; - for (int max = 1, min = -1; min > -50 && !done; max++, min--) { - for (int y = min; y <= max && !done; y++) { - ny = plr[pnum].WorldY + y; + for (int max = 1, min = -1; min > -50 && !done; max++, min--) { + for (int y = min; y <= max && !done; y++) { + ny = plr[pnum].WorldY + y; - for (int x = min; x <= max && !done; x++) { - nx = plr[pnum].WorldX + x; + for (int x = min; x <= max && !done; x++) { + nx = plr[pnum].WorldX + x; - if (PosOkPlayer(pnum, nx, ny)) { - done = TRUE; - } - } - } - } - } + if (PosOkPlayer(pnum, nx, ny)) { + done = TRUE; + } + } + } + } + } - plr[pnum].WorldX = nx; - plr[pnum].WorldY = ny; + plr[pnum].WorldX = nx; + plr[pnum].WorldY = ny; - dPlayer[nx][ny] = pnum + 1; + dPlayer[nx][ny] = pnum + 1; - if (pnum == myplr) { - ViewX = nx; - ViewY = ny; - } - } + if (pnum == myplr) { + ViewX = nx; + ViewY = ny; + } + } } void __fastcall DoHealOther(int pnum, int rid) { - if (pnum == myplr) { - NewCursor(CURSOR_HAND); - } + if (pnum == myplr) { + NewCursor(CURSOR_HAND); + } - if ((char)rid != -1 && (plr[rid]._pHitPoints >> 6) > 0) { - int hp = (random(57, 10) + 1) << 6; + if ((char)rid != -1 && (plr[rid]._pHitPoints >> 6) > 0) { + int hp = (random(57, 10) + 1) << 6; - for (int i = 0; i < plr[pnum]._pLevel; i++) { - hp += (random(57, 4) + 1) << 6; - } + for (int i = 0; i < plr[pnum]._pLevel; i++) { + hp += (random(57, 4) + 1) << 6; + } - for (int j = 0; j < GetSpellLevel(pnum, SPL_HEALOTHER); ++j) { - hp += (random(57, 6) + 1) << 6; - } + for (int j = 0; j < GetSpellLevel(pnum, SPL_HEALOTHER); ++j) { + hp += (random(57, 6) + 1) << 6; + } - if (plr[pnum]._pClass == PC_WARRIOR) { - hp <<= 1; - } + if (plr[pnum]._pClass == PC_WARRIOR) { + hp <<= 1; + } - if (plr[pnum]._pClass == PC_ROGUE) { - hp += hp >> 1; - } + if (plr[pnum]._pClass == PC_ROGUE) { + hp += hp >> 1; + } - plr[rid]._pHitPoints += hp; + plr[rid]._pHitPoints += hp; - if (plr[rid]._pHitPoints > plr[rid]._pMaxHP) { - plr[rid]._pHitPoints = plr[rid]._pMaxHP; - } + if (plr[rid]._pHitPoints > plr[rid]._pMaxHP) { + plr[rid]._pHitPoints = plr[rid]._pMaxHP; + } - plr[rid]._pHPBase += hp; + plr[rid]._pHPBase += hp; - if (plr[rid]._pHPBase > plr[rid]._pMaxHPBase) { - plr[rid]._pHPBase = plr[rid]._pMaxHPBase; - } + if (plr[rid]._pHPBase > plr[rid]._pMaxHPBase) { + plr[rid]._pHPBase = plr[rid]._pMaxHPBase; + } - drawhpflag = TRUE; - } + drawhpflag = TRUE; + } } diff --git a/Source/stores.cpp b/Source/stores.cpp index d0822a42..2b15c19a 100644 --- a/Source/stores.cpp +++ b/Source/stores.cpp @@ -37,63 +37,63 @@ 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 + 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" + "Griswold", + "Pepin", + &empty_string, + "Ogden", + "Cain", + "Farnham", + "Adria", + "Gillian", + "Wirt" }; void __cdecl InitStores() { - int i; // eax + 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; + 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; + for (i = 0; i < 6; i++) + premiumitem[i]._itype = -1; - boyitem._itype = -1; - boylevel = 0; + boyitem._itype = -1; + boylevel = 0; } // 69FB38: using guessed type int talker; // 6A09E0: using guessed type char stextsize; @@ -103,53 +103,53 @@ void __cdecl InitStores() void __cdecl SetupTownStores() { - int i; // eax - int l; // esi + 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); + 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 + 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); + 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 @@ -160,98 +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] + 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); - } + 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; @@ -259,79 +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] + 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); + 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 + 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); + 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; @@ -342,242 +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 + 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); - } + 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 + 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; + 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] + 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); - } - } - } - } + 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; @@ -585,37 +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] + 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; + 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; @@ -623,111 +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] + 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); - } + 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 + 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; + 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; @@ -736,51 +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] + 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; + 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; @@ -788,39 +788,39 @@ void __fastcall S_ScrollSPBuy(int idx) bool __cdecl S_StartSPBuy() { - int *v0; // eax - bool result; // al - int v2; // ST10_4 + 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; + 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; @@ -831,58 +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] + 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; + 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; @@ -891,52 +891,52 @@ void __fastcall S_ScrollSSell(int idx) void __cdecl S_StartSSell() { - int i; // eax - bool sellok; // [esp+14h] [ebp-4h] + int i; // eax + bool sellok; // [esp+14h] [ebp-4h] - stextsize = 1; - sellok = 0; - storenumh = 0; + stextsize = 1; + sellok = 0; + storenumh = 0; - for (i = 0; i < 48; i++) - storehold[i]._itype = -1; + 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)); + 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]._iMagical != ITEM_QUALITY_NORMAL && storehold[storenumh]._iIdentified) + storehold[storenumh]._ivalue = storehold[storenumh]._iIvalue; - if (!(storehold[storenumh]._ivalue >>= 2)) - storehold[storenumh]._ivalue = 1; + if (!(storehold[storenumh]._ivalue >>= 2)) + storehold[storenumh]._ivalue = 1; - storehold[storenumh]._iIvalue = storehold[storenumh]._ivalue; - storehidx[storenumh++] = i; - } - } + 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); - } + 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; @@ -945,102 +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] + 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); + 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; @@ -1049,43 +1049,43 @@ void __cdecl S_StartSRepair() void __fastcall AddStoreHoldRepair(ItemStruct *itm, int i) { - int v2; // ebx - ItemStruct *v3; // ebp - int v5; // eax + 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; + 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; @@ -1093,37 +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] + 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; + 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; @@ -1131,35 +1131,35 @@ void __fastcall S_ScrollWBuy(int idx) void __cdecl S_StartWBuy() { - int v0; // ST10_4 - int v1; // eax - int *v2; // ecx + 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; + 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; @@ -1168,90 +1168,90 @@ void __cdecl S_StartWBuy() bool __fastcall WitchSellOk(int i) { - bool rv; // al - ItemStruct *pI; // edx + bool rv; // al + ItemStruct *pI; // edx - rv = 0; + rv = 0; - if (i < 0) - pI = &plr[myplr].SpdList[~i]; // -(i+1) - else - pI = &plr[myplr].InvList[i]; + 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; + 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] + int i; // eax + bool sellok; // [esp+18h] [ebp-8h] - stextsize = 1; - sellok = 0; - storenumh = 0; + stextsize = 1; + sellok = 0; + storenumh = 0; - for (i = 0; i < 48; i++) - storehold[i]._itype = -1; + 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)); + 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]._iMagical != ITEM_QUALITY_NORMAL && storehold[storenumh]._iIdentified) + storehold[storenumh]._ivalue = storehold[storenumh]._iIvalue; - if (!(storehold[storenumh]._ivalue >>= 2)) - storehold[storenumh]._ivalue = 1; + if (!(storehold[storenumh]._ivalue >>= 2)) + storehold[storenumh]._ivalue = 1; - storehold[storenumh]._iIvalue = storehold[storenumh]._ivalue; - storehidx[storenumh++] = i; - } - } + 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)); + 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]._iMagical != ITEM_QUALITY_NORMAL && storehold[storenumh]._iIdentified) + storehold[storenumh]._ivalue = storehold[storenumh]._iIvalue; - if (!(storehold[storenumh]._ivalue >>= 2)) - storehold[storenumh]._ivalue = 1; + if (!(storehold[storenumh]._ivalue >>= 2)) + storehold[storenumh]._ivalue = 1; - storehold[storenumh]._iIvalue = storehold[storenumh]._ivalue; - storehidx[storenumh++] = ~i; - } - } + 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); - } + 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); + AddSText(0, 22, 1, "Back", COL_WHITE, 1); + OffsetSTextY(22, 6); } // 69F10C: using guessed type int storenumh; // 6A09E0: using guessed type char stextsize; @@ -1260,105 +1260,105 @@ void __cdecl S_StartWSell() bool __fastcall WitchRechargeOk(int i) { - bool rv; // al + 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; + 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 + 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; + 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] + 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); + 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; @@ -1367,166 +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] + BOOL idprint; // esi + char iclr; // [esp+Ch] [ebp-4h] - StartStore(stextshold); - stextscrl = 0; - ClearSText(5, 23); - iclr = COL_WHITE; + 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; + 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; + 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); + 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); + 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; - } + 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 + 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; + 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); + 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); + 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; @@ -1534,31 +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] + 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; + 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; @@ -1566,34 +1566,34 @@ void __fastcall S_ScrollHBuy(int idx) void __cdecl S_StartHBuy() { - int v0; // ST10_4 - int v1; // eax - int *v2; // ecx + 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; + 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; @@ -1602,116 +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 + bool result; // al - result = 0; - if (i->_itype != -1) { - if (i->_iMagical != ITEM_QUALITY_NORMAL) - result = !i->_iIdentified; - } - return result; + 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] + ItemStruct itm; // [esp-170h] [ebp-18Ch] + bool idok; // [esp+10h] [ebp-Ch] + int i; // [esp+14h] [ebp-8h] - idok = 0; - storenumh = 0; - stextsize = 1; + idok = 0; + storenumh = 0; + stextsize = 1; - for (i = 0; i < 48; i++) - storehold[i]._itype = -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); - } + 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); - } - } + 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); - } + 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); + AddSText(0, 22, 1, "Back", COL_WHITE, 1); + OffsetSTextY(22, 6); } // 69F10C: using guessed type int storenumh; // 6A09E0: using guessed type char stextsize; @@ -1720,76 +1720,76 @@ void __cdecl S_StartSIdentify() void __cdecl S_StartIdShow() { - char iclr; // [esp+4h] [ebp-4h] + char iclr; // [esp+4h] [ebp-4h] - StartStore(stextshold); - stextscrl = 0; - ClearSText(5, 23); - iclr = COL_WHITE; + 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; + 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); + 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] + 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); + 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; @@ -1797,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; @@ -1813,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; @@ -1828,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; @@ -1843,105 +1843,105 @@ void __cdecl S_StartDrunk() void __fastcall StartStore(char s) { - char t; // bl - int i; // ecx + 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 (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; - } + for (i = 0; i < 24; i++) { + if (stext[i]._ssel) + break; + } - stextsel = i == 24 ? -1 : i; - stextflag = t; - if (t != 2 || storenumh) - 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; @@ -1952,55 +1952,55 @@ void __fastcall StartStore(char s) void __cdecl DrawSText() { - int i; // edi + 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; - } - } + 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); - } + 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; + if (stextscrl) + DrawSArrows(4, 20); + InStoreFlag = (InStoreFlag & 7) + 1; } // 6A09E0: using guessed type char stextsize; // 6A6BB8: using guessed type int stextscrl; @@ -2008,82 +2008,82 @@ LABEL_19: void __cdecl STextESC() { - char v0; // cl - char v1; // cl - char v2; // cl + 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; - } - } + 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; @@ -2093,45 +2093,45 @@ void __cdecl STextESC() void __cdecl STextUp() { - int v0; // eax + 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; - } - } + 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; @@ -2139,45 +2139,45 @@ void __cdecl STextUp() void __cdecl STextDown() { - int v0; // eax + 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; - } - } + 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; @@ -2186,18 +2186,18 @@ void __cdecl STextDown() 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; @@ -2205,17 +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; @@ -2224,37 +2224,37 @@ void __cdecl STextNext() void __cdecl S_SmithEnter() { - int v0; // ecx + 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; - } + 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; @@ -2265,192 +2265,192 @@ void __cdecl S_SmithEnter() 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 + 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; - } - } - } + 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 + 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); + 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; @@ -2458,44 +2458,44 @@ void __cdecl SmithBuyItem() void __cdecl S_SBuyEnter() { - int v0; // eax - int idx; // ecx - int done; // eax - int i; // esi - char v4; // cl + 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); - } - } + 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; @@ -2505,34 +2505,34 @@ void __cdecl S_SBuyEnter() void __cdecl SmithBuyPItem() { - int xx; // ecx - int idx; // eax - bool v2; // sf - int v3; // eax - int i; // edx + 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); - } + 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); + premiumitem[xx]._itype = -1; + --numpremium; + SpawnPremium(plr[myplr]._pLevel); } // 69F108: using guessed type int stextup; // 69F110: using guessed type int stextlhold; @@ -2540,66 +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 + 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); - } - } + 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; @@ -2609,140 +2609,140 @@ void __cdecl S_SPBuyEnter() bool __fastcall StoreGoldFit(int idx) { - int cost; // edi - int i; // ecx - int sz; // eax - int numsqrs; // [esp+Ch] [ebp-4h] + 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++; + cost = storehold[idx]._iIvalue; + sz = cost / 5000; + if (cost % 5000) + sz++; - SetCursor(storehold[idx]._iCurs + 12); - numsqrs = cursW / 28 * (cursH / 28); - SetCursor(CURSOR_HAND); + SetCursor(storehold[idx]._iCurs + 12); + numsqrs = cursW / 28 * (cursH / 28); + SetCursor(CURSOR_HAND); - if (numsqrs >= sz) - return 1; + if (numsqrs >= sz) + return 1; - for (i = 0; i < 40; i++) { - if (!plr[myplr].InvGrid[i]) - numsqrs++; - } + 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; - } - } + 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; + 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] + bool done; // ecx + int ii; // ebp + int xx; // esi + int yy; // ST20_4 + int i; // [esp+10h] [ebp-10h] - done = 0; + 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; - } - } + 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] + 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; - } - } + 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; @@ -2751,24 +2751,24 @@ void __cdecl StoreSellItem() void __cdecl S_SSellEnter() { - int idx; // eax + int idx; // eax - if (stextsel == 22) { - StartStore(STORE_SMITH); - stextsel = 16; - } else { - stextlhold = stextsel; - idx = stextsval + ((stextsel - stextup) >> 2); - stextshold = 3; - stextvhold = stextsval; + 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)); + qmemcpy(&plr[myplr].HoldItem, &storehold[idx], sizeof(plr[myplr].HoldItem)); - if (!StoreGoldFit(idx)) - StartStore(STORE_NOROOM); - else - StartStore(STORE_CONFIRM); - } + if (!StoreGoldFit(idx)) + StartStore(STORE_NOROOM); + else + StartStore(STORE_CONFIRM); + } } // 69F108: using guessed type int stextup; // 69F110: using guessed type int stextlhold; @@ -2777,27 +2777,27 @@ void __cdecl S_SSellEnter() void __cdecl SmithRepairItem() { - int i; // edx - int idx; // eax + int i; // edx + int idx; // eax - TakePlrsMoney(plr[myplr].HoldItem._iIvalue); + TakePlrsMoney(plr[myplr].HoldItem._iIvalue); - idx = stextvhold + ((stextlhold - stextup) >> 2); - i = storehidx[idx]; - storehold[idx]._iDurability = storehold[idx]._iMaxDur; + 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; - } + 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; @@ -2805,31 +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 + 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); - } + 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; @@ -2838,35 +2838,35 @@ void __cdecl S_SRepairEnter() void __cdecl S_WitchEnter() { - int v0; // ecx + 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; - } + 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; @@ -2877,35 +2877,35 @@ void __cdecl S_WitchEnter() void __cdecl WitchBuyItem() { - int idx; // ebx - ItemStruct *v3; // eax - ItemStruct *v4; // edi + int idx; // ebx + ItemStruct *v3; // eax + ItemStruct *v4; // edi - idx = stextvhold + ((stextlhold - stextup) >> 2); + idx = stextvhold + ((stextlhold - stextup) >> 2); - if (idx < 3) - plr[myplr].HoldItem._iSeed = GetRndSeed(); + if (idx < 3) + plr[myplr].HoldItem._iSeed = GetRndSeed(); - TakePlrsMoney(plr[myplr].HoldItem._iIvalue); - StoreAutoPlace(); + 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); + 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; @@ -2913,40 +2913,40 @@ void __cdecl WitchBuyItem() void __cdecl S_WBuyEnter() { - int idx; // ecx - int done; // eax - int i; // esi + 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 (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; + 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); - } + 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); + if (done) + StartStore(STORE_CONFIRM); + else + StartStore(STORE_NOROOM); - SetCursor(CURSOR_HAND); - } else { - StartStore(STORE_NOMONEY); - } - } + SetCursor(CURSOR_HAND); + } else { + StartStore(STORE_NOMONEY); + } + } } // 4B8C9C: using guessed type int cursH; // 69F108: using guessed type int stextup; @@ -2956,23 +2956,23 @@ void __cdecl S_WBuyEnter() void __cdecl S_WSellEnter() { - int idx; // eax - char v2; // cl + 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); - } + 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; @@ -2981,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; @@ -3003,31 +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 + 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); - } + 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; @@ -3036,34 +3036,34 @@ void __cdecl S_WRechargeEnter() void __cdecl S_BoyEnter() { - signed int v0; // ecx + 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; + 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; @@ -3075,72 +3075,72 @@ void __cdecl S_BoyEnter() 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 + 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); - } + 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; @@ -3149,45 +3149,45 @@ void __cdecl HealerBuyItem() void __cdecl S_BBuyEnter() { - int v0; // ecx - int v1; // eax - int v2; // ecx - int v3; // eax - int v4; // esi + 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; - } + 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; @@ -3197,34 +3197,34 @@ void __cdecl S_BBuyEnter() void __cdecl StoryIdItem() { - int v0; // ecx - int v1; // eax - int v2; // eax + 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); + 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; @@ -3232,55 +3232,55 @@ void __cdecl StoryIdItem() void __cdecl S_ConfirmEnter() { - char v0; // cl + 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; + 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; @@ -3288,36 +3288,36 @@ void __cdecl S_ConfirmEnter() void __cdecl S_HealerEnter() { - int v0; // ecx - int v1; // eax + 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; + 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; @@ -3328,44 +3328,44 @@ void __cdecl S_HealerEnter() void __cdecl S_HBuyEnter() { - int v0; // eax - int idx; // ecx - int done; // eax - int i; // esi - char v4; // cl + 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); - } - } + 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; @@ -3375,27 +3375,27 @@ void __cdecl S_HBuyEnter() void __cdecl S_StoryEnter() { - int v0; // ecx + 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; - } + 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; @@ -3406,31 +3406,31 @@ void __cdecl S_StoryEnter() void __cdecl S_SIDEnter() { - int idx; // eax - int v1; // edx - int v2; // ecx - bool v3; // sf - unsigned char v4; // of - char v5; // cl + 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); - } + 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; @@ -3439,63 +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 + 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); - } - } + 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; @@ -3505,20 +3505,20 @@ void __cdecl S_TalkEnter() void __cdecl S_TavernEnter() { - int v0; // ecx + 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; - } + 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; @@ -3529,20 +3529,20 @@ void __cdecl S_TavernEnter() void __cdecl S_BarmaidEnter() { - int v0; // ecx + 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; - } + 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; @@ -3553,20 +3553,20 @@ void __cdecl S_BarmaidEnter() void __cdecl S_DrunkEnter() { - int v0; // ecx + 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; - } + 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; @@ -3577,86 +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; @@ -3666,64 +3666,64 @@ void __cdecl STextEnter() void __cdecl CheckStoreBtn() { - bool v0; // sf - unsigned char v1; // of - int v2; // eax - int *v3; // ecx + 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(); - } - } - } - } + 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; @@ -3734,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/sync.cpp b/Source/sync.cpp index 30d70965..4d83b88b 100644 --- a/Source/sync.cpp +++ b/Source/sync.cpp @@ -10,335 +10,335 @@ int sgnSyncPInv; // weak int __fastcall sync_all_monsters(TSyncHeader *packet, int size) { - int result; // eax - TSyncHeader *v3; // esi - int v4; // ebx - TSyncMonster *v5; // edi - unsigned int v6; // [esp+4h] [ebp-4h] + int result; // eax + TSyncHeader *v3; // esi + int v4; // ebx + TSyncMonster *v5; // edi + unsigned int v6; // [esp+4h] [ebp-4h] - result = size; - if (nummonsters >= 1 && (unsigned int)size >= 0x2B) { - v3 = packet; - v6 = size - 38; - v4 = 0; - packet->bCmd = CMD_SYNCDATA; - v5 = (TSyncMonster *)(&packet->bPInvId + 1); - packet->bLevel = currlevel; - packet->wLen = 0; - SyncPlrInv(packet); - sync_one_monster(); - if (nummonsters > 0) { - do { - if (v6 < 5 || (v4 >= 2 || !sync_monster_active2(v5)) && !sync_monster_active(v5)) - break; - v3->wLen += 5; - v6 -= 5; - ++v5; - ++v4; - } while (v4 < nummonsters); - } - result = v6; - } - return result; + result = size; + if (nummonsters >= 1 && (unsigned int)size >= 0x2B) { + v3 = packet; + v6 = size - 38; + v4 = 0; + packet->bCmd = CMD_SYNCDATA; + v5 = (TSyncMonster *)(&packet->bPInvId + 1); + packet->bLevel = currlevel; + packet->wLen = 0; + SyncPlrInv(packet); + sync_one_monster(); + if (nummonsters > 0) { + do { + if (v6 < 5 || (v4 >= 2 || !sync_monster_active2(v5)) && !sync_monster_active(v5)) + break; + v3->wLen += 5; + v6 -= 5; + ++v5; + ++v4; + } while (v4 < nummonsters); + } + result = v6; + } + return result; } void __cdecl sync_one_monster() { - int i; // ebx - int v1; // edi - int v2; // esi - short v3; // bp - short v4; // ax - bool v5; // zf - short *v6; // edx - short *v7; // eax + int i; // ebx + int v1; // edi + int v2; // esi + short v3; // bp + short v4; // ax + bool v5; // zf + short *v6; // edx + short *v7; // eax - for (i = 0; i < nummonsters; ++i) { - v1 = monstactive[i]; - v2 = monstactive[i]; - v3 = abs(plr[myplr].WorldY - monster[v2]._my); - v4 = abs(plr[myplr].WorldX - monster[v2]._mx); - v5 = monster[v2]._msquelch == 0; - v6 = &sync_word_6AA708[v1]; - *v6 = v4 + v3; - if (v5) { - *v6 = v4 + v3 + 4096; - } else { - v7 = &sync_word_6AA89C[v1]; - if (*v7) - --*v7; - } - } + for (i = 0; i < nummonsters; ++i) { + v1 = monstactive[i]; + v2 = monstactive[i]; + v3 = abs(plr[myplr].WorldY - monster[v2]._my); + v4 = abs(plr[myplr].WorldX - monster[v2]._mx); + v5 = monster[v2]._msquelch == 0; + v6 = &sync_word_6AA708[v1]; + *v6 = v4 + v3; + if (v5) { + *v6 = v4 + v3 + 4096; + } else { + v7 = &sync_word_6AA89C[v1]; + if (*v7) + --*v7; + } + } } int __fastcall sync_monster_active(TSyncMonster *packet) { - unsigned int v1; // ebx - int v2; // esi - int v3; // edx - int v4; // eax + unsigned int v1; // ebx + int v2; // esi + int v3; // edx + int v4; // eax - v1 = -1; - v2 = 0; - v3 = -1; - if (nummonsters <= 0) - return 0; - do { - v4 = monstactive[v2]; - if ((unsigned short)sync_word_6AA708[v4] < v1 && (unsigned short)sync_word_6AA89C[v4] < 0xFFFEu) { - v1 = (unsigned short)sync_word_6AA708[v4]; - v3 = monstactive[v2]; - } - ++v2; - } while (v2 < nummonsters); - if (v3 == -1) - return 0; - sync_monster_pos(packet, v3); - return 1; + v1 = -1; + v2 = 0; + v3 = -1; + if (nummonsters <= 0) + return 0; + do { + v4 = monstactive[v2]; + if ((unsigned short)sync_word_6AA708[v4] < v1 && (unsigned short)sync_word_6AA89C[v4] < 0xFFFEu) { + v1 = (unsigned short)sync_word_6AA708[v4]; + v3 = monstactive[v2]; + } + ++v2; + } while (v2 < nummonsters); + if (v3 == -1) + return 0; + sync_monster_pos(packet, v3); + return 1; } void __fastcall sync_monster_pos(TSyncMonster *packet, int mon_id) { - int v2; // ebx - TSyncMonster *v3; // esi - int v4; // edi - int v5; // eax - short v6; // cx - char v7; // cl + int v2; // ebx + TSyncMonster *v3; // esi + int v4; // edi + int v5; // eax + short v6; // cx + char v7; // cl - v2 = mon_id; - v3 = packet; - v4 = mon_id; - packet->_mndx = mon_id; - packet->_mx = monster[mon_id]._mx; - packet->_my = monster[mon_id]._my; - packet->_menemy = encode_enemy(mon_id); - v5 = v2; - v6 = sync_word_6AA708[v2]; - if ((unsigned short)v6 > 0xFFu) - _LOBYTE(v6) = -1; - v3->_mdelta = v6; - v7 = monster[v4]._msquelch; - sync_word_6AA708[v5] = -1; - sync_word_6AA89C[v5] = -(v7 != 0) - 1; + v2 = mon_id; + v3 = packet; + v4 = mon_id; + packet->_mndx = mon_id; + packet->_mx = monster[mon_id]._mx; + packet->_my = monster[mon_id]._my; + packet->_menemy = encode_enemy(mon_id); + v5 = v2; + v6 = sync_word_6AA708[v2]; + if ((unsigned short)v6 > 0xFFu) + _LOBYTE(v6) = -1; + v3->_mdelta = v6; + v7 = monster[v4]._msquelch; + sync_word_6AA708[v5] = -1; + sync_word_6AA89C[v5] = -(v7 != 0) - 1; } int __fastcall sync_monster_active2(TSyncMonster *packet) { - int v1; // edx - unsigned int v2; // ebp - int v3; // eax - int v4; // esi - int v6; // [esp+8h] [ebp-4h] + int v1; // edx + unsigned int v2; // ebp + int v3; // eax + int v4; // esi + int v6; // [esp+8h] [ebp-4h] - v1 = -1; - v2 = 65534; - if (nummonsters <= 0) - return 0; - v3 = syncmonsters; - v6 = nummonsters; - do { - if (v3 >= nummonsters) - v3 = 0; - v4 = monstactive[v3]; - if ((unsigned short)sync_word_6AA89C[v4] < v2) { - v2 = (unsigned short)sync_word_6AA89C[v4]; - v1 = monstactive[v3]; - } - ++v3; - --v6; - } while (v6); - syncmonsters = v3; - if (v1 == -1) - return 0; - sync_monster_pos(packet, v1); - return 1; + v1 = -1; + v2 = 65534; + if (nummonsters <= 0) + return 0; + v3 = syncmonsters; + v6 = nummonsters; + do { + if (v3 >= nummonsters) + v3 = 0; + v4 = monstactive[v3]; + if ((unsigned short)sync_word_6AA89C[v4] < v2) { + v2 = (unsigned short)sync_word_6AA89C[v4]; + v1 = monstactive[v3]; + } + ++v3; + --v6; + } while (v6); + syncmonsters = v3; + if (v1 == -1) + return 0; + sync_monster_pos(packet, v1); + return 1; } // 6AA898: using guessed type int syncmonsters; void __fastcall SyncPlrInv(TSyncHeader *pSync) { - int v1; // edx - int v2; // eax - int v3; // eax - short v4; // dx - short v5; // bx - ItemStruct *pItem; // eax + int v1; // edx + int v2; // eax + int v3; // eax + short v4; // dx + short v5; // bx + ItemStruct *pItem; // eax - if (numitems <= 0) { - pSync->bItemI = -1; - } else { - v1 = syncitems; - if (syncitems >= numitems) - v1 = 0; - v2 = itemactive[v1]; - syncitems = v1 + 1; - pSync->bItemI = v2; - v3 = v2; - pSync->bItemX = item[v3]._ix; - pSync->bItemY = item[v3]._iy; - pSync->wItemIndx = item[v3].IDidx; - if (item[v3].IDidx == IDI_EAR) { - _LOBYTE(v4) = 0; - _HIBYTE(v4) = item[v3]._iName[7]; - _LOBYTE(v5) = 0; - pSync->wItemCI = item[v3]._iName[8] | v4; - pSync->dwItemSeed = item[v3]._iName[12] | ((item[v3]._iName[11] | ((item[v3]._iName[10] | (item[v3]._iName[9] << 8)) << 8)) << 8); - pSync->bItemId = item[v3]._iName[13]; - pSync->bItemDur = item[v3]._iName[14]; - pSync->bItemMDur = item[v3]._iName[15]; - pSync->bItemCh = item[v3]._iName[16]; - pSync->bItemMCh = item[v3]._iName[17]; - _HIBYTE(v5) = item[v3]._iName[18]; - pSync->wItemVal = LOWORD(item[v3]._ivalue) | v5 | ((LOWORD(item[v3]._iCurs) - 19) << 6); - pSync->dwItemBuff = item[v3]._iName[22] | ((item[v3]._iName[21] | ((item[v3]._iName[20] | (item[v3]._iName[19] << 8)) << 8)) << 8); - } else { - pSync->wItemCI = item[v3]._iCreateInfo; - pSync->dwItemSeed = item[v3]._iSeed; - pSync->bItemId = item[v3]._iIdentified; - pSync->bItemDur = item[v3]._iDurability; - pSync->bItemMDur = item[v3]._iMaxDur; - pSync->bItemCh = item[v3]._iCharges; - pSync->bItemMCh = item[v3]._iMaxCharges; - if (!item[v3].IDidx) - pSync->wItemVal = item[v3]._ivalue; - } - } - pItem = &plr[myplr].InvBody[sgnSyncPInv]; - if (pItem->_itype == -1) { - pSync->bPInvLoc = -1; - } else { - pSync->bPInvLoc = sgnSyncPInv; - pSync->wPInvIndx = pItem->IDidx; - pSync->wPInvCI = pItem->_iCreateInfo; - pSync->dwPInvSeed = pItem->_iSeed; - pSync->bPInvId = pItem->_iIdentified; - } - if (++sgnSyncPInv >= 7) - sgnSyncPInv = 0; + if (numitems <= 0) { + pSync->bItemI = -1; + } else { + v1 = syncitems; + if (syncitems >= numitems) + v1 = 0; + v2 = itemactive[v1]; + syncitems = v1 + 1; + pSync->bItemI = v2; + v3 = v2; + pSync->bItemX = item[v3]._ix; + pSync->bItemY = item[v3]._iy; + pSync->wItemIndx = item[v3].IDidx; + if (item[v3].IDidx == IDI_EAR) { + _LOBYTE(v4) = 0; + _HIBYTE(v4) = item[v3]._iName[7]; + _LOBYTE(v5) = 0; + pSync->wItemCI = item[v3]._iName[8] | v4; + pSync->dwItemSeed = item[v3]._iName[12] | ((item[v3]._iName[11] | ((item[v3]._iName[10] | (item[v3]._iName[9] << 8)) << 8)) << 8); + pSync->bItemId = item[v3]._iName[13]; + pSync->bItemDur = item[v3]._iName[14]; + pSync->bItemMDur = item[v3]._iName[15]; + pSync->bItemCh = item[v3]._iName[16]; + pSync->bItemMCh = item[v3]._iName[17]; + _HIBYTE(v5) = item[v3]._iName[18]; + pSync->wItemVal = LOWORD(item[v3]._ivalue) | v5 | ((LOWORD(item[v3]._iCurs) - 19) << 6); + pSync->dwItemBuff = item[v3]._iName[22] | ((item[v3]._iName[21] | ((item[v3]._iName[20] | (item[v3]._iName[19] << 8)) << 8)) << 8); + } else { + pSync->wItemCI = item[v3]._iCreateInfo; + pSync->dwItemSeed = item[v3]._iSeed; + pSync->bItemId = item[v3]._iIdentified; + pSync->bItemDur = item[v3]._iDurability; + pSync->bItemMDur = item[v3]._iMaxDur; + pSync->bItemCh = item[v3]._iCharges; + pSync->bItemMCh = item[v3]._iMaxCharges; + if (!item[v3].IDidx) + pSync->wItemVal = item[v3]._ivalue; + } + } + pItem = &plr[myplr].InvBody[sgnSyncPInv]; + if (pItem->_itype == -1) { + pSync->bPInvLoc = -1; + } else { + pSync->bPInvLoc = sgnSyncPInv; + pSync->wPInvIndx = pItem->IDidx; + pSync->wPInvCI = pItem->_iCreateInfo; + pSync->dwPInvSeed = pItem->_iSeed; + pSync->bPInvId = pItem->_iIdentified; + } + if (++sgnSyncPInv >= 7) + sgnSyncPInv = 0; } // 6AAA34: using guessed type int sgnSyncPInv; int __fastcall SyncData(int pnum, TSyncHeader *packet) { - TSyncHeader *v2; // esi - TSyncMonster *v3; // edi - int v4; // ebp - unsigned short v5; // ax - unsigned int v6; // ebx + TSyncHeader *v2; // esi + TSyncMonster *v3; // edi + int v4; // ebp + unsigned short v5; // ax + unsigned int v6; // ebx - v2 = packet; - v3 = (TSyncMonster *)(&packet->bPInvId + 1); - v4 = pnum; - if (packet->bCmd != CMD_SYNCDATA) - TermMsg("bad sync command"); - if (gbBufferMsgs != 1 && v4 != myplr) { - v5 = v2->wLen; - if (v5 >= 5u) { - v6 = v5 / 5u; - do { - if (currlevel == v2->bLevel) - sync_monster_data(v4, v3); - delta_sync_monster((TCmdLocParam1 *)v3, v2->bLevel); - ++v3; - --v6; - } while (v6); - } - } - return v2->wLen + 38; + v2 = packet; + v3 = (TSyncMonster *)(&packet->bPInvId + 1); + v4 = pnum; + if (packet->bCmd != CMD_SYNCDATA) + TermMsg("bad sync command"); + if (gbBufferMsgs != 1 && v4 != myplr) { + v5 = v2->wLen; + if (v5 >= 5u) { + v6 = v5 / 5u; + do { + if (currlevel == v2->bLevel) + sync_monster_data(v4, v3); + delta_sync_monster((TCmdLocParam1 *)v3, v2->bLevel); + ++v3; + --v6; + } while (v6); + } + } + return v2->wLen + 38; } // 676194: using guessed type char gbBufferMsgs; void __fastcall sync_monster_data(int pnum, TSyncMonster *packet) { - TSyncMonster *v2; // edi - int v3; // ecx - int v4; // ebx - int v5; // esi - int v6; // ST18_4 - unsigned int v7; // ecx - unsigned int v8; // eax - int v9; // eax - int v10; // ecx - signed int v11; // ST14_4 - int v12; // eax - int v13; // eax - int v14; // eax - //int v15; // eax - int v16; // eax - int md; // [esp+Ch] [ebp-8h] - int mda; // [esp+Ch] [ebp-8h] + TSyncMonster *v2; // edi + int v3; // ecx + int v4; // ebx + int v5; // esi + int v6; // ST18_4 + unsigned int v7; // ecx + unsigned int v8; // eax + int v9; // eax + int v10; // ecx + signed int v11; // ST14_4 + int v12; // eax + int v13; // eax + int v14; // eax + //int v15; // eax + int v16; // eax + int md; // [esp+Ch] [ebp-8h] + int mda; // [esp+Ch] [ebp-8h] - v2 = packet; - md = pnum; - v3 = 0; - v4 = (unsigned char)packet->_mndx; - v5 = v4; - if (monster[v5]._mhitpoints) { - if (nummonsters > 0) { - do { - if (monstactive[v3] == v4) - break; - ++v3; - } while (v3 < nummonsters); - } - v6 = abs(plr[myplr].WorldY - monster[v5]._my); - v7 = abs(plr[myplr].WorldX - monster[v5]._mx) + v6; - if (v7 > 0xFF) - v7 = 255; - v8 = (unsigned char)v2->_mdelta; - if (v7 >= v8 && (v7 != v8 || md <= myplr)) { - v9 = (unsigned char)v2->_mx; - if (monster[v5]._mfutx != v9 || monster[v5]._mfuty != (unsigned char)v2->_my) { - v10 = monster[v5]._mmode; - if (v10 != MM_CHARGE && v10 != MM_STONE) { - v11 = abs(monster[v5]._mx - v9); - v12 = abs(monster[v5]._my - (unsigned char)v2->_my); - if (v11 > 2 || v12 > 2) { - if (dMonster[0][(unsigned char)v2->_my + 112 * (unsigned char)v2->_mx]) { - LABEL_23: - decode_enemy(v4, (unsigned char)v2->_menemy); - return; - } - M_ClearSquares(v4); - dMonster[0][(unsigned char)v2->_my + 112 * (unsigned char)v2->_mx] = v4 + 1; - monster[v5]._mx = (unsigned char)v2->_mx; - monster[v5]._my = (unsigned char)v2->_my; - decode_enemy(v4, (unsigned char)v2->_menemy); - v16 = GetDirection( - (unsigned char)v2->_mx, - (unsigned char)v2->_my, - (unsigned char)monster[v5]._menemyx, - (unsigned char)monster[v5]._menemyy); - M_StartStand(v4, v16); - } else { - v13 = monster[v5]._mmode; - if (v13 >= MM_WALK && v13 <= MM_WALK3) - goto LABEL_23; - v14 = GetDirection( - monster[v5]._mx, - monster[v5]._my, - (unsigned char)v2->_mx, - (unsigned char)v2->_my); - mda = v14; - //_LOBYTE(v15) = DirOK(v4, v14); - if (!DirOK(v4, v14)) - goto LABEL_23; - M_ClearSquares(v4); - dMonster[0][monster[v5]._my + 112 * monster[v5]._mx] = v4 + 1; - M_WalkDir(v4, mda); - } - monster[v5]._msquelch = -1; - goto LABEL_23; - } - } - } - } + v2 = packet; + md = pnum; + v3 = 0; + v4 = (unsigned char)packet->_mndx; + v5 = v4; + if (monster[v5]._mhitpoints) { + if (nummonsters > 0) { + do { + if (monstactive[v3] == v4) + break; + ++v3; + } while (v3 < nummonsters); + } + v6 = abs(plr[myplr].WorldY - monster[v5]._my); + v7 = abs(plr[myplr].WorldX - monster[v5]._mx) + v6; + if (v7 > 0xFF) + v7 = 255; + v8 = (unsigned char)v2->_mdelta; + if (v7 >= v8 && (v7 != v8 || md <= myplr)) { + v9 = (unsigned char)v2->_mx; + if (monster[v5]._mfutx != v9 || monster[v5]._mfuty != (unsigned char)v2->_my) { + v10 = monster[v5]._mmode; + if (v10 != MM_CHARGE && v10 != MM_STONE) { + v11 = abs(monster[v5]._mx - v9); + v12 = abs(monster[v5]._my - (unsigned char)v2->_my); + if (v11 > 2 || v12 > 2) { + if (dMonster[0][(unsigned char)v2->_my + 112 * (unsigned char)v2->_mx]) { + LABEL_23: + decode_enemy(v4, (unsigned char)v2->_menemy); + return; + } + M_ClearSquares(v4); + dMonster[0][(unsigned char)v2->_my + 112 * (unsigned char)v2->_mx] = v4 + 1; + monster[v5]._mx = (unsigned char)v2->_mx; + monster[v5]._my = (unsigned char)v2->_my; + decode_enemy(v4, (unsigned char)v2->_menemy); + v16 = GetDirection( + (unsigned char)v2->_mx, + (unsigned char)v2->_my, + (unsigned char)monster[v5]._menemyx, + (unsigned char)monster[v5]._menemyy); + M_StartStand(v4, v16); + } else { + v13 = monster[v5]._mmode; + if (v13 >= MM_WALK && v13 <= MM_WALK3) + goto LABEL_23; + v14 = GetDirection( + monster[v5]._mx, + monster[v5]._my, + (unsigned char)v2->_mx, + (unsigned char)v2->_my); + mda = v14; + //_LOBYTE(v15) = DirOK(v4, v14); + if (!DirOK(v4, v14)) + goto LABEL_23; + M_ClearSquares(v4); + dMonster[0][monster[v5]._my + 112 * monster[v5]._mx] = v4 + 1; + M_WalkDir(v4, mda); + } + monster[v5]._msquelch = -1; + goto LABEL_23; + } + } + } + } } void __cdecl sync_clear_pkt() { - syncmonsters = 16 * myplr; - memset(sync_word_6AA89C, 255, 0x190u); + syncmonsters = 16 * myplr; + memset(sync_word_6AA89C, 255, 0x190u); } // 6AA898: using guessed type int syncmonsters; diff --git a/Source/textdat.cpp b/Source/textdat.cpp index e9fd61a3..fabb5f94 100644 --- a/Source/textdat.cpp +++ b/Source/textdat.cpp @@ -5,507 +5,507 @@ /* todo: move text out of struct */ const TextDataStruct alltext[259] = { - { " Ahh, the story of our King, is it? The tragic fall of Leoric was a harsh blow to this land. The people always loved the King, and now they live in mortal fear of him. The question that I keep asking myself is how he could have fallen so far from the Light, as Leoric had always been the holiest of men. Only the vilest powers of Hell could so utterly destroy a man from within... |", - 1, 5, TSFX_STORY1 }, - { "The village needs your help, good master! Some months ago King Leoric's son, Prince Albrecht, was kidnapped. The King went into a rage and scoured the village for his missing child. With each passing day, Leoric seemed to slip deeper into madness. He sought to blame innocent townsfolk for the boy's disappearance and had them brutally executed. Less than half of us survived his insanity...\n \nThe King's Knights and Priests tried to placate him, but he turned against them and sadly, they were forced to kill him. With his dying breath the King called down a terrible curse upon his former followers. He vowed that they would serve him in darkness forever...\n \nThis is where things take an even darker twist than I thought possible! Our former King has risen from his eternal sleep and now commands a legion of undead minions within the Labyrinth. His body was buried in a tomb three levels beneath the Cathedral. Please, good master, put his soul at ease by destroying his now cursed form... |", - 1, 5, TSFX_TAVERN21 }, - { "As I told you, good master, the King was entombed three levels below. He's down there, waiting in the putrid darkness for his chance to destroy this land... |", - 1, 6, TSFX_TAVERN22 }, - { "The curse of our King has passed, but I fear that it was only part of a greater evil at work. However, we may yet be saved from the darkness that consumes our land, for your victory is a good omen. May Light guide you on your way, good master. |", - 1, 5, TSFX_TAVERN23 }, - { "The loss of his son was too much for King Leoric. I did what I could to ease his madness, but in the end it overcame him. A black curse has hung over this kingdom from that day forward, but perhaps if you were to free his spirit from his earthly prison, the curse would be lifted... |", - 1, 5, TSFX_HEALER1 }, - { "I don't like to think about how the King died. I like to remember him for the kind and just ruler that he was. His death was so sad and seemed very wrong, somehow. |", - 1, 6, TSFX_BMAID1 }, - { "I made many of the weapons and most of the armor that King Leoric used to outfit his knights. I even crafted a huge two-handed sword of the finest mithril for him, as well as a field crown to match. I still cannot believe how he died, but it must have been some sinister force that drove him insane! |", - 1, 5, TSFX_SMITH1 }, - { "I don't care about that. Listen, no skeleton is gonna be MY king. Leoric is King. King, so you hear me? HAIL TO THE KING! |", - 1, 5, TSFX_DRUNK1 }, - { "The dead who walk among the living follow the cursed King. He holds the power to raise yet more warriors for an ever growing army of the undead. If you do not stop his reign, he will surely march across this land and slay all who still live here. |", - 1, 5, TSFX_WITCH1 }, - { "Look, I'm running a business here. I don't sell information, and I don't care about some King that's been dead longer than I've been alive. If you need something to use against this King of the undead, then I can help you out... |", - 1, 5, TSFX_PEGBOY1 }, - { "The warmth of life has entered my tomb. Prepare yourself, mortal, to serve my Master for eternity! |", - 0, 5, USFX_SKING1 }, - { "I see that this strange behavior puzzles you as well. I would surmise that since many demons fear the light of the sun and believe that it holds great power, it may be that the rising sun depicted on the sign you speak of has led them to believe that it too holds some arcane powers. Hmm, perhaps they are not all as smart as we had feared... |", - 1, 5, TSFX_STORY2 }, - { "Master, I have a strange experience to relate. I know that you have a great knowledge of those monstrosities that inhabit the labyrinth, and this is something that I cannot understand for the very life of me... I was awakened during the night by a scraping sound just outside of my tavern. When I looked out from my bedroom, I saw the shapes of small demon-like creatures in the inn yard. After a short time, they ran off, but not before stealing the sign to my inn. I don't know why the demons would steal my sign but leave my family in peace... 'tis strange, no? |", - 1, 5, TSFX_TAVERN24 }, - { "Oh, you didn't have to bring back my sign, but I suppose that it does save me the expense of having another one made. Well, let me see, what could I give you as a fee for finding it? Hmmm, what have we here... ah, yes! This cap was left in one of the rooms by a magician who stayed here some time ago. Perhaps it may be of some value to you. |", - 1, 5, TSFX_TAVERN25 }, - { "My goodness, demons running about the village at night, pillaging our homes - is nothing sacred? I hope that Ogden and Garda are all right. I suppose that they would come to see me if they were hurt... |", - 1, 5, TSFX_HEALER2 }, - { "Oh my! Is that where the sign went? My Grandmother and I must have slept right through the whole thing. Thank the Light that those monsters didn't attack the inn. |", - 1, 6, TSFX_BMAID2 }, - { "Demons stole Ogden's sign, you say? That doesn't sound much like the atrocities I've heard of - or seen. \n \nDemons are concerned with ripping out your heart, not your signpost. |", - 1, 6, TSFX_SMITH2 }, - { "You know what I think? Somebody took that sign, and they gonna want lots of money for it. If I was Ogden... and I'm not, but if I was... I'd just buy a new sign with some pretty drawing on it. Maybe a nice mug of ale or a piece of cheese... |", - 1, 5, TSFX_DRUNK2 }, - { "No mortal can truly understand the mind of the demon. \n \nNever let their erratic actions confuse you, as that too may be their plan. |", - 1, 6, TSFX_WITCH2 }, - { "What - is he saying I took that? I suppose that Griswold is on his side, too. \n \nLook, I got over simple sign stealing months ago. You can't turn a profit on a piece of wood. |", - 1, 6, TSFX_PEGBOY2 }, - { "Hey - You that one that kill all! You get me Magic Banner or we attack! You no leave with life! You kill big uglies and give back Magic. Go past corner and door, find uglies. You give, you go! |", - 1, 5, USFX_SNOT1 }, - { "You kill uglies, get banner. You bring to me, or else... |", - 1, 6, USFX_SNOT2 }, - { "You give! Yes, good! Go now, we strong. We kill all with big Magic! |", - 1, 6, USFX_SNOT3 }, - { "This does not bode well, for it confirms my darkest fears. While I did not allow myself to believe the ancient legends, I cannot deny them now. Perhaps the time has come to reveal who I am.\n \nMy true name is Deckard Cain the Elder, and I am the last descendant of an ancient Brotherhood that was dedicated to safeguarding the secrets of a timeless evil. An evil that quite obviously has now been released.\n \nThe Archbishop Lazarus, once King Leoric's most trusted advisor, led a party of simple townsfolk into the Labyrinth to find the King's missing son, Albrecht. Quite some time passed before they returned, and only a few of them escaped with their lives.\n \nCurse me for a fool! I should have suspected his veiled treachery then. It must have been Lazarus himself who kidnapped Albrecht and has since hidden him within the Labyrinth. I do not understand why the Archbishop turned to the darkness, or what his interest is in the child. unless he means to sacrifice him to his dark masters!\n \nThat must be what he has planned! The survivors of his 'rescue party' say that Lazarus was last seen running into the deepest bowels of the labyrinth. You must hurry and save the prince from the sacrificial blade of this demented fiend! |", - 1, 3, TSFX_STORY36 }, - { "You must hurry and rescue Albrecht from the hands of Lazarus. The prince and the people of this kingdom are counting on you! |", - 1, 5, TSFX_STORY37 }, - { "Your story is quite grim, my friend. Lazarus will surely burn in Hell for his horrific deed. The boy that you describe is not our prince, but I believe that Albrecht may yet be in danger. The symbol of power that you speak of must be a portal in the very heart of the labyrinth.\n \nKnow this, my friend - The evil that you move against is the dark Lord of Terror. He is known to mortal men as Diablo. It was he who was imprisoned within the Labyrinth many centuries ago and I fear that he seeks to once again sow chaos in the realm of mankind. You must venture through the portal and destroy Diablo before it is too late! |", - 1, 5, TSFX_STORY38 }, - { "Lazarus was the Archbishop who led many of the townspeople into the labyrinth. I lost many good friends that day, and Lazarus never returned. I suppose he was killed along with most of the others. If you would do me a favor, good master - please do not talk to Farnham about that day. |", - 1, 6, TSFX_TAVERN1 }, - { "|", 1, 5, TSFX_STORY38 }, - { "|", 1, 5, TSFX_STORY38 }, - { "I was shocked when I heard of what the townspeople were planning to do that night. I thought that of all people, Lazarus would have had more sense than that. He was an Archbishop, and always seemed to care so much for the townsfolk of Tristram. So many were injured, I could not save them all... |", - 1, 5, TSFX_HEALER3 }, - { "I remember Lazarus as being a very kind and giving man. He spoke at my mother's funeral, and was supportive of my grandmother and myself in a very troubled time. I pray every night that somehow, he is still alive and safe. |", - 1, 5, TSFX_BMAID3 }, - { "I was there when Lazarus led us into the labyrinth. He spoke of holy retribution, but when we started fighting those hellspawn, he did not so much as lift his mace against them. He just ran deeper into the dim, endless chambers that were filled with the servants of darkness! |", - 1, 5, TSFX_SMITH3 }, - { "They stab, then bite, then they're all around you. Liar! LIAR! They're all dead! Dead! Do you hear me? They just keep falling and falling... their blood spilling out all over the floor... all his fault... |", - 1, 5, TSFX_DRUNK3 }, - { "I did not know this Lazarus of whom you speak, but I do sense a great conflict within his being. He poses a great danger, and will stop at nothing to serve the powers of darkness which have claimed him as theirs. |", - 1, 5, TSFX_WITCH3 }, - { "Yes, the righteous Lazarus, who was sooo effective against those monsters down there. Didn't help save my leg, did it? Look, I'll give you a free piece of advice. Ask Farnham, he was there. |", - 1, 5, TSFX_PEGBOY3 }, - { "Abandon your foolish quest. All that awaits you is the wrath of my Master! You are too late to save the child. Now you will join him in Hell! |", - 0, 5, USFX_LAZ1 }, - { " |", 0, 5, USFX_LAZ1 }, - { "Hmm, I don't know what I can really tell you about this that will be of any help. The water that fills our wells comes from an underground spring. I have heard of a tunnel that leads to a great lake - perhaps they are one and the same. Unfortunately, I do not know what would cause our water supply to be tainted. |", - 1, 5, TSFX_STORY4 }, - { "I have always tried to keep a large supply of foodstuffs and drink in our storage cellar, but with the entire town having no source of fresh water, even our stores will soon run dry. \n \nPlease, do what you can or I don't know what we will do. |", - 1, 6, TSFX_TAVERN2 }, - { "I'm glad I caught up to you in time! Our wells have become brackish and stagnant and some of the townspeople have become ill drinking from them. Our reserves of fresh water are quickly running dry. I believe that there is a passage that leads to the springs that serve our town. Please find what has caused this calamity, or we all will surely perish. |", - 1, 5, TSFX_HEALER20 }, - { "Please, you must hurry. Every hour that passes brings us closer to having no water to drink. \n \nWe cannot survive for long without your help. |", - 1, 6, TSFX_HEALER21 }, - { "What's that you say - the mere presence of the demons had caused the water to become tainted? Oh, truly a great evil lurks beneath our town, but your perseverance and courage gives us hope. Please take this ring - perhaps it will aid you in the destruction of such vile creatures. |", - 1, 5, TSFX_HEALER22 }, - { "My grandmother is very weak, and Garda says that we cannot drink the water from the wells. Please, can you do something to help us? |", - 1, 6, TSFX_BMAID4 }, - { "Pepin has told you the truth. We will need fresh water badly, and soon. I have tried to clear one of the smaller wells, but it reeks of stagnant filth. It must be getting clogged at the source. |", - 1, 5, TSFX_SMITH4 }, - { "You drink water? |", 1, 8, TSFX_DRUNK4 }, - { "The people of Tristram will die if you cannot restore fresh water to their wells. \n \nKnow this - demons are at the heart of this matter, but they remain ignorant of what they have spawned. |", - 1, 6, TSFX_WITCH4 }, - { "For once, I'm with you. My business runs dry - so to speak - if I have no market to sell to. You better find out what is going on, and soon! |", - 1, 6, TSFX_PEGBOY4 }, - { "A book that speaks of a chamber of human bones? Well, a Chamber of Bone is mentioned in certain archaic writings that I studied in the libraries of the East. These tomes inferred that when the Lords of the underworld desired to protect great treasures, they would create domains where those who died in the attempt to steal that treasure would be forever bound to defend it. A twisted, but strangely fitting, end? |", - 1, 4, TSFX_STORY7 }, - { "I am afraid that I don't know anything about that, good master. Cain has many books that may be of some help. |", - 1, 6, TSFX_TAVERN5 }, - { "This sounds like a very dangerous place. If you venture there, please take great care. |", - 1, 6, TSFX_HEALER5 }, - { "I am afraid that I haven't heard anything about that. Perhaps Cain the Storyteller could be of some help. |", - 1, 6, TSFX_BMAID6 }, - { "I know nothing of this place, but you may try asking Cain. He talks about many things, and it would not surprise me if he had some answers to your question. |", - 1, 6, TSFX_SMITH7 }, - { "Okay, so listen. There's this chamber of wood, see. And his wife, you know - her - tells the tree... cause you gotta wait. Then I says, that might work against him, but if you think I'm gonna PAY for this... you... uh... yeah. |", - 1, 5, TSFX_DRUNK7 }, - { "You will become an eternal servant of the dark lords should you perish within this cursed domain. \n \nEnter the Chamber of Bone at your own peril. |", - 1, 6, TSFX_WITCH7 }, - { "A vast and mysterious treasure, you say? Maybe I could be interested in picking up a few things from you... or better yet, don't you need some rare and expensive supplies to get you through this ordeal? |", - 1, 5, TSFX_PEGBOY7 }, - { "It seems that the Archbishop Lazarus goaded many of the townsmen into venturing into the Labyrinth to find the King's missing son. He played upon their fears and whipped them into a frenzied mob. None of them were prepared for what lay within the cold earth... Lazarus abandoned them down there - left in the clutches of unspeakable horrors - to die. |", - 1, 5, TSFX_STORY10 }, - { "Yes, Farnham has mumbled something about a hulking brute who wielded a fierce weapon. I believe he called him a butcher. |", - 1, 6, TSFX_TAVERN8 }, - { "By the Light, I know of this vile demon. There were many that bore the scars of his wrath upon their bodies when the few survivors of the charge led by Lazarus crawled from the Cathedral. I don't know what he used to slice open his victims, but it could not have been of this world. It left wounds festering with disease and even I found them almost impossible to treat. Beware if you plan to battle this fiend... |", - 1, 5, TSFX_HEALER8 }, - { "When Farnham said something about a butcher killing people, I immediately discounted it. But since you brought it up, maybe it is true. |", - 1, 6, TSFX_BMAID8 }, - { "I saw what Farnham calls the Butcher as it swathed a path through the bodies of my friends. He swung a cleaver as large as an axe, hewing limbs and cutting down brave men where they stood. I was separated from the fray by a host of small screeching demons and somehow found the stairway leading out. I never saw that hideous beast again, but his blood-stained visage haunts me to this day. |", - 1, 5, TSFX_SMITH10 }, - { "Big! Big cleaver killing all my friends. Couldn't stop him, had to run away, couldn't save them. Trapped in a room with so many bodies... so many friends... NOOOOOOOOOO! |", - 1, 5, TSFX_DRUNK10 }, - { "The Butcher is a sadistic creature that delights in the torture and pain of others. You have seen his handiwork in the drunkard Farnham. His destruction will do much to ensure the safety of this village. |", - 1, 5, TSFX_WITCH10 }, - { "I know more than you'd think about that grisly fiend. His little friends got a hold of me and managed to get my leg before Griswold pulled me out of that hole. \n \nI'll put it bluntly - kill him before he kills you and adds your corpse to his collection. |", - 1, 6, TSFX_PEGBOY10 }, - { "Please, listen to me. The Archbishop Lazarus, he led us down here to find the lost prince. The bastard led us into a trap! Now everyone is dead...killed by a demon he called the Butcher. Avenge us! Find this Butcher and slay him so that our souls may finally rest... |", - 1, 5, TSFX_WOUND }, - { " |", 1, 5, USFX_CLEAVER }, - { "You recite an interesting rhyme written in a style that reminds me of other works. Let me think now - what was it?\n \n...Darkness shrouds the Hidden. Eyes glowing unseen with only the sounds of razor claws briefly scraping to torment those poor souls who have been made sightless for all eternity. The prison for those so damned is named the Halls of the Blind... |", - 1, 5, TSFX_STORY12 }, - { "I never much cared for poetry. Occasionally, I had cause to hire minstrels when the inn was doing well, but that seems like such a long time ago now. \n \nWhat? Oh, yes... uh, well, I suppose you could see what someone else knows. |", - 1, 6, TSFX_TAVERN10 }, - { "This does seem familiar, somehow. I seem to recall reading something very much like that poem while researching the history of demonic afflictions. It spoke of a place of great evil that... wait - you're not going there are you? |", - 1, 5, TSFX_HEALER10 }, - { "If you have questions about blindness, you should talk to Pepin. I know that he gave my grandmother a potion that helped clear her vision, so maybe he can help you, too. |", - 1, 6, TSFX_BMAID10 }, - { "I am afraid that I have neither heard nor seen a place that matches your vivid description, my friend. Perhaps Cain the Storyteller could be of some help. |", - 1, 6, TSFX_SMITH12 }, - { "Look here... that's pretty funny, huh? Get it? Blind - look here? |", - 1, 6, TSFX_DRUNK12 }, - { "This is a place of great anguish and terror, and so serves its master well. \n \nTread carefully or you may yourself be staying much longer than you had anticipated. |", - 1, 6, TSFX_WITCH12 }, - { "Lets see, am I selling you something? No. Are you giving me money to tell you about this? No. Are you now leaving and going to talk to the storyteller who lives for this kind of thing? Yes. |", - 1, 5, TSFX_PEGBOY11 }, - { "You claim to have spoken with Lachdanan? He was a great hero during his life. Lachdanan was an honorable and just man who served his King faithfully for years. But of course, you already know that.\n \nOf those who were caught within the grasp of the King's Curse, Lachdanan would be the least likely to submit to the darkness without a fight, so I suppose that your story could be true. If I were in your place, my friend, I would find a way to release him from his torture. |", - 1, 5, TSFX_STORY13 }, - { "You speak of a brave warrior long dead! I'll have no such talk of speaking with departed souls in my inn yard, thank you very much. |", - 1, 6, TSFX_TAVERN11 }, - { "A golden elixir, you say. I have never concocted a potion of that color before, so I can't tell you how it would effect you if you were to try to drink it. As your healer, I strongly advise that should you find such an elixir, do as Lachdanan asks and DO NOT try to use it. |", - 1, 5, TSFX_HEALER11 }, - { "I've never heard of a Lachdanan before. I'm sorry, but I don't think that I can be of much help to you. |", - 1, 7, TSFX_BMAID11 }, - { "If it is actually Lachdanan that you have met, then I would advise that you aid him. I dealt with him on several occasions and found him to be honest and loyal in nature. The curse that fell upon the followers of King Leoric would fall especially hard upon him. |", - 1, 5, TSFX_SMITH13 }, - { " Lachdanan is dead. Everybody knows that, and you can't fool me into thinking any other way. You can't talk to the dead. I know! |", - 1, 5, TSFX_DRUNK13 }, - { "You may meet people who are trapped within the Labyrinth, such as Lachdanan. \n \nI sense in him honor and great guilt. Aid him, and you aid all of Tristram. |", - 1, 6, TSFX_WITCH13 }, - { "Wait, let me guess. Cain was swallowed up in a gigantic fissure that opened beneath him. He was incinerated in a ball of hellfire, and can't answer your questions anymore. Oh, that isn't what happened? Then I guess you'll be buying something or you'll be on your way. |", - 1, 5, TSFX_PEGBOY12 }, - { "Please, don't kill me, just hear me out. I was once Captain of King Leoric's Knights, upholding the laws of this land with justice and honor. Then his dark Curse fell upon us for the role we played in his tragic death. As my fellow Knights succumbed to their twisted fate, I fled from the King's burial chamber, searching for some way to free myself from the Curse. I failed...\n \nI have heard of a Golden Elixir that could lift the Curse and allow my soul to rest, but I have been unable to find it. My strength now wanes, and with it the last of my humanity as well. Please aid me and find the Elixir. I will repay your efforts - I swear upon my honor. |", - 1, 3, USFX_LACH1 }, - { "You have not found the Golden Elixir. I fear that I am doomed for eternity. Please, keep trying... |", - 1, 6, USFX_LACH2 }, - { "You have saved my soul from damnation, and for that I am in your debt. If there is ever a way that I can repay you from beyond the grave I will find it, but for now - take my helm. On the journey I am about to take I will have little use for it. May it protect you against the dark powers below. Go with the Light, my friend... |", - 1, 4, USFX_LACH3 }, - { "Griswold speaks of The Anvil of Fury - a legendary artifact long searched for, but never found. Crafted from the metallic bones of the Razor Pit demons, the Anvil of Fury was smelt around the skulls of the five most powerful magi of the underworld. Carved with runes of power and chaos, any weapon or armor forged upon this Anvil will be immersed into the realm of Chaos, imbedding it with magical properties. It is said that the unpredictable nature of Chaos makes it difficult to know what the outcome of this smithing will be... |", - 1, 4, TSFX_STORY14 }, - { "Don't you think that Griswold would be a better person to ask about this? He's quite handy, you know. |", - 1, 7, TSFX_TAVERN12 }, - { "If you had been looking for information on the Pestle of Curing or the Silver Chalice of Purification, I could have assisted you, my friend. However, in this matter, you would be better served to speak to either Griswold or Cain. |", - 1, 6, TSFX_HEALER12 }, - { "Griswold's father used to tell some of us when we were growing up about a giant anvil that was used to make mighty weapons. He said that when a hammer was struck upon this anvil, the ground would shake with a great fury. Whenever the earth moves, I always remember that story. |", - 1, 5, TSFX_BMAID12 }, - { "Greetings! It's always a pleasure to see one of my best customers! I know that you have been venturing deeper into the Labyrinth, and there is a story I was told that you may find worth the time to listen to...\n \nOne of the men who returned from the Labyrinth told me about a mystic anvil that he came across during his escape. His description reminded me of legends I had heard in my youth about the burning Hellforge where powerful weapons of magic are crafted. The legend had it that deep within the Hellforge rested the Anvil of Fury! This Anvil contained within it the very essence of the demonic underworld...\n \nIt is said that any weapon crafted upon the burning Anvil is imbued with great power. If this anvil is indeed the Anvil of Fury, I may be able to make you a weapon capable of defeating even the darkest lord of Hell! \n \nFind the Anvil for me, and I'll get to work! |", - 1, 5, TSFX_SMITH21 }, - { "Nothing yet, eh? Well, keep searching. A weapon forged upon the Anvil could be your best hope, and I am sure that I can make you one of legendary proportions. |", - 1, 5, TSFX_SMITH22 }, - { "I can hardly believe it! This is the Anvil of Fury - good work, my friend. Now we'll show those bastards that there are no weapons in Hell more deadly than those made by men! Take this and may Light protect you. |", - 1, 5, TSFX_SMITH23 }, - { "Griswold can't sell his anvil. What will he do then? And I'd be angry too if someone took my anvil! |", - 1, 6, TSFX_DRUNK14 }, - { "There are many artifacts within the Labyrinth that hold powers beyond the comprehension of mortals. Some of these hold fantastic power that can be used by either the Light or the Darkness. Securing the Anvil from below could shift the course of the Sin War towards the Light. |", - 1, 5, TSFX_WITCH14 }, - { "If you were to find this artifact for Griswold, it could put a serious damper on my business here. Awwww, you'll never find it. |", - 1, 6, TSFX_PEGBOY13 }, - { "The Gateway of Blood and the Halls of Fire are landmarks of mystic origin. Wherever this book you read from resides it is surely a place of great power.\n \nLegends speak of a pedestal that is carved from obsidian stone and has a pool of boiling blood atop its bone encrusted surface. There are also allusions to Stones of Blood that will open a door that guards an ancient treasure...\n \nThe nature of this treasure is shrouded in speculation, my friend, but it is said that the ancient hero Arkaine placed the holy armor Valor in a secret vault. Arkaine was the first mortal to turn the tide of the Sin War and chase the legions of darkness back to the Burning Hells.\n \nJust before Arkaine died, his armor was hidden away in a secret vault. It is said that when this holy armor is again needed, a hero will arise to don Valor once more. Perhaps you are that hero... |", - 1, 3, TSFX_STORY15 }, - { "Every child hears the story of the warrior Arkaine and his mystic armor known as Valor. If you could find its resting place, you would be well protected against the evil in the Labyrinth. |", - 1, 6, TSFX_TAVERN13 }, - { "Hmm... it sounds like something I should remember, but I've been so busy learning new cures and creating better elixirs that I must have forgotten. Sorry... |", - 1, 6, TSFX_HEALER13 }, - { "The story of the magic armor called Valor is something I often heard the boys talk about. You had better ask one of the men in the village. |", - 1, 6, TSFX_BMAID13 }, - { "The armor known as Valor could be what tips the scales in your favor. I will tell you that many have looked for it - including myself. Arkaine hid it well, my friend, and it will take more than a bit of luck to unlock the secrets that have kept it concealed oh, lo these many years. |", - 1, 5, TSFX_SMITH14 }, - { "Zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz... |", 1, 7, TSFX_DRUNK15 }, - { "Should you find these Stones of Blood, use them carefully. \n \nThe way is fraught with danger and your only hope rests within your self trust. |", - 1, 6, TSFX_WITCH15 }, - { "You intend to find the armor known as Valor? \n \nNo one has ever figured out where Arkaine stashed the stuff, and if my contacts couldn't find it, I seriously doubt you ever will either. |", - 1, 6, TSFX_PEGBOY14 }, - { "I know of only one legend that speaks of such a warrior as you describe. His story is found within the ancient chronicles of the Sin War...\n \nStained by a thousand years of war, blood and death, the Warlord of Blood stands upon a mountain of his tattered victims. His dark blade screams a black curse to the living; a tortured invitation to any who would stand before this Executioner of Hell.\n \nIt is also written that although he was once a mortal who fought beside the Legion of Darkness during the Sin War, he lost his humanity to his insatiable hunger for blood. |", - 1, 5, TSFX_STORY18 }, - { "I am afraid that I haven't heard anything about such a vicious warrior, good master. I hope that you do not have to fight him, for he sounds extremely dangerous. |", - 1, 6, TSFX_TAVERN16 }, - { "Cain would be able to tell you much more about something like this than I would ever wish to know. |", - 1, 7, TSFX_HEALER16 }, - { "If you are to battle such a fierce opponent, may Light be your guide and your defender. I will keep you in my thoughts. |", - 1, 6, TSFX_BMAID16 }, - { "Dark and wicked legends surrounds the one Warlord of Blood. Be well prepared, my friend, for he shows no mercy or quarter. |", - 1, 6, TSFX_SMITH17 }, - { "Always you gotta talk about Blood? What about flowers, and sunshine, and that pretty girl that brings the drinks. Listen here, friend - you're obsessive, you know that? |", - 1, 5, TSFX_DRUNK17 }, - { "His prowess with the blade is awesome, and he has lived for thousands of years knowing only warfare. I am sorry... I can not see if you will defeat him. |", - 1, 5, TSFX_WITCH18 }, - { "I haven't ever dealt with this Warlord you speak of, but he sounds like he's going through a lot of swords. Wouldn't mind supplying his armies... |", - 1, 6, TSFX_PEGBOY17 }, - { "My blade sings for your blood, mortal, and by my dark masters it shall not be denied. |", - 0, 6, USFX_WARLRD1 }, - { "Griswold speaks of the Heaven Stone that was destined for the enclave located in the east. It was being taken there for further study. This stone glowed with an energy that somehow granted vision beyond that which a normal man could possess. I do not know what secrets it holds, my friend, but finding this stone would certainly prove most valuable. |", - 1, 5, TSFX_STORY20 }, - { "The caravan stopped here to take on some supplies for their journey to the east. I sold them quite an array of fresh fruits and some excellent sweetbreads that Garda has just finished baking. Shame what happened to them... |", - 1, 6, TSFX_TAVERN18 }, - { "I don't know what it is that they thought they could see with that rock, but I will say this. If rocks are falling from the sky, you had better be careful! |", - 1, 6, TSFX_HEALER18 }, - { "Well, a caravan of some very important people did stop here, but that was quite a while ago. They had strange accents and were starting on a long journey, as I recall. \n \nI don't see how you could hope to find anything that they would have been carrying. |", - 1, 6, TSFX_BMAID18 }, - { "Stay for a moment - I have a story you might find interesting. A caravan that was bound for the eastern kingdoms passed through here some time ago. It was supposedly carrying a piece of the heavens that had fallen to earth! The caravan was ambushed by cloaked riders just north of here along the roadway. I searched the wreckage for this sky rock, but it was nowhere to be found. If you should find it, I believe that I can fashion something useful from it. |", - 1, 5, TSFX_SMITH24 }, - { "I am still waiting for you to bring me that stone from the heavens. I know that I can make something powerful out of it. |", - 1, 6, TSFX_SMITH25 }, - { "Let me see that - aye... aye, it is as I believed. Give me a moment...\n \nAh, Here you are. I arranged pieces of the stone within a silver ring that my father left me. I hope it serves you well. |", - 1, 5, TSFX_SMITH26 }, - { "I used to have a nice ring; it was a really expensive one, with blue and green and red and silver. Don't remember what happened to it, though. I really miss that ring... |", - 1, 5, TSFX_DRUNK19 }, - { "The Heaven Stone is very powerful, and were it any but Griswold who bid you find it, I would prevent it. He will harness its powers and its use will be for the good of us all. |", - 1, 5, TSFX_WITCH20 }, - { "If anyone can make something out of that rock, Griswold can. He knows what he is doing, and as much as I try to steal his customers, I respect the quality of his work. |", - 1, 6, TSFX_PEGBOY18 }, - { "The witch Adria seeks a black mushroom? I know as much about Black Mushrooms as I do about Red Herrings. Perhaps Pepin the Healer could tell you more, but this is something that cannot be found in any of my stories or books. |", - 1, 5, TSFX_STORY21 }, - { "Let me just say this. Both Garda and I would never, EVER serve black mushrooms to our honored guests. If Adria wants some mushrooms in her stew, then that is her business, but I can't help you find any. Black mushrooms... disgusting! |", - 1, 5, TSFX_TAVERN19 }, - { "The witch told me that you were searching for the brain of a demon to assist me in creating my elixir. It should be of great value to the many who are injured by those foul beasts, if I can just unlock the secrets I suspect that its alchemy holds. If you can remove the brain of a demon when you kill it, I would be grateful if you could bring it to me. |", - 1, 5, TSFX_HEALER26 }, - { "Excellent, this is just what I had in mind. I was able to finish the elixir without this, but it can't hurt to have this to study. Would you please carry this to the witch? I believe that she is expecting it. |", - 1, 5, TSFX_HEALER27 }, - { "I think Ogden might have some mushrooms in the storage cellar. Why don't you ask him? |", - 1, 7, TSFX_BMAID19 }, - { "If Adria doesn't have one of these, you can bet that's a rare thing indeed. I can offer you no more help than that, but it sounds like... a huge, gargantuan, swollen, bloated mushroom! Well, good hunting, I suppose. |", - 1, 5, TSFX_SMITH19 }, - { "Ogden mixes a MEAN black mushroom, but I get sick if I drink that. Listen, listen... here's the secret - moderation is the key! |", - 1, 5, TSFX_DRUNK20 }, - { "What do we have here? Interesting, it looks like a book of reagents. Keep your eyes open for a black mushroom. It should be fairly large and easy to identify. If you find it, bring it to me, won't you? |", - 1, 5, TSFX_WITCH22 }, - { "It's a big, black mushroom that I need. Now run off and get it for me so that I can use it for a special concoction that I am working on. |", - 1, 6, TSFX_WITCH23 }, - { "Yes, this will be perfect for a brew that I am creating. By the way, the healer is looking for the brain of some demon or another so he can treat those who have been afflicted by their poisonous venom. I believe that he intends to make an elixir from it. If you help him find what he needs, please see if you can get a sample of the elixir for me. |", - 1, 5, TSFX_WITCH24 }, - { "Why have you brought that here? I have no need for a demon's brain at this time. I do need some of the elixir that the Healer is working on. He needs that grotesque organ that you are holding, and then bring me the elixir. Simple when you think about it, isn't it? |", - 1, 5, TSFX_WITCH25 }, - { "What? Now you bring me that elixir from the healer? I was able to finish my brew without it. Why don't you just keep it... |", - 1, 6, TSFX_WITCH26 }, - { "I don't have any mushrooms of any size or color for sale. How about something a bit more useful? |", - 1, 6, TSFX_PEGBOY19 }, - { "So, the legend of the Map is real. Even I never truly believed any of it! I suppose it is time that I told you the truth about who I am, my friend. You see, I am not all that I seem...\n \nMy true name is Deckard Cain the Elder, and I am the last descendant of an ancient Brotherhood that was dedicated to keeping and safeguarding the secrets of a timeless evil. An evil that quite obviously has now been released...\n \nThe evil that you move against is the dark Lord of Terror - known to mortal men as Diablo. It was he who was imprisoned within the Labyrinth many centuries ago. The Map that you hold now was created ages ago to mark the time when Diablo would rise again from his imprisonment. When the two stars on that map align, Diablo will be at the height of his power. He will be all but invincible...\n \nYou are now in a race against time, my friend! Find Diablo and destroy him before the stars align, for we may never have a chance to rid the world of his evil again! |", - 1, 2, TSFX_STORY22 }, - { "Our time is running short! I sense his dark power building and only you can stop him from attaining his full might. |", - 1, 6, TSFX_STORY23 }, - { "I am sure that you tried your best, but I fear that even your strength and will may not be enough. Diablo is now at the height of his earthly power, and you will need all your courage and strength to defeat him. May the Light protect and guide you, my friend. I will help in any way that I am able. |", - 1, 5, TSFX_STORY24 }, - { "If the witch can't help you and suggests you see Cain, what makes you think that I would know anything? It sounds like this is a very serious matter. You should hurry along and see the storyteller as Adria suggests. |", - 1, 6, TSFX_TAVERN20 }, - { "I can't make much of the writing on this map, but perhaps Adria or Cain could help you decipher what this refers to. \n \nI can see that it is a map of the stars in our sky, but any more than that is beyond my talents. |", - 1, 6, TSFX_HEALER19 }, - { "The best person to ask about that sort of thing would be our storyteller. \n \nCain is very knowledgeable about ancient writings, and that is easily the oldest looking piece of paper that I have ever seen. |", - 1, 6, TSFX_BMAID20 }, - { "I have never seen a map of this sort before. Where'd you get it? Although I have no idea how to read this, Cain or Adria may be able to provide the answers that you seek. |", - 1, 6, TSFX_SMITH20 }, - { "Listen here, come close. I don't know if you know what I know, but you have really got somethin' here. That's a map. |", - 1, 5, TSFX_DRUNK21 }, - { "Oh, I'm afraid this does not bode well at all. This map of the stars portends great disaster, but its secrets are not mine to tell. The time has come for you to have a very serious conversation with the Storyteller... |", - 1, 5, TSFX_WITCH21 }, - { "I've been looking for a map, but that certainly isn't it. You should show that to Adria - she can probably tell you what it is. I'll say one thing; it looks old, and old usually means valuable. |", - 1, 5, TSFX_PEGBOY20 }, - { "Pleeeease, no hurt. No Kill. Keep alive and next time good bring to you. |", - 1, 6, USFX_GARBUD1 }, - { "Something for you I am making. Again, not kill Gharbad. Live and give good. \n \nYou take this as proof I keep word... |", - 1, 6, USFX_GARBUD2 }, - { "Nothing yet! Almost done. \n \nVery powerful, very strong. Live! Live! \n \nNo pain and promise I keep! |", - 1, 6, USFX_GARBUD3 }, - { "This too good for you. Very Powerful! You want - you take! |", - 1, 6, USFX_GARBUD4 }, - { "What?! Why are you here? All these interruptions are enough to make one insane. Here, take this and leave me to my work. Trouble me no more! |", - 1, 6, USFX_ZHAR1 }, - { "Arrrrgh! Your curiosity will be the death of you!!! |", 1, 7, USFX_ZHAR2 }, - { "Hello, my friend. Stay awhile and listen... |", 0, 5, TSFX_STORY25 }, - { "While you are venturing deeper into the Labyrinth you may find tomes of great knowledge hidden there. \n \nRead them carefully for they can tell you things that even I cannot. |", - 1, 6, TSFX_STORY26 }, - { "I know of many myths and legends that may contain answers to questions that may arise in your journeys into the Labyrinth. If you come across challenges and questions to which you seek knowledge, seek me out and I will tell you what I can. |", - 1, 5, TSFX_STORY27 }, - { "Griswold - a man of great action and great courage. I bet he never told you about the time he went into the Labyrinth to save Wirt, did he? He knows his fair share of the dangers to be found there, but then again - so do you. He is a skilled craftsman, and if he claims to be able to help you in any way, you can count on his honesty and his skill. |", - 1, 5, TSFX_STORY28 }, - { "Ogden has owned and run the Rising Sun Inn and Tavern for almost four years now. He purchased it just a few short months before everything here went to hell. He and his wife Garda do not have the money to leave as they invested all they had in making a life for themselves here. He is a good man with a deep sense of responsibility. |", - 1, 5, TSFX_STORY29 }, - { "Poor Farnham. He is a disquieting reminder of the doomed assembly that entered into the Cathedral with Lazarus on that dark day. He escaped with his life, but his courage and much of his sanity were left in some dark pit. He finds comfort only at the bottom of his tankard nowadays, but there are occasional bits of truth buried within his constant ramblings. |", - 1, 5, TSFX_STORY30 }, - { "The witch, Adria, is an anomaly here in Tristram. She arrived shortly after the Cathedral was desecrated while most everyone else was fleeing. She had a small hut constructed at the edge of town, seemingly overnight, and has access to many strange and arcane artifacts and tomes of knowledge that even I have never seen before. |", - 1, 5, TSFX_STORY31 }, - { "The story of Wirt is a frightening and tragic one. He was taken from the arms of his mother and dragged into the labyrinth by the small, foul demons that wield wicked spears. There were many other children taken that day, including the son of King Leoric. The Knights of the palace went below, but never returned. The Blacksmith found the boy, but only after the foul beasts had begun to torture him for their sadistic pleasures. |", - 1, 5, TSFX_STORY33 }, - { "Ah, Pepin. I count him as a true friend - perhaps the closest I have here. He is a bit addled at times, but never a more caring or considerate soul has existed. His knowledge and skills are equaled by few, and his door is always open. |", - 1, 5, TSFX_STORY34 }, - { "Gillian is a fine woman. Much adored for her high spirits and her quick laugh, she holds a special place in my heart. She stays on at the tavern to support her elderly grandmother who is too sick to travel. I sometimes fear for her safety, but I know that any man in the village would rather die than see her harmed. |", - 1, 5, TSFX_STORY35 }, - { "Greetings, good master. Welcome to the Tavern of the Rising Sun! |", - 0, 5, TSFX_TAVERN36 }, - { "Many adventurers have graced the tables of my tavern, and ten times as many stories have been told over as much ale. The only thing that I ever heard any of them agree on was this old axiom. Perhaps it will help you. You can cut the flesh, but you must crush the bone. |", - 1, 5, TSFX_TAVERN37 }, - { "Griswold the blacksmith is extremely knowledgeable about weapons and armor. If you ever need work done on your gear, he is definitely the man to see. |", - 1, 6, TSFX_TAVERN38 }, - { "Farnham spends far too much time here, drowning his sorrows in cheap ale. I would make him leave, but he did suffer so during his time in the Labyrinth. |", - 1, 6, TSFX_TAVERN39 }, - { "Adria is wise beyond her years, but I must admit - she frightens me a little. \n \nWell, no matter. If you ever have need to trade in items of sorcery, she maintains a strangely well-stocked hut just across the river. |", - 1, 6, TSFX_TAVERN40 }, - { "If you want to know more about the history of our village, the storyteller Cain knows quite a bit about the past. |", - 1, 6, TSFX_TAVERN41 }, - { "Wirt is a rapscallion and a little scoundrel. He was always getting into trouble, and it's no surprise what happened to him. \n \nHe probably went fooling about someplace that he shouldn't have been. I feel sorry for the boy, but I don't abide the company that he keeps. |", - 1, 6, TSFX_TAVERN43 }, - { "Pepin is a good man - and certainly the most generous in the village. He is always attending to the needs of others, but trouble of some sort or another does seem to follow him wherever he goes... |", - 1, 6, TSFX_TAVERN44 }, - { "Gillian, my Barmaid? If it were not for her sense of duty to her grand-dam, she would have fled from here long ago. \n \nGoodness knows I begged her to leave, telling her that I would watch after the old woman, but she is too sweet and caring to have done so. |", - 1, 6, TSFX_TAVERN45 }, - { "What ails you, my friend? |", 0, 5, TSFX_HEALER37 }, - { "I have made a very interesting discovery. Unlike us, the creatures in the Labyrinth can heal themselves without the aid of potions or magic. If you hurt one of the monsters, make sure it is dead or it very well may regenerate itself. |", - 1, 5, TSFX_HEALER38 }, - { "Before it was taken over by, well, whatever lurks below, the Cathedral was a place of great learning. There are many books to be found there. If you find any, you should read them all, for some may hold secrets to the workings of the Labyrinth. |", - 1, 5, TSFX_HEALER39 }, - { "Griswold knows as much about the art of war as I do about the art of healing. He is a shrewd merchant, but his work is second to none. Oh, I suppose that may be because he is the only blacksmith left here. |", - 1, 5, TSFX_HEALER40 }, - { "Cain is a true friend and a wise sage. He maintains a vast library and has an innate ability to discern the true nature of many things. If you ever have any questions, he is the person to go to. |", - 1, 5, TSFX_HEALER41 }, - { "Even my skills have been unable to fully heal Farnham. Oh, I have been able to mend his body, but his mind and spirit are beyond anything I can do. |", - 1, 5, TSFX_HEALER42 }, - { "While I use some limited forms of magic to create the potions and elixirs I store here, Adria is a true sorceress. She never seems to sleep, and she always has access to many mystic tomes and artifacts. I believe her hut may be much more than the hovel it appears to be, but I can never seem to get inside the place. |", - 1, 5, TSFX_HEALER43 }, - { "Poor Wirt. I did all that was possible for the child, but I know he despises that wooden peg that I was forced to attach to his leg. His wounds were hideous. No one - and especially such a young child - should have to suffer the way he did. |", - 1, 5, TSFX_HEALER45 }, - { "I really don't understand why Ogden stays here in Tristram. He suffers from a slight nervous condition, but he is an intelligent and industrious man who would do very well wherever he went. I suppose it may be the fear of the many murders that happen in the surrounding countryside, or perhaps the wishes of his wife that keep him and his family where they are. |", - 1, 5, TSFX_HEALER46 }, - { "Ogden's barmaid is a sweet girl. Her grandmother is quite ill, and suffers from delusions. \n \nShe claims that they are visions, but I have no proof of that one way or the other. |", - 1, 6, TSFX_HEALER47 }, - { "Good day! How may I serve you? |", 0, 5, TSFX_BMAID31 }, - { "My grandmother had a dream that you would come and talk to me. She has visions, you know and can see into the future. |", - 1, 6, TSFX_BMAID32 }, - { "The woman at the edge of town is a witch! She seems nice enough, and her name, Adria, is very pleasing to the ear, but I am very afraid of her. \n \nIt would take someone quite brave, like you, to see what she is doing out there. |", - 1, 6, TSFX_BMAID33 }, - { "Our Blacksmith is a point of pride to the people of Tristram. Not only is he a master craftsman who has won many contests within his guild, but he received praises from our King Leoric himself - may his soul rest in peace. Griswold is also a great hero; just ask Cain. |", - 1, 5, TSFX_BMAID34 }, - { "Cain has been the storyteller of Tristram for as long as I can remember. He knows so much, and can tell you just about anything about almost everything. |", - 1, 6, TSFX_BMAID35 }, - { "Farnham is a drunkard who fills his belly with ale and everyone else's ears with nonsense. \n \nI know that both Pepin and Ogden feel sympathy for him, but I get so frustrated watching him slip farther and farther into a befuddled stupor every night. |", - 1, 6, TSFX_BMAID36 }, - { "Pepin saved my grandmother's life, and I know that I can never repay him for that. His ability to heal any sickness is more powerful than the mightiest sword and more mysterious than any spell you can name. If you ever are in need of healing, Pepin can help you. |", - 1, 5, TSFX_BMAID37 }, - { "I grew up with Wirt's mother, Canace. Although she was only slightly hurt when those hideous creatures stole him, she never recovered. I think she died of a broken heart. Wirt has become a mean-spirited youngster, looking only to profit from the sweat of others. I know that he suffered and has seen horrors that I cannot even imagine, but some of that darkness hangs over him still. |", - 1, 5, TSFX_BMAID39 }, - { "Ogden and his wife have taken me and my grandmother into their home and have even let me earn a few gold pieces by working at the inn. I owe so much to them, and hope one day to leave this place and help them start a grand hotel in the east. |", - 1, 5, TSFX_BMAID40 }, - { "Well, what can I do for ya? |", 0, 5, TSFX_SMITH44 }, - { "If you're looking for a good weapon, let me show this to you. Take your basic blunt weapon, such as a mace. Works like a charm against most of those undying horrors down there, and there's nothing better to shatter skinny little skeletons! |", - 1, 5, TSFX_SMITH45 }, - { "The axe? Aye, that's a good weapon, balanced against any foe. Look how it cleaves the air, and then imagine a nice fat demon head in its path. Keep in mind, however, that it is slow to swing - but talk about dealing a heavy blow! |", - 1, 5, TSFX_SMITH46 }, - { "Look at that edge, that balance. A sword in the right hands, and against the right foe, is the master of all weapons. Its keen blade finds little to hack or pierce on the undead, but against a living, breathing enemy, a sword will better slice their flesh! |", - 1, 5, TSFX_SMITH47 }, - { "Your weapons and armor will show the signs of your struggles against the Darkness. If you bring them to me, with a bit of work and a hot forge, I can restore them to top fighting form. |", - 1, 6, TSFX_SMITH48 }, - { "While I have to practically smuggle in the metals and tools I need from caravans that skirt the edges of our damned town, that witch, Adria, always seems to get whatever she needs. If I knew even the smallest bit about how to harness magic as she did, I could make some truly incredible things. |", - 1, 5, TSFX_SMITH49 }, - { "Gillian is a nice lass. Shame that her gammer is in such poor health or I would arrange to get both of them out of here on one of the trading caravans. |", - 1, 6, TSFX_SMITH50 }, - { "Sometimes I think that Cain talks too much, but I guess that is his calling in life. If I could bend steel as well as he can bend your ear, I could make a suit of court plate good enough for an Emperor! |", - 1, 5, TSFX_SMITH51 }, - { "I was with Farnham that night that Lazarus led us into Labyrinth. I never saw the Archbishop again, and I may not have survived if Farnham was not at my side. I fear that the attack left his soul as crippled as, well, another did my leg. I cannot fight this battle for him now, but I would if I could. |", - 1, 5, TSFX_SMITH52 }, - { "A good man who puts the needs of others above his own. You won't find anyone left in Tristram - or anywhere else for that matter - who has a bad thing to say about the healer. |", - 1, 6, TSFX_SMITH53 }, - { "That lad is going to get himself into serious trouble... or I guess I should say, again. I've tried to interest him in working here and learning an honest trade, but he prefers the high profits of dealing in goods of dubious origin. I cannot hold that against him after what happened to him, but I do wish he would at least be careful. |", - 1, 5, TSFX_SMITH55 }, - { "The Innkeeper has little business and no real way of turning a profit. He manages to make ends meet by providing food and lodging for those who occasionally drift through the village, but they are as likely to sneak off into the night as they are to pay him. If it weren't for the stores of grains and dried meats he kept in his cellar, why, most of us would have starved during that first year when the entire countryside was overrun by demons. |", - 1, 5, TSFX_SMITH56 }, - { "Can't a fella drink in peace? |", 0, 5, TSFX_DRUNK27 }, - { "The gal who brings the drinks? Oh, yeah, what a pretty lady. So nice, too. |", - 1, 6, TSFX_DRUNK28 }, - { "Why don't that old crone do somethin' for a change. Sure, sure, she's got stuff, but you listen to me... she's unnatural. I ain't never seen her eat or drink - and you can't trust somebody who doesn't drink at least a little. |", - 1, 5, TSFX_DRUNK29 }, - { "Cain isn't what he says he is. Sure, sure, he talks a good story... some of 'em are real scary or funny... but I think he knows more than he knows he knows. |", - 1, 5, TSFX_DRUNK30 }, - { "Griswold? Good old Griswold. I love him like a brother! We fought together, you know, back when... we... Lazarus... Lazarus... Lazarus!!! |", - 1, 5, TSFX_DRUNK31 }, - { "Hehehe, I like Pepin. He really tries, you know. Listen here, you should make sure you get to know him. Good fella like that with people always wantin' help. Hey, I guess that would be kinda like you, huh hero? I was a hero too... |", - 1, 5, TSFX_DRUNK32 }, - { "Wirt is a kid with more problems than even me, and I know all about problems. Listen here - that kid is gotta sweet deal, but he's been there, you know? Lost a leg! Gotta walk around on a piece of wood. So sad, so sad... |", - 1, 5, TSFX_DRUNK34 }, - { "Ogden is the best man in town. I don't think his wife likes me much, but as long as she keeps tappin' kegs, I'll like her just fine. Seems like I been spendin' more time with Ogden than most, but he's so good to me... |", - 1, 5, TSFX_DRUNK35 }, - { "I wanna tell ya sumthin', 'cause I know all about this stuff. It's my specialty. This here is the best... theeeee best! That other ale ain't no good since those stupid dogs... |", - 1, 5, TSFX_DRUNK23 }, - { "No one ever lis... listens to me. Somewhere - I ain't too sure - but somewhere under the church is a whole pile o' gold. Gleamin' and shinin' and just waitin' for someone to get it. |", - 1, 5, TSFX_DRUNK24 }, - { "I know you gots your own ideas, and I know you're not gonna believe this, but that weapon you got there - it just ain't no good against those big brutes! Oh, I don't care what Griswold says, they can't make anything like they used to in the old days... |", - 1, 5, TSFX_DRUNK25 }, - { "If I was you... and I ain't... but if I was, I'd sell all that stuff you got and get out of here. That boy out there... He's always got somethin good, but you gotta give him some gold or he won't even show you what he's got. |", - 1, 5, TSFX_DRUNK26 }, - { "I sense a soul in search of answers... |", 0, 5, TSFX_WITCH38 }, - { "Wisdom is earned, not given. If you discover a tome of knowledge, devour its words. Should you already have knowledge of the arcane mysteries scribed within a book, remember - that level of mastery can always increase. |", - 1, 5, TSFX_WITCH39 }, - { "The greatest power is often the shortest lived. You may find ancient words of power written upon scrolls of parchment. The strength of these scrolls lies in the ability of either apprentice or adept to cast them with equal ability. Their weakness is that they must first be read aloud and can never be kept at the ready in your mind. Know also that these scrolls can be read but once, so use them with care. |", - 1, 5, TSFX_WITCH40 }, - { "Though the heat of the sun is beyond measure, the mere flame of a candle is of greater danger. No energies, no matter how great, can be used without the proper focus. For many spells, ensorcelled Staves may be charged with magical energies many times over. I have the ability to restore their power - but know that nothing is done without a price. |", - 1, 5, TSFX_WITCH41 }, - { "The sum of our knowledge is in the sum of its people. Should you find a book or scroll that you cannot decipher, do not hesitate to bring it to me. If I can make sense of it I will share what I find. |", - 1, 5, TSFX_WITCH42 }, - { "To a man who only knows Iron, there is no greater magic than Steel. The blacksmith Griswold is more of a sorcerer than he knows. His ability to meld fire and metal is unequaled in this land. |", - 1, 5, TSFX_WITCH43 }, - { "Corruption has the strength of deceit, but innocence holds the power of purity. The young woman Gillian has a pure heart, placing the needs of her matriarch over her own. She fears me, but it is only because she does not understand me. |", - 1, 5, TSFX_WITCH44 }, - { "A chest opened in darkness holds no greater treasure than when it is opened in the light. The storyteller Cain is an enigma, but only to those who do not look. His knowledge of what lies beneath the cathedral is far greater than even he allows himself to realize. |", - 1, 5, TSFX_WITCH45 }, - { "The higher you place your faith in one man, the farther it has to fall. Farnham has lost his soul, but not to any demon. It was lost when he saw his fellow townspeople betrayed by the Archbishop Lazarus. He has knowledge to be gleaned, but you must separate fact from fantasy. |", - 1, 5, TSFX_WITCH46 }, - { "The hand, the heart and the mind can perform miracles when they are in perfect harmony. The healer Pepin sees into the body in a way that even I cannot. His ability to restore the sick and injured is magnified by his understanding of the creation of elixirs and potions. He is as great an ally as you have in Tristram. |", - 1, 5, TSFX_WITCH47 }, - { "There is much about the future we cannot see, but when it comes it will be the children who wield it. The boy Wirt has a blackness upon his soul, but he poses no threat to the town or its people. His secretive dealings with the urchins and unspoken guilds of nearby towns gain him access to many devices that cannot be easily found in Tristram. While his methods may be reproachful, Wirt can provide assistance for your battle against the encroaching Darkness. |", - 1, 4, TSFX_WITCH49 }, - { "Earthen walls and thatched canopy do not a home create. The innkeeper Ogden serves more of a purpose in this town than many understand. He provides shelter for Gillian and her matriarch, maintains what life Farnham has left to him, and provides an anchor for all who are left in the town to what Tristram once was. His tavern, and the simple pleasures that can still be found there, provide a glimpse of a life that the people here remember. It is that memory that continues to feed their hopes for your success. |", - 1, 4, TSFX_WITCH50 }, - { "Pssst... over here... |", 0, 5, TSFX_PEGBOY32 }, - { "Not everyone in Tristram has a use - or a market - for everything you will find in the labyrinth. Not even me, as hard as that is to believe. \n \nSometimes, only you will be able to find a purpose for some things. |", - 1, 6, TSFX_PEGBOY33 }, - { "Don't trust everything the drunk says. Too many ales have fogged his vision and his good sense. |", - 1, 6, TSFX_PEGBOY34 }, - { "In case you haven't noticed, I don't buy anything from Tristram. I am an importer of quality goods. If you want to peddle junk, you'll have to see Griswold, Pepin or that witch, Adria. I'm sure that they will snap up whatever you can bring them... |", - 1, 5, TSFX_PEGBOY35 }, - { "I guess I owe the blacksmith my life - what there is of it. Sure, Griswold offered me an apprenticeship at the smithy, and he is a nice enough guy, but I'll never get enough money to... well, let's just say that I have definite plans that require a large amount of gold. |", - 1, 5, TSFX_PEGBOY36 }, - { "If I were a few years older, I would shower her with whatever riches I could muster, and let me assure you I can get my hands on some very nice stuff. Gillian is a beautiful girl who should get out of Tristram as soon as it is safe. Hmmm... maybe I'll take her with me when I go... |", - 1, 5, TSFX_PEGBOY37 }, - { "Cain knows too much. He scares the life out of me - even more than that woman across the river. He keeps telling me about how lucky I am to be alive, and how my story is foretold in legend. I think he's off his crock. |", - 1, 5, TSFX_PEGBOY38 }, - { "Farnham - now there is a man with serious problems, and I know all about how serious problems can be. He trusted too much in the integrity of one man, and Lazarus led him into the very jaws of death. Oh, I know what it's like down there, so don't even start telling me about your plans to destroy the evil that dwells in that Labyrinth. Just watch your legs... |", - 1, 5, TSFX_PEGBOY39 }, - { "As long as you don't need anything reattached, old Pepin is as good as they come. \n \nIf I'd have had some of those potions he brews, I might still have my leg... |", - 1, 6, TSFX_PEGBOY40 }, - { "Adria truly bothers me. Sure, Cain is creepy in what he can tell you about the past, but that witch can see into your past. She always has some way to get whatever she needs, too. Adria gets her hands on more merchandise than I've seen pass through the gates of the King's Bazaar during High Festival. |", - 1, 5, TSFX_PEGBOY42 }, - { "Ogden is a fool for staying here. I could get him out of town for a very reasonable price, but he insists on trying to make a go of it with that stupid tavern. I guess at the least he gives Gillian a place to work, and his wife Garda does make a superb Shepherd's pie... |", - 1, 5, TSFX_PEGBOY43 }, - { "Beyond the Hall of Heroes lies the Chamber of Bone. Eternal death awaits any who would seek to steal the treasures secured within this room. So speaks the Lord of Terror, and so it is written. |", - 1, 5, PS_WARR1 }, - { "...and so, locked beyond the Gateway of Blood and past the Hall of Fire, Valor awaits for the Hero of Light to awaken... |", - 1, 6, PS_WARR10 }, - { "I can see what you see not.\nVision milky then eyes rot.\nWhen you turn they will be gone,\nWhispering their hidden song.\nThen you see what cannot be,\nShadows move where light should be.\nOut of darkness, out of mind,\nCast down into the Halls of the Blind. |\n", - 1, 5, PS_WARR11 }, - { "The armories of Hell are home to the Warlord of Blood. In his wake lay the mutilated bodies of thousands. Angels and man alike have been cut down to fulfill his endless sacrifices to the Dark ones who scream for one thing - blood. |", - 1, 5, PS_WARR12 }, - { "Beyond the Hall of Heroes lies the Chamber of Bone. Eternal death awaits any who would seek to steal the treasures secured within this room. So speaks the Lord of Terror, and so it is written. |", - 1, 5, PS_MAGE1 }, - { "...and so, locked beyond the Gateway of Blood and past the Hall of Fire, Valor awaits for the Hero of Light to awaken... |", - 1, 6, PS_MAGE10 }, - { "I can see what you see not.\nVision milky then eyes rot.\nWhen you turn they will be gone,\nWhispering their hidden song.\nThen you see what cannot be,\nShadows move where light should be.\nOut of darkness, out of mind,\nCast down into the Halls of the Blind. |\n", - 1, 4, PS_MAGE11 }, - { "The armories of Hell are home to the Warlord of Blood. In his wake lay the mutilated bodies of thousands. Angels and man alike have been cut down to fulfill his endless sacrifices to the Dark ones who scream for one thing - blood. |", - 1, 5, PS_MAGE12 }, - { "Beyond the Hall of Heroes lies the Chamber of Bone. Eternal death awaits any who would seek to steal the treasures secured within this room. So speaks the Lord of Terror, and so it is written. |", - 1, 5, PS_ROGUE1 }, - { "...and so, locked beyond the Gateway of Blood and past the Hall of Fire, Valor awaits for the Hero of Light to awaken... |", - 1, 5, PS_ROGUE10 }, - { "I can see what you see not.\nVision milky then eyes rot.\nWhen you turn they will be gone,\nWhispering their hidden song.\nThen you see what cannot be,\nShadows move where light should be.\nOut of darkness, out of mind,\nCast down into the Halls of the Blind. |\n", - 1, 5, PS_ROGUE11 }, - { "The armories of Hell are home to the Warlord of Blood. In his wake lay the mutilated bodies of thousands. Angels and man alike have been cut down to fulfill his endless sacrifices to the Dark ones who scream for one thing - blood. |", - 1, 5, PS_ROGUE12 }, - { " |", 0, 5, TSFX_COW1 }, - { " |", 0, 5, TSFX_COW2 }, - { "Take heed and bear witness to the truths that lie herein, for they are the last legacy of the Horadrim. There is a war that rages on even now, beyond the fields that we know - between the utopian kingdoms of the High Heavens and the chaotic pits of the Burning Hells. This war is known as the Great Conflict, and it has raged and burned longer than any of the stars in the sky. Neither side ever gains sway for long as the forces of Light and Darkness constantly vie for control over all creation. |", - 1, 5, PS_NAR1 }, - { "Take heed and bear witness to the truths that lie herein, for they are the last legacy of the Horadrim. When the Eternal Conflict between the High Heavens and the Burning Hells falls upon mortal soil, it is called the Sin War. Angels and Demons walk amongst humanity in disguise, fighting in secret, away from the prying eyes of mortals. Some daring, powerful mortals have even allied themselves with either side, and helped to dictate the course of the Sin War. |", - 1, 4, PS_NAR2 }, - { "Take heed and bear witness to the truths that lie herein, for they are the last legacy of the Horadrim. Nearly three hundred years ago, it came to be known that the Three Prime Evils of the Burning Hells had mysteriously come to our world. The Three Brothers ravaged the lands of the east for decades, while humanity was left trembling in their wake. Our Order - the Horadrim - was founded by a group of secretive magi to hunt down and capture the Three Evils once and for all.\n \nThe original Horadrim captured two of the Three within powerful artifacts known as Soulstones and buried them deep beneath the desolate eastern sands. The third Evil escaped capture and fled to the west with many of the Horadrim in pursuit. The Third Evil - known as Diablo, the Lord of Terror - was eventually captured, his essence set in a Soulstone and buried within this Labyrinth.\n \nBe warned that the soulstone must be kept from discovery by those not of the faith. If Diablo were to be released, he would seek a body that is easily controlled as he would be very weak - perhaps that of an old man or a child. |", - 1, 3, PS_NAR3 }, - { "So it came to be that there was a great revolution within the Burning Hells known as The Dark Exile. The Lesser Evils overthrew the Three Prime Evils and banished their spirit forms to the mortal realm. The demons Belial (the Lord of Lies) and Azmodan (the Lord of Sin) fought to claim rulership of Hell during the absence of the Three Brothers. All of Hell polarized between the factions of Belial and Azmodan while the forces of the High Heavens continually battered upon the very Gates of Hell. |", - 1, 4, PS_NAR4 }, - { "Many demons traveled to the mortal realm in search of the Three Brothers. These demons were followed to the mortal plane by Angels who hunted them throughout the vast cities of the East. The Angels allied themselves with a secretive Order of mortal magi named the Horadrim, who quickly became adept at hunting demons. They also made many dark enemies in the underworlds. |", - 1, 5, PS_NAR5 }, - { "So it came to be that the Three Prime Evils were banished in spirit form to the mortal realm and after sewing chaos across the East for decades, they were hunted down by the cursed Order of the mortal Horadrim. The Horadrim used artifacts called Soulstones to contain the essence of Mephisto, the Lord of Hatred and his brother Baal, the Lord of Destruction. The youngest brother - Diablo, the Lord of Terror - escaped to the west.\n \nEventually the Horadrim captured Diablo within a Soulstone as well, and buried him under an ancient, forgotten Cathedral. There, the Lord of Terror sleeps and awaits the time of his rebirth. Know ye that he will seek a body of youth and power to possess - one that is innocent and easily controlled. He will then arise to free his Brothers and once more fan the flames of the Sin War... |", - 1, 3, PS_NAR6 }, - { "All praises to Diablo - Lord of Terror and Survivor of The Dark Exile. When he awakened from his long slumber, my Lord and Master spoke to me of secrets that few mortals know. He told me the kingdoms of the High Heavens and the pits of the Burning Hells engage in an eternal war. He revealed the powers that have brought this discord to the realms of man. My lord has named the battle for this world and all who exist here the Sin War. |", - 1, 4, PS_NAR7 }, - { "Glory and Approbation to Diablo - Lord of Terror and Leader of the Three. My Lord spoke to me of his two Brothers, Mephisto and Baal, who were banished to this world long ago. My Lord wishes to bide his time and harness his awesome power so that he may free his captive brothers from their tombs beneath the sands of the east. Once my Lord releases his Brothers, the Sin War will once again know the fury of the Three. |", - 1, 4, PS_NAR8 }, - { "Hail and Sacrifice to Diablo - Lord of Terror and Destroyer of Souls. When I awoke my Master from his sleep, he attempted to possess a mortal's form. Diablo attempted to claim the body of King Leoric, but my Master was too weak from his imprisonment. My Lord required a simple and innocent anchor to this world, and so found the boy Albrecht to be perfect for the task. While the good King Leoric was left maddened by Diablo's unsuccessful possession, I kidnapped his son Albrecht and brought him before my Master. I now await Diablo's call and pray that I will be rewarded when he at last emerges as the Lord of this world. |", - 1, 3, PS_NAR9 }, - { "Thank goodness you've returned!\nMuch has changed since you lived here, my friend. All was peaceful until the dark riders came and destroyed our village. Many were cut down where they stood, and those who took up arms were slain or dragged away to become slaves - or worse. The church at the edge of town has been desecrated and is being used for dark rituals. The screams that echo in the night are inhuman, but some of our townsfolk may yet survive. Follow the path that lies between my tavern and the blacksmith shop to find the church and save who you can. \n \nPerhaps I can tell you more if we speak again. Good luck.|", - 1, 5, TSFX_TAVERN0 } + { " Ahh, the story of our King, is it? The tragic fall of Leoric was a harsh blow to this land. The people always loved the King, and now they live in mortal fear of him. The question that I keep asking myself is how he could have fallen so far from the Light, as Leoric had always been the holiest of men. Only the vilest powers of Hell could so utterly destroy a man from within... |", + 1, 5, TSFX_STORY1 }, + { "The village needs your help, good master! Some months ago King Leoric's son, Prince Albrecht, was kidnapped. The King went into a rage and scoured the village for his missing child. With each passing day, Leoric seemed to slip deeper into madness. He sought to blame innocent townsfolk for the boy's disappearance and had them brutally executed. Less than half of us survived his insanity...\n \nThe King's Knights and Priests tried to placate him, but he turned against them and sadly, they were forced to kill him. With his dying breath the King called down a terrible curse upon his former followers. He vowed that they would serve him in darkness forever...\n \nThis is where things take an even darker twist than I thought possible! Our former King has risen from his eternal sleep and now commands a legion of undead minions within the Labyrinth. His body was buried in a tomb three levels beneath the Cathedral. Please, good master, put his soul at ease by destroying his now cursed form... |", + 1, 5, TSFX_TAVERN21 }, + { "As I told you, good master, the King was entombed three levels below. He's down there, waiting in the putrid darkness for his chance to destroy this land... |", + 1, 6, TSFX_TAVERN22 }, + { "The curse of our King has passed, but I fear that it was only part of a greater evil at work. However, we may yet be saved from the darkness that consumes our land, for your victory is a good omen. May Light guide you on your way, good master. |", + 1, 5, TSFX_TAVERN23 }, + { "The loss of his son was too much for King Leoric. I did what I could to ease his madness, but in the end it overcame him. A black curse has hung over this kingdom from that day forward, but perhaps if you were to free his spirit from his earthly prison, the curse would be lifted... |", + 1, 5, TSFX_HEALER1 }, + { "I don't like to think about how the King died. I like to remember him for the kind and just ruler that he was. His death was so sad and seemed very wrong, somehow. |", + 1, 6, TSFX_BMAID1 }, + { "I made many of the weapons and most of the armor that King Leoric used to outfit his knights. I even crafted a huge two-handed sword of the finest mithril for him, as well as a field crown to match. I still cannot believe how he died, but it must have been some sinister force that drove him insane! |", + 1, 5, TSFX_SMITH1 }, + { "I don't care about that. Listen, no skeleton is gonna be MY king. Leoric is King. King, so you hear me? HAIL TO THE KING! |", + 1, 5, TSFX_DRUNK1 }, + { "The dead who walk among the living follow the cursed King. He holds the power to raise yet more warriors for an ever growing army of the undead. If you do not stop his reign, he will surely march across this land and slay all who still live here. |", + 1, 5, TSFX_WITCH1 }, + { "Look, I'm running a business here. I don't sell information, and I don't care about some King that's been dead longer than I've been alive. If you need something to use against this King of the undead, then I can help you out... |", + 1, 5, TSFX_PEGBOY1 }, + { "The warmth of life has entered my tomb. Prepare yourself, mortal, to serve my Master for eternity! |", + 0, 5, USFX_SKING1 }, + { "I see that this strange behavior puzzles you as well. I would surmise that since many demons fear the light of the sun and believe that it holds great power, it may be that the rising sun depicted on the sign you speak of has led them to believe that it too holds some arcane powers. Hmm, perhaps they are not all as smart as we had feared... |", + 1, 5, TSFX_STORY2 }, + { "Master, I have a strange experience to relate. I know that you have a great knowledge of those monstrosities that inhabit the labyrinth, and this is something that I cannot understand for the very life of me... I was awakened during the night by a scraping sound just outside of my tavern. When I looked out from my bedroom, I saw the shapes of small demon-like creatures in the inn yard. After a short time, they ran off, but not before stealing the sign to my inn. I don't know why the demons would steal my sign but leave my family in peace... 'tis strange, no? |", + 1, 5, TSFX_TAVERN24 }, + { "Oh, you didn't have to bring back my sign, but I suppose that it does save me the expense of having another one made. Well, let me see, what could I give you as a fee for finding it? Hmmm, what have we here... ah, yes! This cap was left in one of the rooms by a magician who stayed here some time ago. Perhaps it may be of some value to you. |", + 1, 5, TSFX_TAVERN25 }, + { "My goodness, demons running about the village at night, pillaging our homes - is nothing sacred? I hope that Ogden and Garda are all right. I suppose that they would come to see me if they were hurt... |", + 1, 5, TSFX_HEALER2 }, + { "Oh my! Is that where the sign went? My Grandmother and I must have slept right through the whole thing. Thank the Light that those monsters didn't attack the inn. |", + 1, 6, TSFX_BMAID2 }, + { "Demons stole Ogden's sign, you say? That doesn't sound much like the atrocities I've heard of - or seen. \n \nDemons are concerned with ripping out your heart, not your signpost. |", + 1, 6, TSFX_SMITH2 }, + { "You know what I think? Somebody took that sign, and they gonna want lots of money for it. If I was Ogden... and I'm not, but if I was... I'd just buy a new sign with some pretty drawing on it. Maybe a nice mug of ale or a piece of cheese... |", + 1, 5, TSFX_DRUNK2 }, + { "No mortal can truly understand the mind of the demon. \n \nNever let their erratic actions confuse you, as that too may be their plan. |", + 1, 6, TSFX_WITCH2 }, + { "What - is he saying I took that? I suppose that Griswold is on his side, too. \n \nLook, I got over simple sign stealing months ago. You can't turn a profit on a piece of wood. |", + 1, 6, TSFX_PEGBOY2 }, + { "Hey - You that one that kill all! You get me Magic Banner or we attack! You no leave with life! You kill big uglies and give back Magic. Go past corner and door, find uglies. You give, you go! |", + 1, 5, USFX_SNOT1 }, + { "You kill uglies, get banner. You bring to me, or else... |", + 1, 6, USFX_SNOT2 }, + { "You give! Yes, good! Go now, we strong. We kill all with big Magic! |", + 1, 6, USFX_SNOT3 }, + { "This does not bode well, for it confirms my darkest fears. While I did not allow myself to believe the ancient legends, I cannot deny them now. Perhaps the time has come to reveal who I am.\n \nMy true name is Deckard Cain the Elder, and I am the last descendant of an ancient Brotherhood that was dedicated to safeguarding the secrets of a timeless evil. An evil that quite obviously has now been released.\n \nThe Archbishop Lazarus, once King Leoric's most trusted advisor, led a party of simple townsfolk into the Labyrinth to find the King's missing son, Albrecht. Quite some time passed before they returned, and only a few of them escaped with their lives.\n \nCurse me for a fool! I should have suspected his veiled treachery then. It must have been Lazarus himself who kidnapped Albrecht and has since hidden him within the Labyrinth. I do not understand why the Archbishop turned to the darkness, or what his interest is in the child. unless he means to sacrifice him to his dark masters!\n \nThat must be what he has planned! The survivors of his 'rescue party' say that Lazarus was last seen running into the deepest bowels of the labyrinth. You must hurry and save the prince from the sacrificial blade of this demented fiend! |", + 1, 3, TSFX_STORY36 }, + { "You must hurry and rescue Albrecht from the hands of Lazarus. The prince and the people of this kingdom are counting on you! |", + 1, 5, TSFX_STORY37 }, + { "Your story is quite grim, my friend. Lazarus will surely burn in Hell for his horrific deed. The boy that you describe is not our prince, but I believe that Albrecht may yet be in danger. The symbol of power that you speak of must be a portal in the very heart of the labyrinth.\n \nKnow this, my friend - The evil that you move against is the dark Lord of Terror. He is known to mortal men as Diablo. It was he who was imprisoned within the Labyrinth many centuries ago and I fear that he seeks to once again sow chaos in the realm of mankind. You must venture through the portal and destroy Diablo before it is too late! |", + 1, 5, TSFX_STORY38 }, + { "Lazarus was the Archbishop who led many of the townspeople into the labyrinth. I lost many good friends that day, and Lazarus never returned. I suppose he was killed along with most of the others. If you would do me a favor, good master - please do not talk to Farnham about that day. |", + 1, 6, TSFX_TAVERN1 }, + { "|", 1, 5, TSFX_STORY38 }, + { "|", 1, 5, TSFX_STORY38 }, + { "I was shocked when I heard of what the townspeople were planning to do that night. I thought that of all people, Lazarus would have had more sense than that. He was an Archbishop, and always seemed to care so much for the townsfolk of Tristram. So many were injured, I could not save them all... |", + 1, 5, TSFX_HEALER3 }, + { "I remember Lazarus as being a very kind and giving man. He spoke at my mother's funeral, and was supportive of my grandmother and myself in a very troubled time. I pray every night that somehow, he is still alive and safe. |", + 1, 5, TSFX_BMAID3 }, + { "I was there when Lazarus led us into the labyrinth. He spoke of holy retribution, but when we started fighting those hellspawn, he did not so much as lift his mace against them. He just ran deeper into the dim, endless chambers that were filled with the servants of darkness! |", + 1, 5, TSFX_SMITH3 }, + { "They stab, then bite, then they're all around you. Liar! LIAR! They're all dead! Dead! Do you hear me? They just keep falling and falling... their blood spilling out all over the floor... all his fault... |", + 1, 5, TSFX_DRUNK3 }, + { "I did not know this Lazarus of whom you speak, but I do sense a great conflict within his being. He poses a great danger, and will stop at nothing to serve the powers of darkness which have claimed him as theirs. |", + 1, 5, TSFX_WITCH3 }, + { "Yes, the righteous Lazarus, who was sooo effective against those monsters down there. Didn't help save my leg, did it? Look, I'll give you a free piece of advice. Ask Farnham, he was there. |", + 1, 5, TSFX_PEGBOY3 }, + { "Abandon your foolish quest. All that awaits you is the wrath of my Master! You are too late to save the child. Now you will join him in Hell! |", + 0, 5, USFX_LAZ1 }, + { " |", 0, 5, USFX_LAZ1 }, + { "Hmm, I don't know what I can really tell you about this that will be of any help. The water that fills our wells comes from an underground spring. I have heard of a tunnel that leads to a great lake - perhaps they are one and the same. Unfortunately, I do not know what would cause our water supply to be tainted. |", + 1, 5, TSFX_STORY4 }, + { "I have always tried to keep a large supply of foodstuffs and drink in our storage cellar, but with the entire town having no source of fresh water, even our stores will soon run dry. \n \nPlease, do what you can or I don't know what we will do. |", + 1, 6, TSFX_TAVERN2 }, + { "I'm glad I caught up to you in time! Our wells have become brackish and stagnant and some of the townspeople have become ill drinking from them. Our reserves of fresh water are quickly running dry. I believe that there is a passage that leads to the springs that serve our town. Please find what has caused this calamity, or we all will surely perish. |", + 1, 5, TSFX_HEALER20 }, + { "Please, you must hurry. Every hour that passes brings us closer to having no water to drink. \n \nWe cannot survive for long without your help. |", + 1, 6, TSFX_HEALER21 }, + { "What's that you say - the mere presence of the demons had caused the water to become tainted? Oh, truly a great evil lurks beneath our town, but your perseverance and courage gives us hope. Please take this ring - perhaps it will aid you in the destruction of such vile creatures. |", + 1, 5, TSFX_HEALER22 }, + { "My grandmother is very weak, and Garda says that we cannot drink the water from the wells. Please, can you do something to help us? |", + 1, 6, TSFX_BMAID4 }, + { "Pepin has told you the truth. We will need fresh water badly, and soon. I have tried to clear one of the smaller wells, but it reeks of stagnant filth. It must be getting clogged at the source. |", + 1, 5, TSFX_SMITH4 }, + { "You drink water? |", 1, 8, TSFX_DRUNK4 }, + { "The people of Tristram will die if you cannot restore fresh water to their wells. \n \nKnow this - demons are at the heart of this matter, but they remain ignorant of what they have spawned. |", + 1, 6, TSFX_WITCH4 }, + { "For once, I'm with you. My business runs dry - so to speak - if I have no market to sell to. You better find out what is going on, and soon! |", + 1, 6, TSFX_PEGBOY4 }, + { "A book that speaks of a chamber of human bones? Well, a Chamber of Bone is mentioned in certain archaic writings that I studied in the libraries of the East. These tomes inferred that when the Lords of the underworld desired to protect great treasures, they would create domains where those who died in the attempt to steal that treasure would be forever bound to defend it. A twisted, but strangely fitting, end? |", + 1, 4, TSFX_STORY7 }, + { "I am afraid that I don't know anything about that, good master. Cain has many books that may be of some help. |", + 1, 6, TSFX_TAVERN5 }, + { "This sounds like a very dangerous place. If you venture there, please take great care. |", + 1, 6, TSFX_HEALER5 }, + { "I am afraid that I haven't heard anything about that. Perhaps Cain the Storyteller could be of some help. |", + 1, 6, TSFX_BMAID6 }, + { "I know nothing of this place, but you may try asking Cain. He talks about many things, and it would not surprise me if he had some answers to your question. |", + 1, 6, TSFX_SMITH7 }, + { "Okay, so listen. There's this chamber of wood, see. And his wife, you know - her - tells the tree... cause you gotta wait. Then I says, that might work against him, but if you think I'm gonna PAY for this... you... uh... yeah. |", + 1, 5, TSFX_DRUNK7 }, + { "You will become an eternal servant of the dark lords should you perish within this cursed domain. \n \nEnter the Chamber of Bone at your own peril. |", + 1, 6, TSFX_WITCH7 }, + { "A vast and mysterious treasure, you say? Maybe I could be interested in picking up a few things from you... or better yet, don't you need some rare and expensive supplies to get you through this ordeal? |", + 1, 5, TSFX_PEGBOY7 }, + { "It seems that the Archbishop Lazarus goaded many of the townsmen into venturing into the Labyrinth to find the King's missing son. He played upon their fears and whipped them into a frenzied mob. None of them were prepared for what lay within the cold earth... Lazarus abandoned them down there - left in the clutches of unspeakable horrors - to die. |", + 1, 5, TSFX_STORY10 }, + { "Yes, Farnham has mumbled something about a hulking brute who wielded a fierce weapon. I believe he called him a butcher. |", + 1, 6, TSFX_TAVERN8 }, + { "By the Light, I know of this vile demon. There were many that bore the scars of his wrath upon their bodies when the few survivors of the charge led by Lazarus crawled from the Cathedral. I don't know what he used to slice open his victims, but it could not have been of this world. It left wounds festering with disease and even I found them almost impossible to treat. Beware if you plan to battle this fiend... |", + 1, 5, TSFX_HEALER8 }, + { "When Farnham said something about a butcher killing people, I immediately discounted it. But since you brought it up, maybe it is true. |", + 1, 6, TSFX_BMAID8 }, + { "I saw what Farnham calls the Butcher as it swathed a path through the bodies of my friends. He swung a cleaver as large as an axe, hewing limbs and cutting down brave men where they stood. I was separated from the fray by a host of small screeching demons and somehow found the stairway leading out. I never saw that hideous beast again, but his blood-stained visage haunts me to this day. |", + 1, 5, TSFX_SMITH10 }, + { "Big! Big cleaver killing all my friends. Couldn't stop him, had to run away, couldn't save them. Trapped in a room with so many bodies... so many friends... NOOOOOOOOOO! |", + 1, 5, TSFX_DRUNK10 }, + { "The Butcher is a sadistic creature that delights in the torture and pain of others. You have seen his handiwork in the drunkard Farnham. His destruction will do much to ensure the safety of this village. |", + 1, 5, TSFX_WITCH10 }, + { "I know more than you'd think about that grisly fiend. His little friends got a hold of me and managed to get my leg before Griswold pulled me out of that hole. \n \nI'll put it bluntly - kill him before he kills you and adds your corpse to his collection. |", + 1, 6, TSFX_PEGBOY10 }, + { "Please, listen to me. The Archbishop Lazarus, he led us down here to find the lost prince. The bastard led us into a trap! Now everyone is dead...killed by a demon he called the Butcher. Avenge us! Find this Butcher and slay him so that our souls may finally rest... |", + 1, 5, TSFX_WOUND }, + { " |", 1, 5, USFX_CLEAVER }, + { "You recite an interesting rhyme written in a style that reminds me of other works. Let me think now - what was it?\n \n...Darkness shrouds the Hidden. Eyes glowing unseen with only the sounds of razor claws briefly scraping to torment those poor souls who have been made sightless for all eternity. The prison for those so damned is named the Halls of the Blind... |", + 1, 5, TSFX_STORY12 }, + { "I never much cared for poetry. Occasionally, I had cause to hire minstrels when the inn was doing well, but that seems like such a long time ago now. \n \nWhat? Oh, yes... uh, well, I suppose you could see what someone else knows. |", + 1, 6, TSFX_TAVERN10 }, + { "This does seem familiar, somehow. I seem to recall reading something very much like that poem while researching the history of demonic afflictions. It spoke of a place of great evil that... wait - you're not going there are you? |", + 1, 5, TSFX_HEALER10 }, + { "If you have questions about blindness, you should talk to Pepin. I know that he gave my grandmother a potion that helped clear her vision, so maybe he can help you, too. |", + 1, 6, TSFX_BMAID10 }, + { "I am afraid that I have neither heard nor seen a place that matches your vivid description, my friend. Perhaps Cain the Storyteller could be of some help. |", + 1, 6, TSFX_SMITH12 }, + { "Look here... that's pretty funny, huh? Get it? Blind - look here? |", + 1, 6, TSFX_DRUNK12 }, + { "This is a place of great anguish and terror, and so serves its master well. \n \nTread carefully or you may yourself be staying much longer than you had anticipated. |", + 1, 6, TSFX_WITCH12 }, + { "Lets see, am I selling you something? No. Are you giving me money to tell you about this? No. Are you now leaving and going to talk to the storyteller who lives for this kind of thing? Yes. |", + 1, 5, TSFX_PEGBOY11 }, + { "You claim to have spoken with Lachdanan? He was a great hero during his life. Lachdanan was an honorable and just man who served his King faithfully for years. But of course, you already know that.\n \nOf those who were caught within the grasp of the King's Curse, Lachdanan would be the least likely to submit to the darkness without a fight, so I suppose that your story could be true. If I were in your place, my friend, I would find a way to release him from his torture. |", + 1, 5, TSFX_STORY13 }, + { "You speak of a brave warrior long dead! I'll have no such talk of speaking with departed souls in my inn yard, thank you very much. |", + 1, 6, TSFX_TAVERN11 }, + { "A golden elixir, you say. I have never concocted a potion of that color before, so I can't tell you how it would effect you if you were to try to drink it. As your healer, I strongly advise that should you find such an elixir, do as Lachdanan asks and DO NOT try to use it. |", + 1, 5, TSFX_HEALER11 }, + { "I've never heard of a Lachdanan before. I'm sorry, but I don't think that I can be of much help to you. |", + 1, 7, TSFX_BMAID11 }, + { "If it is actually Lachdanan that you have met, then I would advise that you aid him. I dealt with him on several occasions and found him to be honest and loyal in nature. The curse that fell upon the followers of King Leoric would fall especially hard upon him. |", + 1, 5, TSFX_SMITH13 }, + { " Lachdanan is dead. Everybody knows that, and you can't fool me into thinking any other way. You can't talk to the dead. I know! |", + 1, 5, TSFX_DRUNK13 }, + { "You may meet people who are trapped within the Labyrinth, such as Lachdanan. \n \nI sense in him honor and great guilt. Aid him, and you aid all of Tristram. |", + 1, 6, TSFX_WITCH13 }, + { "Wait, let me guess. Cain was swallowed up in a gigantic fissure that opened beneath him. He was incinerated in a ball of hellfire, and can't answer your questions anymore. Oh, that isn't what happened? Then I guess you'll be buying something or you'll be on your way. |", + 1, 5, TSFX_PEGBOY12 }, + { "Please, don't kill me, just hear me out. I was once Captain of King Leoric's Knights, upholding the laws of this land with justice and honor. Then his dark Curse fell upon us for the role we played in his tragic death. As my fellow Knights succumbed to their twisted fate, I fled from the King's burial chamber, searching for some way to free myself from the Curse. I failed...\n \nI have heard of a Golden Elixir that could lift the Curse and allow my soul to rest, but I have been unable to find it. My strength now wanes, and with it the last of my humanity as well. Please aid me and find the Elixir. I will repay your efforts - I swear upon my honor. |", + 1, 3, USFX_LACH1 }, + { "You have not found the Golden Elixir. I fear that I am doomed for eternity. Please, keep trying... |", + 1, 6, USFX_LACH2 }, + { "You have saved my soul from damnation, and for that I am in your debt. If there is ever a way that I can repay you from beyond the grave I will find it, but for now - take my helm. On the journey I am about to take I will have little use for it. May it protect you against the dark powers below. Go with the Light, my friend... |", + 1, 4, USFX_LACH3 }, + { "Griswold speaks of The Anvil of Fury - a legendary artifact long searched for, but never found. Crafted from the metallic bones of the Razor Pit demons, the Anvil of Fury was smelt around the skulls of the five most powerful magi of the underworld. Carved with runes of power and chaos, any weapon or armor forged upon this Anvil will be immersed into the realm of Chaos, imbedding it with magical properties. It is said that the unpredictable nature of Chaos makes it difficult to know what the outcome of this smithing will be... |", + 1, 4, TSFX_STORY14 }, + { "Don't you think that Griswold would be a better person to ask about this? He's quite handy, you know. |", + 1, 7, TSFX_TAVERN12 }, + { "If you had been looking for information on the Pestle of Curing or the Silver Chalice of Purification, I could have assisted you, my friend. However, in this matter, you would be better served to speak to either Griswold or Cain. |", + 1, 6, TSFX_HEALER12 }, + { "Griswold's father used to tell some of us when we were growing up about a giant anvil that was used to make mighty weapons. He said that when a hammer was struck upon this anvil, the ground would shake with a great fury. Whenever the earth moves, I always remember that story. |", + 1, 5, TSFX_BMAID12 }, + { "Greetings! It's always a pleasure to see one of my best customers! I know that you have been venturing deeper into the Labyrinth, and there is a story I was told that you may find worth the time to listen to...\n \nOne of the men who returned from the Labyrinth told me about a mystic anvil that he came across during his escape. His description reminded me of legends I had heard in my youth about the burning Hellforge where powerful weapons of magic are crafted. The legend had it that deep within the Hellforge rested the Anvil of Fury! This Anvil contained within it the very essence of the demonic underworld...\n \nIt is said that any weapon crafted upon the burning Anvil is imbued with great power. If this anvil is indeed the Anvil of Fury, I may be able to make you a weapon capable of defeating even the darkest lord of Hell! \n \nFind the Anvil for me, and I'll get to work! |", + 1, 5, TSFX_SMITH21 }, + { "Nothing yet, eh? Well, keep searching. A weapon forged upon the Anvil could be your best hope, and I am sure that I can make you one of legendary proportions. |", + 1, 5, TSFX_SMITH22 }, + { "I can hardly believe it! This is the Anvil of Fury - good work, my friend. Now we'll show those bastards that there are no weapons in Hell more deadly than those made by men! Take this and may Light protect you. |", + 1, 5, TSFX_SMITH23 }, + { "Griswold can't sell his anvil. What will he do then? And I'd be angry too if someone took my anvil! |", + 1, 6, TSFX_DRUNK14 }, + { "There are many artifacts within the Labyrinth that hold powers beyond the comprehension of mortals. Some of these hold fantastic power that can be used by either the Light or the Darkness. Securing the Anvil from below could shift the course of the Sin War towards the Light. |", + 1, 5, TSFX_WITCH14 }, + { "If you were to find this artifact for Griswold, it could put a serious damper on my business here. Awwww, you'll never find it. |", + 1, 6, TSFX_PEGBOY13 }, + { "The Gateway of Blood and the Halls of Fire are landmarks of mystic origin. Wherever this book you read from resides it is surely a place of great power.\n \nLegends speak of a pedestal that is carved from obsidian stone and has a pool of boiling blood atop its bone encrusted surface. There are also allusions to Stones of Blood that will open a door that guards an ancient treasure...\n \nThe nature of this treasure is shrouded in speculation, my friend, but it is said that the ancient hero Arkaine placed the holy armor Valor in a secret vault. Arkaine was the first mortal to turn the tide of the Sin War and chase the legions of darkness back to the Burning Hells.\n \nJust before Arkaine died, his armor was hidden away in a secret vault. It is said that when this holy armor is again needed, a hero will arise to don Valor once more. Perhaps you are that hero... |", + 1, 3, TSFX_STORY15 }, + { "Every child hears the story of the warrior Arkaine and his mystic armor known as Valor. If you could find its resting place, you would be well protected against the evil in the Labyrinth. |", + 1, 6, TSFX_TAVERN13 }, + { "Hmm... it sounds like something I should remember, but I've been so busy learning new cures and creating better elixirs that I must have forgotten. Sorry... |", + 1, 6, TSFX_HEALER13 }, + { "The story of the magic armor called Valor is something I often heard the boys talk about. You had better ask one of the men in the village. |", + 1, 6, TSFX_BMAID13 }, + { "The armor known as Valor could be what tips the scales in your favor. I will tell you that many have looked for it - including myself. Arkaine hid it well, my friend, and it will take more than a bit of luck to unlock the secrets that have kept it concealed oh, lo these many years. |", + 1, 5, TSFX_SMITH14 }, + { "Zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz... |", 1, 7, TSFX_DRUNK15 }, + { "Should you find these Stones of Blood, use them carefully. \n \nThe way is fraught with danger and your only hope rests within your self trust. |", + 1, 6, TSFX_WITCH15 }, + { "You intend to find the armor known as Valor? \n \nNo one has ever figured out where Arkaine stashed the stuff, and if my contacts couldn't find it, I seriously doubt you ever will either. |", + 1, 6, TSFX_PEGBOY14 }, + { "I know of only one legend that speaks of such a warrior as you describe. His story is found within the ancient chronicles of the Sin War...\n \nStained by a thousand years of war, blood and death, the Warlord of Blood stands upon a mountain of his tattered victims. His dark blade screams a black curse to the living; a tortured invitation to any who would stand before this Executioner of Hell.\n \nIt is also written that although he was once a mortal who fought beside the Legion of Darkness during the Sin War, he lost his humanity to his insatiable hunger for blood. |", + 1, 5, TSFX_STORY18 }, + { "I am afraid that I haven't heard anything about such a vicious warrior, good master. I hope that you do not have to fight him, for he sounds extremely dangerous. |", + 1, 6, TSFX_TAVERN16 }, + { "Cain would be able to tell you much more about something like this than I would ever wish to know. |", + 1, 7, TSFX_HEALER16 }, + { "If you are to battle such a fierce opponent, may Light be your guide and your defender. I will keep you in my thoughts. |", + 1, 6, TSFX_BMAID16 }, + { "Dark and wicked legends surrounds the one Warlord of Blood. Be well prepared, my friend, for he shows no mercy or quarter. |", + 1, 6, TSFX_SMITH17 }, + { "Always you gotta talk about Blood? What about flowers, and sunshine, and that pretty girl that brings the drinks. Listen here, friend - you're obsessive, you know that? |", + 1, 5, TSFX_DRUNK17 }, + { "His prowess with the blade is awesome, and he has lived for thousands of years knowing only warfare. I am sorry... I can not see if you will defeat him. |", + 1, 5, TSFX_WITCH18 }, + { "I haven't ever dealt with this Warlord you speak of, but he sounds like he's going through a lot of swords. Wouldn't mind supplying his armies... |", + 1, 6, TSFX_PEGBOY17 }, + { "My blade sings for your blood, mortal, and by my dark masters it shall not be denied. |", + 0, 6, USFX_WARLRD1 }, + { "Griswold speaks of the Heaven Stone that was destined for the enclave located in the east. It was being taken there for further study. This stone glowed with an energy that somehow granted vision beyond that which a normal man could possess. I do not know what secrets it holds, my friend, but finding this stone would certainly prove most valuable. |", + 1, 5, TSFX_STORY20 }, + { "The caravan stopped here to take on some supplies for their journey to the east. I sold them quite an array of fresh fruits and some excellent sweetbreads that Garda has just finished baking. Shame what happened to them... |", + 1, 6, TSFX_TAVERN18 }, + { "I don't know what it is that they thought they could see with that rock, but I will say this. If rocks are falling from the sky, you had better be careful! |", + 1, 6, TSFX_HEALER18 }, + { "Well, a caravan of some very important people did stop here, but that was quite a while ago. They had strange accents and were starting on a long journey, as I recall. \n \nI don't see how you could hope to find anything that they would have been carrying. |", + 1, 6, TSFX_BMAID18 }, + { "Stay for a moment - I have a story you might find interesting. A caravan that was bound for the eastern kingdoms passed through here some time ago. It was supposedly carrying a piece of the heavens that had fallen to earth! The caravan was ambushed by cloaked riders just north of here along the roadway. I searched the wreckage for this sky rock, but it was nowhere to be found. If you should find it, I believe that I can fashion something useful from it. |", + 1, 5, TSFX_SMITH24 }, + { "I am still waiting for you to bring me that stone from the heavens. I know that I can make something powerful out of it. |", + 1, 6, TSFX_SMITH25 }, + { "Let me see that - aye... aye, it is as I believed. Give me a moment...\n \nAh, Here you are. I arranged pieces of the stone within a silver ring that my father left me. I hope it serves you well. |", + 1, 5, TSFX_SMITH26 }, + { "I used to have a nice ring; it was a really expensive one, with blue and green and red and silver. Don't remember what happened to it, though. I really miss that ring... |", + 1, 5, TSFX_DRUNK19 }, + { "The Heaven Stone is very powerful, and were it any but Griswold who bid you find it, I would prevent it. He will harness its powers and its use will be for the good of us all. |", + 1, 5, TSFX_WITCH20 }, + { "If anyone can make something out of that rock, Griswold can. He knows what he is doing, and as much as I try to steal his customers, I respect the quality of his work. |", + 1, 6, TSFX_PEGBOY18 }, + { "The witch Adria seeks a black mushroom? I know as much about Black Mushrooms as I do about Red Herrings. Perhaps Pepin the Healer could tell you more, but this is something that cannot be found in any of my stories or books. |", + 1, 5, TSFX_STORY21 }, + { "Let me just say this. Both Garda and I would never, EVER serve black mushrooms to our honored guests. If Adria wants some mushrooms in her stew, then that is her business, but I can't help you find any. Black mushrooms... disgusting! |", + 1, 5, TSFX_TAVERN19 }, + { "The witch told me that you were searching for the brain of a demon to assist me in creating my elixir. It should be of great value to the many who are injured by those foul beasts, if I can just unlock the secrets I suspect that its alchemy holds. If you can remove the brain of a demon when you kill it, I would be grateful if you could bring it to me. |", + 1, 5, TSFX_HEALER26 }, + { "Excellent, this is just what I had in mind. I was able to finish the elixir without this, but it can't hurt to have this to study. Would you please carry this to the witch? I believe that she is expecting it. |", + 1, 5, TSFX_HEALER27 }, + { "I think Ogden might have some mushrooms in the storage cellar. Why don't you ask him? |", + 1, 7, TSFX_BMAID19 }, + { "If Adria doesn't have one of these, you can bet that's a rare thing indeed. I can offer you no more help than that, but it sounds like... a huge, gargantuan, swollen, bloated mushroom! Well, good hunting, I suppose. |", + 1, 5, TSFX_SMITH19 }, + { "Ogden mixes a MEAN black mushroom, but I get sick if I drink that. Listen, listen... here's the secret - moderation is the key! |", + 1, 5, TSFX_DRUNK20 }, + { "What do we have here? Interesting, it looks like a book of reagents. Keep your eyes open for a black mushroom. It should be fairly large and easy to identify. If you find it, bring it to me, won't you? |", + 1, 5, TSFX_WITCH22 }, + { "It's a big, black mushroom that I need. Now run off and get it for me so that I can use it for a special concoction that I am working on. |", + 1, 6, TSFX_WITCH23 }, + { "Yes, this will be perfect for a brew that I am creating. By the way, the healer is looking for the brain of some demon or another so he can treat those who have been afflicted by their poisonous venom. I believe that he intends to make an elixir from it. If you help him find what he needs, please see if you can get a sample of the elixir for me. |", + 1, 5, TSFX_WITCH24 }, + { "Why have you brought that here? I have no need for a demon's brain at this time. I do need some of the elixir that the Healer is working on. He needs that grotesque organ that you are holding, and then bring me the elixir. Simple when you think about it, isn't it? |", + 1, 5, TSFX_WITCH25 }, + { "What? Now you bring me that elixir from the healer? I was able to finish my brew without it. Why don't you just keep it... |", + 1, 6, TSFX_WITCH26 }, + { "I don't have any mushrooms of any size or color for sale. How about something a bit more useful? |", + 1, 6, TSFX_PEGBOY19 }, + { "So, the legend of the Map is real. Even I never truly believed any of it! I suppose it is time that I told you the truth about who I am, my friend. You see, I am not all that I seem...\n \nMy true name is Deckard Cain the Elder, and I am the last descendant of an ancient Brotherhood that was dedicated to keeping and safeguarding the secrets of a timeless evil. An evil that quite obviously has now been released...\n \nThe evil that you move against is the dark Lord of Terror - known to mortal men as Diablo. It was he who was imprisoned within the Labyrinth many centuries ago. The Map that you hold now was created ages ago to mark the time when Diablo would rise again from his imprisonment. When the two stars on that map align, Diablo will be at the height of his power. He will be all but invincible...\n \nYou are now in a race against time, my friend! Find Diablo and destroy him before the stars align, for we may never have a chance to rid the world of his evil again! |", + 1, 2, TSFX_STORY22 }, + { "Our time is running short! I sense his dark power building and only you can stop him from attaining his full might. |", + 1, 6, TSFX_STORY23 }, + { "I am sure that you tried your best, but I fear that even your strength and will may not be enough. Diablo is now at the height of his earthly power, and you will need all your courage and strength to defeat him. May the Light protect and guide you, my friend. I will help in any way that I am able. |", + 1, 5, TSFX_STORY24 }, + { "If the witch can't help you and suggests you see Cain, what makes you think that I would know anything? It sounds like this is a very serious matter. You should hurry along and see the storyteller as Adria suggests. |", + 1, 6, TSFX_TAVERN20 }, + { "I can't make much of the writing on this map, but perhaps Adria or Cain could help you decipher what this refers to. \n \nI can see that it is a map of the stars in our sky, but any more than that is beyond my talents. |", + 1, 6, TSFX_HEALER19 }, + { "The best person to ask about that sort of thing would be our storyteller. \n \nCain is very knowledgeable about ancient writings, and that is easily the oldest looking piece of paper that I have ever seen. |", + 1, 6, TSFX_BMAID20 }, + { "I have never seen a map of this sort before. Where'd you get it? Although I have no idea how to read this, Cain or Adria may be able to provide the answers that you seek. |", + 1, 6, TSFX_SMITH20 }, + { "Listen here, come close. I don't know if you know what I know, but you have really got somethin' here. That's a map. |", + 1, 5, TSFX_DRUNK21 }, + { "Oh, I'm afraid this does not bode well at all. This map of the stars portends great disaster, but its secrets are not mine to tell. The time has come for you to have a very serious conversation with the Storyteller... |", + 1, 5, TSFX_WITCH21 }, + { "I've been looking for a map, but that certainly isn't it. You should show that to Adria - she can probably tell you what it is. I'll say one thing; it looks old, and old usually means valuable. |", + 1, 5, TSFX_PEGBOY20 }, + { "Pleeeease, no hurt. No Kill. Keep alive and next time good bring to you. |", + 1, 6, USFX_GARBUD1 }, + { "Something for you I am making. Again, not kill Gharbad. Live and give good. \n \nYou take this as proof I keep word... |", + 1, 6, USFX_GARBUD2 }, + { "Nothing yet! Almost done. \n \nVery powerful, very strong. Live! Live! \n \nNo pain and promise I keep! |", + 1, 6, USFX_GARBUD3 }, + { "This too good for you. Very Powerful! You want - you take! |", + 1, 6, USFX_GARBUD4 }, + { "What?! Why are you here? All these interruptions are enough to make one insane. Here, take this and leave me to my work. Trouble me no more! |", + 1, 6, USFX_ZHAR1 }, + { "Arrrrgh! Your curiosity will be the death of you!!! |", 1, 7, USFX_ZHAR2 }, + { "Hello, my friend. Stay awhile and listen... |", 0, 5, TSFX_STORY25 }, + { "While you are venturing deeper into the Labyrinth you may find tomes of great knowledge hidden there. \n \nRead them carefully for they can tell you things that even I cannot. |", + 1, 6, TSFX_STORY26 }, + { "I know of many myths and legends that may contain answers to questions that may arise in your journeys into the Labyrinth. If you come across challenges and questions to which you seek knowledge, seek me out and I will tell you what I can. |", + 1, 5, TSFX_STORY27 }, + { "Griswold - a man of great action and great courage. I bet he never told you about the time he went into the Labyrinth to save Wirt, did he? He knows his fair share of the dangers to be found there, but then again - so do you. He is a skilled craftsman, and if he claims to be able to help you in any way, you can count on his honesty and his skill. |", + 1, 5, TSFX_STORY28 }, + { "Ogden has owned and run the Rising Sun Inn and Tavern for almost four years now. He purchased it just a few short months before everything here went to hell. He and his wife Garda do not have the money to leave as they invested all they had in making a life for themselves here. He is a good man with a deep sense of responsibility. |", + 1, 5, TSFX_STORY29 }, + { "Poor Farnham. He is a disquieting reminder of the doomed assembly that entered into the Cathedral with Lazarus on that dark day. He escaped with his life, but his courage and much of his sanity were left in some dark pit. He finds comfort only at the bottom of his tankard nowadays, but there are occasional bits of truth buried within his constant ramblings. |", + 1, 5, TSFX_STORY30 }, + { "The witch, Adria, is an anomaly here in Tristram. She arrived shortly after the Cathedral was desecrated while most everyone else was fleeing. She had a small hut constructed at the edge of town, seemingly overnight, and has access to many strange and arcane artifacts and tomes of knowledge that even I have never seen before. |", + 1, 5, TSFX_STORY31 }, + { "The story of Wirt is a frightening and tragic one. He was taken from the arms of his mother and dragged into the labyrinth by the small, foul demons that wield wicked spears. There were many other children taken that day, including the son of King Leoric. The Knights of the palace went below, but never returned. The Blacksmith found the boy, but only after the foul beasts had begun to torture him for their sadistic pleasures. |", + 1, 5, TSFX_STORY33 }, + { "Ah, Pepin. I count him as a true friend - perhaps the closest I have here. He is a bit addled at times, but never a more caring or considerate soul has existed. His knowledge and skills are equaled by few, and his door is always open. |", + 1, 5, TSFX_STORY34 }, + { "Gillian is a fine woman. Much adored for her high spirits and her quick laugh, she holds a special place in my heart. She stays on at the tavern to support her elderly grandmother who is too sick to travel. I sometimes fear for her safety, but I know that any man in the village would rather die than see her harmed. |", + 1, 5, TSFX_STORY35 }, + { "Greetings, good master. Welcome to the Tavern of the Rising Sun! |", + 0, 5, TSFX_TAVERN36 }, + { "Many adventurers have graced the tables of my tavern, and ten times as many stories have been told over as much ale. The only thing that I ever heard any of them agree on was this old axiom. Perhaps it will help you. You can cut the flesh, but you must crush the bone. |", + 1, 5, TSFX_TAVERN37 }, + { "Griswold the blacksmith is extremely knowledgeable about weapons and armor. If you ever need work done on your gear, he is definitely the man to see. |", + 1, 6, TSFX_TAVERN38 }, + { "Farnham spends far too much time here, drowning his sorrows in cheap ale. I would make him leave, but he did suffer so during his time in the Labyrinth. |", + 1, 6, TSFX_TAVERN39 }, + { "Adria is wise beyond her years, but I must admit - she frightens me a little. \n \nWell, no matter. If you ever have need to trade in items of sorcery, she maintains a strangely well-stocked hut just across the river. |", + 1, 6, TSFX_TAVERN40 }, + { "If you want to know more about the history of our village, the storyteller Cain knows quite a bit about the past. |", + 1, 6, TSFX_TAVERN41 }, + { "Wirt is a rapscallion and a little scoundrel. He was always getting into trouble, and it's no surprise what happened to him. \n \nHe probably went fooling about someplace that he shouldn't have been. I feel sorry for the boy, but I don't abide the company that he keeps. |", + 1, 6, TSFX_TAVERN43 }, + { "Pepin is a good man - and certainly the most generous in the village. He is always attending to the needs of others, but trouble of some sort or another does seem to follow him wherever he goes... |", + 1, 6, TSFX_TAVERN44 }, + { "Gillian, my Barmaid? If it were not for her sense of duty to her grand-dam, she would have fled from here long ago. \n \nGoodness knows I begged her to leave, telling her that I would watch after the old woman, but she is too sweet and caring to have done so. |", + 1, 6, TSFX_TAVERN45 }, + { "What ails you, my friend? |", 0, 5, TSFX_HEALER37 }, + { "I have made a very interesting discovery. Unlike us, the creatures in the Labyrinth can heal themselves without the aid of potions or magic. If you hurt one of the monsters, make sure it is dead or it very well may regenerate itself. |", + 1, 5, TSFX_HEALER38 }, + { "Before it was taken over by, well, whatever lurks below, the Cathedral was a place of great learning. There are many books to be found there. If you find any, you should read them all, for some may hold secrets to the workings of the Labyrinth. |", + 1, 5, TSFX_HEALER39 }, + { "Griswold knows as much about the art of war as I do about the art of healing. He is a shrewd merchant, but his work is second to none. Oh, I suppose that may be because he is the only blacksmith left here. |", + 1, 5, TSFX_HEALER40 }, + { "Cain is a true friend and a wise sage. He maintains a vast library and has an innate ability to discern the true nature of many things. If you ever have any questions, he is the person to go to. |", + 1, 5, TSFX_HEALER41 }, + { "Even my skills have been unable to fully heal Farnham. Oh, I have been able to mend his body, but his mind and spirit are beyond anything I can do. |", + 1, 5, TSFX_HEALER42 }, + { "While I use some limited forms of magic to create the potions and elixirs I store here, Adria is a true sorceress. She never seems to sleep, and she always has access to many mystic tomes and artifacts. I believe her hut may be much more than the hovel it appears to be, but I can never seem to get inside the place. |", + 1, 5, TSFX_HEALER43 }, + { "Poor Wirt. I did all that was possible for the child, but I know he despises that wooden peg that I was forced to attach to his leg. His wounds were hideous. No one - and especially such a young child - should have to suffer the way he did. |", + 1, 5, TSFX_HEALER45 }, + { "I really don't understand why Ogden stays here in Tristram. He suffers from a slight nervous condition, but he is an intelligent and industrious man who would do very well wherever he went. I suppose it may be the fear of the many murders that happen in the surrounding countryside, or perhaps the wishes of his wife that keep him and his family where they are. |", + 1, 5, TSFX_HEALER46 }, + { "Ogden's barmaid is a sweet girl. Her grandmother is quite ill, and suffers from delusions. \n \nShe claims that they are visions, but I have no proof of that one way or the other. |", + 1, 6, TSFX_HEALER47 }, + { "Good day! How may I serve you? |", 0, 5, TSFX_BMAID31 }, + { "My grandmother had a dream that you would come and talk to me. She has visions, you know and can see into the future. |", + 1, 6, TSFX_BMAID32 }, + { "The woman at the edge of town is a witch! She seems nice enough, and her name, Adria, is very pleasing to the ear, but I am very afraid of her. \n \nIt would take someone quite brave, like you, to see what she is doing out there. |", + 1, 6, TSFX_BMAID33 }, + { "Our Blacksmith is a point of pride to the people of Tristram. Not only is he a master craftsman who has won many contests within his guild, but he received praises from our King Leoric himself - may his soul rest in peace. Griswold is also a great hero; just ask Cain. |", + 1, 5, TSFX_BMAID34 }, + { "Cain has been the storyteller of Tristram for as long as I can remember. He knows so much, and can tell you just about anything about almost everything. |", + 1, 6, TSFX_BMAID35 }, + { "Farnham is a drunkard who fills his belly with ale and everyone else's ears with nonsense. \n \nI know that both Pepin and Ogden feel sympathy for him, but I get so frustrated watching him slip farther and farther into a befuddled stupor every night. |", + 1, 6, TSFX_BMAID36 }, + { "Pepin saved my grandmother's life, and I know that I can never repay him for that. His ability to heal any sickness is more powerful than the mightiest sword and more mysterious than any spell you can name. If you ever are in need of healing, Pepin can help you. |", + 1, 5, TSFX_BMAID37 }, + { "I grew up with Wirt's mother, Canace. Although she was only slightly hurt when those hideous creatures stole him, she never recovered. I think she died of a broken heart. Wirt has become a mean-spirited youngster, looking only to profit from the sweat of others. I know that he suffered and has seen horrors that I cannot even imagine, but some of that darkness hangs over him still. |", + 1, 5, TSFX_BMAID39 }, + { "Ogden and his wife have taken me and my grandmother into their home and have even let me earn a few gold pieces by working at the inn. I owe so much to them, and hope one day to leave this place and help them start a grand hotel in the east. |", + 1, 5, TSFX_BMAID40 }, + { "Well, what can I do for ya? |", 0, 5, TSFX_SMITH44 }, + { "If you're looking for a good weapon, let me show this to you. Take your basic blunt weapon, such as a mace. Works like a charm against most of those undying horrors down there, and there's nothing better to shatter skinny little skeletons! |", + 1, 5, TSFX_SMITH45 }, + { "The axe? Aye, that's a good weapon, balanced against any foe. Look how it cleaves the air, and then imagine a nice fat demon head in its path. Keep in mind, however, that it is slow to swing - but talk about dealing a heavy blow! |", + 1, 5, TSFX_SMITH46 }, + { "Look at that edge, that balance. A sword in the right hands, and against the right foe, is the master of all weapons. Its keen blade finds little to hack or pierce on the undead, but against a living, breathing enemy, a sword will better slice their flesh! |", + 1, 5, TSFX_SMITH47 }, + { "Your weapons and armor will show the signs of your struggles against the Darkness. If you bring them to me, with a bit of work and a hot forge, I can restore them to top fighting form. |", + 1, 6, TSFX_SMITH48 }, + { "While I have to practically smuggle in the metals and tools I need from caravans that skirt the edges of our damned town, that witch, Adria, always seems to get whatever she needs. If I knew even the smallest bit about how to harness magic as she did, I could make some truly incredible things. |", + 1, 5, TSFX_SMITH49 }, + { "Gillian is a nice lass. Shame that her gammer is in such poor health or I would arrange to get both of them out of here on one of the trading caravans. |", + 1, 6, TSFX_SMITH50 }, + { "Sometimes I think that Cain talks too much, but I guess that is his calling in life. If I could bend steel as well as he can bend your ear, I could make a suit of court plate good enough for an Emperor! |", + 1, 5, TSFX_SMITH51 }, + { "I was with Farnham that night that Lazarus led us into Labyrinth. I never saw the Archbishop again, and I may not have survived if Farnham was not at my side. I fear that the attack left his soul as crippled as, well, another did my leg. I cannot fight this battle for him now, but I would if I could. |", + 1, 5, TSFX_SMITH52 }, + { "A good man who puts the needs of others above his own. You won't find anyone left in Tristram - or anywhere else for that matter - who has a bad thing to say about the healer. |", + 1, 6, TSFX_SMITH53 }, + { "That lad is going to get himself into serious trouble... or I guess I should say, again. I've tried to interest him in working here and learning an honest trade, but he prefers the high profits of dealing in goods of dubious origin. I cannot hold that against him after what happened to him, but I do wish he would at least be careful. |", + 1, 5, TSFX_SMITH55 }, + { "The Innkeeper has little business and no real way of turning a profit. He manages to make ends meet by providing food and lodging for those who occasionally drift through the village, but they are as likely to sneak off into the night as they are to pay him. If it weren't for the stores of grains and dried meats he kept in his cellar, why, most of us would have starved during that first year when the entire countryside was overrun by demons. |", + 1, 5, TSFX_SMITH56 }, + { "Can't a fella drink in peace? |", 0, 5, TSFX_DRUNK27 }, + { "The gal who brings the drinks? Oh, yeah, what a pretty lady. So nice, too. |", + 1, 6, TSFX_DRUNK28 }, + { "Why don't that old crone do somethin' for a change. Sure, sure, she's got stuff, but you listen to me... she's unnatural. I ain't never seen her eat or drink - and you can't trust somebody who doesn't drink at least a little. |", + 1, 5, TSFX_DRUNK29 }, + { "Cain isn't what he says he is. Sure, sure, he talks a good story... some of 'em are real scary or funny... but I think he knows more than he knows he knows. |", + 1, 5, TSFX_DRUNK30 }, + { "Griswold? Good old Griswold. I love him like a brother! We fought together, you know, back when... we... Lazarus... Lazarus... Lazarus!!! |", + 1, 5, TSFX_DRUNK31 }, + { "Hehehe, I like Pepin. He really tries, you know. Listen here, you should make sure you get to know him. Good fella like that with people always wantin' help. Hey, I guess that would be kinda like you, huh hero? I was a hero too... |", + 1, 5, TSFX_DRUNK32 }, + { "Wirt is a kid with more problems than even me, and I know all about problems. Listen here - that kid is gotta sweet deal, but he's been there, you know? Lost a leg! Gotta walk around on a piece of wood. So sad, so sad... |", + 1, 5, TSFX_DRUNK34 }, + { "Ogden is the best man in town. I don't think his wife likes me much, but as long as she keeps tappin' kegs, I'll like her just fine. Seems like I been spendin' more time with Ogden than most, but he's so good to me... |", + 1, 5, TSFX_DRUNK35 }, + { "I wanna tell ya sumthin', 'cause I know all about this stuff. It's my specialty. This here is the best... theeeee best! That other ale ain't no good since those stupid dogs... |", + 1, 5, TSFX_DRUNK23 }, + { "No one ever lis... listens to me. Somewhere - I ain't too sure - but somewhere under the church is a whole pile o' gold. Gleamin' and shinin' and just waitin' for someone to get it. |", + 1, 5, TSFX_DRUNK24 }, + { "I know you gots your own ideas, and I know you're not gonna believe this, but that weapon you got there - it just ain't no good against those big brutes! Oh, I don't care what Griswold says, they can't make anything like they used to in the old days... |", + 1, 5, TSFX_DRUNK25 }, + { "If I was you... and I ain't... but if I was, I'd sell all that stuff you got and get out of here. That boy out there... He's always got somethin good, but you gotta give him some gold or he won't even show you what he's got. |", + 1, 5, TSFX_DRUNK26 }, + { "I sense a soul in search of answers... |", 0, 5, TSFX_WITCH38 }, + { "Wisdom is earned, not given. If you discover a tome of knowledge, devour its words. Should you already have knowledge of the arcane mysteries scribed within a book, remember - that level of mastery can always increase. |", + 1, 5, TSFX_WITCH39 }, + { "The greatest power is often the shortest lived. You may find ancient words of power written upon scrolls of parchment. The strength of these scrolls lies in the ability of either apprentice or adept to cast them with equal ability. Their weakness is that they must first be read aloud and can never be kept at the ready in your mind. Know also that these scrolls can be read but once, so use them with care. |", + 1, 5, TSFX_WITCH40 }, + { "Though the heat of the sun is beyond measure, the mere flame of a candle is of greater danger. No energies, no matter how great, can be used without the proper focus. For many spells, ensorcelled Staves may be charged with magical energies many times over. I have the ability to restore their power - but know that nothing is done without a price. |", + 1, 5, TSFX_WITCH41 }, + { "The sum of our knowledge is in the sum of its people. Should you find a book or scroll that you cannot decipher, do not hesitate to bring it to me. If I can make sense of it I will share what I find. |", + 1, 5, TSFX_WITCH42 }, + { "To a man who only knows Iron, there is no greater magic than Steel. The blacksmith Griswold is more of a sorcerer than he knows. His ability to meld fire and metal is unequaled in this land. |", + 1, 5, TSFX_WITCH43 }, + { "Corruption has the strength of deceit, but innocence holds the power of purity. The young woman Gillian has a pure heart, placing the needs of her matriarch over her own. She fears me, but it is only because she does not understand me. |", + 1, 5, TSFX_WITCH44 }, + { "A chest opened in darkness holds no greater treasure than when it is opened in the light. The storyteller Cain is an enigma, but only to those who do not look. His knowledge of what lies beneath the cathedral is far greater than even he allows himself to realize. |", + 1, 5, TSFX_WITCH45 }, + { "The higher you place your faith in one man, the farther it has to fall. Farnham has lost his soul, but not to any demon. It was lost when he saw his fellow townspeople betrayed by the Archbishop Lazarus. He has knowledge to be gleaned, but you must separate fact from fantasy. |", + 1, 5, TSFX_WITCH46 }, + { "The hand, the heart and the mind can perform miracles when they are in perfect harmony. The healer Pepin sees into the body in a way that even I cannot. His ability to restore the sick and injured is magnified by his understanding of the creation of elixirs and potions. He is as great an ally as you have in Tristram. |", + 1, 5, TSFX_WITCH47 }, + { "There is much about the future we cannot see, but when it comes it will be the children who wield it. The boy Wirt has a blackness upon his soul, but he poses no threat to the town or its people. His secretive dealings with the urchins and unspoken guilds of nearby towns gain him access to many devices that cannot be easily found in Tristram. While his methods may be reproachful, Wirt can provide assistance for your battle against the encroaching Darkness. |", + 1, 4, TSFX_WITCH49 }, + { "Earthen walls and thatched canopy do not a home create. The innkeeper Ogden serves more of a purpose in this town than many understand. He provides shelter for Gillian and her matriarch, maintains what life Farnham has left to him, and provides an anchor for all who are left in the town to what Tristram once was. His tavern, and the simple pleasures that can still be found there, provide a glimpse of a life that the people here remember. It is that memory that continues to feed their hopes for your success. |", + 1, 4, TSFX_WITCH50 }, + { "Pssst... over here... |", 0, 5, TSFX_PEGBOY32 }, + { "Not everyone in Tristram has a use - or a market - for everything you will find in the labyrinth. Not even me, as hard as that is to believe. \n \nSometimes, only you will be able to find a purpose for some things. |", + 1, 6, TSFX_PEGBOY33 }, + { "Don't trust everything the drunk says. Too many ales have fogged his vision and his good sense. |", + 1, 6, TSFX_PEGBOY34 }, + { "In case you haven't noticed, I don't buy anything from Tristram. I am an importer of quality goods. If you want to peddle junk, you'll have to see Griswold, Pepin or that witch, Adria. I'm sure that they will snap up whatever you can bring them... |", + 1, 5, TSFX_PEGBOY35 }, + { "I guess I owe the blacksmith my life - what there is of it. Sure, Griswold offered me an apprenticeship at the smithy, and he is a nice enough guy, but I'll never get enough money to... well, let's just say that I have definite plans that require a large amount of gold. |", + 1, 5, TSFX_PEGBOY36 }, + { "If I were a few years older, I would shower her with whatever riches I could muster, and let me assure you I can get my hands on some very nice stuff. Gillian is a beautiful girl who should get out of Tristram as soon as it is safe. Hmmm... maybe I'll take her with me when I go... |", + 1, 5, TSFX_PEGBOY37 }, + { "Cain knows too much. He scares the life out of me - even more than that woman across the river. He keeps telling me about how lucky I am to be alive, and how my story is foretold in legend. I think he's off his crock. |", + 1, 5, TSFX_PEGBOY38 }, + { "Farnham - now there is a man with serious problems, and I know all about how serious problems can be. He trusted too much in the integrity of one man, and Lazarus led him into the very jaws of death. Oh, I know what it's like down there, so don't even start telling me about your plans to destroy the evil that dwells in that Labyrinth. Just watch your legs... |", + 1, 5, TSFX_PEGBOY39 }, + { "As long as you don't need anything reattached, old Pepin is as good as they come. \n \nIf I'd have had some of those potions he brews, I might still have my leg... |", + 1, 6, TSFX_PEGBOY40 }, + { "Adria truly bothers me. Sure, Cain is creepy in what he can tell you about the past, but that witch can see into your past. She always has some way to get whatever she needs, too. Adria gets her hands on more merchandise than I've seen pass through the gates of the King's Bazaar during High Festival. |", + 1, 5, TSFX_PEGBOY42 }, + { "Ogden is a fool for staying here. I could get him out of town for a very reasonable price, but he insists on trying to make a go of it with that stupid tavern. I guess at the least he gives Gillian a place to work, and his wife Garda does make a superb Shepherd's pie... |", + 1, 5, TSFX_PEGBOY43 }, + { "Beyond the Hall of Heroes lies the Chamber of Bone. Eternal death awaits any who would seek to steal the treasures secured within this room. So speaks the Lord of Terror, and so it is written. |", + 1, 5, PS_WARR1 }, + { "...and so, locked beyond the Gateway of Blood and past the Hall of Fire, Valor awaits for the Hero of Light to awaken... |", + 1, 6, PS_WARR10 }, + { "I can see what you see not.\nVision milky then eyes rot.\nWhen you turn they will be gone,\nWhispering their hidden song.\nThen you see what cannot be,\nShadows move where light should be.\nOut of darkness, out of mind,\nCast down into the Halls of the Blind. |\n", + 1, 5, PS_WARR11 }, + { "The armories of Hell are home to the Warlord of Blood. In his wake lay the mutilated bodies of thousands. Angels and man alike have been cut down to fulfill his endless sacrifices to the Dark ones who scream for one thing - blood. |", + 1, 5, PS_WARR12 }, + { "Beyond the Hall of Heroes lies the Chamber of Bone. Eternal death awaits any who would seek to steal the treasures secured within this room. So speaks the Lord of Terror, and so it is written. |", + 1, 5, PS_MAGE1 }, + { "...and so, locked beyond the Gateway of Blood and past the Hall of Fire, Valor awaits for the Hero of Light to awaken... |", + 1, 6, PS_MAGE10 }, + { "I can see what you see not.\nVision milky then eyes rot.\nWhen you turn they will be gone,\nWhispering their hidden song.\nThen you see what cannot be,\nShadows move where light should be.\nOut of darkness, out of mind,\nCast down into the Halls of the Blind. |\n", + 1, 4, PS_MAGE11 }, + { "The armories of Hell are home to the Warlord of Blood. In his wake lay the mutilated bodies of thousands. Angels and man alike have been cut down to fulfill his endless sacrifices to the Dark ones who scream for one thing - blood. |", + 1, 5, PS_MAGE12 }, + { "Beyond the Hall of Heroes lies the Chamber of Bone. Eternal death awaits any who would seek to steal the treasures secured within this room. So speaks the Lord of Terror, and so it is written. |", + 1, 5, PS_ROGUE1 }, + { "...and so, locked beyond the Gateway of Blood and past the Hall of Fire, Valor awaits for the Hero of Light to awaken... |", + 1, 5, PS_ROGUE10 }, + { "I can see what you see not.\nVision milky then eyes rot.\nWhen you turn they will be gone,\nWhispering their hidden song.\nThen you see what cannot be,\nShadows move where light should be.\nOut of darkness, out of mind,\nCast down into the Halls of the Blind. |\n", + 1, 5, PS_ROGUE11 }, + { "The armories of Hell are home to the Warlord of Blood. In his wake lay the mutilated bodies of thousands. Angels and man alike have been cut down to fulfill his endless sacrifices to the Dark ones who scream for one thing - blood. |", + 1, 5, PS_ROGUE12 }, + { " |", 0, 5, TSFX_COW1 }, + { " |", 0, 5, TSFX_COW2 }, + { "Take heed and bear witness to the truths that lie herein, for they are the last legacy of the Horadrim. There is a war that rages on even now, beyond the fields that we know - between the utopian kingdoms of the High Heavens and the chaotic pits of the Burning Hells. This war is known as the Great Conflict, and it has raged and burned longer than any of the stars in the sky. Neither side ever gains sway for long as the forces of Light and Darkness constantly vie for control over all creation. |", + 1, 5, PS_NAR1 }, + { "Take heed and bear witness to the truths that lie herein, for they are the last legacy of the Horadrim. When the Eternal Conflict between the High Heavens and the Burning Hells falls upon mortal soil, it is called the Sin War. Angels and Demons walk amongst humanity in disguise, fighting in secret, away from the prying eyes of mortals. Some daring, powerful mortals have even allied themselves with either side, and helped to dictate the course of the Sin War. |", + 1, 4, PS_NAR2 }, + { "Take heed and bear witness to the truths that lie herein, for they are the last legacy of the Horadrim. Nearly three hundred years ago, it came to be known that the Three Prime Evils of the Burning Hells had mysteriously come to our world. The Three Brothers ravaged the lands of the east for decades, while humanity was left trembling in their wake. Our Order - the Horadrim - was founded by a group of secretive magi to hunt down and capture the Three Evils once and for all.\n \nThe original Horadrim captured two of the Three within powerful artifacts known as Soulstones and buried them deep beneath the desolate eastern sands. The third Evil escaped capture and fled to the west with many of the Horadrim in pursuit. The Third Evil - known as Diablo, the Lord of Terror - was eventually captured, his essence set in a Soulstone and buried within this Labyrinth.\n \nBe warned that the soulstone must be kept from discovery by those not of the faith. If Diablo were to be released, he would seek a body that is easily controlled as he would be very weak - perhaps that of an old man or a child. |", + 1, 3, PS_NAR3 }, + { "So it came to be that there was a great revolution within the Burning Hells known as The Dark Exile. The Lesser Evils overthrew the Three Prime Evils and banished their spirit forms to the mortal realm. The demons Belial (the Lord of Lies) and Azmodan (the Lord of Sin) fought to claim rulership of Hell during the absence of the Three Brothers. All of Hell polarized between the factions of Belial and Azmodan while the forces of the High Heavens continually battered upon the very Gates of Hell. |", + 1, 4, PS_NAR4 }, + { "Many demons traveled to the mortal realm in search of the Three Brothers. These demons were followed to the mortal plane by Angels who hunted them throughout the vast cities of the East. The Angels allied themselves with a secretive Order of mortal magi named the Horadrim, who quickly became adept at hunting demons. They also made many dark enemies in the underworlds. |", + 1, 5, PS_NAR5 }, + { "So it came to be that the Three Prime Evils were banished in spirit form to the mortal realm and after sewing chaos across the East for decades, they were hunted down by the cursed Order of the mortal Horadrim. The Horadrim used artifacts called Soulstones to contain the essence of Mephisto, the Lord of Hatred and his brother Baal, the Lord of Destruction. The youngest brother - Diablo, the Lord of Terror - escaped to the west.\n \nEventually the Horadrim captured Diablo within a Soulstone as well, and buried him under an ancient, forgotten Cathedral. There, the Lord of Terror sleeps and awaits the time of his rebirth. Know ye that he will seek a body of youth and power to possess - one that is innocent and easily controlled. He will then arise to free his Brothers and once more fan the flames of the Sin War... |", + 1, 3, PS_NAR6 }, + { "All praises to Diablo - Lord of Terror and Survivor of The Dark Exile. When he awakened from his long slumber, my Lord and Master spoke to me of secrets that few mortals know. He told me the kingdoms of the High Heavens and the pits of the Burning Hells engage in an eternal war. He revealed the powers that have brought this discord to the realms of man. My lord has named the battle for this world and all who exist here the Sin War. |", + 1, 4, PS_NAR7 }, + { "Glory and Approbation to Diablo - Lord of Terror and Leader of the Three. My Lord spoke to me of his two Brothers, Mephisto and Baal, who were banished to this world long ago. My Lord wishes to bide his time and harness his awesome power so that he may free his captive brothers from their tombs beneath the sands of the east. Once my Lord releases his Brothers, the Sin War will once again know the fury of the Three. |", + 1, 4, PS_NAR8 }, + { "Hail and Sacrifice to Diablo - Lord of Terror and Destroyer of Souls. When I awoke my Master from his sleep, he attempted to possess a mortal's form. Diablo attempted to claim the body of King Leoric, but my Master was too weak from his imprisonment. My Lord required a simple and innocent anchor to this world, and so found the boy Albrecht to be perfect for the task. While the good King Leoric was left maddened by Diablo's unsuccessful possession, I kidnapped his son Albrecht and brought him before my Master. I now await Diablo's call and pray that I will be rewarded when he at last emerges as the Lord of this world. |", + 1, 3, PS_NAR9 }, + { "Thank goodness you've returned!\nMuch has changed since you lived here, my friend. All was peaceful until the dark riders came and destroyed our village. Many were cut down where they stood, and those who took up arms were slain or dragged away to become slaves - or worse. The church at the edge of town has been desecrated and is being used for dark rituals. The screams that echo in the night are inhuman, but some of our townsfolk may yet survive. Follow the path that lies between my tavern and the blacksmith shop to find the church and save who you can. \n \nPerhaps I can tell you more if we speak again. Good luck.|", + 1, 5, TSFX_TAVERN0 } }; const int gdwAllTextEntries = 259; /* unused */ diff --git a/Source/themes.cpp b/Source/themes.cpp index da4ce7d0..ca2098d8 100644 --- a/Source/themes.cpp +++ b/Source/themes.cpp @@ -22,308 +22,308 @@ bool bCrossFlag; // weak int ThemeGood[4] = { THEME_GOATSHRINE, THEME_SHRINE, THEME_SKELROOM, THEME_LIBRARY }; int trm5x[25] = { - -2, -1, 0, 1, 2, - -2, -1, 0, 1, 2, - -2, -1, 0, 1, 2, - -2, -1, 0, 1, 2, - -2, -1, 0, 1, 2 + -2, -1, 0, 1, 2, + -2, -1, 0, 1, 2, + -2, -1, 0, 1, 2, + -2, -1, 0, 1, 2, + -2, -1, 0, 1, 2 }; int trm5y[25] = { - -2, -2, -2, -2, -2, - -1, -1, -1, -1, -1, - 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, - 2, 2, 2, 2, 2 + -2, -2, -2, -2, -2, + -1, -1, -1, -1, -1, + 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, + 2, 2, 2, 2, 2 }; int trm3x[9] = { - -1, 0, 1, - -1, 0, 1, - -1, 0, 1 + -1, 0, 1, + -1, 0, 1, + -1, 0, 1 }; int trm3y[9] = { - -1, -1, -1, - 0, 0, 0, - 1, 1, 1 + -1, -1, -1, + 0, 0, 0, + 1, 1, 1 }; bool __fastcall TFit_Shrine(int i) { - int v1; // ecx - int v2; // esi - int v3; // eax - int v4; // edx - signed int v6; // [esp+Ch] [ebp-8h] - int v7; // [esp+10h] [ebp-4h] + int v1; // ecx + int v2; // esi + int v3; // eax + int v4; // edx + signed int v6; // [esp+Ch] [ebp-8h] + int v7; // [esp+10h] [ebp-4h] - v1 = themes[i].ttval; - v7 = 0; - v2 = 0; - v6 = 0; - while (1) { - v3 = v2 + 112 * v7; - if (dung_map[0][v3] != v1) /* check */ - goto LABEL_20; - v4 = dPiece[0][v3 - 1]; // *(_DWORD *)&dflags[39][4 * v3 + 36]; - if (nTrapTable[v4] - && !nSolidTable[dPiece[-1][v3]] // !nSolidTable[*(_DWORD *)&dflags[28][4 * v3 + 32]] - && !nSolidTable[dPiece[1][v3]] - && dung_map[-1][v3] == v1 // block_lvid[v3 + 1940] == v1 - && dung_map[1][v3] == v1 - && !dObject[-1][v3 - 1] - && !dObject[0][v3 + 111]) { - v6 = 1; - } - if (v6) - break; - if (!nTrapTable[dPiece[-1][v3]] // !nTrapTable[*(_DWORD *)&dflags[28][4 * v3 + 32]] - || nSolidTable[v4] - || nSolidTable[dPiece[0][v3 + 1]] - || dung_map[0][v3 - 1] != v1 // *(&byte_5B78EB + v3) != v1 - || dung_map[0][v3 + 1] != v1 - || dObject[-1][v3 - 1] - || dObject[-1][v3 + 1]) /* check */ - { - goto LABEL_21; - } - v6 = 2; - LABEL_20: - if (v6) - break; - LABEL_21: - if (++v7 == 112) { - ++v2; - v7 = 0; - if (v2 == 112) - return 0; - } - } - themey = v2; - themex = v7; - themeVar1 = v6; - return 1; + v1 = themes[i].ttval; + v7 = 0; + v2 = 0; + v6 = 0; + while (1) { + v3 = v2 + 112 * v7; + if (dung_map[0][v3] != v1) /* check */ + goto LABEL_20; + v4 = dPiece[0][v3 - 1]; // *(_DWORD *)&dflags[39][4 * v3 + 36]; + if (nTrapTable[v4] + && !nSolidTable[dPiece[-1][v3]] // !nSolidTable[*(_DWORD *)&dflags[28][4 * v3 + 32]] + && !nSolidTable[dPiece[1][v3]] + && dung_map[-1][v3] == v1 // block_lvid[v3 + 1940] == v1 + && dung_map[1][v3] == v1 + && !dObject[-1][v3 - 1] + && !dObject[0][v3 + 111]) { + v6 = 1; + } + if (v6) + break; + if (!nTrapTable[dPiece[-1][v3]] // !nTrapTable[*(_DWORD *)&dflags[28][4 * v3 + 32]] + || nSolidTable[v4] + || nSolidTable[dPiece[0][v3 + 1]] + || dung_map[0][v3 - 1] != v1 // *(&byte_5B78EB + v3) != v1 + || dung_map[0][v3 + 1] != v1 + || dObject[-1][v3 - 1] + || dObject[-1][v3 + 1]) /* check */ + { + goto LABEL_21; + } + v6 = 2; + LABEL_20: + if (v6) + break; + LABEL_21: + if (++v7 == 112) { + ++v2; + v7 = 0; + if (v2 == 112) + return 0; + } + } + themey = v2; + themex = v7; + themeVar1 = v6; + return 1; } bool __fastcall TFit_Obj5(int t) { - int v2; // ebx - int v3; // esi - int v4; // eax - int v5; // edi - int v6; // ecx - signed int v7; // edx - int v8; // ecx - int v10; // [esp+Ch] [ebp-Ch] - int v11; // [esp+10h] [ebp-8h] - signed int v12; // [esp+14h] [ebp-4h] + int v2; // ebx + int v3; // esi + int v4; // eax + int v5; // edi + int v6; // ecx + signed int v7; // edx + int v8; // ecx + int v10; // [esp+Ch] [ebp-Ch] + int v11; // [esp+10h] [ebp-8h] + signed int v12; // [esp+14h] [ebp-4h] - v2 = 0; - v3 = 0; - v4 = random(0, 5) + 1; - v10 = v4; - if (v4 <= 0) { - LABEL_19: - themex = v2; - themey = v3; - return 1; - } - v5 = themes[t].ttval; - v11 = v5; - while (1) { - v6 = v3 + 112 * v2; - if (dung_map[0][v6] == v5 && !nSolidTable[dPiece[0][v6]]) { - v12 = 1; - v7 = 0; - do { - if (v7 >= 25) - break; - v8 = v3 + trm5y[v7] + 112 * (v2 + trm5x[v7]); - if (nSolidTable[dPiece[0][v8]]) - v12 = 0; - v5 = v11; - if (dung_map[0][v8] != v11) - v12 = 0; - ++v7; - } while (v12); - if (v12) { - --v4; - goto LABEL_18; - } - } - if (++v2 != 112) - goto LABEL_18; - v2 = 0; - if (++v3 != 112) - goto LABEL_18; - if (v4 == v10) - return 0; - v3 = 0; - LABEL_18: - if (v4 <= 0) - goto LABEL_19; - } + v2 = 0; + v3 = 0; + v4 = random(0, 5) + 1; + v10 = v4; + if (v4 <= 0) { + LABEL_19: + themex = v2; + themey = v3; + return 1; + } + v5 = themes[t].ttval; + v11 = v5; + while (1) { + v6 = v3 + 112 * v2; + if (dung_map[0][v6] == v5 && !nSolidTable[dPiece[0][v6]]) { + v12 = 1; + v7 = 0; + do { + if (v7 >= 25) + break; + v8 = v3 + trm5y[v7] + 112 * (v2 + trm5x[v7]); + if (nSolidTable[dPiece[0][v8]]) + v12 = 0; + v5 = v11; + if (dung_map[0][v8] != v11) + v12 = 0; + ++v7; + } while (v12); + if (v12) { + --v4; + goto LABEL_18; + } + } + if (++v2 != 112) + goto LABEL_18; + v2 = 0; + if (++v3 != 112) + goto LABEL_18; + if (v4 == v10) + return 0; + v3 = 0; + LABEL_18: + if (v4 <= 0) + goto LABEL_19; + } } bool __fastcall TFit_SkelRoom(int t) { - int i; // esi + int i; // esi - if (leveltype != 1 && leveltype != 2) - return 0; - i = 0; - if (nummtypes <= 0) - return 0; + if (leveltype != 1 && leveltype != 2) + return 0; + i = 0; + if (nummtypes <= 0) + return 0; - while (!IsSkel(Monsters[i].mtype)) { - ++i; - if (i >= nummtypes) - return 0; - } - themeVar1 = i; - return TFit_Obj5(t); + while (!IsSkel(Monsters[i].mtype)) { + ++i; + if (i >= nummtypes) + return 0; + } + themeVar1 = i; + return TFit_Obj5(t); } bool __fastcall TFit_GoatShrine(int t) { - int i; // esi + int i; // esi - i = 0; - if (nummtypes <= 0) - return 0; + i = 0; + if (nummtypes <= 0) + return 0; - while (!IsGoat(Monsters[i].mtype)) { - ++i; - if (i >= nummtypes) - return 0; - } - themeVar1 = i; - return TFit_Obj5(t); + while (!IsGoat(Monsters[i].mtype)) { + ++i; + if (i >= nummtypes) + return 0; + } + themeVar1 = i; + return TFit_Obj5(t); } bool __fastcall CheckThemeObj3(int xp, int yp, int t, int f) { - int i; // edi + int i; // edi - i = 0; - while (1) { - if (xp + trm3x[i] < 0) - break; - if (yp + trm3y[i] < 0) - break; - if (nSolidTable[dPiece[xp + trm3x[i]][yp + trm3y[i]]]) - break; - if (dung_map[xp + trm3x[i]][yp + trm3y[i]] != themes[t].ttval) - break; - if (dObject[xp + trm3x[i]][yp + trm3y[i]]) - break; - if (f != -1) { - if (!random(0, f)) - break; - } - ++i; - if (i >= 9) - return 1; - } - return 0; + i = 0; + while (1) { + if (xp + trm3x[i] < 0) + break; + if (yp + trm3y[i] < 0) + break; + if (nSolidTable[dPiece[xp + trm3x[i]][yp + trm3y[i]]]) + break; + if (dung_map[xp + trm3x[i]][yp + trm3y[i]] != themes[t].ttval) + break; + if (dObject[xp + trm3x[i]][yp + trm3y[i]]) + break; + if (f != -1) { + if (!random(0, f)) + break; + } + ++i; + if (i >= 9) + return 1; + } + return 0; } bool __fastcall TFit_Obj3(int t) { - int yp; // edi - int xp; // esi - char objrnd[4]; // [esp+Bh] [ebp-5h] + int yp; // edi + int xp; // esi + char objrnd[4]; // [esp+Bh] [ebp-5h] - objrnd[0] = 4; - objrnd[1] = 4; - objrnd[2] = 3; - objrnd[3] = 5; - yp = 1; - while (2) { - xp = 1; - do { - if (CheckThemeObj3(xp, yp, t, objrnd[leveltype - 1])) { - themex = xp; - themey = yp; - return 1; - } - ++xp; - } while (xp < 111); - if (++yp < 111) - continue; - break; - } - return 0; + objrnd[0] = 4; + objrnd[1] = 4; + objrnd[2] = 3; + objrnd[3] = 5; + yp = 1; + while (2) { + xp = 1; + do { + if (CheckThemeObj3(xp, yp, t, objrnd[leveltype - 1])) { + themex = xp; + themey = yp; + return 1; + } + ++xp; + } while (xp < 111); + if (++yp < 111) + continue; + break; + } + return 0; } bool __fastcall CheckThemeReqs(int t) { - bool rv; // al - int v2; // ecx - int v3; // ecx - int v4; // ecx - int v5; // ecx - bool v6; // zf - int v7; // ecx - int v8; // ecx - int v9; // ecx + bool rv; // al + int v2; // ecx + int v3; // ecx + int v4; // ecx + int v5; // ecx + bool v6; // zf + int v7; // ecx + int v8; // ecx + int v9; // ecx - rv = 1; - if (t <= 10) { - if (t != 10) { - v2 = t - 1; - if (v2) { - v3 = v2 - 2; - if (v3) { - v4 = v3 - 2; - if (v4) { - v5 = v4 - 2; - if (v5) { - if (v5 != 2) - return rv; - v6 = pFountainFlag == 0; - } else { - v6 = bFountainFlag == 0; - } - LABEL_21: - if (!v6) - return rv; - return 0; - } - } - } - if (leveltype != 3) { - v6 = leveltype == DTYPE_HELL; - goto LABEL_21; - } - return 0; - } - LABEL_16: - v6 = leveltype == DTYPE_CATHEDRAL; - goto LABEL_21; - } - v7 = t - 12; - if (v7) { - v8 = v7 - 1; - if (!v8) { - v6 = mFountainFlag == 0; - goto LABEL_21; - } - v9 = v8 - 1; - if (!v9) { - v6 = tFountainFlag == 0; - goto LABEL_21; - } - if (v9 != 2) - return rv; - goto LABEL_16; - } - if (leveltype == DTYPE_HELL) { - v6 = cauldronFlag == 0; - goto LABEL_21; - } - return 0; + rv = 1; + if (t <= 10) { + if (t != 10) { + v2 = t - 1; + if (v2) { + v3 = v2 - 2; + if (v3) { + v4 = v3 - 2; + if (v4) { + v5 = v4 - 2; + if (v5) { + if (v5 != 2) + return rv; + v6 = pFountainFlag == 0; + } else { + v6 = bFountainFlag == 0; + } + LABEL_21: + if (!v6) + return rv; + return 0; + } + } + } + if (leveltype != 3) { + v6 = leveltype == DTYPE_HELL; + goto LABEL_21; + } + return 0; + } + LABEL_16: + v6 = leveltype == DTYPE_CATHEDRAL; + goto LABEL_21; + } + v7 = t - 12; + if (v7) { + v8 = v7 - 1; + if (!v8) { + v6 = mFountainFlag == 0; + goto LABEL_21; + } + v9 = v8 - 1; + if (!v9) { + v6 = tFountainFlag == 0; + goto LABEL_21; + } + if (v9 != 2) + return rv; + goto LABEL_16; + } + if (leveltype == DTYPE_HELL) { + v6 = cauldronFlag == 0; + goto LABEL_21; + } + return 0; } // 6AAA58: using guessed type int mFountainFlag; // 6AAA5C: using guessed type int cauldronFlag; @@ -333,75 +333,75 @@ bool __fastcall CheckThemeReqs(int t) bool __fastcall SpecialThemeFit(int i, int t) { - bool rv; // eax + bool rv; // eax - rv = CheckThemeReqs(t); - switch (t) { - case THEME_SHRINE: - case THEME_LIBRARY: - if (rv) - rv = TFit_Shrine(i); - break; - case THEME_SKELROOM: - if (rv) - rv = TFit_SkelRoom(i); - break; - case THEME_TREASURE: - rv = treasureFlag; - if (treasureFlag) - treasureFlag = 0; - break; - case THEME_TORTURE: - case THEME_DECAPITATED: - case THEME_ARMORSTAND: - case THEME_BRNCROSS: - case THEME_WEAPONRACK: - if (rv) - rv = TFit_Obj3(i); - break; - case THEME_BLOODFOUNTAIN: - if (rv) { - rv = TFit_Obj5(i); - if (rv) - bFountainFlag = 0; - } - break; - case THEME_PURIFYINGFOUNTAIN: - if (rv) { - rv = TFit_Obj5(i); - if (rv) - pFountainFlag = 0; - } - break; - case THEME_GOATSHRINE: - if (rv) - rv = TFit_GoatShrine(i); - break; - case THEME_CAULDRON: - if (rv) { - rv = TFit_Obj5(i); - if (rv) - cauldronFlag = 0; - } - break; - case THEME_MURKYFOUNTAIN: - if (rv) { - rv = TFit_Obj5(i); - if (rv) - mFountainFlag = 0; - } - break; - case THEME_TEARFOUNTAIN: - if (rv) { - rv = TFit_Obj5(i); - if (rv) - tFountainFlag = 0; - } - break; - default: - return rv; - } - return rv; + rv = CheckThemeReqs(t); + switch (t) { + case THEME_SHRINE: + case THEME_LIBRARY: + if (rv) + rv = TFit_Shrine(i); + break; + case THEME_SKELROOM: + if (rv) + rv = TFit_SkelRoom(i); + break; + case THEME_TREASURE: + rv = treasureFlag; + if (treasureFlag) + treasureFlag = 0; + break; + case THEME_TORTURE: + case THEME_DECAPITATED: + case THEME_ARMORSTAND: + case THEME_BRNCROSS: + case THEME_WEAPONRACK: + if (rv) + rv = TFit_Obj3(i); + break; + case THEME_BLOODFOUNTAIN: + if (rv) { + rv = TFit_Obj5(i); + if (rv) + bFountainFlag = 0; + } + break; + case THEME_PURIFYINGFOUNTAIN: + if (rv) { + rv = TFit_Obj5(i); + if (rv) + pFountainFlag = 0; + } + break; + case THEME_GOATSHRINE: + if (rv) + rv = TFit_GoatShrine(i); + break; + case THEME_CAULDRON: + if (rv) { + rv = TFit_Obj5(i); + if (rv) + cauldronFlag = 0; + } + break; + case THEME_MURKYFOUNTAIN: + if (rv) { + rv = TFit_Obj5(i); + if (rv) + mFountainFlag = 0; + } + break; + case THEME_TEARFOUNTAIN: + if (rv) { + rv = TFit_Obj5(i); + if (rv) + tFountainFlag = 0; + } + break; + default: + return rv; + } + return rv; } // 6AAA54: using guessed type int treasureFlag; // 6AAA58: using guessed type int mFountainFlag; @@ -412,177 +412,177 @@ bool __fastcall SpecialThemeFit(int i, int t) bool __fastcall CheckThemeRoom(int tv) { - int v1; // esi - int *v2; // edx - signed int v3; // edi - signed int v4; // esi - signed int v5; // edx - signed int v6; // eax - int v7; // edi - int *v8; // esi - char *v9; // eax - int *v10; // edx - signed int v12; // [esp+Ch] [ebp-8h] + int v1; // esi + int *v2; // edx + signed int v3; // edi + signed int v4; // esi + signed int v5; // edx + signed int v6; // eax + int v7; // edi + int *v8; // esi + char *v9; // eax + int *v10; // edx + signed int v12; // [esp+Ch] [ebp-8h] - v1 = 0; - if (trigflag[4] <= 0) { - LABEL_5: - v3 = 0; - v4 = 0; - do { - v5 = 0; - v6 = v4; - do { - if (dung_map[0][v6] == tv) { - if (dFlags[0][v6] & DFLAG_POPULATED) - return 0; - ++v3; - } - ++v5; - v6 += 112; - } while (v5 < 112); - ++v4; - } while (v4 < 112); - if (leveltype != 1 || v3 >= 9 && v3 <= 100) { - v7 = 0; - v8 = &dPiece[-1][111]; - LABEL_16: - v12 = 0; - v9 = &dung_map[-1][v7 + 111]; - v10 = v8; - while (v9[1] != tv - || nSolidTable[v10[1]] - || (*(v9 - 111) == tv || nSolidTable[*(v10 - 111)]) /* check */ - && (v9[113] == tv || nSolidTable[v10[113]]) - && (*v9 == tv || nSolidTable[*v10]) - && (v9[2] == tv || nSolidTable[v10[2]])) { - ++v12; - v10 += 112; - v9 += 112; - if (v12 >= 112) { - ++v8; - ++v7; - if ((signed int)v8 < (signed int)&dPiece[0][111]) - goto LABEL_16; - return 1; - } - } - } - } else { - v2 = &trigs[0]._ty; - while (dung_map[*(v2 - 1)][*v2] != tv) { - ++v1; - v2 += 4; - if (v1 >= trigflag[4]) - goto LABEL_5; - } - } - return 0; + v1 = 0; + if (trigflag[4] <= 0) { + LABEL_5: + v3 = 0; + v4 = 0; + do { + v5 = 0; + v6 = v4; + do { + if (dung_map[0][v6] == tv) { + if (dFlags[0][v6] & DFLAG_POPULATED) + return 0; + ++v3; + } + ++v5; + v6 += 112; + } while (v5 < 112); + ++v4; + } while (v4 < 112); + if (leveltype != 1 || v3 >= 9 && v3 <= 100) { + v7 = 0; + v8 = &dPiece[-1][111]; + LABEL_16: + v12 = 0; + v9 = &dung_map[-1][v7 + 111]; + v10 = v8; + while (v9[1] != tv + || nSolidTable[v10[1]] + || (*(v9 - 111) == tv || nSolidTable[*(v10 - 111)]) /* check */ + && (v9[113] == tv || nSolidTable[v10[113]]) + && (*v9 == tv || nSolidTable[*v10]) + && (v9[2] == tv || nSolidTable[v10[2]])) { + ++v12; + v10 += 112; + v9 += 112; + if (v12 >= 112) { + ++v8; + ++v7; + if ((signed int)v8 < (signed int)&dPiece[0][111]) + goto LABEL_16; + return 1; + } + } + } + } else { + v2 = &trigs[0]._ty; + while (dung_map[*(v2 - 1)][*v2] != tv) { + ++v1; + v2 += 4; + if (v1 >= trigflag[4]) + goto LABEL_5; + } + } + return 0; } void __cdecl InitThemes() { - int v0; // esi - char v1; // bl - int v2; // edi - //int v3; // eax - int i; // ebx - //int v6; // eax - int v8; // esi - int v9; // ecx - int j; // eax - //int v11; // eax - int *v13; // edi - int v14; // esi - int *v15; // ebx - //int v16; // eax - int v17; // eax - int k; // esi - int l; // ebx - //int v20; // eax + int v0; // esi + char v1; // bl + int v2; // edi + //int v3; // eax + int i; // ebx + //int v6; // eax + int v8; // esi + int v9; // ecx + int j; // eax + //int v11; // eax + int *v13; // edi + int v14; // esi + int *v15; // ebx + //int v16; // eax + int v17; // eax + int k; // esi + int l; // ebx + //int v20; // eax - zharlib = -1; - v0 = 0; - bCrossFlag = 0; - numthemes = 0; - armorFlag = 1; - bFountainFlag = 1; - cauldronFlag = 1; - mFountainFlag = 1; - pFountainFlag = 1; - tFountainFlag = 1; - treasureFlag = 1; - weaponFlag = 1; - if (currlevel != 16) { - v1 = leveltype; - if (leveltype == DTYPE_CATHEDRAL) { - ThemeGoodIn[0] = 0; - ThemeGoodIn[1] = 0; - ThemeGoodIn[2] = 0; - ThemeGoodIn[3] = 0; - v2 = 0; - do { - if (v0 >= MAXTHEMES) - break; - //_LOBYTE(v3) = CheckThemeRoom(v2); - if (CheckThemeRoom(v2)) { - themes[v0].ttval = v2; - for (i = ThemeGood[random(0, 4)];; i = random(0, 17)) { - //_LOBYTE(v6) = SpecialThemeFit(numthemes, i); - if (SpecialThemeFit(numthemes, i)) - break; - } - v8 = numthemes; - themes[numthemes].ttype = i; - v1 = leveltype; - v0 = v8 + 1; - numthemes = v0; - } - ++v2; - } while (v2 < 256); - } - if (v1 == 2 || v1 == 3 || v1 == 4) { - v9 = themeCount; - for (j = 0; j < v9; ++j) - themes[j].ttype = -1; - //_LOBYTE(v11) = QuestStatus(QTYPE_ZHAR); - v13 = &themeLoc[0].ttval; - if (QuestStatus(QTYPE_ZHAR)) { - v14 = 0; - if (themeCount > 0) { - v15 = &themeLoc[0].ttval; - while (1) { - themes[v14].ttval = *v15; - //_LOBYTE(v16) = SpecialThemeFit(v14, 5); - if (SpecialThemeFit(v14, 5)) - break; - ++v14; - v15 += 5; - if (v14 >= themeCount) - goto LABEL_23; - } - themes[v14].ttype = 5; - zharlib = v14; - } - } - LABEL_23: - v17 = themeCount; - for (k = 0; k < themeCount; v13 += 5) { - if (themes[k].ttype == -1) { - themes[k].ttval = *v13; - for (l = ThemeGood[random(0, 4)];; l = random(0, 17)) { - //_LOBYTE(v20) = SpecialThemeFit(k, l); - if (SpecialThemeFit(k, l)) - break; - } - themes[k].ttype = l; - } - v17 = themeCount; - ++k; - } - numthemes += v17; - } - } + zharlib = -1; + v0 = 0; + bCrossFlag = 0; + numthemes = 0; + armorFlag = 1; + bFountainFlag = 1; + cauldronFlag = 1; + mFountainFlag = 1; + pFountainFlag = 1; + tFountainFlag = 1; + treasureFlag = 1; + weaponFlag = 1; + if (currlevel != 16) { + v1 = leveltype; + if (leveltype == DTYPE_CATHEDRAL) { + ThemeGoodIn[0] = 0; + ThemeGoodIn[1] = 0; + ThemeGoodIn[2] = 0; + ThemeGoodIn[3] = 0; + v2 = 0; + do { + if (v0 >= MAXTHEMES) + break; + //_LOBYTE(v3) = CheckThemeRoom(v2); + if (CheckThemeRoom(v2)) { + themes[v0].ttval = v2; + for (i = ThemeGood[random(0, 4)];; i = random(0, 17)) { + //_LOBYTE(v6) = SpecialThemeFit(numthemes, i); + if (SpecialThemeFit(numthemes, i)) + break; + } + v8 = numthemes; + themes[numthemes].ttype = i; + v1 = leveltype; + v0 = v8 + 1; + numthemes = v0; + } + ++v2; + } while (v2 < 256); + } + if (v1 == 2 || v1 == 3 || v1 == 4) { + v9 = themeCount; + for (j = 0; j < v9; ++j) + themes[j].ttype = -1; + //_LOBYTE(v11) = QuestStatus(QTYPE_ZHAR); + v13 = &themeLoc[0].ttval; + if (QuestStatus(QTYPE_ZHAR)) { + v14 = 0; + if (themeCount > 0) { + v15 = &themeLoc[0].ttval; + while (1) { + themes[v14].ttval = *v15; + //_LOBYTE(v16) = SpecialThemeFit(v14, 5); + if (SpecialThemeFit(v14, 5)) + break; + ++v14; + v15 += 5; + if (v14 >= themeCount) + goto LABEL_23; + } + themes[v14].ttype = 5; + zharlib = v14; + } + } + LABEL_23: + v17 = themeCount; + for (k = 0; k < themeCount; v13 += 5) { + if (themes[k].ttype == -1) { + themes[k].ttval = *v13; + for (l = ThemeGood[random(0, 4)];; l = random(0, 17)) { + //_LOBYTE(v20) = SpecialThemeFit(k, l); + if (SpecialThemeFit(k, l)) + break; + } + themes[k].ttype = l; + } + v17 = themeCount; + ++k; + } + numthemes += v17; + } + } } // 6AAA3C: using guessed type int armorFlag; // 6AAA50: using guessed type int weaponFlag; @@ -597,733 +597,733 @@ void __cdecl InitThemes() void __cdecl HoldThemeRooms() { - int v0; // ebx - int i; // esi - char v2; // dl - signed int v3; // ecx - signed int v4; // eax - signed int v5; // edi + int v0; // ebx + int i; // esi + char v2; // dl + signed int v3; // ecx + signed int v4; // eax + signed int v5; // edi - if (currlevel != 16) { - if (leveltype == DTYPE_CATHEDRAL) { - v0 = numthemes; - for (i = 0; i < v0; ++i) { - v2 = themes[i].ttval; - v3 = 0; - do { - v4 = v3; - v5 = 112; - do { - if (dung_map[0][v4] == v2) - dFlags[0][v4] |= DFLAG_POPULATED; - v4 += 112; - --v5; - } while (v5); - ++v3; - } while (v3 < 112); - } - } else { - DRLG_HoldThemeRooms(); - } - } + if (currlevel != 16) { + if (leveltype == DTYPE_CATHEDRAL) { + v0 = numthemes; + for (i = 0; i < v0; ++i) { + v2 = themes[i].ttval; + v3 = 0; + do { + v4 = v3; + v5 = 112; + do { + if (dung_map[0][v4] == v2) + dFlags[0][v4] |= DFLAG_POPULATED; + v4 += 112; + --v5; + } while (v5); + ++v3; + } while (v3 < 112); + } + } else { + DRLG_HoldThemeRooms(); + } + } } void __fastcall PlaceThemeMonsts(int t, int f) { - int numscattypes; // edx - int i; // ecx - int yp; // ebx - int xp; // edi - int scattertypes[111]; // [esp+Ch] [ebp-1D0h] - int mtype; // [esp+1CCh] [ebp-10h] + int numscattypes; // edx + int i; // ecx + int yp; // ebx + int xp; // edi + int scattertypes[111]; // [esp+Ch] [ebp-1D0h] + int mtype; // [esp+1CCh] [ebp-10h] - numscattypes = 0; + numscattypes = 0; - if (nummtypes > 0) { - for (i = 0; i < nummtypes; i++) { - if (Monsters[i].mPlaceFlags & 1) - scattertypes[numscattypes++] = i; - } - } + if (nummtypes > 0) { + for (i = 0; i < nummtypes; i++) { + if (Monsters[i].mPlaceFlags & 1) + scattertypes[numscattypes++] = i; + } + } - mtype = scattertypes[random(0, numscattypes)]; + mtype = scattertypes[random(0, numscattypes)]; - for (yp = 0; yp < 112; yp++) { - for (xp = 0; xp < 112; xp++) { - if (dung_map[xp][yp] == themes[t].ttval && !nSolidTable[dPiece[xp][yp]] && !dItem[xp][yp] && !dObject[xp][yp]) { - if (!random(0, f)) - AddMonster(xp, yp, random(0, 8), mtype, 1); - } - } - } + for (yp = 0; yp < 112; yp++) { + for (xp = 0; xp < 112; xp++) { + if (dung_map[xp][yp] == themes[t].ttval && !nSolidTable[dPiece[xp][yp]] && !dItem[xp][yp] && !dObject[xp][yp]) { + if (!random(0, f)) + AddMonster(xp, yp, random(0, 8), mtype, 1); + } + } + } } // 45D0E1: using guessed type int var_1D0[111]; void __fastcall Theme_Barrel(int t) { - int yp; // edi - int xp; // ebx - int r; - char monstrnd[4]; - char barrnd[4]; + int yp; // edi + int xp; // ebx + int r; + char monstrnd[4]; + char barrnd[4]; - barrnd[0] = 2; - barrnd[1] = 6; - barrnd[2] = 4; - barrnd[3] = 8; - monstrnd[0] = 5; - monstrnd[1] = 7; - monstrnd[2] = 3; - monstrnd[3] = 9; + barrnd[0] = 2; + barrnd[1] = 6; + barrnd[2] = 4; + barrnd[3] = 8; + monstrnd[0] = 5; + monstrnd[1] = 7; + monstrnd[2] = 3; + monstrnd[3] = 9; - for (yp = 0; yp < 112; yp++) { - for (xp = 0; xp < 112; xp++) { - if (dung_map[xp][yp] == themes[t].ttval && !nSolidTable[dPiece[xp][yp]]) { - if (!random(0, barrnd[leveltype - 1])) { - r = random(0, barrnd[leveltype - 1]); - AddObject((r != 0) + OBJ_BARREL, xp, yp); - } - } - } - } + for (yp = 0; yp < 112; yp++) { + for (xp = 0; xp < 112; xp++) { + if (dung_map[xp][yp] == themes[t].ttval && !nSolidTable[dPiece[xp][yp]]) { + if (!random(0, barrnd[leveltype - 1])) { + r = random(0, barrnd[leveltype - 1]); + AddObject((r != 0) + OBJ_BARREL, xp, yp); + } + } + } + } - PlaceThemeMonsts(t, monstrnd[leveltype - 1]); + PlaceThemeMonsts(t, monstrnd[leveltype - 1]); } void __fastcall Theme_Shrine(int t) { - char monstrnd[4]; // [esp+3h] [ebp-5h] + char monstrnd[4]; // [esp+3h] [ebp-5h] - monstrnd[0] = 6; - monstrnd[1] = 6; - monstrnd[2] = 3; - monstrnd[3] = 9; - TFit_Shrine(t); - if (themeVar1 == 1) { - AddObject(OBJ_CANDLE2, themex - 1, themey); - AddObject(OBJ_SHRINER, themex, themey); - AddObject(OBJ_CANDLE2, themex + 1, themey); - } else { - AddObject(OBJ_CANDLE2, themex, themey - 1); - AddObject(OBJ_SHRINEL, themex, themey); - AddObject(OBJ_CANDLE2, themex, themey + 1); - } - PlaceThemeMonsts(t, monstrnd[leveltype - 1]); + monstrnd[0] = 6; + monstrnd[1] = 6; + monstrnd[2] = 3; + monstrnd[3] = 9; + TFit_Shrine(t); + if (themeVar1 == 1) { + AddObject(OBJ_CANDLE2, themex - 1, themey); + AddObject(OBJ_SHRINER, themex, themey); + AddObject(OBJ_CANDLE2, themex + 1, themey); + } else { + AddObject(OBJ_CANDLE2, themex, themey - 1); + AddObject(OBJ_SHRINEL, themex, themey); + AddObject(OBJ_CANDLE2, themex, themey + 1); + } + PlaceThemeMonsts(t, monstrnd[leveltype - 1]); } void __fastcall Theme_MonstPit(int t) { - int r; // eax - int ixp; // ecx - int iyp; // edx - char monstrnd[4]; // [esp+4h] [ebp-8h] + int r; // eax + int ixp; // ecx + int iyp; // edx + char monstrnd[4]; // [esp+4h] [ebp-8h] - monstrnd[0] = 6; - monstrnd[1] = 7; - monstrnd[2] = 3; - monstrnd[3] = 9; - r = random(0, 100) + 1; - ixp = 0; - iyp = 0; - if (r > 0) { - while (1) { - if (dung_map[ixp][iyp] == themes[t].ttval && !nSolidTable[dPiece[ixp][iyp]]) - --r; - if (r <= 0) - break; - if (++ixp == 112) { - ixp = 0; - if (++iyp == 112) - iyp = 0; - } - } - } - CreateRndItem(ixp, iyp, 1u, 0, 1); - ItemNoFlippy(); - PlaceThemeMonsts(t, monstrnd[leveltype - 1]); + monstrnd[0] = 6; + monstrnd[1] = 7; + monstrnd[2] = 3; + monstrnd[3] = 9; + r = random(0, 100) + 1; + ixp = 0; + iyp = 0; + if (r > 0) { + while (1) { + if (dung_map[ixp][iyp] == themes[t].ttval && !nSolidTable[dPiece[ixp][iyp]]) + --r; + if (r <= 0) + break; + if (++ixp == 112) { + ixp = 0; + if (++iyp == 112) + iyp = 0; + } + } + } + CreateRndItem(ixp, iyp, 1u, 0, 1); + ItemNoFlippy(); + PlaceThemeMonsts(t, monstrnd[leveltype - 1]); } void __fastcall Theme_SkelRoom(int t) { - int yp; // esi - int xp; // edi - char monstrnd[4]; // [esp+Bh] [ebp-5h] + int yp; // esi + int xp; // edi + char monstrnd[4]; // [esp+Bh] [ebp-5h] - monstrnd[0] = 6; - monstrnd[1] = 7; - monstrnd[2] = 3; - monstrnd[3] = 9; - TFit_SkelRoom(t); - yp = themey; - xp = themex; - AddObject(OBJ_SKFIRE, themex, themey); + monstrnd[0] = 6; + monstrnd[1] = 7; + monstrnd[2] = 3; + monstrnd[3] = 9; + TFit_SkelRoom(t); + yp = themey; + xp = themex; + AddObject(OBJ_SKFIRE, themex, themey); - if (random(0, monstrnd[leveltype - 1])) - SpawnSkeleton(PreSpawnSkeleton(), xp - 1, yp - 1); - else - AddObject(OBJ_BANNERL, xp - 1, yp - 1); + if (random(0, monstrnd[leveltype - 1])) + SpawnSkeleton(PreSpawnSkeleton(), xp - 1, yp - 1); + else + AddObject(OBJ_BANNERL, xp - 1, yp - 1); - SpawnSkeleton(PreSpawnSkeleton(), xp, yp - 1); + SpawnSkeleton(PreSpawnSkeleton(), xp, yp - 1); - if (random(0, monstrnd[leveltype - 1])) - SpawnSkeleton(PreSpawnSkeleton(), xp + 1, yp - 1); - else - AddObject(OBJ_BANNERR, xp + 1, yp - 1); + if (random(0, monstrnd[leveltype - 1])) + SpawnSkeleton(PreSpawnSkeleton(), xp + 1, yp - 1); + else + AddObject(OBJ_BANNERR, xp + 1, yp - 1); - if (random(0, monstrnd[leveltype - 1])) - SpawnSkeleton(PreSpawnSkeleton(), xp - 1, yp); - else - AddObject(OBJ_BANNERM, xp - 1, yp); + if (random(0, monstrnd[leveltype - 1])) + SpawnSkeleton(PreSpawnSkeleton(), xp - 1, yp); + else + AddObject(OBJ_BANNERM, xp - 1, yp); - if (random(0, monstrnd[leveltype - 1])) - SpawnSkeleton(PreSpawnSkeleton(), xp + 1, yp); - else - AddObject(OBJ_BANNERM, xp + 1, yp); + if (random(0, monstrnd[leveltype - 1])) + SpawnSkeleton(PreSpawnSkeleton(), xp + 1, yp); + else + AddObject(OBJ_BANNERM, xp + 1, yp); - if (random(0, monstrnd[leveltype - 1])) - SpawnSkeleton(PreSpawnSkeleton(), xp - 1, yp + 1); - else - AddObject(OBJ_BANNERR, xp - 1, yp + 1); + if (random(0, monstrnd[leveltype - 1])) + SpawnSkeleton(PreSpawnSkeleton(), xp - 1, yp + 1); + else + AddObject(OBJ_BANNERR, xp - 1, yp + 1); - SpawnSkeleton(PreSpawnSkeleton(), xp, yp + 1); + SpawnSkeleton(PreSpawnSkeleton(), xp, yp + 1); - if (random(0, monstrnd[leveltype - 1])) - SpawnSkeleton(PreSpawnSkeleton(), xp + 1, yp + 1); - else - AddObject(OBJ_BANNERL, xp + 1, yp + 1); + if (random(0, monstrnd[leveltype - 1])) + SpawnSkeleton(PreSpawnSkeleton(), xp + 1, yp + 1); + else + AddObject(OBJ_BANNERL, xp + 1, yp + 1); - if (!dObject[xp][yp - 3]) // dungeon[xp + 39][yp + 37] ) /* fix */ - AddObject(OBJ_SKELBOOK, xp, yp - 2); - if (!dObject[xp][yp + 3]) - AddObject(OBJ_SKELBOOK, xp, yp + 2); + if (!dObject[xp][yp - 3]) // dungeon[xp + 39][yp + 37] ) /* fix */ + AddObject(OBJ_SKELBOOK, xp, yp - 2); + if (!dObject[xp][yp + 3]) + AddObject(OBJ_SKELBOOK, xp, yp + 2); } void __fastcall Theme_Treasure(int t) { - int yp; // esi - int xp; // edi - int rv; // [esp+14h] [ebp-10h] - char monstrnd[4]; // [esp+18h] [ebp-Ch] - char treasrnd[4]; // [esp+20h] [ebp-4h] + int yp; // esi + int xp; // edi + int rv; // [esp+14h] [ebp-10h] + char monstrnd[4]; // [esp+18h] [ebp-Ch] + char treasrnd[4]; // [esp+20h] [ebp-4h] - treasrnd[0] = 4; - treasrnd[1] = 9; - treasrnd[2] = 7; - treasrnd[3] = 10; - monstrnd[0] = 6; - monstrnd[1] = 8; - monstrnd[2] = 3; - monstrnd[3] = 7; - GetRndSeed(); - for (yp = 0; yp < 112; yp++) { - for (xp = 0; xp < 112; xp++) { - if (dung_map[xp][yp] == themes[t].ttval && !nSolidTable[dPiece[xp][yp]]) { - rv = random(0, treasrnd[leveltype - 1]); - if (!(2 * random(0, treasrnd[leveltype - 1]))) { - CreateTypeItem(xp, yp, 0, ITYPE_GOLD, 0, 0, 1); - ItemNoFlippy(); - } - if (!rv) { - CreateRndItem(xp, yp, 0, 0, 1); - ItemNoFlippy(); - } - if (rv >= treasrnd[leveltype - 1] - 2 && leveltype != 1) - item[ItemNoFlippy()]._ivalue >>= 1; /* check */ - } - } - } - PlaceThemeMonsts(t, monstrnd[leveltype - 1]); + treasrnd[0] = 4; + treasrnd[1] = 9; + treasrnd[2] = 7; + treasrnd[3] = 10; + monstrnd[0] = 6; + monstrnd[1] = 8; + monstrnd[2] = 3; + monstrnd[3] = 7; + GetRndSeed(); + for (yp = 0; yp < 112; yp++) { + for (xp = 0; xp < 112; xp++) { + if (dung_map[xp][yp] == themes[t].ttval && !nSolidTable[dPiece[xp][yp]]) { + rv = random(0, treasrnd[leveltype - 1]); + if (!(2 * random(0, treasrnd[leveltype - 1]))) { + CreateTypeItem(xp, yp, 0, ITYPE_GOLD, 0, 0, 1); + ItemNoFlippy(); + } + if (!rv) { + CreateRndItem(xp, yp, 0, 0, 1); + ItemNoFlippy(); + } + if (rv >= treasrnd[leveltype - 1] - 2 && leveltype != 1) + item[ItemNoFlippy()]._ivalue >>= 1; /* check */ + } + } + } + PlaceThemeMonsts(t, monstrnd[leveltype - 1]); } void __fastcall Theme_Library(int t) { - int v1; // edi - int v2; // ebx - char *v3; // esi - //int v4; // eax - int v7; // eax - //int v8; // eax - int ta; // [esp+Ch] [ebp-14h] - int *v10; // [esp+10h] [ebp-10h] - int *v11; // [esp+14h] [ebp-Ch] - char monstrnd[4]; // [esp+18h] [ebp-8h] - char librnd[4]; // [esp+1Ch] [ebp-4h] + int v1; // edi + int v2; // ebx + char *v3; // esi + //int v4; // eax + int v7; // eax + //int v8; // eax + int ta; // [esp+Ch] [ebp-14h] + int *v10; // [esp+10h] [ebp-10h] + int *v11; // [esp+14h] [ebp-Ch] + char monstrnd[4]; // [esp+18h] [ebp-8h] + char librnd[4]; // [esp+1Ch] [ebp-4h] - ta = t; - librnd[0] = 1; - librnd[1] = 2; - librnd[2] = 2; - librnd[3] = 5; - monstrnd[0] = 5; - monstrnd[1] = 7; - monstrnd[2] = 3; - monstrnd[3] = 9; - TFit_Shrine(t); - v1 = 1; - if (themeVar1 == 1) { - AddObject(OBJ_BOOKCANDLE, themex - 1, themey); - AddObject(OBJ_BOOKCASER, themex, themey); - AddObject(OBJ_BOOKCANDLE, themex + 1, themey); - } else { - AddObject(OBJ_BOOKCANDLE, themex, themey - 1); - AddObject(OBJ_BOOKCASEL, themex, themey); - AddObject(OBJ_BOOKCANDLE, themex, themey + 1); - } - v11 = &dMonster[1][1]; - do { - v2 = 1; - v3 = &dObject[1][v1]; - v10 = v11; - do { - //LOBYTE(v4) = CheckThemeObj3(v2, v1, ta, -1); - if (CheckThemeObj3(v2, v1, ta, -1)) { - if (!*v10) { - if (!random(0, librnd[leveltype - 1])) { - AddObject(OBJ_BOOKSTAND, v2, v1); - if (random(0, 2 * librnd[leveltype - 1])) { - v7 = *v3 - 1; - object[v7]._oSelFlag = 0; - object[v7]._oAnimFrame += 2; - } - } - } - } - v10 += 112; - ++v2; - v3 += 112; - } while (v2 < 111); - ++v11; - ++v1; - } while ((signed int)v11 < (signed int)&dMonster[1][111]); - //LOBYTE(v8) = QuestStatus(QTYPE_ZHAR); - if (!QuestStatus(QTYPE_ZHAR) || ta != zharlib) - PlaceThemeMonsts(ta, monstrnd[leveltype - 1]); + ta = t; + librnd[0] = 1; + librnd[1] = 2; + librnd[2] = 2; + librnd[3] = 5; + monstrnd[0] = 5; + monstrnd[1] = 7; + monstrnd[2] = 3; + monstrnd[3] = 9; + TFit_Shrine(t); + v1 = 1; + if (themeVar1 == 1) { + AddObject(OBJ_BOOKCANDLE, themex - 1, themey); + AddObject(OBJ_BOOKCASER, themex, themey); + AddObject(OBJ_BOOKCANDLE, themex + 1, themey); + } else { + AddObject(OBJ_BOOKCANDLE, themex, themey - 1); + AddObject(OBJ_BOOKCASEL, themex, themey); + AddObject(OBJ_BOOKCANDLE, themex, themey + 1); + } + v11 = &dMonster[1][1]; + do { + v2 = 1; + v3 = &dObject[1][v1]; + v10 = v11; + do { + //LOBYTE(v4) = CheckThemeObj3(v2, v1, ta, -1); + if (CheckThemeObj3(v2, v1, ta, -1)) { + if (!*v10) { + if (!random(0, librnd[leveltype - 1])) { + AddObject(OBJ_BOOKSTAND, v2, v1); + if (random(0, 2 * librnd[leveltype - 1])) { + v7 = *v3 - 1; + object[v7]._oSelFlag = 0; + object[v7]._oAnimFrame += 2; + } + } + } + } + v10 += 112; + ++v2; + v3 += 112; + } while (v2 < 111); + ++v11; + ++v1; + } while ((signed int)v11 < (signed int)&dMonster[1][111]); + //LOBYTE(v8) = QuestStatus(QTYPE_ZHAR); + if (!QuestStatus(QTYPE_ZHAR) || ta != zharlib) + PlaceThemeMonsts(ta, monstrnd[leveltype - 1]); } // 6AAA64: using guessed type int zharlib; void __fastcall Theme_Torture(int t) { - int v1; // ebx - int v2; // esi - char *v3; // edi - //int v4; // eax - int *x; // [esp+Ch] [ebp-14h] - char monstrnd[4]; // [esp+10h] [ebp-10h] - int *v8; // [esp+14h] [ebp-Ch] - char tortrnd[4]; // [esp+18h] [ebp-8h] - int v10; // [esp+1Ch] [ebp-4h] + int v1; // ebx + int v2; // esi + char *v3; // edi + //int v4; // eax + int *x; // [esp+Ch] [ebp-14h] + char monstrnd[4]; // [esp+10h] [ebp-10h] + int *v8; // [esp+14h] [ebp-Ch] + char tortrnd[4]; // [esp+18h] [ebp-8h] + int v10; // [esp+1Ch] [ebp-4h] - v1 = t; - tortrnd[0] = 6; - tortrnd[1] = 8; - tortrnd[2] = 3; - tortrnd[3] = 8; - monstrnd[0] = 6; - monstrnd[1] = 8; - monstrnd[2] = 3; - monstrnd[3] = 9; - v2 = 1; - v8 = &dPiece[1][1]; - do { - v10 = 1; - v3 = &dung_map[1][v2]; - x = v8; - do { - if (*v3 == themes[v1].ttval && !nSolidTable[*x]) { - //LOBYTE(v4) = CheckThemeObj3(v10, v2, v1, -1); - if (CheckThemeObj3(v10, v2, v1, -1)) { - if (!random(0, tortrnd[leveltype - 1])) - AddObject(OBJ_TNUDEM2, v10, v2); - } - } - ++v10; - x += 112; - v3 += 112; - } while (v10 < 111); - ++v8; - ++v2; - } while ((signed int)v8 < (signed int)&dPiece[1][111]); - PlaceThemeMonsts(v1, monstrnd[leveltype - 1]); + v1 = t; + tortrnd[0] = 6; + tortrnd[1] = 8; + tortrnd[2] = 3; + tortrnd[3] = 8; + monstrnd[0] = 6; + monstrnd[1] = 8; + monstrnd[2] = 3; + monstrnd[3] = 9; + v2 = 1; + v8 = &dPiece[1][1]; + do { + v10 = 1; + v3 = &dung_map[1][v2]; + x = v8; + do { + if (*v3 == themes[v1].ttval && !nSolidTable[*x]) { + //LOBYTE(v4) = CheckThemeObj3(v10, v2, v1, -1); + if (CheckThemeObj3(v10, v2, v1, -1)) { + if (!random(0, tortrnd[leveltype - 1])) + AddObject(OBJ_TNUDEM2, v10, v2); + } + } + ++v10; + x += 112; + v3 += 112; + } while (v10 < 111); + ++v8; + ++v2; + } while ((signed int)v8 < (signed int)&dPiece[1][111]); + PlaceThemeMonsts(v1, monstrnd[leveltype - 1]); } void __fastcall Theme_BloodFountain(int t) { - char monstrnd[4]; // [esp+3h] [ebp-5h] + char monstrnd[4]; // [esp+3h] [ebp-5h] - monstrnd[0] = 6; - monstrnd[1] = 8; - monstrnd[2] = 3; - monstrnd[3] = 9; - TFit_Obj5(t); - AddObject(OBJ_BLOODFTN, themex, themey); - PlaceThemeMonsts(t, monstrnd[leveltype - 1]); + monstrnd[0] = 6; + monstrnd[1] = 8; + monstrnd[2] = 3; + monstrnd[3] = 9; + TFit_Obj5(t); + AddObject(OBJ_BLOODFTN, themex, themey); + PlaceThemeMonsts(t, monstrnd[leveltype - 1]); } void __fastcall Theme_Decap(int t) { - int v1; // ebx - int v2; // esi - char *v3; // edi - //int v4; // eax - int *x; // [esp+Ch] [ebp-14h] - char monstrnd[4]; // [esp+10h] [ebp-10h] - int *v8; // [esp+14h] [ebp-Ch] - char decaprnd[4]; // [esp+18h] [ebp-8h] - int v10; // [esp+1Ch] [ebp-4h] + int v1; // ebx + int v2; // esi + char *v3; // edi + //int v4; // eax + int *x; // [esp+Ch] [ebp-14h] + char monstrnd[4]; // [esp+10h] [ebp-10h] + int *v8; // [esp+14h] [ebp-Ch] + char decaprnd[4]; // [esp+18h] [ebp-8h] + int v10; // [esp+1Ch] [ebp-4h] - v1 = t; - decaprnd[0] = 6; - decaprnd[1] = 8; - decaprnd[2] = 3; - decaprnd[3] = 8; - monstrnd[0] = 6; - monstrnd[1] = 8; - monstrnd[2] = 3; - monstrnd[3] = 9; - v2 = 1; - v8 = &dPiece[1][1]; - do { - v10 = 1; - v3 = &dung_map[1][v2]; - x = v8; - do { - if (*v3 == themes[v1].ttval && !nSolidTable[*x]) { - //LOBYTE(v4) = CheckThemeObj3(v10, v2, v1, -1); - if (CheckThemeObj3(v10, v2, v1, -1)) { - if (!random(0, decaprnd[leveltype - 1])) - AddObject(OBJ_DECAP, v10, v2); - } - } - ++v10; - x += 112; - v3 += 112; - } while (v10 < 111); - ++v8; - ++v2; - } while ((signed int)v8 < (signed int)&dPiece[1][111]); - PlaceThemeMonsts(v1, monstrnd[leveltype - 1]); + v1 = t; + decaprnd[0] = 6; + decaprnd[1] = 8; + decaprnd[2] = 3; + decaprnd[3] = 8; + monstrnd[0] = 6; + monstrnd[1] = 8; + monstrnd[2] = 3; + monstrnd[3] = 9; + v2 = 1; + v8 = &dPiece[1][1]; + do { + v10 = 1; + v3 = &dung_map[1][v2]; + x = v8; + do { + if (*v3 == themes[v1].ttval && !nSolidTable[*x]) { + //LOBYTE(v4) = CheckThemeObj3(v10, v2, v1, -1); + if (CheckThemeObj3(v10, v2, v1, -1)) { + if (!random(0, decaprnd[leveltype - 1])) + AddObject(OBJ_DECAP, v10, v2); + } + } + ++v10; + x += 112; + v3 += 112; + } while (v10 < 111); + ++v8; + ++v2; + } while ((signed int)v8 < (signed int)&dPiece[1][111]); + PlaceThemeMonsts(v1, monstrnd[leveltype - 1]); } void __fastcall Theme_PurifyingFountain(int t) { - char monstrnd[4]; // [esp+3h] [ebp-5h] + char monstrnd[4]; // [esp+3h] [ebp-5h] - monstrnd[0] = 6; - monstrnd[1] = 7; - monstrnd[2] = 3; - monstrnd[3] = 9; - TFit_Obj5(t); - AddObject(OBJ_PURIFYINGFTN, themex, themey); - PlaceThemeMonsts(t, monstrnd[leveltype - 1]); + monstrnd[0] = 6; + monstrnd[1] = 7; + monstrnd[2] = 3; + monstrnd[3] = 9; + TFit_Obj5(t); + AddObject(OBJ_PURIFYINGFTN, themex, themey); + PlaceThemeMonsts(t, monstrnd[leveltype - 1]); } void __fastcall Theme_ArmorStand(int t) { - int v1; // esi - int v2; // ebx - char *v3; // edi - //int v4; // eax - int ta; // [esp+Ch] [ebp-14h] - int *v7; // [esp+10h] [ebp-10h] - char monstrnd[4]; // [esp+14h] [ebp-Ch] - int *v9; // [esp+18h] [ebp-8h] - char armorrnd[4]; // [esp+1Ch] [ebp-4h] + int v1; // esi + int v2; // ebx + char *v3; // edi + //int v4; // eax + int ta; // [esp+Ch] [ebp-14h] + int *v7; // [esp+10h] [ebp-10h] + char monstrnd[4]; // [esp+14h] [ebp-Ch] + int *v9; // [esp+18h] [ebp-8h] + char armorrnd[4]; // [esp+1Ch] [ebp-4h] - v1 = 0; - ta = t; - armorrnd[0] = 6; - armorrnd[1] = 8; - armorrnd[2] = 3; - armorrnd[3] = 8; - monstrnd[0] = 6; - monstrnd[1] = 7; - monstrnd[2] = 3; - monstrnd[3] = 9; - if (armorFlag) { - TFit_Obj3(t); - AddObject(OBJ_ARMORSTAND, themex, themey); - } - v9 = (int *)dPiece; - do { - v2 = 0; - v3 = (char *)dung_map + v1; - v7 = v9; - do { - if (*v3 == themes[ta].ttval && !nSolidTable[*v7]) { - //LOBYTE(v4) = CheckThemeObj3(v2, v1, ta, -1); - if (CheckThemeObj3(v2, v1, ta, -1)) { - if (!random(0, armorrnd[leveltype - 1])) - AddObject(OBJ_ARMORSTANDN, v2, v1); - } - } - v7 += 112; - ++v2; - v3 += 112; - } while (v2 < 112); - ++v9; - ++v1; - } while ((signed int)v9 < (signed int)dPiece[1]); - PlaceThemeMonsts(ta, monstrnd[leveltype - 1]); - armorFlag = 0; + v1 = 0; + ta = t; + armorrnd[0] = 6; + armorrnd[1] = 8; + armorrnd[2] = 3; + armorrnd[3] = 8; + monstrnd[0] = 6; + monstrnd[1] = 7; + monstrnd[2] = 3; + monstrnd[3] = 9; + if (armorFlag) { + TFit_Obj3(t); + AddObject(OBJ_ARMORSTAND, themex, themey); + } + v9 = (int *)dPiece; + do { + v2 = 0; + v3 = (char *)dung_map + v1; + v7 = v9; + do { + if (*v3 == themes[ta].ttval && !nSolidTable[*v7]) { + //LOBYTE(v4) = CheckThemeObj3(v2, v1, ta, -1); + if (CheckThemeObj3(v2, v1, ta, -1)) { + if (!random(0, armorrnd[leveltype - 1])) + AddObject(OBJ_ARMORSTANDN, v2, v1); + } + } + v7 += 112; + ++v2; + v3 += 112; + } while (v2 < 112); + ++v9; + ++v1; + } while ((signed int)v9 < (signed int)dPiece[1]); + PlaceThemeMonsts(ta, monstrnd[leveltype - 1]); + armorFlag = 0; } // 6AAA3C: using guessed type int armorFlag; void __fastcall Theme_GoatShrine(int t) { - int v1; // edx - int v2; // esi - int v3; // ecx - int v4; // edi - int v5; // eax - char *v6; // ebx - _DWORD *v7; // [esp+4h] [ebp-8h] + int v1; // edx + int v2; // esi + int v3; // ecx + int v4; // edi + int v5; // eax + char *v6; // ebx + _DWORD *v7; // [esp+4h] [ebp-8h] - TFit_GoatShrine(t); - AddObject(OBJ_GOATSHRINE, themex, themey); - v1 = themey; - v2 = themey - 1; - if (themey - 1 <= themey + 1) { - v3 = themex; - do { - v4 = v3 - 1; - if ((unsigned char)(__OFSUB__(v3 - 1, v3 + 1) ^ 1) | (v3 - 1 == v3 + 1)) { - v5 = v2 + 112 * v4; - v6 = (char *)dung_map + v5; - v7 = (_DWORD *)((char *)dPiece + 4 * v5); - do { - if (*v6 == themes[t].ttval && !nSolidTable[*v7] && (v4 != v3 || v2 != v1)) { - AddMonster(v4, v2, 1, themeVar1, 1); - v1 = themey; - v3 = themex; - } - v7 += 112; - ++v4; - v6 += 112; - } while (v4 <= v3 + 1); - } - ++v2; - } while (v2 <= v1 + 1); - } + TFit_GoatShrine(t); + AddObject(OBJ_GOATSHRINE, themex, themey); + v1 = themey; + v2 = themey - 1; + if (themey - 1 <= themey + 1) { + v3 = themex; + do { + v4 = v3 - 1; + if ((unsigned char)(__OFSUB__(v3 - 1, v3 + 1) ^ 1) | (v3 - 1 == v3 + 1)) { + v5 = v2 + 112 * v4; + v6 = (char *)dung_map + v5; + v7 = (_DWORD *)((char *)dPiece + 4 * v5); + do { + if (*v6 == themes[t].ttval && !nSolidTable[*v7] && (v4 != v3 || v2 != v1)) { + AddMonster(v4, v2, 1, themeVar1, 1); + v1 = themey; + v3 = themex; + } + v7 += 112; + ++v4; + v6 += 112; + } while (v4 <= v3 + 1); + } + ++v2; + } while (v2 <= v1 + 1); + } } void __fastcall Theme_Cauldron(int t) { - char monstrnd[4]; // [esp+3h] [ebp-5h] + char monstrnd[4]; // [esp+3h] [ebp-5h] - monstrnd[0] = 6; - monstrnd[1] = 7; - monstrnd[2] = 3; - monstrnd[3] = 9; - TFit_Obj5(t); - AddObject(OBJ_CAULDRON, themex, themey); - PlaceThemeMonsts(t, monstrnd[leveltype - 1]); + monstrnd[0] = 6; + monstrnd[1] = 7; + monstrnd[2] = 3; + monstrnd[3] = 9; + TFit_Obj5(t); + AddObject(OBJ_CAULDRON, themex, themey); + PlaceThemeMonsts(t, monstrnd[leveltype - 1]); } void __fastcall Theme_MurkyFountain(int t) { - char monstrnd[4]; // [esp+3h] [ebp-5h] + char monstrnd[4]; // [esp+3h] [ebp-5h] - monstrnd[0] = 6; - monstrnd[1] = 7; - monstrnd[2] = 3; - monstrnd[3] = 9; - TFit_Obj5(t); - AddObject(OBJ_MURKYFTN, themex, themey); - PlaceThemeMonsts(t, monstrnd[leveltype - 1]); + monstrnd[0] = 6; + monstrnd[1] = 7; + monstrnd[2] = 3; + monstrnd[3] = 9; + TFit_Obj5(t); + AddObject(OBJ_MURKYFTN, themex, themey); + PlaceThemeMonsts(t, monstrnd[leveltype - 1]); } void __fastcall Theme_TearFountain(int t) { - char monstrnd[4]; // [esp+3h] [ebp-5h] + char monstrnd[4]; // [esp+3h] [ebp-5h] - monstrnd[0] = 6; - monstrnd[1] = 7; - monstrnd[2] = 3; - monstrnd[3] = 9; - TFit_Obj5(t); - AddObject(OBJ_TEARFTN, themex, themey); - PlaceThemeMonsts(t, monstrnd[leveltype - 1]); + monstrnd[0] = 6; + monstrnd[1] = 7; + monstrnd[2] = 3; + monstrnd[3] = 9; + TFit_Obj5(t); + AddObject(OBJ_TEARFTN, themex, themey); + PlaceThemeMonsts(t, monstrnd[leveltype - 1]); } void __fastcall Theme_BrnCross(int t) { - int v1; // esi - int v2; // ebx - char *v3; // edi - //int v4; // eax - int ta; // [esp+Ch] [ebp-14h] - int *v7; // [esp+10h] [ebp-10h] - char monstrnd[4]; // [esp+14h] [ebp-Ch] - int *v9; // [esp+18h] [ebp-8h] - char bcrossrnd[4]; // [esp+1Ch] [ebp-4h] + int v1; // esi + int v2; // ebx + char *v3; // edi + //int v4; // eax + int ta; // [esp+Ch] [ebp-14h] + int *v7; // [esp+10h] [ebp-10h] + char monstrnd[4]; // [esp+14h] [ebp-Ch] + int *v9; // [esp+18h] [ebp-8h] + char bcrossrnd[4]; // [esp+1Ch] [ebp-4h] - ta = t; - monstrnd[0] = 6; - monstrnd[1] = 8; - monstrnd[2] = 3; - monstrnd[3] = 9; - bcrossrnd[0] = 5; - bcrossrnd[1] = 7; - bcrossrnd[2] = 3; - bcrossrnd[3] = 8; - v1 = 0; - v9 = (int *)dPiece; - do { - v2 = 0; - v3 = (char *)dung_map + v1; - v7 = v9; - do { - if (*v3 == themes[ta].ttval && !nSolidTable[*v7]) { - //LOBYTE(v4) = CheckThemeObj3(v2, v1, ta, -1); - if (CheckThemeObj3(v2, v1, ta, -1)) { - if (!random(0, bcrossrnd[leveltype - 1])) - AddObject(OBJ_TBCROSS, v2, v1); - } - } - v7 += 112; - ++v2; - v3 += 112; - } while (v2 < 112); - ++v9; - ++v1; - } while ((signed int)v9 < (signed int)dPiece[1]); - PlaceThemeMonsts(ta, monstrnd[leveltype - 1]); - bCrossFlag = 1; + ta = t; + monstrnd[0] = 6; + monstrnd[1] = 8; + monstrnd[2] = 3; + monstrnd[3] = 9; + bcrossrnd[0] = 5; + bcrossrnd[1] = 7; + bcrossrnd[2] = 3; + bcrossrnd[3] = 8; + v1 = 0; + v9 = (int *)dPiece; + do { + v2 = 0; + v3 = (char *)dung_map + v1; + v7 = v9; + do { + if (*v3 == themes[ta].ttval && !nSolidTable[*v7]) { + //LOBYTE(v4) = CheckThemeObj3(v2, v1, ta, -1); + if (CheckThemeObj3(v2, v1, ta, -1)) { + if (!random(0, bcrossrnd[leveltype - 1])) + AddObject(OBJ_TBCROSS, v2, v1); + } + } + v7 += 112; + ++v2; + v3 += 112; + } while (v2 < 112); + ++v9; + ++v1; + } while ((signed int)v9 < (signed int)dPiece[1]); + PlaceThemeMonsts(ta, monstrnd[leveltype - 1]); + bCrossFlag = 1; } // 6AAC10: using guessed type int bCrossFlag; void __fastcall Theme_WeaponRack(int t) { - int v1; // esi - int v2; // ebx - char *v3; // edi - //int v4; // eax - int ta; // [esp+Ch] [ebp-14h] - int *v7; // [esp+10h] [ebp-10h] - char monstrnd[4]; // [esp+14h] [ebp-Ch] - int *v9; // [esp+18h] [ebp-8h] - char weaponrnd[4]; // [esp+1Ch] [ebp-4h] + int v1; // esi + int v2; // ebx + char *v3; // edi + //int v4; // eax + int ta; // [esp+Ch] [ebp-14h] + int *v7; // [esp+10h] [ebp-10h] + char monstrnd[4]; // [esp+14h] [ebp-Ch] + int *v9; // [esp+18h] [ebp-8h] + char weaponrnd[4]; // [esp+1Ch] [ebp-4h] - v1 = 0; - ta = t; - weaponrnd[0] = 6; - weaponrnd[1] = 8; - weaponrnd[2] = 5; - weaponrnd[3] = 8; - monstrnd[0] = 6; - monstrnd[1] = 7; - monstrnd[2] = 3; - monstrnd[3] = 9; - if (weaponFlag) { - TFit_Obj3(t); - AddObject(OBJ_WEAPONRACK, themex, themey); - } - v9 = (int *)dPiece; - do { - v2 = 0; - v3 = (char *)dung_map + v1; - v7 = v9; - do { - if (*v3 == themes[ta].ttval && !nSolidTable[*v7]) { - //LOBYTE(v4) = CheckThemeObj3(v2, v1, ta, -1); - if (CheckThemeObj3(v2, v1, ta, -1)) { - if (!random(0, weaponrnd[leveltype - 1])) - AddObject(OBJ_WEAPONRACKN, v2, v1); - } - } - v7 += 112; - ++v2; - v3 += 112; - } while (v2 < 112); - ++v9; - ++v1; - } while ((signed int)v9 < (signed int)dPiece[1]); - PlaceThemeMonsts(ta, monstrnd[leveltype - 1]); - weaponFlag = 0; + v1 = 0; + ta = t; + weaponrnd[0] = 6; + weaponrnd[1] = 8; + weaponrnd[2] = 5; + weaponrnd[3] = 8; + monstrnd[0] = 6; + monstrnd[1] = 7; + monstrnd[2] = 3; + monstrnd[3] = 9; + if (weaponFlag) { + TFit_Obj3(t); + AddObject(OBJ_WEAPONRACK, themex, themey); + } + v9 = (int *)dPiece; + do { + v2 = 0; + v3 = (char *)dung_map + v1; + v7 = v9; + do { + if (*v3 == themes[ta].ttval && !nSolidTable[*v7]) { + //LOBYTE(v4) = CheckThemeObj3(v2, v1, ta, -1); + if (CheckThemeObj3(v2, v1, ta, -1)) { + if (!random(0, weaponrnd[leveltype - 1])) + AddObject(OBJ_WEAPONRACKN, v2, v1); + } + } + v7 += 112; + ++v2; + v3 += 112; + } while (v2 < 112); + ++v9; + ++v1; + } while ((signed int)v9 < (signed int)dPiece[1]); + PlaceThemeMonsts(ta, monstrnd[leveltype - 1]); + weaponFlag = 0; } // 6AAA50: using guessed type int weaponFlag; void __cdecl UpdateL4Trans() { - int i; // ecx - int j; // edx + int i; // ecx + int j; // edx - for (i = 0; i < 112; i++) { - for (j = 0; j < 112; j++) { - if (dung_map[i][j]) - dung_map[i][j] = 1; - } - } + for (i = 0; i < 112; i++) { + for (j = 0; j < 112; j++) { + if (dung_map[i][j]) + dung_map[i][j] = 1; + } + } } void __cdecl CreateThemeRooms() { - int i; // esi + int i; // esi - if (currlevel != 16) { - InitObjFlag = 1; - for (i = 0; i < numthemes; i++) { - themex = 0; - themey = 0; - switch (themes[i].ttype) { - case THEME_BARREL: - Theme_Barrel(i); - break; - case THEME_SHRINE: - Theme_Shrine(i); - break; - case THEME_MONSTPIT: - Theme_MonstPit(i); - break; - case THEME_SKELROOM: - Theme_SkelRoom(i); - break; - case THEME_TREASURE: - Theme_Treasure(i); - break; - case THEME_LIBRARY: - Theme_Library(i); - break; - case THEME_TORTURE: - Theme_Torture(i); - break; - case THEME_BLOODFOUNTAIN: - Theme_BloodFountain(i); - break; - case THEME_DECAPITATED: - Theme_Decap(i); - break; - case THEME_PURIFYINGFOUNTAIN: - Theme_PurifyingFountain(i); - break; - case THEME_ARMORSTAND: - Theme_ArmorStand(i); - break; - case THEME_GOATSHRINE: - Theme_GoatShrine(i); - break; - case THEME_CAULDRON: - Theme_Cauldron(i); - break; - case THEME_MURKYFOUNTAIN: - Theme_MurkyFountain(i); - break; - case THEME_TEARFOUNTAIN: - Theme_TearFountain(i); - break; - case THEME_BRNCROSS: - Theme_BrnCross(i); - break; - case THEME_WEAPONRACK: - Theme_WeaponRack(i); - break; - default: - continue; - } - } - InitObjFlag = 0; - if (leveltype == DTYPE_HELL && themeCount > 0) - UpdateL4Trans(); - } + if (currlevel != 16) { + InitObjFlag = 1; + for (i = 0; i < numthemes; i++) { + themex = 0; + themey = 0; + switch (themes[i].ttype) { + case THEME_BARREL: + Theme_Barrel(i); + break; + case THEME_SHRINE: + Theme_Shrine(i); + break; + case THEME_MONSTPIT: + Theme_MonstPit(i); + break; + case THEME_SKELROOM: + Theme_SkelRoom(i); + break; + case THEME_TREASURE: + Theme_Treasure(i); + break; + case THEME_LIBRARY: + Theme_Library(i); + break; + case THEME_TORTURE: + Theme_Torture(i); + break; + case THEME_BLOODFOUNTAIN: + Theme_BloodFountain(i); + break; + case THEME_DECAPITATED: + Theme_Decap(i); + break; + case THEME_PURIFYINGFOUNTAIN: + Theme_PurifyingFountain(i); + break; + case THEME_ARMORSTAND: + Theme_ArmorStand(i); + break; + case THEME_GOATSHRINE: + Theme_GoatShrine(i); + break; + case THEME_CAULDRON: + Theme_Cauldron(i); + break; + case THEME_MURKYFOUNTAIN: + Theme_MurkyFountain(i); + break; + case THEME_TEARFOUNTAIN: + Theme_TearFountain(i); + break; + case THEME_BRNCROSS: + Theme_BrnCross(i); + break; + case THEME_WEAPONRACK: + Theme_WeaponRack(i); + break; + default: + continue; + } + } + InitObjFlag = 0; + if (leveltype == DTYPE_HELL && themeCount > 0) + UpdateL4Trans(); + } } // 67D7C0: using guessed type int InitObjFlag; diff --git a/Source/tmsg.cpp b/Source/tmsg.cpp index 5ede9ca4..fe2f98f2 100644 --- a/Source/tmsg.cpp +++ b/Source/tmsg.cpp @@ -6,46 +6,46 @@ static TMsg *sgpTimedMsgHead; int __fastcall tmsg_get(BYTE *pbMsg, DWORD dwMaxLen) { - int len; - TMsg *head; + int len; + TMsg *head; - if (!sgpTimedMsgHead) - return 0; + if (!sgpTimedMsgHead) + return 0; - if ((int)(sgpTimedMsgHead->hdr.dwTime - GetTickCount()) >= 0) - return 0; - head = sgpTimedMsgHead; - sgpTimedMsgHead = head->hdr.pNext; - len = head->hdr.bLen; - // BUGFIX: ignores dwMaxLen - memcpy(pbMsg, head->body, len); - mem_free_dbg(head); - return len; + if ((int)(sgpTimedMsgHead->hdr.dwTime - GetTickCount()) >= 0) + return 0; + head = sgpTimedMsgHead; + sgpTimedMsgHead = head->hdr.pNext; + len = head->hdr.bLen; + // BUGFIX: ignores dwMaxLen + memcpy(pbMsg, head->body, len); + mem_free_dbg(head); + return len; } void __fastcall tmsg_add(BYTE *pbMsg, BYTE bLen) { - TMsg **tail; + TMsg **tail; - TMsg *msg = (TMsg *)DiabloAllocPtr(bLen + sizeof(*msg)); - msg->hdr.pNext = NULL; - msg->hdr.dwTime = GetTickCount() + 500; - msg->hdr.bLen = bLen; - memcpy(msg->body, pbMsg, bLen); - for (tail = &sgpTimedMsgHead; *tail; tail = &(*tail)->hdr.pNext) { - ; - } - *tail = msg; + TMsg *msg = (TMsg *)DiabloAllocPtr(bLen + sizeof(*msg)); + msg->hdr.pNext = NULL; + msg->hdr.dwTime = GetTickCount() + 500; + msg->hdr.bLen = bLen; + memcpy(msg->body, pbMsg, bLen); + for (tail = &sgpTimedMsgHead; *tail; tail = &(*tail)->hdr.pNext) { + ; + } + *tail = msg; } void *__cdecl tmsg_cleanup() { - while (sgpTimedMsgHead) { - TMsg *next = sgpTimedMsgHead->hdr.pNext; - TMsg *head = sgpTimedMsgHead; - sgpTimedMsgHead = NULL; - mem_free_dbg(head); - sgpTimedMsgHead = next; - } - return sgpTimedMsgHead; + while (sgpTimedMsgHead) { + TMsg *next = sgpTimedMsgHead->hdr.pNext; + TMsg *head = sgpTimedMsgHead; + sgpTimedMsgHead = NULL; + mem_free_dbg(head); + sgpTimedMsgHead = next; + } + return sgpTimedMsgHead; } diff --git a/Source/town.cpp b/Source/town.cpp index 439a20e7..0eb16b27 100644 --- a/Source/town.cpp +++ b/Source/town.cpp @@ -4,998 +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; @@ -1007,151 +1007,151 @@ void __fastcall T_DrawGame(int x, int y) 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; @@ -1163,49 +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; @@ -1221,50 +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; @@ -1274,261 +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 c53d2e4c..76649b53 100644 --- a/Source/towners.cpp +++ b/Source/towners.cpp @@ -12,78 +12,78 @@ 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 } + { 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 } + { 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 }; @@ -91,7 +91,7 @@ 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] = { - // clang-format off + // clang-format off // _qinfra, _qblkm, _qgarb, _qzhar, _qveil, _qmod, _qbutch, _qbol, _qblind, _qblood, _qanvil, _qwarlrd, _qking, _qpw, _qbone, _qvb { 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 }, @@ -104,640 +104,640 @@ QuestTalkData Qtalklist[11] = { { 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 } - // clang-format on + // clang-format on }; int CowPlaying = -1; int __fastcall GetActiveTowner(int t) { - int i; // eax + int i; // eax - i = 0; - if (numtowners <= 0) - return -1; + i = 0; + if (numtowners <= 0) + return -1; - while (towner[i]._ttype != t) { - ++i; - if (i >= numtowners) - return -1; - } - return i; + 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] + 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); + 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 + 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; + 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 + 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(); + 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 + 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); + 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 + 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; + 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 + 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; + 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 + 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; + 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 + 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; + 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 + 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; + 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 + 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; + 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 + 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; + 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 + 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; + 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 + 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; + 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] + 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); + 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 + 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); + 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 + 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(); - } - } + 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 + 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; - } + 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 + 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); + 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 + 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); + 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; @@ -745,410 +745,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] + 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; - } - } - } + 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; @@ -1156,18 +1156,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/track.cpp b/Source/track.cpp index 5719d8d3..e7b1d88e 100644 --- a/Source/track.cpp +++ b/Source/track.cpp @@ -9,42 +9,42 @@ static BOOL sgbIsWalking; void __cdecl track_process() { - if (!sgbIsWalking) - return; + if (!sgbIsWalking) + return; - if (cursmx < 0 || cursmx >= MAXDUNX - 1 || cursmy < 0 || cursmy >= MAXDUNY - 1) - return; + if (cursmx < 0 || cursmx >= MAXDUNX - 1 || cursmy < 0 || cursmy >= MAXDUNY - 1) + return; - if (plr[myplr]._pVar8 <= 6 && plr[myplr]._pmode != PM_STAND) - return; + if (plr[myplr]._pVar8 <= 6 && plr[myplr]._pmode != PM_STAND) + return; - if (cursmx != plr[myplr]._ptargx || cursmy != plr[myplr]._ptargy) { - DWORD tick = GetTickCount(); - if ((int)(tick - sgdwLastWalk) >= 300) { - sgdwLastWalk = tick; - NetSendCmdLoc(TRUE, CMD_WALKXY, cursmx, cursmy); - if (!sgbIsScrolling) - sgbIsScrolling = 1; - } - } + if (cursmx != plr[myplr]._ptargx || cursmy != plr[myplr]._ptargy) { + DWORD tick = GetTickCount(); + if ((int)(tick - sgdwLastWalk) >= 300) { + sgdwLastWalk = tick; + NetSendCmdLoc(TRUE, CMD_WALKXY, cursmx, cursmy); + if (!sgbIsScrolling) + sgbIsScrolling = 1; + } + } } void __fastcall track_repeat_walk(BOOL rep) { - if (sgbIsWalking == rep) - return; + if (sgbIsWalking == rep) + return; - sgbIsWalking = rep; - if (rep) { - sgbIsScrolling = 0; - sgdwLastWalk = GetTickCount() - 50; - NetSendCmdLoc(TRUE, CMD_WALKXY, cursmx, cursmy); - } else if (sgbIsScrolling) { - sgbIsScrolling = 0; - } + sgbIsWalking = rep; + if (rep) { + sgbIsScrolling = 0; + sgdwLastWalk = GetTickCount() - 50; + NetSendCmdLoc(TRUE, CMD_WALKXY, cursmx, cursmy); + } else if (sgbIsScrolling) { + sgbIsScrolling = 0; + } } BOOL __cdecl track_isscrolling() { - return sgbIsScrolling; + return sgbIsScrolling; } diff --git a/Source/trigs.cpp b/Source/trigs.cpp index 5f2f8814..3f4c8652 100644 --- a/Source/trigs.cpp +++ b/Source/trigs.cpp @@ -8,19 +8,19 @@ int TWarpFrom; // weak int TownDownList[11] = { 716, 715, 719, 720, 721, 723, 724, 725, 726, 727, -1 }; int TownWarp1List[13] = { - 1171, - 1172, - 1173, - 1174, - 1175, - 1176, - 1177, - 1178, - 1179, - 1181, - 1183, - 1185, - -1 + 1171, + 1172, + 1173, + 1174, + 1175, + 1176, + 1177, + 1178, + 1179, + 1181, + 1183, + 1185, + -1 }; int L1UpList[12] = { 127, 129, 130, 131, 132, 133, 135, 137, 138, 139, 140, -1 }; int L1DownList[10] = { 106, 107, 108, 109, 110, 112, 114, 115, 118, -1 }; @@ -28,21 +28,21 @@ int L2UpList[3] = { 266, 267, -1 }; int L2DownList[5] = { 269, 270, 271, 272, -1 }; int L2TWarpUpList[3] = { 558, 559, -1 }; int L3UpList[15] = { - 170, - 171, - 172, - 173, - 174, - 175, - 176, - 177, - 178, - 179, - 180, - 181, - 182, - 183, - -1 + 170, + 171, + 172, + 173, + 174, + 175, + 176, + 177, + 178, + 179, + 180, + 181, + 182, + 183, + -1 }; int L3DownList[9] = { 162, 163, 164, 165, 166, 167, 168, 169, -1 }; int L3TWarpUpList[14] = { 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, -1 }; @@ -50,1189 +50,1189 @@ int L4UpList[4] = { 82, 83, 90, -1 }; int L4DownList[6] = { 120, 130, 131, 132, 133, -1 }; int L4TWarpUpList[4] = { 421, 422, 429, -1 }; int L4PentaList[33] = { - 353, - 354, - 355, - 356, - 357, - 358, - 359, - 360, - 361, - 362, - 363, - 364, - 365, - 366, - 367, - 368, - 369, - 370, - 371, - 372, - 373, - 374, - 375, - 376, - 377, - 378, - 379, - 380, - 381, - 382, - 383, - 384, - -1 + 353, + 354, + 355, + 356, + 357, + 358, + 359, + 360, + 361, + 362, + 363, + 364, + 365, + 366, + 367, + 368, + 369, + 370, + 371, + 372, + 373, + 374, + 375, + 376, + 377, + 378, + 379, + 380, + 381, + 382, + 383, + 384, + -1 }; void __cdecl InitNoTriggers() { - trigflag[4] = 0; - trigflag[3] = 0; + trigflag[4] = 0; + trigflag[3] = 0; } void __cdecl InitTownTriggers() { - char v0; // bl - int v1; // eax - int v2; // eax + char v0; // bl + int v1; // eax + int v2; // eax - trigs[0]._tx = 25; - trigs[0]._ty = 29; - trigs[0]._tmsg = WM_DIABNEXTLVL; - trigflag[4] = 1; - if (gbMaxPlayers == 4) { - trigs[1]._tx = 49; - trigflag[0] = 1; - trigflag[1] = 1; - trigflag[2] = 1; - trigs[1]._ty = 21; - trigs[1]._tmsg = WM_DIABTOWNWARP; - trigs[1]._tlvl = 5; - trigs[2]._tx = 17; - trigs[2]._ty = 69; - trigs[2]._tmsg = WM_DIABTOWNWARP; - trigs[2]._tlvl = 9; - trigs[3]._tx = 41; - trigs[3]._ty = 80; - trigs[3]._tmsg = WM_DIABTOWNWARP; - trigs[3]._tlvl = 13; - trigflag[4] = 4; - } else { - trigflag[0] = 0; - trigflag[1] = 0; - trigflag[2] = 0; - v0 = plr[myplr].pTownWarps; - if (v0 & 1) { - trigs[1]._tx = 49; - trigs[1]._ty = 21; - trigs[1]._tmsg = WM_DIABTOWNWARP; - trigs[1]._tlvl = 5; - trigflag[4] = 2; - trigflag[0] = 1; - } - if (v0 & 2) { - trigflag[1] = 1; - v1 = trigflag[4]++; - trigs[v1]._tx = 17; - trigs[v1]._ty = 69; - trigs[v1]._tmsg = WM_DIABTOWNWARP; - trigs[v1]._tlvl = 9; - } - if (v0 & 4) { - trigflag[2] = 1; - v2 = trigflag[4]++; - trigs[v2]._tx = 41; - trigs[v2]._ty = 80; - trigs[v2]._tmsg = WM_DIABTOWNWARP; - trigs[v2]._tlvl = 13; - } - } - trigflag[3] = 0; + trigs[0]._tx = 25; + trigs[0]._ty = 29; + trigs[0]._tmsg = WM_DIABNEXTLVL; + trigflag[4] = 1; + if (gbMaxPlayers == 4) { + trigs[1]._tx = 49; + trigflag[0] = 1; + trigflag[1] = 1; + trigflag[2] = 1; + trigs[1]._ty = 21; + trigs[1]._tmsg = WM_DIABTOWNWARP; + trigs[1]._tlvl = 5; + trigs[2]._tx = 17; + trigs[2]._ty = 69; + trigs[2]._tmsg = WM_DIABTOWNWARP; + trigs[2]._tlvl = 9; + trigs[3]._tx = 41; + trigs[3]._ty = 80; + trigs[3]._tmsg = WM_DIABTOWNWARP; + trigs[3]._tlvl = 13; + trigflag[4] = 4; + } else { + trigflag[0] = 0; + trigflag[1] = 0; + trigflag[2] = 0; + v0 = plr[myplr].pTownWarps; + if (v0 & 1) { + trigs[1]._tx = 49; + trigs[1]._ty = 21; + trigs[1]._tmsg = WM_DIABTOWNWARP; + trigs[1]._tlvl = 5; + trigflag[4] = 2; + trigflag[0] = 1; + } + if (v0 & 2) { + trigflag[1] = 1; + v1 = trigflag[4]++; + trigs[v1]._tx = 17; + trigs[v1]._ty = 69; + trigs[v1]._tmsg = WM_DIABTOWNWARP; + trigs[v1]._tlvl = 9; + } + if (v0 & 4) { + trigflag[2] = 1; + v2 = trigflag[4]++; + trigs[v2]._tx = 41; + trigs[v2]._ty = 80; + trigs[v2]._tmsg = WM_DIABTOWNWARP; + trigs[v2]._tlvl = 13; + } + } + trigflag[3] = 0; } // 679660: using guessed type char gbMaxPlayers; void __cdecl InitL1Triggers() { - int v0; // edi - signed int v1; // esi - int *v2; // edx - int *v3; // ecx - TriggerStruct *v4; // eax - int(*v5)[112]; // [esp+Ch] [ebp-8h] - int(*v6)[112]; // [esp+10h] [ebp-4h] + int v0; // edi + signed int v1; // esi + int *v2; // edx + int *v3; // ecx + TriggerStruct *v4; // eax + int(*v5)[112]; // [esp+Ch] [ebp-8h] + int(*v6)[112]; // [esp+10h] [ebp-4h] - v0 = 0; - trigflag[4] = 0; - v5 = dPiece; - do { - v1 = 0; - v6 = v5; - v2 = &trigs[trigflag[4]]._tmsg; - v3 = &trigs[trigflag[4]]._ty; - v4 = &trigs[trigflag[4]]; - do { - if ((*v6)[0] == 129) { - ++trigflag[4]; - v4->_tx = v1; - *v3 = v0; - *v2 = WM_DIABPREVLVL; - ++v4; - v3 += 4; - v2 += 4; - } - if ((*v6)[0] == 115) { - ++trigflag[4]; - v4->_tx = v1; - *v3 = v0; - *v2 = WM_DIABNEXTLVL; - ++v4; - v3 += 4; - v2 += 4; - } - ++v6; - ++v1; - } while (v1 < 112); - v5 = (int(*)[112])((char *)v5 + 4); - ++v0; - } while ((signed int)v5 < (signed int)dPiece[1]); - trigflag[3] = 0; + v0 = 0; + trigflag[4] = 0; + v5 = dPiece; + do { + v1 = 0; + v6 = v5; + v2 = &trigs[trigflag[4]]._tmsg; + v3 = &trigs[trigflag[4]]._ty; + v4 = &trigs[trigflag[4]]; + do { + if ((*v6)[0] == 129) { + ++trigflag[4]; + v4->_tx = v1; + *v3 = v0; + *v2 = WM_DIABPREVLVL; + ++v4; + v3 += 4; + v2 += 4; + } + if ((*v6)[0] == 115) { + ++trigflag[4]; + v4->_tx = v1; + *v3 = v0; + *v2 = WM_DIABNEXTLVL; + ++v4; + v3 += 4; + v2 += 4; + } + ++v6; + ++v1; + } while (v1 < 112); + v5 = (int(*)[112])((char *)v5 + 4); + ++v0; + } while ((signed int)v5 < (signed int)dPiece[1]); + trigflag[3] = 0; } void __cdecl InitL2Triggers() { - signed int v0; // edi - int *v1; // esi - int *v2; // edx - TriggerStruct *v3; // ecx - int *v4; // eax - int(*v5)[112]; // [esp+Ch] [ebp-10h] - int(*v6)[112]; // [esp+10h] [ebp-Ch] - int v7; // [esp+14h] [ebp-8h] - int *v8; // [esp+18h] [ebp-4h] + signed int v0; // edi + int *v1; // esi + int *v2; // edx + TriggerStruct *v3; // ecx + int *v4; // eax + int(*v5)[112]; // [esp+Ch] [ebp-10h] + int(*v6)[112]; // [esp+10h] [ebp-Ch] + int v7; // [esp+14h] [ebp-8h] + int *v8; // [esp+18h] [ebp-4h] - trigflag[4] = 0; - v7 = 0; - v5 = dPiece; - do { - v0 = 0; - v1 = &trigs[trigflag[4]]._tmsg; - v2 = &trigs[trigflag[4]]._ty; - v3 = &trigs[trigflag[4]]; - v8 = &trigs[trigflag[4]]._tlvl; - v6 = v5; - do { - if ((*v6)[0] == 267 && (v0 != quests[QTYPE_BONE]._qtx || v7 != quests[QTYPE_BONE]._qty)) { - ++trigflag[4]; - v8 += 4; - v3->_tx = v0; - *v2 = v7; - *v1 = WM_DIABPREVLVL; - ++v3; - v2 += 4; - v1 += 4; - } - if ((*v6)[0] == 559) { - v3->_tx = v0; - *v2 = v7; - v4 = v8; - v8 += 4; - *v1 = WM_DIABTWARPUP; - *v4 = 0; - ++trigflag[4]; - ++v3; - v2 += 4; - v1 += 4; - } - if ((*v6)[0] == 271) { - ++trigflag[4]; - v8 += 4; - v3->_tx = v0; - *v2 = v7; - *v1 = WM_DIABNEXTLVL; - ++v3; - v2 += 4; - v1 += 4; - } - ++v6; - ++v0; - } while (v0 < 112); - v5 = (int(*)[112])((char *)v5 + 4); - ++v7; - } while ((signed int)v5 < (signed int)dPiece[1]); - trigflag[3] = 0; + trigflag[4] = 0; + v7 = 0; + v5 = dPiece; + do { + v0 = 0; + v1 = &trigs[trigflag[4]]._tmsg; + v2 = &trigs[trigflag[4]]._ty; + v3 = &trigs[trigflag[4]]; + v8 = &trigs[trigflag[4]]._tlvl; + v6 = v5; + do { + if ((*v6)[0] == 267 && (v0 != quests[QTYPE_BONE]._qtx || v7 != quests[QTYPE_BONE]._qty)) { + ++trigflag[4]; + v8 += 4; + v3->_tx = v0; + *v2 = v7; + *v1 = WM_DIABPREVLVL; + ++v3; + v2 += 4; + v1 += 4; + } + if ((*v6)[0] == 559) { + v3->_tx = v0; + *v2 = v7; + v4 = v8; + v8 += 4; + *v1 = WM_DIABTWARPUP; + *v4 = 0; + ++trigflag[4]; + ++v3; + v2 += 4; + v1 += 4; + } + if ((*v6)[0] == 271) { + ++trigflag[4]; + v8 += 4; + v3->_tx = v0; + *v2 = v7; + *v1 = WM_DIABNEXTLVL; + ++v3; + v2 += 4; + v1 += 4; + } + ++v6; + ++v0; + } while (v0 < 112); + v5 = (int(*)[112])((char *)v5 + 4); + ++v7; + } while ((signed int)v5 < (signed int)dPiece[1]); + trigflag[3] = 0; } void __cdecl InitL3Triggers() { - int v0; // edi - signed int v1; // esi - int *v2; // edx - int *v3; // ecx - TriggerStruct *v4; // eax - int(*v5)[112]; // [esp+Ch] [ebp-8h] - int(*v6)[112]; // [esp+10h] [ebp-4h] + int v0; // edi + signed int v1; // esi + int *v2; // edx + int *v3; // ecx + TriggerStruct *v4; // eax + int(*v5)[112]; // [esp+Ch] [ebp-8h] + int(*v6)[112]; // [esp+10h] [ebp-4h] - v0 = 0; - trigflag[4] = 0; - v5 = dPiece; - do { - v1 = 0; - v6 = v5; - v2 = &trigs[trigflag[4]]._tmsg; - v3 = &trigs[trigflag[4]]._ty; - v4 = &trigs[trigflag[4]]; - do { - if ((*v6)[0] == 171) { - ++trigflag[4]; - v4->_tx = v1; - *v3 = v0; - *v2 = WM_DIABPREVLVL; - ++v4; - v3 += 4; - v2 += 4; - } - if ((*v6)[0] == 168) { - ++trigflag[4]; - v4->_tx = v1; - *v3 = v0; - *v2 = WM_DIABNEXTLVL; - ++v4; - v3 += 4; - v2 += 4; - } - if ((*v6)[0] == 549) { - ++trigflag[4]; - v4->_tx = v1; - *v3 = v0; - *v2 = WM_DIABTWARPUP; - ++v4; - v3 += 4; - v2 += 4; - } - ++v6; - ++v1; - } while (v1 < 112); - v5 = (int(*)[112])((char *)v5 + 4); - ++v0; - } while ((signed int)v5 < (signed int)dPiece[1]); - trigflag[3] = 0; + v0 = 0; + trigflag[4] = 0; + v5 = dPiece; + do { + v1 = 0; + v6 = v5; + v2 = &trigs[trigflag[4]]._tmsg; + v3 = &trigs[trigflag[4]]._ty; + v4 = &trigs[trigflag[4]]; + do { + if ((*v6)[0] == 171) { + ++trigflag[4]; + v4->_tx = v1; + *v3 = v0; + *v2 = WM_DIABPREVLVL; + ++v4; + v3 += 4; + v2 += 4; + } + if ((*v6)[0] == 168) { + ++trigflag[4]; + v4->_tx = v1; + *v3 = v0; + *v2 = WM_DIABNEXTLVL; + ++v4; + v3 += 4; + v2 += 4; + } + if ((*v6)[0] == 549) { + ++trigflag[4]; + v4->_tx = v1; + *v3 = v0; + *v2 = WM_DIABTWARPUP; + ++v4; + v3 += 4; + v2 += 4; + } + ++v6; + ++v1; + } while (v1 < 112); + v5 = (int(*)[112])((char *)v5 + 4); + ++v0; + } while ((signed int)v5 < (signed int)dPiece[1]); + trigflag[3] = 0; } void __cdecl InitL4Triggers() { - signed int v0; // edi - int *v1; // esi - int *v2; // edx - TriggerStruct *v3; // ecx - int *v4; // eax - int v5; // edx - int(*v6)[112]; // edi - signed int v7; // ecx - int *v8; // eax - int(*v9)[112]; // [esp+Ch] [ebp-Ch] - int(*v10)[112]; // [esp+Ch] [ebp-Ch] - int v11; // [esp+10h] [ebp-8h] - int(*v12)[112]; // [esp+14h] [ebp-4h] + signed int v0; // edi + int *v1; // esi + int *v2; // edx + TriggerStruct *v3; // ecx + int *v4; // eax + int v5; // edx + int(*v6)[112]; // edi + signed int v7; // ecx + int *v8; // eax + int(*v9)[112]; // [esp+Ch] [ebp-Ch] + int(*v10)[112]; // [esp+Ch] [ebp-Ch] + int v11; // [esp+10h] [ebp-8h] + int(*v12)[112]; // [esp+14h] [ebp-4h] - trigflag[4] = 0; - v11 = 0; - v9 = dPiece; - do { - v0 = 0; - v12 = v9; - v1 = &trigs[trigflag[4]]._tmsg; - v2 = &trigs[trigflag[4]]._ty; - v3 = &trigs[trigflag[4]]; - v4 = &trigs[trigflag[4]]._tlvl; - do { - if ((*v12)[0] == 83) { - ++trigflag[4]; - v3->_tx = v0; - *v2 = v11; - *v1 = WM_DIABPREVLVL; - v4 += 4; - ++v3; - v2 += 4; - v1 += 4; - } - if ((*v12)[0] == 422) { - v3->_tx = v0; - *v2 = v11; - *v1 = WM_DIABTWARPUP; - *v4 = 0; - ++trigflag[4]; - v4 += 4; - ++v3; - v2 += 4; - v1 += 4; - } - if ((*v12)[0] == 120) { - ++trigflag[4]; - v3->_tx = v0; - *v2 = v11; - *v1 = WM_DIABNEXTLVL; - v4 += 4; - ++v3; - v2 += 4; - v1 += 4; - } - ++v12; - ++v0; - } while (v0 < 112); - v9 = (int(*)[112])((char *)v9 + 4); - ++v11; - } while ((signed int)v9 < (signed int)dPiece[1]); - v5 = 0; - v10 = dPiece; - do { - v6 = v10; - v7 = 0; - v8 = &trigs[trigflag[4]]._ty; - do { - if ((*v6)[0] == 370 && quests[QTYPE_VB]._qactive == 3) { - ++trigflag[4]; - *(v8 - 1) = v7; - *v8 = v5; - v8[1] = WM_DIABNEXTLVL; - v8 += 4; - } - ++v7; - ++v6; - } while (v7 < 112); - v10 = (int(*)[112])((char *)v10 + 4); - ++v5; - } while ((signed int)v10 < (signed int)dPiece[1]); - trigflag[3] = 0; + trigflag[4] = 0; + v11 = 0; + v9 = dPiece; + do { + v0 = 0; + v12 = v9; + v1 = &trigs[trigflag[4]]._tmsg; + v2 = &trigs[trigflag[4]]._ty; + v3 = &trigs[trigflag[4]]; + v4 = &trigs[trigflag[4]]._tlvl; + do { + if ((*v12)[0] == 83) { + ++trigflag[4]; + v3->_tx = v0; + *v2 = v11; + *v1 = WM_DIABPREVLVL; + v4 += 4; + ++v3; + v2 += 4; + v1 += 4; + } + if ((*v12)[0] == 422) { + v3->_tx = v0; + *v2 = v11; + *v1 = WM_DIABTWARPUP; + *v4 = 0; + ++trigflag[4]; + v4 += 4; + ++v3; + v2 += 4; + v1 += 4; + } + if ((*v12)[0] == 120) { + ++trigflag[4]; + v3->_tx = v0; + *v2 = v11; + *v1 = WM_DIABNEXTLVL; + v4 += 4; + ++v3; + v2 += 4; + v1 += 4; + } + ++v12; + ++v0; + } while (v0 < 112); + v9 = (int(*)[112])((char *)v9 + 4); + ++v11; + } while ((signed int)v9 < (signed int)dPiece[1]); + v5 = 0; + v10 = dPiece; + do { + v6 = v10; + v7 = 0; + v8 = &trigs[trigflag[4]]._ty; + do { + if ((*v6)[0] == 370 && quests[QTYPE_VB]._qactive == 3) { + ++trigflag[4]; + *(v8 - 1) = v7; + *v8 = v5; + v8[1] = WM_DIABNEXTLVL; + v8 += 4; + } + ++v7; + ++v6; + } while (v7 < 112); + v10 = (int(*)[112])((char *)v10 + 4); + ++v5; + } while ((signed int)v10 < (signed int)dPiece[1]); + trigflag[3] = 0; } void __cdecl InitSKingTriggers() { - trigflag[3] = 0; - trigflag[4] = 1; - trigs[0]._tx = 82; - trigs[0]._ty = 42; - trigs[0]._tmsg = WM_DIABRTNLVL; + trigflag[3] = 0; + trigflag[4] = 1; + trigs[0]._tx = 82; + trigs[0]._ty = 42; + trigs[0]._tmsg = WM_DIABRTNLVL; } void __cdecl InitSChambTriggers() { - trigflag[3] = 0; - trigflag[4] = 1; - trigs[0]._tx = 70; - trigs[0]._ty = 39; - trigs[0]._tmsg = WM_DIABRTNLVL; + trigflag[3] = 0; + trigflag[4] = 1; + trigs[0]._tx = 70; + trigs[0]._ty = 39; + trigs[0]._tmsg = WM_DIABRTNLVL; } void __cdecl InitPWaterTriggers() { - trigflag[3] = 0; - trigflag[4] = 1; - trigs[0]._tx = 30; - trigs[0]._ty = 83; - trigs[0]._tmsg = WM_DIABRTNLVL; + trigflag[3] = 0; + trigflag[4] = 1; + trigs[0]._tx = 30; + trigs[0]._ty = 83; + trigs[0]._tmsg = WM_DIABRTNLVL; } void __cdecl InitVPTriggers() { - trigflag[3] = 0; - trigflag[4] = 1; - trigs[0]._tx = 35; - trigs[0]._ty = 32; - trigs[0]._tmsg = WM_DIABRTNLVL; + trigflag[3] = 0; + trigflag[4] = 1; + trigs[0]._tx = 35; + trigs[0]._ty = 32; + trigs[0]._tmsg = WM_DIABRTNLVL; } unsigned char __cdecl ForceTownTrig() { - int v0; // edx - int *v1; // esi - int v2; // edx - int *v3; // esi - signed int v4; // esi - signed int v5; // edx + int v0; // edx + int *v1; // esi + int v2; // edx + int *v3; // esi + signed int v4; // esi + signed int v5; // edx - v0 = TownDownList[0]; - if (TownDownList[0] != -1) { - v1 = TownDownList; - while (dPiece[0][cursmy + 112 * cursmx] != v0) { - ++v1; - v0 = *v1; - if (*v1 == -1) - goto LABEL_5; - } - strcpy(infostr, "Down to dungeon"); - cursmx = 25; - cursmy = 29; - return 1; - } + v0 = TownDownList[0]; + if (TownDownList[0] != -1) { + v1 = TownDownList; + while (dPiece[0][cursmy + 112 * cursmx] != v0) { + ++v1; + v0 = *v1; + if (*v1 == -1) + goto LABEL_5; + } + strcpy(infostr, "Down to dungeon"); + cursmx = 25; + cursmy = 29; + return 1; + } LABEL_5: - if (trigflag[0]) { - v2 = TownWarp1List[0]; - if (TownWarp1List[0] != -1) { - v3 = TownWarp1List; - while (dPiece[0][cursmy + 112 * cursmx] != v2) { - ++v3; - v2 = *v3; - if (*v3 == -1) - goto LABEL_13; - } - strcpy(infostr, "Down to catacombs"); - cursmx = 49; - cursmy = 21; - return 1; - } - } + if (trigflag[0]) { + v2 = TownWarp1List[0]; + if (TownWarp1List[0] != -1) { + v3 = TownWarp1List; + while (dPiece[0][cursmy + 112 * cursmx] != v2) { + ++v3; + v2 = *v3; + if (*v3 == -1) + goto LABEL_13; + } + strcpy(infostr, "Down to catacombs"); + cursmx = 49; + cursmy = 21; + return 1; + } + } LABEL_13: - if (trigflag[1]) { - v4 = 1199; - while (dPiece[0][cursmy + 112 * cursmx] != v4) { - if (++v4 > 1220) - goto LABEL_17; - } - strcpy(infostr, "Down to caves"); - cursmx = 17; - cursmy = 69; - return 1; - } + if (trigflag[1]) { + v4 = 1199; + while (dPiece[0][cursmy + 112 * cursmx] != v4) { + if (++v4 > 1220) + goto LABEL_17; + } + strcpy(infostr, "Down to caves"); + cursmx = 17; + cursmy = 69; + return 1; + } LABEL_17: - if (trigflag[2]) { - v5 = 1240; - while (dPiece[0][cursmy + 112 * cursmx] != v5) { - if (++v5 > 1255) - return 0; - } - strcpy(infostr, "Down to hell"); - cursmx = 41; - cursmy = 80; - return 1; - } - return 0; + if (trigflag[2]) { + v5 = 1240; + while (dPiece[0][cursmy + 112 * cursmx] != v5) { + if (++v5 > 1255) + return 0; + } + strcpy(infostr, "Down to hell"); + cursmx = 41; + cursmy = 80; + return 1; + } + return 0; } unsigned char __cdecl ForceL1Trig() { - int *v0; // eax - int *v1; // esi - int v2; // eax - int *v3; // edx - int *v4; // eax - int *v5; // esi - int *v6; // edx - int v8; // eax - int v9; // ecx + int *v0; // eax + int *v1; // esi + int v2; // eax + int *v3; // edx + int *v4; // eax + int *v5; // esi + int *v6; // edx + int v8; // eax + int v9; // ecx - if (L1UpList[0] == -1) { - LABEL_12: - if (L1DownList[0] == -1) - return 0; - v4 = L1DownList; - v5 = L1DownList; - while (1) { - if (dPiece[0][cursmy + 112 * cursmx] == *v4) { - sprintf(infostr, "Down to level %i", currlevel + 1); - v2 = 0; - if (trigflag[4] > 0) - break; - } - LABEL_19: - ++v5; - v4 = v5; - if (*v5 == -1) - return 0; - } - v6 = &trigs[0]._tmsg; - while (*v6 != WM_DIABNEXTLVL) { - ++v2; - v6 += 4; - if (v2 >= trigflag[4]) - goto LABEL_19; - } - } else { - v0 = L1UpList; - v1 = L1UpList; - while (1) { - if (dPiece[0][cursmy + 112 * cursmx] == *v0) { - if (currlevel <= 1u) - strcpy(infostr, "Up to town"); - else - sprintf(infostr, "Up to level %i", currlevel - 1); - v2 = 0; - if (trigflag[4] > 0) - break; - } - LABEL_11: - ++v1; - v0 = v1; - if (*v1 == -1) - goto LABEL_12; - } - v3 = &trigs[0]._tmsg; - while (*v3 != WM_DIABPREVLVL) { - ++v2; - v3 += 4; - if (v2 >= trigflag[4]) - goto LABEL_11; - } - } - v8 = v2; - v9 = trigs[v8]._tx; - cursmy = trigs[v8]._ty; - cursmx = v9; - return 1; + if (L1UpList[0] == -1) { + LABEL_12: + if (L1DownList[0] == -1) + return 0; + v4 = L1DownList; + v5 = L1DownList; + while (1) { + if (dPiece[0][cursmy + 112 * cursmx] == *v4) { + sprintf(infostr, "Down to level %i", currlevel + 1); + v2 = 0; + if (trigflag[4] > 0) + break; + } + LABEL_19: + ++v5; + v4 = v5; + if (*v5 == -1) + return 0; + } + v6 = &trigs[0]._tmsg; + while (*v6 != WM_DIABNEXTLVL) { + ++v2; + v6 += 4; + if (v2 >= trigflag[4]) + goto LABEL_19; + } + } else { + v0 = L1UpList; + v1 = L1UpList; + while (1) { + if (dPiece[0][cursmy + 112 * cursmx] == *v0) { + if (currlevel <= 1u) + strcpy(infostr, "Up to town"); + else + sprintf(infostr, "Up to level %i", currlevel - 1); + v2 = 0; + if (trigflag[4] > 0) + break; + } + LABEL_11: + ++v1; + v0 = v1; + if (*v1 == -1) + goto LABEL_12; + } + v3 = &trigs[0]._tmsg; + while (*v3 != WM_DIABPREVLVL) { + ++v2; + v3 += 4; + if (v2 >= trigflag[4]) + goto LABEL_11; + } + } + v8 = v2; + v9 = trigs[v8]._tx; + cursmy = trigs[v8]._ty; + cursmx = v9; + return 1; } unsigned char __cdecl ForceL2Trig() { - int *v0; // eax - int *v1; // ebp - int v2; // edi - TriggerStruct *v3; // esi - int v4; // ebx - int v5; // eax - int *v6; // eax - int *v7; // esi - int v8; // eax - int *v9; // ecx - int v10; // eax - int v11; // ecx - int v12; // eax - int *v13; // eax - int *v14; // ebp - TriggerStruct *v15; // esi - int v16; // ebx - int v17; // eax - int v19; // edi + int *v0; // eax + int *v1; // ebp + int v2; // edi + TriggerStruct *v3; // esi + int v4; // ebx + int v5; // eax + int *v6; // eax + int *v7; // esi + int v8; // eax + int *v9; // ecx + int v10; // eax + int v11; // ecx + int v12; // eax + int *v13; // eax + int *v14; // ebp + TriggerStruct *v15; // esi + int v16; // ebx + int v17; // eax + int v19; // edi - if (L2UpList[0] == -1) { - LABEL_11: - if (L2DownList[0] != -1) { - v6 = L2DownList; - v7 = L2DownList; - while (1) { - if (dPiece[0][cursmy + 112 * cursmx] == *v6) { - sprintf(infostr, "Down to level %i", currlevel + 1); - v8 = 0; - if (trigflag[4] > 0) - break; - } - LABEL_18: - ++v7; - v6 = v7; - if (*v7 == -1) - goto LABEL_22; - } - v9 = &trigs[0]._tmsg; - while (*v9 != WM_DIABNEXTLVL) { - ++v8; - v9 += 4; - if (v8 >= trigflag[4]) - goto LABEL_18; - } - v10 = v8; - v11 = trigs[v10]._tx; - v12 = trigs[v10]._ty; - cursmx = v11; - goto LABEL_37; - } - LABEL_22: - if (currlevel != 5 || L2TWarpUpList[0] == -1) - return 0; - v13 = L2TWarpUpList; - v14 = L2TWarpUpList; - while (1) { - if (dPiece[0][cursmy + 112 * cursmx] == *v13) { - v2 = 0; - if (trigflag[4] > 0) - break; - } - LABEL_32: - ++v14; - v13 = v14; - if (*v14 == -1) - return 0; - } - v15 = trigs; - while (1) { - if (v15->_tmsg == WM_DIABTWARPUP) { - v16 = abs(v15->_tx - cursmx); - v17 = abs(v15->_ty - cursmy); - if (v16 < 4 && v17 < 4) - break; - } - ++v2; - ++v15; - if (v2 >= trigflag[4]) - goto LABEL_32; - } - strcpy(infostr, "Up to town"); - } else { - v0 = L2UpList; - v1 = L2UpList; - while (1) { - if (dPiece[0][cursmy + 112 * cursmx] == *v0) { - v2 = 0; - if (trigflag[4] > 0) - break; - } - LABEL_10: - ++v1; - v0 = v1; - if (*v1 == -1) - goto LABEL_11; - } - v3 = trigs; - while (1) { - if (v3->_tmsg == WM_DIABPREVLVL) { - v4 = abs(v3->_tx - cursmx); - v5 = abs(v3->_ty - cursmy); - if (v4 < 4 && v5 < 4) - break; - } - ++v2; - ++v3; - if (v2 >= trigflag[4]) - goto LABEL_10; - } - sprintf(infostr, "Up to level %i", currlevel - 1); - } - v19 = v2; - cursmx = trigs[v19]._tx; - v12 = trigs[v19]._ty; + if (L2UpList[0] == -1) { + LABEL_11: + if (L2DownList[0] != -1) { + v6 = L2DownList; + v7 = L2DownList; + while (1) { + if (dPiece[0][cursmy + 112 * cursmx] == *v6) { + sprintf(infostr, "Down to level %i", currlevel + 1); + v8 = 0; + if (trigflag[4] > 0) + break; + } + LABEL_18: + ++v7; + v6 = v7; + if (*v7 == -1) + goto LABEL_22; + } + v9 = &trigs[0]._tmsg; + while (*v9 != WM_DIABNEXTLVL) { + ++v8; + v9 += 4; + if (v8 >= trigflag[4]) + goto LABEL_18; + } + v10 = v8; + v11 = trigs[v10]._tx; + v12 = trigs[v10]._ty; + cursmx = v11; + goto LABEL_37; + } + LABEL_22: + if (currlevel != 5 || L2TWarpUpList[0] == -1) + return 0; + v13 = L2TWarpUpList; + v14 = L2TWarpUpList; + while (1) { + if (dPiece[0][cursmy + 112 * cursmx] == *v13) { + v2 = 0; + if (trigflag[4] > 0) + break; + } + LABEL_32: + ++v14; + v13 = v14; + if (*v14 == -1) + return 0; + } + v15 = trigs; + while (1) { + if (v15->_tmsg == WM_DIABTWARPUP) { + v16 = abs(v15->_tx - cursmx); + v17 = abs(v15->_ty - cursmy); + if (v16 < 4 && v17 < 4) + break; + } + ++v2; + ++v15; + if (v2 >= trigflag[4]) + goto LABEL_32; + } + strcpy(infostr, "Up to town"); + } else { + v0 = L2UpList; + v1 = L2UpList; + while (1) { + if (dPiece[0][cursmy + 112 * cursmx] == *v0) { + v2 = 0; + if (trigflag[4] > 0) + break; + } + LABEL_10: + ++v1; + v0 = v1; + if (*v1 == -1) + goto LABEL_11; + } + v3 = trigs; + while (1) { + if (v3->_tmsg == WM_DIABPREVLVL) { + v4 = abs(v3->_tx - cursmx); + v5 = abs(v3->_ty - cursmy); + if (v4 < 4 && v5 < 4) + break; + } + ++v2; + ++v3; + if (v2 >= trigflag[4]) + goto LABEL_10; + } + sprintf(infostr, "Up to level %i", currlevel - 1); + } + v19 = v2; + cursmx = trigs[v19]._tx; + v12 = trigs[v19]._ty; LABEL_37: - cursmy = v12; - return 1; + cursmy = v12; + return 1; } unsigned char __cdecl ForceL3Trig() { - int *v0; // eax - int *v1; // esi - int v2; // eax - int *v3; // ecx - int *v4; // ecx - int *v5; // esi - int v6; // ecx - int v7; // eax - int *v8; // ecx - int *v9; // eax - int *v10; // ebp - int v11; // edi - TriggerStruct *v12; // esi - int v13; // ebx - int v14; // eax - int v15; // eax - int v16; // ecx - int v17; // eax - int v18; // edi + int *v0; // eax + int *v1; // esi + int v2; // eax + int *v3; // ecx + int *v4; // ecx + int *v5; // esi + int v6; // ecx + int v7; // eax + int *v8; // ecx + int *v9; // eax + int *v10; // ebp + int v11; // edi + TriggerStruct *v12; // esi + int v13; // ebx + int v14; // eax + int v15; // eax + int v16; // ecx + int v17; // eax + int v18; // edi - if (L3UpList[0] != -1) { - v0 = L3UpList; - v1 = L3UpList; - while (1) { - if (dPiece[0][cursmy + 112 * cursmx] == *v0) { - sprintf(infostr, "Up to level %i", currlevel - 1); - v2 = 0; - if (trigflag[4] > 0) - break; - } - LABEL_8: - ++v1; - v0 = v1; - if (*v1 == -1) - goto LABEL_9; - } - v3 = &trigs[0]._tmsg; - while (*v3 != WM_DIABPREVLVL) { - ++v2; - v3 += 4; - if (v2 >= trigflag[4]) - goto LABEL_8; - } - goto LABEL_31; - } + if (L3UpList[0] != -1) { + v0 = L3UpList; + v1 = L3UpList; + while (1) { + if (dPiece[0][cursmy + 112 * cursmx] == *v0) { + sprintf(infostr, "Up to level %i", currlevel - 1); + v2 = 0; + if (trigflag[4] > 0) + break; + } + LABEL_8: + ++v1; + v0 = v1; + if (*v1 == -1) + goto LABEL_9; + } + v3 = &trigs[0]._tmsg; + while (*v3 != WM_DIABPREVLVL) { + ++v2; + v3 += 4; + if (v2 >= trigflag[4]) + goto LABEL_8; + } + goto LABEL_31; + } LABEL_9: - if (L3DownList[0] != -1) { - v4 = L3DownList; - v5 = L3DownList; - while (1) { - v6 = *v4; - v7 = cursmy + 112 * cursmx; - if (dPiece[0][v7] == v6 || dPiece[1][v7] == v6 || dPiece[2][v7] == v6) { - sprintf(infostr, "Down to level %i", currlevel + 1); - v2 = 0; - if (trigflag[4] > 0) - break; - } - LABEL_18: - ++v5; - v4 = v5; - if (*v5 == -1) - goto LABEL_19; - } - v8 = &trigs[0]._tmsg; - while (*v8 != WM_DIABNEXTLVL) { - ++v2; - v8 += 4; - if (v2 >= trigflag[4]) - goto LABEL_18; - } - LABEL_31: - v15 = v2; - v16 = trigs[v15]._tx; - v17 = trigs[v15]._ty; - cursmx = v16; - LABEL_33: - cursmy = v17; - return 1; - } + if (L3DownList[0] != -1) { + v4 = L3DownList; + v5 = L3DownList; + while (1) { + v6 = *v4; + v7 = cursmy + 112 * cursmx; + if (dPiece[0][v7] == v6 || dPiece[1][v7] == v6 || dPiece[2][v7] == v6) { + sprintf(infostr, "Down to level %i", currlevel + 1); + v2 = 0; + if (trigflag[4] > 0) + break; + } + LABEL_18: + ++v5; + v4 = v5; + if (*v5 == -1) + goto LABEL_19; + } + v8 = &trigs[0]._tmsg; + while (*v8 != WM_DIABNEXTLVL) { + ++v2; + v8 += 4; + if (v2 >= trigflag[4]) + goto LABEL_18; + } + LABEL_31: + v15 = v2; + v16 = trigs[v15]._tx; + v17 = trigs[v15]._ty; + cursmx = v16; + LABEL_33: + cursmy = v17; + return 1; + } LABEL_19: - if (currlevel == 9 && L3TWarpUpList[0] != -1) { - v9 = L3TWarpUpList; - v10 = L3TWarpUpList; - while (1) { - if (dPiece[0][cursmy + 112 * cursmx] == *v9) { - v11 = 0; - if (trigflag[4] > 0) - break; - } - LABEL_29: - ++v10; - v9 = v10; - if (*v10 == -1) - return 0; - } - v12 = trigs; - while (1) { - if (v12->_tmsg == WM_DIABTWARPUP) { - v13 = abs(v12->_tx - cursmx); - v14 = abs(v12->_ty - cursmy); - if (v13 < 4 && v14 < 4) - break; - } - ++v11; - ++v12; - if (v11 >= trigflag[4]) - goto LABEL_29; - } - strcpy(infostr, "Up to town"); - v18 = v11; - cursmx = trigs[v18]._tx; - v17 = trigs[v18]._ty; - goto LABEL_33; - } - return 0; + if (currlevel == 9 && L3TWarpUpList[0] != -1) { + v9 = L3TWarpUpList; + v10 = L3TWarpUpList; + while (1) { + if (dPiece[0][cursmy + 112 * cursmx] == *v9) { + v11 = 0; + if (trigflag[4] > 0) + break; + } + LABEL_29: + ++v10; + v9 = v10; + if (*v10 == -1) + return 0; + } + v12 = trigs; + while (1) { + if (v12->_tmsg == WM_DIABTWARPUP) { + v13 = abs(v12->_tx - cursmx); + v14 = abs(v12->_ty - cursmy); + if (v13 < 4 && v14 < 4) + break; + } + ++v11; + ++v12; + if (v11 >= trigflag[4]) + goto LABEL_29; + } + strcpy(infostr, "Up to town"); + v18 = v11; + cursmx = trigs[v18]._tx; + v17 = trigs[v18]._ty; + goto LABEL_33; + } + return 0; } unsigned char __cdecl ForceL4Trig() { - int *v0; // eax - int *v1; // esi - int v2; // eax - int *v3; // ecx - int *v4; // eax - int *v5; // esi - int *v6; // ecx - int *v7; // eax - int *v8; // ebp - int v9; // edi - TriggerStruct *v10; // esi - int v11; // ebx - int v12; // eax - int *v13; // eax - int *v14; // esi - int *v15; // edx - int v16; // edi - int v17; // eax - int v18; // eax - int v19; // ecx + int *v0; // eax + int *v1; // esi + int v2; // eax + int *v3; // ecx + int *v4; // eax + int *v5; // esi + int *v6; // ecx + int *v7; // eax + int *v8; // ebp + int v9; // edi + TriggerStruct *v10; // esi + int v11; // ebx + int v12; // eax + int *v13; // eax + int *v14; // esi + int *v15; // edx + int v16; // edi + int v17; // eax + int v18; // eax + int v19; // ecx - if (L4UpList[0] != -1) { - v0 = L4UpList; - v1 = L4UpList; - while (1) { - if (dPiece[0][cursmy + 112 * cursmx] == *v0) { - sprintf(infostr, "Up to level %i", currlevel - 1); - v2 = 0; - if (trigflag[4] > 0) - break; - } - LABEL_8: - ++v1; - v0 = v1; - if (*v1 == -1) - goto LABEL_9; - } - v3 = &trigs[0]._tmsg; - while (*v3 != WM_DIABPREVLVL) { - ++v2; - v3 += 4; - if (v2 >= trigflag[4]) - goto LABEL_8; - } - goto LABEL_39; - } + if (L4UpList[0] != -1) { + v0 = L4UpList; + v1 = L4UpList; + while (1) { + if (dPiece[0][cursmy + 112 * cursmx] == *v0) { + sprintf(infostr, "Up to level %i", currlevel - 1); + v2 = 0; + if (trigflag[4] > 0) + break; + } + LABEL_8: + ++v1; + v0 = v1; + if (*v1 == -1) + goto LABEL_9; + } + v3 = &trigs[0]._tmsg; + while (*v3 != WM_DIABPREVLVL) { + ++v2; + v3 += 4; + if (v2 >= trigflag[4]) + goto LABEL_8; + } + goto LABEL_39; + } LABEL_9: - if (L4DownList[0] != -1) { - v4 = L4DownList; - v5 = L4DownList; - while (1) { - if (dPiece[0][cursmy + 112 * cursmx] == *v4) { - sprintf(infostr, "Down to level %i", currlevel + 1); - v2 = 0; - if (trigflag[4] > 0) - break; - } - LABEL_16: - ++v5; - v4 = v5; - if (*v5 == -1) - goto LABEL_17; - } - v6 = &trigs[0]._tmsg; - while (*v6 != WM_DIABNEXTLVL) { - ++v2; - v6 += 4; - if (v2 >= trigflag[4]) - goto LABEL_16; - } - goto LABEL_39; - } + if (L4DownList[0] != -1) { + v4 = L4DownList; + v5 = L4DownList; + while (1) { + if (dPiece[0][cursmy + 112 * cursmx] == *v4) { + sprintf(infostr, "Down to level %i", currlevel + 1); + v2 = 0; + if (trigflag[4] > 0) + break; + } + LABEL_16: + ++v5; + v4 = v5; + if (*v5 == -1) + goto LABEL_17; + } + v6 = &trigs[0]._tmsg; + while (*v6 != WM_DIABNEXTLVL) { + ++v2; + v6 += 4; + if (v2 >= trigflag[4]) + goto LABEL_16; + } + goto LABEL_39; + } LABEL_17: - if (currlevel == 13) { - if (L4TWarpUpList[0] != -1) { - v7 = L4TWarpUpList; - v8 = L4TWarpUpList; - while (1) { - if (dPiece[0][cursmy + 112 * cursmx] == *v7) { - v9 = 0; - if (trigflag[4] > 0) - break; - } - LABEL_27: - ++v8; - v7 = v8; - if (*v8 == -1) - goto LABEL_28; - } - v10 = trigs; - while (1) { - if (v10->_tmsg == WM_DIABTWARPUP) { - v11 = abs(v10->_tx - cursmx); - v12 = abs(v10->_ty - cursmy); - if (v11 < 4 && v12 < 4) - break; - } - ++v9; - ++v10; - if (v9 >= trigflag[4]) - goto LABEL_27; - } - strcpy(infostr, "Up to town"); - v16 = v9; - cursmx = trigs[v16]._tx; - v17 = trigs[v16]._ty; - goto LABEL_40; - } - } else { - LABEL_28: - if (currlevel == 15 && L4PentaList[0] != -1) { - v13 = L4PentaList; - v14 = L4PentaList; - while (1) { - if (dPiece[0][cursmy + 112 * cursmx] == *v13) { - strcpy(infostr, "Down to Diablo"); - v2 = 0; - if (trigflag[4] > 0) - break; - } - LABEL_36: - ++v14; - v13 = v14; - if (*v14 == -1) - return 0; - } - v15 = &trigs[0]._tmsg; - while (*v15 != WM_DIABNEXTLVL) { - ++v2; - v15 += 4; - if (v2 >= trigflag[4]) - goto LABEL_36; - } - LABEL_39: - v18 = v2; - v19 = trigs[v18]._tx; - v17 = trigs[v18]._ty; - cursmx = v19; - LABEL_40: - cursmy = v17; - return 1; - } - } - return 0; + if (currlevel == 13) { + if (L4TWarpUpList[0] != -1) { + v7 = L4TWarpUpList; + v8 = L4TWarpUpList; + while (1) { + if (dPiece[0][cursmy + 112 * cursmx] == *v7) { + v9 = 0; + if (trigflag[4] > 0) + break; + } + LABEL_27: + ++v8; + v7 = v8; + if (*v8 == -1) + goto LABEL_28; + } + v10 = trigs; + while (1) { + if (v10->_tmsg == WM_DIABTWARPUP) { + v11 = abs(v10->_tx - cursmx); + v12 = abs(v10->_ty - cursmy); + if (v11 < 4 && v12 < 4) + break; + } + ++v9; + ++v10; + if (v9 >= trigflag[4]) + goto LABEL_27; + } + strcpy(infostr, "Up to town"); + v16 = v9; + cursmx = trigs[v16]._tx; + v17 = trigs[v16]._ty; + goto LABEL_40; + } + } else { + LABEL_28: + if (currlevel == 15 && L4PentaList[0] != -1) { + v13 = L4PentaList; + v14 = L4PentaList; + while (1) { + if (dPiece[0][cursmy + 112 * cursmx] == *v13) { + strcpy(infostr, "Down to Diablo"); + v2 = 0; + if (trigflag[4] > 0) + break; + } + LABEL_36: + ++v14; + v13 = v14; + if (*v14 == -1) + return 0; + } + v15 = &trigs[0]._tmsg; + while (*v15 != WM_DIABNEXTLVL) { + ++v2; + v15 += 4; + if (v2 >= trigflag[4]) + goto LABEL_36; + } + LABEL_39: + v18 = v2; + v19 = trigs[v18]._tx; + v17 = trigs[v18]._ty; + cursmx = v19; + LABEL_40: + cursmy = v17; + return 1; + } + } + return 0; } void __cdecl Freeupstairs() { - int *v0; // ecx - int v1; // ebx - char *v2; // eax - signed int v3; // edi - char *v4; // edx - signed int v5; // esi + int *v0; // ecx + int v1; // ebx + char *v2; // eax + signed int v3; // edi + char *v4; // edx + signed int v5; // esi - if (trigflag[4] > 0) { - v0 = &trigs[0]._ty; - v1 = trigflag[4]; - do { - v2 = &dFlags[*(v0 - 1) - 2][*v0 - 2]; /* v2 = &nBlockTable[112 * *(v0 - 1) + 1830 + *v0]; check */ - v3 = 5; - do { - v4 = v2; - v5 = 5; - do { - *v4 |= DFLAG_POPULATED; - v4 += 112; - --v5; - } while (v5); - ++v2; - --v3; - } while (v3); - v0 += 4; - --v1; - } while (v1); - } + if (trigflag[4] > 0) { + v0 = &trigs[0]._ty; + v1 = trigflag[4]; + do { + v2 = &dFlags[*(v0 - 1) - 2][*v0 - 2]; /* v2 = &nBlockTable[112 * *(v0 - 1) + 1830 + *v0]; check */ + v3 = 5; + do { + v4 = v2; + v5 = 5; + do { + *v4 |= DFLAG_POPULATED; + v4 += 112; + --v5; + } while (v5); + ++v2; + --v3; + } while (v3); + v0 += 4; + --v1; + } while (v1); + } } unsigned char __cdecl ForceSKingTrig() { - int v0; // eax - int *v1; // ecx + int v0; // eax + int *v1; // ecx - v0 = L1UpList[0]; - if (L1UpList[0] == -1) - return 0; - v1 = L1UpList; - while (dPiece[0][cursmy + 112 * cursmx] != v0) { - ++v1; - v0 = *v1; - if (*v1 == -1) - return 0; - } - sprintf(infostr, "Back to Level %i", (unsigned char)quests[QTYPE_KING]._qlevel); - cursmx = trigs[0]._tx; - cursmy = trigs[0]._ty; - return 1; + v0 = L1UpList[0]; + if (L1UpList[0] == -1) + return 0; + v1 = L1UpList; + while (dPiece[0][cursmy + 112 * cursmx] != v0) { + ++v1; + v0 = *v1; + if (*v1 == -1) + return 0; + } + sprintf(infostr, "Back to Level %i", (unsigned char)quests[QTYPE_KING]._qlevel); + cursmx = trigs[0]._tx; + cursmy = trigs[0]._ty; + return 1; } unsigned char __cdecl ForceSChambTrig() { - int v0; // eax - int *v1; // ecx + int v0; // eax + int *v1; // ecx - v0 = L2DownList[0]; - if (L2DownList[0] == -1) - return 0; - v1 = L2DownList; - while (dPiece[0][cursmy + 112 * cursmx] != v0) { - ++v1; - v0 = *v1; - if (*v1 == -1) - return 0; - } - sprintf(infostr, "Back to Level %i", (unsigned char)quests[QTYPE_BONE]._qlevel); - cursmx = trigs[0]._tx; - cursmy = trigs[0]._ty; - return 1; + v0 = L2DownList[0]; + if (L2DownList[0] == -1) + return 0; + v1 = L2DownList; + while (dPiece[0][cursmy + 112 * cursmx] != v0) { + ++v1; + v0 = *v1; + if (*v1 == -1) + return 0; + } + sprintf(infostr, "Back to Level %i", (unsigned char)quests[QTYPE_BONE]._qlevel); + cursmx = trigs[0]._tx; + cursmy = trigs[0]._ty; + return 1; } unsigned char __cdecl ForcePWaterTrig() { - int v0; // eax - int *v1; // ecx + int v0; // eax + int *v1; // ecx - v0 = L3DownList[0]; - if (L3DownList[0] == -1) - return 0; - v1 = L3DownList; - while (dPiece[0][cursmy + 112 * cursmx] != v0) { - ++v1; - v0 = *v1; - if (*v1 == -1) - return 0; - } - sprintf(infostr, "Back to Level %i", (unsigned char)quests[QTYPE_PW]._qlevel); - cursmx = trigs[0]._tx; - cursmy = trigs[0]._ty; - return 1; + v0 = L3DownList[0]; + if (L3DownList[0] == -1) + return 0; + v1 = L3DownList; + while (dPiece[0][cursmy + 112 * cursmx] != v0) { + ++v1; + v0 = *v1; + if (*v1 == -1) + return 0; + } + sprintf(infostr, "Back to Level %i", (unsigned char)quests[QTYPE_PW]._qlevel); + cursmx = trigs[0]._tx; + cursmy = trigs[0]._ty; + return 1; } void __cdecl CheckTrigForce() { - int v0; // eax - int v1; // eax + int v0; // eax + int v1; // eax - trigflag[3] = 0; - if (MouseY <= 351) { - if (setlevel) { - switch (setlvlnum) { - case SL_SKELKING: - v1 = ForceSKingTrig(); - break; - case SL_BONECHAMB: - v1 = ForceSChambTrig(); - break; - case SL_POISONWATER: - v1 = ForcePWaterTrig(); - break; - default: - return; - } - goto LABEL_23; - } - if (leveltype) { - switch (leveltype) { - case DTYPE_CATHEDRAL: - v0 = ForceL1Trig(); - break; - case DTYPE_CATACOMBS: - v0 = ForceL2Trig(); - break; - case DTYPE_CAVES: - v0 = ForceL3Trig(); - break; - case DTYPE_HELL: - v0 = ForceL4Trig(); - break; - default: - LABEL_14: - if (leveltype == DTYPE_TOWN) - goto LABEL_24; - if (trigflag[3]) { - LABEL_25: - ClearPanel(); - return; - } - v1 = ForceQuests(); - LABEL_23: - trigflag[3] = v1; - LABEL_24: - if (!trigflag[3]) - return; - goto LABEL_25; - } - } else { - v0 = ForceTownTrig(); - } - trigflag[3] = v0; - goto LABEL_14; - } + trigflag[3] = 0; + if (MouseY <= 351) { + if (setlevel) { + switch (setlvlnum) { + case SL_SKELKING: + v1 = ForceSKingTrig(); + break; + case SL_BONECHAMB: + v1 = ForceSChambTrig(); + break; + case SL_POISONWATER: + v1 = ForcePWaterTrig(); + break; + default: + return; + } + goto LABEL_23; + } + if (leveltype) { + switch (leveltype) { + case DTYPE_CATHEDRAL: + v0 = ForceL1Trig(); + break; + case DTYPE_CATACOMBS: + v0 = ForceL2Trig(); + break; + case DTYPE_CAVES: + v0 = ForceL3Trig(); + break; + case DTYPE_HELL: + v0 = ForceL4Trig(); + break; + default: + LABEL_14: + if (leveltype == DTYPE_TOWN) + goto LABEL_24; + if (trigflag[3]) { + LABEL_25: + ClearPanel(); + return; + } + v1 = ForceQuests(); + LABEL_23: + trigflag[3] = v1; + LABEL_24: + if (!trigflag[3]) + return; + goto LABEL_25; + } + } else { + v0 = ForceTownTrig(); + } + trigflag[3] = v0; + goto LABEL_14; + } } // 5CF31D: using guessed type char setlevel; void __cdecl CheckTriggers() { - int *v0; // edi - int v1; // esi - int v2; // ecx - int v3; // eax - int v4; // edx - signed int v5; // edx - int v6; // eax - int v9; // [esp-4h] [ebp-20h] - int x; // [esp+Ch] [ebp-10h] - int y; // [esp+10h] [ebp-Ch] - int v12; // [esp+14h] [ebp-8h] - int error_id; // [esp+1Bh] [ebp-1h] + int *v0; // edi + int v1; // esi + int v2; // ecx + int v3; // eax + int v4; // edx + signed int v5; // edx + int v6; // eax + int v9; // [esp-4h] [ebp-20h] + int x; // [esp+Ch] [ebp-10h] + int y; // [esp+10h] [ebp-Ch] + int v12; // [esp+14h] [ebp-8h] + int error_id; // [esp+1Bh] [ebp-1h] - if (plr[myplr]._pmode) - return; - v12 = 0; - if (trigflag[4] <= 0) - return; - v0 = &trigs[0]._tmsg; - while (1) { - v1 = myplr; - v2 = plr[myplr].WorldX; - if (v2 != *(v0 - 2)) - goto LABEL_34; - v3 = plr[v1].WorldY; - if (v3 != *(v0 - 1)) - goto LABEL_34; - v4 = *v0; - if (*v0 == WM_DIABNEXTLVL) { - if (pcurs >= CURSOR_FIRSTITEM && DropItemBeforeTrig()) - return; - v6 = currlevel + 1; - goto LABEL_32; - } - if (*v0 == WM_DIABPREVLVL) { - if (pcurs >= CURSOR_FIRSTITEM && DropItemBeforeTrig()) - return; - v6 = currlevel - 1; - LABEL_32: - v9 = v6; - goto LABEL_33; - } - if (*v0 != WM_DIABRTNLVL) - break; - StartNewLvl(myplr, v4, ReturnLvl); - LABEL_34: - ++v12; - v0 += 4; - if (v12 >= trigflag[4]) - return; - } - if (*v0 != WM_DIABTOWNWARP) { - if (*v0 == WM_DIABTWARPUP) { - TWarpFrom = currlevel; - StartNewLvl(myplr, v4, 0); - } else { - TermMsg("Unknown trigger msg"); - } - goto LABEL_34; - } - if (gbMaxPlayers == 1) - goto LABEL_46; - v5 = 0; - if (v0[1] == 5 && plr[v1]._pLevel < 8) { - v5 = 1; - x = plr[myplr].WorldX; - _LOBYTE(y) = v3 + 1; - _LOBYTE(error_id) = EMSG_REQUIRES_LVL_8; - } - if (v0[1] == 9 && plr[v1]._pLevel < 13) { - v5 = 1; - _LOBYTE(x) = v2 + 1; - y = plr[v1].WorldY; - _LOBYTE(error_id) = EMSG_REQUIRES_LVL_13; - } - if (v0[1] == 13 && plr[v1]._pLevel < 17) { - x = plr[myplr].WorldX; - v5 = 1; - _LOBYTE(y) = v3 + 1; - _LOBYTE(error_id) = EMSG_REQUIRES_LVL_17; - } - if (!v5) { - LABEL_46: - v9 = v0[1]; - LABEL_33: - StartNewLvl(myplr, *v0, v9); - goto LABEL_34; - } - switch (plr[myplr]._pClass) { - case PC_WARRIOR: - PlaySFX(PS_WARR43); - break; - case PC_ROGUE: - PlaySFX(PS_ROGUE43); - break; - case PC_SORCERER: - PlaySFX(PS_MAGE43); - break; - } - _LOBYTE(v2) = error_id; - InitDiabloMsg(v2); - NetSendCmdLoc(TRUE, CMD_WALKXY, x, y); + if (plr[myplr]._pmode) + return; + v12 = 0; + if (trigflag[4] <= 0) + return; + v0 = &trigs[0]._tmsg; + while (1) { + v1 = myplr; + v2 = plr[myplr].WorldX; + if (v2 != *(v0 - 2)) + goto LABEL_34; + v3 = plr[v1].WorldY; + if (v3 != *(v0 - 1)) + goto LABEL_34; + v4 = *v0; + if (*v0 == WM_DIABNEXTLVL) { + if (pcurs >= CURSOR_FIRSTITEM && DropItemBeforeTrig()) + return; + v6 = currlevel + 1; + goto LABEL_32; + } + if (*v0 == WM_DIABPREVLVL) { + if (pcurs >= CURSOR_FIRSTITEM && DropItemBeforeTrig()) + return; + v6 = currlevel - 1; + LABEL_32: + v9 = v6; + goto LABEL_33; + } + if (*v0 != WM_DIABRTNLVL) + break; + StartNewLvl(myplr, v4, ReturnLvl); + LABEL_34: + ++v12; + v0 += 4; + if (v12 >= trigflag[4]) + return; + } + if (*v0 != WM_DIABTOWNWARP) { + if (*v0 == WM_DIABTWARPUP) { + TWarpFrom = currlevel; + StartNewLvl(myplr, v4, 0); + } else { + TermMsg("Unknown trigger msg"); + } + goto LABEL_34; + } + if (gbMaxPlayers == 1) + goto LABEL_46; + v5 = 0; + if (v0[1] == 5 && plr[v1]._pLevel < 8) { + v5 = 1; + x = plr[myplr].WorldX; + _LOBYTE(y) = v3 + 1; + _LOBYTE(error_id) = EMSG_REQUIRES_LVL_8; + } + if (v0[1] == 9 && plr[v1]._pLevel < 13) { + v5 = 1; + _LOBYTE(x) = v2 + 1; + y = plr[v1].WorldY; + _LOBYTE(error_id) = EMSG_REQUIRES_LVL_13; + } + if (v0[1] == 13 && plr[v1]._pLevel < 17) { + x = plr[myplr].WorldX; + v5 = 1; + _LOBYTE(y) = v3 + 1; + _LOBYTE(error_id) = EMSG_REQUIRES_LVL_17; + } + if (!v5) { + LABEL_46: + v9 = v0[1]; + LABEL_33: + StartNewLvl(myplr, *v0, v9); + goto LABEL_34; + } + switch (plr[myplr]._pClass) { + case PC_WARRIOR: + PlaySFX(PS_WARR43); + break; + case PC_ROGUE: + PlaySFX(PS_ROGUE43); + break; + case PC_SORCERER: + PlaySFX(PS_MAGE43); + break; + } + _LOBYTE(v2) = error_id; + InitDiabloMsg(v2); + NetSendCmdLoc(TRUE, CMD_WALKXY, x, y); } // 679660: using guessed type char gbMaxPlayers; // 6ABB30: using guessed type int TWarpFrom; diff --git a/Source/wave.cpp b/Source/wave.cpp index 7240a9bd..f08f3dcf 100644 --- a/Source/wave.cpp +++ b/Source/wave.cpp @@ -6,212 +6,212 @@ static float wave_cpp_init_value = INFINITY; BOOL __fastcall WCloseFile(HANDLE file) { - return SFileCloseFile(file); + return SFileCloseFile(file); } LONG __fastcall WGetFileSize(HANDLE hsFile, DWORD *lpFileSizeHigh) { - unsigned int retry = 0; - LONG ret; + unsigned int retry = 0; + LONG ret; - while ((ret = SFileGetFileSize(hsFile, lpFileSizeHigh)) == 0) - WGetFileArchive(hsFile, &retry, NULL); + while ((ret = SFileGetFileSize(hsFile, lpFileSizeHigh)) == 0) + WGetFileArchive(hsFile, &retry, NULL); - return ret; + return ret; } void __fastcall WGetFileArchive(HANDLE hsFile, unsigned int *retries, const char *FileName) { - HANDLE archive; + HANDLE archive; - if (*retries >= 5) - FileErrDlg(FileName); + if (*retries >= 5) + FileErrDlg(FileName); - if (hsFile && SFileGetFileArchive(hsFile, &archive) && archive != diabdat_mpq) { - Sleep(20); - (*retries)++; - } else if (!InsertCDDlg()) - FileErrDlg(FileName); + if (hsFile && SFileGetFileArchive(hsFile, &archive) && archive != diabdat_mpq) { + Sleep(20); + (*retries)++; + } else if (!InsertCDDlg()) + FileErrDlg(FileName); } BOOL __fastcall WOpenFile(const char *FileName, HANDLE *phsFile, BOOL mayNotExist) { - unsigned int retry = 0; + unsigned int retry = 0; - while (1) { - if (SFileOpenFile(FileName, phsFile)) - return TRUE; - if (mayNotExist && SErrGetLastError() == ERROR_FILE_NOT_FOUND) - break; - WGetFileArchive(NULL, &retry, FileName); - } - return FALSE; + while (1) { + if (SFileOpenFile(FileName, phsFile)) + return TRUE; + if (mayNotExist && SErrGetLastError() == ERROR_FILE_NOT_FOUND) + break; + WGetFileArchive(NULL, &retry, FileName); + } + return FALSE; } void __fastcall WReadFile(HANDLE hsFile, LPVOID buf, DWORD to_read) { - unsigned int retry = 0; - DWORD readed; - int initial_pos = WSetFilePointer(hsFile, 0, NULL, FILE_CURRENT); + unsigned int retry = 0; + DWORD readed; + int initial_pos = WSetFilePointer(hsFile, 0, NULL, FILE_CURRENT); - while (!SFileReadFile(hsFile, buf, to_read, &readed, NULL)) { - WGetFileArchive(hsFile, &retry, NULL); - WSetFilePointer(hsFile, initial_pos, NULL, FILE_BEGIN); - } + while (!SFileReadFile(hsFile, buf, to_read, &readed, NULL)) { + WGetFileArchive(hsFile, &retry, NULL); + WSetFilePointer(hsFile, initial_pos, NULL, FILE_BEGIN); + } } int __fastcall WSetFilePointer(HANDLE file1, int offset, HANDLE file2, int whence) { - unsigned int retry = 0; - int result; + unsigned int retry = 0; + int result; - while (1) { - result = SFileSetFilePointer(file1, offset, file2, whence); - if (result != -1) - break; - WGetFileArchive(file1, &retry, NULL); - } - return result; + while (1) { + result = SFileSetFilePointer(file1, offset, file2, whence); + if (result != -1) + break; + WGetFileArchive(file1, &retry, NULL); + } + return result; } BOOL __fastcall LoadWaveFormat(HANDLE hsFile, WAVEFORMATEX *pwfx) { - BOOL ret; - MEMFILE wave_file; + BOOL ret; + MEMFILE wave_file; - AllocateMemFile(hsFile, &wave_file, 0); - ret = ReadWaveFile(&wave_file, pwfx, NULL); - FreeMemFile(&wave_file); - return ret; + AllocateMemFile(hsFile, &wave_file, 0); + ret = ReadWaveFile(&wave_file, pwfx, NULL); + FreeMemFile(&wave_file); + return ret; } void *__fastcall AllocateMemFile(HANDLE hsFile, MEMFILE *pMemFile, DWORD dwPos) { - DWORD length; + DWORD length; - memset(pMemFile, 0, sizeof(*pMemFile)); - pMemFile->end = WGetFileSize(hsFile, NULL); - length = 4096; - if (dwPos > length) - length = dwPos; - pMemFile->buf_len = length; - if (length >= pMemFile->end) - length = pMemFile->end; - pMemFile->buf_len = length; - pMemFile->buf = DiabloAllocPtr(length); - pMemFile->file = hsFile; - return pMemFile->buf; + memset(pMemFile, 0, sizeof(*pMemFile)); + pMemFile->end = WGetFileSize(hsFile, NULL); + length = 4096; + if (dwPos > length) + length = dwPos; + pMemFile->buf_len = length; + if (length >= pMemFile->end) + length = pMemFile->end; + pMemFile->buf_len = length; + pMemFile->buf = DiabloAllocPtr(length); + pMemFile->file = hsFile; + return pMemFile->buf; } void __fastcall FreeMemFile(MEMFILE *pMemFile) { - void *mem = pMemFile->buf; - pMemFile->buf = NULL; - mem_free_dbg(mem); + void *mem = pMemFile->buf; + pMemFile->buf = NULL; + mem_free_dbg(mem); } BOOL __fastcall ReadWaveFile(MEMFILE *pMemFile, WAVEFORMATEX *pwfx, CKINFO *chunk) { - MMCKINFO hdr; - CKINFO fmt; - PCMWAVEFORMAT wf; + MMCKINFO hdr; + CKINFO fmt; + PCMWAVEFORMAT wf; - if (!ReadMemFile(pMemFile, &hdr, 12)) - return FALSE; - if (hdr.ckid != FOURCC_RIFF || hdr.fccType != MAKEFOURCC('W', 'A', 'V', 'E')) - return FALSE; - if (!ReadWaveSection(pMemFile, MAKEFOURCC('f', 'm', 't', ' '), &fmt)) - return FALSE; - if (fmt.dwSize < sizeof(PCMWAVEFORMAT)) - return FALSE; - if (!ReadMemFile(pMemFile, &wf, sizeof(wf))) - return FALSE; - if (SeekMemFile(pMemFile, fmt.dwSize - sizeof(wf), FILE_CURRENT) == -1) - return FALSE; + if (!ReadMemFile(pMemFile, &hdr, 12)) + return FALSE; + if (hdr.ckid != FOURCC_RIFF || hdr.fccType != MAKEFOURCC('W', 'A', 'V', 'E')) + return FALSE; + if (!ReadWaveSection(pMemFile, MAKEFOURCC('f', 'm', 't', ' '), &fmt)) + return FALSE; + if (fmt.dwSize < sizeof(PCMWAVEFORMAT)) + return FALSE; + if (!ReadMemFile(pMemFile, &wf, sizeof(wf))) + return FALSE; + if (SeekMemFile(pMemFile, fmt.dwSize - sizeof(wf), FILE_CURRENT) == -1) + return FALSE; - pwfx->cbSize = 0; - pwfx->wFormatTag = wf.wf.wFormatTag; - pwfx->nChannels = wf.wf.nChannels; - pwfx->nSamplesPerSec = wf.wf.nSamplesPerSec; - pwfx->nAvgBytesPerSec = wf.wf.nAvgBytesPerSec; - pwfx->nBlockAlign = wf.wf.nBlockAlign; - pwfx->wBitsPerSample = wf.wBitsPerSample; - if (chunk == NULL) - return TRUE; - return ReadWaveSection(pMemFile, MAKEFOURCC('d', 'a', 't', 'a'), chunk); + pwfx->cbSize = 0; + pwfx->wFormatTag = wf.wf.wFormatTag; + pwfx->nChannels = wf.wf.nChannels; + pwfx->nSamplesPerSec = wf.wf.nSamplesPerSec; + pwfx->nAvgBytesPerSec = wf.wf.nAvgBytesPerSec; + pwfx->nBlockAlign = wf.wf.nBlockAlign; + pwfx->wBitsPerSample = wf.wBitsPerSample; + if (chunk == NULL) + return TRUE; + return ReadWaveSection(pMemFile, MAKEFOURCC('d', 'a', 't', 'a'), chunk); } BOOL __fastcall ReadMemFile(MEMFILE *pMemFile, void *lpBuf, size_t length) { - while (length) { - size_t to_copy; - if (!pMemFile->bytes_to_read) - FillMemFile(pMemFile); - to_copy = pMemFile->bytes_to_read; - if (length < to_copy) - to_copy = length; - if (!to_copy) - return FALSE; - memcpy(lpBuf, &pMemFile->buf[pMemFile->dist], to_copy); - pMemFile->offset += to_copy; - pMemFile->dist += to_copy; - pMemFile->bytes_to_read -= to_copy; - // BUGFIX: lpBuf is not incremented, next read will overwrite data - length -= to_copy; - } - return TRUE; + while (length) { + size_t to_copy; + if (!pMemFile->bytes_to_read) + FillMemFile(pMemFile); + to_copy = pMemFile->bytes_to_read; + if (length < to_copy) + to_copy = length; + if (!to_copy) + return FALSE; + memcpy(lpBuf, &pMemFile->buf[pMemFile->dist], to_copy); + pMemFile->offset += to_copy; + pMemFile->dist += to_copy; + pMemFile->bytes_to_read -= to_copy; + // BUGFIX: lpBuf is not incremented, next read will overwrite data + length -= to_copy; + } + return TRUE; } void __fastcall FillMemFile(MEMFILE *pMemFile) { - DWORD to_read; - WSetFilePointer(pMemFile->file, pMemFile->offset, NULL, FILE_BEGIN); - to_read = pMemFile->end - pMemFile->offset; - if (pMemFile->buf_len < to_read) - to_read = pMemFile->buf_len; - if (to_read) - WReadFile(pMemFile->file, pMemFile->buf, to_read); - pMemFile->dist = 0; - pMemFile->bytes_to_read = to_read; + DWORD to_read; + WSetFilePointer(pMemFile->file, pMemFile->offset, NULL, FILE_BEGIN); + to_read = pMemFile->end - pMemFile->offset; + if (pMemFile->buf_len < to_read) + to_read = pMemFile->buf_len; + if (to_read) + WReadFile(pMemFile->file, pMemFile->buf, to_read); + pMemFile->dist = 0; + pMemFile->bytes_to_read = to_read; } int __fastcall SeekMemFile(MEMFILE *pMemFile, LONG lDist, DWORD dwMethod) { - if (lDist < pMemFile->bytes_to_read) { - pMemFile->bytes_to_read -= lDist; - pMemFile->dist += lDist; - } else - pMemFile->bytes_to_read = 0; - pMemFile->offset += lDist; - return pMemFile->offset; + if (lDist < pMemFile->bytes_to_read) { + pMemFile->bytes_to_read -= lDist; + pMemFile->dist += lDist; + } else + pMemFile->bytes_to_read = 0; + pMemFile->offset += lDist; + return pMemFile->offset; } BOOL __fastcall ReadWaveSection(MEMFILE *pMemFile, DWORD id, CKINFO *chunk) { - DWORD hdr[2]; + DWORD hdr[2]; - while (1) { - if (!ReadMemFile(pMemFile, hdr, sizeof(hdr))) - return FALSE; - if (hdr[0] == id) - break; - if (SeekMemFile(pMemFile, hdr[1], FILE_CURRENT) == -1) - return FALSE; - } + while (1) { + if (!ReadMemFile(pMemFile, hdr, sizeof(hdr))) + return FALSE; + if (hdr[0] == id) + break; + if (SeekMemFile(pMemFile, hdr[1], FILE_CURRENT) == -1) + return FALSE; + } - chunk->dwSize = hdr[1]; - chunk->dwOffset = SeekMemFile(pMemFile, 0, FILE_CURRENT); - return chunk->dwOffset != (DWORD)-1; + chunk->dwSize = hdr[1]; + chunk->dwOffset = SeekMemFile(pMemFile, 0, FILE_CURRENT); + return chunk->dwOffset != (DWORD)-1; } void *__fastcall LoadWaveFile(HANDLE hsFile, WAVEFORMATEX *pwfx, CKINFO *chunk) { - MEMFILE wave_file; + MEMFILE wave_file; - AllocateMemFile(hsFile, &wave_file, (DWORD)-1); - if (!ReadWaveFile(&wave_file, pwfx, chunk)) { - FreeMemFile(&wave_file); - return NULL; - } - return wave_file.buf; + AllocateMemFile(hsFile, &wave_file, (DWORD)-1); + if (!ReadWaveFile(&wave_file, pwfx, chunk)) { + FreeMemFile(&wave_file); + return NULL; + } + return wave_file.buf; }