From bbba35362d9053d1be194c2b74bc971e06ce469e Mon Sep 17 00:00:00 2001 From: GabsPuNs Date: Tue, 19 May 2026 00:35:04 -0400 Subject: [PATCH] Remove Win64LaunchOptions --- .../Windows64/Network/WinsockNetLayer.cpp | 1 - .../Windows64/Network/WinsockNetLayer.h | 1 - Minecraft.Client/Windows64/PostProcesser.cpp | 2 - .../Windows64/Windows64_Minecraft.cpp | 168 +++++------------- Minecraft.Server/Windows64/ServerMain.cpp | 1 - 5 files changed, 43 insertions(+), 130 deletions(-) diff --git a/Minecraft.Client/Windows64/Network/WinsockNetLayer.cpp b/Minecraft.Client/Windows64/Network/WinsockNetLayer.cpp index 161ec99d..6e73323f 100644 --- a/Minecraft.Client/Windows64/Network/WinsockNetLayer.cpp +++ b/Minecraft.Client/Windows64/Network/WinsockNetLayer.cpp @@ -78,7 +78,6 @@ BYTE WinsockNetLayer::s_joinAssignedSmallId = 0; DisconnectPacket::eDisconnectReason WinsockNetLayer::s_joinRejectReason = DisconnectPacket::eDisconnect_Quitting; bool g_Win64MultiplayerHost = false; -bool g_Win64MultiplayerJoin = false; int g_Win64MultiplayerPort = WIN64_NET_DEFAULT_PORT; char g_Win64MultiplayerIP[256] = "127.0.0.1"; bool g_Win64DedicatedServer = false; diff --git a/Minecraft.Client/Windows64/Network/WinsockNetLayer.h b/Minecraft.Client/Windows64/Network/WinsockNetLayer.h index 8a11e391..89edb916 100644 --- a/Minecraft.Client/Windows64/Network/WinsockNetLayer.h +++ b/Minecraft.Client/Windows64/Network/WinsockNetLayer.h @@ -194,7 +194,6 @@ public: }; extern bool g_Win64MultiplayerHost; -extern bool g_Win64MultiplayerJoin; extern int g_Win64MultiplayerPort; extern char g_Win64MultiplayerIP[256]; extern bool g_Win64DedicatedServer; diff --git a/Minecraft.Client/Windows64/PostProcesser.cpp b/Minecraft.Client/Windows64/PostProcesser.cpp index c04027d5..2aa43292 100644 --- a/Minecraft.Client/Windows64/PostProcesser.cpp +++ b/Minecraft.Client/Windows64/PostProcesser.cpp @@ -2,8 +2,6 @@ #include "..\Common\PostProcesser.h" #include -#pragma comment(lib, "d3dcompiler.lib") - extern ID3D11Device* g_pd3dDevice; extern ID3D11DeviceContext* g_pImmediateContext; extern IDXGISwapChain* g_pSwapChain; diff --git a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp index 9b098f48..33736968 100644 --- a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp +++ b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp @@ -46,23 +46,11 @@ extern "C" __declspec(dllexport) unsigned long NvOptimusEnablement = 0x00000001; } -#ifdef _MSC_VER -#pragma comment(lib, "legacy_stdio_definitions.lib") -#endif - HINSTANCE hMyInst; LRESULT CALLBACK DlgProc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lParam); char chGlobalText[256]; uint16_t ui16GlobalText[256]; -#define THEME_NAME "584111F70AAAAAAA" -#define THEME_FILESIZE 2797568 - -//#define THREE_MB 3145728 // minimum save size (checking for this on a selected device) -//#define FIVE_MB 5242880 // minimum save size (checking for this on a selected device) -//#define FIFTY_TWO_MB (1024*1024*52) // Maximum TCR space required for a save (checking for this on a selected device) -#define FIFTY_ONE_MB (1000000*51) // Maximum TCR space required for a save is 52MB (checking for this on a selected device) - //#define PROFILE_VERSION 3 // new version for the interim bug fix 166 TU #define NUM_PROFILE_VALUES 5 #define NUM_PROFILE_SETTINGS 4 @@ -78,13 +66,6 @@ DWORD dwProfileSettingsA[NUM_PROFILE_VALUES]= 0,0,0,0,0 #endif }; -//------------------------------------------------------------------------------------- -// Time Since fAppTime is a float, we need to keep the quadword app time -// as a LARGE_INTEGER so that we don't lose precision after running -// for a long time. -//------------------------------------------------------------------------------------- - -BOOL g_bWidescreen = TRUE; // Screen resolution — auto-detected from the monitor at startup. // The 3D world renders at native resolution; Flash UI is 16:9-fitted and centered @@ -115,19 +96,6 @@ struct Win64LaunchOptions bool fullscreen; }; -static void CopyWideArgToAnsi(LPCWSTR source, char* dest, size_t destSize) -{ - if (destSize == 0) - return; - - dest[0] = 0; - if (source == nullptr) - return; - - WideCharToMultiByte(CP_ACP, 0, source, -1, dest, static_cast(destSize), nullptr, nullptr); - dest[destSize - 1] = 0; -} - // ---------- Persistent options (options.txt next to exe) ---------- static void GetOptionsFilePath(char *out, size_t outSize) { @@ -172,76 +140,6 @@ static bool LoadFullscreenOption() } // ------------------------------------------------------------------ -static void ApplyScreenMode(int screenMode) -{ - switch (screenMode) - { - case 1: - g_iScreenWidth = 1280; - g_iScreenHeight = 720; - break; - case 2: - g_iScreenWidth = 640; - g_iScreenHeight = 480; - break; - case 3: - g_iScreenWidth = 720; - g_iScreenHeight = 408; - break; - default: - break; - } -} - -static Win64LaunchOptions ParseLaunchOptions() -{ - Win64LaunchOptions options = {}; - options.screenMode = 0; - - g_Win64MultiplayerJoin = false; - g_Win64MultiplayerPort = WIN64_NET_DEFAULT_PORT; - - int argc = 0; - LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &argc); - if (argv == nullptr) - return options; - - if (argc > 1 && lstrlenW(argv[1]) == 1) - { - if (argv[1][0] >= L'1' && argv[1][0] <= L'3') - options.screenMode = argv[1][0] - L'0'; - } - - for (int i = 1; i < argc; ++i) - { - if (_wcsicmp(argv[i], L"-name") == 0 && (i + 1) < argc) - { - CopyWideArgToAnsi(argv[++i], g_Win64Username, sizeof(g_Win64Username)); - } - else if (_wcsicmp(argv[i], L"-ip") == 0 && (i + 1) < argc) - { - char ipBuf[256]; - CopyWideArgToAnsi(argv[++i], ipBuf, sizeof(ipBuf)); - strncpy_s(g_Win64MultiplayerIP, sizeof(g_Win64MultiplayerIP), ipBuf, _TRUNCATE); - g_Win64MultiplayerJoin = true; - } - else if (_wcsicmp(argv[i], L"-port") == 0 && (i + 1) < argc) - { - wchar_t* endPtr = nullptr; - const long port = wcstol(argv[++i], &endPtr, 10); - if (endPtr != argv[i] && *endPtr == 0 && port > 0 && port <= 65535) - { - g_Win64MultiplayerPort = static_cast(port); - } - } - else if (_wcsicmp(argv[i], L"-fullscreen") == 0) - options.fullscreen = true; - } - - LocalFree(argv); - return options; -} - void DefineActions(void) { // The app needs to define the actions required, and the possible mappings for these @@ -845,7 +743,7 @@ HRESULT InitDevice() sd.Width = width; sd.Height = height; sd.Format = DXGI_FORMAT_R8G8B8A8_UNORM; - sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; + sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT | DXGI_USAGE_SHADER_INPUT; sd.SampleDesc.Count = 1; sd.SampleDesc.Quality = 0; sd.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD; @@ -1023,7 +921,7 @@ static bool ResizeD3D(int newW, int newH) sd.Width = bbW; sd.Height = bbH; sd.Format = DXGI_FORMAT_R8G8B8A8_UNORM; - sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; + sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT | DXGI_USAGE_SHADER_INPUT; sd.SampleDesc.Count = 1; sd.SampleDesc.Quality = 0; sd.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD; @@ -1205,28 +1103,24 @@ postReset: void ToggleFullscreen() { const DWORD dwStyle = GetWindowLong(g_hWnd, GWL_STYLE); + if (!g_isFullscreen) { MONITORINFO mi = {}; mi.cbSize = sizeof(mi); - if (GetWindowPlacement(g_hWnd, &g_wpPrev) && - GetMonitorInfo(MonitorFromWindow(g_hWnd, MONITOR_DEFAULTTOPRIMARY), &mi)) + if (GetWindowPlacement(g_hWnd, &g_wpPrev) && GetMonitorInfo(MonitorFromWindow(g_hWnd, MONITOR_DEFAULTTOPRIMARY), &mi)) { SetWindowLong(g_hWnd, GWL_STYLE, dwStyle & ~WS_OVERLAPPEDWINDOW); - SetWindowPos(g_hWnd, HWND_TOP, - mi.rcMonitor.left, mi.rcMonitor.top, - mi.rcMonitor.right - mi.rcMonitor.left, - mi.rcMonitor.bottom - mi.rcMonitor.top, - SWP_NOOWNERZORDER | SWP_FRAMECHANGED); + SetWindowPos(g_hWnd, HWND_TOP, mi.rcMonitor.left, mi.rcMonitor.top, mi.rcMonitor.right - mi.rcMonitor.left, mi.rcMonitor.bottom - mi.rcMonitor.top, SWP_NOOWNERZORDER | SWP_FRAMECHANGED); } } else { SetWindowLong(g_hWnd, GWL_STYLE, dwStyle | WS_OVERLAPPEDWINDOW); SetWindowPlacement(g_hWnd, &g_wpPrev); - SetWindowPos(g_hWnd, nullptr, 0, 0, 0, 0, - SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_FRAMECHANGED); + SetWindowPos(g_hWnd, nullptr, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_FRAMECHANGED); } + g_isFullscreen = !g_isFullscreen; SaveFullscreenOption(g_isFullscreen); @@ -1239,14 +1133,42 @@ void ToggleFullscreen() //-------------------------------------------------------------------------------------- void CleanupDevice() { - if( g_pImmediateContext ) g_pImmediateContext->ClearState(); + if (g_pImmediateContext) + { + g_pImmediateContext->ClearState(); + g_pImmediateContext->Release(); + g_pImmediateContext = nullptr; + } - if( g_pDepthStencilView ) g_pDepthStencilView->Release(); - if( g_pDepthStencilBuffer ) g_pDepthStencilBuffer->Release(); - if( g_pRenderTargetView ) g_pRenderTargetView->Release(); - if( g_pSwapChain ) g_pSwapChain->Release(); - if( g_pImmediateContext ) g_pImmediateContext->Release(); - if( g_pd3dDevice ) g_pd3dDevice->Release(); + if (g_pDepthStencilView) + { + g_pDepthStencilView->Release(); + g_pDepthStencilView = nullptr; + } + + if (g_pDepthStencilBuffer) + { + g_pDepthStencilBuffer->Release(); + g_pDepthStencilBuffer = nullptr; + } + + if (g_pRenderTargetView) + { + g_pRenderTargetView->Release(); + g_pRenderTargetView = nullptr; + } + + if (g_pSwapChain) + { + g_pSwapChain->Release(); + g_pSwapChain = nullptr; + } + + if (g_pd3dDevice) + { + g_pd3dDevice->Release(); + g_pd3dDevice = nullptr; + } } static Minecraft* InitialiseMinecraftRuntime() @@ -1368,10 +1290,6 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, fclose(f); } - // Load stuff from launch options, including username - const Win64LaunchOptions launchOptions = ParseLaunchOptions(); - ApplyScreenMode(launchOptions.screenMode); - // Ensure uid.dat exists from startup (before any multiplayer/login path). Win64Xuid::ResolvePersistentXuid(); @@ -1468,7 +1386,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, } // Restore fullscreen state from previous session - if (LoadFullscreenOption() && !g_isFullscreen || launchOptions.fullscreen) + if (LoadFullscreenOption() && !g_isFullscreen) { ToggleFullscreen(); } diff --git a/Minecraft.Server/Windows64/ServerMain.cpp b/Minecraft.Server/Windows64/ServerMain.cpp index 04ac390f..9bd1dbf7 100644 --- a/Minecraft.Server/Windows64/ServerMain.cpp +++ b/Minecraft.Server/Windows64/ServerMain.cpp @@ -393,7 +393,6 @@ int main(int argc, char **argv) MultiByteToWideChar(CP_ACP, 0, g_Win64Username, -1, g_Win64UsernameW, 17); g_Win64MultiplayerHost = true; - g_Win64MultiplayerJoin = false; g_Win64MultiplayerPort = config.port; strncpy_s(g_Win64MultiplayerIP, sizeof(g_Win64MultiplayerIP), config.bindIP, _TRUNCATE); g_Win64DedicatedServer = true;