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);
if (v5)
SDlgSetBitmapI(hWnd, 0, &nullcharacter, -1, 1, v5, 0, 284, 148, -1);
ShowCursor(1);
ShowCursor(TRUE);
Fade_SetInputWindow(hWnd);
if (v6)
local_FitButtonDlg(hWnd, msgs, v6, data);
@ -135,7 +135,7 @@ BOOL __fastcall CopyProt_LoadCopyStuff(HWND hWnd, int a2)
// ref: 0x1000430C
void __fastcall CopyProt_EndCopyDlg(HWND hWnd, int a2)
{
ShowCursor(0);
ShowCursor(FALSE);
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
if (Msg == 2) {
ShowCursor(0);
ShowCursor(FALSE);
OkCancel_FreeDlgBmp(hWnd);
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;
goto LABEL_16;
}
ShowCursor(1);
ShowCursor(TRUE);
if (!OkCancel_LoadOkCancGFX(hWnd, (DWORD *)lParam))
SDlgEndDialog(hWnd, (HANDLE)0xFF000000);
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 )
{
ShowCursor(0);
ShowCursor(FALSE);
Progress_100095EC();
}
else if ( Msg > 0x103 )
@ -64,7 +64,7 @@ int __stdcall Progress_100094F4(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lPara
v5 = (void *)SDrawGetFrameWindow(NULL);
local_1000812B(v5);
local_1000812B(hWnd);
ShowCursor(1);
ShowCursor(TRUE);
return 1;
case 0x111u:
if ( (_WORD)wParam == 2 )

22
DiabloUI/selhero.cpp

@ -213,7 +213,14 @@ BOOL __fastcall UiValidPlayerName(char *name)
}
// 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 v8; // eax
@ -232,8 +239,8 @@ BOOL __stdcall UiSelHeroMultDialog(BOOL(__stdcall *fninfo)(BOOL(__stdcall *fninf
*dlgresult = v8;
if (name)
strcpy(name, selhero_heronamestr);
if (a6)
*a6 = selhero_is_created;
if (hero_is_created)
*hero_is_created = selhero_is_created;
return 1;
}
// 10010382: using guessed type _DWORD __stdcall SDrawGetFrameWindow();
@ -704,7 +711,14 @@ BOOL __stdcall SelHero_GetHeroInfo(_uiheroinfo *pInfo)
// 1002A428: using guessed type int selhero_numheroesleft;
// 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 v8; // edi

272
Source/appfat.cpp

@ -3,8 +3,8 @@
#include "../types.h"
char sz_error_buf[256];
int terminating; // weak
int cleanup_thread_id; // weak
BOOL terminating;
int cleanup_thread_id;
// delete overloads the delete operator.
//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
unsigned int v2; // eax
signed int v4; // eax
char *i; // ecx
v1 = error_code;
v2 = ((unsigned int)error_code >> 16) & 0x1FFF;
if (v2 == 0x0878) {
DWORD upper_code;
int size;
char *chr;
upper_code = (error_code >> 16) & 0x1FFF;
if (upper_code == 0x0878) {
TraceErrorDS(error_code, sz_error_buf, 256);
} else if (v2 == 0x0876) {
} else if (upper_code == 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);
} else if (!SErrGetErrorStr(error_code, sz_error_buf, 256)
&& !FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, error_code, 0x400, sz_error_buf, 0x100, NULL)) {
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) {
--v4;
--i;
if (*i != '\r' && *i != '\n')
size = strlen(sz_error_buf);
chr = &sz_error_buf[size - 1];
while (size > 0) {
size--;
chr--;
if (*chr != '\r' && *chr != '\n')
break;
*chr = 0x00;
}
return sz_error_buf;
}
@ -46,7 +51,7 @@ char *__fastcall GetErrorStr(int error_code)
v = #errName; \
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
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);
}
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
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()
{
int v0; // eax
v0 = GetLastError();
return GetErrorStr(v0);
return GetErrorStr(GetLastError());
}
void TermMsg(char *pszFmt, ...)
{
va_list arglist; // [esp+8h] [ebp+8h]
va_list va;
va_start(arglist, pszFmt);
va_start(va, pszFmt);
FreeDlg();
if (pszFmt)
MsgBox(pszFmt, arglist);
va_end(arglist);
init_cleanup(0);
MsgBox(pszFmt, va);
va_end(va);
init_cleanup(FALSE);
exit(1);
}
@ -219,20 +224,21 @@ void __fastcall MsgBox(char *pszFmt, va_list va)
void __cdecl FreeDlg()
{
if (terminating && cleanup_thread_id != GetCurrentThreadId())
Sleep(20000u);
terminating = 1;
Sleep(20000);
terminating = TRUE;
cleanup_thread_id = GetCurrentThreadId();
dx_cleanup();
if ((unsigned char)gbMaxPlayers > 1u) {
if (gbMaxPlayers > 1) {
if (SNetLeaveGame(3))
Sleep(2000u);
Sleep(2000);
}
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, ...)
{
@ -245,169 +251,149 @@ void DrawDlg(char *pszFmt, ...)
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 *v4; // eax
char *msg;
v3 = log_line_nr;
if (error_code) {
v4 = GetErrorStr(error_code);
TermMsg("Direct draw error (%s:%d)\n%s", log_file_path, v3, v4);
msg = GetErrorStr(error_code);
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 *v4; // eax
char *msg;
v3 = log_line_nr;
if (error_code) {
v4 = GetErrorStr(error_code);
TermMsg("Direct sound error (%s:%d)\n%s", log_file_path, v3, v4);
msg = GetErrorStr(error_code);
TermMsg("Direct sound error (%s:%d)\n%s", log_file_path, log_line_nr, msg);
}
}
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;
LONG w, h;
int screenW, screenH;
struct tagRECT Rect;
HDC hdc;
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);
w = Rect.right - Rect.left;
h = Rect.bottom - Rect.top;
hdc = GetDC(hDlg);
screenW = GetDeviceCaps(hdc, HORZRES);
screenH = GetDeviceCaps(hdc, VERTRES);
ReleaseDC(hDlg, hdc);
if (!SetWindowPos(hDlg, HWND_TOP, (screenW - w) / 2, (screenH - h) / 2, 0, 0, SWP_NOZORDER | SWP_NOSIZE)) {
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
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;
char *size;
LPARAM dwInitParam[128];
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);
size = strrchr(log_file_path, '\\');
if (size)
log_file_path = size + 1;
wsprintf((LPSTR)dwInitParam, "%s\nat: %s line %d", GetErrorStr(error_code), log_file_path, log_line_nr);
if (DialogBoxParam(ghInst, MAKEINTRESOURCE(template_id), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)dwInitParam) == -1)
TermMsg("ErrDlg: %d", template_id);
TermMsg(NULL);
}
BOOL __stdcall FuncDlg(HWND hDlg, UINT uMsg, WPARAM wParam, char *text)
{
if (uMsg == WM_INITDIALOG) {
switch (uMsg) {
case WM_INITDIALOG:
TextDlg(hDlg, text);
} else {
if (uMsg != WM_COMMAND)
return 0;
if ((_WORD)wParam == 1) {
break;
case WM_COMMAND:
if ((WORD)wParam == 1) {
EndDialog(hDlg, 1);
} else if ((_WORD)wParam == 2) {
} else if ((WORD)wParam == 2) {
EndDialog(hDlg, 0);
}
break;
default:
return FALSE;
}
return 1;
return TRUE;
}
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);
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
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);
char *size;
LPARAM dwInitParam[128];
size = strrchr(log_file_path, '\\');
if (size)
log_file_path = size + 1;
wsprintf((LPSTR)dwInitParam, "%s\nat: %s line %d", GetErrorStr(error_code), log_file_path, log_line_nr);
DialogBoxParam(ghInst, MAKEINTRESOURCE(template_id), 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)
if (!error)
error = "";
if (DialogBoxParam(ghInst, MAKEINTRESOURCE(IDD_DIALOG3), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)error) == -1)
TermMsg("FileErrDlg");
TermMsg(0);
TermMsg(NULL);
}
void __fastcall DiskFreeDlg(char *error)
{
char *v1; // esi
v1 = error;
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(0);
TermMsg(NULL);
}
BOOL __cdecl InsertCDDlg()
{
int v0; // edi
int nResult;
ShowCursor(TRUE);
ShowCursor(1);
v0 = DialogBoxParam(ghInst, MAKEINTRESOURCE(IDD_DIALOG9), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM) "");
if (v0 == -1)
nResult = DialogBoxParam(ghInst, MAKEINTRESOURCE(IDD_DIALOG9), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM) "");
if (nResult == -1)
TermMsg("InsertCDDlg");
ShowCursor(0);
return v0 == 1;
ShowCursor(FALSE);
return nResult == 1;
}
void __fastcall DirErrorDlg(char *error)
{
char *v1; // esi
v1 = error;
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(0);
TermMsg(NULL);
}

