From 8a48e6dcc3790c23bad43bb57045ccbd62758672 Mon Sep 17 00:00:00 2001 From: NOTPIES Date: Wed, 4 Mar 2026 21:09:02 -0300 Subject: [PATCH] feat: add missing commandline implementations --- .../Network/PlatformNetworkManagerStub.cpp | 27 +++++++++++++++++++ .../Windows64/Windows64_Minecraft.cpp | 26 ++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/Minecraft.Client/Common/Network/PlatformNetworkManagerStub.cpp b/Minecraft.Client/Common/Network/PlatformNetworkManagerStub.cpp index 0a69cd6..932c0bb 100644 --- a/Minecraft.Client/Common/Network/PlatformNetworkManagerStub.cpp +++ b/Minecraft.Client/Common/Network/PlatformNetworkManagerStub.cpp @@ -705,6 +705,33 @@ void CPlatformNetworkManagerStub::SearchForGames() #ifdef _WINDOWS64 std::vector lanSessions = WinsockNetLayer::GetDiscoveredSessions(); + if (g_Win64MultiplayerJoin) + { + bool alreadyPresent = false; + for (size_t i = 0; i < lanSessions.size(); i++) + { + if (strcmp(lanSessions[i].hostIP, g_Win64MultiplayerIP) == 0 && + lanSessions[i].hostPort == g_Win64MultiplayerPort) + { + alreadyPresent = true; + break; + } + } + if (!alreadyPresent) + { + Win64LANSession manual; + memset(&manual, 0, sizeof(manual)); + strncpy_s(manual.hostIP, sizeof(manual.hostIP), g_Win64MultiplayerIP, _TRUNCATE); + manual.hostPort = g_Win64MultiplayerPort; + swprintf_s(manual.hostName, 32, L"%hs:%d", g_Win64MultiplayerIP, g_Win64MultiplayerPort); + manual.playerCount = 0; + manual.maxPlayers = MINECRAFT_NET_MAX_PLAYERS; + manual.isJoinable = true; + manual.lastSeenTick = GetTickCount(); + lanSessions.push_back(manual); + } + } + for (size_t i = 0; i < friendsSessions[0].size(); i++) delete friendsSessions[0][i]; friendsSessions[0].clear(); diff --git a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp index 4f6fac6..072b143 100644 --- a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp +++ b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp @@ -807,6 +807,32 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, nameBuf[n] = 0; strncpy_s(g_Win64Username, 17, nameBuf, _TRUNCATE); } + + char *ipArg = strstr(cmdLineA, "-ip "); + if (ipArg) + { + ipArg += 4; + while (*ipArg == ' ') ipArg++; + char ipBuf[256]; + int n = 0; + while (ipArg[n] && ipArg[n] != ' ' && n < 255) { ipBuf[n] = ipArg[n]; n++; } + ipBuf[n] = 0; + strncpy_s(g_Win64MultiplayerIP, 256, ipBuf, _TRUNCATE); + g_Win64MultiplayerJoin = true; + } + + char *portArg = strstr(cmdLineA, "-port "); + if (portArg) + { + portArg += 6; + while (*portArg == ' ') portArg++; + char portBuf[16]; + int n = 0; + while (portArg[n] && portArg[n] != ' ' && n < 15) { portBuf[n] = portArg[n]; n++; } + portBuf[n] = 0; + g_Win64MultiplayerPort = atoi(portBuf); + if (g_Win64MultiplayerPort <= 0) g_Win64MultiplayerPort = WIN64_NET_DEFAULT_PORT; + } } if (g_Win64Username[0] == 0)