From fa254306949eec458cdff71c3867ded0e7494d2f Mon Sep 17 00:00:00 2001 From: NΞVΛR Date: Sun, 1 Mar 2026 18:19:38 +0100 Subject: Fix for exe not running, not founding the project directory In _tWinMain (Windows64_Minecraft.cpp) add logic to detect if the executable path contains "\\x64\\". If found, truncate the path at that position, append "\\Minecraft.Client" and call SetCurrentDirectoryA to set the process working directory. This ensures relative resource paths resolve correctly when running from an x64 build output directory; the change is guarded by a substring check and uses MAX_PATH-safe APIs. --- Minecraft.Client/Windows64/Windows64_Minecraft.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'Minecraft.Client/Windows64/Windows64_Minecraft.cpp') diff --git a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp index 931e7f17..50791c02 100644 --- a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp +++ b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp @@ -716,6 +716,16 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); + + char exePath[MAX_PATH]; + GetModuleFileNameA(NULL, exePath, MAX_PATH); + char* x64_pos = strstr(exePath, "\\x64\\"); + if (x64_pos) { + *x64_pos = 0; + strcat_s(exePath, MAX_PATH, "\\Minecraft.Client"); + SetCurrentDirectoryA(exePath); + } + // Declare DPI awareness so GetSystemMetrics returns physical pixels SetProcessDPIAware(); g_iScreenWidth = GetSystemMetrics(SM_CXSCREEN); -- cgit v1.2.3 From e23945a020f6483202e21df360f615b1ea55b119 Mon Sep 17 00:00:00 2001 From: NΞVΛR Date: Sun, 1 Mar 2026 18:40:09 +0100 Subject: Fixed performance issue thx to @void2012 --- Minecraft.Client/Windows64/Windows64_Minecraft.cpp | 24 +++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'Minecraft.Client/Windows64/Windows64_Minecraft.cpp') diff --git a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp index 50791c02..42fb2d44 100644 --- a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp +++ b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp @@ -717,13 +717,23 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, UNREFERENCED_PARAMETER(lpCmdLine); - char exePath[MAX_PATH]; - GetModuleFileNameA(NULL, exePath, MAX_PATH); - char* x64_pos = strstr(exePath, "\\x64\\"); - if (x64_pos) { - *x64_pos = 0; - strcat_s(exePath, MAX_PATH, "\\Minecraft.Client"); - SetCurrentDirectoryA(exePath); + WCHAR exePath[MAX_PATH] = { 0 }; + GetModuleFileNameW(NULL, exePath, MAX_PATH); + WCHAR* lastSlash = wcsrchr(exePath, L'\\'); + if (lastSlash) { + *lastSlash = L'\0'; + + WCHAR devCheckPath[MAX_PATH] = { 0 }; + swprintf_s(devCheckPath, MAX_PATH, L"%s\\..\\..\\Minecraft.Client\\Minecraft.Client.vcxproj", exePath); + + if (GetFileAttributesW(devCheckPath) != INVALID_FILE_ATTRIBUTES) { + WCHAR projectPath[MAX_PATH] = { 0 }; + swprintf_s(projectPath, MAX_PATH, L"%s\\..\\..\\Minecraft.Client", exePath); + SetCurrentDirectoryW(projectPath); + } + else { + SetCurrentDirectoryW(exePath); + } } // Declare DPI awareness so GetSystemMetrics returns physical pixels -- cgit v1.2.3 From 3db164d913a0e6e464cc9f32c6c471cbea7a46e7 Mon Sep 17 00:00:00 2001 From: APAmk2 <107351397+APAmk2@users.noreply.github.com> Date: Sun, 1 Mar 2026 22:13:44 +0400 Subject: Windows: More proper shutdown --- Minecraft.Client/Windows64/Windows64_App.cpp | 4 ++-- Minecraft.Client/Windows64/Windows64_App.h | 2 ++ Minecraft.Client/Windows64/Windows64_Minecraft.cpp | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) (limited to 'Minecraft.Client/Windows64/Windows64_Minecraft.cpp') diff --git a/Minecraft.Client/Windows64/Windows64_App.cpp b/Minecraft.Client/Windows64/Windows64_App.cpp index a8b2d9cc..bba33cad 100644 --- a/Minecraft.Client/Windows64/Windows64_App.cpp +++ b/Minecraft.Client/Windows64/Windows64_App.cpp @@ -14,6 +14,7 @@ CConsoleMinecraftApp app; CConsoleMinecraftApp::CConsoleMinecraftApp() : CMinecraftApp() { + m_bShutdown = false; } void CConsoleMinecraftApp::SetRichPresenceContext(int iPad, int contextId) @@ -26,8 +27,7 @@ void CConsoleMinecraftApp::StoreLaunchData() } void CConsoleMinecraftApp::ExitGame() { - // This is likely not the correct way to exit the game, but it will do for now - ExitProcess(0); + m_bShutdown = true; } void CConsoleMinecraftApp::FatalLoadError() { diff --git a/Minecraft.Client/Windows64/Windows64_App.h b/Minecraft.Client/Windows64/Windows64_App.h index 39351d55..de8f6d85 100644 --- a/Minecraft.Client/Windows64/Windows64_App.h +++ b/Minecraft.Client/Windows64/Windows64_App.h @@ -29,6 +29,8 @@ public: // original code virtual void TemporaryCreateGameStart(); + + bool m_bShutdown; }; extern CConsoleMinecraftApp app; diff --git a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp index 42fb2d44..7fe77632 100644 --- a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp +++ b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp @@ -1054,7 +1054,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, } #endif MSG msg = {0}; - while( WM_QUIT != msg.message ) + while( WM_QUIT != msg.message && !app.m_bShutdown) { if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) { -- cgit v1.2.3 From ec61d19d783da9dcc212aab5298ec98329280afd Mon Sep 17 00:00:00 2001 From: Galen Guyer Date: Sun, 1 Mar 2026 13:13:28 -0500 Subject: Revert "Merge pull request #25 from NEVARLeVrai/main" This reverts commit 33e1b5ceb9970e08cb6b2b987afdff4bd42331ac, reversing changes made to 44b68333a31727f2869470acb8df3dab2c653f68. This is a hacky way of doing it instead of just copying the assets that are needed --- Minecraft.Client/Windows64/Windows64_Minecraft.cpp | 20 -------------------- 1 file changed, 20 deletions(-) (limited to 'Minecraft.Client/Windows64/Windows64_Minecraft.cpp') diff --git a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp index 42fb2d44..931e7f17 100644 --- a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp +++ b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp @@ -716,26 +716,6 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); - - WCHAR exePath[MAX_PATH] = { 0 }; - GetModuleFileNameW(NULL, exePath, MAX_PATH); - WCHAR* lastSlash = wcsrchr(exePath, L'\\'); - if (lastSlash) { - *lastSlash = L'\0'; - - WCHAR devCheckPath[MAX_PATH] = { 0 }; - swprintf_s(devCheckPath, MAX_PATH, L"%s\\..\\..\\Minecraft.Client\\Minecraft.Client.vcxproj", exePath); - - if (GetFileAttributesW(devCheckPath) != INVALID_FILE_ATTRIBUTES) { - WCHAR projectPath[MAX_PATH] = { 0 }; - swprintf_s(projectPath, MAX_PATH, L"%s\\..\\..\\Minecraft.Client", exePath); - SetCurrentDirectoryW(projectPath); - } - else { - SetCurrentDirectoryW(exePath); - } - } - // Declare DPI awareness so GetSystemMetrics returns physical pixels SetProcessDPIAware(); g_iScreenWidth = GetSystemMetrics(SM_CXSCREEN); -- cgit v1.2.3