Browse Source

Merge branch 'master2'

pull/25/head
Anders Jenbo 7 years ago
parent
commit
e153e3b062
  1. 4
      DiabloUI/copyprot.cpp
  2. 4
      DiabloUI/okcancel.cpp
  3. 4
      DiabloUI/progress.cpp
  4. 22
      DiabloUI/selhero.cpp
  5. 272
      Source/appfat.cpp
  6. 14
      Source/appfat.h
  7. 2
      Source/codec.cpp
  8. 14
      Source/control.cpp
  9. 4
      Source/drlg_l1.cpp
  10. 26
      Source/drlg_l2.cpp
  11. 2
      Source/effects.cpp
  12. 20
      Source/engine.cpp
  13. 2
      Source/engine.h
  14. 20
      Source/init.cpp
  15. 2
      Source/init.h
  16. 6
      Source/items.cpp
  17. 8
      Source/mainmenu.cpp
  18. 83
      Source/multi.cpp
  19. 2
      Source/multi.h
  20. 2
      Source/town.cpp
  21. 2
      Source/town.h
  22. 6
      Stub/appfat.cpp
  23. 7
      Stub/main.cpp
  24. 1
      Stub/miniwin_sdl.h
  25. 30
      Stub/miniwin_thread.cpp
  26. 12
      Stub/storm_net.cpp

4
DiabloUI/copyprot.cpp

@ -119,7 +119,7 @@ BOOL __fastcall CopyProt_LoadCopyStuff(HWND hWnd, int a2)
v13 = LockResource(copyprot_artpal); v13 = LockResource(copyprot_artpal);
if (v5) if (v5)
SDlgSetBitmapI(hWnd, 0, &nullcharacter, -1, 1, v5, 0, 284, 148, -1); SDlgSetBitmapI(hWnd, 0, &nullcharacter, -1, 1, v5, 0, 284, 148, -1);
ShowCursor(1); ShowCursor(TRUE);
Fade_SetInputWindow(hWnd); Fade_SetInputWindow(hWnd);
if (v6) if (v6)
local_FitButtonDlg(hWnd, msgs, v6, data); local_FitButtonDlg(hWnd, msgs, v6, data);
@ -135,7 +135,7 @@ BOOL __fastcall CopyProt_LoadCopyStuff(HWND hWnd, int a2)
// ref: 0x1000430C // ref: 0x1000430C
void __fastcall CopyProt_EndCopyDlg(HWND hWnd, int a2) void __fastcall CopyProt_EndCopyDlg(HWND hWnd, int a2)
{ {
ShowCursor(0); ShowCursor(FALSE);
SDlgEndDialog(hWnd, (HANDLE)a2); SDlgEndDialog(hWnd, (HANDLE)a2);
} }

4
DiabloUI/okcancel.cpp

@ -56,7 +56,7 @@ LRESULT __stdcall OkCancel_WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lP
HWND v9; // eax HWND v9; // eax
if (Msg == 2) { if (Msg == 2) {
ShowCursor(0); ShowCursor(FALSE);
OkCancel_FreeDlgBmp(hWnd); OkCancel_FreeDlgBmp(hWnd);
return (LRESULT)SDlgDefDialogProc(hWnd, Msg, (HDC)wParam, (HWND)lParam); return (LRESULT)SDlgDefDialogProc(hWnd, Msg, (HDC)wParam, (HWND)lParam);
} }
@ -98,7 +98,7 @@ LRESULT __stdcall OkCancel_WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lP
v6 = 2; v6 = 2;
goto LABEL_16; goto LABEL_16;
} }
ShowCursor(1); ShowCursor(TRUE);
if (!OkCancel_LoadOkCancGFX(hWnd, (DWORD *)lParam)) if (!OkCancel_LoadOkCancGFX(hWnd, (DWORD *)lParam))
SDlgEndDialog(hWnd, (HANDLE)0xFF000000); SDlgEndDialog(hWnd, (HANDLE)0xFF000000);
return 1; return 1;

4
DiabloUI/progress.cpp

