Revert "Project modernization (#630)"

This code was not tested and breaks in Release builds, reverting to restore
functionality of the nightly. All in-game menus do not work and generating
a world crashes.

This reverts commit a9be52c41a.
This commit is contained in:
Loki Rautio
2026-03-07 21:12:22 -06:00
parent a9be52c41a
commit 087b7e7abf
1373 changed files with 19449 additions and 19903 deletions

View File

@@ -47,7 +47,6 @@
#include "..\GameRenderer.h"
#include "Network\WinsockNetLayer.h"
#include "Windows64_Xuid.h"
#include "Common/UI/UI.h"
#include "Xbox/resource.h"
@@ -83,6 +82,7 @@ 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
@@ -124,17 +124,17 @@ static void CopyWideArgToAnsi(LPCWSTR source, char* dest, size_t destSize)
return;
dest[0] = 0;
if (source == nullptr)
if (source == NULL)
return;
WideCharToMultiByte(CP_ACP, 0, source, -1, dest, static_cast<int>(destSize), nullptr, nullptr);
WideCharToMultiByte(CP_ACP, 0, source, -1, dest, (int)destSize, NULL, NULL);
dest[destSize - 1] = 0;
}
// ---------- Persistent options (options.txt next to exe) ----------
static void GetOptionsFilePath(char *out, size_t outSize)
{
GetModuleFileNameA(nullptr, out, static_cast<DWORD>(outSize));
GetModuleFileNameA(NULL, out, (DWORD)outSize);
char *p = strrchr(out, '\\');
if (p) *(p + 1) = '\0';
strncat_s(out, outSize, "options.txt", _TRUNCATE);
@@ -210,7 +210,7 @@ static Win64LaunchOptions ParseLaunchOptions()
int argc = 0;
LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &argc);
if (argv == nullptr)
if (argv == NULL)
return options;
if (argc > 1 && lstrlenW(argv[1]) == 1)
@@ -252,14 +252,14 @@ static Win64LaunchOptions ParseLaunchOptions()
}
else if (_wcsicmp(argv[i], L"-port") == 0 && (i + 1) < argc)
{
wchar_t* endPtr = nullptr;
const long port = wcstol(argv[++i], &endPtr, 10);
wchar_t* endPtr = NULL;
long port = wcstol(argv[++i], &endPtr, 10);
if (endPtr != argv[i] && *endPtr == 0 && port > 0 && port <= 65535)
{
if (options.serverMode)
g_Win64DedicatedServerPort = static_cast<int>(port);
g_Win64DedicatedServerPort = (int)port;
else
g_Win64MultiplayerPort = static_cast<int>(port);
g_Win64MultiplayerPort = (int)port;
}
}
else if (_wcsicmp(argv[i], L"-fullscreen") == 0)
@@ -290,7 +290,7 @@ static void SetupHeadlessServerConsole()
{
if (AllocConsole())
{
FILE* stream = nullptr;
FILE* stream = NULL;
freopen_s(&stream, "CONIN$", "r", stdin);
freopen_s(&stream, "CONOUT$", "w", stdout);
freopen_s(&stream, "CONOUT$", "w", stderr);
@@ -491,7 +491,7 @@ HRESULT InitD3D( IDirect3DDevice9 **ppDevice,
return pD3D->CreateDevice(
0,
D3DDEVTYPE_HAL,
nullptr,
NULL,
D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_BUFFER_2_FRAMES,
pd3dPP,
ppDevice );
@@ -509,16 +509,16 @@ void MemSect(int sect)
}
#endif
HINSTANCE g_hInst = nullptr;
HWND g_hWnd = nullptr;
HINSTANCE g_hInst = NULL;
HWND g_hWnd = NULL;
D3D_DRIVER_TYPE g_driverType = D3D_DRIVER_TYPE_NULL;
D3D_FEATURE_LEVEL g_featureLevel = D3D_FEATURE_LEVEL_11_0;
ID3D11Device* g_pd3dDevice = nullptr;
ID3D11DeviceContext* g_pImmediateContext = nullptr;
IDXGISwapChain* g_pSwapChain = nullptr;
ID3D11RenderTargetView* g_pRenderTargetView = nullptr;
ID3D11DepthStencilView* g_pDepthStencilView = nullptr;
ID3D11Texture2D* g_pDepthStencilBuffer = nullptr;
ID3D11Device* g_pd3dDevice = NULL;
ID3D11DeviceContext* g_pImmediateContext = NULL;
IDXGISwapChain* g_pSwapChain = NULL;
ID3D11RenderTargetView* g_pRenderTargetView = NULL;
ID3D11DepthStencilView* g_pDepthStencilView = NULL;
ID3D11Texture2D* g_pDepthStencilBuffer = NULL;
//
// FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
@@ -586,7 +586,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
if ((lParam & 0x40000000) && vk != VK_LEFT && vk != VK_RIGHT && vk != VK_BACK)
break;
#ifdef _WINDOWS64
const Minecraft* pm = Minecraft::GetInstance();
Minecraft* pm = Minecraft::GetInstance();
ChatScreen* chat = pm && pm->screen ? dynamic_cast<ChatScreen*>(pm->screen) : nullptr;
if (chat)
{
@@ -653,13 +653,13 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_INPUT:
{
UINT dwSize = 0;
GetRawInputData((HRAWINPUT)lParam, RID_INPUT, nullptr, &dwSize, sizeof(RAWINPUTHEADER));
GetRawInputData((HRAWINPUT)lParam, RID_INPUT, NULL, &dwSize, sizeof(RAWINPUTHEADER));
if (dwSize > 0 && dwSize <= 256)
{
BYTE rawBuffer[256];
if (GetRawInputData((HRAWINPUT)lParam, RID_INPUT, rawBuffer, &dwSize, sizeof(RAWINPUTHEADER)) == dwSize)
{
const RAWINPUT* raw = (RAWINPUT*)rawBuffer;
RAWINPUT* raw = (RAWINPUT*)rawBuffer;
if (raw->header.dwType == RIM_TYPEMOUSE)
{
g_KBMInput.OnRawMouseDelta(raw->data.mouse.lLastX, raw->data.mouse.lLastY);
@@ -696,7 +696,7 @@ ATOM MyRegisterClass(HINSTANCE hInstance)
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, "Minecraft");
wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = "Minecraft";
wcex.lpszClassName = "MinecraftClass";
@@ -729,10 +729,10 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
0,
wr.right - wr.left, // width of the window
wr.bottom - wr.top, // height of the window
nullptr,
nullptr,
NULL,
NULL,
hInstance,
nullptr);
NULL);
if (!g_hWnd)
{
@@ -847,7 +847,7 @@ HRESULT InitDevice()
for( UINT driverTypeIndex = 0; driverTypeIndex < numDriverTypes; driverTypeIndex++ )
{
g_driverType = driverTypes[driverTypeIndex];
hr = D3D11CreateDeviceAndSwapChain( nullptr, g_driverType, nullptr, createDeviceFlags, featureLevels, numFeatureLevels,
hr = D3D11CreateDeviceAndSwapChain( NULL, g_driverType, NULL, createDeviceFlags, featureLevels, numFeatureLevels,
D3D11_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice, &g_featureLevel, &g_pImmediateContext );
if( HRESULT_SUCCEEDED( hr ) )
break;
@@ -856,7 +856,7 @@ HRESULT InitDevice()
return hr;
// Create a render target view
ID3D11Texture2D* pBackBuffer = nullptr;
ID3D11Texture2D* pBackBuffer = NULL;
hr = g_pSwapChain->GetBuffer( 0, __uuidof( ID3D11Texture2D ), ( LPVOID* )&pBackBuffer );
if( FAILED( hr ) )
return hr;
@@ -876,7 +876,7 @@ HRESULT InitDevice()
descDepth.BindFlags = D3D11_BIND_DEPTH_STENCIL;
descDepth.CPUAccessFlags = 0;
descDepth.MiscFlags = 0;
hr = g_pd3dDevice->CreateTexture2D(&descDepth, nullptr, &g_pDepthStencilBuffer);
hr = g_pd3dDevice->CreateTexture2D(&descDepth, NULL, &g_pDepthStencilBuffer);
D3D11_DEPTH_STENCIL_VIEW_DESC descDSView;
ZeroMemory(&descDSView, sizeof(descDSView));
@@ -886,7 +886,7 @@ HRESULT InitDevice()
hr = g_pd3dDevice->CreateDepthStencilView(g_pDepthStencilBuffer, &descDSView, &g_pDepthStencilView);
hr = g_pd3dDevice->CreateRenderTargetView( pBackBuffer, nullptr, &g_pRenderTargetView );
hr = g_pd3dDevice->CreateRenderTargetView( pBackBuffer, NULL, &g_pRenderTargetView );
pBackBuffer->Release();
if( FAILED( hr ) )
return hr;
@@ -895,8 +895,8 @@ HRESULT InitDevice()
// Setup the viewport
D3D11_VIEWPORT vp;
vp.Width = static_cast<FLOAT>(width);
vp.Height = static_cast<FLOAT>(height);
vp.Width = (FLOAT)width;
vp.Height = (FLOAT)height;
vp.MinDepth = 0.0f;
vp.MaxDepth = 1.0f;
vp.TopLeftX = 0;
@@ -916,7 +916,7 @@ HRESULT InitDevice()
void Render()
{
// Just clear the backbuffer
const float ClearColor[4] = { 0.0f, 0.125f, 0.3f, 1.0f }; //red,green,blue,alpha
float ClearColor[4] = { 0.0f, 0.125f, 0.3f, 1.0f }; //red,green,blue,alpha
g_pImmediateContext->ClearRenderTargetView( g_pRenderTargetView, ClearColor );
g_pSwapChain->Present( 0, 0 );
@@ -927,7 +927,7 @@ void Render()
//--------------------------------------------------------------------------------------
void ToggleFullscreen()
{
const DWORD dwStyle = GetWindowLong(g_hWnd, GWL_STYLE);
DWORD dwStyle = GetWindowLong(g_hWnd, GWL_STYLE);
if (!g_isFullscreen)
{
MONITORINFO mi = { sizeof(mi) };
@@ -946,7 +946,7 @@ void ToggleFullscreen()
{
SetWindowLong(g_hWnd, GWL_STYLE, dwStyle | WS_OVERLAPPEDWINDOW);
SetWindowPlacement(g_hWnd, &g_wpPrev);
SetWindowPos(g_hWnd, nullptr, 0, 0, 0, 0,
SetWindowPos(g_hWnd, NULL, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
}
g_isFullscreen = !g_isFullscreen;
@@ -999,7 +999,7 @@ static Minecraft* InitialiseMinecraftRuntime()
for (int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; i++)
{
IQNet::m_player[i].m_smallId = static_cast<BYTE>(i);
IQNet::m_player[i].m_smallId = (BYTE)i;
IQNet::m_player[i].m_isRemote = false;
IQNet::m_player[i].m_isHostPlayer = (i == 0);
swprintf_s(IQNet::m_player[i].m_gamertag, 32, L"Player%d", i);
@@ -1021,8 +1021,8 @@ static Minecraft* InitialiseMinecraftRuntime()
Minecraft::main();
Minecraft* pMinecraft = Minecraft::GetInstance();
if (pMinecraft == nullptr)
return nullptr;
if (pMinecraft == NULL)
return NULL;
app.InitGameSettings();
app.InitialiseTips();
@@ -1054,7 +1054,7 @@ static int HeadlessServerConsoleThreadProc(void* lpParameter)
continue;
MinecraftServer* server = MinecraftServer::getInstance();
if (server != nullptr)
if (server != NULL)
{
server->handleConsoleInput(command, server);
}
@@ -1068,7 +1068,7 @@ static int RunHeadlessServer()
SetupHeadlessServerConsole();
Settings serverSettings(new File(L"server.properties"));
const wstring configuredBindIp = serverSettings.getString(L"server-ip", L"");
wstring configuredBindIp = serverSettings.getString(L"server-ip", L"");
const char* bindIp = "*";
if (g_Win64DedicatedServerBindIP[0] != 0)
@@ -1085,8 +1085,8 @@ static int RunHeadlessServer()
printf("Starting headless server on %s:%d\n", bindIp, port);
fflush(stdout);
const Minecraft* pMinecraft = InitialiseMinecraftRuntime();
if (pMinecraft == nullptr)
Minecraft* pMinecraft = InitialiseMinecraftRuntime();
if (pMinecraft == NULL)
{
fprintf(stderr, "Failed to initialise the Minecraft runtime.\n");
return 1;
@@ -1152,13 +1152,13 @@ static int RunHeadlessServer()
printf("Type 'help' for server commands.\n");
fflush(stdout);
C4JThread* consoleThread = new C4JThread(&HeadlessServerConsoleThreadProc, nullptr, "Server console", 128 * 1024);
C4JThread* consoleThread = new C4JThread(&HeadlessServerConsoleThreadProc, NULL, "Server console", 128 * 1024);
consoleThread->Run();
MSG msg = { 0 };
while (WM_QUIT != msg.message && !app.m_bShutdown && !MinecraftServer::serverHalted())
{
if (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE))
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
@@ -1196,7 +1196,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
// 4J-Win64: set CWD to exe dir so asset paths resolve correctly
{
char szExeDir[MAX_PATH] = {};
GetModuleFileNameA(nullptr, szExeDir, MAX_PATH);
GetModuleFileNameA(NULL, szExeDir, MAX_PATH);
char *pSlash = strrchr(szExeDir, '\\');
if (pSlash) { *(pSlash + 1) = '\0'; SetCurrentDirectoryA(szExeDir); }
}
@@ -1208,7 +1208,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
// Load username from username.txt
char exePath[MAX_PATH] = {};
GetModuleFileNameA(nullptr, exePath, MAX_PATH);
GetModuleFileNameA(NULL, exePath, MAX_PATH);
char *lastSlash = strrchr(exePath, '\\');
if (lastSlash)
{
@@ -1224,7 +1224,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
char buf[128] = {};
if (fgets(buf, sizeof(buf), f))
{
int len = static_cast<int>(strlen(buf));
int len = (int)strlen(buf);
while (len > 0 && (buf[len - 1] == '\n' || buf[len - 1] == '\r' || buf[len - 1] == ' '))
{
buf[--len] = '\0';
@@ -1239,7 +1239,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
}
// Load stuff from launch options, including username
const Win64LaunchOptions launchOptions = ParseLaunchOptions();
Win64LaunchOptions launchOptions = ParseLaunchOptions();
ApplyScreenMode(launchOptions.screenMode);
// Ensure uid.dat exists from startup in client mode (before any multiplayer/login path).
@@ -1282,7 +1282,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
if (launchOptions.serverMode)
{
const int serverResult = RunHeadlessServer();
int serverResult = RunHeadlessServer();
CleanupDevice();
return serverResult;
}
@@ -1292,7 +1292,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
MSG msg = {0};
while( WM_QUIT != msg.message )
{
if( PeekMessage( &msg, nullptr, 0, 0, PM_REMOVE ) )
if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
@@ -1340,7 +1340,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
#endif
Minecraft *pMinecraft = InitialiseMinecraftRuntime();
if (pMinecraft == nullptr)
if (pMinecraft == NULL)
{
CleanupDevice();
return 1;
@@ -1376,7 +1376,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
{
g_KBMInput.Tick();
while( PeekMessage( &msg, nullptr, 0, 0, PM_REMOVE ) )
while( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
@@ -1409,7 +1409,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
// Detect KBM vs controller input mode
if (InputManager.IsPadConnected(0))
{
const bool controllerUsed = InputManager.ButtonPressed(0) ||
bool controllerUsed = InputManager.ButtonPressed(0) ||
InputManager.GetJoypadStick_LX(0, false) != 0.0f ||
InputManager.GetJoypadStick_LY(0, false) != 0.0f ||
InputManager.GetJoypadStick_RX(0, false) != 0.0f ||
@@ -1471,7 +1471,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
else
{
MemSect(28);
pMinecraft->soundEngine->tick(nullptr, 0.0f);
pMinecraft->soundEngine->tick(NULL, 0.0f);
MemSect(0);
pMinecraft->textures->tick(true,false);
IntCache::Reset();
@@ -1568,7 +1568,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
// Update mouse grab: grab when in-game and no menu is open
{
static bool altToggleSuppressCapture = false;
const bool shouldCapture = app.GetGameStarted() && !ui.GetMenuDisplayed(0) && pMinecraft->screen == nullptr;
bool shouldCapture = app.GetGameStarted() && !ui.GetMenuDisplayed(0) && pMinecraft->screen == NULL;
// Left Alt key toggles capture on/off for debugging
if (g_KBMInput.IsKeyPressed(VK_LMENU) || g_KBMInput.IsKeyPressed(VK_RMENU))
{
@@ -1589,8 +1589,8 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
// F1 toggles the HUD
if (g_KBMInput.IsKeyPressed(VK_F1))
{
const int primaryPad = ProfileManager.GetPrimaryPad();
const unsigned char displayHud = app.GetGameSettings(primaryPad, eGameSetting_DisplayHUD);
int primaryPad = ProfileManager.GetPrimaryPad();
unsigned char displayHud = app.GetGameSettings(primaryPad, eGameSetting_DisplayHUD);
app.SetGameSettings(primaryPad, eGameSetting_DisplayHUD, displayHud ? 0 : 1);
app.SetGameSettings(primaryPad, eGameSetting_DisplayHand, displayHud ? 0 : 1);
}
@@ -1598,7 +1598,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
// F3 toggles onscreen debug info
if (g_KBMInput.IsKeyPressed(VK_F3))
{
if (const Minecraft* pMinecraft = Minecraft::GetInstance())
if (Minecraft* pMinecraft = Minecraft::GetInstance())
{
if (pMinecraft->options)
{