From 2b881e7a09e6b5d493e866b0c5786e9f1aa74667 Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Tue, 18 Sep 2018 19:42:14 -0500 Subject: [PATCH 1/6] UI splash screen fix (#296) --- DiabloUI/_temp_funcs.h | 2 +- DiabloUI/artfont.cpp | 10 +++++----- DiabloUI/diabloui.h | 2 +- DiabloUI/doom.cpp | 24 ++++++++++++------------ 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/DiabloUI/_temp_funcs.h b/DiabloUI/_temp_funcs.h index 7c124c3ab..9a5e56240 100644 --- a/DiabloUI/_temp_funcs.h +++ b/DiabloUI/_temp_funcs.h @@ -198,7 +198,7 @@ void __cdecl Doom_cpp_init(); void __fastcall Doom_ParseWndProcs(HWND hWnd, int *msgtbl, int a3, int a4); void __fastcall Doom_GetSetWndText(HWND hWnd, int msg, int nFont, int a4); void __fastcall Doom_PrintStrWithSpin(HWND hWnd, BOOL a2); -void __fastcall Doom_AllocAndSetBMP(HWND hWnd, int bmp_flags); +void __fastcall Doom_AllocAndSetBMP(HWND hWnd, int a2, int bmp_flags); /* check args, __stdcall? */ void __fastcall Doom_GetWindowROP3(HWND hWnd1, HWND hWnd2); void __fastcall Doom_ParseWndProc2(HWND hWnd, int *msgtbl, int a3, int a4); void __fastcall Doom_GetSetWndTxt2(HWND hWnd, int msg, int nFont, int a4); diff --git a/DiabloUI/artfont.cpp b/DiabloUI/artfont.cpp index c44fa7c9f..4bfbc1853 100644 --- a/DiabloUI/artfont.cpp +++ b/DiabloUI/artfont.cpp @@ -96,7 +96,7 @@ void __fastcall artfont_FreeArtFont(FontStruct *pFont) if ( pFont->active ) { - v2 = (HANDLE *)pFont->fontpal; + v2 = pFont->fonttrans; v3 = 256; do { @@ -147,11 +147,11 @@ void __fastcall artfont_LoadArtFont(FontStruct *pFont, const char *pszBinFile, c { SFileCloseFile(phFile); local_LoadArtImage(pszFileName, &pBuffer, size); - memset(pFont->fontpal, 0, 0x400u); + memset(pFont->fonttrans, 0, 0x400u); if ( pBuffer ) { v5 = 0; - a1a = (HANDLE *)pFont->fontpal; + a1a = pFont->fonttrans; do { v6 = pFont->fontbin[v5 + 2]; @@ -320,8 +320,8 @@ void __fastcall artfont_PrintFontStr(char *str, DWORD **pSurface, int sx, int sy } goto LABEL_23; } - hTransa = (HANDLE)&v5->fontpal[v6]; - if ( hTransa ) /* check */ + hTransa = v5->fonttrans[v6]; + if ( v5->fonttrans[v6] ) { v10 = pSurface[1]; if ( sx + v8 <= (signed int)v10 ) diff --git a/DiabloUI/diabloui.h b/DiabloUI/diabloui.h index 8566bd8ef..c977ac8c1 100644 --- a/DiabloUI/diabloui.h +++ b/DiabloUI/diabloui.h @@ -9,7 +9,7 @@ extern "C" { struct FontStruct { unsigned char fontbin[258]; - PALETTEENTRY fontpal[256]; + HANDLE fonttrans[256]; BOOL active; }; diff --git a/DiabloUI/doom.cpp b/DiabloUI/doom.cpp index 7ab14bb09..a86d85863 100644 --- a/DiabloUI/doom.cpp +++ b/DiabloUI/doom.cpp @@ -31,7 +31,7 @@ void __fastcall Doom_GetSetWndText(HWND hWnd, int msg, int nFont, int a4) v5 = hWnd; if ( msg ) { - Doom_AllocAndSetBMP(hWnd, 1521); + Doom_AllocAndSetBMP(hWnd, msg, 1521); Doom_GetWindowROP3(v5, v4); artfont_SetArtFont(nFont); Doom_PrintStrWithSpin(v4, a4); @@ -93,18 +93,18 @@ void __fastcall Doom_PrintStrWithSpin(HWND hWnd, BOOL a2) } // ref: 0x10006719 -void __fastcall Doom_AllocAndSetBMP(HWND hWnd, int bmp_flags) +void __fastcall Doom_AllocAndSetBMP(HWND hWnd, int a2, int bmp_flags) { - DWORD *v3; // esi + DWORD *v4; // esi struct tagRECT Rect; // [esp+8h] [ebp-10h] - GetClientRect(hWnd, &Rect); - v3 = local_AllocWndLongData(); - v3[1] = Rect.right; - v3[2] = Rect.bottom; - *v3 = (DWORD)SMemAlloc(Rect.right * Rect.bottom, "C:\\Src\\Diablo\\DiabloUI\\Doom.cpp", 139, 0); - SetWindowLongA(hWnd, -21, (LONG)v3); - SDlgSetBitmapI(hWnd, 0, &nullcharacter, -1, bmp_flags, (void *)*v3, 0, v3[1], v3[2], -1); + GetClientRect((HWND)a2, &Rect); + v4 = local_AllocWndLongData(); + v4[1] = Rect.right; + v4[2] = Rect.bottom; + *v4 = (DWORD)SMemAlloc(Rect.right * Rect.bottom, "C:\\Src\\Diablo\\DiabloUI\\Doom.cpp", 139, 0); + SetWindowLongA((HWND)a2, -21, (LONG)v4); + SDlgSetBitmapI((HWND)a2, 0, &nullcharacter, -1, bmp_flags, (void *)*v4, 0, v4[1], v4[2], -1); } // ref: 0x1000678A @@ -198,7 +198,7 @@ void __fastcall Doom_GetSetWndTxt3(HWND hWnd, int msg, int nFont) v4 = hWnd; if ( msg ) { - Doom_AllocAndSetBMP(hWnd, 1); + Doom_AllocAndSetBMP(hWnd, msg, 1); Doom_GetWindowROP3(v4, v3); artfont_SetArtFont(nFont); v5 = GetWindowLongA(v3, -16); @@ -306,7 +306,7 @@ void __fastcall Doom_GetSetWndTxt5(HWND hWnd, int msg, int nFont) v3 = (HWND)msg; if ( msg ) { - Doom_AllocAndSetBMP(hWnd, 1); + Doom_AllocAndSetBMP(hWnd, msg, 1); Doom_GetWindowROP3(hWnd, v3); artfont_SetArtFont(nFont); Doom_PrintTextMsg403(v3); From 7be8253dc9749dca2d702f87c75600e0f81731cf Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Tue, 18 Sep 2018 21:18:03 -0500 Subject: [PATCH 2/6] Implement "mainmenu.cpp" in DiabloUI (#297) --- DiabloUI/_temp_data.cpp | 11 +- DiabloUI/_temp_funcs.h | 19 +-- DiabloUI/diabloui.h | 2 +- DiabloUI/mainmenu.cpp | 276 ++++++++++++++++++---------------------- 4 files changed, 144 insertions(+), 164 deletions(-) diff --git a/DiabloUI/_temp_data.cpp b/DiabloUI/_temp_data.cpp index 01f521eb0..812604a66 100644 --- a/DiabloUI/_temp_data.cpp +++ b/DiabloUI/_temp_data.cpp @@ -14,6 +14,7 @@ int doom_cpp_float_value = 2139095040; // weak int fade_cpp_float_value = 2139095040; // weak int focus_cpp_float_value = 2139095040; // weak int local_cpp_float_value = 2139095040; // weak +int mainmenu_cpp_float_value = 2139095040; // weak int Title_cpp_float_value = 2139095040; // weak int titlesnd_cpp_float_value = 2139095040; // weak int dword_10022258 = 4; // weak @@ -43,8 +44,8 @@ int dword_10022B10[2] = { 1116, 0 }; int dword_10022B34[2] = { 1038, 0 }; int dword_10022B3C[3] = { 1056, 1054, 0 }; int dword_10022B48[2] = { 1065, 0 }; -int dword_10022BE0[2] = { 1042, 0 }; -int dword_10022BE8[6] = { 1044, 1001, 1002, 1003, 2, 0 }; +int menumsgs_1option[2] = { 1042, 0 }; +int menumsgs_5options[6] = { 1044, 1001, 1002, 1003, 2, 0 }; int dword_10022C4C[2] = { 1038, 0 }; int dword_10022C54[2] = { 1080, 0 }; int dword_10022C5C[2] = { 1108, 0 }; @@ -236,9 +237,9 @@ tagPALETTEENTRY artpal[256]; HGDIOBJ objPalette; // idb BYTE *gpCursorArt; BYTE *gpCursorArt2; -int dword_1002A0D4; // weak -char byte_1002A0D8; // idb -int dword_1002A118; // weak +int mainmenu_cpp_float; // weak +char menu_version_str[64]; +int menu_item_timer; // weak int dword_1002A120; // weak int dword_1002A124; // weak int dword_1002A128; // weak diff --git a/DiabloUI/_temp_funcs.h b/DiabloUI/_temp_funcs.h index 9a5e56240..2f559a4c3 100644 --- a/DiabloUI/_temp_funcs.h +++ b/DiabloUI/_temp_funcs.h @@ -292,15 +292,16 @@ void __cdecl local_SetCursorDefault(); void __fastcall local_SetDiabloCursor(HWND hWnd); -signed int MainMenu_10008164(); -//int __stdcall UiMainMenuDialog(char *, int, int, int); // idb -int __fastcall MainMenu_100081E3(int a1, int a2, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); -void UNKCALL MainMenu_10008354(HWND hDlg); -int __fastcall MainMenu_10008391(int a1, int a2); -void UNKCALL MainMenu_100083A8(HWND hWnd); -int __fastcall MainMenu_1000845A(int a1, int a2, int a3); -BOOL MainMenu_100084D5(); -LRESULT __fastcall MainMenu_100084FA(HWND hWnd, int a2); +void __cdecl j_MainMenu_cpp_init(); +void __cdecl MainMenu_cpp_init(); +BOOL __stdcall UiMainMenuDialog(char *name, int *pdwResult, void (__stdcall *fnSound)(char *file), int a4); +LRESULT __stdcall MainMenu_WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); +void __fastcall MainMenu_KillAndFreeMenu(HWND hWnd); +void __fastcall MainMenu_SetMenuTimer(HWND hWnd); +void __fastcall MainMenu_LoadMenuGFX(HWND hWnd); +void __fastcall MainMenu_DoOptions(HWND hWnd, int option, int PlaySelect); +BOOL __cdecl MainMenu_CheckEnoughMemory(); +void __fastcall MainMenu_CheckWParamFocus(HWND hWnd, WPARAM wParam); int Modem_1000855D(); diff --git a/DiabloUI/diabloui.h b/DiabloUI/diabloui.h index c977ac8c1..85b35e862 100644 --- a/DiabloUI/diabloui.h +++ b/DiabloUI/diabloui.h @@ -37,7 +37,7 @@ int __stdcall UiValidPlayerName(char *a1); int __stdcall UiSelHeroMultDialog(void *fninfo, void *fncreate, void *fnremove, void *fnstats, int *a5, int *a6, char *name); int __stdcall UiSelHeroSingDialog(void *fninfo, void *fncreate, void *fnremove, void *fnstats, int *a5, char *name, int *difficulty); void __stdcall UiCreditsDialog(int a1); -int __stdcall UiMainMenuDialog(char *name, int *a2, void *fnSound, int a4); +BOOL __stdcall UiMainMenuDialog(char *name, int *pdwResult, void (__stdcall *fnSound)(char *file), int a4); int __stdcall UiProgressDialog(HWND window, char *msg, int a3, void *fnfunc, int a5); int __cdecl UiProfileGetString(); void __cdecl UiProfileCallback(); diff --git a/DiabloUI/mainmenu.cpp b/DiabloUI/mainmenu.cpp index ab042291d..e37174af5 100644 --- a/DiabloUI/mainmenu.cpp +++ b/DiabloUI/mainmenu.cpp @@ -1,43 +1,38 @@ // ref: 0x10008164 -signed int MainMenu_10008164() { return 0; } -/* { - signed int result; // eax - - result = 2139095040; - dword_1002A0D4 = 2139095040; - return result; -} */ -// 1002A0D4: using guessed type int dword_1002A0D4; +void __cdecl MainMenu_cpp_init() +{ + mainmenu_cpp_float = mainmenu_cpp_float_value; +} +// 1001F434: using guessed type int mainmenu_cpp_float_value; +// 1002A0D4: using guessed type int mainmenu_cpp_float; // ref: 0x1000816F -int __stdcall UiMainMenuDialog(char *name, int *a2, void *fnSound, int a4) { return 0; } -/* { +BOOL __stdcall UiMainMenuDialog(char *name, int *pdwResult, void (__stdcall *fnSound)(char *file), int a4) +{ int v4; // eax int v5; // esi - dword_1002A118 = a4; - TitleSnd_10010306((void *)a3); - artfont_10001159(); - byte_1002A0D8 = 0; - if ( a1 ) - strncpy((char *)&byte_1002A0D8, a1, 0x40u); - v4 = SDrawGetFrameWindow(); - v5 = SDlgDialogBoxParam(hInstance, "MAINMENU_DIALOG", v4, MainMenu_100081E3, 0); + menu_item_timer = a4; + TitleSnd_SetSoundFunction(fnSound); + artfont_LoadAllFonts(); + menu_version_str[0] = 0; + if ( name ) + strncpy(menu_version_str, name, 0x40u); + v4 = (int)SDrawGetFrameWindow(); + v5 = SDlgDialogBoxParam(ghUiInst, "MAINMENU_DIALOG", v4, MainMenu_WndProc, 0); if ( v5 == 5 ) - artfont_100010C8(); - if ( a2 ) - *(_DWORD *)a2 = v5; + artfont_FreeAllFonts(); + if ( pdwResult ) + *pdwResult = v5; return 1; -} */ -// 10010370: using guessed type int __stdcall SDlgDialogBoxParam(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD); +} // 10010382: using guessed type _DWORD __stdcall SDrawGetFrameWindow(); -// 1002A118: using guessed type int dword_1002A118; +// 1002A118: using guessed type int menu_item_timer; // ref: 0x100081E3 -int __stdcall MainMenu_100081E3(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { return 0; } -/* { +LRESULT __stdcall MainMenu_WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) +{ HWND v5; // eax - int v6; // [esp+0h] [ebp-Ch] if ( Msg <= 0x113 ) { @@ -45,7 +40,7 @@ int __stdcall MainMenu_100081E3(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lPara { if ( Msg == 2 ) { - MainMenu_10008354(hWnd); + MainMenu_KillAndFreeMenu(hWnd); } else if ( Msg > 0x103 ) { @@ -58,37 +53,37 @@ int __stdcall MainMenu_100081E3(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lPara { if ( Msg == 272 ) { - MainMenu_100083A8(hWnd); + MainMenu_LoadMenuGFX(hWnd); PostMessageA(hWnd, 0x7E8u, 0, 0); return 1; } if ( Msg == 273 ) { - MainMenu_10008391(hWnd); + MainMenu_SetMenuTimer(hWnd); switch ( HIWORD(wParam) ) { case 7: - Focus_100075B7(hWnd, (HWND)lParam); + Focus_GetAndBlitSpin(hWnd, lParam); break; case 6: - Focus_10007458((void *)lParam); - Focus_100075DC(hWnd, (HWND)lParam); + Focus_CheckPlayMove(lParam); + Focus_DoBlitSpinIncFrame(hWnd, (HWND)lParam); break; case 0: - MainMenu_100084FA(hWnd, (unsigned short)wParam); + MainMenu_CheckWParamFocus(hWnd, (unsigned short)wParam); break; } } } } - return SDlgDefDialogProc(hWnd, Msg, wParam, lParam); + return (LRESULT)SDlgDefDialogProc(hWnd, Msg, (HDC)wParam, (HWND)lParam); } - if ( wParam == 3 && !DiabloUI_10005C2A() ) + if ( wParam == 3 && !DiabloUI_GetSpawned() ) { - if ( dword_10029728 ) - MainMenu_1000845A((int)hWnd, 6, 0); + if ( app_is_active ) + MainMenu_DoOptions(hWnd, 6, 0); else - MainMenu_10008391(hWnd); + MainMenu_SetMenuTimer(hWnd); } return 0; } @@ -97,156 +92,139 @@ int __stdcall MainMenu_100081E3(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lPara if ( Msg <= 0x202 ) goto LABEL_34; if ( Msg <= 0x203 ) - return SDlgDefDialogProc(hWnd, Msg, wParam, lParam); + return (LRESULT)SDlgDefDialogProc(hWnd, Msg, (HDC)wParam, (HWND)lParam); if ( Msg <= 0x205 ) { LABEL_34: - MainMenu_10008391(hWnd); - return SDlgDefDialogProc(hWnd, Msg, wParam, lParam); + MainMenu_SetMenuTimer(hWnd); + return (LRESULT)SDlgDefDialogProc(hWnd, Msg, (HDC)wParam, (HWND)lParam); } if ( Msg == 2024 ) { - if ( !Fade_1000739F() ) - Fade_100073FD(hWnd, v6); + if ( !Fade_CheckRange5() ) + Fade_SetFadeTimer((int)hWnd); return 0; } } - return SDlgDefDialogProc(hWnd, Msg, wParam, lParam); -} */ -// 1001037C: using guessed type int __stdcall SDlgDefDialogProc(_DWORD, _DWORD, _DWORD, _DWORD); + return (LRESULT)SDlgDefDialogProc(hWnd, Msg, (HDC)wParam, (HWND)lParam); +} // 10010382: using guessed type _DWORD __stdcall SDrawGetFrameWindow(); -// 10029728: using guessed type int dword_10029728; +// 10029728: using guessed type int app_is_active; // ref: 0x10008354 -void UNKCALL MainMenu_10008354(HWND hDlg) { return; } -/* { - HWND v1; // esi - _DWORD *v2; // eax - - v1 = hDlg; - Title_100100E7(hDlg); - Focus_10007818(v1); - Doom_10006C53(v1, (int *)&unk_10022BE8); - Doom_10006C53(v1, (int *)&unk_10022BE0); - v2 = (_DWORD *)GetWindowLongA(v1, -21); - local_10007F72(v2); - return local_1000811B(); -} */ +void __fastcall MainMenu_KillAndFreeMenu(HWND hWnd) +{ + void **v2; // eax + + Title_KillTitleTimer(hWnd); + Focus_KillFocusTimer(hWnd); + Doom_DeleteFreeProcs(hWnd, menumsgs_5options); + Doom_DeleteFreeProcs(hWnd, menumsgs_1option); + v2 = (void **)GetWindowLongA(hWnd, -21); + local_FreeMemPtr(v2); + local_SetCursorDefault(); +} // ref: 0x10008391 -int UNKCALL MainMenu_10008391(void *arg) { return 0; } -/* { - return SDlgSetTimer(arg, 3, 1000 * dword_1002A118, 0); -} */ -// 10010412: using guessed type int __stdcall SDlgSetTimer(_DWORD, _DWORD, _DWORD, _DWORD); -// 1002A118: using guessed type int dword_1002A118; +void __fastcall MainMenu_SetMenuTimer(HWND hWnd) +{ + SDlgSetTimer((int)hWnd, 3, 1000 * menu_item_timer, 0); +} +// 1002A118: using guessed type int menu_item_timer; // ref: 0x100083A8 -void UNKCALL MainMenu_100083A8(HWND hWnd) { return; } -/* { - HWND v1; // esi - int v2; // eax - int *v3; // edi +void __fastcall MainMenu_LoadMenuGFX(HWND hWnd) +{ + DWORD *v2; // eax MAPDST bool v4; // zf const char *v5; // eax HWND v6; // eax - HWND v7; // ST1C_4 - HWND v9; // [esp+0h] [ebp-8h] - v1 = hWnd; - v2 = local_10007F46(); - v3 = (int *)v2; + v2 = local_AllocWndLongData(); if ( v2 ) { - SetWindowLongA(v1, -21, v2); - v4 = DiabloUI_10005C2A() == 0; + SetWindowLongA(hWnd, -21, (LONG)v2); + v4 = DiabloUI_GetSpawned() == 0; v5 = "ui_art\\swmmenu.pcx"; if ( v4 ) v5 = "ui_art\\mainmenu.pcx"; - local_10007944((int)v1, 0, &byte_10029448, -1, 1, (int)v5, v3, v3 + 1, 0); - Fade_100073C5(v1, 1); + local_LoadArtWithPal(hWnd, 0, &nullcharacter, -1, 1, v5, (BYTE **)v2, v2 + 1, 0); + Fade_NoInputAndArt(hWnd, 1); } - v6 = GetDlgItem(v1, 1042); - SetWindowTextA(v6, &byte_1002A0D8); - Doom_100068AB(v1, (int *)&unk_10022BE0, 1); - Doom_1000658C(v1, (int *)&unk_10022BE8, 6, 1); - Focus_100077E9((int)v1, "ui_art\\focus42.pcx", v9); - Title_1001009E(v1, (int)"ui_art\\smlogo.pcx", v7); - MainMenu_10008391(v1); - return local_10007DE9(v1, (int *)&unk_10022BE8); -} */ + v6 = GetDlgItem(hWnd, 1042); + SetWindowTextA(v6, menu_version_str); + Doom_ParseWndProc3(hWnd, menumsgs_1option, 1); + Doom_ParseWndProcs(hWnd, menumsgs_5options, 6, 1); + Focus_SetFocusTimer(hWnd, "ui_art\\focus42.pcx"); + Title_LoadImgSetTimer(hWnd, "ui_art\\smlogo.pcx"); + MainMenu_SetMenuTimer(hWnd); + local_DoUiWndProc2(hWnd, (DWORD *)menumsgs_5options); +} // ref: 0x1000845A -int __fastcall MainMenu_1000845A(int a1, int a2, int a3) { return 0; } -/* { - int v3; // esi - int v4; // edi - - v3 = a1; - v4 = a2; - SDlgKillTimer(a1, 3); - if ( DiabloUI_10005C2A() && v4 == 3 ) +void __fastcall MainMenu_DoOptions(HWND hWnd, int option, int PlaySelect) +{ + SDlgKillTimer((int)hWnd, 3); + if ( DiabloUI_GetSpawned() && option == 3 ) { - SelYesNo_1000FD77(v3, 0x46u, 1); - return SDlgSetTimer(v3, 3, 1000 * dword_1002A118, 0); + SelYesNo_1000FD77((int)hWnd, 0x46u, 1); +LABEL_7: + SDlgSetTimer((int)hWnd, 3, 1000 * menu_item_timer, 0); + return; } - if ( v4 == 2 && !MainMenu_100084D5() ) + if ( option == 2 && !MainMenu_CheckEnoughMemory() ) { - SelYesNo_1000FD77(v3, 0x4Eu, 1); - return SDlgSetTimer(v3, 3, 1000 * dword_1002A118, 0); + SelYesNo_1000FD77((int)hWnd, 0x4Eu, 1); + goto LABEL_7; } - Fade_100073B4(); - if ( a3 ) - TitleSnd_1001031F(); - Fade_100072BE(10); - return SDlgEndDialog(v3, v4); -} */ -// 10010376: using guessed type int __stdcall SDlgEndDialog(_DWORD, _DWORD); -// 10010412: using guessed type int __stdcall SDlgSetTimer(_DWORD, _DWORD, _DWORD, _DWORD); -// 10010418: using guessed type int __stdcall SDlgKillTimer(_DWORD, _DWORD); -// 1002A118: using guessed type int dword_1002A118; + Fade_Range5SetZero(); + if ( PlaySelect ) + TitleSnd_PlaySelectSound(); + Fade_UpdatePaletteRange(10); + SDlgEndDialog(hWnd, (HANDLE)option); +} +// 1002A118: using guessed type int menu_item_timer; // ref: 0x100084D5 -BOOL MainMenu_100084D5() { return 0; } -/* { +BOOL __cdecl MainMenu_CheckEnoughMemory() +{ struct _MEMORYSTATUS Buffer; // [esp+0h] [ebp-20h] Buffer.dwLength = 32; GlobalMemoryStatus(&Buffer); return Buffer.dwTotalPhys > 0xDAC000; -} */ +} // ref: 0x100084FA -LRESULT __fastcall MainMenu_100084FA(HWND hWnd, int a2) { return 0; } -/* { - HWND v2; // esi - LRESULT result; // eax - HWND v4; // eax - LONG v5; // eax - int v6; // [esp-8h] [ebp-Ch] +void __fastcall MainMenu_CheckWParamFocus(HWND hWnd, WPARAM wParam) +{ + HWND v3; // eax + LONG v4; // eax + int v5; // [esp-8h] [ebp-Ch] - v2 = hWnd; - switch ( a2 ) + switch ( wParam ) { - case 1: - v4 = GetFocus(); - v5 = GetWindowLongA(v4, -12); - return SendMessageA(v2, 0x111u, v5, 0); - case 2: - v6 = 5; - return MainMenu_1000845A((int)hWnd, v6, 1); - case 1001: - v6 = 2; - return MainMenu_1000845A((int)hWnd, v6, 1); - case 1002: - v6 = 3; - return MainMenu_1000845A((int)hWnd, v6, 1); - case 1003: - v6 = 4; - return MainMenu_1000845A((int)hWnd, v6, 1); + case 1u: + v3 = GetFocus(); + v4 = GetWindowLongA(v3, -12); + SendMessageA(hWnd, 0x111u, v4, 0); + return; + case 2u: + v5 = 5; + goto LABEL_12; + case 0x3E9u: + v5 = 2; + goto LABEL_12; + case 0x3EAu: + v5 = 3; + goto LABEL_12; + case 0x3EBu: + v5 = 4; +LABEL_12: + MainMenu_DoOptions(hWnd, v5, 1); + return; + case 0x414u: + MainMenu_DoOptions(hWnd, 1, 1); + break; } - result = a2 - 1044; - if ( a2 == 1044 ) - result = MainMenu_1000845A((int)hWnd, 1, 1); - return result; -} */ +} From 91554056bb6ebbcdd8ad3ab1da1fdc51ebf52b96 Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Tue, 18 Sep 2018 23:25:48 -0500 Subject: [PATCH 3/6] Implement "credits.cpp" in DiabloUI (#298) --- 3rdParty/Storm/Source/storm.cpp | 1 + 3rdParty/Storm/Source/storm.def | 2 +- 3rdParty/Storm/Source/storm.h | 1 + 3rdParty/Storm/Source/storm_gcc.def | 3 +- DiabloUI/_temp_data.cpp | 21 +- DiabloUI/_temp_funcs.h | 19 +- DiabloUI/credits.cpp | 311 ++++++++++++---------------- DiabloUI/diabloui.cpp | 8 +- DiabloUI/diabloui.h | 2 +- 9 files changed, 163 insertions(+), 205 deletions(-) diff --git a/3rdParty/Storm/Source/storm.cpp b/3rdParty/Storm/Source/storm.cpp index cfb7c17e5..37c37c10d 100644 --- a/3rdParty/Storm/Source/storm.cpp +++ b/3rdParty/Storm/Source/storm.cpp @@ -247,3 +247,4 @@ BOOL __stdcall SDlgSetTimer(int a1, int a2, int a3, void (__stdcall *a4)(int, in BOOL __stdcall SDlgKillTimer(int a1, int a2) rBool; BOOL __stdcall SDlgDrawBitmap(HWND hWnd, int a2, int a3, int a4, int a5, int a6, int a7) rBool; BOOL __stdcall SDlgDialogBoxParam(HINSTANCE hInst, char *szDialog, int a3, WNDPROC func, int a5) rBool; +BOOL __stdcall SGdiTextOut(void *pBuffer, int x, int y, int mask, char *str, int len) rBool; diff --git a/3rdParty/Storm/Source/storm.def b/3rdParty/Storm/Source/storm.def index da801e1e6..7e496a979 100644 --- a/3rdParty/Storm/Source/storm.def +++ b/3rdParty/Storm/Source/storm.def @@ -187,7 +187,7 @@ EXPORTS ;SGdiRectangle @388 NONAME SGdiSelectObject @389 NONAME SGdiSetPitch @390 NONAME - ;SGdiTextOut @391 NONAME + SGdiTextOut @391 NONAME ;SGdi392 @392 NONAME Ordinal393 @393 NONAME diff --git a/3rdParty/Storm/Source/storm.h b/3rdParty/Storm/Source/storm.h index b2fc9a868..d0f384fa8 100644 --- a/3rdParty/Storm/Source/storm.h +++ b/3rdParty/Storm/Source/storm.h @@ -1310,6 +1310,7 @@ BOOL __stdcall SDlgSetTimer(int a1, int a2, int a3, void (__stdcall *a4)(int, in BOOL __stdcall SDlgKillTimer(int a1, int a2); BOOL __stdcall SDlgDrawBitmap(HWND hWnd, int a2, int a3, int a4, int a5, int a6, int a7); BOOL __stdcall SDlgDialogBoxParam(HINSTANCE hInst, char *szDialog, int a3, WNDPROC func, int a5); +BOOL __stdcall SGdiTextOut(void *pBuffer, int x, int y, int mask, char *str, int len); #ifdef __GNUC__ } diff --git a/3rdParty/Storm/Source/storm_gcc.def b/3rdParty/Storm/Source/storm_gcc.def index 2df6ba6e4..89c30ed4f 100644 --- a/3rdParty/Storm/Source/storm_gcc.def +++ b/3rdParty/Storm/Source/storm_gcc.def @@ -235,7 +235,8 @@ EXPORTS ;SGdiRectangle @388 NONAME SGdiSelectObject @389 NONAME SGdiSetPitch @390 NONAME - ;SGdiTextOut @391 NONAME + SGdiTextOut @391 NONAME + SGdiTextOut@24 @391 NONAME ;SGdi392 @392 NONAME Ordinal393 @393 NONAME diff --git a/DiabloUI/_temp_data.cpp b/DiabloUI/_temp_data.cpp index 812604a66..79867a0d1 100644 --- a/DiabloUI/_temp_data.cpp +++ b/DiabloUI/_temp_data.cpp @@ -8,6 +8,7 @@ ProfileStruct bnprofiles[4] = }; int profilemsg1[6] = { 1125, 1127, 1129, 1131, 1133, 0 }; int profilemsg2[6] = { 1126, 1128, 1130, 1132, 1134, 0 }; +int credits_cpp_float_value = 2139095040; // weak int DiabEdit_cpp_float_value = 2139095040; // weak int DiabloUI_cpp_float_value = 2139095040; // weak int doom_cpp_float_value = 2139095040; // weak @@ -185,18 +186,18 @@ int dword_100296D4; // weak int dword_100296D8; // weak int dword_100296DC; // weak int dword_100296E0; // weak -int dword_100296E8; // weak -int dword_100296EC; // weak -HGLOBAL dword_100296F0; // idb -int dword_100296F4; // weak -int dword_100296F8; // weak -int dword_100296FC; // weak -int dword_10029700; // weak -void *dword_10029704; // idb -int dword_10029708; // weak +int credittext_size; // weak +int credits_cpp_float; // weak +HGLOBAL credittext_rsrc; // idb +int credit_vertical_pos2; // idb +int credit_horz_pos; // idb +int credit_vertical_pos1; // weak +int credit_line_count; // weak +void *credit_back_img; // idb +HANDLE creditsobj; // idb int DiabEdit_cpp_float; // weak int DiabloUI_cpp_float; // weak -int dword_10029714; // weak +int sgbUiIsInitialized; // weak HINSTANCE ghUiInst; // idb int backbmp_flag1; // weak int backbmp_flag2; // weak diff --git a/DiabloUI/_temp_funcs.h b/DiabloUI/_temp_funcs.h index 2f559a4c3..dfe2df914 100644 --- a/DiabloUI/_temp_funcs.h +++ b/DiabloUI/_temp_funcs.h @@ -132,15 +132,16 @@ int __fastcall CreaDung_100051D8(int a1, int a2, int a3, int a4, int a5, int a6, signed int CreaStat_10005287(); -signed int credits_10005297(); -//signed int __stdcall UiCreditsDialog(int a1); -int __fastcall credits_100052C7(int a1, int a2, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); -HGLOBAL __fastcall credits_100053D9(HWND hWnd, int a2); -int __fastcall credits_1000543A(HWND a1, int a2); -BOOL UNKCALL credits_100055C0(HWND hWnd); -signed int UNKCALL credits_10005660(void *arg); -signed int __fastcall credits_10005736(_BYTE *a1); -int __fastcall credits_10005755(int a1, int a2); +void __cdecl j_credits_cpp_init(); +void __cdecl credits_cpp_init(); +BOOL __stdcall UiCreditsDialog(int a1); +LRESULT __stdcall credits_WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); +void __fastcall credits_FreeCreditResrc(HWND hWnd); +void __fastcall credits_LoadImgCreditTxt(HWND hWnd, LPARAM lParam); +void __fastcall credits_CalcPosROP3(HWND hWnd); +void __fastcall credits_PrintCredLines(HWND hWnd); +int __fastcall credits_GetCredLineBreak(char *str); +char *__fastcall credits_GetAdjustText(char *str, int len); void __fastcall DiabEdit_DoPaintBMP(HWND hWnd); diff --git a/DiabloUI/credits.cpp b/DiabloUI/credits.cpp index ba4b55501..5ffdabcba 100644 --- a/DiabloUI/credits.cpp +++ b/DiabloUI/credits.cpp @@ -1,38 +1,33 @@ // ref: 0x10005297 -signed int credits_10005297() { return 0; } -/* { - signed int result; // eax - - result = 2139095040; - dword_100296EC = 2139095040; - return result; -} */ -// 100296EC: using guessed type int dword_100296EC; +void __cdecl credits_cpp_init() +{ + credits_cpp_float = credits_cpp_float_value; +} +// 1001F408: using guessed type int credits_cpp_float_value; +// 100296EC: using guessed type int credits_cpp_float; // ref: 0x100052A2 -void __stdcall UiCreditsDialog(int a1) { return; } -/* { +BOOL __stdcall UiCreditsDialog(int a1) +{ int v1; // eax - v1 = SDrawGetFrameWindow(); - SDlgDialogBoxParam(hInstance, "CREDITS_DIALOG", v1, credits_100052C7, 25); + v1 = (int)SDrawGetFrameWindow(); + SDlgDialogBoxParam(ghUiInst, "CREDITS_DIALOG", v1, credits_WndProc, 25); return 1; -} */ -// 10010370: using guessed type int __stdcall SDlgDialogBoxParam(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD); +} // 10010382: using guessed type _DWORD __stdcall SDrawGetFrameWindow(); // ref: 0x100052C7 -int __fastcall credits_100052C7(int a1, int a2, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { return 0; } -/* { - HWND v7; // eax - int v8; // [esp+0h] [ebp-Ch] +LRESULT __stdcall credits_WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) +{ + HWND v5; // eax if ( Msg > 0x111 ) { if ( Msg == 275 ) { - credits_100055C0(hWnd); - return SDlgDefDialogProc(hWnd, Msg, wParam, lParam); + credits_CalcPosROP3(hWnd); + return (LRESULT)SDlgDefDialogProc(hWnd, Msg, (HDC)wParam, (HWND)lParam); } if ( Msg == 513 || Msg == 516 ) goto LABEL_12; @@ -40,17 +35,17 @@ int __fastcall credits_100052C7(int a1, int a2, HWND hWnd, UINT Msg, WPARAM wPar { if ( Msg == 2024 ) { - if ( !Fade_1000739F() ) - Fade_100073FD(hWnd, v8); + if ( !Fade_CheckRange5() ) + Fade_SetFadeTimer((int)hWnd); return 0; } - return SDlgDefDialogProc(hWnd, Msg, wParam, lParam); + return (LRESULT)SDlgDefDialogProc(hWnd, Msg, (HDC)wParam, (HWND)lParam); } if ( (_WORD)wParam != 513 && (_WORD)wParam != 516 ) - return SDlgDefDialogProc(hWnd, Msg, wParam, lParam); + return (LRESULT)SDlgDefDialogProc(hWnd, Msg, (HDC)wParam, (HWND)lParam); LABEL_25: - Title_100102D7(hWnd); - return SDlgDefDialogProc(hWnd, Msg, wParam, lParam); + Title_KillAndFadeDlg(hWnd); + return (LRESULT)SDlgDefDialogProc(hWnd, Msg, (HDC)wParam, (HWND)lParam); } if ( Msg == 273 ) goto LABEL_25; @@ -64,238 +59,196 @@ LABEL_25: { if ( Msg <= 0x105 ) { - v7 = (HWND)SDrawGetFrameWindow(); - SendMessageA(v7, Msg, wParam, lParam); + v5 = (HWND)SDrawGetFrameWindow(); + SendMessageA(v5, Msg, wParam, lParam); } else if ( Msg == 272 ) { - credits_1000543A(hWnd, lParam); + credits_LoadImgCreditTxt(hWnd, lParam); PostMessageA(hWnd, 0x7E8u, 0, 0); return 1; } } - return SDlgDefDialogProc(hWnd, Msg, wParam, lParam); + return (LRESULT)SDlgDefDialogProc(hWnd, Msg, (HDC)wParam, (HWND)lParam); } if ( wParam != 32 ) return 0; LABEL_12: - Title_100102D7(hWnd); + Title_KillAndFadeDlg(hWnd); return 0; } - credits_100053D9(hWnd, a2); - return SDlgDefDialogProc(hWnd, Msg, wParam, lParam); -} */ -// 1001037C: using guessed type int __stdcall SDlgDefDialogProc(_DWORD, _DWORD, _DWORD, _DWORD); + credits_FreeCreditResrc(hWnd); + return (LRESULT)SDlgDefDialogProc(hWnd, Msg, (HDC)wParam, (HWND)lParam); +} // 10010382: using guessed type _DWORD __stdcall SDrawGetFrameWindow(); // ref: 0x100053D9 -HGLOBAL __fastcall credits_100053D9(HWND hWnd, int a2) { return 0; } -/* { - HWND v2; // edi - _DWORD *v3; // eax - HGLOBAL result; // eax +void __fastcall credits_FreeCreditResrc(HWND hWnd) +{ + void **v2; // eax - v2 = hWnd; - if ( dword_10029708 ) + if ( creditsobj ) { - SGdiDeleteObject(hWnd, a2, dword_10029708); - dword_10029708 = 0; + SGdiDeleteObject(creditsobj); + creditsobj = 0; } - if ( dword_10029704 ) + if ( credit_back_img ) { - SMemFree(dword_10029704, "C:\\Src\\Diablo\\DiabloUI\\credits.cpp", 46, 0); - dword_10029704 = 0; + SMemFree(credit_back_img, "C:\\Src\\Diablo\\DiabloUI\\credits.cpp", 46, 0); + credit_back_img = 0; } - v3 = (_DWORD *)GetWindowLongA(v2, -21); - local_10007F72(v3); - result = dword_100296F0; - if ( dword_100296F0 ) + v2 = (void **)GetWindowLongA(hWnd, -21); + local_FreeMemPtr(v2); + if ( credittext_rsrc ) { - result = (HGLOBAL)FreeResource(dword_100296F0); - dword_100296F0 = 0; + FreeResource(credittext_rsrc); + credittext_rsrc = 0; } - return result; -} */ -// 10010340: using guessed type int __stdcall SMemFree(_DWORD, _DWORD, _DWORD, _DWORD); -// 1001038E: using guessed type int __fastcall SGdiDeleteObject(_DWORD, _DWORD, _DWORD); -// 10029704: using guessed type int dword_10029704; -// 10029708: using guessed type int dword_10029708; +} // ref: 0x1000543A -int __fastcall credits_1000543A(HWND a1, int a2) { return 0; } -/* { - int v2; // eax +void __fastcall credits_LoadImgCreditTxt(HWND hWnd, LPARAM lParam) +{ + signed int v2; // eax HRSRC v3; // eax HRSRC v4; // eax - int v5; // eax - int *v6; // esi + DWORD *v5; // eax + DWORD *v6; // esi int v7; // ebx int v8; // esi - HFONT v9; // eax - HFONT v10; // esi - int v11; // ebx - int result; // eax + HFONT v9; // eax MAPDST + BOOL v11; // ebx struct tagRECT Rect; // [esp+Ch] [ebp-18h] - HWND v14; // [esp+1Ch] [ebp-8h] - HWND hWnd; // [esp+20h] [ebp-4h] + HWND v13; // [esp+1Ch] [ebp-8h] - hWnd = a1; - if ( a2 ) - v2 = 1000 / a2; + if ( lParam ) + v2 = 1000 / lParam; else v2 = 50; - SDlgSetTimer(a1, 1, v2, 0); - v3 = FindResourceA(hInstance, "IDR_CREDITS", "TEXT_FILES"); - dword_100296F0 = LoadResource(hInstance, v3); - v4 = FindResourceA(hInstance, "IDR_CREDITS", "TEXT_FILES"); - dword_100296E8 = SizeofResource(hInstance, v4); - v5 = local_10007F46(); - v6 = (int *)v5; + SDlgSetTimer((int)hWnd, 1, v2, 0); + v3 = FindResourceA(ghUiInst, "IDR_CREDITS", "TEXT_FILES"); + credittext_rsrc = LoadResource(ghUiInst, v3); + v4 = FindResourceA(ghUiInst, "IDR_CREDITS", "TEXT_FILES"); + credittext_size = SizeofResource(ghUiInst, v4); + v5 = local_AllocWndLongData(); + v6 = v5; if ( v5 ) { - SetWindowLongA(hWnd, -21, v5); - local_10007944((int)hWnd, 0, &byte_10029448, -1, 1, (int)"ui_art\\credits.pcx", v6, v6 + 1, 0); - Fade_100073C5(hWnd, 0); + SetWindowLongA(hWnd, -21, (LONG)v5); + local_LoadArtWithPal(hWnd, 0, &nullcharacter, -1, 1, "ui_art\\credits.pcx", (BYTE **)v6, v6 + 1, 0); + Fade_NoInputAndArt(hWnd, 0); } - v14 = GetDlgItem(hWnd, 1000); - GetWindowRect(v14, &Rect); + v13 = GetDlgItem(hWnd, 1000); + GetWindowRect(v13, &Rect); v7 = Rect.right - Rect.left; v8 = Rect.bottom - Rect.top + 60; - dword_10029704 = SMemAlloc((Rect.right - Rect.left) * v8, "C:\\Src\\Diablo\\DiabloUI\\credits.cpp", 122, 0); - dword_100296F8 = v7; - dword_100296FC = v8; - local_10007A68(&Rect, 0, 30); - SDlgSetBitmapI(v14, 0, 0, -1, 1, dword_10029704, &Rect, v7, v8, -1); - dword_100296F4 = v8 - 30; - credits_100055C0(hWnd); + credit_back_img = SMemAlloc((Rect.right - Rect.left) * v8, "C:\\Src\\Diablo\\DiabloUI\\credits.cpp", 122, 0); + credit_horz_pos = v7; + credit_vertical_pos1 = v8; + local_AdjustRectSize(&Rect, 0, 30); + SDlgSetBitmapI(v13, 0, 0, -1, 1, credit_back_img, (int)&Rect, v7, v8, -1); + credit_vertical_pos2 = v8 - 30; + credits_CalcPosROP3(hWnd); v9 = CreateFontA(-17, 0, 0, 0, 700, 0, 0, 0, 0, 0, 0, 0, 0x12u, "Times New Roman"); - v10 = v9; - if ( !v9 || (v11 = SGdiImportFont(v9, &dword_10029708), result = DeleteObject(v10), !v11) ) - result = Title_100102D7(hWnd); - return result; -} */ -// 10010364: using guessed type int __stdcall SMemAlloc(_DWORD, _DWORD, _DWORD, _DWORD); -// 100103B2: using guessed type int __stdcall SGdiImportFont(_DWORD, _DWORD); -// 10010400: using guessed type int __stdcall SDlgSetBitmapI(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD); -// 10010412: using guessed type int __stdcall SDlgSetTimer(_DWORD, _DWORD, _DWORD, _DWORD); -// 100296E8: using guessed type int dword_100296E8; -// 100296F4: using guessed type int dword_100296F4; -// 100296F8: using guessed type int dword_100296F8; -// 100296FC: using guessed type int dword_100296FC; -// 10029704: using guessed type int dword_10029704; -// 10029708: using guessed type int dword_10029708; + if ( !v9 || (v11 = SGdiImportFont(v9, (int)&creditsobj), DeleteObject(v9), !v11) ) + Title_KillAndFadeDlg(hWnd); +} +// 100296E8: using guessed type int credittext_size; +// 100296FC: using guessed type int credit_vertical_pos1; // ref: 0x100055C0 -BOOL UNKCALL credits_100055C0(HWND hWnd) { return 0; } -/* { - HWND v1; // ebx +void __fastcall credits_CalcPosROP3(HWND hWnd) +{ _DWORD *v2; // edi struct tagRECT Rect; // [esp+Ch] [ebp-14h] HWND hWnda; // [esp+1Ch] [ebp-4h] - v1 = hWnd; hWnda = GetDlgItem(hWnd, 1000); - v2 = (_DWORD *)GetWindowLongA(v1, -21); + v2 = (_DWORD *)GetWindowLongA(hWnd, -21); GetWindowRect(hWnda, &Rect); - ScreenToClient(v1, (LPPOINT)&Rect); - ScreenToClient(v1, (LPPOINT)&Rect.right); + ScreenToClient(hWnd, (LPPOINT)&Rect); + ScreenToClient(hWnd, (LPPOINT)&Rect.right); SBltROP3( - dword_10029704 + 30 * dword_100296F8, - Rect.left + *v2 + Rect.top * v2[1], - dword_100296F8, + (char *)credit_back_img + 30 * credit_horz_pos, + (void *)(Rect.left + *v2 + Rect.top * v2[1]), + credit_horz_pos, Rect.bottom - Rect.top, - dword_100296F8, + credit_horz_pos, v2[1], 0, - 13369376); - --dword_100296F4; - credits_10005660(v1); + 0xCC0020u); + --credit_vertical_pos2; + credits_PrintCredLines(hWnd); InvalidateRect(hWnda, 0, 0); - return UpdateWindow(hWnda); -} */ -// 100103F4: using guessed type int __stdcall SBltROP3(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD); -// 100296F4: using guessed type int dword_100296F4; -// 100296F8: using guessed type int dword_100296F8; -// 10029704: using guessed type int dword_10029704; + UpdateWindow(hWnda); +} // ref: 0x10005660 -signed int UNKCALL credits_10005660(void *arg) { return 0; } -/* { - _BYTE *v1; // esi - signed int result; // eax +void __fastcall credits_PrintCredLines(HWND hWnd) +{ + char *v1; // esi int i; // edi - int v4; // ebp - int v5; // ebx - void *v6; // [esp+38h] [ebp-4h] - - v6 = arg; - v1 = LockResource(dword_100296F0); - dword_10029700 = dword_100296E8; - SGdiSelectObject(dword_10029708); - result = SGdiSetPitch(dword_100296F8); - for ( i = dword_100296F4; dword_10029700 > 0; v1 = (_BYTE *)result ) + int v3; // ebp + int v4; // ebx + + v1 = (char *)LockResource(credittext_rsrc); + credit_line_count = credittext_size; + SGdiSelectObject((int)creditsobj); + SGdiSetPitch(credit_horz_pos); + for ( i = credit_vertical_pos2; credit_line_count > 0; v1 = credits_GetAdjustText(v1, v4) ) { - v4 = 0; + v3 = 0; while ( *v1 == 9 ) { - v4 += 40; + v3 += 40; ++v1; - --dword_10029700; + --credit_line_count; } - result = credits_10005736(v1); - v5 = result; - if ( result == -1 ) + v4 = credits_GetCredLineBreak(v1); + if ( v4 == -1 ) break; if ( i >= 0 ) { - result = dword_100296FC - 30; - if ( i > dword_100296FC - 30 ) + if ( i > credit_vertical_pos1 - 30 ) break; - if ( v5 ) + if ( v4 ) { - SGdiTextOut(dword_10029704, v4 + 2, i + 2, 0x1000000, v1, v5); - SGdiTextOut(dword_10029704, v4, i, 16777440, v1, v5); + SGdiTextOut(credit_back_img, v3 + 2, i + 2, 0x1000000, v1, v4); + SGdiTextOut(credit_back_img, v3, i, 16777440, v1, v4); } } i += 22; - result = credits_10005755((int)v1, v5); } if ( i < 0 ) - result = Title_100102D7(v6); - return result; -} */ + Title_KillAndFadeDlg(hWnd); +} // 100103A6: using guessed type int __stdcall SGdiSetPitch(_DWORD); // 100103AC: using guessed type int __stdcall SGdiSelectObject(_DWORD); -// 10010424: using guessed type int __stdcall SGdiTextOut(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD); -// 100296E8: using guessed type int dword_100296E8; -// 100296F4: using guessed type int dword_100296F4; -// 100296F8: using guessed type int dword_100296F8; -// 100296FC: using guessed type int dword_100296FC; -// 10029700: using guessed type int dword_10029700; -// 10029704: using guessed type int dword_10029704; -// 10029708: using guessed type int dword_10029708; +// 100296E8: using guessed type int credittext_size; +// 100296FC: using guessed type int credit_vertical_pos1; +// 10029700: using guessed type int credit_line_count; // ref: 0x10005736 -signed int __fastcall credits_10005736(_BYTE *a1) { return 0; } -/* { - signed int result; // eax +int __fastcall credits_GetCredLineBreak(char *str) +{ + int result; // eax result = 0; - while ( *a1 != 13 && *a1 != 10 ) + while ( *str != 13 && *str != 10 ) { ++result; - ++a1; - if ( result > dword_10029700 ) + ++str; + if ( result > credit_line_count ) return -1; } return result; -} */ -// 10029700: using guessed type int dword_10029700; +} +// 10029700: using guessed type int credit_line_count; // ref: 0x10005755 -int __fastcall credits_10005755(int a1, int a2) { return 0; } -/* { - dword_10029700 += -2 - a2; - return a1 + a2 + 2; -} */ -// 10029700: using guessed type int dword_10029700; +char *__fastcall credits_GetAdjustText(char *str, int len) +{ + credit_line_count += -2 - len; + return &str[len + 2]; +} +// 10029700: using guessed type int credit_line_count; diff --git a/DiabloUI/diabloui.cpp b/DiabloUI/diabloui.cpp index 7b8ebd6dc..9c7323331 100644 --- a/DiabloUI/diabloui.cpp +++ b/DiabloUI/diabloui.cpp @@ -100,14 +100,14 @@ void __stdcall UiSetSpawned(BOOL bSpawned) // ref: 0x10005C73 void __cdecl UiInitialize() { - dword_10029714 = 1; + sgbUiIsInitialized = 1; TitleSnd_InitSoundFunc(); artfont_InitAllFonts(); Connect_10002EC4(); local_LoadArtCursor(); bn_prof_100021C4(); } -// 10029714: using guessed type int dword_10029714; +// 10029714: using guessed type int sgbUiIsInitialized; // ref: 0x10005C96 void __cdecl UiDestroy() @@ -115,9 +115,9 @@ void __cdecl UiDestroy() bn_prof_10002247(); local_FreeArtCursor(); Connect_10002E2B(); - dword_10029714 = 0; + sgbUiIsInitialized = 0; } -// 10029714: using guessed type int dword_10029714; +// 10029714: using guessed type int sgbUiIsInitialized; // ref: 0x10005CAD void __stdcall UiAppActivate(BOOL bActive) diff --git a/DiabloUI/diabloui.h b/DiabloUI/diabloui.h index 85b35e862..c950941ad 100644 --- a/DiabloUI/diabloui.h +++ b/DiabloUI/diabloui.h @@ -36,7 +36,7 @@ void __stdcall UiAppActivate(BOOL bActive); int __stdcall UiValidPlayerName(char *a1); int __stdcall UiSelHeroMultDialog(void *fninfo, void *fncreate, void *fnremove, void *fnstats, int *a5, int *a6, char *name); int __stdcall UiSelHeroSingDialog(void *fninfo, void *fncreate, void *fnremove, void *fnstats, int *a5, char *name, int *difficulty); -void __stdcall UiCreditsDialog(int a1); +BOOL __stdcall UiCreditsDialog(int a1); BOOL __stdcall UiMainMenuDialog(char *name, int *pdwResult, void (__stdcall *fnSound)(char *file), int a4); int __stdcall UiProgressDialog(HWND window, char *msg, int a3, void *fnfunc, int a5); int __cdecl UiProfileGetString(); From 6769eb8baffa4834297dff5663d75e405418a852 Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Wed, 19 Sep 2018 02:31:15 -0500 Subject: [PATCH 4/6] Implement hero selection in DiabloUI (P1) (#300) --- DiabloUI/_temp_data.cpp | 71 ++- DiabloUI/_temp_funcs.h | 94 ++-- DiabloUI/diabloui.h | 6 +- DiabloUI/diabloui_gcc.def | 2 +- DiabloUI/entname.cpp | 2 +- DiabloUI/mainmenu.cpp | 4 +- DiabloUI/selclass.cpp | 2 +- DiabloUI/selhero.cpp | 1080 +++++++++++++++++-------------------- DiabloUI/sellist.cpp | 2 +- DiabloUI/selload.cpp | 2 +- DiabloUI/selyesno.cpp | 260 ++++----- Source/pfile.cpp | 8 +- Source/pfile.h | 8 +- 13 files changed, 707 insertions(+), 834 deletions(-) diff --git a/DiabloUI/_temp_data.cpp b/DiabloUI/_temp_data.cpp index 79867a0d1..14ce312cc 100644 --- a/DiabloUI/_temp_data.cpp +++ b/DiabloUI/_temp_data.cpp @@ -16,6 +16,8 @@ int fade_cpp_float_value = 2139095040; // weak int focus_cpp_float_value = 2139095040; // weak int local_cpp_float_value = 2139095040; // weak int mainmenu_cpp_float_value = 2139095040; // weak +int SelHero_cpp_float_value = 2139095040; // weak +int SelYesNo_cpp_float_value = 2139095040; // weak int Title_cpp_float_value = 2139095040; // weak int titlesnd_cpp_float_value = 2139095040; // weak int dword_10022258 = 4; // weak @@ -65,9 +67,9 @@ char *off_10022F8C[4] = { "Entry1", "Entry2", "Entry3", "Entry4" }; int dword_10022F9C[2] = { 1038, 0 }; int dword_10022FA4[3] = { 1056, 1054, 0 }; int dword_10022FB0[7] = { 1117, 1118, 1119, 1120, 1121, 1122, 0 }; -int dword_10023000[2] = { 1038, 0 }; -int dword_10023008[6] = { 1057, 1058, 1059, 1060, 1061, 0 }; -int dword_10023020[6] = { 1014, 1018, 1017, 1016, 1015, 0 }; +int selhero_msgtbl_string[2] = { 1038, 0 }; +int selhero_msgtbl_3[6] = { 1057, 1058, 1059, 1060, 1061, 0 }; +int selhero_msgtbl_info[6] = { 1014, 1018, 1017, 1016, 1015, 0 }; int dword_100230F0[3] = { 1038, 1080, 0 }; int dword_100230FC[2] = { 1097, 0 }; int dword_10023104[2] = { 1098, 0 }; @@ -90,8 +92,8 @@ int dword_10023250[2] = { 1142, 0 }; int dword_10023258[2] = { 1146, 0 }; int dword_10023260[3] = { 1056, 1054, 0 }; int dword_1002326C[7] = { 1135, 1136, 1137, 1138, 1139, 1140, 0 }; -int dword_100232D4[2] = { 1026, 0 }; -int dword_100232DC[3] = { 1109, 2, 0 }; +int yesno_msgtbl2[2] = { 1026, 0 }; +int yesno_msgtbl1[3] = { 1109, 2, 0 }; int titlemsgtbl[2] = { 1067, 0 }; //data+bss @@ -297,30 +299,27 @@ char byte_1002A380[128]; // weak int dword_1002A400; // weak int dword_1002A404; // weak int dword_1002A408; // weak -int (__stdcall *dword_1002A410)(_DWORD, _DWORD); // weak -int dword_1002A414; // weak -DWORD dword_1002A418; // idb -int dword_1002A41C; // idb -int dword_1002A420; // weak -int dword_1002A424; // weak -int dword_1002A428; // weak -CHAR byte_1002A42C[8]; // idb -int (__stdcall *dword_1002A434)(_DWORD); // weak -int (__stdcall *dword_1002A438)(_DWORD); // weak -CHAR byte_1002A43C[4]; // idb -char byte_1002A440; // idb -int (UNKCALL *dword_1002A450)(_DWORD, _DWORD); // weak -CHAR byte_1002A454[4]; // idb -int dword_1002A458; // weak -int dword_1002A45C; // weak -char byte_1002A460; // weak -char byte_1002A464[18]; // idb -char byte_1002A476; // weak -int dword_1002A484; // weak -int dword_1002A48C; // weak -CHAR byte_1002A490[4]; // idb -CHAR byte_1002A494[4]; // idb -BYTE *dword_1002A498; // idb +BOOL (__stdcall *selhero_fnstats)(int, _uidefaultstats *); +int SelHero_cpp_float; // weak +DWORD selhero_width; // idb +int selhero_height; // idb +int selhero_difficulty; // weak +int selhero_hero_hassaved; // weak +int selhero_numheroesleft; // weak +char selhero_herolevel[4]; +BOOL (__stdcall *selhero_fnremove)(_uiheroinfo *); +BOOL (__stdcall *selhero_fninfo)(BOOL (__stdcall *fninfo)(_uiheroinfo *)); +char selhero_heromag[4]; +char selhero_heronamestr[16]; +BOOL (__stdcall *selhero_fncreate)(_uiheroinfo *); +char selhero_herodex[4]; +_uiheroinfo *sgpHeroInfo; +int selhero_is_created; // weak +_uiheroinfo heroinfo_create; +int selhero_is_good; // idb +char selhero_herostr[4]; +char selhero_herovit[4]; +BYTE *selhero_buffer; int dword_1002A49C; // weak void *dword_1002A4A0; // idb int dword_1002A4A4; // weak @@ -341,15 +340,15 @@ int dword_1002A4DC; // weak int dword_1002A4E0; // weak int dword_1002A4E4; // weak int dword_1002A4E8; // weak -int dword_1002A4EC; // weak +_uiheroinfo *dword_1002A4EC; // idb int dword_1002A4F0; // weak int dword_1002A4F4; // idb -LPCSTR dword_1002A4F8; // idb -int dword_1002A4FC; // weak -int dword_1002A500; // weak -int dword_1002A504; // weak -int (*dword_1002A508)(void); // weak -int dword_1002A50C; // weak +char *yesno_dialog_string; +int SelYesNo_cpp_float; // weak +int yesno_remove_focus; // weak +char *yesno_hero_name; +int (*YesNoFunc)(void); // weak +int yesno_is_popup; // weak HANDLE titlePHTrans[30]; int Title_cpp_float; // weak int titleTransIdx; // weak diff --git a/DiabloUI/_temp_funcs.h b/DiabloUI/_temp_funcs.h index dfe2df914..7f559336f 100644 --- a/DiabloUI/_temp_funcs.h +++ b/DiabloUI/_temp_funcs.h @@ -225,7 +225,7 @@ int __fastcall EntDial_10006F16(HWND hDlg, int, int); // idb signed int EntDial_10006F71(); -int __stdcall EntName_10006F7C(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam); // idb +LRESULT __stdcall EntName_WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); // idb HWND UNKCALL EntName_1000709E(HWND hDlg); int UNKCALL EntName_100070DB(HWND hWnd); // idb int __fastcall EntName_100071AC(HWND hDlg, int a2); @@ -367,7 +367,7 @@ signed int Sbar_10009CC7(); HWND __fastcall Sbar_10009CD2(HWND hDlg, int nIDDlgItem); -int __stdcall SelClass_10009D66(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam); // idb +LRESULT __stdcall SelClass_WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); // idb HWND UNKCALL SelClass_10009EC0(HWND hDlg); int UNKCALL SelClass_10009EFD(HWND hWnd); // idb int __fastcall SelClass_10009FA2(HWND hWnd, int a2); @@ -429,40 +429,41 @@ int SelGame_1000B67E(); signed int SelGame_1000B795(); -int SelHero_1000B7A0(); -int SelHero_1000B7A6(); -void UNKCALL SelHero_1000B7AC(void *arg); -char *SelHero_1000B7B3(); -void *SelHero_1000B7B9(); -int SelHero_1000B7CA(); -int __fastcall SelHero_1000B7D0(int a1, int a2); -signed int SelHero_1000B7DE(); -BOOL __fastcall SelHero_1000B899(HWND hDlg, int a2); -int __fastcall SelHero_1000B905(HWND hDlg, int a2); -HWND __fastcall SelHero_1000BA7B(HWND hDlg, const char *a2); -char *UNKCALL SelHero_1000BAB4(char *arg); -char __fastcall SelHero_1000BB26(char *a1); -int __fastcall SelHero_1000BB34(char *, char *); // idb -//int UNKCALL UiValidPlayerName(char *); // idb -//int __stdcall UiSelHeroMultDialog(int, int, int, int, int, int, char *); // idb -int __stdcall SelHero_1000BC46(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); // idb -BOOL UNKCALL SelHero_1000BDAD(HWND arg); -int *__fastcall SelHero_1000BEDB(int *a1, char *a2); -BOOL UNKCALL SelHero_1000BF33(void *location); -const char *__fastcall SelHero_1000BF4A(const char *a1, const char *a2); -int UNKCALL SelHero_1000BF6D(HWND hWnd); // idb -int UNKCALL SelHero_1000BFF9(HWND hWnd); // idb -int UNKCALL SelHero_1000C09B(HWND hWnd); // idb -signed int __fastcall SelHero_1000C0F9(int a1, char *a2); -BOOL UNKCALL SelHero_1000C21A(HWND hWnd); -int UNKCALL SelHero_1000C269(HWND hWnd); // idb -void UNKCALL SelHero_1000C364(HWND hDlg); -BOOL __fastcall SelHero_1000C3CE(_DWORD *a1); -int __fastcall SelHero_1000C3E2(int a1, int a2); -int UNKCALL SelHero_1000C3FF(HWND hWnd); // idb -BOOL UNKCALL SelHero_1000C49F(HWND hWnd, void *a2); -signed int __stdcall SelHero_1000C541(void *a1); -//int __stdcall UiSelHeroSingDialog(int, int, int, int, int, char *, int); // idb +_uiheroinfo *__cdecl SelHero_GetCurrentHeroInfo(); +int __cdecl SelHero_GetNumHeroesLeft(); +void __fastcall SelHero_SetHeroDifficulty(int diff); +char *__cdecl SelHero_GetHeroNameStr(); +_uiheroinfo *__cdecl SelHero_AllocHeroInfo(); +int __cdecl SelHero_GetHeroIsGood(); +int __fastcall SelHero_SetClassStats(int heroclass, _uidefaultstats *pStats); +void __cdecl j_SelHero_cpp_init(); +void __cdecl SelHero_cpp_init(); +void __fastcall SelHero_SetStaticBMP(HWND hWnd, int adjust_size); +void __fastcall SelHero_PrintHeroInfo(HWND hWnd, _uiheroinfo *pInfo); +void __fastcall SelHero_SetStringWithMsg(HWND hWnd, const char *str); +BOOL __fastcall SelHero_IsNameReserved(char *name); +void __fastcall SelHero_SetLastNamePos(char *name); +BOOL __fastcall SelHero_NameHasChar(char *name, char *illegalchrs); +BOOL __fastcall UiValidPlayerName(char *name); +BOOL __stdcall UiSelHeroMultDialog(BOOL (__stdcall *fninfo)(BOOL (__stdcall *fninfofunc)(_uiheroinfo *)), BOOL (__stdcall *fncreate)(_uiheroinfo *), BOOL (__stdcall *fnremove)(_uiheroinfo *), BOOL (__stdcall *fnstats)(int, _uidefaultstats *), int *dlgresult, int *a6, char *name); +LRESULT __stdcall SelHero_WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); +void __fastcall SelHero_DoStuffWithStrings(HWND hWnd); +_uiheroinfo *__fastcall SelHero_GetNextHeroFromStr(_uiheroinfo *pInfo, char *name); +void __fastcall SelHero_FreeSomeMemory(void *ptr); +_uiheroinfo *__fastcall SelHero_GetHeroSlotFromName(_uiheroinfo *pInfo, const char *name); +void __fastcall SelHero_DoHeroSelList(HWND hWnd); +void __fastcall SelHero_DoHeroSelClass(HWND hWnd); +void __fastcall SelHero_DoEnterName(HWND hWnd); +BOOL __fastcall SelHero_CreateHero(HWND hWnd, char *name); +void __fastcall SelHero_DoSelLoad(HWND hWnd); +void __fastcall SelHero_DoSelDiff(HWND hWnd); +void __fastcall SelHero_DeleteAndFree(HWND hWnd); +void __fastcall SelHero_FreeAllHeroes(_uiheroinfo *pInfo); +void __fastcall SelHero_DoHeroEndFade(HWND hWnd, int a2); +void __fastcall SelHero_LoadHeroGFX(HWND hWnd); +void __fastcall SelHero_SelectHeroRegion(HWND hWnd); +BOOL __stdcall SelHero_GetHeroInfo(_uiheroinfo *pInfo); +BOOL __stdcall UiSelHeroSingDialog(BOOL (__stdcall *fninfo)(BOOL (__stdcall *fninfofunc)(_uiheroinfo *)), BOOL (__stdcall *fncreate)(_uiheroinfo *), BOOL (__stdcall *fnremove)(_uiheroinfo *), BOOL (__stdcall *fnstats)(int, _uidefaultstats *), int *dlgresult, char *name, int *difficulty); void *SelIPX_1000C610(); @@ -503,7 +504,7 @@ HWND __fastcall SelIPX_1000D696(HWND hDlg, int a2, int height); signed int SelList_1000D769(); -int __stdcall SelList_1000D774(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam); // idb +LRESULT __stdcall SelList_WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); // idb HWND UNKCALL SelList_1000D916(HWND hDlg); HWND __fastcall SelList_1000D964(HWND hDlg, int nIDDlgItem); HWND UNKCALL SelList_1000D9CF(HWND hDlg); @@ -524,7 +525,7 @@ HWND UNKCALL SelList_1000E043(HWND hWnd); int __fastcall SelList_1000E0CA(HWND hWnd, int, int); // idb -int __stdcall SelLoad_1000E1C2(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam); // idb +LRESULT __stdcall SelLoad_WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); // idb HWND UNKCALL SelLoad_1000E30E(HWND hDlg); int UNKCALL SelLoad_1000E34B(HWND hWnd); // idb int __fastcall SelLoad_1000E3E2(int a1, LONG a2); @@ -590,14 +591,15 @@ HWND __fastcall SelRegn_1000F929(HWND hWnd, int a2, int height); //signed int __stdcall UiSelectRegion(_DWORD *a1); -int __fastcall SelYesNo_1000FA49(int a1, const CHAR *a2, int a3, int a4); -int __stdcall SelYesNo_1000FA87(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam); // idb -HWND UNKCALL SelYesNo_1000FBC7(HWND hDlg); -void UNKCALL SelYesNo_1000FC1C(HWND hWnd); -int __fastcall SelYesNo_1000FCF6(int a1, LONG a2); -int __fastcall SelYesNo_1000FD39(int a1, const CHAR *a2, int a3, int a4); -int __fastcall SelYesNo_1000FD77(int a1, UINT a2, int a3); -signed int SelYesNo_1000FDE3(); +int __fastcall SelYesNo_YesNoDialog(HWND hWnd, char *dialogstr, char *hero, int nofocus); /* void */ +LRESULT __stdcall SelYesNo_WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); +void __fastcall SelYesNo_RemoveYNDialog(HWND hWnd); +void __fastcall SelYesNo_LoadSelYN_GFX(HWND hWnd); +void __fastcall SelYesNo_DoSelectYesNo(HWND hWnd, int option); +int __fastcall SelYesNo_SelOkDialog(HWND hWnd, char *dialogstr, char *hero, int nofocus); /* void */ +int __fastcall SelYesNo_SpawnErrDialog(HWND hWnd, int string_rsrc, int is_popup); /* void */ +void __cdecl j_SelYesNo_cpp_init(); +void __cdecl SelYesNo_cpp_init(); void __fastcall Title_BlitTitleBuffer(HWND hWnd); diff --git a/DiabloUI/diabloui.h b/DiabloUI/diabloui.h index c950941ad..94760e660 100644 --- a/DiabloUI/diabloui.h +++ b/DiabloUI/diabloui.h @@ -33,9 +33,9 @@ BOOL __stdcall UiTitleDialog(int a1); void __cdecl UiInitialize(); void __stdcall UiCopyProtError(int a1); void __stdcall UiAppActivate(BOOL bActive); -int __stdcall UiValidPlayerName(char *a1); -int __stdcall UiSelHeroMultDialog(void *fninfo, void *fncreate, void *fnremove, void *fnstats, int *a5, int *a6, char *name); -int __stdcall UiSelHeroSingDialog(void *fninfo, void *fncreate, void *fnremove, void *fnstats, int *a5, char *name, int *difficulty); +BOOL __fastcall UiValidPlayerName(char *name); /* check __stdcall */ +BOOL __stdcall UiSelHeroMultDialog(BOOL (__stdcall *fninfo)(BOOL (__stdcall *fninfofunc)(_uiheroinfo *)), BOOL (__stdcall *fncreate)(_uiheroinfo *), BOOL (__stdcall *fnremove)(_uiheroinfo *), BOOL (__stdcall *fnstats)(int, _uidefaultstats *), int *dlgresult, int *a6, char *name); +BOOL __stdcall UiSelHeroSingDialog(BOOL (__stdcall *fninfo)(BOOL (__stdcall *fninfofunc)(_uiheroinfo *)), BOOL (__stdcall *fncreate)(_uiheroinfo *), BOOL (__stdcall *fnremove)(_uiheroinfo *), BOOL (__stdcall *fnstats)(int, _uidefaultstats *), int *dlgresult, char *name, int *difficulty); BOOL __stdcall UiCreditsDialog(int a1); BOOL __stdcall UiMainMenuDialog(char *name, int *pdwResult, void (__stdcall *fnSound)(char *file), int a4); int __stdcall UiProgressDialog(HWND window, char *msg, int a3, void *fnfunc, int a5); diff --git a/DiabloUI/diabloui_gcc.def b/DiabloUI/diabloui_gcc.def index e0fb2e293..446659519 100644 --- a/DiabloUI/diabloui_gcc.def +++ b/DiabloUI/diabloui_gcc.def @@ -2,7 +2,7 @@ LIBRARY "DiabloUI" EXPORTS UiValidPlayerName @1 - UiValidPlayerName@4 @1 + @UiValidPlayerName@4 @1 UiAppActivate @2 UiAppActivate@4 @2 UiArtCallback @3 diff --git a/DiabloUI/entname.cpp b/DiabloUI/entname.cpp index 40671b119..1ab677aa9 100644 --- a/DiabloUI/entname.cpp +++ b/DiabloUI/entname.cpp @@ -1,5 +1,5 @@ // ref: 0x10006F7C -int __stdcall EntName_10006F7C(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam) { return 0; } +LRESULT __stdcall EntName_WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { return 0; } /* { int v4; // edx HWND v5; // eax diff --git a/DiabloUI/mainmenu.cpp b/DiabloUI/mainmenu.cpp index e37174af5..1fb42bf31 100644 --- a/DiabloUI/mainmenu.cpp +++ b/DiabloUI/mainmenu.cpp @@ -167,14 +167,14 @@ void __fastcall MainMenu_DoOptions(HWND hWnd, int option, int PlaySelect) SDlgKillTimer((int)hWnd, 3); if ( DiabloUI_GetSpawned() && option == 3 ) { - SelYesNo_1000FD77((int)hWnd, 0x46u, 1); + SelYesNo_SpawnErrDialog(hWnd, 70, 1); LABEL_7: SDlgSetTimer((int)hWnd, 3, 1000 * menu_item_timer, 0); return; } if ( option == 2 && !MainMenu_CheckEnoughMemory() ) { - SelYesNo_1000FD77((int)hWnd, 0x4Eu, 1); + SelYesNo_SpawnErrDialog(hWnd, 78, 1); goto LABEL_7; } Fade_Range5SetZero(); diff --git a/DiabloUI/selclass.cpp b/DiabloUI/selclass.cpp index c8c96ea75..265b66e06 100644 --- a/DiabloUI/selclass.cpp +++ b/DiabloUI/selclass.cpp @@ -1,5 +1,5 @@ // ref: 0x10009D66 -int __stdcall SelClass_10009D66(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam) { return 0; } +LRESULT __stdcall SelClass_WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { return 0; } /* { HWND v4; // eax LONG v5; // edx diff --git a/DiabloUI/selhero.cpp b/DiabloUI/selhero.cpp index 2250407a1..f6e610f90 100644 --- a/DiabloUI/selhero.cpp +++ b/DiabloUI/selhero.cpp @@ -1,85 +1,71 @@ // ref: 0x1000B7A0 -int SelHero_1000B7A0() { return 0; } -/* { - return dword_1002A458; -} */ -// 1002A458: using guessed type int dword_1002A458; +_uiheroinfo *__cdecl SelHero_GetCurrentHeroInfo() +{ + return sgpHeroInfo; +} // ref: 0x1000B7A6 -int SelHero_1000B7A6() { return 0; } -/* { - return dword_1002A428; -} */ -// 1002A428: using guessed type int dword_1002A428; +int __cdecl SelHero_GetNumHeroesLeft() +{ + return selhero_numheroesleft; +} +// 1002A428: using guessed type int selhero_numheroesleft; // ref: 0x1000B7AC -void UNKCALL SelHero_1000B7AC(void *arg) { return; } -/* { - dword_1002A420 = (int)arg; -} */ -// 1002A420: using guessed type int dword_1002A420; +void __fastcall SelHero_SetHeroDifficulty(int diff) +{ + selhero_difficulty = diff; +} +// 1002A420: using guessed type int selhero_difficulty; // ref: 0x1000B7B3 -char *SelHero_1000B7B3() { return 0; } -/* { - return &byte_1002A440; -} */ +char *__cdecl SelHero_GetHeroNameStr() +{ + return selhero_heronamestr; +} // ref: 0x1000B7B9 -void *SelHero_1000B7B9() { return 0; } -/* { - return SMemAlloc(44, "C:\\Src\\Diablo\\DiabloUI\\SelHero.cpp", 123, 0); -} */ -// 10010364: using guessed type int __stdcall SMemAlloc(_DWORD, _DWORD, _DWORD, _DWORD); +_uiheroinfo *__cdecl SelHero_AllocHeroInfo() +{ + return (_uiheroinfo *)SMemAlloc(0x2Cu, "C:\\Src\\Diablo\\DiabloUI\\SelHero.cpp", 123, 0); +} // ref: 0x1000B7CA -int SelHero_1000B7CA() { return 0; } -/* { - return dword_1002A48C; -} */ -// 1002A48C: using guessed type int dword_1002A48C; +int __cdecl SelHero_GetHeroIsGood() +{ + return selhero_is_good; +} // ref: 0x1000B7D0 -int __fastcall SelHero_1000B7D0(int a1, int a2) { return 0; } -/* { - return dword_1002A410(a1, a2); -} */ -// 1002A410: using guessed type int (__stdcall *dword_1002A410)(_DWORD, _DWORD); +int __fastcall SelHero_SetClassStats(int heroclass, _uidefaultstats *pStats) +{ + return selhero_fnstats(heroclass, pStats); +} // ref: 0x1000B7DE -signed int SelHero_1000B7DE() { return 0; } -/* { - signed int result; // eax - - result = 2139095040; - dword_1002A414 = 2139095040; - return result; -} */ -// 1002A414: using guessed type int dword_1002A414; +void __cdecl SelHero_cpp_init() +{ + SelHero_cpp_float = SelHero_cpp_float_value; +} +// 1001F460: using guessed type int SelHero_cpp_float_value; +// 1002A414: using guessed type int SelHero_cpp_float; // ref: 0x1000B899 -int __fastcall SelHero_1000B899(HWND hDlg, int a2) { return 0; } -/* { - int v2; // ebx +void __fastcall SelHero_SetStaticBMP(HWND hWnd, int adjust_size) +{ HWND v3; // esi struct tagRECT Rect; // [esp+8h] [ebp-10h] - v2 = a2; - v3 = GetDlgItem(hDlg, 1040); + v3 = GetDlgItem(hWnd, 1040); InvalidateRect(v3, 0, 0); GetClientRect(v3, &Rect); - local_10007A68(&Rect, 0, v2 * Rect.bottom); - return SDlgSetBitmapI(v3, 0, "Static", -1, 1, dword_1002A498, &Rect, dword_1002A418, dword_1002A41C, -1); -} */ -// 10010400: using guessed type int __stdcall SDlgSetBitmapI(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD); -// 1002A418: using guessed type int dword_1002A418; -// 1002A41C: using guessed type int dword_1002A41C; -// 1002A498: using guessed type int dword_1002A498; + local_AdjustRectSize(&Rect, 0, adjust_size * Rect.bottom); + SDlgSetBitmapI(v3, 0, "Static", -1, 1, selhero_buffer, (int)&Rect, selhero_width, selhero_height, -1); +} // ref: 0x1000B905 -int __fastcall SelHero_1000B905(HWND hDlg, int a2) { return 0; } -/* { - HWND v2; // ebp +void __fastcall SelHero_PrintHeroInfo(HWND hWnd, _uiheroinfo *pInfo) +{ HWND v3; // eax int v4; // eax HWND v5; // eax @@ -90,255 +76,218 @@ int __fastcall SelHero_1000B905(HWND hDlg, int a2) { return 0; } int v10; // eax HWND v11; // eax int v12; // eax - int result; // eax - int v14; // esi - HWND v15; // edi - HWND v16; // ebp - int v17; // eax - HWND hWnd; // ST1C_4 - int v19; // eax - HWND v20; // ST1C_4 - int v21; // eax - HWND v22; // ST1C_4 - int v23; // eax - HWND v24; // ST1C_4 - int v25; // eax - HWND hDlga; // [esp+Ch] [ebp-4h] - - v14 = a2; - v15 = hDlg; - hDlga = hDlg; - if ( *(_WORD *)(a2 + 20) ) + HWND v15; // ebp + int v16; // eax + HWND v17; // ST1C_4 + int v18; // eax + HWND v19; // ST1C_4 + int v20; // eax + HWND v21; // ST1C_4 + int v22; // eax + HWND v23; // ST1C_4 + int v24; // eax + + if ( pInfo->level ) { - dword_1002A424 = *(_DWORD *)(a2 + 36); - strcpy(&byte_1002A440, (const char *)(a2 + 4)); - v16 = GetDlgItem(v15, 1014); - wsprintfA(byte_1002A42C, "%d", *(unsigned short *)(v14 + 20)); - v17 = GetWindowLongA(v16, -21); - local_10007FA4(v17, byte_1002A42C); - hWnd = GetDlgItem(hDlga, 1018); - wsprintfA(byte_1002A490, "%d", *(unsigned short *)(v14 + 24)); - v19 = GetWindowLongA(hWnd, -21); - local_10007FA4(v19, byte_1002A490); - v20 = GetDlgItem(hDlga, 1017); - wsprintfA(byte_1002A43C, "%d", *(unsigned short *)(v14 + 26)); - v21 = GetWindowLongA(v20, -21); - local_10007FA4(v21, byte_1002A43C); - v22 = GetDlgItem(hDlga, 1016); - wsprintfA(byte_1002A454, "%d", *(unsigned short *)(v14 + 28)); - v23 = GetWindowLongA(v22, -21); - local_10007FA4(v23, byte_1002A454); - v24 = GetDlgItem(hDlga, 1015); - wsprintfA(byte_1002A494, "%d", *(unsigned short *)(v14 + 30)); - v25 = GetWindowLongA(v24, -21); - local_10007FA4(v25, byte_1002A494); - SelHero_1000B899(hDlga, *(unsigned char *)(v14 + 22)); - result = Doom_10006A13(hDlga, (int *)&unk_10023020, 1); + selhero_hero_hassaved = pInfo->hassaved; + strcpy(selhero_heronamestr, pInfo->name); + v15 = GetDlgItem(hWnd, 1014); + wsprintfA(selhero_herolevel, "%d", pInfo->level); + v16 = GetWindowLongA(v15, -21); + local_SetWndLongStr(v16, selhero_herolevel); + v17 = GetDlgItem(hWnd, 1018); + wsprintfA(selhero_herostr, "%d", pInfo->strength); + v18 = GetWindowLongA(v17, -21); + local_SetWndLongStr(v18, selhero_herostr); + v19 = GetDlgItem(hWnd, 1017); + wsprintfA(selhero_heromag, "%d", pInfo->magic); + v20 = GetWindowLongA(v19, -21); + local_SetWndLongStr(v20, selhero_heromag); + v21 = GetDlgItem(hWnd, 1016); + wsprintfA(selhero_herodex, "%d", pInfo->dexterity); + v22 = GetWindowLongA(v21, -21); + local_SetWndLongStr(v22, selhero_herodex); + v23 = GetDlgItem(hWnd, 1015); + wsprintfA(selhero_herovit, "%d", pInfo->vitality); + v24 = GetWindowLongA(v23, -21); + local_SetWndLongStr(v24, selhero_herovit); + SelHero_SetStaticBMP(hWnd, pInfo->heroclass); + Doom_ParseWndProc4(hWnd, selhero_msgtbl_info, 1); } else { - dword_1002A424 = 0; - byte_1002A440 = 0; - v2 = hDlg; - v3 = GetDlgItem(hDlg, 1014); + selhero_hero_hassaved = 0; + selhero_heronamestr[0] = 0; + v3 = GetDlgItem(hWnd, 1014); v4 = GetWindowLongA(v3, -21); - local_10007FA4(v4, "--"); - v5 = GetDlgItem(v2, 1018); + local_SetWndLongStr(v4, "--"); + v5 = GetDlgItem(hWnd, 1018); v6 = GetWindowLongA(v5, -21); - local_10007FA4(v6, "--"); - v7 = GetDlgItem(v2, 1017); + local_SetWndLongStr(v6, "--"); + v7 = GetDlgItem(hWnd, 1017); v8 = GetWindowLongA(v7, -21); - local_10007FA4(v8, "--"); - v9 = GetDlgItem(v2, 1016); + local_SetWndLongStr(v8, "--"); + v9 = GetDlgItem(hWnd, 1016); v10 = GetWindowLongA(v9, -21); - local_10007FA4(v10, "--"); - v11 = GetDlgItem(v2, 1015); + local_SetWndLongStr(v10, "--"); + v11 = GetDlgItem(hWnd, 1015); v12 = GetWindowLongA(v11, -21); - local_10007FA4(v12, "--"); - SelHero_1000B899(v2, 3); - result = Doom_10006A13(v2, (int *)&unk_10023020, 1); + local_SetWndLongStr(v12, "--"); + SelHero_SetStaticBMP(hWnd, 3); + Doom_ParseWndProc4(hWnd, selhero_msgtbl_info, 1); } - return result; -} */ -// 1002A424: using guessed type int dword_1002A424; +} +// 1002A424: using guessed type int selhero_hero_hassaved; // ref: 0x1000BA7B -HWND __fastcall SelHero_1000BA7B(HWND hDlg, const char *a2) { return 0; } -/* { - HWND v2; // esi - const char *v3; // edi - HWND result; // eax +void __fastcall SelHero_SetStringWithMsg(HWND hWnd, const char *str) +{ + HWND v4; // eax int v5; // eax - v2 = hDlg; - v3 = a2; - result = GetDlgItem(hDlg, 1038); - if ( result ) + v4 = GetDlgItem(hWnd, 1038); + if ( v4 ) { - v5 = GetWindowLongA(result, -21); - local_10007FA4(v5, v3); - result = (HWND)Doom_10006A13(v2, (int *)&unk_10023000, 5); + v5 = GetWindowLongA(v4, -21); + local_SetWndLongStr(v5, str); + Doom_ParseWndProc4(hWnd, selhero_msgtbl_string, 5); } - return result; -} */ +} // ref: 0x1000BAB4 -char *UNKCALL SelHero_1000BAB4(char *arg) { return 0; } -/* { +BOOL __fastcall SelHero_IsNameReserved(char *name) +{ UINT v1; // esi - char *result; // eax - CHAR SrcStr; // [esp+4h] [ebp-90h] - CHAR Buffer; // [esp+84h] [ebp-10h] + BOOL result; // eax + char SrcStr[128]; // [esp+4h] [ebp-90h] + char Buffer[16]; // [esp+84h] [ebp-10h] - strcpy(&SrcStr, arg); - _strlwr(&SrcStr); + strcpy(SrcStr, name); + _strlwr(SrcStr); v1 = 19; while ( 1 ) { - LoadStringA(hInstance, v1, &Buffer, 15); - SelHero_1000BB26(&Buffer); - _strlwr(&Buffer); - result = strstr(&SrcStr, &Buffer); + LoadStringA(ghUiInst, v1, Buffer, 15); + SelHero_SetLastNamePos(Buffer); + _strlwr(Buffer); + result = (BOOL)strstr(SrcStr, Buffer); if ( result ) break; if ( (signed int)++v1 > 26 ) return result; } - return (char *)1; -} */ + return 1; +} // ref: 0x1000BB26 -char __fastcall SelHero_1000BB26(char *a1) { return 0; } -/* { - char result; // al - - while ( 1 ) - { - result = *a1; - if ( !*a1 ) - break; - *a1++ = result - 1; - } - return result; -} */ +void __fastcall SelHero_SetLastNamePos(char *name) +{ + while ( *name ) + --*name++; +} // ref: 0x1000BB34 -int __fastcall SelHero_1000BB34(char *a1, char *a2) { return 0; } -/* { - char *v2; // esi - char *v3; // edi +BOOL __fastcall SelHero_NameHasChar(char *name, char *illegalchrs) +{ char v5; // al - v2 = a1; - v3 = a2; - if ( strpbrk(a1, ",<>%&\\\"?*#/:") || strpbrk(v2, v3) ) + if ( strpbrk(name, ",<>%&\\\"?*#/:") || strpbrk(name, illegalchrs) ) return 1; while ( 1 ) { - v5 = *v2; - if ( !*v2 ) + v5 = *name; + if ( !*name ) break; if ( (unsigned char)v5 < 0x20u || (unsigned char)v5 > 0x7Eu && (unsigned char)v5 < 0xC0u ) return 1; - ++v2; + ++name; } return 0; -} */ +} // ref: 0x1000BB75 -int __stdcall UiValidPlayerName(char *arg) { return 0; } -/* { - char *v1; // esi - signed int v2; // edi +BOOL __fastcall UiValidPlayerName(char *name) +{ + BOOL v2; // edi - v1 = arg; v2 = 1; - if ( !strlen(arg) ) + if ( !strlen(name) ) v2 = 0; - if ( dword_1002A48C == 1 && (SelHero_1000BAB4(v1) || SelHero_1000BB34(v1, " ")) ) + if ( selhero_is_good == 1 && (SelHero_IsNameReserved(name) || SelHero_NameHasChar(name, " ")) ) v2 = 0; return v2; -} */ -// 1002A48C: using guessed type int dword_1002A48C; +} // ref: 0x1000BBB4 -int __stdcall UiSelHeroMultDialog(void *fninfo, void *fncreate, void *fnremove, void *fnstats, int *a5, int *a6, char *name) { return 0; } -/* { +BOOL __stdcall UiSelHeroMultDialog(BOOL (__stdcall *fninfo)(BOOL (__stdcall *fninfofunc)(_uiheroinfo *)), BOOL (__stdcall *fncreate)(_uiheroinfo *), BOOL (__stdcall *fnremove)(_uiheroinfo *), BOOL (__stdcall *fnstats)(int, _uidefaultstats *), int *dlgresult, int *a6, char *name) +{ int v7; // eax int v8; // eax - artfont_10001159(); - dword_1002A438 = (int (__stdcall *)(_DWORD))a1; - dword_1002A450 = (int (UNKCALL *)(_DWORD, _DWORD))a2; - dword_1002A434 = (int (__stdcall *)(_DWORD))a3; - dword_1002A410 = (int (__stdcall *)(_DWORD, _DWORD))a4; - dword_1002A458 = 0; - dword_1002A48C = 1; - dword_1002A45C = 0; - v7 = SDrawGetFrameWindow(); - v8 = SDlgDialogBoxParam(hInstance, "SELHERO_DIALOG", v7, SelHero_1000BC46, 0); - if ( a5 ) - *(_DWORD *)a5 = v8; - if ( a7 ) - strcpy(a7, &byte_1002A440); + artfont_LoadAllFonts(); + selhero_fninfo = fninfo; + selhero_fncreate = fncreate; + selhero_fnremove = fnremove; + selhero_fnstats = fnstats; + sgpHeroInfo = 0; + selhero_is_good = 1; + selhero_is_created = 0; + v7 = (int)SDrawGetFrameWindow(); + v8 = SDlgDialogBoxParam(ghUiInst, "SELHERO_DIALOG", v7, SelHero_WndProc, 0); + if ( dlgresult ) + *dlgresult = v8; + if ( name ) + strcpy(name, selhero_heronamestr); if ( a6 ) - *(_DWORD *)a6 = dword_1002A45C; + *a6 = selhero_is_created; return 1; -} */ -// 10010370: using guessed type int __stdcall SDlgDialogBoxParam(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD); +} // 10010382: using guessed type _DWORD __stdcall SDrawGetFrameWindow(); -// 1002A410: using guessed type int (__stdcall *dword_1002A410)(_DWORD, _DWORD); -// 1002A434: using guessed type int (__stdcall *dword_1002A434)(_DWORD); -// 1002A438: using guessed type int (__stdcall *dword_1002A438)(_DWORD); -// 1002A450: using guessed type int (UNKCALL *dword_1002A450)(_DWORD, _DWORD); -// 1002A458: using guessed type int dword_1002A458; -// 1002A45C: using guessed type int dword_1002A45C; -// 1002A48C: using guessed type int dword_1002A48C; +// 1002A45C: using guessed type int selhero_is_created; // ref: 0x1000BC46 -int __stdcall SelHero_1000BC46(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { return 0; } -/* { +LRESULT __stdcall SelHero_WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) +{ HWND v4; // eax int v6; // edx HWND v7; // ecx signed int v8; // [esp-4h] [ebp-8h] - int v9; // [esp+0h] [ebp-4h] if ( Msg > 0xBD2 ) { switch ( Msg ) { case 0xBD3u: - SelHero_1000C21A(hWnd); + SelHero_DoSelLoad(hWnd); return 0; case 0xBD4u: - SelHero_1000C269(hWnd); + SelHero_DoSelDiff(hWnd); return 0; case 0xBD5u: v7 = hWnd; - if ( dword_1002A48C != 1 ) + if ( selhero_is_good != 1 ) { v8 = 2; goto LABEL_30; } break; case 0xBD6u: - strcpy(&byte_1002A440, byte_1002A464); + strcpy(selhero_heronamestr, heroinfo_create.name); v6 = 1; v7 = hWnd; - if ( dword_1002A48C != 1 ) + if ( selhero_is_good != 1 ) { - dword_1002A420 = 0; + selhero_difficulty = 0; LABEL_31: - SelHero_1000C3E2((int)v7, v6); + SelHero_DoHeroEndFade(v7, v6); return 0; } break; case 0xBD7u: - SelHero_1000BDAD(hWnd); + SelHero_DoStuffWithStrings(hWnd); return 0; default: - return SDlgDefDialogProc(hWnd, Msg, wParam, lParam); + return (LRESULT)SDlgDefDialogProc(hWnd, Msg, (HDC)wParam, (HWND)lParam); } v8 = 3; LABEL_30: @@ -347,206 +296,195 @@ LABEL_30: } if ( Msg == 3026 ) { - SelHero_1000C09B(hWnd); + SelHero_DoEnterName(hWnd); return 0; } if ( Msg == 2 ) { - SelHero_1000C364(hWnd); - return SDlgDefDialogProc(hWnd, Msg, wParam, lParam); + SelHero_DeleteAndFree(hWnd); + return (LRESULT)SDlgDefDialogProc(hWnd, Msg, (HDC)wParam, (HWND)lParam); } if ( Msg <= 0x103 ) - return SDlgDefDialogProc(hWnd, Msg, wParam, lParam); + return (LRESULT)SDlgDefDialogProc(hWnd, Msg, (HDC)wParam, (HWND)lParam); if ( Msg <= 0x105 ) { v4 = (HWND)SDrawGetFrameWindow(); SendMessageA(v4, Msg, wParam, lParam); - return SDlgDefDialogProc(hWnd, Msg, wParam, lParam); + return (LRESULT)SDlgDefDialogProc(hWnd, Msg, (HDC)wParam, (HWND)lParam); } switch ( Msg ) { case 0x110u: - SelHero_1000C3FF(hWnd); + SelHero_LoadHeroGFX(hWnd); PostMessageA(hWnd, 0x7E8u, 0, 0); return 0; case 0x7E8u: - if ( !Fade_1000739F() ) - Fade_100073FD(hWnd, v9); + if ( !Fade_CheckRange5() ) + Fade_SetFadeTimer((int)hWnd); return 0; case 0xBD0u: - SelHero_1000BF6D(hWnd); + SelHero_DoHeroSelList(hWnd); return 0; } if ( Msg != 3025 ) - return SDlgDefDialogProc(hWnd, Msg, wParam, lParam); - SelHero_1000BFF9(hWnd); + return (LRESULT)SDlgDefDialogProc(hWnd, Msg, (HDC)wParam, (HWND)lParam); + SelHero_DoHeroSelClass(hWnd); return 0; -} */ -// 1001037C: using guessed type int __stdcall SDlgDefDialogProc(_DWORD, _DWORD, _DWORD, _DWORD); +} // 10010382: using guessed type _DWORD __stdcall SDrawGetFrameWindow(); -// 1002A420: using guessed type int dword_1002A420; -// 1002A48C: using guessed type int dword_1002A48C; +// 1002A420: using guessed type int selhero_difficulty; // ref: 0x1000BDAD -BOOL UNKCALL SelHero_1000BDAD(HWND arg) { return 0; } -/* { - const char *v1; // eax - CHAR v3; // [esp+Ch] [ebp-B4h] - CHAR v4; // [esp+5Ch] [ebp-64h] - CHAR Buffer; // [esp+9Ch] [ebp-24h] - HWND hWnd; // [esp+BCh] [ebp-4h] - - hWnd = arg; - if ( SelHero_1000B7CA() == 1 ) - LoadStringA(hInstance, 0x23u, &Buffer, 31); +void __fastcall SelHero_DoStuffWithStrings(HWND hWnd) +{ + _uiheroinfo *v1; // eax + char dialogstr[80]; // [esp+Ch] [ebp-B4h] + char string64[64]; // [esp+5Ch] [ebp-64h] + char Buffer[32]; // [esp+9Ch] [ebp-24h] + + if ( SelHero_GetHeroIsGood() == 1 ) + LoadStringA(ghUiInst, 0x23u, Buffer, 31); else - LoadStringA(hInstance, 0x22u, &Buffer, 31); - LoadStringA(hInstance, 7u, &v4, 63); - wsprintfA(&v3, &v4, &byte_1002A440); - if ( SelYesNo_1000FA49((int)hWnd, &v3, (int)&Buffer, 1) != 2 ) + LoadStringA(ghUiInst, 0x22u, Buffer, 31); + LoadStringA(ghUiInst, 7u, string64, 63); + wsprintfA(dialogstr, string64, selhero_heronamestr); + if ( SelYesNo_YesNoDialog(hWnd, dialogstr, Buffer, 1) != 2 ) { - v1 = SelHero_1000BF4A((const char *)dword_1002A458, &byte_1002A440); + v1 = SelHero_GetHeroSlotFromName(sgpHeroInfo, selhero_heronamestr); if ( v1 ) { - if ( dword_1002A434(v1) ) + if ( selhero_fnremove(v1) ) { - dword_1002A458 = (int)SelHero_1000BEDB((int *)dword_1002A458, &byte_1002A440); - --dword_1002A428; - LoadStringA(hInstance, 0x1Eu, &v4, 15); - if ( !strcmp(&v4, (const char *)(dword_1002A458 + 4)) ) - return PostMessageA(hWnd, 0xBD1u, 0, 0); - SelHero_1000B905(hWnd, dword_1002A458); + sgpHeroInfo = SelHero_GetNextHeroFromStr(sgpHeroInfo, selhero_heronamestr); + --selhero_numheroesleft; + LoadStringA(ghUiInst, 0x1Eu, string64, 15); + if ( !strcmp(string64, sgpHeroInfo->name) ) + { + PostMessageA(hWnd, 0xBD1u, 0, 0); + return; + } + SelHero_PrintHeroInfo(hWnd, sgpHeroInfo); } else { - LoadStringA(hInstance, 0x11u, &v4, 63); - SelYesNo_1000FD39((int)hWnd, &v4, (int)&Buffer, 1); + LoadStringA(ghUiInst, 0x11u, string64, 63); + SelYesNo_SelOkDialog(hWnd, string64, Buffer, 1); } } } - return PostMessageA(hWnd, 0xBD0u, 0, 0); -} */ -// 1002A428: using guessed type int dword_1002A428; -// 1002A434: using guessed type int (__stdcall *dword_1002A434)(_DWORD); -// 1002A458: using guessed type int dword_1002A458; + PostMessageA(hWnd, 0xBD0u, 0, 0); +} +// 1002A428: using guessed type int selhero_numheroesleft; // ref: 0x1000BEDB -int *__fastcall SelHero_1000BEDB(int *a1, char *a2) { return 0; } -/* { - int *v2; // ebx - _DWORD *v3; // ebp - _DWORD *v4; // edi - int *v5; // esi - char *v7; // [esp+10h] [ebp-4h] - - v2 = a1; +_uiheroinfo *__fastcall SelHero_GetNextHeroFromStr(_uiheroinfo *pInfo, char *name) +{ + _uiheroinfo *v3; // ebp + _uiheroinfo *v4; // edi + v3 = 0; v4 = 0; - v7 = a2; - v5 = a1; - if ( a1 ) + if ( pInfo ) { while ( !v4 ) { - if ( !strcmp((const char *)v5 + 4, v7) ) + if ( !strcmp(pInfo->name, name) ) { - v4 = v5; + v4 = pInfo; } else { - v3 = v5; - v5 = (int *)*v5; + v3 = pInfo; + pInfo = pInfo->next; } - if ( !v5 ) + if ( !pInfo ) { if ( !v4 ) - return v2; + return pInfo; break; } } if ( v3 ) - *v3 = *v4; + v3->next = v4->next; else - v2 = (int *)*v4; - SelHero_1000BF33(v4); + pInfo = v4->next; + SelHero_FreeSomeMemory(v4); } - return v2; -} */ + return pInfo; +} // ref: 0x1000BF33 -int UNKCALL SelHero_1000BF33(void *arg) { return 0; } -/* { - int result; // eax - - if ( arg ) - result = SMemFree(arg, "C:\\Src\\Diablo\\DiabloUI\\SelHero.cpp", 131, 0); - return result; -} */ -// 10010340: using guessed type int __stdcall SMemFree(_DWORD, _DWORD, _DWORD, _DWORD); +void __fastcall SelHero_FreeSomeMemory(void *ptr) +{ + if ( ptr ) + SMemFree(ptr, "C:\\Src\\Diablo\\DiabloUI\\SelHero.cpp", 131, 0); +} // ref: 0x1000BF4A -const char *__fastcall SelHero_1000BF4A(const char *a1, const char *a2) { return 0; } -/* { - const char *v2; // edi - const char *i; // esi +_uiheroinfo *__fastcall SelHero_GetHeroSlotFromName(_uiheroinfo *pInfo, const char *name) +{ + _uiheroinfo *i; // esi - v2 = a2; - for ( i = a1; i && _strcmpi(i + 4, v2); i = *(const char **)i ) + for ( i = pInfo; i && _strcmpi(i->name, name); i = i->next ) ; return i; -} */ +} // ref: 0x1000BF6D -int UNKCALL SelHero_1000BF6D(HWND hWnd) { return 0; } -/* { - HWND v1; // esi - int v2; // eax - int v4; // edx +void __fastcall SelHero_DoHeroSelList(HWND hWnd) +{ + BOOL v2; // eax + int v3; // edx - v1 = hWnd; - v2 = SDlgDialogBoxParam(hInstance, "SELLIST_DIALOG", hWnd, SelList_1000D774, 0); + v2 = SDlgDialogBoxParam(ghUiInst, "SELLIST_DIALOG", (int)hWnd, SelList_WndProc, 0); if ( v2 == 1 ) { - if ( !strlen(&byte_1002A440) ) - return PostMessageA(v1, 0xBD1u, 0, 0); - if ( dword_1002A48C == 1 ) - return PostMessageA(v1, 0xBD5u, 0, 0); - if ( dword_1002A424 ) - return PostMessageA(v1, 0xBD3u, 0, 0); - dword_1002A420 = 0; - v4 = 1; - return SelHero_1000C3E2((int)v1, v4); + if ( !strlen(selhero_heronamestr) ) + { + PostMessageA(hWnd, 0xBD1u, 0, 0); + return; + } + if ( selhero_is_good == 1 ) + { + PostMessageA(hWnd, 0xBD5u, 0, 0); + return; + } + if ( selhero_hero_hassaved ) + { + PostMessageA(hWnd, 0xBD3u, 0, 0); + return; + } + selhero_difficulty = 0; + v3 = 1; +LABEL_13: + SelHero_DoHeroEndFade(hWnd, v3); + return; } if ( v2 != 1006 ) { - v4 = 4; - return SelHero_1000C3E2((int)v1, v4); + v3 = 4; + goto LABEL_13; } - return PostMessageA(v1, 0xBD7u, 0, 0); -} */ -// 10010370: using guessed type int __stdcall SDlgDialogBoxParam(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD); -// 1002A420: using guessed type int dword_1002A420; -// 1002A424: using guessed type int dword_1002A424; -// 1002A48C: using guessed type int dword_1002A48C; + PostMessageA(hWnd, 0xBD7u, 0, 0); +} +// 1002A420: using guessed type int selhero_difficulty; +// 1002A424: using guessed type int selhero_hero_hassaved; // ref: 0x1000BFF9 -int UNKCALL SelHero_1000BFF9(HWND hWnd) { return 0; } -/* { - HWND v1; // esi - int v2; // eax +void __fastcall SelHero_DoHeroSelClass(HWND hWnd) +{ + BOOL v2; // eax int v3; // eax - int result; // eax - CHAR Buffer; // [esp+8h] [ebp-20h] + char Buffer[32]; // [esp+8h] [ebp-20h] - v1 = hWnd; - v2 = SDlgDialogBoxParam(hInstance, "SELCLASS_DIALOG", hWnd, SelClass_10009D66, 0); + v2 = SDlgDialogBoxParam(ghUiInst, "SELCLASS_DIALOG", (int)hWnd, SelClass_WndProc, 0); if ( v2 == -1 || v2 == 2 ) { - LoadStringA(hInstance, 0x1Eu, &Buffer, 31); - if ( !strcmp(&Buffer, (const char *)(dword_1002A458 + 4)) ) - result = SelHero_1000C3E2((int)v1, 4); + LoadStringA(ghUiInst, 0x1Eu, Buffer, 31); + if ( !strcmp(Buffer, sgpHeroInfo->name) ) + SelHero_DoHeroEndFade(hWnd, 4); else - result = PostMessageA(v1, 0xBD0u, 0, 0); + PostMessageA(hWnd, 0xBD0u, 0, 0); } else { @@ -554,204 +492,184 @@ int UNKCALL SelHero_1000BFF9(HWND hWnd) { return 0; } if ( v3 ) { if ( v3 == 1 ) - byte_1002A476 = 2; + heroinfo_create.heroclass = 2; else - byte_1002A476 = 0; + heroinfo_create.heroclass = 0; } else { - byte_1002A476 = 1; + heroinfo_create.heroclass = 1; } - result = PostMessageA(v1, 0xBD2u, 0, 0); + PostMessageA(hWnd, 0xBD2u, 0, 0); } - return result; -} */ -// 10010370: using guessed type int __stdcall SDlgDialogBoxParam(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD); -// 1002A458: using guessed type int dword_1002A458; -// 1002A476: using guessed type char byte_1002A476; +} // ref: 0x1000C09B -int UNKCALL SelHero_1000C09B(HWND hWnd) { return 0; } -/* { - HWND v1; // esi - int result; // eax - char v3; // [esp+8h] [ebp-10h] - char v4; // [esp+17h] [ebp-1h] - - v1 = hWnd; - if ( SDlgDialogBoxParam(hInstance, "ENTERNAME_DIALOG", hWnd, EntName_10006F7C, &v3) != 1 ) - return PostMessageA(v1, 0xBD1u, 0, 0); - v4 = 0; - if ( SelHero_1000C0F9((int)v1, &v3) ) - result = PostMessageA(v1, 0xBD6u, 0, 0); +void __fastcall SelHero_DoEnterName(HWND hWnd) +{ + char namestr[16]; // [esp+8h] [ebp-10h] + + if ( SDlgDialogBoxParam(ghUiInst, "ENTERNAME_DIALOG", (int)hWnd, EntName_WndProc, (int)namestr) == 1 ) + { + namestr[15] = 0; + if ( SelHero_CreateHero(hWnd, namestr) ) + PostMessageA(hWnd, 0xBD6u, 0, 0); + else + PostMessageA(hWnd, 0xBD2u, 0, 0); + } else - result = PostMessageA(v1, 0xBD2u, 0, 0); - return result; -} */ -// 10010370: using guessed type int __stdcall SDlgDialogBoxParam(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD); + { + PostMessageA(hWnd, 0xBD1u, 0, 0); + } +} // ref: 0x1000C0F9 -signed int __fastcall SelHero_1000C0F9(int a1, char *a2) { return 0; } -/* { - const char *v2; // edi - int v3; // ST0C_4 - CHAR v5; // [esp+Ch] [ebp-138h] - CHAR v6; // [esp+9Ch] [ebp-A8h] - CHAR Buffer; // [esp+11Ch] [ebp-28h] - int v8; // [esp+13Ch] [ebp-8h] - char *v9; // [esp+140h] [ebp-4h] - - v9 = a2; - v8 = a1; - if ( SelHero_1000B7CA() == 1 ) - LoadStringA(hInstance, 0x20u, &Buffer, 31); +BOOL __fastcall SelHero_CreateHero(HWND hWnd, char *name) +{ + _uiheroinfo *v2; // edi + char dialogstr[144]; // [esp+Ch] [ebp-138h] + char v5[128]; // [esp+9Ch] [ebp-A8h] + char Buffer[32]; // [esp+11Ch] [ebp-28h] + + if ( SelHero_GetHeroIsGood() == 1 ) + LoadStringA(ghUiInst, 0x20u, Buffer, 31); else - LoadStringA(hInstance, 0x1Fu, &Buffer, 31); - if ( !UiValidPlayerName(v9) ) + LoadStringA(ghUiInst, 0x1Fu, Buffer, 31); + if ( !UiValidPlayerName(name) ) { - LoadStringA(hInstance, 0xFu, &v6, 127); - SelYesNo_1000FD39(v8, &v6, (int)&Buffer, 1); + LoadStringA(ghUiInst, 0xFu, v5, 127); + SelYesNo_SelOkDialog(hWnd, v5, Buffer, 1); return 0; } - v2 = SelHero_1000BF4A((const char *)dword_1002A458, v9); + v2 = SelHero_GetHeroSlotFromName(sgpHeroInfo, name); if ( v2 ) { - LoadStringA(hInstance, 8u, &v6, 127); - wsprintfA(&v5, &v6, v2 + 4); - if ( SelYesNo_1000FA49(v8, &v5, (int)&Buffer, 1) == 2 ) + LoadStringA(ghUiInst, 8u, v5, 127); + wsprintfA(dialogstr, v5, v2->name); + if ( SelYesNo_YesNoDialog(hWnd, dialogstr, Buffer, 1) == 2 ) return 0; } - strcpy(byte_1002A464, v9); - dword_1002A484 = 0; - if ( !dword_1002A450(v3, &unk_1002A460) ) + strcpy(heroinfo_create.name, name); + heroinfo_create.hassaved = 0; + if ( !selhero_fncreate(&heroinfo_create) ) { - LoadStringA(hInstance, 0x10u, &v6, 127); - OkCancel_1000930A(v8, (int)&v6, 1); + LoadStringA(ghUiInst, 0x10u, v5, 127); + OkCancel_1000930A((int)hWnd, (int)v5, 1); return 0; } - dword_1002A45C = 1; + selhero_is_created = 1; return 1; -} */ -// 1002A450: using guessed type int (UNKCALL *dword_1002A450)(_DWORD, _DWORD); -// 1002A458: using guessed type int dword_1002A458; -// 1002A45C: using guessed type int dword_1002A45C; -// 1002A484: using guessed type int dword_1002A484; +} +// 1002A45C: using guessed type int selhero_is_created; // ref: 0x1000C21A -BOOL UNKCALL SelHero_1000C21A(HWND hWnd) { return 0; } -/* { - HWND v1; // esi - int v2; // eax +void __fastcall SelHero_DoSelLoad(HWND hWnd) +{ + BOOL v2; // eax - v1 = hWnd; - v2 = SDlgDialogBoxParam(hInstance, "SELLOAD_DIALOG", hWnd, SelLoad_1000E1C2, 0); + v2 = SDlgDialogBoxParam(ghUiInst, "SELLOAD_DIALOG", (int)hWnd, SelLoad_WndProc, 0); if ( v2 == -1 || v2 == 2 ) - return PostMessageA(v1, 0xBD0u, 0, 0); - if ( v2 == 1106 ) - return PostMessageA(v1, 0xBD5u, 0, 0); - return PostMessageA(v1, 0xBD4u, 0, 0); -} */ -// 10010370: using guessed type int __stdcall SDlgDialogBoxParam(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD); + { + PostMessageA(hWnd, 0xBD0u, 0, 0); + } + else if ( v2 == 1106 ) + { + PostMessageA(hWnd, 0xBD5u, 0, 0); + } + else + { + PostMessageA(hWnd, 0xBD4u, 0, 0); + } +} // ref: 0x1000C269 -int UNKCALL SelHero_1000C269(HWND hWnd) { return 0; } -/* { - HWND v1; // ebx - int v2; // ecx - const char *v4; // eax - int v5; // eax - CHAR Buffer; // [esp+4h] [ebp-208h] - char v7; // [esp+104h] [ebp-108h] - char v8; // [esp+184h] [ebp-88h] - char v9; // [esp+204h] [ebp-8h] - char v10; // [esp+208h] [ebp-4h] - - v1 = hWnd; - if ( !SelHero_1000B7CA() ) +void __fastcall SelHero_DoSelDiff(HWND hWnd) +{ + _uiheroinfo *v3; // eax + int v4; // eax + char Buffer[256]; // [esp+4h] [ebp-208h] + char v6[128]; // [esp+104h] [ebp-108h] + char v7[128]; // [esp+184h] [ebp-88h] + _gamedata gameData; // [esp+204h] [ebp-8h] + + if ( !SelHero_GetHeroIsGood() ) { - SelHero_1000B7AC(0); - v2 = (int)v1; - return SelHero_1000C3E2(v2, 1); + SelHero_SetHeroDifficulty(0); +LABEL_3: + SelHero_DoHeroEndFade(hWnd, 1); + return; } CreaDung_10004C33((void *)1); - if ( SDlgDialogBoxParam(hInstance, "SELDIFF_DIALOG", v1, CreaDung_10004C4A, dword_1002A48C) != 1 ) - return PostMessageA(v1, 0xBD3u, 0, 0); - v4 = SelHero_1000BF4A((const char *)dword_1002A458, &byte_1002A440); - UiCreatePlayerDescription((int)v4, 1145195599, (int)&v8); - v10 = dword_1002A420; - Connect_10003E0C((int)&v9, &byte_1002A440, &v8, &v7, 128); - v5 = UiAuthCallback(2, (int)&byte_1002A440, &v8, 0, &v7, &Buffer, 256); - v2 = (int)v1; - if ( v5 ) - return SelHero_1000C3E2(v2, 1); - SelYesNo_1000FD39((int)v1, &Buffer, 0, 1); - return PostMessageA(v1, 0xBD4u, 0, 0); -} */ -// 10010370: using guessed type int __stdcall SDlgDialogBoxParam(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD); -// 1002A420: using guessed type int dword_1002A420; -// 1002A458: using guessed type int dword_1002A458; -// 1002A48C: using guessed type int dword_1002A48C; + if ( SDlgDialogBoxParam(ghUiInst, "SELDIFF_DIALOG", (int)hWnd, (WNDPROC)CreaDung_10004C4A, selhero_is_good) == 1 ) + { + v3 = SelHero_GetHeroSlotFromName(sgpHeroInfo, selhero_heronamestr); + UiCreatePlayerDescription(v3, 'DBLO', v7); + gameData.bDiff = selhero_difficulty; + Connect_10003E0C((int)&gameData, selhero_heronamestr, v7, v6, 128); + /* temp, fix */ + //v4 = UiAuthCallback(2, (int)selhero_heronamestr, v7, 0, v6, Buffer, 256); + if ( v4 ) + goto LABEL_3; + SelYesNo_SelOkDialog(hWnd, Buffer, 0, 1); + PostMessageA(hWnd, 0xBD4u, 0, 0); + } + else + { + PostMessageA(hWnd, 0xBD3u, 0, 0); + } +} +// 1002A420: using guessed type int selhero_difficulty; // ref: 0x1000C364 -void UNKCALL SelHero_1000C364(HWND hDlg) { return; } -/* { - HWND v1; // esi - _DWORD *v2; // eax - - v1 = hDlg; - Doom_10006C53(hDlg, (int *)&unk_10023020); - Doom_10006C53(v1, (int *)&unk_10023008); - Doom_10006C53(v1, (int *)&unk_10023000); - Title_100100E7(v1); - SelHero_1000C3CE((_DWORD *)dword_1002A458); - if ( dword_1002A498 ) +void __fastcall SelHero_DeleteAndFree(HWND hWnd) +{ + void **v2; // eax + + Doom_DeleteFreeProcs(hWnd, selhero_msgtbl_info); + Doom_DeleteFreeProcs(hWnd, selhero_msgtbl_3); + Doom_DeleteFreeProcs(hWnd, selhero_msgtbl_string); + Title_KillTitleTimer(hWnd); + SelHero_FreeAllHeroes(sgpHeroInfo); + if ( selhero_buffer ) { - SMemFree(dword_1002A498, "C:\\Src\\Diablo\\DiabloUI\\SelHero.cpp", 744, 0); - dword_1002A498 = 0; + SMemFree(selhero_buffer, "C:\\Src\\Diablo\\DiabloUI\\SelHero.cpp", 744, 0); + selhero_buffer = 0; } - v2 = (_DWORD *)GetWindowLongA(v1, -21); - local_10007F72(v2); -} */ -// 10010340: using guessed type int __stdcall SMemFree(_DWORD, _DWORD, _DWORD, _DWORD); -// 1002A458: using guessed type int dword_1002A458; -// 1002A498: using guessed type int dword_1002A498; + v2 = (void **)GetWindowLongA(hWnd, -21); + local_FreeMemPtr(v2); +} // ref: 0x1000C3CE -int __fastcall SelHero_1000C3CE(_DWORD *a1) { return 0; } -/* { - _DWORD *v1; // esi - int result; // eax +void __fastcall SelHero_FreeAllHeroes(_uiheroinfo *pInfo) +{ + _uiheroinfo *v1; // esi - if ( a1 ) + if ( pInfo ) { do { - v1 = (_DWORD *)*a1; - result = SelHero_1000BF33(a1); - a1 = v1; + v1 = pInfo->next; + SelHero_FreeSomeMemory(pInfo); + pInfo = v1; } while ( v1 ); } - return result; -} */ +} // ref: 0x1000C3E2 -int __fastcall SelHero_1000C3E2(int a1, int a2) { return 0; } -/* { - int v2; // edi - int v3; // esi - - v2 = a2; - v3 = a1; - Fade_100073B4(); - Fade_100072BE(10); - return SDlgEndDialog(v3, v2); -} */ -// 10010376: using guessed type int __stdcall SDlgEndDialog(_DWORD, _DWORD); +void __fastcall SelHero_DoHeroEndFade(HWND hWnd, int a2) +{ + void *v2; // edi + + v2 = (void *)a2; + Fade_Range5SetZero(); + Fade_UpdatePaletteRange(10); + SDlgEndDialog(hWnd, v2); +} // ref: 0x1000C3FF -int UNKCALL SelHero_1000C3FF(HWND hWnd) { return 0; } -/* { +void __fastcall SelHero_LoadHeroGFX(HWND hWnd) +{ HWND v1; // eax int v2; // eax HWND v3; // eax @@ -762,132 +680,110 @@ int UNKCALL SelHero_1000C3FF(HWND hWnd) { return 0; } int v8; // eax HWND v9; // eax int v10; // eax - HWND v12; // esi - int v13; // eax - int *v14; // edi - void *v15; // [esp+0h] [ebp-8h] - HWND v16; // [esp+0h] [ebp-8h] - - v12 = hWnd; - SelHero_1000C49F(hWnd, v15); - v13 = local_10007F46(); - v14 = (int *)v13; - if ( v13 ) + DWORD *v12; // eax MAPDST + + SelHero_SelectHeroRegion(hWnd); + v12 = local_AllocWndLongData(); + if ( v12 ) { - SetWindowLongA(v12, -21, v13); - local_10007944((int)v12, 0, &byte_10029448, -1, 1, (int)"ui_art\\selhero.pcx", v14, v14 + 1, 0); - Fade_100073C5(v12, 1); + SetWindowLongA(hWnd, -21, (LONG)v12); + local_LoadArtWithPal(hWnd, 0, &nullcharacter, -1, 1, "ui_art\\selhero.pcx", (BYTE **)v12, v12 + 1, 0); + Fade_NoInputAndArt(hWnd, 1); } - local_100078BE((int)"ui_art\\heros.pcx", &dword_1002A498, &dword_1002A418); - SetActiveWindow(v12); - Title_1001009E(v12, (int)"ui_art\\smlogo.pcx", v16); - Doom_100068AB(v12, (int *)&unk_10023000, 5); - Doom_100068AB(v12, (int *)&unk_10023008, 1); - Doom_100068AB(v12, (int *)&unk_10023020, 1); - dword_1002A424 = 0; - byte_1002A440 = 0; - v1 = GetDlgItem(v12, 1014); + local_LoadArtImage("ui_art\\heros.pcx", &selhero_buffer, &selhero_width); + SetActiveWindow(hWnd); + Title_LoadImgSetTimer(hWnd, "ui_art\\smlogo.pcx"); + Doom_ParseWndProc3(hWnd, selhero_msgtbl_string, 5); + Doom_ParseWndProc3(hWnd, selhero_msgtbl_3, 1); + Doom_ParseWndProc3(hWnd, selhero_msgtbl_info, 1); + selhero_hero_hassaved = 0; + selhero_heronamestr[0] = 0; + v1 = GetDlgItem(hWnd, 1014); v2 = GetWindowLongA(v1, -21); - local_10007FA4(v2, "--"); - v3 = GetDlgItem(v12, 1018); + local_SetWndLongStr(v2, "--"); + v3 = GetDlgItem(hWnd, 1018); v4 = GetWindowLongA(v3, -21); - local_10007FA4(v4, "--"); - v5 = GetDlgItem(v12, 1017); + local_SetWndLongStr(v4, "--"); + v5 = GetDlgItem(hWnd, 1017); v6 = GetWindowLongA(v5, -21); - local_10007FA4(v6, "--"); - v7 = GetDlgItem(v12, 1016); + local_SetWndLongStr(v6, "--"); + v7 = GetDlgItem(hWnd, 1016); v8 = GetWindowLongA(v7, -21); - local_10007FA4(v8, "--"); - v9 = GetDlgItem(v12, 1015); + local_SetWndLongStr(v8, "--"); + v9 = GetDlgItem(hWnd, 1015); v10 = GetWindowLongA(v9, -21); - local_10007FA4(v10, "--"); - SelHero_1000B899(v12, 3); - return Doom_10006A13(v12, (int *)&unk_10023020, 1); -} */ -// 1002A418: using guessed type int dword_1002A418; -// 1002A424: using guessed type int dword_1002A424; -// 1002A498: using guessed type int dword_1002A498; + local_SetWndLongStr(v10, "--"); + SelHero_SetStaticBMP(hWnd, 3); + Doom_ParseWndProc4(hWnd, selhero_msgtbl_info, 1); +} +// 1002A424: using guessed type int selhero_hero_hassaved; // ref: 0x1000C49F -BOOL UNKCALL SelHero_1000C49F(HWND hWnd, void *a2) { return 0; } -/* { - HWND v2; // ebx - int v3; // esi - BOOL result; // eax - int v5; // [esp+10h] [ebp-44h] - CHAR Buffer; // [esp+14h] [ebp-40h] - - v2 = hWnd; - v3 = SelHero_1000B7B9(); - *(_DWORD *)v3 = 0; - LoadStringA(hInstance, 0x1Eu, (LPSTR)(v3 + 4), 15); - *(_WORD *)(v3 + 20) = 0; - dword_1002A458 = (int)SelRegn_1000EF56(dword_1002A458, (_DWORD *)v3); - v5 = dword_1002A458; - dword_1002A428 = 1; - if ( !dword_1002A438(SelHero_1000C541) ) +void __fastcall SelHero_SelectHeroRegion(HWND hWnd) +{ + _uiheroinfo *v2; // esi + _uiheroinfo *v3; // [esp+10h] [ebp-44h] + char Buffer[64]; // [esp+14h] [ebp-40h] + + v2 = SelHero_AllocHeroInfo(); + v2->next = 0; + LoadStringA(ghUiInst, 0x1Eu, v2->name, 15); + v2->level = 0; + sgpHeroInfo = (_uiheroinfo *)SelRegn_1000EF56((int)sgpHeroInfo, (unsigned int *)v2); + v3 = sgpHeroInfo; + selhero_numheroesleft = 1; + if ( !selhero_fninfo(SelHero_GetHeroInfo) ) { - LoadStringA(hInstance, 0x12u, &Buffer, 64); - OkCancel_1000930A((int)v2, (int)&Buffer, 1); + LoadStringA(ghUiInst, 0x12u, Buffer, 64); + OkCancel_1000930A((int)hWnd, (int)Buffer, 1); } - if ( v5 == dword_1002A458 ) - result = PostMessageA(v2, 0xBD1u, 0, 0); + if ( v3 == sgpHeroInfo ) + PostMessageA(hWnd, 0xBD1u, 0, 0); else - result = PostMessageA(v2, 0xBD0u, 0, 0); - return result; -} */ -// 1002A428: using guessed type int dword_1002A428; -// 1002A438: using guessed type int (__stdcall *dword_1002A438)(_DWORD); -// 1002A458: using guessed type int dword_1002A458; + PostMessageA(hWnd, 0xBD0u, 0, 0); +} +// 1002A428: using guessed type int selhero_numheroesleft; // ref: 0x1000C541 -signed int __stdcall SelHero_1000C541(void *a1) { return 0; } -/* { - _DWORD *v1; // esi - _DWORD *v2; // eax - - v1 = (_DWORD *)SelHero_1000B7B9(); - memcpy(v1, a1, 0x2Cu); - *v1 = 0; - v2 = SelRegn_1000EF56(dword_1002A458, v1); - ++dword_1002A428; - dword_1002A458 = (int)v2; +BOOL __stdcall SelHero_GetHeroInfo(_uiheroinfo *pInfo) +{ + _uiheroinfo *v1; // esi + _uiheroinfo *v2; // eax + + v1 = SelHero_AllocHeroInfo(); + memcpy(v1, pInfo, 0x2Cu); + v1->next = 0; + v2 = (_uiheroinfo *)SelRegn_1000EF56((int)sgpHeroInfo, (unsigned int *)v1); + ++selhero_numheroesleft; + sgpHeroInfo = v2; return 1; -} */ -// 1002A428: using guessed type int dword_1002A428; -// 1002A458: using guessed type int dword_1002A458; +} +// 1002A428: using guessed type int selhero_numheroesleft; // ref: 0x1000C57A -int __stdcall UiSelHeroSingDialog(void *fninfo, void *fncreate, void *fnremove, void *fnstats, int *a5, char *name, int *difficulty) { return 0; } -/* { +BOOL __stdcall UiSelHeroSingDialog(BOOL (__stdcall *fninfo)(BOOL (__stdcall *fninfofunc)(_uiheroinfo *)), BOOL (__stdcall *fncreate)(_uiheroinfo *), BOOL (__stdcall *fnremove)(_uiheroinfo *), BOOL (__stdcall *fnstats)(int, _uidefaultstats *), int *dlgresult, char *name, int *difficulty) +{ int v7; // eax int v8; // edi - artfont_10001159(); - dword_1002A438 = (int (__stdcall *)(_DWORD))a1; - dword_1002A450 = (int (UNKCALL *)(_DWORD, _DWORD))a2; - dword_1002A434 = (int (__stdcall *)(_DWORD))a3; - dword_1002A410 = (int (__stdcall *)(_DWORD, _DWORD))a4; - dword_1002A458 = 0; - dword_1002A48C = 0; - v7 = SDrawGetFrameWindow(); - v8 = SDlgDialogBoxParam(hInstance, "SELHERO_DIALOG", v7, SelHero_1000BC46, 0); - if ( a5 ) - *(_DWORD *)a5 = v8; - if ( a6 ) - strcpy(a6, &byte_1002A440); - if ( a7 ) - *(_DWORD *)a7 = dword_1002A420; + artfont_LoadAllFonts(); + selhero_fninfo = fninfo; + selhero_fncreate = fncreate; + selhero_fnremove = fnremove; + selhero_fnstats = fnstats; + sgpHeroInfo = 0; + selhero_is_good = 0; + v7 = (int)SDrawGetFrameWindow(); + v8 = SDlgDialogBoxParam(ghUiInst, "SELHERO_DIALOG", v7, SelHero_WndProc, 0); + if ( dlgresult ) + *dlgresult = v8; + if ( name ) + strcpy(name, selhero_heronamestr); + if ( difficulty ) + *difficulty = selhero_difficulty; if ( v8 != 4 ) - artfont_100010C8(); + artfont_FreeAllFonts(); return 1; -} */ -// 10010370: using guessed type int __stdcall SDlgDialogBoxParam(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD); +} // 10010382: using guessed type _DWORD __stdcall SDrawGetFrameWindow(); -// 1002A410: using guessed type int (__stdcall *dword_1002A410)(_DWORD, _DWORD); -// 1002A420: using guessed type int dword_1002A420; -// 1002A434: using guessed type int (__stdcall *dword_1002A434)(_DWORD); -// 1002A438: using guessed type int (__stdcall *dword_1002A438)(_DWORD); -// 1002A450: using guessed type int (UNKCALL *dword_1002A450)(_DWORD, _DWORD); -// 1002A458: using guessed type int dword_1002A458; -// 1002A48C: using guessed type int dword_1002A48C; +// 1002A420: using guessed type int selhero_difficulty; diff --git a/DiabloUI/sellist.cpp b/DiabloUI/sellist.cpp index 92370a9bc..524e2b8da 100644 --- a/DiabloUI/sellist.cpp +++ b/DiabloUI/sellist.cpp @@ -10,7 +10,7 @@ signed int SelList_1000D769() { return 0; } // 1002A4C0: using guessed type int dword_1002A4C0; // ref: 0x1000D774 -int __stdcall SelList_1000D774(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam) { return 0; } +LRESULT __stdcall SelList_WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { return 0; } /* { HWND v4; // eax char *v5; // eax diff --git a/DiabloUI/selload.cpp b/DiabloUI/selload.cpp index 95174654e..487ec9d62 100644 --- a/DiabloUI/selload.cpp +++ b/DiabloUI/selload.cpp @@ -1,5 +1,5 @@ // ref: 0x1000E1C2 -int __stdcall SelLoad_1000E1C2(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam) { return 0; } +LRESULT __stdcall SelLoad_WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { return 0; } /* { HWND v4; // eax LONG v5; // edx diff --git a/DiabloUI/selyesno.cpp b/DiabloUI/selyesno.cpp index fa80a3be1..9ca9e9a78 100644 --- a/DiabloUI/selyesno.cpp +++ b/DiabloUI/selyesno.cpp @@ -1,25 +1,23 @@ // ref: 0x1000FA49 -int __fastcall SelYesNo_1000FA49(int a1, const CHAR *a2, int a3, int a4) { return 0; } -/* { - dword_1002A4F8 = a2; - dword_1002A504 = a3; - dword_1002A500 = a4; - dword_1002A50C = 0; - dword_1002A508 = 0; - return SDlgDialogBoxParam(hInstance, "SELYESNO_DIALOG", a1, SelYesNo_1000FA87, 0); -} */ -// 10010370: using guessed type int __stdcall SDlgDialogBoxParam(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD); -// 1002A500: using guessed type int dword_1002A500; -// 1002A504: using guessed type int dword_1002A504; -// 1002A508: using guessed type int (*dword_1002A508)(void); -// 1002A50C: using guessed type int dword_1002A50C; +int __fastcall SelYesNo_YesNoDialog(HWND hWnd, char *dialogstr, char *hero, int nofocus) +{ + yesno_dialog_string = dialogstr; + yesno_hero_name = hero; + yesno_remove_focus = nofocus; + yesno_is_popup = 0; + YesNoFunc = 0; + return SDlgDialogBoxParam(ghUiInst, "SELYESNO_DIALOG", (int)hWnd, SelYesNo_WndProc, 0); +} +// 1002A500: using guessed type int yesno_remove_focus; +// 1002A508: using guessed type int (*YesNoFunc)(void); +// 1002A50C: using guessed type int yesno_is_popup; // ref: 0x1000FA87 -int __stdcall SelYesNo_1000FA87(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam) { return 0; } -/* { +LRESULT __stdcall SelYesNo_WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) +{ HWND v4; // eax HWND v5; // eax - LONG v7; // edx + int v7; // edx HWND v8; // eax LONG v9; // eax HWND v10; // ecx @@ -27,8 +25,8 @@ int __stdcall SelYesNo_1000FA87(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lPara if ( Msg == 2 ) { - SelYesNo_1000FBC7(hDlg); - return SDlgDefDialogProc(hDlg, Msg, wParam, lParam); + SelYesNo_RemoveYNDialog(hWnd); + return (LRESULT)SDlgDefDialogProc(hWnd, Msg, (HDC)wParam, (HWND)lParam); } if ( Msg > 0x103 ) { @@ -36,22 +34,22 @@ int __stdcall SelYesNo_1000FA87(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lPara { v11 = (HWND)SDrawGetFrameWindow(); SendMessageA(v11, Msg, wParam, lParam); - return SDlgDefDialogProc(hDlg, Msg, wParam, lParam); + return (LRESULT)SDlgDefDialogProc(hWnd, Msg, (HDC)wParam, (HWND)lParam); } switch ( Msg ) { case 0x110u: - SelYesNo_1000FC1C(hDlg); + SelYesNo_LoadSelYN_GFX(hWnd); return 0; case 0x111u: if ( HIWORD(wParam) == 7 ) { - Focus_100075B7(hDlg, (HWND)lParam); + Focus_GetAndBlitSpin(hWnd, lParam); } else if ( HIWORD(wParam) == 6 ) { - Focus_10007458((void *)lParam); - Focus_100075DC(hDlg, (HWND)lParam); + Focus_CheckPlayMove(lParam); + Focus_DoBlitSpinIncFrame(hWnd, (HWND)lParam); } else { @@ -60,7 +58,7 @@ int __stdcall SelYesNo_1000FA87(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lPara { v8 = GetFocus(); v9 = GetWindowLongA(v8, -12); - v10 = hDlg; + v10 = hWnd; if ( v9 == 1109 ) v7 = 1; else @@ -74,78 +72,72 @@ int __stdcall SelYesNo_1000FA87(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lPara } else if ( (_WORD)wParam != 1109 ) { - return SDlgDefDialogProc(hDlg, Msg, wParam, lParam); + return (LRESULT)SDlgDefDialogProc(hWnd, Msg, (HDC)wParam, (HWND)lParam); } - v10 = hDlg; + v10 = hWnd; } - SelYesNo_1000FCF6((int)v10, v7); + SelYesNo_DoSelectYesNo(v10, v7); } break; case 0x113u: v4 = GetFocus(); - if ( !Focus_100075DC(hDlg, v4) ) + if ( !Focus_DoBlitSpinIncFrame(hWnd, v4) ) { - v5 = GetDlgItem(hDlg, 1109); + v5 = GetDlgItem(hWnd, 1109); if ( !v5 ) - v5 = GetDlgItem(hDlg, 2); + v5 = GetDlgItem(hWnd, 2); SetFocus(v5); } return 0; } } - return SDlgDefDialogProc(hDlg, Msg, wParam, lParam); -} */ -// 1001037C: using guessed type int __stdcall SDlgDefDialogProc(_DWORD, _DWORD, _DWORD, _DWORD); + return (LRESULT)SDlgDefDialogProc(hWnd, Msg, (HDC)wParam, (HWND)lParam); +} // 10010382: using guessed type _DWORD __stdcall SDrawGetFrameWindow(); // ref: 0x1000FBC7 -HWND UNKCALL SelYesNo_1000FBC7(HWND hDlg) { return 0; } -/* { +void __fastcall SelYesNo_RemoveYNDialog(HWND hWnd) +{ HWND v1; // esi - _DWORD *v2; // eax - HWND result; // eax - HWND v4; // eax + void **v2; // eax + HWND v3; // eax - v1 = hDlg; - v2 = (_DWORD *)GetWindowLongA(hDlg, -21); - local_10007F72(v2); - if ( dword_1002A500 ) - Focus_100076C3(); - Doom_10006C53(v1, (int *)&unk_100232DC); - result = (HWND)Doom_10006C53(v1, (int *)&unk_100232D4); - if ( dword_1002A504 ) + v1 = hWnd; + v2 = (void **)GetWindowLongA(hWnd, -21); + local_FreeMemPtr(v2); + if ( yesno_remove_focus ) + Focus_DeleteSpinners(); + Doom_DeleteFreeProcs(v1, yesno_msgtbl1); + Doom_DeleteFreeProcs(v1, yesno_msgtbl2); + if ( yesno_hero_name ) { - v4 = GetParent(v1); - result = SelHero_1000BA7B(v4, 0); + v3 = GetParent(v1); + SelHero_SetStringWithMsg(v3, 0); } - return result; -} */ -// 1002A500: using guessed type int dword_1002A500; -// 1002A504: using guessed type int dword_1002A504; +} +// 1002A500: using guessed type int yesno_remove_focus; // ref: 0x1000FC1C -void UNKCALL SelYesNo_1000FC1C(HWND hWnd) { return; } -/* { - HWND v1; // esi +void __fastcall SelYesNo_LoadSelYN_GFX(HWND hWnd) +{ HWND v2; // eax - int v3; // eax - int *v4; // edi + DWORD *v3; // eax + DWORD *v4; // edi const char *v5; // eax - const CHAR *v6; // ST18_4 + char *v6; // ST18_4 HWND v7; // eax - v1 = hWnd; v2 = GetParent(hWnd); - if ( dword_1002A504 ) - SelHero_1000BA7B(v2, (const char *)dword_1002A504); - v3 = local_10007F46(); - v4 = (int *)v3; + if ( yesno_hero_name ) + SelHero_SetStringWithMsg(v2, yesno_hero_name); + v3 = local_AllocWndLongData(); + v4 = v3; if ( v3 ) { - SetWindowLongA(v1, -21, v3); - if ( dword_1002A50C ) + SetWindowLongA(hWnd, -21, (LONG)v3); + if ( yesno_is_popup ) { - if ( DiabloUI_10005C2A() ) + if ( DiabloUI_GetSpawned() ) v5 = "ui_art\\swmmpop.pcx"; else v5 = "ui_art\\mmpopup.pcx"; @@ -154,97 +146,81 @@ void UNKCALL SelYesNo_1000FC1C(HWND hWnd) { return; } { v5 = "ui_art\\black.pcx"; } - local_10007944((int)v1, 0, "Popup", -1, 1, (int)v5, v4, v4 + 1, 1); + local_LoadArtWithPal(hWnd, 0, "Popup", -1, 1, v5, (BYTE **)v4, v4 + 1, 1); } - v6 = dword_1002A4F8; - v7 = GetDlgItem(v1, 1026); + v6 = yesno_dialog_string; + v7 = GetDlgItem(hWnd, 1026); SetWindowTextA(v7, v6); - Doom_100068AB(v1, (int *)&unk_100232D4, 3); - Doom_1000658C(v1, (int *)&unk_100232DC, 4, 1); - if ( dword_1002A500 ) - Focus_10007719("ui_art\\focus.pcx"); + Doom_ParseWndProc3(hWnd, yesno_msgtbl2, 3); + Doom_ParseWndProcs(hWnd, yesno_msgtbl1, 4, 1); + if ( yesno_remove_focus ) + Focus_LoadSpinner("ui_art\\focus.pcx"); else - Focus_100076FA(); - SDlgSetTimer(v1, 1, 55, 0); - return local_10007DE9(v1, (int *)&unk_100232DC); -} */ -// 10010412: using guessed type int __stdcall SDlgSetTimer(_DWORD, _DWORD, _DWORD, _DWORD); -// 1002A500: using guessed type int dword_1002A500; -// 1002A504: using guessed type int dword_1002A504; -// 1002A50C: using guessed type int dword_1002A50C; + Focus_ResetSpinToZero(); + SDlgSetTimer((int)hWnd, 1, 55, 0); + local_DoUiWndProc2(hWnd, (DWORD *)yesno_msgtbl1); +} +// 1002A500: using guessed type int yesno_remove_focus; +// 1002A50C: using guessed type int yesno_is_popup; // ref: 0x1000FCF6 -int __fastcall SelYesNo_1000FCF6(int a1, LONG a2) { return 0; } -/* { - LONG v2; // esi - int v3; // edi +void __fastcall SelYesNo_DoSelectYesNo(HWND hWnd, int option) +{ HWND v4; // eax - v2 = a2; - v3 = a1; - TitleSnd_1001031F(); - SDlgKillTimer(v3, 1); - if ( v2 == 2 ) + TitleSnd_PlaySelectSound(); + SDlgKillTimer((int)hWnd, 1); + if ( option == 2 ) { - if ( !dword_1002A508 ) - return SDlgEndDialog(v3, v2); - dword_1002A508(); + if ( !YesNoFunc ) + goto LABEL_6; + YesNoFunc(); } - if ( v2 == 1 ) + if ( option == 1 ) { v4 = GetFocus(); - v2 = GetWindowLongA(v4, -12); + option = GetWindowLongA(v4, -12); } - return SDlgEndDialog(v3, v2); -} */ -// 10010376: using guessed type int __stdcall SDlgEndDialog(_DWORD, _DWORD); -// 10010418: using guessed type int __stdcall SDlgKillTimer(_DWORD, _DWORD); -// 1002A508: using guessed type int (*dword_1002A508)(void); +LABEL_6: + SDlgEndDialog(hWnd, (HANDLE)option); +} +// 1002A508: using guessed type int (*YesNoFunc)(void); // ref: 0x1000FD39 -int __fastcall SelYesNo_1000FD39(int a1, const CHAR *a2, int a3, int a4) { return 0; } -/* { - dword_1002A4F8 = a2; - dword_1002A504 = a3; - dword_1002A500 = a4; - dword_1002A50C = 0; - dword_1002A508 = 0; - return SDlgDialogBoxParam(hInstance, "SELOK_DIALOG", a1, SelYesNo_1000FA87, 0); -} */ -// 10010370: using guessed type int __stdcall SDlgDialogBoxParam(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD); -// 1002A500: using guessed type int dword_1002A500; -// 1002A504: using guessed type int dword_1002A504; -// 1002A508: using guessed type int (*dword_1002A508)(void); -// 1002A50C: using guessed type int dword_1002A50C; +int __fastcall SelYesNo_SelOkDialog(HWND hWnd, char *dialogstr, char *hero, int nofocus) +{ + yesno_dialog_string = dialogstr; + yesno_hero_name = hero; + yesno_remove_focus = nofocus; + yesno_is_popup = 0; + YesNoFunc = 0; + return SDlgDialogBoxParam(ghUiInst, "SELOK_DIALOG", (int)hWnd, SelYesNo_WndProc, 0); +} +// 1002A500: using guessed type int yesno_remove_focus; +// 1002A508: using guessed type int (*YesNoFunc)(void); +// 1002A50C: using guessed type int yesno_is_popup; // ref: 0x1000FD77 -int __fastcall SelYesNo_1000FD77(int a1, UINT a2, int a3) { return 0; } -/* { - int v3; // esi - CHAR Buffer; // [esp+4h] [ebp-100h] +int __fastcall SelYesNo_SpawnErrDialog(HWND hWnd, int string_rsrc, int is_popup) +{ + char Buffer[256]; // [esp+4h] [ebp-100h] - v3 = a1; - LoadStringA(hInstance, a2, &Buffer, 255); - dword_1002A50C = a3; - dword_1002A500 = 0; - dword_1002A504 = 0; - dword_1002A4F8 = &Buffer; - dword_1002A508 = 0; - return SDlgDialogBoxParam(hInstance, "SPAWNERR_DIALOG", v3, SelYesNo_1000FA87, 0); -} */ -// 10010370: using guessed type int __stdcall SDlgDialogBoxParam(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD); -// 1002A500: using guessed type int dword_1002A500; -// 1002A504: using guessed type int dword_1002A504; -// 1002A508: using guessed type int (*dword_1002A508)(void); -// 1002A50C: using guessed type int dword_1002A50C; + LoadStringA(ghUiInst, string_rsrc, Buffer, 255); + yesno_is_popup = is_popup; + yesno_remove_focus = 0; + yesno_hero_name = 0; + yesno_dialog_string = Buffer; + YesNoFunc = 0; + return SDlgDialogBoxParam(ghUiInst, "SPAWNERR_DIALOG", (int)hWnd, SelYesNo_WndProc, 0); +} +// 1002A500: using guessed type int yesno_remove_focus; +// 1002A508: using guessed type int (*YesNoFunc)(void); +// 1002A50C: using guessed type int yesno_is_popup; // ref: 0x1000FDE3 -signed int SelYesNo_1000FDE3() { return 0; } -/* { - signed int result; // eax - - result = 2139095040; - dword_1002A4FC = 2139095040; - return result; -} */ -// 1002A4FC: using guessed type int dword_1002A4FC; +void __cdecl SelYesNo_cpp_init() +{ + SelYesNo_cpp_float = SelYesNo_cpp_float_value; +} +// 1001F478: using guessed type int SelYesNo_cpp_float_value; +// 1002A4FC: using guessed type int SelYesNo_cpp_float; diff --git a/Source/pfile.cpp b/Source/pfile.cpp index 5cba7da25..04fea7a06 100644 --- a/Source/pfile.cpp +++ b/Source/pfile.cpp @@ -288,7 +288,7 @@ char __fastcall game_2_ui_class(PlayerStruct *p) return result; } -bool __stdcall pfile_ui_set_hero_infos(void (__stdcall *ui_add_hero_info)(_uiheroinfo *)) +BOOL __stdcall pfile_ui_set_hero_infos(BOOL (__stdcall *ui_add_hero_info)(_uiheroinfo *)) { char *v1; // esi //int v2; // eax @@ -507,7 +507,7 @@ bool __fastcall pfile_archive_contains_game(void *hsArchive) } // 679660: using guessed type char gbMaxPlayers; -bool __stdcall pfile_ui_set_class_stats(int player_class_nr, _uidefaultstats *class_stats) +BOOL __stdcall pfile_ui_set_class_stats(int player_class_nr, _uidefaultstats *class_stats) { int v2; // eax @@ -530,7 +530,7 @@ int __fastcall pfile_get_player_class(int player_class_nr) return result; } -bool __stdcall pfile_ui_save_create(_uiheroinfo *heroinfo) +BOOL __stdcall pfile_ui_save_create(_uiheroinfo *heroinfo) { unsigned int v1; // edi //int v3; // eax @@ -609,7 +609,7 @@ LABEL_10: } // 679660: using guessed type char gbMaxPlayers; -bool __stdcall pfile_delete_save(_uiheroinfo *hero_info) +BOOL __stdcall pfile_delete_save(_uiheroinfo *hero_info) { unsigned int v1; // eax char FileName[260]; // [esp+0h] [ebp-104h] diff --git a/Source/pfile.h b/Source/pfile.h index 6b5553fc8..a4b0e87e8 100644 --- a/Source/pfile.h +++ b/Source/pfile.h @@ -21,17 +21,17 @@ int __fastcall pfile_create_save_file(char *name_1, char *name_2); void __cdecl pfile_flush_W(); void __fastcall game_2_ui_player(PlayerStruct *p, _uiheroinfo *heroinfo, bool bHasSaveFile); char __fastcall game_2_ui_class(PlayerStruct *p); -bool __stdcall pfile_ui_set_hero_infos(void (__stdcall *ui_add_hero_info)(_uiheroinfo *)); +BOOL __stdcall pfile_ui_set_hero_infos(BOOL (__stdcall *ui_add_hero_info)(_uiheroinfo *)); char *__fastcall GetSaveDirectory(char *dst, int dst_size, int save_num); bool __fastcall pfile_read_hero(void *archive, PkPlayerStruct *pPack); void *__fastcall pfile_open_save_archive(int *unused, int save_num); void __fastcall pfile_SFileCloseArchive(void *hsArchive); bool __fastcall pfile_archive_contains_game(void *hsArchive); -bool __stdcall pfile_ui_set_class_stats(int player_class_nr, _uidefaultstats *class_stats); +BOOL __stdcall pfile_ui_set_class_stats(int player_class_nr, _uidefaultstats *class_stats); int __fastcall pfile_get_player_class(int player_class_nr); -bool __stdcall pfile_ui_save_create(_uiheroinfo *heroinfo); +BOOL __stdcall pfile_ui_save_create(_uiheroinfo *heroinfo); bool __stdcall pfile_get_file_name(int lvl, char *dst); -bool __stdcall pfile_delete_save(_uiheroinfo *hero_info); +BOOL __stdcall pfile_delete_save(_uiheroinfo *hero_info); void __cdecl pfile_read_player_from_save(); void __fastcall GetTempLevelNames(char *szTemp); void __fastcall GetPermLevelNames(char *szPerm); From 42c9076ce5ef43b4eb584a1e193ca08c7f72d0c1 Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Wed, 19 Sep 2018 14:44:30 -0500 Subject: [PATCH 5/6] Sync with nightly (#302) --- .editorconfig | 19 +++++++++++-------- .travis/are-we-d1-yet.sh | 2 +- Source/inv.cpp | 4 ++-- Source/items.cpp | 4 ++-- Source/player.cpp | 4 ++-- structs.h | 8 ++++---- 6 files changed, 22 insertions(+), 19 deletions(-) diff --git a/.editorconfig b/.editorconfig index 4fd3d544f..c90d5fd95 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,8 +1,11 @@ -root = true - -[*] -indent_style = tab -end_of_line = crlf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true +root = true + +[*] +indent_style = tab +end_of_line = crlf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.sh] +end_of_line = lf diff --git a/.travis/are-we-d1-yet.sh b/.travis/are-we-d1-yet.sh index dcdab1883..7ab4a4a2b 100755 --- a/.travis/are-we-d1-yet.sh +++ b/.travis/are-we-d1-yet.sh @@ -3,7 +3,7 @@ # based on https://github.com/k3rn31p4nic/travis-ci-discord-webhook # Only run for commits/builds on master, not for PRs for now -if [[ "$TRAVIS_BRANCH" != "master" || $TRAVIS_PULL_REQUEST != "false" ]]; then +if [[ "$TRAVIS_BRANCH" != "nightly" || $TRAVIS_PULL_REQUEST != "false" ]]; then exit fi diff --git a/Source/inv.cpp b/Source/inv.cpp index f70004eaa..cb10e2c08 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -1861,7 +1861,7 @@ void __fastcall RemoveInvItem(int pnum, int iv) { if ( plr[pnum]._pRSpell != SPL_INVALID ) { - // BUGFIX: Cast the literal `1` to `UINT64` to make that bitshift 64bit + // BUGFIX: Cast the literal `1` to `unsigned __int64` to make that bitshift 64bit // this causes the last 4 skills to not reset correctly after use if ( !( plr[pnum]._pScrlSpells64 @@ -1885,7 +1885,7 @@ void __fastcall RemoveSpdBarItem(int pnum, int iv) { if ( plr[pnum]._pRSpell != SPL_INVALID ) { - // BUGFIX: Cast the literal `1` to `UINT64` to make that bitshift 64bit + // BUGFIX: Cast the literal `1` to `unsigned __int64` to make that bitshift 64bit // this causes the last 4 skills to not reset correctly after use if ( !( plr[pnum]._pScrlSpells64 diff --git a/Source/items.cpp b/Source/items.cpp index 313ce2853..12fbc9009 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -775,7 +775,7 @@ void __fastcall CalcPlrItemVals(int p, BOOL Loadgfx) int dadd = 0; // added dexterity int vadd = 0; // added vitality - UINT64 spl = 0; // bitarray for all enabled/active spells + unsigned __int64 spl = 0; // bitarray for all enabled/active spells signed int fr = 0; // fire resistance signed int lr = 0; // lightning resistance @@ -938,7 +938,7 @@ void __fastcall CalcPlrItemVals(int p, BOOL Loadgfx) // check if the current RSplType is a valid/allowed spell if ( plr[p]._pRSplType == RSPLTYPE_CHARGES - && !(spl & ((UINT64)1 << (plr[p]._pRSpell - 1))) ) + && !(spl & ((unsigned __int64)1 << (plr[p]._pRSpell - 1))) ) { plr[p]._pRSpell = SPL_INVALID; plr[p]._pRSplType = RSPLTYPE_INVALID; diff --git a/Source/player.cpp b/Source/player.cpp index eaa5d86b9..dac306b32 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -3105,7 +3105,7 @@ BOOL __fastcall PM_DoSpell(int pnum) if ( !plr[pnum]._pSplFrom ) { if ( plr[pnum]._pRSplType == RSPLTYPE_SCROLL) { if ( !(plr[pnum]._pScrlSpells64 - & (UINT64)1 << (plr[pnum]._pRSpell - 1)) + & (unsigned __int64)1 << (plr[pnum]._pRSpell - 1)) ) { plr[pnum]._pRSpell = SPL_INVALID; plr[pnum]._pRSplType = RSPLTYPE_INVALID; @@ -3115,7 +3115,7 @@ BOOL __fastcall PM_DoSpell(int pnum) if ( plr[pnum]._pRSplType == RSPLTYPE_CHARGES) { if ( !(plr[pnum]._pISpells64 - & (UINT64)1 << (plr[pnum]._pRSpell - 1)) + & (unsigned __int64)1 << (plr[pnum]._pRSpell - 1)) ) { plr[pnum]._pRSpell = SPL_INVALID; plr[pnum]._pRSplType = RSPLTYPE_INVALID; diff --git a/structs.h b/structs.h index 1da28b356..26180816e 100644 --- a/structs.h +++ b/structs.h @@ -213,15 +213,15 @@ struct PlayerStruct char _pSBkSplType; char _pSplLvl[64]; union { - __int64 _pMemSpells64; + unsigned __int64 _pMemSpells64; int _pMemSpells[2]; }; union { - __int64 _pAblSpells64; + unsigned __int64 _pAblSpells64; int _pAblSpells[2]; }; union { - __int64 _pScrlSpells64; + unsigned __int64 _pScrlSpells64; int _pScrlSpells[2]; }; int _pSpellFlags; @@ -322,7 +322,7 @@ struct PlayerStruct int _pIBonusAC; int _pIBonusDamMod; union { - __int64 _pISpells64; + unsigned __int64 _pISpells64; int _pISpells[2]; }; int _pIFlags; From 58bae6de189758d984aedb2426a6e8827ab0da81 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Thu, 20 Sep 2018 02:37:29 +0200 Subject: [PATCH 6/6] Fix WeaponDur --- Source/player.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/Source/player.cpp b/Source/player.cpp index eaa5d86b9..a6cca86b2 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -2464,7 +2464,7 @@ BOOL __fastcall WeaponDur(int pnum, int durrnd) } plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability--; - if ( plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability != 0) { + if ( plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability == 0) { NetSendCmdDelItem(TRUE, INVLOC_HAND_LEFT); plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype = ITYPE_NONE; CalcPlrInv(pnum, TRUE); @@ -2478,7 +2478,7 @@ BOOL __fastcall WeaponDur(int pnum, int durrnd) } plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iDurability--; - if ( plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iDurability != 0 ) { + if ( plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iDurability == 0 ) { NetSendCmdDelItem(TRUE, INVLOC_HAND_RIGHT); plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype = ITYPE_NONE; CalcPlrInv(pnum, TRUE); @@ -2492,7 +2492,7 @@ BOOL __fastcall WeaponDur(int pnum, int durrnd) } plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iDurability--; - if ( plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iDurability != 0 ) { + if ( plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iDurability == 0 ) { NetSendCmdDelItem(TRUE, INVLOC_HAND_RIGHT); plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype = ITYPE_NONE; CalcPlrInv(pnum, TRUE); @@ -2501,14 +2501,16 @@ BOOL __fastcall WeaponDur(int pnum, int durrnd) } if ( plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype == ITYPE_NONE && plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_SHIELD ) { - if ( plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability != 255 ) { - plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability--; - if ( plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability != 0 ) { - NetSendCmdDelItem(TRUE, INVLOC_HAND_LEFT); - plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype = ITYPE_NONE; - CalcPlrInv(pnum, TRUE); - return TRUE; - } + if ( plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability == 255 ) { + return FALSE; + } + + plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability--; + if ( plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability == 0 ) { + NetSendCmdDelItem(TRUE, INVLOC_HAND_LEFT); + plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype = ITYPE_NONE; + CalcPlrInv(pnum, TRUE); + return TRUE; } }