@ -45,7 +45,7 @@ int __stdcall Progress_100094F4(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lPara
if ( Msg == 2 ) if ( Msg == 2 )
{ {
ShowCursor(0); ShowCursor(FALSE);
Progress_100095EC(); Progress_100095EC();
} }
else if ( Msg > 0x103 ) else if ( Msg > 0x103 )
@ -64,7 +64,7 @@ int __stdcall Progress_100094F4(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lPara
v5 = (void *)SDrawGetFrameWindow(NULL); v5 = (void *)SDrawGetFrameWindow(NULL);
local_1000812B(v5); local_1000812B(v5);
local_1000812B(hWnd); local_1000812B(hWnd);
ShowCursor(1); ShowCursor(TRUE);
return 1; return 1;
case 0x111u: case 0x111u:
if ( (_WORD)wParam == 2 ) if ( (_WORD)wParam == 2 )

22
DiabloUI/selhero.cpp

@ -213,7 +213,14 @@ BOOL __fastcall UiValidPlayerName(char *name)
} }
// ref: 0x1000BBB4 // ref: 0x1000BBB4
BOOL __stdcall UiSelHeroMultDialog(BOOL(__stdcall *fninfo)(BOOL(__stdcall *fninfofunc)(_uiheroinfo *)), BOOL(__stdcall *fncreate)(_uiheroinfo *), BOOL(__stdcall *fnremove)(_uiheroinfo *), BOOL(__stdcall *fnstats)(unsigned int, _uidefaultstats *), int *dlgresult, int *a6, char *name) BOOL __stdcall UiSelHeroMultDialog(
BOOL(__stdcall *fninfo)(BOOL(__stdcall *fninfofunc)(_uiheroinfo *)),
BOOL(__stdcall *fncreate)(_uiheroinfo *),
BOOL(__stdcall *fnremove)(_uiheroinfo *),
BOOL(__stdcall *fnstats)(unsigned int, _uidefaultstats *),
int *dlgresult,
int *hero_is_created,
char *name)
{ {
int v7; // eax int v7; // eax
int v8; // eax int v8; // eax
@ -232,8 +239,8 @@ BOOL __stdcall UiSelHeroMultDialog(BOOL(__stdcall *fninfo)(BOOL(__stdcall *fninf
*dlgresult = v8; *dlgresult = v8;
if (name) if (name)
strcpy(name, selhero_heronamestr); strcpy(name, selhero_heronamestr);
if (a6) if (hero_is_created)
*a6 = selhero_is_created; *hero_is_created = selhero_is_created;
return 1; return 1;
} }
// 10010382: using guessed type _DWORD __stdcall SDrawGetFrameWindow(); // 10010382: using guessed type _DWORD __stdcall SDrawGetFrameWindow();
@ -704,7 +711,14 @@ BOOL __stdcall SelHero_GetHeroInfo(_uiheroinfo *pInfo)
// 1002A428: using guessed type int selhero_numheroesleft; // 1002A428: using guessed type int selhero_numheroesleft;
// ref: 0x1000C57A // ref: 0x1000C57A
BOOL __stdcall UiSelHeroSingDialog(BOOL(__stdcall *fninfo)(BOOL(__stdcall *fninfofunc)(_uiheroinfo *)), BOOL(__stdcall *fncreate)(_uiheroinfo *), BOOL(__stdcall *fnremove)(_uiheroinfo *), BOOL(__stdcall *fnstats)(unsigned int, _uidefaultstats *), int *dlgresult, char *name, int *difficulty) BOOL __stdcall UiSelHeroSingDialog(
BOOL(__stdcall *fninfo)(BOOL(__stdcall *fninfofunc)(_uiheroinfo *)),
BOOL(__stdcall *fncreate)(_uiheroinfo *),
BOOL(__stdcall *fnremove)(_uiheroinfo *),
BOOL(__stdcall *fnstats)(unsigned int, _uidefaultstats *),
int *dlgresult,
char *name,
int *difficulty)
{ {
int v7; // eax int v7; // eax
int v8; // edi int v8; // edi

272
Source/appfat.cpp

@ -3,8 +3,8 @@
#include "../types.h" #include "../types.h"
char sz_error_buf[256]; char sz_error_buf[256];
int terminating; // weak BOOL terminating;
int cleanup_thread_id; // weak int cleanup_thread_id;
// delete overloads the delete operator. // delete overloads the delete operator.
//void operator delete(void *ptr) //void operator delete(void *ptr)
@ -14,30 +14,35 @@ int cleanup_thread_id; // weak
// } // }
//} //}
char *__fastcall GetErrorStr(int error_code) char *__fastcall GetErrorStr(DWORD error_code)
{ {
int v1; // edi DWORD upper_code;
unsigned int v2; // eax int size;
signed int v4; // eax char *chr;
char *i; // ecx
upper_code = (error_code >> 16) & 0x1FFF;
v1 = error_code; if (upper_code == 0x0878) {
v2 = ((unsigned int)error_code >> 16) & 0x1FFF;
if (v2 == 0x0878) {
TraceErrorDS(error_code, sz_error_buf, 256); TraceErrorDS(error_code, sz_error_buf, 256);
} else if (v2 == 0x0876) { } else if (upper_code == 0x0876) {
TraceErrorDD(error_code, sz_error_buf, 256); TraceErrorDD(error_code, sz_error_buf, 256);
} else { } else if (!SErrGetErrorStr(error_code, sz_error_buf, 256)
if (!SErrGetErrorStr(error_code, sz_error_buf, 256) && !FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, v1, 0x400u, sz_error_buf, 0x100u, NULL)) && !FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, error_code, 0x400, sz_error_buf, 0x100, NULL)) {
wsprintf(sz_error_buf, "unknown error 0x%08x", v1); wsprintf(sz_error_buf, "unknown error 0x%08x", error_code);
} }
v4 = strlen(sz_error_buf);
for (i = &sz_error_buf[v4 - 1]; v4 > 0; *i = 0) { size = strlen(sz_error_buf);
--v4;
--i; chr = &sz_error_buf[size - 1];
if (*i != '\r' && *i != '\n') while (size > 0) {
size--;
chr--;
if (*chr != '\r' && *chr != '\n')
break; break;
*chr = 0x00;
} }
return sz_error_buf; return sz_error_buf;
} }
@ -46,7 +51,7 @@ char *__fastcall GetErrorStr(int error_code)
v = #errName; \ v = #errName; \
break; break;
void __fastcall TraceErrorDD(int error_code, char *error_buf, int error_buf_len) void __fastcall TraceErrorDD(DWORD error_code, char *error_buf, int error_buf_len)
{ {
const char *v3; // eax const char *v3; // eax
char v4[20]; // [esp+0h] [ebp-14h] char v4[20]; // [esp+0h] [ebp-14h]
@ -158,7 +163,7 @@ void __fastcall TraceErrorDD(int error_code, char *error_buf, int error_buf_len)
strncpy(error_buf, v3, error_buf_len); strncpy(error_buf, v3, error_buf_len);
} }
void __fastcall TraceErrorDS(int error_code, char *error_buf, int error_buf_len) void __fastcall TraceErrorDS(DWORD error_code, char *error_buf, int error_buf_len)
{ {
const char *v3; // eax const char *v3; // eax
char v4[20]; // [esp+0h] [ebp-14h] char v4[20]; // [esp+0h] [ebp-14h]
@ -187,22 +192,22 @@ void __fastcall TraceErrorDS(int error_code, char *error_buf, int error_buf_len)
char *__cdecl TraceLastError() char *__cdecl TraceLastError()
{ {
int v0; // eax return GetErrorStr(GetLastError());
v0 = GetLastError();
return GetErrorStr(v0);
} }
void TermMsg(char *pszFmt, ...) void TermMsg(char *pszFmt, ...)
{ {
va_list arglist; // [esp+8h] [ebp+8h] va_list va;
va_start(arglist, pszFmt); va_start(va, pszFmt);
FreeDlg(); FreeDlg();
if (pszFmt) if (pszFmt)
MsgBox(pszFmt, arglist); MsgBox(pszFmt, va);
va_end(arglist);
init_cleanup(0); va_end(va);
init_cleanup(FALSE);
exit(1); exit(1);
} }
@ -219,20 +224,21 @@ void __fastcall MsgBox(char *pszFmt, va_list va)
void __cdecl FreeDlg() void __cdecl FreeDlg()
{ {
if (terminating && cleanup_thread_id != GetCurrentThreadId()) if (terminating && cleanup_thread_id != GetCurrentThreadId())
Sleep(20000u); Sleep(20000);
terminating = 1;
terminating = TRUE;
cleanup_thread_id = GetCurrentThreadId(); cleanup_thread_id = GetCurrentThreadId();
dx_cleanup(); dx_cleanup();
if ((unsigned char)gbMaxPlayers > 1u) {
if (gbMaxPlayers > 1) {
if (SNetLeaveGame(3)) if (SNetLeaveGame(3))
Sleep(2000u); Sleep(2000);
} }
SNetDestroy(); SNetDestroy();
ShowCursor(1); ShowCursor(TRUE);
} }
// 4B7A34: using guessed type int terminating;
// 4B7A38: using guessed type int cleanup_thread_id;
// 679660: using guessed type char gbMaxPlayers;
void DrawDlg(char *pszFmt, ...) void DrawDlg(char *pszFmt, ...)
{ {
@ -245,169 +251,149 @@ void DrawDlg(char *pszFmt, ...)
SDrawMessageBox(text, "Diablo", MB_TASKMODAL | MB_ICONEXCLAMATION); SDrawMessageBox(text, "Diablo", MB_TASKMODAL | MB_ICONEXCLAMATION);
} }
void __fastcall DDErrMsg(int error_code, int log_line_nr, char *log_file_path) void __fastcall DDErrMsg(DWORD error_code, int log_line_nr, char *log_file_path)
{ {
int v3; // esi char *msg;
char *v4; // eax
v3 = log_line_nr;
if (error_code) { if (error_code) {
v4 = GetErrorStr(error_code); msg = GetErrorStr(error_code);
TermMsg("Direct draw error (%s:%d)\n%s", log_file_path, v3, v4); TermMsg("Direct draw error (%s:%d)\n%s", log_file_path, log_line_nr, msg);
} }
} }
void __fastcall DSErrMsg(int error_code, int log_line_nr, char *log_file_path) void __fastcall DSErrMsg(DWORD error_code, int log_line_nr, char *log_file_path)
{ {
int v3; // esi char *msg;
char *v4; // eax
v3 = log_line_nr;
if (error_code) { if (error_code) {
v4 = GetErrorStr(error_code); msg = GetErrorStr(error_code);
TermMsg("Direct sound error (%s:%d)\n%s", log_file_path, v3, v4); TermMsg("Direct sound error (%s:%d)\n%s", log_file_path, log_line_nr, msg);
} }
} }
void __fastcall center_window(HWND hDlg) void __fastcall center_window(HWND hDlg)
{ {
LONG v1; // esi LONG w, h;
LONG v2; // edi int screenW, screenH;
int v3; // ebx struct tagRECT Rect;
char *v4; // eax HDC hdc;
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); GetWindowRect(hDlg, &Rect);
v1 = Rect.right - Rect.left; w = Rect.right - Rect.left;
v2 = Rect.bottom - Rect.top; h = Rect.bottom - Rect.top;
hdc = GetDC(hWnd); hdc = GetDC(hDlg);
v6 = GetDeviceCaps(hdc, HORZRES); screenW = GetDeviceCaps(hdc, HORZRES);
v3 = GetDeviceCaps(hdc, VERTRES); screenH = GetDeviceCaps(hdc, VERTRES);
ReleaseDC(hWnd, hdc); ReleaseDC(hDlg, hdc);
if (!SetWindowPos(hWnd, HWND_TOP, (v6 - v1) / 2, (v3 - v2) / 2, 0, 0, SWP_NOZORDER | SWP_NOSIZE)) {
v4 = TraceLastError(); if (!SetWindowPos(hDlg, HWND_TOP, (screenW - w) / 2, (screenH - h) / 2, 0, 0, SWP_NOZORDER | SWP_NOSIZE)) {
TermMsg("center_window: %s", v4); TermMsg("center_window: %s", TraceLastError());
} }
} }
void __fastcall ErrDlg(int template_id, int error_code, char *log_file_path, int log_line_nr) void __fastcall ErrDlg(int template_id, DWORD error_code, char *log_file_path, int log_line_nr)
{ {
int v4; // ebx char *size;
int v5; // edi LPARAM dwInitParam[128];
char *v6; // esi
char *v7; // eax
char *v8; // eax
LPARAM dwInitParam[128]; // [esp+Ch] [ebp-200h]
v4 = error_code;
v5 = template_id;
FreeDlg(); FreeDlg();
v6 = log_file_path;
v7 = strrchr(log_file_path, '\\'); size = strrchr(log_file_path, '\\');
if (v7) if (size)
v6 = v7 + 1; log_file_path = size + 1;
v8 = GetErrorStr(v4);
wsprintf((LPSTR)dwInitParam, "%s\nat: %s line %d", v8, v6, log_line_nr); wsprintf((LPSTR)dwInitParam, "%s\nat: %s line %d", GetErrorStr(error_code), log_file_path, log_line_nr);
if (DialogBoxParam(ghInst, MAKEINTRESOURCE(v5), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)dwInitParam) == -1) if (DialogBoxParam(ghInst, MAKEINTRESOURCE(template_id), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)dwInitParam) == -1)
TermMsg("ErrDlg: %d", v5); TermMsg("ErrDlg: %d", template_id);
TermMsg(0);
TermMsg(NULL);
} }
BOOL __stdcall FuncDlg(HWND hDlg, UINT uMsg, WPARAM wParam, char *text) BOOL __stdcall FuncDlg(HWND hDlg, UINT uMsg, WPARAM wParam, char *text)
{ {
if (uMsg == WM_INITDIALOG) { switch (uMsg) {
case WM_INITDIALOG:
TextDlg(hDlg, text); TextDlg(hDlg, text);
} else { break;
if (uMsg != WM_COMMAND) case WM_COMMAND:
return 0; if ((WORD)wParam == 1) {
if ((_WORD)wParam == 1) {
EndDialog(hDlg, 1); EndDialog(hDlg, 1);
} else if ((_WORD)wParam == 2) { } else if ((WORD)wParam == 2) {
EndDialog(hDlg, 0); EndDialog(hDlg, 0);
} }
break;
default:
return FALSE;
} }
return 1;
return TRUE;
} }
void __fastcall TextDlg(HWND hDlg, char *text) void __fastcall TextDlg(HWND hDlg, char *text)
{ {
char *v2; // esi
HWND v3; // edi
v2 = text;
v3 = hDlg;
center_window(hDlg); center_window(hDlg);
if (v2)
SetDlgItemText(v3, 1000, v2); if (text)
SetDlgItemText(hDlg, 1000, text);
} }
void __fastcall ErrOkDlg(int template_id, int error_code, char *log_file_path, int log_line_nr) void __fastcall ErrOkDlg(int template_id, DWORD error_code, char *log_file_path, int log_line_nr)
{ {
char *v4; // esi char *size;
int v5; // edi LPARAM dwInitParam[128];
unsigned short v6; // bx
char *v7; // eax size = strrchr(log_file_path, '\\');
char *v8; // eax if (size)
LPARAM dwInitParam[128]; // [esp+Ch] [ebp-200h] log_file_path = size + 1;
v4 = log_file_path; wsprintf((LPSTR)dwInitParam, "%s\nat: %s line %d", GetErrorStr(error_code), log_file_path, log_line_nr);
v5 = error_code; DialogBoxParam(ghInst, MAKEINTRESOURCE(template_id), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)dwInitParam);
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) void __fastcall FileErrDlg(const char *error)
{ {
const char *v1; // esi
v1 = error;
FreeDlg(); FreeDlg();
if (!v1)
v1 = ""; if (!error)
if (DialogBoxParam(ghInst, MAKEINTRESOURCE(IDD_DIALOG3), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)v1) == -1) error = "";
if (DialogBoxParam(ghInst, MAKEINTRESOURCE(IDD_DIALOG3), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)error) == -1)
TermMsg("FileErrDlg"); TermMsg("FileErrDlg");
TermMsg(0);
TermMsg(NULL);
} }
void __fastcall DiskFreeDlg(char *error) void __fastcall DiskFreeDlg(char *error)
{ {
char *v1; // esi
v1 = error;
FreeDlg(); FreeDlg();
if (DialogBoxParam(ghInst, MAKEINTRESOURCE(IDD_DIALOG7), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)v1) == -1)
if (DialogBoxParam(ghInst, MAKEINTRESOURCE(IDD_DIALOG7), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)error) == -1)
TermMsg("DiskFreeDlg"); TermMsg("DiskFreeDlg");
TermMsg(0);
TermMsg(NULL);
} }
BOOL __cdecl InsertCDDlg() BOOL __cdecl InsertCDDlg()
{ {
int v0; // edi int nResult;
ShowCursor(TRUE);
ShowCursor(1); nResult = DialogBoxParam(ghInst, MAKEINTRESOURCE(IDD_DIALOG9), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM) "");
v0 = DialogBoxParam(ghInst, MAKEINTRESOURCE(IDD_DIALOG9), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM) ""); if (nResult == -1)
if (v0 == -1)
TermMsg("InsertCDDlg"); TermMsg("InsertCDDlg");
ShowCursor(0);
return v0 == 1; ShowCursor(FALSE);
return nResult == 1;
} }
void __fastcall DirErrorDlg(char *error) void __fastcall DirErrorDlg(char *error)
{ {
char *v1; // esi
v1 = error;
FreeDlg(); FreeDlg();
if (DialogBoxParam(ghInst, MAKEINTRESOURCE(IDD_DIALOG11), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)v1) == -1)
if (DialogBoxParam(ghInst, MAKEINTRESOURCE(IDD_DIALOG11), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)error) == -1)
TermMsg("DirErrorDlg"); TermMsg("DirErrorDlg");
TermMsg(0);
TermMsg(NULL);
} }

