mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-08-20 09:57:09 +00:00
-ip and -port launch options now add the ip to the server list and fixed dangling pointers
This commit is contained in:
parent
4e1121cf07
commit
e7eaa60fa8
|
|
@ -5,7 +5,6 @@
|
||||||
#include "..\..\Xbox\Network\NetworkPlayerXbox.h"
|
#include "..\..\Xbox\Network\NetworkPlayerXbox.h"
|
||||||
#ifdef _WINDOWS64
|
#ifdef _WINDOWS64
|
||||||
#include "..\..\Windows64\Network\WinsockNetLayer.h"
|
#include "..\..\Windows64\Network\WinsockNetLayer.h"
|
||||||
#include "..\..\Windows64\Windows64_Xuid.h"
|
|
||||||
#include "..\..\Minecraft.h"
|
#include "..\..\Minecraft.h"
|
||||||
#include "..\..\User.h"
|
#include "..\..\User.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
@ -235,7 +234,6 @@ void CPlatformNetworkManagerStub::DoWork()
|
||||||
qnetPlayer->m_smallId = 0;
|
qnetPlayer->m_smallId = 0;
|
||||||
qnetPlayer->m_isRemote = false;
|
qnetPlayer->m_isRemote = false;
|
||||||
qnetPlayer->m_isHostPlayer = false;
|
qnetPlayer->m_isHostPlayer = false;
|
||||||
qnetPlayer->m_resolvedXuid = INVALID_XUID;
|
|
||||||
qnetPlayer->m_gamertag[0] = 0;
|
qnetPlayer->m_gamertag[0] = 0;
|
||||||
qnetPlayer->SetCustomDataValue(0);
|
qnetPlayer->SetCustomDataValue(0);
|
||||||
WinsockNetLayer::PushFreeSmallId(disconnectedSmallId);
|
WinsockNetLayer::PushFreeSmallId(disconnectedSmallId);
|
||||||
|
|
@ -356,9 +354,7 @@ void CPlatformNetworkManagerStub::HostGame(int localUsersMask, bool bOnlineGame,
|
||||||
#ifdef _WINDOWS64
|
#ifdef _WINDOWS64
|
||||||
IQNet::m_player[0].m_smallId = 0;
|
IQNet::m_player[0].m_smallId = 0;
|
||||||
IQNet::m_player[0].m_isRemote = false;
|
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_isHostPlayer = true;
|
||||||
IQNet::m_player[0].m_resolvedXuid = Win64Xuid::GetLegacyEmbeddedHostXuid();
|
|
||||||
IQNet::s_playerCount = 1;
|
IQNet::s_playerCount = 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -415,8 +411,6 @@ int CPlatformNetworkManagerStub::JoinGame(FriendSessionInfo* searchResult, int l
|
||||||
IQNet::m_player[0].m_smallId = 0;
|
IQNet::m_player[0].m_smallId = 0;
|
||||||
IQNet::m_player[0].m_isRemote = true;
|
IQNet::m_player[0].m_isRemote = true;
|
||||||
IQNet::m_player[0].m_isHostPlayer = 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);
|
wcsncpy_s(IQNet::m_player[0].m_gamertag, 32, searchResult->data.hostName, _TRUNCATE);
|
||||||
|
|
||||||
WinsockNetLayer::StopDiscovery();
|
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_smallId = localSmallId;
|
||||||
IQNet::m_player[localSmallId].m_isRemote = false;
|
IQNet::m_player[localSmallId].m_isRemote = false;
|
||||||
IQNet::m_player[localSmallId].m_isHostPlayer = 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();
|
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||||
wcscpy_s(IQNet::m_player[localSmallId].m_gamertag, 32, pMinecraft->user->name.c_str());
|
wcscpy_s(IQNet::m_player[localSmallId].m_gamertag, 32, pMinecraft->user->name.c_str());
|
||||||
|
|
@ -788,6 +780,25 @@ void CPlatformNetworkManagerStub::SearchForGames()
|
||||||
std::fclose(file);
|
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<uint64_t>(inet_addr(g_Win64MultiplayerIP)) | (static_cast<uint64_t>(g_Win64MultiplayerPort) << 32));
|
||||||
|
friendsSessions[0].push_back(info);
|
||||||
|
}
|
||||||
|
|
||||||
m_searchResultsCount[0] = (int)friendsSessions[0].size();
|
m_searchResultsCount[0] = (int)friendsSessions[0].size();
|
||||||
|
|
||||||
if (m_SessionsUpdatedCallback != NULL)
|
if (m_SessionsUpdatedCallback != NULL)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,3 @@
|
||||||
// Minecraft.cpp : Defines the entry point for the application.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
@ -22,9 +19,6 @@
|
||||||
#include "..\..\Minecraft.World\net.minecraft.world.level.tile.h"
|
#include "..\..\Minecraft.World\net.minecraft.world.level.tile.h"
|
||||||
|
|
||||||
#include "..\ClientConnection.h"
|
#include "..\ClientConnection.h"
|
||||||
#include "..\Minecraft.h"
|
|
||||||
#include "..\ChatScreen.h"
|
|
||||||
#include "KeyboardMouseInput.h"
|
|
||||||
#include "..\User.h"
|
#include "..\User.h"
|
||||||
#include "..\..\Minecraft.World\Socket.h"
|
#include "..\..\Minecraft.World\Socket.h"
|
||||||
#include "..\..\Minecraft.World\ThreadName.h"
|
#include "..\..\Minecraft.World\ThreadName.h"
|
||||||
|
|
@ -45,7 +39,6 @@
|
||||||
#include "..\..\Minecraft.World\OldChunkStorage.h"
|
#include "..\..\Minecraft.World\OldChunkStorage.h"
|
||||||
#include "Common/PostProcesser.h"
|
#include "Common/PostProcesser.h"
|
||||||
#include "Network\WinsockNetLayer.h"
|
#include "Network\WinsockNetLayer.h"
|
||||||
#include "Windows64_Xuid.h"
|
|
||||||
|
|
||||||
#include "Xbox/resource.h"
|
#include "Xbox/resource.h"
|
||||||
|
|
||||||
|
|
@ -575,28 +568,14 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
case WM_CHAR:
|
case WM_CHAR:
|
||||||
// Buffer typed characters so UIScene_Keyboard can dispatch them to the Iggy Flash player
|
// 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
|
if (wParam >= 0x20 || wParam == 0x08 || wParam == 0x0D) // printable chars + backspace + enter
|
||||||
g_KBMInput.OnChar(static_cast<wchar_t>(wParam));
|
g_KBMInput.OnChar((wchar_t)wParam);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_KEYDOWN:
|
case WM_KEYDOWN:
|
||||||
case WM_SYSKEYDOWN:
|
case WM_SYSKEYDOWN:
|
||||||
{
|
{
|
||||||
int vk = static_cast<int>(wParam);
|
int vk = (int)wParam;
|
||||||
if ((lParam & 0x40000000) && vk != VK_LEFT && vk != VK_RIGHT && vk != VK_BACK)
|
if (lParam & 0x40000000) break; // ignore auto-repeat
|
||||||
break;
|
|
||||||
#ifdef _WINDOWS64
|
|
||||||
Minecraft* pm = Minecraft::GetInstance();
|
|
||||||
ChatScreen* chat = pm && pm->screen ? dynamic_cast<ChatScreen*>(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
|
|
||||||
if (vk == VK_SHIFT)
|
if (vk == VK_SHIFT)
|
||||||
vk = (MapVirtualKey((lParam >> 16) & 0xFF, MAPVK_VSC_TO_VK_EX) == VK_RSHIFT) ? VK_RSHIFT : VK_LSHIFT;
|
vk = (MapVirtualKey((lParam >> 16) & 0xFF, MAPVK_VSC_TO_VK_EX) == VK_RSHIFT) ? VK_RSHIFT : VK_LSHIFT;
|
||||||
else if (vk == VK_CONTROL)
|
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_KEYUP:
|
||||||
case WM_SYSKEYUP:
|
case WM_SYSKEYUP:
|
||||||
{
|
{
|
||||||
int vk = static_cast<int>(wParam);
|
int vk = (int)wParam;
|
||||||
if (vk == VK_SHIFT)
|
if (vk == VK_SHIFT)
|
||||||
vk = (MapVirtualKey((lParam >> 16) & 0xFF, MAPVK_VSC_TO_VK_EX) == VK_RSHIFT) ? VK_RSHIFT : VK_LSHIFT;
|
vk = (MapVirtualKey((lParam >> 16) & 0xFF, MAPVK_VSC_TO_VK_EX) == VK_RSHIFT) ? VK_RSHIFT : VK_LSHIFT;
|
||||||
else if (vk == VK_CONTROL)
|
else if (vk == VK_CONTROL)
|
||||||
|
|
@ -1007,6 +986,10 @@ static Minecraft* InitialiseMinecraftRuntime()
|
||||||
|
|
||||||
ProfileManager.SetDebugFullOverride(true);
|
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);
|
Tesselator::CreateNewThreadStorage(1024 * 1024);
|
||||||
AABB::CreateNewThreadStorage();
|
AABB::CreateNewThreadStorage();
|
||||||
Vec3::CreateNewThreadStorage();
|
Vec3::CreateNewThreadStorage();
|
||||||
|
|
@ -1239,12 +1222,6 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||||
Win64LaunchOptions launchOptions = ParseLaunchOptions();
|
Win64LaunchOptions launchOptions = ParseLaunchOptions();
|
||||||
ApplyScreenMode(launchOptions.screenMode);
|
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 no username, let's fall back
|
||||||
if (g_Win64Username[0] == 0)
|
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
|
#if 0
|
||||||
// has the game defined profile data been changed (by a profile load)
|
// has the game defined profile data been changed (by a profile load)
|
||||||
if(app.uiGameDefinedDataChangedBitmask!=0)
|
if(app.uiGameDefinedDataChangedBitmask!=0)
|
||||||
|
|
|
||||||
0
data.hostIP)
Normal file
0
data.hostIP)
Normal file
0
data.hostPort
Normal file
0
data.hostPort
Normal file
0
data.isJoinable
Normal file
0
data.isJoinable
Normal file
0
data.isReadyToJoin
Normal file
0
data.isReadyToJoin
Normal file
0
displayLabel
Normal file
0
displayLabel
Normal file
0
displayLabelLength
Normal file
0
displayLabelLength
Normal file
0
displayLabelViewableStartIndex
Normal file
0
displayLabelViewableStartIndex
Normal file
0
writeFile(
Normal file
0
writeFile(
Normal file
58
yo.patch
Normal file
58
yo.patch
Normal file
|
|
@ -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<uint64_t>(inet_addr(g_Win64MultiplayerIP)) | (static_cast<uint64_t>(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
|
||||||
|
);
|
||||||
Loading…
Reference in a new issue