14
Source/appfat.h

@ -6,21 +6,21 @@ extern char sz_error_buf[256];
extern int terminating; // weak
extern int cleanup_thread_id; // weak
char *__fastcall GetErrorStr(int error_code);
void __fastcall TraceErrorDD(int error_code, char *error_buf, int error_buf_len);
void __fastcall TraceErrorDS(int error_code, char *error_buf, int error_buf_len);
char *__fastcall GetErrorStr(DWORD error_code);
void __fastcall TraceErrorDD(DWORD 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();
void TermMsg(char *pszFmt, ...);
void __fastcall MsgBox(char *pszFmt, va_list va);
void __cdecl FreeDlg();
void DrawDlg(char *pszFmt, ...);
void __fastcall DDErrMsg(int 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 DDErrMsg(DWORD 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 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);
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 DiskFreeDlg(char *error);
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
char *v4; // esi
int v5; // ebx
INT_PTR v5; // ebx
signed int v7; // ecx
int v8; // esi
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
char v14; // cf
unsigned int v15; // ecx
int v18; // [esp+Ch] [ebp-Ch]
INT_PTR 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];
v18 = (INT_PTR)&v6[*((_DWORD *)v5 + 1) - *(_DWORD *)v5];
_EBX = splTrans;
do {
v9 = w;
@ -523,7 +523,7 @@ void __cdecl DrawSpellList()
++v4;
v26 *= (__int64)2;
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)
v17 -= 56;
if (v17 == 20) {
@ -615,7 +615,7 @@ void __fastcall CPrintString(int No, unsigned int glyph, unsigned char col)
int *v3; // ebx
char *v4; // esi
char *v5; // edi
int v6; // ebx
INT_PTR v6; // ebx
signed int v7; // edx
unsigned int v8; // eax
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);
v4 = (char *)pPanelText + *v3;
v5 = (char *)gpBuffer + No;
v6 = (int)&v4[v3[1] - *v3];
v6 = (INT_PTR)&v4[v3[1] - *v3];
if ((_BYTE)col) {
if ((unsigned char)col == 1) {
do {
@ -2607,7 +2607,7 @@ void __cdecl DrawTalkPan()
LABEL_21:
a1 += 21720;
++v10;
if ((signed int)a1 >= (signed int)&plr[4]._pName)
if ((INT_PTR)a1 >= (INT_PTR)&plr[4]._pName)
return;
}
if (byte_4B894C[v10]) {
@ -2836,7 +2836,7 @@ void __cdecl control_press_enter()
break;
++v1;
++v0;
} while ((signed int)v1 < (signed int)&sgszTalkSave[8]);
} while ((INT_PTR)v1 < (INT_PTR)&sgszTalkSave[8]);
if (v0 < 8) {
v2 = sgbNextTalkSave;
v3 = (sgbNextTalkSave - 1) & 7;

4
Source/drlg_l1.cpp

@ -269,7 +269,7 @@ void __cdecl DRLG_L1Pass3()
--v3;
} while (v3);
v1 += 2;
} while ((signed int)v1 < (signed int)dPiece[2]);
} while ((INT_PTR)v1 < (INT_PTR)dPiece[2]);
v4 = 0;
v14 = &dPiece[17][16]; /* check */
do {
@ -365,7 +365,7 @@ void __cdecl DRLG_InitL1Vals()
} while (v6);
v7 = (int(*)[112])((char *)v7 + 4);
++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)