14
Source/appfat.h

@ -6,21 +6,21 @@ extern char sz_error_buf[256];
extern int terminating; // weak extern int terminating; // weak
extern int cleanup_thread_id; // weak extern int cleanup_thread_id; // weak
char *__fastcall GetErrorStr(int error_code); char *__fastcall GetErrorStr(DWORD error_code);
void __fastcall TraceErrorDD(int error_code, char *error_buf, int error_buf_len); void __fastcall TraceErrorDD(DWORD error_code, char *error_buf, int error_buf_len);
void __fastcall TraceErrorDS(int error_code, char *error_buf, int error_buf_len); void __fastcall TraceErrorDS(DWORD error_code, char *error_buf, int error_buf_len);
char *__cdecl TraceLastError(); char *__cdecl TraceLastError();
void TermMsg(char *pszFmt, ...); void TermMsg(char *pszFmt, ...);
void __fastcall MsgBox(char *pszFmt, va_list va); void __fastcall MsgBox(char *pszFmt, va_list va);
void __cdecl FreeDlg(); void __cdecl FreeDlg();
void DrawDlg(char *pszFmt, ...); void DrawDlg(char *pszFmt, ...);
void __fastcall DDErrMsg(int error_code, int log_line_nr, char *log_file_path); void __fastcall DDErrMsg(DWORD error_code, int log_line_nr, char *log_file_path);
void __fastcall DSErrMsg(int error_code, int log_line_nr, char *log_file_path); void __fastcall DSErrMsg(DWORD error_code, int log_line_nr, char *log_file_path);
void __fastcall center_window(HWND hDlg); void __fastcall center_window(HWND hDlg);
void __fastcall ErrDlg(int template_id, int error_code, char *log_file_path, int log_line_nr); void __fastcall ErrDlg(int template_id, DWORD error_code, char *log_file_path, int log_line_nr);
BOOL __stdcall FuncDlg(HWND hDlg, UINT uMsg, WPARAM wParam, char *text); BOOL __stdcall FuncDlg(HWND hDlg, UINT uMsg, WPARAM wParam, char *text);
void __fastcall TextDlg(HWND hDlg, char *text); void __fastcall TextDlg(HWND hDlg, char *text);
void __fastcall ErrOkDlg(int template_id, int error_code, char *log_file_path, int log_line_nr); void __fastcall ErrOkDlg(int template_id, DWORD error_code, char *log_file_path, int log_line_nr);
void __fastcall FileErrDlg(const char *error); void __fastcall FileErrDlg(const char *error);
void __fastcall DiskFreeDlg(char *error); void __fastcall DiskFreeDlg(char *error);
BOOL __cdecl InsertCDDlg(); BOOL __cdecl InsertCDDlg();

