diff --git a/Minecraft.Client/Common/Network/PlatformNetworkManagerStub.cpp b/Minecraft.Client/Common/Network/PlatformNetworkManagerStub.cpp index 80fbd98cf..9bfb27abe 100644 --- a/Minecraft.Client/Common/Network/PlatformNetworkManagerStub.cpp +++ b/Minecraft.Client/Common/Network/PlatformNetworkManagerStub.cpp @@ -5,7 +5,6 @@ #include "..\..\Xbox\Network\NetworkPlayerXbox.h" #ifdef _WINDOWS64 #include "..\..\Windows64\Network\WinsockNetLayer.h" -#include "..\..\Windows64\Windows64_Xuid.h" #include "..\..\Minecraft.h" #include "..\..\User.h" #include @@ -235,7 +234,6 @@ void CPlatformNetworkManagerStub::DoWork() qnetPlayer->m_smallId = 0; qnetPlayer->m_isRemote = false; qnetPlayer->m_isHostPlayer = false; - qnetPlayer->m_resolvedXuid = INVALID_XUID; qnetPlayer->m_gamertag[0] = 0; qnetPlayer->SetCustomDataValue(0); WinsockNetLayer::PushFreeSmallId(disconnectedSmallId); @@ -356,9 +354,7 @@ void CPlatformNetworkManagerStub::HostGame(int localUsersMask, bool bOnlineGame, #ifdef _WINDOWS64 IQNet::m_player[0].m_smallId = 0; IQNet::m_player[0].m_isRemote = false; - // world host is pinned to legacy host XUID to keep old player data compatibility. IQNet::m_player[0].m_isHostPlayer = true; - IQNet::m_player[0].m_resolvedXuid = Win64Xuid::GetLegacyEmbeddedHostXuid(); IQNet::s_playerCount = 1; #endif @@ -415,8 +411,6 @@ int CPlatformNetworkManagerStub::JoinGame(FriendSessionInfo* searchResult, int l IQNet::m_player[0].m_smallId = 0; IQNet::m_player[0].m_isRemote = true; IQNet::m_player[0].m_isHostPlayer = true; - // Remote host still maps to legacy host XUID in mixed old/new sessions. - IQNet::m_player[0].m_resolvedXuid = Win64Xuid::GetLegacyEmbeddedHostXuid(); wcsncpy_s(IQNet::m_player[0].m_gamertag, 32, searchResult->data.hostName, _TRUNCATE); WinsockNetLayer::StopDiscovery(); @@ -432,8 +426,6 @@ int CPlatformNetworkManagerStub::JoinGame(FriendSessionInfo* searchResult, int l IQNet::m_player[localSmallId].m_smallId = localSmallId; IQNet::m_player[localSmallId].m_isRemote = false; IQNet::m_player[localSmallId].m_isHostPlayer = false; - // Local non-host identity is the persistent uid.dat XUID. - IQNet::m_player[localSmallId].m_resolvedXuid = Win64Xuid::ResolvePersistentXuid(); Minecraft* pMinecraft = Minecraft::GetInstance(); wcscpy_s(IQNet::m_player[localSmallId].m_gamertag, 32, pMinecraft->user->name.c_str()); @@ -788,6 +780,25 @@ void CPlatformNetworkManagerStub::SearchForGames() std::fclose(file); } + // -ip launch argument: add to session list so it appears in Join Game + if (g_Win64MultiplayerJoin && g_Win64MultiplayerIP[0] != 0) + { + FriendSessionInfo* info = new FriendSessionInfo(); + wchar_t label[128]; + swprintf_s(label, 128, L"%hs:%d", g_Win64MultiplayerIP, g_Win64MultiplayerPort); + size_t nameLen = wcslen(label); + info->displayLabel = new wchar_t[nameLen + 1]; + wcscpy_s(info->displayLabel, nameLen + 1, label); + info->displayLabelLength = (unsigned char)nameLen; + info->displayLabelViewableStartIndex = 0; + info->data.isReadyToJoin = true; + info->data.isJoinable = true; + strncpy_s(info->data.hostIP, sizeof(info->data.hostIP), g_Win64MultiplayerIP, _TRUNCATE); + info->data.hostPort = g_Win64MultiplayerPort; + info->sessionId = (SessionID)(static_cast(inet_addr(g_Win64MultiplayerIP)) | (static_cast(g_Win64MultiplayerPort) << 32)); + friendsSessions[0].push_back(info); + } + m_searchResultsCount[0] = (int)friendsSessions[0].size(); if (m_SessionsUpdatedCallback != NULL) @@ -931,4 +942,4 @@ bool CPlatformNetworkManagerStub::IsInGameplay() bool CPlatformNetworkManagerStub::IsReadyToPlayOrIdle() { return true; -} +} \ No newline at end of file diff --git a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp index 208fd3f7d..864820aff 100644 --- a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp +++ b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp @@ -1,6 +1,3 @@ -// Minecraft.cpp : Defines the entry point for the application. -// - #include "stdafx.h" #include @@ -22,9 +19,6 @@ #include "..\..\Minecraft.World\net.minecraft.world.level.tile.h" #include "..\ClientConnection.h" -#include "..\Minecraft.h" -#include "..\ChatScreen.h" -#include "KeyboardMouseInput.h" #include "..\User.h" #include "..\..\Minecraft.World\Socket.h" #include "..\..\Minecraft.World\ThreadName.h" @@ -45,7 +39,6 @@ #include "..\..\Minecraft.World\OldChunkStorage.h" #include "Common/PostProcesser.h" #include "Network\WinsockNetLayer.h" -#include "Windows64_Xuid.h" #include "Xbox/resource.h" @@ -575,28 +568,14 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) case WM_CHAR: // Buffer typed characters so UIScene_Keyboard can dispatch them to the Iggy Flash player if (wParam >= 0x20 || wParam == 0x08 || wParam == 0x0D) // printable chars + backspace + enter - g_KBMInput.OnChar(static_cast(wParam)); + g_KBMInput.OnChar((wchar_t)wParam); break; case WM_KEYDOWN: case WM_SYSKEYDOWN: { - int vk = static_cast(wParam); - if ((lParam & 0x40000000) && vk != VK_LEFT && vk != VK_RIGHT && vk != VK_BACK) - break; -#ifdef _WINDOWS64 - Minecraft* pm = Minecraft::GetInstance(); - ChatScreen* chat = pm && pm->screen ? dynamic_cast(pm->screen) : nullptr; - if (chat) - { - if (vk == 'V' && (GetKeyState(VK_CONTROL) & 0x8000)) - { chat->handlePasteRequest(); break; } - if ((vk == VK_UP || vk == VK_DOWN) && !(lParam & 0x40000000)) - { if (vk == VK_UP) chat->handleHistoryUp(); else chat->handleHistoryDown(); break; } - if (vk >= '1' && vk <= '9') // Prevent hotkey conflicts - break; - } -#endif + int vk = (int)wParam; + if (lParam & 0x40000000) break; // ignore auto-repeat if (vk == VK_SHIFT) vk = (MapVirtualKey((lParam >> 16) & 0xFF, MAPVK_VSC_TO_VK_EX) == VK_RSHIFT) ? VK_RSHIFT : VK_LSHIFT; else if (vk == VK_CONTROL) @@ -609,7 +588,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) case WM_KEYUP: case WM_SYSKEYUP: { - int vk = static_cast(wParam); + int vk = (int)wParam; if (vk == VK_SHIFT) vk = (MapVirtualKey((lParam >> 16) & 0xFF, MAPVK_VSC_TO_VK_EX) == VK_RSHIFT) ? VK_RSHIFT : VK_LSHIFT; else if (vk == VK_CONTROL) @@ -1007,6 +986,10 @@ static Minecraft* InitialiseMinecraftRuntime() ProfileManager.SetDebugFullOverride(true); + // Initialise storage manager — was accidentally left inside #if 0 in original code + StorageManager.Init(0, app.GetString(IDS_DEFAULT_SAVENAME), "savegame.dat", FIFTY_ONE_MB, &CConsoleMinecraftApp::DisplaySavingMessage, (LPVOID)&app, ""); + StorageManager.StoreTMSPathName(); + Tesselator::CreateNewThreadStorage(1024 * 1024); AABB::CreateNewThreadStorage(); Vec3::CreateNewThreadStorage(); @@ -1239,12 +1222,6 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, Win64LaunchOptions launchOptions = ParseLaunchOptions(); ApplyScreenMode(launchOptions.screenMode); - // Ensure uid.dat exists from startup in client mode (before any multiplayer/login path). - if (!launchOptions.serverMode) - { - Win64Xuid::ResolvePersistentXuid(); - } - // If no username, let's fall back if (g_Win64Username[0] == 0) { @@ -1629,14 +1606,6 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, } } - // Open chat - if (g_KBMInput.IsKeyPressed('T') && app.GetGameStarted() && !ui.GetMenuDisplayed(0) && pMinecraft->screen == NULL) - { - g_KBMInput.ClearCharBuffer(); - pMinecraft->setScreen(new ChatScreen()); - SetFocus(g_hWnd); - } - #if 0 // has the game defined profile data been changed (by a profile load) if(app.uiGameDefinedDataChangedBitmask!=0) @@ -1921,4 +1890,4 @@ void MemPixStuff() PIXAddNamedCounter(((float)allSectsTotal)/(4096.0f),"MemSect total pages"); } -#endif +#endif \ No newline at end of file diff --git a/data.hostIP) b/data.hostIP) new file mode 100644 index 000000000..e69de29bb diff --git a/data.hostPort b/data.hostPort new file mode 100644 index 000000000..e69de29bb diff --git a/data.isJoinable b/data.isJoinable new file mode 100644 index 000000000..e69de29bb diff --git a/data.isReadyToJoin b/data.isReadyToJoin new file mode 100644 index 000000000..e69de29bb diff --git a/displayLabel b/displayLabel new file mode 100644 index 000000000..e69de29bb diff --git a/displayLabelLength b/displayLabelLength new file mode 100644 index 000000000..e69de29bb diff --git a/displayLabelViewableStartIndex b/displayLabelViewableStartIndex new file mode 100644 index 000000000..e69de29bb diff --git a/writeFile( b/writeFile( new file mode 100644 index 000000000..e69de29bb diff --git a/yo.patch b/yo.patch new file mode 100644 index 000000000..d4b9c66b3 --- /dev/null +++ b/yo.patch @@ -0,0 +1,58 @@ +diff --git a/Minecraft.Client/Common/Network/PlatformNetworkManagerStub.cpp b/Minecraft.Client/Common/Network/PlatformNetworkManagerStub.cpp +index 85531e47..0611cb7e 100644 +--- a/Minecraft.Client/Common/Network/PlatformNetworkManagerStub.cpp ++++ b/Minecraft.Client/Common/Network/PlatformNetworkManagerStub.cpp +@@ -780,7 +780,26 @@ void CPlatformNetworkManagerStub::SearchForGames() + std::fclose(file); + } + ++ // -ip launch argument: add to session list so it appears in Join Game ++ if (g_Win64MultiplayerJoin && g_Win64MultiplayerIP[0] != 0) ++ { ++ FriendSessionInfo* info = new FriendSessionInfo(); ++ wchar_t label[128]; ++ swprintf_s(label, 128, L"%hs:%d", g_Win64MultiplayerIP, g_Win64MultiplayerPort); ++ size_t nameLen = wcslen(label); ++ info->displayLabel = new wchar_t[nameLen + 1]; ++ wcscpy_s(info->displayLabel, nameLen + 1, label); ++ info->displayLabelLength = (unsigned char)nameLen; ++ info->displayLabelViewableStartIndex = 0; ++ info->data.isReadyToJoin = true; ++ info->data.isJoinable = true; ++ strncpy_s(info->data.hostIP, sizeof(info->data.hostIP), g_Win64MultiplayerIP, _TRUNCATE); ++ info->data.hostPort = g_Win64MultiplayerPort; ++ info->sessionId = (SessionID)(static_cast(inet_addr(g_Win64MultiplayerIP)) | (static_cast(g_Win64MultiplayerPort) << 32)); ++ friendsSessions[0].push_back(info); ++ } ++ + m_searchResultsCount[0] = (int)friendsSessions[0].size(); + + if (m_SessionsUpdatedCallback != NULL) +diff --git a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp +index 1146b86d..f7072c1d 100644 +--- a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp ++++ b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp +@@ -989,6 +989,10 @@ static Minecraft* InitialiseMinecraftRuntime() + + ProfileManager.SetDebugFullOverride(true); + ++ // Initialise storage manager — was accidentally left inside #if 0 in original code ++ StorageManager.Init(0, app.GetString(IDS_DEFAULT_SAVENAME), "savegame.dat", FIFTY_ONE_MB, &CConsoleMinecraftApp::DisplaySavingMessage, (LPVOID)&app, ""); ++ StorageManager.StoreTMSPathName(); ++ + Tesselator::CreateNewThreadStorage(1024 * 1024); + AABB::CreateNewThreadStorage(); + Vec3::CreateNewThreadStorage(); +diff --git a/Minecraft.World/ConsoleSaveFileOutputStream.cpp b/Minecraft.World/ConsoleSaveFileOutputStream.cpp +index 3d8bb3f7..3fd9c0c5 100644 +--- a/Minecraft.World/ConsoleSaveFileOutputStream.cpp ++++ b/Minecraft.World/ConsoleSaveFileOutputStream.cpp +@@ -66,7 +66,7 @@ void ConsoleSaveFileOutputStream::write(byteArray b) + + BOOL result = m_saveFile->writeFile( + m_file, +- &b.data, // data buffer ++ b.data, // data buffer + b.length, // number of bytes to write + &numberOfBytesWritten // number of bytes written + ); \ No newline at end of file