26
Source/drlg_l2.cpp

@ -375,7 +375,7 @@ void __fastcall LoadL2Dungeon(char *sFileName, int vx, int vy)
signed int v6; // eax
signed int v7; // ecx
int v8; // esi
int v9; // eax
INT_PTR v9; // eax
int v10; // ebx
int v11; // edi
char *v12; // eax
@ -420,7 +420,7 @@ void __fastcall LoadL2Dungeon(char *sFileName, int vx, int vy)
++v5;
} while (v5 < 40);
v8 = *v4;
v9 = (int)(v4 + 2);
v9 = (INT_PTR)(v4 + 2);
v10 = 0;
v11 = v4[2];
v12 = (char *)(v9 + 2);
@ -489,7 +489,7 @@ void __fastcall LoadL2Dungeon(char *sFileName, int vx, int vy)
} while (v21);
v33 = (int(*)[112])((char *)v33 + 4);
++v18;
} while ((signed int)v33 < (signed int)dPiece[1]);
} while ((INT_PTR)v33 < (INT_PTR)dPiece[1]);
v24 = 0;
v25 = dPiece;
do {
@ -511,7 +511,7 @@ void __fastcall LoadL2Dungeon(char *sFileName, int vx, int vy)
} while (v28);
v25 = (int(*)[112])((char *)v25 + 4);
++v24;
} while ((signed int)v25 < (signed int)dPiece[1]);
} while ((INT_PTR)v25 < (INT_PTR)dPiece[1]);
ViewX = v30;
ViewY = vy;
SetMapMonsters((unsigned char *)ptr, 0, 0);
@ -562,7 +562,7 @@ void __cdecl DRLG_L2Pass3()
--v3;
} while (v3);
v1 += 2;
} while ((signed int)v1 < (signed int)dPiece[2]);
} while ((INT_PTR)v1 < (INT_PTR)dPiece[2]);
v4 = 0;
v14 = &dPiece[17][16];
do {
@ -989,8 +989,8 @@ BOOLEAN __fastcall DRLG_L2PlaceMiniSet(unsigned char *miniset, int tmin, int tma
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_PTR v34; // [esp+20h] [ebp-14h]
INT_PTR v35; // [esp+24h] [ebp-10h]
int v36; // [esp+28h] [ebp-Ch]
int max; // [esp+2Ch] [ebp-8h]
//int v38; // [esp+30h] [ebp-4h]
@ -1084,7 +1084,7 @@ BOOLEAN __fastcall DRLG_L2PlaceMiniSet(unsigned char *miniset, int tmin, int tma
if (v34 > 0) {
v26 = &dungeon[v13][v24 + v14];
do {
v27 = v29[(_DWORD)miniset];
v27 = v29[(UINT_PTR)miniset];
if (v27)
*v26 = v27;
++miniset;
@ -1147,8 +1147,8 @@ void __fastcall DRLG_L2PlaceRndSet(unsigned char *miniset, int rndper)
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_PTR v30; // [esp+34h] [ebp-10h]
INT_PTR v31; // [esp+38h] [ebp-Ch]
int v32; // [esp+3Ch] [ebp-8h]
signed int v33; // [esp+40h] [ebp-4h]
@ -1368,7 +1368,7 @@ void __cdecl DRLG_L2Shadows()
}
}
v1 += 7;
} while ((signed int)v1 < (signed int)&SPATSL2[2].s1);
} while ((INT_PTR)v1 < (INT_PTR)&SPATSL2[2].s1);
v0 += 40;
--v9;
} while (v9);
@ -2971,7 +2971,7 @@ void __cdecl DRLG_InitL2Vals()
} while (v4);
v1 = (int(*)[112])((char *)v1 + 4);
++v0;
} while ((signed int)v1 < (signed int)dPiece[1]);
} while ((INT_PTR)v1 < (INT_PTR)dPiece[1]);
v6 = 0;
v7 = dPiece;
do {
@ -2993,5 +2993,5 @@ void __cdecl DRLG_InitL2Vals()
} while (v10);
v7 = (int(*)[112])((char *)v7 + 4);
++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;
if (sfx_stream) {
//_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)
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)
{
char *v4; // esi
int v5; // edi
INT_PTR v5; // edi
char *v6; // ebx
int v7; // edx
unsigned int v8; // eax
@ -222,7 +222,7 @@ void __fastcall CelDecDatLightTrans(char *pDecodeTo, char *pRLEBytes, int frame_
if (pDecodeTo && pRLEBytes) {
v27 = &pLightTbl[256 * light_table_index];
v4 = pRLEBytes;
v5 = (int)pDecodeTo;
v5 = (INT_PTR)pDecodeTo;
v6 = &pRLEBytes[frame_content_size];
v28 = (unsigned char)pDecodeTo & 1;
do {
@ -987,7 +987,7 @@ void __fastcall CelDecodeRect(char *pBuff, int always_0, int dst_height, int dst
char *v7; // ebx
char *v8; // esi
char *v9; // edi
int v10; // ebx
UINT_PTR v10; // ebx
int v11; // edx
unsigned int v12; // eax
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];
v9 = &pBuff[dst_width * dst_height + always_0];
dst_widtha = frame_width + dst_width;
v10 = (int)&v8[*((_DWORD *)v7 + 1) - *(_DWORD *)v7];
v10 = (UINT_PTR)&v8[*((_DWORD *)v7 + 1) - *(_DWORD *)v7];
do {
v11 = frame_width;
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 *v9; // ecx
int v10; // ecx
LONG v9; // ecx
INT_PTR v10; // ecx
int v11; // eax
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;
if (pCelBuff) {
if (nCel > 0) {
v9 = *(char **)&pCelBuff[4 * nCel];
v9 = *(LONG*)&pCelBuff[4 * nCel];
pCelBuffa = v9;
v10 = (int)&v9[(_DWORD)v8];
v10 = (INT_PTR)&v8[v9];
if (*(_WORD *)(v10 + dir1)) {
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(
(char *)gpBuffer + screen_y_times_768[y - 16 * dir1] + x,
(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);
void __fastcall LoadFileWithMem(char *pszName, void *buf);
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 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);

20
Source/init.cpp

@ -19,35 +19,35 @@ BOOLEAN screensaver_enabled_prev;
char gszVersionNumber[260] = "internal version unknown";
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();
init_disable_screensaver(0);
init_run_office_from_start_menu();
if (diabdat_mpq) {
SFileCloseArchive(diabdat_mpq);
diabdat_mpq = 0;
diabdat_mpq = NULL;
}
if (patch_rt_mpq) {
SFileCloseArchive(patch_rt_mpq);
patch_rt_mpq = 0;
patch_rt_mpq = NULL;
}
if (unused_mpq) {
SFileCloseArchive(unused_mpq);
unused_mpq = 0;
unused_mpq = NULL;
}
UiDestroy();
effects_cleanup_sfx();
sound_cleanup();
NetClose();
dx_cleanup();
MI_Dummy(v1);
MI_Dummy(show_cursor);
StormDestroy();
if (v1)
ShowCursor(1);
if (show_cursor)
ShowCursor(TRUE);
}
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 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 __fastcall init_run_office(char *dir);
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,
BOOL *multi)
{
int a6 = 1;
BOOL hero_is_created = TRUE;
int dlgresult = 0;
if (gbMaxPlayers == 1) {
if (!UiSelHeroSingDialog(
@ -58,7 +58,7 @@ int __stdcall mainmenu_select_hero_dialog(
pfile_delete_save,
pfile_ui_set_class_stats,
&dlgresult,
&a6,
&hero_is_created,
gszHero)) {
TermMsg("Can't load multiplayer dialog");
}
@ -70,9 +70,9 @@ int __stdcall mainmenu_select_hero_dialog(
pfile_create_player_description(cdesc, cdlen);
if (multi) {
if (mode == 'BNET')
*multi = a6 || !plr[myplr].pBattleNet;
*multi = hero_is_created || !plr[myplr].pBattleNet;
else
*multi = a6;
*multi = hero_is_created;
}
if (cname && 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];
*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;
result = v8;
}
@ -862,65 +862,64 @@ void __cdecl SetupLocalCoords()
// 5CF31D: using guessed type char setlevel;
// 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 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 {
int unused;
if (!SNetInitializeProvider(0, client_info, user_info, ui_info, &fileinfo)) {
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;
BOOL __fastcall multi_init_multi(_SNETPROGRAMDATA *client_info, _SNETPLAYERDATA *user_info, _SNETUIDATA *ui_info, int *pfExitProgram)
{
_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]
BOOL first;
int playerId;
int type;
v4 = user_info;
a2 = (int)client_info;
for (i = 1;; i = 0) {
type = 0;
for (first = TRUE;; first = FALSE) {
type = 0x00;
if (byte_678640) {
if (!UiSelectProvider(0, (_SNETPROGRAMDATA *)a2, v4, ui_info, &fileinfo, &type)
&& (!i || SErrGetLastError() != STORM_ERROR_REQUIRES_UPGRADE || !multi_upgrade(pfExitProgram))) {
return 0;
if (!UiSelectProvider(0, client_info, user_info, ui_info, &fileinfo, &type)
&& (!first || SErrGetLastError() != STORM_ERROR_REQUIRES_UPGRADE || !multi_upgrade(pfExitProgram))) {
return FALSE;
}
if (type == 'BNET')
plr[0].pBattleNet = 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;
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;
if ((DWORD)playerId >= MAX_PLRS) {
return FALSE;
} else {
myplr = playerId;
gbMaxPlayers = MAX_PLRS;
pfile_read_player_from_save();
if (type == 'BNET')
plr[myplr].pBattleNet = 1;
return TRUE;
}
}
// 678640: using guessed type char byte_678640;
// 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);
int __fastcall InitNewSeed(int newseed);
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_upgrade(int *pfExitProgram);
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;
// 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
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_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_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_DrawZoom(int x, int y);
void __fastcall T_DrawView(int StartX, int StartY);

6
Stub/appfat.cpp

@ -15,12 +15,12 @@ void TermMsg(char *pszFmt, ...)
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();
}
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();
}
@ -42,7 +42,7 @@ void __fastcall FileErrDlg(const char *error)
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();
}

7
Stub/main.cpp

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

1
Stub/miniwin_sdl.h

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

30
Stub/miniwin_thread.cpp

@ -1,5 +1,8 @@
#include "../types.h"
static std::set<HANDLE> threads;
static std::set<HANDLE> events;
struct event_emul {
SDL_mutex *mutex;
SDL_cond *cond;
@ -15,8 +18,9 @@ uintptr_t __cdecl _beginthreadex(void *_Security, unsigned _StackSize, unsigned(
if(_InitFlag != 0)
UNIMPLEMENTED();
// 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);
threads.insert((HANDLE)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->mutex = SDL_CreateMutex();
ret->cond = SDL_CreateCond();
events.insert((HANDLE*)ret);
return ret;
}
@ -102,7 +107,7 @@ BOOL WINAPI ResetEvent(HANDLE hEvent)
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;
SDL_LockMutex(e->mutex);
@ -113,6 +118,25 @@ DWORD WINAPI WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds)
ret = SDL_CondWaitTimeout(e->cond, e->mutex, dwMilliseconds);
SDL_CondSignal(e->cond);
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)
{
memset(caps, 0, sizeof(struct _SNETCAPS));
caps->maxplayers = 1;
caps->bytessec = 100000;
caps->size = 0; // engine writes only ?!?
caps->flags = 0; // unused
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;
}

Loading…
Cancel
Save