2
Source/codec.cpp

@ -6,7 +6,7 @@ int __fastcall codec_decode(void *pbSrcDst, int size, char *pszPassword)
{ {
unsigned int v3; // ebx unsigned int v3; // ebx
char *v4; // esi char *v4; // esi
int v5; // ebx INT_PTR v5; // ebx
signed int v7; // ecx signed int v7; // ecx
int v8; // esi int v8; // esi
char v9[128]; // [esp+8h] [ebp-98h] char v9[128]; // [esp+8h] [ebp-98h]

14
Source/control.cpp

@ -193,14 +193,14 @@ void __fastcall DrawSpellCel(int xp, int yp, char *Trans, int nCel, int w)
unsigned int v11; // ecx unsigned int v11; // ecx
char v14; // cf char v14; // cf
unsigned int v15; // ecx unsigned int v15; // ecx
int v18; // [esp+Ch] [ebp-Ch] INT_PTR v18; // [esp+Ch] [ebp-Ch]
int _EAX; int _EAX;
unsigned char *_EBX; unsigned char *_EBX;
v5 = &Trans[4 * nCel]; v5 = &Trans[4 * nCel];
v6 = &Trans[*(_DWORD *)v5]; v6 = &Trans[*(_DWORD *)v5];
v7 = (char *)gpBuffer + screen_y_times_768[yp] + xp; v7 = (char *)gpBuffer + screen_y_times_768[yp] + xp;
v18 = (int)&v6[*((_DWORD *)v5 + 1) - *(_DWORD *)v5]; v18 = (INT_PTR)&v6[*((_DWORD *)v5 + 1) - *(_DWORD *)v5];
_EBX = splTrans; _EBX = splTrans;
do { do {
v9 = w; v9 = w;
@ -523,7 +523,7 @@ void __cdecl DrawSpellList()
++v4; ++v4;
v26 *= (__int64)2; v26 *= (__int64)2;
v23 = v4; v23 = v4;
} while ((signed int)v20 < (signed int)&spelldata[MAX_SPELLS].sTownSpell); } while ((INT_PTR)v20 < (INT_PTR)&spelldata[MAX_SPELLS].sTownSpell);
if (v25 && v17 != 636) if (v25 && v17 != 636)
v17 -= 56; v17 -= 56;
if (v17 == 20) { if (v17 == 20) {
@ -615,7 +615,7 @@ void __fastcall CPrintString(int No, unsigned int glyph, unsigned char col)
int *v3; // ebx int *v3; // ebx
char *v4; // esi char *v4; // esi
char *v5; // edi char *v5; // edi
int v6; // ebx INT_PTR v6; // ebx
signed int v7; // edx signed int v7; // edx
unsigned int v8; // eax unsigned int v8; // eax
unsigned int v9; // ecx unsigned int v9; // ecx
@ -637,7 +637,7 @@ void __fastcall CPrintString(int No, unsigned int glyph, unsigned char col)
v3 = (int *)((char *)pPanelText + 4 * glyph); v3 = (int *)((char *)pPanelText + 4 * glyph);
v4 = (char *)pPanelText + *v3; v4 = (char *)pPanelText + *v3;
v5 = (char *)gpBuffer + No; v5 = (char *)gpBuffer + No;
v6 = (int)&v4[v3[1] - *v3]; v6 = (INT_PTR)&v4[v3[1] - *v3];
if ((_BYTE)col) { if ((_BYTE)col) {
if ((unsigned char)col == 1) { if ((unsigned char)col == 1) {
do { do {
@ -2607,7 +2607,7 @@ void __cdecl DrawTalkPan()
LABEL_21: LABEL_21:
a1 += 21720; a1 += 21720;
++v10; ++v10;
if ((signed int)a1 >= (signed int)&plr[4]._pName) if ((INT_PTR)a1 >= (INT_PTR)&plr[4]._pName)
return; return;
} }
if (byte_4B894C[v10]) { if (byte_4B894C[v10]) {
@ -2836,7 +2836,7 @@ void __cdecl control_press_enter()
break; break;
++v1; ++v1;
++v0; ++v0;
} while ((signed int)v1 < (signed int)&sgszTalkSave[8]); } while ((INT_PTR)v1 < (INT_PTR)&sgszTalkSave[8]);
if (v0 < 8) { if (v0 < 8) {
v2 = sgbNextTalkSave; v2 = sgbNextTalkSave;
v3 = (sgbNextTalkSave - 1) & 7; v3 = (sgbNextTalkSave - 1) & 7;

4
Source/drlg_l1.cpp

@ -269,7 +269,7 @@ void __cdecl DRLG_L1Pass3()
--v3; --v3;
} while (v3); } while (v3);
v1 += 2; v1 += 2;
} while ((signed int)v1 < (signed int)dPiece[2]); } while ((INT_PTR)v1 < (INT_PTR)dPiece[2]);
v4 = 0; v4 = 0;
v14 = &dPiece[17][16]; /* check */ v14 = &dPiece[17][16]; /* check */
do { do {
@ -365,7 +365,7 @@ void __cdecl DRLG_InitL1Vals()
} while (v6); } while (v6);
v7 = (int(*)[112])((char *)v7 + 4); v7 = (int(*)[112])((char *)v7 + 4);
++v0; ++v0;
} while ((signed int)v7 < (signed int)dPiece[1]); } while ((INT_PTR)v7 < (INT_PTR)dPiece[1]);
} }
void __fastcall LoadPreL1Dungeon(char *sFileName, int vx, int vy) void __fastcall LoadPreL1Dungeon(char *sFileName, int vx, int vy)

26
Source/drlg_l2.cpp

@ -375,7 +375,7 @@ void __fastcall LoadL2Dungeon(char *sFileName, int vx, int vy)
signed int v6; // eax signed int v6; // eax
signed int v7; // ecx signed int v7; // ecx
int v8; // esi int v8; // esi
int v9; // eax INT_PTR v9; // eax
int v10; // ebx int v10; // ebx
int v11; // edi int v11; // edi
char *v12; // eax char *v12; // eax
@ -420,7 +420,7 @@ void __fastcall LoadL2Dungeon(char *sFileName, int vx, int vy)
++v5; ++v5;
} while (v5 < 40); } while (v5 < 40);
v8 = *v4; v8 = *v4;
v9 = (int)(v4 + 2); v9 = (INT_PTR)(v4 + 2);
v10 = 0; v10 = 0;
v11 = v4[2]; v11 = v4[2];
v12 = (char *)(v9 + 2); v12 = (char *)(v9 + 2);
@ -489,7 +489,7 @@ void __fastcall LoadL2Dungeon(char *sFileName, int vx, int vy)
} while (v21); } while (v21);
v33 = (int(*)[112])((char *)v33 + 4); v33 = (int(*)[112])((char *)v33 + 4);
++v18; ++v18;
} while ((signed int)v33 < (signed int)dPiece[1]); } while ((INT_PTR)v33 < (INT_PTR)dPiece[1]);
v24 = 0; v24 = 0;
v25 = dPiece; v25 = dPiece;
do { do {
@ -511,7 +511,7 @@ void __fastcall LoadL2Dungeon(char *sFileName, int vx, int vy)
} while (v28); } while (v28);
v25 = (int(*)[112])((char *)v25 + 4); v25 = (int(*)[112])((char *)v25 + 4);
++v24; ++v24;
} while ((signed int)v25 < (signed int)dPiece[1]); } while ((INT_PTR)v25 < (INT_PTR)dPiece[1]);
ViewX = v30; ViewX = v30;
ViewY = vy; ViewY = vy;
SetMapMonsters((unsigned char *)ptr, 0, 0); SetMapMonsters((unsigned char *)ptr, 0, 0);
@ -562,7 +562,7 @@ void __cdecl DRLG_L2Pass3()
--v3; --v3;
} while (v3); } while (v3);
v1 += 2; v1 += 2;
} while ((signed int)v1 < (signed int)dPiece[2]); } while ((INT_PTR)v1 < (INT_PTR)dPiece[2]);
v4 = 0; v4 = 0;
v14 = &dPiece[17][16]; v14 = &dPiece[17][16];
do { do {
@ -989,8 +989,8 @@ BOOLEAN __fastcall DRLG_L2PlaceMiniSet(unsigned char *miniset, int tmin, int tma
int v31; // [esp+14h] [ebp-20h] int v31; // [esp+14h] [ebp-20h]
int v32; // [esp+18h] [ebp-1Ch] int v32; // [esp+18h] [ebp-1Ch]
signed int v33; // [esp+1Ch] [ebp-18h] signed int v33; // [esp+1Ch] [ebp-18h]
int v34; // [esp+20h] [ebp-14h] INT_PTR v34; // [esp+20h] [ebp-14h]
int v35; // [esp+24h] [ebp-10h] INT_PTR v35; // [esp+24h] [ebp-10h]
int v36; // [esp+28h] [ebp-Ch] int v36; // [esp+28h] [ebp-Ch]
int max; // [esp+2Ch] [ebp-8h] int max; // [esp+2Ch] [ebp-8h]
//int v38; // [esp+30h] [ebp-4h] //int v38; // [esp+30h] [ebp-4h]
@ -1084,7 +1084,7 @@ BOOLEAN __fastcall DRLG_L2PlaceMiniSet(unsigned char *miniset, int tmin, int tma
if (v34 > 0) { if (v34 > 0) {
v26 = &dungeon[v13][v24 + v14]; v26 = &dungeon[v13][v24 + v14];
do { do {
v27 = v29[(_DWORD)miniset]; v27 = v29[(UINT_PTR)miniset];
if (v27) if (v27)
*v26 = v27; *v26 = v27;
++miniset; ++miniset;
@ -1147,8 +1147,8 @@ void __fastcall DRLG_L2PlaceRndSet(unsigned char *miniset, int rndper)
int v27; // [esp+28h] [ebp-1Ch] int v27; // [esp+28h] [ebp-1Ch]
int v28; // [esp+2Ch] [ebp-18h] int v28; // [esp+2Ch] [ebp-18h]
int v29; // [esp+30h] [ebp-14h] int v29; // [esp+30h] [ebp-14h]
signed int v30; // [esp+34h] [ebp-10h] INT_PTR v30; // [esp+34h] [ebp-10h]
signed int v31; // [esp+38h] [ebp-Ch] INT_PTR v31; // [esp+38h] [ebp-Ch]
int v32; // [esp+3Ch] [ebp-8h] int v32; // [esp+3Ch] [ebp-8h]
signed int v33; // [esp+40h] [ebp-4h] signed int v33; // [esp+40h] [ebp-4h]
@ -1368,7 +1368,7 @@ void __cdecl DRLG_L2Shadows()
} }
} }
v1 += 7; v1 += 7;
} while ((signed int)v1 < (signed int)&SPATSL2[2].s1); } while ((INT_PTR)v1 < (INT_PTR)&SPATSL2[2].s1);
v0 += 40; v0 += 40;
--v9; --v9;
} while (v9); } while (v9);
@ -2971,7 +2971,7 @@ void __cdecl DRLG_InitL2Vals()
} while (v4); } while (v4);
v1 = (int(*)[112])((char *)v1 + 4); v1 = (int(*)[112])((char *)v1 + 4);
++v0; ++v0;
} while ((signed int)v1 < (signed int)dPiece[1]); } while ((INT_PTR)v1 < (INT_PTR)dPiece[1]);
v6 = 0; v6 = 0;
v7 = dPiece; v7 = dPiece;
do { do {
@ -2993,5 +2993,5 @@ void __cdecl DRLG_InitL2Vals()
} while (v10); } while (v10);
v7 = (int(*)[112])((char *)v7 + 4); v7 = (int(*)[112])((char *)v7 + 4);
++v6; ++v6;
} while ((signed int)v7 < (signed int)dPiece[1]); } while ((INT_PTR)v7 < (INT_PTR)dPiece[1]);
} }

