From 5236992d8f88c305ace3f369741b1ee9c0635a7c Mon Sep 17 00:00:00 2001 From: Lundar Date: Thu, 21 Jun 2018 02:50:41 -0400 Subject: [PATCH] a little cleanup --- Source/diablo.cpp | 10 ++++++++++ Source/dthread.cpp | 13 ++++++------- Source/dx.cpp | 11 ++++------- Source/engine.cpp | 12 +++++------- Source/init.cpp | 16 ++++++---------- Source/logging.cpp | 11 ++++------- Source/mainmenu.cpp | 40 +++++++++++++++++++++++++++++++++++++++- Source/nthread.cpp | 11 ++++------- 8 files changed, 78 insertions(+), 46 deletions(-) diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 4835a47..d8b2095 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -284,9 +284,19 @@ bool __cdecl diablo_get_not_running() return GetLastError() != ERROR_ALREADY_EXISTS; } +void preMainInit(){ + engine_cpp_init_2(); + dx_cpp_init_2(); + dthread_cpp_init_2(); + nthread_cpp_init_2(); + log_cpp_init_2(); + +} + //----- (00408B4A) -------------------------------------------------------- int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { + preMainInit(); HINSTANCE v4; // esi //int v11; // ecx char Filename[260]; // [esp+8h] [ebp-10Ch] diff --git a/Source/dthread.cpp b/Source/dthread.cpp index d421a83..04fc850 100644 --- a/Source/dthread.cpp +++ b/Source/dthread.cpp @@ -26,14 +26,13 @@ struct dthread_cpp_init_1 // 52A4E0: using guessed type int dthread_cpp_init_value; //----- (004150A8) -------------------------------------------------------- -struct dthread_cpp_init_2 + +void __cdecl dthread_cpp_init_2() { - dthread_cpp_init_2() - { - dthread_init_mutex(); - dthread_cleanup_mutex_atexit(); - } -} _dthread_cpp_init_2; + dthread_init_mutex(); + dthread_cleanup_mutex_atexit(); +} + //----- (004150B2) -------------------------------------------------------- void __cdecl dthread_init_mutex() diff --git a/Source/dx.cpp b/Source/dx.cpp index 62026c8..67f7e13 100644 --- a/Source/dx.cpp +++ b/Source/dx.cpp @@ -29,14 +29,11 @@ struct dx_cpp_init_1 // 52A514: using guessed type int dx_cpp_init_value; //----- (00415372) -------------------------------------------------------- -struct dx_cpp_init_2 +void __cdecl dx_cpp_init_2() { - dx_cpp_init_2() - { - dx_init_mutex(); - dx_cleanup_mutex_atexit(); - } -} _dx_cpp_init_2; + dx_init_mutex(); + dx_cleanup_mutex_atexit(); +} //----- (0041537C) -------------------------------------------------------- void __cdecl dx_init_mutex() diff --git a/Source/engine.cpp b/Source/engine.cpp index 0192abd..1c0cf78 100644 --- a/Source/engine.cpp +++ b/Source/engine.cpp @@ -1912,14 +1912,12 @@ int __fastcall random(int idx, int v) } //----- (0041756D) -------------------------------------------------------- -struct engine_cpp_init_2 +void __cdecl engine_cpp_init_2() { - engine_cpp_init_2() - { - mem_init_mutex(); - mem_atexit_mutex(); - } -} _engine_cpp_init_2; + mem_init_mutex(); + mem_atexit_mutex(); +} + //----- (00417577) -------------------------------------------------------- void __cdecl mem_init_mutex() diff --git a/Source/init.cpp b/Source/init.cpp index 64c0ad1..f8cc6a1 100644 --- a/Source/init.cpp +++ b/Source/init.cpp @@ -279,18 +279,14 @@ void __cdecl init_archives() fileinfo.originalarchivefile = diabdat_mpq_path; fileinfo.patcharchivefile = patch_rt_mpq_path; init_get_file_info(); + + diabdat_mpq = init_test_access(diabdat_mpq_path, "\\diabdat.mpq", "DiabloCD", 1000, 1); #ifdef COPYPROT - while ( 1 ) - { -#endif - diabdat_mpq = init_test_access(diabdat_mpq_path, "\\diabdat.mpq", "DiabloCD", 1000, 1); -#ifdef COPYPROT - if ( diabdat_mpq ) - break; - UiCopyProtError((int)&v1); + if (! diabdat_mpq ){ + UiCopyProtError(&v1); if ( v1 == COPYPROT_CANCEL ) FileErrDlg("diabdat.mpq"); - } + } #endif if ( !WOpenFile("ui_art\\title.pcx", &a1, 1) ) FileErrDlg("Main program archive: diabdat.mpq"); @@ -500,7 +496,7 @@ void __fastcall init_activate_window(HWND hWnd, bool activated) LONG dwNewLong; // eax window_activated = activated; - UiAppActivate(activated); + //UiAppActivate(activated); dwNewLong = GetWindowLongA(hWnd, GWL_STYLE); if ( window_activated && fullscreen ) diff --git a/Source/logging.cpp b/Source/logging.cpp index 0e441e5..813ca48 100644 --- a/Source/logging.cpp +++ b/Source/logging.cpp @@ -28,14 +28,11 @@ struct log_cpp_init_1 // 646A30: using guessed type int log_cpp_init_value; //----- (00427A02) -------------------------------------------------------- -struct log_cpp_init_2 +void __cdecl log_cpp_init_2() { - log_cpp_init_2() - { - log_init_mutex(); - j_log_cleanup_mutex(); - } -} _log_cpp_init_2; + log_init_mutex(); + j_log_cleanup_mutex(); +} //----- (00427A0C) -------------------------------------------------------- void __cdecl log_init_mutex() diff --git a/Source/mainmenu.cpp b/Source/mainmenu.cpp index 669b4a6..c67ee16 100644 --- a/Source/mainmenu.cpp +++ b/Source/mainmenu.cpp @@ -113,7 +113,7 @@ LABEL_6: //----- (00427F76) -------------------------------------------------------- void __fastcall mainmenu_action(int option) { - int v1; // eax +/* int v1; // eax int a2; // [esp+0h] [ebp-4h] a2 = option; @@ -152,6 +152,44 @@ LABEL_15: } while ( v1 ); LABEL_16: + music_stop();*/ + + int quit; // eax + int a2; // [esp+0h] [ebp-4h] + + //a2 = option;// development history seems to be showing here + mainmenu_refresh_music(); + do{ + quit = 1; + a2 = 0; + if ( !UiMainMenuDialog("Diablo v1.09", &a2, effects_play_sound, 30) ){ + TermMsg("Unable to display mainmenu"); + //old code would go directly to single player here... + break;//new code will quit. + } + + switch ( a2 ) + { + case MAINMENU_SINGLE_PLAYER: + quit = mainmenu_single_player(); + break; + case MAINMENU_MULTIPLAYER: + quit = mainmenu_multi_player(); + break; + case MAINMENU_SHOW_CREDITS: + UiCreditsDialog(16); + break; + case MAINMENU_EXIT_DIABLO: + quit = 0; + break; + case MAINMENU_REPLAY_INTRO: + case MAINMENU_ATTRACT_MODE: + if ( window_activated ) + mainmenu_play_intro(); + break; + } + }while ( quit ); + music_stop(); } // 634980: using guessed type int window_activated; diff --git a/Source/nthread.cpp b/Source/nthread.cpp index 04701d0..c291073 100644 --- a/Source/nthread.cpp +++ b/Source/nthread.cpp @@ -37,14 +37,11 @@ struct nthread_cpp_init_1 // 679700: using guessed type int nthread_cpp_init_value; //----- (00440DBE) -------------------------------------------------------- -struct nthread_cpp_init_2 +void __cdecl nthread_cpp_init_2() { - nthread_cpp_init_2() - { - nthread_init_mutex(); - nthread_cleanup_mutex_atexit(); - } -} _nthread_cpp_init_2; + nthread_init_mutex(); + nthread_cleanup_mutex_atexit(); +} //----- (00440DC8) -------------------------------------------------------- void __cdecl nthread_init_mutex()