From 1e4e826a369bb0bc7ddcfc00dd9e067064313e82 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Wed, 23 Jan 2019 17:11:52 +0100 Subject: [PATCH] Remove delta to devilution --- Source/appfat.cpp | 826 +++++++++++++++++++-------------------- Source/codec.cpp | 12 - Source/debug.cpp | 2 - Source/diablo.cpp | 2 - Source/drlg_l1.cpp | 2 - Source/drlg_l2.cpp | 2 - Source/drlg_l4.cpp | 2 - Source/effects.cpp | 4 +- Source/engine.cpp | 12 - Source/gendung.cpp | 2 - Source/init.h | 1 - Source/interfac.cpp | 2 +- Source/lighting.cpp | 2 - Source/mainmenu.cpp | 2 - Source/nthread.cpp | 12 +- Source/path.cpp | 2 - Source/pfile.cpp | 15 +- Source/pfile.h | 6 - Source/portal.cpp | 2 - Source/render.cpp | 2 - Source/sha.cpp | 2 - Source/sync.cpp | 2 - Source/towners.cpp | 2 - Source/trigs.cpp | 2 - Stub/diablo.cpp | 3 - Stub/diabloui.cpp | 2 +- Stub/miniwin_msg_sdl.cpp | 5 +- Stub/sdlrender.cpp | 1 + Stub/sdlrender.h | 1 + 29 files changed, 425 insertions(+), 507 deletions(-) diff --git a/Source/appfat.cpp b/Source/appfat.cpp index 94ab89aae..7f74667c2 100644 --- a/Source/appfat.cpp +++ b/Source/appfat.cpp @@ -1,413 +1,413 @@ -//HEADER_GOES_HERE - -#include "../types.h" - -char sz_error_buf[256]; -int terminating; // weak -int cleanup_thread_id; // weak - -// delete overloads the delete operator. -//void operator delete(void *ptr) -//{ -// 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 - - 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; - -void __fastcall TraceErrorDD(int error_code, char *error_buf, int error_buf_len) -{ - 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); -} - -void __fastcall TraceErrorDS(int error_code, char *error_buf, int error_buf_len) -{ - 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); -} - -char *__cdecl TraceLastError() -{ - int v0; // eax - - v0 = GetLastError(); - return GetErrorStr(v0); -} - -void TermMsg(char *pszFmt, ...) -{ - 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); -} - -void __fastcall MsgBox(char *pszFmt, va_list va) -{ - 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); -} - -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); -} -// 4B7A34: using guessed type int terminating; -// 4B7A38: using guessed type int cleanup_thread_id; -// 679660: using guessed type char gbMaxPlayers; - -void DrawDlg(char *pszFmt, ...) -{ - 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); -} - -void __fastcall DDErrMsg(int error_code, int log_line_nr, char *log_file_path) -{ - 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); - } -} - -void __fastcall DSErrMsg(int error_code, int log_line_nr, char *log_file_path) -{ - 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); - } -} - -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] - - 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] - - 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; -} - -void __fastcall TextDlg(HWND hDlg, char *text) -{ - char *v2; // esi - HWND v3; // edi - - 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] - - 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 - - v1 = error; - FreeDlg(); - if (!v1) - v1 = ""; - if (DialogBoxParam(ghInst, MAKEINTRESOURCE(IDD_DIALOG3), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)v1) == -1) - TermMsg("FileErrDlg"); - TermMsg(0); -} - -void __fastcall DiskFreeDlg(char *error) -{ - char *v1; // esi - - 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 - - ShowCursor(1); - v0 = DialogBoxParam(ghInst, MAKEINTRESOURCE(IDD_DIALOG9), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM) ""); - if (v0 == -1) - TermMsg("InsertCDDlg"); - ShowCursor(0); - return v0 == 1; -} - -void __fastcall DirErrorDlg(char *error) -{ - char *v1; // esi - - v1 = error; - FreeDlg(); - if (DialogBoxParam(ghInst, MAKEINTRESOURCE(IDD_DIALOG11), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)v1) == -1) - TermMsg("DirErrorDlg"); - TermMsg(0); -} +//HEADER_GOES_HERE + +#include "../types.h" + +char sz_error_buf[256]; +int terminating; // weak +int cleanup_thread_id; // weak + +// delete overloads the delete operator. +//void operator delete(void *ptr) +//{ +// 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 + + 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; + +void __fastcall TraceErrorDD(int error_code, char *error_buf, int error_buf_len) +{ + 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); +} + +void __fastcall TraceErrorDS(int error_code, char *error_buf, int error_buf_len) +{ + 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); +} + +char *__cdecl TraceLastError() +{ + int v0; // eax + + v0 = GetLastError(); + return GetErrorStr(v0); +} + +void TermMsg(char *pszFmt, ...) +{ + 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); +} + +void __fastcall MsgBox(char *pszFmt, va_list va) +{ + 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); +} + +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); +} +// 4B7A34: using guessed type int terminating; +// 4B7A38: using guessed type int cleanup_thread_id; +// 679660: using guessed type char gbMaxPlayers; + +void DrawDlg(char *pszFmt, ...) +{ + 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); +} + +void __fastcall DDErrMsg(int error_code, int log_line_nr, char *log_file_path) +{ + 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); + } +} + +void __fastcall DSErrMsg(int error_code, int log_line_nr, char *log_file_path) +{ + 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); + } +} + +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] + + 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] + + 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; +} + +void __fastcall TextDlg(HWND hDlg, char *text) +{ + char *v2; // esi + HWND v3; // edi + + 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] + + 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 + + v1 = error; + FreeDlg(); + if (!v1) + v1 = ""; + if (DialogBoxParam(ghInst, MAKEINTRESOURCE(IDD_DIALOG3), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)v1) == -1) + TermMsg("FileErrDlg"); + TermMsg(0); +} + +void __fastcall DiskFreeDlg(char *error) +{ + char *v1; // esi + + 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 + + ShowCursor(1); + v0 = DialogBoxParam(ghInst, MAKEINTRESOURCE(IDD_DIALOG9), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM) ""); + if (v0 == -1) + TermMsg("InsertCDDlg"); + ShowCursor(0); + return v0 == 1; +} + +void __fastcall DirErrorDlg(char *error) +{ + char *v1; // esi + + v1 = error; + FreeDlg(); + if (DialogBoxParam(ghInst, MAKEINTRESOURCE(IDD_DIALOG11), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)v1) == -1) + TermMsg("DirErrorDlg"); + TermMsg(0); +} diff --git a/Source/codec.cpp b/Source/codec.cpp index cf43b2ee6..49912ad6a 100644 --- a/Source/codec.cpp +++ b/Source/codec.cpp @@ -2,18 +2,6 @@ #include "../types.h" -#ifdef MINIWIN -#define srand srand_miniwin -#define rand rand_miniwin -#endif - -#ifdef ANDROID -#define srand srand_miniwin -#define rand rand_miniwin -#endif - - - int __fastcall codec_decode(void *pbSrcDst, int size, char *pszPassword) { unsigned int v3; // ebx diff --git a/Source/debug.cpp b/Source/debug.cpp index cb3fc1036..152f21240 100644 --- a/Source/debug.cpp +++ b/Source/debug.cpp @@ -2,11 +2,9 @@ #include "../types.h" -#ifndef NO_GLOBALS void *pSquareCel; char dMonsDbg[NUMLEVELS][MAXDUNX][MAXDUNY]; char dFlagDbg[NUMLEVELS][MAXDUNX][MAXDUNY]; -#endif void __cdecl LoadDebugGFX() { diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 72f254053..a0d716f55 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -64,8 +64,6 @@ char *spszMsgTbl[4] = { }; // weak char *spszMsgKeyTbl[4] = { "F9", "F10", "F11", "F12" }; // weak -bool CUSTOM_SDL_KEY_LSHIFT; - void __cdecl FreeGameMem() { void *p; diff --git a/Source/drlg_l1.cpp b/Source/drlg_l1.cpp index 995b76570..0ddc5bead 100644 --- a/Source/drlg_l1.cpp +++ b/Source/drlg_l1.cpp @@ -2,7 +2,6 @@ #include "../types.h" -#ifndef NO_GLOBALS char L5dungeon[80][80]; char mydflags[40][40]; int setloadflag; // weak @@ -13,7 +12,6 @@ int VR1; int VR2; int VR3; void *pSetPiece; // idb -#endif const ShadowStruct SPATS[37] = { // clang-format off diff --git a/Source/drlg_l2.cpp b/Source/drlg_l2.cpp index 84c019370..c1324c892 100644 --- a/Source/drlg_l2.cpp +++ b/Source/drlg_l2.cpp @@ -2,7 +2,6 @@ #include "../types.h" -#ifndef NO_GLOBALS int nSx1; int nSx2; // weak int nSy1; @@ -11,7 +10,6 @@ int nRoomCnt; char predungeon[40][40]; ROOMNODE RoomList[81]; HALLNODE *pHallList; -#endif int Area_Min = 2; // weak int Room_Max = 10; // weak diff --git a/Source/drlg_l4.cpp b/Source/drlg_l4.cpp index 87539340e..e2c1264da 100644 --- a/Source/drlg_l4.cpp +++ b/Source/drlg_l4.cpp @@ -2,7 +2,6 @@ #include "../types.h" -#ifndef NO_GLOBALS int diabquad1x; // weak int diabquad1y; // weak int diabquad3x; // idb @@ -21,7 +20,6 @@ int SP4y2; // weak char L4dungeon[80][80]; char dung[20][20]; //int dword_52A4DC; // weak -#endif 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] = { diff --git a/Source/effects.cpp b/Source/effects.cpp index d566fb62a..8930c692e 100644 --- a/Source/effects.cpp +++ b/Source/effects.cpp @@ -1052,11 +1052,11 @@ void __fastcall stream_play(TSFX *pSFX, int lVolume, int lPan) if (lVolume > VOLUME_MAX) lVolume = VOLUME_MAX; #ifdef _DEBUG - //SFileEnableDirectAccess(FALSE); + SFileEnableDirectAccess(FALSE); #endif success = SFileOpenFile(pSFX->pszName, &sfx_stream); #ifdef _DEBUG - //SFileEnableDirectAccess(TRUE); + SFileEnableDirectAccess(TRUE); #endif if (!success) { sfx_stream = 0; diff --git a/Source/engine.cpp b/Source/engine.cpp index 4306d8613..d083cf310 100644 --- a/Source/engine.cpp +++ b/Source/engine.cpp @@ -1,7 +1,6 @@ //HEADER_GOES_HERE #include "../types.h" -#include "miniwin_sdl.h" char gbPixelCol; // automap pixel color 8-bit (palette entry) int dword_52B970; // BOOLEAN flip - if y < x @@ -1535,17 +1534,6 @@ int __fastcall random(BYTE idx, int v) return (GetRndSeed() >> 16) % v; } -#ifndef MINIWIN -struct engine_cpp_init_2 -{ - engine_cpp_init_2() - { - mem_init_mutex(); - mem_atexit_mutex(); - } -} _engine_cpp_init_2; -#endif - #ifndef _MSC_VER __attribute__((constructor)) #endif diff --git a/Source/gendung.cpp b/Source/gendung.cpp index 1986d6ca2..301e63ced 100644 --- a/Source/gendung.cpp +++ b/Source/gendung.cpp @@ -2,7 +2,6 @@ #include "../types.h" -#ifndef NO_GLOBALS short level_frame_types[2048]; int themeCount; char nTransTable[2049]; @@ -69,7 +68,6 @@ char dMissile[MAXDUNX][MAXDUNY]; int dminx; // weak int dminy; // weak short dpiece_defs_map_2[16][MAXDUNX][MAXDUNY]; -#endif void __cdecl FillSolidBlockTbls() { diff --git a/Source/init.h b/Source/init.h index 25c2621f0..4687ae4c5 100644 --- a/Source/init.h +++ b/Source/init.h @@ -39,6 +39,5 @@ extern const int init_inf; // weak extern char gszVersionNumber[260]; extern char gszProductName[260]; -extern int SelectedItem; #endif /* __INIT_H__ */ diff --git a/Source/interfac.cpp b/Source/interfac.cpp index 828347a6c..31cc65344 100644 --- a/Source/interfac.cpp +++ b/Source/interfac.cpp @@ -86,7 +86,7 @@ void __fastcall ShowProgress(unsigned int uMsg) DrawCutscene(); PaletteFadeIn(8); IncProgress(); - stream_update(); // What is this? + stream_update(); IncProgress(); switch (uMsg) { case WM_DIABNEXTLVL: diff --git a/Source/lighting.cpp b/Source/lighting.cpp index 4270c9a07..e0d77cc54 100644 --- a/Source/lighting.cpp +++ b/Source/lighting.cpp @@ -2,7 +2,6 @@ #include "../types.h" -#ifndef NO_GLOBALS LightListStruct VisionList[32]; char lightactive[32]; LightListStruct LightList[32]; @@ -16,7 +15,6 @@ char dung_map_rgba[16384]; /* int [64][64] short [64][128] char [64][256] */ int visionid; char *pLightTbl; /* todo: struct? */ BOOL lightflag; -#endif char CrawlTable[2749] = { 1, diff --git a/Source/mainmenu.cpp b/Source/mainmenu.cpp index 09d1434db..47cc703fc 100644 --- a/Source/mainmenu.cpp +++ b/Source/mainmenu.cpp @@ -2,8 +2,6 @@ #include "../types.h" -#include "diablo.h" - char gszHero[16]; /* data */ diff --git a/Source/nthread.cpp b/Source/nthread.cpp index 1502a8c32..cb298ed87 100644 --- a/Source/nthread.cpp +++ b/Source/nthread.cpp @@ -32,16 +32,8 @@ nthread_c_init(void) nthread_cleanup_mutex_atexit(); } -#ifndef MINIWIN -struct nthread_cpp_init_2 -{ - nthread_cpp_init_2() - { - nthread_init_mutex(); - nthread_cleanup_mutex_atexit(); - } -} _nthread_cpp_init_2; -#endif +SEG_ALLOCATE(SEGMENT_C_INIT) +_PVFV nthread_c_init_funcs[] = { &nthread_c_init }; void __cdecl nthread_init_mutex() { diff --git a/Source/path.cpp b/Source/path.cpp index 86ee26831..5ce8858fc 100644 --- a/Source/path.cpp +++ b/Source/path.cpp @@ -2,7 +2,6 @@ #include "../types.h" -#ifndef NO_GLOBALS // preallocated nodes, search is terminated after 300 nodes are visited PATHNODE path_nodes[MAXPATHNODES]; // size of the pnode_tblptr stack @@ -19,7 +18,6 @@ PATHNODE *pnode_ptr; PATHNODE *pnode_tblptr[MAXPATHNODES]; // a linked list of the A* frontier, sorted by distance PATHNODE *path_2_nodes; -#endif // for iterating over the 8 possible movement directions const char pathxdir[8] = { -1, -1, 1, 1, -1, 0, 1, 0 }; diff --git a/Source/pfile.cpp b/Source/pfile.cpp index 9350e9f7a..44d664852 100644 --- a/Source/pfile.cpp +++ b/Source/pfile.cpp @@ -113,16 +113,7 @@ BOOL __fastcall pfile_open_archive(BOOL a1, unsigned int save_num) if ( a1 && gbMaxPlayers > 1 ) mpqapi_update_multi_creation_time(save_num); return FALSE; - - - - - #else - - - - char FileName[MAX_PATH]; pfile_get_save_path(FileName, sizeof(FileName), save_num); @@ -132,9 +123,7 @@ BOOL __fastcall pfile_open_archive(BOOL a1, unsigned int save_num) if (a1 && gbMaxPlayers > 1) mpqapi_update_multi_creation_time(save_num); return FALSE; - #endif - } void __fastcall pfile_get_save_path(char *pszBuf, DWORD dwBufSize, unsigned int save_num) @@ -399,8 +388,8 @@ HANDLE __fastcall pfile_open_save_archive(int *unused, unsigned int save_num) return archive; return NULL; #else // IF NOT ANDROID - 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)) diff --git a/Source/pfile.h b/Source/pfile.h index 40d99d826..9434d0dc3 100644 --- a/Source/pfile.h +++ b/Source/pfile.h @@ -3,12 +3,6 @@ #define __PFILE_H__ extern BOOL gbValidSaveFile; // idb -extern char hero_names[MAX_CHARACTERS][PLR_NAME_LEN]; - - - - - void __cdecl pfile_init_save_directory(); void __fastcall pfile_check_available_space(char *pszDir); diff --git a/Source/portal.cpp b/Source/portal.cpp index 30072106f..95c1f84ba 100644 --- a/Source/portal.cpp +++ b/Source/portal.cpp @@ -2,10 +2,8 @@ #include "../types.h" -#ifndef NO_GLOBALS PortalStruct portal[MAXPORTAL]; int portalindex; -#endif int WarpDropX[MAXPORTAL] = { 57, 59, 61, 63 }; int WarpDropY[MAXPORTAL] = { 40, 40, 40, 40 }; diff --git a/Source/render.cpp b/Source/render.cpp index a0a8be8b1..193408058 100644 --- a/Source/render.cpp +++ b/Source/render.cpp @@ -3,14 +3,12 @@ #include "../types.h" #include "_asm.cpp" -#ifndef NO_GLOBALS int WorldBoolFlag = 0; unsigned int gdwCurrentMask = 0; // char world_4B3264 = 0; unsigned char *gpCelFrame = NULL; unsigned int *gpDrawMask = NULL; // char world_4B326D[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -#endif unsigned int RightMask[32] = { 0xEAAAAAAA, 0xF5555555, 0xFEAAAAAA, 0xFF555555, 0xFFEAAAAA, 0xFFF55555, 0xFFFEAAAA, 0xFFFF5555, diff --git a/Source/sha.cpp b/Source/sha.cpp index 1ed9fa556..edcf595bb 100644 --- a/Source/sha.cpp +++ b/Source/sha.cpp @@ -2,9 +2,7 @@ #include "../types.h" -#ifndef NO_GLOBALS SHA1Context sgSHA1[3]; -#endif void __cdecl SHA1Clear() { diff --git a/Source/sync.cpp b/Source/sync.cpp index c9a2feaeb..b8caffb28 100644 --- a/Source/sync.cpp +++ b/Source/sync.cpp @@ -2,13 +2,11 @@ #include "../types.h" -#ifndef NO_GLOBALS short sync_word_6AA708[MAXMONSTERS]; int syncmonsters; // weak short sync_word_6AA89C[MAXMONSTERS]; int syncitems; int sgnSyncPInv; // weak -#endif int __fastcall sync_all_monsters(TSyncHeader *packet, int size) { diff --git a/Source/towners.cpp b/Source/towners.cpp index e7cab429f..7e0ba1513 100644 --- a/Source/towners.cpp +++ b/Source/towners.cpp @@ -2,7 +2,6 @@ #include "../types.h" -#ifndef NO_GLOBALS int storeflag; // weak int sgnCowMsg; int numtowners; // idb @@ -11,7 +10,6 @@ int bannerflag; // weak // unused 0x6AAC28 int boyloadflag; // weak BYTE *pCowCels; TownerStruct towner[16]; -#endif const int snSFX[3][3] = { { PS_WARR52, PS_ROGUE52, PS_MAGE52 }, diff --git a/Source/trigs.cpp b/Source/trigs.cpp index 362cb9e98..70be89044 100644 --- a/Source/trigs.cpp +++ b/Source/trigs.cpp @@ -2,11 +2,9 @@ #include "../types.h" -#ifndef NO_GLOBALS int trigflag[MAXTRIGGERS]; TriggerStruct trigs[MAXTRIGGERS]; int TWarpFrom; // weak -#endif int TownDownList[11] = { 716, 715, 719, 720, 721, 723, 724, 725, 726, 727, -1 }; int TownWarp1List[13] = { diff --git a/Stub/diablo.cpp b/Stub/diablo.cpp index 6e5dda0da..0730adc68 100644 --- a/Stub/diablo.cpp +++ b/Stub/diablo.cpp @@ -2221,9 +2221,6 @@ void __fastcall game_loop(BOOL bStartup) // 525650: using guessed type int gbRunGame; // 679660: using guessed type char gbMaxPlayers; - -bool CUSTOM_SDL_KEY_LSHIFT; - void __cdecl game_logic() { if ( PauseMode != 2 ) diff --git a/Stub/diabloui.cpp b/Stub/diabloui.cpp index cabf3ba1e..150d881ba 100644 --- a/Stub/diabloui.cpp +++ b/Stub/diabloui.cpp @@ -5,8 +5,8 @@ #include "stubs.h" char chr_name_str[16]; +char hero_names[MAX_CHARACTERS][PLR_NAME_LEN]; -int SelectedItem = 1; int SelectedItemMax = 0; int MenuItem[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; int PreviousItem[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; diff --git a/Stub/miniwin_msg_sdl.cpp b/Stub/miniwin_msg_sdl.cpp index 52a642a3b..4920ad67c 100644 --- a/Stub/miniwin_msg_sdl.cpp +++ b/Stub/miniwin_msg_sdl.cpp @@ -75,7 +75,7 @@ static int translate_sdl_key(SDL_Keysym key) return VK_OEM_PERIOD; case SDLK_COMMA: return VK_OEM_COMMA; - + // case SDLK_LSHIFT: // printf("Fooooooo\n"); //PlayerS._pmode = 5; @@ -94,8 +94,7 @@ static int translate_sdl_key(SDL_Keysym key) } else if (sym >= SDLK_F1 && sym <= SDLK_F12) { return VK_F1 + (sym - SDLK_F1); } - CUSTOM_SDL_KEY_LSHIFT = 0; - + DUMMY_PRINT("unknown key: name=%s sym=0x%X scan=%d mod=0x%X", SDL_GetKeyName(sym), sym, key.scancode, key.mod); return -1; diff --git a/Stub/sdlrender.cpp b/Stub/sdlrender.cpp index 8a6fa1a33..f71dfff45 100644 --- a/Stub/sdlrender.cpp +++ b/Stub/sdlrender.cpp @@ -31,6 +31,7 @@ bool SinglePlayerMenuItemsLoaded = 0; bool DiabloImageLoaded = 0; bool DiabloMainMenuListLoaded = 0; bool TitleImageLoaded = false; +int SelectedItem = 1; void *pPcxLogoImage; int gdwLogoWidth; diff --git a/Stub/sdlrender.h b/Stub/sdlrender.h index 48caf863c..e90b79b14 100644 --- a/Stub/sdlrender.h +++ b/Stub/sdlrender.h @@ -55,6 +55,7 @@ extern int gdwCreditsWidth; extern int gdwCreditsHeight; extern bool TitleImageLoaded; +extern int SelectedItem; extern int totalFrames; //extern SDL_Texture* spriteSheet;