2
Source/effects.cpp

@ -1159,7 +1159,7 @@ void __cdecl sound_update()
//v3 = v1; //v3 = v1;
if (sfx_stream) { if (sfx_stream) {
//_LOBYTE(v2) = SFileDdaGetPos(sfx_stream, (int)&v4, (int)&v3); //_LOBYTE(v2) = SFileDdaGetPos(sfx_stream, (int)&v4, (int)&v3);
if (SFileDdaGetPos(sfx_stream, (int)&v4, (int)&v3)) { if (SFileDdaGetPos(sfx_stream, (INT_PTR)&v4, (INT_PTR)&v3)) {
if (v4 >= v3) if (v4 >= v3)
sfx_stop(); sfx_stop();
} }

20
Source/engine.cpp

@ -201,7 +201,7 @@ void __fastcall CelDecDatLightEntry(unsigned char n, char *LightIndex, char **pD
void __fastcall CelDecDatLightTrans(char *pDecodeTo, char *pRLEBytes, int frame_content_size, int frame_width) void __fastcall CelDecDatLightTrans(char *pDecodeTo, char *pRLEBytes, int frame_content_size, int frame_width)
{ {
char *v4; // esi char *v4; // esi
int v5; // edi INT_PTR v5; // edi
char *v6; // ebx char *v6; // ebx
int v7; // edx int v7; // edx
unsigned int v8; // eax unsigned int v8; // eax
@ -222,7 +222,7 @@ void __fastcall CelDecDatLightTrans(char *pDecodeTo, char *pRLEBytes, int frame_
if (pDecodeTo && pRLEBytes) { if (pDecodeTo && pRLEBytes) {
v27 = &pLightTbl[256 * light_table_index]; v27 = &pLightTbl[256 * light_table_index];
v4 = pRLEBytes; v4 = pRLEBytes;
v5 = (int)pDecodeTo; v5 = (INT_PTR)pDecodeTo;
v6 = &pRLEBytes[frame_content_size]; v6 = &pRLEBytes[frame_content_size];
v28 = (unsigned char)pDecodeTo & 1; v28 = (unsigned char)pDecodeTo & 1;
do { do {
@ -987,7 +987,7 @@ void __fastcall CelDecodeRect(char *pBuff, int always_0, int dst_height, int dst
char *v7; // ebx char *v7; // ebx
char *v8; // esi char *v8; // esi
char *v9; // edi char *v9; // edi
int v10; // ebx UINT_PTR v10; // ebx
int v11; // edx int v11; // edx
unsigned int v12; // eax unsigned int v12; // eax
unsigned int v13; // ecx unsigned int v13; // ecx
@ -1000,7 +1000,7 @@ void __fastcall CelDecodeRect(char *pBuff, int always_0, int dst_height, int dst
v8 = &pCelBuff[*(_DWORD *)v7]; v8 = &pCelBuff[*(_DWORD *)v7];
v9 = &pBuff[dst_width * dst_height + always_0]; v9 = &pBuff[dst_width * dst_height + always_0];
dst_widtha = frame_width + dst_width; dst_widtha = frame_width + dst_width;
v10 = (int)&v8[*((_DWORD *)v7 + 1) - *(_DWORD *)v7]; v10 = (UINT_PTR)&v8[*((_DWORD *)v7 + 1) - *(_DWORD *)v7];
do { do {
v11 = frame_width; v11 = frame_width;
do { do {
@ -1670,11 +1670,11 @@ 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) void __fastcall Cl2DecodeFrm1(int x, int y, char *pCelBuff, int nCel, int width, INT_PTR dir1, INT_PTR dir2)
{ {
char *v8; // edx char *v8; // edx
char *v9; // ecx LONG v9; // ecx
int v10; // ecx INT_PTR v10; // ecx
int v11; // eax int v11; // eax
char *pCelBuffa; // [esp+18h] [ebp+8h] char *pCelBuffa; // [esp+18h] [ebp+8h]
@ -1682,12 +1682,12 @@ void __fastcall Cl2DecodeFrm1(int x, int y, char *pCelBuff, int nCel, int width,
v8 = pCelBuff; v8 = pCelBuff;
if (pCelBuff) { if (pCelBuff) {
if (nCel > 0) { if (nCel > 0) {
v9 = *(char **)&pCelBuff[4 * nCel]; v9 = *(LONG*)&pCelBuff[4 * nCel];
pCelBuffa = v9; pCelBuffa = v9;
v10 = (int)&v9[(_DWORD)v8]; v10 = (INT_PTR)&v8[v9];
if (*(_WORD *)(v10 + dir1)) { if (*(_WORD *)(v10 + dir1)) {
if (dir2 == 8 || (v11 = *(unsigned short *)(v10 + dir2), !*(_WORD *)(v10 + dir2))) if (dir2 == 8 || (v11 = *(unsigned short *)(v10 + dir2), !*(_WORD *)(v10 + dir2)))
v11 = *((_DWORD *)v8 + nCel + 1) - (_DWORD)pCelBuffa; v11 = *((_DWORD *)v8 + nCel + 1) - (UINT_PTR)pCelBuffa;
Cl2DecDatFrm1( Cl2DecDatFrm1(
(char *)gpBuffer + screen_y_times_768[y - 16 * dir1] + x, (char *)gpBuffer + screen_y_times_768[y - 16 * dir1] + x,
(char *)(*(unsigned short *)(v10 + dir1) + v10), (char *)(*(unsigned short *)(v10 + dir1) + v10),

2
Source/engine.h

@ -50,7 +50,7 @@ void __fastcall mem_free_dbg(void *p);
BYTE *__fastcall LoadFileInMem(char *pszName, int *pdwFileLen); BYTE *__fastcall LoadFileInMem(char *pszName, int *pdwFileLen);
void __fastcall LoadFileWithMem(char *pszName, void *buf); void __fastcall LoadFileWithMem(char *pszName, void *buf);
void __fastcall Cl2ApplyTrans(unsigned char *p, unsigned char *ttbl, int last_frame); void __fastcall Cl2ApplyTrans(unsigned char *p, unsigned char *ttbl, int last_frame);
void __fastcall Cl2DecodeFrm1(int x, int y, char *pCelBuff, int nCel, int width, int dir1, int dir2); void __fastcall Cl2DecodeFrm1(int x, int y, char *pCelBuff, int nCel, int width, INT_PTR dir1, INT_PTR dir2);
void __fastcall Cl2DecDatFrm1(char *buffer, char *frame_content, int a3, int width); void __fastcall Cl2DecDatFrm1(char *buffer, char *frame_content, int a3, int width);
void __fastcall Cl2DecodeFrm2(char colour, int screen_x, int screen_y, char *pCelBuff, int nCel, int frame_width, int a7, int a8); void __fastcall Cl2DecodeFrm2(char colour, int screen_x, int screen_y, char *pCelBuff, int nCel, int frame_width, int a7, int a8);
void __fastcall Cl2DecDatFrm2(char *buffer, char *a2, int a3, int a4, char a5); void __fastcall Cl2DecDatFrm2(char *buffer, char *a2, int a3, int a4, char a5);

20
Source/init.cpp

@ -19,35 +19,35 @@ BOOLEAN screensaver_enabled_prev;
char gszVersionNumber[260] = "internal version unknown"; char gszVersionNumber[260] = "internal version unknown";
char gszProductName[260] = "Diablo v1.09"; char gszProductName[260] = "Diablo v1.09";
void __fastcall init_cleanup(BOOLEAN show_cursor) void __fastcall init_cleanup(BOOL show_cursor)
{ {
int v1; // edi
v1 = show_cursor;
pfile_flush_W(); pfile_flush_W();
init_disable_screensaver(0); init_disable_screensaver(0);
init_run_office_from_start_menu(); init_run_office_from_start_menu();
if (diabdat_mpq) { if (diabdat_mpq) {
SFileCloseArchive(diabdat_mpq); SFileCloseArchive(diabdat_mpq);
diabdat_mpq = 0; diabdat_mpq = NULL;
} }
if (patch_rt_mpq) { if (patch_rt_mpq) {
SFileCloseArchive(patch_rt_mpq); SFileCloseArchive(patch_rt_mpq);
patch_rt_mpq = 0; patch_rt_mpq = NULL;
} }
if (unused_mpq) { if (unused_mpq) {
SFileCloseArchive(unused_mpq); SFileCloseArchive(unused_mpq);
unused_mpq = 0; unused_mpq = NULL;
} }
UiDestroy(); UiDestroy();
effects_cleanup_sfx(); effects_cleanup_sfx();
sound_cleanup(); sound_cleanup();
NetClose(); NetClose();
dx_cleanup(); dx_cleanup();
MI_Dummy(v1); MI_Dummy(show_cursor);
StormDestroy(); StormDestroy();
if (v1)
ShowCursor(1); if (show_cursor)
ShowCursor(TRUE);
} }
void __cdecl init_run_office_from_start_menu() void __cdecl init_run_office_from_start_menu()

2
Source/init.h

@ -14,7 +14,7 @@ extern void *patch_rt_mpq;
extern int killed_mom_parent; // weak extern int killed_mom_parent; // weak
extern BOOLEAN screensaver_enabled_prev; extern BOOLEAN screensaver_enabled_prev;
void __fastcall init_cleanup(BOOLEAN show_cursor); void __fastcall init_cleanup(BOOL show_cursor);
void __cdecl init_run_office_from_start_menu(); void __cdecl init_run_office_from_start_menu();
void __fastcall init_run_office(char *dir); void __fastcall init_run_office(char *dir);
void __fastcall init_disable_screensaver(BOOLEAN disable); void __fastcall init_disable_screensaver(BOOLEAN disable);

6
Source/items.cpp

@ -4210,7 +4210,7 @@ void __cdecl SortSmith()
} }
} }
} }
--j; j--;
} }
} }
@ -4404,7 +4404,7 @@ void __cdecl SortWitch()
} }
} }
} }
--j; j--;
} }
} }
@ -4617,7 +4617,7 @@ void __cdecl SortHealer()
} }
} }
} }
--j; j--;
} }
} }

8
Source/mainmenu.cpp

@ -34,7 +34,7 @@ int __stdcall mainmenu_select_hero_dialog(
char *cdesc, DWORD cdlen, char *cdesc, DWORD cdlen,
BOOL *multi) BOOL *multi)
{ {
int a6 = 1; BOOL hero_is_created = TRUE;
int dlgresult = 0; int dlgresult = 0;
if (gbMaxPlayers == 1) { if (gbMaxPlayers == 1) {
if (!UiSelHeroSingDialog( if (!UiSelHeroSingDialog(
@ -58,7 +58,7 @@ int __stdcall mainmenu_select_hero_dialog(
pfile_delete_save, pfile_delete_save,
pfile_ui_set_class_stats, pfile_ui_set_class_stats,
&dlgresult, &dlgresult,
&a6, &hero_is_created,
gszHero)) { gszHero)) {
TermMsg("Can't load multiplayer dialog"); TermMsg("Can't load multiplayer dialog");
} }
@ -70,9 +70,9 @@ int __stdcall mainmenu_select_hero_dialog(
pfile_create_player_description(cdesc, cdlen); pfile_create_player_description(cdesc, cdlen);
if (multi) { if (multi) {
if (mode == 'BNET') if (mode == 'BNET')
*multi = a6 || !plr[myplr].pBattleNet; *multi = hero_is_created || !plr[myplr].pBattleNet;
else else
*multi = a6; *multi = hero_is_created;
} }
if (cname && clen) if (cname && clen)
SStrCopy(cname, gszHero, clen); SStrCopy(cname, gszHero, clen);

83
Source/multi.cpp

@ -146,7 +146,7 @@ unsigned char *__fastcall multi_recv_packet(TBuffer *packet, unsigned char *a2,
v5 = (BYTE *)&v7[v6]; v5 = (BYTE *)&v7[v6];
*a3 -= v6; *a3 -= v6;
} }
memcpy(v3->bData, v5, (size_t)&v3->bData[v3->dwNextWriteOffset - (_DWORD)v5 + 1]); /* memcpy_0 */ memcpy(v3->bData, v5, (size_t)&v3->bData[v3->dwNextWriteOffset - (UINT_PTR)v5 + 1]); /* memcpy_0 */
v3->dwNextWriteOffset += (char *)v3 - (char *)v5 + 4; v3->dwNextWriteOffset += (char *)v3 - (char *)v5 + 4;
result = v8; result = v8;
} }
@ -862,65 +862,64 @@ void __cdecl SetupLocalCoords()
// 5CF31D: using guessed type char setlevel; // 5CF31D: using guessed type char setlevel;
// 679660: using guessed type char gbMaxPlayers; // 679660: using guessed type char gbMaxPlayers;
int __fastcall multi_init_single(_SNETPROGRAMDATA *client_info, _SNETPLAYERDATA *user_info, _SNETUIDATA *ui_info) BOOL __fastcall multi_init_single(_SNETPROGRAMDATA *client_info, _SNETPLAYERDATA *user_info, _SNETUIDATA *ui_info)
{ {
//int v3; // eax int unused;
int result; // eax
//int v5; // eax if (!SNetInitializeProvider(0, client_info, user_info, ui_info, &fileinfo)) {
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(); SErrGetLastError();
result = 0; return FALSE;
} }
return result;
unused = 0;
if (!SNetCreateGame("local", "local", "local", 0, (char *)&sgGameInitInfo.dwSeed, 8, 1, "local", "local", &unused)) {
TermMsg("SNetCreateGame1:\n%s", TraceLastError());
}
myplr = 0;
gbMaxPlayers = 1;
return TRUE;
} }
// 679660: using guessed type char gbMaxPlayers; // 679660: using guessed type char gbMaxPlayers;
BOOL __fastcall multi_init_multi(_SNETPROGRAMDATA *client_info, _SNETPLAYERDATA *user_info, _SNETUIDATA *ui_info, int *pfExitProgram) BOOL __fastcall multi_init_multi(_SNETPROGRAMDATA *client_info, _SNETPLAYERDATA *user_info, _SNETUIDATA *ui_info, int *pfExitProgram)
{ {
_SNETPLAYERDATA *v4; // ebx BOOL first;
signed int i; // edi int playerId;
int a6; // [esp+Ch] [ebp-Ch] int type;
int a2; // [esp+10h] [ebp-8h]
int type; // [esp+14h] [ebp-4h]
v4 = user_info; for (first = TRUE;; first = FALSE) {
a2 = (int)client_info; type = 0x00;
for (i = 1;; i = 0) {
type = 0;
if (byte_678640) { if (byte_678640) {
if (!UiSelectProvider(0, (_SNETPROGRAMDATA *)a2, v4, ui_info, &fileinfo, &type) if (!UiSelectProvider(0, client_info, user_info, ui_info, &fileinfo, &type)
&& (!i || SErrGetLastError() != STORM_ERROR_REQUIRES_UPGRADE || !multi_upgrade(pfExitProgram))) { && (!first || SErrGetLastError() != STORM_ERROR_REQUIRES_UPGRADE || !multi_upgrade(pfExitProgram))) {
return 0; return FALSE;
} }
if (type == 'BNET') if (type == 'BNET')
plr[0].pBattleNet = 1; plr[0].pBattleNet = 1;
} }
multi_event_handler(1); multi_event_handler(1);
if (UiSelectGame(1, (_SNETPROGRAMDATA *)a2, v4, ui_info, &fileinfo, &a6)) if (UiSelectGame(1, client_info, user_info, ui_info, &fileinfo, &playerId))
break; break;
byte_678640 = 1; byte_678640 = 1;
} }
if ((unsigned int)a6 >= MAX_PLRS)
return 0; if ((DWORD)playerId >= MAX_PLRS) {
myplr = a6; return FALSE;
gbMaxPlayers = MAX_PLRS; } else {
pfile_read_player_from_save(); myplr = playerId;
if (type == 'BNET') gbMaxPlayers = MAX_PLRS;
plr[myplr].pBattleNet = 1;
return 1; pfile_read_player_from_save();
if (type == 'BNET')
plr[myplr].pBattleNet = 1;
return TRUE;
}
} }
// 678640: using guessed type char byte_678640; // 678640: using guessed type char byte_678640;
// 679660: using guessed type char gbMaxPlayers; // 679660: using guessed type char gbMaxPlayers;

2
Source/multi.h

@ -47,7 +47,7 @@ void __fastcall buffer_init(TBuffer *pBuf);
void __fastcall multi_send_pinfo(int pnum, char cmd); void __fastcall multi_send_pinfo(int pnum, char cmd);
int __fastcall InitNewSeed(int newseed); int __fastcall InitNewSeed(int newseed);
void __cdecl SetupLocalCoords(); void __cdecl SetupLocalCoords();
int __fastcall multi_init_single(_SNETPROGRAMDATA *client_info, _SNETPLAYERDATA *user_info, _SNETUIDATA *ui_info); BOOL __fastcall multi_init_single(_SNETPROGRAMDATA *client_info, _SNETPLAYERDATA *user_info, _SNETUIDATA *ui_info);
BOOL __fastcall multi_init_multi(_SNETPROGRAMDATA *client_info, _SNETPLAYERDATA *user_info, _SNETUIDATA *ui_info, int *pfExitProgram); BOOL __fastcall multi_init_multi(_SNETPROGRAMDATA *client_info, _SNETPLAYERDATA *user_info, _SNETUIDATA *ui_info, int *pfExitProgram);
BOOL __fastcall multi_upgrade(int *pfExitProgram); BOOL __fastcall multi_upgrade(int *pfExitProgram);
void __fastcall multi_player_joins(int pnum, TCmdPlrInfoHdr *cmd, int a3); void __fastcall multi_player_joins(int pnum, TCmdPlrInfoHdr *cmd, int a3);

2
Source/town.cpp

@ -698,7 +698,7 @@ void __fastcall town_draw_town_all(BYTE *buffer, int x, int y, int a4, int dir,
// 4B8CC0: using guessed type char pcursitem; // 4B8CC0: using guessed type char pcursitem;
// 4B8CC2: using guessed type char pcursplr; // 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) void __fastcall town_draw_upper(int x, int y, int sx, int sy, INT_PTR a5, int a6, int some_flag)
{ {
signed int v7; // ebx signed int v7; // ebx
int v8; // esi int v8; // esi

2
Source/town.h

@ -12,7 +12,7 @@ void __fastcall town_draw_clipped_town_2(int x, int y, int a3, int a4, int a5, i
void __fastcall town_draw_lower_2(int x, int y, int sx, int sy, int a5, int a6, int some_flag); void __fastcall town_draw_lower_2(int x, int y, int sx, int sy, int a5, int a6, int some_flag);
void __fastcall town_draw_e_flag(BYTE *buffer, int x, int y, int a4, int dir, int sx, int sy); void __fastcall town_draw_e_flag(BYTE *buffer, int x, int y, int a4, int dir, int sx, int sy);
void __fastcall town_draw_town_all(BYTE *buffer, int x, int y, int a4, int dir, int sx, int sy, int some_flag); void __fastcall town_draw_town_all(BYTE *buffer, int x, int y, int a4, int dir, int sx, int sy, int some_flag);
void __fastcall town_draw_upper(int x, int y, int sx, int sy, int a5, int a6, int some_flag); void __fastcall town_draw_upper(int x, int y, int sx, int sy, INT_PTR a5, int a6, int some_flag);
void __fastcall T_DrawGame(int x, int y); void __fastcall T_DrawGame(int x, int y);
void __fastcall T_DrawZoom(int x, int y); void __fastcall T_DrawZoom(int x, int y);
void __fastcall T_DrawView(int StartX, int StartY); void __fastcall T_DrawView(int StartX, int StartY);

6
Stub/appfat.cpp

@ -15,12 +15,12 @@ void TermMsg(char *pszFmt, ...)
abort(); abort();
} }
void __fastcall ErrDlg(int template_id, int error_code, char *log_file_path, int log_line_nr) void __fastcall ErrDlg(int template_id, DWORD error_code, char *log_file_path, int log_line_nr)
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
void __fastcall ErrOkDlg(int template_id, int error_code, char *log_file_path, int log_line_nr) void __fastcall ErrOkDlg(int template_id, DWORD error_code, char *log_file_path, int log_line_nr)
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
@ -42,7 +42,7 @@ void __fastcall FileErrDlg(const char *error)
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
void __fastcall DDErrMsg(int error_code, int log_line_nr, char *log_file_path) void __fastcall DDErrMsg(DWORD error_code, int log_line_nr, char *log_file_path)
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }

7
Stub/main.cpp

@ -1,5 +1,10 @@
#include "../types.h" #include "../types.h"
extern "C" const char *__asan_default_options()
{
return "halt_on_error=0";
}
static std::string build_cmdline(int argc, char **argv) static std::string build_cmdline(int argc, char **argv)
{ {
std::string str; std::string str;
@ -13,7 +18,7 @@ static std::string build_cmdline(int argc, char **argv)
} }
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
auto cmdline = build_cmdline(argc, argv); auto cmdline = build_cmdline(argc, argv);
return WinMain(NULL, NULL, cmdline.c_str(), 0); return WinMain(NULL, NULL, cmdline.c_str(), 0);
} }

1
Stub/miniwin_sdl.h

@ -5,6 +5,7 @@
#include <dirent.h> #include <dirent.h>
#include <vector> #include <vector>
#include <deque> #include <deque>
#include <set>
#include <string> #include <string>
#include <functional> #include <functional>
#include <iostream> #include <iostream>

30
Stub/miniwin_thread.cpp

@ -1,5 +1,8 @@
#include "../types.h" #include "../types.h"
static std::set<HANDLE> threads;
static std::set<HANDLE> events;
struct event_emul { struct event_emul {
SDL_mutex *mutex; SDL_mutex *mutex;
SDL_cond *cond; SDL_cond *cond;
@ -15,8 +18,9 @@ uintptr_t __cdecl _beginthreadex(void *_Security, unsigned _StackSize, unsigned(
if(_InitFlag != 0) if(_InitFlag != 0)
UNIMPLEMENTED(); UNIMPLEMENTED();
// WARNING: wrong return type of _StartAddress // WARNING: wrong return type of _StartAddress
SDL_Thread *ret = SDL_CreateThread((SDL_ThreadFunction)_StartAddress, "", _ArgList); SDL_Thread *ret = SDL_CreateThread((SDL_ThreadFunction)_StartAddress, NULL, _ArgList);
*_ThrdAddr = SDL_GetThreadID(ret); *_ThrdAddr = SDL_GetThreadID(ret);
threads.insert((HANDLE)ret);
return (uintptr_t)ret; return (uintptr_t)ret;
} }
@ -81,6 +85,7 @@ HANDLE WINAPI CreateEventA(LPSECURITY_ATTRIBUTES lpEventAttributes, WINBOOL bMan
ret = (struct event_emul*)malloc(sizeof(struct event_emul)); ret = (struct event_emul*)malloc(sizeof(struct event_emul));
ret->mutex = SDL_CreateMutex(); ret->mutex = SDL_CreateMutex();
ret->cond = SDL_CreateCond(); ret->cond = SDL_CreateCond();
events.insert((HANDLE*)ret);
return ret; return ret;
} }
@ -102,7 +107,7 @@ BOOL WINAPI ResetEvent(HANDLE hEvent)
return 1; return 1;
} }
DWORD WINAPI WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds) static DWORD wait_for_sdl_cond(HANDLE hHandle, DWORD dwMilliseconds)
{ {
struct event_emul *e = (struct event_emul*)hHandle; struct event_emul *e = (struct event_emul*)hHandle;
SDL_LockMutex(e->mutex); SDL_LockMutex(e->mutex);
@ -113,6 +118,25 @@ DWORD WINAPI WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds)
ret = SDL_CondWaitTimeout(e->cond, e->mutex, dwMilliseconds); ret = SDL_CondWaitTimeout(e->cond, e->mutex, dwMilliseconds);
SDL_CondSignal(e->cond); SDL_CondSignal(e->cond);
SDL_UnlockMutex(e->mutex); SDL_UnlockMutex(e->mutex);
return ret; // return value different from WinAPI return ret;
}
static DWORD wait_for_sdl_thread(HANDLE hHandle, DWORD dwMilliseconds)
{
if(dwMilliseconds != INFINITE)
UNIMPLEMENTED();
SDL_Thread *t = (SDL_Thread*)hHandle;
SDL_WaitThread(t, NULL);
return 0;
}
DWORD WINAPI WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds)
{
// return value different from WinAPI
if(threads.find(hHandle) != threads.end())
return wait_for_sdl_thread(hHandle, dwMilliseconds);
if(events.find(hHandle) != threads.end())
return wait_for_sdl_cond(hHandle, dwMilliseconds);
UNIMPLEMENTED();
} }

12
Stub/storm_net.cpp

@ -153,8 +153,14 @@ BOOLEAN __stdcall SNetSetBasePlayer(int)
int __stdcall SNetGetProviderCaps(struct _SNETCAPS *caps) int __stdcall SNetGetProviderCaps(struct _SNETCAPS *caps)
{ {
memset(caps, 0, sizeof(struct _SNETCAPS)); caps->size = 0; // engine writes only ?!?
caps->maxplayers = 1; caps->flags = 0; // unused
caps->bytessec = 100000; caps->maxmessagesize = 512; // capped to 512; underflow if < 24
caps->maxqueuesize = 0; // unused
caps->maxplayers = gbMaxPlayers; // capped to 4
caps->bytessec = 100000; // ?
caps->latencyms = 0; // unused
caps->defaultturnssec = 10; // ?
caps->defaultturnsintransit = 10; // ?
return 1; return 1;
} }

Loading…
Cancel
Save